FeedWordPressSyndicationPage::multiundelete_page PHP Method

multiundelete_page() public method

* FeedWordPressSyndicationPage::multidelete_page()
public multiundelete_page ( )
    function multiundelete_page()
    {
        global $wpdb;
        // If this is a POST, validate source and user credentials
        FeedWordPressCompatibility::validate_http_request('feedwordpress_feeds', 'manage_links');
        // Get single link ID or multiple link IDs from REQUEST parameters
        // if available. Sanitize values for MySQL.
        $link_list = $this->requested_link_ids_sql();
        if (MyPHP::post('confirm') == 'Undelete') {
            if (is_array(MyPHP::post('link_action'))) {
                $actions = MyPHP::post('link_action');
            } else {
                $actions = array();
            }
            $do_it = array('unhide' => array());
            foreach ($actions as $link_id => $what) {
                $do_it[$what][] = $link_id;
            }
            $alter = array();
            if (count($do_it['unhide']) > 0) {
                $unhiddem = "(" . implode(', ', $do_it['unhide']) . ")";
                $alter[] = "\n\t\t\t\tUPDATE {$wpdb->links}\n\t\t\t\tSET link_visible = 'Y'\n\t\t\t\tWHERE link_id IN {$unhiddem}\n\t\t\t\t";
            }
            $errs = array();
            $success = array();
            foreach ($alter as $sql) {
                $result = $wpdb->query($sql);
                if (!$result) {
                    $errs[] = mysql_error();
                }
            }
            if (count($alter) > 0) {
                echo "<div class=\"updated\">\n";
                if (count($errs) > 0) {
                    echo "There were some problems processing your ";
                    echo "re-subscribe request. [SQL: " . implode('; ', $errs) . "]";
                } else {
                    echo "Your re-subscribe request(s) have been processed.";
                }
                echo "</div>\n";
            }
            return true;
            // Continue on to Syndicated Sites listing
        } else {
            // $link_list has previously been sanitized for html by self::requested_link_ids_sql
            $targets = $wpdb->get_results("\n\t\t\t\tSELECT * FROM {$wpdb->links}\n\t\t\t\tWHERE link_id IN {$link_list}\n\t\t\t\t");
            ?>
	<form action="<?php 
            print $this->form_action();
            ?>
" method="post">
	<div class="wrap">
	<?php 
            FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
            ?>
	<input type="hidden" name="action" value="<?php 
            print FWP_RESUB_CHECKED;
            ?>
" />
	<input type="hidden" name="confirm" value="Undelete" />
	
	<h2>Re-subscribe to Syndicated Links:</h2>
	<?php 
            foreach ($targets as $link) {
                $subscribed = 'Y' == strtoupper($link->link_visible);
                $link_url = esc_html($link->link_url);
                $link_name = esc_html($link->link_name);
                $link_description = esc_html($link->link_description);
                $link_rss = esc_html($link->link_rss);
                if (!$subscribed) {
                    ?>
	<fieldset>
	<legend><?php 
                    echo $link_name;
                    ?>
</legend>
	<table class="editform" width="100%" cellspacing="2" cellpadding="5">
	<tr><th scope="row" width="20%"><?php 
                    _e('Feed URI:');
                    ?>
</th>
	<td width="80%"><a href="<?php 
                    echo $link_rss;
                    ?>
"><?php 
                    echo $link_rss;
                    ?>
</a></td></tr>
	<tr><th scope="row" width="20%"><?php 
                    _e('Short description:');
                    ?>
</th>
	<td width="80%"><?php 
                    echo $link_description;
                    ?>
</span></td></tr>
	<tr><th width="20%" scope="row"><?php 
                    _e('Homepage:');
                    ?>
</th>
	<td width="80%"><a href="<?php 
                    echo $link_url;
                    ?>
"><?php 
                    echo $link_url;
                    ?>
</a></td></tr>
	<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php 
                    _e('Options');
                    ?>
:</th>
	<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
	<li><input type="radio" id="unhide-<?php 
                    echo $link->link_id;
                    ?>
"
	name="link_action[<?php 
                    echo $link->link_id;
                    ?>
]" value="unhide" checked="checked" />
	<label for="unhide-<?php 
                    echo $link->link_id;
                    ?>
">Turn back on the subscription
	for this syndication source.</label></li>
	<li><input type="radio" id="nothing-<?php 
                    echo $link->link_id;
                    ?>
"
	name="link_action[<?php 
                    echo $link->link_id;
                    ?>
]" value="nothing" />
	<label for="nothing-<?php 
                    echo $link->link_id;
                    ?>
">Leave this feed as it is.
	I changed my mind.</label></li>
	</ul>
	</table>
	</fieldset>
	<?php 
                }
            }
            ?>
	
	<div class="submit">
	<input class="button-primary delete" type="submit" name="submit" value="<?php 
            _e('Re-subscribe to selected feeds &raquo;');
            ?>
" />
	</div>
	</div>
	<?php 
            return false;
            // Don't continue on to Syndicated Sites listing
        }
    }