From 10d96bfd668f445249190c52bedb2eb0e7e9410d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 22 Jan 2017 22:38:00 -0500 Subject: Add user invitations --- app/Model/InviteModel.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/Model/InviteModel.php (limited to 'app/Model') diff --git a/app/Model/InviteModel.php b/app/Model/InviteModel.php new file mode 100644 index 00000000..13d75f69 --- /dev/null +++ b/app/Model/InviteModel.php @@ -0,0 +1,73 @@ +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(); + } +} -- cgit v1.2.3