function getMyStellar()
{
    // read the cookie, and create three groups
    // first group all the classes in the cookie
    // second group is the classes for the current semester
    // third group is the classes from previou semesters
    if (!isset($_COOKIE["mystellar"])) {
        $allTags = array();
    } else {
        $term = StellarData::get_term();
        $allTags = explode(",", $_COOKIE["mystellar"]);
        natsort($allTags);
    }
    $currentTags = array();
    $currentIds = array();
    $oldIds = array();
    foreach ($allTags as $classTag) {
        $parts = explode(" ", $classTag);
        if ($parts[1] == $term) {
            $currentTags[] = $classTag;
            $currentIds[] = $parts[0];
        } else {
            $oldIds[] = $parts[0];
        }
    }
    return (object) array("allTags" => $allTags, "currentTags" => $currentTags, "currentIds" => $currentIds, "oldIds" => $oldIds);
}
Пример #2
0
while($daemon->sleep(STELLAR_FEED_CACHE_TIMEOUT)) {
  db::ping();  //make sure the db keeps running

  $term = StellarData::get_term();
  $subject_ids = StellarData::check_subscriptions($term);

  foreach($subject_ids as $subject_id) {
    $announcements = StellarData::get_announcements($subject_id);

    if(count($announcements) > 0 ) {
      $notification_types = array(
	'apple' => new StellarAppleNotification($subject_id, $announcements)
      );

      foreach(StellarData::subscriptions_for_subject($subject_id, $term) as $subscription) {
        $notification_types[$subscription['device_type']]->queue_notification($subscription['device_id']);
      }
    }
  }
}
 
$daemon->stop();

Class StellarNotification {
  protected $announcements;
  protected $subject_id;
  
  public function __construct($subject_id, $announcements) {
    $this->subject_id = $subject_id;
    $this->announcements = $announcements;
Пример #3
0
  private static function get_announcements_xml($subjectId) {
    if (self::$feedCache === NULL) {
      self::$feedCache = new DiskCache(
        STELLAR_FEED_DIR, STELLAR_FEED_CACHE_TIMEOUT, true);
      self::$feedCache->preserveFormat();
    }

    if (self::$feedCache->isFresh($subjectId))
      return self::$feedCache->read($subjectId);
    
    $subjectData = self::get_subject_info($subjectId);
    if (array_key_exists('stellarUrl', $subjectData)) {
      $rss_id = $subjectData['stellarUrl'];
      $rss = file_get_contents(self::$rss_url . $rss_id);
      self::$feedCache->write($rss, $subjectId);
      return $rss;
    } else { // no feed because no stellarUrl
      return FALSE;
    }
  }
Пример #4
0
<?php
$docRoot = getenv("DOCUMENT_ROOT");

require_once $docRoot . "/mobi-config/mobi_web_constants.php";
require_once WEBROOT . "page_builder/page_header.php";
require_once LIBDIR . "StellarData.php";
require_once WEBROOT . "stellar/stellar_lib.php";

function selfURL() {
  return "course.php?id=" . $_REQUEST['id'] . '&back=' . $_REQUEST['back'];
}

$id = $_REQUEST['id'];
$back = $_REQUEST['back'];
$Back = ucwords($back);

$course = StellarData::get_course($id);
$classes = StellarData::get_subjects_with_xref($id);

require "$page->branch/course.html";
$page->output();
    
?>
Пример #5
0
<?php

require_once "../config/mobi_web_constants.php";
require_once PAGE_HEADER;
require_once LIBDIR . "StellarData.php";
require_once "stellar_lib.php";
function selfURL()
{
    $start = $_REQUEST["start"] ? (int) $_REQUEST["start"] : 0;
    $query = http_build_query(array("filter" => $_REQUEST['filter'], "start" => $start));
    return "search.php?{$query}";
}
$classes = StellarData::search_subjects($_REQUEST['filter']);
// if exactly one class is found redirect to that
// classes detail page
if (count($classes) == 1) {
    header("Location: " . detailURL($classes[0], selfURL()));
    die;
}
$content = new ResultsContent("items", "stellar", $page);
require "{$page->branch}/search.html";
$page->output();
Пример #6
0
  // tab options for Touch/Basic pages
  $tabs->hide('News');
  $tabs->hide('Staff');
  $tabs_html = $tabs->html($page->branch);
  $tab = $tabs->active();

  require "$page->branch/detail.html";

} else {
  // tab options for Touch/Basic pages
  $tabs_html = $tabs->html($page->branch);
  $tab = $tabs->active();

  $stellar_url = stellarURL($class);
  $announcements = StellarData::get_announcements($class_id);
  $has_news = count($announcements) > 0;
  $has_old_news = count($announcements) > 5;

  //start session (used to save class details)
  session_start();
  $_SESSION['class'] = $class;
  $_SESSION['announcements'] = $announcements;

  if($_REQUEST['all']) {
    $all = true;
    $items = $announcements;
  } else {
    $all = false;
    $items = array_slice($announcements, 0, 5);
  }
    $device_type = $_REQUEST['device_type'];       
    $subject = $_REQUEST['subject'];
    $term = $_REQUEST['term'];

    if($device_type == 'apple') {
      if(!APNS_DB::verify_device_id($device_id, $pass_key)) {
	Throw new Exception("invalid {$pass_key} for {$device_id}");
      }
    } else {
      Throw new Exception("Device type='${device_type}' not yet supported");
    }

    switch($_REQUEST['action']) {
    case 'subscribe':
      StellarData::push_subscribe($subject, $term, $device_id, $device_type);
      $data = array('success' => True);
      break;
    case 'unsubscribe':
      StellarData::push_unsubscribe($subject, $term, $device_id, $device_type);
      $data = array('success' => True);
      break;
    }

  default:
    break;
  }
}

echo json_encode($data);

?>
Пример #8
0
<?
$docRoot = getenv("DOCUMENT_ROOT");

require_once $docRoot . "/mobi-config/mobi_lib_constants.php";
require_once(LIBDIR . "StellarData.php");

StellarData::init();

//print_r(StellarData::get_courses());
//print_r(StellarData::get_subjects(7));
//StellarData::get_subjects(99);
//print_r(StellarData::get_announcements_xml(7.012));
//var_dump(StellarData::get_subject_id('7.012'));
//print_r(StellarData::get_subject_info('7.012'));
StellarData::push_subscribe('99.999', 'dummy');
print_r(StellarData::$subscriptions);
//print_r(StellarData::get_announcements('7.012'));
StellarData::push_unsubscribe('99.999', 'dummy');
print_r(StellarData::$subscriptions);


''

?>
Пример #9
0
<?
$docRoot = getenv("DOCUMENT_ROOT");

require_once $docRoot . "/mobi-config/mobi_web_constants.php";
require_once(LIBDIR . 'StellarData.php');
StellarData::init();

$uid = $_REQUEST['uid'];
$subject = $_REQUEST['subject'];

if (isset($_REQUEST['subscribe'])) {
  StellarData::push_subscribe($subject, $uid);
} elseif (isset($_REQUEST['unsubscribe'])) {
  StellarData::push_unsubscribe($subject, $uid);
}


?>
Пример #10
0
<?php

require_once "../config/mobi_web_constants.php";
require_once PAGE_HEADER;
require_once LIBDIR . "StellarData.php";
require_once "stellar_lib.php";
$which = $_REQUEST['which'];
if ($which == "other") {
    $courses = StellarData::get_others();
    $title = "Other Courses";
} else {
    $all_courses = StellarData::get_courses();
    $drill = new DrillNumeralAlpha($which, "key");
    $courses = $drill->get_list($all_courses);
    $title = "Courses {$which}";
}
require "{$page->branch}/courses.html";
$page->output();