public static function userStatus($iProfileId)
 {
     $oUserModel = new \PH7\UserCoreModel();
     echo '<div class="user_status">';
     if ($oUserModel->isOnline($iProfileId, Framework\Mvc\Model\DbConfig::getSetting('userTimeout'))) {
         echo '<img src="', PH7_URL_TPL, PH7_TPL_NAME, PH7_SH, PH7_IMG, 'icon/online.png" alt="', t('Online'), '" title="', t('Is Online!'), '" />';
     } else {
         $iStatus = $oUserModel->getUserStatus($iProfileId);
         $sImgName = $iStatus == 2 ? 'busy' : ($iStatus == 3 ? 'away' : 'offline');
         $sTxt = $iStatus == 2 ? t('Busy') : ($iStatus == 3 ? t('Away') : t('Offline'));
         echo '<img src="', PH7_URL_TPL, PH7_TPL_NAME, PH7_SH, PH7_IMG, 'icon/', $sImgName, '.png" alt="', $sTxt, '" title="', $sTxt, '" />';
     }
     echo '</div>';
     unset($oUserModel);
 }
Beispiel #2
0
 /**
  * Get the User Avatar.
  *
  * @param string $sUername
  * @param string $sSex
  * @param integer $iSize
  * @return void Html contents. URL avatar default 150px or the user avatar.
  */
 public function getUserAvatar($sUsername, $sSex = '', $iSize = '')
 {
     $oCache = (new \PH7\Framework\Cache\Cache())->start(self::CACHE_AVATAR_GROUP . $sUsername, $sSex . $iSize, 60 * 24 * 30);
     if (!($sUrl = $oCache->get())) {
         $oUserModel = new \PH7\UserCoreModel();
         $iProfileId = $oUserModel->getId(null, $sUsername);
         $oGetAvatar = $oUserModel->getAvatar($iProfileId);
         $sSize = $iSize == '32' || $iSize == '64' || $iSize == '100' || $iSize == '150' || $iSize == '200' || $iSize == '400' ? '-' . $iSize : '';
         $sAvatar = @$oGetAvatar->pic;
         $sExt = PH7_DOT . (new File())->getFileExt($sAvatar);
         $sDir = 'user/avatar/img/' . $sUsername . PH7_SH;
         $sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . $sDir . $sAvatar;
         $sUrl = PH7_URL_DATA_SYS_MOD . $sDir . str_replace($sExt, $sSize . $sExt, $sAvatar);
         $bIsModerate = Registry::getInstance()->module === PH7_ADMIN_MOD;
         if (!is_file($sPath) || $oGetAvatar->approvedAvatar == '0') {
             /* If sex is empty, it is recovered in the database using information from member */
             $sSex = !empty($sSex) ? $sSex : $oUserModel->getSex(null, $sUsername, 'Members');
             $sSex = $this->oStr->lower($sSex);
             $sIcon = $sSex == 'male' || $sSex == 'female' || $sSex == 'couple' || $sSex == PH7_ADMIN_USERNAME ? $sSex : 'visitor';
             $sUrlTplName = defined('PH7_TPL_NAME') ? PH7_TPL_NAME : PH7_DEFAULT_THEME;
             /*** If the user does not have an avatar ***/
             if (!is_file($sPath)) {
                 // The user has no avatar, we try to get her Gravatar.
                 // Get the User Email.
                 $sEmail = $oUserModel->getEmail($iProfileId);
                 $bSecureGravatar = \PH7\Framework\Http\Http::isSsl();
                 $sUrl = $this->getGravatarUrl($sEmail, '404', $iSize, 'g', $bSecureGravatar);
                 if (!(new \PH7\Framework\Security\Validate\Validate())->url($sUrl, true)) {
                     // Our Default Image
                     $sUrl = PH7_URL_TPL . $sUrlTplName . PH7_SH . PH7_IMG . 'icon/' . $sIcon . '_no_picture' . $sSize . '.jpg';
                 }
             } elseif (!$bIsModerate) {
                 $sUrl = PH7_URL_TPL . $sUrlTplName . PH7_SH . PH7_IMG . 'icon/pending' . $sSize . '.jpg';
             }
         }
         unset($oUserModel);
         $oCache->put($sUrl);
     }
     unset($oCache);
     echo $sUrl;
 }