示例#1
0
 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
0
	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
0
    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) {