atoulme | b80b468 | 2009-01-22 13:08:36 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2007-2009 Intalio, Inc. |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Antoine Toulme, Intalio Inc. |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | // Use a class to define the hooks to avoid bugs with already defined functions. |
atoulme | 1307303 | 2009-01-27 16:31:27 +0000 | [diff] [blame] | 14 | class Reference_backend { |
atoulme | b80b468 | 2009-01-22 13:08:36 +0000 | [diff] [blame] | 15 | /* |
| 16 | * Authenticate a user. |
| 17 | * Returns the User object if the user is found, or false |
| 18 | */ |
atoulme | dbe670e | 2009-01-27 11:23:51 +0000 | [diff] [blame] | 19 | function authenticate($User, $email, $password) { |
| 20 | $User->userid = 5; |
atoulme | b80b468 | 2009-01-22 13:08:36 +0000 | [diff] [blame] | 21 | } |
atoulme | 828bc47 | 2009-01-28 06:52:51 +0000 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Returns a user that is specialized in running the syncup script. |
| 25 | */ |
| 26 | function syncupUser() { |
| 27 | $User = new User(); |
| 28 | $User->loadFromID(1); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Returns the genie user that represents the headless admin for most operations, |
| 33 | * like importing a zip of translations. |
| 34 | */ |
| 35 | function genieUser() { |
| 36 | $User = new User(); |
| 37 | $User->loadFromID(1); |
| 38 | } |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Returns the name of the current context, one of live, staging or dev. |
| 42 | */ |
| 43 | function context() { |
| 44 | return "reference"; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns a hash of the parameters. |
| 49 | */ |
| 50 | function db_params() { |
| 51 | return array('db_read_host' => '', |
| 52 | 'db_read_user' => '', |
| 53 | 'db_read_pass' => '', |
| 54 | 'db_read_name' => ''); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Deals with error messages. |
| 59 | */ |
| 60 | function error_log() { |
| 61 | $args = func_get_args(); |
| 62 | error_log($args); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the name of the directory Babel should use to work in. |
| 67 | */ |
| 68 | function babel_working() { |
| 69 | return "/home/babel-working/"; |
| 70 | } |
atoulme | b80b468 | 2009-01-22 13:08:36 +0000 | [diff] [blame] | 71 | } |
| 72 | |
atoulme | 1307303 | 2009-01-27 16:31:27 +0000 | [diff] [blame] | 73 | function __register_backend_ref($addon) { |
| 74 | $addon->register('user_authentication', array('Reference_backend', 'authenticate')); |
atoulme | 828bc47 | 2009-01-28 06:52:51 +0000 | [diff] [blame] | 75 | $addon->register('syncup_user', array('Reference_backend', 'syncupUser')); |
| 76 | $addon->register('genie_user', array('Reference_backend', 'genieUser')); |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 77 | $addon->register('context', array('Reference_backend', 'context')); |
| 78 | $addon->register('db_params', array('Reference_backend', 'db_parameters')); |
| 79 | $addon->register('error_log', array('Reference_backend', 'error_log')); |
| 80 | $addon->register('babel_working', array('Reference_backend', 'babel_working')); |
atoulme | b80b468 | 2009-01-22 13:08:36 +0000 | [diff] [blame] | 81 | } |
| 82 | |
atoulme | 1307303 | 2009-01-27 16:31:27 +0000 | [diff] [blame] | 83 | global $register_function_backend; |
| 84 | $register_function_backend = '__register_backend_ref'; |
atoulme | b80b468 | 2009-01-22 13:08:36 +0000 | [diff] [blame] | 85 | |
| 86 | ?> |