Skip to content

Commit

Permalink
Escape colon for NLK.
Browse files Browse the repository at this point in the history
  • Loading branch information
matussabik committed Mar 8, 2016
1 parent abb3782 commit b43d6df
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions module/CPK/src/CPK/Controller/AjaxController.php
Expand Up @@ -206,7 +206,8 @@ public function getHoldingsStatusesAjax()
else $nextItemToken = $usedGetStatus = $usedAleph = null;

foreach ($statuses as $status) {
$id = $status['item_id'];
$unescId = $status['item_id'];
$id = str_replace(':', '\:', $status['item_id']);

$itemsStatuses[$id] = [];

Expand Down Expand Up @@ -245,7 +246,7 @@ public function getHoldingsStatusesAjax()
if (! empty($status['department']))
$itemsStatuses[$id]['department'] = $status['department'];

$key = array_search(trim($id), $ids);
$key = array_search(trim($unescId), $ids);

if ($key !== false)
unset($ids[$key]);
Expand Down Expand Up @@ -434,6 +435,8 @@ public function getMyHoldsAjax()
'AJAX' => true
]);

$cat_username = str_replace(':', '\:', $cat_username);

$toRet = [
'html' => $html,
'obalky' => $obalky,
Expand Down Expand Up @@ -578,6 +581,7 @@ public function getMyTransactionsAjax()
'AJAX' => true
]);

$cat_username = str_replace(':', '\:', $cat_username);
$splitted_cat_username = explode('.', $cat_username);

$toRet = [
Expand Down Expand Up @@ -607,32 +611,32 @@ public function getMyTransactionsAjax()
public function getMyNotificationsAjax()
{
$cat_username = $this->params()->fromPost('cat_username');

// Check user's permissions
$hasPermissions = $this->hasPermissions($cat_username);

// Redirect if not authorized
if ($hasPermissions instanceof \Zend\Http\Response)
return $hasPermissions;

$notifHandler = $this->getServiceLocator()->get('CPK\NotificationsHandler');

// Check we have correct notifications handler
if (! $notifHandler instanceof \CPK\Notifications\NotificationsHandler) {

return $this->output([
'errors' => [
'Did not found expected Notifications handler'
],
'notifications' => []
], self::STATUS_ERROR);
}

try {

$userNotifications = $notifHandler->getUserNotifications($cat_username);
} catch (\Exception $e) {

$userNotifications = [
'errors' => [
$e->getMessage()
Expand All @@ -645,7 +649,7 @@ public function getMyNotificationsAjax()
]
];
}

return $this->output($userNotifications, self::STATUS_OK);
}

Expand Down Expand Up @@ -710,7 +714,7 @@ public function pushFavoritesAjax() {

/**
* Updates read notifications related to user's identity
*
*
* @return \Zend\Http\Response
*/
public function notificationReadAjax()
Expand All @@ -723,31 +727,31 @@ public function notificationReadAjax()
$notificationType = $this->params()->fromPost( 'notificationType' );

$notifHandler = $this->getServiceLocator()->get('CPK\NotificationsHandler');

// Check we have correct notifications handler
if (! $notifHandler instanceof \CPK\Notifications\NotificationsHandler) {

return $this->output([
'errors' => [
'Did not found expected Notifications handler'
],
'notifications' => []
], self::STATUS_ERROR);
}

try {

$notifHandler->setUserNotificationRead($user, $notificationType);
} catch (\Exception $e) {

$userNotifications = [
'errors' => [
$e->getMessage()
],
'notifications' => []
];
}

return $this->output(null, self::STATUS_OK);
}

Expand Down

0 comments on commit b43d6df

Please sign in to comment.