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.11, 1.1.2.12 class.a


From: Joseph Engo <address@hidden>
Subject: [Phpgroupware-cvs] api class.account_mgr.php, 1.1.2.11, 1.1.2.12 class.admin.php, 1.1.2.5, 1.1.2.6 class.base.php, 1.1.1.1.2.10, 1.1.1.1.2.11 class.phpgw.php, 1.1.1.1.2.13, 1.1.1.1.2.14
Date: Thu, 30 Oct 2003 21:18:16 +0000

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

Modified Files:
      Tag: proposal-branch
        class.account_mgr.php class.admin.php class.base.php 
        class.phpgw.php 
Log Message:
Started working on op history


Index: class.account_mgr.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.account_mgr.php,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -d -r1.1.2.11 -r1.1.2.12
*** class.account_mgr.php       29 Oct 2003 11:09:26 -0000      1.1.2.11
--- class.account_mgr.php       30 Oct 2003 21:18:14 -0000      1.1.2.12
***************
*** 27,33 ****
        $GLOBALS['api_account_mgr_menus_loaded'] = False;
        class api_account_mgr
!       {       
                function api_account_mgr()
                {
                        if (! $GLOBALS['api_account_mgr_menus_loaded'])
                        {
--- 27,40 ----
        $GLOBALS['api_account_mgr_menus_loaded'] = False;
        class api_account_mgr
!       {
!               var $method_titles = array();
! 
                function api_account_mgr()
                {
+                       $this->method_titles['show']   = 'List users';
+                       $this->method_titles['create'] = 'Create user';
+                       $this->method_titles['view']   = 'View user';
+                       $this->method_titles['delete'] = 'Delete user';
+ 
                        if (! $GLOBALS['api_account_mgr_menus_loaded'])
                        {

Index: class.base.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.base.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.base.php      29 Oct 2003 11:09:26 -0000      1.1.1.1.2.10
--- class.base.php      30 Oct 2003 21:18:14 -0000      1.1.1.1.2.11
***************
*** 33,36 ****
--- 33,175 ----
        class api_base
        {
+               var $method_titles = array();
+ 
+               function api_base()
+               {
+                       $this->method_titles['start'] = 'Home';
+                       $this->method_titles['about'] = 'About';
+                       $this->method_titles['prefs'] = 'Preferences';
+               }
+ 
+               /*!
+               @function start
+               @abstract The default operation for the api. main task is to 
load the hooks for api.start
+               */
+               function start()
+               {
+                       $result['text'] = 'This is where the home page will get 
its data and be loaded.';
+                       $result['inputs'] = func_get_args();
+                       $GLOBALS['phpgw']->add_xsl('api.start');
+                       
$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;
+               }
+ 
+               /*!
+               @function login
+               @abstract Catches login requests and then kicks off the login 
screen
+               */
+               function login()
+               {
+                       $GLOBALS['phpgw']->rpc->login();
+               }
+ 
+               /*!
+               @function logout
+               @abstract Handles logouts. First kills the session, then sets 
the op to login, which then creates a new anonymous session and goes thru 
api.base.login
+               */
+               function logout()
+               {
+                       $GLOBALS['phpgw']->rpc->logout();
+               }
+ 
+               /*!
+               @function about
+               @abstract Just displays the about screen
+               */
+               function about()
+               {
+                       $GLOBALS['phpgw']->add_xsl('api.about');
+                       
$GLOBALS['phpgw_xml_apinode']->add_node('About','title');
+                       return array('blah');
+               }
+ 
+               function prefs()
+               {
+                       $args = new safe_args();
+                       $args->set('appname','##REQUIRD##','string');
+                       $args->set('form_submit','##NOTSET##','any');
+                       $args->set('new_prefs','##NOTSET##','any');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ 
+                       $GLOBALS['phpgw']->add_xsl('api.widgets');
+                       
$GLOBALS['phpgw_xml_apinode']->add_node('Preferences','title');
+ 
+                       if ($args['appname'] == 'api')
+                       {
+                               $obj = CreateObject('api_base');
+                       }
+                       else
+                       {
+                               $obj = CreateObject($args['appname'] . '_base');
+                               
$GLOBALS['phpgw']->prefs->load($GLOBALS['phpgw_data']['user']['id'],$args['appname']);
+                       }
+ 
+                       if (! is_array($obj->prefs) && ! count($obj->prefs))
+                       {                       $this->method_titles['start'] = 
lang('Home');
+                               $GLOBALS['msgbox']->add(lang('Preferences not 
available or missing for this application'),__LINE__,__FILE__, 'warning');
+                               return array();
+                       }
+ 
+                       if ($args['form_submit'])
+                       {
+                               // FIXME: This should use safe_args to verify
+                               if (is_array($args['new_prefs']))
+                               {
+                                       foreach ($args['new_prefs'] as $key => 
$value)
+                                       {
+                                               
$GLOBALS['phpgw']->prefs->set($args['appname'] . '.' . 
$key,(string)$value,$GLOBALS['phpgw_data']['user']['id']);
+                                       }
+                               }
+                               $GLOBALS['msgbox']->add(lang('Preferences have 
been saved'),__LINE__,__FILE__, 'notice');
+                       }       
+                       $result['pref_widget'] = $obj->prefs;
+ 
+                       $total = count($result['pref_widget']);
+                       for ($i=0; $i<$total; $i++)
+                       {
+                               // The following "value setting" give me 
headaches as well, your not the only one (jengo)
+                               if ($result['pref_widget'][$i]['type'] == 
'inputbox')
+                               {
+                                       $result['pref_widget'][$i]['value'] = 
$GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']];
+                               }
+ 
+                               if ($result['pref_widget'][$i]['type'] == 
'checkbox')
+                               {foreach ($args['new_prefs'] as $key => 
$value)foreach ($args['new_prefs'] as $key => $value)
+                                       // FIXME: The value should be casted to 
a boolean type, don't test as a string
+                                       if 
($GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']] == 'True')
+                                       {
+                                               
$result['pref_widget'][$i]['checked'] = True;
+                                       }
+                                       else
+                                       {
+                                               
$result['pref_widget'][$i]['checked'] = False;
+                                       }
+                               }
+ 
+                               if ($result['pref_widget'][$i]['type'] == 
'selectbox')
+                               {
+                                       // If there is a value present, then 
reset all "selected" values to False, to be set again
+                                       if 
(strlen($GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']]))
+                                       {
+ 
+                                               $t = 
count($result['pref_widget'][$i]['values']);
+                                               for ($j=0; $j<$t; $j++)
+                                               {
+                                                       
$result['pref_widget'][$i]['values'][$j]['selected'] = False;
+ 
+                                                       if 
($result['pref_widget'][$i]['values'][$j]['value'] == 
$GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']])
+                                                       {
+                                                               
$result['pref_widget'][$i]['values'][$j]['selected'] = True;
+                                                       }
+                                               }
+ 
+                                       }
+                               }
+                       }
+                       return $result;
+               }
+ 
                var $prefs = array(
                        0 => array(
***************
*** 1645,1776 ****
                );
  
-               /*!
-               @function start
-               @abstract The default operation for the api. main task is to 
load the hooks for api.start
-               */
-               function start()
-               {
-                       $result['text'] = 'This is where the home page will get 
its data and be loaded.';
-                       $result['inputs'] = func_get_args();
-                       $GLOBALS['phpgw']->add_xsl('api.start');
-                       
$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;
-               }
- 
-               /*!
-               @function login
-               @abstract Catches login requests and then kicks off the login 
screen
-               */
-               function login()
-               {
-                       $GLOBALS['phpgw']->rpc->login();
-               }
- 
-               /*!
-               @function logout
-               @abstract Handles logouts. First kills the session, then sets 
the op to login, which then creates a new anonymous session and goes thru 
api.base.login
-               */
-               function logout()
-               {
-                       $GLOBALS['phpgw']->rpc->logout();
-               }
- 
-               /*!
-               @function about
-               @abstract Just displays the about screen
-               */
-               function about()
-               {
-                       $GLOBALS['phpgw']->add_xsl('api.about');
-                       
$GLOBALS['phpgw_xml_apinode']->add_node('About','title');
-                       return array('blah');
-               }
- 
-               function prefs()
-               {
-                       $args = new safe_args();
-                       $args->set('appname','##REQUIRD##','string');
-                       $args->set('form_submit','##NOTSET##','any');
-                       $args->set('new_prefs','##NOTSET##','any');
-                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
- 
-                       $GLOBALS['phpgw']->add_xsl('api.widgets');
-                       
$GLOBALS['phpgw_xml_apinode']->add_node('Preferences','title');
- 
-                       if ($args['appname'] == 'api')
-                       {
-                               $obj = CreateObject('api_base');
-                       }
-                       else
-                       {
-                               $obj = CreateObject($args['appname'] . '_base');
-                               
$GLOBALS['phpgw']->prefs->load($GLOBALS['phpgw_data']['user']['id'],$args['appname']);
-                       }
- 
-                       if (! is_array($obj->prefs) && ! count($obj->prefs))
-                       {
-                               $GLOBALS['msgbox']->add(lang('Preferences not 
available or missing for this application'),__LINE__,__FILE__, 'warning');
-                               return array();
-                       }
- 
-                       if ($args['form_submit'])
-                       {
-                               // FIXME: This should use safe_args to verify
-                               if (is_array($args['new_prefs']))
-                               {
-                                       foreach ($args['new_prefs'] as $key => 
$value)
-                                       {
-                                               
$GLOBALS['phpgw']->prefs->set($args['appname'] . '.' . 
$key,(string)$value,$GLOBALS['phpgw_data']['user']['id']);
-                                       }
-                               }
-                               $GLOBALS['msgbox']->add(lang('Preferences have 
been saved'),__LINE__,__FILE__, 'notice');
-                       }       
-                       $result['pref_widget'] = $obj->prefs;
- 
-                       $total = count($result['pref_widget']);
-                       for ($i=0; $i<$total; $i++)
-                       {
-                               // The following "value setting" give me 
headaches as well, your not the only one (jengo)
-                               if ($result['pref_widget'][$i]['type'] == 
'inputbox')
-                               {
-                                       $result['pref_widget'][$i]['value'] = 
$GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']];
-                               }
- 
-                               if ($result['pref_widget'][$i]['type'] == 
'checkbox')
-                               {
-                                       // FIXME: The value should be casted to 
a boolean type, don't test as a string
-                                       if 
($GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']] == 'True')
-                                       {
-                                               
$result['pref_widget'][$i]['checked'] = True;
-                                       }
-                                       else
-                                       {
-                                               
$result['pref_widget'][$i]['checked'] = False;
-                                       }
-                               }
- 
-                               if ($result['pref_widget'][$i]['type'] == 
'selectbox')
-                               {
-                                       // If there is a value present, then 
reset all "selected" values to False, to be set again
-                                       if 
(strlen($GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']]))
-                                       {
-                                               $t = 
count($result['pref_widget'][$i]['values']);
-                                               for ($j=0; $j<$t; $j++)
-                                               {
-                                                       
$result['pref_widget'][$i]['values'][$j]['selected'] = False;
- 
-                                                       if 
($result['pref_widget'][$i]['values'][$j]['value'] == 
$GLOBALS['phpgw']->prefs->data[$GLOBALS['phpgw_data']['user']['id']][$args['appname']
 . '.' . $result['pref_widget'][$i]['name']])
-                                                       {
-                                                               
$result['pref_widget'][$i]['values'][$j]['selected'] = True;
-                                                       }
-                                               }
- 
-                                       }
-                               }
-                       }
-                       return $result;
-               }
        }
  
--- 1784,1787 ----

Index: class.admin.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.admin.php,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** class.admin.php     26 Oct 2003 04:57:27 -0000      1.1.2.5
--- class.admin.php     30 Oct 2003 21:18:14 -0000      1.1.2.6
***************
*** 17,20 ****
--- 17,27 ----
        class api_admin
        {
+               var $method_titles = array();
+ 
+               function api_admin()
+               {
+                       $this->method_titles['start'] = 'Admin';
+               }
+ 
                function start()
                {
***************
*** 48,99 ****
                }
  
!               function adduser ()
!               {
!                       $args = new safe_args();
!                       $args->set('username');
!                       $args->set('passwd', '');
!                       $args->set('fname', '');
!                       $args->set('lname', '');
!                       $args->set('isadmin', False, 'bool');
!                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
!                       
$GLOBALS['phpgw_xml_apinode']->add_node('Admin','title');
!                       $GLOBALS['phpgw_xml_apinode']->add_node('Add 
User','subtitle');
  
-                       if (isset($args['username']))
-                       {
-                               $account_info['account_lid']       = 
$args['username'];
-                               $account_info['account_passwd']    = 
$args['passwd'];
-                               $account_info['account_firstname'] = 
$args['fname'];
-                               $account_info['account_lastname']  = 
$args['lname'];
-                               $account_info['account_type']      = 'u';
-                               $account_info['account_status']    = 'A';
-                               $account_info['account_expires']   = mktime 
(0,0,0,12,31,2005);
-                               $newid = 
$GLOBALS['phpgw']->accounts->create($account_info);
-                               if($newid === False)
-                               {
-                                       $result['text'] = '';
-                                       return $result;
-                               }
-                               $result['text'] = 'Created 
'.$args['username'].' which has id of '.$newid;
  
-                               $acl = createobject('api_acl', 
array('account_id'=>$newid));
-                               if($args['username'])
-                               {
-                                       $acl->add('.',63);
-                               }
-                               else
-                               {
-                                       $acl->add('api.base',1);
-                                       $acl->add('skel.base',1);
-                                       $acl->add('wcm.base',1);
-                                       $acl->add('admin.base',1);
-                               }
-                       }
-                       else
-                       {
-                               $result['text'] = 'Enter details';
-                       }
-                       $GLOBALS['phpgw']->add_xsl('api.admin_adduser');
-                       return $result;
-               }       
-       }
--- 55,59 ----
                }
  
!       }
  
  

Index: class.phpgw.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.phpgw.php,v
retrieving revision 1.1.1.1.2.13
retrieving revision 1.1.1.1.2.14
diff -C2 -d -r1.1.1.1.2.13 -r1.1.1.1.2.14
*** class.phpgw.php     29 Oct 2003 11:09:26 -0000      1.1.1.1.2.13
--- class.phpgw.php     30 Oct 2003 21:18:14 -0000      1.1.1.1.2.14
***************
*** 114,129 ****
                                /* load up the accounts, preferences and 
application classeses */                       
                                /* and also have them send their appropriate 
data to phpgw_data */
                                $this->accounts = 
createobject('api_accounts',$GLOBALS['phpgw_session']['session_lid']);
                                $this->accounts->fill_phpgw_data();
                                $this->acl      = createobject('api_acl');
        
                                $this->prefs = createobject('api_prefs');
                                $this->prefs->fill_phpgw_data();
  
  //$GLOBALS['phpgw_data']['server']['translate_service'] = 'google';
  //$GLOBALS['phpgw_data']['prefs']['api.lang'] = 'es';
                                $this->lang = createobject('api_lang');
- 
                                $this->lang->switchlang();
  
                                $this->apps = createobject('api_apps');
--- 114,137 ----
                                /* load up the accounts, preferences and 
application classeses */                       
                                /* and also have them send their appropriate 
data to phpgw_data */
+                               $GLOBALS['debug_timer']['api_aaccount_start']  
= perfgetmicrotime();
                                $this->accounts = 
createobject('api_accounts',$GLOBALS['phpgw_session']['session_lid']);
                                $this->accounts->fill_phpgw_data();
+                               $GLOBALS['debug_timer']['api_aaccount_end']    
= perfgetmicrotime();
+ 
+                               $GLOBALS['debug_timer']['api_acl_start']       
= perfgetmicrotime();
                                $this->acl      = createobject('api_acl');
+                               $GLOBALS['debug_timer']['api_acl_end']         
= perfgetmicrotime();
        
+                               $GLOBALS['debug_timer']['api_pref_start']      
= perfgetmicrotime();
                                $this->prefs = createobject('api_prefs');
                                $this->prefs->fill_phpgw_data();
+                               $GLOBALS['debug_timer']['api_pref_end']        
= perfgetmicrotime();
  
  //$GLOBALS['phpgw_data']['server']['translate_service'] = 'google';
  //$GLOBALS['phpgw_data']['prefs']['api.lang'] = 'es';
+                               $GLOBALS['debug_timer']['api_lang_start']      
= perfgetmicrotime();
                                $this->lang = createobject('api_lang');
                                $this->lang->switchlang();
+                               $GLOBALS['debug_timer']['api_lang_end']        
= perfgetmicrotime();
  
                                $this->apps = createobject('api_apps');
***************
*** 235,239 ****
                        /* Make sure the base classes are loaded. */
                        $this->load_base_classes();
!                       
                        /* Check to see if we should load the main xsl */
                        if($args['loadmainxsl'])
--- 243,247 ----
                        /* Make sure the base classes are loaded. */
                        $this->load_base_classes();
! 
                        /* Check to see if we should load the main xsl */
                        if($args['loadmainxsl'])
***************
*** 250,253 ****
--- 258,290 ----
                        }
  
+                       // Don't add login, or if the last op is a duplicate
+                       if ($GLOBALS['phpgw_data']['api']['op'] != 
'api.base.login' && 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][count($GLOBALS['phpgw_session']['phpgw_data']['op_history'])
 - 1]['op'] != $GLOBALS['phpgw_data']['api']['op'])
+                       {
+                               // I don't like the idea of re-loading this 
class when its already been loaded.
+                               // There should be a global instance of it 
avaiable. (jengo)
+                               list($appname,$class,$method) = 
explode(".",$GLOBALS['phpgw_data']['api']['op']);
+                               $obj = CreateObject($appname . '_' . $class);
+ 
+                               if (is_array($obj->method_titles) && 
$obj->method_titles[$method])
+                               {
+                                       $_title = 
lang($obj->method_titles[$method]);
+                               }
+                               else
+                               {
+                                       $_title = 
$GLOBALS['phpgw_data']['api']['op'];
+                               }
+ 
+                               
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][] = array(
+                                       'title' => $_title,
+                                       'op'    => 
$GLOBALS['phpgw_data']['api']['op'],
+                                       'data'  => array()
+                               );
+ 
+                               if 
(count($GLOBALS['phpgw_session']['phpgw_data']['op_history']) > 5)
+                               {
+                                       
array_shift($GLOBALS['phpgw_session']['phpgw_data']['op_history']);
+                               }
+                       }
+ 
                        /* If any, add the hooks to the API XML node */
                        if(count($this->hooks->data) > 0)
***************
*** 297,302 ****
                        
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['user'],'user');
                        
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['prefs'],'prefs');
                        $GLOBALS['phpgw_xml_apinode']->add_node(strftime('%A, 
%B %e %Y',time()),'currentdate');
!                       
                        /* Add the API section to the XML doc */                
        
                        
$GLOBALS['phpgw_xmldoc']->add_node($GLOBALS['phpgw_xml_apinode']);
--- 334,340 ----
                        
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['user'],'user');
                        
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['prefs'],'prefs');
+                       
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_session']['phpgw_data']['op_history'],'op_history');
                        $GLOBALS['phpgw_xml_apinode']->add_node(strftime('%A, 
%B %e %Y',time()),'currentdate');
! 
                        /* Add the API section to the XML doc */                
        
                        
$GLOBALS['phpgw_xmldoc']->add_node($GLOBALS['phpgw_xml_apinode']);
***************
*** 353,357 ****
                                }
                        }
!                                               
                        
list($GLOBALS['phpgw_data']['flags']['req_app'],$GLOBALS['phpgw_data']['flags']['req_class'],$GLOBALS['phpgw_data']['flags']['req_method'])
 = explode('.',$GLOBALS['phpgw_data']['api']['op']);
                        if (!isset($GLOBALS['phpgw_data']['flags']['req_app']))
--- 391,395 ----
                                }
                        }
! 
                        
list($GLOBALS['phpgw_data']['flags']['req_app'],$GLOBALS['phpgw_data']['flags']['req_class'],$GLOBALS['phpgw_data']['flags']['req_method'])
 = explode('.',$GLOBALS['phpgw_data']['api']['op']);
                        if (!isset($GLOBALS['phpgw_data']['flags']['req_app']))





reply via email to

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