/** * Associate the list of provided media with this display group * @param user $user The logged in user * @param int $displayGroupId The Display Group to Assign to * @param array $mediaList The Media to Assign */ public function AssociateFiles($user, $displayGroupId, $mediaList) { Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); Kit::ClassLoader('lkmediadisplaygroup'); $link = new LkMediaDisplayGroup($this->db); try { $dbh = PDOConnect::init(); // Check that some media assignments have been made if (count($mediaList) == 0) { $this->ThrowError(25006, __('No media to assign')); } // Drop all current assignments if (!$link->UnlinkAllFromDisplayGroup($displayGroupId)) { $this->ThrowError(__('Unable to make this assignment during preparation.')); } // Loop through all the media foreach ($mediaList as $mediaId) { $mediaId = Kit::ValidateParam($mediaId, _INT); // Check we have permissions to use this media (we will use this to copy the media later) $mediaAuth = $user->MediaAuth($mediaId, true); if (!$mediaAuth->view) { $this->ThrowError(__('You have selected media that you no longer have permission to use. Please reload the form.')); } // Create the link if (!$link->Link($displayGroupId, $mediaId)) { $this->ThrowError(__('Unable to make this assignment')); } } // Flag this display group as incomplete $this->FlagIncomplete($displayGroupId); return true; } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); if (!$this->IsError()) { $this->SetError(1, __('Unknown Error')); } return false; } }
public function VersionInstructions() { $response = new ResponseManager(); Kit::ClassLoader('media'); Kit::ClassLoader('display'); Kit::ClassLoader('lkmediadisplaygroup'); $displayGroupId = Kit::GetParam('displaygroupid', _POST, _INT); $mediaId = Kit::GetParam('mediaid', _POST, _INT); // Make sure we have permission to do this to this display $auth = $this->user->DisplayGroupAuth($displayGroupId, true); if (!$auth->edit) { trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); } // Make sure we have permission to use this file $mediaAuth = $this->user->MediaAuth($mediaId, true); if (!$mediaAuth->view) { trigger_error(__('You have selected media that you no longer have permission to use. Please reload the form.'), E_USER_ERROR); } // Make sure this file is assigned to this display group $link = new LkMediaDisplayGroup($this->db); if (!$link->Link($displayGroupId, $mediaId)) { trigger_error($display->GetErrorMessage(), E_USER_ERROR); } // Get the "StoredAs" for this media item $media = new Media($this->db); $storedAs = $media->GetStoredAs($mediaId); // Get a list of displays for this group $displays = $this->user->DisplayList(array('displayid'), array('displaygroupid' => $displayGroupId)); foreach ($displays as $display) { // Update the Display with the new instructions $displayObject = new Display($this->db); if (!$displayObject->SetVersionInstructions($display['displayid'], $mediaId, $storedAs)) { trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR); } } $response->SetFormSubmitResponse(__('Version Instructions Set')); $response->Respond(); }