本文整理汇总了PHP中Comments::deleteComments方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::deleteComments方法的具体用法?PHP Comments::deleteComments怎么用?PHP Comments::deleteComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::deleteComments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteAction
public function deleteAction()
{
// Get the source from the request and initialize the model
$id = $this->_getParam('id');
// Get the sources database
$sources = new Sources();
// Check if the source exists
if (!($source = $sources->getSource($id))) {
return $this->_helper->json->sendJson(true);
}
// Check if we own the source
if ($source['user_id'] != $this->_application->user->id) {
return $this->_helper->json->sendJson(true);
}
// Instantiate a model and remove all the data
$model = SourceModel::newInstance($source['service']);
$model->setSource($source);
$model->deleteItems();
// Delete the duplicated from the Data table
$data = new Data();
$data->deleteItems($source['id']);
// Delete the source settings
$properties = new SourcesProperties(array(Properties::KEY => $source['id']));
$properties->deleteAllProperties();
// Delete the tags
$tags = new Tags();
$tags->deleteSource($source['id']);
// Remove the source
$sources->deleteSource($id);
// We should also delete the associated comments
$comments = new Comments();
$comments->deleteComments($source['id']);
// Forward to the list view with a success message
return $this->_helper->json->sendJson(false);
}
示例2: deleteAction
public function deleteAction() {
// Get, check and setup the parameters
$item_id = $this->getRequest()->getParam("id");
// Get the source
$source_id = $this->_properties->getProperty('stuffpress_source');
//Verify if the requested item exist
$data = new Data();
if (!($item = $data->getItem($source_id, $item_id))) {
throw new Stuffpress_NotFoundException("This item does not exist.");
}
// Get the user
$users = new Users();
$attributes = $item->getAttributes();
$user = $users->getUser($attributes['user_id']);
// Check if we are the owner
if ($this->_application->user->id != $user->id) {
throw new Stuffpress_NotFoundException("Not the owner");
}
// Create the source
$source = StuffpressModel::forUser($user->id);
// If an image or audio file, delete the files
$file = $item->getFile();
if ($file) {
$files = new Files();
$files->deleteFile($file);
}
// All checks ok, we can delete !
$data->deleteItem($source_id, $item_id);
$source->deleteItem($item_id);
// We should also delete the associated comments
$comments = new Comments();
$comments->deleteComments($source->getID(), $item_id);
// return that everything is fine
return $this->_helper->json->sendJson(true);
}
示例3: foreach
foreach ($sources as $source) {
// Instantiate a model and remove all the data
$model = SourceModel::newInstance($source['service']);
$model->setSource($source);
$model->deleteItems();
// Delete the duplicated from the Data table
$data = new Data();
$data->deleteItems($source['id']);
// Delete the source settings
$properties = new SourcesProperties(array(Properties::KEY => $source['id']));
$properties->deleteAllProperties();
// Remove the source
$sdb->deleteSource($source['id']);
// We should also delete the associated comments
$comments = new Comments();
$comments->deleteComments($source['id']);
}
}
// Delete all user files
$fdb = new Files();
$files = $fdb->getFiles();
if ($files && count($files) > 0) {
foreach ($files as $file) {
$fdb->deleteFile($file->key);
}
}
// Delete all stories
$stdb = new Stories();
$stories = $stdb->getStories();
if ($stories && count($stories) > 0) {
foreach ($stories as $story) {