cs-cms-commits Mailing List for CS Content Management System
Status: Alpha
Brought to you by:
crazedsanity
You can subscribe to this list here.
2009 |
Jan
|
Feb
(13) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
From: <cra...@us...> - 2011-11-27 20:03:18
|
Revision: 15 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=15&view=rev Author: crazedsanity Date: 2011-11-27 20:03:12 +0000 (Sun, 27 Nov 2011) Log Message: ----------- Use current instead of 0.1 (that's the current version, anyway). Removed Paths: ------------- trunk/0.1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2011-10-31 14:18:51
|
Revision: 14 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=14&view=rev Author: crazedsanity Date: 2011-10-31 14:18:45 +0000 (Mon, 31 Oct 2011) Log Message: ----------- Bleeding-edge version; should be compatible with all other CS "trunk/current" folders. Added Paths: ----------- trunk/current/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-23 17:36:35
|
Revision: 13 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=13&view=rev Author: crazedsanity Date: 2009-02-23 17:36:31 +0000 (Mon, 23 Feb 2009) Log Message: ----------- Far too complicated... I'll make my own or find a simpler one somewhere else. Modified Paths: -------------- trunk/0.1/schema/pgsql.schema.sql Removed Paths: ------------- trunk/0.1/gacl/ Modified: trunk/0.1/schema/pgsql.schema.sql =================================================================== --- trunk/0.1/schema/pgsql.schema.sql 2009-02-23 17:33:37 UTC (rev 12) +++ trunk/0.1/schema/pgsql.schema.sql 2009-02-23 17:36:31 UTC (rev 13) @@ -1,90 +1,61 @@ --begin; -CREATE TABLE cs_authentication_table ( - uid serial NOT NULL PRIMARY KEY, - username text NOT NULL UNIQUE, - passwd varchar(32), +CREATE TABLE cms_user_id_table ( + user_id serial NOT NULL PRIMARY KEY, + display_name text NOT NULL, + email text NOT NULL, is_active boolean DEFAULT true NOT NULL, - date_created date DEFAULT CURRENT_TIMESTAMP NOT NULL, - last_login timestamp with time zone, - email text + date_created date DEFAULT CURRENT_TIMESTAMP NOT NULL ); -CREATE TABLE csblog_location_table ( - location_id serial NOT NULL PRIMARY KEY, - location text NOT NULL UNIQUE -); -create table csblog_blog_table ( - blog_id serial NOT NULL PRIMARY KEY, - uid integer NOT NULL REFERENCES cs_authentication_table(uid), - blog_name text NOT NULL, - blog_display_name text NOT NULL, - --blog_location text NOT NULL, - location_id integer NOT NULL REFERENCES csblog_location_table(location_id), - is_active boolean NOT NULL DEFAULT true, - last_post_timestamp timestamp without time zone -); -CREATE TABLE csblog_access_table ( - access_id serial NOT NULL PRIMARY KEY, - blog_id integer NOT NULL REFERENCES csblog_blog_table(blog_id), - uid integer NOT NULL REFERENCES cs_authentication_table(uid) +CREATE TABLE cms_status_table ( + status_id serial NOT NULL PRIMARY KEY, + description text NOT NULL, + page_is_active boolean NOT NULL, + page_is_visible_anonymous boolean NOT NULL ); -CREATE TABLE csblog_entry_table ( - entry_id serial NOT NULL PRIMARY KEY, - blog_id integer NOT NULL REFERENCES csblog_blog_table(blog_id), - author_uid integer NOT NULL REFERENCES cs_authentication_table(uid), + +CREATE TABLE cms_page_table ( + page_name text NOT NULL PRIMARY KEY, + owner_user_id integer NOT NULL REFERENCES cms_user_table(user_id), create_date timestamp NOT NULL DEFAULT NOW(), content text NOT NULL, post_timestamp timestamp NOT NULL DEFAULT NOW(), - permalink text NOT NULL, title text NOT NULL, - is_draft boolean NOT NULL DEFAULT false + status_id integer NOT NULL REFERENCES cms_status_table(status_id) ); -CREATE UNIQUE INDEX csblog_entry_table_permalink_blog_id_uidx ON csblog_entry_table USING btree (permalink,blog_id); -CREATE TABLE cs_session_table ( - session_id character varying(32) NOT NULL PRIMARY KEY, - uid integer NOT NULL REFERENCES cs_authentication_table(uid), - create_date timestamp NOT NULL, - last_checkin timestamp, - num_checkins integer NOT NULL DEFAULT 0, - ip varchar(15) NOT NULL -); + + + +------------------------------------ +-- PERMISSIONS STUFF -- --- Table for storing basic permissions. --- -CREATE TABLE csblog_permission_table ( +-- NOTE: the default is DENY, so users are denied unless something specifically gives them access. +-- NOTE2: I intended to use PHPGACL for this... +------------------------------------ + + + + + +CREATE TABLE cms_permission_table ( permission_id serial NOT NULL PRIMARY KEY, - blog_id integer NOT NULL REFERENCES csblog_blog_table(blog_id), - uid integer NOT NULL REFERENCES cs_authentication_table(uid) + name varchar(32) NOT NULL UNIQUE, + description text NOT NULL ); --- --- Table for holding comments. --- NOTE: even though the author is required (i.e. they must be logged-in), "is_anonymous" is set to make it appear as though it were anonymous. --- NOTE2: "ancestry" is for denoting how a comment is linked to other comments. "10:12:15" indicates it's immediate parent is 15, grandparent --- is 12, and thread origin is 10 (all numbers pertain to comment_id's). --- -CREATE TABLE csblog_comment_table ( - comment_id serial NOT NULL PRIMARY KEY, - entry_id int NOT NULL REFERENCES csblog_entry_table(entry_id), - author_uid int NOT NULL REFERENCES cs_authentication_table(uid), - is_anonymous boolean NOT NULL DEFAULT false, - create_timestamp timestamp NOT NULL DEFAULT NOW(), - ancestry text, - title text NOT NULL, - comment text NOT NULL -); +-- Table that defines groups. +CREATE TABLE cms_group_table ( + group_id serial NOT NULL PRIMARY KEY, + name varchar(32) NOT NULL UNIQUE, + description text NOT NULL +); --- Add entries for users. ---NOTE: password for "test" is "test". -INSERT INTO cs_authentication_table (username, passwd) VALUES('test','a0d987ef6826c00ff6e4ac0851ea4744'); --- SET NEXT UID TO BE > 100... -select setval('cs_authentication_table_uid_seq',100); ---abort; + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-23 17:33:41
|
Revision: 12 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=12&view=rev Author: crazedsanity Date: 2009-02-23 17:33:37 +0000 (Mon, 23 Feb 2009) Log Message: ----------- Some changes to "make it work" (yeah, it's still broken; the test just shows a blank screen). Modified Paths: -------------- trunk/0.1/gacl/admin/gacl_admin.inc.php trunk/0.1/gacl/gacl.class.php trunk/0.1/gacl/gacl.ini.php trunk/0.1/gacl/setup.php Modified: trunk/0.1/gacl/admin/gacl_admin.inc.php =================================================================== --- trunk/0.1/gacl/admin/gacl_admin.inc.php 2009-02-23 16:23:36 UTC (rev 11) +++ trunk/0.1/gacl/admin/gacl_admin.inc.php 2009-02-23 17:33:37 UTC (rev 12) @@ -51,7 +51,11 @@ } unset($config); } +else { + exit(__METHOD__ .": no config file (". $config_file .")"); +} + $gacl_api = new gacl_admin_api($gacl_options); $gacl = &$gacl_api; Modified: trunk/0.1/gacl/gacl.class.php =================================================================== --- trunk/0.1/gacl/gacl.class.php 2009-02-23 16:23:36 UTC (rev 11) +++ trunk/0.1/gacl/gacl.class.php 2009-02-23 17:33:37 UTC (rev 12) @@ -51,7 +51,7 @@ /* --- phpGACL Configuration path/file --- */ - var $config_file = './gacl.ini.php'; + var $config_file = 'gacl.ini.php'; /* --- Private properties --- @@ -108,7 +108,7 @@ * @param array An arry of options to oeverride the class defaults */ function gacl($options = NULL) { - + $this->config = dirname(__FILE__) .'/gacl.ini.php'; $available_options = array('db','debug','items_per_page','max_select_box_items','max_search_return_items','db_table_prefix','db_type','db_host','db_user','db_password','db_name','caching','force_cache_expire','cache_dir','cache_expire_time'); //Values supplied in $options array overwrite those in the config file. Modified: trunk/0.1/gacl/gacl.ini.php =================================================================== --- trunk/0.1/gacl/gacl.ini.php 2009-02-23 16:23:36 UTC (rev 11) +++ trunk/0.1/gacl/gacl.ini.php 2009-02-23 17:33:37 UTC (rev 12) @@ -14,11 +14,11 @@ ; ;Database ; -db_type = "mysql" +db_type = "postgres8" db_host = "localhost" -db_user = "root" +db_user = "postgres" db_password = "" -db_name = "gacl" +db_name = "buzzkill_cms" db_table_prefix = "" ; Modified: trunk/0.1/gacl/setup.php =================================================================== --- trunk/0.1/gacl/setup.php 2009-02-23 16:23:36 UTC (rev 11) +++ trunk/0.1/gacl/setup.php 2009-02-23 17:33:37 UTC (rev 12) @@ -1,8 +1,8 @@ <?php -$config_file = './gacl.ini.php'; +$config_file = dirname(__FILE__) .'/gacl.ini.php'; -require_once('./admin/gacl_admin.inc.php'); +require_once(dirname(__FILE__) .'/admin/gacl_admin.inc.php'); require_once(ADODB_DIR .'/adodb-xmlschema.inc.php'); $db_table_prefix = $gacl->_db_table_prefix; @@ -170,7 +170,7 @@ $schema->SetPrefix($db_table_prefix, FALSE); //set $underscore == FALSE // Build the SQL array -$schema->ParseSchema('schema.xml'); +$schema->ParseSchema(dirname(__FILE__) .'/schema.xml'); // maybe display this if $gacl->debug is true? if ($gacl->_debug) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-23 16:23:48
|
Revision: 11 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=11&view=rev Author: crazedsanity Date: 2009-02-23 16:23:36 +0000 (Mon, 23 Feb 2009) Log Message: ----------- Adding PHPGACL (3.3.7). This may be modified to not use ADODB, or to at least accept parameters defined by cs_siteConfig. Added Paths: ----------- trunk/0.1/gacl/ trunk/0.1/gacl/AUTHORS trunk/0.1/gacl/CHANGELOG trunk/0.1/gacl/COPYING.lib trunk/0.1/gacl/CREDITS trunk/0.1/gacl/Cache_Lite/ trunk/0.1/gacl/Cache_Lite/Hashed_Cache_Lite.php trunk/0.1/gacl/Cache_Lite/LICENSE trunk/0.1/gacl/Cache_Lite/Lite.php trunk/0.1/gacl/FAQ trunk/0.1/gacl/README trunk/0.1/gacl/TODO trunk/0.1/gacl/admin/ trunk/0.1/gacl/admin/about.php trunk/0.1/gacl/admin/acl_admin.php trunk/0.1/gacl/admin/acl_debug.php trunk/0.1/gacl/admin/acl_list.php trunk/0.1/gacl/admin/acl_test.php trunk/0.1/gacl/admin/acl_test2.php trunk/0.1/gacl/admin/acl_test3.php trunk/0.1/gacl/admin/admin.css trunk/0.1/gacl/admin/admin_functions.js trunk/0.1/gacl/admin/assign_group.php trunk/0.1/gacl/admin/edit_group.php trunk/0.1/gacl/admin/edit_object_sections.php trunk/0.1/gacl/admin/edit_objects.php trunk/0.1/gacl/admin/gacl_admin.inc.php trunk/0.1/gacl/admin/gacl_admin_api.class.php trunk/0.1/gacl/admin/group_admin.php trunk/0.1/gacl/admin/images/ trunk/0.1/gacl/admin/images/bot-l.png trunk/0.1/gacl/admin/images/bot-r.png trunk/0.1/gacl/admin/images/div-l.png trunk/0.1/gacl/admin/images/div-r.png trunk/0.1/gacl/admin/images/logo.png trunk/0.1/gacl/admin/images/mid-l.png trunk/0.1/gacl/admin/images/mid-r.png trunk/0.1/gacl/admin/images/spacer.gif trunk/0.1/gacl/admin/images/tab-off-l.png trunk/0.1/gacl/admin/images/tab-off-r.png trunk/0.1/gacl/admin/images/tab-on-l.png trunk/0.1/gacl/admin/images/tab-on-r.png trunk/0.1/gacl/admin/images/top-l.png trunk/0.1/gacl/admin/images/top-r.png trunk/0.1/gacl/admin/index.php trunk/0.1/gacl/admin/object_search.php trunk/0.1/gacl/admin/s.gif trunk/0.1/gacl/admin/smarty/ trunk/0.1/gacl/admin/smarty/COPYING.lib trunk/0.1/gacl/admin/smarty/libs/ trunk/0.1/gacl/admin/smarty/libs/Config_File.class.php trunk/0.1/gacl/admin/smarty/libs/Smarty.class.php trunk/0.1/gacl/admin/smarty/libs/Smarty_Compiler.class.php trunk/0.1/gacl/admin/smarty/libs/debug.tpl trunk/0.1/gacl/admin/smarty/libs/internals/ trunk/0.1/gacl/admin/smarty/libs/internals/core.assemble_plugin_filepath.php trunk/0.1/gacl/admin/smarty/libs/internals/core.assign_smarty_interface.php trunk/0.1/gacl/admin/smarty/libs/internals/core.create_dir_structure.php trunk/0.1/gacl/admin/smarty/libs/internals/core.display_debug_console.php trunk/0.1/gacl/admin/smarty/libs/internals/core.get_include_path.php trunk/0.1/gacl/admin/smarty/libs/internals/core.get_microtime.php trunk/0.1/gacl/admin/smarty/libs/internals/core.get_php_resource.php trunk/0.1/gacl/admin/smarty/libs/internals/core.is_secure.php trunk/0.1/gacl/admin/smarty/libs/internals/core.is_trusted.php trunk/0.1/gacl/admin/smarty/libs/internals/core.load_plugins.php trunk/0.1/gacl/admin/smarty/libs/internals/core.load_resource_plugin.php trunk/0.1/gacl/admin/smarty/libs/internals/core.process_cached_inserts.php trunk/0.1/gacl/admin/smarty/libs/internals/core.process_compiled_include.php trunk/0.1/gacl/admin/smarty/libs/internals/core.read_cache_file.php trunk/0.1/gacl/admin/smarty/libs/internals/core.rm_auto.php trunk/0.1/gacl/admin/smarty/libs/internals/core.rmdir.php trunk/0.1/gacl/admin/smarty/libs/internals/core.run_insert_handler.php trunk/0.1/gacl/admin/smarty/libs/internals/core.smarty_include_php.php trunk/0.1/gacl/admin/smarty/libs/internals/core.write_cache_file.php trunk/0.1/gacl/admin/smarty/libs/internals/core.write_compiled_include.php trunk/0.1/gacl/admin/smarty/libs/internals/core.write_compiled_resource.php trunk/0.1/gacl/admin/smarty/libs/internals/core.write_file.php trunk/0.1/gacl/admin/smarty/libs/plugins/ trunk/0.1/gacl/admin/smarty/libs/plugins/block.textformat.php trunk/0.1/gacl/admin/smarty/libs/plugins/compiler.assign.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.assign_debug_info.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.config_load.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.counter.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.cycle.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.debug.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.eval.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.fetch.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.html_checkboxes.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.html_image.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.html_options.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.html_radios.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.html_select_date.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.html_select_time.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.html_table.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.mailto.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.math.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.popup.php trunk/0.1/gacl/admin/smarty/libs/plugins/function.popup_init.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.capitalize.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.cat.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.count_characters.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.count_paragraphs.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.count_sentences.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.count_words.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.date_format.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.debug_print_var.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.default.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.escape.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.indent.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.lower.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.nl2br.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.regex_replace.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.replace.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.spacify.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.string_format.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.strip.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.strip_tags.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.truncate.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.upper.php trunk/0.1/gacl/admin/smarty/libs/plugins/modifier.wordwrap.php trunk/0.1/gacl/admin/smarty/libs/plugins/outputfilter.trimwhitespace.php trunk/0.1/gacl/admin/smarty/libs/plugins/shared.escape_special_chars.php trunk/0.1/gacl/admin/smarty/libs/plugins/shared.make_timestamp.php trunk/0.1/gacl/admin/templates/ trunk/0.1/gacl/admin/templates/phpgacl/ trunk/0.1/gacl/admin/templates/phpgacl/about.tpl trunk/0.1/gacl/admin/templates/phpgacl/acl_admin.tpl trunk/0.1/gacl/admin/templates/phpgacl/acl_admin_js.tpl trunk/0.1/gacl/admin/templates/phpgacl/acl_debug.tpl trunk/0.1/gacl/admin/templates/phpgacl/acl_list.tpl trunk/0.1/gacl/admin/templates/phpgacl/acl_test.tpl trunk/0.1/gacl/admin/templates/phpgacl/acl_test2.tpl trunk/0.1/gacl/admin/templates/phpgacl/acl_test3.tpl trunk/0.1/gacl/admin/templates/phpgacl/assign_group.tpl trunk/0.1/gacl/admin/templates/phpgacl/debug.tpl trunk/0.1/gacl/admin/templates/phpgacl/edit_group.tpl trunk/0.1/gacl/admin/templates/phpgacl/edit_object_sections.tpl trunk/0.1/gacl/admin/templates/phpgacl/edit_objects.tpl trunk/0.1/gacl/admin/templates/phpgacl/footer.tpl trunk/0.1/gacl/admin/templates/phpgacl/group_admin.tpl trunk/0.1/gacl/admin/templates/phpgacl/header.tpl trunk/0.1/gacl/admin/templates/phpgacl/navigation.tpl trunk/0.1/gacl/admin/templates/phpgacl/object_search.tpl trunk/0.1/gacl/admin/templates/phpgacl/pager.tpl trunk/0.1/gacl/admin/test.php trunk/0.1/gacl/adodb/ trunk/0.1/gacl/adodb/adodb-active-record.inc.php trunk/0.1/gacl/adodb/adodb-csvlib.inc.php trunk/0.1/gacl/adodb/adodb-datadict.inc.php trunk/0.1/gacl/adodb/adodb-error.inc.php trunk/0.1/gacl/adodb/adodb-errorhandler.inc.php trunk/0.1/gacl/adodb/adodb-errorpear.inc.php trunk/0.1/gacl/adodb/adodb-exceptions.inc.php trunk/0.1/gacl/adodb/adodb-iterator.inc.php trunk/0.1/gacl/adodb/adodb-lib.inc.php trunk/0.1/gacl/adodb/adodb-memcache.lib.inc.php trunk/0.1/gacl/adodb/adodb-pager.inc.php trunk/0.1/gacl/adodb/adodb-pear.inc.php trunk/0.1/gacl/adodb/adodb-perf.inc.php trunk/0.1/gacl/adodb/adodb-php4.inc.php trunk/0.1/gacl/adodb/adodb-time.inc.php trunk/0.1/gacl/adodb/adodb-xmlschema.inc.php trunk/0.1/gacl/adodb/adodb-xmlschema03.inc.php trunk/0.1/gacl/adodb/adodb.inc.php trunk/0.1/gacl/adodb/contrib/ trunk/0.1/gacl/adodb/contrib/toxmlrpc.inc.php trunk/0.1/gacl/adodb/datadict/ trunk/0.1/gacl/adodb/datadict/datadict-access.inc.php trunk/0.1/gacl/adodb/datadict/datadict-db2.inc.php trunk/0.1/gacl/adodb/datadict/datadict-firebird.inc.php trunk/0.1/gacl/adodb/datadict/datadict-generic.inc.php trunk/0.1/gacl/adodb/datadict/datadict-ibase.inc.php trunk/0.1/gacl/adodb/datadict/datadict-informix.inc.php trunk/0.1/gacl/adodb/datadict/datadict-mssql.inc.php trunk/0.1/gacl/adodb/datadict/datadict-mysql.inc.php trunk/0.1/gacl/adodb/datadict/datadict-oci8.inc.php trunk/0.1/gacl/adodb/datadict/datadict-postgres.inc.php trunk/0.1/gacl/adodb/datadict/datadict-sapdb.inc.php trunk/0.1/gacl/adodb/datadict/datadict-sybase.inc.php trunk/0.1/gacl/adodb/drivers/ trunk/0.1/gacl/adodb/drivers/adodb-access.inc.php trunk/0.1/gacl/adodb/drivers/adodb-ado.inc.php trunk/0.1/gacl/adodb/drivers/adodb-ado5.inc.php trunk/0.1/gacl/adodb/drivers/adodb-ado_access.inc.php trunk/0.1/gacl/adodb/drivers/adodb-ado_mssql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-borland_ibase.inc.php trunk/0.1/gacl/adodb/drivers/adodb-csv.inc.php trunk/0.1/gacl/adodb/drivers/adodb-db2.inc.php trunk/0.1/gacl/adodb/drivers/adodb-fbsql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-firebird.inc.php trunk/0.1/gacl/adodb/drivers/adodb-ibase.inc.php trunk/0.1/gacl/adodb/drivers/adodb-informix.inc.php trunk/0.1/gacl/adodb/drivers/adodb-informix72.inc.php trunk/0.1/gacl/adodb/drivers/adodb-ldap.inc.php trunk/0.1/gacl/adodb/drivers/adodb-mssql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-mssqlpo.inc.php trunk/0.1/gacl/adodb/drivers/adodb-mysql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-mysqli.inc.php trunk/0.1/gacl/adodb/drivers/adodb-mysqlt.inc.php trunk/0.1/gacl/adodb/drivers/adodb-netezza.inc.php trunk/0.1/gacl/adodb/drivers/adodb-oci8.inc.php trunk/0.1/gacl/adodb/drivers/adodb-oci805.inc.php trunk/0.1/gacl/adodb/drivers/adodb-oci8po.inc.php trunk/0.1/gacl/adodb/drivers/adodb-odbc.inc.php trunk/0.1/gacl/adodb/drivers/adodb-odbc_db2.inc.php trunk/0.1/gacl/adodb/drivers/adodb-odbc_mssql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-odbc_oracle.inc.php trunk/0.1/gacl/adodb/drivers/adodb-odbtp.inc.php trunk/0.1/gacl/adodb/drivers/adodb-odbtp_unicode.inc.php trunk/0.1/gacl/adodb/drivers/adodb-oracle.inc.php trunk/0.1/gacl/adodb/drivers/adodb-pdo.inc.php trunk/0.1/gacl/adodb/drivers/adodb-pdo_mssql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-pdo_mysql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-pdo_oci.inc.php trunk/0.1/gacl/adodb/drivers/adodb-pdo_pgsql.inc.php trunk/0.1/gacl/adodb/drivers/adodb-postgres.inc.php trunk/0.1/gacl/adodb/drivers/adodb-postgres64.inc.php trunk/0.1/gacl/adodb/drivers/adodb-postgres7.inc.php trunk/0.1/gacl/adodb/drivers/adodb-postgres8.inc.php trunk/0.1/gacl/adodb/drivers/adodb-proxy.inc.php trunk/0.1/gacl/adodb/drivers/adodb-sapdb.inc.php trunk/0.1/gacl/adodb/drivers/adodb-sqlanywhere.inc.php trunk/0.1/gacl/adodb/drivers/adodb-sqlite.inc.php trunk/0.1/gacl/adodb/drivers/adodb-sqlitepo.inc.php trunk/0.1/gacl/adodb/drivers/adodb-sybase.inc.php trunk/0.1/gacl/adodb/drivers/adodb-sybase_ase.inc.php trunk/0.1/gacl/adodb/drivers/adodb-vfp.inc.php trunk/0.1/gacl/adodb/lang/ trunk/0.1/gacl/adodb/lang/adodb-ar.inc.php trunk/0.1/gacl/adodb/lang/adodb-bg.inc.php trunk/0.1/gacl/adodb/lang/adodb-bgutf8.inc.php trunk/0.1/gacl/adodb/lang/adodb-ca.inc.php trunk/0.1/gacl/adodb/lang/adodb-cn.inc.php trunk/0.1/gacl/adodb/lang/adodb-cz.inc.php trunk/0.1/gacl/adodb/lang/adodb-da.inc.php trunk/0.1/gacl/adodb/lang/adodb-de.inc.php trunk/0.1/gacl/adodb/lang/adodb-en.inc.php trunk/0.1/gacl/adodb/lang/adodb-es.inc.php trunk/0.1/gacl/adodb/lang/adodb-esperanto.inc.php trunk/0.1/gacl/adodb/lang/adodb-fr.inc.php trunk/0.1/gacl/adodb/lang/adodb-hu.inc.php trunk/0.1/gacl/adodb/lang/adodb-it.inc.php trunk/0.1/gacl/adodb/lang/adodb-nl.inc.php trunk/0.1/gacl/adodb/lang/adodb-pl.inc.php trunk/0.1/gacl/adodb/lang/adodb-pt-br.inc.php trunk/0.1/gacl/adodb/lang/adodb-ro.inc.php trunk/0.1/gacl/adodb/lang/adodb-ru1251.inc.php trunk/0.1/gacl/adodb/lang/adodb-sv.inc.php trunk/0.1/gacl/adodb/lang/adodb-uk1251.inc.php trunk/0.1/gacl/adodb/license.txt trunk/0.1/gacl/adodb/perf/ trunk/0.1/gacl/adodb/perf/perf-db2.inc.php trunk/0.1/gacl/adodb/perf/perf-informix.inc.php trunk/0.1/gacl/adodb/perf/perf-mssql.inc.php trunk/0.1/gacl/adodb/perf/perf-mysql.inc.php trunk/0.1/gacl/adodb/perf/perf-oci8.inc.php trunk/0.1/gacl/adodb/perf/perf-postgres.inc.php trunk/0.1/gacl/adodb/pivottable.inc.php trunk/0.1/gacl/adodb/readme.txt trunk/0.1/gacl/adodb/rsfilter.inc.php trunk/0.1/gacl/adodb/server.php trunk/0.1/gacl/adodb/session/ trunk/0.1/gacl/adodb/session/adodb-compress-bzip2.php trunk/0.1/gacl/adodb/session/adodb-compress-gzip.php trunk/0.1/gacl/adodb/session/adodb-cryptsession.php trunk/0.1/gacl/adodb/session/adodb-cryptsession2.php trunk/0.1/gacl/adodb/session/adodb-encrypt-mcrypt.php trunk/0.1/gacl/adodb/session/adodb-encrypt-md5.php trunk/0.1/gacl/adodb/session/adodb-encrypt-secret.php trunk/0.1/gacl/adodb/session/adodb-encrypt-sha1.php trunk/0.1/gacl/adodb/session/adodb-sess.txt trunk/0.1/gacl/adodb/session/adodb-session-clob.php trunk/0.1/gacl/adodb/session/adodb-session-clob2.php trunk/0.1/gacl/adodb/session/adodb-session.php trunk/0.1/gacl/adodb/session/adodb-session2.php trunk/0.1/gacl/adodb/session/adodb-sessions.mysql.sql trunk/0.1/gacl/adodb/session/adodb-sessions.oracle.clob.sql trunk/0.1/gacl/adodb/session/adodb-sessions.oracle.sql trunk/0.1/gacl/adodb/session/crypt.inc.php trunk/0.1/gacl/adodb/session/session_schema.xml trunk/0.1/gacl/adodb/session/session_schema2.xml trunk/0.1/gacl/adodb/toexport.inc.php trunk/0.1/gacl/adodb/tohtml.inc.php trunk/0.1/gacl/adodb/xmlschema.dtd trunk/0.1/gacl/adodb/xmlschema03.dtd trunk/0.1/gacl/docs/ trunk/0.1/gacl/docs/examples/ trunk/0.1/gacl/docs/examples/example.php trunk/0.1/gacl/docs/examples/millennium_falcon/ trunk/0.1/gacl/docs/examples/millennium_falcon/Multi-levelGroups.php trunk/0.1/gacl/docs/examples/millennium_falcon/definingAccessControl.php trunk/0.1/gacl/docs/examples/millennium_falcon/fineGrainAccessControl.php trunk/0.1/gacl/docs/examples/millennium_falcon/footer.php trunk/0.1/gacl/docs/examples/millennium_falcon/header.php trunk/0.1/gacl/docs/examples/millennium_falcon/index.php trunk/0.1/gacl/docs/examples/millennium_falcon/millenniumFalcon.inc trunk/0.1/gacl/docs/examples/millennium_falcon/welcome.php trunk/0.1/gacl/docs/manual.html trunk/0.1/gacl/docs/manual.odt trunk/0.1/gacl/docs/manual.pdf trunk/0.1/gacl/docs/manual.txt trunk/0.1/gacl/docs/manual_html_157037e7.png trunk/0.1/gacl/docs/manual_html_4b803670.png trunk/0.1/gacl/docs/manual_html_676f8c98.png trunk/0.1/gacl/docs/manual_html_7dced6ce.png trunk/0.1/gacl/docs/manual_html_m481ab4b3.png trunk/0.1/gacl/docs/manual_html_m48c2db5c.png trunk/0.1/gacl/docs/manual_html_m4f4324cb.png trunk/0.1/gacl/docs/manual_html_m54d0ced8.png trunk/0.1/gacl/docs/manual_html_m608b392a.png trunk/0.1/gacl/docs/manual_html_m6a630ca2.png trunk/0.1/gacl/docs/manual_html_m770a5a15.png trunk/0.1/gacl/docs/phpdoc/ trunk/0.1/gacl/docs/phpdoc/blank.html trunk/0.1/gacl/docs/phpdoc/classtrees_phpGACL.html trunk/0.1/gacl/docs/phpdoc/elementindex.html trunk/0.1/gacl/docs/phpdoc/elementindex_phpGACL.html trunk/0.1/gacl/docs/phpdoc/errors.html trunk/0.1/gacl/docs/phpdoc/index.html trunk/0.1/gacl/docs/phpdoc/li_phpGACL.html trunk/0.1/gacl/docs/phpdoc/media/ trunk/0.1/gacl/docs/phpdoc/media/banner.css trunk/0.1/gacl/docs/phpdoc/media/images/ trunk/0.1/gacl/docs/phpdoc/media/images/AbstractClass.png trunk/0.1/gacl/docs/phpdoc/media/images/AbstractClass_logo.png trunk/0.1/gacl/docs/phpdoc/media/images/AbstractMethod.png trunk/0.1/gacl/docs/phpdoc/media/images/AbstractPrivateClass.png trunk/0.1/gacl/docs/phpdoc/media/images/AbstractPrivateClass_logo.png trunk/0.1/gacl/docs/phpdoc/media/images/AbstractPrivateMethod.png trunk/0.1/gacl/docs/phpdoc/media/images/Class.png trunk/0.1/gacl/docs/phpdoc/media/images/Class_logo.png trunk/0.1/gacl/docs/phpdoc/media/images/Constant.png trunk/0.1/gacl/docs/phpdoc/media/images/Constructor.png trunk/0.1/gacl/docs/phpdoc/media/images/Destructor.png trunk/0.1/gacl/docs/phpdoc/media/images/Function.png trunk/0.1/gacl/docs/phpdoc/media/images/Global.png trunk/0.1/gacl/docs/phpdoc/media/images/I.png trunk/0.1/gacl/docs/phpdoc/media/images/Index.png trunk/0.1/gacl/docs/phpdoc/media/images/L.png trunk/0.1/gacl/docs/phpdoc/media/images/Lminus.png trunk/0.1/gacl/docs/phpdoc/media/images/Lplus.png trunk/0.1/gacl/docs/phpdoc/media/images/Method.png trunk/0.1/gacl/docs/phpdoc/media/images/Page.png trunk/0.1/gacl/docs/phpdoc/media/images/Page_logo.png trunk/0.1/gacl/docs/phpdoc/media/images/PrivateClass.png trunk/0.1/gacl/docs/phpdoc/media/images/PrivateClass_logo.png trunk/0.1/gacl/docs/phpdoc/media/images/PrivateMethod.png trunk/0.1/gacl/docs/phpdoc/media/images/PrivateVariable.png trunk/0.1/gacl/docs/phpdoc/media/images/T.png trunk/0.1/gacl/docs/phpdoc/media/images/Tminus.png trunk/0.1/gacl/docs/phpdoc/media/images/Tplus.png trunk/0.1/gacl/docs/phpdoc/media/images/Variable.png trunk/0.1/gacl/docs/phpdoc/media/images/blank.png trunk/0.1/gacl/docs/phpdoc/media/images/class_folder.png trunk/0.1/gacl/docs/phpdoc/media/images/empty.png trunk/0.1/gacl/docs/phpdoc/media/images/file.png trunk/0.1/gacl/docs/phpdoc/media/images/folder.png trunk/0.1/gacl/docs/phpdoc/media/images/function_folder.png trunk/0.1/gacl/docs/phpdoc/media/images/next_button.png trunk/0.1/gacl/docs/phpdoc/media/images/next_button_disabled.png trunk/0.1/gacl/docs/phpdoc/media/images/package.png trunk/0.1/gacl/docs/phpdoc/media/images/package_folder.png trunk/0.1/gacl/docs/phpdoc/media/images/previous_button.png trunk/0.1/gacl/docs/phpdoc/media/images/previous_button_disabled.png trunk/0.1/gacl/docs/phpdoc/media/images/private_class_logo.png trunk/0.1/gacl/docs/phpdoc/media/images/tutorial.png trunk/0.1/gacl/docs/phpdoc/media/images/tutorial_folder.png trunk/0.1/gacl/docs/phpdoc/media/images/up_button.png trunk/0.1/gacl/docs/phpdoc/media/stylesheet.css trunk/0.1/gacl/docs/phpdoc/packages.html trunk/0.1/gacl/docs/phpdoc/phpGACL/ trunk/0.1/gacl/docs/phpdoc/phpGACL/_gacl_api_class_php.html trunk/0.1/gacl/docs/phpdoc/phpGACL/_gacl_class_php.html trunk/0.1/gacl/docs/phpdoc/phpGACL/gacl.html trunk/0.1/gacl/docs/phpdoc/phpGACL/gacl_api.html trunk/0.1/gacl/docs/phpgacl-db-schema.png trunk/0.1/gacl/docs/phpgacl-db-schema.vsd trunk/0.1/gacl/docs/translations/ trunk/0.1/gacl/docs/translations/russian/ trunk/0.1/gacl/docs/translations/russian/manual_rus.html trunk/0.1/gacl/docs/translations/russian/manual_rus.pdf trunk/0.1/gacl/docs/translations/russian/manual_rus.sxw trunk/0.1/gacl/docs/translations/russian/manual_rus.txt trunk/0.1/gacl/gacl.class.php trunk/0.1/gacl/gacl.ini.php trunk/0.1/gacl/gacl_api.class.php trunk/0.1/gacl/other_languages/ trunk/0.1/gacl/other_languages/perl/ trunk/0.1/gacl/other_languages/perl/perlGACL-check-1.0.tar.gz trunk/0.1/gacl/phpdoc.phpgacl.ini trunk/0.1/gacl/profiler.inc trunk/0.1/gacl/schema.xml trunk/0.1/gacl/setup.php trunk/0.1/gacl/soap/ trunk/0.1/gacl/soap/clients/ trunk/0.1/gacl/soap/clients/perl_client.pl trunk/0.1/gacl/soap/clients/php_client.php trunk/0.1/gacl/soap/clients/python_client.py trunk/0.1/gacl/soap/nusoap.php trunk/0.1/gacl/soap/server.php trunk/0.1/gacl/test_suite/ trunk/0.1/gacl/test_suite/acl_tests.php trunk/0.1/gacl/test_suite/phpunit/ trunk/0.1/gacl/test_suite/phpunit/ChangeLog trunk/0.1/gacl/test_suite/phpunit/README trunk/0.1/gacl/test_suite/phpunit/phpunit.php trunk/0.1/gacl/test_suite/phpunit/phpunit_test.php trunk/0.1/gacl/test_suite/phpunit/runtests.php trunk/0.1/gacl/test_suite/phpunit/runtests2.php trunk/0.1/gacl/test_suite/phpunit/stylesheet.css trunk/0.1/gacl/test_suite/random_acl_check.php trunk/0.1/gacl/test_suite/run.php trunk/0.1/gacl/test_suite/stress_test.php trunk/0.1/gacl/test_suite/styles.css trunk/0.1/gacl/test_suite/unit_tests.php Added: trunk/0.1/gacl/AUTHORS =================================================================== --- trunk/0.1/gacl/AUTHORS (rev 0) +++ trunk/0.1/gacl/AUTHORS 2009-02-23 16:23:36 UTC (rev 11) @@ -0,0 +1,5 @@ +Mike Benoit <ip...@sn...> + - Initial idea of completely configurable ACLs. + Though I haven't seen anything similar available, I'm sure its out there. + - Initial implementation + - Initial Documentation Added: trunk/0.1/gacl/CHANGELOG =================================================================== --- trunk/0.1/gacl/CHANGELOG (rev 0) +++ trunk/0.1/gacl/CHANGELOG 2009-02-23 16:23:36 UTC (rev 11) @@ -0,0 +1,461 @@ +Tue Sep 05 2006 + mikeb - Release version 3.3.7 +Sun Sep 03 2006 + mikeb - Update documentation to reflect using gacl.ini.php + mikeb - Allow ADODB_DIR to be set prior to GACL class being loaded + mikeb - Remove ADODB_FETCH_MODE global variable, use just setFetchMode() so we don't conflict with other + application code. + mikeb - Upgrade Smarty v2.6.14 + mikeb - Upgrade ADODB v4.92 + mikeb - Switch from CVS to SVN on sourceforge.net. +Sat Dec 03 2005 + mikeb - Release version 3.3.6 +Wed Oct 26 2005 + mikeb - Added function get_section_data() thanks to Rodrigo Moraes <rod...@gm...> +Mon Oct 17 2005 + mikeb - Fixed a bunch of warnings/notices thanks to Charles M Hall <cm...@ha...> +Thu Oct 13 2005 + mikeb - Fixed a few PHP NOTICEs +Sun Oct 9 2005 + mikeb - Fixed PHP5 warning/notice of reference in gacl_api.class to do with end() call. +Thu Sep 22 2005 + mikeb - added dirname() to the config_file variable in admin/gacl_admin.inc.php +Wed Sep 21 2005 + mikeb - Addslashes to JS creation code in assign_group.php. +Thu Sep 08 2005 + mikeb - Added support for MS-SQL in setup.php, thanks to Fran\xE7ois Tissandier <fra...@te...> +Sat Sep 03 2005 + mikeb - Fixed typo in manual + mikeb - Fixed comments in gacl.class.php + mikeb - released v3.3.5 +Mon Aug 22 2005 + mikeb - Fixed bug with edit_acl() for cases where a non-existant acl_id is specified. Thanks to Caleb Simonyi-Gindele <ca...@ve...> +Thu Aug 04 2005 + mikeb - Fixed bug with config ini file path in setup.php +Thu Jul 28 2005 + mikeb - Fixed bug with double/single quotes on line 3526. J\xE9r\xE9my Cohen Solal <je...@ei...> +Sun Jul 24 2005 + mikeb - Removed table prefix comment regarding not using "_". Apparently it works now + mikeb - Fixed comments in gacl.class.php regarding group IDs, it now correctly says group values. + mikeb - Hashed_Cache_Lite class now checks to see if Cache_Lite class already exists before including it. + mikeb - Added Russian manual translation thanks to <ku...@ru...> + mikeb - Added gacl.conf config file for both admin interface and gacl.class.php. Thanks to Richard Plevin <ri...@pl...> + mikeb - Fixed a couple notices with E_ALL enabled in the API. John Mortlock <jo...@hl...> + mikeb - Added a SQL quoting to insert. Eder <luk...@io...> + mikeb - Added support for custom ACL sections to add_acl(), for instance if someone deletes the 'system' section. Vincent Woo <vw...@sf...> + mikeb - Upgraded ADODB to v4.65 + mikeb - Upgraded Smarty to v2.6.9 + mikeb - Release v3.3.5b1 +Wed Dec 8 2004 + mikeb - Release v3.3.4 +Sun Dec 5 2004 + mikeb - Added clear_database() API function that truncates all phpGACL tables. Thanks to Ross Lawley <ros...@me...> + mikeb - Modified millennium falcon example. + dcech - Updated get_group_objects function with much more efficient SQL. +Tue Nov 30 2004 + mikeb - modified query in get_group_objects() to speed it up. It could still be optimized further though. +Mon Nov 29 2004 + mikeb - Applied patch to admin/edit_group.php enabling the deletion of all groups. John Mortlock <jo...@hl...> +Sun Nov 28 2004 + mikeb - Removed default table prefix from gacl.class.php. + mikeb - Corrected minor mistake in the manual with regards to incorrect argument ordering in acl_check() + mikeb - Modified API comments for search_acl() to include return value. + mikeb - Fixed admin link at the bottom of several pages in the Millennium Falcon examples. +Sat Nov 27 2004 + mikeb - Added Millennium Falcon example written by Ross Lawley <ros...@me...> + mikeb - Added 3-dimensional ACL Test page from Meinhard <mei...@ka...> + mikeb - Upgraded ADODB to v4.54 + mikeb - Upgraded Smarty to v2.6.6 +Sun Nov 7 2004 + mikeb - Updated Cache Lite class to latest version, including improved Hashed_Cache_Lite class thanks to Dan. + mikeb - If caching is not enabled, improved the bypassing of the caching library/overhead thanks to Andrew Eddie <edd...@ip...> + mikeb - Updated manual thanks to Andrew Eddie <edd...@ip...> + mikeb - add_group API function now assigns the value to the insert ID if the value is not specified. thanks to Andrew Eddie <edd...@ip...> + mikeb - Moved admin interface specific functions/variables from gacl_api.class.php to admin/gacl_admin_api.class.php. thanks to Andrew Eddie <edd...@ip...> +Mon Oct 4 2004 + mikeb - Added phpDoc style comments thanks to Gordon Luk <gor...@df...> +Sat Oct 2 2004 + mikeb - Added get_ungrouped_objects() function, thanks to Gordon Luk <gor...@df...> +Sun Sep 19 2004 + mikeb - Added a "isset()" call in Hashed_Cache_Lite + mikeb - Applied patch from Gordon Luk <gor...@df...> to allow the search_acl() function to proceed without a where clause. +Thu Sep 09 2004 + mikeb - gacl.class.php line 532, missing quotes around $root_group. Thanks to Erwan le Gall <erw...@ed...> +Sat Aug 28 2004 + mikeb - Released v3.3.3 +Mon Aug 16 2004 + mikeb - Quoted group value in acl_get_groups(). Thanks to Christer Lindh <cl...@ho...> +Wed Aug 11 2004 + mikeb - Add comment to admin/gacl_admin.inc.php to tell people not to use "_" for table prefixes. +Thu Aug 05 2004 + mikeb - Fixed acl_test.php ACL Check timings. Thanks to Gordon Luk <gor...@df...> +Tue Jul 27 2004 + dcech - Fixed missing table prefix in edit_object function. + Thanks to Martin Salo <sa...@la...>. + dcech - Updated to adodb-xmlschema CVS for prefixing. +Mon Jul 26 2004 + mikeb - Fixed bug in is_conflicting_acl() where it would detect an incorrect conflict when using certain AXO combinations. Thanks to a patch from Jeff McDonald <je...@be...> +Sat Jul 17 2004 + mikeb - Fixed group_admin SQL query to be standard complaint so it works on PostgreSQL. + mikeb - Made aro_groups/axo_groups value column unique. +Sat Jul 10 2004 + mikeb - Released v3.3.2 + mikeb - upgraded to ADOdb v4.50 + mikeb - upgraded to Smarty v2.6.3 + mikeb - Fixed group_admin.php bug with hardcoded group_type column name. +Sat Jun 19 2004 + dcech - cleaned up setup script a little + dcech - upgraded to adodb-xmlschema CVS to get fixes for prefix-related problems. +Fri Jun 18 2004 + dcech - upgraded to ADOdb v4.23 +Thu Jun 17 2004 + mikeb - Removed admin/mysql_db_demo_data.sql as it was the old 3.2.x format and useless now. + mikeb - Fixed issue with links and group names with spaces in them. Thanks to Gordon Luk <gor...@df...> + dcech - fixed object count in group admin for groups without objects +Tue May 24 2004 + mikeb - Fixed bug in API that stopped you from changing a group name to the same thing as the group value. Hakan Kuecuekyilmaz <ha...@li...> +Sat May 08 2004 + mikeb - Released v3.3.1 +Fri May 07 2004 + dcech - Fixed setup issues with new schema format, and moved to AXMLS prefixing. +Wed May 05 2004 + mikeb - Fixed bug in acl_get_groups() where $root_group = '' causes a SQL error. Thanks to Hakan Kuecuekyilmaz <ha...@li...> + mikeb - Fixed Unit Tests to work with group_value's. Thanks to the help from Hakan Kuecuekyilmaz <ha...@li...> +Mon May 03 2004 + mikeb - Updated comments for add_group() to explain the Root group limitation of our MPTT format. +Sun May 02 2004 + mikeb - Added Perl ACL_Check module written by Gordon Luk <gl...@df...> + mikeb - Upgraded to ADODB v4.22 + mikeb - Upgraded to Smarty v2.6.2 + mikeb - Re-enabled JS selected = true when selecting objects to assign to groups. + mikeb - Released v3.3.0-final + +==> mikeb - Read the CHANGELOG line with "==>" infront of it. Mar 03 2004. + +Wed Apr 21 2004 + mikeb - Fixed index name for value column in AXO group table. Falk <su...@fa...> + mikeb - Updated schema diagrams. Falk <su...@fa...> +Tue Apr 06 2004 + mikeb - applied code documentation patch thanks to Andrew Eddie <edd...@ip...> +Mon Apr 05 2004 + dcech - added index.php to admin directory, fixed bug in format_groups. Thanks to Andrew Eddie <edd...@ip...> + dcech - Fixed object_search javascript bug, cleaned up admin navigation html. +Sat Apr 03 2004 + dcech - Fixed JavaScript bug in IE, minor cleanup of admin_functions.js +Fri Mar 19 2004 + dcech - Fixed minor typo in gacl_api.class.php. Thanks to Andrew Eddie <edd...@ip...> +Wed Mar 03 2004 + dcech - Updated admin interface and gacl class for value patch. + acl_* functions now all accept group values rather than IDs. + dcech - Minor fixes in gacl_api for group_value patch. + +==> mikeb - *BEWARE* add_group(), edit_group() both require a group_value now! This breaks backwards compatibility. + +Sat Feb 28 2004 + mikeb - Upgraded ADODB to 4.20. + mikeb - Applied group value patch from Christer Lindh <cl...@ho...>. + Admin interface still needs updating. As well as the gacl.class. +Tue Feb 24 2004 + dcech - minor fix to display AXO controls when editing ACLs +Sat Feb 14 2004 + mikeb - Added DB schema diagram to docs/ directory. Thanks to Falk John <su...@fa...> +Fri Feb 13 2004 + dcech - Changed all JOIN queries to INNER JOIN for MySQL 3.23.x compatibility +Thu Feb 12 2004 + dcech - removed final trailing semicolon from schema.xml +Tue Feb 10 2004 + mikeb - Fixed get_object() to support ACLs. +Mon Feb 09 2004 + mikeb - Fixed del_object_section() to properly delete ACLs if the section is deleted. Thanks to Falk John <su...@fa...> + mikeb - Fixed del_object_section() when using ACL objects. + mikeb - Took ";" out of schema.xml, and changed version to b2. + mikeb - Added some missing transaction rollbacks to gacl_api. Thanks to Falk John <su...@fa...> +Sun Feb 08 2004 + dcech - Added titles to admin interface + mikeb - Removed the last of "is_string()" DB errro checks, replaced with "is_object($rs)" + mikeb - Oracle SQL syntax fixes for gacl.class.php and gacl_api.class.php. Thanks to Falk John <su...@fa...> + dcech - SQL syntax fixes for admin system +Sat Feb 07 2004 + dcech - New style for admin interface +Wed Feb 04 2004 + mikeb - Removed old, out dated examples from gacl_api.class.php +Sun Feb 01 2004 + dcech - cleanup of assign_group.php, template updates for assign_group and group_admin +Sat Jan 31 2004 + dcech - more interface cleanups +Fri Jan 30 2004 + dcech - complete overhaul of acl_admin.php + dcech - fix for LIMIT in sql, complete overhaul of object search +Thu Jan 29 2004 + dcech - major interface overhaul + dcech - acl_list interface improvements, minor css modification + mikeb - Upgraded to ADODB 4.11, removed trailing whitespace from adodb-pager.inc.php + dcech - major overhaul of acl_list filtering +Wed Jan 28 2004 + dcech - major update to acl_list + dcech - fix for stress_test to handle existing groups + dcech - fixed trailing whitespace in adodb-pager.inc.php +Sun Jan 25 2004 + mikeb - Changed acl_list layout. + mikeb - Changed setup.php to point to about.php and modified about.php to only display the report section on first run. + mikeb - Unleashed v3.3.0b1 upon the world! Wahahahah! +Sat Jan 24 2004 + mikeb - Minor updates to CREDITS file, README, and footer.tpl + mikeb - Upgraded ADODB to v4.10 + mikeb - Upgraded Smarty to v2.6.1 + dcech - del_object: fix for new GetCol behaviour in ADOdb 4.10 +Wed Jan 14 2004 + mikeb - modified TODO list slightly. + mikeb - added Navigation bar submitted by: <edd...@ip...> on Oct 13/2003. + mikeb - Moved the "select all" checkboxes... + mikeb - modified include syntax in acl_admin_js.tpl slightly. + mikeb - add_object(), edit_object(), edit_object_section(), add_object_section(), fixed issue with hidden being set to a non-int value. +Thu Jan 08 2004 + dcech - Added Select/Deselect All to Admin Interface +Thu Jan 08 2004 + dcech - applied _group_ patch +Mon Nov 24 2003 + mikeb - Fixed PostgreSQL LEFT JOIN issue with is_conflicting_acl(), Can't reference multiple tables, then a LEFT JOIN. ie: + select * from table1, table2 LEFT JOIN table3 LEFT JOIN table4. + Instead: + select * from table1 LEFT JOIN table2 LEFT JOIN table3 LEFT JOIN table4. + mikeb - Fixed PosgresSQL LEFT JOIN issue with acl_check() + mikeb - Fixed PostgreSQL transaction issue, where generating sequences causes the transaction to abort. + Simply move the transaction start _after_ the GenID() call. + dcech - cleaned up get_object_section_section_id - fixed bug if invalid object type specified, and bug if no value specified. +Wed Nov 19 2003 + mikeb - Added transactions to edit_object_section() + mikeb - Added more API test_suite functions. + mikeb - Fixed minor display issue with pager.tpl. + dcech - numerous fixes in gacl_api. edit_group, add_group_object, rebuild_tree & _rebuild_tree. + dcech - new functions in gacl_api. get_root_group_id & get_object_groups. +Tue Nov 18 2003 + mikeb - Added more tests to the test suite. Fixed up a couple SQL syntax errors in del_group(). +Fri Nov 14 2003 + mikeb - Fixed minor bug in get_group_objects() to do with the SQL query, and table prefixes. + dcech - improved count_all function and documentation + dcech - updated Stress Test & added script to do random ACL checks + dcech - fixed bug where debug_db was called after RollBackTrans +Wed Nov 12 2003 + mikeb - More MPTT fixes from Dan + mikeb - is_conflicting_acl() patch from Dan also. +Tue Nov 11 2003 + mikeb - Applied MPTT (different group tree format) patch from Dan Cech <dc...@ph...> + mikeb - Minor cleanup of the above patch. + mikeb - FIxed a couple minor bugs with add_group_object() and del_object() relating to the MPTT patch. +Wed Nov 05 2003 + - Fixed issue where ARO and AXO groups use the same sequence. Not really a bug, but shouldn't + be the case. Thanks to Dan Cech <dc...@ph...> +Wed Oct 29 2003 + - Fixed bug in schema.xml where group_id was missing from a unique index. +Tue Oct 21 2003 + - Group select boxes represent the tree structure much better. Purely cosmetic change. Thanks to Dan Cech <dc...@ph...> +Wed Oct 08 2003 + - Released 3.2.2 + - Fixed bug in acl_list.php where the filter wasn't being passed between pages. Thanks to Dan Cech <dc...@ph...> + - Greatly improved the speed of acl_list.php. Thanks to Dan Cech <dc...@ph...> +Sun Oct 05 2003 + - Fix for major bug in AXOs, if you don't specify AXO values in acl_check(), it could + still match ACLs that have AXO groups assigned to them. Discovered by Dan Cech <dc...@ph...>. +Sun Oct 03 2003 + - Released 3.2.1 +Mon Sep 29 2003 + - Fixed possible bug with re-using database connection objects. + - Fixed bug in assign_group.tpl where it was hard coded to reference AROs. + - Fixed major bug with table prefixes and del_object() function, as well as sequences. Thanks to Ian Eure <ie...@de...> for reporting this. + - Fixed minor bug in generating javascript arrays with values containing quotes. Bug found by: Martino Piccinato <m.p...@ne...> +Sat Sep 20 2003 + - Released 3.2.0-final. + - Upgraded ADODB to 3.90. +Sat Sep 06 2003 + - Fixed minor bug when assigning objects to groups. Thanks Jos Vanlanduyt <jos...@hi...> for pointing this out. +Mon Aug 25 2003 + - Added SOAP server and clients for PHP, Perl, and Python. + - Updated README regarding upgrading and PostgreSQL. + - Released phpGACL v3.2.0b2 +Thu Aug 21 2003 + - Added Help / About page. + - Fixed up the ACL Sections, to use values instead of IDs for consistency sake + - Upgraded to Smarty 2.5.0 + - Released phpGACL v3.2.0b +Mon Aug 18 2003 + - Merged table prefix patch from Ben Margolin (be...@pr...), did some minor clean-ups/fixes. + - Upgraded to ADODB 3.72 +Wed Aug 13 2003 + - Decreased column lengths to varchar(240) so MySQL can index multiple columns. Thanks to Ben Margolin (be...@pr...) + - Fixed bug in add_object(), it was selecting from a non-existent table. Thanks to Ben Margolin (be...@pr...) +Tue July 08 2003 + - Create a new setup.php from scratch using ADODB XML-Schema. This should greatly ease table creation on many different databases. + - Modified ADODB XML-Schema to support all types of indexes. Submitted patch to Richard Tango-Lowy <ri...@ar...> + +Mon July 07 2003 + - add_object() now returns TRUE if the object is already in the database. + +Fri July 04 2003 + - Updated table schema for the acl table. Added the acl_section table, and the phpgacl table. + - Added ACL sections. The purpose of these is like all other sections, to simply classify objects. + For example, you may want to differentiate between automatically created ACLs (System ACLs) and + manually created ACLs (User ACLs). As some installations may have several thousand automatically created + ACLs, its nice to filter these out. + - add_group_object() now returns TRUE if the object is already assigned to the group. + +Tue July 01 2003 + - Fixed security bug that could allow someone to see your database password. + +Mon June 16 2003 + - Added acl_query_array() to aid in running an acl_check() over a large amount of AROs, returning section_value, values + of those that return true. Especially useful with get_group_objects(); + +Thu June 12 2003 + - Added "ACLs" link to the group page, so you easily show all ACLs a specific group is assigned too. + - Added "ACLs" link to the group assign page, so you easily show all ACLs a specific ARO/AXO is assigned too. + - modified return array format for get_group_objects() and added functionality to return objects in child groups as well. + +Wed June 11 2003 + - Object searching now supports a newline delimited list of names/values. + +Sun June 8 2003 + - Fixed more warnings. + +Wed May 28 2003 + - More minor warning fixes. + - Moved the manual to the documentation directory. + - Case insensitive object searching when assigning to groups. + +Mon May 26 2003 + - Fixed many more PHP warnings all over. + - Added example.php + - Upgraded Smarty to v2.5 + - Upgraded ADODB to v3.5. Added line to set FETCH_MODE on a per connection basis. + +Wed May 21 2003 + - Fixed add_acl() for AXOs, as it was previously completely broken. + +Mon May 19 2003 + - Fixed ACL List filtering so it returns all ACL rows, not just the ones matching the LIKE query. + +Fri May 16 2003 + - Fixed a few PHP warnings gacl.class.php + - Removed an else condition from an if statement that didn't do anything anyways. + +Sun Mar 09 2003 + - Fixed small bug in API function get_object_id() where it referenced the $name variable, + but $name was never used. If the function was used properly, this shouldn't have affected anything. + Thanks to: Harald Fielker <fi...@in...> for pointing this out. + +Sat Mar 01 2003 + - Fixed up the layers with AXO show/hide functionality. Usable, but still needs improvement. + +Thu Feb 27 2003 + - Attempted to add javascript show/hide to the AXO section of the acl_admin. + +Tue Feb 25 2003 + - Fixed invalid DB reference in acl_get_groups(); Thanks to Gianluca Faieta <gf...@in...> for the patch. + +Thu Feb 20 2003 + - Fixed bug in get_group_objects() that caused it to return the query record set, not the data itself. Thanks to Thomas <tst...@pe...> for submitting a patch. + - Fixed bug in del_group(), as it neglected to remove the object mapping. Thanks to Thomas <tst...@pe...> for pointing this out. + +Tue Feb 18 2003 + - Added 'force_cache_expire' option, so the cache is automaticalled expired when ACL/Group modifications take place. + This should allow the cache_expire_time to be greatly increased (86400?) and still maintain instance updates. + - Removed un-needed table joins in search_acl() resulting in a large performance increase. + +Mon Feb 17 2003 + - Added "limit" to ARO select query in group_assign.php + +Fri Feb 14 2003 + - Tweeked consolidate_edit_acl() to better consolidate ACLs in the expected manor. + - Fixed cache ID in acl_get_group_path() so it doesn't contain non-alphanumeric characters. + +Wed Feb 12 2003 + - Fixed bug caused by overzealous array_unique in add_acl() + - Switched acl_query() to return TRUE/FALSE for the 'allow' return value instead of 1/0 + - API group functions didn't manipulate the path_to_root mapping when reparenting or deleting occured. + +Tue Feb 04 2003 + - Fixed bug in edit_group(), added more error checking. + - Added object searching to the assign group pages. + - Moved all templates to $smarty_template_dir/phpgacl/ to better integrate with existing smarty installations. + - Fixed recursion in format_groups() so it doesn't use globals anymore. + - Greatly improved performance in sort_groups() (50% improvement) and format_groups() (20%) functions. + +Thu Jan 31 2003 + - Added conflict detection to add_acl(); + +Thu Jan 30 2003 + - Created search_acl() to search for ACLs mapped to specific objects. This should also work for detecting conflicting ACLs. + - Created shift_acl() that basically does the opposite of append_acl(). Remove just the specific objects from the ACL mapping. + +Wed Jan 29 2003 + - Created append_acl() function for simply appending ACO/ARO/ARO Groups/AXO/AXO Groups on to an already existing ACL. + +Mon Jan 28 2003 + - Added ACL searching. + - Added ACL debug page. + - Added sanity checks to add_acl()/edit_acl() to make sure the objects mapped to ACLs actually exist. + - Transactionalized most API functions. + +Fri Jan 24 2003 + - Fixed JS UnSelect button bug for AXO groups. + - Added Object searching to help the admin interface handle an unlimited number of objects. + - Added "max_select_box_items" config option to set the maximum number of items shown in select boxes. + +Tue Jan 14 2003 + - Upgraded ADODB to v3.00 + - Added user definable ACL return values, along with the acl_return_value() function. + - Added ACL notes which serve no other purpose other than to help the administrator keep track of ACL's + - Added paging for large record sets. + +Sun Dec 15 2002 + - Moved to a completely OO structure. + - Config options can now be passed during object creation. $gacl = new gacl($options); + +Sun Dec 01 2002 + - Fixed bug that broke allow and enabled from being changed when editing ACLs. + +Sat Nov 30 2002 + - Merged ERASE feature in to API functions, del_object() and del_object_section() thanks to Martino. + - Changed the acl list page layout + - Changed the acl test page layout + - Added assigned object count to the group admin page. + - Fixed a JS bug that wouldn't allow you to "select" (>>) any objects at all, if one was already selected. + +Sun Nov 17 2002 + - format_groups() function wasn't recursing as efficiently as it could be. Fixed. + - Re-wrote API aro/aco/group specific functions to be generic to help support AXO's. + - Re-wrote aro/aco/group specific admin scripts to be generic to help support AXO's. + - Added AXO support to acl_admin.php. + - Updated gacl.inc.php to support AXO's. + +Mon Nov 11 2002 + - Changed the ordering of the main acl_query() SQL query. It wasn't properly preferring the deepest groups ACLs. - Thanks to Mauro + for spotting this one and helping me track it down. + - Fixed bug that prevented ACO/ARO's with the same 'value' in different sections from being assigned to an ACL. - Thanks to Martino + - Fixed bug that made it seem like assigning a single ARO to a group really added all AROs with the same value to that group. - Thanks to Martino + - Fixed bug causing virtual subtree'ing to only traverse 2 levels of the tree. - Thanks to Martino + - Used dirname(__FILE__) to remove the need for users to manually set the root path in config.inc.php. + +Wed Oct 23 2002 + - Switched away from ID's in favor of VALUES for most functions, including acl_check(). Broke all backwards compatibility. + - Modified DB Schema to reflect above. + - When ARO/ACO values are changed, the API will modify said values in all tables. + - Added a variable for phpGACL's current path. + +Wed Oct 09 2002 + - Added "hidden" flags to relavent API functions + - Added Oracle 8i schema to setup.php + - Changed group "level" table column name to "tree_level", as the old name "level" was a reserved word in some db's. + MySQL: ALTER TABLE `groups_path` CHANGE `level` `tree_level` INT(12) DEFAULT '0' NOT NULL + - Modified a few of the queries to be more portable, specifically for Oracle's sake. + - Added a FAQ entry regarding individualized item permissions. + +Wed Sep 25 2002 + - Added multi-layer ACO checking to ACL_QUERY() + - Removed multi-layer ACO checking in favor of "dual" acl checking. ie: + If you want to set ACL's on a contact list. Create ACO's for each Contact in the list. + and create more generic ACO's for things like "View - Contacts", "Edit - Contacts". + Then simply create an ACL with ACO's "View - Contacts" AND "Contact ID: 15" + Then if ( acl_check("View - Contacts", "John Doe") AND acl_check("Contact ID: 15", "John Doe")) + Very simple, and should be just as fast, or faster then adding more bloat to the database. + - Added "hidden" flag to ACO, ACO Sections, ARO, and ARO sections. Added: trunk/0.1/gacl/COPYING.lib =================================================================== --- trunk/0.1/gacl/COPYING.lib (rev 0) +++ trunk/0.1/gacl/COPYING.lib 2009-02-23 16:23:36 UTC (rev 11) @@ -0,0 +1,458 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose per... [truncated message content] |
From: <cra...@us...> - 2009-02-20 05:54:01
|
Revision: 10 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=10&view=rev Author: crazedsanity Date: 2009-02-20 05:53:54 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Moving more files around & renaming appropriately... converting blogger to be a CMS may be a bit more complicated than I initially thought. Modified Paths: -------------- trunk/0.1/abstract/cs_cms.abstract.class.php trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php Added Paths: ----------- trunk/0.1/abstract/cs_location.class.php trunk/0.1/abstract/cs_permission.class.php Removed Paths: ------------- trunk/0.1/cs_location.class.php trunk/0.1/cs_permission.class.php Modified: trunk/0.1/abstract/cs_cms.abstract.class.php =================================================================== --- trunk/0.1/abstract/cs_cms.abstract.class.php 2009-02-20 05:48:19 UTC (rev 9) +++ trunk/0.1/abstract/cs_cms.abstract.class.php 2009-02-20 05:53:54 UTC (rev 10) @@ -1,8 +1,8 @@ <?php -require_once(dirname(__FILE__) .'/csb_dataLayer.abstract.class.php'); +require_once(dirname(__FILE__) .'/cs_cmsDataLayer.abstract.class.php'); -class csb_blogAbstract extends csb_dataLayerAbstract { +class cs_cmsAbstract extends cs_cmsDataLayerAbstract { /** Internal name of blog (looks like a permalink) */ protected $blogName; Modified: trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php =================================================================== --- trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php 2009-02-20 05:48:19 UTC (rev 9) +++ trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php 2009-02-20 05:53:54 UTC (rev 10) @@ -3,11 +3,11 @@ require_once(dirname(__FILE__) .'/../../cs-content/cs_phpDB.class.php'); require_once(dirname(__FILE__) .'/../../cs-content/cs_globalFunctions.class.php'); require_once(dirname(__FILE__) .'/../../cs-versionparse/cs_version.abstract.class.php'); -require_once(dirname(__FILE__) .'/../csb_location.class.php'); -require_once(dirname(__FILE__) .'/../csb_permission.class.php'); +require_once(dirname(__FILE__) .'/cs_location.class.php'); +require_once(dirname(__FILE__) .'/cs_permission.class.php'); -abstract class csb_dataLayerAbstract extends cs_versionAbstract { +abstract class cs_cmsDataLayerAbstract extends cs_versionAbstract { /** */ protected $gfObj; Copied: trunk/0.1/abstract/cs_location.class.php (from rev 8, trunk/0.1/cs_location.class.php) =================================================================== --- trunk/0.1/abstract/cs_location.class.php (rev 0) +++ trunk/0.1/abstract/cs_location.class.php 2009-02-20 05:53:54 UTC (rev 10) @@ -0,0 +1,128 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); + +class csb_location extends csb_dataLayerAbstract { + + //------------------------------------------------------------------------- + public function __construct(array $dbParams=null) { + parent::__construct($dbParams); + + $this->gfObj = new cs_globalFunctions(); + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function add_location($location) { + if(is_string($location) && strlen($location) > 3) { + if(!preg_match('/^\//', $location)) { + $location = "/". $location; + } + $location = $this->fix_location($location); + $location = $this->gfObj->cleanString($location, "sql_insert"); + $sql = "INSERT INTO csblog_location_table (location) " . + "VALUES ('". $location ."')"; + + try { + $numrows = $this->run_sql($sql); + + + if($numrows == 1) { + //okay, retrieve the id inserted. + $retval = $this->db->get_currval('csblog_location_table_location_id_seq'); + } + else { + throw new exception(__METHOD__ .": failed to create location (". $location ."), " . + "numrows=(". $numrows .")"); + } + } + catch(exception $e) { + cs_debug_backtrace($this->gfObj->debugPrintOpt); + throw new exception(__METHOD__ .": failed to create location (". $location .")... DETAILS::: ". $e->getMessage()); + } + } + else { + throw new exception(__METHOD__ .": invalid location (". $location .")"); + } + + return($retval); + }//end add_location() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_location_id($location) { + if(is_string($location) && strlen($location) > 3) { + $location = $this->fix_location($location); + $location = $this->gfObj->cleanString($location, "sql_insert"); + $sql = "SELECT location_id FROM csblog_location_table " . + "WHERE location='". $location ."'"; + $numrows = $this->run_sql($sql, false); + + + if($numrows == 0) { + $retval = false; + } + elseif($numrows == 1) { + $retval = $this->db->farray(); + $retval = $retval[0]; + } + else { + throw new exception(__METHOD__ .": failed to retrieve location (". $location ."), " . + "invalid numrows (". $numrows .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid location (". $location .")"); + } + + return($retval); + }//end get_location_id() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function fix_location($location) { + if(strlen($location)) { + $retval = $location; + if(!preg_match("/^\//", $retval)) { + $retval = "/". $retval; + } + $retval = preg_replace("/[^A-Za-z0-9\/_-]/", "", $retval); + $retval = preg_replace("/(\/){2,}/", "/", $retval); + $retval = preg_replace("/\/$/", "", $retval); + } + else { + throw new exception(__METHOD__ .": no valid location (". $location .")"); + } + + return($retval); + }//end fix_location() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_locations() { + $sql = "SELECT location_id, location FROM csblog_location_table ORDER BY location_id"; + $numrows = $this->run_sql($sql,false); + + if($numrows > 0) { + $retval = $this->db->farray_nvp('location_id', 'location'); + } + else { + throw new exception(__METHOD__ .": no records found (". $numrows .")"); + } + + return($retval); + }//end get_locations() + //------------------------------------------------------------------------- + + +} +?> \ No newline at end of file Copied: trunk/0.1/abstract/cs_permission.class.php (from rev 8, trunk/0.1/cs_permission.class.php) =================================================================== --- trunk/0.1/abstract/cs_permission.class.php (rev 0) +++ trunk/0.1/abstract/cs_permission.class.php 2009-02-20 05:53:54 UTC (rev 10) @@ -0,0 +1,146 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); +require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); + + +//TODO: this should extend csb_blogAbstract{} + +class csb_permission extends csb_dataLayerAbstract { + + //------------------------------------------------------------------------- + public function __construct(array $dbParams=null) { + parent::__construct($dbParams); + + $this->gfObj = new cs_globalFunctions(); + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function add_permission($blogId, $toUser) { + if(!is_numeric($toUser) && is_string($toUser) && strlen($toUser)) { + $toUser = $this->get_uid($toUser); + } + + if(is_numeric($toUser) && $toUser > 0 && is_numeric($blogId) && $blogId > 0) { + $this->db->beginTrans(); + $sql = "INSERT INTO csblog_permission_table (blog_id, uid) VALUES " . + "(". $blogId .", ". $toUser .")"; + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $this->db->commitTrans(); + $retval = $this->db->get_currval('csblog_permission_table_permission_id_seq'); + } + else { + $this->db->rollbackTrans(); + throw new exception(__METHOD__ .": invalid numrows (". $numrows .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid uid (". $toUser .") or blogId (". $blogId .")"); + } + + return($retval); + }//end add_permission() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function can_access_blog($blogId, $uid) { + if(strlen($blogId) && (is_numeric($uid) || strlen($uid))) { + + try { + if(!is_numeric($uid)) { + $uid = $this->get_uid($uid); + } + if(!is_numeric($blogId)) { + //TODO: if this extended csb_blogAbstract{}, call get_blog_data_by_name() to make this easier. + $blogData = $this->get_blogs(array('blog_name'=>$blogId)); + if(count($blogData) == 1) { + $keys = array_keys($blogData); + $blogId = $keys[0]; + } + else { + throw new exception(__METHOD__ .": too many records found for blog name (". $blogId .")"); + } + } + //if this call doesn't cause an exception, we're good to go (add extra logic anyway) + $blogData = $this->get_blogs(array('blog_id'=>$blogId, 'uid'=>$uid)); + if(is_array($blogData) && count($blogData) == 1 && $blogData[$blogId]['uid'] == $uid) { + $retval = true; + } + else { + $retval = false; + } + } + catch(exception $e) { + //an exception means there was no record; check the permissions table. + $sql = "SELECT * FROM csblog_permission_table WHERE blog_id=". $blogId . + " AND uid=". $uid; + + $numrows = $this->run_sql($sql,false); + + $retval = false; + if($numrows == 1) { + $retval = true; + } + elseif($numrows > 1 || $numrows < 0) { + throw new exception(__METHOD__ .": invalid data returned, numrows=(". $numrows .")"); + } + } + } + else { + //they gave invalid data; default to no access. + $retval = false; + } + + return($retval); + + }//end can_access_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function remove_permission($blogId, $fromUser) { + if(!is_numeric($fromUser) && is_string($fromUser) && strlen($fromUser)) { + $fromUser = $this->get_uid($fromUser); + } + + if(is_numeric($fromUser) && $fromUser > 0 && is_numeric($blogId) && $blogId > 0) { + $sql = "DELETE FROM csblog_permission_table WHERE blog_id=". $blogId + ." AND uid=". $fromUser; + + try { + $this->db->beginTrans(); + $numrows = $this->run_sql($sql, false); + + if($numrows == 0 || $numrows == 1) { + $this->db->commitTrans(); + $retval = $numrows; + } + else { + $this->db->rollbackTrans(); + throw new exception(__METHOD__ .": deleted too many records (". $numrows .")"); + } + } + catch(exception $e) { + throw new exception(__METHOD__ .": unable to delete permission... DETAILS::: ". $e->getMessage()); + } + } + else { + throw new exception(__METHOD__ .": invalid uid (". $fromUser .") or blogId (". $blogId .")"); + } + + return($retval); + }//end remove_permission() + //------------------------------------------------------------------------- + + +} +?> \ No newline at end of file Deleted: trunk/0.1/cs_location.class.php =================================================================== --- trunk/0.1/cs_location.class.php 2009-02-20 05:48:19 UTC (rev 9) +++ trunk/0.1/cs_location.class.php 2009-02-20 05:53:54 UTC (rev 10) @@ -1,128 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); - -class csb_location extends csb_dataLayerAbstract { - - //------------------------------------------------------------------------- - public function __construct(array $dbParams=null) { - parent::__construct($dbParams); - - $this->gfObj = new cs_globalFunctions(); - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function add_location($location) { - if(is_string($location) && strlen($location) > 3) { - if(!preg_match('/^\//', $location)) { - $location = "/". $location; - } - $location = $this->fix_location($location); - $location = $this->gfObj->cleanString($location, "sql_insert"); - $sql = "INSERT INTO csblog_location_table (location) " . - "VALUES ('". $location ."')"; - - try { - $numrows = $this->run_sql($sql); - - - if($numrows == 1) { - //okay, retrieve the id inserted. - $retval = $this->db->get_currval('csblog_location_table_location_id_seq'); - } - else { - throw new exception(__METHOD__ .": failed to create location (". $location ."), " . - "numrows=(". $numrows .")"); - } - } - catch(exception $e) { - cs_debug_backtrace($this->gfObj->debugPrintOpt); - throw new exception(__METHOD__ .": failed to create location (". $location .")... DETAILS::: ". $e->getMessage()); - } - } - else { - throw new exception(__METHOD__ .": invalid location (". $location .")"); - } - - return($retval); - }//end add_location() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_location_id($location) { - if(is_string($location) && strlen($location) > 3) { - $location = $this->fix_location($location); - $location = $this->gfObj->cleanString($location, "sql_insert"); - $sql = "SELECT location_id FROM csblog_location_table " . - "WHERE location='". $location ."'"; - $numrows = $this->run_sql($sql, false); - - - if($numrows == 0) { - $retval = false; - } - elseif($numrows == 1) { - $retval = $this->db->farray(); - $retval = $retval[0]; - } - else { - throw new exception(__METHOD__ .": failed to retrieve location (". $location ."), " . - "invalid numrows (". $numrows .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid location (". $location .")"); - } - - return($retval); - }//end get_location_id() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function fix_location($location) { - if(strlen($location)) { - $retval = $location; - if(!preg_match("/^\//", $retval)) { - $retval = "/". $retval; - } - $retval = preg_replace("/[^A-Za-z0-9\/_-]/", "", $retval); - $retval = preg_replace("/(\/){2,}/", "/", $retval); - $retval = preg_replace("/\/$/", "", $retval); - } - else { - throw new exception(__METHOD__ .": no valid location (". $location .")"); - } - - return($retval); - }//end fix_location() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_locations() { - $sql = "SELECT location_id, location FROM csblog_location_table ORDER BY location_id"; - $numrows = $this->run_sql($sql,false); - - if($numrows > 0) { - $retval = $this->db->farray_nvp('location_id', 'location'); - } - else { - throw new exception(__METHOD__ .": no records found (". $numrows .")"); - } - - return($retval); - }//end get_locations() - //------------------------------------------------------------------------- - - -} -?> \ No newline at end of file Deleted: trunk/0.1/cs_permission.class.php =================================================================== --- trunk/0.1/cs_permission.class.php 2009-02-20 05:48:19 UTC (rev 9) +++ trunk/0.1/cs_permission.class.php 2009-02-20 05:53:54 UTC (rev 10) @@ -1,146 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); -require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); - - -//TODO: this should extend csb_blogAbstract{} - -class csb_permission extends csb_dataLayerAbstract { - - //------------------------------------------------------------------------- - public function __construct(array $dbParams=null) { - parent::__construct($dbParams); - - $this->gfObj = new cs_globalFunctions(); - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function add_permission($blogId, $toUser) { - if(!is_numeric($toUser) && is_string($toUser) && strlen($toUser)) { - $toUser = $this->get_uid($toUser); - } - - if(is_numeric($toUser) && $toUser > 0 && is_numeric($blogId) && $blogId > 0) { - $this->db->beginTrans(); - $sql = "INSERT INTO csblog_permission_table (blog_id, uid) VALUES " . - "(". $blogId .", ". $toUser .")"; - $numrows = $this->run_sql($sql); - - if($numrows == 1) { - $this->db->commitTrans(); - $retval = $this->db->get_currval('csblog_permission_table_permission_id_seq'); - } - else { - $this->db->rollbackTrans(); - throw new exception(__METHOD__ .": invalid numrows (". $numrows .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid uid (". $toUser .") or blogId (". $blogId .")"); - } - - return($retval); - }//end add_permission() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function can_access_blog($blogId, $uid) { - if(strlen($blogId) && (is_numeric($uid) || strlen($uid))) { - - try { - if(!is_numeric($uid)) { - $uid = $this->get_uid($uid); - } - if(!is_numeric($blogId)) { - //TODO: if this extended csb_blogAbstract{}, call get_blog_data_by_name() to make this easier. - $blogData = $this->get_blogs(array('blog_name'=>$blogId)); - if(count($blogData) == 1) { - $keys = array_keys($blogData); - $blogId = $keys[0]; - } - else { - throw new exception(__METHOD__ .": too many records found for blog name (". $blogId .")"); - } - } - //if this call doesn't cause an exception, we're good to go (add extra logic anyway) - $blogData = $this->get_blogs(array('blog_id'=>$blogId, 'uid'=>$uid)); - if(is_array($blogData) && count($blogData) == 1 && $blogData[$blogId]['uid'] == $uid) { - $retval = true; - } - else { - $retval = false; - } - } - catch(exception $e) { - //an exception means there was no record; check the permissions table. - $sql = "SELECT * FROM csblog_permission_table WHERE blog_id=". $blogId . - " AND uid=". $uid; - - $numrows = $this->run_sql($sql,false); - - $retval = false; - if($numrows == 1) { - $retval = true; - } - elseif($numrows > 1 || $numrows < 0) { - throw new exception(__METHOD__ .": invalid data returned, numrows=(". $numrows .")"); - } - } - } - else { - //they gave invalid data; default to no access. - $retval = false; - } - - return($retval); - - }//end can_access_blog() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function remove_permission($blogId, $fromUser) { - if(!is_numeric($fromUser) && is_string($fromUser) && strlen($fromUser)) { - $fromUser = $this->get_uid($fromUser); - } - - if(is_numeric($fromUser) && $fromUser > 0 && is_numeric($blogId) && $blogId > 0) { - $sql = "DELETE FROM csblog_permission_table WHERE blog_id=". $blogId - ." AND uid=". $fromUser; - - try { - $this->db->beginTrans(); - $numrows = $this->run_sql($sql, false); - - if($numrows == 0 || $numrows == 1) { - $this->db->commitTrans(); - $retval = $numrows; - } - else { - $this->db->rollbackTrans(); - throw new exception(__METHOD__ .": deleted too many records (". $numrows .")"); - } - } - catch(exception $e) { - throw new exception(__METHOD__ .": unable to delete permission... DETAILS::: ". $e->getMessage()); - } - } - else { - throw new exception(__METHOD__ .": invalid uid (". $fromUser .") or blogId (". $blogId .")"); - } - - return($retval); - }//end remove_permission() - //------------------------------------------------------------------------- - - -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-20 05:48:31
|
Revision: 9 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=9&view=rev Author: crazedsanity Date: 2009-02-20 05:48:19 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Renaming abstract classes... Added Paths: ----------- trunk/0.1/abstract/cs_cms.abstract.class.php trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php Removed Paths: ------------- trunk/0.1/abstract/csb_blog.abstract.class.php trunk/0.1/abstract/csb_dataLayer.abstract.class.php Copied: trunk/0.1/abstract/cs_cms.abstract.class.php (from rev 5, trunk/0.1/abstract/csb_blog.abstract.class.php) =================================================================== --- trunk/0.1/abstract/cs_cms.abstract.class.php (rev 0) +++ trunk/0.1/abstract/cs_cms.abstract.class.php 2009-02-20 05:48:19 UTC (rev 9) @@ -0,0 +1,456 @@ +<?php + +require_once(dirname(__FILE__) .'/csb_dataLayer.abstract.class.php'); + +class csb_blogAbstract extends csb_dataLayerAbstract { + + /** Internal name of blog (looks like a permalink) */ + protected $blogName; + + /** Displayable name of blog */ + protected $blogDisplayName; + + /** Numeric ID of blog */ + protected $blogId=false; + + /** Location of blog */ + protected $blogLocation; + + //------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $blogName (str) name of blog (NOT the display name) + * @param $dbType (str) Type of database (pgsql/mysql/sqlite) + * @param $dbParams (array) connection options for database + * + * @return exception throws an exception on error. + */ + public function __construct(array $dbParams=null) { + + //TODO: put these in the constructor args, or require CONSTANTS. + parent::__construct($dbParams); + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Initializes information about the selected blog. + * + * @param $blogName (str) name of blog (NOT the display name) + */ + public function initialize_locals($blogName) { + + if(!is_numeric($this->blogId)) { + $data = $this->get_blog_data_by_name($blogName); + + $var2index = array( + 'blogDisplayName' => 'blog_display_name', + 'blogName' => 'blog_name', + 'blogId' => 'blog_id', + 'blogLocation' => 'location' + ); + + foreach($var2index as $var=>$index) { + if(isset($data[$index]) && strlen($data[$index])) { + $this->$var = $data[$index]; + } + else { + throw new exception(__METHOD__ .": var ". $var ." not set from index ". $index .", no data (". $data[$index] .")"); + } + } + } + else { + throw new exception(__METHOD__ .": already initialized"); + } + }//end initialize_locals() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieves protected (or private?) internal var values + * + * @param $var (str) name of internal var to retrieve + * + * @return exception throws an exception if named var doesn't exist. + */ + public function get_internal_var($var) { + if(isset($this->$var)) { + $retval = $this->$var; + } + else { + throw new exception(__METHOD__ .": invalid var name (". $var .")"); + } + + return($retval); + }//end get_internal_var() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function is_initialized() { + $retval = false; + if(is_numeric($this->blogId)) { + $retval = true; + } + return($retval); + }//end is_initialized() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Creates a "permalink" just from title (does NOT include blog location): + * lowercases, strips special characters, uses "_" in place of spaces and + * special characters (NEVER creates more than one "_" in a row) + * + * @param $title (str) string to create permalink from. + * + * @return exception throws exception on error + * @return (string) permalink + */ + public function create_permalink_from_title($title) { + if(is_string($title) && strlen($title) >= CSBLOG_TITLE_MINLEN) { + + $permalink = strtolower($title); + $permalink = preg_replace('/!/', '', $permalink); + $permalink = preg_replace('/&\+/', '-', $permalink); + $permalink = preg_replace('/\'/', '', $permalink); + $permalink = preg_replace("/[^a-zA-Z0-9_]/", "_", $permalink); + + if(!strlen($permalink)) { + throw new exception(__METHOD__ .": invalid filename (". $permalink .") from title=(". $title .")"); + } + + //consolidate multiple underscores... (" . . ." becomes "______", after this becomes just "_") + $permalink = preg_replace('/__*/', '_', $permalink); + } + else { + throw new exception(__METHOD__ .": invalid title (". $title .")"); + } + + return($permalink); + }//end create_permalink_from_title() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Encodes content using base64 + * + * @param $content (str) content to encode + * + * @return (string) encoded content. + */ + public function encode_content($content) { + //make it base64 data, so it is easy to insert. + $retval = base64_encode($content); + return($retval); + }//end encode_content() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Decoded content (reverse of encode_content()) + * + * @param $content (str) Encoded content to decode + * + * @return (string) Decoded content. + */ + public function decode_content($content) { + $retval = base64_decode($content); + return($retval); + }//end decode_content() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieves all data about a blog (the main entry only) by its name. + * + * @param $blogName (str) name of blog (displayable or proper) + * + * @return exception throws exceptions on error + * @return (array) array of data about the blog. + */ + public function get_blog_data_by_name($blogName) { + if(strlen($blogName) > 3) { + $data = $this->get_blogs(array('b.blog_name'=>$blogName), 'blog_id'); + + if(count($data) == 1) { + $keys = array_keys($data); + $retval = $data[$keys[0]]; + } + else { + throw new exception(__METHOD__ .": too many records returned (". count($data) .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid blog name (". $blogName .")"); + } + + return($retval); + }//end get_blog_data_by_name() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Same as get_blog_data_by_name(), but use blog_id to find it. + * + * @param $blogId (int) blog_id to retrieve info for. + * + * @return exception throws exception on error + * @return (array) array of data about the blog. + */ + public function get_blog_data_by_id($blogId) { + + if(is_numeric($blogId) && $blogId > 0) { + $data = $this->get_blogs(array('blog_id'=>$blogId), 'blog_id'); + if(count($data) == 1) { + $keys = array_keys($data); + $retval = $data[$keys[0]]; + } + else { + throw new exception(__METHOD__ .": invalid number of records returned (". count($data) .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid blog id (". $blogId .")"); + } + + return($retval); + }//end get_blog_data_by_id() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Determines if there is one or more matching permalinks for the given + * blog; duplicates are given a suffix of "-N" (where "N" is the number of + * matching entries; first dup is given "-1", and so on). + * + * @param $blogId (int) blog_id for the permalink + * @param $permaLink (str) permalink to check + * + * @return exception thrown on error. + * @return + */ + public function check_permalink($blogId, $permalink) { + if(is_string($permalink) && strlen($permalink) >= CSBLOG_TITLE_MINLEN && is_numeric($blogId) && $blogId > 0) { + #if($permalink == $this->create_permalink_from_title($permalink)) { + $permalink = $this->create_permalink_from_title($permalink); + $sql = "SELECT * FROM csblog_entry_table WHERE blog_id=". $blogId + ." AND permalink='". $permalink ."' OR permalink LIKE '". $permalink ."-%'"; + + $numrows = $this->run_sql($sql, false); + + if($numrows >= 0) { + if($numrows >= 1) { + //got a record, give 'em the data back. + $retval = $permalink ."-". $numrows; + } + elseif($numrows == 0) { + $retval = $permalink; + } + else { + throw new exception(__METHOD__ .": unknown error, numrows=(". $numrows ."), dberror"); + } + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .") or dberror"); + } + } + else { + throw new exception(__METHOD__ .": invalid permalink (". $permalink .") or blog_id (". $blogId .")"); + } + + return($retval); + }//end check_permalink() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function get_age_hype($timestamp, $addBrackets=FALSE) { + if(strlen($timestamp >= 9)) { + if(!is_numeric($timestamp)) { + $timestamp = strtotime($timestamp); + } + + $age = time() - $timestamp; + switch($age) { + case ($age <= 1800): { + $extraText = '<font color="red"><b>Ink\'s still WET!</b></font>'; + } break; + + case ($age <= 3600): { + //modified less than an hour ago! + $extraText = '<font color="red"><b>Hot off the press!</b></font>'; + } break; + + case ($age <= 86400): { + //modified less than 24 hours ago. + $extraText = '<font color="red"><b>New!</b></font>'; + } break; + + case ($age <= 604800): { + //modified this week. + $extraText = '<font color="red">Less than a week old</font>'; + } break; + + case ($age <= 2592000): { + //modified this month. + $extraText = '<b>Less than a month old</b>'; + } break; + + case ($age <= 5184000): { + //modified in the last 2 months + $extraText = '<b>Updated last month</b>'; + } break; + + case ($age <= 7776000): { + $extraText = '<i>Updated 3 months ago</i>'; + } break; + + case ($age <= 10368000): { + $extraText = '<i>Updated 4 months ago</i>'; + } break; + + case ($age <= 12960000): { + $extraText = '<i>Updated 5 months ago</i>'; + } break; + + case ($age <= 15552000): { + $extraText = '<i>Updated in the last 6 months</i>'; + } break; + + default: { + $extraText = '<i>pretty old</i>'; + } + } + + if(strlen($extraText) && $addBrackets) { + $extraText = '['. $extraText .']'; + } + } + else { + throw new exception(__METHOD__ .": invalid timestamp (". $timestamp .")"); + } + + return($extraText); + }//end get_age_hype() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_most_recent_blog() { + $retval = $this->get_recent_blogs(1); + return($retval); + }//end get_most_recent_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_recent_blogs($limit=5, $offset=0, $includeDrafts=false) { + if(is_numeric($this->blogId)) { + if(is_numeric($limit) && $limit > 0) { + if(is_numeric($offset) && $offset >= 0) { + $criteria = array( + 'blog_id' => $this->blogId, + 'is_draft' => 'f' + ); + if($includeDrafts === true) { + unset($criteria['is_draft']); + } + $retval = $this->get_blog_entries($criteria, 'post_timestamp DESC', $limit, $offset); + } + else { + throw new exception(__METHOD__ .": invalid offset (". $offset .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid limit (". $limit .")"); + } + } + else { + throw new exception(__METHOD__ .": blogId not set"); + } + + return($retval); + }//end get_recent_blogs() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function get_full_permalink($permalink) { + if(!strlen($this->blogLocation)) { + throw new exception(__METHOD__ .": missing internal blogLocation (". $this->blogLocation .")"); + } + elseif(!strlen($this->blogName)) { + throw new exception(__METHOD__ .": missing internal blogName (". $this->blogName .")"); + } + elseif(!strlen($permalink)) { + throw new exception(__METHOD__ .": invalid/missing permalink (". $permalink .")"); + } + else { + $retval = $this->blogLocation .'/'. $this->blogName .'/'. $permalink; + } + + return($retval); + }//end get_full_permalink() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function parse_full_permalink($fullPermalink) { + + if(strlen($fullPermalink) && preg_match("/\//", $fullPermalink)) { + $fullPermalink = preg_replace("/^\//", "", $fullPermalink); + $parts = explode("/", $fullPermalink); + + if(count($parts) >= 3) { + $permalink = array_pop($parts); + $blogName = array_pop($parts); + $location = "/". $this->gfObj->string_from_array($parts, NULL, "/"); + + $retval = array( + 'location' => $location, + 'blogName' => $blogName, + 'permalink' => $permalink + ); + } + else { + throw new exception(__METHOD__ .": not enough parts (i.e. location, blogName, & permalink) in " . + "full permalink (". $fullPermalink .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid or non-full permalink given (". $fullPermalink .")"); + } + + return($retval); + }//end parse_full_permalink() + //------------------------------------------------------------------------- + + + +}// end blog{} +?> Property changes on: trunk/0.1/abstract/cs_cms.abstract.class.php ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php (from rev 5, trunk/0.1/abstract/csb_dataLayer.abstract.class.php) =================================================================== --- trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php (rev 0) +++ trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php 2009-02-20 05:48:19 UTC (rev 9) @@ -0,0 +1,668 @@ +<?php + +require_once(dirname(__FILE__) .'/../../cs-content/cs_phpDB.class.php'); +require_once(dirname(__FILE__) .'/../../cs-content/cs_globalFunctions.class.php'); +require_once(dirname(__FILE__) .'/../../cs-versionparse/cs_version.abstract.class.php'); +require_once(dirname(__FILE__) .'/../csb_location.class.php'); +require_once(dirname(__FILE__) .'/../csb_permission.class.php'); + + +abstract class csb_dataLayerAbstract extends cs_versionAbstract { + + /** */ + protected $gfObj; + + /** */ + private $isConnected=false; + + /** */ + protected $dbParams; + + const DBTYPE='pgsql'; + + //------------------------------------------------------------------------- + /** + * Constructor (must be called from extending class) + * + * @param $dbType (str) type of database to connect to (pgsql/mysql/sqlite) + * @param $dbParams (array) list of connection parameters for selected db. + */ + function __construct(array $dbParams=NULL) { + $this->set_version_file_location(dirname(__FILE__) . '/../VERSION'); + $this->gfObj = new cs_globalFunctions(); + + //check that some required constants exist. + if(!defined('CSBLOG_TITLE_MINLEN')) { + define('CSBLOG_TITLE_MINLEN', 4); + } + + $this->dbParams = $dbParams; + $this->connect_db(); + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function connect_db() { + if($this->isConnected === false) { + if(is_array($this->dbParams)) { + $this->db = new cs_phpDB('pgsql'); + try { + $this->db->connect($this->dbParams); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to connect to database, DETAILS: ". $e->getMessage()); + } + + //NOTE: if the call to "connect()" fails, it should throw an exception. + $this->isConnected=true; + } + else { + //no parameters passed. Try using constants. + + $constantList = array( + 'CSBLOG_DB_HOST' => 'host', + 'CSBLOG_DB_PORT' => 'port', + 'CSBLOG_DB_DBNAME' => 'dbname', + 'CSBLOG_DB_USER' => 'user', + 'CSBLOG_DB_PASSWORD' => 'password' + ); + + $dbParams = array(); + foreach($constantList as $constant=>$index) { + $value = ''; + if(defined($constant)) { + $value = constant($constant); + } + else { + if($index != 'password') { + throw new exception(__METHOD__ .": missing one or more constants for database connectivity (". $constant .")"); + } + } + $dbParams[$index] = $value; + } + $this->db = new cs_phpDB('pgsql'); + try { + $this->db->connect($dbParams); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to connect to database using constants, DETAILS: ". $e->getMessage()); + } + + //NOTE: if the call to "connect()" fails, it should throw an exception. + $this->isConnected = true; + } + } + else { + $this->gfObj->debug_print(__METHOD__ .": already connected"); + } + }//end connect_db() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function run_sql($sql, $exceptionOnNoRows=true) { + //TODO: make EVERYTHING use this method, so it can automatically connect to the database. + if($this->isConnected !== true) { + $this->connect_db(); + } + + if($this->isConnected === true) { + if(is_string($sql) && strlen($sql)) { + + //run the statement & check the output. + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if($exceptionOnNoRows === true && $numrows <= 0 && !strlen($dberror)) { + throw new exception(__METHOD__ .": no rows returned (". $numrows .")"); + } + elseif(is_numeric($numrows) && !strlen($dberror)) { + $retval = $numrows; + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows ."), failed to run SQL... " . + "DBERROR: ". $dberror ."<BR>\nSQL::: ". $sql); + } + + } + else { + throw new exception(__METHOD__ .": no sql to run"); + } + } + else { + throw new exception(__METHOD__ .": database isn't connected"); + } + + return($retval); + }//end run_sql() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Loads data into blank (or existing) database. + * + * @param void (void) none + * + * @return exception throws exception on error + * @return (int) Number of records existing in auth table. + */ + public function run_setup() { + $retval = false; + $this->connect_db(); + $this->db->beginTrans(); + $fs = new cs_fileSystem(dirname(__FILE__) .'/../schema'); + $mySchema = $fs->read(self::DBTYPE .'.schema.sql'); + + $retval = $this->db->exec($mySchema); + + #$internalValues = $this->get_version(true); + #foreach($internalValues as $name=>$value) { + # $sql = "INSERT INTO csblog_internal_data_table (internal_name, internal_value) " . + # "VALUES ('". $name ."', '". $value ."')"; + # $this->run_sql($sql); + #} + + $retval = 1; + $this->db->commitTrans(); + return($retval); + }//end run_setup() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Create a user in the database. This assumes that the blogger is in + * complete control of authentication, so this doesn't work if an existing + * mechanism is already in place. + * + * @param $username (str) username to create + * @param $password (str) unencrypted password for the user + * + * @return exception throws exceptions on error + * @return (int) UID of new user + */ + public function create_user($username, $password) { + + $username = $this->gfObj->cleanString($username, 'email'); + if($username != func_get_arg(0)) { + throw new exception(__METHOD__ .": username contained invalid characters (". $username ." != ". func_get_arg(0) .")"); + } + + $existingUser = $this->get_uid($username); + + if($existingUser === false) { + $encryptedPass = md5($username .'-'. $password); + $sql = 'INSERT INTO cs_authentication_table (username, passwd) VALUES ' . + "('". $username ."', '". $encryptedPass ."')"; + + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $sql = "SELECT currval('cs_authentication_table_uid_seq')"; + + $numrows = $this->run_sql($sql); + if($numrows == 1) { + $data = $this->db->farray(); + $retval = $data[0]; + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .") while retrieving last inserted uid"); + } + } + else { + throw new exception(__METHOD__ .": failed insert (". $numrows ."): "); + } + } + else { + throw new exception(__METHOD__ .": user exists (". $username .")"); + } + + return($retval); + }//end create_user() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieve UID for the given username (i.e. for checking dups) + * + * @param $username (str) username to check + * + * @return exception throws exception on error + * @return false boolean FALSE returned if no user + * @return (int) UID for existing user + */ + public function get_user($username) { + + if(strlen($username) && is_string($username) && !is_numeric($username)) { + $username = $this->gfObj->cleanString($username, 'email'); + if($username != func_get_arg(0)) { + throw new exception(__METHOD__ .": username contained invalid characters (". $username ." != ". func_get_arg(0) .")"); + } + $sql = "SELECT * FROM cs_authentication_table WHERE username='". $username ."'"; + $numrows = $this->run_sql($sql, false); + + if($numrows == 1) { + $retval = $this->db->farray_fieldnames(); + } + elseif($numrows == 0) { + $retval = false; + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid data for username (". $username .")"); + } + + return($retval); + }//end get_user() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_uid($username) { + $data = $this->get_user($username); + if(is_bool($data) && $data === false) { + $retval = $data; + } + else { + if(is_array($data) && isset($data['uid']) && is_numeric($data['uid'])) { + $retval = $data['uid']; + } + else { + throw new exception(__METHOD__ .": failed to locate uid column in return DATA::: ". $this->gfObj->debug_print($data,0)); + } + } + + return($retval); + }//end get_uid() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Creates new blog entry. + * + * @param $blogName (str) Display name of blog. + * @param $owner (str/int) UID of owner (username converted to uid) + * @param $location (str) location of blog + * + * @return exception throws exception on error + * @return (int) Newly created blog_id + */ + function create_blog($blogName, $owner, $location) { + if(!strlen($blogName)) { + throw new exception(__METHOD__ .": invalid blogName (". $blogName .")"); + } + elseif(!strlen($owner)) { + throw new exception(__METHOD__ .": invalid owner (". $owner .")"); + } + + if(!is_numeric($owner)) { + $username = $owner;//for later + $owner = $this->get_uid($owner); + if(!is_numeric($owner) || $owner < 1) { + throw new exception(__METHOD__ .": unable to find UID for user (". $username .")"); + } + } + + //attempt to get/create the location... + $loc = new csb_location($this->dbParams); + $locationId = $loc->get_location_id($location); + if(!is_numeric($locationId) || $locationId < 1) { + //TODO: should we really be creating this automatically? + $locationId = $loc->add_location($location); + } + + $formattedBlogName = $this->create_permalink_from_title($blogName); + $sql = "INSERT INTO csblog_blog_table ". $this->gfObj->string_from_array( + array( + 'blog_display_name' => $blogName, + 'blog_name' => $formattedBlogName, + 'uid' => $owner, + 'location_id' => $locationId + ), + 'insert', + NULL, + 'sql_insert' + ); + + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + //pull the blogId. + $retval = $this->db->get_currval('csblog_blog_table_blog_id_seq'); + + if(is_numeric($retval) && $retval > 0) { + //Initialize locals now, if it hasn't been done yet. + if(defined('CSBLOG_SETUP_PENDING') && !$this->is_initialized()) { + $this->initialize_locals($formattedBlogName); + } + } + else { + throw new exception(__METHOD__ .": new blog_id (". $retval .") is invalid"); + } + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .") returned, ERROR: ". $this->db->errorMsg()); + } + + return($retval); + }//end create_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Create new entry for existing blog. + * + * @param $blogId (int) blog_id to associate entry with. + * @param $authorUid (int) UID of author + * @param $title (str) Title of blog. + * @param $content (str) Contents of blog. + * @param $optionalData (array) optional items to specify (i.e. + * post_timestamp) + * + * @return exception throws an exception on error + * @return (array) Array of data, indexes explain values + */ + public function create_entry($blogId, $authorUid, $title, $content, array $optionalData=NULL) { + + //check to make sure we've got all the proper fields and they're formatted appropriately. + $sqlArr = array(); + $cleanStringArr = array( + 'blog_id' => "integer", + 'author_uid' => "integer", + 'title' => "sql", + 'content' => "sql", + 'permalink' => "email" + ); + if(is_numeric($blogId) && $blogId > 0) { + $sqlArr['blog_id'] = $blogId; + } + else { + throw new exception(__METHOD__ .": invalid data for blogId (". $blogId .")"); + } + if(is_numeric($authorUid) && $authorUid > 0) { + $sqlArr['author_uid'] = $authorUid; + } + else { + throw new exception(__METHOD__ .": invalid data for authorUid (". $authorUid .")"); + } + if(is_string($title) && strlen($title) > CSBLOG_TITLE_MINLEN) { + $sqlArr['title'] = $title; + } + else { + throw new exception(__METHOD__ .": invalid data for title (". $title .")"); + } + + //only allow a few other optional fields (make sure they're the appropriate data type). + if(is_array($optionalData) && count($optionalData)) { + + //Valid optional fields are defined here. + $validOptionalFields = array( + 'post_timestamp' => 'datetime', + 'is_draft' => 'boolean' + ); + + $intersectedArray = array_intersect_key($optionalData, $validOptionalFields); + + if(is_array($intersectedArray) && count($intersectedArray)) { + foreach($intersectedArray as $fieldName => $value) { + if(!isset($sqlArr[$fieldName])) { + $sqlArr[$fieldName] = $value; + $cleanStringArr[$fieldName] = $validOptionalFields[$fieldName]; + } + else { + throw new exception(__METHOD__ .": index (". $fieldName .") already exists"); + } + } + } + } + + + //lets check to see that there is NOT already a blog like this... + $permalink = $this->create_permalink_from_title($title); + $checkLink = $this->check_permalink($blogId, $title); + + if($checkLink != $permalink) { + $permalink = $checkLink; + } + //set some fields that can't be specified... + $sqlArr['permalink'] = $permalink; + $sqlArr['content'] = $this->encode_content($content); + + //build the SQL statement. + $sql = "INSERT INTO csblog_entry_table ". $this->gfObj->string_from_array($sqlArr, 'insert', NULL, $cleanStringArr); + + //run the statement & check the output. + $numrows = $this->run_sql($sql); + + if(is_numeric($numrows) && $numrows == 1) { + $blogData = $this->get_blog_data_by_id($blogId); + $retval = array( + 'entry_id' => $this->db->get_currval('csblog_entry_table_entry_id_seq'), + 'full_permalink' => $this->get_full_permalink($sqlArr['permalink']) + ); + + //one final thing: update the main blog table with the newest post_timestamp. + $this->update_blog_last_post_timestamps(); + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows ."), failed to insert data"); + } + + return($retval); + }//end create_entry) + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieve a blog entry based on the FULL permalink (location included) + * + * @param $fullPermalink (str) Permalink (blog location + permalink) for + * entry. + * + * @return exception throws exception on error + * @return (array) Returns array of data, includes decoded content + */ + public function get_blog_entry($fullPermalink) { + //TODO: have this use get_blog_entries() + //the total permalink length should be at least double the minimum title length to include a path. + if(strlen($fullPermalink) > (CSBLOG_TITLE_MINLEN *2)) { + //now get the permalink separate from the title. + $parts = $this->parse_full_permalink($fullPermalink); + $permalink = $parts['permalink']; + $blogName = $parts['blogName']; + $location = $parts['location']; + + $criteria = array('bl.location'=>$location, 'b.blog_name'=>$blogName,'be.permalink'=>$permalink); + $data = $this->get_blog_entries($criteria,'be.entry_id'); + + if(count($data) == 1) { + $keys = array_keys($data); + $retval = $data[$keys[0]]; + } + elseif(count($data) > 1) { + throw new exception(__METHOD__ .": multiple records returned for same location (". count($data) .")"); + } + else { + throw new exception(__METHOD__ .": invalid number of records (". count($data) .") or dberror"); + } + } + else { + throw new exception(__METHOD__ .": failed to meet length requirement of ". (CSBLOG_TITLE_MINLEN *2)); + } + + return($retval); + }//end get_blog_entry() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_blog_entries(array $criteria, $orderBy, $limit=NULL, $offset=NULL) { + if(!is_array($criteria) || !count($criteria)) { + throw new exception(__METHOD__ .": invalid criteria"); + } + + //TODO: should be specifically limited to blogs that are accessible to current user. + $sql = "SELECT be.*, bl.location, b.blog_display_name, be.post_timestamp::date as date_short, " . + "b.blog_name, a.username FROM csblog_entry_table AS be INNER JOIN " . + "csblog_blog_table AS b ON (be.blog_id=b.blog_id) INNER JOIN " . + "csblog_location_table AS bl ON (b.location_id=bl.location_id) INNER JOIN " . + "cs_authentication_table AS a ON (a.uid=be.author_uid) WHERE "; + + //add stuff to the SQL... + foreach($criteria as $field=>$value) { + if(!preg_match('/^[a-z]{1,}\./', $field)) { + unset($criteria[$field]); + $field = "be.". $field; + $criteria[$field] = $value; + } + } + $sql .= $this->gfObj->string_from_array($criteria, 'select', NULL, 'sql'); + + if(strlen($orderBy)) { + $sql .= " ORDER BY ". $orderBy; + } + + if(is_numeric($limit) && $limit > 0) { + $sql .= " LIMIT ". $limit; + } + if(is_numeric($offset) && $limit > 0) { + $sql .= " OFFSET ". $offset; + } + + $numrows = $this->run_sql($sql); + + $retval = $this->db->farray_fieldnames('entry_id', true, false); + foreach($retval as $entryId=>$data) { + $retval[$entryId]['age_hype'] = $this->get_age_hype($data['post_timestamp']); + $retval[$entryId]['content'] = $this->decode_content($data['content']); + $retval[$entryId]['full_permalink'] = $this->get_full_permalink($data['permalink']); + + //make a formatted post_timestamp index. + $retval[$entryId]['formatted_post_timestamp'] = + strftime('%A, %B %d, %Y %I:%M %p', strtotime($data['post_timestamp'])); + + //format the username... + $retval[$entryId]['formatted_author_name'] = ucwords($data['username']); + + //make "is_draft" a real boolean. + $retval[$entryId]['is_draft'] = $this->gfObj->interpret_bool($data['is_draft']); + } + + return($retval); + }//end get_blog_entries() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_blogs(array $criteria, $orderBy=NULL, $limit=NULL, $offset=NULL) { + if(!is_array($criteria) || !count($criteria)) { + throw new exception(__METHOD__ .": invalid criteria"); + } + + //TODO: should be specifically limited to blogs that are accessible to current user. + $sql = "SELECT b.*, bl.location FROM csblog_blog_table AS b INNER JOIN " . + "csblog_location_table AS bl ON (b.location_id=bl.location_id) WHERE "; + + //add stuff to the SQL... + foreach($criteria as $field=>$value) { + if(!preg_match('/^[a-z]{1,}\./', $field)) { + unset($criteria[$field]); + $field = "b.". $field; + $criteria[$field] = $value; + } + } + $sql .= $this->gfObj->string_from_array($criteria, 'select', NULL, 'sql'); + + if(strlen($orderBy)) { + $sql .= " ORDER BY ". $orderBy; + } + else { + $sql .= " ORDER BY b.blog_id"; + } + + if(is_numeric($limit) && $limit > 0) { + $sql .= " LIMIT ". $limit; + } + if(is_numeric($offset) && $limit > 0) { + $sql .= " OFFSET ". $offset; + } + + $numrows = $this->run_sql($sql); + + $retval = $this->db->farray_fieldnames('blog_id', true, false); + + return($retval); + }//end get_blogs() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function update_blog_data(array $updates) { + $sql = "UPDATE csblog_blog_table SET ". + $this->gfObj->string_from_array($updates, 'update', null, 'sql') . + " WHERE blog_id=". $this->blogId; + + try { + $this->db->beginTrans(); + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $retval = $numrows; + $this->db->commitTrans(); + } + else { + throw new exception(__METHOD__ .": updated invalid number of rows (". $numrows .") - transaction aborted"); + } + } + catch(exception $e) { + $this->db->rollbackTrans(); + throw new exception(__METHOD__ .": failed to update blog (". $numrows .")"); + } + + return($retval); + }//end update_blog_data() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function update_blog_last_post_timestamps() { + $sql = "update csblog_blog_table AS b SET last_post_timestamp=" . + "(SELECT post_timestamp FROM csblog_entry_table WHERE " . + "blog_id=b.blog_id ORDER BY post_timestamp DESC limit 1)"; + + try { + $retval = $this->run_sql($sql); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to update last_post_timestamp for blogs, DETAILS::: ". $e->getMessage()); + } + + return($retval); + }//end update_blog_last_post_timestamps() + //------------------------------------------------------------------------- + + +}//end dataLayerAbstract{} +?> Property changes on: trunk/0.1/abstract/cs_cmsDataLayer.abstract.class.php ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/0.1/abstract/csb_blog.abstract.class.php =================================================================== --- trunk/0.1/abstract/csb_blog.abstract.class.php 2009-02-20 05:47:12 UTC (rev 8) +++ trunk/0.1/abstract/csb_blog.abstract.class.php 2009-02-20 05:48:19 UTC (rev 9) @@ -1,456 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/csb_dataLayer.abstract.class.php'); - -class csb_blogAbstract extends csb_dataLayerAbstract { - - /** Internal name of blog (looks like a permalink) */ - protected $blogName; - - /** Displayable name of blog */ - protected $blogDisplayName; - - /** Numeric ID of blog */ - protected $blogId=false; - - /** Location of blog */ - protected $blogLocation; - - //------------------------------------------------------------------------- - /** - * The constructor. - * - * @param $blogName (str) name of blog (NOT the display name) - * @param $dbType (str) Type of database (pgsql/mysql/sqlite) - * @param $dbParams (array) connection options for database - * - * @return exception throws an exception on error. - */ - public function __construct(array $dbParams=null) { - - //TODO: put these in the constructor args, or require CONSTANTS. - parent::__construct($dbParams); - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Initializes information about the selected blog. - * - * @param $blogName (str) name of blog (NOT the display name) - */ - public function initialize_locals($blogName) { - - if(!is_numeric($this->blogId)) { - $data = $this->get_blog_data_by_name($blogName); - - $var2index = array( - 'blogDisplayName' => 'blog_display_name', - 'blogName' => 'blog_name', - 'blogId' => 'blog_id', - 'blogLocation' => 'location' - ); - - foreach($var2index as $var=>$index) { - if(isset($data[$index]) && strlen($data[$index])) { - $this->$var = $data[$index]; - } - else { - throw new exception(__METHOD__ .": var ". $var ." not set from index ". $index .", no data (". $data[$index] .")"); - } - } - } - else { - throw new exception(__METHOD__ .": already initialized"); - } - }//end initialize_locals() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Retrieves protected (or private?) internal var values - * - * @param $var (str) name of internal var to retrieve - * - * @return exception throws an exception if named var doesn't exist. - */ - public function get_internal_var($var) { - if(isset($this->$var)) { - $retval = $this->$var; - } - else { - throw new exception(__METHOD__ .": invalid var name (". $var .")"); - } - - return($retval); - }//end get_internal_var() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function is_initialized() { - $retval = false; - if(is_numeric($this->blogId)) { - $retval = true; - } - return($retval); - }//end is_initialized() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Creates a "permalink" just from title (does NOT include blog location): - * lowercases, strips special characters, uses "_" in place of spaces and - * special characters (NEVER creates more than one "_" in a row) - * - * @param $title (str) string to create permalink from. - * - * @return exception throws exception on error - * @return (string) permalink - */ - public function create_permalink_from_title($title) { - if(is_string($title) && strlen($title) >= CSBLOG_TITLE_MINLEN) { - - $permalink = strtolower($title); - $permalink = preg_replace('/!/', '', $permalink); - $permalink = preg_replace('/&\+/', '-', $permalink); - $permalink = preg_replace('/\'/', '', $permalink); - $permalink = preg_replace("/[^a-zA-Z0-9_]/", "_", $permalink); - - if(!strlen($permalink)) { - throw new exception(__METHOD__ .": invalid filename (". $permalink .") from title=(". $title .")"); - } - - //consolidate multiple underscores... (" . . ." becomes "______", after this becomes just "_") - $permalink = preg_replace('/__*/', '_', $permalink); - } - else { - throw new exception(__METHOD__ .": invalid title (". $title .")"); - } - - return($permalink); - }//end create_permalink_from_title() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Encodes content using base64 - * - * @param $content (str) content to encode - * - * @return (string) encoded content. - */ - public function encode_content($content) { - //make it base64 data, so it is easy to insert. - $retval = base64_encode($content); - return($retval); - }//end encode_content() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Decoded content (reverse of encode_content()) - * - * @param $content (str) Encoded content to decode - * - * @return (string) Decoded content. - */ - public function decode_content($content) { - $retval = base64_decode($content); - return($retval); - }//end decode_content() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Retrieves all data about a blog (the main entry only) by its name. - * - * @param $blogName (str) name of blog (displayable or proper) - * - * @return exception throws exceptions on error - * @return (array) array of data about the blog. - */ - public function get_blog_data_by_name($blogName) { - if(strlen($blogName) > 3) { - $data = $this->get_blogs(array('b.blog_name'=>$blogName), 'blog_id'); - - if(count($data) == 1) { - $keys = array_keys($data); - $retval = $data[$keys[0]]; - } - else { - throw new exception(__METHOD__ .": too many records returned (". count($data) .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid blog name (". $blogName .")"); - } - - return($retval); - }//end get_blog_data_by_name() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Same as get_blog_data_by_name(), but use blog_id to find it. - * - * @param $blogId (int) blog_id to retrieve info for. - * - * @return exception throws exception on error - * @return (array) array of data about the blog. - */ - public function get_blog_data_by_id($blogId) { - - if(is_numeric($blogId) && $blogId > 0) { - $data = $this->get_blogs(array('blog_id'=>$blogId), 'blog_id'); - if(count($data) == 1) { - $keys = array_keys($data); - $retval = $data[$keys[0]]; - } - else { - throw new exception(__METHOD__ .": invalid number of records returned (". count($data) .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid blog id (". $blogId .")"); - } - - return($retval); - }//end get_blog_data_by_id() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Determines if there is one or more matching permalinks for the given - * blog; duplicates are given a suffix of "-N" (where "N" is the number of - * matching entries; first dup is given "-1", and so on). - * - * @param $blogId (int) blog_id for the permalink - * @param $permaLink (str) permalink to check - * - * @return exception thrown on error. - * @return - */ - public function check_permalink($blogId, $permalink) { - if(is_string($permalink) && strlen($permalink) >= CSBLOG_TITLE_MINLEN && is_numeric($blogId) && $blogId > 0) { - #if($permalink == $this->create_permalink_from_title($permalink)) { - $permalink = $this->create_permalink_from_title($permalink); - $sql = "SELECT * FROM csblog_entry_table WHERE blog_id=". $blogId - ." AND permalink='". $permalink ."' OR permalink LIKE '". $permalink ."-%'"; - - $numrows = $this->run_sql($sql, false); - - if($numrows >= 0) { - if($numrows >= 1) { - //got a record, give 'em the data back. - $retval = $permalink ."-". $numrows; - } - elseif($numrows == 0) { - $retval = $permalink; - } - else { - throw new exception(__METHOD__ .": unknown error, numrows=(". $numrows ."), dberror"); - } - } - else { - throw new exception(__METHOD__ .": invalid numrows (". $numrows .") or dberror"); - } - } - else { - throw new exception(__METHOD__ .": invalid permalink (". $permalink .") or blog_id (". $blogId .")"); - } - - return($retval); - }//end check_permalink() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - protected function get_age_hype($timestamp, $addBrackets=FALSE) { - if(strlen($timestamp >= 9)) { - if(!is_numeric($timestamp)) { - $timestamp = strtotime($timestamp); - } - - $age = time() - $timestamp; - switch($age) { - case ($age <= 1800): { - $extraText = '<font color="red"><b>Ink\'s still WET!</b></font>'; - } break; - - case ($age <= 3600): { - //modified less than an hour ago! - $extraText = '<font color="red"><b>Hot off the press!</b></font>'; - } break; - - case ($age <= 86400): { - //modified less than 24 hours ago. - $extraText = '<font color="red"><b>New!</b></font>'; - } break; - - case ($age <= 604800): { - //modified this week. - $extraText = '<font color="red">Less than a week old</font>'; - } break; - - case ($age <= 2592000): { - //modified this month. - $extraText = '<b>Less than a month old</b>'; - } break; - - case ($age <= 5184000): { - //modified in the last 2 months - $extraText = '<b>Updated last month</b>'; - } break; - - case ($age <= 7776000): { - $extraText = '<i>Updated 3 months ago</i>'; - } break; - - case ($age <= 10368000): { - $extraText = '<i>Updated 4 months ago</i>'; - } break; - - case ($age <= 12960000): { - $extraText = '<i>Updated 5 months ago</i>'; - } break; - - case ($age <= 15552000): { - $extraText = '<i>Updated in the last 6 months</i>'; - } break; - - default: { - $extraText = '<i>pretty old</i>'; - } - } - - if(strlen($extraText) && $addBrackets) { - $extraText = '['. $extraText .']'; - } - } - else { - throw new exception(__METHOD__ .": invalid timestamp (". $timestamp .")"); - } - - return($extraText); - }//end get_age_hype() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_most_recent_blog() { - $retval = $this->get_recent_blogs(1); - return($retval); - }//end get_most_recent_blog() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_recent_blogs($limit=5, $offset=0, $includeDrafts=false) { - if(is_numeric($this->blogId)) { - if(is_numeric($limit) && $limit > 0) { - if(is_numeric($offset) && $offset >= 0) { - $criteria = array( - 'blog_id' => $this->blogId, - 'is_draft' => 'f' - ); - if($includeDrafts === true) { - unset($criteria['is_draft']); - } - $retval = $this->get_blog_entries($criteria, 'post_timestamp DESC', $limit, $offset); - } - else { - throw new exception(__METHOD__ .": invalid offset (". $offset .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid limit (". $limit .")"); - } - } - else { - throw new exception(__METHOD__ .": blogId not set"); - } - - return($retval); - }//end get_recent_blogs() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - protected function get_full_permalink($permalink) { - if(!strlen($this->blogLocation)) { - throw new exception(__METHOD__ .": missing internal blogLocation (". $this->blogLocation .")"); - } - elseif(!strlen($this->blogName)) { - throw new exception(__METHOD__ .": missing internal blogName (". $this->blogName .")"); - } - elseif(!strlen($permalink)) { - throw new exception(__METHOD__ .": invalid/missing permalink (". $permalink .")"); - } - else { - $retval = $this->blogLocation .'/'. $this->blogName .'/'. $permalink; - } - - return($retval); - }//end get_full_permalink() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function parse_full_permalink($fullPermalink) { - - if(strlen($fullPermalink) && preg_match("/\//", $fullPermalink)) { - $fullPermalink = preg_replace("/^\//", "", $fullPermalink); - $parts = explode("/", $fullPermalink); - - if(count($parts) >= 3) { - $permalink = array_pop($parts); - $blogName = array_pop($parts); - $location = "/". $this->gfObj->string_from_array($parts, NULL, "/"); - - $retval = array( - 'location' => $location, - 'blogName' => $blogName, - 'permalink' => $permalink - ); - } - else { - throw new exception(__METHOD__ .": not enough parts (i.e. location, blogName, & permalink) in " . - "full permalink (". $fullPermalink .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid or non-full permalink given (". $fullPermalink .")"); - } - - return($retval); - }//end parse_full_permalink() - //------------------------------------------------------------------------- - - - -}// end blog{} -?> Deleted: trunk/0.1/abstract/csb_dataLayer.abstract.class.php =================================================================== --- trunk/0.1/abstract/csb_dataLayer.abstract.class.php 2009-02-20 05:47:12 UTC (rev 8) +++ trunk/0.1/abstract/csb_dataLayer.abstract.class.php 2009-02-20 05:48:19 UTC (rev 9) @@ -1,668 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/../../cs-content/cs_phpDB.class.php'); -require_once(dirname(__FILE__) .'/../../cs-content/cs_globalFunctions.class.php'); -require_once(dirname(__FILE__) .'/../../cs-versionparse/cs_version.abstract.class.php'); -require_once(dirname(__FILE__) .'/../csb_location.class.php'); -require_once(dirname(__FILE__) .'/../csb_permission.class.php'); - - -abstract class csb_dataLayerAbstract extends cs_versionAbstract { - - /** */ - protected $gfObj; - - /** */ - private $isConnected=false; - - /** */ - protected $dbParams; - - const DBTYPE='pgsql'; - - //------------------------------------------------------------------------- - /** - * Constructor (must be called from extending class) - * - * @param $dbType (str) type of database to connect to (pgsql/mysql/sqlite) - * @param $dbParams (array) list of connection parameters for selected db. - */ - function __construct(array $dbParams=NULL) { - $this->set_version_file_location(dirname(__FILE__) . '/../VERSION'); - $this->gfObj = new cs_globalFunctions(); - - //check that some required constants exist. - if(!defined('CSBLOG_TITLE_MINLEN')) { - define('CSBLOG_TITLE_MINLEN', 4); - } - - $this->dbParams = $dbParams; - $this->connect_db(); - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - protected function connect_db() { - if($this->isConnected === false) { - if(is_array($this->dbParams)) { - $this->db = new cs_phpDB('pgsql'); - try { - $this->db->connect($this->dbParams); - } - catch(exception $e) { - throw new exception(__METHOD__ .": failed to connect to database, DETAILS: ". $e->getMessage()); - } - - //NOTE: if the call to "connect()" fails, it should throw an exception. - $this->isConnected=true; - } - else { - //no parameters passed. Try using constants. - - $constantList = array( - 'CSBLOG_DB_HOST' => 'host', - 'CSBLOG_DB_PORT' => 'port', - 'CSBLOG_DB_DBNAME' => 'dbname', - 'CSBLOG_DB_USER' => 'user', - 'CSBLOG_DB_PASSWORD' => 'password' - ); - - $dbParams = array(); - foreach($constantList as $constant=>$index) { - $value = ''; - if(defined($constant)) { - $value = constant($constant); - } - else { - if($index != 'password') { - throw new exception(__METHOD__ .": missing one or more constants for database connectivity (". $constant .")"); - } - } - $dbParams[$index] = $value; - } - $this->db = new cs_phpDB('pgsql'); - try { - $this->db->connect($dbParams); - } - catch(exception $e) { - throw new exception(__METHOD__ .": failed to connect to database using constants, DETAILS: ". $e->getMessage()); - } - - //NOTE: if the call to "connect()" fails, it should throw an exception. - $this->isConnected = true; - } - } - else { - $this->gfObj->debug_print(__METHOD__ .": already connected"); - } - }//end connect_db() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function run_sql($sql, $exceptionOnNoRows=true) { - //TODO: make EVERYTHING use this method, so it can automatically connect to the database. - if($this->isConnected !== true) { - $this->connect_db(); - } - - if($this->isConnected === true) { - if(is_string($sql) && strlen($sql)) { - - //run the statement & check the output. - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if($exceptionOnNoRows === true && $numrows <= 0 && !strlen($dberror)) { - throw new exception(__METHOD__ .": no rows returned (". $numrows .")"); - } - elseif(is_numeric($numrows) && !strlen($dberror)) { - $retval = $numrows; - } - else { - throw new exception(__METHOD__ .": invalid numrows (". $numrows ."), failed to run SQL... " . - "DBERROR: ". $dberror ."<BR>\nSQL::: ". $sql); - } - - } - else { - throw new exception(__METHOD__ .": no sql to run"); - } - } - else { - throw new exception(__METHOD__ .": database isn't connected"); - } - - return($retval); - }//end run_sql() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Loads data into blank (or existing) database. - * - * @param void (void) none - * - * @return exception throws exception on error - * @return (int) Number of records existing in auth table. - */ - public function run_setup() { - $retval = false; - $this->connect_db(); - $this->db->beginTrans(); - $fs = new cs_fileSystem(dirname(__FILE__) .'/../schema'); - $mySchema = $fs->read(self::DBTYPE .'.schema.sql'); - - $retval = $this->db->exec($mySchema); - - #$internalValues = $this->get_version(true); - #foreach($internalValues as $name=>$value) { - # $sql = "INSERT INTO csblog_internal_data_table (internal_name, internal_value) " . - # "VALUES ('". $name ."', '". $value ."')"; - # $this->run_sql($sql); - #} - - $retval = 1; - $this->db->commitTrans(); - return($retval); - }//end run_setup() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Create a user in the database. This assumes that the blogger is in - * complete control of authentication, so this doesn't work if an existing - * mechanism is already in place. - * - * @param $username (str) username to create - * @param $password (str) unencrypted password for the user - * - * @return exception throws exceptions on error - * @return (int) UID of new user - */ - public function create_user($username, $password) { - - $username = $this->gfObj->cleanString($username, 'email'); - if($username != func_get_arg(0)) { - throw new exception(__METHOD__ .": username contained invalid characters (". $username ." != ". func_get_arg(0) .")"); - } - - $existingUser = $this->get_uid($username); - - if($existingUser === false) { - $encryptedPass = md5($username .'-'. $password); - $sql = 'INSERT INTO cs_authentication_table (username, passwd) VALUES ' . - "('". $username ."', '". $encryptedPass ."')"; - - $numrows = $this->run_sql($sql); - - if($numrows == 1) { - $sql = "SELECT currval('cs_authentication_table_uid_seq')"; - - $numrows = $this->run_sql($sql); - if($numrows == 1) { - $data = $this->db->farray(); - $retval = $data[0]; - } - else { - throw new exception(__METHOD__ .": invalid numrows (". $numrows .") while retrieving last inserted uid"); - } - } - else { - throw new exception(__METHOD__ .": failed insert (". $numrows ."): "); - } - } - else { - throw new exception(__METHOD__ .": user exists (". $username .")"); - } - - return($retval); - }//end create_user() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Retrieve UID for the given username (i.e. for checking dups) - * - * @param $username (str) username to check - * - * @return exception throws exception on error - * @return false boolean FALSE returned if no user - * @return (int) UID for existing user - */ - public function get_user($username) { - - if(strlen($username) && is_string($username) && !is_numeric($username)) { - $username = $this->gfObj->cleanString($username, 'email'); - if($username != func_get_arg(0)) { - throw new exception(__METHOD__ .": username contained invalid characters (". $username ." != ". func_get_arg(0) .")"); - } - $sql = "SELECT * FROM cs_authentication_table WHERE username='". $username ."'"; - $numrows = $this->run_sql($sql, false); - - if($numrows == 1) { - $retval = $this->db->farray_fieldnames(); - } - elseif($numrows == 0) { - $retval = false; - } - else { - throw new exception(__METHOD__ .": invalid numrows (". $numrows .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid data for username (". $username ... [truncated message content] |
From: <cra...@us...> - 2009-02-20 05:47:16
|
Revision: 8 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=8&view=rev Author: crazedsanity Date: 2009-02-20 05:47:12 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Renaming more files... Added Paths: ----------- trunk/0.1/cs_location.class.php trunk/0.1/cs_permission.class.php Removed Paths: ------------- trunk/0.1/csb_location.class.php trunk/0.1/csb_permission.class.php Copied: trunk/0.1/cs_location.class.php (from rev 5, trunk/0.1/csb_location.class.php) =================================================================== --- trunk/0.1/cs_location.class.php (rev 0) +++ trunk/0.1/cs_location.class.php 2009-02-20 05:47:12 UTC (rev 8) @@ -0,0 +1,128 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); + +class csb_location extends csb_dataLayerAbstract { + + //------------------------------------------------------------------------- + public function __construct(array $dbParams=null) { + parent::__construct($dbParams); + + $this->gfObj = new cs_globalFunctions(); + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function add_location($location) { + if(is_string($location) && strlen($location) > 3) { + if(!preg_match('/^\//', $location)) { + $location = "/". $location; + } + $location = $this->fix_location($location); + $location = $this->gfObj->cleanString($location, "sql_insert"); + $sql = "INSERT INTO csblog_location_table (location) " . + "VALUES ('". $location ."')"; + + try { + $numrows = $this->run_sql($sql); + + + if($numrows == 1) { + //okay, retrieve the id inserted. + $retval = $this->db->get_currval('csblog_location_table_location_id_seq'); + } + else { + throw new exception(__METHOD__ .": failed to create location (". $location ."), " . + "numrows=(". $numrows .")"); + } + } + catch(exception $e) { + cs_debug_backtrace($this->gfObj->debugPrintOpt); + throw new exception(__METHOD__ .": failed to create location (". $location .")... DETAILS::: ". $e->getMessage()); + } + } + else { + throw new exception(__METHOD__ .": invalid location (". $location .")"); + } + + return($retval); + }//end add_location() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_location_id($location) { + if(is_string($location) && strlen($location) > 3) { + $location = $this->fix_location($location); + $location = $this->gfObj->cleanString($location, "sql_insert"); + $sql = "SELECT location_id FROM csblog_location_table " . + "WHERE location='". $location ."'"; + $numrows = $this->run_sql($sql, false); + + + if($numrows == 0) { + $retval = false; + } + elseif($numrows == 1) { + $retval = $this->db->farray(); + $retval = $retval[0]; + } + else { + throw new exception(__METHOD__ .": failed to retrieve location (". $location ."), " . + "invalid numrows (". $numrows .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid location (". $location .")"); + } + + return($retval); + }//end get_location_id() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function fix_location($location) { + if(strlen($location)) { + $retval = $location; + if(!preg_match("/^\//", $retval)) { + $retval = "/". $retval; + } + $retval = preg_replace("/[^A-Za-z0-9\/_-]/", "", $retval); + $retval = preg_replace("/(\/){2,}/", "/", $retval); + $retval = preg_replace("/\/$/", "", $retval); + } + else { + throw new exception(__METHOD__ .": no valid location (". $location .")"); + } + + return($retval); + }//end fix_location() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_locations() { + $sql = "SELECT location_id, location FROM csblog_location_table ORDER BY location_id"; + $numrows = $this->run_sql($sql,false); + + if($numrows > 0) { + $retval = $this->db->farray_nvp('location_id', 'location'); + } + else { + throw new exception(__METHOD__ .": no records found (". $numrows .")"); + } + + return($retval); + }//end get_locations() + //------------------------------------------------------------------------- + + +} +?> \ No newline at end of file Property changes on: trunk/0.1/cs_location.class.php ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/0.1/cs_permission.class.php (from rev 5, trunk/0.1/csb_permission.class.php) =================================================================== --- trunk/0.1/cs_permission.class.php (rev 0) +++ trunk/0.1/cs_permission.class.php 2009-02-20 05:47:12 UTC (rev 8) @@ -0,0 +1,146 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); +require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); + + +//TODO: this should extend csb_blogAbstract{} + +class csb_permission extends csb_dataLayerAbstract { + + //------------------------------------------------------------------------- + public function __construct(array $dbParams=null) { + parent::__construct($dbParams); + + $this->gfObj = new cs_globalFunctions(); + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function add_permission($blogId, $toUser) { + if(!is_numeric($toUser) && is_string($toUser) && strlen($toUser)) { + $toUser = $this->get_uid($toUser); + } + + if(is_numeric($toUser) && $toUser > 0 && is_numeric($blogId) && $blogId > 0) { + $this->db->beginTrans(); + $sql = "INSERT INTO csblog_permission_table (blog_id, uid) VALUES " . + "(". $blogId .", ". $toUser .")"; + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $this->db->commitTrans(); + $retval = $this->db->get_currval('csblog_permission_table_permission_id_seq'); + } + else { + $this->db->rollbackTrans(); + throw new exception(__METHOD__ .": invalid numrows (". $numrows .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid uid (". $toUser .") or blogId (". $blogId .")"); + } + + return($retval); + }//end add_permission() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function can_access_blog($blogId, $uid) { + if(strlen($blogId) && (is_numeric($uid) || strlen($uid))) { + + try { + if(!is_numeric($uid)) { + $uid = $this->get_uid($uid); + } + if(!is_numeric($blogId)) { + //TODO: if this extended csb_blogAbstract{}, call get_blog_data_by_name() to make this easier. + $blogData = $this->get_blogs(array('blog_name'=>$blogId)); + if(count($blogData) == 1) { + $keys = array_keys($blogData); + $blogId = $keys[0]; + } + else { + throw new exception(__METHOD__ .": too many records found for blog name (". $blogId .")"); + } + } + //if this call doesn't cause an exception, we're good to go (add extra logic anyway) + $blogData = $this->get_blogs(array('blog_id'=>$blogId, 'uid'=>$uid)); + if(is_array($blogData) && count($blogData) == 1 && $blogData[$blogId]['uid'] == $uid) { + $retval = true; + } + else { + $retval = false; + } + } + catch(exception $e) { + //an exception means there was no record; check the permissions table. + $sql = "SELECT * FROM csblog_permission_table WHERE blog_id=". $blogId . + " AND uid=". $uid; + + $numrows = $this->run_sql($sql,false); + + $retval = false; + if($numrows == 1) { + $retval = true; + } + elseif($numrows > 1 || $numrows < 0) { + throw new exception(__METHOD__ .": invalid data returned, numrows=(". $numrows .")"); + } + } + } + else { + //they gave invalid data; default to no access. + $retval = false; + } + + return($retval); + + }//end can_access_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function remove_permission($blogId, $fromUser) { + if(!is_numeric($fromUser) && is_string($fromUser) && strlen($fromUser)) { + $fromUser = $this->get_uid($fromUser); + } + + if(is_numeric($fromUser) && $fromUser > 0 && is_numeric($blogId) && $blogId > 0) { + $sql = "DELETE FROM csblog_permission_table WHERE blog_id=". $blogId + ." AND uid=". $fromUser; + + try { + $this->db->beginTrans(); + $numrows = $this->run_sql($sql, false); + + if($numrows == 0 || $numrows == 1) { + $this->db->commitTrans(); + $retval = $numrows; + } + else { + $this->db->rollbackTrans(); + throw new exception(__METHOD__ .": deleted too many records (". $numrows .")"); + } + } + catch(exception $e) { + throw new exception(__METHOD__ .": unable to delete permission... DETAILS::: ". $e->getMessage()); + } + } + else { + throw new exception(__METHOD__ .": invalid uid (". $fromUser .") or blogId (". $blogId .")"); + } + + return($retval); + }//end remove_permission() + //------------------------------------------------------------------------- + + +} +?> \ No newline at end of file Property changes on: trunk/0.1/cs_permission.class.php ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/0.1/csb_location.class.php =================================================================== --- trunk/0.1/csb_location.class.php 2009-02-20 05:46:29 UTC (rev 7) +++ trunk/0.1/csb_location.class.php 2009-02-20 05:47:12 UTC (rev 8) @@ -1,128 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); - -class csb_location extends csb_dataLayerAbstract { - - //------------------------------------------------------------------------- - public function __construct(array $dbParams=null) { - parent::__construct($dbParams); - - $this->gfObj = new cs_globalFunctions(); - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function add_location($location) { - if(is_string($location) && strlen($location) > 3) { - if(!preg_match('/^\//', $location)) { - $location = "/". $location; - } - $location = $this->fix_location($location); - $location = $this->gfObj->cleanString($location, "sql_insert"); - $sql = "INSERT INTO csblog_location_table (location) " . - "VALUES ('". $location ."')"; - - try { - $numrows = $this->run_sql($sql); - - - if($numrows == 1) { - //okay, retrieve the id inserted. - $retval = $this->db->get_currval('csblog_location_table_location_id_seq'); - } - else { - throw new exception(__METHOD__ .": failed to create location (". $location ."), " . - "numrows=(". $numrows .")"); - } - } - catch(exception $e) { - cs_debug_backtrace($this->gfObj->debugPrintOpt); - throw new exception(__METHOD__ .": failed to create location (". $location .")... DETAILS::: ". $e->getMessage()); - } - } - else { - throw new exception(__METHOD__ .": invalid location (". $location .")"); - } - - return($retval); - }//end add_location() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_location_id($location) { - if(is_string($location) && strlen($location) > 3) { - $location = $this->fix_location($location); - $location = $this->gfObj->cleanString($location, "sql_insert"); - $sql = "SELECT location_id FROM csblog_location_table " . - "WHERE location='". $location ."'"; - $numrows = $this->run_sql($sql, false); - - - if($numrows == 0) { - $retval = false; - } - elseif($numrows == 1) { - $retval = $this->db->farray(); - $retval = $retval[0]; - } - else { - throw new exception(__METHOD__ .": failed to retrieve location (". $location ."), " . - "invalid numrows (". $numrows .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid location (". $location .")"); - } - - return($retval); - }//end get_location_id() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function fix_location($location) { - if(strlen($location)) { - $retval = $location; - if(!preg_match("/^\//", $retval)) { - $retval = "/". $retval; - } - $retval = preg_replace("/[^A-Za-z0-9\/_-]/", "", $retval); - $retval = preg_replace("/(\/){2,}/", "/", $retval); - $retval = preg_replace("/\/$/", "", $retval); - } - else { - throw new exception(__METHOD__ .": no valid location (". $location .")"); - } - - return($retval); - }//end fix_location() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_locations() { - $sql = "SELECT location_id, location FROM csblog_location_table ORDER BY location_id"; - $numrows = $this->run_sql($sql,false); - - if($numrows > 0) { - $retval = $this->db->farray_nvp('location_id', 'location'); - } - else { - throw new exception(__METHOD__ .": no records found (". $numrows .")"); - } - - return($retval); - }//end get_locations() - //------------------------------------------------------------------------- - - -} -?> \ No newline at end of file Deleted: trunk/0.1/csb_permission.class.php =================================================================== --- trunk/0.1/csb_permission.class.php 2009-02-20 05:46:29 UTC (rev 7) +++ trunk/0.1/csb_permission.class.php 2009-02-20 05:47:12 UTC (rev 8) @@ -1,146 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_dataLayer.abstract.class.php'); -require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); - - -//TODO: this should extend csb_blogAbstract{} - -class csb_permission extends csb_dataLayerAbstract { - - //------------------------------------------------------------------------- - public function __construct(array $dbParams=null) { - parent::__construct($dbParams); - - $this->gfObj = new cs_globalFunctions(); - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function add_permission($blogId, $toUser) { - if(!is_numeric($toUser) && is_string($toUser) && strlen($toUser)) { - $toUser = $this->get_uid($toUser); - } - - if(is_numeric($toUser) && $toUser > 0 && is_numeric($blogId) && $blogId > 0) { - $this->db->beginTrans(); - $sql = "INSERT INTO csblog_permission_table (blog_id, uid) VALUES " . - "(". $blogId .", ". $toUser .")"; - $numrows = $this->run_sql($sql); - - if($numrows == 1) { - $this->db->commitTrans(); - $retval = $this->db->get_currval('csblog_permission_table_permission_id_seq'); - } - else { - $this->db->rollbackTrans(); - throw new exception(__METHOD__ .": invalid numrows (". $numrows .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid uid (". $toUser .") or blogId (". $blogId .")"); - } - - return($retval); - }//end add_permission() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function can_access_blog($blogId, $uid) { - if(strlen($blogId) && (is_numeric($uid) || strlen($uid))) { - - try { - if(!is_numeric($uid)) { - $uid = $this->get_uid($uid); - } - if(!is_numeric($blogId)) { - //TODO: if this extended csb_blogAbstract{}, call get_blog_data_by_name() to make this easier. - $blogData = $this->get_blogs(array('blog_name'=>$blogId)); - if(count($blogData) == 1) { - $keys = array_keys($blogData); - $blogId = $keys[0]; - } - else { - throw new exception(__METHOD__ .": too many records found for blog name (". $blogId .")"); - } - } - //if this call doesn't cause an exception, we're good to go (add extra logic anyway) - $blogData = $this->get_blogs(array('blog_id'=>$blogId, 'uid'=>$uid)); - if(is_array($blogData) && count($blogData) == 1 && $blogData[$blogId]['uid'] == $uid) { - $retval = true; - } - else { - $retval = false; - } - } - catch(exception $e) { - //an exception means there was no record; check the permissions table. - $sql = "SELECT * FROM csblog_permission_table WHERE blog_id=". $blogId . - " AND uid=". $uid; - - $numrows = $this->run_sql($sql,false); - - $retval = false; - if($numrows == 1) { - $retval = true; - } - elseif($numrows > 1 || $numrows < 0) { - throw new exception(__METHOD__ .": invalid data returned, numrows=(". $numrows .")"); - } - } - } - else { - //they gave invalid data; default to no access. - $retval = false; - } - - return($retval); - - }//end can_access_blog() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function remove_permission($blogId, $fromUser) { - if(!is_numeric($fromUser) && is_string($fromUser) && strlen($fromUser)) { - $fromUser = $this->get_uid($fromUser); - } - - if(is_numeric($fromUser) && $fromUser > 0 && is_numeric($blogId) && $blogId > 0) { - $sql = "DELETE FROM csblog_permission_table WHERE blog_id=". $blogId - ." AND uid=". $fromUser; - - try { - $this->db->beginTrans(); - $numrows = $this->run_sql($sql, false); - - if($numrows == 0 || $numrows == 1) { - $this->db->commitTrans(); - $retval = $numrows; - } - else { - $this->db->rollbackTrans(); - throw new exception(__METHOD__ .": deleted too many records (". $numrows .")"); - } - } - catch(exception $e) { - throw new exception(__METHOD__ .": unable to delete permission... DETAILS::: ". $e->getMessage()); - } - } - else { - throw new exception(__METHOD__ .": invalid uid (". $fromUser .") or blogId (". $blogId .")"); - } - - return($retval); - }//end remove_permission() - //------------------------------------------------------------------------- - - -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-20 05:46:34
|
Revision: 7 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=7&view=rev Author: crazedsanity Date: 2009-02-20 05:46:29 +0000 (Fri, 20 Feb 2009) Log Message: ----------- First round of renames... Added Paths: ----------- trunk/0.1/cs_cmsEntry.class.php trunk/0.1/cs_cmsLocation.class.php Removed Paths: ------------- trunk/0.1/csb_blogEntry.class.php trunk/0.1/csb_blogLocation.class.php trunk/0.1/csb_blogUser.class.php Copied: trunk/0.1/cs_cmsEntry.class.php (from rev 5, trunk/0.1/csb_blogEntry.class.php) =================================================================== --- trunk/0.1/cs_cmsEntry.class.php (rev 0) +++ trunk/0.1/cs_cmsEntry.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -0,0 +1,132 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); +require_once(dirname(__FILE__) .'/csb_blogComment.class.php'); + +class csb_blogEntry extends csb_blogAbstract { + + /** Internal name of blog (looks like a permalink) */ + protected $blogName; + + /** Numeric ID of blog */ + protected $blogEntryId=false; + + /** Location of blog */ + protected $blogLocation; + + /** Permalink of current entry (just the title portion) */ + protected $permalink; + + /** Full permalink (location + blogName + permalink) */ + protected $fullPermalink; + + /** csb_blogComment{} object */ + protected $blogCommentObj; + + //------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $fullPermalink (str) FULL Permalink. + * @param $dbParams (array) connection options for database + * + * @return exception throws an exception on error. + */ + public function __construct($fullPermalink, array $dbParams=null) { + + //TODO: put these in the constructor args, or require CONSTANTS. + parent::__construct($dbParams); + + if(isset($fullPermalink) && strlen($fullPermalink)) { + + $bits = $this->parse_full_permalink($fullPermalink); + $this->blogLocation = $bits['location']; + $this->blogName = $bits['blogName']; + $this->permalink = $bits['permalink']; + + $data = $this->get_blog_entry($fullPermalink); + $this->blogEntryId = $data['entry_id']; + } + else { + throw new exception(__METHOD__ .": invalid permalink (". $fullPermalink .")"); + } + + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Takes an array for URL, like what contentSystem{} builds, and return the + * contents for the proper blog. + */ + public function display_blog(array $url) { + //TODO: this is very redundant; since this object already has the full permalink, why pass it again? + $fullPermalink = "/". $this->gfObj->string_from_array($url, null, '/'); + $retval = $this->get_blog_entry($fullPermalink); + + return($retval); + }//end display_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Updates a single entry (within a transaction) + * + * @param $blogEntryId (int) entry_id to update. + * @param $updates (array) array of field=>value updates + * + * @return exception throws exception on error. + * @return true returns boolean TRUE on success. + */ + public function update_entry($blogEntryId, array $updates) { + if(is_numeric($blogEntryId) && $blogEntryId > 0 && is_array($updates) && count($updates)) { + $validFields = array( + 'post_timestamp' => 'datetime', + 'content' => 'sql', + 'is_draft' => 'boolean' + ); + $updateThis = array_intersect_key($updates, $validFields); + if(is_array($updateThis) && count($updateThis)) { + + //encode teh content as before. + if(isset($updateThis['content'])) { + $updateThis['content'] = $this->encode_content($updateThis['content']); + } + + $sql = "UPDATE csblog_entry_table SET ". $this->gfObj->string_from_array($updateThis, 'update', NULL, $validFields) + ." WHERE entry_id=". $blogEntryId; + + $this->db->beginTrans(); + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $this->update_blog_last_post_timestamps(); + $this->db->commitTrans(); + $retval = true; + } + else { + $this->db->abortTrans(); + throw new exception(__METHOD__ .": update failed, numrows=(". $numrows ."), dberror"); + } + } + else { + throw new exception(__METHOD__ .": no valid fields in updates array"); + } + } + else { + throw new exception(__METHOD__ .": invalid data passed"); + } + + return($retval); + }//end update_entry() + //------------------------------------------------------------------------- + + + +}// end blog{} +?> Property changes on: trunk/0.1/cs_cmsEntry.class.php ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/0.1/cs_cmsLocation.class.php (from rev 5, trunk/0.1/csb_blogLocation.class.php) =================================================================== --- trunk/0.1/cs_cmsLocation.class.php (rev 0) +++ trunk/0.1/cs_cmsLocation.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -0,0 +1,66 @@ +<?php + + +require_once(dirname(__FILE__) .'/csb_blog.class.php'); + +class csb_blogLocation extends csb_blogAbstract { + + /** An array of blog{} objects. */ + protected $blogObjList; + + /** An array with sub-arrays listing by blog_id, name, etc. */ + protected $blogIndex; + + //------------------------------------------------------------------------- + function __construct($location, array $dbParams=null) { + parent::__construct($dbParams); + + $loc = new csb_location(); + $location = $loc->fix_location($location); + + $criteria = array( + 'is_active' =>"t", + 'bl.location' => $location + ); + + try { + $this->validBlogs = $this->get_blogs($criteria, 'blog_display_name DESC'); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to retrieve any valid blogs for location=(". $location .")... " . + "MORE INFO::: ". $e->getMessage()); + } + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_most_recent_blogs($numPerBlog=1) { + if(is_array($this->validBlogs) && count($this->validBlogs)) { + $retval = array(); + foreach($this->validBlogs as $blogId=>$blogData) { + $blogName = $blogData['blog_name']; + $this->blogs[$blogName] = new csb_blog($blogName, $this->dbParams); + if(!$this->blogs[$blogName]->is_initialized()) { + $this->blogs[$blogName]->initialize_locals($blogName); + } + $retval[$blogName] = $this->blogs[$blogName]->get_recent_blogs($numPerBlog); + if($numPerBlog == 1) { + $keys = array_keys($retval[$blogName]); + $retval[$blogName] = $retval[$blogName][$keys[0]]; + } + } + } + else { + throw new exception(__METHOD__ .": no valid blogs to handle"); + } + + return($retval); + }//end get_most_recent_blogs() + //------------------------------------------------------------------------- + + + +} +?> \ No newline at end of file Property changes on: trunk/0.1/cs_cmsLocation.class.php ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/0.1/csb_blogEntry.class.php =================================================================== --- trunk/0.1/csb_blogEntry.class.php 2009-02-20 05:43:02 UTC (rev 6) +++ trunk/0.1/csb_blogEntry.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -1,132 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); -require_once(dirname(__FILE__) .'/csb_blogComment.class.php'); - -class csb_blogEntry extends csb_blogAbstract { - - /** Internal name of blog (looks like a permalink) */ - protected $blogName; - - /** Numeric ID of blog */ - protected $blogEntryId=false; - - /** Location of blog */ - protected $blogLocation; - - /** Permalink of current entry (just the title portion) */ - protected $permalink; - - /** Full permalink (location + blogName + permalink) */ - protected $fullPermalink; - - /** csb_blogComment{} object */ - protected $blogCommentObj; - - //------------------------------------------------------------------------- - /** - * The constructor. - * - * @param $fullPermalink (str) FULL Permalink. - * @param $dbParams (array) connection options for database - * - * @return exception throws an exception on error. - */ - public function __construct($fullPermalink, array $dbParams=null) { - - //TODO: put these in the constructor args, or require CONSTANTS. - parent::__construct($dbParams); - - if(isset($fullPermalink) && strlen($fullPermalink)) { - - $bits = $this->parse_full_permalink($fullPermalink); - $this->blogLocation = $bits['location']; - $this->blogName = $bits['blogName']; - $this->permalink = $bits['permalink']; - - $data = $this->get_blog_entry($fullPermalink); - $this->blogEntryId = $data['entry_id']; - } - else { - throw new exception(__METHOD__ .": invalid permalink (". $fullPermalink .")"); - } - - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Takes an array for URL, like what contentSystem{} builds, and return the - * contents for the proper blog. - */ - public function display_blog(array $url) { - //TODO: this is very redundant; since this object already has the full permalink, why pass it again? - $fullPermalink = "/". $this->gfObj->string_from_array($url, null, '/'); - $retval = $this->get_blog_entry($fullPermalink); - - return($retval); - }//end display_blog() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - /** - * Updates a single entry (within a transaction) - * - * @param $blogEntryId (int) entry_id to update. - * @param $updates (array) array of field=>value updates - * - * @return exception throws exception on error. - * @return true returns boolean TRUE on success. - */ - public function update_entry($blogEntryId, array $updates) { - if(is_numeric($blogEntryId) && $blogEntryId > 0 && is_array($updates) && count($updates)) { - $validFields = array( - 'post_timestamp' => 'datetime', - 'content' => 'sql', - 'is_draft' => 'boolean' - ); - $updateThis = array_intersect_key($updates, $validFields); - if(is_array($updateThis) && count($updateThis)) { - - //encode teh content as before. - if(isset($updateThis['content'])) { - $updateThis['content'] = $this->encode_content($updateThis['content']); - } - - $sql = "UPDATE csblog_entry_table SET ". $this->gfObj->string_from_array($updateThis, 'update', NULL, $validFields) - ." WHERE entry_id=". $blogEntryId; - - $this->db->beginTrans(); - $numrows = $this->run_sql($sql); - - if($numrows == 1) { - $this->update_blog_last_post_timestamps(); - $this->db->commitTrans(); - $retval = true; - } - else { - $this->db->abortTrans(); - throw new exception(__METHOD__ .": update failed, numrows=(". $numrows ."), dberror"); - } - } - else { - throw new exception(__METHOD__ .": no valid fields in updates array"); - } - } - else { - throw new exception(__METHOD__ .": invalid data passed"); - } - - return($retval); - }//end update_entry() - //------------------------------------------------------------------------- - - - -}// end blog{} -?> Deleted: trunk/0.1/csb_blogLocation.class.php =================================================================== --- trunk/0.1/csb_blogLocation.class.php 2009-02-20 05:43:02 UTC (rev 6) +++ trunk/0.1/csb_blogLocation.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -1,66 +0,0 @@ -<?php - - -require_once(dirname(__FILE__) .'/csb_blog.class.php'); - -class csb_blogLocation extends csb_blogAbstract { - - /** An array of blog{} objects. */ - protected $blogObjList; - - /** An array with sub-arrays listing by blog_id, name, etc. */ - protected $blogIndex; - - //------------------------------------------------------------------------- - function __construct($location, array $dbParams=null) { - parent::__construct($dbParams); - - $loc = new csb_location(); - $location = $loc->fix_location($location); - - $criteria = array( - 'is_active' =>"t", - 'bl.location' => $location - ); - - try { - $this->validBlogs = $this->get_blogs($criteria, 'blog_display_name DESC'); - } - catch(exception $e) { - throw new exception(__METHOD__ .": failed to retrieve any valid blogs for location=(". $location .")... " . - "MORE INFO::: ". $e->getMessage()); - } - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_most_recent_blogs($numPerBlog=1) { - if(is_array($this->validBlogs) && count($this->validBlogs)) { - $retval = array(); - foreach($this->validBlogs as $blogId=>$blogData) { - $blogName = $blogData['blog_name']; - $this->blogs[$blogName] = new csb_blog($blogName, $this->dbParams); - if(!$this->blogs[$blogName]->is_initialized()) { - $this->blogs[$blogName]->initialize_locals($blogName); - } - $retval[$blogName] = $this->blogs[$blogName]->get_recent_blogs($numPerBlog); - if($numPerBlog == 1) { - $keys = array_keys($retval[$blogName]); - $retval[$blogName] = $retval[$blogName][$keys[0]]; - } - } - } - else { - throw new exception(__METHOD__ .": no valid blogs to handle"); - } - - return($retval); - }//end get_most_recent_blogs() - //------------------------------------------------------------------------- - - - -} -?> \ No newline at end of file Deleted: trunk/0.1/csb_blogUser.class.php =================================================================== --- trunk/0.1/csb_blogUser.class.php 2009-02-20 05:43:02 UTC (rev 6) +++ trunk/0.1/csb_blogUser.class.php 2009-02-20 05:46:29 UTC (rev 7) @@ -1,91 +0,0 @@ -<?php - -/* - * This is for displaying blogs for which a user has access. The name is a bit - * of a misnomer, but I couldn't really think of a better name at the time. - */ - - -require_once(dirname(__FILE__) .'/csb_blog.class.php'); - -class csb_blogUser extends csb_blogAbstract { - - /** An array of blog{} objects. */ - protected $blogObjList; - - /** An array with sub-arrays listing by blog_id, name, etc. */ - protected $blogIndex; - - //------------------------------------------------------------------------- - function __construct($user, $location=null, array $dbParams=null) { - if(strlen($user) > 2) { - parent::__construct($dbParams); - - $criteria = array( - 'is_active'=>"t" - ); - - if(is_string($location) && strlen($location)) { - $criteria['bl.location'] = $location; - } - $uid = $this->get_uid($user); - if(is_numeric($uid)) { - $this->validBlogs = $this->get_blogs($criteria, 'last_post_timestamp DESC'); - $permObj = new csb_permission($dbParams); - foreach($this->validBlogs as $blogId=>$data) { - $obj = new csb_blog($data['blog_name']); - if(!$permObj->can_access_blog($blogId, $uid)) { - unset($this->validBlogs[$blogId]); - } - } - } - else { - throw new exception(__METHOD__ .": unable to retrieve uid for (". $user .")"); - } - } - else { - throw new exception(__METHOD__ .": no username set (". $user .")"); - } - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_most_recent_blogs($numPerBlog=1) { - if(is_array($this->validBlogs) && count($this->validBlogs)) { - $retval = array(); - foreach($this->validBlogs as $blogId=>$blogData) { - $blogName = $blogData['blog_name']; - $this->blogs[$blogName] = new csb_blog($blogName, $this->dbParams); - if(!$this->blogs[$blogName]->is_initialized()) { - $this->blogs[$blogName]->initialize_locals($blogName); - } - - $recentBlogs = array(); - try { - $recentBlogs = $this->blogs[$blogName]->get_recent_blogs($numPerBlog, 0, true); - if($numPerBlog == 1) { - $keys = array_keys($retval[$blogName]); - $recentBlogs = $retval[$blogName][$keys[0]]; - } - } - catch(exception $e) { - $this->gfObj->debug_print(__METHOD__ .": no blogs for (". $blogName .")"); - } - $retval[$blogName] = $recentBlogs; - } - } - else { - throw new exception(__METHOD__ .": no valid blogs to handle"); - } - - return($retval); - }//end get_most_recent_blogs() - //------------------------------------------------------------------------- - - - - -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-20 05:43:06
|
Revision: 6 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=6&view=rev Author: crazedsanity Date: 2009-02-20 05:43:02 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Another unneeded class... Removed Paths: ------------- trunk/0.1/csb_blog.class.php Deleted: trunk/0.1/csb_blog.class.php =================================================================== --- trunk/0.1/csb_blog.class.php 2009-02-20 05:41:37 UTC (rev 5) +++ trunk/0.1/csb_blog.class.php 2009-02-20 05:43:02 UTC (rev 6) @@ -1,51 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); - -class csb_blog extends csb_blogAbstract { - - /** Internal name of blog (looks like a permalink) */ - protected $blogName; - - /** Displayable name of blog */ - protected $blogDisplayName; - - /** Numeric ID of blog */ - protected $blogId=false; - - /** Location of blog */ - protected $blogLocation; - - //------------------------------------------------------------------------- - /** - * The constructor. - * - * @param $blogName (str) name of blog (NOT the display name) - * @param $dbType (str) Type of database (pgsql/mysql/sqlite) - * @param $dbParams (array) connection options for database - * - * @return exception throws an exception on error. - */ - public function __construct($blogName, array $dbParams=null) { - - //TODO: put these in the constructor args, or require CONSTANTS. - parent::__construct($dbParams); - - - if(!isset($blogName) || !strlen($blogName)) { - throw new exception(__METHOD__ .": invalid blog name (". $blogName .")"); - } - - $this->blogName = $blogName; - if(!defined('CSBLOG_SETUP_PENDING')) { - //proceed normally... - $this->initialize_locals($blogName); - } - - }//end __construct() - //------------------------------------------------------------------------- - - - -}// end blog{} -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-20 05:41:47
|
Revision: 5 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=5&view=rev Author: crazedsanity Date: 2009-02-20 05:41:37 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Remove the comment class (unneeded for a CMS) Removed Paths: ------------- trunk/0.1/csb_blogComment.class.php Deleted: trunk/0.1/csb_blogComment.class.php =================================================================== --- trunk/0.1/csb_blogComment.class.php 2009-02-20 05:40:04 UTC (rev 4) +++ trunk/0.1/csb_blogComment.class.php 2009-02-20 05:41:37 UTC (rev 5) @@ -1,185 +0,0 @@ -<?php - -require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); -require_once(dirname(__FILE__) .'/csb_blogEntry.class.php'); - -//TODO: consider moving add_comment() and get_comments() to csb_dataLayerAbstract{}, since they're data-type things. - -class csb_blogComment extends csb_blogAbstract { - - protected $blogEntryId; - - //------------------------------------------------------------------------- - public function __construct($fullPermalink, array $dbParams=NULL) { - - parent::__construct($dbParams); - - $blogData = $this->parse_full_permalink($fullPermalink); - - $this->blogLocation = $blogData['location']; - $this->blogName = $blogData['name']; - - }//end __construct() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_num_comments() { - $sql = "SELECT count(*) FROM csblog_comment_table WHERE entry_id=". $this->blogEntryId; - - try { - $numrows = $this->run_sql($sql); - - if($numrows = 1) { - $data = $this->db->farray(); - $retval = $data[0]; - } - else { - throw new exception(__METHOD__ .": failed to get number of comments, invalid numrows (". $numrows .")"); - } - } - catch(exception $e) { - throw new exception(__METHOD__ .": failed to retrieve number of comments, DETAILS::: ". $e->getMessage()); - } - - return($retval); - }//end get_num_comments() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function add_comment($authorUid, $title, $comment, array $ancestry=null, $isAnonymous=false) { - $sqlArr = array( - 'entry_id' => $this>blogEntryId, - 'title' => $title, - 'comment' => $this->encode_content($comment), - 'author_uid' => $authorUid, - 'is_anonymous' => $isAnonymous - ); - - $cleanArr = array( - 'entry_id' => 'numeric', - 'title' => 'sql', - 'comment' => 'sql', - 'author_uid' => 'numeric', - 'is_anonymous' => 'bool', - 'ancestry' => 'sql' - ); - - //handle ancestry, if given. - $ancestryStr = ""; - if(is_array($ancestry) && count($ancestry) > 0) { - foreach($ancestry as $id) { - if(is_numeric($id) && $id > 0) { - $ancestryStr = $this->gfObj->create_list($ancestryStr, $id, ':'); - } - else { - throw new exception(__METHOD__ .": invalid ancestor (". $id .")"); - } - } - $sqlArr['ancestry'] = $ancestryStr; - } - - $sql = "INSERT INTO csblog_comment_table ". $this->gfObj->string_from_array($sqlArr, 'insert', null, $cleanArr); - - try { - $this->db->beginTrans(); - $numrows = $this->run_sql($sql); - - if($numrows == 1) { - $retval = $this->db->get_currval('csblog_comment_table_comment_id_seq'); - $this->db->commitTrans(); - } - else { - $this->db->rollbackTrans(); - throw new exception(__METHOD__ .": failed to create record, invalid numrows (". $numrows .")"); - } - } - catch(exception $e) { - throw new exception(__METHOD__ .": failed to create comment, DETAILS::: ". $e->getMessage()); - } - - return($retval); - }//end add_comment() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - protected function get_comments(array $criteria, $orderBy=null, $limit=NULL, $offset=NULL) { - if(!is_array($criteria) || !count($criteria)) { - throw new exception(__METHOD__ .": invalid criteria"); - } - - //TODO: should be specifically limited to blogs that are accessible to current user. - $sql = "SELECT bc.*, be.permalink, bl.location, b.blog_display_name, be.post_timestamp::date as date_short, " . - "b.blog_name, b.blog_id FROM csblog_comment_table AS bc " . - "INNER JOIN csblog_entry_table AS be ON (be.entry_id=bc.entry_id) " . - "INNER JOIN csblog_blog_table AS b ON (be.blog_id=b.blog_id) " . - "INNER JOIN csblog_location_table AS bl ON (b.location_id=bl.location_id) " . - "WHERE "; - - //add stuff to the SQL... - foreach($criteria as $field=>$value) { - if(!preg_match('/^[a-z]{1,}\./', $field)) { - unset($criteria[$field]); - $field = "bc.". $field; - $criteria[$field] = $value; - } - } - $sql .= $this->gfObj->string_from_array($criteria, 'select', NULL, 'sql'); - - if(strlen($orderBy)) { - $sql .= " ORDER BY ". $orderBy; - } - else { - $sql .= " ORDER BY bc.comment_id"; - } - - if(is_numeric($limit) && $limit > 0) { - $sql .= " LIMIT ". $limit; - } - if(is_numeric($offset) && $limit > 0) { - $sql .= " OFFSET ". $offset; - } - - $numrows = $this->run_sql($sql); - - $retval = $this->db->farray_fieldnames('comment_id', true, false); - foreach($retval as $entryId=>$data) { - $retval[$entryId]['content'] = $this->decode_content($data['content']); - #$retval[$entryId]['full_permalink'] = $this->get_full_permalink($data['permalink']); - } - - return($retval); - }//end get_comments() - //------------------------------------------------------------------------- - - - - //------------------------------------------------------------------------- - public function get_comment_by_id($id) { - if(is_numeric($id) && $id > 0) { - $data = $this->get_comments(array('comment_id'=>$id)); - - if(count($data) == 1 && isset($data[$id])) { - $retval = $data[$id]; - $retval['comment'] = $this->decode_content($retval['comment']); - } - else { - throw new exception(__METHOD__ .": failed to retrieve proper data for comment ID (". $id .")"); - } - } - else { - throw new exception(__METHOD__ .": invalid comment ID (". $id .")"); - } - - return($retval); - }//end get_comment_by_id() - //------------------------------------------------------------------------- - - -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-20 05:40:10
|
Revision: 4 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=4&view=rev Author: crazedsanity Date: 2009-02-20 05:40:04 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Import of cs-blogger v0.2, from which this project will be derived (cs-blogger is also my project; once some things are figured out, one will re-use code from the other to avoid code duplication). Added Paths: ----------- trunk/0.1/CREDITS trunk/0.1/LICENSE trunk/0.1/VERSION trunk/0.1/abstract/ trunk/0.1/abstract/csb_blog.abstract.class.php trunk/0.1/abstract/csb_dataLayer.abstract.class.php trunk/0.1/csb_blog.class.php trunk/0.1/csb_blogComment.class.php trunk/0.1/csb_blogEntry.class.php trunk/0.1/csb_blogLocation.class.php trunk/0.1/csb_blogUser.class.php trunk/0.1/csb_location.class.php trunk/0.1/csb_permission.class.php trunk/0.1/schema/ trunk/0.1/schema/pgsql.schema.sql Property Changed: ---------------- trunk/0.1/ Property changes on: trunk/0.1 ___________________________________________________________________ Added: svn:ignore + .project Added: trunk/0.1/CREDITS =================================================================== --- trunk/0.1/CREDITS (rev 0) +++ trunk/0.1/CREDITS 2009-02-20 05:40:04 UTC (rev 4) @@ -0,0 +1,3 @@ + +Lead Developer: Dan Falconer (cra...@us...) + Added: trunk/0.1/LICENSE =================================================================== --- trunk/0.1/LICENSE (rev 0) +++ trunk/0.1/LICENSE 2009-02-20 05:40:04 UTC (rev 4) @@ -0,0 +1,291 @@ +NOTE: a full HTML version of this license can be found at: +http://www.opensource.org/licenses/gpl-license.php + +It has been reproduced below without any HTML. +========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS Added: trunk/0.1/VERSION =================================================================== --- trunk/0.1/VERSION (rev 0) +++ trunk/0.1/VERSION 2009-02-20 05:40:04 UTC (rev 4) @@ -0,0 +1,5 @@ +## Stores the current version of cs-cms, and it's source. Please do NOT modify this file. + +VERSION: 0.1 +PROJECT: cs-blogger +$HeadURL$ \ No newline at end of file Property changes on: trunk/0.1/VERSION ___________________________________________________________________ Added: svn:keywords + HeadURL Added: trunk/0.1/abstract/csb_blog.abstract.class.php =================================================================== --- trunk/0.1/abstract/csb_blog.abstract.class.php (rev 0) +++ trunk/0.1/abstract/csb_blog.abstract.class.php 2009-02-20 05:40:04 UTC (rev 4) @@ -0,0 +1,456 @@ +<?php + +require_once(dirname(__FILE__) .'/csb_dataLayer.abstract.class.php'); + +class csb_blogAbstract extends csb_dataLayerAbstract { + + /** Internal name of blog (looks like a permalink) */ + protected $blogName; + + /** Displayable name of blog */ + protected $blogDisplayName; + + /** Numeric ID of blog */ + protected $blogId=false; + + /** Location of blog */ + protected $blogLocation; + + //------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $blogName (str) name of blog (NOT the display name) + * @param $dbType (str) Type of database (pgsql/mysql/sqlite) + * @param $dbParams (array) connection options for database + * + * @return exception throws an exception on error. + */ + public function __construct(array $dbParams=null) { + + //TODO: put these in the constructor args, or require CONSTANTS. + parent::__construct($dbParams); + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Initializes information about the selected blog. + * + * @param $blogName (str) name of blog (NOT the display name) + */ + public function initialize_locals($blogName) { + + if(!is_numeric($this->blogId)) { + $data = $this->get_blog_data_by_name($blogName); + + $var2index = array( + 'blogDisplayName' => 'blog_display_name', + 'blogName' => 'blog_name', + 'blogId' => 'blog_id', + 'blogLocation' => 'location' + ); + + foreach($var2index as $var=>$index) { + if(isset($data[$index]) && strlen($data[$index])) { + $this->$var = $data[$index]; + } + else { + throw new exception(__METHOD__ .": var ". $var ." not set from index ". $index .", no data (". $data[$index] .")"); + } + } + } + else { + throw new exception(__METHOD__ .": already initialized"); + } + }//end initialize_locals() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieves protected (or private?) internal var values + * + * @param $var (str) name of internal var to retrieve + * + * @return exception throws an exception if named var doesn't exist. + */ + public function get_internal_var($var) { + if(isset($this->$var)) { + $retval = $this->$var; + } + else { + throw new exception(__METHOD__ .": invalid var name (". $var .")"); + } + + return($retval); + }//end get_internal_var() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function is_initialized() { + $retval = false; + if(is_numeric($this->blogId)) { + $retval = true; + } + return($retval); + }//end is_initialized() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Creates a "permalink" just from title (does NOT include blog location): + * lowercases, strips special characters, uses "_" in place of spaces and + * special characters (NEVER creates more than one "_" in a row) + * + * @param $title (str) string to create permalink from. + * + * @return exception throws exception on error + * @return (string) permalink + */ + public function create_permalink_from_title($title) { + if(is_string($title) && strlen($title) >= CSBLOG_TITLE_MINLEN) { + + $permalink = strtolower($title); + $permalink = preg_replace('/!/', '', $permalink); + $permalink = preg_replace('/&\+/', '-', $permalink); + $permalink = preg_replace('/\'/', '', $permalink); + $permalink = preg_replace("/[^a-zA-Z0-9_]/", "_", $permalink); + + if(!strlen($permalink)) { + throw new exception(__METHOD__ .": invalid filename (". $permalink .") from title=(". $title .")"); + } + + //consolidate multiple underscores... (" . . ." becomes "______", after this becomes just "_") + $permalink = preg_replace('/__*/', '_', $permalink); + } + else { + throw new exception(__METHOD__ .": invalid title (". $title .")"); + } + + return($permalink); + }//end create_permalink_from_title() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Encodes content using base64 + * + * @param $content (str) content to encode + * + * @return (string) encoded content. + */ + public function encode_content($content) { + //make it base64 data, so it is easy to insert. + $retval = base64_encode($content); + return($retval); + }//end encode_content() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Decoded content (reverse of encode_content()) + * + * @param $content (str) Encoded content to decode + * + * @return (string) Decoded content. + */ + public function decode_content($content) { + $retval = base64_decode($content); + return($retval); + }//end decode_content() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieves all data about a blog (the main entry only) by its name. + * + * @param $blogName (str) name of blog (displayable or proper) + * + * @return exception throws exceptions on error + * @return (array) array of data about the blog. + */ + public function get_blog_data_by_name($blogName) { + if(strlen($blogName) > 3) { + $data = $this->get_blogs(array('b.blog_name'=>$blogName), 'blog_id'); + + if(count($data) == 1) { + $keys = array_keys($data); + $retval = $data[$keys[0]]; + } + else { + throw new exception(__METHOD__ .": too many records returned (". count($data) .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid blog name (". $blogName .")"); + } + + return($retval); + }//end get_blog_data_by_name() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Same as get_blog_data_by_name(), but use blog_id to find it. + * + * @param $blogId (int) blog_id to retrieve info for. + * + * @return exception throws exception on error + * @return (array) array of data about the blog. + */ + public function get_blog_data_by_id($blogId) { + + if(is_numeric($blogId) && $blogId > 0) { + $data = $this->get_blogs(array('blog_id'=>$blogId), 'blog_id'); + if(count($data) == 1) { + $keys = array_keys($data); + $retval = $data[$keys[0]]; + } + else { + throw new exception(__METHOD__ .": invalid number of records returned (". count($data) .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid blog id (". $blogId .")"); + } + + return($retval); + }//end get_blog_data_by_id() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Determines if there is one or more matching permalinks for the given + * blog; duplicates are given a suffix of "-N" (where "N" is the number of + * matching entries; first dup is given "-1", and so on). + * + * @param $blogId (int) blog_id for the permalink + * @param $permaLink (str) permalink to check + * + * @return exception thrown on error. + * @return + */ + public function check_permalink($blogId, $permalink) { + if(is_string($permalink) && strlen($permalink) >= CSBLOG_TITLE_MINLEN && is_numeric($blogId) && $blogId > 0) { + #if($permalink == $this->create_permalink_from_title($permalink)) { + $permalink = $this->create_permalink_from_title($permalink); + $sql = "SELECT * FROM csblog_entry_table WHERE blog_id=". $blogId + ." AND permalink='". $permalink ."' OR permalink LIKE '". $permalink ."-%'"; + + $numrows = $this->run_sql($sql, false); + + if($numrows >= 0) { + if($numrows >= 1) { + //got a record, give 'em the data back. + $retval = $permalink ."-". $numrows; + } + elseif($numrows == 0) { + $retval = $permalink; + } + else { + throw new exception(__METHOD__ .": unknown error, numrows=(". $numrows ."), dberror"); + } + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .") or dberror"); + } + } + else { + throw new exception(__METHOD__ .": invalid permalink (". $permalink .") or blog_id (". $blogId .")"); + } + + return($retval); + }//end check_permalink() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function get_age_hype($timestamp, $addBrackets=FALSE) { + if(strlen($timestamp >= 9)) { + if(!is_numeric($timestamp)) { + $timestamp = strtotime($timestamp); + } + + $age = time() - $timestamp; + switch($age) { + case ($age <= 1800): { + $extraText = '<font color="red"><b>Ink\'s still WET!</b></font>'; + } break; + + case ($age <= 3600): { + //modified less than an hour ago! + $extraText = '<font color="red"><b>Hot off the press!</b></font>'; + } break; + + case ($age <= 86400): { + //modified less than 24 hours ago. + $extraText = '<font color="red"><b>New!</b></font>'; + } break; + + case ($age <= 604800): { + //modified this week. + $extraText = '<font color="red">Less than a week old</font>'; + } break; + + case ($age <= 2592000): { + //modified this month. + $extraText = '<b>Less than a month old</b>'; + } break; + + case ($age <= 5184000): { + //modified in the last 2 months + $extraText = '<b>Updated last month</b>'; + } break; + + case ($age <= 7776000): { + $extraText = '<i>Updated 3 months ago</i>'; + } break; + + case ($age <= 10368000): { + $extraText = '<i>Updated 4 months ago</i>'; + } break; + + case ($age <= 12960000): { + $extraText = '<i>Updated 5 months ago</i>'; + } break; + + case ($age <= 15552000): { + $extraText = '<i>Updated in the last 6 months</i>'; + } break; + + default: { + $extraText = '<i>pretty old</i>'; + } + } + + if(strlen($extraText) && $addBrackets) { + $extraText = '['. $extraText .']'; + } + } + else { + throw new exception(__METHOD__ .": invalid timestamp (". $timestamp .")"); + } + + return($extraText); + }//end get_age_hype() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_most_recent_blog() { + $retval = $this->get_recent_blogs(1); + return($retval); + }//end get_most_recent_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_recent_blogs($limit=5, $offset=0, $includeDrafts=false) { + if(is_numeric($this->blogId)) { + if(is_numeric($limit) && $limit > 0) { + if(is_numeric($offset) && $offset >= 0) { + $criteria = array( + 'blog_id' => $this->blogId, + 'is_draft' => 'f' + ); + if($includeDrafts === true) { + unset($criteria['is_draft']); + } + $retval = $this->get_blog_entries($criteria, 'post_timestamp DESC', $limit, $offset); + } + else { + throw new exception(__METHOD__ .": invalid offset (". $offset .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid limit (". $limit .")"); + } + } + else { + throw new exception(__METHOD__ .": blogId not set"); + } + + return($retval); + }//end get_recent_blogs() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function get_full_permalink($permalink) { + if(!strlen($this->blogLocation)) { + throw new exception(__METHOD__ .": missing internal blogLocation (". $this->blogLocation .")"); + } + elseif(!strlen($this->blogName)) { + throw new exception(__METHOD__ .": missing internal blogName (". $this->blogName .")"); + } + elseif(!strlen($permalink)) { + throw new exception(__METHOD__ .": invalid/missing permalink (". $permalink .")"); + } + else { + $retval = $this->blogLocation .'/'. $this->blogName .'/'. $permalink; + } + + return($retval); + }//end get_full_permalink() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function parse_full_permalink($fullPermalink) { + + if(strlen($fullPermalink) && preg_match("/\//", $fullPermalink)) { + $fullPermalink = preg_replace("/^\//", "", $fullPermalink); + $parts = explode("/", $fullPermalink); + + if(count($parts) >= 3) { + $permalink = array_pop($parts); + $blogName = array_pop($parts); + $location = "/". $this->gfObj->string_from_array($parts, NULL, "/"); + + $retval = array( + 'location' => $location, + 'blogName' => $blogName, + 'permalink' => $permalink + ); + } + else { + throw new exception(__METHOD__ .": not enough parts (i.e. location, blogName, & permalink) in " . + "full permalink (". $fullPermalink .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid or non-full permalink given (". $fullPermalink .")"); + } + + return($retval); + }//end parse_full_permalink() + //------------------------------------------------------------------------- + + + +}// end blog{} +?> Added: trunk/0.1/abstract/csb_dataLayer.abstract.class.php =================================================================== --- trunk/0.1/abstract/csb_dataLayer.abstract.class.php (rev 0) +++ trunk/0.1/abstract/csb_dataLayer.abstract.class.php 2009-02-20 05:40:04 UTC (rev 4) @@ -0,0 +1,668 @@ +<?php + +require_once(dirname(__FILE__) .'/../../cs-content/cs_phpDB.class.php'); +require_once(dirname(__FILE__) .'/../../cs-content/cs_globalFunctions.class.php'); +require_once(dirname(__FILE__) .'/../../cs-versionparse/cs_version.abstract.class.php'); +require_once(dirname(__FILE__) .'/../csb_location.class.php'); +require_once(dirname(__FILE__) .'/../csb_permission.class.php'); + + +abstract class csb_dataLayerAbstract extends cs_versionAbstract { + + /** */ + protected $gfObj; + + /** */ + private $isConnected=false; + + /** */ + protected $dbParams; + + const DBTYPE='pgsql'; + + //------------------------------------------------------------------------- + /** + * Constructor (must be called from extending class) + * + * @param $dbType (str) type of database to connect to (pgsql/mysql/sqlite) + * @param $dbParams (array) list of connection parameters for selected db. + */ + function __construct(array $dbParams=NULL) { + $this->set_version_file_location(dirname(__FILE__) . '/../VERSION'); + $this->gfObj = new cs_globalFunctions(); + + //check that some required constants exist. + if(!defined('CSBLOG_TITLE_MINLEN')) { + define('CSBLOG_TITLE_MINLEN', 4); + } + + $this->dbParams = $dbParams; + $this->connect_db(); + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function connect_db() { + if($this->isConnected === false) { + if(is_array($this->dbParams)) { + $this->db = new cs_phpDB('pgsql'); + try { + $this->db->connect($this->dbParams); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to connect to database, DETAILS: ". $e->getMessage()); + } + + //NOTE: if the call to "connect()" fails, it should throw an exception. + $this->isConnected=true; + } + else { + //no parameters passed. Try using constants. + + $constantList = array( + 'CSBLOG_DB_HOST' => 'host', + 'CSBLOG_DB_PORT' => 'port', + 'CSBLOG_DB_DBNAME' => 'dbname', + 'CSBLOG_DB_USER' => 'user', + 'CSBLOG_DB_PASSWORD' => 'password' + ); + + $dbParams = array(); + foreach($constantList as $constant=>$index) { + $value = ''; + if(defined($constant)) { + $value = constant($constant); + } + else { + if($index != 'password') { + throw new exception(__METHOD__ .": missing one or more constants for database connectivity (". $constant .")"); + } + } + $dbParams[$index] = $value; + } + $this->db = new cs_phpDB('pgsql'); + try { + $this->db->connect($dbParams); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to connect to database using constants, DETAILS: ". $e->getMessage()); + } + + //NOTE: if the call to "connect()" fails, it should throw an exception. + $this->isConnected = true; + } + } + else { + $this->gfObj->debug_print(__METHOD__ .": already connected"); + } + }//end connect_db() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function run_sql($sql, $exceptionOnNoRows=true) { + //TODO: make EVERYTHING use this method, so it can automatically connect to the database. + if($this->isConnected !== true) { + $this->connect_db(); + } + + if($this->isConnected === true) { + if(is_string($sql) && strlen($sql)) { + + //run the statement & check the output. + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if($exceptionOnNoRows === true && $numrows <= 0 && !strlen($dberror)) { + throw new exception(__METHOD__ .": no rows returned (". $numrows .")"); + } + elseif(is_numeric($numrows) && !strlen($dberror)) { + $retval = $numrows; + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows ."), failed to run SQL... " . + "DBERROR: ". $dberror ."<BR>\nSQL::: ". $sql); + } + + } + else { + throw new exception(__METHOD__ .": no sql to run"); + } + } + else { + throw new exception(__METHOD__ .": database isn't connected"); + } + + return($retval); + }//end run_sql() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Loads data into blank (or existing) database. + * + * @param void (void) none + * + * @return exception throws exception on error + * @return (int) Number of records existing in auth table. + */ + public function run_setup() { + $retval = false; + $this->connect_db(); + $this->db->beginTrans(); + $fs = new cs_fileSystem(dirname(__FILE__) .'/../schema'); + $mySchema = $fs->read(self::DBTYPE .'.schema.sql'); + + $retval = $this->db->exec($mySchema); + + #$internalValues = $this->get_version(true); + #foreach($internalValues as $name=>$value) { + # $sql = "INSERT INTO csblog_internal_data_table (internal_name, internal_value) " . + # "VALUES ('". $name ."', '". $value ."')"; + # $this->run_sql($sql); + #} + + $retval = 1; + $this->db->commitTrans(); + return($retval); + }//end run_setup() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Create a user in the database. This assumes that the blogger is in + * complete control of authentication, so this doesn't work if an existing + * mechanism is already in place. + * + * @param $username (str) username to create + * @param $password (str) unencrypted password for the user + * + * @return exception throws exceptions on error + * @return (int) UID of new user + */ + public function create_user($username, $password) { + + $username = $this->gfObj->cleanString($username, 'email'); + if($username != func_get_arg(0)) { + throw new exception(__METHOD__ .": username contained invalid characters (". $username ." != ". func_get_arg(0) .")"); + } + + $existingUser = $this->get_uid($username); + + if($existingUser === false) { + $encryptedPass = md5($username .'-'. $password); + $sql = 'INSERT INTO cs_authentication_table (username, passwd) VALUES ' . + "('". $username ."', '". $encryptedPass ."')"; + + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $sql = "SELECT currval('cs_authentication_table_uid_seq')"; + + $numrows = $this->run_sql($sql); + if($numrows == 1) { + $data = $this->db->farray(); + $retval = $data[0]; + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .") while retrieving last inserted uid"); + } + } + else { + throw new exception(__METHOD__ .": failed insert (". $numrows ."): "); + } + } + else { + throw new exception(__METHOD__ .": user exists (". $username .")"); + } + + return($retval); + }//end create_user() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieve UID for the given username (i.e. for checking dups) + * + * @param $username (str) username to check + * + * @return exception throws exception on error + * @return false boolean FALSE returned if no user + * @return (int) UID for existing user + */ + public function get_user($username) { + + if(strlen($username) && is_string($username) && !is_numeric($username)) { + $username = $this->gfObj->cleanString($username, 'email'); + if($username != func_get_arg(0)) { + throw new exception(__METHOD__ .": username contained invalid characters (". $username ." != ". func_get_arg(0) .")"); + } + $sql = "SELECT * FROM cs_authentication_table WHERE username='". $username ."'"; + $numrows = $this->run_sql($sql, false); + + if($numrows == 1) { + $retval = $this->db->farray_fieldnames(); + } + elseif($numrows == 0) { + $retval = false; + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .")"); + } + } + else { + throw new exception(__METHOD__ .": invalid data for username (". $username .")"); + } + + return($retval); + }//end get_user() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_uid($username) { + $data = $this->get_user($username); + if(is_bool($data) && $data === false) { + $retval = $data; + } + else { + if(is_array($data) && isset($data['uid']) && is_numeric($data['uid'])) { + $retval = $data['uid']; + } + else { + throw new exception(__METHOD__ .": failed to locate uid column in return DATA::: ". $this->gfObj->debug_print($data,0)); + } + } + + return($retval); + }//end get_uid() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Creates new blog entry. + * + * @param $blogName (str) Display name of blog. + * @param $owner (str/int) UID of owner (username converted to uid) + * @param $location (str) location of blog + * + * @return exception throws exception on error + * @return (int) Newly created blog_id + */ + function create_blog($blogName, $owner, $location) { + if(!strlen($blogName)) { + throw new exception(__METHOD__ .": invalid blogName (". $blogName .")"); + } + elseif(!strlen($owner)) { + throw new exception(__METHOD__ .": invalid owner (". $owner .")"); + } + + if(!is_numeric($owner)) { + $username = $owner;//for later + $owner = $this->get_uid($owner); + if(!is_numeric($owner) || $owner < 1) { + throw new exception(__METHOD__ .": unable to find UID for user (". $username .")"); + } + } + + //attempt to get/create the location... + $loc = new csb_location($this->dbParams); + $locationId = $loc->get_location_id($location); + if(!is_numeric($locationId) || $locationId < 1) { + //TODO: should we really be creating this automatically? + $locationId = $loc->add_location($location); + } + + $formattedBlogName = $this->create_permalink_from_title($blogName); + $sql = "INSERT INTO csblog_blog_table ". $this->gfObj->string_from_array( + array( + 'blog_display_name' => $blogName, + 'blog_name' => $formattedBlogName, + 'uid' => $owner, + 'location_id' => $locationId + ), + 'insert', + NULL, + 'sql_insert' + ); + + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + //pull the blogId. + $retval = $this->db->get_currval('csblog_blog_table_blog_id_seq'); + + if(is_numeric($retval) && $retval > 0) { + //Initialize locals now, if it hasn't been done yet. + if(defined('CSBLOG_SETUP_PENDING') && !$this->is_initialized()) { + $this->initialize_locals($formattedBlogName); + } + } + else { + throw new exception(__METHOD__ .": new blog_id (". $retval .") is invalid"); + } + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows .") returned, ERROR: ". $this->db->errorMsg()); + } + + return($retval); + }//end create_blog() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Create new entry for existing blog. + * + * @param $blogId (int) blog_id to associate entry with. + * @param $authorUid (int) UID of author + * @param $title (str) Title of blog. + * @param $content (str) Contents of blog. + * @param $optionalData (array) optional items to specify (i.e. + * post_timestamp) + * + * @return exception throws an exception on error + * @return (array) Array of data, indexes explain values + */ + public function create_entry($blogId, $authorUid, $title, $content, array $optionalData=NULL) { + + //check to make sure we've got all the proper fields and they're formatted appropriately. + $sqlArr = array(); + $cleanStringArr = array( + 'blog_id' => "integer", + 'author_uid' => "integer", + 'title' => "sql", + 'content' => "sql", + 'permalink' => "email" + ); + if(is_numeric($blogId) && $blogId > 0) { + $sqlArr['blog_id'] = $blogId; + } + else { + throw new exception(__METHOD__ .": invalid data for blogId (". $blogId .")"); + } + if(is_numeric($authorUid) && $authorUid > 0) { + $sqlArr['author_uid'] = $authorUid; + } + else { + throw new exception(__METHOD__ .": invalid data for authorUid (". $authorUid .")"); + } + if(is_string($title) && strlen($title) > CSBLOG_TITLE_MINLEN) { + $sqlArr['title'] = $title; + } + else { + throw new exception(__METHOD__ .": invalid data for title (". $title .")"); + } + + //only allow a few other optional fields (make sure they're the appropriate data type). + if(is_array($optionalData) && count($optionalData)) { + + //Valid optional fields are defined here. + $validOptionalFields = array( + 'post_timestamp' => 'datetime', + 'is_draft' => 'boolean' + ); + + $intersectedArray = array_intersect_key($optionalData, $validOptionalFields); + + if(is_array($intersectedArray) && count($intersectedArray)) { + foreach($intersectedArray as $fieldName => $value) { + if(!isset($sqlArr[$fieldName])) { + $sqlArr[$fieldName] = $value; + $cleanStringArr[$fieldName] = $validOptionalFields[$fieldName]; + } + else { + throw new exception(__METHOD__ .": index (". $fieldName .") already exists"); + } + } + } + } + + + //lets check to see that there is NOT already a blog like this... + $permalink = $this->create_permalink_from_title($title); + $checkLink = $this->check_permalink($blogId, $title); + + if($checkLink != $permalink) { + $permalink = $checkLink; + } + //set some fields that can't be specified... + $sqlArr['permalink'] = $permalink; + $sqlArr['content'] = $this->encode_content($content); + + //build the SQL statement. + $sql = "INSERT INTO csblog_entry_table ". $this->gfObj->string_from_array($sqlArr, 'insert', NULL, $cleanStringArr); + + //run the statement & check the output. + $numrows = $this->run_sql($sql); + + if(is_numeric($numrows) && $numrows == 1) { + $blogData = $this->get_blog_data_by_id($blogId); + $retval = array( + 'entry_id' => $this->db->get_currval('csblog_entry_table_entry_id_seq'), + 'full_permalink' => $this->get_full_permalink($sqlArr['permalink']) + ); + + //one final thing: update the main blog table with the newest post_timestamp. + $this->update_blog_last_post_timestamps(); + } + else { + throw new exception(__METHOD__ .": invalid numrows (". $numrows ."), failed to insert data"); + } + + return($retval); + }//end create_entry) + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Retrieve a blog entry based on the FULL permalink (location included) + * + * @param $fullPermalink (str) Permalink (blog location + permalink) for + * entry. + * + * @return exception throws exception on error + * @return (array) Returns array of data, includes decoded content + */ + public function get_blog_entry($fullPermalink) { + //TODO: have this use get_blog_entries() + //the total permalink length should be at least double the minimum title length to include a path. + if(strlen($fullPermalink) > (CSBLOG_TITLE_MINLEN *2)) { + //now get the permalink separate from the title. + $parts = $this->parse_full_permalink($fullPermalink); + $permalink = $parts['permalink']; + $blogName = $parts['blogName']; + $location = $parts['location']; + + $criteria = array('bl.location'=>$location, 'b.blog_name'=>$blogName,'be.permalink'=>$permalink); + $data = $this->get_blog_entries($criteria,'be.entry_id'); + + if(count($data) == 1) { + $keys = array_keys($data); + $retval = $data[$keys[0]]; + } + elseif(count($data) > 1) { + throw new exception(__METHOD__ .": multiple records returned for same location (". count($data) .")"); + } + else { + throw new exception(__METHOD__ .": invalid number of records (". count($data) .") or dberror"); + } + } + else { + throw new exception(__METHOD__ .": failed to meet length requirement of ". (CSBLOG_TITLE_MINLEN *2)); + } + + return($retval); + }//end get_blog_entry() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_blog_entries(array $criteria, $orderBy, $limit=NULL, $offset=NULL) { + if(!is_array($criteria) || !count($criteria)) { + throw new exception(__METHOD__ .": invalid criteria"); + } + + //TODO: should be specifically limited to blogs that are accessible to current user. + $sql = "SELECT be.*, bl.location, b.blog_display_name, be.post_timestamp::date as date_short, " . + "b.blog_name, a.username FROM csblog_entry_table AS be INNER JOIN " . + "csblog_blog_table AS b ON (be.blog_id=b.blog_id) INNER JOIN " . + "csblog_location_table AS bl ON (b.location_id=bl.location_id) INNER JOIN " . + "cs_authentication_table AS a ON (a.uid=be.author_uid) WHERE "; + + //add stuff to the SQL... + foreach($criteria as $field=>$value) { + if(!preg_match('/^[a-z]{1,}\./', $field)) { + unset($criteria[$field]); + $field = "be.". $field; + $criteria[$field] = $value; + } + } + $sql .= $this->gfObj->string_from_array($criteria, 'select', NULL, 'sql'); + + if(strlen($orderBy)) { + $sql .= " ORDER BY ". $orderBy; + } + + if(is_numeric($limit) && $limit > 0) { + $sql .= " LIMIT ". $limit; + } + if(is_numeric($offset) && $limit > 0) { + $sql .= " OFFSET ". $offset; + } + + $numrows = $this->run_sql($sql); + + $retval = $this->db->farray_fieldnames('entry_id', true, false); + foreach($retval as $entryId=>$data) { + $retval[$entryId]['age_hype'] = $this->get_age_hype($data['post_timestamp']); + $retval[$entryId]['content'] = $this->decode_content($data['content']); + $retval[$entryId]['full_permalink'] = $this->get_full_permalink($data['permalink']); + + //make a formatted post_timestamp index. + $retval[$entryId]['formatted_post_timestamp'] = + strftime('%A, %B %d, %Y %I:%M %p', strtotime($data['post_timestamp'])); + + //format the username... + $retval[$entryId]['formatted_author_name'] = ucwords($data['username']); + + //make "is_draft" a real boolean. + $retval[$entryId]['is_draft'] = $this->gfObj->interpret_bool($data['is_draft']); + } + + return($retval); + }//end get_blog_entries() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_blogs(array $criteria, $orderBy=NULL, $limit=NULL, $offset=NULL) { + if(!is_array($criteria) || !count($criteria)) { + throw new exception(__METHOD__ .": invalid criteria"); + } + + //TODO: should be specifically limited to blogs that are accessible to current user. + $sql = "SELECT b.*, bl.location FROM csblog_blog_table AS b INNER JOIN " . + "csblog_location_table AS bl ON (b.location_id=bl.location_id) WHERE "; + + //add stuff to the SQL... + foreach($criteria as $field=>$value) { + if(!preg_match('/^[a-z]{1,}\./', $field)) { + unset($criteria[$field]); + $field = "b.". $field; + $criteria[$field] = $value; + } + } + $sql .= $this->gfObj->string_from_array($criteria, 'select', NULL, 'sql'); + + if(strlen($orderBy)) { + $sql .= " ORDER BY ". $orderBy; + } + else { + $sql .= " ORDER BY b.blog_id"; + } + + if(is_numeric($limit) && $limit > 0) { + $sql .= " LIMIT ". $limit; + } + if(is_numeric($offset) && $limit > 0) { + $sql .= " OFFSET ". $offset; + } + + $numrows = $this->run_sql($sql); + + $retval = $this->db->farray_fieldnames('blog_id', true, false); + + return($retval); + }//end get_blogs() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function update_blog_data(array $updates) { + $sql = "UPDATE csblog_blog_table SET ". + $this->gfObj->string_from_array($updates, 'update', null, 'sql') . + " WHERE blog_id=". $this->blogId; + + try { + $this->db->beginTrans(); + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $retval = $numrows; + $this->db->commitTrans(); + } + else { + throw new exception(__METHOD__ .": updated invalid number of rows (". $numrows .") - transaction aborted"); + } + } + catch(exception $e) { + $this->db->rollbackTrans(); + throw new exception(__METHOD__ .": failed to update blog (". $numrows .")"); + } + + return($retval); + }//end update_blog_data() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function update_blog_last_post_timestamps() { + $sql = "update csblog_blog_table AS b SET last_post_timestamp=" . + "(SELECT post_timestamp FROM csblog_entry_table WHERE " . + "blog_id=b.blog_id ORDER BY post_timestamp DESC limit 1)"; + + try { + $retval = $this->run_sql($sql); + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to update last_post_timestamp for blogs, DETAILS::: ". $e->getMessage()); + } + + return($retval); + }//end update_blog_last_post_timestamps() + //------------------------------------------------------------------------- + + +}//end dataLayerAbstract{} +?> Added: trunk/0.1/csb_blog.class.php =================================================================== --- trunk/0.1/csb_blog.class.php (rev 0) +++ trunk/0.1/csb_blog.class.php 2009-02-20 05:40:04 UTC (rev 4) @@ -0,0 +1,51 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); + +class csb_blog extends csb_blogAbstract { + + /** Internal name of blog (looks like a permalink) */ + protected $blogName; + + /** Displayable name of blog */ + protected $blogDisplayName; + + /** Numeric ID of blog */ + protected $blogId=false; + + /** Location of blog */ + protected $blogLocation; + + //------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $blogName (str) name of blog (NOT the display name) + * @param $dbType (str) Type of database (pgsql/mysql/sqlite) + * @param $dbParams (array) connection options for database + * + * @return exception throws an exception on error. + */ + public function __construct($blogName, array $dbParams=null) { + + //TODO: put these in the constructor args, or require CONSTANTS. + parent::__construct($dbParams); + + + if(!isset($blogName) || !strlen($blogName)) { + throw new exception(__METHOD__ .": invalid blog name (". $blogName .")"); + } + + $this->blogName = $blogName; + if(!defined('CSBLOG_SETUP_PENDING')) { + //proceed normally... + $this->initialize_locals($blogName); + } + + }//end __construct() + //------------------------------------------------------------------------- + + + +}// end blog{} +?> Added: trunk/0.1/csb_blogComment.class.php =================================================================== --- trunk/0.1/csb_blogComment.class.php (rev 0) +++ trunk/0.1/csb_blogComment.class.php 2009-02-20 05:40:04 UTC (rev 4) @@ -0,0 +1,185 @@ +<?php + +require_once(dirname(__FILE__) .'/abstract/csb_blog.abstract.class.php'); +require_once(dirname(__FILE__) .'/csb_blogEntry.class.php'); + +//TODO: consider moving add_comment() and get_comments() to csb_dataLayerAbstract{}, since they're data-type things. + +class csb_blogComment extends csb_blogAbstract { + + protected $blogEntryId; + + //------------------------------------------------------------------------- + public function __construct($fullPermalink, array $dbParams=NULL) { + + parent::__construct($dbParams); + + $blogData = $this->parse_full_permalink($fullPermalink); + + $this->blogLocation = $blogData['location']; + $this->blogName = $blogData['name']; + + }//end __construct() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function get_num_comments() { + $sql = "SELECT count(*) FROM csblog_comment_table WHERE entry_id=". $this->blogEntryId; + + try { + $numrows = $this->run_sql($sql); + + if($numrows = 1) { + $data = $this->db->farray(); + $retval = $data[0]; + } + else { + throw new exception(__METHOD__ .": failed to get number of comments, invalid numrows (". $numrows .")"); + } + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to retrieve number of comments, DETAILS::: ". $e->getMessage()); + } + + return($retval); + }//end get_num_comments() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + public function add_comment($authorUid, $title, $comment, array $ancestry=null, $isAnonymous=false) { + $sqlArr = array( + 'entry_id' => $this>blogEntryId, + 'title' => $title, + 'comment' => $this->encode_content($comment), + 'author_uid' => $authorUid, + 'is_anonymous' => $isAnonymous + ); + + $cleanArr = array( + 'entry_id' => 'numeric', + 'title' => 'sql', + 'comment' => 'sql', + 'author_uid' => 'numeric', + 'is_anonymous' => 'bool', + 'ancestry' => 'sql' + ); + + //handle ancestry, if given. + $ancestryStr = ""; + if(is_array($ancestry) && count($ancestry) > 0) { + foreach($ancestry as $id) { + if(is_numeric($id) && $id > 0) { + $ancestryStr = $this->gfObj->create_list($ancestryStr, $id, ':'); + } + else { + throw new exception(__METHOD__ .": invalid ancestor (". $id .")"); + } + } + $sqlArr['ancestry'] = $ancestryStr; + } + + $sql = "INSERT INTO csblog_comment_table ". $this->gfObj->string_from_array($sqlArr, 'insert', null, $cleanArr); + + try { + $this->db->beginTrans(); + $numrows = $this->run_sql($sql); + + if($numrows == 1) { + $retval = $this->db->get_currval('csblog_comment_table_comment_id_seq'); + $this->db->commitTrans(); + } + else { + $this->db->rollbackTrans(); + throw new exception(__METHOD__ .": failed to create record, invalid numrows (". $numrows .")"); + } + } + catch(exception $e) { + throw new exception(__METHOD__ .": failed to create comment, DETAILS::: ". $e->getMessage()); + } + + return($retval); + }//end add_comment() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + protected function get_comments(array $criteria, $orderBy=null, $limit=NULL, $offset=NULL) { + if(!is_array($criteria) || !count($criteria)) { + throw new exception(__METHOD__ .": invalid criteria"); + } + + //TODO: should be specifically limited to blogs that are accessible to current user. + $sql = "SELECT bc.*, be.permalink, bl.location, b.blog_display_name, be.post_timestamp::date as date_short, " . + "b.blog_name, b.blog_id FROM csblog_comment_table AS bc " . + "INNER JOIN csblog_entry_table AS be ON (be.entry_id=bc.entry_id) " . + "INNER JOIN csblog_blog_table AS b ON (be.blog_id=b.blog_id) " . + "INNER JOIN csblog_location_table AS bl ON (b.location_id=bl.location_id) " . + "WHERE "; + + //add stuff to the SQL... + foreach($criteria as $field=>$value) { + if(!preg_match('/^[a-z]{1,}\./', $field)) { + unset($criteria[$field]); + $field = "bc.". $field; + $cri... [truncated message content] |
From: <cra...@us...> - 2009-02-20 05:34:47
|
Revision: 3 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=3&view=rev Author: crazedsanity Date: 2009-02-20 05:34:42 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Initial version... Added Paths: ----------- trunk/0.1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-20 05:34:14
|
Revision: 2 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=2&view=rev Author: crazedsanity Date: 2009-02-20 05:34:09 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Release versions (subfolders in major.minor version notation) Added Paths: ----------- releases/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-20 05:33:33
|
Revision: 1 http://cs-cms.svn.sourceforge.net/cs-cms/?rev=1&view=rev Author: crazedsanity Date: 2009-02-20 05:33:28 +0000 (Fri, 20 Feb 2009) Log Message: ----------- For the bleeding-edge line of development. Added Paths: ----------- trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |