RELEASE 0.9.8.1

This commit is contained in:
Deon George
2009-06-30 20:26:45 +10:00
parent fdee1bdbd1
commit abc62c7fdc
9 changed files with 149 additions and 63 deletions

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/functions.php,v 1.283.2.30 2006/01/15 13:05:52 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/functions.php,v 1.283.2.32 2006/02/19 03:00:40 wurley Exp $
/**
* A collection of functions used throughout phpLDAPadmin.
@@ -12,6 +12,7 @@ define('LANGDIR',sprintf('%s/',realpath(LIBDIR.'../locale/')));
define('CONFDIR',sprintf('%s/',realpath(LIBDIR.'../config')));
define('TMPLDIR',sprintf('%s/',realpath(LIBDIR.'../templates/')));
define('DOCDIR',sprintf('%s/',realpath(LIBDIR.'../doc/')));
define('HOOKSDIR',sprintf('%s/',realpath(LIBDIR.'../hooks/')));
define('CSSDIR','css/');
define('JSDIR','js/');
@@ -1254,7 +1255,7 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu
if ($width > 300) {
$scale_factor = 300 / $width;
$img_width = 300;
$img_height = $height * $scale_factor;
$img_height = intval($height * $scale_factor);
} else {
$img_width = $width;

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/hooks.php,v 1.6 2005/04/15 13:16:59 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/hooks.php,v 1.6.4.1 2006/01/26 11:49:15 wurley Exp $
/**
* Functions related to hooks management.
@@ -171,8 +171,8 @@ function clear_hooks ( $hook_name ) {
}
/* Evaluating user-made hooks */
if ( is_dir('hooks') ) {
$dir = dir ('hooks');
if ( is_dir(HOOKSDIR) ) {
$dir = dir (HOOKSDIR);
while (false !== ($entry = $dir -> read() ) ) {
if ( is_file ("hooks/$entry") and eregi ('php[0-9]?$', $entry) ) {

View File

@@ -1,5 +1,5 @@
<?php
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.34.2.24 2006/01/15 13:05:52 wurley Exp $ */
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.34.2.28 2006/02/25 14:08:54 wurley Exp $ */
/**
* Classes and functions for LDAP server configuration and capability
@@ -336,7 +336,8 @@ class LDAPserver {
if ($this->connect()) {
$r = array_pop($this->search(null,'','objectClass=*',array('namingContexts'),'base'));
$r = array_change_key_case($r);
if (is_array($r))
$r = array_change_key_case($r);
if (isset($r['namingcontexts'])) {
if (! is_array($r['namingcontexts']))
@@ -414,12 +415,12 @@ class LDAPserver {
global $config;
if ($this->connect(false) && $this->haveAuthInfo() && ! $this->isReadOnly() &&
! $config->GetValue('appearance','tree_plm')) {
! $config->GetValue('appearance','tree_plm') &&
$config->GetValue('appearance','mass_delete') === true)
$config->GetValue('appearance','mass_delete') === true;
return true;
} else
else
return false;
}
@@ -1135,7 +1136,7 @@ class LDAPserver {
with its name set to the alias name, and all other data copied.*/
foreach ($aliases as $alias_attr_name) {
# clone is a PHP5 function and must be used.
if (function_exists('clone'))
if (version_compare(PHP_VERSION,'5.0') > 0 )
$new_attr = clone($attr);
else
$new_attr = $attr;
@@ -1435,8 +1436,12 @@ class LDAPserver {
# Delete entry from parent's children as well.
$parent = get_container($dn);
$index = array_search($dn,$tree['browser'][$parent]['children']);
unset($tree['browser'][$parent]['children'][$index]);
# If the parent hasnt been opened in the tree, then there wont be any children.
if (isset($tree['browser'][$parent]['children'])) {
$index = array_search($dn,$tree['browser'][$parent]['children']);
unset($tree['browser'][$parent]['children'][$index]);
}
# Might be worthwhile adding it to our miss list, while we are here.
$tree['misses'][$dn] = true;
@@ -2433,11 +2438,14 @@ class LDAPserver {
get_class($this),$dn,$lower_case_attr_names,$deref);
$attrs = array_pop($this->search(null,dn_escape($dn),'(objectClass=*)',array(),'base',false,$deref));
if ($lower_case_attr_names)
$attrs = array_change_key_case($attrs);
if (is_array($attrs))
if (is_array($attrs)) {
if ($lower_case_attr_names)
$attrs = array_change_key_case($attrs);
ksort($attrs);
}
return $attrs;
}

View File

@@ -1,5 +1,5 @@
<?php
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.29.2.15 2005/12/31 04:26:34 wurley Exp $ */
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.29.2.18 2006/02/25 12:14:17 wurley Exp $ */
/**
* Classes and functions for the template engine.ation and capability
@@ -441,11 +441,31 @@ class Templates {
list($command,$arg) = split(':',$value);
switch ($command) {
#autoFill:attr,string (with %attr%)
#@todo: The autofill mods need to be more flexible, so that multiple can be used eg: /T/l
/*
autoFill:string
string is a literal string, and may contain many fields like %attr|start-end/flags%
to substitute values read from other fields.
|start-end is optional, but must be present if the k flag is used.
/flags is optional.
flags may be:
T: Read display text from selection item (drop-down list), otherwise, read the value of the field
For fields that aren't selection items, /T shouldn't be used, and the field value will always be read.
k: Tokenize:
If the "k" flag is not given:
A |start-end instruction will perform a sub-string operation upon
the value of the attr, passing character positions start-end through.
start can be 0 for first character, or any other integer.
end can be 0 for last character, or any other integer for a specific position.
If the "k" flag is given:
The string read will be split into fields, using : as a delimiter
"start" indicates which field number to pass through.
l: Make the result lower case.
U: Make the result upper case.
*/
case 'autoFill' :
list($attr,$string) = split(',',$arg);
preg_match_all('/%(\w+)(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U',$string,$matchall);
preg_match_all('/%(\w+)(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%/U',$string,$matchall);
//print"<PRE>";print_r($matchall); //0 = highlevel match, 1 = attr, 2 = subst, 3 = mod
if (! isset($_js_hash['autoFill'.$origin]))
@@ -476,44 +496,50 @@ class Templates {
$_js_hash['autoFill'.$origin] .= sprintf(" var %s;\n",$match_attr);
if (trim($match_subst)) {
preg_match_all('/([0-9]*)-([0-9]*)/',$match_subst,$substrarray);
}
if ($match_mod == '/T') {
if (strstr($match_mod,'T')) {
$_js_hash['autoFill'.$origin] .= sprintf(
" %s = document.getElementById('%s').options[document.getElementById('%s').selectedIndex].text;\n",
$match_attr,$match_attr,$match_attr);
} else {
$_js_hash['autoFill'.$origin] .= sprintf(" %s = document.getElementById('%s').value;\n",
$match_attr,$match_attr);
}
if (strstr($match_mod,'k')) {
preg_match_all('/([0-9]+)/',trim($match_subst),$substrarray);
if (isset($substrarray[1][0])) {
$tok_idx = $substrarray[1][0];
} else {
$tok_idx = '0';
}
$_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.split(':')[%s];\n",$match_attr,$match_attr,$tok_idx);
} else {
preg_match_all('/([0-9]*)-([0-9]*)/',trim($match_subst),$substrarray);
if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) {
$_js_hash['autoFill'.$origin] .= sprintf(' %s = document.getElementById("%s").value.substr(%s,%s)',
$_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.substr(%s,%s);\n",
$match_attr,$match_attr,
$substrarray[1][0] ? $substrarray[1][0] : '0',
$substrarray[2][0] ? $substrarray[2][0] : sprintf('document.getElementById("%s").value.length',$match_attr));
} else {
$_js_hash['autoFill'.$origin] .= sprintf(' %s = document.getElementById(\'%s\').value',
$match_attr,$match_attr);
$substrarray[2][0] ? $substrarray[2][0] : sprintf('%s.length',$match_attr));
}
}
switch ($match_mod) {
case '/l':
$_js_hash['autoFill'.$origin] .= '.toLowerCase()';
break;
}
$_js_hash['autoFill'.$origin] .= ";\n";
if (strstr($match_mod,'l')) {
$_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.toLowerCase();\n",$match_attr,$match_attr);
}
if (strstr($match_mod,'U')) {
$_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.toUpperCase();\n",$match_attr,$match_attr);
}
# Matchfor only entry without modifiers.
$formula = preg_replace('/^%('.$match_attr.')%$/U','$1 + \'\'',$formula);
# Matchfor only entry with modifiers.
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','$1 + \'\'',$formula);
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%$/U','$1 + \'\'',$formula);
# Matchfor begining entry.
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','$1 + \'',$formula);
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%/U','$1 + \'',$formula);
# Matchfor ending entry.
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','\' + $1 ',$formula);
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%$/U','\' + $1 ',$formula);
# Match for entries not at begin/end.
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','\' + $1 + \'',$formula);
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[:lTU]+)?%/U','\' + $1 + \'',$formula);
}
$_js_hash['autoFill'.$origin] .= sprintf(" fillRec('%s', %s);\n",$attr,$formula);
@@ -562,6 +588,7 @@ class Templates {
$picklistvalues = return_ldap_hash($ldapserver,$container,$args[1],$args[2],$ldap_attrs);
$detail['value'] = sprintf('<select name="form[%s]" id="%%s" %%s %%s>',(isset($args[4]) ? $args[4] : $args[2]));
$counter = 0;
foreach ($picklistvalues as $key => $values) {
$display = $args[3];
@@ -570,8 +597,8 @@ class Templates {
}
if (! isset($picklist[$display])) {
$detail['value'] .= sprintf('<option id="%s" value="%s" %s>%s</option>',
$display,$values[$args[2]],
$detail['value'] .= sprintf('<option id="%s%s" value="%s" %s>%s</option>',
(isset($args[4]) ? $args[4] : $args[2]),++$counter,$values[$args[2]],
($default == $display ? 'selected' : ''),
$display);
$picklist[$display] = true;
@@ -602,8 +629,8 @@ class Templates {
$varname = $matches[1];
if (isset($_POST['form']['post'][$varname]))
$function_args[] = $_POST['form']['post'][$varname];
if (isset($_POST['form'][$varname]))
$function_args[] = $_POST['form'][$varname];
else
pla_error(sprintf(_('Your template calls php.Function for a default value, however (%s) is NOT available in the POST FORM variables. The following variables are available [%s].'),$varname,
(isset($_POST['form']) ? implode('|',array_keys($_POST['form'])) : 'NONE')));
@@ -614,7 +641,7 @@ class Templates {
# Call the PHP function if exists (PHP 4 >= 4.0.4, PHP 5)
if (function_exists($function_name))
$detail['value'] = call_user_func_array($function_name,$args);
$detail['value'] = call_user_func_array($function_name,$function_args);
break;