Completed
Push — master ( 55b92e...48ecb4 )
by Michael
01:50
created
class/utility.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -39,6 +39,11 @@
 block discarded – undo
39 39
     }
40 40
 
41 41
     // Редактор
42
+
43
+    /**
44
+     * @param string $caption
45
+     * @param string $name
46
+     */
42 47
     public static function getWysiwygForm($caption, $name, $value = '')
43 48
     {
44 49
         $editor                   = false;
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use Xmf\Request;
4
-
5 3
 require_once __DIR__ . '/common/traitversionchecks.php';
6 4
 require_once __DIR__ . '/common/traitserverstats.php';
7 5
 require_once __DIR__ . '/common/traitfilesmgmt.php';
Please login to merge, or discard this patch.
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -13,63 +13,63 @@
 block discarded – undo
13 13
  */
14 14
 class InstructionUtility
15 15
 {
16
-    use VersionChecks; //checkVerXoops, checkVerPhp Traits
16
+	use VersionChecks; //checkVerXoops, checkVerPhp Traits
17 17
 
18
-    use ServerStats; // getServerStats Trait
18
+	use ServerStats; // getServerStats Trait
19 19
 
20
-    use FilesManagement; // Files Management Trait
20
+	use FilesManagement; // Files Management Trait
21 21
 
22
-    // Права
23
-    public static function getItemIds($permtype = 'instruction_view')
24
-    {
25
-        //global $xoopsUser;
26
-        static $permissions = [];
27
-        // Если есть в статике
28
-        if (is_array($permissions) && array_key_exists($permtype, $permissions)) {
29
-            return $permissions[$permtype];
30
-        }
31
-        // Находим из базы
32
-        $moduleHandler          = xoops_getHandler('module');
33
-        $instrModule            = $moduleHandler->getByDirname('instruction');
34
-        $groups                 = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
35
-        $gpermHandler           = xoops_getHandler('groupperm');
36
-        $categories             = $gpermHandler->getItemIds($permtype, $groups, $instrModule->getVar('mid'));
37
-        $permissions[$permtype] = $categories;
38
-        return $categories;
39
-    }
22
+	// Права
23
+	public static function getItemIds($permtype = 'instruction_view')
24
+	{
25
+		//global $xoopsUser;
26
+		static $permissions = [];
27
+		// Если есть в статике
28
+		if (is_array($permissions) && array_key_exists($permtype, $permissions)) {
29
+			return $permissions[$permtype];
30
+		}
31
+		// Находим из базы
32
+		$moduleHandler          = xoops_getHandler('module');
33
+		$instrModule            = $moduleHandler->getByDirname('instruction');
34
+		$groups                 = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
35
+		$gpermHandler           = xoops_getHandler('groupperm');
36
+		$categories             = $gpermHandler->getItemIds($permtype, $groups, $instrModule->getVar('mid'));
37
+		$permissions[$permtype] = $categories;
38
+		return $categories;
39
+	}
40 40
 
41
-    // Редактор
42
-    public static function getWysiwygForm($caption, $name, $value = '')
43
-    {
44
-        $editor                   = false;
45
-        $editor_configs           = [];
46
-        $editor_configs['name']   = $name;
47
-        $editor_configs['value']  = $value;
48
-        $editor_configs['rows']   = 35;
49
-        $editor_configs['cols']   = 60;
50
-        $editor_configs['width']  = '100%';
51
-        $editor_configs['height'] = '350px';
52
-        $editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction'));
41
+	// Редактор
42
+	public static function getWysiwygForm($caption, $name, $value = '')
43
+	{
44
+		$editor                   = false;
45
+		$editor_configs           = [];
46
+		$editor_configs['name']   = $name;
47
+		$editor_configs['value']  = $value;
48
+		$editor_configs['rows']   = 35;
49
+		$editor_configs['cols']   = 60;
50
+		$editor_configs['width']  = '100%';
51
+		$editor_configs['height'] = '350px';
52
+		$editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction'));
53 53
 
54
-        $editor = new XoopsFormEditor($caption, $name, $editor_configs);
55
-        return $editor;
56
-    }
54
+		$editor = new XoopsFormEditor($caption, $name, $editor_configs);
55
+		return $editor;
56
+	}
57 57
 
58
-    // Получение значения переменной, переданной через GET или POST запрос
59
-    public static function cleanVars(&$global, $key, $default = '', $type = 'int')
60
-    {
61
-        switch ($type) {
62
-            case 'string':
63
-                $ret = isset($global[$key]) ? $global[$key] : $default;
64
-                break;
65
-            case 'int':
66
-            default:
67
-                $ret = isset($global[$key]) ? (int)$global[$key] : (int)$default;
68
-                break;
69
-        }
70
-        if (false === $ret) {
71
-            return $default;
72
-        }
73
-        return $ret;
74
-    }
58
+	// Получение значения переменной, переданной через GET или POST запрос
59
+	public static function cleanVars(&$global, $key, $default = '', $type = 'int')
60
+	{
61
+		switch ($type) {
62
+			case 'string':
63
+				$ret = isset($global[$key]) ? $global[$key] : $default;
64
+				break;
65
+			case 'int':
66
+			default:
67
+				$ret = isset($global[$key]) ? (int)$global[$key] : (int)$default;
68
+				break;
69
+		}
70
+		if (false === $ret) {
71
+			return $default;
72
+		}
73
+		return $ret;
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
                 break;
65 65
             case 'int':
66 66
             default:
67
-                $ret = isset($global[$key]) ? (int)$global[$key] : (int)$default;
67
+                $ret = isset($global[$key]) ? (int) $global[$key] : (int) $default;
68 68
                 break;
69 69
         }
70 70
         if (false === $ret) {
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
@@ -5,12 +5,12 @@
 block discarded – undo
5 5
 // Функция вызывается при добавлении комментария
6 6
 function instruction_com_update($pageid, $total_num)
7 7
 {
8
-    $db  = XoopsDatabaseFactory::getDatabaseConnection();
9
-    $sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid  = ' . $pageid;
10
-    $db->query($sql);
8
+	$db  = XoopsDatabaseFactory::getDatabaseConnection();
9
+	$sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid  = ' . $pageid;
10
+	$db->query($sql);
11 11
 }
12 12
 
13 13
 function instruction_com_approve(&$comment)
14 14
 {
15
-    // notification mail here
15
+	// notification mail here
16 16
 }
Please login to merge, or discard this patch.
include/config.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -23,60 +23,60 @@
 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'        => [
68
-        '/sql/wflinks.sql',
69
-        '/class/wfl_lists.php',
70
-        '/class/class_thumbnail.php',
71
-        '/vcard.php',
72
-    ],
73
-    'oldFolders'      => [
74
-        '/images',
75
-        '/css',
76
-        '/js',
77
-        '/tcpdf',
78
-        '/images',
79
-    ],
80
-    'modCopyright'    => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
66
+	],
67
+	'oldFiles'        => [
68
+		'/sql/wflinks.sql',
69
+		'/class/wfl_lists.php',
70
+		'/class/class_thumbnail.php',
71
+		'/vcard.php',
72
+	],
73
+	'oldFolders'      => [
74
+		'/images',
75
+		'/css',
76
+		'/js',
77
+		'/tcpdf',
78
+		'/images',
79
+	],
80
+	'modCopyright'    => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
81 81
                      <img src='" . constant($capsDirName . '_AUTHOR_LOGOIMG') . '\' alt=\'XOOPS Project\' /></a>',
82 82
 ];
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $moduleDirName = basename(dirname(__DIR__));
23 23
 $capsDirName   = strtoupper($moduleDirName);
24 24
 
25
-if (!defined($capsDirName . '_DIRNAME')) {
25
+if ( ! defined($capsDirName . '_DIRNAME')) {
26 26
     //if (!defined(constant($capsDirName . '_DIRNAME'))) {
27 27
     define($capsDirName . '_DIRNAME', $GLOBALS['xoopsModule']->dirname());
28 28
     define($capsDirName . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 }
36 36
 
37 37
 //Configurator
38
-return (object)[
38
+return (object) [
39 39
     'name'          => strtoupper($moduleDirName) . ' Module Configurator',
40 40
     'paths'         => [
41 41
         'dirname'    => $moduleDirName,
Please login to merge, or discard this patch.
include/pagetypes.inc.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 // Типы страницы
3 3
 return [
4
-    0 => _AM_INSTR_PT_0,
5
-    1 => _AM_INSTR_PT_1
4
+	0 => _AM_INSTR_PT_0,
5
+	1 => _AM_INSTR_PT_1
6 6
 ];
Please login to merge, or discard this patch.
include/common.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
  */
19 19
 
20 20
 if (!defined('INSTRUCTION_MODULE_PATH')) {
21
-    define('INSTRUCTION_DIRNAME', basename(dirname(__DIR__)));
22
-    define('INSTRUCTION_URL', XOOPS_URL . '/modules/' . INSTRUCTION_DIRNAME);
23
-    define('INSTRUCTION_IMAGE_URL', INSTRUCTION_URL . '/assets/images/');
24
-    define('INSTRUCTION_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . INSTRUCTION_DIRNAME);
25
-    define('INSTRUCTION_IMAGE_PATH', INSTRUCTION_ROOT_PATH . '/assets/images');
26
-    define('INSTRUCTION_ADMIN_URL', INSTRUCTION_URL . '/admin/');
27
-    define('INSTRUCTION_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . INSTRUCTION_DIRNAME);
28
-    define('INSTRUCTION_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . INSTRUCTION_DIRNAME);
21
+	define('INSTRUCTION_DIRNAME', basename(dirname(__DIR__)));
22
+	define('INSTRUCTION_URL', XOOPS_URL . '/modules/' . INSTRUCTION_DIRNAME);
23
+	define('INSTRUCTION_IMAGE_URL', INSTRUCTION_URL . '/assets/images/');
24
+	define('INSTRUCTION_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . INSTRUCTION_DIRNAME);
25
+	define('INSTRUCTION_IMAGE_PATH', INSTRUCTION_ROOT_PATH . '/assets/images');
26
+	define('INSTRUCTION_ADMIN_URL', INSTRUCTION_URL . '/admin/');
27
+	define('INSTRUCTION_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . INSTRUCTION_DIRNAME);
28
+	define('INSTRUCTION_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . INSTRUCTION_DIRNAME);
29 29
 }
30 30
 xoops_loadLanguage('common', INSTRUCTION_DIRNAME);
31 31
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 $instruction->loadLanguage('common');
47 47
 
48 48
 if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
49
-    require_once $GLOBALS['xoops']->path('class/template.php');
50
-    $xoopsTpl = new XoopsTpl();
49
+	require_once $GLOBALS['xoops']->path('class/template.php');
50
+	$xoopsTpl = new XoopsTpl();
51 51
 }
52 52
 
53 53
 $moduleDirName = basename(dirname(__DIR__));
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * @author       XOOPS Development Team
18 18
  */
19 19
 
20
-if (!defined('INSTRUCTION_MODULE_PATH')) {
20
+if ( ! defined('INSTRUCTION_MODULE_PATH')) {
21 21
     define('INSTRUCTION_DIRNAME', basename(dirname(__DIR__)));
22 22
     define('INSTRUCTION_URL', XOOPS_URL . '/modules/' . INSTRUCTION_DIRNAME);
23 23
     define('INSTRUCTION_IMAGE_URL', INSTRUCTION_URL . '/assets/images/');
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 $instruction = Instruction::getInstance();
46 46
 $instruction->loadLanguage('common');
47 47
 
48
-if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
48
+if ( ! isset($GLOBALS['xoopsTpl']) || ! ($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
49 49
     require_once $GLOBALS['xoops']->path('class/template.php');
50 50
     $xoopsTpl = new XoopsTpl();
51 51
 }
Please login to merge, or discard this patch.
include/plugin.tag.php 3 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -3,66 +3,66 @@
 block discarded – undo
3 3
 // Информация об теге
4 4
 function instruction_tag_iteminfo(&$items)
5 5
 {
6
-    if (empty($items) || !is_array($items)) {
7
-        return false;
8
-    }
6
+	if (empty($items) || !is_array($items)) {
7
+		return false;
8
+	}
9 9
 
10
-    $items_id = [];
11
-    foreach (array_keys($items) as $cat_id) {
12
-        foreach (array_keys($items[$cat_id]) as $item_id) {
13
-            $items_id[] = (int)$item_id;
14
-        }
15
-    }
10
+	$items_id = [];
11
+	foreach (array_keys($items) as $cat_id) {
12
+		foreach (array_keys($items[$cat_id]) as $item_id) {
13
+			$items_id[] = (int)$item_id;
14
+		}
15
+	}
16 16
 
17
-    $itemHandler = xoops_getModuleHandler('instruction', 'instruction');
18
-    $items_obj   = $itemHandler->getObjects(new Criteria('instrid', '(' . implode(', ', $items_id) . ')', 'IN'), true);
17
+	$itemHandler = xoops_getModuleHandler('instruction', 'instruction');
18
+	$items_obj   = $itemHandler->getObjects(new Criteria('instrid', '(' . implode(', ', $items_id) . ')', 'IN'), true);
19 19
 
20
-    foreach (array_keys($items) as $cat_id) {
21
-        foreach (array_keys($items[$cat_id]) as $item_id) {
22
-            if (isset($items_obj[$item_id])) {
23
-                $item_obj                 = $items_obj[$item_id];
24
-                $items[$cat_id][$item_id] = [
25
-                    'title'   => $item_obj->getVar('title'),
26
-                    'uid'     => $item_obj->getVar('uid'),
27
-                    'link'    => "instr.php?id={$item_id}",
28
-                    'time'    => $item_obj->getVar('datecreated'),
29
-                    'tags'    => '',
30
-                    'content' => '',
31
-                ];
32
-            }
33
-        }
34
-    }
35
-    unset($items_obj);
20
+	foreach (array_keys($items) as $cat_id) {
21
+		foreach (array_keys($items[$cat_id]) as $item_id) {
22
+			if (isset($items_obj[$item_id])) {
23
+				$item_obj                 = $items_obj[$item_id];
24
+				$items[$cat_id][$item_id] = [
25
+					'title'   => $item_obj->getVar('title'),
26
+					'uid'     => $item_obj->getVar('uid'),
27
+					'link'    => "instr.php?id={$item_id}",
28
+					'time'    => $item_obj->getVar('datecreated'),
29
+					'tags'    => '',
30
+					'content' => '',
31
+				];
32
+			}
33
+		}
34
+	}
35
+	unset($items_obj);
36 36
 }
37 37
 
38 38
 // Синхронизация тегов
39 39
 function instruction_tag_synchronization($mid)
40 40
 {
41
-    $itemHandler = xoops_getModuleHandler('instruction', 'instruction');
42
-    $linkHandler = xoops_getModuleHandler('link', 'tag');
41
+	$itemHandler = xoops_getModuleHandler('instruction', 'instruction');
42
+	$linkHandler = xoops_getModuleHandler('link', 'tag');
43 43
 
44
-    /* clear tag-item links */
45
-    if (version_compare(mysqli_get_server_info(), '4.1.0', 'ge')):
46
-        $sql = "    DELETE FROM {$linkHandler->table}"
47
-               . '    WHERE '
48
-               . "        tag_modid = {$mid}"
49
-               . '        AND '
50
-               . '        ( tag_itemid NOT IN '
51
-               . "            ( SELECT DISTINCT {$itemHandler->keyName} "
52
-               . "                FROM {$itemHandler->table} "
53
-               . "                WHERE {$itemHandler->table}.status > 0"
54
-               . '            ) '
55
-               . '        )'; else:
56
-        $sql = "    DELETE {$linkHandler->table} FROM {$linkHandler->table}"
57
-               . "    LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} "
58
-               . '    WHERE '
59
-               . "        tag_modid = {$mid}"
60
-               . '        AND '
61
-               . "        ( aa.{$itemHandler->keyName} IS NULL"
62
-               . '            OR aa.status < 1'
63
-               . '        )';
64
-    endif;
65
-    if (!$result = $linkHandler->db->queryF($sql)) {
66
-        //xoops_error($linkHandler->db->error());
67
-    }
44
+	/* clear tag-item links */
45
+	if (version_compare(mysqli_get_server_info(), '4.1.0', 'ge')):
46
+		$sql = "    DELETE FROM {$linkHandler->table}"
47
+			   . '    WHERE '
48
+			   . "        tag_modid = {$mid}"
49
+			   . '        AND '
50
+			   . '        ( tag_itemid NOT IN '
51
+			   . "            ( SELECT DISTINCT {$itemHandler->keyName} "
52
+			   . "                FROM {$itemHandler->table} "
53
+			   . "                WHERE {$itemHandler->table}.status > 0"
54
+			   . '            ) '
55
+			   . '        )'; else:
56
+		$sql = "    DELETE {$linkHandler->table} FROM {$linkHandler->table}"
57
+			   . "    LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} "
58
+			   . '    WHERE '
59
+			   . "        tag_modid = {$mid}"
60
+			   . '        AND '
61
+			   . "        ( aa.{$itemHandler->keyName} IS NULL"
62
+			   . '            OR aa.status < 1'
63
+			   . '        )';
64
+	endif;
65
+	if (!$result = $linkHandler->db->queryF($sql)) {
66
+		//xoops_error($linkHandler->db->error());
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
3 3
 // Информация об теге
4 4
 function instruction_tag_iteminfo(&$items)
5 5
 {
6
-    if (empty($items) || !is_array($items)) {
6
+    if (empty($items) || ! is_array($items)) {
7 7
         return false;
8 8
     }
9 9
 
10 10
     $items_id = [];
11 11
     foreach (array_keys($items) as $cat_id) {
12 12
         foreach (array_keys($items[$cat_id]) as $item_id) {
13
-            $items_id[] = (int)$item_id;
13
+            $items_id[] = (int) $item_id;
14 14
         }
15 15
     }
16 16
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                . '            OR aa.status < 1'
63 63
                . '        )';
64 64
     endif;
65
-    if (!$result = $linkHandler->db->queryF($sql)) {
65
+    if ( ! $result = $linkHandler->db->queryF($sql)) {
66 66
         //xoops_error($linkHandler->db->error());
67 67
     }
68 68
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,8 @@  discard block
 block discarded – undo
52 52
                . "                FROM {$itemHandler->table} "
53 53
                . "                WHERE {$itemHandler->table}.status > 0"
54 54
                . '            ) '
55
-               . '        )'; else:
55
+               . '        )'; else {
56
+               	:
56 57
         $sql = "    DELETE {$linkHandler->table} FROM {$linkHandler->table}"
57 58
                . "    LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} "
58 59
                . '    WHERE '
@@ -60,7 +61,8 @@  discard block
 block discarded – undo
60 61
                . '        AND '
61 62
                . "        ( aa.{$itemHandler->keyName} IS NULL"
62 63
                . '            OR aa.status < 1'
63
-               . '        )';
64
+               . '        )';
65
+               }
64 66
     endif;
65 67
     if (!$result = $linkHandler->db->queryF($sql)) {
66 68
         //xoops_error($linkHandler->db->error());
Please login to merge, or discard this patch.
include/search.inc.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 
10 10
     $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';
11 11
     if (0 != $userid) {
12
-        $sql .= ' AND p.uid = ' . (int)$userid . ' ';
12
+        $sql .= ' AND p.uid = ' . (int) $userid . ' ';
13 13
         //return NULL;
14 14
     }
15 15
 
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -4,45 +4,45 @@
 block discarded – undo
4 4
 
5 5
 function instruction_search($queryarray, $andor, $limit, $offset, $userid)
6 6
 {
7
-    // Подключаем функции
8
-    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
7
+	// Подключаем функции
8
+	include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
9 9
 
10
-    $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';
11
-    if (0 != $userid) {
12
-        $sql .= ' AND p.uid = ' . (int)$userid . ' ';
13
-        //return NULL;
14
-    }
10
+	$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';
11
+	if (0 != $userid) {
12
+		$sql .= ' AND p.uid = ' . (int)$userid . ' ';
13
+		//return NULL;
14
+	}
15 15
 
16
-    // Права на просмотр
17
-    $categories = InstructionUtility::getItemIds();
18
-    if (is_array($categories) && count($categories) > 0) {
19
-        $sql .= ' AND i.cid IN ( ' . implode(', ', $categories) . ' ) ';
20
-        // Если пользователь не имеет прав просмотра ни одной категории
21
-    } else {
22
-        return null;
23
-    }
16
+	// Права на просмотр
17
+	$categories = InstructionUtility::getItemIds();
18
+	if (is_array($categories) && count($categories) > 0) {
19
+		$sql .= ' AND i.cid IN ( ' . implode(', ', $categories) . ' ) ';
20
+		// Если пользователь не имеет прав просмотра ни одной категории
21
+	} else {
22
+		return null;
23
+	}
24 24
 
25
-    // Добавляем в условие ключевые слова поиска
26
-    if (is_array($queryarray) && $count = count($queryarray)) {
27
-        $sql .= " AND ( ( p.title LIKE '%$queryarray[0]%' OR p.hometext LIKE '%$queryarray[0]%' )";
28
-        for ($i = 1; $i < $count; $i++) {
29
-            $sql .= " $andor ";
30
-            $sql .= "( p.title LIKE '%$queryarray[$i]%' OR p.hometext LIKE '%$queryarray[$i]%' )";
31
-        }
32
-        $sql .= ' ) ';
33
-    }
34
-    //$sql .= "ORDER BY date DESC";
35
-    $result = $GLOBALS['xoopsDB']->query($sql, $limit, $offset);
36
-    $ret    = [];
37
-    $i      = 0;
38
-    // Перебираем все результаты
39
-    while (list($pageid, $ptitle, $puid, $pdatecreated, $ititle) = $GLOBALS['xoopsDB']->fetchRow($result)) {
40
-        $ret[$i]['image'] = 'assets/images/size2.gif';
41
-        $ret[$i]['link']  = 'page.php?id=' . $pageid;
42
-        $ret[$i]['title'] = $ititle . ': ' . $ptitle;
43
-        $ret[$i]['time']  = $pdatecreated;
44
-        $ret[$i]['uid']   = $puid;
45
-        $i++;
46
-    }
47
-    return $ret;
25
+	// Добавляем в условие ключевые слова поиска
26
+	if (is_array($queryarray) && $count = count($queryarray)) {
27
+		$sql .= " AND ( ( p.title LIKE '%$queryarray[0]%' OR p.hometext LIKE '%$queryarray[0]%' )";
28
+		for ($i = 1; $i < $count; $i++) {
29
+			$sql .= " $andor ";
30
+			$sql .= "( p.title LIKE '%$queryarray[$i]%' OR p.hometext LIKE '%$queryarray[$i]%' )";
31
+		}
32
+		$sql .= ' ) ';
33
+	}
34
+	//$sql .= "ORDER BY date DESC";
35
+	$result = $GLOBALS['xoopsDB']->query($sql, $limit, $offset);
36
+	$ret    = [];
37
+	$i      = 0;
38
+	// Перебираем все результаты
39
+	while (list($pageid, $ptitle, $puid, $pdatecreated, $ititle) = $GLOBALS['xoopsDB']->fetchRow($result)) {
40
+		$ret[$i]['image'] = 'assets/images/size2.gif';
41
+		$ret[$i]['link']  = 'page.php?id=' . $pageid;
42
+		$ret[$i]['title'] = $ititle . ': ' . $ptitle;
43
+		$ret[$i]['time']  = $pdatecreated;
44
+		$ret[$i]['uid']   = $puid;
45
+		$i++;
46
+	}
47
+	return $ret;
48 48
 }
Please login to merge, or discard this patch.
submit.php 2 patches
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -36,195 +36,195 @@
 block discarded – undo
36 36
 
37 37
 switch ($op) {
38 38
 
39
-    case 'editpage':
40
-
41
-        // Задание тайтла
42
-        $xoopsOption['xoops_pagetitle'] = '';
43
-        // Шаблон
44
-        $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_editpage.tpl';
45
-        // Заголовок
46
-        include_once $GLOBALS['xoops']->path('header.php');
47
-
48
-        // Если мы редактируем страницу
49
-        if ($pageid) {
50
-            // Получаем объект страницы
51
-            $objInspage = $inspageHandler->get($pageid);
52
-            // ID инструкции
53
-            $instrid = $objInspage->getVar('instrid');
54
-            // Объект инструкции
55
-            $objInsinstr = $insinstrHandler->get($instrid);
56
-            // Можно ли редактировать инструкцию в данной категории
57
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
58
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
59
-            }
60
-            // Создание новой страницы
61
-        } elseif ($instrid) {
62
-
63
-            // Если нельзя добавлять не в одну категорию
64
-            //if( ! count( $cat_submit ) ) redirect_header( 'index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMIT_PAGE );
65
-            // Создаём объект страницы
66
-            $objInspage = $inspageHandler->create();
67
-            // Объект инструкции
68
-            $objInsinstr = $insinstrHandler->get($instrid);
69
-            // Можно ли добавлять инструкции в данной категории
70
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
71
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
72
-            }
73
-        } else {
74
-            redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
75
-        }
76
-
77
-        // Информация об инструкции
78
-
79
-        // Массив данных об инструкции
80
-        $instrs = [];
81
-        // ID инструкции
82
-        $instrs['instrid'] = $objInsinstr->getVar('instrid');
83
-        // Название страницы
84
-        $instrs['title'] = $objInsinstr->getVar('title');
85
-        // Описание
86
-        $instrs['description'] = $objInsinstr->getVar('description');
87
-
88
-        // Выводим в шаблон
89
-        $GLOBALS['xoopsTpl']->assign('insInstr', $instrs);
90
-
91
-        //
92
-
93
-        $form = $objInspage->getForm('submit.php', $instrid);
94
-        // Форма
95
-        $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
96
-
97
-        // Подвал
98
-        include_once $GLOBALS['xoops']->path('footer.php');
99
-
100
-        break;
101
-    // Сохранение страницы
102
-    case 'savepage':
103
-
104
-        // Проверка
105
-        if (!$GLOBALS['xoopsSecurity']->check()) {
106
-            redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
107
-        }
108
-
109
-        $err         = false;
110
-        $message_err = '';
111
-
112
-        // Если мы редактируем
113
-        if ($pageid) {
114
-            $objInspage = $inspageHandler->get($pageid);
115
-            // Объект инструкции
116
-            $objInsinstr = $insinstrHandler->get($objInspage->getVar('instrid'));
117
-            // Можно ли редактировать инструкцию в данной категории
118
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
119
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
120
-            }
121
-        } elseif ($instrid) {
122
-            $objInspage = $inspageHandler->create();
123
-            // Объект инструкции
124
-            $objInsinstr = $insinstrHandler->get($instrid);
125
-            // Можно ли добавлять инструкции в данной категории
126
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
127
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
128
-            }
129
-
130
-            // Если мы создаём страницу необходимо указать к какой инструкции
131
-            $objInspage->setVar('instrid', $instrid);
132
-            // Указываем дату создания
133
-            $objInspage->setVar('datecreated', $time);
134
-            // Указываем пользователя
135
-            $objInspage->setVar('uid', $uid);
136
-        } else {
137
-            redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
138
-        }
139
-
140
-        // Родительская страница
141
-        $objInspage->setVar('pid', $pid);
142
-        // Дата обновления
143
-        $objInspage->setVar('dateupdated', $time);
144
-        //
145
-        $objInspage->setVar('title', $_POST['title']);
146
-        $objInspage->setVar('weight', $weight);
147
-        $objInspage->setVar('hometext', $_POST['hometext']);
148
-        // Сноска
149
-        $objInspage->setVar('footnote', $_POST['footnote']);
150
-        $objInspage->setVar('status', $_POST['status']);
151
-        $objInspage->setVar('keywords', $_POST['keywords']);
152
-        $objInspage->setVar('description', $_POST['description']);
153
-
154
-        // Проверка категорий
155
-        if (!$pageid && !$instrid) {
156
-            $err         = true;
157
-            $message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
158
-        }
159
-        // Проверка веса
160
-        if (0 == $weight) {
161
-            $err         = true;
162
-            $message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
163
-        }
164
-        // Проверка родительской страницы
165
-        if ($pageid && ($pageid == $pid)) {
166
-            $err         = true;
167
-            $message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
168
-        }
169
-        // Если были ошибки
170
-        if (true === $err) {
171
-            // Задание тайтла
172
-            $xoopsOption['xoops_pagetitle'] = '';
173
-            // Шаблон
174
-            $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
175
-            // Заголовок
176
-            include_once $GLOBALS['xoops']->path('header.php');
177
-            // Сообщение об ошибке
178
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
179
-            // Выводим ошибки в шаблон
180
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
181
-            // Если небыло ошибок
182
-        } else {
183
-            // Вставляем данные в БД
184
-            if ($inspageHandler->insert($objInspage)) {
185
-                // Если мы редактируем
186
-                if ($pageid) {
187
-                    // Обновление даты
188
-                    $sql = sprintf('UPDATE %s SET `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
189
-                    $GLOBALS['xoopsDB']->query($sql);
190
-                    // Запись в лог
191
-                    xoops_loadLanguage('main', 'userslog');
192
-                    //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_MODIFY_PAGE );
193
-                    //
194
-                    redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEMODIFY);
195
-                    // Если мы добавляем
196
-                } else {
197
-                    // Инкримент комментов
198
-                    $inspageHandler->updateposts($uid, $_POST['status'], 'add');
199
-                    // Инкремент страниц и обновление даты
200
-                    $sql = sprintf('UPDATE %s SET `pages` = `pages` + 1, `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
201
-                    $GLOBALS['xoopsDB']->query($sql);
202
-                    // Запись в лог
203
-                    xoops_loadLanguage('main', 'userslog');
204
-                    //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_SUBMIT_PAGE );
205
-                    //
206
-                    redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEADDED);
207
-                }
208
-            }
209
-
210
-            // Задание тайтла
211
-            $xoopsOption['xoops_pagetitle'] = '';
212
-            // Шаблон
213
-            $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
214
-            // Заголовок
215
-            include_once $GLOBALS['xoops']->path('header.php');
216
-
217
-            // Выводим ошибки в шаблон
218
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
219
-        }
220
-        // Получаем форму
221
-        $form = $objInspage->getForm('submit.php', $instrid);
222
-
223
-        // Форма
224
-        $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
225
-
226
-        // Подвал
227
-        include_once $GLOBALS['xoops']->path('footer.php');
228
-
229
-        break;
39
+	case 'editpage':
40
+
41
+		// Задание тайтла
42
+		$xoopsOption['xoops_pagetitle'] = '';
43
+		// Шаблон
44
+		$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_editpage.tpl';
45
+		// Заголовок
46
+		include_once $GLOBALS['xoops']->path('header.php');
47
+
48
+		// Если мы редактируем страницу
49
+		if ($pageid) {
50
+			// Получаем объект страницы
51
+			$objInspage = $inspageHandler->get($pageid);
52
+			// ID инструкции
53
+			$instrid = $objInspage->getVar('instrid');
54
+			// Объект инструкции
55
+			$objInsinstr = $insinstrHandler->get($instrid);
56
+			// Можно ли редактировать инструкцию в данной категории
57
+			if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
58
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
59
+			}
60
+			// Создание новой страницы
61
+		} elseif ($instrid) {
62
+
63
+			// Если нельзя добавлять не в одну категорию
64
+			//if( ! count( $cat_submit ) ) redirect_header( 'index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMIT_PAGE );
65
+			// Создаём объект страницы
66
+			$objInspage = $inspageHandler->create();
67
+			// Объект инструкции
68
+			$objInsinstr = $insinstrHandler->get($instrid);
69
+			// Можно ли добавлять инструкции в данной категории
70
+			if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
71
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
72
+			}
73
+		} else {
74
+			redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
75
+		}
76
+
77
+		// Информация об инструкции
78
+
79
+		// Массив данных об инструкции
80
+		$instrs = [];
81
+		// ID инструкции
82
+		$instrs['instrid'] = $objInsinstr->getVar('instrid');
83
+		// Название страницы
84
+		$instrs['title'] = $objInsinstr->getVar('title');
85
+		// Описание
86
+		$instrs['description'] = $objInsinstr->getVar('description');
87
+
88
+		// Выводим в шаблон
89
+		$GLOBALS['xoopsTpl']->assign('insInstr', $instrs);
90
+
91
+		//
92
+
93
+		$form = $objInspage->getForm('submit.php', $instrid);
94
+		// Форма
95
+		$GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
96
+
97
+		// Подвал
98
+		include_once $GLOBALS['xoops']->path('footer.php');
99
+
100
+		break;
101
+	// Сохранение страницы
102
+	case 'savepage':
103
+
104
+		// Проверка
105
+		if (!$GLOBALS['xoopsSecurity']->check()) {
106
+			redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
107
+		}
108
+
109
+		$err         = false;
110
+		$message_err = '';
111
+
112
+		// Если мы редактируем
113
+		if ($pageid) {
114
+			$objInspage = $inspageHandler->get($pageid);
115
+			// Объект инструкции
116
+			$objInsinstr = $insinstrHandler->get($objInspage->getVar('instrid'));
117
+			// Можно ли редактировать инструкцию в данной категории
118
+			if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
119
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
120
+			}
121
+		} elseif ($instrid) {
122
+			$objInspage = $inspageHandler->create();
123
+			// Объект инструкции
124
+			$objInsinstr = $insinstrHandler->get($instrid);
125
+			// Можно ли добавлять инструкции в данной категории
126
+			if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
127
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
128
+			}
129
+
130
+			// Если мы создаём страницу необходимо указать к какой инструкции
131
+			$objInspage->setVar('instrid', $instrid);
132
+			// Указываем дату создания
133
+			$objInspage->setVar('datecreated', $time);
134
+			// Указываем пользователя
135
+			$objInspage->setVar('uid', $uid);
136
+		} else {
137
+			redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
138
+		}
139
+
140
+		// Родительская страница
141
+		$objInspage->setVar('pid', $pid);
142
+		// Дата обновления
143
+		$objInspage->setVar('dateupdated', $time);
144
+		//
145
+		$objInspage->setVar('title', $_POST['title']);
146
+		$objInspage->setVar('weight', $weight);
147
+		$objInspage->setVar('hometext', $_POST['hometext']);
148
+		// Сноска
149
+		$objInspage->setVar('footnote', $_POST['footnote']);
150
+		$objInspage->setVar('status', $_POST['status']);
151
+		$objInspage->setVar('keywords', $_POST['keywords']);
152
+		$objInspage->setVar('description', $_POST['description']);
153
+
154
+		// Проверка категорий
155
+		if (!$pageid && !$instrid) {
156
+			$err         = true;
157
+			$message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
158
+		}
159
+		// Проверка веса
160
+		if (0 == $weight) {
161
+			$err         = true;
162
+			$message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
163
+		}
164
+		// Проверка родительской страницы
165
+		if ($pageid && ($pageid == $pid)) {
166
+			$err         = true;
167
+			$message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
168
+		}
169
+		// Если были ошибки
170
+		if (true === $err) {
171
+			// Задание тайтла
172
+			$xoopsOption['xoops_pagetitle'] = '';
173
+			// Шаблон
174
+			$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
175
+			// Заголовок
176
+			include_once $GLOBALS['xoops']->path('header.php');
177
+			// Сообщение об ошибке
178
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
179
+			// Выводим ошибки в шаблон
180
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
181
+			// Если небыло ошибок
182
+		} else {
183
+			// Вставляем данные в БД
184
+			if ($inspageHandler->insert($objInspage)) {
185
+				// Если мы редактируем
186
+				if ($pageid) {
187
+					// Обновление даты
188
+					$sql = sprintf('UPDATE %s SET `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
189
+					$GLOBALS['xoopsDB']->query($sql);
190
+					// Запись в лог
191
+					xoops_loadLanguage('main', 'userslog');
192
+					//userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_MODIFY_PAGE );
193
+					//
194
+					redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEMODIFY);
195
+					// Если мы добавляем
196
+				} else {
197
+					// Инкримент комментов
198
+					$inspageHandler->updateposts($uid, $_POST['status'], 'add');
199
+					// Инкремент страниц и обновление даты
200
+					$sql = sprintf('UPDATE %s SET `pages` = `pages` + 1, `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
201
+					$GLOBALS['xoopsDB']->query($sql);
202
+					// Запись в лог
203
+					xoops_loadLanguage('main', 'userslog');
204
+					//userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_SUBMIT_PAGE );
205
+					//
206
+					redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEADDED);
207
+				}
208
+			}
209
+
210
+			// Задание тайтла
211
+			$xoopsOption['xoops_pagetitle'] = '';
212
+			// Шаблон
213
+			$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
214
+			// Заголовок
215
+			include_once $GLOBALS['xoops']->path('header.php');
216
+
217
+			// Выводим ошибки в шаблон
218
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
219
+		}
220
+		// Получаем форму
221
+		$form = $objInspage->getForm('submit.php', $instrid);
222
+
223
+		// Форма
224
+		$GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
225
+
226
+		// Подвал
227
+		include_once $GLOBALS['xoops']->path('footer.php');
228
+
229
+		break;
230 230
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@  discard block
 block discarded – undo
14 14
 $time = time();
15 15
 
16 16
 // ID инструкции
17
-$instrid = isset($_GET['instrid']) ? (int)$_GET['instrid'] : 0;
18
-$instrid = isset($_POST['instrid']) ? (int)$_POST['instrid'] : $instrid;
17
+$instrid = isset($_GET['instrid']) ? (int) $_GET['instrid'] : 0;
18
+$instrid = isset($_POST['instrid']) ? (int) $_POST['instrid'] : $instrid;
19 19
 // ID страницы
20
-$pageid = isset($_GET['pageid']) ? (int)$_GET['pageid'] : 0;
21
-$pageid = isset($_POST['pageid']) ? (int)$_POST['pageid'] : $pageid;
20
+$pageid = isset($_GET['pageid']) ? (int) $_GET['pageid'] : 0;
21
+$pageid = isset($_POST['pageid']) ? (int) $_POST['pageid'] : $pageid;
22 22
 // ID категории
23
-$cid = isset($_POST['cid']) ? (int)$_POST['cid'] : 0;
23
+$cid = isset($_POST['cid']) ? (int) $_POST['cid'] : 0;
24 24
 // Вес
25
-$weight = isset($_POST['weight']) ? (int)$_POST['weight'] : 0;
25
+$weight = isset($_POST['weight']) ? (int) $_POST['weight'] : 0;
26 26
 //
27
-$pid = isset($_POST['pid']) ? (int)$_POST['pid'] : 0;
27
+$pid = isset($_POST['pid']) ? (int) $_POST['pid'] : 0;
28 28
 
29 29
 // Права на добавление
30 30
 $cat_submit = InstructionUtility::getItemIds($moduleDirName . '_submit');
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             // Объект инструкции
55 55
             $objInsinstr = $insinstrHandler->get($instrid);
56 56
             // Можно ли редактировать инструкцию в данной категории
57
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
57
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_edit)) {
58 58
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
59 59
             }
60 60
             // Создание новой страницы
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             // Объект инструкции
68 68
             $objInsinstr = $insinstrHandler->get($instrid);
69 69
             // Можно ли добавлять инструкции в данной категории
70
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
70
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_submit)) {
71 71
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
72 72
             }
73 73
         } else {
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     case 'savepage':
103 103
 
104 104
         // Проверка
105
-        if (!$GLOBALS['xoopsSecurity']->check()) {
105
+        if ( ! $GLOBALS['xoopsSecurity']->check()) {
106 106
             redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
107 107
         }
108 108
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             // Объект инструкции
116 116
             $objInsinstr = $insinstrHandler->get($objInspage->getVar('instrid'));
117 117
             // Можно ли редактировать инструкцию в данной категории
118
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
118
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_edit)) {
119 119
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
120 120
             }
121 121
         } elseif ($instrid) {
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             // Объект инструкции
124 124
             $objInsinstr = $insinstrHandler->get($instrid);
125 125
             // Можно ли добавлять инструкции в данной категории
126
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
126
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_submit)) {
127 127
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
128 128
             }
129 129
 
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
         $objInspage->setVar('description', $_POST['description']);
153 153
 
154 154
         // Проверка категорий
155
-        if (!$pageid && !$instrid) {
156
-            $err         = true;
155
+        if ( ! $pageid && ! $instrid) {
156
+            $err = true;
157 157
             $message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
158 158
         }
159 159
         // Проверка веса
160 160
         if (0 == $weight) {
161
-            $err         = true;
161
+            $err = true;
162 162
             $message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
163 163
         }
164 164
         // Проверка родительской страницы
165 165
         if ($pageid && ($pageid == $pid)) {
166
-            $err         = true;
166
+            $err = true;
167 167
             $message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
168 168
         }
169 169
         // Если были ошибки
Please login to merge, or discard this patch.
page.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 $criteria->add(new Criteria('pageid ', $pageid));
29 29
 $criteria->add(new Criteria('status ', '0', '>'));
30 30
 if (0 == $inspageHandler->getCount($criteria)) {
31
-    redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST);
32
-    exit();
31
+	redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST);
32
+	exit();
33 33
 }
34 34
 //
35 35
 unset($criteria);
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 
42 42
 // Если админ и ссылка на отключение кэша
43 43
 if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin() && $nocache) {
44
-    // Отключаем кэш
45
-    $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
44
+	// Отключаем кэш
45
+	$GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
46 46
 }
47 47
 
48 48
 // Задание тайтла
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 // Права на просмотр инструкции
60 60
 $categories = InstructionUtility::getItemIds();
61 61
 if (!in_array($objInsinstr->getVar('cid'), $categories)) {
62
-    redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
63
-    exit();
62
+	redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
63
+	exit();
64 64
 }
65 65
 
66 66
 // Массив данных о странице
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 $footnote = $objInspage->getVar('footnote');
78 78
 // Если есть сноски
79 79
 if ($footnote) {
80
-    $pages['footnotes'] = explode('|', $objInspage->getVar('footnote'));
80
+	$pages['footnotes'] = explode('|', $objInspage->getVar('footnote'));
81 81
 } else {
82
-    $pages['footnotes'] = false;
82
+	$pages['footnotes'] = false;
83 83
 }
84 84
 // Мета-теги ключевых слов
85 85
 $pages['keywords'] = $objInspage->getVar('keywords');
@@ -88,39 +88,39 @@  discard block
 block discarded – undo
88 88
 //
89 89
 // Если админ, рисуем админлинк
90 90
 if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) {
91
-    $pages['adminlink'] = '&nbsp;<a href="'
92
-                          . XOOPS_URL
93
-                          . '/modules/'
94
-                          . $moduleDirName
95
-                          . '/admin/instr.php?op=editpage&pageid='
96
-                          . $pages['pageid']
97
-                          . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt='
98
-                          . _EDIT
99
-                          . ' title='
100
-                          . _EDIT
101
-                          . '></a>&nbsp;<a href="'
102
-                          . XOOPS_URL
103
-                          . '/modules/'
104
-                          . $moduleDirName
105
-                          . '/admin/instr.php?op=delpage&pageid='
106
-                          . $pages['pageid']
107
-                          . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt='
108
-                          . _DELETE
109
-                          . ' title='
110
-                          . _DELETE
111
-                          . '></a>&nbsp;';
91
+	$pages['adminlink'] = '&nbsp;<a href="'
92
+						  . XOOPS_URL
93
+						  . '/modules/'
94
+						  . $moduleDirName
95
+						  . '/admin/instr.php?op=editpage&pageid='
96
+						  . $pages['pageid']
97
+						  . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt='
98
+						  . _EDIT
99
+						  . ' title='
100
+						  . _EDIT
101
+						  . '></a>&nbsp;<a href="'
102
+						  . XOOPS_URL
103
+						  . '/modules/'
104
+						  . $moduleDirName
105
+						  . '/admin/instr.php?op=delpage&pageid='
106
+						  . $pages['pageid']
107
+						  . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt='
108
+						  . _DELETE
109
+						  . ' title='
110
+						  . _DELETE
111
+						  . '></a>&nbsp;';
112 112
 } else {
113
-    $pages['adminlink'] = '&nbsp;';
114
-    // Если можно редактировать
115
-    if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) {
116
-        $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>';
117
-    }
118
-
119
-    $pages['adminlink'] .= '&nbsp;';
120
-    // Если нет админлика
121
-    if ('[&nbsp;&nbsp;]' == $pages['adminlink']) {
122
-        $pages['adminlink'] = '';
123
-    }
113
+	$pages['adminlink'] = '&nbsp;';
114
+	// Если можно редактировать
115
+	if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) {
116
+		$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>';
117
+	}
118
+
119
+	$pages['adminlink'] .= '&nbsp;';
120
+	// Если нет админлика
121
+	if ('[&nbsp;&nbsp;]' == $pages['adminlink']) {
122
+		$pages['adminlink'] = '';
123
+	}
124 124
 }
125 125
 // Выводим в шаблон
126 126
 $GLOBALS['xoopsTpl']->assign('insPage', $pages);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 $nav_parent_id = array_reverse($nav_parent_id);
140 140
 $navigation    = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a>&nbsp;:&nbsp;';
141 141
 foreach (array_keys($nav_parent_id) as $i) {
142
-    $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a>&nbsp;:&nbsp;';
142
+	$navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a>&nbsp;:&nbsp;';
143 143
 }
144 144
 $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a>&nbsp;:&nbsp;';
145 145
 $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/instr.php?id=' . $pages['instrid'] . '">' . $objInsinstr->getVar('title') . '</a>';
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 
172 172
 // Рейтинг
173 173
 if (xoops_getModuleOption('userat', 'instruction')) {
174
-    $xoopsTpl->assign('insUserat', true);
174
+	$xoopsTpl->assign('insUserat', true);
175 175
 } else {
176
-    $xoopsTpl->assign('insUserat', false);
176
+	$xoopsTpl->assign('insUserat', false);
177 177
 }
178 178
 
179 179
 // Мета теги
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Получаем данные
21 21
 // ID страницы
22
-$pageid = isset($_GET['id']) ? (int)$_GET['id'] : 0;
22
+$pageid = isset($_GET['id']) ? (int) $_GET['id'] : 0;
23 23
 // Без кэша
24 24
 $nocache = InstructionUtility::cleanVars($_GET, 'nocache', 0, 'int');
25 25
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 // Права на просмотр инструкции
60 60
 $categories = InstructionUtility::getItemIds();
61
-if (!in_array($objInsinstr->getVar('cid'), $categories)) {
61
+if ( ! in_array($objInsinstr->getVar('cid'), $categories)) {
62 62
     redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
63 63
     exit();
64 64
 }
Please login to merge, or discard this patch.