コード例 #1
0
/**
 * Uninstall b2evolution: Delete DB & Cache files
 */
function uninstall_b2evolution()
{
    global $DB;
    /* REMOVE PAGE CACHE */
    load_class('_core/model/_pagecache.class.php', 'PageCache');
    // Remove general page cache
    $PageCache = new PageCache(NULL);
    $PageCache->cache_delete();
    // Skip if T_blogs table is already deleted. Note that db_delete() will not throw any errors on missing tables.
    if ($DB->query('SHOW TABLES LIKE "T_blogs"')) {
        // Get all blogs
        $blogs_SQL = new SQL();
        $blogs_SQL->SELECT('blog_ID');
        $blogs_SQL->FROM('T_blogs');
        $blogs = $DB->get_col($blogs_SQL->get());
        $BlogCache =& get_BlogCache('blog_ID');
        foreach ($blogs as $blog_ID) {
            $Blog = $BlogCache->get_by_ID($blog_ID);
            // Remove page cache of current blog
            $PageCache = new PageCache($Blog);
            $PageCache->cache_delete();
        }
    }
    /* REMOVE DATABASE */
    db_delete();
    echo '<p>' . T_('Reset done!') . '</p>';
}
コード例 #2
0
 public function delete($item_id)
 {
     // @TODO - try... catch...
     drupal_set_message("Deleted queue item " . $item_id);
     db_delete('queue')->condition('item_id', $item_id)->execute();
     return TRUE;
 }
コード例 #3
0
ファイル: user.api.php プロジェクト: rentasite/drupal
/**
 * Act on user account cancellations.
 *
 * The user account is being canceled. Depending on the account cancellation
 * method, the module should either do nothing, unpublish content, anonymize
 * content, or delete content and data belonging to the canceled user account.
 *
 * Expensive operations should be added to the global batch with batch_set().
 *
 * @param $edit
 *   The array of form values submitted by the user.
 * @param $account
 *   The user object on which the operation is being performed.
 * @param $method
 *   The account cancellation method.
 *
 * @see user_cancel_methods()
 * @see hook_user_cancel_methods_alter()
 * @see user_cancel()
 */
function hook_user_cancel($edit, $account, $method)
{
    switch ($method) {
        case 'user_cancel_block_unpublish':
            // Unpublish nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            node_mass_update($nodes, array('status' => 0));
            break;
        case 'user_cancel_reassign':
            // Anonymize nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            node_mass_update($nodes, array('uid' => 0));
            // Anonymize old revisions.
            db_update('node_revision')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute();
            // Clean history.
            db_delete('history')->condition('uid', $account->uid)->execute();
            break;
        case 'user_cancel_delete':
            // Delete nodes (current revisions).
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            foreach ($nodes as $nid) {
                node_delete($nid);
            }
            // Delete old revisions.
            db_delete('node_revision')->condition('uid', $account->uid)->execute();
            // Clean history.
            db_delete('history')->condition('uid', $account->uid)->execute();
            break;
    }
}
コード例 #4
0
 /**
  * Remove the record IF there are no records referencing this user.
  */
 function updateDatabase($form, $myvalues)
 {
     //Perform some data quality checks now.
     if (!isset($myvalues['protocol_shortname'])) {
         die("Cannot delete record because missing protocol_shortname in array!\n" . var_dump($myvalues));
     }
     $updated_dt = date("Y-m-d H:i", time());
     $protocol_shortname = $myvalues['protocol_shortname'];
     //Backup all the existing records.
     $this->m_oPageHelper->copyProtocolLibToReplacedTable($protocol_shortname);
     $this->m_oPageHelper->copyKeywordsToReplacedTable($protocol_shortname);
     $this->m_oPageHelper->copyTemplateValuesToReplacedTable($protocol_shortname);
     //Delete all the records.
     $num_deleted = db_delete('raptor_protocol_lib')->condition('protocol_shortname', $protocol_shortname)->execute();
     $num_deleted = db_delete('raptor_protocol_keywords')->condition('protocol_shortname', $protocol_shortname)->execute();
     $num_deleted = db_delete('raptor_protocol_template')->condition('protocol_shortname', $protocol_shortname)->execute();
     //Success?
     if ($num_deleted == 1) {
         $feedback = 'The ' . $protocol_shortname . ' protocol has been succesfully deleted.';
         drupal_set_message($feedback);
         return 1;
     }
     //We are here because we failed.
     $feedback = 'Trouble deleting ' . $protocol_shortname . ' protocol!';
     error_log($feedback . ' delete reported ' . $num_deleted);
     drupal_set_message($feedback, 'warning');
     return 0;
 }
コード例 #5
0
 /**
  * Removes all URLs and all priority-rules from the URL-cache.
  */
 public function clear()
 {
     // die('clear');
     // drupal_set_message('<pre>PHPCrawlerD7URLCache::clear ' . print_r('', 1) . '</pre>');
     //     $this->conn->query("DELETE FROM " . $this->table . " WHERE crawler_id = '" . $this->crawler_id . "';");
     db_delete($this->table)->condition('crawler_id', $this->crawler_id)->execute();
 }
コード例 #6
0
ファイル: node_convert.api.php プロジェクト: ehazell/AWBA
/**
 * This is an example implementation for the hook. Preforms actions when converting a node based on it's type.
 *
 * @param $data
 *   An array containing information about the conversion process. The keys are
 *   - dest_node_type  The destination type of the node
 *   - node  The node object
 *   - Any other information passed by $op = 'options' or $op = 'options validate'
 * @param $op
 *   A string containing the operation which should be executed. These are the possible values
 *   - insert  Operations which should be run when the node is transferred to the new node type.
 *   Usually for transferring and adding new node information into the database.
 *   - delete  Operations which should be run after the node is transferred to the new node type.
 *   Usually for deleting unneeded information from the database after the transfer.
 *   - options  Configuration elements shown on the conversion form. Should return a FAPI array.
 *   - options validate  Validation check on the options elements.
 * @return
 *    Should return a FAPI array only when using the options operation.
 */
function hook_node_convert_change($data, $op)
{
    // All of this is just an example.
    if ($op == 'insert') {
        if ($data['dest_node_type'] == 'book') {
            $book = array();
            $node = $data['node'];
            $book['link_path'] = 'node/' . $node->nid;
            $book['link_title'] = $node->title;
            $book['plid'] = 0;
            $book['menu_name'] = book_menu_name($node->nid);
            $mlid = menu_link_save($book);
            $book['bid'] = $data['hook_options']['bid'];
            if ($book['bid'] == 'self') {
                $book['bid'] = $node->nid;
            }
            $id = db_insert('book')->fields(array('nid' => $node->nid, 'mlid' => $book['mlid'], 'bid' => $book['bid']))->execute();
        }
        if ($data['dest_node_type'] == 'forum') {
            $id = db_insert('forum')->fields(array('tid' => $data['hook_options']['forum'], 'vid' => $data['node']->vid, 'nid' => $data['node']->nid))->execute();
            $id = db_insert('taxonomy_term_node')->fields(array('tid' => $data['hook_options']['forum'], 'vid' => $data['node']->vid, 'nid' => $data['node']->nid))->execute();
        }
    } elseif ($op == 'delete') {
        if ($data['node']->type == 'book') {
            menu_link_delete($data['node']->book['mlid']);
            db_delete('book')->condition('mlid', $data['node']->book['mlid'])->execute();
        }
        if ($data['node']->type == 'forum') {
            db_delete('forum')->condition('nid', $data['node']->nid)->execute();
            db_delete('taxonomy_term_node')->condition('nid', $data['node']->nid)->execute();
        }
    } elseif ($op == 'options') {
        $form = array();
        if ($data['dest_node_type'] == 'book') {
            foreach (book_get_books() as $book) {
                $options[$book['nid']] = $book['title'];
            }
            $options = array('self' => '<' . t('create a new book') . '>') + $options;
            $form['bid'] = array('#type' => 'select', '#title' => t('Book'), '#options' => $options, '#description' => t('Your page will be a part of the selected book.'), '#attributes' => array('class' => 'book-title-select'));
        }
        if ($data['dest_node_type'] == 'forum') {
            $vid = variable_get('forum_nav_vocabulary', '');
            $form['forum'] = taxonomy_form($vid);
            $form['forum']['#weight'] = 7;
            $form['forum']['#required'] = TRUE;
            $form['forum']['#options'][''] = t('- Please choose -');
        }
        return $form;
    } elseif ($op == 'options validate') {
        $form_state = $data['form_state'];
        if ($data['dest_node_type'] == 'forum') {
            $containers = variable_get('forum_containers', array());
            $term = $form_state['values']['hook_options']['forum'];
            if (in_array($term, $containers)) {
                $term = taxonomy_term_load($term);
                form_set_error('hook_options][forum', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
            }
        }
    }
}
コード例 #7
0
 public function delete()
 {
     if (!is_numeric($this->record['pid']) || self::load($this->record['pid']) === false) {
         throw new \Exception('The record being deleted does not exist.');
     }
     db_delete('ablecore_menu_item_path')->condition('pid', $this->record['pid'])->execute();
 }
コード例 #8
0
ファイル: DeleteUserPage.php プロジェクト: rmurray1/RAPTOR
 /**
  * Actually removes the record IF there are no records referencing this user.
  * If records do reference it, then only marks it inactive.
  */
 function updateDatabase($myvalues)
 {
     $bHasReferences = UserInfo::userIsReferenced($this->m_nUID);
     $feedback = NULL;
     if ($bHasReferences) {
         $updated_dt = date("Y-m-d H:i", time());
         $nUpdated = db_update('raptor_user_profile')->fields(array('accountactive_yn' => 0, 'updated_dt' => $updated_dt))->condition('uid', $this->m_nUID, '=')->execute();
         if ($nUpdated !== 1) {
             error_log("Failed to edit user back to database!\n" . var_dump($myvalues));
             die("Failed to edit user back to database!\n" . var_dump($myvalues));
         }
         $feedback = 'Marked user as inactive instead of deleted because referenced by other records.';
     } else {
         //Delete all the child records first.
         $num_deleted = db_delete('raptor_user_modality')->condition('uid', $this->m_nUID, '=')->execute();
         $num_deleted = db_delete('raptor_user_anatomy')->condition('uid', $this->m_nUID, '=')->execute();
         $num_deleted = db_delete('raptor_user_group_membership')->condition('uid', $this->m_nUID, '=')->execute();
         //Now delete the profile.
         $num_deleted = db_delete('raptor_user_profile')->condition('uid', $this->m_nUID, '=')->execute();
         if ($this->m_nUID == 1) {
             //Do NOT delete this drupal user or will be very unhappy!
             error_log('Removed user 1 from RAPTOR but left it alone in Drupal users table.');
             $feedback = 'Removed user from RAPTOR system.';
         } else {
             //Now delete the Drupal user.
             $num_deleted = db_delete('users')->condition('uid', $this->m_nUID, '=')->execute();
             $feedback = 'Removed the ADMIN user from RAPTOR system.';
         }
     }
     drupal_set_message($feedback);
     return 1;
 }
コード例 #9
0
ファイル: service.php プロジェクト: Nazg-Gul/gate
 function Destroy()
 {
     $this->service->PerformDeletion();
     if ($this->id > 0) {
         db_delete('service', '`id`=' . $this->id);
     }
 }
コード例 #10
0
ファイル: session_test.php プロジェクト: JoshuaGrams/wfpl
function session_test()
{
    tem_load('code/wfpl/test/session_test.html');
    db_delete('wfpl_sessions');
    db_delete('wfpl_session_data');
    session_dump('Clean slate');
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_dump('username jason');
    session_set('username', 'phil');
    session_dump('overwrote username as phil');
    $old = $GLOBALS['session_id'];
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_set('bamph', 'foo');
    session_dump('set username=jason and bamph=foo in new session');
    session_clear('username');
    session_dump('cleared username in new session');
    _kill_session($old);
    session_dump('killed old session');
    kill_session();
    session_dump('kill_session()');
    tem_output();
}
コード例 #11
0
ファイル: ImportOpmlTest.php プロジェクト: nstielau/drops-8
 /**
  * Submits form with invalid, empty, and valid OPML files.
  */
 protected function submitImportForm()
 {
     $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
     $form['files[upload]'] = $this->getInvalidOpml();
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import'));
     $this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.');
     $edit = array('remote' => file_create_url($this->getEmptyOpml()));
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
     $this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.');
     $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
     $this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.');
     db_delete('aggregator_feed')->execute();
     $feeds[0] = $this->getFeedEditArray();
     $feeds[1] = $this->getFeedEditArray();
     $feeds[2] = $this->getFeedEditArray();
     $edit = array('files[upload]' => $this->getValidOpml($feeds), 'refresh' => '900');
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
     $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url[0][value]'])), 'Verifying that a duplicate URL was identified');
     $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title[0][value]'])), 'Verifying that a duplicate title was identified');
     $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
     $this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
     $feeds_from_db = db_query("SELECT title, url, refresh FROM {aggregator_feed}");
     $refresh = TRUE;
     foreach ($feeds_from_db as $feed) {
         $title[$feed->url] = $feed->title;
         $url[$feed->title] = $feed->url;
         $refresh = $refresh && $feed->refresh == 900;
     }
     $this->assertEqual($title[$feeds[0]['url[0][value]']], $feeds[0]['title[0][value]'], 'First feed was added correctly.');
     $this->assertEqual($url[$feeds[1]['title[0][value]']], $feeds[1]['url[0][value]'], 'Second feed was added correctly.');
     $this->assertTrue($refresh, 'Refresh times are correct.');
 }
コード例 #12
0
 /**
  * Delete an entry from the database.
  *
  */
 public static function delete($entry = array())
 {
     $select = db_delete('ea_contact_method_values');
     foreach ($entry as $field => $value) {
         $select->condition($field, $value);
     }
     $select->execute();
 }
コード例 #13
0
ファイル: Other.php プロジェクト: pedrocones/hydrotools
 /**
  * {@inheritdoc}
  */
 public function orderSave(OrderInterface $order)
 {
     if (empty($order->payment_details['description'])) {
         db_delete('uc_payment_other')->condition('order_id', $order->id())->execute();
     } else {
         db_merge('uc_payment_other')->key(array('order_id' => $order->id()))->fields(array('description' => $order->payment_details['description']))->execute();
     }
 }
コード例 #14
0
 function delete($id)
 {
     if (db_delete($this->table, $this->primary_key . "=" . $id)) {
         return db_delete('order', 'transaction_id=' . $id);
     } else {
         return mysql_affected_rows();
     }
 }
コード例 #15
0
ファイル: user.php プロジェクト: anhnt0212/simple-php-mvc
 function delete($id)
 {
     if (db_delete($this->table, $this->primary_key . "=" . $id)) {
         return db_delete('news', 'admin=' . $id);
     } else {
         return mysql_affected_rows();
     }
 }
コード例 #16
0
 public function __db_delete()
 {
     $id_key = $this->id_key();
     $this->switch_to_db();
     db_delete($this->db_table())->condition($id_key, $this->{$id_key})->execute();
     $this->switch_from_db();
     return $this;
 }
コード例 #17
0
 /**
  * {@inheritdoc}
  */
 public function delete_form_submit(&$form_state)
 {
     parent::delete_form_submit($form_state);
     if (\Drupal::service('module_handler')->moduleExists('openlayers_block')) {
         $delta = _openlayers_block_get_block_id($form_state['item']->machine_name);
         db_delete('block')->condition('module', 'openlayers')->condition('delta', $delta)->execute();
     }
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     db_delete('uc_weightquote_methods')->condition('mid', $this->methodId)->execute();
     db_delete('uc_weightquote_products')->condition('mid', $this->methodId)->execute();
     // rules_config_delete(array('get_quote_from_weightquote_' . $mid));
     drupal_set_message(t('Weight quote shipping method deleted.'));
     $form_state->setRedirect('uc_quote.methods');
 }
コード例 #19
0
 /**
  * Delete the record from the database.
  */
 public function delete()
 {
     db_delete('bean')->condition('type', $this->type)->execute();
     ctools_include('export');
     ctools_export_crud_delete('bean_type', $this->type);
     field_attach_delete_bundle('bean', $this->type);
     bean_reset();
 }
コード例 #20
0
 /**
  * Truncates database tables.
  *
  * @param array $tables
  *   The list of tables to be truncated.
  */
 public function truncateTables(array $tables = array())
 {
     foreach ($tables as $table) {
         if (db_table_exists($table)) {
             db_delete($table)->execute();
         }
     }
 }
コード例 #21
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $account = \Drupal::currentUser();
     $cid = $form_state['values'];
     db_delete('oauth_consumer')->condition('cid', $cid)->execute();
     drupal_set_message('OAuth consumer deleted.');
     $form_state['redirect'] = 'user/' . $account->id() . '/oauth/consumer';
 }
コード例 #22
0
/**
 * Deletes a user_badge from all the tables.
 * It is the caller's responsibilty to let the user know this has been done.
 * The caller must have 'manage badges' permission.
 *
 * @param $bid
 *   The badge ID.
 */
function user_badges_delete_badge($bid)
{
    if (user_access('manage badges')) {
        db_delete('user_badges_badges')->condition('bid', $bid)->execute();
        db_delete('user_badges_user')->condition('bid', $bid)->execute();
        db_delete('user_badges_roles')->condition('bid', $bid)->execute();
    }
}
コード例 #23
0
 /**
  * Confirms that we can delete a single record successfully.
  */
 function testSimpleDelete()
 {
     $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
     $num_deleted = db_delete('test')->condition('id', 1)->execute();
     $this->assertIdentical($num_deleted, 1, 'Deleted 1 record.');
     $num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
     $this->assertEqual($num_records_before, $num_records_after + $num_deleted, 'Deletion adds up.');
 }
コード例 #24
0
 /**
  * Delete an entry from the database.
  *
  */
 public static function delete($entry)
 {
     $select = db_delete('ea_groupings');
     foreach ($entry as $field => $value) {
         $select->condition($field, $value);
     }
     $select->execute();
 }
コード例 #25
0
 /**
  * {@inheritdoc}
  */
 public function process(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     db_delete('uc_order_comments')->condition('order_id', $order->id())->execute();
     if (!$form_state->isValueEmpty(['panes', 'comments', 'comments'])) {
         uc_order_comment_save($order->id(), 0, $form_state->getValue(['panes', 'comments', 'comments']), 'order', uc_order_state_default('post_checkout'), TRUE);
     }
     return TRUE;
 }
コード例 #26
0
 public function delete()
 {
     $query = db_delete(static::$table);
     foreach ($this->values(static::$key) as $field => $value) {
         $query->condition($field, $value);
     }
     $query->execute();
     $this->new = TRUE;
 }
コード例 #27
0
function api_data_preset_gprint_remove($data_preset_gprint_id) {
	/* sanity checks */
	validate_id_die($data_preset_gprint_id, "data_preset_gprint_id");

	db_delete("preset_gprint",
		array(
			"id" => array("type" => DB_TYPE_INTEGER, "value" => $data_preset_gprint_id)
			));
}
コード例 #28
0
/**
 * Performs actions on product classes.
 *
 * @param $type
 *   The node type of the product class.
 * @param $op
 *   The action being performed on the product class:
 *   - insert: A new node type is created, or an existing node type is being
 *     converted into a product type.
 *   - update: A product class has been updated.
 *   - delete: A product class has been deleted. Modules that have attached
 *     additional information to the node type because it is a product type
 *     should delete this information.
 */
function hook_uc_product_class($type, $op)
{
    switch ($op) {
        case 'delete':
            db_delete('uc_class_attributes')->condition('pcid', $type)->execute();
            db_delete('uc_class_attribute_options')->condition('pcid', $type)->execute();
            break;
    }
}
コード例 #29
0
 public function delete()
 {
     if ($this->consumerType) {
         $this->inDatabase = FALSE;
         return db_delete('ldap_authorization')->condition('consumer_type', $this->consumerType)->execute();
     } else {
         return FALSE;
     }
 }
コード例 #30
0
ファイル: agenda.admin.php プロジェクト: xtpclark/ppclc
/**
 * Delete an agenda action
 */
function agenda_admin_delete_submit($form, $form_state)
{
    // Clear the agenda variables table
    db_delete('agenda')->condition('bid', $form_state['values']['agenda_admin_delete_bid'])->execute();
    // Also clear the block table
    db_delete('block')->condition('delta', $form_state['values']['agenda_admin_delete_bid'])->condition('module', 'agenda')->execute();
    drupal_set_message('Agenda block was deleted');
    drupal_goto('admin/config/services/agenda');
}