Exemplo n.º 1
0
 public function testGetGroupLeaders()
 {
     $user2 = $this->users["test"];
     $user3 = $this->users["babar"];
     $this->assertEquals(0, count($this->group1->getGroupLeaders()));
     $this->group1->addUser($user2);
     $this->group1->addUser($user3);
     $this->assertEquals(0, count($this->group1->getGroupLeaders()));
     $this->group1->promoteUser($user2);
     $leaders = $this->group1->getGroupLeaders();
     $this->assertEquals(1, count($leaders));
     $this->assertEquals($user2->id, $leaders->current()->id);
     $this->assertEquals($user2->login, $leaders->current()->login);
     $this->group1->promoteUser($user3);
     $this->assertEquals(2, count($this->group1->getGroupLeaders()));
 }
Exemplo n.º 2
0
 public function addleadergroupAction()
 {
     if ($this->_group->isLeaderOrAdmin($this->view->user) == 1) {
         $request = $this->getRequest();
         /* @var $request USVN_Controller_Request_Http */
         $table = new USVN_Db_Table_Groups();
         $group = $table->fetchRow(array("groups_name = ?" => str_replace(USVN_URL_SEP, '/', $request->getParam('group'))));
         /* @var $group USVN_Db_Table_Row_Group */
         try {
             $table = new USVN_Db_Table_Users();
             if ($request->getParam('ap', "") != "") {
                 $user = $table->fetchRow(array("users_login = ?" => $request->getParam('ap')));
                 if ($user === null) {
                     throw new USVN_Exception(sprintf(T_("Unknown user %s"), $request->getParam('ap')));
                 }
                 if (!$group->hasUser($user)) {
                     $group->addUser($user, true);
                 } else {
                     $group->updateLeaderUser($user, 1);
                 }
             }
             if ($request->getParam('deleteid', 0) != 0) {
                 $user = $table->fetchRow(array("users_id = ?" => $request->getParam('deleteid')));
                 if ($user === null) {
                     throw new USVN_Exception(sprintf(T_("Unknown user %s"), $request->getParam('deleteid')));
                 }
                 if ($group->hasUser($user)) {
                     $group->deleteUser($user);
                 }
             }
         } catch (Exception $e) {
             $this->view->message = $e->getMessage();
         }
         $this->view->group = $group;
     } else {
         throw new USVN_Exception(sprintf(T_("Access denied.")));
     }
 }