diff --git a/application/classes/Model/Instant.php b/application/classes/Model/Instant.php index 8636212..9866397 100644 --- a/application/classes/Model/Instant.php +++ b/application/classes/Model/Instant.php @@ -71,20 +71,4 @@ class Model_Instant extends ORM { } return $email->send(); } - - /** - * Send the instant to all subscribers if it's not a draft - **/ - public function save() - { - if (!$this->is_draft()) - { - $subscription = ORM::factory('Subscription', $this->subscription_id); - $subscribers = $subscription->clients->find_all(); - foreach ($subscribers as $subscriber) - { - } - } - } - } diff --git a/application/classes/Model/Subscription.php b/application/classes/Model/Subscription.php index 043ff40..6e62d60 100644 --- a/application/classes/Model/Subscription.php +++ b/application/classes/Model/Subscription.php @@ -50,4 +50,12 @@ class Model_Subscription extends ORM { 'welcome' => 'Welcome message', 'description' => 'Description (for the clients)' ); + + /** + * Return subscriber count + **/ + public function count_clients() + { + return DB::select(array(DB::expr('COUNT(client_id)'), 'cnt'))->from('clients_courses')->where('course_id', '=', $this->id)->execute()->get('cnt'); + } } diff --git a/application/migrations/kangana/20140218143726.php b/application/migrations/kangana/20140218143726.php new file mode 100644 index 0000000..6477ae0 --- /dev/null +++ b/application/migrations/kangana/20140218143726.php @@ -0,0 +1,27 @@ +query(NULL, 'alter table `instants` drop column `is_draft`'); + $db->query(NULL, "alter table `instants` add column `sent` int(1) not null default '0'"); + } + + /** + * Run queries needed to remove this migration + * + * @param Kohana_Database $db Database connection + */ + public function down(Kohana_Database $db) + { + $db->query(NULL, 'alter table `instants` drop column `sent`'); + $db->query(NULL, "alter table `instants` add column `is_draft` int(1) not null default '1'"); + } + +} diff --git a/model.mwb b/model.mwb index 33ccc77..c06836b 100644 Binary files a/model.mwb and b/model.mwb differ