当前位置: 首页>>代码示例>>PHP>>正文


PHP get_viewer函数代码示例

本文整理汇总了PHP中get_viewer函数的典型用法代码示例。如果您正苦于以下问题:PHP get_viewer函数的具体用法?PHP get_viewer怎么用?PHP get_viewer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_viewer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: canDelete

 public function canDelete()
 {
     if (get_viewer()->admin()) {
         return true;
     }
     return false;
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:7,代码来源:category.php

示例2: _commandSubscribe

 /**
  * Subscribe Action.
  *
  * @param LibBaseTemplateObject $command The action object
  */
 protected function _commandSubscribe($command)
 {
     $entity = $this->getController()->getItem();
     $action = $entity->subscribed(get_viewer()) ? 'unsubscribe' : 'subscribe';
     $label = JText::_('LIB-AN-ACTION-' . strtoupper($action));
     $command->append(array('label' => $label))->href($entity->getURL())->class('action-' . $action)->setAttribute('data-action', $action);
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:12,代码来源:default.php

示例3: _actionInvite

 /**
  * Read
  * 
  * @param KCommandContext $contxt
  * 
  * @return void
  */
 protected function _actionInvite($context)
 {
     $data = $context->data;
     $siteConfig = JFactory::getConfig();
     $filter = $this->getService('koowa:filter.email');
     $emails = array_filter((array) $data['email'], function ($email) use($filter) {
         return $filter->validate($email);
     });
     $payloads = array();
     $sent_one = false;
     foreach ($emails as $email) {
         $token = $this->getService('repos://site/invites.token')->getEntity(array('data' => array('inviter' => get_viewer(), 'serviceName' => 'email')));
         $person = $this->getService('repos://site/people')->find(array('email' => $email));
         $payload = array('email' => $email, 'sent' => false);
         if (!$person && $token->save()) {
             $payload['sent'] = true;
             $sent_one = true;
             $this->mail(array('subject' => JText::sprintf('COM-INVITES-MESSAGE-SUBJECT', $siteConfig->getValue('sitename')), 'to' => $email, 'layout' => false, 'template' => 'invite', 'data' => array('invite_url' => $token->getURL(), 'site_name' => $siteConfig->getValue('sitename'), 'sender' => $this->viewer)));
         } else {
             $payload['person'] = $person;
         }
         $payloads[] = $payload;
     }
     $content = $this->getView()->set(array('data' => $payloads))->display();
     $context->response->setContent($content);
     if ($sent_one) {
         $this->setMessage('COM-INVITES-EMAIL-INVITES-SENT', 'info', false);
     }
 }
开发者ID:walteraries,项目名称:anahita,代码行数:36,代码来源:email.php

示例4: _beforeRepositoryFetch

 protected function _beforeRepositoryFetch(KCommandContext $context)
 {
     $viewer = get_viewer();
     if (!$viewer->admin()) {
         $context->query->where('IF(@col(enabled)=FALSE,0,1)');
     }
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:7,代码来源:enableable.php

示例5: _actionAdd

 /**
  * Adds a new post
  * 
  * @param KCommandContext $context Context parameter         
  * 
  * @return void
  */
 protected function _actionAdd($context)
 {
     $data = $context->data;
     $entity = parent::_actionAdd($context);
     //if a person posting a message on his profile
     //or if a target is not actor then it can't be a private message
     if (get_viewer()->eql($this->actor) || !is_person($this->actor)) {
         unset($data->private);
     }
     //if a private message then
     //set the privacy to subject/target
     if ($data->private) {
         $entity->setAccess(array($this->actor->id, get_viewer()->id));
     }
     //create a notification for the subscribers and
     //the post owner as well
     if ($entity->owner->isSubscribable()) {
         //create a notification and pass the owner
         $notification = $this->createNotification(array('name' => 'note_add', 'object' => $entity, 'subscribers' => array($entity->owner->subscriberIds->toArray(), $entity->owner)))->setType('post', array('new_post' => true));
     }
     if (!empty($data['channels'])) {
         $this->shareObject(array('object' => $entity, 'sharers' => $data['channels']));
     }
     return $entity;
 }
开发者ID:walteraries,项目名称:anahita,代码行数:32,代码来源:note.php

示例6: build

 /**
  * Build the route
  *
  * @param   array   An array of URL arguments
  * @return  array   The URL arguments to use to assemble the subsequent URL.
  */
 public function build(&$query)
 {
     if (isset($query['alias']) && isset($query['id'])) {
         if (!isset($query['get'])) {
             $query['id'] = $query['id'] . '-' . $query['alias'];
         }
         unset($query['alias']);
     }
     $has_id = isset($query['id']);
     $segments = parent::build($query);
     if ($has_id) {
         if (isset($query['get'])) {
             $segments[] = $query['get'];
             if ($query['get'] == 'graph') {
                 if (!isset($query['type'])) {
                     $query['type'] = 'followers';
                 }
                 $segments[] = $query['type'];
                 unset($query['type']);
             }
             unset($query['get']);
         }
     } elseif (isset($query['oid'])) {
         if ($query['oid'] == 'viewer') {
             $query['oid'] = get_viewer()->uniqueAlias;
         }
         $segments[] = '@' . $query['oid'];
         unset($query['oid']);
     }
     return $segments;
 }
开发者ID:walteraries,项目名称:anahita,代码行数:37,代码来源:abstract.php

示例7: _actionAdd

 public function _actionAdd($context)
 {
     $context->data->access = $context->data->parent->access;
     $context->data->author = get_viewer();
     $this->parent->resetRead();
     $post = parent::_actionAdd($context);
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:7,代码来源:post.php

示例8: addToolbarCommands

 public function addToolbarCommands()
 {
     $viewer = get_viewer();
     $entity = $this->getController()->getItem();
     if (!$entity && $viewer->admin()) {
         $this->addCommand('addCategory');
         $this->addCommand('addForum');
         $this->addCommand('recount');
     }
     if ($entity && $entity->parent !== NULL && !$viewer->guest() && !$entity->locked) {
         $this->addCommand('new');
     }
     if ($entity && $entity->locked) {
         $this->addCommand('locked');
     }
     if ($entity && $entity->parent !== NULL && ($entity->authorize('subscribe') || $entity->subscribed($viewer))) {
         $this->addCommand('subscribe');
     }
     if ($entity && $entity->authorize('delete')) {
         $this->addCommand('lock');
         $this->addCommand('enable');
         $action = $entity->enabled ? 'disable' : 'enable';
         $this->getCommand('enable')->dataAction($action);
     }
     if ($entity && $entity->authorize('edit')) {
         $this->addCommand('edit');
     }
     if ($entity && $entity->authorize('delete')) {
         $this->addCommand('delete');
         $this->getCommand('delete')->dataRedirect(JRoute::_($entity->parent->getURL()));
     }
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:32,代码来源:forum.php

示例9: addToolbarCommands

 public function addToolbarCommands()
 {
     $entity = $this->getController()->getItem();
     if ($entity && $entity->authorize('add') && !$entity->locked && !$entity->parent->locked) {
         $this->addCommand('new');
     }
     if ($entity && ($entity->locked || $entity->parent->locked)) {
         $this->addCommand('locked');
     }
     if ($entity && ($entity->authorize('subscribe') || $entity->subscribed(get_viewer()))) {
         $this->addCommand('subscribe');
     }
     if ($entity && $entity->authorize('pin')) {
         $this->addCommand('pin');
     }
     if ($entity && $entity->authorize('lock')) {
         $this->addCommand('lock');
     }
     if ($entity && $entity->authorize('delete')) {
         $this->addCommand('enable');
         $label = $entity->enabled ? 'COM-FORUMS-POST-DELETE' : 'COM-FORUMS-POST-RESTORE';
         $action = $entity->enabled ? 'disable' : 'enable';
         $this->getCommand('enable')->label(JText::_($label))->dataAction($action);
     }
     if ($entity && $entity->authorize('delete') && !$entity->enabled) {
         $this->addCommand('delete');
         $this->getCommand('delete')->dataRedirect(JRoute::_($entity->parent->getURL()));
     }
     if ($entity && $entity->authorize('moderate')) {
         $this->addCommand('moderate');
     }
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:32,代码来源:thread.php

示例10: parse

 /**
  * Parses the URI.
  *
  * @param JURI $uri
  */
 public function parse(&$url)
 {
     $this->_fixUrlForParsing($url);
     if (empty($url->path) && !isset($url->query['option'])) {
         $url->path = get_viewer()->guest() ? 'pages' : 'dashboard';
     }
     $this->_parse($url);
 }
开发者ID:NicholasJohn16,项目名称:anahita,代码行数:13,代码来源:router.php

示例11: createNotification

 /**
  * Creates a notification.
  *
  * @param array $data Notification data
  *
  * @return ComNotificationDomainEntityNotification
  */
 public function createNotification($data = array())
 {
     $data = new KConfig($data);
     $data->append(array('component' => 'com_' . $this->_mixer->getIdentifier()->package, 'subject' => get_viewer()));
     $notification = $this->getService('repos:notifications.notification')->getEntity(array('data' => $data));
     $notification->removeSubscribers(get_viewer());
     return $notification;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:15,代码来源:notifier.php

示例12: canModerate

 public function canModerate()
 {
     $viewer = get_viewer();
     if ($viewer->admin()) {
         return true;
     }
     return false;
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:8,代码来源:thread.php

示例13: createStory

 /**
  * Creates a story.
  *
  * @param array|KCommandContext $config Config. Can be a story data or KCommandContext if the method
  *                                      is used as a callback
  *
  * @return ComStoriesDomainEntityStory
  */
 public function createStory($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('subject' => get_viewer(), 'owner' => get_viewer(), 'component' => 'com_' . $this->_mixer->getIdentifier()->package));
     $story = $this->getService('repos://site/stories')->create($config->toArray());
     //$story = $this->getService('com://site/stories.controller.story')->add($config->toArray());
     $story->save();
     return $story;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:17,代码来源:publisher.php

示例14: markRead

 public function markRead()
 {
     $viewer = get_viewer();
     if (!$this->newNotificationIds->offsetExists($viewer->id)) {
         $ids = clone $this->newNotificationIds;
         $ids[] = $viewer->id;
         $this->set('newNotificationIds', $ids)->save();
     }
 }
开发者ID:NicholasJohn16,项目名称:forums,代码行数:9,代码来源:newable.php

示例15: onBeforeControllerGet

 /**
  * Before _actionGet controller event
  *
  * @param  KEvent $event Event object 
  * 
  * @return string
  */
 public function onBeforeControllerGet(KEvent $event)
 {
     parent::onBeforeControllerGet($event);
     if ($this->getController()->isOwnable() && $this->getController()->actor) {
         $actor = pick($this->getController()->actor, get_viewer());
         $this->setTitle(sprintf(JText::_('COM-STORIES-HEADER-STORIES'), $actor->name));
         $this->setActor($actor);
     }
 }
开发者ID:walteraries,项目名称:anahita,代码行数:16,代码来源:actorbar.php


注:本文中的get_viewer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。