set up quill library
This commit is contained in:
40
config.php
40
config.php
@@ -171,14 +171,14 @@ class Session extends PhpObject
|
||||
{
|
||||
$this->addError('Nickname: HTML characters are forbidden');
|
||||
}
|
||||
elseif($this->oMySql->selectRow(MySqlManager::USERS_TABLE, array('user'=>$sLogin)))
|
||||
elseif($this->oMySql->selectRow(Db::USERS_TABLE, array('user'=>$sLogin)))
|
||||
{
|
||||
$this->addError('Nickname: This is already a user called by that name, choose a different one');
|
||||
}
|
||||
else
|
||||
{
|
||||
$asData['pass'] = self::encryptPassword($sPass);
|
||||
$iUserId = $this->oMySql->insertRow(MySqlManager::USERS_TABLE, $asData);
|
||||
$iUserId = $this->oMySql->insertRow(Db::USERS_TABLE, $asData);
|
||||
return $this->logMeIn($sLogin, $sPass);
|
||||
}
|
||||
return false;
|
||||
@@ -187,7 +187,7 @@ class Session extends PhpObject
|
||||
public function logMeIn($sLogin, $sPass)
|
||||
{
|
||||
$bResult = false;
|
||||
$asUser = $this->oMySql->selectRow(MySqlManager::USERS_TABLE, array('user'=>$sLogin));
|
||||
$asUser = $this->oMySql->selectRow(Db::USERS_TABLE, array('user'=>$sLogin));
|
||||
if(!$asUser)
|
||||
{
|
||||
$this->addError('Utilisateur inconnu');
|
||||
@@ -198,7 +198,7 @@ class Session extends PhpObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setSession($asUser[MySqlManager::getId(MySqlManager::USERS_TABLE)], $sLogin);
|
||||
$this->setSession($asUser[Db::getId(Db::USERS_TABLE)], $sLogin);
|
||||
$bResult = true;
|
||||
}
|
||||
return $bResult;
|
||||
@@ -228,9 +228,9 @@ class Session extends PhpObject
|
||||
$asConstraints = array('user'=>$sUserName);
|
||||
if($iUserId>0)
|
||||
{
|
||||
$asConstraints[MySqlManager::getId(MySqlManager::USERS_TABLE)] = $iUserId;
|
||||
$asConstraints[Db::getId(Db::USERS_TABLE)] = $iUserId;
|
||||
}
|
||||
return $this->oMySql->selectValue(MySqlManager::USERS_TABLE, 'COUNT(1)', $asConstraints);
|
||||
return $this->oMySql->selectValue(Db::USERS_TABLE, 'COUNT(1)', $asConstraints);
|
||||
}
|
||||
|
||||
public function logMeOut()
|
||||
@@ -534,7 +534,7 @@ class MyThoughts extends PhpObject
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->oMySql = new MySqlManager();
|
||||
$this->oMySql = new Db();
|
||||
$this->oSession = new Session($this->oMySql);
|
||||
$this->oCalendar = new Calendar($this->oMySql, $this->oSession);
|
||||
$this->oMainMask = new Mask('index');
|
||||
@@ -589,9 +589,9 @@ class MyThoughts extends PhpObject
|
||||
public function updateThought($iThoughtId, $sThought)
|
||||
{
|
||||
$asValues = array('thought'=>$this->encodeThought($sThought));
|
||||
$asConstraints = array( MySqlManager::getId(MySqlManager::THOUGHTS_TABLE)=>$iThoughtId,
|
||||
MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$this->oMySql->updateRow(MySqlManager::THOUGHTS_TABLE, $asConstraints, $asValues);
|
||||
$asConstraints = array( Db::getId(Db::THOUGHTS_TABLE)=>$iThoughtId,
|
||||
Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$this->oMySql->updateRow(Db::THOUGHTS_TABLE, $asConstraints, $asValues);
|
||||
}
|
||||
|
||||
|
||||
@@ -635,8 +635,8 @@ class MyThoughts extends PhpObject
|
||||
{
|
||||
if(!array_key_exists($sSettingName, $this->asSettings))
|
||||
{
|
||||
$asConstraint = array(MySqlManager::getText(MySqlManager::SETTINGS_TABLE)=>$sSettingName, MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$oValue = $this->oMySql->selectValue(MySqlManager::SETTINGS_TABLE, 'value', $asConstraint);
|
||||
$asConstraint = array(Db::getText(Db::SETTINGS_TABLE)=>$sSettingName, Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$oValue = $this->oMySql->selectValue(Db::SETTINGS_TABLE, 'value', $asConstraint);
|
||||
$this->asSettings[$sSettingName] = (!$oValue)?self::getDefaultSetting($sSettingName):$oValue;
|
||||
}
|
||||
return $this->asSettings[$sSettingName];
|
||||
@@ -644,7 +644,7 @@ class MyThoughts extends PhpObject
|
||||
|
||||
private function setSetting($sValue, $sSettingName)
|
||||
{
|
||||
$this->oMySql->insertUpdateRow(MySqlManager::SETTINGS_TABLE, array('setting'=>$sSettingName, MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId()), array('value'=>$sValue));
|
||||
$this->oMySql->insertUpdateRow(Db::SETTINGS_TABLE, array('setting'=>$sSettingName, Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId()), array('value'=>$sValue));
|
||||
}
|
||||
|
||||
public function setSettings($asSettings)
|
||||
@@ -669,9 +669,9 @@ class MyThoughts extends PhpObject
|
||||
if($iThoughtId!=0)
|
||||
{
|
||||
//load a thought
|
||||
$asConstraints = array( MySqlManager::getId(MySqlManager::THOUGHTS_TABLE)=>$iThoughtId,
|
||||
MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$asThought = $this->oMySql->selectRow(MySqlManager::THOUGHTS_TABLE, $asConstraints);
|
||||
$asConstraints = array( Db::getId(Db::THOUGHTS_TABLE)=>$iThoughtId,
|
||||
Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$asThought = $this->oMySql->selectRow(Db::THOUGHTS_TABLE, $asConstraints);
|
||||
$sThought = $this->decodeThought($asThought['thought']);
|
||||
$iThoughtTime = 'Saved at '.date(self::LAYOUT_TIME_FORMAT, strtotime($asThought['led']));
|
||||
}
|
||||
@@ -694,8 +694,8 @@ class MyThoughts extends PhpObject
|
||||
$sMySqlDate = date(self::MYSQL_DATE_FORMAT, $iTimeStamp);
|
||||
$sLayoutDate = date(self::LAYOUT_DATE_FORMAT, $iTimeStamp);
|
||||
|
||||
$asConstraints = array('DATE(led)'=>$sMySqlDate, MySqlManager::getId(MySqlManager::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$asThougths = $this->oMySql->selectRows(array('from'=>MySqlManager::THOUGHTS_TABLE, 'constraint'=>$asConstraints));
|
||||
$asConstraints = array('DATE(led)'=>$sMySqlDate, Db::getId(Db::USERS_TABLE)=>$this->oSession->getUserId());
|
||||
$asThougths = $this->oMySql->selectRows(array('from'=>Db::THOUGHTS_TABLE, 'constraint'=>$asConstraints));
|
||||
|
||||
$this->setPage('read_thought');
|
||||
$this->setPageTitle('Thoughts on '.$sLayoutDate);
|
||||
@@ -825,8 +825,8 @@ class Calendar extends PhpObject
|
||||
{
|
||||
//TODO essayer avec selectRows
|
||||
$sQuery = "SELECT DATE_FORMAT(led, '%d') AS day
|
||||
FROM ".MySqlManager::THOUGHTS_TABLE."
|
||||
WHERE ".MySqlManager::getId(MySqlManager::USERS_TABLE)." = ".$this->oSession->getUserId()."
|
||||
FROM ".Db::THOUGHTS_TABLE."
|
||||
WHERE ".Db::getId(Db::USERS_TABLE)." = ".$this->oSession->getUserId()."
|
||||
AND YEAR(led) = ".$this->iYear."
|
||||
AND MONTH(led) = ".$this->iMonth."
|
||||
GROUP BY day
|
||||
|
||||
Reference in New Issue
Block a user