Inheritance: extends MY_Controller
Ejemplo n.º 1
0
 public static function send($id_user, $content)
 {
     $alert = new Alert();
     $alert->id_user = (int) $id_user;
     $alert->is_read = 0;
     $alert->content = pSQL($content);
     $alert->add_date = "";
     return $alert->add();
 }
 /**
  * @brief 	Envoie un message à un membre
  * @param	int		$idUser 	ID du membre qui doit recevoir le message
  * @param	String	$msg 		Message à envoyer
  * @return	Error	Retourne une information
  */
 public function sendMessage($idUser, $msg)
 {
     $privateAlert = new Alert();
     $privateAlert->setIdMember($idUser);
     $privateAlert->setMessage($msg);
     $privateAlert->setTitle('Message de l\'administrateur');
     AlertsManager::instance()->add($privateAlert);
     return new Error("Votre message a bien été envoyé");
 }
Ejemplo n.º 3
0
 public function addAlert()
 {
     $input = Input::all();
     $alert = new Alert();
     $alert->value = $input['value'];
     $alert->condition = $input['condition'];
     $alert->user_id = $input['user'];
     $alert->owner_user_id = $input['user'];
     $alert->save();
     return Redirect::to('/alerts');
 }
Ejemplo n.º 4
0
	public function index(){
		$alert = DAO::getOne("Alert", "idUser = "******"Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche");
		
		$this->loadView("alert/vEdit", array('alert' => $alert, "days" => $days));

	}
Ejemplo n.º 5
0
 public function testbean_implements()
 {
     error_reporting(E_ERROR | E_PARSE);
     $alert = new Alert();
     $this->assertEquals(false, $alert->bean_implements(''));
     //test with empty value
     $this->assertEquals(false, $alert->bean_implements('test'));
     //test with invalid value
     $this->assertEquals(true, $alert->bean_implements('ACL'));
     //test with valid value
 }
function processAlerts()
{
    if (isset($_POST[POST_INTERN_PROCESS_ALERTS . "_va"])) {
        $alerts = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_ALERTS . "_va"]));
        $visitors = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_ALERTS . "_vb"]);
        $browsers = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_ALERTS . "_vc"]);
        foreach ($alerts as $key => $text) {
            $alert = new Alert($visitors[$key], $browsers[$key], $alerts[$key]);
            $alert->Save();
        }
    }
}
Ejemplo n.º 7
0
 /**
  *
  * Contruct that checks you are loged in before nothing else happens!
  */
 function __construct(Request $request, Response $response)
 {
     if (Theme::get('premium') != 1) {
         Alert::set(Alert::INFO, __('Upgrade your Open Classifieds site to activate this feature.'));
     }
     parent::__construct($request, $response);
 }
Ejemplo n.º 8
0
 public function action_status()
 {
     $status = (bool) $this->request->param('id');
     Model_Config::set_value('general', 'cron', $status);
     Alert::set(Alert::SUCCESS, __('General Configuration updated'));
     $this->redirect(Route::url('oc-panel', array('controller' => 'crontab')));
 }
Ejemplo n.º 9
0
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $order_id = $this->request->param('id');
     $order = new Model_Order();
     $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // case when selling advert
         if ($order->id_product == Model_Order::PRODUCT_AD_SELL) {
             $paypal_account = $order->ad->paypal_account();
             $currency = i18n::get_intl_currency_symbol();
             if (isset($order->ad->cf_shipping) and Valid::numeric($order->ad->cf_shipping) and $order->ad->cf_shipping > 0) {
                 $order->amount = $order->amount + $order->ad->cf_shipping;
             }
         } else {
             $paypal_account = core::config('payment.paypal_account');
             $currency = core::config('payment.paypal_currency');
         }
         $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
         $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => $paypal_account, 'paypal_currency' => $currency, 'item_name' => $order->description);
         $this->template = View::factory('paypal', $paypal_data);
         $this->response->body($this->template->render());
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default'));
     }
 }
Ejemplo n.º 10
0
 /**
  * CRUD controller: UPDATE
  */
 public function action_update()
 {
     $id_role = $this->request->param('id');
     //we do not allow modify the admin
     if ($id_role == Model_Role::ROLE_ADMIN) {
         Alert::set(Alert::WARNING, __('Admin Role can not be modified!'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'role')));
     }
     $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $id_role;
     $role = new Model_Role($id_role);
     if ($this->request->post() and $role->loaded()) {
         //delete all the access
         DB::delete('access')->where('id_role', '=', $role->id_role)->execute();
         //set all the access where post = on
         foreach ($_POST as $key => $value) {
             if ($value == 'on') {
                 DB::insert('access', array('id_role', 'access'))->values(array($role->id_role, str_replace('|', '.', $key)))->execute();
             }
         }
         //saving the role params
         $role->name = core::post('name');
         $role->description = core::post('description');
         $role->save();
         Alert::set(Alert::SUCCESS, __('Item updated'));
         $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())));
     }
     //getting controllers actions
     $controllers = Model_Access::list_controllers();
     //get all the access this user has
     $query = DB::select('access')->from('access')->where('id_role', '=', $id_role)->execute();
     $access_in_use = array_keys($query->as_array('access'));
     // d(in_array('access_index',$access_in_use));
     //d($access_in_use);
     return $this->render('oc-panel/pages/role/update', array('role' => $role, 'controllers' => $controllers, 'access_in_use' => $access_in_use));
 }
Ejemplo n.º 11
0
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     //sandobx doesnt do the x_receipt_link_url redirect so in sanbbox instead we put the order id
     $id_order = Core::config('payment.twocheckout_sandbox') == 1 ? Core::request('x_receipt_link_url') : $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //its a fraud...lets let him know
         if ($order->is_fraud() === TRUE) {
             Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
             $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
         }
         if (($order_id = twocheckout::validate_passback($order)) !== FALSE) {
             //mark as paid
             $order->confirm_payment('2checkout', $order_id, NULL, NULL, NULL, Twocheckout::calculate_fee($order->amount));
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
             $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'goal', 'id' => $order->id_order)));
         } else {
             Alert::set(Alert::INFO, __('Please fill your card details.'));
             $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default'));
     }
 }
Ejemplo n.º 12
0
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_form()
 {
     $this->auto_render = FALSE;
     $order_id = $this->request->param('id');
     $order = new Model_Order();
     $order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // dependant on product we have different names
         if ($order->id_product == Paypal::to_featured) {
             $item_name = __('Advertisement to featured');
         } else {
             if ($order->id_product == Paypal::to_top) {
                 $item_name = __('Advertisement to top');
             } else {
                 $item_name = $order->description . __(' category');
             }
         }
         $paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
         $paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => core::config('payment.paypal_account'), 'paypal_currency' => core::config('payment.paypal_currency'), 'item_name' => $item_name);
         $this->template = View::factory('paypal', $paypal_data);
         $this->response->body($this->template->render());
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->request->redirect(Route::url('default'));
     }
 }
Ejemplo n.º 13
0
 /**
  * sends an email using our configs
  * @param  string/array $to       array(array('name'=>'chema','email'=>'chema@'),)
  * @param  [type] $to_name   [description]
  * @param  [type] $subject   [description]
  * @param  [type] $body      [description]
  * @param  [type] $reply     [description]
  * @param  [type] $replyName [description]
  * @param  [type] $file      [description]
  * @return boolean
  */
 public static function send($to, $to_name = '', $subject, $body, $reply, $replyName, $file = NULL)
 {
     require_once Kohana::find_file('vendor', 'php-mailer/phpmailer', 'php');
     $body = Text::bb2html($body, TRUE);
     //get the template from the html email boilerplate
     $body = View::factory('email', array('title' => $subject, 'content' => nl2br($body)))->render();
     $mail = new PHPMailer();
     $mail->CharSet = Kohana::$charset;
     if (core::config('email.smtp_active') == TRUE) {
         $mail->IsSMTP();
         //SMTP HOST config
         if (core::config('email.smtp_host') != "") {
             $mail->Host = core::config('email.smtp_host');
             // sets custom SMTP server
         }
         //SMTP PORT config
         if (core::config('email.smtp_port') != "") {
             $mail->Port = core::config('email.smtp_port');
             // set a custom SMTP port
         }
         //SMTP AUTH config
         if (core::config('email.smtp_auth') == TRUE) {
             $mail->SMTPAuth = TRUE;
             // enable SMTP authentication
             $mail->Username = core::config('email.smtp_user');
             // SMTP username
             $mail->Password = core::config('email.smtp_pass');
             // SMTP password
             if (core::config('email.smtp_ssl') == TRUE) {
                 $mail->SMTPSecure = "ssl";
                 // sets the prefix to the server
             }
         }
     }
     $mail->From = core::config('email.notify_email');
     $mail->FromName = "no-reply " . core::config('general.site_name');
     $mail->Subject = $subject;
     $mail->MsgHTML($body);
     if ($file !== NULL) {
         $mail->AddAttachment($file['tmp_name'], $file['name']);
     }
     $mail->AddReplyTo($reply, $replyName);
     //they answer here
     if (is_array($to)) {
         foreach ($to as $contact) {
             $mail->AddBCC($contact['email'], $contact['name']);
         }
     } else {
         $mail->AddAddress($to, $to_name);
     }
     $mail->IsHTML(TRUE);
     // send as HTML
     if (!$mail->Send()) {
         //to see if we return a message or a value bolean
         Alert::set(Alert::ALERT, "Mailer Error: " . $mail->ErrorInfo);
         return FALSE;
     } else {
         return TRUE;
     }
 }
Ejemplo n.º 14
0
function addUser($args)
{
    global $dbUsers;
    global $Language;
    // Check if the username already exist in db.
    if (Text::isEmpty($args['username'])) {
        Alert::set($Language->g('username-field-is-empty'));
        return false;
    }
    if ($dbUsers->userExists($args['username'])) {
        Alert::set($Language->g('username-already-exists'));
        return false;
    }
    // Validate password.
    if ($args['password'] != $args['confirm-password'] || Text::isEmpty($args['password'])) {
        Alert::set($Language->g('The password and confirmation password do not match'));
        return false;
    }
    // Add the user.
    if ($dbUsers->add($args)) {
        Alert::set($Language->g('user-has-been-added-successfully'));
        return true;
    } else {
        Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to create the account.');
        return false;
    }
}
Ejemplo n.º 15
0
 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');
 }
Ejemplo n.º 16
0
 /**
  * initializeAlerts - initialize alert object
  *
  */
 public function initializeAlerts()
 {
     if (isset(self::$alertDataArray)) {
         unset(self::$alertDataArray);
     }
     self::$alertDataArray = array();
 }
Ejemplo n.º 17
0
 /**
  * 初始化
  */
 public function init()
 {
     parent::init();
     $this->topic = new TopicModel();
     $this->referer = isset($_SERVER["HTTP_REFERER"]) ? str_replace('http://' . $_SERVER['HTTP_HOST'], '', $_SERVER["HTTP_REFERER"]) : '/admin/index/index';
     //设置白名单(在白名单内不需要tid,否则需要提供tid
     //这样可以避免在专题相关的控制器和方法中再次判断 用户对专题权限
     $url_arr = array("/admin/topic/index", "/admin/topic/index/", "/admin/topicdata/index", "/admin/topicdata/index/", "/admin/topic/add/", "/admin/topic/add", "/admin/topicdata/trashindex", "/admin/topicdata/trashindex/");
     if (!in_array($_SERVER['REQUEST_URI'], $url_arr)) {
         $tid = $this->getRequest()->getQuery("tid");
         //如果不存在tid 非法请求
         if (!$tid) {
             Alert::danger("非法请求");
             Yaf_Controller_Abstract::redirect("/admin/topic/index/");
             exit;
         }
         //根据tid查询当前用户是否是管理员或者是该专题的所有者,如果不是则提示权限不足
         if (!$this->checkrole($tid)) {
             Alert::danger("权限不足");
             Yaf_Controller_Abstract::redirect("/admin/topic/index/");
             exit;
         }
     }
     //判断是否是管理员 并赋值给模板
     $this->getView()->assign("is_admin", $this->is_admin());
 }
Ejemplo n.º 18
0
 /**
  * Update new forum
  */
 public function action_update()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Topic')));
     $topic = new Model_Topic($this->request->param('id'));
     $get_all = Model_Forum::get_all();
     //get all forums to build forum parents in select
     $forum_parents = array();
     foreach ($get_all[0] as $parent) {
         $forum_parents[$parent['id']] = $parent['name'];
     }
     $this->template->content = View::factory('oc-panel/pages/forum/topic', array('topic' => $topic, 'forum_parents' => $forum_parents));
     if ($_POST) {
         $topic->title = core::post('title');
         $topic->id_forum = core::post('id_forum');
         $topic->description = core::post('description');
         if (core::post('seotitle') != $topic->seotitle) {
             $topic->seotitle = $topic->gen_seotitle(core::post('seotitle'));
         }
         if (core::post('status') == 'on') {
             $topic->status = 1;
         } else {
             $topic->status = 0;
         }
         try {
             $topic->save();
             Alert::set(Alert::SUCCESS, __('Topic is updated.'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'topic', 'action' => 'index')));
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     LoginForm::checkLogin();
     $this->pageTitle = "Create Maternal Health Record";
     if (!Patient::model()->findByPk($id)) {
         Alert::alertMessage('danger', 'Patient does not exist.');
         Yii::app()->getController()->redirect(array('patient/index'));
     }
     if (MaternalHealth::model()->findByAttributes(array('patient_id' => $id))) {
         Alert::alertMessage('danger', 'Maternal Health Record for this patient already exists.');
         Yii::app()->getController()->redirect(array('patient/view', 'id' => $id));
     }
     $model = new MaternalHealth();
     $patient_model = Patient::model()->findByPk($id);
     $model->patient_id = $patient_model->id;
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['MaternalHealth'])) {
         $model->attributes = $_POST['MaternalHealth'];
         if (isset($_POST['MaternalHealth']['checklist']) && $_POST['MaternalHealth']['checklist'] !== "") {
             $model->checklist = implode(';', $_POST['MaternalHealth']['checklist']);
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     if (isset($model->checklist) && $model->checklist !== '') {
         $model->checklist = explode(';', $model->checklist);
     }
     $this->render('create', array('model' => $model, 'patient_model' => $patient_model));
 }
Ejemplo n.º 20
0
 public function action_result()
 {
     $this->auto_render = FALSE;
     $id_order = Core::request('id_order');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //its a fraud...lets let him know
         if ($order->is_fraud() === TRUE) {
             Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
         //correct payment?
         if (($result = paguelofacil::check_result()) === TRUE) {
             //mark as paid
             $order->confirm_payment('paguelofacil', Core::request('Oper'));
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             Alert::set(Alert::INFO, __('Transaction not successful!'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
Ejemplo n.º 21
0
function deleteUser($args, $deleteContent = false)
{
    global $dbUsers;
    global $dbPosts;
    global $Language;
    global $Login;
    // The user admin cannot be deleted.
    if ($args['username'] == 'admin') {
        return false;
    }
    // The editors cannot delete users.
    if ($Login->role() !== 'admin') {
        return false;
    }
    if ($deleteContent) {
        $dbPosts->deletePostsByUser($args['username']);
    } else {
        $dbPosts->linkPostsToUser($args['username'], 'admin');
    }
    if ($dbUsers->delete($args['username'])) {
        Alert::set($Language->g('User deleted'));
    } else {
        Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to delete the user.');
    }
}
 static function showFormAlerts($target)
 {
     $self = new self();
     $self->getFromDB(1);
     echo "<form action='{$target}' method='post'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Reminders frequency', 'additionalalerts') . " " . PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</td><td>";
     Alert::dropdownYesNo(array('name' => "use_infocom_alert", 'value' => $self->fields["use_infocom_alert"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td >" . __('Reminders frequency', 'additionalalerts') . " " . __('New imported computers from OCS-NG', 'additionalalerts') . "</td><td>";
     Alert::dropdownYesNo(array('name' => "use_newocs_alert", 'value' => $self->fields["use_newocs_alert"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td >" . __('OCS-NG Synchronization alerts', 'additionalalerts') . "</td><td>";
     Alert::dropdownIntegerNever('delay_ocs', $self->fields["delay_ocs"], array('max' => 99));
     echo "&nbsp;" . _n('Day', 'Days', 2) . "</td></tr>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td class='center' colspan='2'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<input class='submit' type='submit' name='update' value='" . _sx('button', 'Save') . "'>";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
 }
Ejemplo n.º 23
0
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //its a fraud...lets let him know
         if ($order->is_fraud() === TRUE) {
             Alert::set(Alert::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
         if (($order_id = twocheckout::validate_passback($order)) !== FALSE) {
             //mark as paid
             $order->confirm_payment('2checkout', $order_id);
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             Alert::set(Alert::INFO, __('Please fill your card details.'));
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_pay()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         // include class vendor
         require Kohana::find_file('vendor/authorize/', 'autoload');
         define('AUTHORIZENET_API_LOGIN_ID', Core::config('payment.authorize_login'));
         define('AUTHORIZENET_TRANSACTION_KEY', Core::config('payment.authorize_key'));
         define('AUTHORIZENET_SANDBOX', Core::config('payment.authorize_sandbox'));
         $sale = new AuthorizeNetAIM();
         $sale->amount = $order->amount;
         $sale->card_num = Core::post('card-number');
         $sale->exp_date = Core::post('expiry-month') . '/' . Core::post('expiry-year');
         $response = $sale->authorizeAndCapture();
         if ($response->approved) {
             $order->confirm_payment('authorize', $response->transaction_id);
             //redirect him to his ads
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!') . ' ' . $response->transaction_id);
             $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
         } else {
             Alert::set(Alert::INFO, $response->error_message);
             $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
 public function destroy($id)
 {
     $category = $this->categoriesRepo->findOrFail($id);
     $this->categoriesRepo->delete($category);
     \Alert::message("CMS::categories.msg_category_deleted");
     return redirect()->route('CMS::admin.categories.index');
 }
Ejemplo n.º 26
0
 function __construct(Request $request, Response $response)
 {
     if (Theme::get('premium') != 1) {
         Alert::set(Alert::INFO, __('Upgrade your Yclas site to activate this feature.'));
     }
     $this->_filter_fields = array('id_user' => 'INPUT', 'expire_date' => 'DATE', 'created' => 'DATE', 'id_plan' => array('type' => 'SELECT', 'table' => 'plans', 'key' => 'id_plan', 'value' => 'seoname'), 'status' => array(0 => 'Inactive', 1 => 'Active'));
     parent::__construct($request, $response);
 }
 function test_chains_methods_to_build_complex_alert_messages()
 {
     // Having
     $items = ['Laravel courses', 'OOP classes', 'Access to real projects', 'Support', 'And more'];
     Alert::info('Your account is about to expire')->details('A lot of knowledge still waits for you:')->items($items)->button('Renew now!', '#', 'primary')->button('Take me to your leader', 'http://google.com', 'info');
     // Expect
     $this->assertTemplate('alerts/complex', Alert::render());
 }
 public function saveSettings()
 {
     $data = Input::all();
     $profile = new Profile();
     $profile->deleteMyEmailNotifications(Auth::id());
     $profile->saveMyEmailNotifications(Auth::id(), $data);
     return Alert::flash(Lang::get('auth.settings-updated'), 'success');
 }
Ejemplo n.º 29
0
 public function thumbsUp($id, $slug)
 {
     $post = Post::where('id', $id)->where('slug', $slug)->with('user.profile')->firstOrFail();
     if (!Vote::setVotePoints($post)) {
         return Alert::flash(Lang::get('post.vote'), 'warning');
     }
     return Redirect::action('post', [$id, $slug]);
 }
Ejemplo n.º 30
0
 public static function allowOnlyRefer($inputData)
 {
     $refer = Http::get('refer');
     $inputData = str_replace('/', '\\/', $inputData);
     if (!preg_match('/' . $inputData . '/i', $refer)) {
         Alert::make('Page not found');
     }
 }