/** * get, add, or delete moderators for this category * * @param null|array $addUsers * @param null|array $deleteUsers * @return array */ public function moderators( $addUsers = null, $deleteUsers = null ) { if ( ! $this->_category ) { return array(); } if ( $addUsers !== null ) { if ( is_array( $addUsers ) ) { $this->_category->addModerators( $addUsers ); } else { $this->_category->addModerator( $addUsers ); } } if ( $deleteUsers !== null ) { if ( is_array( $deleteUsers ) ) { foreach ( $deleteUsers as $deleteUser ) { $this->_category->removeModerator( $deleteUser ); } } else { $this->_category->removeModerator( $deleteUsers ); } } return $this->_category->getModerators( false, false ); }
/** * Test addModerator() * * @param KunenaForumCategory $category * @return KunenaForumCategory * @depends testCreate */ public function testAddModerator(KunenaForumCategory $category) { $admin = KunenaFactory::getUser('admin'); $access = KunenaFactory::getAccessControl (); $this->assertFalse($category->addModerator(0), "Check that guests cannot become moderators"); $this->assertFalse($category->addModerator(1, "Check that non-existing users cannot become moderators")); $this->assertTrue($category->addModerator($admin), "Check that administrator can become moderator ({$category->getError()})"); $this->assertTrue((bool)$admin->moderator, "Check that becomes a moderator"); $mod = $access->getModeratorStatus ($admin); $this->assertTrue(!empty($mod[$category->id]), "Check that user becomes category moderator"); $newcategory = new KunenaForumCategory(); $this->assertFalse($newcategory->addModerator($admin), "Check that non-existing categories cannot have moderators"); return $category; }