Beispiel #1
0
 protected function EditLibraryMedia()
 {
     $this->response = new ResponseManager();
     $db =& $this->db;
     $user =& $this->user;
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     $mediaid = $this->mediaid;
     $userid = $this->user->userid;
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this media.');
         $this->response->keepOpen = false;
         return $this->response;
     }
     // Hand off to the media module
     $mediaObject = new Media($db);
     // Stored As from the XML
     $storedAs = $this->GetOption('uri');
     // File data
     $tmpName = Kit::GetParam('hidFileID', _POST, _STRING);
     $name = Kit::GetParam('name', _POST, _STRING);
     $tags = Kit::GetParam('tags', _POST, _STRING);
     if ($this->auth->modifyPermissions) {
         $this->duration = Kit::GetParam('duration', _POST, _INT, 0, false);
     }
     // Revise this file?
     if ($tmpName != '') {
         Debug::LogEntry('audit', 'Uploading a new revision', 'module', 'EditLibraryMedia');
         // File name and extension (orignial name)
         $fileName = Kit::GetParam('txtFileName', _POST, _STRING);
         if ($name == '') {
             $name = $fileName;
         }
         if (!($new_mediaid = $mediaObject->FileRevise($mediaid, $tmpName, $fileName, $userid))) {
             $this->response->SetError($mediaObject->GetErrorMessage());
             $this->response->keepOpen = true;
             return $this->response;
         }
         // Are we on a region
         if ($regionid != '') {
             $security = new LayoutMediaGroupSecurity($db);
             $security->Copy($layoutid, $regionid, $mediaid, $new_mediaid);
         }
         // Required Attributes
         $this->mediaid = $new_mediaid;
         // Find out what we stored this item as
         try {
             $dbh = PDOConnect::init();
             $sth = $dbh->prepare('SELECT StoredAs FROM `media` WHERE mediaid = :mediaId');
             $sth->execute(array('mediaId' => $new_mediaid));
             $storedAs = Kit::ValidateParam($sth->fetchColumn(0), _FILENAME);
             $this->SetOption('uri', $storedAs);
         } catch (Exception $e) {
             Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__);
             trigger_error(__('Unable to find uploaded file.'), E_USER_ERROR);
         }
         Debug::LogEntry('audit', 'New revision uploaded: ' . $storedAs, 'module', 'EditLibraryMedia');
     }
     // Edit the media record
     if (!$mediaObject->Edit($this->mediaid, $name, $this->duration, $userid, $tags)) {
         $this->response->SetError($mediaObject->GetErrorMessage());
         $this->response->keepOpen = true;
         return $this->response;
     }
     // Should have built the media object entirely by this time
     if ($regionid != '' && $this->showRegionOptions) {
         // This saves the Media Object to the Region
         $this->UpdateRegion();
         $this->response->loadForm = true;
         $this->response->loadFormUri = "index.php?p=timeline&layoutid={$layoutid}&regionid={$regionid}&q=RegionOptions";
     } elseif ($regionid != '' && !$this->showRegionOptions) {
         $this->UpdateRegion();
         $this->response->loadForm = false;
     } else {
         $this->response->message = 'Edited the ' . $this->displayType;
     }
     // Edit from the library - check to see if we are replacing this media in *all* layouts.
     $replaceInLayouts = Kit::GetParam('replaceInLayouts', _POST, _CHECKBOX) == 1;
     $replaceBackgroundImages = Kit::GetParam('replaceBackgroundImages', _POST, _CHECKBOX) == 1;
     if ($mediaid != $this->mediaid && ($replaceInLayouts || $replaceBackgroundImages)) {
         $this->ReplaceMediaInAllLayouts($replaceInLayouts, $replaceBackgroundImages, $mediaid, $this->mediaid, $this->duration);
     }
     // Do we need to delete the old media item?
     if ($tmpName != '' && Kit::GetParam('deleteOldVersion', _POST, _CHECKBOX) == 1) {
         // We pass in the newMediaId as the second parameter so that we can correctly link a prior revision if one exists.
         if (!$mediaObject->Delete($mediaid, $this->mediaid)) {
             $this->response->message .= ' ' . __('Failed to remove old media');
         }
     }
     return $this->response;
 }
Beispiel #2
0
 protected function EditLibraryMedia()
 {
     $db =& $this->db;
     $user =& $this->user;
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     $mediaid = $this->mediaid;
     $userid = $this->user->userid;
     if (!$this->auth->edit) {
         $this->response->SetError('You do not have permission to edit this media.');
         $this->response->keepOpen = false;
         return $this->response;
     }
     // Hand off to the media module
     Kit::ClassLoader('media');
     $mediaObject = new Media($db);
     // Stored As from the XML
     $storedAs = $this->GetOption('uri');
     // File data
     $tmpName = Kit::GetParam('hidFileID', _POST, _STRING);
     $name = Kit::GetParam('name', _POST, _STRING);
     if ($this->auth->modifyPermissions) {
         $this->duration = Kit::GetParam('duration', _POST, _INT, 0);
     }
     // Revise this file?
     if ($tmpName != '') {
         Debug::LogEntry('audit', 'Uploading a new revision', 'module', 'EditLibraryMedia');
         // File name and extension (orignial name)
         $fileName = Kit::GetParam('txtFileName', _POST, _STRING);
         if ($name == '') {
             $name = $fileName;
         }
         if (!($new_mediaid = $mediaObject->FileRevise($mediaid, $tmpName, $fileName))) {
             $this->response->SetError($mediaObject->GetErrorMessage());
             $this->response->keepOpen = true;
             return $this->response;
         }
         // Are we on a region
         if ($regionid != '') {
             Kit::ClassLoader('layoutmediagroupsecurity');
             $security = new LayoutMediaGroupSecurity($db);
             $security->Copy($layoutid, $regionid, $mediaid, $new_mediaid);
         }
         // Required Attributes
         $this->mediaid = $new_mediaid;
         // Find out what we stored this item as
         $storedAs = $db->GetSingleValue(sprintf("SELECT StoredAs FROM `media` WHERE mediaid = %d", $new_mediaid), 'StoredAs', _STRING);
         $this->SetOption('uri', $storedAs);
         Debug::LogEntry('audit', 'New revision uploaded: ' . $storedAs, 'module', 'EditLibraryMedia');
     }
     // Edit the media record
     if (!$mediaObject->Edit($this->mediaid, $name, $this->duration, $userid)) {
         $this->response->SetError($mediaObject->GetErrorMessage());
         $this->response->keepOpen = true;
         return $this->response;
     }
     // Should have built the media object entirely by this time
     if ($regionid != '' && $this->showRegionOptions) {
         // This saves the Media Object to the Region
         $this->UpdateRegion();
         $this->response->loadForm = true;
         $this->response->loadFormUri = "index.php?p=timeline&layoutid={$layoutid}&regionid={$regionid}&q=RegionOptions";
     } elseif ($regionid != '' && !$this->showRegionOptions) {
         $this->UpdateRegion();
         $this->response->loadForm = false;
     } else {
         $this->response->message = 'Edited the ' . $this->displayType;
     }
     // Edit from the library - check to see if we are replacing this media in *all* layouts.
     if (Kit::GetParam('replaceInLayouts', _POST, _CHECKBOX) == 1) {
         $this->ReplaceMediaInAllLayouts($mediaid, $this->mediaid, $this->duration);
     }
     return $this->response;
 }