blob: 42b0353a4deda3d7c36172ae67429f54413ab8ec [file] [log] [blame]
atoulmeb80b4682009-01-22 13:08:36 +00001<?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.
atoulme13073032009-01-27 16:31:27 +000014class Reference_backend {
atoulmeb80b4682009-01-22 13:08:36 +000015 /*
16 * Authenticate a user.
17 * Returns the User object if the user is found, or false
18 */
atoulmedbe670e2009-01-27 11:23:51 +000019 function authenticate($User, $email, $password) {
20 $User->userid = 5;
atoulmeb80b4682009-01-22 13:08:36 +000021 }
atoulme828bc472009-01-28 06:52:51 +000022
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 }
atoulme3ac52612009-02-02 13:14:39 +000039
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 }
atoulmeb80b4682009-01-22 13:08:36 +000071}
72
atoulme13073032009-01-27 16:31:27 +000073function __register_backend_ref($addon) {
74 $addon->register('user_authentication', array('Reference_backend', 'authenticate'));
atoulme828bc472009-01-28 06:52:51 +000075 $addon->register('syncup_user', array('Reference_backend', 'syncupUser'));
76 $addon->register('genie_user', array('Reference_backend', 'genieUser'));
atoulme3ac52612009-02-02 13:14:39 +000077 $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'));
atoulmeb80b4682009-01-22 13:08:36 +000081}
82
atoulme13073032009-01-27 16:31:27 +000083global $register_function_backend;
84$register_function_backend = '__register_backend_ref';
atoulmeb80b4682009-01-22 13:08:36 +000085
86?>