phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] api class.history.php, NONE, 1.1.2.1 class.account_mg


From: Joseph Engo <address@hidden>
Subject: [Phpgroupware-cvs] api class.history.php, NONE, 1.1.2.1 class.account_mgr.php, 1.1.2.18, 1.1.2.19
Date: Sun, 09 Nov 2003 18:52:15 +0000

Update of /cvsroot/phpgroupware/api
In directory subversions:/tmp/cvs-serv25968/api

Modified Files:
      Tag: proposal-branch
        class.account_mgr.php 
Added Files:
      Tag: proposal-branch
        class.history.php 
Log Message:
- Started working on history
  Update history isn't finished
  The phpgw_history table might have the field history_app changed to history_op
  You have to run setup to add the new table
  View history is missing the alternate handlers
- Fixed account creating not setting the correct password by default
- Fixed some alignment issues with tables


Index: class.account_mgr.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.account_mgr.php,v
retrieving revision 1.1.2.18
retrieving revision 1.1.2.19
diff -C2 -d -r1.1.2.18 -r1.1.2.19
*** class.account_mgr.php       9 Nov 2003 16:01:52 -0000       1.1.2.18
--- class.account_mgr.php       9 Nov 2003 18:52:13 -0000       1.1.2.19
***************
*** 186,194 ****
                                        $args['account_status']  = 'A';
                                        $args['account_expires'] = 
gmmktime(23,59,59,12,30,2037);
  
!                                       if 
($GLOBALS['phpgw']->accounts->create($args))
                                        {
                                                
$GLOBALS['msgbox']->add(lang('Account has been created 
successfully'),__LINE__,__FILE__, 'notice');
                                                unset($result);
                                        }
                                }
--- 186,203 ----
                                        $args['account_status']  = 'A';
                                        $args['account_expires'] = 
gmmktime(23,59,59,12,30,2037);
+                                       $args['account_passwd']  = 
$args['account_password'];
  
!                                       $account_id = 
$GLOBALS['phpgw']->accounts->create($args);
!                                       if ($account_id)
                                        {
                                                
$GLOBALS['msgbox']->add(lang('Account has been created 
successfully'),__LINE__,__FILE__, 'notice');
                                                unset($result);
+ 
+                                               $history_data['account_lid']    
   = $args['account_lid'];
+                                               
$history_data['account_firstname'] = $args['account_firstname'];
+                                               
$history_data['account_lastname']  = $args['account_lastname'];
+ 
+                                               $obj = 
createObject('api_history');
+                                               
$obj->set('api.accounts',$account_id,'C',array(),$history_data);
                                        }
                                }
***************
*** 209,212 ****
--- 218,223 ----
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);
  
+                       $GLOBALS['phpgw']->add_xsl('api.widgets');
+ 
                        $args['account']        = $args['account_id'];
                        $accounts               = 
CreateObject('api_accounts',$args);
***************
*** 221,224 ****
--- 232,243 ----
                        $result['status']       = $accounts->data['status'];
  
+                       $obj                    = createObject('api_history');
+                       $obj->field_desc        = array(
+                               'account_lid'       => lang('Login ID'),
+                               'account_firstname' => lang('First Name'),
+                               'account_lastname'  => lang('Last Name')
+                       );
+                       $result['history_data'] = 
$obj->get('api.accounts',$args['account_id']);
+ 
                        return $result;
                }
***************
*** 266,270 ****
                                if 
($GLOBALS['phpgw']->accounts->delete($args['account_id']))
                                {
!                                       $GLOBALS['msgbox']->add(lang('The 
account %s has been deleted successfully',$account_lid),__LINE__,__FILE__, 
'notice');
                                }
                                else
--- 285,290 ----
                                if 
($GLOBALS['phpgw']->accounts->delete($args['account_id']))
                                {
!                                       
execMethod('api.history.clear',array('appname' => 'api.accounts','record_id' => 
$args['account_id']));
!                                       $GLOBALS['msgbox']->add(lang('The user 
%s has been deleted successfully',$account_lid),__LINE__,__FILE__, 'notice');
                                }
                                else

--- NEW FILE: class.history.php ---
<?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: class.history.php,v 1.1.2.1 2003/11/09 18:52:13 jengo Exp $ */
        /* $Source: /cvsroot/phpgroupware/api/Attic/class.history.php,v $ */

        class api_history
        {
                // These are stock generic types, applications can specify 
there own
                // However, applications should NEVER re-assign the default 
stock ones
                var $types = array(
                        'C' => 'Create',
                        'D' => 'Delete',
                        'U' => 'Update'
                );
                var $field_desc = array();
                var $db;

                function api_history()
                {
                        $this->db = $GLOBALS['phpgw']->db;
                }

                function get()
                {
                        $args = new safe_args();
                        $args->set('appname','##REQUIRED##','string');
                        $args->set('record_id','##REQUIRED##','int');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);

                        $this->db->query("select * from phpgw_history where 
history_app='" . $args['appname'] . "' and history_rid='"
                                . $args['record_id'] . "'",__LINE__,__FILE__);

                        $result = array();
                        while ($this->db->next_record())
                        {
                                $result[] = array(
                                        'owner'     => 
$GLOBALS['phpgw']->accounts->cross_reference((int)$this->db->f('history_owner')),
                                        'field'     => 
($this->field_desc[$this->db->f('history_field')] ? 
$this->field_desc[$this->db->f('history_field')] : 
$this->db->f('history_field')),
                                        'type'      => 
lang($this->types[$this->db->f('history_type')]),
                                        'new_value' => 
$this->db->f('history_n_value'),
                                        'old_value' => 
$this->db->f('history_o_value'),
                                        'timestamp' => 
strftime('%x',$this->db->from_timestamp($this->db->f('history_timestamp'))) . 
date(' h:i:s a',$this->db->from_timestamp($this->db->f('history_timestamp')))
                                );
                        }

                        return $result;
                }

                function set()
                {
                        $args = new safe_args();
                        $args->set('appname','##REQUIRED##','string');
                        $args->set('record_id','##REQUIRED##','int');
                        $args->set('change_type','##REQUIRED##','string');
                        $args->set('old_data','##REQUIRED##','any');
                        $args->set('new_data','##REQUIRED##','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();
                        $this->db->transaction_begin();

                        if ($args['change_type'] == 'C')
                        {
                                foreach ($args['new_data'] as $key => $value)
                                {
                                        $this->db->query("insert into 
phpgw_history 
(history_rid,history_owner,history_app,history_field,history_type,"
                                                . 
"history_n_value,history_timestamp) values ('" . $args['record_id'] . "','"
                                                . 
$GLOBALS['phpgw_data']['user']['id'] . "','" . $args['appname'] . "','" . $key 
. "','C','"
                                                . $value . "','" . 
$this->db->to_timestamp($timestamp) . "')",__LINE__,__FILE__);
                                }
                        }
                        else
                        {
                                $this->db->transaction_begin();
                                foreach ($args['new_data'] as $new_key => 
$new_value)
                                {
                                        // FIXME: This is pending a form that 
actually has a edit section
                                }
                        }

                        $this->db->transaction_commit();

                        return $this->db->affected_rows();
                }

                // 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('appname','##REQUIRED##','string');
                        $args->set('record_id','##REQUIRED##','int');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);

                        $this->db->query("delete from phpgw_history where 
history_rid='" . $args['record_id'] . "' and history_app='" . $args['appname']
                                . "'",__LINE__,__FILE__);

                        return $this->db->affected_rows();
                }
        }







reply via email to

[Prev in Thread] Current Thread [Next in Thread]