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.6


From: nomail
Subject: [Phpgroupware-cvs] tasks/class.base.php, 1.1.2.6
Date: Sun, 9 May 2004 00:03:50 +0200

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

date: 2004/05/08 22:03:50;  author: jengo;  state: Exp;  lines: +88 -54

Log Message:
More work on getting tasks done
=====================================================================
Index: tasks/class.base.php
diff -u tasks/class.base.php:1.1.2.5 tasks/class.base.php:1.1.2.6
--- tasks/class.base.php:1.1.2.5        Fri May  7 07:12:19 2004
+++ tasks/class.base.php        Sat May  8 22:03:50 2004
@@ -37,7 +37,8 @@
                'abstract'     => 'Create task entry',
                'params'       => array
                (
-                       'type'            => array('type' => 'any', 'default' 
=> NOTSET, 'desc' => 'Type'),
+                       'type'            => array('type' => 'any', 'default' 
=> NOTSET, 'desc' => 'Type'),
+                       'responsible'     => array('type' => 'any', 'default' 
=> NOTSET, 'desc' => 'Responsible'),
                        'subject'         => array('type' => 'any', 'default' 
=> NOTSET, 'desc' => 'Subject'),
                        'description'     => array('type' => 'any', 'default' 
=> NOTSET, 'desc' => 'Description'),
                        'category'        => array('type' => 'any', 'default' 
=> NOTSET, 'desc' => 'Category'),
@@ -136,15 +137,37 @@
                        }
                }
 
+               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))
+                       {
+                               return false;
+                       }
+
                        return array
                        (
                                'id'             => 
$dbresult->fields['task_id'],
                                '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'    => 
$GLOBALS['phpgw']->accounts->cross_reference((int)$dbresult->fields['task_responsible']),
+                               'responsible'    => 
$this->_user_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'],
@@ -167,8 +190,19 @@
                        $result['task_data']   = array();
                        $result['action_type'] = 'task_start';
 
-                       $dbresult = $GLOBALS['phpgw']->db->execute("SELECT * 
from phpgw_tasks WHERE task_owner="
-                               . $GLOBALS['phpgw_data']['user']['id'] . " AND 
task_dm_type='N'");
+                       $dbresult = $GLOBALS['phpgw']->db->execute("
+                               SELECT
+                                       *
+                               FROM
+                                       phpgw_tasks
+                               WHERE
+                               (
+                                               task_owner=" . 
$GLOBALS['phpgw_data']['user']['id'] . "
+                                       OR
+                                               task_responsible=" . 
$GLOBALS['phpgw_data']['user']['id'] . "
+                               )
+                               AND
+                                       task_dm_type='N'");
 
                        while (! $dbresult->EOF)
                        {
@@ -192,6 +226,7 @@
                        $this->history->field_desc = array
                        (
                                'task_owner'       => lang('Owner'),
+                               'task_responsible' => lang('Responsible'),
                                'task_subject'     => lang('Subject'),
                                'task_category'    => lang('Category'),
                                'task_description' => lang('Description'),
@@ -218,25 +253,17 @@
                        $args->set('end_time',NOTSET,'any');
                        $args->set('status',NOTSET,'any');
                        $args->set('access',array('private','public'),'enum');
-                       $args->set('dm_type',array('N','H','S'),'enum');
-                       $args = $args->get(func_get_args());
-
-                       /*
-                       $result['task'] = array
-                       (
-                               //'task_owner'       => $args['task_owner'],
-                               'task_subject'     => $args['subject'],
-                               'task_category'    => $args['category'],
-                               'task_description' => $args['description'],
-                               'task_priority'    => $args['priority'],
-                               'task_start'       => $args['start'],
-                               'task_end'         => $args['end'],
-                               'task_status'      => $args['status']
-                       );
-                       */
+                       $args->set('dm_type',array('N','H','S'),'enum');
+                       $args->set('responsible',NOTSET,'any');
+                       $args = $args->get(func_get_args());
 
                        if ($args['form_submit'] == 'True')
-                       {
+                       {
+                               if 
($GLOBALS['phpgw']->accounts->cross_reference((int)$args['responsible']))
+                               {
+                                       $responsible = $args['responsible'];
+                               }
+
                                if (! strlen($args['subject']))
                                {
                                        $result['missing_fields']['subject'] = 
true;
@@ -286,7 +313,7 @@
                                                VALUES
                                                        ($task_id,
                                                        " . 
$GLOBALS['phpgw_data']['user']['id'] . ",
-                                                       0,
+                                                       " . 
$args['responsible'] . ",
                                                        '" . $args['subject'] . 
"',
                                                        " . $args['category'] . 
",
                                                        '" . 
$args['description'] . "',
@@ -299,31 +326,29 @@
                                                        now(),
                                                        now())");
 
-                                       if ($task_id)
-                                       {
-                                               $history_data = array
-                                               (
-                                                       'task_owner'       => 
$dbresult->fields['task_owner'],
-                                                       'task_subject'     => 
$dbresult->fields['task_subject'],
-                                                       'task_category'    => 
$dbresult->fields['task_category'],
-                                                       'task_description' => 
$dbresult->fields['task_description'],
-                                                       'task_priority'    => 
$dbresult->fields['task_priority'],
-                                                       'task_start'       => 
$dbresult->fields['task_start'],
-                                                       'task_end'         => 
$dbresult->fields['task_end'],
-                                                       'task_status'      => 
$dbresult->fields['task_status']
-                                               );
-
-                                               $this->history = 
createObject('api_history');
-                                               $this->history->set('tasks.' . 
$task_id,$history_data,array());
-                                               
$GLOBALS['msgbox']->add(lang('Task has been successfully created'),'notice');
-
-                                               if ($args['dm_type'] == 'D')
-                                               {
-                                                       
execMethod('api.datamine._set',array('location_from' => 
$args['datamine_location'], 'location_to' => 'tasks.base.' . $task_id));
-                                               }
+                                       $history_data = array
+                                       (
+                                               'task_owner'       => 
$GLOBALS['phpgw_data']['user']['id'],
+                                               'task_responsible' => 
$args['responsible'],
+                                               'task_subject'     => 
$args['subject'],
+                                               'task_category'    => 
$args['category'],
+                                               'task_description' => 
$args['description'],
+                                               'task_priority'    => 
$args['priority'],
+                                               'task_start'       => 
$args['start'],
+                                               'task_end'         => 
$args['end'],
+                                               'task_status'      => 
$args['status']
+                                       );
+
+                                       $this->history = 
createObject('api_history');
+                                       $this->history->set('tasks.' . 
$task_id,$history_data,array());
+                                       $GLOBALS['msgbox']->add(lang('Task has 
been successfully created'),'notice');
 
-                                               return $this->view($task_id);
+                                       if ($args['dm_type'] == 'D')
+                                       {
+                                               
execMethod('api.datamine._set',array('location_from' => 
$args['datamine_location'], 'location_to' => 'tasks.base.' . $task_id));
                                        }
+
+                                       return $this->view($task_id);
                                }
                        }
                        else
@@ -402,8 +427,13 @@
                        $args->set('select_tab',1,'number');
                        $args = $args->get(func_get_args());
 
+                       if (! $args['task_id'])
+                       {
+                               return false;
+                       }
+
                        $task = $this->_read($args['task_id'],'N');
-                       if (! $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.' . $args['task_id'],PHPGW_ACL_READ))
                        {
                                
$GLOBALS['phpgw']->interface->access_denied('this record');
                                return array();
@@ -422,10 +452,11 @@
                        $this->history              = 
createObject('api_history');
                        $this->__set_history_fields();
 
-                       $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']    = 
'api.accounts.id2name';
+                       $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';
 
                        $result['history_data'] = $this->history->get('tasks.' 
. $args['task_id']);
 
@@ -530,8 +561,7 @@
                function _read()
                {
                        $args = new safe_args();
-                       $args->set('id',REQUIRED,'number');
-                       $args->set('dm_type','N','string');
+                       $args->set('id',REQUIRED,'number');
                        $args = $args->get(func_get_args());
 
                        $dbresult = $GLOBALS['phpgw']->db->execute("
@@ -540,7 +570,11 @@
                                FROM
                                        phpgw_tasks
                                WHERE
-                                       task_owner=" . 
$GLOBALS['phpgw_data']['user']['id'] . "
+                               (
+                                               task_owner=" . 
$GLOBALS['phpgw_data']['user']['id'] . "
+                                       OR
+                                               task_responsible=" . 
$GLOBALS['phpgw_data']['user']['id'] . "
+                               )
                                AND
                                        task_id=" . $args['id']);
 




reply via email to

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