/** * {@inheritdoc} */ public function cleanup() { $nodes = node_load_multiple(array(), array('title' => $this->nodeTitle1), TRUE); node_delete_multiple(array_keys($nodes)); $nodes = node_load_multiple(array(), array('title' => $this->nodeTitle2), TRUE); node_delete_multiple(array_keys($nodes)); }
public function apply ( $patients ) { if ( !is_array($patients) ) { $patients = array($patients); } foreach ( $patients as $patient ) { \LogHelper::log_info('Applying DeleteDataset treatment to: '.$patient->datasetNodeId); // remove columns $columnNodeIds = gd_column_get_columns_4_dataset($patient->datasetNodeId, LOAD_ENTITY_ID_ONLY, INCLUDE_UNPUBLISHED); if ( !empty($columnNodeIds) ) { node_delete_multiple($columnNodeIds); } node_delete($patient->datasetNodeId); } }
public function actionDeleteAll() { if (isset($_POST['date'])) { $date = $_POST['date']; $img_file = PC . '/epaper2/assets/article_img/' . $date; $result = ""; if (!is_dir($img_file)) { header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4"); } else { $dh = opendir($img_file); while ($file = readdir($dh)) { if ($file != "." && $file != "..") { $fullpath = $img_file . "/" . $file; if (!is_dir($fullpath)) { unlink($fullpath); } else { deldir($fullpath); } } } closedir($dh); //删除当前文件夹: if (rmdir($img_file)) { // Article::model()->deleteAll('create_time=:create_time',array(':create_time'=>$date)); Coor::model()->deleteAll('create_time=:create_time', array(':create_time' => $date)); PageCount::model()->deleteAll('create_time=:create_time', array(':create_time' => $date)); Pname::model()->deleteAll('create_time=:create_time', array(':create_time' => $date)); $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node')->entityCondition('bundle', '_xinwen')->fieldCondition('field_riq', 'value', $date); $result = $query->execute(); if (isset($result['node'])) { $news_items_nids = array_keys($result['node']); node_delete_multiple($news_items_nids); } header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/5"); } else { header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4"); } } } else { header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4"); } }
function unl_reset_site_submit($form, &$form_state) { $nids = db_select('node', 'n')->fields('n', array('nid'))->execute()->fetchCol(); node_delete_multiple($nids); variable_set('site_frontpage', 'node'); $mlids = db_select('menu_links', 'm')->fields('m', array('mlid'))->condition('m.menu_name', 'main-menu')->execute()->fetchCol(); foreach ($mlids as $mlid) { menu_link_delete($mlid); } $home_link = array('link_path' => '<front>', 'link_title' => 'Home', 'menu_name' => 'main-menu', 'module' => 'menu'); menu_link_save($home_link); $fids = db_select('file_managed', 'f')->fields('f', array('fid'))->execute()->fetchCol(); $files = file_load_multiple($fids); foreach ($files as $file) { file_delete($file); } $files_dir = DRUPAL_ROOT . '/' . conf_path() . '/files/'; $cmd = 'rm -rf ' . $files_dir . '*'; echo shell_exec($cmd); drupal_mkdir('public://styles/'); variable_set('site_name', 'Site Name'); }
/** * Implements AcsfEventHandler::handle(). */ public function handle() { drush_print(dt('Entered @class', array('@class' => get_class($this)))); $options = $this->event->context['scrub_options']; $limit = $options['batch_node']; if ($options['retain_content']) { return; } if ($options['avoid_oom']) { if ($nids = $this->getItems($limit)) { node_delete_multiple($nids); $this->event->dispatcher->interrupt(); } } else { do { $nids = $this->getItems($limit); if (empty($nids)) { break; } node_delete_multiple($nids); } while (TRUE); } }
/** * {@inheritdoc} */ public function delete(array $entities) { return node_delete_multiple(array_map(function ($entity) { return is_numeric($entity) ? $entity : $entity->id(); }, $entities)); }
/** * Delete entities. This is a copy of entity_delete_multiple() function in * entity.module since entity module may not be present. * * @param string $entity_type * Entity type. * @param int $min_entity_id * Minimum entity id over which all entities will be deleted. * * @return bool * TRUE if entities got deleted and FALSE otherwise. */ public static function deleteEntities($entity_type, $min_entity_id) { $query = new \EntityFieldQuery(); $results = $query->entityCondition('entity_type', $entity_type)->entityCondition('entity_id', $min_entity_id, '>')->execute(); if (isset($results[$entity_type])) { $entity_ids = array_keys($results[$entity_type]); $info = entity_get_info($entity_type); if (isset($info['deletion callback'])) { foreach ($entity_ids as $id) { $info['deletion callback']($id); } } elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) { entity_get_controller($entity_type)->delete($entity_ids); } else { if ($entity_type == 'node') { node_delete_multiple($entity_ids); } elseif ($entity_type == 'user') { user_delete_multiple($entity_ids); } elseif ($entity_type == 'taxonomy_term') { foreach ($entity_ids as $entity_id) { taxonomy_term_delete($entity_id); } } elseif ($entity_type == 'comment') { foreach ($entity_ids as $entity_id) { comment_delete($entity_id); } } return FALSE; } } }
<?php // Variable for the content type to delete. $machine_name = 'page'; // Get a list of all nodes for the given content type. $results = db_select('node', 'n')->fields('n', array('nid'))->condition('type', array($machine_name), 'IN')->execute(); foreach ($results as $result) { $nids[] = $result->nid; } // Delete all the nodes. if (!empty($nids)) { node_delete_multiple($nids); } // Delete content type. node_type_delete($machine_name);
/** * Deletes contents that don't have titles, "Document Moved", "Export.gov Page Not Found" and "The Web site cannot be found". * These contents are scrapped from export.gov and should not be indexed in solr search engine, * Unless otherwise they are properly rendering searched contents. */ function export_gov_micro_page_cleanup() { $query = db_select('node', 'n'); $query->join('field_data_field_exportrip_origin', 'origin', 'n.nid = origin.entity_id'); $query->fields('n', array('nid', 'title'))->condition('n.type', 'export_gov_micro_site_page', '=')->condition(db_and()->condition(db_or()->condition('n.status', 0, '=')->condition('n.status', 1, '=')))->condition(db_and()->condition(db_or()->condition('n.title', '', '=')->condition('n.title', ' ', '=')->condition('n.title', NULL, '=')->condition('n.title', 'Export.gov Page Not Found', '=')->condition('n.title', 'Document Moved', '=')->condition('n.title', 'The Web site cannot be found', '=')))->range(0, 100); $result = $query->execute(); $results = $result->fetchAll(); $w = 0; $x = 0; $y = 0; $z = 0; foreach ($results as $record) { if ($record->title == '' || $record->title == ' ' || $record->title == NULL) { $a[] = $record->nid; $x++; } elseif ($record->title == 'Export.gov Page Not Found') { $b[] = $record->nid; $y++; } elseif ($record->title == 'Document Moved') { $c[] = $record->nid; $z++; } elseif ($record->title == 'The Web site cannot be found') { $d[] = $record->nid; $w++; } } drupal_set_message(t('Total # of contents to be deleted: %count', array('%count' => count($results))), 'warning'); if (!empty($results)) { if (count($a) > 0) { node_delete_multiple($a); drupal_set_message(t('Deleted %count contents that don\'t have titles.', array('%count' => count($a))), 'warning'); } if (count($b) > 0) { node_delete_multiple($b); drupal_set_message(t('Deleted %count content that says "Export.gov Page Not Found".', array('%count' => count($b))), 'warning'); } if (count($c) > 0) { node_delete_multiple($c); drupal_set_message(t('Deleted %count content that has "Document Moved".', array('%count' => count($c))), 'warning'); } if (count($d) > 0) { node_delete_multiple($d); drupal_set_message(t('Deleted %count content that has "The Web site cannot be found".', array('%count' => count($d))), 'warning'); } } else { drupal_set_message(t('Contents found in DB for deletion: %count', array('%count' => count($w + $x + $y + $z) - 1)), 'warning'); } }
/** * {@inheritdoc} */ public function cleanup() { $nodes = node_load_multiple(array(), array('title' => $this->nodeTitle1), TRUE); node_delete_multiple(array_keys($nodes)); // variable_set('drupal_test_email_collector', ''); }
/** * Delete a node with a specific title. * * @param $title * The title of the node. */ public static function deleteNode($title) { node_delete_multiple(array(static::getNodeId($title))); }