/* Inclusive Design Institute */ /* */ /* This program is free software. You can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /************************************************************************/ // $Id: index.php 495 2011-02-10 21:27:00Z cindy $ // Called by ajax request from guidelineline view report -> "make decision(s)" buttons // @ see checker/js/checker.js define('AC_INCLUDE_PATH', '../include/'); include AC_INCLUDE_PATH . 'vitals.inc.php'; include_once AC_INCLUDE_PATH . 'classes/Utility.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/UserLinksDAO.class.php'; // main process to save decisions $guidelinesDAO = new GuidelinesDAO(); $guideline_rows = $guidelinesDAO->getGuidelineByIDs($_POST['gids']); if (!is_array($guideline_rows)) { echo _AC("AC_ERROR_EMPTY_GID"); exit; } $utility = new Utility(); $seals = $utility->getSeals($guideline_rows); if (is_array($seals)) { $userLinksDAO = new UserLinksDAO(); $rows = $userLinksDAO->getByUserIDAndURIAndSession($_SESSION['user_id'], $_POST['uri'], $_POST['jsessionid']); $savant->assign('user_link_id', $rows[0]['user_link_id']); $savant->assign('seals', $seals); $savant->display('checker/seals.tmpl.php'); } exit;
/** * set main report * @access private * @param none * @return set main report * @author Cindy Qi Li */ private function setMainStr() { // get $html_main.{SESSIONID} $userLinksDAO = new UserLinksDAO(); $row = $userLinksDAO->getByUserLinkID($this->userLinkID); $sessionID = $row['last_sessionID']; if ($this->numOfErrors > 0) { $detail_error = str_replace(array('{DETAIL_TITLE}', '{DIV_ID}', '{DETAIL}'), array(_AC('errors'), 'errors', $this->htmlRpt->getErrorRpt()), $this->html_detail); } if ($this->numOfLikelyProblems > 0) { $detail_likely = str_replace(array('{DETAIL_TITLE}', '{DIV_ID}', '{DETAIL}'), array(_AC('likely_problems'), 'likely_problems', $this->htmlRpt->getLikelyProblemRpt()), $this->html_detail); } if ($this->numOfPotentialProblems > 0) { $detail_potential = str_replace(array('{DETAIL_TITLE}', '{DIV_ID}', '{DETAIL}'), array(_AC('potential_problems'), 'potential_problems', $this->htmlRpt->getPotentialProblemRpt()), $this->html_detail); } // generate $html_main.{DETAIL} if ($detail_error != '' || $detail_likely != '' || $detail_potential != '') { $detail = '<h3>' . _AC("accessibility_review") . '</h3>' . "\n" . $detail_error . $detail_likely . $detail_potential; } // set display of "make decision" button if ($this->numOfNoDecision > 0) { $button_make_decision = $this->html_button_make_decision; } // set main string $this->mainStr = str_replace(array('{SESSIONID}', '{SUMMARY}', '{GUIDELINE}', '{DETAIL}', '{BUTTON_MAKE_DECISION}'), array($sessionID, $this->summaryStr, $this->guidelineStr, $detail, $button_make_decision), $this->html_main); }
/** * Delete user * @access public * @param user_id * @return true, if successful * false and add error into global var $msg, if unsuccessful * @author Cindy Qi Li */ public function Delete($userIDs) { // delete customized guidelines created by user but yet open to public include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/ChecksDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/UserLinksDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/Utility.class.php'; $userIDs = Utility::sanitizeIntArray($userIDs); $guidelinesDAO = new GuidelinesDAO(); $guidelines = $guidelinesDAO->getGuidelineByUserIDs($userIDs); if (is_array($guidelines)) { foreach ($guidelines as $guideline) { if ($guideline['open_to_public'] == 0) { $guidelinesDAO->Delete($guideline['guideline_id']); } } } // delete customized checks created by user but yet open to public $checksDAO = new ChecksDAO(); $checks = $checksDAO->getCheckByUserIDs($userIDs); if (is_array($checks)) { foreach ($checks as $check) { if ($check['open_to_public'] == 0) { $checksDAO->Delete($check['check_id']); } } } // delete user links and decisions generated by this user $userLinksDAO = new UserLinksDAO(); $userLinks = $userLinksDAO->DeleteByUserID($userIDs); $sql = "DELETE FROM " . TABLE_PREFIX . "users\n\t\t WHERE user_id in (" . implode(",", $userIDs) . ")"; return $this->execute($sql); }
$allow_set_decision = 'true'; } } } else { if (isset($_REQUEST['referer_report'])) { $from_referer = 'true'; if (isset($_REQUEST['referer_user_link_id'])) { $user_link_id = $_REQUEST['referer_user_link_id']; if ($_SESSION['user_id'] > 0) { $allow_set_decision = 'true'; } } } else { if (isset($_SESSION['user_id']) && $_REQUEST["validate_uri"]) { // save errors into user_links $userLinksDAO = new UserLinksDAO(); $user_link_id = $userLinksDAO->getUserLinkID($_SESSION['user_id'], $_REQUEST['uri'], $_gids); // save errors into user_decisions // $userDecisionsDAO = new UserDecisionsDAO(); // $userDecisionsDAO->saveErrors($user_link_id, $errors); $allow_set_decision = 'true'; } } } $_SESSION['input_form']['user_link_id'] = $user_link_id; if ($_POST["rpt_format"] == REPORT_FORMAT_GUIDELINE) { $a_rpt = new HTMLByGuidelineRpt($errors, $_gids[0], $user_link_id); $_SESSION['input_form']['mode'] = 'guideline'; } else { if ($_POST["rpt_format"] == REPORT_FORMAT_LINE) { $a_rpt = new HtmlRpt($errors, $user_link_id);
$guidelinesDAO = new GuidelinesDAO(); foreach ($guides as $abbr) { if ($abbr == '') { continue; } $row = $guidelinesDAO->getEnabledGuidelinesByAbbr($abbr); if ($row[0]['guideline_id'] != '') { $gids[] = $row[0]['guideline_id']; } } // set to default guideline if no input guidelines if (!is_array($gids)) { $gids[] = DEFAULT_GUIDELINE; } // retrieve user link ID $userLinksDAO = new UserLinksDAO(); $user_link_id = $userLinksDAO->getUserLinkID($user_id, $uri, $gids); // set new session id $userLinksDAO->setLastSessionID($user_link_id, Utility::getSessionID()); // validating uri content $validate_content = @file_get_contents($uri); if (isset($validate_content)) { $aValidator = new AccessibilityValidator($validate_content, $gids, $uri); $aValidator->setLineOffset($offset); $aValidator->validate(); $errors = $aValidator->getValidationErrorRpt(); // save errors into user_decisions // $userDecisionsDAO = new UserDecisionsDAO(); // $userDecisionsDAO->saveErrors($user_link_id, $errors); if ($output == 'html') { // generate html output
</pre> <?php } // end of foreach (display seals) } // end of if (display seals) ?> </div> <div id="output_div" > <?php if (isset($this->aValidator) && $this->a_rpt->getAllowSetDecisions() == 'true') { $sessionID = Utility::getSessionID(); $userLinksDAO = new UserLinksDAO(); $userLinksDAO->setLastSessionID($this->a_rpt->getUserLinkID(), $sessionID); echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">' . "\n\r"; echo '<input type="hidden" name="jsessionid" value="' . $sessionID . '" />' . "\n\r"; echo '<input type="hidden" name="uri" value="' . $addslashes($_POST["uri"]) . '" />' . "\n\r"; echo '<input type="hidden" name="output" value="html" />' . "\n\r"; echo '<input type="hidden" name="validate_uri" value="1" />' . "\n\r"; echo '<input type="hidden" name="rpt_format" value="' . $addslashes($_POST['rpt_format']) . '" />' . "\n\r"; // report for referer URI if (isset($this->referer_report)) { echo '<input type="hidden" name="referer_report" value="' . $this->referer_report . '" />' . "\n\r"; } // user_link_id for referer URI is sent in from request, don't need to retrieve if (isset($this->referer_user_link_id)) { echo '<input type="hidden" name="referer_user_link_id" value="' . $this->referer_user_link_id . '" />' . "\n\r"; }
} // reverse decision if (isset($_POST['reverse'])) { foreach ($_POST['reverse'] as $sequenceID => $garbage) { $decision->makeDecisions(array($sequenceID => AC_NO_DECISION)); } } } } // end of process to made decision // validate referer URIs that has passed validation and received seal. The click on the seal triggers // the if - else below. if ($_GET['uri'] == 'referer') { // validate if the URI from referer matches the URI defined in user_links.user_link_id if (isset($_GET['id'])) { $userLinksDAO = new UserLinksDAO(); $row = $userLinksDAO->getByUserLinkID($_GET['id']); $pos_user_link_uri = strpos($row['URI'], '?'); if ($pos_user_link_URI > 0) { $user_link_uri = substr($row['URI'], 0, $pos_user_link_uri); } else { $user_link_uri = $row['URI']; } $pos_referer_uri = strpos($_SERVER['HTTP_REFERER'], '?'); if ($pos_referer_uri > 0) { $referer_uri = substr($_SERVER['HTTP_REFERER'], 0, $pos_referer_uri); } else { $referer_uri = $_SERVER['HTTP_REFERER']; } // guideline id must be given if the request is to check referer URI if (!isset($_GET['gid'])) {
/** * private * main process to generate report in html format */ private function generateRESTRpt() { $num_of_errors = 0; $num_of_likely_problems = 0; $num_of_potential_problems = 0; $checksDAO = new ChecksDAO(); $userDecisionsDAO = new UserDecisionsDAO(); // generate section details foreach ($this->errors as $error) { // generate each error result $result_type = ''; $repair = ''; $decision = ''; $decision_questions = ''; $decision_made = ''; $row_check = $checksDAO->getCheckByID($error["check_id"]); if ($row_check["confidence"] == KNOWN) { // only known errors have <repair> $num_of_errors++; $result_type = _AC('error'); $repair = str_replace('{REPAIR}', htmlentities(_AC($row_check["how_to_repair"])), $this->rest_repair); } else { // generate user's decision. only likely and potential problems have decisions to make $row_userDecision = $userDecisionsDAO->getByUserLinkIDAndLineNumAndColNumAndCheckID($this->userLinkID, $error["line_number"], $error["col_number"], $error['check_id']); if ($row_userDecision['decision'] == AC_DECISION_PASS || $row_userDecision['decision'] == AC_DECISION_FAIL) { if ($row_userDecision['decision'] == AC_DECISION_PASS) { $decision_text = _AC('pass'); } if ($row_userDecision['decision'] == AC_DECISION_FAIL) { $decision_text = _AC('fail'); } $decision_made = str_replace(array('{DECISIONMADE}', '{DECISIONMADEDATE}'), array(htmlentities($decision_text), $row_userDecision['last_update']), $this->rest_decision_made); } if ($row_check["confidence"] == LIKELY) { $result_type = _AC('likely_problem'); if (!$row_userDecision || $row_userDecision['decision'] == AC_DECISION_FAIL) { $num_of_likely_problems++; } } if ($row_check["confidence"] == POTENTIAL) { $result_type = _AC('potential_problem'); if (!$row_userDecision || $row_userDecision['decision'] == AC_DECISION_FAIL) { $num_of_potential_problems++; } } $decision_questions = str_replace(array('{SEQUENCEID}', '{DECISIONPASS}', '{DECISIONFAIL}'), array($error['line_number'] . '_' . $error['col_number'] . '_' . $error['check_id'], htmlentities(_AC($row_check['decision_pass'])), htmlentities(_AC($row_check['decision_fail']))), $this->rest_decision_questions); $decision = $decision_questions . $decision_made; // end of generating user's decision } $result .= str_replace(array('{RESULTTYPE}', '{LINENUM}', '{COLUMNNUM}', '{BASE_HREF}', '{CHECK_ID}', '{TITLE}', '{ERRORMSG}', '{ERRORSOURCECODE}', '{REPAIR}', '{DECISION}'), array($result_type, $error["line_number"], $error["col_number"], htmlentities(AC_BASE_HREF), $error['check_id'], htmlentities(_AC("suggest_improvements")), htmlentities(_AC($row_check['err'])), htmlentities($error["html_code"], ENT_QUOTES, "UTF-8"), $repair, $decision), $this->rest_result); } // retrieve session id $userLinksDAO = new UserLinksDAO(); $row = $userLinksDAO->getByUserLinkID($this->userLinkID); $sessionID = $row['last_sessionID']; // generate guidelines $guidelinesDAO = new GuidelinesDAO(); foreach ($this->guidelineArray as $gid) { $row_guideline = $guidelinesDAO->getGuidelineByIDs($gid); $guidelines .= str_replace('{GUIDELINE}', htmlentities($row_guideline[0]['title']), $this->rest_guideline); } // find out result status: pass, fail, conditional pass if ($num_of_errors > 0) { $status = _AC('fail'); } else { if ($num_of_likely_problems + $num_of_potential_problems > 0) { $status = _AC('conditional_pass'); } else { $status = _AC('pass'); } } // generate final output $this->output = str_replace(array('{STATUS}', '{SESSIONID}', '{NUMOFERRORS}', '{NUMOFLIKELYPROBLEMS}', '{NUMOFPOTENTIALPROBLEMS}', '{GUIDELINES}', '{RESULTS}'), array($status, $sessionID, $num_of_errors, $num_of_likely_problems, $num_of_potential_problems, $guidelines, $result), $this->rest_main); }