diff --git a/docs/upgrades/upgrade_3.7.0-3.8.0.sql b/docs/upgrades/upgrade_3.7.0-3.8.0.sql index dd3a01a15..f76ec2e79 100644 --- a/docs/upgrades/upgrade_3.7.0-3.8.0.sql +++ b/docs/upgrades/upgrade_3.7.0-3.8.0.sql @@ -51,6 +51,14 @@ delete from widget where namespace='Poll'; alter table Poll change widgetId wobjectId int not null; alter table Poll_answer change widgetId wobjectId int not null; +insert into wobject (wobjectId, pageId, title, displayTitle, processMacros, description, dateAdded, addedBy, namespace, lastEdited, editedBy, templatePosition, sequenceNumber, startDate, endDate) select widgetId, pageId, title, displayTitle, processMacros, description, dateAdded, addedBy, namespace, lastEdited, editedBy, templatePosition, sequenceNumber, dateAdded, 1336444487 from widget where namespace='LinkList'; +delete from widget where namespace='LinkList'; +alter table LinkList_link change widgetId wobjectId int not null; +alter table LinkList change widgetId wobjectId int not null; + + + + delete from international where language='Svenska'; INSERT INTO international VALUES (367,'WebGUI','Svenska','Bäst före'); diff --git a/lib/WebGUI/Widget/LinkList.pm b/lib/WebGUI/Widget/LinkList.pm deleted file mode 100644 index 9947ba7cf..000000000 --- a/lib/WebGUI/Widget/LinkList.pm +++ /dev/null @@ -1,356 +0,0 @@ -package WebGUI::Widget::LinkList; - -our $namespace = "LinkList"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - -use strict; -use Tie::CPHash; -use WebGUI::International; -use WebGUI::Macro; -use WebGUI::Privilege; -use WebGUI::Session; -use WebGUI::Shortcut; -use WebGUI::SQL; -use WebGUI::URL; -use WebGUI::Widget; - -#------------------------------------------------------------------- -sub _reorderLinks { - my ($sth, $i, $lid); - $sth = WebGUI::SQL->read("select linkId from LinkList_link where widgetId=$_[0] order by sequenceNumber"); - while (($lid) = $sth->array) { - WebGUI::SQL->write("update LinkList_link set sequenceNumber='$i' where linkId=$lid"); - $i++; - } - $sth->finish; -} - -#------------------------------------------------------------------- -sub duplicate { - my ($sth, %data, $newWidgetId, $pageId, @row, $newLinkId); - tie %data, 'Tie::CPHash'; - %data = getProperties($namespace,$_[0]); - $pageId = $_[1] || $data{pageId}; - $newWidgetId = create($pageId,$namespace,$data{title},$data{displayTitle},$data{description},$data{processMacros},$data{templatePosition}); - WebGUI::SQL->write("insert into LinkList values ($newWidgetId, '$data{indent}', '$data{lineSpacing}', ".quote($data{bullet}).")"); - $sth = WebGUI::SQL->read("select * from LinkList_link where widgetId=$_[0]"); - while (@row = $sth->array) { - $newLinkId = getNextId("linkId"); - WebGUI::SQL->write("insert into LinkList_link values ($newWidgetId, $newLinkId, ".quote($row[2]).", ".quote($row[3]).", ".quote($row[4]).", '$row[5]', '$row[6]')"); - } - $sth->finish; -} - -#------------------------------------------------------------------- -sub purge { - WebGUI::SQL->write("delete from LinkList_link where widgetId=$_[0]",$_[1]); - purgeWidget($_[0],$_[1],$namespace); -} - -#------------------------------------------------------------------- -sub widgetName { - return WebGUI::International::get(6,$namespace); -} - -#------------------------------------------------------------------- -sub www_add { - my ($output, %hash); - tie %hash, 'Tie::IxHash'; - if (WebGUI::Privilege::canEditPage()) { - $output = helpLink(1,$namespace); - $output .= '

'.WebGUI::International::get(11,$namespace).'

'; - $output .= formHeader(); - $output .= WebGUI::Form::hidden("widget",$namespace); - $output .= WebGUI::Form::hidden("func","addSave"); - $output .= ''; - $output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("title",20,128,'Link List')); - $output .= tableFormRow(WebGUI::International::get(174),WebGUI::Form::checkbox("displayTitle",1,1)); - $output .= tableFormRow(WebGUI::International::get(175),WebGUI::Form::checkbox("processMacros",1)); - %hash = WebGUI::Widget::getPositions(); - $output .= tableFormRow(WebGUI::International::get(363),WebGUI::Form::selectList("templatePosition",\%hash)); - $output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",'',50,5,1)); - $output .= tableFormRow(WebGUI::International::get(1,$namespace),WebGUI::Form::text("indent",20,2,0)); - $output .= tableFormRow(WebGUI::International::get(2,$namespace),WebGUI::Form::text("lineSpacing",20,1,1)); - $output .= tableFormRow(WebGUI::International::get(4,$namespace),WebGUI::Form::text("bullet",20,255,'·')); - $output .= tableFormRow(WebGUI::International::get(5,$namespace),WebGUI::Form::checkbox("proceed",1,1)); - $output .= formSave(); - $output .= '
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } - return $output; -} - -#------------------------------------------------------------------- -sub www_addSave { - my ($widgetId); - if (WebGUI::Privilege::canEditPage()) { - $widgetId = create($session{page}{pageId},$session{form}{widget},$session{form}{title},$session{form}{displayTitle},$session{form}{description},$session{form}{processMacros},$session{form}{templatePosition}); - WebGUI::SQL->write("insert into LinkList values ($widgetId, '$session{form}{indent}', '$session{form}{lineSpacing}', ".quote($session{form}{bullet}).")"); - if ($session{form}{proceed} == 1) { - $session{form}{wid} = $widgetId; - return www_addLink(); - } else { - return ""; - } - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_addLink { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(7,$namespace).'

'; - $output .= formHeader(); - $output .= WebGUI::Form::hidden("wid",$session{form}{wid}); - $output .= WebGUI::Form::hidden("func","addLinkSave"); - $output .= ''; - $output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("name",20,128)); - $output .= tableFormRow(WebGUI::International::get(8,$namespace),WebGUI::Form::text("url",20,1024)); - $output .= tableFormRow(WebGUI::International::get(3,$namespace),WebGUI::Form::checkbox("newWindow",1,1)); - $output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",'',50,10)); - $output .= formSave(); - $output .= '
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } - return $output; -} - -#------------------------------------------------------------------- -sub www_addLinkSave { - my ($linkId, $nextSeq); - if (WebGUI::Privilege::canEditPage()) { - ($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from LinkList_link where widgetId=$session{form}{wid}"); - $nextSeq += 1; - $linkId = getNextId("linkId"); - WebGUI::SQL->write("insert into LinkList_link values ($session{form}{wid}, $linkId, ".quote($session{form}{name}).", ".quote($session{form}{url}).", ".quote($session{form}{description}).", '$nextSeq', '$session{form}{newWindow}')"); - return www_edit(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - duplicate($session{form}{wid}); - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_deleteLink { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(9,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_deleteLinkConfirm { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - WebGUI::SQL->write("delete from LinkList_link where linkId=$session{form}{lid}"); - _reorderLinks($session{form}{wid}); - return www_edit(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_edit { - my ($output, %hash, @array, %data, @link, $sth); - tie %data, 'Tie::CPHash'; - tie %hash, 'Tie::IxHash'; - if (WebGUI::Privilege::canEditPage()) { - %data = getProperties($namespace,$session{form}{wid}); - $output = helpLink(1,$namespace); - $output .= '

'.WebGUI::International::get(10,$namespace).'

'; - $output .= formHeader(); - $output .= WebGUI::Form::hidden("wid",$session{form}{wid}); - $output .= WebGUI::Form::hidden("func","editSave"); - $output .= ''; - $output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("title",20,128,$data{title})); - $output .= tableFormRow(WebGUI::International::get(174),WebGUI::Form::checkbox("displayTitle",1,$data{displayTitle})); - $output .= tableFormRow(WebGUI::International::get(175),WebGUI::Form::checkbox("processMacros",1,$data{processMacros})); - %hash = WebGUI::Widget::getPositions(); - $array[0] = $data{templatePosition}; - $output .= tableFormRow(WebGUI::International::get(363),WebGUI::Form::selectList("templatePosition",\%hash,\@array)); - $output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",$data{description},50,5,1)); - $output .= tableFormRow(WebGUI::International::get(1,$namespace),WebGUI::Form::text("indent",20,2,$data{indent})); - $output .= tableFormRow(WebGUI::International::get(2,$namespace),WebGUI::Form::text("lineSpacing",20,1,$data{lineSpacing})); - $output .= tableFormRow(WebGUI::International::get(4,$namespace),WebGUI::Form::text("bullet",20,255,$data{bullet})); - $output .= formSave(); - $output .= '
'; - $output .= '

'.WebGUI::International::get(13,$namespace).'

'; - $output .= ''; - $sth = WebGUI::SQL->read("select linkId, name from LinkList_link where widgetId='$session{form}{wid}' order by sequenceNumber"); - while (@link = $sth->array) { - $output .= ''; - } - $sth->finish; - $output .= '
'.$link[1].'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_editSave { - if (WebGUI::Privilege::canEditPage()) { - update(); - WebGUI::SQL->write("update LinkList set indent='$session{form}{indent}', lineSpacing='$session{form}{lineSpacing}', bullet=".quote($session{form}{bullet})." where widgetId=$session{form}{wid}"); - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_editLink { - my ($output, %link); - tie %link, 'Tie::CPHash'; - if (WebGUI::Privilege::canEditPage()) { - %link = WebGUI::SQL->quickHash("select * from LinkList_link where linkId='$session{form}{lid}'"); - $output = '

'.WebGUI::International::get(12,$namespace).'

'; - $output .= formHeader(); - $output .= WebGUI::Form::hidden("wid",$session{form}{wid}); - $output .= WebGUI::Form::hidden("lid",$session{form}{lid}); - $output .= WebGUI::Form::hidden("func","editLinkSave"); - $output .= ''; - $output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("name",20,128,$link{name})); - $output .= tableFormRow(WebGUI::International::get(8,$namespace),WebGUI::Form::text("url",20,2048,$link{url})); - $output .= tableFormRow(WebGUI::International::get(3,$namespace),WebGUI::Form::checkbox("newWindow",1,$link{newWindow})); - $output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",$link{description},50,10)); - $output .= formSave(); - $output .= '
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } - return $output; -} - -#------------------------------------------------------------------- -sub www_editLinkSave { - if (WebGUI::Privilege::canEditPage()) { - 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}"); - return www_edit(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_moveLinkDown { - my (@data, $thisSeq); - if (WebGUI::Privilege::canEditPage()) { - ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from LinkList_link where linkId=$session{form}{lid}"); - @data = WebGUI::SQL->quickArray("select linkId from LinkList_link where widgetId=$session{form}{wid} and sequenceNumber=$thisSeq+1 group by widgetId"); - if ($data[0] ne "") { - WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber+1 where linkId=$session{form}{lid}"); - WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber-1 where linkId=$data[0]"); - } - return www_edit(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_moveLinkUp { - my (@data, $thisSeq); - if (WebGUI::Privilege::canEditPage()) { - ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from LinkList_link where linkId=$session{form}{lid}"); - @data = WebGUI::SQL->quickArray("select linkId from LinkList_link where widgetId=$session{form}{wid} and sequenceNumber=$thisSeq-1 group by widgetId"); - if ($data[0] ne "") { - WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber-1 where linkId=$session{form}{lid}"); - WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber+1 where linkId=$data[0]"); - } - return www_edit(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_view { - my (%data, $i, $indent, $lineSpacing, @link, $output, $sth); - tie %data, 'Tie::CPHash'; - %data = getProperties($namespace,$_[0]); - if (defined %data) { - if ($data{displayTitle}) { - $output = "

".$data{title}."

"; - } - if ($data{description} ne "") { - $output .= $data{description}.'

'; - } - for ($i=0;$i<$data{indent};$i++) { - $indent .= " "; - } - for ($i=0;$i<$data{lineSpacing};$i++) { - $lineSpacing .= "
"; - } - $sth = WebGUI::SQL->read("select name, url, description, newWindow from LinkList_link where widgetId='$_[0]' order by sequenceNumber"); - while (@link = $sth->array) { - $output .= $indent.$data{bullet}.''; - if ($link[2] ne "") { - $output .= ' - '.$link[2]; - } - $output .= $lineSpacing; - } - $sth->finish; - if ($data{processMacros}) { - $output = WebGUI::Macro::process($output); - } - } - return $output; -} - - - - - - - -1; diff --git a/lib/WebGUI/Wobject/FAQ.pm b/lib/WebGUI/Wobject/FAQ.pm index e60992260..8f4c12d6c 100644 --- a/lib/WebGUI/Wobject/FAQ.pm +++ b/lib/WebGUI/Wobject/FAQ.pm @@ -48,7 +48,8 @@ sub duplicate { WebGUI::SQL->write("insert into FAQ_question values ($w, $newQuestionId, " .quote($data{question}).", ".quote($data{answer}).", $data{sequenceNumber})"); } - $sth->finish;} + $sth->finish; +} #------------------------------------------------------------------- sub new { @@ -164,7 +165,7 @@ sub www_editQuestion { $f->hidden("func","editQuestionSave"); $f->textarea("question",WebGUI::International::get(5,$namespace),$question{question}); $f->HTMLArea("answer",WebGUI::International::get(6,$namespace),$question{answer}); - $f->yesNo("proceed",WebGUI::International::get(1,$namespace),1); + $f->yesNo("proceed",WebGUI::International::get(1,$namespace)); $f->submit; $output .= $f->print; return $output; diff --git a/lib/WebGUI/Wobject/LinkList.pm b/lib/WebGUI/Wobject/LinkList.pm new file mode 100644 index 000000000..0e0d5d2bc --- /dev/null +++ b/lib/WebGUI/Wobject/LinkList.pm @@ -0,0 +1,291 @@ +package WebGUI::Wobject::LinkList; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2002 Plain Black Software. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use Tie::CPHash; +use WebGUI::HTMLForm; +use WebGUI::Icon; +use WebGUI::International; +use WebGUI::Macro; +use WebGUI::Privilege; +use WebGUI::Session; +use WebGUI::SQL; +use WebGUI::URL; +use WebGUI::Wobject; + +our @ISA = qw(WebGUI::Wobject); +our $namespace = "LinkList"; +our $name = WebGUI::International::get(6,$namespace); + + +#------------------------------------------------------------------- +sub _reorderLinks { + my ($sth, $i, $lid); + $sth = WebGUI::SQL->read("select linkId from LinkList_link where wobjectId=$_[0] order by sequenceNumber"); + while (($lid) = $sth->array) { + WebGUI::SQL->write("update LinkList_link set sequenceNumber='$i' where linkId=$lid"); + $i++; + } + $sth->finish; +} + +#------------------------------------------------------------------- +sub duplicate { + my ($w, $sth, @row, $newLinkId); + $w = $_[0]->SUPER::duplicate($_[1]); + $w = WebGUI::Wobject::LinkList->new({wobjectId=>$w,namespace=>$namespace}); + $w->set({ + indent=>$_[0]->get("indent"), + bullet=>$_[0]->get("bullet"), + lineSpacing=>$_[0]->get("lineSpacing") + }); + $sth = WebGUI::SQL->read("select * from LinkList_link where wobjectId=".$_[0]->get("wobjectId")); + while (@row = $sth->array) { + $newLinkId = getNextId("linkId"); + WebGUI::SQL->write("insert into LinkList_link values (".$w->get("wobjectId").", $newLinkId, " + .quote($row[2]).", ".quote($row[3]).", ".quote($row[4]).", '$row[5]', '$row[6]')"); + } + $sth->finish; +} + +#------------------------------------------------------------------- +sub new { + my ($self, $class, $property); + $class = shift; + $property = shift; + $self = WebGUI::Wobject->new($property); + bless $self, $class; +} + +#------------------------------------------------------------------- +sub purge { + WebGUI::SQL->write("delete from LinkList_link where wobjectId=".$_[0]->get("wobjectId")); + $_[0]->SUPER::purge(); +} + +#------------------------------------------------------------------- +sub set { + $_[0]->SUPER::set($_[1],[qw(indent bullet lineSpacing)]); +} + +#------------------------------------------------------------------- +sub www_copy { + if (WebGUI::Privilege::canEditPage()) { + $_[0]->duplicate; + return ""; + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_deleteLink { + my ($output); + if (WebGUI::Privilege::canEditPage()) { + $output = '

'.WebGUI::International::get(42).'

'; + $output .= WebGUI::International::get(9,$namespace).'

'; + $output .= '

'.WebGUI::International::get(44).''; + $output .= '   '.WebGUI::International::get(45).'
'; + return $output; + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_deleteLinkConfirm { + my ($output); + if (WebGUI::Privilege::canEditPage()) { + WebGUI::SQL->write("delete from LinkList_link where linkId=$session{form}{lid}"); + _reorderLinks($session{form}{wid}); + return $_[0]->www_edit(); + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_edit { + my ($f, $output, @link, $sth, $indent, $lineSpacing, $bullet); + if (WebGUI::Privilege::canEditPage()) { + $bullet = $_[0]->get("bullet") || '·'; + $lineSpacing = $_[0]->get("lineSpacing") || 1; + $indent = $_[0]->get("indent") || 5; + $output = helpIcon(1,$namespace); + $output .= '

'.WebGUI::International::get(10,$namespace).'

'; + $f = WebGUI::HTMLForm->new; + $f->integer("indent",WebGUI::International::get(1,$namespace),$indent); + $f->integer("lineSpacing",WebGUI::International::get(2,$namespace),$lineSpacing); + $f->text("bullet",WebGUI::International::get(4,$namespace),$bullet); + $f->yesNo("proceed",WebGUI::International::get(5,$namespace),1); + $output .= $_[0]->SUPER::www_edit($f->printRowsOnly); + unless ($_[0]->get("wobjectId") eq "new") { + $output .= '

'.WebGUI::International::get(13,$namespace).'

'; + $sth = WebGUI::SQL->read("select linkId, name from LinkList_link where wobjectId='$session{form}{wid}' order by sequenceNumber"); + while (@link = $sth->array) { + $output .= '

' + .deleteIcon('func=deleteLink&wid='.$session{form}{wid}.'&lid='.$link[0]) + .editIcon('func=editLink&wid='.$session{form}{wid}.'&lid='.$link[0]) + .moveUpIcon('func=moveLinkUp&wid='.$session{form}{wid}.'&lid='.$link[0]) + .moveDownIcon('func=moveLinkDown&wid='.$session{form}{wid}.'&lid='.$link[0]) + .' '.$link[1].'
'; + } + $sth->finish; + } + return $output; + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_editSave { + if (WebGUI::Privilege::canEditPage()) { + $_[0]->SUPER::www_editSave(); + $_[0]->set({ + indent=>$session{form}{indent}, + bullet=>$session{form}{bullet}, + lineSpacing=>$session{form}{lineSpacing} + }); + if ($session{form}{proceed}) { + $_[0]->www_editLink(); + } else { + return ""; + } + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_editLink { + my ($output, %link, $f, $linkId, $newWindow); + tie %link, 'Tie::CPHash'; + if (WebGUI::Privilege::canEditPage()) { + $linkId = $session{form}{lid} || "new"; + %link = WebGUI::SQL->quickHash("select * from LinkList_link where linkId='$session{form}{lid}'"); + if ($linkId eq "new") { + $newWindow = 1; + } else { + $newWindow = $link{newWindow}; + } + $output = '

'.WebGUI::International::get(12,$namespace).'

'; + $f = WebGUI::HTMLForm->new; + $f->hidden("wid",$_[0]->get("wobjectId")); + $f->hidden("lid",$linkId); + $f->hidden("func","editLinkSave"); + $f->text("name",WebGUI::International::get(99),$link{name}); + $f->url("url",WebGUI::International::get(8,$namespace),$link{url}); + $f->yesNo("newWindow",WebGUI::International::get(3,$namespace),$newWindow); + $f->textarea("description",WebGUI::International::get(85),$link{description}); + $f->yesNo("proceed",WebGUI::International::get(5,$namespace)); + $f->submit; + $output .= $f->print; + return $output; + } else { + return WebGUI::Privilege::insufficient(); + } + return $output; +} + +#------------------------------------------------------------------- +sub www_editLinkSave { + my ($seq); + if (WebGUI::Privilege::canEditPage()) { + if ($session{form}{lid} eq "new") { + ($seq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from LinkList_link where wobjectId=".$_[0]->get("wobjectId")); + $session{form}{lid} = getNextId("linkId"); + WebGUI::SQL->write("insert into LinkList_link (wobjectId,linkId,sequenceNumber) values (".$_[0]->get("wobjectId") + .",$session{form}{lid},".($seq+1).")"); + } + 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}"); + if ($session{form}{proceed}) { + $session{form}{lid} = "new"; + $_[0]->www_editLink(); + } else { + return $_[0]->www_edit(); + } + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_moveLinkDown { + my (@data, $thisSeq); + if (WebGUI::Privilege::canEditPage()) { + ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from LinkList_link where linkId=$session{form}{lid}"); + @data = WebGUI::SQL->quickArray("select linkId from LinkList_link where wobjectId=$session{form}{wid} and sequenceNumber=$thisSeq+1 group by wobjectId"); + if ($data[0] ne "") { + WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber+1 where linkId=$session{form}{lid}"); + WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber-1 where linkId=$data[0]"); + } + return $_[0]->www_edit(); + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_moveLinkUp { + my (@data, $thisSeq); + if (WebGUI::Privilege::canEditPage()) { + ($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from LinkList_link where linkId=$session{form}{lid}"); + @data = WebGUI::SQL->quickArray("select linkId from LinkList_link where wobjectId=$session{form}{wid} and sequenceNumber=$thisSeq-1 group by wobjectId"); + if ($data[0] ne "") { + WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber-1 where linkId=$session{form}{lid}"); + WebGUI::SQL->write("update LinkList_link set sequenceNumber=sequenceNumber+1 where linkId=$data[0]"); + } + return $_[0]->www_edit(); + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- +sub www_view { + my ($i, $indent, $lineSpacing, @link, $output, $sth); + $output = $_[0]->displayTitle; + $output .= $_[0]->description; + for ($i=0;$i<$_[0]->get("indent");$i++) { + $indent .= " "; + } + for ($i=0;$i<$_[0]->get("lineSpacing");$i++) { + $lineSpacing .= "
"; + } + $sth = WebGUI::SQL->read("select name, url, description, newWindow from LinkList_link where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber"); + while (@link = $sth->array) { + $output .= $indent.$_[0]->get("bullet").''; + if ($link[2] ne "") { + $output .= ' - '.$link[2]; + } + $output .= $lineSpacing; + } + $sth->finish; + return $_[0]->processMacros($output); +} + + + + +1; +