BUG 000 Add validation in the include of the plugin class

This commit is contained in:
Julio Cesar Laura
2011-10-10 13:25:59 -04:00
parent 0567feda00
commit 34cfa3aadf
2 changed files with 107 additions and 104 deletions

View File

@@ -309,7 +309,7 @@ class PMPluginRegistry {
if ( $detail->sNamespace == $sNamespace ) if ( $detail->sNamespace == $sNamespace )
unset ( $this->_aTaskExtendedProperties[ $key ] ); unset ( $this->_aTaskExtendedProperties[ $key ] );
} }
//unregistering javascripts from this plugin //unregistering javascripts from this plugin
$this->unregisterJavascripts($sNamespace); $this->unregisterJavascripts($sNamespace);
} }
@@ -339,16 +339,16 @@ class PMPluginRegistry {
function installPluginArchive($filename, $pluginName = NULL) { function installPluginArchive($filename, $pluginName = NULL) {
G::LoadThirdParty( 'pear/Archive','Tar'); G::LoadThirdParty( 'pear/Archive','Tar');
$tar = new Archive_Tar ($filename); $tar = new Archive_Tar ($filename);
$files = $tar->listContent(); $files = $tar->listContent();
$plugins = array(); $plugins = array();
foreach ($files as $f) { foreach ($files as $f) {
if (preg_match("/^([\w\.]*).ini$/", $f['filename'], $matches)) { if (preg_match("/^([\w\.]*).ini$/", $f['filename'], $matches)) {
$plugins[] = $matches[1]; $plugins[] = $matches[1];
} }
} }
if (count($plugins) > 1) if (count($plugins) > 1)
throw new Exception("Multiple plugins in one archive are not supported currently"); throw new Exception("Multiple plugins in one archive are not supported currently");
@@ -358,7 +358,7 @@ class PMPluginRegistry {
$pluginName = $plugins[0]; $pluginName = $plugins[0];
$pluginFile = "$pluginName.php"; $pluginFile = "$pluginName.php";
$oldPluginStatus = $this->getStatusPlugin($pluginFile); $oldPluginStatus = $this->getStatusPlugin($pluginFile);
if ($pluginStatus != 0) { if ($pluginStatus != 0) {
$oldDetails = $this->getPluginDetails($pluginFile); $oldDetails = $this->getPluginDetails($pluginFile);
$oldVersion = $oldDetails->iVersion; $oldVersion = $oldDetails->iVersion;
@@ -369,7 +369,7 @@ class PMPluginRegistry {
$pluginIni = $tar->extractInString("$pluginName.ini"); $pluginIni = $tar->extractInString("$pluginName.ini");
$pluginConfig = parse_ini_string($pluginIni); $pluginConfig = parse_ini_string($pluginIni);
/*if (!empty($oClass->aDependences)) { /*if (!empty($oClass->aDependences)) {
foreach ($oClass->aDependences as $aDependence) { foreach ($oClass->aDependences as $aDependence) {
if (file_exists(PATH_PLUGINS . $aDependence['sClassName'] . '.php')) { if (file_exists(PATH_PLUGINS . $aDependence['sClassName'] . '.php')) {
@@ -402,7 +402,7 @@ class PMPluginRegistry {
$this->save(); $this->save();
} }
function uninstallPlugin($sNamespace) { function uninstallPlugin($sNamespace) {
$this->enablePlugin($sNamespace); $this->enablePlugin($sNamespace);
$this->disablePlugin($sNamespace); $this->disablePlugin($sNamespace);
@@ -420,7 +420,7 @@ class PMPluginRegistry {
} }
} }
} }
/** /**
* install the plugin * install the plugin
* *
@@ -556,7 +556,7 @@ class PMPluginRegistry {
if ($sCoreJsFile == $js->sCoreJsFile && $sNamespace == $js->sNamespace) { if ($sCoreJsFile == $js->sCoreJsFile && $sNamespace == $js->sNamespace) {
if (is_string($pluginJsFile)) { if (is_string($pluginJsFile)) {
if (!in_array($pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile)) { if (!in_array($pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile)) {
$this->_aJavascripts[$i]->pluginJsFile[] = $pluginJsFile; $this->_aJavascripts[$i]->pluginJsFile[] = $pluginJsFile;
} }
} else if (is_array($pluginJsFile)) { } else if (is_array($pluginJsFile)) {
$this->_aJavascripts[$i]->pluginJsFile = array_unique(array_merge($pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile)); $this->_aJavascripts[$i]->pluginJsFile = array_unique(array_merge($pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile));
@@ -566,7 +566,7 @@ class PMPluginRegistry {
return $this->_aJavascripts[$i]; return $this->_aJavascripts[$i];
} }
} }
$js = new StdClass(); $js = new StdClass();
$js->sNamespace = $sNamespace; $js->sNamespace = $sNamespace;
$js->sCoreJsFile = $sCoreJsFile; $js->sCoreJsFile = $sCoreJsFile;
@@ -613,7 +613,7 @@ class PMPluginRegistry {
if ($sCoreJsFile == $js->sCoreJsFile && $sNamespace == $js->sNamespace) { if ($sCoreJsFile == $js->sCoreJsFile && $sNamespace == $js->sNamespace) {
$scripts = array_merge($scripts, $this->_aJavascripts[$i]->pluginJsFile); $scripts = array_merge($scripts, $this->_aJavascripts[$i]->pluginJsFile);
} }
} }
} }
return $scripts; return $scripts;
} }
@@ -1042,9 +1042,11 @@ class PMPluginRegistry {
$className = $details->sClassName; $className = $details->sClassName;
$classFile = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'class.' . $pluginFolder .'.php'; $classFile = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'class.' . $pluginFolder .'.php';
if ( file_exists ( $classFile ) ) { if ( file_exists ( $classFile ) ) {
require_once ( $classFile );
$sClassName=substr_replace($className,"class",-6,6); $sClassName=substr_replace($className,"class",-6,6);
//$sClassName = str_replace ( 'plugin', 'class', $className ); //$sClassName = str_replace ( 'plugin', 'class', $className );
if (!class_exists($sClassName)) {
require_once $classFile;
}
$obj = new $sClassName( ); $obj = new $sClassName( );
if ( !in_array ( $methodName, get_class_methods ($obj) ) ) { if ( !in_array ( $methodName, get_class_methods ($obj) ) ) {
throw ( new Exception ( "The method '$methodName' doesn't exist in class '$sClassName' ") ); throw ( new Exception ( "The method '$methodName' doesn't exist in class '$sClassName' ") );
@@ -1152,14 +1154,14 @@ class PMPluginRegistry {
function getCaseSchedulerPlugins( ) { function getCaseSchedulerPlugins( ) {
return $this->_aCaseSchedulerPlugin; return $this->_aCaseSchedulerPlugin;
} }
/** /**
* Register a Task Extended property page in the singleton * Register a Task Extended property page in the singleton
* *
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
* @param unknown_type $sPage * @param unknown_type $sPage
*/ */
function registerTaskExtendedProperty($sNamespace, $sPage, $sName, $sIcon ) { function registerTaskExtendedProperty($sNamespace, $sPage, $sName, $sIcon ) {
$found = false; $found = false;
foreach ( $this->_aTaskExtendedProperties as $row=>$detail ) { foreach ( $this->_aTaskExtendedProperties as $row=>$detail ) {

View File

@@ -2,10 +2,10 @@
/** /**
* Department.php * Department.php
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc. * Copyright (C) 2004 - 2011 Colosa Inc.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
@@ -15,13 +15,13 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* *
*/ */
require_once 'classes/model/om/BaseDepartment.php'; require_once 'classes/model/om/BaseDepartment.php';
@@ -31,7 +31,7 @@ require_once 'classes/model/Users.php';
/** /**
* Skeleton subclass for representing a row from the 'DEPARTMENT' table. * Skeleton subclass for representing a row from the 'DEPARTMENT' table.
* *
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
@@ -45,76 +45,76 @@ class Department extends BaseDepartment {
protected $depo_title = ''; protected $depo_title = '';
/** /**
* Create the Department * Create the Department
* *
* @param array $aData * @param array $aData
* @return void * @return void
*/ */
function create ($aData ) { function create ($aData ) {
$con = Propel::getConnection( DepartmentPeer::DATABASE_NAME ); $con = Propel::getConnection( DepartmentPeer::DATABASE_NAME );
try { try {
if ( isset ( $aData['DEP_UID'] ) ) if ( isset ( $aData['DEP_UID'] ) )
$this->setDepUid ( $aData['DEP_UID'] ); $this->setDepUid ( $aData['DEP_UID'] );
else else
$this->setDepUid ( G::generateUniqueID() ); $this->setDepUid ( G::generateUniqueID() );
if ( isset ( $aData['DEP_PARENT'] ) ) if ( isset ( $aData['DEP_PARENT'] ) )
$this->setDepParent ( $aData['DEP_PARENT'] ); $this->setDepParent ( $aData['DEP_PARENT'] );
else else
$this->setDepParent ( '' ); $this->setDepParent ( '' );
if ( isset ( $aData['DEP_MANAGER'] ) ) if ( isset ( $aData['DEP_MANAGER'] ) )
$this->setDepManager ( $aData['DEP_MANAGER'] ); $this->setDepManager ( $aData['DEP_MANAGER'] );
else else
$this->setDepManager ( '' ); $this->setDepManager ( '' );
if ( isset ( $aData['DEP_LOCATION'] ) ) if ( isset ( $aData['DEP_LOCATION'] ) )
$this->setDepLocation ( $aData['DEP_LOCATION'] ); $this->setDepLocation ( $aData['DEP_LOCATION'] );
else else
$this->setDepLocation ( '' ); $this->setDepLocation ( '' );
if ( isset ( $aData['DEP_STATUS'] ) ) if ( isset ( $aData['DEP_STATUS'] ) )
$this->setDepStatus ( $aData['DEP_STATUS'] ); $this->setDepStatus ( $aData['DEP_STATUS'] );
else else
$this->setDepStatus ( 'ACTIVE' ); $this->setDepStatus ( 'ACTIVE' );
if ( isset ( $aData['DEP_REF_CODE'] ) ) if ( isset ( $aData['DEP_REF_CODE'] ) )
$this->setDepRefCode ( $aData['DEP_REF_CODE'] ); $this->setDepRefCode ( $aData['DEP_REF_CODE'] );
else else
$this->setDepRefCode ( '' ); $this->setDepRefCode ( '' );
if ( isset ( $aData['DEP_LDAP_DN'] ) ) if ( isset ( $aData['DEP_LDAP_DN'] ) )
$this->setDepLdapDn ( $aData['DEP_LDAP_DN'] ); $this->setDepLdapDn ( $aData['DEP_LDAP_DN'] );
else else
$this->setDepLdapDn ( '' ); $this->setDepLdapDn ( '' );
if ( isset ( $aData['DEP_TITLE'] ) ) if ( isset ( $aData['DEP_TITLE'] ) )
$this->setDepTitle ( $aData['DEP_TITLE'] ); $this->setDepTitle ( $aData['DEP_TITLE'] );
else else
$this->setDepTitle ( '' ); $this->setDepTitle ( '' );
if ( $this->validate() ) { if ( $this->validate() ) {
$con->begin(); $con->begin();
$res = $this->save(); $res = $this->save();
$con->commit(); $con->commit();
return $this->getDepUid(); return $this->getDepUid();
} }
else { else {
$msg = ''; $msg = '';
foreach($this->getValidationFailures() as $objValidationFailure) foreach($this->getValidationFailures() as $objValidationFailure)
$msg .= $objValidationFailure->getMessage() . "<br/>"; $msg .= $objValidationFailure->getMessage() . "<br/>";
throw ( new Exception ( " The Department row cannot be created $msg " ) ); throw ( new Exception ( " The Department row cannot be created $msg " ) );
} }
} }
catch (Exception $e) { catch (Exception $e) {
$con->rollback(); $con->rollback();
throw ($e); throw ($e);
} }
} }
/** /**
* Get the [depo_title] column value. * Get the [depo_title] column value.
* @return string * @return string
@@ -131,7 +131,7 @@ protected $depo_title = '';
/** /**
* Set the [depo_title] column value. * Set the [depo_title] column value.
* *
* @param string $v new value * @param string $v new value
* @return void * @return void
*/ */
@@ -143,7 +143,7 @@ protected $depo_title = '';
// Since the native PHP type for this column is string, // Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not). // we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) { if ($v !== null && !is_string($v)) {
$v = (string) $v; $v = (string) $v;
} }
if ($this->depo_title !== $v || $v === '') { if ($this->depo_title !== $v || $v === '') {
@@ -157,11 +157,11 @@ protected $depo_title = '';
/** /**
* Load the Process row specified in [depo_id] column value. * Load the Process row specified in [depo_id] column value.
* *
* @param string $ProUid the uid of the Prolication * @param string $ProUid the uid of the Prolication
* @return array $Fields the fields * @return array $Fields the fields
*/ */
function Load ( $DepUid ) { function Load ( $DepUid ) {
$con = Propel::getConnection(DepartmentPeer::DATABASE_NAME); $con = Propel::getConnection(DepartmentPeer::DATABASE_NAME);
try { try {
@@ -186,12 +186,12 @@ protected $depo_title = '';
* @param array $aData * @param array $aData
* @return variant * @return variant
**/ **/
public function update($aData) public function update($aData)
{ {
$con = Propel::getConnection( DepartmentPeer::DATABASE_NAME ); $con = Propel::getConnection( DepartmentPeer::DATABASE_NAME );
try { try {
$con->begin(); $con->begin();
$oPro = DepartmentPeer::retrieveByPK( $aData['DEP_UID'] ); $oPro = DepartmentPeer::retrieveByPK( $aData['DEP_UID'] );
if (is_object($oPro) && get_class ($oPro) == 'Department' ) { if (is_object($oPro) && get_class ($oPro) == 'Department' ) {
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); $oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
@@ -205,19 +205,19 @@ protected $depo_title = '';
if ( isset ( $aData['DEP_MANAGER'] ) ) if ( isset ( $aData['DEP_MANAGER'] ) )
$oPro->setDepManager( $aData['DEP_MANAGER'] ); $oPro->setDepManager( $aData['DEP_MANAGER'] );
$res = $oPro->save(); $res = $oPro->save();
$con->commit(); $con->commit();
return $res; return $res;
} }
else { else {
$msg = ''; $msg = '';
foreach($this->getValidationFailures() as $objValidationFailure) foreach($this->getValidationFailures() as $objValidationFailure)
$msg .= $objValidationFailure->getMessage() . "<br/>"; $msg .= $objValidationFailure->getMessage() . "<br/>";
throw ( new PropelException ( 'The Department row cannot be created!', new PropelException ( $msg ) ) ); throw ( new PropelException ( 'The Department row cannot be created!', new PropelException ( $msg ) ) );
} }
} }
else { else {
$con->rollback(); $con->rollback();
throw(new Exception( "The row '" . $aData['DEP_UID'] . "' in table Department doesn't exist!" )); throw(new Exception( "The row '" . $aData['DEP_UID'] . "' in table Department doesn't exist!" ));
} }
} }
@@ -229,7 +229,7 @@ protected $depo_title = '';
/** /**
* Remove the row * Remove the row
* @param array $aData or string $ProUid * @param array $aData or string $ProUid
* @return string * @return string
**/ **/
public function remove($ProUid) public function remove($ProUid)
@@ -238,17 +238,17 @@ protected $depo_title = '';
$ProUid = ( isset ( $ProUid['DEP_UID'] ) ? $ProUid['DEP_UID'] : '' ); $ProUid = ( isset ( $ProUid['DEP_UID'] ) ? $ProUid['DEP_UID'] : '' );
} }
try { try {
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(UsersPeer::USR_UID); $oCriteria->addSelectColumn(UsersPeer::USR_UID);
$oCriteria->add(UsersPeer::DEP_UID, $ProUid, Criteria::EQUAL); $oCriteria->add(UsersPeer::DEP_UID, $ProUid, Criteria::EQUAL);
$oDataset = UsersPeer::doSelectRS($oCriteria); $oDataset = UsersPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next(); $oDataset->next();
$aFields = array(); $aFields = array();
while ($aRow = $oDataset->getRow()) { while ($aRow = $oDataset->getRow()) {
$aFields['USR_UID'] = $aRow['USR_UID']; $aFields['USR_UID'] = $aRow['USR_UID'];
$aFields['DEP_UID'] = ''; $aFields['DEP_UID'] = '';
$oDepto = UsersPeer::retrieveByPk($aFields['USR_UID']); $oDepto = UsersPeer::retrieveByPk($aFields['USR_UID']);
@@ -258,12 +258,12 @@ protected $depo_title = '';
$oDepto = new Users(); $oDepto = new Users();
$oDepto->update($aFields); $oDepto->update($aFields);
} }
$oDataset->next(); $oDataset->next();
} }
$oPro = DepartmentPeer::retrieveByPK( $ProUid ); $oPro = DepartmentPeer::retrieveByPK( $ProUid );
if (!is_null($oPro)) if (!is_null($oPro))
{ {
@@ -283,11 +283,11 @@ protected $depo_title = '';
/** /**
* Load the Department row specified in [depo_id] column value. * Load the Department row specified in [depo_id] column value.
* *
* @param string $ProUid the uid of the Prolication * @param string $ProUid the uid of the Prolication
* @return array $Fields the fields * @return array $Fields the fields
*/ */
function existsDepartment( $DepUid ) { function existsDepartment( $DepUid ) {
$con = Propel::getConnection(DepartmentPeer::DATABASE_NAME); $con = Propel::getConnection(DepartmentPeer::DATABASE_NAME);
$oPro = DepartmentPeer::retrieveByPk( $DepUid ); $oPro = DepartmentPeer::retrieveByPk( $DepUid );
@@ -309,7 +309,7 @@ protected $depo_title = '';
return false; return false;
} }
function updateDepartmentManager ($depId) { function updateDepartmentManager ($depId) {
$managerId = ''; $managerId = '';
$depParent = ''; $depParent = '';
@@ -341,15 +341,15 @@ protected $depo_title = '';
$oUser->setUsrReportsTo( $managerParentId ); $oUser->setUsrReportsTo( $managerParentId );
} }
} }
$oUser->save(); $oUser->save();
} }
// get children departments to update the reportsTo of these children // get children departments to update the reportsTo of these children
$childrenCriteria = new Criteria('workflow'); $childrenCriteria = new Criteria('workflow');
$childrenCriteria->add(DepartmentPeer::DEP_PARENT, $depId ); $childrenCriteria->add(DepartmentPeer::DEP_PARENT, $depId );
$oDataset = DepartmentPeer::doSelectRS($childrenCriteria); $oDataset = DepartmentPeer::doSelectRS($childrenCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next(); $oDataset->next();
while ( $aRow = $oDataset->getRow() ) { while ( $aRow = $oDataset->getRow() ) {
$oUser = UsersPeer::retrieveByPk($aRow['DEP_MANAGER']); $oUser = UsersPeer::retrieveByPk($aRow['DEP_MANAGER']);
@@ -358,7 +358,7 @@ protected $depo_title = '';
$oUser->save(); $oUser->save();
} }
$oDataset->next(); $oDataset->next();
} }
} }
@@ -371,7 +371,7 @@ protected $depo_title = '';
$oUser->setDepUid( $depId ); $oUser->setDepUid( $depId );
$oUser->save(); $oUser->save();
} }
//if the user is a manager update Department Table //if the user is a manager update Department Table
if ( $manager ) { if ( $manager ) {
$oDept = DepartmentPeer::retrieveByPk( $depId ); $oDept = DepartmentPeer::retrieveByPk( $depId );
@@ -380,11 +380,11 @@ protected $depo_title = '';
$oDept->save(); $oDept->save();
} }
} }
//now update the reportsto to all //now update the reportsto to all
if ( $updateManager ) { if ( $updateManager ) {
$this->updateDepartmentManager ($depId); $this->updateDepartmentManager ($depId);
} }
return true; return true;
} }
catch ( Exception $oError) { catch ( Exception $oError) {
@@ -402,7 +402,7 @@ function getDepartments( $DepParent ) {
$con = Propel::getConnection(DepartmentPeer::DATABASE_NAME); $con = Propel::getConnection(DepartmentPeer::DATABASE_NAME);
$objects = DepartmentPeer::doSelect($criteria, $con); $objects = DepartmentPeer::doSelect($criteria, $con);
global $RBAC; global $RBAC;
foreach( $objects as $oDepartment ) { foreach( $objects as $oDepartment ) {
$node = array(); $node = array();
$node['DEP_UID'] = $oDepartment->getDepUid(); $node['DEP_UID'] = $oDepartment->getDepUid();
@@ -410,8 +410,9 @@ function getDepartments( $DepParent ) {
$node['DEP_TITLE'] = $oDepartment->getDepTitle(); $node['DEP_TITLE'] = $oDepartment->getDepTitle();
$node['DEP_STATUS'] = $oDepartment->getDepStatus(); $node['DEP_STATUS'] = $oDepartment->getDepStatus();
$node['DEP_MANAGER'] = $oDepartment->getDepManager(); $node['DEP_MANAGER'] = $oDepartment->getDepManager();
$node['DEP_LDAP_DN'] = $oDepartment->getDepLdapDn();
$node['DEP_LAST'] = 0; $node['DEP_LAST'] = 0;
$manager = $oDepartment->getDepManager(); $manager = $oDepartment->getDepManager();
if ($manager != ''){ if ($manager != ''){
$UserUID = $RBAC->load($manager); $UserUID = $RBAC->load($manager);
@@ -419,7 +420,7 @@ function getDepartments( $DepParent ) {
$node['DEP_MANAGER_FIRSTNAME'] = isset($UserUID['USR_FIRSTNAME'])?$UserUID['USR_FIRSTNAME']:''; $node['DEP_MANAGER_FIRSTNAME'] = isset($UserUID['USR_FIRSTNAME'])?$UserUID['USR_FIRSTNAME']:'';
$node['DEP_MANAGER_LASTNAME'] = isset($UserUID['USR_LASTNAME'])?$UserUID['USR_LASTNAME']:''; $node['DEP_MANAGER_LASTNAME'] = isset($UserUID['USR_LASTNAME'])?$UserUID['USR_LASTNAME']:'';
}else{ }else{
$node['DEP_MANAGER_USERNAME'] = ''; $node['DEP_MANAGER_USERNAME'] = '';
$node['DEP_MANAGER_FIRSTNAME'] = ''; $node['DEP_MANAGER_FIRSTNAME'] = '';
$node['DEP_MANAGER_LASTNAME'] = ''; $node['DEP_MANAGER_LASTNAME'] = '';
} }
@@ -442,7 +443,7 @@ function getDepartments( $DepParent ) {
throw $e; throw $e;
} }
} }
function getUsersFromDepartment( $sDepUid, $sManagerUid ) { function getUsersFromDepartment( $sDepUid, $sManagerUid ) {
try { try {
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria('workflow');
@@ -450,12 +451,12 @@ function getDepartments( $DepParent ) {
$oCriteria->addSelectColumn(UsersPeer::USR_REPORTS_TO); $oCriteria->addSelectColumn(UsersPeer::USR_REPORTS_TO);
$oCriteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL); $oCriteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
$oCriteria->add(UsersPeer::DEP_UID, $sDepUid); $oCriteria->add(UsersPeer::DEP_UID, $sDepUid);
$rs = UsersPeer::doSelectRS($oCriteria); $rs = UsersPeer::doSelectRS($oCriteria);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oUser = new Users(); $oUser = new Users();
$aUsers[] = array('USR_UID' =>'char', 'USR_USERNAME' =>'char','USR_FULLNAME' =>'char', 'USR_REPORTS_TO'=>'char','USR_MANAGER' =>'char'); $aUsers[] = array('USR_UID' =>'char', 'USR_USERNAME' =>'char','USR_FULLNAME' =>'char', 'USR_REPORTS_TO'=>'char','USR_MANAGER' =>'char');
$rs->next(); $rs->next();
$row = $rs->getRow(); $row = $rs->getRow();
while( is_array($row) ) { while( is_array($row) ) {
@@ -479,27 +480,27 @@ function getDepartments( $DepParent ) {
$rs->next(); $rs->next();
$row = $rs->getRow(); $row = $rs->getRow();
} }
G::LoadClass('ArrayPeer'); G::LoadClass('ArrayPeer');
global $_DBArray; global $_DBArray;
$_DBArray['DepartmentUserList'] = $aUsers ; $_DBArray['DepartmentUserList'] = $aUsers ;
$_SESSION['_DBArray'] = $_DBArray; $_SESSION['_DBArray'] = $_DBArray;
$oCriteriaT = new Criteria('dbarray'); $oCriteriaT = new Criteria('dbarray');
$oCriteriaT->setDBArrayTable('DepartmentUserList'); $oCriteriaT->setDBArrayTable('DepartmentUserList');
return $oCriteriaT; return $oCriteriaT;
} }
catch (exception $e) { catch (exception $e) {
throw $e; throw $e;
} }
} }
/* /*
* Remove a user from Departments * Remove a user from Departments
* @param string $DepUid, $UsrUid * @param string $DepUid, $UsrUid
* @return array * @return array
*/ */
function removeUserFromDepartment($DepUid, $UsrUid) { function removeUserFromDepartment($DepUid, $UsrUid) {
$aFields = array ('USR_UID'=> $UsrUid,'DEP_UID'=> '', 'USR_REPORTS_TO' => ''); $aFields = array ('USR_UID'=> $UsrUid,'DEP_UID'=> '', 'USR_REPORTS_TO' => '');
try { try {
$oUser = UsersPeer::retrieveByPk( $UsrUid ); $oUser = UsersPeer::retrieveByPk( $UsrUid );
@@ -508,7 +509,7 @@ function getDepartments( $DepParent ) {
$oUser->setDepUid ( ''); $oUser->setDepUid ( '');
$oUser->setUsrReportsTo ( ''); $oUser->setUsrReportsTo ( '');
$oUser->save(); $oUser->save();
} }
} }
catch (exception $oError) { catch (exception $oError) {
throw ($oError); throw ($oError);
@@ -535,7 +536,7 @@ function getDepartments( $DepParent ) {
throw ($oError); throw ($oError);
} }
} }
/* /*
* Return the cant Users In Department * Return the cant Users In Department
* @param string $sDepUID * @param string $sDepUID
@@ -558,20 +559,20 @@ function getDepartments( $DepParent ) {
throw ($oError); throw ($oError);
} }
} }
function loadByGroupname ( $Groupname ) { function loadByGroupname ( $Groupname ) {
$c = new Criteria('workflow'); $c = new Criteria('workflow');
$del = DBAdapter::getStringDelimiter(); $del = DBAdapter::getStringDelimiter();
$c->clearSelectColumns(); $c->clearSelectColumns();
$c->addSelectColumn( ContentPeer::CON_CATEGORY ); $c->addSelectColumn( ContentPeer::CON_CATEGORY );
$c->addSelectColumn( ContentPeer::CON_VALUE ); $c->addSelectColumn( ContentPeer::CON_VALUE );
$c->add(ContentPeer::CON_CATEGORY, 'DEPO_TITLE'); $c->add(ContentPeer::CON_CATEGORY, 'DEPO_TITLE');
$c->add(ContentPeer::CON_VALUE, $Groupname); $c->add(ContentPeer::CON_VALUE, $Groupname);
$c->add(ContentPeer::CON_LANG, SYS_LANG ); $c->add(ContentPeer::CON_LANG, SYS_LANG );
return $c; return $c;
} }
//Added by Qennix //Added by Qennix
function getAllDepartmentsByUser(){ function getAllDepartmentsByUser(){
$c = new Criteria('workflow'); $c = new Criteria('workflow');