private function canAjax( &$field, &$user, $output, $reason, $ignoreEmpty = false )
	{
		global $_CB_framework, $ueConfig;

		if ( ( $_CB_framework->getUi() == 1 ) && ( $output == 'html' ) && ( $reason == 'profile' ) && ( $field instanceof FieldTable ) && ( $user instanceof UserTable ) ) {
			if ( ! ( $field->params instanceof ParamsInterface ) ) {
				$params			=	new Registry( $field->params );
			} else {
				$params			=	$field->params;
			}

			$value				=	$user->get( $field->get( 'name' ) );
			$notEmpty			=	( ( ! ( ( $value === null ) || ( $value === '' ) ) ) || $ueConfig['showEmptyFields'] || cbReplaceVars( CBTxt::T( $field->params->get( 'ajax_placeholder' ) ), $user ) );
			$readOnly			=	$field->get( 'readonly' );

			if ( $field->get( 'name' ) == 'username' ) {
				if ( ! $ueConfig['usernameedit'] ) {
					$readOnly	=	true;
				}
			}

			if ( ( ! $field->get( '_noAjax', false ) ) && ( ! $readOnly ) && ( $notEmpty || $ignoreEmpty )
				 && $params->get( 'ajax_profile', 0 ) && Application::MyUser()->canViewAccessLevel( (int) $params->get( 'ajax_profile_access', 2 ) )
				 && ( ! cbCheckIfUserCanPerformUserTask( $user->get( 'id' ), 'allowModeratorsUserEdit' ) )
			) {
				return true;
			}
		}

		return false;
	}
Esempio n. 2
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);
             }
         }
     }
 }
Esempio n. 3
0
function tabClass( $option, $task, $uid ) {
	global $_CB_framework, $_PLUGINS, $ueConfig, $_REQUEST, $_POST;

	$user					=&	loadComprofilerUser( $uid );
	$cbUser					=&	CBuser::getInstance( ( $user === null ? null : $user->id ) );

	$unsecureChars			=	array( '/', '\\', ':', ';', '{', '}', '(', ')', "\"", "'", '.', ',', "\0", ' ', "\t", "\n", "\r", "\x0B" );
	if ( $task == 'fieldclass' ) {
		$reason				=	cbGetParam( $_REQUEST, 'reason' );
		if ( $user && $user->id ) {
			if ( $reason === 'edit' ) {
				$msg		=	cbCheckIfUserCanPerformUserTask( $user->id, 'allowModeratorsUserEdit' );
				if ( ( $uid != $_CB_framework->myId() ) && ( $msg === null ) ) {
					// safeguard against missconfiguration of the above: also avoids lower-level users editing higher level ones:
					$msg	=	checkCBpermissions( array( (int) $user->id ), 'edit', true );
				}
			} elseif ( ( $reason === 'profile' ) || ( $reason === 'list' ) ) {
				if ( allowAccess( $ueConfig['allow_profileviewbyGID'], 'RECURSE', userGID( $_CB_framework->myId() ) ) ) {
					$msg	=	null;
				} else {
					$msg	=	_UE_NOT_AUTHORIZED;
				}
			} else {
				$msg		=	_UE_NO_INDICATION;
			}

			if ( $msg ) {
				echo $msg;
				return;
			}
		} elseif ( $reason == 'register' ) {
			if ( $_CB_framework->myId() != 0 ) {
				echo _UE_ALREADY_LOGGED_IN;
				return;
			}
		} else {
/*
		if (	( ! ( ( ( $_CB_framework->getCfg( 'allowUserRegistration' ) == '0' )
		   				    && ( ( ! isset($ueConfig['reg_admin_allowcbregistration']) ) || $ueConfig['reg_admin_allowcbregistration'] != '1' ) )
						)
					)
					&&
					allowAccess( $ueConfig['allow_profileviewbyGID'], 'RECURSE', $_CB_framework->acl->get_group_id('Registered','ARO') )
			) {
				$msg		=	_UE_REGISTERFORPROFILEVIEW;
				echo $msg;
				return;
			} else {
				$msg		=	_UE_NOT_AUTHORIZED;
				echo $msg;
				return;
			}
*/
			$msg			=	_UE_NOT_AUTHORIZED;
			echo $msg;
			return;
		}

		$fieldName			=	trim( substr( str_replace( $unsecureChars, '', urldecode( stripslashes( cbGetParam( $_REQUEST, "field" ) ) ) ), 0, 50 ) );
		if ( ! $fieldName ) {
			echo 'no field';
			return;
		}
	} elseif ( $task == 'tabclass' ) {
		$tabClassName		=	urldecode( stripslashes( cbGetParam( $_REQUEST, "tab" ) ) );
		if ( ! $tabClassName ) {
			return;
		}
		$pluginName			=	null;
		$tabClassName		=	substr( str_replace( $unsecureChars, '', $tabClassName ), 0, 32 );
		$method				=	'getTabComponent';
	} elseif ( $task == 'pluginclass' ) {
		$pluginName			=	urldecode( stripslashes( cbGetParam( $_REQUEST, "plugin" ) ) );
		if ( ! $pluginName ) {
			return;
		}
		$tabClassName		=	'CBplug_' . strtolower( substr( str_replace( $unsecureChars, '', $pluginName ), 0, 32 ) );
		$method				=	'getCBpluginComponent';
	}
	$tabs					=	$cbUser->_getCbTabs( false );
	if ( $task == 'fieldclass' ) {
		$result			=	$tabs->fieldCall( $fieldName, $user, $_POST, $reason );
	} else {
		$result				=	$tabs->tabClassPluginTabs( $user, $_POST, $pluginName, $tabClassName, $method );
	}
	if ( $result === false ) {
	 	if( $_PLUGINS->is_errors() ) {
			echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); </script>\n";
	 	}
	} elseif ( $result !== null ) {
		echo $result;
	}
}
Esempio n. 4
0
	/**
	* Generates the menu and user status to display on the user profile by calling back $this->addMenu
	* @param  moscomprofilerTab   $tab       the tab database entry
	* @param  moscomprofilerUser  $user      the user being displayed
	* @param  int                 $ui        1 for front-end, 2 for back-end
	* @return boolean                        either true, or false if ErrorMSG generated
	*/
	function getMenuAndStatus( $tab, $user, $ui ) {
		global $_CB_framework, $_CB_database, $ueConfig,$_REQUEST,$_POST;

		$params				=	$this->params;

		$Itemid				=	getCBprofileItemid( 0 );

		// Build basic menu:
		$ue_base_url		 = "index.php?option=com_comprofiler";
		if ( $Itemid ) {
			$ue_base_url	.= "&amp;Itemid=" . $Itemid;	// Base URL string
		}
		$ue_credits_url		 = $ue_base_url."&amp;task=teamCredits";
		$ue_userdetails_url	 = $ue_base_url."&amp;task=userDetails" . $this->_addUid( $user );
		$ue_useravatar_url	 = $ue_base_url."&amp;task=userAvatar" . $this->_addUid( $user );
		$ue_deleteavatar_url = $ue_base_url."&amp;task=userAvatar&amp;do=deleteavatar" . $this->_addUid( $user );
		$ue_unbanrequest_url = $ue_base_url."&amp;task=banProfile&amp;act=2&amp;reportform=1&amp;uid=".$user->id;
		$ue_banhistory_url   = $ue_base_url."&amp;task=moderateBans&amp;act=2&amp;uid=".$user->id;
		$ue_ban_url 		 = $ue_base_url."&amp;task=banProfile&amp;act=1&amp;uid=".$user->id;
		$ue_unban_url 		 = $ue_base_url."&amp;task=banProfile&amp;act=0&amp;reportform=0&amp;uid=".$user->id;
		$ue_reportuser_url	 = $ue_base_url."&amp;task=reportUser&amp;uid=".$user->id;
		$ue_viewuserreports_url = $ue_base_url."&amp;task=viewReports&amp;uid=".$user->id;
		$ue_viewOlduserreports_url = $ue_base_url."&amp;task=viewReports&amp;act=1&amp;uid=".$user->id;
		$ue_approve_image_url= $ue_base_url."&amp;task=approveImage&amp;flag=1&amp;avatars=".$user->id;
		$ue_reject_image_url = $ue_base_url."&amp;task=approveImage&amp;flag=0&amp;avatars=".$user->id;
		$ue_userprofile_url	 = $ue_base_url."";
		$adminimagesdir		=	$_CB_framework->getCfg( 'live_site' ) . '/components/com_comprofiler/images/';

		// $this->menuBar->set("class", "mainlevel");		//BB: hardcoded to check >RC2.

		$firstMenuName		= $params->get('firstMenuName', '_UE_MENU_CB');
		$firstSubMenuName	= $params->get('firstSubMenuName', '_UE_MENU_ABOUT_CB');
		$firstSubMenuHref	= $params->get('firstSubMenuHref', $ue_credits_url);
		$secondSubMenuName	= $params->get('secondSubMenuName', '');
		$secondSubMenuHref	= $params->get('secondSubMenuHref', '');
		if ($firstMenuName != "") {
			$mi = array(); $mi[$firstMenuName]='';
		//	$this->_addMenuItem( $mi,$firstMenuName,"javascript:void(0)" );		// Community
			if ($firstSubMenuName != "") {
				unset($mi);
				if ($firstSubMenuHref == "") $firstSubMenuHref = "javascript:void(0)";
				$mi = array(); $mi[$firstMenuName]["_UE_TEAMCREDITS_CB"]='';
				$this->_addMenuItem( $mi,getLangDefinition($firstSubMenuName),cbSef($firstSubMenuHref) );		// About...
				if ($secondSubMenuName != "") {
					if ($secondSubMenuHref == "") $secondSubMenuHref = "javascript:void(0)";
					$mi = array(); $mi[$firstMenuName]["_UE_SECOND"]='';
					$this->_addMenuItem( $mi,getLangDefinition($secondSubMenuName),cbSef($secondSubMenuHref) );		// Free...
				}
			}
		}
		// ----- VIEW MENU - BEFORE EDIT MENU IF NOT VIEWING A PROFILE -----
		if ( $_CB_framework->myId() > 0 ) {
			// View My Profile:
			if ( $_CB_framework->displayedUser() === null ) {
				$mi = array(); $mi["_UE_MENU_VIEW"]["_UE_MENU_VIEWMYPROFILE"]=null;
				$this->_addMenuItem( $mi, _UE_MENU_VIEWMYPROFILE,cbSef($ue_userprofile_url), "",
				"","", _UE_MENU_VIEWMYPROFILE_DESC,"" );
			}
		}
		// ----- EDIT MENU -----
		if ( ! cbCheckIfUserCanPerformUserTask( $user->id, 'allowModeratorsUserEdit') ) {
			if ( $user->id == $_CB_framework->myId() ) {
				$menuTexts	=	array(	'_UE_UPDATEPROFILE'				=>	_UE_UPDATEPROFILE,
										'_UE_MENU_UPDATEPROFILE_DESC'	=>	_UE_MENU_UPDATEPROFILE_DESC,
										'_UE_UPDATEAVATAR'				=>	_UE_UPDATEAVATAR,
										'_UE_MENU_UPDATEAVATAR_DESC'	=>	_UE_MENU_UPDATEAVATAR_DESC,
										'_UE_DELETE_AVATAR'				=>	_UE_DELETE_AVATAR,
										'_UE_MENU_DELETE_AVATAR_DESC'	=>	_UE_MENU_DELETE_AVATAR_DESC
									);
			} else {
				$menuTexts	=	array(	'_UE_UPDATEPROFILE'				=>	_UE_MOD_MENU_UPDATEPROFILE,
										'_UE_MENU_UPDATEPROFILE_DESC'	=>	_UE_MOD_MENU_UPDATEPROFILE_DESC,
										'_UE_UPDATEAVATAR'				=>	_UE_MOD_MENU_UPDATEAVATAR,
										'_UE_MENU_UPDATEAVATAR_DESC'	=>	_UE_MOD_MENU_UPDATEAVATAR_DESC,
										'_UE_DELETE_AVATAR'				=>	_UE_MOD_MENU_DELETE_AVATAR,
										'_UE_MENU_DELETE_AVATAR_DESC'	=>	_UE_MOD_MENU_DELETE_AVATAR_DESC
									);
			}
			// Update Profile:
			$mi = array(); $mi["_UE_MENU_EDIT"]["_UE_UPDATEPROFILE"]=null;
			$this->_addMenuItem( $mi, $menuTexts['_UE_UPDATEPROFILE'],cbSef($ue_userdetails_url), "",
			"<img src=\"".$adminimagesdir."updateprofile.gif\" alt='' />","", $menuTexts['_UE_MENU_UPDATEPROFILE_DESC'],"" );
			// Update Avatar:
			if($ueConfig['allowAvatar']==1 && ($ueConfig['allowAvatarUpload']==1 || $ueConfig['allowAvatarGallery']==1)) {
				$mi = array(); $mi["_UE_MENU_EDIT"]["_UE_UPDATEAVATAR"]=null;
				$this->_addMenuItem( $mi, $menuTexts['_UE_UPDATEAVATAR'],cbSef($ue_useravatar_url), "",
				"<img src=\"".$adminimagesdir."newavatar.gif\" alt='' />","", $menuTexts['_UE_MENU_UPDATEAVATAR_DESC'],"" );
				// Delete Avatar:
				if($user->avatar!='' && $user->avatar!=null) {
					$mi = array(); $mi["_UE_MENU_EDIT"]["_UE_DELETE_AVATAR"]=null;
					$this->_addMenuItem( $mi, $menuTexts['_UE_DELETE_AVATAR'],cbSef($ue_deleteavatar_url), "",
					"<img src=\"".$adminimagesdir."delavatar.gif\" alt='' />","", $menuTexts['_UE_MENU_DELETE_AVATAR_DESC'],"" );
				}
			}
		}
		// ----- VIEW MENU - AFTER EDIT IF VIEWING A PROFILE -----
		if ( $_CB_framework->myId() > 0 ) {
			// View My Profile:
			if ( ( $_CB_framework->myId() != $user->id ) && ( $_CB_framework->displayedUser() !== null ) ) {
				$mi = array(); $mi["_UE_MENU_VIEW"]["_UE_MENU_VIEWMYPROFILE"]=null;
				$this->_addMenuItem( $mi, _UE_MENU_VIEWMYPROFILE,cbSef($ue_userprofile_url), "",
				"","", _UE_MENU_VIEWMYPROFILE_DESC,"" );
			}
		}
		// ----- MESSAGES MENU -----
		// Send PMS
		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)) {
						$mi = array(); $mi["_UE_MENU_MESSAGES"][$res["caption"]]=null;
						$this->_addMenuItem( $mi, getLangDefinition($res["caption"]),cbSef($res["url"]), "",
						"","", getLangDefinition($res["tooltip"]),"" );
				 	}
				}
			}
		}

		// Send Email
		$emailHtml=getFieldValue('primaryemailaddress',$user->email,$user);
		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 = $emailHtml;
					$url = "javascript:void(0);";
					$desc = _UE_MENU_USEREMAIL_DESC;
					break;
				case 2:	// Display Email with link:
					$caption = null;
					$url = $emailHtml;
					$desc = _UE_MENU_SENDUSEREMAIL_DESC;
					break;
				case 3:	// Display Email-to text with link to web-form:
					$caption = _UE_MENU_SENDUSEREMAIL;
					$url = $emailHtml;
					$desc = _UE_MENU_SENDUSEREMAIL_DESC;
					break;
			}
			$mi = array(); $mi["_UE_MENU_MESSAGES"]["_UE_MENU_SENDUSEREMAIL"]=null;
			$this->_addMenuItem( $mi, $caption, $url, "", "", "", $desc, "" );
		}
		// ----- CONNECTIONS MENU -----
		IF ($ueConfig['allowConnections'] && $_CB_framework->myId() > 0) {
			$ue_addConnection_url = $ue_base_url."&amp;act=connections&amp;task=addConnection&amp;connectionid=".$user->id;
			$ue_removeConnection_url = $ue_base_url."&amp;act=connections&amp;task=removeConnection&amp;connectionid=".$user->id;
			$ue_manageConnection_url = $ue_base_url."&amp;task=manageConnections";
			
			// Manage My Connections
			$mi = array(); $mi["_UE_MENU_CONNECTIONS"]["_UE_MENU_MANAGEMYCONNECTIONS"]=null;
			$this->_addMenuItem( $mi, _UE_MENU_MANAGEMYCONNECTIONS,cbSef($ue_manageConnection_url), "",
			"","", _UE_MENU_MANAGEMYCONNECTIONS_DESC,"" );
			
			if ( $_CB_framework->myId() != $user->id ) {
				$_CB_database->setQuery("SELECT COUNT(*) FROM #__comprofiler_members WHERE referenceid=" . (int) $_CB_framework->myId() . " AND memberid=" . (int) $user->id);
				$isConnection = $_CB_database->loadResult();
				if ($isConnection) {
					$_CB_database->setQuery("SELECT COUNT(*) FROM #__comprofiler_members WHERE referenceid=" . (int) $_CB_framework->myId() . " AND memberid=" . (int) $user->id." AND pending=0");
					$isApproved = $_CB_database->loadResult();
					$_CB_database->setQuery("SELECT COUNT(*) FROM #__comprofiler_members WHERE referenceid=" . (int) $_CB_framework->myId() . " AND memberid=" . (int) $user->id." AND accepted=1");
					$isAccepted = $_CB_database->loadResult();
				}
				if($isConnection==0) {
					$connectionurl=cbSef($ue_addConnection_url);
					if ( $ueConfig['useMutualConnections'] == 1 ) {
						$fmsg	  = "_UE_ADDCONNECTIONREQUEST";
						$fmsgdesc = _UE_ADDCONNECTIONREQUEST_DESC;
					} else {
						$fmsg	  = "_UE_ADDCONNECTION";
						$fmsgdesc = _UE_ADDCONNECTION_DESC;
					}
					if($ueConfig['conNotifyType']!=0) {
						$connectionurl="javascript:void(0)\" onclick=\"return overlib('"
						. str_replace(array("<",">"), array("&lt;","&gt;"),
						_UE_CONNECTIONINVITATIONMSG."<br /><form action=&quot;".$connectionurl
						."&quot; method=&quot;post&quot; id=&quot;connOverForm&quot; name=&quot;connOverForm&quot;>"._UE_MESSAGE
						."<br /><textarea cols=&quot;40&quot; rows=&quot;8&quot; name=&quot;message&quot;></textarea><br />"
						. "<input type=&quot;button&quot; class=&quot;inputbox&quot; onclick=&quot;cbConnSubmReq();&quot; value=&quot;"
						._UE_SENDCONNECTIONREQUEST."&quot; />&nbsp;&nbsp;"
						."<input type=&quot;button&quot; class=&quot;inputbox&quot; onclick=&quot;cClick();&quot;  value=&quot;"
						._UE_CANCELCONNECTIONREQUEST."&quot; /></form>")
						."', STICKY, CAPTION,'"
						.sprintf(_UE_CONNECTTO,htmlspecialchars(str_replace("'","&#039;",getNameFormat($user->name,$user->username,$ueConfig['name_format'])),ENT_QUOTES))
						."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'cbAddConn',CENTERPOPUP,'LR','UR');";
						// $flink="<a href=\"".$connectionurl."\" id=\"cbAddConn\" name=\"cbAddConn\" title=\"".$fmsgdesc."\">".getLangDefinition($fmsg)."</a>";
						$flink = $connectionurl."\" name=\"cbAddConn";	//BBTRYREMOVED: "\" title=\"".$fmsgdesc."\">".getLangDefinition($fmsg)."</a>";
					} else {
						$flink=$connectionurl;
					}
				} else {
					if ($isAccepted) {
						$connectionurl=cbSef($ue_removeConnection_url);
						if ($isApproved) {
							$fmsg = "_UE_REMOVECONNECTION";
							$fmsgdesc=_UE_REMOVECONNECTION_DESC;
						} else {
							$fmsg = "_UE_REVOKECONNECTIONREQUEST";
							$fmsgdesc=_UE_REVOKECONNECTIONREQUEST_DESC;
						}
						// $flink="<a href=\"".$connectionurl."\" onclick=\"return confirmSubmit();\" title=\"".$fmsgdesc."\">".getLangDefinition($fmsg)."</a>";
						$flink = $connectionurl."\" onclick=\"return confirmSubmit();"; //BBTRYREMOVED: \" title=\"".$fmsgdesc."\">".getLangDefinition($fmsg)."</a>";
					} else {
						/*
						$connectionurl=cbSef($ue_manageConnection_url);
						$fmsg = "_UE_MANAGECONNECTIONS";				//BB this is wrong here, unless non-accepted connections are also displayed there
						$fmsgdesc=_UE_MENU_MANAGEMYCONNECTIONS_DESC;
						$flink=$connectionurl;
						*/
						$fmsg = null;		// manage connections is already above, no need to repeat here !
					}
				}
				// Request/Add/Remove/Revoke Connection
				if ( $fmsg ) {
					$mi = array(); $mi["_UE_MENU_CONNECTIONS"][$fmsg]=null;
					$this->_addMenuItem( $mi, getLangDefinition($fmsg), $flink /*$connectionurl*/, "",
					"","", $fmsgdesc,"" );
				}
			}

		}
		// ----- MODERATE MENU -----
		if ( $_CB_framework->myId() == $user->id ) {
			// Request to unban:
			if($user->banned==1 && $this->cbUserIsModerator==0 && $ueConfig['allowUserBanning']==1) {
				$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_REQUESTUNBANPROFILE"]=null;
				$this->_addMenuItem( $mi, _UE_REQUESTUNBANPROFILE,cbSef($ue_unbanrequest_url), "",
				"","", _UE_MENU_REQUESTUNBANPROFILE_DESC,"" );
			}
		} else {
			// Report User:
			if($ueConfig['allowUserReports']==1 && $this->cbUserIsModerator==0 && $_CB_framework->myId() > 0) {
				$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_REPORTUSER"]=null;
				$this->_addMenuItem( $mi, _UE_REPORTUSER,cbSef($ue_reportuser_url), "",
				"","", _UE_MENU_REPORTUSER_DESC,"" );
			}
			// Approve/Reject Avatar & Ban/Unban profile & View User Reports:
			if($this->cbMyIsModerator==1 && $this->cbUserIsModerator==0) {

				$query = "SELECT COUNT(*) FROM #__comprofiler_userreports  WHERE reportedstatus=0 AND reporteduser="******"SELECT COUNT(*) FROM #__comprofiler_userreports  WHERE reporteduser="******"_UE_MENU_MODERATE"]["_UE_APPROVE_IMAGE"]=null;
						$this->_addMenuItem( $mi, _UE_APPROVE_IMAGE,cbSef($ue_approve_image_url), "",
						"","", _UE_MENU_APPROVE_IMAGE_DESC,"" );
					}
					// Reject Image
					$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_REJECT_IMAGE"]=null;
					$this->_addMenuItem( $mi, _UE_REJECT_IMAGE,cbSef($ue_reject_image_url), "",
					"","", _UE_MENU_REJECT_IMAGE_DESC,"" );
				}
				if($ueConfig['allowUserBanning']==1) {
					if($user->banned!=0 ) {
						// unban profile
						$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_UNBANPROFILE"]=null;
						$this->_addMenuItem( $mi, _UE_UNBANPROFILE,cbSef($ue_unban_url), "",
						"","", _UE_MENU_UNBANPROFILE_DESC,"" );
					} else {
						// ban profile
						$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_BANPROFILE"]=null;
						$this->_addMenuItem( $mi, _UE_BANPROFILE,cbSef($ue_ban_url), "",
						"","", _UE_MENU_BANPROFILE_DESC,"" );
					}
					if( $user->bannedby ) {
						// ban history
						$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_MENU_BANPROFILE_HISTORY"]=null;
						$this->_addMenuItem( $mi, _UE_MENU_BANPROFILE_HISTORY,cbSef($ue_banhistory_url), "",
						"","", _UE_MENU_BANPROFILE_HISTORY_DESC,"" );
					}
				}
				if($ueConfig['allowUserReports']==1 && $userreports>0) {
					// view user reports
					$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_VIEWUSERREPORTS"]=null;
					$this->_addMenuItem( $mi, _UE_VIEWUSERREPORTS,cbSef($ue_viewuserreports_url), "",
					"","", _UE_MENU_VIEWUSERREPORTS_DESC,"" );
				} elseif($ueConfig['allowUserReports']==1 && $userreportsAllTimes>0) {
					// view user reports
					$mi = array(); $mi["_UE_MENU_MODERATE"]["_UE_VIEWUSERREPORTS"]=null;
					$this->_addMenuItem( $mi, _UE_MOD_MENU_VIEWOLDUSERREPORTS,cbSef($ue_viewOlduserreports_url), "",
					"","", _UE_MOD_MENU_VIEWOLDUSERREPORTS_DESC,"" );
				}
			}
		}
		// Test example:
		/*
		$mi = array(); $mi["_UE_MENU_CONNECTIONS"]["duplique"]=null;
		$this->addMenu( array(	"position"	=> "menuBar" ,		// "menuBar", "menuList"
									"arrayPos"	=> $mi ,
									"caption"	=> _UE_MENU_MANAGEMYCONNECTIONS ,
									"url"		=> cbSef($ue_manageConnection_url) ,		// can also be "<a ....>" or "javascript:void(0)" or ""
									"target"	=> "" ,	// e.g. "_blank"
									"img"		=> null ,	// e.g. "<img src='plugins/user/myplugin/images/icon.gif' width='16' height='16' alt='' />"
									"alt"		=> null ,	// e.g. "text"
									"tooltip"	=> _UE_MENU_MANAGEMYCONNECTIONS_DESC ,
									"keystroke"	=> null ) );	// e.g. "P"
		*/
	}
Esempio n. 5
0
function tabClass($option, $task, $uid)
{
    global $_CB_framework, $_PLUGINS, $_REQUEST, $_POST;
    $user =& loadComprofilerUser($uid);
    $cbUser =& CBuser::getInstance($user === null ? null : $user->id);
    $unsecureChars = array('/', '\\', ':', ';', '{', '}', '(', ')', "\"", "'", '.', ',', "", ' ', "\t", "\n", "\r", "\v");
    $appendClass = false;
    if ($task == 'fieldclass') {
        $reason = cbGetParam($_REQUEST, 'reason');
        if ($user && $user->id) {
            $_PLUGINS->loadPluginGroup('user');
            if ($reason === 'edit') {
                $msg = cbCheckIfUserCanPerformUserTask($user->id, 'allowModeratorsUserEdit');
                if ($uid != $_CB_framework->myId() && $msg === null) {
                    // safeguard against missconfiguration of the above: also avoids lower-level users editing higher level ones:
                    $msg = checkCBpermissions(array((int) $user->id), 'edit', true);
                }
                $_PLUGINS->trigger('onBeforeUserProfileEditRequest', array($user->id, &$msg, 1));
            } elseif ($reason === 'profile' || $reason === 'list') {
                if (CBuser::getMyInstance()->authoriseView('profile', $user->id)) {
                    $msg = null;
                } else {
                    $msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
                }
                $_PLUGINS->trigger('onBeforeUserProfileAccess', array($user->id, &$msg, 1));
            } else {
                $msg = CBTxt::Th('UE_NO_INDICATION', 'No indication');
            }
            if ($msg) {
                echo $msg;
                return;
            }
        } elseif ($reason == 'register') {
            if ($_CB_framework->myId() != 0) {
                echo CBTxt::Th('UE_ALREADY_LOGGED_IN', 'You are already logged in');
                return;
            }
        } else {
            $msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
            echo $msg;
            return;
        }
        $fieldName = trim(substr(str_replace($unsecureChars, '', urldecode(stripslashes(cbGetParam($_REQUEST, "field")))), 0, 50));
        if (!$fieldName) {
            echo 'no field';
            return;
        }
        $pluginName = null;
        $tabClassName = null;
        $method = null;
    } elseif ($task == 'tabclass') {
        $tabClassName = urldecode(stripslashes(cbGetParam($_REQUEST, "tab")));
        if (!$tabClassName) {
            return;
        }
        $pluginName = null;
        $tabClassName = substr(str_replace($unsecureChars, '', $tabClassName), 0, 32);
        $method = 'getTabComponent';
        $fieldName = null;
        $reason = null;
    } elseif ($task == 'pluginclass') {
        $pluginName = urldecode(stripslashes(cbGetParam($_REQUEST, "plugin")));
        if (!$pluginName) {
            return;
        }
        $tabClassName = 'CBplug_' . strtolower(substr(str_replace($unsecureChars, '', $pluginName), 0, 32));
        $method = 'getCBpluginComponent';
        $appendClass = cbGetParam($_REQUEST, 'format') != 'raw' && cbGetParam($_REQUEST, 'format') != 'rawraw' ? true : false;
        $fieldName = null;
        $reason = null;
    } else {
        throw new LogicException('Unexpected task for CB tabClass');
    }
    $tabs = $cbUser->_getCbTabs(false);
    if ($task == 'fieldclass') {
        ob_start();
        $results = $tabs->fieldCall($fieldName, $user, $_POST, $reason);
        $result = ob_get_contents() . $results;
        ob_end_clean();
    } else {
        ob_start();
        $results = $tabs->tabClassPluginTabs($user, $_POST, $pluginName, $tabClassName, $method);
        $result = ob_get_contents() . $results;
        ob_end_clean();
    }
    if ($result === false) {
        if ($_PLUGINS->is_errors()) {
            echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); </script>\n";
        }
    } elseif ($result !== null) {
        if ($appendClass) {
            $pageClass = $_CB_framework->getMenuPageClass();
            echo '<div class="cb_template cb_template_' . selectTemplate('dir') . ($pageClass ? ' ' . htmlspecialchars($pageClass) : null) . '">' . $result . '</div>';
            $_CB_framework->setMenuMeta();
        } else {
            echo $result;
        }
    }
}