[3978] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | global $template, $conf, $user; |
---|
| 4 | include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php'); |
---|
| 5 | load_language('plugin.lang', meta_PATH); |
---|
| 6 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
| 7 | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | Check Access and exit when user status is not ok | |
---|
| 10 | // +-----------------------------------------------------------------------+ |
---|
| 11 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 12 | |
---|
| 13 | //-------------------------------------------------------- sections definitions |
---|
[4174] | 14 | |
---|
[22769] | 15 | // TAB gest |
---|
[3978] | 16 | if (!isset($_GET['tab'])) |
---|
| 17 | $page['tab'] = 'gestion'; |
---|
| 18 | else |
---|
| 19 | $page['tab'] = $_GET['tab']; |
---|
| 20 | |
---|
| 21 | $tabsheet = new tabsheet(); |
---|
| 22 | $tabsheet->add('gestion', |
---|
| 23 | l10n('meta_onglet_gestion'), |
---|
| 24 | $my_base_url.'&tab=gestion'); |
---|
[24449] | 25 | $tabsheet->add('persometa', |
---|
[22769] | 26 | l10n('Personal Metadata'), |
---|
| 27 | $my_base_url.'&tab=persometa'); |
---|
[24393] | 28 | |
---|
| 29 | $MPC = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); |
---|
| 30 | if($MPC['state'] == 'active') |
---|
| 31 | { |
---|
| 32 | $tabsheet->add('contactmeta', |
---|
| 33 | l10n('Contact page Metadata'), |
---|
| 34 | $my_base_url.'&tab=contactmeta'); |
---|
| 35 | } |
---|
| 36 | $MAP = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'AdditionalPages';")); |
---|
| 37 | if($MAP['state'] == 'active') |
---|
| 38 | { |
---|
| 39 | $tabsheet->add('AdditionalPagesmeta', |
---|
| 40 | l10n('Additional Pages Metadata'), |
---|
| 41 | $my_base_url.'&tab=AdditionalPagesmeta'); |
---|
| 42 | } |
---|
| 43 | |
---|
[3978] | 44 | $tabsheet->add('description', |
---|
| 45 | l10n('meta_onglet_description'), |
---|
| 46 | $my_base_url.'&tab=description'); |
---|
| 47 | $tabsheet->select($page['tab']); |
---|
| 48 | $tabsheet->assign(); |
---|
| 49 | |
---|
[22769] | 50 | // Tab gest |
---|
[3978] | 51 | switch ($page['tab']) |
---|
| 52 | { |
---|
| 53 | case 'gestion': |
---|
| 54 | |
---|
[22769] | 55 | //read metadata list |
---|
[3978] | 56 | $groups = array(); |
---|
| 57 | $query = ' |
---|
| 58 | select id,metaname |
---|
| 59 | FROM ' . meta_TABLE . ' |
---|
| 60 | ORDER BY metaname ASC;'; |
---|
| 61 | $result = pwg_query($query); |
---|
| 62 | |
---|
[21161] | 63 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[3978] | 64 | { |
---|
| 65 | $groups[$row['id']] = $row['metaname']; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | $selected = 0; |
---|
| 69 | $options[] = l10n('meta_select2'); |
---|
| 70 | $options['a'] = '----------------------'; |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | foreach ($groups as $metalist => $metalist2) |
---|
| 74 | { |
---|
| 75 | $options[$metalist] = $metalist2; |
---|
| 76 | } |
---|
| 77 | $template->assign( |
---|
| 78 | 'gestionA', |
---|
| 79 | array( |
---|
| 80 | 'OPTIONS' => $options, |
---|
| 81 | 'SELECTED' => $selected |
---|
| 82 | )); |
---|
| 83 | |
---|
| 84 | |
---|
[22769] | 85 | //edit meta |
---|
[26359] | 86 | if (isset($_POST['submitchoixmeta']) and is_numeric($_POST['metalist']) and (!$_POST['metalist'])==0) |
---|
[3978] | 87 | { |
---|
| 88 | $lire=$_POST['metalist']; |
---|
| 89 | $query = ' |
---|
| 90 | select id,metaname,metaval |
---|
| 91 | FROM ' . meta_TABLE . ' |
---|
| 92 | WHERE id = \''.$lire.'\' |
---|
| 93 | ;'; |
---|
| 94 | $result = pwg_query($query); |
---|
| 95 | |
---|
[21161] | 96 | $row = pwg_db_fetch_assoc($result); |
---|
[3978] | 97 | $chname=$row['metaname']; |
---|
| 98 | $chval=$row['metaval']; |
---|
| 99 | |
---|
| 100 | $selected2 = ""; |
---|
| 101 | |
---|
| 102 | $template->assign( |
---|
| 103 | 'meta_edit', |
---|
| 104 | array( |
---|
| 105 | 'VALUE' => $chname, |
---|
| 106 | 'CONTENT' => $chval, |
---|
| 107 | 'SELECTED' => $selected2 |
---|
| 108 | )); |
---|
| 109 | } |
---|
| 110 | |
---|
[22769] | 111 | //inser metadata in table |
---|
| 112 | if (isset($_POST['submitinsmeta'])) |
---|
[3978] | 113 | { |
---|
| 114 | $query = ' |
---|
| 115 | UPDATE ' . meta_TABLE . ' |
---|
| 116 | SET metaval= \''.$_POST['inser'].'\' |
---|
| 117 | WHERE metaname = \''.$_POST['invisible'].'\' |
---|
| 118 | ;'; |
---|
| 119 | $result = pwg_query($query); |
---|
[24449] | 120 | array_push($page['infos'], l10n('Metadata updated')); |
---|
[3978] | 121 | } |
---|
| 122 | |
---|
| 123 | break; |
---|
[4174] | 124 | |
---|
[22769] | 125 | //description TAB |
---|
[3978] | 126 | case 'description': |
---|
| 127 | |
---|
| 128 | $blockdesc = 'description'; |
---|
| 129 | $template->assign( |
---|
| 130 | $blockdesc, |
---|
| 131 | array( |
---|
| 132 | 'meta'=>l10n('meta_name'), |
---|
| 133 | )); |
---|
| 134 | break; |
---|
[22769] | 135 | |
---|
| 136 | // TAB personnal metadata |
---|
| 137 | case 'persometa': |
---|
| 138 | |
---|
| 139 | $template->assign( |
---|
| 140 | 'metapersoT', |
---|
| 141 | array( |
---|
| 142 | 'meta'=>l10n('meta_name'), |
---|
| 143 | )); |
---|
| 144 | $admin_base_url = $my_base_url.'&tab=persometa'; |
---|
| 145 | $metapersos = pwg_query("SELECT * FROM `". METAPERSO_TABLE .";"); |
---|
| 146 | |
---|
| 147 | if (pwg_db_num_rows($metapersos)) { |
---|
| 148 | while ($metaperso = pwg_db_fetch_assoc($metapersos)) |
---|
| 149 | { |
---|
| 150 | $items = array( |
---|
| 151 | 'METANAME' => $metaperso['metaname'], |
---|
| 152 | 'METAVAL' => $metaperso['metaval'], |
---|
| 153 | 'METATYPE' => $metaperso['metatype'], |
---|
| 154 | 'U_DELETE' => $admin_base_url.'&delete='.$metaperso['id'], |
---|
| 155 | 'U_EDIT' => $admin_base_url.'&edit='.$metaperso['id'], |
---|
| 156 | ); |
---|
| 157 | |
---|
| 158 | $template->append('metapersos', $items); |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | if (isset($_POST['submitaddpersonalmeta'])) |
---|
| 162 | { |
---|
| 163 | $template->assign( |
---|
| 164 | 'meta_edit2', |
---|
| 165 | array( |
---|
| 166 | 'meta'=>l10n('meta_name'), |
---|
| 167 | 'METAID' => 0, |
---|
| 168 | )); |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | if (isset($_POST['submitaddmetaperso'])) |
---|
| 172 | { |
---|
| 173 | $query = ' |
---|
| 174 | DELETE |
---|
| 175 | FROM ' . METAPERSO_TABLE . ' |
---|
| 176 | WHERE id = '.$_POST['invisibleID'].' |
---|
| 177 | ;'; |
---|
| 178 | $result = pwg_query($query); |
---|
[4174] | 179 | |
---|
[22769] | 180 | |
---|
| 181 | $q = ' |
---|
| 182 | INSERT INTO ' . $prefixeTable . 'metaperso(metaname,metaval,metatype)VALUES ("'.$_POST['insername'].'","'.$_POST['inserval'].'","'.$_POST['insertype'].'");'; |
---|
| 183 | pwg_query($q); |
---|
| 184 | $_SESSION['page_infos'] = array(l10n('Personal metadata update')); |
---|
| 185 | redirect($admin_base_url); |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | if (isset($_GET['edit'])) |
---|
| 189 | { |
---|
| 190 | check_input_parameter('edit', $_GET, false, PATTERN_ID); |
---|
| 191 | |
---|
| 192 | $query = ' |
---|
| 193 | select id,metaname,metaval,metatype |
---|
| 194 | FROM ' . METAPERSO_TABLE . ' |
---|
| 195 | WHERE id = \''.$_GET['edit'].'\' |
---|
| 196 | ;'; |
---|
| 197 | $result = pwg_query($query); |
---|
| 198 | $row = pwg_db_fetch_assoc($result); |
---|
| 199 | $template->assign( |
---|
| 200 | 'meta_edit2', |
---|
| 201 | array( |
---|
| 202 | 'METAID' => $row['id'], |
---|
| 203 | 'METANAME' => $row['metaname'], |
---|
| 204 | 'METAVAL' => $row['metaval'], |
---|
| 205 | 'METATYPE' => $row['metatype'], |
---|
| 206 | )); |
---|
| 207 | |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | if (isset($_GET['delete'])) |
---|
| 211 | { |
---|
| 212 | check_input_parameter('delete', $_GET, false, PATTERN_ID); |
---|
| 213 | |
---|
| 214 | $query = ' |
---|
| 215 | DELETE |
---|
| 216 | FROM '.METAPERSO_TABLE.' |
---|
| 217 | WHERE id = '.$_GET['delete'].' |
---|
| 218 | ;'; |
---|
| 219 | pwg_query($query); |
---|
| 220 | |
---|
| 221 | $_SESSION['page_infos'] = array(l10n('Personal metadata update')); |
---|
| 222 | redirect($admin_base_url); |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | |
---|
| 226 | break; |
---|
| 227 | |
---|
[24393] | 228 | case 'contactmeta': |
---|
| 229 | |
---|
| 230 | $metacontact = explode(',', $conf['contactmeta']); |
---|
[22769] | 231 | |
---|
[24393] | 232 | $template->assign('contactmetaT', |
---|
| 233 | array('CMKEY' => $metacontact[0],'CMDESC' => $metacontact[1],)); |
---|
| 234 | |
---|
| 235 | if (isset($_POST['submitcm'])) |
---|
| 236 | { |
---|
| 237 | $INSCM = $_POST['inser'].",".$_POST['inser2']; |
---|
| 238 | conf_update_param('contactmeta', $INSCM); |
---|
[24449] | 239 | array_push($page['infos'], l10n('Metadata updated')); |
---|
[24393] | 240 | $template->assign( |
---|
| 241 | 'contactmetaT', |
---|
| 242 | array('CMKEY' => stripslashes($_POST['inser']),'CMDESC' => stripslashes($_POST['inser2']))); |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | break; |
---|
| 246 | |
---|
| 247 | case 'AdditionalPagesmeta': |
---|
| 248 | if (!defined('TITLE_AP_TABLE')) define('TITLE_AP_TABLE', $prefixeTable.'title_ap'); |
---|
| 249 | $groups = array(); |
---|
| 250 | $query = ' |
---|
| 251 | select id,title |
---|
| 252 | FROM ' . ADD_PAGES_TABLE . ' |
---|
| 253 | ORDER BY id ASC;'; |
---|
| 254 | $result = pwg_query($query); |
---|
| 255 | |
---|
| 256 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 257 | { |
---|
| 258 | $groups[$row['id']] = $row['id'].' : '.$row['title']; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | $selected = 0; |
---|
| 262 | $options[] = l10n('Choose it page'); |
---|
| 263 | $options['a'] = '----------------------'; |
---|
| 264 | |
---|
| 265 | foreach($groups as $listid => $listid2) |
---|
| 266 | { |
---|
| 267 | $options[$listid] = $listid2; |
---|
| 268 | } |
---|
| 269 | $template->assign( |
---|
| 270 | 'gestionC', |
---|
| 271 | array( |
---|
| 272 | 'OPTIONS' => $options, |
---|
| 273 | 'SELECTED' => $selected |
---|
| 274 | )); |
---|
| 275 | |
---|
| 276 | if (isset($_POST['submitchoixAP'])and is_numeric($_POST['APchoix']) and (!$_POST['APchoix'])==0) |
---|
| 277 | { |
---|
| 278 | $lire=$_POST['APchoix']; |
---|
| 279 | $query = ' |
---|
| 280 | select id,metaKeyap,metadesap |
---|
| 281 | FROM ' . META_AP_TABLE . ' |
---|
| 282 | WHERE id = \''.$lire.'\' |
---|
| 283 | ;'; |
---|
| 284 | $result = pwg_query($query); |
---|
| 285 | $row = pwg_db_fetch_assoc($result); |
---|
| 286 | $metaKeyapap=$row['metaKeyap']; |
---|
| 287 | $metadesap=$row['metadesap']; |
---|
| 288 | |
---|
| 289 | $query = ' |
---|
| 290 | select id,title |
---|
| 291 | FROM ' . ADD_PAGES_TABLE . ' |
---|
| 292 | WHERE id = \''.$lire.'\' |
---|
| 293 | ;'; |
---|
| 294 | $result = pwg_query($query); |
---|
| 295 | $row = pwg_db_fetch_assoc($result); |
---|
| 296 | $idap=$row['id']; |
---|
| 297 | $nameap=$row['title']; |
---|
| 298 | |
---|
| 299 | $selected3 = 0; |
---|
| 300 | |
---|
| 301 | $template->assign( |
---|
| 302 | 'ap_edit', |
---|
| 303 | array( |
---|
| 304 | 'VALUE' => $idap, |
---|
| 305 | 'VALUEN' => $nameap, |
---|
| 306 | 'CONTENTMKAP' => $metaKeyapap, |
---|
| 307 | 'CONTENTMDAP' => $metadesap, |
---|
| 308 | 'SELECTED' => $selected3 |
---|
| 309 | )); |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | if (isset($_POST['submitinsapm'])) |
---|
| 313 | { |
---|
| 314 | $query = ' |
---|
| 315 | DELETE |
---|
| 316 | FROM ' . META_AP_TABLE . ' |
---|
| 317 | WHERE id = \''.$_POST['invisible'].'\' |
---|
| 318 | ;'; |
---|
| 319 | $result = pwg_query($query); |
---|
| 320 | $q = ' |
---|
| 321 | INSERT INTO ' . $prefixeTable . 'meta_ap(id,metaKeyap,metadesap)VALUES ('.$_POST['invisible'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; |
---|
| 322 | pwg_query($q); |
---|
[24449] | 323 | array_push($page['infos'], l10n('Metadata updated')); |
---|
[24393] | 324 | } |
---|
| 325 | |
---|
| 326 | break; |
---|
| 327 | |
---|
[3978] | 328 | } |
---|
[7539] | 329 | |
---|
[3978] | 330 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
| 331 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 332 | ?> |
---|