');
- }
- if (($ENV{'form.uploaddoc.filename'}) &&
- ($ENV{'form.storeupl'}) && ($allowed)) {
- if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/) {
- $syllabus{'uploaded.photourl'}=
- &Apache::lonnet::userfileupload('uploaddoc',1);
- }
- $syllabus{'uploaded.lastmodified'}=time;
- &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
- }
- if (($allowed) && ($ENV{'form.storesyl'})) {
- foreach (keys %syllabusfields) {
- my $field=$ENV{'form.'.$_};
- $field=~s/\s+$//s;
- $field=~s/\\<\;/g;
- $field=~s/\>/\>\;/g;
- $syllabus{$_}=$field;
- }
- $syllabus{'uploaded.lastmodified'}=time;
- &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
- }
+ my $allowed;
+
+ if ($group ne '') {
+ $allowed = $group_edit_perm;
+ if (!$allowed) {
+ $allowed = $group_home_edit;
+ }
+ } else {
+ $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+ }
+ my $privileged=$allowed;
+ if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) {
+ $forcestudent='student';
+ }
+
+ if ($forcestudent or $target eq 'tex') { $allowed=0; }
+
+ if (($env{'form.uploaddoc.filename'} and $target ne 'tex') &&
+ ($env{'form.storeupl'}) && ($allowed)) {
+ if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
+ if ($syllabus{'uploaded.photourl'}) {
+ &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
+ }
+ if ($group ne '') {
+ $syllabus{'uploaded.photourl'}=&Apache::lonnet::userfileupload(
+ 'uploaddoc',1,"grouppage/$group");
+ } else {
+ $syllabus{'uploaded.photourl'}=
+ &Apache::lonnet::userfileupload('uploaddoc',1,'simplepage');
+ }
+ }
+ $syllabus{'uploaded.lastmodified'}=time;
+ &Apache::lonnet::put($db_name,\%syllabus,$dom,$crs);
+ }
+# if ($allowed && $env{'form.delupl'}) {
+# if ($syllabus{'uploaded.photourl'}) {
+# &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
+# delete($syllabus{'uploaded.photourl'});
+# &Apache::lonnet::del('simplepage',['uploaded.photourl']);
+# }
+# }
+ if (($allowed) && ($env{'form.storesyl'})) {
+ foreach my $syl_field (keys(%syllabusfields)) {
+ my $field=$env{'form.'.$syl_field};
+ chomp($field);
+ $field=~s/\s+$//s;
+ $field=~s/^\s+//s;
+ $field=~s/\ $//s;
+ $field=&Apache::lonfeedback::clear_out_html($field,1);
+ $syllabus{$syl_field}=$field;
+ }
+ $syllabus{'uploaded.lastmodified'}=time;
+ &Apache::lonnet::put($db_name,\%syllabus,$dom,$crs);
+ }
+
+#---Print Function
+ if ($target ne 'tex') {
+ if ($allowed || $privileged) {
+ my $functions=&Apache::lonhtmlcommon::start_funclist();
+ if ($allowed) {
+ $functions.=&Apache::lonhtmlcommon::add_item_funclist(
+ ''
+ .&mt('Show Student View').''
+ .&Apache::loncommon::help_open_topic(
+ 'Uploaded_Templates_PublicView'));
+ } elsif ($privileged) {
+ my $edittext = &mt('Edit');
+ if ($group ne '') {
+ $edittext = &mt('Edit Group Homepage');
+ }
+ $functions.=&Apache::lonhtmlcommon::add_item_funclist(
+ ''
+ .$edittext.'');
+ if ($group ne '') {
+ if ($group_edit_perm) {
+ $functions.=&Apache::lonhtmlcommon::add_item_funclist(
+ ''
+ .&mt('Edit Group Settings')
+ .'');
+ }
+ }
+ }
+ $functions.=&Apache::lonhtmlcommon::end_funclist();
+ $r->print(&Apache::loncommon::head_subbox($functions));
+ }
+ }
+
+#---Print help Text
+ if($target ne 'tex'){
+ if ($allowed) {
+ $r->print(&Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')));
+ }
+ }
# ---------------------------------------------------------------- Get syllabus
- if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
- if ($syllabus{'uploaded.photourl'}) {
- $r->print('');
- }
- if ($allowed) {
- $r->print(
- '');
- }
- $r->print('
');
+ if ((($syllabus{'uploaded.lastmodified'}) &&
+ (($group ne '' && ($group_home_view || $group_edit_perm ||
+ $group_view_perm)) || ($group eq ''))) || ($allowed)) {
+ #Print the title
+ my $titletext=&HTML::Entities::encode($syllabus{'aaa_title'},'<>&"');
+ if ($target ne 'tex') {
+ if ($allowed) {
+ }
+ $r->print('
'.$titletext.'
');
+ } else {
+ my $safeinit;
+ $r->print(&Apache::lonxml::xmlparse($r,'tex','
'.$titletext.'
'));
+ }
+ if ($allowed) {
+ if ($env{'form.grade_target'} ne 'tex') {
+ #editbox for title
+ $r->print('');
+ }
+
} else {
- $r->print('
No page information provided.
');
+ if ($group ne '') {
+ &display_group_links($r,$target,$group,'view',$refarg,%groupinfo);
+ } else {
+ my $text=&mt('No page information provided.');
+ if ($target ne 'tex') {
+ $r->print('