skala
Julio Montoya Armas 16 years ago
commit 22f2caaa91
  1. 7
      documentation/changelog.html
  2. 2
      main/admin/add_users_to_group.php
  3. 9
      main/css/blue_lagoon/default.css
  4. 1
      main/inc/lib/display.lib.php
  5. 88
      main/inc/lib/group_portal_manager.lib.php
  6. 7
      main/inc/lib/sortabletable.class.php
  7. 2
      main/inc/lib/usermanager.lib.php
  8. 151
      main/social/group_edit.php
  9. 73
      main/social/groups.php

@ -43,6 +43,13 @@
<li>Added user' photo into user list interface - DT#5496</li>
<li>Disabled field trainers(tutor name) in create course form from user portal, by default is current user's name, you can modify this field into setting course - DT#5496 </li>
<li>Added option to export the trainings list to CSV file in Administration>Trainings - DT#4256</li>
<li>Gradebook automatic deleted bug of a link fixed DT#5229</li>
<li>User tags added DT#5508</li>
<li>Who is online look revamped DT#5490</li>
<li>New search tool added DT#5610 </li>
<li>User groups added DT#5611 </li>
<li>Social network tab added</li>
</ul>
<h3>Debugging</h3>
<ul>

@ -217,6 +217,8 @@ if($_POST['form_sent']) {
}
if ($form_sent == 1) {
GroupPortalManager::delete_users($group_id);
$result = GroupPortalManager::add_users_to_groups($UserList, array($group_id));

@ -149,7 +149,7 @@ input.link_alike:hover {
.coursestatusicons {
border: 0px solid #000;
float: left;
padding-right: 5px;
padding-right: 8px;
width: auto;
}
/* user_portal course list */
@ -2653,8 +2653,6 @@ input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
background-image:url(images/shadow.gif);
}
.independent_course_item a {
font-size:120%;
}
@ -2662,3 +2660,8 @@ input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
.session_course_item a {
font-size:120%;
}
#maincontent .courseslist li {
margin-bottom:8px;
}

@ -317,6 +317,7 @@ class Display {
$column = 0;
$default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
$table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars);
}

@ -260,7 +260,7 @@ class GroupPortalManager
$sql = "SELECT g.picture_uri, g.name, g.description, g.id
FROM $tbl_group g
INNER JOIN $table_group_rel_user gu
ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition ";
ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition ORDER BY created_on desc ";
$result=Database::query($sql,__FILE__,__LINE__);
$array = array();
@ -275,6 +275,76 @@ class GroupPortalManager
return $array;
}
/** Gets the inner join of users and group table
* @author Julio Montoya
* @return int access url id
* @return array Database::store_result of the result
* */
function get_groups_by_popularity($num = 10, $with_image = false)
{
$where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
if (empty($num)) {
$num = 10;
} else {
$num = intval($num);
}
$sql = "SELECT count(user_id) as count, g.picture_uri, g.name, g.description, g.id
FROM $tbl_group g
INNER JOIN $table_group_rel_user gu
ON gu.group_id = g.id GROUP BY g.id ORDER BY count DESC LIMIT $num";
$result=Database::query($sql,__FILE__,__LINE__);
$array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image == true) {
$picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
$img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img;
}
$array[$row['id']] = $row;
}
return $array;
}
/** Gets the last groups created
* @author Julio Montoya
* @return int access url id
* @return array Database::store_result of the result
* */
function get_groups_by_age($num = 10, $with_image = false)
{
$where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
if (empty($num)) {
$num = 10;
} else {
$num = intval($num);
}
$sql = "SELECT g.picture_uri, g.name, g.description, g.id
FROM $tbl_group g
INNER JOIN $table_group_rel_user gu
ON gu.group_id = g.id ORDER BY created_on desc LIMIT $num ";
$result=Database::query($sql,__FILE__,__LINE__);
$array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image == true) {
$picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
$img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img;
}
$array[$row['id']] = $row;
}
return $array;
}
function get_users_by_group($group_id='', $with_image = false)
{
$where = '';
@ -396,10 +466,10 @@ class GroupPortalManager
$table_group_rel_user= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$return_value = 0;
if (!empty($user_id) && !empty($group_id)) {
$sql = "SELECT relation_type FROM $table_group_rel_user WHERE id = ".intval($group_id)." AND user_id = ".intval($user_id)." ";
$sql = "SELECT relation_type FROM $table_group_rel_user WHERE group_id = ".intval($group_id)." AND user_id = ".intval($user_id)." ";
$result = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($result)>0) {
$row = Database::fetch_row($result);
$row = Database::fetch_array($result,'ASSOC');
$return_value = $row['relation_type'];
}
}
@ -567,10 +637,10 @@ class GroupPortalManager
* @param int url id
* @return boolean true if success
* */
function delete_url_rel_user($user_id, $url_id)
function delete_users($group_id)
{
$table_url_rel_user= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql= "DELETE FROM $table_url_rel_user WHERE user_id = ".Database::escape_string($user_id)." AND access_url_id=".Database::escape_string($url_id)." ";
$table_= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$sql= "DELETE FROM $table_ WHERE group_id = ".intval($group_id);
$result = Database::query($sql, __FILE__, __LINE__);
return $result;
}
@ -597,10 +667,10 @@ class GroupPortalManager
* @param int url id
* @return boolean true if success
* */
function delete_url_rel_session($session_id, $url_id)
function delete_user_rel_group($user_id, $group_id)
{
$table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$sql= "DELETE FROM $table_url_rel_session WHERE session_id = ".Database::escape_string($session_id)." AND access_url_id=".Database::escape_string($url_id)." ";
$table = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$sql= "DELETE FROM $table WHERE user_id = ".intval($user_id)." AND group_id=".intval($group_id)." ";
$result = Database::query($sql, __FILE__, __LINE__);
return $result;
}

@ -492,7 +492,14 @@ class SortableTable extends HTML_Table {
</style>';
if ($hide_navigation == true ) {
$items = $this->table_data; //this is a faster way to get what we want
} else {
//the normal way
$items = $this->get_clean_html(); // getting the items of the table
}
// the generating of style classes must be improved. Maybe we need a a table name to create style on the fly:
// i.e: .whoisonline_table_grid_container instead of .grid_container
// where whoisonline is the table's name like drupal's template engine

@ -2652,7 +2652,7 @@ class UserManager
</div>
<div>
<input type="text" size="30" value="'.Security::remove_XSS($query).'" tabindex="1" id="standard_q" name="q"/>
<input type="submit" value="search"/>
<button class="search" value="search"/>'.get_lang('Search').'</button>
</div>
</td>
</tr>

@ -0,0 +1,151 @@
<?php // $Id: user_edit.php 22233 2009-07-20 09:54:05Z ivantcholakov $
/* For licensing terms, see /dokeos_license.txt */
/**
==============================================================================
* @package dokeos.admin
==============================================================================
*/
// Language files that should be included
$language_file = array('admin');
$cidReset = true;
include '../inc/global.inc.php';
$this_section = SECTION_SOCIAL;
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath.'fileManage.lib.php';
require_once $libpath.'fileUpload.lib.php';
require_once $libpath.'group_portal_manager.lib.php';
require_once $libpath.'formvalidator/FormValidator.class.php';
require_once $libpath.'image.lib.php';
require_once $libpath.'mail.lib.inc.php';
require_once $libpath.'social.lib.php';
$group_id = isset($_GET['id']) ? intval($_GET['id']) : intval($_POST['id']);
$tool_name = get_lang('GroupEdit');
$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'group_list.php','name' => get_lang('GroupList'));
$table_group = Database::get_main_table(TABLE_MAIN_GROUP);
$sql = "SELECT * FROM $table_group WHERE id = '".$group_id."'";
$res = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($res) != 1) {
header('Location: groups.php?id='.$group_id);
exit;
}
$group_data = Database::fetch_array($res, 'ASSOC');
// Create the form
$form = new FormValidator('group_edit', 'post', '', '', array('style' => 'width: 60%; float: '.($text_dir == 'rtl' ? 'right;' : 'left;')));
$form->addElement('header', '', $tool_name);
$form->addElement('hidden', 'id', $group_id);
// name
$form->addElement('text', 'name', get_lang('Name'));
$form->applyFilter('name', 'html_filter');
$form->applyFilter('name', 'trim');
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
// Description
$form->addElement('text', 'description', get_lang('Description'));
$form->applyFilter('description', 'html_filter');
$form->applyFilter('description', 'trim');
// url
$form->addElement('text', 'url', get_lang('URL'));
$form->applyFilter('url', 'html_filter');
$form->applyFilter('url', 'trim');
// Picture
$form->addElement('file', 'picture', get_lang('AddPicture'));
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
if (strlen($group_data['picture_uri']) > 0) {
$form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
}
// Status
$status = array();
$status[GROUP_PERMISSION_OPEN] = get_lang('Open');
$status[GROUP_PERMISSION_CLOSED] = get_lang('Closed');
$form->addElement('select', 'visibility', get_lang('GroupPermissions'), $status, array());
// Submit button
$form->addElement('style_submit_button', 'submit', get_lang('ModifyInformation'), 'class="save"');
// Set default values
$form->setDefaults($group_data);
// Validate form
if ( $form->validate()) {
$group = $form->exportValues();
$picture_element = & $form->getElement('picture');
$picture = $picture_element->getValue();
$picture_uri = $group_data['picture_uri'];
if ($group['delete_picture']) {
$picture_uri = GroupPortalManager::delete_group_picture($group_id);
}
elseif (!empty($picture['name'])) {
$picture_uri = GroupPortalManager::update_group_picture($group_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']);
}
$name = $group['name'];
$description = $group['description'];
$url = $group['url'];
$status = intval($group['visibility']);
GroupPortalManager::update($group_id, $name, $description, $url, $status, $picture_uri);
$tok = Security::get_token();
header('Location: groups.php?id='.$group_id.'&action=show_message&message='.urlencode(get_lang('GroupUpdated')).'&sec_token='.$tok);
exit();
}
Display::display_header($tool_name);
//show the action menu
SocialManager::show_social_menu();
echo '<div class="actions-title">';
echo get_lang('Groups');
echo '</div>';
// Group picture
$image_path = GroupPortalManager::get_group_picture_path_by_id($group_id,'web');
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown_group.jpg');
$image_size = api_getimagesize($image_file);
$img_attributes = 'src="'.$image_file.'?rand='.time().'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" ';
if ($image_size[0] > 300) { //limit display width to 300px
$img_attributes .= 'width="300" ';
}
// get the path,width and height from original picture
$big_image = $image_dir.'big_'.$image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size[0];
$big_image_height = $big_image_size[1];
$url_big_image = $big_image.'?rnd='.time();
if ($image == '') {
echo '<img '.$img_attributes.' />';
} else {
echo '<input type="image" '.$img_attributes.' onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
}
// Display form
$form->display();
// Footer
Display::display_footer();

@ -21,6 +21,17 @@ echo '</div>';
$group_id = intval($_GET['id']);
if ($group_id != 0 ) {
if (isset($_GET['action']) && $_GET['action']=='leave') {
$user_leaved = intval($_GET['u']);
GroupPortalManager::delete_user_rel_group($user_leaved, $group_id);
}
if (isset($_GET['action']) && $_GET['action']=='join') {
$user_join = intval($_GET['u']);
GroupPortalManager::add_user_to_group($user_join, $group_id);
}
$group_info = GroupPortalManager::get_group_data($group_id);
$picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,'medium_');
$tags = GroupPortalManager::get_group_tags($group_id,true);
@ -73,48 +84,80 @@ if ($group_id != 0 ) {
echo '<div id="group_permissions">';
if (in_array(api_get_user_id(), $users)) {
if (is_array($users[api_get_user_id()]) && count($users[api_get_user_id()]) > 0) {
//im a member
if (isset($users[api_get_user_id()]) && $users[api_get_user_id()]['relation_info']!='') {
$my_group_role = $users[api_get_get_user_id()]['relation_info'];
// just a reader
if ($users[api_get_user_id()]['relation_type']!='') {
$my_group_role = $users[api_get_user_id()]['relation_type'];
// I'm just a reader
if ($my_group_role == GROUP_USER_PERMISSION_READER) {
echo 'Im just a reader';
echo 'Invite others';
echo 'Leave group';
echo '<a href="groups.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.get_lang('LeaveGroup').'</a>';
echo 'Invite others/';
//the main admin
} elseif ($my_group_role == GROUP_USER_PERMISSION_ADMIN) {
echo 'Imm the admin';
echo 'Edit group';
echo 'Im the admin/';
echo '<a href="group_edit.php?id='.$group_id.'">'.get_lang('EditGroup').'</a>';
echo 'Invite others';
}
} else {
//im not a member
echo 'I should register';
echo '<a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
}
} else {
//im not a member
echo 'I should register';
echo '<a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
}
echo '</div>';
} else {
// Newest groups ----------------
$results = GroupPortalManager::get_groups_by_age(10 , true);
$groups = array();
foreach ($results as $result) {
$id = $result['id'];
$url_open = '<a href="groups.php?id='.$id.'">';
$url_close = '</a>';
$groups[]= array($url_open.$result['picture_uri'].$url_close, $url_open.$result['name'].$url_close);
}
if (count($groups) > 0) {
echo '<h1>'.get_lang('Newest').'</h1>';
Display::display_sortable_grid('search_users', array(), $groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
}
// Pop groups ----------------
$results = GroupPortalManager::get_groups_by_popularity(10 , true);
$groups = array();
foreach ($results as $result) {
$id = $result['id'];
$url_open = '<a href="groups.php?id='.$id.'">';
$url_close = '</a>';
$groups[]= array($url_open.$result['picture_uri'].$url_close, $url_open.$result['name'].$url_close,$result['count']);
}
if (count($groups) > 0) {
echo '<h1>'.get_lang('Popular').'</h1>';
echo '<h1>'.get_lang('MyGroups').'</h1>';
Display::display_sortable_grid('search_users', array(), $groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true));
}
// My groups
$results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0, true);
$groups = array();
foreach ($results as $result) {
$id = $result['id'];
$url_open = '<a href="groups.php?id='.$id.'">';
$url_close = '</a>';
$groups[]= array($url_open.$result['picture_uri'].$url_close, $url_open.$result['name'].$url_close);
}
echo '<h1>'.get_lang('MyGroups').'</h1>';
if (count($groups) > 0) {
Display::display_sortable_grid('search_users', array(), $groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
} else {
echo get_lang('CreateAgroup');
}
}

Loading…
Cancel
Save