@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | require_once('modules/AOS_Products/AOS_Products_sugar.php'); |
| 31 | 31 | class AOS_Products extends AOS_Products_sugar { |
| 32 | 32 | |
| 33 | - function __construct(){ |
|
| 33 | + function __construct() { |
|
| 34 | 34 | parent::__construct(); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
| 39 | 39 | */ |
| 40 | - function AOS_Products(){ |
|
| 40 | + function AOS_Products() { |
|
| 41 | 41 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 42 | - if(isset($GLOBALS['log'])) { |
|
| 42 | + if (isset($GLOBALS['log'])) { |
|
| 43 | 43 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 44 | 44 | } |
| 45 | 45 | else { |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - function save($check_notify=false){ |
|
| 53 | - global $sugar_config,$mod_strings; |
|
| 52 | + function save($check_notify = false) { |
|
| 53 | + global $sugar_config, $mod_strings; |
|
| 54 | 54 | |
| 55 | - if (isset($_POST['deleteAttachment']) && $_POST['deleteAttachment']=='1') { |
|
| 55 | + if (isset($_POST['deleteAttachment']) && $_POST['deleteAttachment'] == '1') { |
|
| 56 | 56 | $this->product_image = ''; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | $GLOBALS['log']->debug('UPLOADING PRODUCT IMAGE'); |
| 61 | 61 | $upload_file = new UploadFile('uploadfile'); |
| 62 | 62 | |
| 63 | - if (isset($_FILES['uploadimage']['tmp_name'])&&$_FILES['uploadimage']['tmp_name']!=""){ |
|
| 63 | + if (isset($_FILES['uploadimage']['tmp_name']) && $_FILES['uploadimage']['tmp_name'] != "") { |
|
| 64 | 64 | |
| 65 | - if($_FILES['uploadimage']['size'] > $sugar_config['upload_maxsize']) { |
|
| 65 | + if ($_FILES['uploadimage']['size'] > $sugar_config['upload_maxsize']) { |
|
| 66 | 66 | die($mod_strings['LBL_IMAGE_UPLOAD_FAIL'].$sugar_config['upload_maxsize']); |
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | else { |
| 70 | - $this->product_image=$sugar_config['site_url'].'/'.$sugar_config['upload_dir'].$_FILES['uploadimage']['name']; |
|
| 70 | + $this->product_image = $sugar_config['site_url'].'/'.$sugar_config['upload_dir'].$_FILES['uploadimage']['name']; |
|
| 71 | 71 | move_uploaded_file($_FILES['uploadimage']['tmp_name'], $sugar_config['upload_dir'].$_FILES['uploadimage']['name']); |
| 72 | 72 | |
| 73 | 73 | } |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 42 | 42 | if(isset($GLOBALS['log'])) { |
| 43 | 43 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 44 | - } |
|
| 45 | - else { |
|
| 44 | + } else { |
|
| 46 | 45 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 47 | 46 | } |
| 48 | 47 | self::__construct(); |
@@ -65,8 +64,7 @@ discard block |
||
| 65 | 64 | if($_FILES['uploadimage']['size'] > $sugar_config['upload_maxsize']) { |
| 66 | 65 | die($mod_strings['LBL_IMAGE_UPLOAD_FAIL'].$sugar_config['upload_maxsize']); |
| 67 | 66 | |
| 68 | - } |
|
| 69 | - else { |
|
| 67 | + } else { |
|
| 70 | 68 | $this->product_image=$sugar_config['site_url'].'/'.$sugar_config['upload_dir'].$_FILES['uploadimage']['name']; |
| 71 | 69 | move_uploaded_file($_FILES['uploadimage']['tmp_name'], $sugar_config['upload_dir'].$_FILES['uploadimage']['name']); |
| 72 | 70 | |
@@ -54,69 +54,69 @@ discard block |
||
| 54 | 54 | var $monitor_id; |
| 55 | 55 | var $table_name; |
| 56 | 56 | protected $enabled = true; |
| 57 | - protected $dirty = false; |
|
| 57 | + protected $dirty = false; |
|
| 58 | 58 | |
| 59 | - var $date_start; |
|
| 60 | - var $date_end; |
|
| 61 | - var $active; |
|
| 62 | - var $round_trips; |
|
| 63 | - var $seconds; |
|
| 64 | - var $session_id; |
|
| 59 | + var $date_start; |
|
| 60 | + var $date_end; |
|
| 61 | + var $active; |
|
| 62 | + var $round_trips; |
|
| 63 | + var $seconds; |
|
| 64 | + var $session_id; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Monitor constructor |
| 68 | 68 | */ |
| 69 | 69 | public function __construct($name='', $monitorId='', $metadata='', $store='') { |
| 70 | 70 | |
| 71 | - if(empty($metadata) || !file_exists($metadata)) { |
|
| 72 | - $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)"); |
|
| 73 | - throw new Exception($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)"); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $this->name = $name; |
|
| 77 | - $this->metricsFile = $metadata; |
|
| 78 | - |
|
| 79 | - require($this->metricsFile); |
|
| 80 | - $fields = $dictionary[$this->name]['fields']; |
|
| 81 | - $this->table_name = !empty($dictionary[$this->name]['table']) ? $dictionary[$this->name]['table'] : $this->name; |
|
| 82 | - $this->metrics = array(); |
|
| 83 | - foreach($fields as $field) { |
|
| 84 | - |
|
| 85 | - //We need to skip auto_increment fields; they are not real metrics |
|
| 86 | - //since they are generated by the database. |
|
| 87 | - if(isset($field['auto_increment'])) { |
|
| 88 | - continue; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $type = isset($field['dbType']) ? $field['dbType'] : $field['type']; |
|
| 92 | - $name = $field['name']; |
|
| 93 | - $this->metrics[$name] = new Metric($type, $name); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $this->monitor_id = $monitorId; |
|
| 97 | - $this->stores = $store; |
|
| 98 | - |
|
| 99 | - if(isset($this->metrics['session_id'])) { |
|
| 100 | - //set the value of the session id for 2 reasons: |
|
| 101 | - //1) it is the same value no matter where it is set |
|
| 102 | - //2) ensure it follows some filter rules. |
|
| 103 | - $this->setValue('session_id', $this->getSessionId()); |
|
| 104 | - } |
|
| 71 | + if(empty($metadata) || !file_exists($metadata)) { |
|
| 72 | + $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)"); |
|
| 73 | + throw new Exception($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)"); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $this->name = $name; |
|
| 77 | + $this->metricsFile = $metadata; |
|
| 78 | + |
|
| 79 | + require($this->metricsFile); |
|
| 80 | + $fields = $dictionary[$this->name]['fields']; |
|
| 81 | + $this->table_name = !empty($dictionary[$this->name]['table']) ? $dictionary[$this->name]['table'] : $this->name; |
|
| 82 | + $this->metrics = array(); |
|
| 83 | + foreach($fields as $field) { |
|
| 84 | + |
|
| 85 | + //We need to skip auto_increment fields; they are not real metrics |
|
| 86 | + //since they are generated by the database. |
|
| 87 | + if(isset($field['auto_increment'])) { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $type = isset($field['dbType']) ? $field['dbType'] : $field['type']; |
|
| 92 | + $name = $field['name']; |
|
| 93 | + $this->metrics[$name] = new Metric($type, $name); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $this->monitor_id = $monitorId; |
|
| 97 | + $this->stores = $store; |
|
| 98 | + |
|
| 99 | + if(isset($this->metrics['session_id'])) { |
|
| 100 | + //set the value of the session id for 2 reasons: |
|
| 101 | + //1) it is the same value no matter where it is set |
|
| 102 | + //2) ensure it follows some filter rules. |
|
| 103 | + $this->setValue('session_id', $this->getSessionId()); |
|
| 104 | + } |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @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 |
|
| 109 | - */ |
|
| 110 | - public function Monitor($name='', $monitorId='', $metadata='', $store=''){ |
|
| 111 | - $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 112 | - if(isset($GLOBALS['log'])) { |
|
| 113 | - $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 114 | - } |
|
| 115 | - else { |
|
| 116 | - trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 117 | - } |
|
| 118 | - self::__construct($name, $monitorId, $metadata, $store); |
|
| 119 | - } |
|
| 107 | + /** |
|
| 108 | + * @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 |
|
| 109 | + */ |
|
| 110 | + public function Monitor($name='', $monitorId='', $metadata='', $store=''){ |
|
| 111 | + $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 112 | + if(isset($GLOBALS['log'])) { |
|
| 113 | + $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 114 | + } |
|
| 115 | + else { |
|
| 116 | + trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 117 | + } |
|
| 118 | + self::__construct($name, $monitorId, $metadata, $store); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | 122 | * setValue |
@@ -127,16 +127,16 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function setValue($name, $value) { |
| 129 | 129 | if(!isset($this->metrics[$name])) { |
| 130 | - $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)"); |
|
| 131 | - throw new Exception($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)"); |
|
| 130 | + $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)"); |
|
| 131 | + throw new Exception($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)"); |
|
| 132 | 132 | } else if($this->metrics[$name]->isMutable()) { |
| 133 | - $this->$name = is_object($value) ? get_class($value) : $value; |
|
| 134 | - $this->dirty = true; |
|
| 133 | + $this->$name = is_object($value) ? get_class($value) : $value; |
|
| 134 | + $this->dirty = true; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public function getValue($name){ |
| 139 | - return $this->$name; |
|
| 139 | + return $this->$name; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | * @return Array of metric instances defined for monitor instance |
| 155 | 155 | */ |
| 156 | 156 | function getMetrics() { |
| 157 | - return $this->metrics; |
|
| 157 | + return $this->metrics; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * isDirty |
|
| 162 | - * Returns if the monitor has data that needs to be saved |
|
| 163 | - * @return $dirty boolean |
|
| 164 | - */ |
|
| 165 | - function isDirty(){ |
|
| 166 | - return $this->dirty; |
|
| 167 | - } |
|
| 160 | + /** |
|
| 161 | + * isDirty |
|
| 162 | + * Returns if the monitor has data that needs to be saved |
|
| 163 | + * @return $dirty boolean |
|
| 164 | + */ |
|
| 165 | + function isDirty(){ |
|
| 166 | + return $this->dirty; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * save |
@@ -173,89 +173,89 @@ discard block |
||
| 173 | 173 | * @param $flush boolean parameter indicating whether or not to flush the instance data to store or possibly cache |
| 174 | 174 | */ |
| 175 | 175 | public function save($flush=true) { |
| 176 | - //If the monitor is not enabled, do not save |
|
| 177 | - if(!$this->isEnabled()&&$this->name!='tracker_sessions')return false; |
|
| 178 | - |
|
| 179 | - //if the monitor does not have values set no need to do the work saving. |
|
| 180 | - if(!$this->dirty)return false; |
|
| 181 | - |
|
| 182 | - if(empty($GLOBALS['tracker_' . $this->table_name])) { |
|
| 183 | - foreach($this->stores as $s) { |
|
| 184 | - $store = $this->getStore($s); |
|
| 185 | - $store->flush($this); |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - $this->clear(); |
|
| 176 | + //If the monitor is not enabled, do not save |
|
| 177 | + if(!$this->isEnabled()&&$this->name!='tracker_sessions')return false; |
|
| 178 | + |
|
| 179 | + //if the monitor does not have values set no need to do the work saving. |
|
| 180 | + if(!$this->dirty)return false; |
|
| 181 | + |
|
| 182 | + if(empty($GLOBALS['tracker_' . $this->table_name])) { |
|
| 183 | + foreach($this->stores as $s) { |
|
| 184 | + $store = $this->getStore($s); |
|
| 185 | + $store->flush($this); |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + $this->clear(); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * clear |
|
| 193 | - * This function clears the metrics data in the monitor instance |
|
| 194 | - */ |
|
| 195 | - public function clear() { |
|
| 196 | - $metrics = $this->getMetrics(); |
|
| 197 | - foreach($metrics as $name=>$metric) { |
|
| 198 | - if($metric->isMutable()) { |
|
| 199 | - $this->$name = ''; |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - $this->dirty = false; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * getStore |
|
| 207 | - * This method checks if the Store implementation has already been instantiated and |
|
| 208 | - * will return the one stored; otherwise it will create the Store implementation and |
|
| 209 | - * save it to the Array of Stores. |
|
| 210 | - * @param $store The name of the store as defined in the 'modules/Trackers/config.php' settings |
|
| 211 | - * @return An instance of a Store implementation |
|
| 212 | - * @throws Exception Thrown if $store class cannot be loaded |
|
| 213 | - */ |
|
| 214 | - protected function getStore($store) { |
|
| 215 | - |
|
| 216 | - if(isset($this->cachedStores[$store])) { |
|
| 217 | - return $this->cachedStores[$store]; |
|
| 218 | - } |
|
| 191 | + /** |
|
| 192 | + * clear |
|
| 193 | + * This function clears the metrics data in the monitor instance |
|
| 194 | + */ |
|
| 195 | + public function clear() { |
|
| 196 | + $metrics = $this->getMetrics(); |
|
| 197 | + foreach($metrics as $name=>$metric) { |
|
| 198 | + if($metric->isMutable()) { |
|
| 199 | + $this->$name = ''; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + $this->dirty = false; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * getStore |
|
| 207 | + * This method checks if the Store implementation has already been instantiated and |
|
| 208 | + * will return the one stored; otherwise it will create the Store implementation and |
|
| 209 | + * save it to the Array of Stores. |
|
| 210 | + * @param $store The name of the store as defined in the 'modules/Trackers/config.php' settings |
|
| 211 | + * @return An instance of a Store implementation |
|
| 212 | + * @throws Exception Thrown if $store class cannot be loaded |
|
| 213 | + */ |
|
| 214 | + protected function getStore($store) { |
|
| 215 | + |
|
| 216 | + if(isset($this->cachedStores[$store])) { |
|
| 217 | + return $this->cachedStores[$store]; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | if(!file_exists("modules/Trackers/store/$store.php")) { |
| 221 | - $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)"); |
|
| 222 | - throw new Exception($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)"); |
|
| 221 | + $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)"); |
|
| 222 | + throw new Exception($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)"); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + require_once("modules/Trackers/store/$store.php"); |
|
| 226 | + $s = new $store(); |
|
| 227 | + $this->cachedStores[$store] = $s; |
|
| 228 | + return $s; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + public function getSessionId(){ |
|
| 232 | + $sessionid = session_id(); |
|
| 233 | + if(!empty($sessionid) && strlen($sessionid) > MAX_SESSION_LENGTH) { |
|
| 234 | + $sessionid = md5($sessionid); |
|
| 235 | + } |
|
| 236 | + return $sessionid; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Returns the monitor's metrics/values as an Array |
|
| 241 | + * @return An Array of data for the monitor's corresponding metrics |
|
| 242 | + */ |
|
| 243 | + public function toArray() { |
|
| 244 | + $to_arr = array(); |
|
| 245 | + $metrics = $this->getMetrics(); |
|
| 246 | + foreach($metrics as $name=>$metric) { |
|
| 247 | + $to_arr[$name] = isset($this->$name) ? $this->$name : null; |
|
| 248 | + } |
|
| 249 | + return $to_arr; |
|
| 223 | 250 | } |
| 224 | 251 | |
| 225 | - require_once("modules/Trackers/store/$store.php"); |
|
| 226 | - $s = new $store(); |
|
| 227 | - $this->cachedStores[$store] = $s; |
|
| 228 | - return $s; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - public function getSessionId(){ |
|
| 232 | - $sessionid = session_id(); |
|
| 233 | - if(!empty($sessionid) && strlen($sessionid) > MAX_SESSION_LENGTH) { |
|
| 234 | - $sessionid = md5($sessionid); |
|
| 235 | - } |
|
| 236 | - return $sessionid; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Returns the monitor's metrics/values as an Array |
|
| 241 | - * @return An Array of data for the monitor's corresponding metrics |
|
| 242 | - */ |
|
| 243 | - public function toArray() { |
|
| 244 | - $to_arr = array(); |
|
| 245 | - $metrics = $this->getMetrics(); |
|
| 246 | - foreach($metrics as $name=>$metric) { |
|
| 247 | - $to_arr[$name] = isset($this->$name) ? $this->$name : null; |
|
| 248 | - } |
|
| 249 | - return $to_arr; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - public function setEnabled($enable=true) { |
|
| 253 | - $this->enabled = $enable; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - public function isEnabled() { |
|
| 257 | - return $this->enabled; |
|
| 258 | - } |
|
| 252 | + public function setEnabled($enable=true) { |
|
| 253 | + $this->enabled = $enable; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + public function isEnabled() { |
|
| 257 | + return $this->enabled; |
|
| 258 | + } |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | ?> |
@@ -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. |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * Monitor constructor |
| 68 | 68 | */ |
| 69 | - public function __construct($name='', $monitorId='', $metadata='', $store='') { |
|
| 69 | + public function __construct($name = '', $monitorId = '', $metadata = '', $store = '') { |
|
| 70 | 70 | |
| 71 | - if(empty($metadata) || !file_exists($metadata)) { |
|
| 72 | - $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)"); |
|
| 73 | - throw new Exception($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)"); |
|
| 71 | + if (empty($metadata) || !file_exists($metadata)) { |
|
| 72 | + $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING']."($metadata)"); |
|
| 73 | + throw new Exception($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING']."($metadata)"); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $this->name = $name; |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | $fields = $dictionary[$this->name]['fields']; |
| 81 | 81 | $this->table_name = !empty($dictionary[$this->name]['table']) ? $dictionary[$this->name]['table'] : $this->name; |
| 82 | 82 | $this->metrics = array(); |
| 83 | - foreach($fields as $field) { |
|
| 83 | + foreach ($fields as $field) { |
|
| 84 | 84 | |
| 85 | 85 | //We need to skip auto_increment fields; they are not real metrics |
| 86 | 86 | //since they are generated by the database. |
| 87 | - if(isset($field['auto_increment'])) { |
|
| 87 | + if (isset($field['auto_increment'])) { |
|
| 88 | 88 | continue; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $this->monitor_id = $monitorId; |
| 97 | 97 | $this->stores = $store; |
| 98 | 98 | |
| 99 | - if(isset($this->metrics['session_id'])) { |
|
| 99 | + if (isset($this->metrics['session_id'])) { |
|
| 100 | 100 | //set the value of the session id for 2 reasons: |
| 101 | 101 | //1) it is the same value no matter where it is set |
| 102 | 102 | //2) ensure it follows some filter rules. |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * @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 |
| 109 | 109 | */ |
| 110 | - public function Monitor($name='', $monitorId='', $metadata='', $store=''){ |
|
| 110 | + public function Monitor($name = '', $monitorId = '', $metadata = '', $store = '') { |
|
| 111 | 111 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 112 | - if(isset($GLOBALS['log'])) { |
|
| 112 | + if (isset($GLOBALS['log'])) { |
|
| 113 | 113 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 114 | 114 | } |
| 115 | 115 | else { |
@@ -126,16 +126,16 @@ discard block |
||
| 126 | 126 | * @throws Exception Thrown if metric name is not configured for monitor instance |
| 127 | 127 | */ |
| 128 | 128 | public function setValue($name, $value) { |
| 129 | - if(!isset($this->metrics[$name])) { |
|
| 130 | - $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)"); |
|
| 131 | - throw new Exception($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)"); |
|
| 132 | - } else if($this->metrics[$name]->isMutable()) { |
|
| 129 | + if (!isset($this->metrics[$name])) { |
|
| 130 | + $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC']."($name)"); |
|
| 131 | + throw new Exception($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC']."($name)"); |
|
| 132 | + } else if ($this->metrics[$name]->isMutable()) { |
|
| 133 | 133 | $this->$name = is_object($value) ? get_class($value) : $value; |
| 134 | 134 | $this->dirty = true; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public function getValue($name){ |
|
| 138 | + public function getValue($name) { |
|
| 139 | 139 | return $this->$name; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * Returns if the monitor has data that needs to be saved |
| 163 | 163 | * @return $dirty boolean |
| 164 | 164 | */ |
| 165 | - function isDirty(){ |
|
| 165 | + function isDirty() { |
|
| 166 | 166 | return $this->dirty; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | * the flush method passing with the montior ($this) instance. |
| 173 | 173 | * @param $flush boolean parameter indicating whether or not to flush the instance data to store or possibly cache |
| 174 | 174 | */ |
| 175 | - public function save($flush=true) { |
|
| 175 | + public function save($flush = true) { |
|
| 176 | 176 | //If the monitor is not enabled, do not save |
| 177 | - if(!$this->isEnabled()&&$this->name!='tracker_sessions')return false; |
|
| 177 | + if (!$this->isEnabled() && $this->name != 'tracker_sessions')return false; |
|
| 178 | 178 | |
| 179 | 179 | //if the monitor does not have values set no need to do the work saving. |
| 180 | - if(!$this->dirty)return false; |
|
| 180 | + if (!$this->dirty)return false; |
|
| 181 | 181 | |
| 182 | - if(empty($GLOBALS['tracker_' . $this->table_name])) { |
|
| 183 | - foreach($this->stores as $s) { |
|
| 182 | + if (empty($GLOBALS['tracker_'.$this->table_name])) { |
|
| 183 | + foreach ($this->stores as $s) { |
|
| 184 | 184 | $store = $this->getStore($s); |
| 185 | 185 | $store->flush($this); |
| 186 | 186 | } |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function clear() { |
| 196 | 196 | $metrics = $this->getMetrics(); |
| 197 | - foreach($metrics as $name=>$metric) { |
|
| 198 | - if($metric->isMutable()) { |
|
| 197 | + foreach ($metrics as $name=>$metric) { |
|
| 198 | + if ($metric->isMutable()) { |
|
| 199 | 199 | $this->$name = ''; |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | protected function getStore($store) { |
| 215 | 215 | |
| 216 | - if(isset($this->cachedStores[$store])) { |
|
| 216 | + if (isset($this->cachedStores[$store])) { |
|
| 217 | 217 | return $this->cachedStores[$store]; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if(!file_exists("modules/Trackers/store/$store.php")) { |
|
| 221 | - $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)"); |
|
| 222 | - throw new Exception($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)"); |
|
| 220 | + if (!file_exists("modules/Trackers/store/$store.php")) { |
|
| 221 | + $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING']."($store)"); |
|
| 222 | + throw new Exception($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING']."($store)"); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | require_once("modules/Trackers/store/$store.php"); |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | return $s; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - public function getSessionId(){ |
|
| 231 | + public function getSessionId() { |
|
| 232 | 232 | $sessionid = session_id(); |
| 233 | - if(!empty($sessionid) && strlen($sessionid) > MAX_SESSION_LENGTH) { |
|
| 233 | + if (!empty($sessionid) && strlen($sessionid) > MAX_SESSION_LENGTH) { |
|
| 234 | 234 | $sessionid = md5($sessionid); |
| 235 | 235 | } |
| 236 | 236 | return $sessionid; |
@@ -243,13 +243,13 @@ discard block |
||
| 243 | 243 | public function toArray() { |
| 244 | 244 | $to_arr = array(); |
| 245 | 245 | $metrics = $this->getMetrics(); |
| 246 | - foreach($metrics as $name=>$metric) { |
|
| 246 | + foreach ($metrics as $name=>$metric) { |
|
| 247 | 247 | $to_arr[$name] = isset($this->$name) ? $this->$name : null; |
| 248 | 248 | } |
| 249 | 249 | return $to_arr; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - public function setEnabled($enable=true) { |
|
| 252 | + public function setEnabled($enable = true) { |
|
| 253 | 253 | $this->enabled = $enable; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -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. |
@@ -111,8 +113,7 @@ discard block |
||
| 111 | 113 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 112 | 114 | if(isset($GLOBALS['log'])) { |
| 113 | 115 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 114 | - } |
|
| 115 | - else { |
|
| 116 | + } else { |
|
| 116 | 117 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 117 | 118 | } |
| 118 | 119 | self::__construct($name, $monitorId, $metadata, $store); |
@@ -174,10 +175,14 @@ discard block |
||
| 174 | 175 | */ |
| 175 | 176 | public function save($flush=true) { |
| 176 | 177 | //If the monitor is not enabled, do not save |
| 177 | - if(!$this->isEnabled()&&$this->name!='tracker_sessions')return false; |
|
| 178 | + if(!$this->isEnabled()&&$this->name!='tracker_sessions') { |
|
| 179 | + return false; |
|
| 180 | + } |
|
| 178 | 181 | |
| 179 | 182 | //if the monitor does not have values set no need to do the work saving. |
| 180 | - if(!$this->dirty)return false; |
|
| 183 | + if(!$this->dirty) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 181 | 186 | |
| 182 | 187 | if(empty($GLOBALS['tracker_' . $this->table_name])) { |
| 183 | 188 | foreach($this->stores as $s) { |
@@ -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. |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Monitor constructor |
| 48 | 48 | */ |
| 49 | - public function __construct($name='', $monitorId='', $metadata='', $store='') { |
|
| 49 | + public function __construct($name = '', $monitorId = '', $metadata = '', $store = '') { |
|
| 50 | 50 | parent::__construct($name, $monitorId, $metadata, $store); |
| 51 | 51 | } |
| 52 | 52 | |
| 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 | - public function tracker_monitor($name='', $monitorId='', $metadata='', $store=''){ |
|
| 56 | + public function tracker_monitor($name = '', $monitorId = '', $metadata = '', $store = '') { |
|
| 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 { |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | * the flush method passing with the montior ($this) instance. |
| 73 | 73 | * @param $flush boolean parameter indicating whether or not to flush the instance data to store or possibly cache |
| 74 | 74 | */ |
| 75 | - public function save($flush=true) { |
|
| 75 | + public function save($flush = true) { |
|
| 76 | 76 | //if the monitor does not have values set no need to do the work saving. |
| 77 | - if(!$this->dirty)return false; |
|
| 77 | + if (!$this->dirty)return false; |
|
| 78 | 78 | |
| 79 | - if(!$this->isEnabled() && (isset($this->visible) && !$this->getValue('visible'))) { |
|
| 79 | + if (!$this->isEnabled() && (isset($this->visible) && !$this->getValue('visible'))) { |
|
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if(empty($GLOBALS['tracker_' . $this->table_name])) { |
|
| 84 | - foreach($this->stores as $s) { |
|
| 83 | + if (empty($GLOBALS['tracker_'.$this->table_name])) { |
|
| 84 | + foreach ($this->stores as $s) { |
|
| 85 | 85 | $store = $this->getStore($s); |
| 86 | 86 | $store->flush($this); |
| 87 | 87 | } |
@@ -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. |
@@ -57,8 +59,7 @@ discard block |
||
| 57 | 59 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 58 | 60 | if(isset($GLOBALS['log'])) { |
| 59 | 61 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 60 | - } |
|
| 61 | - else { |
|
| 62 | + } else { |
|
| 62 | 63 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 63 | 64 | } |
| 64 | 65 | self::__construct($name, $monitorId, $metadata, $store); |
@@ -74,7 +75,9 @@ discard block |
||
| 74 | 75 | */ |
| 75 | 76 | public function save($flush=true) { |
| 76 | 77 | //if the monitor does not have values set no need to do the work saving. |
| 77 | - if(!$this->dirty)return false; |
|
| 78 | + if(!$this->dirty) { |
|
| 79 | + return false; |
|
| 80 | + } |
|
| 78 | 81 | |
| 79 | 82 | if(!$this->isEnabled() && (isset($this->visible) && !$this->getValue('visible'))) { |
| 80 | 83 | return false; |
@@ -53,19 +53,19 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @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 |
|
| 58 | - */ |
|
| 59 | - public function BlankMonitor(){ |
|
| 60 | - $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 61 | - if(isset($GLOBALS['log'])) { |
|
| 62 | - $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 63 | - } |
|
| 64 | - else { |
|
| 65 | - trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 66 | - } |
|
| 67 | - self::__construct(); |
|
| 68 | - } |
|
| 56 | + /** |
|
| 57 | + * @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 |
|
| 58 | + */ |
|
| 59 | + public function BlankMonitor(){ |
|
| 60 | + $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 61 | + if(isset($GLOBALS['log'])) { |
|
| 62 | + $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 63 | + } |
|
| 64 | + else { |
|
| 65 | + trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 66 | + } |
|
| 67 | + self::__construct(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * setValue |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @return Array of metric instances defined for monitor instance |
| 94 | 94 | */ |
| 95 | 95 | function getMetrics() { |
| 96 | - return null; |
|
| 96 | + return null; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -107,27 +107,27 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * getStore |
|
| 112 | - * This method checks if the Store implementation has already been instantiated and |
|
| 113 | - * will return the one stored; otherwise it will create the Store implementation and |
|
| 114 | - * save it to the Array of Stores. |
|
| 115 | - * @param $store The name of the store as defined in the 'modules/Trackers/config.php' settings |
|
| 116 | - * @return An instance of a Store implementation |
|
| 117 | - * @throws Exception Thrown if $store class cannot be loaded |
|
| 118 | - */ |
|
| 119 | - protected function getStore($store) { |
|
| 120 | - return null; |
|
| 121 | - } |
|
| 110 | + /** |
|
| 111 | + * getStore |
|
| 112 | + * This method checks if the Store implementation has already been instantiated and |
|
| 113 | + * will return the one stored; otherwise it will create the Store implementation and |
|
| 114 | + * save it to the Array of Stores. |
|
| 115 | + * @param $store The name of the store as defined in the 'modules/Trackers/config.php' settings |
|
| 116 | + * @return An instance of a Store implementation |
|
| 117 | + * @throws Exception Thrown if $store class cannot be loaded |
|
| 118 | + */ |
|
| 119 | + protected function getStore($store) { |
|
| 120 | + return null; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * clear |
|
| 126 | - * This function clears the metrics data in the monitor instance |
|
| 127 | - */ |
|
| 128 | - public function clear() { |
|
| 124 | + /** |
|
| 125 | + * clear |
|
| 126 | + * This function clears the metrics data in the monitor instance |
|
| 127 | + */ |
|
| 128 | + public function clear() { |
|
| 129 | 129 | |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | ?> |
| 134 | 134 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * @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 |
| 58 | 58 | */ |
| 59 | - public function BlankMonitor(){ |
|
| 59 | + public function BlankMonitor() { |
|
| 60 | 60 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 61 | - if(isset($GLOBALS['log'])) { |
|
| 61 | + if (isset($GLOBALS['log'])) { |
|
| 62 | 62 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 63 | 63 | } |
| 64 | 64 | else { |
@@ -41,231 +41,231 @@ |
||
| 41 | 41 | |
| 42 | 42 | class BreadCrumbStack { |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Maintain an ordered list of items in the breadcrumbs |
|
| 46 | - * |
|
| 47 | - * @var unknown_type |
|
| 48 | - */ |
|
| 49 | - private $stack; |
|
| 50 | - /** |
|
| 51 | - * Maps an item_id to the position index in stack |
|
| 52 | - * |
|
| 53 | - * @var unknown_type |
|
| 54 | - */ |
|
| 55 | - private $stackMap; |
|
| 56 | - /** |
|
| 57 | - * Boolean flag to determine whether or not entries not visible should be removed |
|
| 58 | - * |
|
| 59 | - * @var |
|
| 60 | - */ |
|
| 61 | - private $deleteInvisible = false; |
|
| 44 | + /** |
|
| 45 | + * Maintain an ordered list of items in the breadcrumbs |
|
| 46 | + * |
|
| 47 | + * @var unknown_type |
|
| 48 | + */ |
|
| 49 | + private $stack; |
|
| 50 | + /** |
|
| 51 | + * Maps an item_id to the position index in stack |
|
| 52 | + * |
|
| 53 | + * @var unknown_type |
|
| 54 | + */ |
|
| 55 | + private $stackMap; |
|
| 56 | + /** |
|
| 57 | + * Boolean flag to determine whether or not entries not visible should be removed |
|
| 58 | + * |
|
| 59 | + * @var |
|
| 60 | + */ |
|
| 61 | + private $deleteInvisible = false; |
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * BreadCrumbStack |
|
| 66 | - * Constructor for BreadCrumbStack that builds list of breadcrumbs using tracker table |
|
| 67 | - * |
|
| 68 | - * @param $user_id String value of user id to get bread crumb items for |
|
| 69 | - * @param $modules mixed value of module name(s) to provide extra filtering |
|
| 70 | - */ |
|
| 71 | - public function __construct($user_id, $modules='') { |
|
| 72 | - $this->stack = array(); |
|
| 73 | - $this->stackMap = array(); |
|
| 64 | + /** |
|
| 65 | + * BreadCrumbStack |
|
| 66 | + * Constructor for BreadCrumbStack that builds list of breadcrumbs using tracker table |
|
| 67 | + * |
|
| 68 | + * @param $user_id String value of user id to get bread crumb items for |
|
| 69 | + * @param $modules mixed value of module name(s) to provide extra filtering |
|
| 70 | + */ |
|
| 71 | + public function __construct($user_id, $modules='') { |
|
| 72 | + $this->stack = array(); |
|
| 73 | + $this->stackMap = array(); |
|
| 74 | 74 | |
| 75 | - $admin = new Administration(); |
|
| 76 | - $admin->retrieveSettings('tracker'); |
|
| 75 | + $admin = new Administration(); |
|
| 76 | + $admin->retrieveSettings('tracker'); |
|
| 77 | 77 | |
| 78 | - $this->deleteInvisible = !empty($admin->settings['tracker_Tracker']); |
|
| 79 | - $db = DBManagerFactory::getInstance(); |
|
| 78 | + $this->deleteInvisible = !empty($admin->settings['tracker_Tracker']); |
|
| 79 | + $db = DBManagerFactory::getInstance(); |
|
| 80 | 80 | |
| 81 | - $module_query = ''; |
|
| 82 | - if(!empty($modules)) { |
|
| 83 | - $history_max_viewed = 10; |
|
| 84 | - $module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','" , $modules) . '\')' : ' AND module_name = \'' . $modules . '\''; |
|
| 85 | - } else { |
|
| 86 | - $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 87 | - } |
|
| 81 | + $module_query = ''; |
|
| 82 | + if(!empty($modules)) { |
|
| 83 | + $history_max_viewed = 10; |
|
| 84 | + $module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','" , $modules) . '\')' : ' AND module_name = \'' . $modules . '\''; |
|
| 85 | + } else { |
|
| 86 | + $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $query = 'SELECT distinct item_id AS item_id, id, item_summary, module_name, monitor_id, date_modified FROM tracker WHERE user_id = \'' . $user_id . '\' AND deleted = 0 AND visible = 1 ' . $module_query . ' ORDER BY date_modified DESC'; |
|
| 90 | - $result = $db->limitQuery($query, 0, $history_max_viewed); |
|
| 91 | - $items = array(); |
|
| 92 | - while(($row = $db->fetchByAssoc($result))) { |
|
| 93 | - $items[] = $row; |
|
| 94 | - } |
|
| 95 | - $items = array_reverse($items); |
|
| 96 | - foreach($items as $item) { |
|
| 97 | - $this->push($item); |
|
| 98 | - } |
|
| 99 | - } |
|
| 89 | + $query = 'SELECT distinct item_id AS item_id, id, item_summary, module_name, monitor_id, date_modified FROM tracker WHERE user_id = \'' . $user_id . '\' AND deleted = 0 AND visible = 1 ' . $module_query . ' ORDER BY date_modified DESC'; |
|
| 90 | + $result = $db->limitQuery($query, 0, $history_max_viewed); |
|
| 91 | + $items = array(); |
|
| 92 | + while(($row = $db->fetchByAssoc($result))) { |
|
| 93 | + $items[] = $row; |
|
| 94 | + } |
|
| 95 | + $items = array_reverse($items); |
|
| 96 | + foreach($items as $item) { |
|
| 97 | + $this->push($item); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * @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 |
|
| 103 | - */ |
|
| 104 | - public function BreadCrumbStack($user_id, $modules=''){ |
|
| 105 | - $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 106 | - if(isset($GLOBALS['log'])) { |
|
| 107 | - $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 108 | - } |
|
| 109 | - else { |
|
| 110 | - trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 111 | - } |
|
| 112 | - self::__construct($user_id, $modules); |
|
| 113 | - } |
|
| 101 | + /** |
|
| 102 | + * @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 |
|
| 103 | + */ |
|
| 104 | + public function BreadCrumbStack($user_id, $modules=''){ |
|
| 105 | + $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
| 106 | + if(isset($GLOBALS['log'])) { |
|
| 107 | + $GLOBALS['log']->deprecated($deprecatedMessage); |
|
| 108 | + } |
|
| 109 | + else { |
|
| 110 | + trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
| 111 | + } |
|
| 112 | + self::__construct($user_id, $modules); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * contains |
|
| 117 | - * Returns true if the stack contains the specified item_id, false otherwise. |
|
| 118 | - * |
|
| 119 | - * @param item_id the item id to search for |
|
| 120 | - * @return id of the first item on the stack |
|
| 121 | - */ |
|
| 122 | - public function contains($item_id) { |
|
| 123 | - if(!empty($this->stackMap)){ |
|
| 124 | - return array_key_exists($item_id, $this->stackMap); |
|
| 125 | - }else |
|
| 126 | - return false; |
|
| 127 | - } |
|
| 115 | + /** |
|
| 116 | + * contains |
|
| 117 | + * Returns true if the stack contains the specified item_id, false otherwise. |
|
| 118 | + * |
|
| 119 | + * @param item_id the item id to search for |
|
| 120 | + * @return id of the first item on the stack |
|
| 121 | + */ |
|
| 122 | + public function contains($item_id) { |
|
| 123 | + if(!empty($this->stackMap)){ |
|
| 124 | + return array_key_exists($item_id, $this->stackMap); |
|
| 125 | + }else |
|
| 126 | + return false; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Push an element onto the stack. |
|
| 131 | - * This will only maintain a list of unique item_ids, if an item_id is found to |
|
| 132 | - * already exist in the stack, we want to remove it and update the database to reflect it's |
|
| 133 | - * visibility. |
|
| 134 | - * |
|
| 135 | - * @param array $row - a trackable item to store in memory |
|
| 136 | - */ |
|
| 137 | - public function push($row) { |
|
| 138 | - if(is_array($row) && !empty($row['item_id'])) { |
|
| 139 | - if($this->contains($row['item_id'])) { |
|
| 140 | - //if this item already exists in the stack then update the found items |
|
| 141 | - //to visible = 0 and add our new item to the stack |
|
| 142 | - $item = $this->stack[$this->stackMap[$row['item_id']]]; |
|
| 143 | - if(!empty($item['id']) && $row['id'] != $item['id']){ |
|
| 144 | - $this->makeItemInvisible($item['id'], 0); |
|
| 145 | - } |
|
| 146 | - $this->popItem($item['item_id']); |
|
| 147 | - } |
|
| 148 | - //If we reach the max count, shift the first element off the stack |
|
| 149 | - $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 129 | + /** |
|
| 130 | + * Push an element onto the stack. |
|
| 131 | + * This will only maintain a list of unique item_ids, if an item_id is found to |
|
| 132 | + * already exist in the stack, we want to remove it and update the database to reflect it's |
|
| 133 | + * visibility. |
|
| 134 | + * |
|
| 135 | + * @param array $row - a trackable item to store in memory |
|
| 136 | + */ |
|
| 137 | + public function push($row) { |
|
| 138 | + if(is_array($row) && !empty($row['item_id'])) { |
|
| 139 | + if($this->contains($row['item_id'])) { |
|
| 140 | + //if this item already exists in the stack then update the found items |
|
| 141 | + //to visible = 0 and add our new item to the stack |
|
| 142 | + $item = $this->stack[$this->stackMap[$row['item_id']]]; |
|
| 143 | + if(!empty($item['id']) && $row['id'] != $item['id']){ |
|
| 144 | + $this->makeItemInvisible($item['id'], 0); |
|
| 145 | + } |
|
| 146 | + $this->popItem($item['item_id']); |
|
| 147 | + } |
|
| 148 | + //If we reach the max count, shift the first element off the stack |
|
| 149 | + $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 150 | 150 | |
| 151 | - if($this->length() >= $history_max_viewed) { |
|
| 152 | - $this->pop(); |
|
| 153 | - } |
|
| 154 | - //Push the element into the stack |
|
| 155 | - $this->addItem($row); |
|
| 156 | - } |
|
| 157 | - } |
|
| 151 | + if($this->length() >= $history_max_viewed) { |
|
| 152 | + $this->pop(); |
|
| 153 | + } |
|
| 154 | + //Push the element into the stack |
|
| 155 | + $this->addItem($row); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Pop an item off the stack |
|
| 161 | - * |
|
| 162 | - */ |
|
| 163 | - public function pop(){ |
|
| 164 | - $item = array_shift($this->stack); |
|
| 165 | - if(!empty($item['item_id']) && isset($this->stackMap[$item['item_id']])){ |
|
| 166 | - unset($this->stackMap[$item['item_id']]); |
|
| 167 | - $this->heal(); |
|
| 168 | - } |
|
| 169 | - } |
|
| 159 | + /** |
|
| 160 | + * Pop an item off the stack |
|
| 161 | + * |
|
| 162 | + */ |
|
| 163 | + public function pop(){ |
|
| 164 | + $item = array_shift($this->stack); |
|
| 165 | + if(!empty($item['item_id']) && isset($this->stackMap[$item['item_id']])){ |
|
| 166 | + unset($this->stackMap[$item['item_id']]); |
|
| 167 | + $this->heal(); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * Change the visibility of an item |
|
| 173 | - * |
|
| 174 | - * @param int $id |
|
| 175 | - */ |
|
| 176 | - private function makeItemInvisible($id){ |
|
| 177 | - if($this->deleteInvisible) { |
|
| 178 | - $query = "DELETE FROM tracker where id = '{$id}'"; |
|
| 179 | - } else { |
|
| 180 | - $query = "UPDATE tracker SET visible = 0 WHERE id = '{$id}'"; |
|
| 181 | - } |
|
| 171 | + /** |
|
| 172 | + * Change the visibility of an item |
|
| 173 | + * |
|
| 174 | + * @param int $id |
|
| 175 | + */ |
|
| 176 | + private function makeItemInvisible($id){ |
|
| 177 | + if($this->deleteInvisible) { |
|
| 178 | + $query = "DELETE FROM tracker where id = '{$id}'"; |
|
| 179 | + } else { |
|
| 180 | + $query = "UPDATE tracker SET visible = 0 WHERE id = '{$id}'"; |
|
| 181 | + } |
|
| 182 | 182 | $GLOBALS['db']->query($query, true); |
| 183 | - } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Pop an Item off the stack. Call heal to reconstruct the indices properly |
|
| 187 | - * |
|
| 188 | - * @param string $item_id - the item id to remove from the stack |
|
| 189 | - */ |
|
| 190 | - public function popItem($item_id){ |
|
| 191 | - if(isset($this->stackMap[$item_id])){ |
|
| 192 | - $idx = $this->stackMap[$item_id]; |
|
| 193 | - unset($this->stack[$idx]); |
|
| 194 | - unset($this->stackMap[$item_id]); |
|
| 195 | - $this->heal(); |
|
| 196 | - } |
|
| 197 | - } |
|
| 185 | + /** |
|
| 186 | + * Pop an Item off the stack. Call heal to reconstruct the indices properly |
|
| 187 | + * |
|
| 188 | + * @param string $item_id - the item id to remove from the stack |
|
| 189 | + */ |
|
| 190 | + public function popItem($item_id){ |
|
| 191 | + if(isset($this->stackMap[$item_id])){ |
|
| 192 | + $idx = $this->stackMap[$item_id]; |
|
| 193 | + unset($this->stack[$idx]); |
|
| 194 | + unset($this->stackMap[$item_id]); |
|
| 195 | + $this->heal(); |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Add an item to the stack |
|
| 201 | - * |
|
| 202 | - * @param array $row - the row from the db query |
|
| 203 | - */ |
|
| 204 | - private function addItem($row){ |
|
| 205 | - $this->stack[] = $row; |
|
| 206 | - $this->stackMap[$row['item_id']] = ($this->length() - 1); |
|
| 207 | - } |
|
| 199 | + /** |
|
| 200 | + * Add an item to the stack |
|
| 201 | + * |
|
| 202 | + * @param array $row - the row from the db query |
|
| 203 | + */ |
|
| 204 | + private function addItem($row){ |
|
| 205 | + $this->stack[] = $row; |
|
| 206 | + $this->stackMap[$row['item_id']] = ($this->length() - 1); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Once we have removed an item from the stack we need to be sure to have the |
|
| 211 | - * ids and indices match up properly. Heal takes care of that. This method should only |
|
| 212 | - * be called when an item_id is already in the stack and needs to be removed |
|
| 213 | - * |
|
| 214 | - */ |
|
| 215 | - private function heal(){ |
|
| 216 | - $vals = array_values($this->stack); |
|
| 217 | - $this->stack = array(); |
|
| 218 | - $this->stackMap = array(); |
|
| 219 | - foreach($vals as $key => $val){ |
|
| 220 | - $this->addItem($val); |
|
| 221 | - } |
|
| 222 | - } |
|
| 209 | + /** |
|
| 210 | + * Once we have removed an item from the stack we need to be sure to have the |
|
| 211 | + * ids and indices match up properly. Heal takes care of that. This method should only |
|
| 212 | + * be called when an item_id is already in the stack and needs to be removed |
|
| 213 | + * |
|
| 214 | + */ |
|
| 215 | + private function heal(){ |
|
| 216 | + $vals = array_values($this->stack); |
|
| 217 | + $this->stack = array(); |
|
| 218 | + $this->stackMap = array(); |
|
| 219 | + foreach($vals as $key => $val){ |
|
| 220 | + $this->addItem($val); |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * Return the number of elements in the stack |
|
| 226 | - * |
|
| 227 | - * @return int - the number of elements in the stack |
|
| 228 | - */ |
|
| 229 | - public function length(){ |
|
| 230 | - return count($this->stack); |
|
| 231 | - } |
|
| 224 | + /** |
|
| 225 | + * Return the number of elements in the stack |
|
| 226 | + * |
|
| 227 | + * @return int - the number of elements in the stack |
|
| 228 | + */ |
|
| 229 | + public function length(){ |
|
| 230 | + return count($this->stack); |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * Return the list of breadcrubmbs currently in memory |
|
| 235 | - * |
|
| 236 | - * @return array of breadcrumbs |
|
| 237 | - */ |
|
| 238 | - public function getBreadCrumbList($filter_module='') { |
|
| 239 | - if(!empty($filter_module)) { |
|
| 240 | - $s2 = array(); |
|
| 241 | - if(is_array($filter_module)) { |
|
| 242 | - foreach($this->stack as $entry) { |
|
| 243 | - if(in_array($entry['module_name'], $filter_module)) { |
|
| 244 | - $s2[$entry['item_id']] = $entry; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } else { |
|
| 248 | - foreach($this->stack as $entry) { |
|
| 249 | - if($entry['module_name'] == $filter_module) { |
|
| 250 | - $s2[$entry['item_id']] = $entry; |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 233 | + /** |
|
| 234 | + * Return the list of breadcrubmbs currently in memory |
|
| 235 | + * |
|
| 236 | + * @return array of breadcrumbs |
|
| 237 | + */ |
|
| 238 | + public function getBreadCrumbList($filter_module='') { |
|
| 239 | + if(!empty($filter_module)) { |
|
| 240 | + $s2 = array(); |
|
| 241 | + if(is_array($filter_module)) { |
|
| 242 | + foreach($this->stack as $entry) { |
|
| 243 | + if(in_array($entry['module_name'], $filter_module)) { |
|
| 244 | + $s2[$entry['item_id']] = $entry; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | + foreach($this->stack as $entry) { |
|
| 249 | + if($entry['module_name'] == $filter_module) { |
|
| 250 | + $s2[$entry['item_id']] = $entry; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - $s2 = array_reverse($s2); |
|
| 256 | - if(count($s2) > 10) { |
|
| 257 | - $s2 = array_slice($s2, 0, 10); |
|
| 258 | - } |
|
| 259 | - return $s2; |
|
| 260 | - } |
|
| 255 | + $s2 = array_reverse($s2); |
|
| 256 | + if(count($s2) > 10) { |
|
| 257 | + $s2 = array_slice($s2, 0, 10); |
|
| 258 | + } |
|
| 259 | + return $s2; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $s = $this->stack; |
|
| 263 | - $s = array_reverse($s); |
|
| 264 | - if(count($s) > 10) { |
|
| 265 | - $s = array_slice($s, 0, 10); |
|
| 266 | - } |
|
| 267 | - return $s; |
|
| 268 | - } |
|
| 262 | + $s = $this->stack; |
|
| 263 | + $s = array_reverse($s); |
|
| 264 | + if(count($s) > 10) { |
|
| 265 | + $s = array_slice($s, 0, 10); |
|
| 266 | + } |
|
| 267 | + return $s; |
|
| 268 | + } |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | ?> |
@@ -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. |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param $user_id String value of user id to get bread crumb items for |
| 69 | 69 | * @param $modules mixed value of module name(s) to provide extra filtering |
| 70 | 70 | */ |
| 71 | - public function __construct($user_id, $modules='') { |
|
| 71 | + public function __construct($user_id, $modules = '') { |
|
| 72 | 72 | $this->stack = array(); |
| 73 | 73 | $this->stackMap = array(); |
| 74 | 74 | |
@@ -79,21 +79,21 @@ discard block |
||
| 79 | 79 | $db = DBManagerFactory::getInstance(); |
| 80 | 80 | |
| 81 | 81 | $module_query = ''; |
| 82 | - if(!empty($modules)) { |
|
| 82 | + if (!empty($modules)) { |
|
| 83 | 83 | $history_max_viewed = 10; |
| 84 | - $module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','" , $modules) . '\')' : ' AND module_name = \'' . $modules . '\''; |
|
| 84 | + $module_query = is_array($modules) ? ' AND module_name IN (\''.implode("','", $modules).'\')' : ' AND module_name = \''.$modules.'\''; |
|
| 85 | 85 | } else { |
| 86 | - $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 86 | + $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed'])) ? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $query = 'SELECT distinct item_id AS item_id, id, item_summary, module_name, monitor_id, date_modified FROM tracker WHERE user_id = \'' . $user_id . '\' AND deleted = 0 AND visible = 1 ' . $module_query . ' ORDER BY date_modified DESC'; |
|
| 89 | + $query = 'SELECT distinct item_id AS item_id, id, item_summary, module_name, monitor_id, date_modified FROM tracker WHERE user_id = \''.$user_id.'\' AND deleted = 0 AND visible = 1 '.$module_query.' ORDER BY date_modified DESC'; |
|
| 90 | 90 | $result = $db->limitQuery($query, 0, $history_max_viewed); |
| 91 | 91 | $items = array(); |
| 92 | - while(($row = $db->fetchByAssoc($result))) { |
|
| 92 | + while (($row = $db->fetchByAssoc($result))) { |
|
| 93 | 93 | $items[] = $row; |
| 94 | 94 | } |
| 95 | 95 | $items = array_reverse($items); |
| 96 | - foreach($items as $item) { |
|
| 96 | + foreach ($items as $item) { |
|
| 97 | 97 | $this->push($item); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * @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 |
| 103 | 103 | */ |
| 104 | - public function BreadCrumbStack($user_id, $modules=''){ |
|
| 104 | + public function BreadCrumbStack($user_id, $modules = '') { |
|
| 105 | 105 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 106 | - if(isset($GLOBALS['log'])) { |
|
| 106 | + if (isset($GLOBALS['log'])) { |
|
| 107 | 107 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 108 | 108 | } |
| 109 | 109 | else { |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | * @return id of the first item on the stack |
| 121 | 121 | */ |
| 122 | 122 | public function contains($item_id) { |
| 123 | - if(!empty($this->stackMap)){ |
|
| 123 | + if (!empty($this->stackMap)) { |
|
| 124 | 124 | return array_key_exists($item_id, $this->stackMap); |
| 125 | - }else |
|
| 125 | + } else |
|
| 126 | 126 | return false; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -135,20 +135,20 @@ discard block |
||
| 135 | 135 | * @param array $row - a trackable item to store in memory |
| 136 | 136 | */ |
| 137 | 137 | public function push($row) { |
| 138 | - if(is_array($row) && !empty($row['item_id'])) { |
|
| 139 | - if($this->contains($row['item_id'])) { |
|
| 138 | + if (is_array($row) && !empty($row['item_id'])) { |
|
| 139 | + if ($this->contains($row['item_id'])) { |
|
| 140 | 140 | //if this item already exists in the stack then update the found items |
| 141 | 141 | //to visible = 0 and add our new item to the stack |
| 142 | 142 | $item = $this->stack[$this->stackMap[$row['item_id']]]; |
| 143 | - if(!empty($item['id']) && $row['id'] != $item['id']){ |
|
| 143 | + if (!empty($item['id']) && $row['id'] != $item['id']) { |
|
| 144 | 144 | $this->makeItemInvisible($item['id'], 0); |
| 145 | 145 | } |
| 146 | 146 | $this->popItem($item['item_id']); |
| 147 | 147 | } |
| 148 | 148 | //If we reach the max count, shift the first element off the stack |
| 149 | - $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 149 | + $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed'])) ? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 150 | 150 | |
| 151 | - if($this->length() >= $history_max_viewed) { |
|
| 151 | + if ($this->length() >= $history_max_viewed) { |
|
| 152 | 152 | $this->pop(); |
| 153 | 153 | } |
| 154 | 154 | //Push the element into the stack |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | * Pop an item off the stack |
| 161 | 161 | * |
| 162 | 162 | */ |
| 163 | - public function pop(){ |
|
| 163 | + public function pop() { |
|
| 164 | 164 | $item = array_shift($this->stack); |
| 165 | - if(!empty($item['item_id']) && isset($this->stackMap[$item['item_id']])){ |
|
| 165 | + if (!empty($item['item_id']) && isset($this->stackMap[$item['item_id']])) { |
|
| 166 | 166 | unset($this->stackMap[$item['item_id']]); |
| 167 | 167 | $this->heal(); |
| 168 | 168 | } |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @param int $id |
| 175 | 175 | */ |
| 176 | - private function makeItemInvisible($id){ |
|
| 177 | - if($this->deleteInvisible) { |
|
| 176 | + private function makeItemInvisible($id) { |
|
| 177 | + if ($this->deleteInvisible) { |
|
| 178 | 178 | $query = "DELETE FROM tracker where id = '{$id}'"; |
| 179 | 179 | } else { |
| 180 | 180 | $query = "UPDATE tracker SET visible = 0 WHERE id = '{$id}'"; |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @param string $item_id - the item id to remove from the stack |
| 189 | 189 | */ |
| 190 | - public function popItem($item_id){ |
|
| 191 | - if(isset($this->stackMap[$item_id])){ |
|
| 190 | + public function popItem($item_id) { |
|
| 191 | + if (isset($this->stackMap[$item_id])) { |
|
| 192 | 192 | $idx = $this->stackMap[$item_id]; |
| 193 | 193 | unset($this->stack[$idx]); |
| 194 | 194 | unset($this->stackMap[$item_id]); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @param array $row - the row from the db query |
| 203 | 203 | */ |
| 204 | - private function addItem($row){ |
|
| 204 | + private function addItem($row) { |
|
| 205 | 205 | $this->stack[] = $row; |
| 206 | 206 | $this->stackMap[$row['item_id']] = ($this->length() - 1); |
| 207 | 207 | } |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | * be called when an item_id is already in the stack and needs to be removed |
| 213 | 213 | * |
| 214 | 214 | */ |
| 215 | - private function heal(){ |
|
| 215 | + private function heal() { |
|
| 216 | 216 | $vals = array_values($this->stack); |
| 217 | 217 | $this->stack = array(); |
| 218 | 218 | $this->stackMap = array(); |
| 219 | - foreach($vals as $key => $val){ |
|
| 219 | + foreach ($vals as $key => $val) { |
|
| 220 | 220 | $this->addItem($val); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return int - the number of elements in the stack |
| 228 | 228 | */ |
| 229 | - public function length(){ |
|
| 229 | + public function length() { |
|
| 230 | 230 | return count($this->stack); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -235,25 +235,25 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return array of breadcrumbs |
| 237 | 237 | */ |
| 238 | - public function getBreadCrumbList($filter_module='') { |
|
| 239 | - if(!empty($filter_module)) { |
|
| 238 | + public function getBreadCrumbList($filter_module = '') { |
|
| 239 | + if (!empty($filter_module)) { |
|
| 240 | 240 | $s2 = array(); |
| 241 | - if(is_array($filter_module)) { |
|
| 242 | - foreach($this->stack as $entry) { |
|
| 243 | - if(in_array($entry['module_name'], $filter_module)) { |
|
| 241 | + if (is_array($filter_module)) { |
|
| 242 | + foreach ($this->stack as $entry) { |
|
| 243 | + if (in_array($entry['module_name'], $filter_module)) { |
|
| 244 | 244 | $s2[$entry['item_id']] = $entry; |
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | } else { |
| 248 | - foreach($this->stack as $entry) { |
|
| 249 | - if($entry['module_name'] == $filter_module) { |
|
| 248 | + foreach ($this->stack as $entry) { |
|
| 249 | + if ($entry['module_name'] == $filter_module) { |
|
| 250 | 250 | $s2[$entry['item_id']] = $entry; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | $s2 = array_reverse($s2); |
| 256 | - if(count($s2) > 10) { |
|
| 256 | + if (count($s2) > 10) { |
|
| 257 | 257 | $s2 = array_slice($s2, 0, 10); |
| 258 | 258 | } |
| 259 | 259 | return $s2; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $s = $this->stack; |
| 263 | 263 | $s = array_reverse($s); |
| 264 | - if(count($s) > 10) { |
|
| 264 | + if (count($s) > 10) { |
|
| 265 | 265 | $s = array_slice($s, 0, 10); |
| 266 | 266 | } |
| 267 | 267 | return $s; |
@@ -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. |
@@ -105,8 +107,7 @@ discard block |
||
| 105 | 107 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 106 | 108 | if(isset($GLOBALS['log'])) { |
| 107 | 109 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 108 | - } |
|
| 109 | - else { |
|
| 110 | + } else { |
|
| 110 | 111 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 111 | 112 | } |
| 112 | 113 | self::__construct($user_id, $modules); |
@@ -122,8 +123,9 @@ discard block |
||
| 122 | 123 | public function contains($item_id) { |
| 123 | 124 | if(!empty($this->stackMap)){ |
| 124 | 125 | return array_key_exists($item_id, $this->stackMap); |
| 125 | - }else |
|
| 126 | - return false; |
|
| 126 | + } else { |
|
| 127 | + return false; |
|
| 128 | + } |
|
| 127 | 129 | } |
| 128 | 130 | |
| 129 | 131 | /** |
@@ -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. |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @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 |
| 52 | 52 | */ |
| 53 | - public function Metric($type, $name){ |
|
| 53 | + public function Metric($type, $name) { |
|
| 54 | 54 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 55 | - if(isset($GLOBALS['log'])) { |
|
| 55 | + if (isset($GLOBALS['log'])) { |
|
| 56 | 56 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 57 | 57 | } |
| 58 | 58 | 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. |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | /** |
| 65 | 65 | * @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 |
| 66 | 66 | */ |
| 67 | - private function TrackerManager(){ |
|
| 67 | + private function TrackerManager() { |
|
| 68 | 68 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 69 | - if(isset($GLOBALS['log'])) { |
|
| 69 | + if (isset($GLOBALS['log'])) { |
|
| 70 | 70 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 71 | 71 | } |
| 72 | 72 | else { |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | */ |
| 85 | 85 | private function setup() { |
| 86 | - if(!empty($this->metadata) && empty($GLOBALS['installing'])) { |
|
| 86 | + if (!empty($this->metadata) && empty($GLOBALS['installing'])) { |
|
| 87 | 87 | |
| 88 | 88 | $admin = new Administration(); |
| 89 | 89 | $admin->retrieveSettings('tracker'); |
| 90 | - foreach($this->metadata as $key=>$entry) { |
|
| 91 | - if(isset($entry['bean'])) { |
|
| 92 | - if(!empty($admin->settings['tracker_'. $entry['name']])) { |
|
| 90 | + foreach ($this->metadata as $key=>$entry) { |
|
| 91 | + if (isset($entry['bean'])) { |
|
| 92 | + if (!empty($admin->settings['tracker_'.$entry['name']])) { |
|
| 93 | 93 | $this->disabledMonitors[$entry['name']] = true; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public function setMonitorId($id) { |
| 101 | 101 | self::$monitor_id = $id; |
| 102 | - foreach($this->monitors as $monitor) { |
|
| 102 | + foreach ($this->monitors as $monitor) { |
|
| 103 | 103 | $monitor->monitor_id = self::$monitor_id; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * Singleton method to return static instance of TrackerManager |
| 119 | 119 | * @returns static TrackerManager instance |
| 120 | 120 | */ |
| 121 | -static function getInstance(){ |
|
| 121 | +static function getInstance() { |
|
| 122 | 122 | if (!isset(self::$instance)) { |
| 123 | 123 | self::$instance = new TrackerManager(); |
| 124 | 124 | //Set global variable for tracker monitor instances that are disabled |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function getMonitor($name) { |
| 137 | 137 | //don't waste our time on disabled monitors |
| 138 | - if($name!='tracker_sessions' && !empty($this->disabledMonitors[$name]))return false; |
|
| 139 | - if(isset($this->monitors[$name])) { |
|
| 138 | + if ($name != 'tracker_sessions' && !empty($this->disabledMonitors[$name]))return false; |
|
| 139 | + if (isset($this->monitors[$name])) { |
|
| 140 | 140 | return $this->monitors[$name]; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if(isset($this->metadata) && isset($this->metadata[$name])) { |
|
| 143 | + if (isset($this->metadata) && isset($this->metadata[$name])) { |
|
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | try { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | ); |
| 152 | 152 | $this->monitors[$name] = $instance; |
| 153 | 153 | return $this->monitors[$name]; |
| 154 | - } catch (Exception $ex) { |
|
| 154 | + }catch (Exception $ex) { |
|
| 155 | 155 | $GLOBALS['log']->error($ex->getMessage()); |
| 156 | 156 | $GLOBALS['log']->error($ex->getTraceAsString()); |
| 157 | 157 | require_once('modules/Trackers/monitor/BlankMonitor.php'); |
@@ -160,27 +160,27 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | } else { |
| 163 | - $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_NOT_CONFIGURED'] . "($name)"); |
|
| 163 | + $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_NOT_CONFIGURED']."($name)"); |
|
| 164 | 164 | require_once('modules/Trackers/monitor/BlankMonitor.php'); |
| 165 | 165 | $this->monitors[$name] = new BlankMonitor(); |
| 166 | 166 | return $this->monitors[$name]; |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | -private function _getMonitor($name='', $monitorId='', $metadata='', $store=''){ |
|
| 170 | +private function _getMonitor($name = '', $monitorId = '', $metadata = '', $store = '') { |
|
| 171 | 171 | $class = strtolower($name.'_monitor'); |
| 172 | 172 | $monitor = null; |
| 173 | - if(file_exists('custom/modules/Trackers/monitor/'.$class.'.php')){ |
|
| 173 | + if (file_exists('custom/modules/Trackers/monitor/'.$class.'.php')) { |
|
| 174 | 174 | require_once('custom/modules/Trackers/monitor/'.$class.'.php'); |
| 175 | - if(class_exists($class)){ |
|
| 175 | + if (class_exists($class)) { |
|
| 176 | 176 | $monitor = new $class($name, $monitorId, $metadata, $store); |
| 177 | 177 | } |
| 178 | - }elseif(file_exists('modules/Trackers/monitor/'.$class.'.php')){ |
|
| 178 | + }elseif (file_exists('modules/Trackers/monitor/'.$class.'.php')) { |
|
| 179 | 179 | require_once('modules/Trackers/monitor/'.$class.'.php'); |
| 180 | - if(class_exists($class)){ |
|
| 180 | + if (class_exists($class)) { |
|
| 181 | 181 | $monitor = new $class($name, $monitorId, $metadata, $store); |
| 182 | 182 | } |
| 183 | - }else{ |
|
| 183 | + } else { |
|
| 184 | 184 | $monitor = new Monitor($name, $monitorId, $metadata, $store); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | public function save() { |
| 197 | 197 | |
| 198 | 198 | // Session tracker always saves. |
| 199 | - if ( isset($this->monitors['tracker_sessions']) ) { |
|
| 199 | + if (isset($this->monitors['tracker_sessions'])) { |
|
| 200 | 200 | $this->monitors['tracker_sessions']->save(); |
| 201 | 201 | unset($this->monitors['tracker_sessions']); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if(!$this->isPaused()){ |
|
| 205 | - foreach($this->monitors as $monitor) { |
|
| 206 | - if(array_key_exists('Trackable', class_implements($monitor))) { |
|
| 204 | + if (!$this->isPaused()) { |
|
| 205 | + foreach ($this->monitors as $monitor) { |
|
| 206 | + if (array_key_exists('Trackable', class_implements($monitor))) { |
|
| 207 | 207 | $monitor->save(); |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | * Saves the monitor instance and then clears it |
| 216 | 216 | * If ignoreDisabled is set the ignore the fact of this monitor being disabled |
| 217 | 217 | */ |
| 218 | -public function saveMonitor($monitor, $flush=true, $ignoreDisabled = false) { |
|
| 218 | +public function saveMonitor($monitor, $flush = true, $ignoreDisabled = false) { |
|
| 219 | 219 | |
| 220 | - if(!$this->isPaused() && !empty($monitor)){ |
|
| 220 | + if (!$this->isPaused() && !empty($monitor)) { |
|
| 221 | 221 | |
| 222 | - if((empty($this->disabledMonitors[$monitor->name]) || $ignoreDisabled) && array_key_exists('Trackable', class_implements($monitor))) { |
|
| 222 | + if ((empty($this->disabledMonitors[$monitor->name]) || $ignoreDisabled) && array_key_exists('Trackable', class_implements($monitor))) { |
|
| 223 | 223 | |
| 224 | 224 | $monitor->save($flush); |
| 225 | 225 | |
| 226 | - if($flush) { |
|
| 226 | + if ($flush) { |
|
| 227 | 227 | $monitor->clear(); |
| 228 | 228 | unset($this->monitors[strtolower($monitor->name)]); |
| 229 | 229 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | * Method to unset the monitor so that it will not be saved |
| 237 | 237 | */ |
| 238 | 238 | public function unsetMonitor($monitor) { |
| 239 | - if(!empty($monitor)) { |
|
| 239 | + if (!empty($monitor)) { |
|
| 240 | 240 | unset($this->monitors[strtolower($monitor->name)]); |
| 241 | 241 | } |
| 242 | 242 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * Usage: TrackerManager::getInstance()->pauseTracking(); |
| 250 | 250 | */ |
| 251 | -public function pause(){ |
|
| 251 | +public function pause() { |
|
| 252 | 252 | self::$paused = true; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * * Usage: TrackerManager::getInstance()->unPauseTracking(); |
| 261 | 261 | */ |
| 262 | -public function unPause(){ |
|
| 262 | +public function unPause() { |
|
| 263 | 263 | self::$paused = false; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | public function unsetMonitors() { |
| 305 | 305 | $mons = $this->monitors; |
| 306 | - foreach($mons as $key=>$m) { |
|
| 306 | + foreach ($mons as $key=>$m) { |
|
| 307 | 307 | $this->unsetMonitor($m); |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -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. |
@@ -68,8 +70,7 @@ discard block |
||
| 68 | 70 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 69 | 71 | if(isset($GLOBALS['log'])) { |
| 70 | 72 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 71 | - } |
|
| 72 | - else { |
|
| 73 | + } else { |
|
| 73 | 74 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 74 | 75 | } |
| 75 | 76 | self::__construct(); |
@@ -135,7 +136,9 @@ discard block |
||
| 135 | 136 | */ |
| 136 | 137 | public function getMonitor($name) { |
| 137 | 138 | //don't waste our time on disabled monitors |
| 138 | - if($name!='tracker_sessions' && !empty($this->disabledMonitors[$name]))return false; |
|
| 139 | + if($name!='tracker_sessions' && !empty($this->disabledMonitors[$name])) { |
|
| 140 | + return false; |
|
| 141 | + } |
|
| 139 | 142 | if(isset($this->monitors[$name])) { |
| 140 | 143 | return $this->monitors[$name]; |
| 141 | 144 | } |
@@ -175,12 +178,12 @@ discard block |
||
| 175 | 178 | if(class_exists($class)){ |
| 176 | 179 | $monitor = new $class($name, $monitorId, $metadata, $store); |
| 177 | 180 | } |
| 178 | - }elseif(file_exists('modules/Trackers/monitor/'.$class.'.php')){ |
|
| 181 | + } elseif(file_exists('modules/Trackers/monitor/'.$class.'.php')){ |
|
| 179 | 182 | require_once('modules/Trackers/monitor/'.$class.'.php'); |
| 180 | 183 | if(class_exists($class)){ |
| 181 | 184 | $monitor = new $class($name, $monitorId, $metadata, $store); |
| 182 | 185 | } |
| 183 | - }else{ |
|
| 186 | + } else{ |
|
| 184 | 187 | $monitor = new Monitor($name, $monitorId, $metadata, $store); |
| 185 | 188 | } |
| 186 | 189 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | |
| 42 | -if(!class_exists('Tracker')){ |
|
| 42 | +if (!class_exists('Tracker')) { |
|
| 43 | 43 | |
| 44 | 44 | require_once 'data/SugarBean.php'; |
| 45 | 45 | |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | function __construct() |
| 69 | 69 | { |
| 70 | 70 | global $dictionary; |
| 71 | - if(isset($this->module_dir) && isset($this->object_name) && !isset($GLOBALS['dictionary'][$this->object_name])){ |
|
| 71 | + if (isset($this->module_dir) && isset($this->object_name) && !isset($GLOBALS['dictionary'][$this->object_name])) { |
|
| 72 | 72 | $path = 'modules/Trackers/vardefs.php'; |
| 73 | - if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 73 | + if (defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 74 | 74 | require_once($path); |
| 75 | 75 | } |
| 76 | 76 | parent::__construct(); |
@@ -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 | - public function Tracker(){ |
|
| 82 | + public function Tracker() { |
|
| 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,25 +100,25 @@ discard block |
||
| 100 | 100 | function get_recently_viewed($user_id, $modules = '') |
| 101 | 101 | { |
| 102 | 102 | $path = 'modules/Trackers/BreadCrumbStack.php'; |
| 103 | - if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 103 | + if (defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 104 | 104 | require_once($path); |
| 105 | - if(empty($_SESSION['breadCrumbs'])) { |
|
| 105 | + if (empty($_SESSION['breadCrumbs'])) { |
|
| 106 | 106 | $breadCrumb = new BreadCrumbStack($user_id, $modules); |
| 107 | 107 | $_SESSION['breadCrumbs'] = $breadCrumb; |
| 108 | 108 | $GLOBALS['log']->info(string_format($GLOBALS['app_strings']['LBL_BREADCRUMBSTACK_CREATED'], array($user_id))); |
| 109 | 109 | } else { |
| 110 | 110 | $breadCrumb = $_SESSION['breadCrumbs']; |
| 111 | 111 | $module_query = ''; |
| 112 | - if(!empty($modules)) { |
|
| 112 | + if (!empty($modules)) { |
|
| 113 | 113 | $history_max_viewed = 10; |
| 114 | - $module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','" , $modules) . '\')' : ' AND module_name = \'' . $modules . '\''; |
|
| 114 | + $module_query = is_array($modules) ? ' AND module_name IN (\''.implode("','", $modules).'\')' : ' AND module_name = \''.$modules.'\''; |
|
| 115 | 115 | } else { |
| 116 | - $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 116 | + $history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed'])) ? $GLOBALS['sugar_config']['history_max_viewed'] : 50; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $query = 'SELECT item_id, item_summary, module_name, id FROM ' . $this->table_name . ' WHERE id = (SELECT MAX(id) as id FROM ' . $this->table_name . ' WHERE user_id = \'' . $user_id . '\' AND deleted = 0 AND visible = 1' . $module_query . ')'; |
|
| 120 | - $result = $this->db->limitQuery($query,0,$history_max_viewed,true,$query); |
|
| 121 | - while(($row = $this->db->fetchByAssoc($result))) { |
|
| 119 | + $query = 'SELECT item_id, item_summary, module_name, id FROM '.$this->table_name.' WHERE id = (SELECT MAX(id) as id FROM '.$this->table_name.' WHERE user_id = \''.$user_id.'\' AND deleted = 0 AND visible = 1'.$module_query.')'; |
|
| 120 | + $result = $this->db->limitQuery($query, 0, $history_max_viewed, true, $query); |
|
| 121 | + while (($row = $this->db->fetchByAssoc($result))) { |
|
| 122 | 122 | $breadCrumb->push($row); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -133,20 +133,20 @@ discard block |
||
| 133 | 133 | $query = "UPDATE $this->table_name SET visible = 0 WHERE item_id = '$item_id' AND visible = 1"; |
| 134 | 134 | $this->db->query($query, true); |
| 135 | 135 | $path = 'modules/Trackers/BreadCrumbStack.php'; |
| 136 | - if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 136 | + if (defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 137 | 137 | require_once($path); |
| 138 | - if(!empty($_SESSION['breadCrumbs'])){ |
|
| 138 | + if (!empty($_SESSION['breadCrumbs'])) { |
|
| 139 | 139 | $breadCrumbs = $_SESSION['breadCrumbs']; |
| 140 | 140 | $breadCrumbs->popItem($item_id); |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - static function logPage(){ |
|
| 144 | + static function logPage() { |
|
| 145 | 145 | $time_on_last_page = 0; |
| 146 | 146 | //no need to calculate it if it is a redirection page |
| 147 | - if(empty($GLOBALS['app']->headerDisplayed ))return; |
|
| 148 | - if(!empty($_SESSION['lpage']))$time_on_last_page = time() - $_SESSION['lpage']; |
|
| 149 | - $_SESSION['lpage']=time(); |
|
| 147 | + if (empty($GLOBALS['app']->headerDisplayed))return; |
|
| 148 | + if (!empty($_SESSION['lpage']))$time_on_last_page = time() - $_SESSION['lpage']; |
|
| 149 | + $_SESSION['lpage'] = time(); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * bean_implements |
| 155 | 155 | * Override method to support ACL roles |
| 156 | 156 | */ |
| 157 | - function bean_implements($interface){ |
|
| 157 | + function bean_implements($interface) { |
|
| 158 | 158 | return false; |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -70,7 +70,9 @@ discard block |
||
| 70 | 70 | global $dictionary; |
| 71 | 71 | if(isset($this->module_dir) && isset($this->object_name) && !isset($GLOBALS['dictionary'][$this->object_name])){ |
| 72 | 72 | $path = 'modules/Trackers/vardefs.php'; |
| 73 | - if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 73 | + if(defined('TEMPLATE_URL')) { |
|
| 74 | + $path = SugarTemplateUtilities::getFilePath($path); |
|
| 75 | + } |
|
| 74 | 76 | require_once($path); |
| 75 | 77 | } |
| 76 | 78 | parent::__construct(); |
@@ -83,8 +85,7 @@ discard block |
||
| 83 | 85 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 84 | 86 | if(isset($GLOBALS['log'])) { |
| 85 | 87 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 86 | - } |
|
| 87 | - else { |
|
| 88 | + } else { |
|
| 88 | 89 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 89 | 90 | } |
| 90 | 91 | self::__construct(); |
@@ -100,7 +101,9 @@ discard block |
||
| 100 | 101 | function get_recently_viewed($user_id, $modules = '') |
| 101 | 102 | { |
| 102 | 103 | $path = 'modules/Trackers/BreadCrumbStack.php'; |
| 103 | - if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 104 | + if(defined('TEMPLATE_URL')) { |
|
| 105 | + $path = SugarTemplateUtilities::getFilePath($path); |
|
| 106 | + } |
|
| 104 | 107 | require_once($path); |
| 105 | 108 | if(empty($_SESSION['breadCrumbs'])) { |
| 106 | 109 | $breadCrumb = new BreadCrumbStack($user_id, $modules); |
@@ -133,7 +136,9 @@ discard block |
||
| 133 | 136 | $query = "UPDATE $this->table_name SET visible = 0 WHERE item_id = '$item_id' AND visible = 1"; |
| 134 | 137 | $this->db->query($query, true); |
| 135 | 138 | $path = 'modules/Trackers/BreadCrumbStack.php'; |
| 136 | - if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path); |
|
| 139 | + if(defined('TEMPLATE_URL')) { |
|
| 140 | + $path = SugarTemplateUtilities::getFilePath($path); |
|
| 141 | + } |
|
| 137 | 142 | require_once($path); |
| 138 | 143 | if(!empty($_SESSION['breadCrumbs'])){ |
| 139 | 144 | $breadCrumbs = $_SESSION['breadCrumbs']; |
@@ -144,8 +149,12 @@ discard block |
||
| 144 | 149 | static function logPage(){ |
| 145 | 150 | $time_on_last_page = 0; |
| 146 | 151 | //no need to calculate it if it is a redirection page |
| 147 | - if(empty($GLOBALS['app']->headerDisplayed ))return; |
|
| 148 | - if(!empty($_SESSION['lpage']))$time_on_last_page = time() - $_SESSION['lpage']; |
|
| 152 | + if(empty($GLOBALS['app']->headerDisplayed )) { |
|
| 153 | + return; |
|
| 154 | + } |
|
| 155 | + if(!empty($_SESSION['lpage'])) { |
|
| 156 | + $time_on_last_page = time() - $_SESSION['lpage']; |
|
| 157 | + } |
|
| 149 | 158 | $_SESSION['lpage']=time(); |
| 150 | 159 | } |
| 151 | 160 | |
@@ -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-2012 SugarCRM Inc. |
@@ -59,16 +59,16 @@ discard block |
||
| 59 | 59 | var $assigned_user_name; |
| 60 | 60 | var $assigned_user_link; |
| 61 | 61 | |
| 62 | - function __construct(){ |
|
| 62 | + function __construct() { |
|
| 63 | 63 | parent::__construct(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * @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 |
| 68 | 68 | */ |
| 69 | - function SugarFeed(){ |
|
| 69 | + function SugarFeed() { |
|
| 70 | 70 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 71 | - if(isset($GLOBALS['log'])) { |
|
| 71 | + if (isset($GLOBALS['log'])) { |
|
| 72 | 72 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 73 | 73 | } |
| 74 | 74 | else { |
@@ -78,78 +78,78 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | |
| 81 | - static function activateModuleFeed( $module, $updateDB = true ) { |
|
| 82 | - if ( $module != 'UserFeed' ) { |
|
| 81 | + static function activateModuleFeed($module, $updateDB = true) { |
|
| 82 | + if ($module != 'UserFeed') { |
|
| 83 | 83 | // UserFeed is a fake module, used for the user postings to the feed |
| 84 | 84 | // Don't try to load up any classes for it |
| 85 | 85 | $fileList = SugarFeed::getModuleFeedFiles($module); |
| 86 | 86 | |
| 87 | - foreach ( $fileList as $fileName ) { |
|
| 88 | - $feedClass = substr(basename($fileName),0,-4); |
|
| 87 | + foreach ($fileList as $fileName) { |
|
| 88 | + $feedClass = substr(basename($fileName), 0, -4); |
|
| 89 | 89 | |
| 90 | 90 | require_once($fileName); |
| 91 | 91 | $tmpClass = new $feedClass(); |
| 92 | - $tmpClass->installHook($fileName,$feedClass); |
|
| 92 | + $tmpClass->installHook($fileName, $feedClass); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | - if ( $updateDB == true ) { |
|
| 95 | + if ($updateDB == true) { |
|
| 96 | 96 | |
| 97 | 97 | $admin = new Administration(); |
| 98 | - $admin->saveSetting('sugarfeed','module_'.$admin->db->quote($module),'1'); |
|
| 98 | + $admin->saveSetting('sugarfeed', 'module_'.$admin->db->quote($module), '1'); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - static function disableModuleFeed( $module, $updateDB = true ) { |
|
| 103 | - if ( $module != 'UserFeed' ) { |
|
| 102 | + static function disableModuleFeed($module, $updateDB = true) { |
|
| 103 | + if ($module != 'UserFeed') { |
|
| 104 | 104 | // UserFeed is a fake module, used for the user postings to the feed |
| 105 | 105 | // Don't try to load up any classes for it |
| 106 | 106 | $fileList = SugarFeed::getModuleFeedFiles($module); |
| 107 | 107 | |
| 108 | - foreach ( $fileList as $fileName ) { |
|
| 109 | - $feedClass = substr(basename($fileName),0,-4); |
|
| 108 | + foreach ($fileList as $fileName) { |
|
| 109 | + $feedClass = substr(basename($fileName), 0, -4); |
|
| 110 | 110 | |
| 111 | 111 | require_once($fileName); |
| 112 | 112 | $tmpClass = new $feedClass(); |
| 113 | - $tmpClass->removeHook($fileName,$feedClass); |
|
| 113 | + $tmpClass->removeHook($fileName, $feedClass); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $updateDB == true ) { |
|
| 117 | + if ($updateDB == true) { |
|
| 118 | 118 | |
| 119 | 119 | $admin = new Administration(); |
| 120 | - $admin->saveSetting('sugarfeed','module_'.$admin->db->quote($module),'0'); |
|
| 120 | + $admin->saveSetting('sugarfeed', 'module_'.$admin->db->quote($module), '0'); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | static function flushBackendCache( ) { |
| 125 | 125 | // This function will flush the cache files used for the module list and the link type lists |
| 126 | 126 | sugar_cache_clear('SugarFeedModules'); |
| 127 | - if ( file_exists($cachefile = sugar_cached('modules/SugarFeed/moduleCache.php'))) { |
|
| 127 | + if (file_exists($cachefile = sugar_cached('modules/SugarFeed/moduleCache.php'))) { |
|
| 128 | 128 | unlink($cachefile); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | sugar_cache_clear('SugarFeedLinkType'); |
| 132 | - if ( file_exists($cachefile = sugar_cached('modules/SugarFeed/linkTypeCache.php'))) { |
|
| 132 | + if (file_exists($cachefile = sugar_cached('modules/SugarFeed/linkTypeCache.php'))) { |
|
| 133 | 133 | unlink($cachefile); |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
| 138 | - static function getModuleFeedFiles( $module ) { |
|
| 138 | + static function getModuleFeedFiles($module) { |
|
| 139 | 139 | $baseDirList = array('modules/'.$module.'/SugarFeeds/', 'custom/modules/'.$module.'/SugarFeeds/'); |
| 140 | 140 | |
| 141 | 141 | // We store the files in a list sorted by the filename so you can override a default feed by |
| 142 | 142 | // putting your replacement feed in the custom directory with the same filename |
| 143 | 143 | $fileList = array(); |
| 144 | 144 | |
| 145 | - foreach ( $baseDirList as $baseDir ) { |
|
| 146 | - if ( ! file_exists($baseDir) ) { |
|
| 145 | + foreach ($baseDirList as $baseDir) { |
|
| 146 | + if (!file_exists($baseDir)) { |
|
| 147 | 147 | continue; |
| 148 | 148 | } |
| 149 | 149 | $d = dir($baseDir); |
| 150 | - while ( $file = $d->read() ) { |
|
| 151 | - if ( $file{0} == '.' ) { continue; } |
|
| 152 | - if ( substr($file,-4) == '.php' ) { |
|
| 150 | + while ($file = $d->read()) { |
|
| 151 | + if ($file{0} == '.') { continue; } |
|
| 152 | + if (substr($file, -4) == '.php') { |
|
| 153 | 153 | // We found one |
| 154 | 154 | $fileList[$file] = $baseDir.$file; |
| 155 | 155 | } |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | static function getActiveFeedModules( ) { |
| 163 | 163 | // Stored in a cache somewhere |
| 164 | 164 | $feedModules = sugar_cache_retrieve('SugarFeedModules'); |
| 165 | - if ( $feedModules != null ) { |
|
| 165 | + if ($feedModules != null) { |
|
| 166 | 166 | return($feedModules); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Already stored in a file |
| 170 | - if ( file_exists($cachefile = sugar_cached('modules/SugarFeed/moduleCache.php'))) { |
|
| 170 | + if (file_exists($cachefile = sugar_cached('modules/SugarFeed/moduleCache.php'))) { |
|
| 171 | 171 | require_once($cachefile); |
| 172 | - sugar_cache_put('SugarFeedModules',$feedModules); |
|
| 172 | + sugar_cache_put('SugarFeedModules', $feedModules); |
|
| 173 | 173 | return $feedModules; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | $admin->retrieveSettings(); |
| 180 | 180 | |
| 181 | 181 | $feedModules = array(); |
| 182 | - if ( isset($admin->settings['sugarfeed_enabled']) && $admin->settings['sugarfeed_enabled'] == '1' ) { |
|
| 182 | + if (isset($admin->settings['sugarfeed_enabled']) && $admin->settings['sugarfeed_enabled'] == '1') { |
|
| 183 | 183 | // Only enable modules if the feed system is enabled |
| 184 | - foreach ( $admin->settings as $key => $value ) { |
|
| 185 | - if ( strncmp($key,'sugarfeed_module_',17) === 0 ) { |
|
| 184 | + foreach ($admin->settings as $key => $value) { |
|
| 185 | + if (strncmp($key, 'sugarfeed_module_', 17) === 0) { |
|
| 186 | 186 | // It's a module setting |
| 187 | - if ( $value == '1' ) { |
|
| 188 | - $moduleName = substr($key,17); |
|
| 187 | + if ($value == '1') { |
|
| 188 | + $moduleName = substr($key, 17); |
|
| 189 | 189 | $feedModules[$moduleName] = $moduleName; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
| 196 | - sugar_cache_put('SugarFeedModules',$feedModules); |
|
| 197 | - if ( ! file_exists($cachedir = sugar_cached('modules/SugarFeed'))) { |
|
| 196 | + sugar_cache_put('SugarFeedModules', $feedModules); |
|
| 197 | + if (!file_exists($cachedir = sugar_cached('modules/SugarFeed'))) { |
|
| 198 | 198 | mkdir_recursive($cachedir); |
| 199 | 199 | } |
| 200 | - $fd = fopen("$cachedir/moduleCache.php",'w'); |
|
| 201 | - fwrite($fd,'<'."?php\n\n".'$feedModules = '.var_export($feedModules,true).';'); |
|
| 200 | + $fd = fopen("$cachedir/moduleCache.php", 'w'); |
|
| 201 | + fwrite($fd, '<'."?php\n\n".'$feedModules = '.var_export($feedModules, true).';'); |
|
| 202 | 202 | fclose($fd); |
| 203 | 203 | |
| 204 | 204 | return $feedModules; |
@@ -209,17 +209,17 @@ discard block |
||
| 209 | 209 | $feedModules = array('UserFeed'=>'UserFeed'); |
| 210 | 210 | |
| 211 | 211 | $baseDirList = array('modules/', 'custom/modules/'); |
| 212 | - foreach ( $baseDirList as $baseDir ) { |
|
| 213 | - if ( ! file_exists($baseDir) ) { |
|
| 212 | + foreach ($baseDirList as $baseDir) { |
|
| 213 | + if (!file_exists($baseDir)) { |
|
| 214 | 214 | continue; |
| 215 | 215 | } |
| 216 | 216 | $d = dir($baseDir); |
| 217 | - while ( $module = $d->read() ) { |
|
| 218 | - if ( file_exists($baseDir.$module.'/SugarFeeds/') ) { |
|
| 217 | + while ($module = $d->read()) { |
|
| 218 | + if (file_exists($baseDir.$module.'/SugarFeeds/')) { |
|
| 219 | 219 | $dFeed = dir($baseDir.$module.'/SugarFeeds/'); |
| 220 | - while ( $file = $dFeed->read() ) { |
|
| 221 | - if ( $file{0} == '.' ) { continue; } |
|
| 222 | - if ( substr($file,-4) == '.php' ) { |
|
| 220 | + while ($file = $dFeed->read()) { |
|
| 221 | + if ($file{0} == '.') { continue; } |
|
| 222 | + if (substr($file, -4) == '.php') { |
|
| 223 | 223 | // We found one |
| 224 | 224 | $feedModules[$module] = $module; |
| 225 | 225 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @param $link_type boolean value indicating whether or not feed is a link type |
| 241 | 241 | * @param $link_url String value of the URL (for link types only) |
| 242 | 242 | */ |
| 243 | - static function pushFeed2($text, $bean, $link_type=false, $link_url=false) { |
|
| 243 | + static function pushFeed2($text, $bean, $link_type = false, $link_url = false) { |
|
| 244 | 244 | self::pushFeed($text, $bean->module_dir, $bean->id |
| 245 | 245 | ,$bean->assigned_user_id |
| 246 | 246 | ,$link_type |
@@ -249,31 +249,31 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | static function pushFeed($text, $module, $id, |
| 252 | - $record_assigned_user_id=false, |
|
| 253 | - $link_type=false, |
|
| 254 | - $link_url=false |
|
| 252 | + $record_assigned_user_id = false, |
|
| 253 | + $link_type = false, |
|
| 254 | + $link_url = false |
|
| 255 | 255 | ) { |
| 256 | 256 | $feed = new SugarFeed(); |
| 257 | - if((empty($text) && empty($link_url)) || !$feed->ACLAccess('save', true) ) |
|
| 257 | + if ((empty($text) && empty($link_url)) || !$feed->ACLAccess('save', true)) |
|
| 258 | 258 | { |
| 259 | 259 | $GLOBALS['log']->error('Unable to save SugarFeed record (missing data or no ACL access)'); |
| 260 | 260 | return; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if(!empty($link_url)){ |
|
| 263 | + if (!empty($link_url)) { |
|
| 264 | 264 | $linkClass = SugarFeed::getLinkClass($link_type); |
| 265 | - if ( $linkClass !== FALSE ) { |
|
| 266 | - $linkClass->handleInput($feed,$link_type,$link_url); |
|
| 265 | + if ($linkClass !== FALSE) { |
|
| 266 | + $linkClass->handleInput($feed, $link_type, $link_url); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | $text = strip_tags(from_html($text)); |
| 270 | - $text = '<b>{this.CREATED_BY}</b> ' . $text; |
|
| 270 | + $text = '<b>{this.CREATED_BY}</b> '.$text; |
|
| 271 | 271 | $feed->name = substr($text, 0, 255); |
| 272 | - if(strlen($text) > 255){ |
|
| 272 | + if (strlen($text) > 255) { |
|
| 273 | 273 | $feed->description = substr($text, 255, 510); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if ( $record_assigned_user_id === false ) { |
|
| 276 | + if ($record_assigned_user_id === false) { |
|
| 277 | 277 | $feed->assigned_user_id = $GLOBALS['current_user']->id; |
| 278 | 278 | } else { |
| 279 | 279 | $feed->assigned_user_id = $record_assigned_user_id; |
@@ -287,62 +287,62 @@ discard block |
||
| 287 | 287 | static $linkTypeList = null; |
| 288 | 288 | |
| 289 | 289 | // Fastest, already stored in the static variable |
| 290 | - if ( $linkTypeList != null ) { |
|
| 290 | + if ($linkTypeList != null) { |
|
| 291 | 291 | return $linkTypeList; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // Second fastest, stored in a cache somewhere |
| 295 | 295 | $linkTypeList = sugar_cache_retrieve('SugarFeedLinkType'); |
| 296 | - if ( $linkTypeList != null ) { |
|
| 296 | + if ($linkTypeList != null) { |
|
| 297 | 297 | return($linkTypeList); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // Third fastest, already stored in a file |
| 301 | - if ( file_exists($cachedfile = sugar_cached('modules/SugarFeed/linkTypeCache.php'))) { |
|
| 301 | + if (file_exists($cachedfile = sugar_cached('modules/SugarFeed/linkTypeCache.php'))) { |
|
| 302 | 302 | require_once($cachedfile); |
| 303 | - sugar_cache_put('SugarFeedLinkType',$linkTypeList); |
|
| 303 | + sugar_cache_put('SugarFeedLinkType', $linkTypeList); |
|
| 304 | 304 | return $linkTypeList; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // Slow, have to actually collect the data |
| 308 | - $baseDirs = array('custom/modules/SugarFeed/linkHandlers/','modules/SugarFeed/linkHandlers'); |
|
| 308 | + $baseDirs = array('custom/modules/SugarFeed/linkHandlers/', 'modules/SugarFeed/linkHandlers'); |
|
| 309 | 309 | |
| 310 | 310 | $linkTypeList = array(); |
| 311 | 311 | |
| 312 | - foreach ( $baseDirs as $dirName ) { |
|
| 313 | - if ( !file_exists($dirName) ) { continue; } |
|
| 312 | + foreach ($baseDirs as $dirName) { |
|
| 313 | + if (!file_exists($dirName)) { continue; } |
|
| 314 | 314 | $d = dir($dirName); |
| 315 | - while ( $file = $d->read() ) { |
|
| 316 | - if ( $file{0} == '.' ) { continue; } |
|
| 317 | - if ( substr($file,-4) == '.php' ) { |
|
| 315 | + while ($file = $d->read()) { |
|
| 316 | + if ($file{0} == '.') { continue; } |
|
| 317 | + if (substr($file, -4) == '.php') { |
|
| 318 | 318 | // We found one |
| 319 | - $typeName = substr($file,0,-4); |
|
| 319 | + $typeName = substr($file, 0, -4); |
|
| 320 | 320 | $linkTypeList[$typeName] = $typeName; |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - sugar_cache_put('SugarFeedLinkType',$linkTypeList); |
|
| 326 | - if ( ! file_exists($cachedir = sugar_cached('modules/SugarFeed')) ) { |
|
| 325 | + sugar_cache_put('SugarFeedLinkType', $linkTypeList); |
|
| 326 | + if (!file_exists($cachedir = sugar_cached('modules/SugarFeed'))) { |
|
| 327 | 327 | mkdir_recursive($cachedir); |
| 328 | 328 | } |
| 329 | - $fd = fopen("$cachedir/linkTypeCache.php",'w'); |
|
| 330 | - fwrite($fd,'<'."?php\n\n".'$linkTypeList = '.var_export($linkTypeList,true).';'); |
|
| 329 | + $fd = fopen("$cachedir/linkTypeCache.php", 'w'); |
|
| 330 | + fwrite($fd, '<'."?php\n\n".'$linkTypeList = '.var_export($linkTypeList, true).';'); |
|
| 331 | 331 | fclose($fd); |
| 332 | 332 | |
| 333 | 333 | return $linkTypeList; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - static function getLinkClass( $linkName ) { |
|
| 336 | + static function getLinkClass($linkName) { |
|
| 337 | 337 | $linkTypeList = SugarFeed::getLinkTypes(); |
| 338 | 338 | |
| 339 | 339 | // Have to make sure the linkName is on the list, so they can't pass in linkName's like ../../config.php ... not that they could get anywhere if they did |
| 340 | - if ( ! isset($linkTypeList[$linkName]) ) { |
|
| 340 | + if (!isset($linkTypeList[$linkName])) { |
|
| 341 | 341 | // No class by this name... |
| 342 | 342 | return FALSE; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - if ( file_exists('custom/modules/SugarFeed/linkHandlers/'.$linkName.'.php') ) { |
|
| 345 | + if (file_exists('custom/modules/SugarFeed/linkHandlers/'.$linkName.'.php')) { |
|
| 346 | 346 | require_once('custom/modules/SugarFeed/linkHandlers/'.$linkName.'.php'); |
| 347 | 347 | } else { |
| 348 | 348 | require_once('modules/SugarFeed/linkHandlers/'.$linkName.'.php'); |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | return($linkClass); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - function get_list_view_data(){ |
|
| 358 | + function get_list_view_data() { |
|
| 359 | 359 | $data = parent::get_list_view_data(); |
| 360 | 360 | $delete = ''; |
| 361 | 361 | /* BEGIN - SECURITY GROUPS */ |
@@ -365,63 +365,63 @@ discard block |
||
| 365 | 365 | if (ACLController::moduleSupportsACL($data['RELATED_MODULE'])) { |
| 366 | 366 | $in_group = 'not_set'; |
| 367 | 367 | require_once("modules/SecurityGroups/SecurityGroup.php"); |
| 368 | - $in_group = SecurityGroup::groupHasAccess($data['RELATED_MODULE'],$data['RELATED_ID'],'list'); |
|
| 369 | - if( |
|
| 370 | - !ACLController::checkAccess($data['RELATED_MODULE'], 'view', $data['CREATED_BY'] == $GLOBALS['current_user']->id,'module', $in_group) |
|
| 371 | - && !ACLController::checkAccess($data['RELATED_MODULE'], 'list', $data['CREATED_BY'] == $GLOBALS['current_user']->id,'module', $in_group) |
|
| 368 | + $in_group = SecurityGroup::groupHasAccess($data['RELATED_MODULE'], $data['RELATED_ID'], 'list'); |
|
| 369 | + if ( |
|
| 370 | + !ACLController::checkAccess($data['RELATED_MODULE'], 'view', $data['CREATED_BY'] == $GLOBALS['current_user']->id, 'module', $in_group) |
|
| 371 | + && !ACLController::checkAccess($data['RELATED_MODULE'], 'list', $data['CREATED_BY'] == $GLOBALS['current_user']->id, 'module', $in_group) |
|
| 372 | 372 | |
| 373 | - ){ |
|
| 373 | + ) { |
|
| 374 | 374 | $data['NAME'] = ''; |
| 375 | 375 | return $data; |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | - if(is_admin($GLOBALS['current_user']) || (isset($data['CREATED_BY']) && $data['CREATED_BY'] == $GLOBALS['current_user']->id) ) { |
|
| 379 | - $delete = ' - <a id="sugarFeedDeleteLink'.$data['ID'].'" href="#" onclick=\'SugarFeed.deleteFeed("'. $data['ID'] . '", "{this.id}"); return false;\'>'. $GLOBALS['app_strings']['LBL_DELETE_BUTTON_LABEL'].'</a>'; |
|
| 378 | + if (is_admin($GLOBALS['current_user']) || (isset($data['CREATED_BY']) && $data['CREATED_BY'] == $GLOBALS['current_user']->id)) { |
|
| 379 | + $delete = ' - <a id="sugarFeedDeleteLink'.$data['ID'].'" href="#" onclick=\'SugarFeed.deleteFeed("'.$data['ID'].'", "{this.id}"); return false;\'>'.$GLOBALS['app_strings']['LBL_DELETE_BUTTON_LABEL'].'</a>'; |
|
| 380 | 380 | } |
| 381 | 381 | /* END - SECURITY GROUPS */ |
| 382 | 382 | $data['NAME'] .= $data['DESCRIPTION']; |
| 383 | - $data['NAME'] = '<div style="padding:3px">' . html_entity_decode($data['NAME']); |
|
| 384 | - if(!empty($data['LINK_URL'])){ |
|
| 383 | + $data['NAME'] = '<div style="padding:3px">'.html_entity_decode($data['NAME']); |
|
| 384 | + if (!empty($data['LINK_URL'])) { |
|
| 385 | 385 | $linkClass = SugarFeed::getLinkClass($data['LINK_TYPE']); |
| 386 | - if ( $linkClass !== FALSE ) { |
|
| 386 | + if ($linkClass !== FALSE) { |
|
| 387 | 387 | $data['NAME'] .= $linkClass->getDisplay($data); |
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | $data['NAME'] .= '<div class="byLineBox"><span class="byLineLeft">'; |
| 391 | - $data['NAME'] .= $this->getTimeLapse($data['DATE_ENTERED']) . ' </span><div class="byLineRight"><a id="sugarFeedReplyLink'.$data['ID'].'" href="#" onclick=\'SugarFeed.buildReplyForm("'.$data['ID'].'", "{this.id}", this); return false;\'>'.$GLOBALS['app_strings']['LBL_EMAIL_REPLY'].'</a>' .$delete. '</div></div>'; |
|
| 391 | + $data['NAME'] .= $this->getTimeLapse($data['DATE_ENTERED']).' </span><div class="byLineRight"><a id="sugarFeedReplyLink'.$data['ID'].'" href="#" onclick=\'SugarFeed.buildReplyForm("'.$data['ID'].'", "{this.id}", this); return false;\'>'.$GLOBALS['app_strings']['LBL_EMAIL_REPLY'].'</a>'.$delete.'</div></div>'; |
|
| 392 | 392 | |
| 393 | 393 | $data['NAME'] .= $this->fetchReplies($data); |
| 394 | - return $data ; |
|
| 394 | + return $data; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | function fetchReplies($data) { |
| 398 | 398 | $seedBean = new SugarFeed; |
| 399 | 399 | |
| 400 | - $replies = $seedBean->get_list('date_entered',"related_module = 'SugarFeed' AND related_id = '".$data['ID']."'"); |
|
| 400 | + $replies = $seedBean->get_list('date_entered', "related_module = 'SugarFeed' AND related_id = '".$data['ID']."'"); |
|
| 401 | 401 | |
| 402 | - if ( count($replies['list']) < 1 ) { |
|
| 402 | + if (count($replies['list']) < 1) { |
|
| 403 | 403 | return ''; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | |
| 407 | 407 | $replyHTML = '<div class="clear"></div><blockquote>'; |
| 408 | 408 | |
| 409 | - foreach ( $replies['list'] as $reply ) { |
|
| 409 | + foreach ($replies['list'] as $reply) { |
|
| 410 | 410 | // Setup the delete link |
| 411 | 411 | $delete = ''; |
| 412 | - if(is_admin($GLOBALS['current_user']) || $data['CREATED_BY'] == $GLOBALS['current_user']->id) { |
|
| 413 | - $delete = '<a id="sugarFieldDeleteLink'.$reply->id.'" href="#" onclick=\'SugarFeed.deleteFeed("'. $reply->id . '", "{this.id}"); return false;\'>'. $GLOBALS['app_strings']['LBL_DELETE_BUTTON_LABEL'].'</a>'; |
|
| 412 | + if (is_admin($GLOBALS['current_user']) || $data['CREATED_BY'] == $GLOBALS['current_user']->id) { |
|
| 413 | + $delete = '<a id="sugarFieldDeleteLink'.$reply->id.'" href="#" onclick=\'SugarFeed.deleteFeed("'.$reply->id.'", "{this.id}"); return false;\'>'.$GLOBALS['app_strings']['LBL_DELETE_BUTTON_LABEL'].'</a>'; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $image_url = 'include/images/default_user_feed_picture.png'; |
| 417 | - if ( isset($reply->created_by) ) { |
|
| 417 | + if (isset($reply->created_by)) { |
|
| 418 | 418 | $user = loadBean('Users'); |
| 419 | 419 | $user->retrieve($reply->created_by); |
| 420 | 420 | $image_url = 'index.php?entryPoint=download&id='.$user->picture.'&type=SugarFieldImage&isTempFile=1&isProfile=1'; |
| 421 | 421 | } |
| 422 | 422 | $replyHTML .= '<div style="float: left; margin-right: 3px; width: 50px; height: 50px;"><!--not_in_theme!--><img src="'.$image_url.'" style="max-width: 50px; max-height: 50px;"></div> '; |
| 423 | - $replyHTML .= str_replace("{this.CREATED_BY}",get_assigned_user_name($reply->created_by),html_entity_decode($reply->name)).'<br>'; |
|
| 424 | - $replyHTML .= '<div class="byLineBox"><span class="byLineLeft">'. $this->getTimeLapse($reply->date_entered) . ' </span><div class="byLineRight"> ' .$delete. '</div></div><div class="clear"></div>'; |
|
| 423 | + $replyHTML .= str_replace("{this.CREATED_BY}", get_assigned_user_name($reply->created_by), html_entity_decode($reply->name)).'<br>'; |
|
| 424 | + $replyHTML .= '<div class="byLineBox"><span class="byLineLeft">'.$this->getTimeLapse($reply->date_entered).' </span><div class="byLineRight"> '.$delete.'</div></div><div class="clear"></div>'; |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | $replyHTML .= '</blockquote>'; |
@@ -432,52 +432,52 @@ discard block |
||
| 432 | 432 | static function getTimeLapse($startDate) |
| 433 | 433 | { |
| 434 | 434 | $seconds = $GLOBALS['timedate']->getNow()->ts - $GLOBALS['timedate']->fromUser($startDate)->ts; |
| 435 | - $minutes = $seconds/60; |
|
| 435 | + $minutes = $seconds / 60; |
|
| 436 | 436 | $seconds = $seconds % 60; |
| 437 | - $hours = floor( $minutes / 60); |
|
| 437 | + $hours = floor($minutes / 60); |
|
| 438 | 438 | $minutes = $minutes % 60; |
| 439 | - $days = floor( $hours / 24); |
|
| 439 | + $days = floor($hours / 24); |
|
| 440 | 440 | $hours = $hours % 24; |
| 441 | - $weeks = floor( $days / 7); |
|
| 441 | + $weeks = floor($days / 7); |
|
| 442 | 442 | $days = $days % 7; |
| 443 | 443 | $result = ''; |
| 444 | - if($weeks == 1){ |
|
| 445 | - $result = translate('LBL_TIME_LAST_WEEK','SugarFeed').' '; |
|
| 444 | + if ($weeks == 1) { |
|
| 445 | + $result = translate('LBL_TIME_LAST_WEEK', 'SugarFeed').' '; |
|
| 446 | 446 | return $result; |
| 447 | - }else if($weeks > 1){ |
|
| 448 | - $result .= $weeks . ' '.translate('LBL_TIME_WEEKS','SugarFeed').' '; |
|
| 449 | - if($days > 0) { |
|
| 450 | - $result .= $days . ' '.translate('LBL_TIME_DAYS','SugarFeed').' '; |
|
| 447 | + } else if ($weeks > 1) { |
|
| 448 | + $result .= $weeks.' '.translate('LBL_TIME_WEEKS', 'SugarFeed').' '; |
|
| 449 | + if ($days > 0) { |
|
| 450 | + $result .= $days.' '.translate('LBL_TIME_DAYS', 'SugarFeed').' '; |
|
| 451 | 451 | } |
| 452 | - }else{ |
|
| 453 | - if($days == 1){ |
|
| 454 | - $result = translate('LBL_TIME_YESTERDAY','SugarFeed').' '; |
|
| 452 | + } else { |
|
| 453 | + if ($days == 1) { |
|
| 454 | + $result = translate('LBL_TIME_YESTERDAY', 'SugarFeed').' '; |
|
| 455 | 455 | return $result; |
| 456 | - }else if($days > 1){ |
|
| 457 | - $result .= $days . ' '. translate('LBL_TIME_DAYS','SugarFeed').' '; |
|
| 458 | - }else{ |
|
| 459 | - if($hours == 1) { |
|
| 460 | - $result .= $hours . ' '.translate('LBL_TIME_HOUR','SugarFeed').' '; |
|
| 456 | + } else if ($days > 1) { |
|
| 457 | + $result .= $days.' '.translate('LBL_TIME_DAYS', 'SugarFeed').' '; |
|
| 458 | + } else { |
|
| 459 | + if ($hours == 1) { |
|
| 460 | + $result .= $hours.' '.translate('LBL_TIME_HOUR', 'SugarFeed').' '; |
|
| 461 | 461 | } else { |
| 462 | - $result .= $hours . ' '.translate('LBL_TIME_HOURS','SugarFeed').' '; |
|
| 462 | + $result .= $hours.' '.translate('LBL_TIME_HOURS', 'SugarFeed').' '; |
|
| 463 | 463 | } |
| 464 | - if($hours < 6){ |
|
| 465 | - if($minutes == 1) { |
|
| 466 | - $result .= $minutes . ' ' . translate('LBL_TIME_MINUTE','SugarFeed'). ' '; |
|
| 464 | + if ($hours < 6) { |
|
| 465 | + if ($minutes == 1) { |
|
| 466 | + $result .= $minutes.' '.translate('LBL_TIME_MINUTE', 'SugarFeed').' '; |
|
| 467 | 467 | } else { |
| 468 | - $result .= $minutes . ' ' . translate('LBL_TIME_MINUTES','SugarFeed'). ' '; |
|
| 468 | + $result .= $minutes.' '.translate('LBL_TIME_MINUTES', 'SugarFeed').' '; |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | - if($hours == 0 && $minutes == 0) { |
|
| 472 | - if($seconds == 1 ) { |
|
| 473 | - $result = $seconds . ' ' . translate('LBL_TIME_SECOND','SugarFeed'); |
|
| 471 | + if ($hours == 0 && $minutes == 0) { |
|
| 472 | + if ($seconds == 1) { |
|
| 473 | + $result = $seconds.' '.translate('LBL_TIME_SECOND', 'SugarFeed'); |
|
| 474 | 474 | } else { |
| 475 | - $result = $seconds . ' ' . translate('LBL_TIME_SECONDS','SugarFeed'); |
|
| 475 | + $result = $seconds.' '.translate('LBL_TIME_SECONDS', 'SugarFeed'); |
|
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | - return $result . ' ' . translate('LBL_TIME_AGO','SugarFeed'); |
|
| 480 | + return $result.' '.translate('LBL_TIME_AGO', 'SugarFeed'); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -486,9 +486,9 @@ discard block |
||
| 486 | 486 | * @param $input |
| 487 | 487 | * @return void |
| 488 | 488 | */ |
| 489 | - public static function parseMessage($input){ |
|
| 489 | + public static function parseMessage($input) { |
|
| 490 | 490 | $urls = getUrls($input); |
| 491 | - foreach($urls as $url){ |
|
| 491 | + foreach ($urls as $url) { |
|
| 492 | 492 | $output = "<a href='$url' target='_blank'>".$url."</a>"; |
| 493 | 493 | $input = str_replace($url, $output, $input); |
| 494 | 494 | } |
@@ -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-2012 SugarCRM Inc. |
@@ -70,8 +72,7 @@ discard block |
||
| 70 | 72 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 71 | 73 | if(isset($GLOBALS['log'])) { |
| 72 | 74 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 73 | - } |
|
| 74 | - else { |
|
| 75 | + } else { |
|
| 75 | 76 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
| 76 | 77 | } |
| 77 | 78 | self::__construct(); |
@@ -444,18 +445,18 @@ discard block |
||
| 444 | 445 | if($weeks == 1){ |
| 445 | 446 | $result = translate('LBL_TIME_LAST_WEEK','SugarFeed').' '; |
| 446 | 447 | return $result; |
| 447 | - }else if($weeks > 1){ |
|
| 448 | + } else if($weeks > 1){ |
|
| 448 | 449 | $result .= $weeks . ' '.translate('LBL_TIME_WEEKS','SugarFeed').' '; |
| 449 | 450 | if($days > 0) { |
| 450 | 451 | $result .= $days . ' '.translate('LBL_TIME_DAYS','SugarFeed').' '; |
| 451 | 452 | } |
| 452 | - }else{ |
|
| 453 | + } else{ |
|
| 453 | 454 | if($days == 1){ |
| 454 | 455 | $result = translate('LBL_TIME_YESTERDAY','SugarFeed').' '; |
| 455 | 456 | return $result; |
| 456 | - }else if($days > 1){ |
|
| 457 | + } else if($days > 1){ |
|
| 457 | 458 | $result .= $days . ' '. translate('LBL_TIME_DAYS','SugarFeed').' '; |
| 458 | - }else{ |
|
| 459 | + } else{ |
|
| 459 | 460 | if($hours == 1) { |
| 460 | 461 | $result .= $hours . ' '.translate('LBL_TIME_HOUR','SugarFeed').' '; |
| 461 | 462 | } else { |