private function getAvatarImageUrl($size, $addScheme = false) { assert('is_int($size)'); if (isset($this->serializedAvatarData)) { $avatar = unserialize($this->serializedAvatarData); } // Begin Not Coding Standard $baseGravatarUrl = '//www.gravatar.com/avatar/%s?s=' . $size . '&r=g'; $gravatarUrlFormat = $baseGravatarUrl . '&d=identicon'; $gravatarDefaultUrlFormat = $baseGravatarUrl . '&d=mm'; // End Not Coding Standard if (isset($avatar['avatarType']) && $avatar['avatarType'] == static::AVATAR_TYPE_DEFAULT) { $avatarUrl = sprintf($gravatarDefaultUrlFormat, ''); } elseif (isset($avatar['avatarType']) && $avatar['avatarType'] == static::AVATAR_TYPE_PRIMARY_EMAIL) { $email = $this->primaryEmail->emailAddress; $emailHash = md5(strtolower(trim($email))); $avatarUrl = sprintf($gravatarUrlFormat, $emailHash); } elseif (isset($avatar['avatarType']) && $avatar['avatarType'] == static::AVATAR_TYPE_CUSTOM_EMAIL) { $email = $avatar['customAvatarEmailAddress']; $emailHash = md5(strtolower(trim($email))); $avatarUrl = sprintf($gravatarUrlFormat, $emailHash); } else { $avatarUrl = sprintf($gravatarDefaultUrlFormat, ''); } if (isset($this->avatarImageUrl)) { $this->avatarImageUrl = $avatarUrl; } else { if (CurlUtil::urlExists('http:' . $avatarUrl)) { $this->avatarImageUrl = $avatarUrl; } else { $this->avatarImageUrl = Yii::app()->theme->baseUrl . '/images/offline_user.png'; } } if ($addScheme) { return 'http:' . $this->avatarImageUrl; } return $this->avatarImageUrl; }
/** * Updates a language */ public function updateLanguage($languageCode) { try { $language = ActiveLanguage::getByCode($languageCode); } catch (NotFoundException $e) { throw new NotFoundException(Zurmo::t('ZurmoModule', 'Language not active.')); } $translationUrl = ZurmoTranslationServerUtil::getPoFileUrl($language->code); // Check if the po file exists if (!CurlUtil::urlExists($translationUrl)) { throw new NotFoundException(Zurmo::t('ZurmoModule', 'Translation not available.')); } if (ZurmoMessageSourceUtil::importPoFile($language->code, $translationUrl)) { $language->lastUpdateDatetime = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); if ($language->save()) { return true; } } throw new FailedServiceException(Zurmo::t('ZurmoModule', 'Unexpected error. Please try again later.')); }