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


PHP count_records_sql函数代码示例

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


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

示例1: definition

 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $contexts = $this->_customdata['contexts'];
     $currentcat = $this->_customdata['currentcat'];
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'categoryheader', get_string('addcategory', 'quiz'));
     $questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parent', 'quiz'), array('contexts' => $contexts, 'top' => true, 'currentcat' => $currentcat, 'nochildrenof' => $currentcat));
     $mform->setType('parent', PARAM_SEQUENCE);
     if (1 == count_records_sql("SELECT count(*) FROM {$CFG->prefix}question_categories c1, {$CFG->prefix}question_categories c2 WHERE c2.id = {$currentcat} AND c1.contextid = c2.contextid")) {
         $mform->hardFreeze('parent');
     }
     $mform->setHelpButton('parent', array('categoryparent', get_string('parent', 'quiz'), 'question'));
     $mform->addElement('text', 'name', get_string('name'), 'maxlength="254" size="50"');
     $mform->setDefault('name', '');
     $mform->addRule('name', get_string('categorynamecantbeblank', 'quiz'), 'required', null, 'client');
     $mform->setType('name', PARAM_MULTILANG);
     $mform->addElement('textarea', 'info', get_string('categoryinfo', 'quiz'), array('rows' => '10', 'cols' => '45'));
     $mform->setDefault('info', '');
     $mform->setType('info', PARAM_MULTILANG);
     //--------------------------------------------------------------------------------
     $this->add_action_buttons(false, get_string('addcategory', 'quiz'));
     //--------------------------------------------------------------------------------
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:27,代码来源:category_form.php

示例2: fill_table

 function fill_table()
 {
     global $CFG;
     $numusers = $this->get_numusers();
     if ($courses = get_courses('all', null, 'c.id, c.shortname')) {
         foreach ($courses as $course) {
             // Get course grade_item
             $grade_item = grade_item::fetch(array('itemtype' => 'course', 'courseid' => $course->id));
             // Get the grade
             $finalgrade = get_field('grade_grades', 'finalgrade', 'itemid', $grade_item->id, 'userid', $this->user->id);
             /// prints rank
             if ($finalgrade) {
                 /// find the number of users with a higher grade
                 $sql = "SELECT COUNT(DISTINCT(userid))\n                            FROM {$CFG->prefix}grade_grades\n                            WHERE finalgrade > {$finalgrade}\n                            AND itemid = {$grade_item->id}";
                 $rank = count_records_sql($sql) + 1;
                 $rankdata = "{$rank}/{$numusers}";
             } else {
                 // no grade, no rank
                 $rankdata = "-";
             }
             $courselink = '<a href="' . $CFG->wwwroot . '/grade/report/user/index.php?id=' . $course->id . '">' . $course->shortname . '</a>';
             $this->table->add_data(array($courselink, round(grade_to_percentage($finalgrade, $grade_item->grademin, $grade_item->grademax), 1) . '%', $rankdata));
         }
         return true;
     } else {
         notify(get_string('nocourses', 'grades'));
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:29,代码来源:lib.php

示例3: has_ordering_data

/**
* checks if there are ordering data for the given user context
* @param int $brainstormid
* @param int $userid
* @param int $groupid
* @param boolean $excludemyself
*/
function has_ordering_data($brainstormid, $userid = null, $groupid = 0, $excludemyself = false)
{
    global $CFG;
    $accessClause = brainstorm_get_accessclauses($userid, $groupid, $excludemyself);
    $sql = "\r\n        SELECT\r\n            COUNT(*)\r\n        FROM\r\n            {$CFG->prefix}brainstorm_responses as r,\r\n            {$CFG->prefix}brainstorm_operatordata as od\r\n        WHERE\r\n            r.brainstormid = {$brainstormid} AND\r\n            r.id = od.itemsource AND\r\n            (od.operatorid = 'order'\r\n            {$accessClause})\r\n    ";
    return count_records_sql($sql);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:14,代码来源:locallib.php

示例4: _teacherCount

 /**
  * Counts distinct teachers
  */
 function _teacherCount()
 {
     global $CFG;
     // This works on Moodle 1.6
     //		$sql = 'select count(distinct userid) from '.$CFG->prefix.'user_teachers';
     //  The following works on Moodle 1.8 and later
     $sql = "SELECT COUNT(DISTINCT u.id)\r\n            FROM {$CFG->prefix}role_capabilities rc,\r\n                 {$CFG->prefix}role_assignments ra,\r\n                 {$CFG->prefix}user u\r\n            WHERE (rc.capability = 'moodle/course:update'\r\n\t\t\t\t\tOR rc.capability='moodle/site:doanything'\r\n\t\t\t\t\tOR rc.capability='moodle/legacy:teacher'\r\n\t\t\t\t\tOR rc.capability='moodle/legacy:editingteacher' )\r\n                   AND rc.roleid = ra.roleid\r\n                   AND u.id = ra.userid";
     return count_records_sql($sql);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:12,代码来源:block_ministats.php

示例5: build_table

function build_table($components, $where)
{
    global $CFG;
    $count_sql = "SELECT COUNT(id) FROM {$CFG->prefix}block_courseprefs_users ";
    $sql = "SELECT * FROM {$CFG->prefix}block_courseprefs_users ";
    $where_sql = "WHERE " . implode(' AND ', $where);
    $users = get_records_sql($sql . $where_sql);
    $defaults = $components->as_dict();
    $keys = array_keys($defaults);
    $count = count_records_sql($count_sql . $where_sql);
    // No results gets a special message
    if (empty($users)) {
        echo '<div class = "results">' . get_string('content_no_results', 'block_courseprefs') . '</div>';
    } else {
        echo '<div class = "results">' . $count . get_string('content_results', 'block_courseprefs') . '</div>';
        echo '<table class = "generaltable" id = "tabular">';
        echo '<thead>';
        echo '<tr>';
        foreach ($defaults as $key => $value) {
            echo '<th class="header">' . $value . '</th>';
        }
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';
        $row = 1;
        foreach ($users as $user) {
            $row = $row == 1 ? 0 : 1;
            echo '  <tr class="r' . $row . '">';
            foreach ($keys as $i => $key) {
                $value = $user->{$key};
                // Trac ticket 1
                if ($key == 'username') {
                    $value = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->moodleid . '">' . $user->username . '</a>';
                }
                echo '      <td class="cell ' . $i . '">' . $value . '</td>';
            }
            echo '  </tr>';
        }
        echo '</tbody>';
        echo '</table>';
    }
}
开发者ID:rrusso,项目名称:EARS,代码行数:42,代码来源:content_viewer.php

示例6: assignment_count_real_submissions

/**
 * Counts all real assignment submissions by ENROLLED students (not empty ones)
 *
 * There are also assignment type methods count_real_submissions() wich in the default
 * implementation simply call this function.
 * @param $groupid int optional If nonzero then count is restricted to this group
 * @return int The number of submissions
 */
function assignment_count_real_submissions($assignment, $groupid = 0)
{
    global $CFG;
    if ($groupid) {
        /// How many in a particular group?
        return count_records_sql("SELECT COUNT(DISTINCT gm.userid, gm.groupid)\n                                     FROM {$CFG->prefix}assignment_submissions a,\n                                          {$CFG->prefix}groups_members g\n                                    WHERE a.assignment = {$assignment->id}\n                                      AND a.timemodified > 0\n                                      AND g.groupid = '{$groupid}'\n                                      AND a.userid = g.userid ");
    } else {
        $cm = get_coursemodule_from_instance('assignment', $assignment->id);
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        // this is all the users with this capability set, in this context or higher
        if ($users = get_users_by_capability($context, 'mod/assignment:submit', '', '', '', '', 0, '', false)) {
            foreach ($users as $user) {
                $array[] = $user->id;
            }
            $userlists = '(' . implode(',', $array) . ')';
            return count_records_sql("SELECT COUNT(*)\n                                      FROM {$CFG->prefix}assignment_submissions\n                                     WHERE assignment = '{$assignment->id}'\n                                       AND timemodified > 0\n                                       AND userid IN {$userlists} ");
        } else {
            return 0;
            // no users enroled in course
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:30,代码来源:lib.php

示例7: mnet_permit_rpc_call

/**
 * Check that a given function (or method) in an include file has been designated
 * ok for export
 *
 * @param  string   $includefile    The path to the include file
 * @param  string   $functionname   The name of the function (or method) to
 *                                  execute
 * @param  mixed    $class          A class name, or false if we're just testing
 *                                  a function
 * @return int                      Zero (RPC_OK) if all ok - appropriate
 *                                  constant otherwise
 */
function mnet_permit_rpc_call($includefile, $functionname, $class = false)
{
    global $CFG, $MNET_REMOTE_CLIENT;
    if (file_exists($CFG->dirroot . $includefile)) {
        include_once $CFG->dirroot . $includefile;
        // $callprefix matches the rpc convention
        // of not having a leading slash
        $callprefix = preg_replace('!^/!', '', $includefile);
    } else {
        return RPC_NOSUCHFILE;
    }
    if ($functionname != clean_param($functionname, PARAM_PATH)) {
        // Under attack?
        // Todo: Should really return a much more BROKEN! response
        return RPC_FORBIDDENMETHOD;
    }
    $id_list = $MNET_REMOTE_CLIENT->id;
    if (!empty($CFG->mnet_all_hosts_id)) {
        $id_list .= ', ' . $CFG->mnet_all_hosts_id;
    }
    // TODO: change to left-join so we can disambiguate:
    // 1. method doesn't exist
    // 2. method exists but is prohibited
    $sql = "\n        SELECT\n            count(r.id)\n        FROM\n            {$CFG->prefix}mnet_host2service h2s,\n            {$CFG->prefix}mnet_service2rpc s2r,\n            {$CFG->prefix}mnet_rpc r\n        WHERE\n            h2s.serviceid = s2r.serviceid AND\n            s2r.rpcid = r.id AND\n            r.xmlrpc_path = '{$callprefix}/{$functionname}' AND\n            h2s.hostid in ({$id_list}) AND\n            h2s.publish = '1'";
    $permission = count_records_sql($sql);
    if (!$permission && 'dangerous' != $CFG->mnet_dispatcher_mode) {
        return RPC_FORBIDDENMETHOD;
    }
    // WE'RE LOOKING AT A CLASS/METHOD
    if (false != $class) {
        if (!class_exists($class)) {
            // Generate error response - unable to locate class
            return RPC_NOSUCHCLASS;
        }
        $object = new $class();
        if (!method_exists($object, $functionname)) {
            // Generate error response - unable to locate method
            return RPC_NOSUCHMETHOD;
        }
        if (!method_exists($object, 'mnet_publishes')) {
            // Generate error response - the class doesn't publish
            // *any* methods, because it doesn't have an mnet_publishes
            // method
            return RPC_FORBIDDENMETHOD;
        }
        // Get the list of published services - initialise method array
        $servicelist = $object->mnet_publishes();
        $methodapproved = false;
        // If the method is in the list of approved methods, set the
        // methodapproved flag to true and break
        foreach ($servicelist as $service) {
            if (in_array($functionname, $service['methods'])) {
                $methodapproved = true;
                break;
            }
        }
        if (!$methodapproved) {
            return RPC_FORBIDDENMETHOD;
        }
        // Stash the object so we can call the method on it later
        $MNET_REMOTE_CLIENT->object_to_call($object);
        // WE'RE LOOKING AT A FUNCTION
    } else {
        if (!function_exists($functionname)) {
            // Generate error response - unable to locate function
            return RPC_NOSUCHFUNCTION;
        }
    }
    return RPC_OK;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:82,代码来源:lib.php

示例8: process

 function process($student)
 {
     if (!$this->loaded) {
         return NOT_LAGGING;
     }
     global $CFG;
     // Get the number of completed grades for the student
     $sql = "SELECT COUNT(gg.id)\n                    FROM {$CFG->prefix}grade_grades gg,\n                         {$CFG->prefix}grade_items gr\n                    WHERE gg.userid = {$student->moodleid}\n                      AND gr.id = gg.itemid\n                      AND gr.itemtype != 'course'\n                      AND gr.itemtype != 'category'\n                      AND gr.aggregationcoef > 0.00000\n                      AND gr.courseid = {$this->course->id}\n                      AND (gg.finalgrade IS NOT NULL OR gg.excluded != 0)";
     $item_count = count_records_sql($sql);
     // If they're item count is less than the threshold, then they are lagging
     if ($item_count < $this->item_threshold) {
         return LAGGING;
     }
     // If they have an above average item count, then we check they're grade
     // value threshold
     $grade = get_record('grade_grades', 'userid', $student->moodleid, 'itemid', $this->course_item->id);
     // They don't have a final grade in the class, skip it
     if (!$grade or is_null($grade->finalgrade)) {
         return NOT_LAGGING;
     }
     if ($grade->finalgrade <= $this->problem_threshold) {
         return LAGGING;
     }
     // Well, alright; if they doing really well, report that
     if ($grade->finalgrade >= $this->kudos_threshold) {
         return EXCEPTIONAL;
     }
     return NOT_LAGGING;
 }
开发者ID:rrusso,项目名称:EARS,代码行数:29,代码来源:automaticlib.php

示例9: scorm_get_count_users

function scorm_get_count_users($scormid, $groupingid = null)
{
    global $CFG;
    if (!empty($CFG->enablegroupings) && !empty($groupingid)) {
        $sql = "SELECT COUNT(DISTINCT st.userid)\n                FROM {$CFG->prefix}scorm_scoes_track st\n                    INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid\n                    INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid\n                WHERE st.scormid = {$scormid} AND gg.groupingid = {$groupingid}\n                ";
    } else {
        $sql = "SELECT COUNT(DISTINCT st.userid)\n                FROM {$CFG->prefix}scorm_scoes_track st\n                WHERE st.scormid = {$scormid}\n                ";
    }
    return count_records_sql($sql);
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:10,代码来源:locallib.php

示例10: changeauth_validate

function changeauth_validate(Pieform $form, $values)
{
    global $userids, $SESSION;
    // Make sure all users are members of the institution that
    // this authinstance belongs to.
    $authobj = AuthFactory::create($values['authinstance']);
    if ($authobj->institution != 'mahara') {
        $ph = $userids;
        $ph[] = $authobj->institution;
        $institutionusers = count_records_sql('
            SELECT COUNT(usr)
            FROM {usr_institution}
            WHERE usr IN (' . join(',', array_fill(0, count($userids), '?')) . ') AND institution = ?', $ph);
        if ($institutionusers != count($userids)) {
            $SESSION->add_error_msg(get_string('someusersnotinauthinstanceinstitution', 'admin'));
            $form->set_error('authinstance', get_string('someusersnotinauthinstanceinstitution', 'admin'));
        }
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:19,代码来源:bulk.php

示例11: turnitintool_count_records_sql

/**
 * Abstracted version of count_records_sql() to work with Moodle 1.8 through 2.0
 *
 * @param string $sql The SQL Query
 * @param array $params array of sql parameters
 * @return array An array of data objects
 */
function turnitintool_count_records_sql($sql, $params = NULL)
{
    global $DB;
    if (is_callable(array($DB, 'count_records_sql'))) {
        return $DB->count_records_sql($sql, $params);
    } else {
        return count_records_sql($sql, $params);
    }
}
开发者ID:ccle,项目名称:moodle-mod_turnitintool,代码行数:16,代码来源:lib.php

示例12: display


//.........这里部分代码省略.........
                     } else {
                         if ($noattempts == 1) {
                             // The noattempts = 1 means only no attempts,.
                             // So make the left join ask for only records where the right is null (no attempts).
                             // Show ONLY students without attempts.
                             $where .= ' AND qa.userid IS NULL';
                         } else {
                             if ($noattempts == 3) {
                                 // We want all attempts.
                                 $from = 'FROM {user} u JOIN {game_attempts} qa ON u.id = qa.userid ';
                                 $where = ' WHERE qa.gameid = ' . $game->id . ' AND qa.preview = 0';
                             }
                         }
                     }
                     // The noattempts = 2 means we want all students, with or without attempts.
                 }
             }
         }
         $countsql = 'SELECT COUNT(DISTINCT(' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ')) ' . $from . $where;
     } else {
         if (empty($noattempts)) {
             $from = 'FROM {user} u JOIN {game_attempts} qa ON u.id = qa.userid ';
             $where = ' WHERE qa.gameid = ' . $game->id . ' AND qa.preview = 0';
             $countsql = 'SELECT COUNT(DISTINCT(' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ')) ' . $from . $where;
         }
     }
     if (!$download) {
         // Add extra limits due to initials bar.
         if ($table->get_sql_where()) {
             $where .= ' AND ' . $table->get_sql_where();
         }
         // Count the records NOW, before funky question grade sorting messes up $from.
         if (!empty($countsql)) {
             $totalinitials = count_records_sql($countsql);
             if ($table->get_sql_where()) {
                 $countsql .= ' AND ' . $table->get_sql_where();
             }
             $total = count_records_sql($countsql);
         }
         // Add extra limits due to sorting by question grade.
         if ($sort = $table->get_sql_sort()) {
             $sortparts = explode(',', $sort);
             $newsort = array();
             $questionsort = false;
             foreach ($sortparts as $sortpart) {
                 $sortpart = trim($sortpart);
                 if (substr($sortpart, 0, 1) == '$') {
                     if (!$questionsort) {
                         $qid = intval(substr($sortpart, 1));
                         $select .= ', grade ';
                         $from .= ' LEFT JOIN {question_sessions} qns ON qns.attemptid = qa.id ' . 'LEFT JOIN {question_states} qs ON qs.id = qns.newgraded ';
                         $where .= ' AND (' . sql_isnull('qns.questionid') . ' OR qns.questionid = ' . $qid . ')';
                         $newsort[] = 'grade ' . (strpos($sortpart, 'ASC') ? 'ASC' : 'DESC');
                         $questionsort = true;
                     }
                 } else {
                     $newsort[] = $sortpart;
                 }
             }
             // Reconstruct the sort string.
             $sort = ' ORDER BY ' . implode(', ', $newsort);
         }
         // Fix some wired sorting.
         if (empty($sort)) {
             $sort = ' ORDER BY qa.id';
         }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:67,代码来源:report.php

示例13: get_annotation_feedback

 /**
  * Generates the data object required for displaying annotations on the page.
  *
  * @param   object  $options  Object of annotation options
  *                            - defaults can be retrieved from get_annotation_feedback_options()
  * @return  object $result    Annotation data object
  */
 public static function get_annotation_feedback($options)
 {
     global $USER;
     // set the object's key/val pairs as variables
     foreach ($options as $key => $option) {
         ${$key} = $option;
     }
     $userid = $USER->get('id');
     $canedit = false;
     if (!empty($artefact)) {
         // This is the artefact that the annotation is linked to.
         $artefactobj = artefact_instance_from_id($artefact);
         $canedit = $USER->can_edit_artefact($artefactobj);
         $owner = $artefactobj->get('owner');
         $isowner = $userid && $userid == $owner;
         $view = null;
     } else {
         if (!empty($view)) {
             // This is the view that the annotation is linked to.
             $viewobj = new View($view);
             $canedit = $USER->can_moderate_view($viewobj);
             $owner = $viewobj->get('owner');
             $isowner = $userid && $userid == $owner;
             $artefact = null;
         }
     }
     $result = (object) array('limit' => $limit, 'offset' => $offset, 'annotation' => $annotation, 'view' => $view, 'artefact' => $artefact, 'block' => $block, 'canedit' => $canedit, 'owner' => $owner, 'isowner' => $isowner, 'export' => $export, 'sort' => $sort, 'data' => array());
     $wherearray = array();
     $wherearray[] = 'a.id = ' . (int) $annotation;
     // if artefact and view are not set, this annotation is not linked to anything.
     if (!empty($artefact)) {
         $wherearray[] = 'an.artefact = ' . (int) $artefact;
     } else {
         if (!empty($view)) {
             $wherearray[] = 'an.view = ' . (int) $view;
         } else {
             // Something is wrong.  Don't show anything.
             $wherearray[] = '1 = 2';
         }
     }
     if (!$canedit) {
         $wherearray[] = '(f.private = 0 OR af.author = ' . (int) $userid . ')';
     }
     $where = implode(' AND ', $wherearray);
     $sql = 'SELECT COUNT(*)
             FROM {artefact} a
             INNER JOIN {artefact_annotation} an ON a.id = an.annotation
             INNER JOIN {artefact_annotation_feedback} f ON an.annotation = f.onannotation
             INNER JOIN {artefact} af ON f.artefact = af.id
             INNER JOIN {usr} u ON a.author = u.id
             LEFT JOIN {usr} uf ON af.author = uf.id
             LEFT JOIN {usr_institution} uif ON uf.id = uif.usr
             WHERE ' . $where;
     $result->count = count_records_sql($sql);
     if ($result->count > 0) {
         // If pagination is in use, see if we want to get a page with particular comment
         if ($limit) {
             if ($showcomment == 'last') {
                 // If we have limit (pagination is used) ignore $offset and just get the last page of feedback.
                 $result->forceoffset = $offset = (ceil($result->count / $limit) - 1) * $limit;
             } else {
                 if (is_numeric($showcomment)) {
                     // Ignore $offset and get the page that has the comment
                     // with id $showcomment on it.
                     // Fetch everything up to $showcomment to get its rank
                     // This will get ugly if there are 1000s of feedback.
                     $ids = get_column_sql('
                     SELECT f.artefact
                     FROM {artefact} a
                     INNER JOIN {artefact_annotation} an ON a.id = an.annotation
                     INNER JOIN {artefact_annotation_feedback} f ON an.annotation = f.onannotation
                     INNER JOIN {artefact} af ON f.artefact = af.id
                     INNER JOIN {usr} u ON a.author = u.id
                     LEFT JOIN {usr} uf ON af.author = uf.id
                     LEFT JOIN {usr_institution} uif ON uf.id = uif.usr
                     WHERE ' . $where . '
                     AND f.artefact <= ?
                     ORDER BY a.ctime', array($showcomment));
                     $last = end($ids);
                     if ($last == $showcomment) {
                         // Add 1 because array index starts from 0 and therefore key value is offset by 1.
                         $rank = key($ids) + 1;
                         $result->forceoffset = $offset = (ceil($rank / $limit) - 1) * $limit;
                         $result->showcomment = $showcomment;
                     }
                 }
             }
         }
         $sortorder = !empty($sort) && $sort == 'latest' ? 'af.ctime DESC' : 'af.ctime ASC';
         $sql = 'SELECT
                     af.id, af.author, af.authorname, af.ctime, af.mtime, af.description, af.group,
                     f.private, f.deletedby, f.requestpublic, f.lastcontentupdate,
                     uf.username, uf.firstname, uf.lastname, uf.preferredname, uf.email, uf.staff, uf.admin,
//.........这里部分代码省略.........
开发者ID:rboyatt,项目名称:mahara,代码行数:101,代码来源:lib.php

示例14: activitylist_html

/**
 * Get one page of notifications and return html
 */
function activitylist_html($type = 'all', $limit = 10, $offset = 0)
{
    global $USER;
    $userid = $USER->get('id');
    $typesql = '';
    if ($type != 'all') {
        // Treat as comma-separated list of activity type names
        $types = explode(',', preg_replace('/[^a-z,]+/', '', $type));
        if ($types) {
            $typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')';
            if (in_array('adminmessages', $types)) {
                $typesql = '(' . $typesql . ' OR at.admin = 1)';
            }
            $typesql = ' AND ' . $typesql;
        }
    }
    $from = "\n        FROM {notification_internal_activity} a\n        JOIN {activity_type} at ON a.type = at.id\n        WHERE a.usr = ? {$typesql}";
    $values = array($userid);
    $count = count_records_sql('SELECT COUNT(*)' . $from, $values);
    $pagination = build_pagination(array('id' => 'activitylist_pagination', 'url' => get_config('wwwroot') . 'account/activity/index.php?type=' . $type, 'jsonscript' => 'account/activity/index.json.php', 'datatable' => 'activitylist', 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'jumplinks' => 6, 'numbersincludeprevnext' => 2));
    $result = array('count' => $count, 'limit' => $limit, 'offset' => $offset, 'type' => $type, 'tablerows' => '', 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript']);
    if ($count < 1) {
        return $result;
    }
    $records = get_records_sql_array('
        SELECT
            a.*, at.name AS type, at.plugintype, at.pluginname' . $from . '
        ORDER BY a.ctime DESC', $values, $offset, $limit);
    if ($records) {
        foreach ($records as &$r) {
            $r->date = format_date(strtotime($r->ctime), 'strfdaymonthyearshort');
            $section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}";
            $r->strtype = get_string('type' . $r->type, $section);
            $r->message = format_notification_whitespace($r->message);
        }
    }
    $smarty = smarty_core();
    $smarty->assign('data', $records);
    $result['tablerows'] = $smarty->fetch('account/activity/activitylist.tpl');
    return $result;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:44,代码来源:activity.php

示例15: param_integer

require 'group.php';
$groupid = param_integer('id');
$returnto = param_alpha('returnto', 'mygroups');
define('GROUP', $groupid);
$group = group_current_group();
define('TITLE', $group->name);
if (!group_user_access($group->id)) {
    throw new AccessDeniedException(get_string('notamember', 'group'));
}
if (!group_user_can_leave($group)) {
    throw new AccessDeniedException(get_string('cantleavegroup', 'group'));
}
$goto = get_config('wwwroot') . 'group/' . $returnto . '.php' . ($returnto == 'view' ? '?id=' . $groupid : '');
$views = count_records_sql('SELECT COUNT(*)
    FROM {view} v
    INNER JOIN {view_access_group} a
    ON a.group = ?
    AND a.view = v.id
    WHERE v.owner = ?', array($groupid, $USER->get('id')));
$form = pieform(array('name' => 'leavegroup', 'renderer' => 'div', 'autofocus' => false, 'method' => 'post', 'elements' => array('submit' => array('type' => 'submitcancel', 'value' => array(get_string('yes'), get_string('no')), 'goto' => $goto), 'returnto' => array('type' => 'hidden', 'value' => $returnto))));
$smarty = smarty();
$smarty->assign('subheading', get_string('leavespecifiedgroup', 'group', $group->name));
$smarty->assign('form', $form);
$smarty->assign('message', $views ? get_string('groupconfirmleavehasviews', 'group') : get_string('groupconfirmleave', 'group'));
$smarty->assign('group', $group);
$smarty->display('group/leave.tpl');
function leavegroup_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $groupid, $goto;
    group_remove_user($groupid, $USER->get('id'));
    $SESSION->add_ok_msg(get_string('leftgroup', 'group'));
    redirect($goto);
开发者ID:Br3nda,项目名称:mahara,代码行数:32,代码来源:leave.php


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