2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
2011-01-31 14:14:55 +00:00
|
|
|
/**
|
|
|
|
|
* LoginLog.php
|
2012-10-19 17:09:00 -04:00
|
|
|
*
|
|
|
|
|
* @package workflow.engine.classes.model
|
2011-01-31 14:14:55 +00:00
|
|
|
*/
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
require_once 'classes/model/om/BaseLoginLog.php';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Skeleton subclass for representing a row from the 'LOGIN_LOG' table.
|
|
|
|
|
*
|
2012-10-19 17:09:00 -04:00
|
|
|
*
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* You should add additional methods to this class to meet the
|
2012-10-19 17:09:00 -04:00
|
|
|
* application requirements. This class will only be generated as
|
2010-12-02 23:34:41 +00:00
|
|
|
* long as it does not already exist in the output directory.
|
|
|
|
|
*
|
2012-10-19 17:09:00 -04:00
|
|
|
* @package workflow.engine.classes.model
|
2010-12-02 23:34:41 +00:00
|
|
|
*/
|
2012-10-19 17:09:00 -04:00
|
|
|
class LoginLog extends BaseLoginLog
|
|
|
|
|
{
|
2016-09-09 15:15:51 -04:00
|
|
|
/**
|
|
|
|
|
* @param $aData
|
|
|
|
|
* @return bool
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function create($aData)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2016-10-20 16:00:08 -04:00
|
|
|
$con = Propel::getConnection( LoginLogPeer::DATABASE_NAME );
|
2012-10-19 17:09:00 -04:00
|
|
|
try {
|
2016-10-20 16:00:08 -04:00
|
|
|
$this->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
if ($this->validate()) {
|
|
|
|
|
$con->begin();
|
|
|
|
|
$result = $this->save();
|
|
|
|
|
$con->commit();
|
|
|
|
|
} else {
|
|
|
|
|
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
|
|
|
|
|
$e->aValidationFailures = $this->getValidationFailures();
|
|
|
|
|
throw ($e);
|
|
|
|
|
}
|
|
|
|
|
return $result;
|
2012-10-19 17:09:00 -04:00
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$con->rollback();
|
|
|
|
|
throw ($e);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-19 17:09:00 -04:00
|
|
|
|
|
|
|
|
public function load ($LogUid)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-19 17:09:00 -04:00
|
|
|
try {
|
|
|
|
|
$oRow = LoginLogPeer::retrieveByPK( $LogUid );
|
|
|
|
|
if (! is_null( $oRow )) {
|
|
|
|
|
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
$this->setNew( false );
|
|
|
|
|
return $aFields;
|
|
|
|
|
} else {
|
|
|
|
|
throw (new Exception( "The row '" . $LogUid . "' in table LOGIN_LOG doesn't exist!" ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-19 17:09:00 -04:00
|
|
|
|
|
|
|
|
public function update ($fields)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-19 17:09:00 -04:00
|
|
|
$con = Propel::getConnection( LoginLogPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$con->begin();
|
2016-10-20 16:00:08 -04:00
|
|
|
$this->load( $fields['LOG_ID'] );
|
2012-10-19 17:09:00 -04:00
|
|
|
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
|
|
|
|
|
if ($this->validate()) {
|
|
|
|
|
$result = $this->save();
|
|
|
|
|
$con->commit();
|
|
|
|
|
return $result;
|
|
|
|
|
} else {
|
|
|
|
|
$con->rollback();
|
|
|
|
|
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$con->rollback();
|
|
|
|
|
throw ($e);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-19 17:09:00 -04:00
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function remove ($LogUid)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-19 17:09:00 -04:00
|
|
|
$con = Propel::getConnection( LoginLogPeer::DATABASE_NAME );
|
|
|
|
|
try {
|
|
|
|
|
$con->begin();
|
|
|
|
|
$this->setWlUid( $LogUid );
|
|
|
|
|
$result = $this->delete();
|
|
|
|
|
$con->commit();
|
|
|
|
|
return $result;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$con->rollback();
|
|
|
|
|
throw ($e);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 17:09:00 -04:00
|
|
|
//Added by Qennix
|
2012-10-20 16:52:15 -04:00
|
|
|
public function getLastLoginByUser ($sUID)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-19 17:09:00 -04:00
|
|
|
$c = new Criteria();
|
|
|
|
|
$c->addSelectColumn( LoginLogPeer::LOG_INIT_DATE );
|
|
|
|
|
$c->add( LoginLogPeer::USR_UID, $sUID );
|
|
|
|
|
$c->setLimit( 1 );
|
|
|
|
|
$c->addDescendingOrderByColumn( LoginLogPeer::LOG_INIT_DATE );
|
|
|
|
|
$Dat = LoginLogPeer::doSelectRS( $c );
|
|
|
|
|
$Dat->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$Dat->next();
|
|
|
|
|
$aRow = $Dat->getRow();
|
|
|
|
|
return isset( $aRow['LOG_INIT_DATE'] ) ? $aRow['LOG_INIT_DATE'] : '';
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-19 17:09:00 -04:00
|
|
|
|
|
|
|
|
//Added by Qennix
|
2012-10-20 16:52:15 -04:00
|
|
|
public function getLastLoginAllUsers ()
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-19 17:09:00 -04:00
|
|
|
$c = new Criteria();
|
|
|
|
|
$c->addSelectColumn( LoginLogPeer::USR_UID );
|
|
|
|
|
$c->addAsColumn( 'LAST_LOGIN', 'MAX(LOG_INIT_DATE)' );
|
|
|
|
|
$c->addGroupByColumn( LoginLogPeer::USR_UID );
|
|
|
|
|
$Dat = LoginLogPeer::doSelectRS( $c );
|
|
|
|
|
$Dat->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$aRows = Array ();
|
|
|
|
|
while ($Dat->next()) {
|
|
|
|
|
$row = $Dat->getRow();
|
|
|
|
|
$aRows[$row['USR_UID']] = $row['LAST_LOGIN'];
|
|
|
|
|
}
|
|
|
|
|
return $aRows;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2018-02-19 19:23:51 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the last session id of a user
|
|
|
|
|
* @param string $userUid User uid
|
|
|
|
|
* @return array All session id of php
|
|
|
|
|
* @throws PropelException
|
|
|
|
|
* @throws SQLException
|
|
|
|
|
*/
|
|
|
|
|
public function getSessionsIdByUser($userUid)
|
|
|
|
|
{
|
|
|
|
|
$criteria = new Criteria();
|
|
|
|
|
$criteria->addSelectColumn('LOG_SID');
|
|
|
|
|
$criteria->add(LoginLogPeer::USR_UID, $userUid);
|
|
|
|
|
$criteria->add(LoginLogPeer::LOG_STATUS, 'ACTIVE');
|
|
|
|
|
$criteria->setDistinct();
|
|
|
|
|
$criteria->addDescendingOrderByColumn(LoginLogPeer::LOG_INIT_DATE);
|
|
|
|
|
$resultSet = LoginLogPeer::doSelectRS($criteria);
|
|
|
|
|
$resultSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$row = [];
|
|
|
|
|
while($resultSet->next()) {
|
|
|
|
|
$row[] = $resultSet->getRow();
|
|
|
|
|
}
|
|
|
|
|
return $row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete all records related to a user uid
|
|
|
|
|
* @param string $userUid User uid
|
|
|
|
|
* @return int
|
|
|
|
|
* @throws PropelException
|
|
|
|
|
*/
|
|
|
|
|
public function removeByUser($userUid)
|
|
|
|
|
{
|
|
|
|
|
$criteria = new Criteria();
|
|
|
|
|
$criteria->add(LoginLogPeer::USR_UID, $userUid);
|
|
|
|
|
$resultSet = LoginLogPeer::doDelete($criteria);
|
|
|
|
|
return $resultSet;
|
|
|
|
|
}
|
2012-10-19 17:09:00 -04:00
|
|
|
}
|
|
|
|
|
|