phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] api class.msgbox.php, 1.1.1.1.2.6 class.phpgw.php, 1


From: uid65886
Subject: [Phpgroupware-cvs] api class.msgbox.php, 1.1.1.1.2.6 class.phpgw.php, 1.1.1.1.2.39 class.base.php, 1.1.1.1.2.26 class.account_mgr.php, 1.1.2.30 class.acl.php, 1.1.1.1.2.7 class.statecache.php, 1.1.2.5 class.admin.php, 1.1.2.21 starter.inc.php, 1.1.1.1.2.25
Date: Wed, 27 Apr 2005 07:38:48 -0000

Update of api

Modified Files:
     Branch: proposal-branch
            class.msgbox.php lines: +12 -1
            class.phpgw.php lines: +2 -60
            class.base.php lines: +138 -5
            class.account_mgr.php lines: +21 -21
            class.acl.php lines: +2 -2
            class.statecache.php lines: +221 -19
            class.admin.php lines: +16 -2
            starter.inc.php lines: +51 -25

Log Message:
*NOTE* Since Savannah was down for a long period of time, this is many of the 
changes I made locally.  Some things aren't finished and I might have forgotten 
to mention quite a few things I did durring the down time.  What I can remeber 
is as follows:

- Changed the way forms work, developers no longer specify there <form> tags,
  the API handles this. Its mainly due to the way statecaching works now.
  This only means, each screen can ONLY be *1* form.
- Total overhaul of statecache and op history, this isn't has cumbersum as the
  previous version.
- Fixed a number of image issues with IE
- Fixed table alignment issues with IE and Firebird
- Created widget for time fields
- Added in jscalendar and created widgets for it. (Note: This needs to follow
  users preferences)
- Fixed quite a few issues with layout on Opera
- Ported over nextmatchs, this needs a little twinking on how the op is
  passed, I don't think it should be a required field unless its an odd case.
  Chances are, I will change this.
- Note: There is a current bug with preferences not getting saved most of the
  time, I am looking into it.
- Started working on the ACL manager for single records. This is no where near
  complete and needs a lot of work.
- Started working on the infolog port (application name WILL change in the
  future, I hate the name infolog) I needed this as a test bed for multipage
  forms using tabs, making tabs in general work, ACL manager for single
  records on new records, etc. For this application to fully work, it needs
  contacts and categories. So, until those are complete, this application will
  NOT be usable.
- Removed some legacy code from the PostgreSQL db classes. The MySQL ones are
  NOT as up to date, they will require some updating. I am not worring about
  it now, becuase I will be rewritting the PostgreSQL ones first. It will be
  re-written using safeargs, and as an extended class like the 0.9.x ones, not
  to mention a ton of changes to make it cleaner and better error handling.

====================================================
Index: api/class.msgbox.php
diff -u api/class.msgbox.php:1.1.1.1.2.5 api/class.msgbox.php:1.1.1.1.2.6
--- api/class.msgbox.php:1.1.1.1.2.5    Mon Nov 17 23:39:06 2003
+++ api/class.msgbox.php        Thu Dec 25 02:20:18 2003
@@ -58,6 +58,17 @@
                                        $GLOBALS['phpgw']->finish(False);
                                        break;
                                case 'debug':
+                                       if(is_array($debug_data) || 
is_object($debug_data))
+                                       {
+                                               ob_start();
+                                               print_r($debug_data);
+                                               $debug_data = ob_get_contents();
+                                               ob_end_clean();
+                                       }
+                                       $debug_data = htmlentities($debug_data);
+                                       $this->data[] = array('text'=>$text, 
'line'=>$line, 'file'=>$file, 'type'=>'debug', 'debug_data'=>$debug_data);
+                                       
$GLOBALS['phpgw']->add_xsl('api.phpgw_empty');
+                                       break;
                                case 'fataldebug':
                                        if(is_array($debug_data) || 
is_object($debug_data))
                                        {

====================================================
Index: api/class.phpgw.php
diff -u api/class.phpgw.php:1.1.1.1.2.38 api/class.phpgw.php:1.1.1.1.2.39
--- api/class.phpgw.php:1.1.1.1.2.38    Fri Nov 21 00:39:31 2003
+++ api/class.phpgw.php Thu Dec 25 02:20:18 2003
@@ -27,7 +27,7 @@
        $GLOBALS['docs']['api']['classes']['api_phpgw'] = array(
                'abstract'=>'Central handler class in the api.'
        );
-
+
        class api_phpgw
        {
                var $session;
@@ -387,64 +387,6 @@
                                }
                        }

-                       // Don't add login, or if the last op is a duplicate
-                       if ($GLOBALS['phpgw_data']['api']['op'] != 
'api.base.login'
-                               && $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'])
-                       {
-                               list($appname,$classname,$method) = 
explode(".",$GLOBALS['phpgw_data']['api']['op']);
-
-                               // If it doesn't exist, don't spit out any 
errors or PHP warnings, the API handles that later on
-                               if (file_exists(PHPGW_ROOT . SEP . $appname . 
SEP . 'class.' . $classname . '.php'))
-                               {
-                                       require_once(PHPGW_ROOT . SEP . 
$appname . SEP . 'class.' . $classname . '.php');
-
-                                       if 
(isset($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$method]['title']))
-                                       {
-                                               $_title = 
lang($GLOBALS['docs'][$appname]['classes'][$appname.'_'.$classname]['functions'][$method]['title']);
-                                       }
-                                       else
-                                       {
-                                               $_title = 
$GLOBALS['phpgw_data']['api']['op'];
-                                       }
-
-                                       if 
(is_array($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$method]['params']))
-                                       {
-                                               foreach 
($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$method]['params'] as $key => $params)
-                                               {
-                                                       // For some odd reason, 
when you call this passing ##REQUIRED## it causes PHP to run out of memory
-                                                       // This appears to be a 
better temp work around then disabling this line.
-                                                       $data[$key] = 
get_var($key,array('GET','POST'),$params['type'],'##NOTSET##');
-                                               }
-                                       }
-
-                                       if ($GLOBALS['phpgw_data']['api']['op'] 
!= 'api.base.op_history_redirect')
-                                       {
-                                               
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][] = array(
-                                                       'title' => $_title,
-                                                       'op'    => 
$GLOBALS['phpgw_data']['api']['op'],
-                                                       'data'  => $data
-                                               );
-                                       }
-
-                                       if 
(count($GLOBALS['phpgw_session']['phpgw_data']['op_history']) > 5 && 
$GLOBALS['phpgw_data']['api']['op'] != 'api.base.op_history_redirect')
-                                       {
-                                               
array_shift($GLOBALS['phpgw_session']['phpgw_data']['op_history']);
-                                       }
-                               }
-                       }
-
-                       // Remove the data element, we don't want this in the 
XML, it can get way too big (jengo)
-                       $xml_history = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'];
-                       $total       = count($xml_history);
-                       for ($i=0; $i<$total; $i++)
-                       {
-                               unset($xml_history[$i]['data']);
-                       }
-                       
$GLOBALS['phpgw_xml_apinode']->add_node($xml_history,'op_history');
-
                        if (! $GLOBALS['missing_critical'])
                        {
                                /* If any, add the hooks to the API XML node */

====================================================
Index: api/class.base.php
diff -u api/class.base.php:1.1.1.1.2.25 api/class.base.php:1.1.1.1.2.26
--- api/class.base.php:1.1.1.1.2.25     Mon Dec  1 23:55:33 2003
+++ api/class.base.php  Thu Dec 25 02:20:18 2003
@@ -69,6 +69,18 @@
                'title'        => 'Logout',
                'abstract'     => 'Logout from the system. Will revert user 
back into anonymous session.'
        );
+
+       $functions['config']   = array(
+               'type'         => 'public',
+               'title'        => 'Configuration',
+               'abstract'     => 'Configuration section',
+               'discussion'   => 'This is used by all apps to create a generic 
configuration for there application',
+               'params'       => array(
+                       'location'    => array('type'=>'string', 'default' => 
'##REQUIRED##', 'desc' => 'Location for there config'),
+                       'form_submit' => array('type'=>'any',    'default' => 
'##NOTSET##',   'desc' => 'Set if the user is submitting'),
+                       'new_config'  => array('type'=>'any',    'default' => 
'##NOTSET##',   'desc' => 'Values submitted from the form')
+               )
+       );

        $functions['prefs']    = array(
                'type'         => 'public',
@@ -238,7 +250,7 @@
                function op_history_redirect()
                {
                        $args = new safe_args();
-                       $args->set('position_id','##REQUIRED##','int');
+                       $args->set('position_id','##REQUIRED##','string');
                        $args->set('set_state_values','##NOTSET##','any');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);

@@ -251,7 +263,13 @@
                                $args['set_state_values'] = True;
                        }

-                       $loc_data = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$args['position_id']];
+                       $total = 
count($GLOBALS['phpgw_session']['phpgw_data']['op_history']);
+                       for ($i=0; $i<$total; $i++)
+                       {
+                               
$history[$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$i]['position']] 
= $GLOBALS['phpgw_session']['phpgw_data']['op_history'][$i];
+                       }
+
+                       $loc_data = $history[$args['position_id']];
                        if (! $loc_data['title'])
                        {
                                $GLOBALS['msgbox']->add(lang('History on this 
operation not valid or expired'),__LINE__,__FILE__, 'warning');
@@ -266,8 +284,9 @@
                        }

                        $result = array();
-                       $result = ExecMethod($loc_data['op'],$loc_data['data'], 
False);
+                       $result = execMethod($loc_data['op'],$loc_data['data'], 
False);

+                       
$GLOBALS['phpgw_session']['phpgw_data']['current_history_position'] = 
$args['position_id'];
                        if ($args['set_state_values'])
                        {
                                if 
(isset($GLOBALS['phpgw_session']['form_state_values'][$loc_data['op']]))
@@ -279,6 +298,112 @@
                        return $result;
                }

+               // ACL popup window for ACL on records only
+               function acl()
+               {
+                       $args = new safe_args();
+                       $args->set('location','##REQUIRED##','string');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+
+                       $user = array('username' => 
$GLOBALS['phpgw_session']['session_lid']);
+                       $GLOBALS['phpgw_xml_apinode']->add_node($user,'user');
+                       $GLOBALS['phpgw']->add_xsl('api.acl_popup');
+
+                       $result['acl_accounts'] = 
$GLOBALS['phpgw']->accounts->list_repository();
+                       $result['acl_location'] = $args['location'];
+
+                       $GLOBALS['phpgw_xmldoc']->add_node($result,'APP');
+                       $GLOBALS['phpgw']->finish(False);
+               }
+
+               function config()
+               {
+                       $args = new safe_args();
+                       $args->set('location','##REQUIRED##','string');
+                       $args->set('form_submit','##NOTSET##','any');
+                       $args->set('new_config','##NOTSET##','any');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+
+                       $GLOBALS['phpgw']->add_xsl('api.widgets');
+                       if (strpos($args['location'],'.'))
+                       {
+                               list($app,$class) = 
explode('.',$args['location']);
+                       }
+                       else
+                       {
+                               $app   = $args['location'];
+                               $class = 'base';
+                       }
+
+                       // FIXME: Add ACL check
+                       $obj = CreateObject($app . '_' . $class);
+
+                       if (! is_array($obj->config) && ! count($obj->config))
+                       {
+                               $this->method_titles['start'] = lang('Home');
+                               $GLOBALS['msgbox']->add(lang('Configuration not 
available or missing for this application'),__LINE__,__FILE__, 'warning');
+                               return array();
+                       }
+
+                       if ($args['form_submit'])
+                       {
+
+
+                               $GLOBALS['msgbox']->add(lang('Configuration 
have been saved'),__LINE__,__FILE__, 'notice');
+                               return array();
+                       }
+                       else
+                       {
+                               $GLOBALS['phpgw']->form_lock();
+                       }
+
+                       $result['config_widget'] = $obj->config;
+                       $total = count($result['config_widget']);
+                       for ($i=0; $i<$total; $i++)
+                       {
+                               // The following "value setting" give me 
headaches as well, your not the only one (jengo)
+                               if ($result['config_widget'][$i]['type'] == 
'inputbox')
+                               {
+                                       $result['config_widget'][$i]['value'] = 
$GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' . 
$result['pref_widget'][$i]['name']];
+                               }
+
+                               if ($result['config_widget'][$i]['type'] == 
'checkbox')
+                               {
+                                       // FIXME: The value should be casted to 
a boolean type, don't test as a string
+                                       if 
($GLOBALS['phpgw_data']['prefs'][$args['appname'] . '.' . 
$result['pref_widget'][$i]['name']] == 'True')
+                                       {
+                                               
$result['pref_widget'][$i]['checked'] = True;
+                                       }
+                                       else
+                                       {
+                                               
$result['pref_widget'][$i]['checked'] = False;
+                                       }
+                               }
+
+                               if ($result['config_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_data']['prefs'][$args['appname'] . '.' . 
$result['pref_widget'][$i]['name']]))
+                                       {
+
+                                               $t = 
count($result['config_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_data']['prefs'][$args['appname'] . '.' . 
$result['pref_widget'][$i]['name']])
+                                                       {
+                                                               
$result['pref_widget'][$i]['values'][$j]['selected'] = True;
+                                                       }
+                                               }
+
+                                       }
+                               }
+                       }
+
+                       return $result;
+               }
+
                function prefs()
                {
                        $args = new safe_args();
@@ -294,6 +419,7 @@

                        $GLOBALS['phpgw']->add_xsl('api.widgets');

+                       // FIXME: Add ACL check
                        if ($args['appname'] == 'api')
                        {
                                $obj = CreateObject('api_base');
@@ -305,7 +431,8 @@
                        }

                        if (! is_array($obj->prefs) && ! count($obj->prefs))
-                       {                       $this->method_titles['start'] = 
lang('Home');
+                       {
+                               $this->method_titles['start'] = lang('Home');
                                $GLOBALS['msgbox']->add(lang('Preferences not 
available or missing for this application'),__LINE__,__FILE__, 'warning');
                                return array();
                        }
@@ -321,7 +448,13 @@
                                        }
                                }
                                $GLOBALS['msgbox']->add(lang('Preferences have 
been saved'),__LINE__,__FILE__, 'notice');
+                               return array();
                        }
+                       else
+                       {
+                               $GLOBALS['phpgw']->form_lock();
+                       }
+
                        $result['pref_widget'] = $obj->prefs;

                        $total = count($result['pref_widget']);

====================================================
Index: api/class.account_mgr.php
diff -u api/class.account_mgr.php:1.1.2.29 api/class.account_mgr.php:1.1.2.30
--- api/class.account_mgr.php:1.1.2.29  Mon Dec  1 23:55:33 2003
+++ api/class.account_mgr.php   Thu Dec 25 02:20:18 2003
@@ -56,11 +56,11 @@
                'abstract'     => 'Edit user account',
                'params'       => array(
                        'account_id'                => array('type' => 'int', 
'default' => '##NOTSET##', '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')
+                       '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')
                )
        );

@@ -79,7 +79,7 @@
                'abstract'     => 'Delete user account',
                'params'       => array(
                        'account_id'               => array('type' => 'int', 
'default' => '##NOTSET##', 'desc' => 'Account ID number'),
-                       'answer'                   => array('type' => 'any', 
'default' => '##NOTSET##',  'desc' => 'Answer to yes no dialog')
+                       'answer'                   => array('type' => 'any', 
'default' => '##NOTSET##', 'desc' => 'Answer to yes no dialog')
                )
        );

@@ -122,6 +122,7 @@

                                $GLOBALS['phpgw']->add_xsl('api.account_mgr');
                                $GLOBALS['phpgw']->add_xsl('api.widgets');
+                               $GLOBALS['phpgw']->add_xsl('api.acl_mgr');
                                $GLOBALS['api_account_mgr_menus_loaded'] = True;
                        }
                        $this->db = $GLOBALS['phpgw']->db;
@@ -174,9 +175,18 @@

                function start()
                {
-                       $result['accounts']    = 
$GLOBALS['phpgw']->accounts->list_repository();
+                       $args = new safe_args();
+                       $args->set('start',0,'int');
+                       $args->set('order','account_lid','string');
+                       $args->set('sort', 'asc', 'string');
+                       $args = $args->get(func_get_args(),__LINE__,__FILE__);
+
+                       $args['offset']        = 
$GLOBALS['phpgw_data']['prefs']['api.maxmatchs'];
+                       $result['accounts']    = 
$GLOBALS['phpgw']->accounts->list_repository($args);
                        $result['action_type'] = 'accounts';

+                       
$GLOBALS['phpgw']->interface->handle_nextmatchs($args['start'],$GLOBALS['phpgw']->accounts->record_count());
+
                        if 
($GLOBALS['phpgw']->acl->check('api.account_mgr.edit',1,1))
                        {
                                $result['edit_allowed']   = True;
@@ -193,7 +203,7 @@
                function create()
                {
                        $args = new safe_args();
-                       $args->set('create_account_submit', '##NOTSET##', 
'any');
+                       $args->set('form_submit', 'False', 'any');
                        $args->set('acl_advanced_submit','##NOTSET##','any');
                        $args->set('account_lid', '##NOTSET##', 'any');
                        $args->set('account_firstname', '##NOTSET##', 'any');
@@ -203,9 +213,6 @@
                        $args->set('acl_allow',array(),'any');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);

-                       $GLOBALS['phpgw']->add_xsl('api.account_mgr');
-                       $GLOBALS['phpgw']->add_xsl('api.acl_mgr');
-
                        $result = array(
                                'account_lid'       => $args['account_lid'],
                                'account_firstname' => 
$args['account_firstname'],
@@ -216,11 +223,11 @@
                        $result['action_type'] = 'add_account';
                        if ($args['acl_advanced_submit'])
                        {
-                               
execMethod('api.statecache.pause',$GLOBALS['phpgw']->interface->get_inputs());
+                               
//execMethod('api.statecache.pause',$GLOBALS['phpgw']->interface->get_inputs());

                                execMethod('api.acl_mgr.account');
                        }
-                       else if ($args['create_account_submit'] == 'True')
+                       else if ($args['form_submit'] == 'True')
                        {
                                if (! strlen($args['account_lid']))
                                {
@@ -333,9 +340,6 @@
                                return;
                        }

-                       $GLOBALS['phpgw']->add_xsl('api.account_mgr');
-                       $GLOBALS['phpgw']->add_xsl('api.widgets');
-                       $GLOBALS['phpgw']->add_xsl('api.acl_mgr');

                        $account = 
createObject('api_accounts',(int)$args['account_id']);
                        $result = array(
@@ -436,9 +440,6 @@
                                return;
                        }

-                       $GLOBALS['phpgw']->add_xsl('api.widgets');
-                       $GLOBALS['phpgw']->add_xsl('api.acl_mgr');
-
                        $this->menu_for_this_user($args['account_id']);

                        $args['account']        = $args['account_id'];
@@ -490,7 +491,6 @@

                        if ($args['answer'] == '##NOVAR##')
                        {
-                               $GLOBALS['phpgw']->add_xsl('api.widgets');
                                $result['dialog'] = array(
                                        'question' => lang('Are you sure you 
want to delete the user %s ?',$account_lid),
                                        'yes_op'   => 'api.account_mgr.delete',

====================================================
Index: api/class.acl.php
diff -u api/class.acl.php:1.1.1.1.2.6 api/class.acl.php:1.1.1.1.2.7
--- api/class.acl.php:1.1.1.1.2.6       Mon Dec  1 07:36:34 2003
+++ api/class.acl.php   Thu Dec 25 02:20:18 2003
@@ -243,7 +243,7 @@
                        $args->set('acl_isop', $this->acl_isop, 'number');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);

-                       if($args['acl_isop'] == 1)
+                       if ($args['acl_isop'] == 1)
                        {
                                $args['op'] = '.'.$args['op'];
                        }

====================================================
Index: api/class.statecache.php
diff -u api/class.statecache.php:1.1.2.4 api/class.statecache.php:1.1.2.5
--- api/class.statecache.php:1.1.2.4    Mon Nov 10 00:36:04 2003
+++ api/class.statecache.php    Thu Dec 25 02:20:18 2003
@@ -25,7 +25,9 @@

        class api_statecache
        {
-               var $data = Array();
+               var $data         = array();
+               var $xml_history  = array();
+               var $sess_history = array();

                function pre_serialize()
                {
@@ -36,39 +38,239 @@
                {
                        // stub. No restore needed.
                }
-
-               function pause($inputs = '##NOTSET##')
+
+               function api_statecache()
+               {
+                       $this->data = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'];
+               }
+
+               function set()
                {
-                       if($inputs == '##NOTSET##')
+                       // Just a short cut to make it easier to read
+                       if ($this->allow_set())
                        {
-                               $inputs = array();
+                               $appname    = 
$GLOBALS['phpgw_data']['flags']['req_app'];
+                               $classname  = 
$GLOBALS['phpgw_data']['flags']['req_class'];
+                               $methodname = 
$GLOBALS['phpgw_data']['flags']['req_method'];
+
+                               // If it doesn't exist, don't spit out any 
errors or PHP warnings, the API handles that later on
+                               if (file_exists(PHPGW_ROOT . SEP . $appname . 
SEP . 'class.' . $classname . '.php'))
+                               {
+                                       require_once(PHPGW_ROOT . SEP . 
$appname . SEP . 'class.' . $classname . '.php');
+
+                                       if 
(isset($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$methodname]['title']))
+                                       {
+                                               $_title = 
lang($GLOBALS['docs'][$appname]['classes'][$appname.'_'.$classname]['functions'][$methodname]['title']);
+                                       }
+                                       else
+                                       {
+                                               $_title = 
$GLOBALS['phpgw_data']['api']['op'];
+                                       }
+
+                                       if 
(is_array($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$methodname]['params']))
+                                       {
+                                               foreach 
($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$methodname]['params'] as $key => $params)
+                                               {
+                                                       // For some odd reason, 
when you call this passing ##REQUIRED## it causes PHP to run out of memory
+                                                       // This appears to be a 
better temp work around then disabling this line. (jengo)
+                                                       $data[$key] = 
get_var($key,array('GET','POST'),$params['type'],'##NOTSET##');
+                                               }
+                                       }
+
+                                       if ($GLOBALS['phpgw_data']['api']['op'] 
!= 'api.statecache.restore')
+                                       {
+                                               // If they refresh the current 
page, we lose the current position, so we are going to store it
+                                               // This is only done durring 
new page loads
+                                               
$GLOBALS['phpgw_session']['phpgw_data']['current_history_position'] = 
md5(rand(1,RAND_MAX) . time());
+
+                                               
$this->data[$GLOBALS['phpgw_session']['phpgw_data']['current_history_position']]
 = array(
+                                                       'position' => 
$GLOBALS['phpgw_session']['phpgw_data']['current_history_position'],
+                                                       'title'    => $_title,
+                                                       'op'       => 
$GLOBALS['phpgw_data']['api']['op'],
+                                                       'data'     => $data
+                                               );
+                                       }
+
+                                       if (count($this->data) > 5 && 
$GLOBALS['phpgw_data']['api']['op'] != 'api.base.op_history_redirect')
+                                       {
+                                               array_shift($this->data);
+                                       }
+                                       
$GLOBALS['phpgw_session']['phpgw_data']['op_history'] = $this->data;
+                               }
+
                        }
-                       if (isset($GLOBALS['phpgw_data']['api']['prevop']))
+
+                       $this->handle_xml_return();
+               }
+
+               function minimize($inputs = '##NOTSET##',$position_id)
+               {
+                       $current_op = 
$GLOBALS['phpgw_session']['phpgw_data']['op_history'][$position_id]['op'];
+                       list($appname,$classname,$methodname) = 
explode('.',$current_op);
+
+                       // If it doesn't exist, don't spit out any errors or 
PHP warnings, the API handles that later on
+                       if (file_exists(PHPGW_ROOT . SEP . $appname . SEP . 
'class.' . $classname . '.php'))
                        {
-                               
$this->data[$GLOBALS['phpgw_data']['api']['prevop']] = $inputs;
+                               require_once(PHPGW_ROOT . SEP . $appname . SEP 
. 'class.' . $classname . '.php');
+
+                               if 
(isset($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$methodname]['title']))
+                               {
+                                       $_title = 
lang($GLOBALS['docs'][$appname]['classes'][$appname.'_'.$classname]['functions'][$methodname]['title']);
+                               }
+                               else
+                               {
+                                       $_title = 
$GLOBALS['phpgw_data']['api']['op'];
+                               }
+
+                               if 
(is_array($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$methodname]['params']))
+                               {
+                                       foreach 
($GLOBALS['docs'][$appname]['classes'][$appname . '_' . 
$classname]['functions'][$methodname]['params'] as $key => $params)
+                                       {
+                                               // For some odd reason, when 
you call this passing ##REQUIRED## it causes PHP to run out of memory
+                                               // This appears to be a better 
temp work around then disabling this line. (jengo)
+                                               $data[$key] = 
get_var($key,array('GET','POST'),$params['type'],'##NOTSET##');
+                                       }
+                               }
                        }
+
+                       
$GLOBALS['phpgw_session']['phpgw_data']['statecache'][$current_op] = $data;
+
+                       end($this->data);
+                       $prev = prev($this->data);
+
+                       // If the previous op they we are heading to is the 
same op, we are basicly creating an infinite loop
+                       // that can be hard to get out of.  We will keep going 
backwords for 3 times, if we can't find anything
+                       // that will work by then, then we will just abort to 
the default page. (jengo)
+                       if ($prev['op'] == $current_op)
+                       {
+                               $prev = prev($this->data);
+                       }
+
+                       if ($prev['op'] == $current_op)
+                       {
+                               $prev = prev($this->data);
+                       }
+
+                       // FIXME: This should match the user / system default 
page
+                       if ($prev['op'] == $current_op || $prev['op'] == '')
+                       {
+                               $inputs['op'] = 'api.base.start';
+
+                               return $inputs;
+                       }
+
+                       return $this->restore($inputs,$prev['position']);
                }
-
-               function restore($inputs = '##NOTSET##')
+
+               function handle_xml_return()
                {
-                       
if(!isset($this->data[$GLOBALS['phpgw_data']['api']['op']]))
+                       reset($this->data);
+
+                       foreach ($this->data as $key => $value)
                        {
-                               return $inputs;
+                               $xml_history[] = array(
+                                       'position' => $key,
+                                       'title'    => $value['title']
+                               );
                        }
-
-                       if($inputs == '##NOTSET##')
+
+                       
$GLOBALS['phpgw_xml_apinode']->add_node($xml_history,'op_history');
+                       // This is for the "close" button
+                       
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_session']['phpgw_data']['current_history_position'],'current_history_position');
+               }
+
+               function close($inputs = '##NOTSET##',$position_id)
+               {
+                       $o_op = $this->data[$position_id]['op'];
+                       
unset($GLOBALS['phpgw_session']['phpgw_data']['statecache'][$o_op]);
+
+                       foreach ($this->data as $key => $null)
                        {
-                               $inputs = array();
+                               if ($key == $position_id)
+                               {
+                                       $n_key = $p_key;
+                                       $not_found = False;
+                                       $p = prev($this->data);
+                                       break;
+                               }
+                               $p_key = $key;
                        }
-                       return array_merge($inputs, 
$this->data[$GLOBALS['phpgw_data']['api']['op']]);
+
+                       unset($this->data[$position_id]);
+
+                       if (! $n_key)
+                       {
+                               reset($this->data);
+                               $n_key = key($this->data);
+                       }
+
+                       $GLOBALS['phpgw_session']['phpgw_data']['op_history'] = 
$this->data;
+
+                       
$GLOBALS['phpgw_session']['phpgw_data']['current_history_position'] = 
$this->data[$n_key]['position'];
+                       $op               = $this->data[$n_key]['op'];
+                       $statecache_data  = 
$GLOBALS['phpgw_session']['phpgw_data']['statecache'][$this->data[$n_key]['op']];
+
+                       $GLOBALS['phpgw_session']['phpgw_data']['op_history'] = 
$this->data;
+                       $this->handle_xml_return();
+
+                       return 
array_merge($inputs,$this->data[$n_key]['data'],$statecache_data,array('op' => 
$this->data[$n_key]['op']));
                }

-               function clear()
+               function clear($inputs,$position_id)
                {
-                       
if(isset($this->data[$GLOBALS['phpgw_data']['api']['prevop']]))
+                       $op = $this->data[$position_id]['op'];
+
+                       foreach 
($GLOBALS['phpgw_session']['phpgw_data']['statecache'][$op] as $key => $values)
                        {
-                               
unset($this->data[$GLOBALS['phpgw_data']['api']['prevop']]);
+                               unset($inputs[$key]);
                        }
+                       
unset($GLOBALS['phpgw_session']['phpgw_data']['statecache'][$op]);
+
+                       return array_merge($inputs,array('form_submit' => 
'False'),array('op' => $op));
+               }
+
+               function restore_op($inputs,$op)
+               {
+                       return 
array_merge($GLOBALS['phpgw_session']['phpgw_data']['statecache'][$op],$inputs);
+               }
+
+               function restore($inputs = '##NOTSET##',$position_id)
+               {
+                       
$GLOBALS['phpgw_session']['phpgw_data']['current_history_position'] = 
$position_id;
+                       $op                                   = 
$this->data[$position_id]['op'];
+                       $statecache_data                      = 
$GLOBALS['phpgw_session']['phpgw_data']['statecache'][$op];
+                       $this->handle_xml_return();
+
+                       list($app,$class,$method) = explode('.',$op);
+                       require_once(PHPGW_ROOT . SEP . $app . SEP . 'class.' . 
$class . '.php');
+                       
$GLOBALS['phpgw_xml_apinode']->add_node(lang($GLOBALS['docs']['api']['classes'][$app
 . '_' . $class]['functions'][$method]['title']),'title');
+
+                       return 
array_merge($inputs,$this->data[$position_id]['data'],$statecache_data,array('op'
 => $op));
+               }
+
+               // Don't add login, or if the last op is a duplicate
+               function allow_set()
+               {
+                       $result = True;
+
+                       if ($GLOBALS['phpgw_data']['api']['op'] == 
'api.base.login')
+                       {
+                               $result = False;
+                       }
+
+                       if 
(ereg('api.statecache.',$GLOBALS['phpgw_data']['api']['op']))
+                       {
+                               $result = False;
+                       }
+
+                       $last = end($this->data);
+
+                       if ($last['op'] == $GLOBALS['phpgw_data']['api']['op'])
+                       {
+                               $result = False;
+                       }
+
+                       return $result;
                }
        }


====================================================
Index: api/class.admin.php
diff -u api/class.admin.php:1.1.2.20 api/class.admin.php:1.1.2.21
--- api/class.admin.php:1.1.2.20        Mon Dec  1 23:55:33 2003
+++ api/class.admin.php Thu Dec 25 02:20:18 2003
@@ -51,7 +51,6 @@
        {
                function api_admin()
                {
-                       $GLOBALS['phpgw']->add_xsl('api.admin');
                        $GLOBALS['phpgw']->add_xsl('api.widgets');

                        if 
($GLOBALS['phpgw']->acl->check('api.account_mgr.create',1,1))
@@ -73,6 +72,8 @@

                function start()
                {
+                       $GLOBALS['phpgw']->add_xsl('api.admin');
+
                        $result['g'] = '';
                        
$GLOBALS['phpgw_xml_apinode']->add_node('Admin','title');

@@ -86,6 +87,7 @@
                        $args->set('vsid','##REQUIRED##','string');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);

+                       $GLOBALS['phpgw']->add_xsl('api.admin');
                        $GLOBALS['phpgw_xml_apinode']->add_node('View session 
data','title');

                        $data = 
$GLOBALS['phpgw']->session->read_other_session($args['vsid']);
@@ -112,6 +114,8 @@
                        $args->set('answer', '##NOVAR##', 'any');
                        $args = $args->get(func_get_args(),__LINE__,__FILE__);

+                       $GLOBALS['phpgw']->add_xsl('api.admin');
+
                        if ($args['ksid'] == 
$GLOBALS['phpgw']->session->get_true_sid())
                        {
                                $GLOBALS['msgbox']->add(lang('You can not 
delete your own session'),__LINE__,__FILE__, 'warning');
@@ -152,6 +156,7 @@

                function current_users()
                {
+                       $GLOBALS['phpgw']->add_xsl('api.admin');
                        $GLOBALS['phpgw_xml_apinode']->add_node('Current 
Users','title');

                        $sessions = 
$GLOBALS['phpgw']->session->read_all_sessions(0);
@@ -192,6 +197,15 @@
                                'current_sid'   => 
$GLOBALS['phpgw']->session->get_true_sid()
                        );
                }
+
+               var $config = array(
+                       0 => array(
+                               'type'   => 'inputbox',
+                               'name'   => 'login_history_days_expires',
+                               'label'  => 'Number of days to keep login 
history for',
+                               'value'  => '0'
+                       )
+               );
        }



====================================================
Index: api/starter.inc.php
diff -u api/starter.inc.php:1.1.1.1.2.24 api/starter.inc.php:1.1.1.1.2.25
--- api/starter.inc.php:1.1.1.1.2.24    Mon Nov 10 00:36:04 2003
+++ api/starter.inc.php Thu Dec 25 02:20:18 2003
@@ -101,7 +101,7 @@
        * for performance reasons.                                              
     *
        
\****************************************************************************/

-       if($HTTP_GET_VARS['op'] == 'api.xslt.get')
+       if ($HTTP_GET_VARS['op'] == 'api.xslt.get')
        {
                $result = execmethod('api.xslt.get', $HTTP_GET_VARS);
                exit;
@@ -213,31 +213,56 @@
        /* notice that if critical stuff like config and main tables are 
missing it doesnt do acl checl */
        $result = array();

-       if($methodname == 'api.statecache.pause')
+       // Only do the following if the interface has loaded statecaching
+       if (is_object($GLOBALS['phpgw']->interface->statecache))
        {
-               $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'];
+               $position_id = 
get_var('position_id',array('POST','GET'),'string','##NOTSET##');
+
+               if (strlen($position_id) && ! 
$GLOBALS['phpgw']->interface->statecache->data[$position_id])
+               {
+                       // FIXME: This should be there default app
+                       //$methodname = 'api.base.start';
+                       // FIXME: The show hint should be something explaining 
to the user reasons why the history could be lost.
+                       // For example, opening pages in seperate windows then 
returning to an older one where the history
+                       // is out of date.
+                       $GLOBALS['msgbox']->add(lang('History not found: [ 
*Show hint* ]'),__LINE__,__FILE__,'fataldebug',"position_id: '" . $position_id 
. "'");
+               }
+
+               if ($methodname == 'api.statecache.minimize')
+               {
+                       $min_values = 
$GLOBALS['phpgw']->interface->statecache->minimize($inputs,$position_id);
+                       $methodname = $min_values['op'];
+                       $inputs     = $min_values;
+               }
+               elseif ($methodname == 'api.statecache.clear')
+               {
+                       $clear_values = 
$GLOBALS['phpgw']->interface->statecache->clear($inputs,$position_id);
+                       $methodname   = $clear_values['op'];
+                       $inputs       = $clear_values;
+                       
$GLOBALS['phpgw']->interface->statecache->handle_xml_return();
+               }
+               elseif ($methodname == 'api.statecache.restore')
+               {
+                       $restore_values  = 
$GLOBALS['phpgw']->interface->statecache->restore($inputs,$position_id);
+                       $methodname      = $restore_values['op'];
+                       $inputs          = $restore_values;
+               }
+               elseif ($methodname == 'api.statecache.close')
+               {
+                       $close_values = 
$GLOBALS['phpgw']->interface->statecache->close($inputs,$position_id);
+                       $methodname   = $close_values['op'];
+                       $inputs       = $close_values;
+               }
+               else
+               {
+                       $GLOBALS['phpgw']->interface->statecache->set();
+               }
        }

-       if($GLOBALS['missing_critical'] || 
$GLOBALS['phpgw']->acl->check($methodname, 1))
+       if ($GLOBALS['missing_critical'] || 
$GLOBALS['phpgw']->acl->check($methodname, 1))
        {
                $GLOBALS['performance_timer']->start($methodname);
-               $result = ExecMethod($methodname,$inputs);
+               $result = execMethod($methodname,$inputs);
                if($result == '##NOMETHOD##')
                {
                        if 
(isset($HTTP_SESSION_VARS['phpgw_session']['prevop']))
@@ -250,14 +275,15 @@
                                $methodname = 
$GLOBALS['phpgw_data']['flags']['req_app'].'.'.$GLOBALS['phpgw_data']['flags']['req_class'].'.start';
                        }

-                       $result = ExecMethod($methodname,$inputs, True);
+                       $result = execMethod($methodname,$inputs, True);

                        /* If the method still doesnt exist, then we try and 
keep the user in the app they requested */
                        if ($result == '##NOMETHOD##')
                        {
                                $methodname = 
$GLOBALS['phpgw_data']['flags']['req_app'].'.base.start';
-                               $result = ExecMethod($methodname,$inputs, True);
-                               if($result == '##NOMETHOD##')
+                               $result     = execMethod($methodname,$inputs, 
True);
+
+                               if ($result == '##NOMETHOD##')
                                {
                                        /* If the method still doesnt exist, 
then just make sure result is empty */
                                        $result = '';






reply via email to

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