本文整理匯總了PHP中humhub\modules\user\models\User::updateAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::updateAttributes方法的具體用法?PHP User::updateAttributes怎麽用?PHP User::updateAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類humhub\modules\user\models\User
的用法示例。
在下文中一共展示了User::updateAttributes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getMailUpdate
public function getMailUpdate(User $user, $interval)
{
$output = ['html' => '', 'plaintext' => ''];
$receive_email_activities = $user->getSetting("receive_email_activities", 'core', Setting::Get('receive_email_activities', 'mailing'));
// User never wants activity content
if ($receive_email_activities == User::RECEIVE_EMAIL_NEVER) {
return "";
}
// We are in hourly mode and user wants receive a daily summary
if ($interval == CronController::EVENT_ON_HOURLY_RUN && $receive_email_activities == User::RECEIVE_EMAIL_DAILY_SUMMARY) {
return "";
}
// We are in daily mode and user wants receive not daily
if ($interval == CronController::EVENT_ON_DAILY_RUN && $receive_email_activities != User::RECEIVE_EMAIL_DAILY_SUMMARY) {
return "";
}
// User is online and want only receive when offline
if ($interval == CronController::EVENT_ON_HOURLY_RUN) {
$isOnline = count($user->httpSessions) > 0;
if ($receive_email_activities == User::RECEIVE_EMAIL_WHEN_OFFLINE && $isOnline) {
return "";
}
}
$lastMailDate = $user->last_activity_email;
if ($lastMailDate == "" || $lastMailDate == "0000-00-00 00:00:00") {
$lastMailDate = new \yii\db\Expression('NOW() - INTERVAL 24 HOUR');
}
$stream = new \humhub\modules\dashboard\components\actions\DashboardStream('stream', Yii::$app->controller);
$stream->limit = 50;
$stream->mode = \humhub\modules\content\components\actions\Stream::MODE_ACTIVITY;
$stream->user = $user;
$stream->init();
$stream->activeQuery->andWhere(['>', 'content.created_at', $lastMailDate]);
foreach ($stream->getWallEntries() as $wallEntry) {
try {
$activity = $wallEntry->content->getPolymorphicRelation();
$output['html'] .= $activity->getActivityBaseClass()->render(BaseActivity::OUTPUT_MAIL);
$output['plaintext'] .= $activity->getActivityBaseClass()->render(BaseActivity::OUTPUT_MAIL_PLAINTEXT);
} catch (\yii\base\Exception $ex) {
\Yii::error($ex->getMessage());
}
}
$user->updateAttributes(['last_activity_email' => new \yii\db\Expression('NOW()')]);
return $output;
}