diff --git a/plugins/admin/systems/class_serverService.inc b/plugins/admin/systems/class_serverService.inc
index bfdb7373c2f2b8ad04b7d008e95f577241e6bd8a..c6fe5415b98048d84e02d6bb63c32bd89dd97ce7 100644 (file)
define("START_SERVICE",1);
define("STOP_SERVICE",2);
-define("RESET_SERVICE",3);
+define("RESTART_SERVICE",3);
define("SERVICE_STOPPED",_("Stop"));
define("SERVICE_STARTED",_("Start"));
-define("SERVICE_RESETTED",_("Restart"));
+define("SERVICE_RESTARTED",_("Restart"));
define("ALL_SERVICES",100);
var $current = "";
var $backup = NULL;
var $acl ;
+ var $cn;
function ServerService ($config, $dn)
{
plugin::plugin($config);
$this->dn= $dn;
- $ui= get_userinfo();
- $this->acl= get_permissions ($ui->dn, $ui->subtreeACL);
-
foreach ($config->data['TABS']['SERVERSERVICE'] as $plug){
$name= $plug['CLASS'];
$this->plugin_names[]= $name;
$this->plugins[$name]= new $name($config, $dn);
- $this->plugins[$name]->acl= get_module_permission($this->acl, "$name", $ui->dn);
}
-
$this->divList = new divListSystemService($config,$this);
}
+ function set_acl_base($base)
+ {
+ plugin::set_acl_base($base);
+ foreach($this->plugins as $name => $obj){
+ $this->plugins[$name]->set_acl_base($base);
+ }
+ }
+
+ function set_acl_category($category)
+ {
+ plugin::set_acl_category($category);
+ foreach($this->plugins as $name => $obj){
+ $this->plugins[$name]->set_acl_category($category);
+ }
+ }
function execute()
{
$PossiblePosts = array("addNewService" => "",
"startServices" => "",
"stopServices" => "",
- "resetServices" => "",
+ "restartServices" => "",
"removeServices" => "",
"StartSingleService" => "/^StartSingleService_(.*)_[xy]$/",
"StopSingleService" => "/^StopSingleService_(.*)_[xy]$/",
- "ResetSingleService" => "/^ResetSingleService_(.*)_[xy]$/",
+ "RestartSingleService" => "/^RestartSingleService_(.*)_[xy]$/",
"RemoveSingleService" => "/^RemoveSingleService_(.*)_[xy]$/",
"EditSingleService" => "/^EditSingleService_(.*)_[xy]$/");
/* Handle state changes for services */
- $map = array( "startServices" => array("type" => START_SERVICE , "service" => ALL_SERVICES),
- "stopServices" => array("type" => STOP_SERVICE , "service" => ALL_SERVICES),
- "resetServices" => array("type" => RESET_SERVICE , "service" => ALL_SERVICES),
- "StartSingleService" => array("type" => START_SERVICE , "service" => $s_entry),
- "StopSingleService" => array("type" => STOP_SERVICE , "service" => $s_entry),
- "ResetSingleService" => array("type" => RESET_SERVICE , "service" => $s_entry));
+ $map = array( "startServices" => array("type" => START_SERVICE , "service" => ALL_SERVICES),
+ "stopServices" => array("type" => STOP_SERVICE , "service" => ALL_SERVICES),
+ "restartServices" => array("type" => RESTART_SERVICE , "service" => ALL_SERVICES),
+ "StartSingleService" => array("type" => START_SERVICE , "service" => $s_entry),
+ "StopSingleService" => array("type" => STOP_SERVICE , "service" => $s_entry),
+ "RestartSingleService" => array("type" => RESTART_SERVICE , "service" => $s_entry));
if(isset($map[$s_action])){
$type = $map[$s_action]['type'];
$service = $map[$s_action]['service'];
/* Remove service */
if($s_action == "RemoveSingleService"){
- $this->plugins[$s_entry]->is_account= false;
- $this->plugins[$s_entry] = NULL;
- $this->plugins[$s_entry] = new $s_entry($this->config,$this->dn);
- $this->plugins[$s_entry]->acl = $this->acl;
- $this->plugins[$s_entry]->is_account = false;
+
+ /* Create resetted obj */
+ $new_obj = new $s_entry($this->config,$this->dn);
+ $new_obj -> set_acl_base($this->acl_base);
+ $new_obj -> set_acl_category(preg_replace("/\/$/","",$this->acl_category));
+ $tmp = $new_obj->getListEntry();
+
+ if($tmp['AllowRemove']){
+ $this->plugins[$s_entry] = $new_obj;
+ $this->plugins[$s_entry]->is_account = false;
+ }
}
if(isset($_POST['CancelService'])){
if($this->backup == NULL){
$this->plugins[$this->current] = new $this->current($this->config,$this->dn);
+ $this->plugins[$this->current]-> set_acl_base($this->acl_base);
+ $this->plugins[$this->current]-> set_acl_category(preg_replace("/\/$/","",$this->acl_category));
+
}else{
foreach($this->backup as $name => $value){
$this->plugins[$this->current]->$name = $value;
/* Abort dialog */
if(isset($_POST['SaveService'])){
-
+ $this->dialog->save_object();
$msgs = $this->dialog->check();
if(count($msgs)){
foreach($msgs as $msg){
}
}else{
$this->plugins[$this->current] = $this->dialog;
+ $tmp = get_object_vars($this->dialog);
+ foreach($tmp as $name => $value){
+ $this->plugins[$this->current]->$name = $value;
+ }
$this->current = "";
$this->dialog = NULL;
$this->backup = NULL;
/* Abort dialog */
- if(isset($_POST['SaveServiceAdd'])){
+ if((isset($_POST['SaveServiceAdd'])) && (!empty($_POST['ServiceName']))){
$serv = $_POST['ServiceName'];
$this->plugins[$serv]->is_account = true;
$this->dialog = $this->plugins[$serv];
/* Dispaly services overview */
$this->divList->execute();
$list = array();
+
foreach($this->plugins as $name => $obj){
if($obj->is_account){
- $list[$name] = $obj->getListEntry();
+ $list[$name] = $this->plugins[$name]->getListEntry();
}
}
$this->divList -> setEntries($list);
}
}
}
+
+ /* Only show createable services */
+ if(!$obj->acl_is_createable()){
+ $skip = true;
+ }
+
if(!$skip){
if(isset($obj->DisplayName)){
$ret[$name] = $obj->DisplayName;
$action = SERVICE_STARTED;
}elseif($method== STOP_SERVICE){
$action = SERVICE_STOPPED;
- }elseif($method == RESET_SERVICE){
- $action = SERVICE_RESETTED;
+ }elseif($method == RESTART_SERVICE){
+ $action = SERVICE_RESTARTED;
}else{
print_red(sprintf(_("The specified method '%s' can't executed for services."),$action));
return;
}
+ $caseVars = array("cn","dn");
if($service == ALL_SERVICES){
foreach($this->plugins as $name => $obj){
- if($this->plugins[$name]->is_account){
- $this->plugins[$name]->setStatus($action);
+ foreach($caseVars as $var){
+ if(isset($this->$var)){
+ $this->plugins[$name]->$var = $this->$var;
+ }
+ }
+
+ /* check if services can be restarted */
+ $map =array(SERVICE_STARTED=> "AllowStart" ,
+ SERVICE_STOPPED => "AllowStop",
+ SERVICE_RESTARTED => "AllowRestart");
+
+ /* get plugins informations, restart/start/stop actions allowed ?*/
+ $tmp = $this->plugins[$name]->getListEntry();
+
+ /* Check if given action is allowed for this service */
+ if($tmp[$map[$action]]){
+ if($this->plugins[$name]->initially_was_account && $this->plugins[$name]->is_account){
+ $this->plugins[$name]->setStatus($action);
+ }
}
}
}else{
+ foreach($caseVars as $var){
+ if(isset($this->$var)){
+ $this->plugins[$service]->$var = $this->$var;
+ }
+ }
if($this->plugins[$service]->is_account){
$this->plugins[$service]->setStatus($action);
}