[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[220] trunk/current
Status: Beta
Brought to you by:
crazedsanity
|
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.
|