Ejemplo n.º 1
0
function console_create_user($args)
{
    $fname = array_shift($args);
    $lname = array_shift($args);
    $email = array_shift($args);
    $admin = array_shift($args) == 'true';
    if (is_null($fname) || is_null($lname) || is_null($email)) {
        throw new Exception('create_user: Missing arguments. Expected: (fname, lname, email, admin)');
    }
    $display_name = $fname . " " . $lname;
    $username = str_replace(" ", "_", strtolower($display_name));
    $user_data = array('username' => $username, 'display_name' => $display_name, 'email' => $email, 'password_generator' => 'random', 'timezone' => 0, 'autodetect_time_zone' => 1, 'create_contact' => false, 'company_id' => owner_company()->getId(), 'send_email_notification' => true, 'personal_project' => 0);
    // array
    try {
        DB::beginWork();
        $user = create_user($user_data, $admin, '');
        if (!$user->getContact() instanceof Contact) {
            $contact = new Contact();
            $contact->setFirstName($fname);
            $contact->setLastName($lname);
            $contact->setEmail($email);
            $contact->setUserId($user->getId());
            $contact->save();
        }
        DB::commit();
    } catch (Exception $e) {
        DB::rollback();
        throw $e;
    }
}
Ejemplo n.º 2
0
	function testAddContact () {
		/* Creation du contact */
		$contact = new Contact();
		$contact->setEmail("*****@*****.**");
		$contact->setFirstName("erwantest");
		$contact->setLastName('dagorntest');
		$ret = $this->sales->add($contact);
		echo '<pre> testAddContact <br>/';
		print_r($contact);
		echo '<br/> retour :'.$ret;
		$this->assertIdentical($ret, true);
		$this->assertIdentical(($contact->getId() != ""), true);
		/* Modification  du contact */
		$contact->setFirstName("erwantestModif");
		$ret = $this->sales->update($contact);
		
		$this->assertIdentical($ret, true);
		/* Suppression du contact */
		$ret = $this->sales->delete($contact->getId());
		$this->assertIdentical($ret, true);
		
	}
Ejemplo n.º 3
0
 private function createContact()
 {
     $contact = new Contact();
     $contact->setEmail($this->getFieldValue('Email'));
     $contact->setLastName($this->getFieldValue('LastName'));
     $contact->setFirstName($this->getFieldValue('FirstName'));
     $contact->setPhone($this->getFieldValue('Telephone'));
     $contact->setSujet($this->getFieldValue('Objet'));
     $contact->setWhatId($this->getFieldValue('whatId'));
     if ($this->getFieldValue('formname') == 'contact_default') {
         $contact->setSujet("Contactez nke : " . $contact->getSujet());
     }
     $corp = "[Origine : " . $this->getCurrentURL() . "]\n" . $this->getFieldValue('Message');
     if ($this->getFieldValue('formname') == 'contact_revendeur') {
         $corp .= "Ville de Résidence : " . $this->getFieldValue('Ville') . "\n" . "Port d'attache : " . $this->getFieldValue('Port') . "\n";
         //"Chantier naval : ".$this->getFieldValue('ChantierNaval')."\n";
     }
     $contact->setTexte($corp);
     return $contact;
 }
Ejemplo n.º 4
0
 function signup_user_constant_contact($firstname, $lastname, $email, $list)
 {
     global $premise_base;
     require_once PREMISE_LIB_DIR . 'constant_contact_api/constant_contact_api.php';
     $settings = $premise_base->get_settings();
     $optin = $settings['optin'];
     $premise_base->setup_constant_contact($this->_optin_ConstantContactKey, $optin['constant-contact-username'], $optin['constant-contact-password']);
     $collection = new ContactsCollection();
     list($search) = $collection->searchByEmail($email);
     if (!empty($search)) {
         foreach ($search as $possible) {
             if ($email == $possible->getEmailAddress()) {
                 $contact = $collection->getContact($possible->getLink());
                 break;
             }
         }
     }
     $listKey = 'http://api.constantcontact.com/ws/customers/' . $optin['constant-contact-username'] . '/lists/' . $list;
     if ($contact) {
         $existingLists = $contact->getLists();
         if (in_array($listKey, $existingLists)) {
             return array('error' => __('You have already subscribed to this mailing list', 'premise'));
         } else {
             $contact->setLists($listKey);
         }
         $contact->setFirstName($firstname);
         $contact->setLastName($lastname);
         $result = $collection->updateContact($contact->getId(), $contact);
     } else {
         $contact = new Contact();
         $contact->setFirstName($firstname);
         $contact->setLastName($lastname);
         $contact->setEmailAddress($email);
         $contact->setLists($listKey);
         $result = $collection->createContact($contact);
     }
     $first = substr((string) $result, 0, 1);
     if ($first != 2) {
         return array('error' => __('Could not subscribe you to this mailing list', 'premise'));
     }
     return true;
 }
Ejemplo n.º 5
0
 public function parseContact($contactObject)
 {
     $contact = new Contact();
     $contact->setPhoneNumber($contactObject->phone_number);
     $contact->setFirstName($contactObject->first_name);
     if (property_exists($contactObject, 'last_name')) {
         $contact->setLastName($contactObject->last_name);
     }
     if (property_exists($contactObject, 'user_id')) {
         $contact->setUserId($contactObject->user_id);
     }
     return $contact;
 }
Ejemplo n.º 6
0
    private function submitManagerApplication()
    {
        $request = \Server::getCurrentRequest();
        $vars = $request->getVars();
        $username = $request->getVar('managerUsername');
        $password = $request->getVar('managerPassword');
        $first_name = $request->getVar('contactFirstName');
        $last_name = $request->getVar('contactLastName');
        $email = $request->getVar('emailAddress');
        $phone = $request->getVar('phoneNumber');
        $hours = $request->getVar('contactHours');
        $company_name = $request->getVar('companyName');
        $company_url = $request->getVar('companyUrl');
        $company_address = $request->getVar('companyAddress');
        $private = $request->getVar('managerType');
        $contact = new Contact();
        try {
            $contact->setUsername($username);
            $contact->setPassword($password);
            $contact->setFirstName($first_name);
            $contact->setLastName($last_name);
            $contact->setEmailAddress($email);
            $contact->setPhone($phone);
            $contact->setTimesAvailable($hours);
            if ($private == 'false') {
                $contact->setPrivate(false);
                if (empty($company_name)) {
                    throw \Exception('Missing company name');
                } else {
                    $contact->setCompanyName($company_name);
                }
                if (empty($company_address)) {
                    throw \Exception('Missing company address');
                } else {
                    $contact->setCompanyAddress($company_address);
                }
                $contact->setCompanyUrl($company_url);
            } else {
                $contact->setPrivate(true);
                $contact->setCompanyName('Private Renter');
            }
            $contact->setApproved(false);
            $contact->save();
            $this->emailApprovalNeeded();
        } catch (\Exception $ex) {
            $address = \PHPWS_Settings::get('properties', 'email');
            \Error::log($ex);
            $this->title = 'Sorry!';
            $this->content = <<<EOF
<p>Your manager submission could not be processed. Please email <a href="mailto:{$address}">{$address}</a> to inform them of your problem.</p>
EOF;
            $this->content .= $ex->getMessage();
            return;
        }
        // success
        $this->title = 'Thank you';
        $this->content = <<<EOF
<p>We will review your manager application and email your confirmation.</p>
                <p><a href="./">Return to the home page</a></p>
EOF;
    }