checked new functions in modules.inc
This commit is contained in:
parent
644c0c1e60
commit
65de996633
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/*
|
||||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
||||
Copyright (C) 2003 Tilo Lutz
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
LDAP Account Manager displays table for creating or modifying accounts in LDAP
|
||||
*/
|
||||
|
||||
// Get Lampath, needed 4 includes
|
||||
$lampath_include = str_replace('account', '', str_replace('templates', '', realpath('.'))); // Save full path to lam in session
|
||||
$lampath_include = ereg_replace ( '[/]+', '/', $lampath_include);
|
||||
|
||||
include_once($lampath_include.'lib/config.inc'); // File with configure-functions
|
||||
include_once($lampath_include.'lib/profiles.inc'); // functions to load and save profiles
|
||||
include_once($lampath_include.'lib/status.inc'); // Return error-message
|
||||
include_once($lampath_include.'lib/pdf.inc'); // Return a pdf-file
|
||||
include_once($lampath_include.'lib/ldap.inc'); // LDAP-functions
|
||||
include_once($lampath_include.'lib/modules.inc'); // LDAP-functions
|
||||
include_once($lampath_include.'lib/cache.inc');
|
||||
include_once($lampath_include.'lib/account.inc');
|
||||
|
||||
/* We have to include all modules
|
||||
* before start session
|
||||
*/
|
||||
$dir = opendir($lampath_include.'lib/modules');
|
||||
while ($entry = readdir($dir))
|
||||
if (is_file($lampath_include.'lib/modules/'.$entry)) include_once ($lampath_include.'lib/modules/'.$entry);
|
||||
|
||||
// Start session
|
||||
session_save_path($lampath_include.'sess');
|
||||
@session_start();
|
||||
|
||||
// Redirect to startpage if user is not loged in
|
||||
if (!isset($_SESSION['loggedIn'])) {
|
||||
// *** fixme ../../
|
||||
metaRefresh("../../login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Set correct language, codepages, ....
|
||||
setlanguage();
|
||||
|
||||
if (!isset($_SESSION['cache'])) {
|
||||
$_SESSION['cache'] = new cache();
|
||||
}
|
||||
|
||||
$_SESSION['scope'] = array ('user', 'group', 'host', 'domain');
|
||||
|
||||
?>
|
|
@ -27,7 +27,7 @@ $Id$
|
|||
|
||||
// returns the alias name of a module
|
||||
function getModuleAlias($name) {
|
||||
$eval = "$return = $name::get_alias()";
|
||||
$eval = '$return = '.$name.'::get_alias();';
|
||||
eval ($eval);
|
||||
return $return;
|
||||
}
|
||||
|
@ -36,16 +36,16 @@ function getModuleAlias($name) {
|
|||
// dependencies contains an array with two sub arrays: depends, conflicts
|
||||
// the elements of depends are either module names or an array of module names (OR-case)
|
||||
// the elements of conflicts are module names
|
||||
function getModuleDependencies($scope) {
|
||||
function getModulesDependencies($scope) {
|
||||
// scope = suer, group, host, ....
|
||||
// get module names.
|
||||
$dir = opendir('../../lib/modules');
|
||||
while ($entry = readdir($dir))
|
||||
if (is_file('../../lib/modules/'.$entry)) {
|
||||
$entry = substr($entry, 0, strpos('.'));
|
||||
$eval = "$module = $entry::get_dependencies($scope)";
|
||||
$entry = substr($entry, 0, strpos($entry, '.'));
|
||||
$eval = '$module = '.$entry."::get_dependencies(".$scope.");";
|
||||
eval ($eval);
|
||||
$return[$entry] = $module;
|
||||
if ($module != -1) $return[$entry] = $module;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
@ -58,14 +58,34 @@ function getAvailableModules($scope) {
|
|||
$dir = opendir('../../lib/modules');
|
||||
while ($entry = readdir($dir))
|
||||
if (is_file('../../lib/modules/'.$entry)) {
|
||||
$entry = substr($entry, 0, strpos('.'));
|
||||
$eval = "$module = $entry::get_dependencies($scope)";
|
||||
$entry = substr($entry, 0, strpos($entry, '.'));
|
||||
$eval = '$module = '.$entry."::get_dependencies(".$scope.");";
|
||||
eval ($eval);
|
||||
if ($module != -1) $return[] = getModuleAlias($entry);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function getProfileOptions($scope, $post) {
|
||||
// type = user, group, host, ...
|
||||
if (!isset($_SESSION['profile_account'])) {
|
||||
// create new object
|
||||
$_SESSION['profile_account'] = new accountContainer($scope, 'profile_account');
|
||||
$_SESSION['profile_account']->new_account();
|
||||
}
|
||||
return $_SESSION['profile_account']->display_profile($post);
|
||||
}
|
||||
|
||||
function checkProfileOptions($scope, $post) {
|
||||
// type = user, group, host, ...
|
||||
if (!isset($_SESSION['profile_account'])) {
|
||||
// create new object
|
||||
$_SESSION['profile_account'] = new accountContainer($scope, 'profile_account');
|
||||
$_SESSION['profile_account']->new_account();
|
||||
}
|
||||
return $_SESSION['profile_account']->process_profile($post);
|
||||
}
|
||||
|
||||
|
||||
class accountContainer {
|
||||
// Constructor
|
||||
|
@ -97,7 +117,7 @@ class accountContainer {
|
|||
/* This variale stores the type
|
||||
* of account. Current unix, group, host are supported
|
||||
*/
|
||||
var $type;
|
||||
var $scope;
|
||||
var $ldap; // This is a reference to the ldap class in session
|
||||
var $config; // This is a reference to the config class in session
|
||||
// Localized part of HTML-Header
|
||||
|
|
|
@ -189,7 +189,7 @@ class main {
|
|||
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
$modules = $_SESSION[$this->base]->check_attributes();
|
||||
if (count($modules)!=0) {
|
||||
if (count($modules)!=0 && !$profile) {
|
||||
$disabled = false;
|
||||
// Show reason why module is disabled
|
||||
for ($i=0; $i<count($modules); $i++)
|
||||
|
@ -229,13 +229,13 @@ class main {
|
|||
1 => array ('kind' => 'input', 'name' => 'saveProfile', 'type' => 'submit',
|
||||
'value' => _('Save profile'), 'disabled' => $disabled))) ),
|
||||
2 => array ('kind' => 'help', 'value' => 'saveProfile'));
|
||||
}
|
||||
|
||||
if ($_SESSION[$this->base]->dn_orig!='') $text = _('Modify Account');
|
||||
else $text = _('Create Account');
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => $text ),
|
||||
1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'create', 'value' => $text ),
|
||||
2 => array ('kind' => 'help', 'value' => 'create'));
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,43 +23,8 @@ $Id$
|
|||
LDAP Account Manager displays table for creating or modifying accounts in LDAP
|
||||
*/
|
||||
|
||||
// include all needed files
|
||||
include_once('../../lib/account.inc'); // File with all account-funtions
|
||||
include_once('../../lib/config.inc'); // File with configure-functions
|
||||
include_once('../../lib/profiles.inc'); // functions to load and save profiles
|
||||
include_once('../../lib/status.inc'); // Return error-message
|
||||
include_once('../../lib/pdf.inc'); // Return a pdf-file
|
||||
include_once('../../lib/ldap.inc'); // LDAP-functions
|
||||
include_once('../../lib/modules.inc');
|
||||
include_once('../../lib/cache.inc');
|
||||
include_once('../../lib/include.inc');
|
||||
|
||||
/* We have to include all modules
|
||||
* before start session
|
||||
* *** fixme I would prefer loading them dynamic but
|
||||
* i don't know how to to this
|
||||
*/
|
||||
$dir = opendir('../../lib/modules');
|
||||
while ($entry = readdir($dir))
|
||||
if (is_file('../../lib/modules/'.$entry)) include_once ('../../lib/modules/'.$entry);
|
||||
|
||||
|
||||
|
||||
// Start session
|
||||
session_save_path('../../sess');
|
||||
@session_start();
|
||||
|
||||
// Redirect to startpage if user is not loged in
|
||||
if (!isset($_SESSION['loggedIn'])) {
|
||||
metaRefresh("../login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Set correct language, codepages, ....
|
||||
setlanguage();
|
||||
|
||||
if (!isset($_SESSION['cache'])) {
|
||||
$_SESSION['cache'] = new cache();
|
||||
}
|
||||
if ($_GET['DN']) {
|
||||
//load account
|
||||
$DN = str_replace("\'", '', $_GET['DN']);
|
||||
|
|
|
@ -23,43 +23,8 @@ $Id$
|
|||
LDAP Account Manager displays table for creating or modifying accounts in LDAP
|
||||
*/
|
||||
|
||||
// include all needed files
|
||||
include_once('../../lib/account.inc'); // File with all account-funtions
|
||||
include_once('../../lib/config.inc'); // File with configure-functions
|
||||
include_once('../../lib/profiles.inc'); // functions to load and save profiles
|
||||
include_once('../../lib/status.inc'); // Return error-message
|
||||
include_once('../../lib/pdf.inc'); // Return a pdf-file
|
||||
include_once('../../lib/ldap.inc'); // LDAP-functions
|
||||
include_once('../../lib/modules.inc');
|
||||
include_once('../../lib/cache.inc');
|
||||
include_once('../../lib/include.inc');
|
||||
|
||||
/* We have to include all modules
|
||||
* before start session
|
||||
* *** fixme I would prefer loading them dynamic but
|
||||
* i don't know how to to this
|
||||
*/
|
||||
$dir = opendir('../../lib/modules');
|
||||
while ($entry = readdir($dir))
|
||||
if (is_file('../../lib/modules/'.$entry)) include_once ('../../lib/modules/'.$entry);
|
||||
|
||||
|
||||
|
||||
// Start session
|
||||
session_save_path('../../sess');
|
||||
@session_start();
|
||||
|
||||
// Redirect to startpage if user is not loged in
|
||||
if (!isset($_SESSION['loggedIn'])) {
|
||||
metaRefresh("../login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Set correct language, codepages, ....
|
||||
setlanguage();
|
||||
|
||||
if (!isset($_SESSION['cache'])) {
|
||||
$_SESSION['cache'] = new cache();
|
||||
}
|
||||
if ($_GET['DN']) {
|
||||
//load account
|
||||
$DN = str_replace("\'", '', $_GET['DN']);
|
||||
|
|
|
@ -23,41 +23,8 @@ $Id$
|
|||
LDAP Account Manager displays table for creating or modifying accounts in LDAP
|
||||
*/
|
||||
|
||||
// include all needed files
|
||||
include_once('../../lib/account.inc'); // File with all account-funtions
|
||||
include_once('../../lib/config.inc'); // File with configure-functions
|
||||
include_once('../../lib/profiles.inc'); // functions to load and save profiles
|
||||
include_once('../../lib/status.inc'); // Return error-message
|
||||
include_once('../../lib/pdf.inc'); // Return a pdf-file
|
||||
include_once('../../lib/ldap.inc'); // LDAP-functions
|
||||
include_once('../../lib/modules.inc');
|
||||
include_once('../../lib/cache.inc');
|
||||
include_once('../../lib/include.inc');
|
||||
|
||||
/* We have to include all modules
|
||||
* before start session
|
||||
* *** fixme I would prefer loading them dynamic but
|
||||
* i don't know how to to this
|
||||
*/
|
||||
$dir = opendir('../../lib/modules');
|
||||
while ($entry = readdir($dir))
|
||||
if (is_file('../../lib/modules/'.$entry)) include_once ('../../lib/modules/'.$entry);
|
||||
|
||||
// Start session
|
||||
session_save_path('../../sess');
|
||||
@session_start();
|
||||
|
||||
// Redirect to startpage if user is not loged in
|
||||
if (!isset($_SESSION['loggedIn'])) {
|
||||
metaRefresh("../login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Set correct language, codepages, ....
|
||||
setlanguage();
|
||||
|
||||
if (!isset($_SESSION['cache'])) {
|
||||
$_SESSION['cache'] = new cache();
|
||||
}
|
||||
if ($_GET['DN']) {
|
||||
//load account
|
||||
$DN = str_replace("\'", '', $_GET['DN']);
|
||||
|
@ -70,4 +37,5 @@ else if (count($_POST)==0) {
|
|||
}
|
||||
$_SESSION['account']->continue_main($_POST);
|
||||
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue