Ejemplo n.º 1
0
 /**
  * Display module contents
  * 
  * @return  void
  */
 public function run()
 {
     Lang::load('com_blog', Component::path('com_blog') . '/site');
     include_once \Component::path('com_blog') . DS . 'models' . DS . 'archive.php';
     $this->pullout = $this->params->get('pullout', 'yes');
     $this->feedlink = $this->params->get('feedlink', 'yes');
     $this->limit = $this->params->get('limit', 5);
     $filters = array('limit' => $this->params->get('limit', 5), 'start' => 0, 'scope' => $this->params->get('blog', 'site'), 'scope_id' => 0, 'state' => 1, 'access' => User::getAuthorisedViewLevels());
     if ($filters['scope'] == 'both' || $filters['scope'] == 'group') {
         $filters['limit'] = $filters['limit'] * 5;
         // Since some groups May have private entries, we need to up the limit to try and catch more
     }
     if ($filters['scope'] == 'both') {
         $filters['scope'] = '';
     }
     $archive = new Archive('site', 0);
     $rows = $archive->entries($filters)->ordered()->rows();
     $posts = array();
     foreach ($rows as $k => $gf) {
         if ($this->params->get('blog', 'site') == 'group' || $this->params->get('blog', 'site') == 'both') {
             //make sure that the group for each blog post has the right privacy setting
             if (!$gf->get('scope_id')) {
                 continue;
             }
             $group = $gf->item();
             if (is_object($group)) {
                 $blog_access = GroupHelper::getPluginAccess($group, 'blog');
                 if ($blog_access == 'nobody' || $blog_access == 'registered' && User::isGuest() || $blog_access == 'members' && !in_array(User::get('id'), $group->get('members'))) {
                     continue;
                 }
             } else {
                 continue;
             }
         }
         $posts[] = $gf;
     }
     $this->posts = $posts;
     require $this->getLayoutPath();
 }
Ejemplo n.º 2
0
 /**
  * Deletes a file
  *
  * @return  void
  */
 public function deletefileTask()
 {
     // Check for request forgeries
     Request::checkToken('get');
     // Check if they're logged in
     if (User::isGuest()) {
         $this->displayTask();
         return;
     }
     // Incoming file
     $file = trim(Request::getVar('file', '', 'get'));
     if (!$file) {
         $this->setError(Lang::txt('COM_BLOG_NO_FILE'));
         $this->displayTask();
         return;
     }
     // Incoming
     $archive = new Archive(Request::getWord('scope', 'site'), Request::getInt('id', 0));
     // Build the file path
     $path = $archive->filespace();
     if (!file_exists($path . DS . $file) or !$file) {
         $this->setError(Lang::txt('COM_BLOG_FILE_NOT_FOUND'));
         $this->displayTask();
         return;
     }
     // Attempt to delete the file
     if (!Filesystem::delete($path . DS . $file)) {
         $this->setError(Lang::txt('COM_BLOG_UNABLE_TO_DELETE_FILE'));
     }
     // Push through to the media view
     $this->displayTask();
 }
Ejemplo n.º 3
0
 /**
  * Display a list of entries
  *
  * @apiMethod GET
  * @apiUri    /blog/list
  * @apiParameter {
  * 		"name":          "scope",
  * 		"description":   "Scope type (group, member, etc.)",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "site"
  * }
  * @apiParameter {
  * 		"name":          "scope_id",
  * 		"description":   "Scope object ID",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "start",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "sort",
  * 		"description":   "Field to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "created",
  * 		"allowedValues": "created, title, alias, id, publish_up, publish_down, state"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "desc",
  * 		"allowedValues": "asc, desc"
  * }
  * @return  void
  */
 public function listTask()
 {
     $model = new Archive('site');
     $filters = array('scope' => Request::getVar('scope', 'site'), 'scope_id' => Request::getInt('scope_id', 0), 'search' => Request::getVar('search', ''), 'authorized' => false, 'state' => 1, 'access' => User::getAuthorisedViewLevels());
     $response = new stdClass();
     $response->posts = array();
     $response->total = $model->entries($filters)->count();
     if ($response->total) {
         $base = rtrim(Request::base(), '/');
         $rows = $model->entries($filters)->ordered('sort', 'sort_order')->paginated()->rows();
         foreach ($rows as $i => $entry) {
             $obj = new stdClass();
             $obj->id = $entry->get('id');
             $obj->title = $entry->get('title');
             $obj->alias = $entry->get('alias');
             $obj->state = $entry->get('state');
             $obj->published = $entry->get('publish_up');
             $obj->scope = $entry->get('scope');
             $obj->author = $entry->creator()->get('name');
             $obj->url = str_replace('/api', '', $base . '/' . ltrim(Route::url($entry->link()), DS));
             $obj->comments = $entry->comments()->whereIn('state', array(1, 3))->count();
             $response->posts[] = $obj;
         }
     }
     $response->success = true;
     $this->send($response);
 }