[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/class.history.php, 1.1.2.9
From: |
nomail |
Subject: |
[Phpgroupware-cvs] api/class.history.php, 1.1.2.9 |
Date: |
Thu, 20 May 2004 15:51:04 -0000 |
Update of /api
Modified Files:
Branch: proposal-branch
class.history.php
date: 2004/04/16 20:59:48; author: seek3r; state: Exp; lines: +170 -162
Log Message:
bringing savannah cvs back up to date with what we were doing on our private
cvs server. We will not be doing dev from this cvs tree
=====================================================================
No syntax errors detected in -
=====================================================================
Index: api/class.history.php
diff -u api/class.history.php:1.1.2.8 api/class.history.php:1.1.2.9
--- api/class.history.php:1.1.2.8 Sat Feb 28 10:07:55 2004
+++ api/class.history.php Fri Apr 16 20:59:48 2004
@@ -1,162 +1,170 @@
-<?php
-
/**************************************************************************\
- * phpGroupWare
*
- * http://www.phpgroupware.org
*
- * This file written by Joseph Engo <address@hidden> *
- * Copyright (C) 2003 Joseph Engo
*
- *
-------------------------------------------------------------------------*
- * This library is part of the phpGroupWare API
*
- * http://www.phpgroupware.org/api
*
- *
------------------------------------------------------------------------ *
- * This library is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU Lesser General Public License as published
by *
- * the Free Software Foundation; either version 2.1 of the License,
*
- * or any later version.
*
- * This library is distributed in the hope that it will be useful, but
*
- * WITHOUT ANY WARRANTY; without even the implied warranty of
*
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * See the GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
License *
- * along with this library; if not, write to the Free Software
Foundation, *
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
-
\**************************************************************************/
-
- /* $Id$ */
- /* $Source$ */
-
- class api_history
- {
- // These are stock generic types, applications can specify
there own
- // However, applications should NEVER re-assign the default
stock ones
- var $actions = array(
- 'C' => 'Create',
- 'D' => 'Delete',
- 'U' => 'Update'
- );
- var $field_desc = array();
- var $field_execmethod = array();
- var $account_id;
-
- function api_history()
- {
- $this->account_id =
$GLOBALS['phpgw_data']['user']['id'];
- }
-
- function get()
- {
- $args = new safe_args();
- $args->set('location','##REQUIRED##','string');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
-
- $dbresult = $GLOBALS['phpgw']->db->execute("select *
from phpgw_history where history_location='" . $args['location'] .
"'",__LINE__,__FILE__);
-
- $result = array();
- while (! $dbresult->EOF)
- {
- $dbresult->movenext();
-
- if
(strlen($this->field_execmethod[$dbresult->fields['history_field']]))
- {
- $old_value =
execMethod($this->field_execmethod[$dbresult->fields['history_field']],$dbresult->fields['history_o_value']);
- $new_value =
execMethod($this->field_execmethod[$dbresult->fields['history_field']],$dbresult->fields['history_n_value']);
- }
- else
- {
- $old_value =
$dbresult->fields['history_o_value'];
- $new_value =
$dbresult->fields['history_n_value'];
- }
-
- $owner =
$GLOBALS['phpgw']->accounts->cross_reference((int)$dbresult->fields['history_owner']);
- $result[] = array(
- 'owner' => ($owner ? $owner :
lang('Unknown')),
- 'field' =>
($this->field_desc[$dbresult->fields['history_field']] ?
$this->field_desc[$dbresult->fields['history_field']] :
$dbresult->fields['history_field']),
- 'action' =>
lang($this->actions[$dbresult->fields['history_action']]),
- 'new_value' => $new_value,
- 'old_value' => $old_value,
- 'timestamp' =>
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['history_timestamp']))
. date(' h:i:s
a',$dbresult->unixtimestamp($dbresult->fields['history_timestamp']))
- );
- }
-
- return $result;
- }
-
- function set()
- {
- $args = new safe_args();
- $args->set('location','##REQUIRED##','string');
- $args->set('new_data','##REQUIRED##','any');
- $args->set('old_data','##REQUIRED##','any');
- $args->set('action','##NOTSET##','any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
-
- // FIXME: Can safe_args handle this ? (jengo)
- if (! is_array($args['old_data']) || !
is_array($args['new_data']))
- {
- $GLOBALS['msgbox']->add(lang('New or old data
passed to api.history.set is not an array type'),__LINE__,__FILE__, 'debug');
- return;
- }
-
- $timestamp = time();
- $GLOBALS['phpgw']->db->begintrans();
-
- if (count($args['old_data']) == 0)
- {
- foreach ($args['new_data'] as $key => $value)
- {
- $GLOBALS['phpgw']->db->execute("insert
into phpgw_history
(history_owner,history_location,history_field,history_action,"
- .
"history_n_value,history_timestamp) values ('" . $this->account_id . "','"
- . $args['location'] . "','" .
$key . "','C','" . addslashes($value) . "',"
- .
$GLOBALS['phpgw']->db->dbtimestamp($timestamp) . ")",__LINE__,__FILE__);
- }
- }
- else
- {
- $action = 'U';
- if (strlen($args['action']))
- {
- $action = $args['action'];
- }
-
- foreach ($args['new_data'] as $new_key =>
$new_value)
- {
- if ($args['old_data'][$new_key] !=
$new_value)
- {
-
$GLOBALS['phpgw']->db->execute("insert into phpgw_history
(history_owner,history_location,history_field,"
- .
"history_action,history_o_value,history_n_value,history_timestamp) values ('"
- . $this->account_id .
"','" . $args['location'] . "','" . $new_key
- . "','$action','" .
addslashes($args['old_data'][$new_key]) . "','" . addslashes($new_value) . "',"
- .
$GLOBALS['phpgw']->db->dbtimestamp($timestamp) . ")",__LINE__,__FILE__);
- }
- }
- }
- $GLOBALS['phpgw']->db->committrans();
-
- return $GLOBALS['phpgw']->db->affected_rows();
- }
-
- function record_count()
- {
- $args = new safe_args();
- $args->set('location','##REQUIRED##','string');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
-
- $dbresult = $GLOBALS['phpgw']->db->execute("select
count(id) from phpgw_history where history_location='" . $args['location'] .
"'",__LINE__,__FILE__);
- $dbresult->movenext();
-
- return $dbresult->fields[0];
- }
-
- // FIXME: Something needs to be added to make sure this can NOT
be called from a browser no matter what (jengo)
- function clear()
- {
- $args = new safe_args();
- $args->set('location','##REQUIRED##','string');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
-
- $dbresult = $GLOBALS['phpgw']->db->execute("delete from
phpgw_history where history_location='" . $args['location'] .
"'",__LINE__,__FILE__);
-
- return $dbresult->recordcount();
- }
- }
-
-
+<?php
+
/**************************************************************************\
+ * phpGroupWare
*
+ * http://www.phpgroupware.org
*
+ * This file written by Joseph Engo <address@hidden> *
+ * Copyright (C) 2003 Joseph Engo
*
+ *
-------------------------------------------------------------------------*
+ * This library is part of the phpGroupWare API
*
+ * http://www.phpgroupware.org/api
*
+ *
------------------------------------------------------------------------ *
+ * This library is free software; you can redistribute it and/or modify
it *
+ * under the terms of the GNU Lesser General Public License as published
by *
+ * the Free Software Foundation; either version 2.1 of the License,
*
+ * or any later version.
*
+ * This library is distributed in the hope that it will be useful, but
*
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
*
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
+ * See the GNU Lesser General Public License for more details.
*
+ * You should have received a copy of the GNU Lesser General Public
License *
+ * along with this library; if not, write to the Free Software
Foundation, *
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
+
\**************************************************************************/
+
+ /* $Id$ */
+ /* $Source$ */
+
+ class api_history
+ {
+ // These are stock generic types, applications can specify
there own
+ // However, applications should NEVER re-assign the default
stock ones
+ var $actions = array(
+ 'C' => 'Create',
+ 'D' => 'Delete',
+ 'U' => 'Update'
+ );
+ var $field_desc = array();
+ var $field_execMethod = array();
+ var $account_id;
+
+ function api_history()
+ {
+ $this->account_id =
$GLOBALS['phpgw_data']['user']['id'];
+ }
+
+ function get()
+ {
+ $args = new safe_args();
+ $args->set('location',REQUIRED,'string');
+ $args = $args->get(func_get_args());
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute("select *
from phpgw_history where history_location='" . $args['location'] . "'");
+
+ $result = array();
+ while (! $dbresult->EOF)
+ {
+ if
(strlen($this->field_execMethod[$dbresult->fields['history_field']]))
+ {
+ $old_value =
execMethod($this->field_execMethod[$dbresult->fields['history_field']],$dbresult->fields['history_o_value']);
+ $new_value =
execMethod($this->field_execMethod[$dbresult->fields['history_field']],$dbresult->fields['history_n_value']);
+ }
+ else
+ {
+ $old_value =
$dbresult->fields['history_o_value'];
+ $new_value =
$dbresult->fields['history_n_value'];
+ }
+
+ $owner =
$GLOBALS['phpgw']->accounts->cross_reference((int)$dbresult->fields['history_owner']);
+ $result[] = array
+ (
+ 'owner' => ($owner ? $owner :
lang('Unknown')),
+ 'field' =>
($this->field_desc[$dbresult->fields['history_field']] ?
$this->field_desc[$dbresult->fields['history_field']] :
$dbresult->fields['history_field']),
+ 'action' =>
lang($this->actions[$dbresult->fields['history_action']]),
+ 'new_value' => stripslashes($new_value),
+ 'old_value' => stripslashes($old_value),
+ 'timestamp' =>
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['history_timestamp']))
. date(' h:i:s
a',$dbresult->unixtimestamp($dbresult->fields['history_timestamp']))
+ );
+ $dbresult->movenext();
+ }
+
+ return $result;
+ }
+
+ function set()
+ {
+ $args = new safe_args();
+ $args->set('location',REQUIRED,'string');
+ $args->set('new_data',REQUIRED,'any');
+ $args->set('old_data',REQUIRED,'any');
+ $args->set('action',NOTSET,'any');
+ $args = $args->get(func_get_args());
+
+ // FIXME: Can safe_args handle this ? (jengo)
+ if (! is_array($args['old_data']) || !
is_array($args['new_data']))
+ {
+ $GLOBALS['msgbox']->add(lang('New or old data
passed to api.history.set is not an array type'), 'debug');
+ return;
+ }
+
+ $timestamp = time();
+ $GLOBALS['phpgw']->db->begintrans();
+
+ if (count($args['old_data']) == 0)
+ {
+ foreach ($args['new_data'] as $key => $value)
+ {
+ $GLOBALS['phpgw']->db->Execute("insert
into phpgw_history
(history_owner,history_location,history_field,history_action,"
+ .
"history_n_value,history_timestamp) values ('" . $this->account_id . "','"
+ . $args['location'] . "','" .
$key . "','C','" . addslashes($value) . "',"
+ .
$GLOBALS['phpgw']->db->dbtimestamp($timestamp) . ")");
+ }
+ }
+ else
+ {
+ $action = 'U';
+ if (strlen($args['action']))
+ {
+ $action = $args['action'];
+ }
+
+ foreach ($args['new_data'] as $new_key =>
$new_value)
+ {
+ if ($args['old_data'][$new_key] !=
$new_value)
+ {
+
$GLOBALS['phpgw']->db->Execute("insert into phpgw_history
(history_owner,history_location,history_field,"
+ .
"history_action,history_o_value,history_n_value,history_timestamp) values ('"
+ . $this->account_id .
"','" . $args['location'] . "','" . $new_key
+ . "','$action','" .
addslashes($args['old_data'][$new_key]) . "','" . addslashes($new_value) . "',"
+ .
$GLOBALS['phpgw']->db->dbtimestamp($timestamp) . ")");
+ }
+ }
+ }
+ $GLOBALS['phpgw']->db->committrans();
+
+ return $GLOBALS['phpgw']->db->affected_rows();
+ }
+
+ function record_count()
+ {
+ $args = new safe_args();
+ $args->set('location',REQUIRED,'string');
+ $args = $args->get(func_get_args());
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute("select
count(id) from phpgw_history where history_location='" . $args['location'] .
"'");
+ $dbresult->movenext();
+
+ return $dbresult->fields[0];
+ }
+
+ // FIXME: Something needs to be added to make sure this can NOT
be called from a browser no matter what (jengo)
+ function clear()
+ {
+ $args = new safe_args();
+ $args->set('location',REQUIRED,'string');
+ $args = $args->get(func_get_args());
+
+ $dbresult = $GLOBALS['phpgw']->db->Execute("DELETE FROM
phpgw_history WHERE history_location='" . $args['location'] . "'");
+
+ return $dbresult->recordcount();
+ }
+
+ function _rollback()
+ {
+ $args = new safe_args();
+ $args->set('location',REQUIRED,'string');
+ $args->set('timestamp',REQUIRED,'string');
+ $args = $args->get(func_get_args());
+
+ // execMethod - <app>.<class>.update()
+ }
+ }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api/class.history.php, 1.1.2.9,
nomail <=