/** * セクション名を取得する * * @param object $course // コースオブジェクト * @param int $sectionid // course_sections のID :タイトルの取得に必要 * @param int $sectionnumber // sectionの連番 :存在しない場合のデフォルト名称に必要 * @param object &$mods // モジュール配列 * @return string セクションタイトル(存在しない場合は新規作成される) */ function project_format_get_title(&$course, $sectionid, $sectionnumber = 0) { global $CFG; // 引数のチェック if (!$sectionid) { return false; } // タイトルを取得 if (!($sectiontitle = get_record('course_project_title', 'sectionid', $sectionid))) { // タイトルが取得できなかった(新規のプロジェクトフォーマットアクセス) // 新規でタイトルとフォルダ名を作成する $directoryname = sprintf('section%02d', $sectionnumber); // DBインサート用オブジェクトの生成 $newtitle = new stdClass(); $newtitle->sectionid = $sectionid; $newtitle->directoryname = $directoryname; if (!($newtitle->id = insert_record('course_project_title', $newtitle))) { error('Could not create titles. Project format database is not ready. Aceess admin notify.'); } else { // 新規でタイトルを作成しました表示 notify(get_string('createnewtitle', 'format_project')); // セクション内のモジュールのリンクを書き換える project_format_rename_section_links($course, $sectionid, $directoryname); } $sectiontitle =& $newtitle; } return $sectiontitle; }
error("Could not update the directory name!"); } } else { $name = clean_filename($directoryname); if (file_exists($basedir . "/" . $name)) { // 変更後のディレクトリが存在する // echo(get_string('directoryalreadyexist','format_project',$directoryname)); } else { if (!rename($basedir . "/" . $form->olddirectoryname, $basedir . "/" . $name)) { // ディレクトリをリネームできなかった echo "<p align=\"center\">Error: could not rename {$form->olddirectoryname} to {$name}</p>"; } else { // DB内のディレクトリ名を変更 if (!set_field("course_project_title", "directoryname", $directoryname, "id", $form->id)) { error("Could not update the directory name!"); } } } } // セクション内のモジュールのリンクを書き換える project_format_rename_section_links($course, $section->id, $directoryname, true, true); } add_to_log($course->id, "course", "editprojecttitle", "format/project/edittitle.php?id={$sectiontitle->id}", "{$section->section}"); notify(get_string('updatesection', 'format_project')); redirect("../../view.php?id={$course->id}"); } else { $form = $sectiontitle; include 'edittitle_form.php'; } print_simple_box_end(); print_footer($course);