phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] tasks/class.base.php, 1.1.2.9


From: nomail
Subject: [Phpgroupware-cvs] tasks/class.base.php, 1.1.2.9
Date: Sat, 15 May 2004 11:07:47 +0200

Update of /tasks
Modified Files:
        Branch: proposal-branch
          class.base.php

date: 2004/05/15 09:07:47;  author: jengo;  state: Exp;  lines: +86 -77

Log Message:
- Fixed error reporting not directing user to there current tab
- Added in missing field indicators (Which also work with tabs)
- Most of the add screen is working correctly now, presently the only problem 
is you can't unselect a date after you pick one
=====================================================================
Index: tasks/class.base.php
diff -u tasks/class.base.php:1.1.2.8 tasks/class.base.php:1.1.2.9
--- tasks/class.base.php:1.1.2.8        Fri May 14 05:54:28 2004
+++ tasks/class.base.php        Sat May 15 09:07:47 2004
@@ -137,23 +137,6 @@
                        }
                }
 
-               function _user_fullname()
-               {
-                       $args = new safe_args();
-                       $args->set('id',0,'number');
-                       extract($args->get(func_get_args()));
-
-                       if ($id > 0)
-                       {
-                               $obj = createObject('api_accounts',$id);
-                               return 
$GLOBALS['phpgw']->prefs->_display_account_fullname($obj->data['lid'],$obj->data['firstname'],$obj->data['lastname']);
-                       }
-                       else
-                       {
-                               return '';
-                       }
-               }
-
                function __get_record(&$dbresult)
                {
                        if (! is_object($dbresult))
@@ -167,7 +150,7 @@
                                'dm_type'        => 
$dbresult->fields['task_dm_type'],
                                'owner'          => 
$GLOBALS['phpgw']->accounts->cross_reference((int)$dbresult->fields['task_owner']),
                                'owner_id'       => 
$dbresult->fields['task_owner'],
-                               'responsible'    => 
$this->_user_fullname($dbresult->fields['task_responsible']),
+                               'responsible'    => 
execMethod('api.prefs._display_account_fullname',$dbresult->fields['task_responsible']),
                                'responsible_id' => 
$dbresult->fields['task_responsible'],
                                'category'       => 
$this->_temp_cat($dbresult->fields['task_category']),
                                'category_id'    => 
$dbresult->fields['task_category'],
@@ -177,29 +160,11 @@
                                'subject'        => 
$dbresult->fields['task_subject'],
                                'description'    => 
$dbresult->fields['task_description'],
                                'priority'       => 
$this->_convert_priority($dbresult->fields['task_priority']),
-                               'priority_id'    => 
$dbresult->fields['task_priority']
+                               'priority_id'    => 
$dbresult->fields['task_priority'],
+                               'start'          => 
execMethod('api.prefs._show_date',$dbresult->unixtimestamp($dbresult->fields['task_start'])),
+                               'end'            => 
execMethod('api.prefs._show_date',$dbresult->unixtimestamp($dbresult->fields['task_end']))
                        );
 
-                       if 
($dbresult->unixtimestamp($dbresult->fields['task_start']))
-                       {
-                               $result['start']   = 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_start']))
-                                       . date(' h:i:s 
a',$dbresult->unixtimestamp($dbresult->fields['task_start']));
-                       }
-                       else
-                       {
-                               $result['start'] = '';
-                       }
-
-                       if 
($dbresult->unixtimestamp($dbresult->fields['task_end']))
-                       {
-                               $result['end']   = 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_end']))
-                                       . date(' h:i:s 
a',$dbresult->unixtimestamp($dbresult->fields['task_end']));
-                       }
-                       else
-                       {
-                               $result['end'] = '';
-                       }
-
                        return $result;
                }
 
@@ -237,6 +202,19 @@
                        {
                                
$GLOBALS['phpgw_session']['phpgw_data']['statecache']['tasks.base.create'][$key]
 = $value[$key];
                        }
+               }
+
+               function __restore_cache_value($key,$args)
+               {
+                       if (strlen($args[$key]))
+                       {
+                               $this->set_cache_value($key,$args[$key]);
+                               return $args[$key];
+                       }
+                       else
+                       {
+                               return 
$GLOBALS['phpgw_session']['phpgw_data']['statecache']['tasks.base.create'][$key];
+                       }
                }
 
                function __set_history_fields()
@@ -254,6 +232,38 @@
                                'task_status'      => lang('Status')
                        );
                }
+
+               function __create_tabs()
+               {
+                       $args = new safe_args();
+                       $args->set('select_tab',1,'number');
+                       extract($args->get(func_get_args()));
+
+                       $selected_tab[$select_tab - 1] = 1;
+                       $result = array
+                       (
+                               0 => array
+                               (
+                                       'title'   => lang('Description'),
+                                       'op'      => 
'tasks.base.create&select_tab=1',
+                                       'current' => ($selected_tab[0] ? 
$selected_tab[0] : 0)
+                               ),
+                               1 => array
+                               (
+                                       'title'   => lang('Delegation'),
+                                       'op'      => 
'tasks.base.create&select_tab=2',
+                                       'current' => ($selected_tab[1] ? 
$selected_tab[1] : 0)
+                               ),
+                               2 => array
+                               (
+                                       'title'   => lang('ACL'),
+                                       'op'      => 
'tasks.base.create&select_tab=3',
+                                       'current' => ($selected_tab[2] ? 
$selected_tab[2] : 0)
+                               )
+                       );
+
+                       return $result;
+               }
 
                function create()
                {
@@ -274,6 +284,19 @@
                        $args->set('dm_type',array('N','H','S'),'enum');
                        $args->set('responsible','0','number');
                        $args = $args->get(func_get_args());
+
+                       $result['task_data'] = array
+                       (
+                               'responsible' => 
$this->__restore_cache_value('responsible',$args),
+                               'subject'     => 
$this->__restore_cache_value('subject',$args),
+                               'priority'    => 
$this->__restore_cache_value('priority',$args),
+                               'status'      => 
$this->__restore_cache_value('status',$args),
+                               'description' => 
$this->__restore_cache_value('description',$args),
+                               'start_date'  => 
$this->__restore_cache_value('start_date',$args),
+                               'end_date'    => 
$this->__restore_cache_value('end_date',$args)
+                       );
+                       $result['tab_widget']        = 
$this->__create_tabs($args['select_tab']);
+                       $result['current_tab_index'] = $args['select_tab'];
 
                        if ($args['form_submit'] == 'True')
                        {
@@ -300,14 +323,14 @@
                                        //$missing_fields                       
= true;
                                }
 
-                               //html_print_r($_POST);
                                if (strlen($args['start_date']))
                                {
                                        $epoch_start_timestamp = 
$GLOBALS['phpgw']->prefs->_read_form_date($args['start_date'],$args['start_time']);
                                        if (! $epoch_start_timestamp)
                                        {
                                                trigger_error(lang('invaild 
start date'),E_USER_WARNING);
-                                               // MARK FIELDS
+                                               
$result['missing_fields']['start'] = true;
+                                               $missing_fields                 
   = true;
                                        }
                                        else
                                        {
@@ -326,7 +349,8 @@
                                        if (! $epoch_end_timestamp)
                                        {
                                                trigger_error(lang('invaild end 
date'),E_USER_WARNING);
-                                               // MARK FIELDS
+                                               
$result['missing_fields']['end'] = true;
+                                               $missing_fields                 
 = true;
                                        }
                                        else
                                        {
@@ -341,6 +365,7 @@
 
                                if ($missing_fields)
                                {
+                                       
$_SESSION['phpgw_session']['phpgw_data']['statecache']['tasks.base.create.missing_fields']
 = $result['missing_fields'];
                                        $GLOBALS['msgbox']->add(lang('You 
forgot to enter some of the required fields. The missing fields have been 
marked with a *'), 'notice');
                                        //$GLOBALS['phpgw']->form_lock();
                                }
@@ -395,7 +420,7 @@
                                        if 
($GLOBALS['phpgw']->db->affected_rows())
                                        {
                                                $this->history = 
createObject('api_history');
-                                               $this->history->set('tasks.' . 
$task_id,$history_data,array());
+                                               
$this->history->set('tasks.base.' . $task_id,$history_data,array());
                                                
$GLOBALS['msgbox']->add(lang('Task has been successfully created'),'notice');
        
                                                if ($args['dm_type'] == 'D')
@@ -404,6 +429,7 @@
                                                }
        
                                                
unset($_SESSION['phpgw_session']['phpgw_data']['statecache']['tasks.base.create']);
+                                               
unset($_SESSION['phpgw_session']['phpgw_data']['statecache']['tasks.base.create.missing_fields']);
                                                return $this->view($task_id);
                                        }
                                        else
@@ -414,7 +440,9 @@
                        }
                        else
                        {
-                               $this->set_cache_value('subject',$args);
+                               $result['missing_fields'] = 
$_SESSION['phpgw_session']['phpgw_data']['statecache']['tasks.base.create.missing_fields'];
+                               $this->set_cache_value('subject',$args);
+                               $this->set_cache_value('responsible',$args);
                                $this->set_cache_value('description',$args);
                                $this->set_cache_value('priority',$args);
                                $this->set_cache_value('start_date',$args);
@@ -425,7 +453,8 @@
 
                                
$GLOBALS['phpgw_session']['phpgw_data']['statecache']['tasks.base.create'] = 
array
                                (
-                                       'subject'     => $args['subject'],
+                                       'subject'     => $args['subject'],
+                                       'responsible' => $args['responsible'],
                                        'description' => $args['description'],
                                        'category'    => $args['category'],
                                        'priority'    => $args['priority'],
@@ -441,32 +470,8 @@
                                //$GLOBALS['phpgw']->form_lock();
                        }
 
-                       $selected_tab[$args['select_tab'] - 1] = 1;
-
-                       $result['tab_widget'] = array(
-                               0 => array
-                               (
-                                       'title'   => lang('Description'),
-                                       'op'      => 
'tasks.base.create&select_tab=1',
-                                       'current' => ($selected_tab[0] ? 
$selected_tab[0] : 0)
-                               ),
-                               1 => array
-                               (
-                                       'title'   => lang('Delegation'),
-                                       'op'      => 
'tasks.base.create&select_tab=2',
-                                       'current' => ($selected_tab[1] ? 
$selected_tab[1] : 0)
-                               ),
-                               2 => array
-                               (
-                                       'title'   => lang('ACL'),
-                                       'op'      => 
'tasks.base.create&select_tab=3',
-                                       'current' => ($selected_tab[2] ? 
$selected_tab[2] : 0)
-                               )
-                       );
-
                        //$GLOBALS['phpgw']->form_lock();
-                       $result['current_tab_index'] = $args['select_tab'];
-                       $result['action_type'] = 'task_create';
+                       $result['action_type']       = 'task_create';
 
                        $users = $GLOBALS['phpgw']->accounts->list_repository();
                        foreach ($users as $user)
@@ -494,7 +499,7 @@
                        }
 
                        $task = $this->_read($args['task_id'],'N');
-                       if ($task['responsible_id'] != 
$GLOBALS['phpgw_data']['user']['id'] && ! 
$GLOBALS['phpgw']->acl->check('tasks.' . $args['task_id'],PHPGW_ACL_READ))
+                       if ($task['responsible_id'] != 
$GLOBALS['phpgw_data']['user']['id'] && ! 
$GLOBALS['phpgw']->acl->check('tasks.base.' . $args['task_id'],PHPGW_ACL_READ))
                        {
                                
$GLOBALS['phpgw']->interface->access_denied('this record');
                                return array();
@@ -516,10 +521,12 @@
                        $this->history->field_execMethod['task_category']    = 
'tasks.base._temp_cat';
                        $this->history->field_execMethod['task_status']      = 
'tasks.base._convert_status';
                        $this->history->field_execMethod['task_priority']    = 
'tasks.base._convert_priority';
-                       $this->history->field_execMethod['task_owner']       = 
'tasks.base._user_fullname';
-                       $this->history->field_execMethod['task_responsible'] = 
'tasks.base._user_fullname';
+                       $this->history->field_execMethod['task_owner']       = 
'api.prefs._display_account_fullname';
+                       $this->history->field_execMethod['task_responsible'] = 
'api.prefs._display_account_fullname';
+                       $this->history->field_execMethod['task_start']       = 
'api.prefs._show_date';
+                       $this->history->field_execMethod['task_end']         = 
'api.prefs._show_date';
 
-                       $result['history_data'] = $this->history->get('tasks.' 
. $args['task_id']);
+                       $result['history_data'] = 
$this->history->get('tasks.base.' . $args['task_id']);
 
                        if (! $args['select_tab'])
                        {
@@ -562,7 +569,7 @@
                        $args->set('answer',NOVAR,'any');
                        $args = $args->get(func_get_args());
 
-                       if (! $GLOBALS['phpgw']->acl->check('tasks.' . 
$args['task_id'],PHPGW_ACL_DELETE))
+                       if (! $GLOBALS['phpgw']->acl->check('tasks.base.' . 
$args['task_id'],PHPGW_ACL_DELETE))
                        {
                                
$GLOBALS['phpgw']->interface->access_denied('this record');
                                return array();
@@ -602,8 +609,10 @@
 
                                if ($GLOBALS['phpgw']->db->affected_rows())
                                {
-                                       execMethod('api.history.clear','tasks.' 
. $args['task_id']);
+                                       
execMethod('api.history.clear','tasks.base.' . $args['task_id']);
                                        $GLOBALS['msgbox']->add(lang('Task has 
been deleted successfully'),'notice');
+
+                                       return $this->start();
                                }
                                else
                                {




reply via email to

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