@@ -2,7 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | use EvolutionCMS\Interfaces\ContextMenuInterface; |
| 4 | 4 | |
| 5 | -class ContextMenu implements ContextMenuInterface{ |
|
| 5 | +class ContextMenu implements ContextMenuInterface |
|
| 6 | +{ |
|
| 6 | 7 | public $id; |
| 7 | 8 | /** |
| 8 | 9 | * @var string |
@@ -19,7 +20,8 @@ discard block |
||
| 19 | 20 | |
| 20 | 21 | public static $cnt; |
| 21 | 22 | |
| 22 | - public function __construct($id = '', $width = 120, $visible = false) { |
|
| 23 | + public function __construct($id = '', $width = 120, $visible = false) |
|
| 24 | + { |
|
| 23 | 25 | self::$cnt++; |
| 24 | 26 | $this->html = ""; |
| 25 | 27 | $this->visible = $visible ? $visible : false; |
@@ -27,7 +29,8 @@ discard block |
||
| 27 | 29 | $this->id = $id ? $id : "cntxMnu" . self::$cnt; // set id |
| 28 | 30 | } |
| 29 | 31 | |
| 30 | - public function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
| 32 | + public function addItem($text, $action = "", $img = "", $disabled = 0) |
|
| 33 | + { |
|
| 31 | 34 | global $base_url, $_style; |
| 32 | 35 | if($disabled) { |
| 33 | 36 | return; |
@@ -52,13 +55,15 @@ discard block |
||
| 52 | 55 | $this->html .= $img . ' ' . $text . '</div>'; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | - public function addSeparator() { |
|
| 58 | + public function addSeparator() |
|
| 59 | + { |
|
| 56 | 60 | $this->html .= " |
| 57 | 61 | <div class='cntxMnuSeparator'></div> |
| 58 | 62 | "; |
| 59 | 63 | } |
| 60 | 64 | |
| 61 | - public function render() { |
|
| 65 | + public function render() |
|
| 66 | + { |
|
| 62 | 67 | $ContextMenuScript = <<<BLOCK |
| 63 | 68 | <script> |
| 64 | 69 | function getCntxMenu(id) { |
@@ -76,7 +81,8 @@ discard block |
||
| 76 | 81 | return $html; |
| 77 | 82 | } |
| 78 | 83 | |
| 79 | - public function getClientScriptObject() { |
|
| 84 | + public function getClientScriptObject() |
|
| 85 | + { |
|
| 80 | 86 | return "getCntxMenu('" . $this->id . "')"; |
| 81 | 87 | } |
| 82 | 88 | } |
@@ -11,7 +11,8 @@ discard block |
||
| 11 | 11 | # ----------------------------------------- |
| 12 | 12 | # |
| 13 | 13 | |
| 14 | -class DataSetPager implements DataSetPagerInterface{ |
|
| 14 | +class DataSetPager implements DataSetPagerInterface |
|
| 15 | +{ |
|
| 15 | 16 | |
| 16 | 17 | public $ds; // datasource |
| 17 | 18 | public $pageSize; |
@@ -33,7 +34,8 @@ discard block |
||
| 33 | 34 | public $renderPagerFncArgs; |
| 34 | 35 | public static $dataSetPagerCnt; |
| 35 | 36 | |
| 36 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
| 37 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
| 38 | + { |
|
| 37 | 39 | global $_PAGE; // use view state object |
| 38 | 40 | |
| 39 | 41 | // set id |
@@ -61,35 +63,42 @@ discard block |
||
| 61 | 63 | $this->pager = ''; |
| 62 | 64 | } |
| 63 | 65 | |
| 64 | - public function getRenderedPager() { |
|
| 66 | + public function getRenderedPager() |
|
| 67 | + { |
|
| 65 | 68 | return $this->pager; |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | - public function getRenderedRows() { |
|
| 71 | + public function getRenderedRows() |
|
| 72 | + { |
|
| 69 | 73 | return $this->rows; |
| 70 | 74 | } |
| 71 | 75 | |
| 72 | - public function setDataSource($ds) { |
|
| 76 | + public function setDataSource($ds) |
|
| 77 | + { |
|
| 73 | 78 | $this->ds = $ds; |
| 74 | 79 | } |
| 75 | 80 | |
| 76 | - public function setPageSize($ps) { |
|
| 81 | + public function setPageSize($ps) |
|
| 82 | + { |
|
| 77 | 83 | $this->pageSize = $ps; |
| 78 | 84 | } |
| 79 | 85 | |
| 80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
| 86 | + public function setRenderRowFnc($fncName, $args = "") |
|
| 87 | + { |
|
| 81 | 88 | $this->renderRowFnc = &$fncName; |
| 82 | 89 | $this->renderRowFncArgs = $args; // extra agruments |
| 83 | 90 | |
| 84 | 91 | |
| 85 | 92 | } |
| 86 | 93 | |
| 87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
| 94 | + public function setRenderPagerFnc($fncName, $args = "") |
|
| 95 | + { |
|
| 88 | 96 | $this->renderPagerFnc = $fncName; |
| 89 | 97 | $this->renderPagerFncArgs = $args; // extra agruments |
| 90 | 98 | } |
| 91 | 99 | |
| 92 | - public function render() { |
|
| 100 | + public function render() |
|
| 101 | + { |
|
| 93 | 102 | $modx = evolutionCMS(); global $_PAGE; |
| 94 | 103 | |
| 95 | 104 | $isDataset = $modx->getDatabase()->isResult($this->ds); |
@@ -142,8 +151,10 @@ discard block |
||
| 142 | 151 | $url = $_SERVER['PHP_SELF'] . '?'; |
| 143 | 152 | } |
| 144 | 153 | $i = 0; |
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 154 | + foreach($_GET as $n => $v) { |
|
| 155 | + if($n != 'dpgn' . $this->id) { |
|
| 146 | 156 | $i++; |
| 157 | + } |
|
| 147 | 158 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
| 148 | 159 | } |
| 149 | 160 | if($i >= 1) { |
@@ -1,8 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | $userid = (int)$value; |
| 3 | 3 | if (!isset($modx->getModifiers()->cache['ui'][$userid])) { |
| 4 | - if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid)); |
|
| 5 | - else $user = $modx->getUserInfo($userid); |
|
| 4 | + if ($userid < 0) { |
|
| 5 | + $user = $modx->getWebUserInfo(abs($userid)); |
|
| 6 | + } else { |
|
| 7 | + $user = $modx->getUserInfo($userid); |
|
| 8 | + } |
|
| 6 | 9 | $modx->getModifiers()->cache['ui'][$userid] = $user; |
| 7 | 10 | } else { |
| 8 | 11 | $user = $modx->getModifiers()->cache['ui'][$userid]; |
@@ -1,9 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(strpos($opt,',')) list($limit,$delim) = explode(',', $opt); |
|
| 3 | -elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} |
|
| 4 | -else {$limit=124;$delim='';} |
|
| 2 | +if(strpos($opt,',')) { |
|
| 3 | + list($limit,$delim) = explode(',', $opt); |
|
| 4 | +} elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} else {$limit=124;$delim='';} |
|
| 5 | 5 | |
| 6 | -if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
| 6 | +if($delim==='') { |
|
| 7 | + $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
| 8 | +} |
|
| 7 | 9 | $limit = (int)$limit; |
| 8 | 10 | |
| 9 | 11 | $content = $modx->getModifiers()->parseDocumentSource($value); |
@@ -11,8 +13,9 @@ discard block |
||
| 11 | 13 | $content = strip_tags($content); |
| 12 | 14 | |
| 13 | 15 | $content = str_replace(array("\r\n","\r","\n","\t",' '),' ',$content); |
| 14 | -if(preg_match('/\s+/',$content)) |
|
| 16 | +if(preg_match('/\s+/',$content)) { |
|
| 15 | 17 | $content = preg_replace('/\s+/',' ',$content); |
| 18 | +} |
|
| 16 | 19 | $content = trim($content); |
| 17 | 20 | |
| 18 | 21 | $pos = $modx->getModifiers()->strpos($content, $delim); |
@@ -21,23 +24,35 @@ discard block |
||
| 21 | 24 | $_ = explode($delim, $content); |
| 22 | 25 | $text = ''; |
| 23 | 26 | foreach($_ as $v) { |
| 24 | - if($limit <= $modx->getModifiers()->strlen($text.$v.$delim)) break; |
|
| 27 | + if($limit <= $modx->getModifiers()->strlen($text.$v.$delim)) { |
|
| 28 | + break; |
|
| 29 | + } |
|
| 25 | 30 | $text .= $v.$delim; |
| 26 | 31 | } |
| 27 | - if($text) $content = $text; |
|
| 28 | -} |
|
| 32 | + if($text) { |
|
| 33 | + $content = $text; |
|
| 34 | + } |
|
| 35 | + } |
|
| 29 | 36 | |
| 30 | 37 | if($limit<$modx->getModifiers()->strlen($content) && strpos($content,' ')!==false) { |
| 31 | 38 | $_ = explode(' ', $content); |
| 32 | 39 | $text = ''; |
| 33 | 40 | foreach($_ as $v) { |
| 34 | - if($limit <= $modx->getModifiers()->strlen($text.$v.' ')) break; |
|
| 41 | + if($limit <= $modx->getModifiers()->strlen($text.$v.' ')) { |
|
| 42 | + break; |
|
| 43 | + } |
|
| 35 | 44 | $text .= $v . ' '; |
| 36 | 45 | } |
| 37 | - if($text!=='') $content = $text; |
|
| 38 | -} |
|
| 46 | + if($text!=='') { |
|
| 47 | + $content = $text; |
|
| 48 | + } |
|
| 49 | + } |
|
| 39 | 50 | |
| 40 | -if($limit < $modx->getModifiers()->strlen($content)) $content = $modx->getModifiers()->substr($content, 0, $limit); |
|
| 41 | -if($modx->getModifiers()->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim; |
|
| 51 | +if($limit < $modx->getModifiers()->strlen($content)) { |
|
| 52 | + $content = $modx->getModifiers()->substr($content, 0, $limit); |
|
| 53 | +} |
|
| 54 | +if($modx->getModifiers()->substr($content,-1)==$delim) { |
|
| 55 | + $content = rtrim($content,$delim) . $delim; |
|
| 56 | +} |
|
| 42 | 57 | |
| 43 | 58 | return $content; |
@@ -5,11 +5,14 @@ discard block |
||
| 5 | 5 | $groupNames = ($this->strlen($opt) > 0 ) ? explode(',',$opt) : array(); |
| 6 | 6 | |
| 7 | 7 | // if $groupNames is not an array return false |
| 8 | -if(!is_array($groupNames)) return 0; |
|
| 8 | +if(!is_array($groupNames)) { |
|
| 9 | + return 0; |
|
| 10 | +} |
|
| 9 | 11 | |
| 10 | 12 | // Creates an array with all webgroups the user id is in |
| 11 | -if (isset($modx->getModifiers()->cache['mo'][$userID])) $grpNames = $modx->getModifiers()->cache['mo'][$userID]; |
|
| 12 | -else { |
|
| 13 | +if (isset($modx->getModifiers()->cache['mo'][$userID])) { |
|
| 14 | + $grpNames = $modx->getModifiers()->cache['mo'][$userID]; |
|
| 15 | +} else { |
|
| 13 | 16 | $from = sprintf("[+prefix+]webgroup_names wgn INNER JOIN [+prefix+]web_groups wg ON wg.webgroup=wgn.id AND wg.webuser='%s'",$userID); |
| 14 | 17 | $rs = $modx->getDatabase()->select('wgn.name',$from); |
| 15 | 18 | $modx->getModifiers()->cache['mo'][$userID] = $grpNames = $modx->getDatabase()->getColumn('name',$rs); |
@@ -17,8 +20,10 @@ discard block |
||
| 17 | 20 | |
| 18 | 21 | // Check if a supplied group matches a webgroup from the array we just created |
| 19 | 22 | foreach($groupNames as $k=>$v) { |
| 20 | - if(in_array(trim($v),$grpNames)) return 1; |
|
| 21 | -} |
|
| 23 | + if(in_array(trim($v),$grpNames)) { |
|
| 24 | + return 1; |
|
| 25 | + } |
|
| 26 | + } |
|
| 22 | 27 | |
| 23 | 28 | // If we get here the above logic did not find a match, so return false |
| 24 | 29 | return 0; |
@@ -380,10 +380,12 @@ |
||
| 380 | 380 | $failedlogins += 1; |
| 381 | 381 | |
| 382 | 382 | $fields = array('failedlogincount' => $failedlogins); |
| 383 | - if ($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
| 383 | + if ($failedlogins >= $failed_allowed) { |
|
| 384 | + //block user for too many fail attempts |
|
| 384 | 385 | { |
| 385 | 386 | $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
| 386 | 387 | } |
| 388 | + } |
|
| 387 | 389 | |
| 388 | 390 | $modx->getDatabase()->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
| 389 | 391 | |
@@ -573,7 +573,8 @@ |
||
| 573 | 573 | * @return array|string |
| 574 | 574 | */ |
| 575 | 575 | function parseInput($src, $delim = "||", $type = "string", $columns = true) |
| 576 | - { // type can be: string, array |
|
| 576 | + { |
|
| 577 | +// type can be: string, array |
|
| 577 | 578 | $modx = evolutionCMS(); |
| 578 | 579 | if ($modx->getDatabase()->isResult($src)) { |
| 579 | 580 | // must be a recordset |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | * @see https://github.com/theseer/Autoload |
| 4 | 4 | */ |
| 5 | 5 | spl_autoload_register( |
| 6 | - function($class) { |
|
| 6 | + function($class){ |
|
| 7 | 7 | static $classes = null; |
| 8 | 8 | if ($classes === null) { |
| 9 | 9 | $classes = array( |
@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | $modx->getDatabase()->connect(); |
| 9 | 9 | |
| 10 | -if (empty ($modx->config)) {
|
|
| 10 | +if (empty ($modx->config)) { |
|
| 11 | 11 | $modx->getSettings(); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
|
|
| 14 | +if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) { |
|
| 15 | 15 | $modx->sendErrorPage(); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $_lang = array(); |
| 22 | 22 | include_once MODX_MANAGER_PATH . '/includes/lang/english.inc.php'; |
| 23 | -if ($modx->config['manager_language'] != 'english') {
|
|
| 23 | +if ($modx->config['manager_language'] != 'english') { |
|
| 24 | 24 | include_once MODX_MANAGER_PATH . '/includes/lang/' . $modx->config['manager_language'] . '.inc.php'; |
| 25 | 25 | } |
| 26 | 26 | include_once MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/style.php'; |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | // set limit sql query |
| 34 | 34 | $limit = !empty($modx->config['number_of_results']) ? (int) $modx->config['number_of_results'] : 100; |
| 35 | 35 | |
| 36 | -if (isset($action)) {
|
|
| 37 | - switch ($action) {
|
|
| 36 | +if (isset($action)) { |
|
| 37 | + switch ($action) { |
|
| 38 | 38 | |
| 39 | 39 | case '1': {
|
| 40 | 40 | |
| 41 | - switch ($frame) {
|
|
| 41 | + switch ($frame) { |
|
| 42 | 42 | case 'nodes': |
| 43 | 43 | include_once MODX_MANAGER_PATH . '/frames/nodes.php'; |
| 44 | 44 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $elements = isset($_REQUEST['elements']) && is_scalar($_REQUEST['elements']) ? htmlentities($_REQUEST['elements']) : ''; |
| 54 | 54 | |
| 55 | - if ($elements) {
|
|
| 55 | + if ($elements) { |
|
| 56 | 56 | $output = ''; |
| 57 | 57 | $items = ''; |
| 58 | 58 | $sql = ''; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $sqlLike = $filter ? 'WHERE t1.name LIKE "' . $modx->getDatabase()->escape($filter) . '%"' : ''; |
| 62 | 62 | $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit; |
| 63 | 63 | |
| 64 | - switch ($elements) {
|
|
| 64 | + switch ($elements) { |
|
| 65 | 65 | case 'element_templates': |
| 66 | 66 | $a = 16; |
| 67 | 67 | $sqlLike = $filter ? 'WHERE t1.templatename LIKE "' . $modx->getDatabase()->escape($filter) . '%"' : ''; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ORDER BY t1.templatename ASC |
| 72 | 72 | ' . $sqlLimit); |
| 73 | 73 | |
| 74 | - if ($modx->hasPermission('new_template')) {
|
|
| 74 | + if ($modx->hasPermission('new_template')) { |
|
| 75 | 75 | $output .= '<li><a id="a_19" href="index.php?a=19" target="main"><i class="fa fa-plus"></i>' . $_lang['new_template'] . '</a></li>'; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | ORDER BY t1.name ASC |
| 88 | 88 | ' . $sqlLimit); |
| 89 | 89 | |
| 90 | - if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) {
|
|
| 90 | + if ($modx->hasPermission('edit_template') && $modx->hasPermission('edit_snippet') && $modx->hasPermission('edit_chunk') && $modx->hasPermission('edit_plugin')) { |
|
| 91 | 91 | $output .= '<li><a id="a_300" href="index.php?a=300" target="main"><i class="fa fa-plus"></i>' . $_lang['new_tmplvars'] . '</a></li>'; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | ORDER BY t1.name ASC |
| 102 | 102 | ' . $sqlLimit); |
| 103 | 103 | |
| 104 | - if ($modx->hasPermission('new_chunk')) {
|
|
| 104 | + if ($modx->hasPermission('new_chunk')) { |
|
| 105 | 105 | $output .= '<li><a id="a_77" href="index.php?a=77" target="main"><i class="fa fa-plus"></i>' . $_lang['new_htmlsnippet'] . '</a></li>'; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | ORDER BY t1.name ASC |
| 116 | 116 | ' . $sqlLimit); |
| 117 | 117 | |
| 118 | - if ($modx->hasPermission('new_snippet')) {
|
|
| 118 | + if ($modx->hasPermission('new_snippet')) { |
|
| 119 | 119 | $output .= '<li><a id="a_23" href="index.php?a=23" target="main"><i class="fa fa-plus"></i>' . $_lang['new_snippet'] . '</a></li>'; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -129,19 +129,19 @@ discard block |
||
| 129 | 129 | ORDER BY t1.name ASC |
| 130 | 130 | ' . $sqlLimit); |
| 131 | 131 | |
| 132 | - if ($modx->hasPermission('new_plugin')) {
|
|
| 132 | + if ($modx->hasPermission('new_plugin')) { |
|
| 133 | 133 | $output .= '<li><a id="a_101" href="index.php?a=101" target="main"><i class="fa fa-plus"></i>' . $_lang['new_plugin'] . '</a></li>'; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | break; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ($count = $modx->getDatabase()->getRecordCount($sql)) {
|
|
| 140 | - if ($count == $limit) {
|
|
| 139 | + if ($count = $modx->getDatabase()->getRecordCount($sql)) { |
|
| 140 | + if ($count == $limit) { |
|
| 141 | 141 | $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>'; |
| 142 | 142 | } |
| 143 | - while ($row = $modx->getDatabase()->getRow($sql)) {
|
|
| 144 | - if (($row['disabled'] || $row['locked']) && $role != 1) {
|
|
| 143 | + while ($row = $modx->getDatabase()->getRow($sql)) { |
|
| 144 | + if (($row['disabled'] || $row['locked']) && $role != 1) { |
|
| 145 | 145 | continue; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if (isset($_REQUEST['filter'])) {
|
|
| 152 | + if (isset($_REQUEST['filter'])) { |
|
| 153 | 153 | $output = $items; |
| 154 | - } else {
|
|
| 154 | + } else { |
|
| 155 | 155 | $output .= $items; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->getDatabase()->escape($filter) . '%"' : ''; |
| 170 | 170 | $sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit; |
| 171 | 171 | |
| 172 | - if(!$modx->hasPermission('save_role')) {
|
|
| 172 | + if(!$modx->hasPermission('save_role')) { |
|
| 173 | 173 | $sqlLike .= $sqlLike ? ' AND ' : 'WHERE '; |
| 174 | 174 | $sqlLike .= 't2.role != 1'; |
| 175 | 175 | } |
@@ -181,22 +181,22 @@ discard block |
||
| 181 | 181 | ORDER BY t1.username ASC |
| 182 | 182 | ' . $sqlLimit); |
| 183 | 183 | |
| 184 | - if ($modx->hasPermission('new_user')) {
|
|
| 184 | + if ($modx->hasPermission('new_user')) { |
|
| 185 | 185 | $output .= '<li><a id="a_11" href="index.php?a=11" target="main"><i class="fa fa-plus"></i>' . $_lang['new_user'] . '</a></li>'; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if ($count = $modx->getDatabase()->getRecordCount($sql)) {
|
|
| 189 | - if ($count == $limit) {
|
|
| 188 | + if ($count = $modx->getDatabase()->getRecordCount($sql)) { |
|
| 189 | + if ($count == $limit) { |
|
| 190 | 190 | $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>'; |
| 191 | 191 | } |
| 192 | - while ($row = $modx->getDatabase()->getRow($sql)) {
|
|
| 192 | + while ($row = $modx->getDatabase()->getRow($sql)) { |
|
| 193 | 193 | $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if (isset($_REQUEST['filter'])) {
|
|
| 197 | + if (isset($_REQUEST['filter'])) { |
|
| 198 | 198 | $output = $items; |
| 199 | - } else {
|
|
| 199 | + } else { |
|
| 200 | 200 | $output .= $items; |
| 201 | 201 | } |
| 202 | 202 | |
@@ -220,22 +220,22 @@ discard block |
||
| 220 | 220 | ORDER BY t1.username ASC |
| 221 | 221 | ' . $sqlLimit); |
| 222 | 222 | |
| 223 | - if ($modx->hasPermission('new_web_user')) {
|
|
| 223 | + if ($modx->hasPermission('new_web_user')) { |
|
| 224 | 224 | $output .= '<li><a id="a_87" href="index.php?a=87" target="main"><i class="fa fa-plus"></i>' . $_lang['new_web_user'] . '</a></li>'; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ($count = $modx->getDatabase()->getRecordCount($sql)) {
|
|
| 228 | - if ($count == $limit) {
|
|
| 227 | + if ($count = $modx->getDatabase()->getRecordCount($sql)) { |
|
| 228 | + if ($count == $limit) { |
|
| 229 | 229 | $output .= '<li class="item-input"><input type="text" name="filter" class="dropdown-item form-control form-control-sm" autocomplete="off" /></li>'; |
| 230 | 230 | } |
| 231 | - while ($row = $modx->getDatabase()->getRow($sql)) {
|
|
| 231 | + while ($row = $modx->getDatabase()->getRow($sql)) { |
|
| 232 | 232 | $items .= '<li class="item ' . ($row['blocked'] ? 'disabled' : '') . '"><a id="a_' . $a . '__id_' . $row['id'] . '" href="index.php?a=' . $a . '&id=' . $row['id'] . '" target="main">' . $row['name'] . ' <small>(' . $row['id'] . ')</small></a></li>';
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if (isset($_REQUEST['filter'])) {
|
|
| 236 | + if (isset($_REQUEST['filter'])) { |
|
| 237 | 237 | $output = $items; |
| 238 | - } else {
|
|
| 238 | + } else { |
|
| 239 | 239 | $output .= $items; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | $type = isset($_REQUEST['type']) && is_scalar($_REQUEST['type']) ? $modx->getDatabase()->escape($_REQUEST['type']) : false; |
| 250 | 250 | $contextmenu = ''; |
| 251 | 251 | |
| 252 | - if ($role && $name && $type) {
|
|
| 253 | - switch ($type) {
|
|
| 252 | + if ($role && $name && $type) { |
|
| 253 | + switch ($type) { |
|
| 254 | 254 | case 'Snippet': |
| 255 | 255 | case 'SnippetNoCache': {
|
| 256 | 256 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | WHERE name="' . $name . '" |
| 260 | 260 | LIMIT 1'); |
| 261 | 261 | |
| 262 | - if ($modx->getDatabase()->getRecordCount($sql)) {
|
|
| 262 | + if ($modx->getDatabase()->getRecordCount($sql)) { |
|
| 263 | 263 | $row = $modx->getDatabase()->getRow($sql); |
| 264 | 264 | $contextmenu = array( |
| 265 | 265 | 'header' => array( |
@@ -270,13 +270,13 @@ discard block |
||
| 270 | 270 | 'url' => "index.php?a=22&id=" . $row['id'] |
| 271 | 271 | ) |
| 272 | 272 | ); |
| 273 | - if (!empty($row['description'])) {
|
|
| 273 | + if (!empty($row['description'])) { |
|
| 274 | 274 | $contextmenu['seperator'] = ''; |
| 275 | 275 | $contextmenu['description'] = array( |
| 276 | 276 | 'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description'] |
| 277 | 277 | ); |
| 278 | 278 | } |
| 279 | - } else {
|
|
| 279 | + } else { |
|
| 280 | 280 | $contextmenu = array( |
| 281 | 281 | 'header' => array( |
| 282 | 282 | 'innerHTML' => '<i class="fa fa-code"></i> ' . $name |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | WHERE name="' . $name . '" |
| 298 | 298 | LIMIT 1'); |
| 299 | 299 | |
| 300 | - if ($modx->getDatabase()->getRecordCount($sql)) {
|
|
| 300 | + if ($modx->getDatabase()->getRecordCount($sql)) { |
|
| 301 | 301 | $row = $modx->getDatabase()->getRow($sql); |
| 302 | 302 | $contextmenu = array( |
| 303 | 303 | 'header' => array( |
@@ -308,13 +308,13 @@ discard block |
||
| 308 | 308 | 'url' => "index.php?a=78&id=" . $row['id'] |
| 309 | 309 | ) |
| 310 | 310 | ); |
| 311 | - if (!empty($row['description'])) {
|
|
| 311 | + if (!empty($row['description'])) { |
|
| 312 | 312 | $contextmenu['seperator'] = ''; |
| 313 | 313 | $contextmenu['description'] = array( |
| 314 | 314 | 'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description'] |
| 315 | 315 | ); |
| 316 | 316 | } |
| 317 | - } else {
|
|
| 317 | + } else { |
|
| 318 | 318 | $contextmenu = array( |
| 319 | 319 | 'header' => array( |
| 320 | 320 | 'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | WHERE name="' . $name . '" |
| 335 | 335 | LIMIT 1'); |
| 336 | 336 | |
| 337 | - if ($modx->getDatabase()->getRecordCount($sql)) {
|
|
| 337 | + if ($modx->getDatabase()->getRecordCount($sql)) { |
|
| 338 | 338 | $row = $modx->getDatabase()->getRow($sql); |
| 339 | 339 | $contextmenu = array( |
| 340 | 340 | 'header' => array( |
@@ -345,20 +345,20 @@ discard block |
||
| 345 | 345 | 'url' => "index.php?a=78&id=" . $row['id'] |
| 346 | 346 | ) |
| 347 | 347 | ); |
| 348 | - if (!empty($row['description'])) {
|
|
| 348 | + if (!empty($row['description'])) { |
|
| 349 | 349 | $contextmenu['seperator'] = ''; |
| 350 | 350 | $contextmenu['description'] = array( |
| 351 | 351 | 'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description'] |
| 352 | 352 | ); |
| 353 | 353 | } |
| 354 | - } else {
|
|
| 354 | + } else { |
|
| 355 | 355 | |
| 356 | 356 | $sql = $modx->getDatabase()->query('SELECT *
|
| 357 | 357 | FROM ' . $modx->getFullTableName('site_snippets') . '
|
| 358 | 358 | WHERE name="' . $name . '" |
| 359 | 359 | LIMIT 1'); |
| 360 | 360 | |
| 361 | - if ($modx->getDatabase()->getRecordCount($sql)) {
|
|
| 361 | + if ($modx->getDatabase()->getRecordCount($sql)) { |
|
| 362 | 362 | $row = $modx->getDatabase()->getRow($sql); |
| 363 | 363 | $contextmenu = array( |
| 364 | 364 | 'header' => array( |
@@ -369,13 +369,13 @@ discard block |
||
| 369 | 369 | 'url' => "index.php?a=22&id=" . $row['id'] |
| 370 | 370 | ) |
| 371 | 371 | ); |
| 372 | - if (!empty($row['description'])) {
|
|
| 372 | + if (!empty($row['description'])) { |
|
| 373 | 373 | $contextmenu['seperator'] = ''; |
| 374 | 374 | $contextmenu['description'] = array( |
| 375 | 375 | 'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description'] |
| 376 | 376 | ); |
| 377 | 377 | } |
| 378 | - } else {
|
|
| 378 | + } else { |
|
| 379 | 379 | $contextmenu = array( |
| 380 | 380 | 'header' => array( |
| 381 | 381 | 'innerHTML' => '<i class="fa fa-code"></i> ' . $name |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | 'alias_visible' |
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | - if (in_array($name, $default_field)) {
|
|
| 440 | + if (in_array($name, $default_field)) { |
|
| 441 | 441 | return; |
| 442 | 442 | } |
| 443 | 443 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | WHERE name="' . $name . '" |
| 447 | 447 | LIMIT 1'); |
| 448 | 448 | |
| 449 | - if ($modx->getDatabase()->getRecordCount($sql)) {
|
|
| 449 | + if ($modx->getDatabase()->getRecordCount($sql)) { |
|
| 450 | 450 | $row = $modx->getDatabase()->getRow($sql); |
| 451 | 451 | $contextmenu = array( |
| 452 | 452 | 'header' => array( |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | 'url' => "index.php?a=301&id=" . $row['id'] |
| 458 | 458 | ) |
| 459 | 459 | ); |
| 460 | - if (!empty($row['description'])) {
|
|
| 460 | + if (!empty($row['description'])) { |
|
| 461 | 461 | $contextmenu['seperator'] = ''; |
| 462 | 462 | $contextmenu['description'] = array( |
| 463 | 463 | 'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description'] |
| 464 | 464 | ); |
| 465 | 465 | } |
| 466 | - } else {
|
|
| 466 | + } else { |
|
| 467 | 467 | $contextmenu = array( |
| 468 | 468 | 'header' => array( |
| 469 | 469 | 'innerHTML' => '<i class="fa fa-list-alt"></i> ' . $name |
@@ -488,13 +488,13 @@ discard block |
||
| 488 | 488 | case 'movedocument' : {
|
| 489 | 489 | $json = array(); |
| 490 | 490 | |
| 491 | - if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
|
|
| 491 | + if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) { |
|
| 492 | 492 | $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : ''; |
| 493 | 493 | $parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0; |
| 494 | 494 | $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0; |
| 495 | 495 | |
| 496 | 496 | // set parent |
| 497 | - if ($id && $parent >= 0) {
|
|
| 497 | + if ($id && $parent >= 0) { |
|
| 498 | 498 | |
| 499 | 499 | // find older parent |
| 500 | 500 | $parentOld = $modx->getDatabase()->getValue($modx->getDatabase()->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id));
|
@@ -505,31 +505,31 @@ discard block |
||
| 505 | 505 | 'new_parent' => $parent, |
| 506 | 506 | ]); |
| 507 | 507 | |
| 508 | - if (is_array($eventOut) && count($eventOut) > 0) {
|
|
| 508 | + if (is_array($eventOut) && count($eventOut) > 0) { |
|
| 509 | 509 | $eventParent = array_pop($eventOut); |
| 510 | 510 | |
| 511 | - if ($eventParent == $parentOld) {
|
|
| 511 | + if ($eventParent == $parentOld) { |
|
| 512 | 512 | $json['errors'] = $_lang['error_movedocument2']; |
| 513 | - } else {
|
|
| 513 | + } else { |
|
| 514 | 514 | $parent = $eventParent; |
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - if (empty($json['errors'])) {
|
|
| 518 | + if (empty($json['errors'])) { |
|
| 519 | 519 | // check privileges user for move docs |
| 520 | - if (!empty($modx->config['tree_show_protected']) && $role != 1) {
|
|
| 520 | + if (!empty($modx->config['tree_show_protected']) && $role != 1) { |
|
| 521 | 521 | $sql = $modx->getDatabase()->select('*', $modx->getFullTableName('document_groups'), 'document IN(' . $id . ',' . $parent . ',' . $parentOld . ')');
|
| 522 | - if ($modx->getDatabase()->getRecordCount($sql)) {
|
|
| 522 | + if ($modx->getDatabase()->getRecordCount($sql)) { |
|
| 523 | 523 | $document_groups = array(); |
| 524 | - while ($row = $modx->getDatabase()->getRow($sql)) {
|
|
| 524 | + while ($row = $modx->getDatabase()->getRow($sql)) { |
|
| 525 | 525 | $document_groups[$row['document']]['groups'][] = $row['document_group']; |
| 526 | 526 | } |
| 527 | - foreach ($document_groups as $key => $value) {
|
|
| 528 | - if (($key == $parent || $key == $parentOld || $key == $id) && !in_array($role, $value['groups'])) {
|
|
| 527 | + foreach ($document_groups as $key => $value) { |
|
| 528 | + if (($key == $parent || $key == $parentOld || $key == $id) && !in_array($role, $value['groups'])) { |
|
| 529 | 529 | $json['errors'] = $_lang["error_no_privileges"]; |
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | - if ($json['errors']) {
|
|
| 532 | + if ($json['errors']) { |
|
| 533 | 533 | header('content-type: application/json');
|
| 534 | 534 | echo json_encode($json, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE); |
| 535 | 535 | break; |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if ($parent == 0 && $parent != $parentOld && !$modx->config['udperms_allowroot'] && $role != 1) {
|
|
| 540 | + if ($parent == 0 && $parent != $parentOld && !$modx->config['udperms_allowroot'] && $role != 1) { |
|
| 541 | 541 | $json['errors'] = $_lang["error_no_privileges"]; |
| 542 | - } else {
|
|
| 542 | + } else { |
|
| 543 | 543 | // set new parent |
| 544 | 544 | $modx->getDatabase()->update(array( |
| 545 | 545 | 'parent' => $parent |
@@ -549,13 +549,13 @@ discard block |
||
| 549 | 549 | 'isfolder' => 1 |
| 550 | 550 | ), $modx->getFullTableName('site_content'), 'id=' . $parent);
|
| 551 | 551 | |
| 552 | - if ($parent != $parentOld) {
|
|
| 552 | + if ($parent != $parentOld) { |
|
| 553 | 553 | // check children docs and set parent isfolder |
| 554 | - if ($modx->getDatabase()->getRecordCount($modx->getDatabase()->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) {
|
|
| 554 | + if ($modx->getDatabase()->getRecordCount($modx->getDatabase()->select('id', $modx->getFullTableName('site_content'), 'parent=' . $parentOld))) { |
|
| 555 | 555 | $modx->getDatabase()->update(array( |
| 556 | 556 | 'isfolder' => 1 |
| 557 | 557 | ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
|
| 558 | - } else {
|
|
| 558 | + } else { |
|
| 559 | 559 | $modx->getDatabase()->update(array( |
| 560 | 560 | 'isfolder' => 0 |
| 561 | 561 | ), $modx->getFullTableName('site_content'), 'id=' . $parentOld);
|
@@ -563,16 +563,16 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | // set menuindex |
| 566 | - if (!empty($menuindex)) {
|
|
| 566 | + if (!empty($menuindex)) { |
|
| 567 | 567 | $menuindex = explode(',', $menuindex);
|
| 568 | - foreach ($menuindex as $key => $value) {
|
|
| 568 | + foreach ($menuindex as $key => $value) { |
|
| 569 | 569 | $modx->getDatabase()->query('UPDATE ' . $modx->getFullTableName('site_content') . ' SET menuindex=' . $key . ' WHERE id=' . $value);
|
| 570 | 570 | } |
| 571 | - } else {
|
|
| 571 | + } else { |
|
| 572 | 572 | // TODO: max(*) menuindex |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if (!$json['errors']) {
|
|
| 575 | + if (!$json['errors']) { |
|
| 576 | 576 | $json['success'] = $_lang["actioncomplete"]; |
| 577 | 577 | |
| 578 | 578 | $modx->invokeEvent('onAfterMoveDocument', [
|
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | - } else {
|
|
| 587 | + } else { |
|
| 588 | 588 | $json['errors'] = $_lang["error_no_privileges"]; |
| 589 | 589 | } |
| 590 | 590 | |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | $output = !!$modx->elementIsLocked($type, $id, true); |
| 602 | 602 | |
| 603 | - if (!$output) {
|
|
| 603 | + if (!$output) { |
|
| 604 | 604 | $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
|
| 605 | 605 | $docgrp_cond = $docgrp ? ' OR dg.document_group IN (' . $docgrp . ')' : '';
|
| 606 | 606 | $sql = ' |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | LEFT JOIN ' . $modx->getFullTableName('document_groups') . ' dg ON dg.document=sc.id
|
| 610 | 610 | WHERE sc.id=' . $id . ' GROUP BY sc.id'; |
| 611 | 611 | $sql = $modx->getDatabase()->query($sql); |
| 612 | - if ($modx->getDatabase()->getRecordCount($sql)) {
|
|
| 612 | + if ($modx->getDatabase()->getRecordCount($sql)) { |
|
| 613 | 613 | $row = $modx->getDatabase()->getRow($sql); |
| 614 | 614 | $output = !!$row['locked']; |
| 615 | 615 | } |