Example #1
0
} else {
    $form->addElement('text', 'title', get_lang('Title'), array('id' => 'document_title'));
}
// Show read-only box only in groups
if (!empty($groupId)) {
    $group[] = $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
}
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists');
$current_session_id = api_get_session_id();
$form->add_html_editor('content', '', false, false, $html_editor_config);
// Comment-field
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
// If we are not in the certificates creation, display a folder chooser for the
// new document created
if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'], $dir, $current_session_id)) {
    $folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
    $parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory')));
    // Following two conditions copied from document.inc.php::build_directory_selector()
    $folder_titles = array();
    if (is_array($folders)) {
        $escaped_folders = array();
        foreach ($folders as $key => &$val) {
            //Hide some folders
            if ($val == '/HotPotatoes_files' || $val == '/certificates' || basename($val) == 'css') {
                continue;
            }
            //Admin setting for Hide/Show the folders of all users
            if (api_get_setting('show_users_folders') == 'false' && (strstr($val, '/shared_folder') || strstr($val, 'shared_folder_session_'))) {
                continue;
            }
Example #2
0
if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != 0) {
    $req_gid = '&gidReq=' . $_SESSION['_gid'];
    $interbreadcrumb[] = array("url" => "../group/group_space.php?gidReq=" . $_SESSION['_gid'], "name" => get_lang('GroupSpace'));
    $noPHP_SELF = true;
    $to_group_id = $_SESSION['_gid'];
    $group = GroupManager::get_group_properties($to_group_id);
    $path = explode('/', $dir);
    if ('/' . $path[1] != $group['directory']) {
        api_not_allowed(true);
    }
}
$interbreadcrumb[] = array("url" => "./document.php?curdirpath=" . urlencode($dir) . $req_gid, "name" => get_lang('Documents'));
if (!$is_allowed_in_course) {
    api_not_allowed(true);
}
if (!($is_allowed_to_edit || GroupManager::groupMemberWithUploadRights() || is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir), api_get_session_id()))) {
    api_not_allowed(true);
}
/*	Header */
Event::event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
if (isset($group)) {
    $display_dir = explode('/', $dir);
    unset($display_dir[0]);
    unset($display_dir[1]);
    $display_dir = implode('/', $display_dir);
}
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
    $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
} else {
} else {
    $form->addElement('text', 'title', get_lang('Title'), 'class="span4" id="document_title"');
}
// Show read-only box only in groups
if (!empty($_SESSION['_gid'])) {
    $group[] = $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
}
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists');
$current_session_id = api_get_session_id();
$form->add_html_editor('content', '', false, false, $html_editor_config);
// Comment-field
$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
// If we are not in the certificates creation, display a folder chooser for the
// new document created
if (!$is_certificate_mode && !is_my_shared_folder($userId, $dir, $current_session_id)) {
    $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
    $parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory')));
    // Following two conditions copied from document.inc.php::build_directory_selector()
    $folder_titles = array();
    if (is_array($folders)) {
        $escaped_folders = array();
        foreach ($folders as $key => &$val) {
            //Hide some folders
            if ($val == '/HotPotatoes_files' || $val == '/certificates' || basename($val) == 'css') {
                continue;
            }
            //Admin setting for Hide/Show the folders of all users
            if (api_get_setting('show_users_folders') == 'false' && (strstr($val, '/shared_folder') || strstr($val, 'shared_folder_session_'))) {
                continue;
            }
Example #4
0
 $defaults['formSent'] = 1;
 $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
 // Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
 // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
 $defaults['content'] = str_replace('<!--[', '<!-- [', $content);
 //if ($extension == 'htm' || $extension == 'html')
 // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
 if (($extension == 'htm' || $extension == 'html') && stripos($dir, '/HotPotatoes_files') === false) {
     if (empty($readonly) && $readonly == 0) {
         $_SESSION['showedit'] = 1;
         $form->add_html_editor('content', '', false, false, $html_editor_config);
         //$renderer->setElementTemplate('<div class="row"><div class="label" id="frmModel" style="overflow: visible;"></div><div class="formw">{element}</div></div>', 'content');
         //$form->add_html_editor('content', '', false, true, $html_editor_config);
     }
 }
 if (!$group_document && !is_my_shared_folder(api_get_user_id(), $my_cur_dir_path, $current_session_id)) {
     //$metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Document.'.$document_data['id']).'">'.get_lang('AddMetadata').'</a>';
     // Updated on field
     $last_edit_date = api_get_local_time($last_edit_date);
     $display_date = date_to_str_ago($last_edit_date) . ' <span class="dropbox_date">' . api_format_date($last_edit_date) . '</span>';
     //$form->addElement('label', get_lang('Metadata'), $metadata_link);
     $form->addElement('label', get_lang('UpdatedOn'), $display_date);
 }
 $form->addElement('textarea', 'comment', get_lang('Comment'));
 if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
     $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
     if ($readonly == 1) {
         $checked->setChecked(true);
     }
 }
 if ($is_certificate_mode) {
Example #5
0
 * Responses to AJAX calls for the document upload
 */
$action = $_REQUEST['a'];
switch ($action) {
    case 'upload_file':
        api_protect_course_script(true);
        //User access same as upload.php
        $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
        // This needs cleaning!
        if (api_get_group_id()) {
            if ($is_allowed_to_edit || GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())) {
                // Only courseadmin or group members allowed
            } else {
                exit;
            }
        } elseif ($is_allowed_to_edit || is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())) {
        } else {
            // No course admin and no group member...
            exit;
        }
        if (!empty($_FILES)) {
            $file = $_FILES['file'];
            $result = DocumentManager::upload_document($_FILES, $_POST['curdirpath'], $file['name'], null, 0, 'overwrite', false, false);
            $json = array();
            $json['name'] = Display::url(api_htmlentities($file['name']), api_htmlentities($result['url']), array('target' => '_blank'));
            $json['type'] = api_htmlentities($file['type']);
            $json['size'] = Text::format_file_size($file['size']);
            if (!empty($result) && is_array($result)) {
                $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
            } else {
                $json['result'] = Display::return_icon('exclamation.png', get_lang('Error'));
Example #6
0
if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != 0) {
    $req_gid = '&amp;gidReq=' . $_SESSION['_gid'];
    $interbreadcrumb[] = array("url" => "../group/group_space.php?gidReq=" . $_SESSION['_gid'], "name" => get_lang('GroupSpace'));
    $noPHP_SELF = true;
    $to_group_id = $_SESSION['_gid'];
    $group = GroupManager::get_group_properties($to_group_id);
    $path = explode('/', $dir);
    if ('/' . $path[1] != $group['directory']) {
        api_not_allowed(true);
    }
}
$interbreadcrumb[] = array("url" => "./document.php?id=" . $document_id . $req_gid, "name" => get_lang('Documents'));
if (!$is_allowed_in_course) {
    api_not_allowed(true);
}
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir), api_get_session_id()))) {
    api_not_allowed(true);
}
/*	Header */
event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
if (isset($group)) {
    $display_dir = explode('/', $dir);
    unset($display_dir[0]);
    unset($display_dir[1]);
    $display_dir = implode('/', $display_dir);
}
// Interbreadcrumb for the current directory root path
$counter = 0;
if (isset($document_data['parents'])) {
    foreach ($document_data['parents'] as $document_sub_data) {
Example #7
0
    $interbreadcrumb[] = array("url" => "./document.php?curdirpath=" . urlencode($my_cur_dir_path) . $req_gid, "name" => get_lang('Documents'));
} else {
    $interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
}
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
    $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
} else {
    foreach ($document_data['parents'] as $document_sub_data) {
        if ($document_data['title'] == $document_sub_data['title']) {
            continue;
        }
        $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
    }
}
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || GroupManager::groupMemberWithUploadRights() || is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
if (!$is_allowedToEdit) {
    api_not_allowed(true);
}
event_access_tool(TOOL_DOCUMENT);
Display::display_header($nameTools, 'Doc');
echo '<div class="actions">';
echo '<a href="document.php?id=' . $parent_id . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '<a href="edit_document.php?' . api_get_cidreq() . '&id=' . $document_id . $req_gid . '&origin=editdraw">' . Display::return_icon('edit.png', get_lang('Rename') . '/' . get_lang('Comments'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
if (api_browser_support('svg')) {
    //automatic loading the course language
    $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
    $langsvgedit = api_get_language_isocode();
    $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
    $langsvgedit = file_exists(api_get_path(LIBRARY_PATH) . 'svg-edit/locale/lang.' . $langsvgedit . '.js') ? $langsvgedit : 'en';
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
                         return \'<a href="?action=edit&id=\'+options.rowId+\'">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>' . '&nbsp;<a onclick="javascript:if(!confirm(' . "\\'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)) . "\\'" . ')) return false;"  href="?action=copy&id=\'+options.rowId+\'">' . Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL) . '</a>' . '&nbsp;<a onclick="javascript:if(!confirm(' . "\\'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)) . "\\'" . ')) return false;"  href="?action=delete&id=\'+options.rowId+\'">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>' . '\';
                 }';
$js_content = Display::grid_js('documents', '', $columns, $column_model, $extra_params, $sortable_data, $action_links, true);
$htmlHeadXtra[] = '<script>
$(function() {
    // grid definition see the $career->display() function
    ' . $js_content . '
});
</script>';
require_once 'controller.php';
$controller = new DocumentController();
$tpl = $controller->tpl->get_template('layout/layout_2_col.tpl');
$content = Display::grid_html('documents');
if (!is_null($docs_and_folders)) {
    // Show download zipped folder icon
    global $total_size;
    if (!$is_certificate_mode && $total_size != 0 && (api_get_setting('students_download_folders') == 'true' || api_is_allowed_to_edit() || api_is_platform_admin())) {
        //for student does not show icon into other shared folder, and does not show into main path (root)
        if (is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) && $curdirpath != '/' || api_is_allowed_to_edit() || api_is_platform_admin()) {
            $link = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;action=downloadfolder&amp;id=' . $document_id . '">' . Display::return_icon('save_pack.png', get_lang('Save') . ' (ZIP)', '', ICON_SIZE_MEDIUM) . '</a>';
        }
    }
}
$content .= Display::div($link, array('class' => 'right'));
$controller->tpl->assign('content', $content);
$controller->tpl->display($tpl);
Example #9
0
}
$group_properties = array();
// This needs cleaning!
if (api_get_group_id()) {
    // If the group id is set, check if the user has the right to be here
    // Get group info
    $group_properties = GroupManager::get_group_properties(api_get_group_id());
    if ($is_allowed_to_edit || GroupManager::is_user_in_group($_user['user_id'], api_get_group_id())) {
        // Only courseadmin or group members allowed
        $to_group_id = api_get_group_id();
        $req_gid = '&amp;gidReq=' . api_get_group_id();
        $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq=' . api_get_group_id(), 'name' => get_lang('GroupSpace'));
    } else {
        api_not_allowed(true);
    }
} elseif ($is_allowed_to_edit || is_my_shared_folder(api_get_user_id(), $path, api_get_session_id())) {
    // Admin for "regular" upload, no group documents. And check if is my shared folder
    $to_group_id = 0;
    $req_gid = '';
} else {
    // No course admin and no group member...
    api_not_allowed(true);
}
// Group docs can only be uploaded in the group directory
if ($to_group_id != 0 && $path == '/') {
    $path = $group_properties['directory'];
}
// I'm in the certification module?
$is_certificate_mode = false;
$is_certificate_array = explode('/', $path);
array_shift($is_certificate_array);
Example #10
0
}
if (api_get_group_id()) {
    $query_vars['gidReq'] = api_get_group_id();
}
$query_vars['cidReq'] = api_get_course_id();
$table->set_additional_parameters($query_vars);
$column = 0;
if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($docs_and_folders) > 1) {
    $table->set_header($column++, '', false, array('style' => 'width:12px;'));
}
$table->set_header($column++, get_lang('Type'), true, array('style' => 'width:30px;'));
$table->set_header($column++, get_lang('Name'));
$table->set_header($column++, get_lang('Size'), true, array('style' => 'width:50px;'));
$table->set_header($column++, get_lang('Date'), true, array('style' => 'width:150px;'));
// Admins get an edit column
if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) {
    $table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions'));
}
// Actions on multiple selected documents
// TODO: Currently only delete action -> take only DELETE right into account
if (count($docs_and_folders) > 1) {
    if ($is_allowed_to_edit || $group_member_with_upload_rights) {
        $form_actions = array();
        $form_action['delete'] = get_lang('Delete');
        $portfolio_actions = Portfolio::actions();
        foreach ($portfolio_actions as $action) {
            $form_action[$action->get_name()] = $action->get_title();
        }
        $table->set_form_actions($form_action, 'path');
    }
}
Example #11
0
 // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
 $defaults['content'] = str_replace('<!--[', '<!-- [', $content);
 //if ($extension == 'htm' || $extension == 'html')
 // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
 $showSystemFolders = api_get_course_setting('show_system_folders');
 $condition = stripos($dir, '/HotPotatoes_files') === false;
 if ($showSystemFolders == 1) {
     $condition = true;
 }
 if (($extension == 'htm' || $extension == 'html') && $condition) {
     if (empty($readonly) && $readonly == 0) {
         $_SESSION['showedit'] = 1;
         $form->add_html_editor('content', '', false, false, $html_editor_config);
     }
 }
 if (!$group_document && !is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
     $metadata_link = '<a href="../metadata/index.php?eid=' . urlencode('Document.' . $document_data['id']) . '">' . get_lang('AddMetadata') . '</a>';
     //Updated on field
     $last_edit_date = api_get_local_time($last_edit_date);
     $display_date = date_to_str_ago($last_edit_date) . ' <span class="dropbox_date">' . api_format_date($last_edit_date) . '</span>';
     $form->addElement('static', null, get_lang('Metadata'), $metadata_link);
     $form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
 }
 $form->addElement('textarea', 'comment', get_lang('Comment'), 'rows="3" style="width:300px;"');
 if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
     $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
     if ($readonly == 1) {
         $checked->setChecked(true);
     }
 }
 if ($is_certificate_mode) {
Example #12
0
    $interbreadcrumb[] = array("url" => "./document.php?curdirpath=" . urlencode($my_cur_dir_path) . '&' . api_get_cidreq(), "name" => get_lang('Documents'));
} else {
    $interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
}
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
    $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
} else {
    foreach ($document_data['parents'] as $document_sub_data) {
        if ($document_data['title'] == $document_sub_data['title']) {
            continue;
        }
        $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
    }
}
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
if (!$is_allowedToEdit) {
    api_not_allowed(true);
}
event_access_tool(TOOL_DOCUMENT);
Display::display_header($nameTools, 'Doc');
echo '<div class="actions">';
echo '<a href="document.php?id=' . $parent_id . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '<a href="edit_document.php?' . api_get_cidreq() . '&id=' . $document_id . '&' . api_get_cidreq() . '&origin=editpaint">' . Display::return_icon('edit.png', get_lang('Rename') . '/' . get_lang('Comment'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
///pixlr
$title = $file;
//disk name. No sql name because pixlr return this when save
$pixlr_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
$langpixlr = api_get_language_isocode();
$langpixlr = isset($pixlr_code_translation_table[$langpixlr]) ? $pixlredit_code_translation_table[$langpixlr] : $langpixlr;