File Coverage

blib/lib/FWS/V2.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package FWS::V2;
2              
3 1     1   25249 use 5.006;
  1         5  
  1         42  
4 1     1   5 use strict;
  1         2  
  1         35  
5 1     1   6 use warnings;
  1         7  
  1         172  
6              
7              
8             =head1 NAME
9              
10             FWS::V2 - Framework Sites version 2
11              
12             =head1 VERSION
13              
14             Version 1.13091122
15              
16             =cut
17              
18             our $VERSION = '1.13091122';
19              
20              
21             =head1 SYNOPSIS
22              
23             use FWS::V2;
24             my $fws = FWS::V2->new( DBName => 'myDB',
25             DBUser => 'theUser',
26             DBPassword => 'superSecret',
27             DBHost => 'localhost',
28             DBType => 'MySQL');
29              
30             =cut
31            
32             =head1 DESCRIPTION
33              
34             FWS::V2 is the utility counterpart to the web based content management development platform provided at www.frameworksites.com. The web based version of this module is derived from this source with additional web specific features and packaging. The web based version enables the FWS to function on most any modern hosting environment, be upgraded in real time via the web based FWS administration, and control shared plugins between all of your installations even on different servers.
35              
36             Using this version is ideal for accessing any plugin feature, or data stored within a FWS installation from a standalone script. Examples of this would be scripts to do site maintenance, imports, exports, mass data updates, data mining, 3rd party data synchronization, web services, APIs... and more!
37              
38             The syntax and usage of the FWS::V2 is identical to the web based element and plugin development available within the FWS web based administration. Code from either is interchangeable between both distributions of FWS::V2 and the web based distribution of FWS available from www.frameworksites.com.
39              
40             =head1 PACKAGE DEPENDENCE
41              
42             Wait a second... why does FWS V2 seem to have its own home grown methods that are already in popular well established packages????
43              
44             One of the main goals of FWS is to have a bundled, autonomous version of the FWS that can be picked up and sat on almost any major ISP or Linux hosting environment without any care for what is present on the server. Packages the FWS does use have been carefully picked and validated to be supported on most all major ISPs. For more information on this bundled web optimized version visit http://www.frameworksites.com
45              
46             =head1 SUBROUTINES/METHODS
47              
48             =head2 new
49              
50             Construct a FWS version 2 object. Like the highly compatible web optimized distribution this will initiate access to all the FWS methods to access data, file, session, formatting and network methods. You can pass a variety of different parameters which could be required depending on what methods you are using and the context of your usage. MySQL and SQLite are supported with FWS 2, but MySQL should always be used if it is available. On medium or high traffic sites and sites with any significance of a data footprint, you will see quite a bit of latency with SQLite.
51              
52             Example of using FWS with MySQL:
53              
54             #
55             # Create FWS with MySQL connectivity
56             #
57             use FWS::V2;
58             my $fws = FWS::V2->new( DBName => "theDBName",
59             DBUser => "myUser",
60             DBPassword => "myPass");
61              
62             Example of using FWS with SQLite:
63              
64             #
65             # create FWS with SQLite connectivity
66             #
67             use FWS::V2;
68             my $fws = FWS::V2->new( DBType => "SQLite",
69             DBName => "/home/user/your.db");
70              
71             Any variable passed or derived can be accessed with the following syntax:
72              
73             print $fws->{'someParameter'}."\n";
74              
75             With common uses of FWS, you should never need to change any of these settings. If for some reason, although it is NOT recommended you can set any of these variables with the following syntax:
76              
77             $fws->{'someParameter'} = 'new settings';
78              
79             =head2 Required Parameters
80              
81             =over 4
82              
83             =item * DBName (MySQL and SQLite Required)
84              
85             For MySQL this is the DB Name. For SQLite this is the DB file path and file name.
86             MySQL example: user_fws
87             SQLite example: /home/user/secureFiles/user_fws.db
88              
89             =item * DBUser (MySQL Required)
90              
91             Required for MySQL and is the database user that has full grant access to the database.
92              
93             =item * DBPassword (MySQL Required)
94              
95             The DBUser's password.
96              
97             =item * DBHost (MySQL Required if your database is not on localhost)
98              
99             The DBHost will default to 'localhost' if not specified, but can be what ever is configured for the database environment.
100              
101             =item * DBType (SQLite Required)
102              
103             The DBType will default to 'MySQL' if not specified, but needs to be added if you are connecting to SQLite.
104              
105             =back
106              
107             =head2 Non-Required Parameters
108              
109             Non-required parameters for FWS installations can be added, but depending on the scope of your task they usually are not needed unless your testing code, or interacting with web elements that display rendered content from a stand alone script.
110              
111             =over 4
112              
113             =item * adminPassword
114              
115             For new installations this is the admin password until the first super admin account is created. After an admin account is created this password is disabled.
116              
117             =item * adminURL
118              
119             The url defined to get to the typical /admin log in screen. Default: 'admin'
120              
121             =item * affiliateExpMax
122              
123             The number of seconds an affiliate code will stay active after it has been received. Default: 295200
124              
125             =item * cookieDomainName
126              
127             The domain to use for cookies. Almost always it would be: '.whatEverYourDomainIs.com' For more complex scenario with host names you would want to make this more specific.
128              
129             =item * domain
130              
131             Full domain name with http prefix. Example: http://www.example.com
132              
133             =item * encryptionKey
134              
135             The encryption key to be used if encryptionType is set to 'blowfish'.
136              
137             =item * encryptionType
138              
139             If set this will set what encryption method to use on sensitive data. The only supported type is 'blowfish'.
140              
141             =item * filePath
142              
143             Full path name of common files. Example: /home/user/www/files
144              
145             =item * fileSecurePath
146              
147             Full path name of non web accessible files. Example: /home/user/secureFiles
148              
149             =item * fileWebPath
150              
151             Web path for the same place filePath points to. Example: /files
152              
153             =item * googleAppsKeyFile
154              
155             For google apps support for standard login modules this is required
156              
157             =item * hideEditModeHeaders
158              
159             Turn off all blue bar column headers for a site. (Suppress the adding of elements to pages on a UI standpoint)
160              
161             =item * loadJQueryInHead
162              
163             Load jquery in the head instead of lazy loading.
164              
165             =item * scriptTextSize
166              
167             If your element scripts are larger than 'text' and get truncated you might want to set this to 'mediumtext'
168              
169             =item * secureDomain
170              
171             Secure domain name with https prefix. For non-secure sites that do not have an SSL cert you can use the http:// prefix to disable SSL. Example: https://www.example.com
172              
173             =item * sendmailBin
174              
175             The location of the sendmail bin. Default: /usr/sbin/sendmail
176              
177             =item * sendMethod
178              
179             The method used to process queue requests internal or custom. Default: sendmail
180              
181             =item * sessionCookieName
182              
183             If there could be conflict with the cookie name, you can change the name of the cookie from its default of fws_session to something else.
184              
185             =item * FWSLogLevel
186              
187             Set how verbose logging is for FWS is. Logging will be appended: $fws->{'fileSecurePath'}.'/FWS.log'
188             0 - off , 1 (default)- Display errors
189              
190             =item * FWSKey
191              
192             This is the domain key from your frameworksites.com account. This is used to share content from different installs using frameworksites.com as your distribution hub. This is only used if your a FWS plugin developer or a developer has given you this key to install a plugin they created.
193              
194             =item * FWSPluginServer
195              
196             The server used to plublish and intall plugins. Defaults to https://www.frameworksites.com
197              
198             =item * FWSServer
199              
200             The server used to download the FWS Core updates. Defaults to http://www.frameworksites.com
201              
202             =item * SQLLogLevel
203              
204             Set how verbose logging is for SQL statements ran. Logging will be appended: $fws->{fileSecurePath}.'/SQL.log'
205             0 - off (default), 1 - updates/deletes/inserts only, 2 - everything (This file will grow fast if set to 2)
206              
207             =back
208              
209             =head1 DERIVED VARIABLES AND METHODS
210              
211             =head2 Accessable after setFormValues() is called
212              
213             =over 4
214              
215             =item * formValue()
216              
217             All passed variables. The value is not set, it will return as blank.
218              
219             =item * formArray()
220              
221             An array of form values passed.
222              
223             =back
224              
225             =head2 Accessable after setSiteFiendly() is called
226              
227             =over 4
228              
229             =item * {siteId}
230              
231             The site id of the site currently being rendered. Version 1 of FWS refered to this as the SID. This will be set via setSiteValues('yourSiteId') if setSiteFriendly is not being used.
232              
233             =item * formValue('p')
234              
235             The current page friendly or if not available the page guid.
236              
237             =back
238              
239             =head2 Accessable after setSession() is called
240              
241             =over 4
242              
243             =item * {affiliateId}
244              
245             Is set by passing a value to 'a' as a form value. Can be accessed via $fws->{affiliateId}
246              
247             =item * {affiliateExp}
248              
249             The time in epoch that the affiliate code will expire for the current session.
250              
251             =item * formValue('session')
252              
253             The current session ID.
254              
255             =back
256              
257             =head2 Accessable after setSiteValues() is called
258              
259             =over 4
260              
261             =item * {email}
262              
263             The default email address for the site being rendered. This is set via 'Site Settings' in the administration.
264              
265             =item * {fileFWSPath}
266              
267             The file location of FWS packaged distribution files. This is normaly not used except internally as the files in this directory could change with an upgrade.
268              
269             =item * {homeGUID}
270              
271             The guid of the home page. The formValue 'p' will be set to this if no 'p' value is passed.
272              
273             =item * {siteGUID}
274              
275             The guid of the site currently being rendered.
276              
277             =item * {siteName}
278              
279             The site name of the site currently being rendered.
280              
281             =item * {queryHead}
282              
283             The query head used for links that will maintain session and have a unique random cache key. Example return: ?fws_noCache=asdqwe&session=abc....123&s=site& It is important not to use this in a web rendering that will become static though caching. If the session= is cached on a static page it will cause a user who clicks the cached link to be logged out. queryHead is only to ment to be used in situations when you are passing from one domain to another and wish to maintain the same session ID.
284              
285             =back
286              
287             =head2 Accessable after processLogin() is called
288              
289             =over 4
290              
291             =item * {adminLoginId}
292              
293             The current user id for the admin user logged in. Extra warning: This should never be set externally!
294              
295             =item * {userLoginId}
296              
297             The current user id for the site user logged in. Extra warning: This should never be set externally!
298              
299             =back
300              
301             =head1 WEB BASED RENDERING
302              
303             =head2 Overview
304              
305             To use the web based rendering you can use this module, or the current web optimized version that is available from http://www.frameworksites.com. When using this module as opposed to the web based version you still need to run the FWS core upgrade to receive the admin modules to your local installation. Any time running an FWS core upgrade you of course not have your core updated, only the admin elements and supporting JavaScript and files..
306              
307             =head2 Simple Web Rendering Sequence
308              
309             #
310             # Load FWS
311             #
312             use FWS::V2;
313             $fws = new (
314             #.... FWS Settings ...
315             );
316            
317             #
318             # add any plugins we have installed
319             #
320             $fws->registerPlugins();
321            
322             #
323             # Get the form values
324             #
325             $fws->setFormValues();
326            
327             #
328             # Connect to the DB
329             #
330             $fws->connectDBH();
331            
332             #
333             # Page descisions and friendly url conversions
334             #
335             $fws->setSiteFriendly();
336            
337             #
338             # Run any init scripts if needed
339             #
340             $fws->runInit();
341            
342             #
343             # Set session and or get session vars
344             #
345             $fws->setSession();
346            
347             #
348             # Set site values based on any information we have collected, created or changed
349             #
350             $fws->setSiteValues();
351            
352             #
353             # Do login procedures
354             #
355             $fws->processLogin();
356            
357             #
358             # Run Internal Admin Actions
359             #
360             $fws->runAdminAction();
361            
362             #
363             # Display the content we just created
364             #
365             $fws->displayContent();
366            
367             For a more robust version of this sequence use the go.pl file creation for manual installation located on http://www.frameworksites.com
368            
369             =cut
370              
371             #########################################################################
372             #
373             # CODING AND STYLE HINTS
374             #
375             # If you going to touch the code, read this first!
376             #
377             #########################################################################
378             #
379             # WEB OPTIMIZED COMPATABILITY VERSION
380             # The compatability version of this code base is derived from these
381             # modules and in a couple spots you will see a HIDE and END HIDE
382             # block which is used by the compatability processor. Leave these
383             # in tact to maintain compatability with that processor.
384             #
385             # INHERITANCE
386             # The compatibility version of this code has one package. To maintain
387             # consistancy between the two versions everything is inherited, always.
388             #
389             # ELSE CUDDLING
390             # Use non cuddled elses unless its all on the same line with the if.
391             #
392             # HASH ARRAYS (An array of hashes)
393             # If your unfamiliar wit this technique read up on it. The data model
394             # for FWS is based on the idea of arrays of anonymous hashes. It is
395             # everywhere you get data!
396             #
397             # REFERENCES
398             # The original version of FWS did not use extensive references for data
399             # in an attempt to make things simple. By default hash arrays will come
400             # back in this way unless you specify ref=>1 in the whateverArray or
401             # whateverHash call. In future versions this will be reversed so doing
402             # ref=>1 in all calls hash/Array methods would be considered good form.
403             #
404             # LEGACY GET/SET SUBROUTINES
405             # A lot of get/set type functions were also in the original source
406             # those are getting phased out to only use the $fws->{theSetting} = '1'
407             # syntax. Make note of the legacy functions in the POD and use the
408             # more current syntax when available#
409             #
410             #########################################################################
411              
412              
413             ########### HIDE ################
414              
415             BEGIN {
416            
417 1     1   6 use base "FWS::V2::Database";
  1         2  
  1         1166  
418 1     1   13 use base "FWS::V2::Check";
  1         15  
  1         698  
419 1     1   7 use base "FWS::V2::File";
  1         2  
  1         803  
420             use base "FWS::V2::Format";
421             use base "FWS::V2::Net";
422             use base "FWS::V2::Legacy";
423             use base "FWS::V2::Session";
424             use base "FWS::V2::Cache";
425             use base "FWS::V2::Geo";
426             use base "FWS::V2::Admin";
427             use base "FWS::V2::Display";
428             use base "FWS::V2::Safety";
429              
430             }
431              
432             ############ END HIDE ############
433              
434             sub new {
435             my ($class, %params) = @_;
436             my $self = bless \%params, $class;
437              
438             #
439             # set the FWS version we are using
440             #
441             $self->{FWSVersion} = '2.1';
442              
443             #
444             # Major version parse
445             #
446             my @loadVerSplit = split /\./msx, $self->{FWSVersion};
447             $self->{FWSMajorVersion} = $loadVerSplit[0] . '.' . $loadVerSplit[1];
448              
449             #
450             # fake common ENV vars if we don't have them
451             #
452             $ENV{REMOTE_ADDR} ||= 'localhost';
453             $ENV{SERVER_NAME} ||= 'localhost';
454             $ENV{REQUEST_URI} ||= '';
455              
456             #
457             # set the default security hash
458             #
459             $self->{securityHash}->{isAdmin}{title} = 'Super User Account';
460             $self->{securityHash}->{isAdmin}{note} = 'This user has access to all FWS features, and has the ability to add and remove admin users. All installations should have one user of this type for security reasons. Having a user of this type will disable the embedded admin account.';
461              
462             $self->{securityHash}->{showContent}{title} = 'Full Edit Mode Access';
463             $self->{securityHash}->{showContent}{note} = 'Access to view and change the content in edit mode.';
464              
465             $self->{securityHash}->{showDesign}{title} = 'Designer Access';
466             $self->{securityHash}->{showDesign}{note} = 'Add and delete pages, layouts, design css, javascript, and files.';
467              
468             $self->{securityHash}->{showDeveloper}{title} = 'Developer Access';
469             $self->{securityHash}->{showDeveloper}{note} = 'Access to developer controls, element custom element creation and site creation and deletion.';
470              
471             $self->{securityHash}->{showQueue}{title} = 'Email Queue Access';
472             $self->{securityHash}->{showQueue}{note} = 'Access to view email sending queue, and message history.';
473              
474             $self->{securityHash}->{showSEO}{title} = 'SEO Controls';
475             $self->{securityHash}->{showSEO}{note} = 'Access to change SEO Defaults, content and page properties.';
476              
477             $self->{securityHash}->{showSiteSettings}{title} = 'Site Settings Menu';
478             $self->{securityHash}->{showSiteSettings}{note} = 'Generic site settings and 3rd party connector configurations.';
479              
480             $self->{securityHash}->{showSiteUsers}{title} = 'User Account Access';
481             $self->{securityHash}->{showSiteUsers}{note} = 'Access to create, delete and modify high level information for site accounts and groups.';
482              
483              
484             # if the admin ID is blank, set it to admin so users can access it via /admin
485             $self->{adminURL} ||= 'admin';
486              
487             # set the secure domain to a non https because it probably does not have a cert if it was not set
488             $self->{secureDomain} ||= 'http://'.$ENV{SERVER_NAME};
489              
490             # Change the theme of the ace IDE for developer mode
491             $self->{aceTheme} ||= 'idle_fingers';
492              
493             # The subdirectory of where tinyMCE is placed to make upgrading and testing new versions easier
494             $self->{tinyMCEPath} ||= 'tinymce-3.5.4';
495              
496             # Sometimes sites need bigger thatn text blob, 'mediumtext' might be needed
497             $self->{scriptTextSize} ||= 'text';
498              
499             # set the domains to the environment version if it was not set
500             $self->{sessionCookieName} ||= 'fws_session';
501              
502             # set mysql to default
503             $self->{DBType} ||= 'mysql';
504              
505             # set mysql default port
506             $self->{DBPort} ||= '3306';
507              
508             # set the domains to the environment version if it was not set
509             $self->{domain} ||= 'http://' . $ENV{SERVER_NAME};
510              
511             # if the admin ID is blank, set it to admin so users can access it via /admin
512             $self->{FWSPluginServer} ||= 'https://www.frameworksites.com';
513              
514             # the FWS auto update server
515             $self->{FWSServer} ||= 'http://www.frameworksites.com/downloads';
516              
517             # set the default seconds to how long a affiliate code will last once it is recieved
518             $self->{affiliateExpMax} ||= '295200';
519              
520             # set the default FWS log level
521             $self->{FWSLogLevel} ||= 1;
522              
523             # set the adminSafeMode for shared mode ( Not yet implemented fully )
524             $self->{adminSafeMode} ||= 0;
525              
526             # set the default SQL log level
527             $self->{SQLLogLevel} ||= 0;
528              
529             # set the default location for sendmail
530             $self->{sendmailBin} ||= '/usr/sbin/sendmail';
531              
532             # set the default send method to sendmail
533             $self->{sendMethod} ||= 'sendmail';
534              
535             # set the default email so we have sometihng to try if we need to
536             # this will get overwritten when siteValues is ran but here for
537             # completeness
538             $self->{email} ||= 'webmaster@' . $self->{domain};
539              
540             #
541             # prepopulate a few things that might be needed so they are not undefined
542             #
543             %{$self->{_cssHash}} = ();
544             %{$self->{_jsHash}} = ();
545             %{$self->{_jqueryHash}} = ();
546             %{$self->{_saveWithSessionHash}} = ();
547             %{$self->{_fullElementHashCache}} = ();
548             %{$self->{_tableFieldHashCache}} = ();
549             %{$self->{_siteScriptCache}} = ();
550             %{$self->{_subscriberCache}} = ();
551              
552             $self->{_language} = '';
553             $self->{_languageArray} = '';
554              
555             @{$self->{pluginCSSArray}} = ();
556             @{$self->{pluginJSArray}} = ();
557              
558             #
559             # cache fields will be populated on setSiteValues
560             # but in case we need a ph before then
561             #
562             %{$self->{dataCacheFields}} = ();
563             %{$self->{plugins}} = ();
564              
565             #
566             # this will store the currently logged in userHash
567             #
568             %{$self->{profileHash}} = ();
569              
570             #
571             # For plugin added, and cached elementHashes lets predefine this
572             #
573             %{$self->{elementHash}} = ();
574              
575             #
576             # set this to false, it might be turned on at any time by admin or elements
577             #
578             $self->{tinyMCEEnable} = 0;
579              
580             #
581             # set scriptsize
582             #
583             my $SSIZE = $self->{scriptTextSize};
584              
585             #
586             # core database schema
587             #
588             $self->{dataSchema}{queue_history} = {
589             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' ,noSite => 1},
590             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
591             created_date => { type => 'datetime' ,key => '' ,default => '0000-00-00' },
592             queue_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
593             profile_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
594             directory_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
595             type => { type => 'char(50)' ,key => 'MUL' ,default => '' },
596             queue_from => { type => 'char(255)',key => 'MUL' ,default => '' },
597             from_name => { type => 'char(255)',key => '' ,default => '' },
598             queue_to => { type => 'char(255)',key => 'MUL' ,default => '' },
599             subject => { type => 'char(255)',key => '' ,default => '' },
600             success => { type => 'int(1)' ,key => '' ,default => '0' },
601             synced => { type => 'int(1)' ,key => '' ,default => '0' },
602             body => { type => 'text' ,key => '' ,default => '' },
603             hash => { type => 'text' ,key => '' ,default => '' },
604             failure_code => { type => 'char(255)',key => '' ,default => '' },
605             response => { type => 'char(255)',key => '' ,default => '' },
606             sent_date => { type => 'datetime' ,key => '' ,default => '0000-00-00 00:00:00'},
607             scheduled_date => { type => 'datetime' ,key => '' ,default => '0000-00-00 00:00:00'},
608             };
609              
610             $self->{dataSchema}{queue} = {
611             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' ,noSite => 1},
612             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
613             created_date => { type => 'datetime' ,key => '' ,default => '0000-00-00' },
614             profile_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
615             directory_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
616             type => { type => 'char(50)' ,key => 'MUL' ,default => '' },
617             queue_from => { type => 'char(255)',key => 'MUL' ,default => '' ,AJAXGroup => 'showQueue'},
618             queue_to => { type => 'char(255)',key => 'MUL' ,default => '' ,AJAXGroup => 'showQueue'},
619             draft => { type => 'int(1)' ,key => '' ,default => '0' },
620             from_name => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showQueue'},
621             subject => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showQueue'},
622             mime_type => { type => 'char(100)',key => '' ,default => '' ,AJAXGroup => 'showQueue'},
623             transfer_encoding => { type => 'char(100)',key => '' ,default => '' },
624             digital_assets => { type => 'text' ,key => '' ,default => '' },
625             body => { type => 'text' ,key => '' ,default => '' ,AJAXGroup => 'showQueue'},
626             hash => { type => 'text' ,key => '' ,default => '' },
627             scheduled_date => { type => 'datetime' ,key => '' ,default => '0000-00-00 00:00:00',AJAXGroup => 'showQueue'},
628             };
629              
630             $self->{dataSchema}{auto} = {
631             make => { type => 'char(255)',key => 'MUL' ,default => '' },
632             model => { type => 'char(255)',key => 'MUL' ,default => '' },
633             year => { type => 'char(4)' ,key => 'MUL' ,default => '' },
634             };
635              
636             $self->{dataSchema}{country} = {
637             name => { type => 'char(255)',key => '' ,default => '' },
638             twoCharacter => { type => 'char(2)' ,key => '' ,default => '' },
639             threeCharacter => { type => 'char(3)' ,key => '' ,default => '' },
640             };
641              
642             $self->{dataSchema}{zipcode} = {
643             zipCode => { type => 'char(7)' ,key => 'MUL' ,default => '' },
644             zipType => { type => 'char(1)' ,key => '' ,default => '' },
645             stateAbbr => { type => 'char(2)' ,key => '' ,default => '' },
646             city => { type => 'char(255)',key => 'MUL' ,default => '' },
647             areaCode => { type => 'char(3)' ,key => '' ,default => '' },
648             timeZone => { type => 'char(12)' ,key => '' ,default => '' },
649             UTC => { type => 'int(10)' ,key => '' ,default => '0' },
650             DST => { type => 'char(1)' ,key => '' ,default => '' },
651             latitude => { type => 'float' ,key => 'MUL' ,default => '0' },
652             longitude => { type => 'float' ,key => 'MUL' ,default => '0' },
653             loc_id => { type => 'int(11)' ,key => 'MUL' ,default => '0' },
654             };
655              
656             $self->{dataSchema}{geo_block} = {
657             start_ip => { type => 'int(11)' ,key => 'MUL' ,default => '0' },
658             end_ip => { type => 'int(11)' ,key => 'MUL' ,default => '0' },
659             loc_id => { type => 'int(11)' ,key => 'MUL' ,default => '0' },
660             };
661              
662             $self->{dataSchema}{templates} = {
663             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' ,noSite => 1},
664             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
665             title => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showDesign'},
666             default_template => { type => 'int(1)' ,key => '' ,default => '0' },
667             template_devel => { type => 'text' ,key => '' ,default => '' },
668             css_devel => { type => 'int(1)' ,key => '' ,default => '0' },
669             js_devel => { type => 'int(1)' ,key => '' ,default => '0' },
670             };
671              
672             $self->{dataSchema}{data_cache} = {
673             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
674             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
675             name => { type => 'char(255)',key => 'MUL' ,default => '' },
676             title => { type => 'char(255)',key => 'MUL' ,default => '' },
677             pageIdOfElement => { type => 'char(36)' ,key => 'MUL' ,default => '' },
678             pageDescription => { type => 'text' ,key => 'FULLTEXT' ,default => '' },
679             };
680              
681             $self->{dataSchema}{data} = {
682             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
683             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
684             groups_guid => { type => 'char(36)' ,key => '' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
685             page_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
686             name => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
687             title => { type => 'char(255)',key => 'MUL' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
688             nav_name => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
689             active => { type => 'int(1)' ,key => 'MUL' ,default => '0' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
690             lang => { type => 'char(2)' ,key => 'MUL' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
691             disable_title => { type => 'int(1)' ,key => 'MUL' ,default => '0' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
692             element_type => { type => 'char(50)' ,key => 'MUL' ,default => '' },
693             created_date => { type => 'datetime' ,key => '' ,default => '0000-00-00' },
694             disable_edit_mode => { type => 'int(1)' ,key => '' ,default => '0' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
695             default_element => { type => 'int(2)' ,key => '' ,default => '0' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
696             show_login => { type => 'int(1)' ,key => '' ,default => '1' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
697             show_mobile => { type => 'int(2)' ,key => '' ,default => '0' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
698             show_resubscribe => { type => 'int(1)' ,key => '' ,default => '1' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
699             friendly_url => { type => 'char(255)',key => 'MUL' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
700             page_friendly_url => { type => 'char(255)',key => 'MUL' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
701             extra_value => { type => 'text' ,key => '' ,default => '' ,AJAXGroup => 'showDeveloper|showContent|showDesign'},
702             };
703              
704             $self->{dataSchema}{admin_user} = {
705             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' ,noSite => 1},
706             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
707             user_id => { type => 'char(50)' ,key => 'MUL' ,default => '' },
708             name => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'isAdmin'},
709             email => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'isAdmin'},
710             admin_user_password => { type => 'char(50)' ,key => 'MUL' ,default => '' ,cryptPassword => 1},
711             active => { type => 'int(1)' ,key => 'MUL' ,default => '1' },
712             extra_value => { type => 'text' ,key => '' ,default => '' ,AJAXGroup => 'isAdmin'},
713             };
714              
715             $self->{dataSchema}{profile_groups_xref} = {
716             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
717             profile_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
718             groups_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
719             };
720              
721             $self->{dataSchema}{profile} = {
722             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' ,noSite => 1},
723             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
724             pin => { type => 'char(6)' ,key => 'MUL' ,default => '' },
725             profile_password => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showSiteUsers',cryptPassword => 1},
726             fb_access_token => { type => 'char(255)',key => '' ,default => '' },
727             fb_id => { type => 'char(255)',key => '' ,default => '' },
728             email => { type => 'char(255)',key => 'MUL' ,default => '' },
729             name => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showSiteUsers'},
730             active => { type => 'int(1)' ,key => '' ,default => '1' ,AJAXGroup => 'showSiteUsers'},
731             google_id => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showSiteUsers'},
732             extra_value => { type => 'text' ,key => '' ,default => '' ,AJAXGroup => 'showSiteUsers'},
733             };
734              
735             $self->{dataSchema}{fws_sessions} = {
736             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
737             ip => { type => 'char(50)' ,key => 'MUL' ,default => '' },
738             fws_lang => { type => 'char(2)' ,key => '' ,default => '' },
739             b => { type => 'char(255)',key => '' ,default => '' },
740             l => { type => 'char(50)' ,key => '' ,default => '' },
741             bs => { type => 'char(50)' ,key => '' ,default => '' },
742             e => { type => 'int(1)' ,key => '' ,default => '0' },
743             s => { type => 'int(1)' ,key => '' ,default => '0' },
744             a => { type => 'char(50)' ,key => '' ,default => '' },
745             a_exp => { type => 'int(11)' ,key => '' ,default => '0' },
746             extra_value => { type => 'text' ,key => '' ,default => '' },
747             created => { type => 'timestamp',key => '' ,default => 'CURRENT_TIMESTAMP' },
748             };
749              
750             $self->{dataSchema}{guid_xref} = {
751             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
752             child => { type => 'char(36)' ,key => 'MUL' ,default => '' },
753             parent => { type => 'char(36)' ,key => 'MUL' ,default => '' },
754             ord => { type => 'int(11)' ,key => 'MUL' ,default => '0' },
755             layout => { type => 'char(50)' ,key => 'MUL' ,default => '' },
756             };
757              
758             $self->{dataSchema}{element} = {
759             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
760             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
761             type => { type => 'char(50)' ,key => 'MUL' ,default => '' ,AJAXGroup => 'showDeveloper'},
762             parent => { type => 'char(36)' ,key => 'MUL' ,default => '' ,AJAXGroup => 'showDeveloper'},
763             plugin => { type => 'char(50)' ,key => 'MUL' ,default => '' ,AJAXGroup => 'showDeveloper'},
764             ord => { type => 'int(11)' ,key => 'MUL' ,default => '0' ,AJAXGroup => 'showDeveloper'},
765             title => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showDeveloper'},
766             tags => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showDeveloper'},
767             class_prefix => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showDeveloper'},
768             admin_group => { type => 'char(50)' ,key => '' ,default => '' ,AJAXGroup => 'showDeveloper'},
769             public => { type => 'int(1)' ,key => '' ,default => '0' ,AJAXGroup => 'showDeveloper'},
770             css_devel => { type => 'int(1)' ,key => '' ,default => '0' },
771             js_devel => { type => 'int(1)' ,key => '' ,default => '0' },
772             script_devel => { type => $SSIZE ,key => '' ,default => '' },
773             schema_devel => { type => 'text' ,key => '' ,default => '' },
774             active => { type => 'int(1)' ,key => '' ,default => '0' },
775             checkedout => { type => 'int(1)' ,key => '' ,default => '0' },
776             root_element => { type => 'int(1)' ,key => '' ,default => '0' ,AJAXGroup => 'showDeveloper'},
777             };
778              
779             $self->{dataSchema}{groups} = {
780             site_guid => { type => 'char(36)' ,key => 'MUL' ,default => '' ,noSite => 1},
781             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
782             name => { type => 'char(50)' ,key => '' ,default => '' ,AJAXGroup => 'showSiteUsers'},
783             description => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showSiteUsers'},
784             };
785              
786             $self->{dataSchema}{site} = {
787             site_guid => { type => 'char(36)' ,key => '' ,default => '' ,noSite => 1},
788             guid => { type => 'char(36)' ,key => 'MUL' ,default => '' },
789             email => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showSiteSettings'},
790             name => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showSiteSettings'},
791             language_array => { type => 'char(255)',key => '' ,default => '' ,AJAXGroup => 'showSiteSettings'},
792             sid => { type => 'char(50)' ,key => 'MUL' ,default => '' },
793             created_date => { type => 'datetime' ,key => '' ,default => '0000-00-00' },
794             gateway_type => { type => 'char(10)' ,key => '' ,default => '' ,AJAXGroup => 'showSiteSettings'},
795             gateway_user_id => { type => 'char(150)',key => '' ,default => '' ,AJAXGroup => 'showSiteSettings'},
796             gateway_password => { type => 'char(150)',key => '' ,default => '' ,AJAXGroup => 'showSiteSettings', encrypt=> 1},
797             home_guid => { type => 'char(36)' ,key => '' ,default => '' },
798             js_devel => { type => 'int(1)' ,key => '' ,default => '0' },
799             css_devel => { type => 'int(1)' ,key => '' ,default => '0' },
800             default_site => { type => 'int(1)' ,key => '' ,default => '0' },
801             site_plugins => { type => 'text' ,key => '' ,default => '' },
802             extra_value => { type => 'text' ,key => '' ,default => '' ,AJAXGroup => 'showSiteSettings'},
803             };
804              
805             return $self;
806             }
807              
808              
809             =head1 FWS PLUGINS
810              
811             =head2 registerPlugins
812              
813             Any plugin that is actived via the plugin list in developer menu will attempt to be loaded.
814              
815             #
816             # register all plugins applied to this instance
817             #
818             $fws->registerPlugins();
819              
820             =cut
821              
822             sub registerPlugins {
823             my ( $self, $site ) = @_;
824              
825             #
826             # pull the list from the db
827             #
828             ( $self->{sitePlugins} ) = @{$self->runSQL( SQL => "SELECT site_plugins FROM site WHERE sid = 'admin'" )};
829              
830             #
831             # move trough the list registering each one
832             #
833             my @pluginArray = split /\|/, $self->{sitePlugins};
834              
835             while ( @pluginArray ) {
836             $self->registerPlugin( shift @pluginArray );
837             }
838            
839             #
840             # this if for the systemInfo sanity checking. I happened!
841             #
842             $self->{FWSScriptCheck}->{registerPlugins} = 1;
843              
844             return;
845             }
846              
847              
848             =head2 registerPlugin
849              
850             Apply a plugin to an installation without using the GUI, to force an always on state for the plugin. If server wide plugins are being added for this instance they will be under the FWS::V2 Namespace, if not they can be added just as the plugin name.
851              
852             #
853             # register plugins that are available server wide
854             #
855             $fws->registerPlugin('FWS::V2::SomePlugin');
856            
857             #
858             # register some plugin added via the FWS 2.1 Plugin manager
859             #
860             $fws->registerPlugin('somePlugin');
861              
862             Additionally if you want to check if a plugin is active inside of element or scripts you can use the following conditional:
863              
864             #
865             # check to see if ECommerce is loaded and active
866             #
867             if ($fws->{plugins}->{ECommerce} eq '1') { print "ECommerce is installed!\n" }
868             else { print "No ECommerce for you!\n" }
869              
870              
871             =cut
872              
873             sub registerPlugin {
874             my ( $self, $plugin ) = @_;
875              
876             ## no critic qw(RequireCheckingReturnValueOfEval ProhibitStringyEval)
877             eval 'use lib "' . $self->{fileSecurePath} . '/plugins";';
878             ## use critic
879              
880             #
881             # get the plugin name if it is a server wide plugin
882             #
883             my $pluginName = $plugin;
884             $pluginName =~ s/.*:://xmsg;
885              
886             #
887             # add the plugin and register the init for it
888             #
889             ## no critic qw(RequireCheckingReturnValueOfEval ProhibitStringyEval)
890             eval 'use ' . $plugin . ';';
891             ## use critic
892              
893             if( $@ ){ $self->FWSLog( $plugin . " could not be loaded\n" . $@ ) }
894              
895             ## no critic qw(RequireCheckingReturnValueOfEval ProhibitStringyEval)
896             eval $plugin . '->pluginInit($self);';
897             ## use critic
898              
899             if( $@ ){
900             $self->FWSLog( $plugin . " pluginInit failed\n" . $@ );
901             return 0;
902             }
903              
904             #
905             # mark the plugin as active
906             #
907             return $self->{plugins}->{$plugin} = 1;
908             }
909              
910              
911             =head1 AUTHOR
912              
913             Nate Lewis, C<< >>
914              
915             =head1 BUGS
916              
917             Please report any bugs or feature requests to C, or through
918             the web interface at L. I will be notified, and then you'll
919             automatically be notified of progress on your bug as I make changes.
920              
921              
922              
923              
924             =head1 SUPPORT
925              
926             You can find documentation for this module with the perldoc command.
927              
928             perldoc FWS::V2
929              
930              
931             You can also look for information at:
932              
933             =over 4
934              
935             =item * RT: CPAN's request tracker (report bugs here)
936              
937             L
938              
939             =item * AnnoCPAN: Annotated CPAN documentation
940              
941             L
942              
943             =item * CPAN Ratings
944              
945             L
946              
947             =item * Search CPAN
948              
949             L
950              
951             =back
952              
953             =head1 LICENSE AND COPYRIGHT
954              
955             Copyright 2013 Nate Lewis.
956              
957             This program is free software; you can redistribute it and/or modify it
958             under the terms of either: the GNU General Public License as published
959             by the Free Software Foundation; or the Artistic License.
960              
961             See http://dev.perl.org/licenses/ for more information.
962              
963              
964             =cut
965              
966             1; # End of FWS::V2