/** * Add media to a region from the Library * @return <XiboAPIResponse> */ public function LayoutRegionLibraryAdd() { 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'); } // Make sure we have permission to edit this region 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'); } if (!$region->AddFromLibrary($this->user, $layoutId, $regionId, $mediaList)) { return $this->Error($region->GetErrorNumber(), $region->GetErrorMessage()); } return $this->Respond($this->ReturnId('success', true)); }
/** * Adds the media into the region provided * @return */ function AddFromLibrary() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $layoutId = Kit::GetParam('layoutid', _GET, _INT); $regionId = Kit::GetParam('regionid', _REQUEST, _STRING); $mediaList = Kit::GetParam('MediaID', _POST, _ARRAY, array()); // Make sure we have permission to edit this region 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); } if (!$region->AddFromLibrary($user, $layoutId, $regionId, $mediaList)) { trigger_error($region->GetErrorMessage(), E_USER_ERROR); } // We want to load a new form $response->SetFormSubmitResponse(sprintf(__('%d Media Items Assigned'), count($mediaList))); $response->loadForm = true; $response->loadFormUri = "index.php?p=timeline&layoutid={$layoutId}®ionid={$regionId}&q=Timeline"; $response->Respond(); }