mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 13:24:41 +03:00
Use "update_operator" func for operator modification everywhere
This commit is contained in:
parent
1d9a837e37
commit
65d7cb3823
@ -19,7 +19,6 @@
|
||||
|
||||
namespace Mibew\Controller;
|
||||
|
||||
use Mibew\Database;
|
||||
use Mibew\Http\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
@ -72,17 +71,10 @@ class PasswordRecoveryController extends AbstractController
|
||||
? openssl_random_pseudo_bytes(32)
|
||||
: (time() + microtime()) . mt_rand(0, 99999999)));
|
||||
|
||||
$db = Database::getInstance();
|
||||
$db->query(
|
||||
("UPDATE {operator} "
|
||||
. "SET dtmrestore = :now, vcrestoretoken = :token "
|
||||
. "WHERE operatorid = :operatorid"),
|
||||
array(
|
||||
':now' => time(),
|
||||
':token' => $token,
|
||||
':operatorid' => $to_restore['operatorid'],
|
||||
)
|
||||
);
|
||||
// Update the operator
|
||||
$to_restore['dtmrestore'] = time();
|
||||
$to_restore['vcrestoretoken'] = $token;
|
||||
update_operator($to_restore);
|
||||
|
||||
$href = $this->getRouter()->generate(
|
||||
'password_recovery_reset',
|
||||
@ -178,16 +170,11 @@ class PasswordRecoveryController extends AbstractController
|
||||
if (count($page['errors']) == 0) {
|
||||
$page['isdone'] = true;
|
||||
|
||||
$db = Database::getInstance();
|
||||
$db->query(
|
||||
("UPDATE {operator} "
|
||||
. "SET vcpassword = ?, vcrestoretoken = '' "
|
||||
. "WHERE operatorid = ?"),
|
||||
array(
|
||||
calculate_password_hash($operator['vclogin'], $password),
|
||||
$op_id,
|
||||
)
|
||||
);
|
||||
// Update the operator
|
||||
$operator['vcrestoretoken'] = '';
|
||||
$operator['vcpassword'] = calculate_password_hash($operator['vclogin'], $password);
|
||||
update_operator($operator);
|
||||
|
||||
$page['loginname'] = $operator['vclogin'];
|
||||
|
||||
return $this->render('password_recovery_reset', $page);
|
||||
|
@ -93,11 +93,9 @@ function permission_descriptions()
|
||||
*/
|
||||
function update_operator_permissions($operator_id, $perm)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$db->query(
|
||||
"UPDATE {operator} SET iperm = ? WHERE operatorid = ?",
|
||||
array($perm, $operator_id)
|
||||
);
|
||||
$operator = operator_by_id($operator_id);
|
||||
$operator['iperm'] = $perm;
|
||||
update_operator($operator);
|
||||
}
|
||||
|
||||
function operator_by_login($login)
|
||||
@ -331,11 +329,9 @@ function update_operator($operator)
|
||||
|
||||
function update_operator_avatar($operator_id, $avatar)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$db->query(
|
||||
"UPDATE {operator} SET vcavatar = ? WHERE operatorid = ?",
|
||||
array($avatar, $operator_id)
|
||||
);
|
||||
$operator = operator_by_id($operator_id);
|
||||
$operator['vcavatar'] = $avatar;
|
||||
update_operator($operator);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,16 +427,10 @@ function delete_operator($operator_id)
|
||||
*/
|
||||
function notify_operator_alive($operator_id, $istatus)
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$db->query(
|
||||
("UPDATE {operator} SET istatus = :istatus, dtmlastvisited = :now "
|
||||
. "WHERE operatorid = :operatorid"),
|
||||
array(
|
||||
':istatus' => $istatus,
|
||||
':now' => time(),
|
||||
':operatorid' => $operator_id,
|
||||
)
|
||||
);
|
||||
$operator = operator_by_id($operator_id);
|
||||
$operator['istatus'] = $istatus;
|
||||
$operator['dtmlastvisited'] = time();
|
||||
update_operator($operator);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -784,10 +774,9 @@ function update_operator_groups($operator_id, $new_value)
|
||||
*/
|
||||
function disable_operator($operator_id)
|
||||
{
|
||||
Database::getInstance()->query(
|
||||
'UPDATE {operator} SET idisabled = ? WHERE operatorid = ?',
|
||||
array('1', $operator_id)
|
||||
);
|
||||
$operator = operator_by_id($operator_id);
|
||||
$operator['idisabled'] = 1;
|
||||
update_operator($operator);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -797,10 +786,9 @@ function disable_operator($operator_id)
|
||||
*/
|
||||
function enable_operator($operator_id)
|
||||
{
|
||||
Database::getInstance()->query(
|
||||
'UPDATE {operator} SET idisabled = ? WHERE operatorid = ?',
|
||||
array('0', $operator_id)
|
||||
);
|
||||
$operator = operator_by_id($operator_id);
|
||||
$operator['idisabled'] = 0;
|
||||
update_operator($operator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user