コード例 #1
0
 public function __construct()
 {
     gateKeeper();
     $title = getInput("title");
     $description = getInput("description");
     $access_id = getInput("access_id");
     $membership = getInput("membership");
     $group = new Group();
     $group->title = $title;
     $group->description = $description;
     $group->access_id = $access_id;
     $group->membership = $membership;
     $group->owner_guid = getLoggedInUserGuid();
     $group->save();
     $group->createAvatar();
     $test = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "group", "value" => $group->guid), array("name" => "member_guid", "value" => getLoggedInUserGuid()))));
     if (!$test) {
         $group_membership = new Groupmembership();
         $group_membership->group = $group->guid;
         $group_membership->member_guid = getLoggedInUserGuid();
         $group_membership->access_id = "system";
         $group_membership->save();
     }
     new Activity(getLoggedInUserGuid(), "group:created", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $group->getURL(), $group->title), $group->guid);
     new SystemMessage("Your group has been created.");
     forward("groups");
 }
コード例 #2
0
ファイル: membership.php プロジェクト: simontakite/cookbooks
 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');
 }
コード例 #3
0
ファイル: controller.php プロジェクト: simontakite/cookbooks
 /**
  * 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');
     }
 }
コード例 #4
0
 public function __construct()
 {
     $guid = pageArray(2);
     if (GroupsPlugin::loggedInUserCanJoin($guid)) {
         $membership = new Groupmembership();
         $membership->group = $guid;
         $membership->member_guid = getLoggedInUserGuid();
         $membership->save();
         new SystemMessage("You have successfully joined a group");
         $group = getEntity($guid);
         new Activity(getLoggedInUserGuid(), "group:joined", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $group->getURL(), $group->title), $guid, $group->access_id);
         forward();
     }
 }