[go: up one dir, main page]

File: Driver.php

package info (click to toggle)
sork-accounts 2.1.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 532 kB
  • ctags: 79
  • sloc: sh: 553; php: 360; makefile: 114; perl: 30; xml: 16
file content (140 lines) | stat: -rw-r--r-- 4,707 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
 * $Horde: accounts/lib/Driver.php,v 1.9.2.1 2003/01/19 06:53:19 ericr Exp $
 *
 * Copyright 2001-2003 Eric Rostetter <eric.rostetter@physics.utexas.edu>
 *
 * See the enclosed file LICENSE for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/bsdl.php.
 *
 * Accounts_Driver:: defines an API for getting/displaying account information
 * for a user for the accounts module.
 *
 * @author   Eric Rostetter <eric.rostetter@physics.utexas.edu>
 * @version  $Revision: 1.9.2.1 $
 * @since    Accounts 2.1
 * @package  accounts
 */
class Accounts_Driver {

    /** error string returned to user if an eror occurs. */
    var $err_str;

    /**
     * Attempts to return a concrete Accounts_Driver instance based on $driver.
     *
     * @param string    $driver     The type of concrete Accounts_Driver
     *                              subclass to return.  The is based on the
     *                              accounts driver ($driver).  The code is
     *                              dynamically included.
     *
     * @param array     $params     (optional) A hash containing any additional
     *                              configuration or connection parameters a
     *                              subclass might need.
     *
     * @return mixed    The newly created concrete Accounts_Driver instance, or
     *                  false on an error.
     */
    function &factory($driver, $params = array())
    {
        $driver = strtolower(basename($driver));
        include_once dirname(__FILE__) . '/Driver/' . $driver . '.php';
        $class = 'Accounts_Driver_' . $driver;
        if (class_exists($class)) {
            return new $class($params);
        } else {
            return false;
        }
    }

    /**
     * Attempts to return a reference to a concrete Accounts_Driver instance
     * based on $driver.  It will only create a new instance if no
     * Accounts_Driver instance with the same parameters currently exists.
     *
     * This should be used if multiple storage sources are required.
     *
     * This method must be invoked as: $var = &Accounts_Driver::singleton()
     *
     * @param string    $driver     Type of concrete Accounts_Driver subclass
     *                              to return.  The is based on the accounts
     *                              driver ($driver).  The code is dynamically
     *                              included.
     *
     * @param array     $params     (optional) A hash containing any additional
     *                              configuration or connection parameters a
     *                              subclass might need.
     *
     * @return mixed    The created concrete Accounts_Driver instance, or false
     *                  on error.
     */
    function &singleton($driver, $params = array())
    {
        static $instances;

        if (!isset($instances)) {
            $instances = array();
        }

        $signature = serialize(array($driver, $params));
        if (!isset($instances[$signature])) {
            $instances[$signature] = &Accounts_Driver::factory($driver, $params);
        }

        return $instances[$signature];
    }

    /**
     * Get the user's quota if available
     *
     * @param   $username     The user for which to get the quota.
     * @param   $realm        The realm (domain) for the user.
     *
     * @return  mixed         A quota array, elements are used bytes and
     *                        limit bytes on success, false on failure.
     */
    function getQuota($username, $realm)
    {
        return false;
    }

    /**
     * Get the user's fullname.
     *
     * @param   $username     The user for which to get the full name.
     * @param   $realm        The realm (domain) for the user.
     *
     * @return  mixed         The user's full name (string), or false (error).
     */
    function getFullname($username, $realm)
    {
        return false;
    }

    /**
     * Get the user's Home (Login) Directory.
     *
     * @param   $username     The user for which to get the directory.
     * @param   $realm        The realm (domain) for the user.
     *
     * @return  mixed         The user's directory (string), or false (error).
     */
    function getHome($username, $realm)
    {
        return false;
    }

    /**
     * Get the user's default shell.
     *
     * @param   $username     The user for which to get the default shell.
     * @param   $realm        The realm (domain) for the user.
     *
     * @return  mixed         The user's shell (string), or false (error).
     */
    function getShell($username, $realm)
    {
        return false;
    }

}