Get the view forum url for the given course module id and optionally a page number.

@param int $coursemoduleid The course module id
@param int|null $pageno The page number
@param int|null $sortorder The sorting order
@return moodle_url
761480
public function get_forum_view_url_from_course_module_id(int $coursemoduleid, ?int $pageno = null,
            ?int $sortorder = null) : moodle_url {

        $url = new moodle_url('/mod/forum/view.php', [
            'id' => $coursemoduleid,
        ]);

        if (null !== $pageno) {
            $url->param('p', $pageno);
        }

        if (null !== $sortorder) {
            $url->param('o', $sortorder);
        }

        return $url;
    }
1344467
public function get_url() {
        if ($this->other['forumtype'] == 'single') {
            // Single discussion forums are an exception. We show
            // the forum itself since it only has one discussion
            // thread.
            $url = new \moodle_url('/mod/forum/view.php', array('f' => $this->other['forumid']));
        } else {
            $url = new \moodle_url('/mod/forum/discuss.php', array('d' => $this->other['discussionid']));
        }
        return $url;
    }
925056
public function get_from_course_module_id(int $id) : ?forum_entity {
        $records = $this->get_from_course_module_ids([$id]);
        return count($records) ? array_shift($records) : null;
    }
443158
protected function get_keyfield(?int $sortmethod) : string {
        switch ($sortmethod) {
            case self::SORTORDER_CREATED_DESC:
            case self::SORTORDER_CREATED_ASC:
                return 'fp.created';
            case self::SORTORDER_REPLIES_DESC:
            case self::SORTORDER_REPLIES_ASC:
                return 'replycount';
            default:
                global $CFG;
                $alias = $this->get_table_alias();
                $field = "{$alias}.timemodified";
                if (!empty($CFG->forum_enabletimedposts)) {
                    return "CASE WHEN {$field} < {$alias}.timestart THEN {$alias}.timestart ELSE {$field} END";
                }
                return $field;
        }
    }
666498
public function get_url() {
        global $DB;

        if ($modname = $DB->get_field_sql("SELECT md.name AS modname
                                             FROM {course_modules} cm
                                             JOIN {modules} md ON md.id = cm.module
                                            WHERE cm.id = ?", array($this->_instanceid))) {
            return new moodle_url('/mod/' . $modname . '/view.php', array('id'=>$this->_instanceid));
        }

        return new moodle_url('/');
    }
887933
public function sorter($sort_url, $field_name, $sortBy, $orderBy, $display_name = null)
    {
        if ($sortBy == $field_name && $orderBy == 'asc') {
            $sorted = 'desc';
        } else {
            $sorted = 'asc';
        }
        
        $url = url($sort_url) . '/sort/' . $field_name . '/' . $sorted;
        if (!$display_name) {
             $display_name = trans('redminportal::forms.' . $field_name);
        }
        
        $data = [
            'url' => $url,
            'field_name' => $field_name,
            'display_name' => $display_name,
            'sortBy' => $sortBy,
            'orderBy' => $orderBy
        ];
        
        return view('redminportal::partials.link-sorter', $data);
    }
242020
public static function get_forums_by_courses($courseids = array()) {
        global $CFG;

        require_once($CFG->dirroot . "/mod/forum/lib.php");

        $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids));

        $courses = array();
        if (empty($params['courseids'])) {
            $courses = enrol_get_my_courses();
            $params['courseids'] = array_keys($courses);
        }

        // Array to store the forums to return.
        $arrforums = array();
        $warnings = array();

        // Ensure there are courseids to loop through.
        if (!empty($params['courseids'])) {

            list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);

            // Get the forums in this course. This function checks users visibility permissions.
            $forums = get_all_instances_in_courses("forum", $courses);
            foreach ($forums as $forum) {

                $course = $courses[$forum->course];
                $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id);
                $context = context_module::instance($cm->id);

                // Skip forums we are not allowed to see discussions.
                if (!has_capability('mod/forum:viewdiscussion', $context)) {
                    continue;
                }

                $forum->name = external_format_string($forum->name, $context->id);
                // Format the intro before being returning using the format setting.
                list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat,
                                                                                $context->id, 'mod_forum', 'intro', null);
                $forum->introfiles = external_util::get_area_files($context->id, 'mod_forum', 'intro', false, false);
                // Discussions count. This function does static request cache.
                $forum->numdiscussions = forum_count_discussions($forum, $cm, $course);
                $forum->cmid = $forum->coursemodule;
                $forum->cancreatediscussions = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
                $forum->istracked = forum_tp_is_tracked($forum);
                if ($forum->istracked) {
                    $forum->unreadpostscount = forum_tp_count_forum_unread_posts($cm, $course);
                }

                // Add the forum to the array to return.
                $arrforums[$forum->id] = $forum;
            }
        }

        return $arrforums;
    }
527159
public function display_edit_collapsed(lesson $lesson, $pageid) {
        global $DB, $CFG;

        $manager = lesson_page_type_manager::get($lesson);
        $qtypes = $manager->get_page_type_strings();
        $npages = count($lesson->load_all_pages());

        $table = new html_table();
        $table->head = array(get_string('pagetitle', 'lesson'), get_string('qtype', 'lesson'), get_string('jumps', 'lesson'), get_string('actions', 'lesson'));
        $table->align = array('left', 'left', 'left', 'center');
        $table->wrap = array('', 'nowrap', '', 'nowrap');
        $table->tablealign = 'center';
        $table->cellspacing = 0;
        $table->cellpadding = '2px';
        $table->width = '80%';
        $table->data = array();

        $canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id));

        while ($pageid != 0) {
            $page = $lesson->load_page($pageid);
            $data = array();
            $url = new moodle_url('/mod/lesson/edit.php', array(
                'id'     => $this->page->cm->id,
                'mode'   => 'single',
                'pageid' => $page->id
            ));
            $data[] = html_writer::link($url, format_string($page->title, true), array('id' => 'lesson-' . $page->id));
            $data[] = $qtypes[$page->qtype];
            $data[] = implode("<br />\n", $page->jumps);
            if ($canedit) {
                $data[] = $this->page_action_links($page, $npages, true);
            } else {
                $data[] = '';
            }
            $table->data[] = $data;
            $pageid = $page->nextpageid;
        }

        return html_writer::table($table);
    }
958045
public function get_url() {

        $url = new \moodle_url('/mod/forum/user.php', array('id' => $this->relateduserid,
            'mode' => $this->other['reportmode']));

        if ($this->courseid != SITEID) {
            $url->param('course', $this->courseid);
        }

        return $url;
    }
802853
protected function GetExternalPaymentHandlerURL(TdbShopOrder $oOrder)
    {
        $oUser = TdbDataExtranetUser::GetInstance();
        $oCountry = $oUser->GetCountry();
        $sActiveFrontEndLanguageCode = self::getLanguageService()->getLanguageIsoCode();
        $aParameter = array(
            'PSPID' => $this->GetPSPID(),
            'ORDERID' => $oOrder->fieldOrdernumber,
            'AMOUNT' => $oOrder->fieldValueTotal * 100,
            'CURRENCY' => $this->GetCurrency(),
            'LANGUAGE' => strtolower($sActiveFrontEndLanguageCode).'_'.strtoupper($sActiveFrontEndLanguageCode),
            'CN' => $oUser->fieldFirstname.' '.$oUser->fieldLastname,
            'EMAIL' => $oUser->fieldName,
            'OWNERADDRESS' => $oUser->fieldStreet.' '.$oUser->fieldStreetnr,
            'OWNERCTY' => $oCountry->fieldName,
            'OWNERTOWN' => $oUser->fieldCity,
            'OWNERZIP' => $oUser->fieldPostalcode,
            'PARAMPLUS' => 'PAYCALL='.self::URL_IDENTIFIER.'&PAYHAID='.$this->sqlData['cmsident'], 'PARAMVAR' => self::URL_IDENTIFIER_NOTIFY, );
        $this->AddCustomParameter($aParameter);
        $sOgonePaymentLayoutPageURL = $this->GetOgonePaymentLayoutPage();
        if ($sOgonePaymentLayoutPageURL) {
            $aParameter['TP'] = $sOgonePaymentLayoutPageURL;
        }
        $aParameter['ACCEPTURL'] = $this->GetResponseURL('success');
        $aParameter['DECLINEURL'] = $this->GetResponseURL('decline');
        $aParameter['SHASIGN'] = $this->BuildOutgoingHash($aParameter);
        $sExternalHandlerURL = $this->GetPaymentURL().'?'.str_replace('&amp;', '&', TTools::GetArrayAsURL($aParameter));

        return $sExternalHandlerURL;
    }
959659
public function link_for_activitylink() {
        global $DB;
        $module = $DB->get_record('course_modules', array('id' => $this->properties->activitylink));
        if ($module) {
            $modname = $DB->get_field('modules', 'name', array('id' => $module->module));
            if ($modname) {
                $instancename = $DB->get_field($modname, 'name', array('id' => $module->instance));
                if ($instancename) {
                    return html_writer::link(new moodle_url('/mod/'.$modname.'/view.php',
                        array('id' => $this->properties->activitylink)), get_string('activitylinkname',
                        'lesson', $instancename), array('class' => 'centerpadded lessonbutton standardbutton p-r-1'));
                }
            }
        }
        return '';
    }
237588
public function get_mark_discussion_as_read_url_from_discussion(
        forum_entity $forum,
        discussion_entity $discussion
    ) : moodle_url {
        return new moodle_url('/mod/forum/markposts.php', [
            'f' => $discussion->get_forum_id(),
            'd' => $discussion->get_id(),
            'mark' => 'read',
            'sesskey' => sesskey(),
            'return' => $this->get_forum_view_url_from_forum($forum)->out(),
        ]);
    }
497306
protected function translateModuleId($oldModuleId)
    {
        $module = Module::where('name',StudyModule::findOrFail($oldModuleId)->name)->first();
        if ( $module != null ) {
            return $module->id;
        }
        throw new ModuleNotFoundByNameException();
    }
45314
protected function sortModules()
    {
        $this->modules = $this->modules->sortBy(function (ModuleInterface $module) {
            return $module->getName();
        });

        return $this;
    }
1016431
public function get_pin_discussion_url_from_discussion(discussion_entity $discussion) : moodle_url {
        return new moodle_url('discuss.php', [
            'sesskey' => sesskey(),
            'd' => $discussion->get_id(),
            'pin' => $discussion->is_pinned() ? FORUM_DISCUSSION_UNPINNED : FORUM_DISCUSSION_PINNED
        ]);
    }
479257
public static MozuUrl deleteOrderNoteUrl(String noteId, String orderId)
	{
		UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/notes/{noteId}");
		formatter.formatUrl("noteId", noteId);
		formatter.formatUrl("orderId", orderId);
		return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
	}
93137
public static function action_course_change_sortorder_up_one_by_record($courserecordorid) {
        if (is_int($courserecordorid)) {
            $courserecordorid = get_course($courserecordorid);
        }
        $course = new \core_course_list_element($courserecordorid);
        $category = \core_course_category::get($course->category);
        return self::action_course_change_sortorder_up_one($course, $category);
    }