Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new method isClient($identifier) in JApplicationCms class #8971

Merged
merged 5 commits into from
Oct 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions libraries/cms/application/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,11 @@ protected function initialiseApp($options = array())
* @return boolean True if this application is administrator.
*
* @since 3.2
* @deprecated Use isClient('administrator') instead.
*/
public function isAdmin()
{
return $this->getClientId() === 1;
return $this->isClient('administrator');
}

/**
Expand All @@ -685,10 +686,25 @@ public function isAdmin()
* @return boolean True if this application is site.
*
* @since 3.2
* @deprecated Use isClient('site') instead.
*/
public function isSite()
{
return $this->getClientId() === 0;
return $this->isClient('site');
}

/**
* Check the client interface by name.
*
* @param string $identifier String identifier for the application interface
*
* @return boolean True if this application is of the given type client interface.
*
* @since __DEPLOY_VERSION__
*/
public function isClient($identifier)
{
return $this->getName() == $identifier;
}

/**
Expand Down
22 changes: 18 additions & 4 deletions libraries/legacy/application/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -1121,11 +1121,11 @@ public function getClientId()
* @return boolean True if this application is administrator.
*
* @since 11.1
* @deprecated 4.0
* @deprecated 4.0 Use isClient('administrator') instead.
*/
public function isAdmin()
{
return $this->_clientId == 1;
return $this->isClient('administrator');
}

/**
Expand All @@ -1134,11 +1134,25 @@ public function isAdmin()
* @return boolean True if this application is site.
*
* @since 11.1
* @deprecated 4.0
* @deprecated 4.0 Use isClient('site') instead.
*/
public function isSite()
{
return $this->_clientId == 0;
return $this->isClient('site');
}

/**
* Check the client interface by name.
*
* @param string $identifier String identifier for the application interface
*
* @return boolean True if this application is of the given type client interface.
*
* @since __DEPLOY_VERSION__
*/
public function isClient($identifier)
{
return $this->getName() == $identifier;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,19 @@ public function testIsSite()
$this->assertFalse($this->class->isSite());
}

/**
* Tests the JApplicationCms::isClient method.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function testIsClient()
{
$this->assertTrue($this->class->isClient('administrator'));
$this->assertFalse($this->class->isClient('site'));
}

/**
* Tests the JApplicationCms::render method.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,19 @@ public function testIsSite()
$this->assertFalse($this->class->isSite());
}

/**
* Tests the JApplicationCms::isClient method.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function testIsClient()
{
$this->assertFalse($this->class->isClient('administrator'));
$this->assertFalse($this->class->isClient('site'));
}

/**
* Tests the JApplicationCms::redirect method.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ public function testIsSite()
$this->assertTrue($this->class->isSite());
}

/**
* Tests the JApplicationCms::isClient method.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function testIsClient()
{
$this->assertFalse($this->class->isClient('administrator'));
$this->assertTrue($this->class->isClient('site'));
}

/**
* Tests the JApplicationCms::render method.
*
Expand Down