| Server IP : 185.252.147.100 / Your IP : 216.73.216.196 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/kanboard/app/Model/ |
Upload File : |
<?php
namespace Kanboard\Model;
use Kanboard\Core\Base;
use Kanboard\Core\Security\Token;
/**
* Class InviteModel
*
* @package Kanboard\Model
* @author Frederic Guillot
*/
class InviteModel extends Base
{
const TABLE = 'invites';
public function createInvites(array $emails, $projectId)
{
$emails = array_unique($emails);
$nb = 0;
foreach ($emails as $email) {
$email = trim($email);
if (! empty($email) && $this->createInvite($email, $projectId)) {
$nb++;
}
}
return $nb;
}
protected function createInvite($email, $projectId)
{
$values = array(
'email' => $email,
'project_id' => $projectId,
'token' => Token::getToken(),
);
if ($this->db->table(self::TABLE)->insert($values)) {
$this->sendInvite($values);
return true;
}
return false;
}
protected function sendInvite(array $values)
{
$this->emailClient->send(
$values['email'],
$values['email'],
e('Kanboard Invitation'),
$this->template->render('user_invite/email', array('token' => $values['token']))
);
}
public function getByToken($token)
{
return $this->db->table(self::TABLE)
->eq('token', $token)
->findOne();
}
public function remove($email)
{
return $this->db->table(self::TABLE)
->eq('email', $email)
->remove();
}
}