PageRenderTime 33ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/4.8/administrator/components/com_users/admin.users.html.php

http://miacms.googlecode.com/
PHP | 509 lines | 478 code | 14 blank | 17 comment | 13 complexity | b22c5e6ee468085f5e18716bc126f777 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-2.0
  1. <?php
  2. /**
  3. * @package MiaCMS
  4. * @subpackage Users
  5. * @author MiaCMS see README.php
  6. * @copyright see README.php
  7. * See COPYRIGHT.php for copyright notices and details.
  8. * @license GNU/GPL Version 2, see LICENSE.php
  9. * MiaCMS is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; version 2 of the License.
  12. */
  13. /** ensure this file is being included by a parent file */
  14. defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  15. class HTML_users {
  16. function showUsers( &$rows, $pageNav, $search, $option, $lists ) {
  17. global $mainframe, $mosConfig_offset;
  18. ?>
  19. <form action="index2.php" method="post" id="adminForm" name="adminForm">
  20. <table class="adminheading">
  21. <tr>
  22. <th class="user">
  23. <?php echo T_('User Manager'); ?>
  24. </th>
  25. <td>
  26. <?php echo T_('Filter:'); ?>
  27. </td>
  28. <td>
  29. <input type="text" id="search" name="search" value="<?php echo $search;?>" class="text_area" />
  30. </td>
  31. <td>
  32. <?php echo $lists['type'];?>
  33. </td>
  34. <td>
  35. <?php echo $lists['logged'];?>
  36. </td>
  37. </tr>
  38. </table>
  39. <table class="adminlist">
  40. <tr>
  41. <th width="2%" class="title">
  42. #
  43. </th>
  44. <th width="3%" class="title">
  45. <input id="check_all" type="checkbox" name="toggle" value="" />
  46. </th>
  47. <th class="title">
  48. <?php echo T_('Name'); ?>
  49. </th>
  50. <th width="5%" class="title" nowrap="nowrap">
  51. <?php echo T_('Logged In'); ?>
  52. </th>
  53. <th width="5%" class="title">
  54. <?php echo T_('Enabled'); ?>
  55. </th>
  56. <th width="15%" class="title" >
  57. <?php echo T_('UserID'); ?>
  58. </th>
  59. <th width="15%" class="title">
  60. <?php echo T_('Group'); ?>
  61. </th>
  62. <th width="15%" class="title">
  63. <?php echo T_('E-Mail'); ?>
  64. </th>
  65. <th width="10%" class="title">
  66. <?php echo T_('Last Visit'); ?>
  67. </th>
  68. </tr>
  69. <?php
  70. $k = 0;
  71. for ($i=0, $n=count( $rows ); $i < $n; $i++) {
  72. $row =& $rows[$i];
  73. $published = mosCommonHTML::userPublishedProcessing( $row, $i );
  74. $link = htmlentities('index2.php?option=com_users&task=editA&id='. $row->id. '&hidemainmenu=1');
  75. ?>
  76. <tr class="<?php echo "row$k"; ?>">
  77. <td>
  78. <?php echo $i+1+$pageNav->limitstart;?>
  79. </td>
  80. <td>
  81. <?php echo mosHTML::idBox( $i, $row->id ); ?>
  82. </td>
  83. <td>
  84. <a href="<?php echo $link; ?>">
  85. <?php echo $row->name; ?>
  86. </a>
  87. </td>
  88. <td align="center">
  89. <?php echo $row->loggedin ? '<img src="images/tick.png" width="12" height="12" border="0" alt="" />': ''; ?>
  90. </td>
  91. <td>
  92. <?php echo $published; ?>
  93. </td>
  94. <td>
  95. <?php echo $row->username; ?>
  96. </td>
  97. <td>
  98. <?php echo $row->groupname; ?>
  99. </td>
  100. <td>
  101. <a href="mailto:<?php echo $row->email; ?>">
  102. <?php echo $row->email; ?>
  103. </a>
  104. </td>
  105. <td nowrap="nowrap">
  106. <?php echo mosFormatDate( $row->lastvisitDate, "%Y-%m-%d %H:%M:%S" ); ?>
  107. </td>
  108. </tr>
  109. <?php
  110. $k = 1 - $k;
  111. }
  112. ?>
  113. </table>
  114. <?php echo $pageNav->getListFooter(); ?>
  115. <input type="hidden" name="option" value="<?php echo $option;?>" />
  116. <input type="hidden" name="task" value="" />
  117. <input type="hidden" id="boxchecked" name="boxchecked" value="0" />
  118. <input type="hidden" id="hidemainmenu" name="hidemainmenu" value="0" />
  119. </form>
  120. <?php
  121. $rowCount = count( $rows );
  122. $saveOrderCount = $rowCount - 1;
  123. $tag = <<<JSTAG
  124. <script type="text/javascript">
  125. //Setup the check all onclick handler
  126. YAHOO.util.Event.addListener("check_all", "click", function() {
  127. YAHOO.miacms.base.checkAll($rowCount);
  128. });
  129. //Setup filter event handlers
  130. YAHOO.util.Event.addListener("search", "change", function() {
  131. YAHOO.util.Dom.get("adminForm").submit();
  132. });
  133. YAHOO.util.Event.addListener("filter_type", "change", function() {
  134. YAHOO.util.Dom.get("adminForm").submit();
  135. });
  136. YAHOO.util.Event.addListener("filter_position", "change", function() {
  137. YAHOO.util.Dom.get("adminForm").submit();
  138. });
  139. //Setup save icon event handler
  140. YAHOO.util.Event.addListener("saveorder", "click", function() {
  141. YAHOO.miacms.base.saveorder($saveOrderCount);
  142. });
  143. </script>
  144. JSTAG;
  145. $mainframe->addCustomFootTag($tag);
  146. }
  147. function edituser( &$row, &$contact, &$lists, $option, $uid, $openids = null ) {
  148. global $mainframe, $my, $acl, $mosConfig_live_site;
  149. $canBlockUser = $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'user properties', 'block_user' );
  150. $canEmailEvents = $acl->acl_check( 'workflow', 'email_events', 'users', $acl->get_group_name( $row->gid, 'ARO' ) );
  151. ?>
  152. <form action="index2.php?f=<?php echo mosMainframe::formId($option, 'edit', $my); ?>" method="post" id="adminForm" name="adminForm">
  153. <table class="adminheading">
  154. <tr>
  155. <th class="user">
  156. <?php echo T_('User:'); ?> <small><?php echo $row->id ? T_('Edit') : T_('Add');?></small>
  157. </th>
  158. </tr>
  159. </table>
  160. <table width="100%">
  161. <tr>
  162. <td width="60%" valign="top">
  163. <table class="adminform">
  164. <tr>
  165. <th colspan="2">
  166. <?php echo T_('User Details'); ?>
  167. </th>
  168. </tr>
  169. <tr>
  170. <td width="100">
  171. <?php echo T_('Name:'); ?>
  172. </td>
  173. <td width="85%">
  174. <input type="text" name="name" class="inputbox" size="40" value="<?php echo $row->name; ?>" />
  175. </td>
  176. </tr>
  177. <tr>
  178. <td>
  179. <?php echo T_('Username:'); ?>
  180. </td>
  181. <td>
  182. <input type="text" name="username" class="inputbox" size="40" value="<?php echo $row->username; ?>" />
  183. </td>
  184. </tr>
  185. <tr>
  186. <td>
  187. <?php echo T_('Email:'); ?>
  188. </td>
  189. <td>
  190. <input class="inputbox" type="text" name="email" size="40" value="<?php echo $row->email; ?>" />
  191. </td>
  192. </tr>
  193. <tr>
  194. <td>
  195. <?php echo T_('New Password:'); ?>
  196. </td>
  197. <td>
  198. <input class="inputbox" type="password" name="password" size="40" value="" />
  199. </td>
  200. </tr>
  201. <tr>
  202. <td>
  203. <?php echo T_('Verify Password:'); ?>
  204. </td>
  205. <td>
  206. <input class="inputbox" type="password" name="password2" size="40" value="" />
  207. </td>
  208. </tr>
  209. <tr>
  210. <td valign="top">
  211. <?php echo T_('Group:'); ?>
  212. </td>
  213. <td>
  214. <?php echo $lists['gid']; ?>
  215. </td>
  216. </tr>
  217. <?php
  218. if ($canBlockUser) {
  219. ?>
  220. <tr>
  221. <td>
  222. <?php echo T_('Block User'); ?>
  223. </td>
  224. <td>
  225. <?php echo $lists['block']; ?>
  226. </td>
  227. </tr>
  228. <?php
  229. }
  230. if ($canEmailEvents) {
  231. ?>
  232. <tr>
  233. <td>
  234. <?php echo T_('Receive Submission Emails'); ?>
  235. </td>
  236. <td>
  237. <?php echo $lists['sendEmail']; ?>
  238. </td>
  239. </tr>
  240. <?php
  241. }
  242. if( $uid ) {
  243. ?>
  244. <tr>
  245. <td>
  246. <?php echo T_('Register Date'); ?>
  247. </td>
  248. <td>
  249. <?php echo $row->registerDate;?>
  250. </td>
  251. </tr>
  252. <tr>
  253. <td>
  254. <?php echo T_('Last Visit Date'); ?>
  255. </td>
  256. <td>
  257. <?php echo $row->lastvisitDate;?>
  258. </td>
  259. </tr>
  260. <?php
  261. }
  262. ?>
  263. <tr>
  264. <td colspan="2">&nbsp;
  265. </td>
  266. </tr>
  267. </table>
  268. </td>
  269. <td width="40%" valign="top">
  270. <?php
  271. if ( !$contact ) {
  272. ?>
  273. <table class="adminform">
  274. <tr>
  275. <th>
  276. <?php echo T_('Contact Information'); ?>
  277. </th>
  278. </tr>
  279. <tr>
  280. <td>
  281. <br />
  282. <?php echo T_('No Contact details linked to this User:'); ?>
  283. <br />
  284. <?php echo T_('See "Components -> Contact -> Manage Contacts" for details.'); ?>
  285. <br /><br />
  286. </td>
  287. </tr>
  288. </table>
  289. <?php
  290. } else {
  291. ?>
  292. <table class="adminform">
  293. <tr>
  294. <th colspan="2">
  295. <?php echo T_('Contact Information'); ?>
  296. </th>
  297. </tr>
  298. <tr>
  299. <td width="15%">
  300. <?php echo T_('Name:'); ?>
  301. </td>
  302. <td>
  303. <strong>
  304. <?php echo $contact[0]->name;?>
  305. </strong>
  306. </td>
  307. </tr>
  308. <tr>
  309. <td>
  310. <?php echo T_('Position:'); ?>
  311. </td>
  312. <td >
  313. <strong>
  314. <?php echo $contact[0]->con_position;?>
  315. </strong>
  316. </td>
  317. </tr>
  318. <tr>
  319. <td>
  320. <?php echo T_('Telephone:'); ?>
  321. </td>
  322. <td >
  323. <strong>
  324. <?php echo $contact[0]->telephone;?>
  325. </strong>
  326. </td>
  327. </tr>
  328. <tr>
  329. <td>
  330. <?php echo T_('Fax:'); ?>
  331. </td>
  332. <td >
  333. <strong>
  334. <?php echo $contact[0]->fax;?>
  335. </strong>
  336. </td>
  337. </tr>
  338. <tr>
  339. <td></td>
  340. <td >
  341. <strong>
  342. <?php echo $contact[0]->misc;?>
  343. </strong>
  344. </td>
  345. </tr>
  346. <?php
  347. if ($contact[0]->image) {
  348. ?>
  349. <tr>
  350. <td></td>
  351. <td valign="top">
  352. <img src="<?php echo $mosConfig_live_site;?>/images/stories/<?php echo $contact[0]->image; ?>" align="middle" alt="<?php echo T_('Contact'); ?>" />
  353. </td>
  354. </tr>
  355. <?php
  356. }
  357. ?>
  358. <tr>
  359. <td colspan="2">
  360. <br /><br />
  361. <input class="button" type="button" value="<?php echo T_('Change Contact Details'); ?>" onclick="YAHOO.admin.user.gotocontact( '<?php echo $contact[0]->id; ?>' );" />
  362. <i>
  363. <br />
  364. '<?php echo T_('Components -> Contact -> Manage Contacts'); ?>'.
  365. </i>
  366. </td>
  367. </tr>
  368. </table>
  369. <?php
  370. }
  371. if (($openids != null) && (count($openids) > 0)) {
  372. ?>
  373. <table class="adminform">
  374. <tr>
  375. <th>
  376. <?php echo T_('OpenIDs'); ?>
  377. </th>
  378. </tr>
  379. <tr>
  380. <td>
  381. <?php HTML_users::listOpenIDs($openids); ?>
  382. </td>
  383. </tr>
  384. </table>
  385. <?php
  386. }
  387. ?>
  388. </td>
  389. </tr>
  390. </table>
  391. <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
  392. <input type="hidden" name="option" value="<?php echo $option; ?>" />
  393. <input type="hidden" name="task" value="" />
  394. <input type="hidden" name="contact_id" value="" />
  395. <?php
  396. if (!$canEmailEvents) {
  397. ?>
  398. <input type="hidden" name="sendEmail" value="0" />
  399. <?php
  400. }
  401. ?>
  402. </form>
  403. <?php
  404. //Define heredoc vars
  405. $nameMsg = T_('You must provide a name');
  406. $loginNameMsg = T_('You must provide a user login name');
  407. $invalidMsg = T_('Your login name contains invalid characters or is too short');
  408. $emailMsg = T_('You must provide an email address');
  409. $passwordMsg = T_('Passwords do not match');
  410. $assignUserMsg = T_('You must assign user to a group');
  411. $pfeMsg = T_('Please Select another group as `Public Frontend` is not a selectable option');
  412. $pbeMsg = T_('Please Select another group as `Public Backend` is not a selectable option');
  413. $tag = <<<JSTAG
  414. <script type="text/javascript">
  415. YAHOO.util.Event.on(window, "load", function() {
  416. YAHOO.miacms.base.submitbutton = function(pressbutton) {
  417. var form = YAHOO.util.Dom.get("adminForm") || document.adminForm;
  418. if (pressbutton === 'cancel') {
  419. YAHOO.miacms.base.submitform( pressbutton );
  420. return;
  421. }
  422. var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
  423. //Do field validation
  424. if (YAHOO.miacms.base.trim(form.name.value) === "") {
  425. alert( "$nameMsg" );
  426. } else if (YAHOO.miacms.base.trim(form.username.value) === "") {
  427. alert( "$loginNameMsg" );
  428. } else if (r.exec(form.username.value) || form.username.value.length < 3) {
  429. alert( "$invalidMsg" );
  430. } else if (YAHOO.miacms.base.trim(form.email.value) === "") {
  431. alert( "$emailMsg" );
  432. } else if (YAHOO.miacms.base.trim(form.password.value) != "" && form.password.value != form.password2.value){
  433. alert( "$passwordMsg" );
  434. } else if (form.gid.value === "") {
  435. alert( "$assignUserMsg" );
  436. } else if (form.gid.value == "29") {
  437. alert( "$pfeMsg" );
  438. } else if (form.gid.value == "30") {
  439. alert( "$pbeMsg" );
  440. } else {
  441. YAHOO.miacms.base.submitform( pressbutton );
  442. }
  443. };
  444. YAHOO.namespace("admin.user");
  445. YAHOO.admin.user.gotocontact = function( id ) {
  446. var form = YAHOO.util.Dom.get("adminForm") || document.adminForm;
  447. form.contact_id.value = id;
  448. YAHOO.miacms.base.submitform( 'contact' );
  449. };
  450. });
  451. </script>
  452. JSTAG;
  453. $mainframe->addCustomFootTag($tag);
  454. }
  455. function listOpenIDs($openids) {
  456. //for each openid
  457. global $mainframe, $mosConfig_live_site;
  458. echo "<p>".T_("You can remove your registered OpenIDs by clicking the Remove links.");
  459. echo "<ol>";
  460. foreach ($openids as $openid) {
  461. $link = "index2.php?option=com_users&task=removeOpenID&idopenid=".$openid->id."&userid=".$openid->user_id;
  462. echo "<li>".$openid->openid."&nbsp;<a class='removeopenidlink' href=".$link.">".T_("Remove")."</a></li>";
  463. }
  464. echo "</ol>";
  465. echo "</div>";
  466. $sureMsg = T_('Are you sure you want to delete the OpenID?');
  467. $tag = <<<JSTAG
  468. <script type="text/javascript">
  469. YAHOO.util.Event.on(window, "load", function() {
  470. YAHOO.miacms.base.removeopenid = function(e) {
  471. if (!confirm('$sureMsg')) {
  472. YAHOO.util.Event.preventDefault(e);
  473. YAHOO.util.Event.stopPropagation(e);
  474. return false;
  475. }
  476. return true;
  477. };
  478. var removeopenidlinks = YAHOO.util.Dom.getElementsByClassName("removeopenidlink") || "undefined";
  479. if (removeopenidlinks !=="undefined") {
  480. YAHOO.util.Event.addListener(removeopenidlinks, "click", YAHOO.miacms.base.removeopenid);
  481. }
  482. });
  483. </script>
  484. JSTAG;
  485. $mainframe->addCustomFootTag($tag);
  486. return;
  487. }
  488. }
  489. ?>