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


PHP count_records_select函数代码示例

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


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

示例1: role_context_capabilities

        // site level in override??
    }
    $r_caps = role_context_capabilities($roleid, $parentcontext);
    $localoverrides = get_records_select('role_capabilities', "roleid = {$roleid} AND contextid = {$context->id}", '', 'capability, permission, id');
    $lang = str_replace('_utf8', '', current_language());
    if (!empty($capabilities)) {
        // Print the capabilities overrideable in this context
        print_simple_box_start('center');
        include 'override.html';
        print_simple_box_end();
    } else {
        notice(get_string('nocapabilitiesincontext', 'role'), $CFG->wwwroot . '/' . $CFG->admin . '/roles/' . $baseurl);
    }
} else {
    // Print overview table
    $table->tablealign = 'center';
    $table->cellpadding = 5;
    $table->cellspacing = 0;
    $table->width = '60%';
    $table->head = array(get_string('roles', 'role'), get_string('description'), get_string('overrides', 'role'));
    $table->wrap = array('nowrap', '', 'nowrap');
    $table->align = array('right', 'left', 'center');
    foreach ($overridableroles as $roleid => $rolename) {
        $countusers = 0;
        $overridecount = count_records_select('role_capabilities', "roleid = {$roleid} AND contextid = {$context->id}");
        $description = format_string(get_field('role', 'description', 'id', $roleid));
        $table->data[] = array('<a href="' . $baseurl . '&amp;roleid=' . $roleid . '">' . $rolename . '</a>', $description, $overridecount);
    }
    print_table($table);
}
print_footer($course);
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:override.php

示例2: question_edit_setup

/**
 * Common setup for all pages for editing questions.
 * @param string $edittab code for this edit tab
 * @param boolean $requirecmid require cmid? default false
 * @param boolean $requirecourseid require courseid, if cmid is not given? default true
 * @return array $thispageurl, $contexts, $cmid, $cm, $module, $pagevars
 */
function question_edit_setup($edittab, $requirecmid = false, $requirecourseid = true)
{
    global $COURSE, $QUESTION_EDITTABCAPS;
    //$thispageurl is used to construct urls for all question edit pages we link to from this page. It contains an array
    //of parameters that are passed from page to page.
    $thispageurl = new moodle_url();
    if ($requirecmid) {
        $cmid = required_param('cmid', PARAM_INT);
    } else {
        $cmid = optional_param('cmid', 0, PARAM_INT);
    }
    if ($cmid) {
        list($module, $cm) = get_module_from_cmid($cmid);
        $courseid = $cm->course;
        $thispageurl->params(compact('cmid'));
        require_login($courseid, false, $cm);
        $thiscontext = get_context_instance(CONTEXT_MODULE, $cmid);
    } else {
        $module = null;
        $cm = null;
        if ($requirecourseid) {
            $courseid = required_param('courseid', PARAM_INT);
        } else {
            $courseid = optional_param('courseid', 0, PARAM_INT);
        }
        if ($courseid) {
            $thispageurl->params(compact('courseid'));
            require_login($courseid, false);
            $thiscontext = get_context_instance(CONTEXT_COURSE, $courseid);
        } else {
            $thiscontext = null;
        }
    }
    if ($thiscontext) {
        $contexts = new question_edit_contexts($thiscontext);
        $contexts->require_one_edit_tab_cap($edittab);
    } else {
        $contexts = null;
    }
    $pagevars['qpage'] = optional_param('qpage', -1, PARAM_INT);
    //pass 'cat' from page to page and when 'category' comes from a drop down menu
    //then we also reset the qpage so we go to page 1 of
    //a new cat.
    $pagevars['cat'] = optional_param('cat', 0, PARAM_SEQUENCE);
    // if empty will be set up later
    if ($category = optional_param('category', 0, PARAM_SEQUENCE)) {
        if ($pagevars['cat'] != $category) {
            // is this a move to a new category?
            $pagevars['cat'] = $category;
            $pagevars['qpage'] = 0;
        }
    }
    if ($pagevars['cat']) {
        $thispageurl->param('cat', $pagevars['cat']);
    }
    if ($pagevars['qpage'] > -1) {
        $thispageurl->param('qpage', $pagevars['qpage']);
    } else {
        $pagevars['qpage'] = 0;
    }
    $pagevars['qperpage'] = optional_param('qperpage', -1, PARAM_INT);
    if ($pagevars['qperpage'] > -1) {
        $thispageurl->param('qperpage', $pagevars['qperpage']);
    } else {
        $pagevars['qperpage'] = DEFAULT_QUESTIONS_PER_PAGE;
    }
    $sortoptions = array('alpha' => 'name, qtype ASC', 'typealpha' => 'qtype, name ASC', 'age' => 'id ASC');
    if ($sortorder = optional_param('qsortorder', '', PARAM_ALPHA)) {
        $pagevars['qsortorderdecoded'] = $sortoptions[$sortorder];
        $pagevars['qsortorder'] = $sortorder;
        $thispageurl->param('qsortorder', $sortorder);
    } else {
        $pagevars['qsortorderdecoded'] = $sortoptions['typealpha'];
        $pagevars['qsortorder'] = 'typealpha';
    }
    $defaultcategory = question_make_default_categories($contexts->all());
    $contextlistarr = array();
    foreach ($contexts->having_one_edit_tab_cap($edittab) as $context) {
        $contextlistarr[] = "'{$context->id}'";
    }
    $contextlist = join($contextlistarr, ' ,');
    if (!empty($pagevars['cat'])) {
        $catparts = explode(',', $pagevars['cat']);
        if (!$catparts[0] || FALSE !== array_search($catparts[1], $contextlistarr) || !count_records_select("question_categories", "id = '" . $catparts[0] . "' AND contextid = {$catparts['1']}")) {
            print_error('invalidcategory', 'quiz');
        }
    } else {
        $category = $defaultcategory;
        $pagevars['cat'] = "{$category->id},{$category->contextid}";
    }
    if (($recurse = optional_param('recurse', -1, PARAM_BOOL)) != -1) {
        $pagevars['recurse'] = $recurse;
        $thispageurl->param('recurse', $recurse);
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:editlib.php

示例3: messages_pagesetup

function messages_pagesetup()
{
    // register links --
    global $profile_id, $PAGE, $CFG, $metatags, $function, $USER;
    $pgowner = $profile_id;
    require_once $CFG->dirroot . "mod/messages/lib/messages_config.php";
    require_once $CFG->dirroot . "mod/messages/default_template.php";
    if (isloggedin() && user_info("user_type", $_SESSION['userid']) != "external") {
        // Add the JavaScript functions
        // Lose the trailing slash
        $url = substr($CFG->wwwroot, 0, -1);
        $metatags .= "<script language=\"javascript\" type=\"text/javascript\" src=\"{$url}/mod/messages/messages.js\"></script>";
        $metatags .= "<link rel=\"stylesheet\" href=\"" . $CFG->wwwroot . "mod/messages/css.css\" type=\"text/css\" media=\"screen\" />";
        $messages = count_records_select('messages', 'to_id=' . $USER->ident . " AND status='unread'");
        if (defined("context") && context == "messages" && $pgowner == $_SESSION['userid']) {
            $PAGE->menu[] = array('name' => 'messages', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/" class="selected">' . __gettext("Messages") . " ({$messages})" . '</a></li>');
        } else {
            $PAGE->menu[] = array('name' => 'messages', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/">' . __gettext("Messages") . " ({$messages})" . '</a></li>');
        }
        if (profile_permissions_check("profile") && defined("context") && context == "messages") {
            if (user_type($pgowner) == "person") {
                $PAGE->menu_sub[] = array('name' => 'messages:list', 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/">' . __gettext("View Messages") . '</a>');
                $PAGE->menu_sub[] = array('name' => 'messages:compose', 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/compose">' . __gettext("Compose") . '</a>');
                $PAGE->menu_sub[] = array('name' => 'messages:sent', 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/sent">' . __gettext("Sent Messages") . '</a>');
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:28,代码来源:lib.php

示例4: _activeUsers

 /**
  * Returns count of users with lastaccess in the last month
  */
 function _activeUsers()
 {
     global $CFG;
     $activeUsersStartTime = time() - $CFG->block_ministats_active_users_days * 3600 * 24;
     // timestamp for user activity start time
     return count_records_select('user', 'lastaccess >= ' . $activeUsersStartTime);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:10,代码来源:block_ministats.php

示例5: questionnaire_upgrade_2005021100

function questionnaire_upgrade_2005021100()
{
    $maxnum = 50;
    /// Do 50 at a time.
    $deleted = 4;
    /// Count the number of undeleted surveys.
    if (($numsurveys = count_records_select('questionnaire_survey', 'status != ' . $deleted)) <= 0) {
        return true;
    }
    $startfrom = 0;
    while ($numsurveys > 0) {
        if ($surveys = get_records_select('questionnaire_survey', 'status != ' . $deleted, '', '*', $startfrom, $maxnum)) {
            foreach ($surveys as $survey) {
                /// If a survey belongs to a questionnaire, it *should* belong to a course, so name
                /// the realm accordingly.
                if ($quests = get_records('questionnaire', 'sid', $survey->id)) {
                    /// If the survey is in more than one course, call it public...
                    $realm = false;
                    foreach ($quests as $quest) {
                        /// Make sure we don't orphan any due to missing courses
                        if ($cid = get_field('course', 'id', 'id', $quest->course)) {
                            if ($realm === false) {
                                $cidchk = $cid;
                                $realm = 'private';
                                $owner = $quest->course;
                            } else {
                                if ($cid != $cidchk) {
                                    $realm = 'public';
                                    $owner = SITEID;
                                    break;
                                }
                            }
                        } else {
                            $realm = 'public';
                            $owner = SITEID;
                            break;
                        }
                    }
                    $survey->realm = $realm;
                    $survey->owner = $owner;
                    /// If the survey doesn't belong to a questionnaire, make it a template.
                } else {
                    $survey->realm = 'template';
                    $survey->owner = SITEID;
                }
                update_record('questionnaire_survey', $survey);
            }
        }
        $numsurveys -= $maxnum;
        $startfrom += $maxnum;
    }
    return true;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:53,代码来源:mysql.php

示例6: description

 function description()
 {
     if ($this->inprogress) {
         require_once dirname(__FILE__) . '/etl.php';
         $state = user_activity_task_init(false);
         $last_time = (int) $state['starttime'];
         $records_done = count_records_select('log', "time < {$last_time}");
         $records_togo = count_records_select('log', "time >= {$last_time}");
         return "The ETL process has not completed running.  Certain reports (such as the site-wide time summary) may show incomplete data until the ETL process has completed.\nCurrently, <b>{$records_done}</b> records have been processed and <b>{$records_togo}</b> records remain to be processed.";
     } else {
         return "The ETL process has not been run.  This prevents certain reports (such as the\nsite-wide time summary) from working.";
     }
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:13,代码来源:health.php

示例7: get_content

 function get_content()
 {
     global $CFG, $COURSE;
     $daysnb = $CFG->block_graph_stats_daysnb;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     if (empty($this->instance)) {
         $this->content->text = '';
         return $this->content;
     }
     $this->content->text = '<center><font size=1>' . get_string('graphtitle', 'block_graph_stats', $daysnb) . '</center>';
     if (isadmin() or isteacher($COURSE->id)) {
         $name = 'popup';
         $title = get_string('connectedtoday', 'block_graph_stats');
         $url = '/blocks/' . $this->name() . '/details.php';
         $options = 'menubar=0,location=0,scrollbars,resizable,width=400,height=500';
         $fullscreen = 0;
         $linkname = '<img src="' . $CFG->wwwroot . '/blocks/' . $this->name() . '/graph.php?course_id=' . $COURSE->id . '" alt="' . get_string('graphtitle', 'block_graph_stats', $daysnb) . '" />';
         $this->content->text .= '<center><a target="' . $name . '" title="' . $title . '" href="' . $CFG->wwwroot . $url . '" ' . "onclick=\"return openpopup('{$url}', '{$name}', '{$options}', {$fullscreen});\">{$linkname}</a></center>";
     } else {
         $this->content->text .= '<center><img src="' . $CFG->wwwroot . '/blocks/' . $this->name() . '/graph.php?course_id=' . $COURSE->id . '" alt="' . get_string('graphtitle', 'block_graph_stats', $daysnb) . '" /></center>';
     }
     // Check if we are in a course or on the first page
     if ($COURSE->id > 1) {
         // In a course
         $connections = count_records_select('log', 'time > ' . mktime(0, 0, 0, date("m"), date("d"), date("Y")) . ' AND action = "view" AND course = ' . $COURSE->id . ' ', 'COUNT(DISTINCT(userid))');
         $this->content->text .= '<center><font size=1>' . get_string('connectedtoday', 'block_graph_stats') . $connections . '</font></center>';
     } else {
         // On the first page
         $connections = count_records_select('log', 'time > ' . mktime(0, 0, 0, date("m"), date("d"), date("Y")) . ' AND action = "login"', 'COUNT(userid)');
         $this->content->text .= '<center><font size=1>' . get_string('connectedtoday', 'block_graph_stats') . $connections . '</font></center>';
         // Show details
         $users = count_records('user', 'deleted', 0, 'confirmed', 1);
         $courses = count_records('course', 'visible', 1);
         $this->content->text .= '<hr />';
         $this->content->text .= get_string('membersnb', 'block_graph_stats') . $users . '<br />';
         $this->content->text .= get_string('coursesnb', 'block_graph_stats') . $courses . '<br />';
     }
     return $this->content;
 }
开发者ID:kai707,项目名称:ITSA-backup,代码行数:43,代码来源:block_graph_stats.php

示例8: get_selection_data

function get_selection_data($ufiltering)
{
    global $SESSION;
    // get the SQL filter
    $guest = get_guest();
    $sqlwhere = $ufiltering->get_sql_filter("id<>{$guest->id} AND deleted <> 1");
    $total = count_records_select('user', "id<>{$guest->id} AND deleted <> 1");
    $acount = count_records_select('user', $sqlwhere);
    $scount = count($SESSION->bulk_users);
    $userlist = array('acount' => $acount, 'scount' => $scount, 'ausers' => false, 'susers' => false, 'total' => $total);
    $userlist['ausers'] = get_records_select_menu('user', $sqlwhere, 'fullname', 'id,' . sql_fullname() . ' AS fullname', 0, MAX_BULK_USERS);
    if ($scount) {
        if ($scount < MAX_BULK_USERS) {
            $in = implode(',', $SESSION->bulk_users);
        } else {
            $bulkusers = array_slice($SESSION->bulk_users, 0, MAX_BULK_USERS, true);
            $in = implode(',', $bulkusers);
        }
        $userlist['susers'] = get_records_select_menu('user', "id IN ({$in})", 'fullname', 'id,' . sql_fullname() . ' AS fullname');
    }
    return $userlist;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:22,代码来源:lib.php

示例9: question_list

/**
* Prints the table of questions in a category with interactions
*
* @param object $course   The course object
* @param int $categoryid  The id of the question category to be displayed
* @param int $quizid      The quiz id if we are in the context of a particular quiz, 0 otherwise
* @param int $recurse     This is 1 if subcategories should be included, 0 otherwise
* @param int $page        The number of the page to be displayed
* @param int $perpage     Number of questions to show per page
* @param boolean $showhidden   True if also hidden questions should be displayed
* @param boolean $showquestiontext whether the text of each question should be shown in the list
*/
function question_list($course, $categoryid, $quizid = 0, $recurse = 1, $page = 0, $perpage = 100, $showhidden = false, $sortorder = 'qtype, name ASC', $showquestiontext = false)
{
    global $USER, $CFG, $THEME;
    $qtypemenu = question_type_menu();
    if ($rqp_types = get_records('question_rqp_types')) {
        foreach ($rqp_types as $type) {
            $qtypemenu['rqp_' . $type->id] = $type->name;
        }
    }
    $strcategory = get_string("category", "quiz");
    $strquestion = get_string("question", "quiz");
    $straddquestions = get_string("addquestions", "quiz");
    $strimportquestions = get_string("importquestions", "quiz");
    $strexportquestions = get_string("exportquestions", "quiz");
    $strnoquestions = get_string("noquestions", "quiz");
    $strselect = get_string("select", "quiz");
    $strselectall = get_string("selectall", "quiz");
    $strselectnone = get_string("selectnone", "quiz");
    $strcreatenewquestion = get_string("createnewquestion", "quiz");
    $strquestionname = get_string("questionname", "quiz");
    $strdelete = get_string("delete");
    $stredit = get_string("edit");
    $straction = get_string("action");
    $strrestore = get_string('restore');
    $straddtoquiz = get_string("addtoquiz", "quiz");
    $strtype = get_string("type", "quiz");
    $strcreatemultiple = get_string("createmultiple", "quiz");
    $strpreview = get_string("preview", "quiz");
    if (!$categoryid) {
        echo "<p style=\"text-align:center;\"><b>";
        print_string("selectcategoryabove", "quiz");
        echo "</b></p>";
        if ($quizid) {
            echo "<p>";
            print_string("addingquestions", "quiz");
            echo "</p>";
        }
        return;
    }
    if (!($category = get_record('question_categories', 'id', $categoryid))) {
        notify('Category not found!');
        return;
    }
    $canedit = has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $category->course));
    $editingquiz = false;
    if ($quizid) {
        $cm = get_coursemodule_from_instance('quiz', $quizid);
        $editingquiz = has_capability('mod/quiz:manage', get_context_instance(CONTEXT_MODULE, $cm->id));
    }
    echo '<div class="boxaligncenter">';
    $formatoptions = new stdClass();
    $formatoptions->noclean = true;
    echo format_text($category->info, FORMAT_MOODLE, $formatoptions, $course->id);
    echo '<table><tr>';
    // check if editing questions in this category is allowed
    if ($canedit) {
        echo "<td valign=\"top\"><b>{$strcreatenewquestion}:</b></td>";
        echo '<td valign="top" align="right">';
        popup_form("{$CFG->wwwroot}/question/question.php?category={$category->id}&amp;qtype=", $qtypemenu, "addquestion", "", "choose", "", "", false, "self");
        echo '</td><td valign="top" align="right">';
        helpbutton("questiontypes", $strcreatenewquestion, "quiz");
        echo '</td>';
    } else {
        echo '<td>';
        print_string("publishedit", "quiz");
        echo '</td>';
    }
    echo '</tr></table>';
    echo '</div>';
    $categorylist = $recurse ? question_categorylist($category->id) : $category->id;
    // hide-feature
    $showhidden = $showhidden ? '' : " AND hidden = '0'";
    if (!($totalnumber = count_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}"))) {
        echo "<p style=\"text-align:center;\">";
        print_string("noquestions", "quiz");
        echo "</p>";
        return;
    }
    if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorder, '*', $page * $perpage, $perpage))) {
        // There are no questions on the requested page.
        $page = 0;
        if (!($questions = get_records_select('question', "category IN ({$categorylist}) AND parent = '0' {$showhidden}", $sortorder, '*', 0, $perpage))) {
            // There are no questions at all
            echo "<p style=\"text-align:center;\">";
            print_string("noquestions", "quiz");
            echo "</p>";
            return;
        }
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:editlib.php

示例10: foreach

 foreach ($generalforums as $forum) {
     $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (!groups_course_module_visible($cm)) {
         continue;
     }
     if (isset($forum->groupmode)) {
         $groupmode = groups_get_activity_groupmode($cm);
     } else {
         $groupmode = NOGROUPS;
     }
     $currentgroup = groups_get_activity_group($cm);
     $cantaccessagroup = $groupmode and !has_capability('moodle/site:accessallgroups', $context) and !mygroupid($course->id);
     // this is potentially wrong logic. could possibly check for if user has the right to hmmm
     if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
         $count = count_records_select("forum_discussions", "forum = '{$forum->id}' AND (groupid = '{$currentgroup}' OR groupid = '-1')");
     } else {
         $count = count_records("forum_discussions", "forum", "{$forum->id}");
     }
     if ($usetracking) {
         if ($forum->trackingtype == FORUM_TRACKING_ON || !isset($untracked[$forum->id])) {
             $groupid = $groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $context) ? $currentgroup : false;
             $unread = forum_tp_count_forum_unread_posts($USER->id, $forum->id, $groupid);
             if ($unread > 0) {
                 $unreadlink = '<span class="unread"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a>';
                 $unreadlink .= '<a title="' . $strmarkallread . '" href="markposts.php?f=' . $forum->id . '&amp;mark=read"><img src="' . $CFG->pixpath . '/t/clear.gif" alt="' . $strmarkallread . '" /></a></span>';
             } else {
                 $unreadlink = '<span class="read"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a></span>';
             }
             if ($forum->trackingtype == FORUM_TRACKING_OPTIONAL) {
                 $trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $stryes, 'post', '_self', true, $strnotrackforum);
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:index.php

示例11: scorm_count_launchable

function scorm_count_launchable($scormid, $organization = '')
{
    $strorganization = '';
    if (!empty($organization)) {
        $strorganization = " AND organization='{$organization}'";
    }
    return count_records_select('scorm_scoes', "scorm={$scormid}{$strorganization} AND launch<>'" . sql_empty() . "'");
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:8,代码来源:locallib.php

示例12: addblocktype

 /**
  * adds a block with the given type to a view
  *
  * @param array $values parameters for this function
  *                      blocktype => string name of blocktype to add
  *                      column    => int column to add to
  *                      order     => position in column
  *
  */
 public function addblocktype($values)
 {
     $requires = array('blocktype', 'row', 'column', 'order');
     foreach ($requires as $require) {
         if (!array_key_exists($require, $values) || empty($values[$require])) {
             throw new ParamOutOfRangeException(get_string('missingparam' . $require, 'error'));
         }
     }
     safe_require('blocktype', $values['blocktype']);
     if (!call_static_method(generate_class_name('blocktype', $values['blocktype']), 'allowed_in_view', $this)) {
         throw new UserException('[translate] Cannot put ' . $values['blocktype'] . ' blocktypes into this view');
     }
     if (call_static_method(generate_class_name('blocktype', $values['blocktype']), 'single_only', $this)) {
         $count = count_records_select('block_instance', '"view" = ? AND blocktype = ?', array($this->id, $values['blocktype']));
         if ($count > 0) {
             throw new UserException(get_string('onlyoneblocktypeperview', 'error', $values['blocktype']));
         }
     }
     $blocktypeclass = generate_class_name('blocktype', $values['blocktype']);
     $newtitle = method_exists($blocktypeclass, 'get_instance_title') ? '' : call_static_method($blocktypeclass, 'get_title');
     $bi = new BlockInstance(0, array('blocktype' => $values['blocktype'], 'title' => $newtitle, 'view' => $this->get('id'), 'view_obj' => $this, 'row' => $values['row'], 'column' => $values['column'], 'order' => $values['order']));
     $this->shuffle_cell($values['row'], $values['column'], $values['order']);
     $bi->commit();
     $this->dirtycolumns[$values['row']][$values['column']] = 1;
     if ($values['returndata']) {
         // Return new block rendered in both configure mode and (editing) display mode
         $result = array('display' => $bi->render_editing(false, true));
         if (call_static_method(generate_class_name('blocktype', $values['blocktype']), 'has_instance_config')) {
             $result['configure'] = $bi->render_editing(true, true);
         }
         return $result;
     }
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:42,代码来源:view.php

示例13: turnitintool_count_records_select

/**
 * Abstracted version of count_records_select() to work with Moodle 1.8 through 2.0
 *
 * @param string $table The Database Table
 * @param string $select the select SQL query
 * @param string $countitem The item to count
 * @return int Result count
 */
function turnitintool_count_records_select($table, $select = '', $countitem = 'COUNT(*)')
{
    global $DB;
    if (is_callable(array($DB, 'count_records_select'))) {
        return $DB->count_records_select($table, $select, NULL, $countitem);
    } else {
        return count_records_select($table, $select, $countitem);
    }
}
开发者ID:ccle,项目名称:moodle-mod_turnitintool,代码行数:17,代码来源:lib.php

示例14: xmldb_core_upgrade

function xmldb_core_upgrade($oldversion = 0)
{
    global $SESSION;
    raise_time_limit(120);
    raise_memory_limit('256M');
    $status = true;
    if ($oldversion < 2009022700) {
        // Get rid of all blocks with position 0 caused by 'about me' block on profile views
        if (count_records('block_instance', 'order', 0) && !count_records_select('block_instance', '"order" < 0')) {
            if (is_mysql()) {
                $ids = get_column_sql('
                    SELECT i.id FROM {block_instance} i
                    INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
                        ON (z.view = i.view AND z.column = i.column)');
                execute_sql('UPDATE {block_instance} SET "order" =  -1 * "order" WHERE id IN (' . join(',', $ids) . ')');
            } else {
                execute_sql('UPDATE {block_instance} SET "order" =  -1 * "order" WHERE id IN (
                    SELECT i.id FROM {block_instance} i
                    INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
                        ON (z.view = i.view AND z.column = i.column))');
            }
            execute_sql('UPDATE {block_instance} SET "order" = 1 WHERE "order" = 0');
            execute_sql('UPDATE {block_instance} SET "order" = -1 * ("order" - 1) WHERE "order" < 0');
        }
    }
    if ($oldversion < 2009031000) {
        reload_html_filters();
    }
    if ($oldversion < 2009031300) {
        $table = new XMLDBTable('institution');
        $expiry = new XMLDBField('expiry');
        $expiry->setAttributes(XMLDB_TYPE_DATETIME);
        add_field($table, $expiry);
        $expirymailsent = new XMLDBField('expirymailsent');
        $expirymailsent->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $expirymailsent);
        $suspended = new XMLDBField('suspended');
        $suspended->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $suspended);
        // Insert a cron job to check for soon expiring and expired institutions
        if (!record_exists('cron', 'callfunction', 'auth_handle_institution_expiries')) {
            $cron = new StdClass();
            $cron->callfunction = 'auth_handle_institution_expiries';
            $cron->minute = '5';
            $cron->hour = '9';
            $cron->day = '*';
            $cron->month = '*';
            $cron->dayofweek = '*';
            insert_record('cron', $cron);
        }
    }
    if ($oldversion < 2009031800) {
        // Files can only attach blogpost artefacts, but we would like to be able to attach them
        // to other stuff.  Rename the existing attachment table artefact_blog_blogpost_file to
        // artefact_file_attachment so we don't end up with many tables doing the same thing.
        execute_sql("ALTER TABLE {artefact_blog_blogpost_file} RENAME TO {artefact_attachment}");
        if (is_postgres()) {
            // Ensure all of the indexes and constraints are renamed
            execute_sql("\n            ALTER TABLE {artefact_attachment} RENAME blogpost TO artefact;\n            ALTER TABLE {artefact_attachment} RENAME file TO attachment;\n\n            ALTER INDEX {arteblogblogfile_blofil_pk} RENAME TO {arteatta_artatt_pk};\n            ALTER INDEX {arteblogblogfile_blo_ix} RENAME TO {arteatta_art_ix};\n            ALTER INDEX {arteblogblogfile_fil_ix} RENAME TO {arteatta_att_ix};\n\n            ALTER TABLE {artefact_attachment} DROP CONSTRAINT {arteblogblogfile_blo_fk};\n            ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_art_fk} FOREIGN KEY (artefact) REFERENCES {artefact}(id);\n\n            ALTER TABLE {artefact_attachment} DROP CONSTRAINT {arteblogblogfile_fil_fk};\n            ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_att_fk} FOREIGN KEY (attachment) REFERENCES {artefact}(id);\n            ");
        } else {
            if (is_mysql()) {
                execute_sql("ALTER TABLE {artefact_attachment} DROP FOREIGN KEY {arteblogblogfile_blo_fk}");
                execute_sql("ALTER TABLE {artefact_attachment} DROP INDEX {arteblogblogfile_blo_ix}");
                execute_sql("ALTER TABLE {artefact_attachment} CHANGE blogpost artefact BIGINT(10) DEFAULT NULL");
                execute_sql("ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_art_fk} FOREIGN KEY {arteatta_art_ix} (artefact) REFERENCES {artefact}(id)");
                execute_sql("ALTER TABLE {artefact_attachment} DROP FOREIGN KEY {arteblogblogfile_fil_fk}");
                execute_sql("ALTER TABLE {artefact_attachment} DROP INDEX {arteblogblogfile_fil_ix}");
                execute_sql("ALTER TABLE {artefact_attachment} CHANGE file attachment BIGINT(10) DEFAULT NULL");
                execute_sql("ALTER TABLE {artefact_attachment} ADD CONSTRAINT {arteatta_att_fk} FOREIGN KEY {arteatta_att_ix} (attachment) REFERENCES {artefact}(id)");
            }
        }
        // Drop the _pending table. From now on files uploaded as attachments will become artefacts
        // straight away.  Hopefully changes to the upload/file browser form will make it clear to
        // the user that these attachments sit in his/her files area as soon as they are uploaded.
        $table = new XMLDBTable('artefact_blog_blogpost_file_pending');
        drop_table($table);
    }
    if ($oldversion < 2009040900) {
        // The view access page has been putting the string 'null' in as a group role in IE.
        set_field('view_access_group', 'role', null, 'role', 'null');
    }
    if ($oldversion < 2009040901) {
        $table = new XMLDBTable('import_installed');
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('version', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('release', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('active', XMLDB_TYPE_INTEGER, 1, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 1);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('name'));
        create_table($table);
        $table = new XMLDBTable('import_cron');
        $table->addFieldInfo('plugin', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('callfunction', XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('minute', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
        $table->addFieldInfo('hour', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
        $table->addFieldInfo('day', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
        $table->addFieldInfo('dayofweek', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
        $table->addFieldInfo('month', XMLDB_TYPE_CHAR, 25, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '*');
        $table->addFieldInfo('nextrun', XMLDB_TYPE_DATETIME, null, null);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('plugin', 'callfunction'));
        $table->addKeyInfo('pluginfk', XMLDB_KEY_FOREIGN, array('plugin'), 'import_installed', array('name'));
//.........这里部分代码省略.........
开发者ID:patkira,项目名称:mahara,代码行数:101,代码来源:upgrade.php

示例15: require_capability

}
if (!$ispreviewing) {
    require_capability('mod/quiz:attempt', $context);
}
/// Get number for the next or unfinished attempt
if (!($attemptnumber = (int) get_field_sql('SELECT MAX(attempt)+1 FROM ' . "{$CFG->prefix}quiz_attempts WHERE quiz = '{$quiz->id}' AND " . "userid = '{$USER->id}' AND timefinish > 0 AND preview != 1"))) {
    $attemptnumber = 1;
}
$strattemptnum = get_string('attempt', 'quiz', $attemptnumber);
$strquizzes = get_string("modulenameplural", "quiz");
$popup = $quiz->popup && !$ispreviewing;
// Controls whether this is shown in a javascript-protected window or with a safe browser.
/// We intentionally do not check open and close times here. Instead we do it lower down.
/// This is to deal with what happens when someone submits close to the exact moment when the quiz closes.
/// Check number of attempts
$numberofpreviousattempts = count_records_select('quiz_attempts', "quiz = '{$quiz->id}' AND " . "userid = '{$USER->id}' AND timefinish > 0 AND preview != 1");
if (!empty($quiz->attempts) and $numberofpreviousattempts >= $quiz->attempts) {
    print_error('nomoreattempts', 'quiz', "view.php?id={$cm->id}");
}
/// Check safe browser
if (!$ispreviewing && $quiz->popup == 2 && !quiz_check_safe_browser()) {
    print_error('safebrowsererror', 'quiz', "view.php?id={$cm->id}");
}
/// Check subnet access
if (!$ispreviewing && !empty($quiz->subnet) && !address_in_subnet(getremoteaddr(), $quiz->subnet)) {
    print_error("subneterror", "quiz", "view.php?id={$cm->id}");
}
/// Check password access
if ($ispreviewing && $forcenew) {
    unset($SESSION->passwordcheckedquizzes[$quiz->id]);
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:attempt.php


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