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

PHP set_field_select函数代码示例

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

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



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

示例1: xmldb_qtype_numerical_upgrade

function xmldb_qtype_numerical_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    // In numerical questions, we are changing the 'match anything' answer
    // from the empty string to *, to be like short answer questions.
    if ($result && $oldversion < 2006121500) {
        $result = set_field_select('question_answers', 'answer', '*', sql_compare_text('answer') . " = '" . sql_empty() . "' AND question IN (SELECT id FROM {$CFG->prefix}question WHERE qtype = '" . NUMERICAL . "')");
    }
    return $result;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:11,代码来源:upgrade.php


示例2: increment_page_hits

 /**
  * Increment the hits of a page.
  *
  * @param   int     $wikiid
  * @param   string  $pagename
  * @param   int     $version
  * @param   int     $groupid
  * @param   int     $ownerid
  */
 function increment_page_hits($wikiid, $pagename, $version, $groupid, $ownerid)
 {
     $select = "dfwiki={$wikiid} AND pagename='" . addslashes($pagename) . "' AND version={$version}";
     if (isset($groupid)) {
         $select .= " AND groupid={$groupid}";
     }
     if (isset($ownerid)) {
         $select .= " AND ownerid={$ownerid}";
     }
     // return set_field_select('wiki_pages', 'hits', 'hits+1', $select);
     $hits = get_field_select('wiki_pages', 'hits', $select);
     return set_field_select('wiki_pages', 'hits', $hits + 1, $select);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:22,代码来源:wiki_persistor.php


示例3: form_validate

 // $checked is a subset of the topics in this forum
 form_validate(param_variable('sesskey', null));
 if ($moderator && $type == 'sticky') {
     set_field_select('interaction_forum_topic', 'sticky', 1, 'id IN (' . implode(',', $checked) . ')', array());
     $SESSION->add_ok_msg(get_string('topicstickysuccess', 'interaction.forum'));
 } else {
     if ($moderator && $type == 'unsticky') {
         set_field_select('interaction_forum_topic', 'sticky', 0, 'id IN (' . implode(',', $checked) . ')', array());
         $SESSION->add_ok_msg(get_string('topicunstickysuccess', 'interaction.forum'));
     } else {
         if ($moderator && $type == 'closed') {
             set_field_select('interaction_forum_topic', 'closed', 1, 'id IN (' . implode(',', $checked) . ')', array());
             $SESSION->add_ok_msg(get_string('topicclosedsuccess', 'interaction.forum'));
         } else {
             if ($moderator && $type == 'open') {
                 set_field_select('interaction_forum_topic', 'closed', 0, 'id IN (' . implode(',', $checked) . ')', array());
                 $SESSION->add_ok_msg(get_string('topicopenedsuccess', 'interaction.forum'));
             } else {
                 if ($type == 'subscribe' && !$forum->subscribed) {
                     db_begin();
                     foreach ($checked as $key => $value) {
                         if (!record_exists('interaction_forum_subscription_topic', 'user', $USER->get('id'), 'topic', $value)) {
                             insert_record('interaction_forum_subscription_topic', (object) array('user' => $USER->get('id'), 'topic' => $value, 'key' => PluginInteractionForum::generate_unsubscribe_key()));
                         }
                     }
                     db_commit();
                     $SESSION->add_ok_msg(get_string('topicsubscribesuccess', 'interaction.forum'));
                 } else {
                     if ($type == 'unsubscribe' && !$forum->subscribed) {
                         delete_records_sql('DELETE FROM {interaction_forum_subscription_topic}
         WHERE topic IN (' . implode(',', $checked) . ') AND "user" = ?', array($USER->get('id')));
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:31,代码来源:view.php


示例4: change_language

/** 
 * Change language-specific stuff in the db for a user.  Currently
 * changes the name of the 'assessmentfiles' folder in the user's
 * files area and the views and artefacts tagged for the profile
 * sideblock
 *
 * @param int $userid user id to set preference for
 * @param string $oldlang old language
 * @param string $newlang new language
 */
function change_language($userid, $oldlang, $newlang)
{
    if (get_field('artefact_installed', 'active', 'name', 'file')) {
        safe_require('artefact', 'file');
        ArtefactTypeFolder::change_language($userid, $oldlang, $newlang);
    }
    set_field_select('artefact_tag', 'tag', get_string_from_language($newlang, 'profile'), 'WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE "owner" = ?)', array(get_string_from_language($oldlang, 'profile'), $userid));
    set_field_select('view_tag', 'tag', get_string_from_language($newlang, 'profile'), 'WHERE tag = ? AND "view" IN (SELECT id FROM {view} WHERE "owner" = ?)', array(get_string_from_language($oldlang, 'profile'), $userid));
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:19,代码来源:user.php


示例5: question_move_questions_to_category

/**
 * This function should be considered private to the question bank, it is called from
 * question/editlib.php question/contextmoveq.php and a few similar places to to the work of
 * acutally moving questions and associated data. However, callers of this function also have to
 * do other work, which is why you should not call this method directly from outside the questionbank.
 *
 * @param string $questionids a comma-separated list of question ids.
 * @param integer $newcategory the id of the category to move to.
 */
function question_move_questions_to_category($questionids, $newcategory)
{
    $result = true;
    // Move the questions themselves.
    $result = $result && set_field_select('question', 'category', $newcategory, "id IN ({$questionids})");
    // Move any subquestions belonging to them.
    $result = $result && set_field_select('question', 'category', $newcategory, "parent IN ({$questionids})");
    // TODO Deal with datasets.
    return $result;
}
开发者ID:e-rasvet,项目名称:reader,代码行数:19,代码来源:questionlib.php


示例6: shuffle_cell

 /**
  * helper function for re-ordering block instances within a cell row x column
  * @param int $row     the row
  * @param int $column  the column of the cell to re-order
  * @param int $insert the order we need to insert
  * @param int $remove the order we need to move out of the way
  */
 private function shuffle_cell($row, $column, $insert = 0, $remove = 0)
 {
     /*
     inserting something in the middle from somewhere else (insert and remove)
     we're either reshuffling after a delete, (no insert),
     inserting something in the middle out of nowhere (no remove)
     */
     // inserting and removing
     if (!empty($remove)) {
         // move it out of range (set to 0)
         set_field_select('block_instance', 'order', 0, '"order" = ? AND "view" = ? AND "row" = ? AND "column" = ?', array($remove, $this->get('id'), $row, $column));
         if (!empty($insert)) {
             // shuffle everything up
             $this->shuffle_helper('order', 'up', '>=', $insert, '"row" = ? AND "column" = ?', array($row, $column));
             // now move it back
             set_field_select('block_instance', 'order', $insert, '"order" = ? AND "view" = ? AND "row" = ? AND "column" = ?', array(0, $this->get('id'), $row, $column));
         }
         // shuffle everything down
         $this->shuffle_helper('order', 'down', '>', $remove, '"row" = ? AND "column" = ?', array($row, $column));
     } else {
         if (!empty($insert)) {
             // shuffle everything up
             $this->shuffle_helper('order', 'up', '>=', $insert, '"row" = ? AND "column" = ?', array($row, $column));
         }
     }
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:33,代码来源:view.php


示例7: xmldb_artefact_file_upgrade

function xmldb_artefact_file_upgrade($oldversion = 0)
{
    $status = true;
    if ($oldversion < 2009033000) {
        if (!get_record('artefact_config', 'plugin', 'file', 'field', 'uploadagreement')) {
            insert_record('artefact_config', (object) array('plugin' => 'file', 'field' => 'uploadagreement', 'value' => 1));
            insert_record('artefact_config', (object) array('plugin' => 'file', 'field' => 'usecustomagreement', 'value' => 1));
        }
    }
    if ($oldversion < 2009091700) {
        execute_sql("DELETE FROM {artefact_file_files} WHERE artefact IN (SELECT id FROM {artefact} WHERE artefacttype = 'folder')");
    }
    if ($oldversion < 2009091701) {
        $table = new XMLDBTable('artefact_file_files');
        $key = new XMLDBKey('artefactpk');
        $key->setAttributes(XMLDB_KEY_PRIMARY, array('artefact'));
        add_key($table, $key);
        $table = new XMLDBTable('artefact_file_image');
        $key = new XMLDBKey('artefactpk');
        $key->setAttributes(XMLDB_KEY_PRIMARY, array('artefact'));
        add_key($table, $key);
    }
    if ($oldversion < 2009092300) {
        insert_record('artefact_installed_type', (object) array('plugin' => 'file', 'name' => 'archive'));
        // update old files
        if (function_exists('zip_open')) {
            $files = get_records_select_array('artefact_file_files', "filetype IN ('application/zip', 'application/x-zip')");
            if ($files) {
                $checked = array();
                foreach ($files as $file) {
                    $path = get_config('dataroot') . 'artefact/file/originals/' . $file->fileid % 256 . '/' . $file->fileid;
                    $zip = zip_open($path);
                    if (is_resource($zip)) {
                        $checked[] = $file->artefact;
                        zip_close($zip);
                    }
                }
                if (!empty($checked)) {
                    set_field_select('artefact', 'artefacttype', 'archive', "artefacttype = 'file' AND id IN (" . join(',', $checked) . ')', array());
                }
            }
        }
    }
    if ($oldversion < 2010012702) {
        if ($records = get_records_sql_array("SELECT * FROM {artefact_file_files} WHERE filetype='application/octet-stream'", array())) {
            require_once 'file.php';
            foreach ($records as &$r) {
                $path = get_config('dataroot') . 'artefact/file/originals/' . $r->fileid % 256 . '/' . $r->fileid;
                set_field('artefact_file_files', 'filetype', file_mime_type($path), 'fileid', $r->fileid, 'artefact', $r->artefact);
            }
        }
    }
    if ($oldversion < 2011052500) {
        // Set default quota to 50MB
        set_config_plugin('artefact', 'file', 'defaultgroupquota', 52428800);
    }
    if ($oldversion < 2011070700) {
        // Create an images folder for everyone with a profile icon
        $imagesdir = get_string('imagesdir', 'artefact.file');
        $imagesdirdesc = get_string('imagesdirdesc', 'artefact.file');
        execute_sql("\n            INSERT INTO {artefact} (artefacttype, container, owner, ctime, mtime, atime, title, description, author)\n            SELECT 'folder', 1, owner, current_timestamp, current_timestamp, current_timestamp, ?, ?, owner\n            FROM {artefact} WHERE owner IS NOT NULL AND artefacttype = 'profileicon'\n            GROUP BY owner", array($imagesdir, $imagesdirdesc));
        // Put profileicons into the images folder and update the description
        $profileicondesc = get_string('uploadedprofileicon', 'artefact.file');
        if (is_postgres()) {
            execute_sql("\n                UPDATE {artefact}\n                SET parent = f.folderid, description = ?\n                FROM (\n                    SELECT owner, MAX(id) AS folderid\n                    FROM {artefact}\n                    WHERE artefacttype = 'folder' AND title = ? AND description = ?\n                    GROUP BY owner\n                ) f\n                WHERE artefacttype = 'profileicon' AND {artefact}.owner = f.owner", array($profileicondesc, $imagesdir, $imagesdirdesc));
        } else {
            execute_sql("\n                UPDATE {artefact}, (\n                    SELECT owner, MAX(id) AS folderid\n                    FROM {artefact}\n                    WHERE artefacttype = 'folder' AND title = ? AND description = ?\n                    GROUP BY owner\n                ) f\n                SET parent = f.folderid, description = ?\n                WHERE artefacttype = 'profileicon' AND {artefact}.owner = f.owner", array($imagesdir, $imagesdirdesc, $profileicondesc));
        }
    }
    if ($oldversion < 2011082200) {
        // video file type
        if (!get_record('artefact_installed_type', 'plugin', 'file', 'name', 'video')) {
            insert_record('artefact_installed_type', (object) array('plugin' => 'file', 'name' => 'video'));
        }
        // update existing records
        $videotypes = get_records_sql_array('
            SELECT DISTINCT description
            FROM {artefact_file_mime_types}
            WHERE mimetype ' . db_ilike() . ' \'%video%\'', array());
        if ($videotypes) {
            $mimetypes = array();
            foreach ($videotypes as $type) {
                $mimetypes[] = $type->description;
            }
            $files = get_records_sql_array('
                SELECT *
                FROM {artefact_file_files}
                WHERE filetype IN (
                    SELECT mimetype
                    FROM {artefact_file_mime_types}
                    WHERE description IN (' . join(',', array_map('db_quote', array_values($mimetypes))) . ')
                )', array());
            if ($files) {
                $checked = array();
                foreach ($files as $file) {
                    $checked[] = $file->artefact;
                }
                if (!empty($checked)) {
                    set_field_select('artefact', 'artefacttype', 'video', "artefacttype = 'file' AND id IN (" . join(',', $checked) . ')', array());
                }
//.........这里部分代码省略.........
开发者ID:sarahjcotton,项目名称:mahara,代码行数:101,代码来源:upgrade.php


示例8: group_update


//.........这里部分代码省略.........
    }
    // Institution and shortname cannot be updated (yet)
    unset($new->institution);
    unset($new->shortname);
    foreach (array('id', 'grouptype', 'public', 'request', 'submittableto', 'allowarchives', 'editroles', 'hidden', 'hidemembers', 'hidemembersfrommembers', 'groupparticipationreports') as $f) {
        if (!isset($new->{$f})) {
            $new->{$f} = $old->{$f};
        }
    }
    if (isset($new->jointype)) {
        log_warn("group_update: ignoring supplied jointype");
        unset($new->jointype);
    }
    // If the caller isn't trying to enable open/controlled, use the old values
    if (!isset($new->open)) {
        $new->open = empty($new->controlled) && $old->jointype == 'open';
    }
    if (!isset($new->controlled)) {
        $new->controlled = empty($new->open) && $old->jointype == 'controlled';
    }
    if ($new->open) {
        if ($new->controlled) {
            throw new InvalidArgumentException("group_update: a group cannot have both open and controlled membership");
        }
        $new->request = 0;
        $new->jointype = 'open';
    } else {
        if ($new->controlled) {
            $new->jointype = 'controlled';
        } else {
            $new->jointype = 'approve';
        }
    }
    unset($new->open);
    unset($new->controlled);
    // Ensure only one of invitefriends,suggestfriends gets enabled.
    if (!empty($new->invitefriends)) {
        $new->suggestfriends = 0;
    } else {
        if (!isset($new->invitefriends)) {
            $new->invitefriends = (int) ($old->invitefriends && empty($new->suggestfriends));
        }
    }
    if (!isset($new->suggestfriends)) {
        $new->suggestfriends = $old->suggestfriends;
    }
    $diff = array_diff_assoc((array) $new, (array) $old);
    if (empty($diff)) {
        return null;
    }
    db_begin();
    if (isset($new->members)) {
        group_update_members($new->id, $new->members);
        unset($new->members);
    }
    update_record('group', $new, 'id');
    // Add users who have requested membership of a group that's becoming
    // open
    if ($old->jointype != 'open' && $new->jointype == 'open') {
        $userids = get_column_sql('
            SELECT u.id
            FROM {usr} u JOIN {group_member_request} r ON u.id = r.member
            WHERE r.group = ? AND u.deleted = 0', array($new->id));
        if ($userids) {
            foreach ($userids as $uid) {
                group_add_user($new->id, $uid);
            }
        }
    }
    // Invitations to controlled groups are allowed, but if the admin is
    // changing a group to controlled membership, we'll assume they want
    // want to revoke all the existing invitations.
    if ($old->jointype != 'controlled' && $new->jointype == 'controlled') {
        delete_records('group_member_invite', 'group', $new->id);
    }
    // Remove requests
    if ($old->request && !$new->request) {
        delete_records('group_member_request', 'group', $new->id);
    }
    // When the group type changes, make sure everyone has a valid role.
    safe_require('grouptype', $new->grouptype);
    $allowedroles = call_static_method('GroupType' . ucfirst($new->grouptype), 'get_roles');
    set_field_select('group_member', 'role', 'member', '"group" = ? AND NOT role IN (' . join(',', array_fill(0, count($allowedroles), '?')) . ')', array_merge(array($new->id), $allowedroles));
    // When a group changes from public -> private or vice versa, set the
    // appropriate access permissions on the group homepage view.
    if ($old->public != $new->public) {
        $homepageid = get_field('view', 'id', 'type', 'grouphomepage', 'group', $new->id);
        if ($old->public && !$new->public) {
            delete_records('view_access', 'view', $homepageid, 'accesstype', 'public');
            insert_record('view_access', (object) array('view' => $homepageid, 'accesstype' => 'loggedin', 'ctime' => db_format_timestamp(time())));
        } else {
            if (!$old->public && $new->public) {
                delete_records('view_access', 'view', $homepageid, 'accesstype', 'loggedin');
                insert_record('view_access', (object) array('view' => $homepageid, 'accesstype' => 'public', 'ctime' => db_format_timestamp(time())));
            }
        }
    }
    db_commit();
    return $diff;
}
开发者ID:vohung96,项目名称:mahara,代码行数:101,代码来源:group.php


示例9: game_sudoku_check_number

function game_sudoku_check_number($id, $game, $attempt, $sudoku, $pos, $num)
{
    $textlib = textlib_get_instance();
    $correct = $textlib->substr($sudoku->data, $pos - 1, 1);
    if ($correct != $num) {
        game_sudoku_play($id, $game, $attempt, $sudoku);
        return;
    }
    $leng = $textlib->strlen($sudoku->guess);
    $lend = $textlib->strlen($sudoku->data);
    if ($leng < $lend) {
        $sudoku->guess .= str_repeat(' ', $lend - $leng);
    }
    game_setchar($sudoku->guess, $pos - 1, $correct);
    if (!set_field_select('game_sudoku', 'guess', $sudoku->guess, "id={$sudoku->id}")) {
        error('game_sudoku_check_number: Cannot update table game_sudoku');
    }
    game_sudoku_play($id, $game, $attempt, $sudoku);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:19,代码来源:play.php


示例10: xmldb_core_upgrade


//.........这里部分代码省略.........
        // Add author, authorname to artefact table
        $table = new XMLDBTable('artefact');
        $field = new XMLDBField('author');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10');
        add_field($table, $field);
        $key = new XMLDBKey('authorfk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('author'), 'usr', array('id'));
        add_key($table, $key);
        table_column('artefact', null, 'authorname', 'text', null, null, null, '');
        if (is_postgres()) {
            execute_sql("ALTER TABLE {artefact} ALTER COLUMN authorname DROP DEFAULT");
            set_field('artefact', 'authorname', null);
            execute_sql('UPDATE {artefact} SET authorname = g.name FROM {group} g WHERE "group" = g.id');
            execute_sql("UPDATE {artefact} SET authorname = CASE WHEN institution = 'mahara' THEN ? ELSE i.displayname END FROM {institution} i WHERE institution = i.name", array(get_config('sitename')));
        } else {
            execute_sql("UPDATE {artefact} a, {group} g SET a.authorname = g.name WHERE a.group = g.id");
            execute_sql("UPDATE {artefact} a, {institution} i SET a.authorname = CASE WHEN a.institution = 'mahara' THEN ? ELSE i.displayname END WHERE a.institution = i.name", array(get_config('sitename')));
        }
        execute_sql('UPDATE {artefact} SET author = owner WHERE owner IS NOT NULL');
        execute_sql('ALTER TABLE {artefact} ADD CHECK (
            (author IS NOT NULL AND authorname IS NULL    ) OR
            (author IS NULL     AND authorname IS NOT NULL)
        )');
        // Move feedback activity type to artefact plugin
        execute_sql("\n            UPDATE {activity_type}\n            SET plugintype = 'artefact', pluginname = 'comment'\n            WHERE name = 'feedback'\n        ");
        // Install the comment artefact
        if ($data = check_upgrades('artefact.comment')) {
            upgrade_plugin($data);
        }
        // Flag all views & artefacts to enable/disable comments
        table_column('artefact', null, 'allowcomments', 'integer', 1);
        table_column('view', null, 'allowcomments', 'integer', 1, null, 1);
        // Initially allow comments on blogposts, images, files
        set_field_select('artefact', 'allowcomments', 1, 'artefacttype IN (?,?,?)', array('blogpost', 'image', 'file'));
        // Convert old feedback to comment artefacts
        if ($viewfeedback = get_records_sql_array('
            SELECT f.*, v.id AS viewid, v.owner, v.group, v.institution
            FROM {view_feedback} f JOIN {view} v ON f.view = v.id', array())) {
            foreach ($viewfeedback as &$f) {
                if ($f->author > 0) {
                    $f->authorname = null;
                } else {
                    $f->author = null;
                    if (empty($f->authorname)) {
                        $f->authorname = '?';
                    }
                }
                $artefact = (object) array('artefacttype' => 'comment', 'owner' => $f->owner, 'group' => $f->group, 'institution' => $f->institution, 'author' => $f->author, 'authorname' => $f->authorname, 'title' => get_string('Comment', 'artefact.comment'), 'description' => $f->message, 'ctime' => $f->ctime, 'atime' => $f->ctime, 'mtime' => $f->ctime);
                $aid = insert_record('artefact', $artefact, 'id', true);
                $comment = (object) array('artefact' => $aid, 'private' => 1 - $f->public, 'onview' => $f->viewid);
                insert_record('artefact_comment_comment', $comment);
                if (!empty($f->attachment)) {
                    insert_record('artefact_attachment', (object) array('artefact' => $aid, 'attachment' => $f->attachment));
                }
            }
        }
        // We are throwing away the view information from artefact_feedback.
        // From now on all artefact comments appear together and are not
        // tied to a particular view.
        if ($artefactfeedback = get_records_sql_array('
            SELECT f.*, a.id AS artefactid, a.owner, a.group, a.institution
            FROM {artefact_feedback} f JOIN {artefact} a ON f.artefact = a.id', array())) {
            foreach ($artefactfeedback as &$f) {
                if ($f->author > 0) {
                    $f->authorname = null;
                } else {
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:67,代码来源:upgrade.php


示例11: implode

* @usecase initialize
* @usecase reset
* @usecase igotit
* @usecase ifailed
*/
if ($action == 'initialize') {
    if ($initials = get_records_menu('poodllflashcard_card', "flashcardid = {$flashcard->id} AND userid = {$USER->id} AND deck = {$deck}")) {
        $_SESSION['flashcard_initials'] = implode("','", array_keys($initials));
    }
    unset($_SESSION['flashcard_consumed']);
}
if ($action == 'reset') {
    //Added this isset conditon  Justin 20080828 - seemd to never be set this vsriable
    if (isset($_SESSION['flashcard_initials'])) {
        $initials = $_SESSION['flashcard_initials'];
        set_field_select('poodllflashcard_card', 'deck', $deck, "id IN ('{$initials}')");
    }
    unset($_SESSION['flashcard_consumed']);
}
if ($action == 'igotit') {
    $card->id = required_param('cardid', PARAM_INT);
    $card = get_record('poodllflashcard_card', 'id', $card->id);
    if ($card->deck < $flashcard->decks) {
        $card->deck = $deck + 1;
    } else {
        // if in last deck, consume it !!
        if (array_key_exists('flashcard_consumed', $_SESSION)) {
            $_SESSION['flashcard_consumed'] .= ',' . $card->id;
        } else {
            $_SESSION['flashcard_consumed'] = $card->id;
        }
开发者ID:laiello,项目名称:poodll,代码行数:31,代码来源:playview.controller.php


示例12: commit

 /** 
  * This method updates the contents of the artefact table only.  If your
  * artefact has extra information in other tables, you need to override
  * this method, and call parent::commit() in your own function.
  */
 public function commit()
 {
     if (empty($this->dirty)) {
         return;
     }
     db_begin();
     $fordb = new StdClass();
     foreach (get_object_vars($this) as $k => $v) {
         $fordb->{$k} = $v;
         if (in_array($k, array('mtime', 'ctime', 'atime')) && !empty($v)) {
             $fordb->{$k} = db_format_timestamp($v);
         }
     }
     if (empty($this->id)) {
         $this->id = insert_record('artefact', $fordb, 'id', true);
         if ($this->can_be_logged()) {
             $this->log('created');
         }
         if (!empty($this->parent)) {
             $this->parentdirty = true;
         }
     } else {
         if ($this->can_be_logged()) {
             $this->log('edited');
         }
         update_record('artefact', $fordb, 'id');
     }
     if (!empty($this->group)) {
         $this->save_rolepermissions();
     }
     delete_records('artefact_tag', 'artefact', $this->id);
     if (is_array($this->tags)) {
         foreach (array_unique($this->tags) as $tag) {
             if (empty($tag)) {
                 continue;
             }
             insert_record('artefact_tag', (object) array('artefact' => $this->id, 'tag' => $tag));
         }
     }
     artefact_watchlist_notification($this->id);
     handle_event('saveartefact', $this);
     if (!empty($this->parentdirty)) {
         if ($this->parent) {
             // First set anything relating to this artefact as dirty
             set_field_select('artefact_parent_cache', 'dirty', 1, 'artefact = ? OR parent = ?', array($this->id, $this->id));
             // Then make sure we have a clean record for the new parent
             delete_records('artefact_parent_cache', 'artefact', $this->id, 'parent', $this->parent);
             insert_record('artefact_parent_cache', (object) array('artefact' => $this->id, 'parent' => $this->parent, 'dirty' => 0));
         } else {
             // No parent - no need for any records in the apc then
             delete_records('artefact_parent_cache', 'artefact', $this->id);
         }
     }
     $this->dirty = false;
     $this->deleted = false;
     $this->parentdirty = false;
     db_commit();
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:63,代码来源:lib.php


示例13: upgrade_to_new_roles_ui

function upgrade_to_new_roles_ui()
{
    global $CFG;
    /// New table for storing which roles can be assigned in which contexts.
    /// Define table role_context_levels to be created
    $table = new XMLDBTable('role_context_levels');
    /// Adding fields to table role_context_levels
    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
    $table->addFieldInfo('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
    $table->addFieldInfo('contextlevel', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
    /// Adding keys to table role_context_levels
    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->addKeyInfo('contextlevel-roleid', XMLDB_KEY_UNIQUE, array('contextlevel', 'roleid'));
    $table->addKeyInfo('roleid', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id'));
    /// Conditionally launch create table for role_context_levels
    if (!table_exists($table)) {
        create_table($table);
    }
    /// Now populate the role_context_levels table with the defaults that match
    /// moodle_install_roles, and any other combinations that exist in this system.
    $roleids = get_records_menu('role', '', '', '', 'shortname,id');
    /// Defaults, should match moodle_install_roles.
    $rolecontextlevels = array();
    if (isset($roleids['admin'])) {
        $rolecontextlevels[$roleids['admin']] = get_default_contextlevels('admin');
    }
    if (isset($roleids['coursecreator'])) {
        $rolecontextlevels[$roleids['coursecreator']] = get_default_contextlevels('coursecreator');
    }
    if (isset($roleids['editingteacher'])) {
        $rolecontextlevels[$roleids['editingteacher']] = get_default_contextlevels('editingteacher');
    }
    if (isset($roleids['teacher'])) {
        $rolecontextlevels[$roleids['teacher']] = get_default_contextlevels('teacher');
    }
    if (isset($roleids['student'])) {
        $rolecontextlevels[$roleids['student']] = get_default_contextlevels('student');
    }
    if (isset($roleids['guest'])) {
        $rolecontextlevels[$roleids['guest']] = get_default_contextlevels('guest');
    }
    if (isset($roleids['user'])) {
        $rolecontextlevels[$roleids['user']] = get_default_contextlevels('user');
    }
    /// See what other role assignments are in this database, extend the allowed
    /// lists to allow them too.
    $existingrolecontextlevels = get_recordset_sql('SELECT DISTINCT ra.roleid, con.contextlevel FROM
            {role_assignments} ra JOIN {context} con ON ra.contextid = con.id');
    foreach ($existingrolecontextlevels as $rcl) {
        $rcl = (object) $rcl;
        if (!isset($rolecontextlevels[$rcl->roleid])) {
            $rolecontextlevels[$rcl->roleid] = array($rcl->contextlevel);
        } else {
            if (!in_array($rcl->contextlevel, $rolecontextlevels[$rcl->roleid])) {
                $rolecontextlevels[$rcl->roleid][] = $rcl->contextlevel;
            }
        }
    }
    /// Put the data into the database.
    foreach ($rolecontextlevels as $roleid => $contextlevels) {
        set_role_contextlevels($roleid, $contextlevels);
    }
    /// Remove any role overrides for moodle/site:doanything, or any permissions
    /// for it in a role without legacy:admin.
    $systemcontext = get_context_instance(CONTEXT_SYSTEM);
    // Remove all overrides.
    delete_records_select('role_capabilities', "capability = 'moodle/site:doanything'\n        AND contextid <> {$systemcontext->id}");
    $roletest = '';
    // Get the ids of all the roles that are moodle/legacy:admin.
    if ($adminroleids = get_records_select_menu('role_capabilities', "capability = 'moodle/legacy:admin' AND permission = 1 AND contextid = {$systemcontext->id}", '', 'id, roleid')) {
        $roletest = 'IN ( ' . implode(',', $adminroleids) . ')';
    } else {
        $adminroleids = array();
    }
    delete_records_select('role_capabilities', "roleid NOT {$roletest}\n        AND capability = 'moodle/site:doanything'AND contextid = {$systemcontext->id}");
    set_field_select('role_capabilities', 'permission', 1, "roleid {$roletest} AND capability = 'moodle/site:doanything' AND contextid = {$systemcontext->id}");
    // And for any admin-y roles where moodle/site:doanything is not set, set it.
    $doanythingroleids = get_records_select_menu('role_capabilities', "capability = 'moodle/site:doanything' AND permission = 1 AND contextid = {$systemcontext->id}", '', 'id, roleid');
    foreach ($adminroleids as $roleid) {
        if (!in_array($roleid, $doanythingroleids)) {
            $rc = new stdClass();
            $rc->contextid = $systemcontext->id;
            $rc->roleid = $roleid;
            $rc->capability = 'moodle/site:doanything';
            $rc->permission = 1;
            $rc->timemodified = time();
            insert_record('role_capabilities', $rc);
        }
    }
    set_config('roles_ui_backport_upgraded', 1);
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:91,代码来源:newui.php


示例14: time

 * populated with bookings from any other timetable sytem. It is intended to run
 *  regularly, it will replace any non-edited imported bookings with a new copy but
 * not any that have been edited.
 *
 * It is included by the blocks cron() function each time it runs
 */
//TODO:maybe set it up like tutorlink etc so that it can take uploaded files directly?
//record time for time taken stat
$script_start_time = time();
$cfg_mrbs = get_config('block/mrbs');
//get Moodle config settings for the MRBS block
$output = '';
if (file_exists($cfg_mrbs->cronfile)) {
    if ($mrbs_sessions = fopen($cfg_mrbs->cronfile, 'r')) {
        $output .= get_string('startedimport', 'block_mrbs') . "\n";
        set_field_select('mrbs_entry', 'type', 'M', 'type=\'K\' and start_time > unix_timestamp()');
        // Change old imported (type K) records to temporary type M
        $now = time();
        while ($array = fgetcsv($mrbs_sessions)) {
            //import timetable into mrbs
            $csvrow = new object();
            $csvrow->start_time = clean_param($array[0], PARAM_TEXT);
            $csvrow->end_time = clean_param($array[1], PARAM_TEXT);
            $csvrow->first_date = clean_param($array[2], PARAM_TEXT);
            $csvrow->weekpattern = clean_param($array[3], PARAM_TEXT);
            $csvrow->room_name = clean_param($array[4], PARAM_TEXT);
            $csvrow->username = clean_param($array[5], PARAM_TEXT);
            $csvrow->name = clean_param($array[6], PARAM_TEXT);
            $csvrow->description = clean_param($array[7], PARAM_TEXT);
            list($year, $month, $day) = split('[/]', $csvrow->first_date);
            $date = mktime(12, 00, 00, $month, $day, $year);
开发者ID:rtsfc,项目名称:moodle-block_mrbs,代码行数:31,代码来源:import.php


示例15: rebuild_course_cache

/**
 * Rebuilds the cached list of course activities stored in the database
 * @param int $courseid - id of course to rebuil, empty means all
 * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
 */
function rebuild_course_cache($courseid = 0, $clearonly = false)
{
    global $COURSE;
    if ($clearonly) {
        $courseselect = empty($courseid) ? "" : "id = {$courseid}";
        set_field_select('course', 'modinfo', null, $courseselect);
        // update cached global COURSE too ;-)
        if ($courseid == $COURSE->id) {
            $COURSE->modinfo = null;
        }
        // reset the fast modinfo cache
        $reset = 'reset';
        get_fast_modinfo($reset);
        return;
    }
    if ($courseid) {
        $select = "id = '{$courseid}'";
    } else {
        $select = "";
        @set_time_limit(0);
        // this could take a while!   MDL-10954
    }
    if ($rs = get_recordset_select("course", $select, '', 'id,fullname')) {
        while ($course = rs_fetch_next_record($rs)) {
            $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) . "'!");
            }
            // update cached global COURSE too ;-)
            if ($course->id == $COURSE->id) {
                $COURSE->modinfo = $modinfo;
            }
        }
        rs_close($rs);
    }
    // reset the fast modinfo cache
    $reset = 'reset';
    get_fast_modinfo($reset);
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:44,代码来源:lib.php


示例16: upgrade_fix_incorrect_mnethostids

/**
 * This function will fix the status of the localhost/all records in the mnet_host table
 * checking they exist and adding them if missing + redefine CFG->mnet_localhost_id  and
 * CFG->mnet_all_hosts_id if needed + update all the users having non-existent mnethostid
 * to correct CFG->mnet_localhost_id
 *
 * Implemented because, at some point, specially in old installations upgraded along
 * multiple versions, sometimes the stuff above has ended being inconsistent, causing
 * problems here and there (noticeablely in backup/restore). MDL-16879
 */
function upgrade_fix_incorrect_mnethostids()
{
    global $CFG;
    /// Get current $CFG/mnet_host records
    $old_mnet_localhost_id = !empty($CFG->mnet_localhost_id) ? $CFG->mnet_localhost_id : 0;
    $old_mnet_all_hosts_id = !empty($CFG->mnet_all_hosts_id) ? $CFG->mnet_all_hosts_id : 0;
    $current_mnet_localhost_host = get_record('mnet_host', 'wwwroot', addslashes($CFG->wwwroot));
    /// By wwwroot
    $current_mnet_all_hosts_host = get_record_select('mnet_host', sql_isempty('mnet_host', 'wwwroot', false, false));
    /// By empty wwwroot
    if (!($moodleapplicationid = get_field('mnet_application', 'id', 'name', 'moodle'))) {
        $m = (object) array('name' => 'moodle', 'display_name' => 'Moodle', 'xmlrpc_server_url' => '/mnet/xmlrpc/server.php', 'sso_land_url' => '/auth/mnet/land.php', 'sso_jump_url' => '/auth/mnet/land.php');
        $moodleapplicationid = insert_record('mnet_application', $m);
    }
    /// Create localhost_host if necessary (pretty improbable but better to be 100% in the safe side)
    /// Code stolen from mnet_environment->init
    if (!$current_mnet_localhost_host) {
        $current_mnet_localhost_host = new stdClass();
        $current_mnet_localhost_host->wwwroot = $CFG->wwwroot;
        $current_mnet_localhost_host->ip_address = '';
        $current_mnet_localhost_host->public_key = '';
        $current_mnet_localhost_host->public_key_expires = 0;
        $current_mnet_localhost_host->last_connect_time = 0;
        $current_mnet_localhost_host->last_log_id = 0;
        $current_mnet_localhost_host->deleted = 0;
        $current_mnet_localhost_host->name = '';
        $current_mnet_localhost_host->applicationid = $moodleapplicationid;
        /// Get the ip of the server
        if (empty($_SERVER['SERVER_ADDR'])) {
            /// SERVER_ADDR is only returned by Apache-like webservers
            $count = preg_match("@^(?:http[s]?://)?([A-Z0-9\\-\\.]+).*@i", $current_mnet_localhost_host->wwwroot, $matches);
            $my_hostname = $count > 0 ? $matches[1] : false;
            $my_ip = gethostbyname($my_hostname);
            // Returns unmodified hostname on failure. DOH!
            if ($my_ip == $my_hostname) {
                $current_mnet_localhost_host->ip_address = 'UNKNOWN';
            } else {
                $current_mnet_localhost_host->ip_address = $my_ip;
            }
        } else {
            $current_mnet_localhost_host->ip_address = $_SERVER['SERVER_ADDR'];
        }
        $current_mnet_localhost_host->id = insert_record('mnet_host', $current_mnet_localhost_host, true);
    }
    /// Create all_hosts_host if necessary (pretty improbable but better to be 100% in the safe side)
    /// Code stolen from mnet_environment->init
    if (!$current_mnet_all_hosts_host) {
        $current_mnet_all_hosts_host = new stdClass();
        $current_mnet_all_hosts_host->wwwroot = '';
        $current_mnet_all_hosts_host->ip_address = '';
        $current_mnet_all_hosts_host->public_key = '';
        $current_mnet_all_hosts_host->public_key_expires = 0;
        $current_mnet_all_hosts_host->last_connect_time = 0;
        $current_mnet_all_hosts_host->last_log_id = 0;
        $current_mnet_all_hosts_host->deleted = 0;
        $current_mnet_all_hosts_host->name = 'All Hosts';
        $current_mnet_all_hosts_host->applicationid = $moodleapplicationid;
        $current_mnet_all_hosts_host->id = insert_record('mnet_host', $current_mnet_all_hosts_host, true);
    }
    /// Compare old_mnet_localhost_id and current_mnet_localhost_host
    if ($old_mnet_localhost_id != $current_mnet_localhost_host->id) {
        /// Different = problems
        /// Update $CFG->mnet_localhost_id to correct value
        set_config('mnet_localhost_id', $current_mnet_localhost_host->id);
        /// Delete $old_mnet_localhost_id if exists (users will be assigned to new one below)
        delete_records('mnet_host', 'id', $old_mnet_localhost_id);
    }
    /// Compare old_mnet_all_hosts_id and current_mnet_all_hosts_host
    if ($old_mnet_all_hosts_id != $current_mnet_all_hosts_host->id) {
        /// Different = problems
        /// Update $CFG->mnet_localhost_id to correct value
        set_config('mnet_all_hosts_id', $current_mnet_all_hosts_host->id);
        /// Delete $old_mnet_all_hosts_id if exists
        delete_records('mnet_host', 'id', $old_mnet_all_hosts_id);
    }
    /// Finally, update all the incorrect user->mnethostid to the correct CFG->mnet_localhost_id, preventing UIX dupes
    $hosts = get_records_menu('mnet_host', '', '', '', 'id, id AS id2');
    $hosts_str = implode(', ', $hosts);
    $sql = "SELECT id\n            FROM {$CFG->prefix}user u1\n            WHERE u1.mnethostid NOT IN ({$hosts_str})\n              AND NOT EXISTS (\n                  SELECT 'x'\n                    FROM {$CFG->prefix}user u2\n                   WHERE u2.username = u1.username\n                     AND u2.mnethostid = {$current_mnet_localhost_host->id})"; 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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