Example #1
0
	/**
	 * 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 removeModerator()
	 *
	 * @param KunenaForumCategory $category
	 * @return KunenaForumCategory
	 * @depends testAddModerator
	 */
	public function testRemoveModerator(KunenaForumCategory $category) {
		$admin = KunenaFactory::getUser('admin');
		$access = KunenaFactory::getAccessControl ();

		$this->assertTrue($category->removeModerator($admin), "Check that administrator can loose moderator status ({$category->getError()})");
		$this->assertFalse((bool)$admin->moderator, "Check that user is not moderator");
		$mod = $access->getModeratorStatus ($admin);
		$this->assertTrue(empty($mod[$category->id]), "Check that user is not category moderator");

		return $category;
	}