index 2641a0b5f3de7d250728a676c5aae691be8c6b77..f7ec6810c13d5504306cd059b7a515dd3c2d5828 100644 (file)
var $FAIclass = ""; // Classnames used for this profile
var $FAIclasses = array(); // Contains classname seperated in an array
var $FAIAllclasses = array(); // Contains all possible Classnames
-
+ var $ui ;
var $FAIstate = "";
+ var $view_logged = FALSE;
function faiProfile($config, $dn= NULL)
{
plugin::plugin ($config, $dn);
$ldap=$this->config->get_ldap_link();
- $this->acl = "#all#";
-
- if($this->dn != "new"){
- /* Set acls
- */
- $ui = get_userinfo();
- $acl = get_permissions ($this->dn, $ui->subtreeACL);
- $acli = get_module_permission($acl, "FAIclass", $this->dn);
- $this->acl=$acli;
- }
+ $this->ui = get_userinfo();
/* Parse ldap attribute to get all assigned classes */
$tmp = split(" ",$this->FAIclass);
return($ret);
}
+
+ function acl_base_for_current_object($dn)
+ {
+ if($dn == "new"){
+ if($this->dn == "new"){
+ $dn= $_SESSION['CurrentMainBase'];
+ }else{
+ $dn = $this->dn;
+ }
+ }
+ return($dn);
+ }
+
+
/* returns position in array */
function getpos($atr,$attrs)
{
{
/* Call parent execute */
plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","fai/".get_class($this),$this->dn);
+ }
+
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
/* Remove class name From list */
$sort_once = false;
foreach($_POST as $name => $post){
- if(preg_match("/DEL_/i",$name)){
+ if(preg_match("/DEL_/i",$name) && $this->acl_is_writeable("FAIclass")){
$s_action = "delete";
$s_entry = preg_replace("/DEL_/","",$name);
$s_entry = base64_decode(preg_replace("/_.*$/","",$s_entry));
- }elseif(preg_match("/Add_class/i",$name)){
+ }elseif(preg_match("/Add_class/i",$name)&& $this->acl_is_writeable("FAIclass")){
$s_action = "add";
- }elseif(preg_match("/DelClass/i",$name)){
+ }elseif(preg_match("/DelClass/i",$name) && $this->acl_is_writeable("FAIclass")){
$s_action = "delete";
$s_entry = $_POST['FAIclass'];
- }elseif(preg_match("/AddClass/i",$name)){
+ }elseif(preg_match("/AddClass/i",$name) && $this->acl_is_writeable("FAIclass")){
$s_action = "add";
}
/* Check if a list element should be pushed one position up */
- if((preg_match("/sortup_/",$name))&&(!$sort_once)){
+ if((preg_match("/sortup_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
$sort_once = true;
$val = preg_replace("/sortup_/","",$name);
$val = preg_replace("/_.*$/","",$val);
}
/* Check if a list element should be pushed one position down */
- if((preg_match("/sortdown_/",$name))&&(!$sort_once)){
+ if((preg_match("/sortdown_/",$name))&&(!$sort_once) && $this->acl_is_writeable("FAIclass")){
$sort_once = true;
$val = preg_replace("/sortdown_/","",$name);
$val = preg_replace("/_.*$/","",$val);
}
- if($s_action == "delete"){
+ if($s_action == "delete" && $this->acl_is_writeable("FAIclass")){
unset($this->FAIclasses[$s_entry]);
}
- if($s_action == "add"){
+ if($s_action == "add" && $this->acl_is_writeable("FAIclass")){
$this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses);
$this->is_dialog =true;
}
$linkupdown.= "<input type='image' name='sortdown_%s' alt='down' title='"._("Down")."' src='images/sort_down.png' >";
/* Append fai classes to divlist */
- foreach($this->FAIclasses as $usedClass){
- $str = " ";
+ if($this->acl_is_readable("FAIclass")){
+ foreach($this->FAIclasses as $usedClass){
+ $str = " ";
+ $act = "";
+
+ if(isset($this->FAIAllclasses[$usedClass])){
+ foreach($this->FAIAllclasses[$usedClass] as $class => $obj){
+ $str.= $objTypes[$class];
+ }
+ }
- if(isset($this->FAIAllclasses[$usedClass])){
- foreach($this->FAIAllclasses[$usedClass] as $class => $obj){
- $str.= $objTypes[$class];
+ $field1 = array("string"=> $usedClass,"attach"=>"");
+ $field2 = array("string"=> $str,"attach"=>"");
+ if(($this->FAIstate != "freeze") && $this->acl_is_writeable("FAIclass")){
+ $field3 = array("string"=> preg_replace("/%KEY%/",base64_encode($usedClass),$actions).
+ preg_replace("/%s/",base64_encode($usedClass),$linkupdown),
+ "attach"=>"style='border-right:none;'");
+ }else{
+ $field3 = array("string"=>" ", "attach"=>"style='border-right:none;'");
}
+ $divlist->AddEntry(array($field1,$field2,$field3));
}
-
- $field1 = array("string"=> $usedClass,"attach"=>"");
- $field2 = array("string"=> $str,"attach"=>"");
- if($this->FAIstate != "freeze"){
- $field3 = array("string"=> preg_replace("/%KEY%/",base64_encode($usedClass),$actions).
- preg_replace("/%s/",base64_encode($usedClass),$linkupdown),
- "attach"=>"style='border-right:none;'");
- }else{
- $field3 = array("string"=>" ", "attach"=>"style='border-right:none;'");
- }
- $divlist->AddEntry(array($field1,$field2,$field3));
}
$smarty->assign("FAIclasses" ,$this->FAIclasses);
}
}
- foreach($this->attributes as $attr){
- if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){
- $smarty->assign($attr."ACL"," disabled ");
- }else{
- $smarty->assign($attr."ACL"," ");
- }
+
+ $dn = $this->acl_base_for_current_object($this->dn);
+ $smarty->assign("sub_object_is_addable",
+ preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiScriptEntry")) &&
+ !preg_match("/freeze/",$this->FAIstate));
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translated){
+ $smarty->assign($name."ACL",$this->getacl($name));
}
$display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE));
$use_dn = $this->dn;
}
+ new log("remove","fai/".get_class($this),$use_dn,$this->attributes);
prepare_to_save_FAI_object($use_dn,array(),true);
$this->handle_post_events("remove");
}
function save_object()
{
plugin::save_object();
- foreach($this->attributes as $attrs){
- if(isset($_POST[$attrs])){
- $this->$attrs = $_POST[$attrs];
- }
- }
}
$this->attrs['FAIclass']=trim($this->FAIclass);
prepare_to_save_FAI_object($this->dn,$this->attrs);
-
+
+ if($this->initially_was_account){
+ new log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+ }else{
+ new log("create","fai/".get_class($this),$this->dn,$this->attributes);
+ }
+
show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/profile with dn '%s' failed."),$this->dn));
/* Do object tagging */
"plDescription" => _("FAI profile"),
"plSelfModify" => FALSE,
"plDepends" => array(),
- "plPriority" => 28,
+ "plPriority" => 30,
"plSection" => array("administration"),
"plCategory" => array("fai"),
"plProvidedAcls" => array(