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

PHP get_records_assoc函数代码示例

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

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



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

示例1: load_activity_preferences

/**
 * loads up activity preferences for a given user
 *
 * @param int $userid to load preferences for
 * @todo caching
 */
function load_activity_preferences($userid)
{
    $prefs = array();
    if (empty($userid)) {
        throw new InvalidArgumentException("couldn't load activity preferences, no user id specified");
    }
    if ($prefs = get_records_assoc('usr_activity_preference', 'usr', $userid, '', 'activity,method')) {
        foreach ($prefs as $p) {
            $prefs[$p->activity] = $p->method;
        }
    }
    return $prefs;
}
开发者ID:patkira,项目名称:mahara,代码行数:19,代码来源:user.php


示例2: build_admin_user_search_results

function build_admin_user_search_results($search, $offset, $limit, $sortby, $sortdir)
{
    global $USER;
    $results = get_admin_user_search_results($search, $offset, $limit, $sortby, $sortdir);
    $params = array();
    foreach ($search as $k => $v) {
        if (!empty($v)) {
            $params[] = $k . '=' . $v;
        }
    }
    $searchurl = get_config('wwwroot') . 'admin/users/search.php?' . join('&', $params) . '&limit=' . $limit;
    $usernametemplate = '<a href="' . get_config('wwwroot') . '{if $USER->is_admin_for_user($r.id)}admin/users/edit.php?id={$r.id}{else}user/view.php?id={$r.id}{/if}">{$r.username}</a>';
    $cols = array('icon' => array('name' => '', 'template' => '<img src="{profile_icon_url user=$r maxwidth=40 maxheight=40}" alt="' . get_string('profileimage') . '" />', 'class' => 'center'), 'firstname' => array('name' => get_string('firstname')), 'lastname' => array('name' => get_string('lastname')), 'username' => array('name' => get_string('username'), 'template' => $usernametemplate), 'email' => array('name' => get_string('email')));
    $institutions = get_records_assoc('institution', '', '', '', 'name,displayname');
    if (count($institutions) > 1) {
        $cols['institution'] = array('name' => get_string('institution'), 'template' => '{if !$r.institutions}{$institutions.mahara->displayname}{else}{foreach from=$r.institutions item=i}<div>{$institutions[$i]->displayname}</div>{/foreach}{/if}{if !$r.requested}{foreach from=$r.requested item=i}<div class="pending">{str tag=requestto section=admin} {$institutions[$i]->displayname}{if $USER->is_institutional_admin("$i")} (<a href="{$WWWROOT}admin/users/addtoinstitution.php?id={$r.id}&institution={$i}">{str tag=confirm section=admin}</a>){/if}</div>{/foreach}{/if}{if !$r.invitedby}{foreach from=$r.invitedby item=i}<div class="pending">{str tag=invitedby section=admin} {$institutions[$i]->displayname}</div>{/foreach}{/if}');
    }
    $smarty = smarty_core();
    $smarty->assign_by_ref('results', $results);
    $smarty->assign_by_ref('institutions', $institutions);
    $smarty->assign('USER', $USER);
    $smarty->assign('searchurl', $searchurl);
    $smarty->assign('sortby', $sortby);
    $smarty->assign('sortdir', $sortdir);
    $smarty->assign('pagebaseurl', $searchurl . '&sortby=' . $sortby . '&sortdir=' . $sortdir);
    $smarty->assign('cols', $cols);
    $smarty->assign('ncols', count($cols));
    return $smarty->fetch('searchresulttable.tpl');
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:29,代码来源:searchlib.php


示例3: xmldb_core_upgrade


//.........这里部分代码省略.........
            $elasticsearchartefacttypesmap = array();
            foreach ($artefacttypesmap_array as $key => $value) {
                $tmpkey = explode("|", $value);
                if (count($tmpkey) == 3) {
                    if (!in_array($tmpkey[0], $oldmessagingfieldsarray)) {
                        // we're going to keep this one.
                        $elasticsearchartefacttypesmap[] = $value;
                    }
                }
            }
            // add socialprofile field.
            $elasticsearchartefacttypesmap[] = "socialprofile|Profile|Text";
            // now save the data excluding the old messaging fields.
            set_config_plugin('search', 'elasticsearch', 'artefacttypesmap', implode("\n", $elasticsearchartefacttypesmap));
        }
        log_debug('Delete unused, but still installed artefact types');
        delete_records_select("artefact_installed_type", "name IN (" . $oldmessagingfields . ")");
        log_debug('Install the social profile blocktype so users can see their migrated data');
        if ($data = check_upgrades('blocktype.internal/socialprofile')) {
            upgrade_plugin($data);
        }
    }
    if ($oldversion < 2014092300) {
        log_debug("Install 'multirecipientnotification' plugin");
        if ($data = check_upgrades('module.multirecipientnotification')) {
            upgrade_plugin($data);
        }
    }
    if ($oldversion < 2014101300) {
        log_debug("Make sure default notifications are not set to 'none'");
        // Make sure the 'system messages' and 'messages from other users' have a notification method set
        // It was possible after earlier upgrades to set method to 'none'.
        // Also make sure old defaultmethod is respected.
        $activitytypes = get_records_assoc('activity_type');
        foreach ($activitytypes as $type) {
            $type->defaultmethod = get_config('defaultnotificationmethod') ? get_config('defaultnotificationmethod') : 'email';
            if ($type->name == 'maharamessage' || $type->name == 'usermessage') {
                $type->allownonemethod = 0;
            }
            update_record('activity_type', $type);
        }
        // Make sure users have their 'system messages' and 'messages from other users' notification method set
        if ($useractivities = get_records_sql_assoc("SELECT * FROM {activity_type} at, {usr_activity_preference} uap\n                                                     WHERE at.id = uap.activity\n                                                     AND at.name IN ('maharamessage', 'usermessage')\n                                                     AND (method IS NULL OR method = '')", array())) {
            foreach ($useractivities as $activity) {
                $userprefs = new stdClass();
                $userprefs->method = $activity->defaultmethod;
                update_record('usr_activity_preference', $userprefs, array('usr' => $activity->usr, 'activity' => $activity->activity));
            }
        }
    }
    if ($oldversion < 2014101500) {
        log_debug('Place skin fonts in their correct directories');
        if ($fonts = get_records_assoc('skin_fonts', 'fonttype', 'google')) {
            $fontpath = get_config('dataroot') . 'skins/fonts/';
            foreach ($fonts as $font) {
                // if google font is not already in subdir
                if (!is_dir($fontpath . $font->name)) {
                    if (file_exists($fontpath . $font->previewfont)) {
                        // we need to create the subdir and move the file into it
                        $newfontpath = $fontpath . $font->name . '/';
                        check_dir_exists($newfontpath, true, true);
                        rename($fontpath . $font->previewfont, $newfontpath . $font->previewfont);
                        // and move the license file if it exists also
                        if (file_exists($fontpath . $font->licence)) {
                            rename($fontpath . $font->licence, $newfontpath . $font->licence);
                        }
开发者ID:patkira,项目名称:mahara,代码行数:67,代码来源:upgrade.php


示例4: get_institution_string_for_user

function get_institution_string_for_user($userid)
{
    static $institutions = null;
    if (is_null($institutions)) {
        $institutions = get_records_assoc('institution', '', '', '', 'name, displayname');
    }
    $user = new User();
    $user->find_by_id($userid);
    $userinstitutions = array();
    foreach ($user->get('institutions') as $institution) {
        $userinstitutions[] = $institutions[$institution->institution]->displayname;
    }
    if ($userinstitutions) {
        return get_string('memberofinstitutions', 'mahara', join(', ', $userinstitutions));
    }
    return '';
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:17,代码来源:user.php


示例5: get_extra_collection_info

 /**
  * Get more info for the collections: owner, url, tags, views
  *
  * @param array a list of collections $collectiondata
  * @return array updated collection data
  */
 public static function get_extra_collection_info(&$collectiondata, $gettags = true)
 {
     if ($collectiondata) {
         // Get view owner details for display
         $owners = array();
         $groups = array();
         $institutions = array();
         foreach ($collectiondata as $c) {
             if (!empty($c->owner) && !isset($owners[$c->owner])) {
                 $owners[$c->owner] = (int) $c->owner;
             } else {
                 if (!empty($c->group) && !isset($groups[$c->group])) {
                     $groups[$c->group] = (int) $c->group;
                 } else {
                     if (!empty($c->institution) && !isset($institutions[$c->institution])) {
                         $institutions[$c->institution] = $c->institution;
                     }
                 }
             }
         }
         if ($gettags) {
             $collectionidlist = join(',', array_map('intval', array_keys($collectiondata)));
             $tags = get_records_select_array('collection_tag', 'collection IN (' . $collectionidlist . ')');
             if ($tags) {
                 foreach ($tags as &$tag) {
                     $collectiondata[$tag->collection]->tags[] = $tag->tag;
                 }
             }
         }
         if (!empty($owners)) {
             global $USER;
             $userid = $USER->get('id');
             $fields = array('id', 'username', 'firstname', 'lastname', 'preferredname', 'admin', 'staff', 'studentid', 'email', 'profileicon', 'urlid', 'suspendedctime');
             if (count($owners) == 1 && isset($owners[$userid])) {
                 $owners = array($userid => new StdClass());
                 foreach ($fields as $f) {
                     $owners[$userid]->{$f} = $USER->get($f);
                 }
             } else {
                 $owners = get_records_select_assoc('usr', 'id IN (' . join(',', array_fill(0, count($owners), '?')) . ')', $owners, '', join(',', $fields));
             }
         }
         if (!empty($groups)) {
             $groups = get_records_select_assoc('group', 'id IN (' . join(',', $groups) . ')', null, '', 'id,name,urlid');
         }
         if (!empty($institutions)) {
             $institutions = get_records_assoc('institution', '', '', '', 'name,displayname');
             $institutions['mahara']->displayname = get_config('sitename');
         }
         $wwwroot = get_config('wwwroot');
         $needsubdomain = get_config('cleanurlusersubdomains');
         foreach ($collectiondata as &$c) {
             if (!empty($c->owner)) {
                 $c->sharedby = display_name($owners[$c->owner]);
                 $c->user = $owners[$c->owner];
             } else {
                 if (!empty($c->group)) {
                     $c->sharedby = $groups[$c->group]->name;
                     $c->groupdata = $groups[$c->group];
                 } else {
                     if (!empty($c->institution)) {
                         $c->sharedby = $institutions[$c->institution]->displayname;
                     }
                 }
             }
             $c = (array) $c;
             // Now that we have the owner & group records, create a temporary Collection object
             // so that we can use get_url method.
             require_once get_config('libroot') . 'collection.php';
             $collection = new Collection(0, $c);
             $c['url'] = $collection->get_url(false);
             $c['fullurl'] = $needsubdomain ? $collection->get_url(true) : $wwwroot . $c['url'];
             // Get any views that are part of this collection
             $c['views'] = get_records_sql_assoc('SELECT v.id, v.title, v.mtime FROM {view} v, {collection_view} cv, {collection} c
                                                  WHERE cv.collection = c.id AND cv.view = v.id AND c.id = ?', array($c['id']));
             // Set the collection modified time as the highest view
             // modified time if higher than collection modified time
             foreach ($c['views'] as $view) {
                 $cmodified = new DateTime($c['mtime']);
                 $vmodified = new DateTime($view->mtime);
                 if ($vmodified > $cmodified) {
                     $c['mtime'] = $view->mtime;
                 }
             }
         }
     }
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:93,代码来源:view.php


示例6: xmldb_artefact_file_upgrade


//.........这里部分代码省略.........
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'audio/x-realaudio-plugin'), (object) array('mimetype' => 'audio/x-realaudio-plugin', 'description' => 'ra'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'audio/x-pn-realaudio-plugin'), (object) array('mimetype' => 'audio/x-pn-realaudio-plugin', 'description' => 'ram'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.rn-realmedia-vbr'), (object) array('mimetype' => 'application/vnd.rn-realmedia-vbr', 'description' => 'rmvb'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'text/richtext'), (object) array('mimetype' => 'text/richtext', 'description' => 'rtx'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/x-stuffit'), (object) array('mimetype' => 'application/x-stuffit', 'description' => 'sit'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/smil'), (object) array('mimetype' => 'application/smil', 'description' => 'smi'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'image/svg+xml'), (object) array('mimetype' => 'image/svg+xml', 'description' => 'svg'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.writer'), (object) array('mimetype' => 'application/vnd.sun.xml.writer', 'description' => 'sxw'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.writer.template'), (object) array('mimetype' => 'application/vnd.sun.xml.writer.template', 'description' => 'stw'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.calc'), (object) array('mimetype' => 'application/vnd.sun.xml.calc', 'description' => 'sxc'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.calc.template'), (object) array('mimetype' => 'application/vnd.sun.xml.calc.template', 'description' => 'stc'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.draw'), (object) array('mimetype' => 'application/vnd.sun.xml.draw', 'description' => 'sxd'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.draw.template'), (object) array('mimetype' => 'application/vnd.sun.xml.draw.template', 'description' => 'std'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.impress'), (object) array('mimetype' => 'application/vnd.sun.xml.impress', 'description' => 'sxi'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.impress.template'), (object) array('mimetype' => 'application/vnd.sun.xml.impress.template', 'description' => 'sti'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.writer.global'), (object) array('mimetype' => 'application/vnd.sun.xml.writer.global', 'description' => 'sxg'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.sun.xml.math'), (object) array('mimetype' => 'application/vnd.sun.xml.math', 'description' => 'sxm'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'image/tiff'), (object) array('mimetype' => 'image/tiff', 'description' => 'tif'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/x-tex'), (object) array('mimetype' => 'application/x-tex', 'description' => 'tex'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/x-texinfo'), (object) array('mimetype' => 'application/x-texinfo', 'description' => 'texi'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'text/tab-separated-values'), (object) array('mimetype' => 'text/tab-separated-values', 'description' => 'tsv'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'video/webm'), (object) array('mimetype' => 'video/webm', 'description' => 'webm'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.ms-excel'), (object) array('mimetype' => 'application/vnd.ms-excel', 'description' => 'xls'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'), (object) array('mimetype' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'description' => 'xlsx'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.ms-excel.sheet.macroEnabled.12'), (object) array('mimetype' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'description' => 'xlsm'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'), (object) array('mimetype' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'description' => 'xltx'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.ms-excel.template.macroEnabled.12'), (object) array('mimetype' => 'application/vnd.ms-excel.template.macroEnabled.12', 'description' => 'xltm'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'), (object) array('mimetype' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'description' => 'xlsb'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/vnd.ms-excel.addin.macroEnabled.12'), (object) array('mimetype' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'description' => 'xlam'));
        ensure_record_exists('artefact_file_mime_types', (object) array('mimetype' => 'application/xml'), (object) array('mimetype' => 'application/xml', 'description' => 'xml'));
    }
    if ($oldversion < 2014051200) {
        require_once get_config('docroot') . '/lib/file.php';
        $mimetypes = get_records_assoc('artefact_file_mime_types', '', '', '', 'description,mimetype');
        // Re-examine only those files where their current identified mimetype is
        // different from how we would identify their mimetype based on file extension
        $rs = get_recordset_sql('
            select a.id, aff.oldextension, aff.filetype
            from
                {artefact} a
                inner join {artefact_file_files} aff
                    on a.id = aff.artefact
            where a.artefacttype = \'archive\'
                and not exists (
                    select 1 from {artefact_file_mime_types} afmt
                    where afmt.description = aff.oldextension
                    and afmt.mimetype = aff.filetype
                )
            order by a.id
        ');
        $total = 0;
        $done = 0;
        while ($zf = $rs->FetchRow()) {
            if ($done % 100 == 0) {
                log_debug('Verifying filetypes: ' . $done . '/' . $rs->RecordCount());
            }
            $done++;
            $file = artefact_instance_from_id($zf['id']);
            $path = $file->get_path();
            // Check what our improved file detection system thinks it is
            $guess = file_mime_type($path, 'foo.' . $zf['oldextension']);
            if ($guess != 'application/octet-stream') {
                $data = new stdClass();
                $data->filetype = $data->guess = $guess;
                foreach (array('video', 'audio', 'archive') as $artefacttype) {
                    $classname = 'ArtefactType' . ucfirst($artefacttype);
开发者ID:sarahjcotton,项目名称:mahara,代码行数:67,代码来源:upgrade.php


示例7: save_instance_config_options

 public static function save_instance_config_options($values, Pieform $form)
 {
     $authinstance = new stdClass();
     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;
         $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;
         }
     }
     $authinstance->institution = $values['institution'];
     $authinstance->authname = $values['authname'];
     $authinstance->instancename = $values['instancename'];
     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('weautocreateusers' => $values['weautocreateusers']);
     foreach (self::$default_config as $field => $value) {
         $record = new stdClass();
         $record->instance = $values['instance'];
         $record->field = $field;
         $record->value = $value;
         if ($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));
         }
     }
     return $values;
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:41,代码来源:lib.php


示例8: 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


示例9: license_form_el_basic

/**
 * Given an artefact object, return the first of the two pieform elements.
 *
 * @param object $artefact The artefact
 * @param boolean $always_allow_none True to indicate that it should definitely include "allow none"; otherwise the function decides
 * @return array  A pieform element (license field).
 */
function license_form_el_basic($artefact, $always_allow_none = false)
{
    if (!get_config('licensemetadata')) {
        return array('type' => 'hidden', 'ignore' => true);
    }
    global $USER;
    $licenses = get_records_assoc('artefact_license', null, null, 'displayname');
    if ($licenses) {
        foreach ($licenses as $l) {
            $options[$l->name] = $l->displayname;
        }
    }
    // Determine whether to include the "none selected" option in the list of licenses
    $include_noneselected = false;
    // If it was passed in as a param, then we will include "none selected"
    if ($always_allow_none) {
        $include_noneselected = true;
    }
    $institution = $USER->get('institutions');
    if ($institution) {
        $institution = array_shift($institution);
        // If the user's institution is not set to "license mandatory", then we will include "none selected"
        if (empty($institution->licensemandatory)) {
            $include_noneselected = true;
        }
    } else {
        // If the user has no institution, then we will include "none selected"
        $include_noneselected = true;
    }
    if ($include_noneselected) {
        $options[''] = get_string('licensenone');
    }
    if (empty($artefact)) {
        // Find the correct default license.
        $license = $USER->get_account_preference('licensedefault');
        // If the user is set to "institution default"
        if ($license == LICENSE_INSTITUTION_DEFAULT) {
            if ($institution and isset($institution->licensedefault)) {
                $license = $institution->licensedefault;
            } else {
                $license = '';
            }
        }
        if (!isset($options[$license]) && !get_config('licenseallowcustom')) {
            // Note: this won't happen normally, but it can happen for instance
            // if the site admin removes a license which is the default for the
            // user's institution.
            $license = array_keys($licenses);
            $license = array_shift($license);
        }
    } else {
        $license = $artefact->get('license');
        if (empty($license)) {
            $license = '';
        }
        if (!isset($options[$license])) {
            $options[$license] = $license;
        }
    }
    $res = array('defaultvalue' => $license, 'type' => 'select', 'options' => $options, 'title' => get_string('license'), 'description' => get_string('licensedesc'), 'help' => true);
    if (get_config('licenseallowcustom')) {
        $res['allowother'] = true;
        $res['options']['other'] = get_string('licenseother');
    }
    if (!isset($options[''])) {
        $res['rules'] = array('required' => true);
    }
    return $res;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:76,代码来源:license.php


示例10: define

/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'groups/institutions');
require dirname(dirname(__FILE__)) . '/init.php';
define('TITLE', get_string('institutionmembership'));
require_once 'pieforms/pieform.php';
$institutions = get_records_assoc('institution', '', '', '', 'name,displayname,registerallowed');
// For all institutions the user is already a member of, create a
// button to leave the institution, unless the institution does not
// allow registration.
$member = $USER->get('institutions');
if (!empty($member)) {
    $elements = array();
    foreach ($member as $i) {
        if ($institutions[$i->institution]->registerallowed) {
            $elements[] = array('type' => 'submit', 'name' => '_leave_' . $i->institution, 'confirm' => get_string('reallyleaveinstitution'), 'title' => get_string('youareamemberof', 'mahara', $institutions[$i->institution]->displayname), 'value' => get_string('leaveinstitution'));
        } else {
            $elements[] = array('type' => 'html', 'name' => '_noleave_' . $i->institution, 'title' => get_string('youareamemberof', 'mahara', $institutions[$i->institution]->displayname), 'value' => '');
        }
        unset($institutions[$i->institution]);
    }
    $memberform = pieform(array('name' => 'leaveinstitution', 'method' => 'post', 'plugintype' => 'core', 'pluginname' => 'account', 'elements' => $elements));
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:30,代码来源:institutions.php


示例11: sideblock_sort

 /**
  * Optional method. Takes a list of forums and sorts them according to 
  * their weights for the sideblock
  *
  * @param array $forums An array of hashes of forum data
  * @return array        The array, sorted appropriately
  */
 public static function sideblock_sort($forums)
 {
     if (!$forums) {
         return $forums;
     }
     $weights = get_records_assoc('interaction_forum_instance_config', 'field', 'weight', 'forum', 'forum, value');
     foreach ($forums as &$forum) {
         // Note: forums expect every forum to have a 'weight' record in the
         // forum instance config table, so we don't need to check that
         // there is a weight for the forum here - there should be,
         // otherwise someone has futz'd with the database or there's a bug
         // elsewhere that allowed this to happen
         $forum->weight = $weights[$forum->id]->value;
     }
     usort($forums, create_function('$a, $b', 'return $a->weight > $b->weight;'));
     return $forums;
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:24,代码来源:lib.php


示例12: get_string

        } else {
            $layoutoptions[$key]['columns'] .= ' / ' . get_string($layoutcolumns[$layout[$r + 1]]->widths, 'view');
        }
    }
}
foreach ($basicoptionids as $id) {
    if (array_key_exists($id, $layoutoptions)) {
        $basiclayoutoptions[$id] = $layoutoptions[$id];
    }
}
$clnumcolumnsoptions = array();
for ($i = 1; $i < 6; $i++) {
    $clnumcolumnsoptions[$i] = $i;
}
$columnlayoutoptions = array();
$columnlayouts = get_records_assoc('view_layout_columns');
foreach ($columnlayouts as $layout => $percents) {
    $percentswidths = str_replace(',', ' - ', $percents->widths);
    $columnlayoutoptions[$layout] = $percentswidths;
}
// provide a simple default to build custom layouts with
$defaultcustomlayout = $view->default_columnsperrow();
$defaultlayout = get_record('view_layout_columns', 'columns', $defaultcustomlayout[1]->columns, 'widths', $defaultcustomlayout[1]->widths);
$clnumcolumnsdefault = $defaultlayout->columns;
$clwidths = $defaultlayout->widths;
$inlinejavascript = <<<JAVASCRIPT

function get_max_custom_rows() {
    return {$maxlayoutrows};
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:30,代码来源:layout.php


示例13: resync_filetype_list

 /**
  * Resyncs the allowed filetypes list with the XML configuration file.
  *
  * This can be called on install (and is, in the postinst method above),
  * and every time an upgrade is made that changes the file.
  */
 function resync_filetype_list()
 {
     require_once 'xmlize.php';
     db_begin();
     log_info('Beginning resync of filetype list');
     $currentlist = get_records_assoc('artefact_file_mime_types');
     $newlist = xmlize(file_get_contents(get_config('docroot') . 'artefact/file/filetypes.xml'));
     $filetypes = $newlist['filetypes']['#']['filetype'];
     $newtypes = array();
     // Step one: if a mimetype is in the new list that is not in the current
     // list, add it to the current list.
     foreach ($filetypes as $filetype) {
         $description = $filetype['#']['description'][0]['#'];
         foreach ($filetype['#']['mimetypes'][0]['#']['mimetype'] as $type) {
             $mimetype = $type['#'];
             if (!isset($currentlist[$mimetype])) {
                 log_debug('Adding mimetype: ' . $mimetype . ' (' . $description . ')');
                 execute_sql("INSERT INTO {artefact_file_mime_types} (mimetype, description) VALUES (?,?)", array($mimetype, $description));
             } else {
                 if ($currentlist[$mimetype]->description != $description) {
                     log_debug('Updating mimetype: ' . $mimetype . ' (' . $description . ')');
                     execute_sql("UPDATE {artefact_file_mime_types} SET description = ? WHERE mimetype = ?", array($description, $mimetype));
                 }
             }
             $newtypes[$mimetype] = true;
             $currentlist[$mimetype] = (object) array('mimetype' => $mimetype, 'description' => $description);
         }
     }
     // Step two: If a mimetype is in the current list that is not in the
     // new list, remove it from the current list.
     foreach ($currentlist as $mimetype => $type) {
         if (!isset($newtypes[$mimetype])) {
             log_debug('Removing mimetype: ' . $mimetype);
             delete_records('artefact_file_mime_types', 'mimetype', $mimetype);
         }
     }
     db_commit();
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:44,代码来源:lib.php


示例14: get_mimetypes_from_description

 public static function get_mimetypes_from_description($description = null, $getrecords = false)
 {
     static $allmimetypes = null;
     if (is_null($allmimetypes)) {
         $allmimetypes = get_records_assoc('artefact_file_mime_types');
     }
     if (is_string($description)) {
         $description = array($description);
     }
     $mimetypes = array();
     foreach ($allmimetypes as $r) {
         if (is_null($description) || in_array($r->description, $description)) {
             if ($getrecords) {
                 $mimetypes[$r->mimetype] = $r;
             } else {
                 $mimetypes[] = $r->mimetype;
             }
         }
     }
     return $mimetypes;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:21,代码来源:lib.php


示例15: save_config_options

 public static function save_config_options($values, $form)
 {
     $authinstance = new stdClass();
     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;
         }
     }
     $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('host_url' => $values['host_url'], 'contexts' => $values['contexts'], 'user_type' => $values['user_type'], 'user_attribute' => $values['user_attribute'], 'search_sub' => $values['search_sub'], 'bind_dn' => $values['bind_dn'], 'bind_pw' => $values['bind_pw'], 'version' => $values['version'], 'weautocreateusers' => $values['weautocreateusers'], 'firstnamefield' => $values['firstnamefield'], 'surnamefield' => $values['surnamefield'], 'emailfield' => $values['emailfield']);
     foreach (self::$default_config as $field => $value) {
         $record = new stdClass();
         $record->instance = $values['instance'];
         $record->field = $field;
         $record->value = $value;
         if ($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));
         }
     }
     return $values;
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:44,代码来源:lib.php


示例16: save_instance_config_options

 public static function save_instance_config_options($values, Pieform $form)
 {
     $authinstance = new stdClass();
     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;
         }
     }
     $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();
     }
     foreach (array_keys(self::$default_config) as $key) {
         self::$default_config[$key] = $values[$key];
     }
     foreach (self::$default_config as $field => $value) {
         $record = new stdClass();
         $record->instance = $values['instance'];
         $record->field = $field;
         $record->value = $value;
         if ($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));
         }
     }
     return $values;
 }
开发者ID:vohung96,

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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