public function actionDeleteEmailRecipients() { $result = 1; foreach (OphCoTherapyapplication_Email_Recipient::model()->findAllByPK($_POST['email_recipients']) as $email_recipient) { if (!$email_recipient->delete()) { $result = 0; } } echo $result; }
private function getEmailRecipients($service_info, $recipient_type) { if (!($recipients = OphCoTherapyapplication_Email_Recipient::model()->with('type')->findAll('site_id = ? and type.id is null or type.name = ?', array($service_info->site_id, $recipient_type)))) { if (!($recipients = OphCoTherapyapplication_Email_Recipient::model()->with('type')->findAll('site_id is null and type.id is null or type.name = ?', array($recipient_type)))) { throw new Exception('No email recipient defined for site ' . $service_info->site->name . ", {$recipient_type}"); } } return $recipients; }