/** * Gets a configured instance of a storage adapter. * * @param mixed $adapterName string of adapter configuration or array of settings * @param boolean $renewObject Creates a new instance of the given adapter in the configuration * @throws \RuntimeException * @return \Gaufrette\Filesystem */ public static function adapter($adapterName, $renewObject = false) { $_this = StorageManager::getInstance(); $isConfigured = true; if (is_string($adapterName)) { if (!empty($_this->_adapterConfig[$adapterName])) { $adapter = $_this->_adapterConfig[$adapterName]; } else { throw new \RuntimeException(sprintf('Invalid Storage Adapter %s!', $adapterName)); } if (!empty($_this->_adapterConfig[$adapterName]['object']) && $renewObject === false) { return $_this->_adapterConfig[$adapterName]['object']; } } if (is_array($adapterName)) { $adapter = $adapterName; $isConfigured = false; } $class = $adapter['adapterClass']; $Reflection = new \ReflectionClass($class); if (!is_array($adapter['adapterOptions'])) { throw new \InvalidArgumentException(sprintf('%s: The adapter options must be an array!', $adapterName)); } $adapterObject = $Reflection->newInstanceArgs($adapter['adapterOptions']); $engineObject = new $adapter['class']($adapterObject); if ($isConfigured) { $_this->_adapterConfig[$adapterName]['object'] =& $engineObject; } return $engineObject; }
function __construct() { $this->relationsManager = new RelationsManager(); $this->provider = new SQLRelationsProvider(); // This is hard-coded, maybe in the future it will use another provider $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); }
private function getDao() { if (!isset(self::$dao)) { try { $dbHandler = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); } catch (Exception $e) { throw new EyeDBException('An error occured while getting connection to the database.', 0, $e); } self::$dao = $dbHandler; } return self::$dao; }
protected function __construct() { /** * establim la connexió a base de dades */ $this->eyeosDAO = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); /** * Connect to LDAP host */ $this->eyeosLDAP = ldap_connect(LDAP_HOSTNAME, LDAP_PORT) or $this->sendError("Can't connect to " . LDAP_HOSTNAME . " LDAP Server."); /** * set LDAP version */ ldap_set_option($this->eyeosLDAP, LDAP_OPT_PROTOCOL_VERSION, LDAP_OPT_PROTOCOL_VERSION_VALUE) or $this->sendError("Can't establish LDAP Protocol Version to " . LDAP_OPT_PROTOCOL_VERSION_VALUE); /** * If there is connection parms, link with them, if not, as anonimous */ if (defined('LDAP_BIND_RDN')) { ldap_bind($this->eyeosLDAP, LDAP_BIND_RDN, LDAP_BIND_PASSWORD) or $this->sendError("Can't bind to " . LDAP_HOSTNAME . " LDAP Server with user " . LDAP_BIND_RDN); } else { ldap_bind($this->eyeosLDAP) or $this->sendError("Can't bind to " . LDAP_HOSTNAME . " LDAP Server."); } }
function __start_test() { $dbh = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); // Drop tables try { $dbh->send('DROP TABLE `eyeosuserworkgroupassignation`'); } catch (PDOException $e) { } try { $dbh->send('DROP TABLE `eyeosworkgroup`'); } catch (PDOException $e) { } try { $dbh->send('DROP TABLE `eyeosprincipalgroupassignation`'); } catch (PDOException $e) { } try { $dbh->send('DROP TABLE `eyeosuser`'); } catch (PDOException $e) { } try { $dbh->send('DROP TABLE `eyeosgroup`'); } catch (PDOException $e) { } // Create tables with initial content $initSqlScript = file_get_contents('./extras/EyeosUMSQL/EyeosUMSQL.sql'); $dbh->send($initSqlScript); // Here we're using a test AuthConfiguration using FakeEyeosLoginModule, that allows to login // as root even without root user in the database so we can create... a real user root for // the rest of the tests :) // (the UM service is not accessible for writing by anyone, only root, members of "admin" or // "um" system groups) $originalConf = AuthConfiguration::getConfiguration(); AuthConfiguration::setConfiguration(new XMLAuthConfiguration('./tests/system/conf/services/UM/AuthConfigurations/init_tests.xml')); // We need a valid login context to create test principals $myUManager = UMManager::getInstance(); $subject = new Subject(); $loginContext = new LoginContext('root', $subject); $subject->getPrivateCredentials()->append(new FakeEyeosCredential('root', 'root')); $loginContext->login(); // Create "login" process $procManager = ProcManager::getInstance(); $myProcess = new Process('login'); $procManager->execute($myProcess); $procManager->setProcessLoginContext($myProcess->getPid(), $loginContext); // Delete pre-existing users because we need to create users in a clean way, // to trigger any action that is supposed to take place on user creation // (folder creation, default configuration files, etc.) try { $john = $myUManager->getUserByName('john'); $myUManager->deletePrincipal($john); } catch (EyeNoSuchUserException $e) { } try { $root = $myUManager->getUserByName('root'); $myUManager->deletePrincipal($root); } catch (EyeNoSuchUserException $e) { } // Create root $group = $myUManager->getGroupByName('root'); $user = $myUManager->getNewUserInstance(); $user->setName('root'); $user->setPassword('root', true); $user->setPrimaryGroupId($group->getId()); $myUManager->createUser($user); // Create john $group = $myUManager->getGroupByName(SERVICE_UM_DEFAULTUSERSGROUP); $user = $myUManager->getNewUserInstance(); $user->setName('john'); $user->setPassword('john', true); $user->setPrimaryGroupId($group->getId()); $myUManager->createUser($user); // Now switch to a real authentication with root AuthConfiguration::setConfiguration($originalConf); $subject = new Subject(); $loginContext = new LoginContext('init', $subject); $subject->getPrivateCredentials()->append(new EyeosPasswordCredential('root', 'root')); $loginContext->login(); $procManager = ProcManager::getInstance(); $procManager->setProcessLoginContext($myProcess->getPid(), $loginContext); }
function __construct() { $this->tagManager = new PeopleTagManager(); $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); }
public function tearDown() { if (self::$ClassTearDownToRun) { $this->loginAsRoot(); try { UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('alice')); } catch (EyeNoSuchPrincipalException $e) { } try { UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('bob')); } catch (EyeNoSuchPrincipalException $e) { } try { UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('charlie')); } catch (EyeNoSuchPrincipalException $e) { } try { UMManager::getInstance()->deletePrincipal(UMManager::getGroupByName('wonderland')); } catch (EyeNoSuchPrincipalException $e) { } $conf = SharingManager::getConfiguration('SharingManager'); $providerClassName = (string) $conf->providerClassName[0]; if ($providerClassName == 'DefaultSQLiteShareInfoProvider') { if (is_file(USERS_PATH . '/' . $this->owner->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) { unlink(USERS_PATH . '/' . $this->owner->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db'); } if (is_file(USERS_PATH . '/' . $this->collaborator1->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) { unlink(USERS_PATH . '/' . $this->collaborator1->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db'); } if (is_file(USERS_PATH . '/' . $this->collaborator2->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) { unlink(USERS_PATH . '/' . $this->collaborator2->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db'); } if (is_file(USERS_PATH . '/' . $this->collaborator3->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) { unlink(USERS_PATH . '/' . $this->collaborator3->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db'); } } else { if ($providerClassName == 'DefaultMySQLShareInfoProvider') { require_once SERVICE_SHARING_SHARINGMANAGERS_PROVIDERS_PATH . '/DefaultMySQLShareInfoProvider.php'; $dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); $dao->send('TRUNCATE TABLE ' . DefaultMySQLShareInfoProvider::SHAREINFO_TABLE_NAME); $dao->send('TRUNCATE TABLE ShareableVirtualFilesHandler'); } } try { ProcManager::getInstance()->kill(ProcManager::getInstance()->getProcessByPid(self::$MyProcPid)); } catch (EyeProcException $e) { } ProcManager::getInstance()->setCurrentProcess(self::$InitProcessToRestore); } }
protected function getConnection() { if (!isset(self::$connection)) { $dbHandler = null; try { $dbHandler = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); $dbHandler->send('CREATE TABLE IF NOT EXISTS ' . $this->params[self::PARAM_TABLENAME] . ' (' . 'id INT NOT NULL AUTO_INCREMENT, ' . self::METADATA_FIELD_CLASS . ' VARCHAR(128) NOT NULL, ' . self::METADATA_FIELD_ID . ' VARCHAR(128) NOT NULL, ' . self::METADATA_FIELD_KEY . ' TEXT NOT NULL, ' . self::METADATA_FIELD_DATA . ' TEXT NOT NULL, ' . 'PRIMARY KEY (id) ) '); self::$connection = $dbHandler; } catch (Exception $e) { throw new EyeDBException('An error occured while getting connection to the database.', 0, $e); } } return self::$connection; }
* Copyright (C) 2007 - 2010 eyeos Team * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the * Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * version 3 along with this program in the file "LICENSE". If not, see * <http://www.gnu.org/licenses/agpl-3.0.txt>. * * See www.eyeos.org for more details. All requests should be sent to licensing@eyeos.org * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * eyeos" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices * must display the words "Powered by eyeos" and retain the original copyright notice. */ // you can use $user here, representing the eyeosAbstractUser in the system. $sqlQuery = "INSERT INTO `eyeosmetadata` (`id`, `className`, `object_id`, `name`, `data`) VALUES\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.desktop.widgets', 'a:7:{s:7:\"desktop\";a:4:{s:5:\"title\";s:7:\"Desktop\";s:9:\"installed\";s:5:\"false\";s:6:\"column\";s:1:\"1\";s:8:\"position\";s:1:\"1\";}s:5:\"files\";a:5:{s:5:\"title\";s:5:\"Files\";s:9:\"installed\";s:4:\"true\";s:6:\"column\";i:1;s:8:\"position\";i:0;s:9:\"minimized\";b:0;}s:6:\"groups\";a:5:{s:5:\"title\";s:9:\"My Groups\";s:9:\"installed\";s:4:\"true\";s:6:\"column\";i:1;s:8:\"position\";i:1;s:9:\"minimized\";b:0;}s:6:\"events\";a:6:{s:5:\"title\";s:6:\"Events\";s:9:\"installed\";s:4:\"true\";s:5:\"items\";s:1:\"5\";s:6:\"column\";i:3;s:8:\"position\";i:1;s:9:\"minimized\";b:0;}s:9:\"favorites\";a:5:{s:5:\"title\";s:22:\"Favorites Applications\";s:9:\"installed\";s:4:\"true\";s:6:\"column\";i:3;s:8:\"position\";i:0;s:9:\"minimized\";b:0;}s:5:\"notes\";a:5:{s:5:\"title\";s:5:\"Notes\";s:9:\"installed\";s:4:\"true\";s:6:\"column\";i:3;s:8:\"position\";i:2;s:9:\"minimized\";b:0;}i:1;a:3:{s:6:\"column\";i:1;s:8:\"position\";i:0;s:9:\"minimized\";b:0;}}'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.applications.installed', 'a:6:{s:10:\"calculator\";s:1:\"0\";s:4:\"mail\";s:1:\"0\";s:5:\"files\";s:1:\"0\";s:8:\"calendar\";s:1:\"0\";s:9:\"documents\";s:1:\"0\";s:7:\"notepad\";s:1:\"0\";}'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.applications.favorite', 'a:5:{s:10:\"calculator\";s:1:\"0\";s:5:\"files\";s:1:\"0\";s:8:\"calendar\";s:1:\"0\";s:9:\"documents\";s:1:\"0\";s:7:\"notepad\";s:1:\"0\";}'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.desktop.wallpaperId', 's:6:\"nature\";'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.language', 's:2:\"en\";'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.desktop.mode', 's:7:\"classic\";'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.desktop.dashboard.nbcolumns', 's:1:\"3\";'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.desktop.wallpaperMode', 's:5:\"image\";'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.desktop.backgroundColors', 'a:9:{s:7:\"#E6E6E6\";s:4:\"true\";s:7:\"#CCDADA\";s:5:\"false\";s:7:\"#A1C4E0\";s:5:\"false\";s:7:\"#A7AFC4\";s:5:\"false\";s:7:\"#999999\";s:5:\"false\";s:7:\"#6293BB\";s:5:\"false\";s:7:\"#679966\";s:5:\"false\";s:7:\"#787B9A\";s:5:\"false\";s:7:\"#6E829A\";s:5:\"false\";}'),\n(NULL, 'EyeosUser', '" . $user->getId() . "', 'eyeos.user.desktop.wallpaper', 's:50:\"sys:///extern/images/wallpapers/nature/default.jpg\";');"; $dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); $dao->send($sqlQuery);
function __construct() { $this->contactManager = new ContactManager(); $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); }
public static function configured() { $_this = StorageManager::getInstance(); $config = array(); foreach ($_this->_adapterConfig as $k => $v) { if (empty($v['description'])) { continue; } $config[$k] = $v['description']; } return $config; }
public function updateCalendarPreferences(ICalendarPrefs $calendarPrefs) { $dao = StorageManager::getInstance()->getHandler('SQL/EyeosDAO'); $calendarPrefs = $dao->update($calendarPrefs); unset($dao); }
function __construct() { $this->impressionsManager = new ImpressionsManager(); $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); }
public function retrieveCalendarPreferences($userId, $calendarId) { if (!is_string($userId) || $userId == '') { throw new EyeInvalidArgumentException('$userId must be a non-empty string.'); } if (!is_string($calendarId) || $calendarId == '') { throw new EyeInvalidArgumentException('$calendarId must be a non-empty string.'); } $dao = StorageManager::getInstance()->getHandler('SQL/EyeosDAO'); $calendarPrefs = new CalendarPrefs(); $calendarPrefs->setUserId($userId); $calendarPrefs->setCalendarId($calendarId); $calendarPrefs = $dao->search($calendarPrefs); unset($dao); if (count($calendarPrefs) === 0) { throw new EyeCalendarPrefsNotFoundException('Unknown calendar preferences with user ID "' . $userId . '" and calendar ID "' . $calendarId . '".'); } return current($calendarPrefs); }
/** * Wrapper around the singleton call to StorageManager::getInstance() * * Makes it easy to mock the adapter in tests. * * @return mixed */ public function storageManager() { return StorageManager::getInstance(); }
/** * StorageAdapter * * @param mixed $adapterName string of adapter configuration or array of settings * @param boolean $renewObject Creates a new instance of the given adapter in the configuration * @throws RuntimeException * @return Gaufrette object as configured by first argument */ public static function adapter($adapterName = null, $renewObject = false) { $_this = StorageManager::getInstance(); if (empty($adapterName)) { $adapterName = $_this->_activeAdapter; } $isConfigured = true; if (is_string($adapterName)) { if (!empty($_this->_adapterConfig[$adapterName])) { $adapter = $_this->_adapterConfig[$adapterName]; } else { throw new RuntimeException(__d('file_storage', 'Invalid Storage Adapter %s', $adapterName)); } if (!empty($_this->_adapterConfig[$adapterName]['object']) && $renewObject === false) { return $_this->_adapterConfig[$adapterName]['object']; } } if (is_array($adapterName)) { $adapter = $adapterName; $isConfigured = false; } $class = $adapter['adapterClass']; $Reflection = new ReflectionClass($class); $adapterObject = $Reflection->newInstanceArgs($adapter['adapterOptions']); $engineObject = new $adapter['class']($adapterObject); if ($isConfigured) { $_this->_adapterConfig[$adapterName]['object'] =& $engineObject; } return $engineObject; }
public function __construct() { $this->db = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); }
public function __construct() { $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); $this->dao->send('SET NAMES utf8'); }
protected function __construct() { $this->eyeosDAO = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); }
public function userDeleted(UMEvent $e) { self::$Logger->debug("User deleted! " . $e->getSource()->getId()); //self::$Logger->debug($e); $dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER); try { $sql = 'DELETE FROM `messages` WHERE `from` = \'' . $e->getSource()->getId() . '\''; $dao->send($sql); } catch (Exception $e) { self::$Logger->debug("Error trying to delete garbage of user in messages (from)"); self::$Logger->debug($e); } try { $sql = 'DELETE FROM `messages` WHERE `to` = \'' . $e->getSource()->getId() . '\''; $dao->send($sql); } catch (Exception $e) { self::$Logger->debug("Error trying to delete garbage of user in messages (to)"); self::$Logger->debug($e); } try { $sql = 'DELETE FROM `ShareableVirtualFilesHandler` WHERE `shareableObjectId` = \'' . $e->getSource()->getId() . '\''; $dao->send($sql); } catch (Exception $e) { self::$Logger->debug("Error trying to delete garbage of user in ShareableVirtualFilesHandler"); self::$Logger->debug($e); } }