/**
  * the singleton pattern
  *
  * @return Setup_Controller
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Setup_Controller();
     }
     return self::$_instance;
 }
 /**
  * all imports 
  *
  */
 public function import()
 {
     //@TODO move to admin module
     $this->_log->NOTICE(__METHOD__ . '::' . __LINE__ . ' starting egw import for Admin');
     if ($this->_config->admin->import_groups) {
         $this->importGroups();
     }
     if ($this->_config->admin->import_users) {
         $this->importAccounts();
     }
     if ($this->_config->admin->import_groupmembers) {
         $this->importGroupMembers();
     }
     // walk apps
     $apps = Setup_Controller::getInstance()->searchApplications();
     foreach ($apps['results'] as $app) {
         if ($app['install_status'] == 'uptodate' && $app['name'] != 'Admin' && $this->_config->{strtolower($app['name'])} && $this->_config->{strtolower($app['name'])}->enabled) {
             $config = $this->_config->{strtolower($app['name'])}->toArray();
             $class_name = $app['name'] . '_Setup_Import_Egw14';
             if (!class_exists($class_name)) {
                 $this->_log->ERR(__METHOD__ . '::' . __LINE__ . " no import for {$app['name']} available");
                 continue;
             }
             try {
                 $importer = new $class_name($this->_config->{strtolower($app['name'])}, $this->_log);
                 $importer->import();
             } catch (Exception $e) {
                 $this->_log->ERR(__METHOD__ . '::' . __LINE__ . " import for {$app['name']} failed " . $e->getMessage());
             }
         }
     }
 }
Пример #3
0
 /**
  * move ods export config to import export definitions
  * 
  * @return void
  */
 public function update_1()
 {
     // remove Tinebase_Config::ODSEXPORTCONFIG
     Tinebase_Config::getInstance()->deleteConfigForApplication('odsexportconfig', 'Timetracker');
     // get import export definitions and save them in db
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Timetracker'));
     $this->setApplicationVersion('Timetracker', '3.2');
 }
 /**
  * update to 7.4
  * 
  * - Add note field
  * - Update import / export definitions
  */
 public function update_3()
 {
     if ($this->getTableVersion('inventory_item') != 5) {
         $release6 = new Inventory_Setup_Update_Release6($this->_backend);
         $release6->update_4();
     }
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Inventory'));
     $this->setApplicationVersion('Inventory', '7.4');
 }
Пример #5
0
 /**
  * Returns registry data of setup
  * .
  * @see Tinebase_Application_Json_Abstract
  * 
  * @return mixed array 'variable name' => 'data'
  * 
  * @todo add 'titlePostfix'    => Tinebase_Config::getInstance()->getConfig(Tinebase_Config::PAGETITLEPOSTFIX, NULL, '')->value here?
  */
 public function getRegistryData()
 {
     // anonymous registry
     $registryData = array('configExists' => Setup_Core::configFileExists(), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20SETUP_CODENAME, 'packageString' => TINE20SETUP_PACKAGESTRING, 'releaseTime' => TINE20SETUP_RELEASETIME), 'authenticationData' => $this->loadAuthenticationData());
     // authenticated or non existent config
     if (!Setup_Core::configFileExists() || Setup_Core::isRegistered(Setup_Core::USER)) {
         $registryData = array_merge($registryData, $this->checkConfig());
         $registryData = array_merge($registryData, array('acceptedTermsVersion' => !empty($registryData['checkDB']) && $this->_controller->isInstalled('Tinebase') ? Setup_Controller::getInstance()->getAcceptedTerms() : 0, 'setupChecks' => $this->envCheck(), 'configData' => $this->loadConfig(), 'emailData' => !empty($registryData['checkDB']) && $this->_controller->isInstalled('Tinebase') ? $this->getEmailConfig() : array(), 'messengerData' => !empty($registryData['checkDB']) && $this->_controller->isInstalled('Tinebase') ? $this->getMessengerConfig() : array()));
     }
     // if setup user is logged in
     if (Setup_Core::isRegistered(Setup_Core::USER)) {
         $registryData += array('currentAccount' => Setup_Core::getUser());
     }
     return $registryData;
 }
 /**
  * testDownloadAttachment
  */
 public function testDownloadAttachment()
 {
     if (!Setup_Controller::getInstance()->isInstalled('Calendar')) {
         $this->markTestSkipped('Calendar not installed');
     }
     $event = new Calendar_Model_Event(array('summary' => 'Wakeup', 'dtstart' => '2009-03-25 06:00:00', 'dtend' => '2009-03-25 06:15:00'));
     $tempFile = $this->_getTempFile();
     $event->attachments = array(array('tempFile' => array('id' => $tempFile->getId())));
     $savedEvent = Calendar_Controller_Event::getInstance()->create($event);
     $this->assertTrue(isset($savedEvent->attachments) && count($savedEvent->attachments) === 1);
     // try to fetch attachment of event
     $node = $this->_getWebDAVTree()->getNodeForPath('/webdav/Calendar/records/Calendar_Model_Event/' . $savedEvent->getId() . '/' . $tempFile->name);
     $this->assertEquals('text/plain', $node->getContentType());
     $this->assertEquals(17, $node->getSize());
     return $savedEvent;
 }
 /**
  * download config as config file
  * 
  * @param array $data
  */
 public function downloadConfig($data)
 {
     if (!Setup_Core::configFileExists() || Setup_Core::isRegistered(Setup_Core::USER)) {
         $data = Zend_Json::decode($data, Zend_Json::TYPE_ARRAY);
         $tmpFile = tempnam(Tinebase_Core::getTempDir(), 'tine20_');
         Setup_Controller::getInstance()->writeConfigToFile($data, TRUE, $tmpFile);
         $configData = file_get_contents($tmpFile);
         unlink($tmpFile);
         header("Pragma: public");
         header("Cache-Control: max-age=0");
         header("Content-Disposition: attachment; filename=config.inc.php");
         header("Content-Description: PHP File");
         header("Content-type: text/plain");
         die($configData);
     }
 }
 /**
  * Update import / export definitions
  * Add note field
  */
 public function update_4()
 {
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Inventory'));
     $field = '<field>
                 <name>adt_info</name>
                 <type>text</type>
             </field>';
     $declaration = new Setup_Backend_Schema_Field_Xml($field);
     try {
         $this->_backend->addCol('inventory_item', $declaration);
     } catch (Zend_Db_Statement_Exception $zdse) {
         // already there
     }
     $this->setApplicationVersion('Inventory', '6.5');
     $this->setTableVersion('inventory_item', '5');
 }
 /**
  * update to 8.27
  *
  *  - update export definition
  */
 public function update_26()
 {
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Sales'));
     $this->setApplicationVersion('Sales', '8.27');
 }
 /**
  * update to 2.14
  * - accept terms and conditions
  */
 public function update_13()
 {
     // NOTE: this update can only be applied if user accepted terms
     Setup_Controller::getInstance()->saveAcceptedTerms(1);
     $this->setApplicationVersion('Tinebase', '2.14');
 }
 public function __construct()
 {
     parent::__construct();
 }
 /**
  * update from 3.0 -> 3.1
  * - add new xls export definition
  * 
  * @return void
  */
 public function update_0()
 {
     // get import export definitions and save them in db
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Crm'));
     $this->setApplicationVersion('Crm', '3.1');
 }
Пример #13
0
 /**
  * remove all credential cache records before $_date
  * 
  * @param Tinebase_DateTime|string $_date
  */
 public function clearCacheTable($_date = NULL)
 {
     $dateString = $_date instanceof Tinebase_DateTime ? $_date->format(Tinebase_Record_Abstract::ISO8601LONG) : $_date;
     $dateWhere = $dateString === NULL ? $this->_db->quoteInto('valid_until < ?', Tinebase_DateTime::now()->format(Tinebase_Record_Abstract::ISO8601LONG)) : $this->_db->quoteInto('creation_time < ?', $dateString);
     $where = array($dateWhere);
     if (Setup_Controller::getInstance()->isInstalled('Felamimail')) {
         // delete only records that are not related to email accounts
         $fmailIds = $this->_getFelamimailCredentialIds();
         if (!empty($fmailIds)) {
             $where[] = $this->_db->quoteInto('id NOT IN (?)', $fmailIds);
         }
     }
     $tableName = $this->getTablePrefix() . $this->getTableName();
     $this->_db->delete($tableName, $where);
 }
 /**
  * update to 7.1
  * 
  * @return void
  */
 public function update_0()
 {
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Admin'));
     $this->setApplicationVersion('Admin', '7.1');
 }
 /**
  * - use relations to save lead products
  * - remove old crm products tables
  * 
  * @return void
  */
 public function update_2()
 {
     if (Setup_Controller::getInstance()->isInstalled('Crm')) {
         // get linked products
         $select = $this->_db->select()->from(SQL_TABLE_PREFIX . 'metacrm_leads_products');
         $stmt = $this->_db->query($select);
         $queryResult = $stmt->fetchAll();
         //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . print_r($queryResult, TRUE));
         // insert values into relations table
         $relationsBackend = new Tinebase_Relation_Backend_Sql();
         foreach ($queryResult as $row) {
             $relation = new Tinebase_Model_Relation(array('own_model' => 'Crm_Model_Lead', 'own_backend' => 'Sql', 'own_id' => $row['lead_id'], 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'type' => 'PRODUCT', 'related_model' => 'Sales_Model_Product', 'related_backend' => 'Sql', 'related_id' => $row['product_id'], 'remark' => Zend_Json::encode(array('description' => $row['product_desc'], 'price' => $row['product_price'], 'quantity' => 1))));
             try {
                 $relationsBackend->addRelation($relation);
             } catch (Zend_Db_Statement_Exception $zdse) {
                 Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Found duplicate, increasing quantity (' . $zdse->getMessage() . ')');
                 // increase quantity
                 $updateRelation = $relationsBackend->search(new Tinebase_Model_RelationFilter(array(array('field' => 'own_id', 'operator' => 'equals', 'value' => $relation->own_id), array('field' => 'related_id', 'operator' => 'equals', 'value' => $relation->related_id), array('field' => 'related_model', 'operator' => 'equals', 'value' => 'Sales_Model_Product'))))->getFirstRecord();
                 $remark = $updateRelation->remark;
                 $remark['quantity'] = $remark['quantity'] + 1;
                 $updateRelation->remark = $remark;
                 //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($updateRelation->toArray(), TRUE));
                 $relationsBackend->updateRelation($updateRelation);
             }
         }
         // drop table metacrm_leadsproducts and metacrm_products
         $this->dropTable('metacrm_leads_products');
         $this->dropTable('metacrm_products');
     }
     $this->setApplicationVersion('Sales', '2.3');
 }
Пример #16
0
 /**
  * renders the login dialog
  *
  * @todo perhaps we could add a config option to display the update dialog if it is set
  */
 public function login()
 {
     // redirect to REDIRECTURL if set
     $redirectUrl = Tinebase_Config::getInstance()->getConfig(Tinebase_Config::REDIRECTURL, NULL, '')->value;
     if ($redirectUrl !== '' && Tinebase_Config::getInstance()->getConfig(Tinebase_Config::REDIRECTALWAYS, NULL, FALSE)->value) {
         header('Location: ' . $redirectUrl);
         return;
     }
     // check if setup/update required
     $setupController = Setup_Controller::getInstance();
     $applications = Tinebase_Application::getInstance()->getApplications();
     foreach ($applications as $application) {
         if ($application->status == 'enabled' && $setupController->updateNeeded($application)) {
             $this->setupRequired();
         }
     }
     $this->_renderMainScreen();
     /**
      * old code used to display user registration
      * @todo must be reworked
      * 
     
     $view = new Zend_View();
     $view->setScriptPath('Tinebase/views');
     
     header('Content-Type: text/html; charset=utf-8');
     
     // check if registration is active
     if(isset(Tinebase_Core::getConfig()->login)) {
         $registrationConfig = Tinebase_Core::getConfig()->registration;
         $view->userRegistration = (isset($registrationConfig->active)) ? $registrationConfig->active : '';
     } else {
         $view->userRegistration = 0;
     }        
     
     echo $view->render('jsclient.php');
     */
 }
 public function importAll()
 {
     // walk apps
     $apps = Setup_Controller::getInstance()->searchApplications();
     $importedApps = array();
     $failedApps = array();
     $importerToRun = array();
     foreach ($apps['results'] as $app) {
         if ($app['install_status'] == 'uptodate' && ($this->_config->allApps || $this->_config->{strtolower($app['name'])} && $this->_config->{strtolower($app['name'])}->enabled)) {
             $class_name = $app['name'] . '_Setup_Import_' . $this->_classPostFix;
             if (!class_exists($class_name)) {
                 Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " no import for {$app['name']} available");
                 continue;
             }
             try {
                 /**
                  * @var Setup_Import_Abstract $importer
                  */
                 $importer = new $class_name($this->_config);
                 if (0 === count(array_diff($importer->getRequiredApps(), $importedApps))) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' about to import app ' . $app['name']);
                     }
                     $importer->import();
                     $importedApps[strtolower($app['name'])] = strtolower($app['name']);
                 } else {
                     $importerToRun[strtolower($app['name'])] = $importer;
                 }
             } catch (Exception $e) {
                 Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " import for {$app['name']} failed " . $e);
             }
         }
     }
     // cycle the importer until all of them met their requirements and could be executed
     // fail if we get stuck there
     $didSomething = true;
     while (count($importerToRun) > 0 && true === $didSomething) {
         $didSomething = false;
         foreach ($importerToRun as $app => $importer) {
             /**
              * @var Setup_Import_Abstract $importer
              */
             // check if requirements are met
             if (0 === count(array_diff($importer->getRequiredApps(), $importedApps))) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                     Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' about to import app ' . $app);
                 }
                 try {
                     $importer->import();
                 } catch (Exception $e) {
                     Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " import for {$app} failed " . $e);
                     // we didnt do anything, so dont set variables, but still we want to be removed and not executed again
                     $failedApps[$app] = $app;
                     continue;
                 }
                 $importedApps[$app] = $app;
                 $didSomething = true;
             }
         }
         $importerToRun = array_diff_key($importerToRun, $importedApps, $failedApps);
     }
     if (count($importerToRun) > 0) {
         Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . " import for " . join(', ', array_keys($importerToRun)) . " could not be run due to unmet requirements");
     }
 }
 /**
  * _installAllApps helper
  */
 protected function _installAllApps()
 {
     $installableApplications = Setup_Controller::getInstance()->getInstallableApplications();
     $installableApplications = array_keys($installableApplications);
     $this->_json->installApplications($installableApplications, array('adminLoginName' => Tinebase_Core::get('testconfig')->username, 'adminPassword' => Tinebase_Core::get('testconfig')->password));
 }
 /**
  * Test length name for table name and column name (Oracle Database limitation)
  * Table name is less than 30 at least since Oracle 7
  * 
  * @see 0007452: use json encoded array for saving of policy settings
  */
 public function testSetupXML()
 {
     $applications = Tinebase_Application::getInstance()->getApplications();
     foreach ($applications->name as $applicationName) {
         // skip ActiveSync
         // @todo remove that when #7452 is resolved
         if ($applicationName === 'ActiveSync') {
             continue;
         }
         $xml = Setup_Controller::getInstance()->getSetupXml($applicationName);
         if (isset($xml->tables)) {
             foreach ($xml->tables[0] as $tableXML) {
                 $table = Setup_Backend_Schema_Table_Factory::factory('Xml', $tableXML);
                 $currentTable = $table->name;
                 $this->assertLessThan(30, strlen($currentTable), $applicationName . " -> " . $table->name . "  (" . strlen($currentTable) . ")");
                 foreach ($table->fields as $field) {
                     $this->assertLessThan(31, strlen($field->name), $applicationName . " -> " . $table->name . "  (" . strlen($field->name) . ")");
                 }
             }
         }
     }
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->_uit = Setup_Controller::getInstance();
 }
 /**
  * updates import export definitions
  * adds a label property to hold a humanreadable text if not exists
  */
 public function update_4()
 {
     if (!$this->_backend->columnExists('label', 'importexport_definition')) {
         $this->_addImportExportDefinitionLabel();
     }
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Addressbook'));
     $this->setApplicationVersion('Tinebase', '8.5');
 }
Пример #22
0
 /**
  * set config options (accounts/authentication/email/...)
  * 
  * @param array $_options
  */
 protected function _setupConfigOptions($_options)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Saving config options (accounts/authentication/email/...)');
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_options, TRUE));
     }
     $defaults = empty($_options['authenticationData']) ? Setup_Controller::getInstance()->loadAuthenticationData() : $_options['authenticationData'];
     $defaultGroupNames = $this->_parseDefaultGroupNameOptions($_options);
     $defaults['accounts'][Tinebase_User::getConfiguredBackend()] = array_merge($defaults['accounts'][Tinebase_User::getConfiguredBackend()], $defaultGroupNames);
     $emailConfigKeys = Setup_Controller::getInstance()->getEmailConfigKeys();
     $configsToSet = array_merge($emailConfigKeys, array('authentication', 'accounts', 'redirectSettings', 'acceptedTermsVersion'));
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($configsToSet, TRUE));
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($defaults, TRUE));
     }
     $optionsToSave = array();
     foreach ($configsToSet as $group) {
         if (isset($_options[$group])) {
             $parsedOptions = is_string($_options[$group]) ? Setup_Frontend_Cli::parseConfigValue($_options[$group]) : $_options[$group];
             switch ($group) {
                 case 'authentication':
                 case 'accounts':
                     $backend = isset($parsedOptions['backend']) ? ucfirst($parsedOptions['backend']) : Tinebase_User::SQL;
                     $optionsToSave[$group][$backend] = isset($parsedOptions[$backend]) ? $parsedOptions[$backend] : $parsedOptions;
                     $optionsToSave[$group]['backend'] = $backend;
                     break;
                 default:
                     $optionsToSave[$group] = $parsedOptions;
             }
         } else {
             if (isset($defaults[$group])) {
                 $optionsToSave[$group] = $defaults[$group];
             }
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($optionsToSave, TRUE));
     }
     Setup_Controller::getInstance()->saveEmailConfig($optionsToSave);
     Setup_Controller::getInstance()->saveAuthentication($optionsToSave);
 }
 /**
  * update to 5.5
  * - update import export defs
  *
  * @return void
  */
 public function update_4()
 {
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Addressbook'));
     $this->setApplicationVersion('Addressbook', '5.5');
 }
Пример #24
0
 /**
  * create admin user / activate existing user / allow to reset password
  * 
  * @param Zend_Console_Getopt $_opts
  */
 protected function _createAdminUser(Zend_Console_Getopt $_opts)
 {
     if (!Setup_Controller::getInstance()->isInstalled('Tinebase')) {
         die('Install Tinebase first.');
     }
     echo "Please enter a username. If the user already exists, he is reactivated and you can reset the password.\n";
     $username = Tinebase_Server_Cli::promptInput('Username');
     $tomorrow = Tinebase_DateTime::now()->addDay(1);
     try {
         $user = Tinebase_User::getInstance()->getFullUserByLoginName($username);
         echo "User {$username} already exists.\n";
         $user->accountExpires = $tomorrow;
         $user->accountStatus = Tinebase_Model_User::ACCOUNT_STATUS_ENABLED;
         Tinebase_User::getInstance()->updateUser($user);
         echo "Activated admin user '{$username}' (expires tomorrow).\n";
         $resetPw = Tinebase_Server_Cli::promptInput('Do you want to reset the password (default: "no", "y" or "yes" for reset)?');
         if ($resetPw === 'y' or $resetPw === 'yes') {
             $password = $this->_promptPassword();
             Tinebase_User::getInstance()->setPassword($user, $password);
             echo "User password has been reset.\n";
         }
         // check admin group membership
         $adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
         $memberships = Tinebase_Group::getInstance()->getGroupMemberships($user);
         if (!in_array($adminGroup->getId(), $memberships)) {
             try {
                 Tinebase_Group::getInstance()->addGroupMember($adminGroup, $user);
                 echo "Added user to default admin group\n";
             } catch (Zend_Ldap_Exception $zle) {
                 echo "Could not add user to default admin group: " . $zle->getMessage();
             }
         }
     } catch (Tinebase_Exception_NotFound $tenf) {
         if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP) {
             die('It is not possible to create a new user with LDAP user backend here.');
         }
         // create new admin user that expires tomorrow
         $password = $this->_promptPassword();
         Tinebase_User::createInitialAccounts(array('adminLoginName' => $username, 'adminPassword' => $password, 'expires' => $tomorrow));
         echo "Created new admin user '{$username}' that expires tomorrow.\n";
     }
 }
 /**
  * - update import / export
  */
 public function update_4()
 {
     Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Calendar'));
     $this->setTableVersion('cal_events', 7);
     $this->setApplicationVersion('Calendar', '8.5');
 }
 /**
  * Search server plugins from applications configuration
  *
  * @return array
  */
 protected static function _searchServerPlugins()
 {
     $cache = Tinebase_Core::getCache();
     if ($cache && ($plugins = $cache->load(self::TINEBASE_SERVER_PLUGINS))) {
         return $plugins;
     }
     if (!Setup_Controller::getInstance()->isInstalled('Tinebase')) {
         // get apps by scanning directory
         $applications = array();
         $d = dir(dirname(__DIR__));
         while (false !== ($entry = $d->read())) {
             if ($entry[0] == '.') {
                 continue;
             }
             if (ctype_upper($entry[0]) && is_dir($d->path . DIRECTORY_SEPARATOR . $entry)) {
                 $applications[] = $entry;
             }
         }
         $d->close();
     } else {
         // get list of available applications
         $applications = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED)->name;
     }
     // get list of plugins
     $plugins = array();
     foreach ($applications as $application) {
         $config = $application . '_Config';
         try {
             if (@class_exists($config)) {
                 $reflectedClass = new ReflectionClass($config);
                 if ($reflectedClass->isSubclassOf('Tinebase_Config_Abstract')) {
                     $plugins = array_merge($plugins, call_user_func(array($config, 'getServerPlugins')));
                 }
             }
         } catch (Exception $e) {
             Tinebase_Exception::log($e);
         }
     }
     // sort plugins by priority
     asort($plugins);
     $plugins = array_keys($plugins);
     if ($cache) {
         $cache->save($plugins, self::TINEBASE_SERVER_PLUGINS);
     }
     return $plugins;
 }
 /**
  * test project relation filter
  */
 public function testProjectRelationFilter()
 {
     if (!Setup_Controller::getInstance()->isInstalled('Projects')) {
         $this->markTestSkipped('Projects not installed.');
     }
     $contact = $this->_uit->saveContact($this->_getContactData());
     $project = $this->_getProjectData($contact);
     $projectJson = new Projects_Frontend_Json();
     $newProject = $projectJson->saveProject($project);
     $this->_testProjectRelationFilter($contact, 'definedBy', $newProject);
     $this->_testProjectRelationFilter($contact, 'in', $newProject);
     $this->_testProjectRelationFilter($contact, 'equals', $newProject);
 }
 protected function _restore(Zend_Console_Getopt $_opts)
 {
     $options = $this->_parseRemainingArgs($_opts->getRemainingArgs());
     Setup_Controller::getInstance()->restore($options);
 }
 /**
  * renders the login dialog
  *
  * @todo perhaps we could add a config option to display the update dialog if it is set
  */
 public function login()
 {
     // redirect to REDIRECTURL if set
     $redirectUrl = Tinebase_Config::getInstance()->get(Tinebase_Config::REDIRECTURL, '');
     if ($redirectUrl !== '' && Tinebase_Config::getInstance()->get(Tinebase_Config::REDIRECTALWAYS, FALSE)) {
         header('Location: ' . $redirectUrl);
         return;
     }
     // check if setup/update required
     $setupController = Setup_Controller::getInstance();
     $applications = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED);
     foreach ($applications as $application) {
         if ($setupController->updateNeeded($application)) {
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                 Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " " . $application->name . ' needs an update');
             }
             $this->setupRequired();
         }
     }
     $this->_renderMainScreen();
     /**
      * old code used to display user registration
      * @todo must be reworked
      * 
     
     $view = new Zend_View();
     $view->setScriptPath('Tinebase/views');
     
     header('Content-Type: text/html; charset=utf-8');
     
     // check if registration is active
     if(isset(Tinebase_Core::getConfig()->login)) {
         $registrationConfig = Tinebase_Core::getConfig()->registration;
         $view->userRegistration = (isset($registrationConfig->active)) ? $registrationConfig->active : '';
     } else {
         $view->userRegistration = 0;
     }        
     
     echo $view->render('jsclient.php');
     */
 }
 /**
  * _installAllApps helper
  */
 protected function _installAllApps()
 {
     $installableApplications = Setup_Controller::getInstance()->getInstallableApplications();
     $installableApplications = array_keys($installableApplications);
     $testCredentials = Setup_TestServer::getInstance()->getTestCredentials();
     $this->_json->installApplications($installableApplications, array('adminLoginName' => $testCredentials['username'], 'adminPassword' => $testCredentials['password']));
 }