summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b0b8e9d)
raw | patch | inline | side by side (parent: b0b8e9d)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 5 Oct 2010 09:39:17 +0000 (09:39 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 5 Oct 2010 09:39:17 +0000 (09:39 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19917 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/functions.inc | patch | blob | history |
index b431063863966261ed028a83fab0b8fc0773b760..893d1431d386971e9c26885bb3daf41109d5f324 100644 (file)
}
-/*! \brief Recursion helper for gen_id() */
-function recurse($rule, $variables)
-{
- $result= array();
-
- if (!count($variables)){
- return array($rule);
- }
-
- reset($variables);
- $key= key($variables);
- $val= current($variables);
- unset ($variables[$key]);
-
- foreach($val as $possibility){
- $nrule= str_replace("{$key}", $possibility, $rule);
- $result= array_merge($result, recurse($nrule, $variables));
- }
-
- return ($result);
-}
-
-
-/*! \brief Expands user ID based on possible rules
- *
- * Unroll given rule string by filling in attributes.
- *
- * \param string 'rule' The rule string from gosa.conf.
- * \param array 'attributes' A dictionary of attribute/value mappings
- * \return string Expanded string, still containing the id keyword.
- */
-function expand_id($rule, $attributes)
-{
- /* Check for id rule */
- if(preg_match('/^id(:|#|!)\d+$/',$rule)){
- return (array("{$rule}"));
- }
-
- /* Check for clean attribute */
- if (preg_match('/^%[a-zA-Z0-9]+$/', $rule)){
- $rule= preg_replace('/^%/', '', $rule);
- $val= rewrite(str_replace(' ', '', strtolower($attributes[$rule])));
- return (array($val));
- }
-
- /* Check for attribute with parameters */
- if (preg_match('/^%[a-zA-Z0-9]+\[[0-9-]+\]$/', $rule)){
- $param= preg_replace('/^[^[]+\[([^]]+)]$/', '\\1', $rule);
- $part= preg_replace('/^%/', '', preg_replace('/\[.*$/', '', $rule));
- $val= rewrite(str_replace(' ', '', strtolower($attributes[$part])));
- $start= preg_replace ('/-.*$/', '', $param);
- $stop = preg_replace ('/^[^-]+-/', '', $param);
-
- /* Assemble results */
- $result= array();
- for ($i= $start; $i<= $stop; $i++){
- $result[]= substr($val, 0, $i);
- }
- return ($result);
- }
-
- echo "Error in idGenerator string: don't know how to handle rule $rule.\n";
- return (array($rule));
-}
-
-
/*! \brief Convert various data sizes to bytes
*
* Given a certain value in the format n(g|m|k), where n