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 function hasRatingData(PropelPDO $conn = null) { if ($conn === null) { $conn = Propel::getConnection(); } $c = new Criteria(); $c->add(AutoCourseRatingPeer::FIELD_ID, $this->getId()); $result = AutoCourseRatingPeer::doSelectOne($c, $conn); if ($result === null || !is_object($result)) { return false; } else { return true; } }
public static function getCourseDataArrayForCourseAndInstructorAndYear($courseId, $instructorId, $year, PropelPDO $propelConnection) { $c = new Criteria(); $c->addJoin(AutoCourseRatingPeer::COURSE_INS_ID, CourseInstructorAssociationPeer::ID); $crit1 = $c->getNewCriterion(CourseInstructorAssociationPeer::COURSE_ID, $courseId); $crit2 = $c->getNewCriterion(CourseInstructorAssociationPeer::YEAR, $year); $crit3 = $c->getNewCriterion(CourseInstructorAssociationPeer::INSTRUCTOR_ID, $instructorId); $c->addAnd($crit1); $c->addAnd($crit2); $c->addAnd($crit3); $c->addAscendingOrderByColumn(AutoCourseRatingPeer::FIELD_ID); $c->addAscendingOrderByColumn(AutoCourseRatingPeer::ID); $c->addAscendingOrderByColumn(AutoCourseRatingPeer::RATING); return AutoCourseRatingPeer::doSelect($c, $propelConnection); }
private function buildSubmenu(sfWebRequest $request) { if (!$request->hasParameter("id") || trim($request->getParameter("id")) == "") { $this->forward404(); } // set cookie to remember $id = $request->getParameter("id"); //$this->getResponse()->setCookie('courseId', $id); $conn = Propel::getConnection(); // get rating data $this->ratingYearArray = AutoCourseRatingPeer::getAvailableYearsForCourseId($id, $conn); // get exam data $this->examYearArray = ExamPeer::getAvailableYearsForCourseId($id, $conn); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this RatingField is new, it will return * an empty collection; or if this RatingField has previously * been saved, it will retrieve related AutoCourseRatings from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in RatingField. */ public function getAutoCourseRatingsJoinCourseInstructorAssociation($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(RatingFieldPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collAutoCourseRatings === null) { if ($this->isNew()) { $this->collAutoCourseRatings = array(); } else { $criteria->add(AutoCourseRatingPeer::FIELD_ID, $this->id); $this->collAutoCourseRatings = AutoCourseRatingPeer::doSelectJoinCourseInstructorAssociation($criteria, $con, $join_behavior); } } else { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(AutoCourseRatingPeer::FIELD_ID, $this->id); if (!isset($this->lastAutoCourseRatingCriteria) || !$this->lastAutoCourseRatingCriteria->equals($criteria)) { $this->collAutoCourseRatings = AutoCourseRatingPeer::doSelectJoinCourseInstructorAssociation($criteria, $con, $join_behavior); } } $this->lastAutoCourseRatingCriteria = $criteria; return $this->collAutoCourseRatings; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = AutoCourseRatingPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setFieldId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setRating($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setImportDt($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setCourseInsId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setNumber($arr[$keys[5]]); } }
public static function getMatchedRowsForDt($importDt, PropelPDO $conn = null) { if (!isset($conn)) { $conn = Propel::getConnection(); } $c = new Criteria(); $c->addJoin(AutoCourseRatingPeer::COURSE_INS_ID, CourseInstructorAssociationPeer::ID); $c->addJoin(AutoCourseRatingPeer::FIELD_ID, RatingFieldPeer::ID); $crit = $c->getNewCriterion(AutoCourseRatingPeer::IMPORT_DT, $importDt); $c->addAnd($crit); $c->addAscendingOrderByColumn(CourseInstructorAssociationPeer::YEAR); $c->addAscendingOrderByColumn(CourseInstructorAssociationPeer::COURSE_ID); $c->addAscendingOrderByColumn(RatingFieldPeer::ID); $c->addAscendingOrderByColumn(AutoCourseRatingPeer::RATING); return AutoCourseRatingPeer::doSelectJoinAll($c, $conn); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(AutoCourseRatingPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(AutoCourseRatingPeer::DATABASE_NAME); $criteria->add(AutoCourseRatingPeer::ID, $pks, Criteria::IN); $objs = AutoCourseRatingPeer::doSelect($criteria, $con); } return $objs; }
public function executeImportGood(sfWebRequest $request) { if (!$request->isMethod("post") || !$request->hasParameter("dt")) { $this->forward404("not enough parameters"); } $this->dt = $request->getParameter("dt"); $this->matchedData = AutoCourseRatingPeer::getMatchedRowsForDt($this->dt); }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = CourseInstructorAssociationPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related CourseRating objects $c = new Criteria(CourseRatingPeer::DATABASE_NAME); $c->add(CourseRatingPeer::COURSE_INS_ID, $obj->getId()); $affectedRows += CourseRatingPeer::doDelete($c, $con); // delete related AutoCourseRating objects $c = new Criteria(AutoCourseRatingPeer::DATABASE_NAME); $c->add(AutoCourseRatingPeer::COURSE_INS_ID, $obj->getId()); $affectedRows += AutoCourseRatingPeer::doDelete($c, $con); } return $affectedRows; }