]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Calls/Call.php
Release 6.4.4
[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 class Call extends SugarBean {
47         var $field_name_map;
48         // Stored fields
49         var $id;
50         var $json_id;
51         var $date_entered;
52         var $date_modified;
53         var $assigned_user_id;
54         var $modified_user_id;
55         var $description;
56         var $name;
57         var $status;
58         var $date_start;
59         var $time_start;
60         var $duration_hours;
61         var $duration_minutes;
62         var $date_end;
63         var $parent_type;
64         var $parent_type_options;
65         var $parent_id;
66         var $contact_id;
67         var $user_id;
68         var $lead_id;
69         var $direction;
70         var $reminder_time;
71         var $reminder_time_options;
72         var $reminder_checked;
73         var $required;
74         var $accept_status;
75         var $created_by;
76         var $created_by_name;
77         var $modified_by_name;
78         var $parent_name;
79         var $contact_name;
80         var $contact_phone;
81         var $contact_email;
82         var $account_id;
83         var $opportunity_id;
84         var $case_id;
85         var $assigned_user_name;
86         var $note_id;
87     var $outlook_id;
88         var $update_vcal = true;
89         var $contacts_arr;
90         var $users_arr;
91         var $leads_arr;
92         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');
93         var $minutes_value_default = 15;
94         var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
95         var $table_name = "calls";
96         var $rel_users_table = "calls_users";
97         var $rel_contacts_table = "calls_contacts";
98     var $rel_leads_table = "calls_leads";
99         var $module_dir = 'Calls';
100         var $object_name = "Call";
101         var $new_schema = true;
102         var $importable = true;
103
104         // This is used to retrieve related fields from form posts.
105         var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name');
106         var $relationship_fields = array(       'account_id'            => 'accounts',
107                                                                                 'opportunity_id'        => 'opportunities',
108                                                                                 'contact_id'            => 'contacts',
109                                                                                 'case_id'                       => 'cases',
110                                                                                 'user_id'                       => 'users',
111                                                                                 'assigned_user_id'      => 'users',
112                                                                                 'note_id'                       => 'notes',
113                                         'lead_id'                       => 'leads',
114                                                                 );
115
116         function Call() {
117                 parent::SugarBean();
118                 global $app_list_strings;
119
120         $this->setupCustomFields('Calls');
121
122                 foreach ($this->field_defs as $field) {
123                         $this->field_name_map[$field['name']] = $field;
124                 }
125
126                 
127                 
128
129          if(!empty($GLOBALS['app_list_strings']['duration_intervals']))
130                 $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals'];
131         }
132
133     // save date_end by calculating user input
134     // this is for calendar
135         function save($check_notify = FALSE) {
136                 global $timedate,$current_user;
137
138             if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) 
139         {
140             $td = $timedate->fromDb($this->date_start);
141             if($td)
142             {
143                         $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb();
144             }   
145         }
146                         
147                 if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') {
148                         $check_notify = true;
149         } else {
150                         $check_notify = false;
151                 }
152                 if(empty($_REQUEST['send_invites'])) {
153                         if(!empty($this->id)) {
154                                 $old_record = new Call();
155                                 $old_record->retrieve($this->id);
156                                 $old_assigned_user_id = $old_record->assigned_user_id;
157                         }
158                         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']) ){
159                                 $this->special_notification = true;
160                                 if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) {
161                                         $check_notify = true;
162                                 }
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         $call_fields['CONTACT_NAME'] = $this->contact_name;
430                 $call_fields['PARENT_NAME'] = $this->parent_name;
431         $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true;
432
433                 return $call_fields;
434         }
435
436         function set_notification_body($xtpl, $call) {
437                 global $sugar_config;
438                 global $app_list_strings;
439                 global $current_user;
440                 global $app_list_strings;
441                 global $timedate;
442
443         // rrs: bug 42684 - passing a contact breaks this call
444                 $notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user;
445                         
446
447                 // Assumes $call dates are in user format
448                 $calldate = $timedate->fromDb($call->date_start);
449                 $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser);
450
451                 if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) {
452                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
453                                   '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id);
454                 } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) {
455                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
456                                   '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id);
457                 } else {
458                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
459                                   '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id);
460                 }
461
462                 $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name);
463                 $xtpl->assign("CALL_SUBJECT", $call->name);
464                 $xtpl->assign("CALL_STARTDATE", $xOffset);
465                 $xtpl->assign("CALL_HOURS", $call->duration_hours);
466                 $xtpl->assign("CALL_MINUTES", $call->duration_minutes);
467                 $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : ""));
468                 $xtpl->assign("CALL_DESCRIPTION", $call->description);
469
470                 return $xtpl;
471         }
472
473
474         function get_call_users() {
475                 $template = new User();
476                 // First, get the list of IDs.
477                 $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";
478                 $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
479                 $result = $this->db->query($query, true);
480                 $list = Array();
481
482                 while($row = $this->db->fetchByAssoc($result)) {
483                         $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
484                         $record = $template->retrieve($row['user_id']);
485                         $template->required = $row['required'];
486                         $template->accept_status = $row['accept_status'];
487
488                         if($record != null) {
489                             // this copies the object into the array
490                                 $list[] = $template;
491                         }
492                 }
493                 return $list;
494         }
495
496
497   function get_invite_calls(&$user)
498   {
499     $template = $this;
500     // First, get the list of IDs.
501     $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";
502     $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
503
504
505     $result = $this->db->query($query, true);
506
507
508     $list = Array();
509
510
511     while($row = $this->db->fetchByAssoc($result))
512     {
513       $record = $template->retrieve($row['call_id']);
514       $template->required = $row['required'];
515       $template->accept_status = $row['accept_status'];
516
517
518       if($record != null)
519       {
520         // this copies the object into the array
521         $list[] = $template;
522       }
523     }
524     return $list;
525
526   }
527
528
529   function set_accept_status(&$user,$status)
530   {
531     if ( $user->object_name == 'User')
532     {
533       $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id);
534       $data_values = array('accept_status'=>$status);
535       $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
536       global $current_user;
537
538       if ( $this->update_vcal )
539       {
540         vCal::cache_sugar_vcal($user);
541       }
542     }
543     else if ( $user->object_name == 'Contact')
544     {
545       $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id);
546       $data_values = array('accept_status'=>$status);
547       $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
548     }
549     else if ( $user->object_name == 'Lead')
550     {
551       $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id);
552       $data_values = array('accept_status'=>$status);
553       $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
554     }
555   }
556
557
558
559         function get_notification_recipients() {
560                 if($this->special_notification) {
561                         return parent::get_notification_recipients();
562                 }
563
564 //              $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true));
565                 $list = array();
566         if(!is_array($this->contacts_arr)) {
567                         $this->contacts_arr =   array();
568                 }
569
570                 if(!is_array($this->users_arr)) {
571                         $this->users_arr =      array();
572                 }
573
574         if(!is_array($this->leads_arr)) {
575                         $this->leads_arr =      array();
576                 }
577
578                 foreach($this->users_arr as $user_id) {
579                         $notify_user = new User();
580                         $notify_user->retrieve($user_id);
581                         $notify_user->new_assigned_user_name = $notify_user->full_name;
582                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
583                         $list[$notify_user->id] = $notify_user;
584                 }
585
586                 foreach($this->contacts_arr as $contact_id) {
587                         $notify_user = new Contact();
588                         $notify_user->retrieve($contact_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->leads_arr as $lead_id) {
595                         $notify_user = new Lead();
596                         $notify_user->retrieve($lead_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 //              $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true));
602                 return $list;
603         }
604
605     function bean_implements($interface){
606                 switch($interface){
607                         case 'ACL':return true;
608                 }
609                 return false;
610         }
611
612         function listviewACLHelper(){
613                 $array_assign = parent::listviewACLHelper();
614                 $is_owner = false;
615                 if(!empty($this->parent_name)){
616
617                         if(!empty($this->parent_name_owner)){
618                                 global $current_user;
619                                 $is_owner = $current_user->id == $this->parent_name_owner;
620                         }
621                 }
622                         if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){
623                                 $array_assign['PARENT'] = 'a';
624                         }else{
625                                 $array_assign['PARENT'] = 'span';
626                         }
627                 $is_owner = false;
628                 if(!empty($this->contact_name)){
629
630                         if(!empty($this->contact_name_owner)){
631                                 global $current_user;
632                                 $is_owner = $current_user->id == $this->contact_name_owner;
633                         }
634                 }
635                         if( ACLController::checkAccess('Contacts', 'view', $is_owner)){
636                                 $array_assign['CONTACT'] = 'a';
637                         }else{
638                                 $array_assign['CONTACT'] = 'span';
639                         }
640
641                 return $array_assign;
642         }
643
644         function save_relationship_changes($is_update) {
645                 $exclude = array();
646                 if(empty($this->in_workflow))
647         {
648             if(empty($this->in_import))
649             {
650                 //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
651                 //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
652                 if(!empty($GLOBALS['soap_server_object']))
653                 {
654                             $exclude = array('lead_id', 'contact_id', 'user_id');
655                     }
656                 else
657                 {
658                         $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id');
659                     }
660             }
661             else
662             {
663                 $exclude = array('user_id');
664             }
665
666
667         }
668                 parent::save_relationship_changes($is_update, $exclude);
669         }
670
671     public function getDefaultStatus()
672     {
673          $def = $this->field_defs['status'];
674          if (isset($def['default'])) {
675              return $def['default'];
676          } else {
677             $app = return_app_list_strings_language($GLOBALS['current_language']);
678             if (isset($def['options']) && isset($app[$def['options']])) {
679                 $keys = array_keys($app[$def['options']]);
680                 return $keys[0];
681             }
682         }
683         return '';
684     }
685 }