Esempio n. 1
0
 public static function verifyMembershipByTopicId($topic_id)
 {
     $forum_group_id = Topic::findById($topic_id)->forum_group_id;
     $user = self::getUserLoggedIn();
     if (!(Group_Member::verifyMembership($user->id, $forum_group_id) || $user->admin)) {
         Redirect::to('/', array('message' => 'Et ole ryhmän jäsen!'));
     }
 }
 public static function groups()
 {
     self::checkLoggedIn();
     $user = self::getUserLoggedIn();
     if ($user->admin) {
         $groups = Group::all();
     } else {
         $groups = Group_Member::findGroupByUserId($user->id);
     }
     View::make('groups.html', array('groups' => $groups));
 }
 public static function invite($group_id)
 {
     self::checkLoggedIn();
     self::verifyRightsforDeletingOrEditingGroup($group_id);
     $params = $_POST;
     $user_id = User::findByName($params['name'])->id;
     $message;
     if ($user_id != null) {
         $group_member = new Group_Member(array('forum_group_id' => $group_id, 'user_id' => $user_id));
         $errors = $group_member->errors();
         if (count($errors) == 0) {
             $group_member->save();
             $message = array('message' => 'Käyttäjä lisätty onnistuneesti');
         } else {
             $message = array('errors' => $errors);
         }
     } else {
         $message = array('error' => 'Käyttätunnusta ei ole');
     }
     Redirect::to('/groups/' . $group_id . '/edit', $message);
 }