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

PHP set_account_preference函数代码示例

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

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



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

示例1: edituser_site_submit

function edituser_site_submit(Pieform $form, $values)
{
    global $USER, $authobj, $SESSION;
    if (!($user = get_record('usr', 'id', $values['id']))) {
        return false;
    }
    if (is_using_probation()) {
        // Value should be between 0 and 10 inclusive
        $user->probation = ensure_valid_probation_points($values['probationpoints']);
    }
    if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
        $user->quota = $values['quota'];
        // check if the user has gone over the quota notify limit
        $quotanotifylimit = get_config_plugin('artefact', 'file', 'quotanotifylimit');
        if ($quotanotifylimit <= 0 || $quotanotifylimit >= 100) {
            $quotanotifylimit = 100;
        }
        $user->quotausedpercent = $user->quotaused / $user->quota * 100;
        $overlimit = false;
        if ($quotanotifylimit <= $user->quotausedpercent) {
            $overlimit = true;
        }
        $notified = get_field('usr_account_preference', 'value', 'field', 'quota_exceeded_notified', 'usr', $user->id);
        if ($overlimit && '1' !== $notified) {
            require_once get_config('docroot') . 'artefact/file/lib.php';
            ArtefactTypeFile::notify_users_threshold_exceeded(array($user), false);
            // no need to email admin as we can alert them right now
            $SESSION->add_error_msg(get_string('useroverquotathreshold', 'artefact.file', display_name($user)));
        } else {
            if ($notified && !$overlimit) {
                set_account_preference($user->id, 'quota_exceeded_notified', false);
            }
        }
    }
    $unexpire = $user->expiry && strtotime($user->expiry) < time() && (empty($values['expiry']) || $values['expiry'] > time());
    $newexpiry = db_format_timestamp($values['expiry']);
    if ($user->expiry != $newexpiry) {
        $user->expiry = $newexpiry;
        if ($unexpire) {
            $user->expirymailsent = 0;
            $user->lastaccess = db_format_timestamp(time());
        }
    }
    // Try to kick the user from any active login sessions, before saving data.
    require_once get_config('docroot') . 'auth/session.php';
    remove_user_sessions($user->id);
    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']);
    // process the change of the authinstance and or the remoteuser
    if (isset($values['authinstance']) && isset($values['remoteusername'])) {
        // Authinstance can be changed by institutional admins if both the
        // old and new authinstances belong to the admin's institutions
        $authinst = get_records_select_assoc('auth_instance', 'id = ? OR id = ?', array($values['authinstance'], $user->authinstance));
        // But don't bother if the auth instance doesn't take a remote username
        $authobj = AuthFactory::create($values['authinstance']);
        if ($USER->get('admin') || $USER->is_institutional_admin($authinst[$values['authinstance']]->institution) && ($USER->is_institutional_admin($authinst[$user->authinstance]->institution) || $user->authinstance == 1)) {
            if ($authobj->needs_remote_username()) {
                // determine the current remoteuser
                $current_remotename = get_field('auth_remote_user', 'remoteusername', 'authinstance', $user->authinstance, 'localusr', $user->id);
                if (!$current_remotename) {
                    $current_remotename = $user->username;
                }
                // if the remoteuser is empty
                if (strlen(trim($values['remoteusername'])) == 0) {
                    delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'localusr', $user->id);
                }
                // what should the new remoteuser be
                $new_remoteuser = get_field('auth_remote_user', 'remoteusername', 'authinstance', $values['authinstance'], 'localusr', $user->id);
                // save the remotename for the target existence check
                $target_remotename = $new_remoteuser;
                if (!$new_remoteuser) {
                    $new_remoteuser = $user->username;
                }
                if (strlen(trim($values['remoteusername'])) > 0) {
                    // value changed on page - use it
                    if ($values['remoteusername'] != $current_remotename) {
                        $new_remoteuser = $values['remoteusername'];
                    }
                }
                // only update remote name if the input actually changed on the page  or it doesn't yet exist
                if ($current_remotename != $new_remoteuser || !$target_remotename) {
                    // only remove the ones related to this traget authinstance as we now allow multiple
                    // for dual login mechanisms
                    delete_records('auth_remote_user', 'authinstance', $values['authinstance'], 'localusr', $user->id);
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:edit.php


示例2: set_account_preference

 /** @todo document this method */
 public function set_account_preference($field, $value)
 {
     if ($id = $this->get('id')) {
         set_account_preference($id, $field, $value);
     }
     $accountprefs = $this->get('accountprefs');
     $accountprefs[$field] = $value;
     $this->set('accountprefs', $accountprefs);
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:10,代码来源:user.php


示例3: views_by_owner

 public static function views_by_owner($group = null, $institution = null)
 {
     global $USER;
     // Pagination configuration
     $setlimit = true;
     $limit = param_integer('limit', 0);
     $userlimit = get_account_preference($USER->get('id'), 'viewsperpage');
     if ($limit > 0 && $limit != $userlimit) {
         $USER->set_account_preference('viewsperpage', $limit);
     } else {
         $limit = $userlimit;
     }
     $offset = param_integer('offset', 0);
     // load default page order from user settings as default and overwrite, if changed
     $usersettingorderby = get_account_preference($USER->get('id'), 'orderpagesby');
     $orderby = param_variable('orderby', $usersettingorderby);
     if ($usersettingorderby !== $orderby) {
         set_account_preference($USER->get('id'), 'orderpagesby', $orderby);
     }
     $query = param_variable('query', null);
     $tag = param_variable('tag', null);
     $searchoptions = array('titleanddescription' => get_string('titleanddescription', 'view'), 'tagsonly' => get_string('tagsonly', 'view'));
     if (!empty($tag)) {
         $searchtype = 'tagsonly';
         $searchdefault = $tag;
         $query = null;
     } else {
         $searchtype = 'titleanddescription';
         $searchdefault = $query;
     }
     $searchform = array('name' => 'searchviews', 'checkdirtychange' => false, 'class' => 'with-heading form-inline', 'elements' => array('searchwithin' => array('type' => 'fieldset', 'class' => 'dropdown-group js-dropdown-group', 'elements' => array('query' => array('type' => 'text', 'title' => get_string('search') . ': ', 'class' => 'with-dropdown js-with-dropdown', 'defaultvalue' => $searchdefault), 'type' => array('title' => get_string('searchwithin') . ': ', 'class' => 'dropdown-connect js-dropdown-connect searchviews-type', 'type' => 'select', 'options' => $searchoptions, 'defaultvalue' => $searchtype))), 'setlimit' => array('type' => 'hidden', 'value' => $setlimit), 'orderbygroup' => array('type' => 'fieldset', 'class' => 'input-group', 'elements' => array('orderby' => array('type' => 'select', 'class' => 'input-small', 'title' => get_string('sortby'), 'options' => array('atoz' => get_string('defaultsort', 'view'), 'latestcreated' => get_string('latestcreated', 'view'), 'latestmodified' => get_string('latestmodified', 'view'), 'latestviewed' => get_string('latestviewed', 'view'), 'mostvisited' => get_string('mostvisited', 'view'), 'mostcomments' => get_string('mostcomments', 'view')), 'defaultvalue' => $orderby), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-primary input-group-btn no-label', 'value' => get_string('search'))))));
     if ($group) {
         $searchform['elements']['group'] = array('type' => 'hidden', 'name' => 'group', 'value' => $group);
     } else {
         if ($institution) {
             $searchform['elements']['institution'] = array('type' => 'hidden', 'name' => 'institution', 'value' => $institution);
         }
     }
     $searchform = pieform($searchform);
     $data = self::get_myviews_data($limit, $offset, $query, $tag, $group, $institution, $orderby);
     $url = self::get_myviews_url($group, $institution, $query, $tag, $orderby);
     $pagination = build_pagination(array('url' => $url, 'count' => $data->count, 'limit' => $limit, 'setlimit' => $setlimit, 'offset' => $offset, 'jumplinks' => 6, 'numbersincludeprevnext' => 2));
     return array($searchform, $data, $pagination);
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:44,代码来源:view.php


示例4: check_overcount

/**
 * Check whether an email account is over the site-wide bounce threshold.
 * If the user is over threshold, then e-mail is disabled for their
 * account, and they are sent a notification to notify them of the change.
 *
 * @param object $mailinfo The row from artefact_internal_profile_email for
 * the user being processed.
 * @return boolean false if the user is not over threshold, true if they
 * are.
 */
function check_overcount($mailinfo)
{
    // if we don't handle bounce e-mails, then we can't be over threshold
    if (!get_config('bounces_handle')) {
        return false;
    }
    if (!($minbounces = get_config('bounces_min')) || !($bounceratio = get_config('bounces_ratio'))) {
        return false;
    }
    if ($mailinfo->mailssent == 0) {
        return false;
    }
    // If the bouncecount is larger than the allowed amount
    // and the bounce count ratio (bounces/total sent) is larger than the
    // bounceratio, then disable email
    $overlimit = $mailinfo->mailsbounced >= $minbounces && $mailinfo->mailsbounced / $mailinfo->mailssent >= $bounceratio;
    if ($overlimit) {
        if (get_account_preference($mailinfo->owner, 'maildisabled') != 1) {
            // Disable the e-mail account
            db_begin();
            set_account_preference($mailinfo->owner, 'maildisabled', 1);
            $lang = get_user_language($mailinfo->owner);
            // Send a notification that e-mail has been disabled
            $message = new StdClass();
            $message->users = array($mailinfo->owner);
            $message->subject = get_string_from_language($lang, 'maildisabled', 'account');
            $message->message = get_string_from_language($lang, 'maildisabledbounce', 'account', get_config('wwwroot') . 'account/');
            require_once 'activity.php';
            activity_occurred('maharamessage', $message);
            db_commit();
        }
        return true;
    }
    return false;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:45,代码来源:user.php


示例5: import_user_settings

 /**
  * Given a user and their remote user record, attempt to populate some of
  * the user's profile fields and account settings from the remote data.
  *
  * This does not change the first name, last name or e-mail fields, as these are
  * dealt with differently depending on whether we are creating the user
  * record or updating it.
  *
  * This method attempts to set:
  *
  * * City
  * * Country
  * * Language
  * * Introduction
  * * WYSIWYG editor setting
  *
  * @param User $user
  * @param stdClass $remoteuser
  */
 private function import_user_settings($user, $remoteuser)
 {
     $imported = array();
     // City
     if (!empty($remoteuser->city)) {
         if (get_profile_field($user->id, 'town') != $remoteuser->city) {
             set_profile_field($user->id, 'town', $remoteuser->city);
         }
         $imported[] = 'town';
     }
     // Country
     if (!empty($remoteuser->country)) {
         $validcountries = array_keys(getoptions_country());
         $newcountry = strtolower($remoteuser->country);
         if (in_array($newcountry, $validcountries)) {
             set_profile_field($user->id, 'country', $newcountry);
         }
         $imported[] = 'country';
     }
     // Language
     if (!empty($remoteuser->lang)) {
         $validlanguages = array_keys(get_languages());
         $newlanguage = str_replace('_utf8', '', strtolower($remoteuser->lang)) . '.utf8';
         if (in_array($newlanguage, $validlanguages)) {
             set_account_preference($user->id, 'lang', $newlanguage);
             $user->set_account_preference('lang', $newlanguage);
         }
     }
     // Description
     if (isset($remoteuser->description)) {
         if (get_profile_field($user->id, 'introduction') != $remoteuser->description) {
             set_profile_field($user->id, 'introduction', $remoteuser->description);
         }
         $imported[] = 'introduction';
     }
     // HTML Editor setting
     if (isset($remoteuser->htmleditor)) {
         $htmleditor = $remoteuser->htmleditor ? 1 : 0;
         if ($htmleditor != get_account_preference($user->id, 'wysiwyg')) {
             set_account_preference($user->id, 'wysiwyg', $htmleditor);
             $user->set_account_preference('wysiwyg', $htmleditor);
         }
     }
     return $imported;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:64,代码来源:lib.php


示例6: create_registered_user

 function create_registered_user($profilefields = array())
 {
     global $registration, $SESSION, $USER;
     require_once get_config('libroot') . 'user.php';
     db_begin();
     // Move the user record to the usr table from the registration table
     $registrationid = $registration->id;
     unset($registration->id);
     unset($registration->expiry);
     if ($expirytime = get_config('defaultregistrationexpirylifetime')) {
         $registration->expiry = db_format_timestamp(time() + $expirytime);
     }
     $registration->lastlogin = db_format_timestamp(time());
     $authinstance = get_record('auth_instance', 'institution', $registration->institution, 'authname', $registration->authtype ? $registration->authtype : 'internal');
     if (false == $authinstance) {
         throw new ConfigException('No ' . ($registration->authtype ? $registration->authtype : 'internal') . ' auth instance for institution');
     }
     if (!empty($registration->extra)) {
         // Additional user settings were added during confirmation
         $extrafields = unserialize($registration->extra);
     }
     $user = new User();
     $user->active = 1;
     $user->authinstance = $authinstance->id;
     $user->firstname = $registration->firstname;
     $user->lastname = $registration->lastname;
     $user->email = $registration->email;
     $user->username = get_new_username($user->firstname . $user->lastname);
     $user->passwordchange = 1;
     // Points that indicate the user is a "new user" who should be restricted from spammy activities.
     // We count these down when they do good things; when they have 0 they're no longer a "new user"
     if (is_using_probation()) {
         $user->probation = get_config('probationstartingpoints');
     } else {
         $user->probation = 0;
     }
     if ($registration->institution != 'mahara') {
         if (count_records_select('institution', "name != 'mahara'") == 1 || $registration->pending == 2) {
             if (get_config_plugin('artefact', 'file', 'institutionaloverride')) {
                 $user->quota = get_field('institution', 'defaultquota', 'name', $registration->institution);
             }
         }
     }
     create_user($user, $profilefields);
     // If the institution is 'mahara' then don't do anything
     if ($registration->institution != 'mahara') {
         $institutions = get_records_select_array('institution', "name != 'mahara'");
         // If there is only one available, join it without requiring approval
         if (count($institutions) == 1) {
             $user->join_institution($registration->institution);
         } else {
             if ($registration->pending == 2) {
                 if (get_config('requireregistrationconfirm') || get_field('institution', 'registerconfirm', 'name', $registration->institution)) {
                     $user->join_institution($registration->institution);
                 }
             } else {
                 if ($registration->authtype && $registration->authtype != 'internal') {
                     $auth = AuthFactory::create($authinstance->id);
                     if ($auth->weautocreateusers) {
                         $user->join_institution($registration->institution);
                     } else {
                         $user->add_institution_request($registration->institution);
                     }
                 } else {
                     $user->add_institution_request($registration->institution);
                 }
             }
         }
         if (!empty($extrafields->institutionstaff)) {
             // If the user isn't a member yet, this does nothing, but that's okay, it'll
             // only be set after successful confirmation.
             set_field('usr_institution', 'staff', 1, 'usr', $user->id, 'institution', $registration->institution);
         }
     }
     if (!empty($registration->lang) && $registration->lang != 'default') {
         set_account_preference($user->id, 'lang', $registration->lang);
     }
     // Delete the old registration record
     delete_records('usr_registration', 'id', $registrationid);
     db_commit();
     // Log the user in and send them to the homepage
     $USER = new LiveUser();
     $USER->reanimate($user->id, $authinstance->id);
     if (function_exists('local_post_register')) {
         local_post_register($registration);
     }
     $SESSION->add_ok_msg(get_string('registrationcomplete', 'mahara', get_config('sitename')));
     $SESSION->set('resetusername', true);
     redirect();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:90,代码来源:register.php


示例7: update_user

/**
 * Update user
 *
 * @param object $user stdclass for the usr table
 * @param object $profile profile field/values to set
 * @param string $remotename username on the remote site
 * @param array $accountprefs user account preferences to set
 * @param bool $forceupdateremote force delete of remotename before update attempted
 * @return array list of updated fields
 */
function update_user($user, $profile, $remotename = null, $accountprefs = array(), $forceupdateremote = false, $quickhash = false)
{
    require_once get_config('docroot') . 'auth/session.php';
    if (!empty($user->id)) {
        $oldrecord = get_record('usr', 'id', $user->id);
    } else {
        $oldrecord = get_record('usr', 'username', $user->username);
    }
    $userid = $oldrecord->id;
    db_begin();
    // Log the user out, otherwise they can overwrite all this on the next request
    remove_user_sessions($userid);
    $updated = array();
    $newrecord = new StdClass();
    foreach (get_object_vars($user) as $k => $v) {
        if (!empty($v) && ($k == 'password' || empty($oldrecord->{$k}) || $oldrecord->{$k} != $v)) {
            $newrecord->{$k} = $v;
            $updated[$k] = $v;
        }
        if (!empty($v) && $k === 'email' && $oldrecord->{$k} != $v) {
            set_user_primary_email($userid, $v);
        }
    }
    if (count(get_object_vars($newrecord))) {
        $newrecord->id = $userid;
        update_record('usr', $newrecord);
        if (!empty($newrecord->password)) {
            $newrecord->authinstance = $user->authinstance;
            reset_password($newrecord, false, $quickhash);
        }
    }
    foreach (get_object_vars($profile) as $k => $v) {
        if (get_profile_field($userid, $k) != $v) {
            set_profile_field($userid, $k, $v);
            $updated[$k] = $v;
        }
    }
    if ($remotename) {
        $oldremote = get_field('auth_remote_user', 'remoteusername', 'authinstance', $oldrecord->authinstance, 'localusr', $userid);
        if ($remotename != $oldremote) {
            $updated['remoteuser'] = $remotename;
        }
        delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'localusr', $userid);
        // force the update of the remoteuser - for the case of a series of user updates swapping the remoteuser name
        if ($forceupdateremote) {
            delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'remoteusername', $remotename);
        } else {
            // remote username must not already exist
            if (record_exists('auth_remote_user', 'remoteusername', $remotename, 'authinstance', $user->authinstance)) {
                throw new InvalidArgumentException("user_update: remoteusername already in use: " . $remotename);
            }
        }
        insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $remotename, 'localusr' => $userid));
    }
    // Update account preferences
    if (!empty($accountprefs)) {
        $expectedprefs = expected_account_preferences();
        foreach ($expectedprefs as $eprefkey => $epref) {
            if (isset($accountprefs[$eprefkey]) && $accountprefs[$eprefkey] != get_account_preference($userid, $eprefkey)) {
                set_account_preference($userid, $eprefkey, $accountprefs[$eprefkey]);
                $updated[$eprefkey] = $accountprefs[$eprefkey];
            }
        }
    }
    db_commit();
    return $updated;
}
开发者ID:patkira,项目名称:mahara,代码行数:77,代码来源:user.php


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


示例9: default_parent_for_copy

 /**
  * During the copying of a view, we might be allowed to copy
  * blogposts but not the containing blog.  We need to create a new
  * blog to hold the copied posts.
  */
 public function default_parent_for_copy(&$view, &$template, $artefactstoignore)
 {
     static $blogids;
     global $USER, $SESSION;
     $viewid = $view->get('id');
     if (isset($blogids[$viewid])) {
         return $blogids[$viewid];
     }
     $blogname = get_string('viewposts', 'artefact.blog', $viewid);
     $data = (object) array('title' => $blogname, 'description' => get_string('postscopiedfromview', 'artefact.blog', $template->get('title')), 'owner' => $view->get('owner'), 'group' => $view->get('group'), 'institution' => $view->get('institution'));
     $blog = new ArtefactTypeBlog(0, $data);
     $blog->commit();
     $blogids[$viewid] = $blog->get('id');
     if (!empty($data->group) || !empty($data->institution)) {
         $SESSION->add_ok_msg(get_string('copiedblogpoststonewjournal', 'collection'));
     } else {
         try {
             $user = get_user($view->get('owner'));
             set_account_preference($user->id, 'multipleblogs', 1);
             $SESSION->add_ok_msg(get_string('copiedblogpoststonewjournal', 'collection'));
         } catch (Exception $e) {
             $SESSION->add_error_msg(get_string('unabletosetmultipleblogs', 'error', $user->username, $viewid, get_config('wwwroot') . 'account/index.php'), false);
         }
         try {
             $USER->accountprefs = load_account_preferences($user->id);
         } catch (Exception $e) {
             $SESSION->add_error_msg(get_string('pleaseloginforjournals', 'error'));
         }
     }
     return $blogids[$viewid];
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:36,代码来源:lib.php


示例10: notify_users_threshold_exceeded

 /**
  * Notify users if their quota is above the quota threshold.
  * And notify admins if required as well
  *
  * @param $users         array of user objects - the $user object needs to include a quotausedpercent
  *                       that is set by: (quotaused / quota) * 100
  * @param $notifyadmins  bool
  */
 function notify_users_threshold_exceeded($users, $notifyadmins = false)
 {
     // if we have just been given a $user object
     if (is_object($users)) {
         $users[] = $users;
     }
     require_once get_config('docroot') . 'lib/activity.php';
     safe_require('notification', 'internal');
     foreach ($users as $user) {
         // check that they have not already been notified about being over the limit
         if (!get_record('usr_account_preference', 'usr', $user->id, 'field', 'quota_exceeded_notified', 'value', '1')) {
             $data = array('subject' => get_string('usernotificationsubject', 'artefact.file'), 'message' => get_string('usernotificationmessage', 'artefact.file', ceil((int) $user->quotausedpercent), display_size($user->quota)), 'users' => array($user->id), 'type' => 1);
             $activity = new ActivityTypeMaharamessage($data);
             $activity->notify_users();
             // notify admins
             if ($notifyadmins) {
                 $data = array('subject' => get_string('adm_notificationsubject', 'artefact.file'), 'message' => get_string('adm_notificationmessage', 'artefact.file', display_name($user), ceil((int) $user->quotausedpercent), display_size($user->quota)), 'users' => get_column('usr', 'id', 'admin', 1), 'url' => 'admin/users/edit.php?id=' . $user->id, 'urltext' => get_string('textlinktouser', 'artefact.file', display_name($user)), 'type' => 1);
                 $activity = new ActivityTypeMaharamessage($data);
                 $activity->notify_users();
             }
             set_account_preference($user->id, 'quota_exceeded_notified', true);
         }
     }
 }
开发者ID:vohung96,项目名称:mahara,代码行数:32,代码来源:lib.php


示例11: define

<?php

define('INTERNAL', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
define('TITLE', get_string('mobile_login'));
echo "\n\t<script language='javascript'>\n\tvar config = {\n\t\tloggedin:1\n\t\t\t\t};\n\t</script>";
$new_token = md5(openssl_random_pseudo_bytes(8));
$old_tokenstring = $USER->get_account_preference('mobileuploadtoken');
$tokenarray = explode('|', trim($old_tokenstring, '|'));
array_push($tokenarray, $new_token);
$new_tokenstring = empty($tokenarray) ? null : '|' . join('|', $tokenarray) . '|';
set_account_preference($USER->id, 'mobileuploadtoken', $new_tokenstring);
$arr = array('token' => $new_token, 'user' => $USER->get('username'));
$USER->commit();
echo json_encode($arr);
开发者ID:agwells,项目名称:Mahara-1,代码行数:15,代码来源:login.php


示例12: institution_submit

function institution_submit(Pieform $form, $values)
{
    global $SESSION, $institution, $add, $instancearray, $USER, $authinstances, $customthemedefaults;
    db_begin();
    // Update the basic institution record...
    if ($add) {
        $newinstitution = new Institution();
        $newinstitution->initialise($values['name'], $values['displayname']);
        $institution = $newinstitution->name;
    } else {
        $newinstitution = new Institution($institution);
        $newinstitution->displayname = $values['displayname'];
        $oldinstitution = get_record('institution', 'name', $institution);
        // Clear out any cached menus for this institution
        clear_menu_cache($institution);
    }
    $newinstitution->showonlineusers = !isset($values['showonlineusers']) ? 2 : $values['showonlineusers'];
    if (get_config('usersuniquebyusername')) {
        // Registering absolutely not allowed when this setting is on, it's a
        // security risk. See the documentation for the usersuniquebyusername
        // setting for more information
        $newinstitution->registerallowed = 0;
    } else {
        $newinstitution->registerallowed = $values['registerallowed'] ? 1 : 0;
        $newinstitution->registerconfirm = $values['registerconfirm'] ? 1 : 0;
    }
    if (!empty($values['lang'])) {
        if ($values['lang'] == 'sitedefault') {
            $newinstitution->lang = null;
        } else {
            $newinstitution->lang = $values['lang'];
        }
    }
    $newinstitution->theme = empty($values['theme']) || $values['theme'] == 'sitedefault' ? null : $values['theme'];
    $newinstitution->dropdownmenu = !empty($values['dropdownmenu']) ? 1 : 0;
    $newinstitution->skins = !empty($values['skins']) ? 1 : 0;
    require_once get_config('docroot') . 'artefact/comment/lib.php';
    $commentoptions = ArtefactTypeComment::get_comment_options();
    $newinstitution->commentsortorder = empty($values['commentsortorder']) ? $commentoptions->sort : $values['commentsortorder'];
    $newinstitution->commentthreaded = !empty($values['commentthreaded']) ? 1 : 0;
    if ($newinstitution->theme == 'custom') {
        if (!empty($oldinstitution->style)) {
            $styleid = $oldinstitution->style;
            delete_records('style_property', 'style', $styleid);
        } else {
            $record = (object) array('title' => get_string('customstylesforinstitution', 'admin', $newinstitution->displayname));
            $styleid = insert_record('style', $record, 'id', true);
        }
        $properties = array();
        $record = (object) array('style' => $styleid);
        foreach (array_keys($customthemedefaults) as $name) {
            $record->field = $name;
            $record->value = $values[$name];
            insert_record('style_property', $record);
            $properties[$name] = $values[$name];
        }
        // Cache the css
        $smarty = smarty_core();
        $smarty->assign('data', $properties);
        set_field('style', 'css', $smarty->fetch('customcss.tpl'), 'id', $styleid);
        $newinstitution->style = $styleid;
    } else {
        $newinstitution->style = null;
    }
    if (get_config('licensemetadata')) {
        $newinstitution->licensemandatory = !empty($values['licensemandatory']) ? 1 : 0;
        $newinstitution->licensedefault = isset($values['licensedefault']) ? $values['licensedefault'] : '';
    }
    if (!empty($values['resetcustom']) && !empty($oldinstitution->style)) {
        $newinstitution->style = null;
    }
    if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
        if (!empty($values['updateuserquotas']) && !empty($values['defaultquota'])) {
            execute_sql("UPDATE {usr} SET quota = ? WHERE id IN (SELECT usr FROM {usr_institution} WHERE institution = ?)", array($values['defaultquota'], $institution));
            // get all the users from the institution and make sure that they are still below
            // their quota threshold
            if ($users = get_records_sql_array('SELECT * FROM {usr} u LEFT JOIN {usr_institution} ui ON u.id = ui.usr AND ui.institution = ?', array($institution))) {
                $quotanotifylimit = get_config_plugin('artefact', 'file', 'quotanotifylimit');
                if ($quotanotifylimit <= 0 || $quotanotifylimit >= 100) {
                    $quotanotifylimit = 100;
                }
                foreach ($users as $user) {
                    $user->quota = $values['defaultquota'];
                    // check if the user has gone over the quota notify limit
                    $user->quotausedpercent = $user->quotaused / $user->quota * 100;
                    $overlimit = false;
                    if ($quotanotifylimit <= $user->quotausedpercent) {
                        $overlimit = true;
                    }
                    $notified = get_field('usr_account_preference', 'value', 'field', 'quota_exceeded_notified', 'usr', $user->id);
                    if ($overlimit && '1' !== $notified) {
                        require_once get_config('docroot') . 'artefact/file/lib.php';
                        ArtefactTypeFile::notify_users_threshold_exceeded(array($user), false);
                        // no need to email admin as we can alert them right now
                        $SESSION->add_error_msg(get_string('useroverquotathreshold', 'artefact.file', display_name($user)));
                    } else {
                        if ($notified && !$overlimit) {
                            set_account_preference($user->id, 'quota_exceeded_notified', false);
                        }
                    }
//.........这里部分代码省略.........
开发者ID:sarahjcotton,项目名称:mahara,代码行数:101,代码来源:institutions.php


示例13: create_registered_user

 function create_registered_user($profilefields = array())
 {
     global $registration, $SESSION, $USER;
     require_once get_config('libroot') . 'user.php';
     db_begin();
     // Move the user record to the usr table from the registration table
     $registrationid = $registration->id;
     unset($registration->id);
     unset($registration->expiry);
     if ($expirytime = get_config('defaultaccountlifetime')) {
         $registration->expiry = db_format_timestamp(time() + $expirytime);
     }
     $registration->lastlogin = db_format_timestamp(time());
     $authinstance = get_record('auth_instance', 'institution', $registration->institution, 'authname', 'internal');
     if (false == $authinstance) {
         // TODO: Specify exception
         throw new Exception('No internal auth instance for institution');
     }
     $user = new User();
     $user->username = $registration->username;
     $user->password = $registration->password;
     $user->salt = $registration->salt;
     $user->passwordchange = 0;
     $user->active = 1;
     $user->authinstance = $authinstance->id;
     $user->firstname = $registration->firstname;
     $user->lastname = $registration->lastname;
     $user->email = $registration->email;
     create_user($user, $profilefields);
     $user->add_institution_request($registration->institution);
     if (!empty($registration->lang) && $registration->lang != 'default') {
         set_account_preference($user->id, 'lang', $registration->lang);
     }
     // Delete the old registration record
     delete_records('usr_registration', 'id', $registrationid);
     db_commit();
     // Log the user in and send them to the homepage
     $USER = new LiveUser();
     $USER->reanimate($user->id, $authinstance->id);
     // A special greeting for special people
     if (in_array($user->username, array('waawaamilk', 'Mjollnir`', 'Ned', 'richardm', 'fmarier'))) {
         $SESSION->add_ok_msg('MAMA!!! Maharababy happy to see you :D :D!');
     } else {
         if ($user->username == 'htaccess') {
             $SESSION->add_ok_msg('Welcome B-Quack, htaccess!');
         } else {
             $SESSION->add_ok_msg(get_string('registrationcomplete', 'mahara', get_config('sitename')));
         }
     }
     redirect();
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:51,代码来源:register.php


示例14: cleanup

 /**
  * Deletes the default blog that is created for all users
  */
 public static function cleanup(PluginImportLeap $importer)
 {
     if (self::$importedablog && self::$firstblogid) {
         $blog = artefact_instance_from_id(self::$firstblogid);
         if (!$blog->has_children()) {
             // TODO see #544160
             $blog->delete();
         }
     }
     $userid = $importer->get('usr');
     if (count_records('artefact', 'artefacttype', 'blog', 'owner', $userid) != 1) {
         set_account_preference($userid, 'multipleblogs', 1);
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:17,代码来源:lib.php


示例15: create_registered_user

 function create_registered_user($profilefields = array())
 {
     global $registration, $SESSION, $USER;
     require_once get_config('libroot') . 'user.php';
     db_begin();
     // Move the user record to the usr table from the registration table
     $registrationid = $registration->id;
     unset($registration->id);
     unset($registration->expiry);
     if ($expirytime = get_config('defaultaccountlifetime')) {
         $registration->expiry = db_format_timestamp(time() + $expirytime);
     }
     $registration->lastlogin = db_format_timestamp(time());
     $authinstance = get_record('auth_instance', 'institution', $registration->institution, 'authname', 'internal');
     if (false == $authinstance) {
         throw new ConfigException('No internal auth instance for institution');
     }
     $user = new User();
     $user->active = 1;
     $user->authinstance = $authinstance->id;
     $user->firstname = $registration->firstname;
     $user->lastname = $registration->lastname;
     $user->email = $registration->email;
     $user->username = get_new_username($user->firstname . $user->lastname);
     $user->passwordchange = 1;
     $user->salt = substr(md5(rand(1000000, 9999999)), 2, 8);
     create_user($user, $profilefields);
     // If the institution is 'mahara' then don't do anything
     if ($registration->institution != 'mahara') {
         $institutions = get_records_select_array('institution', "name != 'mahara'");
         // If there is only one available, join it without requiring approval
         if (count($institutions) == 1) {
             $user->join_institution($registration->institution);
         } else {
             $user->add_institution_request($registration->institution);
         }
     }
     if (!empty($registration->lang) && $registration->lang != 'default') {
         set_account_preference($user->id, 'lang', $registration->lang);
     }
     // Delete the old registration record
     delete_records('usr_registration', 'id', $registrationid);
     db_commit();
     // Log the user in and send them to the homepage
     $USER = new LiveUser();
     $USER->reanimate($user->id, $authinstance->id);
     // A special greeting for special people
     if (in_array($user->username, array('waawaamilk', 'Mjollnir`', 'Ned', 'richardm', 'fmarier', 'naveg'))) {
         $SESSION->add_ok_msg('MAMA!!! Maharababy happy to see you :D :D!');
     } else {
         if ($user->username == 'htaccess') {
             $SESSION->add_ok_msg('Welcome B-Quack, htaccess!');
         } else {
             $SESSION->add_ok_msg(get_string('registrationcomplete', 'mahara', get_config('sitename')));
         }
     }
     $SESSION->set('resetusername', true);
     redirect();
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:59,代码来源:register.php



注:本文中的set_account_preference函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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