gunnar: server/kolab-webadmin/admin list.php,NONE,1.1

cvs at kolab.org cvs at kolab.org
Wed Aug 22 08:35:47 CEST 2007


Author: gunnar

Update of /kolabrepository/server/kolab-webadmin/admin
In directory doto:/tmp/cvs-serv828

Added Files:
	list.php 
Log Message:
Reduce all the different Kolab object lists to a single page version in order to remove all the code duplications. This is an early draft.

--- NEW FILE: list.php ---
<?php
/*  
 *  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: 1.1 $
 *
 *  ABOUT
 *  -----
 *
 *  Generate a list of Kolab object types.
 *
 */

/** Our basic webadmin class. */
require_once('Kolab/Webadmin/webadmin.class.php');

/** Read our configuration. */
require_once('../config.php');

/** Get the requested object type. */
$types = array('user',
               'domainmaintainer',
               'maintainer',
               'administrator',
               'address',
               'group',
               'sharedfolder');
$default_type = $types[0];
$type = KolabForm::getRequestVar('type', $default_type);

if (!in_array($type, $types)) {
    $type = $default_type;
 }

/** Initialize page */
$ADMIN = new KolabWebadmin($params);
$ADMIN->setSection($type);

/** Access logic */
switch($type) {
 case 'admin':
 case 'maintainer':
     $deny = !$ADMIN->isAdmin();
     break;
 case 'address':
 case 'domainmaintainer':
     $deny = !$ADMIN->isMaintainer() && 
         !$ADMIN->isAdmin();
     break;
 case 'user':
 case 'group':
 case 'sharedfolder':
     $deny = !$ADMIN->isDomainMaintainer() && 
         !$ADMIN->isMaintainer() && 
         !$ADMIN->isAdmin();
     break;
 default:
     $deny = true;
 }

/** Get the list of entries */
if($deny) {
    $ADMIN->assign('errors', array(_("Error: You don't have Permissions to access this Menu")));
} else {
    switch($type) {
    case 'admin':
        $entries = $ADMIN->getVisibleAdministrators();
        break;
    case 'address':
        $entries = $ADMIN->getVisibleAddresses();
        break;
    case 'group':
        $entries = $ADMIN->getVisibleGroups();
        break;
    case 'maintainers':
        $entries = $ADMIN->getVisibleMaintainers();
        break;
    case 'domainmaintainers':
        $entries = $ADMIN->getVisibleDomainMaintainers();
        break;
    case 'sharedfolder':
        $entries = $ADMIN->getVisibleSharedFolders();
        break;
    case 'user':
        $entries = $ADMIN->getVisibleUsers();
        break;
    }
    if (is_a($entries, 'PEAR_Error')) {
        $ADMIN->assign('errors', $entries->getMessage());
    } else {
        $ADMIN->assign('entries', $entries);
        $ADMIN->assign('type', $type);
    }
}

/** Display the page */
$ADMIN->setContent('list.tpl');
$ADMIN->render();

/*
  Local variables:
  mode: php
  indent-tabs-mode: f
  tab-width: 4
  buffer-file-coding-system: utf-8
  End:
 */
?>





More information about the commits mailing list