예제 #1
0
 private function autoJoinGroup()
 {
     require_once FRAMEWORK_PATH . 'models/groupmembership.php';
     $gm = new Groupmembership($this->registry, 0);
     $user = $this->registry->getObject('authenticate')->getUser()->getUserID();
     $gm->getByUserAndGroup($user, $this->groupID);
     if ($gm->isValid()) {
         $gm = new Groupmembership($this->registry, $gm->getID());
     }
     $gm->setApproved(1);
     $gm->save();
     $this->registry->errorPage('New membership', 'Thanks, you have now joined the group');
 }
예제 #2
0
 /**
  * Controller constructor - direct call to false when being embedded via another controller
  * @param Registry $registry our registry
  * @param bool $directCall - are we calling it directly via the framework (true), or via another controller (false)
  */
 public function __construct(Registry $registry, $directCall)
 {
     $this->registry = $registry;
     $urlBits = $this->registry->getObject('url')->getURLBits();
     if ($this->registry->getObject('authenticate')->isLoggedIn()) {
         if (isset($urlBits[1])) {
             require_once FRAMEWORK_PATH . 'models/group.php';
             $this->group = new Group($this->registry, intval($urlBits[1]));
             $this->groupID = intval($urlBits[1]);
             if ($this->group->isValid() && $this->group->isActive()) {
                 require_once FRAMEWORK_PATH . 'models/groupmembership.php';
                 $gm = new Groupmembership($this->registry);
                 $user = $this->registry->getObject('authenticate')->getUser()->getUserID();
                 $gm->getByUserAndGroup($user, $this->groupID);
                 if ($this->group->getCreator() == $user || $gm->getApproved()) {
                     if (isset($urlBits[2])) {
                         switch ($urlBits[2]) {
                             case 'create-topic':
                                 $this->createTopic();
                                 break;
                             case 'view-topic':
                                 $this->viewTopic(intval($urlBits[3]));
                                 break;
                             case 'reply-to-topic':
                                 $this->replyToTopic(intval($urlBits[3]));
                                 break;
                             case 'membership':
                                 $this->manageMembership(intval($urlBits[3]));
                                 break;
                             default:
                                 $this->viewGroup();
                                 break;
                         }
                     } else {
                         $this->viewGroup();
                     }
                 } else {
                     require_once FRAMEWORK_PATH . 'controllers/group/membership.php';
                     $membership = new Membershipcontroller($this->registry, $this->groupID);
                     $membership->join();
                 }
             } else {
                 $this->registry->errorPage('Group not found', 'Sorry, the group you requested was not found');
             }
         } else {
             $this->registry->errorPage('Group not found', 'Sorry, the group you requested was not found');
         }
     } else {
         $this->registry->errorPage('Please login', 'Sorry, you must be logged in to view groups');
     }
 }