FusionDirectory
 All Data Structures Files Functions Variables
class_simpleService.inc
1 <?php
2 
3 /*
4  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
5  Copyright (C) 2011-2016 FusionDirectory
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21 
25 class simpleService extends simplePlugin {
26 
27  var $status = "";
28 
29  var $conflicts = array();
30  var $dn = NULL;
31  var $cn = "";
32  var $DisplayName = "";
33  var $view_logged = FALSE;
34  var $showActions = TRUE;
35 
43  function __construct ($dn = NULL, $parent = NULL, $attributesInfo = NULL)
44  {
45  /* $parent is the instance of serverService in this case, we set it as parent */
46  parent::__construct($dn, $parent, $parent, FALSE, $attributesInfo);
47  $plInfos = pluglist::pluginInfos(get_class($this));
48  $this->DisplayName = $plInfos['plShortName'];
49  }
50 
53  function execute()
54  {
55  if ($this->is_account && !$this->view_logged) {
56  $this->view_logged = TRUE;
57  logging::log('view', 'server/'.get_class($this), $this->dn);
58  }
59 
60  $str = parent::execute();
61 
62  if (!$this->dialog) {
63  $str .= '<div class="plugbottom servicebottom">'.
64  ' <input type="submit" name="SaveService" value="'.msgPool::saveButton().'"/>&nbsp;'.
65  ' <input type="submit" name="CancelService" value="'.msgPool::cancelButton().'"/>'.
66  '</div>';
67  }
68 
69  return $str;
70  }
71 
72  protected function acl_skip_write()
73  {
74  return FALSE;
75  }
76 
78  function getListEntry()
79  {
80  /* Assign status flag */
81  $fields['Status'] = $this->status;
82 
83  /* Name displayed in service overview */
84  $fields['Message'] = $this->DisplayName;
85 
86  if ($this->showActions && is_object($this->parent->parent) && isset($this->parent->parent->by_object['argonautClient']) && $this->parent->parent->by_object['argonautClient']->is_account) {
87  /* Allow/disallow some functions */
88  $fields['AllowStatus'] = ($this->status == "") && $this->acl_is_writeable("start");
89  $fields['AllowStart'] = ($this->status == "stopped") && $this->acl_is_writeable("start");
90  $fields['AllowStop'] = ($this->status == "running") && $this->acl_is_writeable("stop");
91  $fields['AllowRestart'] = ($this->status == "running") && $this->acl_is_writeable("restart");
92  } else {
93  /* Disable some functions */
94  $fields['AllowStatus'] = FALSE;
95  $fields['AllowStart'] = FALSE;
96  $fields['AllowStop'] = FALSE;
97  $fields['AllowRestart'] = FALSE;
98  }
99 
100  $fields['AllowRemove'] = $this->acl_is_removeable();
101  $fields['AllowEdit'] = $this->acl_is_readable("");
102 
103  return $fields;
104  }
105 
107  function setStatus($value)
108  {
109  /* Can't set status flag for new services (Object doesn't exists in ldap tree) */
110  if (!$this->initially_was_account) {
111  return;
112  }
113 
114  $this->status = $value;
115  }
116 }
117 ?>
$parent
Reference to parent object.
This class is made for easy plugin creation for editing LDAP attributes.
__construct($dn=NULL, $parent=NULL, $attributesInfo=NULL)
constructor
acl_is_readable($attribute)
Can we read the acl.
acl_is_removeable($base=NULL)
Can we delete the object.
acl_is_writeable($attribute, $skipWrite=FALSE)
Can we write the attribute.
getListEntry()
Get service information for serverService plugin.
execute()
This function display the service and return the html code.
This class is made for easy service creation for editing LDAP attributes.
static log($action, $objecttype, $object, array $changes_array=array(), $result= '')
logging method
$attributesInfo
This attribute store all information about attributes.
setStatus($value)
This function save new status flag.