index 0d1ea42a6652df1d9a77581eaf6810277d112c21..10f81c719542047b246f5f68c7dd0987689b1538 100644 (file)
var $subClassName = "faiTemplateEntry";
/* Attributes to initialise for each subObject */
- var $subAttributes = array("cn","description","FAItemplateFile","FAItemplatePath");
- var $sub64coded = array("FAItemplateFile","FAItemplatePath");
+ var $subAttributes = array("cn","description","FAItemplateFile","FAItemplatePath","FAIowner","FAImode");
+ var $sub64coded = array();
/* Specific attributes */
var $cn = ""; // The class name for this object
}
foreach($this->sub64coded as $codeIt){
- $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]);
+ $this->SubObjects[$object['cn'][0]][$codeIt]= base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]);
}
- $this->SubObjects[$object['cn'][0]]['FAItemplateFile'] =base64_decode($this->readBinary("FAItemplateFile",$object['dn']));
+ $this->SubObjects[$object['cn'][0]]['FAItemplateFile']= $this->readBinary("FAItemplateFile",$object['dn']);
- $this->SubObjects[$object['cn'][0]]['status'] = "edited";
- $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn'];
+ $this->SubObjects[$object['cn'][0]]['status']= "edited";
+ $this->SubObjects[$object['cn'][0]]['dn']= $object['dn'];
}
}
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
$this->is_dialog=true;
}
+ if($this->dn != "new"){
+ $_SESSION['objectinfo']= $this->dn;
+ }
+
+
/* Edit selected Sub Object */
if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){
- $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]);
+
+ $temp = $_POST['SubObject'][0];
+
+ $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$temp]);
+ $_SESSION['objectinfo'] = $this->SubObjects[$temp]['dn'];
$this->is_dialog=true;
}
/* Remove Sub object */
if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){
- if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){
- $this->SubObjects[$_POST['SubObject']]['status']= "delete";
- }else{
- unset($this->SubObjects[$_POST['SubObject']]);
+ foreach($_POST['SubObject'] as $temp){
+ if($this->SubObjects[$temp]['status'] == "edited"){
+ $this->SubObjects[$temp]['status']= "delete";
+ }else{
+ unset($this->SubObjects[$temp]);
+ }
}
}
}
}
+ /* Sort entries */
+ $tmp = $keys = array();
+ foreach($this->SubObjects as $key => $entry){
+ $keys[$key]=$key;
+ }
+ natcasesort($keys);
+ foreach($keys as $key){
+ $tmp[$key]=$this->SubObjects[$key];
+ }
+ $this->SubObjects = $tmp;
+
/* Cancel Dialog */
if(isset($_POST['CancelSubObject'])){
$this->is_dialog=false;
$smarty->assign("SubObjects",$this->getList());
$smarty->assign("SubObjectKeys",array_flip($this->getList()));
- /* Assign variables */
+
+ /* Magic quotes GPC, escapes every ' " \, to solve some security risks
+ * If we post the escaped strings they will be escaped again
+ */
foreach($this->attributes as $attrs){
- $smarty->assign($attrs,$this->$attrs);
+ if(get_magic_quotes_gpc()){
+ $smarty->assign($attrs,stripslashes($this->$attrs));
+ }else{
+ $smarty->assign($attrs,($this->$attrs));
+ }
}
+
$display.= $smarty->fetch(get_template_path('faiTemplate.tpl', TRUE));
return($display);
}
$a_return=array();
foreach($this->SubObjects as $obj){
if($obj['status'] != "delete"){
+
if((isset($obj['description']))&&(!empty($obj['description']))){
+ if(strlen($obj['description']) > 40){
+ $obj['description'] = substr($obj['description'],0,40)."...";
+ }
$a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]";
}else{
$a_return[$obj['cn']]= $obj['cn'];
*/
function save_object()
{
- plugin::save_object();
- foreach($this->attributes as $attrs){
- if(isset($_POST[$attrs])){
- $this->$attrs = $_POST[$attrs];
+ if(isset($_POST['FAItemplate_posted'])){
+ plugin::save_object();
+ foreach($this->attributes as $attrs){
+ if(isset($_POST[$attrs])){
+ $this->$attrs = $_POST[$attrs];
+ }
}
}
}
function check()
{
$message= array();
- $str = utf8_encode("üöä");
- if((preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){
- $message[]=_("Please enter a valid description.");
- }
return ($message);
}
if($ldap->count()!=0){
/* Write FAIscript to ldap*/
$ldap->cd($this->dn);
- $ldap->modify($this->attrs);
+ $this->cleanup();
+$ldap->modify ($this->attrs);
+
}else{
/* Write FAIscript to ldap*/
$ldap->cd($this->config->current['BASE']);
$this->handle_post_events("remove");
}elseif($obj['status'] == "edited"){
$ldap->cd($sub_dn);
- $ldap->modify($tmp);
+ $this->cleanup();
+$ldap->modify ($tmp);
+
$this->handle_post_events("modify");
}elseif($obj['status']=="new"){