Пример #1
0
 public function get_Country($returnType, $listingFieldID)
 {
     $value = SJB_Countries::getCountryNameByISO2((string) $this->oProfile->location->country->code);
     if (!empty($value)) {
         $listingFieldSID = SJB_ListingFieldManager::getListingFieldSIDByID($listingFieldID);
         if ($listingFieldSID) {
             $value = SJB_ListingFieldManager::getListItemSIDByValue($value, $listingFieldSID);
             return eval('return (' . $returnType . ') $value;');
         }
     }
 }
Пример #2
0
 /**
  * @param SJB_Object $object
  * @return SJB_Object
  */
 public static function fillRegistrationDataWithUser(SJB_Object $object)
 {
     if (self::$oSocialPlugin instanceof LinkedinSocialPlugin && ($oProfile = self::getProfileObject())) {
         /** @var $oProperty SJB_ObjectProperty */
         foreach ($object->getProperties() as $oProperty) {
             $value = '';
             switch ($oProperty->getID()) {
                 case 'Country':
                     if (!empty($oProfile->location->country->code)) {
                         $value = SJB_Countries::getCountryNameByISO2((string) $oProfile->location->country->code);
                     }
                     break;
                 case 'Location':
                     $country = '';
                     $city = '';
                     $address = '';
                     if (!empty($oProfile->location->country->code)) {
                         $country = SJB_Countries::getCountryNameByISO2((string) $oProfile->location->country->code);
                         $country = $country ? SJB_CountriesManager::getCountrySIDByCountryName($country) : '';
                     }
                     if (!empty($oProfile->location->name)) {
                         $city = $oProfile->location->name;
                     }
                     if (!empty($oProfile->{'main-address'})) {
                         $address = $oProfile->{'main-address'};
                     }
                     $location = $object->getChild('Location');
                     $propertyInfo = $location->getPropertyInfo('Country');
                     if ($propertyInfo && (!$propertyInfo['hidden'] || isset($propertyInfo['madeHidden']))) {
                         $location->setPropertyValue('Country', $country);
                     }
                     $propertyInfo = $location->getPropertyInfo('City');
                     if ($propertyInfo && (!$propertyInfo['hidden'] || isset($propertyInfo['madeHidden']))) {
                         $location->setPropertyValue('City', $city);
                     }
                     $propertyInfo = $location->getPropertyInfo('Address');
                     if ($propertyInfo && (!$propertyInfo['hidden'] || isset($propertyInfo['madeHidden']))) {
                         $location->setPropertyValue('Address', $address);
                     }
                     break;
                 case 'DateOfBirth':
                     if (!empty($oProfile->{'date-of-birth'})) {
                         $year = !empty($oProfile->{'date-of-birth'}->year) ? (string) $oProfile->{'date-of-birth'}->year : '0000';
                         $month = !empty($oProfile->{'date-of-birth'}->month) ? (string) $oProfile->{'date-of-birth'}->month : '00';
                         $day = !empty($oProfile->{'date-of-birth'}->day) ? (string) $oProfile->{'date-of-birth'}->day : '00';
                         $value = SJB_I18N::getInstance()->getDate($day . '-' . $month . '-' . $year);
                     }
                     break;
                 case 'FirstName':
                     if (!empty($oProfile->{'first-name'})) {
                         $value = $oProfile->{'first-name'};
                     }
                     break;
                 case 'LastName':
                     if (!empty($oProfile->{'last-name'})) {
                         $value = $oProfile->{'last-name'};
                     }
                     break;
                 case 'ContactName':
                     if (!empty($oProfile->{'last-name'})) {
                         $value = $oProfile->{'first-name'} . ' ' . $oProfile->{'last-name'};
                     }
                     break;
                 case 'WebSite':
                     // WebSite
                     if (!empty($oProfile->website)) {
                         $value = $oProfile->website;
                     }
                     break;
                 case 'Title':
                 case 'TITLE':
                     if (!empty($oProfile->positions->position->title)) {
                         $value = $oProfile->positions->position->title;
                     }
                     break;
                 case 'CompanyName':
                     if (!empty($oProfile->positions->position->company->name)) {
                         $value = $oProfile->positions->position->company->name;
                     }
                     break;
                 case 'CompanyDescription':
                     if (!empty($oProfile->summary)) {
                         $value = $oProfile->summary;
                     }
                     break;
                 case 'City':
                     if (!empty($oProfile->location->name)) {
                         $value = $oProfile->location->name;
                     }
                     break;
                 case 'PhoneNumber':
                     if (!empty($oProfile->{'phone-numbers'})) {
                         $aPhoneNumbers = array();
                         foreach (self::$oProfile->{'phone-numbers'}->{'phone-number'} as $phone) {
                             array_push($aPhoneNumbers, $phone->{'phone-number'} . ' (' . $phone->{'phone-type'} . ')');
                         }
                         $value = implode(', ', $aPhoneNumbers);
                     }
                     break;
                 case 'jsTwitter':
                     if (!empty($oProfile->{'twitter-accounts'})) {
                         $aTwitters = array();
                         foreach (self::$oProfile->{'twitter-accounts'}->{'twitter-account'} as $twitter) {
                             array_push($aTwitters, $twitter->{'provider-account-name'});
                         }
                         $value = implode(', ', $aTwitters);
                     }
                     break;
                 case 'Address':
                     if (!empty($oProfile->{'main-address'})) {
                         $value = $oProfile->{'main-address'};
                     }
                     break;
                 case 'sendmail':
                     $value = false;
                     break;
                 case 'email':
                     if (!empty($oProfile->{'email-address'}) && !SJB_Request::getVar('email', null)) {
                         $value = array('original' => $oProfile->{'email-address'}, 'confirmed' => $oProfile->{'email-address'});
                     }
                     break;
                 case 'username':
                 case 'password':
                     continue 2;
                     break;
                 default:
                     $propertyCanBeDeleted = !in_array($oProperty->getID(), self::$aUserFields) && !in_array($oProperty->getID(), self::$aListingFields) && !$oProperty->isRequired();
                     if ($propertyCanBeDeleted) {
                         $object->deleteProperty($oProperty->getID());
                     }
                     break;
             }
             if (!empty($value)) {
                 $reqVal = SJB_Request::getVar($oProperty->getID(), false);
                 if (empty($reqVal)) {
                     // if user did not modified his data in form
                     $object->setPropertyValue($oProperty->getID(), $value);
                 }
             }
         }
     }
     return $object;
 }