Commit 7a5aa8b8 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Removed $ui references, using global var $ui instead

parent e06f0339
......@@ -30,9 +30,6 @@
*/
class management
{
// Public
public $ui = NULL;
// The plugin description
public $plugname = "unconfigured";
public $plIcon = "unconfigured";
......@@ -99,12 +96,11 @@ class management
// Some management classes are used in tab groups and needs this set to FALSE.
var $is_template = FALSE;
function __construct($unused, $ui, $plugname, $headpage)
function __construct($plugname, $headpage)
{
global $config;
$this->plugname = $plugname;
$this->headpage = $headpage;
$this->ui = $ui;
// Add copy&paste and snapshot handler.
if (!$this->skipCpHandler) {
......@@ -324,6 +320,7 @@ class management
*/
protected function removeEntryRequested($action = "", $target = array(), $all = array())
{
global $ui;
$disallowed = array();
$this->dns = array();
......@@ -331,7 +328,7 @@ class management
// Check permissons for each target
foreach ($target as $dn) {
$acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin);
$acl = $ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin);
if (preg_match("/d/", $acl)) {
$this->dns[] = $dn;
} else {
......@@ -355,7 +352,7 @@ class management
foreach ($this->dns as $dn) {
$dns_names[] = LDAP::fix($dn);
}
add_lock ($this->dns, $this->ui->dn);
add_lock ($this->dns, $ui->dn);
// Display confirmation dialog.
$smarty = get_smarty();
......@@ -384,6 +381,7 @@ class management
function removeEntryConfirmed($action = "", $target = array(), $all = array(),
$altTabClass = "", $altTabType = "", $altAclCategory = "")
{
global $ui;
$tabType = $this->tabType;
$tabClass = $this->tabClass;
$aclCategory = $this->aclCategory;
......@@ -396,7 +394,7 @@ class management
foreach ($this->dns as $dn) {
// Check permissions, are we allowed to remove this object?
$acl = $this->ui->get_permissions($dn, $aclCategory."/".$this->aclPlugin);
$acl = $ui->get_permissions($dn, $aclCategory."/".$this->aclPlugin);
if (preg_match("/d/", $acl)) {
// Delete the object
......@@ -474,6 +472,7 @@ class management
*/
function createSnapshotDialog($action = '', $target = array(), $all = array())
{
global $ui;
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $target, 'Snaptshot creation initiated!');
if (count($target) == 1) {
......@@ -482,7 +481,7 @@ class management
return;
}
$aclCategory = $this->aclCategory;
if ($this->ui->allow_snapshot_create($this->dn, $aclCategory)) {
if ($ui->allow_snapshot_create($this->dn, $aclCategory)) {
$this->dialogObject = new SnapshotCreateDialog($this->dn, $this, $aclCategory);
$this->dialogObject->set_acl_base($this->dn);
} else {
......@@ -497,11 +496,12 @@ class management
*/
function createSnapshot($dn, $description)
{
global $ui;
if ($this->dn !== $dn) {
trigger_error('There was a problem with the snapshot workflow');
return;
}
if (!empty($dn) && $this->ui->allow_snapshot_create($dn, $this->dialogObject->aclCategory)) {
if (!empty($dn) && $ui->allow_snapshot_create($dn, $this->dialogObject->aclCategory)) {
$this->snapHandler->createSnapshot($dn, $description);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'Snaptshot created!');
} else {
......@@ -517,7 +517,8 @@ class management
*/
function restoreSnapshot($dn)
{
if (!empty($dn) && $this->ui->allow_snapshot_restore($dn, $this->dialogObject->aclCategory)) {
global $ui;
if (!empty($dn) && $ui->allow_snapshot_restore($dn, $this->dialogObject->aclCategory)) {
$this->snapHandler->restoreSnapshot($dn);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'Snaptshot restored');
$this->closeDialogs();
......@@ -540,6 +541,8 @@ class management
*/
function restoreSnapshotDialog($action = '', $target = array(), $all = array())
{
global $ui;
// Set current restore base for snapshot handling.
if (is_object($this->snapHandler)) {
$bases = array();
......@@ -563,7 +566,7 @@ class management
}
$aclCategory = $this->aclCategory;
if ($this->ui->allow_snapshot_restore($this->dn, $aclCategory)) {
if ($ui->allow_snapshot_restore($this->dn, $aclCategory)) {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, 'Snaptshot restoring initiated!');
$this->snapHandler->setSnapshotBases($bases);
$this->dialogObject = new SnapshotRestoreDialog($this->dn, $this, !count($target), $aclCategory);
......@@ -701,7 +704,7 @@ class management
*/
function editEntry($action = "", $target = array(), $all = array(), $altTabClass = "", $altTabType = "", $altAclCategory = "")
{
global $config;
global $config, $ui;
/* To handle mutliple object types overload this method.
* ...
* registerAction('editUser', 'editEntry');
......@@ -747,7 +750,7 @@ class management
if ($user != "") {
return gen_locked_message($user, $this->dn, TRUE);
}
add_lock ($this->dn, $this->ui->dn);
add_lock ($this->dn, $ui->dn);
// Open object.
if (empty($tabClass) || empty($tabType)) {
......@@ -906,6 +909,8 @@ class management
function copyPasteHandler($action = "", $target = array(), $all = array(),
$altTabClass = "", $altTabType = "", $altAclCategory = "", $altAclPlugin = "")
{
global $ui;
// Return without any actions while copy&paste handler is disabled.
if (!is_object($this->cpHandler)) {
return FALSE;
......@@ -948,11 +953,11 @@ class management
$aclPlugin = $altAclPlugin[$dn];
}
if ($action == "copy" && $this->ui->is_copyable($dn, $aclCategory, $aclPlugin)) {
if ($action == "copy" && $ui->is_copyable($dn, $aclCategory, $aclPlugin)) {
$this->cpHandler->add_to_queue($dn, "copy", $tabClass, $tabType, $aclCategory);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Entry copied!");
}
if ($action == "cut" && $this->ui->is_cutable($dn, $aclCategory, $aclPlugin)) {
if ($action == "cut" && $ui->is_cutable($dn, $aclCategory, $aclPlugin)) {
$this->cpHandler->add_to_queue($dn, "cut", $tabClass, $tabType, $aclCategory);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Entry cutted!");
}
......
......@@ -34,7 +34,6 @@
class pluglist {
var $menu = "";
var $iconmenu = "";
var $ui = NULL;
var $current = "";
/*!
......@@ -56,17 +55,11 @@ class pluglist {
/*!
* \brief List the plugins
*
* \param string $config Plugin configuration
*
* \param $ui UI
*/
function __construct($unused, &$ui)
function __construct()
{
global $class_mapping, $config;
$this->ui = &$ui;
/* Fill info part of pluglist */
$classes = get_declared_classes();
......@@ -203,6 +196,7 @@ class pluglist {
*/
function check_access($aclname)
{
global $ui;
if (isset($this->silly_cache[$aclname])) {
return $this->silly_cache[$aclname];
}
......@@ -225,12 +219,12 @@ class pluglist {
if (preg_match("/:self$/", $acl_to_check)) {
$acl_to_check = preg_replace("/:self$/", "", $acl_to_check);
if (strpos($acl_to_check, '/')) {
if ($this->ui->get_permissions($this->ui->dn, $acl_to_check, "") != "") {
if ($ui->get_permissions($ui->dn, $acl_to_check, "") != "") {
$this->silly_cache[$aclname] = TRUE;
return TRUE;
}
} else {
if ($this->ui->get_category_permissions($this->ui->dn, $acl_to_check, "") != "") {
if ($ui->get_category_permissions($ui->dn, $acl_to_check, "") != "") {
$this->silly_cache[$aclname] = TRUE;
return TRUE;
}
......@@ -238,7 +232,7 @@ class pluglist {
} else {
/* No self acls. Check if we have any acls for the given ACL type */
$deps = $this->ui->get_module_departments($acl_to_check, TRUE);
$deps = $ui->get_module_departments($acl_to_check, TRUE);
if (count($deps)) {
$this->silly_cache[$aclname] = TRUE;
return TRUE;
......
......@@ -185,7 +185,7 @@ function load_plist ($ldap_available = TRUE)
/* Initially load all classes */
load_all_classes();
$plist = new pluglist($config, $ui);
$plist = new pluglist();
session::global_set('plist', $plist);
$config->loadPlist($plist);
if ($ldap_available) {
......
......@@ -23,11 +23,11 @@ class groupSelect extends simpleSelectManagement
protected $objectTypes = array('group');
protected $autoFilter = FALSE;
function __construct($ui)
function __construct()
{
$this->filterXMLPath = get_template_path('group-filter.xml', TRUE, dirname(__FILE__));
parent::__construct($ui);
parent::__construct();
}
}
?>
......@@ -30,7 +30,7 @@ class GenericDialog
function __construct($simplePlugin, $attribute)
{
$this->attribute = $attribute;
$this->dialog = new $this->dialogClass(get_userinfo());
$this->dialog = new $this->dialogClass();
}
function execute ()
......
......@@ -140,10 +140,9 @@ class simpleManagement extends management
protected $skipTemplates = TRUE;
function __construct($unused, $ui)
function __construct()
{
global $config;
$this->ui = $ui;
if ($this->filterXMLPath === NULL) {
$this->filterXMLPath = get_template_path('simple-filter.xml', TRUE, dirname(__FILE__));
......@@ -188,7 +187,7 @@ class simpleManagement extends management
$headpage = new $this->headpageClass($this->parseXML($this->listXMLPath));
$headpage->setFilter($filter);
parent::__construct(NULL, $ui, 'unused', $headpage);
parent::__construct('unused', $headpage);
$this->configureHeadpage();
$this->configureFilter();
......@@ -469,6 +468,7 @@ class simpleManagement extends management
function applyTemplateToEntry($action, $target = array())
{
global $ui;
if ($this->skipTemplates) {
return;
}
......@@ -484,7 +484,7 @@ class simpleManagement extends management
}
// Add locks
add_lock ($this->dns, $this->ui->dn);
add_lock ($this->dns, $ui->dn);
$this->dn = array_shift($this->dns);
$this->dialogObject = new templateDialog($this, $type, NULL, $this->dn);
......@@ -569,6 +569,7 @@ class simpleManagement extends management
*/
function editEntry($action = "", $target = array(), $all = array(), $altTabClass = "", $altTabType = "", $altAclCategory = "")
{
global $ui;
// Do not create a new tabObject while there is already one opened,
// the user may have just pressed F5 to reload the page.
if (is_object($this->tabObject)) {
......@@ -593,7 +594,7 @@ class simpleManagement extends management
if ($user != "") {
return gen_locked_message($user, $this->dn, TRUE);
}
add_lock ($this->dn, $this->ui->dn);
add_lock ($this->dn, $ui->dn);
// Open object
$this->openTabObject(objects::open($this->dn, $type), $this->dn);
......@@ -625,6 +626,7 @@ class simpleManagement extends management
*/
protected function removeEntryRequested($action = "", $target = array(), $all = array())
{
global $ui;
$disallowed = array();
$this->dns = array();
......@@ -638,7 +640,7 @@ class simpleManagement extends management
}
try {
$info = objects::infos($type);
$acl = $this->ui->get_permissions($dn, $info['aclCategory'].'/'.$info['mainTab']);
$acl = $ui->get_permissions($dn, $info['aclCategory'].'/'.$info['mainTab']);
if (preg_match('/d/', $acl)) {
$this->dns[] = $dn;
} else {
......@@ -679,7 +681,7 @@ class simpleManagement extends management
'type' => $info['name']
);
}
add_lock ($this->dns, $this->ui->dn);
add_lock ($this->dns, $ui->dn);
// Display confirmation dialog.
$smarty = get_smarty();
......@@ -692,6 +694,7 @@ class simpleManagement extends management
function removeEntryConfirmed($action = '', $target = array(), $all = array(),
$altTabClass = '', $altTabType = '', $altAclCategory = '')
{
global $ui;
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $target, "Entry removal confirmed!");
foreach ($this->dns as $dn) {
......@@ -704,7 +707,7 @@ class simpleManagement extends management
}
$infos = objects::infos($type);
// Check permissions, are we allowed to remove this object?
$acl = $this->ui->get_permissions($dn, $infos['aclCategory']."/".$infos['mainTab']);
$acl = $ui->get_permissions($dn, $infos['aclCategory']."/".$infos['mainTab']);
if (preg_match("/d/", $acl)) {
// Delete the object
$this->dn = $dn;
......@@ -735,7 +738,7 @@ class simpleManagement extends management
*/
function createSnapshotDialog($action = '', $target = array(), $all = array())
{
global $config;
global $config, $ui;
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $target, 'Snaptshot creation initiated!');
if (count($target) == 1) {
......@@ -744,7 +747,7 @@ class simpleManagement extends management
return;
}
$aclCategory = $config->data['OBJECTS'][$this->getType($this->dn)]['aclCategory'];
if ($this->ui->allow_snapshot_create($this->dn, $aclCategory)) {
if ($ui->allow_snapshot_create($this->dn, $aclCategory)) {
$this->dialogObject = new SnapshotCreateDialog($this->dn, $this, $aclCategory);
$this->dialogObject->set_acl_base($this->dn);
} else {
......@@ -766,7 +769,7 @@ class simpleManagement extends management
*/
function restoreSnapshotDialog($action = '', $target = array(), $all = array())
{
global $config;
global $config, $ui;
// Set current restore base for snapshot handling.
if (is_object($this->snapHandler)) {
$bases = array();
......@@ -793,7 +796,7 @@ class simpleManagement extends management
$aclCategory = $config->data['OBJECTS'][$this->getType($this->dn)]['aclCategory'];
}
if ($this->ui->allow_snapshot_restore($this->dn, $aclCategory)) {
if ($ui->allow_snapshot_restore($this->dn, $aclCategory)) {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, 'Snaptshot restoring initiated!');
$this->snapHandler->setSnapshotBases($bases);
$this->dialogObject = new SnapshotRestoreDialog($this->dn, $this, !count($target), $aclCategory);
......@@ -813,6 +816,7 @@ class simpleManagement extends management
function copyPasteHandler($action = "", $target = array(), $all = array(),
$altTabClass = "", $altTabType = "", $altAclCategory = "", $altAclPlugin = "")
{
global $ui;
// Return without any actions while copy&paste handler is disabled.
if (!is_object($this->cpHandler)) {
return FALSE;
......@@ -831,11 +835,11 @@ class simpleManagement extends management
}
$infos = objects::infos($type);
if ($action == "copy" && $this->ui->is_copyable($dn, $infos['aclCategory'], $infos['mainTab'])) {
if ($action == "copy" && $ui->is_copyable($dn, $infos['aclCategory'], $infos['mainTab'])) {
$this->cpHandler->add_to_queue($dn, "copy", $type);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Entry copied!");
}
if ($action == "cut" && $this->ui->is_cutable($dn, $infos['aclCategory'], $infos['mainTab'])) {
if ($action == "cut" && $ui->is_cutable($dn, $infos['aclCategory'], $infos['mainTab'])) {
$this->cpHandler->add_to_queue($dn, "cut", $type);
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Entry cutted!");
}
......@@ -895,7 +899,7 @@ class simpleManagement extends management
} else {
if (!session::is_set($classname) || (isset($_GET['reset']) && $_GET['reset'] == 1)) {
/* Create the object if missing or reset requested */
$managementObject = new $classname(NULL, $ui);
$managementObject = new $classname();
} else {
/* Retrieve the object from session */
$managementObject = session::get($classname);
......
......@@ -29,13 +29,13 @@ class simpleSelectManagement extends simpleManagement
protected $departmentRootVisible = FALSE;
function __construct($ui)
function __construct()
{
if ($this->listXMLPath === NULL) {
$this->listXMLPath = get_template_path('simple-select-list.xml', TRUE, dirname(__FILE__));
}
parent::__construct(NULL, $ui);
parent::__construct();
}
/* Build the action menu, fill the object definition, etc, based on objectTypes info */
......
......@@ -43,11 +43,11 @@ class departmentManagement extends simpleManagement
);
}
function __construct($unused, $ui)
function __construct()
{
$this->objectTypes = self::getDepartmentTypes();
$this->listXMLPath = get_template_path('dep-list.xml', TRUE, dirname(__FILE__));
parent::__construct($unused, $ui);
parent::__construct();
$this->headpage->registerElementFilter("depLabel", "departmentManagement::filterDepLabel");
$this->registerAction("open", "openEntry");
}
......
......@@ -40,7 +40,7 @@ if ( $cleanup ){
/* Create usermanagement object on demand */
if (!session::is_set('departmentManagement')){
$departmentManagement = new departmentManagement (NULL, $ui);
$departmentManagement = new departmentManagement ();
session::set('departmentManagement',$departmentManagement);
}
$departmentManagement = session::get('departmentManagement');
......
......@@ -40,12 +40,12 @@ class groupManagement extends simpleManagement
);
}
function __construct($unused, $ui)
function __construct()
{
$this->filterXMLPath = get_template_path('group-filter.xml', TRUE, dirname(__FILE__));
$this->listXMLPath = get_template_path('group-list.xml', TRUE, dirname(__FILE__));
parent::__construct($unused, $ui);
parent::__construct();
$this->headpage->registerElementFilter('filterProperties', 'groupManagement::filterProperties');
}
......
......@@ -51,12 +51,12 @@ class userManagement extends simpleManagement
);
}
function __construct($unused, $ui)
function __construct()
{
$this->filterXMLPath = get_template_path('user-filter.xml', TRUE, dirname(__FILE__));
$this->listXMLPath = get_template_path('user-list.xml', TRUE, dirname(__FILE__));
parent::__construct($unused, $ui);
parent::__construct();
}
function configureHeadpage ()
......@@ -126,12 +126,12 @@ class userManagement extends simpleManagement
*/
function lockEntry($action, $entry, $all, $type = 'toggle')
{
global $config;
global $config, $ui;
// Filter out entries we are not allowed to modify
$disallowed = array();
$dns = array();
foreach ($entry as $dn) {
if (!preg_match('/w/', $this->ui->get_permissions($dn, 'user/password'))) {
if (!preg_match('/w/', $ui->get_permissions($dn, 'user/password'))) {
$disallowed[] = $dn;
} else {
$allowed[] = $dn;
......
......@@ -40,7 +40,7 @@ if ( $cleanup ){
/* Create usermanagement object on demand */
if (!session::is_set('userManagement')){
$userManagement = new userManagement (NULL, $ui);
$userManagement = new userManagement ();
session::set('userManagement',$userManagement);
}
$userManagement = session::get('userManagement');
......
......@@ -286,8 +286,6 @@ class posixAccount extends simplePlugin
}
$this->attributesAccess['loginShell']->setChoices($loginShellList);
$this->ui = get_userinfo();
$secondaryGroups = array();
$secondaryGroups[''] = "- "._("automatic")." -";
$ldap = $config->get_ldap_link();
......
......@@ -72,7 +72,7 @@ class Step_Finish extends setupStep
/* We need the pluglist object */
load_all_classes();
$plist = new pluglist($config, $ui);
$plist = new pluglist();
/* Now we can save LDAP config */
$config->loadPlist($plist);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment