On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • I already have one client with over 60 web users, and it makes for an ugly list. So I made a few changes to the Web User management system.

    First, I created a new dynamic action, manage_web_users.dynamic.action.php:
    <?php
    if(IN_SYSTEM!="true") die("Please use Manager instead of accessing this file directly.");
    ?>
    <div class="subTitle">
    <span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br /><?php echo $site_name ;?> - <?php echo $_lang['user_management_title']; ?></span>
    </div>
    <div class="sectionHeader"><img src='media/images/misc/dot.gif' alt="." /> <?php echo $_lang['user_management_title']; ?></div>
    <div class="sectionBody">
    <p><?php echo $_lang['user_management_msg']; ?></p>
    <ul>
        <li><a href="index.php?a=87"><?php echo $_lang['new_web_user']; ?></a></li>
    </ul>
    <br />
    <form name="wusearch" action="index.php?a=105" method="post">
    <table id="searchtable" cellpadding="0" cellspacing="0">
    <tr>
    <td style="vertical-align:bottom;"><ul><li><?php echo $_lang['search_by']; ?> </li></ul></td>
    <td><input type="text" name="username"> </td>
    <td><input type="text" name="fullname"> </td>
    <td><input type="text" name="useremail"> </td>
    </tr>
    <tr>
    <td> </td>
    <td style="text-align:center;"><input type="submit" name="uname" value="<?php echo $_lang['username']; ?>"></td>
    <td style="text-align:center;"><input type="submit" name="fname" value="<?php echo $_lang['user_full_name']; ?>"></td>
    <td style="text-align:center;"><input type="submit" name="email" value="<?php echo $_lang['user_email']; ?>"></td>
    </tr>
    </table>
    </form>
    <table cellpadding="0" cellspacing="0">
    <tr><td><ul><li><?php echo $_lang['list_by']; ?> </li></ul></td>
    <td>[<a href="index.php?a=105&l=a">A</a>]</td>
    <td>[<a href="index.php?a=105&l=b">B</a>]</td>
    <td>[<a href="index.php?a=105&l=c">C</a>]</td>
    <td>[<a href="index.php?a=105&l=d">D</a>]</td>
    <td>[<a href="index.php?a=105&l=e">E</a>]</td>
    <td>[<a href="index.php?a=105&l=f">F</a>]</td>
    <td>[<a href="index.php?a=105&l=g">G</a>]</td>
    <td>[<a href="index.php?a=105&l=h">H</a>]</td>
    <td>[<a href="index.php?a=105&l=i">I</a>]</td>
    <td>[<a href="index.php?a=105&l=j">J</a>]</td>
    <td>[<a href="index.php?a=105&l=k">K</a>]</td>
    <td>[<a href="index.php?a=105&l=l">L</a>]</td>
    <td>[<a href="index.php?a=105&l=m">M</a>]</td>
    <td>[<a href="index.php?a=105&l=n">N</a>]</td>
    <td>[<a href="index.php?a=105&l=o">O</a>]</td>
    <td>[<a href="index.php?a=105&l=p">P</a>]</td>
    <td>[<a href="index.php?a=105&l=q">Q</a>]</td>
    <td>[<a href="index.php?a=105&l=r">R</a>]</td>
    <td>[<a href="index.php?a=105&l=s">S</a>]</td>
    <td>[<a href="index.php?a=105&l=t">T</a>]</td>
    <td>[<a href="index.php?a=105&l=u">U</a>]</td>
    <td>[<a href="index.php?a=105&l=v">V</a>]</td>
    <td>[<a href="index.php?a=105&l=w">W</a>]</td>
    <td>[<a href="index.php?a=105&l=x">X</a>]</td>
    <td>[<a href="index.php?a=105&l=y">Y</a>]</td>
    <td>[<a href="index.php?a=105&l=z">Z</a>]</td>
    </tr></table>
    <?php // show search result
    if(isset($_POST['username']) && $_POST['username'] != "") {
        $user = $_POST['username'];
         $sql = "SELECT username, id FROM $dbase.".$table_prefix."web_users WHERE username = '$user'";
     }elseif(isset($_POST['fullname']) && $_POST['fullname'] != "") {
        $user = $_POST['fullname'];
        $sql = "SELECT wu.username, wu.id FROM $dbase.".$table_prefix."web_user_attributes wa, $dbase.".$table_prefix."web_users wu WHERE wa.fullname = '$user' AND wu.id = wa.internalKey";
    }elseif(isset($_POST['useremail']) && $_POST['useremail'] != "") {
        $user = $_POST['useremail'];
        $sql = "SELECT wu.username, wu.id FROM $dbase.".$table_prefix."web_user_attributes wa, $dbase.".$table_prefix."web_users wu WHERE wa.email = '$user' AND wu.id = wa.internalKey";
     }elseif(isset($_GET['l'])) {
        $l = $_GET['l'];
         $sql = "SELECT username, id FROM $dbase.".$table_prefix."web_users WHERE username LIKE '" . $l . "%' ORDER BY username"; 
    }
    if(isset($sql)) {
      $rs = mysql_query($sql); 
      include_once "controls/datasetpager.class.php";	
      $dp = new DataSetPager('',$rs,10);
      $dp->setRenderRowFnc("RenderWebUsers");
      $dp->render();
      $pager = $dp->getRenderedPager();
      $rows = $dp->getRenderedRows();
      if($pager) $pager = "Page $pager";
      else $pager = "<br />";
      echo "<table border='0' width='100%'>";
      echo "<tr><td align='left'>$pager</td></tr>";
      echo "<tr><td><ul>$rows</ul></td></tr>";
      echo "</table>";
     } // end if isset $sql		
    
    function RenderWebUsers($i,$row){
      if($i<1){
        return "<li>The request returned no web users!</li>";
      } else {
        return "<li><a href='index.php?id=".$row['id']."&a=88'>".$row['username']."</a></li>";
      }
     } // end function 
     ?>
    </ul>
    </div>

    I know, it's ugly and needs to have the rough edges smoothed off, but it works.

    Next, I removed the table structure from user_management.dynamic.action.php, as well as the section for Web Users.

    I made one change to mutate_web_user.dynamic.action.php at line 138, changing the query string variable to 105 to return the user to the Manage Web Users page.

    I made a few additions to the langauge file:
    $_lang['web_user_management_title'] = "Manage web users";
    $_lang['search_by'] = "Search by: ";
    $_lang['list_by'] = "List by: ";
    


    Added the function to manager/index.php at line 664:
    	case "105" :
    	include_once "header.inc.php";	
    	include_once "actions/dynamic/manage_web_users.dynamic.action.php";
    	include_once "footer.inc.php";
    	break;	
    


    And finally, added a new menu to the menu frame 2.php at line 165:
    <?php 	if($_SESSION['permissions']['edit_user']==1) { ?>			
    <a onclick="this.blur();" href="index.php?a=105" target="main"><img src='media/images/misc/arrow.gif' alt="Arrow!" /><?php echo $_lang["web_user_management_title"]; ?></a>
    <?php 	} ?>

    You can see it in action at http://www.jewishyou.com/manager, log in as "manager", password "manager". There aren't any users yet, I'm still working on front-end functionality for the site in my spare time.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
    • I already have one client with over 60 web users, and it makes for an ugly list. So I made a few changes to the Web User management system.

      Lovely. I'll add this to the system as well
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
      • I used ModX1 for that client; I've added the new paging system that ModX2 comes with to his user manager page, since he won't be getting many more users, but I'm using this hack for my community site, which hopefully someday will have thousands of users.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org