コード例 #1
13
 /**
  * Implements AcsfEventHandler::handle().
  */
 public function handle()
 {
     drush_print(dt('Entered @class', array('@class' => get_class($this))));
     // Clear the theme field so all users will use the default theme.
     db_update('users')->fields(array('theme' => 0))->execute();
     // Clear any in-progress multistep forms that are not normally wiped during
     // cache-clear. The other caches are expected to be cleared externally from
     // this process.
     cache_clear_all('*', 'cache_form', TRUE);
     // Clean up ACSF variables.
     $acsf_variables = acsf_vget_group('acsf_duplication_scrub');
     foreach ($acsf_variables as $name => $value) {
         acsf_vdel($name);
     }
     // Begin the site without any watchdog records. This should happen right at
     // the end of the scubbing process to remove any log entries added by the
     // scrubbing process itself.
     if (db_table_exists('watchdog')) {
         db_delete('watchdog')->execute();
     }
     // Mark the entire scrubbing process as complete.
     variable_set('acsf_duplication_scrub_status', 'complete');
 }
コード例 #2
0
ファイル: admin.php プロジェクト: reasonat/women
 /**
  * Show the pending update notice on admin pages
  *
  */
 public static function show_pending_update_notice(&$vars)
 {
     if (ShareaholicUtilities::is_admin_page() && ShareaholicUtilities::has_accepted_terms_of_service() && !db_table_exists('shareaholic_content_settings') && user_access('administer modules')) {
         $message = sprintf(t('Action required: You have pending updates required by Shareaholic. Please go to update.php for more information.'));
         $vars['page'] = self::header_message_html($message) . $vars['page'];
     }
 }
コード例 #3
0
ファイル: node.php プロジェクト: reasonat/women
/**
 * Implements hook_form_node_form_alter().
 *
 * When the node form is presented, add additional options
 * for Shareaholic Apps
 *
 * @param Array $form - Nested array of form elements
 * @param Array $form_state - keyed array containing form state
 * @param $form_id - String representing the name of the form itself
 */
function shareaholic_form_node_form_alter(&$form, &$form_state, $form_id)
{
    $node = $form['#node'];
    $form['shareaholic_options'] = array('#type' => 'fieldset', '#access' => TRUE, '#title' => 'Shareaholic Options', '#collapsible' => TRUE, '#collapsed' => TRUE, '#group' => 'additional_settings', '#weight' => 100);
    // I have to namespace it this way because Drupal can't add
    // the shareholic_options name to it
    // when you process the form on submit!!!
    $form['shareaholic_options']['shareaholic_hide_share_buttons'] = array('#type' => 'checkbox', '#title' => 'Hide Share Buttons');
    $form['shareaholic_options']['shareaholic_hide_recommendations'] = array('#type' => 'checkbox', '#title' => 'Hide Related Content');
    $form['shareaholic_options']['shareaholic_exclude_from_recommendations'] = array('#type' => 'checkbox', '#title' => 'Exclude from Related Content');
    $form['shareaholic_options']['shareaholic_exclude_og_tags'] = array('#type' => 'checkbox', '#title' => 'Do not include Open Graph tags');
    if (!db_table_exists('shareaholic_content_settings')) {
        $form['shareaholic_options']['shareaholic_message'] = array('#type' => 'markup', '#markup' => '<p style="color:#FF0000;">' . t('Action required: you have some pending updates required by Shareaholic. Please go to update.php for more information.') . '</p>');
    }
    if ($node->shareaholic_options['shareaholic_exclude_from_recommendations']) {
        $form['shareaholic_options']['shareaholic_exclude_from_recommendations']['#attributes'] = array('checked' => 'checked');
    }
    if ($node->shareaholic_options['shareaholic_hide_recommendations']) {
        $form['shareaholic_options']['shareaholic_hide_recommendations']['#attributes'] = array('checked' => 'checked');
    }
    if ($node->shareaholic_options['shareaholic_hide_share_buttons']) {
        $form['shareaholic_options']['shareaholic_hide_share_buttons']['#attributes'] = array('checked' => 'checked');
    }
    if ($node->shareaholic_options['shareaholic_exclude_og_tags']) {
        $form['shareaholic_options']['shareaholic_exclude_og_tags']['#attributes'] = array('checked' => 'checked');
    }
}
コード例 #4
0
ファイル: content_settings.php プロジェクト: reasonat/women
 /**
  * Implements hook_node_delete().
  *
  * Delete the content settings for a node
  * @param Object $node the node that will be deleted
  */
 public static function delete($node)
 {
     if (!db_table_exists('shareaholic_content_settings')) {
         return;
     }
     db_delete('shareaholic_content_settings')->condition('nid', $node->nid)->execute();
 }
コード例 #5
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();
         }
     }
 }
コード例 #6
0
ファイル: DBManager.php プロジェクト: alexrayu/stlpmadmin
 /**
  * Ensure that the table for an app exists.
  * @param $nid
  * The app nid.
  */
 private function ensureAppTable($nid)
 {
     if (!db_table_exists('app_' . $nid)) {
         db_create_table('app_' . $nid, $this->getAppTableSchema($nid));
     } else {
         $this->pruneAppTable($nid);
     }
 }
function translationwizard_uninstall()
{
    output_notl("Performing Uninstall on Translation Wizard. Thank you for using!`n`n");
    if (db_table_exists(db_prefix("temp_translations"))) {
        db_query("DROP TABLE " . db_prefix("temp_translations"));
    }
    return true;
}
コード例 #8
0
ファイル: file.php プロジェクト: Nazg-Gul/gate
 function file_check_tables()
 {
     if (config_get('check-database')) {
         if (!db_table_exists('files')) {
             db_create_table_safe('files', array('id' => 'INT NOT NULL ' . 'PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'orig_name' => 'TEXT', 'access' => 'INT', 'blocked' => 'BOOL'));
         }
     }
 }
コード例 #9
0
ファイル: market.php プロジェクト: Nazg-Gul/e-marsa
 function CheckTables()
 {
     if (!config_get('check-database')) {
         return;
     }
     if (!db_table_exists('market_basket')) {
         db_create_table_safe('market_basket', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'user_id' => 'INT', 'session_id' => 'TEXT DEFAULT ""', 'item_id' => 'INT', 'timestamp' => 'INT'));
     }
 }
コード例 #10
0
ファイル: wiki.php プロジェクト: Nazg-Gul/gate
 function wiki_initialize()
 {
     if (config_get('check-database')) {
         if (!db_table_exists('content')) {
             db_create_table_safe('content', array('id' => 'INT NOT NULL PRIMARY ' . 'KEY AUTO_INCREMENT', 'order' => 'INT', 'pid' => 'INT DEFAULT 1', 'class' => 'TEXT', 'name' => 'TEXT', 'path' => 'TEXT', 'settings' => 'TEXT DEFAULT ""'));
             db_insert('content', array('order' => '1', 'pid' => '0', 'name' => '"Корневой раздел"', 'path' => '"/"', 'settings' => '"' . addslashes('a:1:{s:8:"security";a:1:' . '{s:3:"ALL";a:2:{s:5:"order";s:10:"allow_deny";s:4:"acts";' . 'a:1:{i:0;a:2:{s:3:"act";s:8:"AllowAll";s:3:"val";' . 's:0:"";}}}}}') . '"'));
         }
     }
 }
コード例 #11
0
 function query($iteratorClass = 'GoogleMiniResultIterator') {
   if (!db_table_exists('cache_google_appliance')) {
     $this->cache = FALSE;
   }
   if (!$this->cache) {
     return parent::query($iteratorClass);
   }
   else {
     $cached_result_obj = NULL;
     $cache_key = md5($this->buildQuery());
     $_cached_result_xml = cache_get($cache_key, 'cache_google_appliance');
     $cached_result_xml = $_cached_result_xml->data;
     $google_debug = variable_get('google_appliance_debug', 0);
     if ($cached_result_xml) {
       try {
         $google_results = GoogleMini::resultFactory($cached_result_xml, $iteratorClass);
       }
       catch (Exception $e) {
         drupal_set_message($e->getMessage(), 'error');
         watchdog('google_appliance', $e->getMessage());
         return FALSE;
       }
       if ($google_debug >= 2 ){
         if (function_exists('dpr')) {
           dpr("got cache for $cache_key");
         }
       }
       elseif ($google_debug == 1)  {
         watchdog('google_appliance', "got cache for !cache_key at !url", array('!cache_key' => $cache_key, '!url' => $_GET['q']));
       }
     }
     else {
       try {
         $google_results = parent::query($iteratorClass);
       }
       catch (Exception $e) {
         drupal_set_message($e->getMessage(), 'error');
         watchdog('google_appliance', $e->getMessage());
         return FALSE;
       }
       $timeout = variable_get('google_appliance_cache_timeout', 600); // 10 minutes by default
       cache_set($cache_key, $google_results->payload->asXML(), 'cache_google_appliance', time() + $timeout);
       $google_debug = variable_get('google_debug', 0);
       if ($google_debug >= 2 ){
         if (function_exists('dpr')) {
           dpr("setting cache for $cache_key");
         }
       }
       elseif ($google_debug == 1)  {
         watchdog('google_appliance', "setting cache for !cache_key at !url", array('!cache_key' => $cache_key, '!url' => $_GET['q']));
       }
     }
     return $google_results;
   }
 }
コード例 #12
0
 /**
  * Assert that none of the tables defined in a module's hook_schema() exist.
  *
  * @param $module
  *   The name of the module.
  */
 function assertModuleTablesDoNotExist($module)
 {
     $tables = array_keys(drupal_get_module_schema($module));
     $tables_exist = FALSE;
     foreach ($tables as $table) {
         if (db_table_exists($table)) {
             $tables_exist = TRUE;
         }
     }
     return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', array('@module' => $module)));
 }
function riddles_install()
{
    if (db_table_exists(db_prefix("riddles"))) {
        debug("Riddles table already exists");
    } else {
        debug("Creating riddles table.");
        // This is pulled out to another file just because it's so big.
        // no reason to parse it every time this module runs.
        require_once "modules/riddles/riddles_install.php";
    }
    module_addhook("superuser");
    module_addeventhook("forest", "return 100;");
    return true;
}
コード例 #14
0
ファイル: uploader_sh.php プロジェクト: juanmnl07/ageco
function create_table()
{
    if (db_table_exists('shortcut_dataset') === True) {
        if (DEBUG) {
            echo "table already exists<br>\n";
        }
        return;
    } else {
        if (DEBUG) {
            echo "create new table<br>\n";
        }
        db_query("create table shortcut_dataset(id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, val TEXT NOT NULL)");
    }
}
コード例 #15
0
 /**
  * Tests that updates from schema versions prior to 8000 are prevented.
  */
 function testInvalidMigration()
 {
     // Mock a D7 system table so that the schema value of the system module
     // can be retrieved.
     db_create_table('system', $this->getSystemSchema());
     // Assert that the table exists.
     $this->assertTrue(db_table_exists('system'), 'The table exists.');
     // Insert a value for the system module.
     db_insert('system')->fields(array('name' => 'system', 'schema_version' => 7000))->execute();
     $system_schema = db_query('SELECT schema_version FROM {system} WHERE name = :system', array(':system' => 'system'))->fetchField();
     $this->drupalGet($this->update_url, array('external' => TRUE));
     $text = 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must <a href="https://drupal.org/node/2179269">migrate your site to Drupal 8</a> first.';
     $this->assertRaw($text, 'Updates from schema versions prior to 8000 are prevented.');
 }
コード例 #16
0
ファイル: upgrade_inc.php プロジェクト: centaurustech/BenFund
 function is_applied()
 {
     $t_upgrade_table = config_get_global('mantis_upgrade_table');
     if (!db_table_exists($t_upgrade_table)) {
         return false;
     }
     $query = "SELECT COUNT(*)\n\t\t\t\t\t  FROM {$t_upgrade_table}\n\t\t\t\t\t  WHERE upgrade_id = '{$this->id}'";
     $result = db_query($query);
     if (0 < db_result($result)) {
         return true;
     } else {
         return false;
     }
 }
コード例 #17
0
ファイル: database.php プロジェクト: wells5609/wp-app
 /**
  * Attempts to drop a database table if it exists.
  * 
  * @param string $table_name
  * @param string $drop_ddl
  * @return boolean Whether the table exists.
  */
 function maybe_drop_table($table_name, $drop_ddl)
 {
     global $wpdb;
     if (strpos($table_name, $wpdb->prefix) !== 0) {
         $table_name = $wpdb->prefix . $table_name;
     }
     $dropped = false;
     foreach ($wpdb->get_col('SHOW TABLES', 0) as $table) {
         if ($table === $table_name) {
             $GLOBALS['wpdb']->query($drop_ddl);
             $dropped = true;
             break;
         }
     }
     return $dropped ? db_table_exists($table_name, true) : false;
 }
function drinks_install_private()
{
    if (db_table_exists(db_prefix("drinks"))) {
        debug("Drinks table already exists");
    } else {
        debug("Creating drinks table");
        $sqls = array("CREATE TABLE " . db_prefix("drinks") . " (\r\n\t\t\t\tdrinkid smallint(6) NOT NULL auto_increment,\r\n\t\t\t\tname varchar(25) NOT NULL default '',\r\n\t\t\t\tactive tinyint(4) NOT NULL default '0',\r\n\t\t\t\tcostperlevel int(11) NOT NULL default '0',\r\n\t\t\t\thpchance tinyint(4) NOT NULL default '0',\r\n\t\t\t\tturnchance tinyint(4) NOT NULL default '0',\r\n\t\t\t\talwayshp tinyint(4) NOT NULL default '0',\r\n\t\t\t\talwaysturn tinyint(4) NOT NULL default '0',\r\n\t\t\t\tdrunkeness tinyint(4) NOT NULL default '0',\r\n\t\t\t\tharddrink tinyint(4) NOT NULL default '0',\r\n\t\t\t\thpmin int(11) NOT NULL default '0',\r\n\t\t\t\thpmax int(11) NOT NULL default '0',\r\n\t\t\t\thppercent int(11) NOT NULL default '0',\r\n\t\t\t\tturnmin int(11) NOT NULL default '0',\r\n\t\t\t\tturnmax int(11) NOT NULL default '0',\r\n\t\t\t\tremarks text NOT NULL default '',\r\n\t\t\t\tbuffname varchar(50) NOT NULL default '',\r\n\t\t\t\tbuffrounds tinyint(4) NOT NULL default '0',\r\n\t\t\t\tbuffroundmsg varchar(75) NOT NULL default '',\r\n\t\t\t\tbuffwearoff varchar(75) NOT NULL default '',\r\n\t\t\t\tbuffatkmod text NOT NULL,\r\n\t\t\t\tbuffdefmod text NOT NULL,\r\n\t\t\t\tbuffdmgmod text  NOT NULL,\r\n\t\t\t\tbuffdmgshield text NOT NULL,\r\n\t\t\t\tbuffeffectfailmsg varchar(255) NOT NULL default '',\r\n\t\t\t\tbuffeffectnodmgmsg varchar(255) NOT NULL default '',\r\n\t\t\t\tbuffeffectmsg varchar(255) NOT NULL default '',\r\n\t\t\t\tPRIMARY KEY  (drinkid)) TYPE=MyISAM", "INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Ale', 1, 10, 2, 1, 0, 0, 33, 0, 0, 0, 10, 1, 1, 'Cedrik pulls out a glass, and pours a foamy ale from a tapped barrel behind him.  He slides it down the bar, and you catch it with your warrior-like reflexes.`n`nTurning around, you take a big chug of the hearty draught, and give {lover} an ale-foam mustache smile.`n`n', '`#Buzz', 10, 'You\\'ve got a nice buzz going.', 'Your buzz fades.', '1.25', '0', '0', '0', '', '', '')", "INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Habanero Martini', 1, 15, 0, 0, 1, 1, 50, 1, -5, 15, 0.0, -1, 1, 'Cedrik pulls out a bottle labeled with 3 X\\'s and a chile pepper and pours a miniscule shot into your glass.  You toss it back and grimace as smoke floods out of your ears.', '`\$Hot Hands', 12, 'You feel like your hands are about to burn off.', 'Finally, your hands are no longer burning.', '1.1', '.9', '1.5', '0', '', '', '')", "INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Mule Daniels', 1, 25, 2, 3, 0, 0, 50, 1, -10, -1, 0.0, 1, 3, 'Cedrik drags a large pony-keg out from behind the bar and pours a slug into a cast iron cup which rattles as the thick liquid is poured into it.  You toss it back in a gulp and make a face like a mule kicked you hard in the gut.  From across the room, you hear {lover} laugh at you.', '`#Mulekick', 15, 'You hear a donkey braying in the distance', 'That donkey finally shuts up.', '0', '0', '1.3', '1.3', 'Your head rings as the donkey kicks you instead.', 'That mule would have kicked {badguy} to the moon, but it missed!', '{badguy} sees`\$ {damage}`) stars as the mule kicks him over the moon.')");
        while (list($key, $sql) = each($sqls)) {
            db_query($sql);
        }
    }
    // See if we're migrating from an old version of the drinks code with a
    // buffactivate field
    $sql = "DESCRIBE " . db_prefix("drinks");
    $result = db_query($sql);
    while ($row = db_fetch_assoc($result)) {
        if ($row['Field'] == "buffactivate") {
            debug("Dropping buffactivate from the drinks table.");
            $sql = "ALTER TABLE " . db_prefix("drinks") . " DROP buffactivate";
            db_query($sql);
        }
        // end if
        if ($row['Field'] == "hppercent" && $row['Type'] == "float") {
            debug("Altering {$row['Field']} from float to int in the drinks table.");
            $sql = "UPDATE " . db_prefix("drinks") . " SET hppercent=hppercent*100";
            db_query($sql);
            $sql = "ALTER TABLE " . db_prefix("drinks") . " CHANGE {$row['Field']} {$row['Field']} int(11) NOT NULL DEFAULT 0";
            db_query($sql);
        }
        if (($row['Field'] == "buffatkmod" || $row['Field'] == "buffdefmod" || $row['Field'] == "buffdmgmod" || $row['Field'] == "buffdmgshield") && $row['Type'] == "float") {
            debug("Altering {$row['Field']} from float to text in the drinks table.");
            $sql = "ALTER TABLE " . db_prefix("drinks") . " CHANGE {$row['Field']} {$row['Field']} text NOT NULL";
            db_query($sql);
        }
    }
    // end while
    // Install the hooks.
    module_addhook("ale");
    module_addhook("newday");
    module_addhook("superuser");
    module_addhook("header-graveyard");
    module_addhook("commentary");
    module_addhook("soberup");
    module_addhook("dragonkill");
    return true;
}
コード例 #19
0
ファイル: gateway.php プロジェクト: Nazg-Gul/e-marsa
 function CheckTables()
 {
     if (!config_get('check-database')) {
         return;
     }
     if (!db_table_exists('tester')) {
         db_create_table_safe('tester', array('security' => 'TEXT DEFAULT ""', 'content' => 'TEXT DEFAULT ""'));
         db_insert('tester', array('security' => '"' . serialize(array()) . '"', 'content' => '"' . serialize(array()) . '"'));
     }
     if (!db_table_exists('tester_problems')) {
         db_create_table_safe('tester_problems', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'lid' => 'INT', 'name' => 'TEXT DEFAULT ""', 'description' => 'LONGTEXT DEFAULT ""', 'settings' => 'LONGTEXT DEFAULT ""', 'uploaded' => 'INT DEFAULT 0'));
         manage_settings_create('Количество задач на странице редактирования', 'Олимпиады', 'WT_problems_per_page', 'CSCNumber');
         manage_settings_create('Количество задач на странице браузера', 'Олимпиады', 'WT_problems_per_browser_page', 'CSCNumber');
         manage_settings_create('Количество записей на странице статуса', 'Олимпиады', 'WT_items_per_status_page', 'CSCNumber');
         opt_set('WT_problems_per_page', 15);
         opt_set('WT_problems_per_browser_page', 10);
         opt_set('WT_items_per_status_page', 15);
         manage_setting_use('WT_problems_per_page');
         manage_setting_use('WT_items_per_status_page');
         manage_setting_use('WT_problems_per_browser_page');
     }
     if (!db_table_exists('tester_tasks')) {
         db_create_table_safe('tester_tasks', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'contest_id' => 'INT', 'problem_id' => 'INT', 'letter' => 'INT', 'catid' => 'INT DEFAULT 0', 'settings' => 'LONGTEXT DEFAULT ""'));
     }
     if (!db_table_exists('tester_checkers')) {
         db_create_table_safe('tester_checkers', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'LONGTEXT', 'uploaded' => 'BOOL DEFAULT 0', 'settings' => 'LONGTEXT DEFAULT ""'));
     }
     if (!db_table_exists('tester_solutions')) {
         db_create_table_safe('tester_solutions', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'lid' => 'INT', 'contest_id' => 'INT', 'problem_id' => 'INT', 'user_id' => 'INT', 'timestamp' => 'INT', 'status' => 'INT', 'parameters' => 'LONGTEXT DEFAULT ""', 'errors' => 'TEXT', 'points' => 'INT', 'ignored' => 'BOOL DEFAULT 0'));
     }
     if (!db_table_exists('tester_contestgroup')) {
         db_create_table_safe('tester_contestgroup', array('contest_id' => 'INT', 'group_id' => 'INT'));
     }
     if (!db_table_exists('tester_judgegroup')) {
         db_create_table_safe('tester_judgegroup', array('contest_id' => 'INT', 'group_id' => 'INT'));
     }
     if (!db_table_exists('tester_disabled_problems')) {
         db_create_table_safe('tester_disabled_problems', array('contest_id' => 'INT', 'problem_id' => 'INT'));
     }
     if (!db_table_exists('tester_tags_dict')) {
         db_create_table_safe('tester_tags_dict', array('id' => 'INT  NOT NULL PRIMARY KEY AUTO_INCREMENT', 'tag' => 'TEXT'));
     }
     if (!db_table_exists('tester_problem_tags')) {
         db_create_table_safe('tester_problem_tags', array('problem_id' => 'INT', 'tag_id' => 'INT'));
     }
 }
コード例 #20
0
ファイル: xpfs.php プロジェクト: Nazg-Gul/gate
 function createVolume($volume = '')
 {
     global $XPFS_DEFAULT_VOLUME;
     if ($volume == '') {
         $volume = $XPFS_DEFAULT_VOLUME;
     }
     if (db_count('xpfs_volumes', '`name`="' . addslashes($volume) . '"') > 0) {
         return false;
     }
     $name = $volume;
     $volume = 'xpfs_volume_' . $volume;
     if (!db_table_exists($volume)) {
         db_create_table($volume, array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'pid' => 'INT', 'name' => 'TEXT', 'data' => 'LONGBLOB', 'mtime' => 'INT DEFAULT 0', 'access' => 'INT DEFAULT 0', 'attr' => 'INT DEFAULT 0'));
         db_insert('xpfs_volumes', array('name' => '"' . addslashes($name) . '"'));
         db_insert($volume, array('name' => '"/"', 'pid' => 0));
         return true;
     }
     return false;
 }
コード例 #21
0
ファイル: install.php プロジェクト: siwiwit/PhreeBooksERP
 function update($module)
 {
     global $db, $messageStack;
     $error = false;
     if (MODULE_PHREEHELP_STATUS < 3.0) {
         foreach ($this->tables as $table => $create_table_sql) {
             if (!db_table_exists($table)) {
                 if (!$db->Execute($create_table_sql)) {
                     $error = true;
                 }
             }
         }
     }
     write_configure(PHREEHELP_FORCE_RELOAD, '1');
     if (!$error) {
         write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION'));
         $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success');
     }
     return $error;
 }
コード例 #22
0
ファイル: dev.php プロジェクト: Nazg-Gul/gate
 function manage_check_tables()
 {
     db_create_table_safe('datatypes', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'class' => 'TEXT', 'refcount' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
     db_create_table_safe('dataset', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'refcount' => 'INT DEFAULT 0'));
     db_create_table_safe('dataset_assoc', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'order' => 'INT', 'dataset' => 'INT', 'datatype' => 'INT', 'title' => 'TEXT', 'field' => 'TEXT', 'settings' => 'TEXT DEFAULT ""'));
     if (!db_table_exists('settings')) {
         db_create_table('settings', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'section' => 'TEXT', 'name' => 'TEXT', 'ident' => 'TEXT', 'class' => 'TEXT', 'used' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Максимальная длина логина пользователя"', 'ident' => '"max_user_login_len"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"14";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Максимальная длина имени пользователя"', 'ident' => '"max_user_name_len"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"32";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Максимальная длина пароля пользователя"', 'ident' => '"max_user_passwd_len"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"16";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Количество записей на странице &laquo;Пользователи и группы&raquo;"', 'ident' => '"user_count"', 'class' => '"CSCNumber"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:2:"15";}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Блокировать сайт"', 'ident' => '"site_lock"', 'class' => '"CSCCheckBox"', 'settings' => '"' . addslashes('a:1:{s:5:"value";b:0;}') . '"', 'used' => '1'));
         db_insert('settings', array('section' => '"Системные"', 'name' => '"Стартовый каталог"', 'ident' => '"start_root"', 'class' => '"CSCText"', 'settings' => '"' . addslashes('a:1:{s:5:"value";s:1:"/";}') . '"', 'used' => '1'));
     }
     db_create_table_safe('storage', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'path' => 'TEXT', 'refcount' => 'INT DEFAULT 0'));
     if (!db_table_exists('templates')) {
         db_create_table_safe('templates', array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'name' => 'TEXT', 'text' => 'LONGTEXT', 'refcount' => 'INT DEFAULT 0', 'settings' => 'TEXT DEFAULT ""'));
     }
     manage_template_register_default();
 }
コード例 #23
0
 /**
  * Confirms that temporary tables work and are limited to one request.
  */
 function testTemporaryQuery()
 {
     $this->drupalGet('database_test/db_query_temporary');
     $data = json_decode($this->drupalGetContent());
     if ($data) {
         $this->assertEqual($this->countTableRows('test'), $data->row_count, 'The temporary table contains the correct amount of rows.');
         $this->assertFalse(db_table_exists($data->table_name), 'The temporary table is, indeed, temporary.');
     } else {
         $this->fail('The creation of the temporary table failed.');
     }
     // Now try to run two db_query_temporary() in the same request.
     $table_name_test = db_query_temporary('SELECT name FROM {test}', array());
     $table_name_task = db_query_temporary('SELECT pid FROM {test_task}', array());
     $this->assertEqual($this->countTableRows($table_name_test), $this->countTableRows('test'), 'A temporary table was created successfully in this request.');
     $this->assertEqual($this->countTableRows($table_name_task), $this->countTableRows('test_task'), 'A second temporary table was created successfully in this request.');
     // Check that leading whitespace and comments do not cause problems
     // in the modified query.
     $sql = "\n      -- Let's select some rows into a temporary table\n      SELECT name FROM {test}\n    ";
     $table_name_test = db_query_temporary($sql, array());
     $this->assertEqual($this->countTableRows($table_name_test), $this->countTableRows('test'), 'Leading white space and comments do not interfere with temporary table creation.');
 }
コード例 #24
0
ファイル: install.php プロジェクト: siwiwit/PhreeBooksERP
 function update($module)
 {
     global $db, $messageStack;
     $error = false;
     if (MODULE_ASSETS_STATUS < 3.1) {
         $tab_map = array('0' => '0');
         if (db_table_exists(DB_PREFIX . 'assets_tabs')) {
             $result = $db->Execute("select * from " . DB_PREFIX . 'assets_tabs');
             while (!$result->EOF) {
                 $updateDB = $db->Execute("insert into " . TABLE_EXTRA_TABS . " set \n\t\t\t  module_id = 'assets',\n\t\t\t  tab_name = '" . $result->fields['category_name'] . "',\n\t\t\t  description = '" . $result->fields['category_description'] . "',\n\t\t\t  sort_order = '" . $result->fields['sort_order'] . "'");
                 $tab_map[$result->fields['category_id']] = db_insert_id();
                 $result->MoveNext();
             }
             $db->Execute("DROP TABLE " . DB_PREFIX . "assets_tabs");
         }
         if (db_table_exists(DB_PREFIX . 'assets_fields')) {
             $result = $db->Execute("select * from " . DB_PREFIX . 'assets_fields');
             while (!$result->EOF) {
                 $updateDB = $db->Execute("insert into " . TABLE_EXTRA_FIELDS . " set \n\t\t\t  module_id = 'assets',\n\t\t\t  tab_id = '" . $tab_map[$result->fields['category_id']] . "',\n\t\t\t  entry_type = '" . $result->fields['entry_type'] . "',\n\t\t\t  field_name = '" . $result->fields['field_name'] . "',\n\t\t\t  description = '" . $result->fields['description'] . "',\n\t\t\t  params = '" . $result->fields['params'] . "'");
                 $result->MoveNext();
             }
             $db->Execute("DROP TABLE " . DB_PREFIX . "assets_fields");
         }
         xtra_field_sync_list('assets', TABLE_ASSETS);
     }
     if (MODULE_ASSETS_STATUS < 3.3) {
         if (!db_field_exists(TABLE_ASSETS, 'attachments')) {
             $db->Execute("ALTER TABLE " . TABLE_ASSETS . " ADD attachments TEXT NOT NULL AFTER terminal_date");
         }
         require_once DIR_FS_MODULES . 'phreedom/functions/phreedom.php';
         xtra_field_sync_list('assets', TABLE_ASSETS);
     }
     if (!$error) {
         write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION'));
         $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success');
     }
     return $error;
 }
コード例 #25
0
ファイル: SchemaTest.php プロジェクト: isramv/camp-gdl
 /**
  * Tests database interactions.
  */
 function testSchema()
 {
     // Try creating a table.
     $table_specification = array('description' => 'Schema table description may contain "quotes" and could be long—very long indeed.', 'fields' => array('id' => array('type' => 'int', 'default' => NULL), 'test_field' => array('type' => 'int', 'not null' => TRUE, 'description' => 'Schema table description may contain "quotes" and could be long—very long indeed. There could be "multiple quoted regions".'), 'test_field_string' => array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => "'\"funky default'\"", 'description' => 'Schema column description for string.'), 'test_field_string_ascii' => array('type' => 'varchar_ascii', 'length' => 255, 'description' => 'Schema column description for ASCII string.')));
     db_create_table('test_table', $table_specification);
     // Assert that the table exists.
     $this->assertTrue(db_table_exists('test_table'), 'The table exists.');
     // Assert that the table comment has been set.
     $this->checkSchemaComment($table_specification['description'], 'test_table');
     // Assert that the column comment has been set.
     $this->checkSchemaComment($table_specification['fields']['test_field']['description'], 'test_table', 'test_field');
     if (Database::getConnection()->databaseType() == 'mysql') {
         // Make sure that varchar fields have the correct collation.
         $columns = db_query('SHOW FULL COLUMNS FROM {test_table}');
         foreach ($columns as $column) {
             if ($column->Field == 'test_field_string') {
                 $string_check = $column->Collation == 'utf8mb4_general_ci';
             }
             if ($column->Field == 'test_field_string_ascii') {
                 $string_ascii_check = $column->Collation == 'ascii_general_ci';
             }
         }
         $this->assertTrue(!empty($string_check), 'string field has the right collation.');
         $this->assertTrue(!empty($string_ascii_check), 'ASCII string field has the right collation.');
     }
     // An insert without a value for the column 'test_table' should fail.
     $this->assertFalse($this->tryInsert(), 'Insert without a default failed.');
     // Add a default value to the column.
     db_field_set_default('test_table', 'test_field', 0);
     // The insert should now succeed.
     $this->assertTrue($this->tryInsert(), 'Insert with a default succeeded.');
     // Remove the default.
     db_field_set_no_default('test_table', 'test_field');
     // The insert should fail again.
     $this->assertFalse($this->tryInsert(), 'Insert without a default failed.');
     // Test for fake index and test for the boolean result of indexExists().
     $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
     $this->assertIdentical($index_exists, FALSE, 'Fake index does not exists');
     // Add index.
     db_add_index('test_table', 'test_field', array('test_field'), $table_specification);
     // Test for created index and test for the boolean result of indexExists().
     $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
     $this->assertIdentical($index_exists, TRUE, 'Index created.');
     // Rename the table.
     db_rename_table('test_table', 'test_table2');
     // Index should be renamed.
     $index_exists = Database::getConnection()->schema()->indexExists('test_table2', 'test_field');
     $this->assertTrue($index_exists, 'Index was renamed.');
     // We need the default so that we can insert after the rename.
     db_field_set_default('test_table2', 'test_field', 0);
     $this->assertFalse($this->tryInsert(), 'Insert into the old table failed.');
     $this->assertTrue($this->tryInsert('test_table2'), 'Insert into the new table succeeded.');
     // We should have successfully inserted exactly two rows.
     $count = db_query('SELECT COUNT(*) FROM {test_table2}')->fetchField();
     $this->assertEqual($count, 2, 'Two fields were successfully inserted.');
     // Try to drop the table.
     db_drop_table('test_table2');
     $this->assertFalse(db_table_exists('test_table2'), 'The dropped table does not exist.');
     // Recreate the table.
     db_create_table('test_table', $table_specification);
     db_field_set_default('test_table', 'test_field', 0);
     db_add_field('test_table', 'test_serial', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Added column description.'));
     // Assert that the column comment has been set.
     $this->checkSchemaComment('Added column description.', 'test_table', 'test_serial');
     // Change the new field to a serial column.
     db_change_field('test_table', 'test_serial', 'test_serial', array('type' => 'serial', 'not null' => TRUE, 'description' => 'Changed column description.'), array('primary key' => array('test_serial')));
     // Assert that the column comment has been set.
     $this->checkSchemaComment('Changed column description.', 'test_table', 'test_serial');
     $this->assertTrue($this->tryInsert(), 'Insert with a serial succeeded.');
     $max1 = db_query('SELECT MAX(test_serial) FROM {test_table}')->fetchField();
     $this->assertTrue($this->tryInsert(), 'Insert with a serial succeeded.');
     $max2 = db_query('SELECT MAX(test_serial) FROM {test_table}')->fetchField();
     $this->assertTrue($max2 > $max1, 'The serial is monotone.');
     $count = db_query('SELECT COUNT(*) FROM {test_table}')->fetchField();
     $this->assertEqual($count, 2, 'There were two rows.');
     // Test renaming of keys and constraints.
     db_drop_table('test_table');
     $table_specification = array('fields' => array('id' => array('type' => 'serial', 'not null' => TRUE), 'test_field' => array('type' => 'int', 'default' => 0)), 'primary key' => array('id'), 'unique keys' => array('test_field' => array('test_field')));
     db_create_table('test_table', $table_specification);
     // Tests for indexes are Database specific.
     $db_type = Database::getConnection()->databaseType();
     // Test for existing primary and unique keys.
     switch ($db_type) {
         case 'pgsql':
             $primary_key_exists = Database::getConnection()->schema()->constraintExists('test_table', '__pkey');
             $unique_key_exists = Database::getConnection()->schema()->constraintExists('test_table', 'test_field' . '__key');
             break;
         case 'sqlite':
             // SQLite does not create a standalone index for primary keys.
             $primary_key_exists = TRUE;
             $unique_key_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
             break;
         default:
             $primary_key_exists = Database::getConnection()->schema()->indexExists('test_table', 'PRIMARY');
             $unique_key_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
             break;
     }
     $this->assertIdentical($primary_key_exists, TRUE, 'Primary key created.');
     $this->assertIdentical($unique_key_exists, TRUE, 'Unique key created.');
     db_rename_table('test_table', 'test_table2');
     // Test for renamed primary and unique keys.
     switch ($db_type) {
         case 'pgsql':
             $renamed_primary_key_exists = Database::getConnection()->schema()->constraintExists('test_table2', '__pkey');
             $renamed_unique_key_exists = Database::getConnection()->schema()->constraintExists('test_table2', 'test_field' . '__key');
             break;
         case 'sqlite':
             // SQLite does not create a standalone index for primary keys.
             $renamed_primary_key_exists = TRUE;
             $renamed_unique_key_exists = Database::getConnection()->schema()->indexExists('test_table2', 'test_field');
             break;
         default:
             $renamed_primary_key_exists = Database::getConnection()->schema()->indexExists('test_table2', 'PRIMARY');
             $renamed_unique_key_exists = Database::getConnection()->schema()->indexExists('test_table2', 'test_field');
             break;
     }
     $this->assertIdentical($renamed_primary_key_exists, TRUE, 'Primary key was renamed.');
     $this->assertIdentical($renamed_unique_key_exists, TRUE, 'Unique key was renamed.');
     // For PostgreSQL check in addition that sequence was renamed.
     if ($db_type == 'pgsql') {
         // Get information about new table.
         $info = Database::getConnection()->schema()->queryTableInformation('test_table2');
         $sequence_name = Database::getConnection()->schema()->prefixNonTable('test_table2', 'id', 'seq');
         $this->assertEqual($sequence_name, current($info->sequences), 'Sequence was renamed.');
     }
     // Use database specific data type and ensure that table is created.
     $table_specification = array('description' => 'Schema table description.', 'fields' => array('timestamp' => array('mysql_type' => 'timestamp', 'pgsql_type' => 'timestamp', 'sqlite_type' => 'datetime', 'not null' => FALSE, 'default' => NULL)));
     try {
         db_create_table('test_timestamp', $table_specification);
     } catch (\Exception $e) {
     }
     $this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.');
 }
コード例 #26
0
 /**
  * Tests whether removing the configuration again works as it should.
  */
 protected function checkModuleUninstall()
 {
     // See whether clearing the server works.
     // Regression test for #2156151.
     $server = Server::load($this->serverId);
     $index = Index::load($this->indexId);
     $server->deleteAllIndexItems($index);
     $query = $this->buildSearch();
     $results = $query->execute();
     $this->assertEqual($results->getResultCount(), 0, 'Clearing the server worked correctly.');
     $table = 'search_api_db_' . $this->indexId;
     $this->assertTrue(db_table_exists($table), 'The index tables were left in place.');
     // Remove first the index and then the server.
     $index->setServer();
     $index->save();
     $server = Server::load($this->serverId);
     $this->assertEqual($server->getBackendConfig()['field_tables'], array(), 'The index was successfully removed from the server.');
     $this->assertFalse(db_table_exists($table), 'The index tables were deleted.');
     $server->delete();
     // Uninstall the module.
     \Drupal::service('module_installer')->uninstall(array('search_api_db'), FALSE);
     #\Drupal::moduleHandler()->uninstall(array('search_api_db'), FALSE);
     $this->assertFalse(\Drupal::moduleHandler()->moduleExists('search_api_db'), 'The Database Search module was successfully disabled.');
     $prefix = \Drupal::database()->prefixTables('{search_api_db_}') . '%';
     $this->assertEqual(\Drupal::database()->schema()->findTables($prefix), array(), 'The Database Search module was successfully uninstalled.');
 }
コード例 #27
0
/**
* db_delete_table()
*
* @param  $tablename
* @return bool "TRUE" or "FALSE"
*/
function db_delete_table($tablename)
{
    global $g_lasttable;
    if (!$tablename) {
        $tablename = $g_lasttable;
    }
    $g_lasttable = $tablename;
    if ($tablename == null || $tablename == "") {
        return false;
    }
    if (db_table_exists($tablename)) {
        $result = raw_db_query("DROP table " . APPPREFIX . $tablename);
    }
    return $result;
}
コード例 #28
0
 /**
  * {@inheritdoc}
  */
 public function deleteMultiple(array $conditions)
 {
     // Because this function is called from sub-module uninstall hooks, we have
     // to manually check if the table exists since it could have been removed
     // in xmlsitemap_uninstall().
     // @todo Remove this check when http://drupal.org/node/151452 is fixed.
     if (!db_table_exists('xmlsitemap')) {
         return FALSE;
     }
     if (!$this->state->get('xmlsitemap_regenerate_needed')) {
         $this->checkChangedLinks($conditions, array(), TRUE);
     }
     // @todo Add a hook_xmlsitemap_link_delete() hook invoked here.
     $query = db_delete('xmlsitemap');
     foreach ($conditions as $field => $value) {
         $query->condition($field, $value);
     }
     return $query->execute();
 }
コード例 #29
0
function test_database_utf8()
{
    if (!db_is_mysql()) {
        return;
    }
    // table collation/character set check
    $result = db_query_bound('SHOW TABLE STATUS');
    while ($row = db_fetch_array($result)) {
        if ($row['Comment'] !== 'VIEW') {
            print_test_row('Checking Table Collation is utf8 for ' . $row['Name'] . '....', substr($row['Collation'], 0, 5) === 'utf8_', $row['Collation']);
        }
    }
    foreach (db_get_table_list() as $t_table) {
        if (db_table_exists($t_table)) {
            $result = db_query_bound('SHOW FULL FIELDS FROM ' . $t_table);
            while ($row = db_fetch_array($result)) {
                if ($row['Collation'] === null) {
                    continue;
                }
                print_test_row('Checking Non-null Column Collation in ' . $t_table . ' is utf8 for ' . $row['Field'] . '....', substr($row['Collation'], 0, 5) === 'utf8_', $row['Collation'] . ' ( ' . $row['Type'] . ')');
            }
        }
    }
}
コード例 #30
0
ファイル: db_stats.php プロジェクト: kaos/mantisbt
 * @copyright Copyright (C) 2002 - 2010  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 * @link http://www.mantisbt.org
 */
/**
 * MantisBT Core API's
 */
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'core.php';
access_ensure_global_level(config_get_global('admin_site_threshold'));
# --------------------
function helper_table_row_count($p_table)
{
    $t_table = $p_table;
    $query = "SELECT COUNT(*) FROM {$t_table}";
    $result = db_query_bound($query);
    $t_users = db_result($result);
    return $t_users;
}
# --------------------
function print_table_stats($p_table_name)
{
    $t_count = helper_table_row_count($p_table_name);
    echo "{$p_table_name} = {$t_count} records<br />";
}
echo '<html><head><title>MantisBT Database Statistics</title></head><body>';
echo '<h1>MantisBT Database Statistics</h1>';
foreach (db_get_table_list() as $t_table) {
    if (db_table_exists($t_table)) {
        print_table_stats($t_table);
    }
}
echo '</body></html>';