cs-webapplibs-commits Mailing List for CS Web Application Libraries
Status: Beta
Brought to you by:
crazedsanity
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(47) |
Sep
(8) |
Oct
(1) |
Nov
(3) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(3) |
Jun
(14) |
Jul
(5) |
Aug
|
Sep
(5) |
Oct
(2) |
Nov
|
Dec
|
| 2011 |
Jan
(15) |
Feb
(7) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(1) |
| 2012 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <cra...@us...> - 2012-03-01 04:09:47
|
Revision: 222
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=222&view=rev
Author: crazedsanity
Date: 2012-03-01 04:09:41 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
Added a sample configuration.
Added Paths:
-----------
trunk/current/sample_files/
trunk/current/sample_files/siteConfig.xml
Added: trunk/current/sample_files/siteConfig.xml
===================================================================
--- trunk/current/sample_files/siteConfig.xml (rev 0)
+++ trunk/current/sample_files/siteConfig.xml 2012-03-01 04:09:41 UTC (rev 222)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<main created="2008-12-18 10:21:00" updated="">
+ <website fix="sanitizeDirs">
+ <SITE_ROOT setglobal="1" setconstant="1" cleanpath="1">{_DIRNAMEOFFILE_}/..</SITE_ROOT>
+ <SITEROOT setglobal="1" setconstant="1">{SITE_ROOT}</SITEROOT>
+ <CS_RWDIR setglobal="1" setconstant="1">{SITE_ROOT}/rw</CS_RWDIR>
+ <RWDIR setglobal="1" setconstant="1">{CS_RWDIR}</RWDIR>
+ <DBTYPE setconstant="1">pgsql</DBTYPE>
+ <DB_PG_HOST setglobal="1" setconstant="1">127.0.0.1</DB_PG_HOST>
+ <DB_PG_DBNAME setglobal="1" setconstant="1">cs__test</DB_PG_DBNAME>
+ <DB_PG_PORT setglobal="1" setconstant="1">5432</DB_PG_PORT>
+ <DB_PG_DBUSER setglobal="1" setconstant="1">postgres</DB_PG_DBUSER>
+ <DB_PG_DBPASS setglobal="1" setconstant="1" />
+ <SESSION_MAX_IDLE setconstant="1" setglobal="1">12 days</SESSION_MAX_IDLE>
+ <SESSION_MAX_TIME setconstant="1">360 days</SESSION_MAX_TIME>
+ <LIBDIR setglobal="1" setconstant="1" parse="1">{SITE_ROOT}/lib</LIBDIR>
+ </website>
+ <cs-content>
+ <DEBUGPRINTOPT setglobal="1" setconstant="1">0</DEBUGPRINTOPT>
+ <WORKINGONIT setglobal="1" setconstant="1">0</WORKINGONIT>
+ <TMPLDIR setglobal="1" setconstant="1" parse="1">{/WEBSITE/SITE_ROOT}/templates</TMPLDIR>
+ <DEFAULT_SECTION setconstant='1'>/content</DEFAULT_SECTION>
+ <ALLOWUNITTESTDBCREATE setconstant='1'>1</ALLOWUNITTESTDBCREATE>
+ <SESSION_NAME setconstant="1">CS_SESSID</SESSION_NAME>
+ <SESSION_DBSAVE setconstant="1" note="Value indicates name of cookie">{/CS-CONTENT/SESSION_NAME}</SESSION_DBSAVE>
+ <session_dbsave_uidpath setconstant="1">/auth/userInfo/uid</session_dbsave_uidpath>
+ <session_db_host setconstant="1">{WEBSITE/DB_PG_HOST}</session_db_host>
+ <session_db_port setconstant="1">{WEBSITE/DB_PG_PORT}</session_db_port>
+ <session_db_dbname setconstant="1">{WEBSITE/DB_PG_DBNAME}</session_db_dbname>
+ <session_db_user setconstant="1">{WEBSITE/DB_PG_DBUSER}</session_db_user>
+ <session_db_password setconstant="1">{WEBSITE/DB_PG_DBPASS}</session_db_password>
+ <autoload_hints setconstant="1">{/WEBSITE/LIBDIR}/class.hints</autoload_hints>
+ </cs-content>
+ <cs-webupgradedb>
+ <db_table setconstant="1" setconstantprefix="cs_webapplibs">cs_version_table</db_table>
+ <db_primarykey setconstant="1" setconstantprefix="cs_webapplibs">project_id</db_primarykey>
+ <db_sequence setconstant="1" setconstantprefix="cs_webapplibs">{DB_TABLE}_{DB_PRIMARYKEY}_seq</db_sequence>
+ <db_connect_host setconstant="1" setconstantprefix="cs_webapplibs">{/WEBSITE/DB_PG_HOST}</db_connect_host>
+ <db_connect_port setconstant="1" setconstantprefix="cs_webapplibs">{/WEBSITE/DB_PG_PORT}</db_connect_port>
+ <db_connect_dbname setconstant="1" setconstantprefix="cs_webapplibs">{WEBSITE/DB_PG_DBNAME}</db_connect_dbname>
+ <db_connect_user setconstant="1" setconstantprefix="cs_webapplibs">{WEBSITE/DB_PG_DBUSER}</db_connect_user>
+ <db_connect_password setconstant="1" setconstantprefix="cs_webapplibs">{WEBSITE/DB_PG_DBPASS}</db_connect_password>
+ <CONFIG_FILE_LOCATION setconstant="1" setconstantprefix="cs_webapplibs">{_CONFIGFILE_}</CONFIG_FILE_LOCATION>
+ <UPGRADE_CONFIG_FILE setconstant="1" setconstantprefix="cs_webapplibs">{SITE_ROOT}/upgrade/upgrade.xml</UPGRADE_CONFIG_FILE>
+ <RWDIR setconstant="1" setconstantprefix="cs_webdbupgrade">{WEBSITE/RWDIR}</RWDIR>
+ </cs-webupgradedb>
+ <cs-project note="This is just a SAMPLE of what else could be here.">
+ <api_authtoken>9dx6f9275dg5972c65e5a5f2366662b7</api_authtoken>
+ </cs-project>
+ <cs-blogger>
+ <cs_blogrwdir setconstant="1">{WEBSITE/CS_RWDIR}/blogger</cs_blogrwdir>
+ <cs_blogimgurl setconstant="1">/images/blog/</cs_blogimgurl>
+ <cs_blogimgdir setconstant="1">{WEBSITE/SITE_ROOT}/public_html/{CS_BLOGIMGURL}</cs_blogimgdir>
+ <cs_authdbname setconstant="1">main.db</cs_authdbname>
+ <cs_blogdbname setconstant="1">main.db</cs_blogdbname>
+ <csblog_db_host setconstant="1">{WEBSITE/DB_PG_HOST}</csblog_db_host>
+ <csblog_db_port setconstant="1">{WEBSITE/DB_PG_PORT}</csblog_db_port>
+ <csblog_db_dbname setconstant="1">{WEBSITE/DB_PG_DBNAME}</csblog_db_dbname>
+ <csblog_db_user setconstant="1">{WEBSITE/DB_PG_DBUSER}</csblog_db_user>
+ <csblog_db_password setconstant="1">{WEBSITE/DB_PG_DBPASS}</csblog_db_password>
+ </cs-blogger>
+ <cs-rssdb>
+ <RSS_FILES_DIR setconstant="1">{WEBSITE/CS_RWDIR}/rss_feeds</RSS_FILES_DIR>
+ <CSRSS_DB_HOST setconstant="1">{WEBSITE/DB_PG_HOST}</CSRSS_DB_HOST>
+ <CSRSS_DB_PORT setconstant="1">{WEBSITE/DB_PG_PORT}</CSRSS_DB_PORT>
+ <CSRSS_DB_DBNAME setconstant="1">{WEBSITE/DB_PG_DBNAME}</CSRSS_DB_DBNAME>
+ <CSRSS_DB_USER setconstant="1">{WEBSITE/DB_PG_DBUSER}</CSRSS_DB_USER>
+ <CSRSS_DB_PASSWORD setconstant="1">{WEBSITE/DB_PG_DBPASS}</CSRSS_DB_PASSWORD>
+ </cs-rssdb>
+ <cs-clilogger>
+ <CLI_DBTYPE setconstant="1">pgsql</CLI_DBTYPE>
+ <CLI_DB_HOST setconstant="1">{WEBSITE/DB_PG_HOST}</CLI_DB_HOST>
+ <CLI_DB_PORT setconstant="1">{WEBSITE/DB_PG_PORT}</CLI_DB_PORT>
+ <CLI_DB_DBNAME setconstant="1">{WEBSITE/DB_PG_DBNAME}</CLI_DB_DBNAME>
+ <CLI_DB_USER setconstant="1">{WEBSITE/DB_PG_DBUSER}</CLI_DB_USER>
+ <CLI_DB_PASSWORD setconstant="1">{WEBSITE/DB_PG_DBPASS}</CLI_DB_PASSWORD>
+ </cs-clilogger>
+</main>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2012-01-10 22:53:47
|
Revision: 221
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=221&view=rev
Author: crazedsanity
Date: 2012-01-10 22:53:41 +0000 (Tue, 10 Jan 2012)
Log Message:
-----------
Minor changes for testing COMET applications...
Modified Paths:
--------------
trunk/current/cs_webdblogger.class.php
Modified: trunk/current/cs_webdblogger.class.php
===================================================================
--- trunk/current/cs_webdblogger.class.php 2011-12-14 05:57:13 UTC (rev 220)
+++ trunk/current/cs_webdblogger.class.php 2012-01-10 22:53:41 UTC (rev 221)
@@ -79,6 +79,8 @@
'logAttrib' => "cswal_log_attribute_table_log_attribute_id_seq"
);
+ public $cometDebug = "NONE";
+
//=========================================================================
/**
* The constructor.
@@ -439,7 +441,8 @@
/**
* Retrieves logs with the given criteria.
*/
- public function get_logs(array $criteria, array $orderBy=NULL, $limit=20) {
+ public function get_logs(array $criteria, array $orderBy=NULL, $limit=20, $greaterThanLogId=null) {
+ $originalCrit = $criteria;
//set a default for the limit.
if(!is_numeric($limit) || $limit < 1) {
//set it again.
@@ -471,6 +474,9 @@
$myFieldData = $allowedCritFields[$field];
$cleanStringArg = $myFieldData[1];
+ //set the prefixed column name.
+ $prefixedName = $myFieldData[0] .'.'. $field;
+
//clean the data.
if($field == 'creation' && is_numeric($value)) {
$value = $this->gfObj->cleanString($value, 'numeric');
@@ -480,9 +486,6 @@
$cleanedData = $this->gfObj->cleanString($value, $cleanStringArg);
}
- //set the prefixed column name.
- $prefixedName = $myFieldData[0] .'.'. $field;
-
//now add it to our array.
$sqlArr[$prefixedName] = $cleanedData;
}
@@ -490,7 +493,10 @@
//build the criteria.
- $sqlArr['ca.category_id'] = '>0';
+ if(!isset($sqlArr['ca.category_id'])) {
+ $sqlArr['ca.category_id'] = '>0';
+ $cleanStringArr['ca.category_id'] = "select";
+ }
$critString = $this->gfObj->string_from_array($sqlArr, 'select');
//check if "timeperiod" is in there (it's special)
@@ -500,6 +506,9 @@
$addThis = "(l.creation >= '". $myTime['start'] ."'::date AND l.creation <= '". $myTime['end'] ."'::date + interval '1 day')";
$critString = create_list($critString, $addThis, ' AND ');
}
+ if(!is_null($greaterThanLogId) && is_numeric($greaterThanLogId)) {
+ $critString = $this->gfObj->create_list($critString, "log_id > ". $greaterThanLogId, ' AND ');
+ }
$orderString = $this->gfObj->string_from_array($orderBy, 'limit');
$sql = "select " .
@@ -521,6 +530,10 @@
try {
//run it.
+ $this->cometDebug = array(
+ 'criteria' => $criteria,
+ 'sql' => $sql
+ );
$data = $this->db->run_query($sql, 'log_id');
$retval = array();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-12-14 05:57:21
|
Revision: 220
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=220&view=rev
Author: crazedsanity
Date: 2011-12-14 05:57:13 +0000 (Wed, 14 Dec 2011)
Log Message:
-----------
*** RELEASE 0.4.1 ***
Summary of changes:
* remove unused (empty) classes (e.g. cs_idPath)
* drop support for MySQL (not supported by most modules)
* provides FULL authentication system including necessary authentication information tables
* permission system uses regular paths (instead of obscure ID-based paths)
* updated unit tests (not complete, but better; problematic if database isn't localhost with default settings)
* session DB no longer attempts to populate user ID ("uid" or "user_id") for simplicity
* upgrade scripts for 0.4.0 to 0.4.1 (handles schema changes)
* better examples for upgrades
* minor changes to DB abstraction layer (cs_phpDB) for better errors & file-based logging)
NOTES:::
MySQL support was dropped due to lack of time to test changes. All it actually takes to support it is just to translate the "setup/schema.pgsql.sql" file into "setup/schema.mysql.sql" again with proper MySQL syntax. I simply don't have time to test those changes, and newer modules didn't support it at all anyway.
IF YOU'D LIKE MySQL SUPPORT: please consider donating to the project, or directing talented developers to the project that can handle creating & updating the MySQL schema.
Modified Paths:
--------------
trunk/current/VERSION
trunk/current/cs_genericPermission.class.php
trunk/current/cs_phpDB.class.php
trunk/current/cs_sessionDB.class.php
trunk/current/cs_webdblogger.class.php
trunk/current/setup/genericPermissions.pgsql.sql
trunk/current/setup/schema.pgsql.sql
trunk/current/tests/testOfCSGenericPermissions.php
trunk/current/upgrades/upgrade.xml
Added Paths:
-----------
trunk/current/upgrades/exampleUpgradeScript.php
trunk/current/upgrades/schemaChangesFor_0.4.1.sql
trunk/current/upgrades/upgradeTo0.4.1.php
Removed Paths:
-------------
trunk/current/cs_idPath.class.php
trunk/current/setup/schema.mysql.sql
Property Changed:
----------------
trunk/current/cs_sessionDB.class.php
Modified: trunk/current/VERSION
===================================================================
--- trunk/current/VERSION 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/VERSION 2011-12-14 05:57:13 UTC (rev 220)
@@ -1,7 +1,7 @@
## Stores the current version of the cs-versionparse system, and it's source.
## Please do NOT modify this file.
-VERSION: 0.4.0
+VERSION: 0.4.1
PROJECT: cs-webapplibs
$HeadURL$
Modified: trunk/current/cs_genericPermission.class.php
===================================================================
--- trunk/current/cs_genericPermission.class.php 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/cs_genericPermission.class.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -11,7 +11,7 @@
* $LastChangedRevision$
*/
-class cs_genericPermission extends cs_genericObjectAbstract {
+class cs_genericPermission extends cs_genericUserGroupAbstract {
/** Database object. */
public $db;
@@ -28,9 +28,6 @@
/** List of valid keys... */
protected $keys = array();
- /** Determine object path pieces based on this... */
- protected $objectDelimiter="/";
-
/** How to clean the path (if at all); boolean true = use cs_globalFunctions::clean_url(); boolean false will
cause it to not be cleaned at all; a string will use cs_globalFunctions::cleanString({string})*/
protected $pathCleaner=true;
@@ -42,7 +39,7 @@
/**
* Generic permission system based on *nix filesystem permissions.
*/
- public function __construct(cs_phpDB $db, $objectDelimiter=NULL, $useUrlCleaner=true) {
+ public function __construct(cs_phpDB $db, $useUrlCleaner=true) {
$this->db = $db;
parent::__construct($db);
$this->gfObj = new cs_globalFunctions;
@@ -57,15 +54,12 @@
7 => 'o_w',
8 => 'o_x'
);
- if(!is_null($objectDelimiter) && is_string($objectDelimiter) && strlen($objectDelimiter)) {
- $this->objectDelimiter=$objectDelimiter;
- }
if(is_bool($useUrlCleaner) || (is_string($useUrlCleaner) && strlen($useUrlCleaner))) {
$this->pathCleaner = $useUrlCleaner;
}
$cleanString = array(
'system_name' => 'integer',
- 'object_path' => 'email_plus',
+ 'path' => 'email_plus',
'user_id' => 'integer',
'group_id' => 'integer',
'inherit' => 'bool',
@@ -130,6 +124,7 @@
* Create permission string based on an array (the opposite of parse_permission_string())
*/
protected function build_permission_string(array $perms) {
+cs_debug_backtrace(1);
$this->_sanityCheck();
//NOTE:: the incoming $perms must have more (or equal) items vs. $this->keys so that it can accept arrays with extra
@@ -174,7 +169,7 @@
if(is_string($name) && strlen($name) && is_numeric($userId) && $userId >= 0 && is_numeric($groupId) && $groupId >= 0) {
try{
$insertArr = $this->parse_permission_string($permString);
- $insertArr['id_path'] = $this->create_id_path($name);
+ $insertArr['path'] = $name;
$insertArr['user_id'] = $userId;
$insertArr['group_id'] = $groupId;
@@ -200,13 +195,10 @@
*/
public function get_permission($name) {
try {
- if(!$this->is_id_path($name)) {
- $name = $this->create_id_path($name);
- }
- $retval = $this->dbTableHandler->get_single_record(array('id_path'=>$name));
+ $retval = $this->dbTableHandler->get_single_record(array('path'=>$name));
+$this->gfObj->debug_var_dump($retval,1);
//now translate the object_path...
- $retval['object_path'] = $this->translate_id_path($retval['id_path']);
$retval['perm_string'] = $this->build_permission_string($retval);
}
catch(Exception $e) {
@@ -246,10 +238,7 @@
/**
* Check available permissions...
*/
- public function check_permission($objectName, $userId) {
- if(!$this->is_id_path($objectName)) {
- $objectName = $this->create_id_path($objectName,false);
- }
+ public function check_permission($path, $userId) {
$availablePerms = array(
'r' => false,
'w' => false,
@@ -258,7 +247,7 @@
try {
//get the object.
- $permission = $this->get_permission($objectName);
+ $permission = $this->get_permission($path);
//now figure out what permissions they have.
if($permission['user_id'] == $userId) {
@@ -399,41 +388,6 @@
//============================================================================
- public function explode_path($path) {
- if(is_string($path) && strlen($path)) {
- $path = preg_replace('/^'. addcslashes($this->objectDelimiter, '/') .'/', '', $path);
- $path = preg_replace('/'. addcslashes($this->objectDelimiter, '/') .'{2,}/', $this->objectDelimiter, $path);
- $bits = explode($this->objectDelimiter, $path);
-#$this->gfObj->debug_print(__METHOD__ .": path=(". $path ."), bits::: ". $this->gfObj->debug_print($bits,0,1));
- }
- else {
- throw new exception(__METHOD__ .": invalid path (". $path .")");
- }
- return($bits);
- }//end explode_path()
- //============================================================================
-
-
-
- //============================================================================
- public function create_id_path($path) {
- //Get the list of objects from the path.
- $bits = $this->explode_path($path);
-
- //now create the path.
- $newPath = $this->create_id_path_from_objects($bits);
-#$this->gfObj->debug_print(__METHOD__ .": newPath=(". $newPath ."), bits::: ". $this->gfObj->debug_print($bits,0,1));
- if(!$this->is_id_path($newPath)) {
- throw new exception(__METHOD__ .": failed to create ID path from (". $path .")");
- }
-
- return($newPath);
- }//end create_id_path()
- //============================================================================
-
-
-
- //============================================================================
public function update_permission() {
}//end update_permission()
//============================================================================
Deleted: trunk/current/cs_idPath.class.php
===================================================================
--- trunk/current/cs_idPath.class.php 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/cs_idPath.class.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -1,26 +0,0 @@
-<?php
-/*
- * Created on January 26, 2011
- *
- * FILE INFORMATION:
- *
- * $HeadURL$
- * $Id$
- * $LastChangedDate$
- * $LastChangedBy$
- * $LastChangedRevision$
- */
-
-class cs_idPath extends cs_webapplibsAbstract {
-
- /** cs_globalFunctions object, for cleaning strings & such. */
- public $gfObj;
-
- //============================================================================
- /**
- */
- public function __construct() {
- }//end __construct()
- //============================================================================
-
-}
Modified: trunk/current/cs_phpDB.class.php
===================================================================
--- trunk/current/cs_phpDB.class.php 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/cs_phpDB.class.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -46,7 +46,7 @@
*/
public function __construct($type='pgsql', $writeCommandsToFile=null) {
- if(is_null($type) || !strlen($type)) {
+ if(is_null($type) || !strlen($type) || !is_string($type)) {
$type = 'pgsql';
}
@@ -69,7 +69,7 @@
$this->fsObj = new cs_fileSystem(constant('RWDIR'));
$lsData = $this->fsObj->ls();
if(!isset($lsData[$this->logFile])) {
- $this->fsObj->create_file($this->logFile);
+ $this->fsObj->create_file($this->logFile, true);
}
$this->fsObj->openFile($this->logFile, 'a');
}
@@ -103,7 +103,7 @@
$retval = call_user_func_array(array($this->dbLayerObj, $methodName), $args);
}
else {
- throw new exception(__METHOD__ .': unsupported method ('. $methodName .') for database of type ('. $this->dbType .')');
+ throw new exception(__METHOD__ .': uninitialized ('. $this->isInitialized .'), no database layer ('. is_object($this->dbLayerObj) .'), or unsupported method ('. $methodName .') for database of type ('. $this->dbType .')');
}
return($retval);
}//end __call()
Modified: trunk/current/cs_sessionDB.class.php
===================================================================
--- trunk/current/cs_sessionDB.class.php 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/cs_sessionDB.class.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -190,26 +190,13 @@
public function sessdb_write($sid, $data) {
if(is_string($sid) && strlen($sid) >= 20) {
$data = array(
- 'session_data' => $data,
- 'user_id' => null
+ 'session_data' => $data
);
$cleanString = array(
'session_data' => 'sql',
- 'user_id' => 'numeric'
+ 'uid' => 'numeric'
);
-
-
- //pull the uid out of the session...
- if(defined('SESSION_DBSAVE_UIDPATH')) {
- $a2p = new cs_arrayToPath($_SESSION);
- $uidVal = $a2p->get_data(constant('SESSION_DBSAVE_UIDPATH'));
-
- if(is_string($uidVal) || is_numeric($uidVal)) {
- $data['user_id'] = $uidVal;
- }
- }
-
$afterSql = "";
if($this->is_valid_sid($sid)) {
$type = 'update';
@@ -231,7 +218,6 @@
$res = $this->db->$funcName($sql, $secondArg);
}
catch(exception $e) {
- //umm... yeah.
$this->exception_handler(__METHOD__ .": failed to perform action (". $type ."), sid=(". $sid ."), sid length=(". strlen($sid) ."), validSid=(". $this->is_valid_sid($sid) .")::: ". $e->getMessage());
}
}
Property changes on: trunk/current/cs_sessionDB.class.php
___________________________________________________________________
Deleted: svn:executable
- *
Modified: trunk/current/cs_webdblogger.class.php
===================================================================
--- trunk/current/cs_webdblogger.class.php 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/cs_webdblogger.class.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -21,8 +21,7 @@
* too many id's that might need to be changed later. Yay, dynamic code!
*
* QUERY TO GET LAST COUPLE OF LOGS::::
- SELECT l.log_id as id, l.creation, l.event_id as lid, le.description AS event, l.details
- FROM cswal_log_table AS l INNER JOIN cswal_event_table AS le USING (event_id) ORDER BY log_id DESC LIMIT 25;
+ SELECT l.log_id as id, l.creation, l.event_id as lid, le.description AS event, l.details FROM cswal_log_table AS l INNER JOIN cswal_event_table AS le USING (event_id) ORDER BY log_id DESC LIMIT 25;
*/
//NOTE::: this class **REQUIRES** cs-content for its "cs_phpDB" class.
Modified: trunk/current/setup/genericPermissions.pgsql.sql
===================================================================
--- trunk/current/setup/genericPermissions.pgsql.sql 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/setup/genericPermissions.pgsql.sql 2011-12-14 05:57:13 UTC (rev 220)
@@ -37,33 +37,20 @@
);
---
--- Object table
--- Unique set of names which should be chained together to create an object path; for a URL of "/member/blog/edit", the pieces would be created
--- with ID's, such as "member"=1, "blog"=2, "edit"=3; the object path would then be ":1::2::3:".
--
-CREATE TABLE cswal_object_table (
- object_id serial NOT NULL PRIMARY KEY,
- object_name text NOT NULL UNIQUE,
- created TIMESTAMPTZ NOT NULL DEFAULT NOW()
-);
-
-
---
-- Permission table
--- Contains unique list of object paths along with the owner, default group, & user/group/other permissions (like *nix filesystem permissions)
--- The permissions for user/group/other could be converted to octal (i.e. "rwxrwxrwx" == "777"), but it isn't as straightforward to read.
+-- Contains paths along with the owner, default group, & user/group/other
+-- permissions (like *nix filesystem permissions) The permissions for
+-- user/group/other could be converted to octal (i.e. "rwxrwxrwx" == "777"),
+-- but it isn't as straightforward to read.
-- NOTE::: the "user_id" table should be updated to match your database schema.
--- NOTE2:: the "inherit" column isn't used by the base permissions system.
--- NOTE3:: the "object_path" is a chain of object_id's.
--
CREATE TABLE cswal_permission_table (
permission_id serial NOT NULL PRIMARY KEY,
system_name integer NOT NULL DEFAULT 0 REFERENCES cswal_system_table(system_id),
- id_path text NOT NULL,
+ path text NOT NULL,
user_id integer NOT NULL REFERENCES cs_authentication_table(uid),
group_id integer NOT NULL REFERENCES cswal_group_table(group_id),
- inherit boolean NOT NULL DEFAULT FALSE,
u_r boolean NOT NULL DEFAULT TRUE,
u_w boolean NOT NULL DEFAULT TRUE,
u_x boolean NOT NULL DEFAULT FALSE,
@@ -79,5 +66,5 @@
INSERT INTO cswal_system_table (system_id, system_name) VALUES (0, 'DEFAULT');
ALTER TABLE ONLY cswal_permission_table
- ADD CONSTRAINT cswal_permission_table_system_path_key UNIQUE (system_name, id_path);
+ ADD CONSTRAINT cswal_permission_table_system_path_key UNIQUE (system_name, path);
Deleted: trunk/current/setup/schema.mysql.sql
===================================================================
--- trunk/current/setup/schema.mysql.sql 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/setup/schema.mysql.sql 2011-12-14 05:57:13 UTC (rev 220)
@@ -1,192 +0,0 @@
--- phpMyAdmin SQL Dump
--- version 2.10.3
--- http://www.phpmyadmin.net
---
--- Generation Time: Aug 26, 2009 at 12:54 PM
--- Server version: 5.0.22
--- PHP Version: 5.1.6
-
-SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_attribute_table`
---
-
-CREATE TABLE `cswal_attribute_table` (
- `attribute_id` int(11) NOT NULL auto_increment,
- `attribute_name` text NOT NULL,
- PRIMARY KEY (`attribute_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_auth_token_table`
---
-
-CREATE TABLE `cswal_auth_token_table` (
- `auth_token_id` bigint(20) unsigned NOT NULL auto_increment,
- `uid` int(11) NOT NULL default '0',
- `checksum` text NOT NULL,
- `token` text NOT NULL,
- `max_uses` int(11) default NULL,
- `total_uses` int(11) NOT NULL default '0',
- `creation` timestamp NOT NULL default CURRENT_TIMESTAMP,
- `last_updated` timestamp NOT NULL default '0000-00-00 00:00:00',
- `expiration` timestamp NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (`auth_token_id`),
- UNIQUE KEY `auth_token_id` (`auth_token_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_category_table`
---
-
-CREATE TABLE `cswal_category_table` (
- `category_id` int(11) NOT NULL auto_increment,
- `category_name` text NOT NULL,
- PRIMARY KEY (`category_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_class_table`
---
-
-CREATE TABLE `cswal_class_table` (
- `class_id` int(11) NOT NULL auto_increment,
- `class_name` text NOT NULL,
- PRIMARY KEY (`class_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_event_table`
---
-
-CREATE TABLE `cswal_event_table` (
- `event_id` int(11) NOT NULL auto_increment,
- `class_id` int(11) NOT NULL,
- `category_id` int(11) NOT NULL,
- `description` text NOT NULL,
- PRIMARY KEY (`event_id`),
- KEY `cswal_event_table_class_id_fkey` (`class_id`),
- KEY `cswal_event_table_category_id_fkey` (`category_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
---
--- RELATIONS FOR TABLE `cswal_event_table`:
--- `class_id`
--- `cswal_class_table` -> `class_id`
--- `category_id`
--- `cswal_category_table` -> `category_id`
---
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_log_attribute_table`
---
-
-CREATE TABLE `cswal_log_attribute_table` (
- `log_attribute_id` int(11) NOT NULL auto_increment,
- `log_id` int(11) NOT NULL,
- `attribute_id` int(11) NOT NULL,
- `value_text` text NOT NULL,
- PRIMARY KEY (`log_attribute_id`),
- KEY `cswal_log_attribute_table_log_id_fkey` (`log_id`),
- KEY `cswal_log_attribute_table_attribute_id_fkey` (`attribute_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
---
--- RELATIONS FOR TABLE `cswal_log_attribute_table`:
--- `attribute_id`
--- `cswal_attribute_table` -> `attribute_id`
--- `log_id`
--- `cswal_log_table` -> `log_id`
---
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_log_table`
---
-
-CREATE TABLE `cswal_log_table` (
- `log_id` int(11) NOT NULL auto_increment,
- `creation` timestamp NOT NULL default CURRENT_TIMESTAMP,
- `event_id` int(11) NOT NULL,
- `uid` int(11) NOT NULL,
- `affected_uid` int(11) NOT NULL,
- `details` text NOT NULL,
- PRIMARY KEY (`log_id`),
- KEY `cswal_log_table_event_id_fkey` (`event_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
---
--- RELATIONS FOR TABLE `cswal_log_table`:
--- `event_id`
--- `cswal_event_table` -> `event_id`
---
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_session_store_table`
---
-
-CREATE TABLE `cswal_session_store_table` (
- `session_store_id` int(11) NOT NULL auto_increment,
- `session_id` varchar(32) NOT NULL,
- `user_id` varchar(16) NOT NULL,
- `date_created` datetime NOT NULL,
- `last_updated` datetime NOT NULL,
- `session_data` longtext NOT NULL,
- PRIMARY KEY (`session_store_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
--- --------------------------------------------------------
-
---
--- Table structure for table `cswal_version_table`
---
-
-CREATE TABLE `cswal_version_table` (
- `version_id` int(11) NOT NULL auto_increment,
- `project_name` varchar(30) NOT NULL,
- `version_string` varchar(50) NOT NULL,
- PRIMARY KEY (`version_id`),
- UNIQUE KEY `project_name` (`project_name`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
-
---
--- Constraints for dumped tables
---
-
---
--- Constraints for table `cswal_event_table`
---
-ALTER TABLE `cswal_event_table`
- ADD CONSTRAINT `cswal_event_table_class_id_fkey` FOREIGN KEY (`class_id`) REFERENCES `cswal_class_table` (`class_id`),
- ADD CONSTRAINT `cswal_event_table_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cswal_category_table` (`category_id`);
-
---
--- Constraints for table `cswal_log_attribute_table`
---
-ALTER TABLE `cswal_log_attribute_table`
- ADD CONSTRAINT `cswal_log_attribute_table_attribute_id_fkey` FOREIGN KEY (`attribute_id`) REFERENCES `cswal_attribute_table` (`attribute_id`),
- ADD CONSTRAINT `cswal_log_attribute_table_log_id_fkey` FOREIGN KEY (`log_id`) REFERENCES `cswal_log_table` (`log_id`);
-
---
--- Constraints for table `cswal_log_table`
---
-ALTER TABLE `cswal_log_table`
- ADD CONSTRAINT `cswal_log_table_event_id_fkey` FOREIGN KEY (`event_id`) REFERENCES `cswal_event_table` (`event_id`);
Modified: trunk/current/setup/schema.pgsql.sql
===================================================================
--- trunk/current/setup/schema.pgsql.sql 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/setup/schema.pgsql.sql 2011-12-14 05:57:13 UTC (rev 220)
@@ -8,7 +8,26 @@
-- Last Updated:::::::: $Date$
--
+--
+-- The user status table is a list of statuses indicating what state a user's
+-- account is in.
+--
+CREATE TABLE cs_user_status_table (
+ user_status_id serial NOT NULL PRIMARY KEY,
+ description text NOT NULL,
+ is_active boolean DEFAULT true NOT NULL
+);
+CREATE TABLE cs_authentication_table (
+ uid serial NOT NULL PRIMARY KEY,
+ username text NOT NULL,
+ passwd character varying(32),
+ is_active boolean DEFAULT true NOT NULL,
+ date_created date DEFAULT now() NOT NULL,
+ last_login timestamp with time zone,
+ email text,
+ user_status_id integer REFERENCES cs_user_status_table(user_status_id)
+);
--
-- The category is the high-level view of the affected system. If this were
-- a project management system with projects and issues, then there would
@@ -58,7 +77,7 @@
log_id serial NOT NULL PRIMARY KEY,
creation timestamp NOT NULL DEFAULT NOW(),
event_id integer NOT NULL REFERENCES cswal_event_table(event_id),
- uid integer NOT NULL,
+ uid integer NOT NULL REFERENCES cs_authentication_table(uid),
affected_uid integer NOT NULL,
details text NOT NULL
);
@@ -94,7 +113,7 @@
CREATE TABLE cswal_auth_token_table (
auth_token_id serial NOT NULL PRIMARY KEY,
- uid integer NOT NULL DEFAULT 0,
+ uid integer NOT NULL REFERENCES cs_authentication_table(uid),
checksum text NOT NULL,
token text NOT NULL,
max_uses integer DEFAULT NULL,
@@ -113,7 +132,7 @@
CREATE TABLE cswal_session_store_table (
session_store_id serial NOT NULL PRIMARY KEY,
session_id varchar(32) NOT NULL DEFAULT '' UNIQUE,
- user_id varchar(16),
+ uid integer REFERENCES cs_authentication_table(uid),
date_created timestamp NOT NULL DEFAULT NOW(),
last_updated timestamp NOT NULL DEFAULT NOW(),
session_data text
Modified: trunk/current/tests/testOfCSGenericPermissions.php
===================================================================
--- trunk/current/tests/testOfCSGenericPermissions.php 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/tests/testOfCSGenericPermissions.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -25,7 +25,13 @@
function setUp() {
$this->gfObj = new cs_globalFunctions;
$this->gfObj->debugPrintOpt=1;
- parent::__construct('postgres','', 'localhost', '5432');
+ parent::__construct(
+ //'postgres','', 'localhost', '5432');
+ constant('cs_webapplibs-DB_CONNECT_USER'),
+ constant('cs_webapplibs-DB_CONNECT_PASSWORD'),
+ constant('cs_webapplibs-DB_CONNECT_HOST'),
+ constant('cs_webapplibs-DB_CONNECT_PORT')
+ );
$this->permObj = new _gpTester($this->db);
$this->permObj->do_schema();
$this->get_valid_users();
@@ -53,15 +59,6 @@
}
}
- //create some objects...
- {
- $requiredItems = array('{APPURL}', 'member');
- foreach($requiredItems as $name) {
- $newId = $this->permObj->create_object($name);
- $this->assertTrue(is_numeric($newId));
- }
- }
-
}//end setUp()
//--------------------------------------------------------------------------
@@ -138,71 +135,6 @@
//--------------------------------------------------------------------------
- public function test_object_paths() {
- //basic functionality test for ID Path creation.
- {
- $expectThis = ':5::30::2::18::5:';
-
- //make the expected string into something that be broken into an array of numbers.
- $chunktify = preg_replace('/^:(.*):$/', '$1', $expectThis);
- $chunktify = preg_replace('/:{2,}/', ':', $chunktify);
- $bits = explode(':', $chunktify);
-
- $this->assertEqual($bits, $this->permObj->explode_id_path($expectThis));
-
- $this->assertEqual(count($bits), 5, 'could not break string into id bits');
-
- $derivedIdPath = "";
- foreach($bits as $id) {
- $derivedIdPath .= $this->permObj->create_id_path_part($id);
- }
- $this->assertEqual($derivedIdPath, $expectThis, 'Invalid idPath, expected=('. $expectThis .'), actual=('. $derivedIdPath .')');
-
- $idPathList = array(':9:', ':9::5:', ':0::0::0:', ':-1:', ':-1::-1:', ':-400::1::3:', ':51041::600000::8109223::999999999999999999999999999999999:');
- foreach($idPathList as $tPath) {
- $this->assertTrue($this->permObj->is_id_path($tPath), "valid path (". $tPath .") not recognized as such");
- }
-
- $invalidIdPathList = array('', ':--1:', '1::3::4:', ':1::3::4', ':1:3:4:');
- foreach($invalidIdPathList as $tPath) {
- $this->assertFalse($this->permObj->is_id_path($tPath), "invalid path (". $tPath .") evaluated as valid");
- }
- }
-
- //Search for existing items (should have been created from setUp())
- {
- $requiredItems = array('{APPURL}', 'member');
- $existingItems = $this->permObj->get_object_ids($requiredItems, false);
- $this->assertEqual(count($existingItems), 2, 'Required items not present... '. $this->gfObj->debug_print($existingItems,0,1));
-
- //in the event the required items aren't there, create them.
- $testExistingItems = $this->permObj->get_object_ids($requiredItems, true);
- $this->assertEqual(count($requiredItems), count($testExistingItems), 'failed to create some existing items');
- $this->assertEqual(count($testExistingItems), count($existingItems), 'WARNING: some required items were not found');
- }
-
- //Build new ID paths...
- {
- $newObjects = array('admin', 'logs', 'view');
- $idPath = $this->permObj->create_id_path('/admin/logs/view');
- $this->assertTrue(preg_match('/^:[0-9]{1,}::[0-9]{1,}::[0-9]{1,}:/', $idPath), 'path appears syntactically incorrect ('. $idPath .')');
-
- //make sure the manually-created ID Path matches what was actually created.
- $idList = $this->permObj->get_object_ids($newObjects, false);
- $this->assertEqual(count($idList), count($newObjects), "there must be missing objects, counts don't match");
-
- $expectedIdPath = "";
- foreach($idList as $id=>$n) {
- $expectedIdPath .= $this->permObj->create_id_path_part($id);
- }
- $this->assertEqual($expectedIdPath, $idPath, "Manually created path (". $expectedIdPath .") does not match idPath (". $idPath .")");
- }
- }//end test_object_paths()
- //--------------------------------------------------------------------------
-
-
-
- //--------------------------------------------------------------------------
public function test_permissions() {
#$GLOBALS['keepDb'] = true;
@@ -442,10 +374,6 @@
//retrieve the permission & check some things out...
$permData = $this->permObj->get_permission($tPath);
$this->assertEqual($permData['permission_id'], $newPermId);
- if(!$this->assertEqual($permData['object_path'], $this->permObj->clean_object_path($tPath))) {
- #$this->permObj->translate_id_path($permData['id_path'], 1);
- $this->gfObj->debug_print($permData);
- }
$this->assertEqual($permData['perm_string'], $tPermString);
if(!$this->assertEqual($this->permObj->parse_perm_string($tPermString), $this->permObj->parse_perm_string($permData['perm_string']))) {
$this->gfObj->debug_print($this->permObj->parse_perm_string($tPermString));
Added: trunk/current/upgrades/exampleUpgradeScript.php
===================================================================
--- trunk/current/upgrades/exampleUpgradeScript.php (rev 0)
+++ trunk/current/upgrades/exampleUpgradeScript.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -0,0 +1,46 @@
+<?php
+
+// upgrade_to_0_4_1
+class upgrade_to_0_4_1 {
+
+ private $logsObj;
+
+ //=========================================================================
+ public function __construct(cs_phpDB &$db) {
+ if(!$db->is_connected()) {
+ throw new exception(__METHOD__ .": database is not connected");
+ }
+ $this->db = $db;
+
+
+ $this->gfObj = new cs_globalFunctions;
+ $this->gfObj->debugPrintOpt = 1;
+ }//end __construct()
+ //=========================================================================
+
+
+
+ //=========================================================================
+ public function run_upgrade() {
+
+ // Check if there's an existing auth table...
+ $doSecondarySql = false;
+ $this->db->beginTrans(__METHOD__);
+
+
+ $this->gfObj->debug_print(__METHOD__ .": running SQL file...");
+ $this->db->run_sql_file(dirname(__FILE__) .'/schemaChangesFor_0.4.1.sql');
+
+ if($doSecondarySql) {
+ $this->gfObj->debug_print(__METHOD__ .": running SQL file...");
+ $this->db->run_sql_file(dirname(__FILE__) .'/schemaChangesFor_0.4.1__existingAuthTable.sql');
+ }
+
+ $this->db->commitTrans(__METHOD__);
+
+ return(true);
+ }//end run_upgrade()
+ //=========================================================================
+}
+
+?>
Added: trunk/current/upgrades/schemaChangesFor_0.4.1.sql
===================================================================
--- trunk/current/upgrades/schemaChangesFor_0.4.1.sql (rev 0)
+++ trunk/current/upgrades/schemaChangesFor_0.4.1.sql 2011-12-14 05:57:13 UTC (rev 220)
@@ -0,0 +1,4 @@
+insert into cs_authentication_table (uid, username, passwd, is_active, user_status_id) VALUES (0, 'anonymous', '__DISABLED__', false, 0);
+ALTER TABLE ONLY cswal_log_table ADD CONSTRAINT cswal_log_table_uid_fkey FOREIGN KEY (uid) REFERENCES cs_authentication_table(uid);
+ALTER TABLE ONLY cswal_session_store_table DROP COLUMN user_id;
+ALTER TABLE ONLY cswal_session_store_table ADD COLUMN uid integer;
Modified: trunk/current/upgrades/upgrade.xml
===================================================================
--- trunk/current/upgrades/upgrade.xml 2011-11-27 23:06:06 UTC (rev 219)
+++ trunk/current/upgrades/upgrade.xml 2011-12-14 05:57:13 UTC (rev 220)
@@ -19,19 +19,14 @@
to get skipped, or an exception to be thrown, potentially leaving the system
in an unstable state. Unstable is bad, m'kay?</system_note>
- <examples>
- <v1.2.0-ALPHA3>
- <target_version>1.2.0-ALPHA4</target_version>
- <script_name>upgradeTo1.2.0-ALPHA4.php</script_name>
- <class_name>upgrade_to_1_2_0_ALPHA4</class_name>
- <call_method>run_upgrade</call_method>
- </v1.2.0-ALPHA3>
- <v1.2.0-ALPHA6>
- <target_version>1.2.0-ALPHA7</target_version>
- <script_name>upgradeTo1.2.0-ALPHA7.php</script_name>
- <class_name>upgrade_to_1_2_0_ALPHA7</class_name>
- <call_method>run_upgrade</call_method>
- </v1.2.0-ALPHA6>
- </examples>
<example_initialversion>0.1.0-BETA1</example_initialversion>
+ <matching>
+ <v0.4.0>
+ <target_version>0.4.1</target_version>
+ <script_name>upgradeTo0.4.1.php</script_name>
+ <class_name>upgrade_to_0_4_1</class_name>
+ <call_method>run_upgrade</call_method>
+ </v0.4.0>
+ </matching>
</upgrade>
+
Added: trunk/current/upgrades/upgradeTo0.4.1.php
===================================================================
--- trunk/current/upgrades/upgradeTo0.4.1.php (rev 0)
+++ trunk/current/upgrades/upgradeTo0.4.1.php 2011-12-14 05:57:13 UTC (rev 220)
@@ -0,0 +1,46 @@
+<?php
+
+// upgrade_to_0_4_1
+class upgrade_to_0_4_1 {
+
+ private $logsObj;
+
+ //=========================================================================
+ public function __construct(cs_phpDB &$db) {
+ if(!$db->is_connected()) {
+ throw new exception(__METHOD__ .": database is not connected");
+ }
+ $this->db = $db;
+
+
+ $this->gfObj = new cs_globalFunctions;
+ $this->gfObj->debugPrintOpt = 1;
+ }//end __construct()
+ //=========================================================================
+
+
+
+ //=========================================================================
+ public function run_upgrade() {
+
+ // Check if there's an existing auth table...
+ $doSecondarySql = false;
+ $this->db->beginTrans(__METHOD__);
+
+
+ $this->gfObj->debug_print(__METHOD__ .": running SQL file...");
+ $this->db->run_sql_file(dirname(__FILE__) .'/schemaChangesFor_0.4.1.sql');
+
+ if($doSecondarySql) {
+ $this->gfObj->debug_print(__METHOD__ .": running SQL file...");
+ $this->db->run_sql_file(dirname(__FILE__) .'/schemaChangesFor_0.4.1__existingAuthTable.sql');
+ }
+
+ $this->db->commitTrans(__METHOD__);
+
+ return(true);
+ }//end run_upgrade()
+ //=========================================================================
+}
+
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-11-27 23:06:12
|
Revision: 219
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=219&view=rev
Author: crazedsanity
Date: 2011-11-27 23:06:06 +0000 (Sun, 27 Nov 2011)
Log Message:
-----------
Minor wording change + newline on VERSION file.
Modified Paths:
--------------
trunk/current/VERSION
trunk/current/setup/genericPermissions.pgsql.sql
Modified: trunk/current/VERSION
===================================================================
--- trunk/current/VERSION 2011-11-24 02:06:22 UTC (rev 218)
+++ trunk/current/VERSION 2011-11-27 23:06:06 UTC (rev 219)
@@ -4,3 +4,4 @@
VERSION: 0.4.0
PROJECT: cs-webapplibs
$HeadURL$
+
Modified: trunk/current/setup/genericPermissions.pgsql.sql
===================================================================
--- trunk/current/setup/genericPermissions.pgsql.sql 2011-11-24 02:06:22 UTC (rev 218)
+++ trunk/current/setup/genericPermissions.pgsql.sql 2011-11-27 23:06:06 UTC (rev 219)
@@ -1,7 +1,7 @@
--
-- Group table
--- Enumerates a list of permissions for a specific group: i.e. for "blog", this could list "create", "edit", and "delete" (among others).
+-- Enumerates a list of permissions for a specific group: e.g. for "blog", this could list "create", "edit", and "delete" (among others).
--
CREATE TABLE cswal_group_table (
group_id serial NOT NULL PRIMARY KEY,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-11-24 02:06:28
|
Revision: 218
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=218&view=rev
Author: crazedsanity
Date: 2011-11-24 02:06:22 +0000 (Thu, 24 Nov 2011)
Log Message:
-----------
*** RELEASE 0.4.0 ***
Summary of changes:
* added generic chat libraries
* various fixes
* ID obfuscation library
* better exception information.
Modified Paths:
--------------
trunk/current/VERSION
Modified: trunk/current/VERSION
===================================================================
--- trunk/current/VERSION 2011-11-22 03:06:03 UTC (rev 217)
+++ trunk/current/VERSION 2011-11-24 02:06:22 UTC (rev 218)
@@ -1,6 +1,6 @@
## Stores the current version of the cs-versionparse system, and it's source.
## Please do NOT modify this file.
-VERSION: 0.4-ALPHA1
+VERSION: 0.4.0
PROJECT: cs-webapplibs
$HeadURL$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-11-22 03:06:09
|
Revision: 217
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=217&view=rev
Author: crazedsanity
Date: 2011-11-22 03:06:03 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------
Slightly better exception (includes connection string).
Modified Paths:
--------------
trunk/current/db_types/cs_phpDB__pgsql.class.php
Modified: trunk/current/db_types/cs_phpDB__pgsql.class.php
===================================================================
--- trunk/current/db_types/cs_phpDB__pgsql.class.php 2011-10-24 16:09:50 UTC (rev 216)
+++ trunk/current/db_types/cs_phpDB__pgsql.class.php 2011-11-22 03:06:03 UTC (rev 217)
@@ -197,7 +197,7 @@
$retval = $this->connectionID;
}
else {
- throw new exception(__METHOD__ .": FATAL ERROR: ". $connectError);
+ throw new exception(__METHOD__ .": FATAL ERROR: ". $connectError . "\n CONNSTR: ". $connStr);
}
}
else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-10-24 16:10:01
|
Revision: 216
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=216&view=rev
Author: crazedsanity
Date: 2011-10-24 16:09:50 +0000 (Mon, 24 Oct 2011)
Log Message:
-----------
Creating a "current" folder for the most current "bleeding-edge" development.
For all cs-* projects, the "current" folder should be compatible. For instance, these should always be compatible (the FULL URL is probably https://{projectName}.svn.sourceforge.net/svnroot/{projectName}):
-- cs-webapplibs/trunk/current
-- cs-content/trunk/current
-- cs-phpxml/trunk/current
This should help avoid conflicts for older checkouts that are still trying to be bleeding edge; it is pretty easy for one project (e.g. cs-webapplibs) to get too far behind or too far ahead of other projects without even realizing it, due to how the URLs are setup in the svn:externals property...
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...> - 2011-10-20 02:18:47
|
Revision: 215
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=215&view=rev
Author: crazedsanity
Date: 2011-10-20 02:18:41 +0000 (Thu, 20 Oct 2011)
Log Message:
-----------
A bit more information when there's a fatal version mismatch.
Modified Paths:
--------------
trunk/0.4/cs_webdbupgrade.class.php
Modified: trunk/0.4/cs_webdbupgrade.class.php
===================================================================
--- trunk/0.4/cs_webdbupgrade.class.php 2011-07-20 00:49:56 UTC (rev 214)
+++ trunk/0.4/cs_webdbupgrade.class.php 2011-10-20 02:18:41 UTC (rev 215)
@@ -527,7 +527,8 @@
$retval = "minor";
}
else {
- $this->error_handler(__METHOD__ .": downgrading minor versions is unsupported");
+ $this->error_handler(__METHOD__ .": downgrading minor versions is unsupported, project_name=(". $this->get_project() ."), ".
+ "file version=(". $versionFileData['version_string'] ."), dbVersion=(". $dbVersion['version_string'] ."");
}
}
elseif($versionFileData['version_major'] > $dbVersion['version_major']) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-07-20 00:50:06
|
Revision: 214
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=214&view=rev
Author: crazedsanity
Date: 2011-07-20 00:49:56 +0000 (Wed, 20 Jul 2011)
Log Message:
-----------
Class for masking ID's in the URL to avoid snooping (i.e. "ooh, what happens if I add 1 to thad ID?")
Added Paths:
-----------
trunk/0.4/cs_idObfuscator.class.php
Copied: trunk/0.4/cs_idObfuscator.class.php (from rev 213, trunk/0.4/cs_idPath.class.php)
===================================================================
--- trunk/0.4/cs_idObfuscator.class.php (rev 0)
+++ trunk/0.4/cs_idObfuscator.class.php 2011-07-20 00:49:56 UTC (rev 214)
@@ -0,0 +1,58 @@
+<?php
+/*
+ * Created on May 16th, 2011
+ *
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ *
+ * Originally pulled from http://raymorgan.net/web-development/how-to-obfuscate-integer-ids/
+ */
+
+class cs_IdObfuscator {
+
+ public static function encode($id) {
+ if (!is_numeric($id) or $id < 1) {return FALSE;}
+ $id = (int)$id;
+ if ($id > pow(2,31)) {return FALSE;}
+ $segment1 = self::getHash($id,16);
+ $segment2 = self::getHash($segment1,8);
+ $dec = (int)base_convert($segment2,16,10);
+ $dec = ($dec>$id)?$dec-$id:$dec+$id;
+ $segment2 = base_convert($dec,10,16);
+ $segment2 = str_pad($segment2,8,'0',STR_PAD_LEFT);
+ $segment3 = self::getHash($segment1.$segment2,8);
+ $hex = $segment1.$segment2.$segment3;
+ $bin = pack('H*',$hex);
+ $oid = base64_encode($bin);
+ $oid = str_replace(array('+','/','='),array('$',':',''),$oid);
+ return $oid;
+ }
+
+ public static function decode($oid) {
+ if (!preg_match('/^[A-Z0-9\:\$]{21,23}$/i',$oid)) {return 0;}
+ $oid = str_replace(array('$',':'),array('+','/'),$oid);
+ $bin = base64_decode($oid);
+ $hex = unpack('H*',$bin); $hex = $hex[1];
+ if (!preg_match('/^[0-9a-f]{32}$/',$hex)) {return 0;}
+ $segment1 = substr($hex,0,16);
+ $segment2 = substr($hex,16,8);
+ $segment3 = substr($hex,24,8);
+ $exp2 = self::getHash($segment1,8);
+ $exp3 = self::getHash($segment1.$segment2,8);
+ if ($segment3 != $exp3) {return 0;}
+ $v1 = (int)base_convert($segment2,16,10);
+ $v2 = (int)base_convert($exp2,16,10);
+ $id = abs($v1-$v2);
+ return $id;
+ }
+
+ private static function getHash($str,$len) {
+ return substr(sha1($str.CRYPT_SALT),0,$len);
+ }
+}
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-05-10 23:57:36
|
Revision: 213
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=213&view=rev
Author: crazedsanity
Date: 2011-05-10 23:57:30 +0000 (Tue, 10 May 2011)
Log Message:
-----------
Fix a couple of bugs (typos), optional argument for retrieving records.
/abstract/cs_singleTableHandler.abstract.class.php:
* get_records_using_custom_filter():
-- fix typo with $orderByStr (one reference was $orderBYStr)
-- remove invalid $ (was "$is_string(...")
-- fix query so $filter doesn't have to contain " WHERE "
* update_record():
-- ARG CHANGE: NEW ARG: #4 ($appendToUpdateString=null)
-- optionally add an extra bit of text to the query.
Modified Paths:
--------------
trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
Modified: trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-04-03 18:17:47 UTC (rev 212)
+++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-05-10 23:57:30 UTC (rev 213)
@@ -236,12 +236,12 @@
}
}
- $orderBYStr = ' ORDER BY '. $this->pkeyField;
- if($is_string($orderBy) && strlen($orderBy)) {
+ $orderByStr = ' ORDER BY '. $this->pkeyField;
+ if(is_string($orderBy) && strlen($orderBy)) {
$orderByStr = ' ORDER BY '. $orderBy;
}
- $sql = 'SELECT * FROM '. $this->tableName . $filter . $orderByStr . $limitOffsetStr;
+ $sql = 'SELECT * FROM '. $this->tableName ." WHERE ". $filter . $orderByStr . $limitOffsetStr;
try {
$data = $this->dbObj->run_query($sql, $this->pkeyField);
}
@@ -268,7 +268,7 @@
* @RETURN (int) SUCCESS: (int) is the number of records updated (should always be 1)
* @EXCEPTION FAIL: exception indicates the error.
*/
- public function update_record($recId, array $updates, $removeEmptyVals=true) {
+ public function update_record($recId, array $updates, $removeEmptyVals=true, $appendToUpdateString=null) {
if(is_numeric($recId) && $recId >= 0 && is_array($updates) && count($updates) > 0) {
$updateString = $this->gfObj->string_from_array($updates, 'update', null, $this->cleanStringArr, $removeEmptyVals);
if(is_null($updateString) || !strlen($updateString) || strlen($updateString) < 3) {
@@ -276,7 +276,7 @@
}
else {
$sql = 'UPDATE '. $this->tableName .' SET '
- . $updateString
+ . $updateString . $appendToUpdateString
.' WHERE '. $this->pkeyField .'='. $recId;
try {
$retval = $this->dbObj->run_update($sql, true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-04-03 18:17:54
|
Revision: 212
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=212&view=rev
Author: crazedsanity
Date: 2011-04-03 18:17:47 +0000 (Sun, 03 Apr 2011)
Log Message:
-----------
Fixes for table handling and some permissions stuff.
Modified Paths:
--------------
trunk/0.4/abstract/cs_genericObject.abstract.class.php
trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
trunk/0.4/cs_genericPermission.class.php
trunk/0.4/setup/genericPermissions.pgsql.sql
trunk/0.4/tests/example_test.php
trunk/0.4/tests/testOfCSGenericPermissions.php
Modified: trunk/0.4/abstract/cs_genericObject.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_genericObject.abstract.class.php 2011-03-26 00:57:34 UTC (rev 211)
+++ trunk/0.4/abstract/cs_genericObject.abstract.class.php 2011-04-03 18:17:47 UTC (rev 212)
@@ -98,8 +98,9 @@
. "object_name IN ";
$myFilter = "";
- foreach($objectNames as $n) {
- $tString = "'". $this->clean_object_name($n) ."'";
+ foreach($objectNames as $i=>$n) {
+ $tCleanName = $this->clean_object_name($n);
+ $tString = "'". $tCleanName ."'";
$myFilter = $this->gfObj->create_list($myFilter, $tString);
}
$sql .= '('. $myFilter .')';
@@ -165,13 +166,11 @@
$idPath = "";
if(is_array($myIds) && count($myIds)) {
- foreach($myIds as $id=>$name) {
- try {
- $idPath = $this->gfObj->create_list($idPath, $this->create_id_path_part($id), '');
- }
- catch(Exception $e) {
- throw new exception($e->getMessage());
- }
+ $nameToId = array_flip($myIds);
+ foreach($objects as $i=>$name) {
+ $cleanName = $this->clean_object_name($name);
+ $tId = $nameToId[$cleanName];
+ $idPath = $this->gfObj->create_list($idPath, $this->create_id_path_part($tId), '');
}
}
else {
@@ -181,6 +180,7 @@
catch(Exception $e) {
throw new exception(__METHOD__ .": failed to create id path, DETAILS::: ". $e->getMessage());
}
+#$this->gfObj->debug_print(__METHOD__ .": returning=(". $idPath ."), objects::: ". $this->gfObj->debug_print($objects,0,1) ."\n<BR> myIds::: ". $this->gfObj->debug_print($myIds,0,1));
return($idPath);
}//end create_id_path_from_objects()
//============================================================================
@@ -188,7 +188,7 @@
//============================================================================
- protected function clean_object_name($n) {
+ public function clean_object_name($n) {
//pulled from cs-content, cs_globalFunctions::cleanString(), style="query"; modified to allow the brackets.
$evilChars = array("\$", ":", "%", "~", "*",">", "<", "-", "[", "]", ")", "(", "&", "#", "?", ".", "\,","\/","\\","\"","\|","!","^","+","`","\n","\r");
$n = preg_replace("/\|/","",$n);
@@ -229,10 +229,19 @@
//============================================================================
- public function translate_id_path($idPath) {
+ public function translate_id_path($idPath, $debug=0) {
if($this->is_id_path($idPath)) {
$bits = $this->explode_id_path($idPath);
- $translatedPath = $this->get_object_names($this->explode_id_path($idPath));
+ $translatedBits = $this->get_object_names($this->explode_id_path($idPath));
+
+ $translatedPath = "";
+ foreach($bits as $id) {
+ $translatedPath = $this->gfObj->create_list($translatedPath, $translatedBits[$id], '/');
+ }
+ #foreach($translatedBits as $id=>$name) {
+ # $translatedPath = $this->gfObj->create_list($translatedPath, $name, '/');
+ #}
+ $translatedPath = '/'. $translatedPath;
}
else {
throw new exception(__METHOD__ .": invalid path (". $idPath .")");
@@ -269,5 +278,18 @@
}//end get_object_names()
//============================================================================
+
+
+ //============================================================================
+ public function clean_object_path($path) {
+ $bits = $this->explode_id_path($path);
+ $newPath = "";
+ foreach($bits as $k=>$v) {
+ $newPath = $this->gfObj->create_list($newPath, $this->clean_object_name($v), '/');
+ }
+ return($newPath);
+ }//end clean_object_path()
+ //============================================================================
+
}
?>
Modified: trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-03-26 00:57:34 UTC (rev 211)
+++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-04-03 18:17:47 UTC (rev 212)
@@ -224,6 +224,41 @@
//-------------------------------------------------------------------------
+ public function get_records_using_custom_filter($filter, $orderBy=null, $limit=null, $offset=null) {
+ if(is_string($filter) && strlen($filter)) {
+ $limitOffsetStr = '';
+ if(is_numeric($limit) && $limit > 0) {
+ $limitOffsetStr = ' LIMIT '. $limit;
+
+ //using an offset without a limit seems silly...
+ if(is_numeric($limitOffsetStr) && $offset > 0) {
+ $limitOffsetStr .= ' OFFSET '. $offset;
+ }
+ }
+
+ $orderBYStr = ' ORDER BY '. $this->pkeyField;
+ if($is_string($orderBy) && strlen($orderBy)) {
+ $orderByStr = ' ORDER BY '. $orderBy;
+ }
+
+ $sql = 'SELECT * FROM '. $this->tableName . $filter . $orderByStr . $limitOffsetStr;
+ try {
+ $data = $this->dbObj->run_query($sql, $this->pkeyField);
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to retrieve records, DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid filter (". $filter .")");
+ }
+ return($data);
+ }//end get_records_using_custom_filter()
+ //-------------------------------------------------------------------------
+
+
+
+ //-------------------------------------------------------------------------
/**
* Update a single record with the given changes.
*
Modified: trunk/0.4/cs_genericPermission.class.php
===================================================================
--- trunk/0.4/cs_genericPermission.class.php 2011-03-26 00:57:34 UTC (rev 211)
+++ trunk/0.4/cs_genericPermission.class.php 2011-04-03 18:17:47 UTC (rev 212)
@@ -174,11 +174,11 @@
if(is_string($name) && strlen($name) && is_numeric($userId) && $userId >= 0 && is_numeric($groupId) && $groupId >= 0) {
try{
$insertArr = $this->parse_permission_string($permString);
- $insertArr['object_path'] = $this->create_id_path($name);
+ $insertArr['id_path'] = $this->create_id_path($name);
$insertArr['user_id'] = $userId;
$insertArr['group_id'] = $groupId;
- $newId = $this->dbTableHandler->create_record($insertArr);
+ $newId = $this->dbTableHandler->create_record($insertArr,false);
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to create new record, name=(". $name ."), permString=(". $permString .") DETAILS::: ". $e->getMessage());
@@ -203,11 +203,11 @@
if(!$this->is_id_path($name)) {
$name = $this->create_id_path($name);
}
- $retval = $this->dbTableHandler->get_single_record(array('object_path'=>$name));
+ $retval = $this->dbTableHandler->get_single_record(array('id_path'=>$name));
//now translate the object_path...
- // TODO: this could be a resource hog if called in rapid succession; consider creating an object cache or whatnot
- $retval['translated_path'] = $this->translate_id_path($retval['object_path']);
+ $retval['object_path'] = $this->translate_id_path($retval['id_path']);
+ $retval['perm_string'] = $this->build_permission_string($retval);
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: error while locating permission '". $name ."', DETAILS::: ". $e->getMessage());
@@ -404,6 +404,7 @@
$path = preg_replace('/^'. addcslashes($this->objectDelimiter, '/') .'/', '', $path);
$path = preg_replace('/'. addcslashes($this->objectDelimiter, '/') .'{2,}/', $this->objectDelimiter, $path);
$bits = explode($this->objectDelimiter, $path);
+#$this->gfObj->debug_print(__METHOD__ .": path=(". $path ."), bits::: ". $this->gfObj->debug_print($bits,0,1));
}
else {
throw new exception(__METHOD__ .": invalid path (". $path .")");
@@ -421,6 +422,7 @@
//now create the path.
$newPath = $this->create_id_path_from_objects($bits);
+#$this->gfObj->debug_print(__METHOD__ .": newPath=(". $newPath ."), bits::: ". $this->gfObj->debug_print($bits,0,1));
if(!$this->is_id_path($newPath)) {
throw new exception(__METHOD__ .": failed to create ID path from (". $path .")");
}
@@ -428,5 +430,12 @@
return($newPath);
}//end create_id_path()
//============================================================================
+
+
+
+ //============================================================================
+ public function update_permission() {
+ }//end update_permission()
+ //============================================================================
}
?>
Modified: trunk/0.4/setup/genericPermissions.pgsql.sql
===================================================================
--- trunk/0.4/setup/genericPermissions.pgsql.sql 2011-03-26 00:57:34 UTC (rev 211)
+++ trunk/0.4/setup/genericPermissions.pgsql.sql 2011-04-03 18:17:47 UTC (rev 212)
@@ -60,7 +60,7 @@
CREATE TABLE cswal_permission_table (
permission_id serial NOT NULL PRIMARY KEY,
system_name integer NOT NULL DEFAULT 0 REFERENCES cswal_system_table(system_id),
- object_path text NOT NULL,
+ id_path text NOT NULL,
user_id integer NOT NULL REFERENCES cs_authentication_table(uid),
group_id integer NOT NULL REFERENCES cswal_group_table(group_id),
inherit boolean NOT NULL DEFAULT FALSE,
@@ -79,5 +79,5 @@
INSERT INTO cswal_system_table (system_id, system_name) VALUES (0, 'DEFAULT');
ALTER TABLE ONLY cswal_permission_table
- ADD CONSTRAINT cswal_permission_table_system_path_key UNIQUE (system_name, object_path);
+ ADD CONSTRAINT cswal_permission_table_system_path_key UNIQUE (system_name, id_path);
Modified: trunk/0.4/tests/example_test.php
===================================================================
--- trunk/0.4/tests/example_test.php 2011-03-26 00:57:34 UTC (rev 211)
+++ trunk/0.4/tests/example_test.php 2011-04-03 18:17:47 UTC (rev 212)
@@ -12,8 +12,22 @@
*/
-require_once(dirname(__FILE__) .'/testOfCSVersionParse.php');
+require_once(dirname(__FILE__) .'/tests/testOfCSGenericChat.php');
+require_once(dirname(__FILE__) .'/tests/testOfCSGenericPermissions.php');
+require_once(dirname(__FILE__) .'/tests/testOfCSPHPDB.php');
+require_once(dirname(__FILE__) .'/tests/testOfCSWebAppLibs.php');
+/*
+tests/testOfCSGenericChat.php:class testOfCSGenericChat extends testDbAbstract {
+tests/testOfCSGenericPermissions.php:class testOfCSGenericPermissions extends testDbAbstract {
+tests/testOfCSGenericPermissions.php:class _gpTester extends cs_genericPermission {
+tests/testOfCSPHPDB.php:class TestOfCSPHPDB extends UnitTestCase {
+tests/testOfCSWebAppLibs.php:class testOfCSWebAppLibs extends testDbAbstract {
+tests/testOfCSWebAppLibs.php:class authTokenTester extends cs_authToken {
+*/
-$test = &new TestOfA2P();
-$test->run(new HtmlReporter())
+$test = new TestSuite('Tests for CS-WebAppLibs');
+$test->addTestCase(new TestOfCSPHPDB());
+$test->addTestCase(new testOfCSWebAppLibs());
+$test->addTestCase(new testOfCSGenericChat());
+$test->addTestCase(new testOfCSGenericPermissions());
?>
Modified: trunk/0.4/tests/testOfCSGenericPermissions.php
===================================================================
--- trunk/0.4/tests/testOfCSGenericPermissions.php 2011-03-26 00:57:34 UTC (rev 211)
+++ trunk/0.4/tests/testOfCSGenericPermissions.php 2011-04-03 18:17:47 UTC (rev 212)
@@ -250,6 +250,126 @@
$this->assertEqual($this->permObj->get_perm_list($myPermArr,'o'), $permByType['o']);
}
+ //test ALL (or at least close to all) variations of permission strings...
+ {
+ $allVariations = array(
+ 'rwxrwxrwx' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => true,
+ 'g_r' => true,
+ 'g_w' => true,
+ 'g_x' => true,
+ 'o_r' => true,
+ 'o_w' => true,
+ 'o_x' => true
+ ),
+ 'rwxrwxrw-' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => true,
+ 'g_r' => true,
+ 'g_w' => true,
+ 'g_x' => true,
+ 'o_r' => true,
+ 'o_w' => true,
+ 'o_x' => false
+ ),
+ 'rwxrwxr--' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => true,
+ 'g_r' => true,
+ 'g_w' => true,
+ 'g_x' => true,
+ 'o_r' => true,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ 'rwxrwx---' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => true,
+ 'g_r' => true,
+ 'g_w' => true,
+ 'g_x' => true,
+ 'o_r' => false,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ 'rwxrw----' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => true,
+ 'g_r' => true,
+ 'g_w' => true,
+ 'g_x' => false,
+ 'o_r' => false,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ 'rwxr-----' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => true,
+ 'g_r' => true,
+ 'g_w' => false,
+ 'g_x' => false,
+ 'o_r' => false,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ 'rwx------' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => true,
+ 'g_r' => false,
+ 'g_w' => false,
+ 'g_x' => false,
+ 'o_r' => false,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ 'rw-------' => array(
+ 'u_r' => true,
+ 'u_w' => true,
+ 'u_x' => false,
+ 'g_r' => false,
+ 'g_w' => false,
+ 'g_x' => false,
+ 'o_r' => false,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ 'r--------' => array(
+ 'u_r' => true,
+ 'u_w' => false,
+ 'u_x' => false,
+ 'g_r' => false,
+ 'g_w' => false,
+ 'g_x' => false,
+ 'o_r' => false,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ '---------' => array(
+ 'u_r' => false,
+ 'u_w' => false,
+ 'u_x' => false,
+ 'g_r' => false,
+ 'g_w' => false,
+ 'g_x' => false,
+ 'o_r' => false,
+ 'o_w' => false,
+ 'o_x' => false
+ ),
+ );
+ foreach($allVariations as $permString=>$testPermArray) {
+ $parsedPerms = $this->permObj->parse_perm_string($permString);
+ $this->assertEqual($parsedPerms, $testPermArray);
+ }
+ }
+
//create some permissions.
{
$userKeys = array_keys($this->validUsers);
@@ -310,27 +430,27 @@
'/content/dev',
'/content/dev/corner',
'/content/dev/coner/cs',
-
- //The following items fail for no apparent reason (that I can find)...
'/admin',
'/cntenx',
- '/content/dev/corner/cs/content', //fails due to duplicate objects in path ("content" is in there twice).
+ '/content/dev/corner/cs/content',
);
- $testPerms = array(
- 'rwxrwxrwx',
- 'rwxrwx---',
- 'rwx---rwx',
- '---rwxrwx',
- 'rwx------',
- '---------',
- 'r--r--r--',
- '-w--w--w-',
- '--x--x--x'
- );
foreach($testPaths as $tPath) {
- $tPermString = 'rwxrwx---';
+ $tPermString = '-w--w----';
$newPermId = $this->permObj->create_permission($tPath, $this->chosenOneUid, $this->defaultGroupId, $tPermString);
$this->assertTrue(is_numeric($newPermId));
+
+ //retrieve the permission & check some things out...
+ $permData = $this->permObj->get_permission($tPath);
+ $this->assertEqual($permData['permission_id'], $newPermId);
+ if(!$this->assertEqual($permData['object_path'], $this->permObj->clean_object_path($tPath))) {
+ #$this->permObj->translate_id_path($permData['id_path'], 1);
+ $this->gfObj->debug_print($permData);
+ }
+ $this->assertEqual($permData['perm_string'], $tPermString);
+ if(!$this->assertEqual($this->permObj->parse_perm_string($tPermString), $this->permObj->parse_perm_string($permData['perm_string']))) {
+ $this->gfObj->debug_print($this->permObj->parse_perm_string($tPermString));
+ $this->gfObj->debug_print($this->permObj->parse_perm_string($permData['perm_string']));
+ }
}
}///*/
}//end test_permissions
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-03-26 00:57:40
|
Revision: 211
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=211&view=rev
Author: crazedsanity
Date: 2011-03-26 00:57:34 +0000 (Sat, 26 Mar 2011)
Log Message:
-----------
Generic chat libraries.
Added Paths:
-----------
trunk/0.4/abstract/cs_genericChatCategory.abstract.class.php
trunk/0.4/abstract/cs_genericChatMessage.abstract.class.php
trunk/0.4/abstract/cs_genericChatRoom.abstract.class.php
trunk/0.4/setup/genericChat.pgsql.sql
trunk/0.4/tests/testOfCSGenericChat.php
Copied: trunk/0.4/abstract/cs_genericChatCategory.abstract.class.php (from rev 208, trunk/0.4/abstract/cs_genericGroup.abstract.class.php)
===================================================================
--- trunk/0.4/abstract/cs_genericChatCategory.abstract.class.php (rev 0)
+++ trunk/0.4/abstract/cs_genericChatCategory.abstract.class.php 2011-03-26 00:57:34 UTC (rev 211)
@@ -0,0 +1,109 @@
+<?php
+/*
+ * Created on February 25, 2011
+ *
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+abstract class cs_genericChatCategoryAbstract extends cs_webapplibsAbstract {
+
+ /** Database object. */
+ public $db;
+
+ /** cs_globalFunctions object, for cleaning strings & such. */
+ public $gfObj;
+
+ /** Table name used to store categories. */
+ protected $myTable = "cswal_chat_category_table";
+
+ /** Sequence for chat category table. */
+ protected $mySeq = "cswal_chat_category_table_change_category_id_seq";
+
+ /** Table handler object for simple SQL handling */
+ private $dbTableHandler;
+
+ /** Internal categoryId to use... */
+ private $categoryId=0;
+
+ //============================================================================
+ public function __construct(cs_phpDB $db) {
+ $this->db = $db;
+ $this->gfObj = new cs_globalFunctions;
+
+ //setup table handler.
+ $cleanString = array(
+ 'category_name' => "text"
+ );
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->myTable, $this->mySeq, 'chat_category_id', $cleanString);
+ }//end __construct()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function set_category_id($categoryId) {
+ if(is_numeric($categoryId)) {
+ $this->categoryId=$categoryId;
+ }
+ else{
+ throw new exception(__METHOD__ .": invalid categoryId (". $categoryId .")");
+ }
+ return($this->categoryId);
+ }//end set_category_id()
+ //============================================================================
+
+
+
+ //============================================================================
+ /**
+ * Build the schema for the generic chat system.
+ */
+ protected function build_schema() {
+ try {
+ $result = $this->db->run_sql_file(dirname(__FILE__) .'/../setup/genericChat.pgsql.sql');
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to create schema, DETAILS::: ". $e->getMessage());
+ }
+ if($result !== true) {
+ throw new exception(__METHOD__ .":: failed to create schema (no details)");
+ }
+ }//end build_schema()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function create_category($name) {
+ try {
+ $result = $this->dbTableHandler->create_record(array('category_name' => $name));
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to create record, DETAILS::: ". $e->getMessage());
+ }
+ return($result);
+ }//end create_category()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function update_category($id, $name) {
+ try {
+ $result = $this->update_record($id, array('category_name' => $name));
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to update record, DETAILS::: ". $e->getMessage());
+ }
+ return($result);
+ }//end update_category()
+ //============================================================================
+
+}
+
Property changes on: trunk/0.4/abstract/cs_genericChatCategory.abstract.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Author
Revision
HeadURL
Date
Added: svn:mergeinfo
+
Copied: trunk/0.4/abstract/cs_genericChatMessage.abstract.class.php (from rev 208, trunk/0.4/abstract/cs_genericGroup.abstract.class.php)
===================================================================
--- trunk/0.4/abstract/cs_genericChatMessage.abstract.class.php (rev 0)
+++ trunk/0.4/abstract/cs_genericChatMessage.abstract.class.php 2011-03-26 00:57:34 UTC (rev 211)
@@ -0,0 +1,123 @@
+<?php
+/*
+ * Created on March 8, 2011
+ *
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+abstract class cs_genericChatMessageAbstract extends cs_genericChatRoomAbstract {
+
+ /** Database object. */
+ public $db;
+
+ /** cs_globalFunctions object, for cleaning strings & such. */
+ public $gfObj;
+
+ /** Table name used to store list of chat messages. */
+ protected $myTable = "cswal_chat_message_table";
+
+ /** Sequence for chat message table. */
+ protected $mySeq = "cswal_chat_message_table_change_message_id_seq";
+
+ /** Table handler object for simple SQL handling */
+ private $dbTableHandler;
+
+ /** */
+ private $categoryId=null;
+
+ /** */
+ protected $uid;
+
+ /** */
+ protected $chatRoomId;
+
+ //============================================================================
+ public function __construct(cs_phpDB $db, $uid, $chatRoomId) {
+ $this->db = $db;
+ $this->gfObj = new cs_globalFunctions;
+
+ //setup table handler.
+ $cleanString = array(
+ 'uid' => 'int',
+ 'chat_room_id' => 'int',
+ 'private_message_uid' => 'int',
+ 'message' => 'int'
+ );
+
+ if(is_numeric($uid)) {
+ $this->uid = $uid;
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid UID (". $uid .")");
+ }
+ if(is_numeric($chatRoomId)) {
+ $this->chatRoomId = $chatRoomId;
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid room ID (". $chatRoomId .")");
+ }
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->myTable, $this->mySeq, 'chat_message_id', $cleanString);
+ }//end __construct()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function create_message($messageText, $privateMessageUid=NULL) {
+ if(is_string($messageName) && strlen($message)) {
+ try {
+ $sqlArr = array(
+ 'uid' => $this->uid,
+ 'chat_room_id' => $this->chatRoomId,
+
+ //TODO: should messageText be encoded?
+ 'message' => $messageText
+ );
+ if(!is_null($privateMessageUid) && is_numeric($privateMessageUid)) {
+ $sqlArr['private_message_uid'] = $privateMessageUid;
+ }
+ $messageId = $this->dbTableHandler->create_record($sqlArr);
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": failed to create record, DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": (". $messageName .")");
+ }
+
+ return($messageId);
+ }//end create()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function get_messages($lastMessageId=NULL, $limit=NULL) {
+ $messages = array();
+ try {
+ //get_records(array $filter=null, $orderBy=null, $limit=null, $offset=null)
+ $filterArr = array();
+ if(!is_null($lastMessageId) && $lastMessageId > 0) {
+ $filterArr['message_id'] => '> '. $lastMessageId;
+ }
+ $messages = $this->dbTableHandler->get_records_using_custom_filter($filter, NULL, $limit);
+ if(!is_array($messages) && $messages === false) {
+ $messages = array();
+ }
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": error while retrieving messages, DETAILS::: ". $e->getMessages());
+ }
+ return($messages);
+ }//end get_messages()
+ //============================================================================
+
+}
+
Property changes on: trunk/0.4/abstract/cs_genericChatMessage.abstract.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Author
Revision
HeadURL
Date
Added: svn:mergeinfo
+
Copied: trunk/0.4/abstract/cs_genericChatRoom.abstract.class.php (from rev 208, trunk/0.4/abstract/cs_genericGroup.abstract.class.php)
===================================================================
--- trunk/0.4/abstract/cs_genericChatRoom.abstract.class.php (rev 0)
+++ trunk/0.4/abstract/cs_genericChatRoom.abstract.class.php 2011-03-26 00:57:34 UTC (rev 211)
@@ -0,0 +1,110 @@
+<?php
+/*
+ * Created on February 25, 2011
+ *
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+abstract class cs_genericChatRoomAbstract extends cs_chatCategoryAbstract {
+
+ /** Database object. */
+ public $db;
+
+ /** cs_globalFunctions object, for cleaning strings & such. */
+ public $gfObj;
+
+ /** Table name used to store list of chat rooms. */
+ protected $myTable = "cswal_chat_room_table";
+
+ /** Sequence for chat room table. */
+ protected $mySeq = "cswal_chat_room_table_change_room_id_seq";
+
+ /** Table handler object for simple SQL handling */
+ private $dbTableHandler;
+
+ //============================================================================
+ public function __construct(cs_phpDB $db) {
+ $this->db = $db;
+ $this->gfObj = new cs_globalFunctions;
+
+ //setup table handler.
+ $cleanString = array(
+ 'category_id' => "int",
+ 'room_name' => "text",
+ 'room_description' => "text",
+ 'is_private' => "bool",
+ 'is_closed' => "bool",
+ //'encoding' => "text"
+ );
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->myTable, $this->mySeq, 'chat_room_id', $cleanString);
+ }//end __construct()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function create_room($roomName, $roomDescription=null, $isPrivate=false) {
+ if(is_string($roomName) && strlen($room)) {
+ try {
+ if(!is_bool($isPrivate)) {
+ $isPrivate=false;
+ }
+ $insertArr = array(
+ 'room_name' => $roomName,
+ 'room_description' => $roomDescription,
+ 'is_private' => $isPrivate
+ );
+ if(is_numeric($this->categoryId)) {
+ $insertArr['category_id'] = $this->categoryId;
+ }
+ $roomId = $this->dbTableHandler->create_record($insertArr);
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": failed to create record, DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid room name (". $roomName .")");
+ }
+
+ return($roomId);
+ }//end create_room()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function update_room($roomId, array $updates) {
+ try {
+ $retval = $this->dbTableHandler->update_record($roomId, $updates);
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": failed to update room, DETAILS::: ". $e->getMessage());
+ }
+ return($retval);
+ }//end update_room();
+ //============================================================================
+
+
+
+ //============================================================================
+ public function close_room($roomId) {
+ if(is_numeric($roomId)) {
+ $retval = $this->update_room($roomId, array('is_closed'=>true));
+ }
+ else {
+ throw new exception(__METHOD__ .": roomId (". $roomId .")");
+ }
+ return($retval);
+ }//end close_room()
+ //============================================================================
+
+
+}
+
Property changes on: trunk/0.4/abstract/cs_genericChatRoom.abstract.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Author
Revision
HeadURL
Date
Added: svn:mergeinfo
+
Added: trunk/0.4/setup/genericChat.pgsql.sql
===================================================================
--- trunk/0.4/setup/genericChat.pgsql.sql (rev 0)
+++ trunk/0.4/setup/genericChat.pgsql.sql 2011-03-26 00:57:34 UTC (rev 211)
@@ -0,0 +1,54 @@
+BEGIN;
+
+--
+-- chat categories (ways to insulate chat rooms)
+--
+CREATE TABLE cswal_chat_category_table (
+ chat_category_id serial NOT NULL PRIMARY KEY,
+ category_name text NOT NULL
+);
+
+INSERT INTO cswal_chat_category_table (chat_category_id, category_name) VALUES (0, 'DEFAULT');
+
+--
+-- Chat rooms
+--
+CREATE TABLE cswal_chat_room_table (
+ chat_room_id serial NOT NULL PRIMARY KEY,
+ chat_category_id integer NOT NULL REFERENCES cswal_chat_category_table(chat_category_id) DEFAULT 0,
+ room_name text NOT NULL,
+ room_description text,
+ creation timestamptz NOT NULL DEFAULT NOW(),
+ is_private boolean NOT NULL DEFAULT false,
+ is_closed boolean NOT NULL DEFAULT false,
+ encoding text
+);
+
+
+--
+-- Chat messages
+-- NOTE::: change the reference on "uid" and "private_message_uid" to match your database schema.
+-- NOTE::: the "private_message_uid" field is for sending private messages (intended for a specific user).
+--
+CREATE TABLE cswal_chat_message_table (
+ chat_message_id serial NOT NULL PRIMARY KEY,
+ uid integer NOT NULL REFERENCES cs_authentication_table(uid),
+ private_message_uid integer DEFAULT NULL REFERENCES cs_authentication_table(uid),
+ chat_room_id integer NOT NULL REFERENCES cswal_chat_room_table(chat_room_id),
+ creation timestamptz NOT NULL DEFAULT NOW(),
+ message text NOT NULL
+);
+
+
+--
+-- Participant table
+-- NOTE: this is a *transient* table; it only has data when the chat room is active.
+--
+CREATE TABLE cswal_chat_participant_table (
+ chat_participant_id serial NOT NULL PRIMARY KEY,
+ chat_room_id integer NOT NULL REFERENCES cswal_chat_room_table(chat_room_id),
+ uid integer NOT NULL REFERENCES cs_authentication_table(uid),
+ enter_timestamp timestamptz NOT NULL DEFAULT NOW(),
+ last_received_message_id integer REFERENCES cswal_chat_message_table(chat_message_id)
+);
+
Copied: trunk/0.4/tests/testOfCSGenericChat.php (from rev 210, trunk/0.4/tests/testOfCSGenericPermissions.php)
===================================================================
--- trunk/0.4/tests/testOfCSGenericChat.php (rev 0)
+++ trunk/0.4/tests/testOfCSGenericChat.php 2011-03-26 00:57:34 UTC (rev 211)
@@ -0,0 +1,53 @@
+<?php
+/*
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+class testOfCSGenericChat extends testDbAbstract {
+
+
+ //--------------------------------------------------------------------------
+ public function __construct() {
+ }//end __construct()
+ //--------------------------------------------------------------------------
+
+
+
+ //--------------------------------------------------------------------------
+ function setUp() {
+ $this->gfObj = new cs_globalFunctions;
+ $this->gfObj->debugPrintOpt=1;
+ parent::__construct('postgres','', 'localhost', '5432');
+
+ }//end setUp()
+ //--------------------------------------------------------------------------
+
+
+
+ //--------------------------------------------------------------------------
+ public function tearDown() {
+ if(isset($GLOBALS['keepDb'])) {
+ unset($GLOBALS['keepDb']);
+ }
+ else {
+ $this->destroy_db();
+ }
+ }
+ //--------------------------------------------------------------------------
+
+
+
+ //--------------------------------------------------------------------------
+ public function test_chatCategories() {
+ }//end test_chatCategories()
+ //--------------------------------------------------------------------------
+
+
+
+}
Property changes on: trunk/0.4/tests/testOfCSGenericChat.php
___________________________________________________________________
Added: svn:keywords
+ Id
Author
Revision
HeadURL
Date
Added: svn:mergeinfo
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-02-24 19:07:03
|
Revision: 210
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=210&view=rev
Author: crazedsanity
Date: 2011-02-24 19:06:57 +0000 (Thu, 24 Feb 2011)
Log Message:
-----------
*** INITIAL RELEASE, v0.3.0 ***
Requires:
* cs-content v1.0+
Optional:
* cs-phpxml v1.0+ (for cs-siteConfig)
SUMMARY OF CAPABILITIES:::
* Authentication tokens (lost password hashes, API keys, etc)
* BBCode Parser
* Database Abastraction layer, supporting PostgreSQL, MySQL, and SQLite
* Database storage for sessions
* XML-Based unified site configuration system
* Tab system, based on templates and block rows
* Generic database logging
* Upgrade system for web applications with database backends
* Abstract class for selecting/updating/deleting on a single table
Added Paths:
-----------
releases/0.3/
Property changes on: releases/0.3
___________________________________________________________________
Added: svn:ignore
+ .project
Added: svn:mergeinfo
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-02-24 18:59:20
|
Revision: 209
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=209&view=rev
Author: crazedsanity
Date: 2011-02-24 18:59:14 +0000 (Thu, 24 Feb 2011)
Log Message:
-----------
Folder for storing stable releases of CS-WebAppLibs.
Added Paths:
-----------
releases/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-02-07 19:47:32
|
Revision: 208
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=208&view=rev
Author: crazedsanity
Date: 2011-02-07 19:47:25 +0000 (Mon, 07 Feb 2011)
Log Message:
-----------
Minor changes so the last query doesn't get overwritten by currval queries.
/db_types/cs_phpDB__pgsql.class.php:
* connect():
-- slightly better exception message...
* exec():
-- ARG CHANGE: NEW ARG: #2 ($setLastQuery=true)
-- optionally NOT set lastQuery var.
* get_currval():
-- pass false as the second argument to exec() so it doesn't get set
as the lastQuery.
Modified Paths:
--------------
trunk/0.4/db_types/cs_phpDB__pgsql.class.php
Modified: trunk/0.4/db_types/cs_phpDB__pgsql.class.php
===================================================================
--- trunk/0.4/db_types/cs_phpDB__pgsql.class.php 2011-02-07 19:37:12 UTC (rev 207)
+++ trunk/0.4/db_types/cs_phpDB__pgsql.class.php 2011-02-07 19:47:25 UTC (rev 208)
@@ -201,7 +201,7 @@
}
}
else {
- throw new exception(__METHOD__ .": paramsAreSet=(". $this->paramsAreSet ."), isConnected=(". $this->isConnected .")");
+ throw new exception(__METHOD__ .": not connected... paramsAreSet=(". $this->paramsAreSet ."), isConnected=(". $this->isConnected .")");
}
return($retval);
@@ -225,8 +225,10 @@
*
* TODO: re-implement query logging (setting debug, logfilename, etc).
*/
- function exec($query) {
- $this->lastQuery = $query;
+ function exec($query,$setLastQuery=true) {
+ if($setLastQuery) {
+ $this->lastQuery = $query;
+ }
if($this->useQueryList) {
$this->queryList[] = $query;
}
@@ -1095,7 +1097,7 @@
//=========================================================================
public function get_currval($sequence) {
if(is_string($sequence) && strlen($sequence) >= 5) {
- $numrows = $this->exec("SELECT currval('". $sequence ."')");
+ $numrows = $this->exec("SELECT currval('". $sequence ."')",false);
$dberror = $this->errorMsg();
if($numrows == 1 && !strlen($dberror)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-02-07 19:37:18
|
Revision: 207
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=207&view=rev
Author: crazedsanity
Date: 2011-02-07 19:37:12 +0000 (Mon, 07 Feb 2011)
Log Message:
-----------
Minor change to keep values deemed as empty from being removed from the SQL.
/abstract/cs_singleTableHandler.abstract.class.php:
* create_record():
-- ARG CHANGE: NEW ARG: #2 ($removeEmptyVals=TRUE)
-- pass new arg to cs_globalFunctions::string_from_array()
Modified Paths:
--------------
trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
Modified: trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-02-01 03:58:32 UTC (rev 206)
+++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-02-07 19:37:12 UTC (rev 207)
@@ -81,10 +81,10 @@
* @RETURN (int) SUCCESS: the (int) is the last inserted ID.
* @EXCEPTION FAIL: exception indicates the error.
*/
- public function create_record(array $data) {
+ public function create_record(array $data, $removeEmptyVals=TRUE) {
if(is_array($data) && count($data)) {
$sql = 'INSERT INTO '. $this->tableName .' '
- . $this->gfObj->string_from_array($data, 'insert', null, $this->cleanStringArr, true);
+ . $this->gfObj->string_from_array($data, 'insert', null, $this->cleanStringArr, $removeEmptyVals);
try {
$newId = $this->dbObj->run_insert($sql, $this->seqName);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-02-01 03:58:38
|
Revision: 206
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=206&view=rev
Author: crazedsanity
Date: 2011-02-01 03:58:32 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
Remove some debugging stuff.
Modified Paths:
--------------
trunk/0.4/abstract/cs_genericObject.abstract.class.php
Modified: trunk/0.4/abstract/cs_genericObject.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_genericObject.abstract.class.php 2011-02-01 03:51:37 UTC (rev 205)
+++ trunk/0.4/abstract/cs_genericObject.abstract.class.php 2011-02-01 03:58:32 UTC (rev 206)
@@ -124,19 +124,13 @@
$missingIndexes = array_diff($objectNames, $nvpArray);
if(count($missingIndexes)) {
-$this->gfObj->debug_print(__METHOD__ .": MISSING INDEXES::: ". $this->gfObj->debug_print($missingIndexes,0,1));
foreach($missingIndexes as $newObjectName) {
$newId = $this->create_object($newObjectName);
$nvpArray[$newId] = $newObjectName;
}
}
-$this->gfObj->debug_print(__METHOD__ .": createMissing=(". $createMissing ."), counts=(". count($objectNames) ."/". count($nvpArray) ."/". count($missingIndexes)."), SQL::: ". $sql);
}
if(!is_array($nvpArray) || !count($nvpArray)) {
-$this->gfObj->debug_print(__METHOD__ .": objectNames::: ". $this->gfObj->debug_print($objectNames,0,1));
-$this->gfObj->debug_print(__METHOD__ .": nvpArray::: ". $this->gfObj->debug_print($nvpArray,0,1));
-$this->gfObj->debug_print(__METHOD__ .": missingIndexes::: ". $this->gfObj->debug_print($missingIndexes,0,1));
-cs_debug_backtrace(1);
throw new exception(__METHOD__ .": no data returned");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-02-01 03:51:44
|
Revision: 205
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=205&view=rev
Author: crazedsanity
Date: 2011-02-01 03:51:37 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
Updated tests & schema.
/setup/genericPermissions.pgsql.sql:
* cswal_group_table:
-- group_admin: changed to NOT NULL
* cswal_object_table:
-- object_id: changed to serial (instead of integer)
* cswal_permission_table:
-- object_path: removed UNIQUE constraint
* MAIN...
-- remove arbitrary INSERT statements
-- add a constraint to the cswal_permission_table
/tests/testOfCSGenericPermissions.php:
* setUp():
-- supplement all the arbitrary insertsfrom the setup file with code
before each run...
* get_valid_users():
-- set some internal vars for later testing.
* test_userGroups():
-- more tests...
* test_object_paths() [NEW]:
-- testing creation & manipulation of ID and object paths
* test_permissions():
-- build a larger list of permissions for testing
* _gpTester{}:
-- create testDbTableHandler object for SQL stuff.
Modified Paths:
--------------
trunk/0.4/setup/genericPermissions.pgsql.sql
trunk/0.4/tests/testOfCSGenericPermissions.php
Modified: trunk/0.4/setup/genericPermissions.pgsql.sql
===================================================================
--- trunk/0.4/setup/genericPermissions.pgsql.sql 2011-02-01 03:29:22 UTC (rev 204)
+++ trunk/0.4/setup/genericPermissions.pgsql.sql 2011-02-01 03:51:37 UTC (rev 205)
@@ -6,7 +6,7 @@
CREATE TABLE cswal_group_table (
group_id serial NOT NULL PRIMARY KEY,
group_name text NOT NULL UNIQUE,
- group_admin integer REFERENCES cs_authentication_table(uid),
+ group_admin integer NOT NULL REFERENCES cs_authentication_table(uid),
created TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
@@ -43,7 +43,7 @@
-- with ID's, such as "member"=1, "blog"=2, "edit"=3; the object path would then be ":1::2::3:".
--
CREATE TABLE cswal_object_table (
- object_id integer NOT NULL PRIMARY KEY,
+ object_id serial NOT NULL PRIMARY KEY,
object_name text NOT NULL UNIQUE,
created TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
@@ -60,7 +60,7 @@
CREATE TABLE cswal_permission_table (
permission_id serial NOT NULL PRIMARY KEY,
system_name integer NOT NULL DEFAULT 0 REFERENCES cswal_system_table(system_id),
- object_path text NOT NULL UNIQUE,
+ object_path text NOT NULL,
user_id integer NOT NULL REFERENCES cs_authentication_table(uid),
group_id integer NOT NULL REFERENCES cswal_group_table(group_id),
inherit boolean NOT NULL DEFAULT FALSE,
@@ -78,20 +78,6 @@
INSERT INTO cswal_system_table (system_id, system_name) VALUES (0, 'DEFAULT');
-INSERT INTO cswal_group_table (group_name) VALUES ('www');
-INSERT INTO cswal_group_table (group_name) VALUES ('blogs');
-INSERT INTO cswal_group_table (group_name) VALUES ('admin');
+ALTER TABLE ONLY cswal_permission_table
+ ADD CONSTRAINT cswal_permission_table_system_path_key UNIQUE (system_name, object_path);
-INSERT INTO cswal_object_table (object_id, object_name) VALUES (0, '{APPURL}');
-INSERT INTO cswal_object_table (object_id, object_name) VALUES (1, 'member');
-
-INSERT INTO cswal_permission_table
- (object_path,user_id, group_id)
- VALUES
- (':0:', 101, 1);
-
-INSERT INTO cswal_permission_table
- (object_path, user_id, group_id, g_r, g_w)
- VALUES
- (':0::1:', 101, 2, true, true);
-
Modified: trunk/0.4/tests/testOfCSGenericPermissions.php
===================================================================
--- trunk/0.4/tests/testOfCSGenericPermissions.php 2011-02-01 03:29:22 UTC (rev 204)
+++ trunk/0.4/tests/testOfCSGenericPermissions.php 2011-02-01 03:51:37 UTC (rev 205)
@@ -29,6 +29,39 @@
$this->permObj = new _gpTester($this->db);
$this->permObj->do_schema();
$this->get_valid_users();
+
+ $this->defaultGroupId = null;
+
+ //create some groups.
+ {
+ $myGroupList = array('www', 'blogs', 'admin', __METHOD__);
+ #$newGroupId = $this->permObj->create_group(__METHOD__);
+ $userKeys = array_keys($this->validUsers);
+ foreach($myGroupList as $tName) {
+ $newGroupId = $this->permObj->create_group($tName, $this->chosenOneUid);
+ if(is_null($this->defaultGroupId)) {
+ $this->defaultGroupId = $newGroupId;
+ }
+ $this->assertTrue(is_numeric($newGroupId));
+ }
+
+ $groupList = $this->permObj->get_all_groups();
+
+ foreach($groupList as $groupId=>$groupData) {
+ $this->assertEqual($this->permObj->get_group_by_id($groupId), $groupData, "failed to get group (". $groupData['group_name'] .") by ID (". $groupId .")");
+ $this->assertEqual($this->permObj->get_group($groupData['group_name']), $groupData, "failed to get group (". $groupData['group_name'] .") by name");
+ }
+ }
+
+ //create some objects...
+ {
+ $requiredItems = array('{APPURL}', 'member');
+ foreach($requiredItems as $name) {
+ $newId = $this->permObj->create_object($name);
+ $this->assertTrue(is_numeric($newId));
+ }
+ }
+
}//end setUp()
//--------------------------------------------------------------------------
@@ -55,6 +88,11 @@
$sql = "SELECT uid,username FROM cs_authentication_table ORDER BY uid";
try {
$this->validUsers = $this->db->run_query($sql);
+
+ $userKeys = array_keys($this->validUsers);
+ $myUser = $this->validUsers[$userKeys[0]];
+ $this->chosenOneUid = $myUser['uid'];
+ $this->defaultUid = $this->chosenOneUid;
}
catch(Exception $e) {
cs_debug_backtrace(1);
@@ -82,25 +120,12 @@
$this->assertTrue(isset($groupList[$myKey]['group_id']));
}
- //create some groups.
- {
- $newGroupId = $this->permObj->create_group(__METHOD__);
- $this->assertTrue(is_numeric($newGroupId));
-
- $groupList = $this->permObj->get_all_groups();
-
- foreach($groupList as $groupId=>$groupData) {
- $this->assertEqual($this->permObj->get_group_by_id($groupId), $groupData, "failed to get group (". $groupData['group_name'] .") by ID (". $groupId .")");
- $this->assertEqual($this->permObj->get_group($groupData['group_name']), $groupData, "failed to get group (". $groupData['group_name'] .") by name");
- }
- }
-
//create & test user_group relationships.
{
- $newId = $this->permObj->create_user_group($this->validUsers[$myKey]['uid'],$newGroupId);
+ $newId = $this->permObj->create_user_group($this->validUsers[$myKey]['uid'],$this->defaultGroupId);
$this->assertTrue(is_numeric($newId));
- $this->assertTrue($this->permObj->is_group_member($this->validUsers[$myKey]['uid'],$newGroupId), "user (".
- $this->validUsers[$myKey]['uid'] .") isn't member of group (". $newGroupId .") after being added to it... ");
+ $this->assertTrue($this->permObj->is_group_member($this->validUsers[$myKey]['uid'],$this->defaultGroupId), "user (".
+ $this->validUsers[$myKey]['uid'] .") isn't member of group (". $this->defaultGroupId .") after being added to it... ");
$ugList = $this->permObj->get_user_groups($this->validUsers[$myKey]['uid']);
$this->assertTrue(is_array($ugList));
@@ -113,7 +138,73 @@
//--------------------------------------------------------------------------
+ public function test_object_paths() {
+ //basic functionality test for ID Path creation.
+ {
+ $expectThis = ':5::30::2::18::5:';
+
+ //make the expected string into something that be broken into an array of numbers.
+ $chunktify = preg_replace('/^:(.*):$/', '$1', $expectThis);
+ $chunktify = preg_replace('/:{2,}/', ':', $chunktify);
+ $bits = explode(':', $chunktify);
+
+ $this->assertEqual($bits, $this->permObj->explode_id_path($expectThis));
+
+ $this->assertEqual(count($bits), 5, 'could not break string into id bits');
+
+ $derivedIdPath = "";
+ foreach($bits as $id) {
+ $derivedIdPath .= $this->permObj->create_id_path_part($id);
+ }
+ $this->assertEqual($derivedIdPath, $expectThis, 'Invalid idPath, expected=('. $expectThis .'), actual=('. $derivedIdPath .')');
+
+ $idPathList = array(':9:', ':9::5:', ':0::0::0:', ':-1:', ':-1::-1:', ':-400::1::3:', ':51041::600000::8109223::999999999999999999999999999999999:');
+ foreach($idPathList as $tPath) {
+ $this->assertTrue($this->permObj->is_id_path($tPath), "valid path (". $tPath .") not recognized as such");
+ }
+
+ $invalidIdPathList = array('', ':--1:', '1::3::4:', ':1::3::4', ':1:3:4:');
+ foreach($invalidIdPathList as $tPath) {
+ $this->assertFalse($this->permObj->is_id_path($tPath), "invalid path (". $tPath .") evaluated as valid");
+ }
+ }
+
+ //Search for existing items (should have been created from setUp())
+ {
+ $requiredItems = array('{APPURL}', 'member');
+ $existingItems = $this->permObj->get_object_ids($requiredItems, false);
+ $this->assertEqual(count($existingItems), 2, 'Required items not present... '. $this->gfObj->debug_print($existingItems,0,1));
+
+ //in the event the required items aren't there, create them.
+ $testExistingItems = $this->permObj->get_object_ids($requiredItems, true);
+ $this->assertEqual(count($requiredItems), count($testExistingItems), 'failed to create some existing items');
+ $this->assertEqual(count($testExistingItems), count($existingItems), 'WARNING: some required items were not found');
+ }
+
+ //Build new ID paths...
+ {
+ $newObjects = array('admin', 'logs', 'view');
+ $idPath = $this->permObj->create_id_path('/admin/logs/view');
+ $this->assertTrue(preg_match('/^:[0-9]{1,}::[0-9]{1,}::[0-9]{1,}:/', $idPath), 'path appears syntactically incorrect ('. $idPath .')');
+
+ //make sure the manually-created ID Path matches what was actually created.
+ $idList = $this->permObj->get_object_ids($newObjects, false);
+ $this->assertEqual(count($idList), count($newObjects), "there must be missing objects, counts don't match");
+
+ $expectedIdPath = "";
+ foreach($idList as $id=>$n) {
+ $expectedIdPath .= $this->permObj->create_id_path_part($id);
+ }
+ $this->assertEqual($expectedIdPath, $idPath, "Manually created path (". $expectedIdPath .") does not match idPath (". $idPath .")");
+ }
+ }//end test_object_paths()
+ //--------------------------------------------------------------------------
+
+
+
+ //--------------------------------------------------------------------------
public function test_permissions() {
+ #$GLOBALS['keepDb'] = true;
//Test permission string parsing.
{
@@ -169,7 +260,9 @@
$usePermName = __METHOD__ .'/test1';
$this->assertFalse($this->permObj->permission_exists($usePermName));
$permId = $this->permObj->create_permission($usePermName, $myUid, 1, $usePermString);
- $this->assertTrue($this->permObj->permission_exists($usePermName));
+ if(!$this->assertTrue($this->permObj->permission_exists($usePermName), "Permission ('". $usePermName ."', id=". $permId .") does not exist")) {
+ $this->gfObj->debug_print($this->permObj->testDbTableHandler->get_records());
+ }
$this->assertTrue(is_numeric($permId));
//the method 'build_permissions_string()' should disregard extra indices in the array & build the string.
@@ -199,14 +292,57 @@
$this->assertEqual($this->permObj->has_write_permission(0,$usePermName), $this->permObj->has_write_permission($thirdUser,$usePermName));
$this->assertEqual($this->permObj->has_execute_permission(0,$usePermName), $this->permObj->has_execute_permission($thirdUser,$usePermName));
}
+
+ //create a huge list of permissions to test different scenarios.
+ {
+ $testPaths = array(
+ '/member',
+ '/member/ttorp',
+ '/member/ttorp/character',
+ '/member/ttorp/character/sheet',
+ '/member/ttorp/character/sheet/44',
+ '/admin/x',
+ '/admin/logs',
+ '/test/scripts/1/2/3/magicMarker',
+ '/api/system/test/212312300231223.21231/get/333',
+ '/content/dev/corner/cs/project',
+ '/content/dev/corner/cs/web/app/libs',
+ '/content/dev',
+ '/content/dev/corner',
+ '/content/dev/coner/cs',
+
+ //The following items fail for no apparent reason (that I can find)...
+ '/admin',
+ '/cntenx',
+ '/content/dev/corner/cs/content', //fails due to duplicate objects in path ("content" is in there twice).
+ );
+ $testPerms = array(
+ 'rwxrwxrwx',
+ 'rwxrwx---',
+ 'rwx---rwx',
+ '---rwxrwx',
+ 'rwx------',
+ '---------',
+ 'r--r--r--',
+ '-w--w--w-',
+ '--x--x--x'
+ );
+ foreach($testPaths as $tPath) {
+ $tPermString = 'rwxrwx---';
+ $newPermId = $this->permObj->create_permission($tPath, $this->chosenOneUid, $this->defaultGroupId, $tPermString);
+ $this->assertTrue(is_numeric($newPermId));
+ }
+ }///*/
}//end test_permissions
//--------------------------------------------------------------------------
}
class _gpTester extends cs_genericPermission {
+ public $testDbTableHandler;
public function __construct($db) {
parent::__construct($db);
+ $this->testDbTableHandler = $this->dbTableHandler;
}
public function do_schema() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-02-01 03:29:28
|
Revision: 204
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=204&view=rev
Author: crazedsanity
Date: 2011-02-01 03:29:22 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
Use ID paths instead of string-based paths.
/cs_genericPermission.class.php:
* __construct():
-- change "object_path" to use the "email_plus" style of string
cleaning (there should really be a more extensible way of using that)
* create_object() [DELETED]:
-- unnecessary alias method
* create_permission():
-- call create_id_path() to set the value for 'object_path'.
-- throw an exception if creating the ID path fails.
-- NOTE::: the new exception is caught by the outer exception, which
will not display those details...
* get_permission():
-- create an ID path to find the object.
-- translates the ID path into an actual path.
* explode_path():
-- separates the given real path into bits so that it can be turned
into an ID path
* create_id_path():
-- creates the ID path for a given normal path.
/abstract/cs_genericGroup.abstract.class.php:
* __construct():
-- 'group_name' gets cleaned like email
* create_group():
-- ARG CHANGE: NEW ARG: #2 ($adminUid)
-- requires the admin's UID when creating the record.
/abstract/cs_genericObject.abstract.class.php:
* __construct():
-- change cleaning of object_name from text to sql
* create_object():
-- catch exception if create_record() throws one
* get_object_ids() [NEW]:
-- build an array of object ID's based on the given names
* create_id_path_part() [NEW]:
-- basically surrounds the given number with colons (i.e. '2' -> ':2:')
* create_id_path_from_objects() [NEW]:
-- creates an ID path from an array of object names.
* clean_object_name() [NEW]:
-- special cleaning so the colons don't get stripped.
* is_id_path() [NEW]:
-- determines if the given string is an ID path or not
* explode_id_path() [NEW]:
-- breaks up an ID path into IDs
* get_object_names() [NEW]:
-- retrieves a list of names associated with the id's in the passed array.
Modified Paths:
--------------
trunk/0.4/abstract/cs_genericGroup.abstract.class.php
trunk/0.4/abstract/cs_genericObject.abstract.class.php
trunk/0.4/cs_genericPermission.class.php
Modified: trunk/0.4/abstract/cs_genericGroup.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_genericGroup.abstract.class.php 2011-01-27 15:04:24 UTC (rev 203)
+++ trunk/0.4/abstract/cs_genericGroup.abstract.class.php 2011-02-01 03:29:22 UTC (rev 204)
@@ -35,7 +35,7 @@
//setup table handler.
$cleanString = array(
- 'group_name' => 'text',
+ 'group_name' => 'email',
'group_admin' => 'integer'
);
$this->dbTableHandler = new cs_dbTableHandler($this->db, $this->groupTable, $this->groupSeq, 'group_id', $cleanString);
@@ -59,9 +59,13 @@
//============================================================================
- public function create_group($name) {
+ public function create_group($name, $adminUid) {
try{
- $newId = $this->dbTableHandler->create_record(array('group_name'=>$this->clean_group_name($name)));
+ $insertData = array(
+ 'group_name' => $this->clean_group_name($name),
+ 'group_admin' => $adminUid
+ );
+ $newId = $this->dbTableHandler->create_record($insertData);
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to create new record, DETAILS::: ". $e->getMessage());
Modified: trunk/0.4/abstract/cs_genericObject.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_genericObject.abstract.class.php 2011-01-27 15:04:24 UTC (rev 203)
+++ trunk/0.4/abstract/cs_genericObject.abstract.class.php 2011-02-01 03:29:22 UTC (rev 204)
@@ -25,7 +25,7 @@
public function __construct(cs_phpDB $db) {
parent::__construct($db);
$cleanString = array(
- 'object_name' => 'text'
+ 'object_name' => 'sql'
);
$this->dbTableHandler = new cs_dbTableHandler($this->db, $this->oTable, $this->oSeq, 'group_id', $cleanString);
}//end __construct()
@@ -36,7 +36,12 @@
//============================================================================
public function create_object($objectName) {
if(strlen($objectName)) {
- $newId = $this->dbTableHandler->create_record(array('object_name', $objectName));
+ try {
+ $newId = $this->dbTableHandler->create_record(array('object_name' => $objectName));
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": failed to create object, DETAILS::: ". $e->getMessage());
+ }
}
else {
throw new exception(__METHOD__ .": invalid object name (". $objectName .")");
@@ -86,7 +91,189 @@
//============================================================================
+ public function get_object_ids(array $objectNames, $createMissing=true) {
+ $nvpArray = array();
+ if(is_array($objectNames) && count($objectNames)) {
+ $sql = "SELECT object_id, object_name FROM ". $this->oTable ." WHERE "
+ . "object_name IN ";
+
+ $myFilter = "";
+ foreach($objectNames as $n) {
+ $tString = "'". $this->clean_object_name($n) ."'";
+ $myFilter = $this->gfObj->create_list($myFilter, $tString);
+ }
+ $sql .= '('. $myFilter .')';
+
+ try {
+ $nvpArray = $this->dbTableHandler->dbObj->run_query($sql, 'object_id', 'object_name');
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": failed to retrieve object list, DETAILS::: ". $e->getMessage());
+ }
+
+ try {
+ if($createMissing === true) {
+ //clean object names...
+ foreach($objectNames as $i=>$n) {
+ $objectNames[$i] = $this->clean_object_name($n);
+ }
+ //pull the missing indexes out so they can be created...
+ if(!is_array($nvpArray)) {
+ $nvpArray = array();
+ }
+ $missingIndexes = array_diff($objectNames, $nvpArray);
+
+ if(count($missingIndexes)) {
+$this->gfObj->debug_print(__METHOD__ .": MISSING INDEXES::: ". $this->gfObj->debug_print($missingIndexes,0,1));
+ foreach($missingIndexes as $newObjectName) {
+ $newId = $this->create_object($newObjectName);
+ $nvpArray[$newId] = $newObjectName;
+ }
+ }
+$this->gfObj->debug_print(__METHOD__ .": createMissing=(". $createMissing ."), counts=(". count($objectNames) ."/". count($nvpArray) ."/". count($missingIndexes)."), SQL::: ". $sql);
+ }
+ if(!is_array($nvpArray) || !count($nvpArray)) {
+$this->gfObj->debug_print(__METHOD__ .": objectNames::: ". $this->gfObj->debug_print($objectNames,0,1));
+$this->gfObj->debug_print(__METHOD__ .": nvpArray::: ". $this->gfObj->debug_print($nvpArray,0,1));
+$this->gfObj->debug_print(__METHOD__ .": missingIndexes::: ". $this->gfObj->debug_print($missingIndexes,0,1));
+cs_debug_backtrace(1);
+ throw new exception(__METHOD__ .": no data returned");
+ }
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": error while creating missing objects, DETAILS::: ". $e->getMessage());
+ }
+ }
+ return($nvpArray);
+ }//end get_object_ids()
//============================================================================
+
+
+ //============================================================================
+ public function create_id_path_part($id) {
+ if(is_numeric($id)) {
+ $retval = ':'. $id .':';
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid id (". $id .")");
+ }
+ return($retval);
+ }//end create_id_path_part()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function create_id_path_from_objects(array $objects) {
+ try {
+ $myIds = $this->get_object_ids($objects,true);
+
+ $idPath = "";
+ if(is_array($myIds) && count($myIds)) {
+ foreach($myIds as $id=>$name) {
+ try {
+ $idPath = $this->gfObj->create_list($idPath, $this->create_id_path_part($id), '');
+ }
+ catch(Exception $e) {
+ throw new exception($e->getMessage());
+ }
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": failed to create any IDs");
+ }
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": failed to create id path, DETAILS::: ". $e->getMessage());
+ }
+ return($idPath);
+ }//end create_id_path_from_objects()
+ //============================================================================
+
+
+
+ //============================================================================
+ protected function clean_object_name($n) {
+ //pulled from cs-content, cs_globalFunctions::cleanString(), style="query"; modified to allow the brackets.
+ $evilChars = array("\$", ":", "%", "~", "*",">", "<", "-", "[", "]", ")", "(", "&", "#", "?", ".", "\,","\/","\\","\"","\|","!","^","+","`","\n","\r");
+ $n = preg_replace("/\|/","",$n);
+ $n = preg_replace("/\'/", "", $n);
+ $n = str_replace($evilChars,"", $n);
+ $n = stripslashes(addslashes($n));
+
+ return($n);
+ }//end clean_object_name($n)
+ //============================================================================
+
+
+
+ //============================================================================
+ public function is_id_path($path) {
+ $isPath = false;
+ if(is_string($path) && strlen($path)) {
+ if(preg_match('/^(:-{0,1}[0-9]{1,}:){1,}$/', $path)) {
+ $isPath = true;
+ }
+ }
+ return($isPath);
+ }//end is_id_path()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function explode_id_path($idPath) {
+ //make the expected string into something that be broken into an array of numbers.
+ $chunktify = preg_replace('/^:(.*):$/', '$1', $idPath);
+ $chunktify = preg_replace('/:{2,}/', ':', $chunktify);
+ $bits = explode(':', $chunktify);
+ return($bits);
+ }//end explode_id_path()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function translate_id_path($idPath) {
+ if($this->is_id_path($idPath)) {
+ $bits = $this->explode_id_path($idPath);
+ $translatedPath = $this->get_object_names($this->explode_id_path($idPath));
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid path (". $idPath .")");
+ }
+ return($translatedPath);
+ }//end translate_id_path()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function get_object_names(array $idList) {
+ if(is_array($idList) && count($idList)) {
+ $sql = "SELECT object_id, object_name FROM ". $this->oTable ." WHERE object_id IN ";
+
+ $idListString = "";
+ foreach($idList as $id) {
+ $idListString = $this->gfObj->create_list($idListString, $id, ", ");
+ }
+ $sql .= "(". $idListString .")";
+
+ //run it.
+ try {
+ $objectNames = $this->dbTableHandler->dbObj->run_query($sql, 'object_id', 'object_name');
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": error while retrieving object names, DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid data type (". gettype($idList) .") or empty array");
+ }
+ return($objectNames);
+ }//end get_object_names()
+ //============================================================================
+
}
?>
Modified: trunk/0.4/cs_genericPermission.class.php
===================================================================
--- trunk/0.4/cs_genericPermission.class.php 2011-01-27 15:04:24 UTC (rev 203)
+++ trunk/0.4/cs_genericPermission.class.php 2011-02-01 03:29:22 UTC (rev 204)
@@ -36,7 +36,7 @@
protected $pathCleaner=true;
/** dbTableHandler{} object for easier SQL. */
- private $dbTableHandler;
+ protected $dbTableHandler;
//============================================================================
/**
@@ -65,7 +65,7 @@
}
$cleanString = array(
'system_name' => 'integer',
- 'object_path' => 'text',
+ 'object_path' => 'email_plus',
'user_id' => 'integer',
'group_id' => 'integer',
'inherit' => 'bool',
@@ -167,46 +167,21 @@
//============================================================================
- /**
- * Same as create_permission().
- */
- public function create_object($name, $userId, $groupId, $permString) {
- return($this->create_permission($name, $userId, $groupId, $permString));
- }//end create_object()
- //============================================================================
-
-
-
- //============================================================================
/**
* Creates a permission object record.
*/
public function create_permission($name, $userId, $groupId, $permString) {
if(is_string($name) && strlen($name) && is_numeric($userId) && $userId >= 0 && is_numeric($groupId) && $groupId >= 0) {
- $cleanStringArr = array(
- 'object_path' => 'sql',
- 'user_id' => 'numeric',
- 'group_id' => 'numeric',
- 'u_r' => 'bool',
- 'u_w' => 'bool',
- 'u_x' => 'bool',
- 'g_r' => 'bool',
- 'g_w' => 'bool',
- 'g_x' => 'bool',
- 'o_r' => 'bool',
- 'o_w' => 'bool',
- 'o_x' => 'bool'
- );
try{
$insertArr = $this->parse_permission_string($permString);
- $insertArr['object_path'] = $this->gfObj->cleanString($name, 'sql', 0);
+ $insertArr['object_path'] = $this->create_id_path($name);
$insertArr['user_id'] = $userId;
$insertArr['group_id'] = $groupId;
$newId = $this->dbTableHandler->create_record($insertArr);
}
catch(Exception $e) {
- throw new exception(__METHOD__ .":: failed to create new record, DETAILS::: ". $e->getMessage());
+ throw new exception(__METHOD__ .":: failed to create new record, name=(". $name ."), permString=(". $permString .") DETAILS::: ". $e->getMessage());
}
}
else {
@@ -225,7 +200,14 @@
*/
public function get_permission($name) {
try {
+ if(!$this->is_id_path($name)) {
+ $name = $this->create_id_path($name);
+ }
$retval = $this->dbTableHandler->get_single_record(array('object_path'=>$name));
+
+ //now translate the object_path...
+ // TODO: this could be a resource hog if called in rapid succession; consider creating an object cache or whatnot
+ $retval['translated_path'] = $this->translate_id_path($retval['object_path']);
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: error while locating permission '". $name ."', DETAILS::: ". $e->getMessage());
@@ -265,6 +247,9 @@
* Check available permissions...
*/
public function check_permission($objectName, $userId) {
+ if(!$this->is_id_path($objectName)) {
+ $objectName = $this->create_id_path($objectName,false);
+ }
$availablePerms = array(
'r' => false,
'w' => false,
@@ -410,5 +395,38 @@
return($retval);
}//end has_execute_permission()
//============================================================================
+
+
+
+ //============================================================================
+ public function explode_path($path) {
+ if(is_string($path) && strlen($path)) {
+ $path = preg_replace('/^'. addcslashes($this->objectDelimiter, '/') .'/', '', $path);
+ $path = preg_replace('/'. addcslashes($this->objectDelimiter, '/') .'{2,}/', $this->objectDelimiter, $path);
+ $bits = explode($this->objectDelimiter, $path);
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid path (". $path .")");
+ }
+ return($bits);
+ }//end explode_path()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function create_id_path($path) {
+ //Get the list of objects from the path.
+ $bits = $this->explode_path($path);
+
+ //now create the path.
+ $newPath = $this->create_id_path_from_objects($bits);
+ if(!$this->is_id_path($newPath)) {
+ throw new exception(__METHOD__ .": failed to create ID path from (". $path .")");
+ }
+
+ return($newPath);
+ }//end create_id_path()
+ //============================================================================
}
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-01-27 15:04:30
|
Revision: 203
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=203&view=rev
Author: crazedsanity
Date: 2011-01-27 15:04:24 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
Fix naming of cs_genericObject, cs_genericPermission now extends it.
Modified Paths:
--------------
trunk/0.4/cs_genericPermission.class.php
Added Paths:
-----------
trunk/0.4/abstract/cs_genericObject.abstract.class.php
Removed Paths:
-------------
trunk/0.4/abstract/cs_genericObject.class.php
Copied: trunk/0.4/abstract/cs_genericObject.abstract.class.php (from rev 202, trunk/0.4/abstract/cs_genericObject.class.php)
===================================================================
--- trunk/0.4/abstract/cs_genericObject.abstract.class.php (rev 0)
+++ trunk/0.4/abstract/cs_genericObject.abstract.class.php 2011-01-27 15:04:24 UTC (rev 203)
@@ -0,0 +1,92 @@
+<?php
+
+/*
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+abstract class cs_genericObjectAbstract extends cs_genericUserGroupAbstract {
+
+ /** Table name used to store object records. */
+ protected $oTable = "cswal_object_table";
+
+ /** Sequence for object table. */
+ protected $oSeq = "cswal_object_table_object_id_seq";
+
+ /** dbTableHandler{} object for simplifying SQL. */
+ private $dbTableHandler;
+
+ //============================================================================
+ public function __construct(cs_phpDB $db) {
+ parent::__construct($db);
+ $cleanString = array(
+ 'object_name' => 'text'
+ );
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->oTable, $this->oSeq, 'group_id', $cleanString);
+ }//end __construct()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function create_object($objectName) {
+ if(strlen($objectName)) {
+ $newId = $this->dbTableHandler->create_record(array('object_name', $objectName));
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid object name (". $objectName .")");
+ }
+ return($newId);
+ }//end create_object()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function get_object_by_name($objectName) {
+ if(strlen($objectName)) {
+ try {
+ $retval = $this->dbTableHandler->get_single_record(array('object_name'=>$objectName));
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to object from name=(". $objectName ."), DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .":: invalid object name (". $objectName .")");
+ }
+ return($retval);
+ }//end get_object_by_name()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function get_object_by_id($objectId) {
+ if(strlen($objectName)) {
+ try {
+ $retval = $this->dbTableHandler->get_record_by_id($objectId);
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to object for ID=(". $objectId ."), DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .":: invalid object ID (". $objectId .")");
+ }
+ return($retval);
+ }//end get_object_by_id()
+ //============================================================================
+
+
+
+ //============================================================================
+ //============================================================================
+
+}
+?>
Deleted: trunk/0.4/abstract/cs_genericObject.class.php
===================================================================
--- trunk/0.4/abstract/cs_genericObject.class.php 2011-01-27 14:53:53 UTC (rev 202)
+++ trunk/0.4/abstract/cs_genericObject.class.php 2011-01-27 15:04:24 UTC (rev 203)
@@ -1,92 +0,0 @@
-<?php
-
-/*
- * FILE INFORMATION:
- *
- * $HeadURL$
- * $Id$
- * $LastChangedDate$
- * $LastChangedBy$
- * $LastChangedRevision$
- */
-
-abstract class cs_genericObject extends cs_genericUserGroupAbstract {
-
- /** Table name used to store object records. */
- protected $oTable = "cswal_object_table";
-
- /** Sequence for object table. */
- protected $oSeq = "cswal_object_table_object_id_seq";
-
- /** dbTableHandler{} object for simplifying SQL. */
- private $dbTableHandler;
-
- //============================================================================
- public function __construct(cs_phpDB $db) {
- parent::__construct($db);
- $cleanString = array(
- 'object_name' => 'text'
- );
- $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->oTable, $this->oSeq, 'group_id', $cleanString);
- }//end __construct()
- //============================================================================
-
-
-
- //============================================================================
- public function create_object($objectName) {
- if(strlen($objectName)) {
- $newId = $this->dbTableHandler->create_record(array('object_name', $objectName));
- }
- else {
- throw new exception(__METHOD__ .": invalid object name (". $objectName .")");
- }
- return($newId);
- }//end create_object()
- //============================================================================
-
-
-
- //============================================================================
- public function get_object_by_name($objectName) {
- if(strlen($objectName)) {
- try {
- $retval = $this->dbTableHandler->get_single_record(array('object_name'=>$objectName));
- }
- catch(Exception $e) {
- throw new exception(__METHOD__ .":: failed to object from name=(". $objectName ."), DETAILS::: ". $e->getMessage());
- }
- }
- else {
- throw new exception(__METHOD__ .":: invalid object name (". $objectName .")");
- }
- return($retval);
- }//end get_object_by_name()
- //============================================================================
-
-
-
- //============================================================================
- public function get_object_by_id($objectId) {
- if(strlen($objectName)) {
- try {
- $retval = $this->dbTableHandler->get_record_by_id($objectId);
- }
- catch(Exception $e) {
- throw new exception(__METHOD__ .":: failed to object for ID=(". $objectId ."), DETAILS::: ". $e->getMessage());
- }
- }
- else {
- throw new exception(__METHOD__ .":: invalid object ID (". $objectId .")");
- }
- return($retval);
- }//end get_object_by_id()
- //============================================================================
-
-
-
- //============================================================================
- //============================================================================
-
-}
-?>
Modified: trunk/0.4/cs_genericPermission.class.php
===================================================================
--- trunk/0.4/cs_genericPermission.class.php 2011-01-27 14:53:53 UTC (rev 202)
+++ trunk/0.4/cs_genericPermission.class.php 2011-01-27 15:04:24 UTC (rev 203)
@@ -11,7 +11,7 @@
* $LastChangedRevision$
*/
-class cs_genericPermission extends cs_genericUserGroupAbstract {
+class cs_genericPermission extends cs_genericObjectAbstract {
/** Database object. */
public $db;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-01-27 14:53:59
|
Revision: 202
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=202&view=rev
Author: crazedsanity
Date: 2011-01-27 14:53:53 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
Class for handling generic objects (for the permissions system, but could be re-used).
Added Paths:
-----------
trunk/0.4/abstract/cs_genericObject.class.php
Copied: trunk/0.4/abstract/cs_genericObject.class.php (from rev 195, trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php)
===================================================================
--- trunk/0.4/abstract/cs_genericObject.class.php (rev 0)
+++ trunk/0.4/abstract/cs_genericObject.class.php 2011-01-27 14:53:53 UTC (rev 202)
@@ -0,0 +1,92 @@
+<?php
+
+/*
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+abstract class cs_genericObject extends cs_genericUserGroupAbstract {
+
+ /** Table name used to store object records. */
+ protected $oTable = "cswal_object_table";
+
+ /** Sequence for object table. */
+ protected $oSeq = "cswal_object_table_object_id_seq";
+
+ /** dbTableHandler{} object for simplifying SQL. */
+ private $dbTableHandler;
+
+ //============================================================================
+ public function __construct(cs_phpDB $db) {
+ parent::__construct($db);
+ $cleanString = array(
+ 'object_name' => 'text'
+ );
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->oTable, $this->oSeq, 'group_id', $cleanString);
+ }//end __construct()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function create_object($objectName) {
+ if(strlen($objectName)) {
+ $newId = $this->dbTableHandler->create_record(array('object_name', $objectName));
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid object name (". $objectName .")");
+ }
+ return($newId);
+ }//end create_object()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function get_object_by_name($objectName) {
+ if(strlen($objectName)) {
+ try {
+ $retval = $this->dbTableHandler->get_single_record(array('object_name'=>$objectName));
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to object from name=(". $objectName ."), DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .":: invalid object name (". $objectName .")");
+ }
+ return($retval);
+ }//end get_object_by_name()
+ //============================================================================
+
+
+
+ //============================================================================
+ public function get_object_by_id($objectId) {
+ if(strlen($objectName)) {
+ try {
+ $retval = $this->dbTableHandler->get_record_by_id($objectId);
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .":: failed to object for ID=(". $objectId ."), DETAILS::: ". $e->getMessage());
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .":: invalid object ID (". $objectId .")");
+ }
+ return($retval);
+ }//end get_object_by_id()
+ //============================================================================
+
+
+
+ //============================================================================
+ //============================================================================
+
+}
+?>
Property changes on: trunk/0.4/abstract/cs_genericObject.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Author
Revision
HeadURL
Date
Added: svn:mergeinfo
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-01-27 06:18:16
|
Revision: 201
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=201&view=rev
Author: crazedsanity
Date: 2011-01-27 06:18:09 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
permissions to allow id-paths; use dbTableHandler to make SQL easier.
/cs_genericPermission.class.php:
* MAIN:::
-- changed objTable to permTable, from const to protected
-- changed objSeq to permSeq, from const to protected
-- objectDelimiter [NEW]: character to separate objects in a path.
-- pathCleaner [NEW]: how to clean the path
-- dbTableHandler [NEW]: object to create & retrieve data from the db.
* __construct():
-- ARG CHANGE: NEW ARG: #2 ($objectDelimiter=NULL)
-- ARG CHANGE: NEW ARG: #3 ($useUrlCleaner=true)
-- set internal vars for objectDelimiter and useUrlCleaner
-- setup internal var for dbTableHandler
* build_permission_string():
-- added comment to explain what might otherwise seem illogical
-- more helpful information in the event of an exception
* create_permission():
-- minor column name changes (object_name to object_path)
-- use dbTableHandler::create_record() instead of arbitrary SQL.
* get_object() [DELETED]:
-- unnecessary alias method
* get_permission():
-- use dbTableHandler::get_single_record() instead of arbitrary SQL.
* get_object_by_id() [DELETED]:
-- unnecessary alias method
* get_permission_by_id():
-- use dbTableHandler::get_record_by_id() instead of arbitrary SQL.
* get_permission_list():
-- remove some commented-out code.
/abstract/cs_genericGroup.abstract.class.php:
* MAIN:::
-- changed groupTable from constant to protected
-- changed groupSeq from constant to protected
-- dbTableHandler [NEW]: object to create & retrieve data from db.
* __construct():
-- setup the dbTableHandler object.
* create_group():
-- use dbTableHandler::create_record() instead of arbitrary SQL.
* get_group():
-- use dbTableHandler::get_single_record() instead of arbitrary SQL.
* get_group_by_id():
-- use dbTableHandler::get_record_by_id() instead of arbitrary SQL.
/abstract/cs_genericUserGroup.abstract.class.php:
* MAIN:::
-- changed ugTable from constant to protected
-- changed ugSeq from constant to protected
-- dbTableHandler [NEW]: for table interaction
* __construct():
-- set dbTableHandler object
* create_user_group():
-- use dbTableHandler::create_record()
* get_user_groups():
-- use dbTableHandler::get_records()
* is_group_member():
-- fixed to work properly
/setup/genericPermissions.pgsql.sql:
* cswal_object_table:
-- updated comment
-- remove "is_hidden" column, unnecessary (and confusing)
* INSERT STATEMENTS:::
-- updated to match new schema.
/tests/testOfCSGenericPermissions.php:
* test_userGroups():
-- updated tests
* test_permissions():
-- removed calls to deleted methods
Modified Paths:
--------------
trunk/0.4/abstract/cs_genericGroup.abstract.class.php
trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php
trunk/0.4/cs_genericPermission.class.php
trunk/0.4/setup/genericPermissions.pgsql.sql
trunk/0.4/tests/testOfCSGenericPermissions.php
Modified: trunk/0.4/abstract/cs_genericGroup.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_genericGroup.abstract.class.php 2011-01-27 05:04:56 UTC (rev 200)
+++ trunk/0.4/abstract/cs_genericGroup.abstract.class.php 2011-01-27 06:18:09 UTC (rev 201)
@@ -20,15 +20,25 @@
public $gfObj;
/** Table name used to store groups. */
- const groupTable = "cswal_group_table";
+ protected $groupTable = "cswal_group_table";
/** Sequence for groups table. */
- const groupSeq = "cswal_group_table_group_id_seq";
+ protected $groupSeq = "cswal_group_table_group_id_seq";
+ /** Table handler object for simple SQL handling */
+ private $dbTableHandler;
+
//============================================================================
public function __construct(cs_phpDB $db) {
$this->db = $db;
$this->gfObj = new cs_globalFunctions;
+
+ //setup table handler.
+ $cleanString = array(
+ 'group_name' => 'text',
+ 'group_admin' => 'integer'
+ );
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->groupTable, $this->groupSeq, 'group_id', $cleanString);
}//end __construct()
//============================================================================
@@ -51,9 +61,7 @@
//============================================================================
public function create_group($name) {
try{
- $name = $this->clean_group_name($name);
- $sql = "INSERT INTO ". self::groupTable ." (group_name) VALUES ('". $name ."')";
- $newId = $this->db->run_insert($sql, self::groupSeq);
+ $newId = $this->dbTableHandler->create_record(array('group_name'=>$this->clean_group_name($name)));
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to create new record, DETAILS::: ". $e->getMessage());
@@ -68,9 +76,7 @@
//============================================================================
public function get_group($name) {
try {
- $name = $this->clean_group_name($name);
- $sql = "SELECT * FROM ". self::groupTable ." WHERE group_name='". $name ."'";
- $retval = $this->db->run_query($sql);
+ $retval = $this->dbTableHandler->get_single_record(array('group_name' => $this->clean_group_name($name)));
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: error while locating group '". $name ."', DETAILS::: ". $e->getMessage());
@@ -85,8 +91,7 @@
//============================================================================
public function get_all_groups() {
try {
- $sql = "SELECT * FROM ". self::groupTable ." ORDER BY group_name";
- $retval = $this->db->run_query($sql);
+ $retval = $this->dbTableHandler->get_records();
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to retrieve groups, DETAILS::: ". $e->getMessage());
@@ -102,8 +107,7 @@
public function get_group_by_id($groupId) {
try {
if(!is_null($groupId) && is_numeric($groupId)) {
- $sql = "SELECT * FROM ". self::groupTable ." WHERE group_id='". $groupId ."'";
- $retval = $this->db->run_query($sql);
+ $retval = $this->dbTableHandler->get_record_by_id($groupId);
}
else {
throw new exception(__METHOD__ .":: invalid group ID (". $groupId .")");
Modified: trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php 2011-01-27 05:04:56 UTC (rev 200)
+++ trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php 2011-01-27 06:18:09 UTC (rev 201)
@@ -1,8 +1,6 @@
<?php
/*
- * Created on June 18, 2010
- *
* FILE INFORMATION:
*
* $HeadURL$
@@ -15,14 +13,22 @@
abstract class cs_genericUserGroupAbstract extends cs_genericGroupAbstract {
/** Table name used to store user_group records. */
- const ugTable = "cswal_user_group_table";
+ protected $ugTable = "cswal_user_group_table";
/** Sequence for user_group table. */
- const ugSeq = "cswal_user_group_table_user_group_id_seq";
+ protected $ugSeq = "cswal_user_group_table_user_group_id_seq";
+ /** dbTableHandler{} object for simplifying SQL. */
+ private $dbTableHandler;
+
//============================================================================
public function __construct(cs_phpDB $db) {
parent::__construct($db);
+ $cleanString = array(
+ 'user_id' => 'integer',
+ 'group_id' => 'integer'
+ );
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->ugTable, $this->ugSeq, 'user_group_id', $cleanString);
}//end __construct()
//============================================================================
@@ -32,8 +38,7 @@
public function create_user_group($userId, $groupId) {
if(is_numeric($userId) && is_numeric($groupId) && $userId >= 0 && $groupId >= 0) {
try {
- $sql = "INSERT INTO ". self::ugTable ." (user_id, group_id) VALUES (". $userId .", ". $groupId .")";
- $newId = $this->db->run_insert($sql, self::ugSeq);
+ $newId = $this->dbTableHandler->create_record(array('user_id'=>$userId,'group_id'=>$groupId));
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to create user group, DETAILS::: ". $e->getMessage());
@@ -52,9 +57,7 @@
public function get_user_groups($userId) {
if(is_numeric($userId) && $userId >= 0) {
try {
- $sql = "SELECT ug.*, g.group_name, g.group_admin FROM ". self::ugTable ." AS ug INNER "
- ."JOIN ". parent::groupTable ." as g USING (group_id) WHERE user_id=". $userId;
- $retval = $this->db->run_query($sql, 'group_id');
+ $retval = $this->dbTableHandler->get_records(array('user_id'=>$userId));
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to locate groups for user_id=(". $userId ."), DETAILS::: ". $e->getMessage());
@@ -73,8 +76,11 @@
public function is_group_member($userId, $groupId) {
$groupList = $this->get_user_groups($userId);
$retval = false;
- if(isset($groupList[$groupId])) {
- $retval = true;
+ if(is_array($groupList)) {
+ $keys = array_keys($groupList);
+ if($groupList[$keys[0]]['group_id'] == $groupId) {
+ $retval = true;
+ }
}
return($retval);
}//end is_group_member()
Modified: trunk/0.4/cs_genericPermission.class.php
===================================================================
--- trunk/0.4/cs_genericPermission.class.php 2011-01-27 05:04:56 UTC (rev 200)
+++ trunk/0.4/cs_genericPermission.class.php 2011-01-27 06:18:09 UTC (rev 201)
@@ -20,19 +20,29 @@
public $gfObj;
/** Table name used to store permissions. */
- const objTable = "cswal_object_table";
+ protected $permTable = "cswal_permission_table";
/** Sequence for permissions table. */
- const objSeq = "cswal_object_table_object_id_seq";
+ protected $permSeq = "cswal_permission_table_permission_id_seq";
/** List of valid keys... */
protected $keys = array();
+ /** Determine object path pieces based on this... */
+ protected $objectDelimiter="/";
+
+ /** How to clean the path (if at all); boolean true = use cs_globalFunctions::clean_url(); boolean false will
+ cause it to not be cleaned at all; a string will use cs_globalFunctions::cleanString({string})*/
+ protected $pathCleaner=true;
+
+ /** dbTableHandler{} object for easier SQL. */
+ private $dbTableHandler;
+
//============================================================================
/**
* Generic permission system based on *nix filesystem permissions.
*/
- public function __construct(cs_phpDB $db) {
+ public function __construct(cs_phpDB $db, $objectDelimiter=NULL, $useUrlCleaner=true) {
$this->db = $db;
parent::__construct($db);
$this->gfObj = new cs_globalFunctions;
@@ -47,6 +57,29 @@
7 => 'o_w',
8 => 'o_x'
);
+ if(!is_null($objectDelimiter) && is_string($objectDelimiter) && strlen($objectDelimiter)) {
+ $this->objectDelimiter=$objectDelimiter;
+ }
+ if(is_bool($useUrlCleaner) || (is_string($useUrlCleaner) && strlen($useUrlCleaner))) {
+ $this->pathCleaner = $useUrlCleaner;
+ }
+ $cleanString = array(
+ 'system_name' => 'integer',
+ 'object_path' => 'text',
+ 'user_id' => 'integer',
+ 'group_id' => 'integer',
+ 'inherit' => 'bool',
+ 'u_r' => 'bool',
+ 'u_w' => 'bool',
+ 'u_x' => 'bool',
+ 'g_r' => 'bool',
+ 'g_w' => 'bool',
+ 'g_x' => 'bool',
+ 'o_r' => 'bool',
+ 'o_w' => 'bool',
+ 'o_x' => 'bool',
+ );
+ $this->dbTableHandler = new cs_dbTableHandler($this->db, $this->permTable, $this->permSeq, 'permission_id', $cleanString);
}//end __construct()
//============================================================================
@@ -98,6 +131,9 @@
*/
protected function build_permission_string(array $perms) {
$this->_sanityCheck();
+
+ //NOTE:: the incoming $perms must have more (or equal) items vs. $this->keys so that it can accept arrays with extra
+ // items, but can disregard those that obviously do not have enough.
if(is_array($perms) && count($perms) >= count($this->keys)) {
$retval = "";
foreach($this->keys as $dbColName) {
@@ -118,7 +154,11 @@
}
}
else {
- throw new exception(__METHOD__ .":: invalid permission set.");
+ $extraInfo="";
+ if(!is_array($perms)) {
+ $extraInfo = " (expected array, received ". gettype($perms) ." '". $perms ."')";
+ }
+ throw new exception(__METHOD__ .":: invalid permission set". $extraInfo);
}
return($retval);
}//end build_permission_string();
@@ -144,7 +184,7 @@
public function create_permission($name, $userId, $groupId, $permString) {
if(is_string($name) && strlen($name) && is_numeric($userId) && $userId >= 0 && is_numeric($groupId) && $groupId >= 0) {
$cleanStringArr = array(
- 'object_name' => 'sql',
+ 'object_path' => 'sql',
'user_id' => 'numeric',
'group_id' => 'numeric',
'u_r' => 'bool',
@@ -159,13 +199,11 @@
);
try{
$insertArr = $this->parse_permission_string($permString);
- $insertArr['object_name'] = $this->gfObj->cleanString($name, 'sql', 0);
+ $insertArr['object_path'] = $this->gfObj->cleanString($name, 'sql', 0);
$insertArr['user_id'] = $userId;
$insertArr['group_id'] = $groupId;
- $insertSql = $this->gfObj->string_from_array($insertArr, 'insert', null, $cleanStringArr);
- $sql = "INSERT INTO ". self::objTable ." ". $insertSql;
- $newId = $this->db->run_insert($sql, self::objSeq);
+ $newId = $this->dbTableHandler->create_record($insertArr);
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to create new record, DETAILS::: ". $e->getMessage());
@@ -183,24 +221,11 @@
//============================================================================
/**
- * Same as get_permission().
- */
- public function get_object($name) {
- return($this->get_permission($name));
- }//end get_object()
- //============================================================================
-
-
-
- //============================================================================
- /**
* Retrieves a permission object by name from the database, exception on failure.
*/
public function get_permission($name) {
try {
- $name = $this->gfObj->cleanString($name, 'sql', 0);
- $sql = "SELECT * FROM ". self::objTable ." WHERE object_name='". $name ."'";
- $retval = $this->db->run_query($sql);
+ $retval = $this->dbTableHandler->get_single_record(array('object_path'=>$name));
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: error while locating permission '". $name ."', DETAILS::: ". $e->getMessage());
@@ -214,24 +239,12 @@
//============================================================================
/**
- * Same as get_permission_by_id().
- */
- public function get_object_by_id($objectId) {
- return($this->get_permission_by_id($objectId));
- }//end get_object_by_id()
- //============================================================================
-
-
-
- //============================================================================
- /**
* Retrieves a permission object from the database based on an ID.
*/
public function get_permission_by_id($permId) {
try {
if(!is_null($permId) && is_numeric($permId)) {
- $sql = "SELECT * FROM ". self::objTable ." WHERE object_id='". $permId ."'";
- $retval = $this->db->run_query($sql);
+ $retval = $this->dbTableHandler->get_record_by_id($permId);
}
else {
throw new exception(__METHOD__ .":: invalid permission ID (". $permId .")");
@@ -298,7 +311,6 @@
if(preg_match('/'. $type .'_[rwx]$/',$myKey)) {
//chop the last character off (i.e. 'r' from 'u_r')
$myPermChar = substr($myKey, -1);
- #$retval[$myPermChar] = $this->gfObj->interpret_bool($permData[$myKey], array('f', 't'));
$retval[$myPermChar] = $this->evaluate_perm_value($permData[$myKey], $type);
}
}
Modified: trunk/0.4/setup/genericPermissions.pgsql.sql
===================================================================
--- trunk/0.4/setup/genericPermissions.pgsql.sql 2011-01-27 05:04:56 UTC (rev 200)
+++ trunk/0.4/setup/genericPermissions.pgsql.sql 2011-01-27 06:18:09 UTC (rev 201)
@@ -40,13 +40,11 @@
--
-- Object table
-- Unique set of names which should be chained together to create an object path; for a URL of "/member/blog/edit", the pieces would be created
--- with ID's, such as "member"=1, "blog"=2, "edit"=3; the object path would then be ":1::2::3:"; an extra prefix element might be created to
--- define a default, inheritable set of permissions, such as "{root}"=10; the path might then be ":10::1::2::3:".
+-- with ID's, such as "member"=1, "blog"=2, "edit"=3; the object path would then be ":1::2::3:".
--
CREATE TABLE cswal_object_table (
object_id integer NOT NULL PRIMARY KEY,
object_name text NOT NULL UNIQUE,
- is_hidden boolean NOT NULL DEFAULT FALSE,
created TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
@@ -84,8 +82,8 @@
INSERT INTO cswal_group_table (group_name) VALUES ('blogs');
INSERT INTO cswal_group_table (group_name) VALUES ('admin');
-INSERT INTO cswal_object_table (object_id, object_name,is_hidden) VALUES (0, '/', true);
-INSERT INTO cswal_object_table (object_id, object_name,is_hidden) VALUES (1, 'member', false);
+INSERT INTO cswal_object_table (object_id, object_name) VALUES (0, '{APPURL}');
+INSERT INTO cswal_object_table (object_id, object_name) VALUES (1, 'member');
INSERT INTO cswal_permission_table
(object_path,user_id, group_id)
Modified: trunk/0.4/tests/testOfCSGenericPermissions.php
===================================================================
--- trunk/0.4/tests/testOfCSGenericPermissions.php 2011-01-27 05:04:56 UTC (rev 200)
+++ trunk/0.4/tests/testOfCSGenericPermissions.php 2011-01-27 06:18:09 UTC (rev 201)
@@ -89,9 +89,9 @@
$groupList = $this->permObj->get_all_groups();
- foreach($groupList as $groupData) {
- $this->assertEqual($this->permObj->get_group_by_id($groupData['group_id']), $groupData);
- $this->assertEqual($this->permObj->get_group($groupData['group_name']), $groupData);
+ foreach($groupList as $groupId=>$groupData) {
+ $this->assertEqual($this->permObj->get_group_by_id($groupId), $groupData, "failed to get group (". $groupData['group_name'] .") by ID (". $groupId .")");
+ $this->assertEqual($this->permObj->get_group($groupData['group_name']), $groupData, "failed to get group (". $groupData['group_name'] .") by name");
}
}
@@ -100,8 +100,7 @@
$newId = $this->permObj->create_user_group($this->validUsers[$myKey]['uid'],$newGroupId);
$this->assertTrue(is_numeric($newId));
$this->assertTrue($this->permObj->is_group_member($this->validUsers[$myKey]['uid'],$newGroupId), "user (".
- $this->validUsers[$myKey]['uid'] .") isn't member of group (". $newGroupId .") after ".
- "being added to it... ");
+ $this->validUsers[$myKey]['uid'] .") isn't member of group (". $newGroupId .") after being added to it... ");
$ugList = $this->permObj->get_user_groups($this->validUsers[$myKey]['uid']);
$this->assertTrue(is_array($ugList));
@@ -175,9 +174,7 @@
//the method 'build_permissions_string()' should disregard extra indices in the array & build the string.
$this->assertEqual($this->permObj->make_perm_string($this->permObj->get_permission_by_id($permId)), $usePermString);
- $this->assertEqual($this->permObj->make_perm_string($this->permObj->get_object_by_id($permId)), $usePermString);
$this->assertEqual($this->permObj->make_perm_string($this->permObj->get_permission($usePermName)), $usePermString);
- $this->assertEqual($this->permObj->make_perm_string($this->permObj->get_object($usePermName)), $usePermString);
//check to make sure individual permission requests work as expected.
$this->assertTrue($this->permObj->has_read_permission($myUid, $usePermName));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-01-27 05:05:02
|
Revision: 200
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=200&view=rev
Author: crazedsanity
Date: 2011-01-27 05:04:56 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
Minor logic fixes, new method to match method from cs_phpDB.
/abstract/cs_singleTableHandler.abstract.class.php:
* get_record_by_id():
-- return just the sub-array (field=>value)
* get_single_record():
-- return just the sub-array (field=>value)
* update_record():
-- remove commented-out debug stuff.
* get_last_query() [NEW]:
-- return value from cs_phpDB::get_last_query().
Modified Paths:
--------------
trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
Modified: trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php
===================================================================
--- trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-01-27 04:04:11 UTC (rev 199)
+++ trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php 2011-01-27 05:04:56 UTC (rev 200)
@@ -114,6 +114,12 @@
if(is_numeric($recId)) {
try {
$data = $this->get_records(array($this->pkeyField => $recId));
+ if(isset($data[$recId])) {
+ $data = $data[$recId];
+ }
+ else {
+ throw new exception(__METHOD__ .": returned data did not contain ID (". $recId .")");
+ }
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: error while retrieving record (". $recId ."), DETAILS::: ". $e->getMessage());
@@ -142,8 +148,14 @@
try {
$data = $this->get_records($filter, null, 1);
- $keys = array_keys($data);
- $retval = $data[$keys[0]];
+ if(is_array($data)) {
+ $keys = array_keys($data);
+ $retval = $data[$keys[0]];
+ }
+ else {
+ //technically, the call to get_records() got boolean(false) from cs_phpDB::run_query(), so we could just return $data directly...
+ $retval = false;
+ }
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to retrieve record, DETAILS::: ". $e->getMessage());
@@ -233,7 +245,6 @@
.' WHERE '. $this->pkeyField .'='. $recId;
try {
$retval = $this->dbObj->run_update($sql, true);
-#$this->gfObj->debug_print(__METHOD__ .":: retval=(". $retval ."), SQL::: ". $sql ,1);
}
catch(Exception $e) {
throw new exception(__METHOD__ .":: failed to update record (". $recId ."), DETAILS::: ". $e->getMessage());
@@ -269,6 +280,14 @@
return($result);
}//end delete_record()
//-------------------------------------------------------------------------
+
+
+
+ //-------------------------------------------------------------------------
+ public function get_last_query() {
+ return($this->dbObj->get_last_query());
+ }//end get_last_query();
+ //-------------------------------------------------------------------------
}
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-01-27 04:04:17
|
Revision: 199
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=199&view=rev
Author: crazedsanity
Date: 2011-01-27 04:04:11 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
New class for handling insert/delete/select statements for a single table.
/cs_dbTableHandler.class.php [NEW]:
* class that simply extends cs_singleTableHandlerAbstract{}, for the
simple purpose of being able to create a sub-object for this handler
instead of extending it directly.
Added Paths:
-----------
trunk/0.4/cs_dbTableHandler.class.php
Copied: trunk/0.4/cs_dbTableHandler.class.php (from rev 195, trunk/0.4/abstract/cs_singleTableHandler.abstract.class.php)
===================================================================
--- trunk/0.4/cs_dbTableHandler.class.php (rev 0)
+++ trunk/0.4/cs_dbTableHandler.class.php 2011-01-27 04:04:11 UTC (rev 199)
@@ -0,0 +1,35 @@
+<?php
+/*
+ * SVN INFORMATION:::
+ * -------------------
+ * Last Author::::::::: $Author$
+ * Current Revision:::: $Revision$
+ * Repository Location: $HeadURL$
+ * Last Updated:::::::: $Date$
+ */
+
+class cs_dbTableHandler extends cs_singleTableHandlerAbstract {
+
+
+ //-------------------------------------------------------------------------
+ /**
+ * Generic way of using a class to define how to update a single database table.
+ *
+ * @param $dbObj (object) Connected instance of cs_phpDB{}.
+ * @param $tableName (str) Name of table inserting/updating.
+ * @param $seqName (str) Name of sequence, used with PostgreSQL for retrieving the last inserted ID.
+ * @param $pkeyField (str) Name of the primary key field, for performing updates & retrieving specific records.
+ * @param $cleanStringArr (array) Array of {fieldName}=>{dataType} for allowing updates & creating records.
+ */
+ public function __construct(cs_phpDB $dbObj, $tableName, $seqName, $pkeyField, array $cleanStringArr) {
+ try {
+ parent::__construct($dbObj, $tableName, $seqName, $pkeyField, $cleanStringArr);
+ }
+ catch(Exception $e) {
+ throw new exception(__METHOD__ .": unable to start, DETAILS::: ". $e->getMessage());
+ }
+ }//end __construct()
+ //-------------------------------------------------------------------------
+
+}
+
Property changes on: trunk/0.4/cs_dbTableHandler.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Author
Revision
HeadURL
Date
Added: svn:mergeinfo
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2011-01-27 03:55:16
|
Revision: 198
http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=198&view=rev
Author: crazedsanity
Date: 2011-01-27 03:55:10 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
Return the last SQL statement/query.
/cs_phpDB.class.php:
* get_last_query():
-- returns the last SQL statement from dbLayerObj (lastQuery var)
/db_types/cs_phpDB__mysql.class.php:
* MAIN:::
-- lastQuery changed to public from protected
/db_types/cs_phpDB__pgsql.class.php:
* MAIN:::
-- lastQuery changed to public from protected
/db_types/cs_phpDB__sqlite.class.php:
* MAIN:::
-- lastQuery changed to public from protected
Modified Paths:
--------------
trunk/0.4/cs_phpDB.class.php
trunk/0.4/db_types/cs_phpDB__mysql.class.php
trunk/0.4/db_types/cs_phpDB__pgsql.class.php
trunk/0.4/db_types/cs_phpDB__sqlite.class.php
Modified: trunk/0.4/cs_phpDB.class.php
===================================================================
--- trunk/0.4/cs_phpDB.class.php 2011-01-26 18:09:30 UTC (rev 197)
+++ trunk/0.4/cs_phpDB.class.php 2011-01-27 03:55:10 UTC (rev 198)
@@ -252,6 +252,14 @@
return($this->dbLayerObj->is_connected());
}//end is_connected()
//=========================================================================
+
+
+
+ //=========================================================================
+ public function get_last_query() {
+ return($this->dbLayerObj->lastQuery);
+ }//end get_last_query()
+ //=========================================================================
} // end class phpDB
?>
Modified: trunk/0.4/db_types/cs_phpDB__mysql.class.php
===================================================================
--- trunk/0.4/db_types/cs_phpDB__mysql.class.php 2011-01-26 18:09:30 UTC (rev 197)
+++ trunk/0.4/db_types/cs_phpDB__mysql.class.php 2011-01-27 03:55:10 UTC (rev 198)
@@ -26,7 +26,7 @@
protected $inTrans = FALSE;
/** Holds the last query performed. */
- protected $lastQuery = NULL;
+ public $lastQuery = NULL;
/** List of queries that have been run */
protected $queryList=array();
Modified: trunk/0.4/db_types/cs_phpDB__pgsql.class.php
===================================================================
--- trunk/0.4/db_types/cs_phpDB__pgsql.class.php 2011-01-26 18:09:30 UTC (rev 197)
+++ trunk/0.4/db_types/cs_phpDB__pgsql.class.php 2011-01-27 03:55:10 UTC (rev 198)
@@ -44,7 +44,7 @@
protected $inTrans = FALSE;
/** Holds the last query performed. */
- protected $lastQuery = NULL;
+ public $lastQuery = NULL;
/** List of queries that have been run */
protected $queryList=array();
Modified: trunk/0.4/db_types/cs_phpDB__sqlite.class.php
===================================================================
--- trunk/0.4/db_types/cs_phpDB__sqlite.class.php 2011-01-26 18:09:30 UTC (rev 197)
+++ trunk/0.4/db_types/cs_phpDB__sqlite.class.php 2011-01-27 03:55:10 UTC (rev 198)
@@ -26,7 +26,7 @@
protected $inTrans = FALSE;
/** Holds the last query performed. */
- protected $lastQuery = NULL;
+ public $lastQuery = NULL;
/** List of queries that have been run */
protected $queryList=array();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|