/** * Override method because this app requires special rights * @see tine20/Setup/Setup_Initialize#_createInitialRights($_application) * * @todo make hard coded role name ('user role') configurable */ protected function _createInitialRights(Tinebase_Model_Application $_application) { parent::_createInitialRights($_application); $roles = Tinebase_Acl_Roles::getInstance(); $userRole = $roles->getRoleByName('user role'); $roles->addSingleRight($userRole->getId(), $_application->getId(), Crm_Acl_Rights::MANAGE_LEADS); }
/** * Override method: Tinebase needs additional initialisation * * @see tine20/Setup/Setup_Initialize#_initialize($_application) */ public function _initialize(Tinebase_Model_Application $_application, $_options = null) { $this->_initProcedures(); $this->_setupConfigOptions($_options); $this->_setupGroups(); Tinebase_Acl_Roles::getInstance()->createInitialRoles(); parent::_initialize($_application, $_options); }
/** * Override method: Setup needs additional initialisation * * @see tine20/Setup/Setup_Initialize#_initialize($_application) */ protected function _initialize(Tinebase_Model_Application $_application, $_options = null) { $initialAdminUserOptions = $this->_parseInitialAdminUserOptions($_options); if (Tinebase_User::getInstance() instanceof Tinebase_User_Interface_SyncAble) { Tinebase_User::syncUsers(array('syncContactData' => TRUE)); } $initialUserName = $initialAdminUserOptions['adminLoginName']; try { $initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialUserName); } catch (Tinebase_Exception_NotFound $tenf) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . ' Could not find initial admin account ' . $initialUserName . ' in user backend. Creating new one ...'); } Tinebase_User::createInitialAccounts($initialAdminUserOptions); $initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialUserName); } Tinebase_Core::set(Tinebase_Core::USER, $initialUser); parent::_initialize($_application, $_options); }
/** * install given application * * @param SimpleXMLElement $_xml * @param array | optional $_options * @return void * @throws Tinebase_Exception_Backend_Database */ protected function _installApplication(SimpleXMLElement $_xml, $_options = null) { if ($this->_backend === NULL) { throw new Tinebase_Exception_Backend_Database('Need configured and working database backend for install.'); } try { if (Setup_Core::isLogLevel(Zend_Log::INFO)) { Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Installing application: ' . $_xml->name); } $createdTables = array(); // traditional xml declaration if (isset($_xml->tables)) { foreach ($_xml->tables[0] as $tableXML) { $table = Setup_Backend_Schema_Table_Factory::factory('Xml', $tableXML); $this->_createTable($table); $createdTables[] = $table; } } else { $application = Setup_Core::getApplicationInstance($_xml->name, '', true); $models = $application->getModels(true); if (count($models) > 0) { // create tables using doctrine 2 Setup_SchemaTool::createSchema($_xml->name, $models); // adopt to old workflow foreach ($models as $model) { $modelConfiguration = $model::getConfiguration(); $createdTables[] = (object) array('name' => Tinebase_Helper::array_value('name', $modelConfiguration->getTable()), 'version' => $modelConfiguration->getVersion()); } } } $application = new Tinebase_Model_Application(array('name' => (string) $_xml->name, 'status' => $_xml->status ? (string) $_xml->status : Tinebase_Application::ENABLED, 'order' => $_xml->order ? (string) $_xml->order : 99, 'version' => (string) $_xml->version)); $application = Tinebase_Application::getInstance()->addApplication($application); // keep track of tables belonging to this application foreach ($createdTables as $table) { Tinebase_Application::getInstance()->addApplicationTable($application, (string) $table->name, (int) $table->version); } // insert default records if (isset($_xml->defaultRecords)) { foreach ($_xml->defaultRecords[0] as $record) { $this->_backend->execInsertStatement($record); } } // look for import definitions and put them into the db $this->createImportExportDefinitions($application); Setup_Initialize::initialize($application, $_options); } catch (Exception $e) { Tinebase_Exception::log($e, false); throw $e; } }
/** * Override method because this app requires special rights * @see tine20/Setup/Setup_Initialize#_createInitialRights($_application) * * @todo make hard coded role name ('user role') configurable */ protected function _createInitialRights(Tinebase_Model_Application $_application) { parent::_createInitialRights($_application); $roles = Tinebase_Acl_Roles::getInstance(); $userRole = $roles->getRoleByName('user role'); $roles->addSingleRight($userRole->getId(), $_application->getId(), Tinebase_Acl_Rights::CHECK_VERSION); $roles->addSingleRight($userRole->getId(), $_application->getId(), Tinebase_Acl_Rights::REPORT_BUGS); $roles->addSingleRight($userRole->getId(), $_application->getId(), Tinebase_Acl_Rights::MANAGE_OWN_STATE); }
/** * Override method because this app requires special rights * @see tine20/Setup/Setup_Initialize#_createInitialRights($_application) * */ protected function _createInitialRights(Tinebase_Model_Application $_application) { parent::_createInitialRights($_application); $groupsBackend = Tinebase_Group::factory(Tinebase_Group::SQL); $adminGroup = $groupsBackend->getDefaultAdminGroup(); // give anyone read rights to the internal addressbook // give Adminstrators group read/edit/admin rights to the internal addressbook Tinebase_Container::getInstance()->addGrants($this->_getInternalAddressbook(), Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE, '0', array(Tinebase_Model_Grants::GRANT_READ), TRUE); Tinebase_Container::getInstance()->addGrants($this->_getInternalAddressbook(), Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, $adminGroup, array(Tinebase_Model_Grants::GRANT_READ, Tinebase_Model_Grants::GRANT_EDIT, Tinebase_Model_Grants::GRANT_ADMIN), TRUE); }
/** * install given application * * @param SimpleXMLElement $_xml * @param array | optional $_options * @return void * @throws Tinebase_Exception_Backend_Database */ protected function _installApplication(SimpleXMLElement $_xml, $_options = null) { if ($this->_backend === NULL) { throw new Tinebase_Exception_Backend_Database('Need configured and working database backend for install.'); } try { if (Setup_Core::isLogLevel(Zend_Log::INFO)) { Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Installing application: ' . $_xml->name); } $createdTables = array(); if (isset($_xml->tables)) { foreach ($_xml->tables[0] as $tableXML) { $table = Setup_Backend_Schema_Table_Factory::factory('Xml', $tableXML); $currentTable = $table->name; if (Setup_Core::isLogLevel(Zend_Log::DEBUG)) { Setup_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Creating table: ' . $currentTable); } try { $this->_backend->createTable($table); } catch (Zend_Db_Statement_Exception $zdse) { throw new Tinebase_Exception_Backend_Database('Could not create table: ' . $zdse->getMessage()); } catch (Zend_Db_Adapter_Exception $zdae) { throw new Tinebase_Exception_Backend_Database('Could not create table: ' . $zdae->getMessage()); } $createdTables[] = $table; } } $application = new Tinebase_Model_Application(array('name' => (string) $_xml->name, 'status' => $_xml->status ? (string) $_xml->status : Tinebase_Application::ENABLED, 'order' => $_xml->order ? (string) $_xml->order : 99, 'version' => (string) $_xml->version)); $application = Tinebase_Application::getInstance()->addApplication($application); // keep track of tables belonging to this application foreach ($createdTables as $table) { Tinebase_Application::getInstance()->addApplicationTable($application, (string) $table->name, (int) $table->version); } // insert default records if (isset($_xml->defaultRecords)) { foreach ($_xml->defaultRecords[0] as $record) { $this->_backend->execInsertStatement($record); } } // look for import definitions and put them into the db $this->createImportExportDefinitions($application); Setup_Initialize::initialize($application, $_options); } catch (Exception $e) { Tinebase_Exception::log($e, false); throw $e; } }