예제 #1
0
 public function deleteSource()
 {
     $sources = new Sources();
     $sources->deleteSource($this->_id);
     $settings = new SourcesSettings();
     $settings->deleteSettings($this->_id);
     $this->deleteAllItems();
 }
예제 #2
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);
 }
예제 #3
0
$sources = $sdb->getSources();
// Delete all sources and associated items
if ($sources && count($sources) > 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();