From 65de9966339fa6d4f83310e0df7c838057abc4ec Mon Sep 17 00:00:00 2001 From: katagia Date: Sun, 8 Feb 2004 15:57:55 +0000 Subject: [PATCH] checked new functions in modules.inc --- lam/lib/include.inc | 66 +++++++++++++++++++++++++++++ lam/lib/modules.inc | 36 ++++++++++++---- lam/lib/modules/main.inc | 12 +++--- lam/templates/account/groupedit.php | 37 +--------------- lam/templates/account/hostedit.php | 37 +--------------- lam/templates/account/useredit.php | 36 +--------------- 6 files changed, 104 insertions(+), 120 deletions(-) create mode 100644 lam/lib/include.inc diff --git a/lam/lib/include.inc b/lam/lib/include.inc new file mode 100644 index 00000000..31b90928 --- /dev/null +++ b/lam/lib/include.inc @@ -0,0 +1,66 @@ + diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 99457925..7a372d58 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -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 diff --git a/lam/lib/modules/main.inc b/lam/lib/modules/main.inc index 2c0e0b30..b9912246 100644 --- a/lam/lib/modules/main.inc +++ b/lam/lib/modules/main.inc @@ -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 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')); } - 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; } diff --git a/lam/templates/account/groupedit.php b/lam/templates/account/groupedit.php index 6212d350..8997a535 100644 --- a/lam/templates/account/groupedit.php +++ b/lam/templates/account/groupedit.php @@ -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']); diff --git a/lam/templates/account/hostedit.php b/lam/templates/account/hostedit.php index 2cc8a872..d69114c5 100644 --- a/lam/templates/account/hostedit.php +++ b/lam/templates/account/hostedit.php @@ -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']); diff --git a/lam/templates/account/useredit.php b/lam/templates/account/useredit.php index 10c39e85..d53c290c 100644 --- a/lam/templates/account/useredit.php +++ b/lam/templates/account/useredit.php @@ -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); + ?>