From 6cdc2e92dacc8b198b9a1495a175841c1ac42bba Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 12 Aug 2013 19:05:41 +0300 Subject: [PATCH] Invite model --- lib/invite.php | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 lib/invite.php diff --git a/lib/invite.php b/lib/invite.php new file mode 100644 index 00000000..f07d6214 --- /dev/null +++ b/lib/invite.php @@ -0,0 +1,76 @@ +execute(array( + $esId, + $userId, + self::STATUS_SENT, + time() + )); + + return \OCP\DB::insertid(`*PREFIX*office_invite`); + } + + public static function accept($esId){ + $query = \OCP\DB::prepare('UPDATE `*PREFIX*office_invite` SET `status`=? WHERE `es_id`=? AND `uid`=?'); + $query->execute(array( + self::STATUS_ACCEPTED, + $esId, + \OCP\User::getUser() + )); + } + + public static function decline($esId){ + $query = \OCP\DB::prepare('UPDATE `*PREFIX*office_invite` SET `status`=? WHERE `es_id`=? AND `uid`=?'); + $query->execute(array( + self::STATUS_DECLINED, + $esId, + \OCP\User::getUser() + )); + } + + + public static function getAllInvites(){ + $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_invite` WHERE `uid`= ?'); + $result = $query->execute(array(\OCP\User::getUser())); + return $result->fetchAll(); + } + + public static function getSenderStatusesAsArray(){ + $l10n = \OCP\Util::getL10N('office'); + + return array( + self::STATUS_SENT => $l10n->t('Sent'), + self::STATUS_DECLINED => $l10n->t('Declined'), + self::STATUS_ACCEPTED => $l10n->t('Accepted') + ); + } + + public static function getRecipientStatusesAsArray(){ + $l10n = \OCP\Util::getL10N('office'); + + return array( + self::STATUS_SENT => $l10n->t('Incoming'), + self::STATUS_DECLINED => $l10n->t('Declined'), + self::STATUS_ACCEPTED => $l10n->t('Accepted') + ); + } +} \ No newline at end of file