Commit de642330 authored by Benoit Mortier's avatar Benoit Mortier
Browse files

Fixes: #1650 Undefined property: sambaAccount::

parent b9df906b
......@@ -1032,7 +1032,7 @@ class phoneAccount extends plugin
/* Show tab dialog headers */
if (!$this->multiple_support_active && $this->parent !== NULL){
if ($this->parent !== NULL){
if ($this->is_account){
$display= $this->show_disable_header(_("Remove phone account"),
msgPool::featuresEnabled(_("Phone")));
......@@ -1269,7 +1269,6 @@ class phoneAccount extends plugin
/* Show main page */
$this->lastmacro = $this->macro;
$smarty->assign("multiple_support",$this->multiple_support_active);
$display.= $smarty->fetch(get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
return($display);
}
......
......@@ -172,32 +172,29 @@ class gofaxAccount extends plugin
$display = "";
if(!$this->multiple_support_active){
/* Do we need to flip is_account state? */
if (isset($_POST['modify_state'])){
$this->is_account= !$this->is_account;
}
/* Do we need to flip is_account state? */
if (isset($_POST['modify_state'])){
$this->is_account= !$this->is_account;
}
/* Do we represent a valid account? */
if (!$this->is_account && $this->parent === NULL){
$display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\">&nbsp;<b>".
msgPool::noValidExtension(_("GOfax"))."</b>";
$display.= back_to_main();
return ($display);
}
/* Do we represent a valid account? */
if (!$this->is_account && $this->parent === NULL){
$display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\">&nbsp;<b>".
msgPool::noValidExtension(_("GOfax"))."</b>";
$display.= back_to_main();
return ($display);
}
/* Show tab dialog headers */
$display= "";
if ($this->parent !== NULL){
if ($this->is_account){
$display= $this->show_disable_header(_("Remove fax account"),
msgPool::featuresEnabled(_("GOfax")));
} else {
$display= $this->show_enable_header(_("Create fax account"),
msgPool::featuresDisabled(_("GOfax")));
return ($display);
}
/* Show tab dialog headers */
$display= "";
if ($this->parent !== NULL){
if ($this->is_account){
$display= $this->show_disable_header(_("Remove fax account"),
msgPool::featuresEnabled(_("GOfax")));
} else {
$display = $this->show_enable_header(_("Create fax account"),
msgPool::featuresDisabled(_("GOfax")));
return $display;
}
}
......
......@@ -288,46 +288,43 @@ class mailgroup extends plugin
Account status
****************/
if(!$this->multiple_support_active){
if(isset($_POST['modify_state'])){
if($this->is_account && $this->acl_is_removeable() && $this->mailMethod->accountRemoveAble()){
$this->is_account= FALSE;
}elseif(!$this->is_account && $this->acl_is_createable() && $this->mailMethod->accountCreateable()){
$this->is_account= TRUE;
}
if(isset($_POST['modify_state'])){
if($this->is_account && $this->acl_is_removeable() && $this->mailMethod->accountRemoveAble()){
$this->is_account= FALSE;
}elseif(!$this->is_account && $this->acl_is_createable() && $this->mailMethod->accountCreateable()){
$this->is_account= TRUE;
}
}
if ($this->is_account){
$reason = "";
if(!$this->mailMethod->accountRemoveable($reason)){
$display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
}else{
$display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::
featuresEnabled(_("Mail")));
}
} else {
$reason = "";
if(!$this->mailMethod->accountCreateable($reason)){
$display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
}else{
$display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::
featuresDisabled(_("Mail")));
/* Show checkbox that allows us to remove imap entry too*/
if($this->initially_was_account){
$c = "";
if($this->remove_folder_from_imap){
$c= " checked ";
}
$display .= "<h2>Shared folder delete options</h2>
<input class='center' type='checkbox' name='remove_folder_from_imap' value='1' ".$c."
title='"._("Remove shared folder from mail server database when entry gets removed in LDAP")."'>";
$display .= _("Remove the shared folder and all its contents after saving this account");
if ($this->is_account){
$reason = "";
if(!$this->mailMethod->accountRemoveable($reason)){
$display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
}else{
$display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::
featuresEnabled(_("Mail")));
}
} else {
$reason = "";
if(!$this->mailMethod->accountCreateable($reason)){
$display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
}else{
$display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::
featuresDisabled(_("Mail")));
/* Show checkbox that allows us to remove imap entry too*/
if($this->initially_was_account){
$c = "";
if($this->remove_folder_from_imap){
$c= " checked ";
}
$display .= "<h2>Shared folder delete options</h2>
<input class='center' type='checkbox' name='remove_folder_from_imap' value='1' ".$c."
title='"._("Remove shared folder from mail server database when entry gets removed in LDAP")."'>";
$display .= _("Remove the shared folder and all its contents after saving this account");
}
return ($display);
}
return ($display);
}
......@@ -537,7 +534,6 @@ class mailgroup extends plugin
$smarty->assign("Forward_all",$this->gosaMailForwardingAddress);
$smarty->assign("Forward_some",$this->gosaMailForwardingAddress_Some);
$smarty->assign("multiple_support",$this->multiple_support_active);
$display.= $smarty->fetch (get_template_path('mail.tpl', TRUE, dirname(__FILE__)));
return ($display);
......@@ -1117,12 +1113,6 @@ class mailgroup extends plugin
$this->gosaMailForwardingAddress[]= $address;
$this->gosaMailForwardingAddress= array_unique($this->gosaMailForwardingAddress);
/* Update multiple edit values too */
if($this->multiple_support_active){
$this->gosaMailForwardingAddress_Some=
array_remove_entries (array($address),$this->gosaMailForwardingAddress_Some);
}
sort ($this->gosaMailForwardingAddress);
reset ($this->gosaMailForwardingAddress);
$this->is_modified= TRUE;
......@@ -1137,11 +1127,6 @@ class mailgroup extends plugin
$this->gosaMailForwardingAddress= array_remove_entries ($addresses,
$this->gosaMailForwardingAddress);
/* Update multiple edit values too */
if($this->multiple_support_active){
$this->gosaMailForwardingAddress_Some = array_remove_entries ($addresses,
$this->gosaMailForwardingAddress_Some);
}
$this->is_modified= TRUE;
}
......
......@@ -27,11 +27,8 @@ class netgroup extends plugin {
var $description = "";
var $netgroups = array();
var $netgroups_used_by_some = array();
var $triples = array();
var $triples_used_by_some = array();
var $allusers = array();
var $users_used_by_some = array();
var $nisNetgroupTriple = array();
var $memberNisNetgroup = array();
......@@ -281,19 +278,6 @@ class netgroup extends plugin {
$smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
$smarty->assign("deplist", $this->config->idepartments);
/* Multiple edit handling */
$smarty->assign("multiple_support", $this->multiple_support_active);
/* $tmp_members=array();
$tmp_members_used_by_some=array();
foreach ($this->triples_used_by_some as $key => $value) {
$tmp_members_used_by_some[$key]=$value;
}
foreach ($this->netgroups_used_by_some as $key => $value) {
$tmp_members_used_by_some[$key]=$value;
}
*/
$smarty->assign("memberCn_All", $this->allusers);
$smarty->assign("memberCn_Some", $this->users_used_by_some);
......@@ -316,24 +300,6 @@ class netgroup extends plugin {
}
function addUser($uid, $objectClass, $dn) {
/* In mutliple edit we have to handle two arrays.
* triples : Containing users used in all netgroups
* triples_used_by_some : Those which are not used in all netgroups
* So we have to remove the given $uid from the ..used_by_some array first.
*/
if ($this->multiple_support_active) {
if (isset($this->netgroups_used_by_some[$uid])) {
unset($this->netgroups_used_by_some[$uid]);
unset($this->dnMapping[$uid]);
unset($this->users_used_by_some[$uid]);
}
if (isset($this->triples_used_by_some[$uid])) {
unset($this->triples_used_by_some[$uid]);
unset($this->dnMapping[$uid]);
unset($this->users_used_by_some[$uid]);
}
}
/* Ensure that the requested object is known to the netgroup class
*/
if (!isset($this->dnMapping[$uid])) {
......@@ -379,24 +345,6 @@ class netgroup extends plugin {
unset($this->dnMapping[$uid]);
unset($this->allusers[$uid]);
}
/* We have two array contianing netgroup members in multiple edit.
* this->triples : Netgroups used by all currently edited netgroups
* this->triples_used_by_some: Used by some
* So we have to remove the specified uid from both arrays.
*/
if ($this->multiple_support_active) {
if (isset($this->triples_used_by_some[$uid])) {
unset($this->triples_used_by_some[$uid]);
unset($this->dnMapping[$uid]);
unset($this->users_used_by_some[$uid]);
}
if (isset($this->netgroups_used_by_some[$uid])) {
unset($this->netgroups_used_by_some[$uid]);
unset($this->dnMapping[$uid]);
unset($this->users_used_by_some[$uid]);
}
}
}
/* Reload data and put in the list */
......@@ -408,11 +356,6 @@ class netgroup extends plugin {
$regex = normalizeLdap($nngufilter['regex']);
$MaxUser = $this->OnlyShowFirstEntries;
/* if ($this->multiple_support_active) {
$this->allusers=array();
$this->users_used_by_some=array();
}
*/
/* Prepare ldap link */
$ldap = $this->config->get_ldap_link();
$ldap->cd($nngufilter['dselect']);
......@@ -475,80 +418,6 @@ class netgroup extends plugin {
}
}
if ($this->multiple_support_active) {
$triplesfilter_used_by_some = "";
if ($this->config->get_cfg_value("ldapFilterNestingLimit") == "" ||
count($this->triples_used_by_some) < $this->config->get_cfg_value("ldapFilterNestingLimit")) {
foreach (array_keys($this->triples_used_by_some) as $value) {
if (!isset($this->members[$value])) {
$triplesfilter_used_by_some .= "(|(cn=" . normalizeLdap($value) . ")(uid=" . normalizeLdap($value) . "))";
}
}
}
/* Search in all the tree for the component of this triple */
if (!empty($triplesfilter_used_by_some)) {
$ldap->cd($this->config->current['BASE']);
$ldap->search("(&(|(objectClass=posixAccount)(objectClass=GOhard)(objectClass=ieee802Device))(|" . $triplesfilter_used_by_some . "))", array("dn", "cn", "uid", "sn", "givenName", "description", "objectClass"));
while ($attrs = $ldap->fetch()) {
$selector = "uid";
$objectClass = "posixAccount";
for ($i = 0; $i < $attrs['objectClass']['count']; $i++) {
if ($attrs['objectClass'][$i] == "goServer") {
$selector = "cn";
$objectClass = "goServer";
break;
}
if ($attrs['objectClass'][$i] == "gotoWorkstation") {
$selector = "cn";
$objectClass = "gotoWorkstation";
break;
}
if ($attrs['objectClass'][$i] == "GOhard") {
$selector = "cn";
$objectClass = "GOhard";
}
if ($attrs['objectClass'][$i] == "ieee802Device") {
$selector = "cn";
$objectClass = "ieee802Device";
break;
}
}
$value = $attrs[$selector][0];
$this->dnMapping[$value] = $attrs['dn'];
$this->members[$value] = $this->createResultName($attrs, $objectClass);
$this->users_used_by_some[$value] = $this->createResultName($attrs, $objectClass);
}
}
/* Create a filter with all the netgroups that no appear in $this->members */
$netgroupfilter_used_by_some = "";
if ($this->config->get_cfg_value("ldapFilterNestingLimit") == "" ||
count($this->netgroups_used_by_some) < $this->config->get_cfg_value("ldapFilterNestingLimit")) {
foreach (array_keys($this->netgroups_used_by_some) as $value) {
if (!isset($this->members[$value])) {
$netgroupfilter_used_by_some .= "(cn=" . normalizeLdap($value) . ")";
}
}
}
/* Search in all the tree for the component of this netgroup */
if (!empty($netgroupfilter_used_by_some)) {
$ldap->cd($this->config->current['BASE']);
$ldap->search("(&(objectClass=nisNetgroup)(|" . $netgroupfilter_used_by_some . "))", array("dn", "cn", "description"));
while ($attrs = $ldap->fetch()) {
$selector = "cn";
$value = $attrs[$selector][0];
$this->dnMapping[$value] = $attrs['dn'];
$this->members[$value] = $this->createResultName($attrs, "nisNetgroup");
$this->users_used_by_some[$value] = $this->createResultName($attrs, "nisNetgroup");
}
}
}
/* Search in all the tree for the component of this netgroup */
if (!empty($netgroupfilter)) {
$ldap->cd($this->config->current['BASE']);
......@@ -897,153 +766,6 @@ class netgroup extends plugin {
)
);
}
function multiple_save_object() {
if (isset($_POST['group_mulitple_edit'])) {
/* Create a base backup and reset the
base directly after calling plugin::save_object();
Base will be set seperatly a few lines below */
$base_tmp = $this->base;
plugin::multiple_save_object();
plugin::save_object();
$this->base = $base_tmp;
foreach (array("base") as $attr) {
if (isset($_POST['use_' . $attr])) {
$this->multi_boxes[] = $attr;
}
}
/* Refresh base */
if ($this->acl_is_moveable($this->base)) {
if (!$this->baseSelector->update()) {
msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
}
if ($this->base != $this->baseSelector->getBase()) {
$this->base = $this->baseSelector->getBase();
$this->is_modified = TRUE;
}
}
}
}
function get_multi_edit_values() {
$ret = plugin::get_multi_edit_values();
foreach (array("base") as $attr) {
if (in_array($attr, $this->multi_boxes)) {
$ret[$attr] = $this->$attr;
}
}
$ret['memberCn'] = $this->allusers;
$ret['memberCn_used_by_some'] = $this->users_used_by_some;
$ret['triples'] = $this->triples;
$ret['triples_used_by_some'] = $this->triples_used_by_some;
$ret['netgroups'] = $this->netgroups;
$ret['netgroups_used_by_some'] = $this->netgroups_used_by_some;
return($ret);
}
function multiple_execute() {
return($this->execute());
}
/* Initialize plugin with given atribute arrays
*/
function init_multiple_support($attrs, $all) {
plugin::init_multiple_support($attrs, $all);
$this->members=array();
$this->allusers=array();
$this->users_used_by_some=array();
$this->netgroups = array();
$this->netgroups_used_by_some = array();
if (isset($attrs['memberNisNetgroup'])) {
for ($i = 0; $i < $attrs['memberNisNetgroup']['count']; $i++) {
$this->netgroups[$attrs['memberNisNetgroup'][$i]] = $attrs['memberNisNetgroup'][$i];
}
ksort($this->netgroups);
}
if (isset($all['memberNisNetgroup'])) {
for ($i = 0; $i < $all['memberNisNetgroup']['count']; $i++) {
if (!in_array($all['memberNisNetgroup'][$i], $this->netgroups)) {
$this->netgroups_used_by_some[$all['memberNisNetgroup'][$i]] = $all['memberNisNetgroup'][$i];
}
}
ksort($this->netgroups_used_by_some);
}
$this->triples = array();
$this->triples_used_by_some = array();
if (isset($attrs['nisNetgroupTriple'])) {
for ($i = 0; $i < $attrs['nisNetgroupTriple']['count']; $i++) {
if (preg_match("/^\((\S+),\-?,(\S*)\)$/", $attrs['nisNetgroupTriple'][$i], $matches)) {
//Removing host.domain entries
if(strpos($matches[1],".")===false){
$this->triples[$matches[1]] = $attrs['nisNetgroupTriple'][$i];
}
}
if (preg_match("/^\(\-?,(\S+),(\S*)\)$/", $attrs['nisNetgroupTriple'][$i], $matches)) {
$this->triples[$matches[1]] = $attrs['nisNetgroupTriple'][$i];
}
}
ksort($this->triples);
}
if (isset($all['nisNetgroupTriple'])) {
for ($i = 0; $i < $all['nisNetgroupTriple']['count']; $i++) {
if (!in_array($all['nisNetgroupTriple'][$i], $this->triples)) {
if (preg_match("/^\((\S+),\-?,(\S*)\)$/", $all['nisNetgroupTriple'][$i], $matches)) {
//Removing host.domain entries
if(strpos($matches[1],".")===false){
$this->triples_used_by_some[$matches[1]] = $all['nisNetgroupTriple'][$i];
}
}
if (preg_match("/^\(\-?,(\S+),(\S*)\)$/", $all['nisNetgroupTriple'][$i], $matches)) {
$this->triples_used_by_some[$matches[1]] = $all['nisNetgroupTriple'][$i];
}
}
}
ksort($this->triples_used_by_some);
}
$this->reload();
}
function set_multi_edit_values($attrs) {
$triples = array();
$netgroups = array();
/* Update netgroupMembership, keep optinal netgroup */
foreach ($attrs['triples_used_by_some'] as $uid => $value) {
if (in_array($uid, array_keys($this->triples))) {
$triples[$uid] = $value;
}
}
foreach ($attrs['netgroups_used_by_some'] as $uid => $value) {
if (in_array($uid, array_keys($this->netgroups))) {
$netgroups[$uid] = $value;
}
}
/* Update netgroupMembership, add forced netgroups */
foreach ($attrs['triples'] as $uid => $value) {
$triples[$uid] = $value;
}
foreach ($attrs['netgroups'] as $uid => $value) {
$netgroups[$uid] = $value;
}
plugin::set_multi_edit_values($attrs);
$this->triples = $triples;
$this->netgroups = $netgroups;
//$this->memberCn = $users;
}
}
?>
......@@ -161,10 +161,6 @@ class netgroupSystem extends plugin {
/* Members and users */
$smarty->assign("members", $this->members);
/* Multiple edit handling */
$smarty->assign("multiple_support", $this->multiple_support_active);
$tmp = $this->plInfo();
foreach ($tmp['plProvidedAcls'] as $name => $translation) {
$smarty->assign($name . "ACL", $this->getacl($name));
......
......@@ -122,10 +122,6 @@ class netgroupAccount extends plugin {
if (isset($_POST['del_users']) && isset($_POST['members']) && preg_match("/w/", $this->getacl("triples"))) {
foreach ($_POST['members'] as $value) {
unset($this->members["$value"]);
if ($this->multiple_support_active) {
unset($this->netgroups_all["$value"]);
unset($this->netgroups_some["$value"]);
}
}
}
......@@ -152,9 +148,6 @@ class netgroupAccount extends plugin {
$attrs = $headpage->getEntry($dn);
$desc=""; if(isset($attrs['description'])) $desc=$attrs['description'];
$this->members[$attrs['cn'][0]] = $attrs['cn'][0]."[".$desc."]";
if ($this->multiple_support_active) {
$this->netgroups_all[$attrs['cn'][0]] = $attrs['cn'][0]."[".$desc."]";
}
}
}
$this->userSelect = NULL;
......@@ -195,10 +188,6 @@ class netgroupAccount extends plugin {
/* Members and users */
$smarty->assign("members", $this->members);
/* Multiple edit handling */
$smarty->assign("multiple_support", $this->multiple_support_active);
$tmp = $this->plInfo();
foreach ($tmp['plProvidedAcls'] as $name => $translation) {
$smarty->assign($name . "ACL", $this->getacl($name));
......
......@@ -246,30 +246,26 @@ class sambaAccount extends plugin
return ($display);
}
$display ="";
if(!$this->multiple_support_active){
// Show tab heades to activate and deactivate the samba extension.
$display= "";
if ($this->parent !== NULL){
if ($this->is_account){
$display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Samba")),
msgPool::featuresEnabled(_("Samba")));
} else {
// Samba3 dependency on posix accounts are enabled in the moment, because I need to rely on unique
// uidNumbers. There'll be a better solution later on.
$obj= $this->parent->by_object['posixAccount'];
if ($obj->is_account){
$display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
msgPool::featuresDisabled(_("Samba")));
} else {
$display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
msgPool::featuresDisabled(_("Samba"), _("POSIX")), TRUE);
}
return ($display);
}
$display = "";
// Show tab heades to activate and deactivate the samba extension.
if ($this->parent !== NULL) {
if ($this->is_account) {
$display = $this->show_disable_header(msgPool::removeFeaturesButton(_("Samba")),
msgPool::featuresEnabled(_("Samba")));