Example #1
0
 public function settings_field_settings_page()
 {
     #var_dump('die');die();
     register_setting('general', self::$option_name, array($this, 'validator'));
     $args = the_alert_box()->settings_fields();
     add_settings_field('alert_box_check', self::alert_label('activate_q'), array($this, 'settings_field_maker'), 'general', 'default', $args['switch']);
 }
Example #2
0
 function pf_options_admin_page_save()
 {
     global $pagenow;
     if ('admin.php' != $pagenow) {
         return;
     }
     if (empty($_POST['submit'])) {
         return;
     }
     check_admin_referer('pf_settings');
     if (current_user_can(get_option('pf_menu_all_content_access', pf_get_defining_capability_by_role('contributor')))) {
         $user_ID = get_current_user_id();
         if (isset($_POST['pf_user_scroll_switch'])) {
             $pf_user_scroll_switch = $_POST['pf_user_scroll_switch'];
             //var_dump($pf_user_scroll_switch); die();
             update_user_option($user_ID, 'pf_user_scroll_switch', $pf_user_scroll_switch);
         } else {
             update_user_option($user_ID, 'pf_user_scroll_switch', 'false');
         }
         if (isset($_POST['pf_user_menu_set'])) {
             $pf_user_menu_set = $_POST['pf_user_menu_set'];
             //var_dump($pf_user_scroll_switch); die();
             update_user_option($user_ID, 'pf_user_menu_set', $pf_user_menu_set);
         } else {
             update_user_option($user_ID, 'pf_user_menu_set', 'false');
         }
         if (isset($_POST['pf_pagefull'])) {
             $pf_pagefull = $_POST['pf_pagefull'];
             //var_dump($pf_user_scroll_switch); die();
             update_user_option($user_ID, 'pf_pagefull', $pf_pagefull);
         } else {
             update_user_option($user_ID, 'pf_pagefull', 'false');
         }
     }
     $verifyPages = array();
     $pf_admin_pages = apply_filters('pf_admin_pages', $verifyPages);
     if (!in_array($_GET['page'], $pf_admin_pages)) {
         return;
     }
     if (current_user_can(get_option('pf_menu_preferences_access', pf_get_defining_capability_by_role('administrator')))) {
         $arrayedAdminRights = array('pf_menu_group_access' => array('default' => 'contributor', 'title' => __('PressForward Menu Group', 'pf')), 'pf_menu_all_content_access' => array('default' => 'contributor', 'title' => __('All Content Menu', 'pf')), 'pf_menu_under_review_access' => array('default' => 'contributor', 'title' => __('Nominated Menu', 'pf')), 'pf_menu_preferences_access' => array('default' => 'administrator', 'title' => __('Preferences Menu', 'pf')), 'pf_menu_feeder_access' => array('default' => 'editor', 'title' => __('Add Feeds', 'pf')), 'pf_menu_add_nomination_access' => array('default' => 'contributor', 'title' => __('Add Nomination Menu', 'pf')));
         $arrayedAdminRights = apply_filters('pf_setup_admin_rights', $arrayedAdminRights);
         foreach ($arrayedAdminRights as $right => $parts) {
             if (isset($_POST[$right])) {
                 $enabled = $_POST[$right];
                 update_option($right, $enabled);
             }
         }
         if (isset($_POST['pf_link_to_source'])) {
             $pf_links_opt_check = $_POST['pf_link_to_source'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_link_to_source', $pf_links_opt_check);
         } else {
             update_option('pf_link_to_source', 0);
         }
         if (isset($_POST['pf_retain_time'])) {
             $pf_links_opt_check = $_POST['pf_retain_time'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_retain_time', $pf_links_opt_check);
         } else {
             update_option('pf_retain_time', 2);
         }
         if (isset($_POST['pf_errors_until_alert'])) {
             $pf_errors_until_alert = $_POST['pf_errors_until_alert'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_errors_until_alert', $pf_errors_until_alert);
         } else {
             update_option('pf_errors_until_alert', 3);
         }
         if (isset($_POST['pf_present_author_as_primary'])) {
             $pf_author_opt_check = $_POST['pf_present_author_as_primary'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_present_author_as_primary', $pf_author_opt_check);
         } else {
             update_option('pf_present_author_as_primary', 'no');
         }
         if (class_exists('The_Alert_Box')) {
             #var_dump($_POST);
             if (empty($_POST[the_alert_box()->option_name()])) {
                 #var_dump('<pre>'); var_dump($_POST); var_dump('</pre>');
                 update_option(the_alert_box()->option_name(), 'false');
             } else {
                 update_option(the_alert_box()->option_name(), $_POST[the_alert_box()->option_name()]);
             }
         }
         if (isset($_POST['pf_use_advanced_user_roles'])) {
             $pf_author_opt_check = $_POST['pf_use_advanced_user_roles'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_use_advanced_user_roles', $pf_author_opt_check);
         } else {
             update_option('pf_use_advanced_user_roles', 'no');
         }
     }
     do_action('pf_admin_op_page_save');
 }
Example #3
0
 public static function pf_feedlist_validate($input)
 {
     set_time_limit(0);
     pf_log('Add Feed Process Invoked: PF_RSS_IMPORT::pf_feedlist_validate');
     pf_log($input);
     if (current_user_can('edit_posts')) {
         pf_log('Yes, the current user can edit posts.');
     } else {
         pf_log('No, the current user can not edit posts.');
     }
     $feed_obj = pressforward()->pf_feeds;
     $subed = '';
     $something_broke = false;
     if (!empty($input['single'])) {
         if (!is_array($input['single'])) {
             pf_log('The feed is not an array;');
             if (!$feed_obj->has_feed($input['single'])) {
                 pf_log('The feed does not already exist.');
                 $check = $feed_obj->create($input['single'], array('type' => 'rss', 'module_added' => get_class($this)));
                 if (is_wp_error($check) || !$check) {
                     pf_log('The feed did not enter the database.');
                     #wp_die($check);
                     $something_broke = true;
                     $description = 'Feed failed initial attempt to add to database | ' . $check->get_error_message();
                     $broken_id = $feed_obj->create($input['single'], array('type' => 'rss-quick', 'description' => $description, 'module_added' => get_called_class()));
                     the_alert_box()->switch_post_type($broken_id);
                     the_alert_box()->add_bug_type_to_post($broken_id, 'Broken feed.');
                 }
             } else {
                 pf_log('The feed already exists, sending it to update.');
                 $check = $feed_obj->update_url($input['single']);
                 pf_log('Our attempt to update resulted in:');
                 pf_log($check);
             }
             $subed = 'a feed ';
         } else {
             pf_log('The feed was an array, this does not work');
             wp_die('Bad feed input. Why are you trying to place an array?');
         }
     }
     #		var_dump($_POST);
     #		die();
     //print_r($inputSingle);
     if (!empty($input['opml'])) {
         self::process_opml($input['opml']);
         $subed = 'an OPML file ';
     }
     if (!empty($input['opml_uploader'])) {
         #var_dump($input); die();
         pf_log('Attempting to upload on OPML file.');
         $keys = array_keys($_FILES);
         $i = 0;
         foreach ($_FILES as $ofile) {
             // if a files was upload
             if ($ofile['size']) {
                 // if it is an OPML
                 // Pattern from http://www.sitepoint.com/wordpress-options-panel/ and http://codex.wordpress.org/Function_Reference/wp_handle_upload
                 if (preg_match('/(opml|xml)$/', $ofile['type'])) {
                     $override = array('test_form' => false);
                     // save the file, and store an array, containing its location in $file
                     $file = wp_handle_upload($ofile, $override);
                     pf_log('File upload resulted in:');
                     pf_log($file);
                     self::process_opml($file['url']);
                 } else {
                     // Not an image.
                     #$options = get_option('plugin_options');
                     #$plugin_options[$keys[$i]] = $options[$logo];
                     // Die and let the user know that they made a mistake.
                     wp_die('No OPML file was uploaded.');
                 }
             } else {
                 #$options = get_option('plugin_options');
                 #$plugin_options[$keys[$i]] = $options[$keys[$i]];
             }
             $i++;
         }
         $subed = 'an OPML uploaded file ';
     }
     #var_dump($_FILES); die();
     if (!empty($_POST['o_feed_url'])) {
         $offender = array_search($_POST['o_feed_url'], $feedlist);
         if ($offender !== false) {
             unset($feedlist[$offender]);
         }
     }
     if ($something_broke) {
         add_settings_error('add_pf_feeds', 'pf_feeds_validation_response', __('You have submitted ', 'pf') . $subed . '. ' . __('The feed was not found.', 'pf'), 'updated');
     } else {
         add_settings_error('add_pf_feeds', 'pf_feeds_validation_response', __('You have submitted ', 'pf') . $subed . '.', 'updated');
     }
     return $input;
 }
Example #4
0
 public function feed_handler($obj, $check = false)
 {
     global $pf;
     $Feeds = new PF_Feeds_Schema();
     pf_log('Invoked: PF_Feed_retrieve::feed_handler()');
     pf_log('Are we just checking?');
     pf_log($check);
     #setup_postdata( $obj );
     $id = $obj->ID;
     pf_log('Feed ID ' . $id);
     $type = $Feeds->get_pf_feed_type($id);
     pf_log('Checking for feed type ' . $type);
     $module_to_use = $this->does_type_exist($type);
     if (!$module_to_use) {
         # Be a better error.
         pf_log('The feed type does not exist.');
         return false;
     }
     pf_log('Begin the process to retrieve the object full of feed items.');
     //Has this process already occurring?
     $feed_go = update_option(PF_SLUG . '_feeds_go_switch', 0);
     pf_log('The Feeds go switch has been updated?');
     pf_log($feed_go);
     $is_it_going = get_option(PF_SLUG . '_iterate_going_switch', 1);
     if ($is_it_going == 0) {
         //WE ARE? SHUT IT DOWN!!!
         update_option(PF_SLUG . '_feeds_go_switch', 0);
         update_option(PF_SLUG . '_feeds_iteration', 0);
         update_option(PF_SLUG . '_iterate_going_switch', 0);
         //print_r( '<br /> We\'re doing this thing already in the data object. <br />' );
         if (get_option(PF_SLUG . '_ready_to_chunk', 1) === 0) {
             pf_log('The chunk is still open because there are no more feeds. [THIS SHOULD NOT OCCUR except at the conclusion of feeds retrieval.]');
             # Wipe the checking option for use next time.
             update_option(PF_SLUG . '_feeds_meta_state', array());
             update_option(PF_SLUG . '_ready_to_chunk', 1);
         } else {
             pf_log('We\'re doing this thing already in the data object.', true);
         }
         //return false;
         die;
     }
     if ('rss-quick' == $type) {
         # Let's update the RSS-Quick so it has real data.
         $rq_update = array('type' => 'rss-quick', 'ID' => $id, 'url' => $obj->guid);
         $Feeds->update($id, $rq_update);
     }
     # module function to return a set of standard pf feed_item object
     # Like get_items in SimplePie
     $feedObj = $this->get_the_feed_object($module_to_use, $obj);
     if ($check) {
         # Be a better error.
         if (!$feedObj) {
             return false;
         } else {
             return true;
         }
     } else {
         # We've completed the feed retrieval, the system should know it is now ok to ask for another feed.
         $feed_go = update_option(PF_SLUG . '_feeds_go_switch', 1);
         pf_log('The Feeds go switch has been updated to on?');
         pf_log($feed_go);
         $prev_iteration = get_option(PF_SLUG . '_prev_iteration', 0);
         $iterate_op_check = get_option(PF_SLUG . '_feeds_iteration', 1);
         pf_log('Did the option properly iterate so that the previous iteration count of ' . $prev_iteration . ' is not equal to the current of ' . $iterate_op_check . '?');
         if ($prev_iteration === $iterate_op_check) {
             pf_log('Nope. Did the iteration option emergency update function here?');
             $check_iteration = update_option(PF_SLUG . '_feeds_iteration', $iterate_op_check + 1);
             pf_log($check_iteration);
         } else {
             pf_log('Yes');
         }
         if (false == $feedObj || is_wp_error($feedObj)) {
         } else {
             if (function_exists('the_alert_box')) {
                 $alert_box = the_alert_box();
                 $ab_status = $alert_box->status();
                 if ($ab_status == $obj->post_status) {
                     # The feed has been retrieved, therefor this is a good feed. We can remove the alert.
                     the_alert_box()->remove_alert_on_edit($obj->ID);
                 }
             }
         }
         return $feedObj;
     }
     #foreach ( $feedObj as $item ) {
     #	$item
     #}
 }
if (class_exists('The_Alert_Box')) {
    ?>
		<p>
			<?php 
    #if (class_exists('The_Alert_Box')){
    $alert_settings = the_alert_box()->settings_fields();
    $alert_switch = $alert_settings['switch'];
    $check = the_alert_box()->setting($alert_switch, $alert_switch['default']);
    #var_dump($check);
    $check = the_alert_box()->setting($alert_switch, $alert_switch['default']);
    if ('true' == $check) {
        $mark = 'checked';
    } else {
        $mark = '';
    }
    echo '<input id="alert_switch" type="checkbox" name="' . the_alert_box()->option_name() . '[' . $alert_switch['parent_element'] . '][' . $alert_switch['element'] . ']" value="true" ' . $mark . ' class="' . $alert_switch['parent_element'] . ' ' . $alert_switch['element'] . '" />  <label for="' . the_alert_box()->option_name() . '[' . $alert_switch['parent_element'] . '][' . $alert_switch['element'] . ']" class="' . $alert_switch['parent_element'] . ' ' . $alert_switch['element'] . '" >' . $alert_switch['label_for'] . '</label>';
    #}
    ?>
		</p>
		<p>
			<?php 
    _e('When alerts are on, feeds that continually return errors display as alerted. You can dismiss alerts in the Subscribed Feeds page.', 'pf');
    ?>
		</p>
		<hr />
<?php 
}
?>
<p>
	<?php 
$default_pf_link_value = get_option('pf_retain_time', 2);
Example #6
0
 public function get($args = array())
 {
     if (!post_type_exists('pf_feed')) {
         $this->register_feed_post_type();
     }
     $post_status = array('publish');
     if (class_exists('The_Alert_Box')) {
         $post_status[] = the_alert_box()->status();
     }
     $defaults = array('post_type' => $this->post_type, 'post_status' => $post_status, 'suppress_filters' => false);
     $query_filters = array();
     // WP_Query does not accept a 'guid' param, so we filter hackishly
     if (isset($args['url'])) {
         $parts = substr_count($args['url'], '&');
         if ($parts > 0) {
             #Apparently WP query can't deal with more than one part in a URL query. So we need another way.
             $args['meta_key'] = 'feedUrl';
             $args['meta_value'] = $args['url'];
         } else {
             $this->filter_data['guid'] = $args['url'];
             unset($args['url']);
             $query_filters['posts_where'][] = '_filter_where_guid';
         }
     }
     foreach ($query_filters as $hook => $filters) {
         foreach ($filters as $f) {
             add_filter($hook, array($this, $f));
         }
     }
     // Other WP_Query args pass through
     $wp_args = wp_parse_args($args, $defaults);
     $posts = get_posts($wp_args);
     foreach ($query_filters as $hook => $filters) {
         foreach ($filters as $f) {
             remove_filter($hook, array($this, $f));
         }
     }
     // Fetch some handy pf-specific data
     return $posts;
 }