Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
AjxpUtils::convertBytes : handle comma
Browse files Browse the repository at this point in the history
Ajxp_VarsFilter::filter : pass an object or an id as resolve user
  • Loading branch information
cdujeu committed Apr 16, 2015
1 parent 803d7fd commit d20c545
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/src/core/classes/class.AJXP_Utils.php
Expand Up @@ -704,7 +704,8 @@ public static function convertBytes($value)
return intval($value);
} else {
$value_length = strlen($value);
$qty = substr($value, 0, $value_length - 1);
$value = str_replace(",",".", $value);
$qty = floatval(substr($value, 0, $value_length - 1));
$unit = strtolower(substr($value, $value_length - 1));
switch ($unit) {
case 'k':
Expand Down
15 changes: 12 additions & 3 deletions core/src/core/classes/class.AJXP_VarsFilter.php
Expand Up @@ -33,15 +33,20 @@ class AJXP_VarsFilter
* Calls the vars.filter hooks.
* @static
* @param $value
* @param AbstractAjxpUser $resolveUser
* @param AbstractAjxpUser|String $resolveUser
* @return mixed|string
*/
public static function filter($value, $resolveUser = null)
{
if (is_string($value) && strpos($value, "AJXP_USER")!==false) {
if (AuthService::usersEnabled()) {
if($resolveUser != null){
$value = str_replace("AJXP_USER", $resolveUser->getId(), $value);
if(is_string($resolveUser)){
$resolveUserId = $resolveUser;
} else {
$resolveUserId = $resolveUser->getId();
}
$value = str_replace("AJXP_USER", $resolveUserId, $value);
}else{
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null) {
Expand All @@ -62,7 +67,11 @@ public static function filter($value, $resolveUser = null)
if (is_string($value) && strpos($value, "AJXP_GROUP_PATH")!==false) {
if (AuthService::usersEnabled()) {
if($resolveUser != null){
$loggedUser = $resolveUser;
if(is_string($resolveUser) && AuthService::userExists($resolveUser)){
$loggedUser = ConfService::getConfStorageImpl()->createUserObject($resolveUser);
}else{
$loggedUser = $resolveUser;
}
}else{
$loggedUser = AuthService::getLoggedUser();
}
Expand Down

0 comments on commit d20c545

Please sign in to comment.