本文整理汇总了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;
}