Esempio n. 1
0
 public function run()
 {
     $general = new Logbook(['title' => 'Algemeen logboek', 'user_id' => 1]);
     $general->save();
     // Create a personal logbook for every user
     foreach (User::all() as $user) {
         if (substr($user->email, 0, 6) === 'system') {
             continue;
         }
         $name = ucfirst($user->username);
         $logbook = new Logbook(['title' => "{$name}'s logboek", 'user_id' => $user->id]);
         $logbook->save();
     }
 }
 protected function addBlogEntryForm()
 {
     $form = Form::load('logbook.views.AddBlogEntry');
     $form->setInputValue('author_id',Logbook::current()->authorId());
     $form->setOptions('access_id',PilotSetup::allAccess());
     return $form;
 }
Esempio n. 3
0
 public function __construct()
 {
     View::share('logbooks_visible', Logbook::inOverview()->get());
     if (Auth::check()) {
         View::share('user_logbook', Logbook::where('user_id', Auth::user()->id)->first());
     }
     View::share('recent_tasks', Task::open()->oldest()->take(5)->get());
 }
Esempio n. 4
0
        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;
        }
        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();
	    }
	}
    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;
        }
Esempio n. 9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $logbook_id
  * @return Response
  */
 public function destroy($logbook_id)
 {
     $logbook = Logbook::findOrFail($logbook_id);
     $logbook->delete();
     return Redirect::to(route('logbooks.index'))->with('message', ['content' => 'Logboek met succes verwijderd!', 'class' => 'success']);
 }
Esempio n. 10
0
 /**
  * Remove the specified log from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Logbook::destroy($id);
     return Redirect::route('admin.logs.index')->with('successMessage', 'Kegiatan berhasil dihapus.');
 }
 public function redirectOnAccessDenied()
 {
     Application::setParam('author_id', Logbook::current()->authorId());
     Application::setParam('entry_id', Application::param('entry_id'));
     Application::redirect(Application::defaultHandler());
 }
Esempio n. 12
0
 public static function doTitleSearchForUser($user, $term, $page = 0, $num_per_page = 0)
 {
     $entry = Logbook::getTitleSearchObjectForUser($user, $term);
     $ret = Logbook::fetchPageFromObject($entry, $page, $num_per_page);
     return $ret;
 }
 public function postSave()
 {
     $input = array('title' => Input::get('title'), 'description' => Input::get('description'), 'prioritiy' => Input::get('priority'));
     $rules = array('title' => 'required', 'description' => 'required');
     $messages = array('title.required' => 'Judulnya yang benar', 'description.required' => 'Deskripsi yang benar', 'priority.required' => 'Pilih salah satu prioritas');
     $validation = Validator::make($input, $rules, $messages);
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         $logbook = new Logbook();
         $logbook->user_id = Sentry::getUser()->id;
         $logbook->title = Input::get('title');
         $logbook->deskripsi = Input::get('description');
         $logbook->priorities_id = Input::get('priority');
         $logbook->save();
         return Redirect::back()->with('successMessage', "New Event was Added to Logbook's Record");
     }
 }
Esempio n. 14
0
 protected static function getAttachments($range)
 {
     return [];
     $id = intval($range);
     if ($id != 0) {
         return Logbook::find($id)->user->attachments;
     }
     return Attachment::orderBy('id', 'asc')->get();
 }
Esempio n. 15
0
 public function index()
 {
     return View::make('exports.index', ['logbooks' => Logbook::select('id', 'title')->get(), 'exports' => Export::paginate(25)]);
 }
Esempio n. 16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($user_id)
 {
     $entry = User::findOrFail($user_id);
     $user = $entry['username'];
     $entry->delete();
     $count = Logbook::where('user_id', '=', $user_id)->count();
     $logbooks = Logbook::where('user_id', '=', $user_id)->update(array('user_id' => 0));
     $tasks = Task::where('user_id', '=', $user_id)->update(array('user_id' => 0));
     $attachments = Attachment::where('user_id', '=', $user_id)->update(array('user_id' => 0));
     if ($count == 1) {
         return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes verwijderd! Let op, ' . $count . ' logboek van gebruiker ' . $user . ' is veranderd naar eigenaar Systeem!', 'class' => 'warning']);
     } else {
         if ($count > 1) {
             return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes verwijderd! Let op, ' . $count . ' logboeken van gebruiker ' . $user . ' zijn veranderd naar eigenaar Systeem!', 'class' => 'warning']);
         }
     }
     return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes verwijderd!', 'class' => 'success']);
 }
Esempio n. 17
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($logbook_id, $entry_id)
 {
     $logbook = Logbook::findOrFail($logbook_id);
     if ($logbook->user_id == Auth::user()->id || $logbook->user_id == 0) {
         $entry = Entry::findOrFail($entry_id);
         $entry->fill(Input::only('title', 'body', 'started_at', 'finished_at', 'evidence_id', 'who', 'what', 'where', 'which', 'way', 'when', 'why'));
         if ($entry->validate()) {
             $entry->save();
         } else {
             return View::make('entries.edit', ['entry' => $entry, 'logbook' => $logbook])->withErrors($entry->validator());
         }
         return Redirect::to(route('logbooks.show', [$logbook->id]))->with('message', ['content' => 'Entry met succes geupdated!', 'class' => 'success']);
     } else {
         return Redirect::to(route('logbooks.show', [$logbook->id]))->with('message', ['content' => 'Geen rechten om entry te updaten!', 'class' => 'danger']);
     }
 }