Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

1.10.x
Yannick Warnier 9 years ago
commit aae6b14afa
  1. 23
      app/Resources/public/css/base.css
  2. 4
      main/admin/careers.php
  3. 2
      main/admin/course_add.php
  4. 42
      main/admin/course_edit.php
  5. 8
      main/admin/course_list.php
  6. 151
      main/document/upload.php
  7. 23
      main/dropbox/dropbox_functions.inc.php
  8. 129
      main/dropbox/dropbox_init.inc.php
  9. 89
      main/forum/forumfunction.inc.php
  10. 2
      main/gradebook/lib/fe/gradebooktable.class.php
  11. 14
      main/inc/ajax/forum.ajax.php
  12. 7
      main/inc/lib/extra_field.lib.php
  13. 42
      main/inc/lib/extra_field_value.lib.php
  14. 190
      main/inc/lib/formvalidator/FormValidator.class.php
  15. 8
      main/inc/lib/webservices/MessagesWebService.class.php
  16. 123
      main/work/upload.php
  17. 12
      plugin/buycourses/src/paypalfunctions.php

@ -5936,3 +5936,26 @@ a.sessionView {
.elfinder-cwd-filename {
color: black !important;
}
#dropzone {
position: relative;
overflow: hidden;
direction: ltr;
cursor: pointer;
text-align: center;
color: #333;
font-weight: bold;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
width: auto;
margin-left: auto;
margin-right: auto;
height: auto;
line-height: 50px;
background-color: #D4E6F0;
border: 2px dashed #bbbbbb;
font-size: 120%;
margin-bottom: 0;
}

@ -107,7 +107,7 @@ switch ($action) {
$_SESSION['notebook_view'] = 'creation_date';
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']);
$form = $career->return_form($url, 'add');
$form = $career->returnForm($url, 'add');
// The validation or display
if ($form->validate()) {
@ -132,7 +132,7 @@ switch ($action) {
case 'edit':
// Action handling: Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$form = $career->return_form($url, 'edit');
$form = $career->returnForm($url, 'edit');
// The validation or display
if ($form->validate()) {

@ -181,7 +181,7 @@ if ($form->validate()) {
}
// Display the form.
$content = $form->return_form();
$content = $form->returnForm();
$tpl = new Template($tool_name);
$tpl->assign('content', $content);

@ -163,7 +163,9 @@ if (!empty($coursesInSession)) {
'advmultiselect',
$groupName,
Display::url(
$session['name'], $sessionUrl, array('target' => '_blank')
$session['name'],
$sessionUrl,
array('target' => '_blank')
) . ' - ' . get_lang('Coaches'),
$allTeachers
);
@ -184,7 +186,6 @@ $categorySelect = $form->addElement(
if (!empty($courseInfo['categoryCode'])) {
$data = getCategory($courseInfo['categoryCode']);
$categorySelect->addOption($data['name'], $data['code']);
}
@ -221,37 +222,9 @@ $form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get
$form->addRule('disk_quota', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
$specialCourseField = new ExtraField('course');
$specialCourseFieldInfo = $specialCourseField->get_handler_field_info_by_field_variable('special_course');
if (!empty($specialCourseFieldInfo)) {
$specialCourseValue = new ExtraFieldValue('course');
$specialCourseValueInfo = $specialCourseValue->get_values_by_handler_and_field_variable(
$course_code,
'special_course'
);
$specialCourseAttributes = array();
if (!empty($specialCourseValueInfo) && $specialCourseValueInfo['value'] == 1) {
$specialCourseAttributes['checked'] = '';
}
$form->addElement(
'checkbox',
'extra_special_course',
array(
null,
get_lang('AllUsersAreAutomaticallyRegistered')
),
get_lang('SpecialCourse'),
$specialCourseAttributes
);
}
//Extra fields
// Extra fields
$extra_field = new ExtraField('course');
$extra = $extra_field->addElements($form, $courseId, ['special_course']);
$extra = $extra_field->addElements($form, $courseId);
$htmlHeadXtra[] = '
<script>
@ -315,10 +288,9 @@ if ($form->validate()) {
$warn = substr($warn, 0, -1);
}
$teachers = $course['course_teachers'];
$teachers = isset($course['course_teachers']) ? $course['course_teachers'] : '';
$title = $course['title'];
$category_code = $course['category_code'];
$category_code = isset($course['category_code']) ? $course['category_code'] : '';
$department_name = $course['department_name'];
$department_url = $course['department_url'];
$course_language = $course['course_language'];

@ -340,7 +340,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$defaults['keyword_subscribe'] = '%';
$defaults['keyword_unsubscribe'] = '%';
$form->setDefaults($defaults);
$content .= $form->return_form();
$content .= $form->returnForm();
} else {
$interbreadcrumb[] = array ('url' => 'index.php', "name" => get_lang('PlatformAdmin'));
$tool_name = get_lang('CourseList');
@ -386,7 +386,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$sessionInfo = SessionManager::fetch($sessionId);
$sessionSelect->addOption($sessionInfo['name'], $sessionInfo['id'], ['selected' => 'selected']);
}
$courseListUrl = api_get_self();
$actions .= '<div class="row">';
$actions .= '<div class="col-md-2">';
@ -396,10 +396,10 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
}
$actions .= '</div>';
$actions .= '<div class="col-md-4">';
$actions .= $form->return_form();
$actions .= $form->returnForm();
$actions .= '</div>';
$actions .= '<div class="col-md-4">';
$actions .= $sessionFilter->return_form();
$actions .= $sessionFilter->returnForm();
$actions .= '</div>';
$actions .= '<div class="col-md-2">';
$actions .= '<div class="pull-right">';

@ -80,8 +80,6 @@ if (empty($document_data)) {
}
$group_properties = array();
$url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?'.api_get_cidreq().'&a=upload_file&curdirpath='.$path;
$htmlHeadXtra[] = '<script>
function check_unzip() {
@ -101,108 +99,6 @@ function setFocus(){
}
</script>';
$htmlHeadXtra[] = "
<script>
$(function () {
'use strict';
var url = '".$url."';
var uploadButton = $('<button/>')
.addClass('btn btn-primary')
.prop('disabled', true)
.text('".get_lang('Loading')."')
.on('click', function () {
var \$this = $(this),
data = \$this.data();
\$this
.off('click')
.text('".get_lang('Cancel')."')
.on('click', function () {
\$this.remove();
data.abort();
});
data.submit().always(function () {
\$this.remove();
});
});
$('#file_upload').fileupload({
url: url,
dataType: 'json',
autoUpload: false,
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true
}).on('fileuploadadd', function (e, data) {
data.context = $('<div/>').appendTo('#files');
$.each(data.files, function (index, file) {
var node = $('<p/>').append($('<span/>').text(file.name));
if (!index) {
node
.append('<br>')
.append(uploadButton.clone(true).data(data));
}
node.appendTo(data.context);
});
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
if (file.preview) {
node
.prepend('<br>')
.prepend(file.preview);
}
if (file.error) {
node
.append('<br>')
.append($('<span class=\"text-danger\"/>').text(file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button')
.text('Upload')
.prop('disabled', !!data.files.error);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}).on('fileuploaddone', function (e, data) {
$.each(data.result.files, function (index, file) {
if (file.url) {
var link = $('<a>')
.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index]).wrap(link);
} else if (file.error) {
var error = $('<span class=\"text-danger\"/>').text(file.error);
$(data.context.children()[index])
.append('<br>')
.append(error);
}
});
}).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index) {
var error = $('<span class=\"text-danger\"/>').text('File upload failed.');
$(data.context.children()[index])
.append('<br>')
.append(error);
});
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>";
// This needs cleaning!
if (!empty($groupId)) {
@ -213,7 +109,7 @@ if (!empty($groupId)) {
// Only courseadmin or group members allowed
if ($is_allowed_to_edit || GroupManager::is_user_in_group(api_get_user_id(), $groupId)) {
$interbreadcrumb[] = array(
'url' => '../group/group_space.php?'.api_get_cidreq(),
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace'),
);
} else {
@ -284,7 +180,6 @@ $this_section = SECTION_COURSES;
Display::display_header($nameTools, 'Doc');
/* Here we do all the work */
$unzip = isset($_POST['unzip']) ? $_POST['unzip'] : null;
$index = isset($_POST['index_document']) ? $_POST['index_document'] : null;
// User has submitted a file
@ -307,14 +202,13 @@ if (!empty($_FILES)) {
// Link back to the documents overview
if ($is_certificate_mode) {
$actions = '<a href="document.php?id='.$document_id.'&selectcat=' . $selectcat.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
$actions = '<a href="document.php?id='.$document_id.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
}
// Link to create a folder
echo $toolbar = Display::toolbarAction('toolbar-upload', array( 0 => $actions), 1);
// Form to select directory
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
@ -399,33 +293,16 @@ $form->setDefaults($defaults);
$simple_form = $form->returnForm();
$multiple_form = '<div class="description-upload">'.get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField').'</div>';
$multiple_form .= '
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>'.get_lang('AddFiles').'</span>
<!-- The file input field used as target for the file upload widget -->
<input id="file_upload" type="file" name="files[]" multiple>
</span>
<br />
<br />
<!-- The global progress bar -->
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<div id="files" class="files"></div>
';
$nav_info = api_get_navigator();
if ($nav_info ['name'] == 'Internet Explorer') {
echo $simple_form;
} else {
$headers = array(
get_lang('Upload'),
get_lang('Upload').' ('.get_lang('Simple').')',
);
echo Display::tabs($headers, array($multiple_form, $simple_form), 'tabs');
}
$url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?'.api_get_cidreq().'&a=upload_file&curdirpath='.$path;
$multipleForm = new FormValidator('post');
$multipleForm->addMultipleUpload($url);
$headers = array(
get_lang('Upload'),
get_lang('Upload').' ('.get_lang('Simple').')',
);
echo Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs');
Display::display_footer();

@ -719,25 +719,10 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
)
);
$multipleForm->addHtml('
<div id="multiple_form" style="display:none">
<div class="description-upload">'.get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField').'</div>
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>'.get_lang('AddFiles').'</span>
<!-- The file input field used as target for the file upload widget -->
<input id="input_fileupload" type="file" name="files[]" multiple>
</span>
<br />
<br />
<!-- The global progress bar -->
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<div id="files" class="files"></div>
</div>
');
$url = api_get_path(WEB_AJAX_PATH).'dropbox.ajax.php?'.api_get_cidreq().'&a=upload_file&id=';
$multipleForm->addHtml('<div id="multiple_form" style="display:none">');
$multipleForm->addMultipleUpload($url);
$multipleForm->addHtml('</div>');
echo Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs');
}

@ -287,133 +287,20 @@ Session::write('javascript', $javascript);
$htmlHeadXtra[] = '<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">';
$checked_files = false;
if (!$view || $view == 'received') {
$part = 'received';
} elseif ($view = 'sent') {
$part = 'sent';
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
$url = api_get_path(WEB_AJAX_PATH).'dropbox.ajax.php?'.api_get_cidreq().'&a=upload_file&id=';
$htmlHeadXtra[] = "<script>
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
$htmlHeadXtra[] = "<script>
$(function () {
'use strict';
var url = '".$url."';
var uploadButton = $('<button/>')
.addClass('btn btn-primary')
.prop('disabled', true)
.text('".get_lang('Loading')."')
.on('click', function () {
var \$this = $(this),
data = \$this.data();
\$this
.off('click')
.text('".get_lang('Cancel')."')
.on('click', function () {
\$this.remove();
data.abort();
});
data.submit().always(function () {
\$this.remove();
});
});
$('#recipient_form').on('change', function() {
$('#multiple_form').show();
});
$('#fileupload').bind('fileuploaddone', function (e, data) {
console.log('fileuploaddone');
event.preventDefault();
return false;
});
$('#fileupload').submit(function() {
return false;
});
$('#fileupload').fileupload({
url: url,
dataType: 'json',
autoUpload: false,
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true,
complete: function (e, data) {
}
}).on('fileuploadadd', function (e, data) {
data.context = $('<div/>').appendTo('#files');
$.each(data.files, function (index, file) {
var node = $('<p/>').append($('<span/>').text(file.name));
if (!index) {
node
.append('<br>')
.append(uploadButton.clone(true).data(data));
}
node.appendTo(data.context);
});
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
if (file.preview) {
node
.prepend('<br>')
.prepend(file.preview);
}
if (file.error) {
node
.append('<br>')
.append($('<span class=\"text-danger\"/>').text(file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button')
.text('Upload')
.prop('disabled', !!data.files.error);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}).on('fileuploaddone', function (e, data) {
$.each(data.result.files, function (index, file) {
if (file.url) {
var link = $('<a>')
//.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index]).wrap(link);
} else if (file.error) {
var error = $('<span class=\"text-danger\"/>').text(file.error);
$(data.context.children()[index])
.append('<br>')
.append(error);
}
});
}).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index) {
var error = $('<span class=\"text-danger\"/>').text('File upload failed.');
$(data.context.children()[index])
.append('<br>')
.append(error);
});
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>";
$checked_files = false;
if (!$view || $view == 'received') {
$part = 'received';
} elseif ($view = 'sent') {
$part = 'sent';
} else {
header('location: index.php?view='.$view.'&error=Error');

@ -48,33 +48,7 @@ function setFocus() {
}
</script>';
// The next javascript script is to manage ajax upload file
$htmlHeadXtra[] = "<script>
$(function () {
setFocus();
$('#file_upload').fileUploadUI({
uploadTable: $('.files'),
downloadTable: $('.files'),
buildUploadRow: function (files, index) {
$('.files').closest('.control-group').show();
return $('<tr><td>' + files[index].name + '<\/td>' +
'<td class=\"file_upload_progress\"><div><\/div><\/td>' +
'<td class=\"file_upload_cancel\">' +
'<button class=\"ui-state-default ui-corner-all\" title=\"".get_lang('Cancel')."\">' + '<span class=\"ui-icon ui-icon-cancel\">".get_lang('Cancel')."<\/span>' +'<\/button>'+
'<\/td><\/tr>');
},
buildDownloadRow: function (file) {
if (!file.error) {
return $('<tr id=' + file.id + ' ><td>' + file.name + '<\/td><td>' + file.size + '<\/td><td>&nbsp;' + file.result +
' <\/td><td> <input style=\"width:90%;\" type=\"text\" value=\"' + file.comment + '\" name=\"file_comments[]\"> <\/td><td>' +
file.delete + '<\/td>' +
'<input type=\"hidden\" value=\"' + file.id +'\" name=\"file_ids[]\">' + '<\/tr>');
} else {
alert('" . get_lang('UploadError') . "');
}
}
});
});
</script>";
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
// Recover Thread ID, will be used to generate delete attachment URL to do ajax
$threadId = isset($_REQUEST['thread']) ? intval($_REQUEST['thread']) : 0;
@ -82,30 +56,30 @@ $forumId = isset($_REQUEST['forum']) ? intval($_REQUEST['forum']) : 0;
// The next javascript script is to delete file by ajax
$htmlHeadXtra[] = '<script>
$(function () {
$(document).on("click", ".deleteLink", function(e) {
e.preventDefault();
e.stopPropagation();
var l = $(this);
var id = l.closest("tr").attr("id");
var filename = l.closest("tr").find(".attachFilename").html();
if (confirm("' . get_lang('AreYouSureToDeleteJS') . '", filename)) {
$.ajax({
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId .'&forum='.$forumId .'",
dataType: "json",
success: function(data) {
if (data.error == false) {
l.closest("tr").remove();
if ($(".files td").length < 1) {
$(".files").closest(".control-group").hide();
}
$(function () {
$(document).on("click", ".deleteLink", function(e) {
e.preventDefault();
e.stopPropagation();
var l = $(this);
var id = l.closest("tr").attr("id");
var filename = l.closest("tr").find(".attachFilename").html();
if (confirm("' . get_lang('AreYouSureToDeleteJS') . '", filename)) {
$.ajax({
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId .'&forum='.$forumId .'",
dataType: "json",
success: function(data) {
if (data.error == false) {
l.closest("tr").remove();
if ($(".files td").length < 1) {
$(".files").closest(".control-group").hide();
}
}
})
}
});
}
})
}
});
});
</script>';
/**
@ -5577,7 +5551,9 @@ function editAttachedFile($array, $id, $courseId = null) {
* @param int $forumId Forum ID from where the post are
* @param int $threadId Thread ID where forum post are
* @param int $postId Post ID to identify Post
* @deprecated this function seems to never been used
* @return string The Forum Attachment Ajax Form
*
*/
function getAttachmentAjaxForm($forumId, $threadId, $postId)
{
@ -5591,18 +5567,11 @@ function getAttachmentAjaxForm($forumId, $threadId, $postId)
}
$url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum=' . $forumId . '&thread=' . $threadId . '&postId=' . $postId . '&a=upload_file';
// Form
$formFileUpload = '<div class="form-ajax">
<form id="file_upload" action="'.$url.'" method="POST" enctype="multipart/form-data">
<input type="file" name="user_upload" multiple>
<button type="submit">Upload</button>
<div class="button-load">
'.get_lang('UploadFiles').'
</div>
</form></div>
';
return $formFileUpload;
$multipleForm = new FormValidator('post');
$multipleForm->addMultipleUpload($url);
return $multipleForm->returnForm();
}
/**

@ -809,7 +809,7 @@ class GradebookTable extends SortableTable
$ySize = 400;
$pChart = new pImage($xSize, $ySize, $dataSet);
/* Turn of Antialiasing */
$pChart->Antialias = FALSE;
$pChart->Antialias = false;
/* Add a border to the picture */
$pChart->drawRectangle(0,0,$xSize-10,$ySize-10,array("R"=>0,"G"=>0,"B"=>0));

@ -38,27 +38,25 @@ if (!empty($action)) {
// 3. if anonymous posts are not allowed
// The only exception is the course manager
// They are several pieces for clarity.
if (!api_is_allowed_to_edit(null, true) AND
if (!api_is_allowed_to_edit(null, true) &&
(
($current_forum_category && $current_forum_category['visibility'] == 0) OR
($current_forum_category && $current_forum_category['visibility'] == 0) ||
$current_forum['visibility'] == 0
)
) {
$json['errorMessage'] = '1. the forum category, forum or thread is invisible (visibility==0)';
break;
}
if (!api_is_allowed_to_edit(null, true) AND
if (!api_is_allowed_to_edit(null, true) &&
(
($current_forum_category && $current_forum_category['locked'] <> 0) OR
$current_forum['locked'] <> 0 OR $current_thread['locked'] <> 0
($current_forum_category && $current_forum_category['locked'] <> 0) ||
$current_forum['locked'] <> 0 || $current_thread['locked'] <> 0
)
) {
$json['errorMessage'] = '2. the forum category, forum or thread is locked (locked <>0)';
break;
}
if (api_is_anonymous() AND
$current_forum['allow_anonymous'] == 0
) {
if (api_is_anonymous() && $current_forum['allow_anonymous'] == 0) {
$json['errorMessage'] = '3. if anonymous posts are not allowed';
break;
}

@ -810,7 +810,7 @@ class ExtraField extends Model
if (isset($field_details['options']) && !empty($field_details['options'])) {
foreach ($field_details['options'] as $option_details) {
$options[$option_details['option_value']] = $option_details['display_text'];
$group[] = $form->createElement(
$group[] = $form->createElement(
'checkbox',
'extra_'.$field_details['variable'],
$option_details['option_value'],
@ -824,7 +824,9 @@ class ExtraField extends Model
$checkboxAttributes = array();
if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) {
$checkboxAttributes['checked'] = true;
if (!empty($extraData[$fieldVariable])) {
$checkboxAttributes['checked'] = 1;
}
}
// We assume that is a switch on/off with 1 and 0 as values
@ -837,6 +839,7 @@ class ExtraField extends Model
$checkboxAttributes
);
}
$form->addGroup(
$group,
'extra_'.$field_details['variable'],

@ -80,7 +80,7 @@ class ExtraFieldValue extends Model
foreach ($params as $key => $value) {
$found = strpos($key, '__persist__');
if ($found === FALSE) {
if ($found === false) {
continue;
}
@ -95,17 +95,23 @@ class ExtraFieldValue extends Model
}
$type = $this->getExtraField()->getExtraFieldType();
$extraField = new ExtraField($this->type);
$extraFields = $extraField->get_all(null, 'option_order');
// Parse params.
foreach ($params as $key => $value) {
if (
substr($key, 0, 6) != 'extra_' &&
substr($key, 0, 7) != '_extra_'
) {
//foreach ($params as $key => $value) {
foreach ($extraFields as $fieldDetails) {
if ($fieldDetails['visible'] != 1) {
continue;
}
// An extra field.
$field_variable = substr($key, 6);
$field_variable = $fieldDetails['variable'];
if (isset($params['extra_'.$field_variable])) {
$value = $params['extra_'.$field_variable];
} else {
$value = '';
}
$extraFieldInfo = $this->getExtraField()->get_handler_field_info_by_field_variable($field_variable);
if (!$extraFieldInfo) {
@ -176,7 +182,7 @@ class ExtraFieldValue extends Model
]);
$tag->setCount(count($tagUses) + 1);
$em->persist($tag);
$em->persist($tag);
}
$em->flush();
@ -267,6 +273,24 @@ class ExtraFieldValue extends Model
self::save($new_params);
}
break;
case ExtraField::FIELD_TYPE_CHECKBOX:
$fieldToSave = 0;
if (is_array($value)) {
if (isset($value['extra_'.$field_variable])) {
$fieldToSave = 1;
}
}
$newParams = array(
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $fieldToSave,
'comment' => $comment
);
self::save($newParams);
break;
default:
$newParams = array(

@ -454,7 +454,7 @@ EOT;
* @param array $attributes Additional attributes
* @return HTML_QuickForm_button
*/
public function addButtonNext($label, $name = 'submit',$attributes = array())
public function addButtonNext($label, $name = 'submit', $attributes = array())
{
return $this->addButton($name, $label, 'arrow-right', 'primary', null, null, $attributes);
}
@ -723,8 +723,14 @@ EOT;
*
* @return HTML_QuickForm_element
*/
public function addSelectFromCollection($name, $label, $collection, $attributes = array(), $addNoneOption = false, $textCallable = '')
{
public function addSelectFromCollection(
$name,
$label,
$collection,
$attributes = array(),
$addNoneOption = false,
$textCallable = ''
) {
$options = [];
if ($addNoneOption) {
@ -1102,7 +1108,7 @@ EOT;
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addTextLettersOnly(
@ -1110,8 +1116,7 @@ EOT;
$label,
$required = false,
$attributes = []
)
{
) {
$attributes = array_merge(
$attributes,
[
@ -1149,7 +1154,7 @@ EOT;
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addTextAlphanumeric(
@ -1157,8 +1162,7 @@ EOT;
$label,
$required = false,
$attributes = []
)
{
) {
$attributes = array_merge(
$attributes,
[
@ -1196,7 +1200,7 @@ EOT;
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addTextLettersAndSpaces(
@ -1204,8 +1208,7 @@ EOT;
$label,
$required = false,
$attributes = []
)
{
) {
$attributes = array_merge(
$attributes,
[
@ -1243,7 +1246,7 @@ EOT;
* A trim-filter is attached to the field.
* @param string $name The element name
* @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true)
* @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element
*/
public function addTextAlphanumericAndSpaces(
@ -1251,8 +1254,7 @@ EOT;
$label,
$required = false,
$attributes = []
)
{
) {
$attributes = array_merge(
$attributes,
[
@ -1285,6 +1287,161 @@ EOT;
);
}
/**
* @param string $url
*/
public function addMultipleUpload($url)
{
$inputName = 'input_file_upload';
$this->addMultipleUploadJavascript($url, $inputName);
$this->addHtml('
<div class="description-upload">'.get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField').'</div>
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>'.get_lang('AddFiles').'</span>
<!-- The file input field used as target for the file upload widget -->
<input id="'.$inputName.'" type="file" name="files[]" multiple>
</span>
<br />
<br />
<div id="dropzone">
<div class="button-load">
'.get_lang('UploadFiles').'
</div>
</div>
<br />
<!-- The global progress bar -->
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<div id="files" class="files"></div>
');
}
/**
*
* @param string $url page that will handle the upload
* @param string $inputName
*/
private function addMultipleUploadJavascript($url, $inputName)
{
$this->addHtml("
<script>
$(function () {
'use strict';
$('#".$this->getAttribute('id')."').submit(function(){
return false;
});
$('#dropzone').on('click', function() {
$('#".$inputName."').click();
});
var url = '".$url."';
var uploadButton = $('<button/>')
.addClass('btn btn-primary')
.prop('disabled', true)
.text('".get_lang('Loading')."')
.on('click', function () {
var \$this = $(this),
data = \$this.data();
\$this
.off('click')
.text('".get_lang('Cancel')."')
.on('click', function () {
\$this.remove();
data.abort();
});
data.submit().always(function () {
\$this.remove();
});
});
$('#".$inputName."').fileupload({
url: url,
dataType: 'json',
autoUpload: false,
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true,
dropzone: $('#dropzone')
}).on('fileuploadadd', function (e, data) {
data.context = $('<div/>').appendTo('#files');
$.each(data.files, function (index, file) {
var node = $('<p/>').append($('<span/>').text(file.name));
if (!index) {
node
.append('<br>')
.append(uploadButton.clone(true).data(data));
}
node.appendTo(data.context);
});
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
if (file.preview) {
node
.prepend('<br>')
.prepend(file.preview);
}
if (file.error) {
node
.append('<br>')
.append($('<span class=\"text-danger\"/>').text(file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button')
.text('Upload')
.prop('disabled', !!data.files.error);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}).on('fileuploaddone', function (e, data) {
$.each(data.result.files, function (index, file) {
if (file.url) {
var link = $('<a>')
.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index]).wrap(link);
} else if (file.error) {
var error = $('<span class=\"text-danger\"/>').text(file.error);
$(data.context.children()[index])
.append('<br>')
.append(error);
}
});
}).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index) {
var error = $('<span class=\"text-danger\"/>').text('".get_lang('Failed')."');
$(data.context.children()[index])
.append('<br>')
.append(error);
});
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
$('.fileinput-button').hide();
});
</script>"
);
}
}
/**
@ -1328,5 +1485,6 @@ function html_filter_student_fullpage($html)
function mobile_phone_number_filter($mobilePhoneNumber)
{
$mobilePhoneNumber = str_replace(array('+', '(', ')'), '', $mobilePhoneNumber);
return ltrim($mobilePhoneNumber,'0');
return ltrim($mobilePhoneNumber, '0');
}

@ -9,6 +9,10 @@
class MessagesWebService extends WebService
{
const SERVICE_NAME = 'MsgREST';
/**
* @var string EXTRA_FIELD_GCM_REGISTRATION Variable name of the user extra field.
* Necessary for register the registration token from the Google Cloud Messaging
*/
const EXTRA_FIELD_GCM_REGISTRATION = 'gcm_registration_id';
/**
@ -144,9 +148,9 @@ class MessagesWebService extends WebService
}
/**
* Register the GCM Registration ID for a user
* Register the Registration ID (token) obtained from Google Cloud Messaging for a user
* @param Chamilo\UserBundle\Entity\User $user The user
* @param string $registrationId The token registration id from GCM
* @param string $registrationId The token registration id from Google Cloud Messaging
* @return int The id after insert or the number of affected rows after update. Otherwhise return false
*/
public static function setGcmRegistrationId(Chamilo\UserBundle\Entity\User $user, $registrationId)

@ -120,108 +120,6 @@ $url = api_get_path(WEB_AJAX_PATH).'work.ajax.php?'.api_get_cidreq().'&a=upload_
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
$htmlHeadXtra[] = to_javascript_work();
$htmlHeadXtra[] = "<script>
$(function () {
'use strict';
var url = '".$url."';
var uploadButton = $('<button/>')
.addClass('btn btn-primary')
.prop('disabled', true)
.text('".get_lang('Loading')."')
.on('click', function () {
var \$this = $(this),
data = \$this.data();
\$this
.off('click')
.text('".get_lang('Cancel')."')
.on('click', function () {
\$this.remove();
data.abort();
});
data.submit().always(function () {
\$this.remove();
});
});
$('#file_upload').fileupload({
url: url,
dataType: 'json',
autoUpload: false,
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true
}).on('fileuploadadd', function (e, data) {
data.context = $('<div/>').appendTo('#files');
$.each(data.files, function (index, file) {
var node = $('<p/>').append($('<span/>').text(file.name));
if (!index) {
node
.append('<br>')
.append(uploadButton.clone(true).data(data));
}
node.appendTo(data.context);
});
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
if (file.preview) {
node
.prepend('<br>')
.prepend(file.preview);
}
if (file.error) {
node
.append('<br>')
.append($('<span class=\"text-danger\"/>').text(file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button')
.text('Upload')
.prop('disabled', !!data.files.error);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}).on('fileuploaddone', function (e, data) {
$.each(data.result.files, function (index, file) {
if (file.url) {
var link = $('<a>')
.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index]).wrap(link);
} else if (file.error) {
var error = $('<span class=\"text-danger\"/>').text(file.error);
$(data.context.children()[index])
.append('<br>')
.append(error);
}
});
}).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index) {
var error = $('<span class=\"text-danger\"/>').text('File upload failed.');
$(data.context.children()[index])
.append('<br>')
.append(error);
});
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>";
Display :: display_header(null);
$headers = array(
@ -229,25 +127,10 @@ $headers = array(
get_lang('Upload').' ('.get_lang('Simple').')',
);
$multiple_form = '<div class="description-upload">'.get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField').'</div>';
$multiple_form .= '
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>'.get_lang('AddFiles').'</span>
<!-- The file input field used as target for the file upload widget -->
<input id="file_upload" type="file" name="files[]" multiple>
</span>
<br />
<br />
<!-- The global progress bar -->
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<div id="files" class="files"></div>
';
$multipleForm = new FormValidator('post');
$multipleForm->addMultipleUpload($url);
$tabs = Display::tabs($headers, array($multiple_form, $form->returnForm()), 'tabs');
$tabs = Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs');
if (!empty($work_id)) {
echo $validationStatus['message'];

@ -300,18 +300,18 @@ function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCar
*/
function MassPayment(array $beneficiaries, $currencyCode) {
$nvpstr = "&RECEIVERTYPE=EmailAddress";
$nvpstr .= "&CURRENCYCODE=".$currencyCode;
$index = 0;
foreach ($beneficiaries as $beneficiary) {
$nvpstr .= "&L_EMAIL".$index."=".$beneficiary['paypal_account'];
$nvpstr .= "&L_AMT".$index."=".$beneficiary['commission'];
$index++;
}
$resArray = hash_call("MassPay", $nvpstr);
return $resArray;
@ -337,8 +337,8 @@ function hash_call($methodName, $nvpStr)
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//turning off the server and peer verification(TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);

Loading…
Cancel
Save