version 1.106.2.1, 2010/02/15 05:31:00
|
version 1.106.2.2, 2010/02/15 16:05:32
|
Line 62 sub handler {
|
Line 62 sub handler {
|
my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri); |
my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri); |
# ------------------------------------------------------------ Get query string |
# ------------------------------------------------------------ Get query string |
&Apache::loncommon::get_unprocessed_cgi |
&Apache::loncommon::get_unprocessed_cgi |
($ENV{'QUERY_STRING'},['delete', 'field', 'forcestudent','register','forceedit','forceflush','wrapperdisplay']); |
($ENV{'QUERY_STRING'},['delete', 'rename', 'field', 'forcestudent','register','forceedit','forceflush','wrapperdisplay']); |
# ----------------------------------------------------- Is this even a course? |
# ----------------------------------------------------- Is this even a course? |
my $homeserver=&Apache::lonnet::homeserver($cnum,$cdom); |
my $homeserver=&Apache::lonnet::homeserver($cnum,$cdom); |
if ($homeserver eq 'no_host') { |
if ($homeserver eq 'no_host') { |
Line 189 ENDSCRIPT
|
Line 189 ENDSCRIPT
|
&Apache::lonnet::del('syllabus', ['properties.v2_converted'], $cdom, $cnum); |
&Apache::lonnet::del('syllabus', ['properties.v2_converted'], $cdom, $cnum); |
delete $syllabus{'data.old_new_map'}; |
delete $syllabus{'data.old_new_map'}; |
&Apache::lonnet::del('syllabus', ['data.old_new_map'], $cdom, $cnum); |
&Apache::lonnet::del('syllabus', ['data.old_new_map'], $cdom, $cnum); |
|
delete $syllabus{'data.deleted_fields'}; |
|
&Apache::lonnet::del('syllabus', ['data.deleted_fields'], $cdom, $cnum); |
%syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum); # load db |
%syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum); # load db |
$r->print("Flushed syllabus DB file.<br />"); |
$r->print("Flushed syllabus DB file.<br />"); |
$r->print("Syllabus conflict: ".$syllabus{'properties.v2_conflict'}."<br />"); |
$r->print("Syllabus conflict: ".$syllabus{'properties.v2_conflict'}."<br />"); |
} |
} |
$r->print("Existing fields: ".$syllabus{'data.fields'}."<br />"); |
$r->print("Existing fields: ".$syllabus{'data.fields'}."<br />"); |
$r->print("Old-new map: ".$syllabus{'data.old_new_map'}."<br />"); |
$r->print("Old-new map: ".$syllabus{'data.old_new_map'}."<br />"); |
|
$r->print("Deleted fields: ".$syllabus{'data.deleted_fields'}."<br />"); |
if (!exists($syllabus{'data.fields'})) { |
if (!exists($syllabus{'data.fields'})) { |
# convert existing 2.x data to new DB fields |
# convert existing 2.x data to new DB fields |
# which become new primary data source for document |
# which become new primary data source for document |
Line 241 ENDSCRIPT
|
Line 244 ENDSCRIPT
|
#do not delete if file in v2 conversion mode |
#do not delete if file in v2 conversion mode |
if (exists($data{'data.field.'.$field}) && |
if (exists($data{'data.field.'.$field}) && |
!exists($data{'properties.v2_converted'})) { |
!exists($data{'properties.v2_converted'})) { |
$r->print("Field can be deleted.<br />"); |
$r->print("Field '$field' can be deleted.<br />"); |
|
# linearly parse "data.fields" and remove it |
|
for (my $i = 0; $i < length(@fields); $i++) { |
|
if ($fields[$i] eq $field) { |
|
splice(@fields, $i, 1); |
|
$r->print("Removed entry $i from 'data.fields'<br />"); |
|
} |
|
} |
|
# if "data.deleted" does not exist, create it |
|
my @deleted; |
|
if (!exists($data{'data.deleted_fields'})) { |
|
@deleted = []; |
|
} else { |
|
@deleted = @{thaw($data{'data.deleted_fields'})}; |
|
} |
|
# only if deleted does not exist in 'data.deleted', push it |
|
my $push = 1; |
|
for (my $i = 0; $i < length(@deleted); $i++) { |
|
if ($deleted[$i] eq $field) { |
|
$push = 0; |
|
last; |
|
} |
|
} |
|
unless (!$push) { |
|
push(@deleted, $field); |
|
} |
|
$data{'data.fields'} = freeze(\@fields); |
|
$data{'data.deleted_fields'} = freeze(\@deleted); |
|
|
|
&Apache::lonnet::put('syllabus',\%data,$cdom,$cnum); |
|
} |
|
} |
|
if (($allowed) && ($env{'form.rename'})) { |
|
my $field = $env{'form.rename'}; |
|
my $new_title = "Hello, World!"; |
|
chomp($field); |
|
$field=~s/[^0-9_]//g; |
|
#check if the field exists |
|
#do not delete if file in v2 conversion mode |
|
if (exists($data{'data.field.'.$field}) && |
|
!exists($data{'properties.v2_converted'})) { |
|
#sanitize HTML content |
|
$r->print("Rename -- field found.<br />"); |
|
my %db_entry = %{thaw($data{'data.field.'.$field})}; |
|
$new_title = &Apache::lonfeedback::clear_out_html($new_title, 1); |
|
$db_entry{title} = $new_title; |
|
$data{'data.field.'.$field} = freeze(\%db_entry); |
|
&Apache::lonnet::put('syllabus',\%data,$cdom,$cnum); |
} |
} |
} |
} |
if (($allowed) && ($env{'form.storesyl'})) { |
if (($allowed) && ($env{'form.storesyl'})) { |
Line 253 ENDSCRIPT
|
Line 303 ENDSCRIPT
|
if (exists($data{'data.field.'.$syl_field})) { |
if (exists($data{'data.field.'.$syl_field})) { |
$r->print("Creating/updated field ".$syl_field."<br />"); |
$r->print("Creating/updated field ".$syl_field."<br />"); |
%field_hash = exists($data{'data.field.'.$syl_field}) ? |
%field_hash = exists($data{'data.field.'.$syl_field}) ? |
%{thaw($data{'data.field.'.$syl_field})} : |
%{thaw($data{'data.field.'.$syl_field})} : (); |
(); |
|
$type = exists($field_hash{type}) ? $field_hash{type} : TYPE_TEXT_HTML; |
$type = exists($field_hash{type}) ? $field_hash{type} : TYPE_TEXT_HTML; |
chomp($field); |
chomp($field); |
$field=~s/\s+$//s; |
$field=~s/\s+$//s; |
Line 590 sub print_template_new_fields {
|
Line 639 sub print_template_new_fields {
|
$key, $default_rich_text); |
$key, $default_rich_text); |
&Apache::lontemplate::print_saveall_template($r); |
&Apache::lontemplate::print_saveall_template($r); |
if (!exists($data{'properties.v2_converted'})) { |
if (!exists($data{'properties.v2_converted'})) { |
$r->print("<a href='?delete=$key&forceedit=1'>Delete</a>"); |
$r->print("<a href='?delete=$key&forceedit=1'>Delete</a> "); |
|
$r->print("<a href='?rename=$key&forceedit=1'>Rename to \"Hello, World!\"</a>"); |
} |
} |
$r->print("</div>"); |
$r->print("</div>"); |
} |
} |