Esempio n. 1
0
 protected function reloadLiveUser($id = null)
 {
     if (is_null($id)) {
         $id = $this->get('id');
     }
     $this->find_by_id($id);
     $this->activityprefs = load_activity_preferences($id);
     $this->accountprefs = load_account_preferences($id);
     $this->load_views();
 }
Esempio n. 2
0
 * @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', 'settings/account');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'account');
define('SECTION_PAGE', 'preferences');
require dirname(dirname(__FILE__)) . '/init.php';
define('TITLE', get_string('account'));
require_once 'pieforms/pieform.php';
// load up user preferences
$prefs = (object) load_account_preferences($USER->id);
$authobj = AuthFactory::create($USER->authinstance);
// @todo auth preference for a password change screen for all auth methods other than internal
if (method_exists($authobj, 'change_password')) {
    $elements = array('changepassworddesc' => array('value' => '<tr><td colspan="2"><h3>' . get_string('changepassworddesc', 'account') . '</h3></td></tr>'), 'oldpassword' => array('type' => 'password', 'title' => get_string('oldpassword'), 'help' => true, 'autocomplete' => 'off'), 'password1' => array('type' => 'password', 'title' => get_string('newpassword')), 'password2' => array('type' => 'password', 'title' => get_string('confirmpassword')));
} else {
    if ($url = get_config_plugin_instance('auth', $USER->authinstance, 'changepasswordurl')) {
        // @todo contextual help
        $elements = array('changepasswordotherinterface' => array('value' => '<tr><td colspan="2"><h3>' . get_string('changepasswordotherinterface', 'account', $url) . '</h3></td></tr>'));
    } else {
        $elements = array();
    }
}
if ($authobj->authname == 'internal') {
    $elements['changeusernameheading'] = array('value' => '<tr><td colspan="2"><h3>' . get_string('changeusernameheading', 'account') . '</h3></td></tr>');
    $elements['username'] = array('type' => 'text', 'defaultvalue' => $USER->get('username'), 'title' => get_string('changeusername', 'account'), 'description' => get_string('changeusernamedesc', 'account', hsc(get_config('sitename'))));
Esempio n. 3
0
/**
 * Returns an object containing information about a user, including account
 * and activity preferences
 *
 * @param int $userid The ID of the user to retrieve information about
 * @return object     The user object. Note this is not in the same form as
 *                    the $USER object used to denote the current user -
 *                    the object returned by this method is a simple object.
 */
function get_user($userid)
{
    if (!($user = get_record('usr', 'id', $userid, null, null, null, null, '*, ' . db_format_tsfield('expiry') . ', ' . db_format_tsfield('lastlogin')))) {
        throw new InvalidArgumentException('Unknown user ' . $userid);
    }
    $user->activityprefs = load_activity_preferences($userid);
    $user->accountprefs = load_account_preferences($userid);
    return $user;
}
Esempio n. 4
0
 /**
  * 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];
 }