/**
  * This function deletes the xml configuration file for the default parameters of the moderator
  * @param string $moderator_prefix
  */
 public static function deleteXML($moderator_prefix)
 {
     $file_name = $moderator_prefix . self::MODERATOR_SUFFIX;
     $config_dir = ProjectConfiguration::guessRootDir() . self::MODERATOR_CONFIG_DIR;
     $absolute_file_path = $config_dir . $file_name;
     unlink($absolute_file_path);
 }
Exemplo n.º 2
0
 public static function editUploadParameters()
 {
     $dom_doc = new DOMDocument();
     $dom_doc->load(ProjectConfiguration::guessRootDir() . '/config/upload.parameters.xml');
     $dom_parameters = $dom_doc->documentElement;
     $new_node = $dom_parameters->getElementsByTagName('value')->item(0);
     $new_node->nodeValue = date('m/d/Y');
     $dom_doc->importNode($new_node, true);
     $to_remove = $dom_parameters->getElementsByTagName('value')->item(0);
     $dom_parameters->replaceChild($new_node, $to_remove);
     $dom_doc->save(ProjectConfiguration::guessRootDir() . '/config/upload.parameters.xml');
 }
Exemplo n.º 3
0
 protected function _initRequiredDirs()
 {
     $phpunit_dir = ProjectConfiguration::guessRootDir() . '/test/phpunit';
     $this->_createDir($phpunit_dir);
     $this->_createDir($phpunit_dir . '/units');
     $this->_createDir($phpunit_dir . '/functionals');
     $this->_createDir($phpunit_dir . '/models');
     $this->_createDir($phpunit_dir . '/fixtures');
     $this->_createDir($phpunit_dir . '/fixtures/units');
     $this->_createDir($phpunit_dir . '/fixtures/functionals');
     $this->_createDir($phpunit_dir . '/fixtures/models');
 }
 protected function _initRequiredDirs()
 {
     if (!$this->_isAllowed('required_dirs')) {
         return;
     }
     $phpunit_dir = ProjectConfiguration::guessRootDir() . '/test/phpunit';
     $this->_createDir($phpunit_dir);
     $this->_createDir($phpunit_dir . '/unit');
     $this->_createDir($phpunit_dir . '/functional');
     $this->_createDir($phpunit_dir . '/unit/model');
     $this->_createDir($phpunit_dir . '/fixtures');
     $this->_createDir($phpunit_dir . '/fixtures/unit');
     $this->_createDir($phpunit_dir . '/fixtures/functional');
     $this->_createDir($phpunit_dir . '/fixtures/unit/model');
     $this->_createDir($phpunit_dir . '/fixtures/snapshots');
     $this->_createDir($phpunit_dir . '/fixtures/snapshots/cache');
 }
Exemplo n.º 5
0
 public static function exportToSql($last_upload)
 {
     $structure = Doctrine::getTable('Structure')->createQuery('a')->fetchOne();
     $fileName = $structure->getName() . '&' . $structure->getAddress()->getStreet() . '&' . $structure->getAddress()->getAddressCity()->getPostalCode() . '&' . $structure->getAddress()->getAddressCity()->getName() . '&' . $structure->getAddress()->getAddressCity()->getAddressCountry()->getName();
     $fileName = Upload::rewrite(utf8_decode($fileName));
     $fp = fopen(ProjectConfiguration::guessRootDir() . '/web/uploads/stats/' . $fileName . '.sql', 'a+');
     $usersStatistics = Doctrine_Query::create()->select('*')->from('UserArchive')->execute();
     foreach ($usersStatistics as $stat) {
         $stringToPrint = utf8_decode("INSERT INTO user_archive VALUES (NULL,`" . $stat->getAge() . "`,`" . $stat->getCreatedAt() . "`,`" . $stat->getCityName() . "`,`" . $stat->getCountry() . "`,`" . $stat->getGender() . "`,`" . $stat->getSeg() . "`,`" . $stat->getAwareness() . "`,`" . $stat->getCategory() . "`,`") . $fileName . "`);";
         fwrite($fp, $stringToPrint . "\n");
     }
     $usesStatistics = Doctrine_Query::create()->select('*')->from('ImputationArchive i')->where('i.imputation_date BETWEEN ? AND ?', array(date('Y-m-d', strtotime($last_upload)), date('Y-m-d')))->execute();
     foreach ($usesStatistics as $stat) {
         $stringToPrint = utf8_decode("INSERT INTO imputation_archive VALUES (NULL,`" . $stat->getImputationDate() . "`,`" . $stat->getImputationType() . "`,`" . $stat->getDuration() . "`,`" . $stat->getDesignation() . "`,`" . $stat->getPrice() . "`,`" . $stat->getMethodOfPayment() . "`,`" . $stat->getBuildingDesignation() . "`,`" . $stat->getRoomDesignation() . "`,`" . $stat->getComputerName() . "`,`" . $stat->getComputerTypeOfConnexion() . "`,`" . $stat->getUserArchiveId() . "`);");
         fwrite($fp, $stringToPrint . "\n");
     }
     fclose($fp);
 }
Exemplo n.º 6
0
 /**
  * This method override sfContext::initialize. It is charged to initialize the context
  * of the Management application based on the initialization of the Kernel.
  * @param sfApplicationConfiguration $configuration
  */
 public function initialize(sfApplicationConfiguration $configuration)
 {
     //Initialize the kernel:
     Kernel::initialize(ProjectConfiguration::guessRootDir() . '/apps/');
     //Build the dependencies table:
     Kernel::buildDependenciesTable();
     //Build the installed modules:
     $modules = Kernel::buildInstalledModules();
     //Get the currently installed cultures:
     parent::set('InstalledCultures', Kernel::getInstalledCultures($configuration));
     //Check if everything is ok,
     //and make the status as an attribute of the calling application context:
     parent::set('KernelStatus', Kernel::check());
     parent::set('DependenciesErrors', Kernel::getUnsatisfiedDependencies());
     //Create the instance of the Kernel, containing only the installed modules list and the dependencies table,
     //and make it as an attribute of the calling application context:
     parent::set('Kernel', Kernel::createInstance());
     parent::set('Modules', Module::checkAll(parent::get('Kernel')->getDependenciesTable(), $modules));
     //Launch the 'classical' intialization process: the sfContext::initialize() method:
     parent::initialize($configuration);
 }
Exemplo n.º 7
0
//F20603-T04
$instance->addLogIf(true, null);
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/error.log'), false, 'TEST OF: KernelInstance::addLogIf method');
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/info.log'), false, 'TEST OF: KernelInstance::addLogIf method');
//F20603-T04
$instance->addLogIf(false, array());
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/error.log'), false, 'TEST OF: KernelInstance::addLogIf method');
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/info.log'), false, 'TEST OF: KernelInstance::addLogIf method');
/*-----------------------------------------------------------F20604-----------------------------------------------------------*/
//F20604-T01
$instance->addLogChoice(1, array('info' => 'test_info', 'error' => 'test_error'));
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/error.log'), true, 'TEST OF: KernelInstance::addLogChoice method');
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/info.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
unlink(ProjectConfiguration::guessRootDir() . '/log/error.log');
//F20604-T02
$instance->addLogChoice(3, array('info' => 'test_info', 'error' => 'test_error'));
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/error.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/info.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
//F20604-T03
$instance->addLogChoice(-1, array('info' => 'test_info', 'error' => 'test_error'));
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/error.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/info.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
//F20604-T04
$instance->addLogChoice(2, array());
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/error.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/info.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
//F20604-T05
$instance->addLogChoice(2, null);
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/error.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
$t->is(file_exists(ProjectConfiguration::guessRootDir() . '/log/info.log'), false, 'TEST OF: KernelInstance::addLogChoice method');
Exemplo n.º 8
0
 /**
  * Adds a log specified by its level and its message. If the level doesn't exist yet, a new file will be created.
  * @param string $log_level
  * @param string $log_as_string
  */
 public function addLog($log_level, $log_as_string)
 {
     try {
         //Check arguments:
         if (is_null($log_level) || is_null($log_as_string) || empty($log_level) || empty($log_as_string)) {
             return false;
         }
         //Get the current date and time and create the string representing the absolute file path:
         $date = date('D, d-m-Y, H:i:s > ');
         $file_name = ProjectConfiguration::guessRootDir() . '/log/' . $log_level . '.log';
         //Check if the file path is not null:
         if (is_null($file_name)) {
             return false;
         }
         //Open this file:
         $file = fopen($file_name, 'a+');
         //Check if the file descriptor is not null:
         if (is_null($file)) {
             return false;
         }
         //Write in the file and finally close it:
         fputs($file, "\n" . $date . $log_as_string);
         fclose($file);
         return true;
     } catch (sfFileException $e) {
         //If an sfFileException has been catched, just return false:
         return false;
     }
 }
 /**
  *
  */
 public static function editYaml()
 {
     //Get the new parameters of the database:
     $params = self::getBddParams();
     //Loads the current databases.yml file:
     $databases = sfYaml::load(ProjectConfiguration::guessRootDir() . '/config/databases.yml');
     //Edit the php variable that corresponds to this file:
     $databases['all']['doctrine']['param']['dsn'] = self::formatDbms($params['dbms']) . ':host=' . $params['ip_address'] . ';dbname=' . $params['db_name'] . ';port=' . $params['srv_port'];
     $databases['all']['doctrine']['param']['username'] = $params['db_user_name'];
     $databases['all']['doctrine']['param']['password'] = $params['db_password'];
     //Dump this php variable to a yaml string:
     $text = sfYaml::dump($databases);
     //Write this string into the yaml file:
     $db_yaml = fopen(ProjectConfiguration::guessRootDir() . '/config/databases.yml', 'w+');
     fwrite($db_yaml, $text);
     fclose($db_yaml);
 }
Exemplo n.º 10
0
 protected function processForm(sfWebRequest $request, sfForm $form, $new = false)
 {
     $req_param = $request->getParameter($form->getName());
     if (!isset($req_param['login']['is_moderator'])) {
         $req_param['login']['is_moderator'] = 'on';
     }
     if (!isset($req_param['login']['locked']) || is_null($req_param['login']['locked'])) {
         $req_param['login']['locked'] = 0;
     }
     $form->bind($req_param);
     if ($form->isValid()) {
         if (ModeratorManagement::checkForDoubloon($req_param['login']['login'])) {
             $moderator = $form->save();
             if ($new) {
                 ModeratorManagement::createXML($moderator->getLogin()->getLogin());
             }
             firstBootLib::editSecurity();
             $installPath = ProjectConfiguration::guessRootDir() . '/web/index.php';
             rename($installPath, 'install.php');
             $indexPath = ProjectConfiguration::guessRootDir() . '/web/genepi.php';
             rename($indexPath, 'index.php');
             firstBootLib::editUploadParameters();
             header("Location: " . "http://" . $_SERVER["SERVER_NAME"]);
             exit;
         } else {
             $this->getUser()->setFlash('error', 'This login already exists, please choose another.');
         }
     }
 }
Exemplo n.º 11
0
 /**
  *This method parses the 'apps/mgmt/modules' directory and determine which modules aren't installed yet.
  *@return an array which contains the installables modules. 
  */
 public static function getInstallables()
 {
     $installables_modules = array();
     //Get the directory:
     $path = ProjectConfiguration::guessRootDir() . '/apps/mgmt/modules';
     $module_dir = dir($path);
     //Parses the elements of the directory:
     while (false !== ($elem = $module_dir->read())) {
         //If the element is a directory, is not installed yet and is not hided,
         if (is_dir($path . '/' . $elem) && !self::isInstalled($elem) && !($elem[0] == '.')) {
             //Add it to the list to return:
             $installables_modules[] = $elem;
         }
     }
     return $installables_modules;
 }