예제 #1
0
 public function postComment($id)
 {
     $input = Input::all();
     Log::info($input);
     $validator = Comment::validate($input);
     if ($validator->fails()) {
         FlashHelper::message("Null title", FlashHelper::DANGER);
         return;
     }
     $post = Post::findOrFail($id);
     if (!$post->can_comment || !PrivacyHelper::checkPermission(Auth::user(), $post)) {
         throw new Exception("Don't have permision");
     }
     $comment = new Comment();
     $Parsedown = new Parsedown();
     $comment->post_id = $id;
     $comment->parrent_id = $input['parrent_id'];
     $comment->markdown = $input['markdown'];
     Log::info($comment);
     $comment->HTML = $Parsedown->text($comment->markdown);
     $comment->save();
     $comment->comments = array();
     $data['html'] = View::make('posts._comment')->with('data', $comment)->with('level', count($comment->parents()))->with('can_comment', true)->render();
     $data['status'] = true;
     $data['parent_id'] = $comment->parrent_id;
     return Response::json($data);
 }
예제 #2
0
 public function postEditPost($id)
 {
     $input = Input::all();
     $validator = Post::validate($input);
     if ($validator->fails()) {
         FlashHelper::message("Null title", FlashHelper::DANGER);
         return Redirect::to(URL::action('BlogController@getNewPost'))->withInput();
     }
     // Post
     $Parsedown = new Parsedown();
     $post = Post::findOrFail($id);
     if ($post->created_by != Auth::id()) {
         return View::make('error.Unauthorized');
     }
     $post->title = Input::get('title');
     $post->makrdown = Input::get('makrdown');
     if (!is_null($post->makrdown)) {
         $post->HTML = $Parsedown->text($post->makrdown);
     }
     $post->privacy_level = Input::get('privacy_level');
     $post->can_comment = Input::get('can_comment');
     // tags
     $topics = trim(Input::get('tags'));
     if ($topics != "") {
         $topics = explode(";", $topics);
         $tagIds = array();
         // Topic Tags
         foreach ($topics as $topic) {
             $tag = Tag::firstOrCreate(array('name' => trim($topic)));
             $tagIds[] = $tag->id;
         }
         // post <=> Tags
         $post->tags()->sync($tagIds);
     }
     // privacy
     if ($post->privacy_level == Post::_CUSTOM) {
         $friends = trim(Input::get('friends'));
         if ($friends == "") {
             $post->privacy_level = Post::_PRIVATE;
         } else {
             $friends = explode(",", $friends);
             $post->friends()->sync($friends);
         }
     }
     $post->save();
     return Redirect::to($post->getShowLink());
 }
예제 #3
0
 public function resendConfirmEmail($email)
 {
     if (empty($email)) {
         return Redirect::to(URL::action('HomeController@showWelcome'));
     }
     // get token
     $token = DB::table('password_reminders')->where('email', $email)->pluck('token');
     if (empty($token)) {
         return Redirect::to(URL::action('HomeController@showWelcome'));
     }
     // send email to confirm
     $data = array('email' => $email, 'clickUrl' => URL::to('/register') . '/confirm/' . $token);
     Mail::send('emails.auth.signup', $data, function ($message) {
         $message->to($email)->subject('Signup Confirmation');
     });
     FlashHelper::message('Please check your Email to get the comfirm link', FlashHelper::SUCCESS);
     return Redirect::to(URL::action('HomeController@showWelcome'))->withInput();
 }
예제 #4
0
 /**
  * @covers jarekkozak\helpers\FlashHelper::setFlashPrimary
  * @todo   Implement testSetFlashPrimary().
  */
 public function testSetFlashPrimary()
 {
     $message = 'Success Message';
     self::assertFalse(FlashHelper::hasFlashPrimary());
     FlashHelper::setFlashPrimary($message);
     self::assertTrue(FlashHelper::hasFlashPrimary());
 }