protected function addBlogEntryForm() { $form = Form::load('logbook.views.AddBlogEntry'); $form->setInputValue('author_id',Logbook::current()->authorId()); $form->setOptions('access_id',PilotSetup::allAccess()); return $form; }
public function get($field) { $ret = DbObject::get($field); if(($field == 'entry_date') && ($date_format = Logbook::current()->entryDateFormat())) $ret = date($date_format,strtotime($ret)); return $ret; }
public function performHandlerTasks() { $comment = new Comment(); $comment->clauseSafe('author_id', Logbook::current()->authorId()); $comment->clauseSafe('entry_id', Application::param('entry_id')); $comment->clauseSafe('comment_id', Application::param('comment_id')); $comment->delete(); Application::setParam('author_id', Logbook::current()->authorId()); $this->redirectOnSave(); }
public static function blogEntry($author_id = '',$entry_id = '') { $entry = new Entry(); $min_access = Application::user()->minAccessLevel(); $access = $entry->also('Access'); $access->clause('access_level',$min_access,Clause::GTE); if(Application::user()->id()) { $lbk_user = $entry->also('LogbookUser'); $lbk_user->clauseSafe('user_id',Application::user()->id()); } if($author_id) $entry->clauseSafe('author_id',Logbook::current()->authorId()); $entry->maybe('BlogTag'); if(!$entry_id) $entry_id = Application::param('entry_id'); if($entry_id&&$author_id) $entry->clauseSafe('entry_id',$entry_id); $entry->order('entry_date'); /*$entry->order('author_id'); $entry->order('entry_id');*/ $entry->maybe('Comment'); $entry->descending(); try { $page = $entry->page(1,1); $ret = current($page->objects()); Logbook::current()->setAuthorId($ret->get('author_id')); } catch(Exception $exc) { $ret = new Entry(); } return $ret; }
protected function entryToEdit() { if(!is_object($this->entry_to_edit)) { $fetch = new Entry(); $fetch->maybe('BlogTag'); $fetch->noForeign(); $fetch->clauseSafe('author_id',Logbook::current()->authorId()); if($id = Application::param('entry_id')) $fetch->clauseSafe('entry_id',Application::param('entry_id')); else throw new AccessDeniedException('Tried to edit an empty entry id'); $this->entry_to_edit = $fetch; } return $this->entry_to_edit; }
public function save() { $form = Form::load('logbook.views.AddBlogComment'); $capval = Captcha::validate(); if($form->validate()&&$capval) { Application::alterParam('comment_content',strip_tags(Application::param('comment_content'))); $item = new Comment(); $item->parse(); $item->set('comment_date',date('Y-m-d H:M:S')); $item->setSafe('author_id',Logbook::current()->authorId()); $item->save(); Application::setParam('author_id',Application::param('author_id')); Application::setParam('entry_id',Application::param('entry_id')); $this->redirectOnSave(); } }
public function redirectOnAccessDenied() { Application::setParam('author_id', Logbook::current()->authorId()); Application::setParam('entry_id', Application::param('entry_id')); Application::redirect(Application::defaultHandler()); }
private static function getTagSearchObjectForUser($user, $term) { $tag_entry = Logbook::getSearchObjectForUser($user); $tag = $tag_entry->also('BlogTag'); $tag->clauseSafe('tag_name', $term); if (Logbook::current()->shouldExcludeTitleFromTagSearch()) { $title_term = '%' . str_replace(' ', '%', $term) . '%'; $entry->clause('entry_title', $title_term, Clause::NOT_LIKE); } return $tag_entry; }