Example #1
0
 /**
  * Initializes the options for an entity after being created
  *
  * @param 	object 	An optional KConfig object with configuration options.
  * @return 	void
  */
 protected function _afterEntityInstantiate(KConfig $config)
 {
     $data = $config->data;
     $data->append(array('subscribers' => array()));
     if ($data->object) {
         if (is($data->object, 'ComBaseDomainEntityComment')) {
             $data->comment = $data->object;
             $data->object = $data->comment->parent;
             $data->append(array('subscribers' => array($data->comment->author->id)));
         } elseif ($data->object->isModifiable() && !is($data->object, 'ComActorsDomainEntityActor')) {
             $data->append(array('subscribers' => array($data->object->author->id)));
         } elseif (is_person($data->object)) {
             $data->append(array('subscribers' => array($data->object->id)));
         }
         if ($data->object->isOwnable()) {
             $data->target = $data->object->owner;
         }
     }
     if ($data->target && $data->target->isNotifiable()) {
         $data->append(array('subscribers' => array($data->target->id)));
     }
     parent::_afterEntityInstantiate($config);
     if ($config->data->subscribers) {
         $this->setSubscribers($config->data->subscribers);
     }
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * Check if a medium authorizes acccess.
  *
  * @param KCommandContext $context Context parameter
  *
  * @return bool
  */
 protected function _authorizeAccess($context)
 {
     if (is_person($this->_viewer) && $this->_viewer->admin()) {
         return true;
     }
     if ($this->_entity->isPrivatable()) {
         return $this->_entity->allows($this->_viewer, 'access');
     }
 }
Example #4
0
 protected function _beforeRepositoryFetch($context)
 {
     if (KService::has('com:people.viewer') && is_person(get_viewer()) && get_viewer()->admin()) {
         return;
     }
     $query = $context->query;
     $config = pick($query->privacy, new KConfig());
     $config->append(array('viewer' => get_viewer()));
     $where = $this->buildCondition(get_viewer(), $config);
     $query->where($where);
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 protected function _beforeRepositoryFetch(KCommandContext $context)
 {
     if (KService::has('com:people.viewer') && is_person(get_viewer()) && get_viewer()->admin()) {
         return;
     }
     $query = $context->query;
     $repository = $query->getRepository();
     $config = pick($query->privacy, new KConfig());
     $config->append(array('visible_to_leaders' => true, 'viewer' => get_viewer(), 'graph_check' => true));
     $where = $this->buildCondition('@col(id)', $config, '@col(access)');
     $query->where($where);
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 protected function _beforeQuerySelect(KCommandContext $context)
 {
     if (KService::has('com:people.viewer') && is_person(get_viewer()) && get_viewer()->admin()) {
         return;
     }
     $query = $context->query;
     $repository = $query->getRepository();
     $config = pick($query->privacy, new KConfig());
     $config->append(array('visible_to_leaders' => true, 'viewer' => KService::get('com:people.viewer'), 'graph_check' => true));
     $query->getRepository()->addBehavior('ownable');
     //do a left join operation just in case an owner is missing
     $query->link('owner', array('type' => 'weak', 'bind_type' => false));
     $config->append(array('use_access_column' => '@col(access)'));
     $c1 = $this->buildCondition('@col(owner.id)', $config, '@col(owner.access)');
     $c2 = $this->buildCondition('@col(owner.id)', $config, $config->use_access_column);
     $where = "IF({$c1}, {$c2}, 0)";
     $query->where($where);
 }
Example #7
0
 /**
  * Event Listener
  *
  * @param KEvent $event
  */
 public function onAfterDomainRepositoryFetch(KEvent $event)
 {
     $viewer = get_viewer();
     $query = $event->query;
     //if method is GET and reading actor.
     //that means we are in the actor profile page
     //redirect to the list of package if not allowed to see the actor
     //not seeing actor means not subscribed to any packages
     if ($query->access_changed && $event->data) {
         $entity = $event->data;
         if (is_person($entity)) {
             return;
         }
         $option = KRequest::get('get.option', 'cmd');
         $id = KRequest::get('get.id', 'cmd');
         if (!$entity->authorize('access') && $entity->id == $id && $entity->component == $option) {
             JFactory::getLanguage()->load('com_subscriptions');
             JFactory::getApplication()->redirect('index.php?option=com_subscriptions&view=packages', JText::_('COM-SUBSCRIPTIONS-ACCESS-PLG-NO-SUBS'));
         }
     }
 }
Example #8
0
 public function name($actor, $linked = true, $attr = array())
 {
     if (!is_person($actor)) {
         return parent::name($actor, $linked, $attr);
     }
     if (is_null($actor) || !isset($actor->id)) {
         $linked = false;
         $name = '<span class="actor-name">' . JText::_('LIB-AN-UNKOWN-PERSON') . '</span>';
     } else {
         $name = '<span class="actor-name" actorid="' . $actor->id . '">' . $actor->username . '</span>';
         if ($actor->verified) {
             $name = $name . ' <span class="icon icon-ok-sign"></span>';
         }
     }
     if (!$linked || !$actor->authorize('access')) {
         return (string) $name;
     }
     $url = JRoute::_($actor->getURL());
     if (is_person($actor)) {
         $attr['title'] = '@' . $actor->username;
     }
     $name = '<a class="actor-name" ' . $this->_buildAttribute($attr) . ' actorid="' . $actor->id . '" href="' . $url . '" >' . $name . '</a>';
     return $name;
 }
Example #9
0
    echo $topic->COUNT_REPLY;
    ?>
 replies</span>
								</a><!--comment-->
							</div>
						</div><!--topic-->
							
						<?php 
}
?>
					</div>
				</div>
			</div><!--content-->
			<div class="col-md-3" id="sidebar">
				<?php 
if (is_person($person->PERSON_ID) || is_admin()) {
    ?>
				<a href="<?php 
    echo base_url();
    ?>
person/edit" type="button" class="create-btn btn btn-warning btn-lg btn-block">
					<span class="glyphicon glyphicon-pencil"></span>
					Edit Profile
				</a>
				<?php 
}
?>
				<a href="mailto:nuttt.p@gmail.com" type="button" class="create-btn btn btn-primary btn-lg btn-block">
					<span class="glyphicon glyphicon-envelope"></span>
					E-mail <?php 
echo $person->DISPLAY_NAME;
Example #10
0
/**
 * Check if an actor is a person type and also is admin
 * 
 * @param ComActorsDomainEntityActor $actor Actor entity
 * 
 * @return boolean
 */
function is_admin($actor)
{
    return is_person($actor) && ($this->userType == 'Administrator' || $this->userType == 'Super Administrator');
}
Example #11
0
									<a href="<?php 
    echo base_url();
    ?>
person/profile/<?php 
    echo $reply->PERSON_ID;
    ?>
" class="name"><strong><?php 
    echo $reply->DISPLAY_NAME;
    ?>
</strong></a>
									<span class="date"><?php 
    echo $reply->TIME;
    ?>
</span>
									<?php 
    if (is_person($reply->PERSON_ID) || is_admin() || is_moderator($post->POST_ID)) {
        ?>
										<a href="edit_post.php" class="tag yellow"><span class="glyphicon glyphicon-pencil"></span> Edit</a>
										<a href="" class="tag red"><span class="glyphicon glyphicon-trash"></span> Remove</a>
									<?php 
    }
    ?>
								</p>
							</div>
							<div class="col-xs-3 text-right">
								<a href="" class="btn btn-danger btn-xs vote vote-down">
									<span class="glyphicon glyphicon-thumbs-down"></span>
								</a><!--vote-->
								<span class="current-score">
									<?php 
    echo $reply->VOTE;
Example #12
0
 /**
  * Fetches an entity
  *
  * @param KCommandContext $context
  * 
  * @return ComActorsDomainEntityActor
  */
 protected function _fetchOwner(KCommandContext $context)
 {
     $actor = pick($this->getActor(), $this->_default);
     $value = $this->{$this->getIdentifiableKey()};
     if ($value) {
         if ($value == 'viewer') {
             $actor = get_viewer();
         } elseif (!is_numeric($value)) {
             $actor = $this->getService('repos://site/people.person')->fetch(array('username' => $value));
         } else {
             $actor = $this->getService('repos://site/actors.actor')->fetch((int) $value);
         }
         //guest actor can never be a context actor
         if (is_person($actor) && $actor->guest()) {
             $actor = null;
         }
         //set the data owner to actor.
         $context->data['owner'] = $actor;
         if (!$actor) {
             throw new LibBaseControllerExceptionNotFound('Owner Not Found');
         }
     }
     $this->setActor($actor);
 }
Example #13
0
    echo @message(@text('COM-ACTORS-PROFILE-DISABLED-PROMPT'), array('type' => 'warning'));
    ?>
		<?php 
}
?>

		<?php 
echo @helper('ui.toolbar', array());
?>

		<h2 id="actor-name">
		<?php 
echo @name($item, false);
?>
		<?php 
if (is_person($item)) {
    ?>
		<small>@<?php 
    echo $item->username;
    ?>
</small>
		<?php 
}
?>
		</h2>

		<?php 
if (!empty($item->body)) {
    ?>
		<div id="actor-description">
		<?php 
Example #14
0
 /**
  * Check if a medium authorizes acccess
  * 
  * @param KCommandContext $context Context parameter
  * 
  * @return boolean
  */
 protected function _authorizeAccess($context)
 {
     if (is_person($this->_viewer) && $this->_viewer->admin()) {
         return true;
     }
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function toSerializableArray($entity)
 {
     $data = new KConfig();
     $viewer = KService::has('com:people.viewer') ? KService::get('com:people.viewer') : null;
     $data[$entity->getIdentityProperty()] = $entity->getIdentityId();
     $data['objectType'] = 'com.' . $entity->getIdentifier()->package . '.' . $entity->getIdentifier()->name;
     if ($entity->isDescribable()) {
         $data['name'] = $entity->name;
         $data['body'] = $entity->body;
         $data['alias'] = $entity->alias;
     }
     if ($entity->inherits('ComBaseDomainEntityComment')) {
         $data['body'] = $entity->body;
     }
     if ($entity->isPortraitable()) {
         $imageURL = array();
         if ($entity->portraitSet()) {
             $sizes = $entity->getPortraitSizes();
             foreach ($sizes as $name => $size) {
                 $url = null;
                 if ($entity->portraitSet()) {
                     $url = $entity->getPortraitURL($name);
                 }
                 $parts = explode('x', $size);
                 $width = 0;
                 $height = 0;
                 if (count($parts) == 0) {
                     continue;
                 } elseif (count($parts) == 1) {
                     $height = $width = $parts[0];
                 } else {
                     $width = $parts[0];
                     $height = $parts[1];
                     //hack to set the ratio based on the original
                     if ($height == 'auto' && isset($sizes['original'])) {
                         $original_size = explode('x', $sizes['original']);
                         $height = $width * $original_size[1] / $original_size[0];
                     }
                 }
                 $imageURL[$name] = array('size' => array('width' => (int) $width, 'height' => (int) $height), 'url' => $url);
             }
         }
         $data['imageURL'] = $imageURL;
     }
     // @todo check for $entity->isAuthorizer() and $entity->authorize('administration') scenarios later on
     if ($entity->isAdministrable()) {
         $data['administratorIds'] = array_values($entity->administratorIds->toArray());
         if ($viewer) {
             $data['isAdministrated'] = $viewer->administrator($entity);
         }
     }
     if ($viewer && !$viewer->eql($entity)) {
         if ($entity->isFollowable()) {
             $data['isLeader'] = $viewer->following($entity);
         }
         if ($entity->isLeadable()) {
             $data['isFollower'] = $viewer->leading($entity);
         }
     }
     if ($entity->isModifiable() && !is_person($entity)) {
         $data->append(array('author' => null, 'creationTime' => null, 'editor' => null, 'updateTime' => null));
         if (isset($entity->author)) {
             $data['author'] = $entity->author->toSerializableArray();
             $data['creationTime'] = $entity->creationTime->getDate();
         }
         if (isset($entity->editor)) {
             $data['editor'] = $entity->editor->toSerializableArray();
             $data['updateTime'] = $entity->updateTime->getDate();
         }
     }
     if ($entity->isCommentable()) {
         $data['openToComment'] = (bool) $entity->openToComment;
         $data['numOfComments'] = $entity->numOfComments;
         $data['lastCommentTime'] = $entity->lastCommentTime ? $entity->lastCommentTime->getDate() : null;
         $data['lastComment'] = null;
         $data['lastCommenter'] = null;
         if (isset($entity->lastComment)) {
             $data['lastComment'] = $entity->lastComment->toSerializableArray();
         }
         if (isset($entity->lastCommenter)) {
             $data['lastCommenter'] = $entity->lastCommenter->toSerializableArray();
         }
     }
     if ($entity->isFollowable()) {
         $data['followerCount'] = $entity->followerCount;
     }
     if ($entity->isLeadable()) {
         $data['leaderCount'] = $entity->leaderCount;
         $data['mutualCount'] = $entity->mutualCount;
     }
     if ($entity->isSubscribable()) {
         $data['subscriberCount'] = $entity->subscriberCount;
     }
     if ($entity->isVotable()) {
         $data['voteUpCount'] = $entity->voteUpCount;
     }
     if ($entity->isOwnable()) {
         $data['owner'] = $entity->owner->toSerializableArray();
     }
     return KConfig::unbox($data);
 }
Example #16
0
 /**
  * Checks if a comment can be added to a  node.
  * 
  * @param KCommandContext $context Context parameter
  * 
  * @return bool
  */
 protected function _authorizeAddComment($context)
 {
     if ($this->_viewer->guest()) {
         return false;
     }
     if ($this->_entity->isCommentable()) {
         if (is_person($this->_viewer) && $this->_viewer->admin()) {
             return true;
         }
         if (!$this->_entity->openToComment) {
             return false;
         }
         if ($this->_entity->isOwnable()) {
             //if the owner has blocked the viewer or the other way around, return false
             $owner = $this->_entity->owner;
             if ($this->_entity->owner->blocking($this->_viewer) || $this->_viewer->blocking($this->_entity->owner)) {
                 return false;
             }
             //if ownable and can't access the owner then
             //can't comment
             if ($this->_entity->owner->authorize('access') === false) {
                 return false;
             }
             $action = 'com_' . $this->_entity->getIdentifier()->package . ':' . $this->_entity->getIdentifier()->name . ':addcomment';
             $result = $this->_entity->owner->authorize('action', array('action' => $action));
             if ($result === false) {
                 /*
                  * @TODO We need to communicate back the nature of not having a 
                  * permission to comment on an entity.Right now we are using
                  * the entity iself as the communication mechanism. Perpas an error
                  * object to KCommandContext
                  */
                 $this->_entity->__require_follow = false;
                 if ($this->_entity->owner->hasPermission($action, LibBaseDomainBehaviorPrivatable::FOLLOWER)) {
                     $this->_entity->__require_follow = true;
                 }
             }
             return $result;
         }
     }
     return false;
 }
Example #17
0
/**
 * Check if an actor is a person type and also is admin.
 * 
 * @param ComActorsDomainEntityActor $actor Actor entity
 * 
 * @return bool
 */
function is_admin($actor)
{
    return is_person($actor) && ($this->userType == ComPeopleDomainEntityPerson::USERTYPE_ADMINISTRATOR || $this->userType == ComPeopleDomainEntityPerson::USERTYPE_SUPER_ADMINISTRATOR);
}
Example #18
0
" class="tag yellow"><span class="glyphicon glyphicon-pencil"></span> Edit</a>
										<a href="<?php 
    echo base_url();
    ?>
post/remove/<?php 
    echo $post->POST_ID;
    ?>
/<?php 
    echo $post->POST_ID;
    ?>
" class="tag red"><span class="glyphicon glyphicon-trash"></span> Remove</a>
									<?php 
}
?>
									<?php 
if (!is_person($post->PERSON_ID)) {
    ?>
									<a href="<?php 
    echo base_url('post/report/' . $post->POST_ID . '?return=post/view/' . $post->POST_ID);
    ?>
" class="tag orange"><span class="glyphicon glyphicon-exclamation-sign"></span> Report</a>
									<?php 
}
?>
								</p>
							</div>
							<div class="col-xs-3 text-right">
								<?php 
include 'hook-vote-topic.php';
?>
							</div>
Example #19
0
 /**
  * If true then the viewer can add new followers to the this actor.
  * 
  * @param KCommandContext $context Context parameter
  * 
  * @return bool
  */
 protected function _authorizeLead(KCommandContext $context)
 {
     //obviously guests cannot add new followers
     if (is_guest($this->_viewer)) {
         return false;
     }
     //viewers cannot add new followers to themselves
     if ($this->_viewer->eql($this->_entity)) {
         return false;
     }
     //new followers cannot be added to people
     if (is_person($this->_entity)) {
         return false;
     }
     return $this->_entity->authorize('action', 'leadable:add');
 }
Example #20
0
        <?php 
if (is_person($reply->PERSON_ID) || is_admin() || is_moderator($post->POST_ID)) {
    ?>
          <a href="<?php 
    echo base_url('post/edit_reply/' . $reply->POST_ID);
    ?>
" class="tag yellow"><span class="glyphicon glyphicon-pencil"></span> Edit</a>
          <a href="<?php 
    echo base_url('post/remove/' . $post->POST_ID . '/' . $reply->POST_ID);
    ?>
" class="tag red"><span class="glyphicon glyphicon-trash"></span> Remove</a>
        <?php 
}
?>
        <?php 
if (!is_person($reply->PERSON_ID)) {
    ?>
        <a href="<?php 
    echo base_url('post/report/' . $reply->POST_ID . '?return=post/view/' . $post->POST_ID);
    ?>
" class="tag orange"><span class="glyphicon glyphicon-exclamation-sign"></span> Report</a>
        <?php 
}
?>
      </p>
    </div>
    <div class="col-xs-6 text-right">
      <?php 
include 'hook-vote.php';
?>
    </div>
Example #21
0
?>

<form class="composer-form" action="<?php 
echo @route();
?>
" method="post">
	<input type="hidden" name="composed" value="1" />
	
	<div class="control-group">			
		<div class="controls">
			<textarea class="input-block-level" id="note-body" name="body" cols="5" rows="3" required maxlength="5000"></textarea>
    	</div>
    </div>
    
	<?php 
if (is_person($actor) && !is_viewer($actor)) {
    ?>
			
	<div class="control-group">			
		<div class="controls">
			<label class="checkbox" for="private-flag">
				<input id="private-flag" type="checkbox" name="private"> 
				<?php 
    echo @text('COM-NOTES-COMPOSER-PRIVATE-FLAG');
    ?>
			</label>
		</div>
    </div>
	<?php 
}
?>