Example #1
0
 /**
  * @param  \CB\Database\Table\TabTable   $tab       the tab database entry
  * @param  \CB\Database\Table\UserTable  $user      the user being displayed
  * @param  int                           $ui        1 for front-end, 2 for back-end
  * @return boolean
  */
 public function getMenuAndStatus($tab, $user, $ui)
 {
     global $_CB_framework, $_CB_database, $ueConfig, $_REQUEST, $_POST;
     $params = $this->params;
     $userId = $user->id && $_CB_framework->myId() == $user->id ? null : $user->id;
     $firstMenuName = $params->get('firstMenuName', '');
     // CBTxt::T( '_UE_MENU_CB', 'Community' )
     $firstSubMenuName = $params->get('firstSubMenuName', '');
     // CBTxt::T( '_UE_MENU_ABOUT_CB', 'About Community Builder...' )
     $firstSubMenuHref = $params->get('firstSubMenuHref', '');
     $secondSubMenuName = $params->get('secondSubMenuName', '');
     $secondSubMenuHref = $params->get('secondSubMenuHref', '');
     // ----- CUSTOM MENU -----
     if ($firstMenuName != '') {
         $customMenu = array();
         $customMenu['arrayPos'] = $firstMenuName;
         $customMenu['position'] = 'menuBar';
         $customMenu['caption'] = CBTxt::T($firstMenuName);
         $this->addMenu($customMenu);
         if ($firstSubMenuName != '') {
             // Custom 1:
             $first = array();
             $first['arrayPos'] = array($firstMenuName => array('_UE_FIRST' => null));
             $first['position'] = 'menuBar';
             $first['caption'] = CBTxt::T($firstSubMenuName);
             $first['url'] = $firstSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($firstSubMenuHref);
             $first['target'] = '';
             $first['img'] = '';
             $first['tooltip'] = '';
             $this->addMenu($first);
             if ($secondSubMenuName != '') {
                 // Custom 2:
                 $second = array();
                 $second['arrayPos'] = array($firstMenuName => array('_UE_SECOND' => null));
                 $second['position'] = 'menuBar';
                 $second['caption'] = CBTxt::T($secondSubMenuName);
                 $second['url'] = $secondSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($secondSubMenuHref);
                 $second['target'] = '';
                 $second['img'] = '';
                 $second['tooltip'] = '';
                 $this->addMenu($second);
             }
         }
     }
     // ----- VIEW MENU -----
     $viewMenu = array();
     $viewMenu['arrayPos'] = '_UE_MENU_VIEW';
     $viewMenu['position'] = 'menuBar';
     $viewMenu['caption'] = CBTxt::T('_UE_MENU_VIEW', 'View');
     $this->addMenu($viewMenu);
     if ($_CB_framework->myId() > 0) {
         if ($_CB_framework->displayedUser() === null || $_CB_framework->myId() != $user->id && $_CB_framework->displayedUser() !== null) {
             // View My Profile:
             $myProfile = array();
             $myProfile['arrayPos'] = array('_UE_MENU_VIEW' => array('_UE_MENU_VIEWMYPROFILE' => null));
             $myProfile['position'] = 'menuBar';
             $myProfile['caption'] = CBTxt::T('UE_MENU_VIEWMYPROFILE', 'View Your Profile');
             $myProfile['url'] = $_CB_framework->userProfileUrl();
             $myProfile['target'] = '';
             $myProfile['img'] = '<span class="fa fa-home"></span> ';
             $myProfile['tooltip'] = CBTxt::T('UE_MENU_VIEWMYPROFILE_DESC', 'View your own profile');
             $this->addMenu($myProfile);
         }
     }
     // ----- EDIT MENU -----
     $editMenu = array();
     $editMenu['arrayPos'] = '_UE_MENU_EDIT';
     $editMenu['position'] = 'menuBar';
     $editMenu['caption'] = CBTxt::T('_UE_MENU_EDIT', 'Edit');
     $this->addMenu($editMenu);
     if (!cbCheckIfUserCanPerformUserTask($user->id, 'allowModeratorsUserEdit')) {
         if ($user->id == $_CB_framework->myId()) {
             $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_UPDATEPROFILE', 'Update Your Profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MENU_UPDATEPROFILE_DESC', 'Change your profile settings'));
         } else {
             $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE', 'Update user profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE_DESC', 'Change profile settings of this user profile'));
         }
         // Update Profile:
         $updateProfile = array();
         $updateProfile['arrayPos'] = array('_UE_MENU_EDIT' => array('_UE_UPDATEPROFILE' => null));
         $updateProfile['position'] = 'menuBar';
         $updateProfile['caption'] = $menuTexts['_UE_UPDATEPROFILE'];
         $updateProfile['url'] = $_CB_framework->userProfileEditUrl($userId);
         $updateProfile['target'] = '';
         $updateProfile['img'] = '<span class="fa fa-edit"></span> ';
         $updateProfile['tooltip'] = $menuTexts['_UE_MENU_UPDATEPROFILE_DESC'];
         $this->addMenu($updateProfile);
     }
     // ----- MESSAGES MENU -----
     $messagesMenu = array();
     $messagesMenu['arrayPos'] = '_UE_MENU_MESSAGES';
     $messagesMenu['position'] = 'menuBar';
     $messagesMenu['caption'] = CBTxt::T('_UE_MENU_MESSAGES', 'Messages');
     $this->addMenu($messagesMenu);
     if ($_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) {
         global $_CB_PMS;
         $resultArray = $_CB_PMS->getPMSlinks($user->id, $_CB_framework->myId(), '', '', 1);
         if (count($resultArray) > 0) {
             foreach ($resultArray as $res) {
                 if (is_array($res)) {
                     // Send Private Message:
                     $sendMessage = array();
                     $sendMessage['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_PM_USER' => null));
                     $sendMessage['position'] = 'menuBar';
                     $sendMessage['caption'] = $res['caption'];
                     // Already translated in CB Menu
                     $sendMessage['url'] = cbSef($res['url']);
                     $sendMessage['target'] = '';
                     $sendMessage['img'] = '<span class="fa fa-comment"></span> ';
                     $sendMessage['tooltip'] = $res['tooltip'];
                     // Already translated in CB Menu
                     $this->addMenu($sendMessage);
                 }
             }
         }
     }
     if ($ueConfig['allow_email_display'] != 4 && $_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) {
         switch ($ueConfig['allow_email_display']) {
             case 1:
                 // Display Email only
                 $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 0);
                 $url = "javascript: void( 0 );;";
                 $desc = CBTxt::T('UE_MENU_USEREMAIL_DESC', 'Email address of this user');
                 break;
             case 2:
                 // Display Email with link
                 $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 1);
                 $url = "javascript: void( 0 );;";
                 $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user');
                 break;
             case 3:
                 // Display Email-to text with link to web-form
             // Display Email-to text with link to web-form
             default:
                 $caption = CBTxt::T('UE_MENU_SENDUSEREMAIL', 'Send Email to User');
                 $url = $_CB_framework->viewUrl('emailuser', true, array('uid' => $userId));
                 $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user');
                 break;
         }
         // Send Email:
         $sendEmail = array();
         $sendEmail['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_MENU_SENDUSEREMAIL' => null));
         $sendEmail['position'] = 'menuBar';
         $sendEmail['caption'] = $caption;
         $sendEmail['url'] = $url;
         $sendEmail['target'] = '';
         $sendEmail['img'] = '<span class="fa fa-envelope"></span> ';
         $sendEmail['tooltip'] = $desc;
         $this->addMenu($sendEmail);
     }
     // ----- CONNECTIONS MENU -----
     $connectionsMenu = array();
     $connectionsMenu['arrayPos'] = '_UE_MENU_CONNECTIONS';
     $connectionsMenu['position'] = 'menuBar';
     $connectionsMenu['caption'] = CBTxt::T('_UE_MENU_CONNECTIONS', 'Connections');
     $this->addMenu($connectionsMenu);
     if ($ueConfig['allowConnections'] && $_CB_framework->myId() > 0) {
         // Manage My Connections:
         $manageConnections = array();
         $manageConnections['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array('_UE_MENU_MANAGEMYCONNECTIONS' => null));
         $manageConnections['position'] = 'menuBar';
         $manageConnections['caption'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS', 'Manage Your Connections');
         $manageConnections['url'] = $_CB_framework->viewUrl('manageconnections');
         $manageConnections['target'] = '';
         $manageConnections['img'] = '<span class="fa fa-users"></span> ';
         $manageConnections['tooltip'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS_DESC', 'Manage your existing connections and pending connections actions');
         $this->addMenu($manageConnections);
         if ($_CB_framework->myId() != $user->id) {
             $cbConnection = new cbConnection((int) $_CB_framework->myId());
             $cbUser =& CBuser::getInstance((int) $user->id, false);
             $connClass = null;
             $connLink = null;
             $connDesc = null;
             $connMsg = null;
             $connImg = null;
             $isConnection = $cbConnection->isConnected((int) $user->id);
             if ($isConnection) {
                 $isApproved = $cbConnection->isConnectionApproved((int) $user->id);
                 $isAccepted = $cbConnection->isConnectionAccepted((int) $user->id);
             } else {
                 $isApproved = false;
                 $isAccepted = false;
             }
             if (!$isConnection) {
                 $connUrl = $_CB_framework->viewUrl('addconnection', true, array('connectionid' => (int) $user->id));
                 if ($ueConfig['useMutualConnections'] == 1) {
                     $connClass = 'UE_ADDCONNECTIONREQUEST';
                     $connMsg = CBTxt::T('UE_ADDCONNECTIONREQUEST', 'Request Connection');
                     $connDesc = CBTxt::T('UE_ADDCONNECTIONREQUEST_DESC', 'Request a Connection to that user');
                 } else {
                     $connClass = 'UE_ADDCONNECTION';
                     $connMsg = CBTxt::T('UE_ADDCONNECTION', 'Add Connection');
                     $connDesc = CBTxt::T('UE_ADDCONNECTION_DESC', 'Add a Connection to that user');
                 }
                 if ($ueConfig['conNotifyType'] != 0) {
                     cbValidator::loadValidation();
                     $tooltipTitle = sprintf(CBTxt::T('UE_CONNECTTO', 'Connect to %s'), $cbUser->getField('formatname', null, 'html', 'none', 'profile', 0, true));
                     $connectionInvitationMsg = CBTxt::T('UE_CONNECTIONINVITATIONMSG', 'Personalize your invitation to connect by adding a message that will be included with your connection.');
                     $tooltip = null;
                     if ($connectionInvitationMsg) {
                         $tooltip .= '<div class="form-group cb_form_line clearfix">' . $connectionInvitationMsg . '</div>';
                     }
                     $tooltip .= '<form action="' . $connUrl . '" method="post" id="connOverForm" name="connOverForm" class="cb_form cbValidation">' . '<div class="form-group cb_form_line clearfix">' . '<label for="message" class="control-label">' . CBTxt::T('UE_MESSAGE', 'Message') . '</label>' . '<div class="cb_field">' . '<textarea cols="40" rows="8" name="message" class="form-control"></textarea>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbConnReqSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_SENDCONNECTIONREQUEST', 'Request Connection')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" id="cbConnReqCancel" class="btn btn-default cbConnReqCancel cbTooltipClose" value="' . htmlspecialchars(CBTxt::Th('UE_CANCELCONNECTIONREQUEST', 'Cancel')) . '" />' . '</div>' . '</form>';
                     $connLink = cbTooltip($ui, $tooltip, $tooltipTitle, 400, null, '<span class="fa fa-heart"></span> ' . CBTxt::Th($connMsg), 'javascript: void( 0 );', 'data-hascbtooltip="true" data-cbtooltip-modal="true"');
                 } else {
                     $connLink = $connUrl;
                     $connImg = '<span class="fa fa-heart"></span> ';
                 }
             } else {
                 if ($isAccepted) {
                     $connUrl = $_CB_framework->viewUrl('removeconnection', true, array('connectionid' => (int) $user->id));
                     if ($isApproved) {
                         $connClass = 'UE_REMOVECONNECTION';
                         $connMsg = CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection');
                         $connDesc = CBTxt::T('UE_REMOVECONNECTION_DESC', 'Remove Connection to that user');
                     } else {
                         $connClass = 'UE_REVOKECONNECTIONREQUEST';
                         $connMsg = CBTxt::T('UE_REVOKECONNECTIONREQUEST', 'Revoke Connection Request');
                         $connDesc = CBTxt::T('UE_REVOKECONNECTIONREQUEST_DESC', 'Cancel the Connection Request to that user');
                     }
                     $js = "if ( typeof confirmSubmit != 'function' ) {" . "function confirmSubmit() {" . "if ( confirm( '" . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . "' ) ) {" . "return true;" . "} else {" . "return false;" . "}" . "};" . "}";
                     $_CB_framework->document->addHeadScriptDeclaration($js);
                     $connLink = $connUrl . '" onclick="return confirmSubmit();';
                     $connImg = '<span class="fa fa-heart-o"></span> ';
                 } else {
                     $connClass = null;
                     $connMsg = null;
                 }
             }
             if ($connMsg) {
                 // Request/Add/Remove/Revoke Connection:
                 $connectionRequest = array();
                 $connectionRequest['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array($connClass => null));
                 $connectionRequest['position'] = 'menuBar';
                 $connectionRequest['caption'] = $connMsg;
                 $connectionRequest['url'] = $connLink;
                 $connectionRequest['target'] = '';
                 $connectionRequest['img'] = $connImg;
                 $connectionRequest['tooltip'] = $connDesc;
                 $this->addMenu($connectionRequest);
             }
         }
     }
     // ----- MODERATE MENU -----
     $moderateMenu = array();
     $moderateMenu['arrayPos'] = '_UE_MENU_MODERATE';
     $moderateMenu['position'] = 'menuBar';
     $moderateMenu['caption'] = CBTxt::T('_UE_MENU_MODERATE', 'Moderate');
     $this->addMenu($moderateMenu);
     if ($_CB_framework->myId() == $user->id) {
         if ($user->banned == 1 && $this->cbUserIsModerator == 0 && $ueConfig['allowUserBanning'] == 1) {
             // Request Unban:
             $requestUnban = array();
             $requestUnban['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REQUESTUNBANPROFILE' => null));
             $requestUnban['position'] = 'menuBar';
             $requestUnban['caption'] = CBTxt::T('UE_REQUESTUNBANPROFILE', 'Submit Unban Request');
             $requestUnban['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 2, 'reportform' => 1, 'uid' => (int) $user->id));
             $requestUnban['target'] = '';
             $requestUnban['img'] = '<span class="fa fa-envelope"></span> ';
             $requestUnban['tooltip'] = CBTxt::T('UE_MENU_REQUESTUNBANPROFILE_DESC', 'Submit a request to the site moderator to unban your profile');
             $this->addMenu($requestUnban);
         }
     } else {
         if ($ueConfig['allowUserReports'] == 1 && $this->cbUserIsModerator == 0 && $_CB_framework->myId() > 0) {
             // Report User:
             $reportUser = array();
             $reportUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REPORTUSER' => null));
             $reportUser['position'] = 'menuBar';
             $reportUser['caption'] = CBTxt::T('UE_REPORTUSER', 'Report User');
             $reportUser['url'] = $_CB_framework->viewUrl('reportuser', true, array('uid' => (int) $user->id));
             $reportUser['target'] = '';
             $reportUser['img'] = '<span class="fa fa-bullhorn"></span> ';
             $reportUser['tooltip'] = CBTxt::T('UE_MENU_REPORTUSER_DESC', 'Report this user to the site moderator so that he can take appropriate action');
             $this->addMenu($reportUser);
         }
         if ($this->cbMyIsModerator == 1 && $this->cbUserIsModerator == 0) {
             $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id . "\n AND " . $_CB_database->NameQuote('reportedstatus') . " = 0";
             $_CB_database->setQuery($query);
             $pendingReports = $_CB_database->loadResult();
             $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id;
             $_CB_database->setQuery($query);
             $processedReports = $_CB_database->loadResult();
             if ($ueConfig['allowUserBanning'] == 1) {
                 if ($user->banned != 0) {
                     // Unban Profile:
                     $unbanUser = array();
                     $unbanUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_UNBANPROFILE' => null));
                     $unbanUser['position'] = 'menuBar';
                     $unbanUser['caption'] = CBTxt::T('UE_UNBANPROFILE', 'Unban Profile');
                     $unbanUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 0, 'reportform' => 0, 'uid' => (int) $user->id));
                     $unbanUser['target'] = '';
                     $unbanUser['img'] = '<span class="fa fa-check-circle-o"></span> ';
                     $unbanUser['tooltip'] = CBTxt::T('UE_MENU_UNBANPROFILE_DESC', 'As Site Moderator: Unban this profile, making it visible to other users');
                     $this->addMenu($unbanUser);
                 } else {
                     // Ban Profile:
                     $banUser = array();
                     $banUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_BANPROFILE' => null));
                     $banUser['position'] = 'menuBar';
                     $banUser['caption'] = CBTxt::T('UE_BANPROFILE', 'Ban Profile');
                     $banUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 1, 'uid' => (int) $user->id));
                     $banUser['target'] = '';
                     $banUser['img'] = '<span class="fa fa-ban"></span> ';
                     $banUser['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_DESC', 'As Site Moderator: Ban this profile, making it invisible to other users');
                     $this->addMenu($banUser);
                 }
                 if ($user->bannedby) {
                     // Ban History:
                     $banHistory = array();
                     $banHistory['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_MENU_BANPROFILE_HISTORY' => null));
                     $banHistory['position'] = 'menuBar';
                     $banHistory['caption'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY', 'Ban history');
                     $banHistory['url'] = $_CB_framework->viewUrl('moderatebans', true, array('act' => 2, 'uid' => (int) $user->id));
                     $banHistory['target'] = '';
                     $banHistory['img'] = '<span class="fa fa-book"></span> ';
                     $banHistory['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY_DESC', 'As Site Moderator: See ban history of this profile');
                     $this->addMenu($banHistory);
                 }
             }
             if ($ueConfig['allowUserReports'] == 1 && $pendingReports > 0) {
                 // View Pending Reports:
                 $userReports = array();
                 $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null));
                 $userReports['position'] = 'menuBar';
                 $userReports['caption'] = CBTxt::T('UE_VIEWUSERREPORTS', 'View User Reports');
                 $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('uid' => (int) $user->id));
                 $userReports['target'] = '';
                 $userReports['img'] = '<span class="fa fa-warning"></span> ';
                 $userReports['tooltip'] = CBTxt::T('UE_MENU_VIEWUSERREPORTS_DESC', 'As Site Moderator: View User Reports for this user');
                 $this->addMenu($userReports);
             } elseif ($ueConfig['allowUserReports'] == 1 && $processedReports > 0) {
                 // View Processed Reports:
                 $userReports = array();
                 $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null));
                 $userReports['position'] = 'menuBar';
                 $userReports['caption'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS', 'View processed user reports');
                 $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('act' => 1, 'uid' => (int) $user->id));
                 $userReports['target'] = '';
                 $userReports['img'] = '<span class="fa fa-warning"></span> ';
                 $userReports['tooltip'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS_DESC', 'As site moderator: View processed user reports for this user');
                 $this->addMenu($userReports);
             }
         }
     }
 }
/**
 * CB 1.0 COMPATIBILITY FUNCTION: DO NOT USE FOR NEW DEVELOPMENT !
 * replaced by cbGetField temporarly
 * @access private
 *
 * @param unknown_type $oType
 * @param unknown_type $oValue
 * @param unknown_type $user
 * @param unknown_type $prefix
 * @param unknown_type $imgMode
 * @param unknown_type $linkURL
 * @param unknown_type $field
 * @return unknown
 */
function getFieldValue($oType, $oValue = null, $user = null, $prefix = null, $imgMode = 0, $linkURL = null, $field = null)
{
    global $ueConfig, $_CB_database, $_CB_framework, $_PLUGINS;
    $oReturn = "";
    switch ($oType) {
        case 'checkbox':
            if ($oValue != '' && $oValue != null) {
                if ($oValue == 1) {
                    $oReturn = _UE_YES;
                } elseif ($oValue == 0) {
                    $oReturn = _UE_NO;
                } else {
                    $oReturn = null;
                }
            }
            break;
        case 'select':
        case 'radio':
            $oReturn = htmlspecialchars(getLangDefinition($oValue));
            break;
        case 'multiselect':
        case 'multicheckbox':
            $oReturn = array();
            $oReturn = explode("|*|", htmlspecialchars($oValue));
            for ($i = 0; $i < count($oReturn); $i++) {
                $oReturn[$i] = htmlspecialchars(getLangDefinition($oReturn[$i]));
            }
            $oReturn = implode(', ', $oReturn);
            break;
        case 'date':
            if ($oValue != '' || $oValue != null) {
                if ($oValue != '0000-00-00 00:00:00' && $oValue != '0000-00-00') {
                    $oReturn = cbFormatDate(htmlspecialchars($oValue));
                } else {
                    $oReturn = "";
                }
            }
            break;
        case 'primaryemailaddress':
            if ($ueConfig['allow_email_display'] == 3 || $imgMode != 0) {
                $oValueText = _UE_SENDEMAIL;
            } else {
                $oValueText = htmlspecialchars($oValue);
            }
            $emailIMG = '<img src="' . $_CB_framework->getCfg('live_site') . '/components/com_comprofiler/images/email.gif" border="0" alt="' . _UE_SENDEMAIL . '" title="' . _UE_SENDEMAIL . '" />';
            switch ($imgMode) {
                case 0:
                    $linkItemImg = null;
                    $linkItemSep = null;
                    $linkItemTxt = $oValueText;
                    break;
                case 1:
                    $linkItemImg = $emailIMG;
                    $linkItemSep = null;
                    $linkItemTxt = null;
                    break;
                case 2:
                    $linkItemImg = $emailIMG;
                    $linkItemSep = ' ';
                    $linkItemTxt = $oValueText;
                    break;
            }
            //if no email or 4 (do not display email) then return empty string
            if ($oValue == null || $ueConfig['allow_email_display'] == 4 || $imgMode != 0 && $ueConfig['allow_email_display'] == 1) {
                $oReturn = "";
            } else {
                switch ($ueConfig['allow_email_display']) {
                    case 1:
                        //display email only
                        $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 0);
                        break;
                    case 2:
                        //mailTo link
                        // cloacking doesn't cloack the text of the hyperlink, if that text does contain email addresses		//TODO: fix it.
                        if (!$linkItemImg && $linkItemTxt == htmlspecialchars($oValue)) {
                            $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, '', 0);
                        } elseif ($linkItemImg && $linkItemTxt != htmlspecialchars($oValue)) {
                            $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, $linkItemImg . $linkItemSep . $linkItemTxt, 0, false);
                        } elseif ($linkItemImg && $linkItemTxt == htmlspecialchars($oValue)) {
                            $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, $linkItemImg, 0, false) . $linkItemSep;
                            $oReturn .= moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, '', 0);
                        } elseif (!$linkItemImg && $linkItemTxt != htmlspecialchars($oValue)) {
                            $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, $linkItemTxt, 0);
                        }
                        break;
                    case 3:
                        //email Form (with cloacked email address if visible)
                        $oReturn = "<a href=\"" . cbSef("index.php?option=com_comprofiler&amp;task=emailUser&amp;uid=" . $user->id . getCBprofileItemid(true)) . "\" title=\"" . _UE_MENU_SENDUSEREMAIL_DESC . "\">" . $linkItemImg . $linkItemSep;
                        if ($linkItemTxt && $linkItemTxt != _UE_SENDEMAIL) {
                            $oReturn .= moscomprofilerHTML::emailCloaking($linkItemTxt, 0);
                        } else {
                            $oReturn .= $linkItemTxt;
                        }
                        $oReturn .= "</a>";
                        break;
                }
            }
            break;
        case 'pm':
            $pmIMG = '<img src="' . $_CB_framework->getCfg('live_site') . '/components/com_comprofiler/images/pm.gif" border="0" alt="' . _UE_PM_USER . '" title="' . _UE_PM_USER . '" />';
            $oReturn = "";
            global $_CB_PMS;
            $resultArray = $_CB_PMS->getPMSlinks($user->id, $_CB_framework->myId(), "", "", 1);
            // toid,fromid,subject,message,1: link to compose new PMS message for $toid user.
            if (count($resultArray) > 0) {
                foreach ($resultArray as $res) {
                    if (is_array($res)) {
                        switch ($imgMode) {
                            case 0:
                                $linkItem = getLangDefinition($res["caption"]);
                                break;
                            case 1:
                                $linkItem = $pmIMG;
                                break;
                            case 2:
                                $linkItem = $pmIMG . ' ' . getLangDefinition($res["caption"]);
                                break;
                        }
                        $oReturn .= "<a href=\"" . cbSef($res["url"]) . "\" title=\"" . getLangDefinition($res["tooltip"]) . "\">" . $linkItem . "</a>";
                    }
                }
            }
            break;
        case 'emailaddress':
            if ($oValue == null) {
                $oReturn = '';
            } else {
                if ($ueConfig['allow_email'] == 1) {
                    $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, "", 0);
                } else {
                    $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 0);
                }
            }
            break;
        case 'webaddress':
            if ($oValue == null) {
                $oReturn = "";
            } elseif ($ueConfig['allow_website'] == 1) {
                $oReturn = array();
                $oReturn = explode("|*|", $oValue);
                if (count($oReturn) < 2) {
                    $oReturn[1] = $oReturn[0];
                }
                $oReturn = "<a href=\"http://" . htmlspecialchars($oReturn[0]) . "\" target=\"_blank\" rel=\"nofollow\">" . htmlspecialchars($oReturn[1]) . "</a>";
            } else {
                $oReturn = $oValue;
            }
            break;
        case 'image':
            $cbUser =& CBuser::getInstance(null);
            $cbUser->loadCbRow($user);
            $oValue = $cbUser->avatarFilePath();
            /*
            			if(is_dir($_CB_framework->getCfg('absolute_path')."/components/com_comprofiler/plugin/language/".$_CB_framework->getCfg( 'lang' )."/images")) $fileLang=$_CB_framework->getCfg( 'lang' );
            			else $fileLang="default_language";
            
            			if($user->avatarapproved==0) $oValue="components/com_comprofiler/plugin/language/".$fileLang."/images/tnpendphoto.jpg";
            			elseif(($user->avatar=='' || $user->avatar==null) && $user->avatarapproved==1) $oValue = "components/com_comprofiler/plugin/language/".$fileLang."/images/tnnophoto.jpg";
            			elseif(strpos($user->avatar,"gallery/")===false) $oValue="images/comprofiler/tn".$oValue;
            			else $oValue="images/comprofiler/".$oValue;
            
            			if(!is_file($_CB_framework->getCfg('absolute_path')."/".$oValue)) $oValue = "components/com_comprofiler/plugin/language/".$fileLang."/images/tnnophoto.jpg";
            			if(is_file($_CB_framework->getCfg('absolute_path')."/".$oValue)) {
            */
            $onclick = null;
            $aTag = null;
            if ($ueConfig['allow_profilelink'] == 1) {
                $profileURL = cbSef("index.php?option=com_comprofiler&amp;task=userProfile&amp;user="******"onclick=\"javascript:window.location='".$profileURL."'\"";
                $aTag = "<a href=\"" . $profileURL . "\">";
            }
            $oReturn = $aTag . "<img src=\"" . $oValue . "\" " . $onclick . " alt=\"\" style=\"border-style: none;\" />" . ($aTag ? "</a>" : "");
            /*
            			}
            */
            break;
        case 'status':
            if ($ueConfig['allow_onlinestatus'] == 1) {
                if (isset($user)) {
                    $_CB_database->setQuery("SELECT COUNT(*) FROM #__session WHERE userid = " . (int) $user->id . " AND guest = 0");
                    $isonline = $_CB_database->loadResult();
                } else {
                    $isonline = $oValue;
                }
                if ($isonline > 0) {
                    $oValue = _UE_ISONLINE;
                    // $img			=	'online.png';
                    $class = 'cb_online';
                    // $onlineIMG= "<img src=\"components/com_comprofiler/images/online.gif\" border=\"0\" alt=\"".$oValue."\" title=\"".$oValue."\" />";
                } else {
                    $oValue = _UE_ISOFFLINE;
                    // $img			=	'offline.png';
                    $class = 'cb_offline';
                    // $onlineIMG= "<img src=\"components/com_comprofiler/images/offline.gif\" border=\"0\" alt=\"".$oValue."\" title=\"".$oValue."\" />";
                }
                switch ($imgMode) {
                    case 0:
                        $oReturn = $oValue;
                        break;
                    case 1:
                        //$oReturn=$onlineIMG;
                        $oReturn = '<span class="' . $class . '" title="' . htmlspecialchars($oValue) . '">&nbsp;</span>';
                        break;
                    case 2:
                        //$oReturn=$onlineIMG.' '.$oValue;
                        $oReturn = '<span class="' . $class . '"><span>' . htmlspecialchars($oValue) . '</span></span>';
                        break;
                }
            }
            break;
        case 'formatname':
            if ($linkURL && $ueConfig['allow_profilelink'] == 1) {
                $oReturn = "<a href=\"" . $linkURL . "\">";
            }
            $oReturn .= getNameFormat($user->name, $user->username, $ueConfig['name_format']);
            if ($linkURL && $ueConfig['allow_profilelink'] == 1) {
                $oReturn .= "</a>";
            }
            break;
        case 'textarea':
            $oReturn = nl2br(htmlspecialchars($oValue));
            break;
        case 'delimiter':
            if ($field !== null && $user !== null) {
                $oReturn = cbReplaceVars(getLangDefinition(cbUnHtmlspecialchars($field->description)), $user);
                //TBD: unhtml is kept for backwards database compatibility until CB 2.0
            } else {
                $oReturn = cbReplaceVars(getLangDefinition($oValue), $user);
            }
            break;
        case 'editorta':
            $cbFielfs = new cbFields();
            $badHtmlFilter =& $cbFielfs->getInputFilter(array(), array(), 1, 1);
            if (isset($ueConfig['html_filter_allowed_tags']) && $ueConfig['html_filter_allowed_tags']) {
                $badHtmlFilter->tagBlacklist = array_diff($badHtmlFilter->tagBlacklist, explode(" ", $ueConfig['html_filter_allowed_tags']));
            }
            $oReturn = $cbFielfs->clean($badHtmlFilter, $oValue);
            unset($cbFielfs);
            break;
        case 'predefined':
            if ($linkURL && $ueConfig['allow_profilelink'] == 1) {
                $oReturn = "<a href=\"" . $linkURL . "\">";
            }
            $oReturn .= htmlspecialchars(cbUnHtmlspecialchars($oValue));
            // needed for #__users:name (has &039; instead of ' in it...)		//TBD: unhtml is kept for backwards database compatibility until CB 2.0
            if ($linkURL && $ueConfig['allow_profilelink'] == 1) {
                $oReturn .= "</a>";
            }
            break;
        case 'text':
        default:
            if ($field != null) {
                $args = array(&$field, &$user, 'html', 'profile');
                $oReturn = $_PLUGINS->callField($oType, 'getField', $args, $field);
            } else {
                $oReturn = htmlspecialchars($oValue);
            }
            break;
    }
    if ($prefix != null && ($oReturn != null || $oReturn != '')) {
        $oReturn = $prefix . $oReturn;
    }
    return $oReturn;
}
Example #3
0
 /**
  * Returns a field in specified format
  *
  * @param  FieldTable  $field
  * @param  UserTable   $user
  * @param  string      $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string      $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  int         $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @return mixed
  */
 public function getField(&$field, &$user, $output, $reason, $list_compare_types)
 {
     global $ueConfig;
     $value = $user->get($field->name);
     switch ($output) {
         case 'html':
         case 'rss':
             $useLayout = true;
             if ($field->type == 'primaryemailaddress') {
                 if (isset($field->_imgMode)) {
                     $imgMode = (int) $field->get('_imgMode');
                     $useLayout = false;
                     // When using override we want to avoid layout usage
                 } else {
                     $imgMode = (int) $field->params->get($reason == 'list' ? 'displayModeList' : 'displayMode', 0);
                 }
                 if ($ueConfig['allow_email_display'] == 3 || $imgMode != 0) {
                     $oValueText = CBTxt::T('UE_SENDEMAIL', 'Send Email');
                 } else {
                     $oValueText = htmlspecialchars($value);
                 }
                 $emailIMG = '<span class="fa fa-envelope" title="' . htmlspecialchars(CBTxt::T('UE_SENDEMAIL', 'Send Email')) . '"></span>';
                 switch ($imgMode) {
                     case 1:
                         $useLayout = false;
                         // We don't want to use layout for icon only display as we use it externally
                         $linkItemImg = $emailIMG;
                         $linkItemSep = null;
                         $linkItemTxt = null;
                         break;
                     case 2:
                         $linkItemImg = $emailIMG;
                         $linkItemSep = ' ';
                         $linkItemTxt = $oValueText;
                         break;
                     case 0:
                     default:
                         $linkItemImg = null;
                         $linkItemSep = null;
                         $linkItemTxt = $oValueText;
                         break;
                 }
                 $oReturn = '';
                 //if no email or 4 (do not display email) then return empty string
                 if ($value == null || $ueConfig['allow_email_display'] == 4 || $imgMode != 0 && $ueConfig['allow_email_display'] == 1) {
                     // $oReturn				=	'';
                 } else {
                     switch ($ueConfig['allow_email_display']) {
                         case 1:
                             //display email only
                             $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 0);
                             break;
                         case 2:
                             //mailTo link
                             // cloacking doesn't cloack the text of the hyperlink, if that text does contain email addresses		//TODO: fix it.
                             if (!$linkItemImg && $linkItemTxt == htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, '', 0);
                             } elseif ($linkItemImg && $linkItemTxt != htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, $linkItemImg . $linkItemSep . $linkItemTxt, 0);
                             } elseif ($linkItemImg && $linkItemTxt == htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, $linkItemImg, 0) . $linkItemSep;
                                 $oReturn .= moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, '', 0);
                             } elseif (!$linkItemImg && $linkItemTxt != htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, $linkItemTxt, 0);
                             }
                             break;
                         case 3:
                             //email Form (with cloacked email address if visible)
                             $oReturn = "<a href=\"" . cbSef("index.php?option=com_comprofiler&amp;view=emailuser&amp;uid=" . $user->id . getCBprofileItemid(true)) . "\" title=\"" . CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user') . "\">" . $linkItemImg . $linkItemSep;
                             if ($linkItemTxt && $linkItemTxt != CBTxt::T('UE_SENDEMAIL', 'Send Email')) {
                                 $oReturn .= moscomprofilerHTML::emailCloaking($linkItemTxt, 0);
                             } else {
                                 $oReturn .= $linkItemTxt;
                             }
                             $oReturn .= "</a>";
                             break;
                     }
                 }
             } else {
                 // emailaddress:
                 if ($value == null) {
                     $oReturn = '';
                 } else {
                     if ($ueConfig['allow_email'] == 1) {
                         $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, "", 0);
                     } else {
                         $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 0);
                     }
                 }
             }
             if ($useLayout) {
                 $oReturn = $this->formatFieldValueLayout($oReturn, $reason, $field, $user);
             }
             break;
         case 'htmledit':
             $oReturn = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $value, $reason != 'search' ? $this->getDataAttributes($field, $user, $output, $reason) : null);
             if ($reason == 'search') {
                 $oReturn = $this->_fieldSearchModeHtml($field, $user, $oReturn, 'text', $list_compare_types);
             }
             break;
         case 'json':
         case 'php':
         case 'xml':
         case 'csvheader':
         case 'fieldslist':
         case 'csv':
         default:
             $oReturn = parent::getField($field, $user, $output, $reason, $list_compare_types);
             break;
     }
     return $oReturn;
 }
 /**
  * Returns a field in specified format
  *
  * @param  moscomprofilerFields  $field
  * @param  moscomprofilerUser    $user
  * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @return mixed                
  */
 function getField(&$field, &$user, $output, $reason, $list_compare_types)
 {
     global $_CB_framework, $ueConfig;
     $value = $user->get($field->name);
     switch ($output) {
         case 'html':
         case 'rss':
             if ($field->type == 'primaryemailaddress') {
                 $imgMode = 0;
                 if ($ueConfig['allow_email_display'] == 3 || $imgMode != 0) {
                     $oValueText = _UE_SENDEMAIL;
                 } else {
                     $oValueText = htmlspecialchars($value);
                 }
                 $emailIMG = '<img src="' . $_CB_framework->getCfg('live_site') . '/components/com_comprofiler/images/email.gif" border="0" alt="' . _UE_SENDEMAIL . '" title="' . _UE_SENDEMAIL . '" />';
                 switch ($imgMode) {
                     case 0:
                         $linkItemImg = null;
                         $linkItemSep = null;
                         $linkItemTxt = $oValueText;
                         break;
                     case 1:
                         $linkItemImg = $emailIMG;
                         $linkItemSep = null;
                         $linkItemTxt = null;
                         break;
                     case 2:
                         $linkItemImg = $emailIMG;
                         $linkItemSep = ' ';
                         $linkItemTxt = $oValueText;
                         break;
                 }
                 $oReturn = '';
                 //if no email or 4 (do not display email) then return empty string
                 if ($value == null || $ueConfig['allow_email_display'] == 4 || $imgMode != 0 && $ueConfig['allow_email_display'] == 1) {
                     // $oReturn				=	'';
                 } else {
                     switch ($ueConfig['allow_email_display']) {
                         case 1:
                             //display email only
                             $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 0);
                             break;
                         case 2:
                             //mailTo link
                             // cloacking doesn't cloack the text of the hyperlink, if that text does contain email addresses		//TODO: fix it.
                             if (!$linkItemImg && $linkItemTxt == htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, '', 0);
                             } elseif ($linkItemImg && $linkItemTxt != htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, $linkItemImg . $linkItemSep . $linkItemTxt, 0);
                             } elseif ($linkItemImg && $linkItemTxt == htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, $linkItemImg, 0) . $linkItemSep;
                                 $oReturn .= moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, '', 0);
                             } elseif (!$linkItemImg && $linkItemTxt != htmlspecialchars($value)) {
                                 $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, $linkItemTxt, 0);
                             }
                             break;
                         case 3:
                             //email Form (with cloacked email address if visible)
                             $oReturn = "<a href=\"" . cbSef("index.php?option=com_comprofiler&amp;task=emailUser&amp;uid=" . $user->id . getCBprofileItemid(true)) . "\" title=\"" . _UE_MENU_SENDUSEREMAIL_DESC . "\">" . $linkItemImg . $linkItemSep;
                             if ($linkItemTxt && $linkItemTxt != _UE_SENDEMAIL) {
                                 $oReturn .= moscomprofilerHTML::emailCloaking($linkItemTxt, 0);
                             } else {
                                 $oReturn .= $linkItemTxt;
                             }
                             $oReturn .= "</a>";
                             break;
                     }
                 }
             } else {
                 // emailaddress:
                 if ($value == null) {
                     $oReturn = '';
                 } else {
                     if ($ueConfig['allow_email'] == 1) {
                         $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 1, "", 0);
                     } else {
                         $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($value), 0);
                     }
                 }
             }
             break;
         case 'htmledit':
             $ajaxCheck = ($field->type == 'primaryemailaddress' && (isset($ueConfig['reg_email_checker']) && $ueConfig['reg_email_checker'] > 0) || $field->params->get('field_check_email', 0) || $_CB_framework->getUi() == 2) && $reason != 'search';
             if (defined('_CB_VALIDATE_NEW')) {
                 if ($ajaxCheck && $reason != 'search') {
                     $oReturn = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $value, '', null, true, array('email', $this->ajaxCheckField($field, $user, $reason, array('email:true'))));
                     // $this->ajaxCheckField( $field, $user, $reason );
                 } else {
                     $oReturn = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $value, '', null, true, $reason != 'search' ? array('email') : array());
                     if ($reason == 'search') {
                         $oReturn = $this->_fieldSearchModeHtml($field, $user, $oReturn, 'text', $list_compare_types);
                     }
                 }
             } else {
                 $oReturn = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $value, '', null, true, $reason != 'search' ? array('email') : array());
                 if ($reason == 'search') {
                     $oReturn = $this->_fieldSearchModeHtml($field, $user, $oReturn, 'text', $list_compare_types);
                 } elseif ($ajaxCheck) {
                     $this->ajaxCheckField($field, $user, $reason);
                 }
             }
             break;
         case 'json':
         case 'php':
         case 'xml':
         case 'csvheader':
         case 'fieldslist':
         case 'csv':
         default:
             $oReturn = parent::getField($field, $user, $output, $reason, $list_compare_types);
             break;
     }
     return $oReturn;
 }