Beispiel #1
0
 /**
  * Get the contact model of this user. All the user profiles are stored in the
  * addressbook.
  * 
  * @return \GO\Addressbook\Model\Contact 
  */
 public function createContact()
 {
     if (GO::modules()->isInstalled("addressbook")) {
         if (!empty($this->contact_id)) {
             //this is for old databases
             $contact = \GO\Addressbook\Model\Contact::model()->findByPk($this->contact_id);
             if ($contact) {
                 $contact->go_user_id = $this->id;
                 $contact->first_name = $this->first_name;
                 $contact->middle_name = $this->middle_name;
                 $contact->last_name = $this->last_name;
                 $contact->email = $this->email;
                 if ($contact->isModified()) {
                     $contact->save(true);
                 }
                 return $contact;
             }
         }
         $contact = $this->contact();
         if (!$contact) {
             $contact = new \GO\Addressbook\Model\Contact();
             $addressbook = \GO\Addressbook\Model\Addressbook::model()->getUsersAddressbook();
             $contact->go_user_id = $this->id;
             $contact->addressbook_id = $addressbook->id;
         }
         $contact->first_name = $this->first_name;
         $contact->middle_name = $this->middle_name;
         $contact->last_name = $this->last_name;
         $contact->email = $this->email;
         if ($contact->isNew || $contact->isModified()) {
             $contact->skip_user_update = true;
             $contact->save(true);
         }
         return $contact;
     } else {
         return false;
     }
 }