]> git.mjollnir.org Git - s9y.git/commitdiff
Add preload ability
authorgarvinhicking <garvinhicking>
Sat, 4 Feb 2006 13:05:27 +0000 (13:05 +0000)
committergarvinhicking <garvinhicking>
Sat, 4 Feb 2006 13:05:27 +0000 (13:05 +0000)
docs/NEWS
include/functions_installer.inc.php

index fa8b18861e70b28b5346ea6fe8e1edbe604b8152..1399abd56a855b46032adac00ed42cbc2268e482 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,13 @@
 Version 1.0-beta2 ()
 ------------------------------------------------------------------------
 
+   * Add ability to "preload" specific plugins and SQL entries into
+     Serendipity. Just create a plugins/preload.txt file containing
+     the plugins to load (one plugin per line, indicate plugin type
+     like "serendipity_event_spartacus:event"). Preloaded SQL data
+     can be put into sql/preload.sql and may only contain INSERT
+     statements. (garvinhicking, judebert)
+
    * When the "no_create" privilege is set, deny users access to any
      external admin plugins (garvinhicking)
 
index 2cf87e988d4e0f2963a48e2e2b57acf275aaaf8f..5fc795ab5de6395ac404fa5f4e06c144b97c8566 100644 (file)
@@ -128,12 +128,21 @@ function serendipity_updateLocalConfig($dbName, $dbPrefix, $dbHost, $dbUser, $db
  */
 function serendipity_installDatabase() {
   global $serendipity;
-  $queries = serendipity_parse_sql_tables(S9Y_INCLUDE_PATH . 'sql/db.sql');
-  $queries = str_replace('{PREFIX}', $serendipity['dbPrefix'], $queries);
 
-  foreach ($queries as $query) {
-      serendipity_db_schema_import($query);
-  }
+    $queries = serendipity_parse_sql_tables(S9Y_INCLUDE_PATH . 'sql/db.sql');
+    $queries = str_replace('{PREFIX}', $serendipity['dbPrefix'], $queries);
+
+    foreach ($queries as $query) {
+        serendipity_db_schema_import($query);
+    }
+
+    if (file_exists(S9Y_INCLUDE_PATH . 'sql/preload.sql')) {
+        $queries = serendipity_parse_sql_inserts(S9Y_INCLUDE_PATH . 'sql/preload.sql');
+        $queries = str_replace('{PREFIX}', $serendipity['dbPrefix'], $queries);
+        foreach ($queries as $query) {
+            serendipity_db_schema_import($query);
+        }
+    }
 }
 
 /**
@@ -583,7 +592,8 @@ function showConfigAll(count) {
 }
 
 /**
- * Parse .sql files for use within Serendipity, query by query
+ * Parse .sql files for use within Serendipity, query by query,
+ * accepting only CREATE commands.
  *
  * @access public
  * @param   string  The filename of the SQL file
@@ -620,6 +630,31 @@ function serendipity_parse_sql_tables($filename) {
     return $queries;
 }
 
+/**
+ * Parse .sql files for use within Serendipity, query by query,
+ * accepting only INSERT commands.
+ *
+ * @access public
+ * @param   string  The filename of the SQL file
+ * @return array    An array of queries to execute
+ */
+function serendipity_parse_sql_inserts($filename) {
+    $queries = array();
+
+    $fp = fopen($filename, 'r', 1);
+    if ($fp) {
+        while (!@feof($fp)) {
+            $line = trim(fgets($fp, 65536));
+                if (preg_match('#^insert\s*into.*;$#i', $line)) {
+                    array_push($queries, $line);
+                }
+            }
+        }
+        fclose($fp);
+
+    return $queries;
+}
+
 /**
  * Check the serendipity Installation for problems, during installation
  *