• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_field_sql函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: forgotpass_validate

function forgotpass_validate(Pieform $form, $values)
{
    // See if the user input an email address or a username. We favour email addresses
    if (!$form->get_error('emailusername')) {
        // Check if the user who associates to username or email address is using the external authentication
        if (record_exists_sql('SELECT u.authinstance
            FROM {usr} u INNER JOIN {auth_instance} ai ON (u.authinstance = ai.id)
            WHERE (LOWER(u.email) = ? OR LOWER(u.username) = ?)
            AND ((ai.authname != \'internal\') AND (ai.authname != \'none\'))', array_fill(0, 2, strtolower($values['emailusername'])))) {
            $form->set_error('emailusername', get_string('forgotpassuserusingexternalauthentication', 'mahara', get_config('wwwroot') . 'contact.php'));
        } else {
            if (!($authinstance = get_field_sql('SELECT u.authinstance
                FROM {usr} u INNER JOIN {auth_instance} ai ON (u.authinstance = ai.id)
                WHERE (LOWER(u.email) = ? OR LOWER(u.username) = ?)
                AND ai.authname = \'internal\'', array_fill(0, 2, strtolower($values['emailusername']))))) {
                $form->set_error('emailusername', get_string('forgotpassnosuchemailaddressorusername'));
            }
        }
    }
    if ($form->get_error('emailusername')) {
        return;
    }
    $authobj = AuthFactory::create($authinstance);
    if (!method_exists($authobj, 'change_password')) {
        die_info(get_string('cantchangepassword'));
    }
}
开发者ID:rboyatt,项目名称:mahara,代码行数:27,代码来源:forgotpass.php


示例2: postinst

 /**
  * Called post install and after every upgrade to the artefact.
  * @param string $prevversion the previously installed version of this artefact.
  */
 public static function postinst($prevversion)
 {
     if ($prevversion == 0) {
         // Since this is the first time, we need to
         // create the default settings and the static
         // table data for aretfact_annotation_deletedby.
         set_config_plugin('artefact', 'annotation', 'commenteditabletime', 10);
         foreach (ArtefactTypeAnnotationfeedback::deleted_by_types() as $index => $type) {
             insert_record('artefact_annotation_deletedby', (object) array('id' => (int) $index + 1, 'name' => $type));
         }
         // If elasticsearch is installed, update the artefacttypesmap field to include
         // annotation and annotationfeedback.
         $sql = "SELECT value FROM {search_config} WHERE plugin='elasticsearch' AND field='artefacttypesmap'";
         if ($result = get_field_sql($sql, array())) {
             $elasticsearchartefacttypesmap = explode("\n", $result);
             // add annotation and annotationfeedback fields.
             $elasticsearchartefacttypesmap[] = "annotation|Annotation|Text";
             $elasticsearchartefacttypesmap[] = "annotationfeedback|Annotation|Text";
             // Now save the data including the new annotation fields.
             set_config_plugin('search', 'elasticsearch', 'artefacttypesmap', implode("\n", $elasticsearchartefacttypesmap));
         }
         // Now install the blocktype annotation only if Mahara was previously installed.
         // Otherwise, the Mahara installer will install everything.
         if (get_config('installed')) {
             if ($upgrade = check_upgrades('blocktype.annotation/annotation')) {
                 upgrade_plugin($upgrade);
             }
         }
     }
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:34,代码来源:lib.php


示例3: memorization_print_new_verse_box

function memorization_print_new_verse_box()
{
    global $CFG, $USER;
    print_box_start('add-verse-box generalbox box');
    print_heading(get_string('newverse', 'memorization'));
    $biblebooks = biblebooks_array();
    // create the book selector
    $biblebookoptions = '';
    foreach ($biblebooks as $booknumber => $bookofbible) {
        if ($booknumber == 0) {
            continue;
        }
        $biblebookoptions .= '<option value="' . $booknumber . '">' . $bookofbible . '</option>';
    }
    $startbookid = '<select name="startbookid">' . $biblebookoptions . '</select>';
    $endbookid = '<select name="endbookid">' . $biblebookoptions . '</select>';
    // create the chapter inputs
    $startchapter = '<input type="text" name="startchapter" size="5" />';
    $endchapter = '<input type="text" name="endchapter" size="5"/>';
    // create the verse inputs
    $startverse = '<input type="text" name="startverse" size="5"/>';
    $endverse = '<input type="text" name="endverse" size="5"/>';
    // create the version chooser
    $versions = get_records('memorization_version');
    if (!empty($versions)) {
        $versionselect = '<select name="versionid">';
        $lastversionid = get_field_sql("SELECT versionid FROM {$CFG->prefix}memorization_verse WHERE userid={$USER->id} ORDER BY id DESC");
        foreach ($versions as $versionid => $version) {
            $selected = $versionid == $lastversionid ? ' SELECTED="selected" ' : '';
            $versionselect .= '<option ' . $selected . ' value="' . $versionid . '">' . $version->value . '</option>';
        }
        $versionselect .= '</select>';
    }
    $currenturl = new moodle_url(qualified_me());
    echo '<form method="POST" action="addverse.php?' . $currenturl->get_query_string() . '">
          <input type="hidden" name="sesskey" value="' . sesskey() . '">
          <table>
            <tr>
              <td>' . get_string('fromverse', 'memorization') . '</td>
              <td>' . $startbookid . ' ' . $startchapter . ':' . $startverse . '</td>
            </tr>

            <tr>
              <td>' . get_string('toverse', 'memorization') . '</td>
              <td>' . $endbookid . ' ' . $endchapter . ':' . $endverse . '</td>
            </tr>

            <tr>
              <td>' . get_string('version', 'memorization') . '</td>
              <td>' . $versionselect . '</td>
            </tr>
          </table>
          <input type="submit">
          </form>';
    print_box_end();
}
开发者ID:NextEinstein,项目名称:riverhills,代码行数:56,代码来源:locallib.php


示例4: getvalue

 /**
  *
  *
  */
 function getvalue($issueid)
 {
     global $CFG;
     if (!$issueid) {
         return '';
     }
     $sql = "\n            SELECT \n                elementitemid\n            FROM\n                {$CFG->prefix}tracker_issueattribute\n            WHERE\n                elementid = {$this->id} AND\n                issueid = {$issueid}\n        ";
     $this->value = get_field_sql($sql);
     return $this->value;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:14,代码来源:trackerelement.class.php


示例5: create_session_and_responses

 function create_session_and_responses(&$question, &$state, $cmoptions, $attempt)
 {
     // Find out how many datasets are available
     global $CFG;
     if (!($maxnumber = (int) get_field_sql("SELECT MIN(a.itemcount)\n                            FROM {$CFG->prefix}question_dataset_definitions a,\n                                 {$CFG->prefix}question_datasets b\n                            WHERE b.question = {$question->id}\n                            AND   a.id = b.datasetdefinition"))) {
         error("Couldn't get the specified dataset for a calculated " . "question! (question: {$question->id}");
     }
     // Choose a random dataset
     $state->options->datasetitem = rand(1, $maxnumber);
     $state->options->dataset = $this->pick_question_dataset($question, $state->options->datasetitem);
     $state->responses = array('' => '');
     return true;
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:13,代码来源:abstractqtype.php


示例6: jeliot_user_outline

/**
 * Return a small object with summary information about what a
 * user has done with a given particular instance of this module
 * Used for user activity reports.
 * $return->time = the time they did it
 * $return->info = a short text description
 *
 * @return null
 * @todo Finish documenting this function
 **/
function jeliot_user_outline($course, $user, $mod, $jeliot)
{
    global $CFG;
    $no_of_times_taken = count_records('jeliot_accesses', 'userid', $user->id, 'jeliotid', $jeliot->id);
    if ($no_of_times_taken > 0) {
        $sql = 'SELECT MAX(accesses.timemodified) as lastime FROM ' . $CFG->prefix . 'jeliot_accesses AS accesses ' . ' WHERE accesses.jeliotid = ' . $jeliot->id . ' AND accesses.userid = ' . $user->id;
        $lasttime = get_field_sql($sql);
        $return->time = $lasttime;
        $return->info = get_string('visualized_n_times', 'jeliot', $no_of_times_taken);
    } else {
        $return->time = time();
        $return->info = get_string('not_visualized', 'jeliot');
    }
    return $return;
}
开发者ID:chriscaragianis,项目名称:jeliot3,代码行数:25,代码来源:lib.php


示例7: forgotpass_validate

function forgotpass_validate(Pieform $form, $values)
{
    // See if the user input an email address or a username. We favour email addresses
    if (!$form->get_error('emailusername')) {
        if (!($authinstance = get_field_sql('SELECT authinstance FROM {usr} WHERE LOWER(email) = ?', array(strtolower($values['emailusername']))))) {
            if (!($authinstance = get_field_sql('SELECT authinstance FROM {usr} WHERE LOWER(username) = ?', array(strtolower($values['emailusername']))))) {
                $form->set_error('emailusername', get_string('forgotpassnosuchemailaddressorusername'));
            }
        }
    }
    if ($form->get_error('emailusername')) {
        return;
    }
    $authobj = AuthFactory::create($authinstance);
    if (!method_exists($authobj, 'change_password')) {
        die_info(get_string('cantchangepassword'));
    }
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:18,代码来源:forgotpass.php


示例8: prevent_double_paid

function prevent_double_paid($course)
{
    global $CFG, $SESSION, $USER;
    $sql = "SELECT id FROM {$CFG->prefix}enrol_authorize WHERE userid = '{$USER->id}' AND courseid = '{$course->id}' ";
    if (empty($CFG->an_test)) {
        // Real mode
        $sql .= 'AND status IN(' . AN_STATUS_AUTH . ',' . AN_STATUS_UNDERREVIEW . ',' . AN_STATUS_APPROVEDREVIEW . ')';
    } else {
        // Test mode
        $sql .= 'AND status=' . AN_STATUS_NONE;
    }
    if ($recid = get_field_sql($sql)) {
        $a = new stdClass();
        $a->orderid = $recid;
        $a->url = "{$CFG->wwwroot}/enrol/authorize/index.php?order={$a->orderid}";
        redirect($a->url, get_string("paymentpending", "enrol_authorize", $a), '10');
        return;
    }
    if (isset($SESSION->ccpaid)) {
        unset($SESSION->ccpaid);
        redirect($CFG->wwwroot . '/login/logout.php?sesskey=' . sesskey());
        return;
    }
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:24,代码来源:localfuncs.php


示例9: report_stats_timeoptions

function report_stats_timeoptions($mode)
{
    global $CFG;
    $tableprefix = $CFG->prefix . 'stats_';
    if ($mode == STATS_MODE_DETAILED) {
        $tableprefix = $CFG->prefix . 'stats_user_';
    }
    $earliestday = get_field_sql('SELECT timeend FROM ' . $tableprefix . 'daily ORDER BY timeend');
    $earliestweek = get_field_sql('SELECT timeend FROM ' . $tableprefix . 'weekly ORDER BY timeend');
    $earliestmonth = get_field_sql('SELECT timeend FROM ' . $tableprefix . 'monthly ORDER BY timeend');
    if (empty($earliestday)) {
        $earliestday = time();
    }
    if (empty($earliestweek)) {
        $earliestweek = time();
    }
    if (empty($earliestmonth)) {
        $earliestmonth = time();
    }
    $now = stats_get_base_daily();
    $lastweekend = stats_get_base_weekly();
    $lastmonthend = stats_get_base_monthly();
    return stats_get_time_options($now, $lastweekend, $lastmonthend, $earliestday, $earliestweek, $earliestmonth);
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:24,代码来源:lib.php


示例10: require_login

    $finishattempt = 1;
}
require_login($course->id, false, $cm);
$coursecontext = get_context_instance(CONTEXT_COURSE, $cm->course);
// course context
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$ispreviewing = has_capability('mod/quiz:preview', $context);
// if no questions have been set up yet redirect to edit.php
if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) {
    redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id);
}
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()) {
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:attempt.php


示例11: xmldb_core_upgrade


//.........这里部分代码省略.........
        drop_table($table);
        $table = new XMLDBTable('artefact_feedback');
        drop_table($table);
        // Add site setting for anonymous comments
        set_config('anonymouscomments', 1);
    }
    if ($oldversion < 2010041900 && !table_exists(new XMLDBTable('site_data'))) {
        // Upgrades for admin stats pages
        // Table for collection of historical stats
        $table = new XMLDBTable('site_data');
        $table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, XMLDB_NOTNULL);
        $table->addFieldInfo('type', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
        $table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', null);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('ctime', 'type'));
        create_table($table);
        // Insert cron jobs to save site data
        $cron = new StdClass();
        $cron->callfunction = 'cron_site_data_weekly';
        $cron->minute = 55;
        $cron->hour = 23;
        $cron->day = '*';
        $cron->month = '*';
        $cron->dayofweek = 6;
        insert_record('cron', $cron);
        $cron = new StdClass();
        $cron->callfunction = 'cron_site_data_daily';
        $cron->minute = 51;
        $cron->hour = 23;
        $cron->day = '*';
        $cron->month = '*';
        $cron->dayofweek = '*';
        insert_record('cron', $cron);
        // Put best guess at installation time into config table.
        set_config('installation_time', get_field_sql("SELECT MIN(ctime) FROM {site_content}"));
        // Save the current time so we know when we started collecting stats
        set_config('stats_installation_time', db_format_timestamp(time()));
        // Add ctime to usr table for daily count of users created
        $table = new XMLDBTable('usr');
        $field = new XMLDBField('ctime');
        $field->setAttributes(XMLDB_TYPE_DATETIME, null, null);
        add_field($table, $field);
        // Add visits column to view table
        $table = new XMLDBTable('view');
        $field = new XMLDBField('visits');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
        // Add table to store daily view visits
        $table = new XMLDBTable('view_visit');
        $table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
        $table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
        $table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
        $table->addIndexInfo('ctimeix', XMLDB_INDEX_NOTUNIQUE, array('ctime'));
        create_table($table);
        // Insert a cron job to check for new versions of Mahara
        $cron = new StdClass();
        $cron->callfunction = 'cron_check_for_updates';
        $cron->minute = rand(0, 59);
        $cron->hour = rand(0, 23);
        $cron->day = '*';
        $cron->month = '*';
        $cron->dayofweek = '*';
        insert_record('cron', $cron);
    }
    if ($oldversion < 2010042600) {
        // @todo: Move to notification/internal
        $table = new XMLDBTable('notification_internal_activity');
开发者ID:patkira,项目名称:mahara,代码行数:67,代码来源:upgrade.php


示例12: get_profile_field

/**
 * Return the value of a profile field for a given user
 *
 * @param integer user id to find the profile field for
 * @param field what profile field you want the value for
 * @returns string the value of the profile field (null if it doesn't exist)
 *
 * @todo, this needs to be better (fix email behaviour)
 */
function get_profile_field($userid, $field)
{
    if ($field == 'email') {
        $value = get_field_sql("\n            SELECT a.title\n            FROM {usr} u\n            JOIN {artefact} a ON (a.title = u.email AND a.owner = u.id)\n            WHERE a.artefacttype = 'email' AND u.id = ?", array($userid));
    } else {
        $value = get_field('artefact', 'title', 'owner', $userid, 'artefacttype', $field);
    }
    if ($value) {
        return $value;
    }
    return null;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:21,代码来源:user.php


示例13: groups_print_course_menu

}
echo '<td class="left">';
groups_print_course_menu($course, $baseurl);
echo '</td>';
if (!isset($hiddenfields['lastaccess'])) {
    // get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
    // we need to make it diferently for normal courses and site course
    if ($context->id != $frontpagectx->id) {
        $minlastaccess = get_field_sql('SELECT min(timeaccess)
                                              FROM ' . $CFG->prefix . 'user_lastaccess
                                             WHERE courseid = ' . $course->id . '
                                               AND timeaccess != 0');
        $lastaccess0exists = record_exists('user_lastaccess', 'courseid', $course->id, 'timeaccess', 0);
    } else {
        $minlastaccess = get_field_sql('SELECT min(lastaccess)
                                              FROM ' . $CFG->prefix . 'user
                                             WHERE lastaccess != 0');
        $lastaccess0exists = record_exists('user', 'lastaccess', 0);
    }
    $now = usergetmidnight(time());
    $timeaccess = array();
    // makes sense for this to go first.
    $timeoptions[0] = get_string('selectperiod');
    // days
    for ($i = 1; $i < 7; $i++) {
        if (strtotime('-' . $i . ' days', $now) >= $minlastaccess) {
            $timeoptions[strtotime('-' . $i . ' days', $now)] = get_string('numdays', 'moodle', $i);
        }
    }
    // weeks
    for ($i = 1; $i < 10; $i++) {
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:index.php


示例14: time

            $now = $fake ? time() - ($realstart - $start) : time();
        }
    }
}
// and now the core ones (much simpler)
$now = $fake ? time() - ($realstart - $start) : time();
$jobs = get_records_select_array('cron', 'nextrun < ? OR nextrun IS NULL', array(db_format_timestamp($now)), '', 'id,callfunction,minute,hour,day,month,dayofweek,' . db_format_tsfield('nextrun'));
if ($jobs) {
    foreach ($jobs as $job) {
        if (!cron_lock($job, $start)) {
            continue;
        }
        // If some other cron instance ran the job while we were messing around,
        // skip it.
        $nextrun = get_field_sql('
            SELECT ' . db_format_tsfield('nextrun') . '
            FROM {cron}
            WHERE id = ?', array($job->id));
        if ($nextrun != $job->nextrun) {
            log_info("Too late to run core {$job->callfunction}; skipping.");
            cron_free($job, $start);
            continue;
        }
        log_info("Running core cron " . $job->callfunction);
        $function = $job->callfunction;
        try {
            $function();
        } catch (Exception $e) {
            log_message($e->getMessage(), LOG_LEVEL_WARN, true, true, $e->getFile(), $e->getLine(), $e->getTrace());
            $output = $e instanceof MaharaException ? $e->render_exception() : $e->getMessage();
            echo "{$output}\n";
            // Don't call handle_exception; try to update next run time and free the lock
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:32,代码来源:cron.php


示例15: feedback_get_page_to_continue

/** 
 *  this returns the position where the user can continue the completing.
 *  @param int $feedbackid
 *  @param int $courseid
 *  @param string $guestid this id will be saved temporary and is unique
 *  @return int the position to continue
 */
function feedback_get_page_to_continue($feedbackid, $courseid = false, $guestid)
{
    global $CFG, $USER;
    //is there any break?
    if (!($allbreaks = feedback_get_all_break_positions($feedbackid))) {
        return false;
    }
    if ($courseid) {
        $courseselect = "fv.course_id = " . $courseid;
    } else {
        $courseselect = "1";
    }
    if ($guestid) {
        $userselect = "AND fc.guestid = '" . $guestid . "'";
        $usergroup = "GROUP BY fc.guestid";
    } else {
        $userselect = "AND fc.userid = " . $USER->id;
        $usergroup = "GROUP BY fc.userid";
    }
    $sql = "SELECT MAX(fi.position)\n                FROM " . $CFG->prefix . "feedback_completedtmp AS fc, " . $CFG->prefix . "feedback_valuetmp AS fv, " . $CFG->prefix . "feedback_item AS fi\n                WHERE fc.id = fv.completed\n                    " . $userselect . "\n                    AND fc.feedback = " . $feedbackid . "\n                    AND " . $courseselect . "\n                    AND fi.id = fv.item\n                " . $usergroup;
    $lastpos = get_field_sql($sql);
    //the index of found pagebreak is the searched pagenumber
    foreach ($allbreaks as $pagenr => $br) {
        if ($lastpos < $br) {
            return $pagenr;
        }
    }
    return count($allbreaks);
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:36,代码来源:lib.php


示例16: has_hidden_grades

 /**
  * Returns the number of grades that are hidden.
  * @param return int Number of hidden grades
  */
 function has_hidden_grades($groupsql = "", $groupwheresql = "")
 {
     global $CFG;
     return get_field_sql("SELECT COUNT(*) FROM {$CFG->prefix}grade_grades g LEFT JOIN " . "{$CFG->prefix}user u ON g.userid = u.id {$groupsql} WHERE itemid = {$this->id} AND hidden = 1 {$groupwheresql}");
 }
开发者ID:r007,项目名称:PMoodle,代码行数:9,代码来源:grade_item.php


示例17: user_comments_allowed

 /**
  * Determine whether a user can write comments on this view
  *
  * If the view doesn't have the allowcomments property set,
  * then we must look at the view_access records to determine
  * whether the user can leave comments.
  *
  * In view_access, allowcomments indicates that the user can
  * comment, however if approvecomments is also set on a particular
  * access record, then all comments can only be private until the
  * view owner decides to make them public.
  *
  * Returns false, 'private', or true
  */
 public function user_comments_allowed(User $user)
 {
     global $SESSION;
     if (!$user->is_logged_in() && !get_config('anonymouscomments')) {
         return false;
     }
     if ($this->get('allowcomments')) {
         return $this->get('approvecomments') ? 'private' : true;
     }
     $userid = $user->get('id');
     $access = self::user_access_records($this->id, $userid);
     $publicviews = get_config('allowpublicviews');
     $publicprofiles = get_config('allowpublicprofiles');
     // a group view won't have an 'owner'
     if ($publicviews && ($ownerobj = $this->get_owner_object())) {
         $owner = new User();
         $owner->find_by_id($ownerobj->id);
         $publicviews = $owner->institution_allows_public_views();
     }
     $allowcomments = false;
     $approvecomments = true;
     $mnettoken = get_cookie('mviewaccess:' . $this->id);
     $usertoken = get_cookie('viewaccess:' . $this->id);
     $cid = $this->collection_id();
     $ctoken = $cid ? get_cookie('caccess:' . $cid) : null;
     if ($access) {
         foreach ($access as $a) {
             if ($a->accesstype == 'public') {
                 if (!$publicviews && (!$publicprofiles || $this->type != 'profile')) {
                     continue;
                 }
             } else {
                 if ($a->token && $a->token != $mnettoken && (!$publicviews || $a->token != $usertoken && $a->token != $ctoken)) {
                     continue;
                 } else {
                     if (!$user->is_logged_in()) {
                         continue;
                     } else {
                         if ($a->accesstype == 'friends') {
                             $owner = $this->get('owner');
                             if (!get_field_sql('
                     SELECT COUNT(*) FROM {usr_friend} f WHERE (usr1=? AND usr2=?) OR (usr1=? AND usr2=?)', array($owner, $userid, $userid, $owner))) {
                                 continue;
                             }
                         }
                     }
                 }
             }
             $objectionable = $this->is_objectionable();
             if ($a->allowcomments && ($objectionable && ($user->get('admin') || $user->is_institutional_admin()) || !$objectionable)) {
                 $allowcomments = $allowcomments || $a->allowcomments;
                 $approvecomments = $approvecomments && $a->approvecomments;
             }
             if (!$approvecomments) {
                 return true;
             }
         }
     }
     if ($allowcomments) {
         return $approvecomments ? 'private' : true;
     }
     return false;
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:77,代码来源:view.php


示例18: define

define('INSTITUTIONALADMIN', 1);
define('JSON', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
json_headers();
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
// Filter for institutional admins:
$instsql = $USER->get('admin') ? '' : ' 
    AND ui.institution IN (' . join(',', array_map('db_quote', array_keys($USER->get('institutions')))) . ')';
// NOTE: the check is not done on the 'active' column here, since suspended
// users are by definition not active. However deleted users are filtered out.
$count = get_field_sql('
    SELECT COUNT(*)
    FROM (
        SELECT u.id
        FROM {usr} u
        LEFT OUTER JOIN {usr_institution} ui ON (ui.usr = u.id)
        WHERE suspendedcusr IS NOT NULL 
        AND deleted = 0 ' . $instsql . '
        GROUP BY u.id
    ) AS a');
$data = get_records_sql_assoc('
    SELECT 
        u.id, u.firstname, u.lastname, u.studentid, u.suspendedctime, u.suspendedreason AS reason,
        ua.firstname AS cusrfirstname, ua.lastname AS cusrlastname
    FROM {usr} u
    LEFT JOIN {usr} ua on (ua.id = u.suspendedcusr)
    LEFT OUTER JOIN {usr_institution} ui ON (ui.usr = u.id)
    WHERE u.suspendedcusr IS NOT NULL
    AND u.deleted = 0 ' . $instsql . '
    GROUP BY
        u.id, u.firstname, u.lastname, u.studentid, u.suspendedctime, u.suspendedreason,
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:32,代码来源:suspended.json.php


示例19: exists

 function exists()
 {
     global $CFG;
     $lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
     return time() - $lastcron > 3600 * 24;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:6,代码来源:health.php


示例20: process_config

 /**
  * process_config
  *
  * @param object $config
  * @return bool true if it will be saved.
  * @access public
  */
 function process_config($config)
 {
     global $CFG;
     $mconfig = get_config('enrol/authorize');
     // site settings
     if (($cost = optional_param('enrol_cost', 5, PARAM_INT)) > 0) {
         set_config('enrol_cost', $cost);
     }
     set_config('enrol_currency', optional_param('enrol_currency', 'USD', PARAM_ALPHA));
     set_config('enrol_mailstudents', optional_param('enrol_mailstudents', 0, PARAM_BOOL));
     set_config('enrol_mailteachers', optional_param('enrol_mailteachers', 0, PARAM_BOOL));
     set_config('enrol_mailadmins', optional_param('enrol_mailadmins', 0, PARAM_BOOL));
     // optional authorize.net settings
     set_config('an_avs', optional_param('an_avs', 0, PARAM_BOOL));
     set_config('an_authcode', optional_param('an_authcode', 0, PARAM_BOOL));
     set_config('an_test', optional_param('an_test', 0, PARAM_BOOL));
     set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL));
     $acceptmethods = optional_param('acceptmethods', get_list_of_payment_methods(), PARAM_ALPHA);
     set_config('an_acceptmethods', implode(',', $acceptmethods));
     $acceptccs = optional_param('acceptccs', array_keys(get_list_of_creditcards()), PARAM_ALPHA);
     set_config('an_acceptccs', implode(',', $acceptccs));
     $acceptechecktypes = optional_param('acceptechecktypes', get_list_of_bank_account_types(), PARAM_ALPHA);
     set_config('an_acceptechecktypes', implode(',', $acceptechecktypes));
     $cutoff_hour = optional_param('an_cutoff_hour', 0, PARAM_INT);
     $cutoff_min = optional_param('an_cutoff_min', 5, PARAM_INT);
     set_config('an_cutoff', $cutoff_hour * 60 + $cutoff_min);
     // cron depencies
     $reviewval = optional_param('an_review', 0, PARAM_BOOL);
     $captureday = optional_param('an_capture_day', 5, PARAM_INT);
     $emailexpired = optional_param('an_emailexpired', 2, PARAM_INT);
     $emailexpiredteacher = optional_param('an_emailexpiredteacher', 0, PARAM_BOOL);
     $sorttype = optional_param('an_sorttype', 'ttl', PARAM_ALPHA);
     $captureday = $captureday > 29 ? 29 : ($captureday < 0 ? 0 : $captureday);
     $emailexpired = $emailexpired > 5 ? 5 : ($emailexpired < 0 ? 0 : $emailexpired);
     if (!empty($reviewval) && ($captureday > 0 || $emailexpired > 0)) {
         $lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
         if (time() - intval($lastcron) > 3600 * 24) {
             return false;
         }
     }
     set_config('an_review', $reviewval);
     set_config('an_capture_day', $captureday);
     set_config('an_emailexpired', $emailexpired);
     set_config('an_emailexpiredteacher', $emailexpiredteacher);
     set_config('an_sorttype', $sorttype);
     // https and openssl library is required
     if (substr($CFG->wwwroot, 0, 5) !== 'https' and empty($CFG->loginhttps) or !check_openssl_loaded()) {
         return false;
     }
     // REQUIRED fields;
     // an_login
     $loginval = optional_param('an_login', '');
     if (empty($loginval) && empty($mconfig->an_login)) {
         return false;
     }
     $loginval = !empty($loginval) ? rc4encrypt($loginval) : strval($mconfig->an_login);
     set_config('an_login', $loginval, 'enrol/authorize');
     // an_tran_key, an_password
     $tranval = optional_param('an_tran_key', '');
     $tranval = !empty($tranval) ? rc4encrypt($tranval) : (isset($mconfig->an_tran_key) ? $mconfig->an_tran_key : '');
     $passwordval = optional_param('an_password', '');
     $passwordval = !empty($passwordval) ? rc4encrypt($passwordval) : (isset($mconfig->an_password) ? $mconfig->an_password : '');
     $deletecurrent = optional_param('delete_current', '0', PARAM_BOOL);
     if (!empty($deletecurrent) and !empty($tranval)) {
         unset_config('an_password', 'enrol/authorize');
         $passwordval = '';
     } elseif (!empty($passwordval)) {
         set_config('an_password', $passwordval, 'enrol/authorize');
     }
     if (empty($tranval) and empty($passwordval)) {
         return false;
     }
     if (!empty($tranval)) {
         set_config('an_tran_key', $tranval, 'enrol/authorize');
     }
     return true;
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:84,代码来源:enrol.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_fields函数代码示例发布时间:2022-05-15
下一篇:
PHP get_field_select函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap