/** * 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)); }