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


PHP ActivityModel::Save方法代码示例

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


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

示例1: Post

 public function Post($Notify = FALSE, $UserID = FALSE)
 {
     if (is_numeric($Notify)) {
         $UserID = $Notify;
         $Notify = FALSE;
     }
     if (!$UserID) {
         $UserID = Gdn::Session()->UserID;
     }
     switch ($Notify) {
         case 'mods':
             $this->Permission('Garden.Moderation.Manage');
             $NotifyUserID = ActivityModel::NOTIFY_MODS;
             break;
         case 'admins':
             $this->Permission('Garden.Settings.Manage');
             $NotifyUserID = ActivityModel::NOTIFY_ADMINS;
             break;
         default:
             $this->Permission('Garden.Profiles.Edit');
             $NotifyUserID = ActivityModel::NOTIFY_PUBLIC;
             break;
     }
     $Activities = array();
     if ($this->Form->IsPostBack()) {
         $Data = $this->Form->FormValues();
         $Data = $this->ActivityModel->FilterForm($Data);
         $Data['Format'] = C('Garden.InputFormatter');
         if ($UserID != Gdn::Session()->UserID) {
             // This is a wall post.
             $Activity = array('ActivityType' => 'WallPost', 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::Session()->UserID, 'HeadlineFormat' => T('HeadlineFormat.WallPost', '{RegardingUserID,you} → {ActivityUserID,you}'), 'Story' => $Data['Comment'], 'Format' => $Data['Format']);
         } else {
             // This is a status update.
             $Activity = array('ActivityType' => 'Status', 'HeadlineFormat' => T('HeadlineFormat.Status', '{ActivityUserID,user}'), 'Story' => $Data['Comment'], 'Format' => $Data['Format'], 'NotifyUserID' => $NotifyUserID);
             $this->SetJson('StatusMessage', Gdn_Format::Display($Data['Comment']));
         }
         $Activity = $this->ActivityModel->Save($Activity, FALSE, array('CheckSpam' => TRUE));
         if ($Activity == SPAM) {
             $this->StatusMessage = T('Your post has been flagged for moderation.');
             $this->Render('Blank', 'Utility');
             return;
         }
         if ($Activity) {
             if ($UserID == Gdn::Session()->UserID && $NotifyUserID == ActivityModel::NOTIFY_PUBLIC) {
                 Gdn::UserModel()->SetField(Gdn::Session()->UserID, 'About', Gdn_Format::PlainText($Activity['Story'], $Activity['Format']));
             }
             $Activities = array($Activity);
             ActivityModel::JoinUsers($Activities);
             $this->ActivityModel->CalculateData($Activities);
         }
     }
     if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
         Redirect($this->Request->Get('Target', '/activity'));
     }
     $this->SetData('Activities', $Activities);
     $this->Render('Activities');
 }
开发者ID:rnovino,项目名称:Garden,代码行数:57,代码来源:class.activitycontroller.php

示例2: DiscussionController_QnA_Create

 /**
  *
  * @param DiscussionController $Sender
  * @param array $Args
  */
 public function DiscussionController_QnA_Create($Sender, $Args = array())
 {
     $Comment = Gdn::SQL()->GetWhere('Comment', array('CommentID' => $Sender->Request->Get('commentid')))->FirstRow(DATASET_TYPE_ARRAY);
     if (!$Comment) {
         throw NotFoundException('Comment');
     }
     $Discussion = Gdn::SQL()->GetWhere('Discussion', array('DiscussionID' => $Comment['DiscussionID']))->FirstRow(DATASET_TYPE_ARRAY);
     // Check for permission.
     if (!(Gdn::Session()->UserID == GetValue('InsertUserID', $Discussion) || Gdn::Session()->CheckPermission('Garden.Moderation.Manage'))) {
         throw PermissionException('Garden.Moderation.Manage');
     }
     if (!Gdn::Session()->ValidateTransientKey($Sender->Request->Get('tkey'))) {
         throw PermissionException();
     }
     switch ($Args[0]) {
         case 'accept':
             $QnA = 'Accepted';
             break;
         case 'reject':
             $QnA = 'Rejected';
             break;
     }
     if (isset($QnA)) {
         $DiscussionSet = array('QnA' => $QnA);
         $CommentSet = array('QnA' => $QnA);
         if ($QnA == 'Accepted') {
             $CommentSet['DateAccepted'] = Gdn_Format::ToDateTime();
             $CommentSet['AcceptedUserID'] = Gdn::Session()->UserID;
             if (!$Discussion['DateAccepted']) {
                 $DiscussionSet['DateAccepted'] = Gdn_Format::ToDateTime();
                 $DiscussionSet['DateOfAnswer'] = $Comment['DateInserted'];
             }
         }
         // Update the comment.
         Gdn::SQL()->Put('Comment', $CommentSet, array('CommentID' => $Comment['CommentID']));
         // Update the discussion.
         if ($Discussion['QnA'] != $QnA && (!$Discussion['QnA'] || in_array($Discussion['QnA'], array('Unanswered', 'Answered', 'Rejected')))) {
             Gdn::SQL()->Put('Discussion', $DiscussionSet, array('DiscussionID' => $Comment['DiscussionID']));
         }
         // Determine QnA change
         if ($Comment['QnA'] != $QnA) {
             $Change = 0;
             switch ($QnA) {
                 case 'Rejected':
                     $Change = -1;
                     if ($Comment['QnA'] != 'Accepted') {
                         $Change = 0;
                     }
                     break;
                 case 'Accepted':
                     $Change = 1;
                     break;
                 default:
                     if ($Comment['QnA'] == 'Rejected') {
                         $Change = 0;
                     }
                     if ($Comment['QnA'] == 'Accepted') {
                         $Change = -1;
                     }
                     break;
             }
         }
         // Apply change effects
         if ($Change) {
             // Update the user
             $UserID = GetValue('InsertUserID', $Comment);
             $this->RecalculateUserQnA($UserID);
             // Update reactions
             if ($this->Reactions) {
                 include_once Gdn::Controller()->FetchViewLocation('reaction_functions', '', 'plugins/Reactions');
                 $Rm = new ReactionModel();
                 // If there's change, reactions will take care of it
                 $Rm->React('Comment', $Comment['CommentID'], 'AcceptAnswer');
             }
         }
         // Record the activity.
         if ($QnA == 'Accepted') {
             $Activity = array('ActivityType' => 'AnswerAccepted', 'NotifyUserID' => $Comment['InsertUserID'], 'HeadlineFormat' => '{ActivityUserID,You} accepted {NotifyUserID,your} answer.', 'RecordType' => 'Comment', 'RecordID' => $Comment['CommentID'], 'Route' => CommentUrl($Comment, '/'), 'Emailed' => ActivityModel::SENT_PENDING, 'Notified' => ActivityModel::SENT_PENDING);
             $ActivityModel = new ActivityModel();
             $ActivityModel->Save($Activity);
         }
     }
     Redirect("/discussion/comment/{$Comment['CommentID']}#Comment_{$Comment['CommentID']}");
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:89,代码来源:class.qna.plugin.php

示例3: SaveUser

 /**
  * Change ban data on a user (ban or unban them).
  *
  * @since 2.0.18
  * @access public
  *
  * @param array $User
  * @param bool $BannedValue Whether user is banned.
  */
 public function SaveUser($User, $BannedValue, $Ban = FALSE)
 {
     $Banned = $User['Banned'];
     if ($Banned == $BannedValue) {
         return;
     }
     Gdn::UserModel()->SetField($User['UserID'], 'Banned', $BannedValue);
     // Add the activity.
     $ActivityModel = new ActivityModel();
     $Activity = array('ActivityType' => 'Ban', 'ActivityUserID' => $User['UserID'], 'RegardingUserID' => Gdn::Session()->UserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS);
     $BannedString = $BannedValue ? 'banned' : 'unbanned';
     if ($Ban) {
         $Activity['HeadlineFormat'] = '{ActivityUserID,user} was ' . $BannedString . ' (based on {Data.BanType}: {Data.BanValue}).';
         $Activity['Data'] = ArrayTranslate($Ban, array('BanType', 'BanValue'));
         $Activity['Story'] = $Ban['Notes'];
         $Activity['RecordType'] = 'Ban';
         if (isset($Ban['BanID'])) {
             $Activity['BanID'] = $Ban['BanID'];
         }
     } else {
         $Activity['HeadlineFormat'] = '{ActivityUserID,user} was ' . $BannedString . '.';
     }
     $ActivityModel->Save($Activity);
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:33,代码来源:class.banmodel.php

示例4: SaveActivity

 public function SaveActivity($User, $Level, $Reason)
 {
     $UserID = $User->UserID;
     $UserName = $User->Name;
     $HeadlineMods = $Level && $Level != 'None' ? T('Warning.HeadlineMods') : T('Warning.HeadlineModsClear');
     $HeadlineUser = $Level && $Level != 'None' ? T('Warning.HeadlineUser') : T('Warning.HeadlineUserClear');
     $StoryMod = $Level && $Level != 'None' ? T('Warning.NotifyModsMsg') : T('Warning.NotifyModsClearMsg');
     $StoryUser = $Level && $Level != 'None' ? T('Warning.NotifyUserMsg') : T('Warning.NotifyUserClearMsg');
     $ActivityModel = new ActivityModel();
     $Activity = array('ActivityType' => 'Warn', 'ActivityUserID' => Gdn::Session()->UserID, 'RegardingUserID' => $UserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'Story' => $StoryMod, 'RecordType' => 'Warn', 'Notified' => ActivityModel::SENT_PENDING, 'Emailed' => ActivityModel::SENT_PENDING, 'Data' => array('Level' => $Level), 'Level' => $Level, 'Name' => $UserName, 'Reason' => $Reason, 'HeadlineFormat' => $HeadlineMods, 'Route' => 'profile/' . $UserID . '/' . rawurlencode($UserName));
     $UserActivity = $Activity;
     $Activity['Story'] = FormatString($UserActivity['Story'], $Activity);
     $Activity['HeadlineFormat'] = FormatString($Activity['HeadlineFormat'], $Activity);
     $UserActivity['NotifyUserID'] = $UserID;
     $UserActivity['Story'] = FormatString($StoryUser, $Activity);
     $UserActivity['HeadlineFormat'] = FormatString($HeadlineUser, $Activity);
     // Mod Activity
     $ActivityModel->Save($Activity, FALSE, array('Force' => TRUE));
     // User Activity
     $ActivityModel->Save($UserActivity, FALSE, array('Force' => TRUE));
 }
开发者ID:Nordic-T,项目名称:Nordic-T,代码行数:21,代码来源:default.php

示例5: Approve

 /**
  * Approve a membership applicant.
  */
 public function Approve($UserID, $Email)
 {
     $ApplicantRoleID = C('Garden.Registration.ApplicantRoleID', 0);
     // Make sure the $UserID is an applicant
     $RoleData = $this->GetRoles($UserID);
     if ($RoleData->NumRows() == 0) {
         throw new Exception(T('ErrorRecordNotFound'));
     } else {
         $AppRoles = $RoleData->Result(DATASET_TYPE_ARRAY);
         $ApplicantFound = FALSE;
         foreach ($AppRoles as $AppRole) {
             if (GetValue('RoleID', $AppRole) == $ApplicantRoleID) {
                 $ApplicantFound = TRUE;
             }
         }
     }
     if ($ApplicantFound) {
         // Retrieve the default role(s) for new users
         $RoleIDs = C('Garden.Registration.DefaultRoles', array(8));
         // Wipe out old & insert new roles for this user
         $this->SaveRoles($UserID, $RoleIDs, FALSE);
         // Send out a notification to the user
         $User = $this->GetID($UserID);
         if ($User) {
             $Email->Subject(sprintf(T('[%1$s] Membership Approved'), C('Garden.Title')));
             $Email->Message(sprintf(T('EmailMembershipApproved'), $User->Name, ExternalUrl(SignInUrl())));
             $Email->To($User->Email);
             //$Email->From(C('Garden.SupportEmail'), C('Garden.SupportName'));
             $Email->Send();
             // Report that the user was approved.
             $ActivityModel = new ActivityModel();
             $ActivityModel->Save(array('ActivityUserID' => $UserID, 'ActivityType' => 'Registration', 'HeadlineFormat' => T('HeadlineFormat.Registration', '{ActivityUserID,You} joined.'), 'Story' => T('Welcome Aboard!')), FALSE, array('GroupBy' => 'ActivityTypeID'));
             // Report the approval for moderators.
             $ActivityModel->Save(array('ActivityType' => 'Registration', 'ActivityUserID' => Gdn::Session()->UserID, 'RegardingUserID' => $UserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'HeadlineFormat' => T('HeadlineFormat.RegistrationApproval', '{ActivityUserID,user} approved the applications for {RegardingUserID,user}.')), FALSE, array('GroupBy' => array('ActivityTypeID', 'ActivityUserID')));
             Gdn::UserModel()->SaveAttribute($UserID, 'ApprovedByUserID', Gdn::Session()->UserID);
         }
     }
     return TRUE;
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:42,代码来源:class.usermodel.php


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