예제 #1
0
/**
 * Submit handler for the shareaholic_failure_modal
 * When submitted, try to create an api key for the user
 *
 */
function shareaholic_failure_modal_form_submit($form, &$form_state)
{
    ShareaholicUtilities::get_or_create_api_key();
}
예제 #2
0
파일: public.php 프로젝트: antoninab/t2c
 /**
  * Inserts the script code snippet into the head of the page
  */
 public static function script_tag()
 {
     if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_or_create_api_key()) {
         ShareaholicUtilities::load_template('script_tag', array('api_key' => ShareaholicUtilities::get_option('api_key'), 'base_settings' => ShareaholicPublicJS::get_base_settings(), 'overrides' => ShareaholicPublicJS::get_overrides()));
     }
 }
예제 #3
0
 /**
  * Checks whether to ask the user to accept the terms of service or not.
  */
 public function terms_of_service()
 {
     if (!ShareaholicUtilities::has_accepted_terms_of_service()) {
         add_action('admin_notices', array('ShareaholicAdmin', 'show_terms_of_service'));
     } else {
         ShareaholicUtilities::get_or_create_api_key();
     }
 }
예제 #4
0
 /**
  * The function for the advanced admin section
  */
 public static function advanced_admin()
 {
     $settings = ShareaholicUtilities::get_settings();
     $api_key = ShareaholicUtilities::get_or_create_api_key();
     $action = str_replace('%7E', '~', $_SERVER['REQUEST_URI']);
     if (!ShareaholicUtilities::has_accepted_terms_of_service()) {
         ShareaholicUtilities::load_template('terms_of_service_modal', array('image_url' => SHAREAHOLIC_ASSET_DIR . 'img'));
     }
     if (isset($_POST['reset_settings']) && $_POST['reset_settings'] == 'Y' && check_admin_referer($action, 'nonce_field')) {
         ShareaholicUtilities::destroy_settings();
         echo "<div class='updated settings_updated'><p><strong>" . sprintf(__('Settings successfully reset. Refresh this page to complete the reset.', 'shareaholic')) . "</strong></p></div>";
     }
     if (isset($_POST['already_submitted']) && $_POST['already_submitted'] == 'Y' && check_admin_referer($action, 'nonce_field')) {
         echo "<div class='updated settings_updated'><p><strong>" . sprintf(__('Settings successfully saved', 'shareaholic')) . "</strong></p></div>";
         foreach (array('disable_tracking', 'disable_og_tags', 'disable_admin_bar_menu', 'disable_debug_info', 'disable_internal_share_counts_api') as $setting) {
             if (isset($settings[$setting]) && !isset($_POST['shareaholic'][$setting]) && $settings[$setting] == 'on') {
                 $_POST['shareaholic'][$setting] = 'off';
             } elseif (!isset($_POST['shareaholic'][$setting])) {
                 $_POST['shareaholic'][$setting] = array();
             }
         }
         if (isset($_POST['shareaholic']['api_key']) && $_POST['shareaholic']['api_key'] != $api_key) {
             ShareaholicUtilities::get_new_location_name_ids($_POST['shareaholic']['api_key']);
         }
         if (isset($_POST['shareaholic']['api_key'])) {
             ShareaholicUtilities::update_options(array('api_key' => $_POST['shareaholic']['api_key']));
         }
         if (isset($_POST['shareaholic']['disable_tracking'])) {
             ShareaholicUtilities::update_options(array('disable_tracking' => $_POST['shareaholic']['disable_tracking']));
         }
         if (isset($_POST['shareaholic']['disable_og_tags'])) {
             ShareaholicUtilities::update_options(array('disable_og_tags' => $_POST['shareaholic']['disable_og_tags']));
         }
         if (isset($_POST['shareaholic']['disable_admin_bar_menu'])) {
             ShareaholicUtilities::update_options(array('disable_admin_bar_menu' => $_POST['shareaholic']['disable_admin_bar_menu']));
         }
         if (isset($_POST['shareaholic']['disable_debug_info'])) {
             ShareaholicUtilities::update_options(array('disable_debug_info' => $_POST['shareaholic']['disable_debug_info']));
         }
         if (isset($_POST['shareaholic']['disable_internal_share_counts_api'])) {
             ShareaholicUtilities::update_options(array('disable_internal_share_counts_api' => $_POST['shareaholic']['disable_internal_share_counts_api']));
         }
         ShareaholicUtilities::log_event("UpdatedSettings");
         // clear cache after settings update
         ShareaholicUtilities::clear_cache();
     }
     ShareaholicUtilities::load_template('advanced_settings', array('settings' => ShareaholicUtilities::get_settings(), 'action' => $action));
 }
예제 #5
0
 /**
  * Inserts the script code snippet into the head of the page
  */
 public static function script_tag()
 {
     if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_or_create_api_key()) {
         ShareaholicUtilities::load_template('script_tag', array('shareaholic_url' => Shareaholic::URL, 'api_key' => ShareaholicUtilities::get_option('api_key'), 'page_config' => ShareaholicPublicJS::get_page_config()));
     }
 }
/**
 * The submit handler for the reset plugin form
 * When the user resets the plugin, destroy settings
 * and get a new api key
 *
 */
function shareaholic_reset_plugin_form_submit($form, &$form_state)
{
    ShareaholicUtilities::destroy_settings();
    ShareaholicUtilities::get_or_create_api_key();
    drupal_set_message(t('Module has been reset. Please clear your cache.'), 'status');
}
예제 #7
0
/**
 * Submit handler for the ToS modal: update values in the database
 * By storing 'true' for shareaholic_has_accepted_tos
 * and get or create an api key if it does not already exists
 *
 */
function shareaholic_tos_modal_form_submit($form, &$form_state)
{
    ShareaholicUtilities::accept_terms_of_service();
    ShareaholicUtilities::get_or_create_api_key();
}