phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.19, 1.1.2.20 class.h


From: Joseph Engo <address@hidden>
Subject: [Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.19, 1.1.2.20 class.history.php, 1.1.2.1, 1.1.2.2 class.setup.php, 1.1.1.1.2.10, 1.1.1.1.2.11
Date: Thu, 13 Nov 2003 20:18:23 +0000

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

Modified Files:
      Tag: proposal-branch
        class.account_mgr.php class.history.php class.setup.php 
Log Message:
- Changed how history works, its much cleanier and easier to use 
(field_execmethod still needs some work to how it functions)
- History will now group changes using row_on and row_off (Note: This was a 
bitch to figure out :P )
- The accounts created durring setup will create the inital entrys for an 
accounts history
- If a account_id is not found by the history class, it uses "Unknown" ...


Index: class.account_mgr.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.account_mgr.php,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -C2 -d -r1.1.2.19 -r1.1.2.20
*** class.account_mgr.php       9 Nov 2003 18:52:13 -0000       1.1.2.19
--- class.account_mgr.php       13 Nov 2003 20:18:20 -0000      1.1.2.20
***************
*** 104,107 ****
--- 104,125 ----
                }
  
+               function account_status()
+               {
+                       $args = new safe_args();
+                       $args->set('account_status', '##REQUIRED##', 'any');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ 
+                       // If there is NO value passed, don't return a disabled 
... it could be a new account
+                       // This is mainly for history (jengo)
+                       if ($args['account_status'] == 'A')
+                       {
+                               return lang('Active');
+                       }
+                       else if ($args['account_status'] == 'D')
+                       {
+                               return lang('Disabled');
+                       }
+               }
+ 
                function show()
                {
***************
*** 199,203 ****
  
                                                $obj = 
createObject('api_history');
!                                               
$obj->set('api.accounts',$account_id,'C',array(),$history_data);
                                        }
                                }
--- 217,221 ----
  
                                                $obj = 
createObject('api_history');
!                                               $obj->set('api.accounts.' . 
$account_id,$history_data,array());
                                        }
                                }
***************
*** 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);
--- 236,239 ----
***************
*** 236,242 ****
                                '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;
--- 252,260 ----
                                'account_lid'       => lang('Login ID'),
                                'account_firstname' => lang('First Name'),
!                               'account_lastname'  => lang('Last Name'),
!                               'account_status'    => lang('Account status')
                        );
!                       $obj->field_execmethod['account_status'] = 
'api.account_mgr.account_status';
!                       $result['history_data'] = $obj->get('api.accounts.' . 
$args['account_id']);
  
                        return $result;

Index: class.history.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.history.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** class.history.php   9 Nov 2003 18:52:13 -0000       1.1.2.1
--- class.history.php   13 Nov 2003 20:18:20 -0000      1.1.2.2
***************
*** 29,43 ****
                // 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;
                }
  
--- 29,46 ----
                // 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 $db;
+               var $account_id;
  
                function api_history()
                {
!                       $this->db         = $GLOBALS['phpgw']->db;
!                       $this->account_id = 
$GLOBALS['phpgw_data']['user']['id'];
                }
  
***************
*** 45,64 ****
                {
                        $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')))
                                );
--- 48,79 ----
                {
                        $args = new safe_args();
!                       $args->set('location','##REQUIRED##','string');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);
  
!                       $GLOBALS['phpgw']->add_xsl('api.widgets');
! 
!                       $this->db->query("select * from phpgw_history where 
history_location='" . $args['location'] . "'",__LINE__,__FILE__);
  
                        $result = array();
                        while ($this->db->next_record())
                        {
+                               if 
($this->field_execmethod[$this->db->f('history_field')])
+                               {
+                                       $old_value = 
execMethod($this->field_execmethod[$this->db->f('history_field')],$this->db->f('history_o_value'));
+                                       $new_value = 
execMethod($this->field_execmethod[$this->db->f('history_field')],$this->db->f('history_n_value'));
+                               }
+                               else
+                               {
+                                       $old_value = 
$this->db->f('history_o_value');
+                                       $new_value = 
$this->db->f('history_n_value');
+                               }
+ 
+                               $owner = 
$GLOBALS['phpgw']->accounts->cross_reference((int)$this->db->f('history_owner'));
                                $result[] = array(
!                                       'owner'     => ($owner ? $owner : 
lang('Unknown')),
                                        'field'     => 
($this->field_desc[$this->db->f('history_field')] ? 
$this->field_desc[$this->db->f('history_field')] : 
$this->db->f('history_field')),
!                                       'action'    => 
lang($this->actions[$this->db->f('history_action')]),
!                                       'new_value' => $new_value,
!                                       'old_value' => $old_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')))
                                );
***************
*** 71,79 ****
                {
                        $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__);
  
--- 86,93 ----
                {
                        $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__);
  
***************
*** 88,110 ****
                        $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();
  
--- 102,135 ----
                        $this->db->transaction_begin();
  
!                       if (count($args['old_data'] == 0))
                        {
                                foreach ($args['new_data'] as $key => $value)
                                {
!                                       $this->db->query("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) . "','"
!                                               . 
$this->db->to_timestamp($timestamp) . "')",__LINE__,__FILE__);
                                }
                        }
                        else
                        {
!                               $action = 'U';
!                               if ($args['action'] != '##NOTSET##')
!                               {
!                                       $action = $args['action'];
!                               }
! 
                                foreach ($args['new_data'] as $new_key => 
$new_value)
                                {
!                                       if ($args['old_data'][$new_key] != 
$new_value)
!                                       {
!                                               $this->db->query("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'] . "','" . $key
!                                                       . "','$action','" . 
addslashes($old_value) . "','" . addslashes($new_value) . "','"
!                                                       . 
$this->db->to_timestamp($timestamp) . "')",__LINE__,__FILE__);
!                                       }
                                }
                        }
                        $this->db->transaction_commit();
  

Index: class.setup.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.setup.php,v
retrieving revision 1.1.1.1.2.10
retrieving revision 1.1.1.1.2.11
diff -C2 -d -r1.1.1.1.2.10 -r1.1.1.1.2.11
*** class.setup.php     3 Nov 2003 17:31:21 -0000       1.1.1.1.2.10
--- class.setup.php     13 Nov 2003 20:18:20 -0000      1.1.1.1.2.11
***************
*** 419,441 ****
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);
  
!                       if(isset($args['admin_lid']))
                        {
!                               $accounts = createobject('api_accounts', 
array('account'=>0));
                                
!                               $admin_account_info['account_lid'] = 
$args['admin_lid'];
!                               $admin_account_info['account_passwd'] = 
$args['admin_pass'];
                                $admin_account_info['account_firstname'] = 
$args['admin_fname'];
!                               $admin_account_info['account_lastname'] = 
$args['admin_lname'];
!                               $admin_account_info['account_type'] = 'u';
!                               $admin_account_info['account_status'] = 'A';
!                               $admin_account_info['account_expires'] = mktime 
(0,0,0,12,31,2005);
!                               $admin_id = 
$accounts->create($admin_account_info);
  
!                               $all_acl = createobject('api_acl', 
array('account_id'=>0));
                                $all_acl->add('api',63,1);
                                $all_acl->add('api.base.about',1);
                                $all_acl->add('api.base.login',1);
                                
!                               $admin_acl = createobject('api_acl', 
array('account_id'=>$admin_id));
                                $admin_acl->add('.',63);
                                $admin_acl->add('api.base',63);
--- 419,451 ----
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);
  
!                       if (isset($args['admin_lid']))
                        {
!                               $history                                 = 
createObject('api_history');
!                               $history->account_id                     = 1;
!                               $accounts                                = 
createObject('api_accounts', array('account' => 0));
                                
!                               $admin_account_info['account_lid']       = 
$args['admin_lid'];
!                               $admin_account_info['account_passwd']    = 
$args['admin_pass'];
                                $admin_account_info['account_firstname'] = 
$args['admin_fname'];
!                               $admin_account_info['account_lastname']  = 
$args['admin_lname'];
!                               $admin_account_info['account_type']      = 'u';
!                               $admin_account_info['account_status']    = 'A';
!                               $admin_account_info['account_expires']   = 
mktime (0,0,0,12,31,2005);
!                               $admin_id                                = 
$accounts->create($admin_account_info);
!                               $history_values = array(
!                                       'account_lid'       => 
$args['admin_lid'],
!                                       'account_firstname' => 
$args['admin_fname'],
!                                       'account_lastname'  => 
$args['admin_lname'],
!                                       'account_status'    => 'A'
  
!                               );
!                               $history->set('api.accounts.' . 
$admin_id,$history_values,array());
! 
!                               $all_acl = createObject('api_acl', 
array('account_id' => 0));
                                $all_acl->add('api',63,1);
                                $all_acl->add('api.base.about',1);
                                $all_acl->add('api.base.login',1);
                                
!                               $admin_acl = createObject('api_acl', 
array('account_id' => $admin_id));
                                $admin_acl->add('.',63);
                                $admin_acl->add('api.base',63);
***************
*** 448,461 ****
                                if($args['create_anon'] = 'yes')
                                {
!                                       $anon_account_info['account_lid'] = 
'anonymous';
!                                       $anon_account_info['account_passwd'] = 
'doesntmatter';
                                        $anon_account_info['account_firstname'] 
= 'Anonymous';
!                                       $account_info['account_lastname'] = 
'User';
!                                       $anon_account_info['account_type'] = 
'u';
!                                       $anon_account_info['account_status'] = 
'A';
!                                       $anon_account_info['account_expires'] = 
mktime (0,0,0,12,31,2009);
!                                       $anon_id = 
$accounts->create($anon_account_info);
  
!                                       $anon_acl = createobject('api_acl', 
array('account_id'=>$anon_id));
                                        $anon_acl->add('wcm.base',1);
                                        $this->install_log['text'] .= ' 
Anonymous account was created.';
--- 458,479 ----
                                if($args['create_anon'] = 'yes')
                                {
!                                       $anon_account_info['account_lid']       
= 'anonymous';
!                                       $anon_account_info['account_passwd']    
= 'doesntmatter';
                                        $anon_account_info['account_firstname'] 
= 'Anonymous';
!                                       $account_info['account_lastname']       
= 'User';
!                                       $anon_account_info['account_type']      
= 'u';
!                                       $anon_account_info['account_status']    
= 'A';
!                                       $anon_account_info['account_expires']   
= mktime (0,0,0,12,31,2009);
!                                       $anon_id                                
= $accounts->create($anon_account_info);
  
!                                       $history_values = array(
!                                               'account_lid'       => 
'anonymous',
!                                               'account_firstname' => 
'Anonymous',
!                                               'account_lastname'  => 'User',
!                                               'account_status'    => 'A'
!                                       );
!                                       $history->set('api.accounts.' . 
$anon_id,$history_values,array());
! 
!                                       $anon_acl = createObject('api_acl', 
array('account_id'=>$anon_id));
                                        $anon_acl->add('wcm.base',1);
                                        $this->install_log['text'] .= ' 
Anonymous account was created.';





reply via email to

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