[262697] Syncup script broken
diff --git a/addons/babel.eclipse.org/backend_functions.php b/addons/babel.eclipse.org/backend_functions.php
index b42c568..618c4be 100644
--- a/addons/babel.eclipse.org/backend_functions.php
+++ b/addons/babel.eclipse.org/backend_functions.php
@@ -65,10 +65,31 @@
             $GLOBALS['g_ERRSTRS'][1] = mysql_error();
         }
     }
+    
+    /**
+     * Returns a user that is specialized in running the syncup script.
+     */
+    function syncupUser() {
+        $User = new User();
+        $User->loadFromID(57110);
+        return $User;
+    }
+    
+    /**
+     * Returns the genie user that represents the headless admin for most operations,
+     * like importing a zip of translations.
+     */
+    function genieUser() {
+        $User = new User();
+        $User->loadFromID(40623);
+        return $User;
+    }
 }
 
 function __register_backend($addon) {
     $addon->register('user_authentication', array('BabelEclipseOrg_backend', 'authenticate'));
+    $addon->register('syncup_user', array('BabelEclipseOrg_backend', 'syncupUser'));
+    $addon->register('genie_user', array('BabelEclipseOrg_backend', 'genieUser'));
 }
 
 global $register_function_backend;
diff --git a/addons/babel.eclipse.org/staging/backend_functions.php b/addons/babel.eclipse.org/staging/backend_functions.php
index 1874c4d..8826d26 100644
--- a/addons/babel.eclipse.org/staging/backend_functions.php
+++ b/addons/babel.eclipse.org/staging/backend_functions.php
@@ -70,7 +70,7 @@
 }
 
 function __register_backend_staging($addon) {
-    $addon->register('user_authentication', array('BabelEclipseOrg_backend_staging', 'authenticate'));
+    __register_backend($addon);
 }
 
 global $register_function_backend;
diff --git a/addons/babel.eclipse.org/staging/html_functions.php b/addons/babel.eclipse.org/staging/html_functions.php
index 0c67113..bb72043 100644
--- a/addons/babel.eclipse.org/staging/html_functions.php
+++ b/addons/babel.eclipse.org/staging/html_functions.php
@@ -22,10 +22,8 @@
 }
 
 function __register_html_staging($addon) {
-    $addon->register('image_root', array('BabelEclipseOrgStaging', '_imageRoot'));
-    $addon->register('validate_map_file_url', array('BabelEclipseOrgStaging', 'validateMapFileUrl'));
+    __register_html($addon);
     $addon->register('head', array('BabelEclipseOrgStaging', 'head'));
-    $addon->register('footer', array('BabelEclipseOrgStaging', 'footer'));
 }
 
 global $register_function_html;
diff --git a/addons/reference/backend_functions.php b/addons/reference/backend_functions.php
index 173206c..3cc7f53 100644
--- a/addons/reference/backend_functions.php
+++ b/addons/reference/backend_functions.php
@@ -19,10 +19,29 @@
     function authenticate($User, $email, $password) {
         $User->userid = 5;
     }
+    
+    /**
+     * Returns a user that is specialized in running the syncup script.
+     */
+    function syncupUser() {
+        $User = new User();
+        $User->loadFromID(1);
+    }
+    
+    /**
+     * Returns the genie user that represents the headless admin for most operations,
+     * like importing a zip of translations.
+     */
+    function genieUser() {
+        $User = new User();
+        $User->loadFromID(1);
+    }
 }
 
 function __register_backend_ref($addon) {
     $addon->register('user_authentication', array('Reference_backend', 'authenticate'));
+    $addon->register('syncup_user', array('Reference_backend', 'syncupUser'));
+    $addon->register('genie_user', array('Reference_backend', 'genieUser'));
 }
 
 global $register_function_backend;
diff --git a/classes/export/syncup.php b/classes/export/syncup.php
index 17454a8..4811574 100644
--- a/classes/export/syncup.php
+++ b/classes/export/syncup.php
@@ -11,15 +11,16 @@
  *    Antoine Toulme - Initial contribution.
 *******************************************************************************/
 
-/*
- * Globals
- */
-header("Content-type: text/plain");
-include("global.php");
-InitPage("");
+ini_set("memory_limit", "64M");
+
+error_reporting(E_ALL);
+ini_set('display_errors', '1');
 
 require(dirname(__FILE__) . "/../system/dbconnection.class.php");
-require(dirname(__FILE__) . "/../html/common_functions.php");
+$dbc = new DBConnection();
+$dbh = $dbc->connect();
+
+require(dirname(__FILE__) . "/../system/backend_functions.php");
 
 if( !function_exists('json_encode') ){
 	require("/home/data/httpd/babel.eclipse.org/html/json_encode.php");
@@ -29,18 +30,13 @@
 	}
 }
 
-global $context;
-if($context == "") {
-	$context = "staging";
-}
-
 $User = getSyncupUser();
 
 $dbc = new DBConnection();
 global $dbh;
 $dbh = $dbc->connect();
 
-echo "Connection established, ready to begin";
+echo "Connection established, ready to begin; The syncup user id is $User->userid \n";
 $langs = mysql_query( "SELECT language_id FROM languages where languages.is_active" );
 while( ($lang_row = mysql_fetch_assoc($langs)) != null ) {
 	$language_id = $lang_row['language_id'];
diff --git a/classes/system/backend_functions.php b/classes/system/backend_functions.php
index 63e5d19..42fe814 100644
--- a/classes/system/backend_functions.php
+++ b/classes/system/backend_functions.php
@@ -68,23 +68,19 @@
 
 /**
 * Returns the genie user to be used for headless applications.
-* The user is found by looking for genie_id in the base.conf file.
+* The user is found by using a hook.
 */
 function getGenieUser() {
-  global $genie_id;
-  $User = new User();
-  $User->loadFromID($genie_id); 
-  return $User;
+  global $addon;
+  return $addon->callHook('genie_user');
 }
 /**
 * Returns the syncup user to be used for headless applications.
 * The user is found by looking for syncup_id in the base.conf file.
 */
 function getSyncupUser() {
-  global $syncup_id;
-  $User = new User();
-  $User->loadFromID($syncup_id); 
-  return $User;
+  global $addon;
+  return $addon->callHook('syncup_user');
 }
 
 /*