adamjakab /
SuiteCRM
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | 1 | 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-2013 SugarCRM Inc. |
||
| 6 | |||
| 7 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
||
| 8 | * Copyright (C) 2011 - 2014 Salesagility Ltd. |
||
| 9 | * |
||
| 10 | * This program is free software; you can redistribute it and/or modify it under |
||
| 11 | * the terms of the GNU Affero General Public License version 3 as published by the |
||
| 12 | * Free Software Foundation with the addition of the following permission added |
||
| 13 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
||
| 14 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
||
| 15 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
||
| 16 | * |
||
| 17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
||
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
| 19 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
||
| 20 | * details. |
||
| 21 | * |
||
| 22 | * You should have received a copy of the GNU Affero General Public License along with |
||
| 23 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
||
| 24 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
||
| 25 | * 02110-1301 USA. |
||
| 26 | * |
||
| 27 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
||
| 28 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
||
| 29 | * |
||
| 30 | * The interactive user interfaces in modified source and object code versions |
||
| 31 | * of this program must display Appropriate Legal Notices, as required under |
||
| 32 | * Section 5 of the GNU Affero General Public License version 3. |
||
| 33 | * |
||
| 34 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
||
| 35 | * these Appropriate Legal Notices must retain the display of the "Powered by |
||
| 36 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
||
| 37 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must |
||
| 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
||
| 39 | ********************************************************************************/ |
||
| 40 | |||
| 41 | /********************************************************************************* |
||
| 42 | |||
| 43 | * Description: TODO: To be written. |
||
| 44 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
||
| 45 | * All Rights Reserved. |
||
| 46 | * Contributor(s): ______________________________________.. |
||
| 47 | ********************************************************************************/ |
||
| 48 | |||
| 49 | class Call extends SugarBean { |
||
| 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 $email_reminder_time; |
||
| 77 | var $email_reminder_checked; |
||
| 78 | var $email_reminder_sent; |
||
| 79 | var $required; |
||
| 80 | var $accept_status; |
||
| 81 | var $created_by; |
||
| 82 | var $created_by_name; |
||
| 83 | var $modified_by_name; |
||
| 84 | var $parent_name; |
||
| 85 | var $contact_name; |
||
| 86 | var $contact_phone; |
||
| 87 | var $contact_email; |
||
| 88 | var $account_id; |
||
| 89 | var $opportunity_id; |
||
| 90 | var $case_id; |
||
| 91 | var $assigned_user_name; |
||
| 92 | var $note_id; |
||
| 93 | var $outlook_id; |
||
| 94 | var $update_vcal = true; |
||
| 95 | var $contacts_arr; |
||
| 96 | var $users_arr; |
||
| 97 | var $leads_arr; |
||
| 98 | 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'); |
||
| 99 | var $minutes_value_default = 15; |
||
| 100 | var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45'); |
||
| 101 | var $table_name = "calls"; |
||
| 102 | var $rel_users_table = "calls_users"; |
||
| 103 | var $rel_contacts_table = "calls_contacts"; |
||
| 104 | var $rel_leads_table = "calls_leads"; |
||
| 105 | var $module_dir = 'Calls'; |
||
| 106 | var $object_name = "Call"; |
||
| 107 | var $new_schema = true; |
||
| 108 | var $importable = true; |
||
| 109 | var $syncing = false; |
||
| 110 | var $recurring_source; |
||
| 111 | |||
| 112 | // This is used to retrieve related fields from form posts. |
||
| 113 | var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name'); |
||
| 114 | var $relationship_fields = array( 'account_id' => 'accounts', |
||
| 115 | 'opportunity_id' => 'opportunities', |
||
| 116 | 'contact_id' => 'contacts', |
||
| 117 | 'case_id' => 'cases', |
||
| 118 | 'user_id' => 'users', |
||
| 119 | 'assigned_user_id' => 'users', |
||
| 120 | 'note_id' => 'notes', |
||
| 121 | 'lead_id' => 'leads', |
||
| 122 | ); |
||
| 123 | |||
| 124 | 43 | public function __construct() { |
|
| 125 | 43 | parent::__construct(); |
|
| 126 | 43 | global $app_list_strings; |
|
| 127 | |||
| 128 | 43 | $this->setupCustomFields('Calls'); |
|
| 129 | |||
| 130 | 43 | foreach ($this->field_defs as $field) { |
|
| 131 | 43 | $this->field_name_map[$field['name']] = $field; |
|
| 132 | } |
||
| 133 | |||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | 43 | if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 138 | 43 | $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
|
| 139 | 43 | } |
|
| 140 | |||
| 141 | /** |
||
| 142 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
||
| 143 | */ |
||
| 144 | public function Call(){ |
||
| 145 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
||
| 146 | if(isset($GLOBALS['log'])) { |
||
| 147 | $GLOBALS['log']->deprecated($deprecatedMessage); |
||
| 148 | } |
||
| 149 | else { |
||
| 150 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
||
| 151 | } |
||
| 152 | self::__construct(); |
||
| 153 | } |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Disable edit if call is recurring and source is not Sugar. It should be edited only from Outlook. |
||
| 157 | * @param $view string |
||
| 158 | * @param $is_owner bool |
||
| 159 | */ |
||
| 160 | 4 | function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
| 161 | // don't check if call is being synced from Outlook |
||
| 162 | 4 | if($this->syncing == false){ |
|
|
0 ignored issues
–
show
|
|||
| 163 | 4 | $view = strtolower($view); |
|
| 164 | switch($view){ |
||
| 165 | 4 | case 'edit': |
|
| 166 | 3 | case 'save': |
|
| 167 | 3 | case 'editview': |
|
| 168 | 3 | case 'delete': |
|
| 169 | 3 | if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
| 170 | 1 | return false; |
|
| 171 | } |
||
| 172 | } |
||
| 173 | } |
||
| 174 | 4 | return parent::ACLAccess($view,$is_owner,$in_group); |
|
| 175 | } |
||
| 176 | // save date_end by calculating user input |
||
| 177 | // this is for calendar |
||
| 178 | 2 | function save($check_notify = FALSE) { |
|
| 179 | 2 | global $timedate,$current_user; |
|
| 180 | |||
| 181 | 2 | if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) |
|
| 182 | { |
||
| 183 | 1 | $td = $timedate->fromDb($this->date_start); |
|
| 184 | 1 | if($td) |
|
| 185 | { |
||
| 186 | $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); |
||
| 187 | } |
||
| 188 | } |
||
| 189 | |||
| 190 | 2 | if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { |
|
| 191 | $check_notify = true; |
||
| 192 | } else { |
||
| 193 | 2 | $check_notify = false; |
|
| 194 | } |
||
| 195 | 2 | if(empty($_REQUEST['send_invites'])) { |
|
| 196 | 2 | if(!empty($this->id)) { |
|
| 197 | 1 | $old_record = new Call(); |
|
| 198 | 1 | $old_record->retrieve($this->id); |
|
| 199 | 1 | $old_assigned_user_id = $old_record->assigned_user_id; |
|
| 200 | } |
||
| 201 | 2 | 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']) ){ |
|
| 202 | $this->special_notification = true; |
||
| 203 | if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) { |
||
| 204 | $check_notify = true; |
||
| 205 | } |
||
| 206 | if(isset($_REQUEST['assigned_user_name'])) { |
||
| 207 | $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; |
||
| 208 | } |
||
| 209 | } |
||
| 210 | } |
||
| 211 | 2 | if (empty($this->status) ) { |
|
| 212 | $this->status = $this->getDefaultStatus(); |
||
| 213 | } |
||
| 214 | |||
| 215 | // prevent a mass mailing for recurring meetings created in Calendar module |
||
| 216 | 2 | if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { |
|
| 217 | $check_notify = false; |
||
| 218 | } |
||
| 219 | /*nsingh 7/3/08 commenting out as bug #20814 is invalid |
||
| 220 | if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ |
||
| 221 | $this->reminder_checked = '1'; |
||
| 222 | $this->reminder_time = $current_user->getPreference('reminder_time'); |
||
| 223 | }*/ |
||
| 224 | |||
| 225 | 2 | $return_id = parent::save($check_notify); |
|
| 226 | 2 | global $current_user; |
|
| 227 | |||
| 228 | |||
| 229 | 2 | if($this->update_vcal) { |
|
| 230 | 2 | vCal::cache_sugar_vcal($current_user); |
|
| 231 | } |
||
| 232 | |||
| 233 | 2 | if(isset($_REQUEST['reminders_data'])) { |
|
| 234 | Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
||
| 235 | } |
||
| 236 | |||
| 237 | 2 | return $return_id; |
|
| 238 | } |
||
| 239 | |||
| 240 | /** Returns a list of the associated contacts |
||
| 241 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. |
||
| 242 | * All Rights Reserved.. |
||
| 243 | * Contributor(s): ______________________________________.. |
||
| 244 | */ |
||
| 245 | 1 | function get_contacts() |
|
| 246 | { |
||
| 247 | // First, get the list of IDs. |
||
| 248 | 1 | $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0"; |
|
| 249 | |||
| 250 | 1 | return $this->build_related_list($query, new Contact()); |
|
| 251 | } |
||
| 252 | |||
| 253 | |||
| 254 | 3 | function get_summary_text() |
|
| 255 | { |
||
| 256 | 3 | return "$this->name"; |
|
| 257 | } |
||
| 258 | |||
| 259 | 1 | function create_list_query($order_by, $where, $show_deleted=0) |
|
| 260 | { |
||
| 261 | 1 | $custom_join = $this->getCustomJoin(); |
|
| 262 | 1 | $query = "SELECT "; |
|
| 263 | $query .= " |
||
| 264 | 1 | calls.*,"; |
|
| 265 | 1 | if ( preg_match("/calls_users\.user_id/",$where)) |
|
| 266 | { |
||
| 267 | $query .= "calls_users.required, |
||
| 268 | calls_users.accept_status,"; |
||
| 269 | } |
||
| 270 | |||
| 271 | $query .= " |
||
| 272 | 1 | users.user_name as assigned_user_name"; |
|
| 273 | 1 | $query .= $custom_join['select']; |
|
| 274 | |||
| 275 | // this line will help generate a GMT-metric to compare to a locale's timezone |
||
| 276 | |||
| 277 | 1 | if ( preg_match("/contacts/",$where)){ |
|
| 278 | $query .= ", contacts.first_name, contacts.last_name"; |
||
| 279 | $query .= ", contacts.assigned_user_id contact_name_owner"; |
||
| 280 | } |
||
| 281 | 1 | $query .= " FROM calls "; |
|
| 282 | |||
| 283 | 1 | if ( preg_match("/contacts/",$where)){ |
|
| 284 | $query .= "LEFT JOIN calls_contacts |
||
| 285 | ON calls.id=calls_contacts.call_id |
||
| 286 | LEFT JOIN contacts |
||
| 287 | ON calls_contacts.contact_id=contacts.id "; |
||
| 288 | } |
||
| 289 | 1 | if ( preg_match('/calls_users\.user_id/',$where)) |
|
| 290 | { |
||
| 291 | $query .= "LEFT JOIN calls_users |
||
| 292 | ON calls.id=calls_users.call_id and calls_users.deleted=0 "; |
||
| 293 | } |
||
| 294 | $query .= " |
||
| 295 | LEFT JOIN users |
||
| 296 | 1 | ON calls.assigned_user_id=users.id "; |
|
| 297 | 1 | $query .= $custom_join['join']; |
|
| 298 | 1 | $where_auto = '1=1'; |
|
| 299 | 1 | if($show_deleted == 0){ |
|
| 300 | 1 | $where_auto = " $this->table_name.deleted=0 "; |
|
| 301 | }else if($show_deleted == 1){ |
||
| 302 | $where_auto = " $this->table_name.deleted=1 "; |
||
| 303 | } |
||
| 304 | |||
| 305 | //$where_auto .= " GROUP BY calls.id"; |
||
| 306 | |||
| 307 | 1 | if($where != "") |
|
| 308 | 1 | $query .= "where $where AND ".$where_auto; |
|
| 309 | else |
||
| 310 | 1 | $query .= "where ".$where_auto; |
|
| 311 | |||
| 312 | 1 | $order_by = $this->process_order_by($order_by); |
|
| 313 | 1 | if (empty($order_by)) { |
|
| 314 | 1 | $order_by = 'calls.name'; |
|
| 315 | } |
||
| 316 | 1 | $query .= ' ORDER BY ' . $order_by; |
|
| 317 | |||
| 318 | 1 | return $query; |
|
| 319 | } |
||
| 320 | |||
| 321 | 1 | function create_export_query($order_by, $where, $relate_link_join='') |
|
| 322 | { |
||
| 323 | 1 | $custom_join = $this->getCustomJoin(true, true, $where); |
|
| 324 | 1 | $custom_join['join'] .= $relate_link_join; |
|
| 325 | 1 | $contact_required = stristr($where, "contacts"); |
|
| 326 | 1 | if($contact_required) |
|
| 327 | { |
||
| 328 | $query = "SELECT calls.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name "; |
||
| 329 | $query .= $custom_join['select']; |
||
| 330 | $query .= " FROM contacts, calls, calls_contacts "; |
||
| 331 | $where_auto = "calls_contacts.contact_id = contacts.id AND calls_contacts.call_id = calls.id AND calls.deleted=0 AND contacts.deleted=0"; |
||
| 332 | } |
||
| 333 | else |
||
| 334 | { |
||
| 335 | 1 | $query = 'SELECT calls.*, users.user_name as assigned_user_name '; |
|
| 336 | 1 | $query .= $custom_join['select']; |
|
| 337 | 1 | $query .= ' FROM calls '; |
|
| 338 | 1 | $where_auto = "calls.deleted=0"; |
|
| 339 | } |
||
| 340 | |||
| 341 | |||
| 342 | 1 | $query .= " LEFT JOIN users ON calls.assigned_user_id=users.id "; |
|
| 343 | |||
| 344 | 1 | $query .= $custom_join['join']; |
|
| 345 | |||
| 346 | 1 | if($where != "") |
|
| 347 | 1 | $query .= "where $where AND ".$where_auto; |
|
| 348 | else |
||
| 349 | 1 | $query .= "where ".$where_auto; |
|
| 350 | |||
| 351 | 1 | $order_by = $this->process_order_by($order_by); |
|
| 352 | 1 | if (empty($order_by)) { |
|
| 353 | 1 | $order_by = 'calls.name'; |
|
| 354 | } |
||
| 355 | 1 | $query .= ' ORDER BY ' . $order_by; |
|
| 356 | |||
| 357 | 1 | return $query; |
|
| 358 | } |
||
| 359 | |||
| 360 | |||
| 361 | |||
| 362 | |||
| 363 | |||
| 364 | 4 | function fill_in_additional_detail_fields() |
|
| 365 | { |
||
| 366 | 4 | global $locale; |
|
| 367 | 4 | parent::fill_in_additional_detail_fields(); |
|
| 368 | 4 | if (!empty($this->contact_id)) { |
|
| 369 | $query = "SELECT first_name, last_name FROM contacts "; |
||
| 370 | $query .= "WHERE id='$this->contact_id' AND deleted=0"; |
||
| 371 | $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: "); |
||
| 372 | |||
| 373 | // Get the contact name. |
||
| 374 | $row = $this->db->fetchByAssoc($result); |
||
| 375 | $GLOBALS['log']->info("additional call fields $query"); |
||
| 376 | if($row != null) |
||
| 377 | { |
||
| 378 | $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', ''); |
||
| 379 | $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name"); |
||
| 380 | $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id"); |
||
| 381 | } |
||
| 382 | } |
||
| 383 | 4 | if (!isset($this->duration_minutes)) { |
|
| 384 | 2 | $this->duration_minutes = $this->minutes_value_default; |
|
| 385 | } |
||
| 386 | |||
| 387 | 4 | global $timedate; |
|
| 388 | //setting default date and time |
||
| 389 | 4 | if (is_null($this->date_start)) { |
|
| 390 | 2 | $this->date_start = $timedate->now(); |
|
| 391 | } |
||
| 392 | |||
| 393 | 4 | if (is_null($this->duration_hours)) |
|
| 394 | 2 | $this->duration_hours = "0"; |
|
| 395 | 4 | if (is_null($this->duration_minutes)) |
|
| 396 | $this->duration_minutes = "1"; |
||
| 397 | |||
| 398 | 4 | $this->fill_in_additional_parent_fields(); |
|
| 399 | |||
| 400 | 4 | global $app_list_strings; |
|
| 401 | 4 | $parent_types = $app_list_strings['record_type_display']; |
|
| 402 | 4 | $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
| 403 | 4 | foreach($disabled_parent_types as $disabled_parent_type){ |
|
| 404 | if($disabled_parent_type != $this->parent_type){ |
||
| 405 | unset($parent_types[$disabled_parent_type]); |
||
| 406 | } |
||
| 407 | } |
||
| 408 | |||
| 409 | 4 | $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type); |
|
| 410 | |||
| 411 | 4 | if (empty($this->reminder_time)) { |
|
| 412 | $this->reminder_time = -1; |
||
| 413 | } |
||
| 414 | |||
| 415 | 4 | if ( empty($this->id) ) { |
|
| 416 | 2 | $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
|
| 417 | 2 | if ( isset($reminder_t) ) |
|
| 418 | $this->reminder_time = $reminder_t; |
||
| 419 | } |
||
| 420 | 4 | $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
|
| 421 | |||
| 422 | 4 | if (empty($this->email_reminder_time)) { |
|
| 423 | $this->email_reminder_time = -1; |
||
| 424 | } |
||
| 425 | 4 | if(empty($this->id)){ |
|
| 426 | 2 | $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
|
| 427 | 2 | if(isset($reminder_t)) |
|
| 428 | $this->email_reminder_time = $reminder_t; |
||
| 429 | } |
||
| 430 | 4 | $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
|
| 431 | |||
| 432 | 4 | if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) { |
|
| 433 | $this->parent_type = $_REQUEST['parent_type']; |
||
| 434 | 4 | } elseif (is_null($this->parent_type)) { |
|
| 435 | 2 | $this->parent_type = $app_list_strings['record_type_default_key']; |
|
| 436 | } |
||
| 437 | 4 | } |
|
| 438 | |||
| 439 | |||
| 440 | 1 | function get_list_view_data(){ |
|
| 441 | 1 | $call_fields = $this->get_list_view_array(); |
|
| 442 | 1 | global $app_list_strings, $focus, $action, $currentModule; |
|
| 443 | 1 | if (isset($focus->id)) $id = $focus->id; |
|
| 444 | 1 | else $id = ''; |
|
| 445 | 1 | if (isset($this->parent_type) && $this->parent_type != null) |
|
| 446 | { |
||
| 447 | $call_fields['PARENT_MODULE'] = $this->parent_type; |
||
| 448 | } |
||
| 449 | 1 | if ($this->status == "Planned") { |
|
| 450 | //cn: added this if() to deal with sequential Closes in Meetings. this is a hack to a hack (formbase.php->handleRedirect) |
||
| 451 | 1 | if(empty($action)) |
|
| 452 | 1 | $action = "index"; |
|
| 453 | |||
| 454 | 1 | $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>"; |
|
| 455 | 1 | if ($this->ACLAccess('edit')) { |
|
| 456 | 1 | $call_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline"," border='0'",null,null,'.gif',translate('LBL_CLOSEINLINE'))."</a>"; |
|
| 457 | } else { |
||
| 458 | $call_fields['SET_COMPLETE'] = ''; |
||
| 459 | } |
||
| 460 | } |
||
| 461 | 1 | global $timedate; |
|
| 462 | 1 | $today = $timedate->nowDb(); |
|
| 463 | 1 | $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day")); |
|
| 464 | 1 | $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']); |
|
| 465 | 1 | $date_db = $timedate->to_db($mergeTime); |
|
| 466 | 1 | if( $date_db < $today){ |
|
| 467 | 1 | $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>"; |
|
| 468 | }else if($date_db < $nextday){ |
||
| 469 | $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>"; |
||
| 470 | }else{ |
||
| 471 | $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>"; |
||
| 472 | } |
||
| 473 | 1 | $this->fill_in_additional_detail_fields(); |
|
| 474 | |||
| 475 | //make sure we grab the localized version of the contact name, if a contact is provided |
||
| 476 | 1 | if (!empty($this->contact_id)) { |
|
| 477 | // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs |
||
| 478 | $contact_temp = BeanFactory::getBean("Contacts", $this->contact_id); |
||
| 479 | if(!empty($contact_temp)) { |
||
| 480 | $contact_temp->_create_proper_name_field(); |
||
| 481 | $this->contact_name = $contact_temp->full_name; |
||
| 482 | } |
||
| 483 | } |
||
| 484 | |||
| 485 | 1 | $call_fields['CONTACT_ID'] = $this->contact_id; |
|
| 486 | 1 | $call_fields['CONTACT_NAME'] = $this->contact_name; |
|
| 487 | 1 | $call_fields['PARENT_NAME'] = $this->parent_name; |
|
| 488 | 1 | $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true; |
|
| 489 | 1 | $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true; |
|
| 490 | |||
| 491 | 1 | return $call_fields; |
|
| 492 | } |
||
| 493 | |||
| 494 | 1 | function set_notification_body($xtpl, $call) { |
|
| 495 | 1 | global $sugar_config; |
|
| 496 | 1 | global $app_list_strings; |
|
| 497 | 1 | global $current_user; |
|
| 498 | 1 | global $app_list_strings; |
|
| 499 | 1 | global $timedate; |
|
| 500 | |||
| 501 | // rrs: bug 42684 - passing a contact breaks this call |
||
| 502 | 1 | $notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user; |
|
| 503 | |||
| 504 | |||
| 505 | // Assumes $call dates are in user format |
||
| 506 | 1 | $calldate = $timedate->fromDb($call->date_start); |
|
| 507 | 1 | $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser); |
|
| 508 | |||
| 509 | 1 | if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) { |
|
| 510 | $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
||
| 511 | '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id); |
||
| 512 | 1 | } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) { |
|
| 513 | $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
||
| 514 | '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id); |
||
| 515 | } else { |
||
| 516 | 1 | $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 517 | 1 | '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 518 | } |
||
| 519 | |||
| 520 | 1 | $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name); |
|
| 521 | 1 | $xtpl->assign("CALL_SUBJECT", $call->name); |
|
| 522 | 1 | $xtpl->assign("CALL_STARTDATE", $xOffset); |
|
| 523 | 1 | $xtpl->assign("CALL_HOURS", $call->duration_hours); |
|
| 524 | 1 | $xtpl->assign("CALL_MINUTES", $call->duration_minutes); |
|
| 525 | 1 | $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : "")); |
|
| 526 | 1 | $xtpl->assign("CALL_DESCRIPTION", $call->description); |
|
| 527 | |||
| 528 | 1 | return $xtpl; |
|
| 529 | } |
||
| 530 | |||
| 531 | |||
| 532 | 1 | function get_call_users() { |
|
| 533 | 1 | $template = new User(); |
|
| 534 | // First, get the list of IDs. |
||
| 535 | 1 | $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"; |
|
| 536 | 1 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
| 537 | 1 | $result = $this->db->query($query, true); |
|
| 538 | 1 | $list = Array(); |
|
| 539 | |||
| 540 | 1 | while($row = $this->db->fetchByAssoc($result)) { |
|
| 541 | $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one |
||
| 542 | $record = $template->retrieve($row['user_id']); |
||
| 543 | $template->required = $row['required']; |
||
| 544 | $template->accept_status = $row['accept_status']; |
||
| 545 | |||
| 546 | if($record != null) { |
||
| 547 | // this copies the object into the array |
||
| 548 | $list[] = $template; |
||
| 549 | } |
||
| 550 | } |
||
| 551 | 1 | return $list; |
|
| 552 | } |
||
| 553 | |||
| 554 | |||
| 555 | 1 | function get_invite_calls(&$user) |
|
| 556 | { |
||
| 557 | 1 | $template = $this; |
|
| 558 | // First, get the list of IDs. |
||
| 559 | 1 | $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"; |
|
| 560 | 1 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
| 561 | |||
| 562 | |||
| 563 | 1 | $result = $this->db->query($query, true); |
|
| 564 | |||
| 565 | |||
| 566 | 1 | $list = Array(); |
|
| 567 | |||
| 568 | |||
| 569 | 1 | while($row = $this->db->fetchByAssoc($result)) |
|
| 570 | { |
||
| 571 | $record = $template->retrieve($row['call_id']); |
||
| 572 | $template->required = $row['required']; |
||
| 573 | $template->accept_status = $row['accept_status']; |
||
| 574 | |||
| 575 | |||
| 576 | if($record != null) |
||
| 577 | { |
||
| 578 | // this copies the object into the array |
||
| 579 | $list[] = $template; |
||
| 580 | } |
||
| 581 | } |
||
| 582 | 1 | return $list; |
|
| 583 | |||
| 584 | } |
||
| 585 | |||
| 586 | |||
| 587 | 1 | function set_accept_status(&$user,$status) |
|
| 588 | { |
||
| 589 | 1 | if ( $user->object_name == 'User') |
|
| 590 | { |
||
| 591 | 1 | $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id); |
|
| 592 | 1 | $data_values = array('accept_status'=>$status); |
|
| 593 | 1 | $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
| 594 | 1 | global $current_user; |
|
| 595 | |||
| 596 | 1 | if ( $this->update_vcal ) |
|
| 597 | { |
||
| 598 | 1 | vCal::cache_sugar_vcal($user); |
|
| 599 | } |
||
| 600 | } |
||
| 601 | else if ( $user->object_name == 'Contact') |
||
| 602 | { |
||
| 603 | $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id); |
||
| 604 | $data_values = array('accept_status'=>$status); |
||
| 605 | $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values); |
||
| 606 | } |
||
| 607 | else if ( $user->object_name == 'Lead') |
||
| 608 | { |
||
| 609 | $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id); |
||
| 610 | $data_values = array('accept_status'=>$status); |
||
| 611 | $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values); |
||
| 612 | } |
||
| 613 | 1 | } |
|
| 614 | |||
| 615 | |||
| 616 | |||
| 617 | 1 | function get_notification_recipients() { |
|
| 618 | 1 | if($this->special_notification) { |
|
| 619 | return parent::get_notification_recipients(); |
||
| 620 | } |
||
| 621 | |||
| 622 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true)); |
||
| 623 | 1 | $list = array(); |
|
| 624 | 1 | if(!is_array($this->contacts_arr)) { |
|
| 625 | 1 | $this->contacts_arr = array(); |
|
| 626 | } |
||
| 627 | |||
| 628 | 1 | if(!is_array($this->users_arr)) { |
|
| 629 | 1 | $this->users_arr = array(); |
|
| 630 | } |
||
| 631 | |||
| 632 | 1 | if(!is_array($this->leads_arr)) { |
|
| 633 | 1 | $this->leads_arr = array(); |
|
| 634 | } |
||
| 635 | |||
| 636 | 1 | foreach($this->users_arr as $user_id) { |
|
| 637 | 1 | $notify_user = new User(); |
|
| 638 | 1 | $notify_user->retrieve($user_id); |
|
| 639 | 1 | $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 640 | 1 | $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 641 | 1 | $list[$notify_user->id] = $notify_user; |
|
| 642 | } |
||
| 643 | |||
| 644 | 1 | foreach($this->contacts_arr as $contact_id) { |
|
| 645 | $notify_user = new Contact(); |
||
| 646 | $notify_user->retrieve($contact_id); |
||
| 647 | $notify_user->new_assigned_user_name = $notify_user->full_name; |
||
| 648 | $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
||
| 649 | $list[$notify_user->id] = $notify_user; |
||
| 650 | } |
||
| 651 | |||
| 652 | 1 | foreach($this->leads_arr as $lead_id) { |
|
| 653 | $notify_user = new Lead(); |
||
| 654 | $notify_user->retrieve($lead_id); |
||
| 655 | $notify_user->new_assigned_user_name = $notify_user->full_name; |
||
| 656 | $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
||
| 657 | $list[$notify_user->id] = $notify_user; |
||
| 658 | } |
||
| 659 | 1 | global $sugar_config; |
|
| 660 | 1 | if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
|
| 661 | global $current_user; |
||
| 662 | if(isset($list[$current_user->id])) |
||
| 663 | unset($list[$current_user->id]); |
||
| 664 | } |
||
| 665 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true)); |
||
| 666 | 1 | return $list; |
|
| 667 | } |
||
| 668 | |||
| 669 | 43 | function bean_implements($interface){ |
|
| 670 | switch($interface){ |
||
| 671 | 43 | case 'ACL':return true; |
|
|
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
|
|||
| 672 | } |
||
| 673 | 3 | return false; |
|
| 674 | } |
||
| 675 | |||
| 676 | 1 | function listviewACLHelper(){ |
|
| 677 | 1 | $array_assign = parent::listviewACLHelper(); |
|
| 678 | 1 | $is_owner = false; |
|
| 679 | 1 | $in_group = false; //SECURITY GROUPS |
|
| 680 | 1 | if(!empty($this->parent_name)){ |
|
| 681 | |||
| 682 | if(!empty($this->parent_name_owner)){ |
||
| 683 | global $current_user; |
||
| 684 | $is_owner = $current_user->id == $this->parent_name_owner; |
||
| 685 | } |
||
| 686 | /* BEGIN - SECURITY GROUPS */ |
||
| 687 | //parent_name_owner not being set for whatever reason so we need to figure this out |
||
| 688 | else if(!empty($this->parent_type) && !empty($this->parent_id)) { |
||
| 689 | global $current_user; |
||
| 690 | $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id); |
||
| 691 | if($parent_bean !== false) { |
||
| 692 | $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
||
| 693 | } |
||
| 694 | } |
||
| 695 | require_once("modules/SecurityGroups/SecurityGroup.php"); |
||
| 696 | $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view'); |
||
| 697 | /* END - SECURITY GROUPS */ |
||
| 698 | } |
||
| 699 | |||
| 700 | /* BEGIN - SECURITY GROUPS */ |
||
| 701 | /** |
||
| 702 | if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){ |
||
| 703 | */ |
||
| 704 | 1 | if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
| 705 | /* END - SECURITY GROUPS */ |
||
| 706 | 1 | $array_assign['PARENT'] = 'a'; |
|
| 707 | }else{ |
||
| 708 | $array_assign['PARENT'] = 'span'; |
||
| 709 | } |
||
| 710 | 1 | $is_owner = false; |
|
| 711 | 1 | $in_group = false; //SECURITY GROUPS |
|
| 712 | 1 | if(!empty($this->contact_name)){ |
|
| 713 | |||
| 714 | if(!empty($this->contact_name_owner)){ |
||
| 715 | global $current_user; |
||
| 716 | $is_owner = $current_user->id == $this->contact_name_owner; |
||
| 717 | } |
||
| 718 | /* BEGIN - SECURITY GROUPS */ |
||
| 719 | //contact_name_owner not being set for whatever reason so we need to figure this out |
||
| 720 | else { |
||
| 721 | global $current_user; |
||
| 722 | $parent_bean = BeanFactory::getBean('Contacts',$this->contact_id); |
||
| 723 | if($parent_bean !== false) { |
||
| 724 | $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
||
| 725 | } |
||
| 726 | } |
||
| 727 | require_once("modules/SecurityGroups/SecurityGroup.php"); |
||
| 728 | $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); |
||
| 729 | /* END - SECURITY GROUPS */ |
||
| 730 | } |
||
| 731 | /* BEGIN - SECURITY GROUPS */ |
||
| 732 | /** |
||
| 733 | if( ACLController::checkAccess('Contacts', 'view', $is_owner)){ |
||
| 734 | */ |
||
| 735 | 1 | if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){ |
|
| 736 | /* END - SECURITY GROUPS */ |
||
| 737 | 1 | $array_assign['CONTACT'] = 'a'; |
|
| 738 | }else{ |
||
| 739 | $array_assign['CONTACT'] = 'span'; |
||
| 740 | } |
||
| 741 | |||
| 742 | 1 | return $array_assign; |
|
| 743 | } |
||
| 744 | |||
| 745 | 3 | function save_relationship_changes($is_update, $exclude = array()) { |
|
| 746 | 3 | if(empty($this->in_workflow)) |
|
| 747 | { |
||
| 748 | 3 | if(empty($this->in_import)) |
|
| 749 | { |
||
| 750 | //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 |
||
| 751 | //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship |
||
| 752 | 3 | if(!empty($GLOBALS['soap_server_object'])) |
|
| 753 | { |
||
| 754 | $exclude = array('lead_id', 'contact_id', 'user_id'); |
||
| 755 | } |
||
| 756 | else |
||
| 757 | { |
||
| 758 | 3 | $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id'); |
|
| 759 | } |
||
| 760 | } |
||
| 761 | else |
||
| 762 | { |
||
| 763 | $exclude = array('user_id'); |
||
| 764 | } |
||
| 765 | |||
| 766 | |||
| 767 | } |
||
| 768 | 3 | parent::save_relationship_changes($is_update, $exclude); |
|
| 769 | 3 | } |
|
| 770 | |||
| 771 | 1 | public function getDefaultStatus() |
|
| 772 | { |
||
| 773 | 1 | $def = $this->field_defs['status']; |
|
| 774 | 1 | if (isset($def['default'])) { |
|
| 775 | 1 | return $def['default']; |
|
| 776 | } else { |
||
| 777 | $app = return_app_list_strings_language($GLOBALS['current_language']); |
||
| 778 | if (isset($def['options']) && isset($app[$def['options']])) { |
||
| 779 | $keys = array_keys($app[$def['options']]); |
||
| 780 | return $keys[0]; |
||
| 781 | } |
||
| 782 | } |
||
| 783 | return ''; |
||
| 784 | } |
||
| 785 | |||
| 786 | 2 | public function mark_deleted($id) |
|
| 787 | { |
||
| 788 | 2 | require_once("modules/Calendar/CalendarUtils.php"); |
|
| 789 | 2 | CalendarUtils::correctRecurrences($this, $id); |
|
| 790 | |||
| 791 | 2 | parent::mark_deleted($id); |
|
| 792 | 2 | } |
|
| 793 | } |
||
| 794 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.