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

PHP moodle_strtolower函数代码示例

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

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



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

示例1: validation

 function validation($data, $files)
 {
     global $CFG, $USER, $DB;
     $errors = parent::validation($data, $files);
     $referentiel = $this->_customdata['referentiel'];
     $cm = $this->_customdata['cm'];
     // Valable pour Moodle 2.1 et Moodle 2.2
     //if ($CFG->version < 2011120100) {
     $context = context_module::instance($cm->id);
     //} else {
     // $context = context_module::instance($cm);
     //}
     $id = (int) $data['id'];
     $data['concept'] = trim($data['concept']);
     if ($id) {
         //We are updating an entry, so we compare current session user with
         //existing entry user to avoid some potential problems if secureforms=off
         //Perhaps too much security? Anyway thanks to skodak (Bug 1823)
         $old = $DB->get_record('referentiel_entries', array('id' => $id));
         $ineditperiod = time() - $old->timecreated < $CFG->maxeditingtime || $referentiel->editalways;
         if (!$ineditperiod || $USER->id != $old->userid and !has_capability('mod/referentiel:manageentries', $context)) {
             if ($USER->id != $old->userid) {
                 $errors['concept'] = get_string('errcannoteditothers', 'referentiel');
             } elseif (!$ineditperiod) {
                 $errors['concept'] = get_string('erredittimeexpired', 'referentiel');
             }
         }
         if (!$referentiel->allowduplicatedentries) {
             if ($DB->record_exists_select('referentiel_entries', 'referentielid = :referentielid AND LOWER(concept) = :concept AND id != :id', array('referentielid' => $referentiel->id, 'concept' => moodle_strtolower($data['concept']), 'id' => $id))) {
                 $errors['concept'] = get_string('errconceptalreadyexists', 'referentiel');
             }
         }
     } else {
         if (!$referentiel->allowduplicatedentries) {
             if ($DB->record_exists_select('referentiel_entries', 'referentielid = :referentielid AND LOWER(concept) = :concept', array('referentielid' => $referentiel->id, 'concept' => moodle_strtolower($data['concept'])))) {
                 $errors['concept'] = get_string('errconceptalreadyexists', 'referentiel');
             }
         }
     }
     return $errors;
 }
开发者ID:jfruitet,项目名称:moodle_referentiel,代码行数:41,代码来源:edit_form.php


示例2: validation

 function validation($usernew, $files)
 {
     global $CFG;
     $usernew = (object) $usernew;
     $usernew->username = trim($usernew->username);
     $user = get_record('user', 'id', $usernew->id);
     $err = array();
     if (!empty($usernew->newpassword)) {
         $errmsg = '';
         //prevent eclipse warning
         if (!check_password_policy($usernew->newpassword, $errmsg)) {
             $err['newpassword'] = $errmsg;
         }
     }
     if (empty($usernew->username)) {
         //might be only whitespace
         $err['username'] = get_string('required');
     } else {
         if (!$user or $user->username !== stripslashes($usernew->username)) {
             //check new username does not exist
             if (record_exists('user', 'username', $usernew->username, 'mnethostid', $CFG->mnet_localhost_id)) {
                 $err['username'] = get_string('usernameexists');
             }
             //check allowed characters
             if ($usernew->username !== moodle_strtolower($usernew->username)) {
                 echo 'grrrr';
                 $err['username'] = get_string('usernamelowercase');
             } else {
                 if (empty($CFG->extendedusernamechars)) {
                     $string = eregi_replace("[^(-\\.[:alnum:])]", '', $usernew->username);
                     if ($usernew->username !== $string) {
                         $err['username'] = get_string('alphanumerical');
                     }
                 }
             }
         }
     }
     if (!$user or $user->email !== stripslashes($usernew->email)) {
         if (!validate_email(stripslashes($usernew->email))) {
             $err['email'] = get_string('invalidemail');
         } else {
             if (record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
                 $err['email'] = get_string('emailexists');
             }
         }
     }
     /// Next the customisable profile fields
     $err += profile_validation($usernew, $files);
     if (count($err) == 0) {
         return true;
     } else {
         return $err;
     }
 }
开发者ID:henriquecrang,项目名称:e-UNI,代码行数:54,代码来源:editadvanced_form.php


示例3: main_upgrade

function main_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($oldversion < 2003010101) {
        delete_records("log_display", "module", "user");
        $new->module = "user";
        $new->action = "view";
        $new->mtable = "user";
        $new->field = "CONCAT(firstname,\" \",lastname)";
        insert_record("log_display", $new);
        delete_records("log_display", "module", "course");
        $new->module = "course";
        $new->action = "view";
        $new->mtable = "course";
        $new->field = "fullname";
        insert_record("log_display", $new);
        $new->action = "update";
        insert_record("log_display", $new);
        $new->action = "enrol";
        insert_record("log_display", $new);
    }
    //support user based course creating
    if ($oldversion < 2003032400) {
        execute_sql("CREATE TABLE {$CFG->prefix}user_coursecreators (\n                                  id int8 SERIAL PRIMARY KEY,\n                                  userid int8  NOT NULL default '0'\n                                  )");
    }
    if ($oldversion < 2003041400) {
        table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
    }
    if ($oldversion < 2003042104) {
        // Try to update permissions of all files
        if ($files = get_directory_list($CFG->dataroot)) {
            echo "Attempting to update permissions for all files... ignore any errors.";
            foreach ($files as $file) {
                echo "{$CFG->dataroot}/{$file}<br />";
                @chmod("{$CFG->dataroot}/{$file}", $CFG->directorypermissions);
            }
        }
    }
    if ($oldversion < 2003042400) {
        // Rebuild all course caches, because of changes to do with visible variable
        if ($courses = get_records_sql("SELECT * FROM {$CFG->prefix}course")) {
            require_once "{$CFG->dirroot}/course/lib.php";
            foreach ($courses as $course) {
                $modinfo = serialize(get_array_of_activities($course->id));
                if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
                    notify("Could not cache module information for course '" . format_string($course->fullname) . "'!");
                }
            }
        }
    }
    if ($oldversion < 2003042500) {
        //  Convert all usernames to lowercase.
        $users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user");
        $cerrors = "";
        $rarray = array();
        foreach ($users as $user) {
            // Check for possible conflicts
            $lcname = trim(moodle_strtolower($user->username));
            if (in_array($lcname, $rarray)) {
                $cerrors .= $user->id . "->" . $lcname . '<br/>';
            } else {
                array_push($rarray, $lcname);
            }
        }
        if ($cerrors != '') {
            notify("Error: Cannot convert usernames to lowercase. \n                    Following usernames would overlap (id->username):<br/> {$cerrors} . \n                    Please resolve overlapping errors.");
            $result = false;
        }
        $cerrors = "";
        echo "Checking userdatabase:<br />";
        foreach ($users as $user) {
            $lcname = trim(moodle_strtolower($user->username));
            if ($lcname != $user->username) {
                $convert = set_field("user", "username", $lcname, "id", $user->id);
                if (!$convert) {
                    if ($cerrors) {
                        $cerrors .= ", ";
                    }
                    $cerrors .= $item;
                } else {
                    echo ".";
                }
            }
        }
        if ($cerrors != '') {
            notify("There were errors when converting following usernames to lowercase. \n                   '{$cerrors}' . Sorry, but you will need to fix your database by hand.");
            $result = false;
        }
    }
    if ($oldversion < 2003042700) {
        /// Changing to multiple indexes
        execute_sql(" CREATE INDEX {$CFG->prefix}log_coursemoduleaction_idx ON {$CFG->prefix}log (course,module,action) ");
        execute_sql(" CREATE INDEX {$CFG->prefix}log_courseuserid_idx ON {$CFG->prefix}log (course,userid) ");
    }
    if ($oldversion < 2003042801) {
        execute_sql("CREATE TABLE {$CFG->prefix}course_display (\n                         id SERIAL PRIMARY KEY,\n                         course integer NOT NULL default '0',\n                         userid integer NOT NULL default '0',\n                         display integer NOT NULL default '0'\n                      )");
        execute_sql("CREATE INDEX {$CFG->prefix}course_display_courseuserid_idx ON {$CFG->prefix}course_display (course,userid)");
    }
    if ($oldversion < 2003050400) {
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:postgres7.php


示例4: highlightfast

/**
 * This function will highlight instances of $needle in $haystack
 *
 * It's faster that the above function {@link highlight()} and doesn't care about
 * HTML or anything.
 *
 * @param string $needle The string to search for
 * @param string $haystack The string to search for $needle in
 * @return string The highlighted HTML
 */
function highlightfast($needle, $haystack)
{
    if (empty($needle) or empty($haystack)) {
        return $haystack;
    }
    $parts = explode(moodle_strtolower($needle), moodle_strtolower($haystack));
    if (count($parts) === 1) {
        return $haystack;
    }
    $pos = 0;
    foreach ($parts as $key => $part) {
        $parts[$key] = substr($haystack, $pos, strlen($part));
        $pos += strlen($part);
        $parts[$key] .= '<span class="highlight">' . substr($haystack, $pos, strlen($needle)) . '</span>';
        $pos += strlen($needle);
    }
    return str_replace('<span class="highlight"></span>', '', join('', $parts));
}
开发者ID:hatone,项目名称:moodle,代码行数:28,代码来源:weblib.php


示例5: filter_remove_duplicates

/**
 * @todo Document this function
 * @param array $linkarray
 * @return array
 */
function filter_remove_duplicates($linkarray)
{
    $concepts = array();
    // keep a record of concepts as we cycle through
    $lconcepts = array();
    // a lower case version for case insensitive
    $cleanlinks = array();
    foreach ($linkarray as $key => $filterobject) {
        if ($filterobject->casesensitive) {
            $exists = in_array($filterobject->phrase, $concepts);
        } else {
            $exists = in_array(moodle_strtolower($filterobject->phrase), $lconcepts);
        }
        if (!$exists) {
            $cleanlinks[] = $filterobject;
            $concepts[] = $filterobject->phrase;
            $lconcepts[] = moodle_strtolower($filterobject->phrase);
        }
    }
    return $cleanlinks;
}
开发者ID:raymondAntonio,项目名称:moodle,代码行数:26,代码来源:filterlib.php


示例6: setShowAdvanced

 /**
  * Set whether to show advanced elements in the form on first displaying form. Default is not to
  * display advanced elements in the form until 'Show Advanced' is pressed.
  *
  * You can get the last state of the form and possibly save it for this user by using
  * value 'mform_showadvanced_last' in submitted data.
  *
  * @param boolean $showadvancedNow
  */
 function setShowAdvanced($showadvancedNow = null)
 {
     if ($showadvancedNow === null) {
         if ($this->_showAdvanced !== null) {
             return;
         } else {
             //if setShowAdvanced is called without any preference
             //make the default to not show advanced elements.
             $showadvancedNow = get_user_preferences(moodle_strtolower($this->_formName . '_showadvanced', 0));
         }
     }
     //value of hidden element
     $hiddenLast = optional_param('mform_showadvanced_last', -1, PARAM_INT);
     //value of button
     $buttonPressed = optional_param('mform_showadvanced', 0, PARAM_RAW);
     //toggle if button pressed or else stay the same
     if ($hiddenLast == -1) {
         $next = $showadvancedNow;
     } elseif ($buttonPressed) {
         //toggle on button press
         $next = !$hiddenLast;
     } else {
         $next = $hiddenLast;
     }
     $this->_showAdvanced = $next;
     if ($showadvancedNow != $next) {
         set_user_preference($this->_formName . '_showadvanced', $next);
     }
     $this->setConstants(array('mform_showadvanced_last' => $next));
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:39,代码来源:formslib.php


示例7: update_user_record

 /**
  * will update a local user record from an external source.
  * is a lighter version of the one in moodlelib -- won't do
  * expensive ops such as enrolment
  *
  * If you don't pass $updatekeys, there is a performance hit and
  * values removed from DB won't be removed from moodle.
  *
  * @param string $username username (with system magic quotes)
  */
 function update_user_record($username, $updatekeys = false)
 {
     global $CFG;
     //just in case check text case
     $username = trim(moodle_strtolower($username));
     // get the current user record
     $user = get_record('user', 'username', $username, 'mnethostid', $CFG->mnet_localhost_id);
     if (empty($user)) {
         // trouble
         error_log("Cannot update non-existent user: {$username}");
         print_error('auth_dbusernotexist', 'auth', $username);
         die;
     }
     // Ensure userid is not overwritten
     $userid = $user->id;
     if ($newinfo = $this->get_userinfo($username)) {
         $newinfo = truncate_userinfo($newinfo);
         if (empty($updatekeys)) {
             // all keys? this does not support removing values
             $updatekeys = array_keys($newinfo);
         }
         foreach ($updatekeys as $key) {
             if (isset($newinfo[$key])) {
                 $value = $newinfo[$key];
             } else {
                 $value = '';
             }
             if (!empty($this->config->{'field_updatelocal_' . $key})) {
                 if ($user->{$key} != $value) {
                     // only update if it's changed
                     set_field('user', $key, addslashes($value), 'id', $userid);
                 }
             }
         }
     }
     return get_record_select('user', "id = {$userid} AND deleted = 0");
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:47,代码来源:auth.php


示例8: validation

 function validation($data, $files)
 {
     global $CFG, $DB;
     $errors = parent::validation($data, $files);
     $authplugin = get_auth_plugin($CFG->registerauth);
     if ($DB->record_exists('user', array('username' => $data['username'], 'mnethostid' => $CFG->mnet_localhost_id))) {
         $errors['username'] = get_string('usernameexists');
     } else {
         //check allowed characters
         if ($data['username'] !== moodle_strtolower($data['username'])) {
             $errors['username'] = get_string('usernamelowercase');
         } else {
             if ($data['username'] !== clean_param($data['username'], PARAM_USERNAME)) {
                 $errors['username'] = get_string('invalidusername');
             }
         }
     }
     //check if user exists in external db
     //TODO: maybe we should check all enabled plugins instead
     if ($authplugin->user_exists($data['username'])) {
         $errors['username'] = get_string('usernameexists');
     }
     if (!validate_email($data['email'])) {
         $errors['email'] = get_string('invalidemail');
     } else {
         if ($DB->record_exists('user', array('email' => $data['email']))) {
             $errors['email'] = get_string('emailexists') . ' <a href="forgot_password.php">' . get_string('newpassword') . '?</a>';
         }
     }
     if (empty($data['email2'])) {
         $errors['email2'] = get_string('missingemail');
     } else {
         if ($data['email2'] != $data['email']) {
             $errors['email2'] = get_string('invalidemail');
         }
     }
     if (!isset($errors['email'])) {
         if ($err = email_is_not_allowed($data['email'])) {
             $errors['email'] = $err;
         }
     }
     $errmsg = '';
     if (!check_password_policy($data['password'], $errmsg)) {
         $errors['password'] = $errmsg;
     }
     if ($this->signup_captcha_enabled()) {
         $recaptcha_element = $this->_form->getElement('recaptcha_element');
         if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) {
             $challenge_field = $this->_form->_submitValues['recaptcha_challenge_field'];
             $response_field = $this->_form->_submitValues['recaptcha_response_field'];
             if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) {
                 $errors['recaptcha'] = $result;
             }
         } else {
             $errors['recaptcha'] = get_string('missingrecaptchachallengefield');
         }
     }
     return $errors;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:59,代码来源:signup_form.php


示例9: update_user_record

/**
 * Will update a local user record from an external source
 *
 * @uses $CFG
 * @param string $username New user's username to add to record
 * @return user A {@link $USER} object
 */
function update_user_record($username, $authplugin)
{
    $username = trim(moodle_strtolower($username));
    /// just in case check text case
    $oldinfo = get_record('user', 'username', $username, '', '', '', '', 'username, auth');
    $userauth = get_auth_plugin($oldinfo->auth);
    if ($newinfo = $userauth->get_userinfo($username)) {
        $newinfo = truncate_userinfo($newinfo);
        foreach ($newinfo as $key => $value) {
            if ($key === 'username') {
                // 'username' is not a mapped updateable/lockable field, so skip it.
                continue;
            }
            $confval = $userauth->config->{'field_updatelocal_' . $key};
            $lockval = $userauth->config->{'field_lock_' . $key};
            if (empty($confval) || empty($lockval)) {
                continue;
            }
            if ($confval === 'onlogin') {
                $value = addslashes($value);
                // MDL-4207 Don't overwrite modified user profile values with
                // empty LDAP values when 'unlocked if empty' is set. The purpose
                // of the setting 'unlocked if empty' is to allow the user to fill
                // in a value for the selected field _if LDAP is giving
                // nothing_ for this field. Thus it makes sense to let this value
                // stand in until LDAP is giving a value for this field.
                if (!(empty($value) && $lockval === 'unlockedifempty')) {
                    set_field('user', $key, $value, 'username', $username) || error_log("Error updating {$key} for {$username}");
                }
            }
        }
    }
    return get_complete_user_data('username', $username);
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:41,代码来源:moodlelib.php


示例10: update_user_record

/**
 * Will update a local user record from an external source.
 * (MNET users can not be updated using this method!)
 *
 * @param string $username user's username to update the record
 * @return stdClass A complete user object
 */
function update_user_record($username)
{
    global $DB, $CFG;
    $username = trim(moodle_strtolower($username));
    /// just in case check text case
    $oldinfo = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id), '*', MUST_EXIST);
    $newuser = array();
    $userauth = get_auth_plugin($oldinfo->auth);
    if ($newinfo = $userauth->get_userinfo($username)) {
        $newinfo = truncate_userinfo($newinfo);
        foreach ($newinfo as $key => $value) {
            $key = strtolower($key);
            if (!property_exists($oldinfo, $key) or $key === 'username' or $key === 'id' or $key === 'auth' or $key === 'mnethostid' or $key === 'deleted') {
                // unknown or must not be changed
                continue;
            }
            $confval = $userauth->config->{'field_updatelocal_' . $key};
            $lockval = $userauth->config->{'field_lock_' . $key};
            if (empty($confval) || empty($lockval)) {
                continue;
            }
            if ($confval === 'onlogin') {
                // MDL-4207 Don't overwrite modified user profile values with
                // empty LDAP values when 'unlocked if empty' is set. The purpose
                // of the setting 'unlocked if empty' is to allow the user to fill
                // in a value for the selected field _if LDAP is giving
                // nothing_ for this field. Thus it makes sense to let this value
                // stand in until LDAP is giving a value for this field.
                if (!(empty($value) && $lockval === 'unlockedifempty')) {
                    if ((string) $oldinfo->{$key} !== (string) $value) {
                        $newuser[$key] = (string) $value;
                    }
                }
            }
        }
        if ($newuser) {
            $newuser['id'] = $oldinfo->id;
            $DB->update_record('user', $newuser);
            // fetch full user record for the event, the complete user data contains too much info
            // and we want to be consistent with other places that trigger this event
            events_trigger('user_updated', $DB->get_record('user', array('id' => $oldinfo->id)));
        }
    }
    return get_complete_user_data('id', $oldinfo->id);
}
开发者ID:hitphp,项目名称:moodle,代码行数:52,代码来源:moodlelib.php


示例11: glossary_sort_entries

/**
 *
 * @param object $entry0
 * @param object $entry1
 * @return int [-1 | 0 | 1]
 */
function glossary_sort_entries ( $entry0, $entry1 ) {

    if ( moodle_strtolower(ltrim($entry0->concept)) < moodle_strtolower(ltrim($entry1->concept)) ) {
        return -1;
    } elseif ( moodle_strtolower(ltrim($entry0->concept)) > moodle_strtolower(ltrim($entry1->concept)) ) {
        return 1;
    } else {
        return 0;
    }
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:16,代码来源:lib.php


示例12: print_courses

             print_courses(0);
             echo html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipavailablecourses'));
         }
     }
     break;
 case FRONTPAGECATEGORYNAMES:
     echo html_writer::tag('a', get_string('skipa', 'access', moodle_strtolower(get_string('categories'))), array('href' => '#skipcategories', 'class' => 'skip-block'));
     echo $OUTPUT->heading(get_string('categories'), 2, 'headingblock header');
     echo $OUTPUT->box_start('generalbox categorybox');
     print_whole_category_list(NULL, NULL, NULL, -1, false);
     echo $OUTPUT->box_end();
     print_course_search('', false, 'short');
     echo html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipcategories'));
     break;
 case FRONTPAGECATEGORYCOMBO:
     echo html_writer::tag('a', get_string('skipa', 'access', moodle_strtolower(get_string('courses'))), array('href' => '#skipcourses', 'class' => 'skip-block'));
     echo $OUTPUT->heading(get_string('courses'), 2, 'headingblock header');
     $renderer = $PAGE->get_renderer('core', 'course');
     // if there are too many courses, budiling course category tree could be slow,
     // users should go to course index page to see the whole list.
     $coursecount = $DB->count_records('course');
     if (empty($CFG->numcoursesincombo)) {
         // if $CFG->numcoursesincombo hasn't been set, use default value 500
         $CFG->numcoursesincombo = 500;
     }
     if ($coursecount > $CFG->numcoursesincombo) {
         $link = new moodle_url('/course/');
         echo $OUTPUT->notification(get_string('maxnumcoursesincombo', 'moodle', array('link' => $link->out(), 'maxnumofcourses' => $CFG->numcoursesincombo, 'numberofcourses' => $coursecount)));
     } else {
         echo $renderer->course_category_tree(get_course_category_tree());
     }
开发者ID:raymondAntonio,项目名称:moodle,代码行数:31,代码来源:index.php


示例13: process_config


//.........这里部分代码省略.........
        }
        if (!isset($config->ldap_version)) {
            $config->ldap_version = '3';
        }
        if (!isset($config->objectclass)) {
            $config->objectclass = '';
        }
        if (!isset($config->memberattribute)) {
            $config->memberattribute = '';
        }
        if (!isset($config->memberattribute_isdn)) {
            $config->memberattribute_isdn = '';
        }
        if (!isset($config->creators)) {
            $config->creators = '';
        }
        if (!isset($config->create_context)) {
            $config->create_context = '';
        }
        if (!isset($config->expiration)) {
            $config->expiration = '';
        }
        if (!isset($config->expiration_warning)) {
            $config->expiration_warning = '10';
        }
        if (!isset($config->expireattr)) {
            $config->expireattr = '';
        }
        if (!isset($config->gracelogins)) {
            $config->gracelogins = '';
        }
        if (!isset($config->graceattr)) {
            $config->graceattr = '';
        }
        if (!isset($config->auth_user_create)) {
            $config->auth_user_create = '';
        }
        if (!isset($config->forcechangepassword)) {
            $config->forcechangepassword = 0;
        }
        if (!isset($config->stdchangepassword)) {
            $config->stdchangepassword = 0;
        }
        if (!isset($config->passtype)) {
            $config->passtype = 'plaintext';
        }
        if (!isset($config->changepasswordurl)) {
            $config->changepasswordurl = '';
        }
        if (!isset($config->removeuser)) {
            $config->removeuser = AUTH_REMOVEUSER_KEEP;
        }
        if (!isset($config->ntlmsso_enabled)) {
            $config->ntlmsso_enabled = 0;
        }
        if (!isset($config->ntlmsso_subnet)) {
            $config->ntlmsso_subnet = '';
        }
        if (!isset($config->ntlmsso_ie_fastpath)) {
            $config->ntlmsso_ie_fastpath = 0;
        }
        if (!isset($config->ntlmsso_type)) {
            $config->ntlmsso_type = 'ntlm';
        }

        // Save settings
        set_config('host_url', trim($config->host_url), $this->pluginconfig);
        set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig);
        set_config('contexts', trim($config->contexts), $this->pluginconfig);
        set_config('user_type', moodle_strtolower(trim($config->user_type)), $this->pluginconfig);
        set_config('user_attribute', moodle_strtolower(trim($config->user_attribute)), $this->pluginconfig);
        set_config('search_sub', $config->search_sub, $this->pluginconfig);
        set_config('opt_deref', $config->opt_deref, $this->pluginconfig);
        set_config('preventpassindb', $config->preventpassindb, $this->pluginconfig);
        set_config('bind_dn', trim($config->bind_dn), $this->pluginconfig);
        set_config('bind_pw', $config->bind_pw, $this->pluginconfig);
        set_config('ldap_version', $config->ldap_version, $this->pluginconfig);
        set_config('objectclass', trim($config->objectclass), $this->pluginconfig);
        set_config('memberattribute', moodle_strtolower(trim($config->memberattribute)), $this->pluginconfig);
        set_config('memberattribute_isdn', $config->memberattribute_isdn, $this->pluginconfig);
        set_config('creators', trim($config->creators), $this->pluginconfig);
        set_config('create_context', trim($config->create_context), $this->pluginconfig);
        set_config('expiration', $config->expiration, $this->pluginconfig);
        set_config('expiration_warning', trim($config->expiration_warning), $this->pluginconfig);
        set_config('expireattr', moodle_strtolower(trim($config->expireattr)), $this->pluginconfig);
        set_config('gracelogins', $config->gracelogins, $this->pluginconfig);
        set_config('graceattr', moodle_strtolower(trim($config->graceattr)), $this->pluginconfig);
        set_config('auth_user_create', $config->auth_user_create, $this->pluginconfig);
        set_config('forcechangepassword', $config->forcechangepassword, $this->pluginconfig);
        set_config('stdchangepassword', $config->stdchangepassword, $this->pluginconfig);
        set_config('passtype', $config->passtype, $this->pluginconfig);
        set_config('changepasswordurl', trim($config->changepasswordurl), $this->pluginconfig);
        set_config('removeuser', $config->removeuser, $this->pluginconfig);
        set_config('ntlmsso_enabled', (int)$config->ntlmsso_enabled, $this->pluginconfig);
        set_config('ntlmsso_subnet', trim($config->ntlmsso_subnet), $this->pluginconfig);
        set_config('ntlmsso_ie_fastpath', (int)$config->ntlmsso_ie_fastpath, $this->pluginconfig);
        set_config('ntlmsso_type', $config->ntlmsso_type, 'auth/ldap');

        return true;
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:auth.php


示例14: remove_excess_backups

    /**
     * Removes excess backups from the external system and the local file system.
     *
     * The number of backups keep comes from $config->backup_auto_keep
     *
     * @param stdClass $course
     * @return bool
     */
    public static function remove_excess_backups($course) {
        $config = get_config('backup');
        $keep =     (int)$config->backup_auto_keep;
        $storage =  $config->backup_auto_storage;
        $dir =      $config->backup_auto_destination;

        $backupword = str_replace(' ', '_', moodle_strtolower(get_string('backupfilename')));
        $backupword = trim(clean_filename($backupword), '_');

        if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
            $dir = null;
        }

        // Clean up excess backups in the course backup filearea
        if ($storage == 0 || $storage == 2) {
            $fs = get_file_storage();
            $context = get_context_instance(CONTEXT_COURSE, $course->id);
            $component = 'backup';
            $filearea = 'automated';
            $itemid = 0;
            $files = array();
            // Store all the matching files into timemodified => stored_file array
            foreach ($fs->get_area_files($context->id, $component, $filearea, $itemid) as $file) {
                if (strpos($file->get_filename(), $backupword) !== 0) {
                    continue;
                }
                $files[$file->get_timemodified()] = $file;
            }
            if (count($files) <= $keep) {
                // There are less matching files than the desired number to keep
                // do there is nothing to clean up.
                return 0;
            }
            // Sort by keys descending (newer to older filemodified)
            krsort($files);
            $remove = array_splice($files, $keep);
            foreach ($remove as $file) {
                $file->delete();
            }
            //mtrace('Removed '.count($remove).' old backup file(s) from the automated filearea');
        }

        // Clean up excess backups in the specified external directory
        if (!empty($dir) && ($storage == 1 || $storage == 2)) {
            // Calculate backup filename regex, ignoring the date/time/info parts that can be
            // variable, depending of languages, formats and automated backup settings
            $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$course->id . '-';
            $regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#';

            // Store all the matching files into fullpath => timemodified array
            $files = array();
            foreach (scandir($dir) as $file) {
                if (preg_match($regex, $file, $matches)) {
                    $files[$file] = filemtime($dir . '/' . $file);
                }
            }
            if (count($files) <= $keep) {
                // There are less matching files than the desired number to keep
                // do there is nothing to clean up.
                return 0;
            }
            // Sort by values descending (newer to older filemodified)
            arsort($files);
            $remove = array_splice($files, $keep);
            foreach (array_keys($remove) as $file) {
                unlink($dir . '/' . $file);
            }
            //mtrace('Removed '.count($remove).' old backup file(s) from external directory');
        }

        return true;
    }
开发者ID:nuckey,项目名称:moodle,代码行数:80,代码来源:backup_cron_helper.class.php


示例15: data_submitted

            } else {
                $frm = data_submitted($loginurl);
            }
        } else {
            $frm = data_submitted($loginurl);
        }
    }
}
/// Check if the user has actually submitted login data to us
if (empty($CFG->usesid) and $testcookies and get_moodle_cookie() == '') {
    // Login without cookie when test requested
    $errormsg = get_string("cookiesnotenabled");
} else {
    if ($frm) {
        // Login WITH cookies
        $frm->username = trim(moodle_strtolower($frm->username));
        if (is_enabled_auth('none') && empty($CFG->extendedusernamechars)) {
            $string = eregi_replace("[^(-\\.[:alnum:])]", "", $frm->username);
            if (strcmp($frm->username, $string)) {
                $errormsg = get_string('username') . ': ' . get_string("alphanumerical");
                $user = null;
            }
        }
        if ($user) {
            //user already supplied by aut plugin prelogin hook
        } else {
            if ($frm->username == 'guest' and empty($CFG->guestloginbutton)) {
                $user = false;
                /// Can't log in as guest if guest button is disabled
                $frm = false;
            } else {
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:index.php


示例16: xmldb_main_upgrade


//.........这里部分代码省略.........
        $table = new XMLDBTable('course_modules');
        $key = new XMLDBKey('groupingid');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groupings', array('id'));
        $result = $result && add_key($table, $key);
        upgrade_main_savepoint($result, 2007081303);
    }
    if ($result && $oldversion < 2007082300) {
        /// Define field ordering to be added to tag_instance table
        $table = new XMLDBTable('tag_instance');
        $field = new XMLDBField('ordering');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'itemid');
        /// Launch add field rawname
        $result = $result && add_field($table, $field);
        upgrade_main_savepoint($result, 2007082300);
    }
    if ($result && $oldversion < 2007082700) {
        /// Define field timemodified to be added to tag_instance
        $table = new XMLDBTable('tag_instance');
        $field = new XMLDBField('timemodified');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'ordering');
        /// Launch add field timemodified
        $result = $result && add_field($table, $field);
        upgrade_main_savepoint($result, 2007082700);
    }
    /// migrate all tags table to tag - this code MUST use SQL only,
    /// because if the db structure changes the library functions will fail in future
    if ($result && $oldversion < 2007082701) {
        $tagrefs = array();
        // $tagrefs[$oldtagid] = $newtagid
        if ($rs = get_recordset('tags')) {
            $db->debug = false;
            while ($oldtag = rs_fetch_next_record($rs)) {
                $raw_normalized = clean_param($oldtag->text, PARAM_TAG);
                $normalized = moodle_strtolower($raw_normalized);
                // if this tag does not exist in tag table yet
                if (!($newtag = get_record('tag', 'name', addslashes($normalized), '', '', '', '', 'id'))) {
                    $itag = new object();
                    $itag->name = $normalized;
                    $itag->rawname = $raw_normalized;
                    $itag->userid = $oldtag->userid;
                    $itag->timemodified = time();
                    $itag->descriptionformat = 0;
                    // default format
                    if ($oldtag->type == 'official') {
                        $itag->tagtype = 'official';
                    } else {
                        $itag->tagtype = 'default';
                    }
                    if ($idx = insert_record('tag', addslashes_recursive($itag))) {
                        $tagrefs[$oldtag->id] = $idx;
                    }
                    // if this tag is already used by tag table
                } else {
                    $tagrefs[$oldtag->id] = $newtag->id;
                }
            }
            $db->debug = true;
            rs_close($rs);
        }
        // fetch all the tag instances and migrate them as well
        if ($rs = get_recordset('blog_tag_instance')) {
            $db->debug = false;
            while ($blogtag = rs_fetch_next_record($rs)) {
                if (array_key_exists($blogtag->tagid, $tagrefs)) {
                    $tag_instance = new object();
                    $tag_instance->tagid = $tagrefs[$blogtag->tagid];
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:67,代码来源:upgrade.php


示例17: print_error

        if ($category->glossaryid != $glossary->id) {
            print_error('invalidid', 'glossary');
        }
    } else {
        print_error('invalidcategoryid');
    }
}
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/glossary:managecategories', $context);
$strglossaries = get_string("modulenameplural", "glossary");
$strglossary = get_string("modulename", "glossary");
$PAGE->navbar->add($strglossaries, new moodle_url('/mod/glossary/index.php', array('id' => $course->id)));
$PAGE->navbar->add(get_string("categories", "glossary"));
if (!empty($action)) {
    $navaction = get_string($action) . " " . moodle_strtolower(get_string("category", "glossary"));
    $PAGE->navbar->add($navaction);
}
$PAGE->set_title(format_string($glossary->name));
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
if ($hook > 0) {
    if ($action == "edit") {
        if ($confirm) {
            $action = "";
            $cat = new stdClass();
            $cat->id = $hook;
            $cat->name = $name;
            $cat->usedynalink = $usedynalink;
            $DB->update_record("glossary_categories", $cat);
            add_to_log($course->id, "glossary", "edit category", "editcategories.php?id={$cm->id}", $hook, $cm->id);
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:editcategories.php


示例18: unset


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP mosArrayToInts函数代码示例发布时间:2022-05-15
下一篇:
PHP moodle_setlocale函数代码示例发布时间: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