本文整理汇总了PHP中CBuser::getUserDataInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP CBuser::getUserDataInstance方法的具体用法?PHP CBuser::getUserDataInstance怎么用?PHP CBuser::getUserDataInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuser
的用法示例。
在下文中一共展示了CBuser::getUserDataInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCBpluginComponent
/**
* @param TabTable $tab Current tab
* @param UserTable $user Current user
* @param int $ui 1 front, 2 admin UI
* @param array $postdata Raw unfiltred POST data
* @return string HTML
*/
public function getCBpluginComponent($tab, $user, $ui, $postdata)
{
global $_CB_framework;
outputCbJs(1);
outputCbTemplate(1);
$plugin = cbblogsClass::getPlugin();
$model = cbblogsClass::getModel();
$action = $this->input('action', null, GetterInterface::STRING);
$function = $this->input('func', null, GetterInterface::STRING);
$id = $this->input('id', null, GetterInterface::INT);
$user = CBuser::getUserDataInstance($_CB_framework->myId());
$tab = new TabTable();
$tab->load(array('pluginid' => (int) $plugin->id));
$profileUrl = $_CB_framework->userProfileUrl($user->get('id'), false, 'cbblogsTab');
if (!($tab->enabled && Application::MyUser()->canViewAccessLevel($tab->viewaccesslevel))) {
cbRedirect($profileUrl, CBTxt::T('Not authorized.'), 'error');
}
ob_start();
switch ($action) {
case 'blogs':
switch ($function) {
case 'new':
$this->showBlogEdit(null, $user, $model, $plugin);
break;
case 'edit':
$this->showBlogEdit($id, $user, $model, $plugin);
break;
case 'save':
cbSpoofCheck('plugin');
$this->saveBlogEdit($id, $user, $model, $plugin);
break;
case 'publish':
$this->stateBlog(1, $id, $user, $model, $plugin);
break;
case 'unpublish':
$this->stateBlog(0, $id, $user, $model, $plugin);
break;
case 'delete':
$this->deleteBlog($id, $user, $model, $plugin);
break;
case 'show':
default:
if ($model->type != 2) {
cbRedirect(cbblogsModel::getUrl((int) $id, false));
} else {
$this->showBlog($id, $user, $model, $plugin);
}
break;
}
break;
default:
cbRedirect($profileUrl, CBTxt::T('Not authorized.'), 'error');
break;
}
$html = ob_get_contents();
ob_end_clean();
$class = $plugin->params->get('general_class', null);
$return = '<div id="cbBlogs" class="cbBlogs' . ($class ? ' ' . htmlspecialchars($class) : null) . '">' . '<div id="cbBlogsInner" class="cbBlogsInner">' . $html . '</div>' . '</div>';
echo $return;
}
示例2: check
public function check()
{
if ($this->get('title') == '') {
$this->setError(CBTxt::T('Title not specified!'));
return false;
} elseif (!$this->get('user')) {
$this->setError(CBTxt::T('User not specified!'));
return false;
} elseif ($this->get('user') && !CBuser::getUserDataInstance((int) $this->get('user'))->id) {
$this->setError(CBTxt::T('User specified does not exist!'));
return false;
} elseif ($this->get('access') === '') {
$this->setError(CBTxt::T('Access not specified!'));
return false;
} elseif ($this->get('category') === '') {
$this->setError(CBTxt::T('Category not specified!'));
return false;
} elseif (!in_array($this->get('category'), cbblogsModel::getCategoriesList(true))) {
$this->setError(CBTxt::T('Category not allowed!'));
return false;
}
return true;
}
示例3: _getUsersSubscriptions
/**
* Gets all subscriptions of $user for $plans having $statuses
* $plans and $statuses can be null or empty array() meaning that condition is ignored
*
* @param int $userId
* @param int[]|null $plans
* @param string[]|null $statuses
* @return cbpaidSomething[]
*/
private function _getUsersSubscriptions( $userId, $plans, $statuses ) {
$subsOfPlansStatus = array();
if ( $userId ) {
// get list of plan_id of all active and inactive subscriptions:
$user = CBuser::getUserDataInstance( $userId );
$subsByPlanType = cbpaidSomethingMgr::getAllSomethingOfUser( $user, null );
foreach ( $subsByPlanType as $subs ) {
foreach ( $subs as $subscription ) {
// $subscription = NEW cbpaidSomething();
if ( ( ( $plans == null ) || in_array( $subscription->plan_id, $plans ) )
&& ( ( $statuses == null ) || in_array( $subscription->status, $statuses ) ) ) {
$subsOfPlansStatus[] = $subscription;
}
}
}
}
return $subsOfPlansStatus;
}
示例4: saveUser
/**
* Saves legacy user edit display
*
* @param string $option
* @param string $task
*/
public function saveUser($option, $task = 'save')
{
global $_CB_framework, $_CB_Backend_task, $_POST, $_PLUGINS;
cbimport('language.all');
cbimport('cb.tabs');
cbimport('cb.params');
cbimport('cb.adminfilesystem');
cbimport('cb.imgtoolbox');
$userIdPosted = (int) cbGetParam($_POST, 'id', 0);
if ($userIdPosted == 0) {
$_POST['id'] = null;
}
$msg = $this->_authorizedEdit($userIdPosted);
if (!$msg) {
if ($userIdPosted != 0) {
$msg = checkCBpermissions(array($userIdPosted), 'save', true);
} else {
$msg = checkCBpermissions(null, 'save', true);
}
}
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onBeforeUserProfileSaveRequest', array($userIdPosted, &$msg, 2));
}
if ($msg) {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
}
$_PLUGINS->loadPluginGroup('user');
// Get current user state:
if ($userIdPosted != 0) {
$userComplete = CBuser::getUserDataInstance($userIdPosted);
if (!($userComplete && $userComplete->id)) {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('Your profile could not be updated.'), 'error');
}
} else {
$userComplete = new UserTable();
}
// Store new user state:
$saveResult = $userComplete->saveSafely($_POST, $_CB_framework->getUi(), 'edit');
if (!$saveResult) {
$regErrorMSG = $userComplete->getError();
$msg = checkCBpermissions(array((int) $userComplete->id), 'edit', true);
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onBeforeUserProfileEditRequest', array((int) $userComplete->id, &$msg, 2));
}
if ($msg) {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
}
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onAfterUserProfileSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
} else {
$_PLUGINS->trigger('onAfterUserRegistrationSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
}
$_CB_framework->enqueueMessage($regErrorMSG, 'error');
$_CB_Backend_task = 'edit';
// so the toolbar comes up...
$_PLUGINS->loadPluginGroup('user');
// resets plugin errors
$userView = _CBloadView('user');
/** @var CBController_user $userView */
$userView->edituser($userComplete, $option, $userComplete->user_id != null ? 0 : 1, $_POST);
return;
}
// Checks-in the row:
$userComplete->checkin();
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onAfterUserProfileSaved', array(&$userComplete, 2));
} else {
$messagesToUser = array();
$_PLUGINS->trigger('onAfterSaveUserRegistration', array(&$userComplete, &$messagesToUser, 2));
}
if ($task == 'apply') {
cbRedirect($_CB_framework->backendViewUrl('edit', false, array('cid' => (int) $userComplete->user_id)), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
} else {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
}
}
示例5: getUpgradeAndRenewalPossibilities
/**
* Checks for upgrade or renewal possibilities
*
* @param int $ui 1=frontend, 2=backend
* @param int $user_id
* @param int $now system unix time
* @param cbpaidUsersubscriptionRecord[] $subscriptionsReturned RETURNED: current subscriptions
* with ->status = 'A' for active ones and 'X' for expired ones. 'R' unpaid, 'C' cancelled.
* @param array|null $plansToShowOnly array of specific plan numbers to show (so we add these plans if allowed and not spontaneous in frontend
* @param int $subsAccess 0 has only read access, 1 has user access, 2 reserved for future Super-admin access
* @param boolean $plansToShowOnlyDoIncludeChildren Include children with plansToShowOnly
* @return cbPaidProduct[] upgrade possibilities including _renewalDiscount in plan's currency
*/
public function getUpgradeAndRenewalPossibilities($ui, $user_id, $now, &$subscriptionsReturned, $plansToShowOnly = null, $subsAccess = 1, $plansToShowOnlyDoIncludeChildren = false)
{
global $_CB_database, $_CB_framework;
if (!isset($this->_upgradesCache[$user_id])) {
$quantity = 1;
//TBD later !
$paidUserExtension = cbpaidUserExtension::getInstance($user_id);
$subscriptions = $paidUserExtension->getUserSubscriptions(null, true);
$user = CBuser::getUserDataInstance((int) $user_id);
$plansMgr = cbpaidPlansMgr::getInstance();
$plans = $plansMgr->loadPublishedPlans($user, true, 'any', null);
//TBD LATER: upgrades limiting owners
$params = cbpaidApp::settingsParams();
$enableFreeRegisteredUser = $params->get('enableFreeRegisteredUser', 1);
$createAlsoFreeSubscriptions = $params->get('createAlsoFreeSubscriptions', 0);
$noValidSubscriptionFound = true;
$subscriptionsUpgradePlansIdsDiscount = array();
// array: [$k][$upgrade_plan->id]=discountedPrice where $l is index in $subscriptions
$activeExclusiveSubChild = array();
// array: [$parentPlanId] = true
$notProposedParents = array();
foreach (array_keys($subscriptions) as $k) {
// for each user subscription:
// 1. check if it's plan can be shown as an extra subscription possibility and/or upgrade,
$subscriptions[$k]->checkRenewalUpgrade($ui, $user, $quantity, $now, $subsAccess);
// 2. don't propose subscription which can not be shown to the user
if ($subscriptions[$k]->_hideItsPlan && isset($plans[$subscriptions[$k]->plan_id])) {
$plans[$subscriptions[$k]->plan_id]->_drawOnlyAsContainer = true;
// $notProposedParents[$subscriptions[$k]->plan_id] = true;
}
if (($subscriptions[$k]->_hideThisSubscription || !$subscriptions[$k]->checkIfValid($now)) && (isset($plans[$subscriptions[$k]->plan_id]) && $plans[$subscriptions[$k]->plan_id]->get('multiple') == 0)) {
foreach (array_keys($plans) as $pk) {
// hidden or inactive subscription: do not display any of its children plans as upgrade possibility:
if ($plans[$pk]->get('parent') == $subscriptions[$k]->plan_id) {
$plans[$pk]->_drawOnlyAsContainer = true;
$notProposedParents[$pk] = true;
}
}
}
if ($subscriptions[$k]->_hideThisSubscription) {
unset($subscriptions[$k]);
} elseif ($subscriptions[$k]->checkIfValid($now)) {
// 3. all upgrade possibilities of this subscription
$noValidSubscriptionFound = false;
$subscriptionsUpgradePlansIdsDiscount[$k] = $subscriptions[$k]->_upgradePlansIdsDiscount;
if ($subscriptions[$k]->getPlanAttribute('exclusive') == 1) {
$activeExclusiveSubChild[$subscriptions[$k]->getPlanAttribute('parent')] = true;
}
} else {
}
}
// add to each plan the subscriptions which can be upgraded: plan, subscription and price:
foreach (array_keys($plans) as $pk) {
foreach ($subscriptionsUpgradePlansIdsDiscount as $k => $upgradePlansDiscount) {
foreach ($upgradePlansDiscount as $planId => $discountedPrice) {
if ($plans[$pk]->get('id') == $planId) {
$plans[$pk]->_subscriptionToUpdate = array($subscriptions[$k]->plan_id, $subscriptions[$k]->id);
$plans[$pk]->_renewalDiscount = $discountedPrice;
}
}
}
}
// finally remove all plans not allowed for upgrade and
// also all exclusive plans which can't be upgraded to by no subscription
// (already subscribed plans have already been removed by plan's _hideItsPlan instructions):
// also memorize them as removed parent, so that children are not proposed either:
foreach (array_keys($plans) as $pk) {
$exclPlan = $plans[$pk]->get('exclusive');
$resultTexts = array();
// remove plans not listed by default and not specifically selected:
if (!$plans[$pk]->isPlanAllowingUpgradesToThis($user_id, $resultTexts) || $plans[$pk]->get('propose_upgrade') != 1 && $ui != 2 && !($plansToShowOnly && (in_array($pk, $plansToShowOnly) || $plansToShowOnlyDoIncludeChildren && in_array($plans[$pk]->get('parent'), $plansToShowOnly))) || $exclPlan == 1 && $plans[$pk]->get('multiple') == 0 && isset($activeExclusiveSubChild[$plans[$pk]->get('parent')]) && $plans[$pk]->_subscriptionToUpdate === null) {
// if ( $ui == 1 ) { // when we are in frontend:
if (!(isset($plans[$pk]->_drawOnlyAsContainer) && $plans[$pk]->_drawOnlyAsContainer)) {
$plans[$pk]->_drawOnlyAsContainer = true;
$notProposedParents[$pk] = true;
}
}
}
// very finally remove also children of non-authorized parent plans:
// second case is that parent plan isn't published:
foreach (array_keys($plans) as $pk) {
$parentPlanId = $plans[$pk]->get('parent');
if ($parentPlanId && (isset($notProposedParents[$parentPlanId]) || !isset($plans[$parentPlanId]))) {
$plans[$pk]->_drawOnlyAsContainer = true;
}
}
// If no sbscriptions at all or no active/registered ones, and the corresponding setting allows it:
//.........这里部分代码省略.........
示例6: substitutionStringsForItemDetailed
/**
* Returns substitution strings
*
* @see cbpaidSomething::substitutionStringsForItemDetailed()
*
* @param boolean $html HTML or TEXT return
* @param string $reason 'N' new subscription, 'R' renewal, 'U'=update )
* @param boolean $autorecurring TRUE: is autorecurring, no real expiration date, FALSE: is not autorecurring
* @return array
*/
public function substitutionStringsForItemDetailed( /** @noinspection PhpUnusedParameterInspection */ $html, $reason, $autorecurring ) {
global $_CB_framework;
$user = CBuser::getUserDataInstance( $this->user_id );
$prefixText = '';
$params =& cbpaidApp::settingsParams();
$extraStrings = array( 'ITEM_NAME' => $this->getPlan()->getPersonalized( 'name', $this->user_id, false ), // CBPTXT::T( $this->getText( 'name' ) ),
'ITEM_ALIAS' => CBPTXT::T( $this->getText( 'alias' ) ),
'ITEM_DESCRIPTION' => $this->getPlan()->getPersonalized( 'description', $this->user_id, false ), //strip_tags( CBPTXT::T( $this->getText( 'description' ) ) ),
'SITENAME' => $_CB_framework->getCfg( 'sitename' ),
'SITEURL' => $_CB_framework->getCfg( 'live_site' ),
'PLANS_TITLE' => strip_tags( CBPTXT::T( $params->get( 'regTitle' ) ) ),
'EMAILADDRESS' => $user->email,
'PREFIX_TEXT' => $prefixText
);
return $extraStrings;
}
示例7: store
//.........这里部分代码省略.........
if (in_array($user->id, $usersSubscribed)) {
if ($plan->get('exclusive') && $plan->get('item_type') == 'usersubscription') {
$paidUserExtension = cbpaidUserExtension::getInstance($user->id);
$subscriptions = $paidUserExtension->getUserSubscriptions(null, false);
foreach ($subscriptions as $s) {
if ($s->parent_plan == $plan->get('parent') && $s->checkIfValid()) {
$sPlan = $s->getPlan();
if ($sPlan->get('exclusive') && $sPlan->get('item_type') == 'usersubscription') {
// check if any other exclusive subscription with same parent plan is active:
$incompatible = true;
break;
}
}
}
}
}
if (!$incompatible) {
if ($plan->get('parent')) {
$plansMgr = cbpaidPlansMgr::getInstance();
$parentPlan = $plansMgr->loadPlan($plan->get('parent'));
$parentSub = $parentPlan->loadLatestSomethingOfUser($user->id, null);
if (!$parentSub) {
$incompatible = true;
}
}
}
if ($incompatible) {
if (!in_array($user->id, $incompatibleUsersSubs)) {
$incompatibleUsersSubs[] = $user->id;
}
continue;
}
if (!$this->dryrun) {
$userFull = CBuser::getUserDataInstance($user->id);
$this->createSomething($plan, $userFull, $this->state, $subscriptionTime);
CBuser::unsetUsersNotNeeded(array((int) $user->id));
}
}
} else {
$cbpaidTimes = cbpaidTimes::getInstance();
$systemTimeZone = new DateTimeZone($cbpaidTimes->systemTimeZone());
foreach ($users as $user) {
@set_time_limit(60);
foreach ($planStateDate[(int) $user->id] as $psd) {
$plan = $plansMgr->loadPlan((int) $psd['plan']);
$status = $psd['status'];
if ($psd['date']) {
$date = DateTime::createFromFormat('Y-m-d H:i:s', $psd['date'], $systemTimeZone);
$subscriptionTime = $date->getTimestamp();
} else {
$subscriptionTime = $cbpaidTimes->startTime();
}
$incompatible = false;
if (in_array($user->id, $usersSubscribed)) {
if ($plan->get('exclusive') && $plan->get('item_type') == 'usersubscription') {
$paidUserExtension = cbpaidUserExtension::getInstance($user->id);
$subscriptions = $paidUserExtension->getUserSubscriptions(null, false);
foreach ($subscriptions as $s) {
if ($s->parent_plan == $plan->get('parent') && $s->checkIfValid()) {
$sPlan = $s->getPlan();
if ($sPlan->get('exclusive') && $sPlan->get('item_type') == 'usersubscription') {
// check if any other exclusive subscription with same parent plan is active:
$incompatible = true;
break;
}
}
示例8: setParams
public function setParams( $params, $html = true ) {
global $_CB_framework, $_PLUGINS;
$plugin = cbgjClass::getPlugin();
$user =& CBuser::getUserDataInstance( $_CB_framework->myId() );
$params = cbgjClass::parseParams( $params, $html, $this->getParams( $html ) );
$_PLUGINS->trigger( 'gjint_onBeforeSetAutoParams', array( &$params, &$this, $user, $plugin ) );
$this->set( 'params', trim( $params->toIniString() ) );
$_PLUGINS->trigger( 'gjint_onAfterSetAutoParams', array( $params, $this, $user, $plugin ) );
}
示例9: sendNotifications
/**
* Parses for users set to receive a notification and sends it to them
*
* @param string $notification The notification to send
* @param string $subject
* @param string $body
* @param GroupTable $group Group for this notification
* @param UserTable|int|null $from UserTable|int: Specific user to notify from (used for substitutions), Null: Notify from self
* @param UserTable|int|null $to UserTable|int: Specific user to notify, Null: Notify everyone elegible
* @param array $skip Array of user ids to skip
* @param int $status Group status restriction for notifications (e.g. 2: Group Moderators and above)
* @param array $extra
* @return bool
*/
static public function sendNotifications( $notification, $subject, $body, $group, $from = null, $to = null, $skip = array(), $status = 1, $extra = array() )
{
global $_CB_database, $_PLUGINS;
if ( is_int( $from ) ) {
$from = \CBuser::getUserDataInstance( $from );
}
if ( is_int( $to ) ) {
$to = \CBuser::getUserDataInstance( $to );
}
$myId = Application::MyUser()->getUserId();
if ( ( ! $notification ) || ( ! $subject ) || ( ! $body ) ) {
return false;
} elseif ( $to && ( $to->get( 'id' ) == $myId ) ) {
return false;
} elseif ( $from && $to && ( $from->get( 'id' ) == $to->get( 'id' ) ) ) {
return false;
} elseif ( ( ! $group->get( 'id' ) ) || ( $group->get( 'published' ) != 1 ) ) {
return false;
} elseif ( $group->category()->get( 'id' ) && ( ! $group->category()->get( 'published' ) ) ) {
return false;
}
static $params = null;
if ( ! $params ) {
$plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbgroupjive' );
$params = $_PLUGINS->getPluginParams( $plugin );
}
if ( ( ! $group->category()->get( 'id' ) ) && ( ! $params->get( 'groups_uncategorized', 1 ) ) ) {
return false;
} elseif ( ! $params->get( 'notifications', 1 ) ) {
return false;
}
if ( ! $status ) {
$status = 1;
}
if ( ! is_array( $skip ) ) {
$skip = array( $skip );
}
if ( $from ) {
$skip[] = $from->get( 'id' );
}
$moderators = Application::CmsPermissions()->getGroupsOfViewAccessLevel( Application::Config()->get( 'moderator_viewaccesslevel', 3, GetterInterface::INT ), true );
$query = 'SELECT DISTINCT n.*'
. ', u.' . $_CB_database->NameQuote( 'status' )
. "\n FROM " . $_CB_database->NameQuote( '#__groupjive_notifications' ) . " AS n"
. "\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
. ' ON u.' . $_CB_database->NameQuote( 'user_id' ) . ' = n.' . $_CB_database->NameQuote( 'user_id' )
. ' AND u.' . $_CB_database->NameQuote( 'group' ) . ' = n.' . $_CB_database->NameQuote( 'group' )
. "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
. ' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = u.' . $_CB_database->NameQuote( 'user_id' )
. "\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( '#__user_usergroup_map' ) . " AS g"
. ' ON g.' . $_CB_database->NameQuote( 'user_id' ) . ' = j.' . $_CB_database->NameQuote( 'id' )
. "\n WHERE n." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' );
if ( $to ) {
$query .= "\n AND n." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $to->get( 'id' );
} else {
$query .= "\n AND n." . $_CB_database->NameQuote( 'user_id' ) . " != " . (int) $myId;
}
if ( $skip ) {
$query .= "\n AND n." . $_CB_database->NameQuote( 'user_id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $skip );
}
$query .= "\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 ( n." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $group->get( 'user_id' )
. ' OR u.' . $_CB_database->NameQuote( 'status' ) . " >= " . (int) $status
. ' OR g.' . $_CB_database->NameQuote( 'group_id' ) . " IN " . $_CB_database->safeArrayOfIntegers( $moderators ) . ' )';
$_CB_database->setQuery( $query );
$rows = $_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\NotificationTable', array( $_CB_database ) );
//.........这里部分代码省略.........
示例10: sendFromSystem
function sendFromSystem($toid, $sub, $message, $replaceVariables = true, $mode = 0, $cc = null, $bcc = null, $attachment = null, $extraStrings = null, $footer = true)
{
global $_CB_framework, $_CB_database, $ueConfig;
if (!$sub && !$message) {
return true;
}
if ($extraStrings === null) {
$extraStrings = array();
}
$rowFrom = new stdClass();
$rowFrom->email = $ueConfig['reg_email_from'];
$rowFrom->name = stripslashes($ueConfig['reg_email_name']);
$rowFrom->replytoEmail = $ueConfig['reg_email_replyto'];
$rowFrom->replytoName = stripslashes($ueConfig['reg_email_name']);
if (!is_object($toid)) {
$rowTo = CBuser::getUserDataInstance($toid);
} else {
$rowTo = $toid;
}
if ($replaceVariables) {
$sub = $this->_replaceVariables($sub, $rowTo, $mode, $extraStrings);
$message = $this->_replaceVariables($message, $rowTo, $mode, $extraStrings);
}
if ($footer) {
$message .= ($mode ? "\n<br />\n<br />" : "\n\n") . sprintf(_UE_EMAILFOOTER, cb_html_entity_decode_all($_CB_framework->getCfg('sitename')), $_CB_framework->getCfg('live_site'));
}
// $message = str_replace(array("\\","\"","\$"), array("\\\\","\\\"","\\\$"), $message);
// eval ("\$message = \"$message\";");
$message = str_replace(array('\\n'), array("\n"), $message);
// compensate for wrong language definitions (using '\n' instaed of "\n")
return $this->_sendEmailMSG($rowTo, $rowFrom, cb_html_entity_decode_all($_CB_framework->getCfg('sitename')) . ' - ' . $sub, $message, false, $mode, $cc, $bcc, $attachment);
}
示例11: sendNewPass
function sendNewPass($option)
{
global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS, $_POST;
// simple spoof check security
checkCBPostIsHTTPS();
cbSpoofCheck('lostPassForm');
cbRegAntiSpamCheck();
$usernameExists = isset($ueConfig['login_type']) && $ueConfig['login_type'] != 2;
// ensure no malicous sql gets past
$checkusername = trim(cbGetParam($_POST, 'checkusername', ''));
$confirmEmail = trim(cbGetParam($_POST, 'checkemail', ''));
$Itemid = $_CB_framework->itemid();
$_PLUGINS->loadPluginGroup('user');
$_PLUGINS->trigger('onStartNewPassword', array(&$checkusername, &$confirmEmail));
if ($_PLUGINS->is_errors()) {
cbRedirect(cbSef("index.php?option={$option}&task=lostPassword" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), $_PLUGINS->getErrorMSG(), 'error');
return;
}
$checkusername = stripslashes($checkusername);
$confirmEmail = stripslashes($confirmEmail);
// these two are used by _NEWPASS_SUB message below:
$_live_site = $_CB_framework->getCfg('live_site');
$_sitename = "";
// NEEDED BY _NEWPASS_SUB for sitename already added in subject by cbNotification class. was = $_CB_framework->getCfg( 'sitename' );
if ($usernameExists && $confirmEmail != '' && !$checkusername) {
$_CB_database->setQuery("SELECT id, username FROM #__users" . "\n WHERE email = " . $_CB_database->Quote($confirmEmail));
$userIdUsername = null;
$result = $_CB_database->loadObjectList($userIdUsername);
if ($_CB_database->getErrorNum() || count($result) == 0) {
cbRedirect(cbSef('index.php?option=' . $option . '&task=lostPassword' . ($Itemid ? '&Itemid=' . (int) $Itemid : ''), false), sprintf(_UE_EMAIL_DOES_NOT_EXISTS_ON_SITE, htmlspecialchars($confirmEmail)), 'error');
}
foreach ($result as $userIdUsername) {
$message = str_replace('\\n', "\n", sprintf(_UE_USERNAMEREMINDER_MSG, $_CB_framework->getCfg('sitename'), $userIdUsername->username, $_live_site));
$subject = sprintf(_UE_USERNAMEREMINDER_SUB, $userIdUsername->username);
$_PLUGINS->trigger('onBeforeUsernameReminder', array($userIdUsername->id, &$subject, &$message));
if ($_PLUGINS->is_errors()) {
cbRedirect(cbSef("index.php?option={$option}&task=lostPassword" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), $_PLUGINS->getErrorMSG(), 'error');
return;
}
$cbNotification = new cbNotification();
$res = $cbNotification->sendFromSystem($userIdUsername->id, $subject, $message);
if (!$res) {
break;
}
}
$_PLUGINS->trigger('onAfterUsernameReminder', array(&$result, &$res));
if ($res) {
cbRedirect(cbSef("index.php?option={$option}&task=done" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), sprintf(_UE_USERNAME_REMINDER_SENT, htmlspecialchars($confirmEmail)));
} else {
cbRedirect(cbSef("index.php?option={$option}&task=done" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), _UE_EMAIL_SENDING_ERROR);
}
} elseif ($confirmEmail != '') {
if ($usernameExists) {
$_CB_database->setQuery("SELECT id FROM #__users" . "\n WHERE username = " . $_CB_database->Quote($checkusername) . " AND email = " . $_CB_database->Quote($confirmEmail));
} else {
$_CB_database->setQuery("SELECT id FROM #__users" . "\n WHERE email = " . $_CB_database->Quote($confirmEmail));
}
$user_id = $_CB_database->loadResult();
if (!$user_id) {
cbRedirect(cbSef('index.php?option=' . $option . '&task=lostPassword' . ($Itemid ? '&Itemid=' . (int) $Itemid : ''), false), _ERROR_PASS);
}
$newpass = cbMakeRandomString(8, true);
// should be $user->setRandomPassword() but as this whole function needs to be redone to require clicking link for new password change, let's leave it for now.
$message = str_replace('\\n', "\n", sprintf(_UE_NEWPASS_MSG, $checkusername, $_live_site, $newpass));
$subject = sprintf(_UE_NEWPASS_SUB, $checkusername);
$_PLUGINS->trigger('onBeforeNewPassword', array($user_id, &$newpass, &$subject, &$message));
if ($_PLUGINS->is_errors()) {
cbRedirect(cbSef("index.php?option={$option}&task=lostPassword" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), $_PLUGINS->getErrorMSG(), 'error');
return;
}
$_PLUGINS->trigger('onNewPassword', array($user_id, $newpass));
$user = CBuser::getUserDataInstance((int) $user_id);
$user->password = $newpass;
if (!$user->storePassword()) {
cbRedirect(cbSef("index.php?option={$option}&task=lostPassword" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), $user->getError(), 'error');
return;
} else {
$cbNotification = new cbNotification();
$res = $cbNotification->sendFromSystem($user_id, $subject, $message);
if (!$res) {
cbRedirect(cbSef("index.php?option={$option}&task=done" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), _UE_NEWPASS_FAILED);
return;
}
}
cbRedirect(cbSef("index.php?option={$option}&task=done" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), sprintf(_UE_NEWPASS_SENT, htmlspecialchars($confirmEmail)));
} else {
cbRedirect(cbSef("index.php?option={$option}&task=done" . ($Itemid ? "&Itemid=" . (int) $Itemid : ""), false), _UE_NEWPASS_FAILED);
}
}
示例12: processAutoRecurringPayment
/**
* Attempts to authorize and capture a credit card for a single payment of a payment basket using PSP DirectLink
*
* @ param array $card : $card['type'], $card['number'], $card['firstname'], $card['lastname'], $card['expmonth'], $card['expyear'], and optionally: $card['address'], $card['zip'], $card['country']
* @param cbpaidPaymentBasket $paymentBasket
* @param string $returnText RETURN param
* @param boolean $transientErrorDoReschedule RETURN param
* @return boolean|null TRUE: succes, FALSE: failed or unknown result, NULL: not implemented
*/
public function processAutoRecurringPayment($paymentBasket, &$returnText, &$transientErrorDoReschedule)
{
// form XML request:
$formvars = $this->_fillinAutoRecuringDirectLinkRequstParams($paymentBasket);
$error = null;
$status = null;
$response = $this->_directLinkOperation($paymentBasket, 'orderdirect', $formvars, 'Autorecurring', $error, $status);
if ($response === false) {
$user = CBuser::getUserDataInstance($paymentBasket->user_id);
$username = $user ? $user->username : '?';
$returnText = sprintf(CBPTXT::T("FAILED Auto-recurring payment of %s for basket %s Order_id %s of %s (username %s - user id %s) using %s due to error %s."), $paymentBasket->renderPrice(null, null, null, false), $paymentBasket->id, $paymentBasket->sale_id, $paymentBasket->first_name . ' ' . $paymentBasket->last_name, $username, $paymentBasket->user_id, $this->getPayName(), 'HTTP error ' . ': ' . $error . ' ' . 'Status' . ': ' . $status);
$transientErrorDoReschedule = true;
$return = false;
} else {
// clean logs for PCI compliance:
$formvarsCleaned = $formvars;
if (isset($formvars['CC'])) {
$formvarsCleaned['CC'] = preg_replace('/^.+(.{4})$/', 'XXXX XXXX XXXX \\1', $formvars['CC']);
}
unset($formvarsCleaned['CVC']);
unset($formvarsCleaned['Ecom_Payment_Card_Verification']);
if (isset($formvars['PSWD'])) {
$formvars['PSWD'] = '********';
}
// Parse the response XML results:
$paymentResult = $this->handleDirectLinkPaymentResult($paymentBasket, $response, 'A', array('formvars' => $formvarsCleaned, 'xmlreply' => $response));
$user = CBuser::getUserDataInstance($paymentBasket->user_id);
$username = $user ? $user->username : '?';
if ($paymentResult !== false) {
if ($paymentResult === true && in_array($paymentBasket->payment_status, array('Completed', 'Pending'))) {
if ($paymentBasket->payment_status == 'Completed') {
$returnText = sprintf(CBPTXT::T("Completed Auto-recurring payment of %s for basket %s Order_id %s of %s (username %s - user id %s) using %s with txn_id %s and auth_id %s."), $paymentBasket->renderPrice(null, null, null, false), $paymentBasket->id, $paymentBasket->sale_id, $paymentBasket->first_name . ' ' . $paymentBasket->last_name, $username, $paymentBasket->user_id, $this->getPayName(), $paymentBasket->txn_id, $paymentBasket->auth_id);
} else {
$returnText = sprintf(CBPTXT::T("Pending Auto-recurring payment of %s for basket %s Order_id %s of %s (username %s - user id %s) using %s with txn_id %s and auth_id %s for reason: %s."), $paymentBasket->renderPrice(null, null, null, false), $paymentBasket->id, $paymentBasket->sale_id, $paymentBasket->first_name . ' ' . $paymentBasket->last_name, $username, $paymentBasket->user_id, $this->getPayName(), $paymentBasket->txn_id, $paymentBasket->auth_id, $paymentBasket->reason_code);
}
$transientErrorDoReschedule = false;
$return = true;
} else {
$returnText = sprintf(CBPTXT::T("FAILED (%s) Auto-recurring payment of %s for basket %s Order_id %s of %s (username %s - user id %s) using %s due to error %s."), $paymentBasket->payment_status, $paymentBasket->renderPrice(null, null, null, false), $paymentBasket->id, $paymentBasket->sale_id, $paymentBasket->first_name . ' ' . $paymentBasket->last_name, $username, $paymentBasket->user_id, $this->getPayName(), $paymentBasket->reason_code);
$transientErrorDoReschedule = true;
$return = false;
}
} else {
$returnText = sprintf(CBPTXT::T("FAILED (Error) Auto-recurring payment of %s for basket %s Order_id %s of %s (username %s - user id %s) using %s due to error %s."), $paymentBasket->renderPrice(null, null, null, false), $paymentBasket->id, $paymentBasket->sale_id, $paymentBasket->first_name . ' ' . $paymentBasket->last_name, $username, $paymentBasket->user_id, $this->getPayName(), $paymentBasket->reason_code);
$transientErrorDoReschedule = true;
$return = false;
}
}
return $return;
}
示例13: getCBpluginComponent
/**
* @param TabTable $tab Current tab
* @param UserTable $user Current user
* @param int $ui 1 front, 2 admin UI
* @param array $postdata Raw unfiltred POST data
* @return string HTML
*/
public function getCBpluginComponent( $tab, $user, $ui, $postdata )
{
global $_CB_framework;
$format = $this->input( 'format', null, GetterInterface::STRING );
if ( $format != 'raw' ) {
outputCbJs( 1 );
outputCbTemplate( 1 );
}
$action = $this->input( 'action', null, GetterInterface::STRING );
$function = $this->input( 'func', null, GetterInterface::STRING );
$type = $this->input( 'type', null, GetterInterface::STRING );
$id = (int) $this->input( 'id', null, GetterInterface::INT );
$userId = (int) $this->input( 'user', null, GetterInterface::INT );
$tabId = (int) $this->input( 'tab', null, GetterInterface::INT );
if ( ! $tabId ) {
switch( $type ) {
case 'photos':
$tabId = 'cbgalleryTabPhotos';
break;
case 'files':
$tabId = 'cbgalleryTabFiles';
break;
case 'videos':
$tabId = 'cbgalleryTabVideos';
break;
case 'music':
$tabId = 'cbgalleryTabMusic';
break;
}
}
$viewer = CBuser::getMyUserDataInstance();
if ( $userId ) {
$user = CBuser::getUserDataInstance( (int) $userId );
} else {
$user = CBuser::getMyUserDataInstance();
}
$profileUrl = $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, $tabId );
if ( ! in_array( $type, array( 'photos', 'files', 'videos', 'music' ) ) ) {
if ( ( $action == 'items' ) && in_array( $function, array( 'download', 'preview', 'show' ) ) ) {
header( 'HTTP/1.0 401 Unauthorized' );
exit();
} else {
cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
}
}
$tab = new TabTable();
$tab->load( ( is_integer( $tabId ) ? $tabId : array( 'pluginclass' => $tabId ) ) );
if ( ! ( $tab->get( 'enabled' ) && Application::User( (int) $viewer->get( 'id' ) )->canViewAccessLevel( $tab->get( 'viewaccesslevel' ) ) ) ) {
if ( ( $action == 'items' ) && in_array( $function, array( 'download', 'preview', 'show' ) ) ) {
header( 'HTTP/1.0 401 Unauthorized' );
exit();
} else {
cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
}
}
if ( ! ( $tab->params instanceof ParamsInterface ) ) {
$tab->params = new Registry( $tab->params );
}
if ( $format != 'raw' ) {
ob_start();
}
switch ( $action ) {
case 'items':
switch ( $function ) {
case 'download':
$this->outputItem( false, false, $id, $type, $tab, $user, $viewer );
break;
case 'edit':
$this->showItemEdit( $id, $type, $tab, $user, $viewer );
break;
case 'new':
$this->showItemEdit( null, $type, $tab, $user, $viewer );
break;
case 'save':
cbSpoofCheck( 'plugin' );
$this->saveItemEdit( $id, $type, $tab, $user, $viewer );
break;
case 'publish':
$this->stateItem( 1, $id, $type, $tab, $user, $viewer );
//.........这里部分代码省略.........
示例14: prepareUser
/**
* Trys to load a user object from a variable
*
* @param object|int $userVar
* @param boolean $fallback
* @return UserTable
*/
private function prepareUser( $userVar, $fallback = true )
{
if ( is_object( $userVar ) ) {
if ( $userVar instanceof UserTable ) {
$user = $userVar;
} elseif ( isset( $userVar->user_id ) ) {
$userId = (int) $userVar->user_id;
} elseif ( isset( $userVar->user ) ) {
$userId = (int) $userVar->user;
} elseif ( isset( $userVar->id ) ) {
$userId = (int) $userVar->id;
}
} elseif ( is_integer( $userVar ) ) {
$userId = $userVar;
}
if ( isset( $userId ) && is_integer( $userId ) ) {
$user = CBuser::getUserDataInstance( (int) $userId );
if ( ( ! $user->get( 'id' ) ) && ( ! $fallback ) ) {
$user = null;
}
}
if ( ! isset( $user ) ) {
if ( $fallback ) {
$user = CBuser::getUserDataInstance( null );
} else {
$user = null;
}
}
return $user;
}
示例15: getOwner
/**
* prepare notification owner CB user
*
* @return moscomprofilerUser
*/
public function getOwner() {
static $cache = array();
$id = $this->get( 'user_id' );
if ( ! isset( $cache[$id] ) ) {
$cache[$id] =& CBuser::getUserDataInstance( (int) $id );
}
return $cache[$id];
}