/** * Generates the adapter * * @param array $db The DB connection * @param string|Zend_Locale $locale OPTIONAL Locale/Language to set, identical with locale identifier, * see Zend_Locale for more information * @param array $options OPTIONAL Options to set */ public function __construct($db, $locale = null, array $options = array()) { // If $db is null: nothing to do. if ($db == null) { return; } // Keep the db reference for possible use $this->db = $db; // Check whether the view system is PHPLIB. In yes we // add all the translations as entities in the view object // Get the utilitary objects from the registry $registry = Zend_registry::getInstance(); $zmax_context = $registry->get("zmax_context"); $config = $zmax_context->config; // By default we take the zmax context view, unless it is explicitly given if (isset($options['view'])) { $this->phplib_view = $options['view']; } else { if ($config->view->zmax_view_system == "phplib") { $this->phplib_view = $zmax_context->view; } } // Now call the parent constructor // Adding this option is necessary starting with Zend 1.6, to prevent // an ugly message $options['disableNotices'] = 'true'; parent::__construct($db, $locale, $options); }
function __construct($mailType, $subject, $scriptPath, $template = null) { // Keep the context objects $this->_db = Zend_Db_Table::getDefaultAdapter(); // get the config from the registry $registry = Zend_registry::getInstance(); $this->_config = $registry->get("Config"); // Get the Zmax context for translations $zmax_context = $registry->get("zmax_context"); $this->_texts = $zmax_context->texts; $this->_mailType = $mailType; $this->_from = $this->_config['chairMail']; $this->_subject = $subject; $this->_copyToChair = false; // Special case of a mail sent to the chair. // NOTE: the chair is assumed to be in User. Is it really safe ? if ($mailType == self::PC_CHAIR) { $this->setTo($this->_config->chairMail); $this->_mailType = self::SOME_USER; } // Default format: text $this->_mailFormat = self::FORMAT_TEXT; // Create a template engine to instantiate template mails $this->_view = new Zmax_View_Phplib(); $this->_view->setPath($scriptPath); // Put configuration information in the view (always useful) $this->_config->putInView($this->_view); // Record the template if ($template != null) { $this->setTemplate($template); } // Put config information in the view: always useful $this->_config->putInView($this->_view); }
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); }
/** * Sets the CAS parameters for authentication * * @return void */ public function __construct($cas_url, $request) { $this->request = $request; // Get the utilitary objects from the registry $registry = Zend_registry::getInstance(); // Get the Zmax context $zmax_context = $registry->get("zmax_context"); // Store the URL of the CAS server and the base URL $this->cas_url = $cas_url; $this->base_url = $zmax_context->config->app->base_url; // Compute the URL of the current action $this->controller = $request->getControllerName(); $this->module = $request->getModuleName(); if (empty($this->module)) { $this->module = "default"; } }
function __construct($scriptPath) { // Keep the context objects $this->_db = Zend_Db_Table::getDefaultAdapter(); // get the config from the registry $registry = Zend_registry::getInstance(); $this->_config = $registry->get("Config"); // Get the Zmax context for translations $zmax_context = $registry->get("zmax_context"); $this->_texts = $zmax_context->texts; // Create a template engine to instantiate template mails $this->_view = new Zmax_View_Phplib(); $this->_view->setPath($scriptPath); // Put configuration information in the view (always useful) $this->_config->putInView($this->_view); // Files are always created in the upload area $this->_filePath = $zmax_context->config->app->upload_path; }
function ReportAssignment(&$tpl, &$members, &$papers, &$choice, $db) { // get the config from the registry $registry = Zend_registry::getInstance(); $config = $registry->get("Config"); $config->putInView($tpl); $tpl->set_var("MAXIMAL_WEIGHT", $config['nbReviewersPerItem'] * 4); $tpl->set_var("SESSION_ID", session_id()); // This function might potentially reach the memory // limit of PHP. Check that this does not happen if (function_exists("memory_get_usage")) { // The following instruction can raise the memory limit ini_set("memory_limit", "100M"); ini_set("max_execution_time", "300"); // 5 mns } // Header of the array reset($members); $userTbl = new User(); foreach ($members as $id) { $user = $userTbl->find($id)->current(); $user->putInView($tpl); $tpl->append("MEMBERS", "MEMBER_DETAIL"); } // Display the array reset($papers); while (list($iPaper, $idPaper) = each($papers)) { $weightPaper = 0; reset($members); while (list($iRef, $email) = each($members)) { $paper = GetPaper($idPaper, $db, "object"); InstanciatePaperVars($paper, $tpl, $db); if ($choice[$iRef][$iPaper] != 0) { $tpl->set_var("BG_COLOR", "lightblue"); $tpl->set_var("PAPER_RATING", $choice[$iRef][$iPaper]); $weightPaper += $choice[$iRef][$iPaper]; } else { $tpl->set_var("BG_COLOR", "white"); $tpl->set_var("PAPER_RATING", GetRatingValue($papers[$iPaper], $members[$iRef], $db)); } $tpl->set_var("WEIGHT", "{$weightPaper}"); $tpl->append("ASSIGNMENTS", "ASSIGNMENT_DETAIL"); } // Add to the list of papers $tpl->append("PAPERS", "PAPER_DETAIL"); $tpl->set_var("ASSIGNMENTS", ""); } }
/** * Get the list of authors */ function getAuthors($format = "string") { // We first look at the blind review mode $registry = Zend_registry::getInstance(); $zmax_context = $registry->get("zmax_context"); // If blind -> return the anonymous string, except if the user is admin if ($this->hideAuthors()) { return $zmax_context->texts->anonymous_author; } else { // Create a string with list of authors $strAuthors = $comma = ""; foreach ($this->_authors as $author) { $strAuthors .= $comma . $author->first_name . " " . $author->last_name; $comma = ", "; } return $strAuthors; } }
/** * Edit method: used to manage a simple workflow for editing * @param object the request object * @return none */ public function edit($request) { // Extract the controller and action info. $module = $request->getModuleName(); $control = $request->getControllerName(); $action = $request->getActionName(); // Set the current edit action URL (use the config to obtain the base URL) // Get the utilitary objects from the registry $registry = Zend_registry::getInstance(); $zmax_context = $registry->get("zmax_context"); if ($module == "default") { $this->url = $zmax_context->config->app->base_url . "/" . $control . "/" . $action . "?1=1"; } else { $this->url = $zmax_context->config->app->base_url . "/" . $module . "/" . $control . "/" . $action . "?1=1"; } // echo "Control = $control Action = $action URL=$this->url<br/>"; // Get the values of the table form if ($request->getParam("show_table_form")) { // Get the values submitted in the table form foreach ($this->info['cols'] as $name) { $form_field_name = $this->getTblFormFieldName($name); if ($request->getParam($form_field_name)) { $this->table_form_values[$form_field_name] = $request->getParam($form_field_name); // Put these values in a GET query $this->form_table_query .= "&{$form_field_name}=" . urlEncode($request->getParam($form_field_name)); } } // echo "Table form fields:"; // print_r ($this->table_form_values); $this->form_table_query = "&show_table_form=1" . $this->form_table_query; } // We are only interested in POST parameters $paramsHTTP = $_REQUEST; // PR: do better // Check whether an action is required. if (isset($paramsHTTP[self::ZMAX_EDIT_ACTION])) { $action = $paramsHTTP[self::ZMAX_EDIT_ACTION]; } else { $action = ""; } $affichage = ""; switch ($action) { case self::DB_INSERT: // Insertion required if ($this->insertion($paramsHTTP)) { $affichage .= "<i>Insertion: done</i>"; $affichage .= "<h2>Input form</h2>"; $affichage .= $this->form(self::DB_INSERT, array()); } else { $affichage .= $this->messageList(); $affichage .= $this->form(self::DB_INSERT, $paramsHTTP); } break; case self::DB_UPDATE: // We must modify the row if ($this->update($paramsHTTP)) { $affichage .= "<i>Update: done.</i>"; } else { $affichage .= $this->messageList(); } $ligne = $this->getRow($paramsHTTP); $affichage .= $this->form(self::DB_UPDATE, $ligne); break; case self::DB_DELETE: // Remove the line $this->delete($paramsHTTP); $affichage .= "<i>Deletion: done.</i>"; $affichage .= $this->form(self::DB_INSERT, array()); break; case self::DB_EDIT: // Search a row and edit it $ligne = $this->getRow($paramsHTTP); $affichage .= $this->form(self::DB_UPDATE, $ligne); break; default: $affichage .= $this->form(self::DB_INSERT, array()); break; } $affichage .= "<br />\n"; // petite separation // Maybe show the HTML table with the content of the table if ($this->show_table_content) { $affichage .= "<h2><i>{$this->table_label}</i></h2>\n"; $affichage .= $this->table(array("BORDER" => 2)); } // Maybe show the form if ($this->mode_show_form) { $add_url = $this->url . $this->form_table_query; $affichage .= "<a href='{$add_url}'>{$this->texts->form->add_line}</a>\n"; } // Retour de la page HTML return $affichage; }
function SummaryPapersAssignment(&$tpl, $db, &$TEXTS) { $registry = Zend_registry::getInstance(); $config = $registry->get("Config"); $config->putInView($tpl); $db = Zend_Db_Table::getDefaultAdapter(); $paperTbl = new Paper(); $reviewTbl = new Review(); $ratingTbl = new Rating(); $userTbl = new User(); /* Check whether there is a prefered topic for papers */ if ($config->selectedPaperTopic) { $prefPaperTopic = $config->selectedPaperTopic; } else { $prefPaperTopic = "%"; } /* Check whether there is a prefered topic for reviewers */ if ($config->selectedReviewerTopic) { $prefReviewerTopic = $config->selectedReviewerTopic; } else { $prefReviewerTopic = "%"; } // Decompose the blocks of the template $tpl->set_block("content", "MEMBER_DETAIL", "MEMBERS"); $tpl->set_block("content", "PAPER_DETAIL", "PAPERS"); $tpl->set_block("content", "NAVIGATION_TABLE", "NAVIGATION"); $tpl->set_block("PAPER_DETAIL", "ASSIGNMENT_DETAIL", "ASSIGNMENTS"); // Get the list of topics $topicList = $db->fetchPairs("SELECT id, label FROM ResearchTopic"); $topicList["0"] = "Any"; ksort($topicList); // Show the selection list $tpl->paper_topics = Zmax_View_Phplib::selectField("paperTopic", $topicList, $prefPaperTopic); $tpl->reviewer_topics = Zmax_View_Phplib::selectField("reviewerTopic", $topicList, $prefReviewerTopic); /* Store the list of reviewers in an array (+easier, +efficient). */ $members = array(); $nb_members = 0; $users = $userTbl->fetchAll("roles LIKE '%R%'", "last_name"); foreach ($users as $user) { if ($prefReviewerTopic == '%' or $user->matchTopic($prefReviewerTopic)) { $members[++$nb_members] = $user; } } // Same thing for papers $papers = array(); $nb_papers = 0; $rPapers = $db->query("SELECT * FROM Paper ORDER BY id"); while ($paper = $rPapers->fetch(Zend_Db::FETCH_OBJ)) { if ($prefPaperTopic == '%' or $paper->topic == $prefPaperTopic) { $papers[++$nb_papers] = $paper; } } // Manage the navigation table if ($nb_papers > MAX_ITEMS_IN_ASSIGNMENT or $nb_members > MAX_ITEMS_IN_ASSIGNMENT) { // Show the navigation table $tpl->set_var("nb_paper", $nb_papers); $tpl->set_var("nb_reviewers", $nb_members); $tpl->set_var("max_items_in_assignment", MAX_ITEMS_IN_ASSIGNMENT); if (isset($_REQUEST['i_paper_min'])) { // The request comes from the navigation table $i_paper_min = $_REQUEST['i_paper_min']; $i_paper_max = min($_REQUEST['i_paper_max'], $nb_papers); $i_member_min = $_REQUEST['i_member_min']; $i_member_max = min($_REQUEST['i_member_max'], $nb_members); } else { $i_paper_min = 1; $i_paper_max = min($nb_papers, MAX_ITEMS_IN_ASSIGNMENT); $i_member_min = 1; $i_member_max = min($nb_members, MAX_ITEMS_IN_ASSIGNMENT); } // Show the navigation table $tpl->set_var("NAV_TABLE", ""); $lines = ""; $script = $tpl->base_url . "/admin/chair/showassignment?1=1"; for ($i = 1; $i <= $nb_papers; $i += MAX_ITEMS_IN_ASSIGNMENT) { $line = ""; for ($j = 1; $j <= $nb_members; $j += MAX_ITEMS_IN_ASSIGNMENT) { $link = $script . "&i_paper_min={$i}" . "&i_paper_max=" . ($i + MAX_ITEMS_IN_ASSIGNMENT - 1) . "&i_member_min={$j}" . "&i_member_max=" . ($j + MAX_ITEMS_IN_ASSIGNMENT - 1); if ($i == $i_paper_min and $j == $i_member_min) { $line .= "<td bgcolor=lightblue><a href='{$link}'>" . "<font color=white>{$i}/{$j}</font></a></td>"; } else { $line .= "<td><a href='{$link}'>{$i}/{$j}</a></td>"; } } $lines .= "<tr>{$line}</tr>\n"; } $tpl->set_var("NAV_TABLE", $lines); $tpl->append("NAVIGATION", "NAVIGATION_TABLE"); } else { // Hide the navigation table $i_paper_min = $i_member_min = 1; $i_paper_max = $nb_papers; $i_member_max = $nb_members; $tpl->set_var("NAVIGATION", ""); } // Put the current values in the template $tpl->set_var("I_PAPER_MIN", $i_paper_min); $tpl->set_var("I_PAPER_MAX", $i_paper_max); $tpl->set_var("I_MEMBER_MIN", $i_member_min); $tpl->set_var("I_MEMBER_MAX", $i_member_max); // echo "I paper min=$i_paper_min I paper max = $i_paper_max<br>"; // OK, now create the table. First the columns' headers for ($j = $i_member_min; $j <= $i_member_max; $j++) { $members[$j]->putInView($tpl); $tpl->member_nb_papers = $members[$j]->countPapers(); $tpl->append("MEMBERS", "MEMBER_DETAIL"); } // then each line $tpl->PAPERS = ""; for ($i = $i_paper_min; $i <= $i_paper_max; $i++) { // Choose the CSS class if ($i % 2 == 0) { $tpl->set_var("css_class", "even"); } else { $tpl->set_var("css_class", "odd"); } $paper = $papers[$i]; $entity = "Paper" . "->id"; $tpl->setVar($entity, $papers[$i]->id); $tpl->SESSION_ID = session_id(); // Get the ratings of each PC member $nbReviewers = 0; for ($j = $i_member_min; $j <= $i_member_max; $j++) { $member = $members[$j]; $member->putInView($tpl); $rating = $ratingTbl->find($paper->id, $member->id)->current(); if ($rating) { $val = $rating->rate; } else { $val = 2; } $tpl->bg_color = "white"; $tpl->set_var("paper_rating", $val); $tpl->set_var("CHECKED_YES", ""); $tpl->set_var("CHECKED_NO", "checked='1'"); // Check if the paper is assigned $review = $reviewTbl->find($paper->id, $member->id)->current(); if ($review) { $nbReviewers = $nbReviewers + 1; $tpl->bg_color = "yellow"; $tpl->set_var("CHECKED_YES", "checked='1'"); $tpl->set_var("CHECKED_NO", ""); } // Add to the assignment line $tpl->append("ASSIGNMENTS", "ASSIGNMENT_DETAIL"); } // Add to the list of papers $tpl->setVar("paper_nb_reviewers", $nbReviewers); $tpl->append("PAPERS", "PAPER_DETAIL"); $tpl->set_var("ASSIGNMENTS", ""); } }
/** * List of papers with their reviews */ private function papersReviews($view, $templateName, $html = true, $anonymized = false) { $db = Zend_Db_Table::getDefaultAdapter(); $paperTbl = new Paper(); $paperStatusTbl = new PaperStatus(); $criteriaTbl = new Criteria(); $reviewTbl = new Review(); $reviewMarkTbl = new ReviewMark(); $registry = Zend_registry::getInstance(); $config = $registry->get("Config"); $config->putInView($view); // Set the mail types $view->someUser = Mail::SOME_USER; // Extract the block for each paper $view->setBlock($templateName, "PAPER_DETAIL", "PAPERS"); $view->setBlock($templateName, "REVIEW_CRITERIA", "REVIEW_CRITERIAS"); $view->setBlock("PAPER_DETAIL", "PAPER_INFO", "PAPER_DATA"); $view->setBlock("PAPER_DETAIL", "REVIEW_MARK", "REVIEW_MARKS"); $view->setBlock("PAPER_DETAIL", "REVIEWER", "REVIEWER_INFO"); // Header of the table, taken from table Criteria $criterias = $criteriaTbl->fetchAll(); $listCriterias = array(); foreach ($criterias as $criteria) { $criteria->putInView($view); $listCriterias[] = $criteria; $view->append("REVIEW_CRITERIAS", "REVIEW_CRITERIA"); } // Sort the papers on the average 'overall' field $query = "SELECT p.*, round(AVG(overall),4) AS overall " . "FROM Paper p LEFT JOIN Review r ON p.id=r.idPaper " . " WHERE inCurrentSelection='Y' GROUP BY p.id"; $result = $db->query($query); $arrPaper = $rankPaper = array(); while ($paper = $result->fetch(Zend_Db::FETCH_OBJ)) { $arrPaper[$paper->id] = $paper; $rankPaper[$paper->id] = $paper->overall; } // Get the status list $statusList = $db->fetchPairs("SELECT * FROM PaperStatus WHERE final_status='Y'"); // Sort in descending order arsort($rankPaper); reset($rankPaper); // List the papers in order $iPaper = 0; foreach ($rankPaper as $idPaper => $overall) { $paper = $arrPaper[$idPaper]; // Choose the CSS class $view->css_class = Config::CssCLass($iPaper++); $view->paper_id = $paper->id; $view->paper_title = $paper->title; if (!$anonymized) { $view->paper_authors = PaperRow::getPaperAuthors($db, $paper); } else { $view->paper_authors = "[anonymized]"; } $view->paper_email_contact = $paper->emailContact; $view->paper_rank = $iPaper; $view->paper_overall = $overall; $view->form_status = Zmax_View_Phplib::checkboxField("radio", "status[{$paper->id}]", $statusList, $paper->status, array("length" => 2)); // Now, loop on reviews $qRev = "SELECT * FROM Review r, User u " . " WHERE idPaper='{$paper->id}' AND u.id=r.id_user"; $resRev = $db->query($qRev); $countReviews = 0; $mail_reviewers = $comma = ""; while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) { $countReviews++; $mail_reviewers .= $comma . $review->email; $comma = ", "; } $view->paper_nb_reviewers = Max(1, $countReviews); //echo "Mail reviewers = $mail_reviewers<br/>"; $view->paper_email_reviewers = $mail_reviewers; $view->append("PAPER_DATA", "PAPER_INFO"); $resRev = $db->query($qRev); $iReview = 0; while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) { $iReview++; $view->reviewer_id = $review->id; if ($anonymized == false) { $view->reviewer_fname = $review->first_name; $view->reviewer_lname = $review->last_name; $view->external_reviewer_fname = $review->fname_ext_reviewer; $view->external_reviewer_lname = $review->lname_ext_reviewer; $view->review_comments = $review->comments; } else { $view->reviewer_fname = $iReview; $view->reviewer_lname = ""; $view->external_reviewer_fname = ""; $view->external_reviewer_lname = ""; $view->review_comments = ""; } $view->reviewer_email = $review->email; $view->review_overall = $review->overall; $view->review_summary = $review->summary; $view->review_details = $review->details; if ($review->reviewerExpertise >= 1 and $review->reviewerExpertise <= 3) { $view->reviewer_expertise = Config::$Expertise[$review->reviewerExpertise]; } // Avoid to introduce Latex commands in Latex files .... if (!$html) { $view->review_summary = str_replace("\\", "", $view->review_summary); $view->review_details = str_replace("\\", "", $view->review_details); $view->review_comments = str_replace("\\", "", $view->review_comments); } $view->assign("REVIEWER_INFO", "REVIEWER"); reset($listCriterias); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $criteria) { $reviewMark = $reviewMarkTbl->find($review->idPaper, $review->id_user, $criteria->id)->current(); if (!is_object($reviewMark)) { $reviewMark = $reviewMarkTbl->createRow(); // for default values } $reviewMark->putInView($view); $view->criteria_label = $criteria->label; $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->append("PAPERS", "PAPER_DETAIL"); // The paper data is shown only once for all the reviews $view->set_var("PAPER_DATA", " "); } // Show the paper even without reviewer if ($countReviews == 0) { $review = $reviewTbl->createRow(); $review->putInView($view); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $id => $label) { $reviewMark = $reviewMarkTbl->createRow(); $reviewMark->putInView($view); $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->set_var("REVIEWER_INFO", ""); $view->append("PAPERS", "PAPER_DETAIL"); $view->set_var("PAPER_DATA", ""); } // Summary for the paper if ($html) { $statPaper = Paper::getStats($paper->id, $listCriterias); $markFieldName = "ReviewMark" . "->mark"; $overallFieldName = "review_overall"; $view->set_var("NB_REVIEWERS", 1); if ($html) { $view->set_var("PAPER_DATA", "<td> </td><th>Summary</th>"); } $view->set_var("REVIEWER_INFO", " "); $view->set_var($overallFieldName, $paper->overall); reset($listCriterias); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $c) { $view->setVar($markFieldName, $statPaper[$c->id]); $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->append("PAPERS", "PAPER_DETAIL"); $view->set_var("PAPER_DATA", ""); } } }
/** * Static method that returns a login form * */ public static function loginForm($req_controller, $req_action, $request) { // Get the current action URL (use the config to obtain the base URL) // Get the utilitary objects from the registry $registry = Zend_registry::getInstance(); $zmax_context = $registry->get("zmax_context"); $module_name = $request->getModuleName(); if (!empty($module_name)) { $module = $request->getModuleName() . "/"; } else { $module = ""; } $url = $zmax_context->config->app->base_url . "/" . $module . $request->getControllerName() . "/" . $request->getActionName() . "?1=1"; // The form always refers to the current controller // and to the current action $current_action = $request->getActionName(); $form = new Zmax_HTML_Form($url); $form->champCache("zmax_req_controller", $req_controller); $form->champCache("zmax_req_action", $req_action); $form->debutTable(); $form->champTexte($zmax_context->texts->zmax->login, "zmax_login", "", 20); $form->champMotDePasse($zmax_context->texts->zmax->password, "zmax_password", "", 20); $form->champValider($zmax_context->texts->zmax->submit, "submit_login"); $form->finTable(); return $form->fin(); }
/** * Delete a review and all dependent objects */ function delete() { // Check whether we are in safe mode $registry = Zend_registry::getInstance(); $safeMode = $registry->get("zmax_context")->config->app->safe_mode; // General rule: never delete a review already submitted if ($safeMode and !empty($this->overall)) { throw new Exception("MyReview error: attempt to delete an existing review ({$this->idPaper}, {$this->id_user})." . "Operation cancelled (unset the safe mode in application.ini to override this)"); return; } // Delete all review answers $answers = $this->findReviewAnswer(); foreach ($answers as $answer) { $answer->delete(); } // Delete all review marks $marks = $this->findReviewMark(); foreach ($marks as $mark) { $mark->delete(); } // Finally delete the review itself parent::delete(); }
public static function setupDatabase() { $zmax_context = self::getRegistry()->get("zmax_context"); $config = $zmax_context->config; if (!isset($config)) { throw new Zmax_Exception('setupConfig() must be called before ' . __FUNCTION__ . '()'); } if (isset($_GET['zmax_display_lang']) && $_GET['zmax_display_lang'] != "") { $locale = new Zmax_Locale($_GET['zmax_display_lang']); } elseif (isset($_COOKIE['zmax_display_lang'])) { $locale = new Zmax_Locale($_COOKIE['zmax_display_lang']); } elseif (isset($zmax_context->locale)) { $locale = $zmax_context->locale; } else { $locale = new Zmax_Locale(); } // Only try to access the DB if the config. requires it if ($config->app->use_database) { if ($config->db->adapter == "couchdb") { $zmax_context->db = new Zmax_CouchDB($config->couchdb->host, $config->couchdb->admin, $config->couchdb->password); // For historical reason: also put in the registry $registry = Zend_registry::getInstance(); $registry->set("couchdb", $zmax_context->db); } else { // Use standard RDBMS $db = new Zmax_Db_Adapter($config->db); //$db->query("SET NAMES 'utf8'"); Zend_Db_Table::setDefaultAdapter($db); $zmax_context->db = $db; } } else { $zmax_context->db = null; } }
/** * Put the values in the view * * Overriden method: put the name of the country instead of the code * @author philipperigaux * */ function putInView(&$view, $html = true) { // Trim some values $this->address = trim($this->address); parent::putInView($view, $html); // Get the config $registry = Zend_registry::getInstance(); $config = $registry->get("Config"); $name = "User" . "->country"; $country = $this->findParentCountry(); if (!is_object($country)) { $country_name = ""; } else { $country_name = $country->name; } $view->setVar($name, $country_name); // Put the default password in the view $name = "User" . "->default_password"; $view->setVar($name, $this->defaultPassword($config->passwordGenerator)); // Create a view field with the list of topics (for existing users) $strTopics = $comma = ""; if ($this->id != "") { $usertopics = $this->findUserTopic(); foreach ($usertopics as $usertopic) { $topic = $usertopic->findParentResearchTopic(); if (is_object($topic)) { $strTopics .= $comma . $topic->label; $comma = ", "; } } } $name = "User" . "->topics"; $view->setVar($name, $strTopics); }