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

Merge branch '5742-acl-handling-for-start-stop-restart-service-is-broken' into '1.3-dev'

Resolve "ACL handling for start/stop/restart service is broken"

See merge request fusiondirectory/fd!90
Showing with 26 additions and 21 deletions
+26 -21
<?php <?php
/* /*
This code is part of FusionDirectory (http://www.fusiondirectory.org/) This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2011-2016 FusionDirectory Copyright (C) 2011-2017 FusionDirectory
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -22,16 +21,14 @@ ...@@ -22,16 +21,14 @@
/*! \brief This class is made for easy service creation for editing LDAP attributes /*! \brief This class is made for easy service creation for editing LDAP attributes
* *
*/ */
class simpleService extends simplePlugin { class simpleService extends simplePlugin
{
protected static $showActions = TRUE;
var $status = ""; protected $status = '';
var $conflicts = array(); public $conflicts = array();
var $dn = NULL; public $DisplayName = '';
var $cn = "";
var $DisplayName = "";
var $view_logged = FALSE;
var $showActions = TRUE;
/*! \brief constructor /*! \brief constructor
* *
...@@ -52,11 +49,6 @@ class simpleService extends simplePlugin { ...@@ -52,11 +49,6 @@ class simpleService extends simplePlugin {
*/ */
function execute() function execute()
{ {
if ($this->is_account && !$this->view_logged) {
$this->view_logged = TRUE;
logging::log('view', 'server/'.get_class($this), $this->dn);
}
$str = parent::execute(); $str = parent::execute();
if (!$this->dialog) { if (!$this->dialog) {
...@@ -83,12 +75,12 @@ class simpleService extends simplePlugin { ...@@ -83,12 +75,12 @@ class simpleService extends simplePlugin {
/* Name displayed in service overview */ /* Name displayed in service overview */
$fields['Message'] = $this->DisplayName; $fields['Message'] = $this->DisplayName;
if ($this->showActions && is_object($this->parent->parent) && isset($this->parent->parent->by_object['argonautClient']) && $this->parent->parent->by_object['argonautClient']->is_account) { if (static::$showActions && is_object($this->parent->parent) && isset($this->parent->parent->by_object['argonautClient']) && $this->parent->parent->by_object['argonautClient']->is_account) {
/* Allow/disallow some functions */ /* Allow/disallow some functions */
$fields['AllowStatus'] = ($this->status == "") && $this->acl_is_writeable("start"); $fields['AllowStatus'] = ($this->status == '') && $this->acl_is_writeable('simpleServiceStatus');
$fields['AllowStart'] = ($this->status == "stopped") && $this->acl_is_writeable("start"); $fields['AllowStart'] = ($this->status == 'stopped') && $this->acl_is_writeable('simpleServiceStart');
$fields['AllowStop'] = ($this->status == "running") && $this->acl_is_writeable("stop"); $fields['AllowStop'] = ($this->status == 'running') && $this->acl_is_writeable('simpleServiceStop');
$fields['AllowRestart'] = ($this->status == "running") && $this->acl_is_writeable("restart"); $fields['AllowRestart'] = ($this->status == 'running') && $this->acl_is_writeable('simpleServiceRestart');
} else { } else {
/* Disable some functions */ /* Disable some functions */
$fields['AllowStatus'] = FALSE; $fields['AllowStatus'] = FALSE;
...@@ -98,7 +90,7 @@ class simpleService extends simplePlugin { ...@@ -98,7 +90,7 @@ class simpleService extends simplePlugin {
} }
$fields['AllowRemove'] = $this->acl_is_removeable(); $fields['AllowRemove'] = $this->acl_is_removeable();
$fields['AllowEdit'] = $this->acl_is_readable(""); $fields['AllowEdit'] = $this->acl_is_readable('');
return $fields; return $fields;
} }
...@@ -113,5 +105,18 @@ class simpleService extends simplePlugin { ...@@ -113,5 +105,18 @@ class simpleService extends simplePlugin {
$this->status = $value; $this->status = $value;
} }
static function generatePlProvidedAcls ($attributesInfo)
{
$acls = parent::generatePlProvidedAcls($attributesInfo);
if (static::$showActions) {
$acls ['simpleServiceStatus'] = _('Get service status');
$acls ['simpleServiceStart'] = _('Start service');
$acls ['simpleServiceStop'] = _('Stop service');
$acls ['simpleServiceRestart'] = _('Restart service');
}
return $acls;
}
} }
?> ?>
Supports Markdown
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