roundcubemail/program/lib/Roundcube/rcube_ldap.php
protected function add_autovalues(&$attrs)
    {
        if (empty($this->prop['autovalues'])) {
            return;
        }

        $attrvals = array();
        foreach ($attrs as $k => $v) {
            $attrvals['{'.$k.'}'] = is_array($v) ? $v[0] : $v;
        }

        foreach ((array)$this->prop['autovalues'] as $lf => $templ) {
            if (empty($attrs[$lf])) {
                if (strpos($templ, '(') !== false) {
                    // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd
                    $code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals)));
                    $res  = false;

                    try {
                        $res = eval("return ($code);");
                    }
                    catch (ParseError $e) {
                        // ignore
                    }

                    if ($res === false) {
                        rcube::raise_error(array(
                            'code' => 505, 'file' => __FILE__, 'line' => __LINE__,
                            'message' => "Expression parse error on: ($code)"), true, false);
                        continue;
                    }

                    $attrs[$lf] = $res;
                }
                else {
                    // replace {attr} placeholders with concrete attribute values
                    $attrs[$lf] = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals));
                }
            }
        }
    }
protected function add_autovalues(&$attrs)
    {
        if (empty($this->prop['autovalues'])) {
            return;
        }

        $attrvals = array();
        foreach ($attrs as $k => $v) {
            $attrvals['{'.$k.'}'] = is_array($v) ? $v[0] : $v;
        }

        foreach ((array)$this->prop['autovalues'] as $lf => $templ) {
            if (empty($attrs[$lf])) {
                if (strpos($templ, '(') !== false) {
                    // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd
                    $code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals)));
                    $res  = false;

                    try {
                        $res = eval("return ($code);");
                    }
                    catch (ParseError $e) {
                        // ignore
                    }

                    if ($res === false) {
                        rcube::raise_error(array(
                            'code' => 505, 'file' => __FILE__, 'line' => __LINE__,
                            'message' => "Expression parse error on: ($code)"), true, false);
                        continue;
                    }

                    $attrs[$lf] = $res;
                }
                else {
                    // replace {attr} placeholders with concrete attribute values
                    $attrs[$lf] = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals));
                }
            }
        }
    }
protected function add_autovalues ( & $ attrs ) { if ( empty ( $ this -> prop [ 'autovalues' ] ) ) { return ; } $ attrvals = array ( ) ; foreach ( $ attrs as $ k => $ v ) { $ attrvals [ '{' . $ k . '}' ] = is_array ( $ v ) ? $ v [ 0 ] : $ v ; } foreach ( ( array ) $ this -> prop [ 'autovalues' ] as $ lf => $ templ ) { if ( empty ( $ attrs [ $ lf ] ) ) { if ( strpos ( $ templ , '(' ) !== false ) { // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd $ code = preg_replace ( '/\{\w+\}/' , '' , strtr ( $ templ , array_map ( 'addslashes' , $ attrvals ) ) ) ; $ res = false ; try { $ res = eval ( "return ($code);" ) ; } catch ( ParseError $ e ) { // ignore } if ( $ res === false ) { rcube :: raise_error ( array ( 'code' => 505 , 'file' => __FILE__ , 'line' => __LINE__ , 'message' => "Expression parse error on: ($code)" ) , true , false ) ; continue ; } $ attrs [ $ lf ] = $ res ; } else { // replace {attr} placeholders with concrete attribute values $ attrs [ $ lf ] = preg_replace ( '/\{\w+\}/' , '' , strtr ( $ templ , $ attrvals ) ) ; } } } }
Generate missing attributes as configured

@param array LDAP record attributes
Generate missing attributes as configured