steffen: server/kolab-webadmin/kolab-webadmin/www/admin/sharedfolder index.php, NONE, 1.1 sf.php, NONE, 1.1
cvs at intevation.de
cvs at intevation.de
Mon May 17 17:24:29 CEST 2004
- Previous message: steffen: server/kolab-webadmin/kolab-webadmin/www/admin/pics erfrakon.png, NONE, 1.1 intevation_logo.png, NONE, 1.1 kdab.png, NONE, 1.1 kde.jpg, NONE, 1.1 kolab_logo.png, NONE, 1.1
- Next message: steffen: server/kolab-webadmin/kolab-webadmin/www/admin/service index.php, NONE, 1.1 service.php, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: steffen
Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/sharedfolder
In directory doto:/tmp/cvs-serv23429/kolab-webadmin/www/admin/sharedfolder
Added Files:
index.php sf.php
Log Message:
new webinterface for the kolab server
--- NEW FILE: index.php ---
<?php
/*
(c) 2004 Klarlvdalens Datakonsult AB
(c) 2003 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
(c) 2003 Martin Konold <martin.konold at erfrakon.de>
This program is Free Software under the GNU General Public License (>=v2).
Read the file COPYING that comes with this packages for details.
*/
require_once('admin/include/mysmarty.php');
require_once('admin/include/headers.php');
require_once('admin/include/authenticate.php');
$errors = array();
/**** Authentication etc. ***/
$sidx = 'sf';
if( $auth->group() != 'maintainer' && $auth->group() != 'admin') {
array_push($errors, "Error: You don't have Permissions to access this Menu");
}
require_once('admin/include/menu.php');
/**** Submenu for current page ***/
$menuitems[$sidx]['selected'] = 'selected';
/**** Extract data from LDAP ***/
// Get all entries & dynamically split the letters with growing entries
if( !$errors ) {
if (isset($_SESSION['base_dn'])) $base_dn = $_SESSION['base_dn'];
else $base_dn = 'k=kolab';
$filter = "(&(cn=*)(objectclass=sharedfolder))";
$result = ldap_search($ldap->connection, $base_dn, $filter);
if( $result ) {
$count = ldap_count_entries($ldap->connection, $result);
$title = "Manage Shared Folders ($count Folders)";
$template = 'sflistall.tpl';
ldap_sort($ldap->connection,$result,'cn');
$entry = ldap_first_entry($ldap->connection, $result);
while( $entry ) {
$attrs = ldap_get_attributes($ldap->connection, $entry);
$dn = ldap_get_dn($ldap->connection,$entry);
$cn = $attrs['cn'][0];
$deleteflag = $attrs['deleteflag'][0];
$homeserver = 'not yet implemented';
$entries[] = array( 'dn' => $dn,
'cn' => $cn,
'homeserver' => $homeserver,
'deleted' => $deleteflag );
$entry = ldap_next_entry( $ldap->connection,$entry );
}
}
}
/**** Insert into template and output ***/
$smarty =& new MySmarty();
$smarty->assign( 'errors', $errors );
$smarty->assign( 'uid', $auth->uid() );
$smarty->assign( 'group', $auth->group() );
$smarty->assign( 'page_title', $menuitems[$sidx]['title'] );
$smarty->assign( 'entries', $entries );
$smarty->assign( 'menuitems', $menuitems );
$smarty->assign( 'submenuitems',
array_key_exists('submenu',
$menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
$smarty->assign( 'maincontent', $template );
$smarty->display('page.tpl');
/*
Local variables:
mode: php
indent-tabs-mode: t
tab-width: 4
buffer-file-coding-system: utf-8
End:
*/
?>
--- NEW FILE: sf.php ---
<?php
require_once('admin/include/mysmarty.php');
require_once('admin/include/headers.php');
require_once('admin/include/authenticate.php');
require_once('admin/include/form.class.php');
/**** Authentication etc. ***/
$errors = array();
$messages = array();
$sidx = 'sf';
$contenttemplate = 'formcontainer.tpl';
$valid_actions = array('firstsave','save','modify','create','delete','kill');
if( $auth->group() != 'maintainer' && $auth->group() != 'admin') {
array_push($errors, "Error: You don't have Permissions to access this Menu");
}
require_once('admin/include/menu.php');
function fill_form_for_modify( &$form, &$ldap_object ) {
if (is_array($ldap_object['cn'])) $cn = $ldap_object['cn'][0];
else $cn = $ldap_object['cn'];
$form->entries['cn']['value'] = $cn;
if (is_array($ldap_object['userquota'])) $userquota = $ldap_object['userquota'][0];
else $userquota = $ldap_object['userquota'];
$form->entries['userquota']['value'] = $userquota;
$form->entries['action']['value'] = 'save';
//debug("got userquota=$userquota<br/>cn=$cn<br/>");
$aclcount = 0;
//var_dump( $ldap_object['acl'] );
foreach( $ldap_object['acl'] as $key => $acl ) {
if( $key === 'count' ) continue;
list($u, $p ) = split( ' ', $acl );
//debug( "u=$u, p=$p" );
$form->entries['acl_'.$aclcount] = array( 'name' => 'Permission for UID',
'type' => 'aclselect',
'user' => $u,
'perm' => $p
);
$aclcount++;
}
$form->entries['acl_'.$aclcount] = array( 'name' => 'Permission for UID',
'type' => 'aclselect',
'user' => '',
'perm' => 'all'
);
}
/**** Submenu for current page ***/
$menuitems[$sidx]['selected'] = 'selected';
$heading = '';
/**** Form/data handling ***/
if (!empty($_REQUEST['action']) &&
in_array($_REQUEST['action'],$valid_actions)) $action = trim($_REQUEST['action']);
else array_push($errors, "Error: need valid action to proceed");
$dn="";
if (!empty($_REQUEST['dn'])) $dn = trim($_REQUEST['dn']);
if (!$errors && $auth->group() != 'maintainer' && $auth->group() != 'admin')
array_push($errors, "Error: You don't have the required Permissions");
$entries = array( 'cn' => array( 'name' => 'Folder Name',
'validation' => 'notempty',
'comment' => 'Required' ),
'userquota' => array( 'name' => 'Quota Limit',
'comment' => 'KBytes (empty for unlimited)' ),
'acl_0' => array( 'name' => 'Permission for UID',
'type' => 'aclselect',
'user' => 'anyone',
'perm' => 'all' ));
$entries['action'] = array( 'name' => 'action',
'type' => 'hidden' );
if( $action == 'modify' || $action == 'delete' ) {
if( $_REQUEST['dn'] ) {
$dn = $_REQUEST['dn'];
} else {
array_push($errors, "Error: DN required for $action operation");
}
}
$form =& new KolabForm( 'vcard', 'createaddr.tpl', $entries );
if( !$errors ) {
switch( $action ) {
case 'create':
$form->entries['action']['value'] = 'firstsave';
$heading = 'Add Shared Folder';
$content = $form->outputForm();
break;
case 'firstsave':
case 'save':
if( $form->isSubmitted() ) {
if( !$form->validate() ) {
$form->setValues();
$content = $form->outputForm();
} else {
$sf_root = $_SESSION['base_dn'];
$ldap_object = array('objectClass' => 'sharedfolder');
$cn = trim($_POST['cn']);
$ldap_object['cn'] = $cn;
foreach ( array( 'userquota') as $attr) {
$count = 0;
$key = $attr;
$args = array();
while (!empty($_POST[$key])) {
$args[$count] = trim($_POST[$key]);
$count++;
$key = $attr."_".$count;
}
if ($count > 0) $ldap_object[$attr] = $args;
else if (!empty($_POST[$key])) $ldap_object[$attr] = $_POST[$key];
}
if( $ldap_object['userquota'] == '' ) unset($ldap_object['userquota']);
$aclcount = 0;
while( $_POST['user_acl_'.$aclcount] ) {
if( !empty( $_POST['user_acl_'.$aclcount] ) ) {
$ldap_object['acl'][] = $_POST['user_acl_'.$aclcount].' '.$_POST['perm_acl_'.$aclcount];
}
$aclcount++;
}
if ($action == "save") {
if (!$errors) {
if (!empty($ldap_object['cn'])) $newdn = "cn=".$ldap_object['cn'].",".$sf_root;
else $newdn = $dn;
if (strcmp($dn,$newdn) != 0) {
if (($result=ldap_read($ldap->connection,$dn,"(objectclass=*)")) &&
($entry=ldap_first_entry($ldap->connection,$result)) &&
($oldattrs=ldap_get_attributes($ldap->connection,$entry))) {
if (!ldap_add($ldap->connection,$newdn, $ldap_object)
|| !ldap_delete($ldap->connection,$dn)) {
array_push($errors, "LDAP Error: could not rename ".$dn.
" to ".$newdn." ".ldap_error($ldap->connection));
} else {
$messages[] = 'Shared folder updated';
}
$dn = $newdn;
} else array_push($errors,"LDAP Error: could not read ".$dn." ".ldap_error($ldap->connection));
} else {
if (!ldap_modify($ldap->connection, $dn, $ldap_object))
array_push($errors, "LDAP Error: could not modify object ".$dn." ".ldap_error($ldap->connection));
else $messages[] = 'Shared folder updated';
}
}
} else {
if (!$errors) {
$dn = "cn=".$ldap_object['cn'].",".$sf_root;
if ($dn && !ldap_add($ldap->connection, $dn, $ldap_object))
array_push($errors, "LDAP Error: could not add object ".$dn." ".ldap_error($ldap->connection));
else $messages[] = 'Shared folder '.$cn.' added';
}
if ($errors) {
//print("<div class=\"maintitle\"> Create New Address Book Entry </div>\n");
$form->entries['action']['value'] = 'create';
break;
}
}
$form->entries['action']['value'] = 'save';
$form->entries['dn'] = array( 'type' => 'hidden', 'value' => $dn );
$form->entries['cn']['attrs'] = 'readonly';
$heading = 'Modify Shared Folder';
fill_form_for_modify( $form, $ldap_object );
$content = $form->outputForm();
}
}
break;
case 'modify':
$result = $ldap->search( $dn, '(objectClass=sharedfolder)' );
if( $result ) {
$ldap_object = ldap_get_entries( $ldap->connection, $result );
if( $ldap_object['count'] == 1 ) {
fill_form_for_modify( $form, $ldap_object[0] );
$form->entries['action']['value'] = 'save';
$form->entries['dn'] = array( 'type' => 'hidden', 'value' => $dn );
$form->entries['cn']['attrs'] = 'readonly';
$heading = 'Modify Shared Folder';
$content = $form->outputForm();
} else {
array_push($errors, "Error: Multiple results returned for DN $dn");
}
}
break;
case 'delete':
$result = $ldap->search( $dn, '(objectClass=sharedfolder)' );
if( $result ) {
$ldap_object = ldap_get_entries( $ldap->connection, $result );
if( $ldap_object['count'] == 1 ) {
fill_form_for_modify( $form, $ldap_object[0] );
$form->entries['action']['value'] = 'kill';
foreach( $form->entries as $key => $val ) {
$form->entries[$key]['attrs'] = 'readonly';
}
$form->submittext = 'Delete';
$heading = 'Delete Shared Folder';
$content = $form->outputForm();
} else {
array_push($errors, "Error: Multiple results returned for DN $dn");
}
}
break;
case 'kill':
if (!$errors) {
$ldap_object = array();
$ldap_object['deleteflag'] = 'TRUE';
if( ldap_modify($ldap->connection, $dn, $ldap_object) ) {
$messages[] = 'Shared folder '.$_REQUEST['cn'].' marked for deletion';
$heading = 'Entry Deleted';
$contenttemplate = 'sfdeleted.tpl';
} else {
array_push($errors, "LDAP Error: could mark ".$dn." for deletion: ".ldap_error($link));
}
}
break;
}
}
/**** Insert into template and output ***/
$smarty =& new MySmarty();
$smarty->assign( 'errors', $errors );
$smarty->assign( 'heading', $heading );
$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( 'heading', $heading );
$smarty->assign( 'form', $content );
if( isset( $dn ) ) $smarty->assign( 'dn', $dn );
if( count($messages)>0) $smarty->assign( 'messages', $messages );
$smarty->assign( 'maincontent', $contenttemplate );
$smarty->display('page.tpl');
/*
Local variables:
mode: php
indent-tabs-mode: t
tab-width: 4
buffer-file-coding-system: utf-8
End:
*/
?>
- Previous message: steffen: server/kolab-webadmin/kolab-webadmin/www/admin/pics erfrakon.png, NONE, 1.1 intevation_logo.png, NONE, 1.1 kdab.png, NONE, 1.1 kde.jpg, NONE, 1.1 kolab_logo.png, NONE, 1.1
- Next message: steffen: server/kolab-webadmin/kolab-webadmin/www/admin/service index.php, NONE, 1.1 service.php, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the commits
mailing list