@@ -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. |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public $requeue; // Requeue on failure? |
71 | 71 | public $retry_count; |
72 | 72 | public $failure_count; |
73 | - public $job_delay=0; // Frequency to run it |
|
73 | + public $job_delay = 0; // Frequency to run it |
|
74 | 74 | public $assigned_user_id; // User under which the task is running |
75 | 75 | public $client; // Client ID that owns this job |
76 | 76 | public $execute_time_db; |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | |
79 | 79 | // standard SugarBean child attrs |
80 | 80 | var $table_name = "job_queue"; |
81 | - var $object_name = "SchedulersJob"; |
|
81 | + var $object_name = "SchedulersJob"; |
|
82 | 82 | var $module_dir = "SchedulersJobs"; |
83 | 83 | var $new_schema = true; |
84 | 84 | var $process_save_dates = true; |
85 | 85 | // related fields |
86 | - var $job_name; // the Scheduler's 'name' field |
|
87 | - var $job; // the Scheduler's 'job' field |
|
86 | + var $job_name; // the Scheduler's 'name' field |
|
87 | + var $job; // the Scheduler's 'job' field |
|
88 | 88 | // object specific attributes |
89 | 89 | public $user; // User object |
90 | 90 | var $scheduler; // Scheduler parent |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function __construct() |
99 | 99 | { |
100 | 100 | parent::__construct(); |
101 | - if(!empty($GLOBALS['sugar_config']['jobs']['min_retry_interval'])) { |
|
101 | + if (!empty($GLOBALS['sugar_config']['jobs']['min_retry_interval'])) { |
|
102 | 102 | $this->min_interval = $GLOBALS['sugar_config']['jobs']['min_retry_interval']; |
103 | 103 | } |
104 | 104 | } |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @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 |
108 | 108 | */ |
109 | - function SchedulersJob(){ |
|
109 | + function SchedulersJob() { |
|
110 | 110 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
111 | - if(isset($GLOBALS['log'])) { |
|
111 | + if (isset($GLOBALS['log'])) { |
|
112 | 112 | $GLOBALS['log']->deprecated($deprecatedMessage); |
113 | 113 | } |
114 | 114 | else { |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string Formatted datetime value |
137 | 137 | */ |
138 | - function handleDateFormat($date='now', $user=null, $user_format=false) { |
|
138 | + function handleDateFormat($date = 'now', $user = null, $user_format = false) { |
|
139 | 139 | global $timedate; |
140 | 140 | |
141 | - if(!isset($timedate) || empty($timedate)) |
|
141 | + if (!isset($timedate) || empty($timedate)) |
|
142 | 142 | { |
143 | 143 | $timedate = new TimeDate(); |
144 | 144 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | // get user for calculation |
147 | 147 | $user = (empty($user)) ? $this->user : $user; |
148 | 148 | |
149 | - if($date == 'now') |
|
149 | + if ($date == 'now') |
|
150 | 150 | { |
151 | 151 | $dbTime = $timedate->asUser($timedate->getNow(), $user); |
152 | 152 | } else { |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param $job String in URI-clean format |
167 | 167 | * @param $timeout Int value in secs for cURL to timeout. 30 default. |
168 | 168 | */ |
169 | - public function fireUrl($job, $timeout=30) |
|
169 | + public function fireUrl($job, $timeout = 30) |
|
170 | 170 | { |
171 | 171 | // TODO: figure out what error is thrown when no more apache instances can be spun off |
172 | 172 | // cURL inits |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | curl_setopt($ch, CURLOPT_FAILONERROR, true); // silent failure (code >300); |
176 | 176 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // do not follow location(); inits - we always use the current |
177 | 177 | curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); |
178 | - curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); // not thread-safe |
|
178 | + curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); // not thread-safe |
|
179 | 179 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return into a variable to continue program execution |
180 | 180 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // never times out - bad idea? |
181 | 181 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // 5 secs for connect timeout |
182 | - curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); // open brand new conn |
|
182 | + curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); // open brand new conn |
|
183 | 183 | curl_setopt($ch, CURLOPT_HEADER, true); // do not return header info with result |
184 | 184 | curl_setopt($ch, CURLOPT_NOPROGRESS, true); // do not have progress bar |
185 | 185 | $urlparts = parse_url($job); |
186 | - if(empty($urlparts['port'])) { |
|
187 | - if($urlparts['scheme'] == 'https'){ |
|
186 | + if (empty($urlparts['port'])) { |
|
187 | + if ($urlparts['scheme'] == 'https') { |
|
188 | 188 | $urlparts['port'] = 443; |
189 | 189 | } else { |
190 | 190 | $urlparts['port'] = 80; |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | |
198 | 198 | curl_setopt($ch, CURLOPT_NOSIGNAL, true); // ignore any cURL signals to PHP (for multi-threading) |
199 | 199 | $result = curl_exec($ch); |
200 | - $cInfo = curl_getinfo($ch); //url,content_type,header_size,request_size,filetime,http_code |
|
200 | + $cInfo = curl_getinfo($ch); //url,content_type,header_size,request_size,filetime,http_code |
|
201 | 201 | //ssl_verify_result,total_time,namelookup_time,connect_time |
202 | 202 | //pretransfer_time,size_upload,size_download,speed_download, |
203 | 203 | //speed_upload,download_content_length,upload_content_length |
204 | 204 | //starttransfer_time,redirect_time |
205 | - if(curl_errno($ch)) { |
|
205 | + if (curl_errno($ch)) { |
|
206 | 206 | $this->errors .= curl_errno($ch)."\n"; |
207 | 207 | } |
208 | 208 | curl_close($ch); |
209 | 209 | |
210 | - if($result !== FALSE && $cInfo['http_code'] < 400) { |
|
210 | + if ($result !== FALSE && $cInfo['http_code'] < 400) { |
|
211 | 211 | $GLOBALS['log']->debug("----->Firing was successful: $job"); |
212 | 212 | $GLOBALS['log']->debug('----->WTIH RESULT: '.strip_tags($result).' AND '.strip_tags(print_r($cInfo, true))); |
213 | 213 | return true; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | $temp_array = $this->get_list_view_array(); |
233 | 233 | $temp_array['JOB_NAME'] = $this->job_name; |
234 | - $temp_array['JOB'] = $this->job; |
|
234 | + $temp_array['JOB'] = $this->job; |
|
235 | 235 | |
236 | 236 | return $temp_array; |
237 | 237 | } |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | public function resolveJob($resolution, $message = null) |
291 | 291 | { |
292 | 292 | $GLOBALS['log']->info("Resolving job {$this->id} as $resolution: $message"); |
293 | - if($resolution == self::JOB_FAILURE) { |
|
293 | + if ($resolution == self::JOB_FAILURE) { |
|
294 | 294 | $this->failure_count++; |
295 | - if($this->requeue && $this->retry_count > 0) { |
|
295 | + if ($this->requeue && $this->retry_count > 0) { |
|
296 | 296 | // retry failed job |
297 | 297 | $this->status = self::JOB_STATUS_QUEUED; |
298 | - if($this->job_delay < $this->min_interval) { |
|
298 | + if ($this->job_delay < $this->min_interval) { |
|
299 | 299 | $this->job_delay = $this->min_interval; |
300 | 300 | } |
301 | 301 | $this->execute_time = $GLOBALS['timedate']->getNow()->modify("+{$this->job_delay} seconds")->asDb(); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $this->addMessages($message); |
314 | 314 | $this->resolution = $resolution; |
315 | 315 | $this->save(); |
316 | - if($this->status == self::JOB_STATUS_DONE && $this->resolution == self::JOB_SUCCESS) { |
|
316 | + if ($this->status == self::JOB_STATUS_DONE && $this->resolution == self::JOB_SUCCESS) { |
|
317 | 317 | $this->updateSchedulerSuccess(); |
318 | 318 | } |
319 | 319 | return true; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | */ |
325 | 325 | protected function updateSchedulerSuccess() |
326 | 326 | { |
327 | - if(empty($this->scheduler_id)) { |
|
327 | + if (empty($this->scheduler_id)) { |
|
328 | 328 | return; |
329 | 329 | } |
330 | 330 | $this->db->query("UPDATE schedulers SET last_run={$this->db->now()} WHERE id=".$this->db->quoted($this->scheduler_id)); |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | */ |
338 | 338 | protected function addMessages($message) |
339 | 339 | { |
340 | - if(!empty($this->errors)) { |
|
340 | + if (!empty($this->errors)) { |
|
341 | 341 | $this->message .= $this->errors; |
342 | 342 | $this->errors = ''; |
343 | 343 | } |
344 | - if(!empty($message)) { |
|
344 | + if (!empty($message)) { |
|
345 | 345 | $this->message .= "$message\n"; |
346 | 346 | } |
347 | 347 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $this->status = self::JOB_STATUS_QUEUED; |
358 | 358 | $this->addMessages($message); |
359 | 359 | $this->resolution = self::JOB_PARTIAL; |
360 | - if(empty($delay)) { |
|
360 | + if (empty($delay)) { |
|
361 | 361 | $delay = intval($this->job_delay); |
362 | 362 | } |
363 | 363 | $this->execute_time = $GLOBALS['timedate']->getNow()->modify("+$delay seconds")->asDb(); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public function unexpectedExit() |
383 | 383 | { |
384 | - if(!$this->job_done) { |
|
384 | + if (!$this->job_done) { |
|
385 | 385 | // Job wasn't properly finished, fail it |
386 | 386 | $this->resolveJob(self::JOB_FAILURE, translate('ERR_FAILED', 'SchedulersJobs')); |
387 | 387 | } |
@@ -397,15 +397,15 @@ discard block |
||
397 | 397 | { |
398 | 398 | $job = new self(); |
399 | 399 | $job->retrieve($id); |
400 | - if(empty($job->id)) { |
|
400 | + if (empty($job->id)) { |
|
401 | 401 | $GLOBALS['log']->fatal("Job $id not found."); |
402 | 402 | return "Job $id not found."; |
403 | 403 | } |
404 | - if($job->status != self::JOB_STATUS_RUNNING) { |
|
404 | + if ($job->status != self::JOB_STATUS_RUNNING) { |
|
405 | 405 | $GLOBALS['log']->fatal("Job $id is not marked as running."); |
406 | 406 | return "Job $id is not marked as running."; |
407 | 407 | } |
408 | - if($job->client != $client) { |
|
408 | + if ($job->client != $client) { |
|
409 | 409 | $GLOBALS['log']->fatal("Job $id belongs to client {$job->client}, can not run as $client."); |
410 | 410 | return "Job $id belongs to another client, can not run as $client."; |
411 | 411 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public function errorHandler($errno, $errstr, $errfile, $errline) |
427 | 427 | { |
428 | - switch($errno) |
|
428 | + switch ($errno) |
|
429 | 429 | { |
430 | 430 | case E_USER_WARNING: |
431 | 431 | case E_COMPILE_WARNING: |
@@ -461,14 +461,14 @@ discard block |
||
461 | 461 | { |
462 | 462 | $GLOBALS['current_user'] = $user; |
463 | 463 | // Reset the session |
464 | - if(session_id()) { |
|
464 | + if (session_id()) { |
|
465 | 465 | session_destroy(); |
466 | 466 | } |
467 | - if(!headers_sent()) { |
|
467 | + if (!headers_sent()) { |
|
468 | 468 | session_start(); |
469 | 469 | session_regenerate_id(); |
470 | 470 | } |
471 | - $_SESSION['is_valid_session']= true; |
|
471 | + $_SESSION['is_valid_session'] = true; |
|
472 | 472 | $_SESSION['user_id'] = $user->id; |
473 | 473 | $_SESSION['type'] = 'user'; |
474 | 474 | $_SESSION['authenticated_user_id'] = $user->id; |
@@ -481,11 +481,11 @@ discard block |
||
481 | 481 | protected function setJobUser() |
482 | 482 | { |
483 | 483 | // set up the current user and drop session |
484 | - if(!empty($this->assigned_user_id)) { |
|
484 | + if (!empty($this->assigned_user_id)) { |
|
485 | 485 | $this->old_user = $GLOBALS['current_user']; |
486 | - if(empty($this->user->id) || $this->assigned_user_id != $this->user->id) { |
|
486 | + if (empty($this->user->id) || $this->assigned_user_id != $this->user->id) { |
|
487 | 487 | $this->user = BeanFactory::getBean('Users', $this->assigned_user_id); |
488 | - if(empty($this->user->id)) { |
|
488 | + if (empty($this->user->id)) { |
|
489 | 489 | $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_NOSUCHUSER', 'SchedulersJobs'), $this->assigned_user_id)); |
490 | 490 | return false; |
491 | 491 | } |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | */ |
504 | 504 | protected function restoreJobUser() |
505 | 505 | { |
506 | - if(!empty($this->old_user->id) && $this->old_user->id != $this->user->id) { |
|
506 | + if (!empty($this->old_user->id) && $this->old_user->id != $this->user->id) { |
|
507 | 507 | $this->sudo($this->old_user); |
508 | 508 | } |
509 | 509 | } |
@@ -518,27 +518,27 @@ discard block |
||
518 | 518 | |
519 | 519 | $this->errors = ""; |
520 | 520 | $exJob = explode('::', $this->target, 2); |
521 | - if($exJob[0] == 'function') { |
|
521 | + if ($exJob[0] == 'function') { |
|
522 | 522 | // set up the current user and drop session |
523 | - if(!$this->setJobUser()) { |
|
523 | + if (!$this->setJobUser()) { |
|
524 | 524 | return false; |
525 | 525 | } |
526 | 526 | $func = $exJob[1]; |
527 | 527 | $GLOBALS['log']->debug("----->SchedulersJob calling function: $func"); |
528 | 528 | set_error_handler(array($this, "errorHandler"), E_ALL & ~E_NOTICE & ~E_STRICT); |
529 | - if(!is_callable($func)) { |
|
529 | + if (!is_callable($func)) { |
|
530 | 530 | $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_CALL', 'SchedulersJobs'), $func)); |
531 | 531 | } |
532 | 532 | $data = array($this); |
533 | - if(!empty($this->data)) { |
|
533 | + if (!empty($this->data)) { |
|
534 | 534 | $data[] = $this->data; |
535 | 535 | } |
536 | 536 | $res = call_user_func_array($func, $data); |
537 | 537 | restore_error_handler(); |
538 | 538 | $this->restoreJobUser(); |
539 | - if($this->status == self::JOB_STATUS_RUNNING) { |
|
539 | + if ($this->status == self::JOB_STATUS_RUNNING) { |
|
540 | 540 | // nobody updated the status yet - job function could do that |
541 | - if($res) { |
|
541 | + if ($res) { |
|
542 | 542 | $this->resolveJob(self::JOB_SUCCESS); |
543 | 543 | return true; |
544 | 544 | } else { |
@@ -548,11 +548,11 @@ discard block |
||
548 | 548 | } else { |
549 | 549 | return $this->resolution != self::JOB_FAILURE; |
550 | 550 | } |
551 | - } elseif($exJob[0] == 'url') { |
|
552 | - if(function_exists('curl_init')) { |
|
551 | + } elseif ($exJob[0] == 'url') { |
|
552 | + if (function_exists('curl_init')) { |
|
553 | 553 | $GLOBALS['log']->debug('----->SchedulersJob firing URL job: '.$exJob[1]); |
554 | 554 | set_error_handler(array($this, "errorHandler"), E_ALL & ~E_NOTICE & ~E_STRICT); |
555 | - if($this->fireUrl($exJob[1])) { |
|
555 | + if ($this->fireUrl($exJob[1])) { |
|
556 | 556 | restore_error_handler(); |
557 | 557 | $this->resolveJob(self::JOB_SUCCESS); |
558 | 558 | return true; |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | } |
567 | 567 | } elseif ($exJob[0] == 'class') { |
568 | 568 | $tmpJob = new $exJob[1](); |
569 | - if($tmpJob instanceof RunnableSchedulerJob) |
|
569 | + if ($tmpJob instanceof RunnableSchedulerJob) |
|
570 | 570 | { |
571 | 571 | // set up the current user and drop session |
572 | - if(!$this->setJobUser()) { |
|
572 | + if (!$this->setJobUser()) { |
|
573 | 573 | return false; |
574 | 574 | } |
575 | 575 | $tmpJob->setJob($this); |
@@ -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. |
@@ -110,8 +112,7 @@ discard block |
||
110 | 112 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
111 | 113 | if(isset($GLOBALS['log'])) { |
112 | 114 | $GLOBALS['log']->deprecated($deprecatedMessage); |
113 | - } |
|
114 | - else { |
|
115 | + } else { |
|
115 | 116 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
116 | 117 | } |
117 | 118 | self::__construct(); |
@@ -587,12 +588,10 @@ discard block |
||
587 | 588 | } else { |
588 | 589 | return $this->resolution != self::JOB_FAILURE; |
589 | 590 | } |
590 | - } |
|
591 | - else { |
|
591 | + } else { |
|
592 | 592 | $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_JOBTYPE', 'SchedulersJobs'), strip_tags($this->target))); |
593 | 593 | } |
594 | - } |
|
595 | - else { |
|
594 | + } else { |
|
596 | 595 | $this->resolveJob(self::JOB_FAILURE, sprintf(translate('ERR_JOBTYPE', 'SchedulersJobs'), strip_tags($this->target))); |
597 | 596 | } |
598 | 597 | return false; |
@@ -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 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | - class ConnectorRecord extends MergeRecord{ |
|
44 | + class ConnectorRecord extends MergeRecord { |
|
45 | 45 | var $object_name = 'ConnectorRecord'; |
46 | 46 | var $module_dir = 'Connector'; |
47 | 47 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @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 |
55 | 55 | */ |
56 | - function ConnectorRecord($merge_module = '', $merge_id = ''){ |
|
56 | + function ConnectorRecord($merge_module = '', $merge_id = '') { |
|
57 | 57 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
58 | - if(isset($GLOBALS['log'])) { |
|
58 | + if (isset($GLOBALS['log'])) { |
|
59 | 59 | $GLOBALS['log']->deprecated($deprecatedMessage); |
60 | 60 | } |
61 | 61 | else { |
@@ -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. |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39 | 39 | ********************************************************************************/ |
40 | 40 | /* BEGIN - SECURITY GROUPS */ |
41 | -if(file_exists("modules/ACLActions/actiondefs.override.php")){ |
|
41 | +if (file_exists("modules/ACLActions/actiondefs.override.php")) { |
|
42 | 42 | require_once("modules/ACLActions/actiondefs.override.php"); |
43 | 43 | } else { |
44 | 44 | require_once('modules/ACLActions/actiondefs.php'); |
45 | 45 | } |
46 | 46 | /* END - SECURITY GROUPS */ |
47 | -class ACLAction extends SugarBean{ |
|
47 | +class ACLAction extends SugarBean { |
|
48 | 48 | var $module_dir = 'ACLActions'; |
49 | 49 | var $object_name = 'ACLAction'; |
50 | 50 | var $table_name = 'acl_actions'; |
51 | 51 | var $new_schema = true; |
52 | 52 | var $disable_custom_fields = true; |
53 | 53 | |
54 | - public function __construct(){ |
|
54 | + public function __construct() { |
|
55 | 55 | parent::__construct(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @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 |
60 | 60 | */ |
61 | - public function ACLAction(){ |
|
61 | + public function ACLAction() { |
|
62 | 62 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
63 | - if(isset($GLOBALS['log'])) { |
|
63 | + if (isset($GLOBALS['log'])) { |
|
64 | 64 | $GLOBALS['log']->deprecated($deprecatedMessage); |
65 | 65 | } |
66 | 66 | else { |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
78 | 78 | * @param STRING $type - the type (e.g. 'module', 'field') |
79 | 79 | */ |
80 | - static function addActions($category, $type='module'){ |
|
80 | + static function addActions($category, $type = 'module') { |
|
81 | 81 | global $ACLActions; |
82 | 82 | $db = DBManagerFactory::getInstance(); |
83 | - if(isset($ACLActions[$type])){ |
|
84 | - foreach($ACLActions[$type]['actions'] as $action_name =>$action_def){ |
|
83 | + if (isset($ACLActions[$type])) { |
|
84 | + foreach ($ACLActions[$type]['actions'] as $action_name =>$action_def) { |
|
85 | 85 | |
86 | 86 | $action = new ACLAction(); |
87 | - $query = "SELECT * FROM " . $action->table_name . " WHERE name='$action_name' AND category = '$category' AND acltype='$type' AND deleted=0 "; |
|
87 | + $query = "SELECT * FROM ".$action->table_name." WHERE name='$action_name' AND category = '$category' AND acltype='$type' AND deleted=0 "; |
|
88 | 88 | $result = $db->query($query); |
89 | 89 | //only add if an action with that name and category don't exist |
90 | - $row=$db->fetchByAssoc($result); |
|
90 | + $row = $db->fetchByAssoc($result); |
|
91 | 91 | if ($row == null) { |
92 | 92 | $action->name = $action_name; |
93 | 93 | $action->category = $category; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - }else{ |
|
103 | + } else { |
|
104 | 104 | sugar_die("FAILED TO ADD: $category - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
105 | 105 | } |
106 | 106 | |
@@ -113,22 +113,22 @@ discard block |
||
113 | 113 | * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
114 | 114 | * @param STRING $type - the type (e.g. 'module', 'field') |
115 | 115 | */ |
116 | - public static function removeActions($category, $type='module'){ |
|
116 | + public static function removeActions($category, $type = 'module') { |
|
117 | 117 | global $ACLActions; |
118 | 118 | $db = DBManagerFactory::getInstance(); |
119 | - if(isset($ACLActions[$type])){ |
|
120 | - foreach($ACLActions[$type]['actions'] as $action_name =>$action_def){ |
|
119 | + if (isset($ACLActions[$type])) { |
|
120 | + foreach ($ACLActions[$type]['actions'] as $action_name =>$action_def) { |
|
121 | 121 | |
122 | 122 | $action = new ACLAction(); |
123 | - $query = "SELECT * FROM " . $action->table_name . " WHERE name='$action_name' AND category = '$category' AND acltype='$type' and deleted=0"; |
|
123 | + $query = "SELECT * FROM ".$action->table_name." WHERE name='$action_name' AND category = '$category' AND acltype='$type' and deleted=0"; |
|
124 | 124 | $result = $db->query($query); |
125 | 125 | //only add if an action with that name and category don't exist |
126 | - $row=$db->fetchByAssoc($result); |
|
126 | + $row = $db->fetchByAssoc($result); |
|
127 | 127 | if ($row != null) { |
128 | 128 | $action->mark_deleted($row['id']); |
129 | 129 | } |
130 | 130 | } |
131 | - }else{ |
|
131 | + } else { |
|
132 | 132 | sugar_die("FAILED TO REMOVE: $category : $name - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
133 | 133 | } |
134 | 134 | } |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @param INT $access - the access level you want the color for |
142 | 142 | * @return the color either name or hex representation or false if the level does not exist |
143 | 143 | */ |
144 | - protected static function AccessColor($access){ |
|
144 | + protected static function AccessColor($access) { |
|
145 | 145 | global $ACLActionAccessLevels; |
146 | - if(isset($ACLActionAccessLevels[$access])){ |
|
146 | + if (isset($ACLActionAccessLevels[$access])) { |
|
147 | 147 | |
148 | 148 | return $ACLActionAccessLevels[$access]['color']; |
149 | 149 | } |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | * @param INT $access - the access level you want the color for |
160 | 160 | * @return the translated access level name or false if the level does not exist |
161 | 161 | */ |
162 | - static function AccessName($access){ |
|
162 | + static function AccessName($access) { |
|
163 | 163 | global $ACLActionAccessLevels; |
164 | - if(isset($ACLActionAccessLevels[$access])){ |
|
164 | + if (isset($ACLActionAccessLevels[$access])) { |
|
165 | 165 | return translate($ACLActionAccessLevels[$access]['label'], 'ACLActions'); |
166 | 166 | } |
167 | 167 | return false; |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | * @param INT $access - the access level you want the color for |
177 | 177 | * @return the access level label or false if the level does not exist |
178 | 178 | */ |
179 | - protected static function AccessLabel($access){ |
|
179 | + protected static function AccessLabel($access) { |
|
180 | 180 | global $ACLActionAccessLevels; |
181 | - if(isset($ACLActionAccessLevels[$access])){ |
|
182 | - $label=preg_replace('/(LBL_ACCESS_)(.*)/', '$2', $ACLActionAccessLevels[$access]['label']); |
|
181 | + if (isset($ACLActionAccessLevels[$access])) { |
|
182 | + $label = preg_replace('/(LBL_ACCESS_)(.*)/', '$2', $ACLActionAccessLevels[$access]['label']); |
|
183 | 183 | return strtolower($label); |
184 | 184 | |
185 | 185 | } |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | * this is used for building select boxes |
193 | 193 | * @return array containg access levels (ints) as keys and access names as values |
194 | 194 | */ |
195 | - protected static function getAccessOptions( $action, $type='module'){ |
|
195 | + protected static function getAccessOptions($action, $type = 'module') { |
|
196 | 196 | global $ACLActions; |
197 | 197 | $options = array(); |
198 | 198 | |
199 | - if(empty($ACLActions[$type]['actions'][$action]['aclaccess']))return $options; |
|
200 | - foreach($ACLActions[$type]['actions'][$action]['aclaccess'] as $action){ |
|
199 | + if (empty($ACLActions[$type]['actions'][$action]['aclaccess']))return $options; |
|
200 | + foreach ($ACLActions[$type]['actions'][$action]['aclaccess'] as $action) { |
|
201 | 201 | $options[$action] = ACLAction::AccessName($action); |
202 | 202 | } |
203 | 203 | return $options; |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | * |
211 | 211 | * |
212 | 212 | */ |
213 | - public static function getDefaultActions($type='module', $action=''){ |
|
213 | + public static function getDefaultActions($type = 'module', $action = '') { |
|
214 | 214 | $query = "SELECT * FROM acl_actions WHERE deleted=0 "; |
215 | - if(!empty($type)){ |
|
215 | + if (!empty($type)) { |
|
216 | 216 | $query .= " AND acltype='$type'"; |
217 | 217 | } |
218 | - if(!empty($action)){ |
|
218 | + if (!empty($action)) { |
|
219 | 219 | $query .= "AND name='$action'"; |
220 | 220 | } |
221 | 221 | $query .= " ORDER BY category"; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $db = DBManagerFactory::getInstance(); |
224 | 224 | $result = $db->query($query); |
225 | 225 | $default_actions = array(); |
226 | - while($row = $db->fetchByAssoc($result) ){ |
|
226 | + while ($row = $db->fetchByAssoc($result)) { |
|
227 | 227 | $acl = new ACLAction(); |
228 | 228 | $acl->populateFromRow($row); |
229 | 229 | $default_actions[] = $acl; |
@@ -242,19 +242,19 @@ discard block |
||
242 | 242 | * @return ARRAY of ACLActionsArray |
243 | 243 | */ |
244 | 244 | |
245 | - static function getUserActions($user_id,$refresh=false, $category='',$type='', $action=''){ |
|
245 | + static function getUserActions($user_id, $refresh = false, $category = '', $type = '', $action = '') { |
|
246 | 246 | //check in the session if we already have it loaded |
247 | - if(!$refresh && !empty($_SESSION['ACL'][$user_id])){ |
|
248 | - if(empty($category) && empty($action)){ |
|
247 | + if (!$refresh && !empty($_SESSION['ACL'][$user_id])) { |
|
248 | + if (empty($category) && empty($action)) { |
|
249 | 249 | return $_SESSION['ACL'][$user_id]; |
250 | - }else{ |
|
251 | - if(!empty($category) && isset($_SESSION['ACL'][$user_id][$category])){ |
|
252 | - if(empty($action)){ |
|
253 | - if(empty($type)){ |
|
250 | + } else { |
|
251 | + if (!empty($category) && isset($_SESSION['ACL'][$user_id][$category])) { |
|
252 | + if (empty($action)) { |
|
253 | + if (empty($type)) { |
|
254 | 254 | return $_SESSION['ACL'][$user_id][$category]; |
255 | 255 | } |
256 | 256 | return $_SESSION['ACL'][$user_id][$category][$type]; |
257 | - }else if(!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
257 | + } else if (!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
258 | 258 | return $_SESSION['ACL'][$user_id][$category][$type][$action]; |
259 | 259 | } |
260 | 260 | } |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | //if we don't have it loaded then lets check against the db |
264 | 264 | $additional_where = ''; |
265 | 265 | $db = DBManagerFactory::getInstance(); |
266 | - if(!empty($category)){ |
|
266 | + if (!empty($category)) { |
|
267 | 267 | $additional_where .= " AND acl_actions.category = '$category' "; |
268 | 268 | } |
269 | - if(!empty($action)){ |
|
269 | + if (!empty($action)) { |
|
270 | 270 | $additional_where .= " AND acl_actions.name = '$action' "; |
271 | 271 | } |
272 | - if(!empty($type)){ |
|
272 | + if (!empty($type)) { |
|
273 | 273 | $additional_where .= " AND acl_actions.acltype = '$type' "; |
274 | 274 | } |
275 | 275 | /* BEGIN - SECURITY GROUPS */ |
@@ -310,38 +310,38 @@ discard block |
||
310 | 310 | $has_user_role = false; //used for user_role_precedence |
311 | 311 | $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults |
312 | 312 | /* END - SECURITY GROUPS */ |
313 | - while($row = $db->fetchByAssoc($result, FALSE) ){ |
|
313 | + while ($row = $db->fetchByAssoc($result, FALSE)) { |
|
314 | 314 | /* BEGIN - SECURITY GROUPS */ |
315 | - if($has_user_role == false && $row['user_role'] == 1) { |
|
315 | + if ($has_user_role == false && $row['user_role'] == 1) { |
|
316 | 316 | $has_user_role = true; |
317 | 317 | } |
318 | - if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) { |
|
318 | + if ($has_role == false && ($row['user_role'] == 1 || $row['user_role'] == 0)) { |
|
319 | 319 | $has_role = true; |
320 | 320 | } |
321 | 321 | //if user roles should take precedence over group roles and we have a user role |
322 | 322 | //break when we get to processing the group roles |
323 | - if($has_user_role == true && $row['user_role'] == 0 |
|
323 | + if ($has_user_role == true && $row['user_role'] == 0 |
|
324 | 324 | && isset($sugar_config['securitysuite_user_role_precedence']) |
325 | - && $sugar_config['securitysuite_user_role_precedence'] == true ) |
|
325 | + && $sugar_config['securitysuite_user_role_precedence'] == true) |
|
326 | 326 | { |
327 | 327 | break; |
328 | 328 | } |
329 | - if($row['user_role'] == -1 && $has_role == true) { |
|
329 | + if ($row['user_role'] == -1 && $has_role == true) { |
|
330 | 330 | break; //no need for default actions when a role is assigned to the user or user's group already |
331 | 331 | } |
332 | 332 | /* END - SECURITY GROUPS */ |
333 | 333 | $acl = new ACLAction(); |
334 | - $isOverride = false; |
|
334 | + $isOverride = false; |
|
335 | 335 | $acl->populateFromRow($row); |
336 | - if(!empty($row['access_override'])){ |
|
336 | + if (!empty($row['access_override'])) { |
|
337 | 337 | $acl->aclaccess = $row['access_override']; |
338 | 338 | $isOverride = true; |
339 | 339 | } |
340 | - if(!isset($selected_actions[$acl->category])){ |
|
340 | + if (!isset($selected_actions[$acl->category])) { |
|
341 | 341 | $selected_actions[$acl->category] = array(); |
342 | 342 | |
343 | 343 | } |
344 | - if(!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
|
344 | + if (!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
|
345 | 345 | || ( |
346 | 346 | /* BEGIN - SECURITY GROUPS - additive security*/ |
347 | 347 | ( |
@@ -369,18 +369,18 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | //only set the session variable if it was a full list; |
372 | - if(empty($category) && empty($action)){ |
|
373 | - if(!isset($_SESSION['ACL'])){ |
|
372 | + if (empty($category) && empty($action)) { |
|
373 | + if (!isset($_SESSION['ACL'])) { |
|
374 | 374 | $_SESSION['ACL'] = array(); |
375 | 375 | } |
376 | 376 | $_SESSION['ACL'][$user_id] = $selected_actions; |
377 | - }else{ |
|
378 | - if(empty($action) && !empty($category)){ |
|
379 | - if(!empty($type)){ |
|
380 | - $_SESSION['ACL'][$user_id][$category][$type] = $selected_actions[$category][$type];} |
|
377 | + } else { |
|
378 | + if (empty($action) && !empty($category)) { |
|
379 | + if (!empty($type)) { |
|
380 | + $_SESSION['ACL'][$user_id][$category][$type] = $selected_actions[$category][$type]; } |
|
381 | 381 | $_SESSION['ACL'][$user_id][$category] = $selected_actions[$category]; |
382 | - }else{ |
|
383 | - if(!empty($action) && !empty($category) && !empty($type)){ |
|
382 | + } else { |
|
383 | + if (!empty($action) && !empty($category) && !empty($type)) { |
|
384 | 384 | $_SESSION['ACL'][$user_id][$category][$type][$action] = $selected_actions[$category][$action]; |
385 | 385 | |
386 | 386 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | /** |
417 | 417 | static function hasAccess($is_owner=false, $access = 0){ |
418 | 418 | */ |
419 | - static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){ |
|
419 | + static function hasAccess($is_owner = false, $in_group = false, $access = 0, ACLAction $action = null) { |
|
420 | 420 | /** |
421 | 421 | if($access != 0 && $access == ACL_ALLOW_ALL || ($is_owner && $access == ACL_ALLOW_OWNER))return true; |
422 | 422 | //if this exists, then this function is not static, so check the aclaccess parameter |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | return true; |
426 | 426 | } |
427 | 427 | */ |
428 | - if($access != 0 && ($access == ACL_ALLOW_ALL |
|
429 | - || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) ) //if owner that's better than in group so count it...better way to clean this up? |
|
428 | + if ($access != 0 && ($access == ACL_ALLOW_ALL |
|
429 | + || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) //if owner that's better than in group so count it...better way to clean this up? |
|
430 | 430 | || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
431 | 431 | )) { |
432 | 432 | return true; |
433 | 433 | } |
434 | - if(!is_null($action) && isset($action->aclaccess)){ |
|
435 | - if($action->aclaccess == ACL_ALLOW_ALL |
|
434 | + if (!is_null($action) && isset($action->aclaccess)) { |
|
435 | + if ($action->aclaccess == ACL_ALLOW_ALL |
|
436 | 436 | || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) |
437 | 437 | || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
438 | 438 | ) { |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | * @param STRING $type |
455 | 455 | * @return boolean |
456 | 456 | */ |
457 | - static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){ |
|
457 | + static function userNeedsSecurityGroup($user_id, $category, $action, $type = 'module') { |
|
458 | 458 | //check if we don't have it set in the cache if not lets reload the cache |
459 | 459 | |
460 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
460 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
461 | 461 | ACLAction::getUserActions($user_id, false); |
462 | 462 | |
463 | 463 | } |
464 | 464 | |
465 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
465 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
466 | 466 | return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP; |
467 | 467 | } |
468 | 468 | return false; |
@@ -488,19 +488,19 @@ discard block |
||
488 | 488 | /** |
489 | 489 | public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false){ |
490 | 490 | */ |
491 | - public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){ |
|
491 | + public static function userHasAccess($user_id, $category, $action, $type = 'module', $is_owner = false, $in_group = false) { |
|
492 | 492 | global $current_user; |
493 | - if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){ |
|
493 | + if ($current_user->isAdminForModule($category) && !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])) { |
|
494 | 494 | return true; |
495 | 495 | } |
496 | 496 | //check if we don't have it set in the cache if not lets reload the cache |
497 | - if(ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) return false; |
|
498 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
497 | + if (ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) return false; |
|
498 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
499 | 499 | ACLAction::getUserActions($user_id, false); |
500 | 500 | |
501 | 501 | } |
502 | 502 | |
503 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
503 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
504 | 504 | /** |
505 | 505 | return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
506 | 506 | */ |
@@ -520,12 +520,12 @@ discard block |
||
520 | 520 | * @param STRING $type |
521 | 521 | * @return INT (ACCESS LEVEL) |
522 | 522 | */ |
523 | - public static function getUserAccessLevel($user_id, $category, $action,$type='module'){ |
|
524 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
523 | + public static function getUserAccessLevel($user_id, $category, $action, $type = 'module') { |
|
524 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
525 | 525 | ACLAction::getUserActions($user_id, false); |
526 | 526 | |
527 | 527 | } |
528 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
528 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
529 | 529 | if (!empty($_SESSION['ACL'][$user_id][$category][$type]['admin']) && $_SESSION['ACL'][$user_id][$category][$type]['admin']['aclaccess'] >= ACL_ALLOW_ADMIN) |
530 | 530 | { |
531 | 531 | // If you have admin access for a module, all ACL's are allowed |
@@ -545,16 +545,16 @@ discard block |
||
545 | 545 | * @param STRING $type |
546 | 546 | * @return boolean |
547 | 547 | */ |
548 | - public static function userNeedsOwnership($user_id, $category, $action,$type='module'){ |
|
548 | + public static function userNeedsOwnership($user_id, $category, $action, $type = 'module') { |
|
549 | 549 | //check if we don't have it set in the cache if not lets reload the cache |
550 | 550 | |
551 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
551 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
552 | 552 | ACLAction::getUserActions($user_id, false); |
553 | 553 | |
554 | 554 | } |
555 | 555 | |
556 | 556 | |
557 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
557 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
558 | 558 | return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_OWNER; |
559 | 559 | } |
560 | 560 | return false; |
@@ -567,18 +567,18 @@ discard block |
||
567 | 567 | * |
568 | 568 | * @param unknown_type $categories |
569 | 569 | */ |
570 | - public static function setupCategoriesMatrix(&$categories){ |
|
570 | + public static function setupCategoriesMatrix(&$categories) { |
|
571 | 571 | global $ACLActions, $current_user; |
572 | 572 | $names = array(); |
573 | 573 | $disabled = array(); |
574 | - foreach($categories as $cat_name=>$category){ |
|
575 | - foreach($category as $type_name=>$type){ |
|
576 | - foreach($type as $act_name=>$action){ |
|
574 | + foreach ($categories as $cat_name=>$category) { |
|
575 | + foreach ($category as $type_name=>$type) { |
|
576 | + foreach ($type as $act_name=>$action) { |
|
577 | 577 | $names[$act_name] = translate($ACLActions[$type_name]['actions'][$act_name]['label'], 'ACLActions'); |
578 | 578 | $categories[$cat_name][$type_name][$act_name]['accessColor'] = ACLAction::AccessColor($action['aclaccess']); |
579 | - if($type_name== 'module'){ |
|
579 | + if ($type_name == 'module') { |
|
580 | 580 | |
581 | - if($act_name != 'aclaccess' && $categories[$cat_name]['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED){ |
|
581 | + if ($act_name != 'aclaccess' && $categories[$cat_name]['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED) { |
|
582 | 582 | $categories[$cat_name][$type_name][$act_name]['accessColor'] = 'darkgray'; |
583 | 583 | $disabled[] = $cat_name; |
584 | 584 | } |
@@ -587,19 +587,19 @@ discard block |
||
587 | 587 | $categories[$cat_name][$type_name][$act_name]['accessName'] = ACLAction::AccessName($action['aclaccess']); |
588 | 588 | $categories[$cat_name][$type_name][$act_name]['accessLabel'] = ACLAction::AccessLabel($action['aclaccess']); |
589 | 589 | |
590 | - if($cat_name=='Users'&& $act_name=='admin'){ |
|
591 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEFAULT]=ACLAction::AccessName(ACL_ALLOW_DEFAULT);; |
|
592 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEV]=ACLAction::AccessName(ACL_ALLOW_DEV);; |
|
590 | + if ($cat_name == 'Users' && $act_name == 'admin') { |
|
591 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEFAULT] = ACLAction::AccessName(ACL_ALLOW_DEFAULT); ; |
|
592 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEV] = ACLAction::AccessName(ACL_ALLOW_DEV); ; |
|
593 | 593 | } |
594 | - else{ |
|
595 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'] = ACLAction::getAccessOptions($act_name, $type_name); |
|
594 | + else { |
|
595 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'] = ACLAction::getAccessOptions($act_name, $type_name); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
601 | - if(!is_admin($current_user)){ |
|
602 | - foreach($disabled as $cat_name){ |
|
601 | + if (!is_admin($current_user)) { |
|
602 | + foreach ($disabled as $cat_name) { |
|
603 | 603 | unset($categories[$cat_name]); |
604 | 604 | } |
605 | 605 | } |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | * |
615 | 615 | * @return array of fields with id, name, access and category |
616 | 616 | */ |
617 | - function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false){ |
|
617 | + function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false) { |
|
618 | 618 | $array_fields = array('id', 'aclaccess'); |
619 | 619 | $arr = array(); |
620 | - foreach($array_fields as $field){ |
|
620 | + foreach ($array_fields as $field) { |
|
621 | 621 | $arr[$field] = $this->$field; |
622 | 622 | } |
623 | 623 | return $arr; |
@@ -629,8 +629,8 @@ discard block |
||
629 | 629 | * |
630 | 630 | * @param Array $arr |
631 | 631 | */ |
632 | - function fromArray($arr){ |
|
633 | - foreach($arr as $name=>$value){ |
|
632 | + function fromArray($arr) { |
|
633 | + foreach ($arr as $name=>$value) { |
|
634 | 634 | $this->$name = $value; |
635 | 635 | } |
636 | 636 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * clears the session variable storing the cache information for acls |
641 | 641 | * |
642 | 642 | */ |
643 | - function clearSessionCache(){ |
|
643 | + function clearSessionCache() { |
|
644 | 644 | unset($_SESSION['ACL']); |
645 | 645 | } |
646 | 646 |
@@ -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. |
@@ -62,8 +64,7 @@ discard block |
||
62 | 64 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
63 | 65 | if(isset($GLOBALS['log'])) { |
64 | 66 | $GLOBALS['log']->deprecated($deprecatedMessage); |
65 | - } |
|
66 | - else { |
|
67 | + } else { |
|
67 | 68 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
68 | 69 | } |
69 | 70 | self::__construct(); |
@@ -100,7 +101,7 @@ discard block |
||
100 | 101 | } |
101 | 102 | } |
102 | 103 | |
103 | - }else{ |
|
104 | + } else{ |
|
104 | 105 | sugar_die("FAILED TO ADD: $category - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
105 | 106 | } |
106 | 107 | |
@@ -128,7 +129,7 @@ discard block |
||
128 | 129 | $action->mark_deleted($row['id']); |
129 | 130 | } |
130 | 131 | } |
131 | - }else{ |
|
132 | + } else{ |
|
132 | 133 | sugar_die("FAILED TO REMOVE: $category : $name - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
133 | 134 | } |
134 | 135 | } |
@@ -196,7 +197,9 @@ discard block |
||
196 | 197 | global $ACLActions; |
197 | 198 | $options = array(); |
198 | 199 | |
199 | - if(empty($ACLActions[$type]['actions'][$action]['aclaccess']))return $options; |
|
200 | + if(empty($ACLActions[$type]['actions'][$action]['aclaccess'])) { |
|
201 | + return $options; |
|
202 | + } |
|
200 | 203 | foreach($ACLActions[$type]['actions'][$action]['aclaccess'] as $action){ |
201 | 204 | $options[$action] = ACLAction::AccessName($action); |
202 | 205 | } |
@@ -247,14 +250,14 @@ discard block |
||
247 | 250 | if(!$refresh && !empty($_SESSION['ACL'][$user_id])){ |
248 | 251 | if(empty($category) && empty($action)){ |
249 | 252 | return $_SESSION['ACL'][$user_id]; |
250 | - }else{ |
|
253 | + } else{ |
|
251 | 254 | if(!empty($category) && isset($_SESSION['ACL'][$user_id][$category])){ |
252 | 255 | if(empty($action)){ |
253 | 256 | if(empty($type)){ |
254 | 257 | return $_SESSION['ACL'][$user_id][$category]; |
255 | 258 | } |
256 | 259 | return $_SESSION['ACL'][$user_id][$category][$type]; |
257 | - }else if(!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
260 | + } else if(!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
258 | 261 | return $_SESSION['ACL'][$user_id][$category][$type][$action]; |
259 | 262 | } |
260 | 263 | } |
@@ -374,12 +377,12 @@ discard block |
||
374 | 377 | $_SESSION['ACL'] = array(); |
375 | 378 | } |
376 | 379 | $_SESSION['ACL'][$user_id] = $selected_actions; |
377 | - }else{ |
|
380 | + } else{ |
|
378 | 381 | if(empty($action) && !empty($category)){ |
379 | 382 | if(!empty($type)){ |
380 | 383 | $_SESSION['ACL'][$user_id][$category][$type] = $selected_actions[$category][$type];} |
381 | 384 | $_SESSION['ACL'][$user_id][$category] = $selected_actions[$category]; |
382 | - }else{ |
|
385 | + } else{ |
|
383 | 386 | if(!empty($action) && !empty($category) && !empty($type)){ |
384 | 387 | $_SESSION['ACL'][$user_id][$category][$type][$action] = $selected_actions[$category][$action]; |
385 | 388 | |
@@ -398,8 +401,9 @@ discard block |
||
398 | 401 | // Fallback to array key if translation is empty |
399 | 402 | $a = empty($app_list_strings['moduleList'][$a]) ? $a : $app_list_strings['moduleList'][$a]; |
400 | 403 | $b = empty($app_list_strings['moduleList'][$b]) ? $b : $app_list_strings['moduleList'][$b]; |
401 | - if ($a == $b) |
|
402 | - return 0; |
|
404 | + if ($a == $b) { |
|
405 | + return 0; |
|
406 | + } |
|
403 | 407 | return ($a < $b) ? -1 : 1; |
404 | 408 | } |
405 | 409 | |
@@ -494,7 +498,9 @@ discard block |
||
494 | 498 | return true; |
495 | 499 | } |
496 | 500 | //check if we don't have it set in the cache if not lets reload the cache |
497 | - if(ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) return false; |
|
501 | + if(ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) { |
|
502 | + return false; |
|
503 | + } |
|
498 | 504 | if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
499 | 505 | ACLAction::getUserActions($user_id, false); |
500 | 506 | |
@@ -590,8 +596,7 @@ discard block |
||
590 | 596 | if($cat_name=='Users'&& $act_name=='admin'){ |
591 | 597 | $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEFAULT]=ACLAction::AccessName(ACL_ALLOW_DEFAULT);; |
592 | 598 | $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEV]=ACLAction::AccessName(ACL_ALLOW_DEV);; |
593 | - } |
|
594 | - else{ |
|
599 | + } else{ |
|
595 | 600 | $categories[$cat_name][$type_name][$act_name]['accessOptions'] = ACLAction::getAccessOptions($act_name, $type_name); |
596 | 601 | } |
597 | 602 | } |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | * |
49 | 49 | */ |
50 | 50 | class SugarAuthenticate{ |
51 | - var $userAuthenticateClass = 'SugarAuthenticateUser'; |
|
52 | - var $authenticationDir = 'SugarAuthenticate'; |
|
53 | - /** |
|
54 | - * Constructs SugarAuthenticate |
|
55 | - * This will load the user authentication class |
|
56 | - * |
|
57 | - * @return SugarAuthenticate |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - // check in custom dir first, in case someone want's to override an auth controller |
|
62 | - if (file_exists('custom/modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
|
51 | + var $userAuthenticateClass = 'SugarAuthenticateUser'; |
|
52 | + var $authenticationDir = 'SugarAuthenticate'; |
|
53 | + /** |
|
54 | + * Constructs SugarAuthenticate |
|
55 | + * This will load the user authentication class |
|
56 | + * |
|
57 | + * @return SugarAuthenticate |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + // check in custom dir first, in case someone want's to override an auth controller |
|
62 | + if (file_exists('custom/modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
|
63 | 63 | require_once('custom/modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php'); |
64 | 64 | } |
65 | 65 | elseif (file_exists('modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
@@ -67,282 +67,282 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | $this->userAuthenticate = new $this->userAuthenticateClass(); |
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @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 |
|
74 | - */ |
|
75 | - public function SugarAuthenticate(){ |
|
76 | - $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
77 | - if(isset($GLOBALS['log'])) { |
|
78 | - $GLOBALS['log']->deprecated($deprecatedMessage); |
|
79 | - } |
|
80 | - else { |
|
81 | - trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
82 | - } |
|
83 | - self::__construct(); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Authenticates a user based on the username and password |
|
88 | - * returns true if the user was authenticated false otherwise |
|
89 | - * it also will load the user into current user if he was authenticated |
|
90 | - * |
|
91 | - * @param string $username |
|
92 | - * @param string $password |
|
93 | - * @return boolean |
|
94 | - */ |
|
95 | - function loginAuthenticate($username, $password, $fallback=false, $PARAMS = array ()){ |
|
96 | - global $mod_strings; |
|
97 | - unset($_SESSION['login_error']); |
|
98 | - $usr= new user(); |
|
99 | - $usr_id=$usr->retrieve_user_id($username); |
|
100 | - $usr->retrieve($usr_id); |
|
101 | - $_SESSION['login_error']=''; |
|
102 | - $_SESSION['waiting_error']=''; |
|
103 | - $_SESSION['hasExpiredPassword']='0'; |
|
104 | - if ($this->userAuthenticate->loadUserOnLogin($username, $password, $fallback, $PARAMS)) { |
|
105 | - require_once('modules/Users/password_utils.php'); |
|
106 | - if(hasPasswordExpired($username)) { |
|
107 | - $_SESSION['hasExpiredPassword'] = '1'; |
|
108 | - } |
|
109 | - // now that user is authenticated, reset loginfailed |
|
110 | - if ($usr->getPreference('loginfailed') != '' && $usr->getPreference('loginfailed') != 0) { |
|
111 | - $usr->setPreference('loginfailed','0'); |
|
112 | - $usr->savePreferencesToDB(); |
|
113 | - } |
|
114 | - return $this->postLoginAuthenticate(); |
|
115 | - |
|
116 | - } |
|
117 | - else |
|
118 | - { |
|
119 | - //if(!empty($usr_id) && $res['lockoutexpiration'] > 0){ |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @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 |
|
74 | + */ |
|
75 | + public function SugarAuthenticate(){ |
|
76 | + $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
77 | + if(isset($GLOBALS['log'])) { |
|
78 | + $GLOBALS['log']->deprecated($deprecatedMessage); |
|
79 | + } |
|
80 | + else { |
|
81 | + trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
82 | + } |
|
83 | + self::__construct(); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Authenticates a user based on the username and password |
|
88 | + * returns true if the user was authenticated false otherwise |
|
89 | + * it also will load the user into current user if he was authenticated |
|
90 | + * |
|
91 | + * @param string $username |
|
92 | + * @param string $password |
|
93 | + * @return boolean |
|
94 | + */ |
|
95 | + function loginAuthenticate($username, $password, $fallback=false, $PARAMS = array ()){ |
|
96 | + global $mod_strings; |
|
97 | + unset($_SESSION['login_error']); |
|
98 | + $usr= new user(); |
|
99 | + $usr_id=$usr->retrieve_user_id($username); |
|
100 | + $usr->retrieve($usr_id); |
|
101 | + $_SESSION['login_error']=''; |
|
102 | + $_SESSION['waiting_error']=''; |
|
103 | + $_SESSION['hasExpiredPassword']='0'; |
|
104 | + if ($this->userAuthenticate->loadUserOnLogin($username, $password, $fallback, $PARAMS)) { |
|
105 | + require_once('modules/Users/password_utils.php'); |
|
106 | + if(hasPasswordExpired($username)) { |
|
107 | + $_SESSION['hasExpiredPassword'] = '1'; |
|
108 | + } |
|
109 | + // now that user is authenticated, reset loginfailed |
|
110 | + if ($usr->getPreference('loginfailed') != '' && $usr->getPreference('loginfailed') != 0) { |
|
111 | + $usr->setPreference('loginfailed','0'); |
|
112 | + $usr->savePreferencesToDB(); |
|
113 | + } |
|
114 | + return $this->postLoginAuthenticate(); |
|
115 | + |
|
116 | + } |
|
117 | + else |
|
118 | + { |
|
119 | + //if(!empty($usr_id) && $res['lockoutexpiration'] > 0){ |
|
120 | 120 | if(!empty($usr_id)){ |
121 | - if (($logout=$usr->getPreference('loginfailed'))=='') |
|
122 | - $usr->setPreference('loginfailed','1'); |
|
123 | - else |
|
124 | - $usr->setPreference('loginfailed',$logout+1); |
|
125 | - $usr->savePreferencesToDB(); |
|
126 | - } |
|
127 | - } |
|
128 | - if(strtolower(get_class($this)) != 'sugarauthenticate'){ |
|
129 | - $sa = new SugarAuthenticate(); |
|
130 | - $error = (!empty($_SESSION['login_error']))?$_SESSION['login_error']:''; |
|
131 | - if($sa->loginAuthenticate($username, $password, true, $PARAMS)){ |
|
132 | - return true; |
|
133 | - } |
|
134 | - $_SESSION['login_error'] = $error; |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - $_SESSION['login_user_name'] = $username; |
|
139 | - $_SESSION['login_password'] = $password; |
|
140 | - if(empty($_SESSION['login_error'])){ |
|
141 | - $_SESSION['login_error'] = translate('ERR_INVALID_PASSWORD', 'Users'); |
|
142 | - } |
|
143 | - |
|
144 | - return false; |
|
145 | - |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Once a user is authenticated on login this function will be called. Populate the session with what is needed and log anything that needs to be logged |
|
150 | - * |
|
151 | - */ |
|
152 | - function postLoginAuthenticate(){ |
|
153 | - |
|
154 | - global $reset_language_on_default_user, $sugar_config; |
|
155 | - |
|
156 | - //just do a little house cleaning here |
|
157 | - unset($_SESSION['login_password']); |
|
158 | - unset($_SESSION['login_error']); |
|
159 | - unset($_SESSION['login_user_name']); |
|
160 | - unset($_SESSION['ACL']); |
|
121 | + if (($logout=$usr->getPreference('loginfailed'))=='') |
|
122 | + $usr->setPreference('loginfailed','1'); |
|
123 | + else |
|
124 | + $usr->setPreference('loginfailed',$logout+1); |
|
125 | + $usr->savePreferencesToDB(); |
|
126 | + } |
|
127 | + } |
|
128 | + if(strtolower(get_class($this)) != 'sugarauthenticate'){ |
|
129 | + $sa = new SugarAuthenticate(); |
|
130 | + $error = (!empty($_SESSION['login_error']))?$_SESSION['login_error']:''; |
|
131 | + if($sa->loginAuthenticate($username, $password, true, $PARAMS)){ |
|
132 | + return true; |
|
133 | + } |
|
134 | + $_SESSION['login_error'] = $error; |
|
135 | + } |
|
161 | 136 | |
162 | - //set the server unique key |
|
163 | - if (isset ($sugar_config['unique_key']))$_SESSION['unique_key'] = $sugar_config['unique_key']; |
|
164 | 137 | |
165 | - //set user language |
|
166 | - if (isset ($reset_language_on_default_user) && $reset_language_on_default_user && $GLOBALS['current_user']->user_name == $sugar_config['default_user_name']) { |
|
167 | - $authenticated_user_language = $sugar_config['default_language']; |
|
168 | - } else { |
|
169 | - $authenticated_user_language = isset($_REQUEST['login_language']) ? $_REQUEST['login_language'] : (isset ($_REQUEST['ck_login_language_20']) ? $_REQUEST['ck_login_language_20'] : $sugar_config['default_language']); |
|
170 | - } |
|
138 | + $_SESSION['login_user_name'] = $username; |
|
139 | + $_SESSION['login_password'] = $password; |
|
140 | + if(empty($_SESSION['login_error'])){ |
|
141 | + $_SESSION['login_error'] = translate('ERR_INVALID_PASSWORD', 'Users'); |
|
142 | + } |
|
171 | 143 | |
172 | - $_SESSION['authenticated_user_language'] = $authenticated_user_language; |
|
144 | + return false; |
|
173 | 145 | |
174 | - $GLOBALS['log']->debug("authenticated_user_language is $authenticated_user_language"); |
|
146 | + } |
|
175 | 147 | |
176 | - // Clear all uploaded import files for this user if it exists |
|
148 | + /** |
|
149 | + * Once a user is authenticated on login this function will be called. Populate the session with what is needed and log anything that needs to be logged |
|
150 | + * |
|
151 | + */ |
|
152 | + function postLoginAuthenticate(){ |
|
153 | + |
|
154 | + global $reset_language_on_default_user, $sugar_config; |
|
155 | + |
|
156 | + //just do a little house cleaning here |
|
157 | + unset($_SESSION['login_password']); |
|
158 | + unset($_SESSION['login_error']); |
|
159 | + unset($_SESSION['login_user_name']); |
|
160 | + unset($_SESSION['ACL']); |
|
161 | + |
|
162 | + //set the server unique key |
|
163 | + if (isset ($sugar_config['unique_key']))$_SESSION['unique_key'] = $sugar_config['unique_key']; |
|
164 | + |
|
165 | + //set user language |
|
166 | + if (isset ($reset_language_on_default_user) && $reset_language_on_default_user && $GLOBALS['current_user']->user_name == $sugar_config['default_user_name']) { |
|
167 | + $authenticated_user_language = $sugar_config['default_language']; |
|
168 | + } else { |
|
169 | + $authenticated_user_language = isset($_REQUEST['login_language']) ? $_REQUEST['login_language'] : (isset ($_REQUEST['ck_login_language_20']) ? $_REQUEST['ck_login_language_20'] : $sugar_config['default_language']); |
|
170 | + } |
|
171 | + |
|
172 | + $_SESSION['authenticated_user_language'] = $authenticated_user_language; |
|
173 | + |
|
174 | + $GLOBALS['log']->debug("authenticated_user_language is $authenticated_user_language"); |
|
175 | + |
|
176 | + // Clear all uploaded import files for this user if it exists |
|
177 | 177 | require_once('modules/Import/ImportCacheFiles.php'); |
178 | 178 | $tmp_file_name = ImportCacheFiles::getImportDir()."/IMPORT_" . $GLOBALS['current_user']->id; |
179 | 179 | |
180 | - if (file_exists($tmp_file_name)) { |
|
181 | - unlink($tmp_file_name); |
|
182 | - } |
|
183 | - |
|
184 | - return true; |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * On every page hit this will be called to ensure a user is authenticated |
|
189 | - * @return boolean |
|
190 | - */ |
|
191 | - function sessionAuthenticate(){ |
|
192 | - |
|
193 | - global $module, $action, $allowed_actions; |
|
194 | - $authenticated = false; |
|
195 | - $allowed_actions = array ("Authenticate", "Login"); // these are actions where the user/server keys aren't compared |
|
196 | - if (isset ($_SESSION['authenticated_user_id'])) { |
|
197 | - |
|
198 | - $GLOBALS['log']->debug("We have an authenticated user id: ".$_SESSION["authenticated_user_id"]); |
|
199 | - |
|
200 | - $authenticated = $this->postSessionAuthenticate(); |
|
201 | - |
|
202 | - } else |
|
203 | - if (isset ($action) && isset ($module) && $action == "Authenticate" && $module == "Users") { |
|
204 | - $GLOBALS['log']->debug("We are authenticating user now"); |
|
205 | - } else { |
|
206 | - $GLOBALS['log']->debug("The current user does not have a session. Going to the login page"); |
|
207 | - $action = "Login"; |
|
208 | - $module = "Users"; |
|
209 | - $_REQUEST['action'] = $action; |
|
210 | - $_REQUEST['module'] = $module; |
|
211 | - } |
|
212 | - if (empty ($GLOBALS['current_user']->id) && !in_array($action, $allowed_actions)) { |
|
213 | - |
|
214 | - $GLOBALS['log']->debug("The current user is not logged in going to login page"); |
|
215 | - $action = "Login"; |
|
216 | - $module = "Users"; |
|
217 | - $_REQUEST['action'] = $action; |
|
218 | - $_REQUEST['module'] = $module; |
|
219 | - |
|
220 | - } |
|
221 | - |
|
222 | - if($authenticated && ((empty($_REQUEST['module']) || empty($_REQUEST['action'])) || ($_REQUEST['module'] != 'Users' || $_REQUEST['action'] != 'Logout'))){ |
|
223 | - $this->validateIP(); |
|
224 | - } |
|
225 | - return $authenticated; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * Called after a session is authenticated - if this returns false the sessionAuthenticate will return false and destroy the session |
|
233 | - * and it will load the current user |
|
234 | - * @return boolean |
|
235 | - */ |
|
236 | - |
|
237 | - function postSessionAuthenticate(){ |
|
238 | - |
|
239 | - global $action, $allowed_actions, $sugar_config; |
|
240 | - $_SESSION['userTime']['last'] = time(); |
|
241 | - $user_unique_key = (isset ($_SESSION['unique_key'])) ? $_SESSION['unique_key'] : ''; |
|
242 | - $server_unique_key = (isset ($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : ''; |
|
243 | - |
|
244 | - //CHECK IF USER IS CROSSING SITES |
|
245 | - if (($user_unique_key != $server_unique_key) && (!in_array($action, $allowed_actions)) && (!isset ($_SESSION['login_error']))) { |
|
246 | - |
|
247 | - $GLOBALS['log']->debug('Destroying Session User has crossed Sites'); |
|
248 | - session_destroy(); |
|
249 | - header("Location: index.php?action=Login&module=Users".$GLOBALS['app']->getLoginRedirect()); |
|
250 | - sugar_cleanup(true); |
|
251 | - } |
|
252 | - if (!$this->userAuthenticate->loadUserOnSession($_SESSION['authenticated_user_id'])) { |
|
253 | - session_destroy(); |
|
254 | - header("Location: index.php?action=Login&module=Users&loginErrorMessage=LBL_SESSION_EXPIRED"); |
|
255 | - $GLOBALS['log']->debug('Current user session does not exist redirecting to login'); |
|
256 | - sugar_cleanup(true); |
|
257 | - } |
|
258 | - $GLOBALS['log']->debug('Current user is: '.$GLOBALS['current_user']->user_name); |
|
259 | - return true; |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Make sure a user isn't stealing sessions so check the ip to ensure that the ip address hasn't dramatically changed |
|
264 | - * |
|
265 | - */ |
|
266 | - function validateIP() { |
|
267 | - global $sugar_config; |
|
268 | - // grab client ip address |
|
269 | - $clientIP = query_client_ip(); |
|
270 | - $classCheck = 0; |
|
271 | - // check to see if config entry is present, if not, verify client ip |
|
272 | - if (!isset ($sugar_config['verify_client_ip']) || $sugar_config['verify_client_ip'] == true) { |
|
273 | - // check to see if we've got a current ip address in $_SESSION |
|
274 | - // and check to see if the session has been hijacked by a foreign ip |
|
275 | - if (isset ($_SESSION["ipaddress"])) { |
|
276 | - $session_parts = explode(".", $_SESSION["ipaddress"]); |
|
277 | - $client_parts = explode(".", $clientIP); |
|
180 | + if (file_exists($tmp_file_name)) { |
|
181 | + unlink($tmp_file_name); |
|
182 | + } |
|
183 | + |
|
184 | + return true; |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * On every page hit this will be called to ensure a user is authenticated |
|
189 | + * @return boolean |
|
190 | + */ |
|
191 | + function sessionAuthenticate(){ |
|
192 | + |
|
193 | + global $module, $action, $allowed_actions; |
|
194 | + $authenticated = false; |
|
195 | + $allowed_actions = array ("Authenticate", "Login"); // these are actions where the user/server keys aren't compared |
|
196 | + if (isset ($_SESSION['authenticated_user_id'])) { |
|
197 | + |
|
198 | + $GLOBALS['log']->debug("We have an authenticated user id: ".$_SESSION["authenticated_user_id"]); |
|
199 | + |
|
200 | + $authenticated = $this->postSessionAuthenticate(); |
|
201 | + |
|
202 | + } else |
|
203 | + if (isset ($action) && isset ($module) && $action == "Authenticate" && $module == "Users") { |
|
204 | + $GLOBALS['log']->debug("We are authenticating user now"); |
|
205 | + } else { |
|
206 | + $GLOBALS['log']->debug("The current user does not have a session. Going to the login page"); |
|
207 | + $action = "Login"; |
|
208 | + $module = "Users"; |
|
209 | + $_REQUEST['action'] = $action; |
|
210 | + $_REQUEST['module'] = $module; |
|
211 | + } |
|
212 | + if (empty ($GLOBALS['current_user']->id) && !in_array($action, $allowed_actions)) { |
|
213 | + |
|
214 | + $GLOBALS['log']->debug("The current user is not logged in going to login page"); |
|
215 | + $action = "Login"; |
|
216 | + $module = "Users"; |
|
217 | + $_REQUEST['action'] = $action; |
|
218 | + $_REQUEST['module'] = $module; |
|
219 | + |
|
220 | + } |
|
221 | + |
|
222 | + if($authenticated && ((empty($_REQUEST['module']) || empty($_REQUEST['action'])) || ($_REQUEST['module'] != 'Users' || $_REQUEST['action'] != 'Logout'))){ |
|
223 | + $this->validateIP(); |
|
224 | + } |
|
225 | + return $authenticated; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * Called after a session is authenticated - if this returns false the sessionAuthenticate will return false and destroy the session |
|
233 | + * and it will load the current user |
|
234 | + * @return boolean |
|
235 | + */ |
|
236 | + |
|
237 | + function postSessionAuthenticate(){ |
|
238 | + |
|
239 | + global $action, $allowed_actions, $sugar_config; |
|
240 | + $_SESSION['userTime']['last'] = time(); |
|
241 | + $user_unique_key = (isset ($_SESSION['unique_key'])) ? $_SESSION['unique_key'] : ''; |
|
242 | + $server_unique_key = (isset ($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : ''; |
|
243 | + |
|
244 | + //CHECK IF USER IS CROSSING SITES |
|
245 | + if (($user_unique_key != $server_unique_key) && (!in_array($action, $allowed_actions)) && (!isset ($_SESSION['login_error']))) { |
|
246 | + |
|
247 | + $GLOBALS['log']->debug('Destroying Session User has crossed Sites'); |
|
248 | + session_destroy(); |
|
249 | + header("Location: index.php?action=Login&module=Users".$GLOBALS['app']->getLoginRedirect()); |
|
250 | + sugar_cleanup(true); |
|
251 | + } |
|
252 | + if (!$this->userAuthenticate->loadUserOnSession($_SESSION['authenticated_user_id'])) { |
|
253 | + session_destroy(); |
|
254 | + header("Location: index.php?action=Login&module=Users&loginErrorMessage=LBL_SESSION_EXPIRED"); |
|
255 | + $GLOBALS['log']->debug('Current user session does not exist redirecting to login'); |
|
256 | + sugar_cleanup(true); |
|
257 | + } |
|
258 | + $GLOBALS['log']->debug('Current user is: '.$GLOBALS['current_user']->user_name); |
|
259 | + return true; |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Make sure a user isn't stealing sessions so check the ip to ensure that the ip address hasn't dramatically changed |
|
264 | + * |
|
265 | + */ |
|
266 | + function validateIP() { |
|
267 | + global $sugar_config; |
|
268 | + // grab client ip address |
|
269 | + $clientIP = query_client_ip(); |
|
270 | + $classCheck = 0; |
|
271 | + // check to see if config entry is present, if not, verify client ip |
|
272 | + if (!isset ($sugar_config['verify_client_ip']) || $sugar_config['verify_client_ip'] == true) { |
|
273 | + // check to see if we've got a current ip address in $_SESSION |
|
274 | + // and check to see if the session has been hijacked by a foreign ip |
|
275 | + if (isset ($_SESSION["ipaddress"])) { |
|
276 | + $session_parts = explode(".", $_SESSION["ipaddress"]); |
|
277 | + $client_parts = explode(".", $clientIP); |
|
278 | 278 | if(count($session_parts) < 4) { |
279 | 279 | $classCheck = 0; |
280 | 280 | } |
281 | 281 | else { |
282 | - // match class C IP addresses |
|
283 | - for ($i = 0; $i < 3; $i ++) { |
|
284 | - if ($session_parts[$i] == $client_parts[$i]) { |
|
285 | - $classCheck = 1; |
|
286 | - continue; |
|
287 | - } else { |
|
288 | - $classCheck = 0; |
|
289 | - break; |
|
290 | - } |
|
291 | - } |
|
282 | + // match class C IP addresses |
|
283 | + for ($i = 0; $i < 3; $i ++) { |
|
284 | + if ($session_parts[$i] == $client_parts[$i]) { |
|
285 | + $classCheck = 1; |
|
286 | + continue; |
|
287 | + } else { |
|
288 | + $classCheck = 0; |
|
289 | + break; |
|
290 | + } |
|
291 | + } |
|
292 | + } |
|
293 | + // we have a different IP address |
|
294 | + if ($_SESSION["ipaddress"] != $clientIP && empty ($classCheck)) { |
|
295 | + $GLOBALS['log']->fatal("IP Address mismatch: SESSION IP: {$_SESSION['ipaddress']} CLIENT IP: {$clientIP}"); |
|
296 | + session_destroy(); |
|
297 | + die("Your session was terminated due to a significant change in your IP address. <a href=\"{$sugar_config['site_url']}\">Return to Home</a>"); |
|
292 | 298 | } |
293 | - // we have a different IP address |
|
294 | - if ($_SESSION["ipaddress"] != $clientIP && empty ($classCheck)) { |
|
295 | - $GLOBALS['log']->fatal("IP Address mismatch: SESSION IP: {$_SESSION['ipaddress']} CLIENT IP: {$clientIP}"); |
|
296 | - session_destroy(); |
|
297 | - die("Your session was terminated due to a significant change in your IP address. <a href=\"{$sugar_config['site_url']}\">Return to Home</a>"); |
|
298 | - } |
|
299 | - } else { |
|
300 | - $_SESSION["ipaddress"] = $clientIP; |
|
301 | - } |
|
302 | - } |
|
303 | - |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * Called when a user requests to logout |
|
311 | - * |
|
312 | - */ |
|
313 | - function logout(){ |
|
314 | - session_start(); |
|
315 | - session_destroy(); |
|
316 | - ob_clean(); |
|
317 | - header('Location: index.php?module=Users&action=Login'); |
|
318 | - sugar_cleanup(true); |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * Encodes a users password. This is a static function and can be called at any time. |
|
324 | - * |
|
325 | - * @param STRING $password |
|
326 | - * @return STRING $encoded_password |
|
327 | - */ |
|
328 | - static function encodePassword($password){ |
|
329 | - return strtolower(md5($password)); |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * If a user may change there password through the Sugar UI |
|
334 | - * |
|
335 | - */ |
|
336 | - function canChangePassword(){ |
|
337 | - return true; |
|
338 | - } |
|
339 | - /** |
|
340 | - * If a user may change there user name through the Sugar UI |
|
341 | - * |
|
342 | - */ |
|
343 | - function canChangeUserName(){ |
|
344 | - return true; |
|
345 | - } |
|
299 | + } else { |
|
300 | + $_SESSION["ipaddress"] = $clientIP; |
|
301 | + } |
|
302 | + } |
|
303 | + |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * Called when a user requests to logout |
|
311 | + * |
|
312 | + */ |
|
313 | + function logout(){ |
|
314 | + session_start(); |
|
315 | + session_destroy(); |
|
316 | + ob_clean(); |
|
317 | + header('Location: index.php?module=Users&action=Login'); |
|
318 | + sugar_cleanup(true); |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * Encodes a users password. This is a static function and can be called at any time. |
|
324 | + * |
|
325 | + * @param STRING $password |
|
326 | + * @return STRING $encoded_password |
|
327 | + */ |
|
328 | + static function encodePassword($password){ |
|
329 | + return strtolower(md5($password)); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * If a user may change there password through the Sugar UI |
|
334 | + * |
|
335 | + */ |
|
336 | + function canChangePassword(){ |
|
337 | + return true; |
|
338 | + } |
|
339 | + /** |
|
340 | + * If a user may change there user name through the Sugar UI |
|
341 | + * |
|
342 | + */ |
|
343 | + function canChangeUserName(){ |
|
344 | + return true; |
|
345 | + } |
|
346 | 346 | |
347 | 347 | |
348 | 348 | /** |
@@ -370,6 +370,6 @@ discard block |
||
370 | 370 | public function redirectToLogin(SugarApplication $app) |
371 | 371 | { |
372 | 372 | $loginVars = $app->createLoginVars(); |
373 | - SugarApplication::redirect('index.php?action=Login&module=Users' . $loginVars); |
|
373 | + SugarApplication::redirect('index.php?action=Login&module=Users' . $loginVars); |
|
374 | 374 | } |
375 | 375 | } |
@@ -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. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * based on the users validation |
48 | 48 | * |
49 | 49 | */ |
50 | -class SugarAuthenticate{ |
|
50 | +class SugarAuthenticate { |
|
51 | 51 | var $userAuthenticateClass = 'SugarAuthenticateUser'; |
52 | 52 | var $authenticationDir = 'SugarAuthenticate'; |
53 | 53 | /** |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | public function __construct() |
60 | 60 | { |
61 | 61 | // check in custom dir first, in case someone want's to override an auth controller |
62 | - if (file_exists('custom/modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
|
63 | - require_once('custom/modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php'); |
|
62 | + if (file_exists('custom/modules/Users/authentication/'.$this->authenticationDir.'/'.$this->userAuthenticateClass.'.php')) { |
|
63 | + require_once('custom/modules/Users/authentication/'.$this->authenticationDir.'/'.$this->userAuthenticateClass.'.php'); |
|
64 | 64 | } |
65 | - elseif (file_exists('modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
|
66 | - require_once('modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php'); |
|
65 | + elseif (file_exists('modules/Users/authentication/'.$this->authenticationDir.'/'.$this->userAuthenticateClass.'.php')) { |
|
66 | + require_once('modules/Users/authentication/'.$this->authenticationDir.'/'.$this->userAuthenticateClass.'.php'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $this->userAuthenticate = new $this->userAuthenticateClass(); |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @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 |
74 | 74 | */ |
75 | - public function SugarAuthenticate(){ |
|
75 | + public function SugarAuthenticate() { |
|
76 | 76 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
77 | - if(isset($GLOBALS['log'])) { |
|
77 | + if (isset($GLOBALS['log'])) { |
|
78 | 78 | $GLOBALS['log']->deprecated($deprecatedMessage); |
79 | 79 | } |
80 | 80 | else { |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | * @param string $password |
93 | 93 | * @return boolean |
94 | 94 | */ |
95 | - function loginAuthenticate($username, $password, $fallback=false, $PARAMS = array ()){ |
|
95 | + function loginAuthenticate($username, $password, $fallback = false, $PARAMS = array()) { |
|
96 | 96 | global $mod_strings; |
97 | 97 | unset($_SESSION['login_error']); |
98 | - $usr= new user(); |
|
99 | - $usr_id=$usr->retrieve_user_id($username); |
|
98 | + $usr = new user(); |
|
99 | + $usr_id = $usr->retrieve_user_id($username); |
|
100 | 100 | $usr->retrieve($usr_id); |
101 | - $_SESSION['login_error']=''; |
|
102 | - $_SESSION['waiting_error']=''; |
|
103 | - $_SESSION['hasExpiredPassword']='0'; |
|
101 | + $_SESSION['login_error'] = ''; |
|
102 | + $_SESSION['waiting_error'] = ''; |
|
103 | + $_SESSION['hasExpiredPassword'] = '0'; |
|
104 | 104 | if ($this->userAuthenticate->loadUserOnLogin($username, $password, $fallback, $PARAMS)) { |
105 | 105 | require_once('modules/Users/password_utils.php'); |
106 | - if(hasPasswordExpired($username)) { |
|
106 | + if (hasPasswordExpired($username)) { |
|
107 | 107 | $_SESSION['hasExpiredPassword'] = '1'; |
108 | 108 | } |
109 | 109 | // now that user is authenticated, reset loginfailed |
110 | 110 | if ($usr->getPreference('loginfailed') != '' && $usr->getPreference('loginfailed') != 0) { |
111 | - $usr->setPreference('loginfailed','0'); |
|
111 | + $usr->setPreference('loginfailed', '0'); |
|
112 | 112 | $usr->savePreferencesToDB(); |
113 | 113 | } |
114 | 114 | return $this->postLoginAuthenticate(); |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | else |
118 | 118 | { |
119 | 119 | //if(!empty($usr_id) && $res['lockoutexpiration'] > 0){ |
120 | - if(!empty($usr_id)){ |
|
121 | - if (($logout=$usr->getPreference('loginfailed'))=='') |
|
122 | - $usr->setPreference('loginfailed','1'); |
|
120 | + if (!empty($usr_id)) { |
|
121 | + if (($logout = $usr->getPreference('loginfailed')) == '') |
|
122 | + $usr->setPreference('loginfailed', '1'); |
|
123 | 123 | else |
124 | - $usr->setPreference('loginfailed',$logout+1); |
|
124 | + $usr->setPreference('loginfailed', $logout + 1); |
|
125 | 125 | $usr->savePreferencesToDB(); |
126 | 126 | } |
127 | 127 | } |
128 | - if(strtolower(get_class($this)) != 'sugarauthenticate'){ |
|
128 | + if (strtolower(get_class($this)) != 'sugarauthenticate') { |
|
129 | 129 | $sa = new SugarAuthenticate(); |
130 | - $error = (!empty($_SESSION['login_error']))?$_SESSION['login_error']:''; |
|
131 | - if($sa->loginAuthenticate($username, $password, true, $PARAMS)){ |
|
130 | + $error = (!empty($_SESSION['login_error'])) ? $_SESSION['login_error'] : ''; |
|
131 | + if ($sa->loginAuthenticate($username, $password, true, $PARAMS)) { |
|
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | $_SESSION['login_error'] = $error; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $_SESSION['login_user_name'] = $username; |
139 | 139 | $_SESSION['login_password'] = $password; |
140 | - if(empty($_SESSION['login_error'])){ |
|
140 | + if (empty($_SESSION['login_error'])) { |
|
141 | 141 | $_SESSION['login_error'] = translate('ERR_INVALID_PASSWORD', 'Users'); |
142 | 142 | } |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * Once a user is authenticated on login this function will be called. Populate the session with what is needed and log anything that needs to be logged |
150 | 150 | * |
151 | 151 | */ |
152 | - function postLoginAuthenticate(){ |
|
152 | + function postLoginAuthenticate() { |
|
153 | 153 | |
154 | 154 | global $reset_language_on_default_user, $sugar_config; |
155 | 155 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | // Clear all uploaded import files for this user if it exists |
177 | 177 | require_once('modules/Import/ImportCacheFiles.php'); |
178 | - $tmp_file_name = ImportCacheFiles::getImportDir()."/IMPORT_" . $GLOBALS['current_user']->id; |
|
178 | + $tmp_file_name = ImportCacheFiles::getImportDir()."/IMPORT_".$GLOBALS['current_user']->id; |
|
179 | 179 | |
180 | 180 | if (file_exists($tmp_file_name)) { |
181 | 181 | unlink($tmp_file_name); |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | * On every page hit this will be called to ensure a user is authenticated |
189 | 189 | * @return boolean |
190 | 190 | */ |
191 | - function sessionAuthenticate(){ |
|
191 | + function sessionAuthenticate() { |
|
192 | 192 | |
193 | 193 | global $module, $action, $allowed_actions; |
194 | 194 | $authenticated = false; |
195 | - $allowed_actions = array ("Authenticate", "Login"); // these are actions where the user/server keys aren't compared |
|
195 | + $allowed_actions = array("Authenticate", "Login"); // these are actions where the user/server keys aren't compared |
|
196 | 196 | if (isset ($_SESSION['authenticated_user_id'])) { |
197 | 197 | |
198 | 198 | $GLOBALS['log']->debug("We have an authenticated user id: ".$_SESSION["authenticated_user_id"]); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | } |
221 | 221 | |
222 | - if($authenticated && ((empty($_REQUEST['module']) || empty($_REQUEST['action'])) || ($_REQUEST['module'] != 'Users' || $_REQUEST['action'] != 'Logout'))){ |
|
222 | + if ($authenticated && ((empty($_REQUEST['module']) || empty($_REQUEST['action'])) || ($_REQUEST['module'] != 'Users' || $_REQUEST['action'] != 'Logout'))) { |
|
223 | 223 | $this->validateIP(); |
224 | 224 | } |
225 | 225 | return $authenticated; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @return boolean |
235 | 235 | */ |
236 | 236 | |
237 | - function postSessionAuthenticate(){ |
|
237 | + function postSessionAuthenticate() { |
|
238 | 238 | |
239 | 239 | global $action, $allowed_actions, $sugar_config; |
240 | 240 | $_SESSION['userTime']['last'] = time(); |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | if (isset ($_SESSION["ipaddress"])) { |
276 | 276 | $session_parts = explode(".", $_SESSION["ipaddress"]); |
277 | 277 | $client_parts = explode(".", $clientIP); |
278 | - if(count($session_parts) < 4) { |
|
278 | + if (count($session_parts) < 4) { |
|
279 | 279 | $classCheck = 0; |
280 | 280 | } |
281 | 281 | else { |
282 | 282 | // match class C IP addresses |
283 | - for ($i = 0; $i < 3; $i ++) { |
|
283 | + for ($i = 0; $i < 3; $i++) { |
|
284 | 284 | if ($session_parts[$i] == $client_parts[$i]) { |
285 | 285 | $classCheck = 1; |
286 | 286 | continue; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * Called when a user requests to logout |
311 | 311 | * |
312 | 312 | */ |
313 | - function logout(){ |
|
313 | + function logout() { |
|
314 | 314 | session_start(); |
315 | 315 | session_destroy(); |
316 | 316 | ob_clean(); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * @param STRING $password |
326 | 326 | * @return STRING $encoded_password |
327 | 327 | */ |
328 | - static function encodePassword($password){ |
|
328 | + static function encodePassword($password) { |
|
329 | 329 | return strtolower(md5($password)); |
330 | 330 | } |
331 | 331 | |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | * If a user may change there password through the Sugar UI |
334 | 334 | * |
335 | 335 | */ |
336 | - function canChangePassword(){ |
|
336 | + function canChangePassword() { |
|
337 | 337 | return true; |
338 | 338 | } |
339 | 339 | /** |
340 | 340 | * If a user may change there user name through the Sugar UI |
341 | 341 | * |
342 | 342 | */ |
343 | - function canChangeUserName(){ |
|
343 | + function canChangeUserName() { |
|
344 | 344 | return true; |
345 | 345 | } |
346 | 346 | |
@@ -370,6 +370,6 @@ discard block |
||
370 | 370 | public function redirectToLogin(SugarApplication $app) |
371 | 371 | { |
372 | 372 | $loginVars = $app->createLoginVars(); |
373 | - SugarApplication::redirect('index.php?action=Login&module=Users' . $loginVars); |
|
373 | + SugarApplication::redirect('index.php?action=Login&module=Users'.$loginVars); |
|
374 | 374 | } |
375 | 375 | } |
@@ -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. |
@@ -61,8 +63,7 @@ discard block |
||
61 | 63 | // check in custom dir first, in case someone want's to override an auth controller |
62 | 64 | if (file_exists('custom/modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
63 | 65 | require_once('custom/modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php'); |
64 | - } |
|
65 | - elseif (file_exists('modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
|
66 | + } elseif (file_exists('modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php')) { |
|
66 | 67 | require_once('modules/Users/authentication/'.$this->authenticationDir.'/' . $this->userAuthenticateClass . '.php'); |
67 | 68 | } |
68 | 69 | |
@@ -76,8 +77,7 @@ discard block |
||
76 | 77 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
77 | 78 | if(isset($GLOBALS['log'])) { |
78 | 79 | $GLOBALS['log']->deprecated($deprecatedMessage); |
79 | - } |
|
80 | - else { |
|
80 | + } else { |
|
81 | 81 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
82 | 82 | } |
83 | 83 | self::__construct(); |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | } |
114 | 114 | return $this->postLoginAuthenticate(); |
115 | 115 | |
116 | - } |
|
117 | - else |
|
116 | + } else |
|
118 | 117 | { |
119 | 118 | //if(!empty($usr_id) && $res['lockoutexpiration'] > 0){ |
120 | 119 | if(!empty($usr_id)){ |
121 | - if (($logout=$usr->getPreference('loginfailed'))=='') |
|
122 | - $usr->setPreference('loginfailed','1'); |
|
123 | - else |
|
124 | - $usr->setPreference('loginfailed',$logout+1); |
|
120 | + if (($logout=$usr->getPreference('loginfailed'))=='') { |
|
121 | + $usr->setPreference('loginfailed','1'); |
|
122 | + } else { |
|
123 | + $usr->setPreference('loginfailed',$logout+1); |
|
124 | + } |
|
125 | 125 | $usr->savePreferencesToDB(); |
126 | 126 | } |
127 | 127 | } |
@@ -160,7 +160,9 @@ discard block |
||
160 | 160 | unset($_SESSION['ACL']); |
161 | 161 | |
162 | 162 | //set the server unique key |
163 | - if (isset ($sugar_config['unique_key']))$_SESSION['unique_key'] = $sugar_config['unique_key']; |
|
163 | + if (isset ($sugar_config['unique_key'])) { |
|
164 | + $_SESSION['unique_key'] = $sugar_config['unique_key']; |
|
165 | + } |
|
164 | 166 | |
165 | 167 | //set user language |
166 | 168 | if (isset ($reset_language_on_default_user) && $reset_language_on_default_user && $GLOBALS['current_user']->user_name == $sugar_config['default_user_name']) { |
@@ -277,8 +279,7 @@ discard block |
||
277 | 279 | $client_parts = explode(".", $clientIP); |
278 | 280 | if(count($session_parts) < 4) { |
279 | 281 | $classCheck = 0; |
280 | - } |
|
281 | - else { |
|
282 | + } else { |
|
282 | 283 | // match class C IP addresses |
283 | 284 | for ($i = 0; $i < 3; $i ++) { |
284 | 285 | if ($session_parts[$i] == $client_parts[$i]) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(!defined('sugarEntry') || !sugarEntry) |
3 | - die('Not A Valid Entry Point'); |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -45,63 +45,63 @@ discard block |
||
45 | 45 | // User is used to store Forecast information. |
46 | 46 | class Document extends File { |
47 | 47 | |
48 | - var $id; |
|
49 | - var $document_name; |
|
50 | - var $description; |
|
51 | - var $category_id; |
|
52 | - var $subcategory_id; |
|
53 | - var $status_id; |
|
54 | - var $status; |
|
55 | - var $created_by; |
|
56 | - var $date_entered; |
|
57 | - var $date_modified; |
|
58 | - var $modified_user_id; |
|
48 | + var $id; |
|
49 | + var $document_name; |
|
50 | + var $description; |
|
51 | + var $category_id; |
|
52 | + var $subcategory_id; |
|
53 | + var $status_id; |
|
54 | + var $status; |
|
55 | + var $created_by; |
|
56 | + var $date_entered; |
|
57 | + var $date_modified; |
|
58 | + var $modified_user_id; |
|
59 | 59 | var $assigned_user_id; |
60 | - var $active_date; |
|
61 | - var $exp_date; |
|
62 | - var $document_revision_id; |
|
63 | - var $filename; |
|
64 | - var $doc_type; |
|
65 | - |
|
66 | - var $img_name; |
|
67 | - var $img_name_bare; |
|
68 | - var $related_doc_id; |
|
69 | - var $related_doc_name; |
|
70 | - var $related_doc_rev_id; |
|
71 | - var $related_doc_rev_number; |
|
72 | - var $is_template; |
|
73 | - var $template_type; |
|
74 | - |
|
75 | - //additional fields. |
|
76 | - var $revision; |
|
77 | - var $last_rev_create_date; |
|
78 | - var $last_rev_created_by; |
|
79 | - var $last_rev_created_name; |
|
80 | - var $file_url; |
|
81 | - var $file_url_noimage; |
|
82 | - |
|
83 | - var $table_name = "documents"; |
|
84 | - var $object_name = "Document"; |
|
85 | - var $user_preferences; |
|
86 | - |
|
87 | - var $encodeFields = Array (); |
|
88 | - |
|
89 | - // This is used to retrieve related fields from form posts. |
|
90 | - var $additional_column_fields = Array ('revision'); |
|
91 | - |
|
92 | - var $new_schema = true; |
|
93 | - var $module_dir = 'Documents'; |
|
94 | - |
|
95 | - var $relationship_fields = Array( |
|
96 | - 'contract_id'=>'contracts', |
|
97 | - ); |
|
98 | - |
|
99 | - |
|
100 | - function __construct() { |
|
101 | - parent::__construct(); |
|
102 | - $this->setupCustomFields('Documents'); //parameter is module name |
|
103 | - $this->disable_row_level_security = false; |
|
104 | - } |
|
60 | + var $active_date; |
|
61 | + var $exp_date; |
|
62 | + var $document_revision_id; |
|
63 | + var $filename; |
|
64 | + var $doc_type; |
|
65 | + |
|
66 | + var $img_name; |
|
67 | + var $img_name_bare; |
|
68 | + var $related_doc_id; |
|
69 | + var $related_doc_name; |
|
70 | + var $related_doc_rev_id; |
|
71 | + var $related_doc_rev_number; |
|
72 | + var $is_template; |
|
73 | + var $template_type; |
|
74 | + |
|
75 | + //additional fields. |
|
76 | + var $revision; |
|
77 | + var $last_rev_create_date; |
|
78 | + var $last_rev_created_by; |
|
79 | + var $last_rev_created_name; |
|
80 | + var $file_url; |
|
81 | + var $file_url_noimage; |
|
82 | + |
|
83 | + var $table_name = "documents"; |
|
84 | + var $object_name = "Document"; |
|
85 | + var $user_preferences; |
|
86 | + |
|
87 | + var $encodeFields = Array (); |
|
88 | + |
|
89 | + // This is used to retrieve related fields from form posts. |
|
90 | + var $additional_column_fields = Array ('revision'); |
|
91 | + |
|
92 | + var $new_schema = true; |
|
93 | + var $module_dir = 'Documents'; |
|
94 | + |
|
95 | + var $relationship_fields = Array( |
|
96 | + 'contract_id'=>'contracts', |
|
97 | + ); |
|
98 | + |
|
99 | + |
|
100 | + function __construct() { |
|
101 | + parent::__construct(); |
|
102 | + $this->setupCustomFields('Documents'); //parameter is module name |
|
103 | + $this->disable_row_level_security = false; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @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 |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | |
121 | - function save($check_notify = false) { |
|
121 | + function save($check_notify = false) { |
|
122 | 122 | |
123 | 123 | if (empty($this->doc_type)) { |
124 | - $this->doc_type = 'Sugar'; |
|
125 | - } |
|
124 | + $this->doc_type = 'Sugar'; |
|
125 | + } |
|
126 | 126 | if (empty($this->id) || $this->new_with_id) |
127 | - { |
|
127 | + { |
|
128 | 128 | if (empty($this->id)) { |
129 | 129 | $this->id = create_guid(); |
130 | 130 | $this->new_with_id = true; |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | |
151 | 151 | if(isset($this->file_ext)) |
152 | 152 | { |
153 | - $Revision->file_ext = $this->file_ext; |
|
153 | + $Revision->file_ext = $this->file_ext; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if(isset($this->file_mime_type)) |
157 | 157 | { |
158 | - $Revision->file_mime_type = $this->file_mime_type; |
|
158 | + $Revision->file_mime_type = $this->file_mime_type; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $Revision->doc_type = $this->doc_type; |
@@ -211,29 +211,29 @@ discard block |
||
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | - return parent :: save($check_notify); |
|
215 | - } |
|
216 | - function get_summary_text() { |
|
217 | - return "$this->document_name"; |
|
218 | - } |
|
214 | + return parent :: save($check_notify); |
|
215 | + } |
|
216 | + function get_summary_text() { |
|
217 | + return "$this->document_name"; |
|
218 | + } |
|
219 | 219 | |
220 | - function is_authenticated() { |
|
221 | - return $this->authenticated; |
|
222 | - } |
|
220 | + function is_authenticated() { |
|
221 | + return $this->authenticated; |
|
222 | + } |
|
223 | 223 | |
224 | - function fill_in_additional_list_fields() { |
|
225 | - $this->fill_in_additional_detail_fields(); |
|
226 | - } |
|
224 | + function fill_in_additional_list_fields() { |
|
225 | + $this->fill_in_additional_detail_fields(); |
|
226 | + } |
|
227 | 227 | |
228 | - function fill_in_additional_detail_fields() { |
|
229 | - global $theme; |
|
230 | - global $current_language; |
|
231 | - global $timedate; |
|
232 | - global $locale; |
|
228 | + function fill_in_additional_detail_fields() { |
|
229 | + global $theme; |
|
230 | + global $current_language; |
|
231 | + global $timedate; |
|
232 | + global $locale; |
|
233 | 233 | |
234 | - parent::fill_in_additional_detail_fields(); |
|
234 | + parent::fill_in_additional_detail_fields(); |
|
235 | 235 | |
236 | - $mod_strings = return_module_language($current_language, 'Documents'); |
|
236 | + $mod_strings = return_module_language($current_language, 'Documents'); |
|
237 | 237 | |
238 | 238 | if (!empty($this->document_revision_id)) { |
239 | 239 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | //populate name |
250 | 250 | if(isset($this->document_name)) |
251 | 251 | { |
252 | - $this->name = $this->document_name; |
|
252 | + $this->name = $this->document_name; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | if(isset($row['filename']))$this->filename = $row['filename']; |
@@ -266,93 +266,93 @@ discard block |
||
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | - //set default file name. |
|
270 | - if (!empty ($img_name) && file_exists($img_name)) { |
|
271 | - $img_name = $img_name_bare; |
|
272 | - } else { |
|
273 | - $img_name = "def_image_inline"; //todo change the default image. |
|
274 | - } |
|
275 | - if($this->ACLAccess('DetailView')) { |
|
276 | - if(!empty($this->doc_type) && $this->doc_type != 'Sugar' && !empty($this->doc_url)) { |
|
269 | + //set default file name. |
|
270 | + if (!empty ($img_name) && file_exists($img_name)) { |
|
271 | + $img_name = $img_name_bare; |
|
272 | + } else { |
|
273 | + $img_name = "def_image_inline"; //todo change the default image. |
|
274 | + } |
|
275 | + if($this->ACLAccess('DetailView')) { |
|
276 | + if(!empty($this->doc_type) && $this->doc_type != 'Sugar' && !empty($this->doc_url)) { |
|
277 | 277 | $file_url= "<a href='".$this->doc_url."' target='_blank'>".SugarThemeRegistry::current()->getImage($this->doc_type.'_image_inline', 'border="0"',null,null,'.png',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
278 | - } else { |
|
279 | - $file_url = "<a href='index.php?entryPoint=download&id={$this->document_revision_id}&type=Documents' target='_blank'>".SugarThemeRegistry::current()->getImage($img_name, 'border="0"', null,null,'.gif',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
280 | - } |
|
278 | + } else { |
|
279 | + $file_url = "<a href='index.php?entryPoint=download&id={$this->document_revision_id}&type=Documents' target='_blank'>".SugarThemeRegistry::current()->getImage($img_name, 'border="0"', null,null,'.gif',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
280 | + } |
|
281 | 281 | |
282 | - $this->file_url = $file_url; |
|
283 | - $this->file_url_noimage = "index.php?entryPoint=download&type=Documents&id={$this->document_revision_id}"; |
|
284 | - }else{ |
|
282 | + $this->file_url = $file_url; |
|
283 | + $this->file_url_noimage = "index.php?entryPoint=download&type=Documents&id={$this->document_revision_id}"; |
|
284 | + }else{ |
|
285 | 285 | $this->file_url = ""; |
286 | 286 | $this->file_url_noimage = ""; |
287 | - } |
|
287 | + } |
|
288 | 288 | |
289 | - //get last_rev_by user name. |
|
290 | - if (!empty ($row)) { |
|
291 | - $this->last_rev_created_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); |
|
289 | + //get last_rev_by user name. |
|
290 | + if (!empty ($row)) { |
|
291 | + $this->last_rev_created_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); |
|
292 | 292 | |
293 | - $this->last_rev_create_date = $timedate->to_display_date_time($this->db->fromConvert($row['rev_date'], 'datetime')); |
|
294 | - $this->last_rev_mime_type = $row['file_mime_type']; |
|
295 | - } |
|
293 | + $this->last_rev_create_date = $timedate->to_display_date_time($this->db->fromConvert($row['rev_date'], 'datetime')); |
|
294 | + $this->last_rev_mime_type = $row['file_mime_type']; |
|
295 | + } |
|
296 | 296 | |
297 | - global $app_list_strings; |
|
298 | - if(!empty($this->status_id)) { |
|
299 | - //_pp($this->status_id); |
|
300 | - $this->status = $app_list_strings['document_status_dom'][$this->status_id]; |
|
301 | - } |
|
297 | + global $app_list_strings; |
|
298 | + if(!empty($this->status_id)) { |
|
299 | + //_pp($this->status_id); |
|
300 | + $this->status = $app_list_strings['document_status_dom'][$this->status_id]; |
|
301 | + } |
|
302 | 302 | if (!empty($this->related_doc_id)) { |
303 | 303 | $this->related_doc_name = Document::get_document_name($this->related_doc_id); |
304 | 304 | $this->related_doc_rev_number = DocumentRevision::get_document_revision_name($this->related_doc_rev_id); |
305 | 305 | } |
306 | - } |
|
306 | + } |
|
307 | 307 | |
308 | - function list_view_parse_additional_sections(&$list_form/*, $xTemplateSection*/) { |
|
309 | - return $list_form; |
|
310 | - } |
|
308 | + function list_view_parse_additional_sections(&$list_form/*, $xTemplateSection*/) { |
|
309 | + return $list_form; |
|
310 | + } |
|
311 | 311 | |
312 | 312 | function create_export_query($order_by, $where, $relate_link_join='') |
313 | 313 | { |
314 | 314 | $custom_join = $this->getCustomJoin(true, true, $where); |
315 | 315 | $custom_join['join'] .= $relate_link_join; |
316 | - $query = "SELECT |
|
316 | + $query = "SELECT |
|
317 | 317 | documents.*"; |
318 | 318 | $query .= $custom_join['select']; |
319 | - $query .= " FROM documents "; |
|
319 | + $query .= " FROM documents "; |
|
320 | 320 | $query .= $custom_join['join']; |
321 | 321 | |
322 | - $where_auto = " documents.deleted = 0"; |
|
322 | + $where_auto = " documents.deleted = 0"; |
|
323 | 323 | |
324 | - if ($where != "") |
|
325 | - $query .= " WHERE $where AND ".$where_auto; |
|
326 | - else |
|
327 | - $query .= " WHERE ".$where_auto; |
|
324 | + if ($where != "") |
|
325 | + $query .= " WHERE $where AND ".$where_auto; |
|
326 | + else |
|
327 | + $query .= " WHERE ".$where_auto; |
|
328 | 328 | |
329 | - if ($order_by != "") |
|
330 | - $query .= " ORDER BY $order_by"; |
|
331 | - else |
|
332 | - $query .= " ORDER BY documents.document_name"; |
|
329 | + if ($order_by != "") |
|
330 | + $query .= " ORDER BY $order_by"; |
|
331 | + else |
|
332 | + $query .= " ORDER BY documents.document_name"; |
|
333 | 333 | |
334 | - return $query; |
|
335 | - } |
|
334 | + return $query; |
|
335 | + } |
|
336 | 336 | |
337 | - function get_list_view_data() { |
|
338 | - global $current_language; |
|
339 | - $app_list_strings = return_app_list_strings_language($current_language); |
|
337 | + function get_list_view_data() { |
|
338 | + global $current_language; |
|
339 | + $app_list_strings = return_app_list_strings_language($current_language); |
|
340 | 340 | |
341 | - $document_fields = $this->get_list_view_array(); |
|
341 | + $document_fields = $this->get_list_view_array(); |
|
342 | 342 | |
343 | 343 | $this->fill_in_additional_list_fields(); |
344 | 344 | |
345 | 345 | |
346 | - $document_fields['FILENAME'] = $this->filename; |
|
347 | - $document_fields['FILE_URL'] = $this->file_url; |
|
348 | - $document_fields['FILE_URL_NOIMAGE'] = $this->file_url_noimage; |
|
349 | - $document_fields['LAST_REV_CREATED_BY'] = $this->last_rev_created_name; |
|
350 | - $document_fields['CATEGORY_ID'] = empty ($this->category_id) ? "" : $app_list_strings['document_category_dom'][$this->category_id]; |
|
351 | - $document_fields['SUBCATEGORY_ID'] = empty ($this->subcategory_id) ? "" : $app_list_strings['document_subcategory_dom'][$this->subcategory_id]; |
|
346 | + $document_fields['FILENAME'] = $this->filename; |
|
347 | + $document_fields['FILE_URL'] = $this->file_url; |
|
348 | + $document_fields['FILE_URL_NOIMAGE'] = $this->file_url_noimage; |
|
349 | + $document_fields['LAST_REV_CREATED_BY'] = $this->last_rev_created_name; |
|
350 | + $document_fields['CATEGORY_ID'] = empty ($this->category_id) ? "" : $app_list_strings['document_category_dom'][$this->category_id]; |
|
351 | + $document_fields['SUBCATEGORY_ID'] = empty ($this->subcategory_id) ? "" : $app_list_strings['document_subcategory_dom'][$this->subcategory_id]; |
|
352 | 352 | $document_fields['NAME'] = $this->document_name; |
353 | - $document_fields['DOCUMENT_NAME_JAVASCRIPT'] = $GLOBALS['db']->quote($document_fields['DOCUMENT_NAME']); |
|
354 | - return $document_fields; |
|
355 | - } |
|
353 | + $document_fields['DOCUMENT_NAME_JAVASCRIPT'] = $GLOBALS['db']->quote($document_fields['DOCUMENT_NAME']); |
|
354 | + return $document_fields; |
|
355 | + } |
|
356 | 356 | |
357 | 357 | |
358 | 358 | /** |
@@ -363,45 +363,45 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @param $id String The record id of the Document instance |
365 | 365 | */ |
366 | - function mark_relationships_deleted($id) |
|
366 | + function mark_relationships_deleted($id) |
|
367 | 367 | { |
368 | 368 | $this->load_relationships('revisions'); |
369 | - $revisions= $this->get_linked_beans('revisions','DocumentRevision'); |
|
370 | - |
|
371 | - if (!empty($revisions) && is_array($revisions)) { |
|
372 | - foreach($revisions as $key=>$version) { |
|
373 | - UploadFile::unlink_file($version->id,$version->filename); |
|
374 | - //mark the version deleted. |
|
375 | - $version->mark_deleted($version->id); |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - } |
|
380 | - |
|
381 | - |
|
382 | - function bean_implements($interface) { |
|
383 | - switch ($interface) { |
|
384 | - case 'ACL' : |
|
385 | - return true; |
|
386 | - } |
|
387 | - return false; |
|
388 | - } |
|
389 | - |
|
390 | - //static function. |
|
391 | - function get_document_name($doc_id){ |
|
392 | - if (empty($doc_id)) return null; |
|
393 | - |
|
394 | - $db = DBManagerFactory::getInstance(); |
|
395 | - $query="select document_name from documents where id='$doc_id' and deleted=0"; |
|
396 | - $result=$db->query($query); |
|
397 | - if (!empty($result)) { |
|
398 | - $row=$db->fetchByAssoc($result); |
|
399 | - if (!empty($row)) { |
|
400 | - return $row['document_name']; |
|
401 | - } |
|
402 | - } |
|
403 | - return null; |
|
404 | - } |
|
369 | + $revisions= $this->get_linked_beans('revisions','DocumentRevision'); |
|
370 | + |
|
371 | + if (!empty($revisions) && is_array($revisions)) { |
|
372 | + foreach($revisions as $key=>$version) { |
|
373 | + UploadFile::unlink_file($version->id,$version->filename); |
|
374 | + //mark the version deleted. |
|
375 | + $version->mark_deleted($version->id); |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + } |
|
380 | + |
|
381 | + |
|
382 | + function bean_implements($interface) { |
|
383 | + switch ($interface) { |
|
384 | + case 'ACL' : |
|
385 | + return true; |
|
386 | + } |
|
387 | + return false; |
|
388 | + } |
|
389 | + |
|
390 | + //static function. |
|
391 | + function get_document_name($doc_id){ |
|
392 | + if (empty($doc_id)) return null; |
|
393 | + |
|
394 | + $db = DBManagerFactory::getInstance(); |
|
395 | + $query="select document_name from documents where id='$doc_id' and deleted=0"; |
|
396 | + $result=$db->query($query); |
|
397 | + if (!empty($result)) { |
|
398 | + $row=$db->fetchByAssoc($result); |
|
399 | + if (!empty($row)) { |
|
400 | + return $row['document_name']; |
|
401 | + } |
|
402 | + } |
|
403 | + return null; |
|
404 | + } |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | require_once('modules/Documents/DocumentExternalApiDropDown.php'); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | var $object_name = "Document"; |
85 | 85 | var $user_preferences; |
86 | 86 | |
87 | - var $encodeFields = Array (); |
|
87 | + var $encodeFields = Array(); |
|
88 | 88 | |
89 | 89 | // This is used to retrieve related fields from form posts. |
90 | - var $additional_column_fields = Array ('revision'); |
|
90 | + var $additional_column_fields = Array('revision'); |
|
91 | 91 | |
92 | 92 | var $new_schema = true; |
93 | 93 | var $module_dir = 'Documents'; |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @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 |
108 | 108 | */ |
109 | - function Document(){ |
|
109 | + function Document() { |
|
110 | 110 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
111 | - if(isset($GLOBALS['log'])) { |
|
111 | + if (isset($GLOBALS['log'])) { |
|
112 | 112 | $GLOBALS['log']->deprecated($deprecatedMessage); |
113 | 113 | } |
114 | 114 | else { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->new_with_id = true; |
131 | 131 | } |
132 | 132 | |
133 | - if ( isset($_REQUEST) && isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] == true && isset($_REQUEST['filename_old_doctype']) ) { |
|
133 | + if (isset($_REQUEST) && isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] == true && isset($_REQUEST['filename_old_doctype'])) { |
|
134 | 134 | $this->doc_type = $_REQUEST['filename_old_doctype']; |
135 | 135 | $isDuplicate = true; |
136 | 136 | } else { |
@@ -143,26 +143,26 @@ discard block |
||
143 | 143 | $Revision->not_use_rel_in_req = true; |
144 | 144 | $Revision->new_rel_id = $this->id; |
145 | 145 | $Revision->new_rel_relname = 'Documents'; |
146 | - $Revision->change_log = translate('DEF_CREATE_LOG','Documents'); |
|
146 | + $Revision->change_log = translate('DEF_CREATE_LOG', 'Documents'); |
|
147 | 147 | $Revision->revision = $this->revision; |
148 | 148 | $Revision->document_id = $this->id; |
149 | 149 | $Revision->filename = $this->filename; |
150 | 150 | |
151 | - if(isset($this->file_ext)) |
|
151 | + if (isset($this->file_ext)) |
|
152 | 152 | { |
153 | 153 | $Revision->file_ext = $this->file_ext; |
154 | 154 | } |
155 | 155 | |
156 | - if(isset($this->file_mime_type)) |
|
156 | + if (isset($this->file_mime_type)) |
|
157 | 157 | { |
158 | 158 | $Revision->file_mime_type = $this->file_mime_type; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $Revision->doc_type = $this->doc_type; |
162 | - if ( isset($this->doc_id) ) { |
|
162 | + if (isset($this->doc_id)) { |
|
163 | 163 | $Revision->doc_id = $this->doc_id; |
164 | 164 | } |
165 | - if ( isset($this->doc_url) ) { |
|
165 | + if (isset($this->doc_url)) { |
|
166 | 166 | $Revision->doc_url = $this->doc_url; |
167 | 167 | } |
168 | 168 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | if (!empty($_FILES['filename_file'])) { |
175 | 175 | rename("upload://{$this->id}", "upload://{$Revision->id}"); |
176 | 176 | $createRevision = true; |
177 | - } else if ( $isDuplicate && ( empty($this->doc_type) || $this->doc_type == 'Sugar' ) ) { |
|
177 | + } else if ($isDuplicate && (empty($this->doc_type) || $this->doc_type == 'Sugar')) { |
|
178 | 178 | // Looks like we need to duplicate a file, this is tricky |
179 | 179 | $oldDocument = new Document(); |
180 | 180 | $oldDocument->retrieve($_REQUEST['duplicateId']); |
@@ -186,27 +186,27 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | // For external documents, we just need to make sure we have a doc_id |
189 | - if ( !empty($this->doc_id) && $this->doc_type != 'Sugar' ) { |
|
189 | + if (!empty($this->doc_id) && $this->doc_type != 'Sugar') { |
|
190 | 190 | $createRevision = true; |
191 | 191 | } |
192 | 192 | |
193 | - if ( $createRevision ) { |
|
193 | + if ($createRevision) { |
|
194 | 194 | $Revision->save(); |
195 | 195 | //update document with latest revision id |
196 | - $this->process_save_dates=false; //make sure that conversion does not happen again. |
|
196 | + $this->process_save_dates = false; //make sure that conversion does not happen again. |
|
197 | 197 | $this->document_revision_id = $Revision->id; |
198 | 198 | } |
199 | 199 | |
200 | 200 | |
201 | 201 | //set relationship field values if contract_id is passed (via subpanel create) |
202 | 202 | if (!empty($_POST['contract_id'])) { |
203 | - $save_revision['document_revision_id']=$this->document_revision_id; |
|
203 | + $save_revision['document_revision_id'] = $this->document_revision_id; |
|
204 | 204 | $this->load_relationship('contracts'); |
205 | - $this->contracts->add($_POST['contract_id'],$save_revision); |
|
205 | + $this->contracts->add($_POST['contract_id'], $save_revision); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | if ((isset($_POST['load_signed_id']) and !empty($_POST['load_signed_id']))) { |
209 | - $query="update linked_documents set deleted=1 where id='".$_POST['load_signed_id']."'"; |
|
209 | + $query = "update linked_documents set deleted=1 where id='".$_POST['load_signed_id']."'"; |
|
210 | 210 | $this->db->query($query); |
211 | 211 | } |
212 | 212 | } |
@@ -247,14 +247,14 @@ discard block |
||
247 | 247 | $row = $this->db->fetchByAssoc($result); |
248 | 248 | |
249 | 249 | //populate name |
250 | - if(isset($this->document_name)) |
|
250 | + if (isset($this->document_name)) |
|
251 | 251 | { |
252 | 252 | $this->name = $this->document_name; |
253 | 253 | } |
254 | 254 | |
255 | - if(isset($row['filename']))$this->filename = $row['filename']; |
|
255 | + if (isset($row['filename']))$this->filename = $row['filename']; |
|
256 | 256 | //$this->latest_revision = $row['revision']; |
257 | - if(isset($row['revision']))$this->revision = $row['revision']; |
|
257 | + if (isset($row['revision']))$this->revision = $row['revision']; |
|
258 | 258 | |
259 | 259 | //image is selected based on the extension name <ext>_icon_inline, extension is stored in document_revisions. |
260 | 260 | //if file is not found then default image file will be used. |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | } else { |
273 | 273 | $img_name = "def_image_inline"; //todo change the default image. |
274 | 274 | } |
275 | - if($this->ACLAccess('DetailView')) { |
|
276 | - if(!empty($this->doc_type) && $this->doc_type != 'Sugar' && !empty($this->doc_url)) { |
|
277 | - $file_url= "<a href='".$this->doc_url."' target='_blank'>".SugarThemeRegistry::current()->getImage($this->doc_type.'_image_inline', 'border="0"',null,null,'.png',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
275 | + if ($this->ACLAccess('DetailView')) { |
|
276 | + if (!empty($this->doc_type) && $this->doc_type != 'Sugar' && !empty($this->doc_url)) { |
|
277 | + $file_url = "<a href='".$this->doc_url."' target='_blank'>".SugarThemeRegistry::current()->getImage($this->doc_type.'_image_inline', 'border="0"', null, null, '.png', $mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
278 | 278 | } else { |
279 | - $file_url = "<a href='index.php?entryPoint=download&id={$this->document_revision_id}&type=Documents' target='_blank'>".SugarThemeRegistry::current()->getImage($img_name, 'border="0"', null,null,'.gif',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
279 | + $file_url = "<a href='index.php?entryPoint=download&id={$this->document_revision_id}&type=Documents' target='_blank'>".SugarThemeRegistry::current()->getImage($img_name, 'border="0"', null, null, '.gif', $mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $this->file_url = $file_url; |
283 | 283 | $this->file_url_noimage = "index.php?entryPoint=download&type=Documents&id={$this->document_revision_id}"; |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | $this->file_url = ""; |
286 | 286 | $this->file_url_noimage = ""; |
287 | 287 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | global $app_list_strings; |
298 | - if(!empty($this->status_id)) { |
|
298 | + if (!empty($this->status_id)) { |
|
299 | 299 | //_pp($this->status_id); |
300 | 300 | $this->status = $app_list_strings['document_status_dom'][$this->status_id]; |
301 | 301 | } |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | return $list_form; |
310 | 310 | } |
311 | 311 | |
312 | - function create_export_query($order_by, $where, $relate_link_join='') |
|
312 | + function create_export_query($order_by, $where, $relate_link_join = '') |
|
313 | 313 | { |
314 | 314 | $custom_join = $this->getCustomJoin(true, true, $where); |
315 | 315 | $custom_join['join'] .= $relate_link_join; |
316 | 316 | $query = "SELECT |
317 | 317 | documents.*"; |
318 | - $query .= $custom_join['select']; |
|
318 | + $query .= $custom_join['select']; |
|
319 | 319 | $query .= " FROM documents "; |
320 | - $query .= $custom_join['join']; |
|
320 | + $query .= $custom_join['join']; |
|
321 | 321 | |
322 | 322 | $where_auto = " documents.deleted = 0"; |
323 | 323 | |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | function mark_relationships_deleted($id) |
367 | 367 | { |
368 | 368 | $this->load_relationships('revisions'); |
369 | - $revisions= $this->get_linked_beans('revisions','DocumentRevision'); |
|
369 | + $revisions = $this->get_linked_beans('revisions', 'DocumentRevision'); |
|
370 | 370 | |
371 | 371 | if (!empty($revisions) && is_array($revisions)) { |
372 | - foreach($revisions as $key=>$version) { |
|
373 | - UploadFile::unlink_file($version->id,$version->filename); |
|
372 | + foreach ($revisions as $key=>$version) { |
|
373 | + UploadFile::unlink_file($version->id, $version->filename); |
|
374 | 374 | //mark the version deleted. |
375 | 375 | $version->mark_deleted($version->id); |
376 | 376 | } |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | //static function. |
391 | - function get_document_name($doc_id){ |
|
391 | + function get_document_name($doc_id) { |
|
392 | 392 | if (empty($doc_id)) return null; |
393 | 393 | |
394 | 394 | $db = DBManagerFactory::getInstance(); |
395 | - $query="select document_name from documents where id='$doc_id' and deleted=0"; |
|
396 | - $result=$db->query($query); |
|
395 | + $query = "select document_name from documents where id='$doc_id' and deleted=0"; |
|
396 | + $result = $db->query($query); |
|
397 | 397 | if (!empty($result)) { |
398 | - $row=$db->fetchByAssoc($result); |
|
398 | + $row = $db->fetchByAssoc($result); |
|
399 | 399 | if (!empty($row)) { |
400 | 400 | return $row['document_name']; |
401 | 401 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -110,8 +111,7 @@ discard block |
||
110 | 111 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
111 | 112 | if(isset($GLOBALS['log'])) { |
112 | 113 | $GLOBALS['log']->deprecated($deprecatedMessage); |
113 | - } |
|
114 | - else { |
|
114 | + } else { |
|
115 | 115 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
116 | 116 | } |
117 | 117 | self::__construct(); |
@@ -252,9 +252,13 @@ discard block |
||
252 | 252 | $this->name = $this->document_name; |
253 | 253 | } |
254 | 254 | |
255 | - if(isset($row['filename']))$this->filename = $row['filename']; |
|
255 | + if(isset($row['filename'])) { |
|
256 | + $this->filename = $row['filename']; |
|
257 | + } |
|
256 | 258 | //$this->latest_revision = $row['revision']; |
257 | - if(isset($row['revision']))$this->revision = $row['revision']; |
|
259 | + if(isset($row['revision'])) { |
|
260 | + $this->revision = $row['revision']; |
|
261 | + } |
|
258 | 262 | |
259 | 263 | //image is selected based on the extension name <ext>_icon_inline, extension is stored in document_revisions. |
260 | 264 | //if file is not found then default image file will be used. |
@@ -281,7 +285,7 @@ discard block |
||
281 | 285 | |
282 | 286 | $this->file_url = $file_url; |
283 | 287 | $this->file_url_noimage = "index.php?entryPoint=download&type=Documents&id={$this->document_revision_id}"; |
284 | - }else{ |
|
288 | + } else{ |
|
285 | 289 | $this->file_url = ""; |
286 | 290 | $this->file_url_noimage = ""; |
287 | 291 | } |
@@ -321,15 +325,17 @@ discard block |
||
321 | 325 | |
322 | 326 | $where_auto = " documents.deleted = 0"; |
323 | 327 | |
324 | - if ($where != "") |
|
325 | - $query .= " WHERE $where AND ".$where_auto; |
|
326 | - else |
|
327 | - $query .= " WHERE ".$where_auto; |
|
328 | + if ($where != "") { |
|
329 | + $query .= " WHERE $where AND ".$where_auto; |
|
330 | + } else { |
|
331 | + $query .= " WHERE ".$where_auto; |
|
332 | + } |
|
328 | 333 | |
329 | - if ($order_by != "") |
|
330 | - $query .= " ORDER BY $order_by"; |
|
331 | - else |
|
332 | - $query .= " ORDER BY documents.document_name"; |
|
334 | + if ($order_by != "") { |
|
335 | + $query .= " ORDER BY $order_by"; |
|
336 | + } else { |
|
337 | + $query .= " ORDER BY documents.document_name"; |
|
338 | + } |
|
333 | 339 | |
334 | 340 | return $query; |
335 | 341 | } |
@@ -389,7 +395,9 @@ discard block |
||
389 | 395 | |
390 | 396 | //static function. |
391 | 397 | function get_document_name($doc_id){ |
392 | - if (empty($doc_id)) return null; |
|
398 | + if (empty($doc_id)) { |
|
399 | + return null; |
|
400 | + } |
|
393 | 401 | |
394 | 402 | $db = DBManagerFactory::getInstance(); |
395 | 403 | $query="select document_name from documents where id='$doc_id' and deleted=0"; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | var $object_name = 'AM_TaskTemplates'; |
48 | 48 | var $table_name = 'am_tasktemplates'; |
49 | 49 | var $importable = false; |
50 | - 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 |
|
50 | + 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 |
|
51 | 51 | var $id; |
52 | 52 | var $name; |
53 | 53 | var $date_entered; |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | var $utilization; |
76 | 76 | var $duration; |
77 | 77 | |
78 | - function __construct(){ |
|
78 | + function __construct() { |
|
79 | 79 | parent::__construct(); |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @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 |
84 | 84 | */ |
85 | - function AM_TaskTemplates_sugar(){ |
|
85 | + function AM_TaskTemplates_sugar() { |
|
86 | 86 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
87 | - if(isset($GLOBALS['log'])) { |
|
87 | + if (isset($GLOBALS['log'])) { |
|
88 | 88 | $GLOBALS['log']->deprecated($deprecatedMessage); |
89 | 89 | } |
90 | 90 | else { |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | - function bean_implements($interface){ |
|
98 | - switch($interface){ |
|
97 | + function bean_implements($interface) { |
|
98 | + switch ($interface) { |
|
99 | 99 | case 'ACL': return true; |
100 | 100 | } |
101 | 101 | 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); |
@@ -40,9 +40,9 @@ |
||
40 | 40 | require_once('modules/AM_TaskTemplates/AM_TaskTemplates_sugar.php'); |
41 | 41 | class AM_TaskTemplates extends AM_TaskTemplates_sugar { |
42 | 42 | |
43 | - public function __construct(){ |
|
44 | - parent::__construct(); |
|
45 | - } |
|
43 | + public function __construct(){ |
|
44 | + parent::__construct(); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @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 |
@@ -40,16 +40,16 @@ |
||
40 | 40 | require_once('modules/AM_TaskTemplates/AM_TaskTemplates_sugar.php'); |
41 | 41 | class AM_TaskTemplates extends AM_TaskTemplates_sugar { |
42 | 42 | |
43 | - public function __construct(){ |
|
43 | + public function __construct() { |
|
44 | 44 | parent::__construct(); |
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @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 |
49 | 49 | */ |
50 | - public function AM_TaskTemplates(){ |
|
50 | + public function AM_TaskTemplates() { |
|
51 | 51 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
52 | - if(isset($GLOBALS['log'])) { |
|
52 | + if (isset($GLOBALS['log'])) { |
|
53 | 53 | $GLOBALS['log']->deprecated($deprecatedMessage); |
54 | 54 | } |
55 | 55 | 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); |
@@ -41,185 +41,185 @@ discard block |
||
41 | 41 | |
42 | 42 | class UpgradeMetaHelper{ |
43 | 43 | |
44 | - var $upgrade_dir; |
|
45 | - var $debug_mode; |
|
46 | - var $upgrade_modules; |
|
47 | - var $customized_modules; |
|
48 | - var $source_dir; |
|
49 | - var $dest_dir ; |
|
50 | - var $evparser; |
|
51 | - var $dvparser; |
|
52 | - var $path_to_master_copy; |
|
53 | - /** |
|
54 | - * UpgradeMetaHelper |
|
55 | - * This is the constructor for the UpgradeMetaHelper class |
|
56 | - * @param $dir The root upgrade directory (where to copy working files) |
|
57 | - * @param $masterCopyDirectory The root master directory (where SugarCRM 5.x files reside) |
|
58 | - * @param $debugMode Debug mode, default is false |
|
59 | - * |
|
60 | - */ |
|
61 | - function __construct($dir='upgrade', $masterCopyDirecotry='modules_50', $debugMode = false) { |
|
62 | - $this->upgrade_dir = $dir; |
|
63 | - $this->debug_mode = $debugMode; |
|
64 | - $this->upgrade_modules = $this->getModifiedModules(); |
|
65 | - |
|
66 | - if(count($this->upgrade_modules) > 0) { |
|
67 | - $_SESSION['Upgraded_Modules'] = $this->upgrade_modules; |
|
68 | - $this->create_upgrade_directory(); |
|
69 | - $this->path_to_master_copy = $masterCopyDirecotry; |
|
70 | - $this->runParser(); |
|
71 | - } |
|
72 | - |
|
73 | - $this->customized_modules = $this->getAllCustomizedModulesBeyondStudio(); |
|
74 | - if(count($this->customized_modules) > 0) { |
|
75 | - $_SESSION['Customized_Modules'] = $this->customized_modules; |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @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 |
|
81 | - */ |
|
82 | - function UpgradeMetaHelper($dir='upgrade', $masterCopyDirecotry='modules_50', $debugMode = false){ |
|
83 | - $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
84 | - if(isset($GLOBALS['log'])) { |
|
85 | - $GLOBALS['log']->deprecated($deprecatedMessage); |
|
86 | - } |
|
87 | - else { |
|
88 | - trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
89 | - } |
|
90 | - self::__construct($dir, $masterCopyDirecotry, $debugMode); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * getModifiedModules |
|
95 | - * This method returns a two-dimensional Array of Studio enabled |
|
96 | - * modules that have been modified. The second Array index is an |
|
97 | - * Array of files that do not match the md5 checksum for the module |
|
98 | - * @return $return_array Two-dimensional Array of [module][modified file(s) Array] |
|
99 | - */ |
|
100 | - function getModifiedModules() { |
|
101 | - |
|
102 | - $md5_string = array(); |
|
103 | - if(file_exists(clean_path(getcwd().'/files.md5'))){ |
|
104 | - require(clean_path(getcwd().'/files.md5')); |
|
105 | - } |
|
106 | - |
|
107 | - $return_array = array(); |
|
108 | - $modules = $this->loadStudioModules(); |
|
109 | - foreach($modules as $mod) { |
|
110 | - |
|
111 | - $editView = "modules/$mod/EditView.html"; |
|
112 | - $detailView = "modules/$mod/DetailView.html"; |
|
113 | - $searchForm = "modules/$mod/SearchForm.html"; |
|
114 | - if(file_exists($editView) && isset($md5_string['./' . $editView])) { |
|
115 | - $fileContents = file_get_contents($editView); |
|
116 | - if(md5($fileContents) != $md5_string['./' . $editView]) { |
|
117 | - $return_array[$mod][] = $editView; |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - if(file_exists($detailView) && isset($md5_string['./' . $detailView])) { |
|
122 | - $fileContents = file_get_contents($detailView); |
|
123 | - if(md5($fileContents) != $md5_string['./' . $detailView]) { |
|
124 | - $return_array[$mod][] = $detailView; |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - if(file_exists($searchForm) && isset($md5_string['./' . $searchForm])) { |
|
129 | - $fileContents = file_get_contents($searchForm); |
|
130 | - if(md5($fileContents) != $md5_string['./' . $searchForm]) { |
|
131 | - $return_array[$mod][] = $searchForm; |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - } //foreach |
|
136 | - |
|
137 | - return $return_array; |
|
138 | - } |
|
44 | + var $upgrade_dir; |
|
45 | + var $debug_mode; |
|
46 | + var $upgrade_modules; |
|
47 | + var $customized_modules; |
|
48 | + var $source_dir; |
|
49 | + var $dest_dir ; |
|
50 | + var $evparser; |
|
51 | + var $dvparser; |
|
52 | + var $path_to_master_copy; |
|
53 | + /** |
|
54 | + * UpgradeMetaHelper |
|
55 | + * This is the constructor for the UpgradeMetaHelper class |
|
56 | + * @param $dir The root upgrade directory (where to copy working files) |
|
57 | + * @param $masterCopyDirectory The root master directory (where SugarCRM 5.x files reside) |
|
58 | + * @param $debugMode Debug mode, default is false |
|
59 | + * |
|
60 | + */ |
|
61 | + function __construct($dir='upgrade', $masterCopyDirecotry='modules_50', $debugMode = false) { |
|
62 | + $this->upgrade_dir = $dir; |
|
63 | + $this->debug_mode = $debugMode; |
|
64 | + $this->upgrade_modules = $this->getModifiedModules(); |
|
65 | + |
|
66 | + if(count($this->upgrade_modules) > 0) { |
|
67 | + $_SESSION['Upgraded_Modules'] = $this->upgrade_modules; |
|
68 | + $this->create_upgrade_directory(); |
|
69 | + $this->path_to_master_copy = $masterCopyDirecotry; |
|
70 | + $this->runParser(); |
|
71 | + } |
|
72 | + |
|
73 | + $this->customized_modules = $this->getAllCustomizedModulesBeyondStudio(); |
|
74 | + if(count($this->customized_modules) > 0) { |
|
75 | + $_SESSION['Customized_Modules'] = $this->customized_modules; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @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 |
|
81 | + */ |
|
82 | + function UpgradeMetaHelper($dir='upgrade', $masterCopyDirecotry='modules_50', $debugMode = false){ |
|
83 | + $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
84 | + if(isset($GLOBALS['log'])) { |
|
85 | + $GLOBALS['log']->deprecated($deprecatedMessage); |
|
86 | + } |
|
87 | + else { |
|
88 | + trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
89 | + } |
|
90 | + self::__construct($dir, $masterCopyDirecotry, $debugMode); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * getModifiedModules |
|
95 | + * This method returns a two-dimensional Array of Studio enabled |
|
96 | + * modules that have been modified. The second Array index is an |
|
97 | + * Array of files that do not match the md5 checksum for the module |
|
98 | + * @return $return_array Two-dimensional Array of [module][modified file(s) Array] |
|
99 | + */ |
|
100 | + function getModifiedModules() { |
|
101 | + |
|
102 | + $md5_string = array(); |
|
103 | + if(file_exists(clean_path(getcwd().'/files.md5'))){ |
|
104 | + require(clean_path(getcwd().'/files.md5')); |
|
105 | + } |
|
106 | + |
|
107 | + $return_array = array(); |
|
108 | + $modules = $this->loadStudioModules(); |
|
109 | + foreach($modules as $mod) { |
|
110 | + |
|
111 | + $editView = "modules/$mod/EditView.html"; |
|
112 | + $detailView = "modules/$mod/DetailView.html"; |
|
113 | + $searchForm = "modules/$mod/SearchForm.html"; |
|
114 | + if(file_exists($editView) && isset($md5_string['./' . $editView])) { |
|
115 | + $fileContents = file_get_contents($editView); |
|
116 | + if(md5($fileContents) != $md5_string['./' . $editView]) { |
|
117 | + $return_array[$mod][] = $editView; |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + if(file_exists($detailView) && isset($md5_string['./' . $detailView])) { |
|
122 | + $fileContents = file_get_contents($detailView); |
|
123 | + if(md5($fileContents) != $md5_string['./' . $detailView]) { |
|
124 | + $return_array[$mod][] = $detailView; |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + if(file_exists($searchForm) && isset($md5_string['./' . $searchForm])) { |
|
129 | + $fileContents = file_get_contents($searchForm); |
|
130 | + if(md5($fileContents) != $md5_string['./' . $searchForm]) { |
|
131 | + $return_array[$mod][] = $searchForm; |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + } //foreach |
|
136 | + |
|
137 | + return $return_array; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | function saveMatchingFilesQueries($currStep,$value){ |
141 | - $upgrade_progress_dir = sugar_cached('upgrades/temp'); |
|
142 | - if(!is_dir($upgrade_progress_dir)){ |
|
143 | - mkdir($upgrade_progress_dir); |
|
144 | - } |
|
145 | - $file_queries_file = $upgrade_progress_dir.'/files_queries.php'; |
|
146 | - if(file_exists($file_queries_file)){ |
|
147 | - include($file_queries_file); |
|
148 | - } |
|
149 | - else{ |
|
150 | - if(function_exists('sugar_fopen')){ |
|
151 | - sugar_fopen($file_queries_file, 'w+'); |
|
152 | - } |
|
153 | - else{ |
|
154 | - fopen($file_queries_file, 'w+'); |
|
155 | - } |
|
156 | - } |
|
157 | - if(!isset($files_queries) || $files_queries == NULL){ |
|
158 | - $files_queries = array(); |
|
159 | - } |
|
160 | - $files_queries[$currStep]=$value; |
|
161 | - if(is_writable($file_queries_file) && write_array_to_file( "file_queries", $file_queries, |
|
162 | - $file_queries_file)) { |
|
163 | - //writing to the file |
|
164 | - } |
|
141 | + $upgrade_progress_dir = sugar_cached('upgrades/temp'); |
|
142 | + if(!is_dir($upgrade_progress_dir)){ |
|
143 | + mkdir($upgrade_progress_dir); |
|
144 | + } |
|
145 | + $file_queries_file = $upgrade_progress_dir.'/files_queries.php'; |
|
146 | + if(file_exists($file_queries_file)){ |
|
147 | + include($file_queries_file); |
|
148 | + } |
|
149 | + else{ |
|
150 | + if(function_exists('sugar_fopen')){ |
|
151 | + sugar_fopen($file_queries_file, 'w+'); |
|
152 | + } |
|
153 | + else{ |
|
154 | + fopen($file_queries_file, 'w+'); |
|
155 | + } |
|
156 | + } |
|
157 | + if(!isset($files_queries) || $files_queries == NULL){ |
|
158 | + $files_queries = array(); |
|
159 | + } |
|
160 | + $files_queries[$currStep]=$value; |
|
161 | + if(is_writable($file_queries_file) && write_array_to_file( "file_queries", $file_queries, |
|
162 | + $file_queries_file)) { |
|
163 | + //writing to the file |
|
164 | + } |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | function getAllCustomizedModulesBeyondStudio() { |
168 | 168 | |
169 | - require_once('modules/UpgradeWizard/uw_utils.php'); |
|
170 | - $md5_string = array(); |
|
171 | - if(file_exists(clean_path(getcwd().'/files.md5'))){ |
|
172 | - require(clean_path(getcwd().'/files.md5')); |
|
173 | - } |
|
169 | + require_once('modules/UpgradeWizard/uw_utils.php'); |
|
170 | + $md5_string = array(); |
|
171 | + if(file_exists(clean_path(getcwd().'/files.md5'))){ |
|
172 | + require(clean_path(getcwd().'/files.md5')); |
|
173 | + } |
|
174 | 174 | $return_array = array(); |
175 | 175 | $modules = $this->loadStudioModules(); |
176 | 176 | $modulesAll = getAllModules(); //keep all modules as well |
177 | 177 | $allOtherModules = array_diff($modulesAll,$modules); |
178 | 178 | foreach($modules as $mod) { |
179 | - if(!is_dir('modules/'.$mod)) continue; |
|
180 | - $editView = "modules/$mod/EditView.html"; |
|
181 | - $detailView ="modules/$mod/DetailView.html"; |
|
182 | - $exclude_files[]=$editView; |
|
183 | - $exclude_files[]=$detailView; |
|
184 | - $allModFiles = array(); |
|
185 | - $allModFiles = findAllFiles('modules/'.$mod,$allModFiles); |
|
186 | - foreach($allModFiles as $file){ |
|
187 | - //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
|
188 | - if(file_exists($file) && !in_array($file,$exclude_files)){ |
|
189 | - if(isset($md5_string['./'.$file])) { |
|
190 | - $fileContents = file_get_contents($file); |
|
191 | - if(md5($fileContents) != $md5_string['./'.$file]) { |
|
192 | - $return_array[$mod][] = $file; |
|
193 | - } |
|
194 | - else{ |
|
195 | - //keep in the array to be deleted later |
|
196 | - $_SESSION['removeMd5MatchingFiles'][] = $file; |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
179 | + if(!is_dir('modules/'.$mod)) continue; |
|
180 | + $editView = "modules/$mod/EditView.html"; |
|
181 | + $detailView ="modules/$mod/DetailView.html"; |
|
182 | + $exclude_files[]=$editView; |
|
183 | + $exclude_files[]=$detailView; |
|
184 | + $allModFiles = array(); |
|
185 | + $allModFiles = findAllFiles('modules/'.$mod,$allModFiles); |
|
186 | + foreach($allModFiles as $file){ |
|
187 | + //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
|
188 | + if(file_exists($file) && !in_array($file,$exclude_files)){ |
|
189 | + if(isset($md5_string['./'.$file])) { |
|
190 | + $fileContents = file_get_contents($file); |
|
191 | + if(md5($fileContents) != $md5_string['./'.$file]) { |
|
192 | + $return_array[$mod][] = $file; |
|
193 | + } |
|
194 | + else{ |
|
195 | + //keep in the array to be deleted later |
|
196 | + $_SESSION['removeMd5MatchingFiles'][] = $file; |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | 201 | } //foreach |
202 | 202 | //also check out other non-studio modules by taking the difference between |
203 | 203 | //allMOdules and |
204 | - foreach($allOtherModules as $mod) { |
|
205 | - if(!is_dir('modules/'.$mod)) continue; |
|
206 | - $allModFiles = array(); |
|
207 | - $allModFiles = findAllFiles('modules/'.$mod,$allModFiles); |
|
208 | - foreach($allModFiles as $file){ |
|
209 | - //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
|
210 | - if(file_exists($file)){ |
|
211 | - if(isset($md5_string['./'.$file])) { |
|
212 | - $fileContents = file_get_contents($file); |
|
213 | - if(md5($fileContents) == $md5_string['./'.$file]) { |
|
214 | - $_SESSION['removeMd5MatchingFiles'][] = $file; |
|
215 | - } |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
219 | - } |
|
220 | - //Also store in a file |
|
221 | - //saveMatchingFilesQueries('removeMd5MatchingFiles',$_SESSION['removeMd5MatchingFiles']); |
|
222 | - return $return_array; |
|
204 | + foreach($allOtherModules as $mod) { |
|
205 | + if(!is_dir('modules/'.$mod)) continue; |
|
206 | + $allModFiles = array(); |
|
207 | + $allModFiles = findAllFiles('modules/'.$mod,$allModFiles); |
|
208 | + foreach($allModFiles as $file){ |
|
209 | + //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
|
210 | + if(file_exists($file)){ |
|
211 | + if(isset($md5_string['./'.$file])) { |
|
212 | + $fileContents = file_get_contents($file); |
|
213 | + if(md5($fileContents) == $md5_string['./'.$file]) { |
|
214 | + $_SESSION['removeMd5MatchingFiles'][] = $file; |
|
215 | + } |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | + } |
|
220 | + //Also store in a file |
|
221 | + //saveMatchingFilesQueries('removeMd5MatchingFiles',$_SESSION['removeMd5MatchingFiles']); |
|
222 | + return $return_array; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -231,39 +231,39 @@ discard block |
||
231 | 231 | */ |
232 | 232 | function getAllCustomizedModules() { |
233 | 233 | |
234 | - require_once('files.md5'); |
|
235 | - |
|
236 | - $return_array = array(); |
|
237 | - $modules = getAllModules(); |
|
238 | - foreach($modules as $mod) { |
|
239 | - //find all files in each module if the files have been modified |
|
240 | - //as compared to the base version then add the module to the |
|
241 | - //customized modules array |
|
242 | - $modFiles = findAllFiles(clean_path(getcwd())."/modules/$mod", array()); |
|
243 | - foreach($modFiles as $file){ |
|
244 | - $fileContents = file_get_contents($file); |
|
245 | - $file = str_replace(clean_path(getcwd()),'',$file); |
|
246 | - if($md5_string['./' . $file]){ |
|
247 | - if(md5($fileContents) != $md5_string['./' . $file]) { |
|
248 | - //A file has been customized in the module. Put the module into the |
|
249 | - // customized modules array. |
|
250 | - echo 'Changed File'.$file; |
|
251 | - $return_array[$mod]; |
|
252 | - break; |
|
253 | - } |
|
254 | - } |
|
255 | - else{ |
|
256 | - // This is a new file in user's version and indicates that module has been |
|
257 | - //customized. Put the module in the customized array. |
|
258 | - echo 'New File'.$file; |
|
259 | - $return_array[$mod]; |
|
260 | - break; |
|
261 | - } |
|
262 | - } |
|
263 | - } //foreach |
|
264 | - |
|
265 | - return $return_array; |
|
266 | - } |
|
234 | + require_once('files.md5'); |
|
235 | + |
|
236 | + $return_array = array(); |
|
237 | + $modules = getAllModules(); |
|
238 | + foreach($modules as $mod) { |
|
239 | + //find all files in each module if the files have been modified |
|
240 | + //as compared to the base version then add the module to the |
|
241 | + //customized modules array |
|
242 | + $modFiles = findAllFiles(clean_path(getcwd())."/modules/$mod", array()); |
|
243 | + foreach($modFiles as $file){ |
|
244 | + $fileContents = file_get_contents($file); |
|
245 | + $file = str_replace(clean_path(getcwd()),'',$file); |
|
246 | + if($md5_string['./' . $file]){ |
|
247 | + if(md5($fileContents) != $md5_string['./' . $file]) { |
|
248 | + //A file has been customized in the module. Put the module into the |
|
249 | + // customized modules array. |
|
250 | + echo 'Changed File'.$file; |
|
251 | + $return_array[$mod]; |
|
252 | + break; |
|
253 | + } |
|
254 | + } |
|
255 | + else{ |
|
256 | + // This is a new file in user's version and indicates that module has been |
|
257 | + //customized. Put the module in the customized array. |
|
258 | + echo 'New File'.$file; |
|
259 | + $return_array[$mod]; |
|
260 | + break; |
|
261 | + } |
|
262 | + } |
|
263 | + } //foreach |
|
264 | + |
|
265 | + return $return_array; |
|
266 | + } |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * loadStudioModules |
@@ -271,139 +271,139 @@ discard block |
||
271 | 271 | * present in the metadata directory of the module |
272 | 272 | * @return $modules Array of modules that are studio enabled |
273 | 273 | */ |
274 | - function loadStudioModules() { |
|
275 | - $modules = array(); |
|
276 | - $d = dir('modules'); |
|
277 | - while($e = $d->read()){ |
|
278 | - if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue; |
|
279 | - if(file_exists('modules/' . $e . '/metadata/studio.php')){ |
|
280 | - $modules[] = $e; |
|
281 | - } |
|
282 | - } |
|
283 | - return $modules; |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * runParser |
|
289 | - * This method creates the EditView and DetailView parser intances |
|
290 | - * and runs the parsing for the modules to upgrade |
|
291 | - * |
|
292 | - */ |
|
293 | - function runParser() { |
|
294 | - require_once('include/SugarFields/Parsers/EditViewMetaParser.php'); |
|
295 | - require_once('include/SugarFields/Parsers/DetailViewMetaParser.php'); |
|
296 | - require_once('include/SugarFields/Parsers/SearchFormMetaParser.php'); |
|
297 | - |
|
298 | - $this->evparser = new EditViewMetaParser(); |
|
299 | - $this->dvparser = new DetailViewMetaParser(); |
|
300 | - $this->svparser = new SearchFormMetaParser(); |
|
301 | - |
|
302 | - foreach($this->upgrade_modules as $module_name=>$files) { |
|
303 | - $this->parseFile($module_name, $files); |
|
304 | - } //foreach |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * parseFile |
|
310 | - * Hanldes parsing the files for given module where Studio or manual |
|
311 | - * changes have been detected. |
|
312 | - * @param $module_name The module to parse |
|
313 | - * @param $files Array of files found to parse |
|
314 | - * |
|
315 | - */ |
|
316 | - function parseFile($module_name, $files) { |
|
317 | - global $beanList, $dictionary; |
|
318 | - foreach($files as $file) { |
|
274 | + function loadStudioModules() { |
|
275 | + $modules = array(); |
|
276 | + $d = dir('modules'); |
|
277 | + while($e = $d->read()){ |
|
278 | + if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue; |
|
279 | + if(file_exists('modules/' . $e . '/metadata/studio.php')){ |
|
280 | + $modules[] = $e; |
|
281 | + } |
|
282 | + } |
|
283 | + return $modules; |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * runParser |
|
289 | + * This method creates the EditView and DetailView parser intances |
|
290 | + * and runs the parsing for the modules to upgrade |
|
291 | + * |
|
292 | + */ |
|
293 | + function runParser() { |
|
294 | + require_once('include/SugarFields/Parsers/EditViewMetaParser.php'); |
|
295 | + require_once('include/SugarFields/Parsers/DetailViewMetaParser.php'); |
|
296 | + require_once('include/SugarFields/Parsers/SearchFormMetaParser.php'); |
|
297 | + |
|
298 | + $this->evparser = new EditViewMetaParser(); |
|
299 | + $this->dvparser = new DetailViewMetaParser(); |
|
300 | + $this->svparser = new SearchFormMetaParser(); |
|
301 | + |
|
302 | + foreach($this->upgrade_modules as $module_name=>$files) { |
|
303 | + $this->parseFile($module_name, $files); |
|
304 | + } //foreach |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * parseFile |
|
310 | + * Hanldes parsing the files for given module where Studio or manual |
|
311 | + * changes have been detected. |
|
312 | + * @param $module_name The module to parse |
|
313 | + * @param $files Array of files found to parse |
|
314 | + * |
|
315 | + */ |
|
316 | + function parseFile($module_name, $files) { |
|
317 | + global $beanList, $dictionary; |
|
318 | + foreach($files as $file) { |
|
319 | 319 | if(preg_match('/(EditView|DetailView|SearchForm|QuickCreate)(\.html|\.tpl)$/s', $file, $matches)) { |
320 | 320 | $view = $matches[1]; |
321 | 321 | |
322 | 322 | switch($view) { |
323 | - case 'EditView' : $parser = $this->evparser; break; |
|
324 | - case 'DetailView' : $parser = $this->dvparser; break; |
|
325 | - case 'SearchForm' : $parser = $this->svparser; break; |
|
323 | + case 'EditView' : $parser = $this->evparser; break; |
|
324 | + case 'DetailView' : $parser = $this->dvparser; break; |
|
325 | + case 'SearchForm' : $parser = $this->svparser; break; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | $lowerCaseView = $view == 'SearchForm' ? 'search' : strtolower($view); |
329 | 329 | |
330 | - include('modules/'.$module_name.'/vardefs.php'); |
|
331 | - $bean_name = $beanList[$module_name]; |
|
332 | - $newFile = $this->upgrade_dir.'/modules/'.$module_name.'/metadata/'.$lowerCaseView.'defs.php'; |
|
333 | - $evfp = fopen($newFile,'w'); |
|
334 | - |
|
335 | - $bean_name = $bean_name == 'aCase' ? 'Case' : $bean_name; |
|
336 | - fwrite($evfp, $parser->parse($file, |
|
337 | - $dictionary[$bean_name]['fields'], |
|
338 | - $module_name, |
|
339 | - true, |
|
340 | - $this->path_to_master_copy.'/modules/'.$module_name.'/metadata/'.$lowerCaseView.'defs.php')); |
|
341 | - fclose($evfp); |
|
330 | + include('modules/'.$module_name.'/vardefs.php'); |
|
331 | + $bean_name = $beanList[$module_name]; |
|
332 | + $newFile = $this->upgrade_dir.'/modules/'.$module_name.'/metadata/'.$lowerCaseView.'defs.php'; |
|
333 | + $evfp = fopen($newFile,'w'); |
|
334 | + |
|
335 | + $bean_name = $bean_name == 'aCase' ? 'Case' : $bean_name; |
|
336 | + fwrite($evfp, $parser->parse($file, |
|
337 | + $dictionary[$bean_name]['fields'], |
|
338 | + $module_name, |
|
339 | + true, |
|
340 | + $this->path_to_master_copy.'/modules/'.$module_name.'/metadata/'.$lowerCaseView.'defs.php')); |
|
341 | + fclose($evfp); |
|
342 | + } //if |
|
343 | + } //foreach |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * create_upgrade_directory |
|
349 | + * Creates a directory called upgrade to house all the modules that are studio enabled. |
|
350 | + * Also creates subdirectories for all studio enabled modules. |
|
351 | + * |
|
352 | + */ |
|
353 | + function create_upgrade_directory() { |
|
354 | + |
|
355 | + $dir = $this->upgrade_dir.'/modules'; |
|
356 | + if(!file_exists($this->upgrade_dir)) { |
|
357 | + mkdir($this->upgrade_dir, 0755); |
|
358 | + } |
|
359 | + if(!file_exists($dir)) { |
|
360 | + mkdir($dir, 0755); |
|
361 | + } |
|
362 | + |
|
363 | + foreach($this->upgrade_modules as $module=>$files){ |
|
364 | + if(!file_exists($dir.'/'.$module)) { |
|
365 | + mkdir($dir.'/'.$module, 0755); |
|
366 | + } |
|
367 | + if(!file_exists($dir.'/'.$module.'/metadata')) { |
|
368 | + mkdir($dir.'/'.$module.'/metadata', 0755); |
|
369 | + } |
|
370 | + |
|
371 | + foreach($files as $file) { |
|
372 | + if(file_exists($file) && is_file($file)) { |
|
373 | + copy($file, $this->upgrade_dir.'/'.$file); |
|
342 | 374 | } //if |
343 | - } //foreach |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * create_upgrade_directory |
|
349 | - * Creates a directory called upgrade to house all the modules that are studio enabled. |
|
350 | - * Also creates subdirectories for all studio enabled modules. |
|
351 | - * |
|
352 | - */ |
|
353 | - function create_upgrade_directory() { |
|
354 | - |
|
355 | - $dir = $this->upgrade_dir.'/modules'; |
|
356 | - if(!file_exists($this->upgrade_dir)) { |
|
357 | - mkdir($this->upgrade_dir, 0755); |
|
358 | - } |
|
359 | - if(!file_exists($dir)) { |
|
360 | - mkdir($dir, 0755); |
|
361 | - } |
|
362 | - |
|
363 | - foreach($this->upgrade_modules as $module=>$files){ |
|
364 | - if(!file_exists($dir.'/'.$module)) { |
|
365 | - mkdir($dir.'/'.$module, 0755); |
|
366 | - } |
|
367 | - if(!file_exists($dir.'/'.$module.'/metadata')) { |
|
368 | - mkdir($dir.'/'.$module.'/metadata', 0755); |
|
369 | - } |
|
370 | - |
|
371 | - foreach($files as $file) { |
|
372 | - if(file_exists($file) && is_file($file)) { |
|
373 | - copy($file, $this->upgrade_dir.'/'.$file); |
|
374 | - } //if |
|
375 | - } //foreach |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * verifyMetaData |
|
382 | - * This function does some quick checks to make sure the metadataFile at |
|
383 | - * least has an Array panel |
|
384 | - * |
|
385 | - * @param $metadataFile The path to the metadata file to verify |
|
386 | - * @param $module The module to verify |
|
387 | - * @param $view The view (EditView or DetailView) |
|
388 | - * @return boolean true if verification check is okay; false otherwise |
|
389 | - */ |
|
390 | - function verifyMetaData($metadataFile, $module, $view) { |
|
391 | - if(!file_exists($metadataFile) || !is_file($metadataFile)) { |
|
392 | - return false; |
|
393 | - } |
|
394 | - |
|
395 | - include($metadataFile); |
|
396 | - |
|
397 | - if(isset($viewdefs) && isset($viewdefs[$module][$view]['panels']) && is_array($viewdefs[$module][$view]['panels'])) { |
|
398 | - return true; |
|
399 | - } |
|
375 | + } //foreach |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * verifyMetaData |
|
382 | + * This function does some quick checks to make sure the metadataFile at |
|
383 | + * least has an Array panel |
|
384 | + * |
|
385 | + * @param $metadataFile The path to the metadata file to verify |
|
386 | + * @param $module The module to verify |
|
387 | + * @param $view The view (EditView or DetailView) |
|
388 | + * @return boolean true if verification check is okay; false otherwise |
|
389 | + */ |
|
390 | + function verifyMetaData($metadataFile, $module, $view) { |
|
391 | + if(!file_exists($metadataFile) || !is_file($metadataFile)) { |
|
392 | + return false; |
|
393 | + } |
|
394 | + |
|
395 | + include($metadataFile); |
|
396 | + |
|
397 | + if(isset($viewdefs) && isset($viewdefs[$module][$view]['panels']) && is_array($viewdefs[$module][$view]['panels'])) { |
|
398 | + return true; |
|
399 | + } |
|
400 | 400 | |
401 | 401 | if(isset($searchdefs) && isset($searchdefs[$module]) && is_array($searchdefs[$module])) { |
402 | - return true; |
|
402 | + return true; |
|
403 | 403 | } |
404 | 404 | |
405 | - return false; |
|
406 | - } |
|
405 | + return false; |
|
406 | + } |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | ?> |
410 | 410 | \ No newline at end of file |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | -class UpgradeMetaHelper{ |
|
42 | +class UpgradeMetaHelper { |
|
43 | 43 | |
44 | 44 | var $upgrade_dir; |
45 | 45 | var $debug_mode; |
46 | 46 | var $upgrade_modules; |
47 | 47 | var $customized_modules; |
48 | 48 | var $source_dir; |
49 | - var $dest_dir ; |
|
49 | + var $dest_dir; |
|
50 | 50 | var $evparser; |
51 | 51 | var $dvparser; |
52 | 52 | var $path_to_master_copy; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * @param $debugMode Debug mode, default is false |
59 | 59 | * |
60 | 60 | */ |
61 | - function __construct($dir='upgrade', $masterCopyDirecotry='modules_50', $debugMode = false) { |
|
61 | + function __construct($dir = 'upgrade', $masterCopyDirecotry = 'modules_50', $debugMode = false) { |
|
62 | 62 | $this->upgrade_dir = $dir; |
63 | 63 | $this->debug_mode = $debugMode; |
64 | 64 | $this->upgrade_modules = $this->getModifiedModules(); |
65 | 65 | |
66 | - if(count($this->upgrade_modules) > 0) { |
|
66 | + if (count($this->upgrade_modules) > 0) { |
|
67 | 67 | $_SESSION['Upgraded_Modules'] = $this->upgrade_modules; |
68 | 68 | $this->create_upgrade_directory(); |
69 | 69 | $this->path_to_master_copy = $masterCopyDirecotry; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | $this->customized_modules = $this->getAllCustomizedModulesBeyondStudio(); |
74 | - if(count($this->customized_modules) > 0) { |
|
74 | + if (count($this->customized_modules) > 0) { |
|
75 | 75 | $_SESSION['Customized_Modules'] = $this->customized_modules; |
76 | 76 | } |
77 | 77 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * @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 |
81 | 81 | */ |
82 | - function UpgradeMetaHelper($dir='upgrade', $masterCopyDirecotry='modules_50', $debugMode = false){ |
|
82 | + function UpgradeMetaHelper($dir = 'upgrade', $masterCopyDirecotry = 'modules_50', $debugMode = false) { |
|
83 | 83 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
84 | - if(isset($GLOBALS['log'])) { |
|
84 | + if (isset($GLOBALS['log'])) { |
|
85 | 85 | $GLOBALS['log']->deprecated($deprecatedMessage); |
86 | 86 | } |
87 | 87 | else { |
@@ -100,34 +100,34 @@ discard block |
||
100 | 100 | function getModifiedModules() { |
101 | 101 | |
102 | 102 | $md5_string = array(); |
103 | - if(file_exists(clean_path(getcwd().'/files.md5'))){ |
|
103 | + if (file_exists(clean_path(getcwd().'/files.md5'))) { |
|
104 | 104 | require(clean_path(getcwd().'/files.md5')); |
105 | 105 | } |
106 | 106 | |
107 | 107 | $return_array = array(); |
108 | 108 | $modules = $this->loadStudioModules(); |
109 | - foreach($modules as $mod) { |
|
109 | + foreach ($modules as $mod) { |
|
110 | 110 | |
111 | 111 | $editView = "modules/$mod/EditView.html"; |
112 | 112 | $detailView = "modules/$mod/DetailView.html"; |
113 | 113 | $searchForm = "modules/$mod/SearchForm.html"; |
114 | - if(file_exists($editView) && isset($md5_string['./' . $editView])) { |
|
114 | + if (file_exists($editView) && isset($md5_string['./'.$editView])) { |
|
115 | 115 | $fileContents = file_get_contents($editView); |
116 | - if(md5($fileContents) != $md5_string['./' . $editView]) { |
|
116 | + if (md5($fileContents) != $md5_string['./'.$editView]) { |
|
117 | 117 | $return_array[$mod][] = $editView; |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | - if(file_exists($detailView) && isset($md5_string['./' . $detailView])) { |
|
121 | + if (file_exists($detailView) && isset($md5_string['./'.$detailView])) { |
|
122 | 122 | $fileContents = file_get_contents($detailView); |
123 | - if(md5($fileContents) != $md5_string['./' . $detailView]) { |
|
123 | + if (md5($fileContents) != $md5_string['./'.$detailView]) { |
|
124 | 124 | $return_array[$mod][] = $detailView; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - if(file_exists($searchForm) && isset($md5_string['./' . $searchForm])) { |
|
128 | + if (file_exists($searchForm) && isset($md5_string['./'.$searchForm])) { |
|
129 | 129 | $fileContents = file_get_contents($searchForm); |
130 | - if(md5($fileContents) != $md5_string['./' . $searchForm]) { |
|
130 | + if (md5($fileContents) != $md5_string['./'.$searchForm]) { |
|
131 | 131 | $return_array[$mod][] = $searchForm; |
132 | 132 | } |
133 | 133 | } |
@@ -137,28 +137,28 @@ discard block |
||
137 | 137 | return $return_array; |
138 | 138 | } |
139 | 139 | |
140 | -function saveMatchingFilesQueries($currStep,$value){ |
|
140 | +function saveMatchingFilesQueries($currStep, $value) { |
|
141 | 141 | $upgrade_progress_dir = sugar_cached('upgrades/temp'); |
142 | - if(!is_dir($upgrade_progress_dir)){ |
|
142 | + if (!is_dir($upgrade_progress_dir)) { |
|
143 | 143 | mkdir($upgrade_progress_dir); |
144 | 144 | } |
145 | 145 | $file_queries_file = $upgrade_progress_dir.'/files_queries.php'; |
146 | - if(file_exists($file_queries_file)){ |
|
146 | + if (file_exists($file_queries_file)) { |
|
147 | 147 | include($file_queries_file); |
148 | 148 | } |
149 | - else{ |
|
150 | - if(function_exists('sugar_fopen')){ |
|
149 | + else { |
|
150 | + if (function_exists('sugar_fopen')) { |
|
151 | 151 | sugar_fopen($file_queries_file, 'w+'); |
152 | 152 | } |
153 | - else{ |
|
153 | + else { |
|
154 | 154 | fopen($file_queries_file, 'w+'); |
155 | 155 | } |
156 | 156 | } |
157 | - if(!isset($files_queries) || $files_queries == NULL){ |
|
157 | + if (!isset($files_queries) || $files_queries == NULL) { |
|
158 | 158 | $files_queries = array(); |
159 | 159 | } |
160 | - $files_queries[$currStep]=$value; |
|
161 | - if(is_writable($file_queries_file) && write_array_to_file( "file_queries", $file_queries, |
|
160 | + $files_queries[$currStep] = $value; |
|
161 | + if (is_writable($file_queries_file) && write_array_to_file("file_queries", $file_queries, |
|
162 | 162 | $file_queries_file)) { |
163 | 163 | //writing to the file |
164 | 164 | } |
@@ -168,30 +168,30 @@ discard block |
||
168 | 168 | |
169 | 169 | require_once('modules/UpgradeWizard/uw_utils.php'); |
170 | 170 | $md5_string = array(); |
171 | - if(file_exists(clean_path(getcwd().'/files.md5'))){ |
|
171 | + if (file_exists(clean_path(getcwd().'/files.md5'))) { |
|
172 | 172 | require(clean_path(getcwd().'/files.md5')); |
173 | 173 | } |
174 | 174 | $return_array = array(); |
175 | 175 | $modules = $this->loadStudioModules(); |
176 | 176 | $modulesAll = getAllModules(); //keep all modules as well |
177 | - $allOtherModules = array_diff($modulesAll,$modules); |
|
178 | - foreach($modules as $mod) { |
|
179 | - if(!is_dir('modules/'.$mod)) continue; |
|
177 | + $allOtherModules = array_diff($modulesAll, $modules); |
|
178 | + foreach ($modules as $mod) { |
|
179 | + if (!is_dir('modules/'.$mod)) continue; |
|
180 | 180 | $editView = "modules/$mod/EditView.html"; |
181 | - $detailView ="modules/$mod/DetailView.html"; |
|
182 | - $exclude_files[]=$editView; |
|
183 | - $exclude_files[]=$detailView; |
|
181 | + $detailView = "modules/$mod/DetailView.html"; |
|
182 | + $exclude_files[] = $editView; |
|
183 | + $exclude_files[] = $detailView; |
|
184 | 184 | $allModFiles = array(); |
185 | - $allModFiles = findAllFiles('modules/'.$mod,$allModFiles); |
|
186 | - foreach($allModFiles as $file){ |
|
185 | + $allModFiles = findAllFiles('modules/'.$mod, $allModFiles); |
|
186 | + foreach ($allModFiles as $file) { |
|
187 | 187 | //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
188 | - if(file_exists($file) && !in_array($file,$exclude_files)){ |
|
189 | - if(isset($md5_string['./'.$file])) { |
|
188 | + if (file_exists($file) && !in_array($file, $exclude_files)) { |
|
189 | + if (isset($md5_string['./'.$file])) { |
|
190 | 190 | $fileContents = file_get_contents($file); |
191 | - if(md5($fileContents) != $md5_string['./'.$file]) { |
|
191 | + if (md5($fileContents) != $md5_string['./'.$file]) { |
|
192 | 192 | $return_array[$mod][] = $file; |
193 | 193 | } |
194 | - else{ |
|
194 | + else { |
|
195 | 195 | //keep in the array to be deleted later |
196 | 196 | $_SESSION['removeMd5MatchingFiles'][] = $file; |
197 | 197 | } |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | } //foreach |
202 | 202 | //also check out other non-studio modules by taking the difference between |
203 | 203 | //allMOdules and |
204 | - foreach($allOtherModules as $mod) { |
|
205 | - if(!is_dir('modules/'.$mod)) continue; |
|
204 | + foreach ($allOtherModules as $mod) { |
|
205 | + if (!is_dir('modules/'.$mod)) continue; |
|
206 | 206 | $allModFiles = array(); |
207 | - $allModFiles = findAllFiles('modules/'.$mod,$allModFiles); |
|
208 | - foreach($allModFiles as $file){ |
|
207 | + $allModFiles = findAllFiles('modules/'.$mod, $allModFiles); |
|
208 | + foreach ($allModFiles as $file) { |
|
209 | 209 | //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); |
210 | - if(file_exists($file)){ |
|
211 | - if(isset($md5_string['./'.$file])) { |
|
210 | + if (file_exists($file)) { |
|
211 | + if (isset($md5_string['./'.$file])) { |
|
212 | 212 | $fileContents = file_get_contents($file); |
213 | - if(md5($fileContents) == $md5_string['./'.$file]) { |
|
213 | + if (md5($fileContents) == $md5_string['./'.$file]) { |
|
214 | 214 | $_SESSION['removeMd5MatchingFiles'][] = $file; |
215 | 215 | } |
216 | 216 | } |
@@ -235,16 +235,16 @@ discard block |
||
235 | 235 | |
236 | 236 | $return_array = array(); |
237 | 237 | $modules = getAllModules(); |
238 | - foreach($modules as $mod) { |
|
238 | + foreach ($modules as $mod) { |
|
239 | 239 | //find all files in each module if the files have been modified |
240 | 240 | //as compared to the base version then add the module to the |
241 | 241 | //customized modules array |
242 | 242 | $modFiles = findAllFiles(clean_path(getcwd())."/modules/$mod", array()); |
243 | - foreach($modFiles as $file){ |
|
243 | + foreach ($modFiles as $file) { |
|
244 | 244 | $fileContents = file_get_contents($file); |
245 | - $file = str_replace(clean_path(getcwd()),'',$file); |
|
246 | - if($md5_string['./' . $file]){ |
|
247 | - if(md5($fileContents) != $md5_string['./' . $file]) { |
|
245 | + $file = str_replace(clean_path(getcwd()), '', $file); |
|
246 | + if ($md5_string['./'.$file]) { |
|
247 | + if (md5($fileContents) != $md5_string['./'.$file]) { |
|
248 | 248 | //A file has been customized in the module. Put the module into the |
249 | 249 | // customized modules array. |
250 | 250 | echo 'Changed File'.$file; |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | break; |
253 | 253 | } |
254 | 254 | } |
255 | - else{ |
|
255 | + else { |
|
256 | 256 | // This is a new file in user's version and indicates that module has been |
257 | 257 | //customized. Put the module in the customized array. |
258 | 258 | echo 'New File'.$file; |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | function loadStudioModules() { |
275 | 275 | $modules = array(); |
276 | 276 | $d = dir('modules'); |
277 | - while($e = $d->read()){ |
|
278 | - if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue; |
|
279 | - if(file_exists('modules/' . $e . '/metadata/studio.php')){ |
|
277 | + while ($e = $d->read()) { |
|
278 | + if (substr($e, 0, 1) == '.' || !is_dir('modules/'.$e))continue; |
|
279 | + if (file_exists('modules/'.$e.'/metadata/studio.php')) { |
|
280 | 280 | $modules[] = $e; |
281 | 281 | } |
282 | 282 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $this->dvparser = new DetailViewMetaParser(); |
300 | 300 | $this->svparser = new SearchFormMetaParser(); |
301 | 301 | |
302 | - foreach($this->upgrade_modules as $module_name=>$files) { |
|
302 | + foreach ($this->upgrade_modules as $module_name=>$files) { |
|
303 | 303 | $this->parseFile($module_name, $files); |
304 | 304 | } //foreach |
305 | 305 | } |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | */ |
316 | 316 | function parseFile($module_name, $files) { |
317 | 317 | global $beanList, $dictionary; |
318 | - foreach($files as $file) { |
|
319 | - if(preg_match('/(EditView|DetailView|SearchForm|QuickCreate)(\.html|\.tpl)$/s', $file, $matches)) { |
|
318 | + foreach ($files as $file) { |
|
319 | + if (preg_match('/(EditView|DetailView|SearchForm|QuickCreate)(\.html|\.tpl)$/s', $file, $matches)) { |
|
320 | 320 | $view = $matches[1]; |
321 | 321 | |
322 | - switch($view) { |
|
322 | + switch ($view) { |
|
323 | 323 | case 'EditView' : $parser = $this->evparser; break; |
324 | 324 | case 'DetailView' : $parser = $this->dvparser; break; |
325 | 325 | case 'SearchForm' : $parser = $this->svparser; break; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | include('modules/'.$module_name.'/vardefs.php'); |
331 | 331 | $bean_name = $beanList[$module_name]; |
332 | 332 | $newFile = $this->upgrade_dir.'/modules/'.$module_name.'/metadata/'.$lowerCaseView.'defs.php'; |
333 | - $evfp = fopen($newFile,'w'); |
|
333 | + $evfp = fopen($newFile, 'w'); |
|
334 | 334 | |
335 | 335 | $bean_name = $bean_name == 'aCase' ? 'Case' : $bean_name; |
336 | 336 | fwrite($evfp, $parser->parse($file, |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | function create_upgrade_directory() { |
354 | 354 | |
355 | 355 | $dir = $this->upgrade_dir.'/modules'; |
356 | - if(!file_exists($this->upgrade_dir)) { |
|
356 | + if (!file_exists($this->upgrade_dir)) { |
|
357 | 357 | mkdir($this->upgrade_dir, 0755); |
358 | 358 | } |
359 | - if(!file_exists($dir)) { |
|
359 | + if (!file_exists($dir)) { |
|
360 | 360 | mkdir($dir, 0755); |
361 | 361 | } |
362 | 362 | |
363 | - foreach($this->upgrade_modules as $module=>$files){ |
|
364 | - if(!file_exists($dir.'/'.$module)) { |
|
363 | + foreach ($this->upgrade_modules as $module=>$files) { |
|
364 | + if (!file_exists($dir.'/'.$module)) { |
|
365 | 365 | mkdir($dir.'/'.$module, 0755); |
366 | 366 | } |
367 | - if(!file_exists($dir.'/'.$module.'/metadata')) { |
|
367 | + if (!file_exists($dir.'/'.$module.'/metadata')) { |
|
368 | 368 | mkdir($dir.'/'.$module.'/metadata', 0755); |
369 | 369 | } |
370 | 370 | |
371 | - foreach($files as $file) { |
|
372 | - if(file_exists($file) && is_file($file)) { |
|
371 | + foreach ($files as $file) { |
|
372 | + if (file_exists($file) && is_file($file)) { |
|
373 | 373 | copy($file, $this->upgrade_dir.'/'.$file); |
374 | 374 | } //if |
375 | 375 | } //foreach |
@@ -388,17 +388,17 @@ discard block |
||
388 | 388 | * @return boolean true if verification check is okay; false otherwise |
389 | 389 | */ |
390 | 390 | function verifyMetaData($metadataFile, $module, $view) { |
391 | - if(!file_exists($metadataFile) || !is_file($metadataFile)) { |
|
391 | + if (!file_exists($metadataFile) || !is_file($metadataFile)) { |
|
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
395 | 395 | include($metadataFile); |
396 | 396 | |
397 | - if(isset($viewdefs) && isset($viewdefs[$module][$view]['panels']) && is_array($viewdefs[$module][$view]['panels'])) { |
|
397 | + if (isset($viewdefs) && isset($viewdefs[$module][$view]['panels']) && is_array($viewdefs[$module][$view]['panels'])) { |
|
398 | 398 | return true; |
399 | 399 | } |
400 | 400 | |
401 | - if(isset($searchdefs) && isset($searchdefs[$module]) && is_array($searchdefs[$module])) { |
|
401 | + if (isset($searchdefs) && isset($searchdefs[$module]) && is_array($searchdefs[$module])) { |
|
402 | 402 | return true; |
403 | 403 | } |
404 | 404 |
@@ -83,8 +83,7 @@ discard block |
||
83 | 83 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
84 | 84 | if(isset($GLOBALS['log'])) { |
85 | 85 | $GLOBALS['log']->deprecated($deprecatedMessage); |
86 | - } |
|
87 | - else { |
|
86 | + } else { |
|
88 | 87 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
89 | 88 | } |
90 | 89 | self::__construct($dir, $masterCopyDirecotry, $debugMode); |
@@ -145,12 +144,10 @@ discard block |
||
145 | 144 | $file_queries_file = $upgrade_progress_dir.'/files_queries.php'; |
146 | 145 | if(file_exists($file_queries_file)){ |
147 | 146 | include($file_queries_file); |
148 | - } |
|
149 | - else{ |
|
147 | + } else{ |
|
150 | 148 | if(function_exists('sugar_fopen')){ |
151 | 149 | sugar_fopen($file_queries_file, 'w+'); |
152 | - } |
|
153 | - else{ |
|
150 | + } else{ |
|
154 | 151 | fopen($file_queries_file, 'w+'); |
155 | 152 | } |
156 | 153 | } |
@@ -176,7 +173,9 @@ discard block |
||
176 | 173 | $modulesAll = getAllModules(); //keep all modules as well |
177 | 174 | $allOtherModules = array_diff($modulesAll,$modules); |
178 | 175 | foreach($modules as $mod) { |
179 | - if(!is_dir('modules/'.$mod)) continue; |
|
176 | + if(!is_dir('modules/'.$mod)) { |
|
177 | + continue; |
|
178 | + } |
|
180 | 179 | $editView = "modules/$mod/EditView.html"; |
181 | 180 | $detailView ="modules/$mod/DetailView.html"; |
182 | 181 | $exclude_files[]=$editView; |
@@ -190,8 +189,7 @@ discard block |
||
190 | 189 | $fileContents = file_get_contents($file); |
191 | 190 | if(md5($fileContents) != $md5_string['./'.$file]) { |
192 | 191 | $return_array[$mod][] = $file; |
193 | - } |
|
194 | - else{ |
|
192 | + } else{ |
|
195 | 193 | //keep in the array to be deleted later |
196 | 194 | $_SESSION['removeMd5MatchingFiles'][] = $file; |
197 | 195 | } |
@@ -202,7 +200,9 @@ discard block |
||
202 | 200 | //also check out other non-studio modules by taking the difference between |
203 | 201 | //allMOdules and |
204 | 202 | foreach($allOtherModules as $mod) { |
205 | - if(!is_dir('modules/'.$mod)) continue; |
|
203 | + if(!is_dir('modules/'.$mod)) { |
|
204 | + continue; |
|
205 | + } |
|
206 | 206 | $allModFiles = array(); |
207 | 207 | $allModFiles = findAllFiles('modules/'.$mod,$allModFiles); |
208 | 208 | foreach($allModFiles as $file){ |
@@ -251,8 +251,7 @@ discard block |
||
251 | 251 | $return_array[$mod]; |
252 | 252 | break; |
253 | 253 | } |
254 | - } |
|
255 | - else{ |
|
254 | + } else{ |
|
256 | 255 | // This is a new file in user's version and indicates that module has been |
257 | 256 | //customized. Put the module in the customized array. |
258 | 257 | echo 'New File'.$file; |
@@ -275,7 +274,9 @@ discard block |
||
275 | 274 | $modules = array(); |
276 | 275 | $d = dir('modules'); |
277 | 276 | while($e = $d->read()){ |
278 | - if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue; |
|
277 | + if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e)) { |
|
278 | + continue; |
|
279 | + } |
|
279 | 280 | if(file_exists('modules/' . $e . '/metadata/studio.php')){ |
280 | 281 | $modules[] = $e; |
281 | 282 | } |
@@ -13,9 +13,9 @@ |
||
13 | 13 | /** |
14 | 14 | * @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 |
15 | 15 | */ |
16 | - function OpportunitiesJjwg_MapsLogicHook(){ |
|
16 | + function OpportunitiesJjwg_MapsLogicHook() { |
|
17 | 17 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
18 | - if(isset($GLOBALS['log'])) { |
|
18 | + if (isset($GLOBALS['log'])) { |
|
19 | 19 | $GLOBALS['log']->deprecated($deprecatedMessage); |
20 | 20 | } |
21 | 21 | else { |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('sugarEntry') || !sugarEntry) |
|
3 | +if (!defined('sugarEntry') || !sugarEntry) { |
|
4 | 4 | die('Not A Valid Entry Point'); |
5 | +} |
|
5 | 6 | |
6 | 7 | class OpportunitiesJjwg_MapsLogicHook { |
7 | 8 | |
@@ -17,8 +18,7 @@ discard block |
||
17 | 18 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
18 | 19 | if(isset($GLOBALS['log'])) { |
19 | 20 | $GLOBALS['log']->deprecated($deprecatedMessage); |
20 | - } |
|
21 | - else { |
|
21 | + } else { |
|
22 | 22 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
23 | 23 | } |
24 | 24 | self::__construct(); |