Feature #576 - Applying the function api_get_permissions_for_new_directories() on its relevant places. Using the function umask() has been avoided because this function is not thread-safe. Other minot corrections.

skala
Ivan Tcholakov 15 years ago
parent 12cbf9c3fb
commit 14108b1593
  1. 11
      main/admin/configure_homepage.php
  2. 99
      main/admin/configure_inscription.php
  3. 24
      main/admin/settings.php
  4. 2
      main/admin/special_exports.php
  5. 14
      main/admin/sub_language.class.php
  6. 2
      main/admin/sub_language_add.php
  7. 8
      main/app_share/appshare.php
  8. 8
      main/app_share/index.php
  9. 103
      main/auth/profile.php
  10. 23
      main/chat/chat_chat.php
  11. 31
      main/chat/chat_message.php
  12. 32
      main/coursecopy/classes/CourseArchiver.class.php
  13. 15
      main/coursecopy/classes/CourseRestorer.class.php
  14. 4
      main/coursecopy/classes/DummyCourseCreator.class.php
  15. 9
      main/document/create_document.php
  16. 4
      main/document/document.php
  17. 2
      main/document/downloadfolder.inc.php
  18. 18
      main/document/edit_document.php
  19. 2
      main/dropbox/dropbox_functions.inc.php
  20. 2
      main/dropbox/dropbox_submit.php
  21. 4
      main/exercice/admin.php
  22. 2
      main/exercice/exercice.php
  23. 7
      main/exercice/export/exercise_import.inc.php
  24. 5
      main/exercice/hotpotatoes.lib.php
  25. 5
      main/exercice/hotpotatoes.php
  26. 9
      main/exercice/question.class.php
  27. 39
      main/inc/banner.inc.php
  28. 33
      main/inc/lib/add_course.lib.inc.php
  29. 4
      main/inc/lib/fckeditor/editor/filemanager/connectors/php/commands.php
  30. 4
      main/inc/lib/fckeditor/editor/filemanager/connectors/php/io.php
  31. 3
      main/inc/lib/fckeditor/editor/plugins/ImageManager/Classes/Files.php
  32. 87
      main/inc/lib/fileManage.lib.php
  33. 82
      main/inc/lib/fileUpload.lib.php
  34. 366
      main/inc/lib/group_portal_manager.lib.php
  35. 22
      main/inc/lib/groupmanager.lib.php
  36. 9
      main/inc/lib/main_api.lib.php
  37. 544
      main/inc/lib/message.lib.php
  38. 6
      main/inc/lib/mpdf/mpdf.php
  39. 328
      main/inc/lib/usermanager.lib.php
  40. 6
      main/mySpace/user_add.php
  41. 10
      main/newscorm/aicc.class.php
  42. 18
      main/newscorm/learnpath.class.php
  43. 22
      main/newscorm/learnpath_functions.inc.php
  44. 4
      main/newscorm/lp_admin_view.php
  45. 4
      main/newscorm/openoffice_document.class.php
  46. 5
      main/newscorm/scormItem.class.php
  47. 6
      main/newscorm/scorm_admin.php
  48. 3
      main/online/online_master.php
  49. 3
      main/online/online_message.php
  50. 2
      main/work/downloadfolder.inc.php
  51. 11
      main/work/work.lib.php
  52. 107
      tests/main/admin/sub_language.class.test.php
  53. 58
      tests/main/inc/lib/add_course.lib.inc.test.php

@ -117,10 +117,7 @@ if ($_configuration['multiple_access_urls']==true) {
$new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url;
//we create the new dir for the new sites
if (!is_dir($new_url_dir)){
umask(0);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0755');
mkdir($new_url_dir, $perm);
mkdir($new_url_dir, api_get_permissions_for_new_directories());
}
}
} else {
@ -143,15 +140,15 @@ foreach($homef as $my_file) {
if ($_configuration['multiple_access_urls']==true) {
if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
copy($homep.$my_file.$ext,$homep_new.$my_file.'_'.$lang.$ext);
}
} else {
}
} else {
if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
copy($homep.$my_file.$ext,$homep.$my_file.'_'.$lang.$ext);
}
}
}
if ($_configuration['multiple_access_urls']==true) {
$homep = $homep_new;
$homep = $homep_new;
}
// Check WCAG settings and prepare edition using WCAG

@ -22,20 +22,20 @@ require_once(api_get_path(INCLUDE_PATH).'lib/legal.lib.php');
//require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
// Load terms & conditions from the current lang
if (get_setting('allow_terms_conditions')=='true') {
if (get_setting('allow_terms_conditions')=='true') {
$get = array_keys($_GET);
if (isset($get)) {
if ($get[0]=='legal'){
if ($get[0]=='legal'){
//$language = api_get_setting('platformLanguage');
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview= LegalManager::get_last_condition($language);
if ($term_preview==false) {
//look for the default language
$language = api_get_setting('platformLanguage');
$language = api_get_setting('platformLanguage');
$language = api_get_language_id($language);
$term_preview= LegalManager::get_last_condition($language);
}
}
$tool_name = get_lang('TermsAndConditions');
Display :: display_header('');
echo '<div class="actions-title">';
@ -43,7 +43,7 @@ if (get_setting('allow_terms_conditions')=='true') {
echo '</div>';
if (!empty($term_preview['content']))
echo $term_preview['content'];
else
else
echo get_lang('ComingSoon');
Display :: display_footer();
exit;
@ -74,28 +74,25 @@ if(!empty($_SESSION['user_language_choice'])) {
// ----- Ensuring availability of main files in the corresponding language -----
if ($_configuration['multiple_access_urls']==true) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$url_info = api_get_access_url($access_url_id);
// "http://" and the final "/" replaced
$url = substr($url_info['url'],7,strlen($url_info['url'])-8);
// "http://" and the final "/" replaced
$url = substr($url_info['url'],7,strlen($url_info['url'])-8);
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/','-',$clean_url);
$clean_url = $clean_url.'/';
$homep = '../../home/'; //homep for Home Path
$homep_new = '../../home/'.$clean_url; //homep for Home Path added the url
$homep = '../../home/'; //homep for Home Path
$homep_new = '../../home/'.$clean_url; //homep for Home Path added the url
$new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url;
//we create the new dir for the new sites
if (!is_dir($new_url_dir)){
umask(0);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0755');
mkdir($new_url_dir, $perm);
}
if (!is_dir($new_url_dir)){
mkdir($new_url_dir, api_get_permissions_for_new_directories());
}
}
} else {
$homep_new ='';
} else {
$homep_new ='';
$homep = '../../home/'; //homep for Home Path
}
@ -110,8 +107,8 @@ foreach($homef as $my_file) {
if ($_configuration['multiple_access_urls']==true) {
if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
copy($homep.$my_file.$ext,$homep_new.$my_file.'_'.$lang.$ext);
}
} else {
}
} else {
if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
copy($homep.$my_file.$ext,$homep.$my_file.'_'.$lang.$ext);
}
@ -131,7 +128,7 @@ if(!empty($action)) {
}
// Write
if (file_exists($homep.$topf.'_'.$lang.$ext)) {
if(is_writable($homep.$topf.'_'.$lang.$ext)) {
if(is_writable($homep.$topf.'_'.$lang.$ext)) {
$fp=fopen($homep.$topf.'_'.$lang.$ext,"w");
fputs($fp,$home_top);
fclose($fp);
@ -139,7 +136,7 @@ if(!empty($action)) {
$errorMsg=get_lang('HomePageFilesNotWritable');
}
} else {
//File does not exist
//File does not exist
$fp=fopen($homep.$topf.'_'.$lang.$ext,"w");
fputs($fp,$home_top);
fclose($fp);
@ -161,7 +158,7 @@ if(!empty($action)) {
$home_top=file_get_contents($homep.$topf.$lang.$ext);
} else {
$errorMsg=get_lang('HomePageFilesNotReadable');
}
}
break;
}
}
@ -183,7 +180,7 @@ if (get_setting('allow_registration')=='approval') {
}
//if openid was not found
if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
Display::display_warning_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
Display::display_warning_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
}
$form = new FormValidator('registration');
@ -197,7 +194,7 @@ if (get_setting('allow_terms_conditions')=='true') {
$display_all_form=true;
}
if ($display_all_form===true) {
// LAST NAME and FIRST NAME
$form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled'));
$form->applyFilter('lastname','trim');
@ -211,7 +208,7 @@ if (api_get_setting('registration', 'email') == 'true')
$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('email', get_lang('EmailWrong'), 'email');
if (api_get_setting('openid_authentication')=='true') {
$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40, 'disabled' => 'disabled'));
$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40, 'disabled' => 'disabled'));
}
// USERNAME
@ -308,15 +305,15 @@ foreach ($extra as $id => $field_details) {
$group[] =& HTML_QuickForm::createElement('radio', 'extra_'.$field_details[1], $option_details[1],$option_details[2].'<br />',$option_details[1]);
}
$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]);
if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]);
break;
case USER_FIELD_TYPE_SELECT:
$options = array();
foreach($field_details[9] as $option_id => $option_details) {
$options[$option_details[1]] = $option_details[2];
}
$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,'');
if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]);
$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,'');
if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]);
break;
case USER_FIELD_TYPE_SELECT_MULTIPLE:
$options = array();
@ -324,7 +321,7 @@ foreach ($extra as $id => $field_details) {
$options[$option_details[1]] = $option_details[2];
}
$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,array('multiple' => 'multiple'));
if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]);
if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]);
break;
case USER_FIELD_TYPE_DATE:
$form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration'));
@ -350,7 +347,7 @@ foreach ($extra as $id => $field_details) {
$values[0][$element[0]] = $element[2];
}
}
$group='';
$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1],'',$values[0],'');
$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1].'*','',$values['*'],'');
@ -362,7 +359,7 @@ foreach ($extra as $id => $field_details) {
// exploding all the selected values (of both select forms)
$selected_values = explode(';',$extra_data['extra_'.$field_details[1]]);
$extra_data['extra_'.$field_details[1]] =array();
// looping through the selected values and assigning the selected values to either the first or second select form
foreach ($selected_values as $key=>$selected_value) {
if (key_exists($selected_value,$values[0])) {
@ -381,13 +378,13 @@ foreach ($extra as $id => $field_details) {
}
//------------ Terms and conditions
if (get_setting('allow_terms_conditions')=='true') {
if (get_setting('allow_terms_conditions')=='true') {
//$language = api_get_setting('platformLanguage');
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview= LegalManager::get_last_condition($language);
if ($term_preview==false) {
$term_preview= LegalManager::get_last_condition($language);
if ($term_preview==false) {
//we load from the platform
$language = api_get_setting('platformLanguage');
$language = api_get_language_id($language);
@ -395,31 +392,31 @@ if (get_setting('allow_terms_conditions')=='true') {
//if is false we load from english
if ($term_preview==false){
$language = api_get_language_id('english'); //this must work
$term_preview= LegalManager::get_last_condition($language);
}
}
$term_preview= LegalManager::get_last_condition($language);
}
}
// Version and language //password
$form->addElement('hidden', 'legal_accept_type',$term_preview['version'].':'.$term_preview['language_id']);
$form->addElement('hidden', 'legal_info',$term_preview['legal_id'].':'.$term_preview['language_id']);
$form->addElement('hidden', 'legal_info',$term_preview['legal_id'].':'.$term_preview['language_id']);
if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) {
$form->addElement('hidden', 'login',$_SESSION['info_current_user'][1]);
$form->addElement('hidden', 'password',$_SESSION['info_current_user'][2]);
$form->addElement('hidden', 'password',$_SESSION['info_current_user'][2]);
}
if($term_preview['type'] == 1) {
$form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').'&nbsp;<a href="inscription.php?legal" target="_blank">'.get_lang('TermsAndConditions').'</a>');
$form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').'&nbsp;<a href="inscription.php?legal" target="_blank">'.get_lang('TermsAndConditions').'</a>');
$form->addRule('extra_legal_accept', get_lang('ThisFieldIsRequired'), 'required');
} else {
if (!empty($term_preview['content'])) {
if (!empty($term_preview['content'])) {
$preview = LegalManager::show_last_condition($term_preview);
$term_preview = '<div class="row">
<div class="label">'.get_lang('TermsAndConditions').'</div>
<div class="formw">
'.$preview.'
<br />
<br />
</div>
</div>';
</div>';
$form->addElement('html', $term_preview);
}
}
}
}
@ -448,7 +445,7 @@ if(!empty($_GET['phone']))
if (api_get_setting('openid_authentication')=='true' && !empty($_GET['openid']))
{
$defaults['openid'] = Security::remove_XSS($_GET['openid']);
$defaults['openid'] = Security::remove_XSS($_GET['openid']);
}
switch($action){
@ -493,7 +490,7 @@ switch($action){
/*******************************/
//Form of language
api_display_language_form();
echo '&nbsp;&nbsp;<a href="'.api_get_self().'?action=edit_top">'.Display::display_icon('edit.gif', get_lang('Edit')).'</a> <a href="'.api_get_self().'?action=edit_top">'.get_lang('EditNotice').'</a>';
echo '<div class="note">';
$home_notice = '';
@ -503,7 +500,7 @@ switch($action){
$home_notice = @file_get_contents($homep.$topf.$ext);
}
echo $home_notice;
echo '</div>';
echo '</div>';
/*******************************/
$form->display();
break;

@ -742,14 +742,9 @@ function upload_stylesheet($values,$picture)
$style_name = api_ereg_replace("[^A-Za-z0-9]", "", $values['name_stylesheet'] );
// create the folder if needed
if(!is_dir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'))
if (!is_dir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'))
{
if(mkdir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'))
{
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/', $perm);
}
mkdir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/', api_get_permissions_for_new_directories());
}
// move the file in the folder
@ -906,7 +901,7 @@ function handle_search() {
// Save the settings
foreach ($formvalues as $key => $value)
{
$result = api_set_setting($key,$value,null,null);
$result = api_set_setting($key, $value, null, null);
}
Display :: display_confirmation_message($SettingsStored);
@ -1022,7 +1017,7 @@ function get_template_data($from, $number_of_items, $column, $direction)
$result = Database::query($sql, __FILE__, __LINE__);
while ($row = Database::fetch_array($result)) {
$row['1'] = get_lang($row['1']);
$return[]=$row;
$return[] = $row;
}
// returning all the information for the sortable table
return $return;
@ -1160,11 +1155,9 @@ function add_edit_template()
$upload_dir = api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/';
// create dir if not exists
if (!is_dir($upload_dir)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
$res = @mkdir($upload_dir,$perm);
}
if (!is_dir($upload_dir)) {
mkdir($upload_dir, api_get_permissions_for_new_directories());
}
// resize image to max default and upload
require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
@ -1226,9 +1219,6 @@ function add_edit_template()
}
Security::clear_token();
display_templates();
}
else
{

@ -135,7 +135,7 @@ function create_zip(){
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$temp_zip_dir = $sys_archive_path."temp";
if(!is_dir($temp_zip_dir)) {
mkdir($temp_zip_dir);
mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
} else {
$handle=opendir($temp_zip_dir);
while (false!==($file = readdir($handle))) {

@ -119,12 +119,8 @@ class SubLanguageManager {
* @return boolean
*/
public static function add_directory_of_sub_language($path_sub_language) {
$rs=@mkdir($path_sub_language,0777);
if ($rs) {
return true;
} else {
return false;
}
//return @mkdir($path_sub_language, 0777) !== false;
return @mkdir($path_sub_language, api_get_permissions_for_new_directories()) !== false;
}
/**
* Delete sub-language
@ -132,9 +128,9 @@ class SubLanguageManager {
* @return void()
*/
public static function removed_sub_language ($parent_id,$sub_language_id) {
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql='DELETE FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($parent_id).'" AND id="'.Database::escape_string($sub_language_id).'" ';
$rs=Database::query($sql,__FILE__,__LINE__);
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'DELETE FROM '.$tbl_admin_languages.' WHERE parent_id="'.Database::escape_string($parent_id).'" AND id="'.Database::escape_string($sub_language_id).'" ';
Database::query($sql, __FILE__, __LINE__);
}
/**
* check if language exist by id

@ -225,7 +225,7 @@ if (isset($_POST['SubmitAddNewLanguage'])) {
$path=api_get_path('SYS_LANG_PATH').$english_name;
$mkdir_result=add_directory_of_sub_language($path);
if ($mkdir_result===true) {
if ($mkdir_result) {
add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id);
Display::display_confirmation_message(get_lang('TheNewSubLanguageHasBeenAdd').$str_info,false);
} else {

@ -15,7 +15,8 @@ $nameTools = get_lang("ModifInfo");
$course_code = $_course["sysCode"];
$app_share_tmp_dir_base = api_get_path(SYS_ARCHIVE_PATH).'app_share/';
mkdir ($app_share_tmp_dir_base, 0700);
//mkdir ($app_share_tmp_dir_base, 0700);
mkdir ($app_share_tmp_dir_base, api_get_permissions_for_new_directories());
$app_share_tmp_dir = $app_share_tmp_dir_base.$course_code;
$app_base_file = api_get_path(SYS_CODE_PATH).'app_share/DokeosAppShare.exe';
$app_share_app_file = $app_share_tmp_dir.'/DokeosAppShare.exe';
@ -23,10 +24,11 @@ $app_share_app_file = $app_share_tmp_dir.'/DokeosAppShare.exe';
$specialCode='';
if (file_exists($app_share_app_file) == FALSE) {
mkdir ($app_share_tmp_dir, 0700);
//mkdir ($app_share_tmp_dir, 0700);
mkdir ($app_share_tmp_dir, api_get_permissions_for_new_directories());
if (file_exists($app_base_file) == FALSE) {
echo('FATAL ERROR: file <b>'.$app_base_file.'</b> not found.<br />');
echo('FATAL ERROR: file <strong>'.$app_base_file.'</strong> not found.<br />');
} else {
$source = fopen($app_base_file, "r");
$target = fopen($app_share_app_file, "a" );

@ -15,7 +15,8 @@ $nameTools = get_lang("ModifInfo");
$course_code = $_course["sysCode"];
$app_share_tmp_dir_base = api_get_path(SYS_ARCHIVE_PATH).'app_share/';
mkdir ($app_share_tmp_dir_base, 0700);
//mkdir ($app_share_tmp_dir_base, 0700);
mkdir ($app_share_tmp_dir_base, api_get_permissions_for_new_directories());
$app_share_tmp_dir = $app_share_tmp_dir_base.$course_code;
$app_base_file = api_get_path(SYS_CODE_PATH).'app_share/DokeosAppShare.exe';
$app_share_app_file = $app_share_tmp_dir.'/DokeosAppShare.exe';
@ -23,10 +24,11 @@ $app_share_app_file = $app_share_tmp_dir.'/DokeosAppShare.exe';
$specialCode='';
if (file_exists($app_share_app_file) == FALSE) {
mkdir ($app_share_tmp_dir, 0700);
//mkdir ($app_share_tmp_dir, 0700);
mkdir ($app_share_tmp_dir, api_get_permissions_for_new_directories());
if (file_exists($app_base_file) == FALSE) {
echo('FATAL ERROR: file <b>'.$app_base_file.'</b> not found.<br />');
echo('FATAL ERROR: file <strong>'.$app_base_file.'</strong> not found.<br />');
} else {
$source = fopen($app_base_file, "r");
$target = fopen($app_share_app_file, "a" );

@ -392,25 +392,25 @@ foreach ($extra as $id => $field_details) {
$form->addElement('static', $field_details[1], '<br /><strong>'.$field_details[3].'</strong>');
break;
case USER_FIELD_TYPE_TAG:
//the magic should be here
//the magic should be here
$user_tags = UserManager::get_user_tags(api_get_user_id(),$field_details[0]);
$pre_html = '<div class="row">
<div class="label">'.$field_details[3].'</div>
<div class="formw">';
$post = '</div></div>';
$tag_list = '';
if (is_array($user_tags) && count($user_tags)> 0) {
foreach ($user_tags as $tag) {
$tag_list .= '<option value="'.$tag['tag'].'" class="selected">'.$tag['tag'].'</option>';
}
}
}
$multi_select = '<select id="extra_'.$field_details[1].'" name="extra_'.$field_details[1].'">
'.$tag_list.'
</select>';
$form->addElement('html',$pre_html.$multi_select.$post );
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php';
$complete_text = get_lang('StartToType');
@ -426,8 +426,8 @@ foreach ($extra as $id => $field_details) {
//onremove: "testme",
//onselect: "testme",
filter_selected: true,
newel: true
});
newel: true
});
EOF;
break;
}
@ -496,10 +496,7 @@ function upload_user_production($user_id) {
$production_repository = $image_path['dir'].$user_id.'/';
if (!file_exists($production_repository)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770');
@mkdir($production_repository, $perm, true);
@mkdir($production_repository, api_get_permissions_for_new_directories(), true);
}
$filename = replace_dangerous_char($_FILES['production']['name']);
@ -564,19 +561,19 @@ if (!empty($_SESSION['change_email'])) {
elseif (!empty($_SESSION['is_not_password'])) {
$msg_is_not_password = ($_SESSION['is_not_password'] == 'success');
unset($_SESSION['is_not_password']);
}
}
elseif (!empty($_SESSION['profile_update'])) {
$update_success = ($_SESSION['profile_update'] == 'success');
unset($_SESSION['profile_update']);
}
}
elseif (!empty($_SESSION['image_uploaded'])) {
$upload_picture_success = ($_SESSION['image_uploaded'] == 'success');
unset($_SESSION['image_uploaded']);
}
}
elseif (!empty($_SESSION['production_uploaded'])) {
$upload_production_success = ($_SESSION['production_uploaded'] == 'success');
unset($_SESSION['production_uploaded']);
}
}
elseif (isset($_POST['remove_production'])) {
foreach (array_keys($_POST['remove_production']) as $production) {
UserManager::remove_user_production($_user['user_id'], urldecode($production));
@ -589,7 +586,7 @@ elseif (isset($_POST['remove_production'])) {
} elseif ($form->validate()) {
$wrong_current_password = false;
// $user_data = $form->exportValues();
// $user_data = $form->exportValues();
$user_data = $form->getSubmitValues();
// set password if a new one was provided
if (!empty($user_data['password0'])) {
@ -606,15 +603,15 @@ elseif (isset($_POST['remove_production'])) {
$wrong_current_password = true;
$_SESSION['is_not_password'] = 'success';
}
if (!check_user_email($user_data['email']) && !empty($user_data['password0']) && ($wrong_current_password==false)) {
$changeemail = $user_data['email'];
}
}
if (!check_user_email($user_data['email']) && empty($user_data['password0'])){
$_SESSION['change_email'] = 'success';
}
// upload picture if a new one is provided
if ($_FILES['picture']['size']) {
if ($new_picture = UserManager::update_user_picture($_user['user_id'], $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) {
@ -654,23 +651,23 @@ elseif (isset($_POST['remove_production'])) {
// build SQL query
$sql = "UPDATE $table_user SET";
unset($user_data['api_key_generate']);
foreach ($user_data as $key => $value) {
if (substr($key, 0, 6) == 'extra_') { //an extra field
$new_key = substr($key, 6);
foreach ($user_data as $key => $value) {
if (substr($key, 0, 6) == 'extra_') { //an extra field
$new_key = substr($key, 6);
// format array date to 'Y-m-d' or date time to 'Y-m-d H:i:s'
if (is_array($value) && isset($value['Y']) && isset($value['F']) && isset($value['d'])) {
if (is_array($value) && isset($value['Y']) && isset($value['F']) && isset($value['d'])) {
if (isset($value['H']) && isset($value['i'])) {
// extra field date time
$time = mktime($value['H'],$value['i'],0,$value['F'],$value['d'],$value['Y']);
$extras[$new_key] = date('Y-m-d H:i:s',$time);
$extras[$new_key] = date('Y-m-d H:i:s',$time);
} else {
// extra field date
$time = mktime(0,0,0,$value['F'],$value['d'],$value['Y']);
$extras[$new_key] = date('Y-m-d',$time);
}
}
} else {
$extras[$new_key] = $value;
}
}
} else {
$sql .= " $key = '".Database::escape_string($value)."',";
}
@ -680,7 +677,7 @@ elseif (isset($_POST['remove_production'])) {
if (isset($changeemail) && !isset($password) ) {
$sql .= " email = '".Database::escape_string($changeemail)."' ";
} elseif (isset($password) && isset($changeemail)) {
$sql .= " email = '".Database::escape_string($changeemail)."', ";
$sql .= " email = '".Database::escape_string($changeemail)."', ";
$password = api_get_encrypted_password($password);
$sql .= " password = '".Database::escape_string($password)."'";
} elseif (isset($password) && !isset($changeemail)) {
@ -693,19 +690,19 @@ elseif (isset($_POST['remove_production'])) {
$sql .= " WHERE user_id = '".$_user['user_id']."'";
//var_dump($sql); exit();
Database::query($sql, __FILE__, __LINE__);
// User tag process
//1. Deleting all user tags
//1. Deleting all user tags
$list_extra_field_type_tag = UserManager::get_all_extra_field_by_type(USER_FIELD_TYPE_TAG);
if (is_array($list_extra_field_type_tag) && count($list_extra_field_type_tag)>0) {
foreach ($list_extra_field_type_tag as $id) {
UserManager::delete_user_tags(api_get_user_id(), $id);
}
}
//2. Update the extra fields and user tags if available
//2. Update the extra fields and user tags if available
if (is_array($extras) && count($extras)> 0) {
foreach ($extras as $key => $value) {
foreach ($extras as $key => $value) {
//3. Tags are process in the UserManager::update_extra_field_value by the UserManager::process_tags function
$myres = UserManager::update_extra_field_value($_user['user_id'], $key, $value);
}
@ -741,24 +738,24 @@ if (isset($_GET['show'])) {
Display::display_header(get_lang('ModifyProfile'));
if (api_get_setting('allow_social_tool') != 'true') {
if (api_get_setting('extended_profile') == 'true') {
echo '<div class="actions">';
if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
}
if (api_get_setting('allow_message_tool') == 'true') {
echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
}
}
$show = isset($_GET['show']) ? '&amp;show='.Security::remove_XSS($_GET['show']) : '';
if (isset($_GET['type']) && $_GET['type'] == 'extended') {
echo '<a href="profile.php?type=reduced'.$show.'">'.Display::return_icon('edit.gif', get_lang('EditNormalProfile')).'&nbsp;'.get_lang('EditNormalProfile').'</a>';
} else {
echo '<a href="profile.php?type=extended'.$show.'">'.Display::return_icon('edit.gif', get_lang('EditExtendProfile')).'&nbsp;'.get_lang('EditExtendProfile').'</a>';
}
echo '</div>';
}
}
@ -774,8 +771,8 @@ if (!empty($file_deleted)) {
if ($upload_production_success) {
$message.='<br />'.get_lang('ProductionUploaded');
}
}
Display :: display_confirmation_message($message, false);
}
@ -820,32 +817,32 @@ $url_big_image = $big_image.'?rnd='.time();
if (api_get_setting('allow_social_tool') == 'true') {
echo '<div id="social-content">';
echo '<div id="social-content-left">';
SocialManager::show_social_menu('home', null, $user_id, $show_full_profile);
echo '</div>';
echo '<div id="social-content-right">';
echo '<div id="social-content-right">';
echo '<div id="social-content-online">';
if (api_get_setting('extended_profile') == 'true') {
$show = isset($_GET['show']) ? '&amp;show='.Security::remove_XSS($_GET['show']) : '';
if (api_get_setting('extended_profile') == 'true') {
$show = isset($_GET['show']) ? '&amp;show='.Security::remove_XSS($_GET['show']) : '';
if (isset($_GET['type']) && $_GET['type'] == 'extended') {
echo '<a href="profile.php?type=reduced'.$show.'"><span class="social-menu-text1">'.Display::return_icon('edit.gif', get_lang('EditNormalProfile')).'&nbsp;'.get_lang('EditNormalProfile').'</span></a>';
} else {
echo '<a href="profile.php?type=extended'.$show.'"><span class="social-menu-text1">'.Display::return_icon('edit.gif', get_lang('EditExtendProfile')).'&nbsp;'.get_lang('EditExtendProfile').'</span></a>';
}
}
echo '</div>';
}
}
echo '</div>';
$form->display();
echo '</div>';
echo '</div>';
} else {
// Style position:absolute has been removed for Opera-compatibility.
// Style position:absolute has been removed for Opera-compatibility.
//echo '<div id="image-message-container" style="float:right;display:inline;position:absolute;padding:3px;width:250px;" >';
echo '<div id="image-message-container" style="float:right;display:inline;padding:3px;width:230px;" >';
if ($image == 'unknown.jpg') {
echo '<img '.$img_attributes.' />';
} else {

@ -57,14 +57,14 @@ if (!empty($course))
$isMaster=$is_courseAdmin?true:false;
$dateNow=date('Y-m-d');
$basepath_chat = '';
$dateNow=date('Y-m-d');
$basepath_chat = '';
$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!empty($group_id)) {
$group_info = GroupManager :: get_group_properties($group_id);
$basepath_chat = $group_info['directory'].'/chat_files';
$basepath_chat = $group_info['directory'].'/chat_files';
} else {
$basepath_chat = '/chat_files';
$basepath_chat = '/chat_files';
}
$chatPath=$documentPath.$basepath_chat.'/';
@ -78,16 +78,13 @@ if (!empty($course))
}
if (!api_is_anonymous()) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
@mkdir($chatPath,$perm);
@chmod($chatPath,$perm);
// save chat files document for group into item property
@mkdir($chatPath, api_get_permissions_for_new_directories());
// save chat files document for group into item property
if (!empty($group_id)) {
$doc_id=add_document($_course,$basepath_chat,'folder',0,'chat_files');
$sql = "INSERT INTO $TABLEITEMPROPERTY (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ('document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql,__FILE__,__LINE__);
}
}
}
@ -98,7 +95,7 @@ if (!empty($course))
} else if (!empty($session_id)) {
$filename_chat = 'messages-'.$dateNow.'_sid-'.$session_id.'.log.html';
} else {
$filename_chat = 'messages-'.$dateNow.'.log.html';
$filename_chat = 'messages-'.$dateNow.'.log.html';
}
if(!file_exists($chatPath.$filename_chat))
@ -106,7 +103,7 @@ if (!empty($course))
@fclose(fopen($chatPath.$filename_chat,'w'));
if (!api_is_anonymous()) {
$doc_id=add_document($_course,$basepath_chat.'/'.$filename_chat,'file',0,$filename_chat);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'],$group_id,null,null,null,$session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'],$group_id,null,null,null,$session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'],$group_id,null,null,null,$session_id);
item_property_update_on_folder($_course,$basepath_chat, $_user['user_id']);
}
@ -118,7 +115,7 @@ if (!empty($course))
} else if (!empty($session_id)) {
$basename_chat = 'messages-'.$dateNow.'_sid-'.$session_id;
} else {
$basename_chat = 'messages-'.$dateNow;
$basename_chat = 'messages-'.$dateNow;
}
if($reset && $isMaster)

@ -47,7 +47,7 @@ $session_id = intval($_SESSION['id_session']);
$group_id = intval($_SESSION['_gid']);
/////
// Juan Carlos Raña insert smileys and self-closing window
// Juan Carlos Ra<EFBFBD>a insert smileys and self-closing window
////
?>
<script language="javascript" type="text/javascript">
@ -121,17 +121,17 @@ if (!empty($course) && !empty($_user['user_id']))
$lastname=Database::result($result,0,'lastname');
$dateNow=date('Y-m-d');
$basepath_chat = '';
$basepath_chat = '';
$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!empty($group_id)) {
$group_info = GroupManager :: get_group_properties($group_id);
$basepath_chat = $group_info['directory'].'/chat_files';
$basepath_chat = $group_info['directory'].'/chat_files';
} else {
$basepath_chat = '/chat_files';
$basepath_chat = '/chat_files';
}
$chatPath=$documentPath.$basepath_chat.'/';
$TABLEITEMPROPERTY= Database::get_course_table(TABLE_ITEM_PROPERTY);
if(!is_dir($chatPath)) {
@ -139,17 +139,14 @@ if (!empty($course) && !empty($_user['user_id']))
@unlink($chatPath);
}
if (!api_is_anonymous()) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
@mkdir($chatPath,$perm);
@chmod($chatPath,$perm);
// save chat files document for group into item property
@mkdir($chatPath, api_get_permissions_for_new_directories());
// save chat files document for group into item property
if (!empty($group_id)) {
$doc_id=add_document($_course,$basepath_chat,'folder',0,'chat_files');
$doc_id = add_document($_course,$basepath_chat,'folder',0,'chat_files');
$sql = "INSERT INTO $TABLEITEMPROPERTY (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ('document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)";
Database::query($sql,__FILE__,__LINE__);
}
Database::query($sql,__FILE__,__LINE__);
}
}
}
@ -237,16 +234,16 @@ if (!empty($course) && !empty($_user['user_id']))
$message=str_replace($emoticon_text204, $emoticon_img204, $message);
$timeNow=date('d/m/y H:i:s');
$basename_chat = '';
if (!empty($group_id)) {
$basename_chat = 'messages-'.$dateNow.'_gid-'.$group_id;
} else if (!empty($session_id)) {
$basename_chat = 'messages-'.$dateNow.'_sid-'.$session_id;
} else {
$basename_chat = 'messages-'.$dateNow;
$basename_chat = 'messages-'.$dateNow;
}
if (!api_is_anonymous()) {
if(!empty($message))
{

@ -61,6 +61,8 @@ class CourseArchiver
*/
function write_course($course)
{
$perm_dirs = api_get_permissions_for_new_directories();
CourseArchiver::clean_backup_dir();
// Create a temp directory
$tmp_dir_name = 'CourseArchiver_'.uniqid('');
@ -71,52 +73,52 @@ class CourseArchiver
$user = api_get_user_info();
$zip_file = $user['user_id'].'_'.$course->code.'_'.date("YmdHis").'.zip';
$php_errormsg = '';
$res = @mkdir($backup_dir, 0755);
if($res == false)
$res = @mkdir($backup_dir, $perm_dirs);
if ($res === false)
{
//TODO set and handle an error message telling the user to review the permissions on the archive directory
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created',0);
}
// Write the course-object to the file
$fp = @fopen($course_info_file, 'w');
if($fp == false)
if ($fp === false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
$res = @fwrite($fp, base64_encode(serialize($course)));
if($res == false)
if ($res === false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
$res = @fclose($fp);
if($res == false)
if ($res === false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
// Copy all documents to the temp-dir
if( is_array($course->resources[RESOURCE_DOCUMENT])) {
if (is_array($course->resources[RESOURCE_DOCUMENT])) {
foreach ($course->resources[RESOURCE_DOCUMENT] as $id => $document) {
if ($document->file_type == DOCUMENT) {
$doc_dir = $backup_dir.$document->path;
@mkdir(dirname($doc_dir), 0755, true);
@mkdir(dirname($doc_dir), $perm_dirs, true);
if (file_exists($course->path.$document->path)) {
copy($course->path.$document->path, $doc_dir);
}
} else {
@mkdir($backup_dir.$document->path, 0755, true);
@mkdir($backup_dir.$document->path, $perm_dirs, true);
}
}
}
// Copy all scorm documents to the temp-dir
if( is_array($course->resources[RESOURCE_SCORM]))
if (is_array($course->resources[RESOURCE_SCORM]))
{
foreach ($course->resources[RESOURCE_SCORM] as $id => $document)
{
$doc_dir=dirname($backup_dir.$document->path);
$doc_dir = dirname($backup_dir.$document->path);
@mkdir($doc_dir, 0755, true);
@mkdir($doc_dir, $perm_dirs, true);
copyDirTo($course->path.$document->path, $doc_dir, false);
}
@ -185,7 +187,7 @@ class CourseArchiver
// Create a temp directory
$tmp_dir_name = 'CourseArchiver_'.uniqid('');
$unzip_dir = api_get_path(SYS_ARCHIVE_PATH).''.$tmp_dir_name;
@mkdir($unzip_dir, 0755, true);
@mkdir($unzip_dir, api_get_permissions_for_new_directories(), true);
@copy(api_get_path(SYS_ARCHIVE_PATH).''.$filename,$unzip_dir.'/backup.zip');
// unzip the archive
$zip = new PclZip($unzip_dir.'/backup.zip');

@ -206,6 +206,8 @@ class CourseRestorer
*/
function restore_documents($session_id = 0,$destination_course_code = '')
{
$perm = api_get_permissions_for_new_directories();
if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
$table = Database :: get_course_table(TABLE_DOCUMENT, $this->course->destination_db);
$resources = $this->course->resources;
@ -213,8 +215,7 @@ class CourseRestorer
/* echo '<pre>'; echo $this->course->backup_path; echo '<br>'; */
foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:0770);
$dirs = explode('/', dirname($document->path));
//if (count($dirs)==1) {
@ -430,6 +431,8 @@ class CourseRestorer
*/
function restore_scorm_documents()
{
$perm = api_get_permissions_for_new_directories();
if ($this->course->has_resources(RESOURCE_SCORM))
{
$resources = $this->course->resources;
@ -438,8 +441,6 @@ class CourseRestorer
{
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
@mkdir(dirname($path.$document->path), $perm, true);
if (file_exists($path.$document->path))
@ -1429,10 +1430,10 @@ class CourseRestorer
* @param boolean Option Overwrite
* @return void()
*/
function allow_create_all_directory($source, $dest, $overwrite = false){
function allow_create_all_directory($source, $dest, $overwrite = false) {
if(!is_dir($dest)) {
mkdir($dest);
}
mkdir($dest, api_get_permissions_for_new_directories());
}
if ($handle = opendir($source)) { // if the folder exploration is sucsessful, continue
while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue

@ -65,7 +65,7 @@ class DummyCourseCreator
$course = Database::get_course_info($course_code);
$this->course = new Course();
$tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid('');
@mkdir($tmp_path, 0755, true);
@mkdir($tmp_path, api_get_permissions_for_new_directories(), true);
$this->course->backup_path = $tmp_path;
$this->create_dummy_links();
$this->create_dummy_events();
@ -108,7 +108,7 @@ class DummyCourseCreator
$dir_to_make = $course_doc_path.$path;
if (!is_dir($dir_to_make))
{
@mkdir($dir_to_make, 0755, true);
@mkdir($dir_to_make, api_get_permissions_for_new_directories(), true);
}
$file = $course_doc_path.$path.$filename;
$fp = fopen($file, 'w');

@ -182,8 +182,8 @@ function InnerDialogLoaded()
{
document.getElementById(\'title_edited\').value = "true";
}
}
}
function setFocus(){
$("#document_title").focus();
}
@ -470,11 +470,8 @@ if ($form->validate()) {
$files_perm = api_get_setting('permissions_for_new_files');
$files_perm = octdec(!empty($files_perm)?$files_perm:'0770');
chmod($filepath.$filename.'.'.$extension,$files_perm);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
if (!is_dir($filepath.'css')) {
mkdir($filepath.'css');
chmod($filepath.'css', $perm);
mkdir($filepath.'css', api_get_permissions_for_new_directories());
$doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css');
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'],null,null,null,null,$current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'],null,null,null,null,$current_session_id);

@ -641,9 +641,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
// create the template_thumbnails folder in the upload folder (if needed)
if (!is_dir(api_get_path(SYS_CODE_PATH).'upload/template_thumbnails/')) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
$res = @mkdir(api_get_path(SYS_CODE_PATH).'upload/template_thumbnails/',$perm);
@mkdir(api_get_path(SYS_CODE_PATH).'upload/template_thumbnails/', api_get_permissions_for_new_directories());
}
// upload the file

@ -35,7 +35,7 @@ $temp_zip_dir = $sys_course_path.$_course['path']."/temp";
if(!is_dir($temp_zip_dir))
{
mkdir($temp_zip_dir);
mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
}
//cleanup: check the temp dir for old files and delete them
else

@ -469,19 +469,17 @@ if($is_allowedToEdit)
fputs($fp,$texte);
fclose($fp);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
if(!is_dir($filepath.'css'))
if (!is_dir($filepath.'css'))
{
mkdir($filepath.'css',$perm);
$doc_id=add_document($_course,$dir.'css','folder',0,'css');
mkdir($filepath.'css', api_get_permissions_for_new_directories());
$doc_id = add_document($_course,$dir.'css','folder',0,'css');
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'],null,null,null,null,$current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'],null,null,null,null,$current_session_id);
}
if(!is_file($filepath.'css/frames.css'))
if (!is_file($filepath.'css/frames.css'))
{
$platform_theme= api_get_setting('stylesheets');
$platform_theme = api_get_setting('stylesheets');
if (file_exists(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css')) {
copy(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css',$filepath.'css/frames.css');
$doc_id=add_document($_course,$dir.'css/frames.css','file',filesize($filepath.'css/frames.css'),'frames.css');
@ -492,20 +490,20 @@ if($is_allowedToEdit)
// "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
$document_id = DocumentManager::get_document_id($_course,$file);
if($document_id)
if ($document_id)
{
$file_size = filesize($filepath.$filename.'.'.$extension);
update_existing_document($_course, $document_id,$file_size,$read_only_flag);
api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $_user['user_id'],null,null,null,null,$current_session_id);
//update parent folders
item_property_update_on_folder($_course,$dir,$_user['user_id']);
$dir= substr($dir,0,-1);
$dir = substr($dir,0,-1);
header('Location: document.php?curdirpath='.urlencode($dir));
exit ();
}
else
{
//$msgError=get_lang('Impossible');
//$msgError=get_lang('Impossible');
}
}
else

@ -1224,7 +1224,7 @@ function zip_download ($array)
// create the directory if it does not exist yet.
if(!is_dir($temp_zip_dir))
{
mkdir($temp_zip_dir);
mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
}
cleanup_temp_dropbox();

@ -220,7 +220,7 @@ if ( isset( $_POST["submitWork"]))
if ( ( ! is_dir( dropbox_cnf("sysPath"))))
{
//The dropbox subdir doesn't exist yet so make it and create the .htaccess file
mkdir( dropbox_cnf("sysPath"), 0700) or die ( dropbox_lang("errorCreatingDir")." (code 404)");
mkdir( dropbox_cnf("sysPath"), api_get_permissions_for_new_directories()) or die ( dropbox_lang("errorCreatingDir")." (code 404)");
$fp = fopen( dropbox_cnf("sysPath")."/.htaccess", "w") or die (dropbox_lang("errorCreatingDir")." (code 405)");
fwrite($fp, "AuthName AllowLocalAccess
AuthType Basic

@ -162,7 +162,7 @@ if($_GET['action'] == 'exportqti2' && !empty($_GET['questionId']))
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
$temp_dir_short = uniqid();
$temp_zip_dir = $archive_path."/".$temp_dir_short;
if(!is_dir($temp_zip_dir)) mkdir($temp_zip_dir);
if(!is_dir($temp_zip_dir)) mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
$temp_zip_file = $temp_zip_dir."/".md5(time()).".zip";
$temp_xml_file = $temp_zip_dir."/qti2export_".$qid.'.xml';
file_put_contents($temp_xml_file,$export);
@ -430,7 +430,7 @@ Display::display_header($nameTools,'Exercise');
echo '<div class="actions">';
echo Display::return_icon('preview.gif', get_lang('Preview')).'<a href="exercice_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('Preview').'</a>';
echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';
if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
echo Display::return_icon('message_reply_forum.png', get_lang('GoBackToQuestionList')).' '.'<a href="admin.php?">'.get_lang('GoBackToQuestionList').'</a><br/>';
echo '</div>';

@ -433,7 +433,7 @@ if ($is_allowedToEdit && !empty ($choice) && $choice == 'exportqti2') {
$temp_dir_short = uniqid();
$temp_zip_dir = $archive_path . "/" . $temp_dir_short;
if (!is_dir($temp_zip_dir))
mkdir($temp_zip_dir);
mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
$temp_zip_file = $temp_zip_dir . "/" . md5(time()) . ".zip";
$temp_xml_file = $temp_zip_dir . "/qti2export_" . $exerciseId . '.xml';
file_put_contents($temp_xml_file, $export);

@ -54,9 +54,12 @@ function get_and_unzip_uploaded_exercise()
//unzip files
$exerciseRepositorySys = get_conf('rootSys') . get_conf('exerciseRepository','cache/');
//create temp dir for upload
claro_mkdir($exerciseRepositorySys);
$uploadDirFullPath = tempdir($exerciseRepositorySys);
//claro_mkdir($exerciseRepositorySys);
mkdir($exerciseRepositorySys, api_get_permissions_for_new_directories(), true);
//
$uploadDirFullPath = tempdir($exerciseRepositorySys, api_get_permissions_for_new_directories());
$uploadDir = str_replace($exerciseRepositorySys,'',$uploadDirFullPath);
$exercisePath = $exerciseRepositorySys.$uploadDir.'/';

@ -20,10 +20,7 @@ function hotpotatoes_init($baseWorkDir) {
if (is_file($documentPath)) {
@unlink($documentPath);
}
@mkdir($documentPath);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod ($documentPath,$perm);
@mkdir($documentPath, api_get_permissions_for_new_directories());
return true;
} else {
//if this directory already exists, return false

@ -138,10 +138,7 @@ if((api_is_allowed_to_edit(null,true)) && (($finish == 0) || ($finish == 2)))
{ //generate new test folder if on first step of file upload
$filename = replace_dangerous_char(trim($_FILES['userFile']['name']),'strict');
$fld = GenerateHpFolder($document_sys_path.$uploadPath."/");
@mkdir($document_sys_path.$uploadPath."/".$fld);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod ($document_sys_path.$uploadPath."/".$fld,$perm);
@mkdir($document_sys_path.$uploadPath."/".$fld, api_get_permissions_for_new_directories());
$doc_id = add_document($_course, '/HotPotatoes_files/'.$fld,'folder',0,$fld);
api_item_property_update($_course,TOOL_DOCUMENT,$doc_id,'FolderCreated',$_user['user_id']);
}

@ -87,11 +87,11 @@ abstract class Question
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$sql="SELECT question,description,ponderation,position,type,picture,level FROM $TBL_QUESTIONS WHERE id='".Database::escape_string($id)."'";
$result=Database::query($sql,__FILE__,__LINE__);
// if the question has been found
if($object=Database::fetch_object($result))
{
@ -327,10 +327,7 @@ abstract class Question
global $picturePath, $_course, $_user;
if (!file_exists($picturePath)) {
if (mkdir($picturePath)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod($picturePath,$perm);
if (mkdir($picturePath, api_get_permissions_for_new_directories())) {
// document path
$documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document";
$path = str_replace($documentPath,'',$picturePath);

@ -35,7 +35,7 @@ $session_name = api_get_session_name($my_session_id);
Course title section
-----------------------------------------------------------------------------
*/
if (!empty($_cid) and $_cid != -1 and isset($_course)) {
if (!empty($_cid) and $_cid != -1 and isset($_course)) {
//Put the name of the course in the header
?>
<div id="my_courses"><a href="<?php echo api_get_path(WEB_COURSE_PATH).$_course['path']; ?>/index.php" target="_top">
@ -58,11 +58,11 @@ if (!empty($_cid) and $_cid != -1 and isset($_course)) {
echo stripslashes($_course['titular']);
}
echo "</a></div>";
} elseif (isset ($nameTools) && $language_file != 'course_home') {
} elseif (isset ($nameTools) && $language_file != 'course_home') {
//Put the name of the user-tools in the header
if (!isset ($_user['user_id'])) {
echo '<div id="my_courses"></div>';
} elseif(!$noPHP_SELF) {
} elseif(!$noPHP_SELF) {
echo "<div id=\"my_courses\"><a href=\"".api_get_self()."?".api_get_cidreq(), "\" target=\"_top\">", $nameTools, "</a></div>", "\n";
} else {
echo '<div id="my_courses">'.$nameTools.'</div>';
@ -198,8 +198,8 @@ if ($_user['user_id'] && !api_is_anonymous()) {
$menu_navigation['mycourses'] = $possible_tabs['mycourses'];
}
// My Profile
if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
// My Profile
if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
$navigation['myprofile'] = $possible_tabs['myprofile'];
} else {
$menu_navigation['myprofile'] = $possible_tabs['myprofile'];
@ -234,8 +234,8 @@ if ($_user['user_id'] && !api_is_anonymous()) {
} else {
$menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
}
}
}
// Social Networking
if (api_get_setting('show_tabs', 'social') == 'true') {
if (api_get_setting('allow_social_tool') == 'true') {
@ -244,7 +244,7 @@ if ($_user['user_id'] && !api_is_anonymous()) {
} else{
$menu_navigation['social'] = $possible_tabs['social'];
}
// Administration
if(api_is_platform_admin(true)) {
if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
@ -276,22 +276,19 @@ if(!empty($_SESSION['user_language_choice'])) {
}
if ($_configuration['multiple_access_urls']==true) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$url_info = api_get_access_url($access_url_id);
$url = substr($url_info['url'],7,strlen($url_info['url'])-8);
$url = substr($url_info['url'],7,strlen($url_info['url'])-8);
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/','-',$clean_url);
$clean_url = $clean_url.'/';
$homep = '../../home/'; //homep for Home Path
$homep_new = '../../home/'.$clean_url; //homep for Home Path added the url
$homep = '../../home/'; //homep for Home Path
$homep_new = '../../home/'.$clean_url; //homep for Home Path added the url
$new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url;
//we create the new dir for the new sites
if (!is_dir($new_url_dir)){
umask(0);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0755');
mkdir($new_url_dir, $perm);
if (!is_dir($new_url_dir)){
mkdir($new_url_dir, api_get_permissions_for_new_directories());
}
}
} else {
@ -320,7 +317,7 @@ if(api_get_self() != '/main/admin/configure_homepage.php') {
echo $open;
} else {
$home_menu = '';
if(file_exists($homep.$menutabs.'_'.$lang.$ext)) {
if(file_exists($homep.$menutabs.'_'.$lang.$ext)) {
$home_menu = file($homep.$menutabs.'_'.$lang.$ext);
} else {
$home_menu = file ($homep.$menutabs.$ext);
@ -330,7 +327,7 @@ if(api_get_self() != '/main/admin/configure_homepage.php') {
if(!empty($enreg)) {
$edit_link='<a href="'.api_get_self().'?action=edit_tabs&amp;link_index='.$key.'" ><span>'.Display::return_icon('edit.gif', get_lang('Edit')).'</span></a>';
$delete_link='<a href="'.api_get_self().'?action=delete_tabs&amp;link_index='.$key.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;"><span>'.Display::return_icon('delete.gif', get_lang('Delete')).'</span></a>';
$tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=','</li>'),array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=',''.$edit_link.$delete_link.'</li>'),$enreg);
$tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=','</li>'),array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=',''.$edit_link.$delete_link.'</li>'),$enreg);
echo $tab_string;
}
}
@ -399,7 +396,7 @@ if (!empty($final_navigation)) {
echo implode(' &gt; ',$final_navigation);
echo '</div>';
} else {
echo '<div id="header4">';
echo '<div id="header4">';
echo '</div>';
}
if(api_get_setting('show_toolshortcuts')=='true') {

@ -190,9 +190,7 @@ function define_course_keys($wantedCode, $prefix4all = "", $prefix4baseName = ""
*/
function prepare_course_repository($courseRepository, $courseId)
{
umask(0);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
$perm = api_get_permissions_for_new_directories();
$perm_file = api_get_setting('permissions_for_new_files');
$perm_file = octdec(!empty($perm_file)?$perm_file:'0660');
mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository, $perm);
@ -391,14 +389,14 @@ function update_Db_course($courseDbName, $language = null)
// Notebook
$TBL_NOTEBOOK = $courseDbName . 'notebook';
// Attendance
$TBL_ATTENDANCE = $courseDbName . 'attendance';
$TBL_ATTENDANCE_SHEET = $courseDbName . 'attendance_sheet';
$TBL_ATTENDANCE_CALENDAR = $courseDbName . 'attendance_calendar';
$TBL_ATTENDANCE_RESULT = $courseDbName . 'attendance_result';
/*
-----------------------------------------------------------
Announcement tool
@ -695,7 +693,7 @@ function update_Db_course($courseDbName, $language = null)
hotspot_coordinates text,
hotspot_type enum('square','circle','poly','delineation') default NULL,
destination text NOT NULL,
id_auto int NOT NULL AUTO_INCREMENT,
id_auto int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id, question_id),
UNIQUE KEY id_auto (id_auto)
)" . $charset_clause;
@ -1722,8 +1720,8 @@ function update_Db_course($courseDbName, $language = null)
$result = Database::query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
/* Attendance tool */
// attendance table
// attendance table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE."` (
id int NOT NULL auto_increment PRIMARY KEY,
@ -1741,7 +1739,7 @@ function update_Db_course($courseDbName, $language = null)
$sql = "ALTER TABLE `".$TBL_ATTENDANCE . "` ADD INDEX (active)";
Database::query($sql, __FILE__, __LINE__);
// attendance sheet table
// attendance sheet table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_SHEET."` (
user_id int NOT NULL,
@ -1753,7 +1751,7 @@ function update_Db_course($courseDbName, $language = null)
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_SHEET . "` ADD INDEX (presence) ";
Database::query($sql, __FILE__, __LINE__);
// attendance calendar table
// attendance calendar table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_CALENDAR."` (
id int NOT NULL auto_increment,
@ -1766,9 +1764,9 @@ function update_Db_course($courseDbName, $language = null)
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_CALENDAR."` ADD INDEX (attendance_id)";
Database::query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_CALENDAR."` ADD INDEX (done_attendance)";
Database::query($sql, __FILE__, __LINE__);
// attendance result table
Database::query($sql, __FILE__, __LINE__);
// attendance result table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_RESULT."` (
id int NOT NULL auto_increment PRIMARY KEY,
@ -1840,10 +1838,11 @@ function sort_pictures($files,$type)
*/
function fill_course_repository($courseRepository)
{
$old_umask = umask(0);
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$web_code_path = api_get_path(WEB_CODE_PATH);
$perm = api_get_permissions_for_new_directories();
/*doc_html = file(api_get_path(SYS_CODE_PATH).'document/example_document.html');
$fp = fopen($sys_course_path.$courseRepository.'/document/example_document.html', 'w');
@ -1879,8 +1878,6 @@ function fill_course_repository($courseRepository)
$pictures_array = sort_pictures($files,"dir");
$pictures_array = array_merge($pictures_array,sort_pictures($files,"file"));
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
$perm_file = api_get_setting('permissions_for_new_files');
$perm_file = octdec(!empty($perm_file)?$perm_file:'0660');
if(!is_dir($course_documents_folder_images))
@ -2010,7 +2007,7 @@ function fill_course_repository($courseRepository)
$default_document_array['video']=$video_array;
}
umask($old_umask);
return $default_document_array;
}

@ -265,9 +265,9 @@ function FileUpload( $resourceType, $currentFolder, $sCommand )
$permissions = $Config['ChmodOnUpload'] ;
}
$oldumask = umask(0) ;
//$oldumask = umask(0) ;
chmod( $sFilePath, $permissions ) ;
umask( $oldumask ) ;
//umask( $oldumask ) ;
}
break ;

@ -131,9 +131,9 @@ function CreateServerFolder( $folderPath, $lastFolder = null )
$permissions = $Config['ChmodOnFolderCreate'] ;
}
// To create the folder with 0777 permissions, we need to set umask to zero.
$oldumask = umask(0) ;
//$oldumask = umask(0) ;
mkdir( $folderPath, $permissions ) ;
umask( $oldumask ) ;
//umask( $oldumask ) ;
}
// While we are in a course: Registering the newly created folder in the course's database.

@ -87,8 +87,7 @@ class Files
//return chmod($newFolder, 0777);
global $permissions_for_new_directories;
mkdir ($newFolder, $permissions_for_new_directories);
return @chmod($newFolder, $permissions_for_new_directories);
return mkdir($newFolder, $permissions_for_new_directories) !== false;
}

@ -344,12 +344,12 @@ function copyDirTo($origDirPath, $destination, $move=true)
// extract directory name - create it at destination - update destination trail
$dirName = basename($origDirPath);
if(is_dir($dirName)){
mkdir ($destination."/".$dirName, 0775);
mkdir ($destination."/".$dirName, api_get_permissions_for_new_directories());
$destinationTrail = $destination."/".$dirName;
if(is_dir($destination)){
chdir ($origDirPath) ;
$handle = opendir($origDirPath);
while ($element = readdir($handle) )
{
if ( $element == "." || $element == "..")
@ -359,7 +359,7 @@ function copyDirTo($origDirPath, $destination, $move=true)
elseif ( is_file($element) )
{
copy($element, $destinationTrail."/".$element);
if($move)
{
unlink($element) ;
@ -370,9 +370,9 @@ function copyDirTo($origDirPath, $destination, $move=true)
$dirToCopy[] = $origDirPath."/".$element;
}
}
closedir($handle) ;
if ( sizeof($dirToCopy) > 0)
{
foreach($dirToCopy as $thisDir)
@ -380,14 +380,14 @@ function copyDirTo($origDirPath, $destination, $move=true)
copyDirTo($thisDir, $destinationTrail, $move); // recursivity
}
}
if($move)
{
rmdir ($origDirPath) ;
}
chdir($save_dir);
}
}
}
}
}
//------------------------------------------------------------------------------
@ -537,56 +537,53 @@ function mkpath($path, $verbose = false, $mode = "herit")
{
global $langCreatedIn, $_configuration;
$path=str_replace("/","\\",$path);
$dirs=explode("\\",$path);
$path = str_replace("/", "\\", $path);
$dirs = explode("\\", $path);
$path=$dirs[0];
$path = $dirs[0];
if($verbose)
if ($verbose)
{
echo "<UL>";
echo "<ul>";
}
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
for($i=1;$i < sizeof($dirs);$i++)
for ($i = 1; $i < sizeof($dirs); $i++)
{
$path.='/'.$dirs[$i];
$path .= '/'.$dirs[$i];
if(ereg('^'.$path,$_configuration['root_sys']) && strlen($path) < strlen($_configuration['root_sys']))
if (ereg('^'.$path,$_configuration['root_sys']) && strlen($path) < strlen($_configuration['root_sys']))
{
continue;
}
if(!is_dir($path))
if (!is_dir($path))
{
$ret=mkdir($path,$perm);
$ret = mkdir($path, api_get_permissions_for_new_directories());
if($ret)
if ($ret)
{
if($verbose)
{
echo '<li><strong>'.basename($path).'</strong><br>'.$langCreatedIn.'<br><strong>'.realpath($path.'/..').'</strong></li>';
echo '<li><strong>'.basename($path).'</strong><br />'.$langCreatedIn.'<br /><strong>'.realpath($path.'/..').'</strong></li>';
}
}
else
{
if($verbose)
if ($verbose)
{
echo '</UL>error : '.$path.' not created';
echo '</ul>error : '.$path.' not created';
}
$ret=false;
$ret = false;
break;
}
}
}
if($verbose)
if ($verbose)
{
echo '</UL>';
echo '</ul>';
}
return $ret;
@ -669,19 +666,19 @@ class FileManager
---------------------------------------------------------------
*/
function list_all_directories($path)
{
$resultArray = array();
if (is_dir($path)) {
{
$resultArray = array();
if (is_dir($path)) {
$save_dir = getcwd();
chdir($path);
$handle = opendir($path);
while ($element = readdir($handle) )
{
{
if ( $element == "." || $element == "..") continue; // skip the current and parent directories
if ( is_dir($element) )
{
$dirArray[] = $path."/".$element;
}
}
}
closedir($handle);
// recursive operation if subdirectories exist
@ -690,15 +687,15 @@ class FileManager
{
for ($i = 0 ; $i < $dirNumber ; $i++ )
{
$subDirArray = FileManager::list_all_directories($dirArray[$i]) ; // function recursivity
$subDirArray = FileManager::list_all_directories($dirArray[$i]) ; // function recursivity
if (is_array($dirArray) && is_array($subDirArray)) {
$dirArray = array_merge( $dirArray , $subDirArray ) ; // data merge
}
}
}
}
$resultArray = $dirArray;
chdir($save_dir) ;
}
chdir($save_dir) ;
}
return $resultArray ;
}
@ -713,12 +710,12 @@ class FileManager
===============================================================
*/
function list_all_files($dirArray)
{
{
$elementArray = array();
if(is_dir($dirArray))
{
$save_dir = getcwd();
foreach ($dirArray as $directory)
{
@ -736,9 +733,9 @@ class FileManager
chdir("..") ;
chdir($save_dir);
}
}
}
return $elementArray;
}
@ -749,7 +746,7 @@ class FileManager
Function is binary safe (is needed on Windows)
*/
function compat_load_file($file_name)
{
{
$buffer = '';
if(file_exists($file_name))
{
@ -759,7 +756,7 @@ class FileManager
//api_display_debug_info(htmlentities($buffer));
}
return $buffer;
}
@ -800,7 +797,7 @@ class FileManager
$sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'";
//api_display_debug_info($sql_query);
$sql_result = Database::query($sql_query,__FILE__,__LINE__);
$sql_result = Database::query($sql_query,__FILE__,__LINE__);
$result = Database::fetch_array($sql_result);
//determine which query to execute
if( $result["number_existing"] > 0 )

@ -116,7 +116,7 @@ function htaccess2txt($filename)
* @see htaccess2txt()
*/
function disable_dangerous_file($filename)
{
{
$filename = php2phps($filename);
$filename = htaccess2txt($filename);
return $filename;
@ -491,7 +491,7 @@ function enough_space($file_size, $max_dir_space)
*/
function dir_total_space($dirPath)
{
{
$save_dir = getcwd();
chdir ($dirPath) ;
@ -735,8 +735,8 @@ function treat_uploaded_file($uploadedFile, $baseWorkDir, $uploadPath, $maxFille
*/
function unzip_uploaded_file($uploadedFile, $uploadPath, $baseWorkDir, $maxFilledSpace)
{
{
$zipFile = new pclZip($uploadedFile['tmp_name']);
// Check the zip content (real size and file extension)
if(file_exists($uploadedFile)) {
@ -768,37 +768,37 @@ function unzip_uploaded_file($uploadedFile, $uploadPath, $baseWorkDir, $maxFille
{
$okAiccScorm=true;
}
$realFileSize += $thisContent['size'];
}
if ((($okPlantynScorm1==true) and ($okPlantynScorm2==true) and ($okPlantynScorm3==true)) or ($okAiccScorm==true))
{
$okScorm=true;
}
if(!$okScorm && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM)
{
return api_failure::set_failure('not_scorm_content');
}
if (! enough_size($realFileSize, $baseWorkDir, $maxFilledSpace) )
{
return api_failure::set_failure('not_enough_space');
}
// it happens on Linux that $uploadPath sometimes doesn't start with '/'
if($uploadPath[0] != '/')
{
$uploadPath='/'.$uploadPath;
}
if($uploadPath[strlen($uploadPath)-1] == '/')
{
$uploadPath=substr($uploadPath,0,-1);
}
/*
--------------------------------------
Uncompressing phase
@ -826,11 +826,11 @@ function unzip_uploaded_file($uploadedFile, $uploadPath, $baseWorkDir, $maxFille
for($j=0;$j<count($unzippingState);$j++)
{
$state=$unzippingState[$j];
//fix relative links in html files
$extension = strrchr($state["stored_filename"], ".");
}
if($dir=@opendir($baseWorkDir.$uploadPath))
{
while($file=readdir($dir))
@ -838,17 +838,17 @@ function unzip_uploaded_file($uploadedFile, $uploadPath, $baseWorkDir, $maxFille
if($file != '.' && $file != '..')
{
$filetype="file";
if(is_dir($baseWorkDir.$uploadPath.'/'.$file)) $filetype="folder";
$safe_file=replace_dangerous_char($file,'strict');
@rename($baseWorkDir.$uploadPath.'/'.$file,$baseWorkDir.$uploadPath.'/'.$safe_file);
set_default_settings($uploadPath,$safe_file,$filetype);
}
}
closedir($dir);
}
chdir($save_dir); //back to previous dir position
@ -1322,7 +1322,7 @@ function search_img_from_html($htmlFile)
$imgFilePath = array();
if(!$fp = fopen($htmlFile, "r")){ //or die('<center>can not open file</center>');
return ;
return ;
}
// search and store occurences of the <IMG> tag in an array
@ -1393,27 +1393,25 @@ function create_unexisting_directory($_course,$user_id,$to_group_id,$to_user_id,
$title = basename($desired_dir_name);
}
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
if (mkdir($base_work_dir.$desired_dir_name.$nb,$perm,true))
{
if (mkdir($base_work_dir.$desired_dir_name.$nb, api_get_permissions_for_new_directories(), true))
{
$document_id = add_document($_course, $desired_dir_name.$nb,'folder',0,$title);
if ($document_id)
{
//update document item_property
$current_session_id = api_get_session_id();
if ($visibility !== '') {
$visibilities = array(0 => 'invisible', 1 => 'visible', 2 => 'delete');
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$visibilities[$visibility],$user_id,$to_group_id,$to_user_id,null,null,$current_session_id);
} else {
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'FolderCreated',$user_id,$to_group_id,$to_user_id,null,null,$current_session_id);
}
return $desired_dir_name.$nb;
//update document item_property
$current_session_id = api_get_session_id();
if ($visibility !== '') {
$visibilities = array(0 => 'invisible', 1 => 'visible', 2 => 'delete');
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$visibilities[$visibility],$user_id,$to_group_id,$to_user_id,null,null,$current_session_id);
} else {
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'FolderCreated',$user_id,$to_group_id,$to_user_id,null,null,$current_session_id);
}
return $desired_dir_name.$nb;
}
}
else
{
return false;
return false;
}
}
@ -1501,7 +1499,7 @@ function replace_img_path_in_html_file($originalImgPath, $newImgPath, $htmlFile)
if (!$fp = fopen($htmlFile, 'w')){ //or die('<center>cannot open file</center>');
return;
}
if (!fwrite($fp, $new_html_content)){ // or die('<center>cannot write in file</center>');
return;
}
@ -1531,8 +1529,8 @@ function create_link_file($filePath, $url)
if (!($fp = fopen ($filePath, 'w'))) {
return false;
}
return fwrite($fp, $fileContent);
return fwrite($fp, $fileContent);
}
}
@ -1552,10 +1550,10 @@ function api_replace_links_in_html($upload_path, $full_file_name)
if(file_exists($full_file_name)){
$fp = fopen($full_file_name, "r");
$buffer = fread ($fp, filesize ($full_file_name));
//Parse the contents
$new_html_content = api_replace_links_in_string($upload_path, $buffer);
//Write the result
$fp = fopen($full_file_name, "w");
fwrite($fp, $new_html_content);
@ -1863,7 +1861,7 @@ if(is_dir($path)){
while($file=readdir($handle))
{
if ($file=='.' || $file=='..') continue;
$completepath="$path/$file";
//directory?
if (is_dir($completepath))
@ -1877,7 +1875,7 @@ if(is_dir($path)){
$document_id=add_document($_course,$current_path.'/'.$safe_file,'folder',0,$title);
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$user_id, $to_group_id,null,null,null,$current_session_id);
//echo $current_path.'/'.$safe_file." added!<br/>";
}
//recursive
add_all_documents_in_folder_to_database($_course,$user_id,$base_work_dir,$current_path.'/'.$safe_file, $to_group_id);
@ -1888,7 +1886,7 @@ if(is_dir($path)){
//rename
$safe_file=disable_dangerous_file(replace_dangerous_char($file, 'strict'));
@rename($base_work_dir.$current_path.'/'.$file,$base_work_dir.$current_path.'/'.$safe_file);
if(!DocumentManager::get_document_id($_course, $current_path.'/'.$safe_file))
{
$title=get_document_title($file);

@ -9,16 +9,16 @@
==============================================================================
*/
// Group permissions
define('GROUP_PERMISSION_OPEN' , '1');
define('GROUP_PERMISSION_OPEN' , '1');
define('GROUP_PERMISSION_CLOSED', '2');
// Group user permissions
define('GROUP_USER_PERMISSION_ADMIN' ,'1'); // the admin of a group
define('GROUP_USER_PERMISSION_ADMIN' ,'1'); // the admin of a group
define('GROUP_USER_PERMISSION_READER' ,'2'); // a normal user
define('GROUP_USER_PERMISSION_PENDING_INVITATION' ,'3'); // When an admin/moderator invites a user
define('GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER' ,'4'); // an user joins a group
define('GROUP_USER_PERMISSION_MODERATOR' ,'5'); // a moderator
define('GROUP_USER_PERMISSION_ANONYMOUS' ,'6'); // an anonymous user
define('GROUP_USER_PERMISSION_ANONYMOUS' ,'6'); // an anonymous user
define('GROUP_IMAGE_SIZE_ORIGINAL', 1);
@ -49,7 +49,7 @@ class GroupPortalManager
picture_uri = '".Database::escape_string($picture)."',
url = '".Database::escape_string($url)."',
visibility = '".Database::escape_string($visibility)."',
created_on = FROM_UNIXTIME(".$tms."),
created_on = FROM_UNIXTIME(".$tms."),
updated_on = FROM_UNIXTIME(".$tms.")";
$result = Database::query($sql, __FILE__, __LINE__);
$return = Database::insert_id();
@ -85,7 +85,7 @@ class GroupPortalManager
/**
* Deletes a group
* Deletes a group
* @author Julio Montoya
* @param int id
* @return boolean true if success
@ -103,20 +103,20 @@ class GroupPortalManager
return $result;
}
/**
* Gets data of all groups
* @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
* */
public static function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10)
public static function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10)
{
$table = Database :: get_main_table(TABLE_MAIN_GROUP);
$visibility = intval($visibility);
$user_condition = '';
$user_condition = '';
$sql = "SELECT name, description, picture_uri FROM $table WHERE visibility = $visibility ";
$res = Database::query($sql, __FILE__, __LINE__);
$data = array ();
@ -125,62 +125,62 @@ class GroupPortalManager
}
return $data;
}
/**
* Gets the group data
*
*
*
*
*/
public static function get_group_data($group_id)
public static function get_group_data($group_id)
{
$table = Database :: get_main_table(TABLE_MAIN_GROUP);
$group_id = intval($group_id);
$user_condition = '';
$user_condition = '';
$sql = "SELECT id, name, description, picture_uri, url, visibility FROM $table WHERE id = $group_id ";
$res = Database::query($sql, __FILE__, __LINE__);
$item = array();
$item = array();
if (Database::num_rows($res)>0) {
$item = Database::fetch_array($res,'ASSOC');
}
return $item;
}
/**
* Gets the tags from a given group
* @param int group id
* @param bool show group links or not
*
* @param bool show group links or not
*
*/
public static function get_group_tags($group_id, $show_tag_links = true)
public static function get_group_tags($group_id, $show_tag_links = true)
{
$tag = Database :: get_main_table(TABLE_MAIN_TAG);
$table_group_rel_tag = Database :: get_main_table(TABLE_MAIN_GROUP_REL_TAG);
$group_id = intval($group_id);
$group_id = intval($group_id);
$user_condition = '';
$sql = "SELECT tag FROM $tag t INNER JOIN $table_group_rel_tag gt ON (gt.tag_id= t.id) WHERE gt.group_id = $group_id ";
$res = Database::query($sql, __FILE__, __LINE__);
$tags = array();
$tags = array();
if (Database::num_rows($res)>0) {
while ($row = Database::fetch_array($res,'ASSOC')) {
$tags[] = $row;
$tags[] = $row;
}
}
if ($show_tag_links == true) {
if (is_array($tags) && count($tags)>0) {
foreach ($tags as $tag) {
$tag_tmp[] = '<a href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tag['tag'].'">'.$tag['tag'].'</a>';
}
if (is_array($tags) && count($tags)>0) {
}
if (is_array($tags) && count($tags)>0) {
$tags= implode(', ',$tag_tmp);
}
} else {
$tags = '';
}
}
}
return $tags;
}
}
/** Gets the inner join from users and group table
* @return int access url id
@ -193,19 +193,19 @@ class GroupPortalManager
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
$user_id = intval($user_id);
if ($relation_type == 0) {
if ($relation_type == 0) {
$where_relation_condition = '';
} else {
$relation_type = intval($relation_type);
$where_relation_condition = "AND gu.relation_type = $relation_type ";
}
$sql = "SELECT g.picture_uri, g.name, g.description, g.id , gu.relation_type
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 ORDER BY created_on desc ";
$result=Database::query($sql,__FILE__,__LINE__);
$array = array();
if (Database::num_rows($result) > 0) {
@ -215,35 +215,35 @@ class GroupPortalManager
$img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img;
}
$array[$row['id']] = $row;
$array[$row['id']] = $row;
}
}
return $array;
}
/** Gets the inner join of users and group table
* @return int quantity of records
* @return bool show groups with image or not
* @return array with group content
* @return array with group content
* @author Julio Montoya
* */
public static function get_groups_by_popularity($num = 6, $with_image = true)
{
$where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
if (empty($num)) {
$num = 6;
} else {
$num = intval($num);
}
// only show admins and readers
$where_relation_condition = " WHERE gu.relation_type IN ('".GROUP_USER_PERMISSION_ADMIN."' , '".GROUP_USER_PERMISSION_READER."') ";
$sql = "SELECT count(user_id) as count, g.picture_uri, g.name, g.description, g.id
$where_relation_condition = " WHERE gu.relation_type IN ('".GROUP_USER_PERMISSION_ADMIN."' , '".GROUP_USER_PERMISSION_READER."') ";
$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 $where_relation_condition 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')) {
@ -252,16 +252,16 @@ class GroupPortalManager
$img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img;
}
$array[$row['id']] = $row;
$array[$row['id']] = $row;
}
return $array;
}
/** Gets the last groups created
* @return int quantity of records
* @return bool show groups with image or not
* @return array with group content
* @author Julio Montoya
* @author Julio Montoya
* */
public static function get_groups_by_age($num = 6, $with_image = true)
{
@ -273,11 +273,11 @@ class GroupPortalManager
$num = 6;
} else {
$num = intval($num);
}
$sql = "SELECT g.picture_uri, g.name, g.description, g.id
}
$sql = "SELECT g.picture_uri, g.name, g.description, g.id
FROM $tbl_group g
ORDER BY created_on desc LIMIT $num ";
$result=Database::query($sql,__FILE__,__LINE__);
$array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -285,12 +285,12 @@ class GroupPortalManager
$picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
$img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img;
}
$array[$row['id']] = $row;
}
$array[$row['id']] = $row;
}
return $array;
}
/**
* Gets the group's members
*/
@ -300,21 +300,21 @@ class GroupPortalManager
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$group_id = intval($group_id);
$from = intval($from);
$from = intval($from);
$limit = intval($limit);
if (empty($group_id)){
return array();
}
if (empty($limit)) {
$limit = 15;
}
if (empty($from)) {
$from = 0;
}
if (count($relation_type) == 0) {
if (count($relation_type) == 0) {
$where_relation_condition = '';
} else {
$new_relation_type = array();
@ -325,24 +325,24 @@ class GroupPortalManager
$relation_type = implode(',', $new_relation_type);
$where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
}
$sql="SELECT picture_uri as image, u.user_id, u.firstname, u.lastname, relation_type FROM $tbl_user u
INNER JOIN $table_group_rel_user gu
ON (gu.user_id = u.user_id) WHERE gu.group_id= $group_id $where_relation_condition ORDER BY relation_type, firstname LIMIT $from, $limit";
$result=Database::query($sql,__FILE__,__LINE__);
$array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image == true) {
$image_path = UserManager::get_user_picture_path_by_id($row['user_id'], 'web', false, true);
$picture = UserManager::get_picture_user($row['user_id'], $image_path['file'],$image_conf['height'],$image_conf['size']);
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image == true) {
$image_path = UserManager::get_user_picture_path_by_id($row['user_id'], 'web', false, true);
$picture = UserManager::get_picture_user($row['user_id'], $image_path['file'],$image_conf['height'],$image_conf['size']);
$row['image'] = '<img src="'.$picture['file'].'" '.$picture['style'].' />';
}
$array[$row['user_id']] = $row;
$array[$row['user_id']] = $row;
}
return $array;
}
/**
* Gets all the members of a group no matter the relationship for more specifications use get_users_by_group
* @param int group id
@ -353,45 +353,45 @@ class GroupPortalManager
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$group_id = intval($group_id);
if (empty($group_id)){
return array();
}
}
$sql="SELECT u.user_id, u.firstname, u.lastname, relation_type FROM $tbl_user u
INNER JOIN $table_group_rel_user gu
ON (gu.user_id = u.user_id) WHERE gu.group_id= $group_id ORDER BY relation_type, firstname";
$result=Database::query($sql,__FILE__,__LINE__);
$array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
$array[$row['user_id']] = $row;
$array[$row['user_id']] = $row;
}
return $array;
}
/**
* Gets the relationship between a group and a User
* Gets the relationship between a group and a User
* @author Julio Montoya
* @param int user id
* @param int group_id
* @return int 0 if there are not relationship otherwise returns the user group
* */
* */
public static function get_user_group_role($user_id, $group_id)
{
$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 group_id = ".intval($group_id)." AND user_id = ".intval($user_id)." ";
$result = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($result)>0) {
$result = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($result)>0) {
$row = Database::fetch_array($result,'ASSOC');
$return_value = $row['relation_type'];
}
}
}
return $return_value;
}
/**
* Add a user into a group
* @author Julio Montoya
@ -402,21 +402,21 @@ class GroupPortalManager
public static function add_user_to_group($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
{
$table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
if (!empty($user_id) && !empty($group_id)) {
$role = self::get_user_group_role($user_id,$group_id);
if (!empty($user_id) && !empty($group_id)) {
$role = self::get_user_group_role($user_id,$group_id);
if ($role == 0) {
$sql = "INSERT INTO $table_url_rel_group
SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type);
$result = Database::query($sql, __FILE__, __LINE__);
} elseif($role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
} elseif($role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
//if somebody already invited me I can be added
self::update_user_role($user_id, $group_id, GROUP_USER_PERMISSION_READER);
}
}
return $result;
}
/**
* Add a group of users into a group of URLs
* @author Julio Montoya
@ -427,7 +427,7 @@ class GroupPortalManager
$table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$result_array = array();
$relation_type = intval($relation_type);
if (is_array($user_list) && is_array($group_list)) {
foreach ($group_list as $group_id) {
foreach ($user_list as $user_id) {
@ -435,8 +435,8 @@ class GroupPortalManager
if ($role == 0) {
$sql = "INSERT INTO $table_url_rel_group
SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type)."";
$result = Database::query($sql, __FILE__, __LINE__);
if ($result)
$result_array[$group_id][$user_id]=1;
@ -462,7 +462,7 @@ class GroupPortalManager
$condition_relation = "";
if (!empty($relation_type)) {
$condition_relation = " AND relation_type = '$relation_type'";
}
}
$sql = "DELETE FROM $table_ WHERE group_id = ".intval($group_id).$condition_relation;
$result = Database::query($sql, __FILE__, __LINE__);
return $result;
@ -482,47 +482,47 @@ class GroupPortalManager
$result = Database::query($sql, __FILE__, __LINE__);
return $result;
}
/**
* Updates the group_rel_user table with a given user and group ids
* @author Julio Montoya
* @param int user id
* @param int group id
* @param int relation type
* @param int relation type
* */
public static function update_user_role($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
{
{
$table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$group_id = intval($group_id);
$user_id = intval($user_id);
$sql = "UPDATE $table_group_rel_user
SET relation_type = ".intval($relation_type)." WHERE user_id = $user_id AND group_id = $group_id" ;
$result = Database::query($sql, __FILE__, __LINE__);
}
public static function get_group_admin_list($user_id, $group_id)
{
{
$table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$group_id = intval($group_id);
$user_id = intval($user_id);
$sql = "SELECT user_id FROM $table_group_rel_user WHERE
relation_type = ".GROUP_USER_PERMISSION_ADMIN." AND user_id = $user_id AND group_id = $group_id" ;
$result = Database::query($sql, __FILE__, __LINE__);
}
public static function get_all_group_tags($tag, $from=0, $number_of_items=10) {
// database table definition
$group_table = Database::get_main_table(TABLE_MAIN_GROUP);
$table_tag = Database::get_main_table(TABLE_MAIN_TAG);
$table_group_tag_values = Database::get_main_table(TABLE_MAIN_GROUP_REL_TAG);
//default field_id == 1
$field_id = 5;
$tag = Database::escape_string($tag);
@ -533,9 +533,9 @@ class GroupPortalManager
$sql = "SELECT g.id, g.name, g.description, g.picture_uri FROM $table_tag t INNER JOIN $table_group_tag_values tv ON (tv.tag_id=t.id)
INNER JOIN $group_table g ON(tv.group_id =g.id)
WHERE tag LIKE '$tag%' AND field_id= $field_id ORDER BY tag";
$sql .= " LIMIT $from,$number_of_items";
$sql .= " LIMIT $from,$number_of_items";
$result = Database::query($sql, __FILE__, __LINE__);
$return = array();
if (Database::num_rows($result)> 0) {
@ -543,54 +543,54 @@ class GroupPortalManager
$return[$row['id']] = $row;
}
}
$keyword = $tag;
$sql = "SELECT g.id, g.name, g.description, g.url, g.picture_uri FROM $group_table g";
//@todo implement groups + multiple urls
//@todo implement groups + multiple urls
/*
global $_configuration;
if ($_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
}*/
//@todo implement visibility
if (isset ($keyword)) {
$keyword = Database::escape_string($keyword);
$keyword = Database::escape_string($keyword);
$sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%' OR g.url LIKE '%".$keyword."%' )";
}
$direction = 'ASC';
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
//$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($res)> 0) {
while ($row = Database::fetch_array($res,'ASSOC')) {
if (!in_array($row['id'], $return)) {
while ($row = Database::fetch_array($res,'ASSOC')) {
if (!in_array($row['id'], $return)) {
$return[$row['id']] = $row;
}
}
}
return $return;
}
/**
* 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
* @param int The group id
* @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.
* 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.
@ -617,9 +617,7 @@ class GroupPortalManager
$path = $path_info['dir'];
// If this directory does not exist - we create it.
if (!file_exists($path)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770');
@mkdir($path, $perm, true);
@mkdir($path, api_get_permissions_for_new_directories(), true);
}
// The old photos (if any).
@ -654,7 +652,7 @@ class GroupPortalManager
if (!in_array($extension, $allowed_types)) {
return false;
}
// This is the common name for the new photos.
if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && !empty($old_file)) {
$old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
@ -670,16 +668,16 @@ class GroupPortalManager
// the correspondent directories to be found successfully.
$filename = $group_id.'_'.$filename;
}
// Storing the new photos in 4 versions with various sizes.
$picture_info = @getimagesize($source_file);
$type = $picture_info[2];
$small = self::resize_picture($source_file, 22);
$medium = self::resize_picture($source_file, 85);
$normal = self::resize_picture($source_file, 200);
$big = new image($source_file); // This is the original picture.
$ok = false;
$detected = array(1 => 'GIF', 2 => 'JPG', 3 => 'PNG');
@ -692,7 +690,7 @@ class GroupPortalManager
}
return $ok ? $filename : false;
}
/**
* 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
@ -755,7 +753,7 @@ class GroupPortalManager
}
return array('dir' => $dir, 'file' => $picture_filename);
}
/**
* Resize a picture
*
@ -781,7 +779,7 @@ class GroupPortalManager
}
return $temp;
}
/**
* Gets the current group image
* @param string group id
@ -799,7 +797,7 @@ class GroupPortalManager
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
return $picture;
}
switch ($size_picture) {
case GROUP_IMAGE_SIZE_ORIGINAL :
$size_picture = '';
@ -812,11 +810,11 @@ class GroupPortalManager
break;
case GROUP_IMAGE_SIZE_SMALL :
$size_picture = 'small_';
break;
break;
default:
$size_picture = 'medium_';
}
$image_array_sys = self::get_group_picture_path_by_id($id, 'system', false, true);
$image_array = self::get_group_picture_path_by_id($id, 'web', false, true);
$file = $image_array_sys['dir'].$size_picture.$picture_file;
@ -840,36 +838,36 @@ class GroupPortalManager
}
return $picture;
}
public static function delete_group_picture($group_id) {
return self::update_group_picture($group_id);
}
}
public static function is_group_admin($group_id, $user_id = 0) {
if (empty($user_id)) {
$user_id = api_get_user_id();
}
$user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
$user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) {
return true;
} else {
return false;
}
}
}
public static function is_group_moderator($group_id, $user_id = 0) {
if (empty($user_id)) {
$user_id = api_get_user_id();
}
$user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
$user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
return true;
} else {
return false;
}
}
}
public static function is_group_member($group_id, $user_id = 0) {
if (empty($user_id)) {
$user_id = api_get_user_id();
@ -879,62 +877,62 @@ class GroupPortalManager
return true;
} else {
return false;
}
}
}
/**
* Shows the left column of the group page
* @param int group id
* @param int user id
*
*
*/
public static function show_group_column_information($group_id, $user_id, $show = '') {
global $relation_group_title, $my_group_role;
$group_info = GroupPortalManager::get_group_data($group_id);
$group_info = GroupPortalManager::get_group_data($group_id);
$picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,GROUP_IMAGE_SIZE_MEDIUM);
$big_image = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_BIG);
$big_image = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_BIG);
$tags = GroupPortalManager::get_group_tags($group_id, true);
$members = GroupPortalManager::get_users_by_group($group_id);
$groups_by_user = GroupPortalManager::get_groups_by_user($user_id, 0);
//my relation with the group is set here
$my_group_role = self::get_user_group_role($user_id, $group_id);
//@todo this must be move to default.css for dev use only
echo '<style>
echo '<style>
#group_members { width:270px; height:300px; overflow-x:none; overflow-y: auto;}
.group_member_item { width:100px; height:130px; float:left; margin:5px 5px 15px 5px; }
.group_member_picture { display:block;
.group_member_picture { display:block;
margin:0;
overflow:hidden; };
</style>';
//Loading group permission
$links = '';
switch ($my_group_role) {
case GROUP_USER_PERMISSION_READER:
// I'm just a reader
$relation_group_title = get_lang('IamAReader');
$relation_group_title = get_lang('IamAReader');
$links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>';
$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
$links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
$links .= '<li><a href="groups.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. Display::return_icon('delete_data.gif', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
$links .= '<li><a href="groups.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. Display::return_icon('delete_data.gif', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
break;
case GROUP_USER_PERMISSION_ADMIN:
$relation_group_title = get_lang('IamAnAdmin');
$links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>';
$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
$links .= '<li><a href="group_edit.php?id='.$group_id.'">'. Display::return_icon('group_edit.png', get_lang('EditGroup'), array('hspace'=>'6')).'<span class="'.($show=='group_edit'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('EditGroup').'</span></a></li>';
$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
//if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
//if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
$links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
//}
$links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
//}
$links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
break;
case GROUP_USER_PERMISSION_PENDING_INVITATION:
case GROUP_USER_PERMISSION_PENDING_INVITATION:
// $links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouHaveBeenInvitedJoinNow').'</span></a></li>';
break;
case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
@ -942,37 +940,37 @@ class GroupPortalManager
break;
case GROUP_USER_PERMISSION_MODERATOR:
$relation_group_title = get_lang('IamAModerator');
$links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>';
$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
$links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>';
$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
$links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
}
$links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
}
$links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
break;
default:
//$links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('JoinGroup').'</a></span></li>';
break;
}
if (!empty($links)) {
echo '<div align="center" class="social-menu-title"><span class="social-menu-text1">'.cut($group_info['name'],40,true).'</span></div>';
echo '<ul class="social-menu-groups">';
echo $links;
echo '</ul>';
}
//Members
if (count($members) > 0) {
echo '<div align="center" class="social-menu-title"><span class="social-menu-text1">'.get_lang('Members').'</span></div>';
echo '<div align="center">';
echo '<div align="center">';
$min_count_members = 4;
$i = 1;
foreach($members as $member) {
if ($i > $min_count_members) break;
foreach($members as $member) {
if ($i > $min_count_members) break;
// if is a member
if (in_array($member['relation_type'] , array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR))) {
//add icons
//add icons
if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
$icon= Display::return_icon('admin_star.png', get_lang('Admin'));
}elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
@ -980,52 +978,52 @@ class GroupPortalManager
} else{
$icon= '';
}
$image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true);
$image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true);
$picture = UserManager::get_picture_user($member['user_id'], $image_path['file'], 60, USER_IMAGE_SIZE_MEDIUM);
echo '<div class="social-menu-group-member">';
echo '<a href="profile.php?u='.$member['user_id'].'">';
echo '<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="'.$picture['file'].'"/>';
echo '<div>'.api_get_person_name(cut($member['firstname'],15),cut($member['lastname'],15)).'&nbsp;'.$icon.'</div></a>';
echo '</div>';
$i++;
}
}
if (count($members) > $min_count_members) {
}
}
if (count($members) > $min_count_members) {
//More link
echo '<div class="group_member_more" style="margin-top:20px;"><a href="group_members.php?id='.$group_id.'">'.get_lang('SeeMore').'</a></div>';
}
echo '</div>';
}
echo '</div>';
echo '<div class="clear"></div>';
echo '<br />';
}
/*
// my other groups
if (count($groups_by_user) > 1) {
// my other groups
if (count($groups_by_user) > 1) {
echo '<div align="center" class="social-menu-title"><span class="social-menu-text1">'.get_lang('MyOtherGroups').'</span></div>';
echo '<div align="center">';
echo '<div align="center">';
$min_count_groups = 4;
$i = 1;
$more_link = false;
foreach($groups_by_user as $group) {
foreach($groups_by_user as $group) {
if ($group['id'] == $group_id) continue;
if ($i > $min_count_groups) {
$more_link = true;
break;
}
$picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'],80);
}
$picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'],80);
echo '<a href="groups.php?id='.$group['id'].'">';
echo '<img height="44" border="2" align="middle" width="44" vspace="10" class="social-groups-image" src="'.$picture['file'].'"/>';
echo '<div>'.cut($group['name'],50,true).'</div></a>';
$i++;
}
if ($more_link) {
}
if ($more_link) {
//More link
echo '<div class="mygroups_more" style="margin-top:20px;"><a href="groups.php?view=mygroups">'.get_lang('SeeMore').'</a></div>';
}
echo '</div>';
}
*/
}
echo '</div>';
}
*/
}
}
?>

@ -116,11 +116,11 @@ class GroupManager {
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER, $course_db);
//condition for the session
$session_id = api_get_session_id();
$my_status_of_user_in_course = CourseManager::get_user_in_course_status($my_user_id,$my_course_code);
$is_student_in_session = false;
if (is_null($my_status_of_user_in_course) || $my_status_of_user_in_course=='') {//into session
if ($session_id>0) {
@ -172,7 +172,7 @@ class GroupManager {
if(!empty($session_condition))
$sql .= $session_condition;
}
else
else
$session_condition = api_get_session_condition($session_id, false);
if(!empty($session_condition))
$sql .= $session_condition;
@ -203,7 +203,7 @@ class GroupManager {
}
}
$groups[] = $thisGroup;
}
return $groups;
}
@ -235,7 +235,7 @@ class GroupManager {
{
$secret_directory = uniqid("")."_team_".$lastId;
}
FileManager :: mkdirs(api_get_path(SYS_COURSE_PATH).$currentCourseRepository."/group/".$secret_directory, 0770);
FileManager :: mkdirs(api_get_path(SYS_COURSE_PATH).$currentCourseRepository."/group/".$secret_directory, api_get_permissions_for_new_directories());
*/
$desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs';
$dir_name = create_unexisting_directory($_course,$_user['user_id'],$lastId,NULL,api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document',$desired_dir_name);
@ -315,7 +315,7 @@ class GroupManager {
*/
public static function create_groups_from_virtual_courses() {
self :: delete_category(VIRTUAL_COURSE_CATEGORY);
$id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', TOOL_NOT_AVAILABLE, TOOL_NOT_AVAILABLE, 0, 0, 1, 1);
$id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', TOOL_NOT_AVAILABLE, TOOL_NOT_AVAILABLE, 0, 0, 1, 1);
$table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY);
$sql = "UPDATE ".$table_group_cat." SET id=".VIRTUAL_COURSE_CATEGORY." WHERE id=$id";
Database::query($sql,__FILE__,__LINE__);
@ -417,10 +417,8 @@ class GroupManager {
// define repository for deleted element
$group_garbage = api_get_path(SYS_ARCHIVE_PATH).$course['path']."/group/";
$perm = api_get_setting('permissions_for_new_directories');
$perm = (!empty($perm)?$perm:'0770');
if (!file_exists($group_garbage))
FileManager :: mkdirs($group_garbage, $perm);
FileManager :: mkdirs($group_garbage, api_get_permissions_for_new_directories());
// Unsubscribe all users
self :: unsubscribe_all_users($group_ids);
$sql = 'SELECT id, secret_directory, session_id FROM '.$group_table.' WHERE id IN ('.implode(' , ', $group_ids).')';
@ -647,8 +645,8 @@ class GroupManager {
* @param int $max_number_of_students
* @param int $groups_per_user
*/
public static function create_category ($title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state,
$chat_state = 1, $self_registration_allowed = 0, $self_unregistration_allowed = 0, $maximum_number_of_students = 8, $groups_per_user = 0)
public static function create_category ($title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state,
$chat_state = 1, $self_registration_allowed = 0, $self_unregistration_allowed = 0, $maximum_number_of_students = 8, $groups_per_user = 0)
{
$table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY);
$sql = "SELECT MAX(display_order)+1 as new_order FROM $table_group_category ";
@ -1440,7 +1438,7 @@ class GroupManager {
* Filters from the array $user_array_in the users already in the group $group_id.
*/
public static function filter_users_already_in_group ($user_array_in, $group_id) {
foreach ($user_array_in as $this_user)
{
if (!self :: is_subscribed($this_user['user_id'], $group_id))

@ -2982,7 +2982,7 @@ function copyr($source, $dest, $exclude = array(), $copied_files = array()) {
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest);
mkdir($dest, api_get_permissions_for_new_directories());
}
// Loop through the folder
@ -3034,11 +3034,8 @@ function copy_folder_course_session($pathname, $base_path_document,$session_id,$
$num_rows = Database::num_rows($rs1);
if ($num_rows == 0) {
if (mkdir($new_pathname)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod($new_pathname,$perm);
}
mkdir($new_pathname, api_get_permissions_for_new_directories());
// Insert new folder with destination session_id
$sql = "INSERT INTO ".$table." SET path = '$path', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string(basename($new_pathname))."' ,filetype='folder', size= '0', session_id = '$session_id'";
Database::query($sql, __FILE__, __LINE__);

File diff suppressed because it is too large Load Diff

@ -53,13 +53,11 @@ if(function_exists("date_default_timezone_set") and function_exists("date_defaul
// where access for writting is guaranteed.
define(_MPDF_GRAPH_CHACHE_PATH, api_get_path(SYS_ARCHIVE_PATH).'mpdf/graph_cache/');
define(_MPDF_TMP_PATH, api_get_path(SYS_ARCHIVE_PATH).'mpdf/tmp/');
$_perm = api_get_setting('permissions_for_new_directories');
$_perm = octdec(!empty($_perm) ? $_perm : '0775');
if (!file_exists(_MPDF_GRAPH_CHACHE_PATH)) {
@mkdir(_MPDF_GRAPH_CHACHE_PATH, $_perm, true);
@mkdir(_MPDF_GRAPH_CHACHE_PATH, api_get_permissions_for_new_directories(), true);
}
if (!file_exists(_MPDF_TMP_PATH)) {
@mkdir(_MPDF_TMP_PATH, $_perm, true);
@mkdir(_MPDF_TMP_PATH, api_get_permissions_for_new_directories(), true);
}
//

@ -20,7 +20,7 @@ define('USER_FIELD_TYPE_DATE', 6);
define('USER_FIELD_TYPE_DATETIME', 7);
define('USER_FIELD_TYPE_DOUBLE_SELECT', 8);
define('USER_FIELD_TYPE_DIVIDER', 9);
define('USER_FIELD_TYPE_TAG', 10);
define('USER_FIELD_TYPE_TAG', 10);
//User image sizes
define('USER_IMAGE_SIZE_ORIGINAL', 1);
@ -41,7 +41,7 @@ define('USER_RELATION_TYPE_RRHH', 7);
class UserManager
class UserManager
{
private function __construct () {
}
@ -184,10 +184,10 @@ class UserManager
*/
public static function delete_user($user_id) {
global $_configuration;
if ($user_id != strval(intval($user_id))) return false;
if ($user_id === false) return false;
if (!self::can_delete_user($user_id)) {
return false;
}
@ -268,12 +268,12 @@ class UserManager
}
UrlManager::delete_url_rel_user($user_id, $url_id);
}
if (api_get_setting('allow_social_tool')=='true' ) {
require_once api_get_path(LIBRARY_PATH).'social.lib.php';
//Delete user from groups
//Delete from user friend lists
//Delete from user friend lists
SocialManager::remove_user_rel_user($user_id,true);
}
// add event to system log
@ -671,7 +671,7 @@ class UserManager
}
return array('dir' => $dir, 'file' => $picture_filename);
}
/**
* Creates new user pfotos in various sizes of a user, or deletes user pfotos.
@ -703,9 +703,7 @@ class UserManager
$path = $path_info['dir'];
// If this directory does not exist - we create it.
if (!file_exists($path)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770');
@mkdir($path, $perm, true);
@mkdir($path, api_get_permissions_for_new_directories(), true);
}
// The old photos (if any).
@ -808,7 +806,7 @@ class UserManager
* @return A string containing the XHTML code to dipslay the production list, or FALSE
*/
public static function build_production_list($user_id, $force = false, $showdelete = false) {
if (!$force && !empty($_POST['remove_production'])) {
return true; // postpone reading from the filesystem
}
@ -874,7 +872,7 @@ class UserManager
*/
public static function remove_user_production($user_id, $production) {
$production_path = self::get_user_picture_path_by_id($user_id, 'system', true);
if (is_file($production_path['dir'].$production)) {
if (is_file($production_path['dir'].$production)) {
unlink($production_path['dir'].$production);
}
}
@ -940,8 +938,8 @@ class UserManager
// Check if enumerated field, if the option is available
$rowuf = Database::fetch_array($resuf);
switch ($rowuf['field_type']) {
case USER_FIELD_TYPE_TAG :
//4. Tags are process here comes from main/auth/profile.php
case USER_FIELD_TYPE_TAG :
//4. Tags are process here comes from main/auth/profile.php
UserManager::process_tags(explode(';', $fvalues), $user_id, $rowuf['id']);
return true;
break;
@ -967,7 +965,7 @@ class UserManager
}
break;
case 1:
case 2:
case 2:
default:
break;
}
@ -1352,8 +1350,8 @@ class UserManager
while ($row = Database::fetch_array($res)) {
if ($row['type'] == USER_FIELD_TYPE_TAG) {
$tags = self::get_user_tags_to_string($user_id,$row['id'],false);
$extra_data['extra_'.$row['fvar']] = $tags;
$extra_data['extra_'.$row['fvar']] = $tags;
} else {
$sqlu = "SELECT field_value as fval " .
" FROM $t_ufv " .
@ -1366,7 +1364,7 @@ class UserManager
" FROM $t_uf " .
" WHERE id=".$row['id'];
$res_df = Database::query($sql_df, __FILE__, __LINE__);
if (Database::num_rows($resu) > 0) {
$rowu = Database::fetch_array($resu);
$fval = $rowu['fval'];
@ -1475,7 +1473,7 @@ class UserManager
}
return $return;
}
public static function get_all_extra_field_by_type($field_type) {
// database table definition
$table_field = Database::get_main_table(TABLE_MAIN_USER_FIELD);
@ -1515,7 +1513,7 @@ class UserManager
}
return $return;
}
/** Get extra user data by value
* @param string the internal variable name of the field
* @param string the internal value of the field
@ -1611,7 +1609,7 @@ class UserManager
ORDER BY session_category_id, date_start, date_end";
$result = Database::query($sessions_sql,__FILE__,__LINE__);
if (Database::num_rows($result)>0) {
if (Database::num_rows($result)>0) {
while ($row = Database::fetch_array($result)) {
$categories[$row['session_category_id']][] = $row['id'];
}
@ -1670,9 +1668,9 @@ class UserManager
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
if ($user_id != strval(intval($user_id))) return array();
//we filter the courses from the URL
$join_access_url = $where_access_url = '';
global $_configuration;
@ -1709,7 +1707,7 @@ class UserManager
$join_access_url
WHERE course_rel_user.user_id = '".$user_id."' $where_access_url
ORDER BY user_course_category.sort, course_rel_user.sort, course.title ASC";
$course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
//var_dump($course_list_sql_result); exit;
while ($result_row = Database::fetch_array($course_list_sql_result)) {
@ -1743,7 +1741,7 @@ class UserManager
$sessions_sql = "SELECT DISTINCT id, name, date_start, date_end, DATE_SUB(date_start, INTERVAL nb_days_access_before_beginning DAY), ADDDATE(date_end, INTERVAL nb_days_access_after_end DAY)
FROM $tbl_session as session
INNER JOIN $tbl_session_course_user as session_rel_course_user
ON session_rel_course_user.id_session = session.id
ON session_rel_course_user.id_session = session.id
AND session_rel_course_user.id_user = $user_id AND session_rel_course_user.status = 2
WHERE (CURDATE() >= DATE_SUB(date_start, INTERVAL nb_days_access_before_beginning DAY)
AND CURDATE() <= ADDDATE(date_end, INTERVAL nb_days_access_after_end DAY)
@ -1781,7 +1779,7 @@ class UserManager
ON user.user_id = session_course_user.id_user
WHERE session_course_user.id_session = $id_session
AND ((session_course_user.id_user=$user_id AND session_course_user.status = 2) OR session.id_coach=$user_id)
ORDER BY i";
ORDER BY i";
$course_list_sql_result = Database::query($personal_course_list_sql, __FILE__, __LINE__);
@ -1813,8 +1811,8 @@ class UserManager
$personal_course_list_sql = "SELECT distinct course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, CONCAT(user.lastname,' ',user.firstname) t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF((session_course_user.id_user = 3 AND session_course_user.status=2),'2', '5')
FROM $tbl_session_course_user as session_course_user
INNER JOIN $tbl_course AS course
ON course.code = session_course_user.course_code AND session_course_user.id_session = $id_session
INNER JOIN $tbl_session as session ON session_course_user.id_session = session.id
ON course.code = session_course_user.course_code AND session_course_user.id_session = $id_session
INNER JOIN $tbl_session as session ON session_course_user.id_session = session.id
LEFT JOIN $tbl_user as user ON user.user_id = session_course_user.id_user
WHERE session_course_user.id_user = $user_id ORDER BY i";
@ -2067,7 +2065,7 @@ class UserManager
$row = Database::fetch_array($res, 'ASSOC');
return $row['id'];
}
/**
* Checks if a user_id is platform admin
* @param int user ID
@ -2132,7 +2130,7 @@ class UserManager
* @return array with the file and the style of an image i.e $array['file'] $array['style']
*/
public static function get_picture_user($user_id, $picture_file, $height, $size_picture = USER_IMAGE_SIZE_MEDIUM , $style = '') {
$patch_profile = 'upload/users/';
$picture = array();
$picture['style'] = $style;
@ -2140,7 +2138,7 @@ class UserManager
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
return $picture;
}
switch ($size_picture) {
case USER_IMAGE_SIZE_ORIGINAL :
$size_picture = '';
@ -2153,7 +2151,7 @@ class UserManager
break;
case USER_IMAGE_SIZE_SMALL :
$size_picture = 'small_';
break;
break;
default:
$size_picture = 'medium_';
}
@ -2165,28 +2163,28 @@ class UserManager
$picture['file'] = $image_array['dir'].$size_picture.$picture_file;
$picture['style'] = '';
if ($height > 0) {
$dimension = api_getimagesize($picture['file']);
$dimension = api_getimagesize($picture['file']);
$margin = (($height - $dimension[1]) / 2);
//@ todo the padding-top should not be here
$picture['style'] = ' style="padding-top:'.$margin.'px; width:'.$dimension[0].'px; height:'.$dimension[1].'px;" ';
$picture['style'] = ' style="padding-top:'.$margin.'px; width:'.$dimension[0].'px; height:'.$dimension[1].'px;" ';
}
} else {
//$file = api_get_path(SYS_CODE_PATH).$patch_profile.$user_id.'/'.$picture_file;
$file = $image_array_sys['dir'].$picture_file;
if (file_exists($file) && !is_dir($file)) {
$file = $image_array_sys['dir'].$picture_file;
if (file_exists($file) && !is_dir($file)) {
$picture['file'] = $image_array['dir'].$picture_file;
} else {
switch ($size_picture) {
case 'big_' :
case 'big_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown.jpg'; break;
case 'medium_' :
case 'medium_' :
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_50_50.jpg'; break;
case 'small_' :
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;
@ -2222,27 +2220,27 @@ class UserManager
$rs = Database::query($sql_insert_outbox, __FILE__, __LINE__);
}
}
/*
*
*
* USER TAGS
*
*
* Intructions to create a new user tag by Julio Montoya <gugli100@gmail.com>
*
*
* 1. Create a new extra field in main/admin/user_fields.php with the "TAG" field type make it available and visible. Called it "books" for example.
* 2. Go to profile main/auth/profile.php There you will see a special input (facebook style) that will show suggestions of tags.
* 2. Go to profile main/auth/profile.php There you will see a special input (facebook style) that will show suggestions of tags.
* 3. All the tags are registered in the user_tag table and the relationship between user and tags is in the user_rel_tag table
* 4. Tags are independent this means that tags can't be shared between tags + book + hobbies.
* 5. Test and enjoy.
*
*
*/
/**
* Gets the tags of a specific field_id
*
* Gets the tags of a specific field_id
*
* @param int field_id
* @param string how we are going to result value in array or in a string (json)
* @return mixed
* @return mixed
* @since Nov 2009
* @version 1.8.6.2
*/
@ -2250,32 +2248,32 @@ class UserManager
// database table definition
$table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$field_id = intval($field_id);
$limit = intval($limit);
$field_id = intval($field_id);
$limit = intval($limit);
$tag = trim(Database::escape_string($tag));
// all the information of the field
$sql = "SELECT id, tag from $table_user_tag
WHERE field_id = $field_id AND tag LIKE '$tag%' ORDER BY tag LIMIT $limit";
$result = Database::query($sql, __FILE__, __LINE__);
$return = array();
$return = array();
if (Database::num_rows($result)>0) {
while ($row = Database::fetch_array($result,'ASSOC')) {
$return[] = array('caption'=>$row['tag'], 'value'=>$row['tag']);
}
}
}
if ($return_format=='json') {
$return = json_encode($return);
}
return $return;
}
public static function get_top_tags($field_id, $limit=100) {
public static function get_top_tags($field_id, $limit=100) {
// database table definition
$table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$field_id = intval($field_id);
$limit = intval($limit);
$limit = intval($limit);
// all the information of the field
$sql = "SELECT count(*) count, tag FROM $table_user_tag_values uv INNER JOIN $table_user_tag ut ON(ut.id = uv.tag_id)
WHERE field_id = $field_id GROUP BY tag_id ORDER BY count DESC LIMIT $limit";
@ -2286,9 +2284,9 @@ class UserManager
$return[] = $row;
}
}
return $return;
return $return;
}
/**
* Get user's tags
* @param int field_id
@ -2301,9 +2299,9 @@ class UserManager
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$field_id = intval($field_id);
$user_id = intval($user_id);
// all the information of the field
$sql = "SELECT ut.id, tag,count FROM $table_user_tag ut INNER JOIN $table_user_tag_values uv ON (uv.tag_id=ut.ID)
$sql = "SELECT ut.id, tag,count FROM $table_user_tag ut INNER JOIN $table_user_tag_values uv ON (uv.tag_id=ut.ID)
WHERE field_id = $field_id AND user_id = $user_id ORDER BY tag";
$result = Database::query($sql, __FILE__, __LINE__);
$return = array();
@ -2314,7 +2312,7 @@ class UserManager
}
return $return;
}
/**
* Get user's tags
@ -2329,9 +2327,9 @@ class UserManager
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$field_id = intval($field_id);
$user_id = intval($user_id);
// all the information of the field
$sql = "SELECT ut.id, tag,count FROM $table_user_tag ut INNER JOIN $table_user_tag_values uv ON (uv.tag_id=ut.ID)
$sql = "SELECT ut.id, tag,count FROM $table_user_tag ut INNER JOIN $table_user_tag_values uv ON (uv.tag_id=ut.ID)
WHERE field_id = $field_id AND user_id = $user_id ORDER BY tag";
$result = Database::query($sql, __FILE__, __LINE__);
$return = array();
@ -2349,14 +2347,14 @@ class UserManager
$tag_tmp[] = $tag['tag'];
}
}
if (is_array($user_tags) && count($user_tags)>0) {
if (is_array($user_tags) && count($user_tags)>0) {
$return = implode(', ',$tag_tmp);
} else {
return '';
}
return $return;
}
/**
* Get the tag id
@ -2368,7 +2366,7 @@ class UserManager
$table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
$tag = Database::escape_string($tag);
$field_id = intval($field_id);
//with COLLATE latin1_bin to select query in a case sensitive mode
//with COLLATE latin1_bin to select query in a case sensitive mode
$sql = "SELECT id FROM $table_user_tag WHERE tag COLLATE latin1_bin LIKE '$tag' AND field_id = $field_id";
$result = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($result)>0) {
@ -2378,7 +2376,7 @@ class UserManager
return 0;
}
}
/**
* Get the tag id
* @param int tag
@ -2398,8 +2396,8 @@ class UserManager
return false;
}
}
/**
* Adds a user-tag value
* @param mixed tag
@ -2414,27 +2412,27 @@ class UserManager
$tag = Database::escape_string($tag);
$tag = trim($tag);
$user_id = intval($user_id);
$field_id = intval($field_id);
$field_id = intval($field_id);
//&& (substr($tag,strlen($tag)-1) == '@')
/*$sent_by_user = false;
/*$sent_by_user = false;
if ( substr($tag,0,1) == '@') {
//is a value sent by the list
$sent_by_user = true;
$tag = substr($tag,1,strlen($tag)-2);
}
*/
$tag_id = UserManager::get_tag_id($tag,$field_id);
/* IMPORTANT
*/
$tag_id = UserManager::get_tag_id($tag,$field_id);
/* IMPORTANT
* @todo we don't create tags with numbers
*
*
*/
if (is_numeric($tag)) {
//the form is sending an id this means that the user select it from the list so it MUST exists
/*$new_tag_id = UserManager::get_tag_id_from_id($tag,$field_id);
if ($new_tag_id !== false) {
$sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id = $new_tag_id";
$result = Database::query($sql, __FILE__, __LINE__);
$result = Database::query($sql, __FILE__, __LINE__);
$last_insert_id = $new_tag_id;
} else {
$sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
@ -2442,7 +2440,7 @@ class UserManager
$last_insert_id = Database::get_last_insert_id();
}*/
} else {
//this is a new tag
//this is a new tag
if ($tag_id == 0) {
//the tag doesn't exist
$sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
@ -2451,11 +2449,11 @@ class UserManager
} else {
//the tag exists we update it
$sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id = $tag_id";
$result = Database::query($sql, __FILE__, __LINE__);
$last_insert_id = $tag_id;
}
$result = Database::query($sql, __FILE__, __LINE__);
$last_insert_id = $tag_id;
}
}
if (!empty($last_insert_id) && ($last_insert_id!=0)) {
//we insert the relationship user-tag
$sql_select ="SELECT tag_id FROM $table_user_tag_values WHERE user_id = $user_id AND tag_id = $last_insert_id ";
@ -2464,53 +2462,53 @@ class UserManager
if (Database::num_rows($result)==0) {
$sql = "INSERT INTO $table_user_tag_values SET user_id = $user_id, tag_id = $last_insert_id";
$result = Database::query($sql, __FILE__, __LINE__);
}
}
}
}
/**
* Deletes an user tag
* @param int user id
* @param int field id
*
*
*/
public function delete_user_tags($user_id, $field_id) {
// database table definition
$table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$tags = UserManager::get_user_tags($user_id, $field_id);
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$tags = UserManager::get_user_tags($user_id, $field_id);
//echo '<pre>';var_dump($tags);
if(is_array($tags) && count($tags)>0) {
foreach ($tags as $key=>$tag) {
if ($tag['count']>'0') {
if ($tag['count']>'0') {
$sql = "UPDATE $table_user_tag SET count = count - 1 WHERE id = $key ";
$result = Database::query($sql, __FILE__, __LINE__);
}
$sql = "DELETE FROM $table_user_tag_values WHERE user_id = $user_id AND tag_id = $key";
$result = Database::query($sql, __FILE__, __LINE__);
}
}
}
}
}
/**
* Process the tag list comes from the UserManager::update_extra_field_value() function
* @param array the tag list that will be added
* @param array the tag list that will be added
* @param int user id
* @param int field id
* @return bool
*/
public function process_tags($tags, $user_id, $field_id) {
public function process_tags($tags, $user_id, $field_id) {
//We loop the tags and add it to the DB
if (is_array($tags)) {
foreach($tags as $tag) {
UserManager::add_tag($tag, $user_id, $field_id);
}
}
} else {
UserManager::add_tag($tags,$user_id, $field_id);
}
return true;
}
/**
* Gives a list of emails from all administrators
* @author cvargas carlos.vargas@dokeos.com
@ -2519,7 +2517,7 @@ class UserManager
public function get_emails_from_all_administrators() {
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
$sql = "SELECT email from $table_user as u, $table_admin as a WHERE u.user_id=a.user_id";
$result = Database::query($sql, __FILE__, __LINE__);
$return = array();
@ -2529,29 +2527,29 @@ class UserManager
}
}
return $return;
}
}
/**
* Searchs an user (tags, firstname, lastname and email )
* @param string the tag
* @param int field id of the tag
* @param int where to start in the query
* @param int number of items
* @param int where to start in the query
* @param int number of items
* @return array
*/
public static function get_all_user_tags($tag, $field_id = 0, $from = 0, $number_of_items = 10) {
// database table definition
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$tag = Database::escape_string($tag);
$field_id = intval($field_id);
$from = intval($from);
$number_of_items = intval($number_of_items);
$where_field = "";
if ($field_id != 0) {
$where_field = " field_id = $field_id AND ";
@ -2559,9 +2557,9 @@ class UserManager
// 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)
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";
$result = Database::query($sql, __FILE__, __LINE__);
$return = array();
if (Database::num_rows($result)> 0) {
@ -2569,7 +2567,7 @@ class UserManager
$return[$row['user_id']] = $row;
}
}
$keyword = $tag;
$sql = "SELECT u.user_id, u.username, firstname, lastname, email, picture_uri FROM $user_table u";
global $_configuration;
@ -2577,10 +2575,10 @@ class UserManager
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
}
if (isset ($keyword)) {
$keyword = Database::escape_string($keyword);
//OR u.official_code LIKE '%".$keyword."%'
//OR u.official_code LIKE '%".$keyword."%'
// OR u.email LIKE '%".$keyword."%'
$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%' OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' )";
}
@ -2588,10 +2586,10 @@ class UserManager
//only active users
if ($keyword_active) {
$sql .= " AND u.active='1'";
}
}
//avoid anonymous
$sql .= " AND u.status <> 6 ";
// adding the filter to see the user's only of the current access_url
if ($_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
$sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
@ -2600,48 +2598,48 @@ class UserManager
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
//$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($res)> 0) {
while ($row = Database::fetch_array($res,'ASSOC')) {
if (!in_array($row['user_id'], $return)) {
while ($row = Database::fetch_array($res,'ASSOC')) {
if (!in_array($row['user_id'], $return)) {
$return[$row['user_id']] = $row;
}
}
}
return $return;
}
/**
* Show the search form
* @param string the value of the search box
*
*
*/
public static function get_search_form($query) {
echo'<form method="GET" action="'.api_get_path(WEB_PATH).'main/social/search.php">
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<div id="search_label">
<div id="search_label">
<b>'.get_lang('Search').'</b > ('.get_lang('UsersGroups').')
<div>
<input type="text" size="30" value="'.Security::remove_XSS($query).'" name="q"/><br />
<input type="text" size="30" value="'.Security::remove_XSS($query).'" name="q"/><br />
<button class="search" type="submit" value="search">'.get_lang('Search').'</button>
</div>
</div>
</td>
</tr>
</table></form>';
}
//deprecated
public static function get_public_users($keyword, $from = 0, $number_of_items= 20, $column=2, $direction='ASC') {
public static function get_public_users($keyword, $from = 0, $number_of_items= 20, $column=2, $direction='ASC') {
$admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
$sql = "SELECT
u.user_id AS col0,
@ -2658,42 +2656,42 @@ class UserManager
u.user_id AS col8 ".
", u.expiration_date AS exp ".
" FROM $user_table u ";
// adding the filter to see the user's only of the current access_url
global $_configuration;
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
}
if (isset ($keyword)) {
$keyword = Database::escape_string($keyword);
//OR u.official_code LIKE '%".$keyword."%'
//OR u.official_code LIKE '%".$keyword."%'
$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
}
$keyword_active = true;
//only active users
if ($keyword_active) {
$sql .= " AND u.active='1'";
}
}
// adding the filter to see the user's only of the current access_url
if ($_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
$sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
}
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = Database::query($sql, __FILE__, __LINE__);
$users = array ();
$t = time();
while ($user = Database::fetch_row($res)) {
@ -2705,13 +2703,13 @@ class UserManager
$user[7] = '-1';
}
}
// forget about the expiration date field
// forget about the expiration date field
$users[] = array($user[0],$user[1],$user[2],$user[3],$user[4],$user[5],$user[6],$user[7],$user[8]);
}
return $users;
}
/**
* Shows the user menu
* Shows the user menu
*/
public static function show_menu(){
echo '<div class="actions">';
@ -2720,10 +2718,10 @@ class UserManager
echo '<a href="/main/messages/outbox.php">'.Display::return_icon('outbox.png').' '. get_lang('Outbox').'</a>';
echo '<span style="float:right; padding-top:7px;">'.
'<a href="/main/auth/profile.php?show=1">'.Display::return_icon('edit.gif').' '.get_lang('Configuration').'</a>';
'</span>';
'</span>';
echo '</div>';
}
/**
* Gives a list of course auto-register (field special_course)
* @return array list of course
@ -2737,19 +2735,19 @@ class UserManager
$tbl_course_field = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$tbl_course_field_value = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
$tbl_user_course_category = Database :: get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
//we filter the courses from the URL
$join_access_url=$where_access_url='';
$join_access_url=$where_access_url='';
global $_configuration;
if ($_configuration['multiple_access_urls']==true) {
$access_url_id = api_get_current_access_url_id();
if($access_url_id!=-1) {
$tbl_url_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tbl_url_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$join_access_url= "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.course_code= course.code";
$where_access_url=" AND access_url_id = $access_url_id ";
}
}
// Filter special courses
$sql_special_course = "SELECT course_code FROM $tbl_course_field_value tcfv INNER JOIN $tbl_course_field tcf ON " .
" tcfv.field_id = tcf.id WHERE tcf.field_variable = 'special_course' AND tcfv.field_value = 1 ";
@ -2762,7 +2760,7 @@ class UserManager
}
$code_special_courses = ' course.code IN ('.join($special_course_list, ',').') ';
}
// variable initialisation
$course_list_sql = '';
$course_list = array();
@ -2774,8 +2772,8 @@ class UserManager
LEFT JOIN ".$tbl_user_course_category." user_course_category
ON course_rel_user.user_course_cat = user_course_category.id
$join_access_url
WHERE $code_special_courses $where_access_url
GROUP BY course.code
WHERE $code_special_courses $where_access_url
GROUP BY course.code
ORDER BY user_course_category.sort,course.title,course_rel_user.sort ASC";
$course_list_sql_result = api_sql_query($course_list_sql, __FILE__, __LINE__);
while ($result_row = Database::fetch_array($course_list_sql_result)) {
@ -2784,7 +2782,7 @@ class UserManager
}
return $course_list;
}
/**
* Allow to register contact to social network
* @param int user friend id
@ -2793,17 +2791,17 @@ class UserManager
*/
public static function relate_users ($friend_id,$my_user_id,$relation_type) {
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_REL_USER);
$friend_id = intval($friend_id);
$my_user_id = intval($my_user_id);
$relation_type = intval($relation_type);
$sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE friend_user_id=' .$friend_id.' AND user_id='.$my_user_id;
$result = Database::query($sql, __FILE__, __LINE__);
$row = Database :: fetch_array($result, 'ASSOC');
$current_date=date('Y-m-d H:i:s');
if ($row['count'] == 0) {
if ($row['count'] == 0) {
$sql_i = 'INSERT INTO ' . $tbl_my_friend . '(friend_user_id,user_id,relation_type,last_edit)values(' . $friend_id . ','.$my_user_id.','.$relation_type.',"'.$current_date.'");';
Database::query($sql_i, __FILE__, __LINE__);
return true;
@ -2814,20 +2812,20 @@ class UserManager
if ($row['count'] == 1) {
//only for the case of a RRHH
if ($row['relation_type'] != $relation_type && $relation_type == USER_RELATION_TYPE_RRHH) {
$sql_i = 'INSERT INTO ' . $tbl_my_friend . '(friend_user_id,user_id,relation_type,last_edit)values(' . $friend_id . ','.$my_user_id.','.$relation_type.',"'.$current_date.'");';
$sql_i = 'INSERT INTO ' . $tbl_my_friend . '(friend_user_id,user_id,relation_type,last_edit)values(' . $friend_id . ','.$my_user_id.','.$relation_type.',"'.$current_date.'");';
} else {
$sql_i = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.$relation_type.' WHERE friend_user_id=' . $friend_id.' AND user_id='.$my_user_id;
}
}
Database::query($sql_i, __FILE__, __LINE__);
return true;
} else {
return false;
}
}
}
}
}
/**
* Deletes a contact
* Deletes a contact
* @param int user friend id
* @param bool true will delete ALL friends relationship from $friend_id
* @author isaac flores paz <isaac.flores@dokeos.com>
@ -2837,23 +2835,23 @@ class UserManager
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_REL_USER);
$tbl_my_message = Database :: get_main_table(TABLE_MAIN_MESSAGE);
$friend_id = intval($friend_id);
if ($real_removed == true) {
if ($real_removed == true) {
//Delete user friend
/*
$sql_delete_relationship1 = 'UPDATE ' . $tbl_my_friend .' SET relation_type='.USER_RELATION_TYPE_DELETED.' WHERE friend_user_id='.$friend_id;
$sql_delete_relationship1 = 'UPDATE ' . $tbl_my_friend .' SET relation_type='.USER_RELATION_TYPE_DELETED.' WHERE friend_user_id='.$friend_id;
$sql_delete_relationship2 = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.USER_RELATION_TYPE_DELETED.' WHERE user_id=' . $friend_id;
Database::query($sql_delete_relationship1, __FILE__, __LINE__);
Database::query($sql_delete_relationship2, __FILE__, __LINE__);*/
$extra_condition = '';
$extra_condition = '';
if ($with_status_condition != '') {
$extra_condition = ' AND relation_type = '.intval($with_status_condition);
}
$sql_delete_relationship1 = 'DELETE FROM ' . $tbl_my_friend .' WHERE friend_user_id='.$friend_id.' '.$extra_condition;
$sql_delete_relationship1 = 'DELETE FROM ' . $tbl_my_friend .' WHERE friend_user_id='.$friend_id.' '.$extra_condition;
$sql_delete_relationship2 = 'DELETE FROM ' . $tbl_my_friend . ' WHERE user_id=' . $friend_id.' '.$extra_condition;
Database::query($sql_delete_relationship1, __FILE__, __LINE__);
Database::query($sql_delete_relationship2, __FILE__, __LINE__);
Database::query($sql_delete_relationship2, __FILE__, __LINE__);
} else {
$user_id = api_get_user_id();
$sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE user_id=' . $user_id . ' AND relation_type <>'.USER_RELATION_TYPE_DELETED.' AND friend_user_id='.$friend_id;
@ -2870,8 +2868,8 @@ class UserManager
Database::query($sql_j, __FILE__, __LINE__);
Database::query($sql_ij, __FILE__, __LINE__);
Database::query($sql_ji, __FILE__, __LINE__);
}
}
}
}
}

@ -280,11 +280,7 @@ if ($form->validate()) {
$picture_uri = '';
if (strlen($picture['name']) > 0) {
if (!is_dir(api_get_path(SYS_CODE_PATH).'upload/users/')) {
if (mkdir(api_get_path(SYS_CODE_PATH).'upload/users/')) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770');
chmod(api_get_path(SYS_CODE_PATH).'upload/users/');
}
mkdir(api_get_path(SYS_CODE_PATH).'upload/users/', api_get_permissions_for_new_directories());
}
$picture_uri = uniqid('').'_'.replace_dangerous_char($picture['name']);
$picture_location = api_get_path(SYS_CODE_PATH).'upload/users/'.$picture_uri;

@ -483,7 +483,7 @@ class aicc extends learnpath {
- parse & change relative html links
- make sure the filenames are secure (filter funny characters or php extensions)
*/
if(is_dir($course_sys_dir.$new_dir) OR @mkdir($course_sys_dir.$new_dir))
if(is_dir($course_sys_dir.$new_dir) OR @mkdir($course_sys_dir.$new_dir, api_get_permissions_for_new_directories()))
{
// PHP method - slower...
if($this->debug>=1){error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir,0);}
@ -532,7 +532,7 @@ class aicc extends learnpath {
if(!empty($mysubdir)){
$mybasedir = $mybasedir.$mysubdir.'/';
if(!is_dir($mybasedir)){
@mkdir($mybasedir);
@mkdir($mybasedir, api_get_permissions_for_new_directories());
if($this->debug==1){error_log('New LP - Dir '.$mybasedir.' doesnt exist. Creating.',0);}
}
}
@ -675,7 +675,7 @@ class aicc extends learnpath {
$result = Database::query($sql, __FILE__, __LINE__);
$row = Database::fetch_array($result);
$LPname = $row['path'];
$list = split('/',$LPname);
$list = split('/',$LPname);
$LPnamesafe = $list[0];
//$zipfoldername = '/tmp';
//$zipfoldername = '../../courses/'.$_course['directory']."/temp/".$LPnamesafe;
@ -687,7 +687,7 @@ class aicc extends learnpath {
//error_log('New LP - cleaning dir '.$zipfoldername,0);
deldir($zipfoldername); //make sure the temp dir is cleared
$res = mkdir($zipfoldername);
mkdir($zipfoldername, api_get_permissions_for_new_directories());
//error_log('New LP - made dir '.$zipfoldername,0);
//create zipfile of given directory
@ -702,7 +702,7 @@ class aicc extends learnpath {
// Delete the temporary zip file and directory in fileManage.lib.php
my_delete($zipfilename);
my_delete($zipfoldername);
return true;
}

@ -575,9 +575,7 @@ class learnpath {
global $_course;
$filepath = api_get_path('SYS_COURSE_PATH') . $_course['path'] . '/document/';
if (!is_dir($filepath . 'audio')) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty ($perm) ? $perm : '0770');
mkdir($filepath . 'audio', $perm);
mkdir($filepath . 'audio', api_get_permissions_for_new_directories());
$audio_id = add_document($_course, '/audio', 'folder', 0, 'audio');
api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id(),null,null,null,null,api_get_session_id());
}
@ -1046,9 +1044,7 @@ class learnpath {
global $_course;
$filepath = api_get_path('SYS_COURSE_PATH') . $_course['path'] . '/document/';
if (!is_dir($filepath . 'audio')) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty ($perm) ? $perm : '0770');
mkdir($filepath . 'audio', $perm);
mkdir($filepath . 'audio', api_get_permissions_for_new_directories());
$audio_id = add_document($_course, '/audio', 'folder', 0, 'audio');
api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id(),null,null,null,null,api_get_session_id());
}
@ -8046,7 +8042,7 @@ class learnpath {
//or do a cleanup befor creating the zipfile
if(!is_dir($temp_zip_dir))
{
mkdir($temp_zip_dir);
mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
}
else
{//cleanup: check the temp dir for old files and delete them
@ -8066,9 +8062,7 @@ class learnpath {
// remove the possible . at the end of the path
$dest_path_to_lp = substr($this->path, -1) == '.' ? substr($this->path, 0, -1) : $this->path;
$dest_path_to_scorm_folder = str_replace('//','/',$temp_zip_dir.'/scorm/'.$dest_path_to_lp);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
mkdir ($dest_path_to_scorm_folder, $perm, true);
mkdir($dest_path_to_scorm_folder, api_get_permissions_for_new_directories(), true);
$zip_files_dist = copyr($current_course_path.'/scorm/'.$this->path, $dest_path_to_scorm_folder, array('imsmanifest'), $zip_files);
}
//Build a dummy imsmanifest structure. Do not add to the zip yet (we still need it)
@ -8818,7 +8812,7 @@ class learnpath {
EOD;
if(!is_dir($archive_path.$temp_dir_short.'/document'))
{
@mkdir($archive_path.$temp_dir_short.'/document');
@mkdir($archive_path.$temp_dir_short.'/document', api_get_permissions_for_new_directories());
}
file_put_contents($archive_path.$temp_dir_short.'/document/non_exportable.html', $file_content);
@ -8870,7 +8864,7 @@ EOD;
if (is_dir($new_path)) {
$path_built = $new_path . '/';
} else {
mkdir($new_path);
mkdir($new_path, api_get_permissions_for_new_directories());
$path_built = $new_path . '/';
}
}

@ -2212,13 +2212,13 @@ function exportpath($learnpath_id)
$fromdir = '../scorm/export/'; //this dir contains some standard files
deldir($expdir); //make sure the temp dir is cleared
mkdir($expdir);
mkdir($expdir.'/css');
mkdir($expdir.'/data');
mkdir($expdir.'/js');
mkdir($expdir.'/data/images');
mkdir($expdir.'/data/audio');
mkdir($expdir.'/data/videos');
mkdir($expdir, api_get_permissions_for_new_directories());
mkdir($expdir.'/css', api_get_permissions_for_new_directories());
mkdir($expdir.'/data', api_get_permissions_for_new_directories());
mkdir($expdir.'/js', api_get_permissions_for_new_directories());
mkdir($expdir.'/data/images', api_get_permissions_for_new_directories());
mkdir($expdir.'/data/audio', api_get_permissions_for_new_directories());
mkdir($expdir.'/data/videos', api_get_permissions_for_new_directories());
$circle1 = array (//this array contains the types of elements we want to export
'Chapter', 'Agenda', 'Ad_Valvas', 'Course_description', 'Document', 'Introduction_text', 'Link _self', 'Link _blank', 'Forum', 'Thread', 'Post', 'Exercise', 'HotPotatoes', 'Assignments', 'Dropbox', 'Users', 'Groups');
@ -2647,7 +2647,7 @@ function CopyNCreate($source, $dest)
{
$dir = $dir.$tdest[$i]."/";
if (!is_dir($dir))
if (!mkdir($dir))
if (!mkdir($dir, api_get_permissions_for_new_directories()))
return false;
}
@ -2682,8 +2682,8 @@ function rcopy($source, $dest)
if (!is_dir($dest))
{
$res = @ mkdir($dest);
if ($res === true)
$res = @mkdir($dest, api_get_permissions_for_new_directories());
if ($res !== false)
{
return true;
}
@ -2692,7 +2692,7 @@ function rcopy($source, $dest)
//remove latest part of path and try creating that
if (rcopy(substr($source, 0, strrpos($source, '/')), substr($dest, 0, strrpos($dest, '/'))))
{
return @ mkdir($dest);
return @mkdir($dest, api_get_permissions_for_new_directories());
}
else
{

@ -229,9 +229,7 @@ if (isset($_POST['save_audio']))
$filepath = api_get_path('SYS_COURSE_PATH').$_course['path'].'/document/';
if(!is_dir($filepath.'audio'))
{
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
mkdir($filepath.'audio',$perm);
mkdir($filepath.'audio', api_get_permissions_for_new_directories());
$audio_id=add_document($_course,'/audio','folder',0,'audio');
api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id(),null,null,null,null,api_get_session_id());
}

@ -136,9 +136,7 @@ abstract class OpenofficeDocument extends learnpath {
break;
}
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:0770);
chmod ($this->base_work_dir.$this->created_dir,$perm);
chmod ($this->base_work_dir.$this->created_dir, api_get_permissions_for_new_directories());
return $this->first_item;
}

@ -17,7 +17,10 @@ class scormItem extends learnpathItem{
var $sub_items = array();
var $metadata;
//var $prerequisites = ''; - defined in learnpathItem.class.php
var $max_time_allowed = ''; //should be something like HHHH:MM:SS.SS
// Modified by Ivan Tcholakov, 06-FEB-2000.
//var $max_time_allowed = ''; //should be something like HHHH:MM:SS.SS
var $max_time_allowed = '00:00:00';
//
var $timelimitaction = '';
var $datafromlms = '';
var $mastery_score = '';

@ -249,7 +249,7 @@ if($is_allowedToEdit) // TEACHER ONLY
}
else
{
if(mkdir($baseWorkDir.$newDirPath.$openDir."/".$newDirName, 0700)){
if(mkdir($baseWorkDir.$newDirPath.$openDir."/".$newDirName, api_get_permissions_for_new_directories())){
FileManager::set_default_settings($newDirPath.$openDir, $newDirName, "folder", $tbl_document);
// RH: was: set_default_settings($newDirPath.$openDir,$newDirName,"folder");
$dialogBox = get_lang('DirCr');
@ -356,7 +356,7 @@ if($is_allowedToEdit) // TEACHER ONLY
}
else
{
if(mkdir($baseWorkDir.$newDirPath."/".$newDirName, 0700))
if(mkdir($baseWorkDir.$newDirPath."/".$newDirName, api_get_permissions_for_new_directories()))
FileManager::set_default_settings($newDirPath, $newDirName, "folder", $tbl_document);
// RH: was: set_default_settings($newDirPath,$newDirName,"folder");
$dialogBox = get_lang('DirCr');
@ -385,7 +385,7 @@ if($is_allowedToEdit) // TEACHER ONLY
$visibilityPath = $make_directory_visible.$make_directory_invisible;
// At least one of these variables are empty. So it's okay to proceed this way
/* Check if there is yet a record for this file in the DB */
$result = mysql_query ("SELECT * FROM $tbl_document WHERE path LIKE '".$visibilityPath."'");
$result = Database::query ("SELECT * FROM $tbl_document WHERE path LIKE '".$visibilityPath."'", __FILE__, __LINE__);
while($row = Database::fetch_array($result, 'ASSOC'))
{
$attribute['path' ] = $row['path' ];

@ -79,8 +79,7 @@ if(!is_dir($onlinePath))
@unlink($onlinePath);
}
@mkdir($onlinePath,0777);
@chmod($onlinePath,0777);
@mkdir($onlinePath, api_get_permissions_for_new_directories());
}
if($isMaster && $init)

@ -75,8 +75,7 @@ if(!is_dir($onlinePath))
@unlink($onlinePath);
}
@mkdir($onlinePath,0777);
@chmod($onlinePath,0777);
@mkdir($onlinePath, api_get_permissions_for_new_directories());
}
$chat_size=0;

@ -28,7 +28,7 @@ $temp_zip_dir = $sys_course_path.$_course['path']."/temp";
//or do a cleanup befor creating the zipfile
if (!is_dir($temp_zip_dir)) {
mkdir($temp_zip_dir);
mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
} else {
//cleanup: check the temp dir for old files and delete them
$handle=opendir($temp_zip_dir);

@ -1011,8 +1011,7 @@ function is_subdir_of($subdir,$basedir)
* @author Yannick Warnier <ywarnier@beeznest.org> Adaptation for work tool
* @param string Base work dir (.../work)
* @param string $desiredDirName complete path of the desired name
* @return string actual directory name if it succeeds,
* boolean false otherwise
* @return string actual directory name if it succeeds, boolean false otherwise
*/
function create_unexisting_work_directory($base_work_dir,$desired_dir_name)
{
@ -1021,14 +1020,10 @@ function create_unexisting_work_directory($base_work_dir,$desired_dir_name)
while ( file_exists($base_work_dir.$desired_dir_name.$nb) ) {
$nb += 1;
}
//echo "creating ".$base_work_dir.$desired_dir_name.$nb."#...";
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
if ( @mkdir($base_work_dir.$desired_dir_name.$nb, $perm)) {
chmod($base_work_dir.$desired_dir_name.$nb, $perm);
if (@mkdir($base_work_dir.$desired_dir_name.$nb, api_get_permissions_for_new_directories())) {
return $desired_dir_name.$nb;
} else {
return false;
return false;
}
}

@ -5,9 +5,9 @@ require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
class TestSubLanguageManager extends UnitTestCase {
public $clean = array();
/**
* Testing who get all data of dokeos folder
* Testing who get all data of dokeos folder
* @param String to url path folder
* @param bool true if we only want the subname
* @return Array All file of dokeos folder
@ -20,8 +20,8 @@ class TestSubLanguageManager extends UnitTestCase {
}
/**
*
*
*
*
*/
public function testget_all_information_of_sub_language(){
$parent_id = 13;
@ -30,12 +30,12 @@ class TestSubLanguageManager extends UnitTestCase {
$this->assertFalse($res);
$this->assertTrue(is_array($res));
// var_dump($res);
}
/**
*
*
/**
*
*
*/
public function testget_all_information_of_language(){
$parent_id = 11;
@ -43,12 +43,12 @@ class TestSubLanguageManager extends UnitTestCase {
$this->assertTrue($res);
$this->assertTrue(is_array($res));
// var_dump($res);
}
/**
*
*
*
*
*/
public function testget_all_language_variable_in_file(){
$dokeos_path_folder = api_get_path(SYS_LANG_PATH);
@ -57,11 +57,11 @@ class TestSubLanguageManager extends UnitTestCase {
$this->assertTrue(is_array($res));
$this->assertTrue($res);
}
/**
*
*
*/
*
*
*/
public function testadd_file_in_language_directory(){
$dirname = api_get_path(SYS_LANG_PATH);
$perm_dir = substr(sprintf('%o', fileperms($dirname)), -4);
@ -73,11 +73,11 @@ class TestSubLanguageManager extends UnitTestCase {
$res = SubLanguageManager::add_file_in_language_directory($dokeos_path_file);
unlink($dokeos_path_file);
$this->assertNull($res);
$this->assertTrue(is_null($res));
}
$this->assertTrue(is_null($res));
}
//var_dump($res);
}
public function testwrite_data_in_file(){
$dirname = api_get_path(SYS_LANG_PATH);
$perm_dir = substr(sprintf('%o', fileperms($dirname)), -4);
@ -91,16 +91,16 @@ class TestSubLanguageManager extends UnitTestCase {
$variable_sub_language='test';
$res = SubLanguageManager::write_data_in_file($path_file,$new_sub_language,$variable_sub_language);
$this->assertTrue(is_null($res));
$this->assertNull($res);
$this->assertNull($res);
}
//var_dump($res);
$this->assertFalse($res);
$this->assertTrue(is_null($res));
}
/**
* Add directory for sub-language
* @param String The sub-language path directory ( /var/www/my_dokeos/main/lang/spanish_corporate )
@ -114,14 +114,14 @@ class TestSubLanguageManager extends UnitTestCase {
} else {
$this->assertFalse($path_sub_language);
}
}
/**
* Delete sub language of database
* @param Integer id's.
* @return null
*/
*/
public function Testremoved_sub_language() {
$parent_id = '';
$sub_language_id = 1;
@ -151,11 +151,11 @@ class TestSubLanguageManager extends UnitTestCase {
$language_id = 13;
$res = SubLanguageManager :: get_name_of_language_by_id($language_id);
$this->assertTrue(is_string($res));
// var_dump($res);
// var_dump($res);
}
/**
* Verified if language is an sub-language
* Verified if language is an sub-language
* @param Integer
* @return Boolean
*/
@ -167,7 +167,7 @@ class TestSubLanguageManager extends UnitTestCase {
}
/**
*
*
*/
public function Testcheck_if_language_is_father() {
$language_id = 12;
@ -175,9 +175,9 @@ class TestSubLanguageManager extends UnitTestCase {
$this->assertTrue(is_bool($res));
// var_dump($res);
}
/**
*
*
*/
public function Testmake_unavailable_language() {
$language_id = 15;
@ -186,20 +186,20 @@ class TestSubLanguageManager extends UnitTestCase {
$this->assertTrue(is_null($res));
// var_dump($res);
}
/**
*
*
*/
public function Testmake_available_language() {
$language_id= 11;
$res = SubLanguageManager :: make_available_language ($language_id);
$this->assertNull($res);
$this->assertTrue(is_null($res));
// var_dump($res);
// var_dump($res);
}
/**
*
*
*
*
*/
public function Testset_platform_language(){
$language_id = '';
@ -209,37 +209,38 @@ class TestSubLanguageManager extends UnitTestCase {
// var_dump($res);
}
/**
*
*
*
*
*/
public function Testremove_directory_of_sub_language(){
// create a directory of sub language
$path_sub_language = api_get_path(SYS_LANG_PATH).'test';
$path_sub_language = api_get_path(SYS_LANG_PATH).'test';
//$path_sub_language = '/var/www/prueba123';
$res = SubLanguageManager :: add_directory_of_sub_language($path_sub_language, 0777);
//$res = SubLanguageManager :: add_directory_of_sub_language($path_sub_language, 0777);
$res = SubLanguageManager :: add_directory_of_sub_language($path_sub_language, api_get_permissions_for_new_directories());
// remove a directory of sub language
if (file_exists($path_sub_language)) {
rmdir($path_sub_language);
rmdir($path_sub_language);
}
$this->assertTrue(is_bool($res));
// var_dump($res);
}
/*
public function TestDeleteCourse(){
$code = 'COURSEX';
$res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive';
/*
public function TestDeleteCourse(){
$code = 'COURSEX';
$res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (strpos($file,$code)!==false) {
if (is_dir($path.'/'.$file)) {
rmdirr($path.'/'.$file);
}
}
while (false !== ($file = readdir($handle))) {
if (strpos($file,$code)!==false) {
if (is_dir($path.'/'.$file)) {
rmdirr($path.'/'.$file);
}
}
}
closedir($handle);
}
}
*/
*/
}
?>

@ -8,7 +8,7 @@ class TestAddCourse extends UnitTestCase {
function TestAddCourse() {
$this->UnitTestCase('Courses creation tests');
}
function TestCreateCourse(){
global $_configuration;
@ -27,9 +27,9 @@ class TestAddCourse extends UnitTestCase {
$course_datos['course_language'],$course_datos['course_admin_id'],
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']);
$this->assertTrue(is_bool($res));
}
function testRegisterCourse() {
global $_configuration;
$course = array(
@ -49,12 +49,12 @@ class TestAddCourse extends UnitTestCase {
$course['course_language'],$course['uidCreator'],
null,null
);
$this->assertTrue($res === 0);
$res = CourseManager::delete_course($course['courseSysCode']);
}
function TestGenerateCourseCode(){
global $charset;
$course_title = 'testcourse';
@ -69,21 +69,21 @@ class TestAddCourse extends UnitTestCase {
$res = define_course_keys(generate_course_code($wantedCode), null, null, null,null, null);
$this->assertTrue($res);
}
/* // 26 excepciones
function TestPrepareCourseRepository(){
umask(0);
function TestPrepareCourseRepository(){
//umask(0); // This function is not thread-safe.
$perm = '0777';
$courseRepository = 'C16';
$courseId = 'COD16';
$res = prepare_course_repository($courseRepository, $courseId);
$res1 = CourseManager::delete_course('C16');
$this->assertTrue($res===0);
}
}
// Problemas con este archivo - falta analizar esta función
function TestUpdateDbCourse(){
global $_configuration;
@ -136,9 +136,9 @@ class TestAddCourse extends UnitTestCase {
$res = fill_Db_course($courseDbName, $courseRepository, $language,array());
$this->assertTrue($res === 0);
}
function TestString2Binary(){
$variable = true;
$res = string2binary($variable);
@ -151,8 +151,8 @@ class TestAddCourse extends UnitTestCase {
$res = checkArchive($pathToArchive);
$this->assertTrue($res === TRUE);
}
/* // 1 excepcion de permisos
function TestReadPropertiesInArchive(){
ob_start();
@ -163,7 +163,7 @@ class TestAddCourse extends UnitTestCase {
$res = readPropertiesInArchive($archive, $isCompressed = TRUE);
if(is_array($res)){
$this->assertTrue(is_array($res));
}else{
}else{
$this->assertNull($res);
}
ob_end_clean();
@ -171,17 +171,17 @@ class TestAddCourse extends UnitTestCase {
}
*/
public function TestDeleteCourse(){
$code = 'testcourse';
$res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive';
public function TestDeleteCourse(){
$code = 'testcourse';
$res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (strpos($file,$code)!==false) {
if (is_dir($path.'/'.$file)) {
rmdirr($path.'/'.$file);
}
}
while (false !== ($file = readdir($handle))) {
if (strpos($file,$code)!==false) {
if (is_dir($path.'/'.$file)) {
rmdirr($path.'/'.$file);
}
}
}
closedir($handle);
}

Loading…
Cancel
Save