Hey Alex,
Sorry! Brain like a sieve.
Here: just add this function to the bottom of your /modules/submission_history/code/general.php file:
Then, to call it, just add this code to your PHP page (the first line is only necessary if you haven't already included the API or library.php file):
Then, $last_modified_info contains all the important details about who last modified it.
Here's what it contains:
Let me know how it goes. If all looks good, I'll add it to the next version of the module!
- Ben
Sorry! Brain like a sieve.
Here: just add this function to the bottom of your /modules/submission_history/code/general.php file:
PHP Code:
/**
* This returns information about who last modified the submission. Added in 1.1.2.
*
* @param integer $form_id
* @param integer $submission_id
* @return array has_history - true/false
* account_type - admin/client/unknown
* account_id - the ID of the admin/client
* first_name - the admin/client last name
* last_name - the admin/client last name
*/
function sh_get_last_modified_info($form_id, $submission_id)
{
global $g_table_prefix;
$query = mysql_query("
SELECT sh___change_account_type, sh___change_account_id
FROM {$g_table_prefix}form_{$form_id}_history
WHERE submission_id = $submission_id
ORDER BY sh___history_id DESC
LIMIT 1
");
$return_info = array("has_been_modified" => false);
if (mysql_num_rows($query) == 0)
{
return $return_info;
}
$result = mysql_fetch_assoc($query);
$return_info = array(
"has_been_modified" => true,
"account_type" => $result["sh___change_account_type"],
"account_id" => $result["sh___change_account_id"]
);
if (is_numeric($result["sh___change_account_id"]))
{
$account_info = ft_get_account_info($result["sh___change_account_id"]);
$return_info["first_name"] = $account_info["first_name"];
$return_info["last_name"] = $account_info["last_name"];
}
return $return_info;
}
Then, to call it, just add this code to your PHP page (the first line is only necessary if you haven't already included the API or library.php file):
PHP Code:
require_once('path/to/global/library.php');
ft_include_module("submission_history");
$form_id = 123;
$submission_id = 456;
$last_modified_info = sh_get_last_modified_info($form_id, $submission_id);
Then, $last_modified_info contains all the important details about who last modified it.
Here's what it contains:
PHP Code:
// boolean. This will contain "true" if there's a record in the history table; false otherwise.
$last_modified_info["has_been_modified"];
// *** the following keys are only populated if has_been_modified == true
// string. this contains "admin", "client" or "unknown"
$last_modified_info["account_type"];
// integer. This only has a value if account_type == "admin" or "client"
$last_modified_info["account_id"];
// strings. These are only populated if account_type == "admin" or "client"
$last_modified_info["first_name"];
$last_modified_info["last_name"];
Let me know how it goes. If all looks good, I'll add it to the next version of the module!
- Ben