]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Calls/Call.php
Release 6.4.1
[Github/sugarcrm.git] / modules / Calls / Call.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2012 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 require_once('modules/Activities/Activity.php');
48 class Call extends Activity
49 {
50         var $field_name_map;
51         // Stored fields
52         var $id;
53         var $json_id;
54         var $date_entered;
55         var $date_modified;
56         var $assigned_user_id;
57         var $modified_user_id;
58         var $description;
59         var $name;
60         var $status;
61         var $date_start;
62         var $time_start;
63         var $duration_hours;
64         var $duration_minutes;
65         var $date_end;
66         var $parent_type;
67         var $parent_type_options;
68         var $parent_id;
69         var $contact_id;
70         var $user_id;
71         var $lead_id;
72         var $direction;
73         var $reminder_time;
74         var $reminder_time_options;
75         var $reminder_checked;
76         var $required;
77         var $accept_status;
78         var $created_by;
79         var $created_by_name;
80         var $modified_by_name;
81         var $parent_name;
82         var $contact_name;
83         var $contact_phone;
84         var $contact_email;
85         var $account_id;
86         var $opportunity_id;
87         var $case_id;
88         var $assigned_user_name;
89         var $note_id;
90     var $outlook_id;
91         var $update_vcal = true;
92         var $contacts_arr;
93         var $users_arr;
94         var $leads_arr;
95         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');
96         var $minutes_value_default = 15;
97         var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
98         var $table_name = "calls";
99         var $rel_users_table = "calls_users";
100         var $rel_contacts_table = "calls_contacts";
101     var $rel_leads_table = "calls_leads";
102         var $module_dir = 'Calls';
103         var $object_name = "Call";
104         var $new_schema = true;
105         var $importable = true;
106
107         // This is used to retrieve related fields from form posts.
108         var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name');
109         var $relationship_fields = array(       'account_id'            => 'accounts',
110                                                                                 'opportunity_id'        => 'opportunities',
111                                                                                 'contact_id'            => 'contacts',
112                                                                                 'case_id'                       => 'cases',
113                                                                                 'user_id'                       => 'users',
114                                                                                 'assigned_user_id'      => 'users',
115                                                                                 'note_id'                       => 'notes',
116                                                                 );
117
118         function Call() {
119                 parent::SugarBean();
120                 global $app_list_strings;
121
122         $this->setupCustomFields('Calls');
123
124                 foreach ($this->field_defs as $field) {
125                         $this->field_name_map[$field['name']] = $field;
126                 }
127
128                 
129                 
130
131          if(!empty($GLOBALS['app_list_strings']['duration_intervals']))
132                 $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals'];
133         }
134
135     // save date_end by calculating user input
136     // this is for calendar
137         function save($check_notify = FALSE) {
138                 global $timedate,$current_user;
139
140             if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) 
141         {
142             $td = $timedate->fromDb($this->date_start);
143             if($td)
144             {
145                         $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb();
146             }   
147         }
148                         
149                 if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') {
150                         $check_notify = true;
151         } else {
152                         $check_notify = false;
153                 }
154                 if(empty($_REQUEST['send_invites'])) {
155                         if(!empty($this->id)) {
156                                 $old_record = new Call();
157                                 $old_record->retrieve($this->id);
158                                 $old_assigned_user_id = $old_record->assigned_user_id;
159                         }
160                         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']) ){
161                                 $this->special_notification = true;
162                                 $check_notify = true;
163                 if(isset($_REQUEST['assigned_user_name'])) {
164                     $this->new_assigned_user_name = $_REQUEST['assigned_user_name'];
165                 }
166                         }
167                 }
168         if (empty($this->status) ) {
169             $this->status = $this->getDefaultStatus();
170         }
171                 /*nsingh 7/3/08  commenting out as bug #20814 is invalid
172                 if($current_user->getPreference('reminder_time')!= -1 &&  isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0  && $_POST['reminder_time']==-1){
173                         $this->reminder_checked = '1';
174                         $this->reminder_time = $current_user->getPreference('reminder_time');
175                 }*/
176
177         $return_id = parent::save($check_notify);
178         global $current_user;
179
180
181         if($this->update_vcal) {
182                         vCal::cache_sugar_vcal($current_user);
183         }
184
185         return $return_id;
186         }
187
188         /** Returns a list of the associated contacts
189          * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
190          * All Rights Reserved..
191          * Contributor(s): ______________________________________..
192         */
193         function get_contacts()
194         {
195                 // First, get the list of IDs.
196                 $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0";
197
198                 return $this->build_related_list($query, new Contact());
199         }
200
201
202         function get_summary_text()
203         {
204                 return "$this->name";
205         }
206
207         function create_list_query($order_by, $where, $show_deleted=0)
208         {
209                 $custom_join = $this->custom_fields->getJOIN();
210                 $query = "SELECT ";
211                 $query .= "
212                         calls.*,";
213                         if ( preg_match("/calls_users\.user_id/",$where))
214                         {
215                                 $query .= "calls_users.required,
216                                 calls_users.accept_status,";
217                         }
218
219                         $query .= "
220                         users.user_name as assigned_user_name";
221                         if($custom_join){
222                                 $query .= $custom_join['select'];
223                         }
224
225                         // this line will help generate a GMT-metric to compare to a locale's timezone
226
227                         if ( preg_match("/contacts/",$where)){
228                                 $query .= ", contacts.first_name, contacts.last_name";
229                                 $query .= ", contacts.assigned_user_id contact_name_owner";
230                         }
231                         $query .= " FROM calls ";
232
233                         if ( preg_match("/contacts/",$where)){
234                                 $query .=       "LEFT JOIN calls_contacts
235                             ON calls.id=calls_contacts.call_id
236                             LEFT JOIN contacts
237                             ON calls_contacts.contact_id=contacts.id ";
238                         }
239                         if ( preg_match('/calls_users\.user_id/',$where))
240                         {
241                 $query .= "LEFT JOIN calls_users
242                         ON calls.id=calls_users.call_id and calls_users.deleted=0 ";
243                         }
244                         $query .= "
245                         LEFT JOIN users
246                         ON calls.assigned_user_id=users.id ";
247                         if($custom_join){
248                                 $query .= $custom_join['join'];
249                         }
250                         $where_auto = '1=1';
251                  if($show_deleted == 0){
252                 $where_auto = " $this->table_name.deleted=0  ";
253                         }else if($show_deleted == 1){
254                                 $where_auto = " $this->table_name.deleted=1 ";
255                         }
256
257                         //$where_auto .= " GROUP BY calls.id";
258
259                 if($where != "")
260                         $query .= "where $where AND ".$where_auto;
261                 else
262                         $query .= "where ".$where_auto;
263
264                 if($order_by != "")
265                 $query .=  " ORDER BY ". $this->process_order_by($order_by, null);
266                 else
267                         $query .= " ORDER BY calls.name";
268                 return $query;
269         }
270
271         function create_export_query(&$order_by, &$where, $relate_link_join='')
272         {
273                 $custom_join = $this->custom_fields->getJOIN(true, true,$where);
274                         if($custom_join)
275                                 $custom_join['join'] .= $relate_link_join;
276                         $contact_required = stristr($where, "contacts");
277             if($contact_required)
278             {
279                     $query = "SELECT calls.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name ";
280                     if($custom_join){
281                                                 $query .= $custom_join['select'];
282                                         }
283                     $query .= " FROM contacts, calls, calls_contacts ";
284                     $where_auto = "calls_contacts.contact_id = contacts.id AND calls_contacts.call_id = calls.id AND calls.deleted=0 AND contacts.deleted=0";
285             }
286             else
287             {
288                     $query = 'SELECT calls.*, users.user_name as assigned_user_name ';
289                         if($custom_join){
290                                                 $query .= $custom_join['select'];
291                                         }
292                     $query .= ' FROM calls ';
293                     $where_auto = "calls.deleted=0";
294             }
295
296
297                         $query .= "  LEFT JOIN users ON calls.assigned_user_id=users.id ";
298
299                         if($custom_join){
300                                 $query .= $custom_join['join'];
301                         }
302
303                         if($where != "")
304                     $query .= "where $where AND ".$where_auto;
305             else
306                     $query .= "where ".$where_auto;
307
308             if($order_by != "")
309                     $query .=  " ORDER BY ". $this->process_order_by($order_by, null);
310             else
311                     $query .= " ORDER BY calls.name";
312
313             return $query;
314         }
315
316
317
318
319
320         function fill_in_additional_detail_fields()
321         {
322                 global $locale;
323                 parent::fill_in_additional_detail_fields();
324                 if (!empty($this->contact_id)) {
325                         $query  = "SELECT first_name, last_name FROM contacts ";
326                         $query .= "WHERE id='$this->contact_id' AND deleted=0";
327                         $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
328
329                         // Get the contact name.
330                         $row = $this->db->fetchByAssoc($result);
331                         $GLOBALS['log']->info("additional call fields $query");
332                         if($row != null)
333                         {
334                                 $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
335                                 $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
336                                 $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
337                         }
338                 }
339                 if (!isset($this->duration_minutes)) {
340                         $this->duration_minutes = $this->minutes_value_default;
341                 }
342
343         global $timedate;
344         //setting default date and time
345                 if (is_null($this->date_start)) {
346                         $this->date_start = $timedate->now();
347                 }
348
349                 if (is_null($this->duration_hours))
350                         $this->duration_hours = "0";
351                 if (is_null($this->duration_minutes))
352                         $this->duration_minutes = "1";
353
354                 $this->fill_in_additional_parent_fields();
355
356                 global $app_list_strings;
357                 $parent_types = $app_list_strings['record_type_display'];
358                 $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
359                 foreach($disabled_parent_types as $disabled_parent_type){
360                         if($disabled_parent_type != $this->parent_type){
361                                 unset($parent_types[$disabled_parent_type]);
362                         }
363                 }
364
365                 $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
366
367                 if (empty($this->reminder_time)) {
368                         $this->reminder_time = -1;
369                 }
370
371                 if ( empty($this->id) ) {
372                     $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
373                     if ( isset($reminder_t) )
374                         $this->reminder_time = $reminder_t;
375                 }
376                 $this->reminder_checked = $this->reminder_time == -1 ? false : true;
377
378
379                 if (isset ($_REQUEST['parent_type'])) {
380                         $this->parent_type = $_REQUEST['parent_type'];
381                 } elseif (is_null($this->parent_type)) {
382                         $this->parent_type = $app_list_strings['record_type_default_key'];
383                 }
384         }
385
386
387         function get_list_view_data(){
388                 $call_fields = $this->get_list_view_array();
389                 global $app_list_strings, $focus, $action, $currentModule;
390                 if (isset($focus->id)) $id = $focus->id;
391                 else $id = '';
392                 if (isset($this->parent_type) && $this->parent_type != null)
393                 {
394                         $call_fields['PARENT_MODULE'] = $this->parent_type;
395                 }
396                 if ($this->status == "Planned") {
397                         //cn: added this if() to deal with sequential Closes in Meetings.  this is a hack to a hack (formbase.php->handleRedirect)
398                         if(empty($action))
399                             $action = "index";
400
401             $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>";
402                         $call_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline","title='".translate('LBL_LIST_CLOSE','Calls')."' border='0'", null,null,'.gif', translate('LBL_LIST_CLOSE','Calls')) . "</a>";
403                 }
404                 global $timedate;
405                 $today = $timedate->nowDb();
406                 $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day"));
407                 $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']);
408                 $date_db = $timedate->to_db($mergeTime);
409                 if( $date_db    < $today){
410                         $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>";
411                 }else if($date_db < $nextday){
412                         $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>";
413                 }else{
414                         $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>";
415                 }
416                 $this->fill_in_additional_detail_fields();
417
418                 //make sure we grab the localized version of the contact name, if a contact is provided
419                 if (!empty($this->contact_id)) {
420                     global $locale;
421            // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs
422             $contact_temp = new Contact();
423             $contact_temp->retrieve($this->contact_id);
424             $contact_temp->_create_proper_name_field();
425             $this->contact_name = $contact_temp->full_name;
426                 }
427
428         $call_fields['CONTACT_ID'] = $this->contact_id;
429         //If we have a contact id and there are more than one contacts found for this meeting then let's create a hover link
430         if($this->alter_many_to_many_query && !empty($this->contact_id) && isset($this->secondary_select_count) && $this->secondary_select_count > 1)
431         {
432            $call_fields['CONTACT_NAME'] = $this->createManyToManyDetailHoverLink($this->contact_name, $this->contact_id);
433         } else {
434            $call_fields['CONTACT_NAME'] = $this->contact_name;
435         }
436
437                 $call_fields['PARENT_NAME'] = $this->parent_name;
438
439         $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true;
440
441                 return $call_fields;
442         }
443
444         function set_notification_body($xtpl, $call) {
445                 global $sugar_config;
446                 global $app_list_strings;
447                 global $current_user;
448                 global $app_list_strings;
449                 global $timedate;
450
451         // rrs: bug 42684 - passing a contact breaks this call
452                 $notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user;
453                         
454
455                 // Assumes $call dates are in user format
456                 $calldate = $timedate->fromDb($call->date_start);
457                 $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser);
458
459                 if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) {
460                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
461                                   '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id);
462                 } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) {
463                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
464                                   '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id);
465                 } else {
466                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
467                                   '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id);
468                 }
469
470                 $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name);
471                 $xtpl->assign("CALL_SUBJECT", $call->name);
472                 $xtpl->assign("CALL_STARTDATE", $xOffset);
473                 $xtpl->assign("CALL_HOURS", $call->duration_hours);
474                 $xtpl->assign("CALL_MINUTES", $call->duration_minutes);
475                 $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : ""));
476                 $xtpl->assign("CALL_DESCRIPTION", $call->description);
477
478                 return $xtpl;
479         }
480
481
482         function get_call_users() {
483                 $template = new User();
484                 // First, get the list of IDs.
485                 $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";
486                 $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
487                 $result = $this->db->query($query, true);
488                 $list = Array();
489
490                 while($row = $this->db->fetchByAssoc($result)) {
491                         $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
492                         $record = $template->retrieve($row['user_id']);
493                         $template->required = $row['required'];
494                         $template->accept_status = $row['accept_status'];
495
496                         if($record != null) {
497                             // this copies the object into the array
498                                 $list[] = $template;
499                         }
500                 }
501                 return $list;
502         }
503
504
505   function get_invite_calls(&$user)
506   {
507     $template = $this;
508     // First, get the list of IDs.
509     $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";
510     $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
511
512
513     $result = $this->db->query($query, true);
514
515
516     $list = Array();
517
518
519     while($row = $this->db->fetchByAssoc($result))
520     {
521       $record = $template->retrieve($row['call_id']);
522       $template->required = $row['required'];
523       $template->accept_status = $row['accept_status'];
524
525
526       if($record != null)
527       {
528         // this copies the object into the array
529         $list[] = $template;
530       }
531     }
532     return $list;
533
534   }
535
536
537   function set_accept_status(&$user,$status)
538   {
539     if ( $user->object_name == 'User')
540     {
541       $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id);
542       $data_values = array('accept_status'=>$status);
543       $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
544       global $current_user;
545
546       if ( $this->update_vcal )
547       {
548         vCal::cache_sugar_vcal($user);
549       }
550     }
551     else if ( $user->object_name == 'Contact')
552     {
553       $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id);
554       $data_values = array('accept_status'=>$status);
555       $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
556     }
557     else if ( $user->object_name == 'Lead')
558     {
559       $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id);
560       $data_values = array('accept_status'=>$status);
561       $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
562     }
563   }
564
565
566
567         function get_notification_recipients() {
568                 if($this->special_notification) {
569                         return parent::get_notification_recipients();
570                 }
571
572 //              $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true));
573                 $list = array();
574         if(!is_array($this->contacts_arr)) {
575                         $this->contacts_arr =   array();
576                 }
577
578                 if(!is_array($this->users_arr)) {
579                         $this->users_arr =      array();
580                 }
581
582         if(!is_array($this->leads_arr)) {
583                         $this->leads_arr =      array();
584                 }
585
586                 foreach($this->users_arr as $user_id) {
587                         $notify_user = new User();
588                         $notify_user->retrieve($user_id);
589                         $notify_user->new_assigned_user_name = $notify_user->full_name;
590                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
591                         $list[$notify_user->id] = $notify_user;
592                 }
593
594                 foreach($this->contacts_arr as $contact_id) {
595                         $notify_user = new Contact();
596                         $notify_user->retrieve($contact_id);
597                         $notify_user->new_assigned_user_name = $notify_user->full_name;
598                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
599                         $list[$notify_user->id] = $notify_user;
600                 }
601
602         foreach($this->leads_arr as $lead_id) {
603                         $notify_user = new Lead();
604                         $notify_user->retrieve($lead_id);
605                         $notify_user->new_assigned_user_name = $notify_user->full_name;
606                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
607                         $list[$notify_user->id] = $notify_user;
608                 }
609 //              $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true));
610                 return $list;
611         }
612
613     function bean_implements($interface){
614                 switch($interface){
615                         case 'ACL':return true;
616                 }
617                 return false;
618         }
619
620         function listviewACLHelper(){
621                 $array_assign = parent::listviewACLHelper();
622                 $is_owner = false;
623                 if(!empty($this->parent_name)){
624
625                         if(!empty($this->parent_name_owner)){
626                                 global $current_user;
627                                 $is_owner = $current_user->id == $this->parent_name_owner;
628                         }
629                 }
630                         if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){
631                                 $array_assign['PARENT'] = 'a';
632                         }else{
633                                 $array_assign['PARENT'] = 'span';
634                         }
635                 $is_owner = false;
636                 if(!empty($this->contact_name)){
637
638                         if(!empty($this->contact_name_owner)){
639                                 global $current_user;
640                                 $is_owner = $current_user->id == $this->contact_name_owner;
641                         }
642                 }
643                         if( ACLController::checkAccess('Contacts', 'view', $is_owner)){
644                                 $array_assign['CONTACT'] = 'a';
645                         }else{
646                                 $array_assign['CONTACT'] = 'span';
647                         }
648
649                 return $array_assign;
650         }
651
652         function save_relationship_changes($is_update) {
653                 $exclude = array();
654                 if(empty($this->in_workflow))
655         {
656             if(empty($this->in_import))
657             {
658                 //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
659                 //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
660                 if(!empty($GLOBALS['soap_server_object']))
661                 {
662                             $exclude = array('lead_id', 'contact_id', 'user_id');
663                     }
664                 else
665                 {
666                         $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id');
667                     }
668             }
669             else
670             {
671                 $exclude = array('user_id');
672             }
673
674
675         }
676                 parent::save_relationship_changes($is_update, $exclude);
677         }
678
679     public function getDefaultStatus()
680     {
681          $def = $this->field_defs['status'];
682          if (isset($def['default'])) {
683              return $def['default'];
684          } else {
685             $app = return_app_list_strings_language($GLOBALS['current_language']);
686             if (isset($def['options']) && isset($app[$def['options']])) {
687                 $keys = array_keys($app[$def['options']]);
688                 return $keys[0];
689             }
690         }
691         return '';
692     }
693 }