Remove gid unset, use api_get_group_id, api_get_course_id

1.10.x
Julio Montoya 10 years ago
parent 053ba518d4
commit 0a8495e3b5
  1. 2
      main/document/create_document.php
  2. 6
      main/forum/index.php
  3. 7
      main/forum/viewforumcategory.php
  4. 2
      main/inc/lib/access_url_edit_users_to_url_functions.lib.php
  5. 4
      main/inc/lib/hook/README.md
  6. 2
      main/inc/lib/jpegcam/webcam_receiver.php
  7. 47
      main/inc/lib/search/search_widget.php
  8. 47
      main/inc/lib/svg-edit/extensions/imagelib/groups.php
  9. 5
      main/permissions/group_permissions.inc.php
  10. 13
      main/user/subscribe_class.php
  11. 14
      main/user/subscribe_user.php

@ -274,7 +274,7 @@ if ($is_certificate_mode) {
}
// Show read-only box only in groups
if (!empty($_SESSION['_gid'])) {
if (!empty($groupId)) {
$group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
}
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');

@ -174,12 +174,6 @@ if (!api_is_anonymous()) {
}
}
/* CLEAN GROUP ID FOR AJAXFILEMANAGER */
if (isset($_SESSION['_gid'])) {
unset($_SESSION['_gid']);
}
/* ACTION LINKS */
echo '<div class="actions">';

@ -168,14 +168,7 @@ if ($action_forums != 'add') {
}
}
/* CLEAN GROUP ID FOR AJAXFILEMANAGER */
if (isset($_SESSION['_gid'])) {
unset($_SESSION['_gid']);
}
/* Display Forum Categories and the Forums in it */
$html = '';
$html .= '<div class="category-forum">';

@ -28,7 +28,7 @@ class Accessurledituserstourl
*/
function search_users($needle, $id)
{
global $tbl_user, $tbl_access_url_rel_user;
global $tbl_user;
$xajax_response = new xajaxResponse();
$return = '';

@ -18,8 +18,8 @@ From version 1.10.x, the following Hooks (or more) exist:
|Number| Directory | EventClass | ObserverInterface | Reference |
|------|-----------------------------------|----------------|---------------------------------|---------------------------|
| 1| /main/inc/lib/usermanager.lib.php | HookCreateUser | HookCreateUserObserverInterface | Usermanager::createUser() |
| 2| /main/inc/lib/usermanager.lib.php | HookUpdateUser | HookUpdateUserObserverInterface | Usermanager::updateUser() |
| 1| /main/inc/lib/usermanager.lib.php | HookCreateUser | HookCreateUserObserverInterface | UserManager::createUser() |
| 2| /main/inc/lib/usermanager.lib.php | HookUpdateUser | HookUpdateUserObserverInterface | UserManager::updateUser() |
| 3| /main/admin/index.php | HookAdminBlock | HookAdminBlockObserverInterface | ADMIN BLOCK |
# What do I need to use Hooks?

@ -48,7 +48,7 @@ if($ext!= 'jpg'){
$dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$saveDir=$dirBaseDocuments.$webcamdir;
$current_session_id = api_get_session_id();
$groupId=$_SESSION['_gid'];
$groupId = api_get_group_id();
//avoid duplicates
$webcamname_to_save=$webcamname;

@ -19,7 +19,7 @@ require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
* @param array $htmlHeadXtra A reference to the doc $htmlHeadXtra
*/
function search_widget_prepare(&$htmlHeadXtra) {
$htmlHeadXtra[] = '
$htmlHeadXtra[] = '
<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.autocomplete.js"></script>
<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'search/search_widget.js"></script>
<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.autocomplete.css" />
@ -31,7 +31,7 @@ function search_widget_prepare(&$htmlHeadXtra) {
*/
function format_one_specific_field_select($prefix, $sf_term_array, $op, $extra_select_attr='size="7" class="sf-select-multiple"') {
global $charset;
$multiple_select .= '<select '. $extra_select_attr .' title="'. $prefix .'" id="sf-'. $prefix .'" name="sf_'. $prefix .'[]">';
$multiple_select = '<select '. $extra_select_attr .' title="'. $prefix .'" id="sf-'. $prefix .'" name="sf_'. $prefix .'[]">';
$all_selected = '';
if (!empty($_REQUEST['sf_'. $prefix]) ) {
@ -123,7 +123,7 @@ function search_widget_normal_form($action, $show_thesaurus, $sf_terms, $op) {
$action='index.php';
}
$navigator_info = api_get_navigator();
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$submit_button1 = '<input type="submit" id="submit" value="'. get_lang('Search') .'" />';
$submit_button2 = '<input class="lower-submit" type="submit" value="'. get_lang('Search') .'" />';
@ -142,8 +142,8 @@ function search_widget_normal_form($action, $show_thesaurus, $sf_terms, $op) {
'.$submit_button1.'
<br /><br />';
$list = get_specific_field_list();
if(!empty($list)) {
if(!empty($list)) {
$form .= '<span class="search-links-box">'. $advanced_options .'&nbsp;</span>
<div id="tags" class="tags" style="display:'. $display_thesaurus .';">
<div class="search-help-box">'. $help .'</div>
@ -200,7 +200,7 @@ function search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op,
if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) {
$action='index.php';
}
$form = '
<form id="chamilo_search" action="'. $action .'" method="GET">
<input type="text" id="query" name="query" size="40" />
@ -226,26 +226,26 @@ function search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op,
unset($sf_term_array);
natcasesort($temp);
$sf_term_array = $temp;
// get specific field name
$sf_value = get_specific_field_list(array( 'code' => "'$prefilter_prefix'" ));
$sf_value = array_shift($sf_value);
$form .= '<label class="sf-select-multiple-title" for="sf_'. $prefix .'[]">'.$icons_for_search_terms[$prefix].' '.$sf_value['name'].'</label><br />';
$form .= format_one_specific_field_select($prefilter_prefix, $sf_term_array, $op, 'id="prefilter"');
$form .= format_specific_fields_selects($sf_terms, $op, $prefilter_prefix);
} else {
$form .= format_specific_fields_selects($sf_terms, $op);
}
$or_checked = '';
$and_checked = '';
if ($op == 'or') {
$or_checked = 'checked="checked"';
} else if ($op == 'and') {
$and_checked = 'checked="checked"';
}
}
$form .= '
</tr>
<tr>
@ -263,11 +263,11 @@ function search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op,
</tr>
</table>
</div>';
}
}
$form .= '
</form>
<br style="clear: both;"/>';
return $form;
}
@ -276,7 +276,7 @@ function search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op,
*/
function display_search_form($action, $show_thesaurus, $sf_terms, $op) {
$type = (!empty($_REQUEST['type'])? htmlentities($_REQUEST['type']): 'normal');
switch ($type) {
case 'prefilter':
$prefilter_prefix = api_get_setting('search_prefilter_prefix');
@ -302,17 +302,17 @@ function display_search_form($action, $show_thesaurus, $sf_terms, $op) {
* @param string $action Just in case your action is not
* index.php
*/
function search_widget_show($action='index.php') {
global $charset;
function search_widget_show($action='index.php')
{
require_once api_get_path(LIBRARY_PATH).'search/ChamiloQuery.php';
// TODO: load images dinamically when they're avalaible from specific field ui to add
$icons_for_search_terms = array();
$groupId = api_get_group_id();
$sf_terms = array();
$specific_fields = get_specific_field_list();
$url_params = array();
if ( ($cid=api_get_course_id()) != -1 ) { // with cid
if (($cid = api_get_course_id()) != -1) { // with cid
// get search engine terms
$course_filter = chamilo_get_boolean_query(XAPIAN_PREFIX_COURSEID . $cid);
@ -330,31 +330,25 @@ function search_widget_show($action='index.php') {
$url_params[] = 'sf_'.$specific_field['code'];
unset($temp);
}
} else { // without cid
// prepare specific fields names (and also get possible URL param names)
foreach ($specific_fields as $specific_field) {
//get Xapian terms for a specific term prefix, in ISO, apparently
$sf_terms[$specific_field['code']] = xapian_get_all_terms(1000, $specific_field['code']);
$url_params[] = 'sf_'.$specific_field['code'];
}
}
echo '<h2>'.get_lang('Search').'</h2>';
// Tool introduction
// TODO: Settings for the online editor to be checked (insert an image for example). Probably this is a special case here.
if (api_get_course_id() !== -1)
if (!empty($_SESSION['_gid'])) {
Display::display_introduction_section(TOOL_SEARCH.$_SESSION['_gid']);
if (!empty($groupId)) {
Display::display_introduction_section(TOOL_SEARCH.$groupId);
} else {
Display::display_introduction_section(TOOL_SEARCH);
}
$op = 'or';
if (!empty($_REQUEST['operator']) && in_array($op,array('or','and'))) {
$op = $_REQUEST['operator'];
@ -379,5 +373,4 @@ function search_widget_show($action='index.php') {
// create the form
// TODO: use FormValidator
display_search_form($action, $show_thesaurus, $sf_terms, $op);
}

@ -13,15 +13,22 @@ api_block_anonymous_users();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$course_info = api_get_course_info();
$groupId = api_get_group_id();
$group_properties = GroupManager::get_group_properties(api_get_group_id());
$groupdirpath = $group_properties['directory'];
$group_disk_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document'.$groupdirpath.'/';
$group_web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$groupdirpath.'/';
$group_properties = GroupManager::get_group_properties($groupId);
$groupdirpath = $group_properties['directory'];
$group_disk_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document'.$groupdirpath.'/';
$group_web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$groupdirpath.'/';
//get all group files and folders
$docs_and_folders = DocumentManager::get_all_document_data($course_info, $groupdirpath, api_get_group_id(), null, $is_allowed_to_edit, false);
$docs_and_folders = DocumentManager::get_all_document_data(
$course_info,
$groupdirpath,
api_get_group_id(),
null,
$is_allowed_to_edit,
false
);
//get all group filenames
$array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array();
@ -36,13 +43,13 @@ if (count($array_to_search) > 0) {
$accepted_extensions = array('.svg', '.png');
if (is_array($all_files) && count($all_files) > 0) {
foreach ($all_files as & $file) {
$slideshow_extension = strrchr($file, '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension, $accepted_extensions)) {
$png_svg_files[] =$file;
}
}
foreach ($all_files as & $file) {
$slideshow_extension = strrchr($file, '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension, $accepted_extensions)) {
$png_svg_files[] =$file;
}
}
}
$style = '<style>';
@ -58,7 +65,10 @@ $style .='</style>';
<?php
echo '<h2>'.get_lang('GroupSingle').': '.$group_properties['name'].'</h2>';
if (($group_properties['doc_state'] == 2 && ($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid']))) || $group_properties['doc_state'] == 1){
if ((
$group_properties['doc_state'] == 2 &&
($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $groupId))) || $group_properties['doc_state'] == 1
){
if (!empty($png_svg_files)) {
echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>';
@ -69,13 +79,12 @@ if (($group_properties['doc_state'] == 2 && ($is_allowed_to_edit || GroupManager
if (strpos($filename, "svg")){
$new_sizes['width'] = 60;
$new_sizes['height'] = 60;
}
else {
} else {
$new_sizes = api_resize_image($image, 60, 60);
}
echo '<li style="display:inline; padding:8px;">';
echo '<a href = "'.$group_web_path.$filename.'" alt="'.$filename.'" title="'.$filename.'">';
echo '<img src = "'.$group_web_path.$filename.'" width = "'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>';
echo '<li style="display:inline; padding:8px;">';
echo '<a href = "'.$group_web_path.$filename.'" alt="'.$filename.'" title="'.$filename.'">';
echo '<img src = "'.$group_web_path.$filename.'" width = "'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>';
}
echo '</ul>';
}

@ -2,12 +2,13 @@
/**
* @package chamilo.permissions
*/
/**
/**
* Code
*/
include_once('permissions_functions.inc.php');
include_once('all_permissions.inc.php');
$group_id=$_SESSION['_gid'];
$group_id = api_get_group_id();
echo $group_id;
// ---------------------------------------------------
// ACTIONS

@ -44,10 +44,14 @@ if (isset($_POST['action'])) {
/**
* * Get the number of classes to display on the current page.
*/
function get_number_of_classes() {
function get_number_of_classes()
{
$class_table = Database :: get_main_table(TABLE_MAIN_CLASS);
$course_class_table = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
$sql = "SELECT * FROM $course_class_table WHERE course_code = '" . $_SESSION['_course']['id'] . "'";
$courseCode = api_get_course_id();
$sql = "SELECT * FROM $course_class_table
WHERE course_code = '" . $courseCode. "'";
$res = Database::query($sql);
$subscribed_classes = array();
while ($obj = Database::fetch_object($res)) {
@ -63,6 +67,7 @@ function get_number_of_classes() {
}
$res = Database::query($sql);
$result = Database::num_rows($res);
return $result;
}
@ -73,7 +78,9 @@ function get_class_data($from, $number_of_items, $column, $direction) {
$class_table = Database :: get_main_table(TABLE_MAIN_CLASS);
$course_class_table = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
$class_user_table = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
$sql = "SELECT * FROM $course_class_table WHERE course_code = '" . $_SESSION['_course']['id'] . "'";
$courseCode = api_get_course_id();
$sql = "SELECT * FROM $course_class_table WHERE course_code = '" . $courseCode . "'";
$res = Database::query($sql);
$subscribed_classes = array();
while ($obj = Database::fetch_object($res)) {

@ -282,6 +282,9 @@ function get_number_of_users()
$tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') {
if (api_get_session_id() != 0) {
@ -429,9 +432,15 @@ function get_number_of_users()
// getting all the users of the course (to make sure that we do not display users that are already in the course)
if (!empty($_SESSION["id_session"])) {
$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], $_SESSION['id_session']);
$a_course_users = CourseManager:: get_user_list_from_course_code(
$courseCode,
$sessionId
);
} else {
$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], 0);
$a_course_users = CourseManager:: get_user_list_from_course_code(
$courseCode,
0
);
}
foreach ($a_course_users as $user_id=>$course_user) {
$users_of_course[] = $course_user['user_id'];
@ -445,6 +454,7 @@ function get_number_of_users()
$row = Database::fetch_row($res);
$count_user = $row[0];
}
return $count_user;
}
/**

Loading…
Cancel
Save