示例#1
0
 /**
  * Add Media to the Database
  * @return
  */
 public function AddMedia()
 {
     $this->response = new ResponseManager();
     $layoutid = $this->layoutid;
     $regionid = $this->regionid;
     //Other properties
     $dataSetId = Kit::GetParam('datasetid', _POST, _INT, 0);
     $duration = Kit::GetParam('duration', _POST, _INT, 0, false);
     // validation
     if ($dataSetId == 0) {
         $this->response->SetError(__('Please select a DataSet'));
         $this->response->keepOpen = true;
         return $this->response;
     }
     // Check we have permission to use this DataSetId
     if (!$this->user->DataSetAuth($dataSetId)) {
         $this->response->keepOpen = true;
         return $this->response->SetError(__('You do not have permission to use that dataset'));
     }
     if ($duration == 0) {
         $this->response->SetError(__('You must enter a duration.'));
         $this->response->keepOpen = true;
         return $this->response;
     }
     // Required Attributes
     $this->mediaid = md5(uniqid());
     $this->duration = $duration;
     // Any Options
     $this->SetOption('datasetid', $dataSetId);
     // Should have built the media object entirely by this time
     // This saves the Media Object to the Region
     $this->UpdateRegion();
     // Link
     Kit::ClassLoader('dataset');
     $dataSet = new DataSet($this->db);
     $dataSet->LinkLayout($dataSetId, $this->layoutid, $this->regionid, $this->mediaid);
     //Set this as the session information
     setSession('content', 'type', 'datasetview');
     if ($this->showRegionOptions) {
         // We want to load a new form
         $this->response->loadForm = true;
         $this->response->loadFormUri = "index.php?p=module&mod=datasetview&q=Exec&method=EditForm&layoutid={$this->layoutid}&regionid={$regionid}&mediaid={$this->mediaid}";
     }
     return $this->response;
 }