Completed
Push — master ( e23147...f5725e )
by Michael
01:48
created
class/PageHandler.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -12,60 +12,60 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
include/comment_functions.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function instruction_com_update($pageid, $total_num)
11 11
 {
12
-    $db  = XoopsDatabaseFactory::getDatabaseConnection();
13
-    $sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid  = ' . $pageid;
14
-    $db->query($sql);
12
+	$db  = XoopsDatabaseFactory::getDatabaseConnection();
13
+	$sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid  = ' . $pageid;
14
+	$db->query($sql);
15 15
 }
16 16
 
17 17
 /**
@@ -19,5 +19,5 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function instruction_com_approve(&$comment)
21 21
 {
22
-    // notification mail here
22
+	// notification mail here
23 23
 }
Please login to merge, or discard this patch.
include/config.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -23,57 +23,57 @@
 block discarded – undo
23 23
 $capsDirName   = strtoupper($moduleDirName);
24 24
 
25 25
 if (!defined($capsDirName . '_DIRNAME')) {
26
-    //if (!defined(constant($capsDirName . '_DIRNAME'))) {
27
-    define($capsDirName . '_DIRNAME', $GLOBALS['xoopsModule']->dirname());
28
-    define($capsDirName . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
29
-    define($capsDirName . '_URL', XOOPS_URL . '/modules/' . constant($capsDirName . '_DIRNAME'));
30
-    define($capsDirName . '_ADMIN', constant($capsDirName . '_URL') . '/admin/index.php');
31
-    define($capsDirName . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
32
-    define($capsDirName . '_AUTHOR_LOGOIMG', constant($capsDirName . '_URL') . '/assets/images/logoModule.png');
33
-    define($capsDirName . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
34
-    define($capsDirName . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
26
+	//if (!defined(constant($capsDirName . '_DIRNAME'))) {
27
+	define($capsDirName . '_DIRNAME', $GLOBALS['xoopsModule']->dirname());
28
+	define($capsDirName . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
29
+	define($capsDirName . '_URL', XOOPS_URL . '/modules/' . constant($capsDirName . '_DIRNAME'));
30
+	define($capsDirName . '_ADMIN', constant($capsDirName . '_URL') . '/admin/index.php');
31
+	define($capsDirName . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
32
+	define($capsDirName . '_AUTHOR_LOGOIMG', constant($capsDirName . '_URL') . '/assets/images/logoModule.png');
33
+	define($capsDirName . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
34
+	define($capsDirName . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
35 35
 }
36 36
 
37 37
 //Configurator
38 38
 return (object)[
39
-    'name'          => strtoupper($moduleDirName) . ' Module Configurator',
40
-    'paths'         => [
41
-        'dirname'    => $moduleDirName,
42
-        'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
43
-        //        'path'       => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
44
-        //        'url'        => XOOPS_URL . '/modules/' . $moduleDirName,
45
-        'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
46
-        'uploadUrl'  => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
47
-    ],
48
-    'uploadFolders' => [
49
-        constant($capsDirName . '_UPLOAD_PATH'),
50
-        //constant($capsDirName . '_UPLOAD_PATH') . '/category',
51
-        //constant($capsDirName . '_UPLOAD_PATH') . '/screenshots',
52
-        //XOOPS_UPLOAD_PATH . '/flags'
53
-    ],
54
-    'blankFiles'    => [
55
-        constant($capsDirName . '_UPLOAD_PATH'),
56
-        //constant($capsDirName . '_UPLOAD_PATH') . '/category',
57
-        //constant($capsDirName . '_UPLOAD_PATH') . '/screenshots',
58
-        //XOOPS_UPLOAD_PATH . '/flags'
59
-    ],
39
+	'name'          => strtoupper($moduleDirName) . ' Module Configurator',
40
+	'paths'         => [
41
+		'dirname'    => $moduleDirName,
42
+		'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
43
+		//        'path'       => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
44
+		//        'url'        => XOOPS_URL . '/modules/' . $moduleDirName,
45
+		'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
46
+		'uploadUrl'  => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
47
+	],
48
+	'uploadFolders' => [
49
+		constant($capsDirName . '_UPLOAD_PATH'),
50
+		//constant($capsDirName . '_UPLOAD_PATH') . '/category',
51
+		//constant($capsDirName . '_UPLOAD_PATH') . '/screenshots',
52
+		//XOOPS_UPLOAD_PATH . '/flags'
53
+	],
54
+	'blankFiles'    => [
55
+		constant($capsDirName . '_UPLOAD_PATH'),
56
+		//constant($capsDirName . '_UPLOAD_PATH') . '/category',
57
+		//constant($capsDirName . '_UPLOAD_PATH') . '/screenshots',
58
+		//XOOPS_UPLOAD_PATH . '/flags'
59
+	],
60 60
 
61
-    'templateFolders' => [
62
-        '/templates/',
63
-        '/templates/blocks/',
64
-        '/templates/admin/'
61
+	'templateFolders' => [
62
+		'/templates/',
63
+		'/templates/blocks/',
64
+		'/templates/admin/'
65 65
 
66
-    ],
67
-    'oldFiles'        => [//        '/sql/mysql.sql',
68
-    ],
69
-    'oldFolders'      => [
70
-        '/images',
71
-        '/css',
72
-        '/js',
73
-        '/tree',
74
-        '/images/icons/16',
75
-        '/images/icons/32',
76
-    ],
77
-    'modCopyright'    => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
66
+	],
67
+	'oldFiles'        => [//        '/sql/mysql.sql',
68
+	],
69
+	'oldFolders'      => [
70
+		'/images',
71
+		'/css',
72
+		'/js',
73
+		'/tree',
74
+		'/images/icons/16',
75
+		'/images/icons/32',
76
+	],
77
+	'modCopyright'    => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
78 78
                      <img src='" . $capsDirName . '_AUTHOR_LOGOIMG' . '\' alt=\'XOOPS Project\' /></a>',
79 79
 ];
Please login to merge, or discard this patch.
include/common.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,8 +70,8 @@
 block discarded – undo
70 70
 $debug = false;
71 71
 
72 72
 if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
73
-    require_once $GLOBALS['xoops']->path('class/template.php');
74
-    $xoopsTpl = new \XoopsTpl();
73
+	require_once $GLOBALS['xoops']->path('class/template.php');
74
+	$xoopsTpl = new \XoopsTpl();
75 75
 }
76 76
 
77 77
 $moduleDirName = basename(dirname(__DIR__));
Please login to merge, or discard this patch.
submit.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -35,195 +35,195 @@
 block discarded – undo
35 35
 
36 36
 switch ($op) {
37 37
 
38
-    case 'editpage':
39
-
40
-        // Задание тайтла
41
-        $xoopsOption['xoops_pagetitle'] = '';
42
-        // Шаблон
43
-        $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_editpage.tpl';
44
-        // Заголовок
45
-        include_once $GLOBALS['xoops']->path('header.php');
46
-
47
-        // Если мы редактируем страницу
48
-        if ($pageid) {
49
-            // Получаем объект страницы
50
-            $objInspage = $pageHandler->get($pageid);
51
-            // ID инструкции
52
-            $instrid = $objInspage->getVar('instrid');
53
-            // Объект инструкции
54
-            $objInsinstr = $instructionHandler->get($instrid);
55
-            // Можно ли редактировать инструкцию в данной категории
56
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
57
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
58
-            }
59
-            // Создание новой страницы
60
-        } elseif ($instrid) {
61
-
62
-            // Если нельзя добавлять не в одну категорию
63
-            //if( ! count( $cat_submit ) ) redirect_header( 'index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMIT_PAGE );
64
-            // Создаём объект страницы
65
-            $objInspage = $pageHandler->create();
66
-            // Объект инструкции
67
-            $objInsinstr = $instructionHandler->get($instrid);
68
-            // Можно ли добавлять инструкции в данной категории
69
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
70
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
71
-            }
72
-        } else {
73
-            redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
74
-        }
75
-
76
-        // Информация об инструкции
77
-
78
-        // Массив данных об инструкции
79
-        $instrs = [];
80
-        // ID инструкции
81
-        $instrs['instrid'] = $objInsinstr->getVar('instrid');
82
-        // Название страницы
83
-        $instrs['title'] = $objInsinstr->getVar('title');
84
-        // Описание
85
-        $instrs['description'] = $objInsinstr->getVar('description');
86
-
87
-        // Выводим в шаблон
88
-        $GLOBALS['xoopsTpl']->assign('insInstr', $instrs);
89
-
90
-        //
91
-
92
-        $form = $objInspage->getForm('submit.php', $instrid);
93
-        // Форма
94
-        $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
95
-
96
-        // Подвал
97
-        include_once $GLOBALS['xoops']->path('footer.php');
98
-
99
-        break;
100
-    // Сохранение страницы
101
-    case 'savepage':
102
-
103
-        // Проверка
104
-        if (!$GLOBALS['xoopsSecurity']->check()) {
105
-            redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
106
-        }
107
-
108
-        $err         = false;
109
-        $message_err = '';
110
-
111
-        // Если мы редактируем
112
-        if ($pageid) {
113
-            $objInspage = $pageHandler->get($pageid);
114
-            // Объект инструкции
115
-            $objInsinstr = $instructionHandler->get($objInspage->getVar('instrid'));
116
-            // Можно ли редактировать инструкцию в данной категории
117
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
118
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
119
-            }
120
-        } elseif ($instrid) {
121
-            $objInspage = $pageHandler->create();
122
-            // Объект инструкции
123
-            $objInsinstr = $instructionHandler->get($instrid);
124
-            // Можно ли добавлять инструкции в данной категории
125
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
126
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
127
-            }
128
-
129
-            // Если мы создаём страницу необходимо указать к какой инструкции
130
-            $objInspage->setVar('instrid', $instrid);
131
-            // Указываем дату создания
132
-            $objInspage->setVar('datecreated', $time);
133
-            // Указываем пользователя
134
-            $objInspage->setVar('uid', $uid);
135
-        } else {
136
-            redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
137
-        }
138
-
139
-        // Родительская страница
140
-        $objInspage->setVar('pid', $pid);
141
-        // Дата обновления
142
-        $objInspage->setVar('dateupdated', $time);
143
-        //
144
-        $objInspage->setVar('title', Request::getString('title', '', 'POST'));
145
-        $objInspage->setVar('weight', $weight);
146
-        $objInspage->setVar('hometext', Request::getText('hometext', '', 'POST'));
147
-        // Сноска
148
-        $objInspage->setVar('footnote', Request::getText('footnote', '', 'POST'));
149
-        $objInspage->setVar('status', Request::getInt('status', 0, 'POST'));
150
-        $objInspage->setVar('keywords', Request::getString('keywords', '', 'POST'));
151
-        $objInspage->setVar('description', Request::getText('description', '', 'POST'));
152
-
153
-        // Проверка категорий
154
-        if (!$pageid && !$instrid) {
155
-            $err         = true;
156
-            $message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
157
-        }
158
-        // Проверка веса
159
-        if (0 == $weight) {
160
-            $err         = true;
161
-            $message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
162
-        }
163
-        // Проверка родительской страницы
164
-        if ($pageid && ($pageid == $pid)) {
165
-            $err         = true;
166
-            $message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
167
-        }
168
-        // Если были ошибки
169
-        if (true === $err) {
170
-            // Задание тайтла
171
-            $xoopsOption['xoops_pagetitle'] = '';
172
-            // Шаблон
173
-            $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
174
-            // Заголовок
175
-            include_once $GLOBALS['xoops']->path('header.php');
176
-            // Сообщение об ошибке
177
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
178
-            // Выводим ошибки в шаблон
179
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
180
-            // Если небыло ошибок
181
-        } else {
182
-            // Вставляем данные в БД
183
-            if ($pageHandler->insert($objInspage)) {
184
-                // Если мы редактируем
185
-                if ($pageid) {
186
-                    // Обновление даты
187
-                    $sql = sprintf('UPDATE %s SET `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
188
-                    $GLOBALS['xoopsDB']->query($sql);
189
-                    // Запись в лог
190
-                    xoops_loadLanguage('main', 'userslog');
191
-                    //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_MODIFY_PAGE );
192
-                    //
193
-                    redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEMODIFY);
194
-                    // Если мы добавляем
195
-                } else {
196
-                    // Инкримент комментов
197
-                    $pageHandler->updateposts($uid, Request::getInt('status', 0, 'POST'), 'add');
198
-                    // Инкремент страниц и обновление даты
199
-                    $sql = sprintf('UPDATE %s SET `pages` = `pages` + 1, `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
200
-                    $GLOBALS['xoopsDB']->query($sql);
201
-                    // Запись в лог
202
-                    xoops_loadLanguage('main', 'userslog');
203
-                    //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_SUBMIT_PAGE );
204
-                    //
205
-                    redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEADDED);
206
-                }
207
-            }
208
-
209
-            // Задание тайтла
210
-            $xoopsOption['xoops_pagetitle'] = '';
211
-            // Шаблон
212
-            $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
213
-            // Заголовок
214
-            include_once $GLOBALS['xoops']->path('header.php');
215
-
216
-            // Выводим ошибки в шаблон
217
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
218
-        }
219
-        // Получаем форму
220
-        $form = $objInspage->getForm('submit.php', $instrid);
221
-
222
-        // Форма
223
-        $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
224
-
225
-        // Подвал
226
-        include_once $GLOBALS['xoops']->path('footer.php');
227
-
228
-        break;
38
+	case 'editpage':
39
+
40
+		// Задание тайтла
41
+		$xoopsOption['xoops_pagetitle'] = '';
42
+		// Шаблон
43
+		$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_editpage.tpl';
44
+		// Заголовок
45
+		include_once $GLOBALS['xoops']->path('header.php');
46
+
47
+		// Если мы редактируем страницу
48
+		if ($pageid) {
49
+			// Получаем объект страницы
50
+			$objInspage = $pageHandler->get($pageid);
51
+			// ID инструкции
52
+			$instrid = $objInspage->getVar('instrid');
53
+			// Объект инструкции
54
+			$objInsinstr = $instructionHandler->get($instrid);
55
+			// Можно ли редактировать инструкцию в данной категории
56
+			if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
57
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
58
+			}
59
+			// Создание новой страницы
60
+		} elseif ($instrid) {
61
+
62
+			// Если нельзя добавлять не в одну категорию
63
+			//if( ! count( $cat_submit ) ) redirect_header( 'index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMIT_PAGE );
64
+			// Создаём объект страницы
65
+			$objInspage = $pageHandler->create();
66
+			// Объект инструкции
67
+			$objInsinstr = $instructionHandler->get($instrid);
68
+			// Можно ли добавлять инструкции в данной категории
69
+			if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
70
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
71
+			}
72
+		} else {
73
+			redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
74
+		}
75
+
76
+		// Информация об инструкции
77
+
78
+		// Массив данных об инструкции
79
+		$instrs = [];
80
+		// ID инструкции
81
+		$instrs['instrid'] = $objInsinstr->getVar('instrid');
82
+		// Название страницы
83
+		$instrs['title'] = $objInsinstr->getVar('title');
84
+		// Описание
85
+		$instrs['description'] = $objInsinstr->getVar('description');
86
+
87
+		// Выводим в шаблон
88
+		$GLOBALS['xoopsTpl']->assign('insInstr', $instrs);
89
+
90
+		//
91
+
92
+		$form = $objInspage->getForm('submit.php', $instrid);
93
+		// Форма
94
+		$GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
95
+
96
+		// Подвал
97
+		include_once $GLOBALS['xoops']->path('footer.php');
98
+
99
+		break;
100
+	// Сохранение страницы
101
+	case 'savepage':
102
+
103
+		// Проверка
104
+		if (!$GLOBALS['xoopsSecurity']->check()) {
105
+			redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
106
+		}
107
+
108
+		$err         = false;
109
+		$message_err = '';
110
+
111
+		// Если мы редактируем
112
+		if ($pageid) {
113
+			$objInspage = $pageHandler->get($pageid);
114
+			// Объект инструкции
115
+			$objInsinstr = $instructionHandler->get($objInspage->getVar('instrid'));
116
+			// Можно ли редактировать инструкцию в данной категории
117
+			if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
118
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
119
+			}
120
+		} elseif ($instrid) {
121
+			$objInspage = $pageHandler->create();
122
+			// Объект инструкции
123
+			$objInsinstr = $instructionHandler->get($instrid);
124
+			// Можно ли добавлять инструкции в данной категории
125
+			if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
126
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
127
+			}
128
+
129
+			// Если мы создаём страницу необходимо указать к какой инструкции
130
+			$objInspage->setVar('instrid', $instrid);
131
+			// Указываем дату создания
132
+			$objInspage->setVar('datecreated', $time);
133
+			// Указываем пользователя
134
+			$objInspage->setVar('uid', $uid);
135
+		} else {
136
+			redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
137
+		}
138
+
139
+		// Родительская страница
140
+		$objInspage->setVar('pid', $pid);
141
+		// Дата обновления
142
+		$objInspage->setVar('dateupdated', $time);
143
+		//
144
+		$objInspage->setVar('title', Request::getString('title', '', 'POST'));
145
+		$objInspage->setVar('weight', $weight);
146
+		$objInspage->setVar('hometext', Request::getText('hometext', '', 'POST'));
147
+		// Сноска
148
+		$objInspage->setVar('footnote', Request::getText('footnote', '', 'POST'));
149
+		$objInspage->setVar('status', Request::getInt('status', 0, 'POST'));
150
+		$objInspage->setVar('keywords', Request::getString('keywords', '', 'POST'));
151
+		$objInspage->setVar('description', Request::getText('description', '', 'POST'));
152
+
153
+		// Проверка категорий
154
+		if (!$pageid && !$instrid) {
155
+			$err         = true;
156
+			$message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
157
+		}
158
+		// Проверка веса
159
+		if (0 == $weight) {
160
+			$err         = true;
161
+			$message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
162
+		}
163
+		// Проверка родительской страницы
164
+		if ($pageid && ($pageid == $pid)) {
165
+			$err         = true;
166
+			$message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
167
+		}
168
+		// Если были ошибки
169
+		if (true === $err) {
170
+			// Задание тайтла
171
+			$xoopsOption['xoops_pagetitle'] = '';
172
+			// Шаблон
173
+			$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
174
+			// Заголовок
175
+			include_once $GLOBALS['xoops']->path('header.php');
176
+			// Сообщение об ошибке
177
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
178
+			// Выводим ошибки в шаблон
179
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
180
+			// Если небыло ошибок
181
+		} else {
182
+			// Вставляем данные в БД
183
+			if ($pageHandler->insert($objInspage)) {
184
+				// Если мы редактируем
185
+				if ($pageid) {
186
+					// Обновление даты
187
+					$sql = sprintf('UPDATE %s SET `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
188
+					$GLOBALS['xoopsDB']->query($sql);
189
+					// Запись в лог
190
+					xoops_loadLanguage('main', 'userslog');
191
+					//userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_MODIFY_PAGE );
192
+					//
193
+					redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEMODIFY);
194
+					// Если мы добавляем
195
+				} else {
196
+					// Инкримент комментов
197
+					$pageHandler->updateposts($uid, Request::getInt('status', 0, 'POST'), 'add');
198
+					// Инкремент страниц и обновление даты
199
+					$sql = sprintf('UPDATE %s SET `pages` = `pages` + 1, `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
200
+					$GLOBALS['xoopsDB']->query($sql);
201
+					// Запись в лог
202
+					xoops_loadLanguage('main', 'userslog');
203
+					//userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_SUBMIT_PAGE );
204
+					//
205
+					redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEADDED);
206
+				}
207
+			}
208
+
209
+			// Задание тайтла
210
+			$xoopsOption['xoops_pagetitle'] = '';
211
+			// Шаблон
212
+			$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
213
+			// Заголовок
214
+			include_once $GLOBALS['xoops']->path('header.php');
215
+
216
+			// Выводим ошибки в шаблон
217
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
218
+		}
219
+		// Получаем форму
220
+		$form = $objInspage->getForm('submit.php', $instrid);
221
+
222
+		// Форма
223
+		$GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
224
+
225
+		// Подвал
226
+		include_once $GLOBALS['xoops']->path('footer.php');
227
+
228
+		break;
229 229
 }
Please login to merge, or discard this patch.
blocks/instr_lastpage.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -12,63 +12,63 @@  discard block
 block discarded – undo
12 12
 function b_instr_lastpage_show($options = [])
13 13
 {
14 14
 
15
-    // Подключаем функции
16
-    $moduleDirName = basename(dirname(__DIR__));
17
-    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/common.php');
18
-    //
19
-    $myts = MyTextSanitizer::getInstance();
20
-    //
21
-    //mb    $instructionHandler = xoops_getModuleHandler('instruction', 'instruction');
22
-    //mb    $pageHandler  = xoops_getModuleHandler('page', 'instruction');
15
+	// Подключаем функции
16
+	$moduleDirName = basename(dirname(__DIR__));
17
+	include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/common.php');
18
+	//
19
+	$myts = MyTextSanitizer::getInstance();
20
+	//
21
+	//mb    $instructionHandler = xoops_getModuleHandler('instruction', 'instruction');
22
+	//mb    $pageHandler  = xoops_getModuleHandler('page', 'instruction');
23 23
 
24
-    $db                 = \XoopsDatabaseFactory::getDatabase();
25
-    $instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db);
26
-    $pageHandler        = new \Xoopsmodules\instruction\PageHandler($db);
24
+	$db                 = \XoopsDatabaseFactory::getDatabase();
25
+	$instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db);
26
+	$pageHandler        = new \Xoopsmodules\instruction\PageHandler($db);
27 27
 
28
-    // Добавляем стили
29
-    //global $xoTheme;
30
-    //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
28
+	// Добавляем стили
29
+	//global $xoTheme;
30
+	//$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
31 31
 
32
-    // Опции
33
-    // Количество страниц
34
-    $limit = $options[0];
35
-    // Количество символов
36
-    $numchars = $options[1];
32
+	// Опции
33
+	// Количество страниц
34
+	$limit = $options[0];
35
+	// Количество символов
36
+	$numchars = $options[1];
37 37
 
38
-    // Права на просмотр
39
-    $cat_view = Xoopsmodules\instruction\Utility::getItemIds();
40
-    // Массив выходных данных
41
-    $block = [];
38
+	// Права на просмотр
39
+	$cat_view = Xoopsmodules\instruction\Utility::getItemIds();
40
+	// Массив выходных данных
41
+	$block = [];
42 42
 
43
-    // Если есть категории для прасмотра
44
-    if (is_array($cat_view) && count($cat_view) > 0) {
43
+	// Если есть категории для прасмотра
44
+	if (is_array($cat_view) && count($cat_view) > 0) {
45 45
 
46
-        // Находим последние страницы
47
-        $sql = "SELECT p.pageid, p.instrid, p.title, p.dateupdated, i.title, i.cid FROM {$pageHandler->table} p, {$instructionHandler->table} i WHERE p.instrid = i.instrid AND i.cid IN (" . implode(', ', $cat_view) . ') AND p.status > 0 AND i.status > 0 ORDER BY p.dateupdated DESC';
48
-        // Лимит запроса
49
-        $result = $GLOBALS['xoopsDB']->query($sql, $limit);
50
-        // Перебираем все значения
51
-        $i = 0;
52
-        while (list($pageid, $instrid, $ptitle, $dateupdated, $ititle, $cid) = $GLOBALS['xoopsDB']->fetchRow($result)) {
53
-            // ID страницы
54
-            $block[$i]['pageid'] = $pageid;
55
-            // ID инструкции
56
-            $block[$i]['instrid'] = $instrid;
57
-            // Название страницы
58
-            $block[$i]['ptitle'] = $myts->htmlSpecialChars($ptitle);
59
-            // Название инструкции
60
-            $block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
61
-            // Дата обновления страницы
62
-            $block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
63
-            // Категория инстркции
64
-            $block[$i]['cid'] = $cid;
65
-            // Инкримент
66
-            $i++;
67
-        }
68
-    }
46
+		// Находим последние страницы
47
+		$sql = "SELECT p.pageid, p.instrid, p.title, p.dateupdated, i.title, i.cid FROM {$pageHandler->table} p, {$instructionHandler->table} i WHERE p.instrid = i.instrid AND i.cid IN (" . implode(', ', $cat_view) . ') AND p.status > 0 AND i.status > 0 ORDER BY p.dateupdated DESC';
48
+		// Лимит запроса
49
+		$result = $GLOBALS['xoopsDB']->query($sql, $limit);
50
+		// Перебираем все значения
51
+		$i = 0;
52
+		while (list($pageid, $instrid, $ptitle, $dateupdated, $ititle, $cid) = $GLOBALS['xoopsDB']->fetchRow($result)) {
53
+			// ID страницы
54
+			$block[$i]['pageid'] = $pageid;
55
+			// ID инструкции
56
+			$block[$i]['instrid'] = $instrid;
57
+			// Название страницы
58
+			$block[$i]['ptitle'] = $myts->htmlSpecialChars($ptitle);
59
+			// Название инструкции
60
+			$block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
61
+			// Дата обновления страницы
62
+			$block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
63
+			// Категория инстркции
64
+			$block[$i]['cid'] = $cid;
65
+			// Инкримент
66
+			$i++;
67
+		}
68
+	}
69 69
 
70
-    // Возвращаем массив
71
-    return $block;
70
+	// Возвращаем массив
71
+	return $block;
72 72
 }
73 73
 
74 74
 // Редактирование последних страниц
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
  */
79 79
 function b_instr_lastpage_edit($options = [])
80 80
 {
81
-    $form = '';
82
-    $form .= _MB_INSTR_DISPLAYPAGESC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
83
-    $form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
81
+	$form = '';
82
+	$form .= _MB_INSTR_DISPLAYPAGESC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
83
+	$form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
84 84
 
85
-    // Возвращаем форму
86
-    return $form;
85
+	// Возвращаем форму
86
+	return $form;
87 87
 }
Please login to merge, or discard this patch.
class/common/ServerStats.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -17,60 +17,60 @@
 block discarded – undo
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 (true === ($gdlib = 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 (true === ($gdlib = 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
 }
Please login to merge, or discard this patch.
include/search.inc.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -13,46 +13,46 @@
 block discarded – undo
13 13
  */
14 14
 function instruction_search($queryarray, $andor, $limit, $offset, $userid)
15 15
 {
16
-    // Подключаем функции
17
-    $moduleDirName = basename(dirname(__DIR__));
18
-    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
16
+	// Подключаем функции
17
+	$moduleDirName = basename(dirname(__DIR__));
18
+	include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
19 19
 
20
-    $sql = 'SELECT p.pageid, p.title, p.uid, p.datecreated, i.title FROM ' . $GLOBALS['xoopsDB']->prefix('instruction_page') . ' p, ' . $GLOBALS['xoopsDB']->prefix('instruction_instr') . ' i WHERE i.instrid = p.instrid AND i.status > 0 AND p.status > 0 AND p.type > 0';
21
-    if (0 != $userid) {
22
-        $sql .= ' AND p.uid = ' . (int)$userid . ' ';
23
-        //return NULL;
24
-    }
20
+	$sql = 'SELECT p.pageid, p.title, p.uid, p.datecreated, i.title FROM ' . $GLOBALS['xoopsDB']->prefix('instruction_page') . ' p, ' . $GLOBALS['xoopsDB']->prefix('instruction_instr') . ' i WHERE i.instrid = p.instrid AND i.status > 0 AND p.status > 0 AND p.type > 0';
21
+	if (0 != $userid) {
22
+		$sql .= ' AND p.uid = ' . (int)$userid . ' ';
23
+		//return NULL;
24
+	}
25 25
 
26
-    // Права на просмотр
27
-    $categories = Xoopsmodules\instruction\Utility::getItemIds();
28
-    if (is_array($categories) && count($categories) > 0) {
29
-        $sql .= ' AND i.cid IN ( ' . implode(', ', $categories) . ' ) ';
30
-        // Если пользователь не имеет прав просмотра ни одной категории
31
-    } else {
32
-        return null;
33
-    }
26
+	// Права на просмотр
27
+	$categories = Xoopsmodules\instruction\Utility::getItemIds();
28
+	if (is_array($categories) && count($categories) > 0) {
29
+		$sql .= ' AND i.cid IN ( ' . implode(', ', $categories) . ' ) ';
30
+		// Если пользователь не имеет прав просмотра ни одной категории
31
+	} else {
32
+		return null;
33
+	}
34 34
 
35
-    // Добавляем в условие ключевые слова поиска
36
-    if (is_array($queryarray) && $count = count($queryarray)) {
37
-        $sql .= " AND ( ( p.title LIKE '%$queryarray[0]%' OR p.hometext LIKE '%$queryarray[0]%' )";
38
-        for ($i = 1; $i < $count; $i++) {
39
-            $sql .= " $andor ";
40
-            $sql .= "( p.title LIKE '%$queryarray[$i]%' OR p.hometext LIKE '%$queryarray[$i]%' )";
41
-        }
42
-        $sql .= ' ) ';
43
-    }
44
-    //$sql .= "ORDER BY date DESC";
45
-    $result = $GLOBALS['xoopsDB']->query($sql, $limit, $offset);
46
-    $ret    = [];
47
-    $i      = 0;
48
-    // Перебираем все результаты
49
-    while (list($pageid, $ptitle, $puid, $pdatecreated, $ititle) = $GLOBALS['xoopsDB']->fetchRow($result)) {
50
-        $ret[$i]['image'] = 'assets/images/size2.gif';
51
-        $ret[$i]['link']  = 'page.php?id=' . $pageid;
52
-        $ret[$i]['title'] = $ititle . ': ' . $ptitle;
53
-        $ret[$i]['time']  = $pdatecreated;
54
-        $ret[$i]['uid']   = $puid;
55
-        $i++;
56
-    }
57
-    return $ret;
35
+	// Добавляем в условие ключевые слова поиска
36
+	if (is_array($queryarray) && $count = count($queryarray)) {
37
+		$sql .= " AND ( ( p.title LIKE '%$queryarray[0]%' OR p.hometext LIKE '%$queryarray[0]%' )";
38
+		for ($i = 1; $i < $count; $i++) {
39
+			$sql .= " $andor ";
40
+			$sql .= "( p.title LIKE '%$queryarray[$i]%' OR p.hometext LIKE '%$queryarray[$i]%' )";
41
+		}
42
+		$sql .= ' ) ';
43
+	}
44
+	//$sql .= "ORDER BY date DESC";
45
+	$result = $GLOBALS['xoopsDB']->query($sql, $limit, $offset);
46
+	$ret    = [];
47
+	$i      = 0;
48
+	// Перебираем все результаты
49
+	while (list($pageid, $ptitle, $puid, $pdatecreated, $ititle) = $GLOBALS['xoopsDB']->fetchRow($result)) {
50
+		$ret[$i]['image'] = 'assets/images/size2.gif';
51
+		$ret[$i]['link']  = 'page.php?id=' . $pageid;
52
+		$ret[$i]['title'] = $ititle . ': ' . $ptitle;
53
+		$ret[$i]['time']  = $pdatecreated;
54
+		$ret[$i]['uid']   = $puid;
55
+		$i++;
56
+	}
57
+	return $ret;
58 58
 }
Please login to merge, or discard this patch.
class/common/VersionChecks.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -17,77 +17,77 @@
 block discarded – undo
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_INSTRUCTION_ERROR_BAD_XOOPS, $requiredVer, $currentVer));
64
-        }
62
+		if (false === $success) {
63
+			$module->setErrors(sprintf(_AM_INSTRUCTION_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_INSTRUCTION_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_INSTRUCTION_ERROR_BAD_PHP, $reqVer, $verNum));
87
+				$success = false;
88
+			}
89
+		}
90 90
 
91
-        return $success;
92
-    }
91
+		return $success;
92
+	}
93 93
 }
Please login to merge, or discard this patch.