allow to instanciate the historylog with a given user or 0 for

changes by the system itself (eg. async service). bo_tracking passes on
it's user param of the constructor.
This commit is contained in:
Ralf Becker 2008-05-27 09:25:25 +00:00
parent 25a9f1165d
commit ae044a9a08
2 changed files with 21 additions and 24 deletions

View File

@ -6,7 +6,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package etemplate
* @subpackage api
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007/8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -202,10 +202,9 @@ class bo_tracking
{
if ($old[$name] != $data[$name] && !(!$old[$name] && !$data[$name]))
{
if (!is_object($this->historylog))
if (!is_object($this->historylog) || $this->historylog->user != $this->user)
{
require_once(EGW_API_INC.'/class.historylog.inc.php');
$this->historylog =& new historylog($this->app);
$this->historylog = new historylog($this->app,$this->user);
}
$this->historylog->add($status,$data[$this->id_field],
is_array($data[$name]) ? implode(',',$data[$name]) : $data[$name],
@ -229,7 +228,7 @@ class bo_tracking
{
$this->errors = $email_sent = array();
if (!$this->notify_current_user) // should we notify the current user about his own changes
if (!$this->notify_current_user && $this->user) // do we have a current user and should we notify the current user about his own changes
{
//error_log("do_notificaton() adding user=$this->user to email_sent, to not notify him");
$email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user,'account_email');

View File

@ -46,6 +46,7 @@ class historylog
* @var int
*/
var $tz_offset_s;
var $user;
var $template;
var $nextmatchs;
var $types = array(
@ -61,13 +62,10 @@ class historylog
* @param string $appname app name this instance operates on
* @return historylog
*/
function historylog($appname='')
function historylog($appname='',$user=null)
{
if (!$appname)
{
$appname = $GLOBALS['egw_info']['flags']['currentapp'];
}
$this->appname = $appname;
$this->appname = $appname ? $appname : $GLOBALS['egw_info']['flags']['currentapp'];
$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
if (is_object($GLOBALS['egw_setup']->db))
{
@ -114,7 +112,7 @@ class historylog
$this->db->insert(self::TABLE,array(
'history_record_id' => $record_id,
'history_appname' => $this->appname,
'history_owner' => $GLOBALS['egw_info']['user']['account_id'],
'history_owner' => $this->user,
'history_status' => $status,
'history_new_value' => $new_value,
'history_old_value' => $old_value,
@ -212,7 +210,7 @@ class historylog
$return_values[] = array(
'id' => $row['history_id'],
'record_id' => $row['history_record_id'],
'owner' => $GLOBALS['egw']->accounts->id2name($row['history_owner']),
'owner' => $row['history_owner'] ? $GLOBALS['egw']->accounts->id2name($row['history_owner']) : lang('eGroupWare'),
'status' => str_replace(' ','',$row['history_status']),
'new_value' => $row['history_new_value'],
'old_value' => $row['history_old_value'],