2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
define('ALIBERR_NOTGR', 20);
|
|
|
|
define('ALIBERR_BADSMEMB', 21);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Subj class
|
|
|
|
*
|
|
|
|
* users + groups
|
|
|
|
* with "linearized recursive membership" ;)
|
|
|
|
* (allow adding users to groups or groups to groups)
|
|
|
|
*
|
2011-01-05 18:19:58 +01:00
|
|
|
* @package Airtime
|
2010-12-07 20:19:27 +01:00
|
|
|
* @subpackage Alib
|
|
|
|
* @copyright 2010 Sourcefabric O.P.S.
|
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt
|
|
|
|
*/
|
2011-09-13 20:16:16 +02:00
|
|
|
class Application_Model_Subjects {
|
2010-12-07 20:19:27 +01:00
|
|
|
|
|
|
|
/* ======================================================= public methods */
|
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
public static function increaseLoginAttempts($login)
|
|
|
|
{
|
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-09-13 20:16:16 +02:00
|
|
|
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = login_attempts+1"
|
|
|
|
." WHERE login='$login'";
|
2012-04-01 21:51:03 +02:00
|
|
|
$res = $con->exec($sql);
|
2011-09-13 20:16:16 +02:00
|
|
|
return (intval($res) > 0);
|
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
|
|
|
public static function resetLoginAttempts($login)
|
|
|
|
{
|
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-09-13 20:16:16 +02:00
|
|
|
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'"
|
|
|
|
." WHERE login='$login'";
|
2012-04-01 21:51:03 +02:00
|
|
|
$res = $con->exec($sql);
|
2012-07-10 05:41:00 +02:00
|
|
|
return true;
|
2011-09-13 20:16:16 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
|
|
|
public static function getLoginAttempts($login)
|
|
|
|
{
|
|
|
|
global $CC_CONFIG;
|
|
|
|
$con = Propel::getConnection();
|
2011-09-13 20:16:16 +02:00
|
|
|
$sql = "SELECT login_attempts FROM ".$CC_CONFIG['subjTable']." WHERE login='$login'";
|
2012-04-01 21:51:03 +02:00
|
|
|
$res = $con->query($sql)->fetchColumn(0);
|
2012-04-19 22:54:38 +02:00
|
|
|
return ($res !== false) ? $res : 0;
|
2011-09-13 20:16:16 +02:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
|
|
|
|
} // class Subjects
|
2011-02-22 18:22:31 +01:00
|
|
|
|