public function formatStoreRecord($record, $model, $store) { $r = new \GO\Base\Mail\EmailRecipients(); $r->addRecipient($model->email, $model->name); $record['from'] = (string) $r; $record['html_signature'] = \GO\Base\Util\String::text_to_html($model->signature); $record['plain_signature'] = $model->signature; $record['signature_below_reply'] = $model->account->signature_below_reply; $record['template_id'] = 0; if (\GO::modules()->addressbook) { $defaultAccountTemplateModel = \GO\Addressbook\Model\DefaultTemplateForAccount::model()->findByPk($model->account_id); if ($defaultAccountTemplateModel) { $record['template_id'] = $defaultAccountTemplateModel->template_id; } else { $defaultUserTemplateModel = \GO\Addressbook\Model\DefaultTemplate::model()->findByPk(\GO::user()->id); if (!$defaultUserTemplateModel) { $defaultUserTemplateModel = new \GO\Addressbook\Model\DefaultTemplateForAccount(); $defaultUserTemplateModel->account_id = $model->account_id; $defaultUserTemplateModel->save(); } $record['template_id'] = $defaultUserTemplateModel->template_id; } } unset($record['signature']); return parent::formatStoreRecord($record, $model, $store); }
protected function actionGetRecipientsAsString($params) { if (empty($params['groups'])) { throw new \Exception(); } $recipients = new \GO\Base\Mail\EmailRecipients(); $groupIds = json_decode($params['groups']); foreach ($groupIds as $groupId) { //ignore acl because members may use groups even without permissions $group = \GO\Base\Model\Group::model()->findByPk($groupId, false, true); if ($group) { $users = $group->users(\GO\Base\Db\FindParams::newInstance()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('email', '', '!='))); while ($user = $users->fetch()) { $recipients->addRecipient($user->email, $user->name); } } } return array('success' => true, 'recipients' => (string) $recipients); }
protected function actionGetRecipientsAsString($params) { if (empty($params['addresslists'])) { throw new \Exception(); } $recipients = new \GO\Base\Mail\EmailRecipients(); $addresslistIds = json_decode($params['addresslists']); foreach ($addresslistIds as $addresslistId) { $addresslist = \GO\Addressbook\Model\Addresslist::model()->findByPk($addresslistId); if ($addresslist) { $contacts = $addresslist->contacts(\GO\Base\Db\FindParams::newInstance()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('email', '', '!='))); while ($contact = $contacts->fetch()) { $recipients->addRecipient($contact->email, $contact->name); } $companies = $addresslist->companies(\GO\Base\Db\FindParams::newInstance()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('email', '', '!='))); while ($company = $companies->fetch()) { $recipients->addRecipient($company->email, $company->name); } } } return array('success' => true, 'recipients' => (string) $recipients); }
public function actionParticipantEmailRecipients($params) { $event = \GO\Calendar\Model\Event::model()->findByPk($params['event_id']); $participants = $event->participants; $to = new \GO\Base\Mail\EmailRecipients(); while ($participant = $participants->fetch()) { $to->addRecipient($participant->email, $participant->name); } $response['success'] = true; $response['to'] = (string) $to; return $response; }