public function courses($department) { $dept = DeptQuery::create()->findPk($department); if ($dept) { $dept->spider(0); echo json_encode($dept->getCourseSelect()); } else { throw new AjaxError("Expected item doesn't exist."); } }
public function getDeptSelect() { $this->ensureConsistency(); $depts = DeptQuery::create()->filterByTerm($this)->withColumn('IF(Dept.Name IS NOT NULL, Dept.Name, Dept.Abbr)', 'DisplayName')->orderBy('DisplayName', 'asc')->orderBy('Dept.Abbr', 'asc')->find(); $r = array(); foreach ($depts as $d) { $r[] = array('name' => $d->getDisplayName(), 'id' => $d->getId()); } return $r; }
$badSchools[] = $school; continue; } if (in_array($school->getSlug(), array('jwu', 'ohiostate', 'puc', 'spu'))) { $badSchools[] = $school; continue; } deleteCookieFile(); echo $school->getSlug(); $sectionClass = str_replace('School', 'Section', get_class($school)); $sectionSpiderer = new $sectionClass(); $goodCount = 0; $itemsCount = 0; while (!$goodCount && $itemsCount <= 10) { // we should already be spidered down to the department level for all schools $dept = DeptQuery::create()->filterBySchool($school)->where('Dept.SpideredAt < ?', time() - 60)->orWhere('Dept.SpideredAt IS NULL')->withColumn('RAND()', 'rand')->orderBy('rand')->findOne(); if (!$dept) { echo "WTF\n"; break; } echo $dept->getAbbr(); Spiderer::spider($dept, true, 0); $course = CourseQuery::create()->filterByDept($dept)->where('Course.SpideredAt < ?', time() - 60)->orWhere('Course.SpideredAt IS NULL')->withColumn('RAND()', 'rand')->orderBy('rand')->findOne(); if (!$course) { echo "WTF\n"; break; } echo $course->getNum(); Spiderer::spider($course, true, 0); $section = SectionQuery::create()->filterByCourse($course)->where('Section.SpideredAt < ?', time() - 60)->orWhere('Section.SpideredAt IS NULL')->withColumn('RAND()', 'rand')->orderBy('rand')->findOne(); if (!$section) {
function updateDepartments() { global $school; //depts $depts = array('AFR' => "Africana Studies", 'ANTH' => "Anthropology", 'ARAB' => "Arabic", 'ARC' => "Academic Resource Center", 'ART' => "Studio Art", 'ARTH' => "Art History", 'AS' => "American Studies", 'BIO' => "Biology", 'BPI' => "Bard Prison Initiative", 'CHEM' => "Chemistry", 'CHI' => "Chinese", 'CLAS' => "Classical Studies", 'CMSC' => "Computer Science", 'DAN' => "Dance", 'ECON' => "Economics", 'EUS' => "Environmental and Urban Studies", 'FILM' => "Film and Electronic Arts", 'FIN' => "Finance", 'FREN' => "French", 'FYS' => "First-Year Seminar", 'GER' => "German", 'GRE' => "Greek", 'HEB' => "Hebrew", 'HIST' => "Historical Studies", 'HR' => "Human Rights", 'ITAL' => "Italian", 'JAPN' => "Japanese", 'JS' => "Jewish Studies", 'LAIS' => "Latin American and Iberian Studies", 'LAT' => "Latin", 'LIT' => "Literature", 'MATH' => "Mathematics", 'MUS' => "Music", 'PHIL' => "Philosophy", 'PHOT' => "Photography", 'PHYS' => "Physics", 'PS' => "Political Studies", 'PSY' => "Psychology", 'REL' => "Religion", 'RUS' => "Russian", 'SCI' => "Science", 'SOC' => "Sociology", 'SPAN' => "Spanish", 'SST' => "Social Studies", 'THEO' => "Theology", 'THTR' => "Theater"); foreach ($depts as $abbr => $name) { $dept = DeptQuery::create()->filterByAbbr($abbr)->useTermQuery()->useCampusQuery()->useSchoolQuery()->filterBySlug('bard')->endUse()->endUse()->endUse()->findOne(); if ($dept) { $dept->setName($name)->save(); } } }
/** * Get the associated Dept object * * @param PropelPDO Optional Connection object. * @return Dept The associated Dept object. * @throws PropelException */ public function getDept(PropelPDO $con = null) { if ($this->aDept === null && ($this->dept_b_id !== "" && $this->dept_b_id !== null)) { $this->aDept = DeptQuery::create()->filterByDeptMetadata($this)->findOne($con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aDept->addDeptMetadatas($this); */ } return $this->aDept; }
} foreach ($departments as $abbr => $name) { $dept = DeptQuery::create()->filterBySchool($school)->filterByAbbr($abbr)->findOne(); if ($dept) { $dept->setName($name)->save(); } } // update courses $term = '201101'; $url = "https://banner-as1.admin.wpi.edu/pls/prod/hwwkrnbw.P_GetDepts?sel_term={$term}&sel_ptrm=S&sel_level=01&sel_campus=x"; $result = curl_get($url) . curl_get(str_replace("level=01", "level=05", $url)); preg_match_all("/(\\/pls.+dept\\=([A-Z]+).+x)\"\\>(.+?)\\<\\/A\\>/", $result, $matches, PREG_SET_ORDER); echo "<pre>"; print_r($matches); foreach ($matches as $m) { $dept = DeptQuery::create()->filterBySchool($school)->filterByAbbr($m[2])->findOne(); if ($dept) { $dept->setName($m[3])->save(); } $url = "https://banner-as1.admin.wpi.edu" . $m[1]; $result = curl_get($url); /* <TD><A HREF="http://www.wpi.edu/Pubs/Catalogs/Ugrad/Current/ascourses.html#as1001">AS 1001</A> A01</TD> <TD>FOUNDATIONS OF US AIR FORCE I</TD> <TD> 1/9</TD> <TD>Lec</TD> <TD>--W--</TD> <TD>2:00-2:50</TD> <TD>HL202</TD> <TD><A HREF="http://www.wpi.edu/Pubs/Faculty/brk.html">Kaanta, Bryan R.</A></TD> *
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(DeptPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = DeptQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
$deptNames = array('ACCT' => 'Accounting', 'ACT SCI' => 'Actuarial Science', 'ADVERTISIN' => 'Advertising', 'AFR-AMER S' => 'African American Studies', 'AMER ST' => 'American Studies', 'ANTHRO' => 'Anthropology', 'AOD' => 'Adult And Organizational Development', 'ARABIC' => 'Arabic', 'ARCH' => 'Architecture', 'ART' => 'Art', 'ART ED' => 'Art Education', 'ART H' => 'Art History', 'ASIA ST' => 'Asian Studies', 'BIOLOGY' => 'Biology', 'BTMM' => 'Broadcast Telecom Mass Media', 'BUS' => 'Business', 'BUS ADM' => 'Business Administration', 'C+IN SC' => 'Computer + Information Science', 'C+R PLN' => 'Community & Regional Planning', 'CCET' => 'Civil + Construction Eng Tech', 'CHEM' => 'Chemistry', 'CHINESE' => 'Chinese', 'CIVIL ENG' => 'Civil Engineering', 'CN PSY' => 'Counseling Psychology', 'COMM SCI' => 'Comm Sciences + Disorders', 'COMM+TH' => 'Communications And Theater', 'CR LANG' => 'Critical Languages Center', 'CRIM JUSTI' => 'Criminal Justice', 'DANCE' => 'Dance', 'DISABILITY' => 'Disability Studies', 'EARTH/ENVI' => 'Earth & Environmental Science', 'ECH ED' => 'Early Childhood Education', 'ECON' => 'Economics', 'ED ADM' => 'Educational Administration', 'ED PSY' => 'Educational Psychology', 'EDUCATION' => 'Education', 'ELECTR ENG' => 'Electrical Engineering', 'ELEM ED' => 'Elementary Education', 'EN ED-E' => 'English Education, Elementary', 'EN ED-S' => 'English Education, Sec Ed', 'ENGLISH' => 'English', 'ENGRG' => 'Engineering', 'ENVIRO STD' => 'Environmental Studies', 'ENVT' => '', 'ET' => 'Engineering Technology', 'FINANCE' => 'Finance', 'FL ED-S' => 'Foreign Lang Ed, Secondary Ed', 'FMA' => 'Film And Media Arts', 'FOUNDATION' => 'Foundations', 'FRENCH' => 'French', 'GEN/STRA M' => '', 'GEOG' => 'Geography And Urban Studies', 'GERMAN' => 'German', 'GK+ROM CL' => 'Greek And Roman Classics', 'GREEK' => 'Greek', 'GREEK,ANC' => 'Greek Ancient', 'GREEK,MODE' => 'Greek, Modern', 'HEBREW' => 'Hebrew', 'HINDI' => 'Hindi', 'HISTORY' => 'History', 'HLTH INF M' => 'Health Information Management', 'HLTH RL PR' => 'Health Related Professions', 'HLTHCARE M' => 'Healthcare Management', 'HORT' => 'Horticulture', 'HUM RES MG' => 'Human Resource Management', 'IBA' => 'International Business Admin', 'IELP' => '', 'IH' => 'Intellectual Heritage', 'ITALIAN' => 'Italian', 'JAPANESE' => 'Japanese', 'JEWISH ST' => 'Jewish Studies', 'JOURNALISM' => 'Journalism', 'KINESIOLOG' => 'Kinesiology', 'KOREAN' => 'Korean', 'LANDSC' => 'Landscape Architecture', 'LATIN' => 'Latin', 'LATIN AM S' => 'Latin American Studies', 'LAW SBM' => 'Law S.B.M.', 'LESBIAN GB' => 'Lesbian Gay Bi & Tg St', 'LIB ARTS' => 'Liberal Arts', 'M ED-E' => 'Math Education, Elementary Ed', 'M ED-S' => 'Math Education, Secondary Ed', 'M L A' => 'Master Of Liberal Arts', 'MASSMEDIAC' => 'Mass Media And Communication', 'MATH' => 'Mathematics', 'MECH ENG' => 'Mechanical Engineering', 'MESSIAH' => '', 'MET' => 'Mechanical Engineering Technol', 'MGT INFO S' => 'Management Information Systems', 'MIL SCI' => 'Military Science', 'MKTG' => 'Marketing', 'MSOM' => 'Management Science/Oper Mgt', 'MUS ED' => 'Music Education', 'MUS ST' => 'Music Studies', 'MUSIC' => 'Music', 'NEUROSCI C' => 'Neuroscience - Cla', 'NURSING' => 'Nursing', 'OC THER' => 'Occupational Therapy', 'PHETE' => 'Phete', 'PHILOS' => 'Philosophy', 'PHYSICS' => 'Physics', 'POL SCI' => 'Political Science', 'PSYCH' => 'Psychology', 'PUBLIC HLT' => 'Public Health', 'REL' => 'Religion', 'RL EST' => 'Real Estate', 'RSK MGT +' => 'Risk Management And Insurance', 'RUSSIAN' => 'Russian', 'SC ED-E' => 'Science Education, Elementary', 'SC ED-S' => 'Science Education, Secondary E', 'SCH PSY' => 'School Psychology', 'SEC ED' => 'Secondary Education', 'SOC' => 'Sociology', 'SOC WRK GR' => 'Social Work Graduate', 'SOCWRK UND' => 'Social Work Undergrad', 'SPANISH' => 'Spanish', 'SPEC ED' => 'Special Education', 'SPEC ORD' => '', 'SS ED-E' => 'Social Studies Education, Elem', 'SS ED-S' => 'Social Studies Ed, Sec Ed', 'STAT' => 'Statistics', 'STRAT COMM' => 'Strategic Communications', 'STRATGIC M' => 'Strategic Management', 'TESOL' => 'Teach Engl Speakr Of Othr Lang', 'THEATER' => 'Theater', 'THERAP REC' => 'Therapeutic Recreation', 'TOUR HOS M' => 'Tourism & Hospitality Mgmt', 'UNIV SEMI' => 'Univ Seminar', 'URB ED' => 'Urban Education', 'VIETNAMESE' => 'Vietnamese', 'WOM STD' => 'Womens Studies'); function getDeptName($abbr, $fixed = false) { global $deptNames; if ($deptNames[$abbr]) { if (is_array($deptNames[$abbr])) { return $fixed && isset($deptNames[$abbr][1]) ? $deptNames[$abbr][1] : str_pad($deptNames[$abbr][0], 31); } else { return str_pad($deptNames[$abbr], 31); } } else { return false; } } // update departments $depts = DeptQuery::create()->filterBySchool($school)->find(); foreach ($depts as $dept) { $abbr = $dept->getAbbr(); if ($name = getDeptName($dept->getAbbr(), true)) { $dept->setName(trim($name))->save(); } } // update courses // sets term cookie curl_post("http://voyager.adminsvc.temple.edu/tucourses/tu_courses.asp", http_build_query(array('radSemester' => '1103', 'radCrseType' => 'All'))); foreach ($depts as $dept) { if ($name = getDeptName($dept->getAbbr())) { $params = http_build_query(array('lstCrsLevel' => 'All', 'radCampus' => 'All', 'lstDept' => $name, 'lstCredHrs' => 'All', 'radDivn' => 'All', 'radStatus' => 'All', 'lstReq' => 'All')) . "&Day1=&Day2=&Day3=&Day4=&Day5=&Day6=&Day7=&PrevCourse1B=&PrevTextCourse1B=&PrevCourse2B=" . "&PrevTextCourse2B=&PrevCourse3B=&PrevTextCourse3B=&PrevCourse4B=&PrevTextCourse4B=" . "&PrevCourse5B=&PrevTextCourse5B=&PrevCourse4B=&PrevTextCourse4B=&PrevCourse5B=&" . "PrevTextCourse5B=&browser=&host="; $result = curl_post("http://voyager.adminsvc.temple.edu/tucourses/tu_courseslist.asp", $params, array(CURLOPT_HTTPHEADER => array("Origin: http://voyager.adminsvc.temple.edu"))); //var_dump($result); //die();
/** * Returns the number of related Dept objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Dept objects. * @throws PropelException */ public function countDepts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if (null === $this->collDepts || null !== $criteria) { if ($this->isNew() && null === $this->collDepts) { return 0; } else { $query = DeptQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByTerm($this)->count($con); } } else { return count($this->collDepts); } }
/** * Returns a new DeptQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return DeptQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof DeptQuery) { return $criteria; } $query = new DeptQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }