Example #1
0
 /**
  * Default layout.
  */
 protected function _layoutDefault()
 {
     $context = new KCommandContext();
     $context->gadgets = new LibBaseTemplateObjectContainer();
     $context->actor = $this->_state->getItem();
     $context->composers = new LibBaseTemplateObjectContainer();
     $context->commands = $this->getTemplate()->renderHelper('toolbar.commands', 'toolbar');
     $context->profile = new KConfig();
     $context->gadgets->insert('socialgraph', array('title' => translate(array('COM-ACTORS-GADGET-LABEL-SOCIALGRAPH', 'COM-' . strtoupper($this->getIdentifier()->package) . '-GADGET-LABEL-SOCIALGRAPH')), 'url' => $context->actor->getURL() . '&get=graph&layout=gadget_profile', 'title_url' => $context->actor->getURL() . '&get=graph'));
     if ($context->actor->authorize('access')) {
         $context->actor->components->registerEventDispatcher($this->getService('anahita:event.dispatcher'));
         $this->getService('anahita:event.dispatcher')->dispatchEvent('onProfileDisplay', $context);
         dispatch_plugin('profile.onDisplay', array('actor' => $this->_state->getItem(), 'profile' => $context->profile));
         $this->profile = $context->profile;
         if (count($context->profile) > 0) {
             $context->gadgets->insert('information', array('title' => translate(array('COM-ACTORS-GADGET-LABEL-ACTOR-INFO', 'COM-' . strtoupper($this->getIdentifier()->package) . '-GADGET-LABEL-ACTOR-INFO')), 'content' => $this->load('info')));
         }
     }
     $context->gadgets->sort(array('stories', 'information'));
     $this->set(array('commands' => $context->commands, 'gadgets' => $context->gadgets, 'composers' => $context->composers));
 }
Example #2
0
 /**
  * Share an object using share adapters.
  * 
  * @param KConfig $config An array options. 
  *                        mixed object
  *                        ComActorsDomainEntityActor $subject
  *                        ComActorsDomainEntityActor $target
  */
 public function shareObject($config = array())
 {
     $config = new KConfig($config);
     if (!$config->object) {
         throw new InvalidArgumentException('Not object specified to share');
     }
     $config->append(array('sharer' => get_viewer()));
     if ($config->object->isOwnable()) {
         $config->append(array('target' => $config->object->owner));
     }
     $request = new ComSharesSharerRequest($config);
     $sharers = new ArrayObject();
     dispatch_plugin('connect.onGetShareAdapters', array('adapters' => $sharers, 'request' => $request));
     if ($config->sharers) {
         $sharers = array_filter((array) $sharers, function ($sharer) use($config) {
             return in_array($sharer->getIdentifier()->name, $config['sharers']);
         });
     }
     foreach ($sharers as $sharer) {
         $sharer->shareRequest($request);
     }
 }
Example #3
0
 /**
  * (non-PHPdoc)
  * @see LibBaseViewJson::_getItem()
  */
 protected function _getItem()
 {
     $item = parent::_getItem();
     $context = new KCommandContext();
     $context->gadgets = new LibBaseTemplateObjectContainer();
     $context->actor = $this->_state->getItem();
     $context->composers = new LibBaseTemplateObjectContainer();
     $context->profile = new KConfig();
     if ($this->_state->getItem()->authorize('access')) {
         $this->_state->getItem()->components->registerEventDispatcher($this->getService('anahita:event.dispatcher'));
         $this->getService('anahita:event.dispatcher')->dispatchEvent('onProfileDisplay', $context);
         dispatch_plugin('profile.onDisplay', array('actor' => $this->_state->getItem(), 'profile' => $context->profile));
         $this->profile = $context->profile;
     }
     $item['gadgets'] = array_map(function ($gadget) {
         return $gadget->name;
     }, $context['gadgets']->getObjects());
     $item['composers'] = array_map(function ($gadget) {
         return $gadget->name;
     }, $context['composers']->getObjects());
     $item['information'] = $context['profile'];
     return $item;
 }
Example #4
0
 /**
  * onAfterRender handler
  * 
  * @return void
  */
 public function onAfterRoute()
 {
     global $mainframe;
     if ($mainframe->isAdmin()) {
         return;
     }
     $person = get_viewer();
     KService::get('repos://site/subscriptions.package');
     if (!$person) {
         return;
     }
     JPluginHelper::importPlugin('subscriptions', null, true, KService::get('anahita:event.dispatcher'));
     //if subscribe then unsubsribe
     if (isset($person->subscription) && $person->subscription->getTimeLeft() < 0) {
         dispatch_plugin('subscriptions.onAfterExpire', array('subscription' => $person->subscription));
         $person->subscription = null;
         if (KService::get('anahita:domain.space')->commitEntities()) {
             //redirect
             $url = (string) KRequest::url();
             KService::get('application.dispatcher')->getResponse()->setRedirect($url)->send();
             exit(0);
         }
     }
 }
Example #5
0
 /**
  * Edit's an actor data.
  *
  * @param KCommandContext $context Context parameter
  *
  * @return AnDomainEntityAbstract
  */
 protected function _actionEdit(KCommandContext $context)
 {
     $entity = parent::_actionEdit($context);
     if ($entity->isPortraitable() && KRequest::has('files.portrait')) {
         $file = KRequest::get('files.portrait', 'raw');
         if ($this->bellowSizeLimit($file) && $file['error'] == 0) {
             $this->getItem()->setPortrait(array('url' => $file['tmp_name'], 'mimetype' => $file['type']));
             $story = $this->createStory(array('name' => 'avatar_edit', 'owner' => $entity, 'target' => $entity));
         } else {
             $this->getItem()->removePortraitImage();
         }
     }
     if ($entity->save($context)) {
         dispatch_plugin('profile.onSave', array('actor' => $entity, 'data' => $context->data));
     }
     return $entity;
 }
Example #6
0
 /**
  * Layout Profile
  * 
  * @return void
  */
 protected function _layoutProfile()
 {
     $this->profile = new KConfig();
     dispatch_plugin('profile.onEdit', array('actor' => $this->_state->getItem(), 'profile' => $this->profile));
 }
Example #7
0
 /**
  * Adds a subscription
  *
  * @param KCommandContext $context
  *
  * @return void
  */
 protected function _actionAdd(KCommandContext $context)
 {
     $payload = $this->_order->getPayload();
     if (!$this->_gateway->process($payload)) {
         throw new ComSubscriptionsDomainPaymentException('Payment error. Check the log');
     }
     $person = $this->_order->getSubscriber();
     $package = $this->_order->getPackage();
     $set = new AnObjectSet();
     $set->insert($this->_order);
     if (!$person->persisted()) {
         $person->reset();
         $user = $person->getJUserObject();
         //encrypt the password
         $user->set('password', $person->getPassword(true));
         $user->set('block', '0');
         $user->save();
         $person = $this->getService('repos://site/people.person')->find(array('userId' => $user->id));
         if ($person) {
             $set->insert($person);
             $this->_order->setSubscriber($person);
         }
     }
     if (!$package->recurring && $person->hasSubscription()) {
         $subscription = $person->changeSubscriptionTo($package);
     } else {
         $subscription = $person->subscribeTo($package);
     }
     $set->insert($subscription);
     if ($payload->getRecurring()) {
         $subscription->setValue('profileId', $payload->getRecurring()->profile_id);
         $subscription->setValue('profileStatus', $payload->getRecurring()->profile_status);
     }
     if (!$this->commit()) {
         $set->delete();
         $this->commit();
         throw new RuntimeException("Subscription can not be added");
     }
     $this->getResponse()->status = KHttpResponse::CREATED;
     dispatch_plugin('subscriptions.onAfterSubscribe', array('subscription' => $subscription));
     $this->setItem($subscription);
     return $subscription;
 }
Example #8
0
 /**
  * Adds a subscription.
  *
  * @param KCommandContext $context
  */
 protected function _actionAdd(KCommandContext $context)
 {
     $payload = $this->_order->getPayload();
     if (!$this->_gateway->process($payload)) {
         throw new ComSubscriptionsDomainPaymentException('Payment error. Check the log');
     }
     $this->getService('repos:people.person')->addBehavior('com://site/subscriptions.domain.behavior.subscriber');
     $person = $this->_order->getSubscriber();
     $package = $this->_order->getPackage();
     if (!$person->persisted()) {
         $person->getRepository()->getSpace()->setEntityState($person, AnDomain::STATE_NEW);
         $person->enable()->saveEntity();
         $this->_order->setSubscriber($person);
     }
     if ($person->hasSubscription() && !$package->recurring) {
         $subscription = $person->changeSubscriptionTo($package);
     } else {
         $subscription = $person->subscribeTo($package);
     }
     if ($payload->getRecurring()) {
         $subscription->setValue('profileId', $payload->getRecurring()->profile_id);
         $subscription->setValue('profileStatus', $payload->getRecurring()->profile_status);
     }
     if (!$this->commit()) {
         throw new RuntimeException("Subscription can not be added");
     }
     $this->getResponse()->status = KHttpResponse::CREATED;
     dispatch_plugin('subscriptions.onAfterSubscribe', array('subscription' => $subscription));
     $this->setItem($subscription);
     return $subscription;
 }