コード例 #1
0
ファイル: contact.php プロジェクト: kotsios5/openclassifieds2
 public function action_user_contact()
 {
     $ad = new Model_Ad($this->request->param('id'));
     //message to user
     if ($ad->loaded() and $this->request->post()) {
         $user = new Model_User($ad->id_user);
         //require login to contact
         if ((core::config('advertisement.login_to_contact') == TRUE or core::config('general.messaging') == TRUE) and !Auth::instance()->logged_in()) {
             Alert::set(Alert::INFO, __('Please, login before contacting'));
             HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
         }
         if (captcha::check('contact')) {
             //check if user is loged in
             if (Auth::instance()->logged_in()) {
                 $email_from = $this->user->email;
                 $name_from = $this->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'))) {
                 if (core::config('general.messaging')) {
                     //price?
                     $price = (core::post('price') !== NULL and is_numeric(core::post('price'))) ? core::post('price') : NULL;
                     $ret = Model_Message::send_ad(core::post('message'), $this->user, $ad->id_ad, $price);
                 } else {
                     if (isset($_FILES['file'])) {
                         $file = $_FILES['file'];
                     } else {
                         $file = NULL;
                     }
                     //contact email is set use that one
                     if (isset($ad->cf_contactemail) and Valid::email($ad->cf_contactemail)) {
                         $to = $ad->cf_contactemail;
                     } else {
                         $to = NULL;
                     }
                     $ret = $user->email('user-contact', array('[EMAIL.BODY]' => core::post('message'), '[AD.NAME]' => $ad->title, '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from, '[URL.AD]' => Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))), $email_from, $name_from, $file, $to);
                 }
                 //if succesfully sent
                 if ($ret) {
                     Alert::set(Alert::SUCCESS, __('Your message has been sent'));
                     // we are updating field of visit table (contact)
                     Model_Visit::contact_ad($ad->id_ad);
                 } else {
                     Alert::set(Alert::ERROR, __('Message not sent'));
                 }
                 HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
             } 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, __('Captcha is not correct'));
             HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
         }
     }
 }
コード例 #2
0
ファイル: contact.php プロジェクト: Wildboard/WbWebApp
 public function action_userprofile_contact()
 {
     $user = new Model_User($this->request->param('id'));
     //message to user
     if ($user->loaded() and $this->request->post()) {
         if (captcha::check('contact')) {
             //akismet spam filter
             if (!core::akismet(core::post('name'), core::post('email'), core::post('message'))) {
                 $ret = $user->email('userprofile.contact', array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => core::post('name'), '[EMAIL.SUBJECT]' => core::post('subject'), '[EMAIL.FROM]' => core::post('email')), core::post('email'), core::post('name'));
                 //if succesfully sent
                 if ($ret) {
                     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, __('You made some mistake'));
         }
         Request::current()->redirect(Route::url('profile', array('seoname' => $user->seoname)));
     }
 }
コード例 #3
0
 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     $user = Auth::instance()->get_user();
     $id = $this->request->param('id');
     if (isset($id)) {
         $active_ad = new Model_Ad($id);
         if ($active_ad->loaded()) {
             $activate = FALSE;
             //admin whatever he wants
             if ($user->id_role == Model_Role::ROLE_ADMIN) {
                 $activate = TRUE;
             } elseif ($user->id_user == $active_ad->id_user and !in_array(core::config('general.moderation'), Model_Ad::$moderation_status)) {
                 $activate = TRUE;
             } else {
                 Alert::set(Alert::ALERT, __("This is not your advertisement."));
             }
             //its not published
             if ($active_ad->status == Model_Ad::STATUS_PUBLISHED) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement is already marked as 'active'"));
             }
             //pending payment
             if ($activate === TRUE and ($order = $active_ad->get_order()) !== FALSE and $order->status == Model_Order::STATUS_CREATED) {
                 $activate = FALSE;
                 Alert::set(Alert::ALERT, __("Advertisement can not be marked as “active”. There is a pending payment."));
             }
             //activate the ad
             if ($activate === TRUE) {
                 $active_ad->published = Date::unix2mysql(time());
                 $active_ad->status = Model_Ad::STATUS_PUBLISHED;
                 try {
                     $active_ad->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
             } else {
                 HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
             }
         } else {
             //throw 404
             throw HTTP_Exception::factory(404, __('Page not found'));
         }
     }
     // send confirmation email
     $cat = new Model_Category($active_ad->id_category);
     $usr = new Model_User($active_ad->id_user);
     if ($usr->loaded()) {
         //we get the QL, and force the regen of token for security
         $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $active_ad->seotitle), TRUE);
         $ret = $usr->email('ads-activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $active_ad->title));
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')));
 }
コード例 #4
0
ファイル: ad.php プロジェクト: azorpax/openclassifieds2
 public function sale(Model_User $user_buyer)
 {
     if ($this->loaded()) {
         // decrease limit of ads, if 0 deactivate
         if ($this->stock > 0) {
             $stock = $this->stock - 1;
             //deactivate the ad
             if ($stock == 0) {
                 $this->status = Model_Ad::STATUS_UNAVAILABLE;
                 //send email to owner that the he run out of stock
                 $url_edit = $user->ql('oc-panel', array('controller' => 'myads', 'action' => 'update', 'id' => $this->id_ad), TRUE);
                 $email_content = array('[URL.EDIT]' => $url_edit, '[AD.TITLE]' => $this->title);
                 // send email to ad OWNER
                 $this->user->email('out-of-stock', $email_content);
             }
         }
         try {
             $this->save();
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         $url_ad = Route::url('ad', array('category' => $this->category->seoname, 'seotitle' => $this->seotitle));
         $email_content = array('[URL.AD]' => $url_ad, '[AD.TITLE]' => $this->title, '[ORDER.ID]' => $this->id_order, '[PRODUCT.ID]' => $this->id_product);
         // send email to BUYER
         $user_buyer->email('ads-purchased', $email_content);
         // send email to ad OWNER
         $this->user->email('ads-sold', $email_content);
     }
 }
コード例 #5
0
ファイル: ad.php プロジェクト: Wildboard/WbWebApp
 public function multiple_mails($receivers)
 {
     foreach ($receivers as $num => $receiver_id) {
         if (is_numeric($receiver_id)) {
             $ad = new Model_Ad($receiver_id);
             $cat = new Model_Category($ad->id_category);
             $usr = new Model_User($ad->id_user);
             if ($usr->loaded()) {
                 $edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $ad->id_ad;
                 $delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $ad->id_ad;
                 //we get the QL, and force the regen of token for security
                 $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $ad->seotitle), TRUE);
                 $ret = $usr->email('ads.activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
             }
         }
     }
 }
コード例 #6
0
ファイル: support.php プロジェクト: Ryanker/open-eshop
 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;
 }
コード例 #7
0
ファイル: profile.php プロジェクト: Wildboard/WbWebApp
 /**
  * Mark advertisement as active : STATUS = 1
  */
 public function action_activate()
 {
     $id = $this->request->param('id');
     if (isset($id)) {
         $active_ad = new Model_Ad($id);
         if ($active_ad->loaded()) {
             if (Auth::instance()->get_user()->id_user !== $active_ad->id_user or Auth::instance()->get_user()->id_role !== Model_Role::ROLE_ADMIN and Auth::instance()->get_user()->id_user == 1) {
                 Alert::set(Alert::ALERT, __("This is not your advertisement."));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
             } elseif ($active_ad->status != 1) {
                 $active_ad->published = Date::unix2mysql(time());
                 $active_ad->status = 1;
                 try {
                     $active_ad->save();
                 } catch (Exception $e) {
                     throw new HTTP_Exception_500($e->getMessage());
                 }
             } else {
                 Alert::set(Alert::ALERT, __("Advertisement is already marked as 'active'"));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
             }
         } else {
             //throw 404
             throw new HTTP_Exception_404();
         }
     }
     // send confirmation email
     $cat = new Model_Category($active_ad->id_category);
     $usr = new Model_User($active_ad->id_user);
     if ($usr->loaded()) {
         $edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $active_ad->id_ad;
         $delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $active_ad->id_ad;
         //we get the QL, and force the regen of token for security
         $url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $active_ad->seotitle), TRUE);
         $ret = $usr->email('ads.activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $active_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
     }
     if (Core::config('sitemap.on_post') == TRUE) {
         Sitemap::generate();
     }
     Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
     Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
 }
コード例 #8
0
ファイル: order.php プロジェクト: Wildboard/WbWebApp
 /**
  * confirm payment for order
  *
  * @param string    $id_order [unique indentifier of order]
  * @param int       $id_user  [unique indentifier of user] 
  */
 public function confirm_payment($id_order, $moderation)
 {
     $orders = new self();
     $orders->where('id_order', '=', $id_order)->where('status', '=', 0)->limit(1)->find();
     $id_ad = $orders->id_ad;
     $product_find = new Model_Ad();
     $product_find = $product_find->where('id_ad', '=', $id_ad)->limit(1)->find();
     $categ = new Model_Category($product_find->id_category);
     $user = new Model_User($orders->id_user);
     // update orders
     if ($orders->loaded()) {
         $orders->status = 1;
         $orders->pay_date = Date::unix2mysql(time());
         try {
             $orders->save();
         } catch (Exception $e) {
             echo $e;
         }
     }
     // update product
     if ($orders->id_product == Paypal::category_product) {
         if ($moderation == Model_Ad::PAYMENT_ON) {
             $product_find->published = Date::unix2mysql(time());
             $product_find->status = 1;
             try {
                 $product_find->save();
                 //we get the QL, and force the regen of token for security
                 $url_cont = $user->ql('contact', array(), TRUE);
                 $url_ad = $user->ql('ad', array('category' => $product_find->id_category, 'seotitle' => $product_find->seotitle), TRUE);
                 $ret = $user->email('ads.user_check', array('[URL.CONTACT]' => $url_cont, '[URL.AD]' => $url_ad, '[AD.NAME]' => $product_find->title));
             } catch (Exception $e) {
                 echo $e;
             }
         } else {
             if ($moderation == Model_Ad::PAYMENT_MODERATION) {
                 $product_find->published = Date::unix2mysql(time());
                 try {
                     $product_find->save();
                     $edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $product_find->id_ad;
                     $delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $product_find->id_ad;
                     //we get the QL, and force the regen of token for security
                     $url_ql = $user->ql('oc-panel', array('controller' => 'profile', 'action' => 'update', 'id' => $orders->id_ad), TRUE);
                     $ret = $user->email('ads.notify', array('[URL.QL]' => $url_ql, '[AD.NAME]' => $product_find->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
                 } catch (Exception $e) {
                 }
             }
         }
     } elseif ($orders->id_product == Paypal::to_top) {
         $product_find->published = Date::unix2mysql(time());
         try {
             $product_find->save();
         } catch (Exception $e) {
             echo $e;
         }
     } elseif ($orders->id_product == Paypal::to_featured) {
         $product_find->featured = Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60);
         try {
             $product_find->save();
         } catch (Exception $e) {
             echo $e;
         }
     }
 }
コード例 #9
0
 public function action_userprofile_contact()
 {
     $user = new Model_User($this->request->param('id'));
     //message to user
     if ($user->loaded() and $this->request->post()) {
         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'))) {
                 if (core::config('general.messaging')) {
                     $ret = Model_Message::send_user(core::post('message'), $this->user->id_user, $user->id_user);
                     if ($ret !== FALSE) {
                         $user->email('messaging-user-contact', array('[FROM.NAME]' => $this->user->name, '[TO.NAME]' => $user->name, '[DESCRIPTION]' => core::post('message'), '[URL.QL]' => $user->ql('oc-panel', array('controller' => 'messages', 'action' => 'message', 'id' => $ret->id_message))));
                     }
                 } else {
                     $ret = $user->email('user-profile-contact', array('[EMAIL.BODY]' => core::post('message'), '[EMAIL.SENDER]' => $name_from, '[EMAIL.SUBJECT]' => core::post('subject'), '[EMAIL.FROM]' => $email_from), $email_from, core::post('name'));
                 }
                 //if succesfully sent
                 if ($ret) {
                     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, __('Captcha is not correct'));
         }
         HTTP::redirect(Route::url('profile', array('seoname' => $user->seoname)));
     }
 }