/
admin_user_block.php
executable file
·141 lines (125 loc) · 6.61 KB
/
admin_user_block.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
include_once('utility_lgmis_lib.php');
include_once($link_to_utility_authorization);
$title = '';
$header = '';
$content = '';
if (isset($_REQUEST['add'])) {
clear_tmp_images_dir(UserBlock::$type, $_REQUEST['id']);
$title = Language::Word('user block adding');
$header = $title;
global $link_to_utility_sql_worker;
global $link_to_img_upload;
$content .= '<form method="post" action="'.$link_to_utility_sql_worker.'">';
$content .= PairLabelAndInput(4, 5, Language::Word('header'), 'name', Language::Word('insert header'));
$content .= PairLabelAndInput(4, 5, Language::Word('priority'), 'priority', Language::Word('number'));
$content .= PairLabelAndSelect(4, 5, Language::Word('language'), 'language', $languages, array('rus', $languages['rus']));
$content .= WrapToHiddenInputs(array('type' => UserBlock::$type, 'yes' => '', 'id' => $_REQUEST['id'], 'author_id' => $_REQUEST['id']));
$content .= '<div class="row"><h3>Текст</h3></div>';
$content .= '<div class="row">';
$content .= '<div class="'.ColAllTypes(8).' '.ColOffsetAllTypes(2).'" align="center">';
$content .= '<textarea id="text_block" name="text_block"></textarea>';
$content .= '</div>';
$content .= '</div>';
$content .= '<script>';
$content .= 'CKEDITOR.replace("text_block",';
$content .= '{ filebrowserImageUploadUrl: "'.$link_to_img_upload.'?'.http_build_query($_REQUEST).'",';
$content .= 'contentsCss: [CKEDITOR.basePath + "contents.css", "css/styles.css", "css/bootstrap.min.css"],';
$content .= 'allowedContent: true, });';
$content .= 'CKEDITOR.config.height = 400;';
$content .= '</script>';
$content .= '<div class="row">';
$content .= '<input type="submit" class="btn btn-primary btn-lg" name="add" value="'.Language::Word('save').'">';
$content .= '</div>';
$content .= '</form>';
} else if (isset($_REQUEST['edit'])) {
global $link_to_utility_sql_worker;
global $link_to_img_upload;
$block_id = $_REQUEST['id'];
$block = UserBlock::FetchByID($block_id);
$assoc = $_REQUEST;
$assoc['author_id'] = $block->author_id;
$content .= '<form method="post" action="'.$link_to_utility_sql_worker.'">';
$content .= PairLabelAndInput(4, 5, Language::Word('header'), 'name', Language::Word('insert header'), $block->name);
$content .= PairLabelAndInput(4, 5, Language::Word('priority'), 'priority', Language::Word('number'), $block->priority);
$content .= WrapToHiddenInputs(array('type' => UserBlock::$type, 'yes' => '', 'id' => $block_id));
$content .= '<div class="row"><h3>Текст</h3></div>';
$content .= '<div class="row">';
$content .= '<div class="'.ColAllTypes(8).' '.ColOffsetAllTypes(2).'" align="center">';
$content .= '<textarea id="text_block" name="text_block">'.$block->text_block.'</textarea>';
$content .= '</div>';
$content .= '</div>';
$content .= '<script>';
$content .= 'CKEDITOR.replace("text_block",';
$content .= '{ filebrowserImageUploadUrl: "'.$link_to_img_upload.'?'.http_build_query($assoc).'",';
$content .= 'filebrowserImageBrowseUrl : "'.$link_to_img_browse.'?'.http_build_query($assoc).'",';
$content .= 'contentsCss: [CKEDITOR.basePath + "contents.css", "css/styles.css", "css/bootstrap.min.css"],';
$content .= 'allowedContent: true, });';
$content .= 'CKEDITOR.config.height = 400;';
$content .= '</script>';
$content .= '<div class="row">';
$content .= DialogInputsYesNo('edit', $_REQUEST['type'], $block_id, Language::Word('save'), Language::Word('cancel'), true);
$content .= '</div>';
$content .= '</form>';
$title = Language::Word('user block editing');
$header = $title;
} else if (isset($_REQUEST['add_lang'])) {
$user_block = UserBlock::FetchByID($_REQUEST['id']);
$blk_langs = $user_block->FetchLanguages();
$free_languages = array_diff($languages, $blk_langs);
if (count($free_languages) === 0) {
$content = AlertMessage('alert-danger', Language::Word('all languages of this user block is implemented'));
} else {
clear_tmp_images_dir(UserBlock::$type, $_REQUEST['id']);
$title = Language::Word('language adding');
$header = $title;
$assoc = $_REQUEST;
$assoc['edit'] = 'edit';
$assoc['author_id'] = $user_block->author_id;
$assoc['id'] = $user_block->GetID();
global $link_to_utility_sql_worker;
global $link_to_img_upload;
$content .= '<form method="post" action="'.$link_to_utility_sql_worker.'">';
$content .= PairLabelAndInput(4, 5, Language::Word('header'), 'name', Language::Word('insert header'));
$content .= PairLabelAndInput(4, 5, Language::Word('priority'), 'priority', Language::Word('number'));
$content .= PairLabelAndSelect(4, 5, Language::Word('language'), 'language', $free_languages, array(key($free_languages), current($free_languages)));
$content .= WrapToHiddenInputs(array('type' => UserBlock::$type, 'yes' => '', 'id' => $_REQUEST['id'], 'glob_id' => $user_block->GetID(), 'author_id' => $user_block->author_id));
$content .= '<div class="row"><h3>Текст</h3></div>';
$content .= '<div class="row">';
$content .= '<div class="'.ColAllTypes(8).' '.ColOffsetAllTypes(2).'" align="center">';
$content .= '<textarea id="text_block" name="text_block"></textarea>';
$content .= '</div>';
$content .= '</div>';
$content .= '<script>';
$content .= 'CKEDITOR.replace("text_block",';
$content .= '{ filebrowserImageUploadUrl: "'.$link_to_img_upload.'?'.http_build_query($assoc).'",';
$content .= 'filebrowserImageBrowseUrl : "'.$link_to_img_browse.'?'.http_build_query($assoc).'",';
$content .= 'contentsCss: [CKEDITOR.basePath + "contents.css", "css/styles.css", "css/bootstrap.min.css"],';
$content .= 'allowedContent: true, });';
$content .= 'CKEDITOR.config.height = 400;';
$content .= '</script>';
$content .= '<div class="row">';
$content .= '<input type="submit" class="btn btn-primary btn-lg" name="add" value="'.Language::Word('save').'">';
$content .= '</div>';
$content .= '</form>';
}
} else {
if (!isset($_REQUEST['full'])) {
echo 'action_type is unset. Must be "full"';
exit();
}
if (!isset($_REQUEST['type'])) {
echo 'object type is unset. Must be "user"';
exit();
}
if (!isset($_REQUEST['id'])) {
echo 'user id is unset';
exit();
}
$user_block = UserBlock::FetchByID($_REQUEST['id']);
$title = Language::Word('user block');
$header = htmlspecialchars($user_block->name);
$content = $user_block->ToHTMLAutoFull(GetUserPrivileges());
}
include_once($link_to_admin_template);
?>