Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
d83b3ee9
Commit
d83b3ee9
authored
Dec 14, 2007
by
Richard Mansfield
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login as
parent
adf9b66b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
0 deletions
+107
-0
htdocs/admin/users/changeuser.php
htdocs/admin/users/changeuser.php
+41
-0
htdocs/admin/users/edit.php
htdocs/admin/users/edit.php
+7
-0
htdocs/auth/user.php
htdocs/auth/user.php
+42
-0
htdocs/lang/en.utf8/admin.php
htdocs/lang/en.utf8/admin.php
+8
-0
htdocs/lib/web.php
htdocs/lib/web.php
+6
-0
htdocs/theme/default/templates/admin/users/edit.tpl
htdocs/theme/default/templates/admin/users/edit.tpl
+3
-0
No files found.
htdocs/admin/users/changeuser.php
0 → 100644
View file @
d83b3ee9
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage admin
* @author Richard Mansfield <richard.mansfield@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
global
$USER
;
if
(
param_integer
(
'restore'
,
0
))
{
$id
=
$USER
->
restore_identity
();
redirect
(
get_config
(
'wwwroot'
)
.
'admin/users/edit.php?id='
.
$id
);
}
$id
=
param_integer
(
'id'
);
$USER
->
change_identity_to
(
$id
);
// Permissions checking is done in here
redirect
(
get_config
(
'wwwroot'
));
?>
htdocs/admin/users/edit.php
View file @
d83b3ee9
...
...
@@ -367,6 +367,13 @@ if ($suspended) {
$smarty
->
assign
(
'suspendform'
,
$suspendform
);
$smarty
->
assign
(
'siteform'
,
$siteform
);
$smarty
->
assign
(
'institutionform'
,
$institutionform
);
if
(
$id
!=
$USER
->
get
(
'id'
)
&&
is_null
(
$USER
->
get
(
'parentuser'
)))
{
$loginas
=
get_string
(
'loginasuser'
,
'admin'
,
$user
->
username
);
}
else
{
$loginas
=
null
;
}
$smarty
->
assign
(
'loginas'
,
$loginas
);
$smarty
->
display
(
'admin/users/edit.tpl'
);
?>
htdocs/auth/user.php
View file @
d83b3ee9
...
...
@@ -84,6 +84,7 @@ class User {
'institutions'
=>
array
(),
'theme'
=>
null
,
'admininstitutions'
=>
array
(),
'parentuser'
=>
null
,
'sesskey'
=>
''
);
$this
->
attributes
=
array
();
...
...
@@ -572,5 +573,46 @@ class LiveUser extends User {
$this
->
SESSION
->
set
(
"user/
$key
"
,
$value
);
return
$this
;
}
protected
function
reloadLiveUser
(
$id
)
{
$this
->
commit
();
$this
->
find_by_id
(
$id
);
$this
->
activityprefs
=
load_activity_preferences
(
$id
);
$this
->
accountprefs
=
load_account_preferences
(
$id
);
}
public
function
change_identity_to
(
$userid
)
{
$user
=
new
User
;
$user
->
find_by_id
(
$userid
);
if
(
!
$this
->
is_admin_for_user
(
$user
))
{
throw
new
AccessDeniedException
(
get_string
(
'loginasdenied'
,
'admin'
));
}
$olduser
=
$this
->
get
(
'parentuser'
);
if
(
!
is_null
(
$olduser
))
{
throw
new
UserException
(
get_string
(
'loginastwice'
,
'admin'
));
}
$olduser
=
new
StdClass
;
$olduser
->
id
=
$this
->
get
(
'id'
);
$olduser
->
name
=
$this
->
firstname
.
' '
.
$this
->
lastname
;
$this
->
reloadLiveUser
(
$userid
);
$this
->
set
(
'parentuser'
,
$olduser
);
}
public
function
restore_identity
()
{
$id
=
$this
->
get
(
'id'
);
$olduser
=
$this
->
get
(
'parentuser'
);
if
(
empty
(
$olduser
)
||
empty
(
$olduser
->
id
))
{
throw
new
UserException
(
get_string
(
'loginasrestorenodata'
,
'admin'
));
}
$this
->
reloadLiveUser
(
$olduser
->
id
);
$this
->
set
(
'parentuser'
,
null
);
return
$id
;
}
}
?>
htdocs/lang/en.utf8/admin.php
View file @
d83b3ee9
...
...
@@ -264,6 +264,14 @@ $string['suspendedby'] = 'This user has been suspended by %s';
$string
[
'filequota'
]
=
'File quota (MB)'
;
$string
[
'confirmremoveuserfrominstitution'
]
=
'Are you sure you want to remove the user from this institution?'
;
// Login as
$string
[
'loginasuser'
]
=
'Login as %s'
;
$string
[
'becomeadminagain'
]
=
'Become %s again'
;
// Login-as exceptions
$string
[
'loginasdenied'
]
=
'Attempt to login as another user without permission'
;
$string
[
'loginastwice'
]
=
'Attempt to login as another user when already logged in as another user'
;
$string
[
'loginasrestorenodata'
]
=
'No user data to restore'
;
// Institutions
$string
[
'admininstitutions'
]
=
'Admininster Institutions'
;
$string
[
'adminauthorities'
]
=
'Admininster Authorities'
;
...
...
htdocs/lib/web.php
View file @
d83b3ee9
...
...
@@ -1733,6 +1733,12 @@ function get_loggedin_string() {
'<span id="headerunreadmessages">'
.
get_string
(
$key
)
.
'</span></a>)'
;
}
$saveduser
=
$USER
->
get
(
'parentuser'
);
if
(
!
empty
(
$saveduser
)
&&
$saveduser
->
name
)
{
$str
.
=
' (<a href="'
.
get_config
(
'wwwroot'
)
.
'admin/users/changeuser.php?restore=1">'
.
get_string
(
'becomeadminagain'
,
'admin'
,
$saveduser
->
name
)
.
'</a>)'
;
}
return
$str
;
}
...
...
htdocs/theme/default/templates/admin/users/edit.tpl
View file @
d83b3ee9
...
...
@@ -3,6 +3,9 @@
{
include
file
=
"columnfullstart.tpl"
}
<div
id=
"edituser"
>
<h2><a
href=
"
{
$WWWROOT
}
user/view.php?id=
{
$user
->
id
}
"
>
{
$user
->
firstname
}
{
$user
->
lastname
}
(
{
$user
->
username
}
)
</a></h2>
{
if
!
empty
(
$loginas
)
}
<div><a
href=
"
{
$WWWROOT
}
admin/users/changeuser.php?id=
{
$user
->
id
}
"
>
{
$loginas
}
</a></div>
{/
if
}
{
if
!
$suspended
}
<h3>
{
str
tag
=
"suspenduser"
section
=
"admin"
}
</h3>
{
else
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment