コード例 #1
0
 public static function get_blog_info($cmid, $username)
 {
     global $DB;
     $params = self::validate_parameters(self::get_blog_info_parameters(), array('cmid' => $cmid, 'username' => $username));
     $user = $DB->get_field('user', 'id', array('username' => $params['username']), IGNORE_MISSING);
     if (!$user) {
         return array();
     }
     $result = oublog_import_getbloginfo($params['cmid'], $user);
     return array('bcmid' => $result[0], 'boublogid' => $result[1], 'bcontextid' => $result[2], 'boublogname' => $result[3], 'bcoursename' => $result[4]);
 }
コード例 #2
0
ファイル: import.php プロジェクト: nadavkav/moodle-mod_oublog
 if ($step == 2) {
     // Do the import, show feedback. First check access.
     echo html_writer::tag('p', get_string('import_step2_inst', 'oublog'));
     flush();
     $bid = required_param('bid', PARAM_INT);
     if ($remote = optional_param('remote', false, PARAM_BOOL)) {
         // Blog on remote server, use WS to get info.
         if (!($result = oublog_import_remote_call('mod_oublog_get_blog_info', array('username' => $USER->username, 'cmid' => $bid)))) {
             throw new moodle_exception('invalidcoursemodule', 'error');
         }
         $boublogid = $result->boublogid;
         $bcontextid = $result->bcontextid;
         $boublogname = $result->boublogname;
         $bcoursename = $result->bcoursename;
     } else {
         list($bid, $boublogid, $bcontextid, $boublogname, $bcoursename) = oublog_import_getbloginfo($bid);
     }
     require_sesskey();
     // Get selected and pre-selected posts.
     $preselected = explode(',', optional_param('preselected', '', PARAM_SEQUENCE));
     $selected = array();
     foreach ($_POST as $name => $val) {
         if (strpos($name, 'post_') === 0) {
             $selected[] = $val;
         }
     }
     $selected = array_filter(array_unique(array_merge($selected, $preselected), SORT_NUMERIC));
     $stepinfo = array('step' => 2, 'bid' => $bid, 'preselected' => implode(',', $selected), 'remote' => $remote);
     if (empty($selected)) {
         echo html_writer::tag('p', get_string('import_step2_none', 'oublog'));
         echo $OUTPUT->continue_button(new moodle_url('/mod/oublog/import.php', array_merge($params, $stepinfo, array('step' => 1))));