当前位置: 首页>>代码示例>>PHP>>正文


PHP username_load_fields_from_object函数代码示例

本文整理汇总了PHP中username_load_fields_from_object函数的典型用法代码示例。如果您正苦于以下问题:PHP username_load_fields_from_object函数的具体用法?PHP username_load_fields_from_object怎么用?PHP username_load_fields_from_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了username_load_fields_from_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display_content

 protected function display_content($question, $rowclasses)
 {
     if (!empty($question->modifierfirstname) && !empty($question->modifierlastname)) {
         $u = new \stdClass();
         $u = username_load_fields_from_object($u, $question, 'modifier');
         echo fullname($u);
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:8,代码来源:modifier_name_column.php

示例2: display_content

 protected function display_content($question, $rowclasses)
 {
     if (!empty($question->creatorfirstname) && !empty($question->creatorlastname)) {
         $u = new \stdClass();
         $u = username_load_fields_from_object($u, $question, 'creator');
         $date = userdate($question->timecreated, get_string('strftimedatetime', 'langconfig'));
         echo fullname($u) . '<br>' . \html_writer::tag('span', $date, array('class' => 'date'));
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:9,代码来源:creator_name_column.php

示例3: get_course_contacts

 /**
  * Returns list of course contacts (usually teachers) to display in course link
  *
  * Roles to display are set up in $CFG->coursecontact
  *
  * The result is the list of users where user id is the key and the value
  * is an array with elements:
  *  - 'user' - object containing basic user information
  *  - 'role' - object containing basic role information (id, name, shortname, coursealias)
  *  - 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS)
  *  - 'username' => fullname($user, $canviewfullnames)
  *
  * @return array
  */
 public function get_course_contacts()
 {
     global $CFG;
     if (empty($CFG->coursecontact)) {
         // No roles are configured to be displayed as course contacts.
         return array();
     }
     if ($this->coursecontacts === null) {
         $this->coursecontacts = array();
         $context = context_course::instance($this->id);
         if (!isset($this->record->managers)) {
             // Preload course contacts from DB.
             $courses = array($this->id => &$this->record);
             coursecat::preload_course_contacts($courses);
         }
         // Build return array with full roles names (for this course context) and users names.
         $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
         foreach ($this->record->managers as $ruser) {
             if (isset($this->coursecontacts[$ruser->id])) {
                 // Only display a user once with the highest sortorder role.
                 continue;
             }
             $user = new stdClass();
             $user = username_load_fields_from_object($user, $ruser, null, array('id', 'username'));
             $role = new stdClass();
             $role->id = $ruser->roleid;
             $role->name = $ruser->rolename;
             $role->shortname = $ruser->roleshortname;
             $role->coursealias = $ruser->rolecoursealias;
             $this->coursecontacts[$user->id] = array('user' => $user, 'role' => $role, 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS), 'username' => fullname($user, $canviewfullnames));
         }
     }
     return $this->coursecontacts;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:48,代码来源:coursecatlib.php

示例4: get_forum_discussion_posts

 /**
  * Returns a list of forum posts for a discussion
  *
  * @param int $discussionid the post ids
  * @param string $sortby sort by this element (id, created or modified)
  * @param string $sortdirection sort direction: ASC or DESC
  *
  * @return array the forum post details
  * @since Moodle 2.7
  */
 public static function get_forum_discussion_posts($discussionid, $sortby = "created", $sortdirection = "DESC")
 {
     global $CFG, $DB, $USER;
     $warnings = array();
     // Validate the parameter.
     $params = self::validate_parameters(self::get_forum_discussion_posts_parameters(), array('discussionid' => $discussionid, 'sortby' => $sortby, 'sortdirection' => $sortdirection));
     // Compact/extract functions are not recommended.
     $discussionid = $params['discussionid'];
     $sortby = $params['sortby'];
     $sortdirection = $params['sortdirection'];
     $sortallowedvalues = array('id', 'created', 'modified');
     if (!in_array($sortby, $sortallowedvalues)) {
         throw new invalid_parameter_exception('Invalid value for sortby parameter (value: ' . $sortby . '),' . 'allowed values are: ' . implode(',', $sortallowedvalues));
     }
     $sortdirection = strtoupper($sortdirection);
     $directionallowedvalues = array('ASC', 'DESC');
     if (!in_array($sortdirection, $directionallowedvalues)) {
         throw new invalid_parameter_exception('Invalid value for sortdirection parameter (value: ' . $sortdirection . '),' . 'allowed values are: ' . implode(',', $directionallowedvalues));
     }
     $discussion = $DB->get_record('forum_discussions', array('id' => $discussionid), '*', MUST_EXIST);
     $forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
     $course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
     $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
     // Validate the module context. It checks everything that affects the module visibility (including groupings, etc..).
     $modcontext = context_module::instance($cm->id);
     self::validate_context($modcontext);
     // This require must be here, see mod/forum/discuss.php.
     require_once $CFG->dirroot . "/mod/forum/lib.php";
     // Check they have the view forum capability.
     require_capability('mod/forum:viewdiscussion', $modcontext, null, true, 'noviewdiscussionspermission', 'forum');
     if (!($post = forum_get_post_full($discussion->firstpost))) {
         throw new moodle_exception('notexists', 'forum');
     }
     // This function check groups, qanda, timed discussions, etc.
     if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
         throw new moodle_exception('noviewdiscussionspermission', 'forum');
     }
     $canviewfullname = has_capability('moodle/site:viewfullnames', $modcontext);
     // We will add this field in the response.
     $canreply = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
     $forumtracked = forum_tp_is_tracked($forum);
     $sort = 'p.' . $sortby . ' ' . $sortdirection;
     $posts = forum_get_all_discussion_posts($discussion->id, $sort, $forumtracked);
     foreach ($posts as $pid => $post) {
         if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
             $warning = array();
             $warning['item'] = 'post';
             $warning['itemid'] = $post->id;
             $warning['warningcode'] = '1';
             $warning['message'] = 'You can\'t see this post';
             $warnings[] = $warning;
             continue;
         }
         // Function forum_get_all_discussion_posts adds postread field.
         // Note that the value returned can be a boolean or an integer. The WS expects a boolean.
         if (empty($post->postread)) {
             $posts[$pid]->postread = false;
         } else {
             $posts[$pid]->postread = true;
         }
         $posts[$pid]->canreply = $canreply;
         if (!empty($posts[$pid]->children)) {
             $posts[$pid]->children = array_keys($posts[$pid]->children);
         } else {
             $posts[$pid]->children = array();
         }
         $user = new stdclass();
         $user = username_load_fields_from_object($user, $post);
         $posts[$pid]->userfullname = fullname($user, $canviewfullname);
         $posts[$pid] = (array) $post;
     }
     $result = array();
     $result['posts'] = $posts;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:educacionbe,项目名称:cursos,代码行数:86,代码来源:externallib.php

示例5: workshop_get_recent_mod_activity

/**
 * Returns all activity in course workshops since a given time
 *
 * @param array $activities sequentially indexed array of objects
 * @param int $index
 * @param int $timestart
 * @param int $courseid
 * @param int $cmid
 * @param int $userid defaults to 0
 * @param int $groupid defaults to 0
 * @return void adds items into $activities and increases $index
 */
function workshop_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0) {
    global $CFG, $COURSE, $USER, $DB;

    if ($COURSE->id == $courseid) {
        $course = $COURSE;
    } else {
        $course = $DB->get_record('course', array('id'=>$courseid));
    }

    $modinfo = get_fast_modinfo($course);

    $cm = $modinfo->cms[$cmid];

    $params = array();
    if ($userid) {
        $userselect = "AND (author.id = :authorid OR reviewer.id = :reviewerid)";
        $params['authorid'] = $userid;
        $params['reviewerid'] = $userid;
    } else {
        $userselect = "";
    }

    if ($groupid) {
        $groupselect = "AND (authorgroupmembership.groupid = :authorgroupid OR reviewergroupmembership.groupid = :reviewergroupid)";
        $groupjoin   = "LEFT JOIN {groups_members} authorgroupmembership ON authorgroupmembership.userid = author.id
                        LEFT JOIN {groups_members} reviewergroupmembership ON reviewergroupmembership.userid = reviewer.id";
        $params['authorgroupid'] = $groupid;
        $params['reviewergroupid'] = $groupid;
    } else {
        $groupselect = "";
        $groupjoin   = "";
    }

    $params['cminstance'] = $cm->instance;
    $params['submissionmodified'] = $timestart;
    $params['assessmentmodified'] = $timestart;

    $authornamefields = get_all_user_name_fields(true, 'author', null, 'author');
    $reviewerfields = get_all_user_name_fields(true, 'reviewer', null, 'reviewer');

    $sql = "SELECT s.id AS submissionid, s.title AS submissiontitle, s.timemodified AS submissionmodified,
                   author.id AS authorid, $authornamefields, author.picture AS authorpicture, author.imagealt AS authorimagealt,
                   author.email AS authoremail, a.id AS assessmentid, a.timemodified AS assessmentmodified,
                   reviewer.id AS reviewerid, $reviewerfields, reviewer.picture AS reviewerpicture,
                   reviewer.imagealt AS reviewerimagealt, reviewer.email AS revieweremail
              FROM {workshop_submissions} s
        INNER JOIN {workshop} w ON s.workshopid = w.id
        INNER JOIN {user} author ON s.authorid = author.id
         LEFT JOIN {workshop_assessments} a ON a.submissionid = s.id
         LEFT JOIN {user} reviewer ON a.reviewerid = reviewer.id
        $groupjoin
             WHERE w.id = :cminstance
                   AND s.example = 0
                   $userselect $groupselect
                   AND (s.timemodified > :submissionmodified OR a.timemodified > :assessmentmodified)
          ORDER BY s.timemodified ASC, a.timemodified ASC";

    $rs = $DB->get_recordset_sql($sql, $params);

    $groupmode       = groups_get_activity_groupmode($cm, $course);
    $context         = context_module::instance($cm->id);
    $grader          = has_capability('moodle/grade:viewall', $context);
    $accessallgroups = has_capability('moodle/site:accessallgroups', $context);
    $viewauthors     = has_capability('mod/workshop:viewauthornames', $context);
    $viewreviewers   = has_capability('mod/workshop:viewreviewernames', $context);

    $submissions = array(); // recent submissions indexed by submission id
    $assessments = array(); // recent assessments indexed by assessment id
    $users       = array();

    foreach ($rs as $activity) {

        // remember all user names we can use later
        if (empty($users[$activity->authorid])) {
            $u = new stdclass();
            $additionalfields = explode(',', user_picture::fields());
            $u = username_load_fields_from_object($u, $activity, 'author', $additionalfields);
            $users[$activity->authorid] = $u;
        }
        if ($activity->reviewerid and empty($users[$activity->reviewerid])) {
            $u = new stdclass();
            $additionalfields = explode(',', user_picture::fields());
            $u = username_load_fields_from_object($u, $activity, 'reviewer', $additionalfields);
            $users[$activity->reviewerid] = $u;
        }

        if ($activity->submissionmodified > $timestart and empty($submissions[$activity->submissionid])) {
            $s = new stdclass();
//.........这里部分代码省略.........
开发者ID:rohitshriwas,项目名称:moodle,代码行数:101,代码来源:lib.php

示例6: render_workshop_submission_summary

 /**
  * Renders short summary of the submission
  *
  * @param workshop_submission_summary $summary
  * @return string text to be echo'ed
  */
 protected function render_workshop_submission_summary(workshop_submission_summary $summary)
 {
     $o = '';
     // output HTML code
     $anonymous = $summary->is_anonymous();
     $classes = 'submission-summary';
     if ($anonymous) {
         $classes .= ' anonymous';
     }
     $gradestatus = '';
     if ($summary->status == 'notgraded') {
         $classes .= ' notgraded';
         $gradestatus = $this->output->container(get_string('nogradeyet', 'workshop'), 'grade-status');
     } else {
         if ($summary->status == 'graded') {
             $classes .= ' graded';
             $gradestatus = $this->output->container(get_string('alreadygraded', 'workshop'), 'grade-status');
         }
     }
     $o .= $this->output->container_start($classes);
     // main wrapper
     $o .= html_writer::link($summary->url, format_string($summary->title), array('class' => 'title'));
     if (!$anonymous) {
         $author = new stdClass();
         $additionalfields = explode(',', user_picture::fields());
         $author = username_load_fields_from_object($author, $summary, 'author', $additionalfields);
         $userpic = $this->output->user_picture($author, array('courseid' => $this->page->course->id, 'size' => 35));
         $userurl = new moodle_url('/user/view.php', array('id' => $author->id, 'course' => $this->page->course->id));
         $a = new stdClass();
         $a->name = fullname($author);
         $a->url = $userurl->out();
         $byfullname = get_string('byfullname', 'workshop', $a);
         $oo = $this->output->container($userpic, 'picture');
         $oo .= $this->output->container($byfullname, 'fullname');
         $o .= $this->output->container($oo, 'author');
     }
     $created = get_string('userdatecreated', 'workshop', userdate($summary->timecreated));
     $o .= $this->output->container($created, 'userdate created');
     if ($summary->timemodified > $summary->timecreated) {
         $modified = get_string('userdatemodified', 'workshop', userdate($summary->timemodified));
         $o .= $this->output->container($modified, 'userdate modified');
     }
     $o .= $gradestatus;
     $o .= $this->output->container_end();
     // end of the main wrapper
     return $o;
 }
开发者ID:dg711,项目名称:moodle,代码行数:53,代码来源:renderer.php

示例7: display


//.........这里部分代码省略.........
                 echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post', 'action' => $PAGE->url->out(false), 'onsubmit' => 'return confirm("' . $strreallydel . '");'));
                 echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
                 echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
                 echo \html_writer::start_div('', array('style' => 'display: none;'));
                 echo \html_writer::input_hidden_params($PAGE->url);
                 echo \html_writer::end_div();
                 echo \html_writer::start_div();
             }
             $table->initialbars($totalinitials > 20);
             // Build table rows.
         } else {
             $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params);
         }
         if ($attempts) {
             foreach ($attempts as $scouser) {
                 $row = array();
                 if (!empty($scouser->attempt)) {
                     $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt);
                 } else {
                     $timetracks = '';
                 }
                 if (in_array('checkbox', $columns)) {
                     if ($candelete && !empty($timetracks->start)) {
                         $row[] = \html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
                     } else {
                         if ($candelete) {
                             $row[] = '';
                         }
                     }
                 }
                 if (in_array('picture', $columns)) {
                     $user = new \stdClass();
                     $additionalfields = explode(',', \user_picture::fields());
                     $user = username_load_fields_from_object($user, $scouser, null, $additionalfields);
                     $user->id = $scouser->userid;
                     $row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id));
                 }
                 if (!$download) {
                     $url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
                     $row[] = \html_writer::link($url, fullname($scouser));
                 } else {
                     $row[] = fullname($scouser);
                 }
                 foreach ($extrafields as $field) {
                     $row[] = s($scouser->{$field});
                 }
                 if (empty($timetracks->start)) {
                     $row[] = '-';
                     $row[] = '-';
                     $row[] = '-';
                     $row[] = '-';
                 } else {
                     if (!$download) {
                         $url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
                         $row[] = \html_writer::link($url, $scouser->attempt);
                     } else {
                         $row[] = $scouser->attempt;
                     }
                     if ($download == 'ODS' || $download == 'Excel') {
                         $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
                     } else {
                         $row[] = userdate($timetracks->start);
                     }
                     if ($download == 'ODS' || $download == 'Excel') {
                         $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
                     } else {
开发者ID:lucaboesch,项目名称:moodle,代码行数:67,代码来源:report.php

示例8: render_teamwork_discussion_summary

 /**
  * Renders short summary of the submission
  *
  * @param teamwork_discussion_summary $summary
  * @return string text to be echo'ed
  */
 protected function render_teamwork_discussion_summary(teamwork_discussion_summary $summary)
 {
     global $USER, $DB, $PAGE;
     $o = '';
     // output HTML code
     $anonymous = $summary->is_anonymous();
     $classes = 'discussion-summary';
     if ($anonymous) {
         $classes .= ' anonymous';
     }
     $gradestatus = '';
     if ($summary->status == 'notgraded') {
         $classes .= ' notgraded';
         $gradestatus = $this->output->container(get_string('nogradeyet', 'teamwork'), 'grade-status');
     } else {
         if ($summary->status == 'graded') {
             $classes .= ' graded';
             $gradestatus = $this->output->container(get_string('alreadygraded', 'teamwork'), 'grade-status');
         }
     }
     $o .= $this->output->container_start($classes);
     // main wrapper
     $grade = get_string('fen', 'teamwork', $summary->score);
     $o .= html_writer::link($summary->url, format_string($grade), array('class' => 'grade'));
     if (!$anonymous) {
         $author = new stdClass();
         // change in course_server.
         $any_student = $DB->get_record('user', array('username' => 'any_student'));
         $additionalfields = explode(',', user_picture::fields());
         if ($USER->id == $summary->authorid || has_capability('mod/teamwork:editsettings', $PAGE->context)) {
             $author = username_load_fields_from_object($author, $summary, 'author', $additionalfields);
         } else {
             $author = username_load_fields_from_object($author, $any_student, null, $additionalfields);
         }
         $userpic = $this->output->user_picture($author, array('courseid' => $this->page->course->id, 'size' => 35));
         $userurl = new moodle_url('/user/view.php', array('id' => $author->id, 'course' => $this->page->course->id));
         $a = new stdClass();
         $a->name = fullname($author);
         $a->url = $userurl->out();
         $byfullname = get_string('postbyfullname', 'teamwork', $a);
         $oo = $this->output->container($userpic, 'picture');
         $oo .= $this->output->container($byfullname, 'fullname');
         $o .= $this->output->container($oo, 'author');
     }
     $o .= html_writer::link($summary->url, format_string($summary->message), array('class' => 'description'));
     if ($summary->timemodified > $summary->timecreated) {
         $modified = get_string('userdatemodified', 'teamwork', userdate($summary->timemodified));
         $o .= $this->output->container($modified, 'userdate modified');
     }
     $o .= $gradestatus;
     $o .= $this->output->container_end();
     // end of the main wrapper
     return $o;
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:60,代码来源:renderer.php

示例9: test_username_load_fields_from_object

 /**
  * Test function username_load_fields_from_object().
  */
 public function test_username_load_fields_from_object()
 {
     $this->resetAfterTest();
     // This object represents the information returned from an sql query.
     $userinfo = new stdClass();
     $userinfo->userid = 1;
     $userinfo->username = 'loosebruce';
     $userinfo->firstname = 'Bruce';
     $userinfo->lastname = 'Campbell';
     $userinfo->firstnamephonetic = 'ブルース';
     $userinfo->lastnamephonetic = 'カンベッル';
     $userinfo->middlename = '';
     $userinfo->alternatename = '';
     $userinfo->email = '';
     $userinfo->picture = 23;
     $userinfo->imagealt = 'Michael Jordan draining another basket.';
     $userinfo->idnumber = 3982;
     // Just user name fields.
     $user = new stdClass();
     $user = username_load_fields_from_object($user, $userinfo);
     $expectedarray = new stdClass();
     $expectedarray->firstname = 'Bruce';
     $expectedarray->lastname = 'Campbell';
     $expectedarray->firstnamephonetic = 'ブルース';
     $expectedarray->lastnamephonetic = 'カンベッル';
     $expectedarray->middlename = '';
     $expectedarray->alternatename = '';
     $this->assertEquals($user, $expectedarray);
     // User information for showing a picture.
     $user = new stdClass();
     $additionalfields = explode(',', user_picture::fields());
     $user = username_load_fields_from_object($user, $userinfo, null, $additionalfields);
     $user->id = $userinfo->userid;
     $expectedarray = new stdClass();
     $expectedarray->id = 1;
     $expectedarray->firstname = 'Bruce';
     $expectedarray->lastname = 'Campbell';
     $expectedarray->firstnamephonetic = 'ブルース';
     $expectedarray->lastnamephonetic = 'カンベッル';
     $expectedarray->middlename = '';
     $expectedarray->alternatename = '';
     $expectedarray->email = '';
     $expectedarray->picture = 23;
     $expectedarray->imagealt = 'Michael Jordan draining another basket.';
     $this->assertEquals($user, $expectedarray);
     // Alter the userinfo object to have a prefix.
     $userinfo->authorfirstname = 'Bruce';
     $userinfo->authorlastname = 'Campbell';
     $userinfo->authorfirstnamephonetic = 'ブルース';
     $userinfo->authorlastnamephonetic = 'カンベッル';
     $userinfo->authormiddlename = '';
     $userinfo->authorpicture = 23;
     $userinfo->authorimagealt = 'Michael Jordan draining another basket.';
     $userinfo->authoremail = 'test@testing.net';
     // Return an object with user picture information.
     $user = new stdClass();
     $additionalfields = explode(',', user_picture::fields());
     $user = username_load_fields_from_object($user, $userinfo, 'author', $additionalfields);
     $user->id = $userinfo->userid;
     $expectedarray = new stdClass();
     $expectedarray->id = 1;
     $expectedarray->firstname = 'Bruce';
     $expectedarray->lastname = 'Campbell';
     $expectedarray->firstnamephonetic = 'ブルース';
     $expectedarray->lastnamephonetic = 'カンベッル';
     $expectedarray->middlename = '';
     $expectedarray->alternatename = '';
     $expectedarray->email = 'test@testing.net';
     $expectedarray->picture = 23;
     $expectedarray->imagealt = 'Michael Jordan draining another basket.';
     $this->assertEquals($user, $expectedarray);
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:75,代码来源:moodlelib_test.php

示例10: col_picture

 /**
  * Generate the display of the user's picture column.
  * @param object $attempt the table row being output.
  * @return string HTML content to go inside the td.
  */
 public function col_picture($attempt)
 {
     global $OUTPUT;
     $user = new stdClass();
     $additionalfields = explode(',', user_picture::fields());
     $user = username_load_fields_from_object($user, $attempt, null, $additionalfields);
     $user->id = $attempt->userid;
     return $OUTPUT->user_picture($user);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:14,代码来源:attemptsreport_table.php

示例11: display


//.........这里部分代码省略.........
                 echo '<form id="attemptsform" method="post" action="' . $PAGE->url->out(false) . '" onsubmit="return confirm(\'' . $strreallydel . '\');">';
                 echo '<input type="hidden" name="action" value="delete"/>';
                 echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
                 echo '<div style="display: none;">';
                 echo html_writer::input_hidden_params($PAGE->url);
                 echo '</div>';
                 echo '<div>';
             }
             $table->initialbars($totalinitials > 20);
             // Build table rows
         } else {
             $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params);
         }
         if ($attempts) {
             foreach ($attempts as $scouser) {
                 $row = array();
                 if (!empty($scouser->attempt)) {
                     $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt);
                 } else {
                     $timetracks = '';
                 }
                 if (in_array('checkbox', $columns)) {
                     if ($candelete && !empty($timetracks->start)) {
                         $row[] = '<input type="checkbox" name="attemptid[]" value="' . $scouser->userid . ':' . $scouser->attempt . '" />';
                     } else {
                         if ($candelete) {
                             $row[] = '';
                         }
                     }
                 }
                 if (in_array('picture', $columns)) {
                     $user = new stdClass();
                     $additionalfields = explode(',', user_picture::fields());
                     $user = username_load_fields_from_object($user, $scouser, null, $additionalfields);
                     $user->id = $scouser->userid;
                     $row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id));
                 }
                 if (!$download) {
                     $row[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $scouser->userid . '&amp;course=' . $course->id . '">' . fullname($scouser) . '</a>';
                 } else {
                     $row[] = fullname($scouser);
                 }
                 foreach ($extrafields as $field) {
                     $row[] = s($scouser->{$field});
                 }
                 if (empty($timetracks->start)) {
                     $row[] = '-';
                     $row[] = '-';
                     $row[] = '-';
                     $row[] = '-';
                 } else {
                     if (!$download) {
                         $row[] = '<a href="' . $CFG->wwwroot . '/mod/scorm/report/userreport.php?id=' . $cm->id . '&amp;user=' . $scouser->userid . '&amp;attempt=' . $scouser->attempt . '">' . $scouser->attempt . '</a>';
                     } else {
                         $row[] = $scouser->attempt;
                     }
                     if ($download == 'ODS' || $download == 'Excel') {
                         $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
                     } else {
                         $row[] = userdate($timetracks->start);
                     }
                     if ($download == 'ODS' || $download == 'Excel') {
                         $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
                     } else {
                         $row[] = userdate($timetracks->finish);
                     }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:67,代码来源:report.php

示例12: list

} else {
    $groupwhere = "";
}
if ($groupingid) {
    $groupingwhere = "AND gg.groupingid = :groupingid";
    $params['groupingid'] = $groupingid;
} else {
    $groupingwhere = "";
}
list($sort, $sortparams) = users_order_by_sql('u');
$allnames = get_all_user_name_fields(true, 'u');
$sql = "SELECT g.id AS groupid, gg.groupingid, u.id AS userid, {$allnames}, u.idnumber, u.username\n          FROM {groups} g\n               LEFT JOIN {groupings_groups} gg ON g.id = gg.groupid\n               LEFT JOIN {groups_members} gm ON g.id = gm.groupid\n               LEFT JOIN {user} u ON gm.userid = u.id\n         WHERE g.courseid = :courseid {$groupwhere} {$groupingwhere}\n      ORDER BY g.name, {$sort}";
$rs = $DB->get_recordset_sql($sql, array_merge($params, $sortparams));
foreach ($rs as $row) {
    $user = new stdClass();
    $user = username_load_fields_from_object($user, $row, null, array('id' => 'userid', 'username', 'idnumber'));
    if (!$row->groupingid) {
        $row->groupingid = -1;
    }
    if (!array_key_exists($row->groupid, $members[$row->groupingid])) {
        $members[$row->groupingid][$row->groupid] = array();
    }
    if (!empty($user->id)) {
        $members[$row->groupingid][$row->groupid][] = $user;
    }
}
$rs->close();
navigation_node::override_active_url(new moodle_url('/group/index.php', array('id' => $courseid)));
$PAGE->navbar->add(get_string('overview', 'group'));
/// Print header
$PAGE->set_title($strgroups);
开发者ID:Keneth1212,项目名称:moodle,代码行数:31,代码来源:overview.php

示例13: get_forum_discussions_paginated


//.........这里部分代码省略.........
     }
     $forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST);
     $course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
     $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
     // Validate the module context. It checks everything that affects the module visibility (including groupings, etc..).
     $modcontext = context_module::instance($cm->id);
     self::validate_context($modcontext);
     // Check they have the view forum capability.
     require_capability('mod/forum:viewdiscussion', $modcontext, null, true, 'noviewdiscussionspermission', 'forum');
     $sort = 'd.pinned DESC, d.' . $sortby . ' ' . $sortdirection;
     $alldiscussions = forum_get_discussions($cm, $sort, true, -1, -1, true, $page, $perpage, FORUM_POSTS_ALL_USER_GROUPS);
     if ($alldiscussions) {
         $canviewfullname = has_capability('moodle/site:viewfullnames', $modcontext);
         // Get the unreads array, this takes a forum id and returns data for all discussions.
         $unreads = array();
         if ($cantrack = forum_tp_can_track_forums($forum)) {
             if ($forumtracked = forum_tp_is_tracked($forum)) {
                 $unreads = forum_get_discussions_unread($cm);
             }
         }
         // The forum function returns the replies for all the discussions in a given forum.
         $replies = forum_count_discussion_replies($forumid, $sort, -1, $page, $perpage);
         foreach ($alldiscussions as $discussion) {
             // This function checks for qanda forums.
             // Note that the forum_get_discussions returns as id the post id, not the discussion id so we need to do this.
             $discussionrec = clone $discussion;
             $discussionrec->id = $discussion->discussion;
             if (!forum_user_can_see_discussion($forum, $discussionrec, $modcontext)) {
                 $warning = array();
                 // Function forum_get_discussions returns forum_posts ids not forum_discussions ones.
                 $warning['item'] = 'post';
                 $warning['itemid'] = $discussion->id;
                 $warning['warningcode'] = '1';
                 $warning['message'] = 'You can\'t see this discussion';
                 $warnings[] = $warning;
                 continue;
             }
             $discussion->numunread = 0;
             if ($cantrack && $forumtracked) {
                 if (isset($unreads[$discussion->discussion])) {
                     $discussion->numunread = (int) $unreads[$discussion->discussion];
                 }
             }
             $discussion->numreplies = 0;
             if (!empty($replies[$discussion->discussion])) {
                 $discussion->numreplies = (int) $replies[$discussion->discussion]->replies;
             }
             $discussion->name = external_format_string($discussion->name, $modcontext->id);
             $discussion->subject = external_format_string($discussion->subject, $modcontext->id);
             // Rewrite embedded images URLs.
             list($discussion->message, $discussion->messageformat) = external_format_text($discussion->message, $discussion->messageformat, $modcontext->id, 'mod_forum', 'post', $discussion->id);
             // List attachments.
             if (!empty($discussion->attachment)) {
                 $discussion->attachments = external_util::get_area_files($modcontext->id, 'mod_forum', 'attachment', $discussion->id);
             }
             $messageinlinefiles = external_util::get_area_files($modcontext->id, 'mod_forum', 'post', $discussion->id);
             if (!empty($messageinlinefiles)) {
                 $discussion->messageinlinefiles = $messageinlinefiles;
             }
             $discussion->locked = forum_discussion_is_locked($forum, $discussion);
             $discussion->canreply = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
             if (forum_is_author_hidden($discussion, $forum)) {
                 $discussion->userid = null;
                 $discussion->userfullname = null;
                 $discussion->userpictureurl = null;
                 $discussion->usermodified = null;
                 $discussion->usermodifiedfullname = null;
                 $discussion->usermodifiedpictureurl = null;
             } else {
                 $picturefields = explode(',', user_picture::fields());
                 // Load user objects from the results of the query.
                 $user = new stdclass();
                 $user->id = $discussion->userid;
                 $user = username_load_fields_from_object($user, $discussion, null, $picturefields);
                 // Preserve the id, it can be modified by username_load_fields_from_object.
                 $user->id = $discussion->userid;
                 $discussion->userfullname = fullname($user, $canviewfullname);
                 $userpicture = new user_picture($user);
                 $userpicture->size = 1;
                 // Size f1.
                 $discussion->userpictureurl = $userpicture->get_url($PAGE)->out(false);
                 $usermodified = new stdclass();
                 $usermodified->id = $discussion->usermodified;
                 $usermodified = username_load_fields_from_object($usermodified, $discussion, 'um', $picturefields);
                 // Preserve the id (it can be overwritten due to the prefixed $picturefields).
                 $usermodified->id = $discussion->usermodified;
                 $discussion->usermodifiedfullname = fullname($usermodified, $canviewfullname);
                 $userpicture = new user_picture($usermodified);
                 $userpicture->size = 1;
                 // Size f1.
                 $discussion->usermodifiedpictureurl = $userpicture->get_url($PAGE)->out(false);
             }
             $discussions[] = $discussion;
         }
     }
     $result = array();
     $result['discussions'] = $discussions;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:101,代码来源:externallib.php

示例14: forum_get_recent_mod_activity

/**
 * Returns all forum posts since a given time in specified forum.
 *
 * @todo Document this functions args
 * @global object
 * @global object
 * @global object
 * @global object
 */
function forum_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0)
{
    global $CFG, $COURSE, $USER, $DB;
    if ($COURSE->id == $courseid) {
        $course = $COURSE;
    } else {
        $course = $DB->get_record('course', array('id' => $courseid));
    }
    $modinfo = get_fast_modinfo($course);
    $cm = $modinfo->cms[$cmid];
    $params = array($timestart, $cm->instance);
    if ($userid) {
        $userselect = "AND u.id = ?";
        $params[] = $userid;
    } else {
        $userselect = "";
    }
    if ($groupid) {
        $groupselect = "AND d.groupid = ?";
        $params[] = $groupid;
    } else {
        $groupselect = "";
    }
    $allnames = get_all_user_name_fields(true, 'u');
    if (!($posts = $DB->get_records_sql("SELECT p.*, f.type AS forumtype, d.forum, d.groupid,\n                                              d.timestart, d.timeend, d.userid AS duserid,\n                                              {$allnames}, u.email, u.picture, u.imagealt, u.email\n                                         FROM {forum_posts} p\n                                              JOIN {forum_discussions} d ON d.id = p.discussion\n                                              JOIN {forum} f             ON f.id = d.forum\n                                              JOIN {user} u              ON u.id = p.userid\n                                        WHERE p.created > ? AND f.id = ?\n                                              {$userselect} {$groupselect}\n                                     ORDER BY p.id ASC", $params))) {
        // order by initial posting date
        return;
    }
    $groupmode = groups_get_activity_groupmode($cm, $course);
    $cm_context = context_module::instance($cm->id);
    $viewhiddentimed = has_capability('mod/forum:viewhiddentimedposts', $cm_context);
    $accessallgroups = has_capability('moodle/site:accessallgroups', $cm_context);
    $printposts = array();
    foreach ($posts as $post) {
        if (!empty($CFG->forum_enabletimedposts) and $USER->id != $post->duserid and ($post->timestart > 0 and $post->timestart > time() or $post->timeend > 0 and $post->timeend < time())) {
            if (!$viewhiddentimed) {
                continue;
            }
        }
        if ($groupmode) {
            if ($post->groupid == -1 or $groupmode == VISIBLEGROUPS or $accessallgroups) {
                // oki (Open discussions have groupid -1)
            } else {
                // separate mode
                if (isguestuser()) {
                    // shortcut
                    continue;
                }
                if (!in_array($post->groupid, $modinfo->get_groups($cm->groupingid))) {
                    continue;
                }
            }
        }
        $printposts[] = $post;
    }
    if (!$printposts) {
        return;
    }
    $aname = format_string($cm->name, true);
    foreach ($printposts as $post) {
        $tmpactivity = new stdClass();
        $tmpactivity->type = 'forum';
        $tmpactivity->cmid = $cm->id;
        $tmpactivity->name = $aname;
        $tmpactivity->sectionnum = $cm->sectionnum;
        $tmpactivity->timestamp = $post->modified;
        $tmpactivity->content = new stdClass();
        $tmpactivity->content->id = $post->id;
        $tmpactivity->content->discussion = $post->discussion;
        $tmpactivity->content->subject = format_string($post->subject);
        $tmpactivity->content->parent = $post->parent;
        $tmpactivity->user = new stdClass();
        $additionalfields = array('id' => 'userid', 'picture', 'imagealt', 'email');
        $additionalfields = explode(',', user_picture::fields());
        $tmpactivity->user = username_load_fields_from_object($tmpactivity->user, $post, null, $additionalfields);
        $tmpactivity->user->id = $post->userid;
        $activities[$index++] = $tmpactivity;
    }
    return;
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:89,代码来源:lib.php

示例15: export_content_leap2a

    /**
     * Add a LEAP2A entry element that corresponds to a submission including attachments.
     *
     * @param portfolio_format_leap2a_writer $leapwriter Writer object to add entries to.
     * @param workshop_submission $workshopsubmission
     * @param string $html The exported HTML content of the submission
     * @return int id of new entry
     */
    protected function export_content_leap2a(portfolio_format_leap2a_writer $leapwriter,
            workshop_submission $workshopsubmission, $html) {

        $entry = new portfolio_format_leap2a_entry('workshopsubmission'.$workshopsubmission->id,  s($workshopsubmission->title),
            'resource', $html);
        $entry->published = $workshopsubmission->timecreated;
        $entry->updated = $workshopsubmission->timemodified;
        $entry->author = (object)[
            'id' => $workshopsubmission->authorid,
            'email' => $workshopsubmission->authoremail
        ];
        username_load_fields_from_object($entry->author, $workshopsubmission);

        $leapwriter->link_files($entry, $this->multifiles);
        $entry->add_category('web', 'resource_type');
        $leapwriter->add_entry($entry);

        return $entry->id;
    }
开发者ID:rezaies,项目名称:moodle,代码行数:27,代码来源:portfolio_caller.php


注:本文中的username_load_fields_from_object函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。