gunnar: server/kolab-webadmin/admin admin.php, NONE, 1.1 config.php, NONE, 1.1 index.php, NONE, 1.1 logout.php, NONE, 1.1 mysmarty.php, NONE, 1.1 print.css, NONE, 1.1 style.css, NONE, 1.1

cvs at kolab.org cvs at kolab.org
Fri Aug 17 10:51:28 CEST 2007


Author: gunnar

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

Added Files:
	admin.php config.php index.php logout.php mysmarty.php 
	print.css style.css 
Log Message:
The web admin will be restructured to get a better distinction between the library and the web application parts. This currently a draft but I wanted to add this early into CVS so that the following changes will be visible.

--- NEW FILE: admin.php ---
<?php
/*  
 *  COPYRIGHT
 *  ---------
 *
 *  See docs/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
 *  -----
 *
 *  Main Kolab admin object.
 *
 */

require_once('config.php');
require_once('Kolab/Webadmin/locale.php');
require_once('Kolab/Webadmin/form.class.php');
require_once('Kolab/Webadmin/auth.class.php');
require_once('Kolab/Webadmin/ldap.class.php');
require_once('Kolab/Webadmin/menu.php');

require_once('smarty/Smarty.class.php');

class KolabWebadmin extends Smarty {

    function KolabWebadmin() 
    {
        global $params;

	global $language;

	session_start();

	$this->Smarty();

	$basedir = dirname(__FILE__) . '/';
	$this->template_dir = $basedir.'templates/';
	$this->compile_dir = $basedir.'templates_c/';
	$this->config_dir = $basedir.'configs/';
	$this->cache_dir = $basedir.'cache/';
	// Added for i18n management (Romain 05-03-03)
	$this->register_function("tr", "translate");

	$this->assign( 'topdir', $params['topdir'] );
	$this->assign( 'prefix', $params['webserver_web_prefix'] );

	$this->assign( 'self_url', $_SERVER['REQUEST_URI'] );

	$cleanurl = preg_replace('/(\?|&)lang=(.*)(&|$)/', '', $_SERVER['REQUEST_URI']);
	$this->assign( 'lang_url', 
				   strpos($cleanurl,'?')===false?
				   ($cleanurl.'?lang='):
				   ($cleanurl.'&lang=') );
	
	// If you add a translation, 
	// add the new language here
	$this->assign( 'currentlang', $language );
	$this->assign( 'languages', array( 
									  array( 'name' => 'Deutsch',
											 'code' => 'de_DE' ),
									  array( 'name' => 'English',
											 'code' => 'en_US' ),
									  array( 'name' => 'Français',
											 'code' => 'fr_FR' ),
									  array( 'name' => 'Italiano',
											 'code' => 'it_IT' ),
									  array( 'name' => 'Nederlands',
											 'code' => 'nl_NL' ),
									  array( 'name' => 'Español',
											 'code' => 'es_ES' ),
									  ));

        $this->ldap =& new KolabLDAP($params);
        $this->auth =& new KolabAuth($this->ldap, $params);

	$authenticated = $this->auth->authenticate();

	if ($authenticated == 0 || $authenticated == 2) {
            $this->assign( 'uid', '' );
            $this->assign( 'group', '' );
            $this->assign( 'menuitems', array() );
            $this->assign( 'maincontent', 'login.tpl' );
            if ($this->auth->error()) { 
              $this->assign( 'errors', $this->auth->error() );
            }
	    if ($authenticated == 0) {
              $this->assign( 'page_title', _('Error') );
	    } else {
              $this->assign( 'page_title', _('Login') );
	    }
            $this->display('page.tpl');
	    exit();
        }

        $this->assign( 'uid', $this->auth->uid() );
        $this->assign( 'group', $this->auth->group() );
        $this->menuitems = generate_menu($this->auth, $params['topdir']);
        $this->assign( 'menuitems', $this->menuitems );

	
  }


  function domains_valid() {
    $domains = $this->ldap->domains();
    foreach( $domains as $domain ) {
	if( !$this->ldap->exists_group( 'hostmaster@'.$domain ) ||
		!$this->ldap->exists_group( 'postmaster@'.$domain ) ||
		!$this->ldap->exists_group( 'abuse@'.$domain ) ||
		!$this->ldap->exists_group( 'virusalert@'.$domain ) ||
		!$this->ldap->exists_group( 'MAILER-DAEMON@'.$domain ) ) {
		return false;
		}
	}
	return true;
  }

  /** UTF-8 friendly htmlentities() */
  /* static */ function htmlentities( $str ) {	
	return htmlentities( $str, ENT_QUOTES, "UTF-8");
  }
};

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

--- NEW FILE: config.php ---
<?php
/*  
 *  COPYRIGHT
 *  ---------
 *
 *  See docs/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
 *  -----
 *
 *  The configuration for kolab-webadmin
 *
 */

$params = array();

$params['fqdnhostname'] = "@@@fqdnhostname@@@";
$params['ldap_master_uri'] = "@@@ldap_master_uri@@@";
$params['base_dn'] = "@@@base_dn@@@";
$params['php_dn'] = "@@@php_dn@@@";
$params['php_pw'] = "@@@php_pw@@@";

//$params['webserver_web_prefix'] = "@webserver_web_prefix@";
$params['webserver_web_prefix'] = "";

$params['web_root'] = $params['webserver_web_prefix'] . '/admin/'

//$params['topdir'] = '/@kolab_php_module_prefix at admin';
$params['topdir'] = '/admin';

/*
 * Which user classes can log in to the webgui?
 * Currently 4 user classes exist: user, admin, maintainer and manager
 */
$params['allow_user_classes'] = array( 'user', 'admin', 'maintainer', 'manager', 'domain-maintainer' );


//$params['encryption_key'] = "@sysconfdir@/kolab/res_pub.pem";
$params['encryption_key'] = "/kolab/etc/kolab/res_pub.pem";

/*
 * Array to configure visibility/access of LDAP attributes to users account object
 *
 * Possible values for attribute is 
 *
 * 'ro' (readonly)
 * 'rw' (read/write)
 * 'hidden' (atribute removed from display)
 * 'mandatory' (read/write and must not be empty)
 *
 * If an attribute is not in this array, it defaults to 'rw'
 *
 * Note, attributes correspond to form attribute names and not LDAP attribute names.
 *
 * TODO(steffen): Make form and LDAP attributes the same.
 */

$params['attribute_access'] = array(
			 /*
                         // Examples
			 'firstname'  => 'ro',
			 'lastname'   => 'ro',
			 'password'   => 'rw',
			 'mail'       => 'ro',
			 'uid'        => 'ro',
			 'title'      => 'ro',
			 'roomNumber' => 'mandatory',
			 'kolabdelegate'  => 'ro',
			 'telephoneNumber' => 'hidden'
			 */
);

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

--- NEW FILE: index.php ---
<?php
/*  
 *  COPYRIGHT
 *  ---------
 *
 *  See docs/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
 *  -----
 *
 *  The entry script for kolab-webadmin
 *
 */

require_once('mysmarty.php');

$smarty = new MySmarty();

/**** Check for system aliases ****/
$maincontent = 'welcome.tpl';
if( $smarty->auth->group() == 'admin' && !$smarty->domains_valid()) {
	  // Ok, user did not set up system aliases
	  $maincontent = 'systemaliasnagscreen.tpl';
  }

/**** Insert into template and output ***/
$smarty->assign( 'page_title', 'Kolab' );
$smarty->assign( 'submenuitems', array() );
$smarty->assign( 'maincontent', $maincontent );
$smarty->display('page.tpl');

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

--- NEW FILE: logout.php ---
<?php
/*  
 *  COPYRIGHT
 *  ---------
 *
 *  See docs/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
 *  -----
 *
 *  Log out of kolab-webadmin
 *
 */

require_once('config.php');

session_start();
session_destroy();
session_unset();

header('Location: ' . $params['web_root']);

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

--- NEW FILE: mysmarty.php ---
<?php
/*  
 *  COPYRIGHT
 *  ---------
 *
 *  See docs/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
 *  -----
 *
 *  Basic setup for our session. Initializes Smarty.
 *
 */

require_once('config.php');
require_once('Kolab/Webadmin/locale.php');
require_once('Kolab/Webadmin/form.class.php');
require_once('Kolab/Webadmin/auth.class.php');
require_once('Kolab/Webadmin/ldap.class.php');
require_once('Kolab/Webadmin/menu.php');

require_once('smarty/Smarty.class.php');

class MySmarty extends Smarty {

    function MySmarty() 
    {
        global $params;

	global $language;

	session_start();

	$this->Smarty();

	$basedir = dirname(__FILE__) . '/';
	$this->template_dir = $basedir.'templates/';
	$this->compile_dir = $basedir.'templates_c/';
	$this->config_dir = $basedir.'configs/';
	$this->cache_dir = $basedir.'cache/';
	// Added for i18n management (Romain 05-03-03)
	$this->register_function("tr", "translate");

	$this->assign( 'topdir', $params['topdir'] );
	$this->assign( 'prefix', $params['webserver_web_prefix'] );

	$this->assign( 'self_url', $_SERVER['REQUEST_URI'] );

	$cleanurl = preg_replace('/(\?|&)lang=(.*)(&|$)/', '', $_SERVER['REQUEST_URI']);
	$this->assign( 'lang_url', 
				   strpos($cleanurl,'?')===false?
				   ($cleanurl.'?lang='):
				   ($cleanurl.'&lang=') );
	
	// If you add a translation, 
	// add the new language here
	$this->assign( 'currentlang', $language );
	$this->assign( 'languages', array( 
									  array( 'name' => 'Deutsch',
											 'code' => 'de_DE' ),
									  array( 'name' => 'English',
											 'code' => 'en_US' ),
									  array( 'name' => 'Français',
											 'code' => 'fr_FR' ),
									  array( 'name' => 'Italiano',
											 'code' => 'it_IT' ),
									  array( 'name' => 'Nederlands',
											 'code' => 'nl_NL' ),
									  array( 'name' => 'Español',
											 'code' => 'es_ES' ),
									  ));

        $this->ldap =& new KolabLDAP($params);
        $this->auth =& new KolabAuth($this->ldap, $params);

	$authenticated = $this->auth->authenticate();

	if ($authenticated == 0 || $authenticated == 2) {
            $this->assign( 'uid', '' );
            $this->assign( 'group', '' );
            $this->assign( 'menuitems', array() );
            $this->assign( 'maincontent', 'login.tpl' );
            if ($this->auth->error()) { 
              $this->assign( 'errors', $this->auth->error() );
            }
	    if ($authenticated == 0) {
              $this->assign( 'page_title', _('Error') );
	    } else {
              $this->assign( 'page_title', _('Login') );
	    }
            $this->display('page.tpl');
	    exit();
        }

        $this->assign( 'uid', $this->auth->uid() );
        $this->assign( 'group', $this->auth->group() );
        $this->menuitems = generate_menu($this->auth, $params['topdir']);
        $this->assign( 'menuitems', $this->menuitems );

	
  }


  function domains_valid() {
    $domains = $this->ldap->domains();
    foreach( $domains as $domain ) {
	if( !$this->ldap->exists_group( 'hostmaster@'.$domain ) ||
		!$this->ldap->exists_group( 'postmaster@'.$domain ) ||
		!$this->ldap->exists_group( 'abuse@'.$domain ) ||
		!$this->ldap->exists_group( 'virusalert@'.$domain ) ||
		!$this->ldap->exists_group( 'MAILER-DAEMON@'.$domain ) ) {
		return false;
		}
	}
	return true;
  }

  /** UTF-8 friendly htmlentities() */
  /* static */ function htmlentities( $str ) {	
	return htmlentities( $str, ENT_QUOTES, "UTF-8");
  }
};

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

--- NEW FILE: print.css ---
/*
  Local variables:
  buffer-file-coding-system: utf-8
  End:
*/
#topbar {
  height: auto;
}
#toplogo {
  display: none;
}
#toptitle {
  padding: 0; 
  text-align: left;
  border-bottom: 1px solid black;
}
#topuserinfo {
  display: none;
}
#topmenu {
  display: none;
}
#submenu {
  display: none;
}
#maincontent {
  margin: 0;
  padding: 0;
}
.contenttext {
  margin: 0;
}
.contenttable th,
.contenttable td {
  border: 1px solid black;
}

--- NEW FILE: style.css ---
/*
  Local variables:
  buffer-file-coding-system: utf-8
  End:
*/
body { 
  color: black;
  background-color: #F8FCF8;
  font-family: verdana,arial,helvetica,sans-serif; 
  font-size: 95%;
  border: 0; 
  margin: 0; 
}
a, a:visited {  
  font-family: verdana,arial,helvetica,sans-serif; 
}

a { color: #001155; }
a:hover { color: #113399; }

#page { 
  background-repeat: no-repeat; 
  background-position: top right;
}

#topbar { 
  display:block; 
  background-color: #B0BCD0; 
  height: 70px; 
  clear: both;
}
#toplogo { 
  display:block; 
  background-image: url(pics/kolab_logo.png); 
  background-color: #B0BCD0; 
  width: 245px; 
  height: 70px; 
  margin-left: 1em;
  margin-top: 0.4em;
  float: left;
}
#toptitle { 
  display:block; 
  text-align: right;
  font-size: 200%; 
  padding-right: 1em;
  padding-top: 0.5em;
}
#topuserinfo { 
  display:block;
  background-color: #B0BCD0; 
  font-size: 80%;
  padding: 0.1em;
  border-bottom: solid 1px black;
  text-align: right;
}
#topmenu { 
  background-color: #B0BCD0; 
  font-size: 90%;
  border-bottom: solid 1px black;
}
#submenu { 
  background-color: #EEEEEE;
  border-bottom: solid 1px black;  
  font-size: 90%;
}

.topmenuitem { 
  background-color: #B0BCD0; 
  border-right: solid 1px black;
  padding-left: 0.5em;
  padding-right: 0.5em;
  margin: 0px;
}
.topmenuitemselected { 
  background-color: #EEEEEE;   
  border-right: solid 1px black;
  padding-left: 0.5em;
  padding-right: 0.5em;
  margin: 0px;
  border-bottom: solid 1px #EEEEEE;
}
.submenuitem {
}
.submenuitemselected {   
}
.alphagroupitem { 
}
.alphagroupitemselected { 
  font-weight:bold
}
#logout { 
  color: red;
}
#maintitle { 
  font-size: 200%;
}
#maincontent { 
  display:block;
  padding: 1em; 
  margin: 1em; 
}
#errorcontent { 
  display:block;
  padding: 0.2em; 
  margin: 1em; 
  text-align: left;
  color: red;
  background-color: #EEEEEE;   
  border: solid 1px black;
}
#errorheader { 
  display:block;
  text-align: left;
  color: black;
  background-color: #EEEEEE;   
  font-size: 150%; 
}
#messagecontent { 
  display:block;
  padding: 0.2em; 
  margin: 1em; 
  text-align: left;
  color: green;
  background-color: #EEEEEE;   
  border: solid 1px black;
}
#messageheader { 
  display:block;
  text-align: left;
  color: black;
  background-color: #EEEEEE;   
  font-size: 150%; 
}
.contenttext {  
  margin: 10px;
}
.contenttable { 
  width: 100%;
  background-color: black;
  border: 0px;
}
.contentroweven { 
  background-color: #C0CDE0; 
  margin: 0px;
}
.contentrowodd { 
  background-color: #D0DDF0; 
  margin: 0px;
}
.contentcell {   
  font-size: 90%;
  padding: .1em .5em .1em .5em; 
  margin: 0px;
/*  text-align: center; */
}
.actioncell {   
  font-size: 90%;
  padding: .1em .5em .1em .5em; 
  width: 10%;
  margin: 0px;
  text-align: center;
}
.contentform { 
  /*float: left;*/ 
  padding: .1em .5em .1em .5em; 
  background-color: #EEEEEE; 
  border: solid 1px black;
}
.contentformtable { 
  font-size: 90%;
}
.langcombo { 
  font-size: 80%;
}

#validators { 
  text-align: right;
}

th {  
  background-color: #EEEEEE; 
  border: 0px;
}

.ctrl {
  background-color: #E0E3E0;
  border: solid 1px black;  
  padding: .2em .5em .2em .5em; 
}

.required_asterisk { 
  color: red;
  font-size: 80%;
  text-align: right;
}

label {
  cursor: pointer;
}





More information about the commits mailing list