[Svn] r4121 - in trunk/roundcubemail: . program/include program/js program/localization/de_CH program/localization/de_DE program/localization/en_US program/steps/addressbook skins/default skins/default/templates

trac at roundcube.net trac at roundcube.net
Fri Oct 22 17:24:39 CEST 2010


Author: thomasb
Date: 2010-10-22 10:24:39 -0500 (Fri, 22 Oct 2010)
New Revision: 4121

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_contacts.php
   trunk/roundcubemail/program/js/app.js
   trunk/roundcubemail/program/localization/de_CH/labels.inc
   trunk/roundcubemail/program/localization/de_DE/labels.inc
   trunk/roundcubemail/program/localization/en_US/labels.inc
   trunk/roundcubemail/program/steps/addressbook/show.inc
   trunk/roundcubemail/skins/default/common.css
   trunk/roundcubemail/skins/default/settings.css
   trunk/roundcubemail/skins/default/templates/showcontact.html
Log:
List groups in address detail view and allow to subscribe/unsubscribe from there (#1486753)

Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/CHANGELOG	2010-10-22 15:24:39 UTC (rev 4121)
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- List groups in address detail view and allow to subscribe/unsubscribe from there (#1486753)
 - Messages caching: performance improvements, fixed syncing, fixes related with #1486748
 - Add link to identities in compose window (#1486729)
 - Add Internationalized Domain Name (IDNA) support (#1483894)

Modified: trunk/roundcubemail/program/include/rcube_contacts.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_contacts.php	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/program/include/rcube_contacts.php	2010-10-22 15:24:39 UTC (rev 4121)
@@ -355,6 +355,33 @@
 
 
     /**
+     * Get group assignments of a specific contacr record
+     *
+     * @param mixed Record identifier
+     * @param array List of assigned groups as ID=>Name pairs
+     */
+    function get_record_groups($id)
+    {
+      $results = array();
+
+      if (!$this->groups)
+          return $results;
+
+      $sql_result = $this->db->query(
+        "SELECT cgm.contactgroup_id, cg.name FROM " . get_table_name($this->db_groupmembers) . " AS cgm" .
+        " LEFT JOIN " . get_table_name($this->db_groups) . " AS cg ON (cgm.contactgroup_id = cg.contactgroup_id AND cg.del<>1)" .
+        " WHERE cgm.contact_id=?",
+        $id
+      );
+      while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
+        $results[$sql_arr['contactgroup_id']] = $sql_arr['name'];
+      }
+
+      return $results;
+    }
+
+
+    /**
      * Create a new contact record
      *
      * @param array Assoziative array with save data

Modified: trunk/roundcubemail/program/js/app.js
===================================================================
--- trunk/roundcubemail/program/js/app.js	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/program/js/app.js	2010-10-22 15:24:39 UTC (rev 4121)
@@ -306,8 +306,18 @@
           this.enable_command('group-create', this.env.address_sources[this.env.source].groups);
         }
 
-        if (this.env.cid)
+        if (this.env.cid) {
           this.enable_command('show', 'edit', true);
+          // register handlers for group assignment via checkboxes
+          if (this.gui_objects.editform) {
+            $('input.groupmember').change(function(){
+              var cmd = this.checked ? 'group-addmembers' : 'group-delmembers';
+              ref.http_post(cmd, '_cid='+urlencode(ref.env.cid)
+                + '&_source='+urlencode(ref.env.source)
+                + '&_gid='+urlencode(this.value));
+            });
+          }
+        }
 
         if ((this.env.action=='add' || this.env.action=='edit') && this.gui_objects.editform) {
           this.enable_command('save', true);
@@ -3713,7 +3723,7 @@
   {
     // exit if no mailbox specified or if selection is empty
     var selection = this.contact_list.get_selection();
-    if (!(selection.length || this.env.cid) || (!this.env.group && !confirm(this.get_label('deletecontactconfirm'))))
+    if (!(selection.length || this.env.cid) || !confirm(this.get_label('deletecontactconfirm')))
       return;
 
     var id, a_cids = [], qs = '';
@@ -3737,10 +3747,7 @@
       qs += '&_search='+this.env.search_request;
 
     // send request to server
-    if (this.env.group)
-      this.http_post('group-delmembers', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+qs);
-    else
-      this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs);
+    this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs);
 
     return true;
   };

Modified: trunk/roundcubemail/program/localization/de_CH/labels.inc
===================================================================
--- trunk/roundcubemail/program/localization/de_CH/labels.inc	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/program/localization/de_CH/labels.inc	2010-10-22 15:24:39 UTC (rev 4121)
@@ -201,6 +201,7 @@
 $labels['surname'] = 'Nachname';
 $labels['email'] = 'E-Mail';
 $labels['contacts'] = 'Kontakte';
+$labels['contactproperties'] = 'Kontaktdaten';
 $labels['addcontact'] = 'Kontakt hinzufügen';
 $labels['editcontact'] = 'Kontakt bearbeiten';
 $labels['edit'] = 'Bearbeiten';

Modified: trunk/roundcubemail/program/localization/de_DE/labels.inc
===================================================================
--- trunk/roundcubemail/program/localization/de_DE/labels.inc	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/program/localization/de_DE/labels.inc	2010-10-22 15:24:39 UTC (rev 4121)
@@ -204,6 +204,7 @@
 $labels['addcontact'] = 'Kontakt hinzufügen';
 $labels['editcontact'] = 'Kontakt bearbeiten';
 $labels['contacts'] = 'Kontakte';
+$labels['contactproperties'] = 'Kontaktdaten';
 $labels['edit'] = 'Bearbeiten';
 $labels['cancel'] = 'Abbrechen';
 $labels['save'] = 'Speichern';

Modified: trunk/roundcubemail/program/localization/en_US/labels.inc
===================================================================
--- trunk/roundcubemail/program/localization/en_US/labels.inc	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/program/localization/en_US/labels.inc	2010-10-22 15:24:39 UTC (rev 4121)
@@ -259,6 +259,7 @@
 $labels['addcontact'] = 'Add new contact';
 $labels['editcontact'] = 'Edit contact';
 $labels['contacts'] = 'Contacts';
+$labels['contactproperties'] = 'Contact properties';
 
 $labels['edit']   = 'Edit';
 $labels['cancel'] = 'Cancel';

Modified: trunk/roundcubemail/program/steps/addressbook/show.inc
===================================================================
--- trunk/roundcubemail/program/steps/addressbook/show.inc	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/program/steps/addressbook/show.inc	2010-10-22 15:24:39 UTC (rev 4121)
@@ -25,6 +25,10 @@
   $OUTPUT->set_env('cid', $record['ID']);
 }
 
+$GROUPS = $CONTACTS->list_groups();
+$OUTPUT->set_env('groups', !empty($GROUPS));
+
+
 function rcmail_contact_details($attrib)
 {
   global $CONTACTS, $OUTPUT;
@@ -69,6 +73,37 @@
 }
 
 
+function rcmail_contact_record_groups($attrib)
+{
+  global $RCMAIL, $CONTACTS, $GROUPS;
+  
+  // check if we have a valid result
+  if (!(($result = $CONTACTS->get_result()) && ($record = $result->first())))
+    return false;
+  
+  $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
+  
+  $members = $CONTACTS->get_record_groups($record['ID']);
+  $checkbox = new html_checkbox(array('name' => '_gid[]', 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly));
+  foreach ($GROUPS as $group) {
+    $gid = $group['ID'];
+    $table->add(null, $checkbox->show($members[$gid] ? $gid : null, array('value' => $gid, 'id' => 'ff_gid' . $gid)));
+    $table->add(null, html::label('ff_gid' . $gid, Q($group['name'])));
+  }
+  
+  $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
+  $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
+  
+  $form_start = $RCMAIL->output->request_form(array('name' => "form", 'method' => "post", 'task' => $RCMAIL->task, 'action' => 'save', 'request' => 'save.'.intval($record['ID']), 'noclose' => true) + $attrib, $hiddenfields->show());
+  $form_end = !strlen($attrib['form']) ? '</form>' : '';
+
+  $RCMAIL->output->add_gui_object('editform', !empty($attrib['form']) ? $attrib['form'] : 'form');
+  
+  return $form_start . $table->show($attrib) . $form_end;
+}
+
+
 //$OUTPUT->framed = $_framed;
 $OUTPUT->add_handler('contactdetails', 'rcmail_contact_details');
+$OUTPUT->add_handler('contactgroups', 'rcmail_contact_record_groups');
 $OUTPUT->send('showcontact');

Modified: trunk/roundcubemail/skins/default/common.css
===================================================================
--- trunk/roundcubemail/skins/default/common.css	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/skins/default/common.css	2010-10-22 15:24:39 UTC (rev 4121)
@@ -843,6 +843,18 @@
   background-position: right -23px;
 }
 
+fieldset
+{
+  margin-bottom: 1em;
+  border: 1px solid #999999;
+  padding: 4px 8px 9px 8px; 
+}
+
+legend
+{
+  color: #999999;
+}
+
 fieldset.tabbed
 {
   margin-top: 22px;

Modified: trunk/roundcubemail/skins/default/settings.css
===================================================================
--- trunk/roundcubemail/skins/default/settings.css	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/skins/default/settings.css	2010-10-22 15:24:39 UTC (rev 4121)
@@ -149,18 +149,6 @@
   bottom: 0;
 }
 
-fieldset
-{
-  margin-bottom: 0.5em;
-  border: 1px solid #999999;
-  padding: 4px 8px 9px 8px; 
-}
-
-legend
-{
-  color: #999999;
-}
-
 #identities-list,
 #sectionslist
 {

Modified: trunk/roundcubemail/skins/default/templates/showcontact.html
===================================================================
--- trunk/roundcubemail/skins/default/templates/showcontact.html	2010-10-22 11:13:39 UTC (rev 4120)
+++ trunk/roundcubemail/skins/default/templates/showcontact.html	2010-10-22 15:24:39 UTC (rev 4121)
@@ -9,9 +9,20 @@
 <div id="contact-title" class="boxtitle"><roundcube:object name="contactdetails" part="name" /></div>
 
 <div id="contact-details" class="boxcontent">
-<roundcube:object name="contactdetails" />
+<fieldset>
+  <legend><roundcube:label name="contactproperties" /></legend>
+  <roundcube:object name="contactdetails" />
 
-<p><br /><roundcube:button command="edit" type="input" class="button" label="editcontact" condition="!ENV:readonly" /></p>
+  <p><br /><roundcube:button command="edit" type="input" class="button" label="editcontact" condition="!ENV:readonly" /></p>
+</fieldset>
+
+<roundcube:if condition="ENV:groups" />
+<fieldset>
+  <legend><roundcube:label name="groups" /></legend>
+  <roundcube:object name="contactgroups" />
+</fieldset>
+<roundcube:endif />
+
 </div>
 
 </body>

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


More information about the Svn mailing list