Пример #1
0
 /**
  * Executes query and hydrate this object
  *
  * @param       string $query the query being searched for
  */
 public function query($query, PropelPDO $propelConnection = null)
 {
     $refQuery = trim($query);
     if (strlen($refQuery) < 3) {
         throw new Exception("Too few characters in the query string");
     } elseif (helperFunctions::isMaliciousString($refQuery)) {
         throw new Exception("Malicious string detected. Are you trying to wreck our system?");
     } else {
         // search for courses
         $c = new Criteria();
         $idCrit = $c->getNewCriterion(CoursePeer::ID, $refQuery . "%", Criteria::LIKE);
         $nameCrit = $c->getNewCriterion(CoursePeer::DESCR, "%" . $refQuery . "%", Criteria::LIKE);
         $idCrit->addOr($nameCrit);
         $c->addAnd($idCrit);
         $c->setDistinct();
         $c->addAscendingOrderByColumn(CoursePeer::ID);
         $this->_courseList = CoursePeer::doselect($c, $propelConnection);
         // search for professors
         $c = new Criteria();
         $firstNameCrit = $c->getNewCriterion(InstructorPeer::FIRST_NAME, "%" . $refQuery . "%", Criteria::LIKE);
         $lastNameCrit = $c->getNewCriterion(InstructorPeer::LAST_NAME, "%" . $refQuery . "%", Criteria::LIKE);
         $firstNameCrit->addOr($lastNameCrit);
         $c->addAnd($firstNameCrit);
         $c->setDistinct();
         $c->addAscendingOrderByColumn(InstructorPeer::LAST_NAME);
         $this->_profList = InstructorPeer::doSelect($c, $propelConnection);
         // search for programs
         $c = new Criteria();
         $descrCrit = $c->getNewCriterion(DisciplinePeer::DESCR, "%" . $refQuery . "%", Criteria::LIKE);
         $c->addAnd($descrCrit);
         $c->setDistinct();
         $c->addAscendingOrderByColumn(DisciplinePeer::DESCR);
         $this->_programList = DisciplinePeer::doSelect($c, $propelConnection);
     }
 }
 public static function decipherCourseInsYear($year)
 {
     $arr = array();
     $arr['year'] = substr($year, 0, 4);
     $arr['term'] = helperFunctions::translateTerm(substr($year, 4));
     return $arr;
 }
Пример #3
0
 public function executeLogin(sfWebRequest $request)
 {
     if (helperFunctions::isLoggedIn($request)) {
         $this->redirect("siteadmin/index");
     }
     if ($request->isMethod(sfRequest::POST) && $request->hasParameter('username') && $request->hasParameter('password')) {
         $username = $request->getParameter("username");
         $password = $request->getParameter("password");
         if (helperFunctions::isMaliciousString($username) || helperFunctions::isMaliciousString($password)) {
             $this->error = "* Malicious keywords detected. Do not attempt this again!";
         } else {
             $conn = Propel::getConnection();
             $admin = UserPeer::retrieveByPK($username, $conn);
             if (!is_object($admin) || $admin->getPassword() != $password) {
                 $this->error = "* Incorrect credentials.";
             } elseif ($admin->getTypeId() != EnumItemPeer::USER_ADMIN) {
                 $this->error = "* You do not have enough clearance to access this section.";
             } else {
                 $this->getResponse()->setCookie('username', $username);
                 // redirect to whatever page the user came from
                 if ($request->hasParameter("redirect")) {
                     $redirect = $request->getParameter("redirect");
                 } else {
                     $redirect = "siteadmin/index";
                 }
                 $this->redirect($redirect);
             }
         }
     }
 }
Пример #4
0
 public function preExecute()
 {
     if (!helperFunctions::isLoggedIn(sfContext::getInstance()->getRequest())) {
         $this->redirect("siteadmin/login");
     }
     $this->earliestYear = skuleadminConst::EARLIEST_YEAR;
     $this->date = getdate();
 }
Пример #5
0
 public function preExecute()
 {
     if (!helperFunctions::isLoggedIn(sfContext::getInstance()->getRequest())) {
         $this->redirect("siteadmin/login");
     }
     // separator used for course_discipl assoc data
     $this->separator = "&&**&&";
 }
Пример #6
0
function skuleShutdown()
{
    // this is used to register fatal error
    if ($error = error_get_last()) {
        if ($error['type'] == E_ERROR) {
            helperFunctions::errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
        }
    }
}
Пример #7
0
 public function preExecute()
 {
     if (!helperFunctions::isLoggedIn(sfContext::getInstance()->getRequest())) {
         $this->redirect("siteadmin/login");
     }
     // separator used for course_discipl assoc data
     $this->separator = "&&**&&";
     $this->date = getdate();
     $this->earliestYear = skuleadminConst::EARLIEST_YEAR;
 }
Пример #8
0
 public function get()
 {
     $returnStr = "<div id='left'>";
     $returnStr .= $this->getMenuStud();
     if ($this->_menuOption < subMenuOptions::MAINTENANCE) {
         // courses and search menu styling
         $conn = Propel::getConnection();
         if (isset($this->_courseId)) {
             if (!isset($this->_ratingYearArray)) {
                 // get rating data
                 $this->_ratingYearArray = AutoCourseRatingPeer::getAvailableYearsForCourseId($this->_courseId, $conn);
             }
             if (!isset($this->_examYearArray)) {
                 // get exam data
                 $this->_examYearArray = ExamPeer::getAvailableYearsForCourseId($this->_courseId, $conn);
             }
             if ($this->_menuOption == subMenuOptions::COURSE) {
                 $returnStr .= "<dl><dt>" . $this->_courseId . "</dt>";
             } else {
                 $returnStr .= "<dl><dt>" . link_to($this->_courseId, "course/index?id=" . $this->_courseId) . "</dt>";
             }
             // critique
             $returnStr .= "<div class='popupmenu' id='subCritique' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>";
             if (count($this->_ratingYearArray) == 0) {
                 $returnStr .= "<a>None Available</a>";
             } else {
                 foreach ($this->_ratingYearArray as $year) {
                     $returnStr .= link_to(helperFunctions::translateTerm($year), "course/critique?id=" . $this->_courseId . "&year=" . $year);
                 }
             }
             $returnStr .= "</div>\n\t        \t<dd><a class='pointer' onmouseover='mopen(\"subCritique\")' onmouseout='mclosetime()'>Course Critiques</a></dd>";
             // exams
             $returnStr .= "<div class='popupmenu' id='subExam' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>";
             if (count($this->_examYearArray) == 0) {
                 $returnStr .= "<a>None Available</a>";
             } else {
                 foreach ($this->_examYearArray as $year) {
                     $returnStr .= link_to(helperFunctions::translateTerm($year), "course/exam?id=" . $this->_courseId . "&year=" . $year);
                 }
             }
             $returnStr .= "<a onclick='grayout(\"submitExam\");'>Submit Exams</a>";
             $returnStr .= "</div>\n\t        \t<dd><a class='pointer' onmouseover='mopen(\"subExam\")' onmouseout='mclosetime()'>Exams Repository</a></dd></dl>";
         }
     } elseif ($this->_menuOption == subMenuOptions::MAINTENANCE) {
         //TODO: make maintenance menu
         $returnStr .= "<dl><dt>" . link_to("Maintenance", "maintenance/index") . "</dt>";
         foreach (subMenuOptions::getMaintenanceSections() as $key => $value) {
             $returnStr .= "<dd>" . link_to($key, $value) . "</dd>";
         }
     } elseif ($this->_menuOption == subMenuOptions::ERROR) {
         $returnStr .= "<dl><dt>Error</dt></dl>";
     }
     $returnStr .= "</div>";
     return $returnStr;
 }
 public static function getRelatedDisciplinesForCourse(Course $course, PropelPDO $propelConnection)
 {
     $c = new Criteria();
     $c->addAscendingOrderByColumn(DisciplinePeer::DESCR);
     $rawResults = $course->getCourseDisciplineAssociationsJoinDiscipline($c, $propelConnection);
     $retResults = array();
     foreach ($rawResults as $result) {
         $en = $result->getDiscipline();
         $retResults[] = array("programName" => $en->getDescr(), "year" => helperFunctions::getYearOfStudy($result->getYearOfStudy()), "disciplineId" => $en->getId(), "numYear" => $result->getYearOfStudy());
     }
     return $retResults;
 }
Пример #10
0
 protected function submitForm(sfWebRequest $request, sfForm $userform)
 {
     $noerror = true;
     $userform->bind($request->getParameter($userform->getName()), $request->getFiles($userform->getName()));
     if ($userform->getObject()->isNew()) {
         $userform->getObject()->setRegisteredOn(date("Y-m-d H:i:s"));
     }
     if ($userform->isValid()) {
         try {
             $user = $userform->save();
             // send out an email to the newly created user
             include sfContext::getInstance()->getConfigCache()->checkConfig('config/skuleGlobal.yml');
             $msg = "Dear " . $user->getUserName() . ",\n\nYou have been registered with SkuleCourses (http://{$skuleGlobalParams['domain']}";
             if (isset($skuleGlobalParams['port']) && $skuleGlobalParams['port'] != "") {
                 $msg .= ":{$skuleGlobalParams['port']}";
             }
             $msg .= "). Please note the following information:\n\n";
             $msg .= "Credential Level: " . helperFunctions::getUserType($user->getTypeId());
             $msg .= "\nPassword: "******"\n\nSkuleCourses Webmaster";
             helperFunctions::sendEmail(array($user->getEmail()), "SkuleCourses User Registration", $msg);
         } catch (Exception $e) {
             $this->globalErrors = $e->getMessage();
             $noerror = false;
         }
     } else {
         $noerror = false;
     }
     if ($noerror) {
         $par = "";
         if ($request->hasParameter("page")) {
             $par = "page=" . $request->getParameter("page");
         }
         $this->redirect('adminuser/edit?' . $par . "&id=" . $userform->getObject()->getUserName());
     }
 }
Пример #11
0
			<td valign="top">
				<ul>
					<?php 
foreach ($ratingYearArray as $year) {
    ?>
					<li><?php 
    echo link_to(helperFunctions::translateTerm($year), "course/critique?id=" . $sf_request->getParameter('id') . "&year=" . $year);
    ?>
</li>
					<?php 
}
?>
				</ul>
			</td>
			<td valign="top">
				<ul>
					<?php 
foreach ($examYearArray as $year) {
    ?>
					<li><?php 
    echo link_to(helperFunctions::translateTerm($year), "course/exam?id=" . $sf_request->getParameter('id') . "&year=" . $year);
    ?>
</li>
					<?php 
}
?>
				</ul>
			</td>
		</tr>
	</table>
</div></div>
Пример #12
0
 public function executeSubmitExam(sfWebRequest $request)
 {
     if ($request->isMethod(sfRequest::POST) && $request->hasParameter('security') && $request->hasParameter('year') && $request->hasParameter('descr')) {
         $files = $request->getFiles();
         $file = $files['file'];
         $descr = $request->getParameter('descr');
         if (isset($file) && strtoupper(substr($file['name'], -3, 3)) == 'PDF' && !helperFunctions::isMaliciousString($descr)) {
             if ($request->getParameter("security") != $_SESSION['securityImage']) {
                 echo "<input type='text' id='status' value='Security'/>";
                 exit;
             }
             $year = $request->getParameter("year") . $request->getParameter("term");
             // make directories if not exist
             if (!is_dir("exams/custom")) {
                 if (!mkdir("exams/custom")) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     exit;
                 }
             }
             $tgt_path = "exams/custom/" . $year;
             if (!is_dir($tgt_path)) {
                 if (!mkdir($tgt_path)) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     exit;
                 }
             }
             $fileName = time() . ".pdf";
             if (move_uploaded_file($file['tmp_name'], $tgt_path . "/" . $fileName)) {
                 // register in db
                 $conn = Propel::getConnection();
                 $exam = new Exam();
                 $exam->setCourseId($request->getParameter("course"));
                 $exam->setFilePath($tgt_path . "/" . $fileName);
                 $exam->setYear($year);
                 $exam->setType($request->getParameter("type"));
                 $exam->setDescr($descr);
                 $exam->save($conn);
                 // send notification email
                 $ip = $_SERVER['REMOTE_ADDR'];
                 $msg = "Submitted by " . $ip . " [id=" . $exam->getId() . "]";
                 helperFunctions::sendEmailNotice("Exam Submission", $msg);
                 echo "<input type='text' id='status' value='Success'/>";
             } else {
                 echo "<input type='text' id='status' value='Moving'/>";
             }
         } else {
             echo "<input type='text' id='status' value='PDF'/>";
         }
     }
     exit;
 }
Пример #13
0
 public function executeImportratings(sfWebRequest $request)
 {
     if (helperFunctions::isLoggedIn($request)) {
         $this->buildSubmenu();
         $this->form = new skuleForm("frm", "maintenance/importratings", $request);
     } else {
         // redirect to log in page
         $this->buildSubmenu();
     }
 }
Пример #14
0
 /**
  * Take the exam submission request and save it into database
  * @param sfWebRequest $request
  */
 public function executeSubmitExam(sfWebRequest $request)
 {
     //TODO: set up uniform display name for each exam/test uploaded so things don't get messy.
     //i.e. instead of letting the user choose the display name, we'll appropriate it
     //requested by David
     set_time_limit(0);
     if ($request->isMethod(sfRequest::POST) && $request->hasParameter('security') && $request->hasParameter('year') && $request->hasParameter('descr')) {
         $files = $request->getFiles();
         $file = $files['file'];
         $descr = $request->getParameter('descr');
         if (isset($file) && strtoupper(substr($file['name'], -3, 3)) == 'PDF' && !helperFunctions::isMaliciousString($descr)) {
             if ($request->getParameter("security") != $_SESSION['securityImage']) {
                 echo "<input type='text' id='status' value='Security'/>";
                 return sfView::NONE;
             }
             $year = $request->getParameter("year") . $request->getParameter("term");
             // make directories if not exist
             if (!is_dir("exams/custom")) {
                 if (!mkdir("exams/custom")) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     return sfView::NONE;
                 }
             }
             $tgt_path = "exams/custom/" . $year;
             if (!is_dir($tgt_path)) {
                 if (!mkdir($tgt_path)) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     return sfView::NONE;
                 }
             }
             // unique filename
             $courseId = $request->getParameter("course");
             $examType = $request->getParameter("type");
             $examTypeAbbr = HelperFunctions::getExamTypeAbbr($examType);
             $fileName = substr($courseId, 0, 6) . '_' . substr($year, 0, 4) . '_' . $examTypeAbbr . '_' . time() . ".pdf";
             if (move_uploaded_file($file['tmp_name'], $tgt_path . "/" . $fileName)) {
                 try {
                     // register in db
                     $conn = Propel::getConnection();
                     $exam = new Exam();
                     $exam->setCourseId($courseId);
                     $exam->setFilePath($tgt_path . "/" . $fileName);
                     $exam->setYear($year);
                     $exam->setType($examType);
                     $exam->setDescr($descr);
                     $exam->save($conn);
                     // send notification email
                     $ip = $_SERVER['REMOTE_ADDR'];
                     $msg = "A new exam on [title=" . $exam->getDescr() . "; course=" . $exam->getCourseId() . "; year=" . $exam->getYear() . "; id=" . $exam->getId() . "] has been submitted by " . $ip . " on " . date('Y-m-d H:i:s') . ".";
                     helperFunctions::sendEmailNotice("Exam Submission", $msg);
                     echo "<input type='text' id='status' value='Success'/>";
                 } catch (Exception $e) {
                     echo "<input type='text' id='status' value='Saving'/>";
                     // send error email
                     helperFunctions::sendEmailNotice("Exam Submission Error", $e->getMessage());
                 }
             } else {
                 echo "<input type='text' id='status' value='Moving'/>";
             }
         } else {
             echo "<input type='text' id='status' value='PDF'/>";
         }
         return sfView::NONE;
     } else {
         $this->forward404();
     }
 }
Пример #15
0
 public function preExecute()
 {
     if (!helperFunctions::isLoggedIn(sfContext::getInstance()->getRequest())) {
         $this->redirect("siteadmin/login");
     }
 }
Пример #16
0
 /**
  * 
  * @param $rawTime e.g. T1500
  * @return array(weekday, time);
  */
 private function decipherTime($rawTime)
 {
     $weekday = substr($rawTime, 0, 1);
     $time = substr($rawTime, 1, 4);
     return array(helperFunctions::translateWeekDayAbbrv($weekday), $time);
 }
Пример #17
0
        ?>
			
			<!-- exam -->
			<div class='popupmenu' id='subExam' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
				<?php 
        if (!isset($examYearArray) || count($examYearArray) == 0) {
            ?>
					<a>None Available</a>
				<?php 
        } else {
            ?>
					<?php 
            foreach ($examYearArray as $year) {
                ?>
					<?php 
                echo link_to(helperFunctions::translateTerm($year), "course/exam?id=" . $courseId . "&year=" . $year);
                ?>
					<?php 
            }
            ?>
				<?php 
        }
        ?>
				<a onclick='grayout("submitExam");'>Submit Exams</a>
			</div>
			<dd class='pointer' onmouseover='mopen("subExam")' onmouseout='mclosetime()'>
			<?php 
        if ($menuOption == subMenuOptions::COURSE_EXAM) {
            ?>
Exams Repository<?php 
        } else {
Пример #18
0
<?php

include_partial("global/submenu", array("menuOption" => subMenuOptions::COURSE_EXAM, "courseId" => $courseObj->getId(), "ratingYearArray" => $ratingYearArray, "examYearArray" => $examYearArray));
?>
<div id="main"><div id="critique_content">
	<h2><?php 
echo $courseObj->getId();
?>
 (<?php 
echo $courseObj->getDescr();
?>
)</h2>
	<h3>Exams Repository of <?php 
echo helperFunctions::translateTerm($year);
?>
</h3>

	<?php 
if (isset($examArr)) {
    ?>
	<div class="critique_block">
		<div class="box">
			<div class="title_bar">Exams</div>
			<ul>
			  <?php 
    foreach ($examArr as $subArr) {
        ?>
			  <li><a href='/<?php 
        echo $subArr["path"];
        ?>
' target='_blank'><?php 
Пример #19
0
 public function executeSearchByProgram(sfWebRequest $request)
 {
     $conn = Propel::getConnection();
     $today = getdate();
     $this->searchType = searchActions::SEARCH_BY_PROGRAM;
     $rawProgList = DisciplinePeer::doSelectAll($conn);
     $this->programList = array();
     foreach ($rawProgList as $obj) {
         $this->programList[$obj->getId()] = $obj->getDescr();
     }
     $this->yearList = array("0" => "All", "1" => "First Year", "2" => "Second Year", "3" => "Third Year", "4" => "Fourth Year");
     if ($request->hasParameter("year") && $request->hasParameter("program")) {
         $this->programId = $request->getParameter("program");
         if (helperFunctions::isMaliciousString($this->programId)) {
             $this->forward404();
         }
         $this->year = $request->getParameter("year");
         if (helperFunctions::isMaliciousString($this->year)) {
             $this->forward404();
         }
         // get result set
         $discipline = DisciplinePeer::retrieveByPK($this->programId, $conn);
         if (!is_object($discipline)) {
             $this->forward404();
         }
         $this->resultTitle = "Results for " . $discipline->getDescr();
         $this->results = CoursePeer::findCoursesByDisciplineIdAndYear($this->programId, $this->year, $conn);
     } else {
         $this->programId = $rawProgList[0]->getId();
         $this->year = 1;
     }
 }
Пример #20
0
		<th width="100">Applies To</th>
		<th width="100">Course</th>
		<th width="150">Criterion</th>
		<th width="150">Rating</th>
		<th width="150">Number</th>
	</tr>
	<?php 
foreach ($matchedData as $row) {
    ?>
	<tr>
		<td><?php 
    echo link_to(" ", "course/index", array("class" => "select", "title" => "Select to edit"));
    ?>
</td>
		<td><?php 
    echo helperFunctions::translateTerm($row->getCourseInstructorAssociation()->getYear());
    ?>
</td>
		<td><?php 
    echo $row->getCourseInstructorAssociation()->getCourseId();
    ?>
</td>
		<td><?php 
    echo $row->getRatingField()->getDescr();
    ?>
</td>
		<td>
			<?php 
    if ($row->getFieldId() == RatingFieldPeer::NUMBER_ENROLLED || $row->getFieldId() == RatingFieldPeer::NUMBER_RESPONDED) {
        ?>
			/
Пример #21
0
        ?>
	<?php 
        foreach ($commentList->getResults() as $commentObj) {
            ?>
	<div class="critique_block">
		<div class="box">
			<?php 
            $a = strtotime($commentObj->getInputDt());
            ?>
			<div class="title_bar">
				Submitted: <?php 
            echo date('M d, Y h:i A', $a);
            ?>
&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
				Applies To: <?php 
            echo helperFunctions::translateTerm($commentObj->getAppliesTo());
            ?>
			</div>
			<?php 
            echo $commentObj->getComment();
            ?>
		</div>
	</div>
	<?php 
        }
        ?>
	
	<div class="critique_block">
		<div class="box">
			<a class="btn" onclick="grayout('submitComment');">I would like to leave a comment for this course...</a>
		</div>
Пример #22
0
 private function setMeanAndMedian($arr)
 {
     $item = $arr["typeObj"];
     if ($item->getId() == EnumItemPeer::RATING_BOOLEAN) {
         $arr["mean"] = "N/A";
         $arr["median"] = "N/A";
     } elseif ($item->getParentId() == EnumItemPeer::RATING_SCALE) {
         $arr["mean"] = helperFunctions::findMean(1, $item->getDescr(), $arr);
         $arr["median"] = helperFunctions::findMedian(1, $item->getDescr(), $arr);
     } else {
         // FIXME type not supported
         throw new Exception("type not supported");
     }
     return $arr;
 }
Пример #23
0
 public function executeAjaxFetchValidationRequirements(sfWebRequest $request)
 {
     if (!$request->isXmlHttpRequest()) {
         $this->forward404();
     }
     echo "<script type='text/javascript'>";
     $criteria = RatingFieldPeer::doSelectAll();
     $counter = 0;
     foreach ($criteria as $criterion) {
         $enum = $criterion->getEnumItem();
         echo "validation_requirements[{$counter}]=new Array(); \n      \tvalidation_requirements[{$counter}][0]=0;validation_requirements[{$counter}][1]=\"{$criterion->getDescr()}\";validation_requirements[{$counter}][4]=0;";
         if ($enum->getId() == EnumItemPeer::RATING_BOOLEAN) {
             echo "validation_requirements[{$counter}][2]=2;validation_requirements[{$counter}][3]=1;";
         } elseif ($enum->getId() != EnumItemPeer::RATING_NUMBER) {
             $end = intval($enum->getDescr()) - 1;
             echo "validation_requirements[{$counter}][2]={$enum->getDescr()};validation_requirements[{$counter}][3]=", helperFunctions::sum(0, $end), ";";
         }
         $counter++;
     }
     echo "validateAndSaveMappings();</script>";
     return sfView::NONE;
 }