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


PHP ActivityModel::GetID方法代码示例

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


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

示例1: Delete

 /**
  * Delete an activity item.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param int $ActivityID Unique ID of item to delete.
  * @param string $TransientKey Verify intent.
  */
 public function Delete($ActivityID = '', $TransientKey = '')
 {
     $Session = Gdn::Session();
     if (!$Session->ValidateTransientKey($TransientKey)) {
         throw PermissionException();
     }
     if (!is_numeric($ActivityID)) {
         throw Gdn_UserException('Invalid activity ID');
     }
     $HasPermission = $Session->CheckPermission('Garden.Activity.Delete');
     if (!$HasPermission) {
         $Activity = $this->ActivityModel->GetID($ActivityID);
         if (!$Activity) {
             throw NotFoundException('Activity');
         }
         $HasPermission = $Activity['InsertUserID'] == $Session->UserID;
     }
     if (!$HasPermission) {
         throw PermissionException();
     }
     $this->ActivityModel->Delete($ActivityID);
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         Redirect(GetIncomingValue('Target', $this->SelfUrl));
     }
     // Still here? Getting a 404.
     $this->ControllerName = 'Home';
     $this->View = 'FileNotFound';
     $this->Render();
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:38,代码来源:class.activitycontroller.php

示例2: Index

 /**
  * This determines if the current user can react on this item with this action
  *
  * @param string $Type valid options are 'discussion', 'comment', and 'activity'
  * @param int $ID
  * @param int $ActionID
  * @throws Gdn_UserException
  */
 public function Index($Type, $ID, $ActionID)
 {
     $Type = strtolower($Type);
     $Action = $this->ActionModel->GetByID($ActionID);
     // Make sure the action exists and the user is allowed to react
     if (!$Action) {
         throw new Gdn_UserException(T('Yaga.Action.Invalid'));
     }
     if (!Gdn::Session()->CheckPermission($Action->Permission)) {
         throw PermissionException();
     }
     switch ($Type) {
         case 'discussion':
             $Model = new DiscussionModel();
             $AnchorID = '#Discussion_';
             break;
         case 'comment':
             $Model = new CommentModel();
             $AnchorID = '#Comment_';
             break;
         case 'activity':
             $Model = new ActivityModel();
             $AnchorID = '#Activity_';
             break;
         default:
             throw new Gdn_UserException(T('Yaga.Action.InvalidTargetType'));
             break;
     }
     $Item = $Model->GetID($ID);
     if ($Item) {
         $Anchor = $AnchorID . $ID . ' .ReactMenu';
     } else {
         throw new Gdn_UserException(T('Yaga.Action.InvalidTargetID'));
     }
     $UserID = Gdn::Session()->UserID;
     switch ($Type) {
         case 'comment':
         case 'discussion':
             $ItemOwnerID = $Item->InsertUserID;
             break;
         case 'activity':
             $ItemOwnerID = $Item['RegardingUserID'];
             break;
         default:
             throw new Gdn_UserException(T('Yaga.Action.InvalidTargetType'));
             break;
     }
     if ($ItemOwnerID == $UserID) {
         throw new Gdn_UserException(T('Yaga.Error.ReactToOwn'));
     }
     // It has passed through the gauntlet
     $this->ReactionModel->Set($ID, $Type, $ItemOwnerID, $UserID, $ActionID);
     $this->JsonTarget($Anchor, RenderReactionList($ID, $Type, FALSE), 'ReplaceWith');
     // Don't render anything
     $this->Render('Blank', 'Utility', 'Dashboard');
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:64,代码来源:class.reactcontroller.php

示例3: GetRecord

 function GetRecord($RecordType, $ID, $ThrowError = FALSE)
 {
     $Row = FALSE;
     switch (strtolower($RecordType)) {
         case 'discussion':
             $Model = new DiscussionModel();
             $Row = $Model->GetID($ID);
             $Row->Url = DiscussionUrl($Row);
             $Row->ShareUrl = $Row->Url;
             if ($Row) {
                 return (array) $Row;
             }
             break;
         case 'comment':
             $Model = new CommentModel();
             $Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Url'] = Url("/discussion/comment/{$ID}#Comment_{$ID}", TRUE);
                 $Model = new DiscussionModel();
                 $Discussion = $Model->GetID($Row['DiscussionID']);
                 if ($Discussion) {
                     $Discussion->Url = DiscussionUrl($Discussion);
                     $Row['ShareUrl'] = $Discussion->Url;
                     $Row['Name'] = $Discussion->Name;
                     $Row['Discussion'] = (array) $Discussion;
                 }
                 return $Row;
             }
             break;
         case 'activity':
             $Model = new ActivityModel();
             $Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Name'] = FormatString($Row['HeadlineFormat'], $Row);
                 $Row['Body'] = $Row['Story'];
                 return $Row;
             }
         default:
             throw new Gdn_UserException(sprintf("I don't know what a %s is.", strtolower($RecordType)));
     }
     if ($ThrowError) {
         throw NotFoundException($RecordType);
     } else {
         return FALSE;
     }
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:46,代码来源:functions.general.php


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