/** * @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); } } } }
function _getUserNumberOfConnections($user) { global $_CB_framework; $cbCon = new cbConnection($_CB_framework->myId()); return $cbCon->getConnectionsCount($user->id); }
/** * save invite * * @param int $id * @param UserTable $user */ private function saveInviteEdit( $id, $user ) { global $_CB_framework, $_CB_database, $_PLUGINS; $row = new InviteTable(); $row->load( (int) $id ); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $groupId = $this->input( 'group', null, GetterInterface::INT ); if ( $groupId === null ) { $group = $row->group(); } else { $group = CBGroupJive::getGroup( $groupId ); } $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ); if ( ! CBGroupJive::canAccessGroup( $group, $user ) ) { cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' ); } elseif ( $row->get( 'id' ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this invite.' ), 'error' ); } elseif ( ! $isModerator ) { if ( ( $group->get( 'published' ) == -1 ) || ( ( ! $this->params->get( 'groups_invites_display', 1 ) ) && ( $group->get( 'type' ) != 3 ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have access to invites in this group.' ), 'error' ); } elseif ( ( ! $row->get( 'id' ) ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'invites' ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create an invite in this group.' ), 'error' ); } } $skipCaptcha = false; $row->set( 'message', $this->input( 'post/message', $row->get( 'message' ), GetterInterface::STRING ) ); if ( ! $row->get( 'id' ) ) { $row->set( 'user_id', (int) $row->get( 'user_id', $user->get( 'id' ) ) ); $row->set( 'group', (int) $group->get( 'id' ) ); $to = $this->input( 'post/to', null, GetterInterface::STRING ); $selected = (int) $this->input( 'post/selected', 0, GetterInterface::INT ); if ( $selected ) { $token = $this->input( 'post/token', null, GetterInterface::STRING ); if ( $token ) { if ( $token == md5( $row->get( 'user_id' ) . $to . $row->get( 'group' ) . $row->get( 'message' ) . $_CB_framework->getCfg( 'secret' ) ) ) { $skipCaptcha = true; $row->set( 'user', (int) $selected ); } } elseif ( $this->params->get( 'groups_invites_list', 0 ) ) { $connections = array(); $cbConnection = new cbConnection( (int) $user->get( 'id' ) ); foreach( $cbConnection->getConnectedToMe( (int) $user->get( 'id' ) ) as $connection ) { $connections[] = (int) $connection->id; } if ( in_array( $selected, $connections ) ) { $row->set( 'user', (int) $selected ); } } } else { $inviteByLimit = explode( '|*|', $this->params->get( 'groups_invites_by', '1|*|2|*|3|*|4' ) ); if ( ! $inviteByLimit ) { $inviteByLimit = array( 1, 2, 3, 4 ); } $recipient = new UserTable(); if ( in_array( 1, $inviteByLimit ) && $recipient->load( (int) $to ) ) { $row->set( 'user', (int) $recipient->get( 'id' ) ); } elseif ( in_array( 4, $inviteByLimit ) && cbIsValidEmail( $to ) ) { if ( $recipient->load( array( 'email' => $to ) ) ) { $row->set( 'user', (int) $recipient->get( 'id' ) ); } else { $row->set( 'email', $to ); } } elseif ( in_array( 2, $inviteByLimit ) && $recipient->load( array( 'username' => $to ) ) ) { $row->set( 'user', (int) $recipient->get( 'id' ) ); } elseif ( in_array( 3, $inviteByLimit ) ) { $query = 'SELECT cb.' . $_CB_database->NameQuote( 'id' ) . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j" . ' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' ) . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u" . ' ON u.' . $_CB_database->NameQuote( 'user_id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' ) . ' AND u.' . $_CB_database->NameQuote( 'group' ) . ' = ' . (int) $group->get( 'id' ) . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i" . ' ON i.' . $_CB_database->NameQuote( 'group' ) . ' = ' . (int) $group->get( 'id' ) . ' AND i.' . $_CB_database->NameQuote( 'user' ) . ' = cb.' . $_CB_database->NameQuote( 'id' ) . "\n WHERE j." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $to, true ) . '%', false ) . "\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1" . "\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1" . "\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0" . "\n AND u." . $_CB_database->NameQuote( 'id' ) . " IS NULL" . "\n AND i." . $_CB_database->NameQuote( 'id' ) . " IS NULL" . "\n ORDER BY j." . $_CB_database->NameQuote( 'registerDate' ) . " DESC"; $_CB_database->setQuery( $query, 0, 15 ); $users = $_CB_database->loadResultArray(); if ( $users ) { if ( count( $users ) > 1 ) { CBGroupJive::getTemplate( 'invite_list' ); CBuser::advanceNoticeOfUsersNeeded( $users ); HTML_groupjiveInviteList::showInviteList( $to, $users, $row, $group, $user, $this ); return; } else { $row->set( 'user', (int) $users[0] ); } } } } } if ( ( ! $isModerator ) && $this->params->get( 'groups_create_captcha', 0 ) && ( ! $skipCaptcha ) ) { $_PLUGINS->loadPluginGroup( 'user' ); $_PLUGINS->trigger( 'onCheckCaptchaHtmlElements', array() ); if ( $_PLUGINS->is_errors() ) { $row->setError( $_PLUGINS->getErrorMSG() ); } } $new = ( $row->get( 'id' ) ? false : true ); if ( $row->getError() || ( ! $row->check() ) ) { $_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_INVITE_FAILED_TO_SAVE', 'Invite failed to save! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); $this->showInviteEdit( $id, $user ); return; } if ( $row->getError() || ( ! $row->store() ) ) { $_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_INVITE_FAILED_TO_SAVE', 'Invite failed to save! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); $this->showInviteEdit( $id, $user ); return; } if ( $new ) { cbRedirect( $returnUrl, CBTxt::T( 'Invite created successfully!' ) ); } else { cbRedirect( $returnUrl, CBTxt::T( 'Invite saved successfully!' ) ); } }
function processConnectionActions($connectionids) { global $_CB_framework, $ueConfig, $_POST; // simple spoof check security cbSpoofCheck( 'manageConnections' ); if(!$ueConfig['allowConnections']) { echo _UE_FUNCTIONALITY_DISABLED; return; } if ( ! ( $_CB_framework->myId() > 0 ) ) { cbNotAuth(); return; } $cbCon = new cbConnection( $_CB_framework->myId() ); if (is_array($connectionids)) { foreach($connectionids AS $cid) { $action = cbGetParam( $_POST, $cid . 'action' ); if ( $action== 'd' ) { $cbCon->denyConnection( $_CB_framework->myId(), $cid ); } elseif ( $action == 'a' ) { $cbCon->acceptConnection( $_CB_framework->myId(), $cid ); } } } $error = $cbCon->getErrorMSG(); if ( $error ) { cbRedirect( cbSef( 'index.php?option=com_comprofiler&task=manageConnections' . getCBprofileItemid(), false ), $error, 'error' ); } else { cbRedirect( cbSef( 'index.php?option=com_comprofiler&task=manageConnections' . getCBprofileItemid(), false ), ( is_array($connectionids) ) ? _UE_CONNECTIONACTIONSSUCCESSFULL : null ); } return; }
/** * Checks if user has increment access to this field * * @param FieldTable $field * @param UserTable $user * @return boolean */ private function getIncrementAccess(&$field, &$user) { global $_CB_framework, $_CB_database; static $cache = array(); $myId = (int) $_CB_framework->myId(); $userId = (int) $user->get('id'); $fieldId = (int) $field->get('fieldid'); $ipAddresses = cbGetIParray(); $ipAddress = trim(array_shift($ipAddresses)); $incrementDelay = $field->params->get('points_inc_delay', null); $customDelay = $field->params->get('points_inc_delay_custom', null); $cacheId = $myId . $userId . $fieldId; if (!isset($cache[$cacheId])) { $ratingAccess = (int) $field->params->get('points_access', 1); $excludeSelf = (int) $field->params->get('points_access_exclude', 0); $includeSelf = (int) $field->params->get('points_access_include', 0); $viewAccessLevel = (int) $field->params->get('points_access_custom', 1); $access = false; switch ($ratingAccess) { case 8: if (Application::MyUser()->canViewAccessLevel($viewAccessLevel) && ($userId == $myId && !$excludeSelf || $userId != $myId)) { $access = true; } break; case 7: if (Application::MyUser()->isModeratorFor(Application::User((int) $userId)) && ($userId == $myId && !$excludeSelf || $userId != $myId)) { $access = true; } break; case 6: if ($userId != $myId) { $cbConnection = new cbConnection($userId); if ($cbConnection->getConnectionDetails($userId, $myId) !== false) { $access = true; } } else { if ($userId == $myId && $includeSelf) { $access = true; } } break; case 5: if ($myId == 0 && $userId != $myId || $userId == $myId && $includeSelf) { $access = true; } break; case 4: if ($myId > 0 && ($userId == $myId && !$excludeSelf || $userId != $myId)) { $access = true; } break; case 3: if ($userId != $myId) { $access = true; } break; case 2: if ($userId == $myId) { $access = true; } break; case 1: default: if ($userId == $myId && !$excludeSelf || $userId != $myId) { $access = true; } break; } $cache[$cacheId] = $access; } $canAccess = $cache[$cacheId]; if ($canAccess && $incrementDelay) { $query = 'SELECT ' . $_CB_database->NameQuote('date') . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_ratings') . "\n WHERE " . $_CB_database->NameQuote('type') . " = " . $_CB_database->Quote('field') . "\n AND " . $_CB_database->NameQuote('item') . " = " . $fieldId . "\n AND " . $_CB_database->NameQuote('target') . " = " . $userId . "\n AND " . $_CB_database->NameQuote('user_id') . " = " . $myId; if ($myId == 0) { $query .= "\n AND " . $_CB_database->NameQuote('ip_address') . " = " . $_CB_database->Quote($ipAddress); } $query .= "\n ORDER BY " . $_CB_database->NameQuote('date') . " DESC"; $_CB_database->setQuery($query, 0, 1); $incrementDate = $_CB_database->loadResult(); if ($incrementDate) { if ($incrementDelay == 'FOREVER') { $canAccess = false; } elseif ($incrementDelay == 'CUSTOM') { if ($customDelay && $_CB_framework->getUTCTimestamp(strtoupper($customDelay), $_CB_framework->getUTCTimestamp($incrementDate)) >= $_CB_framework->getUTCNow()) { $canAccess = false; } } elseif ($_CB_framework->getUTCTimestamp($incrementDelay, $_CB_framework->getUTCTimestamp($incrementDate)) >= $_CB_framework->getUTCNow()) { $canAccess = false; } } } return $canAccess; }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user */ public function execute( $trigger, $user ) { global $ueConfig; if ( ! $user->get( 'id' ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_CONNECTION_NO_USER', ':: Action [action] :: Connection skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return; } foreach ( $trigger->getParams()->subTree( 'connection' ) as $row ) { /** @var ParamsInterface $row */ $users = $trigger->getSubstituteString( $row->get( 'users', null, GetterInterface::STRING ) ); if ( $users ) { $users = explode( ',', $users ); cbArrayToInts( $users ); $message = $trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false ); $mutual = $row->get( 'mutual', 2, GetterInterface::INT ); $cross = $row->get( 'cross', 1, GetterInterface::INT ); $notify = $row->get( 'notify', 0, GetterInterface::BOOLEAN ); if ( $mutual ) { $oldMutual = $ueConfig['useMutualConnections']; $ueConfig['useMutualConnections'] = ( $mutual == 1 ? '1' : '0' ); } if ( $cross ) { $oldCross = $ueConfig['autoAddConnections']; $ueConfig['autoAddConnections'] = ( $cross == 1 ? '1' : '0' ); } if ( $row->get( 'direction', 0, GetterInterface::BOOLEAN ) ) { foreach ( $users as $userId ) { if ( $userId != $user->get( 'id' ) ) { $connections = new cbConnection( $userId ); if ( ! $connections->getConnectionDetails( $userId, $user->get( 'id' ) ) ) { $connections->addConnection( $user->get( 'id' ), $message, $notify ); } } } } else { $connections = new cbConnection( $user->get( 'id' ) ); foreach ( $users as $userId ) { if ( $userId != $user->get( 'id' ) ) { if ( ! $connections->getConnectionDetails( $user->get( 'id' ), $userId ) ) { $connections->addConnection( $userId, $message, $notify ); } } } } if ( $mutual ) { $ueConfig['useMutualConnections'] = $oldMutual; } if ( $cross ) { $ueConfig['autoAddConnections'] = $oldCross; } } } }
/** * 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; $oReturn = null; if ($ueConfig['allowConnections'] && is_object($user)) { $cbCon = new cbConnection($_CB_framework->myId()); $value = $cbCon->getConnectionsCount($user->id); switch ($output) { case 'html': case 'rss': $oReturn = $value; break; case 'htmledit': // $oReturn = parent::getField( $field, $user, $output, $reason, $list_compare_types ); $oReturn = null; //TBD for now no searches...not optimal in SQL anyway. break; case 'json': case 'php': case 'xml': case 'csvheader': case 'fieldslist': case 'csv': default: $oReturn = $this->_formatFieldOutputIntBoolFloat($field->name, $value, $output); break; } } return $oReturn; }
/** * prepare list of connections * * @param moscomprofilerUser $user * @return mixed */ static public function getConnectionsList( $user ) { static $cache = array(); if ( ! isset( $cache[$user->id] ) ) { $plugin = cbgjClass::getPlugin(); $inviteBy = explode( '|*|', $plugin->params->get( 'group_invites_by', '1|*|2|*|3|*|4' ) ); $listUsers = array(); if ( $inviteBy ) { $cbConnection = new cbConnection( $user->id ); $connections = $cbConnection->getActiveConnections( $user->id ); if ( $connections ) foreach ( $connections as $connection ) { $cbConn =& CBuser::getInstance( (int) $connection->id ); if ( ! $cbConn ) { $cbConn =& CBuser::getInstance( null ); } if ( in_array( 2, $inviteBy ) ) { $value = $connection->username; } elseif ( in_array( 3, $inviteBy ) ) { $value = $connection->name; } elseif ( in_array( 4, $inviteBy ) ) { $value = $connection->email; } elseif ( in_array( 1, $inviteBy ) ) { $value = $connection->id; } $listUsers[] = moscomprofilerHTML::makeOption( $value, $cbConn->getField( 'formatname', null, 'html', 'none', 'profile', 0, true ) ); } } $cache[$user->id] = $listUsers; } return $cache[$user->id]; }
} else { $newMessageCount = 0; } if (isset($privateMessageURL[0]['url'])) { $privateMessageURL = $privateMessageURL[0]['url']; } else { $privateMessageURL = $_CB_framework->userProfileUrl(); } if ($showPrivateMessages == 1 && !$newMessageCount) { $showPrivateMessages = 0; } } else { $showPrivateMessages = 0; $newMessageCount = 0; $privateMessageURL = $_CB_framework->userProfileUrl(); } if ($showConnectionRequests && (isset($ueConfig['allowConnections']) && $ueConfig['allowConnections'])) { $cbConnections = new cbConnection((int) $user->get('id')); $newConnectionRequests = (int) $cbConnections->getPendingConnectionsCount((int) $user->get('id')); if ($showConnectionRequests == 1 && !$newConnectionRequests) { $showConnectionRequests = 0; } } else { $showConnectionRequests = 0; $newConnectionRequests = 0; } $twoFactorMethods = modCBLoginHelper::getTwoFactorMethods(); if ($type == 'logout') { $moduleLayout .= '_logout'; } require JModuleHelper::getLayoutPath('mod_cblogin', $moduleLayout);
function processConnectionActions($connectionids) { global $_CB_framework, $ueConfig, $_PLUGINS; // simple spoof check security cbSpoofCheck('manageconnections'); if (!$ueConfig['allowConnections']) { $msg = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.'); } elseif (!($_CB_framework->myId() > 0)) { $msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!'); } else { $msg = null; } $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onBeforeProcessConnectionsRequest', array($connectionids, &$msg)); if ($msg) { $_CB_framework->enqueueMessage($msg, 'error'); return; } $cbCon = new cbConnection($_CB_framework->myId()); if (is_array($connectionids)) { foreach ($connectionids as $cid) { $action = cbGetParam($_POST, $cid . 'action'); if ($action == 'd') { $cbCon->denyConnection($_CB_framework->myId(), $cid); } elseif ($action == 'a') { $cbCon->acceptConnection($_CB_framework->myId(), $cid); } } } $error = $cbCon->getErrorMSG(); if ($error) { cbRedirect($_CB_framework->viewUrl('manageconnections', false), $error, 'error'); } else { cbRedirect($_CB_framework->viewUrl('manageconnections', false), is_array($connectionids) ? CBTxt::Th('UE_CONNECTIONACTIONSSUCCESSFULL', 'Connection actions successful!') : null); } }
/** * @param int $userId * @return mixed */ public function isAuthorized( $userId ) { global $_PLUGINS; static $cache = array(); $id = (int) $this->get( 'id' ); $owner = (int) $this->get( 'user_id' ); $userId = (int) $userId; if ( ! isset( $cache[$userId][$id] ) ) { $rules = explode( '|*|', $this->get( 'rule' ) ); $cache[$userId][$id] = false; $_PLUGINS->trigger( 'privacy_onBeforeIsAuthorized', array( &$cache[$userId][$id], $rules, $userId, $this ) ); if ( empty( $rules ) || in_array( '0', $rules ) || ( $userId == $owner ) ) { $cache[$userId][$id] = true; } elseif ( in_array( '1', $rules ) ) { if ( $userId > 0 ) { $cache[$userId][$id] = true; } } elseif ( in_array( '99', $rules ) ) { $cache[$userId][$id] = false; } else { $types = array(); foreach ( $rules as $rule ) { if ( substr( $rule, 0, 5 ) == 'CONN-' ) { $types[] = str_replace( 'CONN-', '', $rule ); } } $access = array(); foreach ( $rules as $rule ) { if ( substr( $rule, 0, 7 ) == 'ACCESS-' ) { $access[] = str_replace( 'ACCESS-', '', $rule ); } } $groups = array(); foreach ( $rules as $rule ) { if ( substr( $rule, 0, 6 ) == 'GROUP-' ) { $groups[] = str_replace( 'GROUP-', '', $rule ); } } if ( ( $cache[$userId][$id] == false ) && ( in_array( '2', $rules ) || $types ) ) { static $connections = array(); if ( ! isset( $connections[$userId][$owner] ) ) { $cbConnection = new cbConnection( $userId ); $connections[$userId][$owner] = $cbConnection->getConnectionDetails( $owner, $userId ); } $connection = $connections[$userId][$owner]; if ( $connection && ( $connection->accepted == 1 ) && ( $connection->pending == 0 ) ) { if ( in_array( '2', $rules ) ) { $cache[$userId][$id] = true; } else { if ( $connection->type ) { $connTypes = explode( '|*|', $connection->type ); foreach ( $connTypes as $connType ) { if ( in_array( trim( htmlspecialchars( $connType ) ), $types ) ) { $cache[$userId][$id] = true; } } } } } } if ( ( $cache[$userId][$id] == false ) && in_array( '3', $rules ) ) { static $subConnections = array(); if ( ! isset( $subConnections[$userId][$owner] ) ) { $cbConnection = new cbConnection( $userId ); $subConnections[$userId][$owner] = $cbConnection->getDegreeOfSepPathArray( $owner, $userId, 1, 2 ); } if ( ! empty( $subConnections[$userId][$owner] ) ) { $cache[$userId][$id] = true; } } if ( ( $cache[$userId][$id] == false ) && $access ) { static $accessLevels = array(); if ( ! isset( $accessLevels[$userId] ) ) { $accessLevels[$userId] = Application::User( $userId )->getAuthorisedViewLevels(); } $usersAccess = $accessLevels[$userId]; foreach ( $access as $accessLevel ) { if ( ( $cache[$userId][$id] == false ) && in_array( $accessLevel, $usersAccess ) ) { $cache[$userId][$id] = true; } } } if ( ( $cache[$userId][$id] == false ) && $groups ) { static $userGroups = array(); if ( ! isset( $userGroups[$userId] ) ) { $userGroups[$userId] = Application::User( $userId )->getAuthorisedGroups(); } $usersGroups = $userGroups[$userId]; foreach ( $groups as $group ) { if ( ( $cache[$userId][$id] == false ) && in_array( $group, $usersGroups ) ) { $cache[$userId][$id] = true; } } } } $_PLUGINS->trigger( 'privacy_onAfterIsAuthorized', array( &$cache[$userId][$id], $rules, $userId, $this ) ); } return $cache[$userId][$id]; }
/** * Returns an options array of available user tags with optional activity specific * * @param null|int|ActivityTable $activityId * @param null|int $userId * @return array */ static public function loadTagOptions( $activityId = null, $userId = null ) { global $_CB_database; /** @var ActivityTable[] $cache */ static $cache = array(); if ( $activityId && ( $userId === null ) ) { if ( $activityId instanceof ActivityTable ) { $activity = $activityId; $activityId = (int) $activity->get( 'id' ); } else { if ( ! isset( $cache[$activityId] ) ) { $activity = new ActivityTable(); $activity->load( (int) $activityId ); $cache[$activityId] = $activity; } $activity = $cache[$activityId]; } $userId = (int) $activity->get( 'user_id' ); } elseif ( $userId === null ) { $userId = Application::MyUser()->getUserId(); } static $connections = array(); static $custom = array(); static $options = array(); if ( ! isset( $options[$userId][$activityId] ) ) { if ( ! isset( $connections[$userId] ) ) { $connectionOptions = array(); if ( Application::Config()->get( 'allowConnections' ) ) { $cbConnection = new \cbConnection( $userId ); foreach( $cbConnection->getConnectedToMe( $userId ) as $connection ) { $connectionOptions[] = \moscomprofilerHTML::makeOption( (string) $connection->id, getNameFormat( $connection->name, $connection->username, Application::Config()->get( 'name_format', 3 ) ) ); } } $connections[$userId] = $connectionOptions; } if ( ! isset( $custom[$activityId] ) ) { $activityOptions = array(); if ( $activityId ) { $exclude = array(); foreach ( $connections[$userId] as $connection ) { $exclude[] = $connection->value; } $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_activity_tags' ) . "\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'activity' ) . "\n AND " . $_CB_database->NameQuote( 'item' ) . " = " . (int) $activityId . "\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " ASC"; $_CB_database->setQuery( $query ); $tags = $_CB_database->loadObjectList( null, '\CB\Plugin\Activity\Table\TagTable', array( $_CB_database ) ); /** @var TagTable[] $tags */ foreach ( $tags as $tag ) { if ( ! in_array( $tag->get( 'user' ), $exclude ) ) { $activityOptions[] = \moscomprofilerHTML::makeOption( (string) $tag->get( 'user' ), $tag->get( 'user' ) ); } } } $custom[$activityId] = $activityOptions; } $options[$userId][$activityId] = array_merge( $connections[$userId], $custom[$activityId] ); } return $options[$userId][$activityId]; }
/** * @param UserTable $user * @return bool */ public function accept( $user ) { global $_CB_framework, $_PLUGINS; if ( ! $this->isAccepted() ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbinvites' ); if ( ! $plugin ) { return false; } $params = $_PLUGINS->getPluginParams( $plugin ); $mode = $params->get( 'invite_connection', 2 ); $this->set( 'accepted', $_CB_framework->getUTCDate() ); $_PLUGINS->trigger( 'invites_onBeforeAcceptInvite', array( &$this, $user ) ); if ( $this->store() ) { if ( $mode ) { $connections = new cbConnection( $this->get( 'user_id' ) ); $connections->addConnection( $user->get( 'id' ), null, false ); if ( $mode == 2 ) { $connections->acceptConnection( $this->get( 'user_id' ), $user->get( 'id' ), false ); } } } else { return false; } $_PLUGINS->trigger( 'invites_onAfterAcceptInvite', array( $this, $user ) ); } return true; }
function awUserActivated($user, $success) { global $_CB_framework, $ueConfig; if (!$success) return false; // get CBUser so we can use replaceUserVars() from CBAPI $awCBuser =& CBUser::getInstance((int) $user->id); $res_wpms = true; $res_wemail = true; $res_wconnect = true; $plugparams=$this->_awGetPlugParameters(); $testNotifications = new cbNotification(); if ($plugparams["awautomessageenable"]) { switch ($plugparams["awmessagemethod"]) { case 0: // PMS $cbawNotification = new cbNotification(); $res_wpms = $cbawNotification->sendUserPMSmsg((int) $user->id, $plugparams["awpmsfromuserid"], $awCBuser->replaceUserVars( $plugparams["awpmsmessagesubject"] ), $awCBuser->replaceUserVars( $plugparams["awpmsmessagebody"] ), true); if (!$res_wpms) { $this->_setErrorMSG("Auto-Welcome plugin failed to send PMS welcome message"); } break; case 1: // Email $cbawNotification = new cbNotification(); $res_wemail=$cbawNotification->sendUserEmail((int) $user->id, $plugparams["awemailfromuserid"], $awCBuser->replaceUserVars( $plugparams["awemailmessagesubject"] ), $awCBuser->replaceUserVars( $plugparams["awemailmessagebody"] ), $plugparams["awemailfromuserid"]); //reveal email if (!$res_wemail) { $this->_setErrorMSG("Auto-Welcome plugin failed to send Email welcome message"); } break; case 2: // Email and PMS $cbawNotification = new cbNotification(); $res_wpms = $cbawNotification->sendUserPMSmsg((int) $user->id, $plugparams["awpmsfromuserid"], $awCBuser->replaceUserVars( $plugparams["awpmsmessagesubject"] ), $awCBuser->replaceUserVars( $plugparams["awpmsmessagebody"] ), true); if (!$res_wpms) { $this->_setErrorMSG("Auto-Welcome plugin failed to send PMS welcome message"); } $res_wemail=$cbawNotification->sendUserEmail((int) $user->id, $plugparams["awemailfromuserid"], $awCBuser->replaceUserVars( $plugparams["awemailmessagesubject"] ), $awCBuser->replaceUserVars( $plugparams["awemailmessagebody"] ), $plugparams["awpmsfromuserid"]); //reveal email if (!$res_wemail) { $this->_setErrorMSG("Auto-Welcome plugin failed to send Email welcome message"); } break; default: break; } } if ($plugparams["awautoconnectenable"] && $ueConfig['allowConnections']) { $awkeyuserid_count = substr_count($plugparams["awkeyuserid"],','); $res_wconnect = true; $awkeyuserid_item = explode(",",$plugparams["awkeyuserid"]); if ($plugparams["awautoconnectdirection"]==0) { // connect new user to key users $cbawCon=new cbConnection( (int) $user->id); for ($aw_i=0;$aw_i<=$awkeyuserid_count;$aw_i++) { $res_wconnect = $res_wconnect && $cbawCon->addConnection((int) $awkeyuserid_item[$aw_i], $awCBuser->replaceUserVars( $plugparams["awautoconnectmessage"] )); } if (!$res_wconnect) { $this->_setErrorMSG("Auto-Welcome plugin failed to initiate auto-connection"); } unset($cbawCon); // cleanup } else { // connect key users to new user for ($aw_i=0;$aw_i<=$awkeyuserid_count;$aw_i++) { $cbawCon=new cbConnection((int) $awkeyuserid_item[$aw_i]); $res_wconnect = $res_wconnect && $cbawCon->addConnection((int) $user->id, $awCBuser->replaceUserVars( $plugparams["awautoconnectmessage"] )); unset($cbawCon); // cleanup } if (!$res_wconnect) { $this->_setErrorMSG("Auto-Welcome plugin failed to initiate auto-connection"); } } } if (!($res_wemail && $res_wpms && $res_wconnect)) { $this->raiseError(0); } return $res_wemail && $res_wpms && $res_wconnect; }