@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * @param $data |
|
| 50 | - * @return bool|string |
|
| 49 | + * @param string $data |
|
| 50 | + * @return string|false |
|
| 51 | 51 | */ |
| 52 | 52 | protected function findUser($data) |
| 53 | 53 | {
|
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | - * @param $key |
|
| 100 | + * @param string $key |
|
| 101 | 101 | * @param $value |
| 102 | 102 | * @return $this |
| 103 | 103 | */ |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | /** |
| 291 | 291 | * @param $id |
| 292 | 292 | * @param $password |
| 293 | - * @param $blocker |
|
| 293 | + * @param boolean $blocker |
|
| 294 | 294 | * @param null $fire_events |
| 295 | 295 | * @return bool |
| 296 | 296 | */ |
@@ -364,8 +364,9 @@ discard block |
||
| 364 | 364 | * SessionHandler |
| 365 | 365 | * Starts the user session on login success. Destroys session on error or logout. |
| 366 | 366 | * |
| 367 | - * @param string $directive ('start' or 'destroy')
|
|
| 368 | - * @return void |
|
| 367 | + * @param string $directive ('start' or 'destroy') |
|
| 368 | + * @param string $cookieName |
|
| 369 | + * @return modUsers |
|
| 369 | 370 | * @author Raymond Irving |
| 370 | 371 | * @author Scotty Delicious |
| 371 | 372 | * |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | if (!$find = $this->findUser($id)) {
|
| 82 | 82 | $this->id = null; |
| 83 | - }else {
|
|
| 83 | + } else {
|
|
| 84 | 84 | $result = $this->query("
|
| 85 | 85 | SELECT * from {$this->makeTable('web_user_attributes')} as attribute
|
| 86 | 86 | LEFT JOIN {$this->makeTable('web_users')} as user ON user.id=attribute.internalKey
|
@@ -200,7 +200,9 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | foreach ($fld as $key => $value) {
|
| 203 | - if ($value == '') continue; |
|
| 203 | + if ($value == '') {
|
|
| 204 | + continue; |
|
| 205 | + } |
|
| 204 | 206 | $result = $this->query("SELECT `setting_value` FROM {$this->makeTable('web_user_settings')} WHERE `webuser` = '{$this->id}' AND `setting_name` = '{$key}'");
|
| 205 | 207 | if ($this->modx->db->getRecordCount($result) > 0) {
|
| 206 | 208 | $result = $this->query("UPDATE {$this->makeTable('web_user_settings')} SET `setting_value` = '{$value}' WHERE `webuser` = '{$this->id}' AND `setting_name` = '{$key}';");
|
@@ -252,7 +254,9 @@ discard block |
||
| 252 | 254 | public function authUser($id = 0, $fulltime = true, $cookieName = 'WebLoginPE', $fire_events = null) |
| 253 | 255 | {
|
| 254 | 256 | $flag = false; |
| 255 | - if (!$this->getID() && $id) $this->edit($id); |
|
| 257 | + if (!$this->getID() && $id) {
|
|
| 258 | + $this->edit($id); |
|
| 259 | + } |
|
| 256 | 260 | if ($this->getID()) {
|
| 257 | 261 | //$this->logOut($cookieName); |
| 258 | 262 | $flag = true; |
@@ -349,7 +353,9 @@ discard block |
||
| 349 | 353 | */ |
| 350 | 354 | public function logOut($cookieName = 'WebLoginPE', $fire_events = null) |
| 351 | 355 | {
|
| 352 | - if (!$uid = $this->modx->getLoginUserID('web')) return;
|
|
| 356 | + if (!$uid = $this->modx->getLoginUserID('web')) {
|
|
| 357 | + return; |
|
| 358 | + } |
|
| 353 | 359 | $params = array( |
| 354 | 360 | 'username' => $_SESSION['webShortname'], |
| 355 | 361 | 'internalKey' => $uid, |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'gender' => null, |
| 29 | 29 | 'country' => null, |
| 30 | 30 | 'state' => null, |
| 31 | - 'city' => null, |
|
| 31 | + 'city' => null, |
|
| 32 | 32 | 'zip' => null, |
| 33 | 33 | 'fax' => null, |
| 34 | 34 | 'photo' => null, |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | $this->invokeEvent('OnWebChangePassword',array(
|
| 212 | 212 | 'userObj' => $this, |
| 213 | 213 | 'userid' => $this->id, |
| 214 | - 'user' => $this->toArray(), |
|
| 215 | - 'userpassword' => $this->givenPassword, |
|
| 214 | + 'user' => $this->toArray(), |
|
| 215 | + 'userpassword' => $this->givenPassword, |
|
| 216 | 216 | 'internalKey' => $this->id, |
| 217 | 217 | 'username' => $this->get('username')
|
| 218 | 218 | ),$fire_events); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | if (!$find = $this->findUser($id)) {
|
| 83 | 83 | $this->id = null; |
| 84 | - }else {
|
|
| 84 | + } else {
|
|
| 85 | 85 | $result = $this->query("
|
| 86 | 86 | SELECT * from {$this->makeTable('web_user_attributes')} as attribute
|
| 87 | 87 | LEFT JOIN {$this->makeTable('web_users')} as user ON user.id=attribute.internalKey
|
@@ -133,17 +133,17 @@ discard block |
||
| 133 | 133 | public function save($fire_events = null, $clearCache = false) |
| 134 | 134 | {
|
| 135 | 135 | if ($this->get('email') == '' || $this->get('username') == '' || $this->get('password') == '') {
|
| 136 | - $this->log['EmptyPKField'] = 'Email, username or password is empty <pre>' . print_r($this->toArray(), true) . '</pre>'; |
|
| 136 | + $this->log['EmptyPKField'] = 'Email, username or password is empty <pre>'.print_r($this->toArray(), true).'</pre>'; |
|
| 137 | 137 | return false; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | if (!$this->checkUnique('web_users', 'username')) {
|
| 141 | - $this->log['UniqueUsername'] = 'username not unique <pre>' . print_r($this->get('username'), true) . '</pre>';
|
|
| 141 | + $this->log['UniqueUsername'] = 'username not unique <pre>'.print_r($this->get('username'), true).'</pre>';
|
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | if (!$this->checkUnique('web_user_attributes', 'email', 'internalKey')) {
|
| 146 | - $this->log['UniqueEmail'] = 'Email not unique <pre>' . print_r($this->get('email'), true) . '</pre>';
|
|
| 146 | + $this->log['UniqueEmail'] = 'Email not unique <pre>'.print_r($this->get('email'), true).'</pre>';
|
|
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | $fld = $this->toArray(); |
| 156 | 156 | foreach ($this->default_field['user'] as $key => $value) {
|
| 157 | 157 | $tmp = $this->get($key); |
| 158 | - if ($this->newDoc && ( !is_int($tmp) && $tmp=='')) {
|
|
| 159 | - if($tmp == $value){
|
|
| 158 | + if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
|
|
| 159 | + if ($tmp == $value) {
|
|
| 160 | 160 | //take default value from global config |
| 161 | 161 | } |
| 162 | 162 | $this->field[$key] = $value; |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | if (!empty($this->set['user'])) {
|
| 168 | 168 | if ($this->newDoc) {
|
| 169 | - $SQL = "INSERT into {$this->makeTable('web_users')} SET " . implode(', ', $this->set['user']);
|
|
| 169 | + $SQL = "INSERT into {$this->makeTable('web_users')} SET ".implode(', ', $this->set['user']);
|
|
| 170 | 170 | } else {
|
| 171 | - $SQL = "UPDATE {$this->makeTable('web_users')} SET " . implode(', ', $this->set['user']) . " WHERE id = " . $this->id;
|
|
| 171 | + $SQL = "UPDATE {$this->makeTable('web_users')} SET ".implode(', ', $this->set['user'])." WHERE id = ".$this->id;
|
|
| 172 | 172 | } |
| 173 | 173 | $this->query($SQL); |
| 174 | 174 | } |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | foreach ($this->default_field['attribute'] as $key => $value) {
|
| 181 | 181 | $tmp = $this->get($key); |
| 182 | - if ($this->newDoc && ( !is_int($tmp) && $tmp=='')) {
|
|
| 183 | - if($tmp == $value){
|
|
| 182 | + if ($this->newDoc && (!is_int($tmp) && $tmp == '')) {
|
|
| 183 | + if ($tmp == $value) {
|
|
| 184 | 184 | //take default value from global config |
| 185 | 185 | } |
| 186 | 186 | $this->field[$key] = $value; |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | if (!empty($this->set['attribute'])) {
|
| 192 | 192 | if ($this->newDoc) {
|
| 193 | 193 | $this->set('internalKey', $this->id)->Uset('internalKey', 'attribute');
|
| 194 | - $SQL = "INSERT into {$this->makeTable('web_user_attributes')} SET " . implode(', ', $this->set['attribute']);
|
|
| 194 | + $SQL = "INSERT into {$this->makeTable('web_user_attributes')} SET ".implode(', ', $this->set['attribute']);
|
|
| 195 | 195 | } else {
|
| 196 | - $SQL = "UPDATE {$this->makeTable('web_user_attributes')} SET " . implode(', ', $this->set['attribute']) . " WHERE internalKey = " . $this->getID();
|
|
| 196 | + $SQL = "UPDATE {$this->makeTable('web_user_attributes')} SET ".implode(', ', $this->set['attribute'])." WHERE internalKey = ".$this->getID();
|
|
| 197 | 197 | } |
| 198 | 198 | $this->query($SQL); |
| 199 | 199 | } |
@@ -208,21 +208,21 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | if (!$this->newDoc && $this->givenPassword) {
|
| 211 | - $this->invokeEvent('OnWebChangePassword',array(
|
|
| 211 | + $this->invokeEvent('OnWebChangePassword', array(
|
|
| 212 | 212 | 'userObj' => $this, |
| 213 | 213 | 'userid' => $this->id, |
| 214 | 214 | 'user' => $this->toArray(), |
| 215 | 215 | 'userpassword' => $this->givenPassword, |
| 216 | 216 | 'internalKey' => $this->id, |
| 217 | 217 | 'username' => $this->get('username')
|
| 218 | - ),$fire_events); |
|
| 218 | + ), $fire_events); |
|
| 219 | 219 | } |
| 220 | - $this->invokeEvent('OnWebSaveUser',array (
|
|
| 220 | + $this->invokeEvent('OnWebSaveUser', array(
|
|
| 221 | 221 | 'userObj' => $this, |
| 222 | 222 | 'mode' => $this->newDoc ? "new" : "upd", |
| 223 | 223 | 'id' => $this->id, |
| 224 | 224 | 'user' => $this->toArray() |
| 225 | - ),$fire_events); |
|
| 225 | + ), $fire_events); |
|
| 226 | 226 | |
| 227 | 227 | if ($clearCache) {
|
| 228 | 228 | $this->clearCache($fire_events); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | 'username' => $this->get('username'),
|
| 275 | 275 | 'userpassword' => $this->givenPassword, |
| 276 | 276 | 'rememberme' => $fulltime |
| 277 | - ),$fire_events); |
|
| 277 | + ), $fire_events); |
|
| 278 | 278 | } |
| 279 | 279 | return $flag; |
| 280 | 280 | } |
@@ -317,13 +317,13 @@ discard block |
||
| 317 | 317 | if ( |
| 318 | 318 | ($tmp->getID()) && (!$blocker || ($blocker && !$tmp->checkBlock($id))) |
| 319 | 319 | ) {
|
| 320 | - $eventResult = $this->getInvokeEventResult('OnWebAuthentication',array(
|
|
| 320 | + $eventResult = $this->getInvokeEventResult('OnWebAuthentication', array(
|
|
| 321 | 321 | 'userObj' => $this, |
| 322 | 322 | 'userid' => $tmp->getID(), |
| 323 | 323 | 'username' => $tmp->get('username'),
|
| 324 | 324 | 'userpassword' => $password, |
| 325 | 325 | 'savedpassword' => $tmp->get('password')
|
| 326 | - ),$fire_events); |
|
| 326 | + ), $fire_events); |
|
| 327 | 327 | if (is_array($eventResult)) {
|
| 328 | 328 | foreach ($eventResult as $result) {
|
| 329 | 329 | $pluginFlag = (bool)$result; |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $cookie = explode('|', $_COOKIE[$cookieName], 2);
|
| 352 | 352 | if (isset($cookie[0], $cookie[1]) && strlen($cookie[0]) == 32 && strlen($cookie[1]) == 32) {
|
| 353 | 353 | $this->close(); |
| 354 | - $q = $this->modx->db->query("SELECT id FROM " . $this->makeTable('web_users') . " WHERE md5(username)='{$this->escape($cookie[0])}'");
|
|
| 354 | + $q = $this->modx->db->query("SELECT id FROM ".$this->makeTable('web_users')." WHERE md5(username)='{$this->escape($cookie[0])}'");
|
|
| 355 | 355 | $id = $this->modx->db->getValue($q); |
| 356 | 356 | if ($this->edit($id) && $this->getID() && $this->get('password') == $cookie[1] && $this->testAuth($this->getID(), $cookie[1], true)) {
|
| 357 | 357 | $flag = $this->authUser($this->getID(), $fulltime, $cookieName, $fire_events); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $_SESSION['webUserGroupNames'] = $this->getUserGroups(); |
| 411 | 411 | $_SESSION['webDocgroups'] = $this->getDocumentGroups(); |
| 412 | 412 | if ($remember) {
|
| 413 | - $cookieValue = md5($this->get('username')) . '|' . $this->get('password');
|
|
| 413 | + $cookieValue = md5($this->get('username')).'|'.$this->get('password');
|
|
| 414 | 414 | $cookieExpires = time() + (is_bool($remember) ? (60 * 60 * 24 * 365 * 5) : (int)$remember); |
| 415 | 415 | setcookie($cookieName, $cookieValue, $cookieExpires, '/'); |
| 416 | 416 | } |
@@ -452,17 +452,17 @@ discard block |
||
| 452 | 452 | * @param int $userID |
| 453 | 453 | * @return array |
| 454 | 454 | */ |
| 455 | - public function getDocumentGroups($userID = 0){
|
|
| 455 | + public function getDocumentGroups($userID = 0) {
|
|
| 456 | 456 | $out = array(); |
| 457 | 457 | $user = $this->switchObject($userID); |
| 458 | - if($user->getID()){
|
|
| 458 | + if ($user->getID()) {
|
|
| 459 | 459 | $web_groups = $this->modx->getFullTableName('web_groups');
|
| 460 | 460 | $webgroup_access = $this->modx->getFullTableName('webgroup_access');
|
| 461 | 461 | |
| 462 | 462 | $sql = "SELECT `uga`.`documentgroup` FROM {$web_groups} as `ug`
|
| 463 | 463 | INNER JOIN {$webgroup_access} as `uga` ON `uga`.`webgroup`=`ug`.`webgroup`
|
| 464 | 464 | WHERE `ug`.`webuser` = ".$user->getID(); |
| 465 | - $out = $this->modx->db->getColumn('documentgroup',$this->query($sql));
|
|
| 465 | + $out = $this->modx->db->getColumn('documentgroup', $this->query($sql));
|
|
| 466 | 466 | |
| 467 | 467 | } |
| 468 | 468 | unset($user); |
@@ -473,17 +473,17 @@ discard block |
||
| 473 | 473 | * @param int $userID |
| 474 | 474 | * @return array |
| 475 | 475 | */ |
| 476 | - public function getUserGroups($userID = 0){
|
|
| 476 | + public function getUserGroups($userID = 0) {
|
|
| 477 | 477 | $out = array(); |
| 478 | 478 | $user = $this->switchObject($userID); |
| 479 | - if($user->getID()){
|
|
| 479 | + if ($user->getID()) {
|
|
| 480 | 480 | $web_groups = $this->makeTable('web_groups');
|
| 481 | 481 | $webgroup_names = $this->makeTable('webgroup_names');
|
| 482 | 482 | |
| 483 | 483 | $sql = "SELECT `ugn`.`name` FROM {$web_groups} as `ug`
|
| 484 | 484 | INNER JOIN {$webgroup_names} as `ugn` ON `ugn`.`id`=`ug`.`webgroup`
|
| 485 | 485 | WHERE `ug`.`webuser` = ".$user->getID(); |
| 486 | - $out = $this->modx->db->getColumn('name',$this->query($sql));
|
|
| 486 | + $out = $this->modx->db->getColumn('name', $this->query($sql));
|
|
| 487 | 487 | } |
| 488 | 488 | unset($user); |
| 489 | 489 | return $out; |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | |
| 492 | 492 | public function setUserGroups($userID = 0, $groupIds = array()) {
|
| 493 | 493 | $user = $this->switchObject($userID); |
| 494 | - if(($uid = $user->getID()) && is_array($groupIds)) {
|
|
| 494 | + if (($uid = $user->getID()) && is_array($groupIds)) {
|
|
| 495 | 495 | foreach ($groupIds as $gid) {
|
| 496 | 496 | $this->query("REPLACE INTO {$this->makeTable('web_groups')} (`webgroup`, `webuser`) VALUES ('{$gid}', '{$uid}')");
|
| 497 | 497 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $value = (int)((bool)$value); |
| 213 | 213 | if($value){ |
| 214 | 214 | $this->field['deletedon'] = time() + $this->modxConfig('server_offset_time'); |
| 215 | - }else{ |
|
| 215 | + } else{ |
|
| 216 | 216 | $this->field['deletedon'] = 0; |
| 217 | 217 | } |
| 218 | 218 | break; |
@@ -402,7 +402,9 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | foreach ($fld as $key => $value) { |
| 405 | - if (empty($this->tv[$key])) continue; |
|
| 405 | + if (empty($this->tv[$key])) {
|
|
| 406 | + continue; |
|
| 407 | + } |
|
| 406 | 408 | if ($value === '') { |
| 407 | 409 | $this->query("DELETE FROM {$this->makeTable('site_tmplvar_contentvalues')} WHERE `contentid` = '{$this->id}' AND `tmplvarid` = '{$this->tv[$key]}'"); |
| 408 | 410 | } else { |
@@ -434,7 +436,9 @@ discard block |
||
| 434 | 436 | if (is_array($_ids) && $_ids != array()) { |
| 435 | 437 | $id = $this->sanitarIn($_ids); |
| 436 | 438 | $this->query("UPDATE {$this->makeTable('site_content')} SET `deleted`='1' WHERE `id` IN ({$id})"); |
| 437 | - } else throw new Exception('Invalid IDs list for mark trash: <pre>' . print_r($ids, 1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>'); |
|
| 439 | + } else {
|
|
| 440 | + throw new Exception('Invalid IDs list for mark trash: <pre>' . print_r($ids, 1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>');
|
|
| 441 | + } |
|
| 438 | 442 | return $this; |
| 439 | 443 | } |
| 440 | 444 | public function clearTrash($fire_events = null){ |
@@ -477,7 +481,9 @@ discard block |
||
| 477 | 481 | "ids" => $_ids |
| 478 | 482 | ), $fire_events); |
| 479 | 483 | } |
| 480 | - } else throw new Exception('Invalid IDs list for delete: <pre>' . print_r($ids, 1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>'); |
|
| 484 | + } else {
|
|
| 485 | + throw new Exception('Invalid IDs list for delete: <pre>' . print_r($ids, 1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>');
|
|
| 486 | + } |
|
| 481 | 487 | |
| 482 | 488 | return $this; |
| 483 | 489 | } |
@@ -574,7 +580,9 @@ discard block |
||
| 574 | 580 | if (is_scalar($tpl)) { |
| 575 | 581 | $sql = "SELECT `id` FROM {$this->makeTable('site_templates')} WHERE `templatename` = '".$this->escape($tpl)."'"; |
| 576 | 582 | $rs = $this->query($sql); |
| 577 | - if (!$rs || $this->modx->db->getRecordCount($rs) <= 0) throw new Exception("Template {$tpl} is not exists"); |
|
| 583 | + if (!$rs || $this->modx->db->getRecordCount($rs) <= 0) {
|
|
| 584 | + throw new Exception("Template {$tpl} is not exists");
|
|
| 585 | + } |
|
| 578 | 586 | $tpl = $this->modx->db->getValue($rs); |
| 579 | 587 | } else { |
| 580 | 588 | throw new Exception("Invalid template name: " . print_r($tpl, 1)); |
@@ -94,20 +94,20 @@ discard block |
||
| 94 | 94 | $out = array_diff_key(parent::toArray(), $this->default_field); |
| 95 | 95 | $tpl = $this->get('template'); |
| 96 | 96 | $tvTPL = APIHelpers::getkey($this->tvTpl, $tpl, array()); |
| 97 | - foreach($tvTPL as $item){ |
|
| 98 | - if(isset($this->tvid[$item]) && !array_key_exists($this->tvid[$item], $out)){ |
|
| 97 | + foreach ($tvTPL as $item) { |
|
| 98 | + if (isset($this->tvid[$item]) && !array_key_exists($this->tvid[$item], $out)) { |
|
| 99 | 99 | $out[$this->tvid[$item]] = $this->get($this->tvid[$item]); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - if($render){ |
|
| 103 | - foreach($out as $key => $val){ |
|
| 102 | + if ($render) { |
|
| 103 | + foreach ($out as $key => $val) { |
|
| 104 | 104 | $out[$key] = $this->renderTV($key); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | return $out; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function toArray($prefix = '', $suffix = '', $sep = '_', $render = true){ |
|
| 110 | + public function toArray($prefix = '', $suffix = '', $sep = '_', $render = true) { |
|
| 111 | 111 | $out = array_merge( |
| 112 | 112 | $this->toArrayMain(), |
| 113 | 113 | $this->toArrayTV($render), |
@@ -115,17 +115,17 @@ discard block |
||
| 115 | 115 | ); |
| 116 | 116 | return \APIhelpers::renameKeyArr($out, $prefix, $suffix, $sep); |
| 117 | 117 | } |
| 118 | - public function getUrl(){ |
|
| 118 | + public function getUrl() { |
|
| 119 | 119 | $out = null; |
| 120 | 120 | $id = (int)$this->getID(); |
| 121 | - if(!empty($id)){ |
|
| 121 | + if (!empty($id)) { |
|
| 122 | 122 | $out = $this->modx->makeUrl($id); |
| 123 | 123 | } |
| 124 | 124 | return $out; |
| 125 | 125 | } |
| 126 | - public function getTitle($main = 'menutitle', $second = 'pagetitle'){ |
|
| 126 | + public function getTitle($main = 'menutitle', $second = 'pagetitle') { |
|
| 127 | 127 | $title = $this->get($main); |
| 128 | - if(empty($title) && $title !== '0'){ |
|
| 128 | + if (empty($title) && $title !== '0') { |
|
| 129 | 129 | $title = $this->get($second); |
| 130 | 130 | } |
| 131 | 131 | return $title; |
@@ -138,16 +138,16 @@ discard block |
||
| 138 | 138 | $del = ($this->get('deleted') == 0 && ($this->get('deletedon') == 0 || $this->get('deletedon') > time())); |
| 139 | 139 | return ($pub && $unpub && $del); |
| 140 | 140 | } |
| 141 | - public function touch(){ |
|
| 141 | + public function touch() { |
|
| 142 | 142 | $this->set('editedon', time()); |
| 143 | 143 | return $this; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public function renderTV($tvname){ |
|
| 146 | + public function renderTV($tvname) { |
|
| 147 | 147 | $out = null; |
| 148 | - if($this->getID() > 0){ |
|
| 149 | - include_once MODX_MANAGER_PATH . "includes/tmplvars.format.inc.php"; |
|
| 150 | - include_once MODX_MANAGER_PATH . "includes/tmplvars.commands.inc.php"; |
|
| 148 | + if ($this->getID() > 0) { |
|
| 149 | + include_once MODX_MANAGER_PATH."includes/tmplvars.format.inc.php"; |
|
| 150 | + include_once MODX_MANAGER_PATH."includes/tmplvars.commands.inc.php"; |
|
| 151 | 151 | $tvval = $this->get($tvname); |
| 152 | 152 | $param = APIHelpers::getkey($this->tvd, $tvname, array()); |
| 153 | 153 | $display = APIHelpers::getkey($param, 'display', ''); |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | return $out; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function get($key){ |
|
| 161 | + public function get($key) { |
|
| 162 | 162 | $out = parent::get($key); |
| 163 | - if(isset($this->tv[$key])){ |
|
| 163 | + if (isset($this->tv[$key])) { |
|
| 164 | 164 | $tpl = $this->get('template'); |
| 165 | 165 | $tvTPL = APIHelpers::getkey($this->tvTpl, $tpl, array()); |
| 166 | 166 | $tvID = APIHelpers::getkey($this->tv, $key, 0); |
| 167 | - if(in_array($tvID, $tvTPL) && is_null($out)){ |
|
| 167 | + if (in_array($tvID, $tvTPL) && is_null($out)) { |
|
| 168 | 168 | $out = APIHelpers::getkey($this->tvd[$key], 'value', null); |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -184,38 +184,38 @@ discard block |
||
| 184 | 184 | break; |
| 185 | 185 | case 'published': |
| 186 | 186 | $value = (int)((bool)$value); |
| 187 | - if($value){ |
|
| 187 | + if ($value) { |
|
| 188 | 188 | $this->field['publishedon'] = time() + $this->modxConfig('server_offset_time'); |
| 189 | 189 | } |
| 190 | 190 | break; |
| 191 | 191 | case 'pub_date': |
| 192 | 192 | $value = $this->getTime($value); |
| 193 | - if($value > 0 && time() + $this->modxConfig('server_offset_time') > $value){ |
|
| 193 | + if ($value > 0 && time() + $this->modxConfig('server_offset_time') > $value) { |
|
| 194 | 194 | $this->field['published'] = 1; |
| 195 | 195 | $this->field['publishedon'] = $value; |
| 196 | 196 | } |
| 197 | 197 | break; |
| 198 | 198 | case 'unpub_date': |
| 199 | 199 | $value = $this->getTime($value); |
| 200 | - if($value > 0 && time() + $this->modxConfig('server_offset_time') > $value){ |
|
| 200 | + if ($value > 0 && time() + $this->modxConfig('server_offset_time') > $value) { |
|
| 201 | 201 | $this->field['published'] = 0; |
| 202 | 202 | $this->field['publishedon'] = 0; |
| 203 | 203 | } |
| 204 | 204 | break; |
| 205 | 205 | case 'deleted': |
| 206 | 206 | $value = (int)((bool)$value); |
| 207 | - if($value){ |
|
| 207 | + if ($value) { |
|
| 208 | 208 | $this->field['deletedon'] = time() + $this->modxConfig('server_offset_time'); |
| 209 | - }else{ |
|
| 209 | + } else { |
|
| 210 | 210 | $this->field['deletedon'] = 0; |
| 211 | 211 | } |
| 212 | 212 | break; |
| 213 | 213 | case 'deletedon': |
| 214 | 214 | $value = $this->getTime($value); |
| 215 | - if($value > 0 && time() + $this->modxConfig('server_offset_time') < $value){ |
|
| 215 | + if ($value > 0 && time() + $this->modxConfig('server_offset_time') < $value) { |
|
| 216 | 216 | $value = 0; |
| 217 | 217 | } |
| 218 | - if($value){ |
|
| 218 | + if ($value) { |
|
| 219 | 219 | $this->field['deleted'] = 1; |
| 220 | 220 | } |
| 221 | 221 | break; |
@@ -236,19 +236,19 @@ discard block |
||
| 236 | 236 | return $this; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - protected function getUser($value, $default = 0){ |
|
| 239 | + protected function getUser($value, $default = 0) { |
|
| 240 | 240 | $currentAdmin = APIHelpers::getkey($_SESSION, 'mgrInternalKey', 0); |
| 241 | 241 | $value = (int)$value; |
| 242 | - if(!empty($value)){ |
|
| 242 | + if (!empty($value)) { |
|
| 243 | 243 | $by = $this->findUserBy($value); |
| 244 | 244 | $exists = $this->managerUsers->exists(function($key, $val) use ($by, $value){ |
| 245 | 245 | return ($val->containsKey($by) && $val->get($by) === (string)$value); |
| 246 | 246 | }); |
| 247 | - if(!$exists){ |
|
| 247 | + if (!$exists) { |
|
| 248 | 248 | $value = 0; |
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | - if(empty($value)){ |
|
| 251 | + if (empty($value)) { |
|
| 252 | 252 | $value = empty($currentAdmin) ? $default : $currentAdmin; |
| 253 | 253 | } |
| 254 | 254 | return $value; |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | return $find; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - protected function getTime($value){ |
|
| 275 | + protected function getTime($value) { |
|
| 276 | 276 | $value = trim($value); |
| 277 | - if(!empty($value)){ |
|
| 278 | - if(!is_numeric($value)){ |
|
| 277 | + if (!empty($value)) { |
|
| 278 | + if (!is_numeric($value)) { |
|
| 279 | 279 | $value = (int)strtotime($value); |
| 280 | 280 | } |
| 281 | - if(!empty($value)){ |
|
| 281 | + if (!empty($value)) { |
|
| 282 | 282 | $value += $this->modxConfig('server_offset_time'); |
| 283 | 283 | } |
| 284 | 284 | } |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | $this->close(); |
| 302 | 302 | $this->newDoc = false; |
| 303 | 303 | |
| 304 | - $result = $this->query("SELECT * from {$this->makeTable('site_content')} where `id`=" . (int)$id); |
|
| 304 | + $result = $this->query("SELECT * from {$this->makeTable('site_content')} where `id`=".(int)$id); |
|
| 305 | 305 | $this->fromArray($this->modx->db->getRow($result)); |
| 306 | - $result = $this->query("SELECT * from {$this->makeTable('site_tmplvar_contentvalues')} where `contentid`=" . (int)$id); |
|
| 306 | + $result = $this->query("SELECT * from {$this->makeTable('site_tmplvar_contentvalues')} where `contentid`=".(int)$id); |
|
| 307 | 307 | while ($row = $this->modx->db->getRow($result)) { |
| 308 | 308 | $this->field[$this->tvid[$row['tmplvarid']]] = $row['value']; |
| 309 | 309 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | { |
| 323 | 323 | $parent = null; |
| 324 | 324 | if ($this->field['pagetitle'] == '') { |
| 325 | - $this->log['emptyPagetitle'] = 'Pagetitle is empty in <pre>' . print_r($this->field, true) . '</pre>'; |
|
| 325 | + $this->log['emptyPagetitle'] = 'Pagetitle is empty in <pre>'.print_r($this->field, true).'</pre>'; |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | |
@@ -338,8 +338,8 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | foreach ($this->default_field as $key => $value) { |
| 340 | 340 | $tmp = $this->get($key); |
| 341 | - if ($this->newDoc && ( !is_int($tmp) && $tmp=='')) { |
|
| 342 | - if($tmp == $value){ |
|
| 341 | + if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
| 342 | + if ($tmp == $value) { |
|
| 343 | 343 | switch ($key) { |
| 344 | 344 | case 'cacheable': |
| 345 | 345 | $value = $this->modxConfig('cache_default'); |
@@ -360,11 +360,11 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | $this->field[$key] = $value; |
| 362 | 362 | } |
| 363 | - switch(true){ |
|
| 363 | + switch (true) { |
|
| 364 | 364 | case $key == 'parent': |
| 365 | 365 | $parent = (int)$this->get($key); |
| 366 | 366 | $q = $this->query("SELECT count(`id`) FROM {$this->makeTable('site_content')} WHERE `id`='{$parent}'"); |
| 367 | - if($this->modx->db->getValue($q)!=1){ |
|
| 367 | + if ($this->modx->db->getValue($q) != 1) { |
|
| 368 | 368 | $parent = $value; |
| 369 | 369 | } |
| 370 | 370 | $this->field[$key] = $parent; |
@@ -381,9 +381,9 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | if (!empty($this->set)) { |
| 383 | 383 | if ($this->newDoc) { |
| 384 | - $SQL = "INSERT into {$this->makeTable('site_content')} SET " . implode(', ', $this->set); |
|
| 384 | + $SQL = "INSERT into {$this->makeTable('site_content')} SET ".implode(', ', $this->set); |
|
| 385 | 385 | } else { |
| 386 | - $SQL = "UPDATE {$this->makeTable('site_content')} SET " . implode(', ', $this->set) . " WHERE `id` = " . $this->id; |
|
| 386 | + $SQL = "UPDATE {$this->makeTable('site_content')} SET ".implode(', ', $this->set)." WHERE `id` = ".$this->id; |
|
| 387 | 387 | } |
| 388 | 388 | $this->query($SQL); |
| 389 | 389 | |
@@ -423,20 +423,20 @@ discard block |
||
| 423 | 423 | return $this->id; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - public function toTrash($ids){ |
|
| 426 | + public function toTrash($ids) { |
|
| 427 | 427 | $ignore = $this->systemID(); |
| 428 | 428 | $_ids = $this->cleanIDs($ids, ',', $ignore); |
| 429 | 429 | if (is_array($_ids) && $_ids != array()) { |
| 430 | 430 | $id = $this->sanitarIn($_ids); |
| 431 | 431 | $this->query("UPDATE {$this->makeTable('site_content')} SET `deleted`='1' WHERE `id` IN ({$id})"); |
| 432 | - } else throw new Exception('Invalid IDs list for mark trash: <pre>' . print_r($ids, 1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>'); |
|
| 432 | + } else throw new Exception('Invalid IDs list for mark trash: <pre>'.print_r($ids, 1).'</pre> please, check ignore list: <pre>'.print_r($ignore, 1).'</pre>'); |
|
| 433 | 433 | return $this; |
| 434 | 434 | } |
| 435 | - public function clearTrash($fire_events = null){ |
|
| 435 | + public function clearTrash($fire_events = null) { |
|
| 436 | 436 | $q = $this->query("SELECT `id` FROM {$this->makeTable('site_content')} WHERE `deleted`='1'"); |
| 437 | 437 | $q = $this->modx->makeArray($q); |
| 438 | 438 | $_ids = array(); |
| 439 | - foreach($q as $item){ |
|
| 439 | + foreach ($q as $item) { |
|
| 440 | 440 | $_ids[] = $item['id']; |
| 441 | 441 | } |
| 442 | 442 | if (is_array($_ids) && $_ids != array()) { |
@@ -465,14 +465,14 @@ discard block |
||
| 465 | 465 | ), $fire_events); |
| 466 | 466 | |
| 467 | 467 | $id = $this->sanitarIn($_ids); |
| 468 | - if(!empty($id)){ |
|
| 468 | + if (!empty($id)) { |
|
| 469 | 469 | $this->query("DELETE from {$this->makeTable('site_content')} where `id` IN ({$id})"); |
| 470 | 470 | $this->query("DELETE from {$this->makeTable('site_tmplvar_contentvalues')} where `contentid` IN ({$id})"); |
| 471 | 471 | $this->invokeEvent('OnEmptyTrash', array( |
| 472 | 472 | "ids" => $_ids |
| 473 | 473 | ), $fire_events); |
| 474 | 474 | } |
| 475 | - } else throw new Exception('Invalid IDs list for delete: <pre>' . print_r($ids, 1) . '</pre> please, check ignore list: <pre>' . print_r($ignore, 1) . '</pre>'); |
|
| 475 | + } else throw new Exception('Invalid IDs list for delete: <pre>'.print_r($ids, 1).'</pre> please, check ignore list: <pre>'.print_r($ignore, 1).'</pre>'); |
|
| 476 | 476 | |
| 477 | 477 | return $this; |
| 478 | 478 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | $suffix = substr($alias, -2); |
| 510 | 510 | if (preg_match('/-(\d+)/', $suffix, $tmp) && isset($tmp[1]) && (int)$tmp[1] > 1) { |
| 511 | 511 | $suffix = (int)$tmp[1] + 1; |
| 512 | - $alias = substr($alias, 0, -2) . '-' . $suffix; |
|
| 512 | + $alias = substr($alias, 0, -2).'-'.$suffix; |
|
| 513 | 513 | } else { |
| 514 | 514 | $alias .= '-2'; |
| 515 | 515 | } |
@@ -527,30 +527,30 @@ discard block |
||
| 527 | 527 | protected function get_TV($reload = false) |
| 528 | 528 | { |
| 529 | 529 | if (empty($this->modx->_TVnames) || $reload) { |
| 530 | - $result = $this->query('SELECT `id`,`name` FROM ' . $this->makeTable('site_tmplvars')); |
|
| 530 | + $result = $this->query('SELECT `id`,`name` FROM '.$this->makeTable('site_tmplvars')); |
|
| 531 | 531 | while ($row = $this->modx->db->GetRow($result)) { |
| 532 | 532 | $this->modx->_TVnames[$row['name']] = $row['id']; |
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | - foreach($this->modx->_TVnames as $name => $id){ |
|
| 535 | + foreach ($this->modx->_TVnames as $name => $id) { |
|
| 536 | 536 | $this->tvid[$id] = $name; |
| 537 | 537 | $this->tv[$name] = $id; |
| 538 | 538 | } |
| 539 | 539 | $this->loadTVTemplate()->loadTVDefault(array_values($this->tv)); |
| 540 | 540 | return $this; |
| 541 | 541 | } |
| 542 | - protected function loadTVTemplate(){ |
|
| 542 | + protected function loadTVTemplate() { |
|
| 543 | 543 | $q = $this->query("SELECT `tmplvarid`, `templateid` FROM ".$this->makeTable('site_tmplvar_templates')); |
| 544 | 544 | $q = $this->modx->db->makeArray($q); |
| 545 | 545 | $this->tvTpl = array(); |
| 546 | - foreach($q as $item){ |
|
| 546 | + foreach ($q as $item) { |
|
| 547 | 547 | $this->tvTpl[$item['templateid']][] = $item['tmplvarid']; |
| 548 | 548 | } |
| 549 | 549 | return $this; |
| 550 | 550 | } |
| 551 | 551 | protected function loadTVDefault(array $tvId = array()) |
| 552 | 552 | { |
| 553 | - if(is_array($tvId) && !empty($tvId)){ |
|
| 553 | + if (is_array($tvId) && !empty($tvId)) { |
|
| 554 | 554 | $tbl_site_tmplvars = $this->makeTable('site_tmplvars'); |
| 555 | 555 | $fields = 'id,name,default_text as value,display,display_params,type'; |
| 556 | 556 | $implodeTvId = implode(',', $tvId); |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | if (!$rs || $this->modx->db->getRecordCount($rs) <= 0) throw new Exception("Template {$tpl} is not exists"); |
| 573 | 573 | $tpl = $this->modx->db->getValue($rs); |
| 574 | 574 | } else { |
| 575 | - throw new Exception("Invalid template name: " . print_r($tpl, 1)); |
|
| 575 | + throw new Exception("Invalid template name: ".print_r($tpl, 1)); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | return (int)$tpl; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * @TODO add parameter showFolder - include document container in result data whithout children document if you set depth parameter. |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -include_once(dirname(__FILE__) . "/site_content.php"); |
|
| 17 | +include_once(dirname(__FILE__)."/site_content.php"); |
|
| 18 | 18 | |
| 19 | 19 | class site_content_tagsDocLister extends site_contentDocLister |
| 20 | 20 | {
|
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | $link = $this->checkExtender('request') ? $this->extender['request']->getLink() : "";
|
| 38 | 38 | $tag = $this->checkTag(); |
| 39 | 39 | if ($tag != false && is_array($tag) && $tag['mode'] == 'get') {
|
| 40 | - $link .= "&tag=" . urlencode($tag['tag']); |
|
| 40 | + $link .= "&tag=".urlencode($tag['tag']); |
|
| 41 | 41 | } |
| 42 | - $url = ($id == $this->modx->config['site_start']) ? $this->modx->config['site_url'] . ($link != '' ? "?{$link}" : "") : $this->modx->makeUrl($id, '', $link, 'full');
|
|
| 42 | + $url = ($id == $this->modx->config['site_start']) ? $this->modx->config['site_url'].($link != '' ? "?{$link}" : "") : $this->modx->makeUrl($id, '', $link, 'full');
|
|
| 43 | 43 | return $url; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | case 'static': |
| 58 | 58 | default: |
| 59 | 59 | $tag = $tmp[1]; |
| 60 | - $separator = $this->getCFGDef('tagsSeparator','||');
|
|
| 60 | + $separator = $this->getCFGDef('tagsSeparator', '||');
|
|
| 61 | 61 | if (!empty($tag) && !empty($separator)) {
|
| 62 | - $_tag = explode($separator,$tag); |
|
| 62 | + $_tag = explode($separator, $tag); |
|
| 63 | 63 | if (count($_tag) > 1) $tag = $_tag; |
| 64 | 64 | } |
| 65 | 65 | break; |
@@ -84,23 +84,23 @@ discard block |
||
| 84 | 84 | {
|
| 85 | 85 | $tag = $this->checkTag(true); |
| 86 | 86 | if ($tag !== false) {
|
| 87 | - $join = "RIGHT JOIN " . $this->getTable('site_content_tags', 'ct') . " on ct.doc_id=c.id
|
|
| 88 | - RIGHT JOIN " . $this->getTable('tags', 't') . " on t.id=ct.tag_id";
|
|
| 87 | + $join = "RIGHT JOIN ".$this->getTable('site_content_tags', 'ct')." on ct.doc_id=c.id
|
|
| 88 | + RIGHT JOIN " . $this->getTable('tags', 't')." on t.id=ct.tag_id";
|
|
| 89 | 89 | if (is_array($tag['tag'])) {
|
| 90 | - $where = "t.`name` IN (" . $this->sanitarIn($tag['tag']) . ")";
|
|
| 90 | + $where = "t.`name` IN (".$this->sanitarIn($tag['tag']).")";
|
|
| 91 | 91 | } else {
|
| 92 | - $where = "t.`name`='" . $this->modx->db->escape($tag['tag']) . "'"; |
|
| 92 | + $where = "t.`name`='".$this->modx->db->escape($tag['tag'])."'"; |
|
| 93 | 93 | } |
| 94 | - $where .= ($this->getCFGDef('tagsData', '') > 0) ? "AND ct.tv_id=" . (int)$this->getCFGDef('tagsData', '') : "";
|
|
| 94 | + $where .= ($this->getCFGDef('tagsData', '') > 0) ? "AND ct.tv_id=".(int)$this->getCFGDef('tagsData', '') : "";
|
|
| 95 | 95 | |
| 96 | 96 | if (!empty($this->_filters['where'])) {
|
| 97 | - $this->_filters['where'] .= " AND " . $where; |
|
| 97 | + $this->_filters['where'] .= " AND ".$where; |
|
| 98 | 98 | } else {
|
| 99 | 99 | $this->_filters['where'] = $where; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | if (!empty($this->_filters['join'])) {
|
| 103 | - $this->_filters['join'] .= ' ' . $join; |
|
| 103 | + $this->_filters['join'] .= ' '.$join; |
|
| 104 | 104 | } else {
|
| 105 | 105 | $this->_filters['join'] = $join; |
| 106 | 106 | } |
@@ -60,7 +60,9 @@ |
||
| 60 | 60 | $separator = $this->getCFGDef('tagsSeparator','||');
|
| 61 | 61 | if (!empty($tag) && !empty($separator)) {
|
| 62 | 62 | $_tag = explode($separator,$tag); |
| 63 | - if (count($_tag) > 1) $tag = $_tag; |
|
| 63 | + if (count($_tag) > 1) {
|
|
| 64 | + $tag = $_tag; |
|
| 65 | + } |
|
| 64 | 66 | } |
| 65 | 67 | break; |
| 66 | 68 | } |