]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Calls/Call.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Calls / Call.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description:  TODO: To be written.
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46 // Call is used to store customer information.
47 class Call extends SugarBean
48 {
49         var $field_name_map;
50         // Stored fields
51         var $id;
52         var $json_id;
53         var $date_entered;
54         var $date_modified;
55         var $assigned_user_id;
56         var $modified_user_id;
57         var $description;
58         var $name;
59         var $status;
60         var $date_start;
61         var $time_start;
62         var $duration_hours;
63         var $duration_minutes;
64         var $date_end;
65         var $parent_type;
66         var $parent_type_options;
67         var $parent_id;
68         var $contact_id;
69         var $user_id;
70         var $lead_id;
71         var $direction;
72         var $reminder_time;
73         var $reminder_time_options;
74         var $reminder_checked;
75         var $required;
76         var $accept_status;
77         var $created_by;
78         var $created_by_name;
79         var $modified_by_name;
80         var $parent_name;
81         var $contact_name;
82         var $contact_phone;
83         var $contact_email;
84         var $account_id;
85         var $opportunity_id;
86         var $case_id;
87         var $assigned_user_name;
88         var $note_id;
89     var $outlook_id;
90         var $update_vcal = true;
91         var $contacts_arr;
92         var $users_arr;
93         var $leads_arr;
94         var $default_call_name_values = array('Assemble catalogs', 'Make travel arrangements', 'Send a letter', 'Send contract', 'Send fax', 'Send a follow-up letter', 'Send literature', 'Send proposal', 'Send quote');
95         var $minutes_value_default = 15;
96         var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
97         var $table_name = "calls";
98         var $rel_users_table = "calls_users";
99         var $rel_contacts_table = "calls_contacts";
100     var $rel_leads_table = "calls_leads";
101         var $module_dir = 'Calls';
102         var $object_name = "Call";
103         var $new_schema = true;
104         var $importable = true;
105
106         // This is used to retrieve related fields from form posts.
107         var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name');
108         var $relationship_fields = array(       'account_id'            => 'accounts',
109                                                                                 'opportunity_id'        => 'opportunities',
110                                                                                 'contact_id'            => 'contacts',
111                                                                                 'case_id'                       => 'cases',
112                                                                                 'user_id'                       => 'users',
113                                                                                 'assigned_user_id'      => 'users',
114                                                                                 'note_id'                       => 'notes',
115                                                                 );
116
117         function Call() {
118                 parent::SugarBean();
119                 global $app_list_strings;
120
121         $this->setupCustomFields('Calls');
122
123                 foreach ($this->field_defs as $field) {
124                         $this->field_name_map[$field['name']] = $field;
125                 }
126
127
128          if(!empty($GLOBALS['app_list_strings']['duration_intervals']))
129                 $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals'];
130         }
131
132     // save date_end by calculating user input
133     // this is for calendar
134         function save($check_notify = FALSE) {
135                 require_once('modules/Calendar/DateTimeUtil.php');
136                 global $timedate,$current_user;
137                 global $disable_date_format;
138
139         if(     isset($this->date_start) &&
140                 isset($this->duration_hours) &&
141                 isset($this->duration_minutes) ) {
142                         $date_time_start = DateTimeUtil::get_time_start($this->date_start);
143                         $date_time_end = DateTimeUtil::get_time_end($date_time_start, $this->duration_hours, $this->duration_minutes);
144                         $this->date_end = gmdate("Y-m-d", $date_time_end->ts);
145         }
146                 if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') {
147                         $check_notify = true;
148         } else {
149                         $check_notify = false;
150                 }
151                 if(empty($_REQUEST['send_invites'])) {
152                         if(!empty($this->id)) {
153                                 $old_record = new Call();
154                                 $old_record->retrieve($this->id);
155                                 $old_assigned_user_id = $old_record->assigned_user_id;
156                         }
157                         if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){
158                                 $this->special_notification = true;
159                                 $check_notify = true;
160                 if(isset($_REQUEST['assigned_user_name'])) {
161                     $this->new_assigned_user_name = $_REQUEST['assigned_user_name'];
162                 }
163                         }
164                 }
165         if (empty($this->status) ) {
166             $mod_strings = return_module_language($GLOBALS['current_language'], $this->module_dir);
167             $this->status = $mod_strings['LBL_DEFAULT_STATUS'];
168         }
169                 /*nsingh 7/3/08  commenting out as bug #20814 is invalid
170                 if($current_user->getPreference('reminder_time')!= -1 &&  isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0  && $_POST['reminder_time']==-1){
171                         $this->reminder_checked = '1';
172                         $this->reminder_time = $current_user->getPreference('reminder_time');
173                 }*/
174
175         $return_id = parent::save($check_notify);
176         global $current_user;
177
178
179         if($this->update_vcal) {
180                         vCal::cache_sugar_vcal($current_user);
181         }
182
183         return $return_id;
184         }
185
186         /** Returns a list of the associated contacts
187          * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
188          * All Rights Reserved..
189          * Contributor(s): ______________________________________..
190         */
191         function get_contacts()
192         {
193                 // First, get the list of IDs.
194                 $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0";
195
196                 return $this->build_related_list($query, new Contact());
197         }
198
199
200         function get_summary_text()
201         {
202                 return "$this->name";
203         }
204
205         function create_list_query($order_by, $where, $show_deleted=0)
206         {
207                 $custom_join = $this->custom_fields->getJOIN();
208                 $query = "SELECT ";
209                 $query .= "
210                         calls.*,";
211                         if ( preg_match("/calls_users\.user_id/",$where))
212                         {
213                                 $query .= "calls_users.required,
214                                 calls_users.accept_status,";
215                         }
216
217                         $query .= "
218                         users.user_name as assigned_user_name";
219                         if($custom_join){
220                                 $query .= $custom_join['select'];
221                         }
222
223                         // this line will help generate a GMT-metric to compare to a locale's timezone
224
225                         if ( preg_match("/contacts/",$where)){
226                                 $query .= ", contacts.first_name, contacts.last_name";
227                                 $query .= ", contacts.assigned_user_id contact_name_owner";
228                         }
229                         $query .= " FROM calls ";
230
231                         /*
232                         if ( $this->db->dbType == 'mssql' )
233                         {
234                                 $query .= ", calls.date_start ";
235                                 if ( preg_match("/contacts/",$where)){
236                                         $query .= ", contacts.first_name, contacts.last_name";
237                                         $query .= ", contacts.assigned_user_id contact_name_owner";
238                                 }
239                                 $query .= " FROM calls ";
240                         }
241                         */
242                         if ( preg_match("/contacts/",$where)){
243                                 $query .=       "LEFT JOIN calls_contacts
244                             ON calls.id=calls_contacts.call_id
245                             LEFT JOIN contacts
246                             ON calls_contacts.contact_id=contacts.id ";
247                         }
248                         if ( preg_match("/calls_users\.user_id/",$where))
249                         {
250                 $query .= "LEFT JOIN calls_users
251                         ON calls.id=calls_users.call_id and calls_users.deleted=0 ";
252                         }
253                         $query .= "
254                         LEFT JOIN users
255                         ON calls.assigned_user_id=users.id ";
256                         if($custom_join){
257                                 $query .= $custom_join['join'];
258                         }
259                         $where_auto = '1=1';
260                  if($show_deleted == 0){
261                 $where_auto = " $this->table_name.deleted=0  ";
262                         }else if($show_deleted == 1){
263                                 $where_auto = " $this->table_name.deleted=1 ";
264                         }
265
266                         //$where_auto .= " GROUP BY calls.id";
267
268                 if($where != "")
269                         $query .= "where $where AND ".$where_auto;
270                 else
271                         $query .= "where ".$where_auto;
272
273                 if($order_by != "")
274                 $query .=  " ORDER BY ". $this->process_order_by($order_by, null);
275                 else
276                         $query .= " ORDER BY calls.name";
277                 return $query;
278         }
279
280         function create_export_query(&$order_by, &$where, $relate_link_join='')
281         {
282                 $custom_join = $this->custom_fields->getJOIN(true, true,$where);
283                         if($custom_join)
284                                 $custom_join['join'] .= $relate_link_join;
285                         $contact_required = stristr($where, "contacts");
286             if($contact_required)
287             {
288                     $query = "SELECT calls.*, contacts.first_name, contacts.last_name";
289                     if($custom_join){
290                                                 $query .= $custom_join['select'];
291                                         }
292                     $query .= " FROM contacts, calls, calls_contacts ";
293                     $where_auto = "calls_contacts.contact_id = contacts.id AND calls_contacts.call_id = calls.id AND calls.deleted=0 AND contacts.deleted=0";
294             }
295             else
296             {
297                     $query = 'SELECT calls.*';
298                         if($custom_join){
299                                                 $query .= $custom_join['select'];
300                                         }
301                     $query .= ' FROM calls ';
302                     $where_auto = "calls.deleted=0";
303             }
304
305
306                         if($custom_join){
307                                 $query .= $custom_join['join'];
308                         }
309
310                         if($where != "")
311                     $query .= "where $where AND ".$where_auto;
312             else
313                     $query .= "where ".$where_auto;
314
315             if($order_by != "")
316                     $query .=  " ORDER BY ". $this->process_order_by($order_by, null);
317             else
318                     $query .= " ORDER BY calls.name";
319
320             return $query;
321         }
322
323
324
325
326
327         function fill_in_additional_detail_fields()
328         {
329                 global $locale;
330                 parent::fill_in_additional_detail_fields();
331                 if (!empty($this->contact_id)) {
332                         $query  = "SELECT first_name, last_name FROM contacts ";
333                         $query .= "WHERE id='$this->contact_id' AND deleted=0";
334                         $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
335
336                         // Get the contact name.
337                         $row = $this->db->fetchByAssoc($result);
338                         $GLOBALS['log']->info("additional call fields $query");
339                         if($row != null)
340                         {
341                                 $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
342                                 $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
343                                 $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
344                         }
345                 }
346                 if (!isset($this->duration_minutes)) {
347                         $this->duration_minutes = $this->minutes_value_default;
348                 }
349
350         global $timedate;
351         //setting default date and time
352                 if (is_null($this->date_start)) {
353                         $this->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
354                 }
355
356                 if (is_null($this->duration_hours))
357                         $this->duration_hours = "0";
358                 if (is_null($this->duration_minutes))
359                         $this->duration_minutes = "1";
360
361                 $this->fill_in_additional_parent_fields();
362
363                 global $app_list_strings;
364                 $parent_types = $app_list_strings['record_type_display'];
365                 $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
366                 foreach($disabled_parent_types as $disabled_parent_type){
367                         if($disabled_parent_type != $this->parent_type){
368                                 unset($parent_types[$disabled_parent_type]);
369                         }
370                 }
371
372                 $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
373
374                 if (empty($this->reminder_time)) {
375                         $this->reminder_time = -1;
376                 }
377
378                 if ( empty($this->id) ) {
379                     $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
380                     if ( isset($reminder_t) )
381                         $this->reminder_time = $reminder_t;
382                 }
383                 $this->reminder_checked = $this->reminder_time == -1 ? false : true;
384
385
386                 if (isset ($_REQUEST['parent_type'])) {
387                         $this->parent_type = $_REQUEST['parent_type'];
388                 } elseif (is_null($this->parent_type)) {
389                         $this->parent_type = $app_list_strings['record_type_default_key'];
390                 }
391         }
392
393
394         function get_list_view_data(){
395                 $call_fields = $this->get_list_view_array();
396                 global $app_list_strings, $focus, $action, $currentModule;
397                 if (isset($focus->id)) $id = $focus->id;
398                 else $id = '';
399                 if (isset($this->parent_type) && $this->parent_type != null)
400                 {
401                         $call_fields['PARENT_MODULE'] = $this->parent_type;
402                 }
403                 if ($this->status == "Planned") {
404                         //cn: added this if() to deal with sequential Closes in Meetings.  this is a hack to a hack (formbase.php->handleRedirect)
405                         if(empty($action))
406                             $action = "index";
407
408             $setCompleteUrl = "<a onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>";  
409                         $call_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline","title=".translate('LBL_LIST_CLOSE','Calls')." border='0'")."</a>";
410                 }
411                 global $timedate;
412                 $today = gmdate($GLOBALS['timedate']->get_db_date_time_format(), time());
413                 $nextday = gmdate($GLOBALS['timedate']->dbDayFormat, time() + 3600*24);
414                 $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']);
415                 $date_db = $timedate->to_db($mergeTime);
416                 if( $date_db    < $today){
417                         $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>";
418                 }else if($date_db < $nextday){
419                         $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>";
420                 }else{
421                         $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>";
422                 }
423                 $this->fill_in_additional_detail_fields();
424         $call_fields['CONTACT_ID'] = $this->contact_id;
425         $call_fields['CONTACT_NAME'] = $this->contact_name;
426
427                 $call_fields['PARENT_NAME'] = $this->parent_name;
428
429         $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true;
430
431                 return $call_fields;
432         }
433
434         function set_notification_body($xtpl, $call) {
435                 global $sugar_config;
436                 global $app_list_strings;
437                 global $current_user;
438                 global $app_list_strings;
439                 global $timedate;
440
441         if ( method_exists($call->current_notify_user,'getUserDateTimePreferences') ) {
442             $prefDate = $call->current_notify_user->getUserDateTimePreferences();
443         } else {
444             $prefDate['date'] = $timedate->get_date_format(true, $current_user);
445             $prefDate['time'] = $timedate->get_time_format(true, $current_user);
446         }
447                 $x = date($prefDate['date']." ".$prefDate['time'], strtotime(($call->date_start . " " . $call->time_start)));
448                 $xOffset = $timedate->handle_offset($x, $prefDate['date']." ".$prefDate['time'], true, $current_user);
449
450                 if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) {
451                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
452                                   '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id);
453                 } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) {
454                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
455                                   '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id);
456                 } else {
457                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
458                                   '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id);
459                 }
460
461                 $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name);
462                 $xtpl->assign("CALL_SUBJECT", $call->name);
463                 $xtpl->assign("CALL_STARTDATE", $xOffset . " " . (!empty($app_list_strings['dom_timezones_extra'][$prefDate['userGmtOffset']]) ? $app_list_strings['dom_timezones_extra'][$prefDate['userGmtOffset']] : $prefDate['userGmt']));
464                 $xtpl->assign("CALL_HOURS", $call->duration_hours);
465                 $xtpl->assign("CALL_MINUTES", $call->duration_minutes);
466                 $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : ""));
467                 $xtpl->assign("CALL_DESCRIPTION", $call->description);
468
469                 return $xtpl;
470         }
471
472
473         function get_call_users() {
474                 $template = new User();
475                 // First, get the list of IDs.
476                 $query = "SELECT calls_users.required, calls_users.accept_status, calls_users.user_id from calls_users where calls_users.call_id='$this->id' AND calls_users.deleted=0";
477                 $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
478                 $result = $this->db->query($query, true);
479                 $list = Array();
480
481                 while($row = $this->db->fetchByAssoc($result)) {
482                         $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
483                         $record = $template->retrieve($row['user_id']);
484                         $template->required = $row['required'];
485                         $template->accept_status = $row['accept_status'];
486
487                         if($record != null) {
488                             // this copies the object into the array
489                                 $list[] = $template;
490                         }
491                 }
492                 return $list;
493         }
494
495
496   function get_invite_calls(&$user)
497   {
498     $template = $this;
499     // First, get the list of IDs.
500     $query = "SELECT calls_users.required, calls_users.accept_status, calls_users.call_id from calls_users where calls_users.user_id='$user->id' AND ( calls_users.accept_status IS NULL OR  calls_users.accept_status='none') AND calls_users.deleted=0";
501     $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
502
503
504     $result = $this->db->query($query, true);
505
506
507     $list = Array();
508
509
510     while($row = $this->db->fetchByAssoc($result))
511     {
512       $record = $template->retrieve($row['call_id']);
513       $template->required = $row['required'];
514       $template->accept_status = $row['accept_status'];
515
516
517       if($record != null)
518       {
519         // this copies the object into the array
520         $list[] = $template;
521       }
522     }
523     return $list;
524
525   }
526
527
528   function set_accept_status(&$user,$status)
529   {
530     if ( $user->object_name == 'User')
531     {
532       $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id);
533       $data_values = array('accept_status'=>$status);
534       $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
535       global $current_user;
536
537       if ( $this->update_vcal )
538       {
539         vCal::cache_sugar_vcal($user);
540       }
541     }
542     else if ( $user->object_name == 'Contact')
543     {
544       $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id);
545       $data_values = array('accept_status'=>$status);
546       $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
547     }
548     else if ( $user->object_name == 'Lead')
549     {
550       $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id);
551       $data_values = array('accept_status'=>$status);
552       $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
553     }
554   }
555
556
557
558         function get_notification_recipients() {
559                 if($this->special_notification) {
560                         return parent::get_notification_recipients();
561                 }
562
563 //              $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true));
564                 $list = array();
565
566                 $notify_user = new User();
567                 $notify_user->retrieve($this->assigned_user_id);
568                 $notify_user->new_assigned_user_name = $notify_user->full_name;
569                 $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
570                 $list[] = $notify_user;
571
572                 if(!is_array($this->contacts_arr)) {
573                         $this->contacts_arr =   array();
574                 }
575
576                 if(!is_array($this->users_arr)) {
577                         $this->users_arr =      array();
578                 }
579
580         if(!is_array($this->leads_arr)) {
581                         $this->leads_arr =      array();
582                 }
583
584                 foreach($this->users_arr as $user_id) {
585                         $notify_user = new User();
586                         $notify_user->retrieve($user_id);
587                         $notify_user->new_assigned_user_name = $notify_user->full_name;
588                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
589                         $list[] = $notify_user;
590                 }
591
592                 foreach($this->contacts_arr as $contact_id) {
593                         $notify_user = new Contact();
594                         $notify_user->retrieve($contact_id);
595                         $notify_user->new_assigned_user_name = $notify_user->full_name;
596                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
597                         $list[] = $notify_user;
598                 }
599
600         foreach($this->leads_arr as $lead_id) {
601                         $notify_user = new Lead();
602                         $notify_user->retrieve($lead_id);
603                         $notify_user->new_assigned_user_name = $notify_user->full_name;
604                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
605                         $list[] = $notify_user;
606                 }
607 //              $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true));
608                 return $list;
609         }
610
611     function bean_implements($interface){
612                 switch($interface){
613                         case 'ACL':return true;
614                 }
615                 return false;
616         }
617
618         function listviewACLHelper(){
619                 $array_assign = parent::listviewACLHelper();
620                 $is_owner = false;
621                 if(!empty($this->parent_name)){
622
623                         if(!empty($this->parent_name_owner)){
624                                 global $current_user;
625                                 $is_owner = $current_user->id == $this->parent_name_owner;
626                         }
627                 }
628                         if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){
629                                 $array_assign['PARENT'] = 'a';
630                         }else{
631                                 $array_assign['PARENT'] = 'span';
632                         }
633                 $is_owner = false;
634                 if(!empty($this->contact_name)){
635
636                         if(!empty($this->contact_name_owner)){
637                                 global $current_user;
638                                 $is_owner = $current_user->id == $this->contact_name_owner;
639                         }
640                 }
641                         if( ACLController::checkAccess('Contacts', 'view', $is_owner)){
642                                 $array_assign['CONTACT'] = 'a';
643                         }else{
644                                 $array_assign['CONTACT'] = 'span';
645                         }
646
647                 return $array_assign;
648         }
649
650         function save_relationship_changes($is_update) {
651                 $exclude = array();
652                 if(empty($this->in_workflow)) {
653            //if the global soap_server_object variable is not empty (as in from a soap/OPI call), then process the assigned_user_id relationship, otherwise 
654            //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
655                 if(!empty($GLOBALS['soap_server_object'])){
656                         $exclude = array('lead_id', 'contact_id', 'user_id');
657                 }else{          
658                     $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id');
659                 }
660         }
661                 parent::save_relationship_changes($is_update, $exclude);
662         }
663
664 }
665
666 ?>