@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | $criteria->add(new \Criteria('pageid ', $pageid)); |
| 30 | 30 | $criteria->add(new \Criteria('status ', '0', '>')); |
| 31 | 31 | if (0 == $pageHandler->getCount($criteria)) { |
| 32 | - redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST); |
|
| 33 | - exit(); |
|
| 32 | + redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST); |
|
| 33 | + exit(); |
|
| 34 | 34 | } |
| 35 | 35 | // |
| 36 | 36 | unset($criteria); |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | // Если админ и ссылка на отключение кэша |
| 44 | 44 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin() && $nocache) { |
| 45 | - // Отключаем кэш |
|
| 46 | - $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0; |
|
| 45 | + // Отключаем кэш |
|
| 46 | + $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Задание тайтла |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | // Права на просмотр инструкции |
| 61 | 61 | $categories = Xoopsmodules\instruction\Utility::getItemIds(); |
| 62 | 62 | if (!in_array($objInsinstr->getVar('cid'), $categories)) { |
| 63 | - redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 64 | - exit(); |
|
| 63 | + redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 64 | + exit(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Массив данных о странице |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | $footnote = $objInspage->getVar('footnote'); |
| 79 | 79 | // Если есть сноски |
| 80 | 80 | if ($footnote) { |
| 81 | - $pages['footnotes'] = explode('|', $objInspage->getVar('footnote')); |
|
| 81 | + $pages['footnotes'] = explode('|', $objInspage->getVar('footnote')); |
|
| 82 | 82 | } else { |
| 83 | - $pages['footnotes'] = false; |
|
| 83 | + $pages['footnotes'] = false; |
|
| 84 | 84 | } |
| 85 | 85 | // Мета-теги ключевых слов |
| 86 | 86 | $pages['keywords'] = $objInspage->getVar('keywords'); |
@@ -89,39 +89,39 @@ discard block |
||
| 89 | 89 | // |
| 90 | 90 | // Если админ, рисуем админлинк |
| 91 | 91 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
| 92 | - $pages['adminlink'] = ' <a href="' |
|
| 93 | - . XOOPS_URL |
|
| 94 | - . '/modules/' |
|
| 95 | - . $moduleDirName |
|
| 96 | - . '/admin/instr.php?op=editpage&pageid=' |
|
| 97 | - . $pages['pageid'] |
|
| 98 | - . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 99 | - . _EDIT |
|
| 100 | - . ' title=' |
|
| 101 | - . _EDIT |
|
| 102 | - . '></a> <a href="' |
|
| 103 | - . XOOPS_URL |
|
| 104 | - . '/modules/' |
|
| 105 | - . $moduleDirName |
|
| 106 | - . '/admin/instr.php?op=delpage&pageid=' |
|
| 107 | - . $pages['pageid'] |
|
| 108 | - . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 109 | - . _DELETE |
|
| 110 | - . ' title=' |
|
| 111 | - . _DELETE |
|
| 112 | - . '></a> '; |
|
| 92 | + $pages['adminlink'] = ' <a href="' |
|
| 93 | + . XOOPS_URL |
|
| 94 | + . '/modules/' |
|
| 95 | + . $moduleDirName |
|
| 96 | + . '/admin/instr.php?op=editpage&pageid=' |
|
| 97 | + . $pages['pageid'] |
|
| 98 | + . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 99 | + . _EDIT |
|
| 100 | + . ' title=' |
|
| 101 | + . _EDIT |
|
| 102 | + . '></a> <a href="' |
|
| 103 | + . XOOPS_URL |
|
| 104 | + . '/modules/' |
|
| 105 | + . $moduleDirName |
|
| 106 | + . '/admin/instr.php?op=delpage&pageid=' |
|
| 107 | + . $pages['pageid'] |
|
| 108 | + . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 109 | + . _DELETE |
|
| 110 | + . ' title=' |
|
| 111 | + . _DELETE |
|
| 112 | + . '></a> '; |
|
| 113 | 113 | } else { |
| 114 | - $pages['adminlink'] = ' '; |
|
| 115 | - // Если можно редактировать |
|
| 116 | - if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) { |
|
| 117 | - $pages['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/submit.php?op=editpage&pageid=' . $pages['pageid'] . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' . _EDIT . ' title=' . _EDIT . '></a>'; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $pages['adminlink'] .= ' '; |
|
| 121 | - // Если нет админлика |
|
| 122 | - if ('[ ]' === $pages['adminlink']) { |
|
| 123 | - $pages['adminlink'] = ''; |
|
| 124 | - } |
|
| 114 | + $pages['adminlink'] = ' '; |
|
| 115 | + // Если можно редактировать |
|
| 116 | + if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) { |
|
| 117 | + $pages['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/submit.php?op=editpage&pageid=' . $pages['pageid'] . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' . _EDIT . ' title=' . _EDIT . '></a>'; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $pages['adminlink'] .= ' '; |
|
| 121 | + // Если нет админлика |
|
| 122 | + if ('[ ]' === $pages['adminlink']) { |
|
| 123 | + $pages['adminlink'] = ''; |
|
| 124 | + } |
|
| 125 | 125 | } |
| 126 | 126 | // Выводим в шаблон |
| 127 | 127 | $GLOBALS['xoopsTpl']->assign('insPage', $pages); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $nav_parent_id = array_reverse($nav_parent_id); |
| 141 | 141 | $navigation = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a> : '; |
| 142 | 142 | foreach (array_keys($nav_parent_id) as $i) { |
| 143 | - $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 143 | + $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 144 | 144 | } |
| 145 | 145 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a> : '; |
| 146 | 146 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/instr.php?id=' . $pages['instrid'] . '">' . $objInsinstr->getVar('title') . '</a>'; |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | // Рейтинг |
| 174 | 174 | if (xoops_getModuleOption('userat', 'instruction')) { |
| 175 | - $xoopsTpl->assign('insUserat', true); |
|
| 175 | + $xoopsTpl->assign('insUserat', true); |
|
| 176 | 176 | } else { |
| 177 | - $xoopsTpl->assign('insUserat', false); |
|
| 177 | + $xoopsTpl->assign('insUserat', false); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Мета теги |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class InstructionCorePreload extends XoopsPreloadItem |
| 24 | 24 | { |
| 25 | - // to add PSR-4 autoloader |
|
| 26 | - /** |
|
| 27 | - * @param $args |
|
| 28 | - */ |
|
| 29 | - public static function eventCoreIncludeCommonEnd($args) |
|
| 30 | - { |
|
| 31 | - include __DIR__ . '/autoloader.php'; |
|
| 32 | - } |
|
| 25 | + // to add PSR-4 autoloader |
|
| 26 | + /** |
|
| 27 | + * @param $args |
|
| 28 | + */ |
|
| 29 | + public static function eventCoreIncludeCommonEnd($args) |
|
| 30 | + { |
|
| 31 | + include __DIR__ . '/autoloader.php'; |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -4,29 +4,29 @@ |
||
| 4 | 4 | * @see http://www.php-fig.org/psr/psr-4/examples/ |
| 5 | 5 | */ |
| 6 | 6 | spl_autoload_register(function ($class) { |
| 7 | - // project-specific namespace prefix |
|
| 8 | - $prefix = 'Xoopsmodules\\instruction\\'; |
|
| 7 | + // project-specific namespace prefix |
|
| 8 | + $prefix = 'Xoopsmodules\\instruction\\'; |
|
| 9 | 9 | |
| 10 | - // base directory for the namespace prefix |
|
| 11 | - $base_dir = __DIR__ . '/../class/'; |
|
| 10 | + // base directory for the namespace prefix |
|
| 11 | + $base_dir = __DIR__ . '/../class/'; |
|
| 12 | 12 | |
| 13 | - // does the class use the namespace prefix? |
|
| 14 | - $len = strlen($prefix); |
|
| 13 | + // does the class use the namespace prefix? |
|
| 14 | + $len = strlen($prefix); |
|
| 15 | 15 | |
| 16 | - if (0 !== strncmp($prefix, $class, $len)) { |
|
| 17 | - return; |
|
| 18 | - } |
|
| 16 | + if (0 !== strncmp($prefix, $class, $len)) { |
|
| 17 | + return; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - // get the relative class name |
|
| 21 | - $relative_class = substr($class, $len); |
|
| 20 | + // get the relative class name |
|
| 21 | + $relative_class = substr($class, $len); |
|
| 22 | 22 | |
| 23 | - // replace the namespace prefix with the base directory, replace namespace |
|
| 24 | - // separators with directory separators in the relative class name, append |
|
| 25 | - // with .php |
|
| 26 | - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 23 | + // replace the namespace prefix with the base directory, replace namespace |
|
| 24 | + // separators with directory separators in the relative class name, append |
|
| 25 | + // with .php |
|
| 26 | + $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 27 | 27 | |
| 28 | - // if the file exists, require it |
|
| 29 | - if (file_exists($file)) { |
|
| 30 | - require $file; |
|
| 31 | - } |
|
| 28 | + // if the file exists, require it |
|
| 29 | + if (file_exists($file)) { |
|
| 30 | + require $file; |
|
| 31 | + } |
|
| 32 | 32 | }); |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | $module = $helper->getModule(); |
| 49 | 49 | |
| 50 | 50 | if (Xoopsmodules\instruction\Utility::checkVerXoops($module, '2.5.9')) { |
| 51 | - $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
| 52 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
| 51 | + $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
| 52 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
| 53 | 53 | } else { |
| 54 | - $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
| 55 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
| 54 | + $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
| 55 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Находим список всех инструкций |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | $criteria->add(new \Criteria('status', '0', '>')); |
| 63 | 63 | // Если есть категория |
| 64 | 64 | if ($cid) { |
| 65 | - // Если нельзя просматривать эту категорию |
|
| 66 | - if (!in_array($cid, $categories)) { |
|
| 67 | - redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
| 68 | - } |
|
| 69 | - $criteria->add(new \Criteria('cid', $cid, '=')); |
|
| 70 | - // Иначе находим список всех |
|
| 65 | + // Если нельзя просматривать эту категорию |
|
| 66 | + if (!in_array($cid, $categories)) { |
|
| 67 | + redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
| 68 | + } |
|
| 69 | + $criteria->add(new \Criteria('cid', $cid, '=')); |
|
| 70 | + // Иначе находим список всех |
|
| 71 | 71 | } else { |
| 72 | - $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
| 72 | + $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Число инструкций, удовлетворяющих данному условию |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | $instr_arr = $instructionHandler->getall($criteria); |
| 87 | 87 | // Если записей больше чем $limit, то выводим пагинатор |
| 88 | 88 | if ($numrows > $limit) { |
| 89 | - $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
| 90 | - $pagenav = $pagenav->renderNav(4); |
|
| 89 | + $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
| 90 | + $pagenav = $pagenav->renderNav(4); |
|
| 91 | 91 | } else { |
| 92 | - $pagenav = ''; |
|
| 92 | + $pagenav = ''; |
|
| 93 | 93 | } |
| 94 | 94 | // Выводим пагинатор в шаблон |
| 95 | 95 | $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav); |
@@ -100,53 +100,53 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | // Если есть записи |
| 102 | 102 | if ($numrows > 0) { |
| 103 | - $class = 'odd'; |
|
| 104 | - foreach (array_keys($instr_arr) as $i) { |
|
| 105 | - |
|
| 106 | - // |
|
| 107 | - $class = ('even' === $class) ? 'odd' : 'even'; |
|
| 108 | - // ID |
|
| 109 | - $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
| 110 | - // Название |
|
| 111 | - $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
| 112 | - // Статус |
|
| 113 | - $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
| 114 | - // Количество страниц |
|
| 115 | - $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
| 116 | - // Категория |
|
| 117 | - $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
| 118 | - $insinstr_cat = $categoryHandler->get($insinstr_cid); |
|
| 119 | - // Права на добавление |
|
| 120 | - $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
| 121 | - // Права на редактирование |
|
| 122 | - $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
| 123 | - //Мета-теги ключевых слов |
|
| 124 | - $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
| 125 | - // Если есть - добавляем в мета-теги страницы |
|
| 126 | - if ($insinstr_metakeywords) { |
|
| 127 | - $index_metakeywords[] = $insinstr_metakeywords; |
|
| 128 | - } |
|
| 129 | - // Мета-теги описания |
|
| 130 | - $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
| 131 | - // Если есть - добавляем в мета-теги страницы |
|
| 132 | - if ($insinstr_metadescript) { |
|
| 133 | - $index_metadescript[] = $insinstr_metadescript; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // Выводим в шаблон |
|
| 137 | - $GLOBALS['xoopsTpl']->append('insListInstr', |
|
| 138 | - ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class]); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - // Языковые константы |
|
| 103 | + $class = 'odd'; |
|
| 104 | + foreach (array_keys($instr_arr) as $i) { |
|
| 105 | + |
|
| 106 | + // |
|
| 107 | + $class = ('even' === $class) ? 'odd' : 'even'; |
|
| 108 | + // ID |
|
| 109 | + $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
| 110 | + // Название |
|
| 111 | + $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
| 112 | + // Статус |
|
| 113 | + $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
| 114 | + // Количество страниц |
|
| 115 | + $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
| 116 | + // Категория |
|
| 117 | + $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
| 118 | + $insinstr_cat = $categoryHandler->get($insinstr_cid); |
|
| 119 | + // Права на добавление |
|
| 120 | + $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
| 121 | + // Права на редактирование |
|
| 122 | + $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
| 123 | + //Мета-теги ключевых слов |
|
| 124 | + $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
| 125 | + // Если есть - добавляем в мета-теги страницы |
|
| 126 | + if ($insinstr_metakeywords) { |
|
| 127 | + $index_metakeywords[] = $insinstr_metakeywords; |
|
| 128 | + } |
|
| 129 | + // Мета-теги описания |
|
| 130 | + $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
| 131 | + // Если есть - добавляем в мета-теги страницы |
|
| 132 | + if ($insinstr_metadescript) { |
|
| 133 | + $index_metadescript[] = $insinstr_metadescript; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // Выводим в шаблон |
|
| 137 | + $GLOBALS['xoopsTpl']->append('insListInstr', |
|
| 138 | + ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class]); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + // Языковые константы |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Если есть мета-теги |
| 145 | 145 | if (count($index_metakeywords)) { |
| 146 | - $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
| 146 | + $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
| 147 | 147 | } |
| 148 | 148 | if (count($index_metadescript)) { |
| 149 | - $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
| 149 | + $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // Подвал |
@@ -17,77 +17,77 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | trait VersionChecks |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * |
|
| 22 | - * Verifies XOOPS version meets minimum requirements for this module |
|
| 23 | - * @static |
|
| 24 | - * @param \XoopsModule|null $module |
|
| 25 | - * |
|
| 26 | - * @param null|string $requiredVer |
|
| 27 | - * @return bool true if meets requirements, false if not |
|
| 28 | - */ |
|
| 29 | - public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
| 30 | - { |
|
| 31 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
| 32 | - if (null === $module) { |
|
| 33 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 34 | - } |
|
| 35 | - xoops_loadLanguage('admin', $moduleDirName); |
|
| 36 | - //check for minimum XOOPS version |
|
| 37 | - $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
| 38 | - $currArray = explode('.', $currentVer); |
|
| 39 | - if (null === $requiredVer) { |
|
| 40 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 41 | - } |
|
| 42 | - $reqArray = explode('.', $requiredVer); |
|
| 43 | - $success = true; |
|
| 44 | - foreach ($reqArray as $k => $v) { |
|
| 45 | - if (isset($currArray[$k])) { |
|
| 46 | - if ($currArray[$k] > $v) { |
|
| 47 | - break; |
|
| 48 | - } elseif ($currArray[$k] == $v) { |
|
| 49 | - continue; |
|
| 50 | - } else { |
|
| 51 | - $success = false; |
|
| 52 | - break; |
|
| 53 | - } |
|
| 54 | - } else { |
|
| 55 | - if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
| 56 | - $success = false; |
|
| 57 | - break; |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 20 | + /** |
|
| 21 | + * |
|
| 22 | + * Verifies XOOPS version meets minimum requirements for this module |
|
| 23 | + * @static |
|
| 24 | + * @param \XoopsModule|null $module |
|
| 25 | + * |
|
| 26 | + * @param null|string $requiredVer |
|
| 27 | + * @return bool true if meets requirements, false if not |
|
| 28 | + */ |
|
| 29 | + public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
| 30 | + { |
|
| 31 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
| 32 | + if (null === $module) { |
|
| 33 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
| 34 | + } |
|
| 35 | + xoops_loadLanguage('admin', $moduleDirName); |
|
| 36 | + //check for minimum XOOPS version |
|
| 37 | + $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
| 38 | + $currArray = explode('.', $currentVer); |
|
| 39 | + if (null === $requiredVer) { |
|
| 40 | + $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
| 41 | + } |
|
| 42 | + $reqArray = explode('.', $requiredVer); |
|
| 43 | + $success = true; |
|
| 44 | + foreach ($reqArray as $k => $v) { |
|
| 45 | + if (isset($currArray[$k])) { |
|
| 46 | + if ($currArray[$k] > $v) { |
|
| 47 | + break; |
|
| 48 | + } elseif ($currArray[$k] == $v) { |
|
| 49 | + continue; |
|
| 50 | + } else { |
|
| 51 | + $success = false; |
|
| 52 | + break; |
|
| 53 | + } |
|
| 54 | + } else { |
|
| 55 | + if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
| 56 | + $success = false; |
|
| 57 | + break; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - if (false === $success) { |
|
| 63 | - $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
| 64 | - } |
|
| 62 | + if (false === $success) { |
|
| 63 | + $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return $success; |
|
| 67 | - } |
|
| 66 | + return $success; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * |
|
| 71 | - * Verifies PHP version meets minimum requirements for this module |
|
| 72 | - * @static |
|
| 73 | - * @param \XoopsModule $module |
|
| 74 | - * |
|
| 75 | - * @return bool true if meets requirements, false if not |
|
| 76 | - */ |
|
| 77 | - public static function checkVerPhp(\XoopsModule $module) |
|
| 78 | - { |
|
| 79 | - xoops_loadLanguage('admin', $module->dirname()); |
|
| 80 | - // check for minimum PHP version |
|
| 81 | - $success = true; |
|
| 82 | - $verNum = PHP_VERSION; |
|
| 83 | - $reqVer = $module->getInfo('min_php'); |
|
| 84 | - if (false !== $reqVer && '' !== $reqVer) { |
|
| 85 | - if (version_compare($verNum, $reqVer, '<')) { |
|
| 86 | - $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
| 87 | - $success = false; |
|
| 88 | - } |
|
| 89 | - } |
|
| 69 | + /** |
|
| 70 | + * |
|
| 71 | + * Verifies PHP version meets minimum requirements for this module |
|
| 72 | + * @static |
|
| 73 | + * @param \XoopsModule $module |
|
| 74 | + * |
|
| 75 | + * @return bool true if meets requirements, false if not |
|
| 76 | + */ |
|
| 77 | + public static function checkVerPhp(\XoopsModule $module) |
|
| 78 | + { |
|
| 79 | + xoops_loadLanguage('admin', $module->dirname()); |
|
| 80 | + // check for minimum PHP version |
|
| 81 | + $success = true; |
|
| 82 | + $verNum = PHP_VERSION; |
|
| 83 | + $reqVer = $module->getInfo('min_php'); |
|
| 84 | + if (false !== $reqVer && '' !== $reqVer) { |
|
| 85 | + if (version_compare($verNum, $reqVer, '<')) { |
|
| 86 | + $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
| 87 | + $success = false; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return $success; |
|
| 92 | - } |
|
| 91 | + return $success; |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -17,60 +17,60 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | trait ServerStats |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * serverStats() |
|
| 22 | - * |
|
| 23 | - * @return string |
|
| 24 | - */ |
|
| 25 | - public static function getServerStats() |
|
| 26 | - { |
|
| 27 | - //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
| 28 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
| 29 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
| 30 | - xoops_loadLanguage('common', $moduleDirName); |
|
| 31 | - $html = ''; |
|
| 32 | - // $sql = 'SELECT metavalue'; |
|
| 33 | - // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
| 34 | - // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
| 35 | - // $query = $GLOBALS['xoopsDB']->query($sql); |
|
| 36 | - // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
| 37 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
| 38 | - $html .= "<div style='padding: 8px;'>\n"; |
|
| 39 | - // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
| 40 | - // $html .= "<br>\n"; |
|
| 41 | - // $html .= "<br>\n"; |
|
| 42 | - $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
| 43 | - $html .= "<ul>\n"; |
|
| 44 | - // |
|
| 45 | - $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
| 46 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
| 47 | - if (function_exists('gd_info')) { |
|
| 48 | - if ($gdlib = (true === gd_info())) { |
|
| 49 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - // |
|
| 53 | - // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
| 54 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
| 55 | - // |
|
| 56 | - // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
| 57 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
| 58 | - // |
|
| 59 | - $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
| 60 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
| 61 | - // |
|
| 62 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
| 63 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
| 64 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
| 65 | - $html .= "</ul>\n"; |
|
| 66 | - $html .= "<ul>\n"; |
|
| 67 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
| 68 | - $html .= "</ul>\n"; |
|
| 69 | - $html .= "<br>\n"; |
|
| 70 | - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
| 71 | - $html .= '</div>'; |
|
| 72 | - $html .= '</fieldset><br>'; |
|
| 20 | + /** |
|
| 21 | + * serverStats() |
|
| 22 | + * |
|
| 23 | + * @return string |
|
| 24 | + */ |
|
| 25 | + public static function getServerStats() |
|
| 26 | + { |
|
| 27 | + //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
| 28 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
| 29 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
| 30 | + xoops_loadLanguage('common', $moduleDirName); |
|
| 31 | + $html = ''; |
|
| 32 | + // $sql = 'SELECT metavalue'; |
|
| 33 | + // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
| 34 | + // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
| 35 | + // $query = $GLOBALS['xoopsDB']->query($sql); |
|
| 36 | + // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
| 37 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
| 38 | + $html .= "<div style='padding: 8px;'>\n"; |
|
| 39 | + // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
| 40 | + // $html .= "<br>\n"; |
|
| 41 | + // $html .= "<br>\n"; |
|
| 42 | + $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
| 43 | + $html .= "<ul>\n"; |
|
| 44 | + // |
|
| 45 | + $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
| 46 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
| 47 | + if (function_exists('gd_info')) { |
|
| 48 | + if ($gdlib = (true === gd_info())) { |
|
| 49 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + // |
|
| 53 | + // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
| 54 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
| 55 | + // |
|
| 56 | + // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
| 57 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
| 58 | + // |
|
| 59 | + $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
| 60 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
| 61 | + // |
|
| 62 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
| 63 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
| 64 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
| 65 | + $html .= "</ul>\n"; |
|
| 66 | + $html .= "<ul>\n"; |
|
| 67 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
| 68 | + $html .= "</ul>\n"; |
|
| 69 | + $html .= "<br>\n"; |
|
| 70 | + $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
| 71 | + $html .= '</div>'; |
|
| 72 | + $html .= '</fieldset><br>'; |
|
| 73 | 73 | |
| 74 | - return $html; |
|
| 75 | - } |
|
| 74 | + return $html; |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -33,48 +33,48 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class Breadcrumb |
| 35 | 35 | { |
| 36 | - public $dirname; |
|
| 37 | - private $bread = []; |
|
| 36 | + public $dirname; |
|
| 37 | + private $bread = []; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * |
|
| 41 | - */ |
|
| 42 | - public function __construct() |
|
| 43 | - { |
|
| 44 | - $this->dirname = basename(dirname(__DIR__)); |
|
| 45 | - } |
|
| 39 | + /** |
|
| 40 | + * |
|
| 41 | + */ |
|
| 42 | + public function __construct() |
|
| 43 | + { |
|
| 44 | + $this->dirname = basename(dirname(__DIR__)); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Add link to breadcrumb |
|
| 49 | - * |
|
| 50 | - * @param string $title |
|
| 51 | - * @param string $link |
|
| 52 | - */ |
|
| 53 | - public function addLink($title = '', $link = '') |
|
| 54 | - { |
|
| 55 | - $this->bread[] = [ |
|
| 56 | - 'link' => $link, |
|
| 57 | - 'title' => $title |
|
| 58 | - ]; |
|
| 59 | - } |
|
| 47 | + /** |
|
| 48 | + * Add link to breadcrumb |
|
| 49 | + * |
|
| 50 | + * @param string $title |
|
| 51 | + * @param string $link |
|
| 52 | + */ |
|
| 53 | + public function addLink($title = '', $link = '') |
|
| 54 | + { |
|
| 55 | + $this->bread[] = [ |
|
| 56 | + 'link' => $link, |
|
| 57 | + 'title' => $title |
|
| 58 | + ]; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Render Pedigree BreadCrumb |
|
| 63 | - * |
|
| 64 | - */ |
|
| 65 | - public function render() |
|
| 66 | - { |
|
| 67 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
| 68 | - require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
| 69 | - $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
| 70 | - } |
|
| 61 | + /** |
|
| 62 | + * Render Pedigree BreadCrumb |
|
| 63 | + * |
|
| 64 | + */ |
|
| 65 | + public function render() |
|
| 66 | + { |
|
| 67 | + if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
| 68 | + require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
| 69 | + $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 73 | - $breadcrumbTpl = new \XoopsTpl(); |
|
| 74 | - $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
| 75 | - $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
| 76 | - unset($breadcrumbTpl); |
|
| 72 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 73 | + $breadcrumbTpl = new \XoopsTpl(); |
|
| 74 | + $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
| 75 | + $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
| 76 | + unset($breadcrumbTpl); |
|
| 77 | 77 | |
| 78 | - return $html; |
|
| 79 | - } |
|
| 78 | + return $html; |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -24,38 +24,38 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class Helper extends \Xmf\Module\Helper |
| 26 | 26 | { |
| 27 | - public $debug; |
|
| 27 | + public $debug; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @internal param $debug |
|
| 31 | - * @param bool $debug |
|
| 32 | - */ |
|
| 33 | - protected function __construct($debug = false) |
|
| 34 | - { |
|
| 35 | - $this->debug = $debug; |
|
| 36 | - $this->dirname = basename(dirname(__DIR__)); |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * @internal param $debug |
|
| 31 | + * @param bool $debug |
|
| 32 | + */ |
|
| 33 | + protected function __construct($debug = false) |
|
| 34 | + { |
|
| 35 | + $this->debug = $debug; |
|
| 36 | + $this->dirname = basename(dirname(__DIR__)); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param bool $debug |
|
| 41 | - * |
|
| 42 | - * @return \Xoopsmodules\instruction\Helper |
|
| 43 | - */ |
|
| 44 | - public static function getInstance($debug = false) |
|
| 45 | - { |
|
| 46 | - static $instance; |
|
| 47 | - if (null === $instance) { |
|
| 48 | - $instance = new static($debug); |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * @param bool $debug |
|
| 41 | + * |
|
| 42 | + * @return \Xoopsmodules\instruction\Helper |
|
| 43 | + */ |
|
| 44 | + public static function getInstance($debug = false) |
|
| 45 | + { |
|
| 46 | + static $instance; |
|
| 47 | + if (null === $instance) { |
|
| 48 | + $instance = new static($debug); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - return $instance; |
|
| 52 | - } |
|
| 51 | + return $instance; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public function getDirname() |
|
| 58 | - { |
|
| 59 | - return $this->dirname; |
|
| 60 | - } |
|
| 54 | + /** |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public function getDirname() |
|
| 58 | + { |
|
| 59 | + return $this->dirname; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -12,60 +12,60 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class PageHandler extends \XoopsPersistableObjectHandler |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @param null|mixed $db |
|
| 17 | - */ |
|
| 18 | - public function __construct(\XoopsDatabase $db = null) |
|
| 19 | - { |
|
| 20 | - parent::__construct($db, 'instruction_page', Page::class, 'pageid', 'title'); |
|
| 21 | - } |
|
| 15 | + /** |
|
| 16 | + * @param null|mixed $db |
|
| 17 | + */ |
|
| 18 | + public function __construct(\XoopsDatabase $db = null) |
|
| 19 | + { |
|
| 20 | + parent::__construct($db, 'instruction_page', Page::class, 'pageid', 'title'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Generate function for update user post |
|
| 25 | - * |
|
| 26 | - * @ Update user post count after send approve content |
|
| 27 | - * @ Update user post count after change status content |
|
| 28 | - * @ Update user post count after delete content |
|
| 29 | - * @param $uid |
|
| 30 | - * @param $status |
|
| 31 | - * @param $action |
|
| 32 | - */ |
|
| 33 | - public function updateposts($uid, $status, $action) |
|
| 34 | - { |
|
| 35 | - // |
|
| 36 | - switch ($action) { |
|
| 37 | - // Добавление страницы |
|
| 38 | - case 'add': |
|
| 39 | - if ($uid && $status) { |
|
| 40 | - $user = new \XoopsUser($uid); |
|
| 41 | - $memberHandler = xoops_getHandler('member'); |
|
| 42 | - // Добавялем +1 к комментам |
|
| 43 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 44 | - } |
|
| 45 | - break; |
|
| 46 | - // Удаление страницы |
|
| 47 | - case 'delete': |
|
| 48 | - if ($uid && $status) { |
|
| 49 | - $user = new \XoopsUser($uid); |
|
| 50 | - $memberHandler = xoops_getHandler('member'); |
|
| 51 | - // Декримент комментов |
|
| 52 | - //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
| 53 | - // Сохраняем |
|
| 54 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 55 | - } |
|
| 56 | - break; |
|
| 23 | + /** |
|
| 24 | + * Generate function for update user post |
|
| 25 | + * |
|
| 26 | + * @ Update user post count after send approve content |
|
| 27 | + * @ Update user post count after change status content |
|
| 28 | + * @ Update user post count after delete content |
|
| 29 | + * @param $uid |
|
| 30 | + * @param $status |
|
| 31 | + * @param $action |
|
| 32 | + */ |
|
| 33 | + public function updateposts($uid, $status, $action) |
|
| 34 | + { |
|
| 35 | + // |
|
| 36 | + switch ($action) { |
|
| 37 | + // Добавление страницы |
|
| 38 | + case 'add': |
|
| 39 | + if ($uid && $status) { |
|
| 40 | + $user = new \XoopsUser($uid); |
|
| 41 | + $memberHandler = xoops_getHandler('member'); |
|
| 42 | + // Добавялем +1 к комментам |
|
| 43 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 44 | + } |
|
| 45 | + break; |
|
| 46 | + // Удаление страницы |
|
| 47 | + case 'delete': |
|
| 48 | + if ($uid && $status) { |
|
| 49 | + $user = new \XoopsUser($uid); |
|
| 50 | + $memberHandler = xoops_getHandler('member'); |
|
| 51 | + // Декримент комментов |
|
| 52 | + //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
| 53 | + // Сохраняем |
|
| 54 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 55 | + } |
|
| 56 | + break; |
|
| 57 | 57 | |
| 58 | - case 'status': |
|
| 59 | - if ($uid) { |
|
| 60 | - $user = new \XoopsUser($uid); |
|
| 61 | - $memberHandler = xoops_getHandler('member'); |
|
| 62 | - if ($status) { |
|
| 63 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 64 | - } else { |
|
| 65 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - break; |
|
| 69 | - } |
|
| 70 | - } |
|
| 58 | + case 'status': |
|
| 59 | + if ($uid) { |
|
| 60 | + $user = new \XoopsUser($uid); |
|
| 61 | + $memberHandler = xoops_getHandler('member'); |
|
| 62 | + if ($status) { |
|
| 63 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 64 | + } else { |
|
| 65 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + break; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | } |