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

PHP get_records_select_assoc函数代码示例

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

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



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

示例1: pieform_element_userlist

/**
 * Provides a basic text field input.
 *
 * @todo this is just lies ...
 * @param array    $element The element to render
 * @param Pieform  $form    The form to render the element for
 * @return string           The HTML for the element
 */
function pieform_element_userlist(Pieform $form, $element)
{
    $smarty = smarty_core();
    $smarty->left_delimiter = '{{';
    $smarty->right_delimiter = '}}';
    $value = $form->get_value($element);
    if (!is_array($value) && isset($element['defaultvalue']) && is_array($element['defaultvalue'])) {
        $value = $element['defaultvalue'];
    }
    if (is_array($value) && count($value)) {
        $orderby = isset($element['searchparams']['orderby']) && $element['searchparams']['orderby'] == 'lastname' ? 'lastname,firstname,id' : 'firstname,lastname,id';
        $members = get_records_select_assoc('usr', 'id IN (' . join(',', array_map('intval', $value)) . ')', null, $orderby, 'id,username,firstname,lastname,preferredname,staff');
        foreach ($members as &$member) {
            $member = display_name($member);
        }
        $smarty->assign('options', $members);
        $smarty->assign('value', join(',', $value));
    }
    $smarty->assign('name', $element['name']);
    if (!empty($element['lefttitle'])) {
        $smarty->assign('lefttitle', $element['lefttitle']);
    }
    if (!empty($element['righttitle'])) {
        $smarty->assign('righttitle', $element['righttitle']);
    }
    if (!empty($element['leftarrowlabel'])) {
        $smarty->assign('leftarrowlabel', $element['leftarrowlabel']);
    }
    if (!empty($element['rightarrowlabel'])) {
        $smarty->assign('rightarrowlabel', $element['rightarrowlabel']);
    }
    if (!empty($element['group'])) {
        $smarty->assign('group', $element['group']);
        $smarty->assign('includeadmins', !isset($element['includeadmins']) || $element['includeadmins'] ? 1 : 0);
    }
    if (empty($element['searchscript'])) {
        $element['searchscript'] = 'json/usersearch.php';
    }
    $smarty->assign('searchscript', $element['searchscript']);
    if (empty($element['searchparams'])) {
        $element['searchparams'] = array('query' => '', 'limit' => 100);
    }
    $smarty->assign('searchparams', json_encode($element['searchparams']));
    $smarty->assign('onlyshowingfirst', json_encode(get_string('onlyshowingfirst', 'admin')));
    $smarty->assign('resultsof', json_encode(get_string('resultsof', 'admin')));
    return $smarty->fetch('form/userlist.tpl');
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:55,代码来源:userlist.php


示例2: removeMember

 public function removeMember($user)
 {
     if (is_numeric($user)) {
         $user = get_record('usr', 'id', $user);
     }
     db_begin();
     // If the user is being authed by the institution they are
     // being removed from, change them to internal auth, or if
     // we can't find that, some other no institution auth.
     $authinstances = get_records_select_assoc('auth_instance', "institution IN ('mahara', ?)", array($this->name), "institution = 'mahara' DESC, authname = 'internal' DESC");
     $oldauth = $user->authinstance;
     if (isset($authinstances[$oldauth]) && $authinstances[$oldauth]->institution == $this->name) {
         foreach ($authinstances as $ai) {
             if ($ai->authname == 'internal' && $ai->institution == 'mahara') {
                 $user->authinstance = $ai->id;
                 break;
             } else {
                 if ($ai->institution == 'mahara') {
                     $user->authinstance = $ai->id;
                     break;
                 }
             }
         }
         delete_records('auth_remote_user', 'authinstance', $oldauth, 'localusr', $user->id);
         // If the old authinstance was external, the user may need
         // to set a password
         if ($user->password == '') {
             log_debug('resetting pw for ' . $user->id);
             $this->removeMemberSetPassword($user);
         }
         update_record('usr', $user);
     }
     delete_records('usr_institution', 'usr', $user->id, 'institution', $this->name);
     handle_event('updateuser', $user->id);
     db_commit();
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:36,代码来源:institution.php


示例3: locked_profile_fields

function locked_profile_fields()
{
    global $USER, $SESSION;
    // Profile fields are locked for a user if they are locked by any
    // institution the user is a member of, but not an admin for.
    $lockinginstitutions = array_keys($USER->get('institutions'));
    $lockinginstitutions[] = 'mahara';
    $lockinginstitutions = array_diff($lockinginstitutions, $USER->get('admininstitutions'));
    $locked = get_records_select_assoc('institution_locked_profile_field', 'name IN (' . join(',', array_map('db_quote', $lockinginstitutions)) . ')', null, '', 'profilefield,name');
    if ($remotelocked = $SESSION->get('lockedfields')) {
        foreach ($remotelocked as $f) {
            if (!isset($locked[$f])) {
                $locked[$f] = $f;
            }
        }
    }
    return $locked;
}
开发者ID:patkira,项目名称:mahara,代码行数:18,代码来源:index.php


示例4: progressbarform_submit

function progressbarform_submit(Pieform $form, $values)
{
    global $SESSION, $USER, $possibleitems;
    $institution = $values['institution'];
    // Pre-fetching the current settings to reduce SELECT queries
    $currentsettings = get_records_select_assoc('institution_config', 'institution=? and field like \'progressbaritem_%\'', array($institution), 'field', 'field, value');
    if (!$currentsettings) {
        $currentsettings = array();
    }
    foreach ($possibleitems as $plugin => $pluginitems) {
        foreach ($pluginitems as $artefact) {
            $itemname = "progressbaritem_{$plugin}_{$artefact->name}";
            // Format the value into an integer or 0/1
            $val = $values[$itemname];
            if ($artefact->iscountable) {
                $val = (int) $val;
            } else {
                $val = (int) (bool) $val;
            }
            // Update the record if it already exists, or create the record if it doesn't
            if (array_key_exists($itemname, $currentsettings)) {
                if ($val) {
                    set_field('institution_config', 'value', $val, 'institution', $institution, 'field', $itemname);
                } else {
                    delete_records('institution_config', 'institution', $institution, 'field', $itemname);
                }
            } else {
                if ($val) {
                    insert_record('institution_config', (object) array('institution' => $institution, 'field' => $itemname, 'value' => $val));
                }
            }
        }
    }
    $SESSION->add_ok_msg(get_string('progressbarsaved', 'admin'));
    redirect('/admin/users/progressbar.php?institution=' . $institution);
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:36,代码来源:progressbar.php


示例5: changeauth_submit

function changeauth_submit(Pieform $form, $values)
{
    global $users, $SESSION, $authinstances, $USER;
    $newauth = AuthFactory::create($values['authinstance']);
    $needspassword = method_exists($newauth, 'change_password');
    $updated = 0;
    $needpassword = 0;
    db_begin();
    $newauthinst = get_records_select_assoc('auth_instance', 'id = ?', array($values['authinstance']));
    if ($USER->get('admin') || $USER->is_institutional_admin($newauthinst[$values['authinstance']]->institution)) {
        foreach ($users as $user) {
            if ($user->authinstance != $values['authinstance']) {
                // Authinstance can be changed by institutional admins if both the
                // old and new authinstances belong to the admin's institutions
                $authinst = get_field('auth_instance', 'institution', 'id', $user->authinstance);
                if ($USER->get('admin') || $USER->is_institutional_admin($authinst)) {
                    // determine the current remoteusername
                    $current_remotename = get_field('auth_remote_user', 'remoteusername', 'authinstance', $user->authinstance, 'localusr', $user->id);
                    if (!$current_remotename) {
                        $current_remotename = $user->username;
                    }
                    // remove row if new authinstance row already exists to avoid doubleups
                    delete_records('auth_remote_user', 'authinstance', $values['authinstance'], 'localusr', $user->id);
                    insert_record('auth_remote_user', (object) array('authinstance' => $values['authinstance'], 'remoteusername' => $current_remotename, 'localusr' => $user->id));
                }
                if ($user->haspassword && !$needspassword) {
                    $user->password = '';
                } else {
                    if ($needspassword && !$user->haspassword) {
                        $needpassword++;
                    }
                }
                $user->authinstance = $values['authinstance'];
                update_record('usr', $user, 'id');
                $updated++;
            }
        }
    }
    db_commit();
    if ($needpassword) {
        // Inform the user that they may need to reset passwords
        $SESSION->add_info_msg(get_string('bulkchangeauthmethodresetpassword', 'admin', $needpassword));
    }
    $message = get_string('bulkchangeauthmethodsuccess', 'admin', $updated);
    $form->reply(PIEFORM_OK, array('message' => $message));
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:46,代码来源:bulk.php


示例6: edituser_site_submit

function edituser_site_submit(Pieform $form, $values)
{
    if (!($user = get_record('usr', 'id', $values['id']))) {
        return false;
    }
    if (isset($values['password']) && $values['password'] !== '') {
        $user->password = $values['password'];
        $user->salt = '';
    }
    $user->passwordchange = (int) ($values['passwordchange'] == 'on');
    $user->quota = $values['quota'];
    $user->expiry = db_format_timestamp($values['expiry']);
    global $USER;
    if ($USER->get('admin')) {
        // Not editable by institutional admins
        $user->staff = (int) ($values['staff'] == 'on');
        $user->admin = (int) ($values['admin'] == 'on');
        if ($user->admin) {
            activity_add_admin_defaults(array($user->id));
        }
    }
    if ($values['maildisabled'] == 0 && get_account_preference($user->id, 'maildisabled') == 1) {
        // Reset the sent and bounce counts otherwise mail will be disabled
        // on the next send attempt
        $u = new StdClass();
        $u->email = $user->email;
        $u->id = $user->id;
        update_bounce_count($u, true);
        update_send_count($u, true);
    }
    set_account_preference($user->id, 'maildisabled', $values['maildisabled']);
    // Authinstance can be changed by institutional admins if both the
    // old and new authinstances belong to the admin's institutions
    $remotename = get_field('auth_remote_user', 'remoteusername', 'authinstance', $user->authinstance, 'localusr', $user->id);
    if (!$remotename) {
        $remotename = $user->username;
    }
    if (isset($values['authinstance']) && ($values['authinstance'] != $user->authinstance || isset($values['remoteusername']) && $values['remoteusername'] != $remotename)) {
        $authinst = get_records_select_assoc('auth_instance', 'id = ? OR id = ?', array($values['authinstance'], $user->authinstance));
        if ($USER->get('admin') || $USER->is_institutional_admin($authinst[$values['authinstance']]->institution) && $USER->is_institutional_admin($authinst[$user->authinstance]->institution)) {
            delete_records('auth_remote_user', 'localusr', $user->id);
            if ($authinst[$values['authinstance']]->authname != 'internal') {
                if (isset($values['remoteusername']) && strlen($values['remoteusername']) > 0) {
                    $un = $values['remoteusername'];
                } else {
                    $un = $remotename;
                }
                insert_record('auth_remote_user', (object) array('authinstance' => $values['authinstance'], 'remoteusername' => $un, 'localusr' => $user->id));
            }
            $user->authinstance = $values['authinstance'];
        }
    }
    update_record('usr', $user);
    redirect('/admin/users/edit.php?id=' . $user->id);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:55,代码来源:edit.php


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


示例8: delete

 /**
  * Deletes a Collection
  *
  */
 public function delete()
 {
     $viewids = get_column('collection_view', 'view', 'collection', $this->id);
     db_begin();
     // Delete navigation blocks within the collection's views which point at this collection.
     if ($viewids) {
         $values = $viewids;
         $values[] = 'navigation';
         $navigationblocks = get_records_select_assoc('block_instance', 'view IN (' . join(',', array_fill(0, count($viewids), '?')) . ') AND blocktype = ?', $values);
         if ($navigationblocks) {
             safe_require('blocktype', 'navigation');
             foreach ($navigationblocks as $b) {
                 $bi = new BlockInstance($b->id, $b);
                 $configdata = $bi->get('configdata');
                 if (isset($configdata['collection']) && $configdata['collection'] == $this->id) {
                     $bi->delete();
                 }
             }
         }
     }
     delete_records('collection_view', 'collection', $this->id);
     delete_records('collection_tag', 'collection', $this->id);
     delete_records('collection', 'id', $this->id);
     // Secret url records belong to the collection, so remove them from the view.
     // @todo: add user message to whatever calls this.
     if ($viewids) {
         delete_records_select('view_access', 'view IN (' . join(',', $viewids) . ') AND token IS NOT NULL');
     }
     db_commit();
 }
开发者ID:agwells,项目名称:Mahara-1,代码行数:34,代码来源:collection.php


示例9: get_extra_view_info

 public static function get_extra_view_info(&$viewdata, $getartefacts = true)
 {
     if ($viewdata) {
         // Get view owner details for display
         $owners = array();
         $groups = array();
         $institutions = array();
         foreach ($viewdata as $v) {
             if ($v->owner && !isset($owners[$v->owner])) {
                 $owners[$v->owner] = (int) $v->owner;
             } else {
                 if ($v->group && !isset($groups[$v->group])) {
                     $groups[$v->group] = (int) $v->group;
                 } else {
                     if (strlen($v->institution) && !isset($institutions[$v->institution])) {
                         $institutions[$v->institution] = $v->institution;
                     }
                 }
             }
         }
         $viewidlist = join(',', array_map('intval', array_keys($viewdata)));
         if ($getartefacts) {
             $artefacts = get_records_sql_array('SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
                 FROM {view_artefact} va
                 INNER JOIN {artefact} a ON va.artefact = a.id
                 INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
                 WHERE va.view IN (' . $viewidlist . ')
                 GROUP BY va.view, va.artefact, a.title, a.artefacttype, t.plugin
                 ORDER BY a.title, va.artefact', '');
             if ($artefacts) {
                 foreach ($artefacts as $artefactrec) {
                     safe_require('artefact', $artefactrec->plugin);
                     $classname = generate_artefact_class_name($artefactrec->artefacttype);
                     $artefactobj = new $classname(0, array('title' => $artefactrec->title));
                     $artefactobj->set('dirty', false);
                     if (!$artefactobj->in_view_list()) {
                         continue;
                     }
                     $artname = $artefactobj->display_title(30);
                     if (strlen($artname)) {
                         $viewdata[$artefactrec->view]->artefacts[] = array('id' => $artefactrec->artefact, 'title' => $artname);
                     }
                 }
             }
         }
         $tags = get_records_select_array('view_tag', 'view IN (' . $viewidlist . ')');
         if ($tags) {
             foreach ($tags as &$tag) {
                 $viewdata[$tag->view]->tags[] = $tag->tag;
             }
         }
         if (!empty($owners)) {
             $owners = get_records_select_assoc('usr', 'id IN (' . join(',', $owners) . ')', null, '', 'id,username,firstname,lastname,preferredname,admin,staff,studentid,email,profileicon');
         }
         if (!empty($groups)) {
             $groups = get_records_select_assoc('group', 'id IN (' . join(',', $groups) . ')', null, '', 'id,name');
         }
         if (!empty($institutions)) {
             $institutions = get_records_assoc('institution', '', '', '', 'name,displayname');
             $institutions['mahara']->displayname = get_config('sitename');
         }
         foreach ($viewdata as &$v) {
             $v->shortdescription = str_shorten_html(str_replace('<br />', ' ', $v->description), 100, true);
             if ($v->owner) {
                 $v->sharedby = View::owner_name($v->ownerformat, $owners[$v->owner]);
                 $v->user = $owners[$v->owner];
             } else {
                 if ($v->group) {
                     $v->sharedby = $groups[$v->group]->name;
                 } else {
                     if ($v->institution) {
                         $v->sharedby = $institutions[$v->institution]->displayname;
                     }
                 }
             }
             $v = (array) $v;
         }
     }
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:79,代码来源:view.php


示例10: array

        $values = array($institution);
        $params['institution'] = $institution;
    } else {
        define('MENUITEM', 'content/notes');
        $pageheading = get_string('mynotes', 'artefact.internal');
        $where = 'owner = ?';
        $values = array($USER->get('id'));
    }
}
if ($params) {
    $baseurl .= '?' . http_build_query($params);
}
$where .= ' AND artefacttype = ?';
$values[] = 'html';
$count = count_records_select('artefact', $where, $values);
$data = get_records_select_assoc('artefact', $where, $values, 'title, id', '*', $offset, $limit);
// Get blocks
if ($data) {
    $blocks = get_records_sql_assoc('
        SELECT
            bi.id AS block, bi.title AS blocktitle,
            va.artefact,
            va.view, v.title AS viewtitle, v.owner, v.group, v.institution, v.ownerformat, v.urlid
        FROM
            {block_instance} bi
            JOIN {view_artefact} va ON bi.id = va.block
            JOIN {view} v ON va.view = v.id
        WHERE
            va.artefact IN (' . join(',', array_fill(0, count($data), '?')) . ')
        ORDER BY va.view, bi.title', array_keys($data));
    if ($blocks) {
开发者ID:sarahjcotton,项目名称:mahara,代码行数:31,代码来源:notes.php


示例11: define

 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'group.php';
$data['error'] = false;
$data['message'] = null;
$initialgroups = param_integer_list('initialgroups', array());
$resultgroups = param_integer_list('resultgroups', array());
$userid = param_integer('userid');
$addtype = param_variable('addtype');
// Prevent group membership changing done by ordinary members, Tutors can only
// add members to group and cannot remove anyone. Group admins can do anything.
// With regard to invitation, both admins and tutors can invite people.
$allgroups = array_unique(array_merge($initialgroups, $resultgroups));
$groupdata = get_records_select_assoc('group', 'id IN (' . join(',', array_fill(0, count($allgroups), '?')) . ')', $allgroups);
foreach (group_get_grouptypes() as $grouptype) {
    safe_require('grouptype', $grouptype);
}
foreach ($allgroups as $groupid) {
    if (!($loggedinrole = group_user_access($groupid))) {
        json_reply('local', get_string('accessdenied', 'error'));
    }
    if ($loggedinrole == 'admin') {
        continue;
    }
    if (!in_array($loggedinrole, call_static_method('GroupType' . $groupdata[$groupid]->grouptype, 'get_view_assessing_roles'))) {
        json_reply('local', get_string('accessdenied', 'error'));
    }
    if (group_user_access($groupid, $userid) && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
        json_reply('local', get_string('cantremovememberfromgroup', 'group', hsc($groupdata[$groupid]->name)));
开发者ID:sarahjcotton,项目名称:mahara,代码行数:31,代码来源:changegroupsmembership.json.php


示例12: archive_mime_types

 public static function archive_mime_types()
 {
     static $mimetypes = null;
     if (is_null($mimetypes)) {
         $descriptions = self::archive_file_descriptions();
         $mimetypes = get_records_select_assoc('artefact_file_mime_types', 'description IN (' . join(',', array_map('db_quote', array_keys($descriptions))) . ')');
     }
     return $mimetypes;
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:9,代码来源:lib.php


示例13: switch

    }
    switch (group_user_access($groupid)) {
        case 'member':
            json_reply('local', get_string('accessdenied', 'error'));
            break;
        case 'tutor':
            if ($usertype = group_user_access($groupid, $userid)) {
                if ($usertype == 'member' && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
                    json_reply('local', get_string('cantremovemember', 'group'));
                } elseif ($usertype != 'member' && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
                    json_reply('local', get_string('cantremoveuserisadmin', 'group'));
                }
            }
    }
}
$groupdata = get_records_select_assoc('group', 'id IN (' . join(',', array_unique(array_merge($initialgroups, $resultgroups))) . ')');
if ($jointype == 'controlled') {
    db_begin();
    //remove group membership
    if ($groupstoremove = array_diff($initialgroups, $resultgroups)) {
        $groupstoremovemail = '';
        foreach ($groupstoremove as $groupid) {
            group_remove_user($groupid, $userid, $role = null);
            $groupstoremovemail .= $groupdata[$groupid]->name . "\n";
        }
    }
    //add group membership
    if ($groupstoadd = array_diff($resultgroups, $initialgroups)) {
        $groupstoaddmail = '';
        foreach ($groupstoadd as $groupid) {
            group_add_user($groupid, $userid, $role = null);
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:31,代码来源:changegroupsmembership.json.php


示例14: locked_profile_fields

function locked_profile_fields()
{
    global $USER;
    // Profile fields are locked for a user if they are locked by any
    // institution the user is a member of, but not an admin for.
    $lockinginstitutions = array_keys($USER->get('institutions'));
    $lockinginstitutions[] = 'mahara';
    $lockinginstitutions = array_diff($lockinginstitutions, $USER->get('admininstitutions'));
    return get_records_select_assoc('institution_locked_profile_field', 'name IN (' . join(',', array_map('db_quote', $lockinginstitutions)) . ')', null, '', 'profilefield,name');
}
开发者ID:Br3nda,项目名称:mahara,代码行数:10,代码来源:index.php


示例15: get_folder_path_for_file

 /**
  * Given a file, returns the folder path for it in the Mahara files area
  *
  * The path is pre-sanitised so it can be used when generating the export
  *
  * @param  $file The file or folder to get the folder path for
  * @return string
  */
 private function get_folder_path_for_file($file)
 {
     if ($this->folderdata === null) {
         $this->folderdata = get_records_select_assoc('artefact', "artefacttype = 'folder' AND owner = ?", array($file->get('owner')));
         if ($this->folderdata) {
             foreach ($this->folderdata as &$folder) {
                 $folder->title = PluginExportHtml::sanitise_path($folder->title);
             }
         }
     }
     $folderpath = ArtefactTypeFileBase::get_full_path($file->get('parent'), $this->folderdata);
     return $folderpath;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:21,代码来源:lib.php


示例16: removeMember

 public function removeMember($user)
 {
     if (is_numeric($user)) {
         $user = get_record('usr', 'id', $user);
     }
     db_begin();
     // If the user is being authed by the institution they are
     // being removed from, change them to internal auth, or if
     // we can't find that, some other no institution auth.
     $authinstances = get_records_select_assoc('auth_instance', "institution IN ('mahara', ?)", array($this->name), "institution = 'mahara' DESC, authname = 'internal' DESC");
     $oldauth = $user->authinstance;
     if (isset($authinstances[$oldauth]) && $authinstances[$oldauth]->institution == $this->name) {
         foreach ($authinstances as $ai) {
             if ($ai->authname == 'internal' && $ai->institution == 'mahara') {
                 $user->authinstance = $ai->id;
                 break;
             } else {
                 if ($ai->institution == 'mahara') {
                     $user->authinstance = $ai->id;
                     break;
                 }
             }
         }
         delete_records('auth_remote_user', 'authinstance', $oldauth, 'localusr', $user->id);
         // If the old authinstance was external, the user may need
         // to set a password
         if ($user->password == '') {
             log_debug('resetting pw for ' . $user->id);
             $this->removeMemberSetPassword($user);
         } else {
             if ($authinstances[$oldauth]->authname != 'internal') {
                 $sitename = get_config('sitename');
                 $fullname = display_name($user, null, true);
                 email_user($user, null, get_string('noinstitutionoldpassemailsubject', 'mahara', $sitename, $this->displayname), get_string('noinstitutionoldpassemailmessagetext', 'mahara', $fullname, $this->displayname, $sitename, $user->username, get_config('wwwroot'), get_config('wwwroot'), $sitename, get_config('wwwroot')), get_string('noinstitutionoldpassemailmessagehtml', 'mahara', hsc($fullname), hsc($this->displayname), hsc($sitename), hsc($user->username), get_config('wwwroot'), get_config('wwwroot'), get_config('wwwroot'), hsc($sitename), get_config('wwwroot'), get_config('wwwroot')));
             }
         }
         update_record('usr', $user);
     }
     // If this user has a favourites list which is updated by this institution, remove it
     // from this institution's control.
     // Don't delete it in case the user wants to keep it, but move it out of the way, so
     // another institution can create a new faves list with the same name.
     execute_sql("\n            UPDATE {favorite}\n            SET institution = NULL, shortname = substring(shortname from 1 for 100) || '.' || ?\n            WHERE owner = ? AND institution = ?", array(substr($this->name, 0, 100) . '.' . get_random_key(), $user->id, $this->name));
     execute_sql("\n            DELETE FROM {usr_tag}\n            WHERE usr = ? AND tag " . db_ilike() . " 'lastinstitution:%'", array($user->id));
     insert_record('usr_tag', (object) array('usr' => $user->id, 'tag' => 'lastinstitution:' . strtolower($this->name)));
     // If the user's license default is set to "institution default", remove the pref
     delete_records('usr_account_preference', 'usr', $user->id, 'field', 'licensedefault', 'value', LICENSE_INSTITUTION_DEFAULT);
     delete_records('usr_institution', 'usr', $user->id, 'institution', $this->name);
     handle_event('updateuser', $user->id);
     db_commit();
 }
开发者ID:kienv,项目名称:mahara,代码行数:51,代码来源:institution.php


示例17: progressbar_sideblock

function progressbar_sideblock($preview = false)
{
    global $USER;
    // TODO: Remove this URL param from here, and when previewing pass institution
    // by function param instead
    $institution = param_alphanum('i', null);
    if (is_array($USER->institutions) && count($USER->institutions) > 0) {
        // Get all institutions where user is member
        $institutions = array();
        foreach ($USER->institutions as $inst) {
            if (empty($inst->suspended)) {
                $institutions = array_merge($institutions, array($inst->institution => $inst->displayname));
            }
        }
        // Set user's first institution in case that institution isn't
        // set yet or user is not member of currently set institution.
        if (!$institution || !array_key_exists($institution, $institutions)) {
            $institution = key(array_slice($institutions, 0, 1));
        }
    } else {
        $institutions = array();
        $institution = 'mahara';
    }
    // Set appropriate preview according to institution, if the institutio is selected
    // If the institution isn't selected then show preview for first institution, which
    // is also selected as a default value in institution selection box
    if ($preview) {
        $default = get_column('institution', 'name');
        // TODO: Remove this URL param from here, and when previewing pass institution
        // by function param instead
        $institution = param_alphanum('institution', $default[0]);
    }
    // We need to check to see if any of the institutions have profile completeness to allow
    // the select box to work correctly for users with more than one institution
    $multiinstitutionprogress = false;
    $counting = null;
    if (!empty($institutions)) {
        foreach ($institutions as $key => $value) {
            if ($result = get_records_select_assoc('institution_config', 'institution=? and field like \'progressbaritem_%\'', array($key), 'field', 'field, value')) {
                $multiinstitutionprogress = true;
                if ($key == $institution) {
                    $counting = $result;
                    break;
                }
            }
        }
    } else {
        $counting = get_records_select_assoc('institution_config', 'institution=? and field like \'progressbaritem_%\'', array($institution), 'field', 'field, value');
    }
    // Get artefacts that count towards profile completeness
    if ($counting) {
        // Without locked ones (site locked and institution locked)
        $sitelocked = (array) get_column('institution_locked_profile_field', 'profilefield', 'name', 'mahara');
        $instlocked = (array) get_column('institution_locked_profile_field', 'profilefield', 'name', $institution);
        $locked = $sitelocked + $instlocked;
        foreach ($locked as $l) {
            unset($counting["progressbaritem_internal_{$l}"]);
        }
        $totalcounting = 0;
        foreach ($counting as $c) {
            $totalcounting = $totalcounting + $c->value;
        }
        // Get all artefacts for progressbar and create data structure
        $data = array();
        // For the artefact_get_progressbar_items function, we want them indexed by plugin
        // and then subindexed by artefact. For most other purposes, having them indexed
        // by config name is sufficient
        $onlytheseplugins = array();
        foreach ($counting as $key => $obj) {
            // This one has no value. So remove it from the list.
            if (!$obj->value) {
                unset($counting[$key]);
                continue;
            }
            $parts = explode('_', $obj->field);
            $plugin = $parts[1];
            $item = $parts[2];
            if (empty($onlytheseplugins[$plugin])) {
                $onlytheseplugins[$plugin] = array();
            }
            $onlytheseplugins[$plugin][$item] = $item;
        }
        $progressbaritems = artefact_get_progressbar_items($onlytheseplugins);
        // Get the data link about every item
        foreach ($progressbaritems as $pluginname => $itemlist) {
            foreach ($itemlist as $artefactname => $item) {
                $itemname = "progressbaritem_{$pluginname}_{$artefactname}";
                $c = $counting[$itemname];
                $target = $c->value;
                $completed = 0;
                $data[$itemname] = array('artefact' => $artefactname, 'link' => progressbar_artefact_link($pluginname, $artefactname), 'counting' => $target, 'completed' => $completed, 'display' => (bool) $c->value, 'label' => progressbar_artefact_task_label($pluginname, $artefactname, $target, $completed));
            }
        }
        if ($preview) {
            $percent = 0;
        } else {
            // Since this is not a preview, gather data about the users' actual progress,
            // and update the records we placed in $data.
            // Get a list of all the basic artefact types in this progress bar.
            $nonmeta = array();
//.........这里部分代码省略.........
开发者ID:kienv,项目名称:mahara,代码行数:101,代码来源:mahara.php


示例18: artefactchooser_folder_data

 public static function artefactchooser_folder_data(&$artefact)
 {
     // Grab data about all folders the artefact owner has, so we
     // can make full paths to them, and show the artefact owner if
     // it's a group or institution.
     static $folderdata = array();
     $ownerkey = $artefact->owner . '::' . $artefact->group . '::' . $artefact->institution;
     if (!isset($folderdata[$ownerkey])) {
         $ownersql = artefact_owner_sql($artefact->owner, $artefact->group, $artefact->institution);
         $folderdata[$ownerkey]->data = get_records_select_assoc('artefact', "artefacttype='folder' AND {$ownersql}", array(), '', 'id, title, parent');
         if ($artefact->group) {
             $folderdata[$ownerkey]->ownername = get_field('group', 'name', 'id', $artefact->group) . ':';
         } else {
             if ($artefact->institution) {
                 if ($artefact->institution == 'mahara') {
                     $folderdata[$ownerkey]->ownername = get_config('sitename') . ':';
                 } else {
                     $folderdata[$ownerkey]->ownername = get_field('institution', 'displayname', 'name', $artefact->institution) . ':';
                 }
             } else {
                 $folderdata[$ownerkey]->ownername = '';
             }
         }
     }
     return $folderdata[$ownerkey];
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:26,代码来源:lib.php


示例19: delete_by_artefacttype

该文章已有0人参与评论

请发表评论

全部评论

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