Exemple #1
0
 /**
  * Reorder media on a region
  * @return <XiboAPIResponse>
  */
 public function LayoutRegionMediaReorder()
 {
     if (!$this->user->PageAuth('layout')) {
         return $this->Error(1, 'Access Denied');
     }
     $layoutId = $this->GetParam('layoutId', _INT);
     $regionId = $this->GetParam('regionId', _STRING);
     $mediaList = $this->GetParam('mediaList', _ARRAY);
     // Does the user have permissions to view this region?
     if (!$this->user->LayoutAuth($layoutId)) {
         return $this->Error(1, 'Access Denied');
     }
     // Check the user has permission
     Kit::ClassLoader('region');
     $region = new region();
     $ownerId = $region->GetOwnerId($layoutId, $regionId);
     $regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutId, $regionId, true);
     if (!$regionAuth->edit) {
         return $this->Error(1, 'Access Denied');
     }
     // TODO: Validate the media list in some way (make sure there are the correct number of items)
     // Hand off to the region object to do the actual reorder
     if (!$region->ReorderTimeline($layoutId, $regionId, $mediaList)) {
         return $this->Error($region->GetErrorNumber(), $region->GetErrorMessage());
     }
     return $this->Respond($this->ReturnId('success', true));
 }
Exemple #2
0
 /**
  * Re-orders a medias regions
  * @return
  */
 function TimelineReorder()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     // Vars
     $layoutId = Kit::GetParam('layoutid', _REQUEST, _INT);
     $regionId = Kit::GetParam('regionid', _POST, _STRING);
     $mediaList = Kit::GetParam('medialist', _POST, _STRING);
     // Check the user has permission
     Kit::ClassLoader('region');
     $region = new region($db);
     $ownerId = $region->GetOwnerId($layoutId, $regionId);
     $regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutId, $regionId, true);
     if (!$regionAuth->edit) {
         trigger_error(__('You do not have permissions to edit this region'), E_USER_ERROR);
     }
     // Create a list of media
     if ($mediaList == '') {
         trigger_error(__('No media to reorder'));
     }
     // Trim the last | if there is one
     $mediaList = rtrim($mediaList, '|');
     // Explode into an array
     $mediaList = explode('|', $mediaList);
     // Store in an array
     $resolvedMedia = array();
     foreach ($mediaList as $mediaNode) {
         // Explode the second part of the array
         $mediaNode = explode(',', $mediaNode);
         $resolvedMedia[] = array('mediaid' => $mediaNode[0], 'lkid' => $mediaNode[1]);
     }
     // Hand off to the region object to do the actual reorder
     if (!$region->ReorderTimeline($layoutId, $regionId, $resolvedMedia)) {
         trigger_error($region->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Order Changed'));
     $response->keepOpen = true;
     $response->Respond();
 }