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.20, 1.1.2.21 class.h


From: Joseph Engo <address@hidden>
Subject: [Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.20, 1.1.2.21 class.history.php, 1.1.2.2, 1.1.2.3
Date: Fri, 14 Nov 2003 03:26:19 +0000

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

Modified Files:
      Tag: proposal-branch
        class.account_mgr.php class.history.php 
Log Message:
- Added a edit account screen, mainly to test history update ... edit account 
needs a lot of work
- Fixed update history, it wasn't working


Index: class.account_mgr.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.account_mgr.php,v
retrieving revision 1.1.2.20
retrieving revision 1.1.2.21
diff -C2 -d -r1.1.2.20 -r1.1.2.21
*** class.account_mgr.php       13 Nov 2003 20:18:20 -0000      1.1.2.20
--- class.account_mgr.php       14 Nov 2003 03:26:17 -0000      1.1.2.21
***************
*** 51,54 ****
--- 51,69 ----
        );
  
+ /*    $functions['edit']    = array(
+               'type'         => 'public',
+               'title'        => 'Edit user',
+               'abstract'     => 'Edit user account',
+               'params'       => array(
+                       'account_id'                => array('type' => 'int', 
'default' => '##REQUIRED##', 'desc' => 'Account ID'),
+                       'account_lid'               => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'Login ID'),
+                       'account_firstname'         => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'First Name'),
+                       'account_lastname'          => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'Last Name'),
+                       'account_password'          => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'Password'),
+                       'account_password_confirm'  => array('type' => 'any', 
'default' => '##NOTSET##',   'desc' => 'Password confirmation')
+               )
+       );
+ */
+ 
        $functions['view']    = array(
                'type'         => 'public',
***************
*** 230,233 ****
--- 245,357 ----
                }
  
+               function edit()
+               {
+                       $args = new safe_args();
+                       $args->set('edit_account_submit', '##NOTSET##', 'any');
+                       $args->set('account_id', '##REQUIRED##', 'int');
+                       $args->set('account_lid', '##NOTSET##', 'any');
+                       $args->set('account_firstname', '##NOTSET##', 'any');
+                       $args->set('account_lastname', '##NOTSET##', 'any');
+                       $args->set('account_password', '##NOTSET##', 'any');
+                       $args->set('account_password_confirm', '##NOTSET##', 
'any');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ 
+                       $GLOBALS['phpgw_xml_apinode']->add_node('Edit user 
account','title');
+ 
+                       if (! 
$GLOBALS['phpgw']->accounts->cross_reference((int)$args['account_id']))
+                       {
+                               // This normally shouldn't happen
+                               $GLOBALS['msgbox']->add(lang('The account you 
are tring to edit could not be found'),__LINE__,__FILE__, 'warning');
+                               return;
+                       }
+ 
+                       $GLOBALS['phpgw']->add_xsl('api.account_mgr');
+                       $GLOBALS['phpgw']->add_xsl('api.widgets');
+                       $account = 
createObject('api_accounts',(int)$args['account_id']);
+                       $result = array(
+                               'account_id'        => $args['account_id'],
+                               'account_lid'       => $args['account_lid'],
+                               'account_firstname' => 
$args['account_firstname'],
+                               'account_lastname'  => $args['account_lastname']
+                       );
+ 
+                       // Yes, this is supposed to be a string, NOT a boolean 
value
+                       $result['action_type'] = 'edit_account';
+                       if ($args['edit_account_submit'] == 'True')
+                       {
+                               if (! strlen($args['account_lid']))
+                               {
+                                       
$result['missing_fields']['account_lid'] = True;
+                                       $missing_fields = True;
+                               }
+ 
+                               if (! strlen($args['account_firstname']))
+                               {
+                                       
$result['missing_fields']['account_firstname'] = True;
+                                       $missing_fields = True;
+                               }
+ 
+                               if (! strlen($args['account_lastname']))
+                               {
+                                       
$result['missing_fields']['account_lastname'] = True;
+                                       $missing_fields = True;
+                               }
+ 
+                               if (strlen($args['account_password']) || 
strlen($args['account_password_confirm']) && $args['account_password'] != 
$args['account_password_confirm'])
+                               {
+                                       
$result['missing_fields']['account_password']         = True;
+                                       
$result['missing_fields']['account_password_confirm'] = True;
+                                       $GLOBALS['msgbox']->add(lang('The 
passwords you entered do not match'),__LINE__,__FILE__, 'notice');
+ 
+                               }
+                               else
+                               {
+                                       // FIXME: This hasn't been tested yet
+                                       
//sanitize($args['account_password'],'password');
+                               }
+ 
+                               if ($missing_fields)
+                               {
+                                       $GLOBALS['msgbox']->add(lang('You 
forgot to enter some of the required fields. The missing fields have been 
marked with a *'),__LINE__,__FILE__, 'notice');
+                                       $GLOBALS['phpgw']->form_lock();
+                               }
+                               else
+                               {
+                                       $old_values['account_lid'      ]  = 
$account->data['lid'];
+                                       $old_values['account_firstname']  = 
$account->data['firstname'];
+                                       $old_values['account_lastname']   = 
$account->data['lastname'];
+ 
+                                       $account->data['lid']       = 
$args['account_lid'];
+                                       $account->data['firstname'] = 
$args['account_firstname'];
+                                       $account->data['lastname']  = 
$args['account_lastname'];
+ 
+                                       if ($account->save_repository())
+                                       {
+                                               
$GLOBALS['msgbox']->add(lang('Account has been updated 
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.' . 
$args['account_id'],$history_data,$old_values);
+                                       }
+                               }
+ 
+                       }
+                       else
+                       {
+                               $result['account_id']        = 
$account->data['id'];
+                               $result['account_lid']       = 
$account->data['lid'];
+                               $result['account_firstname'] = 
$account->data['firstname'];
+                               $result['account_lastname']  = 
$account->data['lastname'];
+ 
+                               $GLOBALS['phpgw']->form_lock();
+                       }
+ 
+                       return $result;
+               }
+ 
                function view()
                {
***************
*** 236,239 ****
--- 360,364 ----
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);
  
+                       $GLOBALS['phpgw']->add_xsl('api.widgets');
                        $args['account']        = $args['account_id'];
                        $accounts               = 
CreateObject('api_accounts',$args);
***************
*** 303,307 ****
                                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');
                                }
--- 428,432 ----
                                if 
($GLOBALS['phpgw']->accounts->delete($args['account_id']))
                                {
!                                       
execMethod('api.history.clear','api.accounts.' . $args['account_id']);
                                        $GLOBALS['msgbox']->add(lang('The user 
%s has been deleted successfully',$account_lid),__LINE__,__FILE__, 'notice');
                                }

Index: class.history.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.history.php,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** class.history.php   13 Nov 2003 20:18:20 -0000      1.1.2.2
--- class.history.php   14 Nov 2003 03:26:17 -0000      1.1.2.3
***************
*** 51,56 ****
                        $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__);
  
--- 51,54 ----
***************
*** 102,106 ****
                        $this->db->transaction_begin();
  
!                       if (count($args['old_data'] == 0))
                        {
                                foreach ($args['new_data'] as $key => $value)
--- 100,104 ----
                        $this->db->transaction_begin();
  
!                       if (count($args['old_data']) == 0)
                        {
                                foreach ($args['new_data'] as $key => $value)
***************
*** 115,119 ****
                        {
                                $action = 'U';
!                               if ($args['action'] != '##NOTSET##')
                                {
                                        $action = $args['action'];
--- 113,117 ----
                        {
                                $action = 'U';
!                               if (strlen($args['action']))
                                {
                                        $action = $args['action'];
***************
*** 126,131 ****
                                                $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__);
                                        }
--- 124,129 ----
                                                $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'] . "','" . $new_key
!                                                       . "','$action','" . 
addslashes($args['old_data'][$new_key]) . "','" . addslashes($new_value) . "','"
                                                        . 
$this->db->to_timestamp($timestamp) . "')",__LINE__,__FILE__);
                                        }
***************
*** 141,150 ****
                {
                        $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();
--- 139,146 ----
                {
                        $args = new safe_args();
!                       $args->set('location','##REQUIRED##','string');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);
  
!                       $this->db->query("delete from phpgw_history where 
history_location='" . $args['location'] . "'",__LINE__,__FILE__);
  
                        return $this->db->affected_rows();





reply via email to

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