<?php 
# ************** LICENCE ****************
/*
	Copyright (c) PORTANEO.
*/
# ***************************************
# Display group members
#
# !! be careful, this file must be saved under uft8 format, and display an e accentuated here : é
# ***************************************
$not_access=1;
$granted="I";

require_once('includes_mobile.php');
require_once('../../../../db_layer/'.__DBTYPE.'/portal.php');
require_once('../includes/template.inc.php');
require_once('../../../../db_layer/'.__DBTYPE.'/enterprise.php');
require_once('../includes/date.inc.php');

$id = (isset($_GET['id']))          ?       $_GET['id']         :       0;
$page = isset($_GET['page'])        ?       $_GET['page']       :       0;
$ismyprofil = false;
$myarticles = array();
$previousStr = '';
$nextStr = '';

$options = defineHeader();
     
echo page_begining();

echo '<div id="header">';
    echo generate_header($options,$message);
echo '</div>';

echo '<div id="wrapper">';
echo '<div id="page">';		

//group control: check if the user user has access to the group notebook.
include_once('../../../../notebook/groupsecurity.inc.php');
if ($userIsMemberOfGroup == 0) {
    echo generate_warning('alert',lg("NotCorrectGroup"),'','');
    echo "</div>";
    echo "</div>";
	echo generate_footer("group");
	exit();
}

$myNetwork = array();
$DB->getResults($xmlnetworkusers_getDesc,$DB->escape($_SESSION['user_id']));
$i = 0;
while($row = $DB->fetch(0)) {
    $friend_id = $row['id'];
    $myNetwork[$i] = $friend_id;
    $i++;
}

$DB->getResults($notebook_getGroupbookProperties,$DB->escape($_SESSION['user_id']),$DB->escape($id));
$nbRes = $DB->nbResults();
if ($nbRes == 0) {
	echo generate_warning('info',''.lg("NotCorrectGroup").'','','');
    echo "</div>";
    echo "</div>";
	echo generate_footer("group");
	exit();
}
$row = $DB->fetch(0);
$description = $row['description'];
if (strlen($description)>75) {
    $description = formatString($description,75).'...';
}
echo '
      <div class="users">
        <div class="title">
            <img src="../../../'.displayPicture($row['picture']).'" class="avatar" width="50" height="50" style="float: left;margin-right: 5px;">
            <span>'.$row['name'].'</span>
        </div>';
            if ($description != '') echo '<div class="subtitle">'.$description.'</div>';  
echo '	<div class="links">
                <a href="groupbook.php?id='.$id.'" class="greylink">'.lg("publications").'</a> |';
    echo '      <a href="groupbook_addarticle.php?id='.$id.'" class="greylink">'.lg("add_article").'</a>';
echo '  </div>
      </div>';
$DB->freeResults();

//members list
$cpt = 0;
$DB->getResults($mobNetworkusers_getUsersByNotebook, $DB->escape($id), $DB->escape($page));
while ( ($row = $DB->fetch(0)) && $cpt<10) {
    $idfriend = $row["id"];
    $creator = $row["created_by"];
	echo '
		  <div class="users">
			<div class="title">
                <a href="notebook_articles.php?id='.$idfriend.'&page=0"><img src="../../../'.displayPicture($row['picture']).'" class="avatar" width="50" height="50" style="float: left;margin-right: 5px;"></a>
                <a href="notebook_articles.php?id='.$idfriend.'&page=0">'.$row['long_name'].' '.$row['firstname'].'</a>';
    if ($creator == $idfriend)
    echo '      <span style="color:orange;">['.lg("manager").']</font></span>';
	echo '  </div>';
    if ($row['stat']!='') echo '<div class="subtitle">'.$row['stat'].'</div>';  
	echo '<div class="memberlinks"><a href="notebook_articles.php?id='.$idfriend.'">'.lg("hisnotebook").'</a> ';
    if (!in_array($idfriend, $myNetwork) && $idfriend!=$_SESSION['user_id'])
    echo '| <a href="network_add_user.php?id='.$idfriend.'&group='.$id.'">'.lg("add_contact").'</a>';
echo '     </div>
		  </div>';
          
    $cpt++;
}
$DB->freeResults();

if ($page!=0) {
	$previousStr = '<a href="group_members.php?page='.($page-10).'">'.lg("page_back").'</a>';
}
if ($max == 11) {
	$nextStr = '<a href="group_members.php?page='.($page+10).'">'.lg("page_next").'</a>';
}

echo '<center><div>'.$previousStr.' &nbsp;&nbsp; '.$nextStr.'</div></center>'; 

echo "</div>";
echo "</div>";

echo generate_footer("group");
?>