示例#1
0
 /**
  * @param array $isbns        array of potentially invalid 10 or 13-digit ISBNs
  * @param array $slugs        array of potentially invalid Section slugs
  */
 public function __construct($isbns, $sectionSlugs = array(), $schoolSlug = '', $termSlug = '', $campusSlug = '')
 {
     global $tag, $school, $vendors, $state, $defaultTag;
     $this->isbns = array_map('Isbn::to13', $isbns);
     $this->sectionSlugs = $sectionSlugs;
     $this->schoolSlug = $schoolSlug;
     $this->campusSlug = $campusSlug;
     $this->termSlug = $termSlug;
     $school = SchoolQuery::create()->findOneBySlug($this->schoolSlug);
     // 1 query
     // process school
     if ($school) {
         $tag = $school->getAmazonTag();
         // uses session tag if set
         $this->bookstore = $school->getBookstoreType();
         $vendors[array_search('Bookstore', $vendors)] = $this->bookstore;
         $state = $school->getState();
     } else {
         if ($schoolSlug) {
             throw new GetchabooksError("Unknown school slug: {$schoolSlug}");
         } else {
             $this->sectionSlugs = null;
             $tag = isset($_SESSION['tag']) ? $_SESSION['tag'] : $defaultTag;
             unset($vendors[array_search('Bookstore', $vendors)]);
             $state = null;
         }
     }
     if ($this->schoolSlug) {
         $this->spiderSections();
     }
     $this->fetchData();
     $this->makePackages();
 }
 public function campuses($school)
 {
     $school = SchoolQuery::create()->findOneBySlug($school);
     if ($school) {
         $school->spider(2);
         echo json_encode($school->getCampusSelect());
     } else {
         throw new AjaxError("Expected item doesn't exist.");
     }
 }
示例#3
0
 /**
  * Sets the slug, checking for duplicates and appending a number to make it unique if they exist.
  */
 public function setSlug($slug, $i = 0)
 {
     $preExisting = SchoolQuery::create();
     if ($this->getId()) {
         $preExisting->where('School.Id != ?', $this->getId());
     }
     $preExisting->filterBySlug($i ? $slug . $i : $slug);
     if ($preExisting->findOne()) {
         $this->setSlug($slug, $i + 1);
     } else {
         parent::setSlug($i ? $slug . $i : $slug)->save();
     }
     return $this;
 }
示例#4
0
 /**
  * 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(SchoolPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = SchoolQuery::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;
     }
 }
示例#5
0
<?php

/**
 * dump [--reset]
 *
 * Dump the current state of the schools table to XML.
 */
$reset = in_array('--reset', $argv);
$xmlDir = BASE_DIR . '/config';
$attributes = array('Name', 'ShortName', 'Slug', 'State', 'Zip', 'LocalTax', 'AmazonTag', 'Subdomain', 'BId');
$xmls = array();
$schools = SchoolQuery::create()->orderBy('Slug')->find();
foreach ($schools as $school) {
    $bookstore = $school->getBookstoreType();
    $xml = "";
    if (!$school->getEnabled()) {
        $xml .= "<!--";
    }
    $xml .= "\t<school>\n";
    foreach ($attributes as $a) {
        if ($a == 'AmazonTag' && $school->getAmazonTag() == 'txtbks-20') {
            continue;
        }
        $xml .= "\t\t<{$a}>" . htmlentities(call_user_func(array($school, "get{$a}"))) . "</{$a}>\n";
    }
    $xml .= "\t</school>\n";
    if (!$school->getEnabled()) {
        $xml .= "-->";
    }
    if (!isset($xmls[$bookstore])) {
        $xmls[$bookstore] = "<schools>\n";
示例#6
0
#****************************************************************************
#*  Retrieving post vars and scrubbing the data
#****************************************************************************
if (isset($_POST["page"])) {
    $currentPageNmbr = $_POST["page"];
} else {
    $currentPageNmbr = 1;
}
$searchType = $_POST["searchType"];
$searchText = trim($_POST["searchText"]);
# remove redundant whitespace
$searchText = preg_replace('/\\s+/', " ", $searchText);
#****************************************************************************
#*  Search database
#****************************************************************************
$sclQ = new SchoolQuery();
$sclQ->setItemsPerPage(OBIB_ITEMS_PER_PAGE);
$sclQ->connect();
$sclQ->execSearch($searchType, $searchText, $currentPageNmbr);
#**************************************************************************
#*  Show member view screen if only one result from barcode query
#**************************************************************************
if ($searchType == "schoolCode" && $sclQ->getRowCount() == 1) {
    $scl = $sclQ->fetchMember();
    $sclQ->close();
    header("Location: ../circ/scl_view.php?sclid=" . U($scl->getSchoolid()) . "&reset=Y");
    exit;
}
#**************************************************************************
#*  Show search results
#**************************************************************************
示例#7
0
/* This file is part of a copyrighted work; it is distributed with NO WARRANTY.
 * See the file COPYRIGHT.html for more details.
 */
require_once "../functions/inputFuncs.php";
require_once '../classes/DmQuery.php';
require_once '../classes/SchoolQuery.php';
require_once '../classes/School.php';
$dmQ = new DmQuery();
$dmQ->connect();
$mbrClassifyDm = $dmQ->getAssoc('mbr_classify_dm');
$customFields = $dmQ->getAssoc('member_fields_dm');
$dmQ->close();
$gender = array(OBIB_GENDER_MALE => "Male", OBIB_GENDER_FEMALE => "Female");
$standardlevel = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10);
$standardGrade = array('' => 'none', 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E', 'F' => 'F', 'G' => 'G', 'H' => 'H', 'I' => 'I', 'J' => 'J', 'K' => 'K', 'L' => 'L', 'M' => 'M', 'N' => 'N', 'O' => 'O', 'P' => 'P', 'Q' => 'Q', 'R' => 'R', 'S' => 'S', 'T' => 'T', 'U' => 'U', 'V' => 'V', 'W' => 'W', 'X' => 'X', 'Y' => 'Y', 'Z' => 'Z');
$scQ = new SchoolQuery();
$scQ->connect();
$schoolList = $scQ->getSchoolList();
$scQ->close();
$fields = array("mbrFldsClassify" => inputField('select', 'classification', $mbr->getClassification(), NULL, $mbrClassifyDm), "mbrFldsLastName" => inputField('text', "lastName", $mbr->getLastName()), "mbrFldsFirstName" => inputField('text', "firstName", $mbr->getFirstName()), "mbrFldsGender" => inputField('select', "gender", $mbr->getGender(), Null, $gender), "mbrFldsSchool" => inputField('select', "school", $mbr->getSchoolId(), Null, $schoolList), "mbrFldsStandard" => inputField('select', "standard", $mbr->getStandard(), Null, $standardlevel), "mbrFldsStandardGrade" => inputField('select', "grade", $mbr->getGrade(), Null, $standardGrade), "mbrFldsSchoolTeacher" => inputField('text', "schoolTeacher", $mbr->getSchoolTeacher()), "mbrFldsParentName" => inputField('text', "parentname", $mbr->getParentName()), "mbrFldsParentOccupation" => inputField('text', "parentoccupation", $mbr->getParentOccupation()), "mbrFldsMotherTongue" => inputField('text', "mothertongue", $mbr->getMotherTongue()), "mbrFldsEmail" => inputField('text', "email", $mbr->getEmail()), "Mailing Address:" => inputField('textarea', "address", $mbr->getAddress()), "mbrFldsHomePhone" => inputField('text', "homePhone", $mbr->getHomePhone()), "mbrFldsWorkPhone" => inputField('text', "workPhone", $mbr->getWorkPhone()));
foreach ($customFields as $name => $title) {
    $fields[$title . ':'] = inputField('text', 'custom_' . $name, $mbr->getCustom($name));
}
?>

<table class="primary">
  <tr>
    <th colspan="2" valign="top" nowrap="yes" align="left">
      <?php 
echo H($headerWording);
?>
示例#8
0
<?php

/**
 * json
 *
 * Regenerate schools.json
 */
$schools = SchoolQuery::create()->filterByEnabled(1)->orderBy('School.Name', 'asc')->find();
$rows = array();
foreach ($schools as $school) {
    $rows[] = array('name' => $school->getName(), 'nickname' => $school->getShortName(), 'slug' => $school->getSlug());
}
$json = json_encode($rows);
file_put_contents(BASE_DIR . '/config/schools.json', $json);
$gbCache->set('schooljson', $json);
示例#9
0
$scl->setSchoolAddress($_POST["schoolAddress"]);
$_POST["schoolAddress"] = $scl->getSchoolAddress();
$scl->setContactNumber($_POST["contactNumber"]);
$_POST["contactNumber"] = $scl->getContactNumber();
$scl->setcontactPerson($_POST["contactPerson"]);
$_POST["contactPerson"] = $scl->getContactPerson();
$scl->setEmail($_POST["email"]);
$_POST["email"] = $scl->getEmail();
$validData = $scl->validateData();
if (!$validData) {
    $pageErrors["schoolName"] = $scl->getSchoolNameError();
    $_SESSION["postVars"] = $_POST;
    $_SESSION["pageErrors"] = $pageErrors;
    header("Location: ../circ/scl_new_form.php");
    exit;
}
#**************************************************************************
#*  Insert new library school
#**************************************************************************
$sclQ = new SchoolQuery();
$sclQ->connect();
$sclid = $sclQ->insert($scl);
$sclQ->close();
#**************************************************************************
#*  Destroy form values and errors
#**************************************************************************
unset($_SESSION["postVars"]);
unset($_SESSION["pageErrors"]);
$msg = $loc->getText("sclNewSuccess");
header("Location: ../circ/scl_view.php?sclid=" . U($sclid) . "&reset=Y&msg=" . U($msg));
exit;
示例#10
0
 /**
  * Get the associated School object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     School The associated School object.
  * @throws     PropelException
  */
 public function getSchool(PropelPDO $con = null)
 {
     if ($this->aSchool === null && $this->school_id !== null) {
         $this->aSchool = SchoolQuery::create()->findPk($this->school_id, $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->aSchool->addCampuss($this);
         		 */
     }
     return $this->aSchool;
 }
示例#11
0
 public static function addSchools()
 {
     $class = get_called_class();
     decho("Adding schools for {$class}");
     foreach (static::getSchools() as $data) {
         print_r($data);
         $school = SchoolQuery::create()->filterByBookstoreType($class)->filterBySubdomain($data['Subdomain'])->findOne();
         if (!$school) {
             $school = new School();
             $school->setBookstoreType($class)->setSubdomain($data['Subdomain']);
         }
         $school->setSlug($data['Slug'])->setName($school->getName() ?: $data['Name'])->setShortName($school->getShortName(true) ?: (isset($data['ShortName']) ? $data['ShortName'] : School::guessShortName($data['Name'], $data['Slug'])))->setTouched(1)->save();
     }
 }
 /**
  * Returns a new SchoolQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    SchoolQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof SchoolQuery) {
         return $criteria;
     }
     $query = new SchoolQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
示例#13
0
<?php

$term = '201130';
require_once __DIR__ . '/../functions.php';
$school = SchoolQuery::create()->filterBySlug('northeastern')->findOne();
// update departments
$depts = curl_post("https://bnr8ssbp.neu.edu/udcprod8/bwckctlg.p_disp_cat_term_date", array('call_proc_in' => 'bwckctlg.p_disp_dyn_ctlg', 'cat_term_in' => $term));
preg_match("/sel_dept.+?\\/SELECT/s", $depts, $matches);
preg_match_all("/VALUE\\=\"(.+?)\"\\>(.+?)\\</s", $matches[0], $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
    $dept = DeptQuery::create()->filterBySchool($school)->filterByAbbr($m[1])->findOne();
    if ($dept) {
        $dept->setName($m[2])->save();
    }
}
$courses = CourseQuery::create()->filterBySchool($school)->find();
foreach ($courses as $c) {
    $result = curl_get("https://bnr8ssbp.neu.edu/udcprod8/bwckctlg.p_disp_course_detail?" . "cat_term_in={$term}&subj_code_in=" . $c->getDept()->getAbbr() . "&crse_numb_in=" . $c->getNum());
    if (preg_match('/' . $c->getDept()->getAbbr() . '\\s' . $c->getNum() . '\\s\\-\\s(.+?)\\</', $result, $matches)) {
        echo $c->getDept()->getAbbr() . $c->getNum() . "\n";
        $c->setName(htmlspecialchars_decode($matches[1]))->save();
    }
    $url = "https://bnr8ssbp.neu.edu/udcprod8/bwckctlg.p_disp_listcrse?term_in={$term}&subj_in=" . $c->getDept()->getAbbr() . "&crse_in=" . $c->getNum() . "&schd_in=";
    $sections = curl_get($url);
    if (preg_match_all("/(\\d{5})\\s\\-\\s.+?Instructors\\:\\s\\<\\/SPAN\\>(.+?)(?:\\<|\\()/s", $sections, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $m) {
            $section = SectionQuery::create()->filterByCourse($c)->filterByNum($m[1])->findOne();
            if ($section) {
                $section->setProfessor(trim($m[2]))->save();
            }
        }
示例#14
0
<?php

require_once __DIR__ . "/../functions.php";
$departments = array("ACC" => "Accounting", "AHF" => "Arts & Humanities Foundation", "AMS" => "American Studies", "ART" => "Art", "ASM" => "Advanced Strategic Management", "BPR" => "Business Practicum Program", "BRC" => "BRIC", "CGE" => "Cross-Registration Courses", "CHN" => "Chinese", "COM" => "Communications", "CVA" => "Culture and Values", "CXD" => "Offshore Course", "ECN" => "Economics", "ENG" => "English", "EPS" => "Entrepreneurship", "EXC" => "Babson Study Abroad", "FIN" => "Finance", "FLM" => "Film", "FME" => "Foundation of Management & Entrepreneurship (FME)", "FRN" => "French", "FYS" => "First-Year Seminar", "GDR" => "Gender Studies", "HIS" => "History", "HSF" => "History & Society Foundation", "HSS" => "History & Society", "IMH" => "Honors Seminar", "IND" => "Independent Research", "JPN" => "Japanese", "LAW" => "Law", "LIB" => "Liberal Arts", "LIT" => "Literature", "LVA" => "Literature & Visual Arts", "MBA" => "MBA", "MCE" => "Managing in a Competitive Environment (MCE)", "MDS" => "Media Studies", "MFE" => "Management Consulting Field Experience (MCFE)", "MIS" => "Management Information Systems", "MKT" => "Marketing", "MOB" => "Management", "OEM" => "Organizing for Effective Management (OEM)", "OLIN" => "Olin College of Engineering Cross Registration", "OPS" => "Operations", "PHL" => "Philosophy", "PHO" => "Photography", "POL" => "Politics", "PRF" => "Performing Arts", "PSA" => "Petition Study Abroad", "PSY" => "Psychology", "QTM" => "Quantitative Methods", "RHT" => "Rhetoric", "SCN" => "Science", "SPN" => "Spanish", "TAX" => "Taxes", "VSA" => "Visual Arts", "WRT" => "Writing");
$school = SchoolQuery::create()->findOneBySlug('babson');
// update departments
$depts = DeptQuery::create()->filterBySchool($school)->find();
foreach ($depts as $d) {
    if (isset($departments[$d->getAbbr()])) {
        $d->setName($departments[$d->getAbbr()])->save();
    }
}
// update courses
$term = "Spring+2011";
$url1 = "http://fusionmx.babson.edu/CourseListing/index.cfm?fuseaction=CourseListing.DisplayCourseListing&blnShowHeader=false&program=Graduate&semester={$term}&sort_by=course_number&btnSubmit=Display+Courses";
$url2 = "http://fusionmx.babson.edu/CourseListing/index.cfm?fuseaction=CourseListing.DisplayCourseListing&blnShowHeader=false&program=Undergraduate&semester={$term}&sort_by=course_number&btnSubmit=Display+Courses";
$result = curl_get($url2) . curl_get($url1);
preg_match_all("/85\"\\>([A-Z]+)(\\d+)\\-([A-Z\\d]+)\\<\\/td\\>.+?400\\);\"\\>(.+?)\\<\\/a.+?nowrap\"\\>(.+?),.+?\\<\\/span/s", $result, $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
    unset($m[0]);
    print_r($m);
    $dept = DeptQuery::create()->filterBySchool($school)->filterByAbbr($m[1])->findOne();
    if (!$dept) {
        continue;
    }
    $course = CourseQuery::create()->filterByDept($dept)->filterByNum(ltrim($m[2], '0'))->findOne();
    if (!$course) {
        continue;
    }
    $name = preg_replace("/\\(.+\\)\$/", "", $m[4]);
    $course->setName(formatCourseName($name))->save();
示例#15
0
<?php

require_once __DIR__ . "/../../base/propel.php";
require_once __DIR__ . "/../../spider/curl.php";
$term = "2011_1";
$school = SchoolQuery::create()->filterBySlug('columbia')->findOne();
$sections = SectionQuery::create()->joinWith('Section.Course')->joinWith('Course.Dept')->filterBySchool($school)->orderBy('Section.Slug')->find();
$sections->populateRelation('SectionHasItem');
foreach ($sections as $section) {
    $itemsByAuthor = array();
    foreach ($section->getSectionHasItems() as $shi) {
        $itemsByAuthor[trim(strtolower($shi->getItem()->getAuthor()))] = $shi->getItem();
    }
    echo $section->getSlug() . ", number of items in db : " . count($itemsByAuthor) . "\n";
    $url = "https://courseworks.columbia.edu/cms/public/intro_out.cfm?crs=" . $section->getCourse()->getDept()->getAbbr() . $section->getCourse()->getNum() . '_' . $section->getNum() . '_' . $term;
    $result = curl_get($url);
    preg_match_all("/\\<tr.*?\\>.*?\\<\\/tr\\>/s", $result, $matches);
    $idsAlreadyTaken = array();
    $requireType = null;
    foreach ($matches[0] as $match) {
        if (preg_match("/\\<strong\\>(.*?)\\<\\/strong\\>/", $match, $ms)) {
            if ($ms[1] == "Recommended") {
                $requireType = SectionHasItem::REQUIRED;
            } else {
                if ($ms[1] == "Required") {
                    $requireType = SectionHasItem::RECOMMENDED;
                }
            }
        }
        if (preg_match_all("/\\<td.*?\\>(.*?)\\<\\/td\\>/", $match, $ms)) {
            if (count($ms[1]) != 7) {
 /**
  * Finds the related School objects and keep them for later
  *
  * @param PropelPDO $con A connection object
  */
 protected function findRelatedSchools($con)
 {
     $criteria = clone $this;
     if ($this->useAliasInSQL) {
         $alias = $this->getModelAlias();
         $criteria->removeAlias($alias);
     } else {
         $alias = '';
     }
     $this->schools = SchoolQuery::create()->joinCampus($alias)->mergeWith($criteria)->find($con);
 }
示例#17
0
<?php

$bc = SchoolQuery::create()->filterBySlug('bc')->findOne();
$campuses = $bc->getCampuss();
$currentTerm = $campuses[0]->getCurrentTerm();
$depts = array('01' => array('BI' => 'Biology', 'BK' => 'African and African Diaspora Studies', 'CH' => 'Chemistry', 'CL' => 'Classical Studies', 'CO' => 'Communication', 'CS' => 'Computer Science', 'CT' => 'Theater', 'EC' => 'Economics', 'EN' => 'English', 'FA' => 'Fine Arts/Art History', 'FM' => 'Film Studies', 'FS' => 'Fine Arts/Studio Art', 'GE' => array('Earth and Environmental Sciences', 'Earth and Environmental Sciences'), 'GM' => 'Germanic Studies', 'HP' => 'Honors Program', 'HS' => 'History', 'IC' => 'Islamic Civilization and Societies', 'IN' => 'International Studies', 'MT' => 'Mathematics', 'MU' => 'Music', 'PH' => 'Physics', 'PL' => 'Philosophy', 'PO' => 'Political Science', 'PS' => 'Psychology', 'RL' => 'Romance Languages/Literatures', 'SC' => 'Sociology', 'SL' => 'Slavic and Eastern Languages', 'TH' => 'Theology', 'UN' => 'University Courses and Capstone'), '04' => array('LL' => 'Law'), '05' => array('AD' => 'Administrative Studies', 'BA' => array('Advancing Studies/Accounting', 'adv studies/accounting'), 'BF' => array('Advancing Studies/Finance', 'adv studies/finance'), 'BI' => 'Biology', 'BL' => array('Advancing Studies/Law', 'adv studies/law'), 'BM' => array('Advancing Studies Management/Marketing', 'ad studies mgmnt/marketing'), 'CO' => 'Communication', 'EC' => 'Economics', 'ED' => 'Education', 'EN' => 'English', 'FA' => 'Fine Arts/Art History', 'GM' => 'Germanic Studies', 'HS' => 'History', 'LA' => array('Advancing Studies/Law', 'adv studies/law'), 'MT' => 'Mathematics', 'PL' => 'Philosophy', 'PO' => 'Political Science', 'PS' => 'Psychology', 'RL' => 'Romance Languages/Literatures', 'SC' => 'Sociology', 'TH' => 'Theology'), '06' => array('SW' => 'Social Work'), '07' => array('MA' => 'Accounting', 'MB' => array('Organizational Studies/Human Resource Management', 'organizatnl std/human res mgmt'), 'MD' => array('Operations, Information & Strategic Management', 'operations,information & strategic mgmt'), 'MF' => 'Finance', 'MH' => array('Undergrad Management Honors/Ethics', 'undergrad mgmt honors/ethics'), 'MI' => 'Information Systems', 'MJ' => 'Business Law', 'MK' => 'Marketing', 'MM' => array('Graduate Management Practice/International', 'grad mgmt practice/international')), '08' => array('NU' => 'Nursing'), '09' => array('ED' => 'Education', 'PY' => 'Education/Psychology'), '18' => array('TM' => 'Theology and Ministry'));
foreach ($depts as $schoolNum => $ds) {
    foreach ($ds as $abbr => $name) {
        if (is_array($name)) {
            $formatted = $name[0];
            $lookup = $name[1];
        } else {
            $formatted = $name;
            $lookup = strtolower($name);
        }
        $data = array('BUTNS' => '', 'DAYS' => 'A', 'DEPT' => "{$abbr}={$lookup}", 'DEPT00' => "", 'DEPT01' => "", 'DEPT05' => $schoolNum == '05' ? "{$abbr}={$lookup}" : "", 'DEPT07' => "", 'DEPT09' => "", 'EDIT.DEPT.ENTERED' => 'Select a department', 'EDIT.TERM.ENTERED' => 'Select a term', 'ETIME' => 'ALL', 'FORMNAME' => 'course.schedule', 'LEVEL' => 'A', 'PROF' => '', 'SCHOOL' => $schoolNum, 'STATUS' => 'A', 'STIME' => 'ALL', 'TERM' => '2012S', 'TITLE' => '');
        $result = Curl::post("https://agora.bc.edu/cgi-bin/uiscgi?wwmr", $data);
        // with course popup hyperlink
        $regex1 = "/\\<td\\>[^>]+?\\>([A-Z]{2})(.+?)(..)\\<.+?\\<td\\>.+?\\<td\\>.+?\\<td\\>.+?\\<td\\>(.+?)\\<\\/td\\>.+?\\<td\\>.+?\\<td\\>.+?\\<td\\>[^>]+?\\>(.+?)\\</s";
        // without course popup hyperlink
        $regex2 = "/\\<td\\>\\s*([A-Z]{2})([A-Z0-9]+?)([A-Z0-9]{2})\\<\\/td.+?\\<td\\>.+?\\<td\\>.+?\\<td\\>.+?\\<td\\>(.+?)\\<\\/td\\>.+?\\<td\\>.+?\\<td\\>.+?\\<td\\>[^>]+?\\>(.+?)\\</s";
        if (!preg_match_all($regex1, $result, $matches, PREG_SET_ORDER)) {
            preg_match_all($regex2, $result, $matches, PREG_SET_ORDER);
        }
        if (count($matches) > 1) {
            unset($matches[0]);
        }
        if (!$matches) {
            echo "No matches for {$schoolNum} {$abbr}.\n";
        }
        foreach ($matches as $m) {
示例#18
0
 * a depth of 2 (department-aware).
 *
 * If SCHOOL is the exact name of a bookstore type, then the department-aware 
 * spidering will be limited to schools of that bookstore type.
 *
 * If --disabled, even disabled schools will be spidered.
 */
$bookstore = @file_exists(BASE_DIR . "/models/Vendors/Bookstores/{$argv[1]}.php");
if (isset($argv[1]) && !$bookstore) {
    $school = SchoolQuery::create()->filterBySlug($argv[1])->findOne();
    if ($school) {
        $school->spider(4);
        $school->setTouched(1)->setEnabled(1)->save();
        $school->updateCourseInfo();
    } else {
        echo "Unknown school: {$argv[1]}\n";
    }
} else {
    $schools = SchoolQuery::create();
    if ($bookstore) {
        $schools->filterByBookstoreType($argv[1]);
    }
    if (!in_array('--disabled', $argv)) {
        $schools->filterByEnabled(1);
    }
    foreach ($schools->find() as $school) {
        $school->setTouched(0)->save();
        $school->spider(2);
        $school->setTouched(1)->save();
    }
}
示例#19
0
 function getSchoolCode($schoolid)
 {
     $sclq = new SchoolQuery();
     $sclq->connect();
     $school = $sclq->get($schoolid);
     return $school->getSchoolCode();
 }
示例#20
0
$tab = "circulation";
$restrictToMbrAuth = TRUE;
$nav = "deletedone";
$restrictInDemo = true;
require_once "../shared/logincheck.php";
require_once "../classes/SchoolQuery.php";
require_once "../classes/School.php";
require_once "../functions/errorFuncs.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
$sclid = $_GET["sclid"];
$sclName = $_GET["name"];
#**************************************************************************
#*  Delete library member
#**************************************************************************
$sclQ = new SchoolQuery();
$sclQ->connect();
$sclQ->delete($sclid);
$sclQ->close();
#**************************************************************************
#*  Show success page
#**************************************************************************
require_once "../shared/header.php";
echo $loc->getText("sclDelSuccess", array("name" => $sclName));
?>
<br><br>
<a href="../circ/scl_index.php"><?php 
echo $loc->getText("sclDelReturn");
?>
</a>
<?php 
示例#21
0
require_once "../classes/SchoolQuery.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
$sclid = $_GET["sclid"];
#****************************************************************************
#*  Getting school name
#****************************************************************************
$sclQ = new SchoolQuery();
$sclQ->connect();
$scl = $sclQ->get($sclid);
$sclQ->close();
$sclName = $scl->getSchoolName();
#****************************************************************************
#*  Getting checkout count
#****************************************************************************
$sclQ = new SchoolQuery();
$sclQ->connect();
$deleteConfirm = $sclQ->deleteConfirm($sclid);
$sclQ->close();
#**************************************************************************
#*  Show confirm page
#**************************************************************************
require_once "../shared/header.php";
if (!$deleteConfirm) {
    ?>
<center>
  <?php 
    echo $loc->getText("sclDelConfirmWarn", array("name" => $sclName));
    ?>
  <br><br>
  <a href="../circ/scl_view.php?sclid=<?php 
示例#22
0
require_once "../shared/common.php";
session_cache_limiter(null);
$tab = "circulation";
$restrictToMbrAuth = TRUE;
$nav = "schoolEdit";
require_once "../functions/inputFuncs.php";
require_once "../shared/logincheck.php";
require_once "../classes/School.php";
require_once "../classes/SchoolQuery.php";
if (isset($_GET["sclid"])) {
    $sclid = $_GET["sclid"];
} else {
    require "../shared/get_form_vars.php";
    $sclid = $postVars["sclid"];
}
$sclQ = new SchoolQuery();
$sclQ->connect();
$scl = $sclQ->get($sclid);
$sclQ->close();
require_once "../shared/header.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
$headerWording = $loc->getText("sclEditForm");
$cancelLocation = "../circ/scl_view.php?sclid=" . $sclid . "&reset=Y";
?>

<form name="editSclform" method="POST" action="../circ/scl_edit.php">
<input type="hidden" name="sclid" value="<?php 
echo H($sclid);
?>
">
示例#23
0
$scl = new School();
$scl->setSchoolid($_POST["sclid"]);
//  $scl->setSchoolCode($_POST["schoolCode"]);
//  $_POST["schoolCode"] = $scl->getSchoolCode();
$scl->setLastChangeUserid($_SESSION["userid"]);
$scl->setSchoolName($_POST["schoolName"]);
$_POST["schoolName"] = $scl->getSchoolName();
$scl->setSchoolAddress($_POST["schoolAddress"]);
$_POST["schoolAddress"] = $scl->getSchoolAddress();
$scl->setContactNumber($_POST["contactNumber"]);
$_POST["contactNumber"] = $scl->getContactNumber();
$scl->setcontactPerson($_POST["contactPerson"]);
$_POST["contactPerson"] = $scl->getContactPerson();
$scl->setEmail($_POST["email"]);
$_POST["email"] = $scl->getEmail();
$sclQ = new SchoolQuery();
$sclQ->connect();
$validData = $scl->validateData();
if (!$validData) {
    $pageErrors["schoolName"] = $scl->getSchoolNameError();
    $_SESSION["postVars"] = $_POST;
    $_SESSION["pageErrors"] = $pageErrors;
    header("Location: ../circ/scl_new_form.php");
    exit;
}
#**************************************************************************
#*  Update library member
#**************************************************************************
$sclQ->update($scl);
$sclQ->close();
#**************************************************************************
示例#24
0
$dmQ->connect();
$mbrClassifyDm = $dmQ->getAssoc("mbr_classify_dm");
$mbrMaxFines = $dmQ->getAssoc("mbr_classify_dm", "max_fines");
$biblioStatusDm = $dmQ->getAssoc("biblio_status_dm");
$materialTypeDm = $dmQ->getAssoc("material_type_dm");
$materialImageFiles = $dmQ->getAssoc("material_type_dm", "image_file");
$memberFieldsDm = $dmQ->getAssoc("member_fields_dm");
$dmQ->close();
#****************************************************************************
#*  Search database for member
#****************************************************************************
$mbrQ = new MemberQuery();
$mbrQ->connect();
$mbr = $mbrQ->get($mbrid);
$mbrQ->close();
$sclQ = new SchoolQuery();
$sclQ->connect();
$sclName = $sclQ->getSchoolName($mbr->getSchoolId());
$sclQ->close();
#****************************************************************************
#*  Check for outstanding balance due
#****************************************************************************
$acctQ = new MemberAccountQuery();
$balance = $acctQ->getBalance($mbrid);
$balMsg = "";
if ($balance > 0 && $balance >= $mbrMaxFines[$mbr->getClassification()]) {
    $balText = moneyFormat($balance, 2);
    $balMsg = "<font class=\"error\">" . $loc->getText("mbrViewBalMsg", array("bal" => $balText)) . "</font><br><br>";
}
#**************************************************************************
#*  Show member information
示例#25
0
<?php

require_once "../functions.php";
$departments = array("AR" => "Art History/Architecture/Essentials of Art", "AS" => "Air Science", "BCB" => "Bioinformatics and Computational Biology", "BB" => "Biology", "CHE" => "Chemical Engineering", "CH" => "Chemistry", "CE" => "Civil Engineering", "CS" => "Computer Science", "ECE" => "Electrical and Computer Engineering", "EN" => "English", "GN" => "German", "HI" => "History", "HU" => "Humanities & Arts", "MU" => "Music", "PY" => "Philosophy", "RE" => "Religion", "WR" => "Writing", "SP" => "Spanish", "BUS" => "Business", "CPE" => "Corporate & Professional Education", "ECON" => "Economics", "ENV" => "Environmental Studies", "ES" => "Engineering Science", "ETR" => "Entrepreneurship", "EX" => "Exchange Program", "FIN" => "Finance", "FP" => "Fire Protection Engineering", "FY" => "First Year", "GE" => "Geology", "GOV" => "Political Science, Government and Law", "IMGD" => "Interactive Media and Game Development", "ISE" => "International Students (English)", "ID" => "Interdisciplinary", "MFE" => "Manufacturing Engineering", "MIS" => "Management Information Systems", "MKT" => "Marketing", "MTE" => "Material Science & Engineering", "MA" => "Mathematical Sciences", "ME" => "Mechanical Engineering", "MG" => "Management Communication", "ML" => "Military Leadership", "MME" => "Mathematics for Educators", "OBC" => "Organizational Behavior and Change", "OIE" => "Operations and Industrial Engineering", "PE" => "Physical Education", "PH" => "Physics", "RBE" => "Robotics Engineering", "SS" => "Social Science", "PSY" => "Psychology", "RH" => "Rhetoric", "SD" => "System Dynamics", "SOC" => "Sociology", "STS" => "Society & Technology Studies", "SP" => "Spanish", "SYS" => "Systems Engineering");
$school = SchoolQuery::create()->filterByBnSubdomain('wpi')->findOne();
// update departments
$url = "http://rewww.wpi.edu/academics/catalogs/ugrad/programdesc.html";
$url2 = "http://rewww.wpi.edu/academics/catalogs/grad/academ44.html";
$result = curl_get($url) . curl_get($url2);
preg_match_all("/title\\=\"(.+?)\" href\\=\".+\\/(.+)(dept)?\\.html\"/", $result, $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
    $abbr = str_replace("dept", "", $m[2]);
    $dept = DeptQuery::create()->filterBySchool($school)->filterByAbbr($abbr)->findOne();
    if ($dept) {
        $dept->setName(trim($m[1]))->save();
    }
}
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) {
示例#26
0
<?php

require_once __DIR__ . '/../functions.php';
$term = '1103';
$school = SchoolQuery::create()->filterBySlug('temple')->findOne();
$school->setDeptsToIgnore("CANCL TEXT")->save();
// temporarily, let's reset all the courses and sections' names and professors
//CourseQuery::create()->filterBySchool($school)->update(array('Name' => null));
//SectionQuery::create()->filterBySchool($school)->update(array('Professor' => null));
/**
 * key is the department abbreviation as it appears on bncollege.  Value is the name as it appears 
 * on the temple course catalog.  Value can be an array if the second value should be substituted
 * for the first value in our database.  But, 'And' => 'and' and 'Of' => 'of' happen automatically.
 */
$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) {
示例#27
0
<?php

/**
 * courseinfo SCHOOL
 *
 * CourseInfo updating happens automatically when a school is done fully 
 * spidering, but sometimes you might want to do it on its own.
 */
if (!isset($argv[1])) {
    die("No school provided.\n");
}
$school = SchoolQuery::create()->filterBySlug($argv[1])->findOne();
$school->updateCourseInfo();
    public function savePage()
    {
        global $app, $siteName, $siteUrl;
        $args = func_get_args();
        $in = array();
        if (count($args) == 5) {
            list($email, $school, $campus, $term, $ids) = $args;
        } else {
            list($email, $school, $term, $ids) = $args;
            $campus = null;
        }
        if (!$this->validate($email)) {
            echo "false";
            return;
        }
        $in['school'] = $school;
        $in['campus'] = $campus;
        $in['term'] = $term;
        $in['ids'] = htmlspecialchars($ids);
        if (!$school || $school == 'isbn') {
            $route = 'isbn_results';
        } else {
            if ($campus) {
                $route = 'multicampus_results';
            } else {
                $route = 'singlecampus_results';
            }
        }
        $url = $app->request()->getUrl() . $app->urlFor($route, $in) . '?saved';
        $numItems = count(explode(SECTION_DELIMITER, $ids));
        $numWithRegularNoun = function ($num, $noun) {
            return ($num > 1 ? cardinal($num) . ' ' : '') . $noun . ($num > 1 ? 's' : '');
        };
        if ($school == 'isbn') {
            $yourX = "your " . $numWithRegularNoun($numItems, 'book');
        } else {
            if ($school = SchoolQuery::create()->findOneBySlug($school)) {
                $schoolName = $school->getName();
                $yourX = "all your books for your " . $numWithRegularNoun($numItems, 'course') . " at {$schoolName}";
            } else {
                echo "false";
                return;
            }
        }
        $date = date('l, F j');
        $subject = "Your Textbooks at {$siteUrl}";
        $body = <<<END
Hey there,

Here's a link to {$yourX}:

{$url}

Use that link at any time to come back to {$siteName} and find the lowest prices for your textbooks.

Have a great semester! We'll see you soon.
--
You're receiving this email because on {$date}, someone visited {$siteUrl} and requested an email reminder with a link to their textbooks. If you feel you received this message in error, let us know by replying to this message. We'll make sure it doesn't happen again.
END;
        try {
            $this->sendMail($email, $subject, $body);
            echo "true";
        } catch (Exception $e) {
            echo "false";
            throw $e;
        }
    }
            $goodSchools[] = $school;
        } else {
            if ($shis->keepQuery()->count() >= 10) {
                echo "{$slug}: didn't find a suitable item, adding to bad schools\n";
                $badSchools[] = $school;
            } else {
                $unsureSchools[] = $school;
            }
        }
    }
    return array($goodSchools, $badSchools, $unsureSchools);
}
// BEGIN MAIN SCRIPT
$debug = true;
// identify schools which already have at least one section spidered with a book with an isbn
$schools = SchoolQuery::create()->orderBy('School.Slug', 'asc')->find();
list($goodSchools, $badSchools, $unsureSchools) = doMinimalTest($schools);
// randomly spider bad schools until we've found a section with an isbn or are pretty sure that the school doesn't list isbns
$newUnsureSchools = array();
foreach ($unsureSchools as $i => $school) {
    if (in_array($school->getSlug(), array('columbia'))) {
        $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));
示例#30
0
    if (libxml_get_errors()) {
        echo "Errors in {$abbr}-schools.xml, skipping.\n";
        continue;
    }
    foreach ($schools->school as $school) {
        if ($obj = SchoolQuery::create()->filterBySlug($school->Slug)->findOne()) {
            if ($bookstoreType != $obj->getBookstoreType()) {
                echo "Tried to add a school for a slug that already exists, skipping: {$school->Slug}\n";
                continue;
            } else {
                $obj->setTouched(true)->save();
            }
        }
        $query = SchoolQuery::create()->filterByBookstoreType($bookstoreType);
        $obj = $query->filterBySlug($school->Slug)->findOne();
        if (!$obj) {
            $obj = new School();
            $obj->setSlug($school->Slug)->setBookstoreType($bookstoreType);
            echo "Adding new school: {$school->Slug}\n";
        }
        $obj->setName(html_entity_decode($school->Name))->setShortName(html_entity_decode($school->ShortName))->setSlug($school->Slug)->setState($school->State)->setZip($school->Zip)->setLocalTax($school->LocalTax)->setAmazonTag($school->AmazonTag ?: 'txtbks-20')->setSubdomain($school->Subdomain)->setBId($school->BId)->setTouched(1)->setEnabled(1)->save();
    }
}
$untouchedSchools = SchoolQuery::create()->filterByTouched(false)->find();
foreach ($untouchedSchools as $school) {
    if ($school->getEnabled()) {
        echo "Disabling " . $school->getSlug() . "\n";
        $school->setEnabled(0)->save();
    }
}
require_once __DIR__ . '/json.php';