Documentation is available at registrar_factory.php
- <?php
- class net_nemein_registrations_registrar_factory {
- var $_debug_prefix;
- var $_config;
- var $_topic;
- var $_auth;
- var $_group;
- var $_l10n;
- var $_l10n_midcom;
- var $_person_cache;
- var $_mail_to_person_map;
- function net_nemein_registrations_registrar_factory(&$topic, &$config, &$auth, &$group) {
- $this->_debug_prefix = "net.nemein.registrations registrar_factory::";
- debug_push($this->_debug_prefix . "constructor");
- $this->_config =& $config;
- $this->_topic =& $topic;
- $this->_auth =& $auth;
- $this->_group =& $group;
- $i18n =& $GLOBALS["midcom"]->get_service("i18n");
- $this->_l10n = $i18n->get_l10n("net.nemein.registrations");
- $this->_l10n_midcom = $i18n->get_l10n("midcom");
- $this->_person_cache = Array();
- $this->_mail_to_person_map = Array();
- $this->update_cache();
- debug_pop();
- }
- function update_cache () {
- if (! $this->_su())
- return false;
- debug_push ($this->_debug_prefix . "update_cache");
- $this->_person_cache = Array();
- $this->_mail_to_person_map = Array();
- $members = mgd_list_members($this->_group->id);
- if ($members) {
- while($members->fetch()){
- $id = $members->uid;
- $person = mgd_get_person($id);
- if (! $person) {
- debug_print_r("Could not load Person $id (" . mgd_errstr()
- . "), this is strange as the ID $id comes out of this fetchable:",
- $members
- );
- continue;
- }
- $this->_person_cache[$id] = $person;
- $this->_mail_to_person_map[$person->email] =& $this->_person_cache[$id];
- }
- } else {
- debug_add("No active accounts found.");
- }
- debug_print_r("mailtopersonmap:", $this->_mail_to_person_map);
- $this->_su(false);
- debug_pop();
- return true;
- }
- function getby_id ($id) {
- if ($this->exists_id($id))
- return $this->_person_cache[$id];
- else
- return null;
- }
- function getby_email ($mail) {
- if ($this->exists_email($mail))
- return $this->_mail_to_person_map[$mail];
- else
- return null;
- }
- function exists_id ($id) {
- return array_key_exists($id, $this->_person_cache);
- }
- function exists_email ($email) {
- return array_key_exists($email, $this->_mail_to_person_map);
- }
- function _su ($on = true) {
- if ($on) {
- if (! mgd_auth_midgard ($this->_config->get("admin_user"), $this->_config->get("admin_password"), false)) {
- debug_add("mgd_auth_midgard to admin level user failed:" . mgd_errstr());
- return false;
- } else {
- /* Call mgd_get_midgard, seems to be required according to emile/piotras */
- $midgard = mgd_get_midgard();
- debug_print_r("New midgard object is: ", $midgard);
- return true;
- }
- } else {
- $result = mgd_unsetuid();
- /* Call mgd_get_midgard, seems to be required according to emile/piotras */
- $unused = mgd_get_midgard();
- return $result;
- }
- }
- }
- ?>
Documentation generated on Mon, 21 Nov 2005 18:21:10 +0100 by phpDocumentor 1.3.0RC3