/** * create new user session * * @param string $_loginname * @param string $_password * @param string $_ipAddress * @param string $_clientIdString * @param string $securitycode the security code(captcha) * @return bool */ public function login($_loginname, $_password, $_ipAddress, $_clientIdString = NULL, $securitycode = NULL) { if (isset(Tinebase_Core::getConfig()->captcha->count) && Tinebase_Core::getConfig()->captcha->count != 0) { if ($_SESSION['tinebase']['code'] != $securitycode) { return FALSE; } } $authResult = Tinebase_Auth::getInstance()->authenticate($_loginname, $_password); $accessLog = new Tinebase_Model_AccessLog(array('sessionid' => session_id(), 'ip' => $_ipAddress, 'li' => Tinebase_DateTime::now()->get(Tinebase_Record_Abstract::ISO8601LONG), 'result' => $authResult->getCode(), 'clienttype' => $_clientIdString), TRUE); $user = NULL; if ($accessLog->result == Tinebase_Auth::SUCCESS) { $user = $this->_getLoginUser($authResult->getIdentity(), $accessLog); if ($user !== NULL) { $this->_checkUserStatus($user, $accessLog); } } if ($accessLog->result === Tinebase_Auth::SUCCESS && $user !== NULL && $user->accountStatus === Tinebase_User::STATUS_ENABLED) { $this->_initUser($user, $accessLog, $_password); $result = true; } else { $this->_loginFailed($_loginname, $accessLog); $_SESSION['tinebase']['code'] = 'code'; $result = false; } Tinebase_AccessLog::getInstance()->create($accessLog); return $result; }
/** * factory function to return a selected phone backend class * * @param string $_type * @return Phone_Backend_Interface * @throws Phone_Exception_InvalidArgument * @throws Phone_Exception_NotFound */ public static function factory($_type) { switch ($_type) { case self::ASTERISK: if (!isset(self::$_backends[$_type])) { if (isset(Tinebase_Core::getConfig()->asterisk)) { $asteriskConfig = Tinebase_Core::getConfig()->asterisk; $url = $asteriskConfig->managerbaseurl; $username = $asteriskConfig->managerusername; $password = $asteriskConfig->managerpassword; } else { throw new Phone_Exception_NotFound('No settings found for asterisk backend in config file!'); } self::$_backends[$_type] = Phone_Backend_Asterisk::getInstance($url, $username, $password); } $instance = self::$_backends[$_type]; break; case self::CALLHISTORY: if (!isset(self::$_backends[$_type])) { self::$_backends[$_type] = new Phone_Backend_Snom_Callhistory(); } $instance = self::$_backends[$_type]; break; case self::SNOM_WEBSERVER: if (!isset(self::$_backends[$_type])) { self::$_backends[$_type] = new Phone_Backend_Snom_Webserver(); } $instance = self::$_backends[$_type]; break; default: throw new Phone_Exception_InvalidArgument('Unsupported phone backend (' . $_type . ').'); } return $instance; }
public static function getThemeConfig() { $extJS = 'ext-all.css'; $themePath = 'tine20'; $favicon = 'images/favicon.ico'; $title = 'Tine 2.0'; $themeConfig = Tinebase_Core::getConfig()->theme; if ($themeConfig instanceof Tinebase_Config_Struct && $themeConfig->active) { if ($themeConfig->path) { $themePath = $themeConfig->path; //is useBlueAsBase set? if ($themeConfig->useBlueAsBase) { $extJS = 'ext-all-notheme.css'; } //is there a customized favicon? if (file_exists('themes/' . $themePath . '/resources/images/favicon.ico')) { $favicon = 'themes/' . $themePath . '/resources/images/favicon.ico'; } } } //Do we have a branding favicon? $favicon = Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_FAVICON) ? Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_FAVICON) : $favicon; //Do we have a branding title? $title = Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_TITLE) ? Tinebase_Config::getInstance()->get(Tinebase_Config::BRANDING_TITLE) : $title; $result = array('favicon' => $favicon, 'extJs' => '<link rel="stylesheet" type="text/css" href="library/ExtJS/resources/css/' . $extJS . '" />', 'themePath' => '<link rel="stylesheet" type="text/css" href="themes/' . $themePath . '/resources/css/' . $themePath . '.css" />', 'title' => $title); return $result; }
/** * constructor * * @see http://framework.zend.com/manual/en/zend.queue.adapters.html for config options */ private function __construct() { if (isset(Tinebase_Core::getConfig()->actionqueue)) { $options = Tinebase_Core::getConfig()->actionqueue->toArray(); $adapter = array_key_exists('adapter', $options) ? $options['adapter'] : 'Db'; unset($options['adapter']); $options['name'] = array_key_exists('name', $options) ? $options['name'] : 'tine20actionqueue'; switch ($adapter) { case 'Redis': $options['adapterNamespace'] = 'Rediska_Zend_Queue_Adapter'; $options['driverOptions'] = array_key_exists('driverOptions', $options) ? $options['driverOptions'] : array('namespace' => 'Application_'); break; case 'Db': // use default db settings if empty $options['driverOptions'] = array_key_exists('driverOptions', $options) ? $options['driverOptions'] : Tinebase_Core::getConfig()->database->toArray(); if (!array_key_exists('type', $options['driverOptions'])) { $options['driverOptions']['type'] = array_key_exists('adapter', $options['driverOptions']) ? $options['driverOptions']['adapter'] : 'pdo_mysql'; } break; } try { $this->_queue = new Zend_Queue($adapter, $options); } catch (Zend_Db_Adapter_Exception $zdae) { throw new Tinebase_Exception_Backend_Database('Could not connect to queue DB: ' . $zdae->getMessage()); } } }
/** * the constructor * * @param Zend_Db_Adapter_Abstract $_db (optional) * @param array $_options (optional) */ public function __construct($_dbAdapter = NULL, $_options = array()) { parent::__construct($_dbAdapter, $_options); // set default adapter $config = Tinebase_Core::getConfig(); $adapter = $config->{Tinebase_Auth_CredentialCache_Adapter_Config::CONFIG_KEY} ? 'Config' : 'Cookie'; $this->setCacheAdapter($adapter); }
/** * the constructor */ public function __construct() { $this->_fileObjectBackend = new Tinebase_Tree_FileObject(); $this->_treeNodeBackend = new Tinebase_Tree_Node(); if (!Tinebase_Core::isFilesystemAvailable()) { throw new Tinebase_Exception_Backend('No base path (filesdir) configured or path not writeable'); } $this->_basePath = Tinebase_Core::getConfig()->filesdir; }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { if (empty(Tinebase_Core::getConfig()->filesdir)) { $this->markTestSkipped('filesystem base path not found'); } Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb()); Tinebase_FileSystem::getInstance()->initializeApplication(Tinebase_Application::getInstance()->getApplicationByName('Addressbook')); clearstatcache(); }
/** * update from 2.0 -> 2.1 * - get crm default settings from config and write them to db * * @return void */ public function update_0() { $config = Tinebase_Core::getConfig(); if (isset($config->crm)) { $defaults = array('leadstate_id' => isset($config->crm->defaultstate) ? Tinebase_Core::getConfig()->crm->defaultstate : 1, 'leadtype_id' => isset($config->crm->defaulttype) ? Tinebase_Core::getConfig()->crm->defaulttype : 1, 'leadsource_id' => isset($config->crm->defaultsource) ? Tinebase_Core::getConfig()->crm->defaultsource : 1); Tinebase_Config::getInstance()->setConfigForApplication(Tinebase_Config::APPDEFAULTS, Zend_Json::encode($defaults), 'Crm'); } $this->setApplicationVersion('Crm', '2.1'); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { if (empty(Tinebase_Core::getConfig()->filesdir)) { $this->markTestSkipped('filesystem base path not found'); } Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb()); $this->_basePath = 'tine20:///' . Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId() . '/internal/phpunit'; Tinebase_FileSystem::getInstance()->initializeApplication(Tinebase_Application::getInstance()->getApplicationByName('Tinebase')); clearstatcache(); }
/** * the constructor */ public function __construct() { $this->_currentAccount = Tinebase_Core::getUser(); $this->_fileObjectBackend = new Tinebase_Tree_FileObject(); $this->_treeNodeBackend = new Tinebase_Tree_Node(); if (empty(Tinebase_Core::getConfig()->filesdir) || !is_writeable(Tinebase_Core::getConfig()->filesdir)) { throw new Tinebase_Exception_Backend('No base path (filesdir) configured or path not writeable'); } $this->_basePath = Tinebase_Core::getConfig()->filesdir; }
/** * the constructor * * don't use the constructor. use the singleton */ private function __construct() { $this->_applicationName = 'Billing'; $this->_backend = new Billing_Backend_Bank(); $this->_modelName = 'Billing_Model_Bank'; $this->_currentAccount = Tinebase_Core::getUser(); $this->_purgeRecords = FALSE; $this->_doContainerACLChecks = FALSE; $this->_config = isset(Tinebase_Core::getConfig()->billing) ? Tinebase_Core::getConfig()->billing : new Zend_Config(array()); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { if (!extension_loaded('redis')) { $this->markTestSkipped('redis extension not found'); } if (!isset(Tinebase_Core::getConfig()->actionqueue) || !isset(Tinebase_Core::getConfig()->actionqueue->backend) || ucfirst(strtolower(Tinebase_Core::getConfig()->actionqueue->backend)) != Tinebase_ActionQueue::BACKEND_REDIS) { $this->markTestSkipped('no redis actionqueue configured'); } Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb()); }
/** * the singleton pattern * * @return Felamimail_Controller_Cache_Folder */ public static function getInstance() { if (self::$_instance === NULL) { $adapter = Tinebase_Core::getConfig()->messagecache; $adapter = empty($adapter) ? 'sql' : $adapter; $classname = 'Felamimail_Controller_Cache_' . ucfirst($adapter) . '_Folder'; self::$_instance = $classname::getInstance(); } return self::$_instance; }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { if (empty(Tinebase_Core::getConfig()->filesdir)) { $this->markTestSkipped('filesystem base path not found'); } Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb()); $this->_controller = new Tinebase_FileSystem(); $this->_basePath = '/' . Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId() . '/folders/' . Tinebase_Model_Container::TYPE_SHARED; $this->_controller->initializeApplication(Tinebase_Application::getInstance()->getApplicationByName('Tinebase')); }
public function tearDown() { // kill daemon $daemonpid = file_get_contents($this->_daemonPid); $killCommand = 'kill ' . $daemonpid; exec($killCommand); unlink($this->_daemonLog); unlink($this->_configIni); // restore actionqueueconfig Tinebase_Core::getConfig()->actionqueue = $this->_actionQueueConfigBackup; }
/** * getDefaultKey() - get default cache key * @return string * @throws Tinebase_Exception_NotFound */ public function getDefaultKey() { $result = NULL; $config = Tinebase_Core::getConfig(); if ($config->{self::CONFIG_KEY}) { $result = $config->{self::CONFIG_KEY}; } else { throw new Tinebase_Exception_NotFound('No credential cache key found in config!'); } return $result; }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb()); $cfg = Tinebase_Core::getConfig(); if (!$cfg->sipgate) { $this->markTestSkipped('No config to access the sipgate api is available.'); } $this->_testConfig = $cfg->sipgate->toArray(); $this->_testConfig['description'] = 'unittest'; $this->_testConfig['accounttype'] = 'plus'; }
/** * temporaray function to get a default container] * * @param string $_referingApplication * @return Tinebase_Model_Container container * * @todo replace this by Tinebase_Container::getDefaultContainer */ public function getDefaultContainer($_referingApplication = 'tasks') { $taskConfig = Tinebase_Core::getConfig()->tasks; $configString = 'defaultcontainer_' . (empty($_referingApplication) ? 'tasks' : $_referingApplication); if (isset($taskConfig->{$configString})) { $defaultContainer = Tinebase_Container::getInstance()->getContainerById((int) $taskConfig->{$configString}); } else { $defaultContainer = Tinebase_Container::getInstance()->getDefaultContainer($this->_currentAccount->accountId, 'Webconference'); } return $defaultContainer; }
/** * the constructor * * don't use the constructor. use the singleton */ private function __construct() { $this->_applicationName = 'Billing'; $this->_backend = new Billing_Backend_StockFlow(); $this->_modelName = 'Billing_Model_StockFlow'; $this->_articleSupplyController = Billing_Controller_ArticleSupply::getInstance(); $this->_currentAccount = Tinebase_Core::getUser(); $this->_purgeRecords = FALSE; $this->_doContainerACLChecks = FALSE; $this->_config = isset(Tinebase_Core::getConfig()->billing) ? Tinebase_Core::getConfig()->billing : new Zend_Config(array()); }
/** * factory function to return a selected phone backend class * * @param string $_type * @return Sipgate_Backend_Interface * @throws Sipgate_Exception_InvalidArgument * @throws Sipgate_Exception_NotFound */ public static function factory() { if (isset(Tinebase_Core::getConfig()->sipgate)) { $sipgateConfig = Tinebase_Core::getConfig()->sipgate; $username = $sipgateConfig->api_username; $password = $sipgateConfig->api_password; $url = $sipgateConfig->api_url; } else { throw new Sipgate_Exception_Backend('No settings found for sipgate backend in config file!'); } $instance = Sipgate_Backend_Api::getInstance($username, $password, $url); return $instance; }
/** * constructor */ public function __construct(array $_options) { $_options['baseDn'] = $_options['machineDn']; $_options['plugins'][] = new Tinebase_User_Plugin_Samba(Tinebase_Core::getConfig()->samba->toArray()); $this->_options = $_options; if (isset($this->_options['minMachineId'])) { $this->_options['minUserId'] = $_options['minMachineId']; } if (isset($this->_options['maxMachineId'])) { $this->_options['maxUserId'] = $_options['maxMachineId']; } $this->_ldap = new Tinebase_User_Ldap($this->_options); }
/** * constructs Admin_Frontend_Json */ public function __construct() { // manage samba sam? if (isset(Tinebase_Core::getConfig()->samba)) { $this->_manageSAM = Tinebase_Core::getConfig()->samba->get('manageSAM', false); } // manage email user settings if (Tinebase_EmailUser::manages(Tinebase_Config::IMAP)) { $this->_manageImapEmailUser = TRUE; } if (Tinebase_EmailUser::manages(Tinebase_Config::SMTP)) { $this->_manageSmtpEmailUser = TRUE; } }
/** * the constructor * * don't use the constructor. use the singleton */ private function __construct() { $this->_applicationName = 'Sipgate'; $this->_modelName = 'Sipgate_Model_Account'; $this->_backend = new Sipgate_Backend_Account(); $cfg = Tinebase_Core::getConfig(); if ($cfg->shared_credential_key) { $this->_credential_key = $cfg->shared_credential_key; if (strlen($this->_credential_key) != 24) { throw new Sipgate_Exception_ResolveCredentials('The shared_credential_key must have a length of 24. Your key has a length of ' . strlen($this->_credential_key)); } } else { throw new Sipgate_Exception_ResolveCredentials('You must configure a shared_credential_key in config.inc.php'); } }
/** * the constructor * * don't use the constructor. use the singleton */ private function __construct() { // get config if (isset(Tinebase_Core::getConfig()->registration)) { $this->_config = Tinebase_Core::getConfig()->registration; } else { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' no config for registration found! '); } } // create table objects and get db adapter $this->_registrationsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'registrations')); $this->_invitationsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'registration_invitation')); $this->_db = Tinebase_Core::getDb(); }
public static function suite() { $suite = new PHPUnit_Framework_TestSuite('Tine 2.0 Setup All Backend Tests'); $backendAdapter = Tinebase_Core::getConfig()->database->adapter; if ($backendAdapter === 'pdo_mysql') { // MySQL only tests $suite->addTestSuite('Setup_Backend_MysqlTest'); $suite->addTestSuite('Setup_Backend_Schema_AllTests'); } else { if ($backendAdapter === 'pdo_pgsql') { // Postgresql only tests $suite->addTestSuite('Setup_Backend_PgsqlTest'); } } return $suite; }
/** * Takes the config from config.inc.php and creates an account with the associated lines * @param Zend_Console_Getopt $_opts */ public function take_config($_opts) { // resolve arguments $args = $this->_parseArgs($_opts, array()); $type = in_array('shared', $args['other']) ? 'shared' : 'private'; if (@isset(Tinebase_Core::getConfig()->sipgate)) { $conf = Tinebase_Core::getConfig()->sipgate; if (@isset($conf->api_username) && @isset($conf->api_password)) { echo 'Validate configuration from config.inc.php...' . PHP_EOL; $accountData = array('data' => array('accounttype' => @isset($conf->api_url) && $conf->api_url != 'https://samurai.sipgate.net/RPC2' ? 'team' : 'plus', 'description' => 'Created by update', 'username' => $conf->api_username, 'password' => $conf->api_password, 'type' => $type)); if (Sipgate_Controller_Account::getInstance()->validateAccount($accountData)) { echo 'Data from config.inc.php could be validated, creating account...' . PHP_EOL; try { $account = Sipgate_Controller_Account::getInstance()->create(new Sipgate_Model_Account($accountData['data'])); } catch (Tinebase_Exception_Duplicate $e) { echo 'An account with this credentials exists already! Did you use this script twice?' . PHP_EOL; die; } if ($account) { echo 'Account created. Trying to synchronize the lines..' . PHP_EOL; if (Sipgate_Controller_Line::getInstance()->syncAccount($account->getId())) { $opts = new Zend_Console_Getopt('abp:'); $args = array('initial', 'verbose'); if ($type == 'shared') { $args[] = 'shared'; } $opts->setArguments($args); echo 'Lines have been synchronized. Now syncing connections from the last two months, day per day. This could take some time.' . PHP_EOL; $this->sync_connections($opts); echo 'Connections has been synchronized. Now assign users to the line(s) to allow them to use the line(s)' . PHP_EOL; echo 'READY!' . PHP_EOL; } else { echo 'The lines for the account could not be created!' . PHP_EOL; } } else { echo 'The account could not be created!' . PHP_EOL; } } else { echo 'The credentials found in config.inc.php could not be validated!' . PHP_EOL; } } else { echo 'No username or password could be found in config.php.inc!' . PHP_EOL; } } else { echo 'No sipgate config could be found in config.php.inc!' . PHP_EOL; } }
/** * the constructor * * don't use the constructor. use the singleton */ private function __construct() { if (!Tinebase_Core::getConfig()->samba) { throw new Admin_Exception('No samba settings defined in config.'); } if (Tinebase_User::getConfiguredBackend() != Tinebase_User::LDAP) { throw new Admin_Exception('Works only with LDAP user backend.'); } $ldapOptions = Tinebase_User::getBackendConfiguration(); $sambaOptions = Tinebase_Core::getConfig()->samba->toArray(); $options = array_merge($ldapOptions, $sambaOptions); $options['machineGroup'] = isset($options['machineGroup']) ? $options['machineGroup'] : 'Domain Computers'; $this->_options = $options; $this->_applicationName = 'Admin'; // we might want to add a factory here when we support multiple backends $this->_backend = new Admin_Backend_SambaMachine($this->_options); }
/** * wrapper around Zend_Db_Table_Abstract::fetchAll * * @param string|array $_where OPTIONAL * @param string $_order OPTIONAL * @param string $_dir OPTIONAL * @param int $_count OPTIONAL * @param int $_offset OPTIONAL * @throws Tinebase_Exception_InvalidArgument if $_dir is not ASC or DESC * @return array the row results per the Zend_Db_Adapter fetch mode. */ public function fetchAll($_where = NULL, $_order = NULL, $_dir = 'ASC', $_count = NULL, $_offset = NULL) { if ($_dir != 'ASC' && $_dir != 'DESC') { throw new Tinebase_Exception_InvalidArgument('$_dir can be only ASC or DESC'); } $order = NULL; if ($_order !== NULL) { $order = $_order . ' ' . $_dir; } // possibility to tracing queries if (Tinebase_Core::isLogLevel(Zend_Log::TRACE) && ($config = Tinebase_Core::getConfig()->logger)) { if ($config->traceQueryOrigins) { $e = new Exception(); Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . "\n" . "BACKTRACE: \n" . $e->getTraceAsString() . "\n" . "SQL QUERY: \n" . $this->select()->assemble()); } } $rowSet = parent::fetchAll($_where, $order, $_count, $_offset); return $rowSet; }
/** * testCleanupCache */ public function testCleanupCache() { $this->_instance->cleanupCache(Zend_Cache::CLEANING_MODE_ALL); $cache = Tinebase_Core::getCache(); $oldLifetime = $cache->getOption('lifetime'); $cache->setLifetime(1); $cacheId = Tinebase_Helper::convertCacheId('testCleanupCache'); $cache->save('value', $cacheId); sleep(3); // cleanup with CLEANING_MODE_OLD $this->_instance->cleanupCache(); $cache->setLifetime($oldLifetime); $this->assertFalse($cache->load($cacheId)); // check for cache files $config = Tinebase_Core::getConfig(); if ($config->caching && $config->caching->backend == 'File' && $config->caching->path) { $cacheFile = $this->_lookForCacheFile($config->caching->path); $this->assertEquals(NULL, $cacheFile, 'found cache file: ' . $cacheFile); } }
/** * constructor */ private function __construct() { $options = null; $backend = self::BACKEND_DIRECT; if (isset(Tinebase_Core::getConfig()->actionqueue) && Tinebase_Core::getConfig()->actionqueue->active) { $options = Tinebase_Core::getConfig()->actionqueue->toArray(); $backend = isset($options['backend']) || array_key_exists('backend', $options) ? ucfirst(strtolower($options['backend'])) : $backend; unset($options['backend']); } $className = 'Tinebase_ActionQueue_Backend_' . $backend; if (!class_exists($className)) { if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) { Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " Queue class name {$className} not found. Falling back to direct execution."); } $className = 'Tinebase_ActionQueue_Backend_Direct'; } $this->_queue = new $className($options); if (!$this->_queue instanceof Tinebase_ActionQueue_Backend_Interface) { throw new Tinebase_Exception_UnexpectedValue('backend does not implement Tinebase_ActionQueue_Backend_Interface'); } }