index efed58c996b1e672bdc6aba08d0635ea8500caf2..d5338a003c203fb266ec38686f8a28cbbc940e1c 100644 (file)
* This code is part of GOsa (http://www.gosa-project.org)
* Copyright (C) 2003-2008 GONICUS GmbH
*
* This code is part of GOsa (http://www.gosa-project.org)
* Copyright (C) 2003-2008 GONICUS GmbH
*
- * ID: $$Id$$
+ * ID: $$Id: functions.inc 13100 2008-12-01 14:07:48Z hickert $$
*
* 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
*
* 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
}
/* Allow setting the config file in the apache configuration
}
/* Allow setting the config file in the apache configuration
- e.g. SetEnv CONFIG_FILE gosa.conf.2.5
+ e.g. SetEnv CONFIG_FILE gosa.conf.2.6
*/
if(!isset($_SERVER['CONFIG_FILE'])){
define ("CONFIG_FILE", "gosa.conf");
*/
if(!isset($_SERVER['CONFIG_FILE'])){
define ("CONFIG_FILE", "gosa.conf");
define('DES3_CBC_SHA1',16);
/* Define globals for revision comparing */
define('DES3_CBC_SHA1',16);
/* Define globals for revision comparing */
-$svn_path = '$HeadURL: https://oss.gonicus.de/repositories/gosa/trunk/gosa-core/include/functions.inc $';
-$svn_revision = '$Revision: 9246 $';
+$svn_path = '$HeadURL$';
+$svn_revision = '$Revision$';
/* Include required files */
require_once("class_location.inc");
/* Include required files */
require_once("class_location.inc");
define ("DEBUG_CONFIG", 64);
define ("DEBUG_ACL", 128);
define ("DEBUG_SI", 256);
define ("DEBUG_CONFIG", 64);
define ("DEBUG_ACL", 128);
define ("DEBUG_SI", 256);
+define ("DEBUG_MAIL", 512); // mailAccounts, imap, sieve etc.
+define ("DEBUG_FAI", 1024); // FAI (incomplete)
/* Rewrite german 'umlauts' and spanish 'accents'
to get better results */
/* Rewrite german 'umlauts' and spanish 'accents'
to get better results */
/* Debug level action */
function DEBUG($level, $line, $function, $file, $data, $info="")
{
/* Debug level action */
function DEBUG($level, $line, $function, $file, $data, $info="")
{
- if (session::get('DEBUGLEVEL') & $level){
+ if (session::global_get('DEBUGLEVEL') & $level){
$output= "DEBUG[$level] ";
if ($function != ""){
$output.= "($file:$function():$line) - $info: ";
$output= "DEBUG[$level] ";
if ($function != ""){
$output.= "($file:$function():$line) - $info: ";
/* Rewrite ui object to another dn */
function change_ui_dn($dn, $newdn)
{
/* Rewrite ui object to another dn */
function change_ui_dn($dn, $newdn)
{
- $ui= session::get('ui');
+ $ui= session::global_get('ui');
if ($ui->dn == $dn){
$ui->dn= $newdn;
if ($ui->dn == $dn){
$ui->dn= $newdn;
- session::set('ui',$ui);
+ session::global_set('ui',$ui);
}
}
}
}
/* Return plugin dir or root directory? */
if ($plugin){
if ($path == ""){
/* Return plugin dir or root directory? */
if ($plugin){
if ($path == ""){
- $nf= preg_replace("!^".$BASE_DIR."/!", "", session::get('plugin_dir'));
+ $nf= preg_replace("!^".$BASE_DIR."/!", "", session::global_get('plugin_dir'));
} else {
$nf= preg_replace("!^".$BASE_DIR."/!", "", $path);
}
} else {
$nf= preg_replace("!^".$BASE_DIR."/!", "", $path);
}
return ("$BASE_DIR/ihtml/themes/default/$nf/$filename");
}
if ($path == ""){
return ("$BASE_DIR/ihtml/themes/default/$nf/$filename");
}
if ($path == ""){
- return (session::get('plugin_dir')."/$filename");
+ return (session::global_get('plugin_dir')."/$filename");
} else {
return ($path."/$filename");
}
} else {
return ($path."/$filename");
}
$ui->loadACL();
/* TODO: check java script for htaccess authentication */
$ui->loadACL();
/* TODO: check java script for htaccess authentication */
- session::set('js',true);
+ session::global_set('js',true);
return ($ui);
}
return ($ui);
}
/* Remember which entries were opened as read only, because we
don't need to remove any locks for them later.
*/
/* Remember which entries were opened as read only, because we
don't need to remove any locks for them later.
*/
- if(!session::is_set("LOCK_CACHE")){
- session::set("LOCK_CACHE",array(""));
+ if(!session::global_is_set("LOCK_CACHE")){
+ session::global_set("LOCK_CACHE",array(""));
}
}
- $cache = &session::get("LOCK_CACHE");
+ $cache = &session::global_get("LOCK_CACHE");
if(isset($_POST['open_readonly'])){
$cache['READ_ONLY'][$object] = TRUE;
if(isset($_POST['open_readonly'])){
$cache['READ_ONLY'][$object] = TRUE;
- echo "ADDED : {$user}:{$object}<br>";
return;
}
if(isset($cache['READ_ONLY'][$object])){
return;
}
if(isset($cache['READ_ONLY'][$object])){
- echo "Removed lock entry $object <br>";
unset($cache['READ_ONLY'][$object]);
}
unset($cache['READ_ONLY'][$object]);
}
-
if(is_array($object)){
foreach($object as $obj){
add_lock($obj,$user);
if(is_array($object)){
foreach($object as $obj){
add_lock($obj,$user);
/* If this object was opened in read only mode then
skip removing the lock entry, there wasn't any lock created.
*/
/* If this object was opened in read only mode then
skip removing the lock entry, there wasn't any lock created.
*/
- if(session::is_set("LOCK_CACHE")){
- $cache = &session::get("LOCK_CACHE");
+ if(session::global_is_set("LOCK_CACHE")){
+ $cache = &session::global_get("LOCK_CACHE");
if(isset($cache['READ_ONLY'][$object])){
if(isset($cache['READ_ONLY'][$object])){
- if(isset($_POST['delete_lock'])){
- unset($cache['READ_ONLY'][$object]);
- }else{
- echo "Skipped: $object <br>";
- return;
- }
+ unset($cache['READ_ONLY'][$object]);
+ return;
}
}
}
}
@@ -1031,7 +1026,7 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G
function check_sizelimit()
{
/* Ignore dialog? */
function check_sizelimit()
{
/* Ignore dialog? */
- if (session::is_set('size_ignore') && session::get('size_ignore')){
+ if (session::global_is_set('size_ignore') && session::global_get('size_ignore')){
return ("");
}
return ("");
}
if (session::is_set('limit_exceeded') && session::get('limit_exceeded')){
$smarty= get_smarty();
$smarty->assign('warning', sprintf(_("The size limit of %d entries is exceed!"),
if (session::is_set('limit_exceeded') && session::get('limit_exceeded')){
$smarty= get_smarty();
$smarty->assign('warning', sprintf(_("The size limit of %d entries is exceed!"),
- session::get('size_limit')));
- $smarty->assign('limit_message', sprintf(_("Set the new size limit to %s and show me this message if the limit still exceeds"), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.(session::get('size_limit') +100).'">'));
+ session::global_get('size_limit')));
+ $smarty->assign('limit_message', sprintf(_("Set the new size limit to %s and show me this message if the limit still exceeds"), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.(session::global_get('size_limit') +100).'">'));
return($smarty->fetch(get_template_path('sizelimit.tpl')));
}
return($smarty->fetch(get_template_path('sizelimit.tpl')));
}
function print_sizelimit_warning()
{
function print_sizelimit_warning()
{
- if (session::is_set('size_limit') && session::get('size_limit') >= 10000000 ||
+ if (session::global_is_set('size_limit') && session::global_get('size_limit') >= 10000000 ||
(session::is_set('limit_exceeded') && session::get('limit_exceeded'))){
$config= "<input type='submit' name='edit_sizelimit' value="._("Configure").">";
} else {
(session::is_set('limit_exceeded') && session::get('limit_exceeded'))){
$config= "<input type='submit' name='edit_sizelimit' value="._("Configure").">";
} else {
if (tests::is_id($_POST['new_limit']) &&
isset($_POST['action']) && $_POST['action']=="newlimit"){
if (tests::is_id($_POST['new_limit']) &&
isset($_POST['action']) && $_POST['action']=="newlimit"){
- session::set('size_limit', validate($_POST['new_limit']));
+ session::global_set('size_limit', validate($_POST['new_limit']));
session::set('size_ignore', FALSE);
}
/* User wants no limits? */
if (isset($_POST['action']) && $_POST['action']=="ignore"){
session::set('size_ignore', FALSE);
}
/* User wants no limits? */
if (isset($_POST['action']) && $_POST['action']=="ignore"){
- session::set('size_limit', 0);
- session::set('size_ignore', TRUE);
+ session::global_set('size_limit', 0);
+ session::global_set('size_ignore', TRUE);
}
/* User wants incomplete results */
if (isset($_POST['action']) && $_POST['action']=="limited"){
}
/* User wants incomplete results */
if (isset($_POST['action']) && $_POST['action']=="limited"){
- session::set('size_ignore', TRUE);
+ session::global_set('size_ignore', TRUE);
}
}
getMenuCache();
/* Allow fallback to dialog */
if (isset($_POST['edit_sizelimit'])){
}
}
getMenuCache();
/* Allow fallback to dialog */
if (isset($_POST['edit_sizelimit'])){
- session::set('size_ignore',FALSE);
+ session::global_set('size_ignore',FALSE);
}
}
}
}
global $config;
$map = array(
global $config;
$map = array(
+ "roleRDN" => "ou=roles,",
"ogroupRDN" => "ou=groups,",
"applicationRDN" => "ou=apps,",
"systemRDN" => "ou=systems,",
"ogroupRDN" => "ou=groups,",
"applicationRDN" => "ou=apps,",
"systemRDN" => "ou=systems,",
}
}
-function gen_locked_message($user, $dn)
+function gen_locked_message($user, $dn, $allow_readonly = FALSE)
{
global $plug, $config;
{
global $plug, $config;
/* Prepare and show template */
$smarty= get_smarty();
/* Prepare and show template */
$smarty= get_smarty();
-
+ $smarty->assign("allow_readonly",$allow_readonly);
if(is_array($dn)){
$msg = "<pre>";
foreach($dn as $sub_dn){
if(is_array($dn)){
$msg = "<pre>";
foreach($dn as $sub_dn){
/* Don't assign used ones */
if (!in_array($uid, $used)){
/* Don't assign used ones */
if (!in_array($uid, $used)){
- $ret[]= $uid;
+ /* Add uid, but remove {} first. These are invalid anyway. */
+ $ret[]= preg_replace('/[{}]/', '', $uid);
}
}
}
}
function progressbar($percentage,$width=100,$height=15,$showvalue=false)
{
function progressbar($percentage,$width=100,$height=15,$showvalue=false)
{
- $str = ""; // Our return value will be saved in this var
-
- $color = dechex($percentage+150);
- $color2 = dechex(150 - $percentage);
- $bgcolor= $showvalue?"FFFFFF":"DDDDDD";
-
- $progress = (int)(($percentage /100)*$width);
-
- /* If theres a better solution for this, use it... */
- $str = "\n <div style=\" width:".($width)."px; ";
- $str.= "\n height:".($height)."px; ";
- $str.= "\n background-color:#000000; ";
- $str.= "\n padding:1px;\" > ";
-
- $str.= "\n <div style=\" width:".($width)."px; ";
- $str.= "\n background-color:#$bgcolor; ";
- $str.= "\n height:".($height)."px;\" > ";
-
- if(($height >10)&&($showvalue)){
- $str.= "\n <font style=\"font-size:".($height-2)."px; ";
- $str.= "\n color:#FF0000; align:middle; ";
- $str.= "\n padding-left:".((int)(($width*0.4)))."px; \"> ";
- $str.= "\n <b>".$percentage."%</b> ";
- $str.= "\n </font> ";
- }
-
- $str.= "\n <div style=\" width:".$progress."px; ";
- $str.= "\n height:".$height."px; ";
- $str.= "\n background-color:#".$color2.$color2.$color."; \" >";
- $str.= "\n </div>";
- $str.= "\n </div>";
- $str.= "\n </div>";
-
- return($str);
+ return("<img src='progress.php?x=$width&y=$height&p=$percentage'>");
}
}
/* The gosa base schema */
$checks['gosaObject'] = $def_check;
/* The gosa base schema */
$checks['gosaObject'] = $def_check;
- $checks['gosaObject']['REQUIRED_VERSION'] = "2.4";
+ $checks['gosaObject']['REQUIRED_VERSION'] = "2.6.1";
$checks['gosaObject']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema");
$checks['gosaObject']['CLASSES_REQUIRED'] = array("gosaObject");
$checks['gosaObject']['IS_MUST_HAVE'] = TRUE;
/* GOsa Account class */
$checks['gosaObject']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema");
$checks['gosaObject']['CLASSES_REQUIRED'] = array("gosaObject");
$checks['gosaObject']['IS_MUST_HAVE'] = TRUE;
/* GOsa Account class */
- $checks["gosaAccount"]["REQUIRED_VERSION"]= "2.4";
+ $checks["gosaAccount"]["REQUIRED_VERSION"]= "2.6.1";
$checks["gosaAccount"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema");
$checks["gosaAccount"]["CLASSES_REQUIRED"]= array("gosaAccount");
$checks["gosaAccount"]["IS_MUST_HAVE"] = TRUE;
$checks["gosaAccount"]["INFO"] = _("Used to store account specific informations.");
/* GOsa lock entry, used to mark currently edited objects as 'in use' */
$checks["gosaAccount"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema");
$checks["gosaAccount"]["CLASSES_REQUIRED"]= array("gosaAccount");
$checks["gosaAccount"]["IS_MUST_HAVE"] = TRUE;
$checks["gosaAccount"]["INFO"] = _("Used to store account specific informations.");
/* GOsa lock entry, used to mark currently edited objects as 'in use' */
- $checks["gosaLockEntry"]["REQUIRED_VERSION"] = "2.4";
+ $checks["gosaLockEntry"]["REQUIRED_VERSION"] = "2.6.1";
$checks["gosaLockEntry"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema");
$checks["gosaLockEntry"]["CLASSES_REQUIRED"] = array("gosaLockEntry");
$checks["gosaLockEntry"]["IS_MUST_HAVE"] = TRUE;
$checks["gosaLockEntry"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema");
$checks["gosaLockEntry"]["CLASSES_REQUIRED"] = array("gosaLockEntry");
$checks["gosaLockEntry"]["IS_MUST_HAVE"] = TRUE;
/* Some other checks */
foreach(array(
/* Some other checks */
foreach(array(
- "gosaCacheEntry" => array("version" => "2.4"),
- "gosaDepartment" => array("version" => "2.4"),
+ "gosaCacheEntry" => array("version" => "2.6.1"),
+ "gosaDepartment" => array("version" => "2.6.1"),
"goFaxAccount" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
"goFaxSBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
"goFaxRBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
"goFaxAccount" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
"goFaxSBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
"goFaxRBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
- "gosaUserTemplate" => array("version" => "2.4", "class" => "posixAccount","file" => "nis.schema"),
- "gosaMailAccount" => array("version" => "2.4", "class" => "mailAccount","file" => "gosa+samba3.schema"),
- "gosaProxyAccount" => array("version" => "2.4", "class" => "proxyAccount","file" => "gosa+samba3.schema"),
- "gosaApplication" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
- "gosaApplicationGroup" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
- "GOhard" => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
- "gotoTerminal" => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
- "goServer" => array("version" => "2.4","class" => "server","file" => "goserver.schema"),
- "goTerminalServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goShareServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goNtpServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goSyslogServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
- "goLdapServer" => array("version" => "2.4"),
- "goCupsServer" => array("version" => "2.4", "class" => array("posixAccount", "terminals"),),
- "goImapServer" => array("version" => "2.4", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3. schema"),
- "goKrbServer" => array("version" => "2.4"),
- "goFaxServer" => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"),
+ "gosaUserTemplate" => array("version" => "2.6.1", "class" => "posixAccount","file" => "nis.schema"),
+ "gosaMailAccount" => array("version" => "2.6.1", "class" => "mailAccount","file" => "gosa+samba3.schema"),
+ "gosaProxyAccount" => array("version" => "2.6.1", "class" => "proxyAccount","file" => "gosa+samba3.schema"),
+ "gosaApplication" => array("version" => "2.6.1", "class" => "appgroup","file" => "gosa.schema"),
+ "gosaApplicationGroup" => array("version" => "2.6.1", "class" => "appgroup","file" => "gosa.schema"),
+ "GOhard" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "gotoTerminal" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goServer" => array("version" => "2.6.1","class" => "server","file" => "goserver.schema"),
+ "goTerminalServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goShareServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goNtpServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goSyslogServer" => array("version" => "2.6.1", "class" => "terminals","file" => "goto.schema"),
+ "goLdapServer" => array("version" => "2.6.1"),
+ "goCupsServer" => array("version" => "2.6.1", "class" => array("posixAccount", "terminals"),),
+ "goImapServer" => array("version" => "2.6.1", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3. schema"),
+ "goKrbServer" => array("version" => "2.6.1"),
+ "goFaxServer" => array("version" => "2.6.1", "class" => "gofaxAccount","file" => "gofax.schema"),
) as $name => $values){
$checks[$name] = $def_check;
) as $name => $values){
$checks[$name] = $def_check;
/* The gosa base schema */
$checks['posixGroup'] = $def_check;
/* The gosa base schema */
$checks['posixGroup'] = $def_check;
- $checks['posixGroup']['REQUIRED_VERSION'] = "2.4";
+ $checks['posixGroup']['REQUIRED_VERSION'] = "2.6.1";
$checks['posixGroup']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema");
$checks['posixGroup']['CLASSES_REQUIRED'] = array("posixGroup");
$checks['posixGroup']['STATUS'] = TRUE;
$checks['posixGroup']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema");
$checks['posixGroup']['CLASSES_REQUIRED'] = array("posixGroup");
$checks['posixGroup']['STATUS'] = TRUE;
} else {
$hash= "";
}
} else {
$hash= "";
}
+
+ if ($hash == "") {
+ msg_dialog::display(_("Configuration error"), _("Cannot generate samba hash!"), ERROR_DIALOG);
+ return ("");
+ }
} else {
$tmp= $config->get_cfg_value('sambaHashHook')." ".escapeshellarg($password);
@DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute");
} else {
$tmp= $config->get_cfg_value('sambaHashHook')." ".escapeshellarg($password);
@DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute");
flush();
reset($ar);
$hash= current($ar);
flush();
reset($ar);
$hash= current($ar);
- }
- if ($hash == "") {
- msg_dialog::display(_("Configuration error"), _("Cannot generate samba hash!"), ERROR_DIALOG);
- return ("");
+ if ($hash == "") {
+ msg_dialog::display(_("Configuration error"), sprintf(_("Cannot generate samba hash: running '%s' failed, check the 'sambaHashHook'!"),$config->get_cfg_value('sambaHashHook')), ERROR_DIALOG);
+ return ("");
+ }
}
list($lm,$nt)= split (":", trim($hash));
}
list($lm,$nt)= split (":", trim($hash));
return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $password, pack("H*", $input), MCRYPT_MODE_ECB, $iv);
}
return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $password, pack("H*", $input), MCRYPT_MODE_ECB, $iv);
}
+function get_object_info()
+{
+ return(session::get('objectinfo'));
+}
+
+function set_object_info($str = "")
+{
+ session::set('objectinfo',$str);
+}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>