[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_admin/users_extended.php,v $ 14 | $Revision: 1.42 $ 15 | $Date: 2007/01/28 20:49:45 $ 16 | $Author: e107steved $ 17 +----------------------------------------------------------------------------+ 18 */ 19 require_once ("../class2.php"); 20 if (!getperms("4")) { 21 header("location:".e_BASE."index.php"); 22 exit; 23 } 24 if (isset($_POST['cancel'])) 25 { 26 header("location:".e_SELF); 27 exit; 28 } 29 30 $e_sub_cat = 'user_extended'; 31 $user = new users_ext; 32 $curtype = '1'; 33 require_once(e_HANDLER."calendar/calendar_class.php"); 34 $cal = new DHTML_Calendar(true); 35 require_once ("auth.php"); 36 require_once(e_HANDLER."user_extended_class.php"); 37 require_once(e_HANDLER."userclass_class.php"); 38 39 40 $ue = new e107_user_extended; 41 42 if (e_QUERY) 43 { 44 $tmp = explode(".", e_QUERY); 45 $action = $tmp[0]; 46 $sub_action = $tmp[1]; 47 $id = $tmp[2]; 48 unset($tmp); 49 } 50 51 52 53 if (isset($_POST['up_x'])) 54 { 55 $qs = explode(".", $_POST['id']); 56 $_id = $qs[0]; 57 $_order = $qs[1]; 58 $_parent = $qs[2]; 59 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order+1 WHERE user_extended_struct_type > 0 AND user_extended_struct_parent = {$_parent} AND user_extended_struct_order ='".($_order-1)."'"); 60 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order-1 WHERE user_extended_struct_type > 0 AND user_extended_struct_parent = {$_parent} AND user_extended_struct_id='".$_id."'"); 61 } 62 63 if (isset($_POST['down_x'])) 64 { 65 $qs = explode(".", $_POST['id']); 66 $_id = $qs[0]; 67 $_order = $qs[1]; 68 $_parent = $qs[2]; 69 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order-1 WHERE user_extended_struct_type > 0 AND user_extended_struct_parent = {$_parent} AND user_extended_struct_order='".($_order+1)."'"); 70 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order+1 WHERE user_extended_struct_type > 0 AND user_extended_struct_parent = {$_parent} AND user_extended_struct_id='".$_id."'"); 71 } 72 73 74 if (isset($_POST['catup_x'])) 75 { 76 $qs = explode(".", $_POST['id']); 77 $_id = $qs[0]; 78 $_order = $qs[1]; 79 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order+1 WHERE user_extended_struct_type = 0 AND user_extended_struct_order='".($_order-1)."'"); 80 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order-1 WHERE user_extended_struct_type = 0 AND user_extended_struct_id='".$_id."'"); 81 } 82 83 if (isset($_POST['catdown_x'])) 84 { 85 $qs = explode(".", $_POST['id']); 86 $_id = $qs[0]; 87 $_order = $qs[1]; 88 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order-1 WHERE user_extended_struct_type = 0 AND user_extended_struct_order='".($_order+1)."'"); 89 $sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order+1 WHERE user_extended_struct_type = 0 AND user_extended_struct_id='".$_id."'"); 90 } 91 92 if (isset($_POST['add_field'])) 93 { 94 $ue_field_name = str_replace(' ','_',trim($_POST['user_field'])); // Replace space with underscore - better security 95 if (preg_match('#^\w+$#',$ue_field_name) === 1) // Check for allowed characters, finite field length 96 { 97 if($_POST['user_type']==4) 98 { 99 $_POST['user_values'] = array($_POST['table_db'],$_POST['field_id'],$_POST['field_value'],$_POST['field_order']); 100 } 101 $new_values = make_delimited($_POST['user_values']); 102 $new_parms = $tp->toDB($_POST['user_include']."^,^".$_POST['user_regex']."^,^".$_POST['user_regexfail']."^,^".$_POST['user_hide']); 103 104 // Check to see if its a reserved field name before adding to database 105 if($ue->user_extended_reserved($ue_field_name)) 106 { // Reserved field name 107 $message = "[user_".$tp->toHTML($ue_field_name)."] ".EXTLAN_74; 108 } 109 else 110 { 111 $result = admin_update($ue->user_extended_add($ue_field_name, $_POST['user_text'], $_POST['user_type'], $new_parms, $new_values, $_POST['user_default'], $_POST['user_required'], $_POST['user_read'], $_POST['user_write'], $_POST['user_applicable'], 0, $_POST['user_parent']), 'insert', EXTLAN_29); 112 if(!$result) 113 { 114 $message = EXTLAN_75; 115 } 116 } 117 } 118 else 119 { 120 $message = EXTLAN_76." : ".$tp->toHTML($ue_field_name); 121 } 122 } 123 124 if (isset($_POST['update_field'])) { 125 if($_POST['user_type']==4){ 126 $_POST['user_values'] = array($_POST['table_db'],$_POST['field_id'],$_POST['field_value'],$_POST['field_order']); 127 } 128 $upd_values = make_delimited($_POST['user_values']); 129 $upd_parms = $tp->toDB($_POST['user_include']."^,^".$_POST['user_regex']."^,^".$_POST['user_regexfail']."^,^".$_POST['user_hide']); 130 admin_update($ue->user_extended_modify($sub_action, $_POST['user_field'], $_POST['user_text'], $_POST['user_type'], $upd_parms, $upd_values, $_POST['user_default'], $_POST['user_required'], $_POST['user_read'], $_POST['user_write'], $_POST['user_applicable'], $_POST['user_parent']), 'update', EXTLAN_29); 131 } 132 133 if (isset($_POST['update_category'])) 134 { 135 $name = trim($tp->toHTML($_POST['user_field'])); 136 admin_update($sql->db_Update("user_extended_struct","user_extended_struct_name = '{$name}', user_extended_struct_read = '{$_POST['user_read']}', user_extended_struct_write = '{$_POST['user_write']}', user_extended_struct_applicable = '{$_POST['user_applicable']}' WHERE user_extended_struct_id = '{$sub_action}'"), 'update', EXTLAN_43); 137 } 138 139 if (isset($_POST['add_category'])) 140 { 141 $name = $tp->toHTML($_POST['user_field']); 142 admin_update($sql->db_Insert("user_extended_struct","'0', '$name', '', 0, '', '', '', '{$_POST['user_read']}', '{$_POST['user_write']}', '0', '0', '{$_POST['user_applicable']}', '0', '0'"), 'insert', EXTLAN_40); 143 } 144 145 if ($_POST['eu_action'] == "delext") 146 { 147 list($_id, $_name) = explode(",",$_POST['key']); 148 if($ue->user_extended_remove($_id, $_name)) 149 { 150 $message = EXTLAN_30; 151 } 152 } 153 154 if ($_POST['eu_action'] == "delcat") 155 { 156 list($_id, $_name) = explode(",",$_POST['key']); 157 if($ue->user_extended_remove($_id, $_name)) 158 { 159 $message = EXTLAN_41; 160 } 161 } 162 163 if(isset($_POST['activate'])) 164 { 165 $message .= field_activate(); 166 } 167 168 if(isset($_POST['deactivate'])) 169 { 170 $message .= field_deactivate(); 171 } 172 173 if($sql->db_Select("user_extended_struct","DISTINCT(user_extended_struct_parent)")) 174 { 175 $plist = $sql->db_getList(); 176 foreach($plist as $_p) 177 { 178 $o = 0; 179 if($sql->db_Select("user_extended_struct", "user_extended_struct_id", "user_extended_struct_parent = {$_p['user_extended_struct_parent']} && user_extended_struct_type != 0 ORDER BY user_extended_struct_order ASC")) 180 { 181 $_list = $sql->db_getList(); 182 foreach($_list as $r) 183 { 184 $sql->db_Update("user_extended_struct", "user_extended_struct_order = '{$o}' WHERE user_extended_struct_id = {$r['user_extended_struct_id']}"); 185 $o++; 186 } 187 } 188 } 189 } 190 191 if($message) 192 { 193 $ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>"); 194 } 195 196 if(isset($_POST['table_db']) && !$_POST['add_field'] && !$_POST['update_field']){ 197 $action = "continue"; 198 $current['user_extended_struct_name'] = $_POST['user_field']; 199 $current['user_extended_struct_parms'] = $_POST['user_include']."^,^".$_POST['user_regex']."^,^".$_POST['user_regexfail']."^,^".$_POST['user_hide']; 200 $current['user_extended_struct_text'] = $_POST['user_text']; 201 $current['user_extended_struct_type'] = $_POST['user_type']; 202 $user->show_extended($current); 203 } 204 205 if (!e_QUERY || $action == 'main') 206 { 207 $user->show_extended(); 208 } 209 210 if ($action == "editext") 211 { 212 if($sql->db_Select('user_extended_struct','*',"user_extended_struct_id = '{$sub_action}'")) 213 { 214 $tmp = $sql->db_Fetch(); 215 $user->show_extended($tmp); 216 } 217 else 218 { 219 $user->show_extended('new'); 220 } 221 } 222 223 if($action == 'pre') 224 { 225 show_predefined(); 226 } 227 228 if($action == 'cat') 229 { 230 if(is_numeric($sub_action)) 231 { 232 if($sql->db_Select('user_extended_struct','*',"user_extended_struct_id = '{$sub_action}'")) 233 { 234 $tmp = $sql->db_Fetch(); 235 } 236 } 237 $user->show_categories($tmp); 238 } 239 240 require_once ("footer.php"); 241 242 class users_ext 243 { 244 245 function show_extended($current) 246 { 247 global $sql, $ns, $ue, $curtype, $tp, $mySQLdefaultdb, $action, $sub_action; 248 249 $catList = $ue->user_extended_get_categories(); 250 $catList[0][0] = array('user_extended_struct_name' => EXTLAN_36); 251 $catNums = array_keys($catList); 252 $extendedList = $ue->user_extended_get_fields(); 253 254 if(!$current){ 255 $text = "<div style='text-align:center'>"; 256 $text .= "<table style='".ADMIN_WIDTH."' class='fborder'> 257 <tr> 258 <td class='fcaption'>".EXTLAN_1."</td> 259 <td class='fcaption'>".EXTLAN_2."</td>"; 260 // $text .="<td class='fcaption'>".EXTLAN_3."</td>"; 261 $text .="<td class='fcaption'>".EXTLAN_4."</td> 262 <td class='fcaption'>".EXTLAN_5."</td> 263 <td class='fcaption'>".EXTLAN_6."</td> 264 <td class='fcaption'>".EXTLAN_7."</td> 265 <td class='fcaption'> </td> 266 <td class='fcaption'>".EXTLAN_8."</td> 267 </tr> 268 "; 269 270 foreach($catNums as $cn) 271 { 272 $text .= " 273 <tr> 274 <td class='forumheader' colspan='9' style='text-align:center'>{$catList[$cn][0]['user_extended_struct_name']}</td> 275 </tr> 276 "; 277 278 $i=0; 279 if(count($extendedList)) 280 { 281 // Show current extended fields 282 foreach($extendedList[$cn] as $ext) { 283 $fname = "user_".$ext['user_extended_struct_name']; 284 $uVal = str_replace(chr(1), "", $curVal[$fname]); 285 $text .= " 286 <tr> 287 <td class='forumheader3'>{$ext['user_extended_struct_name']}<br />[".$tp->toHTML($ext['user_extended_struct_text'], FALSE, "defs")."]</td> 288 <td class='forumheader3'>".$ue->user_extended_edit($ext,$uVal)."</td> 289 <td class='forumheader3'>".($ext['user_extended_struct_required'] == 1 ? LAN_YES : LAN_NO)."</td> 290 <td class='forumheader3'>".r_userclass_name($ext['user_extended_struct_applicable'])."</td> 291 <td class='forumheader3'>".r_userclass_name($ext['user_extended_struct_read'])."</td> 292 <td class='forumheader3'>".r_userclass_name($ext['user_extended_struct_write'])."</td> 293 <td class='forumheader3' style='width:5px'> 294 <form method='post' action='".e_SELF."'> 295 <input type='hidden' name='id' value='{$ext['user_extended_struct_id']}.{$ext['user_extended_struct_order']}.{$ext['user_extended_struct_parent']}' /> 296 "; 297 if($i > 0){ 298 $text .= " 299 <input type='image' alt='' title='".EXTLAN_26."' src='".e_IMAGE."/admin_images/up.png' name='up' value='{$ext['user_extended_struct_id']}.{$ext['user_extended_struct_order']}.{$ext['user_extended_struct_parent']}' /> 300 "; 301 } 302 if($i <= count($extendedList[$cn])-2) 303 { 304 $text .= "<input type='image' alt='' title='".EXTLAN_25."' src='".e_IMAGE."/admin_images/down.png' name='down' value='{$ext['user_extended_struct_id']}.{$ext['user_extended_struct_order']}.{$ext['user_extended_struct_parent']}' />"; 305 } 306 $text .= " 307 </form> 308 </td> 309 <td class='forumheader3' style='width:50px;text-align:center;'> 310 <form method='post' action='".e_SELF."?extended' onsubmit='return confirm(\"".EXTLAN_27."\")'> 311 <a style='text-decoration:none' href='".e_SELF."?editext.{$ext['user_extended_struct_id']}'>".ADMIN_EDIT_ICON."</a> 312 <input type='hidden' name='eu_action' value='delext' /> 313 <input type='hidden' name='key' value='{$ext['user_extended_struct_id']},{$ext['user_extended_struct_name']}' /> 314 <input type='image' title='".LAN_DELETE."' name='eudel' src='".ADMIN_DELETE_ICON_PATH."' /> 315 </form> 316 </td> 317 </tr> 318 "; 319 $i++; 320 } 321 } 322 else 323 { 324 $text .= " 325 <tr> 326 <td colspan='8' class='forumheader3' style='text-align:center'>".EXTLAN_28."</td> 327 </tr> 328 "; 329 } 330 } 331 //Show add/edit form 332 $text .= " 333 </table>"; 334 } 335 else 336 { 337 if($current == 'new') 338 { 339 $current = ''; 340 } 341 list($current_include, $current_regex, $current_regexfail, $current_hide) = explode("^,^",$current['user_extended_struct_parms']); 342 $text .= " 343 <form method='post' action='".e_SELF."?".e_QUERY."'> 344 "; 345 $text .= "<table style='".ADMIN_WIDTH."' class='fborder'> "; 346 $text .= " 347 348 <tr> 349 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_10.":</td> 350 <td style='width:70%' class='forumheader3' colspan='3'>user_"; 351 if(is_array($current) && $current['user_extended_struct_name']) 352 { 353 $text .= $current['user_extended_struct_name']." 354 <input type='hidden' name='user_field' value='".$current['user_extended_struct_name']."' /> 355 "; 356 } 357 else 358 { 359 $text .= " 360 <input class='tbox' type='text' name='user_field' size='40' value='".$current['user_extended_struct_name']."' maxlength='50' /> 361 "; 362 } 363 $text .= " 364 <br /><span class='smalltext'>".EXTLAN_11."</span> 365 </td> 366 </tr> 367 368 <tr> 369 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_12.":</td> 370 <td style='width:70%' class='forumheader3' colspan='3'> 371 <input class='tbox' type='text' name='user_text' size='40' value='".$current['user_extended_struct_text']."' maxlength='50' /><br /> 372 <span class='smalltext'>".EXTLAN_13."</span> 373 </td> 374 </tr> 375 "; 376 377 $text .= "<tr> 378 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_14."</td> 379 <td style='width:70%' class='forumheader3' colspan='3'> 380 <select onchange='changeHelp(this.value)' class='tbox' name='user_type' id='user_type'>"; 381 foreach($ue->user_extended_types as $key => $val) 382 { 383 $selected = ($current['user_extended_struct_type'] == $key) ? " selected='selected'": ""; 384 $text .= "<option value='".$key."' $selected>".$val."</option>"; 385 } 386 $curtype = $current['user_extended_struct_type']; 387 if(!$curtype) 388 { 389 $curtype = '1'; 390 } 391 $text .= " 392 </select> 393 </td></tr>"; 394 395 396 397 $text .= " 398 <tr> 399 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_3."</td> 400 <td style='width:70%' class='forumheader3' colspan='3'>"; 401 // Start of Values --------------------------------- 402 403 $val_hide = ($current['user_extended_struct_type'] != 4) ? "visible" : "none"; 404 405 $text .= "<div id='values' style='display:$val_hide'>\n"; 406 $text .= "<div id='value_container' >\n"; 407 $curVals = explode(",",$current['user_extended_struct_values']); 408 if(count($curVals) == 0){ 409 $curVals[]=''; 410 } 411 $i=0; 412 foreach($curVals as $v){ 413 $id = $i ? "" : " id='value_line'"; 414 $i++; 415 $text .= " 416 <span {$id}> 417 <input class='tbox' type='text' name='user_values[]' size='40' value='{$v}' /></span><br />"; 418 } 419 $text .= " 420 </div> 421 <input type='button' class='button' value='".EXTLAN_48."' onclick=\"duplicateHTML('value_line','value_container');\" /> 422 <br /><span class='smalltext'>".EXTLAN_17."</span></div>"; 423 // End of Values. -------------------------------------- 424 $db_hide = ($current['user_extended_struct_type'] == 4) ? "visible" : "none"; 425 426 $text .= "<div id='db_mode' style='display:$db_hide'>\n"; 427 $text .= "<table style='width:70%;margin-left:0px'><tr><td>"; 428 $text .= EXTLAN_62."</td><td style='70%'><select style='width:99%' class='tbox' name='table_db' onchange=\"this.form.submit()\" > 429 <option value='' class='caption'>".EXTLAN_61."</option>\n"; 430 $result = mysql_list_tables($mySQLdefaultdb); 431 while ($row2 = mysql_fetch_row($result)){ 432 $fld = str_replace(MPREFIX,"",$row2[0]); 433 $selected = ($_POST['table_db'] == $fld || $curVals[0] == $fld) ? " selected='selected'" : ""; 434 $text .= (strpos($row2[0], MPREFIX) !== FALSE) ? "<option value=\"".$fld."\" $selected>".$fld."</option>\n" : ""; 435 } 436 $text .= " </select></td></tr>"; 437 if($_POST['table_db'] || $curVals[0]){ 438 // Field ID 439 $text .= "<tr><td>".EXTLAN_63."</td><td><select style='width:99%' class='tbox' name='field_id' >\n 440 <option value='' class='caption'>".EXTLAN_61."</option>\n"; 441 $table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0] ; 442 if($sql -> db_Select_gen("DESCRIBE ".MPREFIX."{$table_list}")){ 443 while($row3 = $sql -> db_Fetch()){ 444 $field_name=$row3[0]; 445 $selected = ($curVals[1] == $field_name) ? " selected='selected' " : ""; 446 $text .="<option value=\"$field_name\" $selected>".$field_name."</option>\n"; 447 } 448 } 449 $text .= " </select></td></tr><tr><td>"; 450 // Field Value 451 $text .= EXTLAN_64."</td><td><select style='width:99%' class='tbox' name='field_value' > 452 <option value='' class='caption'>".EXTLAN_61."</option>\n"; 453 $table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0] ; 454 if($sql -> db_Select_gen("DESCRIBE ".MPREFIX."{$table_list}")){ 455 while($row3 = $sql -> db_Fetch()){ 456 $field_name=$row3[0]; 457 $selected = ($curVals[2] == $field_name) ? " selected='selected' " : ""; 458 $text .="<option value=\"$field_name\" $selected>".$field_name."</option>\n"; 459 } 460 } 461 $text .= " </select></td></tr><tr><td>"; 462 463 $text .= LAN_ORDER."</td><td><select style='width:99%' class='tbox' name='field_order' > 464 <option value='' class='caption'>".EXTLAN_61."</option>\n"; 465 $table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0] ; 466 if($sql -> db_Select_gen("DESCRIBE ".MPREFIX."{$table_list}")){ 467 while($row3 = $sql -> db_Fetch()){ 468 $field_name=$row3[0]; 469 $selected = ($curVals[3] == $field_name) ? " selected='selected' " : ""; 470 $text .="<option value=\"$field_name\" $selected>".$field_name."</option>\n"; 471 } 472 } 473 $text .= " </select></td></tr>"; 474 475 } 476 $text .= "</table></div>"; 477 // --------------------------------------------------------- 478 $text .= " 479 </td> 480 </tr> 481 482 <tr> 483 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_16."</td> 484 <td style='width:70%' class='forumheader3' colspan='3'> 485 <input class='tbox' type='text' name='user_default' size='40' value='{$current['user_extended_struct_default']}' /> 486 </td> 487 </tr> 488 489 490 <tr> 491 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_15."</td> 492 <td style='width:70%' class='forumheader3' colspan='3'> 493 <textarea class='tbox' name='user_include' cols='60' rows='2'>{$current_include}</textarea><br /> 494 <span class='smalltext'>".EXTLAN_51."</span><br /> 495 </td> 496 </tr> 497 498 <tr> 499 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_52."</td> 500 <td style='width:70%' class='forumheader3' colspan='3'> 501 <input class='tbox' type='text' name='user_regex' size='30' value='{$current_regex}' /><br /> 502 <span class='smalltext'>".EXTLAN_53."</span><br /> 503 </td> 504 </tr> 505 506 <tr> 507 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_54."</td> 508 <td style='width:70%' class='forumheader3' colspan='3'> 509 <input class='tbox' type='text' name='user_regexfail' size='40' value='{$current_regexfail}' /><br /> 510 <span class='smalltext'>".EXTLAN_55."</span><br /> 511 </td> 512 </tr> 513 514 <tr> 515 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_44."</td> 516 <td style='width:70%' class='forumheader3' colspan='3'> 517 <select class='tbox' name='user_parent'>"; 518 foreach($catNums as $k) 519 { 520 $sel = ($k == $current['user_extended_struct_parent']) ? " selected='selected' " : ""; 521 $text .= "<option value='{$k}' {$sel}>{$catList[$k][0]['user_extended_struct_name']}</option>\n"; 522 } 523 $text .= "</select> 524 525 </td> 526 </tr> 527 528 <tr> 529 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_18."</td> 530 <td style='width:70%' class='forumheader3' colspan='3'> 531 <select class='tbox' name='user_required'> 532 "; 533 $_r = array('0' => EXTLAN_65, '1' => EXTLAN_66, '2' => EXTLAN_67); 534 foreach($_r as $k => $v) 535 { 536 $sel = ($current['user_extended_struct_required'] == $k ? " selected='selected' " : ""); 537 $text .= "<option value='{$k}' {$sel}>{$v}</option>\n"; 538 } 539 540 $text .= " 541 </select> 542 <br /> 543 <span class='smalltext'>".EXTLAN_19."</span> 544 </td> 545 </tr> 546 547 <tr> 548 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_5."</td> 549 <td style='width:70%' class='forumheader3' colspan='3'> 550 ".r_userclass("user_applicable", $current['user_extended_struct_applicable'], 'off', 'member, admin, classes, nobody')."<br /><span class='smalltext'>".EXTLAN_20."</span> 551 </td> 552 </tr> 553 554 <tr> 555 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_6."</td> 556 <td style='width:70%' class='forumheader3' colspan='3'> 557 ".r_userclass("user_read", $current['user_extended_struct_read'], 'off', 'public, member, admin, readonly, classes')."<br /><span class='smalltext'>".EXTLAN_22."</span> 558 </td> 559 </tr> 560 561 <tr> 562 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_7."</td> 563 <td style='width:70%' class='forumheader3' colspan='3'> 564 ".r_userclass("user_write", $current['user_extended_struct_write'], 'off', 'member, admin, classes')."<br /><span class='smalltext'>".EXTLAN_21."</span> 565 </td> 566 </tr> 567 568 <tr> 569 <td style='width:30%;vertical-align:top' class='forumheader3'>".EXTLAN_49." 570 </td> 571 <td style='width:70%' class='forumheader3' colspan='3'> 572 <select class='tbox' name='user_hide'> 573 "; 574 if($current_hide) 575 { 576 $text .= " 577 <option value='1' selected='selected'>".LAN_YES."</option> 578 <option value='0'>".LAN_NO."</option>"; 579 } 580 else 581 { 582 $text .= " 583 <option value='1'>".LAN_YES."</option> 584 <option value='0' selected='selected'>".LAN_NO."</option>"; 585 } 586 $text .= " 587 </select> 588 <br /><span class='smalltext'>".EXTLAN_50."</span> 589 </td> 590 </tr> 591 "; 592 593 $text .= "<tr> 594 <td colspan='4' style='text-align:center' class='forumheader'>"; 595 596 if ((!is_array($current) || $action == "continue") && $sub_action == "") 597 { 598 $text .= " 599 <input class='button' type='submit' name='add_field' value='".EXTLAN_23."' /> 600 "; 601 } 602 else 603 { 604 $text .= " 605 <input class='button' type='submit' name='update_field' value='".EXTLAN_24."' /> 606 <input class='button' type='submit' name='cancel' value='".EXTLAN_33."' /> 607 "; 608 } 609 // ======= end added by Cam. 610 $text .= "</td> 611 </tr> 612 613 </table></form> 614 "; 615 } 616 // $text .= "</div>"; 617 $ns->tablerender(EXTLAN_9, $text); 618 } 619 620 function show_categories($current) 621 { 622 global $sql, $ns, $ue; 623 624 $text = "<div style='text-align:center'>"; 625 $text .= " 626 <table style='".ADMIN_WIDTH."' class='fborder'> 627 <tr> 628 <td class='fcaption'>".EXTLAN_1."</td> 629 <td class='fcaption'>".EXTLAN_5."</td> 630 <td class='fcaption'>".EXTLAN_6."</td> 631 <td class='fcaption'>".EXTLAN_7."</td> 632 <td class='fcaption'> </td> 633 <td class='fcaption'>".EXTLAN_8."</td> 634 </tr> 635 "; 636 $catList = $ue->user_extended_get_categories(FALSE); 637 if(count($catList)) 638 { 639 // Show current categories 640 $i=0; 641 foreach($catList as $ext) 642 { 643 if ($ext['user_extended_struct_order'] != $i) 644 { 645 $ext['user_extended_struct_order'] = $i; 646 $xID=$ext['user_extended_struct_id']; 647 $sql->db_Update("user_extended_struct", "user_extended_struct_order=$i WHERE user_extended_struct_type = 0 AND user_extended_struct_id=$xID"); 648 } 649 650 $text .= " 651 <td class='forumheader3'>{$ext['user_extended_struct_name']}</td> 652 </td> 653 <td class='forumheader3'>".r_userclass_name($ext['user_extended_struct_applicable'])."</td> 654 <td class='forumheader3'>".r_userclass_name($ext['user_extended_struct_read'])."</td> 655 <td class='forumheader3'>".r_userclass_name($ext['user_extended_struct_write'])."</td> 656 <td class='forumheader3'> 657 <form method='post' action='".e_SELF."?cat'> 658 <input type='hidden' name='id' value='{$ext['user_extended_struct_id']}.{$ext['user_extended_struct_order']}' /> 659 "; 660 if($i > 0) 661 { 662 $text .= " 663 <input type='image' alt='' title='".EXTLAN_26."' src='".e_IMAGE."/admin_images/up.png' name='catup' value='{$ext['user_extended_struct_id']}.{$i}' /> 664 "; 665 } 666 if($i <= count($catList)-2) 667 { 668 $text .= "<input type='image' alt='' title='".EXTLAN_25."' src='".e_IMAGE."/admin_images/down.png' name='catdown' value='{$ext['user_extended_struct_id']}.{$i}' />"; 669 } 670 $text .= " 671 </form> 672 </td> 673 <td class='forumheader3' style='text-align:center; white-space: nowrap'> 674 <form method='post' action='".e_SELF."?cat' onsubmit='return confirm(\"".EXTLAN_27."\")'> 675 <input type='hidden' name='eu_action' value='delcat' /> 676 <input type='hidden' name='key' value='{$ext['user_extended_struct_id']},{$ext['user_extended_struct_name']}' /> 677 <a style='text-decoration:none' href='".e_SELF."?cat.{$ext['user_extended_struct_id']}'>".ADMIN_EDIT_ICON."</a> 678 <input type='image' title='".LAN_DELETE."' name='eudel' src='".ADMIN_DELETE_ICON_PATH."' /> 679 </form> 680 </td> 681 </tr> 682 "; 683 $i++; 684 } 685 } 686 else 687 { 688 $text .= " 689 <tr> 690 <td colspan='8' class='forumheader3' style='text-align:center'>".EXTLAN_37."</td> 691 </tr> 692 "; 693 } 694 695 //Show add/edit form 696 $text .= " 697 </table> 698 <form method='post' action='".e_SELF."?".e_QUERY."'> 699 "; 700 $text .= "<div><br /></div><table style='".ADMIN_WIDTH."' class='fborder'> "; 701 $text .= " 702 703 <tr> 704 <td style='width:30%' class='forumheader3'>".EXTLAN_38.":</td> 705 <td style='width:70%' class='forumheader3' colspan='3'> 706 <input class='tbox' type='text' name='user_field' size='40' value='".$current['user_extended_struct_name']."' maxlength='50' /> 707 <br /><span class='smalltext'>".EXTLAN_11."</span> 708 </td> 709 </tr> 710 711 <tr> 712 <td style='width:30%' class='forumheader3'>".EXTLAN_5."</td> 713 <td style='width:70%' class='forumheader3' colspan='3'> 714 ".r_userclass("user_applicable", $current['user_extended_struct_applicable'], 'off', 'member, admin, classes')."<br /><span class='smalltext'>".EXTLAN_20."</span> 715 </td> 716 </tr> 717 718 <tr> 719 <td style='width:30%' class='forumheader3'>".EXTLAN_6."</td> 720 <td style='width:70%' class='forumheader3' colspan='3'> 721 ".r_userclass("user_read", $current['user_extended_struct_read'], 'off', 'public, member, admin, classes, readonly')."<br /><span class='smalltext'>".EXTLAN_22."</span> 722 </td> 723 </tr> 724 725 <tr> 726 <td style='width:30%' class='forumheader3'>".EXTLAN_7."</td> 727 <td style='width:70%' class='forumheader3' colspan='3'> 728 ".r_userclass("user_write", $current['user_extended_struct_write'], 'off', 'member, admin, classes')."<br /><span class='smalltext'>".EXTLAN_21."</span> 729 </td> 730 </tr>"; 731 732 733 $text .= "<tr> 734 <td colspan='4' style='text-align:center' class='forumheader'>"; 735 736 if (!is_array($current)) 737 { 738 $text .= " 739 <input class='button' type='submit' name='add_category' value='".EXTLAN_39."' /> 740 "; 741 } 742 else 743 { 744 $text .= " 745 <input class='button' type='submit' name='update_category' value='".EXTLAN_42."' /> 746 <input class='button' type='submit' name='cancel_cat' value='".EXTLAN_33."' /> 747 "; 748 } 749 // ======= end added by Cam. 750 $text .= "</td> 751 </tr> 752 753 </table></form></div>"; 754 $ns->tablerender(EXTLAN_9, $text); 755 } 756 757 function show_options($action) { 758 // ##### Display options --------------------------------------------------------------------------------------------------------- 759 if ($action == "") { 760 $action = "main"; 761 } 762 // ##### Display options --------------------------------------------------------------------------------------------------------- 763 $var['main']['text'] = EXTLAN_34; 764 $var['main']['link'] = e_SELF; 765 766 $var['editext']['text'] = EXTLAN_45; 767 $var['editext']['link'] = e_SELF."?editext"; 768 769 $var['cat']['text'] = EXTLAN_35; 770 $var['cat']['link'] = e_SELF."?cat"; 771 772 $var['pre']['text'] = EXTLAN_56; 773 $var['pre']['link'] = e_SELF."?pre"; 774 775 show_admin_menu(EXTLAN_9, $action, $var); 776 } 777 } 778 779 function users_extended_adminmenu() { 780 global $user, $action, $ns, $curtype, $action; 781 $user->show_options($action); 782 if($action == 'editext' || $action == 'continue') 783 { 784 $ns->tablerender(EXTLAN_46." - <span id='ue_type'> </span>", "<div id='ue_help'> </div>"); 785 echo "<script type='text/javascript'>changeHelp('{$curtype}');</script>"; 786 } 787 } 788 789 790 function make_delimited($var) 791 { 792 global $tp; 793 foreach($var as $k => $v) 794 { 795 $var[$k] = $tp->toDB(trim($v)); 796 $var[$k] = str_replace(",", "[E_COMMA]", $var[$k]); 797 if($var[$k] == "") 798 { 799 unset($var[$k]); 800 } 801 } 802 $ret = implode(",", $var); 803 return $ret; 804 } 805 806 function show_predefined() 807 { 808 global $tp, $ns, $ue, $sql; 809 810 // Get list of current extended fields 811 $curList = $ue->user_extended_get_fieldlist(); 812 foreach($curList as $c) 813 { 814 $curNames[] = $c['user_extended_struct_name']; 815 } 816 817 //Get list of predefined fields, determine which are already activated. 818 $preList = $ue->parse_extended_xml('getfile'); 819 ksort($preList); 820 foreach($preList as $k => $v) 821 { 822 if($k != 'version') 823 { 824 if(in_array($v['name'], $curNames)) 825 { 826 $active[] = $v; 827 } 828 else 829 { 830 $inactive[] = $v; 831 } 832 } 833 } 834 835 $txt = " 836 <form method='post' action='".e_SELF."?pre'> 837 <table class='fborder' style='".ADMIN_WIDTH."'> 838 <tr> 839 <td class='fcaption' colspan='4'>".EXTLAN_57."</td> 840 </tr> 841 "; 842 if(count($active)) 843 { 844 foreach($active as $a) 845 { 846 $txt .= show_field($a, 'deactivate'); 847 } 848 } 849 else 850 { 851 $txt .= "<tr><td class='forumheader3' colspan='4'>".EXTLAN_61."</td></tr>"; 852 } 853 854 $txt .= " 855 <tr> 856 <td class='fcaption' colspan='4'>".EXTLAN_58."</td> 857 </tr> 858 "; 859 foreach($inactive as $a) 860 { 861 $txt .= show_field($a); 862 } 863 $txt .= "</table></form>"; 864 $ns->tablerender(EXTLAN_56, $txt); 865 require_once ('footer.php'); 866 exit; 867 } 868 869 function show_field($var, $type='activate') 870 { 871 global $tp; 872 static $head_shown; 873 $txt = ""; 874 // $showlist = array('type','text', 'values', 'include_text', 'regex'); 875 if($head_shown != 1) 876 { 877 878 $txt .= " 879 <tr> 880 <td class='forumheader'>".UE_LAN_9."</td> 881 <td class='forumheader'>".UE_LAN_10."</td> 882 <td class='forumheader'>".UE_LAN_11."</td> 883 <td class='forumheader' style='width: 5%'> </td> 884 </tr> 885 "; 886 $head_shown = 1; 887 } 888 $txt .= " 889 <tr> 890 <td class='forumheader3'>{$var['name']}</td> 891 <td class='forumheader3'>".$tp->toHTML($var['type'], false, 'defs')."</td> 892 <td class='forumheader3'>".constant(strtoupper($var['text'])."_DESC")."</td> 893 "; 894 // $txt .= constant("UE_LAN_".strtoupper($var['text'])."DESC")."<br />"; 895 // foreach($showlist as $f) 896 // { 897 // if($var[$f] != "" && $f != 'type' && $f !='text') 898 // { 899 // $txt .= "<strong>{$f}: </strong>".$tp->toHTML($var[$f], false, 'defs')."<br />"; 900 // } 901 // } 902 $val = ('activate' == $type) ? EXTLAN_59 : EXTLAN_60; 903 $txt .= " 904 <td class='forumheader3' style='text-align: center'><input class='button' type='submit' name='{$type}[{$var['name']}]' value='{$val}' /></td> 905 </tr>"; 906 return $txt; 907 } 908 909 function field_activate() 910 { 911 global $ue, $ns, $tp; 912 $ret = ""; 913 $preList = $ue->parse_extended_xml('getfile'); 914 $tmp = $preList; 915 916 foreach(array_keys($_POST['activate']) as $f) 917 { 918 919 $tmp[$f]['parms'] = $tp->toDB($tmp[$f]['parms']); 920 if($ue->user_extended_add($tmp[$f])) 921 { 922 $ret .= EXTLAN_68." $f ".EXTLAN_69."<br />"; 923 924 if($tmp[$f]['type']=="db field" && is_readable(e_ADMIN."sql/extended_".$f.".php")){ 925 $ret .= (process_sql($f)) ? LAN_CREATED." user_extended_{$f}<br />" : LAN_CREATED_FAILED." user_extended_{$f}<br />"; 926 } 927 } 928 else 929 { 930 $ret .= EXTLAN_70." $f ".EXTLAN_71."<br />"; 931 } 932 } 933 return $ret; 934 } 935 936 function field_deactivate() 937 { 938 global $ue, $ns, $tp,$sql; 939 $ret = ""; 940 foreach(array_keys($_POST['deactivate']) as $f) 941 { 942 if($ue->user_extended_remove($f, $f)) 943 { 944 $ret .= EXTLAN_68." $f ".EXTLAN_72."<br />"; 945 if(is_readable(e_ADMIN."sql/extended_".$f.".php")){ 946 $ret .= (mysql_query("DROP TABLE ".MPREFIX."user_extended_".$f)) ? LAN_DELETED." user_extended_".$f."<br />" : LAN_DELETED_FAILED." user_extended_".$f."<br />"; 947 } 948 } 949 else 950 { 951 $ret .= EXTLAN_70." $f ".EXTLAN_73."<br />"; 952 } 953 } 954 return $ret; 955 } 956 957 958 function process_sql($f){ 959 global $sql; 960 $filename = e_ADMIN."sql/extended_".$f.".php"; 961 $fd = fopen ($filename, "r"); 962 $sql_data = fread($fd, filesize($filename)); 963 fclose ($fd); 964 965 $search[0] = "CREATE TABLE "; $replace[0] = "CREATE TABLE ".MPREFIX; 966 $search[1] = "INSERT INTO "; $replace[1] = "INSERT INTO ".MPREFIX; 967 968 preg_match_all("/create(.*?)myisam;/si", $sql_data, $creation); 969 foreach($creation[0] as $tab){ 970 $query = str_replace($search,$replace,$tab); 971 if(!mysql_query($query)){ 972 $error = TRUE; 973 } 974 } 975 976 preg_match_all("/insert(.*?);/si", $sql_data, $inserts); 977 foreach($inserts[0] as $ins){ 978 $qry = str_replace($search,$replace,$ins); 979 if(!mysql_query($qry)){ 980 $error = TRUE; 981 } 982 } 983 984 return ($error) ? FALSE : TRUE; 985 986 } 987 988 989 990 function headerjs() 991 { 992 include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_user_extended.php"); 993 $text = " 994 <script type='text/javascript'> 995 996 function changeHelp(type) { 997 var ftype; 998 var helptext; 999 "; 1000 for($i=1; $i<=8; $i++) 1001 { 1002 $type_const = "UE_LAN_{$i}"; 1003 $help_const = "EXTLAN_HELP_{$i}"; 1004 $text .= " 1005 if(type == \"{$i}\") 1006 { 1007 xtype=\"".constant($type_const)."\"; 1008 what=\"".constant($help_const)."\"; 1009 }"; 1010 } 1011 $text .= " 1012 document.getElementById('ue_type').innerHTML=''+xtype+''; 1013 document.getElementById('ue_help').innerHTML=''+what+''; 1014 1015 if(type == 4){ 1016 document.getElementById('db_mode').style.display = ''; 1017 document.getElementById('values').style.display = 'none'; 1018 }else{ 1019 document.getElementById('values').style.display = ''; 1020 document.getElementById('db_mode').style.display = 'none'; 1021 } 1022 } 1023 1024 1025 </script>"; 1026 1027 global $cal; 1028 $text .= $cal->load_files(); 1029 1030 echo $text; 1031 } 1032 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |