/** * @param int $userId * @param UserTable $user * @return mixed */ public function deleteUser( $userId, $user ) { global $_CB_framework, $_PLUGINS; if ( ! $userId ) { $userId = $user->get( 'id' ); } $profileUrl = $_CB_framework->userProfileUrl( $userId, false ); if ( ! $userId ) { $profileUrl = 'index.php'; } if ( $this->getDeleteField( $userId, $user ) ) { $cbUser = CBuser::getInstance( $userId, false ); $deleteUser = $cbUser->getUserData(); $_PLUGINS->trigger( 'privacy_onBeforeAccountDelete', array( &$deleteUser, $user ) ); if ( $deleteUser->delete( $userId ) ) { $closed = new cbprivacyClosedTable(); $closed->set( 'user_id', (int) $deleteUser->get( 'id' ) ); $closed->set( 'username', $deleteUser->get( 'username' ) ); $closed->set( 'name', $deleteUser->get( 'name' ) ); $closed->set( 'email', $deleteUser->get( 'email' ) ); $closed->set( 'type', 'delete' ); $closed->set( 'date', $_CB_framework->getUTCDate() ); $closed->set( 'reason', $this->input( 'reason', null, GetterInterface::STRING ) ); $closed->store(); $notification = new cbNotification(); $extra = array( 'ip_address' => cbGetIPlist(), 'reason' => $closed->get( 'reason' ), 'date' => $closed->get( 'date' ) ); $subject = $cbUser->replaceUserVars( CBTxt::T( 'User Account Deleted' ), true, false, $extra, false ); $body = $cbUser->replaceUserVars( CBTxt::T( 'Name: [name]<br />Username: [username]<br />Email: [email]<br />IP Address: [ip_address]<br />Date: [date]<br /><br />[reason]<br /><br />' ), false, false, $extra, false ); if ( $subject && $body ) { $notification->sendToModerators( $subject, $body, false, 1 ); } $subject = CBTxt::T( 'Your Account has been Deleted' ); $body = CBTxt::T( 'This is a notice that your account [username] on [siteurl] has been deleted.' ); if ( $subject && $body ) { $notification->sendFromSystem( $deleteUser, $subject, $body, true, 1, null, null, null, $extra ); } $_PLUGINS->trigger( 'privacy_onAfterAccountDelete', array( $deleteUser, $user ) ); cbRedirect( 'index.php', CBTxt::T( 'Account deleted successfully!' ) ); } else { cbRedirect( $profileUrl, CBTxt::T( 'ACCOUNT_FAILED_TO_DELETE', 'Account failed to delete! Error: [error]', array( '[error]' => $deleteUser->getError() ) ), 'error' ); } } cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); }
function rejectUser($uids) { global $_CB_framework, $_CB_database, $ueConfig, $_POST, $_PLUGINS; $andItemid = getCBprofileItemid(); // simple spoof check security cbSpoofCheck( 'pendingApprovalUsers' ); if($ueConfig['allowModUserApproval']==0) { echo _UE_FUNCTIONALITY_DISABLED; exit(); } $isModerator=isModerator( $_CB_framework->myId() ); if (!$isModerator){ cbNotAuth(); return; } $cbNotification= new cbNotification(); foreach($uids AS $uid) { $query = "SELECT * FROM #__comprofiler c, #__users u WHERE c.id=u.id AND c.id = " . (int) $uid; $_CB_database->setQuery($query); $user = $_CB_database->loadObjectList(); $row = $user[0]; $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger( 'onBeforeUserApproval', array($row,false)); if($_PLUGINS->is_errors()) { cbRedirect( cbSef("index.php?option=$option&task=pendingApprovalUser".($Itemid ? "&Itemid=". (int) $Itemid : ""), false ), $_PLUGINS->getErrorMSG(), 'error' ); return; } $sql="UPDATE #__comprofiler SET approved=2 WHERE id=" . (int) $uid; $_CB_database->SetQuery($sql); $_CB_database->query(); $_PLUGINS->trigger( 'onAfterUserApproval', array($row,false,true)); $cbNotification->sendFromSystem(cbGetEscaped($uid),_UE_REG_REJECT_SUB,sprintf(_UE_USERREJECT_MSG,$_CB_framework->getCfg( 'sitename' ), stripslashes( cbGetParam( $_POST, 'comment' . $uid, '' ) ) ) ); } cbRedirect( cbSef( 'index.php?option=com_comprofiler&task=pendingApprovalUser' . $andItemid, false ),(count($uids))?count($uids)." "._UE_USERREJECT_SUCCESSFUL:""); }
function _notifyConnectionChange($userid, $connectionid, $msg, $subject, $messageHTML, $messageText, $userMessage = null) { global $_CB_framework, $_CB_database, $ueConfig; $rowFrom = new moscomprofilerUser($_CB_database); $rowFrom->load((int) $userid); $fromname = getNameFormat($rowFrom->name, $rowFrom->username, $ueConfig['name_format']); $fromURL = "index.php?option=com_comprofiler&task=userProfile&user="******"&tab=1" . getCBprofileItemid(true); $fromURL = cbSef($fromURL); if (strncasecmp("http", $fromURL, 4) != 0) { $fromURL = $_CB_framework->getCfg('live_site') . "/" . $fromURL; } $subject = sprintf($subject, $fromname); if ($userMessage != null) { $messageHTML .= sprintf(str_replace("\n", "\n<br />", _UE_CONNECTIONMSGPREFIX), $fromname, "<strong>" . htmlspecialchars($userMessage) . "</strong>"); $messageText .= sprintf(str_replace("\n", "\r\n", _UE_CONNECTIONMSGPREFIX), $fromname, $userMessage); } $nmsgHTML = sprintf($messageHTML, '<strong><a href="' . $fromURL . '">' . $fromname . '</a></strong>'); $nmsgText = sprintf($messageText, $fromname); $manageURL = 'index.php?option=com_comprofiler&task=manageConnections' . getCBprofileItemid(true); $manageURL = cbSef($manageURL); if (strncasecmp("http", $manageURL, 4) != 0) { $manageURL = $_CB_framework->getCfg('live_site') . "/" . $manageURL; } $nmsgHTML = $nmsgHTML . "\n<br /><br /><a href=\"" . $manageURL . "\">" . _UE_MANAGECONNECTIONS . "</a>\n"; $nmsgText = $nmsgText . "\r\n\r\n\r\n" . $fromname . " " . _UE_PROFILE . ": " . cbUnHtmlspecialchars($fromURL); $nmsgText = $nmsgText . "\r\n\r\n" . _UE_MANAGECONNECTIONS . ": " . cbUnHtmlspecialchars($manageURL) . "\r\n"; $nmsgHTML = '<div style="padding: 4px; margin: 4px 3px 6px 0px; background: #C44; font-weight: bold;" class="cbNotice">' . _UE_SENDPMSNOTICE . "</div>\n\n" . $nmsgHTML; $cbNotification = new cbNotification(); $cbNotification->sendFromUser($connectionid, $userid, $subject, $nmsgHTML, $nmsgText); $this->_setUserMSG($msg); return true; }
/** * Sends appropriate email depending on status. * Should be called only once upon each change of this something, * * @param UserTable $user * @param string $cause 'PaidSubscription' (first activation only), 'SubscriptionActivated' (renewals, cancellation reversals), 'SubscriptionDeactivated', 'Denied' * @param string $reason 'N' new subscription, 'R' renewal, 'U'=update ) * @param int $autorenewed 0: not auto-renewing (manually renewed), 1: automatically renewed (if $reason == 'R') */ public function sendNewStatusEmail( &$user, $cause, $reason, $autorenewed = 0 ) { global $_CB_framework; if ( ! is_object( $user ) ) { return; } $emailkind = null; if ( ( $this->status == 'A' ) && ( $cause == 'PaidSubscription' ) && ( $reason != 'R' ) ) { $emailkind = 'thankyou'; } elseif ( ( $this->status == 'A' ) && ( $cause == 'PaidSubscription' ) && ( $reason == 'R' ) && ( $autorenewed == 0 ) ) { $emailkind = 'renewal'; } elseif ( ( $this->status == 'A' ) && ( $cause == 'PaidSubscription' ) && ( $reason == 'R' ) && ( $autorenewed == 1 ) ) { $emailkind = 'autorenewal'; } elseif ( ( $this->status == 'X' ) && ( $cause == 'Denied' ) ) { $emailkind = 'expiration'; } elseif ( ( $this->status == 'C' ) && ( $cause == 'Denied' ) && ( $user->id == $_CB_framework->myId() ) && ( $_CB_framework->getUi() == 1 ) ) { $emailkind = 'cancelled'; // by the user only in frontend } elseif ( ( $cause == 'Pending' ) && ( $reason != 'R' ) && ( $autorenewed == 0 ) ) { $emailkind = 'pendingfirst'; } elseif ( ( $cause == 'Pending' ) && ( $reason == 'R' ) && ( $autorenewed == 0 ) ) { $emailkind = 'pendingrenewal'; } if ( $emailkind ) { // email to user only if activated for the first time: $plan = $this->getPlan(); if ( ! $plan ) { return; } cbimport( 'cb.tabs' ); // for cbNotification and comprofilerMail() cbimport( 'language.front' ); // for _UE_EMAILFOOTER translation $mailHtml = ( $plan->get( $emailkind . 'emailhtml' ) == '1' ? 1 : 0 ); $mailSubject = $this->getPersonalized( $emailkind . 'emailsubject', false, false ); $mailBody = $this->getPersonalized( $emailkind . 'emailbody', $mailHtml ); $mailCC = trim( $plan->get( $emailkind . 'emailcc' ) ); $mailBCC = trim( $plan->get( $emailkind . 'emailbcc' ) ); $mailAttachments = trim( $plan->get( $emailkind . 'emailattachments' ) ); if ( $mailCC != '' ) { $mailCC = preg_split( '/ *, */', $mailCC ); } else { $mailCC = null; } if ( $mailBCC != '' ) { $mailBCC = preg_split( '/ *, */', $mailBCC ); } else { $mailBCC = null; } if ( $mailAttachments != '' ) { $mailAttachments = preg_split( '/ *, */', $mailAttachments ); } else { $mailAttachments = null; } if ( $mailSubject || $mailBody ) { $notifier = new cbNotification(); $notifier->sendFromSystem( $user, $mailSubject, $mailBody, true, $mailHtml, $mailCC, $mailBCC, $mailAttachments ); } } //TBD: else email in case of deactivation }
/** * Notifies connection changes * * @param int $userId * @param int $connectionId * @param string $msg * @param string $subject * @param string $messageHTML * @param string $messageText * @param string $userMessage * @return boolean */ protected function _notifyConnectionChange( $userId, $connectionId, $msg, $subject, $messageHTML, $messageText, $userMessage = null ) { global $_CB_framework, $ueConfig; $rowFrom = new UserTable(); $rowFrom->load( (int) $userId ); $fromName = getNameFormat( $rowFrom->name, $rowFrom->username, $ueConfig['name_format'] ); $fromURL = 'index.php?option=com_comprofiler&view=userprofile&user='******'&tab=1' . getCBprofileItemid(true); $fromURL = cbSef( $fromURL ); if ( strncasecmp( 'http', $fromURL, 4 ) != 0 ) { $fromURL = $_CB_framework->getCfg( 'live_site' ) . '/' . $fromURL; } $subject = sprintf( $subject, $fromName ); if ( $userMessage != null ) { $messageHTML .= sprintf( str_replace( "\n", "\n<br />", CBTxt::T( 'UE_CONNECTIONMSGPREFIX', " %s included the following personal message:\n\n%s" ) ), htmlspecialchars( $fromName ), '<strong>' . htmlspecialchars( $userMessage ) . '</strong>' ); $messageText .= sprintf( str_replace( "\n", "\r\n", CBTxt::T( 'UE_CONNECTIONMSGPREFIX', " %s included the following personal message:\n\n%s" ) ), $fromName, $userMessage ); } $notificationMsgHTML = sprintf( $messageHTML, '<strong><a href="' . $fromURL . '">' . htmlspecialchars( $fromName ) . '</a></strong>' ); $notificationMsgText = sprintf( $messageText, $fromName ); $manageURL = 'index.php?option=com_comprofiler&view=manageconnections' . getCBprofileItemid( true ); $manageURL = cbSef( $manageURL ); if ( strncasecmp( 'http', $manageURL, 4 ) != 0 ) { $manageURL = $_CB_framework->getCfg( 'live_site' ) . '/' . $manageURL; } $notificationMsgHTML = $notificationMsgHTML . "\n<br /><br /><a href=\"" . $manageURL . '">' . CBTxt::T( 'UE_MANAGECONNECTIONS_LINK UE_MANAGECONNECTIONS', 'Manage Connections' ) . "</a>\n"; $notificationMsgText = $notificationMsgText . "\r\n\r\n\r\n" . $fromName . ' ' . CBTxt::T( 'CONNECTION_PROFILE UE_PROFILE', 'Profile' ) . ': ' . cbUnHtmlspecialchars( $fromURL ); $notificationMsgText = $notificationMsgText . "\r\n\r\n" . CBTxt::T( 'UE_MANAGECONNECTIONS_URL_LABEL UE_MANAGECONNECTIONS', 'Manage Connections' ) . ': ' . cbUnHtmlspecialchars( $manageURL ) . "\r\n"; $notificationMsgHTML = '<div style="padding: 4px; margin: 4px 3px 6px 0px; background: #C44; font-weight: bold;" class="cbNotice">' . CBTxt::T( 'UE_SENDPMSNOTICE', 'NOTE: This is a message generated automatically by the Connections system. It has the connecting user\'s address, so you can conveniently reply if you wish to.' ) . "</div>\n\n" . $notificationMsgHTML; $cbNotification = new cbNotification(); $cbNotification->sendFromUser( $connectionId, $userId, $subject, $notificationMsgHTML, $notificationMsgText ); $this->_setUserMSG( $msg ); return true; }
function pbEdit( $id, $userId, $curruser, $iAmModerator, $tab ) { global $_CB_database, $ueConfig; $postertitle = $this->_getReqParam( 'postertitle', null ); $postercomment = $this->_getReqParam( 'postercomments', null ); $postername = $this->_getReqParam( 'postername', null ); $posterlocation = $this->_getReqParam( 'posterlocation', null ); $posteremail = $this->_getReqParam( 'posteremail', null ); $posterurl = $this->_getReqParam( 'posterurl', null ); $posterid = Application::MyUser()->getUserId(); $posterip = cbGetIPlist(); $postervote = $this->_getReqParam( 'postervote', 'NULL' ); $editedbyname = ( $posterid ? getNameFormat( $curruser->name, $curruser->username, $ueConfig['name_format'] ) : stripslashes( $postername ) ); $query = 'UPDATE #__comprofiler_plug_profilebook' . ' SET editdate = NOW()' . ( $posterid ? ', editedbyid = ' . $posterid : '' ) . ', editedbyname = ' . $_CB_database->Quote( $editedbyname ) . ', postername = ' . $_CB_database->Quote( stripslashes( $postername ) ) . ( $posteremail ? ', posteremail = ' . $_CB_database->Quote( stripslashes( $posteremail ) ) : '' ) . ', posterlocation = ' . $_CB_database->Quote( stripslashes( $posterlocation ) ) . ', postertitle = ' . $_CB_database->Quote( stripslashes( $postertitle ) ) . ', postercomment = ' . $_CB_database->Quote( stripslashes( $postercomment ) ) . ', postervote = ' . (int) $postervote . ', posterip = ' . $_CB_database->Quote( $posterip ) // . ( $published !== null ? ', published = ' . (int) $published : '' ) . ', posterurl = ' . $_CB_database->Quote( stripslashes( $posterurl ) ) . ' WHERE id = ' . (int) $id . ' AND userid = ' . (int) $userId . ( $iAmModerator ? '' : ' AND posterid = ' . (int) $posterid ) ; $_CB_database->setQuery( $query ); $_CB_database->query(); $notify = $this->getUserParam( $userId, 'notifyme' ); $res = true; if ( $notify && ( $userId != $posterid ) ) { $autoPublish = $this->getUserParam( $userId, 'autopublish' ); $cbNotification = new cbNotification( ); $res = $cbNotification->sendFromSystem( (int) $userId, sprintf( CBTxt::T( "An entry in your %s has just been updated" ), CBTxt::T( $tab->title ) ), sprintf( CBTxt::T( "%s has just submitted an edited entry for %s in your %s." ), $editedbyname, $postername, CBTxt::T( $tab->title ) ) . ( $iAmModerator ? '' : sprintf( $autoPublish ? CBTxt::T( "\n\nYour current setting is that new entries in your %1\$s are automatically published. To see the new entry, please login. You can then see the new entry and take appropriate action if needed. Direct access to your %1\$s:\n%2\$s\n" ) : CBTxt::T( "\n\nYour current setting is that you need to review entries in your %1\$s. Please login, review the new entry and publish if you agree. Direct access to your %1\$s:\n%2\$s\n" ), CBTxt::T( $tab->title ), cbUnHtmlspecialchars( $this->_getAbsURLwithParam( array() ) ) ) ) ); } return $res; }
/** * Saves a folder * * @param int $id * @param string $type * @param TabTable $tab * @param UserTable $user * @param UserTable $viewer */ private function saveFolderEdit( $id, $type, $tab, $user, $viewer ) { global $_CB_framework, $_PLUGINS; $row = new cbgalleryFolderTable(); $row->load( (int) $id ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $canAccess = false; if ( ! $row->get( 'id' ) ) { if ( ( $user->get( 'id' ) != $viewer->get( 'id' ) ) && ( ! $cbModerator ) ) { $user = $viewer; } $canAccess = cbgalleryClass::canUserCreate( $viewer, $type, true ); } elseif ( ( $row->get( 'type' ) == $type ) && ( $cbModerator || ( $viewer->get( 'id' ) == $row->get( 'user_id' ) ) ) ) { $canAccess = true; } if ( $this->input( 'folder', false, GetterInterface::BOOLEAN ) ) { $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ); } else { $returnUrl = $_CB_framework->userProfileUrl( (int) $row->get( 'user_id', $user->get( 'id' ) ), false, $tab->get( 'tabid' ) ); } if ( ! $canAccess ) { cbRedirect( $returnUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } switch( $type ) { case 'photos': case 'videos': case 'music': $typeTranslated = CBTxt::T( 'Album' ); break; default: $typeTranslated = CBTxt::T( 'Folder' ); break; } if ( $cbModerator || ( ! $this->params->get( $type . '_folder_approval', 0 ) ) || ( $row->get( 'id' ) && ( $row->get( 'published' ) != -1 ) ) ) { $row->set( 'published', $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) ); } else { $row->set( 'published', ( $this->params->get( $type . '_folder_approval', 0 ) ? -1 : $row->get( 'published', 1 ) ) ); } $row->set( 'type', $type ); $row->set( 'title', $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ); $row->set( 'description', $this->input( 'post/description', $row->get( 'description' ), GetterInterface::STRING ) ); if ( $cbModerator ) { $row->set( 'user_id', $this->input( 'post/user_id', $row->get( 'user_id', $viewer->get( 'id' ) ), GetterInterface::INT ) ); } else { $row->set( 'user_id', $row->get( 'user_id', $viewer->get( 'id' ) ) ); } if ( $this->params->get( $type . '_folder_captcha', 0 ) && ( ! $cbModerator ) ) { $_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() ) ) { $this->showItemEdit( $id, $type, $tab, $user, $viewer, CBTxt::T( 'FOLDER_FAILED_TO_SAVE', '[type] failed to save! Error: [error]', array( '[type]' => $typeTranslated, '[error]' => $row->getError() ) ) ); return; } if ( $row->getError() || ( ! $row->store() ) ) { $this->showItemEdit( $id, $type, $tab, $user, $viewer, CBTxt::T( 'FOLDER_FAILED_TO_SAVE', '[type] failed to save! Error: [error]', array( '[type]' => $typeTranslated, '[error]' => $row->getError() ) ) ); return; } if ( $row->get( 'published' ) == -1 ) { if ( $new && ( ! $cbModerator ) && $this->params->get( $type . '_folder_approval_notify', 1 ) ) { $cbUser = CBuser::getInstance( (int) $row->get( 'user_id' ), false ); $extraStrings = array( 'folder_id' => (int) $row->get( 'id' ), 'folder_title' => ( $row->get( 'title' ) ? $row->get( 'title' ) : $row->get( 'date' ) ), 'folder_description' => $row->get( 'description' ), 'folder_date' => $row->get( 'date' ), 'folder_url' => $_CB_framework->pluginClassUrl( $this->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $row->get( 'user_id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ), 'folder_type' => $typeTranslated, 'folder_tab_url' => $_CB_framework->viewUrl( 'userprofile', true, array( 'user' => (int) $row->get( 'user_id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ), 'gallery_photos_url' => $_CB_framework->viewUrl( 'userprofile', true, array( 'user' => (int) $row->get( 'user_id' ), 'tab' => 'cbgalleryTabPhotos' ) ), 'gallery_videos_url' => $_CB_framework->viewUrl( 'userprofile', true, array( 'user' => (int) $row->get( 'user_id' ), 'tab' => 'cbgalleryTabVideos' ) ), 'gallery_music_url' => $_CB_framework->viewUrl( 'userprofile', true, array( 'user' => (int) $row->get( 'user_id' ), 'tab' => 'cbgalleryTabMusic' ) ), 'gallery_files_url' => $_CB_framework->viewUrl( 'userprofile', true, array( 'user' => (int) $row->get( 'user_id' ), 'tab' => 'cbgalleryTabFiles' ) ), 'user_url' => $_CB_framework->viewUrl( 'userprofile', true, array( 'user' => (int) $row->get( 'user_id' ) ) ) ); $subject = $cbUser->replaceUserVars( CBTxt::T( 'NOTIFY_NEW_FOLDER_CREATED_SUBJECT', 'Gallery - New [type] Created!', array( '[type]' => $typeTranslated ) ), false, true, $extraStrings, false ); $message = $cbUser->replaceUserVars( CBTxt::T( 'NOTIFY_NEW_FOLDER_CREATED_BODY', '<a href="[user_url]">[formatname]</a> created [folder_type] <a href="[folder_url]">[folder_title]</a> and requires <a href="[folder_tab_url]">approval</a>!' ), false, true, $extraStrings, false ); $notifications = new cbNotification(); $notifications->sendToModerators( $subject, $message, false, 1 ); } cbRedirect( $returnUrl, CBTxt::T( 'FOLDER_SAVED_SUCCESSFULLY_AND_AWAITING_APPROVAL', '[type] saved successfully and awaiting approval!', array( '[type]' => $typeTranslated ) ) ); } else { cbRedirect( $returnUrl, CBTxt::T( 'FOLDER_SAVED_SUCCESSFULLY', '[type] saved successfully!', array( '[type]' => $typeTranslated ) ) ); } }
/** * Sends a PM or Email notification with substitutions based off configuration * * @param int $type 1: Email, 2: PM, 3: Moderators, 4: Auto * @param UserTable|int|null $from * @param UserTable|int|string $to * @param string $subject * @param string $body * @param GroupTable $group * @param array $extra * @return bool */ static public function sendNotification( $type, $from, $to, $subject, $body, $group, $extra = array() ) { global $_CB_framework, $_PLUGINS; if ( ( ! $subject ) || ( ! $body ) || ( ! $group->get( 'id' ) ) || ( $group->get( 'published', 1 ) != 1 ) || ( ! $group->category()->get( 'published', 1 ) ) || ( ! $to ) ) { return false; } if ( $from instanceof UserTable ) { $fromUser = $from; } elseif ( is_int( $from ) ) { $fromUser = \CBuser::getUserDataInstance( $from ); } else { $fromUser = null; } if ( $to instanceof UserTable ) { $toUser = $to; } elseif ( is_int( $to ) ) { $toUser = \CBuser::getUserDataInstance( $to ); } else { $toUser = null; } if ( $fromUser && $toUser && ( $fromUser->get( 'id' ) == $toUser->get( 'id' ) ) ) { return false; } static $plugin = null; static $params = null; if ( ! $params ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbgroupjive' ); $params = $_PLUGINS->getPluginParams( $plugin ); } $notifyBy = (int) $params->get( 'notifications_notifyby', 1 ); $fromName = $params->get( 'notifications_from_name', null ); $fromEmail = $params->get( 'notifications_from_address', null ); $cbUser = \CBuser::getInstance( ( $fromUser ? (int) $fromUser->get( 'id' ) : ( $toUser ? (int) $toUser->get( 'id' ) : 0 ) ), false ); $user = $cbUser->getUserData(); $extras = array( 'category_id' => (int) $group->category()->get( 'id' ), 'category_name' => ( $group->category()->get( 'id' ) ? CBTxt::T( $group->category()->get( 'name' ) ) : CBTxt::T( 'Uncategorized' ) ), 'category' => '<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $group->get( 'category' ) ) ) . '">' . ( $group->category()->get( 'id' ) ? CBTxt::T( $group->category()->get( 'name' ) ) : CBTxt::T( 'Uncategorized' ) ) . '</a>', 'group_id' => (int) $group->get( 'id' ), 'group_name' => htmlspecialchars( CBTxt::T( $group->get( 'name' ) ) ), 'group' => '<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $group->get( 'name' ) ) ) . '</a>', 'user' => '<a href="' . $_CB_framework->viewUrl( 'userprofile', false, array( 'user' => (int) $user->get( 'id' ) ) ) . '">' . getNameFormat( $user->get( 'name' ), $user->get( 'username' ), Application::Config()->get( 'name_format', 3 ) ) . '</a>' ); if ( ! $toUser ) { $extras['email'] = $to; $extras['name'] = $to; $extras['username'] = $to; } $extras = array_merge( $extras, $extra ); $subject = $cbUser->replaceUserVars( $subject, true, false, $extras, false ); $body = $cbUser->replaceUserVars( $body, false, false, $extras, false ); if ( $type == 4 ) { $type = ( $notifyBy == 2 ? 2 : 1 ); } $notification = new \cbNotification(); if ( $type == 3 ) { // Moderator Notification: $notification->sendToModerators( $subject, $body, false, 1 ); } elseif ( ( $type == 2 ) && $toUser ) { // PM Notification: if ( ! $toUser->get( 'id' ) ) { return false; } $notification->sendUserPMSmsg( $toUser, 0, $subject, $body, true, false, 1, $extras ); } else { // Email Notification: if ( $toUser ) { if ( ! $toUser->get( 'id' ) ) { return false; } $notification->sendFromSystem( $toUser, $subject, $body, 1, 1, null, null, null, $extras, true, $fromName, $fromEmail ); } else { $userTo = new UserTable(); $userTo->set( 'email', $to ); $userTo->set( 'name', $to ); $userTo->set( 'username', $to ); $notification->sendFromSystem( $userTo, $subject, $body, 1, 1, null, null, null, $extras, true, $fromName, $fromEmail ); } } return true; }
/** * Outputs legacy user mass mailer and user reconfirm email display * * @param string $option * @param string $task * @param int[] $cid * @return bool * @deprecated 2.0 */ public function showUsers($option, $task, $cid) { global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS; cbimport('language.all'); cbimport('cb.tabs'); cbimport('cb.params'); cbimport('cb.pagination'); cbimport('cb.lists'); // We just need the user rows as we've already filtered down the IDs in user management: $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler') . " AS c" . "\n INNER JOIN " . $_CB_database->NameQuote('#__users') . " AS u" . ' ON u.' . $_CB_database->NameQuote('id') . ' = c.' . $_CB_database->NameQuote('id') . "\n WHERE u." . $_CB_database->NameQuote('id') . " IN ( " . implode(', ', cbArrayToInts($cid)) . " )"; $_CB_database->setQuery($query); $rows = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\UserTable', array($_CB_database)); $total = count($rows); if ($task == 'resendconfirmationemails') { if (!$rows) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => $task)), 'error'); } $count = 0; /** @var UserTable[] $rows */ foreach ($rows as $row) { if ($row->confirmed == 0) { if ($row->cbactivation == '') { // Generate a new confirmation code if the user doesn't have one (requires email confirmation to be enabled): $row->store(); } $cbNotification = new cbNotification(); $cbNotification->sendFromSystem($row->id, CBTxt::T($ueConfig['reg_pend_appr_sub']), CBTxt::T($ueConfig['reg_pend_appr_msg']), true, isset($ueConfig['reg_email_html']) ? (int) $ueConfig['reg_email_html'] : 0); ++$count; } } cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SENT_CONFIRMATION_EMAILS_TO_NUM_USERS_USERS', 'Sent confirmation emails to [NUM_USERS] users', array('[NUM_USERS]' => $count))); } else { $emailSubject = stripslashes(cbGetParam($_POST, 'emailsubject', '')); $emailBody = stripslashes(rawurldecode(cbGetParam($_POST, 'emailbody', '', _CB_ALLOWRAW | _CB_NOTRIM))); $emailAttach = stripslashes(cbGetParam($_POST, 'emailattach', '')); $emailsPerBatch = stripslashes(cbGetParam($_POST, 'emailsperbatch', 50)); $emailsBatch = stripslashes(cbGetParam($_POST, 'emailsbatch', 0)); $emailFromName = stripslashes(cbGetParam($_POST, 'emailfromname', '')); $emailFromAddr = stripslashes(cbGetParam($_POST, 'emailfromaddr', '')); $emailReplyName = stripslashes(cbGetParam($_POST, 'emailreplyname', '')); $emailReplyAddr = stripslashes(cbGetParam($_POST, 'emailreplyaddr', '')); $emailPause = stripslashes(cbGetParam($_POST, 'emailpause', 30)); $simulationMode = stripslashes(cbGetParam($_POST, 'simulationmode', '')); // B/C trigger variables: if (count($cid) > 0 && count($cid) < $total) { $total = count($cid); } $pageNav = new cbPageNav($total, 0, 10); $search = ''; $lists = array(); $inputTextExtras = null; $select_tag_attribs = null; if ($task == 'emailusers') { if (!$rows) { cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => $task)), 'error'); } $pluginRows = $_PLUGINS->trigger('onBeforeBackendUsersEmailForm', array(&$rows, &$pageNav, &$search, &$lists, &$cid, &$emailSubject, &$emailBody, &$inputTextExtras, &$select_tag_attribs, $simulationMode, $option, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr)); $usersView = _CBloadView('users'); /** @var CBView_users $usersView */ $usersView->emailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows); } elseif ($task == 'startemailusers') { $pluginRows = $_PLUGINS->trigger('onBeforeBackendUsersEmailStart', array(&$rows, $total, $search, $lists, $cid, &$emailSubject, &$emailBody, &$inputTextExtras, $simulationMode, $option, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr)); $usersView = _CBloadView('users'); /** @var CBView_users $usersView */ $usersView->startEmailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows); } elseif ($task == 'ajaxemailusers') { cbSpoofCheck('cbadmingui'); cbRegAntiSpamCheck(); $cbNotification = new cbNotification(); $mode = 1; // html $errors = 0; $success = array(); $failed = array(); $users = array_slice($rows, $emailsBatch, $emailsPerBatch); if ($simulationMode) { $success = array('<div class="alert alert-info">' . CBTxt::T('Emails do not send in simulation mode') . '</div>'); } else { foreach ($users as $user) { $extraStrings = array(); $_PLUGINS->trigger('onBeforeBackendUserEmail', array(&$user, &$emailSubject, &$emailBody, $mode, &$extraStrings, $simulationMode, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr)); $attachments = cbReplaceVars($emailAttach, $user, $mode, true, $extraStrings); if ($attachments) { $attachments = preg_split(' *, *', $attachments); } else { $attachments = null; } if (!$cbNotification->sendFromSystem($user, $emailSubject, $this->makeLinksAbsolute($emailBody), true, $mode, null, null, $attachments, $extraStrings, false, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr)) { $failed[] = '<div class="alert alert-danger">' . '<strong>' . htmlspecialchars($user->name . ' <' . $user->email . '>') . '</strong>: ' . CBTxt::Th('ERROR_SENDING_EMAIL_ERRORMSG', 'Error sending email: [ERROR_MSG]', array('[ERROR_MSG]' => $cbNotification->errorMSG)) . '</div>'; ++$errors; } else { $success[] = htmlspecialchars($user->name . ' <' . $user->email . '>'); } } } $usernames = implode(', ', $success) . implode('', $failed); if ($total < $emailsPerBatch) { $limit = $total; } else { $limit = $emailsPerBatch; } ob_start(); $usersView = _CBloadView('users'); /** @var CBView_users $usersView */ $usersView->ajaxResults($usernames, $emailSubject, $this->makeLinksAbsolute($emailBody), $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsBatch, $limit, $total, $errors); $html = ob_get_contents(); ob_end_clean(); $reply = array('result' => 1, 'htmlcontent' => $html); if (!($total - ((int) $emailsBatch + (int) $emailsPerBatch) > 0)) { $reply['result'] = 2; } echo json_encode($reply); } } }
function pgNotify($id,$user,$notification_action) { global $_CB_framework, $res_1, $res_2, $res_3; $res_1 = $res_2 = $res_3 = true; switch ($notification_action) { case 'MODERATOR-APPROVE': // Notify end user about approval $tabparams = $this->_pgGetTabParameters($user); if($tabparams["pgmoderatornotification"] && ($_CB_framework->myId() != $user->id)){ $cbNotification = new cbNotification(); $messagebody = CBTxt::Th("A Gallery item in your Gallery Tab has just been approved by a moderator.\n\n\n" ."Please do not respond to this message as it is automatically generated and is for information purposes only\n" ); //eval ("\$messagebody = \"$messagebody\";"); if (!$cbNotification->sendFromSystem($user->id,CBTxt::Th("Your Gallery Item has been approved!"),$messagebody)) { $this->_setErrorMSG("CB Gallery failed to send user email approval notification"); $res_1 = false; } } break; case 'MODERATOR-DELETE': // Notify end-user about deletion $tabparams = $this->_pgGetTabParameters($user); if($tabparams["pgmoderatornotification"] && ($_CB_framework->myId() != $user->id)){ $cbNotification = new cbNotification(); $messagebody = CBTxt::Th("A Gallery item in your Gallery Tab has just been deleted by a moderator.\n\n\n" ."If you feel that this action is unjustified please contact one of our moderators.\n" ."Please do not respond to this message as it is automatically generated and is for information purposes only\n" ); //eval ("\$messagebody = \"$messagebody\";"); if (!$cbNotification->sendFromSystem($user->id,CBTxt::Th("Your Gallery Item has been deleted!"),$messagebody)) { $this->_setErrorMSG("CB Gallery failed to send moderation deletion email"); $res_2 = false; } } break; case 'MODERATOR-REVOKE': // Notify end-user about item revoke $tabparams = $this->_pgGetTabParameters($user); if($tabparams["pgmoderatornotification"] && ($_CB_framework->myId() != $user->id)){ $cbNotification = new cbNotification(); $messagebody = CBTxt::Th("A Gallery item in your Gallery Tab has just been revoked by a moderator.\n\n\n" ."If you feel that this action is unjustified please contact one of our moderators.\n" ."Please do not respond to this message as it is automatically generated and is for information purposes only\n" ); //eval ("\$messagebody = \"$messagebody\";"); if (!$cbNotification->sendFromSystem($user->id,CBTxt::Th("Your Gallery Item has been revoked!"),$messagebody)) { $this->_setErrorMSG("CB Gallery failed to send moderation revocation email"); $res_3 = false; } } break; default: break; } if (!($res_1 && $res_2 && $res_3)) { $this->raiseError(0); } return $res_1 && $res_2 && $res_3; }
/** * Prepares field data for saving to database (safe transfer from $postdata to $user) * Override * * @param moscomprofilerFields $field * @param moscomprofilerUser $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save profile edit, 'register' for registration, 'search' for searches */ function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) { global $_CB_framework, $ueConfig, $_PLUGINS, $_FILES; $this->_prepareFieldMetaSave( $field, $user, $postdata, $reason ); $col = $field->name; $colapproved = $col . 'approved'; $col_choice = $col . '__choice'; $col_file = $col . '__file'; $col_gallery = $col . '__gallery'; $choice = stripslashes( cbGetParam( $postdata, $col_choice ) ); switch ( $choice ) { case 'upload': $value = ( isset( $_FILES[$col_file] ) ? $_FILES[$col_file] : null ); if ( $this->validate( $field, $user, $choice, $value, $postdata, $reason ) ) { $_PLUGINS->loadPluginGroup( 'user' ); $isModerator = isModerator( $_CB_framework->myId() ); $_PLUGINS->trigger( 'onBeforeUserAvatarUpdate', array( &$user, &$user, $isModerator, &$value['tmp_name'] ) ); if ( $_PLUGINS->is_errors() ) { $this->_setErrorMSG( $_PLUGINS->getErrorMSG() ); } $imgToolBox = new imgToolBox(); $imgToolBox->_conversiontype = $ueConfig['conversiontype']; $imgToolBox->_IM_path = $ueConfig['im_path']; $imgToolBox->_NETPBM_path = $ueConfig['netpbm_path']; $imgToolBox->_maxsize = $this->_getImageFieldParam( $field, 'avatarSize' ); $imgToolBox->_maxwidth = $this->_getImageFieldParam( $field, 'avatarWidth' ); $imgToolBox->_maxheight = $this->_getImageFieldParam( $field, 'avatarHeight' ); $imgToolBox->_thumbwidth = $this->_getImageFieldParam( $field, 'thumbWidth' ); $imgToolBox->_thumbheight = $this->_getImageFieldParam( $field, 'thumbHeight' ); $imgToolBox->_debug = 0; $allwaysResize = ( isset( $ueConfig['avatarResizeAlways'] ) ? $ueConfig['avatarResizeAlways'] : 1 ); $fileNameInDir = ( $col == 'avatar' ? '' : $col . '_' ) . uniqid( $user->id . '_' ); $newFileName = $imgToolBox->processImage( $value, $fileNameInDir, $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/', 0, 0, 1, $allwaysResize ); if ( ! $newFileName ) { $this->_setValidationError( $field, $user, $reason, $imgToolBox->_errMSG ); // needed if uploaded file fails in imgToolbox //BB: maybe this needed instead ? : // $this->_setErrorMSG( $imgToolBox->_errMSG ); return; } if ( isset( $user->$col ) && ! ( ( $col == 'avatar' ) && ( $ueConfig['avatarUploadApproval'] == 1 ) && ( $isModerator == 0 ) ) ) { // if auto-approved: //TBD: else need to log update on image approval ! $this->_logFieldUpdate( $field, $user, $reason, $user->$col, $newFileName ); } if ( isset( $user->$col ) && ( $user->$col != '' ) ) { deleteAvatar( $user->$col ); } if ( ( $col == 'avatar' ) && ( $ueConfig['avatarUploadApproval'] == 1 ) && ( $isModerator == 0 ) ) { $cbNotification = new cbNotification(); $cbNotification->sendToModerators( _UE_IMAGE_ADMIN_SUB, _UE_IMAGE_ADMIN_MSG ); $user->$col = $newFileName; $user->$colapproved = 0; } else { $user->$col = $newFileName; $user->$colapproved = 1; } $_PLUGINS->trigger( 'onAfterUserAvatarUpdate', array( &$user, &$user, $isModerator, $newFileName ) ); } break; case 'gallery': $newAvatar = stripslashes( cbGetParam( $postdata, $col_gallery ) ); if ( $this->validate( $field, $user, $choice, $newAvatar, $postdata, $reason ) ) { $value = 'gallery/' . $newAvatar; if ( isset( $user->$col ) ) { $this->_logFieldUpdate( $field, $user, $reason, $user->$col, $value ); } deleteAvatar( $user->$col ); // delete old avatar $user->$col = $value; $user->$colapproved = 1; } break; case 'delete': if ( $user->id && ( $user->$col != null ) && ( $user->$col != '' ) ) { global $_CB_database; if ( isset( $user->$col ) ) { $this->_logFieldUpdate( $field, $user, $reason, $user->$col, '' ); } deleteAvatar( $user->$col ); // delete old avatar $user->$col = null; // this will not update, so we do query below: $user->$colapproved = 1; $query = 'UPDATE ' . $_CB_database->NameQuote( $field->table ) . "\n SET " . $_CB_database->NameQuote( $col ) . ' = NULL' . ', ' . $_CB_database->NameQuote( $col . 'approved' ) . ' = 1' . ', ' . $_CB_database->NameQuote( 'lastupdatedate' ) . ' = ' . $_CB_database->Quote( $_CB_framework->dateDbOfNow() ) . "\n WHERE " . $_CB_database->NameQuote( 'id' ) . ' = ' . (int) $user->id; $_CB_database->setQuery( $query ); $_CB_database->query(); } break; case 'approve': if ( isset( $user->$col ) && ( $_CB_framework->getUi() == 2 ) && $user->id && ( $user->$col != null ) && ( $user->$colapproved == 0 ) ) { $this->_logFieldUpdate( $field, $user, $reason, '', $user->$col ); // here we are missing the old value, so can't give it... $user->$colapproved = 1; $user->lastupdatedate = $_CB_framework->dateDbOfNow(); $cbNotification = new cbNotification(); $cbNotification->sendFromSystem( $user, _UE_IMAGEAPPROVED_SUB, _UE_IMAGEAPPROVED_MSG ); } break; case '': default: $this->validate( $field, $user, $choice, $newAvatar, $postdata, $reason ); break; } }
static function save_avatar_cb($userid, $pic_url) { $pic = JoomdleHelperContent::get_file($pic_url); if (!$pic) { return; } if ($moodle_version == 19) { $extension = '.jpg'; // Moodle stores JPG always in 1.9 $type = 'image/jpeg'; } else { $extension = '.png'; // Moodle stores PNG always in 2.0 $type = 'image/png'; } $newFileName = uniqid($userid . "_") . '.' . $extension; file_put_contents(JPATH_SITE . '/images/comprofiler/' . $newFileName, $pic); $db = JFactory::getDBO(); if ($ueConfig['avatarUploadApproval'] == 1) { $cbNotification = new cbNotification(); $cbNotification->sendToModerators(_UE_IMAGE_ADMIN_SUB, _UE_IMAGE_ADMIN_MSG); $db->setQuery("UPDATE #__comprofiler SET avatar=" . $db->Quote($newFileName) . ", avatarapproved=0 WHERE id=" . (int) $userid); } else { $db->setQuery("UPDATE #__comprofiler SET avatar=" . $db->Quote($newFileName) . ", avatarapproved=1, lastupdatedate=now() WHERE id=" . (int) $userid); } $db->query(); }
function reportUser($option, $form = 1, $uid = 0) { global $_CB_framework, $ueConfig, $_PLUGINS, $_POST; if ($ueConfig['allowUserReports'] == 0) { $msg = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.'); } elseif (!CBuser::getMyInstance()->authoriseView('profile', $uid)) { $msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!'); } else { $msg = null; } $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onBeforeReportUserRequest', array($uid, &$msg, $form)); if ($msg) { $_CB_framework->enqueueMessage($msg, 'error'); return; } $reportedByUser = CBuser::getUserDataInstance($_CB_framework->myId()); $reportedUser = CBuser::getUserDataInstance($uid); if ($form == 1) { $results = $_PLUGINS->trigger('onBeforeReportUserForm', array($uid, &$reportedByUser, &$reportedUser)); if ($_PLUGINS->is_errors()) { $_CB_framework->enqueueMessage($_PLUGINS->getErrorMSG('<br />'), 'error'); return; } if (implode('', $results) != "") { $return = '<div class="cb_template cb_template_' . selectTemplate('dir') . '">' . '<div>' . implode('</div><div>', $results) . '</div>' . '</div>'; echo $return; return; } HTML_comprofiler::reportUserForm($option, $uid, $reportedByUser, $reportedUser); } else { cbSpoofCheck('reportuser'); $row = new UserReportTable(); $_PLUGINS->trigger('onStartSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser)); if ($_PLUGINS->is_errors()) { cbRedirect($_CB_framework->viewUrl('reportuser', false), $_PLUGINS->getErrorMSG(), 'error'); return; } if (!$row->bind($_POST)) { cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error'); return; } $row->reportedondate = htmlspecialchars($row->reportedondate, ENT_QUOTES); //TBD: remove this: not urgent but isn't right $row->reportexplaination = htmlspecialchars($row->reportexplaination, ENT_QUOTES); //TBD: remove this: not urgent but isn't right $row->reportedondate = $_CB_framework->getUTCDate(); if (!$row->check()) { cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error'); return; } $_PLUGINS->trigger('onBeforeSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser)); if (!$row->store()) { cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error'); return; } if ($ueConfig['moderatorEmail'] == 1) { $cbNotification = new cbNotification(); $cbNotification->sendToModerators(CBTxt::T('UE_USERREPORT_SUB', 'User Report Pending Review'), CBTxt::T('UE_USERREPORT_MSG', 'A user has submitted a report regarding a user that requires your review. Please log in and take the appropriate action.')); } $_PLUGINS->trigger('onAfterSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser)); $_CB_framework->enqueueMessage(CBTxt::Th('UE_USERREPORT_SUCCESSFUL', 'User report submitted successfully.')); } }
/** * @param null|int $id * @param UserTable $user * @param stdClass $model * @param PluginTable $plugin */ private function saveBlogEdit( $id, $user, $model, $plugin ) { global $_CB_framework, $_PLUGINS; $blogLimit = (int) $plugin->params->get( 'blog_limit', null ); $cbModerator = Application::User( (int) $user->get( 'id' ) )->isGlobalModerator(); $row = new cbblogsBlogTable(); $canAccess = false; if ( $row->load( (int) $id ) ) { if ( ! $row->get( 'id' ) ) { if ( $cbModerator ) { $canAccess = true; } elseif ( $user->get( 'id' ) && Application::MyUser()->canViewAccessLevel( $plugin->params->get( 'blog_create_access', 2 ) ) ) { if ( ( ! $blogLimit ) || ( $blogLimit && ( cbblogsModel::getBlogsTotal( null, $user, $user, $plugin ) < $blogLimit ) ) ) { $canAccess = true; } } } elseif ( $cbModerator || ( $row->get( 'user' ) == $user->get( 'id' ) ) ) { $canAccess = true; } } $profileUrl = $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), false, 'cbblogsTab' ); if ( $canAccess ) { if ( $plugin->params->get( 'blog_captcha', 0 ) && ( ! $row->get( 'id' ) ) && ( ! $cbModerator ) ) { $_PLUGINS->loadPluginGroup( 'user' ); $_PLUGINS->trigger( 'onCheckCaptchaHtmlElements', array() ); if ( $_PLUGINS->is_errors() ) { $row->setError( CBTxt::T( $_PLUGINS->getErrorMSG() ) ); } } $new = ( $row->get( 'id' ) ? false : true ); if ( ! $row->bind( $_POST ) ) { $this->showBlogEdit( $id, $user, $model, $plugin, CBTxt::T( 'BLOG_FAILED_TO_BIND_ERROR_ERROR', 'Blog failed to bind! Error: [error]', array( '[error]' => $row->getError() ) ) ); return; } if ( ! $row->check() ) { $this->showBlogEdit( $id, $user, $model, $plugin, CBTxt::T( 'BLOG_FAILED_TO_VALIDATE_ERROR_ERROR', 'Blog failed to validate! Error: [error]', array( '[error]' => $row->getError() ) ) ); return; } if ( $row->getError() || ( ! $row->store() ) ) { $this->showBlogEdit( $id, $user, $model, $plugin, CBTxt::T( 'BLOG_FAILED_TO_SAVE_ERROR_ERROR', 'Blog failed to save! Error: [error]', array( '[error]' => $row->getError() ) ) ); return; } if ( $new && ( ! $row->get( 'published' ) ) && $plugin->params->get( 'approval_notify', 1 ) && ( ! $cbModerator ) ) { $cbUser = CBuser::getInstance( (int) $row->get( 'user' ), false ); $extraStrings = array( 'site_name' => $_CB_framework->getCfg( 'sitename' ), 'site' => '<a href="' . $_CB_framework->getCfg( 'live_site' ) . '">' . $_CB_framework->getCfg( 'sitename' ) . '</a>', 'blog_id' => (int) $row->get( 'id' ), 'blog_title' => $row->get( 'title' ), 'blog_intro' => $row->get( 'blog_intro' ), 'blog_full' => $row->get( 'blog_full' ), 'blog_created' => $row->get( 'blog_created' ), 'blog_user' => (int) $row->get( 'user' ), 'blog_url' => cbblogsModel::getUrl( $row ), 'blog_tab_url' => $_CB_framework->viewUrl( 'userprofile', false, array( 'user' => (int) $row->get( 'user_id' ), 'tab' => 'cbblogsTab' ) ), 'user_name' => $cbUser->getField( 'formatname', null, 'html', 'none', 'profile' ), 'user' => '<a href="' . $_CB_framework->viewUrl( 'userprofile', true, array( 'user' => (int) $row->get( 'user_id' ) ) ) . '">' . $cbUser->getField( 'formatname', null, 'html', 'none', 'profile' ) . '</a>' ); $subject = $cbUser->replaceUserVars( CBTxt::T( 'Blogs - New Blog Created!' ), false, true, $extraStrings, false ); $message = $cbUser->replaceUserVars( CBTxt::T( '[user] created [blog_title] and requires <a href="[blog_tab_url]">approval</a>!' ), false, true, $extraStrings, false ); $notifications = new cbNotification(); $notifications->sendToModerators( $subject, $message, false, 1 ); } cbRedirect( $profileUrl, CBTxt::T( 'Blog saved successfully!' ) ); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } }
/** * Logins on host CMS using any allowed authentication methods * * @param string $username The username * @param string|boolean $password Well, The password OR strictly boolean false for login without password * @param boolean $rememberMe If login should be remembered in a cookie to be sent back to user's browser * @param boolean $message If an alert message should be prepared on successful login * @param string $return IN & OUT: IN: return URL NOT SEFED for normal login completition (unless an event says different), OUT: redirection url (no htmlspecialchars) NOT SEFED * @param array $messagesToUser OUT: messages to display to user (html) * @param array $alertMessages OUT: messages to alert to user (text) * @param int $loginType 0: username, 1: email, 2: username or email, 3: username, email or CMS authentication * @param string $secretKey secretKey used for two step authentication * @return string Error message if error */ public function login($username, $password, $rememberMe, $message, &$return, &$messagesToUser, &$alertMessages, $loginType = 0, $secretKey = null) { global $_CB_framework, $ueConfig, $_PLUGINS; $returnURL = null; $loggedIn = false; if (!$username || !$password && $password !== false) { $resultError = CBTxt::T('LOGIN_INCOMPLETE', 'Please complete the username and password fields.'); } else { $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onBeforeLogin', array(&$username, &$password, &$secretKey)); $resultError = null; $showSysMessage = true; $stopLogin = false; $firstLogin = false; $row = new UserTable(); if ($_PLUGINS->is_errors()) { $resultError = $_PLUGINS->getErrorMSG(); } else { $foundUser = false; // Try login by CB authentication trigger: $_PLUGINS->trigger('onLoginAuthentication', array(&$username, &$password, &$row, $loginType, &$foundUser, &$stopLogin, &$resultError, &$messagesToUser, &$alertMessages, &$return, &$secretKey)); if (!$foundUser) { if ($loginType != 2) { // login by username: $foundUser = $row->loadByUsername($username) && ($password === false || $row->verifyPassword($password)); } if (!$foundUser && $loginType >= 1) { // login by email: $foundUser = $row->loadByEmail($username) && ($password === false || $row->verifyPassword($password)); if ($foundUser) { $username = $row->username; } } if (!$foundUser && $loginType > 2) { // If no result, try login by CMS authentication: if ($_CB_framework->login($username, $password, $rememberMe, null, $secretKey)) { $foundUser = $row->load((int) $_CB_framework->myId()); // core user might not have username set, so we use id (bug #3303 fix) $this->cbSplitSingleName($row); $row->confirmed = 1; $row->approved = 1; $row->store(); // synchronizes with comprofiler table $loggedIn = true; } } } if ($foundUser) { $returnPluginsOverrides = null; $pluginResults = $_PLUGINS->trigger('onDuringLogin', array(&$row, 1, &$returnPluginsOverrides)); if ($returnPluginsOverrides) { $return = $returnPluginsOverrides; } if (is_array($pluginResults) && count($pluginResults)) { foreach ($pluginResults as $res) { if (is_array($res)) { if (isset($res['messagesToUser'])) { $messagesToUser[] = $res['messagesToUser']; } if (isset($res['alertMessage'])) { $alertMessages[] = $res['alertMessage']; } if (isset($res['showSysMessage'])) { $showSysMessage = $showSysMessage && $res['showSysMessage']; } if (isset($res['stopLogin'])) { $stopLogin = $stopLogin || $res['stopLogin']; } } } } if ($_PLUGINS->is_errors()) { $resultError = $_PLUGINS->getErrorMSG(); } elseif ($stopLogin) { // login stopped: don't even check for errors... } elseif ($row->approved == 2) { $resultError = CBTxt::T('LOGIN_REJECTED', 'Your sign up request was rejected!'); } elseif ($row->confirmed != 1) { if ($row->cbactivation == '') { $row->store(); // just in case the activation code was missing } $cbNotification = new cbNotification(); $cbNotification->sendFromSystem($row->id, CBTxt::T(stripslashes($ueConfig['reg_pend_appr_sub'])), CBTxt::T(stripslashes($ueConfig['reg_pend_appr_msg'])), true, isset($ueConfig['reg_email_html']) ? (int) $ueConfig['reg_email_html'] : 0); $resultError = CBTxt::T('LOGIN_NOT_CONFIRMED', 'Your sign up process is not yet complete! Please check again your email for further instructions that have just been resent. If you don\'t find the email, check your spam-box. Make sure that your email account options are not set to immediately delete spam. If that was the case, just try logging in again to receive a new instructions email.'); } elseif ($row->approved == 0) { $resultError = CBTxt::T('LOGIN_NOT_APPROVED', 'Your account has not yet been approved!'); } elseif ($row->block == 1) { $resultError = CBTxt::T('LOGIN_BLOCKED', 'Your login is blocked.'); } elseif ($row->lastvisitDate == '0000-00-00 00:00:00') { $firstLogin = true; if (isset($ueConfig['reg_first_visit_url']) and $ueConfig['reg_first_visit_url'] != "") { $return = $ueConfig['reg_first_visit_url']; } else { if ($returnPluginsOverrides) { $return = $returnPluginsOverrides; // by default return to homepage on first login (or on page overridden by plugin). } } $_PLUGINS->trigger('onBeforeFirstLogin', array(&$row, $username, $password, &$return, $secretKey)); if ($_PLUGINS->is_errors()) { $resultError = $_PLUGINS->getErrorMSG("<br />"); } } } else { if ($loginType < 2) { $resultError = CBTxt::T('LOGIN_INCORRECT_USER_NOT_FOUND LOGIN_INCORRECT', 'Incorrect username or password. Please try again.'); } else { $resultError = CBTxt::T('UE_INCORRECT_EMAIL_OR_PASSWORD', 'Incorrect email or password. Please try again.'); } } } if ($resultError) { if ($showSysMessage) { $alertMessages[] = $resultError; } } elseif (!$stopLogin) { if (!$loggedIn) { $_PLUGINS->trigger('onDoLoginNow', array($username, $password, $rememberMe, &$row, &$loggedIn, &$resultError, &$messagesToUser, &$alertMessages, &$return, $secretKey)); } if (!$loggedIn) { $_CB_framework->login($username, $password, $rememberMe, null, $secretKey); $loggedIn = true; } if ($firstLogin) { $_PLUGINS->trigger('onAfterFirstLogin', array(&$row, $loggedIn)); } $_PLUGINS->trigger('onAfterLogin', array(&$row, $loggedIn)); if ($loggedIn && $message && $showSysMessage) { $alertMessages[] = CBTxt::T('LOGIN_SUCCESS', 'You have successfully logged in'); } if (!$loggedIn) { $resultError = CBTxt::T('LOGIN_INCORRECT_USER_AUTHENTICATION_FAILED LOGIN_INCORRECT', 'Incorrect username or password. Please try again.'); } // changing com_comprofiler to comprofiler is a quick-fix for SEF ON on return path... if ($return && !(strpos($return, 'comprofiler') && (strpos($return, 'login') || strpos($return, 'logout') || strpos($return, 'registers') || strpos(strtolower($return), 'lostpassword')))) { // checks for the presence of a return url // and ensures that this url is not the registration or login pages $returnURL = $return; } elseif (!$returnURL) { $returnURL = 'index.php'; } } } if (!$loggedIn) { $_PLUGINS->trigger('onLoginFailed', array(&$resultError, &$returnURL)); } $return = $returnURL; return $resultError; }
/** * Mutator: * Prepares field data commit * Override * * @param FieldTable $field * @param UserTable $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save user edit, 'register' for save registration */ public function commitFieldDataSave(&$field, &$user, &$postdata, $reason) { global $_CB_framework, $ueConfig, $_PLUGINS, $_FILES; $col = $field->name; $colapproved = $col . 'approved'; $col_choice = $col . '__choice'; $col_file = $col . '__file'; $choice = stripslashes(cbGetParam($postdata, $col_choice)); switch ($choice) { case 'upload': $value = isset($_FILES[$col_file]) ? $_FILES[$col_file] : null; if ($this->validate($field, $user, $choice, $value, $postdata, $reason)) { $_PLUGINS->loadPluginGroup('user'); $isModerator = Application::MyUser()->isModeratorFor(Application::User((int) $user->id)); $_PLUGINS->trigger('onBeforeUserAvatarUpdate', array(&$user, &$user, $isModerator, &$value['tmp_name'])); if ($_PLUGINS->is_errors()) { $this->_setErrorMSG($_PLUGINS->getErrorMSG()); } $conversionType = (int) (isset($ueConfig['conversiontype']) ? $ueConfig['conversiontype'] : 0); $imageSoftware = $conversionType == 5 ? 'gmagick' : ($conversionType == 1 ? 'imagick' : 'gd'); $imagePath = $_CB_framework->getCfg('absolute_path') . '/images/comprofiler/'; $fileName = ($col == 'avatar' ? '' : $col . '_') . uniqid($user->id . '_'); try { $image = new \CBLib\Image\Image($imageSoftware, $this->_getImageFieldParam($field, 'avatarResizeAlways', 1), $this->_getImageFieldParam($field, 'avatarMaintainRatio', 1)); $image->setName($fileName); $image->setSource($value); $image->setDestination($imagePath); $image->processImage($this->_getImageFieldParam($field, 'avatarWidth', 200), $this->_getImageFieldParam($field, 'avatarHeight', 500)); $newFileName = $image->getCleanFilename(); $image->setName('tn' . $fileName); $image->processImage($this->_getImageFieldParam($field, 'thumbWidth', 60), $this->_getImageFieldParam($field, 'thumbHeight', 86)); } catch (Exception $e) { $this->_setValidationError($field, $user, $reason, $e->getMessage()); return; } $uploadApproval = $this->_getImageFieldParam($field, 'avatarUploadApproval', 1); if (isset($user->{$col}) && !($uploadApproval == 1 && !$isModerator)) { // if auto-approved: //TBD: else need to log update on image approval ! $this->_logFieldUpdate($field, $user, $reason, $user->{$col}, $newFileName); } if (isset($user->{$col}) && $user->{$col} != '') { deleteAvatar($user->{$col}); } if ($uploadApproval == 1 && !$isModerator) { $cbNotification = new cbNotification(); $cbNotification->sendToModerators(cbReplaceVars(CBTxt::T('UE_IMAGE_ADMIN_SUB', 'Image Pending Approval'), $user), cbReplaceVars(CBTxt::T('UE_IMAGE_ADMIN_MSG', 'A user has submitted an image for approval. Please log in and take the appropriate action.'), $user)); $user->{$col} = $newFileName; $user->{$colapproved} = 0; } else { $user->{$col} = $newFileName; $user->{$colapproved} = 1; } $_PLUGINS->trigger('onAfterUserAvatarUpdate', array(&$user, &$user, $isModerator, $newFileName)); } break; } }
/** * Mutator: * Prepares field data commit * Override * * @param moscomprofilerFields $field * @param moscomprofilerUser $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save user edit, 'register' for save registration */ function commitFieldDataSave(&$field, &$user, &$postdata, $reason) { global $_CB_framework, $ueConfig, $_PLUGINS, $_FILES; $col = $field->name; $colapproved = $col . 'approved'; $col_choice = $col . '__choice'; $col_file = $col . '__file'; $choice = stripslashes(cbGetParam($postdata, $col_choice)); switch ($choice) { case 'upload': $value = isset($_FILES[$col_file]) ? $_FILES[$col_file] : null; if ($this->validate($field, $user, $choice, $value, $postdata, $reason)) { $_PLUGINS->loadPluginGroup('user'); $isModerator = isModerator($_CB_framework->myId()); $_PLUGINS->trigger('onBeforeUserAvatarUpdate', array(&$user, &$user, $isModerator, &$value['tmp_name'])); if ($_PLUGINS->is_errors()) { $this->_setErrorMSG($_PLUGINS->getErrorMSG()); } $imgToolBox = new imgToolBox(); $imgToolBox->_conversiontype = $ueConfig['conversiontype']; $imgToolBox->_IM_path = $ueConfig['im_path']; $imgToolBox->_NETPBM_path = $ueConfig['netpbm_path']; $imgToolBox->_maxsize = $this->_getImageFieldParam($field, 'avatarSize'); $imgToolBox->_maxwidth = $this->_getImageFieldParam($field, 'avatarWidth'); $imgToolBox->_maxheight = $this->_getImageFieldParam($field, 'avatarHeight'); $imgToolBox->_thumbwidth = $this->_getImageFieldParam($field, 'thumbWidth'); $imgToolBox->_thumbheight = $this->_getImageFieldParam($field, 'thumbHeight'); $imgToolBox->_debug = 0; $allwaysResize = isset($ueConfig['avatarResizeAlways']) ? $ueConfig['avatarResizeAlways'] : 1; $fileNameInDir = ($col == 'avatar' ? '' : $col . '_') . uniqid($user->id . '_'); $newFileName = $imgToolBox->processImage($value, $fileNameInDir, $_CB_framework->getCfg('absolute_path') . '/images/comprofiler/', 0, 0, 1, $allwaysResize); if (!$newFileName) { $this->_setValidationError($field, $user, $reason, $imgToolBox->_errMSG); // needed if uploaded file fails in imgToolbox //BB: maybe this needed instead ? : // $this->_setErrorMSG( $imgToolBox->_errMSG ); return; } if (isset($user->{$col}) && !($col == 'avatar' && $ueConfig['avatarUploadApproval'] == 1 && $isModerator == 0)) { // if auto-approved: //TBD: else need to log update on image approval ! $this->_logFieldUpdate($field, $user, $reason, $user->{$col}, $newFileName); } if (isset($user->{$col}) && $user->{$col} != '') { deleteAvatar($user->{$col}); } if ($col == 'avatar' && $ueConfig['avatarUploadApproval'] == 1 && $isModerator == 0) { $cbNotification = new cbNotification(); $cbNotification->sendToModerators(cbReplaceVars(_UE_IMAGE_ADMIN_SUB, $user), cbReplaceVars(_UE_IMAGE_ADMIN_MSG, $user)); $user->{$col} = $newFileName; $user->{$colapproved} = 0; } else { $user->{$col} = $newFileName; $user->{$colapproved} = 1; } $_PLUGINS->trigger('onAfterUserAvatarUpdate', array(&$user, &$user, $isModerator, $newFileName)); } break; } }
function _cbadmin_emailUsers( &$rows, $emailSubject, $emailBody, $limitstart, $limit, $total, $simulationMode ) { global $_PLUGINS; // simple spoof check security cbSpoofCheck( 'cbadmingui' ); cbRegAntiSpamCheck(); $cbNotification = new cbNotification(); $mode = 1; // html $usernames = ''; foreach ( $rows as $row ) { $user = CBuser::getUserDataInstance( (int) $row->id ); $usernames .= ( $usernames ? ', ' : '' ) . htmlspecialchars( $user->username ); if ( $simulationMode ) { $usernames .= ' (' . htmlspecialchars( CBTxt::T('email not send: simulation mode') ) . ')'; } else { $extraStrings = array(); $_PLUGINS->trigger( 'onBeforeBackendUserEmail', array( &$user, &$emailSubject, &$emailBody, $mode, &$extraStrings, $simulationMode ) ); if ( ! $cbNotification->sendFromSystem( $user, $emailSubject, $this->_cbadmin_makeLinksAbsolute( $emailBody ), true, $mode, null, null, null, $extraStrings, false ) ) { $usernames .= ': <span class="cb_result_error">' . htmlspecialchars( CBTxt::T('Error sending email!') ) . '</span>'; } } } if ( $total < $limit ) { $limit = $total; } ob_start(); $usersView = _CBloadView( 'users' ); $usersView->ajaxResults( $usernames, $emailSubject, $this->_cbadmin_makeLinksAbsolute( $emailBody ), $limitstart, $limit, $total ); $html = ob_get_contents(); ob_end_clean(); $reply = array( 'result' => 1, 'htmlcontent' => $html ); if ( ! ( $total - ( $limitstart + $limit ) > 0 ) ) { $reply['result'] = 2; } echo json_encode( $reply ); sleep(3); }
/** * Logins on host CMS using any allowed authentication methods * * @param string $username The username * @param string|boolean $password Well, The password OR strictly boolean false for login without password * @param boolean $rememberMe If login should be remembered in a cookie to be sent back to user's browser * @param boolean $message If an alert message should be prepared on successful login * @param string $return IN & OUT: IN: return URL NOT SEFED for normal login completition (unless an event says different), OUT: redirection url (no htmlspecialchars) NOT SEFED * @param array $messagesToUser OUT: messages to display to user (html) * @param array $alertmessages OUT: messages to alert to user (text) * @param int $loginType 0: username, 1: email, 2: username or email, 3: username, email or CMS authentication */ function login( $username, $password, $rememberMe, $message, &$return, &$messagesToUser, &$alertmessages, $loginType = 0 ) { global $_CB_database, $_CB_framework, $ueConfig, $_PLUGINS; $returnURL = null; if ( ( ! $username ) || ( ( ! $password ) && ( $password !== false ) ) ) { $resultError = _LOGIN_INCOMPLETE; } else { $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger( 'onBeforeLogin', array( &$username, &$password ) ); $resultError = null; $showSysMessage = true; $stopLogin = false; $loggedIn = false; if($_PLUGINS->is_errors()) { $resultError = $_PLUGINS->getErrorMSG(); } else { $row = new moscomprofilerUser( $_CB_database ); $foundUser = false; // Try login by CB authentication trigger: $_PLUGINS->trigger( 'onLoginAuthentication', array( &$username, &$password, &$row, $loginType, &$foundUser, &$stopLogin, &$resultError, &$messagesToUser, &$alertmessages, &$return ) ); if ( ! $foundUser ) { if ( $loginType != 2 ) { // login by username: $foundUser = $row->loadByUsername( stripslashes( $username ) ) && ( ( $password === false ) || $row->verifyPassword( $password ) ); } if ( ( ! $foundUser ) && ( $loginType >= 1 ) ) { // login by email: $foundUser = $row->loadByEmail( stripslashes( $username ) ) && ( ( $password === false ) || $row->verifyPassword( $password ) ); if ( $foundUser ) { $username = $row->username; } } if ( ( ! $foundUser ) && ( $loginType > 2 ) ) { // If no result, try login by CMS authentication: if ( $_CB_framework->login( $username, $password, $rememberMe ) ) { $foundUser = $row->loadByUsername( stripslashes( $username ) ); cbSplitSingleName( $row ); $row->confirmed = 1; $row->approved = 1; $row->store(); // synchronizes with comprofiler table $loggedIn = true; } } } if ( $foundUser ) { $returnPluginsOverrides = null; $pluginResults = $_PLUGINS->trigger( 'onDuringLogin', array( &$row, 1, &$returnPluginsOverrides ) ); if ( $returnPluginsOverrides ) { $return = $returnPluginsOverrides; } if ( is_array( $pluginResults ) && count( $pluginResults ) ) { foreach ( $pluginResults as $res ) { if ( is_array( $res ) ) { if ( isset( $res['messagesToUser'] ) ) { $messagesToUser[] = $res['messagesToUser']; } if ( isset( $res['alertMessage'] ) ) { $alertmessages[] = $res['alertMessage']; } if ( isset( $res['showSysMessage'] ) ) { $showSysMessage = $showSysMessage && $res['showSysMessage']; } if ( isset( $res['stopLogin'] ) ) { $stopLogin = $stopLogin || $res['stopLogin']; } } } } if($_PLUGINS->is_errors()) { $resultError = $_PLUGINS->getErrorMSG(); } elseif ( $stopLogin ) { // login stopped: don't even check for errors... } elseif ($row->approved == 2){ $resultError = _LOGIN_REJECTED; } elseif ($row->confirmed != 1){ if ( $row->cbactivation == '' ) { $row->store(); // just in case the activation code was missing } $cbNotification = new cbNotification(); $cbNotification->sendFromSystem($row->id,getLangDefinition(stripslashes($ueConfig['reg_pend_appr_sub'])),getLangDefinition(stripslashes($ueConfig['reg_pend_appr_msg']))); $resultError = _LOGIN_NOT_CONFIRMED; } elseif ($row->approved == 0){ $resultError = _LOGIN_NOT_APPROVED; } elseif ($row->block == 1) { $resultError = _UE_LOGIN_BLOCKED; } elseif ($row->lastvisitDate == '0000-00-00 00:00:00') { if (isset($ueConfig['reg_first_visit_url']) and ($ueConfig['reg_first_visit_url'] != "")) { $return = $ueConfig['reg_first_visit_url']; } else { $return = $returnPluginsOverrides; // by default return to homepage on first login (or on page overridden by plugin). } $_PLUGINS->trigger( 'onBeforeFirstLogin', array( &$row, $username, $password, &$return )); if ($_PLUGINS->is_errors()) { $resultError = $_PLUGINS->getErrorMSG( "<br />" ); } } } else { if ( $loginType < 2 ) { $resultError = _LOGIN_INCORRECT; } else { $resultError = _UE_INCORRECT_EMAIL_OR_PASSWORD; } } } if ( $resultError ) { if ( $showSysMessage ) { $alertmessages[] = $resultError; } } elseif ( ! $stopLogin ) { if ( ! $loggedIn ) { $_PLUGINS->trigger( 'onDoLoginNow', array( $username, $password, $rememberMe, &$row, &$loggedIn, &$resultError, &$messagesToUser, &$alertmessages, &$return ) ); } if ( ! $loggedIn ) { $_CB_framework->login( $username, $password, $rememberMe ); $loggedIn = true; } $_PLUGINS->trigger( 'onAfterLogin', array( &$row, $loggedIn ) ); if ( $loggedIn && $message && $showSysMessage ) { $alertmessages[] = _LOGIN_SUCCESS; } if ( ! $loggedIn ) { $resultError = _LOGIN_INCORRECT; } // changing com_comprofiler to comprofiler is a quick-fix for SEF ON on return path... if ( $return && !( strpos( $return, 'comprofiler' /* 'com_comprofiler' */ ) && ( strpos( $return, 'login') || strpos( $return, 'logout') || strpos( $return, 'registers' ) || strpos( strtolower( $return ), 'lostpassword' ) ) ) ) { // checks for the presence of a return url // and ensures that this url is not the registration or login pages $returnURL = $return; } elseif ( ! $returnURL ) { $returnURL = 'index.php'; } } } $return = $returnURL; return $resultError; }
/** * Activates a user * user plugins must have been loaded * * @param UserTable $user * @param int $ui 1=frontend, 2=backend, 0=no UI: machine-machine UI * @param string $cause (one of: 'UserRegistration', 'UserConfirmation', 'UserApproval', 'NewUser', 'UpdateUser') * @param boolean $mailToAdmins true if the standard new-user email should be sent to admins if moderator emails are enabled * @param boolean $mailToUser true if the welcome new user email (from CB config) should be sent to the new user * @param boolean $triggerBeforeActivate * @return array Texts to display */ function activateUser(&$user, $ui, $cause, $mailToAdmins = true, $mailToUser = true, $triggerBeforeActivate = true) { global $ueConfig, $_PLUGINS; static $notificationsSent = array(); $activate = $user->confirmed && $user->approved == 1; $showSysMessage = true; $savedLanguage = CBTxt::setLanguage($user->getUserLanguage()); $messagesToUser = getActivationMessage($user, $cause); CBTxt::setLanguage($savedLanguage); if ($cause == 'UserConfirmation' && $user->approved == 0) { $activate = false; $msg = array('emailAdminSubject' => array('sys' => CBTxt::T('UE_REG_ADMIN_PA_SUB', 'ACTION REQUIRED! New user sign up request pending approval')), 'emailAdminMessage' => array('sys' => CBTxt::T('UE_REG_ADMIN_PA_MSG', "A new user has signed up at [SITEURL] and requires approval.\nThis email contains their details\n\nName - [NAME]\nE-mail - [EMAILADDRESS]\nUsername - [USERNAME]\n\n\nPlease do not respond to this message as it is automatically generated and is for informational purposes only.\n")), 'emailUserSubject' => array(), 'emailUserMessage' => array()); } elseif ($user->confirmed == 0) { $msg = array('emailAdminSubject' => array(), 'emailAdminMessage' => array()); $savedLanguage = CBTxt::setLanguage($user->getUserLanguage()); $msg['emailUserSubject'] = array('sys' => CBTxt::T(stripslashes($ueConfig['reg_pend_appr_sub']))); $msg['emailUserMessage'] = array('sys' => CBTxt::T(stripslashes($ueConfig['reg_pend_appr_msg']))); CBTxt::setLanguage($savedLanguage); } elseif ($cause == 'SameUserRegistrationAgain') { $activate = false; $msg = array('emailAdminSubject' => array(), 'emailAdminMessage' => array(), 'emailUserSubject' => array(), 'emailUserMessage' => array()); } elseif ($user->confirmed && !($user->approved == 1)) { $msg = array('emailAdminSubject' => array('sys' => CBTxt::T('UE_REG_ADMIN_PA_SUB', 'ACTION REQUIRED! New user sign up request pending approval')), 'emailAdminMessage' => array('sys' => CBTxt::T('UE_REG_ADMIN_PA_MSG', "A new user has signed up at [SITEURL] and requires approval.\nThis email contains their details\n\nName - [NAME]\nE-mail - [EMAILADDRESS]\nUsername - [USERNAME]\n\n\nPlease do not respond to this message as it is automatically generated and is for informational purposes only.\n"))); $savedLanguage = CBTxt::setLanguage($user->getUserLanguage()); $msg['emailUserSubject'] = array('sys' => CBTxt::T(stripslashes($ueConfig['reg_pend_appr_sub']))); $msg['emailUserMessage'] = array('sys' => CBTxt::T(stripslashes($ueConfig['reg_pend_appr_msg']))); CBTxt::setLanguage($savedLanguage); } elseif ($user->confirmed && $user->approved == 1) { $msg = array('emailAdminSubject' => array('sys' => CBTxt::T('UE_REG_ADMIN_SUB', 'New user sign up')), 'emailAdminMessage' => array('sys' => CBTxt::T('UE_REG_ADMIN_MSG', "A new user has signed up at [SITEURL].\nThis email contains their details\n\nName - [NAME]\nE-mail - [EMAILADDRESS]\nUsername - [USERNAME]\n\n\nPlease do not respond to this message as it is automatically generated and is for information purposes only.\n"))); $savedLanguage = CBTxt::setLanguage($user->getUserLanguage()); $msg['emailUserSubject'] = array('sys' => CBTxt::T(stripslashes($ueConfig['reg_welcome_sub']))); $msg['emailUserMessage'] = array('sys' => CBTxt::T(stripslashes($ueConfig['reg_welcome_msg']))); CBTxt::setLanguage($savedLanguage); } $msg['messagesToUser'] = $messagesToUser; if ($triggerBeforeActivate) { $results = $_PLUGINS->trigger('onBeforeUserActive', array(&$user, $ui, $cause, $mailToAdmins, $mailToUser)); if ($_PLUGINS->is_errors() && $ui != 0) { echo $_PLUGINS->getErrorMSG('<br />'); } foreach ($results as $res) { if (is_array($res)) { $activate = $activate && $res['activate']; $mailToAdmins = $mailToAdmins && $res['mailToAdmins']; $mailToUser = $mailToUser && $res['mailToUser']; $showSysMessage = $showSysMessage && $res['showSysMessage']; foreach (array_keys($msg) as $key) { if (isset($res[$key]) && $res[$key]) { array_push($msg[$key], $res[$key]); } } } } if (!($mailToAdmins && $ueConfig['moderatorEmail'] == 1)) { unset($msg['emailAdminSubject']['sys']); unset($msg['emailAdminMessage']['sys']); } if (!$mailToUser) { unset($msg['emailUserSubject']['sys']); unset($msg['emailUserMessage']['sys']); } if (!$showSysMessage) { unset($msg['messagesToUser']['sys']); } } if ($activate) { $user->block = 0; $user->storeBlock(false); $user->removeActivationCode(); } if ($activate) { $_PLUGINS->trigger('onUserActive', array(&$user, $ui, $cause, $mailToAdmins, $mailToUser)); if ($_PLUGINS->is_errors() && $ui != 0) { $msg['messagesToUser'] = $_PLUGINS->getErrorMSG('<br />') . $msg['messagesToUser']; } } if (!isset($notificationsSent[$user->id][$user->confirmed][$user->approved][$user->block])) { // in case done several times (e.g. plugins), avoid resending messages. $cbNotification = new cbNotification(); if ($ueConfig['moderatorEmail'] && count($msg['emailAdminMessage'])) { $pwd = $user->password; $user->password = null; $cbNotification->sendToModerators(implode(', ', $msg['emailAdminSubject']), $cbNotification->_replaceVariables(implode('\\n\\n', $msg['emailAdminMessage']), $user)); $user->password = $pwd; } if (count($msg['emailUserMessage'])) { $cbNotification->sendFromSystem($user, implode(', ', $msg['emailUserSubject']), implode('\\n\\n', $msg['emailUserMessage']), true, isset($ueConfig['reg_email_html']) ? (int) $ueConfig['reg_email_html'] : 0); } $notificationsSent[$user->id][$user->confirmed][$user->approved][$user->block] = true; } return $msg['messagesToUser']; }
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; }