/** * Loads the configuration records for the Online Config Manager * @return boolean true = proceed with install, false = an error occured */ function plugin_load_configuration_external() { global $_CONF, $_CONF_EXP, $_TABLES; COM_errorLog("Loading the configuration for the External plugin", 1); require_once $_CONF['path'] . 'plugins/' . $_CONF_EXP['pi_name'] . '/install_defaults.php'; // Get the admin group ID that was saved previously. $group_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='{$_CONF_EXP['pi_name']} Admin'"); return plugin_initconfig_external($group_id); }
/** * Puts the datastructures for this plugin into the Geeklog database * Note: Corresponding uninstall routine is in functions.inc * @return boolean True if successful False otherwise * @ignore */ function plugin_install_external() { global $pi_name, $NEWTABLE, $_CONF_EXP, $DEFVALUES, $NEWFEATURE, $_TABLES, $_CONF; COM_errorLog("Attempting to install the {$pi_name} Plugin", 1); // Create the Plugins Tables foreach ($NEWTABLE as $table => $sql) { COM_errorLog("Creating {$table} table", 1); DB_query($sql, 1); if (DB_error()) { COM_errorLog("Error Creating {$table} table", 1); PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Success - Created {$table} table", 1); } // Insert Default Data /*foreach ($DEFVALUES as $table => $sql) { COM_errorLog("Inserting default data into $table table",1); DB_query($sql,1); if (DB_error()) { COM_errorLog("Error inserting default data into $table table",1); PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Success - inserting data into $table table",1); }*/ // Create the plugin admin security group COM_errorLog("Attempting to create {$pi_name} admin group", 1); DB_query("INSERT INTO {$_TABLES['groups']} (\n grp_name, \n grp_descr) \n VALUES (\n '{$pi_name} Admin', \n 'Users in this group can administer the {$pi_name} plugin')", 1); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } COM_errorLog('...success', 1); $group_id = DB_insertId(); // Save the grp id for later uninstall COM_errorLog('About to save group_id to vars table for use during uninstall', 1); DB_query("INSERT INTO {$_TABLES['vars']} \n VALUES ('{$pi_name}_gid', {$group_id})", 1); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } COM_errorLog('...success', 1); // Add plugin Features foreach ($NEWFEATURE as $feature => $desc) { COM_errorLog("Adding {$feature} feature", 1); DB_query("INSERT INTO {$_TABLES['features']} \n (ft_name, ft_descr) \n VALUES \n ('{$feature}','{$desc}')", 1); if (DB_error()) { COM_errorLog("Failure adding {$feature} feature", 1); PLG_uninstall($pi_name); return false; exit; } $feat_id = DB_insertId(); COM_errorLog("Success", 1); COM_errorLog("Adding {$feature} feature to admin group", 1); DB_query("INSERT INTO {$_TABLES['access']} \n (acc_ft_id, acc_grp_id) \n VALUES \n ({$feat_id}, {$group_id})"); if (DB_error()) { COM_errorLog("Failure adding {$feature} feature to admin group", 1); PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Success", 1); } // OK, now give Root users access to this plugin now! NOTE: Root group should always be 1 COM_errorLog("Attempting to give all users in Root group access to {$pi_name} admin group", 1); DB_query("INSERT INTO {$_TABLES['group_assignments']} \n VALUES ({$group_id}, NULL, 1)"); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } // Load the online configuration records if (!plugin_initconfig_external($group_id)) { PLG_uninstall($pi_name); return false; } // Register the plugin with Geeklog COM_errorLog("Registering {$pi_name} plugin with Geeklog", 1); DB_delete($_TABLES['plugins'], 'pi_name', 'external'); DB_query("INSERT INTO {$_TABLES['plugins']} (\n pi_name, \n pi_version, \n pi_gl_version, \n pi_homepage, \n pi_enabled) \n VALUES (\n '{$_CONF_EXP['pi_name']}', \n '{$_CONF_EXP['pi_version']}', \n '{$_CONF_EXP['gl_version']}', \n '{$_CONF_EXP['pi_url']}', \n 1)"); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Succesfully installed the {$pi_name} Plugin!", 1); return true; }