PageRenderTime 62ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/e107_admin/users_extended.php

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