Use the querybuilder instead
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
24
lib/imap.php
24
lib/imap.php
@@ -52,25 +52,29 @@ class OC_User_IMAP extends \OCA\user_external\Base {
|
||||
$uid = str_replace("%40","@",$uid);
|
||||
}
|
||||
|
||||
$result = \OC::$server->getDatabaseConnection()->executeQuery(
|
||||
'SELECT `userid` FROM `*PREFIX*preferences` WHERE `appid`=? AND `configkey`=? AND `configvalue`=?',
|
||||
array('settings','email',$uid)
|
||||
);
|
||||
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
|
||||
$query->select('userid')
|
||||
->from('preferences')
|
||||
->where($query->expr()->eq('appid', $query->createNamedParameter('settings')))
|
||||
->andWhere($query->expr()->eq('configkey', $query->createNamedParameter('email')))
|
||||
->andWhere($query->expr()->eq('configvalue', $query->createNamedParameter($uid)));
|
||||
$result = $query->execute();
|
||||
|
||||
$users = array();
|
||||
$users = [];
|
||||
while ($row = $result->fetch()) {
|
||||
$users[] = $row['userid'];
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
||||
if(count($users) === 1) {
|
||||
$username = $uid;
|
||||
$uid = $users[0];
|
||||
// Check if we only want logins from ONE domain and strip the domain part from UID
|
||||
}elseif($this->domain !== '') {
|
||||
}elseif($this->domain !== '') {
|
||||
$pieces = explode('@', $uid);
|
||||
if(count($pieces) === 1) {
|
||||
$username = $uid . "@" . $this->domain;
|
||||
}elseif((count($pieces) === 2) and ($pieces[1] === $this->domain)) {
|
||||
}elseif((count($pieces) === 2) && ($pieces[1] === $this->domain)) {
|
||||
$username = $uid;
|
||||
$uid = $pieces[0];
|
||||
}else{
|
||||
@@ -83,13 +87,13 @@ class OC_User_IMAP extends \OCA\user_external\Base {
|
||||
$mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1);
|
||||
imap_errors();
|
||||
imap_alerts();
|
||||
if($mbox !== FALSE) {
|
||||
if($mbox !== false) {
|
||||
imap_close($mbox);
|
||||
$uid = mb_strtolower($uid);
|
||||
$this->storeUser($uid);
|
||||
return $uid;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user