CODE STYLE class.sessions.php
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* class.Sessions.php
|
* class.Sessions.php
|
||||||
|
*
|
||||||
* @package workflow.engine.ProcessMaker
|
* @package workflow.engine.ProcessMaker
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -24,14 +25,17 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require_once 'classes/model/Session.php';
|
require_once 'classes/model/Session.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sessions - Sessions class
|
* Sessions - Sessions class
|
||||||
|
*
|
||||||
* @package workflow.engine.ProcessMaker
|
* @package workflow.engine.ProcessMaker
|
||||||
* @author Everth S. Berrios Morales
|
* @author Everth S. Berrios Morales
|
||||||
* @copyright 2008 COLOSA
|
* @copyright 2008 COLOSA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Sessions {
|
class Sessions
|
||||||
|
{
|
||||||
|
|
||||||
protected $tmpfile;
|
protected $tmpfile;
|
||||||
private $sessionId;
|
private $sessionId;
|
||||||
@@ -39,10 +43,12 @@ class Sessions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is the constructor of the Sessions class
|
* This function is the constructor of the Sessions class
|
||||||
|
*
|
||||||
* @param string $sSessionId
|
* @param string $sSessionId
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($sSessionId=NULL){
|
public function __construct ($sSessionId = NULL)
|
||||||
|
{
|
||||||
$this->sessionId = $sSessionId;
|
$this->sessionId = $sSessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,34 +61,32 @@ class Sessions {
|
|||||||
* @param string sSessionId
|
* @param string sSessionId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getSessionUser($sSessionId=NULL)
|
public function getSessionUser ($sSessionId = NULL)
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
if ($sSessionId != NULL) {
|
||||||
if($sSessionId != NULL){
|
|
||||||
$this->sessionId = $sSessionId;
|
$this->sessionId = $sSessionId;
|
||||||
} else if($this->sessionId == NULL){
|
} else if ($this->sessionId == NULL) {
|
||||||
throw new Exception('session id was not set.');
|
throw new Exception( 'session id was not set.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria( 'workflow' );
|
||||||
$oCriteria->addSelectColumn(SessionPeer::USR_UID);
|
$oCriteria->addSelectColumn( SessionPeer::USR_UID );
|
||||||
$oCriteria->addSelectColumn(SessionPeer::SES_STATUS);
|
$oCriteria->addSelectColumn( SessionPeer::SES_STATUS );
|
||||||
$oCriteria->addSelectColumn(SessionPeer::SES_DUE_DATE);
|
$oCriteria->addSelectColumn( SessionPeer::SES_DUE_DATE );
|
||||||
$oCriteria->add(SessionPeer::SES_UID, $this->sessionId);
|
$oCriteria->add( SessionPeer::SES_UID, $this->sessionId );
|
||||||
|
|
||||||
$oDataset = SessionPeer::doSelectRS($oCriteria);
|
$oDataset = SessionPeer::doSelectRS( $oCriteria );
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
$aRow = $oDataset->getRow();
|
$aRow = $oDataset->getRow();
|
||||||
|
|
||||||
if( !is_array($aRow) ){
|
if (! is_array( $aRow )) {
|
||||||
$this->deleteTmpfile();
|
$this->deleteTmpfile();
|
||||||
}
|
}
|
||||||
return $aRow;
|
return $aRow;
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
throw ($oError);
|
||||||
throw($oError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,38 +99,36 @@ class Sessions {
|
|||||||
* @param string sSessionId
|
* @param string sSessionId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function verifySession($sSessionId=NULL)
|
public function verifySession ($sSessionId = NULL)
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
if ($sSessionId != NULL) {
|
||||||
if($sSessionId != NULL){
|
|
||||||
$this->sessionId = $sSessionId;
|
$this->sessionId = $sSessionId;
|
||||||
} else if($this->sessionId == NULL){
|
} else if ($this->sessionId == NULL) {
|
||||||
throw new Exception('session id was not set.');
|
throw new Exception( 'session id was not set.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$date=date('Y-m-d H:i:s');
|
$date = date( 'Y-m-d H:i:s' );
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria( 'workflow' );
|
||||||
$oCriteria->addSelectColumn(SessionPeer::USR_UID);
|
$oCriteria->addSelectColumn( SessionPeer::USR_UID );
|
||||||
$oCriteria->addSelectColumn(SessionPeer::SES_STATUS);
|
$oCriteria->addSelectColumn( SessionPeer::SES_STATUS );
|
||||||
$oCriteria->addSelectColumn(SessionPeer::SES_DUE_DATE);
|
$oCriteria->addSelectColumn( SessionPeer::SES_DUE_DATE );
|
||||||
$oCriteria->add(SessionPeer::SES_UID, $this->sessionId);
|
$oCriteria->add( SessionPeer::SES_UID, $this->sessionId );
|
||||||
$oCriteria->add(SessionPeer::SES_STATUS, 'ACTIVE');
|
$oCriteria->add( SessionPeer::SES_STATUS, 'ACTIVE' );
|
||||||
$oCriteria->add(SessionPeer::SES_DUE_DATE, $date, Criteria::GREATER_EQUAL);
|
$oCriteria->add( SessionPeer::SES_DUE_DATE, $date, Criteria::GREATER_EQUAL );
|
||||||
|
|
||||||
$oDataset = SessionPeer::doSelectRS($oCriteria);
|
$oDataset = SessionPeer::doSelectRS( $oCriteria );
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
$aRow = $oDataset->getRow();
|
$aRow = $oDataset->getRow();
|
||||||
|
|
||||||
if( !is_array($aRow) ){
|
if (! is_array( $aRow )) {
|
||||||
$this->deleteTmpfile();
|
$this->deleteTmpfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $aRow;
|
return $aRow;
|
||||||
}
|
} catch (Exception $oError) {
|
||||||
catch (Exception $oError) {
|
throw ($oError);
|
||||||
throw($oError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,32 +142,32 @@ class Sessions {
|
|||||||
* @param string $value
|
* @param string $value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function registerGlobal($name, $value)
|
public function registerGlobal ($name, $value)
|
||||||
{
|
{
|
||||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||||
|
|
||||||
if($this->sessionId == NULL){
|
if ($this->sessionId == NULL) {
|
||||||
throw new Exception('session id was not set.');
|
throw new Exception( 'session id was not set.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpfile_content = '';
|
$tmpfile_content = '';
|
||||||
if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
|
if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
|
||||||
$tmpfile_content = file_get_contents($this->tmpfile);
|
$tmpfile_content = file_get_contents( $this->tmpfile );
|
||||||
}
|
}
|
||||||
|
|
||||||
//getting the global array
|
//getting the global array
|
||||||
if( $tmpfile_content != ''){
|
if ($tmpfile_content != '') {
|
||||||
$this->globals = unserialize($tmpfile_content);
|
$this->globals = unserialize( $tmpfile_content );
|
||||||
} else {
|
} else {
|
||||||
$this->globals = Array();
|
$this->globals = Array ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//registering the new global variable
|
//registering the new global variable
|
||||||
$this->globals[$name] = $value;
|
$this->globals[$name] = $value;
|
||||||
|
|
||||||
//saving the global array
|
//saving the global array
|
||||||
$tmpfile_content = serialize($this->globals);
|
$tmpfile_content = serialize( $this->globals );
|
||||||
file_put_contents($this->tmpfile, $tmpfile_content);
|
file_put_contents( $this->tmpfile, $tmpfile_content );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,28 +180,28 @@ class Sessions {
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getGlobal($name)
|
public function getGlobal ($name)
|
||||||
{
|
{
|
||||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||||
|
|
||||||
if($this->sessionId == NULL){
|
if ($this->sessionId == NULL) {
|
||||||
throw new Exception('session id was not set.');
|
throw new Exception( 'session id was not set.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpfile_content = '';
|
$tmpfile_content = '';
|
||||||
if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
|
if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
|
||||||
$tmpfile_content = file_get_contents($this->tmpfile);
|
$tmpfile_content = file_get_contents( $this->tmpfile );
|
||||||
}
|
}
|
||||||
|
|
||||||
//getting the global array
|
//getting the global array
|
||||||
if( $tmpfile_content != ''){
|
if ($tmpfile_content != '') {
|
||||||
$this->globals = unserialize($tmpfile_content);
|
$this->globals = unserialize( $tmpfile_content );
|
||||||
} else {
|
} else {
|
||||||
$this->globals = Array();
|
$this->globals = Array ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//getting the new global variable
|
//getting the new global variable
|
||||||
if( isset($this->globals[$name]) ){
|
if (isset( $this->globals[$name] )) {
|
||||||
return $this->globals[$name];
|
return $this->globals[$name];
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
@@ -215,24 +217,24 @@ class Sessions {
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getGlobals()
|
public function getGlobals ()
|
||||||
{
|
{
|
||||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||||
|
|
||||||
if($this->sessionId == NULL){
|
if ($this->sessionId == NULL) {
|
||||||
throw new Exception('session id was not set.');
|
throw new Exception( 'session id was not set.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpfile_content = '';
|
$tmpfile_content = '';
|
||||||
if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
|
if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
|
||||||
$tmpfile_content = file_get_contents($this->tmpfile);
|
$tmpfile_content = file_get_contents( $this->tmpfile );
|
||||||
}
|
}
|
||||||
|
|
||||||
//getting the global array
|
//getting the global array
|
||||||
if( $tmpfile_content != ''){
|
if ($tmpfile_content != '') {
|
||||||
$this->globals = unserialize($tmpfile_content);
|
$this->globals = unserialize( $tmpfile_content );
|
||||||
} else {
|
} else {
|
||||||
$this->globals = Array();
|
$this->globals = Array ();
|
||||||
}
|
}
|
||||||
return $this->globals;
|
return $this->globals;
|
||||||
}
|
}
|
||||||
@@ -246,12 +248,13 @@ class Sessions {
|
|||||||
* param
|
* param
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function deleteTmpfile(){
|
private function deleteTmpfile ()
|
||||||
if($this->sessionId == NULL){
|
{
|
||||||
throw new Exception('session id was not set.');
|
if ($this->sessionId == NULL) {
|
||||||
|
throw new Exception( 'session id was not set.' );
|
||||||
}
|
}
|
||||||
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
$this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
|
||||||
@unlink($this->tmpfile);
|
@unlink( $this->tmpfile );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user