Integrated Mandy's changes to userlist.inc. Activated more parts of the user
authorBen Klang <ben@alkaloid.net>
Thu, 14 Jul 2005 00:26:24 +0000 (00:26 +0000)
committerBen Klang <ben@alkaloid.net>
Thu, 14 Jul 2005 00:26:24 +0000 (00:26 +0000)
forms.  Added javascript popups.  Moved all contexts back to drop-down
box in main menu for super-admins.  System Settings tab will become something
else, but not entirely sure what yet.

git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@52 06cd67b6-e706-0410-b29e-9de616bca6e9

index.php
lib/Driver/ldap.php
lib/Shout.php
shout.webprj
templates/menu.inc
templates/users/userlist.inc
users.php

index 1e2fb07..2d753d0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -19,9 +19,6 @@ if (!$shout_configured) {
 
 require_once SHOUT_BASE . '/lib/base.php';
 require_once SHOUT_BASE . '/lib/Shout.php';
-#require_once SHOUT_TEMPLATES . '/comment.inc';
-#require_once 'Horde/Variables.php';
-#require_once 'Horde/Text/Filter.php';
 
 $context = Util::getFormData("context");
 $section = Util::getFormData("section");
@@ -36,19 +33,26 @@ if (count($contexts) == 1) {
     $context = $shout->getHomeContext();
 }
 
+$tabs = &Shout::getTabs($context, $vars);
+$tabs->preserve('context', $context);
+if (!$section) {
+    $section = $tabs->_tabs[0]['tabname'];
+}
+
+#require_once SHOUT_TEMPLATES . '/comment.inc';
+#require_once 'Horde/Variables.php';
+#require_once 'Horde/Text/Filter.php';
+
+
+
 #$title = '[#' . $ticket->getId() . '] ' . $ticket->get('summary');
 require SHOUT_TEMPLATES . '/common-header.inc';
 require SHOUT_TEMPLATES . '/menu.inc';
 
-$tabs = &Shout::getTabs($context, $vars);
-$tabs->preserve('context', $context);
 
 echo "<br />";
 // if (!$section) {
 //     $section =
-if (!$section) {
-    $section = $tabs->_tabs[0]['tabname'];
-}
 
 echo $tabs->render($section);
 switch ($section) {
index bde7119..b630fb7 100644 (file)
@@ -55,23 +55,31 @@ class Shout_Driver_ldap extends Shout_Driver
 
         # Determine which combination of contexts need to be returned
         if ($searchfilters == SHOUT_CONTEXT_ALL) {
-            $searchfilter="(objectClass=*)";
+            $searchfilter="(objectClass=asteriskObject)";
         } else {
             $searchfilter = "(|";
             if ($searchfilters & SHOUT_CONTEXT_CUSTOMERS) {
                 $searchfilter.="(objectClass=vofficeCustomer)";
+            } else {
+                $searchfilter.="(!(objectClass=vofficeCustomer))";
             }
 
             if ($searchfilters & SHOUT_CONTEXT_EXTENSIONS) {
                 $searchfilter.="(objectClass=asteriskExtensions)";
+            } else {
+                $searchfilter.="(!(objectClass=asteriskExtensions))";
             }
 
             if ($searchfilters & SHOUT_CONTEXT_MOH) {
                 $searchfilter.="(objectClass=asteriskMusicOnHold)";
+            } else {
+                $searchfilter.="(!(objectClass=asteriskMusicOnHold))";
             }
 
             if ($searchfilters & SHOUT_CONTEXT_CONFERENCE) {
                 $searchfilter.="(objectClass=asteriskMeetMe)";
+            } else {
+                $searchfilter.="(!(objectClass=asteriskMeetMe))";
             }
             $searchfilter .= ")";
         }
index 6b46e2c..1ee50c9 100644 (file)
@@ -22,36 +22,17 @@ class Shout
      */
     function getMenu($returnType = 'object')
     {
-        global $conf, $page;
+        global $conf, $context, $section;
 
         require_once 'Horde/Menu.php';
 
         $menu = &new Menu(HORDE_MENU_MASK_ALL);
 
-        if (@count($conf['menu']['pages'])) {
-            foreach ($conf['menu']['pages'] as $pagename) {
-                /* Determine who we should say referred us. */
-                $curpage = isset($page) ? $page->pageName() : null;
-                $referrer = Util::getFormData('referrer', $curpage);
-
-                /* Determine if we should depress the button. We have to do
-                 * this on our own because all the buttons go to the same .php
-                 * file, just with different args. */
-                if (!strstr($_SERVER['PHP_SELF'], 'prefs.php') &&
-                    $curpage === _($pagename)) {
-                    $cellclass = 'current';
-                } else {
-                    $cellclass = '__noselection';
-                }
-
-                /* Construct the URL. */
-                $url = Horde::applicationUrl('display.php');
-                $url = Util::addParameter($url, array('page' => $pagename,
-                                                      'referrer' => $referrer));
-
-                $menu->add($url, _($pagename), $pagename . '.png', null, null,
-null, $cellclass);
-            }
+        if (isset($context) && isset($section) && $section == "users" &&
+            Shout::checkRights("shout:contexts:$context:users",
+                PERMS_EDIT, 1)) {
+            $menu->add("#", _("Add User"), "add-user.gif", null, null,
+                "open_adduser_win('context=$context')", null);
         }
 
         if ($returnType == 'object') {
@@ -81,26 +62,26 @@ null, $cellclass);
 
         $tabs = &new Horde_UI_Tabs('section', $vars);
 
-        if (Shout::checkRights("$permprefix:users") &&
+        if (Shout::checkRights("$permprefix:users", null, 1) &&
             $shout->checkContextType($context, "users")) {
             $tabs->addTab(_("Users"),
                     Horde::applicationUrl("index.php?context=$context"),
                     'users');
         }
 
-        if (Shout::checkRights("$permprefix:dialplan") &&
+        if (Shout::checkRights("$permprefix:dialplan", null, 1) &&
             $shout->checkContextType($context, "dialplan")) {
             $tabs->addTab(_("Dial Plan"),
                 Horde::applicationUrl('index.php'), 'dialplan');
         }
 
-        if (Shout::checkRights("$permprefix:conference") &&
+        if (Shout::checkRights("$permprefix:conference", null, 1) &&
             $shout->checkContextType($context, "conference")) {
             $tabs->addTab(_("Conference Rooms"),
                 Horde::applicationUrl('index.php'), 'conference');
         }
 
-       if (Shout::checkRights("$permprefix:moh") &&
+       if (Shout::checkRights("$permprefix:moh", null, 1) &&
             $shout->checkContextType($context, "moh")) {
             $tabs->addTab(_("Music on Hold"),
                 Horde::applicationUrl('index.php'), 'moh');
@@ -119,21 +100,48 @@ null, $cellclass);
         return $tabs;
     }
 
-    function checkRights($permname, $permmask = null)
+    // {{{
+    /**
+     * Checks for the given permissions for the current user on the given
+     * permission.  Optionally check for higher-level permissions and ultimately
+     * test for superadmin priveleges.
+     *
+     * @param string $permname Name of the permission to check
+     *
+     * @param optional int $permmask Bitfield of permissions to check for
+     *
+     * @param options int $numparents Check for the same permissions this
+     *                                many levels up the tree
+     *
+     * @return boolean the effective permissions for the user.
+     */
+    function checkRights($permname, $permmask = null, $numparents = 0)
     {
         if ($permmask == null) {
             $permmask = PERMS_SHOW|PERMS_READ;
         }
 
+        # Default deny all permissions
+        $user = 0;
+
         $superadmin = Auth::isAdmin("shout:superadmin", $permmask);
-        $user = Auth::isAdmin($permname, $permmask);
-        $test = $superadmin | $user;
-        if ($test) {
-            return TRUE;
-        } else {
-            return FALSE;
+
+        while ($numparents >= 0) {
+            $tmpuser = Auth::isAdmin($permname, $permmask);
+            $user = $user | $tmpuser;
+            if ($numparents> 0) {
+                $pos = strrpos($permname, ':');
+                if ($pos) {
+                    $permname = substr($permname, 0, $pos);
+                }
+            }
+            $numparents--;
         }
+
+        $test = $superadmin | $user;
+        return $test;
     }
+    // }}}
 
     function getContextTypes()
     {
index 12a188b..86ec4ad 100644 (file)
@@ -9,26 +9,26 @@
     <item url="templates/" uploadstatus="2" />
     <item url="lib/" uploadstatus="2" />
     <item url="lib/Driver/" uploadstatus="2" />
-    <item modified_time="1120808744" url="lib/Driver/ldap.php" uploadstatus="2" />
+    <item modified_time="1121295100" url="lib/Driver/ldap.php" uploadstatus="2" />
     <item modified_time="1120792108" url="lib/base.php" uploadstatus="2" />
-    <item modified_time="1120799748" url="lib/Driver.php" uploadstatus="2" />
-    <item modified_time="1120793382" url="index.php" uploadstatus="2" />
+    <item modified_time="1120815592" url="lib/Driver.php" uploadstatus="2" />
+    <item modified_time="1121298118" url="index.php" uploadstatus="2" />
     <uploadprofiles showtreeviews="true" defaultProfile="Shout" >
       <profile remote_host="picasso.v-office.biz" remote_port="" remote_path="/srv/vhost/users/aklang/sites/intranet.v-office.biz/shout" remote_protocol="sftp" user="aklang" name="Shout" >
         <uploadeditem upload_time="0" url="config/" />
         <uploadeditem upload_time="1120073766" url="config/conf.xml" />
         <uploadeditem upload_time="1120183942" url="contexts.php" />
         <uploadeditem upload_time="1120648621" url="dialplan.php" />
-        <uploadeditem upload_time="1120793382" url="index.php" />
+        <uploadeditem upload_time="1121298118" url="index.php" />
         <uploadeditem upload_time="1120021874" url="index.php~" />
         <uploadeditem upload_time="0" url="lib/" />
-        <uploadeditem upload_time="1120799748" url="lib/Driver.php" />
+        <uploadeditem upload_time="1120815592" url="lib/Driver.php" />
         <uploadeditem upload_time="1120022560" url="lib/Driver.php~" />
         <uploadeditem upload_time="0" url="lib/Driver/" />
-        <uploadeditem upload_time="1120808744" url="lib/Driver/ldap.php" />
+        <uploadeditem upload_time="1121295100" url="lib/Driver/ldap.php" />
         <uploadeditem upload_time="1120026921" url="lib/Driver/ldap.php~" />
         <uploadeditem upload_time="1120288491" url="lib/SelectContext.php" />
-        <uploadeditem upload_time="1120812478" url="lib/Shout.php" />
+        <uploadeditem upload_time="1121298016" url="lib/Shout.php" />
         <uploadeditem upload_time="1120812245" url="lib/System.php" />
         <uploadeditem upload_time="1120279975" url="lib/Users.php" />
         <uploadeditem upload_time="1120792108" url="lib/base.php" />
         <uploadeditem upload_time="1120169761" url="templates/context/contextline.inc" />
         <uploadeditem upload_time="0" url="templates/dialplan/" />
         <uploadeditem upload_time="1120648933" url="templates/dialplan/dialplanlist.inc" />
-        <uploadeditem upload_time="1120798154" url="templates/menu.inc" />
+        <uploadeditem upload_time="1121297521" url="templates/menu.inc" />
         <uploadeditem upload_time="0" url="templates/users/" />
-        <uploadeditem upload_time="1120648933" url="templates/users/userlist.inc" />
-        <uploadeditem upload_time="1120792108" url="users.php" />
+        <uploadeditem upload_time="1121300479" url="templates/users/userlist.inc" />
+        <uploadeditem upload_time="0" url="themes/" />
+        <uploadeditem upload_time="0" url="themes/graphics/" />
+        <uploadeditem upload_time="1121295816" url="themes/graphics/add-user.gif" />
+        <uploadeditem upload_time="1121298200" url="users.php" />
       </profile>
     </uploadprofiles>
     <debuggers>
     <defaultDTD>-//w3c//dtd xhtml 1.0 strict//en</defaultDTD>
     <item modified_time="1120073766" url="config/conf.xml" uploadstatus="1" />
     <item url="config/" uploadstatus="1" />
-    <item modified_time="1120812478" url="lib/Shout.php" uploadstatus="1" />
+    <item modified_time="1121298016" url="lib/Shout.php" uploadstatus="1" />
+    <item modified_time="1120158044" url="templates/common-header.inc" uploadstatus="1" />
+    <item modified_time="1121297521" url="templates/menu.inc" uploadstatus="1" />
+    <item modified_time="1121298200" url="users.php" uploadstatus="1" />
+    <item url="templates/context/" uploadstatus="1" />
+    <item modified_time="1120169761" url="templates/context/contextline.inc" uploadstatus="1" />
+    <item modified_time="1120296517" url="moh.php" uploadstatus="1" />
+    <item url="templates/users/" uploadstatus="1" />
+    <item modified_time="1121300479" url="templates/users/userlist.inc" uploadstatus="1" />
+    <item modified_time="1120648621" url="dialplan.php" uploadstatus="1" />
+    <item modified_time="1120648933" url="templates/dialplan/dialplanlist.inc" uploadstatus="1" />
+    <item url="templates/dialplan/" uploadstatus="1" />
+    <item modified_time="1120811068" url="system.php" uploadstatus="1" />
+    <item modified_time="1120812245" url="lib/System.php" uploadstatus="1" />
     <author>Ben Klang</author>
     <email>ben@alkaloid.net</email>
     <debuggerclient>Gubed</debuggerclient>
       <mailinglist address="" />
     </teamdata>
     <events/>
-    <item modified_time="1120158044" url="templates/common-header.inc" uploadstatus="1" />
-    <item modified_time="1120798154" url="templates/menu.inc" uploadstatus="1" />
-    <item modified_time="1120792108" url="users.php" uploadstatus="1" />
-    <item url="templates/context/" uploadstatus="1" />
-    <item modified_time="1120169761" url="templates/context/contextline.inc" uploadstatus="1" />
-    <item modified_time="1120296517" url="moh.php" uploadstatus="1" />
-    <item url="templates/users/" uploadstatus="1" />
-    <item modified_time="1120648933" url="templates/users/userlist.inc" uploadstatus="1" />
-    <item modified_time="1120648621" url="dialplan.php" uploadstatus="1" />
-    <item modified_time="1120648933" url="templates/dialplan/dialplanlist.inc" uploadstatus="1" />
-    <item url="templates/dialplan/" uploadstatus="1" />
-    <item modified_time="1120811068" url="system.php" />
-    <item modified_time="1120812245" url="lib/System.php" />
+    <item url="themes/" />
+    <item url="themes/graphics/" />
+    <item modified_time="1121295816" url="themes/graphics/add-user.gif" />
     <treestatus>
       <openfolder url="config" />
       <openfolder url="lib" />
       <openfolder url="lib/Driver" />
       <openfolder url="templates" />
-      <openfolder url="templates/context" />
-      <openfolder url="templates/dialplan" />
       <openfolder url="templates/users" />
+      <openfolder url="themes" />
+      <openfolder url="themes/graphics" />
     </treestatus>
   </project>
 </webproject>
index 76ecabc..a34f44e 100644 (file)
@@ -12,7 +12,7 @@ $menu_view = $prefs->getValue('menu_view');
    <label for="context" accesskey="<?php echo $accesskey ?>">
     <select id="context" name="context" onchange="contextSubmit()">
      <?php
-        foreach ($shout->getContexts(SHOUT_CONTEXT_CUSTOMERS) as $item) {
+        foreach ($shout->getContexts() as $item) {
             print "<option name=\"$item\"";
             if ($item == $context) {
                 print " selected";
@@ -51,8 +51,62 @@ function contextSubmit(clear)
         }
     }
 }
-// -->
-</script>
 
 
+var last_adduser_win;
 
+function open_adduser_win(args)
+{
+    var url = "<?php echo Horde::url($GLOBALS['registry']->applicationWebPath('%application%/users/add.php' , 'shout')) ?>";
+    if (url.indexOf('?') == -1) {
+        var glue = '?';
+    } else {
+        var glue = '&';
+    }
+    var now = new Date();
+    var name = "adduser_windows_" + now.getTime();
+    if (args != "") {
+        url = url + glue + args + "&uniq=" + now.getTime();
+    } else {
+        url = url + glue + "uniq=" + now.getTime();
+    }
+    var width = screen.width;
+    if (width > 775) {
+        width = 700;
+    } else {
+        width -= 75;
+    }
+    var height = screen.height;
+    if (height > 725) {
+        height = 650;
+    } else {
+        height -= 75;
+    }
+    param = "toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",left=0,top=0";
+    name = window.open(url, name, param);
+    if (!name) {
+        alert("<?php echo addslashes(_("The compose window can't be opened.  Perhaps you have set your browser to block popup windows?")) ?>");
+    } else {
+        if (!eval("name.opener")) {
+            name.opener = self;
+        }
+
+        last_adduser_win = name;
+    }
+}
+
+function focus_adduser_win(adduser_win)
+{
+    if (!adduser_win) {
+        adduser_win = last_adduser_win;
+    }
+
+    if (!adduser_win) {
+        return;
+    }
+
+    adduser_win.focus();
+}
+
+// -->
+</script>
index e48204c..d4baf88 100644 (file)
@@ -1,22 +1,63 @@
-<table width="90%" border="0" cellspacing="0" cellpadding="0" class="item">
+<script language="JavaScript" type="text/javascript">
+<!--
+function open_user_win(args, useraction)
+{
+    var url = "<?php echo Horde::applicationUrl("/users/") ?>"
+        + useraction + ".php";
+    if (url.indexOf('?') == -1) {
+        var glue = '?';
+    } else {
+        var glue = '&';
+    }
+    var name = useraction + "_user_window";
+    if (args != "") {
+        url = url + glue + args;
+    }
+    var width = screen.width;
+    if (width > 775) {
+        width = 700;
+    } else {
+        width -= 75;
+    }
+    var height = screen.height;
+    if (height > 725) {
+        height = 650;
+    } else {
+        height -= 75;
+    }
+    param =
+"toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",left=0,top=0";
+    name = window.open(url, name, param);
+    if (!name) {
+        alert("<?php echo addslashes(_("The compose window can't be opened.  Perhaps you have set your browser to block popup windows?")) ?>");
+    } else {
+        if (!eval("name.opener")) {
+            name.opener = self;
+        }
+    }
+}
+
+// -->
+</script>
+
+<link href="/screen_002.css" rel="stylesheet" type="text/css">
+<table width="95%" border="0" cellpadding="0" cellspacing="0" class="header">
+  <tr valign="bottom">
+    <td width="61"><div align="center"><font size="1">
+      &nbsp;
+    </td>
+    <td width="148"><div align="center"></div></td>
+    <td width="332">&nbsp;</td>
+    <td width="202"><font size="3">Context: <?php echo $context; ?></font></td>
+  </tr>
+</table>
+
+<table width="95%" border="0" cellpadding="0" cellspacing="0">
   <tbody>
-    <tr style="">
-        <td class="class">
-            <input name="AddUsr" type="submit" id="AddUsr3" value="Add User" />
-        </td>
-        <td class="class">Click on Name to edit User information.</td>
-        <td width="20" class="class"><div align="left"></div></td>
-        <td class="header">V-Office</td>
-    </tr>
-    <tr style="">
-        <td>&nbsp;</td>
-        <td>&nbsp;</td>
-        <td colspan="2">&nbsp;</td>
-    </tr>
-    <tr style="">
-        <td class="class"><strong>Ext.</strong></td>
-        <td class="class"><strong>Name</strong></td>
-        <td colspan="2" class="class"><strong>Email</strong></td>
+    <tr class="class">
+        <td width="7%"><strong>Ext.</strong></td>
+        <td colspan="2"><strong>Name</strong></td>
+        <td><strong>Email</strong></td>
     </tr>
     <?php
         $line = 0;
             $rowcolor = $line % 2;
             $line++;
     ?>
-    <tr style="item<?php echo $rowcolor; ?>">
-        <td><?php echo $extension; ?></td>
-        <td><?php echo $user['name'];
-?></td>
-        <td><?php echo $user['email']; ?></td>
+    <tr class="item<?php echo $rowcolor; ?>">
+        <td width="7%"><?php echo Horde::link("#", '', '', '',
+"open_user_win('context=$context&amp;extension=$extension', 'edit')");?>
+            <?php echo $extension; ?></a>
+        </td>
+        <td><?php echo Horde::link("#", '', '', '',
+"open_user_win('context=$context&amp;extension=$extension', 'edit')");?>
+            <?php echo $user['name'];?></a>
+        </td>
+        <td width="100">
+            <div align="center">
+                <?php
+                echo Horde::link("#", '', '', '',
+"open_user_win('context=$context&amp;extension=$extension', 'edit')");
+                ?><font size="1">edit</font></a>
+                &nbsp;&nbsp;|&nbsp;&nbsp;
+                <?php
+                echo Horde::link("#", '', '', '',
+
+"open_user_win('context=$context&amp;extension=$extension', 'delete')");
+                ?><font size="1">delete</font></a>
+            </div>
+            <div align="center"></div>
+        </td>
+    <td><?php echo $user['email']; ?></td>
     </tr>
     <?php
         }
     ?>
   </tbody>
-</table>
\ No newline at end of file
+</table>
index 098d07a..8b2b6f4 100644 (file)
--- a/users.php
+++ b/users.php
@@ -3,4 +3,4 @@ if (!defined(SHOUT_BASE)) {
     define(SHOUT_BASE, dirname(__FILE__));
 }
 
-require SHOUT_TEMPLATES . "/users/userlist.html";
\ No newline at end of file
+require SHOUT_TEMPLATES . "/users/userlist.inc";
\ No newline at end of file