Exemplo n.º 1
0
            } 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'));
            }
            echo json_encode($json);
        }
        break;
    case 'document_preview':
        $course_info = api_get_course_info_by_id($_REQUEST['course_id']);
        if (!empty($course_info) && is_array($course_info)) {
            echo DocumentManager::get_document_preview($course_info, false, '_blank', $_REQUEST['session_id']);
        }
        break;
}
exit;
Exemplo n.º 2
0
 */
require_once '../global.inc.php';
api_protect_course_script(true);
$action = $_REQUEST['a'];
$course_id = api_get_course_int_id();
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
switch ($action) {
    case 'get_documents':
        $courseInfo = api_get_course_info();
        $folderId = isset($_GET['folder_id']) ? $_GET['folder_id'] : null;
        if (empty($folderId)) {
            exit;
        }
        $lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : null;
        $url = isset($_GET['url']) ? $_GET['url'] : null;
        echo DocumentManager::get_document_preview($courseInfo, $lpId, null, api_get_session_id(), true, null, $url, true, false, $folderId);
        break;
    case 'add_lp_item':
        if (api_is_allowed_to_edit(null, true)) {
            if ($_SESSION['oLP']) {
                //Updating the lp.modified_on
                $_SESSION['oLP']->set_modified_on();
                $title = $_REQUEST['title'];
                if ($_REQUEST['type'] == TOOL_QUIZ) {
                    $title = Exercise::format_title_variable($title);
                }
                echo $_SESSION['oLP']->add_item($_REQUEST['parent_id'], $_REQUEST['previous_id'], $_REQUEST['type'], $_REQUEST['id'], $title, null);
            }
        }
        break;
    case 'update_lp_item_order':
Exemplo n.º 3
0
 /**
  * Creates a list with all the documents in it
  * @return string
  */
 public function get_documents()
 {
     $course_info = api_get_course_info();
     $document_tree = DocumentManager::get_document_preview($course_info, $this->lp_id, null, 0, true);
     return $document_tree;
 }
Exemplo n.º 4
0
$tpl->assign('enable_nanogong', api_get_setting('enable_nanogong') == 'true' ? 1 : 0);
$tpl->assign('enable_wami', api_get_setting('enable_wami_record') == 'true' ? 1 : 0);
$tpl->assign('cur_dir_path', '/audio');
$tpl->assign('lp_item_id', $lp_item_id);
$tpl->assign('lp_dir', api_remove_trailing_slash($lpPathInfo['dir']));
$recordVoiceForm .= $tpl->fetch('default/learnpath/record_voice.tpl');
$form->addElement('header', get_lang('Or'));
$form->addElement('header', get_lang('AudioFile'));
$form->addElement('html', sprintf(get_lang('AudioFileForItemX'), $lp_item->get_title()));
if (!empty($file)) {
    $audioPlayer = '<div id="preview">' . Display::getMediaPlayer($file, array('url' => $urlFile)) . "</div>";
    $form->addElement('label', get_lang('Listen'), $audioPlayer);
    $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?lp_id=' . $_SESSION['oLP']->get_id() . '&action=add_audio&id=' . $lp_item_id . '&delete_file=1&' . api_get_cidreq();
    $form->addElement('label', null, Display::url(get_lang('RemoveAudio'), $url, array('class' => 'btn btn-danger')));
} else {
    $form->addElement('file', 'file');
    $form->addElement('hidden', 'id', $lp_item_id);
    $form->addButtonSave(get_lang('Save'));
}
$form->addElement('header', get_lang('Or'));
$courseInfo = api_get_course_info();
$documentTree = DocumentManager::get_document_preview($courseInfo, false, null, api_get_session_id(), false, '', urlencode('lp_controller.php?action=add_audio&lp_id=' . $_SESSION['oLP']->get_id() . '&id=' . $lp_item_id), false, true);
$page .= $recordVoiceForm;
$page .= $form->return_form();
$page .= '<legend>' . get_lang('SelectAnAudioFileFromDocuments') . '</legend>';
$page .= $documentTree;
$page .= '</div>';
$page .= '</div>';
$tpl->assign('content', $page);
$content = $tpl->fetch('default/learnpath/lp_upload_audio.tpl');
$tpl->display_one_col_template();
Exemplo n.º 5
0
    $documents = getAllDocumentToWork($workId, api_get_course_int_id());
    if (!empty($documents)) {
        echo Display::page_subheader(get_lang('DocumentsAdded'));
        echo '<div class="well">';
        foreach ($documents as $doc) {
            $documentId = $doc['document_id'];
            $docData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
            if ($docData) {
                $url = api_get_path(WEB_CODE_PATH) . 'work/add_document.php?action=delete&id=' . $workId . '&document_id=' . $documentId;
                $link = Display::url(get_lang('Delete'), $url);
                echo $docData['title'] . ' ' . $link . '<br />';
            }
        }
        echo '</div>';
    }
    $document_tree = DocumentManager::get_document_preview($courseInfo, null, null, 0, false, '/', api_get_path(WEB_CODE_PATH) . 'work/add_document.php?id=' . $workId);
    echo Display::page_subheader(get_lang('Documents'));
    echo $document_tree;
    echo '<hr /><div class="clear"></div>';
} else {
    $message = null;
    $documentInfo = DocumentManager::get_document_data_by_id($docId, $courseInfo['code']);
    $form = new FormValidator('add_doc', 'post', api_get_path(WEB_CODE_PATH) . 'work/add_document.php?id=' . $workId . '&document_id=' . $docId);
    $form->addElement('header', get_lang('AddDocument'));
    $form->addElement('hidden', 'add_doc', '1');
    $form->addElement('hidden', 'id', $workId);
    $form->addElement('hidden', 'document_id', $docId);
    $form->addElement('label', get_lang('File'), $documentInfo['title']);
    $form->addElement('style_submit_button', 'submit', get_lang('Add'));
    if ($form->validate()) {
        $values = $form->exportValues();
Exemplo n.º 6
0
 /**
  * Creates a list with all the documents in it
  * @param bool $showInvisibleFiles
  * @return string
  */
 public function get_documents($showInvisibleFiles = false)
 {
     $course_info = api_get_course_info();
     $sessionId = api_get_session_id();
     $document_tree = DocumentManager::get_document_preview($course_info, $this->lp_id, null, $sessionId, true, null, null, $showInvisibleFiles, true);
     return $document_tree;
 }
Exemplo n.º 7
0
 /**
  * Creates a list with all the documents in it
  * @param bool $showInvisibleFiles
  * @return string
  */
 public function get_documents($showInvisibleFiles = false)
 {
     $course_info = api_get_course_info();
     $sessionId = api_get_session_id();
     $documentTree = DocumentManager::get_document_preview($course_info, $this->lp_id, null, $sessionId, true, null, null, $showInvisibleFiles, true);
     $headers = array(get_lang('Files'), get_lang('NewDocument'), get_lang('Upload'));
     $form = new FormValidator('form_upload', 'POST', api_get_self() . '?' . $_SERVER['QUERY_STRING'], '', array('enctype' => "multipart/form-data"));
     $folders = DocumentManager::get_all_document_folders(api_get_course_info(), 0, true);
     DocumentManager::build_directory_selector($folders, '', array(), true, $form, 'directory_parent_id');
     $form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'nothing');
     $form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'overwrite');
     $form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename');
     $form->setDefaults(['if_exists' => 'rename']);
     // Check box options
     $form->addElement('checkbox', 'unzip', get_lang('Options'), get_lang('Uncompress'));
     $url = api_get_path(WEB_AJAX_PATH) . 'document.ajax.php?' . api_get_cidreq() . '&a=upload_file&curdirpath=';
     $form->addMultipleUpload($url);
     $new = $this->display_document_form('add', 0);
     $tabs = Display::tabs($headers, array($documentTree, $new, $form->returnForm()), 'subtab');
     return $tabs;
 }
Exemplo n.º 8
0
echo $_SESSION['oLP']->return_new_tree(null, true);
// Show the template list.
echo '</div>';
echo '<div id="doc_form" class="col-md-8">';
$lp_item = new learnpathItem($lp_item_id);
$form = new FormValidator('add_audio', 'post', api_get_self() . '?action=add_audio&id=' . $lp_item_id, null, array('enctype' => 'multipart/form-data'));
$form->addElement('header', get_lang('UplUpload'));
$form->addElement('html', $lp_item->get_title());
$form->addElement('file', 'file', get_lang('AudioFile'), 'style="width: 250px"');
$form->addElement('hidden', 'id', $lp_item_id);
if (isset($lp_item->audio) && !empty($lp_item->audio)) {
    $form->addElement('checkbox', 'delete_file', null, get_lang('RemoveAudio'));
    $player = '<script type="text/javascript" src="../inc/lib/mediaplayer/swfobject.js"></script>';
    $player .= '<div id="preview"></div><script type="text/javascript">
                    var s1 = new SWFObject("../inc/lib/mediaplayer/player.swf","ply","250","20","9","#FFFFFF");
                    s1.addParam("allowscriptaccess","always");
                    s1.addParam("flashvars","file=../../courses/' . $_course['path'] . '/document/audio/' . $lp_item->audio . '");
                    s1.write("preview");
                </script>';
    $form->addElement('label', get_lang('Preview'), $player);
}
$form->addElement('button', 'submit', get_lang('Edit'));
$course_info = api_get_course_info();
$document_tree = DocumentManager::get_document_preview($course_info, null, null, 0, false, '/audio', 'lp_controller.php?action=add_audio&id=' . $lp_item_id);
$form->display();
echo '<legend>' . get_lang('SelectAnAudioFileFromDocuments') . '</legend>';
echo $document_tree;
echo '</div>';
echo '</div>';
/* FOOTER */
Display::display_footer();