[Kolab-devel] [PATCH] types for shared folders

Tobias Koenig tokoe at kde.org
Tue Apr 11 15:05:31 CEST 2006


On Sun, Mar 26, 2006 at 11:37:07PM +0200, Martin Konold wrote:
> Am Dienstag, 21. März 2006 18:32 schrieb Tobias Koenig:
> 
> Hi Tobias,
Hi Martin,

sorry for the delay, had to extract the patch from all our changes to
the web frontend ;)

> I did not integrate the LDAP.pm patch because the folder annotations are 
> optional not mandatory even for shared folders and the elseif are overkill.
Ok, the new patch makes it optional.

Patches for the perl module and the webadmin frontend are attached.

Ciao,
Tobias
-- 
Separate politics from religion and economy!
The Councile of the European Union is an undemocratic and illegal institution!
-------------- next part --------------
--- admin.orig/templates/sflistall.tpl	2006-02-08 17:23:41.000000000 +0100
+++ admin.tokoe/templates/sflistall.tpl	2006-04-11 14:15:08.000000000 +0200
@@ -10,12 +10,13 @@
 
 <table class="contenttable" cellpadding="0" cellspacing="1px">
 	<tr class="contentrow">
-	<th>{tr msg="Name"}</th><th>{tr msg="Server"}</th><th colspan="2">{tr msg="Action"}</th>
+	<th>{tr msg="Name"}</th><th>{tr msg="Server"}</th><th>{tr msg="Type"}</th><th colspan="2">{tr msg="Action"}</th>
 	</tr>
 {section name=id loop=$entries}
 	<tr class="contentrow{cycle values="even,odd"}">
 	   <td class="contentcell">{$entries[id].cn|escape:"html"}</td>
 	   <td class="contentcell">{$entries[id].kolabhomeserver|escape:"html"}</td>
+	   <td class="contentcell">{$entries[id].foldertype|escape:"html"}</td>
 	{if $entries[id].deleted neq "FALSE"}
 	   <td class="actioncell" colspan="2">{tr msg="Folder deleted, awaiting cleanup..."}</td>
 	{else}
--- admin.orig/include/form.class.php	2006-02-08 17:23:41.000000000 +0100
+++ admin.tokoe/include/form.class.php	2006-04-11 14:21:59.000000000 +0200
@@ -140,6 +140,30 @@ class KolabForm {
         $str .= '<td>'.$value['comment'].'</td>';
 		$str .= '</tr>'."\n";
 		break;
+	  case 'foldertypeselect':
+		$str .= '<tr>';
+		$str .= '<td>'.$value['name'].'</td>';
+                $entries = array ( '' => _('None'), 'mail' => _('Mails'), 'task' => _('Tasks'), 'journal' => _('Journals'),
+		                     'event' => _('Events'), 'contact' => _('Contacts'), 'note' => _('Notes'));
+		if( ereg( 'readonly', $value['attrs'] ) ) {
+		  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($entries[$value['value']]).
+			'<input type="hidden" name="'.$key.'" value="'.MySmarty::htmlentities($value['value']).'" /></p></td>';
+		} else {
+		  $str .= '<td><select name="'.$key.'" '.$value['attrs'].' >'."\n";
+		  foreach ($entries as $id => $title) {
+		  	if ( $value['value'] == $id )
+				$s = 'selected';
+			else
+				$s = '';
+
+		  	$str .= '<option value="'.$id.'" '.$s.'>'.MySmarty::htmlentities($title).'</option>'."\n";
+		  }
+		  $str .= '</select>';
+		  $str .= '</td>';
+		}
+        	$str .= '<td>'.$value['comment'].'</td>';
+		$str .= '</tr>'."\n";
+		break;
       case 'aclselect': // Special Kolab entry for ACLs
 		$str .= '<tr>';
 		$str .= '<td>'.$value['name'].'</td>';
--- admin.orig/sharedfolder/index.php	2006-02-08 17:23:41.000000000 +0100
+++ admin.tokoe/sharedfolder/index.php	2006-04-11 14:26:21.000000000 +0200
@@ -46,10 +46,16 @@ if( !$errors ) {
 	  $cn = $attrs['cn'][0];
 	  $deleted = array_key_exists('kolabDeleteflag',$attrs)?$attrs['kolabDeleteflag'][0]:"FALSE";
 	  $kolabhomeserver = $attrs['kolabHomeServer'][0];
+	  
+          $folderTypeMap = array ( '' => _('None'), 'mail' => _('Mails'), 'task' => _('Tasks'), 'journal' => _('Journals'),
+		                   'event' => _('Events'), 'contact' => _('Contacts'), 'note' => _('Notes'));
+	  $folderType = $folderTypeMap[$attrs['folderType'][0]];
+
 	  $entries[] = array( 'dn' => $dn,
 						  'cn' => $cn,
 						  'kolabhomeserver' => $kolabhomeserver,
-						  'deleted' => $deleted );
+			    			  'deleted' => $deleted,
+						  'foldertype' => $folderType );
 	  $entry = ldap_next_entry( $ldap->connection,$entry );
 	}
   }
--- admin.orig/sharedfolder/sf.php	2006-02-08 17:23:41.000000000 +0100
+++ admin.tokoe/sharedfolder/sf.php	2006-04-11 14:40:17.000000000 +0200
@@ -38,6 +38,11 @@ function fill_form_for_modify( &$form, &
   if (is_array($ldap_object['kolabHomeServer'])) $kolabhomeserver = $ldap_object['kolabHomeServer'][0];
   $form->entries['kolabhomeserver']['value'] = $kolabhomeserver;
 
+  if (is_array($ldap_object['folderType']))
+	$form->entries['foldertype']['value'] = $ldap_object['folderType'][0];
+  else
+  	$form->entries['foldertype']['value'] = '';
+
   $form->entries['action']['value'] = 'save';
   //debug("got userquota=$userquota<br/>cn=$cn<br/>");
   $aclcount = 0;
@@ -123,6 +128,10 @@ $entries = array( 'cn' => array( 'name' 
 										 'validation' => 'notempty',
 										 'comment' => ($action=='create')?_('Required, non volatile'):_('Non volatile'),
 										 'value' => $_SESSION['fqdnhostname'] ),
+				  'foldertype' => array( 'name' => _('Folder Type'),
+							 'type' => 'foldertypeselect',
+							 'value' => '' ),
+
 				  'cyrus-userquota' => array( 'name' => _('Quota Limit'),
 										'comment' => _('MBytes (empty for unlimited)') ),
 				  'acl_0' => array( 'name' => _('Permission for UID/GID'),
@@ -176,6 +185,10 @@ if( !$errors ) {
 		$cn = str_replace( utf8_decode('ß'), 'ss', $cn );
 		debug("cn=$cn");
 		$ldap_object['cn'] = utf8_encode($cn);
+
+		if (!empty($_POST['foldertype']))
+		  $ldap_object['folderType'] = $_POST['foldertype'];
+
 		foreach ( array( 'cyrus-userquota') as $attr) {
 		  $count = 0;
 		  $key = $attr;
@@ -262,7 +275,11 @@ if( !$errors ) {
 	  $form->entries['action']['value'] = 'save';
 	  $form->entries['dn'] = array( 'type' => 'hidden', 'value' => $dn );
 	  $form->entries['cn']['attrs'] = 'readonly';
+	  $form->entries['cn']['comment'] = '';
 	  $form->entries['kolabhomeserver']['attrs'] = 'readonly';
+	  $form->entries['kolabhomeserver']['comment'] = '';
+          $form->entries['foldertype']['attrs'] = 'readonly';
+          $form->entries['foldertype']['comment'] = '';
 	  $heading = _('Modify Shared Folder');
 	  $content = $form->outputForm();
 	} else {
@@ -276,6 +293,7 @@ if( !$errors ) {
 	  $form->entries['action']['value'] = 'kill';
 	  foreach( $form->entries as $key => $val ) {
 		$form->entries[$key]['attrs'] = 'readonly';
+		$form->entries[$key]['comment'] = '';
 	  }
 	  $form->submittext = _('Delete');
 	  $heading = _('Delete Shared Folder');
-------------- next part --------------
--- LDAP.pm.orig	2005-07-19 03:18:21.000000000 +0200
+++ LDAP.pm.tokoe	2006-04-11 14:54:48.000000000 +0200
@@ -304,6 +312,13 @@ sub createObject
             # We have a object that we have no previous record of, so create everything
             if ($sync) { $newuid_db{$guid} = $uid; } else { $uid_db{$guid} = $uid; }
             Kolab::Cyrus::createMailbox($cyrus, $uid, ($p eq 'sf' ? 1 : 0));
+	      if( $p eq 'sf' ){
+    		my $foldertype = lc($object->get_value('foldertype'));
+
+		if ( $foldertype ne '' ){
+		  Kolab::Cyrus::setFolderType($cyrus,$uid,1,$foldertype);
+		}
+	      }
 	    if( $p ne 'sf' && !$islocal ) {
 	      # Hide user mailboxes on other servers
 	      Kolab::Cyrus::setACL($cyrus,$uid,0, ["$uid rswipcda"]);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
URL: <http://lists.kolab.org/pipermail/devel/attachments/20060411/30ae2e9c/attachment.sig>


More information about the devel mailing list