Ejemplo n.º 1
0
 /**
  * test testGetAllowedActions().
  */
 public function testGetAllowedActions()
 {
     $authManager = new RecruitmentAuthManager();
     $app = JobApplication::getJobApplication(1);
     $app5 = JobApplication::getJobApplication(5);
     // Different users
     $admin = new authorize(null, authorize::YES);
     $hiring = new authorize('011', authorize::NO);
     $first = new authorize(13, authorize::NO);
     $second = new authorize(14, authorize::NO);
     $manager = new authorize(15, authorize::NO);
     $nonManager = new authorize(16, authorize::NO);
     $director = new authorize(17, authorize::NO);
     $otherDirector = new authorize(18, authorize::NO);
     /* SUBMITTED */
     $app->setStatus(JobApplication::STATUS_SUBMITTED);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW);
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW);
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
     /* FIRST INTERVIEW SCHEDULED (scheduled) */
     $app->setStatus(JobApplication::STATUS_FIRST_INTERVIEW_SCHEDULED);
     $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW);
     $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED);
     $expected = array(JobApplication::ACTION_REJECT);
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT);
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT);
     $role = $authManager->getRoleForApplication($first, $app);
     $this->assertEquals(RecruitmentAuthManager::ROLE_INTERVIEW1_MANAGER, $role);
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
     /* FIRST INTERVIEW SCHEDULED (finished) */
     $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW);
     $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_FINISHED);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW);
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW);
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW);
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
     /* SECOND INTERVIEW SCHEDULED (scheduled) */
     $app->setStatus(JobApplication::STATUS_SECOND_INTERVIEW_SCHEDULED);
     $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW);
     $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED);
     $app->setEvents(array($event));
     $expected = array(JobApplication::ACTION_REJECT);
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT);
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT);
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
     /* SECOND INTERVIEW SCHEDULED (finished) */
     $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW);
     $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_FINISHED);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
     // Job Offered
     $app->setStatus(JobApplication::STATUS_JOB_OFFERED);
     $expected = array(JobApplication::ACTION_MARK_OFFER_DECLINED, JobApplication::ACTION_SEEK_APPROVAL);
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_MARK_OFFER_DECLINED, JobApplication::ACTION_SEEK_APPROVAL);
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
     // Offer Declined
     $app->setStatus(JobApplication::STATUS_OFFER_DECLINED);
     $expected = array();
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     // Pending approval
     $app5->setStatus(JobApplication::STATUS_PENDING_APPROVAL);
     $expected = array();
     $actions = $authManager->getAllowedActions($admin, $app5);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($hiring, $app5);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app5);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app5);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app5);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app5);
     $this->assertEquals($expected, $actions);
     $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_APPROVE);
     $actions = $authManager->getAllowedActions($director, $app5);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app5);
     $this->assertEquals($expected, $actions);
     // Hired
     $app->setStatus(JobApplication::STATUS_HIRED);
     $expected = array();
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
     // Rejected
     $app->setStatus(JobApplication::STATUS_REJECTED);
     $expected = array();
     $actions = $authManager->getAllowedActions($admin, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($hiring, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($first, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($second, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($manager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($nonManager, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($director, $app);
     $this->assertEquals($expected, $actions);
     $expected = array();
     $actions = $authManager->getAllowedActions($otherDirector, $app);
     $this->assertEquals($expected, $actions);
 }
Ejemplo n.º 2
0
?>
</div><br />
        <div class="txtName"><?php 
echo $lang_Recruit_JobApplicationDetails_Status;
?>
</div>
        <div class="txtValue" style="white-space:nowrap;">
            <?php 
echo $statusList[$application->getStatus()];
?>
</div><br/>

        <?php 
$authManager = new RecruitmentAuthManager();
$auth = new authorize($_SESSION['empID'], $_SESSION['isAdmin']);
$role = $authManager->getRoleForApplication($auth, $application);
$eventCount = 0;
foreach ($events as $event) {
    $allowEdit = $authManager->isAllowedToEditEvent($auth, $event);
    $allowStatusChange = $authManager->isAllowedToChangeEventStatus($auth, $event);
    $title = $eventTitles[$event->getEventType()];
    if ($event->getEventType() == JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW || $event->getEventType() == JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW) {
        $showEventDate = true;
        $evenDateLabel = $lang_Recruit_JobApplicationHistory_InterviewTime;
        $showStatus = true;
        $showOwner = true;
        $creatorLabel = $lang_Recruit_JobApplicationHistory_ScheduledBy;
    } else {
        $eventDateLabel = '';
        $showEventDate = false;
        $showStatus = false;