/**
  * Sets the organizations contact address
  *
  * @return $this
  * @throws \InvalidArgumentException
  */
 protected function setOrganizationInfo()
 {
     if (!isset($this->job)) {
         throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job');
     }
     $organizationName = '';
     $organizationStreet = '';
     $organizationPostalCode = '';
     $organizationPostalCity = '';
     $organization = $this->job->organization;
     $user = $this->job->getUser();
     if (isset($organization)) {
         $organizationName = $organization->organizationName->name;
         $organizationStreet = $organization->contact->street . ' ' . $organization->contact->houseNumber;
         $organizationPostalCode = $organization->contact->postalcode;
         $organizationPostalCity = $organization->contact->city;
         $organizationPhone = $organization->contact->phone;
         $organizationFax = $organization->contact->fax;
     } else {
         $organizationName = $organizationStreet = $organizationPostalCode = $organizationPostalCity = $organizationPhone = $organizationFax = '';
     }
     $this->container['contactEmail'] = $user ? $user->getInfo()->getEmail() : '';
     $this->container['organizationName'] = $organizationName;
     $this->container['street'] = $organizationStreet;
     $this->container['postalCode'] = $organizationPostalCode;
     $this->container['city'] = $organizationPostalCity;
     $this->container['phone'] = $organizationPhone;
     $this->container['fax'] = $organizationFax;
     if (isset($organization) && isset($organization->image) && $organization->image->uri) {
         $this->container['uriLogo'] = $this->makeAbsolutePath($organization->image->uri);
     } else {
         $this->container['uriLogo'] = $this->makeAbsolutePath($this->config->default_logo);
     }
     return $this;
 }
 protected function render()
 {
     $organization = $this->job->getOrganization();
     if ($organization->isHiringOrganization()) {
         $organization = $organization->getParent();
     }
     $users = array($organization->getUser());
     foreach ($organization->getEmployees() as $emp) {
         /* @var $emp \Organizations\Entity\Employee */
         $users[] = $emp->getUser();
     }
     $model = new ViewModel();
     $model->setVariables(array('currentUser' => $this->job->getUser(), 'users' => $users, 'organization' => $organization, 'job' => $this->job));
     $model->setTemplate('jobs/assign-user');
     return $model;
 }
示例#3
0
 public function testSetGetUserTwice()
 {
     $user1 = new User();
     $user1->setId(123);
     $this->target->setUser($user1);
     $user2 = new User();
     $user2->setId(456);
     $this->target->setUser($user2);
     $this->assertEquals($this->target->getUser(), $user2);
 }
示例#4
0
 /**
  * Sends a job event related mail
  *
  * @param Job    $job
  * @param string $template
  * @param string $subject
  * @param bool   $adminMail if true, the mail is send to the administrator instead of to the user.
  */
 protected function sendMail(Job $job, $template, $subject, $adminMail = false)
 {
     $mail = $this->mailer->get('htmltemplate');
     $mail->setTemplate($template)->setSubject($subject)->setVariables(array('job' => $job, 'siteName' => $this->options['siteName']));
     if ($adminMail) {
         $mail->setTo($this->options['adminEmail']);
     } else {
         $user = $job->getUser();
         $userInfo = $user->getInfo();
         $userEmail = $userInfo->getEmail();
         $userName = $userInfo->getDisplayName(false);
         $mail->setTo($userEmail, $userName);
     }
     $this->mailer->send($mail);
 }