/** * Load plugin configuration from database * * @param string $pi_name Plugin name * @return boolean true on success, otherwise false * @see plugin_initconfig_links * */ function plugin_load_configuration_links($pi_name) { global $_CONF; $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/'; require_once $_CONF['path_system'] . 'classes/config.class.php'; require_once $base_path . 'install_defaults.php'; return plugin_initconfig_links(); }
/** * Loads the configuration records for the Online Config Manager * * @return boolean true = proceed with install, false = an error occured * */ function plugin_load_configuration_links() { global $_CONF; require_once $_CONF['path'] . 'plugins/links/install_defaults.php'; return plugin_initconfig_links(); }
function upgrade_LinksPlugin() { global $_CONF, $_TABLES; require_once $_CONF['path_system'] . 'classes/config.class.php'; $plugin_path = $_CONF['path'] . 'plugins/links/'; require_once $plugin_path . 'install_defaults.php'; if (file_exists($plugin_path . 'config.php')) { global $_DB_table_prefix, $_LI_CONF; require_once $plugin_path . 'config.php'; } if (!plugin_initconfig_links()) { echo 'There was an error upgrading the Links plugin'; return false; } $li_config = config::get_instance(); $_LI_CONF = $li_config->get_config('links'); if (empty($_LI_CONF['root'])) { $_LI_CONF['root'] = 'site'; } $root = addslashes($_LI_CONF['root']); $P_SQL = array(); $P_SQL[] = "CREATE TABLE [dbo].[{$_TABLES['linkcategories']}] (\r\n [cid] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,\r\n [pid] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,\r\n [category] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,\r\n [description] [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,\r\n [tid] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,\r\n [created] [datetime] NULL ,\r\n [modified] [datetime] NULL ,\r\n [owner_id] [numeric](8, 0) NOT NULL ,\r\n [group_id] [numeric](8, 0) NOT NULL ,\r\n [perm_owner] [tinyint] NOT NULL ,\r\n [perm_group] [tinyint] NOT NULL ,\r\n [perm_members] [tinyint] NOT NULL ,\r\n [perm_anon] [tinyint] NOT NULL\r\n ) ON [PRIMARY]"; $P_SQL[] = "ALTER TABLE [dbo].[{$_TABLES['linkcategories']}] ADD\r\n CONSTRAINT [PK_{$_TABLES['linkcategories']}] PRIMARY KEY CLUSTERED\r\n (\r\n [pid]\r\n ) ON [PRIMARY]"; $blockadmin_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='Block Admin'"); $P_SQL[] = "ALTER TABLE {$_TABLES['linksubmission']} ADD owner_id INTEGER NOT NULL default '1'"; $P_SQL[] = "EXEC sp_rename '{$_TABLES['linksubmission']}.category', 'cid', 'COLUMN'"; $P_SQL[] = "ALTER TABLE {$_TABLES['linksubmission']} ALTER COLUMN [cid] varchar(32) NOT NULL"; $P_SQL[] = "EXEC sp_rename '{$_TABLES['links']}.category', 'cid', 'COLUMN'"; $P_SQL[] = "ALTER TABLE {$_TABLES['links']} ALTER COLUMN [cid] varchar(32) NOT NULL"; $P_SQL[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$root}', 'root', 'Root', 'Website root', NULL, NOW(), NOW(), 5, 2, 3, 3, 2, 2)"; $P_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_version = '2.0.0', pi_gl_version='1.5.0' WHERE pi_name='links'"; foreach ($P_SQL as $sql) { $rst = DB_query($sql); if (DB_error()) { echo "There was an error upgrading the links, SQL: {$sql}<br>"; return false; } } // get Links admin group number $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Links Admin'"); // loop through adding to category table, then update links table with cids $result = DB_query("SELECT DISTINCT cid AS category FROM {$_TABLES['links']}"); $nrows = DB_numRows($result); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); $category = addslashes($A['category']); $cid = $category; $sql = "INSERT INTO {$_TABLES['linkcategories']} (cid,pid,category,description,tid,owner_id,group_id,created,modified, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$cid}','{$root}','{$category}','{$category}','all',2,'{$group_id}',NOW(),NOW(), 3, 3, 2, 2)"; DB_query($sql, 0); if ($cid != $category) { // still experimenting ... $sql = "UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$category}'"; DB_query($sql, 0); } if (DB_error()) { echo "Error inserting categories into linkcategories table"; return false; } } return true; }
function upgrade_LinksPlugin() { global $_CONF, $_TABLES; require_once $_CONF['path_system'] . 'classes/config.class.php'; $plugin_path = $_CONF['path'] . 'plugins/links/'; require_once $plugin_path . 'install_defaults.php'; if (file_exists($plugin_path . 'config.php')) { global $_DB_table_prefix, $_LI_CONF; require_once $plugin_path . 'config.php'; } if (!plugin_initconfig_links()) { echo 'There was an error upgrading the Links plugin'; return false; } $li_config = config::get_instance(); $_LI_CONF = $li_config->get_config('links'); if (empty($_LI_CONF['root'])) { $_LI_CONF['root'] = 'site'; } $root = addslashes($_LI_CONF['root']); $P_SQL = array(); $P_SQL[] = "\n CREATE TABLE {$_TABLES['linkcategories']} (\n cid varchar(32) NOT NULL,\n pid varchar(32) NOT NULL,\n category varchar(32) NOT NULL,\n description text DEFAULT NULL,\n tid varchar(20) DEFAULT NULL,\n created datetime DEFAULT NULL,\n modified datetime DEFAULT NULL,\n owner_id mediumint(8) unsigned NOT NULL default '1',\n group_id mediumint(8) unsigned NOT NULL default '1',\n perm_owner tinyint(1) unsigned NOT NULL default '3',\n perm_group tinyint(1) unsigned NOT NULL default '2',\n perm_members tinyint(1) unsigned NOT NULL default '2',\n perm_anon tinyint(1) unsigned NOT NULL default '2',\n PRIMARY KEY (cid),\n KEY links_pid (pid)\n ) ENGINE=MyISAM\n "; $blockadmin_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='Block Admin'"); $P_SQL[] = "ALTER TABLE {$_TABLES['linksubmission']} ADD owner_id mediumint(8) unsigned NOT NULL default '1' AFTER date"; $P_SQL[] = "ALTER TABLE {$_TABLES['linksubmission']} CHANGE category cid varchar(32) NOT NULL"; $P_SQL[] = "ALTER TABLE {$_TABLES['links']} CHANGE category cid varchar(32) NOT NULL"; $P_SQL[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$root}', 'root', 'Root', 'Website root', NULL, NOW(), NOW(), 5, 2, 3, 3, 2, 2)"; $P_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_version = '2.0.0', pi_gl_version='1.5.0' WHERE pi_name='links'"; $P_SQL = INST_checkInnodbUpgrade($P_SQL); foreach ($P_SQL as $sql) { $rst = DB_query($sql); if (DB_error()) { echo "There was an error upgrading the links, SQL: {$sql}<br>"; return false; } } // get Links admin group number $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Links Admin'"); // loop through adding to category table, then update links table with cids $result = DB_query("SELECT DISTINCT cid AS category FROM {$_TABLES['links']}"); $nrows = DB_numRows($result); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); $category = addslashes($A['category']); $cid = $category; DB_query("INSERT INTO {$_TABLES['linkcategories']} (cid,pid,category,description,tid,owner_id,group_id,created,modified) VALUES ('{$cid}','{$root}','{$category}','{$category}','all',2,'{$group_id}',NOW(),NOW())", 1); if ($cid != $category) { // still experimenting ... DB_query("UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$category}'", 1); } if (DB_error()) { echo "Error inserting categories into linkcategories table"; return false; } } return true; }
/** * Loads the configuration records for the GL Online Config Manager * * @return boolean true = proceed with install, false = an error occured * */ function plugin_load_configuration() { global $_CONF, $base_path; require_once $_CONF['path_system'] . 'classes/config.class.php'; require_once $base_path . 'install_defaults.php'; return plugin_initconfig_links(); }