The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/showthread.php 26 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/showthread.php 137 forum_permissions
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key "mybb" - Line: 1952 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1952 errorHandler->error
/inc/functions_indicators.php 41 my_set_array_cookie
/showthread.php 629 mark_thread_read
Warning [2] Undefined property: MyLanguage::$ratings_update_error - Line: 5 - File: showthread.php(732) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(732) : eval()'d code 5 errorHandler->error
/showthread.php 732 eval
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "invisible" - Line: 1506 - File: showthread.php PHP 8.1.27 (Linux)
File Line Function
/showthread.php 1506 errorHandler->error
Warning [2] Undefined variable $threadnotesbox - Line: 30 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 30 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $addremovesubscription - Line: 79 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 79 errorHandler->error
/showthread.php 1533 eval



FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Last Updated By Field
#1
I would suggest creating a field that shows "Last Updated By:" and the name of the account holder that updated the entry.

Although the submission history is great, I can't pull that info out of the database and display it on a web page. For example, I pull the content of the database entry out, and display it on a web page. I would like to have a field that shows "Last Updated by John Doe on 9/21/2011 at 0000 hours." I can already do the time part by using the modified date and time.. but can't pull that user's name out.

Alex
Reply
#2
Yeah, that would be a nice feature. But I think I'd just extend the module to return that info if requested (e.g. sh_get_last_updated_info($submission_id)).

Is this something you already do on your own site (I mean, display the submission data)?

- Ben
Reply
#3
Ben - that would work perfect. Yes, - it's the press release application you helped me with. :-)


(Sep 22nd, 2011, 1:19 PM)Ben Wrote: Yeah, that would be a nice feature. But I think I'd just extend the module to return that info if requested (e.g. sh_get_last_updated_info($submission_id)).

Is this something you already do on your own site (I mean, display the submission data)?

- Ben

Reply
#4
Hey Alex,

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
Reply
#5
Thanks Ben! So I added the code your provided to the general.php file, and then added this to the php file I want to display the info:

Code:
<?php require_once('/path/to/global/library.php');
ft_include_module("submission_history");
$form_id = form_16;
$submission_id = id;
$last_modified_info = sh_get_last_modified_info($form_id, $submission_id);
?>

(I updated the path, and the form_id to the correct value. "id" will be obtained from the url, test.php?id=1)

So, there are no errors on the page. yay! But now to print the info I need on the page...so I would assume

Code:
echo $last_modified_info["first_name"];

Of course, with my limited (but learning!) php knowledge, I have missed something.. because nothing is displayed :-)



(Sep 25th, 2011, 8:51 PM)Ben Wrote: Hey Alex,

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

Reply
#6
Hey Alex,

Was this exactly as you added it to your page?

PHP Code:
$form_id form_16;
$submission_id id

If so, change the first line to read:
PHP Code:
$form_id 16

For the second line, do you have the ID in a variable? If so, include the variable name with the dollar sign:
PHP Code:
$submission_id $id

(or just pass the variable directly to the function).

One other tip: add this at the very end. That will output everything in the returned value. It should contain one array key, at least!
PHP Code:
print_r($last_modified_info); 

Let me know how it goes!

- Ben
Reply
#7
Aha!

Now it prints all the good stuff!

Quote:Array ( [has_been_modified] => 1 [account_type] => admin [account_id] => 1 [first_name] => Alex [last_name] => H )


(Sep 29th, 2011, 11:12 AM)Ben Wrote: Hey Alex,

Was this exactly as you added it to your page?

PHP Code:
$form_id form_16;
$submission_id id

If so, change the first line to read:
PHP Code:
$form_id 16

For the second line, do you have the ID in a variable? If so, include the variable name with the dollar sign:
PHP Code:
$submission_id $id

(or just pass the variable directly to the function).

One other tip: add this at the very end. That will output everything in the returned value. It should contain one array key, at least!
PHP Code:
print_r($last_modified_info); 

Let me know how it goes!

- Ben

Reply
#8
Ok, so this is working great! Thank you so much! Can I pull something from an extended client field?

Also - if a user CREATES the entry from within formtools (Logged in, and not thru an external form), does that make has_been_modified == 1? Or will it still be == 0 until it is modified again?


Alex
Reply
#9
I just upgraded, and noticed that I was getting a bunch of fatal errors on some of my pages. I had to re-add the code to the bottom of the /modules/submission_history/global/code/general.php file. Will this code be added to future versions so I don't have to keep adding it?


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;
}
Reply
#10
Oh drat, I totally forgot to add that function in.

[EDIT: I just released 1.1.3 of the Submission History module. Just download that and you're all set!]

- Ben
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)