Skip to content

Commit

Permalink
[Jobs] Allows the admin to preview inactive jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
cbleek committed Jun 24, 2015
1 parent 084dee0 commit 669b78d
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @filesource
* @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
* @author cbleek
* @author bleek@cross-solution.de
* @license MIT
*/

Expand All @@ -14,6 +14,9 @@
use Zend\ServiceManager\ServiceLocatorInterface;
use Applications\Options\ModuleOptions;

/**
* Creates an instance of options for applications
*/
class ModuleOptionsFactory implements FactoryInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* YAWIK
*
* @filesource
* @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
* @author bleek@cross-solution.de
* @license MIT
*/

namespace Applications\Filter;

Expand Down
1 change: 1 addition & 0 deletions module/Applications/src/Applications/Form/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Base extends SummaryForm
{
/**
* Label for the form.
*
* @var string
*/
protected $label = /*@translate*/ 'Cover Letter';
Expand Down
11 changes: 11 additions & 0 deletions module/Applications/src/Applications/Form/Mail.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* YAWIK
*
* @filesource
* @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
* @author bleek@cross-solution.de
* @license MIT
*/

namespace Applications\Form;

Expand All @@ -8,6 +16,9 @@
use Core\Entity\Hydrator\InjectAwareEntityHydrator as Hydrator;
use Zend\InputFilter\InputFilterProviderInterface;

/**
* Formular for inviting or rejecting applicants
*/
class Mail extends Form
{

Expand Down
19 changes: 16 additions & 3 deletions module/Auth/src/Auth/Controller/Plugin/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Auth\Controller\Plugin;

use Auth\Entity\Info;

use Auth\Entity\User;
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
use Zend\Authentication\AuthenticationService;

Expand Down Expand Up @@ -42,11 +41,25 @@ public function __invoke($property=null)
}
return $this->get($property);
}


/**
* Checks, if a user is logged in
*
* @return bool
*/
public function isLoggedIn()
{
return $this->getAuthenticationService()->hasIdentity();
}

/**
* Checks, if a user is an Admin
*
* @return bool
*/
public function isAdmin() {
return $this->getAuthenticationService()->getUser()->getRole() == User::ROLE_ADMIN;
}

public function __call($method, $params)
{
Expand Down
18 changes: 18 additions & 0 deletions module/Auth/src/Auth/Entity/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,22 @@ public function hasOrganization();
*/
public function getOrganization();

/**
* Returns true, if a user is created as a draft.
*
* @return bool
* @since 0.19
*/
public function isDraft();

/**
* marks a users as draft.
*
* @param bool
* @return self
* @since 0.19
*/
public function setIsDraft($draft);


}
13 changes: 11 additions & 2 deletions module/Auth/src/Auth/View/Helper/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Zend\Authentication\AuthenticationService;
use Zend\View\Helper\AbstractHelper;
use Auth\Entity\User;

/**
* View helper to access authentication service and the
Expand Down Expand Up @@ -100,17 +101,25 @@ public function __invoke($property = null)
}
}


/**
* Checks if an user is authenticated.
*
* Proxies to \Zend\AuthenticationService\AuthenticationService::hasIdentity()
*
* @return boolean
* @return bool
* @use getService()
*/
public function isLoggedIn()
{
return $this->getService()->hasIdentity();
}

/**
* Checks, if a user is an Admin
*
* @return bool
*/
public function isAdmin() {
return $this->getService()->getUser()->getRole() == User::ROLE_ADMIN;
}
}
2 changes: 1 addition & 1 deletion module/Auth/test/AuthTest/Entity/InfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @group Jobs
* @group Jobs.Entity
*/
class JobsTest extends \PHPUnit_Framework_TestCase
class InfoTest extends \PHPUnit_Framework_TestCase
{
/**
* The "Class under Test"
Expand Down
151 changes: 151 additions & 0 deletions module/Auth/test/AuthTest/Entity/UserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php
/**
* YAWIK
*
* @filesource
* @license MIT
* @copyright 2013 - 2015 Cross Solution <http://cross-solution.de>
*/

/** */
namespace AuthTest\Entity;

use Auth\Entity\Info;
use Auth\Entity\User;

/**
* Tests for User
*
* @covers \Auth\Entity\User
* @coversDefaultClass \Auth\Entity\User
*
* @author Carsten Bleek <bleek@cross-solution.de>
* @group Jobs
* @group Jobs.Entity
*/
class UserTest extends \PHPUnit_Framework_TestCase
{
/**
* The "Class under Test"
*
* @var User
*/
private $target;

public function setup()
{
$this->target = new User();
}

/**
* @testdox Extends \Core\Entity\AbstractEntity and implements \Auth\Entity\UserInterface
* @coversNothing
*/
public function testExtendsAbstractEntityAndImplementsJobInterface()
{
$this->assertInstanceOf('\Core\Entity\AbstractEntity', $this->target);
$this->assertInstanceOf('\Auth\Entity\UserInterface', $this->target);
}

/**
* @testdox Allows to set the login name of the user
* @covers Auth\Entity\User::getLogin
* @covers Auth\Entity\User::setLogin
*/
public function testSetGetLogin()
{
$input = 'demo';
$this->target->setLogin($input);
$this->assertEquals($input, $this->target->getLogin());
}

public function provideRoleTestData()
{
return array(
array(null, User::ROLE_USER),
array(User::ROLE_ADMIN, User::ROLE_ADMIN),
array(User::ROLE_RECRUITER, User::ROLE_RECRUITER),
array(User::ROLE_USER, User::ROLE_USER),
);
}
/**
* @testdox Allows to set the role name of a user
* @covers Auth\Entity\User::getRole
* @covers Auth\Entity\User::setRole
* @dataProvider provideRoleTestData
*/
public function testSetGetRole($role,$expectedRole)
{
$this->target->setRole($role);
$this->assertEquals($expectedRole, $this->target->getRole());
}

public function provideInfoTestData()
{
return array(
array(new Info(), new Info()),
);
}
/**
* @testdox Allows to set the role name of a user
* @covers Auth\Entity\User::getInfo
* @covers Auth\Entity\User::setInfo
* @dataProvider provideInfoTestData
*/
public function testSetGetInfo($info,$expectedInfo)
{
$this->target->setInfo($info);
$this->assertEquals($expectedInfo, $this->target->getInfo());
}

/**
* @testdox Allows to set the secret of a user
* @covers Auth\Entity\User::getSecret
* @covers Auth\Entity\User::setSecret
*/
public function testSetGetSecret()
{
$input = 'secret';
$this->target->setSecret($input);
$this->assertEquals($input, $this->target->getSecret());
}

/**
* @testdox Allows to mark a user as draft
* @covers Auth\Entity\User::isDraft
* @covers Auth\Entity\User::setIsDraft
*/
public function testSetIsDraft()
{
$input = true;
$this->target->setIsDraft($input);
$this->assertEquals($input, $this->target->isDraft());
$input = false;
$this->target->setIsDraft($input);
$this->assertEquals($input, $this->target->isDraft());
}

public function provideEmailTestData()
{
return array(
array(null, "info1@example.com", "info1@example.com"),
array("user@example.com", "info2@example.com", "user@example.com"),
);
}
/**
* @testdox Allows to set the role name of a user
* @covers Auth\Entity\User::getEmail
* @covers Auth\Entity\User::setEmail
* @dataProvider provideEmailTestData
*/
public function testSetGetEmail($userEmail,$infoEmail,$expectedEmail)
{
$info = new Info();
$info->setEmail($infoEmail);
$this->target->setInfo($info);
$this->target->setEmail($userEmail);
$this->assertEquals($expectedEmail, $this->target->getEmail());
}


}
2 changes: 1 addition & 1 deletion module/Jobs/src/Jobs/Controller/ManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function attachDefaultListeners()
/**
* Dispatch listener callback.
*
* Attachs the MailSender aggregate listener to the job event manager.
* Attaches the MailSender aggregate listener to the job event manager.
*
* @param MvcEvent $e
* @since 0.19
Expand Down
4 changes: 3 additions & 1 deletion module/Jobs/src/Jobs/Controller/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ public function viewAction()
$mvcEvent = $this->getEvent();
$applicationViewModel = $mvcEvent->getViewModel();

$isAdmin=$this->auth()->isAdmin();

$model = $services->get('Jobs/viewModelTemplateFilter')->__invoke($job);

if ($job->status != 'active' && !$job->getPermissions()->isChangeGranted($this->auth()->getUser()) && ! $this->auth()->isAdmin) {
if ($job->status != 'active' && !$job->getPermissions()->isChangeGranted($this->auth()->getUser()) && ! $isAdmin) {
$this->response->setStatusCode(404);
$model->setVariable('message','job is not available');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function createService(ServiceLocatorInterface $serviceLocator)
. $channel->getLinkText() . '|'
. $link . '|' . $channel->getPublishDuration() . '|'
. $currencyFormat($channel->getPrice(),$channel->getCurrency(),2) . '|'
. $channel->getPrice();
. $channel->getPrice() . '|'
. $channel->getLogo();
}


Expand Down
5 changes: 4 additions & 1 deletion module/Jobs/src/Jobs/Options/ProviderOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class ProviderOptions extends AbstractOptions implements \IteratorAggregate {
public function __construct()
{
$this->channels = array();
//$this->long_label = '';
}

/**
Expand All @@ -45,6 +44,8 @@ public function getIterator()
}

/**
* Adds a channel (aka job portal)
*
* @param ChannelOptions $channel
* @return $this
*/
Expand All @@ -56,6 +57,8 @@ public function addChannel(ChannelOptions $channel)
}

/**
* Get a channel by "key"
*
* @param string $key
* @return $this
*/
Expand Down

0 comments on commit 669b78d

Please sign in to comment.