@@ -47,176 +47,176 @@ discard block |
||
| 47 | 47 | ********************************************************************************/ |
| 48 | 48 | |
| 49 | 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; |
|
| 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 | 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"; |
|
| 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 | 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', |
|
| 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 | 121 | 'lead_id' => 'leads', |
| 122 | - ); |
|
| 123 | - |
|
| 124 | - public function __construct() { |
|
| 125 | - parent::__construct(); |
|
| 126 | - global $app_list_strings; |
|
| 127 | - |
|
| 128 | - $this->setupCustomFields('Calls'); |
|
| 129 | - |
|
| 130 | - foreach ($this->field_defs as $field) { |
|
| 131 | - $this->field_name_map[$field['name']] = $field; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 138 | - $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
|
| 139 | - } |
|
| 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 | - function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
| 161 | - // don't check if call is being synced from Outlook |
|
| 162 | - if($this->syncing == false){ |
|
| 163 | - $view = strtolower($view); |
|
| 164 | - switch($view){ |
|
| 165 | - case 'edit': |
|
| 166 | - case 'save': |
|
| 167 | - case 'editview': |
|
| 168 | - case 'delete': |
|
| 169 | - if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - return parent::ACLAccess($view,$is_owner,$in_group); |
|
| 175 | - } |
|
| 122 | + ); |
|
| 123 | + |
|
| 124 | + public function __construct() { |
|
| 125 | + parent::__construct(); |
|
| 126 | + global $app_list_strings; |
|
| 127 | + |
|
| 128 | + $this->setupCustomFields('Calls'); |
|
| 129 | + |
|
| 130 | + foreach ($this->field_defs as $field) { |
|
| 131 | + $this->field_name_map[$field['name']] = $field; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 138 | + $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
|
| 139 | + } |
|
| 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 | + function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
| 161 | + // don't check if call is being synced from Outlook |
|
| 162 | + if($this->syncing == false){ |
|
| 163 | + $view = strtolower($view); |
|
| 164 | + switch($view){ |
|
| 165 | + case 'edit': |
|
| 166 | + case 'save': |
|
| 167 | + case 'editview': |
|
| 168 | + case 'delete': |
|
| 169 | + if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + return parent::ACLAccess($view,$is_owner,$in_group); |
|
| 175 | + } |
|
| 176 | 176 | // save date_end by calculating user input |
| 177 | 177 | // this is for calendar |
| 178 | - function save($check_notify = FALSE) { |
|
| 179 | - global $timedate,$current_user; |
|
| 178 | + function save($check_notify = FALSE) { |
|
| 179 | + global $timedate,$current_user; |
|
| 180 | 180 | |
| 181 | - if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) |
|
| 181 | + if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) |
|
| 182 | 182 | { |
| 183 | - $td = $timedate->fromDb($this->date_start); |
|
| 184 | - if($td) |
|
| 185 | - { |
|
| 186 | - $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); |
|
| 187 | - } |
|
| 183 | + $td = $timedate->fromDb($this->date_start); |
|
| 184 | + if($td) |
|
| 185 | + { |
|
| 186 | + $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); |
|
| 187 | + } |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { |
|
| 191 | - $check_notify = true; |
|
| 190 | + if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { |
|
| 191 | + $check_notify = true; |
|
| 192 | 192 | } else { |
| 193 | - $check_notify = false; |
|
| 194 | - } |
|
| 195 | - if(empty($_REQUEST['send_invites'])) { |
|
| 196 | - if(!empty($this->id)) { |
|
| 197 | - $old_record = new Call(); |
|
| 198 | - $old_record->retrieve($this->id); |
|
| 199 | - $old_assigned_user_id = $old_record->assigned_user_id; |
|
| 200 | - } |
|
| 201 | - 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 | - } |
|
| 193 | + $check_notify = false; |
|
| 194 | + } |
|
| 195 | + if(empty($_REQUEST['send_invites'])) { |
|
| 196 | + if(!empty($this->id)) { |
|
| 197 | + $old_record = new Call(); |
|
| 198 | + $old_record->retrieve($this->id); |
|
| 199 | + $old_assigned_user_id = $old_record->assigned_user_id; |
|
| 200 | + } |
|
| 201 | + 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 | 206 | if(isset($_REQUEST['assigned_user_name'])) { |
| 207 | 207 | $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; |
| 208 | 208 | } |
| 209 | - } |
|
| 210 | - } |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | if (empty($this->status) ) { |
| 212 | 212 | $this->status = $this->getDefaultStatus(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - // prevent a mass mailing for recurring meetings created in Calendar module |
|
| 216 | - 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 |
|
| 215 | + // prevent a mass mailing for recurring meetings created in Calendar module |
|
| 216 | + 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 | 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 | 221 | $this->reminder_checked = '1'; |
| 222 | 222 | $this->reminder_time = $current_user->getPreference('reminder_time'); |
@@ -227,87 +227,87 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | if($this->update_vcal) { |
| 230 | - vCal::cache_sugar_vcal($current_user); |
|
| 230 | + vCal::cache_sugar_vcal($current_user); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if(isset($_REQUEST['reminders_data'])) { |
|
| 234 | - Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
|
| 235 | - } |
|
| 233 | + if(isset($_REQUEST['reminders_data'])) { |
|
| 234 | + Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | return $return_id; |
| 238 | - } |
|
| 238 | + } |
|
| 239 | 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 | - function get_contacts() |
|
| 246 | - { |
|
| 247 | - // First, get the list of IDs. |
|
| 248 | - $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0"; |
|
| 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 | + function get_contacts() |
|
| 246 | + { |
|
| 247 | + // First, get the list of IDs. |
|
| 248 | + $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0"; |
|
| 249 | 249 | |
| 250 | - return $this->build_related_list($query, new Contact()); |
|
| 251 | - } |
|
| 250 | + return $this->build_related_list($query, new Contact()); |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | |
| 254 | - function get_summary_text() |
|
| 255 | - { |
|
| 256 | - return "$this->name"; |
|
| 257 | - } |
|
| 254 | + function get_summary_text() |
|
| 255 | + { |
|
| 256 | + return "$this->name"; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - function create_list_query($order_by, $where, $show_deleted=0) |
|
| 260 | - { |
|
| 259 | + function create_list_query($order_by, $where, $show_deleted=0) |
|
| 260 | + { |
|
| 261 | 261 | $custom_join = $this->getCustomJoin(); |
| 262 | 262 | $query = "SELECT "; |
| 263 | - $query .= " |
|
| 263 | + $query .= " |
|
| 264 | 264 | calls.*,"; |
| 265 | - if ( preg_match("/calls_users\.user_id/",$where)) |
|
| 266 | - { |
|
| 267 | - $query .= "calls_users.required, |
|
| 265 | + if ( preg_match("/calls_users\.user_id/",$where)) |
|
| 266 | + { |
|
| 267 | + $query .= "calls_users.required, |
|
| 268 | 268 | calls_users.accept_status,"; |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - $query .= " |
|
| 271 | + $query .= " |
|
| 272 | 272 | users.user_name as assigned_user_name"; |
| 273 | 273 | $query .= $custom_join['select']; |
| 274 | 274 | |
| 275 | - // this line will help generate a GMT-metric to compare to a locale's timezone |
|
| 275 | + // this line will help generate a GMT-metric to compare to a locale's timezone |
|
| 276 | 276 | |
| 277 | - if ( preg_match("/contacts/",$where)){ |
|
| 278 | - $query .= ", contacts.first_name, contacts.last_name"; |
|
| 279 | - $query .= ", contacts.assigned_user_id contact_name_owner"; |
|
| 280 | - } |
|
| 281 | - $query .= " FROM calls "; |
|
| 277 | + if ( preg_match("/contacts/",$where)){ |
|
| 278 | + $query .= ", contacts.first_name, contacts.last_name"; |
|
| 279 | + $query .= ", contacts.assigned_user_id contact_name_owner"; |
|
| 280 | + } |
|
| 281 | + $query .= " FROM calls "; |
|
| 282 | 282 | |
| 283 | - if ( preg_match("/contacts/",$where)){ |
|
| 284 | - $query .= "LEFT JOIN calls_contacts |
|
| 283 | + if ( preg_match("/contacts/",$where)){ |
|
| 284 | + $query .= "LEFT JOIN calls_contacts |
|
| 285 | 285 | ON calls.id=calls_contacts.call_id |
| 286 | 286 | LEFT JOIN contacts |
| 287 | 287 | ON calls_contacts.contact_id=contacts.id "; |
| 288 | - } |
|
| 289 | - if ( preg_match('/calls_users\.user_id/',$where)) |
|
| 290 | - { |
|
| 291 | - $query .= "LEFT JOIN calls_users |
|
| 288 | + } |
|
| 289 | + if ( preg_match('/calls_users\.user_id/',$where)) |
|
| 290 | + { |
|
| 291 | + $query .= "LEFT JOIN calls_users |
|
| 292 | 292 | ON calls.id=calls_users.call_id and calls_users.deleted=0 "; |
| 293 | - } |
|
| 294 | - $query .= " |
|
| 293 | + } |
|
| 294 | + $query .= " |
|
| 295 | 295 | LEFT JOIN users |
| 296 | 296 | ON calls.assigned_user_id=users.id "; |
| 297 | 297 | $query .= $custom_join['join']; |
| 298 | - $where_auto = '1=1'; |
|
| 299 | - if($show_deleted == 0){ |
|
| 300 | - $where_auto = " $this->table_name.deleted=0 "; |
|
| 301 | - }else if($show_deleted == 1){ |
|
| 302 | - $where_auto = " $this->table_name.deleted=1 "; |
|
| 303 | - } |
|
| 298 | + $where_auto = '1=1'; |
|
| 299 | + if($show_deleted == 0){ |
|
| 300 | + $where_auto = " $this->table_name.deleted=0 "; |
|
| 301 | + }else if($show_deleted == 1){ |
|
| 302 | + $where_auto = " $this->table_name.deleted=1 "; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - //$where_auto .= " GROUP BY calls.id"; |
|
| 305 | + //$where_auto .= " GROUP BY calls.id"; |
|
| 306 | 306 | |
| 307 | - if($where != "") |
|
| 308 | - $query .= "where $where AND ".$where_auto; |
|
| 309 | - else |
|
| 310 | - $query .= "where ".$where_auto; |
|
| 307 | + if($where != "") |
|
| 308 | + $query .= "where $where AND ".$where_auto; |
|
| 309 | + else |
|
| 310 | + $query .= "where ".$where_auto; |
|
| 311 | 311 | |
| 312 | 312 | $order_by = $this->process_order_by($order_by); |
| 313 | 313 | if (empty($order_by)) { |
@@ -315,14 +315,14 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | $query .= ' ORDER BY ' . $order_by; |
| 317 | 317 | |
| 318 | - return $query; |
|
| 319 | - } |
|
| 318 | + return $query; |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | 321 | function create_export_query($order_by, $where, $relate_link_join='') |
| 322 | 322 | { |
| 323 | 323 | $custom_join = $this->getCustomJoin(true, true, $where); |
| 324 | 324 | $custom_join['join'] .= $relate_link_join; |
| 325 | - $contact_required = stristr($where, "contacts"); |
|
| 325 | + $contact_required = stristr($where, "contacts"); |
|
| 326 | 326 | if($contact_required) |
| 327 | 327 | { |
| 328 | 328 | $query = "SELECT calls.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name "; |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
| 342 | - $query .= " LEFT JOIN users ON calls.assigned_user_id=users.id "; |
|
| 342 | + $query .= " LEFT JOIN users ON calls.assigned_user_id=users.id "; |
|
| 343 | 343 | |
| 344 | 344 | $query .= $custom_join['join']; |
| 345 | 345 | |
| 346 | - if($where != "") |
|
| 346 | + if($where != "") |
|
| 347 | 347 | $query .= "where $where AND ".$where_auto; |
| 348 | 348 | else |
| 349 | 349 | $query .= "where ".$where_auto; |
@@ -361,199 +361,199 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | |
| 363 | 363 | |
| 364 | - function fill_in_additional_detail_fields() |
|
| 365 | - { |
|
| 366 | - global $locale; |
|
| 367 | - parent::fill_in_additional_detail_fields(); |
|
| 368 | - 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 | - if (!isset($this->duration_minutes)) { |
|
| 384 | - $this->duration_minutes = $this->minutes_value_default; |
|
| 385 | - } |
|
| 364 | + function fill_in_additional_detail_fields() |
|
| 365 | + { |
|
| 366 | + global $locale; |
|
| 367 | + parent::fill_in_additional_detail_fields(); |
|
| 368 | + 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 | + if (!isset($this->duration_minutes)) { |
|
| 384 | + $this->duration_minutes = $this->minutes_value_default; |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | 387 | global $timedate; |
| 388 | 388 | //setting default date and time |
| 389 | - if (is_null($this->date_start)) { |
|
| 390 | - $this->date_start = $timedate->now(); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - if (is_null($this->duration_hours)) |
|
| 394 | - $this->duration_hours = "0"; |
|
| 395 | - if (is_null($this->duration_minutes)) |
|
| 396 | - $this->duration_minutes = "1"; |
|
| 397 | - |
|
| 398 | - $this->fill_in_additional_parent_fields(); |
|
| 399 | - |
|
| 400 | - global $app_list_strings; |
|
| 401 | - $parent_types = $app_list_strings['record_type_display']; |
|
| 402 | - $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
| 403 | - 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 | - $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type); |
|
| 410 | - |
|
| 411 | - if (empty($this->reminder_time)) { |
|
| 412 | - $this->reminder_time = -1; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - if ( empty($this->id) ) { |
|
| 416 | - $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
|
| 417 | - if ( isset($reminder_t) ) |
|
| 418 | - $this->reminder_time = $reminder_t; |
|
| 419 | - } |
|
| 420 | - $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
|
| 421 | - |
|
| 422 | - if (empty($this->email_reminder_time)) { |
|
| 423 | - $this->email_reminder_time = -1; |
|
| 424 | - } |
|
| 425 | - if(empty($this->id)){ |
|
| 426 | - $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
|
| 427 | - if(isset($reminder_t)) |
|
| 428 | - $this->email_reminder_time = $reminder_t; |
|
| 429 | - } |
|
| 430 | - $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
|
| 431 | - |
|
| 432 | - if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) { |
|
| 433 | - $this->parent_type = $_REQUEST['parent_type']; |
|
| 434 | - } elseif (is_null($this->parent_type)) { |
|
| 435 | - $this->parent_type = $app_list_strings['record_type_default_key']; |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - function get_list_view_data(){ |
|
| 441 | - $call_fields = $this->get_list_view_array(); |
|
| 442 | - global $app_list_strings, $focus, $action, $currentModule; |
|
| 443 | - if (isset($focus->id)) $id = $focus->id; |
|
| 444 | - else $id = ''; |
|
| 445 | - if (isset($this->parent_type) && $this->parent_type != null) |
|
| 446 | - { |
|
| 447 | - $call_fields['PARENT_MODULE'] = $this->parent_type; |
|
| 448 | - } |
|
| 449 | - 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 | - if(empty($action)) |
|
| 452 | - $action = "index"; |
|
| 389 | + if (is_null($this->date_start)) { |
|
| 390 | + $this->date_start = $timedate->now(); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + if (is_null($this->duration_hours)) |
|
| 394 | + $this->duration_hours = "0"; |
|
| 395 | + if (is_null($this->duration_minutes)) |
|
| 396 | + $this->duration_minutes = "1"; |
|
| 397 | + |
|
| 398 | + $this->fill_in_additional_parent_fields(); |
|
| 399 | + |
|
| 400 | + global $app_list_strings; |
|
| 401 | + $parent_types = $app_list_strings['record_type_display']; |
|
| 402 | + $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
| 403 | + 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 | + $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type); |
|
| 410 | + |
|
| 411 | + if (empty($this->reminder_time)) { |
|
| 412 | + $this->reminder_time = -1; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + if ( empty($this->id) ) { |
|
| 416 | + $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
|
| 417 | + if ( isset($reminder_t) ) |
|
| 418 | + $this->reminder_time = $reminder_t; |
|
| 419 | + } |
|
| 420 | + $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
|
| 421 | + |
|
| 422 | + if (empty($this->email_reminder_time)) { |
|
| 423 | + $this->email_reminder_time = -1; |
|
| 424 | + } |
|
| 425 | + if(empty($this->id)){ |
|
| 426 | + $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
|
| 427 | + if(isset($reminder_t)) |
|
| 428 | + $this->email_reminder_time = $reminder_t; |
|
| 429 | + } |
|
| 430 | + $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
|
| 431 | + |
|
| 432 | + if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) { |
|
| 433 | + $this->parent_type = $_REQUEST['parent_type']; |
|
| 434 | + } elseif (is_null($this->parent_type)) { |
|
| 435 | + $this->parent_type = $app_list_strings['record_type_default_key']; |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + function get_list_view_data(){ |
|
| 441 | + $call_fields = $this->get_list_view_array(); |
|
| 442 | + global $app_list_strings, $focus, $action, $currentModule; |
|
| 443 | + if (isset($focus->id)) $id = $focus->id; |
|
| 444 | + else $id = ''; |
|
| 445 | + if (isset($this->parent_type) && $this->parent_type != null) |
|
| 446 | + { |
|
| 447 | + $call_fields['PARENT_MODULE'] = $this->parent_type; |
|
| 448 | + } |
|
| 449 | + 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 | + if(empty($action)) |
|
| 452 | + $action = "index"; |
|
| 453 | 453 | |
| 454 | 454 | $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>"; |
| 455 | - if ($this->ACLAccess('edit')) { |
|
| 455 | + if ($this->ACLAccess('edit')) { |
|
| 456 | 456 | $call_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline"," border='0'",null,null,'.gif',translate('LBL_CLOSEINLINE'))."</a>"; |
| 457 | 457 | } else { |
| 458 | 458 | $call_fields['SET_COMPLETE'] = ''; |
| 459 | 459 | } |
| 460 | - } |
|
| 461 | - global $timedate; |
|
| 462 | - $today = $timedate->nowDb(); |
|
| 463 | - $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day")); |
|
| 464 | - $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']); |
|
| 465 | - $date_db = $timedate->to_db($mergeTime); |
|
| 466 | - if( $date_db < $today){ |
|
| 467 | - $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 | - $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 | - if (!empty($this->contact_id)) { |
|
| 477 | - // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs |
|
| 460 | + } |
|
| 461 | + global $timedate; |
|
| 462 | + $today = $timedate->nowDb(); |
|
| 463 | + $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day")); |
|
| 464 | + $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']); |
|
| 465 | + $date_db = $timedate->to_db($mergeTime); |
|
| 466 | + if( $date_db < $today){ |
|
| 467 | + $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 | + $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 | + if (!empty($this->contact_id)) { |
|
| 477 | + // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs |
|
| 478 | 478 | $contact_temp = BeanFactory::getBean("Contacts", $this->contact_id); |
| 479 | 479 | if(!empty($contact_temp)) { |
| 480 | 480 | $contact_temp->_create_proper_name_field(); |
| 481 | 481 | $this->contact_name = $contact_temp->full_name; |
| 482 | 482 | } |
| 483 | - } |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | 485 | $call_fields['CONTACT_ID'] = $this->contact_id; |
| 486 | 486 | $call_fields['CONTACT_NAME'] = $this->contact_name; |
| 487 | - $call_fields['PARENT_NAME'] = $this->parent_name; |
|
| 487 | + $call_fields['PARENT_NAME'] = $this->parent_name; |
|
| 488 | 488 | $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true; |
| 489 | - $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true; |
|
| 489 | + $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true; |
|
| 490 | 490 | |
| 491 | - return $call_fields; |
|
| 492 | - } |
|
| 491 | + return $call_fields; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - function set_notification_body($xtpl, $call) { |
|
| 495 | - global $sugar_config; |
|
| 496 | - global $app_list_strings; |
|
| 497 | - global $current_user; |
|
| 498 | - global $app_list_strings; |
|
| 499 | - global $timedate; |
|
| 494 | + function set_notification_body($xtpl, $call) { |
|
| 495 | + global $sugar_config; |
|
| 496 | + global $app_list_strings; |
|
| 497 | + global $current_user; |
|
| 498 | + global $app_list_strings; |
|
| 499 | + global $timedate; |
|
| 500 | 500 | |
| 501 | 501 | // rrs: bug 42684 - passing a contact breaks this call |
| 502 | - $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 | - $calldate = $timedate->fromDb($call->date_start); |
|
| 507 | - $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser); |
|
| 508 | - |
|
| 509 | - 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 | - } 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 | - $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 517 | - '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name); |
|
| 521 | - $xtpl->assign("CALL_SUBJECT", $call->name); |
|
| 522 | - $xtpl->assign("CALL_STARTDATE", $xOffset); |
|
| 523 | - $xtpl->assign("CALL_HOURS", $call->duration_hours); |
|
| 524 | - $xtpl->assign("CALL_MINUTES", $call->duration_minutes); |
|
| 525 | - $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : "")); |
|
| 526 | - $xtpl->assign("CALL_DESCRIPTION", $call->description); |
|
| 527 | - |
|
| 528 | - return $xtpl; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - |
|
| 532 | - function get_call_users() { |
|
| 533 | - $template = new User(); |
|
| 534 | - // First, get the list of IDs. |
|
| 535 | - $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 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
| 537 | - $result = $this->db->query($query, true); |
|
| 538 | - $list = Array(); |
|
| 539 | - |
|
| 540 | - 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 | - return $list; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - |
|
| 555 | - function get_invite_calls(&$user) |
|
| 556 | - { |
|
| 502 | + $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 | + $calldate = $timedate->fromDb($call->date_start); |
|
| 507 | + $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser); |
|
| 508 | + |
|
| 509 | + 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 | + } 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 | + $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
|
| 517 | + '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id); |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name); |
|
| 521 | + $xtpl->assign("CALL_SUBJECT", $call->name); |
|
| 522 | + $xtpl->assign("CALL_STARTDATE", $xOffset); |
|
| 523 | + $xtpl->assign("CALL_HOURS", $call->duration_hours); |
|
| 524 | + $xtpl->assign("CALL_MINUTES", $call->duration_minutes); |
|
| 525 | + $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : "")); |
|
| 526 | + $xtpl->assign("CALL_DESCRIPTION", $call->description); |
|
| 527 | + |
|
| 528 | + return $xtpl; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + |
|
| 532 | + function get_call_users() { |
|
| 533 | + $template = new User(); |
|
| 534 | + // First, get the list of IDs. |
|
| 535 | + $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 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
| 537 | + $result = $this->db->query($query, true); |
|
| 538 | + $list = Array(); |
|
| 539 | + |
|
| 540 | + 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 | + return $list; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + |
|
| 555 | + function get_invite_calls(&$user) |
|
| 556 | + { |
|
| 557 | 557 | $template = $this; |
| 558 | 558 | // First, get the list of IDs. |
| 559 | 559 | $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"; |
@@ -568,182 +568,182 @@ discard block |
||
| 568 | 568 | |
| 569 | 569 | while($row = $this->db->fetchByAssoc($result)) |
| 570 | 570 | { |
| 571 | - $record = $template->retrieve($row['call_id']); |
|
| 572 | - $template->required = $row['required']; |
|
| 573 | - $template->accept_status = $row['accept_status']; |
|
| 571 | + $record = $template->retrieve($row['call_id']); |
|
| 572 | + $template->required = $row['required']; |
|
| 573 | + $template->accept_status = $row['accept_status']; |
|
| 574 | 574 | |
| 575 | 575 | |
| 576 | - if($record != null) |
|
| 577 | - { |
|
| 576 | + if($record != null) |
|
| 577 | + { |
|
| 578 | 578 | // this copies the object into the array |
| 579 | 579 | $list[] = $template; |
| 580 | - } |
|
| 580 | + } |
|
| 581 | 581 | } |
| 582 | 582 | return $list; |
| 583 | 583 | |
| 584 | - } |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | |
| 587 | - function set_accept_status(&$user,$status) |
|
| 588 | - { |
|
| 587 | + function set_accept_status(&$user,$status) |
|
| 588 | + { |
|
| 589 | 589 | if ( $user->object_name == 'User') |
| 590 | 590 | { |
| 591 | - $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id); |
|
| 592 | - $data_values = array('accept_status'=>$status); |
|
| 593 | - $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
| 594 | - global $current_user; |
|
| 591 | + $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id); |
|
| 592 | + $data_values = array('accept_status'=>$status); |
|
| 593 | + $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
| 594 | + global $current_user; |
|
| 595 | 595 | |
| 596 | - if ( $this->update_vcal ) |
|
| 597 | - { |
|
| 596 | + if ( $this->update_vcal ) |
|
| 597 | + { |
|
| 598 | 598 | vCal::cache_sugar_vcal($user); |
| 599 | - } |
|
| 599 | + } |
|
| 600 | 600 | } |
| 601 | 601 | else if ( $user->object_name == 'Contact') |
| 602 | 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); |
|
| 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 | 606 | } |
| 607 | 607 | else if ( $user->object_name == 'Lead') |
| 608 | 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); |
|
| 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 | + } |
|
| 612 | 613 | } |
| 613 | - } |
|
| 614 | 614 | |
| 615 | 615 | |
| 616 | 616 | |
| 617 | - function get_notification_recipients() { |
|
| 618 | - if($this->special_notification) { |
|
| 619 | - return parent::get_notification_recipients(); |
|
| 620 | - } |
|
| 617 | + function get_notification_recipients() { |
|
| 618 | + if($this->special_notification) { |
|
| 619 | + return parent::get_notification_recipients(); |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true)); |
| 623 | - $list = array(); |
|
| 623 | + $list = array(); |
|
| 624 | 624 | if(!is_array($this->contacts_arr)) { |
| 625 | - $this->contacts_arr = array(); |
|
| 626 | - } |
|
| 625 | + $this->contacts_arr = array(); |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - if(!is_array($this->users_arr)) { |
|
| 629 | - $this->users_arr = array(); |
|
| 630 | - } |
|
| 628 | + if(!is_array($this->users_arr)) { |
|
| 629 | + $this->users_arr = array(); |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | 632 | if(!is_array($this->leads_arr)) { |
| 633 | - $this->leads_arr = array(); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - foreach($this->users_arr as $user_id) { |
|
| 637 | - $notify_user = new User(); |
|
| 638 | - $notify_user->retrieve($user_id); |
|
| 639 | - $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 640 | - $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 641 | - $list[$notify_user->id] = $notify_user; |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - 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 | - } |
|
| 633 | + $this->leads_arr = array(); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + foreach($this->users_arr as $user_id) { |
|
| 637 | + $notify_user = new User(); |
|
| 638 | + $notify_user->retrieve($user_id); |
|
| 639 | + $notify_user->new_assigned_user_name = $notify_user->full_name; |
|
| 640 | + $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name"); |
|
| 641 | + $list[$notify_user->id] = $notify_user; |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + 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 | 651 | |
| 652 | 652 | 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 | - global $sugar_config; |
|
| 660 | - 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 | - } |
|
| 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 | + global $sugar_config; |
|
| 660 | + 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 | 665 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true)); |
| 666 | - return $list; |
|
| 667 | - } |
|
| 666 | + return $list; |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | 669 | function bean_implements($interface){ |
| 670 | - switch($interface){ |
|
| 671 | - case 'ACL':return true; |
|
| 672 | - } |
|
| 673 | - return false; |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - function listviewACLHelper(){ |
|
| 677 | - $array_assign = parent::listviewACLHelper(); |
|
| 678 | - $is_owner = false; |
|
| 679 | - $in_group = false; //SECURITY GROUPS |
|
| 680 | - 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; |
|
| 670 | + switch($interface){ |
|
| 671 | + case 'ACL':return true; |
|
| 672 | + } |
|
| 673 | + return false; |
|
| 674 | + } |
|
| 675 | + |
|
| 676 | + function listviewACLHelper(){ |
|
| 677 | + $array_assign = parent::listviewACLHelper(); |
|
| 678 | + $is_owner = false; |
|
| 679 | + $in_group = false; //SECURITY GROUPS |
|
| 680 | + 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 | 690 | $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id); |
| 691 | 691 | if($parent_bean !== false) { |
| 692 | - $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 692 | + $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 693 | 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 | - /** |
|
| 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 | 702 | if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){ |
| 703 | - */ |
|
| 704 | - if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
| 705 | - /* END - SECURITY GROUPS */ |
|
| 706 | - $array_assign['PARENT'] = 'a'; |
|
| 707 | - }else{ |
|
| 708 | - $array_assign['PARENT'] = 'span'; |
|
| 709 | - } |
|
| 710 | - $is_owner = false; |
|
| 711 | - $in_group = false; //SECURITY GROUPS |
|
| 712 | - 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; |
|
| 703 | + */ |
|
| 704 | + if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
| 705 | + /* END - SECURITY GROUPS */ |
|
| 706 | + $array_assign['PARENT'] = 'a'; |
|
| 707 | + }else{ |
|
| 708 | + $array_assign['PARENT'] = 'span'; |
|
| 709 | + } |
|
| 710 | + $is_owner = false; |
|
| 711 | + $in_group = false; //SECURITY GROUPS |
|
| 712 | + 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 | 722 | $parent_bean = BeanFactory::getBean('Contacts',$this->contact_id); |
| 723 | 723 | if($parent_bean !== false) { |
| 724 | - $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 724 | + $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
|
| 725 | 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 | - /** |
|
| 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 | 733 | if( ACLController::checkAccess('Contacts', 'view', $is_owner)){ |
| 734 | - */ |
|
| 735 | - if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){ |
|
| 736 | - /* END - SECURITY GROUPS */ |
|
| 737 | - $array_assign['CONTACT'] = 'a'; |
|
| 738 | - }else{ |
|
| 739 | - $array_assign['CONTACT'] = 'span'; |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - return $array_assign; |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - function save_relationship_changes($is_update, $exclude = array()) { |
|
| 746 | - if(empty($this->in_workflow)) |
|
| 734 | + */ |
|
| 735 | + if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){ |
|
| 736 | + /* END - SECURITY GROUPS */ |
|
| 737 | + $array_assign['CONTACT'] = 'a'; |
|
| 738 | + }else{ |
|
| 739 | + $array_assign['CONTACT'] = 'span'; |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + return $array_assign; |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + function save_relationship_changes($is_update, $exclude = array()) { |
|
| 746 | + if(empty($this->in_workflow)) |
|
| 747 | 747 | { |
| 748 | 748 | if(empty($this->in_import)) |
| 749 | 749 | { |
@@ -751,12 +751,12 @@ discard block |
||
| 751 | 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 | 752 | if(!empty($GLOBALS['soap_server_object'])) |
| 753 | 753 | { |
| 754 | - $exclude = array('lead_id', 'contact_id', 'user_id'); |
|
| 755 | - } |
|
| 754 | + $exclude = array('lead_id', 'contact_id', 'user_id'); |
|
| 755 | + } |
|
| 756 | 756 | else |
| 757 | 757 | { |
| 758 | - $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id'); |
|
| 759 | - } |
|
| 758 | + $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id'); |
|
| 759 | + } |
|
| 760 | 760 | } |
| 761 | 761 | else |
| 762 | 762 | { |
@@ -765,15 +765,15 @@ discard block |
||
| 765 | 765 | |
| 766 | 766 | |
| 767 | 767 | } |
| 768 | - parent::save_relationship_changes($is_update, $exclude); |
|
| 769 | - } |
|
| 768 | + parent::save_relationship_changes($is_update, $exclude); |
|
| 769 | + } |
|
| 770 | 770 | |
| 771 | 771 | public function getDefaultStatus() |
| 772 | 772 | { |
| 773 | - $def = $this->field_defs['status']; |
|
| 774 | - if (isset($def['default'])) { |
|
| 775 | - return $def['default']; |
|
| 776 | - } else { |
|
| 773 | + $def = $this->field_defs['status']; |
|
| 774 | + if (isset($def['default'])) { |
|
| 775 | + return $def['default']; |
|
| 776 | + } else { |
|
| 777 | 777 | $app = return_app_list_strings_language($GLOBALS['current_language']); |
| 778 | 778 | if (isset($def['options']) && isset($app[$def['options']])) { |
| 779 | 779 | $keys = array_keys($app[$def['options']]); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | var $leads_arr; |
| 98 | 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 | 99 | var $minutes_value_default = 15; |
| 100 | - var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45'); |
|
| 100 | + var $minutes_values = array('0'=>'00', '15'=>'15', '30'=>'30', '45'=>'45'); |
|
| 101 | 101 | var $table_name = "calls"; |
| 102 | 102 | var $rel_users_table = "calls_users"; |
| 103 | 103 | var $rel_contacts_table = "calls_contacts"; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | // This is used to retrieve related fields from form posts. |
| 113 | 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', |
|
| 114 | + var $relationship_fields = array('account_id' => 'accounts', |
|
| 115 | 115 | 'opportunity_id' => 'opportunities', |
| 116 | 116 | 'contact_id' => 'contacts', |
| 117 | 117 | 'case_id' => 'cases', |
@@ -134,16 +134,16 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 137 | + if (!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 138 | 138 | $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 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 | 143 | */ |
| 144 | - public function Call(){ |
|
| 144 | + public function Call() { |
|
| 145 | 145 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 146 | - if(isset($GLOBALS['log'])) { |
|
| 146 | + if (isset($GLOBALS['log'])) { |
|
| 147 | 147 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 148 | 148 | } |
| 149 | 149 | else { |
@@ -157,58 +157,58 @@ discard block |
||
| 157 | 157 | * @param $view string |
| 158 | 158 | * @param $is_owner bool |
| 159 | 159 | */ |
| 160 | - function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){ |
|
| 160 | + function ACLAccess($view, $is_owner = 'not_set', $in_group = 'not_set') { |
|
| 161 | 161 | // don't check if call is being synced from Outlook |
| 162 | - if($this->syncing == false){ |
|
| 162 | + if ($this->syncing == false) { |
|
| 163 | 163 | $view = strtolower($view); |
| 164 | - switch($view){ |
|
| 164 | + switch ($view) { |
|
| 165 | 165 | case 'edit': |
| 166 | 166 | case 'save': |
| 167 | 167 | case 'editview': |
| 168 | 168 | case 'delete': |
| 169 | - if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){ |
|
| 169 | + if (!empty($this->recurring_source) && $this->recurring_source != "Sugar") { |
|
| 170 | 170 | return false; |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | - return parent::ACLAccess($view,$is_owner,$in_group); |
|
| 174 | + return parent::ACLAccess($view, $is_owner, $in_group); |
|
| 175 | 175 | } |
| 176 | 176 | // save date_end by calculating user input |
| 177 | 177 | // this is for calendar |
| 178 | 178 | function save($check_notify = FALSE) { |
| 179 | - global $timedate,$current_user; |
|
| 179 | + global $timedate, $current_user; |
|
| 180 | 180 | |
| 181 | - if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) |
|
| 181 | + if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) |
|
| 182 | 182 | { |
| 183 | 183 | $td = $timedate->fromDb($this->date_start); |
| 184 | - if($td) |
|
| 184 | + if ($td) |
|
| 185 | 185 | { |
| 186 | 186 | $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { |
|
| 190 | + if (!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') { |
|
| 191 | 191 | $check_notify = true; |
| 192 | 192 | } else { |
| 193 | 193 | $check_notify = false; |
| 194 | 194 | } |
| 195 | - if(empty($_REQUEST['send_invites'])) { |
|
| 196 | - if(!empty($this->id)) { |
|
| 195 | + if (empty($_REQUEST['send_invites'])) { |
|
| 196 | + if (!empty($this->id)) { |
|
| 197 | 197 | $old_record = new Call(); |
| 198 | 198 | $old_record->retrieve($this->id); |
| 199 | 199 | $old_assigned_user_id = $old_record->assigned_user_id; |
| 200 | 200 | } |
| 201 | - 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']) ){ |
|
| 201 | + 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 | 202 | $this->special_notification = true; |
| 203 | - if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) { |
|
| 203 | + if (!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) { |
|
| 204 | 204 | $check_notify = true; |
| 205 | 205 | } |
| 206 | - if(isset($_REQUEST['assigned_user_name'])) { |
|
| 206 | + if (isset($_REQUEST['assigned_user_name'])) { |
|
| 207 | 207 | $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | - if (empty($this->status) ) { |
|
| 211 | + if (empty($this->status)) { |
|
| 212 | 212 | $this->status = $this->getDefaultStatus(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | global $current_user; |
| 227 | 227 | |
| 228 | 228 | |
| 229 | - if($this->update_vcal) { |
|
| 229 | + if ($this->update_vcal) { |
|
| 230 | 230 | vCal::cache_sugar_vcal($current_user); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if(isset($_REQUEST['reminders_data'])) { |
|
| 233 | + if (isset($_REQUEST['reminders_data'])) { |
|
| 234 | 234 | Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data'])); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | return "$this->name"; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - function create_list_query($order_by, $where, $show_deleted=0) |
|
| 259 | + function create_list_query($order_by, $where, $show_deleted = 0) |
|
| 260 | 260 | { |
| 261 | 261 | $custom_join = $this->getCustomJoin(); |
| 262 | 262 | $query = "SELECT "; |
| 263 | 263 | $query .= " |
| 264 | 264 | calls.*,"; |
| 265 | - if ( preg_match("/calls_users\.user_id/",$where)) |
|
| 265 | + if (preg_match("/calls_users\.user_id/", $where)) |
|
| 266 | 266 | { |
| 267 | 267 | $query .= "calls_users.required, |
| 268 | 268 | calls_users.accept_status,"; |
@@ -274,19 +274,19 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | // this line will help generate a GMT-metric to compare to a locale's timezone |
| 276 | 276 | |
| 277 | - if ( preg_match("/contacts/",$where)){ |
|
| 277 | + if (preg_match("/contacts/", $where)) { |
|
| 278 | 278 | $query .= ", contacts.first_name, contacts.last_name"; |
| 279 | 279 | $query .= ", contacts.assigned_user_id contact_name_owner"; |
| 280 | 280 | } |
| 281 | 281 | $query .= " FROM calls "; |
| 282 | 282 | |
| 283 | - if ( preg_match("/contacts/",$where)){ |
|
| 284 | - $query .= "LEFT JOIN calls_contacts |
|
| 283 | + if (preg_match("/contacts/", $where)) { |
|
| 284 | + $query .= "LEFT JOIN calls_contacts |
|
| 285 | 285 | ON calls.id=calls_contacts.call_id |
| 286 | 286 | LEFT JOIN contacts |
| 287 | 287 | ON calls_contacts.contact_id=contacts.id "; |
| 288 | 288 | } |
| 289 | - if ( preg_match('/calls_users\.user_id/',$where)) |
|
| 289 | + if (preg_match('/calls_users\.user_id/', $where)) |
|
| 290 | 290 | { |
| 291 | 291 | $query .= "LEFT JOIN calls_users |
| 292 | 292 | ON calls.id=calls_users.call_id and calls_users.deleted=0 "; |
@@ -296,15 +296,15 @@ discard block |
||
| 296 | 296 | ON calls.assigned_user_id=users.id "; |
| 297 | 297 | $query .= $custom_join['join']; |
| 298 | 298 | $where_auto = '1=1'; |
| 299 | - if($show_deleted == 0){ |
|
| 299 | + if ($show_deleted == 0) { |
|
| 300 | 300 | $where_auto = " $this->table_name.deleted=0 "; |
| 301 | - }else if($show_deleted == 1){ |
|
| 301 | + } else if ($show_deleted == 1) { |
|
| 302 | 302 | $where_auto = " $this->table_name.deleted=1 "; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | //$where_auto .= " GROUP BY calls.id"; |
| 306 | 306 | |
| 307 | - if($where != "") |
|
| 307 | + if ($where != "") |
|
| 308 | 308 | $query .= "where $where AND ".$where_auto; |
| 309 | 309 | else |
| 310 | 310 | $query .= "where ".$where_auto; |
@@ -313,17 +313,17 @@ discard block |
||
| 313 | 313 | if (empty($order_by)) { |
| 314 | 314 | $order_by = 'calls.name'; |
| 315 | 315 | } |
| 316 | - $query .= ' ORDER BY ' . $order_by; |
|
| 316 | + $query .= ' ORDER BY '.$order_by; |
|
| 317 | 317 | |
| 318 | 318 | return $query; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - function create_export_query($order_by, $where, $relate_link_join='') |
|
| 321 | + function create_export_query($order_by, $where, $relate_link_join = '') |
|
| 322 | 322 | { |
| 323 | 323 | $custom_join = $this->getCustomJoin(true, true, $where); |
| 324 | 324 | $custom_join['join'] .= $relate_link_join; |
| 325 | 325 | $contact_required = stristr($where, "contacts"); |
| 326 | - if($contact_required) |
|
| 326 | + if ($contact_required) |
|
| 327 | 327 | { |
| 328 | 328 | $query = "SELECT calls.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name "; |
| 329 | 329 | $query .= $custom_join['select']; |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $query .= $custom_join['join']; |
| 345 | 345 | |
| 346 | - if($where != "") |
|
| 346 | + if ($where != "") |
|
| 347 | 347 | $query .= "where $where AND ".$where_auto; |
| 348 | 348 | else |
| 349 | 349 | $query .= "where ".$where_auto; |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | if (empty($order_by)) { |
| 353 | 353 | $order_by = 'calls.name'; |
| 354 | 354 | } |
| 355 | - $query .= ' ORDER BY ' . $order_by; |
|
| 355 | + $query .= ' ORDER BY '.$order_by; |
|
| 356 | 356 | |
| 357 | 357 | return $query; |
| 358 | 358 | } |
@@ -368,12 +368,12 @@ discard block |
||
| 368 | 368 | if (!empty($this->contact_id)) { |
| 369 | 369 | $query = "SELECT first_name, last_name FROM contacts "; |
| 370 | 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: "); |
|
| 371 | + $result = $this->db->limitQuery($query, 0, 1, true, " Error filling in additional detail fields: "); |
|
| 372 | 372 | |
| 373 | 373 | // Get the contact name. |
| 374 | 374 | $row = $this->db->fetchByAssoc($result); |
| 375 | 375 | $GLOBALS['log']->info("additional call fields $query"); |
| 376 | - if($row != null) |
|
| 376 | + if ($row != null) |
|
| 377 | 377 | { |
| 378 | 378 | $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', ''); |
| 379 | 379 | $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name"); |
@@ -399,9 +399,9 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | global $app_list_strings; |
| 401 | 401 | $parent_types = $app_list_strings['record_type_display']; |
| 402 | - $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list'); |
|
| 403 | - foreach($disabled_parent_types as $disabled_parent_type){ |
|
| 404 | - if($disabled_parent_type != $this->parent_type){ |
|
| 402 | + $disabled_parent_types = ACLController::disabledModuleList($parent_types, false, 'list'); |
|
| 403 | + foreach ($disabled_parent_types as $disabled_parent_type) { |
|
| 404 | + if ($disabled_parent_type != $this->parent_type) { |
|
| 405 | 405 | unset($parent_types[$disabled_parent_type]); |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -412,9 +412,9 @@ discard block |
||
| 412 | 412 | $this->reminder_time = -1; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if ( empty($this->id) ) { |
|
| 415 | + if (empty($this->id)) { |
|
| 416 | 416 | $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
| 417 | - if ( isset($reminder_t) ) |
|
| 417 | + if (isset($reminder_t)) |
|
| 418 | 418 | $this->reminder_time = $reminder_t; |
| 419 | 419 | } |
| 420 | 420 | $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
@@ -422,9 +422,9 @@ discard block |
||
| 422 | 422 | if (empty($this->email_reminder_time)) { |
| 423 | 423 | $this->email_reminder_time = -1; |
| 424 | 424 | } |
| 425 | - if(empty($this->id)){ |
|
| 425 | + if (empty($this->id)) { |
|
| 426 | 426 | $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
| 427 | - if(isset($reminder_t)) |
|
| 427 | + if (isset($reminder_t)) |
|
| 428 | 428 | $this->email_reminder_time = $reminder_t; |
| 429 | 429 | } |
| 430 | 430 | $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | |
| 440 | - function get_list_view_data(){ |
|
| 440 | + function get_list_view_data() { |
|
| 441 | 441 | $call_fields = $this->get_list_view_array(); |
| 442 | 442 | global $app_list_strings, $focus, $action, $currentModule; |
| 443 | 443 | if (isset($focus->id)) $id = $focus->id; |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | if ($this->status == "Planned") { |
| 450 | 450 | //cn: added this if() to deal with sequential Closes in Meetings. this is a hack to a hack (formbase.php->handleRedirect) |
| 451 | - if(empty($action)) |
|
| 451 | + if (empty($action)) |
|
| 452 | 452 | $action = "index"; |
| 453 | 453 | |
| 454 | 454 | $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>"; |
| 455 | 455 | if ($this->ACLAccess('edit')) { |
| 456 | - $call_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline"," border='0'",null,null,'.gif',translate('LBL_CLOSEINLINE'))."</a>"; |
|
| 456 | + $call_fields['SET_COMPLETE'] = $setCompleteUrl.SugarThemeRegistry::current()->getImage("close_inline", " border='0'", null, null, '.gif', translate('LBL_CLOSEINLINE'))."</a>"; |
|
| 457 | 457 | } else { |
| 458 | 458 | $call_fields['SET_COMPLETE'] = ''; |
| 459 | 459 | } |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day")); |
| 464 | 464 | $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']); |
| 465 | 465 | $date_db = $timedate->to_db($mergeTime); |
| 466 | - if( $date_db < $today){ |
|
| 467 | - $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>"; |
|
| 468 | - }else if($date_db < $nextday){ |
|
| 466 | + if ($date_db < $today) { |
|
| 467 | + $call_fields['DATE_START'] = "<font class='overdueTask'>".$call_fields['DATE_START']."</font>"; |
|
| 468 | + } else if ($date_db < $nextday) { |
|
| 469 | 469 | $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>"; |
| 470 | - }else{ |
|
| 470 | + } else { |
|
| 471 | 471 | $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>"; |
| 472 | 472 | } |
| 473 | 473 | $this->fill_in_additional_detail_fields(); |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | if (!empty($this->contact_id)) { |
| 477 | 477 | // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs |
| 478 | 478 | $contact_temp = BeanFactory::getBean("Contacts", $this->contact_id); |
| 479 | - if(!empty($contact_temp)) { |
|
| 479 | + if (!empty($contact_temp)) { |
|
| 480 | 480 | $contact_temp->_create_proper_name_field(); |
| 481 | 481 | $this->contact_name = $contact_temp->full_name; |
| 482 | 482 | } |
@@ -485,8 +485,8 @@ discard block |
||
| 485 | 485 | $call_fields['CONTACT_ID'] = $this->contact_id; |
| 486 | 486 | $call_fields['CONTACT_NAME'] = $this->contact_name; |
| 487 | 487 | $call_fields['PARENT_NAME'] = $this->parent_name; |
| 488 | - $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true; |
|
| 489 | - $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true; |
|
| 488 | + $call_fields['REMINDER_CHECKED'] = $this->reminder_time == -1 ? false : true; |
|
| 489 | + $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time == -1 ? false : true; |
|
| 490 | 490 | |
| 491 | 491 | return $call_fields; |
| 492 | 492 | } |
@@ -499,17 +499,17 @@ discard block |
||
| 499 | 499 | global $timedate; |
| 500 | 500 | |
| 501 | 501 | // rrs: bug 42684 - passing a contact breaks this call |
| 502 | - $notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user; |
|
| 502 | + $notifyUser = ($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user; |
|
| 503 | 503 | |
| 504 | 504 | |
| 505 | 505 | // Assumes $call dates are in user format |
| 506 | 506 | $calldate = $timedate->fromDb($call->date_start); |
| 507 | 507 | $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser); |
| 508 | 508 | |
| 509 | - if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) { |
|
| 509 | + if (strtolower(get_class($call->current_notify_user)) == 'contact') { |
|
| 510 | 510 | $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
| 511 | 511 | '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id); |
| 512 | - } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) { |
|
| 512 | + } elseif (strtolower(get_class($call->current_notify_user)) == 'lead') { |
|
| 513 | 513 | $xtpl->assign("ACCEPT_URL", $sugar_config['site_url']. |
| 514 | 514 | '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id); |
| 515 | 515 | } else { |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | $xtpl->assign("CALL_STARTDATE", $xOffset); |
| 523 | 523 | $xtpl->assign("CALL_HOURS", $call->duration_hours); |
| 524 | 524 | $xtpl->assign("CALL_MINUTES", $call->duration_minutes); |
| 525 | - $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : "")); |
|
| 525 | + $xtpl->assign("CALL_STATUS", ((isset($call->status)) ? $app_list_strings['call_status_dom'][$call->status] : "")); |
|
| 526 | 526 | $xtpl->assign("CALL_DESCRIPTION", $call->description); |
| 527 | 527 | |
| 528 | 528 | return $xtpl; |
@@ -537,13 +537,13 @@ discard block |
||
| 537 | 537 | $result = $this->db->query($query, true); |
| 538 | 538 | $list = Array(); |
| 539 | 539 | |
| 540 | - while($row = $this->db->fetchByAssoc($result)) { |
|
| 540 | + while ($row = $this->db->fetchByAssoc($result)) { |
|
| 541 | 541 | $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one |
| 542 | 542 | $record = $template->retrieve($row['user_id']); |
| 543 | 543 | $template->required = $row['required']; |
| 544 | 544 | $template->accept_status = $row['accept_status']; |
| 545 | 545 | |
| 546 | - if($record != null) { |
|
| 546 | + if ($record != null) { |
|
| 547 | 547 | // this copies the object into the array |
| 548 | 548 | $list[] = $template; |
| 549 | 549 | } |
@@ -566,14 +566,14 @@ discard block |
||
| 566 | 566 | $list = Array(); |
| 567 | 567 | |
| 568 | 568 | |
| 569 | - while($row = $this->db->fetchByAssoc($result)) |
|
| 569 | + while ($row = $this->db->fetchByAssoc($result)) |
|
| 570 | 570 | { |
| 571 | 571 | $record = $template->retrieve($row['call_id']); |
| 572 | 572 | $template->required = $row['required']; |
| 573 | 573 | $template->accept_status = $row['accept_status']; |
| 574 | 574 | |
| 575 | 575 | |
| 576 | - if($record != null) |
|
| 576 | + if ($record != null) |
|
| 577 | 577 | { |
| 578 | 578 | // this copies the object into the array |
| 579 | 579 | $list[] = $template; |
@@ -584,56 +584,56 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | |
| 587 | - function set_accept_status(&$user,$status) |
|
| 587 | + function set_accept_status(&$user, $status) |
|
| 588 | 588 | { |
| 589 | - if ( $user->object_name == 'User') |
|
| 589 | + if ($user->object_name == 'User') |
|
| 590 | 590 | { |
| 591 | - $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id); |
|
| 591 | + $relate_values = array('user_id'=>$user->id, 'call_id'=>$this->id); |
|
| 592 | 592 | $data_values = array('accept_status'=>$status); |
| 593 | - $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values); |
|
| 593 | + $this->set_relationship($this->rel_users_table, $relate_values, true, true, $data_values); |
|
| 594 | 594 | global $current_user; |
| 595 | 595 | |
| 596 | - if ( $this->update_vcal ) |
|
| 596 | + if ($this->update_vcal) |
|
| 597 | 597 | { |
| 598 | 598 | vCal::cache_sugar_vcal($user); |
| 599 | 599 | } |
| 600 | 600 | } |
| 601 | - else if ( $user->object_name == 'Contact') |
|
| 601 | + else if ($user->object_name == 'Contact') |
|
| 602 | 602 | { |
| 603 | - $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id); |
|
| 603 | + $relate_values = array('contact_id'=>$user->id, 'call_id'=>$this->id); |
|
| 604 | 604 | $data_values = array('accept_status'=>$status); |
| 605 | - $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values); |
|
| 605 | + $this->set_relationship($this->rel_contacts_table, $relate_values, true, true, $data_values); |
|
| 606 | 606 | } |
| 607 | - else if ( $user->object_name == 'Lead') |
|
| 607 | + else if ($user->object_name == 'Lead') |
|
| 608 | 608 | { |
| 609 | - $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id); |
|
| 609 | + $relate_values = array('lead_id'=>$user->id, 'call_id'=>$this->id); |
|
| 610 | 610 | $data_values = array('accept_status'=>$status); |
| 611 | - $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values); |
|
| 611 | + $this->set_relationship($this->rel_leads_table, $relate_values, true, true, $data_values); |
|
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | |
| 616 | 616 | |
| 617 | 617 | function get_notification_recipients() { |
| 618 | - if($this->special_notification) { |
|
| 618 | + if ($this->special_notification) { |
|
| 619 | 619 | return parent::get_notification_recipients(); |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true)); |
| 623 | 623 | $list = array(); |
| 624 | - if(!is_array($this->contacts_arr)) { |
|
| 625 | - $this->contacts_arr = array(); |
|
| 624 | + if (!is_array($this->contacts_arr)) { |
|
| 625 | + $this->contacts_arr = array(); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - if(!is_array($this->users_arr)) { |
|
| 629 | - $this->users_arr = array(); |
|
| 628 | + if (!is_array($this->users_arr)) { |
|
| 629 | + $this->users_arr = array(); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - if(!is_array($this->leads_arr)) { |
|
| 633 | - $this->leads_arr = array(); |
|
| 632 | + if (!is_array($this->leads_arr)) { |
|
| 633 | + $this->leads_arr = array(); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - foreach($this->users_arr as $user_id) { |
|
| 636 | + foreach ($this->users_arr as $user_id) { |
|
| 637 | 637 | $notify_user = new User(); |
| 638 | 638 | $notify_user->retrieve($user_id); |
| 639 | 639 | $notify_user->new_assigned_user_name = $notify_user->full_name; |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | $list[$notify_user->id] = $notify_user; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - foreach($this->contacts_arr as $contact_id) { |
|
| 644 | + foreach ($this->contacts_arr as $contact_id) { |
|
| 645 | 645 | $notify_user = new Contact(); |
| 646 | 646 | $notify_user->retrieve($contact_id); |
| 647 | 647 | $notify_user->new_assigned_user_name = $notify_user->full_name; |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | $list[$notify_user->id] = $notify_user; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - foreach($this->leads_arr as $lead_id) { |
|
| 652 | + foreach ($this->leads_arr as $lead_id) { |
|
| 653 | 653 | $notify_user = new Lead(); |
| 654 | 654 | $notify_user->retrieve($lead_id); |
| 655 | 655 | $notify_user->new_assigned_user_name = $notify_user->full_name; |
@@ -657,38 +657,38 @@ discard block |
||
| 657 | 657 | $list[$notify_user->id] = $notify_user; |
| 658 | 658 | } |
| 659 | 659 | global $sugar_config; |
| 660 | - if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
|
| 660 | + if (isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
|
| 661 | 661 | global $current_user; |
| 662 | - if(isset($list[$current_user->id])) |
|
| 662 | + if (isset($list[$current_user->id])) |
|
| 663 | 663 | unset($list[$current_user->id]); |
| 664 | 664 | } |
| 665 | 665 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true)); |
| 666 | 666 | return $list; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - function bean_implements($interface){ |
|
| 670 | - switch($interface){ |
|
| 669 | + function bean_implements($interface) { |
|
| 670 | + switch ($interface) { |
|
| 671 | 671 | case 'ACL':return true; |
| 672 | 672 | } |
| 673 | 673 | return false; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | - function listviewACLHelper(){ |
|
| 676 | + function listviewACLHelper() { |
|
| 677 | 677 | $array_assign = parent::listviewACLHelper(); |
| 678 | 678 | $is_owner = false; |
| 679 | 679 | $in_group = false; //SECURITY GROUPS |
| 680 | - if(!empty($this->parent_name)){ |
|
| 680 | + if (!empty($this->parent_name)) { |
|
| 681 | 681 | |
| 682 | - if(!empty($this->parent_name_owner)){ |
|
| 682 | + if (!empty($this->parent_name_owner)) { |
|
| 683 | 683 | global $current_user; |
| 684 | 684 | $is_owner = $current_user->id == $this->parent_name_owner; |
| 685 | 685 | } |
| 686 | 686 | /* BEGIN - SECURITY GROUPS */ |
| 687 | 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)) { |
|
| 688 | + else if (!empty($this->parent_type) && !empty($this->parent_id)) { |
|
| 689 | 689 | global $current_user; |
| 690 | - $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id); |
|
| 691 | - if($parent_bean !== false) { |
|
| 690 | + $parent_bean = BeanFactory::getBean($this->parent_type, $this->parent_id); |
|
| 691 | + if ($parent_bean !== false) { |
|
| 692 | 692 | $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
| 693 | 693 | } |
| 694 | 694 | } |
@@ -701,17 +701,17 @@ discard block |
||
| 701 | 701 | /** |
| 702 | 702 | if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){ |
| 703 | 703 | */ |
| 704 | - if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
|
| 704 | + if (!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)) { |
|
| 705 | 705 | /* END - SECURITY GROUPS */ |
| 706 | 706 | $array_assign['PARENT'] = 'a'; |
| 707 | - }else{ |
|
| 707 | + } else { |
|
| 708 | 708 | $array_assign['PARENT'] = 'span'; |
| 709 | 709 | } |
| 710 | 710 | $is_owner = false; |
| 711 | 711 | $in_group = false; //SECURITY GROUPS |
| 712 | - if(!empty($this->contact_name)){ |
|
| 712 | + if (!empty($this->contact_name)) { |
|
| 713 | 713 | |
| 714 | - if(!empty($this->contact_name_owner)){ |
|
| 714 | + if (!empty($this->contact_name_owner)) { |
|
| 715 | 715 | global $current_user; |
| 716 | 716 | $is_owner = $current_user->id == $this->contact_name_owner; |
| 717 | 717 | } |
@@ -719,8 +719,8 @@ discard block |
||
| 719 | 719 | //contact_name_owner not being set for whatever reason so we need to figure this out |
| 720 | 720 | else { |
| 721 | 721 | global $current_user; |
| 722 | - $parent_bean = BeanFactory::getBean('Contacts',$this->contact_id); |
|
| 723 | - if($parent_bean !== false) { |
|
| 722 | + $parent_bean = BeanFactory::getBean('Contacts', $this->contact_id); |
|
| 723 | + if ($parent_bean !== false) { |
|
| 724 | 724 | $is_owner = $current_user->id == $parent_bean->assigned_user_id; |
| 725 | 725 | } |
| 726 | 726 | } |
@@ -732,10 +732,10 @@ discard block |
||
| 732 | 732 | /** |
| 733 | 733 | if( ACLController::checkAccess('Contacts', 'view', $is_owner)){ |
| 734 | 734 | */ |
| 735 | - if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){ |
|
| 735 | + if (ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) { |
|
| 736 | 736 | /* END - SECURITY GROUPS */ |
| 737 | 737 | $array_assign['CONTACT'] = 'a'; |
| 738 | - }else{ |
|
| 738 | + } else { |
|
| 739 | 739 | $array_assign['CONTACT'] = 'span'; |
| 740 | 740 | } |
| 741 | 741 | |
@@ -743,13 +743,13 @@ discard block |
||
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | function save_relationship_changes($is_update, $exclude = array()) { |
| 746 | - if(empty($this->in_workflow)) |
|
| 746 | + if (empty($this->in_workflow)) |
|
| 747 | 747 | { |
| 748 | - if(empty($this->in_import)) |
|
| 748 | + if (empty($this->in_import)) |
|
| 749 | 749 | { |
| 750 | 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 | 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 | - if(!empty($GLOBALS['soap_server_object'])) |
|
| 752 | + if (!empty($GLOBALS['soap_server_object'])) |
|
| 753 | 753 | { |
| 754 | 754 | $exclude = array('lead_id', 'contact_id', 'user_id'); |
| 755 | 755 | } |
@@ -1,5 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -134,8 +136,9 @@ discard block |
||
| 134 | 136 | |
| 135 | 137 | |
| 136 | 138 | |
| 137 | - if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) |
|
| 138 | - $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
|
| 139 | + if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) { |
|
| 140 | + $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals']; |
|
| 141 | + } |
|
| 139 | 142 | } |
| 140 | 143 | |
| 141 | 144 | /** |
@@ -145,8 +148,7 @@ discard block |
||
| 145 | 148 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 146 | 149 | if(isset($GLOBALS['log'])) { |
| 147 | 150 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 148 | - } |
|
| 149 | - else { |
|
| 151 | + } else { |
|
| 150 | 152 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 151 | 153 | } |
| 152 | 154 | self::__construct(); |
@@ -298,16 +300,17 @@ discard block |
||
| 298 | 300 | $where_auto = '1=1'; |
| 299 | 301 | if($show_deleted == 0){ |
| 300 | 302 | $where_auto = " $this->table_name.deleted=0 "; |
| 301 | - }else if($show_deleted == 1){ |
|
| 303 | + } else if($show_deleted == 1){ |
|
| 302 | 304 | $where_auto = " $this->table_name.deleted=1 "; |
| 303 | 305 | } |
| 304 | 306 | |
| 305 | 307 | //$where_auto .= " GROUP BY calls.id"; |
| 306 | 308 | |
| 307 | - if($where != "") |
|
| 308 | - $query .= "where $where AND ".$where_auto; |
|
| 309 | - else |
|
| 310 | - $query .= "where ".$where_auto; |
|
| 309 | + if($where != "") { |
|
| 310 | + $query .= "where $where AND ".$where_auto; |
|
| 311 | + } else { |
|
| 312 | + $query .= "where ".$where_auto; |
|
| 313 | + } |
|
| 311 | 314 | |
| 312 | 315 | $order_by = $this->process_order_by($order_by); |
| 313 | 316 | if (empty($order_by)) { |
@@ -329,8 +332,7 @@ discard block |
||
| 329 | 332 | $query .= $custom_join['select']; |
| 330 | 333 | $query .= " FROM contacts, calls, calls_contacts "; |
| 331 | 334 | $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 |
|
| 335 | + } else |
|
| 334 | 336 | { |
| 335 | 337 | $query = 'SELECT calls.*, users.user_name as assigned_user_name '; |
| 336 | 338 | $query .= $custom_join['select']; |
@@ -343,10 +345,11 @@ discard block |
||
| 343 | 345 | |
| 344 | 346 | $query .= $custom_join['join']; |
| 345 | 347 | |
| 346 | - if($where != "") |
|
| 347 | - $query .= "where $where AND ".$where_auto; |
|
| 348 | - else |
|
| 349 | - $query .= "where ".$where_auto; |
|
| 348 | + if($where != "") { |
|
| 349 | + $query .= "where $where AND ".$where_auto; |
|
| 350 | + } else { |
|
| 351 | + $query .= "where ".$where_auto; |
|
| 352 | + } |
|
| 350 | 353 | |
| 351 | 354 | $order_by = $this->process_order_by($order_by); |
| 352 | 355 | if (empty($order_by)) { |
@@ -390,10 +393,12 @@ discard block |
||
| 390 | 393 | $this->date_start = $timedate->now(); |
| 391 | 394 | } |
| 392 | 395 | |
| 393 | - if (is_null($this->duration_hours)) |
|
| 394 | - $this->duration_hours = "0"; |
|
| 395 | - if (is_null($this->duration_minutes)) |
|
| 396 | - $this->duration_minutes = "1"; |
|
| 396 | + if (is_null($this->duration_hours)) { |
|
| 397 | + $this->duration_hours = "0"; |
|
| 398 | + } |
|
| 399 | + if (is_null($this->duration_minutes)) { |
|
| 400 | + $this->duration_minutes = "1"; |
|
| 401 | + } |
|
| 397 | 402 | |
| 398 | 403 | $this->fill_in_additional_parent_fields(); |
| 399 | 404 | |
@@ -414,8 +419,9 @@ discard block |
||
| 414 | 419 | |
| 415 | 420 | if ( empty($this->id) ) { |
| 416 | 421 | $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time'); |
| 417 | - if ( isset($reminder_t) ) |
|
| 418 | - $this->reminder_time = $reminder_t; |
|
| 422 | + if ( isset($reminder_t) ) { |
|
| 423 | + $this->reminder_time = $reminder_t; |
|
| 424 | + } |
|
| 419 | 425 | } |
| 420 | 426 | $this->reminder_checked = $this->reminder_time == -1 ? false : true; |
| 421 | 427 | |
@@ -424,8 +430,9 @@ discard block |
||
| 424 | 430 | } |
| 425 | 431 | if(empty($this->id)){ |
| 426 | 432 | $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time'); |
| 427 | - if(isset($reminder_t)) |
|
| 428 | - $this->email_reminder_time = $reminder_t; |
|
| 433 | + if(isset($reminder_t)) { |
|
| 434 | + $this->email_reminder_time = $reminder_t; |
|
| 435 | + } |
|
| 429 | 436 | } |
| 430 | 437 | $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true; |
| 431 | 438 | |
@@ -440,16 +447,20 @@ discard block |
||
| 440 | 447 | function get_list_view_data(){ |
| 441 | 448 | $call_fields = $this->get_list_view_array(); |
| 442 | 449 | global $app_list_strings, $focus, $action, $currentModule; |
| 443 | - if (isset($focus->id)) $id = $focus->id; |
|
| 444 | - else $id = ''; |
|
| 450 | + if (isset($focus->id)) { |
|
| 451 | + $id = $focus->id; |
|
| 452 | + } else { |
|
| 453 | + $id = ''; |
|
| 454 | + } |
|
| 445 | 455 | if (isset($this->parent_type) && $this->parent_type != null) |
| 446 | 456 | { |
| 447 | 457 | $call_fields['PARENT_MODULE'] = $this->parent_type; |
| 448 | 458 | } |
| 449 | 459 | if ($this->status == "Planned") { |
| 450 | 460 | //cn: added this if() to deal with sequential Closes in Meetings. this is a hack to a hack (formbase.php->handleRedirect) |
| 451 | - if(empty($action)) |
|
| 452 | - $action = "index"; |
|
| 461 | + if(empty($action)) { |
|
| 462 | + $action = "index"; |
|
| 463 | + } |
|
| 453 | 464 | |
| 454 | 465 | $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>"; |
| 455 | 466 | if ($this->ACLAccess('edit')) { |
@@ -465,9 +476,9 @@ discard block |
||
| 465 | 476 | $date_db = $timedate->to_db($mergeTime); |
| 466 | 477 | if( $date_db < $today){ |
| 467 | 478 | $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>"; |
| 468 | - }else if($date_db < $nextday){ |
|
| 479 | + } else if($date_db < $nextday){ |
|
| 469 | 480 | $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>"; |
| 470 | - }else{ |
|
| 481 | + } else{ |
|
| 471 | 482 | $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>"; |
| 472 | 483 | } |
| 473 | 484 | $this->fill_in_additional_detail_fields(); |
@@ -597,14 +608,12 @@ discard block |
||
| 597 | 608 | { |
| 598 | 609 | vCal::cache_sugar_vcal($user); |
| 599 | 610 | } |
| 600 | - } |
|
| 601 | - else if ( $user->object_name == 'Contact') |
|
| 611 | + } else if ( $user->object_name == 'Contact') |
|
| 602 | 612 | { |
| 603 | 613 | $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id); |
| 604 | 614 | $data_values = array('accept_status'=>$status); |
| 605 | 615 | $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values); |
| 606 | - } |
|
| 607 | - else if ( $user->object_name == 'Lead') |
|
| 616 | + } else if ( $user->object_name == 'Lead') |
|
| 608 | 617 | { |
| 609 | 618 | $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id); |
| 610 | 619 | $data_values = array('accept_status'=>$status); |
@@ -659,8 +668,9 @@ discard block |
||
| 659 | 668 | global $sugar_config; |
| 660 | 669 | if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) { |
| 661 | 670 | global $current_user; |
| 662 | - if(isset($list[$current_user->id])) |
|
| 663 | - unset($list[$current_user->id]); |
|
| 671 | + if(isset($list[$current_user->id])) { |
|
| 672 | + unset($list[$current_user->id]); |
|
| 673 | + } |
|
| 664 | 674 | } |
| 665 | 675 | // $GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true)); |
| 666 | 676 | return $list; |
@@ -704,7 +714,7 @@ discard block |
||
| 704 | 714 | if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){ |
| 705 | 715 | /* END - SECURITY GROUPS */ |
| 706 | 716 | $array_assign['PARENT'] = 'a'; |
| 707 | - }else{ |
|
| 717 | + } else{ |
|
| 708 | 718 | $array_assign['PARENT'] = 'span'; |
| 709 | 719 | } |
| 710 | 720 | $is_owner = false; |
@@ -735,7 +745,7 @@ discard block |
||
| 735 | 745 | if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){ |
| 736 | 746 | /* END - SECURITY GROUPS */ |
| 737 | 747 | $array_assign['CONTACT'] = 'a'; |
| 738 | - }else{ |
|
| 748 | + } else{ |
|
| 739 | 749 | $array_assign['CONTACT'] = 'span'; |
| 740 | 750 | } |
| 741 | 751 | |
@@ -752,13 +762,11 @@ discard block |
||
| 752 | 762 | if(!empty($GLOBALS['soap_server_object'])) |
| 753 | 763 | { |
| 754 | 764 | $exclude = array('lead_id', 'contact_id', 'user_id'); |
| 755 | - } |
|
| 756 | - else |
|
| 765 | + } else |
|
| 757 | 766 | { |
| 758 | 767 | $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id'); |
| 759 | 768 | } |
| 760 | - } |
|
| 761 | - else |
|
| 769 | + } else |
|
| 762 | 770 | { |
| 763 | 771 | $exclude = array('user_id'); |
| 764 | 772 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | var $table_name = 'aop_case_updates'; |
| 37 | 37 | var $tracker_visibility = false; |
| 38 | 38 | var $importable = false; |
| 39 | - var $disable_row_level_security = true ; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO |
|
| 39 | + var $disable_row_level_security = true; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO |
|
| 40 | 40 | var $id; |
| 41 | 41 | var $name; |
| 42 | 42 | var $date_entered; |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | var $assigned_user_name; |
| 54 | 54 | var $assigned_user_link; |
| 55 | 55 | |
| 56 | - public function __construct(){ |
|
| 56 | + public function __construct() { |
|
| 57 | 57 | parent::__construct(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @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 |
| 62 | 62 | */ |
| 63 | - public function AOP_Case_Updates_sugar(){ |
|
| 63 | + public function AOP_Case_Updates_sugar() { |
|
| 64 | 64 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 65 | - if(isset($GLOBALS['log'])) { |
|
| 65 | + if (isset($GLOBALS['log'])) { |
|
| 66 | 66 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 67 | 67 | } |
| 68 | 68 | else { |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
| 75 | - function bean_implements($interface){ |
|
| 76 | - switch($interface){ |
|
| 75 | + function bean_implements($interface) { |
|
| 76 | + switch ($interface) { |
|
| 77 | 77 | case 'ACL': return true; |
| 78 | 78 | } |
| 79 | 79 | return false; |
@@ -23,8 +23,7 @@ |
||
| 23 | 23 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 24 | 24 | if(isset($GLOBALS['log'])) { |
| 25 | 25 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 26 | - } |
|
| 27 | - else { |
|
| 26 | + } else { |
|
| 28 | 27 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 29 | 28 | } |
| 30 | 29 | self::__construct($seed, $module, $subPanel, $options); |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | require_once 'include/clean.php'; |
| 31 | 31 | class AOP_Case_Updates extends AOP_Case_Updates_sugar { |
| 32 | 32 | |
| 33 | - public function __construct(){ |
|
| 33 | + public function __construct() { |
|
| 34 | 34 | parent::__construct(); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @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 |
| 39 | 39 | */ |
| 40 | - public function AOP_Case_Updates(){ |
|
| 40 | + public function AOP_Case_Updates() { |
|
| 41 | 41 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 42 | - if(isset($GLOBALS['log'])) { |
|
| 42 | + if (isset($GLOBALS['log'])) { |
|
| 43 | 43 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 44 | 44 | } |
| 45 | 45 | else { |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - function save($check_notify = false){ |
|
| 52 | + function save($check_notify = false) { |
|
| 53 | 53 | $this->name = SugarCleaner::cleanHtml($this->name); |
| 54 | 54 | $this->description = SugarCleaner::cleanHtml($this->description); |
| 55 | 55 | parent::save($check_notify); |
| 56 | - if(file_exists('custom/modules/AOP_Case_Updates/CaseUpdatesHook.php')){ |
|
| 56 | + if (file_exists('custom/modules/AOP_Case_Updates/CaseUpdatesHook.php')) { |
|
| 57 | 57 | require_once 'custom/modules/AOP_Case_Updates/CaseUpdatesHook.php'; |
| 58 | - }else{ |
|
| 58 | + } else { |
|
| 59 | 59 | require_once 'modules/AOP_Case_Updates/CaseUpdatesHook.php'; |
| 60 | 60 | } |
| 61 | - if(class_exists('CustomCaseUpdatesHook')){ |
|
| 61 | + if (class_exists('CustomCaseUpdatesHook')) { |
|
| 62 | 62 | $hook = new CustomCaseUpdatesHook(); |
| 63 | - }else{ |
|
| 63 | + } else { |
|
| 64 | 64 | $hook = new CaseUpdatesHook(); |
| 65 | 65 | } |
| 66 | 66 | $hook->sendCaseUpdate($this); |
@@ -70,68 +70,68 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * @return aCase |
| 72 | 72 | */ |
| 73 | - public function getCase(){ |
|
| 74 | - $case = BeanFactory::getBean("Cases",$this->case_id); |
|
| 73 | + public function getCase() { |
|
| 74 | + $case = BeanFactory::getBean("Cases", $this->case_id); |
|
| 75 | 75 | return $case; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function getContacts(){ |
|
| 78 | + public function getContacts() { |
|
| 79 | 79 | $case = $this->getCase(); |
| 80 | - if($case){ |
|
| 81 | - return $case->get_linked_beans("contacts","Contacts"); |
|
| 80 | + if ($case) { |
|
| 81 | + return $case->get_linked_beans("contacts", "Contacts"); |
|
| 82 | 82 | } |
| 83 | 83 | return null; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function getUpdateContact(){ |
|
| 87 | - if($this->contact_id){ |
|
| 88 | - return BeanFactory::getBean("Contacts",$this->contact_id); |
|
| 86 | + public function getUpdateContact() { |
|
| 87 | + if ($this->contact_id) { |
|
| 88 | + return BeanFactory::getBean("Contacts", $this->contact_id); |
|
| 89 | 89 | } |
| 90 | 90 | return null; |
| 91 | 91 | } |
| 92 | - public function getUser(){ |
|
| 93 | - $user = BeanFactory::getBean('Users',$this->getCase()->assigned_user_id); |
|
| 92 | + public function getUser() { |
|
| 93 | + $user = BeanFactory::getBean('Users', $this->getCase()->assigned_user_id); |
|
| 94 | 94 | return $user; |
| 95 | 95 | } |
| 96 | - public function getUpdateUser(){ |
|
| 97 | - $user = BeanFactory::getBean('Users',$this->assigned_user_id); |
|
| 96 | + public function getUpdateUser() { |
|
| 97 | + $user = BeanFactory::getBean('Users', $this->assigned_user_id); |
|
| 98 | 98 | return $user; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function getEmailForUser(){ |
|
| 101 | + public function getEmailForUser() { |
|
| 102 | 102 | $user = $this->getUser(); |
| 103 | - if($user){ |
|
| 103 | + if ($user) { |
|
| 104 | 104 | return array($user->emailAddress->getPrimaryAddress($user)); |
| 105 | 105 | } |
| 106 | 106 | return array(); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - private function populateTemplate(EmailTemplate $template, $addDelimiter = true, $contactId = null){ |
|
| 109 | + private function populateTemplate(EmailTemplate $template, $addDelimiter = true, $contactId = null) { |
|
| 110 | 110 | global $app_strings, $sugar_config; |
| 111 | 111 | //Order of beans seems to matter here so we place contact first. |
| 112 | 112 | $userId = ''; |
| 113 | 113 | $user = $this->getUpdateUser(); |
| 114 | - if(!$user){ |
|
| 114 | + if (!$user) { |
|
| 115 | 115 | $this->getUser(); |
| 116 | 116 | } |
| 117 | - $beans = array("Contacts" => $contactId,"Cases" => $this->getCase()->id, "Users" => $user->id, "AOP_Case_Updates" => $this->id); |
|
| 117 | + $beans = array("Contacts" => $contactId, "Cases" => $this->getCase()->id, "Users" => $user->id, "AOP_Case_Updates" => $this->id); |
|
| 118 | 118 | $ret = array(); |
| 119 | - $ret['subject'] = from_html(aop_parse_template($template->subject,$beans)); |
|
| 120 | - $body = aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body_html),$beans); |
|
| 121 | - $bodyAlt = aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body),$beans); |
|
| 122 | - if($addDelimiter){ |
|
| 123 | - $body = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'] . $body; |
|
| 124 | - $bodyAlt = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'] . $bodyAlt; |
|
| 119 | + $ret['subject'] = from_html(aop_parse_template($template->subject, $beans)); |
|
| 120 | + $body = aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body_html), $beans); |
|
| 121 | + $bodyAlt = aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body), $beans); |
|
| 122 | + if ($addDelimiter) { |
|
| 123 | + $body = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].$body; |
|
| 124 | + $bodyAlt = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].$bodyAlt; |
|
| 125 | 125 | } |
| 126 | 126 | $ret['body'] = from_html($body); |
| 127 | 127 | $ret['body_alt'] = strip_tags(from_html($bodyAlt)); |
| 128 | 128 | return $ret; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null){ |
|
| 131 | + public function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null) { |
|
| 132 | 132 | $GLOBALS['log']->info("AOPCaseUpdates: sendEmail called"); |
| 133 | 133 | require_once("include/SugarPHPMailer.php"); |
| 134 | - $mailer=new SugarPHPMailer(); |
|
| 134 | + $mailer = new SugarPHPMailer(); |
|
| 135 | 135 | $admin = new Administration(); |
| 136 | 136 | $admin->retrieveSettings(); |
| 137 | 137 | |
@@ -139,35 +139,35 @@ discard block |
||
| 139 | 139 | $mailer->setMailerForSystem(); |
| 140 | 140 | |
| 141 | 141 | $signatureHTML = ""; |
| 142 | - if($signature && array_key_exists("signature_html",$signature)){ |
|
| 142 | + if ($signature && array_key_exists("signature_html", $signature)) { |
|
| 143 | 143 | $signatureHTML = from_html($signature['signature_html']); |
| 144 | 144 | } |
| 145 | 145 | $signaturePlain = ""; |
| 146 | - if($signature && array_key_exists("signature",$signature)){ |
|
| 146 | + if ($signature && array_key_exists("signature", $signature)) { |
|
| 147 | 147 | $signaturePlain = $signature['signature']; |
| 148 | 148 | } |
| 149 | 149 | $emailSettings = getPortalEmailSettings(); |
| 150 | 150 | $text = $this->populateTemplate($template, $addDelimiter, $contactId); |
| 151 | 151 | $mailer->Subject = $text['subject']; |
| 152 | - $mailer->Body = $text['body'] . $signatureHTML; |
|
| 152 | + $mailer->Body = $text['body'].$signatureHTML; |
|
| 153 | 153 | $mailer->IsHTML(true); |
| 154 | - $mailer->AltBody = $text['body_alt'] . $signaturePlain; |
|
| 154 | + $mailer->AltBody = $text['body_alt'].$signaturePlain; |
|
| 155 | 155 | $mailer->From = $emailSettings['from_address']; |
| 156 | 156 | $mailer->FromName = $emailSettings['from_name']; |
| 157 | - foreach($emails as $email){ |
|
| 157 | + foreach ($emails as $email) { |
|
| 158 | 158 | $mailer->AddAddress($email); |
| 159 | 159 | } |
| 160 | - if ($mailer->Send()){ |
|
| 160 | + if ($mailer->Send()) { |
|
| 161 | 161 | require_once('modules/Emails/Email.php'); |
| 162 | 162 | $emailObj = new Email(); |
| 163 | - $emailObj->to_addrs = implode(",",$emails); |
|
| 164 | - $emailObj->type= 'out'; |
|
| 163 | + $emailObj->to_addrs = implode(",", $emails); |
|
| 164 | + $emailObj->type = 'out'; |
|
| 165 | 165 | $emailObj->deleted = '0'; |
| 166 | 166 | $emailObj->name = $mailer->Subject; |
| 167 | 167 | $emailObj->description = $mailer->AltBody; |
| 168 | 168 | $emailObj->description_html = $mailer->Body; |
| 169 | 169 | $emailObj->from_addr = $mailer->From; |
| 170 | - if ( $caseId) { |
|
| 170 | + if ($caseId) { |
|
| 171 | 171 | $emailObj->parent_type = "Cases"; |
| 172 | 172 | $emailObj->parent_id = $caseId; |
| 173 | 173 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | $emailObj->created_by = '1'; |
| 177 | 177 | $emailObj->status = 'sent'; |
| 178 | 178 | $emailObj->save(); |
| 179 | - }else{ |
|
| 180 | - $GLOBALS['log']->info("AOPCaseUpdates: Could not send email: " . $mailer->ErrorInfo); |
|
| 179 | + } else { |
|
| 180 | + $GLOBALS['log']->info("AOPCaseUpdates: Could not send email: ".$mailer->ErrorInfo); |
|
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | return true; |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 42 | 42 | if(isset($GLOBALS['log'])) { |
| 43 | 43 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 44 | - } |
|
| 45 | - else { |
|
| 44 | + } else { |
|
| 46 | 45 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 47 | 46 | } |
| 48 | 47 | self::__construct(); |
@@ -55,12 +54,12 @@ discard block |
||
| 55 | 54 | parent::save($check_notify); |
| 56 | 55 | if(file_exists('custom/modules/AOP_Case_Updates/CaseUpdatesHook.php')){ |
| 57 | 56 | require_once 'custom/modules/AOP_Case_Updates/CaseUpdatesHook.php'; |
| 58 | - }else{ |
|
| 57 | + } else{ |
|
| 59 | 58 | require_once 'modules/AOP_Case_Updates/CaseUpdatesHook.php'; |
| 60 | 59 | } |
| 61 | 60 | if(class_exists('CustomCaseUpdatesHook')){ |
| 62 | 61 | $hook = new CustomCaseUpdatesHook(); |
| 63 | - }else{ |
|
| 62 | + } else{ |
|
| 64 | 63 | $hook = new CaseUpdatesHook(); |
| 65 | 64 | } |
| 66 | 65 | $hook->sendCaseUpdate($this); |
@@ -176,7 +175,7 @@ discard block |
||
| 176 | 175 | $emailObj->created_by = '1'; |
| 177 | 176 | $emailObj->status = 'sent'; |
| 178 | 177 | $emailObj->save(); |
| 179 | - }else{ |
|
| 178 | + } else{ |
|
| 180 | 179 | $GLOBALS['log']->info("AOPCaseUpdates: Could not send email: " . $mailer->ErrorInfo); |
| 181 | 180 | return false; |
| 182 | 181 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | var $object_name = 'AOR_Report'; |
| 29 | 29 | var $table_name = 'aor_reports'; |
| 30 | 30 | var $importable = true; |
| 31 | - var $disable_row_level_security = true ; |
|
| 31 | + var $disable_row_level_security = true; |
|
| 32 | 32 | |
| 33 | 33 | var $id; |
| 34 | 34 | var $name; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | var $assigned_user_link; |
| 48 | 48 | var $report_module; |
| 49 | 49 | |
| 50 | - function __construct(){ |
|
| 50 | + function __construct() { |
|
| 51 | 51 | parent::__construct(); |
| 52 | 52 | $this->load_report_beans(); |
| 53 | 53 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @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 |
| 59 | 59 | */ |
| 60 | - function AOR_Report(){ |
|
| 60 | + function AOR_Report() { |
|
| 61 | 61 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 62 | - if(isset($GLOBALS['log'])) { |
|
| 62 | + if (isset($GLOBALS['log'])) { |
|
| 63 | 63 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 64 | 64 | } |
| 65 | 65 | else { |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | - function bean_implements($interface){ |
|
| 73 | - switch($interface){ |
|
| 72 | + function bean_implements($interface) { |
|
| 73 | + switch ($interface) { |
|
| 74 | 74 | case 'ACL': return true; |
| 75 | 75 | } |
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - function save($check_notify = FALSE){ |
|
| 79 | + function save($check_notify = FALSE) { |
|
| 80 | 80 | |
| 81 | 81 | // TODO: process of saveing the fields and conditions is too long so we will have to make some optimization on save_lines functions |
| 82 | 82 | set_time_limit(3600); |
| 83 | 83 | |
| 84 | - if (empty($this->id)){ |
|
| 84 | + if (empty($this->id)) { |
|
| 85 | 85 | unset($_POST['aor_conditions_id']); |
| 86 | 86 | unset($_POST['aor_fields_id']); |
| 87 | 87 | } |
@@ -101,13 +101,13 @@ discard block |
||
| 101 | 101 | $chart->save_lines($_POST, $this, 'aor_chart_'); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - function load_report_beans(){ |
|
| 104 | + function load_report_beans() { |
|
| 105 | 105 | global $beanList, $app_list_strings; |
| 106 | 106 | |
| 107 | 107 | $app_list_strings['aor_moduleList'] = $app_list_strings['moduleList']; |
| 108 | 108 | |
| 109 | - foreach($app_list_strings['aor_moduleList'] as $mkey => $mvalue){ |
|
| 110 | - if(!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')){ |
|
| 109 | + foreach ($app_list_strings['aor_moduleList'] as $mkey => $mvalue) { |
|
| 110 | + if (!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')) { |
|
| 111 | 111 | unset($app_list_strings['aor_moduleList'][$mkey]); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | - function getReportFields(){ |
|
| 121 | + function getReportFields() { |
|
| 122 | 122 | $fields = array(); |
| 123 | - foreach($this->get_linked_beans('aor_fields','AOR_Fields') as $field){ |
|
| 123 | + foreach ($this->get_linked_beans('aor_fields', 'AOR_Fields') as $field) { |
|
| 124 | 124 | $fields[] = $field; |
| 125 | 125 | } |
| 126 | - usort($fields,function($a,$b){ |
|
| 126 | + usort($fields, function($a, $b) { |
|
| 127 | 127 | return $a->field_order - $b->field_order; |
| 128 | 128 | }); |
| 129 | 129 | return $fields; |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | const CHART_TYPE_RGRAPH = 'rgraph'; |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART){ |
|
| 137 | + function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART) { |
|
| 138 | 138 | global $beanList; |
| 139 | - $linkedCharts = $this->get_linked_beans('aor_charts','AOR_Charts'); |
|
| 140 | - if(!$linkedCharts){ |
|
| 139 | + $linkedCharts = $this->get_linked_beans('aor_charts', 'AOR_Charts'); |
|
| 140 | + if (!$linkedCharts) { |
|
| 141 | 141 | //No charts to display |
| 142 | 142 | return ''; |
| 143 | 143 | } |
@@ -161,16 +161,16 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | $field_module = $this->report_module; |
| 163 | 163 | $field_alias = $field_bean->table_name; |
| 164 | - if($path[0] != $this->report_module){ |
|
| 165 | - foreach($path as $rel){ |
|
| 166 | - if(empty($rel)){ |
|
| 164 | + if ($path[0] != $this->report_module) { |
|
| 165 | + foreach ($path as $rel) { |
|
| 166 | + if (empty($rel)) { |
|
| 167 | 167 | continue; |
| 168 | 168 | } |
| 169 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 170 | - $field_alias = $field_alias . ':'.$rel; |
|
| 169 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 170 | + $field_alias = $field_alias.':'.$rel; |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | - $label = str_replace(' ','_',$field->label).$i; |
|
| 173 | + $label = str_replace(' ', '_', $field->label).$i; |
|
| 174 | 174 | $fields[$label]['field'] = $field->field; |
| 175 | 175 | $fields[$label]['label'] = $field->label; |
| 176 | 176 | $fields[$label]['display'] = $field->display; |
@@ -185,10 +185,10 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | // get the main group |
| 187 | 187 | |
| 188 | - if($field->group_display) { |
|
| 188 | + if ($field->group_display) { |
|
| 189 | 189 | |
| 190 | 190 | // if we have a main group already thats wrong cause only one main grouping field possible |
| 191 | - if(!is_null($mainGroupField)) { |
|
| 191 | + if (!is_null($mainGroupField)) { |
|
| 192 | 192 | $GLOBALS['log']->fatal('main group already found'); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -203,18 +203,18 @@ discard block |
||
| 203 | 203 | $query = $this->build_report_query(); |
| 204 | 204 | $result = $this->db->query($query); |
| 205 | 205 | $data = array(); |
| 206 | - while($row = $this->db->fetchByAssoc($result, false)) |
|
| 206 | + while ($row = $this->db->fetchByAssoc($result, false)) |
|
| 207 | 207 | { |
| 208 | - foreach($fields as $name => $att){ |
|
| 208 | + foreach ($fields as $name => $att) { |
|
| 209 | 209 | |
| 210 | 210 | $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : ''; |
| 211 | 211 | |
| 212 | - switch ($att['function']){ |
|
| 212 | + switch ($att['function']) { |
|
| 213 | 213 | case 'COUNT': |
| 214 | 214 | break; |
| 215 | 215 | default: |
| 216 | - if(!is_numeric($row[$name])) { |
|
| 217 | - $row[$name] = trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id,$att['params']))); |
|
| 216 | + if (!is_numeric($row[$name])) { |
|
| 217 | + $row[$name] = trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id, $att['params']))); |
|
| 218 | 218 | |
| 219 | 219 | } |
| 220 | 220 | break; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | $fields = $this->getReportFields(); |
| 226 | 226 | |
| 227 | - switch($chartType) { |
|
| 227 | + switch ($chartType) { |
|
| 228 | 228 | case self::CHART_TYPE_PCHART: |
| 229 | 229 | $html = '<script src="modules/AOR_Charts/lib/pChart/imagemap.js"></script>'; |
| 230 | 230 | break; |
@@ -232,17 +232,17 @@ discard block |
||
| 232 | 232 | $html = '<script src="modules/AOR_Reports/js/Chart.js"></script>'; |
| 233 | 233 | break; |
| 234 | 234 | case self::CHART_TYPE_RGRAPH: |
| 235 | - if($_REQUEST['module']!= 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 235 | + if ($_REQUEST['module'] != 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 236 | 236 | require_once('include/SuiteGraphs/RGraphIncludes.php'); |
| 237 | 237 | |
| 238 | 238 | break; |
| 239 | 239 | } |
| 240 | 240 | $x = 0; |
| 241 | - foreach($linkedCharts as $chart){ |
|
| 242 | - if($chartIds !== null && !in_array($chart->id,$chartIds)){ |
|
| 241 | + foreach ($linkedCharts as $chart) { |
|
| 242 | + if ($chartIds !== null && !in_array($chart->id, $chartIds)) { |
|
| 243 | 243 | continue; |
| 244 | 244 | } |
| 245 | - $html .= $chart->buildChartHTML($data,$fields,$x, $chartType, $mainGroupField); |
|
| 245 | + $html .= $chart->buildChartHTML($data, $fields, $x, $chartType, $mainGroupField); |
|
| 246 | 246 | $x++; |
| 247 | 247 | } |
| 248 | 248 | return $html; |
@@ -254,12 +254,12 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | $rows = $this->getGroupDisplayFieldByReportId($this->id, $level); |
| 256 | 256 | |
| 257 | - if(count($rows) > 1) { |
|
| 258 | - $GLOBALS['log']->fatal('ambiguous group display for report ' . $this->id); |
|
| 257 | + if (count($rows) > 1) { |
|
| 258 | + $GLOBALS['log']->fatal('ambiguous group display for report '.$this->id); |
|
| 259 | 259 | } |
| 260 | - else if(count($rows) == 1){ |
|
| 260 | + else if (count($rows) == 1) { |
|
| 261 | 261 | $rows[0]['module_path'] = unserialize(base64_decode($rows[0]['module_path'])); |
| 262 | - if(!$rows[0]['module_path'][0]) { |
|
| 262 | + if (!$rows[0]['module_path'][0]) { |
|
| 263 | 263 | $module = new $beanList[$this->report_module](); |
| 264 | 264 | $rows[0]['field_id_name'] = $module->field_defs[$rows[0]['field']]['id_name'] ? $module->field_defs[$rows[0]['field']]['id_name'] : $module->field_defs[$rows[0]['field']]['name']; |
| 265 | 265 | $rows[0]['module_path'][0] = $module->table_name; |
@@ -269,23 +269,23 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | $path[] = $rows[0]; |
| 271 | 271 | |
| 272 | - if($level>10) { |
|
| 272 | + if ($level > 10) { |
|
| 273 | 273 | $msg = 'Too many nested groups'; |
| 274 | 274 | $GLOBALS['log']->fatal($msg); |
| 275 | 275 | return null; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - return $this->buildMultiGroupReport($offset, $links, $level+1, $path); |
|
| 278 | + return $this->buildMultiGroupReport($offset, $links, $level + 1, $path); |
|
| 279 | 279 | } |
| 280 | - else if(!$rows) { |
|
| 281 | - if($path) { |
|
| 280 | + else if (!$rows) { |
|
| 281 | + if ($path) { |
|
| 282 | 282 | $html = ''; |
| 283 | 283 | foreach ($path as $pth) { |
| 284 | 284 | $_fieldIdName = $this->db->quoteIdentifier($pth['field_id_name']); |
| 285 | - $query = "SELECT $_fieldIdName FROM " . $this->db->quoteIdentifier($pth['module_path'][0]) . " GROUP BY $_fieldIdName;"; |
|
| 285 | + $query = "SELECT $_fieldIdName FROM ".$this->db->quoteIdentifier($pth['module_path'][0])." GROUP BY $_fieldIdName;"; |
|
| 286 | 286 | $values = $this->dbSelect($query); |
| 287 | 287 | |
| 288 | - foreach($values as $value) { |
|
| 288 | + foreach ($values as $value) { |
|
| 289 | 289 | |
| 290 | 290 | //$where = [ $this->db->quote($pth['module_path'][0]) . '.' . $_fieldIdName . ' = \'' . $this->db->quote($value[$pth['field_id_name']]) . '\'' ]; |
| 291 | 291 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | // escape values for query |
| 322 | 322 | |
| 323 | 323 | $_id = $this->db->quote($reportId); |
| 324 | - $_level = (int) $level; |
|
| 324 | + $_level = (int)$level; |
|
| 325 | 325 | |
| 326 | 326 | // get results array |
| 327 | 327 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $results = $this->db->query($query); |
| 337 | 337 | |
| 338 | 338 | $rows = array(); |
| 339 | - while($row = $this->db->fetchByAssoc($results)) { |
|
| 339 | + while ($row = $this->db->fetchByAssoc($results)) { |
|
| 340 | 340 | $rows[] = $row; |
| 341 | 341 | } |
| 342 | 342 | |
@@ -345,20 +345,20 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | private function getMultiGroupFrameHTML($header, $body) { |
| 347 | 347 | $html = '<div class="multi-group-list" style="border: 1px solid black; padding: 10px;"> |
| 348 | - <h3>' . $header . '</h3> |
|
| 349 | - <div class="multi-group-list-inner">' . $body . '</div> |
|
| 348 | + <h3>' . $header.'</h3> |
|
| 349 | + <div class="multi-group-list-inner">' . $body.'</div> |
|
| 350 | 350 | </div>'; |
| 351 | 351 | return $html; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | private function addDataIdValueToInnertext($html) { |
| 355 | 355 | preg_match('/\sdata-id-value\s*=\s*"([^"]*)"/', $html, $match); |
| 356 | - $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2' . $match[1] . '$3', $html); |
|
| 356 | + $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2'.$match[1].'$3', $html); |
|
| 357 | 357 | return $html; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | |
| 361 | - function build_group_report($offset = -1, $links = true, $extra = array()){ |
|
| 361 | + function build_group_report($offset = -1, $links = true, $extra = array()) { |
|
| 362 | 362 | global $beanList; |
| 363 | 363 | |
| 364 | 364 | $html = ''; |
@@ -369,23 +369,23 @@ discard block |
||
| 369 | 369 | $sql = "SELECT id FROM aor_fields WHERE aor_report_id = '".$this->id."' AND group_display = 1 AND deleted = 0 ORDER BY field_order ASC"; |
| 370 | 370 | $field_id = $this->db->getOne($sql); |
| 371 | 371 | |
| 372 | - if(!$field_id) { |
|
| 373 | - $query_array['select'][] = $module->table_name . ".id AS '" . $module->table_name . "_id'"; |
|
| 372 | + if (!$field_id) { |
|
| 373 | + $query_array['select'][] = $module->table_name.".id AS '".$module->table_name."_id'"; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if($field_id != ''){ |
|
| 376 | + if ($field_id != '') { |
|
| 377 | 377 | $field = new AOR_Field(); |
| 378 | 378 | $field->retrieve($field_id); |
| 379 | 379 | |
| 380 | - $field_label = str_replace(' ','_',$field->label); |
|
| 380 | + $field_label = str_replace(' ', '_', $field->label); |
|
| 381 | 381 | |
| 382 | 382 | $path = unserialize(base64_decode($field->module_path)); |
| 383 | 383 | |
| 384 | 384 | $field_module = $module; |
| 385 | 385 | $table_alias = $field_module->table_name; |
| 386 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
| 387 | - foreach($path as $rel){ |
|
| 388 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)]; |
|
| 386 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
| 387 | + foreach ($path as $rel) { |
|
| 388 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)]; |
|
| 389 | 389 | $oldAlias = $table_alias; |
| 390 | 390 | $table_alias = $table_alias.":".$rel; |
| 391 | 391 | |
@@ -399,71 +399,71 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | $data = $field_module->field_defs[$field->field]; |
| 401 | 401 | |
| 402 | - if($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 402 | + if ($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 403 | 403 | $field->field = $data['id_name']; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - if($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) { |
|
| 407 | - if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 406 | + if ($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) { |
|
| 407 | + if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 408 | 408 | $query['select'][$table_alias.'_currency_id'] = $table_alias.'_cstm'.".currency_id AS '".$table_alias."_currency_id'"; |
| 409 | 409 | } else { |
| 410 | - $query_array['select'][$table_alias . '_currency_id'] = $table_alias . ".currency_id AS '" . $table_alias . "_currency_id'"; |
|
| 410 | + $query_array['select'][$table_alias.'_currency_id'] = $table_alias.".currency_id AS '".$table_alias."_currency_id'"; |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if( (isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 414 | + if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 415 | 415 | $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field; |
| 416 | 416 | // Fix for #1251 - added a missing parameter to the function call |
| 417 | 417 | $query_array = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $table_alias, $field_module, 'custom', $query); |
| 418 | 418 | } else { |
| 419 | - $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 419 | + $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - if($field->sort_by != ''){ |
|
| 422 | + if ($field->sort_by != '') { |
|
| 423 | 423 | $query_array['sort_by'][] = $field_label.' '.$field->sort_by; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if($field->group_by == 1){ |
|
| 426 | + if ($field->group_by == 1) { |
|
| 427 | 427 | $query_array['group_by'][] = $select_field; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - if($field->field_function != null){ |
|
| 430 | + if ($field->field_function != null) { |
|
| 431 | 431 | $select_field = $field->field_function.'('.$select_field.')'; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - $query_array['select'][] = $select_field ." AS '".$field_label."'"; |
|
| 435 | - if(isset($extra['select']) && $extra['select']) { |
|
| 436 | - foreach($extra['select'] as $selectField => $selectAlias) { |
|
| 437 | - if($selectAlias) { |
|
| 438 | - $query_array['select'][] = $selectField . " AS " . $selectAlias; |
|
| 434 | + $query_array['select'][] = $select_field." AS '".$field_label."'"; |
|
| 435 | + if (isset($extra['select']) && $extra['select']) { |
|
| 436 | + foreach ($extra['select'] as $selectField => $selectAlias) { |
|
| 437 | + if ($selectAlias) { |
|
| 438 | + $query_array['select'][] = $selectField." AS ".$selectAlias; |
|
| 439 | 439 | } |
| 440 | 440 | else { |
| 441 | 441 | $query_array['select'][] = $selectField; |
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | - $query_array['where'][] = $select_field ." IS NOT NULL AND "; |
|
| 446 | - if(isset($extra['where']) && $extra['where']) { |
|
| 447 | - $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND '; |
|
| 445 | + $query_array['where'][] = $select_field." IS NOT NULL AND "; |
|
| 446 | + if (isset($extra['where']) && $extra['where']) { |
|
| 447 | + $query_array['where'][] = implode(' AND ', $extra['where']).' AND '; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $query_array = $this->build_report_query_where($query_array); |
| 451 | 451 | |
| 452 | - foreach ($query_array['select'] as $select){ |
|
| 453 | - $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 452 | + foreach ($query_array['select'] as $select) { |
|
| 453 | + $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | $query .= ' FROM '.$module->table_name.' '; |
| 457 | 457 | |
| 458 | - if(isset($query_array['join'])){ |
|
| 459 | - foreach ($query_array['join'] as $join){ |
|
| 458 | + if (isset($query_array['join'])) { |
|
| 459 | + foreach ($query_array['join'] as $join) { |
|
| 460 | 460 | $query .= $join; |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | - if(isset($query_array['where'])){ |
|
| 463 | + if (isset($query_array['where'])) { |
|
| 464 | 464 | $query_where = ''; |
| 465 | - foreach ($query_array['where'] as $where){ |
|
| 466 | - $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 465 | + foreach ($query_array['where'] as $where) { |
|
| 466 | + $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | $query_where = $this->queryWhereRepair($query_where); |
@@ -471,41 +471,41 @@ discard block |
||
| 471 | 471 | $query .= ' '.$query_where; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if(isset($query_array['group_by'])){ |
|
| 474 | + if (isset($query_array['group_by'])) { |
|
| 475 | 475 | $query_group_by = ''; |
| 476 | - foreach ($query_array['group_by'] as $group_by){ |
|
| 477 | - $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 476 | + foreach ($query_array['group_by'] as $group_by) { |
|
| 477 | + $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 478 | 478 | } |
| 479 | 479 | $query .= ' '.$query_group_by; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - if(isset($query_array['sort_by'])){ |
|
| 482 | + if (isset($query_array['sort_by'])) { |
|
| 483 | 483 | $query_sort_by = ''; |
| 484 | - foreach ($query_array['sort_by'] as $sort_by){ |
|
| 485 | - $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 484 | + foreach ($query_array['sort_by'] as $sort_by) { |
|
| 485 | + $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 486 | 486 | } |
| 487 | 487 | $query .= ' '.$query_sort_by; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $query .= ' group by ' . $field_label; |
|
| 490 | + $query .= ' group by '.$field_label; |
|
| 491 | 491 | |
| 492 | 492 | $result = $this->db->query($query); |
| 493 | 493 | |
| 494 | 494 | while ($row = $this->db->fetchByAssoc($result)) { |
| 495 | - if($html != '') $html .= '<br />'; |
|
| 495 | + if ($html != '') $html .= '<br />'; |
|
| 496 | 496 | |
| 497 | 497 | $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
| 498 | 498 | |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if($html == '') $html = $this->build_report_html($offset, $links); |
|
| 502 | + if ($html == '') $html = $this->build_report_html($offset, $links); |
|
| 503 | 503 | return $html; |
| 504 | 504 | |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | |
| 508 | - function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()){ |
|
| 508 | + function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()) { |
|
| 509 | 509 | |
| 510 | 510 | global $beanList, $sugar_config; |
| 511 | 511 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | $report_sql = $this->build_report_query($_group_value, $extra); |
| 515 | 515 | |
| 516 | 516 | // Fix for issue 1232 - items listed in a single report, should adhere to the same standard as ListView items. |
| 517 | - if($sugar_config['list_max_entries_per_page']!='') { |
|
| 517 | + if ($sugar_config['list_max_entries_per_page'] != '') { |
|
| 518 | 518 | $max_rows = $sugar_config['list_max_entries_per_page']; |
| 519 | 519 | } else { |
| 520 | 520 | $max_rows = 20; |
@@ -527,22 +527,22 @@ discard block |
||
| 527 | 527 | // We have a count query. Run it and get the results. |
| 528 | 528 | $result = $this->db->query($count_query); |
| 529 | 529 | $assoc = $this->db->fetchByAssoc($result); |
| 530 | - if(!empty($assoc['c'])) |
|
| 530 | + if (!empty($assoc['c'])) |
|
| 531 | 531 | { |
| 532 | 532 | $total_rows = $assoc['c']; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | $html = "<table class='list' id='report_table".$group_value."' width='100%' cellspacing='0' cellpadding='0' border='0' repeat_header='1'>"; |
| 536 | 536 | |
| 537 | - if($offset >= 0){ |
|
| 537 | + if ($offset >= 0) { |
|
| 538 | 538 | $start = 0; |
| 539 | 539 | $end = 0; |
| 540 | 540 | $previous_offset = 0; |
| 541 | 541 | $next_offset = 0; |
| 542 | 542 | $last_offset = 0; |
| 543 | 543 | |
| 544 | - if($total_rows > 0){ |
|
| 545 | - $start = $offset +1; |
|
| 544 | + if ($total_rows > 0) { |
|
| 545 | + $start = $offset + 1; |
|
| 546 | 546 | $end = (($offset + $max_rows) < $total_rows) ? $offset + $max_rows : $total_rows; |
| 547 | 547 | $previous_offset = ($offset - $max_rows) < 0 ? 0 : $offset - $max_rows; |
| 548 | 548 | $next_offset = $offset + $max_rows; |
@@ -554,36 +554,36 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value); |
| 556 | 556 | |
| 557 | - $html .="<td colspan='18'> |
|
| 557 | + $html .= "<td colspan='18'> |
|
| 558 | 558 | <table class='paginationTable' border='0' cellpadding='0' cellspacing='0' width='100%'> |
| 559 | 559 | <td style='text-align:left' ><H3><a href=\"javascript:void(0)\" class=\"collapseLink\" onclick=\"groupedReportToggler.toggleList(this);\"><img border=\"0\" id=\"detailpanel_1_img_hide\" src=\"themes/SuiteR/images/basic_search.gif\"></a>$moduleFieldByGroupValue</H3></td> |
| 560 | 560 | <td class='paginationChangeButtons' align='right' nowrap='nowrap' width='1%'>"; |
| 561 | 561 | |
| 562 | - if($offset == 0){ |
|
| 563 | - $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'> |
|
| 562 | + if ($offset == 0) { |
|
| 563 | + $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'> |
|
| 564 | 564 | <img src='".SugarThemeRegistry::current()->getImageURL('start_off.gif')."' alt='Start' align='absmiddle' border='0'> |
| 565 | 565 | </button> |
| 566 | 566 | <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' disabled='disabled'> |
| 567 | 567 | <img src='".SugarThemeRegistry::current()->getImageURL('previous_off.gif')."' alt='Previous' align='absmiddle' border='0'> |
| 568 | 568 | </button>"; |
| 569 | 569 | } else { |
| 570 | - $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 570 | + $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 571 | 571 | <img src='".SugarThemeRegistry::current()->getImageURL('start.gif')."' alt='Start' align='absmiddle' border='0'> |
| 572 | 572 | </button> |
| 573 | 573 | <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' onclick='changeReportPage(\"".$this->id."\",".$previous_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
| 574 | 574 | <img src='".SugarThemeRegistry::current()->getImageURL('previous.gif')."' alt='Previous' align='absmiddle' border='0'> |
| 575 | 575 | </button>"; |
| 576 | 576 | } |
| 577 | - $html .=" <span class='pageNumbers'>(".$start ." - ".$end ." of ". $total_rows .")</span>"; |
|
| 578 | - if($next_offset < $total_rows){ |
|
| 579 | - $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 577 | + $html .= " <span class='pageNumbers'>(".$start." - ".$end." of ".$total_rows.")</span>"; |
|
| 578 | + if ($next_offset < $total_rows) { |
|
| 579 | + $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 580 | 580 | <img src='".SugarThemeRegistry::current()->getImageURL('next.gif')."' alt='Next' align='absmiddle' border='0'> |
| 581 | 581 | </button> |
| 582 | 582 | <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button' onclick='changeReportPage(\"".$this->id."\",".$last_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
| 583 | 583 | <img src='".SugarThemeRegistry::current()->getImageURL('end.gif')."' alt='End' align='absmiddle' border='0'> |
| 584 | 584 | </button>"; |
| 585 | 585 | } else { |
| 586 | - $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' disabled='disabled'> |
|
| 586 | + $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' disabled='disabled'> |
|
| 587 | 587 | <img src='".SugarThemeRegistry::current()->getImageURL('next_off.gif')."' alt='Next' align='absmiddle' border='0'> |
| 588 | 588 | </button> |
| 589 | 589 | <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button' disabled='disabled'> |
@@ -592,12 +592,12 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - $html .="</td> |
|
| 595 | + $html .= "</td> |
|
| 596 | 596 | </table> |
| 597 | 597 | </td>"; |
| 598 | 598 | |
| 599 | - $html .="</tr></thead>"; |
|
| 600 | - } else{ |
|
| 599 | + $html .= "</tr></thead>"; |
|
| 600 | + } else { |
|
| 601 | 601 | |
| 602 | 602 | $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value); |
| 603 | 603 | |
@@ -623,16 +623,16 @@ discard block |
||
| 623 | 623 | |
| 624 | 624 | $field_module = $this->report_module; |
| 625 | 625 | $field_alias = $field_bean->table_name; |
| 626 | - if($path[0] != $this->report_module){ |
|
| 627 | - foreach($path as $rel){ |
|
| 628 | - if(empty($rel)){ |
|
| 626 | + if ($path[0] != $this->report_module) { |
|
| 627 | + foreach ($path as $rel) { |
|
| 628 | + if (empty($rel)) { |
|
| 629 | 629 | continue; |
| 630 | 630 | } |
| 631 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 632 | - $field_alias = $field_alias . ':'.$rel; |
|
| 631 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 632 | + $field_alias = $field_alias.':'.$rel; |
|
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | - $label = str_replace(' ','_',$field->label).$i; |
|
| 635 | + $label = str_replace(' ', '_', $field->label).$i; |
|
| 636 | 636 | $fields[$label]['field'] = $field->field; |
| 637 | 637 | $fields[$label]['label'] = $field->label; |
| 638 | 638 | $fields[$label]['display'] = $field->display; |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | $fields[$label]['params'] = array("date_format" => $field->format); |
| 646 | 646 | |
| 647 | 647 | |
| 648 | - if($fields[$label]['display']){ |
|
| 648 | + if ($fields[$label]['display']) { |
|
| 649 | 649 | $html .= "<th scope='col'>"; |
| 650 | 650 | $html .= "<div style='white-space: normal;' width='100%' align='left'>"; |
| 651 | 651 | $html .= $field->label; |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | $html .= "</thead>"; |
| 659 | 659 | $html .= "<tbody>"; |
| 660 | 660 | |
| 661 | - if($offset >= 0){ |
|
| 661 | + if ($offset >= 0) { |
|
| 662 | 662 | $result = $this->db->limitQuery($report_sql, $offset, $max_rows); |
| 663 | 663 | } else { |
| 664 | 664 | $result = $this->db->query($report_sql); |
@@ -671,39 +671,39 @@ discard block |
||
| 671 | 671 | while ($row = $this->db->fetchByAssoc($result)) { |
| 672 | 672 | $html .= "<tr class='".$row_class."' height='20'>"; |
| 673 | 673 | |
| 674 | - foreach($fields as $name => $att){ |
|
| 675 | - if($att['display']){ |
|
| 674 | + foreach ($fields as $name => $att) { |
|
| 675 | + if ($att['display']) { |
|
| 676 | 676 | $html .= "<td class='' valign='top' align='left'>"; |
| 677 | - if($att['link'] && $links){ |
|
| 678 | - $html .= "<a href='" . $sugar_config['site_url'] . "/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>"; |
|
| 677 | + if ($att['link'] && $links) { |
|
| 678 | + $html .= "<a href='".$sugar_config['site_url']."/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>"; |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : ''; |
| 682 | 682 | |
| 683 | - switch ($att['function']){ |
|
| 683 | + switch ($att['function']) { |
|
| 684 | 684 | case 'COUNT': |
| 685 | 685 | //case 'SUM': |
| 686 | 686 | $html .= $row[$name]; |
| 687 | 687 | break; |
| 688 | 688 | default: |
| 689 | 689 | |
| 690 | - $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name],'',$currency_id, $att['params']); |
|
| 690 | + $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id, $att['params']); |
|
| 691 | 691 | break; |
| 692 | 692 | } |
| 693 | - if($att['total']){ |
|
| 693 | + if ($att['total']) { |
|
| 694 | 694 | $totals[$name][] = $row[$name]; |
| 695 | 695 | } |
| 696 | - if($att['link'] && $links) $html .= "</a>"; |
|
| 696 | + if ($att['link'] && $links) $html .= "</a>"; |
|
| 697 | 697 | $html .= "</td>"; |
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | $html .= "</tr>"; |
| 701 | 701 | |
| 702 | - $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1':'oddListRowS1'; |
|
| 702 | + $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1' : 'oddListRowS1'; |
|
| 703 | 703 | } |
| 704 | 704 | $html .= "</tbody>"; |
| 705 | 705 | |
| 706 | - $html .= $this->getTotalHtml($fields,$totals); |
|
| 706 | + $html .= $this->getTotalHtml($fields, $totals); |
|
| 707 | 707 | |
| 708 | 708 | $html .= "</table>"; |
| 709 | 709 | |
@@ -746,13 +746,13 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | $field_module = $this->report_module; |
| 748 | 748 | $field_alias = $field_bean->table_name; |
| 749 | - if($path[0] != $this->report_module){ |
|
| 750 | - foreach($path as $rel){ |
|
| 751 | - if(empty($rel)){ |
|
| 749 | + if ($path[0] != $this->report_module) { |
|
| 750 | + foreach ($path as $rel) { |
|
| 751 | + if (empty($rel)) { |
|
| 752 | 752 | continue; |
| 753 | 753 | } |
| 754 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 755 | - $field_alias = $field_alias . ':'.$rel; |
|
| 754 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 755 | + $field_alias = $field_alias.':'.$rel; |
|
| 756 | 756 | } |
| 757 | 757 | } |
| 758 | 758 | |
@@ -765,31 +765,31 @@ discard block |
||
| 765 | 765 | return $moduleFieldByGroupValue; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - function getTotalHTML($fields,$totals){ |
|
| 768 | + function getTotalHTML($fields, $totals) { |
|
| 769 | 769 | global $app_list_strings; |
| 770 | 770 | $html = ''; |
| 771 | 771 | $html .= "<tbody>"; |
| 772 | 772 | $html .= "<tr>"; |
| 773 | - foreach($fields as $label => $field){ |
|
| 774 | - if(!$field['display']){ |
|
| 773 | + foreach ($fields as $label => $field) { |
|
| 774 | + if (!$field['display']) { |
|
| 775 | 775 | continue; |
| 776 | 776 | } |
| 777 | - if($field['total']){ |
|
| 778 | - $totalLabel = $field['label'] ." ".$app_list_strings['aor_total_options'][$field['total']]; |
|
| 777 | + if ($field['total']) { |
|
| 778 | + $totalLabel = $field['label']." ".$app_list_strings['aor_total_options'][$field['total']]; |
|
| 779 | 779 | $html .= "<th>{$totalLabel}</th>"; |
| 780 | - }else{ |
|
| 780 | + } else { |
|
| 781 | 781 | $html .= "<th></th>"; |
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | $html .= "</tr>"; |
| 785 | 785 | $html .= "<tr>"; |
| 786 | - foreach($fields as $label => $field){ |
|
| 787 | - if(!$field['display']){ |
|
| 786 | + foreach ($fields as $label => $field) { |
|
| 787 | + if (!$field['display']) { |
|
| 788 | 788 | continue; |
| 789 | 789 | } |
| 790 | - if($field['total'] && isset($totals[$label])){ |
|
| 791 | - $html .= "<td>".$this->calculateTotal($field['total'],$totals[$label])."</td>"; |
|
| 792 | - }else{ |
|
| 790 | + if ($field['total'] && isset($totals[$label])) { |
|
| 791 | + $html .= "<td>".$this->calculateTotal($field['total'], $totals[$label])."</td>"; |
|
| 792 | + } else { |
|
| 793 | 793 | $html .= "<td></td>"; |
| 794 | 794 | } |
| 795 | 795 | } |
@@ -798,24 +798,24 @@ discard block |
||
| 798 | 798 | return $html; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - function calculateTotal($type, $totals){ |
|
| 802 | - switch($type){ |
|
| 801 | + function calculateTotal($type, $totals) { |
|
| 802 | + switch ($type) { |
|
| 803 | 803 | case 'SUM': |
| 804 | 804 | return array_sum($totals); |
| 805 | 805 | case 'COUNT': |
| 806 | 806 | return count($totals); |
| 807 | 807 | case 'AVG': |
| 808 | - return array_sum($totals)/count($totals); |
|
| 808 | + return array_sum($totals) / count($totals); |
|
| 809 | 809 | default: |
| 810 | 810 | return ''; |
| 811 | 811 | } |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - private function encloseForCSV($field){ |
|
| 814 | + private function encloseForCSV($field) { |
|
| 815 | 815 | return '"'.$field.'"'; |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - function build_report_csv(){ |
|
| 818 | + function build_report_csv() { |
|
| 819 | 819 | |
| 820 | 820 | ini_set('zlib.output_compression', 'Off'); |
| 821 | 821 | |
@@ -839,20 +839,20 @@ discard block |
||
| 839 | 839 | $path = unserialize(base64_decode($field->module_path)); |
| 840 | 840 | |
| 841 | 841 | $field_module = $this->report_module; |
| 842 | - if($path[0] != $this->report_module){ |
|
| 843 | - foreach($path as $rel){ |
|
| 844 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 842 | + if ($path[0] != $this->report_module) { |
|
| 843 | + foreach ($path as $rel) { |
|
| 844 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | - $label = str_replace(' ','_',$field->label).$i; |
|
| 847 | + $label = str_replace(' ', '_', $field->label).$i; |
|
| 848 | 848 | $fields[$label]['field'] = $field->field; |
| 849 | 849 | $fields[$label]['display'] = $field->display; |
| 850 | 850 | $fields[$label]['function'] = $field->field_function; |
| 851 | 851 | $fields[$label]['module'] = $field_module; |
| 852 | 852 | |
| 853 | 853 | |
| 854 | - if($field->display){ |
|
| 855 | - $csv.= $this->encloseForCSV($field->label); |
|
| 854 | + if ($field->display) { |
|
| 855 | + $csv .= $this->encloseForCSV($field->label); |
|
| 856 | 856 | $csv .= $delimiter; |
| 857 | 857 | } |
| 858 | 858 | ++$i; |
@@ -863,30 +863,30 @@ discard block |
||
| 863 | 863 | |
| 864 | 864 | while ($row = $this->db->fetchByAssoc($result)) { |
| 865 | 865 | $csv .= "\r\n"; |
| 866 | - foreach($fields as $name => $att){ |
|
| 867 | - if($att['display']){ |
|
| 868 | - if($att['function'] != '' ) |
|
| 866 | + foreach ($fields as $name => $att) { |
|
| 867 | + if ($att['display']) { |
|
| 868 | + if ($att['function'] != '') |
|
| 869 | 869 | $csv .= $this->encloseForCSV($row[$name]); |
| 870 | 870 | else |
| 871 | - $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name])))); |
|
| 871 | + $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name])))); |
|
| 872 | 872 | $csv .= $delimiter; |
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | - $csv= $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset()); |
|
| 877 | + $csv = $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset()); |
|
| 878 | 878 | |
| 879 | 879 | ob_clean(); |
| 880 | 880 | header("Pragma: cache"); |
| 881 | 881 | header("Content-type: text/comma-separated-values; charset=".$GLOBALS['locale']->getExportCharset()); |
| 882 | 882 | header("Content-Disposition: attachment; filename=\"{$this->name}.csv\""); |
| 883 | 883 | header("Content-transfer-encoding: binary"); |
| 884 | - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); |
|
| 885 | - header("Last-Modified: " . TimeDate::httpTime() ); |
|
| 886 | - header("Cache-Control: post-check=0, pre-check=0", false ); |
|
| 884 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
| 885 | + header("Last-Modified: ".TimeDate::httpTime()); |
|
| 886 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
| 887 | 887 | header("Content-Length: ".mb_strlen($csv, '8bit')); |
| 888 | 888 | if (!empty($sugar_config['export_excel_compatible'])) { |
| 889 | - $csv==chr(255) . chr(254) . mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8'); |
|
| 889 | + $csv == chr(255).chr(254).mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8'); |
|
| 890 | 890 | } |
| 891 | 891 | print $csv; |
| 892 | 892 | |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | |
| 897 | 897 | |
| 898 | - function build_report_query($group_value ='', $extra = array()){ |
|
| 898 | + function build_report_query($group_value = '', $extra = array()) { |
|
| 899 | 899 | global $beanList; |
| 900 | 900 | |
| 901 | 901 | $module = new $beanList[$this->report_module](); |
@@ -904,26 +904,26 @@ discard block |
||
| 904 | 904 | $query_array = array(); |
| 905 | 905 | |
| 906 | 906 | $query_array = $this->build_report_query_select($query_array, $group_value); |
| 907 | - if(isset($extra['where']) && $extra['where']) { |
|
| 908 | - $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND '; |
|
| 907 | + if (isset($extra['where']) && $extra['where']) { |
|
| 908 | + $query_array['where'][] = implode(' AND ', $extra['where']).' AND '; |
|
| 909 | 909 | } |
| 910 | 910 | $query_array = $this->build_report_query_where($query_array); |
| 911 | 911 | |
| 912 | - foreach ($query_array['select'] as $select){ |
|
| 913 | - $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 912 | + foreach ($query_array['select'] as $select) { |
|
| 913 | + $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | $query .= ' FROM '.$this->db->quoteIdentifier($module->table_name).' '; |
| 917 | 917 | |
| 918 | - if(isset($query_array['join'])){ |
|
| 919 | - foreach ($query_array['join'] as $join){ |
|
| 918 | + if (isset($query_array['join'])) { |
|
| 919 | + foreach ($query_array['join'] as $join) { |
|
| 920 | 920 | $query .= $join; |
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | - if(isset($query_array['where'])){ |
|
| 923 | + if (isset($query_array['where'])) { |
|
| 924 | 924 | $query_where = ''; |
| 925 | - foreach ($query_array['where'] as $where){ |
|
| 926 | - $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 925 | + foreach ($query_array['where'] as $where) { |
|
| 926 | + $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | $query_where = $this->queryWhereRepair($query_where); |
@@ -931,18 +931,18 @@ discard block |
||
| 931 | 931 | $query .= ' '.$query_where; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - if(isset($query_array['group_by'])){ |
|
| 934 | + if (isset($query_array['group_by'])) { |
|
| 935 | 935 | $query_group_by = ''; |
| 936 | - foreach ($query_array['group_by'] as $group_by){ |
|
| 937 | - $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 936 | + foreach ($query_array['group_by'] as $group_by) { |
|
| 937 | + $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 938 | 938 | } |
| 939 | 939 | $query .= ' '.$query_group_by; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - if(isset($query_array['sort_by'])){ |
|
| 942 | + if (isset($query_array['sort_by'])) { |
|
| 943 | 943 | $query_sort_by = ''; |
| 944 | - foreach ($query_array['sort_by'] as $sort_by){ |
|
| 945 | - $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 944 | + foreach ($query_array['sort_by'] as $sort_by) { |
|
| 945 | + $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 946 | 946 | } |
| 947 | 947 | $query .= ' '.$query_sort_by; |
| 948 | 948 | } |
@@ -956,11 +956,11 @@ discard block |
||
| 956 | 956 | |
| 957 | 957 | $safe = 0; |
| 958 | 958 | $query_where_clean = ''; |
| 959 | - while($query_where_clean != $query_where) { |
|
| 959 | + while ($query_where_clean != $query_where) { |
|
| 960 | 960 | $query_where_clean = $query_where; |
| 961 | 961 | $query_where = preg_replace('/\b(AND|OR)\s*\(\s*\)|[^\w+\s*]\(\s*\)/i', '', $query_where_clean); |
| 962 | 962 | $safe++; |
| 963 | - if($safe>100){ |
|
| 963 | + if ($safe > 100) { |
|
| 964 | 964 | $GLOBALS['log']->fatal('Invalid report query conditions'); |
| 965 | 965 | break; |
| 966 | 966 | } |
@@ -969,10 +969,10 @@ discard block |
||
| 969 | 969 | return $query_where; |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | - function build_report_query_select($query = array(), $group_value =''){ |
|
| 972 | + function build_report_query_select($query = array(), $group_value = '') { |
|
| 973 | 973 | global $beanList; |
| 974 | 974 | |
| 975 | - if($beanList[$this->report_module]){ |
|
| 975 | + if ($beanList[$this->report_module]) { |
|
| 976 | 976 | $module = new $beanList[$this->report_module](); |
| 977 | 977 | |
| 978 | 978 | $query['select'][] = $this->db->quoteIdentifier($module->table_name).".id AS '".$module->table_name."_id'"; |
@@ -985,16 +985,16 @@ discard block |
||
| 985 | 985 | $field = new AOR_Field(); |
| 986 | 986 | $field->retrieve($row['id']); |
| 987 | 987 | |
| 988 | - $field->label = str_replace(' ','_',$field->label).$i; |
|
| 988 | + $field->label = str_replace(' ', '_', $field->label).$i; |
|
| 989 | 989 | |
| 990 | 990 | $path = unserialize(base64_decode($field->module_path)); |
| 991 | 991 | |
| 992 | 992 | $field_module = $module; |
| 993 | 993 | $table_alias = $field_module->table_name; |
| 994 | 994 | $oldAlias = $table_alias; |
| 995 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
| 996 | - foreach($path as $rel){ |
|
| 997 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)]; |
|
| 995 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
| 996 | + foreach ($path as $rel) { |
|
| 997 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)]; |
|
| 998 | 998 | $oldAlias = $table_alias; |
| 999 | 999 | $table_alias = $table_alias.":".$rel; |
| 1000 | 1000 | $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
@@ -1005,54 +1005,54 @@ discard block |
||
| 1005 | 1005 | |
| 1006 | 1006 | $data = $field_module->field_defs[$field->field]; |
| 1007 | 1007 | |
| 1008 | - if($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 1008 | + if ($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 1009 | 1009 | $field->field = $data['id_name']; |
| 1010 | 1010 | $data_new = $field_module->field_defs[$field->field]; |
| 1011 | - if(isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])){ |
|
| 1011 | + if (isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) { |
|
| 1012 | 1012 | $data_new['type'] = 'link'; |
| 1013 | 1013 | $data_new['relationship'] = $data['link']; |
| 1014 | 1014 | } |
| 1015 | 1015 | $data = $data_new; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - if($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 1019 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$data['relationship'])]; |
|
| 1018 | + if ($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 1019 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $data['relationship'])]; |
|
| 1020 | 1020 | $table_alias = $data['relationship']; |
| 1021 | - $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
|
| 1021 | + $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
|
| 1022 | 1022 | $field_module = $new_field_module; |
| 1023 | 1023 | $field->field = 'id'; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | - if($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) { |
|
| 1027 | - if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 1026 | + if ($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) { |
|
| 1027 | + if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 1028 | 1028 | $query['select'][$table_alias.'_currency_id'] = $this->db->quoteIdentifier($table_alias.'_cstm').".currency_id AS '".$table_alias."_currency_id'"; |
| 1029 | 1029 | } else { |
| 1030 | 1030 | $query['select'][$table_alias.'_currency_id'] = $this->db->quoteIdentifier($table_alias).".currency_id AS '".$table_alias."_currency_id'"; |
| 1031 | 1031 | } |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | - if((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 1034 | + if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 1035 | 1035 | $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field; |
| 1036 | - $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm',$table_alias, $field_module, 'custom', $query); |
|
| 1036 | + $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $table_alias, $field_module, 'custom', $query); |
|
| 1037 | 1037 | } else { |
| 1038 | - $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 1038 | + $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | - if($field->sort_by != ''){ |
|
| 1041 | + if ($field->sort_by != '') { |
|
| 1042 | 1042 | $query['sort_by'][] = $select_field." ".$field->sort_by; |
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | - if($field->group_by == 1){ |
|
| 1046 | - $query['group_by'][] = $field->format ? str_replace('(%1)', '(' . $select_field . ')', preg_replace(array('/\s+/', '/Y/', '/m/', '/d/'), array(', ', 'YEAR(%1)', 'MONTH(%1)', 'DAY(%1)'), trim(preg_replace('/[^Ymd]/', ' ', $field->format)))) : $select_field; |
|
| 1045 | + if ($field->group_by == 1) { |
|
| 1046 | + $query['group_by'][] = $field->format ? str_replace('(%1)', '('.$select_field.')', preg_replace(array('/\s+/', '/Y/', '/m/', '/d/'), array(', ', 'YEAR(%1)', 'MONTH(%1)', 'DAY(%1)'), trim(preg_replace('/[^Ymd]/', ' ', $field->format)))) : $select_field; |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | - if($field->field_function != null){ |
|
| 1049 | + if ($field->field_function != null) { |
|
| 1050 | 1050 | $select_field = $field->field_function.'('.$select_field.')'; |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - $query['select'][] = $select_field ." AS '".$field->label."'"; |
|
| 1053 | + $query['select'][] = $select_field." AS '".$field->label."'"; |
|
| 1054 | 1054 | |
| 1055 | - if($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1055 | + if ($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1056 | 1056 | ++$i; |
| 1057 | 1057 | } |
| 1058 | 1058 | } |
@@ -1060,30 +1060,30 @@ discard block |
||
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | |
| 1063 | - function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(),SugarBean $rel_module = null ){ |
|
| 1063 | + function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(), SugarBean $rel_module = null) { |
|
| 1064 | 1064 | |
| 1065 | - if(!isset($query['join'][$alias])){ |
|
| 1065 | + if (!isset($query['join'][$alias])) { |
|
| 1066 | 1066 | |
| 1067 | - switch ($type){ |
|
| 1067 | + switch ($type) { |
|
| 1068 | 1068 | case 'custom': |
| 1069 | - $query['join'][$alias] = 'LEFT JOIN '.$this->db->quoteIdentifier($module->get_custom_table_name()).' '.$this->db->quoteIdentifier($name).' ON '.$this->db->quoteIdentifier($parentAlias).'.id = '. $this->db->quoteIdentifier($name).'.id_c '; |
|
| 1069 | + $query['join'][$alias] = 'LEFT JOIN '.$this->db->quoteIdentifier($module->get_custom_table_name()).' '.$this->db->quoteIdentifier($name).' ON '.$this->db->quoteIdentifier($parentAlias).'.id = '.$this->db->quoteIdentifier($name).'.id_c '; |
|
| 1070 | 1070 | break; |
| 1071 | 1071 | |
| 1072 | 1072 | case 'relationship': |
| 1073 | - if($module->load_relationship($name)){ |
|
| 1073 | + if ($module->load_relationship($name)) { |
|
| 1074 | 1074 | $params['join_type'] = 'LEFT JOIN'; |
| 1075 | - if($module->$name->relationship_type != 'one-to-many'){ |
|
| 1076 | - if($module->$name->getSide() == REL_LHS){ |
|
| 1075 | + if ($module->$name->relationship_type != 'one-to-many') { |
|
| 1076 | + if ($module->$name->getSide() == REL_LHS) { |
|
| 1077 | 1077 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1078 | 1078 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1079 | 1079 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1080 | - }else{ |
|
| 1080 | + } else { |
|
| 1081 | 1081 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1082 | 1082 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1083 | 1083 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - }else{ |
|
| 1086 | + } else { |
|
| 1087 | 1087 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1088 | 1088 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1089 | 1089 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | $params['join_table_link_alias'] = $this->db->quoteIdentifier($linkAlias); |
| 1093 | 1093 | $join = $module->$name->getJoin($params, true); |
| 1094 | 1094 | $query['join'][$alias] = $join['join']; |
| 1095 | - if($rel_module != null) { |
|
| 1095 | + if ($rel_module != null) { |
|
| 1096 | 1096 | $query['join'][$alias] .= $this->build_report_access_query($rel_module, $name); |
| 1097 | 1097 | } |
| 1098 | 1098 | $query['select'][] = $join['select']." AS '".$alias."_id'"; |
@@ -1107,11 +1107,11 @@ discard block |
||
| 1107 | 1107 | return $query; |
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | - function build_report_access_query(SugarBean $module, $alias){ |
|
| 1110 | + function build_report_access_query(SugarBean $module, $alias) { |
|
| 1111 | 1111 | |
| 1112 | 1112 | $module->table_name = $alias; |
| 1113 | 1113 | $where = ''; |
| 1114 | - if($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list') ) |
|
| 1114 | + if ($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list')) |
|
| 1115 | 1115 | { |
| 1116 | 1116 | global $current_user; |
| 1117 | 1117 | $owner_where = $module->getOwnerWhere($current_user->id); |
@@ -1119,18 +1119,18 @@ discard block |
||
| 1119 | 1119 | |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - if(file_exists('modules/SecurityGroups/SecurityGroup.php')){ |
|
| 1122 | + if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { |
|
| 1123 | 1123 | /* BEGIN - SECURITY GROUPS */ |
| 1124 | - if($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list') ) |
|
| 1124 | + if ($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list')) |
|
| 1125 | 1125 | { |
| 1126 | 1126 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
| 1127 | 1127 | global $current_user; |
| 1128 | 1128 | $owner_where = $module->getOwnerWhere($current_user->id); |
| 1129 | - $group_where = SecurityGroup::getGroupWhere($alias,$module->module_dir,$current_user->id); |
|
| 1130 | - if(!empty($owner_where)){ |
|
| 1131 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 1129 | + $group_where = SecurityGroup::getGroupWhere($alias, $module->module_dir, $current_user->id); |
|
| 1130 | + if (!empty($owner_where)) { |
|
| 1131 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
| 1132 | 1132 | } else { |
| 1133 | - $where .= ' AND '. $group_where; |
|
| 1133 | + $where .= ' AND '.$group_where; |
|
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | 1136 | /* END - SECURITY GROUPS */ |
@@ -1143,16 +1143,16 @@ discard block |
||
| 1143 | 1143 | * @param array $query |
| 1144 | 1144 | * @return array |
| 1145 | 1145 | */ |
| 1146 | - function build_report_query_where($query = array()){ |
|
| 1146 | + function build_report_query_where($query = array()) { |
|
| 1147 | 1147 | global $beanList, $app_list_strings, $sugar_config; |
| 1148 | 1148 | |
| 1149 | 1149 | $closure = false; |
| 1150 | - if(!empty($query['where'])) { |
|
| 1150 | + if (!empty($query['where'])) { |
|
| 1151 | 1151 | $query['where'][] = '('; |
| 1152 | 1152 | $closure = true; |
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - if($beanList[$this->report_module]){ |
|
| 1155 | + if ($beanList[$this->report_module]) { |
|
| 1156 | 1156 | $module = new $beanList[$this->report_module](); |
| 1157 | 1157 | |
| 1158 | 1158 | $sql = "SELECT id FROM aor_conditions WHERE aor_report_id = '".$this->id."' AND deleted = 0 ORDER BY condition_order ASC"; |
@@ -1169,21 +1169,21 @@ discard block |
||
| 1169 | 1169 | $condition_module = $module; |
| 1170 | 1170 | $table_alias = $condition_module->table_name; |
| 1171 | 1171 | $oldAlias = $table_alias; |
| 1172 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
| 1173 | - foreach($path as $rel){ |
|
| 1174 | - if(empty($rel)){ |
|
| 1172 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
| 1173 | + foreach ($path as $rel) { |
|
| 1174 | + if (empty($rel)) { |
|
| 1175 | 1175 | continue; |
| 1176 | 1176 | } |
| 1177 | 1177 | // Bug: Prevents relationships from loading. |
| 1178 | 1178 | //$rel = strtolower($rel); |
| 1179 | - $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir,$rel)]; |
|
| 1179 | + $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)]; |
|
| 1180 | 1180 | $oldAlias = $table_alias; |
| 1181 | 1181 | $table_alias = $table_alias.":".$rel; |
| 1182 | 1182 | $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_condition_module); |
| 1183 | 1183 | $condition_module = $new_condition_module; |
| 1184 | 1184 | } |
| 1185 | 1185 | } |
| 1186 | - if(isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { |
|
| 1186 | + if (isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { |
|
| 1187 | 1187 | $where_set = false; |
| 1188 | 1188 | |
| 1189 | 1189 | $data = $condition_module->field_defs[$condition->field]; |
@@ -1198,24 +1198,24 @@ discard block |
||
| 1198 | 1198 | $data = $data_new; |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - if($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 1202 | - $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir,$data['relationship'])]; |
|
| 1201 | + if ($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 1202 | + $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir, $data['relationship'])]; |
|
| 1203 | 1203 | $table_alias = $data['relationship']; |
| 1204 | - $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); |
|
| 1204 | + $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); |
|
| 1205 | 1205 | $condition_module = $new_field_module; |
| 1206 | 1206 | |
| 1207 | 1207 | // Debugging: security groups conditions - It's a hack to just get the query working |
| 1208 | - if($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) { |
|
| 1208 | + if ($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) { |
|
| 1209 | 1209 | // $table_alias = 'opportunities:assigned_user_link:SecurityGroups' ; |
| 1210 | - $table_alias = $oldAlias. ':' .$rel; |
|
| 1210 | + $table_alias = $oldAlias.':'.$rel; |
|
| 1211 | 1211 | } |
| 1212 | 1212 | $condition->field = 'id'; |
| 1213 | 1213 | } |
| 1214 | 1214 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
| 1215 | - $field = $this->db->quoteIdentifier($table_alias . '_cstm') . '.' . $condition->field; |
|
| 1216 | - $query = $this->build_report_query_join($table_alias . '_cstm', $table_alias . '_cstm', $oldAlias, $condition_module, 'custom', $query); |
|
| 1215 | + $field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$condition->field; |
|
| 1216 | + $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $oldAlias, $condition_module, 'custom', $query); |
|
| 1217 | 1217 | } else { |
| 1218 | - $field = $this->db->quoteIdentifier($table_alias) . '.' . $condition->field; |
|
| 1218 | + $field = $this->db->quoteIdentifier($table_alias).'.'.$condition->field; |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | if (!empty($this->user_parameters[$condition->id]) && $condition->parameter) { |
@@ -1247,10 +1247,10 @@ discard block |
||
| 1247 | 1247 | $condition->field = 'id'; |
| 1248 | 1248 | } |
| 1249 | 1249 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
| 1250 | - $value = $condition_module->table_name . '_cstm.' . $condition->value; |
|
| 1251 | - $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1250 | + $value = $condition_module->table_name.'_cstm.'.$condition->value; |
|
| 1251 | + $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1252 | 1252 | } else { |
| 1253 | - $value = ($table_alias ? "`$table_alias`" : $condition_module->table_name) . '.' . $condition->value; |
|
| 1253 | + $value = ($table_alias ? "`$table_alias`" : $condition_module->table_name).'.'.$condition->value; |
|
| 1254 | 1254 | } |
| 1255 | 1255 | break; |
| 1256 | 1256 | |
@@ -1262,10 +1262,10 @@ discard block |
||
| 1262 | 1262 | } else { |
| 1263 | 1263 | $value = 'NOW()'; |
| 1264 | 1264 | } |
| 1265 | - } else if($params[0] == 'today'){ |
|
| 1266 | - if($sugar_config['dbconfig']['db_type'] == 'mssql'){ |
|
| 1265 | + } else if ($params[0] == 'today') { |
|
| 1266 | + if ($sugar_config['dbconfig']['db_type'] == 'mssql') { |
|
| 1267 | 1267 | //$field = |
| 1268 | - $value = 'CAST(GETDATE() AS DATE)'; |
|
| 1268 | + $value = 'CAST(GETDATE() AS DATE)'; |
|
| 1269 | 1269 | } else { |
| 1270 | 1270 | $field = 'DATE('.$field.')'; |
| 1271 | 1271 | $value = 'Curdate()'; |
@@ -1273,10 +1273,10 @@ discard block |
||
| 1273 | 1273 | } else { |
| 1274 | 1274 | $data = $condition_module->field_defs[$params[0]]; |
| 1275 | 1275 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
| 1276 | - $value = $condition_module->table_name . '_cstm.' . $params[0]; |
|
| 1277 | - $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1276 | + $value = $condition_module->table_name.'_cstm.'.$params[0]; |
|
| 1277 | + $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1278 | 1278 | } else { |
| 1279 | - $value = $condition_module->table_name . '.' . $params[0]; |
|
| 1279 | + $value = $condition_module->table_name.'.'.$params[0]; |
|
| 1280 | 1280 | } |
| 1281 | 1281 | } |
| 1282 | 1282 | |
@@ -1287,9 +1287,9 @@ discard block |
||
| 1287 | 1287 | $params[3] = 'hours'; |
| 1288 | 1288 | default: |
| 1289 | 1289 | if ($sugar_config['dbconfig']['db_type'] == 'mssql') { |
| 1290 | - $value = "DATEADD(" . $params[3] . ", " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2], $value)"; |
|
| 1290 | + $value = "DATEADD(".$params[3].", ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2], $value)"; |
|
| 1291 | 1291 | } else { |
| 1292 | - $value = "DATE_ADD($value, INTERVAL " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2] " . $params[3] . ")"; |
|
| 1292 | + $value = "DATE_ADD($value, INTERVAL ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2] ".$params[3].")"; |
|
| 1293 | 1293 | } |
| 1294 | 1294 | break; |
| 1295 | 1295 | } |
@@ -1304,11 +1304,11 @@ discard block |
||
| 1304 | 1304 | $value = '('; |
| 1305 | 1305 | foreach ($multi_values as $multi_value) { |
| 1306 | 1306 | if ($value != '(') $value .= $sep; |
| 1307 | - $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; |
|
| 1307 | + $value .= $field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator]." '".$multi_value."'"; |
|
| 1308 | 1308 | } |
| 1309 | 1309 | $value .= ')'; |
| 1310 | 1310 | } |
| 1311 | - $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $value; |
|
| 1311 | + $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).$value; |
|
| 1312 | 1312 | $where_set = true; |
| 1313 | 1313 | break; |
| 1314 | 1314 | case "Period": |
@@ -1317,20 +1317,20 @@ discard block |
||
| 1317 | 1317 | } else { |
| 1318 | 1318 | $params = base64_decode($condition->value); |
| 1319 | 1319 | } |
| 1320 | - $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"'; |
|
| 1320 | + $value = '"'.getPeriodDate($params)->format('Y-m-d H:i:s').'"'; |
|
| 1321 | 1321 | break; |
| 1322 | 1322 | case "CurrentUserID": |
| 1323 | 1323 | global $current_user; |
| 1324 | - $value = '"' . $current_user->id . '"'; |
|
| 1324 | + $value = '"'.$current_user->id.'"'; |
|
| 1325 | 1325 | break; |
| 1326 | 1326 | case 'Value': |
| 1327 | 1327 | default: |
| 1328 | - $value = "'" . $this->db->quote($condition->value) . "'"; |
|
| 1328 | + $value = "'".$this->db->quote($condition->value)."'"; |
|
| 1329 | 1329 | break; |
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | //handle like conditions |
| 1333 | - Switch($condition->operator) { |
|
| 1333 | + Switch ($condition->operator) { |
|
| 1334 | 1334 | case 'Contains': |
| 1335 | 1335 | $value = "CONCAT('%', ".$value." ,'%')"; |
| 1336 | 1336 | break; |
@@ -1342,11 +1342,11 @@ discard block |
||
| 1342 | 1342 | break; |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | - if($condition->value_type == 'Value' && !$condition->value && $condition->operator == 'Equal_To') { |
|
| 1345 | + if ($condition->value_type == 'Value' && !$condition->value && $condition->operator == 'Equal_To') { |
|
| 1346 | 1346 | $value = "{$value} OR {$field} IS NULL"; |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | - if($tiltLogicOp) { |
|
| 1349 | + if ($tiltLogicOp) { |
|
| 1350 | 1350 | if ($condition->value_type == "Period") { |
| 1351 | 1351 | if (array_key_exists($condition->value, $app_list_strings['date_time_period_list'])) { |
| 1352 | 1352 | $params = $condition->value; |
@@ -1354,32 +1354,32 @@ discard block |
||
| 1354 | 1354 | $params = base64_decode($condition->value); |
| 1355 | 1355 | } |
| 1356 | 1356 | $date = getPeriodEndDate($params)->format('Y-m-d H:i:s'); |
| 1357 | - $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"'; |
|
| 1357 | + $value = '"'.getPeriodDate($params)->format('Y-m-d H:i:s').'"'; |
|
| 1358 | 1358 | |
| 1359 | 1359 | switch ($app_list_strings['aor_sql_operator_list'][$condition->operator]) { |
| 1360 | 1360 | case "=": |
| 1361 | - $query['where'][] = $field . ' BETWEEN ' . $value . ' AND ' . '"' . $date . '"'; |
|
| 1361 | + $query['where'][] = $field.' BETWEEN '.$value.' AND '.'"'.$date.'"'; |
|
| 1362 | 1362 | break; |
| 1363 | 1363 | case "!=": |
| 1364 | - $query['where'][] = $field . ' NOT BETWEEN ' . $value . ' AND ' . '"' . $date . '"'; |
|
| 1364 | + $query['where'][] = $field.' NOT BETWEEN '.$value.' AND '.'"'.$date.'"'; |
|
| 1365 | 1365 | break; |
| 1366 | 1366 | case ">": |
| 1367 | 1367 | case "<": |
| 1368 | 1368 | case ">=": |
| 1369 | 1369 | case "<=": |
| 1370 | - $query['where'][] = $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; |
|
| 1370 | + $query['where'][] = $field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator].' '.$value; |
|
| 1371 | 1371 | break; |
| 1372 | 1372 | } |
| 1373 | 1373 | } else { |
| 1374 | - $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; |
|
| 1374 | + $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).$field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator].' '.$value; |
|
| 1375 | 1375 | } |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | $tiltLogicOp = false; |
| 1379 | 1379 | } |
| 1380 | - else if($condition->parenthesis) { |
|
| 1381 | - if($condition->parenthesis == 'START') { |
|
| 1382 | - $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . '('; |
|
| 1380 | + else if ($condition->parenthesis) { |
|
| 1381 | + if ($condition->parenthesis == 'START') { |
|
| 1382 | + $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).'('; |
|
| 1383 | 1383 | $tiltLogicOp = true; |
| 1384 | 1384 | } |
| 1385 | 1385 | else { |
@@ -1393,7 +1393,7 @@ discard block |
||
| 1393 | 1393 | |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | - if(isset($query['where']) && $query['where']) { |
|
| 1396 | + if (isset($query['where']) && $query['where']) { |
|
| 1397 | 1397 | array_unshift($query['where'], '('); |
| 1398 | 1398 | $query['where'][] = ') AND '; |
| 1399 | 1399 | } |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | |
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | - if($closure) { |
|
| 1404 | + if ($closure) { |
|
| 1405 | 1405 | $query['where'][] = ')'; |
| 1406 | 1406 | } |
| 1407 | 1407 | |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 62 | 62 | if(isset($GLOBALS['log'])) { |
| 63 | 63 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 64 | - } |
|
| 65 | - else { |
|
| 64 | + } else { |
|
| 66 | 65 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 67 | 66 | } |
| 68 | 67 | self::__construct(); |
@@ -232,8 +231,10 @@ discard block |
||
| 232 | 231 | $html = '<script src="modules/AOR_Reports/js/Chart.js"></script>'; |
| 233 | 232 | break; |
| 234 | 233 | case self::CHART_TYPE_RGRAPH: |
| 235 | - if($_REQUEST['module']!= 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 234 | + if($_REQUEST['module']!= 'Home') { |
|
| 235 | + //Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 236 | 236 | require_once('include/SuiteGraphs/RGraphIncludes.php'); |
| 237 | + } |
|
| 237 | 238 | |
| 238 | 239 | break; |
| 239 | 240 | } |
@@ -256,15 +257,13 @@ discard block |
||
| 256 | 257 | |
| 257 | 258 | if(count($rows) > 1) { |
| 258 | 259 | $GLOBALS['log']->fatal('ambiguous group display for report ' . $this->id); |
| 259 | - } |
|
| 260 | - else if(count($rows) == 1){ |
|
| 260 | + } else if(count($rows) == 1){ |
|
| 261 | 261 | $rows[0]['module_path'] = unserialize(base64_decode($rows[0]['module_path'])); |
| 262 | 262 | if(!$rows[0]['module_path'][0]) { |
| 263 | 263 | $module = new $beanList[$this->report_module](); |
| 264 | 264 | $rows[0]['field_id_name'] = $module->field_defs[$rows[0]['field']]['id_name'] ? $module->field_defs[$rows[0]['field']]['id_name'] : $module->field_defs[$rows[0]['field']]['name']; |
| 265 | 265 | $rows[0]['module_path'][0] = $module->table_name; |
| 266 | - } |
|
| 267 | - else { |
|
| 266 | + } else { |
|
| 268 | 267 | $rows[0]['field_id_name'] = $rows[0]['field']; |
| 269 | 268 | } |
| 270 | 269 | $path[] = $rows[0]; |
@@ -276,8 +275,7 @@ discard block |
||
| 276 | 275 | } |
| 277 | 276 | |
| 278 | 277 | return $this->buildMultiGroupReport($offset, $links, $level+1, $path); |
| 279 | - } |
|
| 280 | - else if(!$rows) { |
|
| 278 | + } else if(!$rows) { |
|
| 281 | 279 | if($path) { |
| 282 | 280 | $html = ''; |
| 283 | 281 | foreach ($path as $pth) { |
@@ -295,12 +293,10 @@ discard block |
||
| 295 | 293 | } |
| 296 | 294 | } |
| 297 | 295 | return $html; |
| 298 | - } |
|
| 299 | - else { |
|
| 296 | + } else { |
|
| 300 | 297 | return $this->build_group_report($offset, $links); |
| 301 | 298 | } |
| 302 | - } |
|
| 303 | - else { |
|
| 299 | + } else { |
|
| 304 | 300 | throw new Exception('incorrect results'); |
| 305 | 301 | } |
| 306 | 302 | throw new Exception('incorrect state'); |
@@ -436,8 +432,7 @@ discard block |
||
| 436 | 432 | foreach($extra['select'] as $selectField => $selectAlias) { |
| 437 | 433 | if($selectAlias) { |
| 438 | 434 | $query_array['select'][] = $selectField . " AS " . $selectAlias; |
| 439 | - } |
|
| 440 | - else { |
|
| 435 | + } else { |
|
| 441 | 436 | $query_array['select'][] = $selectField; |
| 442 | 437 | } |
| 443 | 438 | } |
@@ -492,14 +487,18 @@ discard block |
||
| 492 | 487 | $result = $this->db->query($query); |
| 493 | 488 | |
| 494 | 489 | while ($row = $this->db->fetchByAssoc($result)) { |
| 495 | - if($html != '') $html .= '<br />'; |
|
| 490 | + if($html != '') { |
|
| 491 | + $html .= '<br />'; |
|
| 492 | + } |
|
| 496 | 493 | |
| 497 | 494 | $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
| 498 | 495 | |
| 499 | 496 | } |
| 500 | 497 | } |
| 501 | 498 | |
| 502 | - if($html == '') $html = $this->build_report_html($offset, $links); |
|
| 499 | + if($html == '') { |
|
| 500 | + $html = $this->build_report_html($offset, $links); |
|
| 501 | + } |
|
| 503 | 502 | return $html; |
| 504 | 503 | |
| 505 | 504 | } |
@@ -693,7 +692,9 @@ discard block |
||
| 693 | 692 | if($att['total']){ |
| 694 | 693 | $totals[$name][] = $row[$name]; |
| 695 | 694 | } |
| 696 | - if($att['link'] && $links) $html .= "</a>"; |
|
| 695 | + if($att['link'] && $links) { |
|
| 696 | + $html .= "</a>"; |
|
| 697 | + } |
|
| 697 | 698 | $html .= "</td>"; |
| 698 | 699 | } |
| 699 | 700 | } |
@@ -777,7 +778,7 @@ discard block |
||
| 777 | 778 | if($field['total']){ |
| 778 | 779 | $totalLabel = $field['label'] ." ".$app_list_strings['aor_total_options'][$field['total']]; |
| 779 | 780 | $html .= "<th>{$totalLabel}</th>"; |
| 780 | - }else{ |
|
| 781 | + } else{ |
|
| 781 | 782 | $html .= "<th></th>"; |
| 782 | 783 | } |
| 783 | 784 | } |
@@ -789,7 +790,7 @@ discard block |
||
| 789 | 790 | } |
| 790 | 791 | if($field['total'] && isset($totals[$label])){ |
| 791 | 792 | $html .= "<td>".$this->calculateTotal($field['total'],$totals[$label])."</td>"; |
| 792 | - }else{ |
|
| 793 | + } else{ |
|
| 793 | 794 | $html .= "<td></td>"; |
| 794 | 795 | } |
| 795 | 796 | } |
@@ -865,10 +866,11 @@ discard block |
||
| 865 | 866 | $csv .= "\r\n"; |
| 866 | 867 | foreach($fields as $name => $att){ |
| 867 | 868 | if($att['display']){ |
| 868 | - if($att['function'] != '' ) |
|
| 869 | - $csv .= $this->encloseForCSV($row[$name]); |
|
| 870 | - else |
|
| 871 | - $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name])))); |
|
| 869 | + if($att['function'] != '' ) { |
|
| 870 | + $csv .= $this->encloseForCSV($row[$name]); |
|
| 871 | + } else { |
|
| 872 | + $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name])))); |
|
| 873 | + } |
|
| 872 | 874 | $csv .= $delimiter; |
| 873 | 875 | } |
| 874 | 876 | } |
@@ -1052,7 +1054,9 @@ discard block |
||
| 1052 | 1054 | |
| 1053 | 1055 | $query['select'][] = $select_field ." AS '".$field->label."'"; |
| 1054 | 1056 | |
| 1055 | - if($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1057 | + if($field->group_display == 1 && $group_value) { |
|
| 1058 | + $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1059 | + } |
|
| 1056 | 1060 | ++$i; |
| 1057 | 1061 | } |
| 1058 | 1062 | } |
@@ -1077,13 +1081,13 @@ discard block |
||
| 1077 | 1081 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1078 | 1082 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1079 | 1083 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1080 | - }else{ |
|
| 1084 | + } else{ |
|
| 1081 | 1085 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1082 | 1086 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1083 | 1087 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1084 | 1088 | } |
| 1085 | 1089 | |
| 1086 | - }else{ |
|
| 1090 | + } else{ |
|
| 1087 | 1091 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1088 | 1092 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1089 | 1093 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
@@ -1298,12 +1302,16 @@ discard block |
||
| 1298 | 1302 | |
| 1299 | 1303 | case 'Multi': |
| 1300 | 1304 | $sep = ' AND '; |
| 1301 | - if ($condition->operator == 'Equal_To') $sep = ' OR '; |
|
| 1305 | + if ($condition->operator == 'Equal_To') { |
|
| 1306 | + $sep = ' OR '; |
|
| 1307 | + } |
|
| 1302 | 1308 | $multi_values = unencodeMultienum($condition->value); |
| 1303 | 1309 | if (!empty($multi_values)) { |
| 1304 | 1310 | $value = '('; |
| 1305 | 1311 | foreach ($multi_values as $multi_value) { |
| 1306 | - if ($value != '(') $value .= $sep; |
|
| 1312 | + if ($value != '(') { |
|
| 1313 | + $value .= $sep; |
|
| 1314 | + } |
|
| 1307 | 1315 | $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; |
| 1308 | 1316 | } |
| 1309 | 1317 | $value .= ')'; |
@@ -1376,18 +1384,15 @@ discard block |
||
| 1376 | 1384 | } |
| 1377 | 1385 | |
| 1378 | 1386 | $tiltLogicOp = false; |
| 1379 | - } |
|
| 1380 | - else if($condition->parenthesis) { |
|
| 1387 | + } else if($condition->parenthesis) { |
|
| 1381 | 1388 | if($condition->parenthesis == 'START') { |
| 1382 | 1389 | $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . '('; |
| 1383 | 1390 | $tiltLogicOp = true; |
| 1384 | - } |
|
| 1385 | - else { |
|
| 1391 | + } else { |
|
| 1386 | 1392 | $query['where'][] = ')'; |
| 1387 | 1393 | $tiltLogicOp = false; |
| 1388 | 1394 | } |
| 1389 | - } |
|
| 1390 | - else { |
|
| 1395 | + } else { |
|
| 1391 | 1396 | $GLOBALS['log']->debug('illegal condition'); |
| 1392 | 1397 | } |
| 1393 | 1398 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | |
| 4 | 4 | |
| 5 | 5 | require_once('include/Dashlets/Dashlet.php'); |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | parent::__construct($id); |
| 18 | 18 | $this->isConfigurable = true; |
| 19 | 19 | $this->def = $def; |
| 20 | - if(empty($def['dashletTitle'])) { |
|
| 20 | + if (empty($def['dashletTitle'])) { |
|
| 21 | 21 | $this->title = translate('LBL_AOR_REPORTS_DASHLET', 'AOR_Reports'); |
| 22 | - } else{ |
|
| 22 | + } else { |
|
| 23 | 23 | $this->title = $def['dashletTitle']; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $this->params = array(); |
| 27 | - if(!empty($def['parameter_id'])) { |
|
| 27 | + if (!empty($def['parameter_id'])) { |
|
| 28 | 28 | foreach ($def['parameter_id'] as $key => $parameterId) { |
| 29 | 29 | $this->params[$parameterId] = array( |
| 30 | 30 | 'id' => $parameterId, |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'value' => $def['parameter_value'][$key]); |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | - if(!empty($def['aor_report_id'])) { |
|
| 36 | + if (!empty($def['aor_report_id'])) { |
|
| 37 | 37 | $this->report = BeanFactory::getBean('AOR_Reports', $def['aor_report_id']); |
| 38 | 38 | $this->report->user_parameters = $this->params; |
| 39 | 39 | } |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * @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 |
| 46 | 46 | */ |
| 47 | - function AORReportsDashlet($id, $def = array()){ |
|
| 47 | + function AORReportsDashlet($id, $def = array()) { |
|
| 48 | 48 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 49 | - if(isset($GLOBALS['log'])) { |
|
| 49 | + if (isset($GLOBALS['log'])) { |
|
| 50 | 50 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 51 | 51 | } |
| 52 | 52 | else { |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | $mod_strings = return_module_language($current_language, 'AOR_Reports'); |
| 61 | 61 | $dashletSmarty = new Sugar_Smarty(); |
| 62 | 62 | $dashletTemplate = get_custom_file_if_exists('modules/AOR_Reports/Dashlets/AORReportsDashlet/dashlet.tpl'); |
| 63 | - $dashletSmarty->assign('MOD',$mod_strings); |
|
| 64 | - $dashletSmarty->assign('dashlet_id',$this->id); |
|
| 65 | - $dashletSmarty->assign('report_id',$this->report->id); |
|
| 66 | - $dashletSmarty->assign('chartHTML',$this->getChartHTML()); |
|
| 63 | + $dashletSmarty->assign('MOD', $mod_strings); |
|
| 64 | + $dashletSmarty->assign('dashlet_id', $this->id); |
|
| 65 | + $dashletSmarty->assign('report_id', $this->report->id); |
|
| 66 | + $dashletSmarty->assign('chartHTML', $this->getChartHTML()); |
|
| 67 | 67 | $dashletSmarty->assign('onlyCharts', $this->onlyCharts); |
| 68 | - $dashletSmarty->assign('parameters',json_encode(array( |
|
| 68 | + $dashletSmarty->assign('parameters', json_encode(array( |
|
| 69 | 69 | 'ids' => isset($this->def['parameter_id']) ? $this->def['parameter_id'] : null, |
| 70 | 70 | 'operators' => isset($this->def['parameter_operator']) ? $this->def['parameter_operator'] : null, |
| 71 | 71 | 'types' => isset($this->def['parameter_type']) ? $this->def['parameter_type'] : null, |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | return $dashletSmarty->fetch($dashletTemplate); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - function getChartHTML(){ |
|
| 77 | - if(!empty($this->report->id)) { |
|
| 76 | + function getChartHTML() { |
|
| 77 | + if (!empty($this->report->id)) { |
|
| 78 | 78 | //return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_CHARTJS); |
| 79 | 79 | return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_RGRAPH); |
| 80 | - }else{ |
|
| 80 | + } else { |
|
| 81 | 81 | return ''; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | global $current_language, $app_list_strings, $datetime; |
| 91 | 91 | $mod_strings = return_module_language($current_language, 'AOR_Reports'); |
| 92 | 92 | $optionsSmarty = new Sugar_Smarty(); |
| 93 | - $optionsSmarty->assign('MOD',$mod_strings); |
|
| 93 | + $optionsSmarty->assign('MOD', $mod_strings); |
|
| 94 | 94 | $optionsSmarty->assign('id', $this->id); |
| 95 | 95 | $optionsSmarty->assign('dashletTitle', $this->title); |
| 96 | 96 | $optionsSmarty->assign('aor_report_id', $this->report->id); |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | $optionsSmarty->assign('date_time_period_list', $app_list_strings['date_time_period_list']); |
| 104 | 104 | |
| 105 | 105 | $charts = array(); |
| 106 | - if(!empty($this->report->id)){ |
|
| 107 | - foreach($this->report->get_linked_beans('aor_charts','AOR_Charts') as $chart){ |
|
| 106 | + if (!empty($this->report->id)) { |
|
| 107 | + foreach ($this->report->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) { |
|
| 108 | 108 | $charts[$chart->id] = $chart->name; |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | $conditions = getConditionsAsParameters($this->report, $this->params); |
| 112 | 112 | $i = 0; |
| 113 | - foreach($conditions as $condition) { |
|
| 114 | - if($condition["value_type"] == "Date"){ |
|
| 115 | - if($condition["additionalConditions"][0] == "now") { |
|
| 113 | + foreach ($conditions as $condition) { |
|
| 114 | + if ($condition["value_type"] == "Date") { |
|
| 115 | + if ($condition["additionalConditions"][0] == "now") { |
|
| 116 | 116 | $conditions[$i]["value"] = date("d/m/Y"); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $i++; |
| 121 | 121 | } |
| 122 | 122 | $optionsSmarty->assign('parameters', $conditions); |
| 123 | - $chartOptions = get_select_options_with_id($charts,$this->charts); |
|
| 123 | + $chartOptions = get_select_options_with_id($charts, $this->charts); |
|
| 124 | 124 | $optionsSmarty->assign('chartOptions', $chartOptions); |
| 125 | 125 | $optionsTemplate = get_custom_file_if_exists('modules/AOR_Reports/Dashlets/AORReportsDashlet/dashletConfigure.tpl'); |
| 126 | 126 | ob_clean(); |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | // $req['parameter_value'][0] = $secondValue; |
| 134 | 134 | // $req['parameter_value'][1] = $firstValue; |
| 135 | 135 | // } |
| 136 | - $allowedKeys = array_flip(array('aor_report_id','dashletTitle','charts','onlyCharts','parameter_id','parameter_value','parameter_type','parameter_operator')); |
|
| 137 | - $intersected = array_intersect_key($req,$allowedKeys); |
|
| 136 | + $allowedKeys = array_flip(array('aor_report_id', 'dashletTitle', 'charts', 'onlyCharts', 'parameter_id', 'parameter_value', 'parameter_type', 'parameter_operator')); |
|
| 137 | + $intersected = array_intersect_key($req, $allowedKeys); |
|
| 138 | 138 | return $intersected; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -1,5 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | |
| 4 | 6 | |
| 5 | 7 | require_once('include/Dashlets/Dashlet.php'); |
@@ -48,8 +50,7 @@ discard block |
||
| 48 | 50 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 49 | 51 | if(isset($GLOBALS['log'])) { |
| 50 | 52 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 51 | - } |
|
| 52 | - else { |
|
| 53 | + } else { |
|
| 53 | 54 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 54 | 55 | } |
| 55 | 56 | self::__construct($id, $def); |
@@ -77,7 +78,7 @@ discard block |
||
| 77 | 78 | if(!empty($this->report->id)) { |
| 78 | 79 | //return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_CHARTJS); |
| 79 | 80 | return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_RGRAPH); |
| 80 | - }else{ |
|
| 81 | + } else{ |
|
| 81 | 82 | return ''; |
| 82 | 83 | } |
| 83 | 84 | } |
@@ -35,9 +35,9 @@ |
||
| 35 | 35 | /** |
| 36 | 36 | * @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 |
| 37 | 37 | */ |
| 38 | - function jjwg_Areas_sugar(){ |
|
| 38 | + function jjwg_Areas_sugar() { |
|
| 39 | 39 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 40 | - if(isset($GLOBALS['log'])) { |
|
| 40 | + if (isset($GLOBALS['log'])) { |
|
| 41 | 41 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 42 | 42 | } |
| 43 | 43 | else { |
@@ -23,8 +23,7 @@ |
||
| 23 | 23 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 24 | 24 | if(isset($GLOBALS['log'])) { |
| 25 | 25 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 26 | - } |
|
| 27 | - else { |
|
| 26 | + } else { |
|
| 28 | 27 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 29 | 28 | } |
| 30 | 29 | self::__construct($seed, $module, $subPanel, $options); |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /* |
|
| 53 | + /* |
|
| 54 | 54 | * |
| 55 | 55 | */ |
| 56 | - function __construct() |
|
| 57 | - { |
|
| 56 | + function __construct() |
|
| 57 | + { |
|
| 58 | 58 | |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * @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 |
@@ -73,91 +73,91 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /* |
|
| 77 | - * |
|
| 78 | - */ |
|
| 79 | - function _get_where_clause() |
|
| 80 | - { |
|
| 81 | - $where = ''; |
|
| 82 | - if(isset($_REQUEST['query'])) |
|
| 83 | - { |
|
| 84 | - $where_clauses = array(); |
|
| 85 | - append_where_clause($where_clauses, "name", "acl_roles.name"); |
|
| 86 | - $where = generate_where_statement($where_clauses); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - return $where; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 76 | + /* |
|
| 93 | 77 | * |
| 94 | 78 | */ |
| 95 | - function process_page() |
|
| 96 | - { |
|
| 97 | - global $mod_strings; |
|
| 98 | - global $app_strings; |
|
| 99 | - global $currentModule; |
|
| 100 | - global $sugar_version, $sugar_config; |
|
| 101 | - |
|
| 102 | - $output_html = ''; |
|
| 103 | - $where = ''; |
|
| 104 | - |
|
| 105 | - $where = $this->_get_where_clause(); |
|
| 106 | - |
|
| 107 | - $name = empty($_REQUEST['name']) ? '' : $_REQUEST['name']; |
|
| 108 | - $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; |
|
| 109 | - $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true; |
|
| 110 | - |
|
| 111 | - $button = "<form action='index.php' method='post' name='form' id='form'>\n"; |
|
| 112 | - if(!$hide_clear_button) |
|
| 113 | - { |
|
| 114 | - $button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='" |
|
| 115 | - .$app_strings['LBL_CLEAR_BUTTON_TITLE']."' value=' " |
|
| 116 | - .$app_strings['LBL_CLEAR_BUTTON_LABEL']." ' />\n"; |
|
| 117 | - } |
|
| 118 | - $button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='" |
|
| 119 | - .$app_strings['LBL_CANCEL_BUTTON_TITLE']."' value=' " |
|
| 120 | - .$app_strings['LBL_CANCEL_BUTTON_LABEL']." ' />\n"; |
|
| 121 | - $button .= "</form>\n"; |
|
| 122 | - |
|
| 123 | - $form = new XTemplate('modules/ACLRoles/Popup_picker.html'); |
|
| 124 | - $form->assign('MOD', $mod_strings); |
|
| 125 | - $form->assign('APP', $app_strings); |
|
| 126 | - $form->assign('MODULE_NAME', $currentModule); |
|
| 127 | - $form->assign('NAME', $name); |
|
| 128 | - $form->assign('request_data', $request_data); |
|
| 129 | - |
|
| 130 | - ob_start(); |
|
| 131 | - insert_popup_header(); |
|
| 132 | - $output_html .= ob_get_contents(); |
|
| 133 | - ob_end_clean(); |
|
| 134 | - |
|
| 135 | - $output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false); |
|
| 136 | - |
|
| 137 | - $form->parse('main.SearchHeader'); |
|
| 138 | - $output_html .= $form->text('main.SearchHeader'); |
|
| 139 | - |
|
| 140 | - // Reset the sections that are already in the page so that they do not print again later. |
|
| 141 | - $form->reset('main.SearchHeader'); |
|
| 142 | - |
|
| 143 | - // create the listview |
|
| 144 | - $seed_bean = new ACLRole(); |
|
| 145 | - $ListView = new ListView(); |
|
| 146 | - $ListView->show_export_button = false; |
|
| 147 | - $ListView->process_for_popups = true; |
|
| 148 | - $ListView->setXTemplate($form); |
|
| 149 | - $ListView->setHeaderTitle($mod_strings['LBL_ROLE']); |
|
| 150 | - $ListView->setHeaderText($button); |
|
| 151 | - $ListView->setQuery($where, '', 'name', 'ROLE'); |
|
| 152 | - $ListView->setModStrings($mod_strings); |
|
| 153 | - |
|
| 154 | - ob_start(); |
|
| 155 | - $ListView->processListView($seed_bean, 'main', 'ROLE'); |
|
| 156 | - $output_html .= ob_get_contents(); |
|
| 157 | - ob_end_clean(); |
|
| 158 | - |
|
| 159 | - $output_html .= insert_popup_footer(); |
|
| 160 | - return $output_html; |
|
| 161 | - } |
|
| 79 | + function _get_where_clause() |
|
| 80 | + { |
|
| 81 | + $where = ''; |
|
| 82 | + if(isset($_REQUEST['query'])) |
|
| 83 | + { |
|
| 84 | + $where_clauses = array(); |
|
| 85 | + append_where_clause($where_clauses, "name", "acl_roles.name"); |
|
| 86 | + $where = generate_where_statement($where_clauses); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + return $where; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * |
|
| 94 | + */ |
|
| 95 | + function process_page() |
|
| 96 | + { |
|
| 97 | + global $mod_strings; |
|
| 98 | + global $app_strings; |
|
| 99 | + global $currentModule; |
|
| 100 | + global $sugar_version, $sugar_config; |
|
| 101 | + |
|
| 102 | + $output_html = ''; |
|
| 103 | + $where = ''; |
|
| 104 | + |
|
| 105 | + $where = $this->_get_where_clause(); |
|
| 106 | + |
|
| 107 | + $name = empty($_REQUEST['name']) ? '' : $_REQUEST['name']; |
|
| 108 | + $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; |
|
| 109 | + $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true; |
|
| 110 | + |
|
| 111 | + $button = "<form action='index.php' method='post' name='form' id='form'>\n"; |
|
| 112 | + if(!$hide_clear_button) |
|
| 113 | + { |
|
| 114 | + $button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='" |
|
| 115 | + .$app_strings['LBL_CLEAR_BUTTON_TITLE']."' value=' " |
|
| 116 | + .$app_strings['LBL_CLEAR_BUTTON_LABEL']." ' />\n"; |
|
| 117 | + } |
|
| 118 | + $button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='" |
|
| 119 | + .$app_strings['LBL_CANCEL_BUTTON_TITLE']."' value=' " |
|
| 120 | + .$app_strings['LBL_CANCEL_BUTTON_LABEL']." ' />\n"; |
|
| 121 | + $button .= "</form>\n"; |
|
| 122 | + |
|
| 123 | + $form = new XTemplate('modules/ACLRoles/Popup_picker.html'); |
|
| 124 | + $form->assign('MOD', $mod_strings); |
|
| 125 | + $form->assign('APP', $app_strings); |
|
| 126 | + $form->assign('MODULE_NAME', $currentModule); |
|
| 127 | + $form->assign('NAME', $name); |
|
| 128 | + $form->assign('request_data', $request_data); |
|
| 129 | + |
|
| 130 | + ob_start(); |
|
| 131 | + insert_popup_header(); |
|
| 132 | + $output_html .= ob_get_contents(); |
|
| 133 | + ob_end_clean(); |
|
| 134 | + |
|
| 135 | + $output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false); |
|
| 136 | + |
|
| 137 | + $form->parse('main.SearchHeader'); |
|
| 138 | + $output_html .= $form->text('main.SearchHeader'); |
|
| 139 | + |
|
| 140 | + // Reset the sections that are already in the page so that they do not print again later. |
|
| 141 | + $form->reset('main.SearchHeader'); |
|
| 142 | + |
|
| 143 | + // create the listview |
|
| 144 | + $seed_bean = new ACLRole(); |
|
| 145 | + $ListView = new ListView(); |
|
| 146 | + $ListView->show_export_button = false; |
|
| 147 | + $ListView->process_for_popups = true; |
|
| 148 | + $ListView->setXTemplate($form); |
|
| 149 | + $ListView->setHeaderTitle($mod_strings['LBL_ROLE']); |
|
| 150 | + $ListView->setHeaderText($button); |
|
| 151 | + $ListView->setQuery($where, '', 'name', 'ROLE'); |
|
| 152 | + $ListView->setModStrings($mod_strings); |
|
| 153 | + |
|
| 154 | + ob_start(); |
|
| 155 | + $ListView->processListView($seed_bean, 'main', 'ROLE'); |
|
| 156 | + $output_html .= ob_get_contents(); |
|
| 157 | + ob_end_clean(); |
|
| 158 | + |
|
| 159 | + $output_html .= insert_popup_footer(); |
|
| 160 | + return $output_html; |
|
| 161 | + } |
|
| 162 | 162 | } // end of class Popup_Picker |
| 163 | 163 | ?> |
| 164 | 164 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * @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 |
| 63 | 63 | */ |
| 64 | - function Popup_Picker(){ |
|
| 64 | + function Popup_Picker() { |
|
| 65 | 65 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 66 | - if(isset($GLOBALS['log'])) { |
|
| 66 | + if (isset($GLOBALS['log'])) { |
|
| 67 | 67 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 68 | 68 | } |
| 69 | 69 | else { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | function _get_where_clause() |
| 80 | 80 | { |
| 81 | 81 | $where = ''; |
| 82 | - if(isset($_REQUEST['query'])) |
|
| 82 | + if (isset($_REQUEST['query'])) |
|
| 83 | 83 | { |
| 84 | 84 | $where_clauses = array(); |
| 85 | 85 | append_where_clause($where_clauses, "name", "acl_roles.name"); |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; |
| 109 | 109 | $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true; |
| 110 | 110 | |
| 111 | - $button = "<form action='index.php' method='post' name='form' id='form'>\n"; |
|
| 112 | - if(!$hide_clear_button) |
|
| 111 | + $button = "<form action='index.php' method='post' name='form' id='form'>\n"; |
|
| 112 | + if (!$hide_clear_button) |
|
| 113 | 113 | { |
| 114 | 114 | $button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='" |
| 115 | 115 | .$app_strings['LBL_CLEAR_BUTTON_TITLE']."' value=' " |
@@ -43,7 +43,9 @@ discard block |
||
| 43 | 43 | * Date: 06/03/15 |
| 44 | 44 | * Comments |
| 45 | 45 | */ |
| 46 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 46 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 47 | + die('Not A Valid Entry Point'); |
|
| 48 | +} |
|
| 47 | 49 | |
| 48 | 50 | class CasesController extends SugarController { |
| 49 | 51 | |
@@ -90,8 +92,7 @@ discard block |
||
| 90 | 92 | $count++; |
| 91 | 93 | } |
| 92 | 94 | echo '</table>'; |
| 93 | - } |
|
| 94 | - else { |
|
| 95 | + } else { |
|
| 95 | 96 | echo $mod_strings['LBL_NO_SUGGESTIONS']; |
| 96 | 97 | } |
| 97 | 98 | die(); |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | |
| 4 | 4 | require_once('include/MVC/View/views/view.detail.php'); |
| 5 | 5 | |
| 6 | 6 | class ACLRolesViewClassic extends ViewDetail { |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - function __construct(){ |
|
| 9 | + function __construct() { |
|
| 10 | 10 | parent::__construct(); |
| 11 | 11 | |
| 12 | 12 | //turn off normal display of subpanels |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @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 |
| 18 | 18 | */ |
| 19 | - function ACLRolesViewClassic(){ |
|
| 19 | + function ACLRolesViewClassic() { |
|
| 20 | 20 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 21 | - if(isset($GLOBALS['log'])) { |
|
| 21 | + if (isset($GLOBALS['log'])) { |
|
| 22 | 22 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 23 | 23 | } |
| 24 | 24 | else { |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - function display(){ |
|
| 31 | + function display() { |
|
| 32 | 32 | $this->dv->process(); |
| 33 | 33 | |
| 34 | 34 | $file = SugarController::getActionFilename($this->action); |
| 35 | - $this->includeClassicFile('modules/'. $this->module . '/'. $file . '.php'); |
|
| 35 | + $this->includeClassicFile('modules/'.$this->module.'/'.$file.'.php'); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - function preDisplay(){ |
|
| 38 | + function preDisplay() { |
|
| 39 | 39 | parent::preDisplay(); |
| 40 | 40 | |
| 41 | 41 | $this->options['show_subpanels'] = false; //eggsurplus: will display subpanels twice otherwise |
@@ -43,7 +43,9 @@ discard block |
||
| 43 | 43 | * Date: 06/03/15 |
| 44 | 44 | * Comments |
| 45 | 45 | */ |
| 46 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 46 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 47 | + die('Not A Valid Entry Point'); |
|
| 48 | +} |
|
| 47 | 49 | |
| 48 | 50 | class CasesController extends SugarController { |
| 49 | 51 | |
@@ -90,8 +92,7 @@ discard block |
||
| 90 | 92 | $count++; |
| 91 | 93 | } |
| 92 | 94 | echo '</table>'; |
| 93 | - } |
|
| 94 | - else { |
|
| 95 | + } else { |
|
| 95 | 96 | echo $mod_strings['LBL_NO_SUGGESTIONS']; |
| 96 | 97 | } |
| 97 | 98 | die(); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | ********************************************************************************/ |
| 40 | 40 | |
| 41 | 41 | |
| 42 | -class ACLRole extends SugarBean{ |
|
| 42 | +class ACLRole extends SugarBean { |
|
| 43 | 43 | var $module_dir = 'ACLRoles'; |
| 44 | 44 | var $object_name = 'ACLRole'; |
| 45 | 45 | var $table_name = 'acl_roles'; |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | var $created_by; |
| 54 | 54 | |
| 55 | - public function __construct(){ |
|
| 55 | + public function __construct() { |
|
| 56 | 56 | parent::__construct(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @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 |
| 61 | 61 | */ |
| 62 | - public function ACLRole(){ |
|
| 62 | + public function ACLRole() { |
|
| 63 | 63 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 64 | - if(isset($GLOBALS['log'])) { |
|
| 64 | + if (isset($GLOBALS['log'])) { |
|
| 65 | 65 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 66 | 66 | } |
| 67 | 67 | else { |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | * @param GUID $action_id - the ACL Action id |
| 88 | 88 | * @param int $access - the access level ACL_ALLOW_ALL ACL_ALLOW_NONE ACL_ALLOW_OWNER... |
| 89 | 89 | */ |
| 90 | -function setAction($role_id, $action_id, $access){ |
|
| 90 | +function setAction($role_id, $action_id, $access) { |
|
| 91 | 91 | $relationship_data = array('role_id'=>$role_id, 'action_id'=>$action_id,); |
| 92 | 92 | $additional_data = array('access_override'=>$access); |
| 93 | - $this->set_relationship('acl_roles_actions',$relationship_data,true, true,$additional_data); |
|
| 93 | + $this->set_relationship('acl_roles_actions', $relationship_data, true, true, $additional_data); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param GUID $user_id |
| 102 | 102 | * @return a list of ACLRole objects |
| 103 | 103 | */ |
| 104 | -function getUserRoles($user_id, $getAsNameArray = true){ |
|
| 104 | +function getUserRoles($user_id, $getAsNameArray = true) { |
|
| 105 | 105 | |
| 106 | 106 | //if we don't have it loaded then lets check against the db |
| 107 | 107 | $additional_where = ''; |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | $result = $GLOBALS['db']->query($query); |
| 115 | 115 | $user_roles = array(); |
| 116 | 116 | |
| 117 | - while($row = $GLOBALS['db']->fetchByAssoc($result) ){ |
|
| 117 | + while ($row = $GLOBALS['db']->fetchByAssoc($result)) { |
|
| 118 | 118 | $role = new ACLRole(); |
| 119 | 119 | $role->populateFromRow($row); |
| 120 | - if($getAsNameArray) |
|
| 120 | + if ($getAsNameArray) |
|
| 121 | 121 | $user_roles[] = $role->name; |
| 122 | 122 | else |
| 123 | 123 | $user_roles[] = $role; |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | * @param GUID $user_id |
| 134 | 134 | * @return a list of ACLRole Names |
| 135 | 135 | */ |
| 136 | -function getUserRoleNames($user_id){ |
|
| 136 | +function getUserRoleNames($user_id) { |
|
| 137 | 137 | |
| 138 | 138 | $user_roles = sugar_cache_retrieve("RoleMembershipNames_".$user_id); |
| 139 | 139 | |
| 140 | - if(!$user_roles){ |
|
| 140 | + if (!$user_roles) { |
|
| 141 | 141 | //if we don't have it loaded then lets check against the db |
| 142 | 142 | $additional_where = ''; |
| 143 | 143 | $query = "SELECT acl_roles.* ". |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $result = $GLOBALS['db']->query($query); |
| 150 | 150 | $user_roles = array(); |
| 151 | 151 | |
| 152 | - while($row = $GLOBALS['db']->fetchByAssoc($result) ){ |
|
| 152 | + while ($row = $GLOBALS['db']->fetchByAssoc($result)) { |
|
| 153 | 153 | $user_roles[] = $row['name']; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param boolean $returnAsArray - should it return the results as an array of arrays or as an array of ACLRoles |
| 167 | 167 | * @return either an array of array representations of acl roles or an array of ACLRoles |
| 168 | 168 | */ |
| 169 | -function getAllRoles($returnAsArray = false){ |
|
| 169 | +function getAllRoles($returnAsArray = false) { |
|
| 170 | 170 | $db = DBManagerFactory::getInstance(); |
| 171 | 171 | $query = "SELECT acl_roles.* FROM acl_roles |
| 172 | 172 | WHERE acl_roles.deleted=0 ORDER BY name"; |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | $result = $db->query($query); |
| 175 | 175 | $roles = array(); |
| 176 | 176 | |
| 177 | - while($row = $db->fetchByAssoc($result) ){ |
|
| 177 | + while ($row = $db->fetchByAssoc($result)) { |
|
| 178 | 178 | $role = new ACLRole(); |
| 179 | 179 | $role->populateFromRow($row); |
| 180 | - if($returnAsArray){ |
|
| 180 | + if ($returnAsArray) { |
|
| 181 | 181 | $roles[] = $role->toArray(); |
| 182 | - }else{ |
|
| 182 | + } else { |
|
| 183 | 183 | $roles[] = $role; |
| 184 | 184 | } |
| 185 | 185 | |
@@ -197,41 +197,41 @@ discard block |
||
| 197 | 197 | * @param GUID $role_id |
| 198 | 198 | * @return array of actions |
| 199 | 199 | */ |
| 200 | -function getRoleActions($role_id, $type='module'){ |
|
| 200 | +function getRoleActions($role_id, $type = 'module') { |
|
| 201 | 201 | global $beanList; |
| 202 | 202 | //if we don't have it loaded then lets check against the db |
| 203 | 203 | $additional_where = ''; |
| 204 | 204 | $db = DBManagerFactory::getInstance(); |
| 205 | 205 | $query = "SELECT acl_actions.*"; |
| 206 | 206 | //only if we have a role id do we need to join the table otherwise lets use the ones defined in acl_actions as the defaults |
| 207 | - if(!empty($role_id)){ |
|
| 208 | - $query .=" ,acl_roles_actions.access_override "; |
|
| 207 | + if (!empty($role_id)) { |
|
| 208 | + $query .= " ,acl_roles_actions.access_override "; |
|
| 209 | 209 | } |
| 210 | - $query .=" FROM acl_actions "; |
|
| 210 | + $query .= " FROM acl_actions "; |
|
| 211 | 211 | |
| 212 | - if(!empty($role_id)){ |
|
| 213 | - $query .= " LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = '$role_id' AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted = 0"; |
|
| 212 | + if (!empty($role_id)) { |
|
| 213 | + $query .= " LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = '$role_id' AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted = 0"; |
|
| 214 | 214 | } |
| 215 | 215 | $query .= " WHERE acl_actions.deleted=0 ORDER BY acl_actions.category, acl_actions.name"; |
| 216 | 216 | $result = $db->query($query); |
| 217 | 217 | $role_actions = array(); |
| 218 | 218 | |
| 219 | - while($row = $db->fetchByAssoc($result) ){ |
|
| 219 | + while ($row = $db->fetchByAssoc($result)) { |
|
| 220 | 220 | $action = new ACLAction(); |
| 221 | 221 | $action->populateFromRow($row); |
| 222 | - if(!empty($row['access_override'])){ |
|
| 222 | + if (!empty($row['access_override'])) { |
|
| 223 | 223 | $action->aclaccess = $row['access_override']; |
| 224 | - }else{ |
|
| 224 | + } else { |
|
| 225 | 225 | $action->aclaccess = ACL_ALLOW_DEFAULT; |
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | //#27877 . If there is no this module in beanlist , we will not show them in UI, no matter this module was deleted or not in ACL_ACTIONS table. |
| 229 | - if(empty($beanList[$action->category])){ |
|
| 229 | + if (empty($beanList[$action->category])) { |
|
| 230 | 230 | continue; |
| 231 | 231 | } |
| 232 | 232 | //end |
| 233 | 233 | |
| 234 | - if(!isset($role_actions[$action->category])){ |
|
| 234 | + if (!isset($role_actions[$action->category])) { |
|
| 235 | 235 | $role_actions[$action->category] = array(); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @param ACLRole GUID $id |
| 265 | 265 | */ |
| 266 | -function mark_relationships_deleted($id){ |
|
| 266 | +function mark_relationships_deleted($id) { |
|
| 267 | 267 | //we need to delete the actions relationship by hand (special case) |
| 268 | 268 | $date_modified = db_convert("'".TimeDate::getInstance()->nowDb()."'", 'datetime'); |
| 269 | - $query = "UPDATE acl_roles_actions SET deleted=1 , date_modified=$date_modified WHERE role_id = '$id' AND deleted=0"; |
|
| 269 | + $query = "UPDATE acl_roles_actions SET deleted=1 , date_modified=$date_modified WHERE role_id = '$id' AND deleted=0"; |
|
| 270 | 270 | $this->db->query($query); |
| 271 | 271 | parent::mark_relationships_deleted($id); |
| 272 | 272 | } |
@@ -277,13 +277,13 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @return array of fields with id, name, description |
| 279 | 279 | */ |
| 280 | - function toArray($dbOnly = false, $stringOnly = false, $upperKeys=false){ |
|
| 280 | + function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false) { |
|
| 281 | 281 | $array_fields = array('id', 'name', 'description'); |
| 282 | 282 | $arr = array(); |
| 283 | - foreach($array_fields as $field){ |
|
| 284 | - if(isset($this->$field)){ |
|
| 283 | + foreach ($array_fields as $field) { |
|
| 284 | + if (isset($this->$field)) { |
|
| 285 | 285 | $arr[$field] = $this->$field; |
| 286 | - }else{ |
|
| 286 | + } else { |
|
| 287 | 287 | $arr[$field] = ''; |
| 288 | 288 | } |
| 289 | 289 | } |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @param Array $arr |
| 298 | 298 | */ |
| 299 | - function fromArray($arr){ |
|
| 300 | - foreach($arr as $name=>$value){ |
|
| 299 | + function fromArray($arr) { |
|
| 300 | + foreach ($arr as $name=>$value) { |
|
| 301 | 301 | $this->$name = $value; |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -1,5 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -63,8 +65,7 @@ discard block |
||
| 63 | 65 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 64 | 66 | if(isset($GLOBALS['log'])) { |
| 65 | 67 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 66 | - } |
|
| 67 | - else { |
|
| 68 | + } else { |
|
| 68 | 69 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 69 | 70 | } |
| 70 | 71 | self::__construct(); |
@@ -117,10 +118,11 @@ discard block |
||
| 117 | 118 | while($row = $GLOBALS['db']->fetchByAssoc($result) ){ |
| 118 | 119 | $role = new ACLRole(); |
| 119 | 120 | $role->populateFromRow($row); |
| 120 | - if($getAsNameArray) |
|
| 121 | - $user_roles[] = $role->name; |
|
| 122 | - else |
|
| 123 | - $user_roles[] = $role; |
|
| 121 | + if($getAsNameArray) { |
|
| 122 | + $user_roles[] = $role->name; |
|
| 123 | + } else { |
|
| 124 | + $user_roles[] = $role; |
|
| 125 | + } |
|
| 124 | 126 | } |
| 125 | 127 | |
| 126 | 128 | return $user_roles; |
@@ -179,7 +181,7 @@ discard block |
||
| 179 | 181 | $role->populateFromRow($row); |
| 180 | 182 | if($returnAsArray){ |
| 181 | 183 | $roles[] = $role->toArray(); |
| 182 | - }else{ |
|
| 184 | + } else{ |
|
| 183 | 185 | $roles[] = $role; |
| 184 | 186 | } |
| 185 | 187 | |
@@ -221,7 +223,7 @@ discard block |
||
| 221 | 223 | $action->populateFromRow($row); |
| 222 | 224 | if(!empty($row['access_override'])){ |
| 223 | 225 | $action->aclaccess = $row['access_override']; |
| 224 | - }else{ |
|
| 226 | + } else{ |
|
| 225 | 227 | $action->aclaccess = ACL_ALLOW_DEFAULT; |
| 226 | 228 | |
| 227 | 229 | } |
@@ -252,8 +254,9 @@ discard block |
||
| 252 | 254 | // Fallback to array key if translation is empty |
| 253 | 255 | $a = empty($app_list_strings['moduleList'][$a]) ? $a : $app_list_strings['moduleList'][$a]; |
| 254 | 256 | $b = empty($app_list_strings['moduleList'][$b]) ? $b : $app_list_strings['moduleList'][$b]; |
| 255 | - if ($a == $b) |
|
| 256 | - return 0; |
|
| 257 | + if ($a == $b) { |
|
| 258 | + return 0; |
|
| 259 | + } |
|
| 257 | 260 | return ($a < $b) ? -1 : 1; |
| 258 | 261 | } |
| 259 | 262 | /** |
@@ -283,7 +286,7 @@ discard block |
||
| 283 | 286 | foreach($array_fields as $field){ |
| 284 | 287 | if(isset($this->$field)){ |
| 285 | 288 | $arr[$field] = $this->$field; |
| 286 | - }else{ |
|
| 289 | + } else{ |
|
| 287 | 290 | $arr[$field] = ''; |
| 288 | 291 | } |
| 289 | 292 | } |