UI improvements - user groups see #5508

skala
Julio Montoya 16 years ago
parent cc51cbf16f
commit d7600dc5cc
  1. 54
      main/admin/add_users_to_group.php
  2. 2
      main/admin/add_users_to_session.php
  3. 4
      main/admin/group_list.php
  4. 12
      main/css/blue_lagoon/default.css
  5. BIN
      main/img/unknown_50_50.jpg
  6. BIN
      main/img/unknown_group.png
  7. 123
      main/inc/lib/group_portal_manager.lib.php
  8. 15
      main/inc/lib/usermanager.lib.php
  9. 10
      main/social/groups.php

@ -39,7 +39,7 @@ $tbl_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tool_name = get_lang('SubscribeUsersToGroup'); $tool_name = get_lang('SubscribeUsersToGroup');
$group_id = intval($_GET['id']); $group_id = intval($_GET['id']);
$add_type = 'single'; $add_type = 'multiple';
if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
$add_type = Security::remove_XSS($_REQUEST['add_type']); $add_type = Security::remove_XSS($_REQUEST['add_type']);
} }
@ -210,13 +210,17 @@ if($_POST['form_sent']) {
$UserList = $_POST['sessionUsersList']; $UserList = $_POST['sessionUsersList'];
$ClassList = $_POST['sessionClassesList']; $ClassList = $_POST['sessionClassesList'];
$group_id = intval($_POST['id']);
if(!is_array($UserList)) { if(!is_array($UserList)) {
$UserList=array(); $UserList=array();
} }
if ($form_sent == 1) { if ($form_sent == 1) {
//added a parameter to send emails when registering a user $result = GroupPortalManager::add_users_to_groups($UserList, array($group_id));
// SessionManager::suscribe_users_to_session($id_session,$UserList,true,true);
//SessionManager::suscribe_users_to_session($id_session,$UserList,true,true);
//adding the session to the access_url_rel_session table //adding the session to the access_url_rel_session table
/*global $_configuration; /*global $_configuration;
@ -333,13 +337,11 @@ if ($ajax_search) {
ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session' ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
$where_filter $where_filter
$order_clause"; $order_clause";
} else { } else {
$sql="SELECT u.user_id, lastname, firstname, username, group_id $sql="SELECT u.user_id, lastname, firstname, username, group_id
FROM $tbl_user u FROM $tbl_user u
LEFT JOIN $tbl_group_rel_user gu LEFT JOIN $tbl_group_rel_user gu
ON (gu.user_id = u.user_id) WHERE gu.group_id = $group_id ON (gu.user_id = u.user_id) AND gu.group_id = $group_id
$order_clause"; $order_clause";
} }
@ -364,13 +366,13 @@ if ($ajax_search) {
if($user['group_id'] != $group_id) if($user['group_id'] != $group_id)
$nosessionUsersList[$user['user_id']] = $user ; $nosessionUsersList[$user['user_id']] = $user ;
} }
var_dump($nosessionUsersList);
$user_anonymous=api_get_anonymous_id(); $user_anonymous=api_get_anonymous_id();
/* foreach($nosessionUsersList as $key_user_list =>$value_user_list) { foreach($nosessionUsersList as $key_user_list =>$value_user_list) {
if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) { if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) {
unset($nosessionUsersList[$key_user_list]); unset($nosessionUsersList[$key_user_list]);
} }
}*/ }
//filling the correct users in list //filling the correct users in list
$sql="SELECT u.user_id, lastname, firstname, username, group_id $sql="SELECT u.user_id, lastname, firstname, username, group_id
@ -392,6 +394,7 @@ if ($ajax_search) {
$order_clause"; $order_clause";
} }
} }
$result=Database::query($sql,__FILE__,__LINE__); $result=Database::query($sql,__FILE__,__LINE__);
$Users=Database::store_result($result); $Users=Database::store_result($result);
@ -402,7 +405,7 @@ if ($ajax_search) {
} }
foreach ($Users as $user) { foreach ($Users as $user) {
if($user['group_id'] == $group_id){ if($user['group_id'] == $group_id) {
$sessionUsersList[$user['user_id']] = $user; $sessionUsersList[$user['user_id']] = $user;
if (array_key_exists($user['user_id'],$nosessionUsersList)) if (array_key_exists($user['user_id'],$nosessionUsersList))
unset($nosessionUsersList[$user['user_id']]); unset($nosessionUsersList[$user['user_id']]);
@ -411,25 +414,21 @@ if ($ajax_search) {
} }
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
//$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; $link_add_type_unique = '<a href="'.api_get_self().'?id='.$group_id.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
//$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
} else { } else {
//$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'); $link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
//$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>'; $link_add_type_multiple = '<a href="'.api_get_self().'?id='.$group_id.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
/*
* <div class="actions">
<?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>
</div>
*/
} }
?> ?>
<div class="actions">
<?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>
</div>
<?php echo '<div class="row"><div class="form_header">'.$tool_name.' ('.$session_info['name'].')</div></div><br/>'; ?> <?php echo '<div class="row"><div class="form_header">'.$tool_name.' ('.$session_info['name'].')</div></div><br/>'; ?>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo Security::remove_XSS($_GET['page']); ?>&id_session=<?php echo $id_session; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $group_id; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
<?php <?php
if ($add_type=='multiple') { if ($add_type=='multiple') {
@ -461,6 +460,7 @@ if ($add_type=='multiple') {
?> ?>
<input type="hidden" name="form_sent" value="1" /> <input type="hidden" name="form_sent" value="1" />
<input type="hidden" name="id" value="<?=$group_id?>" />
<input type="hidden" name="add_type" /> <input type="hidden" name="add_type" />
<?php <?php
@ -537,7 +537,7 @@ if(!empty($errorMsg)) {
<?php <?php
} }
?> ?>
<br /><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br />
</td> </td>
<td align="center"> <td align="center">
<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;"> <select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:360px;">
@ -559,13 +559,7 @@ unset($sessionUsersList);
<td colspan="3" align="center"> <td colspan="3" align="center">
<br /> <br />
<?php <?php
if(isset($_GET['add'])) { echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToGroup').'</button>';
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
} else {
//@todo see that the call to "valide()" doesn't duplicate the onsubmit of the form (necessary to avoid delete on "enter" key pressed)
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToGroup').'</button>';
}
?> ?>
</td> </td>
</tr> </tr>

@ -373,7 +373,7 @@ if ($ajax_search) {
$order_clause"; $order_clause";
} }
} }
echo $sql;
$result=Database::query($sql,__FILE__,__LINE__); $result=Database::query($sql,__FILE__,__LINE__);
$Users=Database::store_result($result); $Users=Database::store_result($result);
//var_dump($_REQUEST['id_session']); //var_dump($_REQUEST['id_session']);

@ -106,7 +106,7 @@ function get_group_data($from, $number_of_items, $column, $direction)
$users = array (); $users = array ();
$t = time(); $t = time();
while ($group = Database::fetch_row($res)) { while ($group = Database::fetch_row($res)) {
// forget about the expiration date field $group['1'] = '<a href="/main/social/groups.php?id='.$group['0'].'">'.$group['1'].'</a>';
$groups[] = $group; $groups[] = $group;
} }
return $groups; return $groups;
@ -180,8 +180,6 @@ function modify_filter($group_id,$url_params,$row)
$result .= '<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_users_to_group.php?id='.$group_id.'">'.Display::return_icon('add_user_big.gif',get_lang('AddUsersToGroup')).'</a>'; $result .= '<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_users_to_group.php?id='.$group_id.'">'.Display::return_icon('add_user_big.gif',get_lang('AddUsersToGroup')).'</a>';
$result .= '<a href="group_edit.php?id='.$group_id.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>&nbsp;&nbsp;'; $result .= '<a href="group_edit.php?id='.$group_id.'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>&nbsp;&nbsp;';
$result .= '<a href="group_list.php?action=delete_group&amp;group_id='.$group_id.'&amp;'.$url_params.'&amp;sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>'; $result .= '<a href="group_list.php?action=delete_group&amp;group_id='.$group_id.'&amp;'.$url_params.'&amp;sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
} }
return $result; return $result;
} }

@ -2616,6 +2616,8 @@ input.arrowl {
/* UI improvements */ /* UI improvements */
* { * {
outline :none; outline :none;
} }
@ -2641,3 +2643,13 @@ input, select, textarea {
input[type="text"]:focus, input[type="password"]:focus, textarea:focus { input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
background-image:url(images/shadow.gif); background-image:url(images/shadow.gif);
} }
.independent_course_item a {
font-size:120%;
}
.session_course_item a {
font-size:120%;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

@ -4,7 +4,7 @@
============================================================================== ==============================================================================
* This library provides functions for the access_url management. * This library provides functions for the access_url management.
* Include/require it in your code to use its functionality. * Include/require it in your code to use its functionality.
* * @author Julio Montoya <gugli100@gmail.com>
* @package dokeos.library * @package dokeos.library
============================================================================== ==============================================================================
*/ */
@ -147,6 +147,9 @@ class GroupPortalManager
/** /**
* Gets data of all groups * Gets data of all groups
* @author Julio Montoya * @author Julio Montoya
* @param int visibility
* @param int from which record the results will begin (use for pagination)
* @param int number of items
* @return array * @return array
* */ * */
function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10) function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10)
@ -163,6 +166,11 @@ class GroupPortalManager
return $data; return $data;
} }
/**
* Gets the group data
*
*
*/
function get_group_data($group_id) function get_group_data($group_id)
{ {
$table = Database :: get_main_table(TABLE_MAIN_GROUP); $table = Database :: get_main_table(TABLE_MAIN_GROUP);
@ -177,6 +185,12 @@ class GroupPortalManager
return $item; return $item;
} }
/**
* Gets the tags from a given group
* @param int group id
* @param bool show group links or not
*
*/
function get_group_tags($group_id, $show_tag_links = true) function get_group_tags($group_id, $show_tag_links = true)
{ {
$tag = Database :: get_main_table(TABLE_MAIN_TAG); $tag = Database :: get_main_table(TABLE_MAIN_TAG);
@ -283,7 +297,7 @@ class GroupPortalManager
$array = array(); $array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image == true) { if ($with_image == true) {
$picture = UserManager::get_picture_user($row['user_id'], $row['picture_uri'],80); $picture = UserManager::get_picture_user($row['user_id'], $row['picture_uri'],80,'medium_');
$img = '<img src="'.$picture['file'].'" />'; $img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img; $row['picture_uri'] = $img;
} }
@ -374,8 +388,9 @@ class GroupPortalManager
* @author Julio Montoya * @author Julio Montoya
* @param int user id * @param int user id
* @param int group_id * @param int group_id
* @return boolean true if success * @return int 0 if there are not relationship otherwise return GROUP_USER_PERMISSION_ADMIN or GROUP_USER_PERMISSION_READER constants
* */ * */
function get_user_group_role($user_id, $group_id) function get_user_group_role($user_id, $group_id)
{ {
$table_group_rel_user= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
@ -425,35 +440,6 @@ class GroupPortalManager
} }
/**
* Add a group of users into a group of URLs
* @author Julio Montoya
* @param array of user_ids
* @param array of url_ids
* */
function add_users_to_urls($user_list, $url_list)
{
$table_url_rel_user= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$result_array=array();
if (is_array($user_list) && is_array($url_list)){
foreach ($url_list as $url_id) {
foreach ($user_list as $user_id) {
$count = UrlManager::relation_url_user_exist($user_id,$url_id);
if ($count==0) {
$sql = "INSERT INTO $table_url_rel_user
SET user_id = ".Database::escape_string($user_id).", access_url_id = ".Database::escape_string($url_id);
$result = Database::query($sql, __FILE__, __LINE__);
if($result)
$result_array[$url_id][$user_id]=1;
else
$result_array[$url_id][$user_id]=0;
}
}
}
}
return $result_array;
}
/** /**
@ -540,34 +526,40 @@ class GroupPortalManager
return $result; return $result;
} }
function add_course_to_url($course_code, $url_id=1)
{
$table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
if (empty($url_id)) $url_id=1;
$count = UrlManager::relation_url_course_exist($course_code,$url_id);
if (empty($count)) {
$sql = "INSERT INTO $table_url_rel_course
SET course_code = '".Database::escape_string($course_code)."', access_url_id = ".Database::escape_string($url_id);
$result = Database::query($sql, __FILE__, __LINE__);
}
return $result;
}
/**
* Add a group of users into a group of URLs
* @author Julio Montoya
* @param array of user_ids
* @param array of url_ids
* */
function add_users_to_groups($user_list, $group_list, $relation_type = GROUP_USER_PERMISSION_READER) {
$table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$result_array = array();
$relation_type = intval($relation_type);
function add_session_to_url($session_id, $url_id=1) if (is_array($user_list) && is_array($group_list)) {
{ foreach ($group_list as $group_id) {
$table_url_rel_session= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); foreach ($user_list as $user_id) {
if (empty($url_id)) $url_id=1; $role = self::get_user_group_role($user_id,$group_id);
$count = UrlManager::relation_url_session_exist($session_id,$url_id); if ($role == 0) {
if (empty($count)) { $sql = "INSERT INTO $table_url_rel_group
$sql = "INSERT INTO $table_url_rel_session SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type)."";
SET session_id = ".Database::escape_string($session_id).", access_url_id = ".Database::escape_string($url_id);
$result = Database::query($sql, __FILE__, __LINE__); $result = Database::query($sql, __FILE__, __LINE__);
if ($result)
$result_array[$group_id][$user_id]=1;
else
$result_array[$group_id][$user_id]=0;
}
}
}
} }
return $result; return $result_array;
} }
/** /**
* Deletes an url and user relationship * Deletes an url and user relationship
* @author Julio Montoya * @author Julio Montoya
@ -815,14 +807,14 @@ class GroupPortalManager
/** /**
* Creates new user pfotos in various sizes of a user, or deletes user pfotos. * Creates new group pictures in various sizes of a user, or deletes user pfotos.
* Note: This method relies on configuration setting from dokeos/main/inc/conf/profile.conf.php * Note: This method relies on configuration setting from dokeos/main/inc/conf/profile.conf.php
* @param int $user_id The user internal identitfication number. * @param int The group id
* @param string $file The common file name for the newly created pfotos. It will be checked and modified for compatibility with the file system. * @param string $file The common file name for the newly created pfotos. It will be checked and modified for compatibility with the file system.
* If full name is provided, path component is ignored. * If full name is provided, path component is ignored.
* If an empty name is provided, then old user photos are deleted only, @see UserManager::delete_user_picture() as the prefered way for deletion. * If an empty name is provided, then old user photos are deleted only, @see UserManager::delete_user_picture() as the prefered way for deletion.
* @param string $source_file The full system name of the image from which user photos will be created. * @param string $source_file The full system name of the image from which user photos will be created.
* @return string/bool Returns the resulting common file name of created images which usually should be stored in database. * @return string/bool Returns the resulting common file name of created images which usually should be stored in database.
* When deletion is recuested returns empty string. In case of internal error or negative validation returns FALSE. * When deletion is recuested returns empty string. In case of internal error or negative validation returns FALSE.
*/ */
public static function update_group_picture($group_id, $file = null, $source_file = null) { public static function update_group_picture($group_id, $file = null, $source_file = null) {
@ -919,7 +911,7 @@ class GroupPortalManager
} }
/** /**
* Get user picture URL or path from user ID (returns an array). * Gets the group picture URL or path from group ID (returns an array).
* The return format is a complete path, enabling recovery of the directory * The return format is a complete path, enabling recovery of the directory
* with dirname() or the file with basename(). This also works for the * with dirname() or the file with basename(). This also works for the
* functions dealing with the user's productions, as they are located in * functions dealing with the user's productions, as they are located in
@ -981,7 +973,7 @@ class GroupPortalManager
return array('dir' => $dir, 'file' => $picture_filename); return array('dir' => $dir, 'file' => $picture_filename);
} }
/** /**
* Resize a picture * Resize a picture
* *
* @param string file picture * @param string file picture
@ -1006,10 +998,11 @@ class GroupPortalManager
} }
return $temp; return $temp;
} }
/**
* Gets the current user image /**
* @param string user id * Gets the current group image
* @param string picture user name * @param string group id
* @param string picture group name
* @param string height * @param string height
* @param string picture size it can be small_, medium_ or big_ * @param string picture size it can be small_, medium_ or big_
* @param string style css * @param string style css

@ -2209,7 +2209,17 @@ class UserManager
if (file_exists($file) && !is_dir($file)) { if (file_exists($file) && !is_dir($file)) {
$picture['file'] = $image_array['dir'].$picture_file; $picture['file'] = $image_array['dir'].$picture_file;
} else { } else {
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; switch ($size_picture) {
case 'big_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; break;
case 'medium_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_50_50.jpg'; break;
case 'small_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; break;
default:
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; break;
}
} }
} }
return $picture; return $picture;
@ -2565,10 +2575,9 @@ class UserManager
$where_field = " field_id = $field_id AND "; $where_field = " field_id = $field_id AND ";
} }
// all the information of the field // all the information of the field
$sql = "SELECT u.user_id,u.username,firstname, lastname, email, tag, picture_uri FROM $table_user_tag ut INNER JOIN $table_user_tag_values uv ON (uv.tag_id=ut.id) $sql = "SELECT u.user_id,u.username,firstname, lastname, email, tag, picture_uri FROM $table_user_tag ut INNER JOIN $table_user_tag_values uv ON (uv.tag_id=ut.id)
INNER JOIN $user_table u ON(uv.user_id =u.user_id) INNER JOIN $user_table u ON(uv.user_id =u.user_id)
WHERE $where_field tag LIKE '$tag%' ORDER BY tag"; WHERE $where_field tag LIKE '$tag%' ORDER BY tag";
$sql .= " LIMIT $from,$number_of_items"; $sql .= " LIMIT $from,$number_of_items";
$result = Database::query($sql, __FILE__, __LINE__); $result = Database::query($sql, __FILE__, __LINE__);

@ -26,8 +26,12 @@ if ($group_id != 0 ) {
$tags = GroupPortalManager::get_group_tags($group_id,true); $tags = GroupPortalManager::get_group_tags($group_id,true);
$users = GroupPortalManager::get_users_by_group($group_id,true); $users = GroupPortalManager::get_users_by_group($group_id,true);
//@todo this must be move to default.css for dev use only
echo '<style>
#group_members { width:250px; height:300px; overflow-x:none; overflow-y: auto;}
.group_member_item { width:80px; float:left;}
//var_dump($users); </style>';
//Group's title //Group's title
@ -60,10 +64,10 @@ if ($group_id != 0 ) {
echo '</div>'; echo '</div>';
} }
echo get_lang('Members').' : ';
echo '<div id="group_members">'; echo '<div id="group_members">';
echo get_lang('Members').' : ';
foreach($users as $user) { foreach($users as $user) {
echo $user['picture_uri'].$user['firstname'].$user['lastname'].'<br />'; echo '<div class="group_member_item">'.$user['picture_uri'].$user['firstname'].$user['lastname'].'</div>';
} }
echo '</div>'; echo '</div>';

Loading…
Cancel
Save