diff --git a/plugins/admin/fai/class_faiTemplateEntry.inc b/plugins/admin/fai/class_faiTemplateEntry.inc
index 160047b5dd2efd42b8c1cfaa3f947e1cadae0c1a..57eee41245f8440b826e34ff19138ea7672279f2 100644 (file)
var $user = "root";
var $group = "root";
var $binary = false;
+
+ var $FAIstate = "";
function faiTemplateEntry ($config, $dn= NULL,$object=false)
{
plugin::plugin ($config, $dn);
- if($dn != "new"){
+
+ if((isset($object['cn'])) && (!empty($object['cn']))){
$this->orig_cn= $object['cn'];
$this->dn=$object['dn'];
foreach($object as $name=>$value){
$oname = $name;
$this->$oname=$value;
}
+
+ if(isset($this->attrs['FAIstate'][0])){
+ $this->FAIstate = $this->attrs['FAIstate'][0];
+ }
+
}else{
$this->status = "new";
- $this->orig_cn = false;
+ $this->orig_cn= false;
}
+
$this->user = explode( '.', $this->FAIowner );
$this->group = $this->user[1];
$this->user = $this->user[0];
$this->FAImode= sprintf("%0.4s", $this->FAImode)." ";
}
+
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty = get_smarty();
$smarty->assign("rand", rand(0, 10000));
$this->FAItemplateFile = $str;
/* If we don't have a filename set it from upload filename. */
- if( 0 == strlen( $this->FAItemplatePath ) )
+ if( 0 == strlen( $this->FAItemplatePath )){
$this->FAItemplatePath = $_FILES['FAItemplateFile']['name'];
+ }
+
+ $_SESSION['binary'] = $this->FAItemplateFile;
+ $_SESSION['binarytype'] = 'octet-stream';
+ $_SESSION['binaryfile'] = basename( $this->FAItemplatePath );
}
-
}
$status= _("no file uploaded yet");
+
+ $bStatus = false; // Hide download icon on default
+
if(strlen($this->FAItemplateFile)){
$status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->FAItemplateFile));
+ $bStatus = true; // Display download icon
}
$smarty->assign("status",$status);
+ $smarty->assign("bStatus",$bStatus);
/* Magic quotes GPC, escapes every ' " \, to solve some security risks
* If we post the escaped strings they will be escaped again
$smarty->assign("FAItemplateFile","");
+ foreach($this->attributes as $attr){
+ if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){
+ $smarty->assign($attr."ACL"," disabled ");
+ }else{
+ $smarty->assign($attr."ACL"," ");
+ }
+ }
+
$display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE));
return($display);
}
if (!isset($_POST['FAItemplatePath'])){
return;
}
- if(isset($_POST['SubObjectFormSubmitted'])){
+ if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){
foreach($this->attributes as $attrs){
if($attrs == "FAItemplateFile")
continue;
$this->$attrs = "";
}
}
- }
-
- /* Save mode */
- $tmode= "";
- foreach (array("s", "u", "g", "o") as $type){
- $nr= 1;
- $dest= 0;
- while ($nr < 5){
- if (isset($_POST["$type$nr"])){
- $dest+= $nr;
+ /* Save mode */
+ $tmode= "";
+ foreach (array("s", "u", "g", "o") as $type){
+ $nr= 1;
+ $dest= 0;
+ while ($nr < 5){
+ if (isset($_POST["$type$nr"])){
+ $dest+= $nr;
+ }
+ $nr+= $nr;
}
- $nr+= $nr;
+ $tmode= $tmode.$dest;
}
- $tmode= $tmode.$dest;
+ $this->FAImode= $tmode;
}
- $this->FAImode= $tmode;
}
/* Check supplied data */
function check()
{
- $message= array();
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
if(empty($this->FAItemplateFile)){
$message[]=_("Please specify a value for attribute 'file'.");
}
$message[] = _("Please enter a user.");
}
elseif(preg_match("/[^0-9a-z]/i",$this->user)){
- $message[] = _("Please enter a valid user. Only a-Z 0-9 are allowed.");
+ $message[] = _("Please enter a valid user. Only a-z/0-9 are allowed.");
}
if(empty($this->group)){
$message[] = _("Please enter a group.");
}
elseif(preg_match("/[^0-9a-z]/i",$this->group)){
- $message[] = _("Please enter a valid group. Only a-Z 0-9 are allowed.");
+ $message[] = _("Please enter a valid group. Only a-z/0-9 are allowed.");
}
return ($message);