public function loadCorporateUser(\Stratum\Model\CorporateUser $user)
 {
     $bullhornClient = $this->getClient();
     $userController = new \Stratum\Controller\CorporateUserController();
     $userController->setLogger($this->_logger);
     //load $user based on ID currently in $user
     $user = $bullhornClient->findCorporateUser($user);
     if ($user == null) {
         //error condition according to Stratum
         //re-initialize
         $user = new \Stratum\Model\CorporateUser();
         $user->setLogger($this->_logger);
     }
     return $user;
 }
 private function findCorporateUser($candidate)
 {
     //find the corporateUser Owner of this candidate (for From and ReplyTo email address)
     //$owner1 = json_decode($candidate->get("owner"), true); //a json array structure
     $owner1 = $candidate->get("owner");
     Log::debug($owner1);
     $owner = null;
     if (isset($owner1['id'])) {
         $ownerId = $owner1['id'];
         if (Cache::has("user" . $ownerId)) {
             $owner = Cache::get("user" . $ownerId);
         } else {
             $owner = new \Stratum\Model\CorporateUser();
             $owner->set("id", $ownerId);
             $this->bcontroller->loadCorporateUser($owner);
             Cache::add('user' . $ownerId, $owner, 60);
         }
     } else {
         Log::debug("No ID in owner?");
         Log::debug($owner1['id']);
     }
     return $owner;
 }
 public function testGetActiveForm()
 {
     //userid=0&entitytype=candidate&entityid=99&privatelabelid=105&height=yy&width=xx
     $upload = "http://northcreek.ca/launch/?userid=0&entitytype=candidate&entityid=10809&privatelabelid=105&height=yy&width=xx";
     $url_components = preg_split("/[?&]/", $upload);
     $id = 0;
     foreach ($url_components as $piece) {
         $length = strlen('entityid');
         if (substr($piece, 0, $length) === 'entityid') {
             $eid = preg_split("/=/", $piece);
             $id = $eid[1];
             echo "Found ID " . $id . "\n";
         }
     }
     $this->candidate->set("id", $id);
     echo "Loading " . $id . "\n";
     self::$bcontroller->load($this->candidate);
     $this->assertNotNull($this->candidate);
     //autofilled fields to be extracted from candidate
     //id,firstName,lastName,dateOfBirth,nickName,email,email2,mobile,phone,workPhone,fax3,pager,customTextBlock2
     $id = $this->candidate->get("id");
     $firstName = $this->candidate->get("firstName");
     $lastName = $this->candidate->get("lastName");
     $dateOfBirth = $this->candidate->getDateOfBirthWithFormat("d/m/Y");
     $maritalStatus = $this->candidate->get("nickName");
     $email = $this->candidate->get("email");
     $workEmail = $this->candidate->get("email2");
     $mobile = $this->candidate->get("mobile");
     $homePhone = $this->candidate->get("phone");
     $workPhone = $this->candidate->get("workPhone");
     $fax = $this->candidate->get("fax3");
     $skype = $this->candidate->get("pager");
     $types = $this->candidate->get("customTextBlock2");
     $ownerId = $this->candidate->get("owner")["id"];
     $owner = new \Stratum\Model\CorporateUser();
     $owner->set("id", $ownerId);
     self::$bcontroller->loadCorporateUser($owner);
     $obj = $this->candidate->loadCustomObject(3);
     if ($obj) {
         $radio = $obj->get("text1");
         $content = $obj->get("textBlock1");
         if ($radio == "No – Generic Email") {
             echo "will send generic email\n";
         } else {
             if ($radio == "Yes - Free Text") {
                 if ($content == "") {
                     echo "will not send anything, no-op\n";
                 } else {
                     echo "will send with content:\n";
                     echo $content . "\n";
                 }
             } else {
                 if ($radio == "Yes - Template") {
                     if ($content == "") {
                         echo "must load template data into customObj3->textBlock1\n";
                     } else {
                         echo "will send with content:\n";
                         echo $content . "\n";
                     }
                 } else {
                     echo "Found this value for Radio: {$radio}\n";
                     echo "Found this value for content:\n{$content}\n";
                 }
             }
         }
     }
     //$types is an array, must translate to String
     $type = '';
     if (is_array($types)) {
         foreach ($types as $t) {
             $type .= $t . ";";
         }
     }
     $type = substr($type, 0, strlen($type) - 1);
     //remove last semi-colon
     $autofill = ['21741440' => [$id, $firstName, $lastName, $dateOfBirth, $maritalStatus], '21741491' => [$type], '21741451' => [$email, $workEmail, $mobile, $homePhone, $workPhone, $fax, $skype]];
     var_dump($autofill);
     //$send = self::$wcontroller->sendUrlWithAutofill($form->id, $email, $autofill);
     //var_dump($send);
 }
Beispiel #4
0
 //load the id from the request
 $id = $request->getAttribute('entityid');
 //set up the controllers and their loggers
 $wcontroller = new \Stratum\Controller\WorldappController();
 $bcontroller = new \Stratum\Controller\BullhornController();
 $bcontroller->setLogger($log);
 $wcontroller->setLogger($log);
 //find the correct form
 $form = $wcontroller->find_form_by_name('Registration Form - Stratum International');
 //load the candidate data from Bullhorn
 $candidate = new Stratum\Model\Candidate();
 $candidate->set("id", $id);
 $bcontroller->load($candidate);
 //find the corporateUser Owner of this candidate (for From and ReplyTo email address)
 $ownerId = $candidate->get("owner")["id"];
 $owner = new \Stratum\Model\CorporateUser();
 $owner->set("id", $ownerId);
 $bcontroller->loadCorporateUser($owner);
 //load the custom Object that contains the template information
 $obj = $this->candidate->loadCustomObject(3);
 //download and store the original template (so we can convert back)
 $emailTemplate = $wcontroller->getEmailTemplate($form->id);
 //set up the correct template
 $newTemplate = [];
 $newTemplate['formId'] = $form->id;
 $newTemplate['from'] = $owner->get("email");
 $newTemplate['replyTo'] = $owner->get("email");
 $newTemplate['subject'] = $emailTemplate->subject;
 $newTemplate['content'] = $obj->get("customTextBlock1");
 //set the correct template on the WorldApp server
 self::$wcontroller->setEmailTemplate($newTemplate);