cs-project-svn_notify Mailing List for CS-Project (Page 11)
Brought to you by:
crazedsanity
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(65) |
Dec
(47) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(34) |
Feb
(82) |
Mar
(21) |
Apr
(12) |
May
(16) |
Jun
|
Jul
(6) |
Aug
(8) |
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(1) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(9) |
Aug
(5) |
Sep
(12) |
Oct
(11) |
Nov
(4) |
Dec
(15) |
2010 |
Jan
|
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(9) |
2012 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <cra...@us...> - 2008-02-07 01:48:40
|
Revision: 791 http://cs-project.svn.sourceforge.net/cs-project/?rev=791&view=rev Author: crazedsanity Date: 2008-02-06 17:48:37 -0800 (Wed, 06 Feb 2008) Log Message: ----------- Uncommitted files from last commit. Added Paths: ----------- trunk/1.0/lib/cs-content/db_types/ trunk/1.0/lib/cs-content/db_types/cs_phpDB__pgsql.class.php trunk/1.0/lib/cs-content/documentation/source/why_templating.odt trunk/1.0/lib/cs-content/documentation/why_templating.pdf trunk/1.0/templates/system/404.shared.tmpl Added: trunk/1.0/lib/cs-content/db_types/cs_phpDB__pgsql.class.php =================================================================== --- trunk/1.0/lib/cs-content/db_types/cs_phpDB__pgsql.class.php (rev 0) +++ trunk/1.0/lib/cs-content/db_types/cs_phpDB__pgsql.class.php 2008-02-07 01:48:37 UTC (rev 791) @@ -0,0 +1,1160 @@ +<?php + +/* + * A class for generic PostgreSQL database access. + * + * SVN INFORMATION::: + * SVN Signature:::::::: $Id: cs_phpDB__pgsql.class.php 252 2008-01-31 21:57:49Z crazedsanity $ + * Last Committted Date: $Date: 2008-01-31 15:57:49 -0600 (Thu, 31 Jan 2008) $ + * Last Committed Path:: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/db_types/cs_phpDB__pgsql.class.php $ + * + */ + +/////////////////////// +// ORIGINATION INFO: +// Author: Trevin Chow (with contributions from Lee Pang, wle...@ho...) +// Email: t1...@ma... +// Date: February 21, 2000 +// Last Updated: August 14, 2001 +// +// Description: +// Abstracts both the php function calls and the server information to POSTGRES +// databases. Utilizes class variables to maintain connection information such +// as number of rows, result id of last operation, etc. +// +/////////////////////// + +//TODO: option to not use layered transactions +//TODO: rollbackTrans() in layered transaction causes abort when final layer is committed/aborted +//TODO: stop sending queries to backend when transction is bad/aborted. +//TODO: commit/abort specific layer requests (i.e. if there's 8 layers & the first is named "x", calling commitTrans("x") will cause the whole transaction to commit & all layers to be destroyed. + +class cs_phpDB__pgsql { + + /** Internal result set pointer. */ + protected $result = NULL; + + /** Internal error code. */ + protected $errorCode = 0; + + /** Status of the current transaction. */ + protected $transStatus = NULL; + + /** Whether there is a transaction in progress or not. */ + protected $inTrans = FALSE; + + /** Holds the last query performed. */ + protected $lastQuery = NULL; + + /** List of queries that have been run */ + protected $queryList=array(); + + /** How many seconds to wait for a query before cancelling it. */ + protected $timeOutSeconds = NULL; + + /** Internal check to determine if a connection has been established. */ + protected $isConnected=FALSE; + + /** Internal check to determine if the parameters have been set. */ + protected $paramsAreSet=FALSE; + + /** Resource handle. */ + protected $connectionID = -1; + + /** Hostname or IP to connect to */ + protected $host; + + /** Port to connect to (default for Postgres is 5432) */ + protected $port; + + /** Name of the database */ + protected $dbname; + + /** Username to connect to the database */ + protected $user; + + /** password to connect to the database */ + protected $password; + + /** Row counter for looping through records */ + protected $row = -1; + + /** cs_globalFunctions object, for string stuff. */ + protected $gfObj; + + /** Internal check to ensure the object has been properly created. */ + protected $isInitialized=FALSE; + + /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ + protected $preparedStatements = array(); + + /** Set to TRUE to save all queries into an array. */ + protected $useQueryList=FALSE; + + /** array that essentially remembers how many times beginTrans() was called. */ + protected $transactionTree = NULL; + + //////////////////////////////////////////// + // Core primary connection/database function + //////////////////////////////////////////// + + + //========================================================================= + public function __construct() { + $this->gfObj = new cs_globalFunctions; + + if(defined('DEBUGPRINTOPT')) { + $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; + } + + $this->isInitialized = TRUE; + }//end __construct() + //========================================================================= + + + + //========================================================================= + /** + * Make sure the object is sane. + */ + final protected function sanity_check() { + if($this->isInitialized !== TRUE) { + throw new exception(__METHOD__ .": not properly initialized"); + } + }//end sanity_check() + //========================================================================= + + + + //========================================================================= + /** + * Set appropriate parameters for database connection + */ + public function set_db_info(array $params){ + $this->sanity_check(); + $required = array('host', 'port', 'dbname', 'user', 'password'); + + $requiredCount = 0; + foreach($params as $index=>$value) { + if(property_exists($this, $index) && in_array($index, $required)) { + $this->$index = $value; + $requiredCount++; + } + else { + throw new exception(__METHOD__. ": property (". $index .") does " . + "not exist or isn't allowed"); + } + } + + if($requiredCount == count($required)) { + $this->paramsAreSet = TRUE; + } + else { + throw new exception(__METHOD__ .": required count (". $requiredCount + .") does not match required number of fields (". count($required) .")"); + } + }//end set_db_info() + //========================================================================= + + + + //========================================================================= + /** + * Wrapper for close() + */ + function disconnect() { + //Disconnect from $database + return($this->close()); + }//end disconnect() + //========================================================================= + + + + //========================================================================= + /** + * Standard method to close connection. + */ + function close() { + $this->isConnected = FALSE; + $retval = null; + if($this->connectionID != -1) { + $retval = pg_close($this->connectionID); + } + else { + throw new exception(__METHOD__ .": Failed to close connection: connection is invalid"); + } + + return($retval); + }//end close() + //========================================================================= + + + + //========================================================================= + /** + * Connect to the database + */ + function connect(array $dbParams=NULL, $forceNewConnection=FALSE){ + $this->sanity_check(); + $retval = NULL; + if(is_array($dbParams)) { + $this->set_db_info($dbParams); + } + + if($this->paramsAreSet === TRUE && $this->isConnected === FALSE) { + + $myConnArr = array( + 'host' => $this->host, + 'port' => $this->port, + 'dbname' => $this->dbname, + 'user' => $this->user, + 'password' => $this->password + ); + + //make it into a string separated by spaces, don't clean anything, remove null elements + $connStr = $this->gfObj->string_from_array($myConnArr, 'url', " "); + + //start output buffer for displaying error. + ob_start(); + if($forceNewConnection) { + $connID = pg_connect($connStr, PGSQL_CONNECT_FORCE_NEW); + } + else { + $connID =pg_connect($connStr); + } + $connectError = ob_get_contents(); + ob_end_clean(); + + if(is_resource($connID)) { + $this->errorCode=0; + $this->connectionID = $connID; + $this->isConnected = TRUE; + $retval = $this->connectionID; + } + else { + throw new exception(__METHOD__ .": FATAL ERROR: ". $connectError); + } + } + else { + throw new exception(__METHOD__ .": paramsAreSet=(". $this->paramsAreSet ."), isConnected=(". $this->isConnected .")"); + } + + return($retval); + }//end connect() + //========================================================================= + + + + //========================================================================= + function get_hostname() { + $this->sanity_check(); + return($this->host); + }//end get_hostname() + //========================================================================= + + + + //========================================================================= + /** + * Run sql queries + * + * TODO: re-implement query logging (setting debug, logfilename, etc). + */ + function exec($query) { + $this->lastQuery = $query; + if($this->useQueryList) { + $this->queryList[] = $query; + } + $returnVal = false; + + if(($this->get_transaction_status() != -1) && ($this->connectionID != -1)) { + $this->result = @pg_query($this->connectionID, $query); + + if($this->result !== false) { + if (eregi("^[[:space:]]*select", $query)) { + //If we didn't have an error and we are a select statement, move the pointer to first result + $numRows = $this->numRows(); + if($numRows > 0) { + $this->move_first(); + } + $returnVal = $numRows; + + } + else { + //We got something other than an update. Use numAffected + $returnVal = $this->numAffected(); + } + } + } + return($returnVal); + }//end exec() + //========================================================================= + + + + //========================================================================= + /** + * Returns any error caused by the last executed query. + * + * @return NULL OK: no error + * @return (string) FAIL: contains error returned from the query. + */ + function errorMsg($setMessage=NULL,$logError=NULL) { + $this->sanity_check(); + if ($this->connectionID < 0) { + switch ($this->errorCode) { + //############################################### + case -1: + $retVal = "FATAL ERROR - CONNECTION ERROR: RESOURCE NOT FOUND"; + break; + //############################################### + + //############################################### + case -2: + $retVal = "FATAL ERROR - CLASS ERROR: FUNCTION CALLED WITHOUT PARAMETERS"; + break; + //############################################### + + //############################################### + case -3: + $retVal = "Query exceeded maximum timeout (". $this->timeoutSeconds .")"; + break; + //############################################### + + //############################################### + default: + $retVal = null; + //############################################### + } + } else { + $retVal = pg_last_error($this->connectionID); + } + + return($retVal); + }//end errorMsg() + //========================================================================= + + + + + //////////////////// + // Cursor movement + //////////////////// + + + + + //========================================================================= + /** + * move pointer to first row of result set + */ + function move_first() { + $this->sanity_check(); + if($this->result == NULL) { + $retval = FALSE; + } + else { + $this->set_row(0); + $retval = TRUE; + } + + return($retval); + }//end move_first() + //========================================================================= + + + + //========================================================================= + /** + * move pointer to last row of result set + */ + function move_last() { + $this->sanity_check(); + if($this->result == NULL) { + $retval = FALSE; + } + else { + $this->set_row($this->numRows()-1); + $retval = TRUE; + } + + return($retval); + }//end move_list() + //========================================================================= + + + + //========================================================================= + /** + * point to the next row, return false if no next row + */ + function move_next() { + $this->sanity_check(); + // If more rows, then advance row pointer + if($this->row < $this->numRows()-1) { + $this->set_row($this->row +1); + $retval = TRUE; + } + else { + $retval = FALSE; + } + + return($retval); + }//end move_next() + //========================================================================= + + + + //========================================================================= + /** + * point to the previous row, return false if no previous row + */ + function move_previous() { + // If not first row, then advance row pointer + if ($this->row > 0) { + $this->set_row($this->row -1); + return true; + } + else return false; + }//end move_previous() + //========================================================================= + + + + //========================================================================= + // point to the next row, return false if no next row + function next_row() { + // If more rows, then advance row pointer + if ($this->row < $this->numRows()-1) { + $this->set_row($this->row +1); + return true; + } + else return false; + }//end next_row() + //========================================================================= + + + + //========================================================================= + // can be used to set a pointer to a perticular row + function set_row($row){ + if(is_numeric($row)) { + $this->row = $row; + } + else { + throw new exception(__METHOD__ .": invalid data for row (". $row .")"); + } + return($this->row); + }//end set_row(); + //========================================================================= + + + + + /////////////////////// + // Result set related + /////////////////////// + + + + //========================================================================= + /** + * Return the current row as an object. + */ + function fobject() { + $this->sanity_check(); + if($this->result == NULL || $this->row == -1) { + $retval = NULL; + } + else { + $retval = pg_fetch_object($this->result, $this->row); + } + + return($retval); + } + //========================================================================= + + + + //========================================================================= + /** + * Fetch the current row as an array containing fieldnames AND numeric indexes. + */ + function farray(){ + if($this->result == NULL || $this->row == -1) { + $retval = NULL; + } + else { + $retval = pg_fetch_array($this->result,$this->row); + } + + return($retval); + }//end farray() + //========================================================================= + + + + //========================================================================= + /** + * Another way to retrieve a single row (useful for loops). + */ + function frow(){ + $this->sanity_check(); + if($this->numRows() <= 0) { + $retval = NULL; + } + else { + if($this->result == null || $this->row == -1) { + $retval = NULL; + } + else { + $retval = pg_fetch_row($this->result, $this->row); + } + } + + return($retval); + }//end frow() + //========================================================================= + + + + //========================================================================= + /** + * Similar to farray(), except all indexes are non-numeric, and the entire + * result set is retrieved: if only one row is available, no numeric index + * is set, unless $numbered is TRUE. + * + * TODO: clean this up! + */ + function farray_fieldnames($index=NULL, $numbered=NULL,$unsetIndex=1) { + $this->sanity_check(); + $retval = NULL; + + //before we get too far, let's make sure there's something there. + if($this->numRows() <= 0) { + $retval = 0; + } + else { + //keep any errors/warnings from printing to the screen by using OUTPUT BUFFERS. + ob_start(); + + $x = 0; + do { + $temp = $this->farray(); + foreach($temp as $key=>$value) { + //remove the numbered indexes. + if(is_string($key)) { + $tArr[$key] = $value; + } + } + $newArr[$x] = $tArr; + $x++; + } + while($this->next_row()); + + if($index) { + foreach($newArr as $row=>$contents) { //For each of the returned sets of information + foreach($contents as $fieldname=>$value) { //And now for each of the items in that set + if($fieldname == $index) { + //The index for the new array will be this fieldname's value + $arrayKey = $value; + } + + $tempContent[$fieldname] = $value; + //don't include the "index" field in the subarray; that always seems to end badly. + if ($unsetIndex) { + unset($tempContent[$index]); + } + } + + if (!isset($tempArr[$arrayKey])) { + //Make sure we didn't already set this in the array. If so, then we don't have a unique variable to use for the array index. + $tempArr[$arrayKey] = $tempContent; + } + else { + //TODO: bigtime cleaning... should only return at the bottom of the method. + $retval = 0; + break; + } + $arrayKey = NULL; //Blank this out after using it, just in case we don't find one in the next iteration + } + + if (count($tempArr) != count($newArr)) { + $details = "farray_fieldnames(): Array counts don't match.<BR>\n" + ."FUNCTION ARGUMENTS: index=[$index], numbered=[$numbered], unsetIndex=[$unsetIndex]<BR>\n" + ."LAST QUERY: ". $this->lastQuery; + throw new exception(__METHOD__ .": $details"); + } + $newArr = $tempArr; + } + //this is where, if there's only one row (and the planets align just the way + // I like them to), there's no row w/ a sub-array... This is only done + // if $index is NOT set... + if(($this->numRows() == 1) AND (!$index) AND (!$numbered)) { + $newArr = $newArr[0]; + } + $retval = $newArr; + ob_end_clean(); + } + return($retval); + }//end farray_fieldnames() + //========================================================================= + + + + //========================================================================= + /** + * Uses farray_fieldnames() to retrieve the entire result set, but the final + * array is contains name=>value pairs. + */ + function farray_nvp($name, $value) { + if((!$name) OR (!$value)) { + $retval = 0; + } + else { + $tArr = $this->farray_fieldnames(NULL,1); + if(!is_array($tArr)) { + $retval = 0; + } + else { + //loop through it & grab the proper info. + $retval = array(); + foreach($tArr as $row=>$array) { + $tKey = $array[$name]; + $tVal = $array[$value]; + $retval[$tKey] = $tVal; + } + } + } + + //return the new array. + return($retval); + }//end farray_nvp() + //========================================================================= + + + + //========================================================================= + /** + * Similar to farray_fieldnames(), but only returns the NUMERIC indexes + */ + function farray_numbered() { + do { + $temp = $this->frow(); + $retArr[] = $temp[0]; + } + while($this->next_row()); + + return($retArr); + }//end farray_numbered() + //========================================================================= + + + + //========================================================================= + /** + * Returns the number of tuples affected by an insert/delete/update query. + * NOTE: select queries must use numRows() + */ + function numAffected() { + if($this->result == null) { + $retval = 0; + } else { + $this->affectedRows = pg_affected_rows($this->result); + $retval = $this->affectedRows; + } + + return($retval); + }//end numAffected() + //========================================================================= + + + + //========================================================================= + /** + * Returns the number of rows in a result (from a SELECT query). + */ + function numRows() { + if ($this->result == null) { + $retval = 0; + } + else { + $this->numrows = pg_num_rows($this->result); + $retval = $this->numrows; + } + + return($retval); + }//end numRows() + //========================================================================= + + + + //========================================================================= + /** + * wrapper for numAffected() + */ + function affectedRows(){ + return($this->numAffected()); + }//end affectedRows() + //========================================================================= + + + + //========================================================================= + /** + * Returns the current row number. + */ + function currRow(){ + return($this->row); + }//end currRow() + //========================================================================= + + + + //========================================================================= + /** + * Get the number of fields in a result. + */ + // get the number of fields in a result + function num_fields() { + if($this->result == null) { + $retval = 0; + } + else { + $retval = pg_num_fields($this->result); + } + return($retval); + }//end num_fields() + //========================================================================= + + + + //========================================================================= + function column_count() { + return($this->numFields()); + }//end column_count() + //========================================================================= + + + + //========================================================================= + /** + * get last OID (object identifier) of last INSERT statement + */ + function lastOID($doItForMe=0, $field=NULL) { + if($this->result == NULL) { + $retval = NULL; + } + else { + $tOid = pg_last_oid($this->result); + $retval = $tOid; + + if(($doItForMe) AND (eregi("^insert", $this->last_query))) { + //attempt to parse the insert statement, then select + // all fields (unless $field is set) from it. + $t = split(" into ", strtolower($this->last_query)); + $t = split(" ", $t[1]); + $t = split("\(", $t[0]); + $table = $t[0]; + + //now we have the table. + if(!$field) { + $field = "*"; + } + $query = "SELECT $field FROM $table WHERE OID=$tOid"; + $this->exec($query); + $dberror = $this->errorMsg(1,1,1,"lastOID(): "); + + if(!$dberror) { + $res = $this->farray(); + if(is_string($field)) { + $retval = $res[0]; + } + } + } + } + return($retval); + }//end lastOID() + //========================================================================= + + + + //========================================================================= + /** + * get result field name of the given field number. + */ + // get result field name + function fieldname($fieldnum) { + if($this->result == NULL) { + $retval =NULL; + } + else { + $retval = pg_field_name($this->result, $fieldnum); + } + + return($retval); + }//end fieldname() + //========================================================================= + + + + + //////////////////////// + // Transaction related + //////////////////////// + + + + + //========================================================================= + /** + * Start a transaction. + */ + function beginTrans($transName=NULL) { + $transStatus = $this->get_transaction_status(TRUE); + if(!$this->inTrans) { + //not in a transaction. Set up the transaction tree properly. + $this->transactionTree = array(); + } + else { + if($this->inTrans && is_null($this->transactionTree)) { + $transLevel = $this->get_transaction_level(); + //transaction started without using beginTrans()... + $this->transactionTree = array(); + $this->gfObj->debug_print(__METHOD__ .": transaction already started, transStatus=(". $transStatus ."), transLevel=(". $transLevel .")"); + $this->transactionTree[] = "Already started..."; + } + } + + if(is_null($transName)) { + $transName = time(TRUE); + } + $this->transactionTree[] = $transName; + $transLevel = $this->get_transaction_level(); + return($this->exec("BEGIN")); + }//end beginTrans() + //========================================================================= + + + + //========================================================================= + /** + * Commit a transaction. + */ + function commitTrans() { + $retval = $this->get_transaction_status(); + $lastTransLayer = array_pop($this->transactionTree); + $transLevel = $this->get_transaction_level(); + if($transLevel == 0) { + if($retval > 1) { + $retval = 1; + } + $this->exec("COMMIT"); + + //check to see if there was an error (deferred constraints are checked at commit time) + if(strlen($this->errorMsg())) { + $retval = 0; + } + } + $this->get_transaction_status(); + return($retval); + }//end commitTrans() + //========================================================================= + + + + //========================================================================= + // returns true/false + function rollbackTrans() { + $retval = $this->exec("ABORT"); + $this->get_transaction_status(); + return($retval); + }//end rollbackTrans() + //========================================================================= + + + + //////////////////////// + // SQL String Related + //////////////////////// + + + + //========================================================================= + /** + * Gets rid of evil characters that might lead ot SQL injection attacks. + */ + function querySafe($string) { + return($this->gfObj->cleanString($string,"query")); + }//end querySafe() + //========================================================================= + + + + //========================================================================= + /** + * Make it SQL safe. + */ + function sqlSafe($string) { + return($this->gfObj->cleanString($string,"sql")); + }//end sqlSafe() + //========================================================================= + + + + //========================================================================= + /** + * Gives textual explanation of the current status of our database + * connection. + * + * @param $goodOrBad (bool,optional) return good/bad status. + * + * @return (-1) (FAIL) connection is broken + * @return (0) (FAIL) error was encountered (transient error) + * @return (1) (PASS) useable + * @return (2) (PASS) useable, but not just yet (working + * on something) + */ + function get_transaction_status($goodOrBad=TRUE) { + $myStatus = pg_transaction_status($this->connectionID); + $text = 'unknown'; + switch($myStatus) { + case PGSQL_TRANSACTION_IDLE: { + //No query in progress: it's idle. + $goodOrBadValue = 1; + $text = 'idle'; + $this->inTrans = FALSE; + } + break; + + + case PGSQL_TRANSACTION_ACTIVE: { + //there's a command in progress. + $goodOrBadValue = 2; + $text = 'processing'; + } + break; + + + case PGSQL_TRANSACTION_INTRANS: { + //connection idle within a valid transaction block. + $goodOrBadValue = 1; + $text = 'valid transaction'; + $this->inTrans = TRUE; + } + break; + + + case PGSQL_TRANSACTION_INERROR: { + //connection idle within a broken transaction. + $goodOrBadValue = 0; + $text = 'failed transaction'; + $this->inTrans = TRUE; + } + break; + + + case PGSQL_TRANSACTION_UNKNOWN: + default: { + //the connection is bad. + $goodOrBadValue = -1; + $text = 'bad connection'; + } + break; + } + + //do they want text or the good/bad number? + $retval = $text; + $this->transactionStatus = $goodOrBadValue; + if($goodOrBad) { + //they want the number. + $retval = $goodOrBadValue; + } + + return($retval); + }//end get_transaction_status() + //========================================================================= + + + + //========================================================================= + public function is_connected() { + $retval = FALSE; + if(is_resource($this->connectionID) && $this->isConnected === TRUE) { + $retval = TRUE; + } + + return($retval); + }//end is_connected() + //========================================================================= + + + + //========================================================================= + /** + * Create a prepared statement. + */ + public function create_prepared_statement($planName,array $fieldToType, $statement) { + $retval = FALSE; + //store the mappings. + $this->preparedStatements[$planName] = $fieldToType; + + //TODO: check that the string in "$statement" has the same number of "${n}" as are in "$fieldToType". + + $dataTypeString = ""; + foreach($fieldToType as $field => $type) { + $dataTypeString = $this->gfObj->create_list($dataTypeString, $type, ", "); + } + + $sql = "PREPARE ". $planName ."(". $dataTypeString .") AS ". $statement; + + $myNumrows = $this->exec($sql); + $myDberror = $this->errorMsg(); + + if(!strlen($myDberror)) { + $retval = TRUE; + } + else { + throw new exception(__METHOD__ .": failed to create prepared statement '". $planName ."'... dberror::: ". $myDberror ."\n\nSQL::: ". $sql); + } + + return($retval); + }//end create_prepared_statement() + //========================================================================= + + + + //========================================================================= + /** + * Run a statement prepared by this object. + * + * NOTE: determination of rows affected (numAffected) vs. rows returned (numRows) + * must be done by the user via the referenced methods. + */ + public function run_prepared_statement($name, array $data) { + $retval = FALSE; + if(is_array($this->preparedStatements[$name]) && count($data) == count($this->preparedStatements[$name])) { + $this->result = pg_execute($this->connectionID, $name, $data); + $dberror = $this->errorMsg(); + + if(!strlen($dberror)) { + $retval = TRUE; + } + } + else { + throw new exception(__METHOD__ .": invalid statement name (". $name ."), or incorrect number of elements"); + } + + return($retval); + }//end run_prepared_statement() + //========================================================================= + + + + //========================================================================= + /** + * Starts a copy command. + * + * TODO: implement safeguards so they can only put a line until the copy is ended. + */ + public function start_copy($tableName, array $fields) { + $retval = FALSE; + $copyStmt = "COPY ". $tableName ." (". $this->gfObj->string_from_array($fields, NULL, ", ") . ") FROM stdin;"; + $this->exec($copyStmt); + if(!strlen($this->errorMsg())) { + //TODO: set something here so that NOTHING ELSE can be done except put_line() and end_copy(). + $this->copyInProgress = TRUE; + $retval = TRUE; + } + else { + $this->end_copy(); + $retval = FALSE; + } + + return($retval); + }//end start_copy() + //========================================================================= + + + + //========================================================================= + /** + * Used to send a line to the COPY in progress (only if it was initiated by + * the internal start_copy() method). + * + * NOTE: the "end-of-copy" line, '\.', should NEVER be sent here. + */ + public function put_line($line) { + $retval = FALSE; + if($this->copyInProgress === TRUE) { + $myLine = trim($line); + $myLine .= "\n"; + + $retval = pg_put_line($this->connectionID, $myLine); + } + else { + throw new exception(__METHOD__ .": cannot send line if no copy is in progress"); + } + + return($retval); + }//end put_line() + //========================================================================= + + + + //========================================================================= + public function end_copy() { + if($this->copyInProgress === TRUE) { + //send the end-of-copy line... + $this->put_line("\\.\n"); + } + + $retval = pg_end_copy($this->connectionID); + + return($retval); + }//end end_copy() + //========================================================================= + + + + //========================================================================= + /** + * Determines how many times a transaction has been started. Starting + * multiple transactions does NOT protect the outer transaction from + * problems that occur in the inner transaction. In fact, it does the + * opposite: it protects the code from committing too early (which might + * destroy something that depending on the transaction). + */ + public function get_transaction_level() { + if(is_array($this->transactionTree)) { + $retval = count($this->transactionTree); + } + else { + $retval = 0; + } + + return($retval); + }//end get_transaction_level() + //========================================================================= + + + + //========================================================================= + /** + * Simple way to determine if the current connection is inside a + * transaction or not. + */ + public function is_in_transaction() { + $retval = 0; + if($this->inTrans || $this->get_transaction_level() != 0) { + $retval = TRUE; + } + return($retval); + }//end is_in_transaction() + //========================================================================= + + + +} // end class phpDB + +?> Added: trunk/1.0/lib/cs-content/documentation/source/why_templating.odt =================================================================== (Binary files differ) Property changes on: trunk/1.0/lib/cs-content/documentation/source/why_templating.odt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/1.0/lib/cs-content/documentation/why_templating.pdf =================================================================== (Binary files differ) Property changes on: trunk/1.0/lib/cs-content/documentation/why_templating.pdf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/1.0/templates/system/404.shared.tmpl =================================================================== --- trunk/1.0/templates/system/404.shared.tmpl (rev 0) +++ trunk/1.0/templates/system/404.shared.tmpl 2008-02-07 01:48:37 UTC (rev 791) @@ -0,0 +1,84 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> +<!-- + * Created on Nov 9, 2007 + * + * To change the template for this generated file go to + * Window - Preferences - PHPeclipse - PHP - Code Templates +--> +<head> + <title>404/403: Not Found or Access Denied</title> + <link rel=stylesheet type='text/css' href='/css/common.css'> + <script language="javascript" src="/js/cs-project.js" type="text/javascript"></script> + <script language="javascript" src="/js/prototype.js" type="text/javascript"></script> + <script language="javascript" src="/js/scriptaculous.js" type="text/javascript"></script> +</head> +<body> + + +<br> +<table align="center" border="0" cellpadding="0" cellspacing="0"> + <tbody> + <tr> + <td class="fatal" align="left" valign="top" width="5"><img src="/images/frame/crn-white-tl.gif" alt="" height="5" width="5"></td> + + <td class="fatal"><img src="/images/clear.gif" alt="" height="2" width="20"></td> + <td class="fatal" align="right" valign="top" width="5"><img src="/images/frame/crn-white-tr.gif" alt="" height="5" width="5"></td> + </tr> + <tr> + <td class="fatal" width="5"><img src="/images/clear.gif" alt="" height="20" width="5"></td> + <td> + <table class="fatal" border="0" cellpadding="5" cellspacing="0" width="100%"> + <tbody> + <tr> + <td valign="top"> <span class="title1">Forbidden / Page Not Found</span> + <table border="0" cellpadding="0" cellspacing="0" width="100%"> + + <tbody> + <tr> + <td class="fatal"><img src="/images/clear.gif" height="2" width="5"></td> + </tr> + </tbody> + </table> + + <img src="/images/marmoset_gat.gif"><br> + <table border="0" cellpadding="0" cellspacing="0" width="100%"> + + <tbody> + <tr> + <td class="fatal"><img src="/images/clear.gif" height="2" width="5"></td> + </tr> + </tbody> + </table> + <p style="margin: 5px 0px;width:300px;"><br> + You are not allowed to access this location... or maybe the page doesn't exist... + If you're not allowed to access, then please stop doing whenever you are doing. If + the page doesnt' exist, then stop fishing for page URLs.<BR><BR> + + Of course, if the page <b>should</b> exist, or you got here from some link... + well, you should probably tell somebody about it. Right?<BR><BR> + + <i>{details}</i> + </p> + </td> + </tr> + </tbody> + </table> + </td> + + <td class="fatal" width="5"><img src="/images/clear.gif" alt="" height="20" width="5"></td> + </tr> + <tr> + <td class="fatal" align="left" valign="bottom" width="5"><img src="/images/frame/crn-white-bl.gif" alt="" height="5" width="5"></td> + <td class="fatal"><img src="/images/clear.gif" alt="" height="2" width="20"></td> + <td class="fatal" align="right" valign="bottom" width="5"><img src="/images/frame/crn-white-br.gif" alt="" height="5" width="5"></td> + </tr> + </tbody> +</table> + + </body> +</html> + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-07 01:47:27
|
Revision: 790 http://cs-project.svn.sourceforge.net/cs-project/?rev=790&view=rev Author: crazedsanity Date: 2008-02-06 17:47:25 -0800 (Wed, 06 Feb 2008) Log Message: ----------- Updates to cs-content v0.10.8, cs-phpxml v0.5.5, minor template & include changes for new version, and "brought to you by" addition on login page. Modified Paths: -------------- trunk/1.0/includes/login.inc trunk/1.0/lib/cs-arrayToPath/VERSION trunk/1.0/lib/cs-arrayToPath/arrayToPathClass.php trunk/1.0/lib/cs-content/VERSION trunk/1.0/lib/cs-content/contentSystemClass.php trunk/1.0/lib/cs-content/cs_bbCodeParser.class.php trunk/1.0/lib/cs-content/cs_fileSystemClass.php trunk/1.0/lib/cs-content/cs_genericPageClass.php trunk/1.0/lib/cs-content/cs_globalFunctions.php trunk/1.0/lib/cs-content/cs_phpDB.php trunk/1.0/lib/cs-content/cs_sessionClass.php trunk/1.0/lib/cs-content/cs_versionAbstract.class.php trunk/1.0/lib/cs-content/documentation/basics.pdf trunk/1.0/lib/cs-phpxml/VERSION trunk/1.0/lib/cs-phpxml/xmlAbstract.class.php trunk/1.0/lib/cs-phpxml/xmlBuilderClass.php trunk/1.0/lib/cs-phpxml/xmlCreatorClass.php trunk/1.0/lib/cs-phpxml/xmlParserClass.php trunk/1.0/lib/globalFunctions.php trunk/1.0/lib/includes.php trunk/1.0/lib/projectClass.php trunk/1.0/lib/sessionCacheClass.php trunk/1.0/lib/session_class.php trunk/1.0/lib/site_config.php Added Paths: ----------- trunk/1.0/templates/login.content.tmpl Removed Paths: ------------- trunk/1.0/templates/login.tmpl Modified: trunk/1.0/includes/login.inc =================================================================== --- trunk/1.0/includes/login.inc 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/includes/login.inc 2008-02-07 01:47:25 UTC (rev 790) @@ -55,7 +55,7 @@ if($_GET['destination']) { $_SESSION['loginDestination'] = urlencode($_GET['destination']); } -//show the default page. -$page->change_content(html_file_to_string("login.tmpl")); +$page->add_template_var('cs-project_version', VERSION_STRING); + ?> \ No newline at end of file Modified: trunk/1.0/lib/cs-arrayToPath/VERSION =================================================================== --- trunk/1.0/lib/cs-arrayToPath/VERSION 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-arrayToPath/VERSION 2008-02-07 01:47:25 UTC (rev 790) @@ -2,4 +2,4 @@ VERSION: 0.2.2 PROJECT: cs-arrayToPath -$HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/releases/0.2.2/VERSION $ \ No newline at end of file +$HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/releases/0.2/VERSION $ \ No newline at end of file Modified: trunk/1.0/lib/cs-arrayToPath/arrayToPathClass.php =================================================================== --- trunk/1.0/lib/cs-arrayToPath/arrayToPathClass.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-arrayToPath/arrayToPathClass.php 2008-02-07 01:47:25 UTC (rev 790) @@ -6,7 +6,7 @@ * ------------------- * Last Author::::::::: $Author: crazedsanity $ * Current Revision:::: $Revision: 17 $ - * Repository Location: $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/releases/0.2.2/arrayToPathClass.php $ + * Repository Location: $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/releases/0.2/arrayToPathClass.php $ * Last Updated:::::::: $Date: 2007-09-12 14:24:46 -0500 (Wed, 12 Sep 2007) $ * * Modified: trunk/1.0/lib/cs-content/VERSION =================================================================== --- trunk/1.0/lib/cs-content/VERSION 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/VERSION 2008-02-07 01:47:25 UTC (rev 790) @@ -1,5 +1,5 @@ ## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. -VERSION: 0.9.1 +VERSION: 0.10.8 PROJECT: cs-content -$HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/VERSION $ \ No newline at end of file +$HeadURL:https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/VERSION $ \ No newline at end of file Modified: trunk/1.0/lib/cs-content/contentSystemClass.php =================================================================== --- trunk/1.0/lib/cs-content/contentSystemClass.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/contentSystemClass.php 2008-02-07 01:47:25 UTC (rev 790) @@ -1,10 +1,10 @@ -<? +<?php /* * FILE INFORMATION: - * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/contentSystemClass.php $ - * $Id: contentSystemClass.php 165 2007-09-21 16:00:30Z crazedsanity $ - * $LastChangedDate: 2007-09-21 11:00:30 -0500 (Fri, 21 Sep 2007) $ - * $LastChangedRevision: 165 $ + * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/contentSystemClass.php $ + * $Id: contentSystemClass.php 252 2008-01-31 21:57:49Z crazedsanity $ + * $LastChangedDate: 2008-01-31 15:57:49 -0600 (Thu, 31 Jan 2008) $ + * $LastChangedRevision: 252 $ * $LastChangedBy: crazedsanity $ * * HOW THE SYSTEM WORKS::: @@ -90,12 +90,15 @@ ); protected $templateList = array(); protected $includesList = array(); - protected $templateObj = NULL; + public $templateObj = NULL; protected $gfObj = NULL; protected $tabs = NULL; protected $finalSection; + private $isValid=FALSE; + private $reason=NULL; + //------------------------------------------------------------------------ /** * The CONSTRUCTOR. Duh. @@ -201,13 +204,16 @@ * if they're not, this will cause them to be redirected to another URL * (generally, so they can login). */ - public function force_authentication($redirectToUrl, $appendDestination=TRUE) { + public function force_authentication($redirectToUrl, $destinationArg='loginDestination') { if(is_object($this->session) && method_exists($this->session, 'is_authenticated')) { if(strlen($redirectToUrl)) { $cleanedRedirect = $this->clean_url($redirectToUrl); if($this->section != $cleanedRedirect) { if(!$this->session->is_authenticated()) { //run the redirect. + if(strlen($destinationArg)) { + $redirectToUrl .= '?'. $destinationArg .'='. urlencode($_SERVER['REQUEST_URI']); + } $this->gfObj->conditional_header($redirectToUrl, TRUE); } } @@ -254,8 +260,7 @@ * Rips apart the "section" string, setting $this->section and $this->sectionArr. */ private function parse_section() { - // - if($this->section === 0) { + if($this->section === 0 || is_null($this->section) || !strlen($this->section)) { $this->section = "content/index"; } $myArr = split('/', $this->section); @@ -283,8 +288,10 @@ //make sure we've still got something valid to work with. if(!strlen($section)) { + //TODO: remove the extra return statement (should only be one at the bottom of the method). return(0); - } else { + } + else { //check the string to make sure it doesn't begin or end with a "/" if($section[0] == '/') { $section = substr($section, 1, strlen($section)); @@ -356,8 +363,9 @@ //now cd() all the way back. $this->fileSystemObj->cd('/'); - } else { - //couldn't find the templates directory... ick. + } + else { + //couldn't find the templates directory, and no includes... it's dead. $this->die_gracefully(__METHOD__ .": unable to find the templates directory, or non-valid page [". $this->validate_page() ."]"); } }//end prepare() @@ -396,14 +404,17 @@ } $lsDir = $this->fileSystemObj->ls($indexFilename); + $lsDirVals = array_values($lsDir); $lsFile = $this->fileSystemObj->ls("$finalSection.content.tmpl"); - if(is_array(array_values($lsDir))) { - //it's the dir. + + if(is_array(array_values($lsFile)) && is_array($lsFile[$finalSection .".content.tmpl"])) { + //it's the file ("{finalSection}.content.tmpl", like "mySection.content.tmpl") + $myIndex = $finalSection .".content.tmpl"; + } + elseif(is_array(array_values($lsDir)) && (is_array($lsDir[$indexFilename]))) { $myIndex = $indexFilename; - } elseif(is_array(array_values($lsFile))) { - //it's the file (no dir, or dir w/o index) - $myIndex = $finalSection.content.tmpl; - } else { + } + else { //nothin' doin'. $myIndex = NULL; } @@ -417,21 +428,35 @@ if(isset($myIndex)) { $valid = TRUE; $this->fileSystemObj->cd('/templates'); - } else { - $this->reason = __METHOD__ .": couldn't find page template for (". $this->section .", final=[$finalSection])..."; } - } else { - //just the base template. Make sure it's good. + else { + $this->reason = __METHOD__ .": couldn't find page template for ". $this->section; + } + } + else { + //if the baseDir is "help", this would try to use "/help/index.content.tmpl" $myFile = $this->baseDir .'/index.content.tmpl'; - $lsData = $this->fileSystemObj->ls($myFile); - if(isset($lsData[$myFile]) && $lsData[$myFile]['type'] == 'file') { + $sectionLsData = $this->fileSystemObj->ls($myFile); + + //if the baseDir is "help", this would try to use "/help.content.tmpl" + $sectionFile = $this->baseDir .'.content.tmpl'; + $lsData = $this->fileSystemObj->ls(); + + if(isset($lsData[$sectionFile]) && is_array($lsData[$sectionFile])) { + $valid = TRUE; + $this->finalSection = $this->baseDir; + } + elseif(isset($sectionLsData[$myFile]) && $sectionLsData[$myFile]['type'] == 'file') { //we're good. $valid = TRUE; $this->finalSection = $this->baseDir; - } else { + } + else { $this->reason = __METHOD__ .": couldn't find base template."; } } + $this->isValid = $valid; + return($valid); }//end validate_page() //------------------------------------------------------------------------ @@ -483,6 +508,10 @@ $this->templateList[$mySection] = $myTmpl; } } + if(isset($tmplList[$this->baseDir]['content'])) { + //load template for the main page (if $this->baseDir == "help", this would load "/help.content.tmpl" as content) + $this->templateList['content'] = $tmplList[$this->baseDir]['content']; + } } }//end load_page_templates() //------------------------------------------------------------------------ @@ -550,6 +579,7 @@ if(($myType == 'file') && !in_array($index, $this->ignoredList[$myType])) { $filename = $this->gfObj->create_list($this->fileSystemObj->cwd, $index, '/'); $filename = preg_replace('/^\/templates/', '', $filename); + $filename = preg_replace('/^\/\//', '/', $filename); //call another method to rip the filename apart properly, then arrange things as needed. $pieces = $this->parse_filename($index); $myPriIndex = $pieces[$primaryIndex]; @@ -684,9 +714,8 @@ } else { //TODO: make it *actually* die gracefully... the way it works now looks more like puke than grace. - $this->gfObj->debug_print(__METHOD__ .": something broke. \nDETAILS::: $details" . + throw new exception(__METHOD__ .": Couldn't find 404 template, plus additional error... \nDETAILS::: $details" . "\nREASON::: ". $this->reason); - exit; } }//end die_gracefully() //------------------------------------------------------------------------ @@ -735,15 +764,41 @@ //now include the includes scripts, if there are any. if(is_array($this->includesList) && count($this->includesList)) { - foreach($this->includesList as $myInternalIndex=>$myInternalScriptName) { - $this->myLastInclude = $myInternalScriptName; - include_once($this->myLastInclude); + try { + foreach($this->includesList as $myInternalIndex=>$myInternalScriptName) { + $this->myLastInclude = $myInternalScriptName; + include_once($this->myLastInclude); + } } + catch(exception $e) { + $myRoot = preg_replace('/\//', '\\\/', $this->fileSystemObj->root); + $displayableInclude = preg_replace('/^'. $myRoot .'/', '', $this->myLastInclude); + $this->templateObj->set_message_wrapper(array( + 'title' => "Fatal Error", + 'message' => __METHOD__ .": A fatal error occurred while processing <b>". + $displayableInclude ."</b>:<BR>\n<b>ERROR</b>: ". $e->getMessage(), + 'type' => "fatal" + )); + + //try to pass the error on to the user's exception handler, if there is one. + if(function_exists('exception_handler')) { + exception_handler($e); + } + } unset($myInternalIndex); unset($myInternalScriptName); } - $page->print_page(); + if(is_bool($this->templateObj->allow_invalid_urls() === TRUE) && $this->isValid === FALSE) { + $this->isValid = $this->templateObj->allow_invalid_urls(); + } + + if($this->isValid === TRUE) { + $page->print_page(); + } + else { + $this->die_gracefully($this->reason); + } }//end finish() //------------------------------------------------------------------------ @@ -753,8 +808,7 @@ /** * Method for accessing the protected $this->sectionArr array. */ - public function get_sectionArr() - { + public function get_sectionArr() { //give 'em what they want. return($this->sectionArr); }//end get_sectionArr() @@ -766,8 +820,7 @@ /** * Method for accessing the protected member $this->finalSection. */ - public function get_finalSection() - { + public function get_finalSection() { //give 'em what they want. return($this->finalSection); }//end get_finalSection() @@ -779,8 +832,7 @@ /** * Method for accessing "baseDir", only referenced as the base section. */ - public function get_baseSection() - { + public function get_baseSection() { return($this->baseDir); }//end get_baseSection() //------------------------------------------------------------------------ Modified: trunk/1.0/lib/cs-content/cs_bbCodeParser.class.php =================================================================== --- trunk/1.0/lib/cs-content/cs_bbCodeParser.class.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/cs_bbCodeParser.class.php 2008-02-07 01:47:25 UTC (rev 790) @@ -5,11 +5,11 @@ * * SVN INFORMATION::: * ------------------ - * SVN Signature::::::: $Id: cs_bbCodeParser.class.php 173 2007-10-02 14:36:50Z crazedsanity $ + * SVN Signature::::::: $Id: cs_bbCodeParser.class.php 179 2007-10-04 22:31:43Z crazedsanity $ * Last Author::::::::: $Author: crazedsanity $ - * Current Revision:::: $Revision: 173 $ - * Repository Location: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/cs_bbCodeParser.class.php $ - * Last Updated:::::::: $Date: 2007-10-02 09:36:50 -0500 (Tue, 02 Oct 2007) $ + * Current Revision:::: $Revision: 179 $ + * Repository Location: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/cs_bbCodeParser.class.php $ + * Last Updated:::::::: $Date: 2007-10-04 17:31:43 -0500 (Thu, 04 Oct 2007) $ * * * Originally from a snippet (just the function) on PHPFreaks.com: http://www.phpfreaks.com/quickcode/BBCode/712.php Modified: trunk/1.0/lib/cs-content/cs_fileSystemClass.php =================================================================== --- trunk/1.0/lib/cs-content/cs_fileSystemClass.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/cs_fileSystemClass.php 2008-02-07 01:47:25 UTC (rev 790) @@ -1,12 +1,12 @@ -<? +<?php /* * FILE INFORMATION: - * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/cs_fileSystemClass.php $ - * $Id: cs_fileSystemClass.php 170 2007-09-25 22:54:19Z crazedsanity $ - * $LastChangedDate: 2007-09-25 17:54:19 -0500 (Tue, 25 Sep 2007) $ + * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/cs_fileSystemClass.php $ + * $Id: cs_fileSystemClass.php 252 2008-01-31 21:57:49Z crazedsanity $ + * $LastChangedDate: 2008-01-31 15:57:49 -0600 (Thu, 31 Jan 2008) $ * $LastChangedBy: crazedsanity $ - * $LastChangedRevision: 170 $ + * $LastChangedRevision: 252 $ */ require_once(dirname(__FILE__) ."/cs_globalFunctions.php"); @@ -253,6 +253,7 @@ * can enlighten me, I'd be glad to give them credit. */ private function translate_perms($in_Perms) { + $sP = ""; $sP .= (($in_Perms & 0x0100) ? 'r' : '-') . (($in_Perms & 0x0080) ? 'w' : '-') . (($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) : @@ -307,11 +308,11 @@ $this->closeFile(); } else { - throw new exception(__METHOD__ .": unable to open specified file"); + throw new exception(__METHOD__ .": unable to open specified file (". $filename .")"); } } else { - throw new exception(__METHOD__ .": file is not writable"); + throw new exception(__METHOD__ .": Cannot truncate, file (". $filename .") is not writable"); } } return($retval); Modified: trunk/1.0/lib/cs-content/cs_genericPageClass.php =================================================================== --- trunk/1.0/lib/cs-content/cs_genericPageClass.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/cs_genericPageClass.php 2008-02-07 01:47:25 UTC (rev 790) @@ -1,11 +1,11 @@ <?php /* * FILE INFORMATION: - * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/cs_genericPageClass.php $ - * $Id: cs_genericPageClass.php 172 2007-10-01 16:24:17Z crazedsanity $ - * $LastChangedDate: 2007-10-01 11:24:17 -0500 (Mon, 01 Oct 2007) $ + * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/cs_genericPageClass.php $ + * $Id: cs_genericPageClass.php 252 2008-01-31 21:57:49Z crazedsanity $ + * $LastChangedDate: 2008-01-31 15:57:49 -0600 (Thu, 31 Jan 2008) $ * $LastChangedBy: crazedsanity $ - * $LastChangedRevision: 172 $ + * $LastChangedRevision: 252 $ */ require_once(dirname(__FILE__) ."/template.inc"); require_once(dirname(__FILE__) ."/cs_versionAbstract.class.php"); @@ -22,6 +22,8 @@ private $showEditableLink = FALSE; + private $allowInvalidUrls=NULL; + //--------------------------------------------------------------------------------------------- /** * The constructor. @@ -65,7 +67,7 @@ $this->add_template_var($key, $value); } } - if(is_array($GLOBALS['templateFiles'])) { + if(isset($GLOBALS['templateFiles']) && is_array($GLOBALS['templateFiles'])) { foreach($GLOBALS['templateFiles'] as $key => $value) { $this->templateFiles[$key] = $value; } @@ -257,7 +259,7 @@ if($stripUndefVars) { $numLoops = 0; - while(preg_match_all('/\{.*?\}/', $this->templateObj->varvals[out], $tags) && $numLoops < 50) { + while(preg_match_all('/\{.\S+?\}/', $this->templateObj->varvals['out'], $tags) && $numLoops < 50) { $tags = $tags[0]; //TODO: figure out why this works when running it twice. @@ -286,8 +288,9 @@ */ public function process_set_message() { //if there's not a message set, skip. - $errorBox = $this->file_to_string("system/message_box.tmpl"); - if(is_array($_SESSION['message'])) { + $errorBox = ""; + if(isset($_SESSION['message']) && is_array($_SESSION['message'])) { + $errorBox = $this->file_to_string("system/message_box.tmpl"); //let's make sure the "type" value is *lowercase*. $_SESSION['message']['type'] = strtolower($_SESSION['message']['type']); @@ -307,6 +310,7 @@ // they'll never get past this point). unset($_SESSION['message']); } + return($errorBox); }//end of process_set_message() //--------------------------------------------------------------------------------------------- @@ -595,6 +599,17 @@ return($retval); }//end set_all_block_rows() //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + public function allow_invalid_urls($newSetting=NULL) { + if(!is_null($newSetting) && is_bool($newSetting)) { + $this->allowInvalidUrls = $newSetting; + } + return($this->allowInvalidUrls); + }//end allow_invalid_urls() + //--------------------------------------------------------------------------------------------- }//end cs_genericPage{} ?> Modified: trunk/1.0/lib/cs-content/cs_globalFunctions.php =================================================================== --- trunk/1.0/lib/cs-content/cs_globalFunctions.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/cs_globalFunctions.php 2008-02-07 01:47:25 UTC (rev 790) @@ -82,9 +82,10 @@ */ public function string_from_array($array,$style=NULL,$separator=NULL, $cleanString=NULL, $removeEmptyVals=FALSE) { + $retval = NULL; //precheck... if it's not an array, kill it. if(!is_array($array)) { - return(0); + return(NULL); } //make sure $style is valid. @@ -167,7 +168,7 @@ $value = $this->cleanString($value, "sql"); $value = "'". $value ."'"; } - $retval = $this->create_list($retval, $field . $separator . $value, " "); + $retval = $this->create_list($retval, $value, ", "); } if($style == "order" && !preg_match('/order by/', strtolower($retval))) { $retval = "ORDER BY ". $retval; @@ -271,7 +272,7 @@ } else { //not an array. - $retval = 0; + $retval = NULL; } return($retval); @@ -639,6 +640,49 @@ }//end truncate_string() //--------------------------------------------------------------------------------------------- + + + + //########################################################################## + public function array_as_option_list(array $data, $checkedValue=NULL, $type="select", $useTemplateString=NULL, array $repArr=NULL) { + $typeArr = array ( + "select" => "selected", + "radio" => "checked", + "checkbox" => "checked" + ); + + $myType = $typeArr[$type]; + if(is_null($useTemplateString)) { + // + $useTemplateString = "\t\t<option value='%%value%%'%%selectedString%%>%%display%%</option>"; + } + + $retval = ""; + foreach($data as $value=>$display) { + //see if it's the value that's been selected. + $selectedString = ""; + if($value == $checkedValue || $display == $checkedValue) { + //yep, it's selected. + $selectedString = " ". $myType; + } + + //create the string. + $myRepArr = array( + 'value' => $value, + 'display' => $display, + 'selectedString' => $selectedString + ); + if(is_array($repArr) && is_array($repArr[$value])) { + //merge the arrays. + $myRepArr = array_merge($repArr[$value], $myRepArr); + } + $addThis = $this->mini_parser($useTemplateString, $myRepArr, "%%", "%%"); + $retval = $this->create_list($retval, $addThis, "\n"); + } + + return($retval); + }//end array_as_option_list() + //########################################################################## }//end cs_globalFunctions{} Modified: trunk/1.0/lib/cs-content/cs_phpDB.php =================================================================== --- trunk/1.0/lib/cs-content/cs_phpDB.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/cs_phpDB.php 2008-02-07 01:47:25 UTC (rev 790) @@ -4,9 +4,9 @@ * A class for generic PostgreSQL database access. * * SVN INFORMATION::: - * SVN Signature:::::::: $Id: cs_phpDB.php 154 2007-09-12 18:43:16Z crazedsanity $ - * Last Committted Date: $Date: 2007-09-12 13:43:16 -0500 (Wed, 12 Sep 2007) $ - * Last Committed Path:: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/cs_phpDB.php $ + * SVN Signature:::::::: $Id: cs_phpDB.php 252 2008-01-31 21:57:49Z crazedsanity $ + * Last Committted Date: $Date: 2008-01-31 15:57:49 -0600 (Thu, 31 Jan 2008) $ + * Last Committed Path:: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/cs_phpDB.php $ * */ @@ -24,1062 +24,59 @@ // /////////////////////// +//TODO: option to not use layered transactions +//TODO: rollbackTrans() in layered transaction causes abort when final layer is committed/aborted +//TODO: stop sending queries to backend when transction is bad/aborted. +//TODO: commit/abort specific layer requests (i.e. if there's 8 layers & the first is named "x", calling commitTrans("x") will cause the whole transaction to commit & all layers to be destroyed. + require_once(dirname(__FILE__) ."/cs_versionAbstract.class.php"); class cs_phpDB extends cs_versionAbstract { - - /** Internal result set pointer. */ - protected $result = NULL; - /** Internal error code. */ - protected $errorCode = 0; + private $dbLayerObj; + private $dbType; - /** Status of the current transaction. */ - protected $transStatus = NULL; - - /** Whether there is a transaction in progress or not. */ - protected $inTrans = FALSE; - - /** Holds the last query performed. */ - protected $lastQuery = NULL; - - /** List of queries that have been run */ - protected $queryList=array(); - - /** How many seconds to wait for a query before cancelling it. */ - protected $timeOutSeconds = NULL; - - /** Internal check to determine if a connection has been established. */ - protected $isConnected=FALSE; - - /** Internal check to determine if the parameters have been set. */ - protected $paramsAreSet=FALSE; - - /** Resource handle. */ - protected $connectionID = -1; - - /** Hostname or IP to connect to */ - protected $host; - - /** Port to connect to (default for Postgres is 5432) */ - protected $port; - - /** Name of the database */ - protected $dbname; - - /** Username to connect to the database */ - protected $user; - - /** password to connect to the database */ - protected $password; - - /** Row counter for looping through records */ - protected $row = -1; - - /** cs_globalFunctions object, for string stuff. */ - protected $gfObj; - - /** Internal check to ensure the object has been properly created. */ - protected $isInitialized=FALSE; - - /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ - protected $preparedStatements = array(); - - /** Set to TRUE to save all queries into an array. */ - protected $useQueryList=FALSE; - - //////////////////////////////////////////// - // Core primary connection/database function - //////////////////////////////////////////// - - //========================================================================= - public function __construct() { - $this->gfObj = new cs_globalFunctions; - $this->gfObj->debugRemoveHr=0; - $this->gfObj->debugPrintOpt=0; + public function __construct($type='pgsql') { - $this->isInitialized = TRUE; - }//end __construct() - //========================================================================= - - - - //========================================================================= - /** - * Make sure the object is sane. - */ - final protected function sanity_check() { - if($this->isInitialized !== TRUE) { - throw new exception(__METHOD__ .": not properly initialized"); - } - }//end sanity_check() - //========================================================================= - - - - //========================================================================= - /** - * Set appropriate parameters for database connection - */ - public function set_db_info(array $params){ - $this->sanity_check(); - $required = array('host', 'port', 'dbname', 'user', 'password'); - - $requiredCount = 0; - foreach($params as $index=>$value) { - if(property_exists($this, $index) && in_array($index, $required)) { - $this->$index = $value; - $requiredCount++; - } - else { - throw new exception(__METHOD__. ": property (". $index .") does " . - "not exist or isn't allowed"); - } - } - - if($requiredCount == count($required)) { - $this->paramsAreSet = TRUE; - } - else { - throw new exception(__METHOD__ .": required count (". $requiredCount - .") does not match required number of fields (". count($required) .")"); - } - }//end set_db_info() - //========================================================================= - - - - //========================================================================= - /** - * Wrapper for close() - */ - function disconnect() { - //Disconnect from $database - return($this->close()); - }//end disconnect() - //========================================================================= - - - - //========================================================================= - /** - * Standard method to close connection. - */ - function close() { - $this->isConnected = FALSE; - $retval = null; - if($this->connectionID != -1) { - $retval = pg_close($this->connectionID); - } - else { - throw new exception(__METHOD__ .": Failed to close connection: connection is invalid"); - } - - return($retval); - }//end close() - //========================================================================= - - - - //========================================================================= - /** - * Connect to the database - */ - function connect(array $dbParams=NULL, $forceNewConnection=FALSE){ - $this->sanity_check(); - $retval = NULL; - if(is_array($dbParams)) { - $this->set_db_info($dbParams); - } - - if($this->paramsAreSet === TRUE && $this->isConnected === FALSE) { + if(strlen($type)) { - $myConnArr = array( - 'host' => $this->host, - 'port' => $this->port, - 'dbname' => $this->dbname, - 'user' => $this->user, - 'password' => $this->password - ); + require_once(dirname(__FILE__) .'/db_types/'. __CLASS__ .'__'. $type .'.class.php'); + $className = __CLASS__ .'__'. $type; + $this->dbLayerObj = new $className; + $this->dbType = $type; - //make it into a string separated by spaces, don't clean anything, remove null elements - $connStr = $this->gfObj->string_from_array($myConnArr, 'url', " "); + $this->gfObj = new cs_globalFunctions; - //start output buffer for displaying error. - ob_start(); - if($forceNewConnection) { - $connID = pg_connect($connStr, PGSQL_CONNECT_FORCE_NEW); + if(defined('DEBUGPRINTOPT')) { + $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; } - else { - $connID =pg_connect($connStr); - } - $connectError = ob_get_contents(); - ob_end_clean(); - if(is_resource($connID)) { - $this->errorCode=0; - $this->connectionID = $connID; - $this->isConnected = TRUE; - $retval = $this->connectionID; - } - else { - throw new exception(__METHOD__ .": FATAL ERROR: ". $connectError); - } + $this->isInitialized = TRUE; } else { - throw new exception(__METHOD__ .": paramsAreSet=(". $this->paramsAreSet ."), isConnected=(". $this->isConnected .")"); + throw new exception(__METHOD__ .": failed to give a type (". $type .")"); } - - return($retval); - }//end connect() + }//end __construct() //========================================================================= //========================================================================= - function get_hostname() { - $this->sanity_check(); - return($this->host); - }//end get_hostname() - //========================================================================= - - - - //========================================================================= - /** - * Run sql queries - * - * TODO: re-implement query logging (setting debug, logfilename, etc). - */ - function exec($query) { - $this->lastQuery = $query; - if($this->useQueryList) { - $this->queryList[] = $query; - } - $returnVal = false; - - if(($this->get_transaction_status() != -1) && ($this->connectionID != -1)) { - $this->result = @pg_query($this->connectionID, $query); - - if($this->result !== false) { - if (eregi("^[[:space:]]*select", $query)) { - //If we didn't have an error and we are a select statement, move the pointer to first result - $numRows = $this->numRows(); - if($numRows > 0) { - $this->move_first(); - } - $returnVal = $numRows; - - } - else { - //We got something other than an update. Use numAffected - $returnVal = $this->numAffected(); - } - } - } - return($returnVal); - }//end exec() - //========================================================================= - - - - //========================================================================= /** - * Returns any error caused by the last executed query. - * - * @return NULL OK: no error - * @return (string) FAIL: contains error returned from the query. + * Magic method to call methods within the database abstraction layer ($this->dbLayerObj). */ - function errorMsg($setMessage=NULL,$logError=NULL) { - $this->sanity_check(); - if ($this->connectionID < 0) { - switch ($this->errorCode) { - //############################################### - case -1: - $retVal = "FATAL ERROR - CONNECTION ERROR: RESOURCE NOT FOUND"; - break; - //############################################### - - //############################################### - case -2: - $retVal = "FATAL ERROR - CLASS ERROR: FUNCTION CALLED WITHOUT PARAMETERS"; - break; - //############################################### - - //############################################### - case -3: - $retVal = "Query exceeded maximum timeout (". $this->timeoutSeconds .")"; - break; - //############################################### - - //############################################### - default: - $retVal = null; - //############################################### - } - } else { - $retVal = pg_last_error($this->connectionID); + public function __call($methodName, $args) { + if(method_exists($this->dbLayerObj, $methodName)) { + $retval = call_user_func_array(array($this->dbLayerObj, $methodName), $args); } - - return($retVal); - }//end errorMsg() - //========================================================================= - - - - - //////////////////// - // Cursor movement - //////////////////// - - - - - //========================================================================= - /** - * move pointer to first row of result set - */ - function move_first() { - $this->sanity_check(); - if($this->result == NULL) { - $retval = FALSE; - } else { - $this->set_row(0); - $retval = TRUE; + throw new exception(__METHOD__ .': unsupported method ('. $methodName .') for database of type ('. $this->dbType .')'); } - return($retval); - }//end move_first() + }//end __call() //========================================================================= - - - //========================================================================= - /** - * move pointer to last row of result set - */ - function move_last() { - $this->sanity_check(); - if($this->result == NULL) { - $retval = FALSE; - } - else { - $this->set_row($this->numRows()-1); - $retval = TRUE; - } - - return($retval); - }//end move_list() - //========================================================================= - - - - //========================================================================= - /** - * point to the next row, return false if no next row - */ - function move_next() { - $this->sanity_check(); - // If more rows, then advance row pointer - if($this->row < $this->numRows()-1) { - $this->set_row($this->row +1); - $retval = TRUE; - } - else { - $retval = FALSE; - } - - return($retval); - }//end move_next() - //========================================================================= - - - - //========================================================================= - /** - * point to the previous row, return false if no previous row - */ - function move_previous() { - // If not first row, then advance row pointer - if ($this->row > 0) { - $this->set_row($this->row -1); - return true; - } - else return false; - }//end move_previous() - //========================================================================= - - - - //========================================================================= - // point to the next row, return false if no next row - function next_row() { - // If more rows, then advance row pointer - if ($this->row < $this->numRows()-1) { - $this->set_row($this->row +1); - return true; - } - else return false; - }//end next_row() - //========================================================================= - - - - //========================================================================= - // can be used to set a pointer to a perticular row - function set_row($row){ - if(is_numeric($row)) { - $this->row = $row; - } - else { - throw new exception(__METHOD__ .": invalid data for row (". $row .")"); - } - return($this->row); - }//end set_row(); - //========================================================================= - - - - - /////////////////////// - // Result set related - /////////////////////// - - - - //========================================================================= - /** - * Return the current row as an object. - */ - function fobject() { - $this->sanity_check(); - if($this->result == NULL || $this->row == -1) { - $retval = NULL; - } - else { - $retval = pg_fetch_object($this->result, $this->row); - } - - return($retval); - } - //========================================================================= - - - - //========================================================================= - /** - * Fetch the current row as an array containing fieldnames AND numeric indexes. - */ - function farray(){ - if($this->result == NULL || $this->row == -1) { - $retval = NULL; - } - else { - $retval = pg_fetch_array($this->result,$this->row); - } - - return($retval); - }//end farray() - //========================================================================= - - - - //========================================================================= - /** - * Another way to retrieve a single row (useful for loops). - */ - function frow(){ - $this->sanity_check(); - if($this->numRows() <= 0) { - $retval = NULL; - } - else { - if($this->result == null || $this->row == -1) { - $retval = NULL; - } - else { - $retval = pg_fetch_row($this->result, $this->row); - } - } - - return($retval); - }//end frow() - //========================================================================= - - - - //========================================================================= - /** - * Similar to farray(), except all indexes are non-numeric, and the entire - * result set is retrieved: if only one row is available, no numeric index - * is set, unless $numbered is TRUE. - * - * TODO: clean this up! - */ - function farray_fieldnames($index=NULL, $numbered=NULL,$unsetIndex=1) { - $this->sanity_check(); - $retval = NULL; - - //before we get too far, let's make sure there's something there. - if($this->numRows() <= 0) { - $retval = 0; - } - else { - //keep any errors/warnings from printing to the screen by using OUTPUT BUFFERS. - ob_start(); - - $x = 0; - do { - $temp = $this->farray(); - foreach($temp as $key=>$value) { - //remove the numbered indexes. - if(is_string($key)) { - $tArr[$key] = $value; - } - } - $newArr[$x] = $tArr; - $x++; - } - while($this->next_row()); - - if($index) { - foreach($newArr as $row=>$contents) { //For each of the returned sets of information - foreach($contents as $fieldname=>$value) { //And now for each of the items in that set - if($fieldname == $index) { - //The index for the new array will be this fieldname's value - $arrayKey = $value; - } - - $tempContent[$fieldname] = $value; - //don't include the "index" field in the subarray; that always seems to end badly. - if ($unsetIndex) { - unset($tempContent[$index]); - } - } - - if (!isset($tempArr[$arrayKey])) { - //Make sure we didn't already set this in the array. If so, then we don't have a unique variable to use for the array index. - $tempArr[$arrayKey] = $tempContent; - } - else { - //TODO: bigtime cleaning... should only return at the bottom of the method. - $retval = 0; - break; - } - $arrayKey = NULL; //Blank this out after using it, just in case we don't find one in the next iteration - } - - if (count($tempArr) != count($newArr)) { - $details = "farray_fieldnames(): Array counts don't match.<BR>\n" - ."FUNCTION ARGUMENTS: index=[$index], numbered=[$numbered], unsetIndex=[$unsetIndex]<BR>\n" - ."LAST QUERY: ". $this->lastQuery; - throw new exception(__METHOD__ .": $details"); - } - $newArr = $tempArr; - } - //this is where, if there's only one row (and the planets align just the way - // I like them to), there's no row w/ a sub-array... This is only done - // if $index is NOT set... - if(($this->numRows() == 1) AND (!$index) AND (!$numbered)) { - $newArr = $newArr[0]; - } - $retval = $newArr; - ob_end_clean(); - } - return($retval); - }//end farray_fieldnames() - //========================================================================= - - - - //========================================================================= - /** - * Uses farray_fieldnames() to retrieve the entire result set, but the final - * array is contains name=>value pairs. - */ - function farray_nvp($name, $value) { - if((!$name) OR (!$value)) { - $retval = 0; - } - else { - $tArr = $this->farray_fieldnames(NULL,1); - if(!is_array($tArr)) { - $retval = 0; - } - else { - //loop through it & grab the proper info. - $retval = array(); - foreach($tArr as $row=>$array) { - $tKey = $array[$name]; - $tVal = $array[$value]; - $retval[$tKey] = $tVal; - } - } - } - - //return the new array. - return($retval); - }//end farray_nvp() - //========================================================================= - - - - //========================================================================= - /** - * Similar to farray_fieldnames(), but only returns the NUMERIC indexes - */ - function farray_numbered() { - do { - $temp = $this->frow(); - $retArr[] = $temp[0]; - } - while($this->next_row()); - - return($retArr); - }//end farray_numbered() - //========================================================================= - - - - //========================================================================= - /** - * Returns the number of tuples affected by an insert/delete/update query. - * NOTE: select queries must use numRows() - */ - function numAffected() { - if($this->result == null) { - $retval = 0; - } else { - $this->affectedRows = pg_affected_rows($this->result); - $retval = $this->affectedRows; - } - - return($retval); - }//end numAffected() - //========================================================================= - - - - //========================================================================= - /** - * Returns the number of rows in a result (from a SELECT query). - */ - function numRows() { - if ($this->result == null) { - $retval = 0; - } - else { - $this->numrows = pg_num_rows($this->result); - $retval = $this->numrows; - } - - return($retval); - }//end numRows() - //========================================================================= - - - - //========================================================================= - /** - * wrapper for numAffected() - */ - function affectedRows(){ - return($this->numAffected()); - }//end affectedRows() - //========================================================================= - - - - //========================================================================= - /** - * Returns the current row number. - */ - function currRow(){ - return($this->row); - }//end currRow() - //========================================================================= - - - - //========================================================================= - /** - * Get the number of fields in a result. - */ - // get the number of fields in a result - function num_fields() { - if($this->result == null) { - $retval = 0; - } - else { - $retval = pg_num_fields($this->result); - } - return($retval); - }//end num_fields() - //========================================================================= - - - - //========================================================================= - function column_count() { - return($this->numFields()); - }//end column_count() - //========================================================================= - - - - //========================================================================= - /** - * get last OID (object identifier) of last INSERT statement - */ - function lastOID($doItForMe=0, $field=NULL) { - if($this->result == NULL) { - $retval = NULL; - } - else { - $tOid = pg_last_oid($this->result); - $retval = $tOid; - - if(($doItForMe) AND (eregi("^insert", $this->last_query))) { - //attempt to parse the insert statement, then select - // all fields (unless $field is set) from it. - $t = split(" into ", strtolower($this->last_query)); - $t = split(" ", $t[1]); - $t = split("\(", $t[0]); - $table = $t[0]; - - //now we have the table. - if(!$field) { - $field = "*"; - } - $query = "SELECT $field FROM $table WHERE OID=$tOid"; - $this->exec($query); - $dberror = $this->errorMsg(1,1,1,"lastOID(): "); - - if(!$dberror) { - $res = $this->farray(); - if(is_string($field)) { - $retval = $res[0]; - } - } - } - } - return($retval); - }//end lastOID() - //========================================================================= - - - - //========================================================================= - /** - * get result field name of the given field number. - */ - // get result field name - function fieldname($fieldnum) { - if($this->result == NULL) { - $retval =NULL; - } - else { - $retval = pg_field_name($this->result, $fieldnum); - } - - return($retval); - }//end fieldname() - //========================================================================= - - - - - //////////////////////// - // Transaction related - //////////////////////// - - - - - //========================================================================= - /** - * Start a transaction. - */ - function beginTrans() { - $this->inTrans = TRUE; - return($this->exec("BEGIN")); - }//end beginTrans() - //========================================================================= - - - - //========================================================================= - /** - * Commit a transaction. - */ - function commitTrans() { - $retval = $this->get_transaction_status(); - if($retval > 1) { - $retval = 1; - } - $this->exec("COMMIT"); - $this->get_transaction_status(); - return($retval); - }//end commitTrans() - //========================================================================= - - - - //========================================================================= - // returns true/false - function rollbackTrans() { - $retval = $this->exec("ABORT"); - $this->get_transaction_status(); - return($retval); - }//end rollbackTrans() - //========================================================================= - - - - //////////////////////// - // SQL String Related - //////////////////////// - - - - //========================================================================= - /** - * Gets rid of evil characters that might lead ot SQL injection attacks. - */ - function querySafe($string) { - return($this->gfObj->cleanString($string,"query")); - }//end querySafe() - //========================================================================= - - - - //========================================================================= - /** - * Make it SQL safe. - */ - function sqlSafe($string) { - return($this->gfObj->cleanString($string,"sql")); - }//end sqlSafe() - //========================================================================= - - - - //========================================================================= - /** - * Gives textual explanation of the current status of our database - * connection. - * - * @param $goodOrBad (bool,optional) return good/bad status. - * - * @return (-1) (FAIL) connection is broken - * @return (0) (FAIL) error was encountered (transient error) - * @return (1) (PASS) useable - * @return (2) (PASS) useable, but not just yet (working - * on something) - */ - function get_transaction_status($goodOrBad=TRUE) { - $myStatus = pg_transaction_status($this->connectionID); - $text = 'unknown'; - switch($myStatus) { - case PGSQL_TRANSACTION_IDLE: { - //No query in progress: it's idle. - $goodOrBadValue = 1; - $text = 'idle'; - $this->inTrans = FALSE; - } - break; - - - case PGSQL_TRANSACTION_ACTIVE: { - //there's a command in progress. - $goodOrBadValue = 2; - $text = 'processing'; - } - break; - - - case PGSQL_TRANSACTION_INTRANS: { - //connection idle within a valid transaction block. - $goodOrBadValue = 1; - $text = 'valid transaction'; - $this->inTrans = TRUE; - } - break; - - - case PGSQL_TRANSACTION_INERROR: { - //connection idle within a broken transaction. - $goodOrBadValue = 0; - $text = 'failed transaction'; - $this->inTrans = TRUE; - } - break; - - - case PGSQL_TRANSACTION_UNKNOWN: - default: { - //the connection is bad. - $goodOrBadValue = -1; - $text = 'bad connection'; - } - break; - } - - //do they want text or the good/bad number? - $retval = $text; - $this->transactionStatus = $goodOrBadValue; - if($goodOrBad) { - //they want the number. - $retval = $goodOrBadValue; - } - - return($retval); - }//end valid_transaction() - //========================================================================= - - - - //========================================================================= - public function is_connected() { - $retval = FALSE; - if(is_resource($this->connectionID) && $this->isConnected === TRUE) { - $retval = TRUE; - } - - return($retval); - }//end is_connected() - //========================================================================= - - - - //========================================================================= - /** - * Create a prepared statement. - */ - public function create_prepared_statement($planName,array $fieldToType, $statement) { - $retval = FALSE; - //store the mappings. - $this->preparedStatements[$planName] = $fieldToType; - - //TODO: check that the string in "$statement" has the same number of "${n}" as are in "$fieldToType". - - $dataTypeString = ""; - foreach($fieldToType as $field => $type) { - $dataTypeString = $this->gfObj->create_list($dataTypeString, $type, ", "); - } - - $sql = "PREPARE ". $planName ."(". $dataTypeString .") AS ". $statement; - - $myNumrows = $this->exec($sql); - $myDberror = $this->errorMsg(); - - if(!strlen($myDberror)) { - $retval = TRUE; - } - else { - throw new exception(__METHOD__ .": failed to create prepared statement '". $planName ."'... dberror::: ". $myDberror ."\n\nSQL::: ". $sql); - } - - return($retval); - }//end create_prepared_statement() - //========================================================================= - - - - //========================================================================= - /** - * Run a statement prepared by this object. - * - * NOTE: determination of rows affected (numAffected) vs. rows returned (numRows) - * must be done by the user via the referenced methods. - */ - public function run_prepared_statement($name, array $data) { - $retval = FALSE; - if(is_array($this->preparedStatements[$name]) && count($data) == count($this->preparedStatements[$name])) { - $this->result = pg_execute($this->connectionID, $name, $data); - $dberror = $this->errorMsg(); - - if(!strlen($dberror)) { - $retval = TRUE; - } - } - else { - throw new exception(__METHOD__ .": invalid statement name (". $name ."), or incorrect number of elements"); - } - - return($retval); - }//end run_prepared_statement() - //========================================================================= - - - - //========================================================================= - /** - * Starts a copy command. - * - * TODO: implement safeguards so they can only put a line until the copy is ended. - */ - public function start_copy($tableName, array $fields) { - $retval = FALSE; - $copyStmt = "COPY ". $tableName ." (". $this->gfObj->string_from_array($fields, NULL, ", ") . ") FROM stdin;"; - $this->exec($copyStmt); - if(!strlen($this->errorMsg())) { - //TODO: set something here so that NOTHING ELSE can be done except put_line() and end_copy(). - $this->copyInProgress = TRUE; - $retval = TRUE; - } - else { - $this->end_copy(); - $retval = FALSE; - } - - return($retval); - }//end start_copy() - //========================================================================= - - - - //========================================================================= - /** - * Used to send a line to the COPY in progress (only if it was initiated by - * the internal start_copy() method). - * - * NOTE: the "end-of-copy" line, '\.', should NEVER be sent here. - */ - public function put_line($line) { - $retval = FALSE; - if($this->copyInProgress === TRUE) { - $myLine = trim($line); - $myLine .= "\n"; - - $retval = pg_put_line($this->connectionID, $myLine); - } - else { - throw new exception(__METHOD__ .": cannot send line if no copy is in progress"); - } - - return($retval); - }//end put_line() - //========================================================================= - - - - //========================================================================= - public function end_copy() { - if($this->copyInProgress === TRUE) { - //send the end-of-copy line... - $this->put_line("\\.\n"); - } - - $retval = pg_end_copy($this->connectionID); - - return($retval); - }//end end_copy() - //========================================================================= - - } // end class phpDB ?> Modified: trunk/1.0/lib/cs-content/cs_sessionClass.php =================================================================== --- trunk/1.0/lib/cs-content/cs_sessionClass.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/cs_sessionClass.php 2008-02-07 01:47:25 UTC (rev 790) @@ -1,11 +1,11 @@ <?php /* * FILE INFORMATION: - * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/cs_sessionClass.php $ - * $Id: cs_sessionClass.php 161 2007-09-19 02:49:28Z crazedsanity $ - * $LastChangedDate: 2007-09-18 21:49:28 -0500 (Tue, 18 Sep 2007) $ + * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/cs_sessionClass.php $ + * $Id: cs_sessionClass.php 221 2007-11-21 17:39:01Z crazedsanity $ + * $LastChangedDate: 2007-11-21 11:39:01 -0600 (Wed, 21 Nov 2007) $ * $LastChangedBy: crazedsanity $ - * $LastChangedRevision: 161 $ + * $LastChangedRevision: 221 $ */ require_once(dirname(__FILE__) ."/cs_versionAbstract.class.php"); @@ -18,6 +18,11 @@ public $sid_check = 1; //--------------------------------------------------------------------------------------------- + /** + * The constructor. + * + * @param $createSession (boolean,optional) determines if a session will be started or not. + */ function __construct($createSession=1) { if($createSession) { //now actually create the session. @@ -41,10 +46,91 @@ //--------------------------------------------------------------------------------------------- + /** + * Required method, so passing the object to contentSystem::handle_session() + * will work properly. + * + * @param (none) + * + * @return FALSE FAIL: user is not authenticated (hard-coded this way). + */ public function is_authenticated() { return(FALSE); }//end is_authenticated() //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Retrieve data for an existing cookie. + * + * @param $name (string) Name of cookie to retrieve value for. + * + * @return NULL FAIL (?): cookie doesn't exist or has NULL value. + * @return (string) PASS: value of cookie. + */ + public function get_cookie($name) { + $retval = NULL; + if(isset($_COOKIE) && $_COOKIE[$name]) { + $retval = $_COOKIE[$name]; + } + return($retval); + }//end get_cookie() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Create a new cookie. + * + * @param $name (string) Name of cookie + * @param $value (string) value of cookie + * @param $expiration (string/number) unix timestamp or value for strtotime(). + */ + public function create_cookie($name, $value, $expiration=NULL) { + + $expTime = NULL; + if(!is_null($expiration)) { + if(is_numeric($expiration)) { + $expTime = $expiration; + } + elseif(preg_match('/ /', $expiration)) { + $expTime = strtotime($expiration); + } + else { + throw new exception(__METHOD__ .": invalid timestamp given (". $expiration .")"); + } + } + + $retval = setcookie($name, $value, $expTime, '/'); + return($retval); + + }//end create_cookie() + //--------------------------------------------------------------------------------------------- + + + + //--------------------------------------------------------------------------------------------- + /** + * Destroy (expire) an existing cookie. + * + * @param $name (string) Name of cookie to destroy + * + * @return FALSE FAIL: no cookie by that name. + * @return TRUE PASS: cookie destroyed. + */ + public function drop_cookie($name) { + $retval = FALSE; + if(isset($_COOKIE[$name])) { + setcookie($name, $_COOKIE[$name], time() -10000, '/'); + unset($_COOKIE[$name]); + $retval = TRUE; + } + return($retval); + }//end drop_cookie() + //--------------------------------------------------------------------------------------------- }//end cs_session{} Modified: trunk/1.0/lib/cs-content/cs_versionAbstract.class.php =================================================================== --- trunk/1.0/lib/cs-content/cs_versionAbstract.class.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-content/cs_versionAbstract.class.php 2008-02-07 01:47:25 UTC (rev 790) @@ -5,9 +5,9 @@ * SVN INFORMATION::: * ------------------- * Last Author::::::::: $Author: crazedsanity $ - * Current Revision:::: $Revision: 155 $ - * Repository Location: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.9.0/cs_versionAbstract.class.php $ - * Last Updated:::::::: $Date: 2007-09-12 14:28:20 -0500 (Wed, 12 Sep 2007) $ + * Current Revision:::: $Revision: 221 $ + * Repository Location: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/releases/0.10/cs_versionAbstract.class.php $ + * Last Updated:::::::: $Date: 2007-11-21 11:39:01 -0600 (Wed, 21 Nov 2007) $ */ abstract class cs_versionAbstract { Modified: trunk/1.0/lib/cs-content/documentation/basics.pdf =================================================================== (Binary files differ) Modified: trunk/1.0/lib/cs-phpxml/VERSION =================================================================== --- trunk/1.0/lib/cs-phpxml/VERSION 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/lib/cs-phpxml/VERSION 2008-02-07 01:47:25 UTC (rev 790) @@ -1,5 +1,5 @@ ## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. -VERSION: 0.5.4 +VERSION: 0.5.5 PROJECT: cs-phpxml -$HeadURL: https://cs-phpxml.svn.sourceforge.net/svnroot/cs-phpxml/releases/0.5.4/VERSION $ \ No newline at end of file +$HeadURL: https://cs-phpxml.svn.sourceforge.net/svnroot/cs-phpxml/releases/0.5/VERSION $ \ No newline at end of file Modified: trunk/1.0/lib/cs-phpxml/xmlAbstract.class.php =================================================================== --- trunk/1.0/lib/cs-phpxml/xmlAbstract.class.php 2008-02-07 00:53:47 UTC (rev 789) +++ trunk/1.0/li... [truncated message content] |
From: <cra...@us...> - 2008-02-07 00:53:49
|
Revision: 789 http://cs-project.svn.sourceforge.net/cs-project/?rev=789&view=rev Author: crazedsanity Date: 2008-02-06 16:53:47 -0800 (Wed, 06 Feb 2008) Log Message: ----------- New trunk copy of 1.1.x (for simpler updates). Added Paths: ----------- trunk/1.1/ Copied: trunk/1.1 (from rev 788, releases/1.1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-07 00:53:16
|
Revision: 788 http://cs-project.svn.sourceforge.net/cs-project/?rev=788&view=rev Author: crazedsanity Date: 2008-02-06 16:53:09 -0800 (Wed, 06 Feb 2008) Log Message: ----------- New trunk copy of 1.0.x (for simpler updates). Added Paths: ----------- trunk/1.0/ Copied: trunk/1.0 (from rev 787, releases/1.0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-07 00:51:58
|
Revision: 787 http://cs-project.svn.sourceforge.net/cs-project/?rev=787&view=rev Author: crazedsanity Date: 2008-02-06 16:51:55 -0800 (Wed, 06 Feb 2008) Log Message: ----------- New trunk for v1.2.x Added Paths: ----------- trunk/1.2/ Removed Paths: ------------- trunk_1.2/ Copied: trunk/1.2 (from rev 786, trunk_1.2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-07 00:50:52
|
Revision: 786 http://cs-project.svn.sourceforge.net/cs-project/?rev=786&view=rev Author: crazedsanity Date: 2008-02-06 16:50:51 -0800 (Wed, 06 Feb 2008) Log Message: ----------- New trunk structure (will have subfolders representing each supported version). Added Paths: ----------- trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-07 00:49:03
|
Revision: 785 http://cs-project.svn.sourceforge.net/cs-project/?rev=785&view=rev Author: crazedsanity Date: 2008-02-06 16:49:00 -0800 (Wed, 06 Feb 2008) Log Message: ----------- Restructuring trunk to have folders for each supported version for easier updates. Added Paths: ----------- trunk_1.2/ Removed Paths: ------------- trunk/ Copied: trunk_1.2 (from rev 784, trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-06 03:30:47
|
Revision: 784 http://cs-project.svn.sourceforge.net/cs-project/?rev=784&view=rev Author: crazedsanity Date: 2008-02-05 19:30:42 -0800 (Tue, 05 Feb 2008) Log Message: ----------- Updates leader of current group when it's changed... NOTE: updating leader doesn't work anymore... Modified Paths: -------------- trunk/includes/content/settings.inc trunk/templates/content/settings/index.content.tmpl Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-06 02:50:55 UTC (rev 783) +++ trunk/includes/content/settings.inc 2008-02-06 03:30:42 UTC (rev 784) @@ -193,6 +193,7 @@ } $page->ui->set_cache("settings/showGroup", $showGroup); regenerate_group_lists($showGroup); + display_current_leader($showGroup); } } } @@ -312,7 +313,6 @@ //now show all the users (if there are any) associated with that group. $groupData = $adminUserClass->get_group_user($groupId); $page->add_template_var('groupId', $groupId); - $page->add_template_var('currentGroupLeader', $allUsers[$myGroupData['leader_uid']]['username']); $addUsers = 0; $removeUsers = 0; @@ -343,11 +343,6 @@ } } - - //set the option list for changing the leader! - $changeLeaderOption = array_as_option_list($changeLeaderOptionArr, $myGroupData['leader_uid']); - $page->add_template_var('changeGroupLeader_list', $changeLeaderOption); - if($removeUsers) { //show 'em the list to be removed. $page->add_template_var('show_group_list__removeUser', $removeUsersRow); @@ -423,6 +418,55 @@ $cache = new sessionCache("/userInput/content"); $cache->set_cache("settings/showGroup", $groupId); $objResponse = regenerate_group_lists($groupId); + + //update the current leader. + $curLeaderInfo = display_current_leader($groupId, TRUE); + $objResponse->addAssign('currentGroupLeader', 'innerHTML', $curLeaderInfo); + return($objResponse); }//end ajax__change_current_group() + + +function display_current_leader($groupId, $isAjaxCall=FALSE) { + $user = $GLOBALS['objects']['user']; + $page = $GLOBALS['objects']['page']; + $adminUserClass = $GLOBALS['objects']['admin']; + $allUsers = $adminUserClass->get_users(); + + $allGroupData = $adminUserClass->get_groups(FALSE); + $myGroupData = $allGroupData[$groupId]; + #$page->add_template_var('currentGroupLeader', $allUsers[$myGroupData['leader_uid']]['username']); + + + $changeLeaderOptionArr = array(); + $groupData = $adminUserClass->get_group_user($groupId); + + foreach($allUsers as $uid=>$userData) { + if(isset($groupData[$uid])) { + $changeLeaderOptionArr[$uid] = $userData['username']; + } + } + + //set the option list for changing the leader! + $changeLeaderOption = array_as_option_list($changeLeaderOptionArr, $myGroupData['leader_uid']); + $page->add_template_var('changeGroupLeader_list', $changeLeaderOption); + + $addTemplateVars = array( + 'currentGroupLeader' => $allUsers[$myGroupData['leader_uid']]['username'], + 'changeGroupLeader_list' => $changeLeaderOption + ); + + + if($isAjaxCall) { + $retval = $page->templateRows['currentGroupLeaderBox']; + $retval = mini_parser($retval, $addTemplateVars, '{', '}'); + return($retval); + } + else { + foreach($addTemplateVars as $name=>$value) { + $page->add_template_var($name, $value); + } + $page->add_template_var('currentGroupLeaderBox', $page->templateRows['currentGroupLeaderBox']); + } +}//end display_current_leader() ?> Modified: trunk/templates/content/settings/index.content.tmpl =================================================================== --- trunk/templates/content/settings/index.content.tmpl 2008-02-06 02:50:55 UTC (rev 783) +++ trunk/templates/content/settings/index.content.tmpl 2008-02-06 03:30:42 UTC (rev 784) @@ -111,11 +111,15 @@ <option onClick="javascript:void(xajax_ajax__change_current_group(%%group_id%%))" %%selectedString%%>%%display%% (%%short_name%%)</option> <!-- END show_group_list --> </SELECT><BR><BR><hr> + <div id="currentGroupLeader"> +<!-- BEGIN currentGroupLeaderBox --> <b>Change Leader </b>({currentGroupLeader})<b> to:</b> <input name="changeLeader[groupId]" type="HIDDEN" value="{groupId}"> <SELECT name="changeLeader[newLeader]"> {changeGroupLeader_list} </SELECT><BR> +<!-- END currentGroupLeaderBox --> + </div> <input type="submit" value="Change Leader" onClick="this.form.action.value='changeLeader'"> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-06 02:51:03
|
Revision: 783 http://cs-project.svn.sourceforge.net/cs-project/?rev=783&view=rev Author: crazedsanity Date: 2008-02-05 18:50:55 -0800 (Tue, 05 Feb 2008) Log Message: ----------- Remove unnecessary code for old non-ajax calls. Modified Paths: -------------- trunk/includes/content/settings.inc Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-06 02:49:35 UTC (rev 782) +++ trunk/includes/content/settings.inc 2008-02-06 02:50:55 UTC (rev 783) @@ -120,36 +120,9 @@ if(strlen($goHere)) { conditional_header($goHere); - exit; } exit; } -elseif(isset($_GET['action'])) { - - $adminUserClass = new adminUserClass($page->db); - - switch($_GET['action']) { - - case 'addUser': { - //add 'em! - $adminUserClass->add_user_to_group($_GET['uid'], $_GET['groupId']); - } - break; - - case 'removeUser': { - //remove 'em! - $adminUserClass->remove_user_from_group($_GET['uid'], $_GET['groupId']); - } - break; - - - default: { - //log that we didn't do anything. - } - } - conditional_header("/content/settings"); - exit; -} else { //some display settings. $x = $page->set_all_block_rows("content"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-06 02:49:39
|
Revision: 782 http://cs-project.svn.sourceforge.net/cs-project/?rev=782&view=rev Author: crazedsanity Date: 2008-02-05 18:49:35 -0800 (Tue, 05 Feb 2008) Log Message: ----------- AJAX calls to update current group on settings (admin only). Modified Paths: -------------- trunk/includes/content/settings.inc trunk/templates/content/settings/index.content.tmpl Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-06 02:32:22 UTC (rev 781) +++ trunk/includes/content/settings.inc 2008-02-06 02:49:35 UTC (rev 782) @@ -444,4 +444,12 @@ return($objResponse); }//end regenerate_group_lists() + + +function ajax__change_current_group($groupId) { + $cache = new sessionCache("/userInput/content"); + $cache->set_cache("settings/showGroup", $groupId); + $objResponse = regenerate_group_lists($groupId); + return($objResponse); +}//end ajax__change_current_group() ?> Modified: trunk/templates/content/settings/index.content.tmpl =================================================================== --- trunk/templates/content/settings/index.content.tmpl 2008-02-06 02:32:22 UTC (rev 781) +++ trunk/templates/content/settings/index.content.tmpl 2008-02-06 02:49:35 UTC (rev 782) @@ -108,7 +108,7 @@ <b>Change current group:</b><BR> <SELECT> <!-- BEGIN show_group_list --> - <option onClick="javascript:document.location.href='/content/settings?showGroup=%%value%%'" %%selectedString%%>%%display%% (%%short_name%%)</option> + <option onClick="javascript:void(xajax_ajax__change_current_group(%%group_id%%))" %%selectedString%%>%%display%% (%%short_name%%)</option> <!-- END show_group_list --> </SELECT><BR><BR><hr> <b>Change Leader </b>({currentGroupLeader})<b> to:</b> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-06 02:32:24
|
Revision: 781 http://cs-project.svn.sourceforge.net/cs-project/?rev=781&view=rev Author: crazedsanity Date: 2008-02-05 18:32:22 -0800 (Tue, 05 Feb 2008) Log Message: ----------- Extra stuff for handling AJAX stuff (only do extra processing if it's an AJAX request). Modified Paths: -------------- trunk/includes/content/settings.inc Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-06 02:28:04 UTC (rev 780) +++ trunk/includes/content/settings.inc 2008-02-06 02:32:22 UTC (rev 781) @@ -277,7 +277,7 @@ else { $result = $adminUserClass->remove_user_from_group($uid, $groupId); } - $objResponse = regenerate_group_lists($groupId); + regenerate_group_lists($groupId, $objResponse); $msg = array( 'title' => "Update Complete", @@ -305,7 +305,7 @@ }//end ajax__group_user() -function regenerate_group_lists($groupId) { +function regenerate_group_lists($groupId, xajaxResponse &$objResponse=NULL) { $user = $GLOBALS['objects']['user']; $page = $GLOBALS['objects']['page']; $page->ui = new sessionCache("/userInput/content"); @@ -417,28 +417,31 @@ ); $page->set_message_wrapper($msg); } - $ajax_nonUsers = mini_parser( - $page->templateRows['group_nonMembers'], - array( - 'show_group_list__removeUser' => $removeUsersRow, - 'show_group_list__noRemoveUser' => "" - ), - '{', '}' - ); - $ajax_curUsers = mini_parser( - $page->templateRows['group_currentMembers'], - array( - 'show_group_list__selectUser' => $addUsersRow, - 'show_group_list__noUser' => "" - ), - '{', '}' - ); + if(!is_null($objResponse)) { + $ajax_nonUsers = mini_parser( + $page->templateRows['group_nonMembers'], + array( + 'show_group_list__removeUser' => $removeUsersRow, + 'show_group_list__noRemoveUser' => "" + ), + '{', '}' + ); + + $ajax_curUsers = mini_parser( + $page->templateRows['group_currentMembers'], + array( + 'show_group_list__selectUser' => $addUsersRow, + 'show_group_list__noUser' => "" + ), + '{', '}' + ); + + $objResponse->addAssign('group_currentMembers', 'innerHTML', $ajax_curUsers); + $objResponse->addAssign('group_nonMembers', 'innerHTML', $ajax_nonUsers); + $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); + } - $objResponse->addAssign('group_currentMembers', 'innerHTML', $ajax_curUsers); - $objResponse->addAssign('group_nonMembers', 'innerHTML', $ajax_nonUsers); - $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); - return($objResponse); }//end regenerate_group_lists() ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-06 02:28:13
|
Revision: 780 http://cs-project.svn.sourceforge.net/cs-project/?rev=780&view=rev Author: crazedsanity Date: 2008-02-05 18:28:04 -0800 (Tue, 05 Feb 2008) Log Message: ----------- Regeneration of members & non-members for groups on settings page (admin) now regenerates properly via AJAX calls. Yay! Modified Paths: -------------- trunk/includes/content/settings.inc Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-04 23:31:49 UTC (rev 779) +++ trunk/includes/content/settings.inc 2008-02-06 02:28:04 UTC (rev 780) @@ -152,13 +152,9 @@ } else { //some display settings. - $x = $page->set_all_block_rows("content", array('group_nonMembers', 'group_currentMembers')); + $x = $page->set_all_block_rows("content"); - - //TODO: make this work. - //TODO: when they don't have the pref, select the default! - //show 'em their preferences. $allPrefs = $prefObj->list_all_prefs(); $userPrefs = $prefObj->get_user_prefs(); @@ -281,6 +277,7 @@ else { $result = $adminUserClass->remove_user_from_group($uid, $groupId); } + $objResponse = regenerate_group_lists($groupId); $msg = array( 'title' => "Update Complete", @@ -301,10 +298,11 @@ ); $page->set_message_wrapper($msg); } + $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); return($objResponse); -}//end ajax__group_add_user() +}//end ajax__group_user() function regenerate_group_lists($groupId) { @@ -314,7 +312,14 @@ $objResponse = new xajaxResponse(); if($user->is_admin()) { - $page->set_all_block_rows(); + + if(!isset($page->templateRows['group_nonMembers'])) { + $page->set_all_block_rows(); + } + //array('group_nonMembers', 'group_currentMembers') + $page->add_template_var('group_nonMembers', $page->templateRows['group_nonMembers']); + $page->add_template_var('group_currentMembers', $page->templateRows['group_currentMembers']); + $adminUserClass = $GLOBALS['objects']['admin']; $myGroups = $adminUserClass->get_groups(TRUE); @@ -338,7 +343,8 @@ $addUsers = 0; $removeUsers = 0; - if(is_array($groupData) && count($groupData)) { + //TODO: is there any reason to do special processing if there is no $groupData? + #if(is_array($groupData) && count($groupData)) { $baseRow = $page->templateRows['show_group_list__selectUser']; $addUsersRow = ""; $removeUsersRow = ""; @@ -354,6 +360,8 @@ $removeUsersRow .= mini_parser($page->templateRows['show_group_list__removeUser'], $userData, '%%', '%%'); $removeUsers++; $changeLeaderOptionArr[$uid] = $userData['username']; + + // } else { //not in this group. @@ -362,6 +370,7 @@ } } + //set the option list for changing the leader! $changeLeaderOption = array_as_option_list($changeLeaderOptionArr, $myGroupData['leader_uid']); $page->add_template_var('changeGroupLeader_list', $changeLeaderOption); @@ -373,6 +382,7 @@ else { //tell 'em there's no users to be removed. $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); + $removeUsersRow = $page->templateRows['show_group_list__noRemoveUser']; } if($addUsers) { @@ -382,8 +392,9 @@ else { //no users to add. $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); + $addUsersRow = $page->templateRows['show_group_list__noUser']; } - } + /*} else { //show the row that says there's no users. $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); @@ -396,7 +407,7 @@ } $page->add_template_var('show_group_list__selectUser', $addUsersRow); $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); - } + }#*/ } else { $msg = array( @@ -406,6 +417,26 @@ ); $page->set_message_wrapper($msg); } + $ajax_nonUsers = mini_parser( + $page->templateRows['group_nonMembers'], + array( + 'show_group_list__removeUser' => $removeUsersRow, + 'show_group_list__noRemoveUser' => "" + ), + '{', '}' + ); + + $ajax_curUsers = mini_parser( + $page->templateRows['group_currentMembers'], + array( + 'show_group_list__selectUser' => $addUsersRow, + 'show_group_list__noUser' => "" + ), + '{', '}' + ); + + $objResponse->addAssign('group_currentMembers', 'innerHTML', $ajax_curUsers); + $objResponse->addAssign('group_nonMembers', 'innerHTML', $ajax_nonUsers); $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); return($objResponse); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-04 23:31:54
|
Revision: 779 http://cs-project.svn.sourceforge.net/cs-project/?rev=779&view=rev Author: crazedsanity Date: 2008-02-04 15:31:49 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Changes to generate/regenerate group member lists via AJAX. Modified Paths: -------------- trunk/includes/content/settings.inc trunk/templates/content/settings/index.content.tmpl Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-04 23:13:44 UTC (rev 778) +++ trunk/includes/content/settings.inc 2008-02-04 23:31:49 UTC (rev 779) @@ -152,7 +152,7 @@ } else { //some display settings. - $x = $page->set_all_block_rows("content"); + $x = $page->set_all_block_rows("content", array('group_nonMembers', 'group_currentMembers')); @@ -223,84 +223,7 @@ $showGroup = $_SESSION['login_group_id']; } $page->ui->set_cache("settings/showGroup", $showGroup); - - //get a complete list of users. - $allUsers = $adminUserClass->get_users(); - - //display the list of available groups. - $repArr = $adminUserClass->get_groups(FALSE); - $displayGroupList = array_as_option_list( - $myGroups, $showGroup, "select", $page->templateRows['show_group_list'], $repArr - ); - $page->add_template_var('show_group_list', $displayGroupList); - - //set this for later use... - $myGroupData = $repArr[$showGroup]; - - //now show all the users (if there are any) associated with that group. - $groupData = $adminUserClass->get_group_user($showGroup); - $page->add_template_var('groupId', $showGroup); - $page->add_template_var('currentGroupLeader', $allUsers[$myGroupData['leader_uid']]['username']); - - if(is_array($groupData) && count($groupData)) { - $baseRow = $page->templateRows['show_group_list__selectUser']; - $addUsersRow = ""; - $removeUsersRow = ""; - - //build the list of users that CAN be added, and the list that can be removed. - $addUsers = 0; - $removeUsers = 0; - $changeLeaderOptionArr = array(); - foreach($allUsers as $uid=>$userData) { - $userData['group_id'] = $showGroup; - if(isset($groupData[$uid])) { - //they're already in this group. - $removeUsersRow .= mini_parser($page->templateRows['show_group_list__removeUser'], $userData, '%%', '%%'); - $removeUsers++; - $changeLeaderOptionArr[$uid] = $userData['username']; - } - else { - //not in this group. - $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); - $addUsers++; - } - } - - //set the option list for changing the leader! - $changeLeaderOption = array_as_option_list($changeLeaderOptionArr, $myGroupData['leader_uid']); - $page->add_template_var('changeGroupLeader_list', $changeLeaderOption); - - if($removeUsers) { - //show 'em the list to be removed. - $page->add_template_var('show_group_list__removeUser', $removeUsersRow); - } - else { - //tell 'em there's no users to be removed. - $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); - } - - if($addUsers) { - //show 'em. - $page->add_template_var('show_group_list__selectUser', $addUsersRow); - } - else { - //no users to add. - $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); - } - } - else { - //show the row that says there's no users. - $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); - - //now put ALL users into the list that can be added... - foreach($allUsers as $uid=>$userData) { - $userData['group_id'] = $showGroup; - $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); - $addUsers++; - } - $page->add_template_var('show_group_list__selectUser', $addUsersRow); - $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); - } + regenerate_group_lists($showGroup); } } } @@ -382,4 +305,109 @@ return($objResponse); }//end ajax__group_add_user() + + +function regenerate_group_lists($groupId) { + $user = $GLOBALS['objects']['user']; + $page = $GLOBALS['objects']['page']; + $page->ui = new sessionCache("/userInput/content"); + $objResponse = new xajaxResponse(); + + if($user->is_admin()) { + $page->set_all_block_rows(); + $adminUserClass = $GLOBALS['objects']['admin']; + $myGroups = $adminUserClass->get_groups(TRUE); + + //get a complete list of users. + $allUsers = $adminUserClass->get_users(); + + //display the list of available groups. + $repArr = $adminUserClass->get_groups(FALSE); + $displayGroupList = array_as_option_list( + $myGroups, $groupId, "select", $page->templateRows['show_group_list'], $repArr + ); + $page->add_template_var('show_group_list', $displayGroupList); + + //set this for later use... + $myGroupData = $repArr[$groupId]; + + //now show all the users (if there are any) associated with that group. + $groupData = $adminUserClass->get_group_user($groupId); + $page->add_template_var('groupId', $groupId); + $page->add_template_var('currentGroupLeader', $allUsers[$myGroupData['leader_uid']]['username']); + + $addUsers = 0; + $removeUsers = 0; + if(is_array($groupData) && count($groupData)) { + $baseRow = $page->templateRows['show_group_list__selectUser']; + $addUsersRow = ""; + $removeUsersRow = ""; + + //build the list of users that CAN be added, and the list that can be removed. + $addUsers = 0; + $removeUsers = 0; + $changeLeaderOptionArr = array(); + foreach($allUsers as $uid=>$userData) { + $userData['group_id'] = $groupId; + if(isset($groupData[$uid])) { + //they're already in this group. + $removeUsersRow .= mini_parser($page->templateRows['show_group_list__removeUser'], $userData, '%%', '%%'); + $removeUsers++; + $changeLeaderOptionArr[$uid] = $userData['username']; + } + else { + //not in this group. + $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); + $addUsers++; + } + } + + //set the option list for changing the leader! + $changeLeaderOption = array_as_option_list($changeLeaderOptionArr, $myGroupData['leader_uid']); + $page->add_template_var('changeGroupLeader_list', $changeLeaderOption); + + if($removeUsers) { + //show 'em the list to be removed. + $page->add_template_var('show_group_list__removeUser', $removeUsersRow); + } + else { + //tell 'em there's no users to be removed. + $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); + } + + if($addUsers) { + //show 'em. + $page->add_template_var('show_group_list__selectUser', $addUsersRow); + } + else { + //no users to add. + $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); + } + } + else { + //show the row that says there's no users. + $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); + + //now put ALL users into the list that can be added... + foreach($allUsers as $uid=>$userData) { + $userData['group_id'] = $groupId; + $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); + $addUsers++; + } + $page->add_template_var('show_group_list__selectUser', $addUsersRow); + $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); + } + } + else { + $msg = array( + 'title' => "Admin Privileges Required", + 'message' => "You must have admin privileges in order to perform this action.", + 'type' => "error" + ); + $page->set_message_wrapper($msg); + } + $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); + + return($objResponse); +}//end regenerate_group_lists() ?> Modified: trunk/templates/content/settings/index.content.tmpl =================================================================== --- trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:13:44 UTC (rev 778) +++ trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:31:49 UTC (rev 779) @@ -120,6 +120,8 @@ </td> <td> + <div id="group_nonMembers"> + <!-- BEGIN group_nonMembers --> <table> <!-- BEGIN show_group_list__removeUser --> <tr> @@ -132,9 +134,13 @@ </tr> <!-- END show_group_list__noRemoveUser --> </table> + <!-- END group_nonMembers --> + </div> </td> <td> + <div id="group_currentMembers"> + <!-- BEGIN group_currentMembers --> <table> <!-- BEGIN show_group_list__selectUser --> <tr> @@ -147,6 +153,8 @@ </tr> <!-- END show_group_list__noUser --> </table> + <!-- END group_currentMembers --> + </div> </td> </tr> </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-04 23:13:59
|
Revision: 778 http://cs-project.svn.sourceforge.net/cs-project/?rev=778&view=rev Author: crazedsanity Date: 2008-02-04 15:13:44 -0800 (Mon, 04 Feb 2008) Log Message: ----------- AJAX stuff for adding/removing users to/from groups (doesn't update UI yet). Modified Paths: -------------- trunk/includes/content/settings.inc trunk/includes/content/shared.inc trunk/templates/content/settings/index.content.tmpl Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-04 23:12:12 UTC (rev 777) +++ trunk/includes/content/settings.inc 2008-02-04 23:13:44 UTC (rev 778) @@ -13,6 +13,14 @@ $prefObj = new pref($page->db, $_SESSION['uid']); $GLOBALS['objects']['pref'] = $prefObj; +if($user->is_admin() == 1) { + //add the template to show various admin stuff. + $page->add_template_var("admin_section", $page->templateRows['admin_section']); + + //create an object with administrative capabilities. + $adminUserClass = new adminUserClass($page->db); + $GLOBALS['objects']['admin'] = $adminUserClass; +} addAjax(); @@ -333,4 +341,45 @@ return($objResponse); }//end ajax__update_preference() + + + + +function ajax__group_user($groupId, $uid, $addRemove) { + $user = $GLOBALS['objects']['user']; + $page = $GLOBALS['objects']['page']; + $objResponse = new xajaxResponse(); + if($user->is_admin()) { + + $adminUserClass = $GLOBALS['objects']['admin']; + if($addRemove == 'add') { + $result = $adminUserClass->add_user_to_group($uid, $groupId); + } + else { + $result = $adminUserClass->remove_user_from_group($uid, $groupId); + } + + $msg = array( + 'title' => "Update Complete", + 'message' => "Result of <b>". $addRemove ."</b>: (". $result .")", + 'type' => "status" + ); + + + $page->set_message_wrapper($msg); + + //now regenerate the current users & the excluded users lists. + } + else { + $msg = array( + 'title' => "Admin Privileges Required", + 'message' => "You must have admin privileges in order to perform this action.", + 'type' => "error" + ); + $page->set_message_wrapper($msg); + } + $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); + + return($objResponse); +}//end ajax__group_add_user() ?> Modified: trunk/includes/content/shared.inc =================================================================== --- trunk/includes/content/shared.inc 2008-02-04 23:12:12 UTC (rev 777) +++ trunk/includes/content/shared.inc 2008-02-04 23:13:44 UTC (rev 778) @@ -17,6 +17,7 @@ $GLOBALS['objects']['page'] =& $page; $GLOBALS['objects']['proj'] =& $proj; $GLOBALS['objects']['tag'] =& $proj->tagObj; +$GLOBALS['objects']['user'] =& $user; /** Modified: trunk/templates/content/settings/index.content.tmpl =================================================================== --- trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:12:12 UTC (rev 777) +++ trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:13:44 UTC (rev 778) @@ -90,6 +90,8 @@ <hr> <h2><font color="red">Administrative Settings</font></h2> + +<a name="group"> <table border=1 cellpadding=3 cellspacing=0> <tr> <th colspan="3"><a href="#groupManagement"></a>Group Management</th> @@ -121,7 +123,7 @@ <table> <!-- BEGIN show_group_list__removeUser --> <tr> - <td>(<b><a href="?action=removeUser&groupId=%%group_id%%&uid=%%uid%%">Remove</a></b>) %%username%%</td> + <td>(<b><a href="javascript:void(xajax_ajax__group_user(%%group_id%%, %%uid%%, 'remove'));">Remove</a></b>) %%username%%</td> </tr> <!-- END show_group_list__removeUser --> <!-- BEGIN show_group_list__noRemoveUser --> @@ -136,7 +138,7 @@ <table> <!-- BEGIN show_group_list__selectUser --> <tr> - <td>(<b><a href="?action=addUser&groupId=%%group_id%%&uid=%%uid%%">Add</a></b>) %%username%%</td> + <td>(<b><a href="javascript:void(xajax_ajax__group_user(%%group_id%%, %%uid%%, 'add'));">Add</a></b>) %%username%%</td> </tr> <!-- END show_group_list__selectUser --> <!-- BEGIN show_group_list__noUser --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-04 23:12:46
|
Revision: 777 http://cs-project.svn.sourceforge.net/cs-project/?rev=777&view=rev Author: crazedsanity Date: 2008-02-04 15:12:12 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Fix problem with users being attached multiple times to same group (issue #143). /lib/adminUserClass.php: * add_user_to_group(): -- pulls users from that group; if user is already in the list, no insert is performed. Modified Paths: -------------- trunk/lib/adminUserClass.php Modified: trunk/lib/adminUserClass.php =================================================================== --- trunk/lib/adminUserClass.php 2008-02-04 21:34:56 UTC (rev 776) +++ trunk/lib/adminUserClass.php 2008-02-04 23:12:12 UTC (rev 777) @@ -213,29 +213,34 @@ //========================================================================= public function add_user_to_group($uid,$groupId) { - //add the user to a group. - $sqlArr = array( - 'uid' => $uid, - 'group_id' => $groupId - ); - $sql = "INSERT INTO user_group_table ". string_from_array($sqlArr, 'insert', NULL, 'number'); - if(!$this->run_sql($sql)) { - //indications are it failed. - if(strlen($this->lastError)) { - $this->logsObj->log_dberror(__METHOD__ .": failed to add user to group (". $groupId ."): ". $this->lastError); + $groupData = $this->get_group_user($groupId); + $retval = FALSE; + if(!isset($groupData[$uid])) { + //add the user to a group. + $sqlArr = array( + 'uid' => $uid, + 'group_id' => $groupId + ); + + $sql = "INSERT INTO user_group_table ". string_from_array($sqlArr, 'insert', NULL, 'number'); + if(!$this->run_sql($sql)) { + //indications are it failed. + if(strlen($this->lastError)) { + $this->logsObj->log_dberror(__METHOD__ .": failed to add user to group (". $groupId ."): ". $this->lastError); + } + $retval = FALSE; } - $retval = FALSE; + else { + //it worked! + $retval = TRUE; + + //log it! + $groupData = $this->get_groups(FALSE); + $details = "Added user to group #". $groupId ." (". $groupData[$groupId]['name'] .")"; + $this->logsObj->log_by_class($details, 'update', $uid); + } } - else { - //it worked! - $retval = TRUE; - - //log it! - $groupData = $this->get_groups(FALSE); - $details = "Added user to group #". $groupId ." (". $groupData[$groupId]['name'] .")"; - $this->logsObj->log_by_class($details, 'update', $uid); - } return($retval); }//end add_user_to_group() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-04 21:35:02
|
Revision: 776 http://cs-project.svn.sourceforge.net/cs-project/?rev=776&view=rev Author: crazedsanity Date: 2008-02-04 13:34:56 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Removed some unneeded comments & such. Modified Paths: -------------- trunk/includes/content/settings.inc Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-04 21:33:29 UTC (rev 775) +++ trunk/includes/content/settings.inc 2008-02-04 21:34:56 UTC (rev 776) @@ -304,10 +304,7 @@ $objResponse = new xajaxResponse(); $prefData = $prefObj->list_all_prefs(array('pref_type_id' => $prefId)); - #debug_print($prefData,1); - #exit; - //update the preference. $result = $prefObj->update_user_pref($prefId, $newValue); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-04 21:33:32
|
Revision: 775 http://cs-project.svn.sourceforge.net/cs-project/?rev=775&view=rev Author: crazedsanity Date: 2008-02-04 13:33:29 -0800 (Mon, 04 Feb 2008) Log Message: ----------- AJAX-ified preference updates. Modified Paths: -------------- trunk/includes/content/settings.inc trunk/templates/content/settings/index.content.tmpl Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-04 20:14:52 UTC (rev 774) +++ trunk/includes/content/settings.inc 2008-02-04 21:33:29 UTC (rev 775) @@ -10,6 +10,12 @@ * Last Updated: $Date$ */ + +$prefObj = new pref($page->db, $_SESSION['uid']); +$GLOBALS['objects']['pref'] = $prefObj; + +addAjax(); + require_once(dirname(__FILE__) .'/../../lib/adminUserClass.php'); require_once(dirname(__FILE__) .'/../../lib/prefClass.php'); @@ -100,31 +106,7 @@ $goHere = "/content/settings"; } break; - - - - case 'set_preference': { - $pref = new pref($page->db, $_SESSION['uid']); - $result = $pref->update_user_pref($_POST['prefTypeId'], $_POST['prefType'][$_POST['prefTypeId']]); - if($result == 1) { - $messageArr = array( - 'title' => "Preference Updated", - 'message' => "Your preference was successfully stored.", - 'type' => "status" - ); - } - else { - $messageArr = array( - 'title' => "Error Updating Preference", - 'message' => "There was an error while attempting to update your preference ($result).", - 'type' => "error" - ); - } - set_message_wrapper($messageArr); - } - break; - DEFAULT: } @@ -132,6 +114,7 @@ conditional_header($goHere); exit; } + exit; } elseif(isset($_GET['action'])) { @@ -169,7 +152,6 @@ //TODO: when they don't have the pref, select the default! //show 'em their preferences. - $prefObj = new pref($page->db, $_SESSION['uid']); $allPrefs = $prefObj->list_all_prefs(); $userPrefs = $prefObj->get_user_prefs(); @@ -314,4 +296,44 @@ } } } + + +function ajax__update_preference($prefId, $newValue) { + $page = $GLOBALS['objects']['page']; + $prefObj = $GLOBALS['objects']['pref']; + $objResponse = new xajaxResponse(); + + $prefData = $prefObj->list_all_prefs(array('pref_type_id' => $prefId)); + #debug_print($prefData,1); + #exit; + + + //update the preference. + $result = $prefObj->update_user_pref($prefId, $newValue); + + $properSelectedName = $prefData['optionList'][$newValue]['name']; + + if($result == 1) { + $messageArr = array( + 'title' => "Preference Updated", + 'message' => "Your preference for <b>". $prefData['display_name'] ."</b> was successfully " . + "stored (<i>". $properSelectedName ."</i>).", + 'type' => "status" + ); + } + else { + $messageArr = array( + 'title' => "Error Updating Preference", + 'message' => "There was an error while attempting to update your preference ($result).", + 'type' => "error" + ); + } + $page->set_message_wrapper($messageArr); + $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); + + $objResponse->addAssign('pref_currentSetting_'. $prefId, 'innerHTML', $properSelectedName); + + return($objResponse); + +}//end ajax__update_preference() ?> Modified: trunk/templates/content/settings/index.content.tmpl =================================================================== --- trunk/templates/content/settings/index.content.tmpl 2008-02-04 20:14:52 UTC (rev 774) +++ trunk/templates/content/settings/index.content.tmpl 2008-02-04 21:33:29 UTC (rev 775) @@ -63,13 +63,14 @@ <select name="prefType[%%pref_type_id%%]"> %%row_optionList%% <!-- BEGIN pref_optionList --> - <option %%selectedString%% value="%%value%%" onClick="document.prefTable.prefTypeId.value='%%pref_type_id%%';document.prefTable.submit();">%%display%% (%%effective_value%%)</option> + <option %%selectedString%% value="%%value%%" + onClick="xajax_ajax__update_preference(%%pref_type_id%%, %%value%%);">%%display%% (%%effective_value%%)</option> <!-- END pref_optionList --> </select> </td> <td style="background-color:%%rowColor%%"> - %%currentSetting%% + <div id="pref_currentSetting_%%pref_type_id%%">%%currentSetting%%</div> <div class="note">(Default value: %%default_value%%)</div> </td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-04 20:14:58
|
Revision: 774 http://cs-project.svn.sourceforge.net/cs-project/?rev=774&view=rev Author: crazedsanity Date: 2008-02-04 12:14:52 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Add hitstracker image to main page (eventually, it should show info about upgrading). Modified Paths: -------------- trunk/includes/login.inc trunk/templates/login.content.tmpl Modified: trunk/includes/login.inc =================================================================== --- trunk/includes/login.inc 2008-02-01 07:46:26 UTC (rev 773) +++ trunk/includes/login.inc 2008-02-04 20:14:52 UTC (rev 774) @@ -15,6 +15,8 @@ $db->connect(get_config_db_params()); $page->db = &$db; +$page->add_template_var('cs-project_version', VERSION_STRING); + if(isset($_GET['loginDestination']) && strlen($_GET['loginDestination'])) { $_SESSION['loginDestination'] = $_GET['loginDestination']; } Modified: trunk/templates/login.content.tmpl =================================================================== --- trunk/templates/login.content.tmpl 2008-02-01 07:46:26 UTC (rev 773) +++ trunk/templates/login.content.tmpl 2008-02-04 20:14:52 UTC (rev 774) @@ -57,6 +57,13 @@ </ul> </td> </tr> + + <tr> + <td align="center"> + <div>Brought to you by:</div> + <img src="http://www.crazedsanity.com/php-bin/hitsTracker.php?data=_version:{cs-project_version}/_name:{PROJ_NAME}/_image:isUpdateable" border="0"> + </td> + </tr> </table> </center> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-01 07:46:28
|
Revision: 773 http://cs-project.svn.sourceforge.net/cs-project/?rev=773&view=rev Author: crazedsanity Date: 2008-01-31 23:46:26 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Add todo's to helpdesk issues. AFFECTS ISSUE::: #14: Tasks for Helpdesk Issues /includes/content/helpdesk.inc: * use new function for parsing related todos, if available. /includes/content/project.inc: * use new function for parsing related todos, if available. * remove "todo" index from related items array. /includes/content/shared.inc: * parse_related_todo() [NEW]: -- copied from project.inc -- should be easy to port into something useful for ajax calls. /includes/content/todo.inc: * deal with retrieving helpdesk vs. project details. * NOTE: the array name is a bit misleading ($projectDetails) /lib/helpdeskClass.php: * get_todos() [NEW]: -- copied from projectClass::get_todos() -- used to retrieve related todo records. /templates/content/related_todo.shared.tmpl: * create link now contains module variable. /templates/content/helpdesk/view.content.tmpl: * section to display related_todo records. Modified Paths: -------------- trunk/includes/content/helpdesk.inc trunk/includes/content/project.inc trunk/includes/content/shared.inc trunk/includes/content/todo.inc trunk/lib/helpdeskClass.php trunk/templates/content/helpdesk/view.content.tmpl trunk/templates/content/related_todo.shared.tmpl Modified: trunk/includes/content/helpdesk.inc =================================================================== --- trunk/includes/content/helpdesk.inc 2008-02-01 05:43:12 UTC (rev 772) +++ trunk/includes/content/helpdesk.inc 2008-02-01 07:46:26 UTC (rev 773) @@ -349,8 +349,14 @@ //now, rip all block rows that don't need to be there... $page->set_all_block_rows("content", $doNotRipRows); + $todoData = $proj->helpdeskObj->get_todos($helpdeskId); + $page->set_all_block_rows('related_todo'); + if(is_array($todoData)) { + parse_related_todo($todoData); + } + $useTextTags = FALSE; if($helpdeskData['status_id'] == 4) { $useTextTags = TRUE; Modified: trunk/includes/content/project.inc =================================================================== --- trunk/includes/content/project.inc 2008-02-01 05:43:12 UTC (rev 772) +++ trunk/includes/content/project.inc 2008-02-01 07:46:26 UTC (rev 773) @@ -316,6 +316,12 @@ $page->add_template_var("helpdeskPrefWarning", $page->templateRows['helpdeskPrefWarning']); } + //SPECIAL PROCESSING FOR TODO's... + if(is_array($detailsArr['related']['todo'])) { + parse_related_todo($detailsArr['related']['todo']); + } + unset($detailsArr['related']['todo']); + //parse-in everything under "related"... foreach($detailsArr['related'] as $type => $subArr) { $rowName = "related_". $type ."_row"; Modified: trunk/includes/content/shared.inc =================================================================== --- trunk/includes/content/shared.inc 2008-02-01 05:43:12 UTC (rev 772) +++ trunk/includes/content/shared.inc 2008-02-01 07:46:26 UTC (rev 773) @@ -54,4 +54,89 @@ $page->add_template_var('XAJAX_HEADERS', $xajaxHeaders); }//end addAjax() +function parse_related_todo(array $parseData) { + $page = $GLOBALS['objects']['page']; + $bgColor = NULL; + $bgColor2 = NULL; + + $rowName = 'related_todo_row'; + $baseRow = $page->templateRows[$rowName]; + + foreach($parseData as $id=>$arr) { + swapValue($bgColor, "rgb(213, 213, 213)", "rgb(194, 194, 194)"); + swapValue($bgColor2, "#d5d5d5", "#c2c2c2"); + $repArr = array( + "id" => $id, + "bgColor" => $bgColor, + "bgColor2" => $bgColor2 + ); + $changeFontColor=TRUE; + //Making TODO stuff look purdy. Boy. + if(!preg_match('/accepted/', strtolower($arr['status_text']))) { + $repArr['bgColor'] = "e0e0e0"; + $repArr['bgColor2'] = "e0e0e0"; + } + + //Add dashes to fields that don't have any information in them. + if(strlen($arr['deadline']) <6) { + $changeFontColor = FALSE; + $arr['deadline'] = "————"; + } + if(strlen($arr['begin_date']) <6) { + $changeFontColor = FALSE; + $arr['begin_date'] = "————"; + } + if(strlen($arr['assigned_user']) == 0) { + //put some dashes in if nobody is assigned. + $arr['assigned_user'] = "——"; + } + + //cross-out all items that are ended. + if(preg_match('/ended/', strtolower($arr['status_text']))) { + $changeFontColor = FALSE; + $strikeThroughArr = array( + "creator", "creator", "assigned", "status_text", "remark", "begin_date", "deadline" + ); + foreach($strikeThroughArr as $myField) { + $arr[$myField] = '<del> '. $arr[$myField] .' </del>'; + } + unset($strikeThroughArr); + } + + if(strlen($arr['deadline']) && preg_match('/ended/', strtolower($arr['status_text']))) { + //make the deadline look nice. + $today = date("Ymd"); + $myDeadline = str_replace("-", "", $arr['deadline']); + settype($myDeadline, "int"); + settype($today, "int"); + + if(!$changeFontColor) { + //do nothing. + } + elseif($myDeadline <= $today) { + $arr['deadline'] = '<font color="red"><b>'. $arr['deadline'] .'</b></font>'; + } + else { + $arr['deadline'] = '<font color="green">'. $arr['deadline'] .'</font>'; + } + } + + if($arr['status_id'] == 2) { + $repArr['font_weight'] = "bold"; + } + else { + $repArr['font_weight'] = "normal"; + } + + //put every item in our array into the replacement array. + foreach($arr as $x=>$y) { + $repArr[$x] = $y; + } + $myRow .= mini_parser($baseRow, $repArr, "%%", "%%"); + } + $page->add_template_var($rowName, $myRow); +}//end parse_related_todo() + + + ?> Modified: trunk/includes/content/todo.inc =================================================================== --- trunk/includes/content/todo.inc 2008-02-01 05:43:12 UTC (rev 772) +++ trunk/includes/content/todo.inc 2008-02-01 07:46:26 UTC (rev 773) @@ -2,10 +2,10 @@ /* * SVN INFORMATION::: * ------------------ - * Last Author: $Author$ - * Current Revision: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated: $Date$ + * Last Author: $Author:crazedsanity $ + * Current Revision: $Revision:637 $ + * Repository Location: $HeadURL:https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/includes/content/todo.inc $ + * Last Updated: $Date:2007-11-20 11:04:33 -0600 (Tue, 20 Nov 2007) $ */ if($_POST) { @@ -110,7 +110,12 @@ } else { //get the details. - $projectDetails = $proj->get_details($_GET['parentPublicId']); + if($_GET['module'] == 'helpdesk') { + $projectDetails = $proj->helpdeskObj->get_record($_GET['parentPublicId']); + } + else { + $projectDetails = $proj->get_details($_GET['parentPublicId']); + } $page->add_template_var("record_id", $projectDetails['record_id']); } Modified: trunk/lib/helpdeskClass.php =================================================================== --- trunk/lib/helpdeskClass.php 2008-02-01 05:43:12 UTC (rev 772) +++ trunk/lib/helpdeskClass.php 2008-02-01 07:46:26 UTC (rev 773) @@ -455,5 +455,42 @@ //================================================================================================ + + //========================================================================= + function get_todos($helpdeskId) { + $retval = 0; + $prefObj = new pref($this->db, $_SESSION['uid']); + $todoDisplayPref = $prefObj->get_pref_value_by_name('projectDetails_todoDisplayOnlyMine'); + + $todoObj = new todoClass($this->db); + + //attempt to get a list of the todos... + //TODO: change this reference to "publicId" instead of "projectId" + $todoObj->projectId = $helpdeskId; + + + $critArr = array("record_id"=>$this->get_parent_from_ancestry($this->get_ancestry($helpdeskId,TRUE),0)); + $contactCrit = NULL; + if($todoDisplayPref != 'all') { + if($todoDisplayPref == 'mine') { + $contactCrit = array( + 't.creator_contact_id' => $_SESSION['contact_id'], + 't.assigned_contact_id' => $_SESSION['contact_id'] + ); + } + elseif($todoDisplayPref == 'assigned') { + $contactCrit = array( + 't.assigned_contact_id' => $_SESSION['contact_id'] + ); + } + } + $retval = $todoObj->get_todos($critArr, NULL, $contactCrit); + + return($retval); + + }//end get_todos() + //========================================================================= + + }//end helpdeskClass{} ?> \ No newline at end of file Modified: trunk/templates/content/helpdesk/view.content.tmpl =================================================================== --- trunk/templates/content/helpdesk/view.content.tmpl 2008-02-01 05:43:12 UTC (rev 772) +++ trunk/templates/content/helpdesk/view.content.tmpl 2008-02-01 07:46:26 UTC (rev 773) @@ -187,6 +187,13 @@ <td style="border-bottom:solid #000 1px;" width="650" colspan="2" nowrap><code>{subject}</code></td> </tr> <tr> + <th>Todos:</th> + + <td> + <div id="related_todo">{related_todo}</div> + </td> +</tr> +<tr> <th style="border-bottom:solid #000 1px;" align="right">Notes:<BR><font size="-3"><i>(Includes previous/current<BR>solution(s), if available)</i></font></th> <td style="border-bottom:solid #000 1px;" colspan="2"> <!-- BEGIN issueNotes --> Modified: trunk/templates/content/related_todo.shared.tmpl =================================================================== --- trunk/templates/content/related_todo.shared.tmpl 2008-02-01 05:43:12 UTC (rev 772) +++ trunk/templates/content/related_todo.shared.tmpl 2008-02-01 07:46:26 UTC (rev 773) @@ -1,6 +1,6 @@ <table cellpadding="2" cellspacing="0" border="1"> <tr> - <td colspan="8"><b>Todo: </b>(<a href='/content/todo/create?parentPublicId={public_id}' target=_top>Create</a>): + <td colspan="8"><b>Todo: </b>(<a href='/content/todo/create?parentPublicId={public_id}&module={module}' target=_top>Create</a>): <!-- BEGIN todoPrefWarning --> <BR><font color="red"><b>Warning:</b></font> Not all issues will be displayed, due to your <a href="/content/settings">preferences</a>. <!-- END todoPrefWarning --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-01 05:43:19
|
Revision: 772 http://cs-project.svn.sourceforge.net/cs-project/?rev=772&view=rev Author: crazedsanity Date: 2008-01-31 21:43:12 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Notes always show below todo list (no matter how many issues there are). Modified Paths: -------------- trunk/templates/content/project/view/index.content.tmpl Modified: trunk/templates/content/project/view/index.content.tmpl =================================================================== --- trunk/templates/content/project/view/index.content.tmpl 2008-02-01 05:29:53 UTC (rev 771) +++ trunk/templates/content/project/view/index.content.tmpl 2008-02-01 05:43:12 UTC (rev 772) @@ -1,4 +1,4 @@ -<table border="0" cellpadding="2" cellspacing="0"> +<table border="1" cellpadding="2" cellspacing="0"> <tr> <td><!-- first cell of main table --> <form action="{PHP_SELF}" method="POST" name=frm> @@ -118,17 +118,13 @@ </td> </tr> <tr> - <td> - {related_todo} + <td width="50%"> + <div id="related_todo" width="100%">{related_todo}</div> + <div id="related_note" style="padding-top:1em;">{related_note}</div> </td> - <td> - {related_issue} + <td width="50%"> + <div id="related_issue">{related_issue}</div> </td> </tr> - <tr> - <td colspan="2"> - {related_note} - </td> - </tr> </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-01 05:29:56
|
Revision: 771 http://cs-project.svn.sourceforge.net/cs-project/?rev=771&view=rev Author: crazedsanity Date: 2008-01-31 21:29:53 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Fix to allow note creation, remove some unneeded code. Modified Paths: -------------- trunk/includes/content/notes.inc trunk/templates/content/notes/view.content.tmpl Added Paths: ----------- trunk/templates/content/notes/create.content.tmpl Modified: trunk/includes/content/notes.inc =================================================================== --- trunk/includes/content/notes.inc 2008-02-01 05:15:24 UTC (rev 770) +++ trunk/includes/content/notes.inc 2008-02-01 05:29:53 UTC (rev 771) @@ -2,10 +2,10 @@ /* * SVN INFORMATION::: * ------------------ - * Last Author: $Author$ - * Current Revision: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated: $Date$ + * Last Author: $Author:crazedsanity $ + * Current Revision: $Revision:637 $ + * Repository Location: $HeadURL:https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/includes/content/notes.inc $ + * Last Updated: $Date:2007-11-20 11:04:33 -0600 (Tue, 20 Nov 2007) $ */ if($_POST) { @@ -105,7 +105,6 @@ exit; } else { - $page->rip_all_block_rows('content', array('owner_options')); $projectData = $proj->get_details($projectId, FALSE); if(is_array($projectData)) { Copied: trunk/templates/content/notes/create.content.tmpl (from rev 765, trunk/templates/content/notes/view.content.tmpl) =================================================================== --- trunk/templates/content/notes/create.content.tmpl (rev 0) +++ trunk/templates/content/notes/create.content.tmpl 2008-02-01 05:29:53 UTC (rev 771) @@ -0,0 +1,35 @@ +<form action='' method='POST'> +<input type="hidden" name="note_id" value={note_id}> +<input type="hidden" name="module" value="notes"> + +<table border=0 cellpadding=0 cellspacing=0><tr><td> +<table border=0 bgcolor=#D5D5D5> +<tr> + <td><a href="javascript:void();"><b>Notes</b></a></td> + +<tr> + <td></td> +</tr> +<tr> + <td colspan=2>Title:<input type='text' name='updates[subject]' size='92' value="{note_subject}" {note_name_readonly}></td> +</tr> +<tr> + <td> + <textarea rows=20 cols=95 name="updates[body]" wrap=physical>{note_body}</textarea> + </td> +<tr> +</table> + +<table align="center"> +<tr> + <td align="center"> + <input type="HIDDEN" name="updates[record_id]" value="{record_id}"> + <input type="submit" name="{submit_name}" value="{submit_value}"> + </td> +</tr> +<tr> + <td align="center"><a href='{goBackLink}'><b>GO BACK</b></a></td> +</tr> +</table> + +</td></tr></table> Modified: trunk/templates/content/notes/view.content.tmpl =================================================================== --- trunk/templates/content/notes/view.content.tmpl 2008-02-01 05:15:24 UTC (rev 770) +++ trunk/templates/content/notes/view.content.tmpl 2008-02-01 05:29:53 UTC (rev 771) @@ -2,44 +2,20 @@ <input type="hidden" name="note_id" value={note_id}> <input type="hidden" name="module" value="notes"> -<table border=0 cellpadding=0 cellspacing=0><tr><td> -<table border=0 bgcolor=#D5D5D5> +<table border=0 bgcolor=#D5D5D5 width="50%"> <tr> <td><a href="javascript:void();"><b>Notes</b></a></td> <tr> <td></td> </tr> -<!-- BEGIN nonowner_options --> <tr> <td style="border-bottom:solid #000 1px;">Title: <b>{note_subject}</b></td> </tr> <tr> - <td><div>{note_body}</div></td> + <td style="border-bottom:solid #000 1px;"><div>{note_body}</div></td> </tr> -<!-- END nonowner_options --> -<!-- BEGIN owner_options --> <tr> - <td colspan=2>Title:<input type='text' name='updates[subject]' size='92' value="{note_subject}" {note_name_readonly}></td> -</tr> -<tr> - <td> - <textarea rows=20 cols=95 name="updates[body]" wrap=physical>{note_body}</textarea> - </td> -<tr> -</table> - -<table align="center"> -<tr> - <td align="center"> - <input type="HIDDEN" name="updates[record_id]" value="{record_id}"> - <input type="submit" name="{submit_name}" value="{submit_value}"> - </td> -</tr> -<!-- END owner_options --> -<tr> <td align="center"><a href='{goBackLink}'><b>GO BACK</b></a></td> </tr> </table> - -</td></tr></table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-01 05:15:26
|
Revision: 770 http://cs-project.svn.sourceforge.net/cs-project/?rev=770&view=rev Author: crazedsanity Date: 2008-01-31 21:15:24 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Move related todo template into a more accessible location (project view still works). Added Paths: ----------- trunk/templates/content/related_todo.shared.tmpl Removed Paths: ------------- trunk/templates/content/project/view/related_todo.content.tmpl Deleted: trunk/templates/content/project/view/related_todo.content.tmpl =================================================================== --- trunk/templates/content/project/view/related_todo.content.tmpl 2008-02-01 05:03:03 UTC (rev 769) +++ trunk/templates/content/project/view/related_todo.content.tmpl 2008-02-01 05:15:24 UTC (rev 770) @@ -1,36 +0,0 @@ -<table cellpadding="2" cellspacing="0" border="1"> -<tr> - <td colspan="8"><b>Todo: </b>(<a href='/content/todo/create?parentPublicId={public_id}' target=_top>Create</a>): -<!-- BEGIN todoPrefWarning --> - <BR><font color="red"><b>Warning:</b></font> Not all issues will be displayed, due to your <a href="/content/settings">preferences</a>. -<!-- END todoPrefWarning --> - <hr> - <b>NOTE: </b>In the "Hours Left" column of todos, the format is::: <i>remaining hours (current estimate)</i></td> -</tr> -<tr> - <th>Pri</th> - <th>Creator</th> - <th>Assigned</th> - <th>%</th> - <th>Status</th> - <th>Title</th> - <th>Deadline</th> - <th>Hours Left</th> -</tr> - -<!-- BEGIN related_todo_row --> -<tr style="background-color: %%bgColor%%;" onmouseover="this.style.backgroundColor = '#ffffff'" - onmouseout="this.style.backgroundColor = '%%bgColor2%%'" onclick="location.href = '/content/todo/view?ID=%%id%%'"> - <td><font style="font-weight:%%font_weight%%;">%%priority%%</font></td> - <td><font style="font-weight:%%font_weight%%;">%%creator%%</font></td> - <td><font style="font-weight:%%font_weight%%;">%%assigned_user%%</font></td> - <td align="right"><font style="font-weight:%%font_weight%%;">%%progress%%%</font></td> - <td nowrap align="center">(%%status_text%%)</td> - <td><a href="/content/todo/view?ID=%%id%%" target="_top" style="font-weight:%%font_weight%%;"> - %%name%%</a></td> - <td>%%deadline%%</td> - <td><b>%%hours_remaining%%</b> (%%estimate_current%%) </td> - -</tr> -<!-- END related_todo_row --> -</table> \ No newline at end of file Copied: trunk/templates/content/related_todo.shared.tmpl (from rev 765, trunk/templates/content/project/view/related_todo.content.tmpl) =================================================================== --- trunk/templates/content/related_todo.shared.tmpl (rev 0) +++ trunk/templates/content/related_todo.shared.tmpl 2008-02-01 05:15:24 UTC (rev 770) @@ -0,0 +1,36 @@ +<table cellpadding="2" cellspacing="0" border="1"> +<tr> + <td colspan="8"><b>Todo: </b>(<a href='/content/todo/create?parentPublicId={public_id}' target=_top>Create</a>): +<!-- BEGIN todoPrefWarning --> + <BR><font color="red"><b>Warning:</b></font> Not all issues will be displayed, due to your <a href="/content/settings">preferences</a>. +<!-- END todoPrefWarning --> + <hr> + <b>NOTE: </b>In the "Hours Left" column of todos, the format is::: <i>remaining hours (current estimate)</i></td> +</tr> +<tr> + <th>Pri</th> + <th>Creator</th> + <th>Assigned</th> + <th>%</th> + <th>Status</th> + <th>Title</th> + <th>Deadline</th> + <th>Hours Left</th> +</tr> + +<!-- BEGIN related_todo_row --> +<tr style="background-color: %%bgColor%%;" onmouseover="this.style.backgroundColor = '#ffffff'" + onmouseout="this.style.backgroundColor = '%%bgColor2%%'" onclick="location.href = '/content/todo/view?ID=%%id%%'"> + <td><font style="font-weight:%%font_weight%%;">%%priority%%</font></td> + <td><font style="font-weight:%%font_weight%%;">%%creator%%</font></td> + <td><font style="font-weight:%%font_weight%%;">%%assigned_user%%</font></td> + <td align="right"><font style="font-weight:%%font_weight%%;">%%progress%%%</font></td> + <td nowrap align="center">(%%status_text%%)</td> + <td><a href="/content/todo/view?ID=%%id%%" target="_top" style="font-weight:%%font_weight%%;"> + %%name%%</a></td> + <td>%%deadline%%</td> + <td><b>%%hours_remaining%%</b> (%%estimate_current%%) </td> + +</tr> +<!-- END related_todo_row --> +</table> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-01 05:03:10
|
Revision: 769 http://cs-project.svn.sourceforge.net/cs-project/?rev=769&view=rev Author: crazedsanity Date: 2008-01-31 21:03:03 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Display bottom border of access block on helpdesk even after it is closed. Modified Paths: -------------- trunk/templates/content/helpdesk/view.content.tmpl Modified: trunk/templates/content/helpdesk/view.content.tmpl =================================================================== --- trunk/templates/content/helpdesk/view.content.tmpl 2008-02-01 04:55:51 UTC (rev 768) +++ trunk/templates/content/helpdesk/view.content.tmpl 2008-02-01 05:03:03 UTC (rev 769) @@ -79,11 +79,15 @@ <!-- END linkToIssue --> <!-- BEGIN accessBlock__modifyButton --> <tr> - <td align="center" colspan="2" style="border-left:solid #000 1px;border-right:solid #000 1px;border-bottom:solid #000 1px;"> + <td align="center" colspan="2" style="border-left:solid #000 1px;border-right:solid #000 1px;"> <input id="accessBlock__modifyButton" type="submit" name="action" value="Modify"> </td> </tr> <!-- END accessBlock__modifyButton --> + <tr> + <td colspan="2" style="border:solid #000 1px;border-top:none;"> + <img src="/images/clear.gif" height="1px"></td> + </tr> </table> <!-- END access_block --> <!-- BEGIN associatedUserBlock --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-02-01 04:55:54
|
Revision: 768 http://cs-project.svn.sourceforge.net/cs-project/?rev=768&view=rev Author: crazedsanity Date: 2008-01-31 20:55:51 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Protect setup system from potential evil-doers. AFFECTS ISSUE::: #34: Protect Setup System Modified Paths: -------------- trunk/includes/setup.inc Modified: trunk/includes/setup.inc =================================================================== --- trunk/includes/setup.inc 2008-01-31 23:19:33 UTC (rev 767) +++ trunk/includes/setup.inc 2008-02-01 04:55:51 UTC (rev 768) @@ -4,10 +4,10 @@ * * SVN INFORMATION::: * ------------------ - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ + * Last Author::::::::: $Author:crazedsanity $ + * Current Revision:::: $Revision:638 $ + * Repository Location: $HeadURL:https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/includes/setup.inc $ + * Last Updated:::::::: $Date:2007-11-20 11:04:59 -0600 (Tue, 20 Nov 2007) $ * * TODO: check for the existence of the /lib/config.xml file * TODO: if the config.xml exists, check if the database connection works, and if we can get ANY version data: if so, give fatal message saying it won't work. @@ -19,104 +19,120 @@ require_once(dirname(__FILE__) .'/../lib/simpletest/unit_tester.php'); require_once(dirname(__FILE__) .'/../lib/simpletest/reporter.php'); -if(!is_numeric($_SESSION['setup']['lastStep'])) { - $_SESSION['setup']['lastStep'] = 1; +$configData = read_config_file(FALSE); + +if(strlen($configData['DATABASE__DBNAME'])) { + //setup already complete. Stop 'em. + $page->set_message_wrapper(array( + 'title' => "Setup Unavailable", + 'message' => "It appears that CS-Project has already been installed. Please use " . + "the administrative section of the <a href=\"/content/settings\">Settings " . + "Tab</a> to make changes to your configuration (<i><b>NOTE:</b> you must be " . + "an admin to be able to see administrative options</i>).", + 'type' => "error" + )); + $page->conditional_header('/login.php'); } - -$stepNames = array( - 1 => "Database Information", - 2 => "Create Database + Build Schema", - 3 => "Create Default Values", - 4 => "Get Extra Information", - 5 => "Write Config File + Tests" -); - -//do some checking to make sure they're not doing something we don't want them to. -if(count($sectionArr) > 2 || ((count($sectionArr)) == 2 && !is_numeric($sectionArr[1]))) { - //too many things in the URL. - $page->set_message_wrapper( - array( - 'title' => "Invalid URL", - 'message' => "The page you were trying to go view was invalid.", - 'type' => "error" - ) +else { + //setup hasn't run; we're good. + if(!is_numeric($_SESSION['setup']['lastStep'])) { + $_SESSION['setup']['lastStep'] = 1; + } + + $stepNames = array( + 1 => "Database Information", + 2 => "Create Database + Build Schema", + 3 => "Create Default Values", + 4 => "Get Extra Information", + 5 => "Write Config File + Tests" ); - $page->conditional_header("/setup/". $_SESSION['setup']['lastStep'], TRUE); -} -elseif(count($sectionArr) == 2 && is_numeric($sectionArr[1]) && $sectionArr[1] != 1) { - if(!is_numeric(get_setup_data($sectionArr[1], 'accessible'))) { + + //do some checking to make sure they're not doing something we don't want them to. + if(count($sectionArr) > 2 || ((count($sectionArr)) == 2 && !is_numeric($sectionArr[1]))) { + //too many things in the URL. $page->set_message_wrapper( array( - 'title' => "Incomplete Step", - 'message' => "Tried to go to a step that wasn't complete... ", + 'title' => "Invalid URL", + 'message' => "The page you were trying to go view was invalid.", 'type' => "error" ) ); $page->conditional_header("/setup/". $_SESSION['setup']['lastStep'], TRUE); } -} - - -$page->add_template_var("VERSION_STRING", read_version_file()); -$page->rip_all_block_rows('stepData'); -$page->clear_content('infobar'); - - -//determine the current step based on the URL ($sectionArr is provided by contentSystem). -$currentStep = $sectionArr[1]; - - -$tmplStepTitle = "Main Setup Screen"; -foreach($stepNames as $num=>$name) { - $stepResult = get_setup_data($num, 'result'); - if(!is_numeric($stepResult)) { - $passFail = "Incomplete"; - $bgColor = "yellow"; - if(strlen(get_setup_data($num, 'text'))) { - $stepText = get_setup_data($num, 'text'); + elseif(count($sectionArr) == 2 && is_numeric($sectionArr[1]) && $sectionArr[1] != 1) { + if(!is_numeric(get_setup_data($sectionArr[1], 'accessible'))) { + $page->set_message_wrapper( + array( + 'title' => "Incomplete Step", + 'message' => "Tried to go to a step that wasn't complete... ", + 'type' => "error" + ) + ); + $page->conditional_header("/setup/". $_SESSION['setup']['lastStep'], TRUE); } - else { - $stepText = "Step incomplete..."; - } } - else { - $passFail = interpret_bool($stepResult, array('FAIL', 'Pass')); - $bgColor = interpret_bool($stepResult, array('red', 'green')); - - if(strlen(get_setup_data($num, 'text'))) { - $stepText = get_setup_data($num, 'text'); + + + $page->add_template_var("VERSION_STRING", read_version_file()); + $page->rip_all_block_rows('stepData'); + $page->clear_content('infobar'); + + + //determine the current step based on the URL ($sectionArr is provided by contentSystem). + $currentStep = $sectionArr[1]; + + + $tmplStepTitle = "Main Setup Screen"; + foreach($stepNames as $num=>$name) { + $stepResult = get_setup_data($num, 'result'); + if(!is_numeric($stepResult)) { + $passFail = "Incomplete"; + $bgColor = "yellow"; + if(strlen(get_setup_data($num, 'text'))) { + $stepText = get_setup_data($num, 'text'); + } + else { + $stepText = "Step incomplete..."; + } } else { - $stepText = " "; + $passFail = interpret_bool($stepResult, array('FAIL', 'Pass')); + $bgColor = interpret_bool($stepResult, array('red', 'green')); + + if(strlen(get_setup_data($num, 'text'))) { + $stepText = get_setup_data($num, 'text'); + } + else { + $stepText = " "; + } + + store_setup_data($num, 1, 'accessible'); + if($passFail == 'Pass') { + $_SESSION['setup']['lastStep'] = $num; + } } - - store_setup_data($num, 1, 'accessible'); - if($passFail == 'Pass') { - $_SESSION['setup']['lastStep'] = $num; + $curStepL = " "; + $curStepR = " "; + if($currentStep == $num) { + $curStepL = ">"; + $curStepR = "<"; + $tmplStepTitle = "Step #". $num .": ". $name; } + $repArr = array( + 'stepNum' => $num, + 'stepName' => $name, + 'passFail' => $passFail, + 'stepBGColor' => $bgColor, + 'stepText' => $stepText, + 'isCurStepL' => $curStepL, + 'isCurStepR' => $curStepR + ); + $myRows .= $page->gfObj->mini_parser($page->templateRows['step_data_row'], $repArr, '%%', '%%'); } - $curStepL = " "; - $curStepR = " "; - if($currentStep == $num) { - $curStepL = ">"; - $curStepR = "<"; - $tmplStepTitle = "Step #". $num .": ". $name; - } - $repArr = array( - 'stepNum' => $num, - 'stepName' => $name, - 'passFail' => $passFail, - 'stepBGColor' => $bgColor, - 'stepText' => $stepText, - 'isCurStepL' => $curStepL, - 'isCurStepR' => $curStepR - ); - $myRows .= $page->gfObj->mini_parser($page->templateRows['step_data_row'], $repArr, '%%', '%%'); + $page->add_template_var('stepTitle', $tmplStepTitle); + $page->add_template_var('step_data_row', $myRows); } -$page->add_template_var('stepTitle', $tmplStepTitle); -$page->add_template_var('step_data_row', $myRows); - //============================================================================= function store_setup_data($step, $data, $type='data') { $_SESSION['setup'][$type][$step] = $data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2008-01-31 23:19:35
|
Revision: 767 http://cs-project.svn.sourceforge.net/cs-project/?rev=767&view=rev Author: crazedsanity Date: 2008-01-31 15:19:33 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Fix display of child projects (all links now stay to the right of "Child Projects:"). Modified Paths: -------------- trunk/templates/content/project/view/index.content.tmpl Modified: trunk/templates/content/project/view/index.content.tmpl =================================================================== --- trunk/templates/content/project/view/index.content.tmpl 2008-01-31 22:50:11 UTC (rev 766) +++ trunk/templates/content/project/view/index.content.tmpl 2008-01-31 23:19:33 UTC (rev 767) @@ -98,10 +98,15 @@ </td> </tr> <tr> - <td align="left" style="border-top:solid #000 1px;border-bottom:solid #000 1px;padding-right:0px;"> - <div style="height:40px;overflow:auto;background-color:#fff;"> - <b>Child Projects:</b> <div style="display:inline;width:100%; height:{children_string_height}px; overflow:auto;">{children_string}</div> - </div> + <td align="left" style="border-top:solid #000 1px;border-bottom:solid #000 1px;"> + <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"> + <tr> + <td style="overflow:auto;background-color:#fff;padding-right:3px;" width="10%" nowrap> + <b>Child Projects:</b></td> + <td><div style="overflow:auto;background-color:#fff;overflow:auto;"> + {children_string}</div></td> + </tr> + </table> </td> <td align="center" style="border-top:solid #000 1px;border-bottom:solid #000 1px;padding-left:0px;"> <!-- BEGIN modify_button --><input type="submit" value="{submit_name}"><BR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |