source: trunk/phpgwapi/inc/class.accounts.inc.php @ 7673

Revision 7673, 22.6 KB checked in by douglasz, 11 years ago (diff)

Ticket #3236 - Correcoes para Performance: Function Within Loop Declaration.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare API - Accounts manager shared functions                       *
4        * Written by Joseph Engo <jengo@phpgroupware.org>                          *
5        *        and Bettina Gille [ceb@phpgroupware.org]                          *
6        * shared functions for other account repository managers                   *
7        * Copyright (C) 2000 - 2002 Joseph Engo                                    *
8        * Copyright (C) 2003 Joseph Engo, Bettina Gille                            *
9        * -------------------------------------------------------------------------*
10        * This library is part of the eGroupWare API                               *
11        * http://www.egroupware.org                                                *
12        * ------------------------------------------------------------------------ *
13        * This library is free software; you can redistribute it and/or modify it  *
14        * under the terms of the GNU Lesser General Public License as published by *
15        * the Free Software Foundation; either version 2.1 of the License,         *
16        * or any later version.                                                    *
17        * This library is distributed in the hope that it will be useful, but      *
18        * WITHOUT ANY WARRANTY; without even the implied warranty of               *
19        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
20        * See the GNU Lesser General Public License for more details.              *
21        * You should have received a copy of the GNU Lesser General Public License *
22        * along with this library; if not, write to the Free Software Foundation,  *
23        * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
24        \**************************************************************************/
25
26        if (empty($GLOBALS['phpgw_info']['server']['account_repository']))
27        {
28                if (!empty($GLOBALS['phpgw_info']['server']['auth_type']))
29                {
30                        $GLOBALS['phpgw_info']['server']['account_repository'] = $GLOBALS['phpgw_info']['server']['auth_type'];
31                }
32                else
33                {
34                        $GLOBALS['phpgw_info']['server']['account_repository'] = 'sql';
35                }
36        }
37        include_once(PHPGW_API_INC . '/class.accounts_' . $GLOBALS['phpgw_info']['server']['account_repository'] . '.inc.php');
38
39        /*
40          Dont know where to put this (seek3r)
41          This is where it belongs (jengo)
42          This is where it ended up (milosch)
43          Moved again at least temporarily since sql and ldap use it.
44        */
45        $GLOBALS['phpgw_info']['server']['global_denied_users'] = array(
46                'root'     => True, 'bin'      => True, 'daemon'   => True,
47                'adm'      => True, 'lp'       => True, 'sync'     => True,
48                'shutdown' => True, 'halt'     => True, 'ldap'     => True,
49                'mail'     => True, 'news'     => True, 'uucp'     => True,
50                'operator' => True, 'games'    => True, 'gopher'   => True,
51                'nobody'   => True, 'xfs'      => True, 'pgsql'    => True,
52                'mysql'    => True, 'postgres' => True, 'oracle'   => True,
53                'ftp'      => True, 'gdm'      => True, 'named'    => True,
54                'alias'    => True, 'web'      => True, 'sweep'    => True,
55                'cvs'      => True, 'qmaild'   => True, 'qmaill'   => True,
56                'qmaillog' => True, 'qmailp'   => True, 'qmailq'   => True,
57                'qmailr'   => True, 'qmails'   => True, 'rpc'      => True,
58                'rpcuser'  => True, 'amanda'   => True, 'apache'   => True,
59                'pvm'      => True, 'squid'    => True, 'ident'    => True,
60                'nscd'     => True, 'mailnull' => True, 'cyrus'    => True,
61                'backup'    => True
62        );
63
64        $GLOBALS['phpgw_info']['server']['global_denied_groups'] = array(
65                'root'      => True, 'bin'       => True, 'daemon'    => True,
66                'sys'       => True, 'adm'       => True, 'tty'       => True,
67                'disk'      => True, 'lp'        => True, 'mem'       => True,
68                'kmem'      => True, 'wheel'     => True, 'mail'      => True,
69                'uucp'      => True, 'man'       => True, 'games'     => True,
70                'dip'       => True, 'ftp'       => True, 'nobody'    => True,
71                'floppy'    => True, 'xfs'       => True, 'console'   => True,
72                'utmp'      => True, 'pppusers'  => True, 'popusers'  => True,
73                'slipusers' => True, 'slocate'   => True, 'mysql'     => True,
74                'dnstools'  => True, 'web'       => True, 'named'     => True,
75                'dba'       => True, 'oinstall'  => True, 'oracle'    => True,
76                'gdm'       => True, 'sweep'     => True, 'cvs'       => True,
77                'postgres'  => True, 'qmail'     => True, 'nofiles'   => True,
78                'ldap'      => True, 'backup'    => True
79        );
80
81        /*!
82         @class_start accounts
83         @abstract Class for handling user and group accounts
84        */
85
86        class accounts extends accounts_
87        {
88                var $memberships    = array();
89                var $members        = array();
90                var $xmlrpc_methods = array();
91                // enables the session-cache
92                var $use_session_cache = True;
93
94                /**************************************************************************\
95                * Standard constructor for setting $this->account_id                       *
96                * This constructor sets the account id, if string is sent, converts to id  *
97                * I might move this to the accounts_shared if it stays around              *
98                \**************************************************************************/
99                function accounts($account_id = '', $account_type='')
100                {
101                        // enable the caching in the session onyl for ldap
102                        $this->use_session_cache = $GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap';
103
104                        $this->db = $GLOBALS['phpgw']->db;
105
106                        if($account_id != '')
107                        {
108                                $this->account_id = get_account_id($account_id);
109                        }
110
111                        if($account_type != '')
112                        {
113                                $this->account_type = $account_type;
114                        }
115
116                        $this->query_types = array(
117                                'all' => 'all fields',
118                                'firstname' => 'firstname',
119                                'lastname' => 'lastname',
120                                'lid' => 'LoginID',
121                                'email' => 'email',     
122                                'start' => 'start with',
123                                'exact' => 'exact',
124                        );
125                        $this->accounts_();                     // call constructor of extended class
126
127                        $this->xmlrpc_methods[] = array(
128                                'name'        => 'get_list',
129                                'description' => 'Returns a list of accounts and/or groups'
130                        );
131                        $this->xmlrpc_methods[] = array(
132                                'name'        => 'name2id',
133                                'description' => 'Cross reference account_lid with account_id'
134                        );
135                        $this->xmlrpc_methods[] = array(
136                                'name'        => 'id2name',
137                                'description' => 'Cross reference account_id with account_lid'
138                        );
139                }
140
141                /**
142                * Sets up the account-data cache
143                *
144                * The cache is shared between all instances of the account-class and it can be save in the session,
145                * if use_session_cache is set to True
146                */
147                function setup_cache()
148                {
149                        if ($this->use_session_cache &&         // are we supposed to use a session-cache
150                                !@$GLOBALS['phpgw_info']['accounts']['session_cache_setup'] &&  // is it already setup
151                                // is the account-class ready (startup !)
152                                is_object($GLOBALS['phpgw']->session) && $GLOBALS['phpgw']->session->account_id)
153                        {
154                                // setting up the session-cache
155                                $GLOBALS['phpgw_info']['accounts']['cache'] = $GLOBALS['phpgw']->session->appsession('accounts_cache','phpgwapi');
156                                $GLOBALS['phpgw_info']['accounts']['session_cache_setup'] = True;
157                                //echo "accounts::setup_cache() cache=<pre>".print_r($GLOBALS['phpgw_info']['accounts']['cache'],True)."</pre>\n";
158                        }
159                        if (!isset($this->cache))
160                        {
161                                $this->cache = &$GLOBALS['phpgw_info']['accounts']['cache'];
162                        }
163                }
164
165                /**
166                * Saves the account-data cache in the session
167                *
168                * Gets called from common::phpgw_final()
169                */
170                function save_session_cache()
171                {
172                        if ($this->use_session_cache &&         // are we supposed to use a session-cache
173                                $GLOBALS['phpgw_info']['accounts']['session_cache_setup'] &&    // is it already setup
174                                // is the account-class ready (startup !)
175                                is_object($GLOBALS['phpgw']->session))
176                        {
177                                $GLOBALS['phpgw']->session->appsession('accounts_cache','phpgwapi',$GLOBALS['phpgw_info']['accounts']['cache']);
178                        }
179                }
180
181                /**
182                 * Searches / lists accounts: users and/or groups
183                 *
184                 * @param $param['type'] string/int 'accounts', 'groups', 'owngroups' (groups the user is a member of), 'both'
185                 *      or integer group-id for a list of members of that group
186                 * @param $param['start'] int first account to return (returns offset or max_matches entries) or all if not set
187                 * @param $param['sort'] string column to sort after, default account_lid if unset
188                 * @param $param['order'] string 'ASC' or 'DESC', default 'DESC' if not set
189                 * @param $param['query'] string to search for, no search if unset or empty
190                 * @param $param['query_type'] string:
191                 *      'all'   - query all fields for containing $param[query]
192                 *      'start' - query all fields starting with $param[query]
193                 *      'exact' - query all fields for exact $param[query]
194                 *      'lid','firstname','lastname','email' - query only the given field for containing $param[query]
195                 * @param $param['app'] string with an app-name, to limit result on accounts with run-right for that app
196                 * @param $param['offset'] int - number of matches to return if start given, default use the value in the prefs
197                 * @return array with uid / data pairs, data is an array with account_id, account_lid, account_firstname,
198                 *      account_lastname, person_id (id of the linked addressbook entry), account_status, account_expires, account_primary_group
199                 */
200                function search($param)
201                {
202                        //echo "<p>accounts::search(".print_r($param,True).")</p>\n";
203                        $this->setup_cache();
204                        $account_search = &$this->cache['account_search'];
205                       
206                        $serial = serialize($param);
207
208                        if (isset($account_search[$serial]))
209                        {
210                                $this->total = $account_search[$serial]['total'];
211                        }
212                        elseif (function_exists('accounts_::search'))   // implements its on search function ==> use it
213                        {
214                                $account_search[$serial]['data'] = accounts_::search($param);
215                                $account_search[$serial]['total'] = $this->total;
216                        }
217                        else
218                        {
219                                $serial2 = $serial;
220                                if (is_numeric($param['type']) || $param['app'] || $param['type'] == 'owngroups')       // do we need to limit the search on a group or app?
221                                {
222                                        $app = $param['app'];
223                                        unset($param['app']);
224                                        if (is_numeric($param['type']))
225                                        {
226                                                $group = (int) $param['type'];
227                                                $param['type'] = 'accounts';
228                                        }
229                                        elseif ($param['type'] == 'owngroups')
230                                        {
231                                                $group = -1;
232                                                $param['type'] = 'groups';
233                                        }
234                                        $start = $param['start'];
235                                        unset($param['start']);
236                                        $serial2 = serialize($param);
237                                }
238                                if (!isset($account_search[$serial2]))  // check if we already did this general search
239                                {
240                                        $account_search[$serial2]['data'] = array();
241                                        $accounts = accounts_::get_list($param['type'],$param['start'],$param['sort'],$param['order'],$param['query'],$param['offset'],$param['query_type']);
242                                        if (!$accounts) $accounts = array();
243                                        foreach($accounts as $data)
244                                        {
245                                                $account_search[$serial2]['data'][$data['account_id']] = $data;
246                                        }
247                                        $account_search[$serial2]['total'] = $this->total;
248                                }
249                                else
250                                {
251                                        $this->total = $account_search[$serial2]['total'];
252                                }
253                                //echo "accounts_::get_list($param[type],$param[start],$param[sort],$param[order],$param[query],$param[offset],$param[query_type]) returned<pre>".print_r($account_search[$serial2],True)."</pre>\n";
254                                if ($app || $group)     // limit the search on accounts with run-rights for app or a group
255                                {
256                                        $valid = array();
257                                        if ($app)
258                                        {
259                                                $valid = $this->split_accounts($app,$param['type'] == 'both' ? 'merge' : $param['type']);
260                                        }
261                                        if ($group)
262                                        {
263                                                $members = $group > 0 ? $GLOBALS['phpgw']->acl->get_ids_for_location($group, 1, 'phpgw_group') :
264                                                        $GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1,$GLOBALS['phpgw_info']['user']['account_id']);
265                                                if (!$members) $members = array();
266                                                $valid = !$app ? $members : array_intersect($valid,$members);   // use the intersection
267                                        }
268                                        //echo "<p>limiting result to app='app' and/or group=$group valid-ids=".print_r($valid,true)."</p>\n";
269                                        $offset = $param['offset'] ? $param['offset'] : $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
270                                        $stop = $start + $offset;
271                                        $n = 0;
272                                        $account_search[$serial]['data'] = array();
273                                        foreach ($account_search[$serial2]['data'] as $id => $data)
274                                        {
275                                                if (!in_array($id,$valid))
276                                                {
277                                                        $this->total--;
278                                                        continue;
279                                                }
280                                                // now we have a valid entry
281                                                if (!is_int($start) || $start <= $n && $n < $stop)
282                                                {
283                                                        $account_search[$serial]['data'][$id] = $data;
284                                                }
285                                                ++$n;
286                                        }
287                                        $account_search[$serial]['total'] = $this->total;
288                                }
289                        }
290                        //echo "<p>accounts::search('$serial')=<pre>".print_r($account_search[$serial]['data'],True).")</pre>\n";
291                        return $account_search[$serial]['data'];
292                }
293
294
295                function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '',$query_type='')
296                {
297                        //echo "<p>accounts::get_list(".print_r($_type,True).",start='$start',sort='$sort',order='$order',query='$query',offset='$offset')</p>\n";
298                        $this->setup_cache();
299                        $account_list = &$this->cache['account_list'];
300
301                        // For XML-RPC
302                        if (is_array($_type))
303                        {
304                                $p      = $_type;
305                                $_type  = $p['type'];
306                                $start  = $p['start'];
307                                $order  = $p['order'];
308                                $query  = $p['query'];
309                                $offset = $p['offset'];
310                                $query_type = $p['query_type'];
311                        }
312                        else
313                        {
314                                $p = array(
315                                        'type' => $_type,
316                                        'start' => $start,
317                                        'order' => $order,
318                                        'query' => $query,
319                                        'offset' => $offset,
320                                        'query_type' => $query_type ,
321                                );
322                        }
323                        $serial = serialize($p);
324
325                        if (isset($account_list[$serial]))
326                        {
327                                $this->total = $account_list[$serial]['total'];
328                        }
329                        else
330                        {
331                                $account_list[$serial]['data'] = accounts_::get_list($_type,$start,$sort,$order,$query,$offset,$query_type);
332                                $account_list[$serial]['total'] = $this->total;
333                        }
334                        return $account_list[$serial]['data'];
335                }
336
337                function is_expired()
338                {
339                        if ($this->data['expires'] != -1 && $this->data['expires'] < time())
340                        {
341                                return True;
342                        }
343                        else
344                        {
345                                return False;
346                        }
347                }
348
349                /**
350                * Invalidate the cache (or parts of it) after change in $account_id
351                *
352                * Atm simplest approach - delete it all ;-)
353                */
354                function cache_invalidate($account_id)
355                {
356                        //echo "<p>accounts::cache_invalidate($account_id)</p>\n";
357                        $GLOBALS['phpgw_info']['accounts']['cache'] = array();
358                }
359
360                function save_repository()
361                {
362                        $this->cache_invalidate($this->account_id);
363                        accounts_::save_repository();
364                }
365
366                function delete($accountid = '')
367                {
368                        $this->cache_invalidate($accountid);
369                        parent::delete($accountid);
370                       
371                        // delete all acl_entries belonging to that user or group
372                        $GLOBALS['phpgw']->acl->delete_account($accountid);
373                }
374
375                function create($account_info,$default_prefs=True)
376                {
377                        $account_id = accounts_::create($account_info,$default_prefs);
378                        $this->cache_invalidate($account_id);
379
380                        return $account_id;
381                }
382
383                function read_repository()
384                {
385                        $this->setup_cache();
386                        $account_data = &$this->cache['account_data'];
387
388                        if (isset($account_data[$this->account_id]))
389                        {
390                                return $this->data = $account_data[$this->account_id];
391                        }
392                        return $account_data[$this->account_id] = accounts_::read_repository();
393                }
394
395                function read()
396                {
397                        if (count($this->data) == 0)
398                        {
399                                $this->read_repository();
400                        }
401
402                        reset($this->data);
403                        return $this->data;
404                }
405
406                function update_data($data)
407                {
408                        reset($data);
409                        $this->data = Array();
410                        $this->data = $data;
411
412                        reset($this->data);
413                        return $this->data;
414                }
415
416                function membership($accountid = '')
417                {
418                        $this->setup_cache();
419                        $membership_list = &$this->cache['membership_list'];
420
421                        $account_id = get_account_id($accountid);
422
423                        if (isset($membership_list[$account_id]))
424                        {
425                                return $membership_list[$account_id];
426                        }
427
428                        $security_equals = Array();
429                        $security_equals = $GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id);
430
431                        if ($security_equals == False)
432                        {
433                                return $membership_list[$account_id] = False;
434                        }
435
436                        $this->memberships = Array();
437
438            $security_equals_count = count($security_equals);
439                        for ($idx=0; $idx<$security_equals_count; ++$idx)
440                        {
441                                $groups = (int)$security_equals[$idx];
442                               
443                                /* jakjr: expressoLivre does not need the cn of each group */
444                                //$this->memberships[] = Array('account_id' => $groups, 'account_name' => $this->id2name($groups));
445                               
446                                $this->memberships[] = Array('account_id' => $groups, 'account_name' => $groups);
447                        }
448
449                        return $membership_list[$account_id] = $this->memberships;
450                }
451
452                function member($accountid = '')
453                {
454                        $account_id = get_account_id($accountid);
455
456                        $security_equals = Array();
457                        $acl = CreateObject('phpgwapi.acl');
458                        $security_equals = $acl->get_ids_for_location($account_id, 1, 'phpgw_group');
459                        unset($acl);
460
461                        if ($security_equals == False)
462                        {
463                                return False;
464                        }
465
466            $security_equals_count = count($security_equals);
467                        for ($idx=0; $idx<$security_equals_count; ++$idx)
468                        {
469                                $name = $this->id2name((int)$security_equals[$idx]);
470                                $this->members[] = Array('account_id' => (int)$security_equals[$idx], 'account_name' => $name);
471                        }
472
473                        return $this->members;
474                }
475
476                /*!
477                @function get_nextid
478                @abstract Using the common functions next_id and last_id, find the next available account_id
479                @param $account_type (optional, default to 'u')
480                */
481                // NOTE: to my knowledge this is not used any more RalfBecker 2004/06/15
482                function get_nextid($account_type='u')
483                {
484                        $min = $GLOBALS['phpgw_info']['server']['account_min_id'] ? $GLOBALS['phpgw_info']['server']['account_min_id'] : 0;
485                        $max = $GLOBALS['phpgw_info']['server']['account_max_id'] ? $GLOBALS['phpgw_info']['server']['account_max_id'] : 0;
486
487                        if ($account_type == 'g')
488                        {
489                                $type = 'groups';
490                        }
491                        else
492                        {
493                                $type = 'accounts';
494                        }
495                        $nextid = (int)$GLOBALS['phpgw']->common->last_id($type,$min,$max);
496
497                        /* Loop until we find a free id */
498                        $free = 0;
499                        while (!$free)
500                        {
501                                $account_lid = '';
502                                //echo '<br>calling search for id: '.$nextid;
503                                if ($this->exists($nextid))
504                                {
505                                        $nextid = (int)$GLOBALS['phpgw']->common->next_id($type,$min,$max);
506                                }
507                                else
508                                {
509                                        $account_lid = $this->id2name($nextid);
510                                        /* echo '<br>calling search for lid: '.$account_lid . '(from account_id=' . $nextid . ')'; */
511                                        if ($this->exists($account_lid))
512                                        {
513                                                $nextid = (int)$GLOBALS['phpgw']->common->next_id($type,$min,$max);
514                                        }
515                                        else
516                                        {
517                                                $free = True;
518                                        }
519                                }
520                        }
521                        if      ($GLOBALS['phpgw_info']['server']['account_max_id'] &&
522                                ($nextid > $GLOBALS['phpgw_info']['server']['account_max_id']))
523                        {
524                                return False;
525                        }
526                        /* echo '<br>using'.$nextid;exit; */
527                        return $nextid;
528                }
529
530
531                /**
532                * splits users and groups from a array of id's or the accounts with run-rights for a given app-name
533                *
534                * @param $app_users array of user-id's or app-name (if you use app-name the result gets cached!)
535                * @param $use string what should be returned only an array with id's of either 'accounts' or 'groups'.
536                *       Or an array with arrays for 'both' under the keys 'groups' and 'accounts' or 'merge' for accounts
537                *       and groups merged into one array
538                * @return see $use
539                */
540                function split_accounts($app_users,$use='both')
541                {
542                        if (!is_array($app_users))
543                        {
544                                $this->setup_cache();
545                                $cache = &$this->cache['account_split'][$app_user];
546
547                                if (is_array($cache))
548                                {
549                                        return $cache;
550                                }
551                                $app_users = $GLOBALS['phpgw']->acl->get_ids_for_location('run',1,$app_users);
552                        }
553                        $accounts = array(
554                                'accounts' => array(),
555                                'groups' => array(),
556                        );
557                        foreach($app_users as $id)
558                        {
559                                $type = $GLOBALS['phpgw']->accounts->get_type($id);
560                                if($type == 'g')
561                                {
562                                        $accounts['groups'][$id] = $id;
563                                        foreach((array)$GLOBALS['phpgw']->acl->get_ids_for_location($id,1,'phpgw_group') as $id)
564                                        {
565                                                $accounts['accounts'][$id] = $id;
566                                        }
567                                }
568                                else
569                                {
570                                        $accounts['accounts'][$id] = $id;
571                                }
572                        }
573
574                        // not sure why they need to be sorted, but we need to remove the keys anyway
575                        sort($accounts['groups']);
576                        sort($accounts['accounts']);
577
578                        if (isset($cache))
579                        {
580                                $cache = $accounts;
581                        }
582                        //echo "<p>accounts::split_accounts(".print_r($app_users,True).",'$use') = <pre>".print_r($accounts,True)."</pre>\n";
583
584                        switch($use)
585                        {
586                                case 'both':
587                                        return $accounts;
588                                case 'groups':
589                                        return $accounts['groups'];
590                                case 'accounts':
591                                        return $accounts['accounts'];
592                                case 'merge':
593                                        return array_merge($accounts['accounts'],$accounts['groups']);
594                        }
595                        return False;
596                }
597
598                /**
599                 * phpgw compatibility function, better use split_accounts
600                 */
601                function return_members($accounts)
602                {
603                        $arr = $this->split_accounts($accounts);
604
605                        return array(
606                                'users'  => $arr['accounts'],
607                                'groups' => $arr['groups'],
608                        );
609                }
610
611                function name2id($name,$which='account_lid')
612                {
613                        $this->setup_cache();
614                        $name_list = &$this->cache['name_list'];
615
616                        if(@isset($name_list[$which][$name]) && $name_list[$which][$name])
617                        {
618                                return $name_list[$which][$name];
619                        }
620
621                        /* Don't bother searching for empty account_lid */
622                        if(empty($name))
623                        {
624                                return False;
625                        }
626                        return $name_list[$which][$name] = accounts_::name2id($name,$which);
627                }
628
629                function id2name($account_id,$which='account_lid')
630                {
631                        $this->setup_cache();
632                        $id_list = &$this->cache['id_list'];
633
634                        if (! $account_id)
635                        {
636                                return False;
637                        }
638
639                        if($id_list[$account_id][$which])
640                        {
641                                return $id_list[$account_id][$which];
642                        }
643                        return $id_list[$account_id][$which] = accounts_::id2name($account_id,$which);
644                }
645
646                function get_type($accountid)
647                {
648                        $this->setup_cache();
649                        $account_type = &$this->cache['account_type'];
650
651                        $account_id = get_account_id($accountid);
652
653                        if (isset($this->account_type) && $account_id == $this->account_id)
654                        {
655                                return $this->account_type;
656                        }
657
658                        if(@isset($account_type[$account_id]) && @$account_type[$account_id])
659                        {
660                                return $account_type[$account_id];
661                        }
662                        elseif($account_id == '')
663                        {
664                                return False;
665                        }
666                        return $account_type[$account_id] = accounts_::get_type($account_id);
667                }
668
669                function get_account_name($accountid,&$lid,&$fname,&$lname)
670                {
671                        $this->setup_cache();
672                        $account_name = &$this->cache['account_name'];
673
674                        $account_id = get_account_id($accountid);
675                        if(isset($account_name[$account_id]))
676                        {
677                                $lid = $account_name[$account_id]['lid'];
678                                $fname = $account_name[$account_id]['fname'];
679                                $lname = $account_name[$account_id]['lname'];
680                                return $account_name[$account_id] !== False;
681                        }
682                        $Ok = accounts_::get_account_name($accountid,$lid,$fname,$lname);
683
684                        $account_name[$account_id] = array(
685                                'lid' => $lid,
686                                'fname' => $fname,
687                                'lname' => $lname,
688                        );
689                        return $Ok;
690                }
691
692                function get_account_data($account_id)
693                {
694                        $this->account_id = $account_id;
695                        $this->read_repository();
696
697                        $data[$this->data['account_id']]['lid']       = $this->data['account_lid'];
698                        $data[$this->data['account_id']]['firstname'] = $this->data['firstname'];
699                        $data[$this->data['account_id']]['lastname']  = $this->data['lastname'];
700                        $data[$this->data['account_id']]['fullname']  = $this->data['fullname'];
701                        $data[$this->data['account_id']]['type']      = $this->data['account_type'];
702
703                        return $data;
704                }
705        }
Note: See TracBrowser for help on using the repository browser.