Пример #1
0
 /**
  * @httpMethod GET
  * @path /
  */
 public function doIndex()
 {
     if ($this->user->hasRight('pipe_view')) {
         // load pipe
         $recordPipe = $this->getHandler()->getOneByPageId($this->page->getId(), array(), Sql::FETCH_OBJECT);
         $this->template->assign('recordPipe', $recordPipe);
         // check whether user has the media right
         if ($recordPipe instanceof Record && (!empty($recordPipe->mediaRightId) && !$this->user->hasRightId($recordPipe->mediaRightId))) {
             throw new Exception('Access not allowed');
         }
         // get content
         $embedded = $this->get->embedded('boolean');
         $content = '';
         if ($recordPipe instanceof Record) {
             // set header
             header_remove('Expires');
             header_remove('Cache-Control');
             header_remove('Pragma');
             header('Last-Modified: ' . $recordPipe->getLastModified()->format(DateTime::RFC1123));
             // get content
             $content = $recordPipe->getContent();
         }
         if (!$embedded) {
             $this->template->assign('data', $content);
         } else {
             echo $content;
             exit;
         }
         // options
         if ($recordPipe instanceof Record) {
             $url = $this->service->getApiEndpoint() . '/form?format=json&method=update&id=' . $recordPipe->id;
         } else {
             $url = $this->service->getApiEndpoint() . '/form?format=json&method=create&pageId=' . $this->page->getId();
         }
         $options = new Option(__CLASS__, $this->registry, $this->user, $this->page);
         $options->add('pipe_edit', 'Edit', 'javascript:amun.services.pipe.showForm(\'' . $url . '\')');
         $options->load(array($this->page));
         $this->template->assign('options', $options);
         // template
         $this->htmlCss->add('pipe');
         $this->htmlJs->add('pipe');
         $this->htmlJs->add('ace');
         $this->htmlJs->add('bootstrap');
         $this->htmlJs->add('prettify');
     } else {
         throw new Exception('Access not allowed');
     }
 }
Пример #2
0
 protected function handle()
 {
     if ($this->user->hasRight('php_view')) {
         // load php
         $fields = array('id', 'globalId', 'pageId', 'content', 'date', 'authorName', 'authorProfileUrl', 'pagePath');
         $recordPhp = $this->getHandler()->getOneByPageId($this->page->getId(), $fields, Sql::FETCH_OBJECT);
         $this->template->assign('recordPhp', $recordPhp);
         // options
         if ($recordPhp instanceof Record) {
             $url = $this->service->getApiEndpoint() . '/form?format=json&method=update&id=' . $recordPhp->id;
         } else {
             $url = $this->service->getApiEndpoint() . '/form?format=json&method=create&pageId=' . $this->page->getId();
         }
         $options = new Option(__CLASS__, $this->registry, $this->user, $this->page);
         $options->add('php_edit', 'Edit', 'javascript:amun.services.php.showForm(\'' . $url . '\')');
         $options->load(array($this->page));
         $this->template->assign('options', $options);
         // parse content
         $phpResponse = null;
         $phpError = null;
         if ($recordPhp instanceof Record) {
             ob_start();
             try {
                 $return = eval($recordPhp->content);
                 $phpResponse = ob_get_contents();
             } catch (\Exception $e) {
                 // build message
                 $phpError = '<p>' . $e->getMessage() . '</p>';
                 if ($this->config['psx_debug'] === true) {
                     $phpError .= '<pre>' . $e->getTraceAsString() . '</pre>';
                 }
             }
             ob_end_clean();
         }
         $this->template->assign('phpResponse', $phpResponse);
         $this->template->assign('phpError', $phpError);
         // template
         $this->htmlCss->add('php');
         $this->htmlJs->add('php');
         $this->htmlJs->add('ace-php');
         $this->htmlJs->add('bootstrap');
         $this->htmlJs->add('prettify');
     } else {
         throw new Exception('Access not allowed');
     }
 }
Пример #3
0
 public function onLoad()
 {
     parent::onLoad();
     // friend request count
     $con = new Condition();
     $con->add('friendId', '=', $this->user->getId());
     $con->add('status', '=', Friend\Record::REQUEST);
     $requestCount = $this->getSql()->count($this->registry['table.user_friend'], $con);
     $this->template->assign('requestCount', $requestCount);
     // pending count
     $con = new Condition();
     $con->add('userId', '=', $this->user->getId());
     $con->add('status', '=', Friend\Record::REQUEST);
     $pendingCount = $this->getSql()->count($this->registry['table.user_friend'], $con);
     $this->template->assign('pendingCount', $pendingCount);
     // load groups
     $groupList = $this->getGroups();
     $this->template->assign('groupList', $groupList);
     // options
     $friends = new Option('friends', $this->registry, $this->user, $this->page);
     $friends->add('my_view', 'Friends', $this->page->getUrl() . '/friends');
     if ($requestCount > 0) {
         $friends->add('my_view', 'Request (' . $requestCount . ')', $this->page->getUrl() . '/friends/request');
     }
     if ($pendingCount > 0) {
         $friends->add('my_view', 'Pending (' . $pendingCount . ')', $this->page->getUrl() . '/friends/pending');
     }
     $friends->add('my_view', 'Groups', $this->page->getUrl() . '/friends/group');
     $friends->load(array($this->page));
     $this->template->assign('optionsFriends', $friends);
 }
Пример #4
0
 /**
  * @httpMethod GET
  * @path /{userName}
  */
 public function doProfile()
 {
     if ($this->user->hasRight('profile_view')) {
         $account = $this->getAccount();
         if (!$account instanceof Account\Record) {
             throw new Exception('Invalid user');
         }
         $this->template->assign('account', $account);
         // check whether remote profile
         if ($account->status == Account\Record::REMOTE) {
             Base::setResponseCode(301);
             header('Location: ' . $account->profileUrl);
             exit;
         }
         // add path
         $this->path->add($account->name, $this->page->getUrl() . '/' . $account->name);
         // get activities
         $activities = $this->getActivities($account);
         $this->template->assign('activities', $activities);
         // options
         $url = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/friend';
         $options = new Option(__CLASS__, $this->registry, $this->user, $this->page);
         if (!$this->user->isAnonymous() && !$this->user->hasFriend($account)) {
             $options->add('profile_view', 'Add as friend', 'javascript:amun.services.profile.friendshipRequest(' . $this->user->getId() . ', ' . $account->id . ', \'' . $url . '\', this)');
         }
         $options->load(array($this->page, $account));
         $this->template->assign('options', $options);
         // template
         $this->htmlCss->add('profile');
         $this->htmlJs->add('amun');
         $this->htmlJs->add('profile');
         $this->htmlContent->add(Html\Content::META, Atom\Writer::link('Activity', $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $account->id . '?format=atom'));
         $this->htmlContent->add(Html\Content::META, '<link rel="alternate" type="application/stream+json" href="' . $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/activity/' . $account->id . '?format=jas" />');
         $this->htmlContent->add(Html\Content::META, '<link rel="meta" type="application/rdf+xml" title="FOAF" href="' . $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/foaf/' . $account->name . '" />');
         $this->htmlContent->add(Html\Content::META, '<link rel="profile" type="html/text" href="' . $account->profileUrl . '" />');
     } else {
         throw new Exception('Access not allowed');
     }
 }
Пример #5
0
 public function onLoad()
 {
     parent::onLoad();
     // options
     $settings = new Option('settings', $this->registry, $this->user, $this->page);
     $settings->add('my_view', 'Account', $this->page->getUrl() . '/settings');
     $settings->add('my_view', 'Security', $this->page->getUrl() . '/settings/security');
     $settings->add('my_view', 'Connection', $this->page->getUrl() . '/settings/connection');
     $settings->add('my_view', 'Application', $this->page->getUrl() . '/settings/application');
     $settings->load(array($this->page));
     $this->template->assign('optionsSettings', $settings);
 }
Пример #6
0
 public function onLoad()
 {
     parent::onLoad();
     if ($this->user->hasRight('my_view')) {
         // check status of current user
         if ($this->user->isAnonymous()) {
             throw new Exception('Anonymous user cant view their profile');
         }
     } else {
         throw new Exception('Access not allowed');
     }
     // options
     $options = new Option('index', $this->registry, $this->user, $this->page);
     $options->add('my_view', 'Settings', $this->page->getUrl() . '/settings');
     $options->add('my_view', 'Friends', $this->page->getUrl() . '/friends');
     $options->add('my_view', 'Account', $this->page->getUrl());
     $options->load(array($this->page));
     $this->template->assign('options', $options);
 }
Пример #7
0
 /**
  * Helper method to build the options for an application. Using the option
  * class has the advantage that other services can easily extend the service
  * by injecting links into the option menu
  *
  * @param array $data
  * @return void
  */
 protected function setOptions(array $data)
 {
     $options = new Option($this->location->getClass()->getName(), $this->registry, $this->user, $this->page);
     foreach ($data as $row) {
         list($rightName, $title, $url) = $row;
         $options->add($rightName, $title, $url);
     }
     $options->load(array($this->page));
     $this->template->assign('options', $options);
 }