[Svn] r5748 - trunk/plugins/acl

trac at roundcube.net trac at roundcube.net
Tue Jan 10 10:55:35 CET 2012


Author: alec
Date: 2012-01-10 03:55:35 -0600 (Tue, 10 Jan 2012)
New Revision: 5748

Modified:
   trunk/plugins/acl/acl.js
   trunk/plugins/acl/acl.php
   trunk/plugins/acl/package.xml
Log:
- Fixed edit/delete actions state after deleting table row                                                                                           
- Chandle adding ACL user-entries with comma - split the value and create many entries


Modified: trunk/plugins/acl/acl.js
===================================================================
--- trunk/plugins/acl/acl.js	2012-01-09 14:30:56 UTC (rev 5747)
+++ trunk/plugins/acl/acl.js	2012-01-10 09:55:35 UTC (rev 5748)
@@ -179,9 +179,8 @@
         if (this.env.acl_specials.length && $.inArray(selection[n], this.env.acl_specials) >= 0) {
             users.push(selection[n]);
         }
-        else {
-            row = list.rows[selection[n]].obj;
-            cell = $('td.user', row);
+        else if (row = list.rows[selection[n]]) {
+            cell = $('td.user', row.obj);
             if (cell.length == 1)
                 users.push(cell.text());
         }
@@ -193,10 +192,17 @@
 // Removes ACL table row
 rcube_webmail.prototype.acl_remove_row = function(id)
 {
-    this.acl_list.remove_row(id);
+    var list = this.acl_list;
+
+    list.remove_row(id);
+    list.clear_selection();
+
     // we don't need it anymore (remove id conflict)
     $('#rcmrow'+id).remove();
     this.env.acl[id] = null;
+
+    this.enable_command('acl-delete', list.selection.length > 0);
+    this.enable_command('acl-edit', list.selection.length == 1);
 }
 
 // Adds ACL table row
@@ -259,7 +265,7 @@
 // Initializes and shows ACL create/edit form
 rcube_webmail.prototype.acl_init_form = function(id)
 {
-    var ul, row, val = '', type = 'user', li_elements, body = $('body'),
+    var ul, row, td, val = '', type = 'user', li_elements, body = $('body'),
         adv_ul = $('#advancedrights'), sim_ul = $('#simplerights'),
         name_input = $('#acluser');
 
@@ -286,10 +292,11 @@
     li_elements = $(':checkbox', ul);
     li_elements.attr('checked', false);
 
-    if (id) {
-        row = this.acl_list.rows[id].obj;
+    if (id && (row = this.acl_list.rows[id])) {
+        row = row.obj;
         li_elements.map(function() {
-            var val = this.value, td = $('td.'+this.id, row);
+            val = this.value;
+            td = $('td.'+this.id, row);
             if (td && td.hasClass('enabled'))
                 this.checked = true;
         });

Modified: trunk/plugins/acl/acl.php
===================================================================
--- trunk/plugins/acl/acl.php	2012-01-09 14:30:56 UTC (rev 5747)
+++ trunk/plugins/acl/acl.php	2012-01-10 09:55:35 UTC (rev 5748)
@@ -441,26 +441,37 @@
         $acl   = trim(get_input_value('_acl', RCUBE_INPUT_GPC));
         $oldid = trim(get_input_value('_old', RCUBE_INPUT_GPC));
 
-        $acl = array_intersect(str_split($acl), $this->rights_supported());
+        $acl   = array_intersect(str_split($acl), $this->rights_supported());
+        $users = $oldid ? array($user) : explode(',', $user);
 
-        if (!empty($this->specials) && in_array($user, $this->specials)) {
-            $username = $this->gettext($user);
-        }
-        else {
-            if (!strpos($user, '@') && ($realm = $this->get_realm())) {
-                $user .= '@' . rcube_idn_to_ascii(preg_replace('/^@/', '', $realm));
+        foreach ($users as $user) {
+            $user = trim($user);
+
+            if (!empty($this->specials) && in_array($user, $this->specials)) {
+                $username = $this->gettext($user);
             }
-            $username = $user;
-        }
+            else {
+                if (!strpos($user, '@') && ($realm = $this->get_realm())) {
+                    $user .= '@' . rcube_idn_to_ascii(preg_replace('/^@/', '', $realm));
+                }
+                $username = $user;
+            }
 
-        if ($acl && $user && $user != $_SESSION['username'] && strlen($mbox)) {
-            $result = $this->rc->imap->set_acl($mbox, $user, $acl);
+            if (!$acl || !$user || !strlen($mbox)) {
+                continue;
+            }
+
+            if ($user != $_SESSION['username'] && $username != $_SESSION['username']) {
+                if ($this->rc->imap->set_acl($mbox, $user, $acl)) {
+                    $ret = array('id' => html_identifier($user),
+                         'username' => $username, 'acl' => implode($acl), 'old' => $oldid);
+                    $this->rc->output->command('acl_update', $ret);
+                    $result++;
+                }
+            }
         }
 
         if ($result) {
-            $ret = array('id' => html_identifier($user),
-                 'username' => $username, 'acl' => implode($acl), 'old' => $oldid);
-            $this->rc->output->command('acl_update', $ret);
             $this->rc->output->show_message($oldid ? 'acl.updatesuccess' : 'acl.createsuccess', 'confirmation');
         }
         else {
@@ -479,6 +490,7 @@
         $user = explode(',', $user);
 
         foreach ($user as $u) {
+            $u = trim($u);
             if ($this->rc->imap->delete_acl($mbox, $u)) {
                 $this->rc->output->command('acl_remove_row', html_identifier($u));
             }

Modified: trunk/plugins/acl/package.xml
===================================================================
--- trunk/plugins/acl/package.xml	2012-01-09 14:30:56 UTC (rev 5747)
+++ trunk/plugins/acl/package.xml	2012-01-10 09:55:35 UTC (rev 5748)
@@ -13,10 +13,10 @@
 		<email>alec at alec.pl</email>
 		<active>yes</active>
 	</lead>
-	<date>2011-11-28</date>
+	<date>2012-01-10</date>
 	<version>
-		<release>0.6.6</release>
-		<api>0.6</api>
+		<release>0.7</release>
+		<api>0.7</api>
 	</version>
 	<stability>
 		<release>stable</release>

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list