Ejemplo n.º 1
1
 /**
  * Attempt to create a user, given a user email and a password
  */
 function create($email, $password, $idSession)
 {
     $user = new User();
     $userRow = $user->findByEmail($email);
     $config = new Config();
     $configRow = $config->fetchAll()->current();
     // Does this user exist?
     if ($userRow) {
         // Check the password
         if ($userRow->password == md5($password)) {
             // Delete a possibly existing session. Safer.
             $db = Zend_Db_Table::getDefaultAdapter();
             $db->query("DELETE FROM Session WHERE idSession = '{$idSession}'");
             // Insert in Session, for 2 hours
             $sessionRow = $this->createRow();
             $sessionRow->idSession = $idSession;
             $sessionRow->id_user = $userRow->id;
             $this->tempsLimite = date("U") + 7200;
             $sessionRow->roles = $userRow->roles;
             $sessionRow->save();
             return true;
         }
         return false;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 function indexAction()
 {
     $config_table = new Config();
     $modules_table = new Modules("core");
     $request = new Bolts_Request($this->getRequest());
     if ($request->has('modid')) {
         $modid = $request->modid;
     } else {
         $modid = 'bolts';
     }
     if ($this->_request->isPost()) {
         //we are posting
         $config_params = $this->_request->getParams();
         foreach ($config_params as $ckey => $value) {
             $data = array('value' => $value);
             $config_table->update($data, "ckey = '" . $ckey . "' and module='" . $modid . "'");
         }
         $this->view->success = $this->_T('Configuration Updated.');
         $config_table->cache();
         $params = array();
         $this->_Bolts_plugin->doAction($this->_mca . '_post_save', $params);
         // ACTION HOOK
     }
     $config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid));
     if (count($config) > 0) {
         $config = $config->toArray();
         sort($config);
         $this->view->config = $config;
     }
     $modules = $modules_table->getEnabledModules();
     sort($modules);
     $this->view->modules = $modules;
     $this->view->current = $modid;
     $this->view->modid = $modid;
 }
Ejemplo n.º 3
0
 function configAction()
 {
     // When the form is submitted
     $form_mess = "";
     if (isset($_POST['confName'])) {
         $form_mess = $this->updateConfig($_POST, $this->db_v1, $this->view, $this->session);
         $this->config_v1 = GetConfig($this->db_v1);
         // Check whether the logo file has been transmitted
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination('images/');
         $adapter->addValidator('IsImage', false);
         if ($adapter->receive()) {
             $name = $adapter->getFileName('logo_file');
             //récupérer le nom du fichier sans avoir tout le chemin
             $name = basename($name);
             $this->db_v1->execRequete("UPDATE Config SET logo_file='{$name}'");
         }
         $config = new Config();
         $this->config = $config->fetchAll()->current();
         $this->config->putInView($this->view);
         $registry = Zend_registry::getInstance();
         $registry->set("Config", $this->config);
     }
     $this->view->config_message = $form_mess;
     $this->instantiateConfigVars($this->config_v1, $this->view);
     $this->view->setFile("content", "config.xml");
     $this->view->setFile("form_config", "form_config.xml");
     $form_mess = "";
     $this->view->messages = $form_mess;
     // N.B: the config values ar eput in the views by the Myreview controller
     echo $this->view->render("layout");
 }
 function init()
 {
     // Same as the parent
     parent::init();
     // Get the utilitary objects from the registry
     $registry = Zend_registry::getInstance();
     // Instantiate a Config object with all config values. Put it in the registry
     // (can be accessed by models) and in the controller.
     $config = new Config();
     $this->config = $config->fetchAll()->current();
     $this->config->putInView($this->view);
     $registry->set("Config", $this->config);
     /// The following is for backward compatibility with V1. To be removed eventually.
     // Initialize the $db_v1 object, using the Version DB interface.
     $db_config = $this->zmax_context->config->db->params;
     $this->db_v1 = new BD($db_config->username, $db_config->password, $db_config->dbname, $db_config->host);
     // Load the translations for the myreview namespace
     $this->zmax_context->texts->addTranslation($this->zmax_context->db, $this->zmax_context->locale, array("namespaces" => array('author', 'reviewer', 'admin', 'mail', 'attendee')));
     // Load the configuration of MyReview. Put the values in the view
     $this->config_v1 = GetConfig($this->db_v1);
     // Get the codes of the application (V1).
     $this->codes = new Codes("Codes.xml");
     // Keep the lang in the controller
     $this->lang = $this->zmax_context->locale->getLanguage();
     $this->view->conf_name = $this->config_v1['confName'];
     $this->view->page_title = "";
     // Check whether the user is connected
     $this->texts = $this->zmax_context->texts;
     $this->session = $this->user = null;
     if (!$this->checkSession()) {
         $this->view->user_status = $this->texts->user_not_connected;
         // Propose the links to create and account or log in
         $this->view->account_mngt = $this->texts->def->create_account;
         $this->view->account_mngt_link = "createaccount";
         $this->view->login_logout = $this->texts->def->log_in;
         $this->view->login_logout_link = "login";
     } else {
         $logoutLink = $this->view->base_url . "/index/logout";
         $this->view->user_status = $this->zmax_context->texts->you_are_currently_connected . " " . $this->user->first_name . " <b>" . $this->user->last_name . "</b>.";
         // Propose the links to edit account and account or log out
         $this->view->account_mngt = $this->texts->author->edit_account_header;
         $this->view->account_mngt_link = "editaccount";
         $this->view->login_logout = $this->texts->def->log_out;
         $this->view->login_logout_link = "logout";
     }
     // Put the user and the session in the registry
     $registry->set("session", $this->session);
     $registry->set("user", $this->user);
 }
Ejemplo n.º 5
0
	function indexAction()
	{
		$config_table = new Config();
		// $modules_table = new Modules('core');
		$modules_table = new Modules('modules');
		$modules_table_core = new Modules('core');
		$request = new RivetyCore_Request($this->getRequest());
		$modid = $request->has('modid') ? $request->modid : 'default';
		if ($this->_request->isPost())
		{
			$config_params = $this->_request->getParams();
			foreach ($config_params as $ckey => $value)
			{
				$data = array('value' => $value);
				$config_table->update($data, "ckey = '" . $ckey . "' and module = '" . $modid . "'");
			}
			$this->view->success = $this->_T('Configuration Updated.');
			$config_table->cache();
			$params = array();
			$this->_rivety_plugin->doAction($this->_mca . '_post_save', $params); // ACTION HOOK
		}
		$config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid));
		if (count($config) > 0)
		{
			$config = $config->toArray();
			sort($config);
			$this->view->config = $config;
		}
		$modules = $modules_table_core->getEnabledModules();
		sort($modules);
		$this->view->modules = $modules;
		$this->view->current = $modid;
		$this->view->modid = $modid;
		if ($modid == 'default') $mod_cfg = $modules_table_core->parseIni($modid);
		else $mod_cfg = $modules_table->parseIni($modid);
		$this->view->module_title = $mod_cfg['general']['name'];
		$this->view->breadcrumbs = array('Module Config' => null);
	}
Ejemplo n.º 6
0
 /** Check the infos about a paper before inserting
  */
 function checkRequest($connectedUser, $file, $fileRequired, &$texts)
 {
     $configTble = new Config();
     $config = $configTble->fetchAll()->current();
     $this->_messages = array();
     // Some tests...
     if (empty($this->title)) {
         $this->_messages[] = $texts->author->missing_title;
     }
     // Check that the topic is not null or blanck
     if (empty($this->topic)) {
         $this->_messages[] = $texts->author->missing_topic;
     }
     // Check the abstract. Loop on the abstract structure, and check that
     // each abstract section is filled if it is mandatory.
     $abstractStruct = new AbstractSection();
     $abstractStruct->select()->order('position ASC');
     $abstractStructRows = $abstractStruct->fetchAll();
     $countWords = 0;
     foreach ($abstractStructRows as $abstractStructRow) {
         if (!isset($this->_abstract[$abstractStructRow->id])) {
             // This section should exist
             $this->_messages[] = $texts->author->missing_abstract_section;
         } else {
             $this->_abstract[$abstractStructRow->id]->content = trim($this->_abstract[$abstractStructRow->id]->content);
             if ($abstractStructRow->mandatory == "Y" and empty($this->_abstract[$abstractStructRow->id]->content)) {
                 $this->_messages[] = $texts->author->abstract_section_empty . ": " . "{author." . $abstractStructRow->section_name . "}";
             }
             // Count the number of words
             $countWords += str_word_count($this->_abstract[$abstractStructRow->id]->content);
         }
     }
     // echo "Nb words = $countWords<br/>";
     if ($countWords > $config->max_abstract_size) {
         $this->_messages[] = $texts->author->abstract_too_long . " ({$countWords} > {$config->max_abstract_size})";
     }
     // Check the authors
     $found = false;
     $nbAuthors = $this->nbAuthors();
     if ($nbAuthors == 0) {
         $this->_messages[] = $texts->author->missing_authors;
     }
     $connUserPresent = false;
     $mailAuthors = array();
     for ($i = 0; $i < $nbAuthors; $i++) {
         $author = $this->getAuthor($i);
         // Do not check the city and zip code for simple authors
         $messages = $author->checkValues($texts, array("address", "city", "zip_code"));
         foreach ($messages as $message) {
             $iplus = $i + 1;
             $this->_messages[] = "(" . $texts->author->author . " {$iplus}) - " . $message;
         }
         $mailAuthors[$author->email] = 1;
         // Check whether this is the connected user
         if ($author->email == $connectedUser->email) {
             $connUserPresent = true;
         }
     }
     // Check that the same author is not reported twice: compare the number of email
     // to the number of authors (who can do better? Find a nice PHP function)
     if (count($mailAuthors) != count($this->_authors)) {
         $this->_messages[] = $texts->author->duplicate_authors;
     }
     // Test: the connected user must be part of the author list
     if (!$connUserPresent) {
         $this->_messages[] = $texts->author->user_mandatory;
     }
     // Test: at least one contact author
     if ($this->_contactAuthor < 0) {
         $this->_messages[] = $texts->author->missing_contact_author;
     }
     // Test: the file is provided (if required)
     if ($fileRequired) {
         if (!is_uploaded_file($file['tmp_name'])) {
             $this->_messages[] = $this->uploadError($file, $texts);
         } else {
             // Check the PDF format (always in lowercase)
             $ext = substr($file['name'], strrpos($file['name'], '.') + 1);
             if (strToLower($ext) != "pdf") {
                 $this->_messages[] = $texts->author->invalid_format . " (extension:{$ext}, format:" . $paper['format'] . ")";
             }
         }
     }
     // There should be no message
     if (count($this->_messages) > 0) {
         return false;
     } else {
         return true;
     }
 }