public static function getInstance() { if (is_null(self::$instance)) { $prefs = Preferences::getInstance(); if (!$prefs) { die_error('get Preferences failed', __FILE__, __LINE__); } $mods_enable = $prefs->get('general', 'module_enable'); if (!in_array('UserGroupDBDynamicCached', $mods_enable)) { die_error(_('UserGroupDBDynamicCached module must be enabled'), __FILE__, __LINE__); } $mod_app_name = 'UserGroupDBDynamicCached_' . $prefs->get('UserGroupDBDynamicCached', 'enable'); self::$instance = new $mod_app_name(); } return self::$instance; }
public function __construct() { $prefs = Preferences::getInstance(); if (!$prefs) { die_error('get Preferences failed', __FILE__, __LINE__); } $mods_enable = $prefs->get('general', 'module_enable'); if (!in_array('UserGroupDB', $mods_enable)) { die_error(_('UserGroupDB module must be enabled'), __FILE__, __LINE__); } $this->instance_type = array(); $mod_usergroup_name = 'UserGroupDB_' . $prefs->get('UserGroupDB', 'enable'); $a_userGroupDB = new $mod_usergroup_name(); $this->instance_type['static'] = $a_userGroupDB; if (Preferences::moduleIsEnabled('UserGroupDBDynamic')) { $this->instance_type['dynamic'] = UserGroupDBDynamic::getInstance(); } if (Preferences::moduleIsEnabled('UserGroupDBDynamicCached')) { $this->instance_type['dynamiccached'] = UserGroupDBDynamicCached::getInstance(); } }
public static function loadGroups($type_, $element_) { Logger::debug('main', "Abstract_Liaison_dynamic::loadGroups ({$type_},{$element_})"); $groups = array(); if (Preferences::moduleIsEnabled('UserGroupDBDynamic')) { $userGroupDB_dynamic = UserGroupDBDynamic::getInstance(); $usergroup_list = $userGroupDB_dynamic->getList(); foreach ($usergroup_list as $group) { if (in_array($element_, $group->usersLogin())) { $l = new Liaison($element_, $group->getUniqueID()); $groups[$l->group] = $l; } } } if (Preferences::moduleIsEnabled('UserGroupDBDynamicCached')) { $userGroupDB_dynamic = UserGroupDBDynamicCached::getInstance(); $usergroup_list = $userGroupDB_dynamic->getList(); foreach ($usergroup_list as $group) { if (in_array($element_, $group->usersLogin())) { $l = new Liaison($element_, $group->getUniqueID()); $groups[$l->group] = $l; } } } return $groups; }
public static function prefsIsValid($prefs_, &$log = array()) { $ret = parent::prefsIsValid($prefs_, $log); if ($ret === false) { return false; } $sql_conf = $prefs_->get('general', 'sql'); if (!is_array($sql_conf)) { return false; } $table = $sql_conf['prefix'] . 'usergroup_dynamic_cached'; $sql2 = SQL::newInstance($sql_conf); $ret = $sql2->DoQuery('SHOW TABLES FROM @1 LIKE %2', $sql_conf['database'], $table); if ($ret !== false) { $ret2 = $sql2->NumRows(); if ($ret2 == 1) { return true; } else { Logger::error('main', 'UserGroupDBDynamic_cached::prefsIsValid table \'' . $table . '\' does not exist'); return false; } } else { Logger::error('main', 'UserGroupDBDynamic_cached::prefsIsValid table \'' . $table . '\' does not exist(2)'); return false; } }
* along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/../admin/includes/core-minimal.inc.php'; if (Preferences::fileExists() === false) { exit(1); } //BEGIN Updating logs cache $servers = Abstract_Server::load_all(); foreach ($servers as $server) { $buf = new Server_Logs($server); $buf->process(); } //END Updating logs cache //BEGIN UserGroupDBDynamic_cached update if (Preferences::moduleIsEnabled('UserGroupDBDynamicCached')) { $ugdbdc = UserGroupDBDynamicCached::getInstance(); $groups = $ugdbdc->getList(); if (!is_array($groups)) { Logger::error('main', '(hourly cron) UserGroupDBDynamic_cached->getList() failed'); } else { foreach ($groups as $a_group) { $ret = $ugdbdc->updateCache($a_group); if ($ret !== true) { Logger::error('main', '(hourly cron) UserGroupDBDynamic_cached->updateCache for group \'' . $a_group->getUniqueID() . '\' failed'); } } } } //END UserGroupDBDynamic_cached update exit(0);