gunnar: server/kolab-webadmin/admin/user deliver.php, 1.1, 1.2 forward.php, 1.1, 1.2 index.php, 1.1, 1.2 vacation.php, 1.1, 1.2
cvs at kolab.org
cvs at kolab.org
Mon Aug 20 11:43:34 CEST 2007
- Previous message: gunnar: server/kolab-webadmin/admin index.php, 1.2, 1.3 admin.php, 1.1, NONE mysmarty.php, 1.1, NONE
- Next message: gunnar: server/php-kolab/Kolab_Webadmin/Webadmin sieveutils.class.php, 1.2, 1.3 user.class.php, 1.1, 1.2 webadmin.class.php, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: gunnar
Update of /kolabrepository/server/kolab-webadmin/admin/user
In directory doto:/tmp/cvs-serv12727/user
Modified Files:
deliver.php forward.php index.php vacation.php
Log Message:
Started restructuring the users part of the kolab web admin frontend.
Index: deliver.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/admin/user/deliver.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- deliver.php 17 Aug 2007 08:51:26 -0000 1.1
+++ deliver.php 20 Aug 2007 09:43:32 -0000 1.2
@@ -1,108 +1,86 @@
<?php
-/*
- * Copyright (c) 2004 Klarälvdalens Datakonsult AB
+/*
+ * COPYRIGHT
+ * ---------
*
- * Written by Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
+ * See ../AUTHORS file
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2, or
+ *
+ * LICENSE
+ * -------
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Revision$
+ *
+ * ABOUT
+ * -----
+ *
+ * Allow a user to set a different inbox.
*
- * You can view the GNU General Public License, online, at the GNU
- * Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
*/
-require_once('../mysmarty.php');
-require_once 'Kolab/Webadmin/sieveutils.class.php';
-
-require_once('Net/Sieve.php');
-
-// Funny multiline string escaping in Sieve
-function dotstuff( $str ) {
- return str_replace( "\n.", "\n..", $str );
-}
+/** Our basic webadmin class. */
+require_once('Kolab/Webadmin/webadmin.class.php');
-function undotstuff( $str ) {
- return str_replace( "\n..", "\n.", $str );
-}
+/** Read our configuration. */
+require_once('../config.php');
+/** Initialize variables */
$errors = array();
-/**** Authentication etc. ***/
-$sidx = 'user';
-
-require_once('Kolab/Webadmin/menu.php');
-
-/**** Submenu for current page ***/
-$menuitems[$sidx]['selected'] = 'selected';
-
-/**** Sieve handling ***/
-// this is the name KDE client stores - so we can also change the setting from KDE client
-$scriptname = "kolab-deliver.siv";
-if( !$errors ) {
- $obj = $ldap->read( $auth->dn() );
- $sieve =& new Net_Sieve( $auth->uid(), $auth->password(), $obj['kolabHomeServer'][0] );
-
- // Update sieve script on server in case we have submit data
- if( $_REQUEST['submit'] ) {
- $inbox = trim($_REQUEST['inbox']);
- $active = isset($_REQUEST['active']);
-
- $script =
- "require \"fileinto\";\r\nif header :contains [\"X-Kolab-Scheduling-Message\"] [\"FALSE\"] {\r\nfileinto \"INBOX/$inbox\";\r\n}\r\n";
-
- if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
- $errors[] = $res->getMessage();
- $errors[] = _('Script was:');
- $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
- }
- if( !$active && $sieve->getActive() === $scriptname ) {
- $sieve->setActive( '' );
- }
+$ADMIN = new KolabWebadmin($params);
+$ADMIN->setSection('user');
- if( !$errors ) {
- if( $active ) $messages[] = sprintf(_("Delivery to '%s' successfully activated"), $inbox);
- else $messages[] = sprintf(_("Delivery to '%s' successfully deactivated"), $inbox);
- }
- }
+/** Get the request variables */
+$submit = KolabForm::getRequestVar('submit');
+$inbox = trim( KolabForm::getRequestVar('inbox'));
+$active = KolabForm::getRequestVar('active');
- $scripts = $sieve->listScripts();
- $inbox = false;
- if( in_array( $scriptname, $scripts ) ) {
- // Fetch script data from server
- $script = $sieve->getScript($scriptname);
- $inbox = SieveUtils::getDeliverFolder( $script );
- }
- if( $inbox === false ) $inbox = 'Inbox';
- $active = ( $sieve->getActive() === $scriptname );
+/**** Page logic ***/
+$sieve = $ADMIN->getSieve();
+if( $submit ) {
+ $result = $sieve->storeDeliverSieve($inbox, $active);
+ if (is_a($result, 'PEAR_Error')) {
+ $errors[] = $result->getMessage();
+ $errors[] = 'Script was:';
+ $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
+ } else {
+ if ( $active ) {
+ $messages[] = sprintf(_("Delivery to '%s' successfully activated"),
+ $inbox);
+ } else {
+ $messages[] = sprintf(_("Delivery to '%s' successfully deactivated"),
+ $inbox);
+ }
+ }
}
+($inbox, $active) = $sieve->getDeliverSieve();
/**** Insert into template and output ***/
-$smarty = new MySmarty();
-$smarty->assign( 'errors', $errors );
-$smarty->assign( 'messages', $messages );
-$smarty->assign( 'uid', $auth->uid() );
-$smarty->assign( 'group', $auth->group() );
-$smarty->assign( 'page_title', $menuitems[$sidx]['title'] );
-$smarty->assign( 'menuitems', $menuitems );
-$smarty->assign( 'submenuitems',
- array_key_exists('submenu',
- $menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
-$smarty->assign( 'active', $active );
-$smarty->assign( 'inbox', $inbox );
-$smarty->assign( 'maincontent', 'deliver.tpl' );
-$smarty->display('page.tpl');
+$ADMIN->assign( 'errors', $errors );
+$ADMIN->assign( 'messages', $messages );
+$ADMIN->assign( 'active', $active );
+$ADMIN->assign( 'inbox', $inbox );
+$ADMIN->setContent( 'deliver.tpl' );
+$ADMIN->render();
/*
Local variables:
mode: php
- indent-tabs-mode: t
+ indent-tabs-mode: f
tab-width: 4
buffer-file-coding-system: utf-8
End:
Index: forward.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/admin/user/forward.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- forward.php 17 Aug 2007 08:51:26 -0000 1.1
+++ forward.php 20 Aug 2007 09:43:32 -0000 1.2
@@ -1,114 +1,90 @@
<?php
-/*
- * Copyright (c) 2004 Klarälvdalens Datakonsult AB
+/*
+ * COPYRIGHT
+ * ---------
*
- * Written by Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
+ * See ../AUTHORS file
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2, or
+ *
+ * LICENSE
+ * -------
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Revision$
+ *
+ * ABOUT
+ * -----
+ *
+ * Allow users to set a forwarding address.
*
- * You can view the GNU General Public License, online, at the GNU
- * Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
*/
-require_once('../mysmarty.php');
-require_once 'Kolab/Webadmin/sieveutils.class.php';
-
-require_once('Net/Sieve.php');
-
-// Funny multiline string escaping in Sieve
-function dotstuff( $str ) {
- return str_replace( "\n.", "\n..", $str );
-}
+/** Our basic webadmin class. */
+require_once('Kolab/Webadmin/webadmin.class.php');
-function undotstuff( $str ) {
- return str_replace( "\n..", "\n.", $str );
-}
+/** Read our configuration. */
+require_once('../config.php');
+/** Initialize variables */
$errors = array();
-/**** Authentication etc. ***/
-$sidx = 'user';
-
-require_once('Kolab/Webadmin/menu.php');
-
-/**** Submenu for current page ***/
-$menuitems[$sidx]['selected'] = 'selected';
+$ADMIN = new KolabWebadmin($params);
+$ADMIN->setSection('user');
-/**** Sieve handling ***/
-// this is the name KDE client stores - so we can also change the setting from KDE client
-$scriptname = "kolab-forward.siv";
-if( !$errors ) {
- $obj = $ldap->read( $auth->dn() );
- $sieve =& new Net_Sieve( $auth->uid(), $auth->password(), $obj['kolabHomeServer'][0] );
-
- // Update sieve script on server in case we have submit data
- if( $_REQUEST['submit'] ) {
- $address = trim($_REQUEST['address']);
- $keep = isset($_REQUEST['keep']);
- $active = isset($_REQUEST['active']);
+/** Get the request variables */
+$submit = KolabForm::getRequestVar('submit');
+$address = trim(KolabForm::getRequestVar('address'));
+$keep = KolabForm::getRequestVar('keep');
+$active = KolabForm::getRequestVar('active');
+/**** Page logic ***/
+$sieve = $ADMIN->getSieve();
+if( $submit ) {
if( empty( $address ) ) {
- $errors[] = _('Please enter an email address');
+ $errors[] = _('Please enter an email address');
} else {
- $script =
- "require \"fileinto\";\r\nredirect \"".addslashes($address)."\";".($keep?" keep;":"");
- if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
- $errors[] = $res->getMessage();
- $errors[] = _('Script was:');
- $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
- }
- if( !$active && $sieve->getActive() === $scriptname ) {
- $sieve->setActive( '' );
- }
-
- if( !$errors ) {
- if( $active ) $messages[] = sprintf(_("Forwarding to '%s' successfully activated"), $address);
- else $messages[] = sprintf(_("Forwarding to '%s' successfully deactivated"), $address);
- }
+ $result = $sieve->storeForwardSieve($address, $keep, $active);
+ if (is_a($result, 'PEAR_Error')) {
+ $errors[] = $result->getMessage();
+ $errors[] = _('Script was:');
+ $errors[] = '<pre>' . $ADMIN->htmlentities($script) . '</pre>';
+ } else {
+ if( $active ) {
+ $messages[] = sprintf(_("Forwarding to '%s' successfully activated"), $address);
+ } else {
+ $messages[] = sprintf(_("Forwarding to '%s' successfully deactivated"), $address);
+ }
+ }
}
- }
-
- $scripts = $sieve->listScripts();
- if( in_array( $scriptname, $scripts ) ) {
- $script = $sieve->getScript($scriptname);
- $address = SieveUtils::getForwardAddress( $script );
- $keep = SieveUtils::getKeepOnServer( $script );
- } else {
- $address = '';
- $keep = true;
- }
- $active = ( $sieve->getActive() === $scriptname );
-}
+ }
+($address, $keep, $active) = $sieve->getForwardSieve();
/**** Insert into template and output ***/
-$smarty = new MySmarty();
-$smarty->assign( 'errors', $errors );
-$smarty->assign( 'messages', $messages );
-$smarty->assign( 'uid', $auth->uid() );
-$smarty->assign( 'group', $auth->group() );
-$smarty->assign( 'page_title', $menuitems[$sidx]['title'] );
-$smarty->assign( 'menuitems', $menuitems );
-$smarty->assign( 'submenuitems',
- array_key_exists('submenu',
- $menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
-$smarty->assign( 'active', $active );
-$smarty->assign( 'keep', $keep );
-$smarty->assign( 'address', $address );
-$smarty->assign( 'maincontent', 'forward.tpl' );
-$smarty->display('page.tpl');
+$ADMIN->assign( 'errors', $errors );
+$ADMIN->assign( 'messages', $messages );
+$ADMIN->assign( 'active', $active );
+$ADMIN->assign( 'keep', $keep );
+$ADMIN->assign( 'address', $address );
+$ADMIN->setContent( 'forward.tpl' );
+$ADMIN->render();
/*
Local variables:
mode: php
- indent-tabs-mode: t
+ indent-tabs-mode: f
tab-width: 4
buffer-file-coding-system: utf-8
End:
Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/admin/user/index.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- index.php 17 Aug 2007 08:51:26 -0000 1.1
+++ index.php 20 Aug 2007 09:43:32 -0000 1.2
@@ -1,204 +1,120 @@
<?php
-/*
- * Copyright (c) 2004-2005 Klarälvdalens Datakonsult AB
+/*
+ * COPYRIGHT
+ * ---------
*
- * Written by Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
+ * See ../AUTHORS file
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2, or
+ *
+ * LICENSE
+ * -------
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Revision$
+ *
+ * ABOUT
+ * -----
+ *
+ * Generate a list of users.
*
- * You can view the GNU General Public License, online, at the GNU
- * Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
*/
-require_once('../mysmarty.php');
-$smarty = new MySmarty();
-
-$errors = array();
-
-/**** Authentication etc. ***/
-$sidx = 'user';
+/** Our basic webadmin class. */
+require_once('Kolab/Webadmin/webadmin.class.php');
-if( $smarty->auth->group() != 'maintainer' && $smarty->auth->group() != 'admin' && $smarty->auth->group() != 'domain-maintainer' ) {
- debug("auth->group=".$smarty->auth->group());
- array_push($errors, _("Error: You don't have Permissions to access this Menu"));
-}
+/** Read our configuration. */
+require_once('../config.php');
-require_once('Kolab/Webadmin/menu.php');
+/** Initialize variables */
+$errors = array();
+$entries = array();
+$sublist = '';
-/**** Submenu for current page ***/
-$smarty->menuitems[$sidx]['selected'] = 'selected';
+$ADMIN = new KolabWebadmin($params);
+$ADMIN->setSection('user');
-/**** Extract data from LDAP ***/
+/** Access logic */
+if( !$ADMIN->isMaintainer() &&
+ !$ADMIN->isAdmin() &&
+ !$ADMIN->isDomainMaintainer() ) {
+ array_push($errors,
+ _("Error: You don't have Permissions to access this Menu"));
+} else {
+ /** Get the request variables */
+ $alphaselect = KolabForm::getRequestVar('alphaselect', '[A-F]');
+ $page = KolabForm::getRequestVar('page', '1');
+ $filterattr = KolabForm::getRequestVar('filterattr');
+ $filtertype = KolabForm::getRequestVar('filtertype');
+ $filtervalue = KolabForm::getRequestVar('filtervalue');
+ $alphalimit = KolabForm::getRequestVar('alphalimit');
+ $alphagroup = KolabForm::getRequestVar('alphagroup');
-// read selector for register display
-if (isset($HTTP_GET_VARS['alphaselect'])) $alphaselect = $HTTP_GET_VARS['alphaselect'];
-else $alphaselect = "[A-F]";
-if (isset($HTTP_GET_VARS['page'])) $page = $HTTP_GET_VARS['page'];
-else $page = "1";
+ if ( !empty($alphalimit) ) {
+ $sublist = $a[0];
+ }
-// Get all entries & dynamically split the letters with growing entries
-$entries = array();
-if( !$errors ) {
- if (isset($_SESSION['base_dn'])) $base_dn = $_SESSION['base_dn'];
- else $base_dn = 'k=kolab';
+ /** Extract data from LDAP */
+ $users = $ADMIN->getUserClass();
+ $entries = $users->getVisibleUsers($dn, $filterattr,
+ $filtertype, $filtervalue,
+ $alphalimit, $alphagroup);
+}
- $privmembers = array_merge( (array)$smarty->ldap->groupMembers( "cn=internal,$base_dn", 'admin' ),
- (array)$smarty->ldap->groupMembers( "cn=internal,$base_dn", 'maintainer' ) );
+$count = count($entries);
- $userfilter = "cn=*";
- $filterattr = KolabForm::getRequestVar('filterattr');
- $filtertype = KolabForm::getRequestVar('filtertype');
- $filtervalue = KolabForm::getRequestVar('filtervalue');
- if( !in_array( $filterattr, array( 'cn', 'uid', 'mail' ) ) ) $filterattr = 'cn';
- if( isset( $filtervalue ) && !empty( $filtervalue ) ) {
- switch( $filtertype ) {
- case 'contains': // contains
- $userfilter = "$filterattr=*".$smarty->ldap->escape($filtervalue).'*';
- break;
- case 'is': // is
- $userfilter = "$filterattr=".$smarty->ldap->escape($filtervalue);
- break;
- case 'begins': // begins with
- $userfilter = "$filterattr=".$smarty->ldap->escape($filtervalue).'*';
- break;
- case 'ends': // ends with
- $userfilter = "$filterattr=*".$smarty->ldap->escape($filtervalue);
- break;
- }
- }
- $alphalimit = '';
- $sublist = '';
- $alphagroup = '';
- // Disabled for now
- if( false && isset($_REQUEST['alphalimit']) ) {
- $ala='sn'; // alpha limit attibute
- $a = $_REQUEST['alphalimit'];
- if( $a == "other" ) {
- $alphalimit = "(|($ala=æ*)($ala=ø*)($ala=å*)($ala=ä*)($ala=ö*)($ala=ü*)($ala=0*)($ala=1*)($ala=2*)($ala=3*)($ala=4*)($ala=5*)($ala=6*)($ala=7*)($ala=8*)($ala=9*))";
- } else if( !empty($a)) {
- $alphalimit ="($ala=$a*)";
- $sublist = $a[0];
- }
- } else if( isset( $_REQUEST['alphagroup']) ) {
- $ala='sn'; // alpha limit attibute
- $alphagroup = $_REQUEST['alphagroup'];
- switch( $_REQUEST['alphagroup'] ) {
- case 'a': $alphalimit = "(|($ala=a*)($ala=b*)($ala=c*)($ala=d*)($ala=e*)($ala=f*))"; break;
- case 'g': $alphalimit = "(|($ala=g*)($ala=h*)($ala=i*)($ala=j*)($ala=k*)($ala=l*))"; break;
- case 'm': $alphalimit = "(|($ala=m*)($ala=n*)($ala=o*)($ala=p*)($ala=q*)($ala=r*))"; break;
- case 's': $alphalimit = "(|($ala=s*)($ala=t*)($ala=u*)($ala=v*)($ala=w*)($ala=x*)($ala=y*)($ala=z*))"; break;
- case 'other': $alphalimit = "(|($ala=æ*)($ala=ø*)($ala=å*)($ala=ä*)($ala=ö*)($ala=ü*)($ala=0*)($ala=1*)($ala=2*)($ala=3*)($ala=4*)($ala=5*)($ala=6*)($ala=7*)($ala=8*)($ala=9*))"; break;
- default: $alphalimit = '';
- }
- }
- $domains = $smarty->ldap->domainsForMaintainerDn($smarty->auth->dn());
- #debug_var_dump($domains);
- if( is_array($domains) ) {
- $domainfilter='';
- foreach( $domains as $dom ) {
- $domainfilter .= '(mail=*@'.$smarty->ldap->escape($dom).')';
- }
- if( $domainfilter ) $domainfilter = "(|$domainfilter)";
- } else {
- $domainfilter= "";
- }
- $filter = "(&($userfilter)$domainfilter$alphalimit(objectclass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))";
- debug("filter is \"$filter\"");
- $result = ldap_search($smarty->ldap->connection, $base_dn, $filter, array( 'uid', 'mail', 'sn', 'cn', 'kolabDeleteflag' ));
+$title = sprintf(_("Manage Email User (%d Users)"), $count);
- if( $result ) {
- $count = ldap_count_entries($smarty->ldap->connection, $result);
- $title = sprintf(_("Manage Email User (%d Users)"), $count);
- // if there are more than 2000 entries, split in 26 categories for every letter,
- // or if more than 50, put in groups, or else just show all.
- if ( $count > 2000) {
- // ... TODO
- //$template = 'userlistalpha.tpl';
- $template = 'userlisterror.tpl';
- } else if( false && $count > 50 ) {
- // ... TODO
- $template = 'userlistgroup.tpl';
- } else {
- $template = 'userlistall.tpl';
- $starttime = getmicrotime();
- ldap_sort($smarty->ldap->connection,$result,'sn');
- $endtime = getmicrotime();
- //print "sorting took ".($endtime-$starttime)."<br/>";
- $entry = ldap_first_entry($smarty->ldap->connection, $result);
- while( $entry ) {
- $attrs = ldap_get_attributes($smarty->ldap->connection, $entry);
- $dn = ldap_get_dn($smarty->ldap->connection,$entry);
- $deleted = array_key_exists('kolabDeleteflag',$attrs)?$attrs['kolabDeleteflag'][0]:"FALSE";
- $uid = $attrs['uid'][0];
- $mail = $attrs['mail'][0];
- $sn = $attrs['sn'][0];
- $cn = $attrs['cn'][0];
- $a = strlen($sn);
- $b = strlen($cn);
- $fn = substr($cn, 0, $b - $a);
- $dncomp = split( ',', $dn );
- if( in_array('cn=groups',$dncomp) ) {
- $type = 'G';
- } else if( in_array('cn=resources',$dncomp) ) {
- $type = 'R';
- } else if( in_array('cn=internal',$dncomp) ) {
- $type = 'I';
- } else {
- $type = 'U';
- }
+// if there are more than 2000 entries, split in 26 categories for every letter,
+// or if more than 50, put in groups, or else just show all.
+if ( $count > 2000) {
+ // ... TODO
+ //$template = 'userlistalpha.tpl';
+ $template = 'userlisterror.tpl';
+ } else if( false && $count > 50 ) {
+ // ... TODO
+ $template = 'userlistgroup.tpl';
+ } else {
+ $template = 'userlistall.tpl';
+ }
- // skip admins and maintainers
- if( !array_key_exists( $dn, $privmembers ) ) {
- $entries[] = array( 'dn' => $dn,
- 'sn' => $sn,
- 'fn' => $fn,
- 'type' => $type,
- 'mail' => $mail,
- 'uid' => $uid,
- 'deleted' => $deleted );
- }
- $entry = ldap_next_entry( $smarty->ldap->connection,$entry );
- }
- }
- }
-}
-/**** Insert into template and output ***/
-$smarty->assign( 'errors', $errors );
-$smarty->assign( 'page_title', $smarty->menuitems[$sidx]['title'] );
-$smarty->assign( 'self_url', $_SERVER['PHP_SELF'] );
-$smarty->assign( 'alphagroup', $alphagroup );
-$smarty->assign( 'filterattrs', array( 'cn' => _('Name'),
+/** Insert into template and output */
+$ADMIN->assign( 'errors', $errors );
+$ADMIN->assign( 'self_url', $_SERVER['PHP_SELF'] );
+$ADMIN->assign( 'alphagroup', $alphagroup );
+$ADMIN->assign( 'filterattrs', array( 'cn' => _('Name'),
'mail' => _('Email'),
'uid' => _('UID') ) );
-$smarty->assign( 'filtertypes', array( 'contains' => _('contains'),
+$ADMIN->assign( 'filtertypes', array( 'contains' => _('contains'),
'is' => _('is'),
'begins' => _('begins with'),
'ends' => _('ends with') ) );
-$smarty->assign( 'filterattr', $filterattr );
-$smarty->assign( 'filtertype', $filtertype );
-$smarty->assign( 'filtervalue', $filtervalue );
+$ADMIN->assign( 'filterattr', $filterattr );
+$ADMIN->assign( 'filtertype', $filtertype );
+$ADMIN->assign( 'filtervalue', $filtervalue );
-$smarty->assign( 'sublist', $sublist );
-$smarty->assign( 'entries', $entries );
-$smarty->assign( 'submenuitems',
- array_key_exists('submenu',
- $smarty->menuitems[$sidx])?$smarty->menuitems[$sidx]['submenu']:array() );
-$smarty->assign( 'maincontent', $template );
-$smarty->display('page.tpl');
+$ADMIN->assign( 'sublist', $sublist );
+$ADMIN->assign( 'entries', $entries );
+$ADMIN->setContent($template);
+$ADMIN->render();
/*
Local variables:
mode: php
- indent-tabs-mode: t
+ indent-tabs-mode: f
tab-width: 4
buffer-file-coding-system: utf-8
End:
Index: vacation.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/admin/user/vacation.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- vacation.php 17 Aug 2007 08:51:26 -0000 1.1
+++ vacation.php 20 Aug 2007 09:43:32 -0000 1.2
@@ -1,124 +1,105 @@
<?php
-/*
- (c) 2004 Klarälvdalens Datakonsult AB
-
- This program is Free Software under the GNU General Public License (>=v2).
- Read the file COPYING that comes with this packages for details.
-*/
+/*
+ * COPYRIGHT
+ * ---------
+ *
+ * See ../AUTHORS file
+ *
+ *
+ * LICENSE
+ * -------
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Revision$
+ *
+ * ABOUT
+ * -----
+ *
+ * Allow users to set a vacation reply.
+ *
+ */
-require_once('../mysmarty.php');
-require_once 'Kolab/Webadmin/sieveutils.class.php';
+/** Our basic webadmin class. */
+require_once('Kolab/Webadmin/webadmin.class.php');
-require_once('Net/Sieve.php');
+/** Read our configuration. */
+require_once('../config.php');
+/** Initialize variables */
$errors = array();
-/**** Authentication etc. ***/
-$sidx = 'user';
-
-require_once('Kolab/Webadmin/menu.php');
-
-/**** Submenu for current page ***/
-$menuitems[$sidx]['selected'] = 'selected';
-
-/**** Sieve handling ***/
-$scriptname = 'kolab-vacation.siv';
-if( !$errors ) {
- $obj = $ldap->read( $auth->dn() );
- $sieve =& new Net_Sieve( $auth->uid(), $auth->password(), $obj['kolabHomeServer'][0] );
- //$sieve->setDebug(true);
-
- // Update sieve script on server in case we have submit data
- if( $_REQUEST['submit'] ) {
- $addresses = array_unique( array_filter( array_map( 'trim', preg_split( '/\n/', $_REQUEST['addresses'] ) ), 'strlen') );
- $maildomain = trim( $_REQUEST['maildomain'] );
- $reacttospam = isset( $_REQUEST['reacttospam'] );
- $days = $_REQUEST['days'];
- if( $days < 1 ) {
- $errors[] = _('Days must be at least one');
- } else {
- $script =
- "require \"vacation\";\r\n\r\n".
- (!empty($maildomain)?"if not address :domain :contains \"From\" \"".$maildomain."\" { keep; stop; }\r\n":"").
- ($reacttospam?"if header :contains \"X-Spam-Flag\" \"YES\" { keep; stop; }\r\n":"").
- "vacation :addresses [ \"".join('", "', $addresses )."\" ] :days ".
- $_REQUEST['days']." text:\r\n".
- SieveUtils::dotstuff(trim($_REQUEST['text']))."\r\n.\r\n;\r\n\r\n";
- $active = isset($_REQUEST['active']);
-
- if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
- $errors[] = $res->getMessage();
- $errors[] = 'Script was:';
- $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
- }
- if( !$active && $sieve->getActive() === $scriptname ) {
- $sieve->setActive( '' );
- }
- }
+$ADMIN = new KolabWebadmin($params);
+$ADMIN->setSection('user');
- if( !$errors ) {
- if( $active ) $messages[] = _('Vacation message successfully activated');
- else $messages[] = _('Vacation message successfully deactivated');
- }
- }
+/** Get the request variables */
+$submit = KolabForm::getRequestVar('submit');
+$addresses = array_unique(
+ array_filter(
+ array_map('trim',
+ preg_split(
+ '/\n/',
+ KolabForm::getRequestVar('addresses')
+ ),
+ 'strlen'
+ )
+ )
+);
+$maildomain = trim( KolabForm::getRequestVar('maildomain'));
+$reacttospam = KolabForm::getRequestVar('reacttospam');
+$days = KolabForm::getRequestVar('days');
+$active = KolabForm::getRequestVar('active');
- $addresses = $days = $text = false;
- $scripts = $sieve->listScripts();
- if( in_array( $scriptname, $scripts ) ) {
- $script = $sieve->getScript($scriptname);
- $maildomain = SieveUtils::getMailDomain( $script );
- $reacttospam = SieveUtils::getReactToSpam( $script );
- debug("reacttospam=".($reacttospam?"true":"false"));
- $addresses = SieveUtils::getVacationAddresses( $script );
- $days = SieveUtils::getVacationDays( $script );
- $text = SieveUtils::getVacationText( $script );
- } else $reacttospam = true;
- if( $addresses === false ) {
- $object = $ldap->read( $auth->dn() );
- $addresses = array_merge( (array)$object['mail'], (array)$object['alias'] );
- }
- if( $days === false || $days < 1 ) $days = 7;
- if( $text === false ) {
- $date = strftime(_('%x'));
- $text = sprintf(
- _("I am out of office until %s.\r\n").
- _("In urgent cases, please contact Mrs. <vacation replacement>\r\n\r\n").
- _("email: <email address of vacation replacement>\r\n").
- _("phone: +49 711 1111 11\r\n").
- _("fax.: +49 711 1111 12\r\n\r\n").
- _("Yours sincerely,\r\n").
- _("-- \r\n").
- _("<enter your name and email address here>"),
- $date);
- }
- $active = ( $sieve->getActive() === $scriptname );
+/**** Page logic ***/
+$sieve = $ADMIN->getSieve();
+if( $submit ) {
+ if( $days < 1 ) {
+ $errors[] = _('Days must be at least one');
+ } else {
+ $result = $sieve->storeVacationSieve($addresses, $maildomain, $reacttospam, $days, $active);
+ if (is_a($result, 'PEAR_Error')) {
+ $errors[] = $result->getMessage();
+ $errors[] = 'Script was:';
+ $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
+ } else {
+ if ( $active ) {
+ $messages[] = _('Vacation message successfully activated');
+ } else {
+ $messages[] = _('Vacation message successfully deactivated');
+ }
+ }
+ }
}
+($addresses, $maildomain, $reacttospam, $days, $active) = $sieve->getVacationSieve();
/**** Insert into template and output ***/
-$smarty = new MySmarty();
-$smarty->assign( 'errors', $errors );
-$smarty->assign( 'messages', $messages );
-$smarty->assign( 'uid', $auth->uid() );
-$smarty->assign( 'group', $auth->group() );
-$smarty->assign( 'page_title', $menuitems[$sidx]['title'] );
-$smarty->assign( 'menuitems', $menuitems );
-$smarty->assign( 'submenuitems',
- array_key_exists('submenu',
- $menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
-$smarty->assign( 'active', $active );
-$smarty->assign( 'text', $text );
-$smarty->assign( 'addresses', $addresses );
-$smarty->assign( 'maildomain', $maildomain );
-$smarty->assign( 'reacttospam', $reacttospam );
-$smarty->assign( 'days', $days );
-$smarty->assign( 'inbox', $inbox );
-$smarty->assign( 'maincontent', 'vacation.tpl' );
-$smarty->display('page.tpl');
+$ADMIN->assign( 'errors', $errors );
+$ADMIN->assign( 'messages', $messages );
+$ADMIN->assign( 'active', $active );
+$ADMIN->assign( 'text', $text );
+$ADMIN->assign( 'addresses', $addresses );
+$ADMIN->assign( 'maildomain', $maildomain );
+$ADMIN->assign( 'reacttospam', $reacttospam );
+$ADMIN->assign( 'days', $days );
+$ADMIN->setContent( 'vacation.tpl' );
+$ADMIN->render();
/*
Local variables:
mode: php
- indent-tabs-mode: t
+ indent-tabs-mode: f
tab-width: 4
buffer-file-coding-system: utf-8
End:
- Previous message: gunnar: server/kolab-webadmin/admin index.php, 1.2, 1.3 admin.php, 1.1, NONE mysmarty.php, 1.1, NONE
- Next message: gunnar: server/php-kolab/Kolab_Webadmin/Webadmin sieveutils.class.php, 1.2, 1.3 user.class.php, 1.1, 1.2 webadmin.class.php, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the commits
mailing list