Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
ec8805ab
Commit
ec8805ab
authored
Nov 21, 2007
by
Richard Mansfield
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create admin user account editing page
parent
16154f09
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
201 additions
and
54 deletions
+201
-54
htdocs/admin/users/edit.php
htdocs/admin/users/edit.php
+168
-0
htdocs/js/adminusersearch.js
htdocs/js/adminusersearch.js
+0
-51
htdocs/lang/en.utf8/admin.php
htdocs/lang/en.utf8/admin.php
+14
-0
htdocs/lib/searchlib.php
htdocs/lib/searchlib.php
+0
-2
htdocs/theme/default/templates/admin/users/edit.tpl
htdocs/theme/default/templates/admin/users/edit.tpl
+18
-0
htdocs/theme/default/templates/admin/users/username.tpl
htdocs/theme/default/templates/admin/users/username.tpl
+1
-1
No files found.
htdocs/admin/users/
suspend
.php
→
htdocs/admin/users/
edit
.php
View file @
ec8805ab
...
...
@@ -27,7 +27,7 @@
define
(
'INTERNAL'
,
1
);
define
(
'ADMIN'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
define
(
'TITLE'
,
get_string
(
'
suspenduser
'
,
'admin'
));
define
(
'TITLE'
,
get_string
(
'
edituseraccount
'
,
'admin'
));
define
(
'SECTION_PLUGINTYPE'
,
'core'
);
define
(
'SECTION_PLUGINNAME'
,
'admin'
);
require_once
(
'pieforms/pieform.php'
);
...
...
@@ -38,38 +38,131 @@ if (!$user = get_record('usr', 'id', $id)) {
throw
new
UserNotFoundException
(
"User not found"
);
}
$f
=
pieform
(
array
(
'name'
=>
'suspend'
,
'elements'
=>
array
(
'id'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$id
,
),
'reason'
=>
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'reason'
),
),
'submit'
=>
array
(
'type'
=>
'submitcancel'
,
'value'
=>
array
(
get_string
(
'suspenduser'
,
'admin'
),
get_string
(
'cancel'
)),
),
)
));
if
(
empty
(
$user
->
suspendedcusr
))
{
$suspendform
=
pieform
(
array
(
'name'
=>
'suspend'
,
'plugintype'
=>
'core'
,
'pluginname'
=>
'admin'
,
'elements'
=>
array
(
'id'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$id
,
),
'reason'
=>
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'reason'
),
),
'submit'
=>
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'suspenduser'
,
'admin'
),
),
)
));
}
else
{
$suspendform
=
pieform
(
array
(
'name'
=>
'unsuspend'
,
'plugintype'
=>
'core'
,
'pluginname'
=>
'admin'
,
'elements'
=>
array
(
'id'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$id
,
),
'submit'
=>
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'unsuspenduser'
,
'admin'
),
),
)
));
}
function
suspend_submit
(
Pieform
$form
,
$values
)
{
global
$SESSION
;
suspend_user
(
$values
[
'id'
],
$values
[
'reason'
]);
$SESSION
->
add_ok_msg
(
get_string
(
'usersuspended'
,
'admin'
));
redirect
(
'/
user/view
.php?id='
.
$values
[
'id'
]);
redirect
(
'/
admin/users/edit
.php?id='
.
$values
[
'id'
]);
}
function
suspend_cancel_submit
()
{
redirect
(
'/admin/users/search.php'
);
function
unsuspend_submit
(
Pieform
$form
,
$values
)
{
global
$SESSION
;
unsuspend_user
(
$values
[
'id'
]);
$SESSION
->
add_ok_msg
(
get_string
(
'userunsuspended'
,
'admin'
));
redirect
(
'/admin/users/edit.php?id='
.
$values
[
'id'
]);
}
// Site-wide account settings
$elements
[
'id'
]
=
array
(
'type'
=>
'hidden'
,
'rules'
=>
array
(
'integer'
=>
true
),
'value'
=>
$id
,
);
$elements
[
'password'
]
=
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'resetpassword'
,
'admin'
),
);
$elements
[
'passwordchange'
]
=
array
(
'type'
=>
'checkbox'
,
'title'
=>
get_string
(
'forcepasswordchange'
,
'admin'
),
'defaultvalue'
=>
$user
->
passwordchange
,
);
$elements
[
'staff'
]
=
array
(
'type'
=>
'checkbox'
,
'title'
=>
get_string
(
'sitestaff'
,
'admin'
),
'defaultvalue'
=>
$user
->
staff
,
);
$elements
[
'admin'
]
=
array
(
'type'
=>
'checkbox'
,
'title'
=>
get_string
(
'siteadmin'
,
'admin'
),
'defaultvalue'
=>
$user
->
admin
,
);
$elements
[
'quota'
]
=
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'filequota'
,
'admin'
),
'defaultvalue'
=>
$user
->
quota
/
1048576
,
'rules'
=>
array
(
'integer'
=>
true
),
);
$elements
[
'submit'
]
=
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'savechanges'
,
'admin'
),
);
$mainform
=
pieform
(
array
(
'name'
=>
'edituser'
,
'renderer'
=>
'table'
,
'plugintype'
=>
'core'
,
'pluginname'
=>
'admin'
,
'elements'
=>
$elements
,
));
function
edituser_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
->
passwordchange
=
(
int
)
(
$values
[
'passwordchange'
]
==
'on'
);
$user
->
staff
=
(
int
)
(
$values
[
'staff'
]
==
'on'
);
$user
->
admin
=
(
int
)
(
$values
[
'admin'
]
==
'on'
);
$user
->
quota
=
$values
[
'quota'
]
*
1048576
;
update_record
(
'usr'
,
$user
);
redirect
(
'/admin/users/edit.php?id='
.
$user
->
id
);
}
$smarty
=
smarty
();
$smarty
->
assign
(
'user'
,
$user
);
$smarty
->
assign
(
'form'
,
$f
);
$smarty
->
display
(
'admin/users/suspend.tpl'
);
$smarty
->
assign
(
'suspendform'
,
$suspendform
);
$smarty
->
assign
(
'mainform'
,
$mainform
);
$smarty
->
display
(
'admin/users/edit.tpl'
);
?>
htdocs/js/adminusersearch.js
View file @
ec8805ab
...
...
@@ -6,7 +6,6 @@ function UserSearch() {
self
.
rewriteQueryButton
();
self
.
rewritePaging
();
self
.
rewriteSorting
();
self
.
rewriteSuspendLinks
();
self
.
params
=
{};
}
...
...
@@ -110,13 +109,6 @@ function UserSearch() {
$
(
'
results
'
).
innerHTML
=
data
.
data
;
self
.
rewritePaging
();
self
.
rewriteSorting
();
self
.
rewriteSuspendLinks
();
});
}
this
.
rewriteSuspendLinks
=
function
()
{
forEach
(
getElementsByTagAndClassName
(
'
a
'
,
'
suspend-user-link
'
,
'
searchresults
'
),
function
(
i
)
{
connect
(
i
,
'
onclick
'
,
suspendDisplay
);
});
}
...
...
@@ -124,46 +116,3 @@ function UserSearch() {
}
userSearch
=
new
UserSearch
();
function
suspendDisplay
(
e
)
{
e
.
stop
();
ref
=
this
.
parentNode
.
parentNode
;
// get the TR
var
reason
=
INPUT
({
'
type
'
:
'
text
'
});
var
cancelButton
=
BUTTON
({
'
type
'
:
'
button
'
},
get_string
(
'
cancel
'
));
var
saveButton
=
BUTTON
({
'
type
'
:
'
button
'
},
get_string
(
'
suspenduser
'
));
insertSiblingNodesAfter
(
ref
,
TR
(
null
,
TD
({
'
colSpan
'
:
6
},
get_string
(
'
suspensionreason
'
)
+
'
:
'
,
reason
,
cancelButton
,
saveButton
)));
reason
.
focus
();
connect
(
reason
,
'
onkeypress
'
,
function
(
k
)
{
if
(
k
.
key
().
code
==
13
)
{
self
.
suspendSave
(
reason
);
}
if
(
k
.
key
().
code
==
27
)
{
suspendCancel
(
reason
);
}
});
connect
(
cancelButton
,
'
onclick
'
,
partial
(
suspendCancel
,
reason
));
var
id
=
getNodeAttribute
(
this
,
'
href
'
).
replace
(
/.*
\?
id=
(\d
+
)
.*/
,
'
$1
'
);
connect
(
saveButton
,
'
onclick
'
,
partial
(
suspendSave
,
id
,
reason
));
}
function
suspendSave
(
id
,
reason
)
{
var
susReason
=
reason
.
value
;
sendjsonrequest
(
'
search.json.php
'
,
{
'
action
'
:
'
suspend
'
,
'
reason
'
:
susReason
,
'
id
'
:
id
},
'
GET
'
);
removeElement
(
reason
.
parentNode
.
parentNode
);
}
function
suspendCancel
(
reason
)
{
removeElement
(
reason
.
parentNode
.
parentNode
);
}
htdocs/lang/en.utf8/admin.php
View file @
ec8805ab
...
...
@@ -238,6 +238,20 @@ $string['usersdeletedsuccessfully'] = 'Users deleted successfully';
$string
[
'usersunsuspendedsuccessfully'
]
=
'Users unsuspended successfully'
;
$string
[
'suspendingadmin'
]
=
'Suspending Admin'
;
$string
[
'usersuspended'
]
=
'User suspended'
;
$string
[
'userunsuspended'
]
=
'User unsuspended'
;
// User account settings
$string
[
'siteaccountsettings'
]
=
'Site account settings'
;
$string
[
'resetpassword'
]
=
'Reset password'
;
$string
[
'forcepasswordchange'
]
=
'Force password change on next login'
;
$string
[
'sitestaff'
]
=
'Site staff'
;
$string
[
'siteadmin'
]
=
'Site administrator'
;
$string
[
'suspended'
]
=
'Suspended'
;
$string
[
'suspendedreason'
]
=
'Reason for suspension'
;
$string
[
'suspendedreasondescription'
]
=
'The explanation you enter here will be displayed to the user when they try to login'
;
$string
[
'unsuspenduser'
]
=
'Unsuspend User'
;
$string
[
'thisuserissuspended'
]
=
'This user has been suspended'
;
$string
[
'filequota'
]
=
'File quota (MB)'
;
// Institutions
$string
[
'admininstitutions'
]
=
'Admininster Institutions'
;
...
...
htdocs/lib/searchlib.php
View file @
ec8805ab
...
...
@@ -175,8 +175,6 @@ function build_admin_user_search_results($search, $offset, $limit, $sortby, $sor
'email'
=>
array
(
'name'
=>
get_string
(
'email'
)),
'institution'
=>
array
(
'name'
=>
get_string
(
'institution'
),
'template'
=>
file_get_contents
(
$templatedir
.
'institution.tpl'
)),
'suspend'
=>
array
(
'name'
=>
''
,
'template'
=>
file_get_contents
(
$templatedir
.
'suspendlink.tpl'
))
);
$smarty
=
smarty_core
();
...
...
htdocs/theme/default/templates/admin/users/edit.tpl
0 → 100644
View file @
ec8805ab
{
include
file
=
"header.tpl"
}
{
include
file
=
"columnfullstart.tpl"
}
<h2><a
href=
"
{
$WWWROOT
}
user/view.php?id=
{
$user
->
id
}
"
>
{
$user
->
firstname
}
{
$user
->
lastname
}
(
{
$user
->
username
}
)
</a></h2>
{
if
empty
(
$user
->
suspendedcusr
)
}
<h3>
{
str
tag
=
"suspenduser"
section
=
"admin"
}
</h3>
{
else
}
<h4>
{
str
tag
=
"thisuserissuspended"
section
=
"admin"
}
</h4>
<div><strong>
{
str
tag
=
"suspendedreason"
section
=
"admin"
}
:
</strong></div>
<div>
{
$user
->
suspendedreason
}
</div>
{/
if
}
{
$suspendform
}
<h3>
{
str
tag
=
"siteaccountsettings"
section
=
"admin"
}
</h3>
{
$mainform
}
{
include
file
=
"columnfullend.tpl"
}
{
include
file
=
"footer.tpl"
}
htdocs/theme/default/templates/admin/users/username.tpl
View file @
ec8805ab
<a
href=
"
{
$WWWROOT
}
user/view.php?id=
{
$r.id
}
"
>
{
$r.username
}
</a>
\ No newline at end of file
<a
href=
"
{
$WWWROOT
}
/admin/users/edit.php?id=
{
$r.id
}
"
>
{
$r.username
}
</a>
\ No newline at end of file
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