Esempio n. 1
0
 /**
  * Basic message read permission
  */
 public function allowRead($userid)
 {
     // If private, only the group member can access
     if ($this->data->access) {
         $my = JXFactory::getUser();
         $userGroups = $my->getParam('groups_member');
         // added condition to allow also siteadmin and superuser to read the private group content
         return JXUtility::csvExist($userGroups, $this->data->group_id) || $my->isAdmin();
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Return true if the user is allowed to download it
  */
 public function allowDownload($userid)
 {
     // If this is a group, and the group is private, only members can download it
     $my = JXFactory::getUser($userid);
     $limitGroup = $my->getParam('groups_member_limited');
     if ($limitGroup) {
         return JXUtility::csvExist($limitGroup, $this->group_id);
     }
     if ($this->group_id) {
         $group = JTable::getInstance('Group', 'StreamTable');
         $group->load($this->group_id);
         // People need to be able to read the group
         if (!$my->authorise('stream.group.read', $group)) {
             return false;
         }
     }
     return !empty($userid);
 }
Esempio n. 3
0
 /**
  * Return true if the user can set the todo item as 'done'
  */
 public function allowDone($userid)
 {
     // If the userid is the stream owner, allow it
     if ($this->data->user_id == $userid) {
         return true;
     }
     // If stream belong to a group and userid is a member of the group
     // allow it
     if (!empty($this->data->group_id)) {
         $user = JXFactory::getUser($userid);
         $userGroups = $user->getParam('groups_member');
         return JXUtility::csvExist($userGroups, $this->data->group_id);
     }
     return false;
 }
Esempio n. 4
0
function offiria_list_groups($groups, $title, $groupIJoin, $groupIFollow)
{
    $group_id = JRequest::getVar('group_id');
    $my = JXFactory::getUser();
    $streamModel = StreamFactory::getModel('stream');
    ?>
	<div class="groups-listing followed">
		<h3><?php 
    echo $title;
    ?>
</h3>
		<?php 
    // Only show list of groups if there is any
    if (!empty($groups)) {
        ?>
		<ul>
			<?php 
        foreach ($groups as $group) {
            ?>
			<li class="groups <?php 
            if ($group_id == $group->id) {
                echo 'active';
            }
            ?>
">
				<?php 
            $lastReadId = $my->getParam('group_' . $group->id . '_read');
            $statusClass = JXUtility::csvExist($groupIJoin, $group->id) ? 'joined' : 'followed';
            $groupLastMsg = $group->getParam('last_message');
            $groupNewMsg = 0;
            // Only calculate if there is a diff here
            if ($lastReadId != $groupLastMsg) {
                $groupNewMsg = $streamModel->countStream(array('!user_id' => $my->id, 'id_more' => $lastReadId, 'group_id' => $group->id));
            }
            $styleHide = '';
            ?>

				<a class="<?php 
            echo $statusClass;
            ?>
" id="groups_<?php 
            echo $group->id;
            ?>
_link" href="<?php 
            echo JRoute::_('index.php?option=com_stream&view=groups&task=show&group_id=' . $group->id);
            ?>
"><?php 
            echo StreamTemplate::escape($group->name);
            ?>
</a>

				<?php 
            if (intval($groupNewMsg) == 0) {
                $styleHide = 'display:none';
            }
            echo '<span style="' . $styleHide . '" class="navigator-notice" id="groups_' . $group->id . '">' . intval($groupNewMsg) . '</span>';
            ?>
				<!-- <span class="navigator-notice"></span> -->
			</li>
			<?php 
        }
        ?>
		</ul>
		<?php 
    }
    ?>
	</div>
<?php 
}
Esempio n. 5
0
 /**
  *  AJAX Add Tag
  */
 public function tagAdd()
 {
     $message_id = JRequest::getInt('message_id');
     $tag = JRequest::getVar('tag');
     // Filter unsupported characters. TODO: ajax error status/msg handling
     $unsupportedChars = array(',');
     $tag = str_replace($unsupportedChars, '', $tag);
     $hashedTag = '#' . trim($tag) . '#';
     // Unlike message hash tags, we wrap them in hashes for specific searching
     $stream = JTable::getInstance('Stream', 'StreamTable');
     $stream->load($message_id);
     $rawData = json_decode($stream->raw);
     $rawData->tags = isset($rawData->tags) ? $rawData->tags : '';
     /* TODO: TEMPORARY START: Wrap tags without them */
     if (!empty($rawData->tags)) {
         $tagsExploded = explode(',', $rawData->tags);
         $addHashesCallback = create_function('$value', 'if($value[0] != "#" && $value[strlen($value)-1] != "#") { return "#".$value."#"; } else { return $value; }');
         $tagsExploded = array_map($addHashesCallback, $tagsExploded);
         $rawData->tags = implode(',', $tagsExploded);
     }
     /* TEMPORARY END */
     if (!JXUtility::csvExist($rawData->tags, $hashedTag)) {
         $rawData->tags = JXUtility::csvInsert($rawData->tags, $hashedTag);
         $stream->raw = json_encode($rawData);
         $stream->store(true);
         $tagsTrend = new StreamTag();
         $tagsTrend->updateTrending($tag, $stream->group_id, true);
     }
     $tmpl = new StreamTemplate();
     $tmpl->set('stream', $stream);
     $data = array();
     $data['html'] = $tmpl->fetch('stream.tag');
     $data['id'] = $message_id;
     $group_id = JRequest::getVar('group_id');
     header('Content-Type: text/json');
     echo json_encode($data);
     exit;
 }
Esempio n. 6
0
<?php

if ($group->isMember($my->id) || $my->isAdmin()) {
    if ($group->archived) {
        ?>
		<div class="alert-message block-message warning group-filter">       
		<p>This group has been archived. You can no longer leave a message in this group. An achived group simply mean that this group is no longer active and has either completed its objectives</p>        
		</div>
	<?php 
    } else {
        // Allow only group members to see the stream.post box
        $userGroups = $my->getParam('groups_member');
        if (JXUtility::csvExist($userGroups, $group->id)) {
            if (JRequest::getVar('template') != 'mobile') {
                $tmpl = new StreamTemplate();
                echo $tmpl->set('title', "title")->set('group_id', $group->id)->fetch('stream.post');
            }
        }
    }
}
?>
<script type="text/javascript">

$(function() {
	/* Follow group */	
	$('a[href="#followGroup"]').click(function() {
		$.ajax({
			type: "POST",
			url: S.path['group.follow'],
			data: $('form[name="group-actions"]').serialize(),
			dataType: 'json',
Esempio n. 7
0
// Only show list of groups if there is any
if (!empty($myGroups)) {
    ?>
			<ul>
				<?php 
    foreach ($myGroups as $group) {
        ?>
				<li class="<?php 
        if ($group_id == $group->id) {
            echo 'active';
        }
        ?>
">
					<?php 
        $lastReadId = $my->getParam('group_' . $group->id . '_read');
        $statusClass = JXUtility::csvExist($groupIJoin, $group->id) ? 'joined' : 'followed';
        $groupLastMsg = $group->getParam('last_message');
        $groupNewMsg = 0;
        // Only calculate if there is a diff here
        if ($lastReadId != $groupLastMsg) {
            $groupNewMsg = $streamModel->countStream(array('!user_id' => $my->id, 'id_more' => $lastReadId, 'group_id' => $group->id));
        }
        $styleHide = '';
        ?>
					
					<a class="<?php 
        echo $statusClass;
        ?>
" id="groups_<?php 
        echo $group->id;
        ?>
Esempio n. 8
0
 /**
  * If it is private group, you can read, if you're a member
  */
 public function allowRead($userid)
 {
     // If the user is limited by group, do not allow them to access group
     // beyond their assigned group
     $user = JXFactory::getUser($userid);
     $limitGroup = $user->getParam('groups_member_limited');
     if ($limitGroup) {
         return JXUtility::csvExist($limitGroup, $this->id);
     }
     if (!$this->access) {
         return true;
     }
     $userGroups = $user->getParam('groups_member');
     return JXUtility::csvExist($userGroups, $this->id);
 }