phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] api class.base.php, 1.1.1.1.2.20, 1.1.1.1.2.21 class.


From: Joseph Engo <address@hidden>
Subject: [Phpgroupware-cvs] api class.base.php, 1.1.1.1.2.20, 1.1.1.1.2.21 class.phpgw.php, 1.1.1.1.2.32, 1.1.1.1.2.33 class.statecache.php, 1.1.2.3, 1.1.2.4 starter.inc.php, 1.1.1.1.2.23, 1.1.1.1.2.24
Date: Mon, 10 Nov 2003 00:36:06 +0000

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

Modified Files:
      Tag: proposal-branch
        class.base.php class.phpgw.php class.statecache.php 
        starter.inc.php 
Log Message:
- Created a *basic* user profile editor, mainly so it will be easier to create 
the contacts class around it
- Added basic parts to auth.change_passsword, it only works for current user 
and needs to ACL checking
- I added profile.xsl pending talking to Seek3r about combing about.xsl, 
home.xsl and profile.xsl into base.xsl
- Added api.statecache.cancel, which will put you into the previous op history 
item.
  I didn't use prevop becuase if you refresh that form, or submit it, it will 
throw things off


Index: starter.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/starter.inc.php,v
retrieving revision 1.1.1.1.2.23
retrieving revision 1.1.1.1.2.24
diff -C2 -d -r1.1.1.1.2.23 -r1.1.1.1.2.24
*** starter.inc.php     7 Nov 2003 09:05:42 -0000       1.1.1.1.2.23
--- starter.inc.php     10 Nov 2003 00:36:04 -0000      1.1.1.1.2.24
***************
*** 217,232 ****
        {
                $GLOBALS['phpgw']->statecache->pause($inputs);
!               $num = 
count($GLOBALS['phpgw_session']['phpgw_data']['op_history']) - 2;
                $methodname = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['op'];
!               $inputs = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['data'];
        }
        elseif($methodname == 'api.statecache.clear')
        {
                $GLOBALS['phpgw']->statecache->clear();
!               $num = 
count($GLOBALS['phpgw_session']['phpgw_data']['op_history']) - 2;
                $methodname = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['op'];
!               $inputs = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['data'];
        }
!       
        if($GLOBALS['missing_critical'] || 
$GLOBALS['phpgw']->acl->check($methodname, 1))
        {
--- 217,238 ----
        {
                $GLOBALS['phpgw']->statecache->pause($inputs);
!               $num        = 
count($GLOBALS['phpgw_session']['phpgw_data']['op_history']) - 2;
                $methodname = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['op'];
!               $inputs     = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['data'];
        }
        elseif($methodname == 'api.statecache.clear')
        {
                $GLOBALS['phpgw']->statecache->clear();
!               $num        = 
count($GLOBALS['phpgw_session']['phpgw_data']['op_history']) - 2;
                $methodname = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['op'];
!               $inputs     = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['data'];
        }
!       elseif($methodname == 'api.statecache.cancel')
!       {
!               $num        = 
count($GLOBALS['phpgw_session']['phpgw_data']['op_history']) - 2;
!               $methodname = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['op'];
!               $inputs     = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$num]['data'];
!       }
! 
        if($GLOBALS['missing_critical'] || 
$GLOBALS['phpgw']->acl->check($methodname, 1))
        {

Index: class.base.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.base.php,v
retrieving revision 1.1.1.1.2.20
retrieving revision 1.1.1.1.2.21
diff -C2 -d -r1.1.1.1.2.20 -r1.1.1.1.2.21
*** class.base.php      3 Nov 2003 20:26:34 -0000       1.1.1.1.2.20
--- class.base.php      10 Nov 2003 00:36:04 -0000      1.1.1.1.2.21
***************
*** 41,44 ****
--- 41,56 ----
        );
  
+       $functions['profile']   = array(
+               'type'         => 'public',
+               'title'        => 'Update profile',
+               'abstract'     => 'Update user profile',
+               'params'       => array(
+                       'profile_firstname'         => array('type' => 'any', 
'default' => '##NOTSET##', 'desc' => 'First Name'),
+                       'profile_lastname'          => array('type' => 'any', 
'default' => '##NOTSET##', 'desc' => 'Last Name'),
+                       'profile_password'          => array('type' => 'any', 
'default' => '##NOTSET##', 'desc' => 'Password'),
+                       'profile_password_confirm'  => array('type' => 'any', 
'default' => '##NOTSET##', 'desc' => 'Password confirmation')
+               )
+       );
+ 
        $functions['about']    = array(
                'type'         => 'public',
***************
*** 94,97 ****
--- 106,193 ----
                        
$GLOBALS['phpgw']->hooks->execute(array('hook'=>'api.base.start', 
'fname'=>'test_firstname', 'lname'=>'test_lastname'));
                        $GLOBALS['phpgw_xml_apinode']->add_node('Home','title');
+ 
+                       return $result;
+               }
+ 
+               // For now, this is just updating your password, long term it 
will be used to update all your personal info
+               function profile()
+               {
+                       $args = new safe_args();
+                       $args->set('profile_submit', '##NOTSET##', 'string');
+                       $args->set('profile_firstname', '##NOTSET##', 'any');
+                       $args->set('profile_lastname', '##NOTSET##', 'any');
+                       $args->set('profile_password', '##NOTSET##', 'any');
+                       $args->set('profile_password_confirm', '##NOTSET##', 
'any');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ 
+                       if ($args['profile_submit'])
+                       {
+                               if (! strlen($args['profile_firstname']))
+                               {
+                                       
$result['missing_fields']['profile_firstname'] = True;
+                                       $result['profile_firstname'] = 
$GLOBALS['phpgw_data']['user']['firstname'];
+                                       $missing_fields = True;
+                               }
+ 
+                               if (! strlen($args['profile_lastname']))
+                               {
+                                       
$result['missing_fields']['profile_lastname'] = True;
+                                       $result['profile_lastname']  = 
$GLOBALS['phpgw_data']['user']['lastname'];
+                                       $missing_fields = True;
+                               }
+ 
+                               if (! strlen($args['profile_password']))
+                               {
+                                       
$result['missing_fields']['profile_password'] = True;
+                                       $missing_fields = True;
+                               }
+ 
+                               if (! strlen($args['profile_password_confirm']))
+                               {
+                                       
$result['missing_fields']['profile_password_confirm'] = True;
+                                       $missing_fields = True;
+                               }
+                               else if ($args['profile_password'] != 
$args['profile_password_confirm'])
+                               {
+                                       
$result['missing_fields']['profile_password']         = True;
+                                       
$result['missing_fields']['profile_password_confirm'] = True;
+                                       $missing_fields = 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['profile_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();
+                                       $result['action_type'] = 'profile';
+                               }
+                               else
+                               {
+                                       
$GLOBALS['phpgw']->accounts->data['firstname'] = $args['profile_firstname'];
+                                       
$GLOBALS['phpgw']->accounts->data['lastname']  = $args['profile_lastname'];
+                                       
$GLOBALS['phpgw']->accounts->save_repository();
+ 
+                                       
execMethod('api.auth.change_password',array('current_passwd' => '', 
'new_passwd' => $args['profile_password'], 'account_id' => 
$GLOBALS['phpgw_data']['user']['id']));
+                                       $GLOBALS['msgbox']->add(lang('Profile 
has been updated successfully'),__LINE__,__FILE__, 'notice');
+                               }
+                       }
+                       else
+                       {
+                               $result['profile_firstname'] = 
$GLOBALS['phpgw_data']['user']['firstname'];
+                               $result['profile_lastname']  = 
$GLOBALS['phpgw_data']['user']['lastname'];
+ 
+                               $GLOBALS['phpgw']->form_lock();
+ 
+                               $result['action_type'] = 'profile';
+                       }
+ 
+                       $GLOBALS['phpgw']->add_xsl('api.profile');
+                       $GLOBALS['phpgw_xml_apinode']->add_node('Update your 
profile','title');
  
                        return $result;

Index: class.statecache.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.statecache.php,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** class.statecache.php        3 Nov 2003 20:21:42 -0000       1.1.2.3
--- class.statecache.php        10 Nov 2003 00:36:04 -0000      1.1.2.4
***************
*** 38,42 ****
                }
                
!               function pause ($inputs = '##NOTSET##')
                {
                        if($inputs == '##NOTSET##')
--- 38,42 ----
                }
                
!               function pause($inputs = '##NOTSET##')
                {
                        if($inputs == '##NOTSET##')
***************
*** 50,54 ****
                }
                
!               function restore ($inputs = '##NOTSET##')
                {
                        
if(!isset($this->data[$GLOBALS['phpgw_data']['api']['op']]))
--- 50,54 ----
                }
                
!               function restore($inputs = '##NOTSET##')
                {
                        
if(!isset($this->data[$GLOBALS['phpgw_data']['api']['op']]))
***************
*** 64,68 ****
                }
  
!               function clear ()
                {
                        
if(isset($this->data[$GLOBALS['phpgw_data']['api']['prevop']]))
--- 64,68 ----
                }
  
!               function clear()
                {
                        
if(isset($this->data[$GLOBALS['phpgw_data']['api']['prevop']]))
***************
*** 72,73 ****
--- 72,74 ----
                }
        }
+ 

Index: class.phpgw.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.phpgw.php,v
retrieving revision 1.1.1.1.2.32
retrieving revision 1.1.1.1.2.33
diff -C2 -d -r1.1.1.1.2.32 -r1.1.1.1.2.33
*** class.phpgw.php     3 Nov 2003 20:21:41 -0000       1.1.1.1.2.32
--- class.phpgw.php     10 Nov 2003 00:36:04 -0000      1.1.1.1.2.33
***************
*** 208,212 ****
                function apimenu()
                {
!                       if($this->acl->check('api.base.start', 1))
                        {
                                $menu[] = array(
--- 208,212 ----
                function apimenu()
                {
!                       if ($this->acl->check('api.base.start', 1))
                        {
                                $menu[] = array(
***************
*** 215,219 ****
                                );
                        }
!                       if($this->acl->check('api.admin.start', 1))
                        {
                                $menu[] = array(
--- 215,220 ----
                                );
                        }
! 
!                       if ($this->acl->check('api.admin.start', 1))
                        {
                                $menu[] = array(
***************
*** 222,226 ****
                                );
                        }
!                       if($this->acl->check('api.base.prefs', 1))
                        {
                                $menu[] = array(
--- 223,228 ----
                                );
                        }
! 
!                       if ($this->acl->check('api.base.prefs', 1))
                        {
                                $menu[] = array(
***************
*** 229,233 ****
                                );
                        }
!                       if($this->acl->check('api.base.about', 1))
                        {
                                $menu[] = array(
--- 231,244 ----
                                );
                        }
! 
!                       if ($this->acl->check('api.base.profile', 1))
!                       {
!                               $menu[] = array(
!                                       'title'     => lang('Your Profile', 
'##NOTSET##', 'api'),
!                                       'op'        => 'api.base.profile'
!                               );
!                       }
! 
!                       if ($this->acl->check('api.base.about', 1))
                        {
                                $menu[] = array(
***************
*** 236,239 ****
--- 247,251 ----
                                );
                        }
+ 
                        $menu[] = array(
                                'title' => lang('Logout', '##NOTSET##', 'api'),
***************
*** 281,284 ****
--- 293,297 ----
                                && $GLOBALS['phpgw_data']['api']['op'] != 
'api.statecache.clear'
                                && $GLOBALS['phpgw_data']['api']['op'] != 
'api.statecache.pause'
+                               && $GLOBALS['phpgw_data']['api']['op'] != 
'api.statecache.cancel'
                                && 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][count($GLOBALS['phpgw_session']['phpgw_data']['op_history'])
 - 1]['op'] != $GLOBALS['phpgw_data']['api']['op'])
                        {





reply via email to

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