function addConnection($userid,$connectionid,$umsg=null) { global $_CB_framework, $ueConfig; $andItemid = getCBprofileItemid(true); if(!$ueConfig['allowConnections']) { echo _UE_FUNCTIONALITY_DISABLED; return; } if (! ($_CB_framework->myId() > 0 ) ) { cbNotAuth(); return; } $cbCon=new cbConnection($userid); $cbCon->addConnection($connectionid,stripcslashes($umsg)); $url=cbSef( "index.php?option=com_comprofiler&task=userProfile&user="******"<script type=\"text/javascript\"> alert('".addslashes(htmlspecialchars($cbCon->getUserMSG()))."'); document.location.href='".cbUnHtmlspecialchars($url)."'; </script>\n"; }
/** * @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; } } } }
/** * @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 addConnection($userid, $connectionid, $umsg = null, $act = 'connections') { global $_CB_framework, $ueConfig, $_PLUGINS; if (!$ueConfig['allowConnections']) { $msg = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.'); } elseif (!($_CB_framework->myId() > 0)) { cbNotAuth(true); return; } else { $msg = null; } $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onBeforeAddConnectionRequest', array($userid, $connectionid, &$msg, &$umsg, $act)); if ($msg) { $_CB_framework->enqueueMessage($msg, 'error'); return; } $cbCon = new cbConnection($userid); if (!$cbCon->addConnection($connectionid, stripcslashes($umsg))) { $msg = $cbCon->getErrorMSG(); } else { $msg = $cbCon->getUserMSG(); } if ($act == 'connections') { cbRedirectToProfile($userid, $msg, null, 'getConnectionTab'); } elseif ($act == 'manage') { cbRedirectToProfile($connectionid, $msg, 'manageconnections', 'cbtabconnections'); } else { cbRedirectToProfile($connectionid, $msg); } }
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; }