public function postSeen($docId, $commentId) { $allowed = false; $user = Auth::user(); $user->load('docs'); // Check user documents against current document foreach ($user->docs as $doc) { if ($doc->id == $docId) { $allowed = true; break; } } if (!$allowed) { throw new Exception("You are not authorized to mark this annotation as seen."); } $comment = Comment::find($commentId); $comment->seen = 1; $comment->save(); $doc = Doc::find($docId); $vars = array('sponsor' => $user->fname . ' ' . $user->lname, 'label' => 'comment', 'slug' => $doc->slug, 'title' => $doc->title, 'text' => $comment->text); $email = $comment->user->email; Mail::queue('email.read', $vars, function ($message) use($email) { $message->subject('Your feedback on Madison was viewed by a sponsor!'); $message->from('*****@*****.**', 'Madison'); $message->to($email); // Recipient address }); return Response::json($comment); }
public function getSearch() { $q = Input::get('q'); $results = Doc::search(urldecode($q)); //$results = json_decode($results); $docs = array(); foreach ($results['hits']['hits'] as $result) { $doc = Doc::find($result['_source']['id']); array_push($docs, $doc); } $data = array('page_id' => 'doc-search', 'page_title' => 'Search Results', 'results' => $docs, 'query' => $q); return View::make('doc.search.index', $data); }
public function editDocument($documentId) { if (!Auth::check()) { return Redirect::to('/')->with('error', 'You must be logged in'); } $doc = Doc::find($documentId); if (is_null($doc)) { return Redirect::to('documents')->with('error', 'Document not found.'); } if (!$doc->canUserEdit(Auth::user())) { return Redirect::to('documents')->with('error', 'You are not authorized to view that document.'); } return View::make('documents.edit', array('page_id' => 'edit_doc', 'page_title' => "Editing {$doc->title}", 'doc' => $doc, 'contentItem' => $doc->content()->where('parent_id')->first())); }
/** * Method for handling annotation notifications * * @param Annotation $data * @return null */ public function onDocAnnotated($data) { $notices = Notification::getActiveNotifications(MadisonEvent::DOC_ANNOTATED); $notifications = $this->processNotices($notices, MadisonEvent::DOC_ANNOTATED); $doc = Doc::find($data->doc_id); //Load annotation link $data->link = $data->getLink(); $this->doNotificationActions($notifications, array('data' => array('annotation' => $data->toArray(), 'doc' => $doc->toArray()), 'subject' => 'A new annotation on a document!', 'from_email_address' => static::FROM_EMAIL_ADDRESS, 'from_email_name' => static::FROM_EMAIL_NAME)); }
public function postDate($doc) { $doc = Doc::find($doc); $date = Input::get('date'); $returned = new Date(); $returned->label = $date['label']; $returned->date = date("Y-m-d H:i:s", strtotime($date['date'])); $doc->dates()->save($returned); return Response::json($returned); }
/** * PUT route for saving documents. */ public function putDocs($id = '') { $user = Auth::user(); if (!$user->can('admin_manage_documents')) { return Redirect::to('/dashboard')->with('message', "You do not have permission"); } $content = Input::get('content'); $content_id = Input::get('content_id'); if ($content_id) { try { $doc_content = DocContent::find($content_id); } catch (Exception $e) { return Redirect::to('dashboard/docs/' . $id)->with('error', 'Error saving the document: ' . $e->getMessage()); } } else { $doc_content = new DocContent(); } $doc_content->doc_id = $id; $doc_content->content = $content; $doc_content->save(); Event::fire(MadisonEvent::DOC_EDITED, $doc); $doc = Doc::find($id); $doc->indexContent($doc_content); return Redirect::to('dashboard/docs/' . $id)->with('success_message', 'Document Saved Successfully'); }