本文整理汇总了PHP中humhub\modules\user\models\User::getSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getSetting方法的具体用法?PHP User::getSetting怎么用?PHP User::getSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类humhub\modules\user\models\User
的用法示例。
在下文中一共展示了User::getSetting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMailUpdate
public function getMailUpdate(User $user, $interval)
{
$output = "";
foreach (Session::find()->where(['<', 'expire', time()])->all() as $session) {
$session->delete();
}
$receive_email_notifications = $user->getSetting("receive_email_notifications", 'core', Setting::Get('receive_email_notifications', 'mailing'));
// Never receive notifications
if ($receive_email_notifications == User::RECEIVE_EMAIL_NEVER) {
return "";
}
// We are in hourly mode and user wants daily
if ($interval == CronController::EVENT_ON_HOURLY_RUN && $receive_email_notifications == User::RECEIVE_EMAIL_DAILY_SUMMARY) {
return "";
}
// We are in daily mode and user dont wants daily reports
if ($interval == CronController::EVENT_ON_DAILY_RUN && $receive_email_notifications != User::RECEIVE_EMAIL_DAILY_SUMMARY) {
return "";
}
// User wants only when offline and is online
if ($interval == CronController::EVENT_ON_HOURLY_RUN) {
$isOnline = count($user->httpSessions) > 0;
if ($receive_email_notifications == User::RECEIVE_EMAIL_WHEN_OFFLINE && $isOnline) {
return "";
}
}
$query = Notification::find()->where(['user_id' => $user->id])->andWhere(['!=', 'seen', 1])->andWhere(['!=', 'emailed', 1]);
foreach ($query->all() as $notification) {
$output .= $notification->getClass()->render(BaseNotification::OUTPUT_MAIL);
$notification->emailed = 1;
$notification->save();
}
return $output;
}
示例2: 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->last_activity_email = new \yii\db\Expression('NOW()');
$user->save();
return $output;
}