本文整理汇总了PHP中ActivityModel::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP ActivityModel::getID方法的具体用法?PHP ActivityModel::getID怎么用?PHP ActivityModel::getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActivityModel
的用法示例。
在下文中一共展示了ActivityModel::getID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->delete($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: comment
/**
* Comment on an activity item.
*
* @since 2.0.0
* @access public
*/
public function comment()
{
$this->permission('Garden.Profiles.Edit');
$Session = Gdn::session();
$this->Form->setModel($this->ActivityModel);
$NewActivityID = 0;
// Form submitted
if ($this->Form->authenticatedPostBack()) {
$Body = $this->Form->getValue('Body', '');
$ActivityID = $this->Form->getValue('ActivityID', '');
if (is_numeric($ActivityID) && $ActivityID > 0) {
$activity = $this->ActivityModel->getID($ActivityID);
if ($activity) {
if ($activity['NotifyUserID'] == ActivityModel::NOTIFY_ADMINS) {
$this->permission('Garden.Settings.Manage');
} elseif ($activity['NotifyUserID'] == ActivityModel::NOTIFY_MODS) {
$this->permission('Garden.Moderation.Manage');
}
} else {
throw new Exception(t('Invalid activity'));
}
$ActivityComment = array('ActivityID' => $ActivityID, 'Body' => $Body, 'Format' => 'Text');
$ID = $this->ActivityModel->comment($ActivityComment);
if ($ID == SPAM || $ID == UNAPPROVED) {
$this->StatusMessage = t('ActivityCommentRequiresApproval', 'Your comment will appear after it is approved.');
$this->render('Blank', 'Utility');
return;
}
$this->Form->setValidationResults($this->ActivityModel->validationResults());
if ($this->Form->errorCount() > 0) {
throw new Exception($this->ActivityModel->Validation->resultsText());
$this->errorMessage($this->Form->errors());
}
}
}
// Redirect back to the sending location if this isn't an ajax request
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
$Target = $this->Form->getValue('Return');
if (!$Target) {
$Target = '/activity';
}
redirect($Target);
} else {
// Load the newly added comment.
$this->setData('Comment', $this->ActivityModel->getComment($ID));
// Set it in the appropriate view.
$this->View = 'comment';
}
// And render
$this->render();
}
示例3: 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();
}
示例4: getRecord
/**
* Get a record from the database.
*
* @param string $recordType The type of record to get. This is usually the un-prefixed table name of the record.
* @param int $id The ID of the record.
* @param bool $throw Whether or not to throw an exception if the record isn't found.
* @return array|false Returns an array representation of the record or false if the record isn't found.
* @throws Exception Throws an exception with a 404 code if the record isn't found and {@link $throw} is true.
* @throws Gdn_UserException Throws an exception when {@link $recordType} is unknown.
*/
function getRecord($recordType, $id, $throw = 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;
}
break;
default:
throw new Gdn_UserException('Unknown record type requested.');
}
if ($throw) {
throw NotFoundException();
} else {
return false;
}
}