1: 2012-04-14 (土) 08:51:51 iseki |
現: 2018-09-18 (火) 21:09:55 iseki |
- | ** Moodle1.9 Programing [#l2cb4679] | + | ** Moodle2.2 Programing [#l2cb4679] |
- | - http://docs.moodle.org/dev/Blocks/Blocks_for_1.5_to_1.9 | + | - Block: http://docs.moodle.org/en/Development:Blocks |
| + | |
| + | - [[1.x→2.x>../1.x→2.x]] |
| + | #br |
| + | |
| + | *** Data Base [#xc80db23] |
| + | - DB は全面的に XMLDB に移行 |
| + | - $DB 変数必須 |
| + | **** XMLDB [#yaa09041] |
| + | - http://dev.moodle.org/mod/resource/view.php?id=48 |
| + | - block にディレクトリを作成し,その中に dbディレクトリを作る. |
| + | - 「サイト管理」→「開発」→「XMLDBエディタ」 でデータベース定義用の db/install.xml を作成する. |
| #br | | #br |
| | | |
| *** global 変数 [#s52b390d] | | *** global 変数 [#s52b390d] |
| + | **** $DB [#c208b528] |
| + | - データベースにアクセスする場合は必ず必要 |
| | | |
| **** $CFG [#v460c415] | | **** $CFG [#v460c415] |
| #br | | #br |
| | | |
- | *** 権限 [#kca35ac9] | + | *** PAGE, OUTPUT [#p5713263] |
- | - isadmin() | + | **** エラー: The theme has already been set up for this page ready for output. Therefore, you can no longer change the theme, or anything that might affect what the current theme is, for example, the course. [#ocfe165c] |
- | - isguest() | + | - 通常は require_login() を実行してから ヘッダーを書く. |
- | - require_login($course->id); | + | - ヘッダーを書いた後に require_login() を実行すると,上記のエラーが出る. |
- | - isteacher($course->id) | + | - 対策: require_login() を実行してから ヘッダーを書く. |
| + | $PAGE->set_title($title); |
| + | $PAGE->set_heading($heading); |
| + | $PAGE->set_cacheable($cache); // true |
| + | $PAGE->set_button($button); // ' ' |
| + | $PAGE->set_headingmenu($menu); |
| + | |
| + | require_login($course->id); |
| + | echo $OUTPUT->header(); |
| #br | | #br |
| | | |
| + | *** 権限 [#kca35ac9] |
| + | - require_login($course->id) |
| | | |
| + | #br |
| + | **** 2.x で廃止になった関数 [#c3786957] |
| + | - %%isadmin()%% |
| + | - %%isguest()%% |
| + | - %%isteacher($course->id)%% |
| | | |
| + | **** 代替関数 [#iafed563] |
| + | - see jbxl_moodle_tools.php |
| + | #br |
| | | |
| *** メッセージ [#pb1c2054] | | *** メッセージ [#pb1c2054] |
| + | - メッセージテーブルはローカルに持つ |
| + | - ja_utf-8 → ja, en_utf-8 → en |
| - get_string( , ) | | - get_string( , ) |
| #br | | #br |
| | | |
| *** DataBase [#v4abf387] | | *** DataBase [#v4abf387] |
- | - lib/dmllib.php | + | - lib/dml/moodle_database.php |
| + | - $strictness: MUST_EXIST, IGNORE_MISSING |
| #br | | #br |
| | | |
- | **** count_records [#rc2a2d4a] | + | **** $DB->count_records [#rc2a2d4a] |
- | $count = count_records('autoattend_sessions', 'courseid', $course->id, 'sessdate', $sdate, 'starttime', $starttime); | + | $count = $DB->count_records('autoattend_sessions', array('courseid'=>$course->id, 'sessdate'=>$sdate, 'starttime'=>$starttime)); |
| | | |
- | **** get_record(s) [#z3e3f469] | + | **** $DB->get_record(s) [#z3e3f469] |
- | - get_record($table, $field1, $value1, $field2="", $value2="", $field3="", $value3="", $fields='*') | + | - $DB-> get_record($table, array $conditions, $fields='*', $strictness=IGNORE_MISSING) |
- | if ($user = get_record("user", "id", $USER->id)) { | + | if ($user = $DB->get_record('user', array('id'=>$USER->id))) { |
| $firstname = $user->firstname; | | $firstname = $user->firstname; |
| } | | } |
- | - get_records($table, $field="", $value="", $sort="", $fields='*', $limitfrom="", $limitnum="") | + | |
- | if (!$vars = get_records('autoattend_settings', 'courseid', $courseid, 'id')) { | + | |
- | $vars = get_records('autoattend_settings', 'courseid', 0); // use default | + | - $DB->get_records($table, array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) |
| + | if (!$vars = $DB->get_records('autoattend_settings', array('courseid'=>$courseid), 'id ASC')) { |
| + | $vars = $DB->get_records('autoattend_settings', array('courseid'=>0)); // use default |
| } | | } |
| | | |
- | **** get_records_sql [#r096c770] | + | **** $DB->get_records_sql [#r096c770] |
| + | - $DB->get_record_sql($sql, array $params=null, $strictness=IGNORE_MISSING) |
| $qey = "SELECT * FROM ......."; | | $qey = "SELECT * FROM ......."; |
- | if ($users = get_records_sql($qry)) { | + | if ($users = $DB->get_records_sql($qry)) { |
| foreach($users as $key => $user) { | | foreach($users as $key => $user) { |
| $return['id'] = $user->id; | | $return['id'] = $user->id; |
| } | | } |
| | | |
- | **** update_record, insert_record [#bfdf5685] | + | **** $DB->update_record, $DB->insert_record [#bfdf5685] |
| $update = false; | | $update = false; |
- | if ($rec = get_record('autoattend_settings', 'courseid', $course->id, 'status', $status[$i])) { | + | if ($rec = $DB->get_record('autoattend_settings', array('courseid'=>$course->id, 'status'=>$status[$i]))) { |
| $update = true; | | $update = true; |
| } | | } |
| ............................ | | ............................ |
| if ($update) { | | if ($update) { |
- | $result = update_record('autoattend_settings', $rec); | + | $result = $DB->update_record('autoattend_settings', $rec); |
| } | | } |
| else { | | else { |
- | $result = insert_record('autoattend_settings', $rec); | + | $result = $DB->insert_record('autoattend_settings', $rec); |
| } | | } |
| unset($rec); | | unset($rec); |
| | | |
- | **** delete_records [#u570f164] | + | **** $DB->delete_records [#u570f164] |
- | delete_records('autoattend_settings', 'courseid', $course->id); | + | $DB->delete_records('autoattend_settings', array('courseid'=>$course->id)); |
- | | + | |
- | **** XMLDB [#yaa09041] | + | |
- | - http://dev.moodle.org/mod/resource/view.php?id=48 | + | |
- | - block にディレクトリを作成し,その中に dbディレクトリを作る. | + | |
- | - 「サイト管理」→「その他」→「XMLDBエディタ」 でデータベース定義用の db/install.xml を作成する. | + | |
- | #br | + | |
| | | |
| *** ログ [#q8c98d5f] | | *** ログ [#q8c98d5f] |
| #br | | #br |
| | | |
- | *** Form [#o9495a23] | + | *** User Table [#ne3233f5] |
| + | - [id] => 237 |
| + | - [auth] => email |
| + | - [confirmed] => 1 |
| + | - [policyagreed] => 0 |
| + | - [deleted] => 0 |
| + | - [suspended] => 0 |
| + | - [mnethostid] => 1 |
| + | - [username] => alice |
| + | - [password] => ************** |
| + | - [idnumber] => |
| + | - [firstname] => 電脳空間内アリス |
| + | - [lastname] => alice |
| + | - [email] => alice@edu.tuis.ac.jp |
| + | - [emailstop] => 0 |
| + | - [icq] => |
| + | - [skype] => |
| + | - [yahoo] => |
| + | - [aim] => |
| + | - [msn] => |
| + | - [phone1] => |
| + | - [phone2] => |
| + | - [institution] => |
| + | - [department] => |
| + | - [address] => |
| + | - [city] => 電脳空間内 |
| + | - [country] => AQ |
| + | - [lang] => ja |
| + | - [theme] => |
| + | - [timezone] => 99 |
| + | - [firstaccess] => 1272419261 |
| + | - [lastaccess] => 1334212672 |
| + | - [lastlogin] => 1309493183 |
| + | - [currentlogin] => 1334212371 |
| + | - [lastip] => 202.26.159.212 |
| + | - [secret] => |
| + | - [picture] => 0 |
| + | - [url] => |
| + | - [description] => |
| + | - [descriptionformat] => 1 |
| + | - [mailformat] => 1 |
| + | - [maildigest] => 0 |
| + | - [maildisplay] => 2 |
| + | - [htmleditor] => 1 |
| + | - [ajax] => 1 |
| + | - [autosubscribe] => 1 |
| + | - [trackforums] => 0 |
| + | - [timecreated] => 1272419261 |
| + | - [timemodified] => 1334212362 |
| + | - [trustbitmask] => 0 |
| + | - [imagealt] => |
| + | - [screenreader] => 0 |
| | | |
| #br | | #br |
| | | |
| **** Moodle Data Cleaning Parameters [#z68f6bc6] | | **** Moodle Data Cleaning Parameters [#z68f6bc6] |
| + | - see also https://github.com/moodle/moodle/blob/master/lib/moodlelib.php |
| + | |
| - PARAM_RAW: specifies a parameter that is not cleaned or processed in any way. | | - PARAM_RAW: specifies a parameter that is not cleaned or processed in any way. |
| - PARAM_CLEAN: Obsolete, please try to use a more specific type of parameter. | | - PARAM_CLEAN: Obsolete, please try to use a more specific type of parameter. |
| -- note: do not forget to addslashes() before storing into database! | | -- note: do not forget to addslashes() before storing into database! |
| - PARAM_ALPHAEXT: the same contents as PARAM_ALPHA plus the chars in quotes: "/-_" allowed, suitable for include() and require() | | - PARAM_ALPHAEXT: the same contents as PARAM_ALPHA plus the chars in quotes: "/-_" allowed, suitable for include() and require() |
| + | - PARAM_ALPHANUMEXT: expected numbers, letters only and _-. |
| - PARAM_SAFEDIR: safe directory name, suitable for include() and require() | | - PARAM_SAFEDIR: safe directory name, suitable for include() and require() |
| - PARAM_SEQUENCE: expects a sequence of numbers like 8 to 1, 5, 6, 4, 6, 8, 9. Numbers and commas only. | | - PARAM_SEQUENCE: expects a sequence of numbers like 8 to 1, 5, 6, 4, 6, 8, 9. Numbers and commas only. |