From 5d0e6d9efc70520a502191a69269beecbb3b3ec8 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Wed, 12 Oct 2016 10:22:02 +0700 Subject: [PATCH] Notes and relations --- application/classes/Model/Course.php | 6 +- application/classes/Model/Subscription.php | 6 +- application/classes/View/Course/Index.php | 14 +++++ .../classes/View/Subscription/Index.php | 12 ++++ application/i18n/ru.php | 7 +++ .../kangana/20161012090530_course-groups.php | 59 +++++++++++++++++++ 6 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 application/migrations/kangana/20161012090530_course-groups.php diff --git a/application/classes/Model/Course.php b/application/classes/Model/Course.php index 7c75cf7..1f7feaf 100644 --- a/application/classes/Model/Course.php +++ b/application/classes/Model/Course.php @@ -14,7 +14,11 @@ class Model_Course extends ORM { ), 'letters' => array( 'model' => 'Letter' - ) + ), + 'group' => array( + 'model' => 'Group', + 'through' => 'courses_groups' + ), ); /** diff --git a/application/classes/Model/Subscription.php b/application/classes/Model/Subscription.php index 9834e7c..161ff7c 100644 --- a/application/classes/Model/Subscription.php +++ b/application/classes/Model/Subscription.php @@ -13,7 +13,11 @@ class Model_Subscription extends ORM { ), 'instants' => array( 'model' => 'Instant' - ) + ), + 'group' => array( + 'model' => 'Group', + 'through' => 'subscriptions_groups' + ), ); /** diff --git a/application/classes/View/Course/Index.php b/application/classes/View/Course/Index.php index 95697b8..59a27fa 100644 --- a/application/classes/View/Course/Index.php +++ b/application/classes/View/Course/Index.php @@ -18,6 +18,20 @@ class View_Course_Index extends View_Index { I18n::translate('Delete') ); } + + public function content() + { + return '

' + .I18n::translate('A course is a pre-defined regular mailing list.') + .' ' + .I18n::translate("You add a message, forming a series of messages.") + .' ' + .I18n::translate("Each new subscriber gets the first message in this series.") + .' ' + .I18n::translate("You can customize the delay (1 day by default) between the messages.") + .'

'; + } + /** * An internal function to prepare item data. **/ diff --git a/application/classes/View/Subscription/Index.php b/application/classes/View/Subscription/Index.php index 9bc734c..bd9ef8e 100644 --- a/application/classes/View/Subscription/Index.php +++ b/application/classes/View/Subscription/Index.php @@ -18,6 +18,18 @@ class View_Subscription_Index extends View_Index { I18n::translate('Delete') ); } + + public function content() + { + return '

' + .I18n::translate('A subscription is a non-regular mailing list.') + .' ' + .I18n::translate( + "You add a message, and then you send it to subscribers." + ) + .'

'; + } + /** * An internal function to prepare item data. **/ diff --git a/application/i18n/ru.php b/application/i18n/ru.php index 6c9fa5c..721e60b 100644 --- a/application/i18n/ru.php +++ b/application/i18n/ru.php @@ -77,4 +77,11 @@ return array( 'Groups' => 'Группы', 'Group name' => 'Название группы', 'Delete group' => 'Удалить группу', + 'A subscription is a non-regular mailing list.' => 'Рассылка - это список для нерегулярной рассылки писем.', + "You add a message, and then you send it to subscribers." => 'Вы добавляете сообщение, а потом рассылаете его подписчикам.', + 'Send to subscribers' => 'Разослать подписчикам', + 'A course is a pre-defined regular mailing list.' => 'Курс - это заранее сформированный регулярный список рассылки.', + "You add a message, forming a series of messages." => 'Вы добавляете сообщение в серию сообщений.', + "Each new subscriber gets the first message in this series." => 'Каждый новый подписчик получает первое сообщение в этой серии.', + "You can customize the delay (1 day by default) between the messages." => 'Вы можете настроить задержку (по умолчанию - один день) между сообщениями.', ); diff --git a/application/migrations/kangana/20161012090530_course-groups.php b/application/migrations/kangana/20161012090530_course-groups.php new file mode 100644 index 0000000..3854dda --- /dev/null +++ b/application/migrations/kangana/20161012090530_course-groups.php @@ -0,0 +1,59 @@ +query(NULL, " +CREATE TABLE IF NOT EXISTS `courses_groups` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `course_id` int(11) NOT NULL, + `group_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `fk_courses_groups_course_index` (`course_id`), + KEY `fk_courses_groups_group_index` (`group_id`) +) ENGINE=InnoDB;"); + + $db->query(NULL, " +ALTER TABLE `courses_groups` + ADD CONSTRAINT `fk_courses_groups_course` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_courses_groups_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + "); + + $db->query(NULL, " +CREATE TABLE IF NOT EXISTS `subscriptions_groups` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `subscription_id` int(11) NOT NULL, + `group_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `fk_subscriptions_groups_subscription_index` (`subscription_id`), + KEY `fk_subscriptions_groups_group_index` (`group_id`) +) ENGINE=InnoDB;"); + + $db->query(NULL, " +ALTER TABLE `subscriptions_groups` + ADD CONSTRAINT `fk_subscriptions_groups_subscription` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_subscriptions_groups_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + "); + } + + /** + * Run queries needed to remove this migration + * + * @param Kohana_Database $db Database connection + */ + public function down(Kohana_Database $db) + { + $db->query(NULL, "DROP TABLE `subscriptions_groups`"); + $db->query(NULL, "DROP TABLE `courses_groups`"); + } + +}