diff --git a/lib/WebGUI/Macro/AOIHits.pm b/lib/WebGUI/Macro/AOIHits.pm new file mode 100644 index 000000000..402546787 --- /dev/null +++ b/lib/WebGUI/Macro/AOIHits.pm @@ -0,0 +1,36 @@ +package WebGUI::Macro::AOIHits; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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 WebGUI::Macro; +use WebGUI::Session; +use WebGUI::SQL; + +#------------------------------------------------------------------- +sub process { + my (@param, $temp); + @param = WebGUI::Macro::getParams($_[0]); + my $key = $param[0]; + my $value = $param[1]; + my $sql = "select count from passiveProfileAOI a, metaData_fields f + where a.fieldId=f.fieldId + and userId=".quote($session{user}{userId})." + and fieldName=".quote($key)." + and value=".quote($value); + my ($count) = WebGUI::SQL->buildArray($sql); + return $count; +} + + +1; + + diff --git a/lib/WebGUI/Macro/AOIRank.pm b/lib/WebGUI/Macro/AOIRank.pm new file mode 100644 index 000000000..e91308ea9 --- /dev/null +++ b/lib/WebGUI/Macro/AOIRank.pm @@ -0,0 +1,36 @@ +package WebGUI::Macro::AOIRank; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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 WebGUI::Macro; +use WebGUI::Session; +use WebGUI::SQL; + +#------------------------------------------------------------------- +sub process { + my (@param, $temp); + @param = WebGUI::Macro::getParams($_[0]); + my $key = $param[0]; + my $rank = $param[1] || 1; # 1 is highest rank + $rank--; # Rank is zero based + my $sql = "select value from passiveProfileAOI a, metaData_fields f + where a.fieldId=f.fieldId + and userId=".quote($session{user}{userId})." + and fieldName=".quote($key)." order by a.count desc"; + my @values = WebGUI::SQL->buildArray($sql); + return $values[$rank]; +} + + +1; + + diff --git a/lib/WebGUI/Operation/MetaData.pm b/lib/WebGUI/Operation/MetaData.pm new file mode 100644 index 000000000..8743428a5 --- /dev/null +++ b/lib/WebGUI/Operation/MetaData.pm @@ -0,0 +1,195 @@ +package WebGUI::Operation::MetaData; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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 Exporter; +use strict; +use Tie::IxHash; +use WebGUI::International; +use WebGUI::Macro; +use WebGUI::Session; +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 + &www_deleteMetaDataFieldConfirm &www_saveSettings); + +#------------------------------------------------------------------- +sub _submenu { + my (%menu); + tie %menu, 'Tie::IxHash'; + $menu{WebGUI::URL::page('op=manageSettings')} = WebGUI::International::get(4); + if($session{form}{op} ne "manageMetaData") { + $menu{WebGUI::URL::page('op=manageMetaData')} = WebGUI::International::get('Manage Metadata','MetaData'); + } + $menu{WebGUI::URL::page('op=editMetaDataField')} = WebGUI::International::get('Add new field','MetaData'); + return menuWrapper($_[0],\%menu); +} + +#------------------------------------------------------------------- +sub www_saveSettings { + return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); + WebGUI::SQL->write("update settings set value=".quote($session{form}{metaDataEnabled})." where name='metaDataEnabled'"); + WebGUI::SQL->write("update settings set value=".quote($session{form}{passiveProfilingEnabled})." where name='passiveProfilingEnabled'"); + $session{setting}{metaDataEnabled} = $session{form}{metaDataEnabled}; + $session{setting}{passiveProfilingEnabled} = $session{form}{passiveProfilingEnabled}; + return www_manageMetaData(); +} + +#------------------------------------------------------------------- +sub www_editMetaDataField { + return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); + return WebGUI::Privilege::vitalComponent() if ($session{form}{fid} < 1000 && $session{form}{fid} > 0); + + my ($output, $fieldName, $defaultValue, $description, $fieldInfo); + # TODO: add help / internationlize + $output = helpIcon(22); + $output .= '
'; + $output .= '
'. + WebGUI::International::get('Add new field','MetaData'). + '
'; + return _submenu($output); +} + + + +1; diff --git a/lib/WebGUI/PassiveProfiling.pm b/lib/WebGUI/PassiveProfiling.pm new file mode 100644 index 000000000..5d7925801 --- /dev/null +++ b/lib/WebGUI/PassiveProfiling.pm @@ -0,0 +1,151 @@ +package WebGUI::PassiveProfiling; + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2004 Plain Black LLC. + ------------------------------------------------------------------- + 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 + ------------------------------------------------------------------- + +=cut + + +use strict; +use WebGUI::Session; +use WebGUI::SQL; +use WebGUI::DateTime; +use Tie::IxHash; + +=head1 NAME + +Package WebGUI::PassiveProfiling + +=head1 DESCRIPTION + +This package provides an interface to the passive profiling system. + +=head1 SYNOPSIS + + use WebGUI::PassiveProfiling; + WebGUI::PassiveProfiling::add( $wobjectId ); + +=head1 METHODS + +These functions/methods are available from this package: + +=cut + +#------------------------------------------------------------------- + +=head2 add ( wobjectId ) + +Adds a wobjectId to the passive profile log. + +=over + +=item wobjectId + +The wobjectId to add. + +=back + +=cut + +sub add { + return unless ($session{setting}{passiveProfilingEnabled}); + my $wobjectId = shift; + my $sql = "insert into passiveProfileLog (passiveProfileLogId, userId, sessionId, wobjectId, dateOfEntry) + values (".quote(getNextId("passiveProfileLogId")).",". + quote($session{user}{userId}).",". + quote($session{var}{sessionId}).",". + quote($wobjectId).",". + quote(WebGUI::DateTime::time()).")"; + WebGUI::SQL->write($sql); + return; +} + +#------------------------------------------------------------------- + +=head2 addPage ( [ pageId ] ) + +Adds all wobjects on current page to the passive profile log. +Optionally you can specify an alternate pageId. + +=over + +=item pageId + +The pageId of the page you want to log. + +=back + +=cut + +sub addPage { + return unless ($session{setting}{passiveProfilingEnabled}); + my $pageId = shift || $session{page}{pageId}; + my @wids = WebGUI::SQL->buildArray("select * from wobject where pageId=".quote($pageId)); + foreach my $wid (@wids) { + add($wid); + } + return; +} + +#------------------------------------------------------------------- + +=head2 summarizeAOI ( hashRef ) + +Summarizes passive profile log data using the metadata attributes. An entry +is logged in the passiveProfileAOI table. + +=item hashRef + +A hashRef with userId and wobjectId. + +=back + +=cut + +sub summarizeAOI { + my $data = shift; + my $sql = " + select f.fieldName, + f.fieldType, + d.fieldId, + d.wobjectId, + d.value + from metaData_data d , metaData_fields f + where f.fieldId = d.fieldId + and d.wobjectId = ".$data->{wobjectId}; + + my $sth = WebGUI::SQL->read($sql); + while (my $field = $sth->hashRef) { + my $aoi = WebGUI::SQL->quickHashRef("select * from passiveProfileAOI + where userId=".quote($data->{userId})." + and fieldId=".quote($field->{fieldId})." and + value=".quote($field->{value})); + if(not exists $aoi->{userId}) { + # Add record to DB + WebGUI::SQL->write("insert into passiveProfileAOI (userId, fieldId, value) + values (".quote($data->{userId}).",". + quote($field->{fieldId}).",". + quote($field->{value}).")"); + } + my $count = $aoi->{count}; + $count++; + + WebGUI::SQL->write("update passiveProfileAOI set count=".quote($count)." + where userId=".quote($data->{userId})." + and fieldId=".quote($field->{fieldId})." and + value=".quote($field->{value})); + } + $sth->finish; +} + +1; + diff --git a/lib/WebGUI/i18n/English/MetaData.pm b/lib/WebGUI/i18n/English/MetaData.pm new file mode 100644 index 000000000..dfaa9eb2b --- /dev/null +++ b/lib/WebGUI/i18n/English/MetaData.pm @@ -0,0 +1,57 @@ +package WebGUI::i18n::English::MetaData; + +our $I18N = { + 'Metadata' => { + message => q|Metadata|, + lastUpdated => 1089039511, + context => 'Label for tab' + }, + 'duplicateField' => { + message => q|Error: Fieldname "%field%" is already in use.
|, + lastUpdated => 1089039511, + }, + 'Delete Metadata field' => { + message => q|Delete Metadata field|, + lastUpdated => 1089039511, + }, + 'deleteConfirm' => { + message => q|Are you certain you want to delete this Metadata field ?|, + lastUpdated => 1089039511, + }, + 'Manage Metadata' => { + message => q|Manage Metadata|, + lastUpdated => 1089039511, + }, + 'Enable Metadata ?' => { + message => q|Enable Metadata ?|, + lastUpdated => 1089039511, + }, + 'Add new field' => { + message => q|Add new field|, + lastUpdated => 1089039511, + }, + 'Manage Metadata fields' => { + message => q|Manage Metadata fields|, + lastUpdated => 1089039511, + }, + 'Edit Metadata' => { + message => q|Edit Metadata|, + lastUpdated => 1089039511, + }, + 'Field Id' => { + message =>q|Field Id|, + lastUpdated=> 1089039511, + }, + 'Field name' => { + message => q|Field name|, + lastUpdated=> 1089039511, + }, + 'Enable passive profiling ?' => { + message => q|Enable passive profiling ?|, + lastUpdated=> 1089039511, + }, + + +}; + +1; diff --git a/sbin/Hourly/SummarizePassiveProfileLog.pm b/sbin/Hourly/SummarizePassiveProfileLog.pm new file mode 100644 index 000000000..cef94e450 --- /dev/null +++ b/sbin/Hourly/SummarizePassiveProfileLog.pm @@ -0,0 +1,50 @@ +package Hourly::SummarizePassiveProfileLog; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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 WebGUI::DateTime; +use WebGUI::Session; +use WebGUI::SQL; +use WebGUI::PassiveProfiling; +use WebGUI::DateTime; + +#----------------------------------------- +sub process { + my $verbose = shift; + unless ($session{setting}{passiveProfilingEnabled}) { + print "Passive profiling is disabled...\n"; + return; + } + my ($firstDate) = WebGUI::SQL->quickArray("select min(dateOfEntry) from passiveProfileLog"); + my $interval = $session{config}{passiveProfileInterval} || 86400; + if (WebGUI::DateTime::time()-$firstDate < $interval) { + print " - Recently runned: Skipping...\n" if ($verbose); + return ""; + } + + my $sessionExpired = WebGUI::DateTime::time() - $session{setting}{sessionTimeout}; + + # We process entries for registered users and expired visitor sessions + my $sql = "select * from passiveProfileLog"; + $sql .= " where userId <> 1 or (userId = 1 and dateOfEntry < ".quote($sessionExpired).")"; + my $sth = WebGUI::SQL->read($sql); + while (my $data = $sth->hashRef) { + WebGUI::PassiveProfiling::summarizeAOI($data); + WebGUI::SQL->write("delete from passiveProfileLog where passiveProfileLogId = ". + quote($data->{passiveProfileLogId})); + } + $sth->finish; +} + +1; + diff --git a/sbin/generateContent.pl b/sbin/generateContent.pl new file mode 100644 index 000000000..2801a36b6 --- /dev/null +++ b/sbin/generateContent.pl @@ -0,0 +1,123 @@ +#!/usr/bin/perl + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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 +#------------------------------------------------------------------- + + +our $webguiRoot; + +BEGIN { + $webguiRoot = ".."; + unshift (@INC, $webguiRoot."/lib"); +} + +use DBI; +use Getopt::Long; +use strict qw(subs vars); +use WebGUI; +use WebGUI::Session; +use WebGUI::HTML; +use WebGUI::Utility; + +$|=1; + +my ($configFile, $pageId, $userId, $styleId, $toFile, $stripHTML, $help); + +$userId = 1; + +GetOptions( + 'configFile:s'=>\$configFile, + 'pageId:i'=>\$pageId, + 'userId:i'=>\$userId, + 'styleId:i'=>\$styleId, + 'toFile:s'=>\$toFile, + 'stripHTML'=>\$stripHTML, + 'help'=>\$help +); + +#if ($help || $configFile eq '' || $pageId eq '' ) { +if ($help || $configFile eq '' ) { + print <