Пример #1
0
 /**
  * Display a list of authors
  *
  * @param   integer  $id  Resource ID
  * @return  void
  */
 public function displayTask($id = null)
 {
     // Incoming
     if (!$id) {
         $id = Request::getInt('id', 0);
     }
     // Ensure we have an ID to work with
     if (!$id) {
         App::abort(404, Lang::txt('CONTRIBUTE_NO_ID'));
     }
     // Get all contributors of this resource
     $resource = Resource::oneOrFail($id);
     $authors = $resource->authors()->ordered()->rows();
     // Get all roles for this resoruce type
     $roles = $resource->type()->roles()->rows();
     // Output view
     $this->view->set('config', $this->config)->set('id', $id)->set('contributors', $authors)->set('roles', $roles)->setErrors($this->getErrors())->setLayout('display')->display();
 }
Пример #2
0
 /**
  * Remove entries
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Do we have any IDs?
     if (!empty($ids)) {
         $i = 0;
         // Loop through each ID and delete the necessary items
         foreach ($ids as $id) {
             $row = Resource::oneOrFail($id);
             if (!$row->destroy()) {
                 Notify::error($row->getError());
                 continue;
             }
             // Remove
             $i++;
         }
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $i ? Lang::txt('COM_TOOLS_DELETE_SUCCESSFUL') : null);
 }
Пример #3
0
 /**
  * Display an upload form and file listing
  *
  * @return  void
  */
 public function displayTask()
 {
     // Incoming directory (this should be a path built from a resource ID and its creation year/month)
     $resource = Request::getInt('resource', 0);
     if (!$resource) {
         echo '<p class="error">' . Lang::txt('No resource ID provided.') . '</p>';
         return;
     }
     if ($resource < 1 || substr($resource, 0, 4) == '9999') {
         $row = Resource::blank();
     } else {
         $row = Resource::oneOrFail($resource);
     }
     $row->set('id', $resource);
     // Incoming sub-directory
     $subdir = Request::getVar('subdir', '');
     // Allow for temp resource uploads
     if (!$row->get('created') || $row->get('created') == '0000-00-00 00:00:00') {
         $row->set('created', Date::format('Y-m-d 00:00:00'));
     }
     $path = $row->filespace() . DS . 'media';
     $folders = array();
     $docs = array();
     if (is_dir($path)) {
         // Loop through all files and separate them into arrays of images, folders, and other
         $dirIterator = new \DirectoryIterator($path);
         foreach ($dirIterator as $file) {
             if ($file->isDot()) {
                 continue;
             }
             $name = $file->getFilename();
             if ($file->isDir()) {
                 $folders[$path . DS . $name] = $name;
                 continue;
             }
             if ($file->isFile()) {
                 if ('cvs' == strtolower($name) || '.svn' == strtolower($name)) {
                     continue;
                 }
                 $docs[$path . DS . $name] = $name;
             }
         }
         ksort($folders);
         ksort($docs);
     }
     // Output the HTML
     $this->view->set('resource', $resource)->set('row', $row)->set('subdir', $subdir)->set('path', $path)->set('docs', $docs)->set('folders', $folders)->setErrors($this->getErrors())->setLayout('display')->display();
 }
Пример #4
0
 /**
  * Retract a submission
  *
  * @return  void
  */
 public function retractTask()
 {
     // Incoming
     $id = Request::getInt('id', 0);
     // Ensure we have an ID to work with
     if ($id) {
         // Load the resource
         $resource = Resource::oneOrFail($id);
         // Check if it's in pending status
         if ($resource->get('published') == 3) {
             // Set it back to "draft" status
             $resource->set('published', 2);
             // Save changes
             $resource->save();
         }
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&task=new'));
 }
Пример #5
0
 /**
  * Display a list of attachments
  *
  * @param   integer  $id  Resource ID
  * @return  void
  */
 public function displayTask($id = null)
 {
     // Incoming
     if (!$id) {
         $id = Request::getInt('id', 0);
     }
     // Ensure we have an ID to work with
     if (!$id) {
         App::abort(404, Lang::txt('CONTRIBUTE_NO_ID'));
     }
     // Initiate a resource
     $resource = Resource::oneOrFail($id);
     $children = $resource->children()->order('ordering', 'ASC')->rows();
     // Output HTML
     $this->view->set('config', $this->config)->set('children', $children)->set('path', '')->set('id', $id)->setErrors($this->getErrors())->setLayout('display')->display();
 }