]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Meetings/Meeting.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Meetings / Meeting.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
47
48
49 // Meeting is used to store customer information.
50 class Meeting extends SugarBean {
51         // Stored fields
52         var $id;
53         var $date_entered;
54         var $date_modified;
55         var $assigned_user_id;
56         var $modified_user_id;
57         var $created_by;
58         var $created_by_name;
59         var $modified_by_name;
60         var $description;
61         var $name;
62         var $location;
63         var $status;
64         var $date_start;
65         var $time_start;
66         var $date_end;
67         var $duration_hours;
68         var $duration_minutes;
69         var $time_meridiem;
70         var $parent_type;
71         var $parent_type_options;
72         var $parent_id;
73         var $field_name_map;
74         var $contact_id;
75         var $user_id;
76         var $meeting_id;
77         var $reminder_time;
78         var $reminder_checked;
79         var $required;
80         var $accept_status;
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 $outlook_id;
90
91         var $update_vcal = true;
92         var $contacts_arr;
93         var $users_arr;
94         var $meetings_arr;
95         // when assoc w/ a user/contact:
96         var $minutes_value_default = 15;
97         var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
98         var $table_name = "meetings";
99         var $rel_users_table = "meetings_users";
100         var $rel_contacts_table = "meetings_contacts";
101         var $rel_leads_table = "meetings_leads";
102         var $module_dir = "Meetings";
103         var $object_name = "Meeting";
104
105         var $importable = true;
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', 'accept_status');
108         var $relationship_fields = array('account_id'=>'accounts','opportunity_id'=>'opportunity','case_id'=>'case',
109                                                                          'assigned_user_id'=>'users','contact_id'=>'contacts', 'user_id'=>'users', 'meeting_id'=>'meetings');
110         // so you can run get_users() twice and run query only once
111         var $cached_get_users = null;
112         var $new_schema = true;
113
114         /**
115          * sole constructor
116          */
117         function Meeting() {
118                 parent::SugarBean();
119                 $this->setupCustomFields('Meetings');
120                 foreach($this->field_defs as $field) {
121                         $this->field_name_map[$field['name']] = $field;
122                 }
123 //              $this->fill_in_additional_detail_fields();
124         }
125
126         /**
127          * Stub for integration
128          * @return bool
129          */
130         function hasIntegratedMeeting() {
131                 return false;
132         }
133
134         // save date_end by calculating user input
135         // this is for calendar
136         function save($check_notify = FALSE) {
137                 require_once('modules/Calendar/DateTimeUtil.php');
138                 global $timedate;
139                 global $current_user;
140                 global $disable_date_format;
141
142                 if(isset($this->date_start)
143                         && isset($this->duration_hours)
144                         && isset($this->duration_minutes)) {
145                         $date_time_start = DateTimeUtil::get_time_start($this->date_start);
146                         $date_time_end = DateTimeUtil::get_time_end($date_time_start, $this->duration_hours, $this->duration_minutes);
147                         $this->date_end = gmdate("Y-m-d", $date_time_end->ts);
148                 }
149
150                 $check_notify =(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') ? true : false;
151                 if(empty($_REQUEST['send_invites'])) {
152                         if(!empty($this->id)) {
153                                 $old_record = new Meeting();
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                 /*nsingh 7/3/08  commenting out as bug #20814 is invalid
166                 if($current_user->getPreference('reminder_time')!= -1 &&  isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0  && $_POST['reminder_time']==-1){
167                         $this->reminder_checked = '1';
168                         $this->reminder_time = $current_user->getPreference('reminder_time');
169                 }*/
170
171         if (empty($this->status) ) {
172             $mod_strings = return_module_language($GLOBALS['current_language'], $this->module_dir);
173             $this->status = $mod_strings['LBL_DEFAULT_STATUS'];
174         }
175                 $return_id = parent::save($check_notify);
176
177                 if($this->update_vcal) {
178                         vCal::cache_sugar_vcal($current_user);
179                 }
180
181                 return $return_id;
182         }
183
184         // this is for calendar
185         function mark_deleted($id) {
186
187                 global $current_user;
188
189                 parent::mark_deleted($id);
190
191                 if($this->update_vcal) {
192                         vCal::cache_sugar_vcal($current_user);
193                 }
194         }
195
196         function get_summary_text() {
197                 return "$this->name";
198         }
199
200     function create_export_query(&$order_by, &$where, $relate_link_join='')
201     {
202         $custom_join = $this->custom_fields->getJOIN(true, true,$where);
203                 if($custom_join)
204                                 $custom_join['join'] .= $relate_link_join;
205                 $contact_required = stristr($where, "contacts");
206
207                 if($contact_required) {
208                         $query = "SELECT meetings.*, contacts.first_name, contacts.last_name, contacts.assigned_user_id contact_name_owner ";
209                         if($custom_join) {
210                                 $query .= $custom_join['select'];
211                         }
212                         $query .= " FROM contacts, meetings, meetings_contacts ";
213                         $where_auto = " meetings_contacts.contact_id = contacts.id AND meetings_contacts.meeting_id = meetings.id AND meetings.deleted=0 AND contacts.deleted=0";
214                 } else {
215                         $query = 'SELECT meetings.*';
216                         if($custom_join) {
217                                 $query .= $custom_join['select'];
218                         }
219                         $query .= ' FROM meetings ';
220                         $where_auto = "meetings.deleted=0";
221                 }
222
223                 if($custom_join) {
224                         $query .= $custom_join['join'];
225                 }
226
227                 if($where != "")
228                         $query .= " where $where AND ".$where_auto;
229                 else
230                         $query .= " where ".$where_auto;
231
232                 if($order_by != "") {
233                         $query .= " ORDER BY $order_by";
234                 } else {
235                         $alternate_order_by =   $this->process_order_by($order_by, null);
236                         if($alternate_order_by != "")
237                                 $query .=       " ORDER BY ". $alternate_order_by;
238                 }
239                 return $query;
240         }
241
242
243
244         function fill_in_additional_detail_fields() {
245                 global $locale;
246                 // Fill in the assigned_user_name
247                 $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
248
249                 if (!empty($this->contact_id)) {
250                         $query  = "SELECT first_name, last_name FROM contacts ";
251                         $query .= "WHERE id='$this->contact_id' AND deleted=0";
252                         $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
253
254                         // Get the contact name.
255                         $row = $this->db->fetchByAssoc($result);
256                         $GLOBALS['log']->info("additional call fields $query");
257                         if($row != null)
258                         {
259                                 $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
260                                 $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
261                                 $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
262                         }
263                 }
264
265
266
267                 $this->created_by_name = get_assigned_user_name($this->created_by);
268                 $this->modified_by_name = get_assigned_user_name($this->modified_user_id);
269                 $this->fill_in_additional_parent_fields();
270
271                 if (!isset($this->time_hour_start)) {
272                         $this->time_start_hour = intval(substr($this->time_start, 0, 2));
273                 } //if-else
274
275                 if (isset($this->time_minute_start)) {
276                         $time_start_minutes = $this->time_minute_start;
277                 } else {
278                         $time_start_minutes = substr($this->time_start, 3, 5);
279                         if ($time_start_minutes > 0 && $time_start_minutes < 15) {
280                                 $time_start_minutes = "15";
281                         } else if ($time_start_minutes > 15 && $time_start_minutes < 30) {
282                                 $time_start_minutes = "30";
283                         } else if ($time_start_minutes > 30 && $time_start_minutes < 45) {
284                                 $time_start_minutes = "45";
285                         } else if ($time_start_minutes > 45) {
286                                 $this->time_start_hour += 1;
287                                 $time_start_minutes = "00";
288                     } //if-else
289                 } //if-else
290
291
292                 if (isset($this->time_hour_start)) {
293                         $time_start_hour = $this->time_hour_start;
294                 } else {
295                         $time_start_hour = intval(substr($this->time_start, 0, 2));
296                 }
297
298                 global $timedate;
299         $this->time_meridiem = $timedate->AMPMMenu('', $this->time_start, 'onchange="SugarWidgetScheduler.update_time();"');
300                 $hours_arr = array ();
301                 $num_of_hours = 13;
302                 $start_at = 1;
303
304                 if (empty ($time_meridiem)) {
305                         $num_of_hours = 24;
306                         $start_at = 0;
307                 } //if
308
309                 for ($i = $start_at; $i < $num_of_hours; $i ++) {
310                         $i = $i."";
311                         if (strlen($i) == 1) {
312                                 $i = "0".$i;
313                         }
314                         $hours_arr[$i] = $i;
315                 } //for
316
317         if (!isset($this->duration_minutes)) {
318                         $this->duration_minutes = $this->minutes_value_default;
319                 }
320
321         //setting default date and time
322                 if (is_null($this->date_start))
323                         $this->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
324                 if (is_null($this->time_start))
325                         $this->time_start = $timedate->to_display_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()), true);
326                 if (is_null($this->duration_hours)) {
327                         $this->duration_hours = "0";
328                 }
329                 if (is_null($this->duration_minutes))
330                         $this->duration_minutes = "1";
331
332                 global $app_list_strings;
333                 $parent_types = $app_list_strings['record_type_display'];
334                 $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
335                 foreach($disabled_parent_types as $disabled_parent_type){
336                         if($disabled_parent_type != $this->parent_type){
337                                 unset($parent_types[$disabled_parent_type]);
338                         }
339                 }
340
341                 $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
342                 if (empty($this->reminder_time)) {
343                         $this->reminder_time = -1;
344                 }
345
346                 if ( empty($this->id) ) {
347                     $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
348                     if ( isset($reminder_t) )
349                         $this->reminder_time = $reminder_t;
350                 }
351                 $this->reminder_checked = $this->reminder_time == -1 ? false : true;
352
353                 if (isset ($_REQUEST['parent_type'])) {
354                         $this->parent_type = $_REQUEST['parent_type'];
355                 } elseif (is_null($this->parent_type)) {
356                         $this->parent_type = $app_list_strings['record_type_default_key'];
357                 }
358         }
359
360         function get_list_view_data() {
361                 $meeting_fields = $this->get_list_view_array();
362                 global $app_list_strings, $focus, $action, $currentModule;
363                 if(isset($this->parent_type))
364                         $meeting_fields['PARENT_MODULE'] = $this->parent_type;
365                 if($this->status == "Planned") {
366                         //cn: added this if() to deal with sequential Closes in Meetings.       this is a hack to a hack(formbase.php->handleRedirect)
367                         if(empty($action))
368                              $action = "index";
369             $setCompleteUrl = "<a onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>";
370                         $meeting_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline","title=".translate('LBL_LIST_CLOSE','Meetings')." border='0'")."</a>";
371                 }
372                 global $timedate;
373                 $today = gmdate($GLOBALS['timedate']->get_db_date_time_format(), time());
374                 $nextday = gmdate($GLOBALS['timedate']->dbDayFormat, time() + 3600*24);
375                 $mergeTime = $meeting_fields['DATE_START']; //$timedate->merge_date_time($meeting_fields['DATE_START'], $meeting_fields['TIME_START']);
376                 $date_db = $timedate->to_db($mergeTime);
377                 if($date_db     < $today        ) {
378                         $meeting_fields['DATE_START']= "<font class='overdueTask'>".$meeting_fields['DATE_START']."</font>";
379                 }else if($date_db       < $nextday) {
380                         $meeting_fields['DATE_START'] = "<font class='todaysTask'>".$meeting_fields['DATE_START']."</font>";
381                 } else {
382                         $meeting_fields['DATE_START'] = "<font class='futureTask'>".$meeting_fields['DATE_START']."</font>";
383                 }
384                 $this->fill_in_additional_detail_fields();
385         $meeting_fields['CONTACT_ID'] = $this->contact_id;
386         $meeting_fields['CONTACT_NAME'] = $this->contact_name;
387
388                 $meeting_fields['PARENT_NAME'] = $this->parent_name;
389
390         $meeting_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true;
391
392                 return $meeting_fields;
393         }
394
395         function set_notification_body($xtpl, &$meeting) {
396                 global $sugar_config;
397                 global $app_list_strings;
398                 global $current_user;
399                 global $timedate;
400
401
402                 // cn: bug 9494 - passing a contact breaks this call
403                 $notifyUser =($meeting->current_notify_user->object_name == 'User') ? $meeting->current_notify_user : $current_user;
404                 // cn: bug 8078 - fixed call to $timedate
405                 $prefDate = $notifyUser->getUserDateTimePreferences();
406
407                 if(strtolower(get_class($meeting->current_notify_user)) == 'contact') {
408                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
409                                                         '/index.php?entryPoint=acceptDecline&module=Meetings&contact_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
410                 } elseif(strtolower(get_class($meeting->current_notify_user)) == 'lead') {
411                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
412                                                         '/index.php?entryPoint=acceptDecline&module=Meetings&lead_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
413                 } else {
414                         $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
415                                                         '/index.php?entryPoint=acceptDecline&module=Meetings&user_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
416                 }
417                 $xtpl->assign("MEETING_TO", $meeting->current_notify_user->new_assigned_user_name);
418                 $xtpl->assign("MEETING_SUBJECT", trim($meeting->name));
419                 $xtpl->assign("MEETING_STATUS",(isset($meeting->status)? $app_list_strings['meeting_status_dom'][$meeting->status]:""));
420                 $xtpl->assign("MEETING_STARTDATE", $timedate->to_display_date_time($meeting->date_start,true,true,$notifyUser)." ".$prefDate['userGmt']);
421                 $xtpl->assign("MEETING_HOURS", $meeting->duration_hours);
422                 $xtpl->assign("MEETING_MINUTES", $meeting->duration_minutes);
423                 $xtpl->assign("MEETING_DESCRIPTION", $meeting->description);
424
425                 return $xtpl;
426         }
427
428         function get_meeting_users() {
429                 $template = new User();
430                 // First, get the list of IDs.
431                 $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.user_id from meetings_users where meetings_users.meeting_id='$this->id' AND meetings_users.deleted=0";
432                 $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
433                 $result = $this->db->query($query, true);
434                 $list = Array();
435
436                 while($row = $this->db->fetchByAssoc($result)) {
437                         $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
438                         $record = $template->retrieve($row['user_id']);
439                         $template->required = $row['required'];
440                         $template->accept_status = $row['accept_status'];
441
442                         if($record != null) {
443                                 // this copies the object into the array
444                                 $list[] = $template;
445                         }
446                 }
447                 return $list;
448         }
449
450         function get_invite_meetings(&$user) {
451                 $template = $this;
452                 // First, get the list of IDs.
453                 $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
454                 $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.meeting_id from meetings_users where meetings_users.user_id='$user->id' AND( meetings_users.accept_status IS NULL OR     meetings_users.accept_status='none') AND meetings_users.deleted=0";
455                 $result = $this->db->query($query, true);
456                 $list = Array();
457
458                 while($row = $this->db->fetchByAssoc($result)) {
459                         $record = $template->retrieve($row['meeting_id']);
460                         $template->required = $row['required'];
461                         $template->accept_status = $row['accept_status'];
462
463
464                         if($record != null)
465                         {
466                         // this copies the object into the array
467                         $list[] = $template;
468                         }
469                 }
470                 return $list;
471         }
472
473
474         function set_accept_status(&$user,$status)
475         {
476                 if($user->object_name == 'User')
477                 {
478                         $relate_values = array('user_id'=>$user->id,'meeting_id'=>$this->id);
479                         $data_values = array('accept_status'=>$status);
480                         $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
481                         global $current_user;
482
483                         if($this->update_vcal)
484                         {
485                                 vCal::cache_sugar_vcal($user);
486                         }
487                 }
488                 else if($user->object_name == 'Contact')
489                 {
490                         $relate_values = array('contact_id'=>$user->id,'meeting_id'=>$this->id);
491                         $data_values = array('accept_status'=>$status);
492                         $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
493                 }
494         else if($user->object_name == 'Lead')
495                 {
496                         $relate_values = array('lead_id'=>$user->id,'meeting_id'=>$this->id);
497                         $data_values = array('accept_status'=>$status);
498                         $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
499                 }
500         }
501
502
503         function get_notification_recipients() {
504                 if($this->special_notification) {
505                         return parent::get_notification_recipients();
506                 }
507
508                 $list = array();
509                 if(!is_array($this->contacts_arr)) {
510                         $this->contacts_arr =   array();
511                 }
512
513                 if(!is_array($this->users_arr)) {
514                         $this->users_arr =      array();
515                 }
516
517         if(!is_array($this->leads_arr)) {
518                         $this->leads_arr =      array();
519                 }
520
521                 foreach($this->users_arr as $user_id) {
522                         $notify_user = new User();
523                         $notify_user->retrieve($user_id);
524                         $notify_user->new_assigned_user_name = $notify_user->full_name;
525                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
526                         $list[] = $notify_user;
527                 }
528
529                 foreach($this->contacts_arr as $contact_id) {
530                         $notify_user = new Contact();
531                         $notify_user->retrieve($contact_id);
532                         $notify_user->new_assigned_user_name = $notify_user->full_name;
533                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
534                         $list[] = $notify_user;
535                 }
536
537         foreach($this->leads_arr as $lead_id) {
538                         $notify_user = new Lead();
539                         $notify_user->retrieve($lead_id);
540                         $notify_user->new_assigned_user_name = $notify_user->full_name;
541                         $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
542                         $list[] = $notify_user;
543                 }
544
545                 return $list;
546         }
547
548
549         function bean_implements($interface) {
550                 switch($interface) {
551                         case 'ACL':return true;
552                 }
553                 return false;
554         }
555
556         function listviewACLHelper() {
557                 $array_assign = parent::listviewACLHelper();
558                 $is_owner = false;
559                 if(!empty($this->parent_name)) {
560
561                         if(!empty($this->parent_name_owner)) {
562                                 global $current_user;
563                                 $is_owner = $current_user->id == $this->parent_name_owner;
564                         }
565                 }
566
567                 if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)) {
568                         $array_assign['PARENT'] = 'a';
569                 } else {
570                         $array_assign['PARENT'] = 'span';
571                 }
572
573                 $is_owner = false;
574
575                 if(!empty($this->contact_name)) {
576                         if(!empty($this->contact_name_owner)) {
577                                 global $current_user;
578                                 $is_owner = $current_user->id == $this->contact_name_owner;
579                         }
580                 }
581
582                 if(ACLController::checkAccess('Contacts', 'view', $is_owner)) {
583                         $array_assign['CONTACT'] = 'a';
584                 } else {
585                         $array_assign['CONTACT'] = 'span';
586                 }
587                 return $array_assign;
588         }
589
590
591         function save_relationship_changes($is_update) {
592                 $exclude = array();
593             if(empty($this->in_workflow)) {
594            if(empty($this->in_import)){//if a meeting is being imported then contact_id  should not be excluded 
595            //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 
596            //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
597                 if(!empty($GLOBALS['soap_server_object'])){
598                         $exclude = array('contact_id', 'user_id');
599                 }else{          
600                         $exclude = array('contact_id', 'user_id','assigned_user_id');
601                 }
602            }
603            else{
604                 $exclude = array('user_id');
605            }
606         }
607        parent::save_relationship_changes($is_update, $exclude);
608         }
609
610
611         /**
612          * @see SugarBean::afterImportSave()
613          */
614         public function afterImportSave()
615         {
616             if ( $this->parent_type == 'Contacts' ) {
617                 $this->load_relationship('contacts');
618                 if ( !$this->contacts->relationship_exists('contacts',array('id'=>$this->parent_id)) )
619                     $this->contacts->add($this->parent_id);
620             }
621             elseif ( $this->parent_type == 'Leads' ) {
622                 $this->load_relationship('leads');
623                 if ( !$this->leads->relationship_exists('leads',array('id'=>$this->parent_id)) )
624                     $this->leads->add($this->parent_id);
625             }
626
627             parent::afterImportSave();
628         }
629 } // end class def
630 ?>