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

PHP get_records_array函数代码示例

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

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



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

示例1: deletefontform_submit

function deletefontform_submit(Pieform $form, $values)
{
    global $SESSION;
    $fontname = $values['font'];
    $result = delete_records('skin_fonts', 'name', $fontname);
    if ($result == false) {
        $SESSION->add_error_msg(get_string('cantdeletefont', 'skin'));
    } else {
        // Check to see if the font is being used in a skin. If it is remove it from
        // the skin's viewskin data
        $skins = get_records_array('skin');
        if (is_array($skins)) {
            foreach ($skins as $skin) {
                $options = unserialize($skin->viewskin);
                foreach ($options as $key => $option) {
                    if (preg_match('/font_family/', $key) && $option == $fontname) {
                        require_once get_config('docroot') . 'lib/skin.php';
                        $skinobj = new Skin($skin->id);
                        $viewskin = $skinobj->get('viewskin');
                        $viewskin[$key] = 'Arial';
                        // the default font
                        $skinobj->set('viewskin', $viewskin);
                        $skinobj->commit();
                    }
                }
            }
        }
        // Also delete all the files in the appropriate folder and the folder itself...
        $fontpath = get_config('dataroot') . 'skins/fonts/' . $fontname;
        recurse_remove_dir($fontpath);
        $SESSION->add_ok_msg(get_string('fontdeleted', 'skin'));
    }
    redirect('/admin/site/fonts.php');
}
开发者ID:patkira,项目名称:mahara,代码行数:34,代码来源:delete.php


示例2: xmldb_blocktype_openbadgedisplayer_upgrade

function xmldb_blocktype_openbadgedisplayer_upgrade($oldversion = 0)
{
    if ($oldversion < 2015062301) {
        $blocks = get_records_array('block_instance', 'blocktype', 'openbadgedisplayer');
        if (is_array($blocks)) {
            foreach ($blocks as $block) {
                $configdata = unserialize($block->configdata);
                if (isset($configdata['badgegroup'])) {
                    // Append source to legacy values
                    if (is_string($configdata['badgegroup'])) {
                        $configdata['badgegroup'] = 'backpack:' . $configdata['badgegroup'];
                    } else {
                        if (is_array($configdata['badgegroup'])) {
                            foreach ($configdata['badgegroup'] as &$group) {
                                $group = str_replace('https://openbadgepassport.com/', 'passport', $group);
                                $group = str_replace('https://backpack.openbadges.org/', 'backpack', $group);
                            }
                        }
                    }
                    $block->configdata = serialize($configdata);
                    update_record('block_instance', $block, 'id');
                }
            }
        }
    }
    return true;
}
开发者ID:ninelanterns,项目名称:mahara-openbadgedisplayer,代码行数:27,代码来源:upgrade.php


示例3: xmldb_interaction_forum_upgrade

function xmldb_interaction_forum_upgrade($oldversion = 0)
{
    if ($oldversion < 2009062300) {
        foreach (array('topic', 'forum') as $type) {
            log_debug("Subscription upgrade for {$type}s");
            // Add missing primary key to the subscription tables
            // Step 1: remove duplicates
            if ($dupes = get_records_sql_array('
                SELECT "user", ' . $type . ', COUNT(*)
                FROM {interaction_forum_subscription_' . $type . '}
                GROUP BY "user", ' . $type . '
                HAVING COUNT(*) > 1', array())) {
                // We found duplicate subscriptions to a topic/forum
                foreach ($dupes as $dupe) {
                    log_debug("interaction.forum: Removing duplicate {$type} subscription for {$dupe->user}");
                    delete_records('interaction_forum_subscription_' . $type, 'user', $dupe->user, $type, $dupe->{$type});
                    insert_record('interaction_forum_subscription_' . $type, (object) array('user' => $dupe->user, $type => $dupe->{$type}));
                }
            }
            // Step 2: add the actual key
            $table = new XMLDBTable('interaction_forum_subscription_' . $type);
            $key = new XMLDBKey('primary');
            $key->setAttributes(XMLDB_KEY_PRIMARY, array('user', $type));
            add_key($table, $key);
            // Add a 'key' column, used for unsubscriptions
            $field = new XMLDBField('key');
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, null);
            add_field($table, $field);
            $key = new XMLDBKey('keyuk');
            $key->setAttributes(XMLDB_KEY_UNIQUE, array('key'));
            add_key($table, $key);
            // Populate the key column
            if ($records = get_records_array('interaction_forum_subscription_' . $type, '', '', '', '"user", ' . $type)) {
                foreach ($records as $where) {
                    $new = (object) array('user' => $where->user, $type => $where->{$type}, 'key' => dechex(mt_rand()));
                    update_record('interaction_forum_subscription_' . $type, $new, $where);
                }
            }
            // Now make the key column not null
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, XMLDB_NOTNULL);
            change_field_notnull($table, $field);
        }
    }
    if ($oldversion < 2009081700) {
        if (!get_record('interaction_config', 'plugin', 'forum', 'field', 'postdelay')) {
            insert_record('interaction_config', (object) array('plugin' => 'forum', 'field' => 'postdelay', 'value' => 30));
        }
    }
    if ($oldversion < 2009081800) {
        $subscription = (object) array('plugin' => 'forum', 'event' => 'creategroup', 'callfunction' => 'create_default_forum');
        ensure_record_exists('interaction_event_subscription', $subscription, $subscription);
    }
    return true;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:54,代码来源:upgrade.php


示例4: add_links

 public function add_links()
 {
     parent::add_links();
     // check for blog posts this file may be attached to
     if (!($posts = get_records_array('artefact_attachment', 'attachment', $this->artefact->get('id')))) {
         return;
     }
     foreach ($posts as $p) {
         $post = artefact_instance_from_id($p->artefact);
         $this->add_artefact_link($post, 'is_attachment_of');
     }
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:12,代码来源:lib.php


示例5: load_account_preferences

/** 
 * loads up account preferences for a given user
 * if you want them for the current user
 * use $SESSION->accountprefs
 *
 * @param int $userid to load preferences for 
 * @todo caching
 * @todo defaults? 
 */
function load_account_preferences($userid)
{
    $prefs = array();
    $expectedprefs = expected_account_preferences();
    if (empty($userid)) {
        throw new InvalidArgumentException("couldn't load account preferences, no user id specified");
    }
    if ($prefs = get_records_array('usr_account_preference', 'usr', $userid)) {
        foreach ($prefs as $p) {
            $prefs[$p->field] = $p->value;
        }
    }
    foreach ($expectedprefs as $field => $default) {
        if (!isset($prefs[$field])) {
            $prefs[$field] = $default;
        }
    }
    return $prefs;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:28,代码来源:user.php


示例6: jimmy_config

 /**
  * munge the Mahara config.
  *
  * @uses $CFG
  */
 public function jimmy_config()
 {
     global $CFG;
     $this->originaldbconfig = get_records_array('config');
     $CFG->dbprefix = $GLOBALS['TESTDBPREFIX'];
     $CFG->prefix = $GLOBALS['TESTDBPREFIX'];
     $CFG->libdir = get_config('libroot');
     try {
         db_ignore_sql_exceptions(true);
         load_config();
         db_ignore_sql_exceptions(false);
     } catch (SQLException $e) {
         db_ignore_sql_exceptions(false);
     }
     // now reload the config since $CFG is dirty with the real config table
     foreach ($this->originaldbconfig as $c) {
         unset($CFG->{$c->field});
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:24,代码来源:phpunit.php


示例7: getRecordDataById

 public static function getRecordDataById($type, $id)
 {
     $record = parent::getRecordDataById($type, $id);
     if (!$record) {
         return false;
     }
     //  Created by
     if (intval($record->owner) > 0) {
         $record->createdby = get_record('usr', 'id', $record->owner);
         $record->createdbyname = display_name($record->createdby);
     }
     //  Tags
     $tags = get_records_array('view_tag', 'view', $id);
     if ($tags != false) {
         foreach ($tags as $tag) {
             $record->tags[] = $tag->tag;
         }
     } else {
         $record->tags = null;
     }
     return $record;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:22,代码来源:ElasticsearchType_view.php


示例8: xmldb_blocktype_externalfeed_upgrade

function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
    if ($oldversion < 2008042101) {
        // We hit the 255 character limit for feed URLs
        if (is_postgres()) {
            execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
        } else {
            if (is_mysql()) {
                // If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
                // We have to remove then add the constraint again else the change will make MySQL cry
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
            }
        }
    }
    if ($oldversion < 2009121600) {
        if (is_mysql()) {
            // Make content column wider (TEXT is only 65kb in mysql)
            $table = new XMLDBTable('blocktype_externalfeed_data');
            $field = new XMLDBField('content');
            $field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
            change_field_precision($table, $field);
        }
    }
    if ($oldversion < 2010073000) {
        execute_sql('
            UPDATE {blocktype_cron}
            SET minute = ?
            WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
    }
    if ($oldversion < 2011091400) {
        // Add columns for HTTP basic auth
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field1 = new XMLDBField('authuser');
        $field1->setAttributes(XMLDB_TYPE_TEXT);
        $field2 = new XMLDBField('authpassword');
        $field2->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field1);
        add_field($table, $field2);
        // Change unique constraint that's no longer valid
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $index = new XMLDBIndex('url_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('url'));
        drop_index($table, $index);
        if (is_postgres()) {
            $index = new XMLDBIndex('urlautautix');
            $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
            add_index($table, $index);
        } else {
            if (is_mysql()) {
                // MySQL needs size limits when indexing text fields
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
                           {blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
            }
        }
    }
    if ($oldversion < 2011091401) {
        // Add columns for insecure SSL mode
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field = new XMLDBField('insecuresslmode');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
    }
    if ($oldversion < 2012090700) {
        // Reset all feeds to reset themselves
        set_field('blocktype_externalfeed_data', 'lastupdate', db_format_timestamp('0'));
        safe_require('blocktype', 'externalfeed');
        call_static_method('PluginBlocktypeExternalfeed', 'refresh_feeds');
    }
    if ($oldversion < 2014041500) {
        log_debug('Cleaning up duplicate feeds in the externalfeed blocktype');
        log_debug('1. Find the duplicate feed urls');
        // Setting these to be empty strings instead of NULL will make our SQL a lot simpler in the next section
        execute_sql("update {blocktype_externalfeed_data} set authuser='' where authuser is null");
        execute_sql("update {blocktype_externalfeed_data} set authpassword='' where authpassword is null");
        if ($duplicatefeeds = get_records_sql_array("SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_externalfeed_data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY url, authuser, authpassword", array())) {
            log_debug('2. Get all feed ids for the duplicated feed urls');
            // Use the 1st one found to be the feed id for the block instances that need updating
            $feedstoupdate = array();
            foreach ($duplicatefeeds as $feed) {
                $feedids = get_column('blocktype_externalfeed_data', 'id', 'url', $feed->url, 'authuser', $feed->authuser, 'authpassword', $feed->authpassword);
                $feedstoupdate[$feed->url] = $feedids;
            }
            log_debug('3. Updating blocks to use correct feed id');
            // Find the block instances using external feeds. Check to see if they are not using the 'true' id and update them accordingly
            require_once get_config('docroot') . 'blocktype/lib.php';
            $blockids = get_records_array('block_instance', 'blocktype', 'externalfeed', 'id ASC', 'id');
            foreach ($blockids as $blockid) {
                $blockinstance = new BlockInstance($blockid->id);
                $configdata = $blockinstance->get('configdata');
                if (!empty($configdata['feedid'])) {
                    foreach ($feedstoupdate as $url => $ids) {
                        foreach ($ids as $key => $id) {
                            if ($id == $configdata['feedid'] && $key != '0') {
                                $configdata['feedid'] = $ids[0];
                                $blockinstance->set('configdata', $configdata);
                                $blockinstance->set('dirty', true);
                                $blockinstance->commit();
                                break;
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:upgrade.php


示例9: instance_config_form

 public static function instance_config_form(BlockInstance $instance)
 {
     global $USER;
     $configdata = $instance->get('configdata');
     $types = get_records_array('activity_type', 'admin', 0, 'plugintype,pluginname,name', 'name,plugintype,pluginname');
     if ($USER->get('admin')) {
         $types[] = (object) array('name' => 'adminmessages');
     }
     $elements = array();
     $elements['types'] = array('type' => 'fieldset', 'legend' => get_string('messagetypes', 'blocktype.inbox'), 'elements' => array());
     foreach ($types as $type) {
         if (!empty($type->plugintype)) {
             $title = get_string('type' . $type->name, $type->plugintype . '.' . $type->pluginname);
         } else {
             $title = get_string('type' . $type->name, 'activity');
         }
         $elements['types']['elements'][$type->name] = array('type' => 'switchbox', 'title' => $title, 'defaultvalue' => isset($configdata[$type->name]) ? $configdata[$type->name] : 0);
     }
     $elements['maxitems'] = array('type' => 'text', 'title' => get_string('maxitems', 'blocktype.inbox'), 'description' => get_string('maxitemsdescription', 'blocktype.inbox'), 'defaultvalue' => isset($configdata['maxitems']) ? $configdata['maxitems'] : 5, 'rules' => array('minvalue' => 1, 'maxvalue' => 100));
     return $elements;
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:21,代码来源:lib.php


示例10: get_special_notifications

/**
 * Get special case activity types.
 * Currently checks if a non admin is an admin/moderator of a group and
 * adds that notification type to the array.
 *
 * @param object $user whose settings are being displayed
 * @param array  $activitytypes array of elements
 * @return array $activitytypes amended array of elements
 */
function get_special_notifications($user, $activitytypes)
{
    if (empty($user)) {
        return $activitytypes;
    }
    // Check if the non-admin is a group admin/moderator in any of their groups
    if ($user->get('grouproles') !== null) {
        $groups = $user->get('grouproles');
        $allowreportpost = false;
        foreach ($groups as $group => $role) {
            if ($role == 'admin') {
                $allowreportpost = true;
                break;
            } else {
                if ($moderator = get_record_sql("SELECT i.id\n                FROM {interaction_forum_moderator} m, {interaction_instance} i\n                WHERE i.id = m.forum AND i.group = ? AND i.deleted = 0 and m.user = ?", array($group, $user->get('id')))) {
                    $allowreportpost = true;
                    break;
                }
            }
        }
        if ($allowreportpost) {
            // Add the reportpost option to the $activitytypes
            $reportpost = get_records_array('activity_type', 'name', 'reportpost', 'id');
            $activitytypes = array_merge($activitytypes, $reportpost);
        }
    }
    return $activitytypes;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:37,代码来源:activity.php


示例11: define

define('ADMIN', 1);
define('MENUITEM', 'configextensions/webservices');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
define('TITLE', get_string('pluginadmin', 'admin'));
require_once 'pieforms/pieform.php';
$service = param_integer('service', 0);
$dbservice = get_record('external_services', 'id', $service);
if (empty($dbservice)) {
    $SESSION->add_error_msg(get_string('invalidservice', 'auth.webservice'));
    redirect('/webservice/admin/index.php?open=webservices_function_groups');
}
$enabled = $dbservice->enabled;
$restrictedusers = $dbservice->restrictedusers <= 0 ? 0 : 1;
$tokenusers = $dbservice->tokenusers <= 0 ? 0 : 1;
$functions = array('elements' => array('enabledname' => array('title' => ' ', 'class' => 'heading', 'type' => 'html', 'value' => get_string('enabled')), 'classname' => array('title' => ' ', 'class' => 'heading', 'type' => 'html', 'value' => get_string('classname', 'auth.webservice')), 'methodname' => array('title' => ' ', 'class' => 'heading', 'type' => 'html', 'value' => get_string('methodname', 'auth.webservice'))));
$dbfunctions = get_records_array('external_functions', null, null, 'name');
foreach ($dbfunctions as $function) {
    $sfexists = record_exists('external_services_functions', 'externalserviceid', $dbservice->id, 'functionname', $function->name);
    $functions['elements']['id' . $function->id . '_enabled'] = array('defaultvalue' => $sfexists ? 'checked' : '', 'type' => 'switchbox', 'disabled' => false, 'title' => $function->name);
    $functions['elements']['id' . $function->id . '_class'] = array('value' => $function->classname, 'type' => 'html', 'title' => $function->name);
    $functions['elements']['id' . $function->id . '_method'] = array('value' => '<a class="dialogue" href="' . get_config('wwwroot') . 'webservice/wsdoc.php?id=' . $function->id . '">' . $function->methodname . '</a>', 'type' => 'html', 'title' => $function->name);
}
$functions['elements']['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('back')), 'goto' => get_config('wwwroot') . 'webservice/admin/index.php?open=webservices_function_groups');
$elements = array('service' => array('type' => 'hidden', 'value' => $dbservice->id), 'webservicesmaster' => array('type' => 'fieldset', 'legend' => get_string('enableservice', 'auth.webservice'), 'elements' => array('enabled' => array('type' => 'switchbox', 'defaultvalue' => $enabled, 'on_label' => get_string('enabled'), 'off_label' => get_string('disabled'), 'wrapperclass' => 'switch-wrapper-inline', 'labelhtml' => get_string('servicename', 'auth.webservice')), 'restrictedusers' => array('type' => 'switchbox', 'defaultvalue' => $restrictedusers, 'on_label' => get_string('usersonly', 'auth.webservice'), 'off_label' => get_string('tokensonly', 'auth.webservice'), 'wrapperclass' => 'switch-wrapper-inline', 'labelhtml' => get_string('restrictedusers', 'auth.webservice')), 'tokenusers' => array('type' => 'switchbox', 'defaultvalue' => $tokenusers, 'on_label' => get_string('enabled'), 'off_label' => get_string('disabled'), 'wrapperclass' => 'switch-wrapper-inline', 'labelhtml' => get_string('fortokenusers', 'auth.webservice'))), 'collapsible' => true, 'collapsed' => false), 'functions' => array('type' => 'fieldset', 'renderer' => 'multicolumnfieldsettable', 'columns' => array('enabledname', 'classname', 'methodname'), 'legend' => get_string('servicefunctionlist', 'auth.webservice'), 'comment' => get_string('sfldescription', 'auth.webservice'), 'elements' => $functions['elements'], 'collapsible' => true, 'collapsed' => false));
$form = array('renderer' => 'table', 'type' => 'div', 'id' => 'maintable', 'elements' => $elements, 'jsform' => false);
$heading = get_string('servicegroup', 'auth.webservice', $dbservice->name);
$form['name'] = 'serviceconfig';
$form['successcallback'] = 'serviceconfig_submit';
$form = pieform($form);
$headers[] = '<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">';
$headers[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'js/jquery/jquery-ui/css/ui-lightness/jquery-ui-1.10.2.min.css') . '">';
开发者ID:vohung96,项目名称:mahara,代码行数:31,代码来源:serviceconfig.php


示例12: foreach

foreach ($services as $service) {
    $sopts[$service->id] = $service->name;
}
$token_details['elements']['institution'] = array('type' => 'select', 'title' => get_string('institution'), 'options' => $iopts, 'defaultvalue' => trim($dbtoken->institution));
$searchicon = $THEME->get_url('images/btn-search.gif', false, 'auth/webservice');
if ($USER->is_admin_for_user($dbuser->id)) {
    $user_url = get_config('wwwroot') . 'admin/users/edit.php?id=' . $dbuser->id;
} else {
    $user_url = get_config('wwwroot') . 'user/view.php?id=' . $dbuser->id;
}
$token_details['elements']['usersearch'] = array('type' => 'html', 'title' => get_string('username'), 'value' => '<a href="' . $user_url . '">' . $dbuser->username . '</a>');
$token_details['elements']['user'] = array('type' => 'hidden', 'value' => $dbuser->id);
$token_details['elements']['service'] = array('type' => 'select', 'title' => get_string('servicename', 'auth.webservice'), 'options' => $sopts, 'defaultvalue' => $dbtoken->externalserviceid);
$token_details['elements']['enabled'] = array('title' => get_string('enabled'), 'defaultvalue' => $dbservice->enabled == 1 ? 'checked' : '', 'type' => 'checkbox', 'disabled' => true);
$token_details['elements']['restricted'] = array('title' => get_string('restrictedusers', 'auth.webservice'), 'defaultvalue' => $dbservice->restrictedusers == 1 ? 'checked' : '', 'type' => 'checkbox', 'disabled' => true);
$functions = get_records_array('external_services_functions', 'externalserviceid', $dbtoken->externalserviceid);
$function_list = array();
if ($functions) {
    foreach ($functions as $function) {
        $dbfunction = get_record('external_functions', 'name', $function->functionname);
        $function_list[] = '<a href="' . get_config('wwwroot') . 'webservice/wsdoc.php?id=' . $dbfunction->id . '">' . $function->functionname . '</a>';
    }
}
$token_details['elements']['functions'] = array('title' => get_string('functions', 'auth.webservice'), 'value' => implode(', ', $function_list), 'type' => 'html');
$token_details['elements']['wssigenc'] = array('defaultvalue' => $dbtoken->wssigenc == 1 ? 'checked' : '', 'type' => 'checkbox', 'disabled' => false, 'title' => get_string('wssigenc', 'auth.webservice'));
$token_details['elements']['publickey'] = array('type' => 'textarea', 'title' => get_string('publickey', 'admin'), 'defaultvalue' => $dbtoken->publickey, 'rows' => 15, 'cols' => 90);
$token_details['elements']['publickeyexpires'] = array('type' => 'html', 'title' => get_string('publickeyexpires', 'admin'), 'value' => $dbtoken->publickeyexpires ? format_date($dbtoken->publickeyexpires, 'strftimedatetime', 'formatdate', 'auth.webservice') : format_date(time(), 'strftimedatetime', 'formatdate', 'auth.webservice'));
$token_details['elements']['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('back')), 'goto' => get_config('wwwroot') . 'webservice/admin/index.php?open=webservices_token');
$elements = array('token_details' => array('type' => 'fieldset', 'legend' => get_string('tokenid', 'auth.webservice', $dbtoken->token), 'elements' => array('sflist' => array('type' => 'html', 'value' => pieform($token_details))), 'collapsible' => false));
$form = array('renderer' => 'table', 'type' => 'div', 'id' => 'maintable', 'name' => 'tokenconfig', 'jsform' => true, 'successcallback' => 'allocate_webservice_tokens_submit', 'validatecallback' => 'allocate_webservice_tokens_validate', 'elements' => $elements);
$form = pieform($form);
开发者ID:vohung96,项目名称:mahara,代码行数:31,代码来源:tokenconfig.php


示例13: save_instance_config_options

 public static function save_instance_config_options($values, Pieform $form)
 {
     if (false === strpos($values['wwwroot'], '://')) {
         $values['wwwroot'] = 'http://' . $values['wwwroot'];
     }
     db_begin();
     $authinstance = new stdClass();
     $peer = new Peer();
     if ($values['instance'] > 0) {
         $values['create'] = false;
         $current = get_records_assoc('auth_instance_config', 'instance', $values['instance'], '', 'field, value');
         $authinstance->id = $values['instance'];
     } else {
         $values['create'] = true;
         // Get the auth instance with the highest priority number (which is
         // the instance with the lowest priority).
         // TODO: rethink 'priority' as a fieldname... it's backwards!!
         $lastinstance = get_records_array('auth_instance', 'institution', $values['institution'], 'priority DESC', '*', '0', '1');
         if ($lastinstance == false) {
             $authinstance->priority = 0;
         } else {
             $authinstance->priority = $lastinstance[0]->priority + 1;
         }
     }
     if (false == $peer->findByWwwroot($values['wwwroot'])) {
         try {
             $peer->bootstrap($values['wwwroot'], null, $values['appname'], $values['institution']);
         } catch (RemoteServerException $e) {
             $form->set_error('wwwroot', get_string('cantretrievekey', 'auth'));
             throw new RemoteServerException($e->getMessage(), $e->getCode());
         }
     }
     $peer->wwwroot = preg_replace("|\\/+\$|", "", $values['wwwroot']);
     $peer->name = $values['name'];
     $peer->deleted = $values['deleted'];
     $peer->appname = $values['appname'];
     $peer->institution = $values['institution'];
     if (isset($values['publickey'])) {
         $peer->publickey = new PublicKey($values['publickey'], $peer->wwwroot);
         $peer->publickeyexpires = $peer->publickey->expires;
     }
     /**
     * The following properties are not user-updatable
             $peer->lastconnecttime      = $values['lastconnecttime'];
     */
     $peer->commit();
     $authinstance->instancename = $values['instancename'];
     $authinstance->institution = $values['institution'];
     $authinstance->authname = $values['authname'];
     if ($values['create']) {
         $values['instance'] = insert_record('auth_instance', $authinstance, 'id', true);
     } else {
         update_record('auth_instance', $authinstance, array('id' => $values['instance']));
     }
     if (empty($current)) {
         $current = array();
     }
     self::$default_config = array('wwwroot' => $values['wwwroot'], 'parent' => $values['parent'], 'authloginmsg' => $values['authloginmsg'], 'wessoout' => 0, 'theyssoin' => 0, 'theyautocreateusers' => 0, 'weautocreateusers' => 0, 'updateuserinfoonlogin' => 0, 'weimportcontent' => 0);
     if ($values['ssodirection'] == 'wessoout') {
         self::$default_config['wessoout'] = 1;
         self::$default_config['theyautocreateusers'] = $values['theyautocreateusers'];
     } else {
         if ($values['ssodirection'] == 'theyssoin') {
             self::$default_config['theyssoin'] = 1;
             self::$default_config['updateuserinfoonlogin'] = $values['updateuserinfoonlogin'];
             self::$default_config['weautocreateusers'] = $values['weautocreateusers'];
             self::$default_config['weimportcontent'] = $values['weimportcontent'];
         }
     }
     foreach (self::$default_config as $field => $value) {
         $record = new stdClass();
         $record->instance = $values['instance'];
         $record->field = $field;
         $record->value = $value;
         if ($field == 'wwwroot') {
             $record->value = dropslash($value);
         }
         if (empty($value)) {
             delete_records('auth_instance_config', 'field', $field, 'instance', $values['instance']);
         } elseif ($values['create'] || !array_key_exists($field, $current)) {
             insert_record('auth_instance_config', $record);
         } else {
             update_record('auth_instance_config', $record, array('instance' => $values['instance'], 'field' => $field));
         }
     }
     db_commit();
     return $values;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:88,代码来源:lib.php


示例14: init

 /**
  * Instantiate the plugin by pulling the config data for an instance from
  * the database
  *
  * @param  int  $id   The unique ID of the auth instance
  * @return bool       Whether the create was successful
  */
 public function init($id)
 {
     if (!is_numeric($id) || intval($id) != $id) {
         throw new UserNotFoundException();
     }
     $instance = get_record('auth_instance', 'id', $id);
     if (empty($instance)) {
         throw new UserNotFoundException();
     }
     $this->instanceid = $id;
     $this->institution = $instance->institution;
     $this->instancename = $instance->instancename;
     $this->priority = $instance->priority;
     $this->authname = $instance->authname;
     // Return now if the plugin type doesn't require any config
     // (e.g. internal)
     if ($this->has_instance_config == false) {
         return true;
     }
     $records = get_records_array('auth_instance_config', 'instance', $this->instanceid);
     if ($records == false) {
         return false;
     }
     foreach ($records as $record) {
         $this->config[$record->field] = $record->value;
     }
     return true;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean-old,代码行数:35,代码来源:lib.php


示例15: update_group_members

 /**
  * update one or more sets of group membership
  *
  * @param array $groups
  */
 public static function update_group_members($groups)
 {
     global $USER, $WEBSERVICE_INSTITUTION;
     // Do basic automatic PARAM checks on incoming data, using params description
     $params = self::validate_parameters(self::update_group_members_parameters(), array('groups' => $groups));
     db_begin();
     $groupids = array();
     foreach ($params['groups'] as $group) {
         // Make sure that the group doesn't already exist
         if (!empty($group['id'])) {
             if (!($dbgroup = get_record('group', 'id', $group['id'], 'deleted', 0))) {
                 throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('groupnotexist', 'auth.webservice', $group['id']));
             }
         } else {
             if (!empty($group['name'])) {
                 if (!($dbgroup = get_record('group', 'name', $group['name'], 'deleted', 0))) {
                     throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('groupnotexist', 'auth.webservice', $group['name']));
                 }
             } else {
                 if (!empty($group['shortname'])) {
                     if (empty($group['institution'])) {
                         throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('instmustset', 'auth.webservice', $group['shortname']));
                     }
                     if (!($dbgroup = get_record('group', 'shortname', $group['shortname'], 'institution', $group['institution'], 'deleted', 0))) {
                         throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('groupnotexist', 'auth.webservice', $group['shortname'] . '/' . $group['institution']));
                     }
                 } else {
                     throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('nogroup', 'auth.webservice'));
                 }
             }
         }
         // are we allowed to administer this group
         if (!empty($dbgroup->institution) && $WEBSERVICE_INSTITUTION != $dbgroup->institution) {
             throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('accessdeniedforinstgroup', 'auth.webservice', $group['institution'], $group['name']));
         }
         if (!empty($dbgroup->institution) && !$USER->can_edit_institution($dbgroup->institution)) {
             throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('accessdeniedforinstgroup', 'auth.webservice', $group['institution'], $group['shortname']));
         }
         // get old members
         $oldmembers = get_records_array('group_member', 'group', $dbgroup->id, '', 'member,role');
         $existingmembers = array();
         if (!empty($oldmembers)) {
             foreach ($oldmembers as $member) {
                 $existingmembers[$member->member] = $member->role;
             }
         }
         // check that the members exist and we are allowed to administer them
         foreach ($group['members'] as $member) {
             if (!empty($member['id'])) {
                 $dbuser = get_record('usr', 'id', $member['id'], 'deleted', 0);
             } else {
                 if (!empty($member['username'])) {
                     $dbuser = get_record('usr', 'username', $member['username'], 'deleted', 0);
                 } else {
                     throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('nousernameoridgroup', 'auth.webservice', $group['name']));
                 }
             }
             if (empty($dbuser)) {
                 throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('invalidusergroup', 'auth.webservice', $member['id'] . '/' . $member['username'], $group['name']));
             }
             // check user is in this institution if this is an institution controlled group
             if (!empty($dbgroup->shortname) && !empty($dbgroup->institution)) {
                 if (!mahara_external_in_institution($dbuser, $WEBSERVICE_INSTITUTION)) {
                     throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('notauthforuseridinstitutiongroup', 'auth.webservice', $dbuser->id, $WEBSERVICE_INSTITUTION, $group['shortname']));
                 }
             } else {
                 // Make sure auth is valid
                 if (!($authinstance = get_record('auth_instance', 'id', $dbuser->authinstance))) {
                     throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('invalidauthtype', 'auth.webservice', $dbuser->authinstance));
                 }
                 // check the institution is allowed
                 // basic check authorisation to edit for the current institution of the user
                 if (!$USER->can_edit_institution($authinstance->institution)) {
                     throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('accessdeniedforinstuser', 'auth.webservice', $authinstance->institution, $dbuser->username));
                 }
             }
             // determine the changes to the group membership
             if ($member['action'] == 'remove') {
                 if (isset($existingmembers[$dbuser->id])) {
                     unset($existingmembers[$dbuser->id]);
                 }
                 // silently fail
             } else {
                 if ($member['action'] == 'add') {
                     // check the specified role
                     if (!in_array($member['role'], self::$member_roles)) {
                         throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('invalidmemroles', 'auth.webservice', $member['role'], $dbuser->username));
                     }
                     $existingmembers[$dbuser->id] = $member['role'];
                     // silently fail
                 } else {
                     throw new WebserviceInvalidParameterException('update_group_members | ' . get_string('membersinvalidaction', 'auth.webservice', $member['action'], $dbuser->id . '/' . $dbuser->username, $group['name']));
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:rboyatt,项目名称:mahara,代码行数:101,代码来源:mahara_group_external.php


示例16: get_config

require_once 'skin.php';
require_once get_config('docroot') . 'artefact/file/lib.php';
$exportid = param_integer('id', 0);
// id(s) of skin(s) to be exported...
$exportsiteskins = param_boolean('site', false);
if (!can_use_skins(null, $exportsiteskins)) {
    throw new FeatureNotEnabledException();
}
if ($exportid == 0) {
    if ($exportsiteskins) {
        // We are exporting site skins...
        $exportskins = get_records_array('skin', 'type', 'site');
        $xmlfilename = 'siteskins';
    } else {
        // We are exporting user skins...
        $exportskins = get_records_array('skin', 'owner', $USER->get('id'));
        $xmlfilename = 'myskins';
    }
} else {
    $exportskins = get_record('skin', 'id', $exportid, 'owner', $USER->get('id'));
    // Convert to array with one object - for one view skin, with specified id...
    $exportskins = array($exportskins);
    $xmlfilename = 'skin' . $exportid;
}
// ===============================
//  Dinamically create export XML
// ===============================
$xmldoc = new DOMDocument('1.0', 'UTF-8');
$comment = $xmldoc->appendChild(new DOMComment('Skin definitions to be used with Mahara pages. More info about Mahara at http://mahara.org'));
$topelement = $xmldoc->createElement('skins');
$topnode = $xmldoc->appendChild($topelement);
开发者ID:sarahjcotton,项目名称:mahara,代码行数:31,代码来源:export.php


示例17: get_comments

 /**
  * Generates data object required for displaying comments on the page.
  *
  * @param  int $limit              The number of comments to display (set to
  *                                 0 for disabling pagination and showing all comments)
  * @param  int $offset             The offset of comments used for pagination
  * @param  int|string $showcomment Optionally show page with particular comment
  *                                 on it or the last page. $offset will be ignored.
  *                                 Specify either comment_id or 'last' respectively.
  *                                 Set to null to use $offset for pagination.
  * @param  object $view            The view object
  * @param  object $artefact        Optional artefact object
  * @param  bool   $export          Determines if comments are fetched for html export purposes
  * @return object $result          Comments data object
  */
 public static function get_comments($limit = 10, $offset = 0, $showcomment, &$view, &$artefact = null, $export = false)
 {
     global $USER;
     $userid = $USER->get('id');
     $viewid = $view->get('id');
     if (!empty($artefact)) {
         $canedit = $USER->can_edit_artefact($artefact);
         $owner = $artefact->get('owner');
         $isowner = $userid && $userid == $owner;
         $artefactid = $artefact->get('id');
     } else {
         $canedit = $USER->can_moderate_view($view);
         $owner = $view 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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