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

Fixes #2657 First pass of constructor reorganization

mainTab is now dynamic.
parent is now given in the constructor.
parent d5952855
......@@ -167,18 +167,7 @@ class CopyPasteHandler
return array();
}
if (isset($entry['type'])) {
$entry['object'] = objects::open($entry['dn'], $entry['type']);
} else {
trigger_error('Call to deprecated tabs constructor');
// old way
$tab_c = $entry['tab_class'];
$tab_o = $entry['tab_object'];
$tab_a = $entry['tab_acl_category'];
// Deprecated
$entry['object'] = new $tab_c(NULL, $config->data['TABS'][$tab_o], $entry['dn'], $tab_a);
}
$entry['object'] = objects::open($entry['dn'], $entry['type']);
$entry['object']->set_acl_base($base);
if ($entry['parent'] !== NULL) {
......
......@@ -46,7 +46,7 @@ class SnapshotCreateDialog extends simplePlugin
);
}
function __construct ($unused, $dn, $parent, $aclCategory)
function __construct ($dn, $parent, $aclCategory)
{
parent::__construct();
$this->attributesAccess['description']->setInLdap(FALSE);
......@@ -191,7 +191,7 @@ class SnapshotRestoreDialog extends simplePlugin
);
}
function __construct ($unused, $dn, $parent, $global, $aclCategory)
function __construct ($dn, $parent, $global, $aclCategory)
{
parent::__construct();
$this->object_dn = $dn;
......
......@@ -483,7 +483,7 @@ class management
}
$aclCategory = $this->aclCategory;
if ($this->ui->allow_snapshot_create($this->dn, $aclCategory)) {
$this->dialogObject = new SnapshotCreateDialog(NULL, $this->dn, $this, $aclCategory);
$this->dialogObject = new SnapshotCreateDialog($this->dn, $this, $aclCategory);
$this->dialogObject->set_acl_base($this->dn);
} else {
msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to create a snapshot for %s.'), $this->dn),
......@@ -566,7 +566,7 @@ class management
if ($this->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(NULL, $this->dn, $this, !count($target), $aclCategory);
$this->dialogObject = new SnapshotRestoreDialog($this->dn, $this, !count($target), $aclCategory);
$this->dialogObject->set_acl_base($this->dn);
} else {
msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to restore a snapshot for %s.'), $this->dn),
......
......@@ -35,7 +35,7 @@ class plugin
*
* \sa tab
*/
var $parent = NULL;
public $parent = NULL;
/*!
\brief Mark plugin as account
......@@ -116,10 +116,10 @@ class plugin
*
* \sa plugin()
*/
function __construct ($unused, $dn = NULL, $object = NULL)
function __construct ($dn = NULL, $object = NULL)
{
global $config;
/* Configuration is fine, allways */
$this->dn = $dn;
// Ensure that we've a valid acl_category set.
......
......@@ -173,7 +173,7 @@ class passwordMethod
lock_ssh_account($mode, $attrs, $modify);
// (Un)lock the account by modifying the password hash.
$pwdClass = new user(NULL, $dn);
$pwdClass = new user($dn);
$pwdClass->callHook('PRE'.$mode, array(), $ret);
if ($mode == 'LOCK') {
......
......@@ -37,10 +37,10 @@ class multiPlugin extends simplePlugin
return array();
}
function __construct ($unused = NULL, $dn = NULL, $parent = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL)
{
global $config;
parent::__construct($unused, $dn, $parent);
parent::__construct($dn, $object, $parent, FALSE);
$plInfos = pluglist::pluginInfos(get_class($this));
......@@ -50,7 +50,7 @@ class multiPlugin extends simplePlugin
continue;
}
$name = $plug['CLASS'];
$this->plugin[$name] = new $name($unused, $dn, $parent);
$this->plugin[$name] = new $name($dn, $object, $parent);
/* Acl base && category configuration,
these settings will be overloaded in main.inc,
......@@ -80,11 +80,6 @@ class multiPlugin extends simplePlugin
$display .= back_to_main();
return $display;
}
} else {
foreach ($this->plugin as &$plug) {
$plug->parent = $this->parent;
}
unset($plug);
}
/* Execude objects */
......
......@@ -745,7 +745,7 @@ class simpleManagement extends management
}
$aclCategory = $config->data['OBJECTS'][$this->getType($this->dn)]['aclCategory'];
if ($this->ui->allow_snapshot_create($this->dn, $aclCategory)) {
$this->dialogObject = new SnapshotCreateDialog(NULL, $this->dn, $this, $aclCategory);
$this->dialogObject = new SnapshotCreateDialog($this->dn, $this, $aclCategory);
$this->dialogObject->set_acl_base($this->dn);
} else {
msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to create a snapshot for %s.'), $this->dn),
......@@ -796,7 +796,7 @@ class simpleManagement extends management
if ($this->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(NULL, $this->dn, $this, !count($target), $aclCategory);
$this->dialogObject = new SnapshotRestoreDialog($this->dn, $this, !count($target), $aclCategory);
$this->dialogObject->set_acl_base($this->dn);
} else {
msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to restore a snapshot for %s.'), $this->dn),
......
......@@ -78,9 +78,13 @@ class simplePlugin extends plugin
* \param array $attributesInfo An attributesInfo array, if NULL, getAttributesInfo will be used.
*
*/
function __construct ($unused = NULL, $dn = NULL, $object = NULL, $attributesInfo = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE, $attributesInfo = NULL)
{
global $config;
$this->parent = $parent;
$this->mainTab = $mainTab;
if ($attributesInfo === NULL) {
$attributesInfo = $this->getAttributesInfo();
}
......@@ -115,7 +119,7 @@ class simplePlugin extends plugin
}
// We call plugin constructor
parent::__construct($unused, $dn, $object);
parent::__construct($dn, $object);
$this->setTemplate($this->is_template);
......@@ -476,7 +480,7 @@ class simplePlugin extends plugin
$class = get_class($this);
$attrsWrapper = new stdClass();
$attrsWrapper->attrs = $this->group_attrs;
$group = new $class(NULL, $this->group_attrs['dn'], $attrsWrapper);
$group = new $class($this->group_attrs['dn'], $attrsWrapper, $this->parent, $this->mainTab);
$smarty = get_smarty();
$group->renderAttributes(TRUE);
......@@ -747,7 +751,7 @@ class simplePlugin extends plugin
*
* \param string $entry_dn the dn of the object to show/edit
*
* \param string $tabs the tab class to use (or TRUE to use tabs, FALSE to show directly the plugin class)
* \param string $tabs TRUE to use tabs, FALSE to show directly the plugin class
*
* \param boolean $edit_mode wether or not this plugin can be edited
*
......@@ -757,14 +761,11 @@ class simplePlugin extends plugin
static function mainInc ($classname, $entry_dn, $tabs = FALSE, $edit_mode = TRUE, $objectType = FALSE)
{
global $remove_lock, $cleanup, $display, $config, $plug, $ui;
if ($tabs === TRUE) {
$tabs = 'tabs'; // Default tab class
}
$plInfo = pluglist::pluginInfos($classname);
$plIcon = (isset($plInfo['plIcon'])?$plInfo['plIcon']:'plugin.png');
$plHeadline = $plInfo['plTitle'];
if (($tabs !== FALSE) && ($objectType === FALSE)) {
if ($objectType === FALSE) {
$key = key($plInfo['plObjectType']);
if (is_numeric($key)) {
$key = $plInfo['plObjectType'][$key];
......@@ -779,6 +780,12 @@ class simplePlugin extends plugin
$plCategory = $key;
}
$mainTab = FALSE;
if (!$tabs) {
$infos = objects::infos($objectType);
$mainTab = (reset($config->data['TABS'][$infos['tabGroup']])['CLASS'] == $classname);
}
$lock_msg = "";
if ($edit_mode) {
/* Remove locks created by this plugin */
......@@ -803,7 +810,7 @@ class simplePlugin extends plugin
/* Create account object on demand */
if (!session::is_set($classname) || (isset($_GET['reset']) && $_GET['reset'] == 1)) {
if ($tabs) {
$account = new $tabs($objectType, $entry_dn);
$account = objects::open($entry_dn, $objectType);
if ($edit_mode) {
foreach ($account->by_object as &$obj) {
$obj->setNeedEditMode(TRUE);
......@@ -811,7 +818,7 @@ class simplePlugin extends plugin
unset($obj);
}
} else {
$account = new $classname(NULL, $entry_dn);
$account = new $classname($entry_dn, NULL, NULL, $mainTab);
$account->set_acl_category($plCategory);
if ($edit_mode) {
$account->setNeedEditMode(TRUE);
......
......@@ -40,12 +40,12 @@ class simpleService extends simplePlugin {
* \param array $attributesInfo An attributesInfo array, if NULL, getAttributesInfo will be used.
*
*/
function __construct($unused, $dn, $object = NULL, $attributesInfo = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $attributesInfo = NULL)
{
parent::__construct($unused, $dn, $object, $attributesInfo);
/* $object is the instance of serverService in this case, we set it as parent */
parent::__construct($dn, $object, $object, FALSE, $attributesInfo);
$plInfos = pluglist::pluginInfos(get_class($this));
$this->DisplayName = $plInfos['plShortName'];
$this->parent = $object; /* $object is the instance of serverService in this case */
}
/*! \brief This function display the service and return the html code
......
......@@ -70,6 +70,7 @@ class simpleTabs
}
$this->objectType = $type;
} else {
trigger_error('deprecated call to old tabclass constructor');
/* Deprecated, used by old management classes */
//$config_object = func_get_arg(0); // ignored
$data = func_get_arg(1);
......@@ -100,15 +101,14 @@ class simpleTabs
$this->by_name[$tab['CLASS']] = $tab['NAME'];
if ($baseobject === NULL) {
$baseobject = new $tab['CLASS'](NULL, $this->dn, $attrs_object);
$baseobject = new $tab['CLASS']($this->dn, $attrs_object, $this, TRUE);
$this->by_object[$tab['CLASS']] = $baseobject;
$this->baseclass = $tab['CLASS'];
} else {
$this->by_object[$tab['CLASS']] = new $tab['CLASS'](NULL, $this->dn, $baseobject);
$this->by_object[$tab['CLASS']] = new $tab['CLASS']($this->dn, $baseobject, $this, FALSE);
}
$this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
$this->by_object[$tab['CLASS']]->parent = &$this;
$this->by_object[$tab['CLASS']]->set_acl_category($this->acl_category);
}
unset($tab);
......@@ -145,12 +145,11 @@ class simpleTabs
continue;
}
if ($baseobject === NULL) {
$baseobject = new $class(NULL, $this->dn);
$baseobject = new $class($this->dn, NULL, $this, TRUE);
$this->by_object[$name] = $baseobject;
} else {
$this->by_object[$name] = new $class(NULL, $this->dn, $baseobject);
$this->by_object[$name] = new $class($this->dn, $baseobject, $this, FALSE);
}
$this->by_object[$name]->parent = &$this;
$this->by_object[$name]->set_acl_category($this->acl_category);
}
}
......@@ -459,8 +458,7 @@ class simpleTabs
}
$this->by_name[$tab['CLASS']] = $tab['NAME'];
$this->by_object[$tab['CLASS']] = new $tab['CLASS'](NULL, $this->dn, $baseobject);
$this->by_object[$tab['CLASS']]->parent = &$this;
$this->by_object[$tab['CLASS']] = new $tab['CLASS']($this->dn, $baseobject, $this, FALSE);
$this->by_object[$tab['CLASS']]->set_acl_category($this->acl_category);
}
}
......
......@@ -52,9 +52,9 @@ class dashboard extends simplePlugin
);
}
function __construct($unused, $dn = NULL, $object = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
parent::__construct($unused, $dn, $object);
parent::__construct($dn, $object, $parent, $mainTab);
$this->stats = $this->overview_stats();
}
......
......@@ -53,9 +53,9 @@ class dashboardUsers extends simplePlugin
);
}
function __construct($unused, $dn = NULL, $object = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
parent::__construct($unused, $dn, $object);
parent::__construct($dn, $object, $parent, $mainTab);
$this->users_stats = $this->computeUsersStats();
$this->groups_stats = $this->computeGroupsStats();
......
......@@ -20,8 +20,6 @@
class aclAssignmentDialogWindow extends simplePlugin
{
protected $mainTab = TRUE;
static function plInfo()
{
return array(
......@@ -63,9 +61,9 @@ class aclAssignmentDialogWindow extends simplePlugin
);
}
function __construct ($unused, $value, $isContainer = FALSE)
function __construct ($value, $isContainer = FALSE)
{
parent::__construct($unused);
parent::__construct(NULL, NULL, NULL, TRUE);
if ($isContainer) {
$this->attributesAccess['aclMode']->setDefaultValue('subtree');
} else {
......@@ -144,7 +142,7 @@ class ACLsAssignmentDialog extends GenericDialog
$isContainer = TRUE;
}
$this->attribute = $attribute;
$this->dialog = new $this->dialogClass(NULL, $acl, $isContainer);
$this->dialog = new $this->dialogClass($acl, $isContainer);
$this->dialog->set_acl_base($simplePlugin->acl_base);
$this->initialAclValue = $acl;
}
......@@ -292,9 +290,9 @@ class aclAssignment extends simplePlugin
);
}
function __construct ($unused, $dn = NULL, $object = NULL, $attributesInfo = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
parent::__construct ($unused, $dn, $object);
parent::__construct ($dn, $object, $parent, $mainTab);
$this->attributesInfo['main']['name'] = sprintf(_('Assignments on object or subtree %s'), $this->dn);
}
......
......@@ -70,7 +70,6 @@ class ACLsAttribute extends DialogOrderedArrayAttribute
class aclRole extends simplePlugin
{
var $objectclasses = array('top','gosaRole');
var $mainTab = TRUE;
static function plInfo()
{
......@@ -119,12 +118,5 @@ class aclRole extends simplePlugin
),
);
}
function __construct ($unused, $dn = NULL, $object = NULL)
{
parent::__construct($unused, $dn, $object);
$this->attributesAccess['cn']->setUnique(TRUE);
}
}
?>
......@@ -26,7 +26,6 @@ class department extends simplePlugin
/* Do not append the structural object classes here, they are added dynamically in the constructor */
var $objectclasses = array("top", "gosaDepartment");
var $structuralOC = array("organizationalUnit");
var $mainTab = TRUE;
static function plInfo()
{
......@@ -120,7 +119,7 @@ class department extends simplePlugin
return $attributesInfo;
}
function __construct ($unused, $dn = NULL, $object = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
/* Add the default structural object class if this is a new entry */
......@@ -143,7 +142,7 @@ class department extends simplePlugin
}
$this->objectclasses = array_unique($this->objectclasses);
parent::__construct($unused, $dn, $object);
parent::__construct($dn, $object, $parent, $mainTab);
$categoriesList = $config->get_cfg_value('DepartmentCategories', array());
......
......@@ -22,7 +22,6 @@
class group extends simplePlugin
{
var $mainTab = TRUE;
var $objectclasses = array('posixGroup');
static function plInfo()
......@@ -107,9 +106,9 @@ class group extends simplePlugin
);
}
function __construct ($unused, $dn = NULL, $object = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
parent::__construct($unused, $dn, $object);
parent::__construct($dn, $object, $parent, $mainTab);
$this->attributesAccess['trustMode']->setInLdap(FALSE);
$this->attributesAccess['trustMode']->setManagedAttributes(
......
......@@ -79,7 +79,7 @@ class groupManagement extends simpleManagement
if (class_available($plug['CLASS'])) {
$name = $plug['CLASS'];
$grouptabs[$name] = new $name(NULL, $dn);
$grouptabs[$name] = new $name($dn);
}
}
}
......
......@@ -130,7 +130,6 @@ class ObjectSelectDialog extends GenericSelectDialog
class ogroup extends simplePlugin
{
var $mainTab = TRUE;
var $objectclasses = array('groupOfNames', 'gosaGroupOfNames');
var $used_workstations = array();
......@@ -229,10 +228,10 @@ class ogroup extends simplePlugin
);
}
function __construct ($unused, $dn = NULL, $object = NULL)
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
parent::__construct($unused, $dn, $object);
parent::__construct($dn, $object, $parent, $mainTab);
$this->attributesAccess['trustMode']->setInLdap(FALSE);
$this->attributesAccess['trustMode']->setManagedAttributes(
......
......@@ -47,8 +47,6 @@ class RoleMembersAttribute extends UsersAttribute
class roleGeneric extends simplePlugin
{
var $mainTab = TRUE;
var $objectclasses = array('organizationalRole');
static function plInfo()
......@@ -109,14 +107,5 @@ class roleGeneric extends simplePlugin
)
);
}
/*!
* \brief Constructor
*/
function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($unused, $dn, $object);
$this->attributesAccess['cn']->setUnique(TRUE);
}
}
?>
......@@ -107,16 +107,15 @@ class ogrouptabs extends simpleTabs_noSpecial
function addTab ($class)
{
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class, "Adding tab ");
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class, 'Adding tab ');
$plInfos = pluglist::pluginInfos($class);
$this->by_name["$class"] = $plInfos['plShortName'];
if (isset($this->removed_tabs["$class"])) {
$this->by_object["$class"] = $this->removed_tabs["$class"];
unset($this->removed_tabs["$class"]);
$this->by_name[$class] = $plInfos['plShortName'];
if (isset($this->removed_tabs[$class])) {
$this->by_object[$class] = $this->removed_tabs[$class];
unset($this->removed_tabs[$class]);
} else {
$this->by_object["$class"] = new $class(NULL, $this->dn, $this->getBaseObject());
$this->by_object["$class"]->parent = &$this;
$this->by_object["$class"]->set_acl_category($this->acl_category);
$this->by_object[$class] = new $class($this->dn, $this->getBaseObject(), $this, FALSE);
$this->by_object[$class]->set_acl_category($this->acl_category);
}
}
......
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