Fix on pics urls encoding
Change-Id: I8567856051e6781be18dae4eb77a63b2a8a817d4
This commit is contained in:
parent
f2439838b8
commit
14e58c4808
@ -1,5 +1,4 @@
|
||||
<?php namespace Libs\ModelSerializers;
|
||||
|
||||
/**
|
||||
* Copyright 2016 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -12,11 +11,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use libs\utils\JsonUtils;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
use models\utils\IEntity;
|
||||
|
||||
/**
|
||||
* Class AbstractSerializer
|
||||
* @package Libs\ModelSerializers
|
||||
@ -188,6 +185,9 @@ abstract class AbstractSerializer implements IModelSerializer
|
||||
{
|
||||
$value = JsonUtils::toObfuscatedEmail($value);
|
||||
}
|
||||
case 'json_url':{
|
||||
$value = JsonUtils::encodeUrl($value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,20 @@ abstract class JsonUtils
|
||||
return $obfuscated_email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
public static function encodeUrl(string $url):string{
|
||||
$url= rawurlencode($url);
|
||||
$url = str_replace("%3A",":", $url);
|
||||
$url = str_replace("%2F","/", $url);
|
||||
$url = str_replace("%3D","=", $url);
|
||||
$url = str_replace("%3F","?", $url);
|
||||
$url = str_replace("%26","&", $url);
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return bool
|
||||
|
@ -35,6 +35,7 @@ class AbstractMemberSerializer extends SilverStripeSerializer
|
||||
'Country' => 'country:json_string',
|
||||
'Active' => 'active:json_boolean',
|
||||
'EmailVerified' => 'email_verified:json_boolean',
|
||||
'ProfilePhotoUrl' => 'pic:json_url',
|
||||
];
|
||||
|
||||
protected static $allowed_relations = [
|
||||
@ -57,8 +58,7 @@ class AbstractMemberSerializer extends SilverStripeSerializer
|
||||
|
||||
if(!count($relations)) $relations = $this->getAllowedRelations();
|
||||
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$values['pic'] = $member->getProfilePhotoUrl();
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
|
||||
if(in_array('groups', $relations))
|
||||
$values['groups'] = $member->getGroupsIds();
|
||||
|
@ -21,21 +21,22 @@ use models\summit\PresentationSpeaker;
|
||||
class PresentationSpeakerSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = [
|
||||
'FirstName' => 'first_name:json_string',
|
||||
'LastName' => 'last_name:json_string',
|
||||
'Title' => 'title:json_string',
|
||||
'Bio' => 'bio:json_string',
|
||||
'IRCHandle' => 'irc:json_string',
|
||||
'TwitterName' => 'twitter:json_string',
|
||||
'OrgHasCloud' => 'org_has_cloud:json_boolean',
|
||||
'Country' => 'country:json_string',
|
||||
'AvailableForBureau' => 'available_for_bureau:json_boolean',
|
||||
'FundedTravel' => 'funded_travel:json_boolean',
|
||||
'WillingToTravel' => 'willing_to_travel:json_boolean',
|
||||
'WillingToPresentVideo' => 'willing_to_present_video:json_boolean',
|
||||
'FirstName' => 'first_name:json_string',
|
||||
'LastName' => 'last_name:json_string',
|
||||
'Title' => 'title:json_string',
|
||||
'Bio' => 'bio:json_string',
|
||||
'IRCHandle' => 'irc:json_string',
|
||||
'TwitterName' => 'twitter:json_string',
|
||||
'OrgHasCloud' => 'org_has_cloud:json_boolean',
|
||||
'Country' => 'country:json_string',
|
||||
'AvailableForBureau' => 'available_for_bureau:json_boolean',
|
||||
'FundedTravel' => 'funded_travel:json_boolean',
|
||||
'WillingToTravel' => 'willing_to_travel:json_boolean',
|
||||
'WillingToPresentVideo' => 'willing_to_present_video:json_boolean',
|
||||
'Email' => 'email:json_obfuscated_email',
|
||||
'MemberID' => 'member_id:json_int',
|
||||
'RegistrationRequestId' => 'registration_request_id:json_int'
|
||||
'RegistrationRequestId' => 'registration_request_id:json_int',
|
||||
'ProfilePhotoUrl' => 'pic:json_url'
|
||||
];
|
||||
|
||||
protected static $allowed_relations = [
|
||||
@ -64,8 +65,6 @@ class PresentationSpeakerSerializer extends SilverStripeSerializer
|
||||
$values['moderated_presentations'] = $speaker->getModeratedPresentationIds($summit_id, $published);
|
||||
}
|
||||
|
||||
$values['pic'] = $speaker->getProfilePhotoUrl();
|
||||
|
||||
if (in_array('member', $relations) && $speaker->hasMember())
|
||||
{
|
||||
$member = $speaker->getMember();
|
||||
|
Loading…
x
Reference in New Issue
Block a user