includes/pageprocess.php
changeset 827 2c20563245b2
parent 825 9d5c04c1414f
parent 821 a64c56a1a6a4
child 832 7152ca0a0ce9
--- a/includes/pageprocess.php	Sun Jan 25 21:20:14 2009 -0500
+++ b/includes/pageprocess.php	Sun Jan 25 21:21:07 2009 -0500
@@ -504,10 +504,11 @@
   /**
    * Creates the page if it doesn't already exist.
    * @param string Optional page title.
+   * @param bool Visibility (allow indexing) flag
    * @return bool True on success, false on failure.
    */
   
-  function create_page($title = false)
+  function create_page($title = false, $visible = true)
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
     global $lang;
@@ -552,7 +553,7 @@
         'namespace' => $this->namespace,
         'name' => $name,
         'special' => 0,
-        'visible' => 1,
+        'visible' => $visible ? 1 : 0,
         'comments_on' => 1,
         'protected' => ( $this->namespace == 'System' ? 1 : 0 ),
         'delvotes' => 0,
@@ -569,8 +570,8 @@
     $blank_array = $db->escape(serialize(array()));
     
     // Query 1: Metadata entry
-    $q = $db->sql_query('INSERT INTO ' . table_prefix . "pages(name, urlname, namespace, protected, delvotes, delvote_ips, wiki_mode)\n"
-                        . "VALUES ( '$name', '$page_id', '$namespace', $protect, 0, '$blank_array', 2 );");
+    $q = $db->sql_query('INSERT INTO ' . table_prefix . "pages(name, urlname, namespace, visible, protected, delvotes, delvote_ips, wiki_mode)\n"
+                      . "  VALUES ( '$name', '$page_id', '$namespace', {$metadata['visible']}, $protect, 0, '$blank_array', 2 );");
     if ( !$q )
       $db->_die('PageProcessor page creation - metadata stage');
     
@@ -590,6 +591,9 @@
     // Update the cache
     $paths->update_metadata_cache();
     
+    // Make sure that when/if we save the page later in this instance it doesn't get re-created
+    $this->page_exists = true;
+    
     // Page created. We're good!
     return true;
   }