mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-23 10:29:07 +01:00
Compare commits
3 commits
a8e0707e7a
...
e71823b644
Author | SHA1 | Date | |
---|---|---|---|
|
e71823b644 | ||
|
38fa02619d | ||
|
7f862c9765 |
85 changed files with 699 additions and 634 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
|||
upgrade.log
|
||||
*.sav
|
||||
*~
|
||||
vendor
|
||||
/src/local.*
|
||||
tests-report.xml
|
||||
|
|
18
.gitlab-ci.yml
Normal file
18
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
stages:
|
||||
- tests
|
||||
|
||||
tests:
|
||||
image: composer
|
||||
stage: tests
|
||||
rules:
|
||||
- changes:
|
||||
- src/*
|
||||
script:
|
||||
- composer install
|
||||
- ./vendor/bin/phpstan analyse --no-interaction --configuration=phpstan.neon --error-format=junit > tests-report.xml
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- tests-report.xml
|
||||
reports:
|
||||
junit: tests-report.xml
|
5
composer.json
Normal file
5
composer.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.9"
|
||||
}
|
||||
}
|
32
phpstan.neon
Normal file
32
phpstan.neon
Normal file
|
@ -0,0 +1,32 @@
|
|||
parameters:
|
||||
level: 1
|
||||
paths:
|
||||
- src
|
||||
excludePaths:
|
||||
- src/local
|
||||
- src/tmp
|
||||
# Error message "Class Smarty_Resource_LdapSaisie extends unknown class Smarty_Resource_Custom." cannot be ignored, use excludePaths instead.
|
||||
- src/includes/class/class.LStemplate_smarty3_support.php
|
||||
bootstrapFiles:
|
||||
- src/includes/core.php
|
||||
universalObjectCratesClasses:
|
||||
- LSsearch
|
||||
- LSsearchEntry
|
||||
- LSrelation
|
||||
- LSlog_handler
|
||||
- LSlog_logger
|
||||
- LSldapObject
|
||||
- LSurlRequest
|
||||
ignoreErrors:
|
||||
- "#Instantiated class (Smarty|Console_Table|ZxcvbnPhp\\\\Zxcvbn|phpseclib\\\\Crypt\\\\RSA|phpseclib\\\\Net\\\\SFTP|phpseclib\\\\Net\\\\SSH2|Net_FTP) not found\\.#"
|
||||
- "#Call to static method (connect|isError)\\(\\) on an unknown class Net_LDAP2\\.#"
|
||||
- "#(Class|Constant) (Net_LDAP2_Filter|Net_LDAP2_Entry|PEAR_Error) not found\\.#"
|
||||
- "#Call to static method (create|parse|combine|escape)\\(\\) on an unknown class Net_LDAP2_Filter\\.#"
|
||||
- "#Call to static method (createFresh)\\(\\) on an unknown class Net_LDAP2_Entry\\.#"
|
||||
- "#Call to static method (forceAuthentication|getUser|logout|setDebug|client|setNoCasServerValidation|setCasServerCACert|setExtraCurlOption)\\(\\) on an unknown class phpCAS\\.#"
|
||||
-
|
||||
message: "#Call to static method factory\\(\\) on an unknown class Mail\\.#"
|
||||
path: src/includes/addons/LSaddons.mail.php
|
||||
-
|
||||
message: "#Instantiated class Mail_mime not found\\.#"
|
||||
path: src/includes/addons/LSaddons.mail.php
|
|
@ -122,10 +122,6 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
|
|||
),
|
||||
),
|
||||
|
||||
'before_modify' => 'valid',
|
||||
'after_modify' => 'valid',
|
||||
//'after_create' => 'createMaildirByFTP',
|
||||
//'after_delete' => 'removeMaildirByFTP',
|
||||
'display_name_format' => '%{cn}',
|
||||
'label' => 'Users',
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ LSerror :: defineError('ASTERISK_03',
|
|||
}
|
||||
|
||||
$password = $ldapObject -> attrs[ LS_ASTERISK_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
|
||||
if (!$password or empty($password)) {
|
||||
if (!$password) {
|
||||
LSerror :: addErrorCode('ASTERISK_03');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -304,15 +304,15 @@ function triggerUpdateDynGroupsMembersCacheOnUserChanges(&$user, &$changed_attrs
|
|||
continue;
|
||||
}
|
||||
|
||||
$is_impacted = false;
|
||||
$impacted_attr = null;
|
||||
foreach($filter_attrs as $attr) {
|
||||
if (in_array(strtolower($attr), $changed_attrs)) {
|
||||
$is_impacted = true;
|
||||
$impacted_attr = $attr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$is_impacted) {
|
||||
if (!$impacted_attr) {
|
||||
LSlog :: get_logger('LSaddon_dyngroup') -> debug(
|
||||
"triggerUpdateDynGroupsMembersCacheOnUserChanges($user): $group is NOT impacted by user's changes."
|
||||
);
|
||||
|
@ -320,7 +320,7 @@ function triggerUpdateDynGroupsMembersCacheOnUserChanges(&$user, &$changed_attrs
|
|||
}
|
||||
LSlog :: get_logger('LSaddon_dyngroup') -> debug(
|
||||
"triggerUpdateDynGroupsMembersCacheOnUserChanges($user): $group is impacted by user's changes ".
|
||||
"(at least by attribute '$attr')."
|
||||
"(at least by attribute '$impacted_attr')."
|
||||
);
|
||||
$impacted_dyngroups++;
|
||||
if (updateDynGroupMembersCache($group, false))
|
||||
|
|
|
@ -115,7 +115,7 @@ function organizationalChartData() {
|
|||
$parent_id_attr = LSconfig :: get('parent_id_attr', '', 'string', $conf);
|
||||
if ($parent_id_attr) {
|
||||
if (!$obj_type :: hasAttr($parent_id_attr))
|
||||
LStemplate :: fatal_error("Object '$obj_type' does not have attribute '$id_attr'.");
|
||||
LStemplate :: fatal_error("Object '$obj_type' does not have attribute '$parent_id_attr'.");
|
||||
$requested_attrs[$obj_type][] = $parent_id_attr;
|
||||
}
|
||||
$objects_conf[$obj_type]['parent_id_attr'] = $parent_id_attr;
|
||||
|
@ -130,7 +130,7 @@ function organizationalChartData() {
|
|||
foreach(getFieldInFormat($attr) as $a) {
|
||||
if (!$obj_type :: hasAttr($a))
|
||||
LStemplate :: fatal_error("Object '$obj_type' does not have attribute '$a'.");
|
||||
if (!in_array($a, $attrs))
|
||||
if (!in_array($a, $requested_attrs[$obj_type]))
|
||||
$requested_attrs[$obj_type][] = $a;
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ function organizationalChartData() {
|
|||
echo json_encode(
|
||||
$entities,
|
||||
(
|
||||
$pretty || isset($_REQUEST['pretty'])?
|
||||
isset($_REQUEST['pretty'])?
|
||||
JSON_PRETTY_PRINT:
|
||||
0
|
||||
)
|
||||
|
|
|
@ -201,6 +201,7 @@ function ppolicy_extraDisplayColumn_password_expiration($entry) {
|
|||
* @return boolean Void if CSV file is successfully generated and upload, false in other case
|
||||
*/
|
||||
function ppolicy_export_search_info($LSsearch, $as_csv=true, $return=false) {
|
||||
$csv = null;
|
||||
if ($as_csv) {
|
||||
$csv = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+');
|
||||
|
||||
|
@ -224,6 +225,7 @@ function ppolicy_export_search_info($LSsearch, $as_csv=true, $return=false) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
if ($as_csv) {
|
||||
$headers = array($LSsearch->label_objectName, 'DN');
|
||||
foreach($attrs as $attr) {
|
||||
|
@ -236,9 +238,6 @@ function ppolicy_export_search_info($LSsearch, $as_csv=true, $return=false) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
foreach ($LSsearch -> getSearchEntries() as $e) {
|
||||
$row = array(
|
||||
|
@ -250,7 +249,7 @@ function ppolicy_export_search_info($LSsearch, $as_csv=true, $return=false) {
|
|||
if ($as_csv) {
|
||||
$values = ensureIsArray($e -> get($attr));
|
||||
if ($values) {
|
||||
$row[] = ($as_json?$values:implode('|', $values));
|
||||
$row[] = implode('|', $values);
|
||||
}
|
||||
else {
|
||||
$no_value_label = LSconfig::get(
|
||||
|
@ -282,7 +281,7 @@ function ppolicy_export_search_info($LSsearch, $as_csv=true, $return=false) {
|
|||
if ($return)
|
||||
return $data;
|
||||
header("Content-disposition: attachment; filename=ppolicy-".$LSsearch->LSobject.".json");
|
||||
displayAjaxReturn($data);
|
||||
LSsession :: displayAjaxReturn($data);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -330,9 +329,11 @@ function _ppolicy_write_row_in_csv(&$csv, &$row) {
|
|||
* @return void
|
||||
**/
|
||||
function handle_api_LSobject_exportPpolicyInfo($request) {
|
||||
get_LSobject_from_API_request($request);
|
||||
$object = get_LSobject_from_API_request($request);
|
||||
if (!$object)
|
||||
return;
|
||||
$container_dn = LSconfig::get(
|
||||
"LSobjects.".$LSsearch->LSobject.".container_dn",
|
||||
"LSobjects.".$object->LSobject.".container_dn",
|
||||
"", "string");
|
||||
$whoami = LSsession :: whoami(
|
||||
$container_dn?
|
||||
|
@ -423,8 +424,8 @@ function cli_export_ppolicy_info($command_args) {
|
|||
print($data);
|
||||
exit();
|
||||
}
|
||||
$fd = fopen($output, 'w') or fatal_error("Fail to open output file '$output'");
|
||||
fwrite($fd, $data) or fatal_error("Fail to write result in output file '$output'");
|
||||
$fd = fopen($output, 'w') or LStemplate::fatal_error("Fail to open output file '$output'");
|
||||
fwrite($fd, $data) or LStemplate::fatal_error("Fail to write result in output file '$output'");
|
||||
@fclose($fd);
|
||||
}
|
||||
|
||||
|
|
|
@ -491,7 +491,7 @@ function generate_sambaProfilePath($ldapObject) {
|
|||
function generate_shadowExpire_from_sambaPwdMustChange($ldapObject) {
|
||||
$time = $ldapObject -> getValue('sambaPwdMustChange', true, null);
|
||||
if ($time)
|
||||
return str_val(round(int_val($time)/86400));
|
||||
return strval(round(intval($time)/86400));
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ function generate_shadowExpire_from_sambaPwdMustChange($ldapObject) {
|
|||
function generate_timestamp_from_shadowExpire($ldapObject) {
|
||||
$days = $ldapObject -> getValue('shadowExpire', true, null);
|
||||
if ($days)
|
||||
return str_val(int_val($days) * 86400);
|
||||
return strval(intval($days) * 86400);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ function showTechInfo($object) {
|
|||
'creatorsName' => _('Creator DN'),
|
||||
'modifyTimestamp' => _('Last modification date'),
|
||||
'modifiersName' => _('Last modifier DN'),
|
||||
'modifiersName' => _('Last modifier DN'),
|
||||
'entryCSN' => _('LDAP entry change sequence number'),
|
||||
'entryUUID' => _('LDAP entry UUID'),
|
||||
'hasSubordinates' => _('LDAP entry has children'),
|
||||
|
|
|
@ -223,7 +223,7 @@ LSerror :: defineError('SSH_07',
|
|||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function removeDirsBySFTP($connection_params, $dirs, $recursive=false) {
|
||||
function removeDirsBySFTP($connection_params, $dirs, $recursive=false, $continue=false) {
|
||||
$cnx = connectToSSH($connection_params, true);
|
||||
if (! $cnx){
|
||||
return;
|
||||
|
|
|
@ -814,6 +814,26 @@ function supannGetOIDCGenrePossibleValues($options, $name, $ldapObject) {
|
|||
return supannGetNomenclaturePossibleValues('oidc_genre', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Détecte et alimente la liste des codes de populations dans la variable
|
||||
* $GLOBALS['supannNomenclatures']['SUPANN']['codePopulation'].
|
||||
*
|
||||
* @param array $populations
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
function supannDetectCodesPopulations($populations, $prefix="") {
|
||||
if (!$populations) {
|
||||
return;
|
||||
}
|
||||
foreach($populations as $letter => $infos) {
|
||||
$code = "$prefix$letter";
|
||||
if (isset($infos['label']))
|
||||
$GLOBALS['supannNomenclatures']['SUPANN']['codePopulation'][$code] = $infos['label']." ($code)";
|
||||
supannDetectCodesPopulations($infos['subpopulations'], $code);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Charge une nomenclature SUPANN
|
||||
*
|
||||
|
@ -866,19 +886,7 @@ function supannLoadNomenclature($table) {
|
|||
return false;
|
||||
}
|
||||
$GLOBALS['supannNomenclatures']['SUPANN']['codePopulation'] = array();
|
||||
|
||||
function _detectCodesPopulations($populations, $prefix="") {
|
||||
if (!$populations) {
|
||||
return;
|
||||
}
|
||||
foreach($populations as $letter => $infos) {
|
||||
$code = "$prefix$letter";
|
||||
if (isset($infos['label']))
|
||||
$GLOBALS['supannNomenclatures']['SUPANN']['codePopulation'][$code] = $infos['label']." ($code)";
|
||||
_detectCodesPopulations($infos['subpopulations'], $code);
|
||||
}
|
||||
}
|
||||
_detectCodesPopulations($GLOBALS['supannPopulations']);
|
||||
supannDetectCodesPopulations($GLOBALS['supannPopulations']);
|
||||
break;
|
||||
|
||||
case 'etuDiplome':
|
||||
|
|
|
@ -35,7 +35,7 @@ class LSattr_html_maildir extends LSattr_html {
|
|||
public function __construct($name, $config, &$attribute) {
|
||||
$attribute -> addObjectEvent('before_delete',$this,'beforeDelete');
|
||||
$attribute -> addObjectEvent('after_delete',$this,'deleteMaildirByFTP');
|
||||
return parent :: __construct($name, $config, $attribute);
|
||||
parent :: __construct($name, $config, $attribute);
|
||||
}
|
||||
|
||||
public function doOnModify($action,$cur,$new) {
|
||||
|
|
|
@ -309,7 +309,7 @@ class LSattr_html_select_list extends LSattr_html{
|
|||
* @retval array Tableau associatif des valeurs possible de la liste avec en clé
|
||||
* la valeur des balises option et en valeur ce qui sera affiché.
|
||||
*/
|
||||
protected function getLSattributePossibleValues($attr, $options ,$name ,&$ldapObject) {
|
||||
protected static function getLSattributePossibleValues($attr, $options ,$name ,&$ldapObject) {
|
||||
$retInfos=array();
|
||||
if (is_string($attr)) {
|
||||
if (isset($ldapObject->attrs[$attr]) && $ldapObject->attrs[$attr] instanceof LSattribute) {
|
||||
|
@ -410,7 +410,7 @@ class LSattr_html_select_list extends LSattr_html{
|
|||
);
|
||||
}
|
||||
catch (Exception $er) {
|
||||
self :: log_exception($er, strval($this)." -> _getPossibleValues(): exception occured running ".format_callable($get_possible_values));
|
||||
self :: log_exception($er, get_called_class()." -> _getPossibleValues(): exception occured running ".format_callable($get_possible_values));
|
||||
$retInfos = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ class LSattr_ldap_password extends LSattr_ldap {
|
|||
break;
|
||||
case 'sha256':
|
||||
case 'sha512':
|
||||
$mhash_type = null;
|
||||
switch($encode) {
|
||||
case 'sha256':
|
||||
$mhash_type = MHASH_SHA256;
|
||||
|
@ -163,6 +164,7 @@ class LSattr_ldap_password extends LSattr_ldap {
|
|||
case 'ssha':
|
||||
case 'ssha256':
|
||||
case 'ssha512':
|
||||
$mhash_type = null;
|
||||
switch($encode) {
|
||||
case 'ssha':
|
||||
$mhash_type = MHASH_SHA1;
|
||||
|
@ -188,7 +190,7 @@ class LSattr_ldap_password extends LSattr_ldap {
|
|||
if( function_exists( 'mhash' ) && function_exists( 'mhash_keygen_s2k' ) ) {
|
||||
mt_srand( (double) microtime() * 1000000 );
|
||||
if (is_null($salt))
|
||||
$salt = mhash_keygen_s2k( MHASH_MD5, $password_clear, substr( pack( "h*", md5( mt_rand() ) ), 0, 8 ), 4 );
|
||||
$salt = mhash_keygen_s2k( MHASH_MD5, $clearPassword, substr( pack( "h*", md5( mt_rand() ) ), 0, 8 ), 4 );
|
||||
return "{SMD5}".base64_encode( mhash( MHASH_MD5, $clearPassword.$salt ).$salt );
|
||||
}
|
||||
else {
|
||||
|
@ -263,12 +265,10 @@ class LSattr_ldap_password extends LSattr_ldap {
|
|||
return (strcasecmp(call_user_func_array($encodeFunction, array(&$this -> attribute -> ldapObject, $clearPassword)), $hashedPassword) == 0);
|
||||
|
||||
// Extract cipher
|
||||
$hashedPasswordData = $cypher = null;
|
||||
if (preg_match('/{([^}]+)}(.*)/',$hashedPassword,$matches)) {
|
||||
$hashedPasswordData = $matches[2];
|
||||
$cypher = strtolower($matches[1]);
|
||||
|
||||
} else {
|
||||
$cypher = null;
|
||||
}
|
||||
|
||||
// Verify password according on cypher
|
||||
|
|
|
@ -699,7 +699,7 @@ class LSattribute extends LSlog_staticLoggerClass {
|
|||
call_user_func_array($e['fct'], array(&$e['params']));
|
||||
}
|
||||
catch(Exception $er) {
|
||||
self :: log_exception($er, strval($this)." -> fireEvent($event): exception occured running ".format_callable(e['fct']));
|
||||
self :: log_exception($er, strval($this)." -> fireEvent($event): exception occured running ".format_callable($e['fct']));
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ class LSauthMethod extends LSlog_staticLoggerClass {
|
|||
self :: log_debug(get_class($this)." :: __construct(): config file ($conf_file) loaded");
|
||||
else
|
||||
self :: log_debug(get_class($this)." :: __construct(): config file ($conf_file) not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +68,7 @@ class LSauthMethod extends LSlog_staticLoggerClass {
|
|||
self :: log_debug("No user found for provided username '".$this -> authData['username']."'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (count($authobjects) > 1) {
|
||||
self :: log_debug('Multiple users match with provided username: '.implode(', ', array_keys($authobjects)));
|
||||
LSerror :: addErrorCode('LSauth_02');
|
||||
|
|
|
@ -33,8 +33,7 @@ class LSauthMethod_CAS extends LSauthMethod {
|
|||
public function __construct() {
|
||||
LSauth :: disableLoginForm();
|
||||
|
||||
if (!parent :: __construct())
|
||||
return;
|
||||
parent :: __construct();
|
||||
|
||||
if (LSsession :: includeFile(PHP_CAS_PATH, true)) {
|
||||
if (defined('PHP_CAS_DEBUG_FILE')) {
|
||||
|
@ -67,7 +66,7 @@ class LSauthMethod_CAS extends LSauthMethod {
|
|||
// Check CAS server SSL validation is now configured
|
||||
if (!$cas_server_ssl_validation_configured) {
|
||||
LSerror :: addErrorCode('LSauthMethod_CAS_02');
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined('LSAUTH_CAS_CURL_SSLVERION')) {
|
||||
|
@ -82,12 +81,10 @@ class LSauthMethod_CAS extends LSauthMethod {
|
|||
|
||||
// Set configured flag
|
||||
$this -> configured = true;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
LSerror :: addErrorCode('LSauthMethod_CAS_01');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,6 @@ class LSauthMethod_HTTP extends LSauthMethod_basic {
|
|||
LSauth :: disableLoginForm();
|
||||
if (!defined('LSAUTHMETHOD_HTTP_LOGOUT_REMOTE_URL'))
|
||||
LSauth :: disableLogoutBtn();
|
||||
return True;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,8 +34,7 @@ class LSauthMethod_anonymous extends LSauthMethod {
|
|||
LSauth :: disableLoginForm();
|
||||
LSauth :: disableSelfAccess();
|
||||
|
||||
if (!parent :: __construct())
|
||||
return;
|
||||
parent :: __construct();
|
||||
|
||||
if ( (!defined('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT')) || (constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT') === True)) {
|
||||
self :: log_debug('logout : '.constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT'));
|
||||
|
@ -46,7 +45,6 @@ class LSauthMethod_anonymous extends LSauthMethod {
|
|||
LSerror :: addErrorCode('LSauthMethod_anonymous_01');
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,6 +55,7 @@ class LSform extends LSlog_staticLoggerClass {
|
|||
var $api_mode = false;
|
||||
|
||||
private $submited = false;
|
||||
private $submit = null;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -528,7 +529,7 @@ class LSform extends LSlog_staticLoggerClass {
|
|||
}
|
||||
// Retrieve POST data of the element
|
||||
if( !($element -> getPostData($this -> _postData, $onlyIfPresent)) ) {
|
||||
LSerror :: addErrorCode('LSform_02',$element_name);
|
||||
LSerror :: addErrorCode('LSform_02',$elementName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -548,7 +549,7 @@ class LSform extends LSlog_staticLoggerClass {
|
|||
*
|
||||
* @retval LSformElement
|
||||
*/
|
||||
public function addElement($type,$name,$label,$params=array(),&$attr_html) {
|
||||
public function addElement($type,$name,$label,$params,&$attr_html) {
|
||||
$elementType='LSformElement_'.$type;
|
||||
LSsession :: loadLSclass($elementType);
|
||||
if (!class_exists($elementType)) {
|
||||
|
|
|
@ -36,6 +36,7 @@ class LSformElement extends LSlog_staticLoggerClass {
|
|||
var $label;
|
||||
var $params;
|
||||
var $values = array();
|
||||
var $form = null;
|
||||
var $_required = false;
|
||||
var $_freeze = false;
|
||||
var $attr_html;
|
||||
|
@ -364,7 +365,7 @@ class LSformElement extends LSlog_staticLoggerClass {
|
|||
*
|
||||
* @retval boolean True on success, False otherwise
|
||||
*/
|
||||
protected function split_autocomplete_attr_values($attr_value="", $multiple_value_delimiter="|", &$attr_values, &$last_attr_value) {
|
||||
protected function split_autocomplete_attr_values($attr_value, $multiple_value_delimiter, &$attr_values, &$last_attr_value) {
|
||||
$attr_values = explode($multiple_value_delimiter, $attr_value);
|
||||
if (count($attr_values) > 1 && !$this -> getParam('multiple', false, 'bool')) {
|
||||
self :: log_error("The attribute ".$this -> name." is not multivalued.");
|
||||
|
|
|
@ -110,7 +110,7 @@ class LSformElement_image extends LSformElement {
|
|||
$php_debug_params[] = "$param = '".ini_get($param)."'";
|
||||
$php_debug_params[] = "HTML form MAX_FILE_SIZE = '".MAX_SEND_FILE_SIZE."'";
|
||||
self :: log_debug('LSformElement_image('.$this->name.')->getPostData(): '.implode(', ', $php_debug_params));
|
||||
$this -> form -> setElementError($this -> attr_html, $this -> getFileUploadErrorMessage($_FILES[$this -> name]));
|
||||
$this -> form -> setElementError($this -> attr_html, $this -> getFileUploadErrorMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class LSformElement_image extends LSformElement {
|
|||
* @retval string The translated file upload error message
|
||||
*/
|
||||
private function getFileUploadErrorMessage() {
|
||||
if (isset($_FILES) && isset($_FILES[$this -> name]) && isset($_FILES[$this -> name]['error'])) {
|
||||
if (isset($_FILES[$this -> name]) && isset($_FILES[$this -> name]['error'])) {
|
||||
switch($_FILES[$this -> name]['error']) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
return _('The uploaded file size exceeds the limit accepted by the server.');
|
||||
|
|
|
@ -71,7 +71,7 @@ class LSformElement_maildir extends LSformElement_text {
|
|||
'nodo' => _("Click to enable maildir creation/modification on user creation/modification.")
|
||||
)
|
||||
);
|
||||
return parent :: getDisplay($return);
|
||||
return parent :: getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ class LSformElement_rss extends LSformElement_text {
|
|||
'display' => _("Display RSS stack.")
|
||||
)
|
||||
);
|
||||
return parent :: getDisplay($return);
|
||||
return parent :: getDisplay();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -192,10 +192,8 @@ class LSformElement_select extends LSformElement {
|
|||
*
|
||||
* @retval void
|
||||
**/
|
||||
function LSformElement_select_checkIsValidValue($params,$template) {
|
||||
extract($params);
|
||||
|
||||
$ret = LSformElement_select :: _isValidValue($value, $possible_values);
|
||||
function LSformElement_select_checkIsValidValue($params, $template) {
|
||||
$ret = LSformElement_select :: _isValidValue($params['value'], $params['possible_values']);
|
||||
|
||||
if ($ret===False) {
|
||||
$label='';
|
||||
|
|
|
@ -309,7 +309,7 @@ class LSformElement_supannCompositeAttribute extends LSformElement {
|
|||
break;
|
||||
|
||||
default:
|
||||
self :: error('Unrecognized component type "'.$this -> components[$c]['type'].'"');
|
||||
self :: log_error('Unrecognized component type "'.$this -> components[$c]['type'].'"');
|
||||
}
|
||||
}
|
||||
self :: log_debug("translateComponentValue($c, $val): ".varDump($retval));
|
||||
|
@ -400,7 +400,7 @@ class LSformElement_supannCompositeAttribute extends LSformElement {
|
|||
}
|
||||
self :: log_debug($this." -> getPostData(): POST data = ".varDump($parseValues));
|
||||
|
||||
if (!$parseValue && $onlyIfPresent)
|
||||
if (!$parseValues && $onlyIfPresent)
|
||||
return true;
|
||||
|
||||
$return[$this -> name] = array();
|
||||
|
@ -572,7 +572,7 @@ class LSformElement_supannCompositeAttribute extends LSformElement {
|
|||
public function getApiValue($details=false) {
|
||||
$values = array();
|
||||
foreach(ensureIsArray($this -> values) as $value) {
|
||||
$decodedValue = $this -> parseCompositeValue($value, true);
|
||||
$decodedValue = $this -> parseCompositeValue($value);
|
||||
if (is_array($decodedValue)) {
|
||||
$parsedValue = array();
|
||||
foreach(array_keys($this -> components) as $c) {
|
||||
|
|
|
@ -84,7 +84,7 @@ class LSformElement_supannEmpProfil extends LSformElement_supannCompositeAttribu
|
|||
'required' => false,
|
||||
),
|
||||
);
|
||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class LSformElement_supannEtuInscription extends LSformElement_supannCompositeAt
|
|||
'required' => false,
|
||||
),
|
||||
);
|
||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class LSformElement_supannExtProfil extends LSformElement_supannCompositeAttribu
|
|||
'required' => false,
|
||||
),
|
||||
);
|
||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class LSformElement_supannRessourceEtat extends LSformElement_supannCompositeAtt
|
|||
'required' => false,
|
||||
),
|
||||
);
|
||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ class LSformElement_supannRessourceEtat extends LSformElement_supannCompositeAtt
|
|||
if (!$value['ressource'] || !$value['etat'])
|
||||
return null;
|
||||
$ret = "{".$value['ressource']."}".$value['etat'];
|
||||
if (isset($value['sous_etat']) && !is_empty($matches['sous_etat']))
|
||||
if (isset($value['sous_etat']) && !is_empty($value['sous_etat']))
|
||||
$ret .= ":".$value['sous_etat'];
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class LSformElement_supannRessourceEtatDate extends LSformElement_supannComposit
|
|||
'required' => false,
|
||||
),
|
||||
);
|
||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,7 @@ class LSformElement_supannRoleEntite extends LSformElement_supannCompositeAttrib
|
|||
'required' => false
|
||||
)
|
||||
);
|
||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -178,6 +178,7 @@ class LSformElement_text extends LSformElement {
|
|||
);
|
||||
}
|
||||
else {
|
||||
$filters = array();
|
||||
foreach($value_attributes as $attr) {
|
||||
$filters[] = Net_LDAP2_Filter::create($attr, 'contains', $pattern);
|
||||
}
|
||||
|
@ -217,19 +218,18 @@ class LSformElement_text extends LSformElement {
|
|||
foreach($value_attributes as $attr) {
|
||||
if (!isset($object['attrs'][$attr])) continue;
|
||||
$values = ensureIsArray($object['attrs'][$attr]);
|
||||
foreach($values as $value)
|
||||
|
||||
if ($displayNameFormat)
|
||||
$displayName = getFData(
|
||||
foreach($values as $value) {
|
||||
$ret[$value] = (
|
||||
$displayNameFormat?
|
||||
getFData(
|
||||
$displayNameFormat,
|
||||
array_merge(
|
||||
array('value' => $value, 'dn' => $object['dn']),
|
||||
$object['attrs']
|
||||
)
|
||||
);
|
||||
else
|
||||
$displayName = $value;
|
||||
$ret[$value] = $displayName;
|
||||
):$value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class LSformElement_xmpp extends LSformElement_text {
|
|||
'chat' => _("Chat with this person.")
|
||||
)
|
||||
);
|
||||
return parent :: getDisplay($return);
|
||||
return parent :: getDisplay();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class LSformRule extends LSlog_staticLoggerClass {
|
|||
*
|
||||
* @return boolean True if value is valid, False otherwise
|
||||
*/
|
||||
public static function validate_values($rule_name, $values, $options=array(), &$formElement) {
|
||||
public static function validate_values($rule_name, $values, $options, &$formElement) {
|
||||
// Compute PHP class name of the rule
|
||||
$rule_class = "LSformRule_".$rule_name;
|
||||
|
||||
|
@ -93,7 +93,7 @@ class LSformRule extends LSlog_staticLoggerClass {
|
|||
*
|
||||
* @return boolean True if value is valid, False otherwise
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,7 @@ class LSformRule extends LSlog_staticLoggerClass {
|
|||
$rule_name = null;
|
||||
$rule_class = null;
|
||||
$rule_name_arg_num = null;
|
||||
$rule_name_quote_char = null;
|
||||
$params = array();
|
||||
for ($i=0; $i < count($command_args); $i++) {
|
||||
switch ($command_args[$i]) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_LSformElement_select_validValue extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valide, false if not
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$ret = $formElement -> isValidValue($value);
|
||||
if ($ret===False) return False;
|
||||
return True;
|
||||
|
|
|
@ -42,7 +42,7 @@ class LSformRule_alphanumeric extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
|
||||
if (LSconfig :: get('params.withAccents', false, 'bool', $options)) {
|
||||
$regex = '/(*UTF8)^[0-9\p{L}]+$/';
|
||||
|
|
|
@ -46,7 +46,7 @@ class LSformRule_callable extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valid, false otherwise
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$callable = LSconfig :: get('params.callable', null, null, $options);
|
||||
if (is_callable($callable))
|
||||
return call_user_func_array(
|
||||
|
|
|
@ -35,34 +35,39 @@ class LSformRule_compare extends LSformRule {
|
|||
);
|
||||
|
||||
// Operators mapping
|
||||
static protected $_operators = array(
|
||||
'eq' => '==',
|
||||
'neq' => '!=',
|
||||
'gt' => '>',
|
||||
'gte' => '>=',
|
||||
'lt' => '<',
|
||||
'lte' => '<='
|
||||
static protected $_operators_aliases = array(
|
||||
'==' => 'eq',
|
||||
'!=' => 'neq',
|
||||
'>' => 'gt',
|
||||
'>=' => 'gte',
|
||||
'<' => 'lt',
|
||||
'<=' => 'lte',
|
||||
);
|
||||
static protected $_operators_to_compare_function = array(
|
||||
'eq' => function($a, $b) {return floatval($a) == floatval($b);},
|
||||
'neq' => function($a, $b) {return floatval($a) != floatval($b);},
|
||||
'gt' => function($a, $b) {return $a > $b;},
|
||||
'gte' => function($a, $b) {return $a >= $b;},
|
||||
'lt' => function($a, $b) {return $a < $b;},
|
||||
'lte' => function($a, $b) {return $a <= $b;},
|
||||
);
|
||||
|
||||
/**
|
||||
* Retourne l'operateur de comparaison.
|
||||
* Return the compare function associated with the specified operator
|
||||
*
|
||||
* @access private
|
||||
* @param string Nom de l'operateur
|
||||
* @param string The operator name
|
||||
*
|
||||
* @return string Operateur à utiliser
|
||||
* @return function The compare function
|
||||
*/
|
||||
private static function _findOperator($operator_name) {
|
||||
|
||||
if (empty(self :: $operator_name)) {
|
||||
return '==';
|
||||
} elseif (isset(self :: $_operators[$operator_name])) {
|
||||
return self :: $_operators[$operator_name];
|
||||
} elseif (in_array($operator_name, self :: $_operators)) {
|
||||
return $operator_name;
|
||||
} else {
|
||||
return '==';
|
||||
}
|
||||
private static function _findOperatorCompareFunction($operator_name) {
|
||||
if (empty($operator_name))
|
||||
$operator_name = 'eq';
|
||||
elseif (isset(self :: $_operators_aliases[$operator_name]))
|
||||
$operator_name = self :: $_operators_aliases[$operator_name];
|
||||
elseif (!isset(self :: $_operators_to_compare_function[$operator_name]))
|
||||
$operator_name = 'eq';
|
||||
return self :: $_operators_to_compare_function[$operator_name];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,19 +80,13 @@ class LSformRule_compare extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($values, $options=array(), &$formElement) {
|
||||
public static function validate($values, $options, &$formElement) {
|
||||
$operator = LSconfig :: get('params.operator', null, 'string', $options);
|
||||
if (!$operator) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'compare', 'param' => 'operator'));
|
||||
return;
|
||||
}
|
||||
$operator = self :: _findOperator($operator);
|
||||
if ('==' != $operator && '!=' != $operator) {
|
||||
$compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);');
|
||||
}
|
||||
else {
|
||||
$compareFn = create_function('$a, $b', 'return $a ' . $operator . ' $b;');
|
||||
}
|
||||
$compareFn = self :: _findOperatorCompareFunction($operator);
|
||||
return $compareFn($values[0], $values[1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class LSformRule_date extends LSformRule {
|
|||
*
|
||||
* @return boolean True si les données sont valide, False sinon.
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$special_values = LSconfig :: get('params.special_values', array(), null, $options);
|
||||
if (in_array($value, $special_values))
|
||||
return true;
|
||||
|
|
|
@ -42,7 +42,7 @@ class LSformRule_differentPassword extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$otherPasswordAttributes = LSconfig :: get('params.otherPasswordAttributes', null, null, $options);
|
||||
if (!is_null($otherPasswordAttributes)) {
|
||||
// Load LSattr_ldap_password
|
||||
|
|
|
@ -43,7 +43,7 @@ class LSformRule_email extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
return checkEmail(
|
||||
$value,
|
||||
LSconfig :: get('params.domain', null, null, $options),
|
||||
|
|
|
@ -44,7 +44,7 @@ class LSformRule_filesize extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
// According to PHP doc, strlen() returns the number of bytes rather
|
||||
// than the number of characters in a string.
|
||||
// See: https://www.php.net/manual/en/function.strlen.php
|
||||
|
|
|
@ -40,7 +40,7 @@ class LSformRule_imagefile extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$file = LSsession :: getTmpFile($value);
|
||||
|
||||
$mimetype = mime_content_type($file);
|
||||
|
|
|
@ -48,7 +48,7 @@ class LSformRule_imagesize extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$file = LSsession :: getTmpFile($value);
|
||||
list($width, $height, $type, $attr) = getimagesize($file);
|
||||
self :: log_debug("validate(): image size is $width x $height, type=$type, attr='$attr'");
|
||||
|
|
|
@ -45,7 +45,7 @@ class LSformRule_inarray extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valid, false otherwise
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$possible_values = LSconfig :: get('params.possible_values', null, null, $options);
|
||||
$reverse = LSconfig :: get('params.reverse', false, 'bool', $options);
|
||||
if (!is_array($possible_values)) {
|
||||
|
|
|
@ -48,7 +48,7 @@ class LSformRule_integer extends LSformRule{
|
|||
*
|
||||
* @return boolean true if the value is valided, false otherwise
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$max = LSconfig :: get('params.max', null, 'int', $options);
|
||||
if(is_int($max) && $max != 0 && $value > $max) {
|
||||
self :: log_debug("value is too higth ($value > $max)");
|
||||
|
|
|
@ -46,7 +46,7 @@ class LSformRule_ldapSearchURI extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valid, false otherwise
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
self :: log_trace("validate($value): options = ".varDump($options));
|
||||
$uri_parts = explode('?', $value);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_lettersonly extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$regex = '/^[a-zA-Z]+$/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -42,7 +42,7 @@ class LSformRule_maxlength extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$limit = LSconfig :: get('params.limit', null, 'int', $options);
|
||||
if(is_null($limit)) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'maxlength', 'param' => 'limit'));
|
||||
|
|
|
@ -44,7 +44,7 @@ class LSformRule_mimetype extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$file = LSsession :: getTmpFile($value);
|
||||
$real_mimetype = mime_content_type($file);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class LSformRule_minlength extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$limit = LSconfig :: get('params.limit', null, 'int', $options);
|
||||
if(is_null($limit)) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'minlength', 'param' => 'limit'));
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_nonzero extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$regex = '/^-?[1-9][0-9]*/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_nopunctuation extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$regex = '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -45,7 +45,7 @@ class LSformRule_numberOfValues extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valide, false if not
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$max_values = LSconfig :: get('params.max', null, 'int', $options);
|
||||
$min_values = LSconfig :: get('params.min', null, 'int', $options);
|
||||
if(is_null($max_values) && is_null($min_values)) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_numeric extends LSformRule{
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$regex = '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -52,7 +52,7 @@ class LSformRule_password extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$errors = array();
|
||||
|
||||
$maxLength = LSconfig :: get('params.maxLength', null, 'int', $options);
|
||||
|
|
|
@ -43,7 +43,7 @@ class LSformRule_rangelength extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$limits = LSconfig :: get('params.limits', null, null, $options);
|
||||
if(!is_array($limits) || count($limits) != 2) {
|
||||
LSerror :: addErrorCode('LSformRule_01',array('type' => 'rangelength', 'param' => 'limits'));
|
||||
|
|
|
@ -42,7 +42,7 @@ class LSformRule_regex extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
if (is_array($options)) {
|
||||
$regex = LSconfig :: get('params.regex', null, 'string', $options);
|
||||
if (!is_string($regex)) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_required extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
return ((string)$value != '');
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_ssh_pub_key extends LSformRule {
|
|||
*
|
||||
* @return boolean true if the value is valide, false if not
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
if (preg_match('/^(ssh-[a-z0-9]+) +([^ ]+) +(.*)$/', $value, $m)) {
|
||||
$data=@base64_decode($m[2]);
|
||||
if (is_string($data))
|
||||
|
|
|
@ -36,7 +36,7 @@ class LSformRule_telephonenumber extends LSformRule {
|
|||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
$regex = '/^(01|02|03|04|05|06|08|09)[0-9]{8}$/';
|
||||
LSsession :: loadLSclass('LSformRule_regex');
|
||||
return LSformRule_regex :: validate($value,$regex,$formElement);
|
||||
|
|
|
@ -20,14 +20,6 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
use ZxcvbnPhp\Zxcvbn;
|
||||
LSsession :: includeFile(
|
||||
LSconfig :: get(
|
||||
'params.zxcvbn_autoload_path', 'Zxcvbn/autoload.php',
|
||||
'string', $options
|
||||
), true
|
||||
);
|
||||
|
||||
/**
|
||||
* Rule to validate password using ZXCVBN-PHP lib
|
||||
*
|
||||
|
@ -54,8 +46,14 @@ class LSformRule_zxcvbn extends LSformRule {
|
|||
*
|
||||
* @return boolean True if value is valid, False otherwise
|
||||
*/
|
||||
public static function validate($value, $options=array(), &$formElement) {
|
||||
$zxcvbn = new Zxcvbn();
|
||||
public static function validate($value, $options, &$formElement) {
|
||||
LSsession :: includeFile(
|
||||
LSconfig :: get(
|
||||
'params.zxcvbn_autoload_path', 'Zxcvbn/autoload.php',
|
||||
'string', $options
|
||||
), true
|
||||
);
|
||||
$zxcvbn = new ZxcvbnPhp\Zxcvbn();
|
||||
$userData = array();
|
||||
$userDataAttrs = LSconfig :: get('params.userDataAttrs', array(), 'array', $options);
|
||||
if ($userDataAttrs) {
|
||||
|
|
|
@ -290,7 +290,9 @@ class LSio extends LSlog_staticLoggerClass {
|
|||
$object = new $LSobject();
|
||||
if (!$object -> loadData($dn)) {
|
||||
self :: log_debug('import(): Failed to load data of '.$dn);
|
||||
$globalErrors[] = getFData(_("Failed to load existing object %{dn} from LDAP server. Can't update object."));
|
||||
$globalErrors[] = getFData(
|
||||
_("Failed to load existing object %{dn} from LDAP server. Can't update object."),
|
||||
$dn);
|
||||
}
|
||||
else {
|
||||
// Instanciate a modify form (in API mode)
|
||||
|
@ -585,7 +587,7 @@ class LSio extends LSlog_staticLoggerClass {
|
|||
$ioFormat = $command_args[$i];
|
||||
}
|
||||
else
|
||||
LScli :: usage("Invalid $arg parameter.");
|
||||
LScli :: usage("Invalid ".$command_args[$i]." parameter.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class LSioFormatCSV extends LSioFormatDriver {
|
|||
private $enclosure = null;
|
||||
private $escape = null;
|
||||
private $length = null;
|
||||
private $multiple_value_delimiter = null;
|
||||
|
||||
private $rows = null;
|
||||
private $headers = null;
|
||||
|
|
|
@ -231,10 +231,360 @@ if (php_sapi_name() != "cli") return true;
|
|||
*
|
||||
* @retval boolean True on success, false otherwise
|
||||
**/
|
||||
global $LSlang_cli_logger, $available_onlys, $available_withouts;
|
||||
global $LSlang_cli_logger, $available_onlys, $available_withouts;
|
||||
|
||||
$available_onlys = array("config", "templates", "addons", "auth_methods", "includes");
|
||||
$available_withouts = array_merge($available_onlys, array("select-list"));
|
||||
function _cli_relative2absolute_path($path) {
|
||||
if ($path[0] == '/')
|
||||
return $path;
|
||||
global $curdir;
|
||||
return realpath($curdir)."/".$path;
|
||||
}
|
||||
|
||||
function _cli_absolute2relative_path($path) {
|
||||
if ($path[0] == '/')
|
||||
$path = realpath($path);
|
||||
if (substr($path, 0, strlen(LS_ROOT_DIR)) == LS_ROOT_DIR)
|
||||
return substr($path, strlen(LS_ROOT_DIR)+1);
|
||||
return $path;
|
||||
}
|
||||
|
||||
function _cli_interactive_ask($context, $msg) {
|
||||
global $copyoriginalvalue, $interactive_exit;
|
||||
|
||||
if ($interactive_exit) {
|
||||
if ($copyoriginalvalue)
|
||||
return $msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Format question
|
||||
$empty_action = ($copyoriginalvalue?'copy original message':'pass');
|
||||
$question ="\"$msg\"\n\n => Please enter translated string";
|
||||
$question .= " (i";
|
||||
if (!$copyoriginalvalue)
|
||||
$question .= "/c";
|
||||
$question .= "/q/? or leave empty to $empty_action): ";
|
||||
|
||||
while (true) {
|
||||
if ($context)
|
||||
fwrite(STDERR, "\n# $context\n");
|
||||
fwrite(STDERR, $question);
|
||||
$in = trim(fgets(STDIN));
|
||||
switch($in) {
|
||||
case 'q': // Exit interactive mode
|
||||
case 'Q':
|
||||
$interactive_exit = true;
|
||||
return True;
|
||||
case 'i': // Ignore
|
||||
case 'I':
|
||||
return True;
|
||||
case 'c':
|
||||
case 'C': // Copy
|
||||
if (!$copyoriginalvalue)
|
||||
return $msg;
|
||||
case '?': // Help message
|
||||
fwrite(STDERR, "Available choices:\n");
|
||||
fwrite(STDERR, " - i: ignore this message\n");
|
||||
if (!$copyoriginalvalue)
|
||||
fwrite(STDERR, " - c: copy original message\n");
|
||||
fwrite(STDERR, " - q: quit interactive mode and ignore all following untranslated messages\n");
|
||||
fwrite(STDERR, " - ?: Show this message\n");
|
||||
fwrite(STDERR, "Or leave empty to $empty_action.\n");
|
||||
break;
|
||||
case "": // Empty
|
||||
// On copy orignal value mode, return $msg
|
||||
if ($copyoriginalvalue)
|
||||
return $msg;
|
||||
// Otherwise, leave translation empty
|
||||
return "";
|
||||
default:
|
||||
// Return user input
|
||||
return $in;
|
||||
}
|
||||
}
|
||||
// Supposed to never happen
|
||||
return true;
|
||||
}
|
||||
|
||||
function _cli_add_str_to_translate($msg, $context=null) {
|
||||
global $LSlang_cli_logger, $lang, $data, $translations, $interactive, $interactive_exit, $copyoriginalvalue, $format;
|
||||
$LSlang_cli_logger -> trace("_cli_add_str_to_translate($msg, $context)");
|
||||
if ($msg == '')
|
||||
return;
|
||||
if (!is_null($lang) && _($msg) != "$msg")
|
||||
return;
|
||||
|
||||
// Message already exists ?
|
||||
if (array_key_exists($msg, $data)) {
|
||||
if ($context && !in_array($context, $data[$msg]['contexts']))
|
||||
$data[$msg]['contexts'][] = $context;
|
||||
return True;
|
||||
}
|
||||
|
||||
// Handle translation
|
||||
$translation = "";
|
||||
if (array_key_exists($msg, $translations)) {
|
||||
$translation = $translations[$msg];
|
||||
}
|
||||
elseif (!is_null($lang) && _($msg) != $msg) {
|
||||
$translation = _($msg);
|
||||
}
|
||||
elseif ($interactive && $format != 'pot') {
|
||||
$translation = _cli_interactive_ask($context, $msg);
|
||||
if (!is_string($translation))
|
||||
return true;
|
||||
}
|
||||
$data[$msg] = array (
|
||||
'translation' => $translation,
|
||||
'contexts' => ($context?array($context):array()),
|
||||
);
|
||||
}
|
||||
|
||||
function _cli_add_str_to_translate_from_LSconfig($pattern, $value='value', $excludes=array()) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> trace("_cli_add_str_to_translate_from_LSconfig($pattern, array(".implode(',', $excludes)."))");
|
||||
$keys = LSconfig :: getMatchingKeys($pattern);
|
||||
$LSlang_cli_logger -> trace("addFromLSconfig : ".count($keys)." matching key(s)");
|
||||
foreach ($keys as $key => $value) {
|
||||
$LSlang_cli_logger -> trace("addFromLSconfig : $key = ".varDump($value));
|
||||
if ($value == 'key') {
|
||||
// Get the last key parts as value and all other as key
|
||||
$key_parts = explode('.', $key);
|
||||
$value = $key_parts[count($key_parts)-1];
|
||||
$key = implode('.', array_slice($key_parts, 0, count($key_parts)-1));
|
||||
}
|
||||
if (!in_array($value, $excludes) && is_string($value))
|
||||
_cli_add_str_to_translate($value, $key);
|
||||
}
|
||||
}
|
||||
|
||||
function _cli_add_possible_values_from_LSconfig($context, $withouts, $level=0) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> trace("_cli_add_possible_values_from_LSconfig($context)");
|
||||
if (in_array('select-list', $withouts))
|
||||
return true;
|
||||
if (!LSconfig :: get("$context.translate_labels", True, "bool"))
|
||||
return true;
|
||||
foreach(LSconfig :: get("$context.possible_values", array()) as $pkey => $plabel) {
|
||||
if (is_array($plabel)) {
|
||||
// Sub possible values
|
||||
// Check level
|
||||
if ($level > 1) {
|
||||
$LSlang_cli_logger -> warning(
|
||||
"_cli_add_possible_values_from_LSconfig($context): Level to hight to handle sub possible values of $context.possible_values.$pkey"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
_cli_add_str_to_translate_from_LSconfig("$context.possible_values.$pkey.label");
|
||||
$LSlang_cli_logger -> trace("_cli_add_possible_values_from_LSconfig($context): handle sub possible values of $context.possible_values.$pkey");
|
||||
_cli_add_possible_values_from_LSconfig("$context.possible_values.$pkey", $withouts, $level+1);
|
||||
}
|
||||
else {
|
||||
switch ($pkey) {
|
||||
case 'OTHER_OBJECT':
|
||||
$LSlang_cli_logger -> trace("_cli_add_possible_values_from_LSconfig($context): ignore $context.possible_values.$pkey (OTHER_OBJECT)");
|
||||
break;
|
||||
case 'OTHER_ATTRIBUTE':
|
||||
if (is_array($plabel)) {
|
||||
if (isset($plabel['json_component_key']))
|
||||
_cli_add_str_to_translate_from_LSconfig("$context.possible_values.OTHER_ATTRIBUTE.json_component_label");
|
||||
else
|
||||
_cli_add_str_to_translate_from_LSconfig("$context.possible_values.OTHER_ATTRIBUTE.*");
|
||||
}
|
||||
else {
|
||||
$LSlang_cli_logger -> warning("_cli_add_possible_values_from_LSconfig($context): invalid $context.possible_values.OTHER_ATTRIBUTE config => Must be an array.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_cli_add_str_to_translate($plabel, "$context.possible_values.$pkey");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _cli_parse_template_file($file) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> debug("Looking for string to translate in '$file' template file");
|
||||
$count = 0;
|
||||
foreach(file($file) as $line) {
|
||||
$count ++;
|
||||
if (preg_match_all('/\{ *tr +msg=["\']([^\}]+)["\'] *\}/',$line,$matches)) {
|
||||
foreach($matches[1] as $t) {
|
||||
$t = preg_replace('/[\'"]\|escape\:.*$/', '', $t);
|
||||
$LSlang_cli_logger -> trace(" - \"$t\" # Line $count");
|
||||
_cli_add_str_to_translate($t, _cli_absolute2relative_path($file).":$count");
|
||||
}
|
||||
}
|
||||
}
|
||||
$LSlang_cli_logger -> trace("_cli_parse_template_file($file) : done.");
|
||||
}
|
||||
|
||||
function _cli_find_and_parse_template_file($dir) {
|
||||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file=='.' || $file=='..') continue;
|
||||
if (is_dir($dir.'/'.$file)) {
|
||||
_cli_find_and_parse_template_file($dir.'/'.$file);
|
||||
}
|
||||
elseif (is_file($dir."/".$file) && preg_match('/\.tpl$/',$file)) {
|
||||
_cli_parse_template_file($dir.'/'.$file);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _cli_parse_php_file($file) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> debug("Looking for string to translate in '$file' PHP file");
|
||||
$count = 0;
|
||||
$quote='';
|
||||
$res='';
|
||||
foreach(file($file) as $line) {
|
||||
$count++;
|
||||
$LSlang_cli_logger -> trace("Handle line #$count of '$file' PHP file");
|
||||
$offset=0;
|
||||
while ($pos = strpos($line,'__(',$offset)) {
|
||||
$LSlang_cli_logger -> trace("$file:$count: detect keyword at position #$pos ('$line')");
|
||||
for ($i=$pos+3;$i<strlen($line);$i++) {
|
||||
$offset=$i; // Always increase offset to avoid infinity-loop
|
||||
if (empty($quote)) {
|
||||
// Quote char not detected : try to detect it
|
||||
if ($line[$i]=='\\' || $line[$i]==" " || $line[$i]=="\t") {
|
||||
// Space or escape char : pass
|
||||
$i++;
|
||||
}
|
||||
elseif ($line[$i]=='"' || $line[$i]=="'") {
|
||||
// Quote detected
|
||||
$quote=$line[$i];
|
||||
}
|
||||
elseif ($line[$i]=='$' || $line[$i]==')') {
|
||||
// Variable translation not possible or end function call detected
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Unknown case : continue
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
elseif ($quote) {
|
||||
// Quote char already detected : try to detect end quote char
|
||||
if ($line[$i]=='\\') {
|
||||
// Escape char detected : pass this char and the following one
|
||||
$res.=$line[$i];
|
||||
$i++;
|
||||
$res.=$line[$i];
|
||||
}
|
||||
elseif ($line[$i]==$quote) {
|
||||
// End quote char detected : reset quote char detection and break detection
|
||||
$quote='';
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// End quote char not detected : append current char to result
|
||||
$res.=$line[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Include detected string if not empty and quote char was detected and reseted
|
||||
if (!empty($res) && empty($quote)) {
|
||||
_cli_add_str_to_translate($res, _cli_absolute2relative_path($file).":$count");
|
||||
$res='';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _cli_find_and_parse_php_file($dir, $filename_regex) {
|
||||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if (preg_match($filename_regex, $file)) {
|
||||
_cli_parse_php_file($dir.'/'.$file);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _cli_output_php($fd) {
|
||||
global $LSlang_cli_logger, $additionalfileformat, $data, $copyoriginalvalue, $keep_unused, $translations;
|
||||
fwrite($fd, "<?php\n\n");
|
||||
|
||||
if (!$additionalfileformat) fwrite($fd, "\$GLOBALS['LSlang'] = array (\n");
|
||||
|
||||
foreach($data as $key => $key_data) {
|
||||
if ($copyoriginalvalue && $key_data['translation'] == "") {
|
||||
$val = $key;
|
||||
}
|
||||
else
|
||||
$val = $key_data['translation'];
|
||||
$key=str_replace('"','\\"',$key);
|
||||
$val=str_replace('"','\\"',$val);
|
||||
foreach ($key_data['contexts'] as $context)
|
||||
fwrite($fd, "\n# $context");
|
||||
if ($additionalfileformat) {
|
||||
fwrite($fd, "\n\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n");
|
||||
}
|
||||
else {
|
||||
fwrite($fd, "\n\"$key\" =>\n \"$val\",\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Handle keep unused mode
|
||||
if ($keep_unused) {
|
||||
$unused_msgs = array();
|
||||
foreach ($translations as $msg => $trans)
|
||||
if (!array_key_exists($msg, $data))
|
||||
$unused_msgs[$msg] = $trans;
|
||||
if ($unused_msgs) {
|
||||
fwrite($fd, "\n\n");
|
||||
fwrite($fd, "######################################################################\n");
|
||||
fwrite($fd, "# Unused translations keeped #\n");
|
||||
fwrite($fd, "######################################################################\n");
|
||||
foreach($unused_msgs as $key => $val) {
|
||||
$key=str_replace('"','\\"',$key);
|
||||
$val=str_replace('"','\\"',$val);
|
||||
if ($additionalfileformat) {
|
||||
fwrite($fd, "\n\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n");
|
||||
}
|
||||
else {
|
||||
fwrite($fd, "\n\"$key\" =>\n \"$val\",\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$additionalfileformat) fwrite($fd, "\n);\n");
|
||||
}
|
||||
|
||||
function _cli_clean_for_pot_file($val) {
|
||||
$val = str_replace('"', '\\"', $val);
|
||||
return str_replace("\n", "\\n", $val);
|
||||
}
|
||||
|
||||
function _cli_output_pot($fd) {
|
||||
global $LSlang_cli_logger, $data, $copyoriginalvalue;
|
||||
foreach($data as $key => $key_data) {
|
||||
if ($copyoriginalvalue && $key_data['translation'] == "") {
|
||||
$val = $key;
|
||||
}
|
||||
else
|
||||
$val = $key_data['translation'];
|
||||
foreach ($key_data['contexts'] as $context)
|
||||
fwrite($fd, "#: $context\n");
|
||||
$key = _cli_clean_for_pot_file($key);
|
||||
$val = _cli_clean_for_pot_file($val);
|
||||
fwrite($fd, "msgid \"$key\"\nmsgstr \"$val\"\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
$available_onlys = array("config", "templates", "addons", "auth_methods", "includes");
|
||||
$available_withouts = array_merge($available_onlys, array("select-list"));
|
||||
function cli_generate_lang_file($command_args) {
|
||||
// Use global variables to share it with sub-functions
|
||||
global $LSlang_cli_logger, $available_onlys, $available_withouts, $data, $translations, $interactive,
|
||||
|
@ -273,21 +623,6 @@ function cli_generate_lang_file($command_args) {
|
|||
$curdir = getcwd();
|
||||
chdir(dirname(__FILE__).'/../');
|
||||
|
||||
function relative2absolute_path($path) {
|
||||
if ($path[0] == '/')
|
||||
return $path;
|
||||
global $curdir;
|
||||
return realpath($curdir)."/".$path;
|
||||
}
|
||||
|
||||
function absolute2relative_path($path) {
|
||||
if ($path[0] == '/')
|
||||
$path = realpath($path);
|
||||
if (substr($path, 0, strlen(LS_ROOT_DIR)) == LS_ROOT_DIR)
|
||||
return substr($path, strlen(LS_ROOT_DIR)+1);
|
||||
return $path;
|
||||
}
|
||||
|
||||
for ($i=0; $i < count($command_args); $i++) {
|
||||
switch ($command_args[$i]) {
|
||||
case '--without':
|
||||
|
@ -309,7 +644,7 @@ function cli_generate_lang_file($command_args) {
|
|||
$only = strtolower($command_args[$i]);
|
||||
if (!in_array($only, $available_onlys))
|
||||
LScli :: usage("Invalid -O/--only parameter. Must be one of the following values : '".implode("','", $available_onlys)."'.");
|
||||
elseif ($without)
|
||||
elseif ($withouts)
|
||||
LScli :: usage("You could not use only -O/--only parameter combined with -W/--without parameter.");
|
||||
break;
|
||||
|
||||
|
@ -377,7 +712,7 @@ function cli_generate_lang_file($command_args) {
|
|||
break;
|
||||
|
||||
default:
|
||||
$path = relative2absolute_path($command_args[$i]);
|
||||
$path = _cli_relative2absolute_path($command_args[$i]);
|
||||
if (is_file($path))
|
||||
$load_files[] = $path;
|
||||
else
|
||||
|
@ -385,115 +720,7 @@ function cli_generate_lang_file($command_args) {
|
|||
}
|
||||
}
|
||||
|
||||
function interactive_ask($context, $msg) {
|
||||
global $copyoriginalvalue, $interactive_exit;
|
||||
|
||||
if ($interactive_exit) {
|
||||
if ($copyoriginalvalue)
|
||||
return $msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Format question
|
||||
$empty_action = ($copyoriginalvalue?'copy original message':'pass');
|
||||
$question ="\"$msg\"\n\n => Please enter translated string";
|
||||
$question .= " (i";
|
||||
if (!$copyoriginalvalue)
|
||||
$question .= "/c";
|
||||
$question .= "/q/? or leave empty to $empty_action): ";
|
||||
|
||||
while (true) {
|
||||
if ($context)
|
||||
fwrite(STDERR, "\n# $context\n");
|
||||
fwrite(STDERR, $question);
|
||||
$in = trim(fgets(STDIN));
|
||||
switch($in) {
|
||||
case 'q': // Exit interactive mode
|
||||
case 'Q':
|
||||
$interactive_exit = true;
|
||||
return True;
|
||||
case 'i': // Ignore
|
||||
case 'I':
|
||||
return True;
|
||||
case 'c':
|
||||
case 'C': // Copy
|
||||
if (!$copyoriginalvalue)
|
||||
return $msg;
|
||||
case '?': // Help message
|
||||
fwrite(STDERR, "Available choices:\n");
|
||||
fwrite(STDERR, " - i: ignore this message\n");
|
||||
if (!$copyoriginalvalue)
|
||||
fwrite(STDERR, " - c: copy original message\n");
|
||||
fwrite(STDERR, " - q: quit interactive mode and ignore all following untranslated messages\n");
|
||||
fwrite(STDERR, " - ?: Show this message\n");
|
||||
fwrite(STDERR, "Or leave empty to $empty_action.\n");
|
||||
break;
|
||||
case "": // Empty
|
||||
// On copy orignal value mode, return $msg
|
||||
if ($copyoriginalvalue)
|
||||
return $msg;
|
||||
// Otherwise, leave translation empty
|
||||
return "";
|
||||
default:
|
||||
// Return user input
|
||||
return $in;
|
||||
}
|
||||
}
|
||||
// Supposed to never happen
|
||||
return true;
|
||||
}
|
||||
|
||||
function add($msg, $context=null) {
|
||||
global $LSlang_cli_logger, $lang, $data, $translations, $interactive, $interactive_exit, $copyoriginalvalue, $format;
|
||||
$LSlang_cli_logger -> trace("add($msg, $context)");
|
||||
if ($msg == '')
|
||||
return;
|
||||
if (!is_null($lang) && _($msg) != "$msg")
|
||||
return;
|
||||
|
||||
// Message already exists ?
|
||||
if (array_key_exists($msg, $data)) {
|
||||
if ($context && !in_array($context, $data[$msg]['contexts']))
|
||||
$data[$msg]['contexts'][] = $context;
|
||||
return True;
|
||||
}
|
||||
|
||||
// Handle translation
|
||||
$translation = "";
|
||||
if (array_key_exists($msg, $translations)) {
|
||||
$translation = $translations[$msg];
|
||||
}
|
||||
elseif (!is_null($lang) && _($msg) != $msg) {
|
||||
$translation = _($msg);
|
||||
}
|
||||
elseif ($interactive && $format != 'pot') {
|
||||
$translation = interactive_ask($context, $msg);
|
||||
if (!is_string($translation))
|
||||
return true;
|
||||
}
|
||||
$data[$msg] = array (
|
||||
'translation' => $translation,
|
||||
'contexts' => ($context?array($context):array()),
|
||||
);
|
||||
}
|
||||
|
||||
function addFromLSconfig($pattern, $value='value', $excludes=array()) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> trace("addFromLSconfig($pattern, array(".implode(',', $excludes)."))");
|
||||
$keys = LSconfig :: getMatchingKeys($pattern);
|
||||
$LSlang_cli_logger -> trace("addFromLSconfig : ".count($keys)." matching key(s)");
|
||||
foreach ($keys as $key => $value) {
|
||||
$LSlang_cli_logger -> trace("addFromLSconfig : $key = ".varDump($value));
|
||||
if ($value == 'key') {
|
||||
// Get the last key parts as value and all other as key
|
||||
$key_parts = explode('.', $key);
|
||||
$value = $key_parts[count($key_parts)-1];
|
||||
$key = implode('.', array_slice($key_parts, 0, count($key_parts)-1));
|
||||
}
|
||||
if (!in_array($value, $excludes) && is_string($value))
|
||||
add($value, $key);
|
||||
}
|
||||
}
|
||||
|
||||
// In fix-utf8 mode, load ForceUT8/Encoding lib
|
||||
if ($fix_utf8)
|
||||
|
@ -524,51 +751,6 @@ function cli_generate_lang_file($command_args) {
|
|||
}
|
||||
}
|
||||
|
||||
function addPossibleValuesFromLSconfig($context, $withouts, $level=0) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> trace("addPossibleValuesFromLSconfig($context)");
|
||||
if (in_array('select-list', $withouts))
|
||||
return true;
|
||||
if (!LSconfig :: get("$context.translate_labels", True, "bool"))
|
||||
return true;
|
||||
foreach(LSconfig :: get("$context.possible_values", array()) as $pkey => $plabel) {
|
||||
if (is_array($plabel)) {
|
||||
// Sub possible values
|
||||
// Check level
|
||||
if ($level > 1) {
|
||||
$LSlang_cli_logger -> warning(
|
||||
"addPossibleValuesFromLSconfig($context): Level to hight to handle sub possible values of $context.possible_values.$pkey"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
addFromLSconfig("$context.possible_values.$pkey.label");
|
||||
$LSlang_cli_logger -> trace("addPossibleValuesFromLSconfig($context): handle sub possible values of $context.possible_values.$pkey");
|
||||
addPossibleValuesFromLSconfig("$context.possible_values.$pkey", $withouts, $level+1);
|
||||
}
|
||||
else {
|
||||
switch ($pkey) {
|
||||
case 'OTHER_OBJECT':
|
||||
$LSlang_cli_logger -> trace("addPossibleValuesFromLSconfig($context): ignore $context.possible_values.$pkey (OTHER_OBJECT)");
|
||||
break;
|
||||
case 'OTHER_ATTRIBUTE':
|
||||
if (is_array($plabel)) {
|
||||
if (isset($plabel['json_component_key']))
|
||||
addFromLSconfig("$context.possible_values.OTHER_ATTRIBUTE.json_component_label");
|
||||
else
|
||||
addFromLSconfig("$context.possible_values.OTHER_ATTRIBUTE.*");
|
||||
}
|
||||
else {
|
||||
$LSlang_cli_logger -> warning("addPossibleValuesFromLSconfig($context): invalid $context.possible_values.OTHER_ATTRIBUTE config => Must be an array.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
add($plabel, "$context.possible_values.$pkey");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage configuration parameters
|
||||
*/
|
||||
|
@ -578,14 +760,14 @@ function cli_generate_lang_file($command_args) {
|
|||
$LSlang_cli_logger -> info("Looking for string to translate configuration of LDAP servers");
|
||||
foreach(LSconfig :: keys('ldap_servers') as $ldap_server_id) {
|
||||
$LSlang_cli_logger -> debug("Looking for string to translate configuration of LDAP server #$ldap_server_id");
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.name");
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.subDnLabel");
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.recoveryHashMail.subject");
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.recoveryHashMail.msg");
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.newPasswordMail.subject");
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.newPasswordMail.msg");
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.subDn.*", 'key', array("LSobject"));
|
||||
addFromLSconfig("ldap_servers.$ldap_server_id.LSprofiles.*.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.name");
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.subDnLabel");
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.recoverPassword.recoveryHashMail.subject");
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.recoverPassword.recoveryHashMail.msg");
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.recoverPassword.newPasswordMail.subject");
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.recoverPassword.newPasswordMail.msg");
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.subDn.*", 'key', array("LSobject"));
|
||||
_cli_add_str_to_translate_from_LSconfig("ldap_servers.$ldap_server_id.LSprofiles.*.label");
|
||||
|
||||
// LSaccess
|
||||
foreach (LSconfig :: get("ldap_servers.$ldap_server_id.LSaccess", array()) as $LSobject) {
|
||||
|
@ -606,76 +788,76 @@ function cli_generate_lang_file($command_args) {
|
|||
// LSobject
|
||||
foreach($objects as $obj) {
|
||||
$LSlang_cli_logger -> info("Looking for string to translate configuration of object type $obj");
|
||||
addFromLSconfig("LSobjects.$obj.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.label");
|
||||
|
||||
// LSrelation
|
||||
addFromLSconfig("LSobjects.$obj.LSrelation.*.label");
|
||||
addFromLSconfig("LSobjects.$obj.LSrelation.*.emptyText");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSrelation.*.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSrelation.*.emptyText");
|
||||
|
||||
// Custom Actions
|
||||
addFromLSconfig("LSobjects.$obj.customActions.*.label");
|
||||
addFromLSconfig("LSobjects.$obj.customActions.*.helpInfo");
|
||||
addFromLSconfig("LSobjects.$obj.customActions.*.question_format");
|
||||
addFromLSconfig("LSobjects.$obj.customActions.*.onSuccessMsgFormat");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.customActions.*.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.customActions.*.helpInfo");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.customActions.*.question_format");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.customActions.*.onSuccessMsgFormat");
|
||||
|
||||
// LSform
|
||||
addFromLSconfig("LSobjects.$obj.LSform.layout.*.label");
|
||||
addFromLSconfig("LSobjects.$obj.LSform.dataEntryForm.*.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSform.layout.*.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSform.dataEntryForm.*.label");
|
||||
|
||||
// LSsearch
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.predefinedFilters.*");
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.label");
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.LSformat");
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.alternativeLSformats.*");
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.formaterLSformat");
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.customActions.*.label");
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.customActions.*.question_format");
|
||||
addFromLSconfig("LSobjects.$obj.LSsearch.customActions.*.onSuccessMsgFormat");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.predefinedFilters.*");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.LSformat");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.alternativeLSformats.*");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.formaterLSformat");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.customActions.*.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.customActions.*.question_format");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.LSsearch.customActions.*.onSuccessMsgFormat");
|
||||
|
||||
// Attributes
|
||||
foreach(LSconfig :: keys("LSobjects.$obj.attrs") as $attr) {
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.label");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.help_info");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.no_value_label");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.check_data.*.msg");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.validation.*.msg");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.help_info");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.no_value_label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.check_data.*.msg");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.validation.*.msg");
|
||||
|
||||
// HTML Options
|
||||
$html_type = LSconfig :: get("LSobjects.$obj.attrs.$attr.html_type");
|
||||
switch($html_type) {
|
||||
case 'boolean':
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.true_label");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.false_label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.true_label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.false_label");
|
||||
break;
|
||||
case 'jsonCompositeAttribute':
|
||||
$components = LSconfig :: keys("LSobjects.$obj.attrs.$attr.html_options.components");
|
||||
foreach($components as $c) {
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.label");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.help_info");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.check_data.*.msg");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.label");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.help_info");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.check_data.*.msg");
|
||||
|
||||
if (LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.components.$c.type") == 'select_list')
|
||||
addPossibleValuesFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.options", $withouts);
|
||||
_cli_add_possible_values_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.components.$c.options", $withouts);
|
||||
}
|
||||
break;
|
||||
case 'labeledValue':
|
||||
if (LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.translate_labels", True, "bool"))
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.labels.*");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.labels.*");
|
||||
break;
|
||||
case 'password':
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.mail.subject");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.mail.msg");
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.confirmChangeQuestion");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.mail.subject");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.mail.msg");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.confirmChangeQuestion");
|
||||
break;
|
||||
case 'select_list':
|
||||
case 'select_box':
|
||||
addPossibleValuesFromLSconfig("LSobjects.$obj.attrs.$attr.html_options", $withouts);
|
||||
_cli_add_possible_values_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options", $withouts);
|
||||
break;
|
||||
case 'valueWithUnit':
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.units.*");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.units.*");
|
||||
break;
|
||||
case 'date':
|
||||
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.special_values.*");
|
||||
_cli_add_str_to_translate_from_LSconfig("LSobjects.$obj.attrs.$attr.html_options.special_values.*");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -686,151 +868,39 @@ function cli_generate_lang_file($command_args) {
|
|||
* Manage template file
|
||||
*/
|
||||
if (!in_array('templates', $withouts) && (!$only || $only == 'templates')) {
|
||||
function parse_template_file($file) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> debug("Looking for string to translate in '$file' template file");
|
||||
$count = 0;
|
||||
foreach(file($file) as $line) {
|
||||
$count ++;
|
||||
if (preg_match_all('/\{ *tr +msg=["\']([^\}]+)["\'] *\}/',$line,$matches)) {
|
||||
foreach($matches[1] as $t) {
|
||||
$t = preg_replace('/[\'"]\|escape\:.*$/', '', $t);
|
||||
$LSlang_cli_logger -> trace(" - \"$t\" # Line $count");
|
||||
add($t, absolute2relative_path($file).":$count");
|
||||
}
|
||||
}
|
||||
}
|
||||
$LSlang_cli_logger -> trace("parse_template_file($file) : done.");
|
||||
}
|
||||
|
||||
function find_and_parse_template_file($dir) {
|
||||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file=='.' || $file=='..') continue;
|
||||
if (is_dir($dir.'/'.$file)) {
|
||||
find_and_parse_template_file($dir.'/'.$file);
|
||||
}
|
||||
elseif (is_file($dir."/".$file) && preg_match('/\.tpl$/',$file)) {
|
||||
parse_template_file($dir.'/'.$file);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
$LSlang_cli_logger -> info("Looking for string to translate in templates file");
|
||||
if ($include_upstream) find_and_parse_template_file(LS_ROOT_DIR.'/'.LS_TEMPLATES_DIR);
|
||||
find_and_parse_template_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_TEMPLATES_DIR);
|
||||
if ($include_upstream) _cli_find_and_parse_template_file(LS_ROOT_DIR.'/'.LS_TEMPLATES_DIR);
|
||||
_cli_find_and_parse_template_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_TEMPLATES_DIR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage custom PHP code/config files
|
||||
*/
|
||||
function parse_php_file($file) {
|
||||
global $LSlang_cli_logger;
|
||||
$LSlang_cli_logger -> debug("Looking for string to translate in '$file' PHP file");
|
||||
$count = 0;
|
||||
$quote='';
|
||||
$res='';
|
||||
foreach(file($file) as $line) {
|
||||
$count++;
|
||||
$LSlang_cli_logger -> trace("Handle line #$count of '$file' PHP file");
|
||||
$offset=0;
|
||||
while ($pos = strpos($line,'__(',$offset)) {
|
||||
$LSlang_cli_logger -> trace("$file:$count: detect keyword at position #$pos ('$line')");
|
||||
for ($i=$pos+3;$i<strlen($line);$i++) {
|
||||
$offset=$i; // Always increase offset to avoid infinity-loop
|
||||
if (empty($quote)) {
|
||||
// Quote char not detected : try to detect it
|
||||
if ($line[$i]=='\\' || $line[$i]==" " || $line[$i]=="\t") {
|
||||
// Space or escape char : pass
|
||||
$i++;
|
||||
}
|
||||
elseif ($line[$i]=='"' || $line[$i]=="'") {
|
||||
// Quote detected
|
||||
$quote=$line[$i];
|
||||
}
|
||||
elseif ($line[$i]=='$' || $line[$i]==')') {
|
||||
// Variable translation not possible or end function call detected
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Unknown case : continue
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
elseif (!empty($quote)) {
|
||||
// Quote char already detected : try to detect end quote char
|
||||
if ($line[$i]=='\\') {
|
||||
// Escape char detected : pass this char and the following one
|
||||
$res.=$line[$i];
|
||||
$i++;
|
||||
$res.=$line[$i];
|
||||
}
|
||||
elseif ($line[$i]==$quote) {
|
||||
// End quote char detected : reset quote char detection and break detection
|
||||
$quote='';
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// End quote char not detected : append current char to result
|
||||
$res.=$line[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Include detected string if not empty and quote char was detected and reseted
|
||||
if (!empty($res) && empty($quote)) {
|
||||
add($res, absolute2relative_path($file).":$count");
|
||||
$res='';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function find_and_parse_php_file($dir, $filename_regex) {
|
||||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if (preg_match($filename_regex, $file)) {
|
||||
parse_php_file($dir.'/'.$file);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage includes files
|
||||
*/
|
||||
// Manage includes files
|
||||
if (!in_array('includes', $withouts) && (!$only || $only == 'includes')) {
|
||||
// Note: Upstream code most only use gettext translation, do not handle it here
|
||||
if ($include_upstream) find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_INCLUDE_DIR, '/^(.+)\.php$/');
|
||||
find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_INCLUDE_DIR, '/^(.+)\.php$/');
|
||||
if ($include_upstream) find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_CLASS_DIR, '/^class\.(.+)\.php$/');
|
||||
find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_CLASS_DIR, '/^class\.(.+)\.php$/');
|
||||
if ($include_upstream) _cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_INCLUDE_DIR, '/^(.+)\.php$/');
|
||||
_cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_INCLUDE_DIR, '/^(.+)\.php$/');
|
||||
if ($include_upstream) _cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_CLASS_DIR, '/^class\.(.+)\.php$/');
|
||||
_cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_CLASS_DIR, '/^class\.(.+)\.php$/');
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage addons files
|
||||
*/
|
||||
// Manage addons files
|
||||
if (!in_array('addons', $withouts) && (!$only || $only == 'addons')) {
|
||||
$LSlang_cli_logger -> info("Looking for string to translate in LSaddons PHP code");
|
||||
if ($include_upstream) find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_ADDONS_DIR, '/^LSaddons\.(.+)\.php$/');
|
||||
find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_ADDONS_DIR, '/^LSaddons\.(.+)\.php$/');
|
||||
if ($include_upstream) _cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_ADDONS_DIR, '/^LSaddons\.(.+)\.php$/');
|
||||
_cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_ADDONS_DIR, '/^LSaddons\.(.+)\.php$/');
|
||||
$LSlang_cli_logger -> info("Looking for string to translate in LSaddons configuration files");
|
||||
if ($include_upstream) find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_CONF_DIR.'/LSaddons', '/^config\.LSaddons\.(.+)\.php$$/');
|
||||
find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_CONF_DIR.'/LSaddons', '/^config\.LSaddons\.(.+)\.php$$/');
|
||||
if ($include_upstream) _cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_CONF_DIR.'/LSaddons', '/^config\.LSaddons\.(.+)\.php$$/');
|
||||
_cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_CONF_DIR.'/LSaddons', '/^config\.LSaddons\.(.+)\.php$$/');
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage auth methods files
|
||||
*/
|
||||
// Manage auth methods files
|
||||
if (!in_array('auth_methods', $withouts) && (!$only || $only == 'auth_methods')) {
|
||||
$LSlang_cli_logger -> info("Looking for string to translate in LSauthMethods configuration files");
|
||||
if ($include_upstream) find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_CONF_DIR.'/LSauth', '/^config\.(.+)\.php$$/');
|
||||
find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_CONF_DIR.'/LSauth', '/^config\.(.+)\.php$$/');
|
||||
if ($include_upstream) _cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_CONF_DIR.'/LSauth', '/^config\.(.+)\.php$$/');
|
||||
_cli_find_and_parse_php_file(LS_ROOT_DIR.'/'.LS_LOCAL_DIR.LS_CONF_DIR.'/LSauth', '/^config\.(.+)\.php$$/');
|
||||
}
|
||||
|
||||
// Sort resulting strings
|
||||
|
@ -839,82 +909,12 @@ function cli_generate_lang_file($command_args) {
|
|||
/*
|
||||
* Handle output file format
|
||||
*/
|
||||
function output_php($fd) {
|
||||
global $LSlang_cli_logger, $additionalfileformat, $data, $copyoriginalvalue, $keep_unused, $translations;
|
||||
fwrite($fd, "<?php\n\n");
|
||||
|
||||
if (!$additionalfileformat) fwrite($fd, "\$GLOBALS['LSlang'] = array (\n");
|
||||
|
||||
foreach($data as $key => $key_data) {
|
||||
if ($copyoriginalvalue && $key_data['translation'] == "") {
|
||||
$val = $key;
|
||||
}
|
||||
else
|
||||
$val = $key_data['translation'];
|
||||
$key=str_replace('"','\\"',$key);
|
||||
$val=str_replace('"','\\"',$val);
|
||||
foreach ($key_data['contexts'] as $context)
|
||||
fwrite($fd, "\n# $context");
|
||||
if ($additionalfileformat) {
|
||||
fwrite($fd, "\n\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n");
|
||||
}
|
||||
else {
|
||||
fwrite($fd, "\n\"$key\" =>\n \"$val\",\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Handle keep unused mode
|
||||
if ($keep_unused) {
|
||||
$unused_msgs = array();
|
||||
foreach ($translations as $msg => $trans)
|
||||
if (!array_key_exists($msg, $data))
|
||||
$unused_msgs[$msg] = $trans;
|
||||
if ($unused_msgs) {
|
||||
fwrite($fd, "\n\n");
|
||||
fwrite($fd, "######################################################################\n");
|
||||
fwrite($fd, "# Unused translations keeped #\n");
|
||||
fwrite($fd, "######################################################################\n");
|
||||
foreach($unused_msgs as $key => $val) {
|
||||
$key=str_replace('"','\\"',$key);
|
||||
$val=str_replace('"','\\"',$val);
|
||||
if ($additionalfileformat) {
|
||||
fwrite($fd, "\n\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n");
|
||||
}
|
||||
else {
|
||||
fwrite($fd, "\n\"$key\" =>\n \"$val\",\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$additionalfileformat) fwrite($fd, "\n);\n");
|
||||
}
|
||||
|
||||
function clean_for_pot_file($val) {
|
||||
$val = str_replace('"', '\\"', $val);
|
||||
return str_replace("\n", "\\n", $val);
|
||||
}
|
||||
|
||||
function output_pot($fd) {
|
||||
global $LSlang_cli_logger, $data, $copyoriginalvalue;
|
||||
foreach($data as $key => $key_data) {
|
||||
if ($copyoriginalvalue && $key_data['translation'] == "") {
|
||||
$val = $key;
|
||||
}
|
||||
else
|
||||
$val = $key_data['translation'];
|
||||
foreach ($key_data['contexts'] as $context)
|
||||
fwrite($fd, "#: $context\n");
|
||||
$key = clean_for_pot_file($key);
|
||||
$val = clean_for_pot_file($val);
|
||||
fwrite($fd, "msgid \"$key\"\nmsgstr \"$val\"\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Determine where to write result
|
||||
if ($output) {
|
||||
$output = relative2absolute_path($output);
|
||||
$output = _cli_relative2absolute_path($output);
|
||||
$LSlang_cli_logger -> info("Write result in output file ($output)");
|
||||
$fd = null;
|
||||
try {
|
||||
$LSlang_cli_logger -> debug("Open output file ($output)");
|
||||
$fd = fopen($output, 'w');
|
||||
|
@ -935,11 +935,11 @@ function cli_generate_lang_file($command_args) {
|
|||
$LSlang_cli_logger -> debug("Output format : $format");
|
||||
switch($format) {
|
||||
case 'pot':
|
||||
output_pot($fd);
|
||||
_cli_output_pot($fd);
|
||||
break;
|
||||
case 'php':
|
||||
default:
|
||||
output_php($fd);
|
||||
_cli_output_php($fd);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -459,7 +459,7 @@ class LSldap extends LSlog_staticLoggerClass {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (!is_empty($val)) {
|
||||
if (!is_empty($attrVal)) {
|
||||
$drop = false;
|
||||
$changed_attrs[$attrName][]=$attrVal;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
public function getDisplayName($spe=null, $full=false) {
|
||||
if (is_null($spe))
|
||||
$spe = $this -> getDisplayNameFormat();
|
||||
$val = $this -> getFData($spe, $this -> attrs, 'getDisplayValue');
|
||||
$val = $this -> getDisplayFData($spe);
|
||||
if (LSsession :: haveSubDn() && $full) {
|
||||
$val.=' ('.$this -> subDnName.')';
|
||||
}
|
||||
|
@ -216,11 +216,13 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
$LSform = new LSform($this, $idForm, null, $api_mode);
|
||||
$this -> forms[$idForm] = array($LSform, $load);
|
||||
|
||||
$loadObject = null;
|
||||
if ($load) {
|
||||
$type = $this -> getType();
|
||||
$loadObject = new $type();
|
||||
if (!$loadObject -> loadData($load)) {
|
||||
$load=false;
|
||||
$load = false;
|
||||
$loadObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -761,18 +763,19 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
* - [1] : les paramètres suivants
|
||||
*/
|
||||
public static function getDnInfos($dn) {
|
||||
$infos=ldap_explode_dn($dn,0);
|
||||
$infos = ldap_explode_dn($dn, 0);
|
||||
if(!$infos)
|
||||
return;
|
||||
$first=true;
|
||||
for($i=1;$i<$infos['count'];$i++)
|
||||
$first = true;
|
||||
$basedn = "";
|
||||
for($i=1; $i<$infos['count']; $i++)
|
||||
if($first) {
|
||||
$basedn.=$infos[$i];
|
||||
$first=false;
|
||||
$basedn .= $infos[$i];
|
||||
$first = false;
|
||||
}
|
||||
else
|
||||
$basedn.=','.$infos[$i];
|
||||
return array($infos[0],$basedn);
|
||||
$basedn .= ','.$infos[$i];
|
||||
return array($infos[0], $basedn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2329,7 +2332,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
}
|
||||
|
||||
if ($confirm) {
|
||||
$obj -> _cli_show($raw_values);
|
||||
$obj -> _cli_show();
|
||||
// Sure ?
|
||||
if (!LScli :: confirm("\nAre you sure you want to delete this object?"))
|
||||
return True;
|
||||
|
@ -2449,7 +2452,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
* @retval boolean True on success, false otherwise
|
||||
**/
|
||||
public static function cli_create($command_args) {
|
||||
$objType = null;
|
||||
$objType = $obj = null;
|
||||
$delimiter = "|";
|
||||
$confirm = true;
|
||||
$just_try = false;
|
||||
|
@ -2484,6 +2487,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
}
|
||||
}
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
if (is_null($objType) || empty($attrs_values))
|
||||
LScli :: usage('You must provide LSobject type, DN and at least one change.');
|
||||
|
||||
|
@ -2612,7 +2616,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
* @retval boolean True on success, false otherwise
|
||||
**/
|
||||
public static function cli_modify($command_args) {
|
||||
$objType = null;
|
||||
$objType = $obj = null;
|
||||
$dn = null;
|
||||
$delimiter = "|";
|
||||
$confirm = true;
|
||||
|
@ -2651,6 +2655,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
|||
}
|
||||
}
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
if (is_null($objType) || is_null($dn) || empty($changes))
|
||||
LScli :: usage('You must provide LSobject type, DN and at least one change.');
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class LSlog_console extends LSlog_handler {
|
|||
$this -> stdout = fopen('php://stdout', 'w');
|
||||
$this -> stderr = fopen('php://stderr', 'w');
|
||||
if ($this -> enabled)
|
||||
self :: log_trace("$this Enabled", get_class($this));
|
||||
self :: log_trace("$this Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ class LSlog_email extends LSlog_handler {
|
|||
parent :: __construct($config);
|
||||
$this -> recipient = self :: getConfig('recipient');
|
||||
if ($this -> enabled)
|
||||
self :: log_trace("$this Enabled", get_class($this));
|
||||
self :: log_trace("$this Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ class LSlog_file extends LSlog_handler {
|
|||
if (substr($this -> path, 0, 1) != '/')
|
||||
$this -> path = LS_ROOT_DIR."/".$this -> path;
|
||||
if ($this -> enabled)
|
||||
self :: log_trace("$this Enabled", get_class($this));
|
||||
self :: log_trace("$this Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -237,7 +237,7 @@ class LSlog_handler extends LSlog_staticLoggerClass {
|
|||
if (isset(LSsession :: $ldapServer['name']))
|
||||
return LSsession :: $ldapServer['name'];
|
||||
else
|
||||
return "#".LSsession :: $ldapServerId;
|
||||
return "#".LSsession :: get('ldap_server_id');
|
||||
}
|
||||
return "Not connected";
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class LSlog_syslog extends LSlog_handler {
|
|||
parent :: __construct($config);
|
||||
$this -> priority = static :: getConfig('priority');
|
||||
if ($this -> enabled)
|
||||
self :: log_trace("$this Enabled", get_class($this));
|
||||
self :: log_trace("$this Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,7 +40,7 @@ class LSlog_system extends LSlog_handler {
|
|||
public function __construct($config) {
|
||||
parent :: __construct($config);
|
||||
if ($this -> enabled)
|
||||
self :: log_trace("$this Enabled", get_class($this));
|
||||
self :: log_trace("$this Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,28 +37,28 @@ class LSmail {
|
|||
}
|
||||
|
||||
public static function ajax_display(&$data) {
|
||||
if (isset($_REQUEST['object']['type']) && isset($_REQUEST['object']['dn'])) {
|
||||
if (LSsession ::loadLSobject($_REQUEST['object']['type'])) {
|
||||
$obj = new $_REQUEST['object']['type']();
|
||||
$obj -> loadData($_REQUEST['object']['dn']);
|
||||
$msg = $obj -> getFData($_REQUEST['msg']);
|
||||
$subject = $obj -> getFData($_REQUEST['subject']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$msg = $_REQUEST['msg'];
|
||||
$subject = $_REQUEST['subject'];
|
||||
$msg = $_REQUEST['msg'];
|
||||
$subject = $_REQUEST['subject'];
|
||||
if (
|
||||
isset($_REQUEST['object']['type'])
|
||||
&& isset($_REQUEST['object']['dn'])
|
||||
&& LSsession ::loadLSobject($_REQUEST['object']['type'])
|
||||
) {
|
||||
$obj = new $_REQUEST['object']['type']();
|
||||
$obj -> loadData($_REQUEST['object']['dn']);
|
||||
$msg = $obj -> getFData($msg);
|
||||
$subject = $obj -> getFData($subject);
|
||||
}
|
||||
|
||||
LStemplate :: assign('LSmail_msg',$msg);
|
||||
LStemplate :: assign('LSmail_subject',$subject);
|
||||
LStemplate :: assign('LSmail_options',$_REQUEST['options']);
|
||||
LStemplate :: assign('LSmail_msg', $msg);
|
||||
LStemplate :: assign('LSmail_subject', $subject);
|
||||
LStemplate :: assign('LSmail_options', $_REQUEST['options']);
|
||||
|
||||
if (is_array($_REQUEST['mails'])) {
|
||||
LStemplate :: assign('LSmail_mails',$_REQUEST['mails']);
|
||||
LStemplate :: assign('LSmail_mails', $_REQUEST['mails']);
|
||||
}
|
||||
else if(empty($_REQUEST['mails'])) {
|
||||
LStemplate :: assign('LSmail_mails',array($_REQUEST['mails']));
|
||||
LStemplate :: assign('LSmail_mails', array($_REQUEST['mails']));
|
||||
}
|
||||
|
||||
$data = array(
|
||||
|
|
|
@ -135,7 +135,7 @@ class LSsearch extends LSlog_staticLoggerClass {
|
|||
foreach($this -> config['predefinedFilters'] as $filter => $label) {
|
||||
if(!LSldap::isValidFilter($filter)) {
|
||||
LSerror::addErrorCode('LSsearch_15',array('label' => $label, 'filter' => $filter, 'type' => $this -> LSobject));
|
||||
unset($this -> config['predefinedFilters'][$key]);
|
||||
unset($this -> config['predefinedFilters'][$filter]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ class LSsearch extends LSlog_staticLoggerClass {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(!empty($filters)) {
|
||||
if($filters) {
|
||||
$filter=LSldap::combineFilters('or',$filters);
|
||||
if ($filter) {
|
||||
return $filter;
|
||||
|
@ -1049,7 +1049,7 @@ class LSsearch extends LSlog_staticLoggerClass {
|
|||
}
|
||||
if (!$searchParams)
|
||||
return false;
|
||||
if ($searchParams['filter'] instanceof Net_LDAP_Filter) {
|
||||
if ($searchParams['filter'] instanceof Net_LDAP2_Filter) {
|
||||
$searchParams['filter'] = $searchParams['filter'] -> asString();
|
||||
}
|
||||
$to_hash = print_r($searchParams, true);
|
||||
|
|
|
@ -42,16 +42,19 @@ class LSsearchEntry extends LSlog_staticLoggerClass {
|
|||
private $params = array();
|
||||
|
||||
// The attributes list
|
||||
private $attrs_list=array();
|
||||
private $attrs_list = array();
|
||||
|
||||
// The attributes values
|
||||
private $attrs=array();
|
||||
private $attrs = array();
|
||||
|
||||
// The index of the entry in the result of the search
|
||||
private $id = null;
|
||||
|
||||
// Cache
|
||||
private $cache=array();
|
||||
private $cache = array();
|
||||
|
||||
// Other values
|
||||
private $other_values=array();
|
||||
private $other_values = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
@ -140,6 +140,8 @@ class LSsession {
|
|||
return self :: getEmailSender();
|
||||
case 'api_mode':
|
||||
return boolval(self :: $api_mode);
|
||||
case 'ldap_server_id':
|
||||
return boolval(self :: $ldapServerId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -371,7 +373,7 @@ class LSsession {
|
|||
'libs_dir' => LS_ROOT_DIR. '/'. LS_LIB_DIR,
|
||||
'compile_dir' => LS_TMP_DIR_PATH,
|
||||
'debug' => LSdebug,
|
||||
'debug_smarty' => (isset($_REQUEST) && isset($_REQUEST['LStemplate_debug'])),
|
||||
'debug_smarty' => isset($_REQUEST['LStemplate_debug']),
|
||||
)
|
||||
))
|
||||
return False;
|
||||
|
@ -863,7 +865,7 @@ class LSsession {
|
|||
if (self :: $ldapServerId) {
|
||||
LStemplate :: assign('ldapServerId',self :: $ldapServerId);
|
||||
}
|
||||
if (isset($_GET['LSsession_recoverPassword'])) {
|
||||
if (isset($recoveryPasswordInfos)) {
|
||||
self :: displayRecoverPasswordForm($recoveryPasswordInfos);
|
||||
}
|
||||
elseif(LSauth :: displayLoginForm()) {
|
||||
|
@ -1836,7 +1838,7 @@ class LSsession {
|
|||
}
|
||||
|
||||
if (LSerror :: errorsDefined()) {
|
||||
$data['errors'] = LSerror :: getErrors(self :: $api_mode);
|
||||
$data['errors'] = LSerror :: getErrors();
|
||||
}
|
||||
|
||||
if (!self :: $api_mode && LSdebugDefined()) {
|
||||
|
@ -2414,7 +2416,7 @@ class LSsession {
|
|||
* @param string $authorized The authorized maximum right
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkRight($requested, $authorized) {
|
||||
public static function checkRight($requested, $authorized) {
|
||||
if ($requested == $authorized)
|
||||
return true;
|
||||
if ($requested == 'r' && $authorized == 'w')
|
||||
|
@ -3161,7 +3163,7 @@ class LSsession {
|
|||
'LSsession_21',
|
||||
array(
|
||||
'func' => $func -> getName(),
|
||||
'addon' => $addon,
|
||||
'addon' => $LSaddon,
|
||||
'view' => $viewId,
|
||||
)
|
||||
);
|
||||
|
@ -3172,7 +3174,7 @@ class LSsession {
|
|||
'LSsession_23',
|
||||
array(
|
||||
'func' => $viewFunction,
|
||||
'addon' => $addon,
|
||||
'addon' => $LSaddon,
|
||||
'view' => $viewId,
|
||||
)
|
||||
);
|
||||
|
|
|
@ -652,18 +652,15 @@ class LStemplate extends LSlog_staticLoggerClass {
|
|||
}
|
||||
|
||||
function LStemplate_smarty_getFData($params) {
|
||||
extract($params);
|
||||
echo getFData($format,$data,$meth=NULL);
|
||||
echo getFData($params['format'], $params['data'], $meth=NULL);
|
||||
}
|
||||
|
||||
function LStemplate_smarty_tr($params) {
|
||||
extract($params);
|
||||
echo __($msg);
|
||||
echo __($params['msg']);
|
||||
}
|
||||
|
||||
function LStemplate_smarty_img($params) {
|
||||
extract($params);
|
||||
echo "image/$name";
|
||||
echo "image/".$params['name'];
|
||||
}
|
||||
|
||||
function LStemplate_smarty_css($params) {
|
||||
|
|
|
@ -131,7 +131,7 @@ class LSurl extends LSlog_staticLoggerClass {
|
|||
// Reset last redirect
|
||||
if (isset($_SESSION['last_redirect']))
|
||||
unset($_SESSION['last_redirect']);
|
||||
self :: log_debug("URL : result :\n".varDump($request, 1));
|
||||
self :: log_debug("URL : result :\n".varDump($request));
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
ini_set( 'magic_quotes_gpc', 'off' );
|
||||
ini_set( 'magic_quotes_sybase', 'off' );
|
||||
ini_set( 'magic_quotes_runtime', 'off' );
|
||||
if ((isset($_REQUEST) && isset($_REQUEST['LSdebug'])) || (isset($_SERVER['HTTP_HOST']) && preg_match('/^127\.[0-9]+\.[0-9]+\.[0-9]+$/', $_SERVER['HTTP_HOST'])))
|
||||
if (isset($_REQUEST['LSdebug']) || (isset($_SERVER['HTTP_HOST']) && preg_match('/^127\.[0-9]+\.[0-9]+\.[0-9]+$/', $_SERVER['HTTP_HOST'])))
|
||||
error_reporting(E_ALL);
|
||||
else
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||||
|
|
|
@ -788,7 +788,7 @@ function dateTime2LdapDate($datetime, $timezone=null, $format=null) {
|
|||
$datetime -> setTimezone(timezone_open(is_null($timezone)?'UTC':$timezone));
|
||||
}
|
||||
if (is_null($format))
|
||||
$format = ($naive?'YmdHis':'YmdHisO');
|
||||
$format = ($timezone == 'naive'?'YmdHis':'YmdHisO');
|
||||
$datetime_string = $datetime -> format($format);
|
||||
|
||||
// Replace +0000 or -0000 end by Z
|
||||
|
|
|
@ -262,6 +262,8 @@ LSurl :: add_handler('#^global_search\.php#', 'handle_old_global_search_php', fa
|
|||
* @retval void
|
||||
**/
|
||||
function handle_static_file($request) {
|
||||
$path = null;
|
||||
$mime_type = null;
|
||||
switch ($request -> type) {
|
||||
case 'image':
|
||||
$path = LStemplate :: getImagePath($request -> file);
|
||||
|
@ -276,7 +278,7 @@ function handle_static_file($request) {
|
|||
$mime_type = 'text/javascript';
|
||||
break;
|
||||
}
|
||||
if ($path && is_file($path)) {
|
||||
if ($path && is_file($path)) {
|
||||
dumpFile($path, $mime_type);
|
||||
}
|
||||
LSurl :: error_404($request);
|
||||
|
@ -1775,7 +1777,7 @@ function handle_api_LSobject_import($request) {
|
|||
$data['updateIfExists'],
|
||||
$data['justTry']
|
||||
);
|
||||
LSlog :: debug("LSio::importFromPostData(): result = ".varDump($result));
|
||||
LSlog :: debug("LSio::importFromPostData(): result = ".varDump($data));
|
||||
}
|
||||
|
||||
LSsession :: displayAjaxReturn($data);
|
||||
|
@ -1946,7 +1948,7 @@ function handle_api_LSobject_remove($request) {
|
|||
$data['success'] = true;
|
||||
}
|
||||
else {
|
||||
LSerror :: addErrorCode('LSldapObject_15', $objectname);
|
||||
LSerror :: addErrorCode('LSldapObject_15', $data['name']);
|
||||
}
|
||||
LSsession :: displayAjaxReturn($data);
|
||||
}
|
||||
|
@ -1972,7 +1974,7 @@ function handle_api_LSobject_relation($request) {
|
|||
// Handle relation URL parameter
|
||||
$relationName = $request -> relation;
|
||||
if (!is_array($object -> getConfig("LSrelation.$relationName"))) {
|
||||
LSlog :: log_error("LSobject $LSobject have no relation '$relationName'.");
|
||||
LSlog :: error("LSobject $LSobject have no relation '$relationName'.");
|
||||
LSsession :: displayAjaxReturn();
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue