本文整理汇总了PHP中Email::content方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::content方法的具体用法?PHP Email::content怎么用?PHP Email::content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::content方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
//template header
$this->template->title = __('Contact Us');
$this->template->meta_description = __('Contact') . ' ' . core::config('general.site_name');
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Contact Us')));
if ($this->request->post()) {
//captcha check
if (captcha::check('contact')) {
//check if user is loged in
if (Auth::instance()->logged_in()) {
$email_from = Auth::instance()->get_user()->email;
$name_from = Auth::instance()->get_user()->name;
} else {
$email_from = core::post('email');
$name_from = core::post('name');
}
//akismet spam filter
if (!core::akismet($name_from, $email_from, core::post('message'))) {
$replace = array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from);
if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), $email_from, $name_from, 'contact-admin', $replace)) {
Alert::set(Alert::SUCCESS, __('Your message has been sent'));
} else {
Alert::set(Alert::ERROR, __('Message not sent'));
}
} else {
Alert::set(Alert::WARNING, __('This email has been considered as spam! We are sorry but we can not send this email.'));
}
} else {
Alert::set(Alert::ERROR, __('Wrong captcha'));
}
}
$this->template->content = View::factory('pages/contact');
}
示例2: notify
/**
* Function to notify subscribers
*/
public static function notify(Model_Ad $ad)
{
$subscribers = new Model_Subscribe();
if ($ad->price > 0) {
$subscribers->where_open()->where(DB::EXPR((int) $ad->price), 'BETWEEN', array('min_price', 'max_price'))->or_where('max_price', '=', 0)->where_close();
}
//location is set
if (is_numeric($ad->id_location)) {
$subscribers->where('id_location', 'in', array($ad->id_location, 0));
}
//filter by category, 0 means all the cats, in case was not set
$subscribers->where('id_category', 'in', array($ad->id_category, 0));
$subscribers = $subscribers->find_all();
$subscribers_id = array();
// array to be filled with user emails
foreach ($subscribers as $subs) {
// do not repeat same users.
if (!in_array($subs->id_user, $subscribers_id)) {
$subscribers_id[] = $subs->id_user;
}
}
// query for getting users, transform it to array and pass to email function
if (count($subscribers_id) > 0) {
$query = DB::select('email')->select('name')->from('users')->where('id_user', 'IN', $subscribers_id)->where('status', '=', Model_User::STATUS_ACTIVE)->execute();
$users = $query->as_array();
// Send mails like in newsletter, to multiple users simultaneously
if (count($users) > 0) {
$url_ad = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
$replace = array('[URL.AD]' => $url_ad, '[AD.TITLE]' => $ad->title);
Email::content($users, '', core::config('email.notify_email'), core::config('general.site_name'), 'ads-subscribers', $replace);
}
}
}
示例3: action_index
public function action_index()
{
//template header
$this->template->title = __('Contact Us');
$this->template->meta_description = __('Contact Us');
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Contact Us')));
if ($this->request->post()) {
//captcha check
if (captcha::check('contact')) {
//akismet spam filter
if (!core::akismet(core::post('name'), core::post('email'), core::post('message'))) {
$replace = array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => core::post('name'), '[EMAIL.FROM]' => core::post('email'));
if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::post('email'), core::post('name'), 'contact.admin', $replace)) {
Alert::set(Alert::SUCCESS, __('Your message has been sent'));
} else {
Alert::set(Alert::ERROR, __('Message not sent'));
}
} else {
Alert::set(Alert::SUCCESS, __('This email has been considered as spam! We are sorry but we can not send this email.'));
}
} else {
Alert::set(Alert::ERROR, __('Check the form for errors'));
}
}
$this->template->content = View::factory('pages/contact');
}
示例4: confirm_payment
/**
* confirm payment for order
*
* @param string $id_order [unique indentifier of order]
* @param string $txn_id id of the transaction depending on provider
*/
public function confirm_payment($paymethod = 'paypal', $txn_id = NULL)
{
// update orders
if ($this->loaded()) {
$ad = $this->ad;
$this->status = self::STATUS_PAID;
$this->pay_date = Date::unix2mysql();
$this->paymethod = $paymethod;
$this->txn_id = $txn_id;
try {
$this->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
//if saved delete coupon from session and -- number of coupons.
Model_Coupon::sale($this->coupon);
//send email to site owner! new sale!!
if (core::config('email.new_ad_notify') == TRUE) {
$url_ad = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
$replace = array('[AD.TITLE]' => $ad->title, '[URL.AD]' => $url_ad, '[ORDER.ID]' => $this->id_order, '[PRODUCT.ID]' => $this->id_product);
Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::config('email.notify_email'), core::config('general.site_name'), 'ads-sold', $replace);
}
//depending on the product different actions
switch ($this->id_product) {
case Model_Order::PRODUCT_AD_SELL:
$ad->sale($this);
break;
case Model_Order::PRODUCT_TO_TOP:
$ad->to_top();
break;
case Model_Order::PRODUCT_TO_FEATURED:
$ad->to_feature($this->featured_days);
break;
case Model_Order::PRODUCT_CATEGORY:
$ad->paid_category();
break;
}
}
}
示例5: action_forgot
/**
* Sends an email with a link to change your password
*
*/
public function action_forgot()
{
//template header
$this->template->title = __('Remember password');
$this->template->meta_description = __('Here you can reset your password if you forgot it');
$this->template->content = View::factory('pages/auth/forgot');
//if user loged in redirect home
if (Auth::instance()->logged_in()) {
$this->redirect(Route::get('oc-panel')->uri());
} elseif (core::post('email') and CSRF::valid('forgot')) {
$email = core::post('email');
if (Valid::email($email, TRUE)) {
//check we have this email in the DB
$user = new Model_User();
$user = $user->where('email', '=', $email)->limit(1)->find();
if ($user->loaded()) {
//we get the QL, and force the regen of token for security
$url_ql = $user->ql('oc-panel', array('controller' => 'profile', 'action' => 'changepass'), TRUE);
//we don't use this since checks if the user is subscribed which is stupid since you want to remember your password.
//$ret = $user->email('auth-remember',array('[URL.QL]'=>$url_ql));
$ret = Email::content($user->email, $user->name, NULL, NULL, 'auth-remember', array('[URL.QL]' => $url_ql));
//email sent notify and redirect him
if ($ret) {
Alert::set(Alert::SUCCESS, __('Email to recover password sent'));
$this->redirect(Route::url('oc-panel', array('controller' => 'auth', 'action' => 'login')));
}
} else {
Form::set_errors(array(__('User not in database')));
}
} else {
Form::set_errors(array(__('Invalid Email')));
}
}
}
示例6: action_new
/**
* displays the form new topic
* @return [type] [description]
*/
public function action_new()
{
if (!Auth::instance()->logged_in()) {
Alert::set(Alert::ALERT, __('Please login before posting'));
$this->redirect(Route::url('oc-panel', array('controller' => 'auth', 'action' => 'login')));
}
$forums = Model_Forum::get_forum_count();
if (count($forums) == 0) {
if (Auth::instance()->logged_in() and Auth::instance()->get_user()->id_role == Model_Role::ROLE_ADMIN) {
Alert::set(Alert::INFO, __('Please, first create some Forums.'));
$this->redirect(Route::url('oc-panel', array('controller' => 'forum', 'action' => 'index')));
} else {
Alert::set(Alert::INFO, __('New Topic is not available as a feature.'));
$this->redirect(Route::url('default'));
}
}
$errors = NULL;
if ($this->request->post()) {
//captcha check
if (captcha::check('new-forum')) {
$user = Auth::instance()->get_user();
//akismet spam filter
if (!core::akismet($user->name, $user->email, core::post('description'))) {
$validation = Validation::factory($this->request->post())->rule('description', 'not_empty')->rule('description', 'min_length', array(':value', 5))->rule('description', 'max_length', array(':value', 1000))->rule('title', 'not_empty')->rule('title', 'min_length', array(':value', 5))->rule('id_forum', 'numeric');
// Optional banned words validation
if (core::config('advertisement.validate_banned_words')) {
$validation = $validation->rule('title', 'no_banned_words');
}
if ($validation->check()) {
$topic = new Model_Post();
$topic->id_user = $user->id_user;
$topic->id_forum = core::post('id_forum');
$topic->title = Text::banned_words(core::post('title'));
$topic->seotitle = $topic->gen_seotitle($topic->title);
$topic->description = Text::banned_words(core::post('description'));
$topic->status = Model_Post::STATUS_ACTIVE;
$topic->ip_address = ip2long(Request::$client_ip);
$topic->save();
$forum_url = Route::url('forum-topic', array('forum' => $topic->forum->seoname, 'seotitle' => $topic->seotitle));
if (core::config('email.new_ad_notify') == TRUE or core::config('email.new_sale_notify') == TRUE) {
Email::content(core::config('email.notify_email'), '', NULL, NULL, 'new-forum-answer', array('[FORUM.LINK]' => $forum_url));
}
$this->redirect($forum_url);
} else {
$errors = $validation->errors('ad');
}
} else {
Alert::set(Alert::WARNING, __('This email has been considered as spam! We are sorry but we can not send this email.'));
}
} else {
Alert::set(Alert::ERROR, __('Check the form for errors'));
}
}
//template header
$this->template->title = __('New Forum Topic');
$this->template->meta_description = $this->template->title;
Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
$this->template->styles = array('css/jquery.sceditor.default.theme.min.css' => 'screen');
$this->template->scripts['footer'] = array('js/jquery.sceditor.bbcode.min.js', 'js/forum-new.js');
$this->template->bind('content', $content);
$this->template->content = View::factory('pages/forum/new', array('forums' => $forums));
$content->errors = $errors;
}
示例7: notify_admins
/**
* notify admins of new ad
* @return void
*/
public function notify_admins()
{
//NOTIFY ADMIN
// new ad notification email to admin (notify_email), if set to TRUE
if (core::config('email.new_ad_notify') == TRUE) {
$url_ad = Route::url('ad', array('category' => $this->category->seoname, 'seotitle' => $this->seotitle));
$replace = array('[URL.AD]' => $url_ad, '[AD.TITLE]' => $this->title);
Email::content(Email::get_notification_emails(), core::config('general.site_name'), core::config('email.notify_email'), core::config('general.site_name'), 'ads-to-admin', $replace);
}
}
示例8: action_request
/**
* Sends request to admin (private site)
*
*/
public function action_request()
{
//template header
$this->template->title = __('Request Access');
$this->template->content = View::factory('pages/auth/request');
$this->template->meta_description = __('Send your Name and Email to the administrator of the website');
//if user loged in redirect home
if (Auth::instance()->logged_in()) {
$this->redirect(Route::get('oc-panel')->uri());
} elseif (core::post('email') and core::post('name')) {
$name = core::post('name');
$email = core::post('email');
if (Valid::email($email)) {
//check we have this email in the DB
$user = new Model_User();
$user = $user->where('email', '=', $email)->limit(1)->find();
if (!$user->loaded()) {
// email sent to admin
$replace = array('[EMAIL.BODY]' => $name . ' requests access.', '[EMAIL.SUBJECT]' => 'Access Request', '[EMAIL.SENDER]' => $name, '[EMAIL.FROM]' => $email);
if (Email::content(core::config('email.notify_email'), core::config('general.site_name'), $email, $name, 'contact-admin', $replace)) {
Alert::set(Alert::SUCCESS, __('Your request has been sent'));
} else {
Alert::set(Alert::ERROR, __('Request not sent'));
}
} else {
Alert::set(Alert::ERROR, __('User already exists'));
}
} else {
Alert::set(Alert::ERROR, __('Invalid Email'));
}
}
$this->redirect(Route::get('default')->uri());
}
示例9: confirm_payment
/**
* confirm payment for order
*
* @param string $id_order [unique indentifier of order]
* @param string $txn_id id of the transaction depending on provider
*/
public function confirm_payment($paymethod = 'paypal', $txn_id = NULL)
{
// update orders
if ($this->loaded()) {
$this->status = self::STATUS_PAID;
$this->pay_date = Date::unix2mysql();
$this->paymethod = $paymethod;
$this->txn_id = $txn_id;
try {
$this->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
//if saved delete coupon from session and -- number of coupons.
Model_Coupon::sale($this->coupon);
//for membership plans
if ($this->id_product >= 100) {
Model_Subscription::new_order($this);
$replace_email = array('[AD.TITLE]' => $this->description, '[URL.AD]' => Route::url('pricing'), '[ORDER.ID]' => $this->id_order, '[PRODUCT.ID]' => $this->id_product, '[VAT.COUNTRY]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_country : '', '[VAT.NUMBER]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_number : '', '[VAT.PERCENTAGE]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT : '');
} else {
$ad = $this->ad;
//depending on the product different actions
switch ($this->id_product) {
case Model_Order::PRODUCT_AD_SELL:
$ad->sale($this);
break;
case Model_Order::PRODUCT_TO_TOP:
$ad->to_top();
break;
case Model_Order::PRODUCT_TO_FEATURED:
$ad->to_feature($this->featured_days);
Social::social_post_featured_ad($ad);
break;
case Model_Order::PRODUCT_CATEGORY:
$ad->paid_category();
break;
}
$url_ad = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
$replace_email = array('[AD.TITLE]' => $ad->title, '[URL.AD]' => $url_ad, '[ORDER.ID]' => $this->id_order, '[PRODUCT.ID]' => $this->id_product, '[VAT.COUNTRY]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_country : '', '[VAT.NUMBER]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_number : '', '[VAT.PERCENTAGE]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT : '');
}
//send email to site owner! new sale!!
if (core::config('email.new_ad_notify') == TRUE) {
Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::config('email.notify_email'), core::config('general.site_name'), 'ads-sold', $replace_email);
}
}
}
示例10: action_changepass
public function action_changepass()
{
// only admins can change password
if ($this->request->post() and $this->user->id_role == Model_Role::ROLE_ADMIN) {
$user = new Model_User($this->request->param('id'));
if (core::post('password1') == core::post('password2')) {
if (!empty(core::post('password1'))) {
$user->password = core::post('password1');
$user->last_modified = Date::unix2mysql();
$user->failed_attempts = 0;
$user->last_failed = NULL;
try {
$user->save();
// email user with new password
Email::content($user->email, $user->name, NULL, NULL, 'password-changed', array('[USER.PWD]' => core::post('password1')));
} catch (ORM_Validation_Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
Alert::set(Alert::SUCCESS, __('Password is changed'));
} else {
Form::set_errors(array(__('Nothing is provided')));
}
} else {
Form::set_errors(array(__('Passwords do not match')));
}
}
$this->redirect(Route::url('oc-panel', array('controller' => 'user', 'action' => 'update', 'id' => $this->request->param('id'))));
}
示例11: action_update
public function action_update()
{
//template header
$this->template->title = __('Edit Product');
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Product')));
$this->template->styles = array('css/sortable.css' => 'screen', '//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/css/jquery.fileupload.css' => 'screen', 'css/jasny-bootstrap.min.css' => 'screen');
$this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/jasny-bootstrap.min.js', 'js/oc-panel/products.js', 'js/jquery-sortable-min.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/vendor/jquery.ui.widget.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/jquery.iframe-transport.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/jquery.fileupload.js');
$cats = Model_Category::get_as_array();
$order = Model_Category::get_multidimensional();
$obj_product = new Model_Product($this->request->param('id'));
if ($obj_product->loaded()) {
// get currencies from product, returns array
$currency = $obj_product::get_currency();
$this->template->content = View::factory('oc-panel/pages/products/update', array('product' => $obj_product, 'categories' => $cats, 'order_categories' => $order, 'currency' => $currency));
if ($product = $this->request->post()) {
// save product file
if (isset($_FILES['file_name'])) {
if ($file = $_FILES['file_name']) {
$file = $obj_product->save_product($file);
if ($file != FALSE) {
$obj_product->file_name = $file;
} else {
Alert::set(Alert::INFO, __('Product is not uploaded.'));
}
}
}
// deleting single image by path
$deleted_image = core::post('img_delete');
if (is_numeric($deleted_image)) {
$img_path = $obj_product->gen_img_path($obj_product->id_product, $obj_product->created);
$img_seoname = $obj_product->seotitle;
// delete image from Amazon S3
if (core::config('image.aws_s3_active')) {
require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
$s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
//delete original image
$s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . $deleted_image . '.jpg');
//delete formated image
$s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . $deleted_image . '.jpg');
//re-ordering image file names
for ($i = $deleted_image; $i < $obj_product->has_images; $i++) {
//rename original image
$s3->copyObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . ($i + 1) . '.jpg', core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . $i . '.jpg', S3::ACL_PUBLIC_READ);
$s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . ($i + 1) . '.jpg');
//rename formated image
$s3->copyObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg', core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . $i . '.jpg', S3::ACL_PUBLIC_READ);
$s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg');
}
}
if (!is_dir($img_path)) {
return FALSE;
} else {
//delete original image
@unlink($img_path . $img_seoname . '_' . $deleted_image . '.jpg');
//delete formated image
@unlink($img_path . 'thumb_' . $img_seoname . '_' . $deleted_image . '.jpg');
//re-ordering image file names
for ($i = $deleted_image; $i < $obj_product->has_images; $i++) {
rename($img_path . $img_seoname . '_' . ($i + 1) . '.jpg', $img_path . $img_seoname . '_' . $i . '.jpg');
rename($img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg', $img_path . 'thumb_' . $img_seoname . '_' . $i . '.jpg');
}
}
$obj_product->has_images = $obj_product->has_images > 0 ? $obj_product->has_images - 1 : 0;
$obj_product->updated = Date::unix2mysql();
try {
$obj_product->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
$this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
}
// end of img delete
//delete product file
$product_delete = core::post('product_delete');
if ($product_delete) {
$p_path = $obj_product->get_file($obj_product->file_name);
if (!is_file($p_path)) {
return FALSE;
} else {
@chmod($p_path, 0755);
//delete product
unlink($p_path);
$obj_product->file_name = '';
$obj_product->save();
$this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
}
}
$product['status'] = (!isset($_POST['status']) or core::post('status') === NULL) ? Model_Product::STATUS_NOACTIVE : Model_Product::STATUS_ACTIVE;
$product['updated'] = Date::unix2mysql();
//we do this so we assure use the entire day , nasty
$product['offer_valid'] .= ' 23:59:59';
$product['featured'] .= ' 23:59:59';
// each field in edit product
foreach ($product as $field => $value) {
// do not include submit
if ($field != 'submit' and $field != 'notify') {
// check if its different, and set it is
if ($value != $obj_product->{$field}) {
$obj_product->{$field} = $value;
// if title is changed, make new seotitle
//.........这里部分代码省略.........
示例12: email
/**
* sends email to the current user replacing tags
* @param string $seotitle from Model_Content
* @param array $replace
* @param array $file file to be uploaded
* @return boolean
*/
public function email($seotitle, array $replace = NULL, $from = NULL, $from_name = NULL, $file = NULL, $to = NULL)
{
if ($this->loaded() and $this->subscriber == 1) {
return Email::content($to == NULL ? $this->email : $to, $this->name, $from, $from_name, $seotitle, $replace, $file);
}
return FALSE;
}
示例13: action_ticket
public function action_ticket()
{
$this->template->scripts['footer'] = array('js/oc-panel/ticket.js');
//after creating the reply we redirect to the ticket view
$errors = NULL;
$user = Auth::instance()->get_user();
$ticket_id = $this->request->param('id', 0);
//getting the parent ticket
$ticket = new Model_Ticket();
if (!$user->has_access('supportadmin')) {
$ticket->where('id_user', '=', $user->id_user);
}
$ticket->where('id_ticket', '=', $ticket_id)->where('id_ticket_parent', 'IS', NULL)->limit(1)->find();
if (!$ticket->loaded()) {
Alert::set(Alert::ERROR, __('Not your ticket.'));
$this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index')));
}
//marking it as read if was not assign we assign an agent.
if ($ticket->status == Model_Ticket::STATUS_CREATED and $user->has_access('supportadmin') and !is_numeric($ticket->id_user_support)) {
//modify status of parent ticket
$ticket->id_user_support = $user->id_user;
$ticket->read_date = Date::unix2mysql();
$ticket->status = Model_Ticket::STATUS_READ;
$ticket->save();
}
//Change the agent assigned to this ticket
if (core::post('agent') and $user->has_access('supportadmin')) {
//modify ticket
$ticket->id_user_support = core::post('agent');
$ticket->status = Model_Ticket::STATUS_CREATED;
$ticket->save();
//send notification to agent
$agent = new Model_User(core::post('agent'));
$agent->email('assign-agent', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $ticket->description, '[URL.QL]' => $agent->ql('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
Alert::set(Alert::SUCCESS, __('Agent assigned.'));
$this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index', 'id' => 'admin')));
}
//create new reply
if ($this->request->post() and Form::token('reply_ticket', TRUE)) {
$validation = Validation::factory($this->request->post())->rule('description', 'not_empty')->rule('description', 'min_length', array(':value', 5))->rule('description', 'max_length', array(':value', 1000));
if ($validation->check()) {
//creates the answer ticket
$ticketr = new Model_Ticket();
$ticketr->id_user = $user->id_user;
$ticketr->id_order = $ticket->id_order;
$ticketr->id_ticket_parent = $ticket->id_ticket;
$ticketr->description = core::post('description');
$ticketr->ip_address = ip2long(Request::$client_ip);
$ticketr->save();
unset($_POST['description']);
//modify status of parent ticket
$ticket->status = Model_Ticket::STATUS_CREATED;
$ticket->save();
//an admin answer so we send email to owner of ticket
if ($user->has_access('supportadmin')) {
$ticket->id_user_support = $user->id_user;
$ticket->read_date = Date::unix2mysql();
$ticket->status = Model_Ticket::STATUS_HOLD;
$ticket->save();
//send email to creator of the ticket
$ticket->user->email('new-reply', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $user->signature, '[URL.QL]' => $ticket->user->ql('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
} elseif (is_numeric($ticket->id_user_support)) {
//send notification to agent
$agent = new Model_User($ticket->id_user_support);
$agent->email('new-reply', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $ticketr->description, '[URL.QL]' => $agent->ql('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
} elseif (core::config('email.new_sale_notify')) {
Email::content(core::config('email.notify_email'), NULL, NULL, NULL, 'new-reply', array('[TITLE]' => $ticket->title, '[DESCRIPTION]' => $ticketr->description, '[URL.QL]' => Route::url('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
}
//set empty since they already replied
Request::current()->post('description', '');
Alert::set(Alert::SUCCESS, __('Reply created.'));
} else {
$errors = $validation->errors('ad');
}
}
//getting all the ticket replies
$replies = new Model_Ticket();
$replies = $replies->where('id_ticket_parent', '=', $ticket->id_ticket)->order_by('created', 'asc')->find_all();
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Ticket')));
$this->template->title = $ticket->title . ' - ' . __('Ticket');
//loading agents/admins
$users = NULL;
if ($user->has_access('supportadmin')) {
//getting the roles that have access to the supportadmin since are the agents ;)
$support_roles = array(Model_Role::ROLE_ADMIN);
$access = new Model_Access();
$access = $access->where('access', '=', 'supportadmin.*')->find_all();
foreach ($access as $a) {
$support_roles[] = $a->id_role;
}
//getting agents ;)
$users_db = DB::select('u.id_user')->select('u.name')->from(array('users', 'u'))->where('id_role', 'in', $support_roles)->as_object()->execute();
foreach ($users_db as $key => $value) {
$users[$value->id_user] = $value->name;
}
}
$this->template->bind('content', $content);
$this->template->content = View::factory('oc-panel/pages/support/ticket', array('replies' => $replies, 'ticket' => $ticket, 'users' => $users));
$content->errors = $errors;
}
示例14: email
/**
* sends email to the current user replacing tags
* @param string $seotitle from Model_Content
* @param array $replace
* @param array $file file to be uploaded
* @return boolean
*/
public function email($seotitle, array $replace = NULL, $from = NULL, $from_name = NULL, $file = NULL)
{
if ($this->loaded()) {
return Email::content($this->email, $this->name, $from, $from_name, $seotitle, $replace, $file);
}
return FALSE;
}
示例15: notify_repliers
/**
* send notification of new answer to the repliers of a topic
*/
public function notify_repliers()
{
$data = array('[FORUM.LINK]' => Route::url('forum-topic', array('forum' => $this->forum->seoname, 'seotitle' => $this->seotitle)));
Email::content($this->get_repliers(), '', NULL, NULL, 'new-forum-answer', $data);
}