本文整理汇总了PHP中ActivityModel::canDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP ActivityModel::canDelete方法的具体用法?PHP ActivityModel::canDelete怎么用?PHP ActivityModel::canDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActivityModel
的用法示例。
在下文中一共展示了ActivityModel::canDelete方法的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 ID');
}
if (!$this->ActivityModel->canDelete($this->ActivityModel->getID($ActivityID))) {
throw permissionException();
}
$this->ActivityModel->deleteID($ActivityID);
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
$target = Gdn::request()->get('Target');
if ($target) {
// Bail with a redirect if we got one.
redirect($target);
} else {
// We got this as a full page somehow, so send them back to /activity.
$this->RedirectUrl = url('activity');
}
}
$this->render();
}
示例2: 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 ID');
}
if (!$this->ActivityModel->canDelete($this->ActivityModel->getID($ActivityID))) {
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();
}
示例3: writeActivityComment
function writeActivityComment($Comment, $Activity)
{
$Session = Gdn::session();
$Author = UserBuilder($Comment, 'Insert');
$PhotoAnchor = userPhoto($Author, 'Photo');
$CssClass = 'Item ActivityComment ActivityComment';
if ($PhotoAnchor != '') {
$CssClass .= ' HasPhoto';
}
?>
<li id="ActivityComment_<?php
echo $Comment['ActivityCommentID'];
?>
" class="<?php
echo $CssClass;
?>
">
<?php
if ($PhotoAnchor != '') {
?>
<div class="Author Photo"><?php
echo $PhotoAnchor;
?>
</div>
<?php
}
?>
<div class="ItemContent ActivityComment">
<?php
echo userAnchor($Author, 'Title Name');
?>
<div class="Excerpt"><?php
echo Gdn_Format::to($Comment['Body'], $Comment['Format']);
?>
</div>
<div class="Meta">
<span class="DateCreated"><?php
echo Gdn_Format::date($Comment['DateInserted'], 'html');
?>
</span>
<?php
if (ActivityModel::canDelete($Activity)) {
echo anchor(t('Delete'), "dashboard/activity/deletecomment?id={$Comment['ActivityCommentID']}&tk=" . $Session->TransientKey() . '&target=' . urlencode(Gdn_Url::Request()), 'DeleteComment');
}
?>
</div>
</div>
</li>
<?php
}