Example #1
0
 /**
  * Payment deatails and paypal configuration can be configured here
  * @return [view] Renders view with form inputs
  */
 public function action_payment()
 {
     //delete featured plan
     if (is_numeric(Core::get('delete_plan'))) {
         Model_Order::delete_featured_plan(Core::get('delete_plan'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
     }
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Payments')));
     $this->template->title = __('Payments');
     // all form config values
     $paymentconf = new Model_Config();
     $config = $paymentconf->where('group_name', '=', 'payment')->find_all();
     // save only changed values
     if ($this->request->post()) {
         if (is_numeric(Core::request('featured_days')) and is_numeric(Core::request('featured_price'))) {
             Model_Order::set_featured_plan(Core::request('featured_days'), Core::request('featured_price'), Core::request('featured_days_key'));
             Alert::set(Alert::SUCCESS, __('Featured plan updated'));
             $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
         }
         $validation = Validation::factory($this->request->post())->rule('pay_to_go_on_top', 'not_empty')->rule('pay_to_go_on_top', 'numeric')->rule('stripe_appfee', 'numeric')->rule('stripe_appfee', 'range', array(':value', 0, 100))->rule('to_featured', 'range', array(':value', 0, 1))->rule('to_top', 'range', array(':value', 0, 1))->rule('sandbox', 'range', array(':value', 0, 1))->rule('paypal_seller', 'range', array(':value', 0, 1))->rule('stock', 'range', array(':value', 0, 1))->rule('authorize_sandbox', 'range', array(':value', 0, 1))->rule('stripe_address', 'range', array(':value', 0, 1));
         //not updatable fields
         $do_nothing = array('featured_days', 'pay_to_go_on_feature', 'featured_plans');
         if ($validation->check()) {
             foreach ($config as $c) {
                 $config_res = $this->request->post($c->config_key);
                 if (!in_array($c->config_key, $do_nothing) and $config_res != $c->config_value) {
                     if ($c->config_key == 'pay_to_go_on_top') {
                         $config_res = str_replace(',', '.', $config_res);
                     }
                     $c->config_value = $config_res;
                     try {
                         $c->save();
                     } catch (Exception $e) {
                         throw HTTP_Exception::factory(500, $e->getMessage());
                     }
                 }
             }
         } else {
             $errors = $validation->errors('config');
             foreach ($errors as $error) {
                 Alert::set(Alert::ALERT, $error);
             }
             $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
         }
         Alert::set(Alert::SUCCESS, __('Payments Configuration updated'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
     }
     $pages = array('' => __('Deactivated'));
     foreach (Model_Content::get_pages() as $key => $value) {
         $pages[$value->seotitle] = $value->title;
     }
     $this->template->content = View::factory('oc-panel/pages/settings/payment', array('config' => $config, 'pages' => $pages, 'featured_plans' => Model_Order::get_featured_plans()));
 }
Example #2
0
 /**
  * affiliate configuration can be configured here
  * @return [view] Renders view with form inputs
  */
 public function action_affiliates()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Affiliates')));
     $this->template->title = __('Affiliates');
     $this->template->scripts['footer'][] = 'js/jquery.validate.min.js';
     $this->template->scripts['footer'][] = 'js/oc-panel/settings.js';
     // all form config values
     $paymentconf = new Model_Config();
     $config = $paymentconf->where('group_name', '=', 'affiliate')->find_all();
     // save only changed values
     if ($this->request->post()) {
         $validation = Validation::factory($this->request->post())->rule('active', 'range', array(':value', 0, 1))->rule('cookie', 'not_empty')->rule('cookie', 'digit')->rule('payment_days', 'not_empty')->rule('payment_days', 'digit')->rule('payment_min', 'not_empty')->rule('payment_min', 'digit');
         if ($validation->check()) {
             foreach ($config as $c) {
                 $config_res = $this->request->post($c->config_key);
                 if ($config_res != $c->config_value) {
                     $c->config_value = $config_res;
                     try {
                         $c->save();
                     } catch (Exception $e) {
                         echo $e;
                     }
                 }
             }
         } else {
             $errors = $validation->errors('config');
             foreach ($errors as $error) {
                 Alert::set(Alert::ALERT, $error);
             }
             $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'affiliates')));
         }
         Alert::set(Alert::SUCCESS, __('Affiliate Configuration updated'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'affiliates')));
     }
     $pages = array('' => __('Deactivated'));
     foreach (Model_Content::get_pages() as $key => $value) {
         $pages[$value->seotitle] = $value->title;
     }
     $this->template->content = View::factory('oc-panel/pages/settings/affiliates', array('config' => $config, 'pages' => $pages));
 }
Example #3
0
 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     $pages = new Model_Content();
     $pages = $pages->select('seotitle', 'title')->where('type', '=', 'page')->where('status', '=', 1)->order_by('order', 'asc')->cached()->find_all();
     $this->page_items = Model_Content::get_pages();
 }
Example #4
0
            <div class="form-group">
                <?php 
echo FORM::label($forms['contact']['key'], __('Contact form'), array('class' => 'control-label col-sm-3', 'for' => $forms['contact']['key']));
?>
                <div class="col-sm-4">
                    <?php 
echo FORM::select($forms['contact']['key'], array(FALSE => "FALSE", TRUE => "TRUE"), $forms['contact']['value'], array('placeholder' => "", 'class' => 'tips form-control', 'id' => $forms['contact']['key'], 'data-content' => __("Enables Contact Form"), 'data-trigger' => "hover", 'data-placement' => "right", 'data-toggle' => "popover", 'data-original-title' => __("Contact form appears int he ad.")));
?>
 
                </div>
            </div>
			<?php 
$pages = array('' => __('Deactivated'));
?>
			<?php 
foreach (Model_Content::get_pages() as $key => $value) {
    $pages[$value->seotitle] = $value->title;
}
?>
			<div class="form-group">
				<?php 
echo FORM::label($forms['tos']['key'], "<a target='_blank' href='http://open-classifieds.com/2013/08/13/how_to_add_pages/'>" . __('Terms of Service') . "</a>", array('class' => 'control-label col-sm-3', 'for' => $forms['tos']['key']));
?>
				<div class="col-sm-4">
					<?php 
echo FORM::select($forms['tos']['key'], $pages, $forms['tos']['value'], array('placeholder' => "http://foo.com/", 'class' => 'tips form-control', 'id' => $forms['tos']['key'], 'data-content' => __("If you choose to use terms of service, you can select activate. And to edit content, select link 'Content' on your admin panel sidebar. Find page named 'Terms of service' click 'Edit'. In section 'Description' add content that suits you."), 'data-trigger' => "hover", 'data-placement' => "right", 'data-toggle' => "popover", 'data-original-title' => __("Terms of Service")));
?>
 
				</div>
			</div>
			<div class="form-group">
Example #5
0
 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     $this->page_items = Model_Content::get_pages();
 }