Changed to use confirm and deleteCollateral and setCollateral from wobject superclass.
This commit is contained in:
parent
dd112a5306
commit
82490a390f
8 changed files with 90 additions and 139 deletions
|
|
@ -575,7 +575,7 @@ sub set {
|
|||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
=head2 setCollateral ( tableName, keyName, properties [ , useSequenceNumber, wobjectId ] )
|
||||
=head2 setCollateral ( tableName, keyName, properties [ , useSequenceNumber, useWobjectId ] )
|
||||
|
||||
Performs and insert/update of collateral data for any wobject's
|
||||
collateral data. Returns the primary key value for that row of
|
||||
|
|
|
|||
|
|
@ -121,17 +121,9 @@ sub www_deleteFile {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteDownload {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(12,$namespace).'<p>';
|
||||
$output .= '<div align="center">'.
|
||||
'<a href="'.WebGUI::URL::page('func=deleteDownloadConfirm&wid='.
|
||||
$session{form}{wid}.'&did='.$session{form}{did}).'">'.
|
||||
WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('func=edit&wid='.$session{form}{wid}).'">'.
|
||||
WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
return $_[0]->confirm(WebGUI::International::get(12,$namespace),
|
||||
WebGUI::URL::page('func=deleteDownloadConfirm&wid='.$session{form}{wid}.'&did='.$session{form}{did}));
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
|
|
@ -143,7 +135,7 @@ sub www_deleteDownloadConfirm {
|
|||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$file->deleteNode;
|
||||
WebGUI::SQL->write("delete from DownloadManager_file where downloadId=$session{form}{did}");
|
||||
$_[0]->deleteCollateral("DownloadManager_file","downloadId",$session{form}{did});
|
||||
_reorderDownloads($session{form}{wid});
|
||||
return "";
|
||||
} else {
|
||||
|
|
@ -267,37 +259,27 @@ sub www_editDownload {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editDownloadSave {
|
||||
my ($file, $alt1, $alt2, $sqlAdd);
|
||||
my ($file, %files);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
if ($session{form}{did} eq "new") {
|
||||
$session{form}{did} = getNextId("downloadId");
|
||||
WebGUI::SQL->write("insert into DownloadManager_file (wobjectId,downloadId,sequenceNumber)
|
||||
values (".$_[0]->get("wobjectId").",$session{form}{did},-1)");
|
||||
_reorderDownloads($_[0]->get("wobjectId"));
|
||||
}
|
||||
$files{downloadId} = $_[0]->setCollateral("DownloadManager_file", "downloadId", {
|
||||
downloadId => $session{form}{did},
|
||||
fileTitle => $session{form}{fileTitle},
|
||||
briefSynopsis => $session{form}{briefSynopsis},
|
||||
dateUploaded => time(),
|
||||
groupToView => $session{form}{groupToView}
|
||||
});
|
||||
_reorderDownloads($_[0]->get("wobjectId"));
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$file->save("downloadFile");
|
||||
if ($file->getFilename ne "") {
|
||||
$sqlAdd = ', downloadFile='.quote($file->getFilename);
|
||||
}
|
||||
$alt1 = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$alt1->save("alternateVersion1");
|
||||
if ($alt1->getFilename ne "") {
|
||||
$sqlAdd .= ', alternateVersion1='.quote($alt1->getFilename);
|
||||
}
|
||||
$alt2 = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$alt2->save("alternateVersion2");
|
||||
if ($alt2->getFilename ne "") {
|
||||
$sqlAdd = ', alternateVersion2='.quote($alt2->getFilename);
|
||||
}
|
||||
WebGUI::SQL->write("update DownloadManager_file set ".
|
||||
"fileTitle=".quote($session{form}{fileTitle}).
|
||||
$sqlAdd.
|
||||
", groupToView='$session{form}{groupToView}'".
|
||||
", briefSynopsis=".quote($session{form}{briefSynopsis}).
|
||||
", dateUploaded=".time().
|
||||
" where downloadId=".$session{form}{did}
|
||||
);
|
||||
$files{downloadFile} = $file->getFilename;
|
||||
$files{fileTitle} = $files{downloadFile} if ($session{form}{fileTitle} eq "");
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$file->save("alternateVersion1");
|
||||
$files{alternateVersion1} = $file->getFilename;
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$file->save("alternateVersion2");
|
||||
$files{alternateVersion2} = $file->getFilename;
|
||||
$_[0]->setCollateral("DownloadManager_file", "downloadId", \%files);
|
||||
if ($session{form}{proceed}) {
|
||||
$session{form}{did} = "new";
|
||||
$_[0]->www_editDownload();
|
||||
|
|
|
|||
|
|
@ -141,9 +141,9 @@ sub www_deleteEvent {
|
|||
sub www_deleteEventConfirm {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
if ($session{form}{rid} > 0) {
|
||||
WebGUI::SQL->write("delete from EventsCalendar_event where recurringEventId=$session{form}{rid}");
|
||||
$_[0]->deleteCollateral("EventsCalendar_event","recurringEventId",$session{form}{rid});
|
||||
} else {
|
||||
WebGUI::SQL->write("delete from EventsCalendar_event where eventId=$session{form}{eid}");
|
||||
$_[0]->deleteCollateral("EventsCalendar_event","eventId",$session{form}{eid});
|
||||
}
|
||||
return "";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -70,15 +70,9 @@ sub set {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteQuestion {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(7,$namespace).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('func=deleteQuestionConfirm&wid='.$_[0]->get("wobjectId").
|
||||
'&qid='.$session{form}{qid}).'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page().'">'.WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
return $_[0]->confirm(WebGUI::International::get(7,$namespace),
|
||||
WebGUI::URL::page('func=deleteQuestionConfirm&wid='.$_[0]->get("wobjectId").'&qid='.$session{form}{qid}));
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
|
|
@ -88,7 +82,7 @@ sub www_deleteQuestion {
|
|||
sub www_deleteQuestionConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from FAQ_question where questionId=$session{form}{qid}");
|
||||
$_[0]->deleteCollateral("FAQ_question","questionId",$session{form}{qid});
|
||||
_reorderQuestions($_[0]->get("wobjectId"));
|
||||
return "";
|
||||
} else {
|
||||
|
|
@ -165,14 +159,11 @@ sub www_editQuestion {
|
|||
sub www_editQuestionSave {
|
||||
my ($seq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
if ($session{form}{qid} eq "new") {
|
||||
($seq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from FAQ_question where wobjectId=".$_[0]->get("wobjectId"));
|
||||
$session{form}{qid} = getNextId("questionId");
|
||||
WebGUI::SQL->write("insert into FAQ_question (wobjectId,questionId,sequenceNumber) values
|
||||
(".$_[0]->get("wobjectId").",$session{form}{qid},".($seq+1).")");
|
||||
}
|
||||
WebGUI::SQL->write("update FAQ_question set question=".quote($session{form}{question}).",
|
||||
answer=".quote($session{form}{answer})." where questionId=$session{form}{qid}");
|
||||
$_[0]->setCollateral("FAQ_question", "questionId", {
|
||||
questionId => $session{form}{qid},
|
||||
question => $session{form}{question},
|
||||
answer => $session{form}{answer}
|
||||
});
|
||||
if ($session{form}{proceed}) {
|
||||
$session{form}{qid} = "new";
|
||||
return $_[0]->www_editQuestion();
|
||||
|
|
|
|||
|
|
@ -70,16 +70,9 @@ sub set {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteLink {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(9,$namespace).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('func=deleteLinkConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid})
|
||||
.'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('func=edit&wid='.$session{form}{wid})
|
||||
.'">'.WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
return $_[0]->confirm(WebGUI::International::get(9,$namespace),
|
||||
WebGUI::URL::page('func=deleteLinkConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}));
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
|
|
@ -89,7 +82,7 @@ sub www_deleteLink {
|
|||
sub www_deleteLinkConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from LinkList_link where linkId=$session{form}{lid}");
|
||||
$_[0]->deleteCollateral("LinkList_link","linkId",$session{form}{lid});
|
||||
_reorderLinks($session{form}{wid});
|
||||
return "";
|
||||
} else {
|
||||
|
|
@ -175,15 +168,13 @@ sub www_editLink {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_editLinkSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
if ($session{form}{lid} eq "new") {
|
||||
$session{form}{lid} = getNextId("linkId");
|
||||
WebGUI::SQL->write("insert into LinkList_link (wobjectId,linkId,sequenceNumber) values (".$_[0]->get("wobjectId")
|
||||
.",$session{form}{lid},-1)");
|
||||
_reorderLinks($_[0]->get("wobjectId"));
|
||||
}
|
||||
WebGUI::SQL->write("update LinkList_link set name=".quote($session{form}{name}).",
|
||||
url=".quote($session{form}{url}).",description=".quote($session{form}{description}).",
|
||||
newWindow='$session{form}{newWindow}' where linkId=$session{form}{lid}");
|
||||
$_[0]->setCollateral("LinkList_link", "linkId", {
|
||||
linkId => $session{form}{lid},
|
||||
description => $session{form}{description},
|
||||
newWindow => $session{form}{newWindow},
|
||||
url => $session{form}{url},
|
||||
name => $session{form}{name}
|
||||
});
|
||||
if ($session{form}{proceed}) {
|
||||
$session{form}{lid} = "new";
|
||||
$_[0]->www_editLink();
|
||||
|
|
|
|||
|
|
@ -90,31 +90,25 @@ sub set {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteField {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(19,$namespace).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('func=deleteFieldConfirm&wid='.$_[0]->get("wobjectId").
|
||||
'&fid='.$session{form}{fid}).'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('func=edit&wid='.$_[0]->get("wobjectId"))
|
||||
.'">'.WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
return $_[0]->confirm(WebGUI::International::get(19,$namespace),
|
||||
WebGUI::URL::page('func=deleteFieldConfirm&wid='.$_[0]->get("wobjectId").'&fid='.$session{form}{fid}));
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteFieldConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from MailForm_field where mailFieldId=$session{form}{fid}");
|
||||
_reorderFields($_[0]->get("wobjectId"));
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$_[0]->deleteCollateral("MailForm_field","mailFieldId",$session{form}{fid});
|
||||
_reorderFields($_[0]->get("wobjectId"));
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ sub www_editSave {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_resetVotes {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from Poll_answer where wobjectId=".$_[0]->get("wobjectId"));
|
||||
$_[0]->deleteCollateral("Poll_answer","wobjectId",$_[0]->get("wobjectId"));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,15 +272,11 @@ sub www_deleteImage {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteSubmission {
|
||||
my ($output, $owner);
|
||||
my ($owner);
|
||||
($owner) = WebGUI::SQL->quickArray("select userId from UserSubmission_submission where submissionId=$session{form}{sid}");
|
||||
if ($owner == $session{user}{userId} || WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) {
|
||||
$output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(17,$namespace).'<p>';
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::page('func=deleteSubmissionConfirm&wid='.
|
||||
$session{form}{wid}.'&sid='.$session{form}{sid}).'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page().'">'.WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
return $_[0]->confirm(WebGUI::International::get(17,$namespace),
|
||||
WebGUI::URL::page('func=deleteSubmissionConfirm&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}));
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
|
|
@ -291,7 +287,7 @@ sub www_deleteSubmissionConfirm {
|
|||
my ($output, $owner, $file);
|
||||
($owner) = WebGUI::SQL->quickArray("select userId from UserSubmission_submission where submissionId=$session{form}{sid}");
|
||||
if ($owner == $session{user}{userId} || WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) {
|
||||
WebGUI::SQL->write("delete from UserSubmission_submission where submissionId=$session{form}{sid}");
|
||||
$_[0]->deleteCollateral("UserSubmission_submission","submissionId",$session{form}{sid});
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$file->deleteNode;
|
||||
return "";
|
||||
|
|
@ -412,41 +408,38 @@ sub www_editSubmission {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSubmissionSave {
|
||||
my ($sqlAdd,$submission,$image,$attachment,$title,$u);
|
||||
my ($submission, %hash, $file, $u);
|
||||
$submission = $_[0]->getCollateral("UserSubmission_submission","submissionId",$session{form}{sid});
|
||||
if ($submission->{userId} == $session{user}{userId} || ($submission->{submissionId} eq "new" && WebGUI::Privilege::isInGroup($_[0]->get("groupToContribute"))) || WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) {
|
||||
if ($submission->{submissionId} eq "new") {
|
||||
$session{form}{sid} = getNextId("submissionId");
|
||||
WebGUI::SQL->write("insert into UserSubmission_submission (wobjectId,submissionId,userId,username)
|
||||
values (".$_[0]->get("wobjectId").",$session{form}{sid},$session{user}{userId},".quote($session{user}{username}).")");
|
||||
if ($submission->{userId} == $session{user}{userId}
|
||||
|| ($submission->{submissionId} eq "new"
|
||||
&& WebGUI::Privilege::isInGroup($_[0]->get("groupToContribute")))
|
||||
|| WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) {
|
||||
$hash{title} = $session{form}{title} || WebGUI::International::get(16,$namespace);
|
||||
if ($session{form}{sid} eq "new") {
|
||||
$hash{username} = $session{user}{username};
|
||||
$hash{userId} = $session{user}{userId};
|
||||
if ($session{setting}{useKarma}) {
|
||||
$u = WebGUI::User->new($session{user}{userId});
|
||||
$u->karma($_[0]->get("karmaPerSubmission"),$namespace." (".$_[0]->get("wobjectId")."/".$session{form}{sid}.")","User submission.");
|
||||
$u = WebGUI::User->new($session{user}{userId});
|
||||
$u->karma($_[0]->get("karmaPerSubmission"),$namespace." (".$_[0]->get("wobjectId")
|
||||
."/".$session{form}{sid}.")","User submission.");
|
||||
}
|
||||
}
|
||||
$image = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$image->save("image");
|
||||
if ($image->getFilename ne "") {
|
||||
$sqlAdd = 'image='.quote($image->getFilename).', ';
|
||||
}
|
||||
$attachment = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$attachment->save("attachment");
|
||||
if ($attachment->getFilename ne "") {
|
||||
$sqlAdd .= 'attachment='.quote($attachment->getFilename).', ';
|
||||
|
||||
}
|
||||
if ($session{form}{title} ne "") {
|
||||
$title = $session{form}{title};
|
||||
} else {
|
||||
$title = WebGUI::International::get(16,$namespace);
|
||||
}
|
||||
WebGUI::SQL->write("update UserSubmission_submission set
|
||||
dateSubmitted=".time().",
|
||||
convertCarriageReturns=$session{form}{convertCarriageReturns},
|
||||
title=".quote($title).",
|
||||
content=".quote($session{form}{content}).",
|
||||
".$sqlAdd."
|
||||
status='".$_[0]->get("defaultStatus")."'
|
||||
where submissionId=$session{form}{sid}");
|
||||
$hash{submissionId} = $session{form}{sid};
|
||||
$hash{dateSubmitted} = time();
|
||||
$hash{content} = $session{form}{content};
|
||||
$hash{convertCarriageReturns} => $session{form}{convertCarriageReturns};
|
||||
$hash{status} = $_[0]->get("defaultStatus");
|
||||
$session{form}{sid} = $_[0]->setCollateral("UserSubmission_submission", "submissionId",\%hash,0);
|
||||
%hash = ();
|
||||
$hash{submissionId} = $session{form}{sid};
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$file->save("image");
|
||||
$hash{image} = $file->getFilename;
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$file->save("attachment");
|
||||
$hash{attachment} = $file->getFilename;
|
||||
$_[0]->setCollateral("UserSubmission_submission", "submissionId", \%hash, 0);
|
||||
if ($_[0]->get("defaultStatus") ne "Approved") {
|
||||
WebGUI::MessageLog::addInternationalizedEntry('',$_[0]->get("groupToApprove"),
|
||||
WebGUI::URL::page('func=viewSubmission&wid='.$_[0]->get("wobjectId").'&sid='.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue