Esempio n. 1
0
    protected function getComments($limit = null, $offset = null)
    {
        $sql = sprintf('select BlorgComment.* from BlorgComment
			left outer join BlorgAuthor on BlorgComment.author = BlorgAuthor.id
			where %s
			order by createdate desc', $this->getWhereClause());
        $this->app->db->setLimit($limit, $offset);
        $wrapper = SwatDBClassMap::get('BlorgCommentWrapper');
        $comments = SwatDB::query($this->app->db, $sql, $wrapper);
        // efficiently load posts for all comments
        $instance_id = $this->app->getInstanceId();
        $post_sql = sprintf('select id, title, bodytext
			from BlorgPost
			where instance %s %s and id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $post_wrapper = SwatDBClassMap::get('BlorgPostWrapper');
        $comments->loadAllSubDataObjects('post', $this->app->db, $post_sql, $post_wrapper);
        // efficiently load authors for all comments
        $instance_id = $this->app->getInstanceId();
        $author_sql = sprintf('select id, name
			from BlorgAuthor
			where instance %s %s and id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $author_wrapper = SwatDBClassMap::get('BlorgAuthorWrapper');
        $comments->loadAllSubDataObjects('author', $this->app->db, $author_sql, $author_wrapper);
        return $comments;
    }
Esempio n. 2
0
    protected function loadData()
    {
        $tag_list = new PinholeTagList($this->app, $this->tag->name, true);
        $photos = $tag_list->getPhotos();
        $order_array = array();
        $class_name = SwatDBClassMap::get('PinholeImageSet');
        $set = new $class_name();
        $set->setDatabase($this->app->db);
        $set->instance = $this->app->getInstance();
        $set->loadByShortname('photos');
        $thumb = $set->getDimensionByShortname('thumb');
        foreach ($photos as $photo) {
            $image = new SwatImageDisplay();
            $image->image = $photo->getUri('thumb', '../');
            $image->width = $photo->getWidth('thumb');
            $image->height = $photo->getHeight('thumb');
            $image->occupy_width = $thumb->max_width;
            $image->occupy_height = $thumb->max_height;
            ob_start();
            $image->display();
            $order_array[$photo->id] = ob_get_clean();
        }
        $order_widget = $this->ui->getWidget('order');
        $order_widget->width = '580px';
        $order_widget->height = '400px';
        $order_widget->addOptionsByArray($order_array, 'text/xml');
        $sql = sprintf('select sum(displayorder) from PinholePhotoTagBinding
			where tag = %s', $this->app->db->quote($this->tag->id, 'integer'));
        $sum = SwatDB::queryOne($this->app->db, $sql, 'integer');
        $options_list = $this->ui->getWidget('options');
        $options_list->value = $sum == 0 ? 'auto' : 'custom';
    }
    protected function getPhoto($filename)
    {
        $sql = sprintf('select PinholePhoto.*
			from PinholePhoto
			inner join ImageSet on PinholePhoto.image_set = ImageSet.id
			where PinholePhoto.filename = %s and ImageSet.instance %s %s', $this->app->db->quote($filename, 'text'), SwatDB::equalityOperator($this->app->getInstanceId()), $this->app->db->quote($this->app->getInstanceId(), 'integer'));
        $wrapper_class = SwatDBClassMap::get('PinholePhotoWrapper');
        $photos = SwatDB::query($this->app->db, $sql, $wrapper_class);
        if (count($photos) == 0) {
            $instance = $this->app->getInstance();
            if ($instance === null) {
                $message = sprintf("Photo with filename '%s' does not exist.", $filename);
            } else {
                $message = sprintf("Photo with filename '%s' does not exist " . "in the instance '%s'.", $filename, $instance->shortname);
            }
            throw new SiteNotFoundException($message);
        }
        $photo = $photos->getFirst();
        if ($photo->private && !$this->app->session->isLoggedIn()) {
            $message = sprintf("Photo with filename '%s' is private and user " . "is not logged in.", $filename);
            throw new SiteNotFoundException($message);
        }
        $photo->setFileBase('../photos');
        return $photo;
    }
Esempio n. 4
0
    protected function buildInternal()
    {
        parent::buildInternal();
        $locale = SwatI18NLocale::get();
        $item_list = $this->getItemList('integer');
        $dep = new AdminListDependency();
        $dep->setTitle(CME::_('CME credit'), CME::_('CME credits'));
        $sql = sprintf('select CMECredit.*
			from CMECredit
			where CMECredit.id in (%s)', $item_list);
        $credits = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('CMECreditWrapper'));
        foreach ($credits as $credit) {
            $data = new stdClass();
            $data->id = $credit->id;
            $data->status_level = AdminDependency::DELETE;
            $data->parent = null;
            $data->title = $credit->getTitle();
            $dep->entries[] = new AdminDependencyEntry($data);
        }
        $message = $this->ui->getWidget('confirmation_message');
        $message->content = $dep->getMessage();
        $message->content_type = 'text/xml';
        if ($dep->getStatusLevelCount(AdminDependency::DELETE) === 0) {
            $this->switchToCancelButton();
        }
    }
 protected function init()
 {
     parent::init();
     $this->registerInternalProperty('instance', SwatDBClassMap::get('SiteInstance'));
     $this->table = 'NewsletterTemplate';
     $this->id_field = 'integer:id';
 }
Esempio n. 6
0
    /**
     * Creates a new tag
     *
     * @throws SwatException if no database connection is set on this tag
     *                        entry control.
     */
    protected function insertTag($title, $index)
    {
        if ($this->app === null) {
            throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.');
        }
        // check to see if the tag already exists
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select * from
			PinholeTag where lower(title) = lower(%s)
				and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('PinholeTagDataObjectWrapper'));
        // only insert if no tag already exists (prevents creating two tags on
        // reloading)
        if (count($tags) > 0) {
            $tag_obj = $tags->getFirst();
        } else {
            $tag_obj = new PinholeTagDataObject();
            $tag_obj->setDatabase($this->app->db);
            $tag_obj->instance = $instance_id;
            $tag_obj->title = $title;
            $tag_obj->save();
            $message = new SwatMessage(sprintf(Pinhole::_('“%s” tag has been added'), SwatString::minimizeEntities($tag_obj->title)));
            $message->content_type = 'text/xml';
            $message->secondary_content = sprintf(Pinhole::_('You can <a href="Tag/Edit?id=%d">edit this tag</a> ' . 'to customize it.'), $tag_obj->id);
            $this->app->messages->add($message);
        }
        $this->tag_array[$tag_obj->name] = $tag_obj->title;
        $this->selected_tag_array[$tag_obj->name] = $tag_obj->title;
    }
Esempio n. 7
0
 protected function init()
 {
     parent::init();
     $this->registerInternalProperty('post', SwatDBClassMap::get('BlorgPost'));
     $this->registerInternalProperty('author', SwatDBClassMap::get('BlorgAuthor'));
     $this->table = 'BlorgComment';
 }
Esempio n. 8
0
    /**
     * Creates a new tag
     *
     * @throws SwatException if no database connection is set on this tag
     *                        entry control.
     */
    protected function insertTag($title, $index)
    {
        if ($this->app === null) {
            throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.');
        }
        // check to see if the tag already exists
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select * from
			BlorgTag where lower(title) = lower(%s) and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgTagWrapper'));
        // only insert if no tag already exists (prevents creating two tags on
        // reloading)
        if (count($tags) > 0) {
            $tag = $tags->getFirst();
        } else {
            $tag = new BlorgTag();
            $tag->setDatabase($this->app->db);
            $tag->instance = $instance_id;
            $tag->title = $title;
            $tag->save();
            if (isset($this->app->memcache)) {
                $this->app->memcache->flushNs('tags');
            }
            $message = new SwatMessage(sprintf(Blorg::_('The tag “%s” has been added.'), $tag->title));
            $this->app->messages->add($message);
        }
        $this->tag_array[$tag->shortname] = $tag->title;
        $this->selected_tag_array[$tag->shortname] = $tag->title;
    }
 protected function init()
 {
     parent::init();
     $this->registerInternalProperty('instance', SwatDBClassMap::get('SiteInstance'));
     $this->table = 'MailingListCampaignSegment';
     $this->id_field = 'integer:id';
 }
Esempio n. 10
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()));
        }
    }
Esempio n. 11
0
 protected function init()
 {
     $this->table = 'CMECredit';
     $this->id_field = 'integer:id';
     $this->registerInternalProperty('front_matter', SwatDBClassMap::get('CMEFrontMatter'));
     $this->registerInternalProperty('quiz', SwatDBClassMap::get('CMEQuiz'));
 }
Esempio n. 12
0
    protected function getComments($limit = null, $offset = null)
    {
        $sql = sprintf('select PinholeComment.* from PinholeComment
			left outer join PinholePhotographer on PinholeComment.photographer = PinholePhotographer.id
			where %s
			order by createdate desc', $this->getWhereClause());
        $this->app->db->setLimit($limit, $offset);
        $wrapper = SwatDBClassMap::get('PinholeCommentWrapper');
        $comments = SwatDB::query($this->app->db, $sql, $wrapper);
        // efficiently load photos for all comments
        $instance_id = $this->app->getInstanceId();
        $photo_sql = sprintf('select PinholePhoto.*	from PinholePhoto
			inner join ImageSet on ImageSet.id = PinholePhoto.image_set
			where ImageSet.instance %s %s and PinholePhoto.id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $photo_wrapper = SwatDBClassMap::get('PinholePhotoWrapper');
        $comments->loadAllSubDataObjects('photo', $this->app->db, $photo_sql, $photo_wrapper);
        // efficiently load photographers for all comments
        $instance_id = $this->app->getInstanceId();
        $photographer_sql = sprintf('select id, fullname
			from PinholePhotographer
			where instance %s %s and id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        $photographer_wrapper = SwatDBClassMap::get('PinholePhotographerWrapper');
        $comments->loadAllSubDataObjects('photographer', $this->app->db, $photographer_sql, $photographer_wrapper);
        return $comments;
    }
Esempio n. 13
0
    protected function processDBData()
    {
        parent::processDBData();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        // delete attached files using their dataobjects to remove the actual
        // files
        $sql = sprintf('select * from BlorgFile
			inner join BlorgPost on BlorgPost.id = BlorgFile.post
			where BlorgPost.instance %s %s and BlorgFile.post in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $files = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgFileWrapper'));
        foreach ($files as $file) {
            $file->setFileBase('../');
            $file->delete();
        }
        // delete the posts
        $sql = sprintf('delete from BlorgPost
			where instance %s %s and id in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $num = SwatDB::exec($this->app->db, $sql);
        if (isset($this->app->memcache)) {
            $this->app->memcache->flushNS('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been deleted.', '%s posts have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
Esempio n. 14
0
    protected function buildInternal()
    {
        parent::buildInternal();
        $locale = SwatI18NLocale::get();
        $item_list = $this->getItemList('integer');
        $dep = new AdminListDependency();
        $dep->setTitle(CME::_('CME front matter'), CME::_('CME front matters'));
        $sql = sprintf('select CMEFrontMatter.id, sum(CMECredit.hours) as hours
			from CMEFrontMatter
			left outer join CMECredit
				on CMECredit.front_matter = CMEFrontMatter.id
			where CMEFrontMatter.id in (%s)
			group by CMEFrontMatter.id', $item_list);
        $rs = SwatDB::query($this->app->db, $sql);
        $class_name = SwatDBClassMap::get('CMEFrontMatter');
        foreach ($rs as $row) {
            $front_matter = new $class_name($row);
            $front_matter->setDatabase($this->app->db);
            $row->status_level = AdminDependency::DELETE;
            $row->parent = null;
            // not using ngettext because hours is a float
            $row->title = sprintf($row->hours == 1 ? CME::_('%s (1 hour)') : CME::_('%s (%s hours)'), $front_matter->getProviderTitleList(), $locale->formatNumber($row->hours));
            $dep->entries[] = new AdminDependencyEntry($row);
        }
        $message = $this->ui->getWidget('confirmation_message');
        $message->content = $dep->getMessage();
        $message->content_type = 'text/xml';
        if ($dep->getStatusLevelCount(AdminDependency::DELETE) === 0) {
            $this->switchToCancelButton();
        }
    }
Esempio n. 15
0
    protected function initPosts($shortname, $page)
    {
        $class_name = SwatDBClassMap::get('BlorgTag');
        $tag = new $class_name();
        $tag->setDatabase($this->app->db);
        if (!$tag->loadByShortname($shortname, $this->app->getInstance())) {
            throw new SiteNotFoundException('Page not found.');
        }
        $this->tag = $tag;
        $memcache = isset($this->app->memcache) ? $this->app->memcache : null;
        $this->loader = new BlorgPostLoader($this->app->db, $this->app->getInstance(), $memcache);
        $this->loader->addSelectField('title');
        $this->loader->addSelectField('bodytext');
        $this->loader->addSelectField('shortname');
        $this->loader->addSelectField('publish_date');
        $this->loader->addSelectField('author');
        $this->loader->addSelectField('comment_status');
        $this->loader->addSelectField('visible_comment_count');
        $this->loader->setLoadFiles(true);
        $this->loader->setLoadTags(true);
        $this->loader->setWhereClause(sprintf('enabled = %s and
			id in (select post from BlorgPostTagBinding where tag = %s)', $this->app->db->quote(true, 'boolean'), $this->app->db->quote($tag->id, 'integer')));
        $this->loader->setOrderByClause('publish_date desc');
        $offset = ($page - 1) * self::MAX_POSTS;
        $this->loader->setRange(self::MAX_POSTS, $offset);
        $this->posts = $this->loader->getPosts();
        if (count($this->posts) == 0) {
            throw new SiteNotFoundException('Page not found.');
        }
    }
    protected function getSegments()
    {
        $sql = 'select * from MailingListCampaignSegment
			where %s and instance %s %s';
        $sql = sprintf($sql, $this->force_all ? '1 = 1' : sprintf('enabled = %s', $this->db->quote(true, 'boolean')), SwatDB::equalityOperator($this->getInstanceId()), $this->db->quote($this->getInstanceId(), 'integer'));
        return SwatDB::query($this->db, $sql, SwatDBClassMap::get('DeliveranceCampaignSegmentWrapper'));
    }
Esempio n. 17
0
 /**
  * Deletes a file
  *
  * @param integer $file_id the id of the file to delete.
  *
  * @return boolean true.
  */
 public function delete($file_id)
 {
     $instance_id = $this->app->getInstanceId();
     if ($this->app->getInstance() === null) {
         $path = '../../files';
     } else {
         $path = '../../files/' . $this->app->getInstance()->shortname;
     }
     $class_name = SwatDBClassMap::get('BlorgFile');
     $file = new $class_name();
     $file->setDatabase($this->app->db);
     $file->setFileBase($path);
     if ($file->load(intval($file_id))) {
         if ($file->getInternalValue('instance') === $instance_id) {
             $file->delete();
         }
     }
     if ($file_id == $this->app->config->blorg->header_image) {
         $this->app->config->blorg->header_image = '';
     } else {
         $this->app->config->blorg->feed_logo = '';
     }
     $this->app->config->save();
     return true;
 }
 public function process()
 {
     // initialize authentication
     $auth = new Sabre_HTTP_DigestAuth();
     $auth->setRealm($this->app->config->site->auth_realm);
     $auth->init();
     // authenticate and get correct user
     $email = $auth->getUsername();
     $class_name = SwatDBClassMap::get('PinholeAdminUser');
     $user = new $class_name();
     $user->setDatabase($this->app->db);
     if (!$user->loadFromEmail($email) || !$auth->validateA1($user->digest_ha1)) {
         $auth->requireLogin();
         echo Pinhole::_('Authentication required') . "\n";
         exit;
     }
     // create directory for account and object tree for dav server
     $root = new PinholeDavDirectory($this->app, $user);
     $tree = new Sabre_DAV_ObjectTree($root);
     // create server
     $server = new Sabre_DAV_Server($tree);
     $server->setBaseUri($this->getDavBaseUri());
     // don't save temp files in the database
     $tempFilePlugin = new Sabre_DAV_TemporaryFileFilterPlugin($this->getDataDir('dav/temp'));
     $server->addPlugin($tempFilePlugin);
     // set up lock plugin
     $lockBackend = new Sabre_DAV_Locks_Backend_FS($this->getDataDir('dav/locks'));
     $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
     $server->addPlugin($lockPlugin);
     // also allow regular web browsing
     $browserPlugin = new Sabre_DAV_Browser_Plugin(false);
     $server->addPlugin($browserPlugin);
     // serve it up!
     $server->exec();
 }
Esempio n. 19
0
    protected function initComments($page)
    {
        // get comments for this page
        $this->comments = false;
        if (isset($this->app->memcache)) {
            $key = $this->getCommentsCacheKey();
            $this->comments = $this->app->memcache->getNs('posts', $key);
            /*
             * Note: The limit of comments per page is somewhat important here.
             * In extreme cases, we could run over the 1M size limit for cached
             * values. This would occur when every comment is close to the
             * maximum size in bodytext (8K) and the associated posts also have
             * a very large bodytext (about 8K each). In these rare cases,
             * caching will fail.
             */
        }
        if ($this->comments === false) {
            $sql = sprintf('select BlorgComment.* from BlorgComment %s where %s
				order by BlorgComment.createdate desc', $this->getJoinClause(), $this->getWhereClause());
            $offset = ($page - 1) * $this->getPageSize();
            $this->app->db->setLimit($this->getPageSize(), $offset);
            $wrapper = SwatDBClassMap::get('BlorgCommentWrapper');
            $this->comments = SwatDB::query($this->app->db, $sql, $wrapper);
            // efficiently load posts
            $post_wrapper = SwatDBClassMap::get('BlorgPostWrapper');
            $post_sql = 'select id, title, shortname, bodytext, publish_date
				from BlorgPost
				where id in (%s)';
            $this->comments->loadAllSubDataObjects('post', $this->app->db, $post_sql, $post_wrapper);
            // efficiently load authors
            $author_wrapper = SwatDBClassMap::get('BlorgAuthorWrapper');
            $author_sql = 'select id, name, shortname, email, visible
				from BlorgAuthor
				where id in (%s)';
            $this->comments->loadAllSubDataObjects('author', $this->app->db, $author_sql, $author_wrapper);
            if (isset($this->app->memcache)) {
                $this->app->memcache->setNs('posts', $key, $this->comments);
            }
        } else {
            $this->comments->setDatabase($this->app->db);
        }
        // if we're not on the first page and there are no comments, 404
        if ($page > 1 && count($this->comments) === 0) {
            throw new SiteNotFoundException('Page not found.');
        }
        // get total number of comments
        $this->total_count = false;
        if (isset($this->app->memcache)) {
            $total_key = $this->getTotalCountCacheKey();
            $this->total_count = $this->app->memcache->getNs('posts', $total_key);
        }
        if ($this->total_count === false) {
            $sql = sprintf('select count(1) from BlorgComment %s where %s', $this->getJoinClause(), $this->getWhereClause());
            $this->total_count = SwatDB::queryOne($this->app->db, $sql);
            if (isset($this->app->memcache)) {
                $this->app->memcache->setNs('posts', $total_key, $this->total_count);
            }
        }
    }
Esempio n. 20
0
 protected function getNewImageInstance()
 {
     $class_name = SwatDBClassMap::get('SiteImage');
     $image = new $class_name();
     $image->setDatabase($this->app->db);
     $image->image_set = $this->getImageSet();
     return $image;
 }
Esempio n. 21
0
 protected function getNewAttachmentInstance()
 {
     $class_name = SwatDBClassMap::get('SiteAttachment');
     $attachment = new $class_name();
     $attachment->setDatabase($this->app->db);
     $attachment->attachment_set = $this->getAttachmentSet();
     return $attachment;
 }
 protected function init()
 {
     $this->table = 'AccountEarnedCMECredit';
     $this->id_field = 'integer:id';
     $this->registerInternalProperty('account', SwatDBClassMap::get('CMEAccount'));
     $this->registerInternalProperty('credit', SwatDBClassMap::get('CMECredit'));
     $this->registerDateProperty('earned_date');
 }
Esempio n. 23
0
 protected function init()
 {
     $this->table = 'AccountCMEProgress';
     $this->id_field = 'integer:id';
     $this->registerInternalProperty('account', SwatDBClassMap::get('CMEAccount'));
     $this->registerInternalProperty('quiz', SwatDBClassMap::get('CMEQuiz'));
     $this->registerInternalProperty('evaluation', SwatDBClassMap::get('CMEEvaluation'));
 }
Esempio n. 24
0
    /**
     * Creates a new author index page
     *
     * @param SiteWebApplication $app the application.
     * @param SiteLayout $layout
     */
    public function __construct(SiteWebApplication $app, SiteLayout $layout, array $arguments = array())
    {
        parent::__construct($app, $layout, $arguments);
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('select * from BlorgAuthor
			where instance %s %s and visible = %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $this->app->db->quote(true, 'boolean'));
        $this->authors = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgAuthorWrapper'));
    }
Esempio n. 25
0
 protected function initFrontMatter()
 {
     $sql = sprintf('select * from CMEFrontMatter where evaluation = %s', $this->app->db->quote($this->inquisition->id, 'integer'));
     $this->front_matter = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('CMEFrontMatterWrapper'))->getFirst();
     if (!$this->front_matter instanceof CMEFrontMatter) {
         throw new AdminNotFoundException(sprintf('Evaluation with id of %s not found.', $this->id));
     }
 }
Esempio n. 26
0
 private function initTag()
 {
     $tag_class = SwatDBClassMap::get('BlorgTag');
     $this->tag = new $tag_class();
     $this->tag->setDatabase($this->app->db);
     if (!$this->tag->load($this->id)) {
         throw new AdminNotFoundException(sprintf(Blorg::_('Tag with id “%s” not found.'), $this->id));
     }
 }
Esempio n. 27
0
 protected function initCredit()
 {
     $class_name = SwatDBClassMap::get('CMECredit');
     $this->credit = new $class_name();
     $this->credit->setDatabase($this->app->db);
     if (!$this->credit->load($this->id)) {
         throw new AdminNotFoundException(sprintf('A CME credit with the id of ‘%s’ does not exist.', $this->id));
     }
 }
Esempio n. 28
0
 protected function initFile($filename)
 {
     $class_name = SwatDBClassMap::get('BlorgFile');
     $this->file = new $class_name();
     $this->file->setDatabase($this->app->db);
     if (!$this->file->loadByFilename($filename, $this->app->getInstance())) {
         throw new SiteNotFoundException('File not found.');
     }
 }
Esempio n. 29
0
 protected function initDataObject($id)
 {
     $class_name = SwatDBClassMap::get('BlorgComment');
     $this->data_object = new $class_name();
     $this->data_object->setDatabase($this->app->db);
     if (!$this->data_object->load($id)) {
         throw new AdminNotFoundException(sprintf('Comment with id ‘%s’ not found.', $id));
     }
 }
Esempio n. 30
0
 protected function initTag()
 {
     $class_name = SwatDBClassMap::get('BlorgTag');
     $this->tag = new $class_name();
     $this->tag->setDatabase($this->app->db);
     if (!$this->tag->loadByShortname($this->getArgument('shortname'), $this->app->getInstance())) {
         throw new SiteNotFoundException('Page not found.');
     }
 }