本文整理汇总了PHP中Email::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::setUser方法的具体用法?PHP Email::setUser怎么用?PHP Email::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::setUser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeStatus
public function changeStatus()
{
$status = (int) $this->request->get('status');
$shipment = Shipment::getInstanceByID('Shipment', (int) $this->request->get('id'), true, array('Order' => 'CustomerOrder', 'ShippingAddress' => 'UserAddress'));
$shipment->loadItems();
$zone = $shipment->getDeliveryZone();
$shipmentRates = $zone->getShippingRates($shipment);
$shipment->setAvailableRates($shipmentRates);
$history = new OrderHistory($shipment->order->get(), $this->user);
$shipment->status->set($status);
$shipment->save();
$history->saveLog();
$status = $shipment->status->get();
$enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES');
$m = array('EMAIL_STATUS_UPDATE_NEW' => Shipment::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => Shipment::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => Shipment::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => Shipment::STATUS_SHIPPED);
$sendEmail = false;
foreach ($m as $configKey => $constValue) {
if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) {
$sendEmail = true;
}
}
if ($sendEmail || $this->config->get('EMAIL_STATUS_UPDATE')) {
$user = $shipment->order->get()->user->get();
$user->load();
$email = new Email($this->application);
$email->setUser($user);
$email->setTemplate('order.status');
$email->set('order', $shipment->order->get()->toArray(array('payments' => true)));
$email->set('shipments', array($shipment->toArray()));
$email->send();
}
return new JSONResponse(false, 'success');
}
示例2: testUser
function testUser()
{
$user = User::getNewInstance('recipient@test.com');
$user->firstName->set('test');
$user->lastName->set('recipient');
Swift_Connection_Fake::resetBuffer();
$user->save();
//var_dump(Swift_Connection_Fake::getBuffer());
$email = new Email(self::getApplication());
$email->setFrom('tester@integry.com', 'Unit Test');
$email->setSubject('test');
$email->setText('some text');
$email->setUser($user);
$res = $email->send();
$this->assertTrue(strpos($email->getMessage()->getHeaders()->get('To'), $user->email->get()) !== false);
$this->assertEqual($res, 1);
}
示例3: add
public function add()
{
if ($this->buildOrderNoteValidator()->isValid()) {
$order = CustomerOrder::getInstanceById($this->request->get('id'), CustomerOrder::LOAD_DATA);
$note = OrderNote::getNewInstance($order, $this->user);
$note->isAdmin->set(true);
$note->text->set($this->request->get('comment'));
$note->save();
if ($this->config->get('EMAIL_ORDERNOTE')) {
$order->user->get()->load();
$email = new Email($this->application);
$email->setUser($order->user->get());
$email->setTemplate('order.message');
$email->set('order', $order->toArray(array('payments' => true)));
$email->set('message', $note->toArray());
$email->send();
}
return new ActionRedirectResponse('backend.orderNote', 'view', array('id' => $note->getID()));
} else {
return new RawResponse('invalid');
}
}
示例4: do_register
public function do_register()
{
$request = $this->application->getRequest();
$first_name = $request->get('firstName');
$last_name = $request->get('lastName');
$company = $request->get('companyName');
$email = $request->get('email');
$pass = $request->get('password');
if (!isset($first_name) || !isset($last_name) || !isset($email) || !isset($pass)) {
throw new Exception("Please complete required field " . $last_name);
}
$user = User::getInstanceByEmail($email);
if (isset($user)) {
throw new Exception('User already exist');
}
$user = User::getNewInstance($email, $pass);
$user->firstName->set($first_name);
$user->lastName->set($last_name);
if (isset($company)) {
$user->companyName->set($company);
}
$user->email->set($email);
$user->isEnabled->set('1');
$user->save();
$code = rand(1, 10000000) . rand(1, 10000000);
$user->setPreference('confirmation', $code);
$user->save();
$_email = new Email($this->application);
$_email->setUser($user);
$_email->set('code', $code);
$_email->setTemplate('user.confirm');
$_email->send();
$response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
$response->addChild('state', '1');
return new SimpleXMLResponse($response);
}
示例5: sendWelcomeEmail
public function sendWelcomeEmail(User $user)
{
// send welcome email with user account details
if ($this->config->get('EMAIL_NEW_USER')) {
if ($this->session->get('password')) {
$user->setPassword($this->session->get('password'));
}
$email = new Email($this->application);
$email->setUser($user);
$email->setTemplate('user.new');
$email->send();
}
}
示例6: sendStatusNotifyEmail
public function sendStatusNotifyEmail(CustomerOrder $order)
{
$status = $order->status->get();
$enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES');
$m = array('EMAIL_STATUS_UPDATE_NEW' => CustomerOrder::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => CustomerOrder::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => CustomerOrder::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => CustomerOrder::STATUS_SHIPPED);
$sendEmail = false;
foreach ($m as $configKey => $constValue) {
if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) {
$sendEmail = true;
}
}
if ($this->config->get('EMAIL_STATUS_UPDATE') || $sendEmail) {
$this->loadLanguageFile('Frontend');
$this->application->loadLanguageFiles();
$order->user->get()->load();
$email = new Email($this->application);
$email->setUser($order->user->get());
$email->setTemplate('order.status');
$email->set('order', $order->toArray(array('payments' => true)));
$email->set('shipments', $order->getShipments()->toArray());
$email->send();
}
}
示例7: save
public function save($con = null)
{
if ($this->getObject()->isNew()) {
$signup = true;
} else {
$signup = false;
}
$object = parent::save();
// update profile
$values = $this->getValues();
$profile = $object->getProfile();
// save and remove photo from values
$photo = $values["profile"]["photo"];
unset($values["profile"]["photo"]);
// update profile object
$profile->fromArray($values["profile"], BasePeer::TYPE_FIELDNAME);
$profile->setUser($object);
// new photo??
if ($photo) {
$fileName = $profile->getPhoto(false);
if (!$fileName) {
$fileName = $profile->generateAvatarName() . '.jpg';
}
$photo->save(sfConfig::get('sf_userimage_dir') . DIRECTORY_SEPARATOR . $fileName);
$profile->setPhoto($fileName);
}
if ($values["profile"]["remove_photo"]) {
$fileName = $profile->getPhoto(false);
if ($fileName) {
$profile->setPhoto(null);
$profile->save();
// remove from filesystem
unlink(sfConfig::get('sf_userimage_dir') . DIRECTORY_SEPARATOR . $fileName);
} else {
$profile->save();
}
} else {
$profile->save();
}
// if creating, setup email and permanent jotag
if ($signup) {
// setup email
$email = new Email();
$email->setEmail($this->getValue('email'));
$email->setIsConfirmed(true);
$email->setIsPrimary(true);
$email->setType(ContactPeer::TP_PERSONAL);
$email->setUser($object);
$email->save();
// generate JOTAG.
$tag = new Tag();
$tag->setJotag($object->generateRandomJOTAG());
$tag->setIsPrimary(true);
$tag->setStatus(TagPeer::ST_ACTIVE);
$tag->setUser($object);
// link primary email to tag
$tm = new TagEmail();
$tm->setEmail($email);
$tag->addTagEmail($tm);
// save new tag
$tag->save();
}
return $object;
}
示例8: finalizeOrder
protected function finalizeOrder($options = array())
{
if (!count($this->order->getShipments())) {
throw new ApplicationException('No shipments in order');
}
$user = $this->order->user->get();
$user->load();
$newOrder = $this->order->finalize($options);
$orderArray = $this->order->toArray(array('payments' => true));
// send order confirmation email
if ($this->config->get('EMAIL_NEW_ORDER')) {
$email = new Email($this->application);
$email->setUser($user);
$email->setTemplate('order.new');
$email->set('order', $orderArray);
$email->send();
}
// notify store admin
if ($this->config->get('NOTIFY_NEW_ORDER')) {
$email = new Email($this->application);
$email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME'));
$email->setTemplate('notify.order');
$email->set('order', $orderArray);
$email->set('user', $user->toArray());
$email->send();
}
$this->session->set('completedOrderID', $this->order->getID());
if ($newOrder instanceof CustomerOrder) {
SessionOrder::save($newOrder);
} else {
SessionOrder::destroy();
}
return new ActionRedirectResponse('checkout', 'completed');
}
示例9: finalizeOrder
protected function finalizeOrder(CustomerOrder $customer_order, User $user)
{
$user->load();
/*if (!count($customer_order->getShipments()))
{
throw new Exception('No shipments in order');
}*/
$newOrder = $customer_order->finalize();
$orderArray = $customer_order->toArray(array('payments' => true));
// send order confirmation email
if ($this->application->config->get('EMAIL_NEW_ORDER')) {
$email = new Email($this->application);
$email->setUser($user);
$email->setTemplate('order.new');
$email->set('order', $orderArray);
$email->send();
}
// notify store admin
if ($this->application->config->get('NOTIFY_NEW_ORDER')) {
$email = new Email($this->application);
$email->setTo($this->application->config->get('NOTIFICATION_EMAIL'), $this->application->config->get('STORE_NAME'));
$email->setTemplate('notify.order');
$email->set('order', $orderArray);
$email->set('user', $user->toArray());
$email->send();
}
// if user hasn't wish list items order->finalize() will return null, saving null with SessionOrder causes fatal error!
if ($newOrder instanceof CustomerOrder) {
return true;
}
return false;
}