예제 #1
0
 /**
  * Deletes a single record while ignoring relationships.
  *
  * @chainable
  * @throws Kohana_Exception
  * @return ORM
  */
 public function delete()
 {
     if (!$this->_loaded) {
         throw new Kohana_Exception('Cannot delete :model model because it is not loaded.', array(':model' => $this->_object_name));
     }
     //remove image
     $this->delete_image();
     //remove ads, will remove reviews, images etc...
     $ads = new Model_Ad();
     $ads = $ads->where('id_user', '=', $this->id_user)->find_all();
     foreach ($ads as $ad) {
         $ad->delete();
     }
     //bye profile pic
     $this->delete_image();
     //delete favorites
     DB::delete('favorites')->where('id_user', '=', $this->id_user)->execute();
     //delete reviews
     DB::delete('reviews')->where('id_user', '=', $this->id_user)->execute();
     //delete orders
     DB::delete('orders')->where('id_user', '=', $this->id_user)->execute();
     //delete subscribtions
     DB::delete('subscribers')->where('id_user', '=', $this->id_user)->execute();
     //delete posts
     DB::delete('posts')->where('id_user', '=', $this->id_user)->execute();
     //delete messages
     DB::delete('messages')->where('id_user_from', '=', $this->id_user)->or_where('id_user_to', '=', $this->id_user)->execute();
     //unsusbcribe from elasticemail
     if (Core::config('email.elastic_listname') != '') {
         ElasticEmail::unsubscribe(Core::config('email.elastic_listname'), $this->email);
     }
     parent::delete();
 }
예제 #2
0
 public function action_unsubscribe()
 {
     $id_subscribe = $this->request->param('id');
     $subscription = new Model_Subscribe($id_subscribe);
     if ($subscription->loaded() and $subscription->id_user == Auth::instance()->get_user()->id_user) {
         try {
             $subscription->delete();
             Alert::set(Alert::SUCCESS, __('You are unsubscribed'));
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         //unsusbcribe from elasticemail
         if (Core::config('email.elastic_listname') != '') {
             ElasticEmail::subscribe(Core::config('email.elastic_listname'), Auth::instance()->get_user()->email);
         }
         $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'subscriptions')));
     }
 }
예제 #3
0
 public function action_unsubscribe()
 {
     $email_encoded = $this->request->param('id');
     $user = new Model_User();
     //mail encoded
     if ($email_encoded !== NULL) {
         //decode emails
         $email_encoded = Base64::fix_from_url($email_encoded);
         $encrypt = new Encrypt(Core::config('auth.hash_key'), MCRYPT_MODE_NOFB, MCRYPT_RIJNDAEL_128);
         $email = $encrypt->decode($email_encoded);
         if (Valid::email($email)) {
             //check we have this email in the DB
             $user = new Model_User();
             $user = $user->where('email', '=', $email)->limit(1)->find();
         } else {
             Alert::set(Alert::INFO, __('Not valid email.'));
         }
     } elseif (Auth::instance()->logged_in()) {
         $user = Auth::instance()->get_user();
     }
     //lets unsubscribe the user
     if ($user->loaded()) {
         $user->subscriber = 0;
         $user->last_modified = Date::unix2mysql();
         try {
             $user->save();
             Alert::set(Alert::SUCCESS, __('You have successfully unsubscribed'));
         } catch (Exception $e) {
             //throw 500
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         //unsusbcribe from elasticemail
         if (Core::config('email.elastic_listname') != '') {
             ElasticEmail::unsubscribe(Core::config('email.elastic_listname'), $user->email);
         }
     } else {
         Alert::set(Alert::INFO, __('Please login to unsubscribe.'));
     }
     //smart redirect
     if (Auth::instance()->logged_in()) {
         $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit')));
     } else {
         $this->redirect(Route::url('default'));
     }
 }
예제 #4
0
 public function enviar()
 {
     $data = Sfphp_Peticion::get('_parametros');
     $html = Curl::getWebPage(BASE_URL . "cotizaciones/formatopublico/id/" . base64_encode($data['id']));
     echo ElasticEmail::send($data['correo'], "Cotización", "", $html, "*****@*****.**", "Nats S.A. de C.V.");
 }