コード例 #1
0
ファイル: comments.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Display a list of blog entries
  *
  * @return  void
  */
 public function displayTask()
 {
     $filters = array('entry_id' => Request::getState($this->_option . '.' . $this->_controller . '.entry_id', 'entry_id', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'created'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'));
     $entry = Entry::oneOrNew($filters['entry_id']);
     $comments = Comment::all();
     if ($filters['search']) {
         $comments->whereLike('title', strtolower((string) $filters['search']));
     }
     if ($filters['entry_id']) {
         $comments->whereEquals('entry_id', $filters['entry_id']);
     }
     $rows = $comments->ordered('filter_order', 'filter_order_Dir')->rows();
     $levellimit = $filters['limit'] == 0 ? 500 : $filters['limit'];
     $list = array();
     $children = array();
     if ($rows) {
         // First pass - collect children
         foreach ($rows as $k) {
             $pt = $k->get('parent');
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $k);
             $children[$pt] = $list;
         }
         // Second pass - get an indent list of the items
         $list = $this->treeRecurse(0, '', array(), $children, max(0, $levellimit - 1));
     }
     // Output the HTML
     $this->view->set('filters', $filters)->set('entry', $entry)->set('total', count($list))->set('rows', array_slice($list, $filters['start'], $filters['limit']))->display();
 }
コード例 #2
0
ファイル: entries.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Save entry
  *
  * @return  void
  */
 public function saveTask()
 {
     if (User::isGuest()) {
         $rtrn = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option . '&task=' . $this->_task), 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn)), Lang::txt('COM_BLOG_LOGIN_NOTICE'), 'warning');
         return;
     }
     if (!$this->config->get('access-create-entry') && !$this->config->get('access-edit-entry') && !$this->config->get('access-manage-entry')) {
         App::abort(403, Lang::txt('COM_BLOG_NOT_AUTH'));
     }
     // Check for request forgeries
     Request::checkToken();
     $fields = Request::getVar('entry', array(), 'post', 'none', 2);
     // Make sure we don't want to turn off comments
     //$fields['allow_comments'] = (isset($fields['allow_comments'])) ? 1 : 0;
     if (isset($fields['publish_up']) && $fields['publish_up'] != '') {
         $fields['publish_up'] = Date::of($fields['publish_up'], Config::get('offset'))->toSql();
     }
     if (isset($fields['publish_down']) && $fields['publish_down'] != '') {
         $fields['publish_down'] = Date::of($fields['publish_down'], Config::get('offset'))->toSql();
     }
     $fields['scope'] = 'site';
     $fields['scope_id'] = 0;
     $row = Entry::oneOrNew($fields['id'])->set($fields);
     // Store new content
     if (!$row->save()) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     // Process tags
     if (!$row->tag(Request::getVar('tags', ''))) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     // Log activity
     Event::trigger('system.logActivity', ['activity' => ['action' => $fields['id'] ? 'updated' : 'created', 'scope' => 'blog.entry', 'scope_id' => $row->get('id'), 'description' => Lang::txt('COM_BLOG_ACTIVITY_ENTRY_' . ($fields['id'] ? 'UPDATED' : 'CREATED'), '<a href="' . Route::url($row->link()) . '">' . $row->get('title') . '</a>'), 'details' => array('title' => $row->get('title'), 'url' => Route::url($row->link()))], 'recipients' => [$row->get('created_by')]]);
     // Redirect to the entry
     App::redirect(Route::url($row->link()));
 }
コード例 #3
0
ファイル: blog.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Save an entry
  *
  * @return  void
  */
 private function _save()
 {
     if (User::isGuest()) {
         $blog = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name, false, true);
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($blog)), Lang::txt('GROUPS_LOGIN_NOTICE'), 'warning');
         return;
     }
     if (!$this->authorized) {
         $this->setError(Lang::txt('PLG_GROUPS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     if (!$this->_getPostingPermissions()) {
         $this->setError(Lang::txt('PLG_GROUPS_BLOG_ERROR_PERMISSION_DENIED'));
         return $this->_browse();
     }
     // Check for request forgeries
     Request::checkToken();
     $entry = Request::getVar('entry', array(), 'post', 'none', 2);
     if (isset($entry['publish_up']) && $entry['publish_up'] != '') {
         $entry['publish_up'] = Date::of($entry['publish_up'], Config::get('offset'))->toSql();
     }
     if (isset($entry['publish_down']) && $entry['publish_down'] != '') {
         $entry['publish_down'] = Date::of($entry['publish_down'], Config::get('offset'))->toSql();
     }
     // make sure we dont want to turn off comments
     $entry['allow_comments'] = isset($entry['allow_comments']) ?: 0;
     // Instantiate model
     $row = \Components\Blog\Models\Entry::oneOrNew($entry['id'])->set($entry);
     if ($row->get('alias') == '') {
         $alias = $row->automaticAlias($row);
     }
     if ($row->isNew()) {
         $item = \Components\Blog\Models\Entry::oneByScope($alias, $this->model->get('scope'), $this->model->get('scope_id'));
         if ($item->get('id')) {
             $this->setError(Lang::txt('PLG_GROUPS_BLOG_ERROR_ALIAS_EXISTS'));
             return $this->_edit($row);
         }
     }
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     // Process tags
     if (!$row->tag(Request::getVar('tags', ''))) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     // Record the activity
     $recipients = array(['group', $this->group->get('gidNumber')]);
     if (!in_array($row->get('created_by'), $this->group->get('managers'))) {
         $recipients[] = ['user', $row->get('created_by')];
     }
     foreach ($this->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => $entry['id'] ? 'updated' : 'created', 'scope' => 'blog.entry', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_GROUPS_BLOG_ACTIVITY_ENTRY_' . ($entry['id'] ? 'UPDATED' : 'CREATED'), '<a href="' . Route::url($row->link()) . '">' . $row->get('title') . '</a>'), 'details' => array('title' => $row->get('title'), 'url' => Route::url($row->link()))], 'recipients' => $recipients]);
     App::redirect(Route::url($row->link()));
 }
コード例 #4
0
ファイル: entries.php プロジェクト: zooley/hubzero-cms
 /**
  * Save entry
  *
  * @return  void
  */
 public function saveTask()
 {
     if (User::isGuest()) {
         $rtrn = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option . '&task=' . $this->_task), 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn)), Lang::txt('COM_BLOG_LOGIN_NOTICE'), 'warning');
         return;
     }
     // Check for request forgeries
     Request::checkToken();
     $fields = Request::getVar('entry', array(), 'post', 'none', 2);
     // Make sure we don't want to turn off comments
     //$fields['allow_comments'] = (isset($fields['allow_comments'])) ? : 0;
     if (isset($fields['publish_up']) && $fields['publish_up'] != '') {
         $fields['publish_up'] = Date::of($fields['publish_up'], Config::get('offset'))->toSql();
     }
     if (isset($fields['publish_down']) && $fields['publish_down'] != '') {
         $fields['publish_down'] = Date::of($fields['publish_down'], Config::get('offset'))->toSql();
     }
     $row = Entry::oneOrNew($fields['id'])->set($fields);
     // Store new content
     if (!$row->save()) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     // Process tags
     if (!$row->tag(Request::getVar('tags', ''))) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     App::redirect(Route::url($row->link()));
 }
コード例 #5
0
 /**
  * Delete an entry
  *
  * @apiMethod DELETE
  * @apiUri    /blog/{id}
  * @apiParameter {
  * 		"name":        "id",
  * 		"description": "Blog entry identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @return    void
  */
 public function deleteTask()
 {
     $this->requiresAuthentication();
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     if (count($ids) <= 0) {
         throw new Exception(Lang::txt('COM_BLOG_ERROR_MISSING_ID'), 500);
     }
     foreach ($ids as $id) {
         $row = Entry::oneOrNew(intval($id));
         if (!$row->get('id')) {
             throw new Exception(Lang::txt('COM_BLOG_ERROR_MISSING_RECORD'), 404);
         }
         if (!$row->destroy()) {
             throw new Exception($row->getError(), 500);
         }
     }
     $this->send(null, 204);
 }
コード例 #6
0
ファイル: entries.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Sets the state of one or more entries
  *
  * @return  void
  */
 public function stateTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     if (!User::authorise('core.edit.state', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     $state = $this->_task == 'publish' ? 1 : 0;
     // Incoming
     $ids = Request::getVar('id', array(0));
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Check for a resource
     if (count($ids) < 1) {
         Notify::warning(Lang::txt('COM_BLOG_SELECT_ENTRY_TO', $this->_task));
         return $this->cancelTask();
     }
     // Loop through all the IDs
     $success = 0;
     foreach ($ids as $id) {
         // Load the article
         $row = Entry::oneOrNew(intval($id));
         $row->set('state', $state);
         // Store new content
         if (!$row->save()) {
             Notify::error($row->getError());
             continue;
         }
         $success++;
     }
     if ($success) {
         switch ($this->_task) {
             case 'publish':
                 $message = Lang::txt('COM_BLOG_ITEMS_PUBLISHED', $success);
                 break;
             case 'unpublish':
                 $message = Lang::txt('COM_BLOG_ITEMS_UNPUBLISHED', $success);
                 break;
             case 'archive':
                 $message = Lang::txt('COM_BLOG_ITEMS_ARCHIVED', $success);
                 break;
         }
         Notify::success($message);
     }
     // Set the redirect
     $this->cancelTask();
 }
コード例 #7
0
ファイル: entriesv1_0.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Delete an entry
  *
  * @apiMethod DELETE
  * @apiUri    /blog/{id}
  * @apiParameter {
  * 		"name":        "id",
  * 		"description": "Blog entry identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @return    void
  */
 public function deleteTask()
 {
     $this->requiresAuthentication();
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     if (count($ids) <= 0) {
         throw new Exception(Lang::txt('COM_BLOG_ERROR_MISSING_ID'), 500);
     }
     foreach ($ids as $id) {
         $row = Entry::oneOrNew(intval($id));
         if (!$row->get('id')) {
             throw new Exception(Lang::txt('COM_BLOG_ERROR_MISSING_RECORD'), 404);
         }
         if (!$row->destroy()) {
             throw new Exception($row->getError(), 500);
         }
         // Log activity
         $base = rtrim(Request::base(), '/');
         $url = str_replace('/api', '', $base . '/' . ltrim(Route::url($row->link()), '/'));
         Event::trigger('system.logActivity', ['activity' => ['action' => 'deleted', 'scope' => 'blog.entry', 'scope_id' => $id, 'description' => Lang::txt('COM_BLOG_ACTIVITY_ENTRY_DELETED', '<a href="' . $url . '">' . $row->get('title') . '</a>'), 'details' => array('title' => $row->get('title'), 'url' => $url)], 'recipients' => [$entry->get('created_by')]]);
     }
     $this->send(null, 204);
 }
コード例 #8
0
ファイル: blog.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Save an entry
  *
  * @return  void
  */
 private function _save()
 {
     if (User::isGuest()) {
         $blog = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name, false, true);
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($blog)), Lang::txt('GROUPS_LOGIN_NOTICE'), 'warning');
         return;
     }
     if (!$this->authorized) {
         $this->setError(Lang::txt('PLG_GROUPS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     if (!$this->_getPostingPermissions()) {
         $this->setError(Lang::txt('PLG_GROUPS_BLOG_ERROR_PERMISSION_DENIED'));
         return $this->_browse();
     }
     $entry = Request::getVar('entry', array(), 'post', 'none', 2);
     if (isset($entry['publish_up']) && $entry['publish_up'] != '') {
         $entry['publish_up'] = Date::of($entry['publish_up'], Config::get('offset'))->toSql();
     }
     if (isset($entry['publish_down']) && $entry['publish_down'] != '') {
         $entry['publish_down'] = Date::of($entry['publish_down'], Config::get('offset'))->toSql();
     }
     // make sure we dont want to turn off comments
     $entry['allow_comments'] = isset($entry['allow_comments']) ?: 0;
     // Instantiate model
     $row = \Components\Blog\Models\Entry::oneOrNew($entry['id'])->set($entry);
     if ($row->isNew()) {
         $item = \Components\Blog\Models\Entry::oneByScope($row->get('alias'), $this->model->get('scope'), $this->model->get('scope_id'));
         if ($item->get('id')) {
             $this->setError(Lang::txt('PLG_GROUPS_BLOG_ERROR_ALIAS_EXISTS'));
             return $this->_edit($row);
         }
     }
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     // Process tags
     if (!$row->tag(Request::getVar('tags', ''))) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     App::redirect(Route::url($row->link()));
 }
コード例 #9
0
ファイル: entries.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Sets the state of one or more entries
  *
  * @return  void
  */
 public function stateTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     $state = $this->_task == 'publish' ? 1 : 0;
     // Incoming
     $ids = Request::getVar('id', array(0));
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Check for a resource
     if (count($ids) < 1) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_BLOG_SELECT_ENTRY_TO', $this->_task), 'error');
         return;
     }
     // Loop through all the IDs
     $success = 0;
     foreach ($ids as $id) {
         // Load the article
         $row = Entry::oneOrNew(intval($id));
         $row->set('state', $state);
         // Store new content
         if (!$row->store()) {
             Notify::error($row->getError());
             continue;
         }
         $success++;
     }
     switch ($this->_task) {
         case 'publish':
             $message = Lang::txt('COM_BLOG_ITEMS_PUBLISHED', $success);
             break;
         case 'unpublish':
             $message = Lang::txt('COM_BLOG_ITEMS_UNPUBLISHED', $success);
             break;
         case 'archive':
             $message = Lang::txt('COM_BLOG_ITEMS_ARCHIVED', $success);
             break;
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $message);
 }
コード例 #10
0
ファイル: blog.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Save an entry
  *
  * @return  void
  */
 private function _save()
 {
     // Login check
     if (User::isGuest()) {
         return $this->_login();
     }
     if (User::get('id') != $this->member->get('id')) {
         $this->setError(Lang::txt('PLG_MEMBERS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     // Check for request forgeries
     Request::checkToken();
     $entry = Request::getVar('entry', array(), 'post', 'none', 2);
     if (isset($entry['publish_up']) && $entry['publish_up'] != '') {
         $entry['publish_up'] = Date::of($entry['publish_up'], Config::get('offset'))->toSql();
     }
     if (isset($entry['publish_down']) && $entry['publish_down'] != '') {
         $entry['publish_down'] = Date::of($entry['publish_down'], Config::get('offset'))->toSql();
     }
     // make sure we dont want to turn off comments
     $entry['allow_comments'] = isset($entry['allow_comments']) ?: 0;
     // Instantiate model
     $row = \Components\Blog\Models\Entry::oneOrNew($entry['id'])->set($entry);
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     // Process tags
     if (!$row->tag(Request::getVar('tags', ''))) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     // Log activity
     Event::trigger('system.logActivity', ['activity' => ['action' => $entry['id'] ? 'updated' : 'created', 'scope' => 'blog.entry', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_MEMBERS_BLOG_ACTIVITY_ENTRY_' . ($entry['id'] ? 'UPDATED' : 'CREATED'), '<a href="' . Route::url($row->link()) . '">' . $row->get('title') . '</a>'), 'details' => array('title' => $row->get('title'), 'url' => Route::url($row->link()))], 'recipients' => [$this->member->get('id')]]);
     App::redirect(Route::url($row->link()));
 }
コード例 #11
0
ファイル: blog.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Save an entry
  *
  * @return  void
  */
 private function _save()
 {
     // Login check
     if (User::isGuest()) {
         $this->setError(Lang::txt('MEMBERS_LOGIN_NOTICE'));
         return $this->_login();
     }
     if (User::get('id') != $this->member->get('uidNumber')) {
         $this->setError(Lang::txt('PLG_MEMBERS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     // Check for request forgeries
     Request::checkToken();
     $entry = Request::getVar('entry', array(), 'post', 'none', 2);
     if (isset($entry['publish_up']) && $entry['publish_up'] != '') {
         $entry['publish_up'] = Date::of($entry['publish_up'], Config::get('offset'))->toSql();
     }
     if (isset($entry['publish_down']) && $entry['publish_down'] != '') {
         $entry['publish_down'] = Date::of($entry['publish_down'], Config::get('offset'))->toSql();
     }
     // make sure we dont want to turn off comments
     $entry['allow_comments'] = isset($entry['allow_comments']) ?: 0;
     // Instantiate model
     $row = \Components\Blog\Models\Entry::oneOrNew($entry['id'])->set($entry);
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     // Process tags
     if (!$row->tag(Request::getVar('tags', ''))) {
         $this->setError($row->getError());
         return $this->_edit($row);
     }
     App::redirect(Route::url($row->link()));
 }