本文整理匯總了PHP中Gdn_Model::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gdn_Model::delete方法的具體用法?PHP Gdn_Model::delete怎麽用?PHP Gdn_Model::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Gdn_Model
的用法示例。
在下文中一共展示了Gdn_Model::delete方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deleteEditorUploads
/**
* Remove file from filesystem, and clear db entry.
*
* @param type $FileID
* @param type $ForeignID
* @param type $ForeignType
* @return boolean
*/
protected function deleteEditorUploads($MediaID, $ForeignID = '', $ForeignType = '')
{
// Save data to database using model with media table
$Model = new Gdn_Model('Media');
$Media = (array) $Model->getID($MediaID);
$IsOwner = !empty($Media['InsertUserID']) && Gdn::session()->UserID == $Media['InsertUserID'];
// @todo Per-category edit permission would be better, but this global is far simpler to check here.
// However, this currently matches the permission check in views/attachments.php so keep that in sync.
$CanDelete = $IsOwner || Gdn::session()->checkPermission('Garden.Moderation.Manage');
if ($Media && $CanDelete) {
try {
if ($Model->delete($MediaID)) {
// unlink the images.
$path = PATH_UPLOADS . '/' . $Media['Path'];
$thumbPath = PATH_UPLOADS . '/' . $Media['ThumbPath'];
if (file_exists($path)) {
unlink($path);
}
if (file_exists($thumbPath)) {
unlink($thumbPath);
}
}
} catch (Exception $e) {
die($e->getMessage());
return false;
}
return true;
}
return false;
}
示例2: deleteEditorUploads
/**
* Remove file from filesystem, and clear db entry.
*
* @param type $FileID
* @param type $ForeignID
* @param type $ForeignType
* @return boolean
*/
protected function deleteEditorUploads($MediaID, $ForeignID = '', $ForeignType = '')
{
// Save data to database using model with media table
$Model = new Gdn_Model('Media');
$Media = (array) $Model->getID($MediaID);
$IsOwner = !empty($Media['InsertUserID']) && Gdn::session()->UserID == $Media['InsertUserID'];
// @todo Per-category edit permission would be better, but this global is far simpler to check here.
// However, this currently matches the permission check in views/attachments.php so keep that in sync.
$CanDelete = $IsOwner || Gdn::session()->checkPermission('Garden.Moderation.Manage');
if ($Media && $CanDelete) {
try {
if ($Model->delete($MediaID)) {
// unlink the images.
$path = PATH_UPLOADS . '/' . $Media['Path'];
$thumbPath = PATH_UPLOADS . '/' . $Media['ThumbPath'];
if (file_exists($path)) {
unlink($path);
}
if (file_exists($thumbPath)) {
unlink($thumbPath);
}
// Clear the cache, if exists.
/*$discussionID = '';
if ($Media['ForeignTable'] == 'discussion') {
$discussionID = $Media['ForeignID'];
} elseif ($Media['ForeignTable'] == 'comment') {
$commentModel = new CommentModel();
$commentRow = $commentModel->getID($Media['ForeignID'], DATASET_TYPE_ARRAY);
if ($commentRow) {
$discussionID = $commentRow['DiscussionID'];
}
}
if ($discussionID) {
$cacheKey = sprintf(self::DISCUSSION_MEDIA_CACHE_KEY, $discussionID);
Gdn::cache()->Remove($cacheKey);
}*/
}
} catch (Exception $e) {
die($e->getMessage());
return false;
}
return true;
}
return false;
}
示例3: delete
/**
* Delete a message.
*
* @param array|int $where The where clause to delete or an integer value.
* @param array|true $options An array of options to control the delete.
* @return bool Returns **true** on success or **false** on failure.
*/
public function delete($where = [], $options = [])
{
$result = parent::delete($where, $options);
self::messages(null);
return $result;
}
示例4: delete
/**
* Delete a message.
*
* @param string $Where
* @param bool $Limit
* @param bool $ResetData
*/
public function delete($Where = '', $Limit = false, $ResetData = false)
{
parent::delete($Where, $Limit, $ResetData);
self::messages(null);
}
示例5: deletePicture
/**
* Delete a screenshot from an addon.
*
* @param string $AddonPictureID Picture id to remove.
* @throws Gdn_UserException No permission to delete this picture.
*/
public function deletePicture($AddonPictureID = '')
{
$AddonPictureModel = new Gdn_Model('AddonPicture');
$Picture = $AddonPictureModel->getWhere(array('AddonPictureID' => $AddonPictureID))->firstRow();
$AddonModel = new AddonModel();
$Addon = $AddonModel->getID($Picture->AddonID);
$Session = Gdn::session();
if ($Session->UserID != $Addon['InsertUserID'] && !$Session->checkPermission('Addons.Addon.Manage')) {
throw permissionException();
}
if ($this->Form->authenticatedPostBack() && $this->Form->getFormValue('Yes')) {
if ($Picture) {
$Upload = new Gdn_Upload();
$Upload->delete(changeBasename($Picture->File, 'ao%s'));
$Upload->delete(changeBasename($Picture->File, 'at%s'));
$AddonPictureModel->delete(array('AddonPictureID' => $AddonPictureID));
}
$this->RedirectUrl = url('/addon/' . $Picture->AddonID);
}
$this->render('deletepicture');
}
示例6: delete
/**
* Remove a ban.
*
* @param array|int $where The where clause to delete or an integer value.
* @param array|true $options An array of options to control the delete.
* @return bool Returns **true** on success or **false** on failure.
*/
public function delete($where = [], $options = [])
{
if (isset($where['BanID'])) {
$OldBan = $this->getID($where['BanID'], DATASET_TYPE_ARRAY);
}
$result = parent::delete($where, $options);
if (isset($OldBan)) {
$this->ApplyBan(null, $OldBan);
}
return $result;
}
示例7: deleteID
/**
* Delete a particular activity item.
*
* @param int $ActivityID The unique ID of activity to be deleted.
* @param array $Options Not used.
*/
public function deleteID($ActivityID, $Options = array())
{
// Get the activity first.
$Activity = $this->getID($ActivityID);
if ($Activity) {
// Log the deletion.
$Log = val('Log', $Options);
if ($Log) {
LogModel::insert($Log, 'Activity', $Activity);
}
// Delete comments on the activity item
$this->SQL->delete('ActivityComment', array('ActivityID' => $ActivityID));
// Delete the activity item
parent::delete(array('ActivityID' => $ActivityID));
}
}
示例8: delete
/**
* {@inheritdoc}
*/
public function delete($where = [], $options = [])
{
if (is_numeric($where)) {
deprecated('ActivityModel->delete(int)', 'ActivityModel->deleteID(int)');
$result = $this->deleteID($where, $options);
return $result;
} elseif (count($where) === 1 && isset($where['ActivityID'])) {
return parent::delete($where, $options);
}
throw new \BadMethodCallException("ActivityModel->delete() is not supported.", 400);
}