From: Sam H. v. a. <we...@ma...> - 2005-09-30 20:28:30
|
Log Message: ----------- added manage_course_files activity. changed FileManger to use new activity. added hasPermissions() checks to Index and Contentgenerator to only show File Manger when user has permission. Modified Files: -------------- webwork2/conf: global.conf.dist webwork2/lib/WeBWorK: ContentGenerator.pm webwork2/lib/WeBWorK/ContentGenerator/Instructor: FileManager.pm Index.pm Revision Data ------------- Index: global.conf.dist =================================================================== RCS file: /webwork/cvs/system/webwork2/conf/global.conf.dist,v retrieving revision 1.143 retrieving revision 1.144 diff -Lconf/global.conf.dist -Lconf/global.conf.dist -u -r1.143 -r1.144 --- conf/global.conf.dist +++ conf/global.conf.dist @@ -524,6 +524,7 @@ modify_set_def_files => "professor", modify_scoring_files => "professor", modify_problem_template_files => "professor", + manage_course_files => "professor", create_and_delete_courses => "professor", fix_course_databases => "professor", Index: ContentGenerator.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator.pm,v retrieving revision 1.149 retrieving revision 1.150 diff -Llib/WeBWorK/ContentGenerator.pm -Llib/WeBWorK/ContentGenerator.pm -u -r1.149 -r1.150 --- lib/WeBWorK/ContentGenerator.pm +++ lib/WeBWorK/ContentGenerator.pm @@ -646,8 +646,10 @@ print CGI::end_li(); ## Library browser - print CGI::li(CGI::a({href=>$self->systemLink($maker,params=>{ %displayOptions,})}, sp2nbsp($maker->name))) if $authz->hasPermissions($user, "modify_problem_sets"); - print CGI::li(CGI::a({href=>$self->systemLink($assigner,params=>{ %displayOptions,})}, sp2nbsp($assigner->name))) if $authz->hasPermissions($user, "assign_problem_sets"); + print CGI::li(CGI::a({href=>$self->systemLink($maker,params=>{ %displayOptions,})}, sp2nbsp($maker->name))) + if $authz->hasPermissions($user, "modify_problem_sets"); + print CGI::li(CGI::a({href=>$self->systemLink($assigner,params=>{ %displayOptions,})}, sp2nbsp($assigner->name))) + if $authz->hasPermissions($user, "assign_problem_sets"); ## Stats print CGI::li(CGI::a({href=>$self->systemLink($stats,params=>{ %displayOptions,})}, sp2nbsp($stats->name))); print CGI::start_li(); @@ -677,10 +679,13 @@ print CGI::end_ul(); print CGI::end_li(); ## Scoring tools - print CGI::li(CGI::a({href=>$self->systemLink($scoring,params=>{ %displayOptions,})}, sp2nbsp($scoring->name))) if $authz->hasPermissions($user, "score_sets"); + print CGI::li(CGI::a({href=>$self->systemLink($scoring,params=>{ %displayOptions,})}, sp2nbsp($scoring->name))) + if $authz->hasPermissions($user, "score_sets"); ## Email - print CGI::li(CGI::a({href=>$self->systemLink($mail,params=>{ %displayOptions,})}, sp2nbsp($mail->name))) if $authz->hasPermissions($user, "send_mail"); - print CGI::li(CGI::a({href=>$self->systemLink($fileMgr,params=>{ %displayOptions,})}, sp2nbsp($fileMgr->name))); + print CGI::li(CGI::a({href=>$self->systemLink($mail,params=>{ %displayOptions,})}, sp2nbsp($mail->name))) + if $authz->hasPermissions($user, "send_mail"); + print CGI::li(CGI::a({href=>$self->systemLink($fileMgr,params=>{ %displayOptions,})}, sp2nbsp($fileMgr->name))) + if $authz->hasPermissions($user, "manage_course_files"); #print CGI::li(CGI::a({href=>$self->systemLink($fileXfer)}, sp2nbsp($fileXfer->name))); print CGI::li( $self->helpMacro('instructor_links')); print CGI::end_ul(); Index: Index.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/Index.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -Llib/WeBWorK/ContentGenerator/Instructor/Index.pm -Llib/WeBWorK/ContentGenerator/Instructor/Index.pm -u -r1.49 -r1.50 --- lib/WeBWorK/ContentGenerator/Instructor/Index.pm +++ lib/WeBWorK/ContentGenerator/Instructor/Index.pm @@ -399,7 +399,10 @@ CGI::td(CGI::submit("edit_set_for_users", "Edit"). " one <b>set</b> for <b>users</b>"), CGI::td({-height=>4}), CGI::td(CGI::submit("email_users", "Email"). " your students"), - CGI::td(CGI::submit("transfer_files", "Transfer"). " course files"), + ($authz->hasPermissions($user, "manage_course_files") + ? CGI::td(CGI::submit("transfer_files", "Transfer"). " course files") + : () + ), ]) ) ) Index: FileManager.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -Llib/WeBWorK/ContentGenerator/Instructor/FileManager.pm -Llib/WeBWorK/ContentGenerator/Instructor/FileManager.pm -u -r1.15 -r1.16 --- lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm +++ lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm @@ -58,11 +58,9 @@ my $authz = $r->authz; my $user = $r->param('user'); - unless ($authz->hasPermissions($user, "access_instructor_tools")) { - $self->addbadmessage("You aren't authorized to manage course files"); - return; - } - + # we don't need to return an error here, because body() will print an error for us :) + return unless $authz->hasPermissions($user, "manage_course_files"); + my $action = $r->param('action'); $self->Download if ($action && $action eq 'Download'); my $file = $r->param('download'); @@ -111,8 +109,8 @@ my $user = $r->param('user'); my $key = $r->param('key'); - return CGI::em("You are not authorized to access the instructor tools") - unless $authz->hasPermissions($user, "access_instructor_tools"); + return CGI::em("You are not authorized to manage course files") + unless $authz->hasPermissions($user, "manage_course_files"); $self->{pwd} = $self->checkPWD($r->param('pwd') || HOME); return CGI::em("You have specified an illegal working directory!") unless defined $self->{pwd}; |