Esempio n. 1
0
 /**
  * Get the item type
  *
  * @param   string  $as  Return type as?
  * @return  string
  */
 public function type($as = null)
 {
     if ($as == 'title') {
         return Lang::txt('Forum thread');
     }
     return parent::type($as);
 }
Esempio n. 2
0
 /**
  * Get the item type
  *
  * @param   string  $as  Return type as?
  * @return  string
  */
 public function type($as = null)
 {
     if ($as == 'title') {
         return Lang::txt('Wiki page');
     }
     return parent::type($as);
 }
Esempio n. 3
0
 /**
  * Get the item type
  *
  * @param   string  $as  Return type as?
  * @return  string
  */
 public function type($as = null)
 {
     if ($as == 'title') {
         return Lang::txt('Knowledge base article');
     }
     return parent::type($as);
 }
Esempio n. 4
0
 /**
  * Get the item type
  *
  * @param   string  $as  Return type as?
  * @return  string
  */
 public function type($as = null)
 {
     if ($as == 'title') {
         return Lang::txt('Blog post');
     }
     return parent::type($as);
 }
Esempio n. 5
0
 /**
  * Display a list of files
  *
  * @return  void
  */
 public function listTask()
 {
     // Incoming
     $listdir = Request::getInt('dir', 0, 'get');
     if (!$listdir) {
         $this->setError(Lang::txt('COM_COLLECTIONS_NO_ID'));
     }
     $this->view->item = Item::getInstance($listdir);
     if (!$this->view->item->exists()) {
         $this->setError(Lang::txt('COM_COLLECTIONS_NO_ID'));
     }
     $this->view->config = $this->config;
     $this->view->listdir = $listdir;
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->display();
 }
Esempio n. 6
0
 /**
  * Create a post
  *
  * @apiMethod POST
  * @apiUri    /collections/{id}/posts
  * @apiParameter {
  * 		"name":        "collection_id",
  * 		"description": "Collection identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "title",
  * 		"description": "Entry title",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "description",
  * 		"description": "Entry description",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "url",
  * 		"description": "Entry URL; Requires 'type'='link'",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "created",
  * 		"description": "Created timestamp (YYYY-MM-DD HH:mm:ss)",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     "now"
  * }
  * @apiParameter {
  * 		"name":        "created_by",
  * 		"description": "User ID of entry creator",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "state",
  * 		"description": "Published state (0 = unpublished, 1 = published)",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "access",
  * 		"description": "Access level (0 = public, 1 = registered users, 4 = private)",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "type",
  * 		"description": "Item type",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     "file"
  * }
  * @apiParameter {
  * 		"name":        "object_id",
  * 		"description": "Object ID",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @return    void
  */
 public function createTask()
 {
     $this->requiresAuthentication();
     $fields = array('title' => Request::getVar('title', null, 'post', 'none', 2), 'description' => Request::getVar('description', null, 'post', 'none', 2), 'url' => Request::getVar('url', null, 'post'), 'created' => Request::getVar('created', new Date('now'), 'post'), 'created_by' => Request::getInt('created_by', 0, 'post'), 'state' => Request::getInt('state', 1, 'post'), 'access' => Request::getInt('access', 0, 'post'), 'type' => Request::getVar('type', 'file', 'post'), 'object_id' => Request::getInt('object_id', 0, 'post'), 'collection_id' => Request::getInt('collection_id', 0, 'post'));
     if (!$fields['collection_id']) {
         throw new Exception(Lang::txt('COM_COLLECTIONS_ERROR_MISSING_COLLECTION'), 422);
     }
     $row = new Item();
     if (!$row->bind($fields)) {
         throw new Exception(Lang::txt('COM_COLLECTIONS_ERROR_BINDING_DATA'), 500);
     }
     if (!$row->store(true)) {
         throw new Exception(Lang::txt('COM_COLLECTIONS_ERROR_SAVING_DATA'), 500);
     }
     $post = new Post();
     $post->set('item_id', $row->get('id'));
     $post->set('original', 1);
     $post->set('collection_id', $fields['collection_id']);
     if (!$post->store(true)) {
         throw new Exception(Lang::txt('COM_COLLECTIONS_ERROR_SAVING_DATA'), 500);
     }
     $this->send($row);
 }
Esempio n. 7
0
 /**
  * Save an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Login is required
     if (User::isGuest()) {
         return $this->loginTask();
     }
     // Incoming
     $fields = Request::getVar('fields', array(), 'post', 'none', 2);
     // Get model
     $row = new Item();
     // Bind content
     if (!$row->bind($fields)) {
         $this->setError($row->getError());
         return $this->editTask($row);
     }
     // Add some data
     //$row->set('_files', $files);
     $row->set('_assets', Request::getVar('assets', array(), 'post'));
     $row->set('_tags', trim(Request::getVar('tags', '')));
     $row->set('state', 1);
     // Store new content
     if (!$row->store()) {
         $this->setError($row->getError());
         return $this->editTask($row);
     }
     // Create a post entry linking the item to the board
     $p = Request::getVar('post', array(), 'post');
     // Load a post entry
     $post = new Post($p['id']);
     if (!$post->exists()) {
         // No post existed so set some values
         $post->set('item_id', $row->get('id'));
         $post->set('original', 1);
     }
     // Are we creating a new collection for it?
     $coltitle = Request::getVar('collection_title', '', 'post');
     if (!$p['collection_id'] && $coltitle) {
         $collection = new Collection();
         $collection->set('title', $coltitle);
         $collection->set('object_id', User::get('id'));
         $collection->set('object_type', 'member');
         $collection->store();
         $p['collection_id'] = $collection->get('id');
     }
     $post->set('collection_id', $p['collection_id']);
     // Set the description
     if (isset($p['description'])) {
         $post->set('description', $p['description']);
     }
     // Store record
     if (!$post->store()) {
         $this->setError($post->getError());
     }
     // Check for any errors
     if ($this->getError()) {
         return $this->editTask($row);
     }
     // Redirect to main listing
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=collections'));
 }
Esempio n. 8
0
 /**
  * Delete one or more 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;
     if (count($ids) > 0) {
         // Loop through all the IDs
         foreach ($ids as $id) {
             $entry = new Item(intval($id));
             // Delete the entry
             if (!$entry->delete()) {
                 \Notify::error($entry->getError());
             }
         }
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_COLLECTIONS_ITEMS_DELETED'));
 }