コード例 #1
0
        throw new SharingCart_RepositoryException('Repository URL was missing');
    }
    if (empty($config[$repo_id]->instance)) {
        throw new SharingCart_RepositoryException('Repository course ID was missing');
    }
    if (empty($config[$repo_id]->username)) {
        throw new SharingCart_RepositoryException('Repository username was missing');
    }
    $zip_path = make_user_directory($USER->id, true) . '/' . $sharing_cart->file;
    $zip_data = file_get_contents($zip_path);
    $form = new MoodleQuickForm('upload', 'post', $config[$repo_id]->url . '/course/format/repository/material.php');
    $form->addElement('hidden', 'mode', 'upload');
    $form->addElement('hidden', 'id', $config[$repo_id]->instance);
    $form->addElement('hidden', 'username', $config[$repo_id]->username);
    $form->addElement('hidden', 'password', $config[$repo_id]->password);
    $form->addElement('hidden', 'icon', $sharing_cart->icon);
    $form->addElement('hidden', 'type', $sharing_cart->name);
    $form->addElement('hidden', 'title', $sharing_cart->text);
    $form->addElement('hidden', 'file', base64_encode($zip_data));
    $form->addElement('hidden', 'sha1', sha1($zip_data));
    $form->addElement('hidden', 'usersite', $CFG->wwwroot);
    $form->addElement('hidden', 'sitename', $SITE->fullname);
    $icon = sharing_cart_lib::get_icon($sharing_cart->name, $sharing_cart->icon);
    $text = '<span class="icon">' . $icon . '</span><span>' . $sharing_cart->text . '</span>';
    $form->addElement('static', NULL, '', $text);
    $form->addElement('static', NULL, '', SharingCart_Repository::getString('confirm_upload'));
    $form->addElement('submit', 'upload', SharingCart_Repository::getString('upload'));
    SharingCart_Repository::printForm($form, SharingCart_Repository::getString('upload_to_repository'), $course_id);
} catch (Exception $e) {
    error((string) $e);
}
コード例 #2
0
    $forms = array();
    foreach ($config as $id => $info) {
        if ($id == $update_id) {
            if (!empty($succeeded)) {
                $message = get_string('updated', NULL, SharingCart_Repository::getString('settings'));
            } elseif (!empty($forbidden)) {
                $message = SharingCart_Repository::getString('auth_fail');
            } else {
                $message = SharingCart_Repository::getString('not_found');
            }
            $forms[] = new SharingCart_Repository_Form_Settings($course_id, $id, $info, $message);
        } else {
            $forms[] = new SharingCart_Repository_Form_Settings($course_id, $id, $info);
        }
    }
    //* (暫定) UL/DL機能が複数設定に対応していないので機能隠蔽
    if (!optional_param('add')) {
        class add_repository_form extends moodleform
        {
            public function definition()
            {
                $this->_form->addElement('submit', 'add', get_string('add'));
            }
        }
        $forms[] = new add_repository_form();
    }
    //*/
    SharingCart_Repository::printForm($forms, SharingCart_Repository::getString('settings'), $course_id, $return_to);
} catch (Exception $e) {
    error((string) $e);
}