@@ -16,226 +16,226 @@ |
||
16 | 16 | */ |
17 | 17 | trait FilesManagement |
18 | 18 | { |
19 | - /** |
|
20 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
21 | - * |
|
22 | - * @param string $folder The full path of the directory to check |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public static function createFolder($folder) |
|
27 | - { |
|
28 | - try { |
|
29 | - if (!file_exists($folder)) { |
|
30 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
31 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
32 | - } |
|
33 | - |
|
34 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
35 | - } |
|
36 | - } catch (Exception $e) { |
|
37 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
38 | - } |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param $file |
|
43 | - * @param $folder |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - public static function copyFile($file, $folder) |
|
47 | - { |
|
48 | - return copy($file, $folder); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @param $src |
|
53 | - * @param $dst |
|
54 | - */ |
|
55 | - public static function recurseCopy($src, $dst) |
|
56 | - { |
|
57 | - $dir = opendir($src); |
|
58 | - @mkdir($dst); |
|
59 | - while (false !== ($file = readdir($dir))) { |
|
60 | - if (('.' !== $file) && ('..' !== $file)) { |
|
61 | - if (is_dir($src . '/' . $file)) { |
|
62 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
63 | - } else { |
|
64 | - copy($src . '/' . $file, $dst . '/' . $file); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - closedir($dir); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * |
|
73 | - * Remove files and (sub)directories |
|
74 | - * |
|
75 | - * @param string $src source directory to delete |
|
76 | - * |
|
77 | - * @uses \Xmf\Module\Helper::getHelper() |
|
78 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
79 | - * |
|
80 | - * @return bool true on success |
|
81 | - */ |
|
82 | - public static function deleteDirectory($src) |
|
83 | - { |
|
84 | - // Only continue if user is a 'global' Admin |
|
85 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
86 | - return false; |
|
87 | - } |
|
88 | - |
|
89 | - $success = true; |
|
90 | - // remove old files |
|
91 | - $dirInfo = new SplFileInfo($src); |
|
92 | - // validate is a directory |
|
93 | - if ($dirInfo->isDir()) { |
|
94 | - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
95 | - foreach ($fileList as $k => $v) { |
|
96 | - $fileInfo = new SplFileInfo("{$src}/{$v}"); |
|
97 | - if ($fileInfo->isDir()) { |
|
98 | - // recursively handle subdirectories |
|
99 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
100 | - break; |
|
101 | - } |
|
102 | - } else { |
|
103 | - // delete the file |
|
104 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
105 | - break; |
|
106 | - } |
|
107 | - } |
|
108 | - } |
|
109 | - // now delete this (sub)directory if all the files are gone |
|
110 | - if ($success) { |
|
111 | - $success = rmdir($dirInfo->getRealPath()); |
|
112 | - } |
|
113 | - } else { |
|
114 | - // input is not a valid directory |
|
115 | - $success = false; |
|
116 | - } |
|
117 | - return $success; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * |
|
122 | - * Recursively remove directory |
|
123 | - * |
|
124 | - * @todo currently won't remove directories with hidden files, should it? |
|
125 | - * |
|
126 | - * @param string $src directory to remove (delete) |
|
127 | - * |
|
128 | - * @return bool true on success |
|
129 | - */ |
|
130 | - public static function rrmdir($src) |
|
131 | - { |
|
132 | - // Only continue if user is a 'global' Admin |
|
133 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
134 | - return false; |
|
135 | - } |
|
136 | - |
|
137 | - // If source is not a directory stop processing |
|
138 | - if (!is_dir($src)) { |
|
139 | - return false; |
|
140 | - } |
|
141 | - |
|
142 | - $success = true; |
|
143 | - |
|
144 | - // Open the source directory to read in files |
|
145 | - $iterator = new DirectoryIterator($src); |
|
146 | - foreach ($iterator as $fObj) { |
|
147 | - if ($fObj->isFile()) { |
|
148 | - $filename = $fObj->getPathname(); |
|
149 | - $fObj = null; // clear this iterator object to close the file |
|
150 | - if (!unlink($filename)) { |
|
151 | - return false; // couldn't delete the file |
|
152 | - } |
|
153 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
154 | - // Try recursively on directory |
|
155 | - self::rrmdir($fObj->getPathname()); |
|
156 | - } |
|
157 | - } |
|
158 | - $iterator = null; // clear iterator Obj to close file/directory |
|
159 | - return rmdir($src); // remove the directory & return results |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Recursively move files from one directory to another |
|
164 | - * |
|
165 | - * @param string $src - Source of files being moved |
|
166 | - * @param string $dest - Destination of files being moved |
|
167 | - * |
|
168 | - * @return bool true on success |
|
169 | - */ |
|
170 | - public static function rmove($src, $dest) |
|
171 | - { |
|
172 | - // Only continue if user is a 'global' Admin |
|
173 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
174 | - return false; |
|
175 | - } |
|
176 | - |
|
177 | - // If source is not a directory stop processing |
|
178 | - if (!is_dir($src)) { |
|
179 | - return false; |
|
180 | - } |
|
181 | - |
|
182 | - // If the destination directory does not exist and could not be created stop processing |
|
183 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
184 | - return false; |
|
185 | - } |
|
186 | - |
|
187 | - // Open the source directory to read in files |
|
188 | - $iterator = new DirectoryIterator($src); |
|
189 | - foreach ($iterator as $fObj) { |
|
190 | - if ($fObj->isFile()) { |
|
191 | - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
192 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
193 | - // Try recursively on directory |
|
194 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
195 | - // rmdir($fObj->getPath()); // now delete the directory |
|
196 | - } |
|
197 | - } |
|
198 | - $iterator = null; // clear iterator Obj to close file/directory |
|
199 | - return rmdir($src); // remove the directory & return results |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Recursively copy directories and files from one directory to another |
|
204 | - * |
|
205 | - * @param string $src - Source of files being moved |
|
206 | - * @param string $dest - Destination of files being moved |
|
207 | - * |
|
208 | - * @uses \Xmf\Module\Helper::getHelper() |
|
209 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
210 | - * |
|
211 | - * @return bool true on success |
|
212 | - */ |
|
213 | - public static function rcopy($src, $dest) |
|
214 | - { |
|
215 | - // Only continue if user is a 'global' Admin |
|
216 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
217 | - return false; |
|
218 | - } |
|
219 | - |
|
220 | - // If source is not a directory stop processing |
|
221 | - if (!is_dir($src)) { |
|
222 | - return false; |
|
223 | - } |
|
224 | - |
|
225 | - // If the destination directory does not exist and could not be created stop processing |
|
226 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
227 | - return false; |
|
228 | - } |
|
229 | - |
|
230 | - // Open the source directory to read in files |
|
231 | - $iterator = new DirectoryIterator($src); |
|
232 | - foreach ($iterator as $fObj) { |
|
233 | - if ($fObj->isFile()) { |
|
234 | - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
235 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
236 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
237 | - } |
|
238 | - } |
|
239 | - return true; |
|
240 | - } |
|
19 | + /** |
|
20 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
21 | + * |
|
22 | + * @param string $folder The full path of the directory to check |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public static function createFolder($folder) |
|
27 | + { |
|
28 | + try { |
|
29 | + if (!file_exists($folder)) { |
|
30 | + if (!mkdir($folder) && !is_dir($folder)) { |
|
31 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
32 | + } |
|
33 | + |
|
34 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
35 | + } |
|
36 | + } catch (Exception $e) { |
|
37 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
38 | + } |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param $file |
|
43 | + * @param $folder |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + public static function copyFile($file, $folder) |
|
47 | + { |
|
48 | + return copy($file, $folder); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @param $src |
|
53 | + * @param $dst |
|
54 | + */ |
|
55 | + public static function recurseCopy($src, $dst) |
|
56 | + { |
|
57 | + $dir = opendir($src); |
|
58 | + @mkdir($dst); |
|
59 | + while (false !== ($file = readdir($dir))) { |
|
60 | + if (('.' !== $file) && ('..' !== $file)) { |
|
61 | + if (is_dir($src . '/' . $file)) { |
|
62 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
63 | + } else { |
|
64 | + copy($src . '/' . $file, $dst . '/' . $file); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + closedir($dir); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * |
|
73 | + * Remove files and (sub)directories |
|
74 | + * |
|
75 | + * @param string $src source directory to delete |
|
76 | + * |
|
77 | + * @uses \Xmf\Module\Helper::getHelper() |
|
78 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
79 | + * |
|
80 | + * @return bool true on success |
|
81 | + */ |
|
82 | + public static function deleteDirectory($src) |
|
83 | + { |
|
84 | + // Only continue if user is a 'global' Admin |
|
85 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
86 | + return false; |
|
87 | + } |
|
88 | + |
|
89 | + $success = true; |
|
90 | + // remove old files |
|
91 | + $dirInfo = new SplFileInfo($src); |
|
92 | + // validate is a directory |
|
93 | + if ($dirInfo->isDir()) { |
|
94 | + $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
95 | + foreach ($fileList as $k => $v) { |
|
96 | + $fileInfo = new SplFileInfo("{$src}/{$v}"); |
|
97 | + if ($fileInfo->isDir()) { |
|
98 | + // recursively handle subdirectories |
|
99 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
100 | + break; |
|
101 | + } |
|
102 | + } else { |
|
103 | + // delete the file |
|
104 | + if (!($success = unlink($fileInfo->getRealPath()))) { |
|
105 | + break; |
|
106 | + } |
|
107 | + } |
|
108 | + } |
|
109 | + // now delete this (sub)directory if all the files are gone |
|
110 | + if ($success) { |
|
111 | + $success = rmdir($dirInfo->getRealPath()); |
|
112 | + } |
|
113 | + } else { |
|
114 | + // input is not a valid directory |
|
115 | + $success = false; |
|
116 | + } |
|
117 | + return $success; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * |
|
122 | + * Recursively remove directory |
|
123 | + * |
|
124 | + * @todo currently won't remove directories with hidden files, should it? |
|
125 | + * |
|
126 | + * @param string $src directory to remove (delete) |
|
127 | + * |
|
128 | + * @return bool true on success |
|
129 | + */ |
|
130 | + public static function rrmdir($src) |
|
131 | + { |
|
132 | + // Only continue if user is a 'global' Admin |
|
133 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
134 | + return false; |
|
135 | + } |
|
136 | + |
|
137 | + // If source is not a directory stop processing |
|
138 | + if (!is_dir($src)) { |
|
139 | + return false; |
|
140 | + } |
|
141 | + |
|
142 | + $success = true; |
|
143 | + |
|
144 | + // Open the source directory to read in files |
|
145 | + $iterator = new DirectoryIterator($src); |
|
146 | + foreach ($iterator as $fObj) { |
|
147 | + if ($fObj->isFile()) { |
|
148 | + $filename = $fObj->getPathname(); |
|
149 | + $fObj = null; // clear this iterator object to close the file |
|
150 | + if (!unlink($filename)) { |
|
151 | + return false; // couldn't delete the file |
|
152 | + } |
|
153 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
154 | + // Try recursively on directory |
|
155 | + self::rrmdir($fObj->getPathname()); |
|
156 | + } |
|
157 | + } |
|
158 | + $iterator = null; // clear iterator Obj to close file/directory |
|
159 | + return rmdir($src); // remove the directory & return results |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Recursively move files from one directory to another |
|
164 | + * |
|
165 | + * @param string $src - Source of files being moved |
|
166 | + * @param string $dest - Destination of files being moved |
|
167 | + * |
|
168 | + * @return bool true on success |
|
169 | + */ |
|
170 | + public static function rmove($src, $dest) |
|
171 | + { |
|
172 | + // Only continue if user is a 'global' Admin |
|
173 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
174 | + return false; |
|
175 | + } |
|
176 | + |
|
177 | + // If source is not a directory stop processing |
|
178 | + if (!is_dir($src)) { |
|
179 | + return false; |
|
180 | + } |
|
181 | + |
|
182 | + // If the destination directory does not exist and could not be created stop processing |
|
183 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
184 | + return false; |
|
185 | + } |
|
186 | + |
|
187 | + // Open the source directory to read in files |
|
188 | + $iterator = new DirectoryIterator($src); |
|
189 | + foreach ($iterator as $fObj) { |
|
190 | + if ($fObj->isFile()) { |
|
191 | + rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
192 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
193 | + // Try recursively on directory |
|
194 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
195 | + // rmdir($fObj->getPath()); // now delete the directory |
|
196 | + } |
|
197 | + } |
|
198 | + $iterator = null; // clear iterator Obj to close file/directory |
|
199 | + return rmdir($src); // remove the directory & return results |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Recursively copy directories and files from one directory to another |
|
204 | + * |
|
205 | + * @param string $src - Source of files being moved |
|
206 | + * @param string $dest - Destination of files being moved |
|
207 | + * |
|
208 | + * @uses \Xmf\Module\Helper::getHelper() |
|
209 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
210 | + * |
|
211 | + * @return bool true on success |
|
212 | + */ |
|
213 | + public static function rcopy($src, $dest) |
|
214 | + { |
|
215 | + // Only continue if user is a 'global' Admin |
|
216 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
217 | + return false; |
|
218 | + } |
|
219 | + |
|
220 | + // If source is not a directory stop processing |
|
221 | + if (!is_dir($src)) { |
|
222 | + return false; |
|
223 | + } |
|
224 | + |
|
225 | + // If the destination directory does not exist and could not be created stop processing |
|
226 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
227 | + return false; |
|
228 | + } |
|
229 | + |
|
230 | + // Open the source directory to read in files |
|
231 | + $iterator = new DirectoryIterator($src); |
|
232 | + foreach ($iterator as $fObj) { |
|
233 | + if ($fObj->isFile()) { |
|
234 | + copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
235 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
236 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
237 | + } |
|
238 | + } |
|
239 | + return true; |
|
240 | + } |
|
241 | 241 | } |
@@ -23,37 +23,37 @@ |
||
23 | 23 | */ |
24 | 24 | class Instruction extends \Xmf\Module\Helper |
25 | 25 | { |
26 | - public $debugArray = []; |
|
26 | + public $debugArray = []; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @internal param $debug |
|
30 | - */ |
|
31 | - protected function __construct() |
|
32 | - { |
|
33 | - // $this->debug = $debug; |
|
34 | - $this->dirname = basename(dirname(__DIR__)); |
|
35 | - } |
|
28 | + /** |
|
29 | + * @internal param $debug |
|
30 | + */ |
|
31 | + protected function __construct() |
|
32 | + { |
|
33 | + // $this->debug = $debug; |
|
34 | + $this->dirname = basename(dirname(__DIR__)); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param bool $debug |
|
39 | - * |
|
40 | - * @return Newbb |
|
41 | - */ |
|
42 | - public static function getInstance($debug = false) |
|
43 | - { |
|
44 | - static $instance; |
|
45 | - if (null === $instance) { |
|
46 | - $instance = new static($debug); |
|
47 | - } |
|
37 | + /** |
|
38 | + * @param bool $debug |
|
39 | + * |
|
40 | + * @return Newbb |
|
41 | + */ |
|
42 | + public static function getInstance($debug = false) |
|
43 | + { |
|
44 | + static $instance; |
|
45 | + if (null === $instance) { |
|
46 | + $instance = new static($debug); |
|
47 | + } |
|
48 | 48 | |
49 | - return $instance; |
|
50 | - } |
|
49 | + return $instance; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function getDirname() |
|
56 | - { |
|
57 | - return $this->dirname; |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function getDirname() |
|
56 | + { |
|
57 | + return $this->dirname; |
|
58 | + } |
|
59 | 59 | } |
@@ -13,63 +13,63 @@ |
||
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 | } |
@@ -10,62 +10,62 @@ discard block |
||
10 | 10 | $xoops_url = parse_url(XOOPS_URL); |
11 | 11 | |
12 | 12 | $modversion = [ |
13 | - 'version' => 1.06, |
|
14 | - 'module_status' => 'Beta 3', |
|
15 | - 'release_date' => '2017/05/11', |
|
16 | - 'name' => _MI_INSTRUCTION_NAME, |
|
17 | - 'description' => _MI_INSTRUCTION_DESC, |
|
18 | - 'credits' => 'radio-hobby.org, www.shmel.org', |
|
19 | - 'author' => 'andrey3761, aerograf', |
|
20 | - 'nickname' => '', |
|
21 | - 'help' => 'page=help', |
|
22 | - 'license' => 'GNU GPL 2.0', |
|
23 | - 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html/', |
|
24 | - 'official' => 0, |
|
25 | - 'image' => 'assets/images/slogo.png', |
|
26 | - 'dirname' => $moduleDirName, |
|
27 | - 'modicons16' => 'assets/images/icons/16', |
|
28 | - 'modicons32' => 'assets/images/icons/32', |
|
29 | - // О модуле |
|
30 | - 'module_website_url' => 'radio-hobby.org', |
|
31 | - 'module_website_name' => 'radio-hobby.org', |
|
13 | + 'version' => 1.06, |
|
14 | + 'module_status' => 'Beta 3', |
|
15 | + 'release_date' => '2017/05/11', |
|
16 | + 'name' => _MI_INSTRUCTION_NAME, |
|
17 | + 'description' => _MI_INSTRUCTION_DESC, |
|
18 | + 'credits' => 'radio-hobby.org, www.shmel.org', |
|
19 | + 'author' => 'andrey3761, aerograf', |
|
20 | + 'nickname' => '', |
|
21 | + 'help' => 'page=help', |
|
22 | + 'license' => 'GNU GPL 2.0', |
|
23 | + 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html/', |
|
24 | + 'official' => 0, |
|
25 | + 'image' => 'assets/images/slogo.png', |
|
26 | + 'dirname' => $moduleDirName, |
|
27 | + 'modicons16' => 'assets/images/icons/16', |
|
28 | + 'modicons32' => 'assets/images/icons/32', |
|
29 | + // О модуле |
|
30 | + 'module_website_url' => 'radio-hobby.org', |
|
31 | + 'module_website_name' => 'radio-hobby.org', |
|
32 | 32 | |
33 | - 'author_website_url' => 'radio-hobby.org', |
|
34 | - 'author_website_name' => 'andrey3761', |
|
35 | - 'module_website_url' => 'www.xoops.org', |
|
36 | - 'module_website_name' => 'Support site', |
|
37 | - 'min_php' => '5.5', |
|
38 | - 'min_xoops' => '2.5.8', |
|
39 | - 'min_admin' => '1.1', |
|
40 | - 'min_db' => ['mysql' => '5.5'], |
|
41 | - // Файл базы данных |
|
42 | - 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
43 | - // Таблицы |
|
44 | - 'tables' => [ |
|
45 | - $moduleDirName . '_cat', |
|
46 | - $moduleDirName . '_instr', |
|
47 | - $moduleDirName . '_page' |
|
48 | - ], |
|
49 | - // Имеет админку |
|
50 | - 'hasAdmin' => 1, |
|
51 | - 'adminindex' => 'admin/index.php', |
|
52 | - 'adminmenu' => 'admin/menu.php', |
|
53 | - 'system_menu' => 1, |
|
54 | - // Меню |
|
55 | - 'hasMain' => 1, |
|
56 | - // Search |
|
57 | - 'hasSearch' => 1, |
|
58 | - 'search' => [ |
|
59 | - 'file' => 'include/search.inc.php', |
|
60 | - 'func' => $moduleDirName . '_search', |
|
61 | - ], |
|
33 | + 'author_website_url' => 'radio-hobby.org', |
|
34 | + 'author_website_name' => 'andrey3761', |
|
35 | + 'module_website_url' => 'www.xoops.org', |
|
36 | + 'module_website_name' => 'Support site', |
|
37 | + 'min_php' => '5.5', |
|
38 | + 'min_xoops' => '2.5.8', |
|
39 | + 'min_admin' => '1.1', |
|
40 | + 'min_db' => ['mysql' => '5.5'], |
|
41 | + // Файл базы данных |
|
42 | + 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
43 | + // Таблицы |
|
44 | + 'tables' => [ |
|
45 | + $moduleDirName . '_cat', |
|
46 | + $moduleDirName . '_instr', |
|
47 | + $moduleDirName . '_page' |
|
48 | + ], |
|
49 | + // Имеет админку |
|
50 | + 'hasAdmin' => 1, |
|
51 | + 'adminindex' => 'admin/index.php', |
|
52 | + 'adminmenu' => 'admin/menu.php', |
|
53 | + 'system_menu' => 1, |
|
54 | + // Меню |
|
55 | + 'hasMain' => 1, |
|
56 | + // Search |
|
57 | + 'hasSearch' => 1, |
|
58 | + 'search' => [ |
|
59 | + 'file' => 'include/search.inc.php', |
|
60 | + 'func' => $moduleDirName . '_search', |
|
61 | + ], |
|
62 | 62 | ]; |
63 | 63 | // Help files |
64 | 64 | $modversion['helpsection'] = [ |
65 | - ['name' => _MI_INSTRUCTION_HELP_OVERVIEW, 'link' => 'page=help'], |
|
66 | - ['name' => _MI_INSTRUCTION_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
67 | - ['name' => _MI_INSTRUCTION_LICENSE, 'link' => 'page=license'], |
|
68 | - ['name' => _MI_INSTRUCTION_SUPPORT, 'link' => 'page=support'], |
|
65 | + ['name' => _MI_INSTRUCTION_HELP_OVERVIEW, 'link' => 'page=help'], |
|
66 | + ['name' => _MI_INSTRUCTION_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
67 | + ['name' => _MI_INSTRUCTION_LICENSE, 'link' => 'page=license'], |
|
68 | + ['name' => _MI_INSTRUCTION_SUPPORT, 'link' => 'page=support'], |
|
69 | 69 | ]; |
70 | 70 | |
71 | 71 | // Comments |
@@ -78,144 +78,144 @@ discard block |
||
78 | 78 | |
79 | 79 | // Templates |
80 | 80 | $modversion['templates'] = [ |
81 | - [ |
|
82 | - 'file' => 'admin/' . $moduleDirName . '_admin_index.tpl', |
|
83 | - 'description' => '' |
|
84 | - ], |
|
85 | - [ |
|
86 | - 'file' => 'admin/' . $moduleDirName . '_admin_cat.tpl', |
|
87 | - 'description' => '' |
|
88 | - ], |
|
89 | - [ |
|
90 | - 'file' => 'admin/' . $moduleDirName . '_admin_editcat.tpl', |
|
91 | - 'description' => '' |
|
92 | - ], |
|
93 | - [ |
|
94 | - 'file' => 'admin/' . $moduleDirName . '_admin_savecat.tpl', |
|
95 | - 'description' => '' |
|
96 | - ], |
|
97 | - [ |
|
98 | - 'file' => 'admin/' . $moduleDirName . '_admin_viewcat.tpl', |
|
99 | - 'description' => '' |
|
100 | - ], |
|
101 | - [ |
|
102 | - 'file' => 'admin/' . $moduleDirName . '_admin_instr.tpl', |
|
103 | - 'description' => '' |
|
104 | - ], |
|
105 | - [ |
|
106 | - 'file' => 'admin/' . $moduleDirName . '_admin_editinstr.tpl', |
|
107 | - 'description' => '' |
|
108 | - ], |
|
109 | - [ |
|
110 | - 'file' => 'admin/' . $moduleDirName . '_admin_saveinstr.tpl', |
|
111 | - 'description' => '' |
|
112 | - ], |
|
113 | - [ |
|
114 | - 'file' => 'admin/' . $moduleDirName . '_admin_viewinstr.tpl', |
|
115 | - 'description' => '' |
|
116 | - ], |
|
117 | - [ |
|
118 | - 'file' => 'admin/' . $moduleDirName . '_admin_editpage.tpl', |
|
119 | - 'description' => '' |
|
120 | - ], |
|
121 | - [ |
|
122 | - 'file' => 'admin/' . $moduleDirName . '_admin_savepage.tpl', |
|
123 | - 'description' => '' |
|
124 | - ], |
|
125 | - [ |
|
126 | - 'file' => 'admin/' . $moduleDirName . '_admin_perm.tpl', |
|
127 | - 'description' => '' |
|
128 | - ], |
|
129 | - [ |
|
130 | - 'file' => 'admin/' . $moduleDirName . '_admin_about.tpl', |
|
131 | - 'description' => '' |
|
132 | - ], |
|
133 | - [ |
|
134 | - 'file' => $moduleDirName . '_page.tpl', |
|
135 | - 'description' => '' |
|
136 | - ], |
|
137 | - [ |
|
138 | - 'file' => $moduleDirName . '_instr.tpl', |
|
139 | - 'description' => '' |
|
140 | - ], |
|
141 | - [ |
|
142 | - 'file' => $moduleDirName . '_index.tpl', |
|
143 | - 'description' => '' |
|
144 | - ], |
|
145 | - [ |
|
146 | - 'file' => $moduleDirName . '_editpage.tpl', |
|
147 | - 'description' => '' |
|
148 | - ], |
|
149 | - [ |
|
150 | - 'file' => $moduleDirName . '_savepage.tpl', |
|
151 | - 'description' => '' |
|
152 | - ], |
|
81 | + [ |
|
82 | + 'file' => 'admin/' . $moduleDirName . '_admin_index.tpl', |
|
83 | + 'description' => '' |
|
84 | + ], |
|
85 | + [ |
|
86 | + 'file' => 'admin/' . $moduleDirName . '_admin_cat.tpl', |
|
87 | + 'description' => '' |
|
88 | + ], |
|
89 | + [ |
|
90 | + 'file' => 'admin/' . $moduleDirName . '_admin_editcat.tpl', |
|
91 | + 'description' => '' |
|
92 | + ], |
|
93 | + [ |
|
94 | + 'file' => 'admin/' . $moduleDirName . '_admin_savecat.tpl', |
|
95 | + 'description' => '' |
|
96 | + ], |
|
97 | + [ |
|
98 | + 'file' => 'admin/' . $moduleDirName . '_admin_viewcat.tpl', |
|
99 | + 'description' => '' |
|
100 | + ], |
|
101 | + [ |
|
102 | + 'file' => 'admin/' . $moduleDirName . '_admin_instr.tpl', |
|
103 | + 'description' => '' |
|
104 | + ], |
|
105 | + [ |
|
106 | + 'file' => 'admin/' . $moduleDirName . '_admin_editinstr.tpl', |
|
107 | + 'description' => '' |
|
108 | + ], |
|
109 | + [ |
|
110 | + 'file' => 'admin/' . $moduleDirName . '_admin_saveinstr.tpl', |
|
111 | + 'description' => '' |
|
112 | + ], |
|
113 | + [ |
|
114 | + 'file' => 'admin/' . $moduleDirName . '_admin_viewinstr.tpl', |
|
115 | + 'description' => '' |
|
116 | + ], |
|
117 | + [ |
|
118 | + 'file' => 'admin/' . $moduleDirName . '_admin_editpage.tpl', |
|
119 | + 'description' => '' |
|
120 | + ], |
|
121 | + [ |
|
122 | + 'file' => 'admin/' . $moduleDirName . '_admin_savepage.tpl', |
|
123 | + 'description' => '' |
|
124 | + ], |
|
125 | + [ |
|
126 | + 'file' => 'admin/' . $moduleDirName . '_admin_perm.tpl', |
|
127 | + 'description' => '' |
|
128 | + ], |
|
129 | + [ |
|
130 | + 'file' => 'admin/' . $moduleDirName . '_admin_about.tpl', |
|
131 | + 'description' => '' |
|
132 | + ], |
|
133 | + [ |
|
134 | + 'file' => $moduleDirName . '_page.tpl', |
|
135 | + 'description' => '' |
|
136 | + ], |
|
137 | + [ |
|
138 | + 'file' => $moduleDirName . '_instr.tpl', |
|
139 | + 'description' => '' |
|
140 | + ], |
|
141 | + [ |
|
142 | + 'file' => $moduleDirName . '_index.tpl', |
|
143 | + 'description' => '' |
|
144 | + ], |
|
145 | + [ |
|
146 | + 'file' => $moduleDirName . '_editpage.tpl', |
|
147 | + 'description' => '' |
|
148 | + ], |
|
149 | + [ |
|
150 | + 'file' => $moduleDirName . '_savepage.tpl', |
|
151 | + 'description' => '' |
|
152 | + ], |
|
153 | 153 | ]; |
154 | 154 | // Конфигурация |
155 | 155 | $modversion['config'][] = [ |
156 | - 'name' => 'form_options', |
|
157 | - 'title' => '_MI_INSTRUCTION_FORM_OPTIONS', |
|
158 | - 'description' => '_MI_INSTRUCTION_FORM_OPTIONS_DESC', |
|
159 | - 'formtype' => 'select', |
|
160 | - 'valuetype' => 'text', |
|
161 | - 'default' => 'dhtml', |
|
162 | - 'options' => array_flip($editorHandler->getList()) |
|
156 | + 'name' => 'form_options', |
|
157 | + 'title' => '_MI_INSTRUCTION_FORM_OPTIONS', |
|
158 | + 'description' => '_MI_INSTRUCTION_FORM_OPTIONS_DESC', |
|
159 | + 'formtype' => 'select', |
|
160 | + 'valuetype' => 'text', |
|
161 | + 'default' => 'dhtml', |
|
162 | + 'options' => array_flip($editorHandler->getList()) |
|
163 | 163 | ]; |
164 | 164 | $modversion['config'][] = [ |
165 | - 'name' => 'perpageadmin', |
|
166 | - 'title' => '_MI_INSTRUCTION_PERPAGEADMIN', |
|
167 | - 'description' => '_MI_INSTRUCTION_PERPAGEADMINDSC', |
|
168 | - 'formtype' => 'textbox', |
|
169 | - 'valuetype' => 'int', |
|
170 | - 'default' => 20 |
|
165 | + 'name' => 'perpageadmin', |
|
166 | + 'title' => '_MI_INSTRUCTION_PERPAGEADMIN', |
|
167 | + 'description' => '_MI_INSTRUCTION_PERPAGEADMINDSC', |
|
168 | + 'formtype' => 'textbox', |
|
169 | + 'valuetype' => 'int', |
|
170 | + 'default' => 20 |
|
171 | 171 | ]; |
172 | 172 | $modversion['config'][] = [ |
173 | - 'name' => 'perpagemain', |
|
174 | - 'title' => '_MI_INSTRUCTION_PERPAGEMAIN', |
|
175 | - 'description' => '_MI_INSTRUCTION_PERPAGEMAINDSC', |
|
176 | - 'formtype' => 'textbox', |
|
177 | - 'valuetype' => 'int', |
|
178 | - 'default' => 20 |
|
173 | + 'name' => 'perpagemain', |
|
174 | + 'title' => '_MI_INSTRUCTION_PERPAGEMAIN', |
|
175 | + 'description' => '_MI_INSTRUCTION_PERPAGEMAINDSC', |
|
176 | + 'formtype' => 'textbox', |
|
177 | + 'valuetype' => 'int', |
|
178 | + 'default' => 20 |
|
179 | 179 | ]; |
180 | 180 | // Теги |
181 | 181 | $modversion['config'][] = [ |
182 | - 'name' => 'usetag', |
|
183 | - 'title' => '_MI_INSTRUCTION_USETAG', |
|
184 | - 'description' => '_MI_INSTRUCTION_USETAGDSC', |
|
185 | - 'formtype' => 'yesno', |
|
186 | - 'valuetype' => 'int', |
|
187 | - 'default' => 0 |
|
182 | + 'name' => 'usetag', |
|
183 | + 'title' => '_MI_INSTRUCTION_USETAG', |
|
184 | + 'description' => '_MI_INSTRUCTION_USETAGDSC', |
|
185 | + 'formtype' => 'yesno', |
|
186 | + 'valuetype' => 'int', |
|
187 | + 'default' => 0 |
|
188 | 188 | ]; |
189 | 189 | // Оценки |
190 | 190 | $modversion['config'][] = [ |
191 | - 'name' => 'userat', |
|
192 | - 'title' => '_MI_INSTRUCTION_USERAT', |
|
193 | - 'description' => '_MI_INSTRUCTION_USERATDSC', |
|
194 | - 'formtype' => 'yesno', |
|
195 | - 'valuetype' => 'int', |
|
196 | - 'default' => 0 |
|
191 | + 'name' => 'userat', |
|
192 | + 'title' => '_MI_INSTRUCTION_USERAT', |
|
193 | + 'description' => '_MI_INSTRUCTION_USERATDSC', |
|
194 | + 'formtype' => 'yesno', |
|
195 | + 'valuetype' => 'int', |
|
196 | + 'default' => 0 |
|
197 | 197 | ]; |
198 | 198 | |
199 | 199 | // Блоки |
200 | 200 | // Блок последних страниц |
201 | 201 | $modversion['blocks'][] = [ |
202 | - 'file' => 'instr_lastpage.php', |
|
203 | - 'name' => _MI_INSTR_BLOCK_LASTPAGE, |
|
204 | - 'description' => _MI_INSTR_BLOCK_LASTPAGE_DESC, |
|
205 | - 'show_func' => 'b_instr_lastpage_show', |
|
206 | - 'edit_func' => 'b_instr_lastpage_edit', |
|
207 | - 'options' => '10|20', |
|
208 | - 'template' => $moduleDirName . '_block_lastpage.tpl' |
|
202 | + 'file' => 'instr_lastpage.php', |
|
203 | + 'name' => _MI_INSTR_BLOCK_LASTPAGE, |
|
204 | + 'description' => _MI_INSTR_BLOCK_LASTPAGE_DESC, |
|
205 | + 'show_func' => 'b_instr_lastpage_show', |
|
206 | + 'edit_func' => 'b_instr_lastpage_edit', |
|
207 | + 'options' => '10|20', |
|
208 | + 'template' => $moduleDirName . '_block_lastpage.tpl' |
|
209 | 209 | ]; |
210 | 210 | // Блок последних инструкций |
211 | 211 | $modversion['blocks'][] = [ |
212 | - 'file' => 'instr_lastinstr.php', |
|
213 | - 'name' => _MI_INSTR_BLOCK_LASTINSTR, |
|
214 | - 'description' => _MI_INSTR_BLOCK_LASTINSTR_DESC, |
|
215 | - 'show_func' => 'b_instr_lastinstr_show', |
|
216 | - 'edit_func' => 'b_instr_lastinstr_edit', |
|
217 | - 'options' => '10|20', |
|
218 | - 'template' => $moduleDirName . '_block_lastinstr.tpl' |
|
212 | + 'file' => 'instr_lastinstr.php', |
|
213 | + 'name' => _MI_INSTR_BLOCK_LASTINSTR, |
|
214 | + 'description' => _MI_INSTR_BLOCK_LASTINSTR_DESC, |
|
215 | + 'show_func' => 'b_instr_lastinstr_show', |
|
216 | + 'edit_func' => 'b_instr_lastinstr_edit', |
|
217 | + 'options' => '10|20', |
|
218 | + 'template' => $moduleDirName . '_block_lastinstr.tpl' |
|
219 | 219 | ]; |
220 | 220 | |
221 | 221 | // Notification |
@@ -7,12 +7,12 @@ |
||
7 | 7 | |
8 | 8 | $com_itemid = Request::getInt('com_itemid', 0, 'GET'); |
9 | 9 | if ($com_itemid > 0) { |
10 | - $itemObj = $publisher->getHandler('item')->get($com_itemid); |
|
11 | - $com_replytext = _POSTEDBY . ' <strong>' . $itemObj->getLinkedPosterName() . '</strong> ' . _DATE . ' <strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary(); |
|
12 | - $bodytext = $itemObj->body(); |
|
13 | - if ('' != $bodytext) { |
|
14 | - $com_replytext .= '<br><br>' . $bodytext . ''; |
|
15 | - } |
|
16 | - $com_replytitle = $itemObj->getTitle(); |
|
17 | - include_once $GLOBALS['xoops']->path('include/comment_new.php'); |
|
10 | + $itemObj = $publisher->getHandler('item')->get($com_itemid); |
|
11 | + $com_replytext = _POSTEDBY . ' <strong>' . $itemObj->getLinkedPosterName() . '</strong> ' . _DATE . ' <strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary(); |
|
12 | + $bodytext = $itemObj->body(); |
|
13 | + if ('' != $bodytext) { |
|
14 | + $com_replytext .= '<br><br>' . $bodytext . ''; |
|
15 | + } |
|
16 | + $com_replytitle = $itemObj->getTitle(); |
|
17 | + include_once $GLOBALS['xoops']->path('include/comment_new.php'); |
|
18 | 18 | } |
@@ -8,27 +8,27 @@ |
||
8 | 8 | $myts = MyTextSanitizer::getInstance(); |
9 | 9 | |
10 | 10 | if ($xoopsUser) { |
11 | - $modulepermHandler = xoops_getHandler('groupperm'); |
|
12 | - if (!$modulepermHandler->checkRight('module_admin', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) { |
|
13 | - redirect_header(XOOPS_URL, 1, _NOPERM); |
|
14 | - exit(); |
|
15 | - } |
|
11 | + $modulepermHandler = xoops_getHandler('groupperm'); |
|
12 | + if (!$modulepermHandler->checkRight('module_admin', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) { |
|
13 | + redirect_header(XOOPS_URL, 1, _NOPERM); |
|
14 | + exit(); |
|
15 | + } |
|
16 | 16 | } else { |
17 | - redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM); |
|
18 | - exit(); |
|
17 | + redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM); |
|
18 | + exit(); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** @var Xmf\Module\Helper $moduleHelper */ |
22 | 22 | if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
23 | 23 | } else { |
24 | - $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
24 | + $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
25 | 25 | } |
26 | 26 | /** @var Xmf\Module\Admin $adminObject */ |
27 | 27 | $adminObject = \Xmf\Module\Admin::getInstance(); |
28 | 28 | |
29 | 29 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
30 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
31 | - $xoopsTpl = new XoopsTpl(); |
|
30 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
31 | + $xoopsTpl = new XoopsTpl(); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | $pathIcon16 = Xmf\Module\Admin::iconUrl('', 16); |
@@ -27,272 +27,272 @@ |
||
27 | 27 | // Выбор |
28 | 28 | switch ($op) { |
29 | 29 | |
30 | - case 'main': |
|
31 | - |
|
32 | - // Подключаем трей |
|
33 | - $moduleDirName = dirname(__DIR__); |
|
34 | - include_once $moduleDirName . '/class/tree.php'; |
|
35 | - //include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php'); |
|
36 | - |
|
37 | - // Заголовок админки |
|
38 | - xoops_cp_header(); |
|
39 | - // Навигация |
|
40 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
41 | - |
|
42 | - // Находим ID-категории => Число страниц |
|
43 | - $cidinstrids = []; |
|
44 | - $sql = "SELECT `cid`, COUNT( `instrid` ) FROM {$insinstrHandler->table} GROUP BY `cid`"; |
|
45 | - $result = $GLOBALS['xoopsDB']->query($sql); |
|
46 | - while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
|
47 | - // Заполняем массив |
|
48 | - $cidinstrids[$cid] = $count; |
|
49 | - } |
|
50 | - |
|
51 | - // Выбираем категории из БД |
|
52 | - $criteria = new CriteriaCompo(); |
|
53 | - $criteria->setSort('weight ASC, title'); |
|
54 | - $criteria->setOrder('ASC'); |
|
55 | - $ins_cat = $instructioncatHandler->getall($criteria); |
|
56 | - unset($criteria); |
|
57 | - |
|
58 | - // Инициализируем |
|
59 | - $cattree = new InstructionTree($ins_cat, 'cid', 'pid'); |
|
60 | - // Выводим списко категорий в шаблон |
|
61 | - $GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids)); |
|
62 | - |
|
63 | - // Создание новой категории |
|
64 | - $objInstructioncat = $instructioncatHandler->create(); |
|
65 | - $form = $objInstructioncat->getForm('cat.php'); |
|
66 | - // Форма |
|
67 | - $GLOBALS['xoopsTpl']->assign('insFormCat', $form->render()); |
|
68 | - // Выводим шаблон |
|
69 | - $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl'); |
|
70 | - |
|
71 | - // Текст внизу админки |
|
72 | - include __DIR__ . '/admin_footer.php'; |
|
73 | - // Подвал админки |
|
74 | - xoops_cp_footer(); |
|
75 | - |
|
76 | - break; |
|
77 | - |
|
78 | - // Редактирование категории |
|
79 | - case 'editcat': |
|
80 | - |
|
81 | - // Заголовок админки |
|
82 | - xoops_cp_header(); |
|
83 | - // Навигация |
|
84 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
85 | - |
|
86 | - $objInstructioncat = $instructioncatHandler->get($cid); |
|
87 | - $form = $objInstructioncat->getForm('cat.php'); |
|
88 | - // Форма |
|
89 | - //$GLOBALS['xoopsTpl']->assign( 'insFormCat', $form->render() ); |
|
90 | - echo $form->render(); |
|
91 | - // Выводим шаблон |
|
92 | - $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editcat.tpl'); |
|
93 | - |
|
94 | - // Текст внизу админки |
|
95 | - include __DIR__ . '/admin_footer.php'; |
|
96 | - // Подвал админки |
|
97 | - xoops_cp_footer(); |
|
98 | - |
|
99 | - break; |
|
100 | - |
|
101 | - // Сохранение категорий |
|
102 | - case 'savecat': |
|
103 | - |
|
104 | - // Проверка |
|
105 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
106 | - redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
107 | - } |
|
108 | - // Если мы редактируем |
|
109 | - if ($cid) { |
|
110 | - $objInstructioncat = $instructioncatHandler->get($cid); |
|
111 | - } else { |
|
112 | - $objInstructioncat = $instructioncatHandler->create(); |
|
113 | - // Указываем дату создания |
|
114 | - $objInstructioncat->setVar('datecreated', $time); |
|
115 | - } |
|
116 | - |
|
117 | - $err = false; |
|
118 | - $message_err = ''; |
|
119 | - |
|
120 | - // Дата обновления |
|
121 | - $objInstructioncat->setVar('dateupdated', $time); |
|
122 | - $objInstructioncat->setVar('pid', $pid); |
|
123 | - $objInstructioncat->setVar('title', $_POST['title']); |
|
124 | - $objInstructioncat->setVar('description', $_POST['description']); |
|
125 | - $objInstructioncat->setVar('weight', $weight); |
|
126 | - $objInstructioncat->setVar('metakeywords', $_POST['metakeywords']); |
|
127 | - $objInstructioncat->setVar('metadescription', $_POST['metadescription']); |
|
128 | - |
|
129 | - // Проверка веса |
|
130 | - if (0 == $weight) { |
|
131 | - $err = true; |
|
132 | - $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>'; |
|
133 | - } |
|
134 | - // Проверка категорий |
|
135 | - if ($cid && ($cid == $pid)) { |
|
136 | - $err = true; |
|
137 | - $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>'; |
|
138 | - } |
|
139 | - // Если были ошибки |
|
140 | - if (true === $err) { |
|
141 | - xoops_cp_header(); |
|
142 | - // Навигация |
|
143 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
144 | - |
|
145 | - $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
|
146 | - // Выводим ошибки в шаблон |
|
147 | - $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
|
148 | - // Если небыло ошибок |
|
149 | - } else { |
|
150 | - // Вставляем данные в БД |
|
151 | - if ($instructioncatHandler->insert($objInstructioncat)) { |
|
152 | - |
|
153 | - // ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи. |
|
154 | - $new_cid = $cid ?: $objInstructioncat->get_new_enreg(); |
|
155 | - |
|
156 | - // =============== |
|
157 | - // ==== Права ==== |
|
158 | - // =============== |
|
159 | - |
|
160 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
161 | - |
|
162 | - // Если мы редактируем категорию, то старые права нужно удалить |
|
163 | - if ($cid) { |
|
164 | - // Права на просмотр |
|
165 | - $criteria = new CriteriaCompo(); |
|
166 | - $criteria->add(new Criteria('gperm_itemid', $new_cid, '=')); |
|
167 | - $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
168 | - $criteria->add(new Criteria('gperm_name', 'instruction_view', '=')); |
|
169 | - $gpermHandler->deleteAll($criteria); |
|
170 | - // Права на добавление |
|
171 | - $criteria = new CriteriaCompo(); |
|
172 | - $criteria->add(new Criteria('gperm_itemid', $new_cid, '=')); |
|
173 | - $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
174 | - $criteria->add(new Criteria('gperm_name', 'instruction_submit', '=')); |
|
175 | - $gpermHandler->deleteAll($criteria); |
|
176 | - // Права на редактирование |
|
177 | - $criteria = new CriteriaCompo(); |
|
178 | - $criteria->add(new Criteria('gperm_itemid', $new_cid, '=')); |
|
179 | - $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
180 | - $criteria->add(new Criteria('gperm_name', 'instruction_edit', '=')); |
|
181 | - $gpermHandler->deleteAll($criteria); |
|
182 | - } |
|
183 | - |
|
184 | - // Добавляем права |
|
185 | - // Права на просмотр |
|
186 | - if (isset($_POST['groups_instr_view'])) { |
|
187 | - foreach ($_POST['groups_instr_view'] as $onegroup_id) { |
|
188 | - $gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
189 | - } |
|
190 | - } |
|
191 | - // Права на добавление |
|
192 | - if (isset($_POST['groups_instr_submit'])) { |
|
193 | - foreach ($_POST['groups_instr_submit'] as $onegroup_id) { |
|
194 | - $gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
195 | - } |
|
196 | - } |
|
197 | - // Права на редактирование |
|
198 | - if (isset($_POST['groups_instr_edit'])) { |
|
199 | - foreach ($_POST['groups_instr_edit'] as $onegroup_id) { |
|
200 | - $gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - // |
|
205 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED); |
|
206 | - } |
|
207 | - xoops_cp_header(); |
|
208 | - // Навигация |
|
209 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
210 | - // Выводим ошибки в шаблон |
|
211 | - $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors()); |
|
212 | - } |
|
213 | - // Выводим шаблон |
|
214 | - $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl'); |
|
215 | - // Выводим форму |
|
216 | - $form = $objInstructioncat->getForm(); |
|
217 | - // Форма |
|
218 | - echo $form->render(); |
|
219 | - // Текст внизу админки |
|
220 | - include __DIR__ . '/admin_footer.php'; |
|
221 | - // Подвал админки |
|
222 | - xoops_cp_footer(); |
|
223 | - |
|
224 | - break; |
|
225 | - |
|
226 | - // Удаление категории |
|
227 | - case 'delcat': |
|
228 | - |
|
229 | - // Находим число инструкций в данной категории |
|
230 | - // Критерий выборки |
|
231 | - $criteria = new CriteriaCompo(); |
|
232 | - // Все инструкции в данной категории |
|
233 | - $criteria->add(new Criteria('cid', $cid, '=')); |
|
234 | - $numrows = $insinstrHandler->getCount($criteria); |
|
235 | - // |
|
236 | - unset($criteria); |
|
237 | - // Если есть хоть одна инструкция |
|
238 | - if ($numrows) { |
|
239 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY); |
|
240 | - } |
|
241 | - |
|
242 | - $objInscat = $instructioncatHandler->get($cid); |
|
243 | - // Если нет такой категории |
|
244 | - if (!is_object($objInscat)) { |
|
245 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT); |
|
246 | - } |
|
247 | - |
|
248 | - // Нельзя удалять пока есть доченрии категории |
|
249 | - // Подключаем трей |
|
250 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
251 | - $inscat_arr = $instructioncatHandler->getall(); |
|
252 | - $mytree = new XoopsObjectTree($inscat_arr, 'cid', 'pid'); |
|
253 | - $ins_childcat = $mytree->getAllChild($cid); |
|
254 | - // Если есть дочернии категории |
|
255 | - if (count($ins_childcat)) { |
|
256 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN); |
|
257 | - } |
|
258 | - |
|
259 | - // Нажали ли мы на кнопку OK |
|
260 | - $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0; |
|
261 | - // Если мы нажали на кнопку |
|
262 | - if ($ok) { |
|
263 | - |
|
264 | - // Проверка |
|
265 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
266 | - redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
267 | - } |
|
268 | - // Пытаемся удалить категорию |
|
269 | - if ($instructioncatHandler->delete($objInscat)) { |
|
270 | - |
|
271 | - // Удалить права доступа к категории |
|
272 | - // ================================= |
|
273 | - |
|
274 | - // Редирект |
|
275 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED); |
|
276 | - // Если не смогли удалить категорию |
|
277 | - } else { |
|
278 | - // Редирект |
|
279 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT); |
|
280 | - } |
|
281 | - } else { |
|
282 | - |
|
283 | - // Заголовок админки |
|
284 | - xoops_cp_header(); |
|
285 | - // Навигация |
|
286 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
287 | - |
|
288 | - xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title'))); |
|
289 | - |
|
290 | - // Текст внизу админки |
|
291 | - include __DIR__ . '/admin_footer.php'; |
|
292 | - // Подвал админки |
|
293 | - xoops_cp_footer(); |
|
294 | - } |
|
295 | - |
|
296 | - break; |
|
30 | + case 'main': |
|
31 | + |
|
32 | + // Подключаем трей |
|
33 | + $moduleDirName = dirname(__DIR__); |
|
34 | + include_once $moduleDirName . '/class/tree.php'; |
|
35 | + //include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php'); |
|
36 | + |
|
37 | + // Заголовок админки |
|
38 | + xoops_cp_header(); |
|
39 | + // Навигация |
|
40 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
41 | + |
|
42 | + // Находим ID-категории => Число страниц |
|
43 | + $cidinstrids = []; |
|
44 | + $sql = "SELECT `cid`, COUNT( `instrid` ) FROM {$insinstrHandler->table} GROUP BY `cid`"; |
|
45 | + $result = $GLOBALS['xoopsDB']->query($sql); |
|
46 | + while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
|
47 | + // Заполняем массив |
|
48 | + $cidinstrids[$cid] = $count; |
|
49 | + } |
|
50 | + |
|
51 | + // Выбираем категории из БД |
|
52 | + $criteria = new CriteriaCompo(); |
|
53 | + $criteria->setSort('weight ASC, title'); |
|
54 | + $criteria->setOrder('ASC'); |
|
55 | + $ins_cat = $instructioncatHandler->getall($criteria); |
|
56 | + unset($criteria); |
|
57 | + |
|
58 | + // Инициализируем |
|
59 | + $cattree = new InstructionTree($ins_cat, 'cid', 'pid'); |
|
60 | + // Выводим списко категорий в шаблон |
|
61 | + $GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids)); |
|
62 | + |
|
63 | + // Создание новой категории |
|
64 | + $objInstructioncat = $instructioncatHandler->create(); |
|
65 | + $form = $objInstructioncat->getForm('cat.php'); |
|
66 | + // Форма |
|
67 | + $GLOBALS['xoopsTpl']->assign('insFormCat', $form->render()); |
|
68 | + // Выводим шаблон |
|
69 | + $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl'); |
|
70 | + |
|
71 | + // Текст внизу админки |
|
72 | + include __DIR__ . '/admin_footer.php'; |
|
73 | + // Подвал админки |
|
74 | + xoops_cp_footer(); |
|
75 | + |
|
76 | + break; |
|
77 | + |
|
78 | + // Редактирование категории |
|
79 | + case 'editcat': |
|
80 | + |
|
81 | + // Заголовок админки |
|
82 | + xoops_cp_header(); |
|
83 | + // Навигация |
|
84 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
85 | + |
|
86 | + $objInstructioncat = $instructioncatHandler->get($cid); |
|
87 | + $form = $objInstructioncat->getForm('cat.php'); |
|
88 | + // Форма |
|
89 | + //$GLOBALS['xoopsTpl']->assign( 'insFormCat', $form->render() ); |
|
90 | + echo $form->render(); |
|
91 | + // Выводим шаблон |
|
92 | + $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editcat.tpl'); |
|
93 | + |
|
94 | + // Текст внизу админки |
|
95 | + include __DIR__ . '/admin_footer.php'; |
|
96 | + // Подвал админки |
|
97 | + xoops_cp_footer(); |
|
98 | + |
|
99 | + break; |
|
100 | + |
|
101 | + // Сохранение категорий |
|
102 | + case 'savecat': |
|
103 | + |
|
104 | + // Проверка |
|
105 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
106 | + redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
107 | + } |
|
108 | + // Если мы редактируем |
|
109 | + if ($cid) { |
|
110 | + $objInstructioncat = $instructioncatHandler->get($cid); |
|
111 | + } else { |
|
112 | + $objInstructioncat = $instructioncatHandler->create(); |
|
113 | + // Указываем дату создания |
|
114 | + $objInstructioncat->setVar('datecreated', $time); |
|
115 | + } |
|
116 | + |
|
117 | + $err = false; |
|
118 | + $message_err = ''; |
|
119 | + |
|
120 | + // Дата обновления |
|
121 | + $objInstructioncat->setVar('dateupdated', $time); |
|
122 | + $objInstructioncat->setVar('pid', $pid); |
|
123 | + $objInstructioncat->setVar('title', $_POST['title']); |
|
124 | + $objInstructioncat->setVar('description', $_POST['description']); |
|
125 | + $objInstructioncat->setVar('weight', $weight); |
|
126 | + $objInstructioncat->setVar('metakeywords', $_POST['metakeywords']); |
|
127 | + $objInstructioncat->setVar('metadescription', $_POST['metadescription']); |
|
128 | + |
|
129 | + // Проверка веса |
|
130 | + if (0 == $weight) { |
|
131 | + $err = true; |
|
132 | + $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>'; |
|
133 | + } |
|
134 | + // Проверка категорий |
|
135 | + if ($cid && ($cid == $pid)) { |
|
136 | + $err = true; |
|
137 | + $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>'; |
|
138 | + } |
|
139 | + // Если были ошибки |
|
140 | + if (true === $err) { |
|
141 | + xoops_cp_header(); |
|
142 | + // Навигация |
|
143 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
144 | + |
|
145 | + $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
|
146 | + // Выводим ошибки в шаблон |
|
147 | + $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
|
148 | + // Если небыло ошибок |
|
149 | + } else { |
|
150 | + // Вставляем данные в БД |
|
151 | + if ($instructioncatHandler->insert($objInstructioncat)) { |
|
152 | + |
|
153 | + // ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи. |
|
154 | + $new_cid = $cid ?: $objInstructioncat->get_new_enreg(); |
|
155 | + |
|
156 | + // =============== |
|
157 | + // ==== Права ==== |
|
158 | + // =============== |
|
159 | + |
|
160 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
161 | + |
|
162 | + // Если мы редактируем категорию, то старые права нужно удалить |
|
163 | + if ($cid) { |
|
164 | + // Права на просмотр |
|
165 | + $criteria = new CriteriaCompo(); |
|
166 | + $criteria->add(new Criteria('gperm_itemid', $new_cid, '=')); |
|
167 | + $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
168 | + $criteria->add(new Criteria('gperm_name', 'instruction_view', '=')); |
|
169 | + $gpermHandler->deleteAll($criteria); |
|
170 | + // Права на добавление |
|
171 | + $criteria = new CriteriaCompo(); |
|
172 | + $criteria->add(new Criteria('gperm_itemid', $new_cid, '=')); |
|
173 | + $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
174 | + $criteria->add(new Criteria('gperm_name', 'instruction_submit', '=')); |
|
175 | + $gpermHandler->deleteAll($criteria); |
|
176 | + // Права на редактирование |
|
177 | + $criteria = new CriteriaCompo(); |
|
178 | + $criteria->add(new Criteria('gperm_itemid', $new_cid, '=')); |
|
179 | + $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
180 | + $criteria->add(new Criteria('gperm_name', 'instruction_edit', '=')); |
|
181 | + $gpermHandler->deleteAll($criteria); |
|
182 | + } |
|
183 | + |
|
184 | + // Добавляем права |
|
185 | + // Права на просмотр |
|
186 | + if (isset($_POST['groups_instr_view'])) { |
|
187 | + foreach ($_POST['groups_instr_view'] as $onegroup_id) { |
|
188 | + $gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
189 | + } |
|
190 | + } |
|
191 | + // Права на добавление |
|
192 | + if (isset($_POST['groups_instr_submit'])) { |
|
193 | + foreach ($_POST['groups_instr_submit'] as $onegroup_id) { |
|
194 | + $gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
195 | + } |
|
196 | + } |
|
197 | + // Права на редактирование |
|
198 | + if (isset($_POST['groups_instr_edit'])) { |
|
199 | + foreach ($_POST['groups_instr_edit'] as $onegroup_id) { |
|
200 | + $gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + // |
|
205 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED); |
|
206 | + } |
|
207 | + xoops_cp_header(); |
|
208 | + // Навигация |
|
209 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
210 | + // Выводим ошибки в шаблон |
|
211 | + $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors()); |
|
212 | + } |
|
213 | + // Выводим шаблон |
|
214 | + $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl'); |
|
215 | + // Выводим форму |
|
216 | + $form = $objInstructioncat->getForm(); |
|
217 | + // Форма |
|
218 | + echo $form->render(); |
|
219 | + // Текст внизу админки |
|
220 | + include __DIR__ . '/admin_footer.php'; |
|
221 | + // Подвал админки |
|
222 | + xoops_cp_footer(); |
|
223 | + |
|
224 | + break; |
|
225 | + |
|
226 | + // Удаление категории |
|
227 | + case 'delcat': |
|
228 | + |
|
229 | + // Находим число инструкций в данной категории |
|
230 | + // Критерий выборки |
|
231 | + $criteria = new CriteriaCompo(); |
|
232 | + // Все инструкции в данной категории |
|
233 | + $criteria->add(new Criteria('cid', $cid, '=')); |
|
234 | + $numrows = $insinstrHandler->getCount($criteria); |
|
235 | + // |
|
236 | + unset($criteria); |
|
237 | + // Если есть хоть одна инструкция |
|
238 | + if ($numrows) { |
|
239 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY); |
|
240 | + } |
|
241 | + |
|
242 | + $objInscat = $instructioncatHandler->get($cid); |
|
243 | + // Если нет такой категории |
|
244 | + if (!is_object($objInscat)) { |
|
245 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT); |
|
246 | + } |
|
247 | + |
|
248 | + // Нельзя удалять пока есть доченрии категории |
|
249 | + // Подключаем трей |
|
250 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
251 | + $inscat_arr = $instructioncatHandler->getall(); |
|
252 | + $mytree = new XoopsObjectTree($inscat_arr, 'cid', 'pid'); |
|
253 | + $ins_childcat = $mytree->getAllChild($cid); |
|
254 | + // Если есть дочернии категории |
|
255 | + if (count($ins_childcat)) { |
|
256 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN); |
|
257 | + } |
|
258 | + |
|
259 | + // Нажали ли мы на кнопку OK |
|
260 | + $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0; |
|
261 | + // Если мы нажали на кнопку |
|
262 | + if ($ok) { |
|
263 | + |
|
264 | + // Проверка |
|
265 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
266 | + redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
267 | + } |
|
268 | + // Пытаемся удалить категорию |
|
269 | + if ($instructioncatHandler->delete($objInscat)) { |
|
270 | + |
|
271 | + // Удалить права доступа к категории |
|
272 | + // ================================= |
|
273 | + |
|
274 | + // Редирект |
|
275 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED); |
|
276 | + // Если не смогли удалить категорию |
|
277 | + } else { |
|
278 | + // Редирект |
|
279 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT); |
|
280 | + } |
|
281 | + } else { |
|
282 | + |
|
283 | + // Заголовок админки |
|
284 | + xoops_cp_header(); |
|
285 | + // Навигация |
|
286 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
287 | + |
|
288 | + xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title'))); |
|
289 | + |
|
290 | + // Текст внизу админки |
|
291 | + include __DIR__ . '/admin_footer.php'; |
|
292 | + // Подвал админки |
|
293 | + xoops_cp_footer(); |
|
294 | + } |
|
295 | + |
|
296 | + break; |
|
297 | 297 | |
298 | 298 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!isset($moduleDirName)) { |
4 | - $moduleDirName = basename(dirname(__DIR__)); |
|
4 | + $moduleDirName = basename(dirname(__DIR__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
8 | 8 | } else { |
9 | - $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
9 | + $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | $pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); |
@@ -17,34 +17,34 @@ discard block |
||
17 | 17 | |
18 | 18 | // Административное меню |
19 | 19 | $adminmenu = [ |
20 | - [ |
|
21 | - 'title' => _MI_INSTRUCTION_ADMIN_HOME, |
|
22 | - 'link' => 'admin/index.php', |
|
23 | - 'desc' => _MI_INSTRUCTION_ADMIN_HOME_DESC, |
|
24 | - 'icon' => $pathIcon32 . '/home.png' |
|
25 | - ], |
|
26 | - [ |
|
27 | - 'title' => _MI_INSTRUCTION_ADMIN_CAT, |
|
28 | - 'link' => 'admin/cat.php', |
|
29 | - 'desc' => _MI_INSTRUCTION_ADMIN_CAT_DESC, |
|
30 | - 'icon' => $pathIcon32 . '/category.png' |
|
31 | - ], |
|
32 | - [ |
|
33 | - 'title' => _MI_INSTRUCTION_ADMIN_INSTR, |
|
34 | - 'link' => 'admin/instr.php', |
|
35 | - 'desc' => _MI_INSTRUCTION_ADMIN_INSTR_DESC, |
|
36 | - 'icon' => $pathModIcon32 . '/nav_book.png' |
|
37 | - ], |
|
38 | - [ |
|
39 | - 'title' => _MI_INSTRUCTION_ADMIN_PERM, |
|
40 | - 'link' => 'admin/perm.php', |
|
41 | - 'desc' => _MI_INSTRUCTION_ADMIN_PERM_DESC, |
|
42 | - 'icon' => $pathIcon32 . '/permissions.png' |
|
43 | - ], |
|
44 | - [ |
|
45 | - 'title' => _MI_INSTRUCTION_ADMIN_ABOUT, |
|
46 | - 'link' => 'admin/about.php', |
|
47 | - 'desc' => _MI_INSTRUCTION_ADMIN_ABOUT_DESC, |
|
48 | - 'icon' => $pathIcon32 . '/about.png' |
|
49 | - ] |
|
20 | + [ |
|
21 | + 'title' => _MI_INSTRUCTION_ADMIN_HOME, |
|
22 | + 'link' => 'admin/index.php', |
|
23 | + 'desc' => _MI_INSTRUCTION_ADMIN_HOME_DESC, |
|
24 | + 'icon' => $pathIcon32 . '/home.png' |
|
25 | + ], |
|
26 | + [ |
|
27 | + 'title' => _MI_INSTRUCTION_ADMIN_CAT, |
|
28 | + 'link' => 'admin/cat.php', |
|
29 | + 'desc' => _MI_INSTRUCTION_ADMIN_CAT_DESC, |
|
30 | + 'icon' => $pathIcon32 . '/category.png' |
|
31 | + ], |
|
32 | + [ |
|
33 | + 'title' => _MI_INSTRUCTION_ADMIN_INSTR, |
|
34 | + 'link' => 'admin/instr.php', |
|
35 | + 'desc' => _MI_INSTRUCTION_ADMIN_INSTR_DESC, |
|
36 | + 'icon' => $pathModIcon32 . '/nav_book.png' |
|
37 | + ], |
|
38 | + [ |
|
39 | + 'title' => _MI_INSTRUCTION_ADMIN_PERM, |
|
40 | + 'link' => 'admin/perm.php', |
|
41 | + 'desc' => _MI_INSTRUCTION_ADMIN_PERM_DESC, |
|
42 | + 'icon' => $pathIcon32 . '/permissions.png' |
|
43 | + ], |
|
44 | + [ |
|
45 | + 'title' => _MI_INSTRUCTION_ADMIN_ABOUT, |
|
46 | + 'link' => 'admin/about.php', |
|
47 | + 'desc' => _MI_INSTRUCTION_ADMIN_ABOUT_DESC, |
|
48 | + 'icon' => $pathIcon32 . '/about.png' |
|
49 | + ] |
|
50 | 50 | ]; |
@@ -36,24 +36,24 @@ discard block |
||
36 | 36 | $moduleId = $GLOBALS['xoopsModule']->getVar('mid'); |
37 | 37 | |
38 | 38 | switch ($permission) { |
39 | - // Права на просмотр |
|
40 | - case 1: |
|
41 | - $formTitle = _AM_INSTRUCTION_PERM_VIEW; |
|
42 | - $permissionName = 'instruction_view'; |
|
43 | - $permissionDescription = _AM_INSTRUCTION_PERM_VIEW_DSC; |
|
44 | - break; |
|
45 | - // Права на добавление |
|
46 | - case 2: |
|
47 | - $formTitle = _AM_INSTRUCTION_PERM_SUBMIT; |
|
48 | - $permissionName = 'instruction_submit'; |
|
49 | - $permissionDescription = _AM_INSTRUCTION_PERM_SUBMIT_DSC; |
|
50 | - break; |
|
51 | - // Права на редактирование |
|
52 | - case 3: |
|
53 | - $formTitle = _AM_INSTRUCTION_PERM_EDIT; |
|
54 | - $permissionName = 'instruction_edit'; |
|
55 | - $permissionDescription = _AM_INSTRUCTION_PERM_EDIT_DSC; |
|
56 | - break; |
|
39 | + // Права на просмотр |
|
40 | + case 1: |
|
41 | + $formTitle = _AM_INSTRUCTION_PERM_VIEW; |
|
42 | + $permissionName = 'instruction_view'; |
|
43 | + $permissionDescription = _AM_INSTRUCTION_PERM_VIEW_DSC; |
|
44 | + break; |
|
45 | + // Права на добавление |
|
46 | + case 2: |
|
47 | + $formTitle = _AM_INSTRUCTION_PERM_SUBMIT; |
|
48 | + $permissionName = 'instruction_submit'; |
|
49 | + $permissionDescription = _AM_INSTRUCTION_PERM_SUBMIT_DSC; |
|
50 | + break; |
|
51 | + // Права на редактирование |
|
52 | + case 3: |
|
53 | + $formTitle = _AM_INSTRUCTION_PERM_EDIT; |
|
54 | + $permissionName = 'instruction_edit'; |
|
55 | + $permissionDescription = _AM_INSTRUCTION_PERM_EDIT_DSC; |
|
56 | + break; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Права |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | $sql = 'SELECT cid, pid, title FROM ' . $xoopsDB->prefix('instruction_cat') . ' ORDER BY title'; |
63 | 63 | $result = $xoopsDB->query($sql); |
64 | 64 | if ($result) { |
65 | - while ($row = $xoopsDB->fetchArray($result)) { |
|
66 | - $permissionsForm->addItem($row['cid'], $row['title'], $row['pid']); |
|
67 | - } |
|
65 | + while ($row = $xoopsDB->fetchArray($result)) { |
|
66 | + $permissionsForm->addItem($row['cid'], $row['title'], $row['pid']); |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | echo $permissionsForm->render(); |