Esempio n. 1
0
 protected function initAuthor()
 {
     $this->author = new BlorgAuthor();
     $this->author->setDatabase($this->app->db);
     if ($this->id !== null) {
         if (!$this->author->load($this->id)) {
             throw new AdminNotFoundException(sprintf(Blorg::_('Author with id ‘%s’ not found.'), $this->id));
         }
         $instance_id = $this->author->getInternalValue('instance');
         if ($instance_id !== $this->app->getInstanceId()) {
             throw new AdminNotFoundException(sprintf(Blorg::_('Author with id ‘%d’ not found.'), $this->id));
         }
     }
 }
Esempio n. 2
0
 protected function initAuthor($shortname)
 {
     $this->author = false;
     if (isset($this->app->memcache)) {
         $key = 'author_' . $shortname;
         $this->author = $this->app->memcache->getNs('authors', $key);
     }
     if ($this->author === false) {
         $class_name = SwatDBClassMap::get('BlorgAuthor');
         $this->author = new $class_name();
         $this->author->setDatabase($this->app->db);
         if (!$this->author->loadByShortname($shortname, $this->app->getInstance())) {
             throw new SiteNotFoundException('Author not found.');
         }
         if (!$this->author->visible) {
             throw new SiteNotFoundException('Author not found.');
         }
         if (isset($this->app->memcache)) {
             $this->app->memcache->setNs('authors', $key, $this->author);
         }
     } else {
         $this->author->setDatabase($this->app->db);
     }
 }