summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a6dc299)
raw | patch | inline | side by side (parent: a6dc299)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 5 Oct 2010 12:23:17 +0000 (12:23 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 5 Oct 2010 12:23:17 +0000 (12:23 +0000) |
-Allow to use placeholder in arrays
-Allow to use slices of variables by adding [n-m] to the variable to replace
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19918 594d385d-05f5-0310-b6e9-bd551577e9d8
-Allow to use slices of variables by adding [n-m] to the variable to replace
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19918 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_plugin.inc | patch | blob | history |
index d7a97a60e397d4d64aedc25553a1861a93bb543d..46d127d352fddc94e0b7fa4c2d29b9b465b91f99 100644 (file)
$ldap->cat ($dn);
$this->attrs= $ldap->fetch();
- /* Walk through attributes */
- foreach ($this->attributes as $val){
+ $values = array();
+ foreach($this->attributes as $name){
+ if(isset($this->parent->$name)){
+ $value = $this->parent->$name;
+ if(is_numeric($name)) continue;
+ if(is_string($value)) $values[$name] = $value;
+ if(is_array($value) && isset($value[0])) $values[$name] = $value[0];
+ }
+ }
- /* Skip the ones in skip list */
- if (in_array($val, $skip)){
- continue;
- }
+ foreach($this->attributes as $name){
- if (isset($this->attrs["$val"][0])){
+ // Skip the ones in skip list
+ if (in_array($name, $skip)) continue;
+ if (!isset($this->attrs[$name]['count'])) continue;
- /* If attribute is set, replace dynamic parts:
- %sn, %givenName and %uid. Fill these in our local variables. */
- $value= $this->attrs["$val"][0];
+ $value= $this->attrs[$name][0];
- foreach (array("sn", "givenName", "uid") as $repl){
- if (preg_match("/%$repl/i", $value)){
- $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
- }
+ if($this->attrs[$name]['count'] == 1){
+ $value = fillReplacements($this->attrs[$name][0], $values);
+ }else{
+ $value = array();
+ for($i=0;$i<$this->attrs[$name]['count'];$i++){
+ $value[] = fillReplacements($this->attrs[$name][$i], $values);
+ }
}
- $this->$val= $value;
- }
+
+ $this->$name = $value;
+ print_a(array($name => $value));
}
/* Is Account? */
$found= TRUE;
foreach ($this->objectclasses as $obj){
- if (preg_match('/top/i', $obj)){
- continue;
- }
+ if (preg_match('/top/i', $obj)) continue;
if (!in_array_ics ($obj, $this->attrs['objectClass'])){
$found= FALSE;
break;
}
}
- if ($found){
- $this->is_account= TRUE;
- }
+ $this->is_account = $found;
}
/* \brief Indicate whether a password change is needed or not */