예제 #1
0
파일: Record.php 프로젝트: visapi/amun
 public function getFields()
 {
     $fields = parent::getFields();
     // add rights field
     $fields['rights'] = isset($this->rights) ? $this->rights : null;
     return $fields;
 }
예제 #2
0
파일: Record.php 프로젝트: visapi/amun
 public function getFields()
 {
     $fields = parent::getFields();
     // add folder field
     $fields['folder'] = isset($this->folder) ? $this->folder : null;
     return $fields;
 }
예제 #3
0
 public function notify($type, TableInterface $table, RecordInterface $record)
 {
     $handler = $this->hm->getHandler('AmunService\\Log', $this->user);
     $log = $handler->getRecord();
     $log->setRefId(isset($record->id) ? $record->id : 0);
     $log->setType(RecordAbstract::getType($type));
     $log->setTable($table->getName());
     $handler->create($log);
 }
예제 #4
0
파일: Record.php 프로젝트: visapi/amun
 public function setType($type)
 {
     $type = $this->_validate->apply($type, 'string', array(new Filter\InArray(RecordAbstract::getType())), 'type', 'Type');
     if (!$this->_validate->hasError()) {
         $this->type = $type;
     } else {
         throw new Exception($this->_validate->getLastError());
     }
 }
예제 #5
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->title);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, $this->authorProfileUrl);
             $entry->addLink($this->getUrl(), 'alternate', 'text/html');
             $entry->setContent($this->text, 'html');
             return $entry;
             break;
         case WriterInterface::JAS:
             $image = new ActivityStream\MediaLink();
             $image->setUrl($this->authorThumbnailUrl);
             $actor = new ActivityStream\Object();
             $actor->setObjectType('person');
             $actor->setDisplayName($this->authorName);
             $actor->setUrl($this->authorProfileUrl);
             $actor->setImage($image);
             $object = new ActivityStream\Object();
             $object->setObjectType('article');
             $object->setId('urn:uuid:' . $this->globalId);
             $object->setDisplayName($this->title);
             $object->setUrl($this->getUrl());
             $object->setPublished($this->getDate());
             $object->setContent($this->text);
             $activity = new ActivityStream\Activity();
             $activity->setActor($actor);
             $activity->setVerb('post');
             $activity->setObject($object);
             return $activity;
             break;
         default:
             return parent::export($result);
             break;
     }
 }
예제 #6
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->title);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor('System');
             $entry->addLink($this->getUrl(), 'alternate', 'text/html');
             $entry->setContent($this, 'application/xml');
             return $entry;
             break;
         default:
             return parent::export($result);
             break;
     }
 }
예제 #7
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::JSON:
         case WriterInterface::XML:
             return parent::export($result);
             break;
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->href);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, $this->authorProfileUrl);
             $entry->addLink($this->href, 'alternate', 'text/html');
             return $entry;
             break;
         default:
             throw new Exception('Writer is not supported');
             break;
     }
 }
예제 #8
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::JSON:
         case WriterInterface::XML:
             return parent::export($result);
             break;
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle('Revision ' . $this->revision . ': ' . $this->message);
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getCommitDate());
             $entry->addAuthor($this->getAuthor()->name);
             $entry->addLink($this->url, 'alternate', 'text/html');
             return $entry;
             break;
         default:
             throw new Exception('Writer is not supported');
             break;
     }
 }
예제 #9
0
    private function handleDefault($type, TableInterface $table, RecordInterface $record)
    {
        // get template message
        $sql = <<<SQL
SELECT
\t`template`.`verb`,
\t`template`.`path`,
\t`template`.`summary`
FROM 
\t{$this->registry['table.user_activity_template']} `template`
WHERE 
\t`template`.`table` = ?
AND 
\t`template`.`type` = ?
SQL;
        $row = $this->sql->getRow($sql, array($table->getName(), RecordAbstract::getType($type)));
        if (!empty($row)) {
            // get object
            $className = $this->registry->getClassNameFromTable($table->getName());
            $handler = $this->hm->getHandler($className, $this->user);
            $object = $handler->get($record->id, array(), Sql::FETCH_OBJECT);
            // build object url
            if (isset($object->pagePath) && !empty($row['path'])) {
                $url = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . $object->pagePath . '/' . $row['path'];
                $url = $this->substituteVars($object, $url);
            } else {
                $url = '#';
            }
            // get activity stream object. If the record does not support jas
            // an exception is thrown
            $jas = null;
            try {
                $jas = $object->export(new WriterResult(WriterInterface::JAS, new Writer\Jas()));
            } catch (\Exception $e) {
            }
            // insert activity
            $handler = $this->hm->getHandler('AmunService\\User\\Activity', $this->user);
            $activity = $handler->getRecord();
            $activity->verb = $row['verb'];
            $activity->object = $jas instanceof ActivityStream\Activity ? json_encode($jas->getData()) : null;
            $activity->summary = $this->substituteVars($object, $row['summary'], $url);
            $handler->create($activity);
        }
    }
예제 #10
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::JSON:
         case WriterInterface::XML:
             return parent::export($result);
             break;
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle($this->title);
             $entry->setId('urn:uuid:' . $this->_base->getUUID('system:api:' . $this->id));
             $entry->setUpdated($this->getDate());
             $entry->addAuthor('System');
             $entry->addLink($this->url, 'alternate', 'text/html');
             $entry->setContent($this->description, 'text');
             return $entry;
             break;
         default:
             throw new Exception('Writer is not supported');
             break;
     }
 }
예제 #11
0
 /**
  * This method should be called by each handler if an record was inserted, 
  * updated or deleted. It notifies all listeners of the core.record_change 
  * event
  *
  * @param integer $type
  * @param PSX\Data\RecordInterface $record
  * @return void
  */
 public function notify($type, RecordInterface $record)
 {
     if (RecordAbstract::getType($type) === false) {
         throw new Exception('Invalid notification type');
     }
     $this->event->notifyListener('core.record_change', array($type, $this->table, $record), $this->user);
 }
예제 #12
0
파일: Record.php 프로젝트: visapi/amun
 public function export(WriterResult $result)
 {
     switch ($result->getType()) {
         case WriterInterface::ATOM:
             $entry = $result->getWriter()->createEntry();
             $entry->setTitle(Util::stripAndTruncateHtml($this->summary));
             $entry->setId('urn:uuid:' . $this->globalId);
             $entry->setUpdated($this->getDate());
             $entry->addAuthor($this->authorName, 'urn:uuid:' . $this->authorGlobalId);
             $entry->setContent($this->summary, 'html');
             if ($this->parentId > 0) {
                 $writer = $result->getWriter()->writer;
                 $parent = $this->_table->select(array('id', 'globalId', 'date'))->where('id', '=', $this->parentId)->getRow();
                 $writer->startElementNS('thr', 'in-reply-to', 'http://purl.org/syndication/thread/1.0');
                 $writer->writeAttribute('ref', 'urn:uuid:' . $parent['globalId']);
                 $writer->endElement();
             }
             return $entry;
             break;
         case WriterInterface::JAS:
             $object = $this->getObject();
             if (empty($object)) {
                 $image = new ActivityStream\MediaLink();
                 $image->setUrl($this->authorThumbnailUrl);
                 $actor = new ActivityStream\Object();
                 $actor->setObjectType('person');
                 $actor->setDisplayName($this->authorName);
                 $actor->setUrl($this->authorProfileUrl);
                 $actor->setImage($image);
                 $object = new ActivityStream\Object();
                 $object->setObjectType('note');
                 $object->setId('urn:uuid:' . $this->globalId);
                 $object->setDisplayName(Util::stripAndTruncateHtml($this->summary));
                 $object->setPublished($this->getDate());
                 $object->setContent($this->summary);
                 $activity = new ActivityStream\Activity();
                 $activity->setActor($actor);
                 $activity->setVerb('post');
                 $activity->setObject($object);
                 return $activity;
             } else {
                 return $object;
             }
             break;
         default:
             return parent::export($result);
             break;
     }
 }