Ejemplo n.º 1
0
 public function viewGroup($name, $mode = 'default')
 {
     $group = Group::where('group_name', $name)->firstOrFail();
     $subscription = Gsub::where('user_fp', self::userFp())->where('group_name', $name)->first();
     $subscribers = Gsub::where('group_name', $name)->count();
     $subscribers = DB::table('gsubs')->where('gsubs.group_name', $name)->join('users', 'users.user_fp', '=', 'gsubs.user_fp')->select('gsubs.id', 'users.*')->get();
     return View::make('board.group', ['mode' => $mode, 'posts' => Post::group($name, $mode, self::getBL()), 'subscription' => $subscription, 'subscribers' => $subscribers, 'group' => $group]);
 }
Ejemplo n.º 2
0
 public static function createGroup($user_fp, $input)
 {
     $group = new Group();
     $group->group_name = $input['group_name'];
     $group->group_title = $input['group_title'];
     $group->description = $input['description'];
     $group->submit_text = $input['submit_text'];
     if ($input['is_private']) {
         $group->is_private = 1;
     }
     $group->save();
     // Subscribe to group with owner rights
     $gs = new Gsub();
     $gs->user_fp = $user_fp;
     $gs->group_name = $group->group_name;
     $gs->is_member = 1;
     $gs->role = "owner";
     $gs->save();
 }
Ejemplo n.º 3
0
 public static function unsubscribeGroup($name)
 {
     Gsub::unsubscribe($name, self::userFp());
     return Redirect::to('g/' . $name);
 }
Ejemplo n.º 4
0
 public static function createPost($user_fp, $input, $timestamp = false)
 {
     $timestamp = $timestamp ? $timestamp : date('Y-m-d H:i:s');
     if ($input['parent_id'] != 0) {
         $parent_post = Post::findOrFail($input['parent_id']);
         if ($parent_post->parent_id != 0) {
             App::abort(500, "Illegal post_id");
         }
         if (Ban::isBanned($parent_post->user_fp, $user_fp)) {
             App::abort(500, "You are banned");
         }
         if ($parent_post->group_name != "" && Group::where('group_name', $parent_post->group_name)->first()->is_private == 1) {
             if (!Gsub::membership($user_fp, $parent_post->group_name)) {
                 App::abort(500, 'Only members of group can leave comments.');
             }
         }
     } else {
         if ($input['group_name']) {
             $group = Group::where('group_name', $input['group_name'])->firstOrFail();
             if ($group->is_private == 1) {
                 if (!Gsub::membership($user_fp, $input['group_name'])) {
                     App::abort(500, 'Membership required to post.');
                 }
             }
         }
     }
     $message = rtrim($input['message']);
     $plaintext = BaseController::isSigned($message);
     $post = new Post();
     $post->parent_id = $input['parent_id'] ? $input['parent_id'] : 0;
     $post->user_fp = $user_fp;
     $post->timestamp = $timestamp;
     if ($input['source_link']) {
         $post->source_link = $input['source_link'];
     }
     if ($input['title']) {
         $post->title = $input['title'];
     }
     if ($plaintext) {
         $post->clear_message = self::convertEmoji($plaintext);
         $post->message = $message;
     } else {
         $post->clear_message = "";
         $post->message = self::convertEmoji($message);
     }
     if (!isset($parent_post)) {
         if ($input['chan']) {
             $post->chan = $input['chan'];
         }
         if ($input['group_name']) {
             $post->group_name = $input['group_name'];
         }
     }
     $post->save();
     if (isset($parent_post)) {
         $parent_post->replies += 1;
         $parent_post->save();
     }
     return $post;
 }
Ejemplo n.º 5
0
 public static function checkOwner($user_fp, $name)
 {
     if (Gsub::where('group_name', $name)->where('user_fp', $user_fp)->where('role', 'owner')->first() == NULL) {
         App::abort(500, 'You are not owner!');
     }
 }
Ejemplo n.º 6
0
 public static function membership($user_fp, $group_name)
 {
     return Gsub::where('group_name', $group_name)->where('user_fp', $user_fp)->where('is_member', 1)->first();
 }