index 6f9b053ab1368a8eb0040aaaf4f8516af3322c9c..a05c6a1c0de4fbb3195d818ada9e9cd70fd6ec28 100644 (file)
class termgroup extends plugin
{
/* attribute list for save action */
class termgroup extends plugin
{
/* attribute list for save action */
- var $attributes= array("gotoMode","gotoSyslogServer", "gotoNtpServer");
- var $objectclasses= array("gotoWorkstationTemplate");
-
var $members= array();
var $gotoMode = "locked";
var $members= array();
var $gotoMode = "locked";
var $gotoNtpServers = array();
var $modes = array();
var $inheritTimeServer = true;
var $gotoNtpServers = array();
var $modes = array();
var $inheritTimeServer = true;
- var $acl ;
var $is_account = true;
var $orig_dn = "";
var $didAction = FALSE;
var $is_account = true;
var $orig_dn = "";
var $didAction = FALSE;
- var $mapActions = array("reboot" => "",
+ var $mapActions = array("reboot" => "localboot",
"instant_update" => "softupdate",
"update" => "sceduledupdate",
"reinstall" => "install",
"instant_update" => "softupdate",
"update" => "sceduledupdate",
"reinstall" => "install",
"memcheck" => "memcheck",
"sysinfo" => "sysinfo");
"memcheck" => "memcheck",
"sysinfo" => "sysinfo");
+ var $attributes = array("gotoMode","gotoSyslogServer", "gotoNtpServer");
+ var $objectclasses = array("gotoWorkstationTemplate");
+ var $CopyPasteVars = array("gotoNtpServers","modes","inheritTimeServer","members");
+ var $view_logged = FALSE;
+
- function termgroup ($config, $dn= NULL)
+ function termgroup ($config, $dn= NULL, $parent= NULL)
{
/***************
Some initialisations
***************/
{
/***************
Some initialisations
***************/
- plugin::plugin($config, $dn);
+ plugin::plugin($config, $dn, $parent);
$ldap= $config->get_ldap_link();
$this->is_account = true;
$ldap= $config->get_ldap_link();
$this->is_account = true;
- $ui = get_userinfo();
- $acl = get_permissions ($this->dn, $ui->subtreeACL);
- $this->acl = get_module_permission($acl, "group", $this->dn);
-
$this->modes["active"]= _("Activated");
$this->modes["locked"]= _("Locked");
// $this->modes["memcheck"]= _("Memory test");
$this->modes["active"]= _("Activated");
$this->modes["locked"]= _("Locked");
// $this->modes["memcheck"]= _("Memory test");
unset($this->gotoNtpServers[$key]);
}
}
unset($this->gotoNtpServers[$key]);
}
}
-
-
}
function check()
}
function check()
/* Call common method to give check the hook */
$message= plugin::check();
/* Call common method to give check the hook */
$message= plugin::check();
- if (chkacl($this->acl, "create") != ""){
+ if (!$this->acl_is_createable() && $this->dn == "new"){
$message[]= _("You have no permissions to create a workstation on this 'Base'.");
}
$message[]= _("You have no permissions to create a workstation on this 'Base'.");
}
$ldap->cd($this->orig_dn);
$ldap->modify($this->attrs);
$this->handle_post_events("remove");
$ldap->cd($this->orig_dn);
$ldap->modify($this->attrs);
$this->handle_post_events("remove");
+ @log::log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
+
+ function update_term_member_FAIstate($act)
+ {
+ /* Get required informations */
+ $og = $this->parent->by_object['ogroup'];
+ $allobs = $og->objcache;
+
+ /* Get correct value for FAIstate */
+ $action = $this->mapActions[$act];
+
+ /* Get ldap connection */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->config->current['BASE']);
+
+ /* Foreach member of mthis ogroup ... */
+ foreach($og->member as $key ){
+
+ /* check objectClasses and create attributes array */
+ $attrs = array("FAIstate"=>$action);
+ for($i = 0; $i < $allobs[$key]['objectClass']['count'] ; $i ++){
+ $attrs['objectClass'][] = $allobs[$key]['objectClass'][$i];
+ }
+ if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+ $attrs['objectClass'][] = "FAIobject";
+ }
+ if($attrs['FAIstate'] == ""){
+ $attrs['FAIstate'] = array();
+ }
+
+ /* If this objects is workstation,terminal or server upodate FAIstate */
+ if(preg_match("/(w|t|s)/i",$allobs[$key]['type'])){
+ $ldap->cd ($key);
+ $ldap->modify($attrs);
+ show_ldap_error($ldap->get_error(),sprintf(_("Setting action state (FAIstate) failed for object '%s', value was '%s'."),$key,$action));
+ }
+ }
}
function execute()
}
function execute()
/* Call parent execute */
plugin::execute();
/* Call parent execute */
plugin::execute();
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ @log::log("view","ogroups/".get_class($this),$this->dn);
+ }
/***************
Handle requested action
/***************
Handle requested action
}
if (isset($_POST['action'])){
}
if (isset($_POST['action'])){
+
+ /* Update members fai state */
+ $this->update_term_member_FAIstate(trim($_POST['saction']));
+
$cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD");
if ($cmd == ""){
$cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD");
if ($cmd == ""){
/* Set government mode */
$smarty= get_smarty();
/* Set government mode */
$smarty= get_smarty();
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translated) {
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
foreach($this->attributes as $attr){
$smarty->assign($attr, $this->$attr);
foreach($this->attributes as $attr){
$smarty->assign($attr, $this->$attr);
- $smarty->assign($attr."ACL",chkacl($this->acl,$this->$attr));
}
/* Variables */
foreach(array("gotoMode","gotoNtpServer") as $val){
$smarty->assign($val."_select", $this->$val);
}
/* Variables */
foreach(array("gotoMode","gotoNtpServer") as $val){
$smarty->assign($val."_select", $this->$val);
- $smarty->assign($val."ACL", chkacl($this->acl, $val));
}
$smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
}
$smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
$smarty->assign("inheritTimeServer",$this->inheritTimeServer);
$smarty->assign("modes", $this->modes);
$smarty->assign("inheritTimeServer",$this->inheritTimeServer);
$smarty->assign("modes", $this->modes);
- $smarty->assign("actionACL", chkacl($this->acl, 'action'));
$tmp = array();
foreach($this->gotoNtpServers as $server){
$tmp = array();
foreach($this->gotoNtpServers as $server){
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
- if ($this->orig_dn == 'new'){
- $ldap->cd($this->config->current['BASE']);
- $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- if(!$this->didAction){
- $this->handle_post_events("add");
- }
- } else {
- if ($this->orig_dn != $this->dn){
- $this->move($this->orig_dn, $this->dn);
- }
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
- if(!$this->didAction){
- $this->handle_post_events("modify");
- }
+ if($this->initially_was_account){
+ @log::log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ @log::log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}
}
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/workstation with dn '%s' failed."),$this->dn));
+
+ if(!$this->didAction){
+ $this->handle_post_events("modify");
+ }
+ show_ldap_error($ldap->get_error(), _("Saving workstation failed"));
+
+ }
+
+ function plInfo()
+ {
+ return (array(
+ "plShortName" => _("System"),
+ "plDescription" => _("System group"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 5,
+ "plSection" => array("administration"),
+ "plCategory" => array("ogroups"),
+ "plProvidedAcls"=> array(
+ "gotoMode" => _("Mode"),
+ "gotoSyslogServer" => _("Syslog server"),
+ "FAIstate" => _("Action flag"),
+ "gotoNtpServer" => _("Ntp server"))
+ ));
}
}
+
+
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: