From 01c69d52911c2c6caf30eb7cdd6453eb88d336de Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 13 Aug 2004 14:34:36 +0000 Subject: [PATCH] more guid stuff --- docs/upgrades/upgrade_6.1.1-6.2.0.sql | 2 +- lib/WebGUI/Operation/MetaData.pm | 13 +++++++------ lib/WebGUI/Operation/Navigation.pm | 17 +++++++++-------- lib/WebGUI/Operation/Template.pm | 10 +++++----- lib/WebGUI/PassiveProfiling.pm | 7 ++++--- lib/WebGUI/Template.pm | 17 +++++++---------- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/upgrades/upgrade_6.1.1-6.2.0.sql b/docs/upgrades/upgrade_6.1.1-6.2.0.sql index 46c39e299..75fecacf9 100644 --- a/docs/upgrades/upgrade_6.1.1-6.2.0.sql +++ b/docs/upgrades/upgrade_6.1.1-6.2.0.sql @@ -255,5 +255,5 @@ alter table users change referringAffiliate referringAffiliate char(22) not null alter table page change lft nestedSetLeft int(11); alter table page change rgt nestedSetRight int(11); alter table page change id id char(22); -delete from incrementer where incrementerId in ("collateralId","pageId","databaseLinkId", "DataForm_entryId", "DataForm_fieldId", "DataForm_tabId", "EventsCalendar_eventId", "EventsCalendar_recurringId", "FileManager_fileId", "forumId", "forumPostId", "forumThreadId", "groupId", "languageId", "Product_benefitId", "Product_featureId", "Product_specificationId", "replacementId", "Survey_answerId", "Survey_id", "Survey_questionId", "Survey_responseId", "USS_id", "USS_submissionId", "wobjectId"); +delete from incrementer where incrementerId in ("navigationId","passiveProfileLogId","metaData_field","userId","collateralId","pageId","databaseLinkId", "DataForm_entryId", "DataForm_fieldId", "DataForm_tabId", "EventsCalendar_eventId", "EventsCalendar_recurringId", "FileManager_fileId", "forumId", "forumPostId", "forumThreadId", "groupId", "languageId", "Product_benefitId", "Product_featureId", "Product_specificationId", "replacementId", "Survey_answerId", "Survey_id", "Survey_questionId", "Survey_responseId", "USS_id", "USS_submissionId", "wobjectId"); diff --git a/lib/WebGUI/Operation/MetaData.pm b/lib/WebGUI/Operation/MetaData.pm index 642dec97a..c8e6d82a3 100644 --- a/lib/WebGUI/Operation/MetaData.pm +++ b/lib/WebGUI/Operation/MetaData.pm @@ -13,16 +13,17 @@ package WebGUI::Operation::MetaData; use Exporter; use strict; use Tie::IxHash; +use WebGUI::Icon; +use WebGUI::Id; use WebGUI::International; use WebGUI::Macro; +use WebGUI::MetaData; +use WebGUI::Operation::Shared; +use WebGUI::Privilege; use WebGUI::Session; +use WebGUI::SQL; use WebGUI::URL; use WebGUI::Utility; -use WebGUI::Operation::Shared; -use WebGUI::Icon; -use WebGUI::Privilege; -use WebGUI::SQL; -use WebGUI::MetaData; our @ISA = qw(Exporter); our @EXPORT = qw(&www_editMetaDataField &www_manageMetaData &www_editMetaDataFieldSave &www_deleteMetaDataField @@ -109,7 +110,7 @@ sub www_editMetaDataFieldSave { . www_editMetaDataField(); } if($session{form}{fid} eq 'new') { - $session{form}{fid} = getNextId("metaData_fieldId"); + $session{form}{fid} = WebGUI::Id::generate(); WebGUI::SQL->write("insert into metaData_properties (fieldId, fieldName, defaultValue, description, fieldType, possibleValues) values (". quote($session{form}{fid}).",". quote($session{form}{fieldName}).",". diff --git a/lib/WebGUI/Operation/Navigation.pm b/lib/WebGUI/Operation/Navigation.pm index a5956529c..cad98b946 100644 --- a/lib/WebGUI/Operation/Navigation.pm +++ b/lib/WebGUI/Operation/Navigation.pm @@ -19,6 +19,7 @@ use WebGUI::ErrorHandler; use WebGUI::Grouping; use WebGUI::HTMLForm; use WebGUI::Icon; +use WebGUI::Id; use WebGUI::International; use WebGUI::Macro; use WebGUI::Navigation; @@ -60,9 +61,9 @@ sub www_copyNavigation { WebGUI::SQL->write("insert into Navigation (navigationId, identifier, depth, method, startAt, stopAtLevel, templateId, showSystemPages, showHiddenPages, showUnprivilegedPages, reverse) - values (".getNextId("navigationId").", - ".quote('Copy of '.$navigation{identifier}).", $navigation{depth}, ".quote($navigation{method}). - ", ".quote($navigation{startAt}).", $navigation{stopAtLevel}, $navigation{templateId}, + values (".WebGUI::Id::generate().", + ".quote($navigation{identifier}.' (copy)').", $navigation{depth}, ".quote($navigation{method}). + ", ".quote($navigation{startAt}).", $navigation{stopAtLevel}, ".quote($navigation{templateId}).", $navigation{showSystemPages}, $navigation{showHiddenPages},$navigation{showUnprivilegedPages}, $navigation{reverse})"); return www_listNavigation(); @@ -90,7 +91,7 @@ sub www_deleteNavigationConfirm { if ($session{form}{navigationId} < 1000 && $session{form}{navigationId} > 0) { return WebGUI::Privilege::vitalComponent(); } - WebGUI::SQL->write("delete from Navigation where navigationId = $session{form}{navigationId}"); + WebGUI::SQL->write("delete from Navigation where navigationId = ".quote($session{form}{navigationId})); # Also delete cache WebGUI::Page->recacheNavigation; @@ -258,22 +259,22 @@ sub www_editNavigationSave { return WebGUI::International::get(33,'Navigation').www_editNavigation(); } if ($session{form}{navigationId} eq "new") { - $session{form}{navigationId} = getNextId("navigationId"); + $session{form}{navigationId} = WebGUI::Id::generate(); WebGUI::SQL->write("insert into Navigation (navigationId, identifier) - values ($session{form}{navigationId}, ".quote($session{form}{identifier}).")"); + values (".quote($session{form}{navigationId}).", ".quote($session{form}{identifier}).")"); } $session{form}{startAt} = $session{form}{startAt_new} || $session{form}{startAt}; # Combo field WebGUI::SQL->write("update Navigation set depth = $session{form}{depth}, method = ".quote($session{form}{method}).", startAt = ".quote($session{form}{startAt}).", stopAtLevel = ".quote($session{form}{stopAtLevel}).", - templateId = $session{form}{templateId}, + templateId = ".quote($session{form}{templateId}).", showSystemPages = $session{form}{showSystemPages}, showHiddenPages = $session{form}{showHiddenPages}, showUnprivilegedPages = $session{form}{showUnprivilegedPages}, identifier = ".quote($session{form}{identifier}).", reverse = ".quote($session{form}{'reverse'})." - where navigationId = $session{form}{navigationId}"); + where navigationId = ".quote($session{form}{navigationId})); # Delete from cache WebGUI::Page->recacheNavigation; diff --git a/lib/WebGUI/Operation/Template.pm b/lib/WebGUI/Operation/Template.pm index 31c30f0ea..38c37e62b 100644 --- a/lib/WebGUI/Operation/Template.pm +++ b/lib/WebGUI/Operation/Template.pm @@ -92,14 +92,14 @@ sub www_deleteTemplateConfirm { return WebGUI::Privilege::vitalComponent(); } elsif (WebGUI::Grouping::isInGroup(8)) { if ($session{form}{namespace} eq "Page") { - $a = WebGUI::SQL->read("select * from page where templateId=".$session{form}{tid}); + $a = WebGUI::SQL->read("select * from page where templateId=".quote($session{form}{tid})); while (($pageId) = $a->array) { - WebGUI::SQL->write("update wobject set templatePosition=1 where pageId=$pageId"); + WebGUI::SQL->write("update wobject set templatePosition=1 where pageId=".quote($pageId)); } $a->finish; - WebGUI::SQL->write("update page set templateId=2 where templateId=".$session{form}{tid}); + WebGUI::SQL->write("update page set templateId=2 where templateId=".quote($session{form}{tid})); } - WebGUI::SQL->write("delete from template where templateId=".$session{form}{tid} + WebGUI::SQL->write("delete from template where templateId=".quote($session{form}{tid}) ." and namespace=".quote($session{form}{namespace})); return www_listTemplates(); } else { @@ -120,7 +120,7 @@ sub www_editTemplate { $template{template} = "

\n\n"; } } else { - %template = WebGUI::SQL->quickHash("select * from template where templateId=$session{form}{tid} and + %template = WebGUI::SQL->quickHash("select * from template where templateId=".quote($session{form}{tid})." and namespace=".quote($session{form}{namespace})); } $output .= helpIcon("template add/edit"); diff --git a/lib/WebGUI/PassiveProfiling.pm b/lib/WebGUI/PassiveProfiling.pm index 6aff7ef5b..7f7b9d282 100644 --- a/lib/WebGUI/PassiveProfiling.pm +++ b/lib/WebGUI/PassiveProfiling.pm @@ -16,10 +16,11 @@ package WebGUI::PassiveProfiling; use strict; +use Tie::IxHash; +use WebGUI::DateTime; +use WebGUI::Id; use WebGUI::Session; use WebGUI::SQL; -use WebGUI::DateTime; -use Tie::IxHash; =head1 NAME @@ -60,7 +61,7 @@ sub add { return unless ($session{setting}{passiveProfilingEnabled}); my $wobjectId = shift; my $sql = "insert into passiveProfileLog (passiveProfileLogId, userId, sessionId, wobjectId, dateOfEntry) - values (".quote(getNextId("passiveProfileLogId")).",". + values (".quote(WebGUI::Id::generate()).",". quote($session{user}{userId}).",". quote($session{var}{sessionId}).",". quote($wobjectId).",". diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm index 804ffca27..856ad943e 100644 --- a/lib/WebGUI/Template.pm +++ b/lib/WebGUI/Template.pm @@ -16,14 +16,15 @@ package WebGUI::Template; +use File::Path; use HTML::Template; use strict; use WebGUI::Attachment; use WebGUI::ErrorHandler; +use WebGUI::Id; use WebGUI::International; use WebGUI::Session; use WebGUI::SQL; -use File::Path; =head1 NAME @@ -109,7 +110,7 @@ Defaults to "page". Specify the namespace of the template to retrieve. sub get { my $templateId = shift || 1; my $namespace = shift || "page"; - return WebGUI::SQL->quickHashRef("select * from template where templateId=".$templateId." and namespace=".quote($namespace),WebGUI::SQL->getSlave); + return WebGUI::SQL->quickHashRef("select * from template where templateId=".quote($templateId)." and namespace=".quote($namespace),WebGUI::SQL->getSlave); } @@ -229,7 +230,7 @@ sub process { my $template; unless (-f $file->getPath) { - ($template) = WebGUI::SQL->quickArray("select template from template where templateId=".$templateId." and namespace=".quote($namespace),WebGUI::SQL->getSlave); + ($template) = WebGUI::SQL->quickArray("select template from template where templateId=".quote($templateId)." and namespace=".quote($namespace),WebGUI::SQL->getSlave); $file->saveFromScalar($template); unless (-f $file->getPath) { WebGUI::ErrorHandler::warn("Could not create file ".$file->getPath."\nTemplate file caching is disabled"); @@ -304,18 +305,14 @@ A hash reference containing the data to be stored. At minimum the hash reference sub set { my $data = shift; if ($data->{templateId} eq "new") { - ($data->{templateId}) = WebGUI::SQL->quickArray("select max(templateId) from template where namespace=".quote($data->{namespace})); - $data->{templateId}++; - if ($data->{templateId} < 1000) { - $data->{templateId} = 1000; - } - WebGUI::SQL->write("insert into template (templateId,namespace) values (".$data->{templateId}.",".quote($data->{namespace}).")"); + $data->{templateId} = WebGUI::Id::generate(); + WebGUI::SQL->write("insert into template (templateId,namespace) values (".quote($data->{templateId}).",".quote($data->{namespace}).")"); } my @pairs; foreach my $key (keys %{$data}) { push(@pairs, $key."=".quote($data->{$key})) unless ($key eq "namespace" || $key eq "templateId"); } - WebGUI::SQL->write("update template set ".join(",",@pairs)." where templateId=".$data->{templateId}." and namespace=".quote($data->{namespace})); + WebGUI::SQL->write("update template set ".join(",",@pairs)." where templateId=".quote($data->{templateId})." and namespace=".quote($data->{namespace})); my $file = _getTemplateFile($data->{templateId},$data->{namespace}); $file->delete; return $data->{templateId};