phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] infolog/inc class.uiinfolog.inc.php, 1.30.2.12.2.9 cl


From: ceb
Subject: [Phpgroupware-cvs] infolog/inc class.uiinfolog.inc.php, 1.30.2.12.2.9 class.soinfolog.inc.php, 1.10.2.1.2.12 class.boinfolog.inc.php, 1.14.2.3.2.11
Date: Thu, 24 Feb 2005 13:29:34 -0000

Update of infolog/inc

Modified Files:
     Branch: Version-0_9_16-branch
            class.uiinfolog.inc.php lines: +79 -21
            class.soinfolog.inc.php lines: +37 -18
            class.boinfolog.inc.php lines: +134 -3

Log Message:
update

====================================================
Index: infolog/inc/class.uiinfolog.inc.php
diff -u infolog/inc/class.uiinfolog.inc.php:1.30.2.12.2.8 
infolog/inc/class.uiinfolog.inc.php:1.30.2.12.2.9
--- infolog/inc/class.uiinfolog.inc.php:1.30.2.12.2.8   Sun Oct  5 05:47:13 2003
+++ infolog/inc/class.uiinfolog.inc.php Thu Jan  6 01:29:06 2005
@@ -39,6 +39,7 @@
                                        'phone'     => 'phone.gif',     
'phone_alt'     => 'Phonecall',
                                        'note'      => 'note.gif',      
'note_alt'      => 'Note',
                                        'confirm'   => 'confirm.gif',   
'confirm_alt'   => 'Confirmation',
+                                       'finish'        => 'finish.png',        
'finish_alt'    => 'Finished',
                                        'reject'    => 'reject.gif',    
'reject_alt'    => 'Reject',
                                        'email'     => 'email.gif',     
'email_alt'     => 'Email' ),
                                'action' => array(
@@ -46,6 +47,7 @@
                                        'view'      => 'view.gif',      
'view_alt'      => 'View Subs',
                                        'parent'    => 'parent.gif',    
'parent_alt'    => 'View other Subs',
                                        'edit'      => 'edit.gif',      
'edit_alt'      => 'Edit',
+                                       'confirm'       => 'confirm.gif',       
'confirm_alt'   => 'Confirm',
                                        'addfile'   => 'addfile.gif',   
'addfile_alt'   => 'Add a file',
                                        'delete'    => 'delete.gif',    
'delete_alt'    => 'Delete' ),
                                'status' => array(
@@ -58,15 +60,15 @@
                        );

                        $this->filters = array(
-                               'none'             =>   'no Filter',
-                               'done'             =>   'done',
-                               'own'              =>   'own',
-                               'own-open-today'   =>   'own open',
-                               'own-open-overdue' =>   'own overdue',
-                               'own-upcoming'     =>   'own upcoming',
-                               'open-today'       =>   'open',
-                               'open-overdue'     =>   'overdue',
-                               'upcoming'         =>   'upcoming'
+                               'all'                           => 'no Filter',
+                               'own'                           => 'own',
+                               'open-today'            => 'open',
+                               'own-open-today'        => 'own open',
+                               'own-open-overdue'      => 'own overdue',
+                               'own-upcoming'          => 'own upcoming',
+                               'open-overdue'          => 'overdue',
+                               'upcoming'                      => 'upcoming',
+                               'done'                          => 'done'
                        );

                        $this->messages = array(
@@ -88,6 +90,9 @@
                        {
                                $info = $this->bo->read($info);
                        }
+
+                       //echo "uiinfolog::get_info: info="; 
_debug_array($info);
+
                        $id = $info['info_id'];
                        $done = $info['info_status'] == 'done' || 
$info['info_status'] == 'billed';
                        $info['sub_class'] = $info['info_pri'] . ($done ? 
'_done' : '');
@@ -100,6 +105,17 @@

                        $readonlys["edit[$id]"] = 
!$this->bo->check_access($id,PHPGW_ACL_EDIT);
                        $readonlys["delete[$id]"] = 
!$this->bo->check_access($id,PHPGW_ACL_DELETE);
+
+                       if(intval($info['info_responsible']) > 0 && 
$info['info_owner'] != $info['info_responsible'] && $info['info_owner'] != 
$GLOBALS['phpgw_info']['user']['account_id'])
+                       {
+                               $readonlys["confirm[$id]"] = 
!$this->bo->check_access($id,'confirm');
+                               $readonlys["finish[$id]"] = 
!$this->bo->check_access($id,'finish');
+                       }
+                       else
+                       {
+                               $readonlys["confirm[$id]"] = 
$readonlys["finish[$id]"] = True;
+                       }
+
                        $readonlys["sp[$id]"] = 
!$this->bo->check_access($id,PHPGW_ACL_ADD);
                        $readonlys["view[$id]"] = $info['info_anz_subs'] < 1;
                        $readonlys['view[0]'] = True;   // no parent
@@ -157,6 +173,12 @@
                {
                        $referer = is_array($values) ? $values['referer'] : 
$referer;
                        //echo 
"<p>uiinfolog::index(action='$action/$action_id',referer='$referer/$values[referer]')</p>\n";
+
+                       if(!$_GET['filter'])
+                       {
+                               $_GET['filter'] = 'own';
+                       }
+
                        if (!is_array($values))
                        {
                                $values = array('nm' => 
$GLOBALS['phpgw']->session->appsession('session_data','infolog'));
@@ -209,12 +231,29 @@
                                                        $action = 'sp';
                                                        $action_id = $do_id;
                                                        break;
+                                               case 'confirm':
+                                                       
$this->bo->confirm($do_id,'accepted');
+                                                       $value = array();
+                                                       $action = '';
+                                                       $action_id = 0;
+                                                       break;
+                                               case 'finish':
+                                                       
$this->bo->confirm($do_id,'finished');
+                                                       $value = array();
+                                                       $action = '';
+                                                       $action_id = 0;
+                                                       break;
                                                default:
                                                        $value = array();
                                                        $action = '';
                                                        $action_id = 0;
                                                        break;
                                        }
+
+                                       if($this->bo->emailnotification && ($do 
== 'confirm' || $do == 'finish'))
+                                       {
+                                               
$this->bo->send_notification($do_id,'confirm');
+                                       }
                                }
                        }
                        switch ($action)
@@ -241,7 +280,7 @@
                        {
                                $values['nm']['header_left'] = 
'infolog.index.header_left';
                        }
-                       $values['nm']['bottom_too'] = True;
+                       $values['nm']['bottom_too'] = False;
                        $persist['action'] = $values['nm']['action'] = $action;
                        $persist['action_id'] = $values['nm']['action_id'] = 
$action_id;
                        $persist['referer'] = $referer;
@@ -305,6 +344,8 @@
                                {
                                        if ($content['save'] && (!$info_id || 
$this->bo->check_access($info_id,PHPGW_ACL_EDIT)))
                                        {
+                                               $content['old_responsible']     
        = $this->bo->so->data['info_responsible'];
+
                                                if 
(strstr($content['info_link_id'],':') !== False)
                                                {
                                                        $info_link_id = 
$content['info_link_id'];
@@ -329,6 +370,18 @@
                                                                ),False);
                                                        }
                                                }
+
+                                               if($this->bo->emailnotification)
+                                               {
+                                                       if(!$info_id && 
intval($content['info_responsible']) > 0 && $content['info_responsible'] != 
$content['info_owner'])
+                                                       {
+                                                               
$this->bo->send_notification($content);
+                                                       }
+                                                       
elseif(intval($content['info_responsible']) != $content['old_responsible'] && 
$content['info_responsible'] != $content['info_owner'])
+                                                       {
+                                                               
$this->bo->send_notification($content);
+                                                       }
+                                               }
                                        }
                                        elseif ($content['delete'] && $info_id 
> 0)
                                        {
@@ -499,7 +552,7 @@
                        return $icon ? 
$this->html->image('infolog',$icon,lang($alt),'border=0') : lang($alt);
                }

-               function admin( )
+               function admin()
                {
                        if(get_var('cancel',Array('POST')))
                        {
@@ -521,11 +574,14 @@
                                                $this->bo->send_file_ips[$val] 
= stripslashes($ip[$key]);
                                        }
                                }
+
                                $this->bo->config->config_data = array(
-                                       'link_pathes' => $this->bo->link_pathes,
-                                       'send_file_ips' => 
$this->bo->send_file_ips
+                                       'link_pathes'           => 
$this->bo->link_pathes,
+                                       'send_file_ips'         => 
$this->bo->send_file_ips,
+                                       'emailnotification'     => 
($_POST['emailnotification']?'yes':'no')
                                );
                                $this->bo->config->save_repository(True);
+                               
$GLOBALS['phpgw']->redirect_link('/admin/index.php');
                        }

                        $GLOBALS['phpgw_info']['flags']['css'] = 
$this->html->theme2css();
@@ -537,13 +593,15 @@
                        $GLOBALS['phpgw']->template->set_block('info_admin_t', 
'info_admin');

                        $GLOBALS['phpgw']->template->set_var(Array(
-                               'text' => lang('<b>file-attachments via 
symlinks</b> instead of uploads and retrieval via file:/path for direct 
lan-clients'),
-                               'action_url'  => 
$this->html->link('/index.php',$this->menuaction('admin')),
-                               'save_button' => 
$this->html->submit_button('save','Save'),
-                               'done_button' => 
$this->html->submit_button('cancel','Cancel'),
-                               'lang_valid'  => lang('valid path on 
clientside<br>eg. \\\\Server\\Share or e:\\'),
-                               'lang_trans'  => lang('path on 
(web-)serverside<br>eg. /var/samba/Share'),
-                               'lang_ip'     => lang('reg. expr. for local 
IP\'s<br>eg. ^192\\.168\\.1\\.')
+                               'text'                          => 
lang('<b>file-attachments via symlinks</b> instead of uploads and retrieval via 
file:/path for direct lan-clients'),
+                               'action_url'            => 
$this->html->link('/index.php',$this->menuaction('admin')),
+                               'save_button'           => 
$this->html->submit_button('save','Save'),
+                               'done_button'           => 
$this->html->submit_button('cancel','Cancel'),
+                               'lang_valid'            => lang('valid path on 
clientside<br>eg. \\\\Server\\Share or e:\\'),
+                               'lang_trans'            => lang('path on 
(web-)serverside<br>eg. /var/samba/Share'),
+                               'lang_ip'                       => lang('reg. 
expr. for local IP\'s<br>eg. ^192\\.168\\.1\\.'),
+                               'lang_enable_emailnotification' => lang('enable 
email notification for assigned tasks'),
+                               'notify_checked'        => 
($this->bo->emailnotification?'checked="checked"':'')
                        ));

                        if (!is_array($this->bo->send_file_ips))

====================================================
Index: infolog/inc/class.soinfolog.inc.php
diff -u infolog/inc/class.soinfolog.inc.php:1.10.2.1.2.11 
infolog/inc/class.soinfolog.inc.php:1.10.2.1.2.12
--- infolog/inc/class.soinfolog.inc.php:1.10.2.1.2.11   Sun Nov  7 14:49:57 2004
+++ infolog/inc/class.soinfolog.inc.php Thu Jan  6 01:29:06 2005
@@ -44,7 +44,7 @@

                        $this->links = CreateObject('infolog.solink');

-                       $this->read( $info_id );
+                       $this->read($info_id);
                }

                /*!
@@ -55,7 +55,7 @@
                @param $required_rights PHPGW_ACL_xyz anded together
                @returns True if access is granted else False
                */
-               function check_access( $info_id,$required_rights )
+               function check_access($info_id,$required_rights)
                {
                        if ($info_id != $this->data['info_id'])         // 
already loaded?
                        {
@@ -72,17 +72,29 @@
                        {
                                return False;
                        }
+
                        $owner = $info['info_owner'];

+                       if($required_rights == 'confirm' && 
($info['info_confirm'] == 'accept' || $info['info_confirm'] == 'both'))
+                       {
+                               $access_ok = (intval($info['info_responsible']) 
> 0 && $info['info_responsible'] != $owner && $info['info_responsible'] == 
$this->user && $info['info_confirm_status'] == 'not');
+                               return $access_ok;
+                       }
+
+                       if($required_rights == 'finish' && 
($info['info_confirm'] == 'finish' || $info['info_confirm'] == 'both'))
+                       {
+                               $access_ok = (intval($info['info_responsible']) 
> 0 && $info['info_responsible'] != $owner && $info['info_responsible'] == 
$this->user && $info['info_confirm_status'] != 'finished');
+                               return $access_ok;
+                       }
+
                        $access_ok = $owner == $this->user ||                // 
user has all rights
                                                         // ACL only on public 
entrys || $owner granted _PRIVATE
                                                         
!!($this->grants[$owner] & $required_rights) &&
                                                         ($info['info_access'] 
== 'public' ||
-                                                        
!!($this->grants[$owner] & PHPGW_ACL_PRIVATE));
-
-                       // echo "check_access(info_id=$info_id (owner=$owner, 
user=$user),required_rights=$required_rights): 
access".($access_ok?"Ok":"Denied");
-
-                       return $access_ok;
+                                                        
!!($this->grants[$owner] & PHPGW_ACL_PRIVATE));
+
+                       //echo "check_access(info_id=$info_id (owner=$owner, 
user=" . $info['info_responsible'] . "),required_rights=$required_rights): 
access".($access_ok?"Ok":"Denied") . '<br />';
+                       return $access_ok;
                }

                /*!
@@ -94,7 +106,7 @@
                */
                function aclFilter($filter = 'none')
                {
-                       ereg('.*(own|privat|all|none).*',$filter,$vars);
+                       ereg('.*(own|none).*',$filter,$vars);
                        $filter = $vars[1];

                        if (isset($this->acl_filter[$filter]))
@@ -120,27 +132,26 @@
                                        $has_private_access = 'info_owner IN 
('.implode(',',$private_user_list).')';
                                }
                        }
-                       $filtermethod = " (info_owner=$this->user"; // user has 
all rights
+                       $filtermethod = ' (info_owner=' . $this->user; // user 
has all rights

                        // private: own entries plus the one user is 
responsible for
-                       if ($filter == 'private' || $filter == 'own')
+                       if ($filter == 'own')
                        {
-                               $filtermethod .= " OR 
(info_responsible=$this->user OR info_status = 'offer')".
-                                                " AND 
(info_access='public'".($has_private_access?" OR $has_private_access":'').')';
+                               $filtermethod .= ' OR info_responsible=' . 
$this->user . " OR (info_status = 'offer' AND info_access='public')";
                        }
-                       else                                    // none --> all 
entrys user has rights to see
+                       else
                        {
                                if ($has_private_access)
                                {
-                                       $filtermethod .= " OR 
$has_private_access";
+                                       $filtermethod .= ' OR ' . 
$has_private_access;
                                }
                                if (count($public_user_list))
-                               {
+                               {
                                        $filtermethod .= " OR 
(info_access='public' AND info_owner IN(" . implode(',',$public_user_list) . 
'))';
                                }
                        }
                        $filtermethod .= ') ';
-
+
                        return $this->acl_filter[$filter] = $filtermethod;  // 
cache the filter
                }

@@ -242,7 +253,7 @@
                                (!$this->db->query("select * FROM phpgw_infolog 
WHERE info_id=$info_id",__LINE__,__FILE__) ||
                                 !$this->db->next_record()))
                        {
-                               $this->init( );
+                               $this->init();
                                return False;
                        }
                        if ($info_id != $this->data['info_id'])      // data 
yet read in
@@ -255,6 +266,8 @@
                                        $this->data['#'.$this->db->f(0)] = 
$this->db->f(1);
                                }
                        }
+
+                       //echo 'soinfolog:read:' . _debug_array($this->data);
                        return $this->data;
                }

@@ -527,4 +540,10 @@
                        }
                        return $ids;
                }
+
+               function confirm($info_id,$confirm_status = 'accepted')
+               {
+                       $this->db->query("Update phpgw_infolog set 
info_confirm_status='$confirm_status' where info_id=" . 
intval($info_id),__LINE__,__FILE__);
+               }
        }
+?>

====================================================
Index: infolog/inc/class.boinfolog.inc.php
diff -u infolog/inc/class.boinfolog.inc.php:1.14.2.3.2.10 
infolog/inc/class.boinfolog.inc.php:1.14.2.3.2.11
--- infolog/inc/class.boinfolog.inc.php:1.14.2.3.2.10   Sun Sep  7 01:29:29 2003
+++ infolog/inc/class.boinfolog.inc.php Thu Jan  6 01:29:06 2005
@@ -107,9 +107,12 @@
                                {
                                        $this->customfields = 
$this->config->config_data['customfields'];
                                }
+                               
if($this->config->config_data['emailnotification'] == 'yes')
+                               {
+                                       $this->emailnotification = True;
+                               }
                        }
-
-                       $this->read( $info_id);
+                       $this->read($info_id);
                }

                /*!
@@ -275,4 +278,132 @@
                        }
                        return $content;
                }
+
+               function confirm($info_id,$confirm_status)
+               {
+                       $this->so->confirm($info_id,$confirm_status);
+               }
+
+               function send_notification($content = 0,$action = 'assign')
+               {
+                       if(!is_array($content))
+                       {
+                               $info_id = $content;
+                               $content = $this->read($info_id);
+
+                               //echo 'boinfolog:send_notification: ' . 
_debug_array($content);
+
+                               if(intval($content['info_responsible']) > 0 && 
$content['info_responsible'] != $content['info_owner'])
+                               {
+                                       switch($content['info_confirm'])
+                                       {
+                                               case 'accept':
+                                                       $send = 
($content['info_confirm_status'] == 'accepted'?True:False);
+                                                       break;
+                                               case 'finish':
+                                                       $send = 
($content['info_confirm_status'] == 'finished'?True:False);
+                                                       break;
+                                               case 'both':
+                                                       $send = 
(($content['info_confirm_status'] == 'accepted' || 
$content['info_confirm_status'] == 'finished')?True:False);
+                                                       break;
+                                       }
+                               }
+
+                               if(!$send)
+                               {
+                                       return False;
+                               }
+                       }
+
+                       $msg = lang('subject') . ': ' . 
$content['info_subject'] . "\n";
+                       $msg .= lang('type') . ': ' . $content['info_type'] . 
"\n";
+                       $msg .= lang('description') . ': ' . 
lang($content['info_des']) . "\n";
+                       $msg .= lang('confirm') . ': ' . 
lang($content['info_confirm']) . "\n";
+
+                       switch($action)
+                       {
+                               case 'assign':
+                                       $sender         = 
$content['info_owner'];
+                                       $recipient      = 
$content['info_responsible'];
+                                       $subject        = lang('infolog task 
*%1* has been assigned to you', $content['info_subject']);
+                                       $msg .= lang('created by') . ': ' . 
$GLOBALS['phpgw']->common->grab_owner_name($content['info_owner']) . "\n";
+                                       break;
+                               case 'confirm':
+                                       $sender         = 
$content['info_responsible'];
+                                       $recipient      = 
$content['info_owner'];
+                                       switch($content['info_confirm_status'])
+                                       {
+                                               case 'accepted':
+                                                       $subject = 
lang('infolog task *%1* delegation has been 
confirmed',$content['info_subject']);
+                                                       break;
+                                               case 'finished':
+                                                       $subject = 
lang('infolog task *%1* has been finished',$content['info_subject']);
+                                                       break;
+                                       }
+                                       $msg .= lang('responsible') . ': ' . 
$GLOBALS['phpgw']->common->grab_owner_name($content['info_responsible']) . "\n";
+                                       $msg .= lang('confirmation status') . 
': ' . lang($content['info_confirm_status']);
+                                       break;
+                       }
+
+                       //create the url for automatic login
+                       $link_data = array
+                       (
+                               'phpgw_forward'         => '/index.php',
+                               'phpgw_menuaction'      => 
'infolog.uiinfolog.index'
+                       );
+
+                       $param_list = '';
+                       $is_first_param = True;
+
+                       foreach($link_data as $param_name => $param_val)
+                       {
+                               $param_val = urlencode($param_val);
+
+                               $param_list .= ($is_first_param?'?':'&') . 
$param_name . '=' . $param_val;
+                               $is_first_param = false;
+                       }
+
+                       $msg .= "\n\n" . 'http://' . $_SERVER['HTTP_HOST'] . 
$GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php' . $param_list;
+                       //$msg .= "\n\n" . 
$GLOBALS['phpgw']->link('/index.php',$link_data);
+
+                       $prefs_sender   = 
CreateObject('phpgwapi.preferences',$sender);
+                       $prefs_sender->read_repository();
+                       $sender_email   = $prefs_sender->email_address($sender);
+                       unset($prefs_sender);
+
+                       $prefs = 
CreateObject('phpgwapi.preferences',$recipient);
+                       $prefs->read_repository();
+
+                       $msgtype = '"infolog";';
+
+                       if(!is_object($GLOBALS['phpgw']->send))
+                       {
+                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                       }
+
+                       $to = $prefs->email_address($recipient);
+
+                       /*if (empty($to) || $to[0] == '@' || $to[0] == '$')     
// we have no valid email-address
+                       {
+                               //echo "<p>infolog::send_notification: Empty 
email adress for user '".$emp_events[$k]['emp_name']."' ==> ignored !!!</p>\n";
+                               continue;
+                       }*/
+                       //echo 'Email being sent to ' . $to;
+
+                       $subject = 
$GLOBALS['phpgw']->send->encode_subject($subject);
+
+                       $returncode = 
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$msg,''/*$msgtype*/,'','','',$sender);
+                       //echo "<p>send(to='$to', 
sender='$sender'<br>subject='$subject') 
returncode=$returncode<br>".nl2br($body)."</p>\n";
+
+                       if (!$returncode)       // not nice, but better than 
failing silently
+                       {
+                               echo '<p><b>boinfolog::send_notification</b>: 
'.lang("Failed sending message to '%1' #%2 subject='%3', sender='%4' 
!!!",$to,$sender,htmlspecialchars($subject), $sender)."<br>\n";
+                               echo 
'<i>'.$GLOBALS['phpgw']->send->err['desc']."</i><br>\n";
+                               echo lang('This is mostly caused by a not or 
wrongly configured SMTP server. Notify your administrator.')."</p>\n";
+                               echo '<p>'.lang('Click %1here%2 to return to 
infolog.','<a 
href="'.$GLOBALS['phpgw']->link('/infolog/').'">','</a>')."</p>\n";
+                       }
+                       unset($prefs);
+                       return $returncode;
+               }
        }
+?>






reply via email to

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