Example #1
0
    protected function initReport()
    {
        $quarter = SiteApplication::initVar('quarter', null, SiteApplication::VAR_GET);
        if ($quarter === null || preg_match('/^2[0-9]{3}-0[1-4]$/', $quarter) === 0) {
            throw new AdminNotFoundException('Invalid quarter.');
        }
        list($year, $quarter) = explode('-', $quarter, 2);
        $start_month = (intval($quarter) - 1) * 3 + 1;
        $quarter = new SwatDate();
        $quarter->setTime(0, 0, 0);
        $quarter->setDate($year, $start_month, 1);
        $quarter->setTZ($this->app->default_time_zone);
        $quarter->toUTC();
        $type = SiteApplication::initVar('type', null, SiteApplication::VAR_GET);
        $provider = new CMEProvider();
        $provider->setDatabase($this->app->db);
        if (!$provider->loadByShortname($type)) {
            throw new AdminNotFoundException('Invalid CME provider.');
        }
        $sql = sprintf('select * from QuizReport
			where quarter = %s and provider = %s', $this->app->db->quote($quarter->getDate(), 'date'), $this->app->db->quote($provider->id, 'integer'));
        $this->report = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('CMEQuizReportWrapper'))->getFirst();
        if (!$this->report instanceof CMEQuizReport) {
            throw new AdminNotFoundException(sprintf('Report not found for quarter %s.', $quarter->getDate()));
        }
        $this->report->setFileBase('../../system/quiz-report-updater');
        if (!file_exists($this->report->getFilePath())) {
            throw new AdminNotFoundException(sprintf('Report file ‘%s’ not found', $this->report->getFilePath()));
        }
    }
Example #2
0
 protected function initInternal()
 {
     parent::initInternal();
     $this->ui->loadFromXML($this->ui_xml);
     $this->id = SiteApplication::initVar('id');
     $this->initTag();
 }
Example #3
0
 protected function initInternal()
 {
     parent::initInternal();
     $this->parent = SiteApplication::initVar('parent');
     $form = $this->ui->getWidget('order_form');
     $form->addHiddenField('parent', $this->parent);
 }
Example #4
0
 /**
  * Creates a new Atom post page
  *
  * @param SiteWebApplication $app the application.
  * @param SiteLayout $layout
  * @param string $dimension_shortname
  */
 public function __construct(SiteWebApplication $app, SiteLayout $layout, array $arguments = array())
 {
     $layout = new SiteLayout($app, 'Site/layouts/xhtml/atom.php');
     parent::__construct($app, $layout, $arguments);
     $tags = SiteApplication::initVar('tags');
     $this->createTagList($tags);
     $this->dimension = $this->initDimension($this->getArgument('dimension_shortname'));
 }
Example #5
0
 protected function initInternal()
 {
     parent::initInternal();
     $this->id = SiteApplication::initVar('id');
     $this->ui->loadFromXML($this->getUiXml());
     $this->initNewsletter();
     $this->updateNewsletterStats();
 }
Example #6
0
 protected function initFrontMatter()
 {
     if ($this->isNew()) {
         $front_matter_id = SiteApplication::initVar('front-matter');
         $class_name = SwatDBClassMap::get('CMEFrontMatter');
         $this->credit->front_matter = new $class_name();
         $this->credit->front_matter->setDatabase($this->app->db);
         if (!$this->credit->front_matter->load($front_matter_id)) {
             throw new AdminNotFoundException(sprintf('A CME front matter with the id of ‘%s’ does not ' . 'exist.', $front_matter_id));
         }
     }
 }
Example #7
0
 protected function loadPost()
 {
     $id = SiteApplication::initVar('id');
     $post_class = SwatDBClassMap::get('BlorgPost');
     $this->post = new $post_class();
     $this->post->setDatabase($this->app->db);
     if (!$this->post->load($id)) {
         throw new AdminNotFoundException(sprintf(Blorg::_('A post with an id of ‘%d’ does not exist.'), $id));
     }
     $instance_id = $this->post->getInternalValue('instance');
     if ($instance_id !== $this->app->getInstanceId()) {
         throw new AdminNotFoundException(sprintf(Blorg::_('A post with an id of ‘%d’ does not exist.'), $id));
     }
 }
Example #8
0
 protected function initInternal()
 {
     parent::initInternal();
     $this->id = SiteApplication::initVar('id');
     $this->initTag();
     $this->ui->loadFromXML($this->ui_xml);
     $instance_id = $this->app->getInstanceId();
     $this->ui->getWidget('passphrase_field')->visible = $this->app->config->pinhole->passphrase === null;
     // setup tag entry control
     $this->ui->getWidget('tags')->setApplication($this->app);
     $this->ui->getWidget('tags')->setAllTags();
     // setup status list
     $status_flydown = $this->ui->getWidget('status_flydown');
     $status_flydown->addOptionsByArray(PinholePhoto::getStatuses());
 }
 protected function getJSONResponse()
 {
     // remember per-question timestamps to handle race conditions
     if (!isset($this->app->session->quiz_question_timestamp)) {
         $this->app->session->quiz_question_timestamp = new ArrayObject();
     }
     $quiz_question_timestamp = $this->app->session->quiz_question_timestamp;
     $transaction = new SwatDBTransaction($this->app->db);
     try {
         if (!$this->app->session->isLoggedIn()) {
             return $this->getErrorResponse('Not logged in.');
         }
         $account = $this->app->session->account;
         $quiz = $this->getQuiz($this->getProgress($this->getCredits()));
         if (!$quiz instanceof CMEQuiz) {
             return $this->getErrorResponse('Quiz not found.');
         }
         $binding_id = SiteApplication::initVar('binding_id', null, SiteApplication::VAR_POST);
         if ($binding_id === null) {
             return $this->getErrorResponse('Question binding not specified.');
         }
         $binding = $this->getQuestionBinding($quiz, $binding_id);
         $timestamp = SiteApplication::initVar('timestamp', null, SiteApplication::VAR_POST);
         if ($timestamp === null) {
             return $this->getErrorResponse('Timestamp not specified.');
         }
         if (isset($quiz_question_timestamp[$binding_id]) && $timestamp < $quiz_question_timestamp[$binding_id]) {
             return $this->getErrorResponse('Request is out of sequence.');
         }
         $quiz_question_timestamp[$binding_id] = $timestamp;
         $option_id = SiteApplication::initVar('option_id', null, SiteApplication::VAR_POST);
         if ($option_id === null) {
             return $this->getErrorResponse('Response option id not specified.');
         }
         $response = $this->getResponse($quiz);
         $response_value = $this->getResponseValue($quiz, $response, $binding, $option_id);
         if ($response_value === null) {
             return $this->getErrorResponse('Response option id not valid for the specified question.');
         }
         $this->saveResponseValue($response, $response_value);
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollback();
         throw $e;
     }
     return array('status' => array('code' => 'ok', 'message' => ''), 'timestamp' => time());
 }
Example #10
0
 protected function initPhoto()
 {
     $id = SiteApplication::initVar('id');
     $class_name = SwatDBClassMap::get('PinholePhoto');
     $this->photo = new $class_name();
     $this->photo->setDatabase($this->app->db);
     if ($id === null) {
         throw new AdminNoAccessException(Pinhole::_('A Photo id is required.'));
     } else {
         $instance_id = $this->app->getInstanceId();
         if (!$this->photo->load($id)) {
             throw new AdminNotFoundException(sprintf(Pinhole::_('Photo with id “%s” not found.'), $id));
         } elseif ($this->photo->image_set->instance !== null && $this->photo->image_set->instance->id != $instance_id) {
             throw new AdminNotFoundException(sprintf(Pinhole::_('Photo with id “%s” loaded ' . 'in the wrong instance.'), $id));
         }
     }
 }
Example #11
0
 protected function initInternal()
 {
     $this->ui_xml = dirname(__FILE__) . '/merge.xml';
     parent::initInternal();
     $id = SiteApplication::initVar('id', null, SiteApplication::VAR_GET);
     if ($id !== null) {
         $this->setItems(array($id));
     }
     if (count($this->items) != 1) {
         throw new SiteNotFoundException('Only 1 id at a time!');
     }
     foreach ($this->items as $item) {
         $id = $item;
     }
     $this->source_tag = $this->getTag($id);
     $this->ui->getWidget('dst_tag')->setApplication($this->app);
     $this->ui->getWidget('dst_tag')->setAllTags();
 }
Example #12
0
 protected function initInternal()
 {
     AdminIndex::initInternal();
     $this->id = SiteApplication::initVar('id');
     if (is_numeric($this->id)) {
         $this->id = intval($this->id);
     }
     $this->initCredit();
     $this->initInquisition();
     $this->ui->loadFromXML($this->getUiXml());
     $local_ui = new SwatUI();
     $local_ui->loadFromXML($this->getCreditDetailsViewXml());
     $provider_titles = array();
     foreach ($this->credit->front_matter->providers as $provider) {
         $provider_titles[] = $provider->credit_title_plural;
     }
     $local_ui->getWidget('details_view')->getField('hour')->title = SwatString::toList($provider_titles);
     $view = $this->ui->getWidget('details_view');
     foreach ($local_ui->getWidget('details_view')->getFields() as $field) {
         $view->appendField($field);
     }
 }
 protected function buildForm(SwatForm $form)
 {
     parent::buildForm($form);
     $email = SiteApplication::initVar('email');
     if (strlen($email) > 0) {
         $this->ui->getWidget('email')->value = $email;
     } elseif (!$form->isProcessed() && $this->app->session->isLoggedIn()) {
         $this->ui->getWidget('email')->value = $this->app->session->account->email;
     }
 }
Example #14
0
 protected function initInternal()
 {
     parent::initInternal();
     $this->post_id = SiteApplication::initVar('post_id', null, SiteApplication::VAR_GET);
     $this->form_unique_id = SiteApplication::initVar('form_unique_id', null, SiteApplication::VAR_GET);
 }
Example #15
0
 /**
  * Display an ad
  *
  * If $config->blorg->ad_referers_only is true, the referer's domain is
  * checked against the site's domain to ensure the page has been arrived at
  * via another site.
  *
  * @param SiteApplication $app The current application
  * @param string $ad_type The type of ad to display
  */
 public static function displayAd(SiteApplication $app, $type)
 {
     $type_name = 'ad_' . $type;
     if ($app->config->blorg->{$type_name} != '') {
         $base_href = $app->getBaseHref();
         $referer = SiteApplication::initVar('HTTP_REFERER', null, SiteApplication::VAR_SERVER);
         // Display ad if referers only is off OR if there is a referer and
         // it does not start with the app base href.
         if (!$app->config->blorg->ad_referers_only || $referer !== null && strncmp($referer, $base_href, strlen($base_href)) != 0) {
             echo '<div class="ad">';
             echo $app->config->blorg->{$type_name};
             echo '</div>';
         }
     }
 }
Example #16
0
 public function __construct(SiteApplication $app, SiteLayout $layout = null, array $arguments = array())
 {
     parent::__construct($app, $layout, $arguments);
     $tags = SiteApplication::initVar('tags');
     $this->createTagList($tags);
 }
Example #17
0
 protected function isPreSelected(CMEFrontMatter $front_matter)
 {
     $selected = SiteApplication::initVar('selected', null, SiteApplication::VAR_GET);
     return is_array($selected) && in_array($front_matter->id, $selected);
 }
Example #18
0
 protected function getCacheKey($method_name, array $args = array())
 {
     /*
     both (string)$this and the tag get var are needed to make the cache
     key unique. We need the get var for page tags that are removed, and
     $this->tags for when the tag list is duplicated and manipulated.
     */
     $tags = SiteApplication::initVar('tags');
     return sprintf('PinholeTagList.%s.%s.%s.%s.%s', (string) $this, (string) $tags, $method_name, md5(serialize($args)), $this->show_private_photos ? 'private' : 'public');
 }
Example #19
0
 protected function initInternal()
 {
     parent::initInternal();
     $this->id = SiteApplication::initVar('id');
     $this->initTag();
 }