当前位置: 首页>>代码示例>>PHP>>正文


PHP ActivityModel::SaveQueue方法代码示例

本文整理汇总了PHP中ActivityModel::SaveQueue方法的典型用法代码示例。如果您正苦于以下问题:PHP ActivityModel::SaveQueue方法的具体用法?PHP ActivityModel::SaveQueue怎么用?PHP ActivityModel::SaveQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActivityModel的用法示例。


在下文中一共展示了ActivityModel::SaveQueue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Award

 /**
  * Award a badge to a user and record some activity
  *
  * @param int $BadgeID
  * @param int $UserID This is the user that should get the award
  * @param int $InsertUserID This is the user that gave the award
  * @param string $Reason This is the reason the giver gave with the award
  */
 public function Award($BadgeID, $UserID, $InsertUserID = NULL, $Reason = '')
 {
     $Badge = Yaga::BadgeModel()->GetByID($BadgeID);
     if (!empty($Badge)) {
         if (!$this->Exists($UserID, $BadgeID)) {
             $this->SQL->Insert('BadgeAward', array('BadgeID' => $BadgeID, 'UserID' => $UserID, 'InsertUserID' => $InsertUserID, 'Reason' => $Reason, 'DateInserted' => date(DATE_ISO8601)));
             // Record the points for this badge
             UserModel::GivePoints($UserID, $Badge->AwardValue, 'Badge');
             // Increment the user's badge count
             $this->SQL->Update('User')->Set('CountBadges', 'CountBadges + 1', FALSE)->Where('UserID', $UserID)->Put();
             if (is_null($InsertUserID)) {
                 $InsertUserID = Gdn::Session()->UserID;
             }
             // Record some activity
             $ActivityModel = new ActivityModel();
             $Activity = array('ActivityType' => 'BadgeAward', 'ActivityUserID' => $UserID, 'RegardingUserID' => $InsertUserID, 'Photo' => $Badge->Photo, 'RecordType' => 'Badge', 'RecordID' => $BadgeID, 'Route' => '/badges/detail/' . $Badge->BadgeID . '/' . Gdn_Format::Url($Badge->Name), 'HeadlineFormat' => T('Yaga.Badge.EarnedHeadlineFormat'), 'Data' => array('Name' => $Badge->Name), 'Story' => $Badge->Description);
             // Create a public record
             $ActivityModel->Queue($Activity, FALSE);
             // TODO: enable the grouped notifications after issue #1776 is resolved , array('GroupBy' => 'Route'));
             // Notify the user of the award
             $Activity['NotifyUserID'] = $UserID;
             $ActivityModel->Queue($Activity, 'BadgeAward', array('Force' => TRUE));
             // Actually save the activity
             $ActivityModel->SaveQueue();
             $this->EventArguments['UserID'] = $UserID;
             $this->FireEvent('AfterBadgeAward');
         }
     }
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:37,代码来源:class.badgeawardmodel.php

示例2: AddUserToConversation

 /**
  * Add another user to the conversation.
  * 
  * @since 2.0.0
  * @access public
  *
  * @param int $ConversationID Unique ID of conversation effected.
  * @param int $UserID Unique ID of current user.
  */
 public function AddUserToConversation($ConversationID, $UserID)
 {
     if (!is_array($UserID)) {
         $UserID = array($UserID);
     }
     // First define the current users in the conversation
     $OldContributorData = $this->GetRecipients($ConversationID);
     $OldContributorData = Gdn_DataSet::Index($OldContributorData, 'UserID');
     $AddedUserIDs = array();
     // Get some information about this conversation
     $ConversationData = $this->SQL->Select('LastMessageID')->Select('CountMessages')->From('Conversation')->Where('ConversationID', $ConversationID)->Get()->FirstRow();
     // Add the user(s) if they are not already in the conversation
     foreach ($UserID as $NewUserID) {
         if (!array_key_exists($NewUserID, $OldContributorData)) {
             $AddedUserIDs[] = $NewUserID;
             $this->SQL->Insert('UserConversation', array('UserID' => $NewUserID, 'ConversationID' => $ConversationID, 'LastMessageID' => $ConversationData->LastMessageID, 'CountReadMessages' => 0, 'DateConversationUpdated' => $ConversationData['DateUpdated']));
         } elseif ($OldContributorData[$NewUserID]->Deleted) {
             $AddedUserIDs[] = $NewUserID;
             $this->SQL->Put('UserConversation', array('Deleted' => 0), array('ConversationID' => $ConversationID, 'UserID' => $NewUserID));
         }
     }
     if (count($AddedUserIDs) > 0) {
         $Session = Gdn::Session();
         // Update the Contributors field on the conversation
         $Contributors = array_unique(array_merge($AddedUserIDs, array_keys($OldContributorData)));
         sort($Contributors);
         $this->SQL->Update('Conversation')->Set('Contributors', Gdn_Format::Serialize($Contributors))->Where('ConversationID', $ConversationID)->Put();
         $ActivityModel = new ActivityModel();
         foreach ($AddedUserIDs as $AddedUserID) {
             $ActivityModel->Queue(array('ActivityType' => 'AddedToConversation', 'NotifyUserID' => $AddedUserID, 'HeadlineFormat' => T('You were added to a conversation.', '{InsertUserID,user} added {NotifyUserID,you} to a <a href="{Url,htmlencode}">conversation</a>.')), 'ConversationMessage');
         }
         $ActivityModel->SaveQueue();
         $this->UpdateUserUnreadCount($AddedUserIDs);
     }
 }
开发者ID:rnovino,项目名称:Garden,代码行数:44,代码来源:class.conversationmodel.php

示例3: unBan

 /**
  * Unban a user.
  *
  * @since 2.1
  *
  * @param int $UserID
  * @param array $Options
  */
 public function unBan($UserID, $Options = array())
 {
     $User = $this->getID($UserID, DATASET_TYPE_ARRAY);
     if (!$User) {
         throw notFoundException();
     }
     $Banned = $User['Banned'];
     if (!BanModel::isBanned($Banned, BanModel::BAN_MANUAL)) {
         throw new Gdn_UserException(t("The user isn't banned.", "The user isn't banned or is banned by some other function."));
     }
     // Unban the user.
     $NewBanned = BanModel::setBanned($Banned, false, BanModel::BAN_MANUAL);
     $this->setField($UserID, 'Banned', $NewBanned);
     // Restore the user's content.
     if (val('RestoreContent', $Options)) {
         $BanLogID = $this->getAttribute($UserID, 'BanLogID');
         if ($BanLogID) {
             $LogModel = new LogModel();
             try {
                 $LogModel->restore($BanLogID);
             } catch (Exception $Ex) {
                 if ($Ex->getCode() != 404) {
                     throw $Ex;
                 }
             }
             $this->saveAttribute($UserID, 'BanLogID', null);
         }
     }
     // Add an activity for the unbanning.
     if (val('AddActivity', $Options, true)) {
         $ActivityModel = new ActivityModel();
         $Story = val('Story', $Options, null);
         // Notify the moderators of the unban.
         $Activity = array('ActivityType' => 'Ban', 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::session()->UserID, 'HeadlineFormat' => t('HeadlineFormat.Unban', '{RegardingUserID,You} unbanned {ActivityUserID,you}.'), 'Story' => $Story, 'Data' => array('Unban' => true));
         $ActivityModel->Queue($Activity);
         // Notify the user of the unban.
         $Activity['NotifyUserID'] = $UserID;
         $Activity['Emailed'] = ActivityModel::SENT_PENDING;
         $Activity['HeadlineFormat'] = t('HeadlineFormat.Unban.Notification', "You've been unbanned.");
         $ActivityModel->Queue($Activity, false, array('Force' => true));
         $ActivityModel->SaveQueue();
     }
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:51,代码来源:class.usermodel.php

示例4: UnBan

 /**
  * Unban a user.
  * @since 2.1
  * @param int $UserID
  * @param array $Options 
  */
 public function UnBan($UserID, $Options = array())
 {
     $User = $this->GetID($UserID, DATASET_TYPE_ARRAY);
     if (!$User) {
         throw NotFoundException();
     }
     if (!$User['Banned']) {
         throw new Gdn_UserException(T("The user isn't banned."));
     }
     // Unban the user.
     $this->SetField($UserID, 'Banned', FALSE);
     // Restore the user's content.
     if (GetValue('RestoreContent', $Options)) {
         $BanLogID = $this->GetAttribute($UserID, 'BanLogID');
         if ($BanLogID) {
             $LogModel = new LogModel();
             try {
                 $LogModel->Restore($BanLogID);
             } catch (Exception $Ex) {
                 if ($Ex->getCode() != 404) {
                     throw $Ex;
                 }
             }
             $this->SaveAttribute($UserID, 'BanLogID', NULL);
         }
     }
     // Add an activity for the unbanning.
     if (GetValue('AddActivity', $Options, TRUE)) {
         $ActivityModel = new ActivityModel();
         $Story = GetValue('Story', $Options, NULL);
         // Notify the moderators of the unban.
         $Activity = array('ActivityType' => 'Ban', 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::Session()->UserID, 'HeadlineFormat' => T('HeadlineFormat.Unban', '{RegardingUserID,You} unbanned {ActivityUserID,you}.'), 'Story' => $Story);
         $ActivityModel->Queue($Activity);
         // Notify the user of the unban.
         $Activity['NotifyUserID'] = $UserID;
         $Activity['Emailed'] = ActivityModel::SENT_PENDING;
         $Activity['HeadlineFormat'] = T('HeadlineFormat.Unban.Notification', "You've been unbanned.");
         $ActivityModel->Queue($Activity, FALSE, array('Force' => TRUE));
         $ActivityModel->SaveQueue();
     }
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:47,代码来源:class.usermodel.php

示例5: Set

 /**
  * Set a user's rank and record some activity if it was a promotion
  *
  * @param int $RankID
  * @param int $UserID This is the user that should get the award
  * @param bool $Activity Whether or not to insert an activity record.
  */
 public function Set($RankID, $UserID, $Activity = FALSE)
 {
     $Rank = $this->GetByID($RankID);
     if ($Activity) {
         // Throw up a promotion activity
         $ActivityModel = new ActivityModel();
         $Activity = array('ActivityType' => 'RankPromotion', 'ActivityUserID' => $UserID, 'RegardingUserID' => $UserID, 'Photo' => C('Yaga.Ranks.Photo'), 'RecordType' => 'Rank', 'RecordID' => $Rank->RankID, 'HeadlineFormat' => T('Yaga.Rank.PromotedHeadlineFormat'), 'Data' => array('Name' => $Rank->Name), 'Story' => $Rank->Description);
         // Create a public record
         $ActivityModel->Queue($Activity, FALSE);
         // TODO: enable the grouped notifications after issue #1776 is resolved , array('GroupBy' => 'Story'));
         // Notify the user of the award
         $Activity['NotifyUserID'] = $UserID;
         $ActivityModel->Queue($Activity, 'RankPromotion', array('Force' => TRUE));
         $ActivityModel->SaveQueue();
     }
     // Update the rank id
     $UserModel = Gdn::UserModel();
     $OldRankID = $UserModel->GetID($UserID)->RankID;
     $UserModel->SetField($UserID, 'RankID', $Rank->RankID);
     // Update the roles if necessary
     $this->_UpdateUserRoles($UserID, $OldRankID, $Rank->RankID);
     $this->EventArguments['Rank'] = $Rank;
     $this->EventArguments['UserID'] = $UserID;
     $this->FireEvent('AfterRankChange');
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:32,代码来源:class.rankmodel.php


注:本文中的ActivityModel::SaveQueue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。