public function delete() { global $db, $history; /* The global constants can be overriden by passing appropriate params */ //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login']; $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval']; $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification']; $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email']; if (empty($this->params['id'])) { flash('error', gt('Missing id for the comment you would like to delete')); $lastUrl = expHistory::getLast('editable'); } // delete the note $simplenote = new expSimpleNote($this->params['id']); $rows = $simplenote->delete(); // delete the assocication too $db->delete($simplenote->attachable_table, 'expsimplenote_id=' . $this->params['id']); // send the user back where they came from. $lastUrl = expHistory::getLast('editable'); if (!empty($this->params['tab'])) { $lastUrl .= "#" . $this->params['tab']; } redirect_to($lastUrl); }
function emailCustomer() { //eDebug($this->params,true); global $db, $template, $user; if (empty($this->params['id'])) { expHistory::back(); } // get the order $order = new order($this->params['id']); // Save the message for future use if that is what the user wanted. if (!empty($this->params['save_message'])) { $message->body = $this->params['email_message']; $db->insertObject($message, 'order_status_messages'); } $email_addys[] = explode(',', $this->params['to_addresses']); //$order->billingmethod[0]->email; //eDebug($email_addy,true); if (!empty($email_addys[0])) { assign_to_template(array('message' => $this->params['email_message'])); $html = $template->render(); if ($this->params['include_invoice']) { $html .= '<br><hr><br>'; $html .= renderAction(array('controller' => 'order', 'action' => 'show', 'view' => 'email_invoice', 'id' => $this->params['id'], 'printerfriendly' => '1', 'no_output' => 'true')); } else { $html .= ecomconfig::getConfig('footer'); } //eDebug($html,true); if (isset($this->params['from_address'])) { if ($this->params['from_address'] == 'other') { $from = $this->params['other_from_address']; } else { $from = $this->params['from_address']; } } else { $from = ecomconfig::getConfig('from_address'); } if (isset($this->params['email_subject'])) { $email_subject = $this->params['email_subject']; } else { $email_subject = 'Message from ' . ecomconfig::getConfig('storename') . ' about your order (#' . $order->invoice_id . ')'; } $mail = new expMail(); //FIXME Unless you need each mail sent separately, you can now set 'to'=>$email_addys and let expMail send a single email to all addresses foreach ($email_addys as $email_addy) { $mail->quickSend(array('html_message' => $html, 'text_message' => str_replace("<br>", "\r\n", $template->render()), 'to' => $email_addy, 'from' => $from, 'subject' => $email_subject)); } $emailed_to = implode(',', $email_addys); $note = new expSimpleNote(); $note->body = "<strong>[action]: Emailed message to " . $emailed_to . ":</strong><br><br>" . $this->params['email_message']; $note->approved = 1; $note->name = $user->firstname . " " . $user->lastname; $note->email = $user->email; $note->save(); $note->refresh(); $noteObj->expsimplenote_id = $note->id; $noteObj->content_id = $order->id; $noteObj->content_type = 'order'; $db->insertObject($noteObj, 'content_expSimpleNote'); //eDebug($note,true); } else { flash('error', gt('The email address was NOT sent. An email address count not be found for this customer')); expHistory::back(); } flash('message', gt('Email sent.')); expHistory::back(); }