1
|
|
|
<?php
|
2
|
|
|
// Права
|
3
|
|
View Code Duplication |
function instr_MygetItemIds($permtype = 'instruction_view')
|
|
|
|
|
4
|
|
|
{
|
5
|
|
|
//global $xoopsUser;
|
6
|
|
|
static $permissions = [];
|
7
|
|
|
// Если есть в статике
|
8
|
|
|
if(is_array($permissions) && array_key_exists($permtype, $permissions)) {
|
9
|
|
|
return $permissions[$permtype];
|
10
|
|
|
}
|
11
|
|
|
// Находим из базы
|
12
|
|
|
$module_handler = xoops_gethandler('module');
|
13
|
|
|
$instrModule = $module_handler->getByDirname('instruction');
|
14
|
|
|
$groups = is_object( $GLOBALS['xoopsUser'] ) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
|
15
|
|
|
$gperm_handler = xoops_gethandler('groupperm');
|
16
|
|
|
$categories = $gperm_handler->getItemIds($permtype, $groups, $instrModule->getVar('mid'));
|
17
|
|
|
$permissions[$permtype] = $categories;
|
18
|
|
|
return $categories;
|
19
|
|
|
}
|
20
|
|
|
|
21
|
|
|
// Редактор
|
22
|
|
View Code Duplication |
function &instr_getWysiwygForm($caption, $name, $value = '')
|
|
|
|
|
23
|
|
|
{
|
24
|
|
|
$editor = false;
|
|
|
|
|
25
|
|
|
$editor_configs = [];
|
26
|
|
|
$editor_configs['name'] = $name;
|
27
|
|
|
$editor_configs['value'] = $value;
|
28
|
|
|
$editor_configs['rows'] = 35;
|
29
|
|
|
$editor_configs['cols'] = 60;
|
30
|
|
|
$editor_configs['width'] = '100%';
|
31
|
|
|
$editor_configs['height'] = '350px';
|
32
|
|
|
$editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction'));
|
33
|
|
|
|
34
|
|
|
$editor = new XoopsFormEditor($caption, $name, $editor_configs);
|
35
|
|
|
return $editor;
|
36
|
|
|
}
|
37
|
|
|
|
38
|
|
|
// Получение значения переменной, переданной через GET или POST запрос
|
39
|
|
|
function instr_CleanVars(&$global, $key, $default = '', $type = 'int') {
|
40
|
|
|
switch ($type) {
|
41
|
|
|
case 'string':
|
42
|
|
|
$ret = (isset($global[$key])) ? $global[$key] : $default;
|
43
|
|
|
break;
|
44
|
|
|
case 'int':
|
45
|
|
|
default:
|
46
|
|
|
$ret = (isset($global[$key])) ? intval($global[$key]) : intval($default);
|
47
|
|
|
break;
|
48
|
|
|
}
|
49
|
|
|
if ($ret === false) {
|
50
|
|
|
return $default;
|
51
|
|
|
}
|
52
|
|
|
return $ret;
|
53
|
|
|
}
|
54
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.