Ejemplo n.º 1
0
 function index()
 {
     // we'll show varying levels of blank state screens
     // do we have a consumer key and secret?
     if (setting('twitter_consumer_key') == '' or setting('twitter_consumer_secret') == '') {
         return redirect('admincp/twitter/register_application');
     }
     // we have an app setup, but we may need the OAuth token...
     if (setting('twitter_oauth_token') == '' or setting('twitter_oauth_token_secret') == '') {
         return redirect('admincp/twitter/update_oauth');
     }
     // we have oauth tokens, but let's make sure they are up-to-date
     require APPPATH . 'modules/twitter/libraries/twitteroauth.php';
     $connection = new TwitterOAuth(setting('twitter_consumer_key'), setting('twitter_consumer_secret'), setting('twitter_oauth_token'), setting('twitter_oauth_token_secret'));
     $test = $connection->get('account/verify_credentials');
     if ($connection->http_code != 200) {
         // connection failed
         $this->notices->SetError('Your Twitter OAuth tokens are out of date!  Please re-authorize.');
         return redirect('admincp/twitter/update_oauth');
     }
     // Twitter credentials are solid!
     $this->admin_navigation->module_link('Update Application Credentials', site_url('admincp/twitter/register_application'));
     $this->admin_navigation->module_link('Update Authorization Tokens', site_url('admincp/twitter/update_oauth'));
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('Twitter Configuration');
     // get content types
     $this->load->model('publish/content_type_model');
     $types = $this->content_type_model->get_content_types(array('is_standard' => '1'));
     $type_options = array();
     foreach ($types as $type) {
         $type_options[$type['id']] = $type['name'];
     }
     // get topics
     $this->load->model('publish/topic_model');
     $topics = $this->topic_model->get_tiered_topics();
     $topic_options = array();
     $topic_options[0] = 'Any Topic';
     foreach ($topics as $topic) {
         $topic_options[$topic['id']] = $topic['name'];
     }
     $form->value_row(' ', 'Configure ' . setting('app_name') . ' to automatically tweet your latest content with the options below.');
     $checked = setting('twitter_enabled') == '1' ? TRUE : FALSE;
     $form->checkbox('Enable Tweeting?', 'enabled', '1', $checked);
     $selected = setting('twitter_content_types') != '' ? unserialize(setting('twitter_content_types')) : array();
     $form->dropdown('Content Types', 'content_types', $type_options, $selected, TRUE, FALSE, 'Only posts of these content types will be tweeted.');
     $selected = setting('twitter_topics') != '' ? unserialize(setting('twitter_topics')) : array();
     $form->dropdown('Topics', 'topics', $topic_options, $selected, TRUE, FALSE, 'Only posts in these topics will be tweeted.');
     //$value = (setting('twitter_template') == '') ? '[TITLE]: [URL]' : setting('twitter_template');
     //$form->textarea('Tweet Template','template',$value,'Specify the format of the Tweet.  You may use the tags: [SITE_NAME], [TITLE], and [URL].');
     $data = array('form_title' => 'Twitter: Configuration', 'form_action' => site_url('admincp/twitter/post_config'), 'form' => $form->display(), 'form_button' => 'Save Configuration');
     $this->load->view('generic', $data);
 }
Ejemplo n.º 2
0
 private function build_coupon_form($coupon = array(), $id = 0)
 {
     $this->load->model('store/shipping_model');
     $this->load->model('store/products_model');
     $this->load->model('billing/subscription_plan_model');
     // Get the required options
     $coupon_products = isset($coupon['products']) ? $coupon['products'] : array();
     $coupon_plans = isset($coupon['plans']) ? $coupon['plans'] : array();
     $coupon_shipping = isset($coupon['shipping']) ? $coupon['shipping'] : array();
     $coupon_types = $this->coupon_model->get_coupon_types();
     foreach ($coupon_types as $type) {
         $type_options[$type->coupon_type_id] = $type->coupon_type_name;
     }
     $reduction_options = array(0 => '%', 1 => setting('currency_symbol'));
     $products = $this->products_model->get_products();
     $product_options = array();
     $product_options['-1'] = 'not available for any products';
     if (is_array($products)) {
         foreach ($products as $product) {
             $product_options[$product['id']] = $product['name'];
         }
     }
     $plans = $this->subscription_plan_model->get_plans();
     $plan_options = array();
     $plan_options['-1'] = 'not available for any subscriptions';
     if (is_array($plans)) {
         foreach ($plans as $plan) {
             $plan_options[$plan['id']] = $plan['name'];
         }
     }
     $shipping = $this->shipping_model->get_rates();
     $shipping_options = array();
     if (is_array($shipping)) {
         foreach ($shipping as $rate) {
             $shipping_options[$rate['id']] = $rate['name'];
         }
     }
     // Build the form
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('Coupon Information');
     $form->hidden('coupon_id', $id);
     $form->text('Coupon Name', 'coupon_name', isset($coupon['coupon_name']) ? $coupon['coupon_name'] : null, 'Something for you to recognize the coupon by.', TRUE);
     $form->text('Coupon Code', 'coupon_code', isset($coupon['coupon_code']) ? $coupon['coupon_code'] : null, 'The code the customer must enter.', TRUE);
     $form->date('Start Date', 'coupon_start_date', isset($coupon['coupon_start_date']) ? $coupon['coupon_start_date'] : null, null, TRUE, FALSE, FALSE, '8em');
     $form->date('Expiry Date', 'coupon_end_date', isset($coupon['coupon_end_date']) ? $coupon['coupon_end_date'] : null, null, TRUE, FALSE, FALSE, '8em');
     $form->text('Maximum Uses', 'coupon_max_uses', (isset($coupon['coupon_max_uses']) and !empty($coupon['coupon_max_uses'])) ? $coupon['coupon_max_uses'] : null, 'The maximum number of customers that can use the coupon.', FALSE, FALSE, FALSE, '6em');
     $form->checkbox('One Per Customer?', 'coupon_customer_limit', '1', isset($coupon['coupon_customer_limit']) && $coupon['coupon_customer_limit'] == 1 ? TRUE : FALSE, 'Check to limit each customer to a single use.');
     $form->dropdown('Coupon Type', 'coupon_type_id', $type_options, isset($coupon['coupon_type_id']) ? $coupon['coupon_type_id'] : FALSE, FALSE, FALSE, FALSE, FALSE, 'coupon_type');
     $form->fieldset('Price Reduction', array('coupon_reduction'));
     $form->dropdown('Reduction Type', 'coupon_reduction_type', $reduction_options, isset($coupon['coupon_reduction_type']) ? $coupon['coupon_reduction_type'] : FALSE);
     $form->text('Reduction Amount', 'coupon_reduction_amt', isset($coupon['coupon_reduction_amt']) ? $coupon['coupon_reduction_amt'] : null, 'The amount of the discount.', FALSE, FALSE, FALSE, '6em');
     $form->dropdown('Products', 'products[]', $product_options, $coupon_products, TRUE, FALSE, 'Leave all unselected to make available for all products.');
     $form->dropdown('Subscription Plans', 'plans[]', $plan_options, $coupon_plans, TRUE, FALSE, 'Leave all unselected to make available for all subscriptions.');
     $form->fieldset('Free Trial', array('coupon_trial'));
     $form->text('Free Trial Length', 'coupon_trial_length', isset($coupon['coupon_trial_length']) ? $coupon['coupon_trial_length'] : null, null, FALSE, 'in days', FALSE, '6em');
     $form->dropdown('Subscription Plans', 'trial_subs[]', $plan_options, $coupon_plans, TRUE, 'If left blank, will select ALL SUBSCRIPTION PLANS');
     $form->fieldset('Free Shipping', array('coupon_shipping'));
     $form->text('Min. Cart Amount', 'coupon_min_cart_amt', isset($coupon['coupon_min_cart_amt']) ? $coupon['coupon_min_cart_amt'] : null, 'The minimum order amount before the coupon may be used.', FALSE, FALSE, FALSE, '6em');
     $form->dropdown('Shipping Methods', 'ship_rates[]', $shipping_options, $coupon_shipping, TRUE, 'If left blank, will select ALL SHIPPING PLANS');
     return $form;
 }
Ejemplo n.º 3
0
 function type_edit($id)
 {
     $this->load->model('content_type_model');
     $type = $this->content_type_model->get_content_type($id);
     if (empty($type)) {
         die(show_error('No content type exists by that ID.'));
     }
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('New Content Type');
     $form->text('Name', 'name', $type['name'], 'Enter the name for this type of content.', TRUE, 'e.g., News Articles', TRUE);
     $form->fieldset('Options');
     $form->checkbox('Standard page fields?', 'is_standard', '1', $type['is_standard'], 'If checked, each content item will have the following fields: "Title", "URL Path", and "Topic".  These are standard items which allow ' . setting('app_name') . ' to display this content as an individual web page, include in blog/topic listings, etc.');
     $form->checkbox('Restrict to certain member groups?', 'is_privileged', '1', $type['is_privileged'], 'If checked, you will be able to specify the member group(s) that have permissions to see this content (or make it public).');
     $form->fieldset('Design');
     $this->load->helper('template_files');
     $template_files = template_files();
     $form->dropdown('Output Template', 'template', $template_files, $type['template'], FALSE, TRUE, 'This template in your theme directory will be used to display content of this type.  (Ignore this field if it\'s not applicable.)');
     $form->text('Base URL Path', 'base_url', $type['base_url'], '(Optional) If this value is set, the URL Path box where you create the URL for each piece of content will be pre-loaded with a folder that will unify all content of this type.  For example, setting this to "articles/" will help you make all URL\'s for content of this type like "articles/my_article", "articles/my_other_article", etc.');
     $data = array('form' => $form->display(), 'form_title' => 'Edit Content Type', 'form_action' => site_url('admincp/publish/post_type/edit/' . $type['id']), 'action' => 'edit');
     $this->load->view('type_form.php', $data);
 }
Ejemplo n.º 4
0
 function edit($id)
 {
     $this->load->model('usergroup_model');
     $usergroups = $this->usergroup_model->get_usergroups();
     $usergroup_options = array();
     foreach ($usergroups as $group) {
         $usergroup_options[$group['id']] = $group['name'];
     }
     $user = $this->user_model->get_user($id);
     if (!$user) {
         die(show_error('No user found with that ID.'));
     }
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('System Information');
     $form->text('Username', 'username', $user['username'], FALSE, TRUE, FALSE, TRUE);
     $form->text('Email', 'email', $user['email'], FALSE, TRUE, '*****@*****.**', TRUE);
     $form->password('Password', 'password', '', FALSE, TRUE);
     $form->password('Repeat Password', 'password2', 'Leave blank to keep current password. Passwords must be at least 6 characters in length.', FALSE, TRUE);
     $form->fieldset('Usergroup');
     $form->dropdown('Usergroups', 'usergroups', $usergroup_options, $user['usergroups'], TRUE, TRUE);
     $form->checkbox('Administrator', 'is_admin', '1', $user['is_admin']);
     $form->fieldset('Profile Information');
     $form->names('Name', $user['first_name'], $user['last_name'], FALSE, TRUE);
     $form->custom_fields($this->user_model->get_custom_fields(), $user, TRUE);
     $data = array('user' => array(), 'usergroups' => $usergroup_options, 'default_usergroup' => $this->usergroup_model->get_default(), 'form' => $form->display(), 'form_title' => 'Edit Member Account', 'form_action' => site_url('admincp/users/post_user/edit/' . $user['id']));
     $this->load->view('user_form.php', $data);
 }
Ejemplo n.º 5
0
 function shipping_edit($rate_id)
 {
     // get rate
     $this->load->model('shipping_model');
     $rate = $this->shipping_model->get_rate($rate_id);
     $this->load->library('admin_form');
     $form = new Admin_form();
     $form->fieldset('Shipping Rate');
     $this->load->model('states_model');
     $countries = $this->states_model->GetCountries();
     $states = $this->states_model->GetStates();
     $options = array();
     $options[0] = '';
     foreach ($countries as $country) {
         $options[$country['id']] = $country['name'];
     }
     $form->dropdown('Available to Country', 'country', $options, $rate['country_id'], FALSE, 'If selected, the rate will only be available to purchasers from this country.');
     $options = array();
     $options[0] = '';
     foreach ($states as $state) {
         $options[$state['id']] = $state['name'];
     }
     $form->dropdown('Available to State', 'state', $options, $rate['state_id'], FALSE, 'If selected, the rate will only be available to purchasers from this state/province.');
     $options = array('weight' => 'Calculate the shipping rate as a multiple of each ' . setting('weight_unit') . ' in the shopping cart', 'product' => 'Flat rate per product', 'flat' => 'Flat rate per cart');
     if ($this->config->item('shipping_module')) {
         $module = $this->config->item('shipping_module');
         $this->load->library($module . '/' . $module);
         $mod_options = $this->{$module}->get_types();
         if (is_array($mod_options)) {
             $options = array_merge($options, $mod_options);
         }
     }
     $form->radio('Rate Type', 'type', $options, $rate['type']);
     $form->text('Rate (' . setting('currency_symbol') . ')', 'rate', $rate['rate'], FALSE, TRUE, 'e.g., "5.00"', FALSE, '70px', 'rate', array('number'));
     $form->checkbox('<a href="' . site_url('admincp/store/taxes') . '">Tax rules</a> apply', 'taxable', '1', $rate['taxable']);
     $form->text('Method Name', 'name', $rate['name'], 'This will be seen by the customer when they select their shipping method.', TRUE, 'e.g., &quot;FedEx Overnight&quot;');
     $form->text('Max Cart Weight (' . setting('weight_unit') . ')', 'max_weight', $rate['max_weight'], '(Optional) Shipping option will only be available if their cart weight is less than or equal to this amount.', FALSE, FALSE, FALSE, '70px');
     $data = array('form' => $form->display(), 'form_action' => site_url('admincp/store/post_shipping/edit/' . $rate['id']), 'form_title' => 'Edit Shipping Method');
     $this->load->view('shipping_form', $data);
 }