コード例 #1
0
 function tdomf_theme_widget_form($args, $params)
 {
     extract($args);
     $form_id = $params;
     if (!tdomf_form_exists($form_id)) {
         $form_id = tdomf_get_first_form_id();
     }
     echo $before_widget;
     echo $before_title;
     echo tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id);
     echo $after_title;
     tdomf_the_form($form_id);
     echo "<br/><br/>\n";
     echo $after_widget;
 }
コード例 #2
0
                    if (!empty($name)) {
                        echo $name;
                    } else {
                        if (!empty($email)) {
                            echo $email;
                        } else {
                            _e("N/A", "tdomf");
                        }
                    }
                }
            }
            ?>
                </td>
                <td>
                <?php 
            if (tdomf_form_exists($e->form_id) != false) {
                #$form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form=$e->form_id";
                $form_edit_url = tdomf_get_mod_posts_url(array('form_id' => $e->form_id));
                $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $e->form_id);
                echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s', 'tdomf'), $e->form_id, $form_name) . '</a>';
            }
            ?>
                </td>
                <td>
                <a href="<?php 
            tdomf_get_mod_posts_url(array('ip' => $e->ip, 'echo' => true));
            ?>
">
                    <?php 
            echo $e->ip;
            ?>
コード例 #3
0
function tdomf_get_post_list_line($p)
{
    $form_id = get_post_meta($p->ID, TDOMF_KEY_FORM_ID, true);
    $submitter = get_post_meta($p->ID, TDOMF_KEY_NAME, true);
    if ($form_id == false || !tdomf_form_exists($form_id)) {
        if ($submitter == false || empty($submitter)) {
            return "<li>" . sprintf(__("<a href=\"%s\">\"%s\"</a>", "tdomf"), get_permalink($p->ID), $p->post_title) . "</li>";
        } else {
            return "<li>" . sprintf(__("<a href=\"%s\">\"%s\"</a> submitted by %s", "tdomf"), get_permalink($p->ID), $p->post_title, $submitter) . "</li>";
        }
    } else {
        if ($submitter == false || empty($submitter)) {
            return "<li>" . sprintf(__("<a href=\"%s\">\"%s\"</a> using form %d", "tdomf"), get_permalink($p->ID), $p->post_title, $form_id) . "</li>";
        }
    }
    return "<li>" . sprintf(__("<a href=\"%s\">\"%s\"</a> submitted by %s using form %d", "tdomf"), get_permalink($p->ID), $p->post_title, $submitter, $form_id) . "</li>";
}
コード例 #4
0
function tdomf_notify_poster_rejected($post_id)
{
    global $wpdb;
    if (wp_is_post_revision($post_id)) {
        tdomf_log_message_extra("tdomf_notify_poster_rejected: post {$post_id} is a revision -- do nothing.");
        return $post_id;
    }
    $email = get_post_meta($post_id, TDOMF_KEY_NOTIFY_EMAIL, true);
    tdomf_log_message_extra("tdomf_notify_poster_rejected: {$email}");
    delete_post_meta($post_id, TDOMF_KEY_NOTIFY_EMAIL);
    if (get_post_meta($post_id, TDOMF_KEY_SPAM, true)) {
        tdomf_log_message_extra("tdomf_notify_poster_rejected: post {$post_id} is spam -- do nothing.");
        return $post_id;
    }
    if (tdomf_check_email_address($email)) {
        tdomf_log_message("Attempting to send notification email to {$email} for rejected post {$post_id}!");
        $postdata = get_postdata($post_id);
        $title = $postdata['Title'];
        $form_id = get_post_meta($post_id, TDOMF_KEY_FORM_ID, true);
        if ($form_id == false || !tdomf_form_exists($form_id)) {
            $form_id = tdomf_get_first_form_id();
        }
        $subject = tdomf_widget_notify_get_message($form_id, 'rejected_subject', true, $post_id);
        $notify_message = tdomf_widget_notify_get_message($form_id, 'rejected', true, $post_id);
        // Use custom from field
        //
        if (tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id)) {
            // We can modify the "from" field by using the "header" option at the end!
            //
            $headers = "MIME-Version: 1.0\n" . "From: " . tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id) . "\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
            return @wp_mail($email, $subject, $notify_message, $headers);
        } else {
            return @wp_mail($email, $subject, $notify_message);
        }
    }
    return $post_id;
}
コード例 #5
0
function tdomf_show_mod_posts_menu()
{
    tdomf_moderation_handler();
    $user_id = false;
    if (isset($_REQUEST['user_id'])) {
        $user_id = intval($_REQUEST['user_id']);
    }
    $ip = false;
    if (isset($_REQUEST['ip'])) {
        $ip = $_REQUEST['ip'];
    }
    $form_id = false;
    if (isset($_REQUEST['form_id'])) {
        $form_id = intval($_REQUEST['form_id']);
        if ($form_id <= 0) {
            $form_id = false;
        }
    }
    $pending_count = tdomf_get_posts(array('count' => true, 'post_status' => array('draft'), 'nospam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $scheduled_count = tdomf_get_posts(array('count' => true, 'post_status' => array('future'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $published_count = tdomf_get_posts(array('count' => true, 'post_status' => array('publish'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $spam_count = tdomf_get_posts(array('count' => true, 'spam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $all_count = tdomf_get_posts(array('count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $form_ids = tdomf_get_form_ids();
    $pending_edits_count = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $spam_edits_count = tdomf_get_edits(array('state' => 'spam', 'count' => true, 'unique_post_ids' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $approved_edits_count = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
    $limit = 10;
    # fixed
    if (isset($_REQUEST['limit'])) {
        $limit = intval($_REQUEST['limit']);
    }
    $paged = 1;
    if (isset($_GET['paged'])) {
        $paged = intval($_GET['paged']);
    }
    $offset = $limit * ($paged - 1);
    $show = 'all';
    if (isset($_REQUEST['show'])) {
        $show = $_REQUEST['show'];
    }
    $posts = false;
    $max_pages = 0;
    $max_items = 0;
    if ($show == 'all') {
        $posts = tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
        $max_pages = ceil($all_count / $limit);
        $max_items = $all_count;
    } else {
        if ($show == 'pending_submissions') {
            $posts = tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'post_status' => array('draft'), 'nospam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
            $max_pages = ceil($pending_count / $limit);
            $max_items = $pending_count;
        } else {
            if ($show == 'scheduled') {
                $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('future'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
                $max_pages = ceil($scheduled_count / $limit);
                $max_items = $scheduled_count;
            } else {
                if ($show == 'published') {
                    $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('publish'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
                    $max_pages = ceil($published_count / $limit);
                    $max_items = $published_count;
                } else {
                    if ($show == 'spam_submissions') {
                        $posts = tdomf_get_posts(array('offset' => $offset, 'spam' => true, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
                        $max_pages = ceil($spam_count / $limit);
                        $max_items = $spam_count;
                    } else {
                        if ($show == 'pending_edits') {
                            $edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
                            $max_pages = ceil($pending_edits_count / $limit);
                            $posts = array();
                            # a little hacky magic
                            foreach ($edits as $e) {
                                $posts[] = (object) array('ID' => $e->post_id);
                            }
                            $max_items = $pending_edits_count;
                        } else {
                            if ($show == 'spam_edits') {
                                $edits = tdomf_get_edits(array('state' => 'spam', 'unique_post_ids' => true, 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
                                $max_pages = ceil($spam_edits_count / $limit);
                                $posts = array();
                                # a little hacky magic
                                foreach ($edits as $e) {
                                    $posts[] = (object) array('ID' => $e->post_id);
                                }
                                $max_items = $spam_edits_count;
                            } else {
                                if ($show == 'approved_edits') {
                                    $edits = tdomf_get_edits(array('state' => 'approved', 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
                                    $max_pages = ceil($approved_edits_count / $limit);
                                    $posts = array();
                                    # a little hacky magic
                                    foreach ($edits as $e) {
                                        $posts[] = (object) array('ID' => $e->post_id, 'edit_id' => $e->edit_id);
                                    }
                                    $max_items = $approved_edits_count;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    # max is incorrect... doesn't account for form filter...
    $mode = 'list';
    if (isset($_GET['mode'])) {
        $mode = $_GET['mode'];
    }
    $count = 0;
    # what bulk actions to support
    $bulk_sub_publish_now = false;
    $bulk_sub_publish = false;
    $bulk_sub_unpublish = false;
    $bulk_sub_spamit = false;
    $bulk_sub_hamit = false;
    $bulk_sub_lock = false;
    $bulk_sub_unlock = false;
    $bulk_edit_approve = false;
    $bulk_edit_revert = false;
    $bulk_edit_delete = false;
    $bulk_edit_spamit = false;
    $bulk_edit_hamit = false;
    ?>
   
   <div class="wrap">
   
   <?php 
    /* screen_icon(); */
    ?>
   <h2>
   <?php 
    if ($user_id || $ip) {
        if ($user_id) {
            $u = get_userdata($user_id);
            printf(__('Posts submitted by user %s', 'tdomf'), $u->user_login);
        } else {
            if ($ip) {
                printf(__('Posts submitted from IP %s', 'tdomf'), $ip);
            }
        }
    } else {
        ?>
   <?php 
        _e('Moderation', 'tdomf');
        ?>
   <?php 
    }
    ?>
   </h2>
   
   <?php 
    /*if(count($posts) <= 0) { ?>
         <div class="clear"></div>
         <p><?php _e('No submissions found','tdomf') ?></p>
         </div> <!-- wrap --><?php 
      return; }*/
    ?>
   
   <form id="posts-filter" action="<?php 
    tdomf_get_mod_posts_url(true, $show, 0);
    ?>
" method="post">
   
   <!-- hidden vars -->
   
   <ul class="subsubsub">
   <?php 
    if ($all_count > 0) {
        ?>
       <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'all'));
        ?>
"<?php 
        if ($show == 'all') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('All Submissions (%s)', 'tdomf'), $all_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
       
   <?php 
    if ($pending_count > 0) {
        ?>
      <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'pending_submissions'));
        ?>
"<?php 
        if ($show == 'pending_submissions') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('Pending Submissions (%s)', 'tdomf'), $pending_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
   <?php 
    if ($scheduled_count > 0) {
        ?>
      <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'scheduled'));
        ?>
"<?php 
        if ($show == 'scheduled') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('Scheduled Submissions (%s)', 'tdomf'), $scheduled_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
   <?php 
    if ($published_count > 0) {
        ?>
       <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'published'));
        ?>
"<?php 
        if ($show == 'published') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('Published (%s)', 'tdomf'), $published_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
   <?php 
    if ($spam_count > 0) {
        ?>
       <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'spam_submissions'));
        ?>
"<?php 
        if ($show == 'spam_submissions') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('Spam Submissions (%s)', 'tdomf'), $spam_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
   <?php 
    if ($approved_edits_count > 0) {
        ?>
       <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'approved_edits'));
        ?>
"<?php 
        if ($show == 'approved_edits') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('Approved Edits (%s)', 'tdomf'), $approved_edits_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
    
   <?php 
    if ($pending_edits_count > 0) {
        ?>
       <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'pending_edits'));
        ?>
"<?php 
        if ($show == 'pending_edits') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('Pending Edits (%s)', 'tdomf'), $pending_edits_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
   <?php 
    if ($spam_edits_count > 0) {
        ?>
       <li><a href="<?php 
        tdomf_get_mod_posts_url(array('echo' => true, 'show' => 'spam_edits'));
        ?>
"<?php 
        if ($show == 'spam_edits') {
            ?>
 class="current"<?php 
        }
        ?>
><?php 
        printf(__('Spam Edits (%s)', 'tdomf'), $spam_edits_count);
        ?>
</a> | </li>
   <?php 
    }
    ?>
 
   </ul>

   <div class="tablenav">
   
   <?php 
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%', tdomf_get_mod_posts_url(array())), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => $max_pages, 'current' => $paged));
    ?>
    
<?php 
    if ($page_links) {
        ?>
<div class="tablenav-pages"><?php 
        $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n($offset), number_format_i18n($offset + count($posts)), number_format_i18n($max_items), $page_links);
        echo $page_links_text;
        ?>
</div>
<?php 
    }
    ?>

<div class="view-switch">
	<a href="<?php 
    tdomf_get_mod_posts_url(array('echo' => true, 'mode' => 'list'));
    ?>
"><img <?php 
    if ('list' == $mode) {
        echo 'class="current"';
    }
    ?>
 id="view-switch-list" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php 
    _e('List View');
    ?>
" alt="<?php 
    _e('List View');
    ?>
" /></a>
	<a href="<?php 
    tdomf_get_mod_posts_url(array('echo' => true, 'mode' => 'excerpt'));
    ?>
"><img <?php 
    if ('excerpt' == $mode) {
        echo 'class="current"';
    }
    ?>
 id="view-switch-excerpt" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php 
    _e('Excerpt View');
    ?>
" alt="<?php 
    _e('Excerpt View');
    ?>
" /></a>
</div>
    
    <?php 
    $form_ids_check = array();
    foreach ($form_ids as $form) {
        if (TDOMF_Widget::isSubmitForm(false, $form->form_id)) {
            $count = tdomf_get_posts(array('count' => true, 'form_id' => $form->form_id));
        } else {
            $count = tdomf_get_edits(array('count' => true, 'form_id' => $form->form_id));
        }
        if ($count > 0) {
            $form_ids_check[] = $form->form_id;
        }
    }
    if (!empty($form_ids_check)) {
        ?>
              <select name='form_id'>
                 <option value="-1" selected="selected"><?php 
        _e('Show All', 'tdomf');
        ?>
</option>
                 <?php 
        foreach ($form_ids_check as $form) {
            ?>
 
                        <option value="<?php 
            echo $form;
            ?>
" <?php 
            if ($form_id == $form) {
                ?>
 selected="selected" <?php 
            }
            ?>
><?php 
            printf(__('Form #%d', 'tdomf'), $form);
            ?>
</option>
                <?php 
        }
        ?>
              </select>
              <input type="submit" id="post-query-submit" value="<?php 
        _e('Filter');
        ?>
" class="button-secondary" />
     <?php 
    }
    ?>
    
<div class="clear"></div>

</div> <!-- tablenav -->

<div class="clear"></div>

<table class="widefat post fixed" cellspacing="0">

	<thead>
	<tr>
	<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
	<th scope="col" id="title" class="manage-column column-title" style=""><?php 
    _e('Post', 'tdomf');
    ?>
</th>
	<th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php 
    _e('Submitted', 'tdomf');
    ?>
</th>
	<th scope="col" id="edited" class="manage-column column-edited" style="">
    <?php 
    if ($show == 'approved_edits') {
        _e('Edit', 'tdomf');
    } else {
        if ($show == 'pending_edits') {
            _e('Pending Edit', 'tdomf');
        } else {
            if ($show == 'spam_edits') {
                _e('Spam Edit', 'tdomf');
            } else {
                _e('Most Recent Edit', 'tdomf');
            }
        }
    }
    ?>
</th>
	<th scope="col" id="status" class="manage-column column-status" style=""><?php 
    _e('Status', 'tdomf');
    ?>
</th>
	</tr>
	</thead>

	<tfoot>
	<tr>
	<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
	<th scope="col" id="title" class="manage-column column-title" style=""><?php 
    _e('Post', 'tdomf');
    ?>
</th>
	<th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php 
    _e('Submitted', 'tdomf');
    ?>
</th>
	<th scope="col" id="edited" class="manage-column column-edited" style="">
    <?php 
    if ($show == 'approved_edits') {
        _e('Edit', 'tdomf');
    } else {
        if ($show == 'pending_edits') {
            _e('Pending Edit', 'tdomf');
        } else {
            if ($show == 'spam_edits') {
                _e('Spam Edit', 'tdomf');
            } else {
                _e('Most Recent Edit', 'tdomf');
            }
        }
    }
    ?>
</th>
	<th scope="col" id="status" class="manage-column column-status" style=""><?php 
    _e('Status', 'tdomf');
    ?>
</th>
	</tr>
	</tfoot>
    
    <tbody>
    <?php 
    if (!empty($posts)) {
        foreach ($posts as $p) {
            $count++;
            ?>

        <?php 
            $post =& get_post($p->ID);
            /* seems I need this later */
            ?>
 
        <?php 
            if ($show == 'approved_edits') {
                // not really the "last" edit but lest pretend
                $last_edit = array(tdomf_get_edit($p->edit_id));
            } else {
                $last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 2));
                /* and need this earlier too */
            }
            ?>
        <?php 
            $form_id = get_post_meta($p->ID, TDOMF_KEY_FORM_ID, true);
            ?>
        <?php 
            $queue = intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id));
            if ($queue > 0) {
                $queue = true;
            } else {
                $queue = false;
            }
            ?>
        <?php 
            $is_spam = get_post_meta($p->ID, TDOMF_KEY_SPAM);
            ?>
        <?php 
            $locked = get_post_meta($post->ID, TDOMF_KEY_LOCK, true);
            ?>

        <tr id='post-<?php 
            echo $p->ID;
            ?>
' class='<?php 
            if ($count % 2 != 0) {
                ?>
alternate <?php 
            }
            ?>
status-<?php 
            echo $post->post_status;
            ?>
 iedit' valign="top">

        <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php 
            echo $p->ID;
            ?>
" /></th>
        <td class="post-title column-title"><strong><a class="row-title" href="post.php?action=edit&amp;post=<?php 
            echo $p->ID;
            ?>
" title="Edit"><?php 
            echo $post->post_title;
            ?>
</a></strong>

        <?php 
            /*$fuoptions = TDOMF_WidgetUploadFiles::getOptions($form_id);*/
            $index = 0;
            $filelinks = "";
            while (true) {
                $filename = get_post_meta($p->ID, TDOMF_KEY_DOWNLOAD_NAME . $index, true);
                if ($filename == false) {
                    break;
                }
                /*if($fuoptions['nohandler'] && trim($fuoptions['url']) != "") {
                      $uri = trailingslashit($fuoptions['url'])."$p->ID/".$filename;
                  } else {*/
                $uri = trailingslashit(get_bloginfo('wpurl')) . '?tdomf_download=' . $p->ID . '&id=' . $i;
                /*}*/
                $filelinks .= "<a href='{$uri}' title='" . htmlentities($filename) . "'>{$index}</a>, ";
                $index++;
            }
            if (!empty($filelinks)) {
                ?>
                 <?php 
                _e('Uploaded Files: ', 'tdomf');
                echo $filelinks;
                ?>
<br/>
             <?php 
            }
            ?>
  
        <?php 
            if ('excerpt' == $mode) {
                # Have to create our own excerpt, the_excerpt() doesn't cut it
                # here :(
                if (empty($post->post_excerpt)) {
                    $excerpt = apply_filters('the_content', $post->post_content);
                } else {
                    $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
                }
                $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
                $excerpt = wp_html_excerpt($excerpt, 252);
                if (strlen($excerpt) == 252) {
                    $excerpt .= '...';
                }
                echo '<blockquote>' . $excerpt . '</blockquote>';
            }
            ?>
        
        <?php 
            if (get_option(TDOMF_OPTION_MOD_SHOW_LINKS)) {
                ?>
        <div>
        <?php 
            } else {
                ?>
        <div class="row-actions">
        <?php 
            }
            ?>
           <?php 
            if ($post->post_status == 'future') {
                $bulk_sub_publish_now = true;
                ?>
               <span class="publish"><a href="<?php 
                tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID));
                ?>
" title="<?php 
                echo htmlentities(__('Publish this submission now', 'tdomf'));
                ?>
"><?php 
                _e('Publish Now', 'tdomf');
                ?>
</a> |</span>
           <?php 
            } else {
                if ($post->post_status != 'publish') {
                    ?>
               <?php 
                    if ($queue) {
                        $bulk_sub_publish_now = true;
                        $bulk_sub_publish = true;
                        ?>
                   <span class="publish"><a href="<?php 
                        tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID));
                        ?>
" title="<?php 
                        echo htmlentities(__('Add submission to publish queue', 'tdomf'));
                        ?>
"><?php 
                        _e('Queue', 'tdomf');
                        ?>
</a> |</span>
                   <span class="publish"><a href="<?php 
                        tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID));
                        ?>
" title="<?php 
                        echo htmlentities(__('Publish submission now', 'tdomf'));
                        ?>
"><?php 
                        _e('Publish Now', 'tdomf');
                        ?>
</a> |</span>
               <?php 
                    } else {
                        $bulk_sub_publish = true;
                        ?>
                   <span class="publish"><a href="<?php 
                        tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID));
                        ?>
" title="<?php 
                        echo htmlentities(__('Publish submission', 'tdomf'));
                        ?>
"><?php 
                        _e('Publish', 'tdomf');
                        ?>
</a> |</span>
               <?php 
                    }
                    ?>
           <?php 
                } else {
                    if ($post->post_status == 'publish') {
                        $bulk_sub_unpublish = true;
                        ?>
               <span class="publish"><a href="<?php 
                        tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'unpublish', 'post_id' => $p->ID, 'nonce' => 'tdomf-unpublish_' . $p->ID));
                        ?>
" title="<?php 
                        echo htmlentities(__('Set submission to draft/unmoderated status.', 'tdomf'));
                        ?>
"><?php 
                        _e('Un-publish', 'tdomf');
                        ?>
</a> |</span>
           <?php 
                    }
                }
            }
            ?>
           <span class='delete'><a class='submitdelete' title='Delete this submission' href='<?php 
            echo wp_nonce_url("post.php?action=delete&amp;post={$p->ID}", 'delete-post_' . $p->ID);
            ?>
' onclick="if ( confirm('<?php 
            echo js_escape(sprintf(__("You are about to delete this post \\'%s\\'\n \\'Cancel\\' to stop, \\'OK\\' to delete.", 'tdomf'), $post->post_title));
            ?>
') ) { return true;}return false;"><?php 
            _e('Delete', 'tdomf');
            ?>
</a> | </span>
           <?php 
            if ($locked) {
                $bulk_sub_unlock = true;
                ?>
               <span class="lock"><a href="<?php 
                tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'unlock', 'post_id' => $p->ID, 'nonce' => 'tdomf-unlock_' . $p->ID));
                ?>
" title="<?php 
                echo htmlentities(__('Unlock submission so it can be edited.', 'tdomf'));
                ?>
"><?php 
                _e('Unlock', 'tdomf');
                ?>
</a> |</span>
           <?php 
            } else {
                $bulk_sub_lock = true;
                ?>
               <span class="lock"><a href="<?php 
                tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'lock', 'post_id' => $p->ID, 'nonce' => 'tdomf-lock_' . $p->ID));
                ?>
" title="<?php 
                echo htmlentities(__('Lock submission from being edited.', 'tdomf'));
                ?>
"><?php 
                _e('Lock', 'tdomf');
                ?>
</a> |</span>               
           <?php 
            }
            ?>
           <?php 
            if ($post->post_status == 'publish') {
                ?>
            <span class='view'><a href="<?php 
                echo get_permalink($p->ID);
                ?>
" title="<?php 
                echo htmlentities(sprintf(__('View \'%s\'', 'tdomf'), $post->post_title));
                ?>
" rel="permalink"><?php 
                _e('View', 'tdomf');
                ?>
</a> | </span>
           <?php 
            } else {
                ?>
            <span class='view'><a href="<?php 
                echo get_permalink($p->ID);
                ?>
" title="<?php 
                echo htmlentities(sprintf(__('Preview \'%s\'', 'tdomf'), $post->post_title));
                ?>
" rel="permalink"><?php 
                _e('Preview', 'tdomf');
                ?>
</a> | </span>               
           <?php 
            }
            ?>
            <span class='edit'><a href="post.php?action=edit&amp;post=<?php 
            echo $p->ID;
            ?>
" title="<?php 
            echo htmlentities(__('Edit this submission', 'tdomf'));
            ?>
"><?php 
            _e('Edit', 'tdomf');
            ?>
</a>
           <?php 
            if (get_option(TDOMF_OPTION_SPAM)) {
                ?>
 |</span><?php 
            }
            ?>
           <?php 
            if (get_option(TDOMF_OPTION_SPAM)) {
                if (!$is_spam) {
                    $bulk_sub_spamit = true;
                    ?>
               <span class="spam"><a href="<?php 
                    tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'spamit', 'post_id' => $p->ID, 'nonce' => 'tdomf-spamit_' . $p->ID));
                    ?>
" onclick="if ( confirm('<?php 
                    echo js_escape(sprintf(__("You are about to flag this submission \\'%s\\' as spam\n \\'Cancel\\' to stop, \\'OK\\' to delete.", 'tdomf'), $post->post_title));
                    ?>
') ) { return true;}return false;"><?php 
                    _e('Spam', 'tdomf');
                    ?>
</a></span>
           <?php 
                } else {
                    $bulk_sub_hamit = true;
                    ?>
              <span class="spam"><a href="<?php 
                    tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'hamit', 'post_id' => $p->ID, 'nonce' => 'tdomf-hamit_' . $p->ID));
                    ?>
" ><?php 
                    _e('Not Spam', 'tdomf');
                    ?>
</span>
           <?php 
                }
            }
            ?>
        </div>
        </td>
        
        <td class="column-submitted">
       
        <ul style="font-size: 11px;">
        <li>
        <?php 
            $name = get_post_meta($p->ID, TDOMF_KEY_NAME, true);
            $email = get_post_meta($p->ID, TDOMF_KEY_EMAIL, true);
            $user_id = get_post_meta($p->ID, TDOMF_KEY_USER_ID, true);
            if ($user_id != false) {
                ?>
                 <!-- <a href="user-edit.php?user_id=<?php 
                echo $user_id;
                ?>
" class="edit"> -->
                 <a href="<?php 
                tdomf_get_mod_posts_url(array('echo' => true, 'user_id' => $user_id, 'ip' => false, 'form_id' => false));
                ?>
">
                 <?php 
                $u = get_userdata($user_id);
                echo $u->user_login;
                ?>
</a>
                 <?php 
            } else {
                if (!empty($name) && !empty($email)) {
                    echo $name . " (" . $email . ")";
                } else {
                    if (!empty($name)) {
                        echo $name;
                    } else {
                        if (!empty($email)) {
                            echo $email;
                        } else {
                            _e("N/A", "tdomf");
                        }
                    }
                }
            }
            ?>
                 / <?php 
            $ip = get_post_meta($p->ID, TDOMF_KEY_IP, true);
            if (!empty($ip)) {
                ?>
           <a href="<?php 
                tdomf_get_mod_posts_url(array('echo' => true, 'ip' => $ip, 'user_id' => false, 'form_id' => false));
                ?>
">
                 <?php 
            }
            ?>
 <?php 
            echo $ip;
            ?>
 <?php 
            if (!empty($ip)) {
                ?>
 </a> <?php 
            }
            ?>
         </li>
        <li>
        <?php 
            if ($form_id == false || tdomf_form_exists($form_id) == false) {
                ?>
                 <?php 
                _e("Unknown or deleted form", "tdomf");
                ?>
              <?php 
            } else {
                $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$form_id}";
                $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id);
                echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s</a>', 'tdomf'), $form_id, $form_name) . '</a>';
            }
            ?>
        </li>
        <li>
        <?php 
            if ($post->post_status != 'publish' && $post->post_status != 'future') {
                $post_date_gmt = get_post_meta($p->ID, TDOMF_KEY_SUBMISSION_DATE, true);
                if ($post_date_gmt) {
                    echo mysql2date(__('Y/m/d'), $post_date_gmt);
                } else {
                    #echo mysql2date(__('Y/m/d'), $post->post_modified_gmt);
                }
            } else {
                echo mysql2date(__('Y/m/d'), $post->post_date_gmt);
            }
            ?>
        </li>
        </ul>
        </td>

        <td class="column-edited">
        <?php 
            /*$last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 1));*/
            if ($last_edit == false || empty($last_edit) || $last_edit == NULL) {
                ?>
                        <!-- no edits -->
        <?php 
            } else {
                $previous_edit = false;
                if (count($last_edit) == 2) {
                    $previous_edit = $last_edit[1];
                }
                $last_edit = $last_edit[0];
                # only care about the first entry
                $last_edit_data = maybe_unserialize($last_edit->data);
                ?>
        <ul style="font-size: 11px;">
        <li><?php 
                $user_id = $last_edit->user_id;
                $name = __("N/A", "tdomf");
                if (isset($last_edit_data[TDOMF_KEY_NAME])) {
                    $name = $last_edit_data[TDOMF_KEY_NAME];
                }
                $email = __("N/A", "tdomf");
                if (isset($last_edit_data[TDOMF_KEY_EMAIL])) {
                    $email = $last_edit_data[TDOMF_KEY_EMAIL];
                }
                if ($user_id != 0) {
                    ?>
                 <a href="user-edit.php?user_id=<?php 
                    echo $user_id;
                    ?>
" class="edit">
                 <?php 
                    $u = get_userdata($user_id);
                    echo $u->user_login;
                    ?>
</a>
                 <?php 
                } else {
                    if (!empty($name) && !empty($email)) {
                        echo $name . " (" . $email . ")";
                    } else {
                        if (!empty($name)) {
                            echo $name;
                        } else {
                            if (!empty($email)) {
                                echo $email;
                            } else {
                                _e("N/A", "tdomf");
                            }
                        }
                    }
                }
                ?>
         / <?php 
                echo $last_edit->ip;
                ?>
         </li>
        <li>
        <?php 
                $form_id = $last_edit->form_id;
                if ($form_id == false || tdomf_form_exists($form_id) == false) {
                    ?>
                 <?php 
                    _e("Unknown or deleted form", "tdomf");
                    ?>
              <?php 
                } else {
                    $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$form_id}";
                    $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id);
                    echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s', 'tdomf'), $form_id, $form_name) . '</a>';
                }
                ?>
         </li>
         <li><?php 
                echo mysql2date(__('Y/m/d'), $last_edit->date_gmt);
                ?>
</li>
        <li><?php 
                switch ($last_edit->state) {
                    case 'unapproved':
                        _e('Unapproved', "tdomf");
                        break;
                    case 'approved':
                        _e('Approved', "tdomf");
                        break;
                    case 'spam':
                        _e('Spam', "tdomf");
                        break;
                    default:
                        echo _e($last_edit->state, "tdomf");
                        break;
                }
                ?>
         </li>
        </ul>
        
        <div class="row-actions">
        
        <?php 
                /* nothing to do if revisioning is disabled for the edits... */
                if ($last_edit->revision_id != 0) {
                    ?>
        
           <?php 
                    if ($last_edit->state != 'approved') {
                        ?>
              <span class='view'><a href="admin.php?page=<?php 
                        echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $last_edit->edit_id;
                        ?>
"><?php 
                        _e('View', 'tdomf');
                        ?>
</a> |<span>
              <!-- <span class='view'><a href="revision.php?revision=<?php 
                        echo $last_edit->revision_id;
                        ?>
"><?php 
                        _e('View', 'tdomf');
                        ?>
</a> |<span> -->
           <?php 
                    }
                    ?>
 
           <?php 
                    if ($last_edit->state == 'approved') {
                        $bulk_edit_revert = true;
                        ?>
              <span class="edit"><a href="<?php 
                        tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'revert_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-revert_edit_' . $last_edit->edit_id));
                        ?>
"><?php 
                        _e('Revert', 'tdomf');
                        ?>
</a> | </span>
           <?php 
                    } else {
                        if ($last_edit->state == 'unapproved' || $last_edit->state == 'spam') {
                            $bulk_edit_delete = true;
                            $bulk_edit_approve = true;
                            ?>
               <span class="delete"><a href="<?php 
                            tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'delete_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-delete_edit_' . $last_edit->edit_id));
                            ?>
"><?php 
                            _e('Delete', 'tdomf');
                            ?>
</a> | </span>
               <span class="edit"><a href="<?php 
                            tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'approve_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-approve_edit_' . $last_edit->edit_id));
                            ?>
"><?php 
                            _e('Approve', 'tdomf');
                            ?>
</a> | </span>
           <?php 
                        }
                    }
                    ?>
           <?php 
                    if ($previous_edit) {
                        ?>
               <span class="edit"><a href="admin.php?page=<?php 
                        echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $last_edit->edit_id;
                        ?>
&right=<?php 
                        echo $last_edit->edit_id;
                        ?>
&left=<?php 
                        echo $previous_edit->edit_id;
                        ?>
"><?php 
                        _e('Compare', 'tdomf');
                        ?>
</a>
           <?php 
                    } else {
                        ?>
               <!-- <span class="edit"><a href="revision.php?action=diff&right=<?php 
                        echo $last_edit->revision_id;
                        ?>
&left=<?php 
                        echo $last_edit->current_revision_id;
                        ?>
"><?php 
                        _e('Compare', 'tdomf');
                        ?>
</a> -->
               <span class="edit"><a href="admin.php?page=<?php 
                        echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $last_edit->edit_id;
                        ?>
&right=<?php 
                        echo $last_edit->edit_id;
                        ?>
&left=previous"><?php 
                        _e('Compare', 'tdomf');
                        ?>
</a>
           <?php 
                    }
                    ?>
        <?php 
                    if (get_option(TDOMF_OPTION_SPAM)) {
                        ?>
 |<?php 
                    }
                    ?>
</span>           
        <?php 
                    if (get_option(TDOMF_OPTION_SPAM)) {
                        if ($last_edit->state == 'spam') {
                            $bulk_edit_hamit = true;
                            ?>
             <span class="spam"><a href="<?php 
                            tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'hamit_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-hamit_edit_' . $last_edit->edit_id));
                            ?>
" title="<?php 
                            echo htmlentities(__('Flag contributation as not being spam', 'tdomf'));
                            ?>
" ><?php 
                            _e('Not Spam', 'tdomf');
                            ?>
</span>
         <?php 
                        } else {
                            $bulk_edit_spamit = true;
                            ?>
              <span class="spam"><a href="<?php 
                            tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'spamit_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-spamit_edit_' . $last_edit->edit_id));
                            ?>
" title="<?php 
                            echo htmlentities(__('Flag contributation as being spam', 'tdomf'));
                            ?>
" onclick="if ( confirm('<?php 
                            echo js_escape(__("You are about to flag this contribution as spam\n \\'Cancel\\' to stop, \\'OK\\' to delete.", 'tdomf'));
                            ?>
') ) { return true;}return false;"><?php 
                            _e('Spam', 'tdomf');
                            ?>
</a></span>
        <?php 
                        }
                    }
                    ?>
        
        <?php 
                }
                ?>
            
           </div>
        
        <?php 
            }
            ?>
        
        </td>
        
         <td class="status column-status">
         <!-- todo take into account edited status -->
         <?php 
            if ($is_spam && $post->post_status == 'draft') {
                ?>
                      <?php 
                _e('Spam', "tdomf");
                ?>
                   <?php 
            } else {
                switch ($post->post_status) {
                    case 'draft':
                        _e('Draft', "tdomf");
                        break;
                    case 'publish':
                        _e('Published', "tdomf");
                        break;
                    case 'future':
                        _e('Scheduled', "tdomf");
                        break;
                    default:
                        echo _e($post->post_status, "tdomf");
                        break;
                }
                if ($is_spam) {
                    _e(' (Spam)', "tdomf");
                }
                if ($locked) {
                    _e(' [Locked]', 'tdomf');
                }
            }
            ?>
         </td>
    <?php 
        }
    }
    ?>
    
    </tbody>
    
</table>

<div class="tablenav">

<?php 
    if ($page_links) {
        echo "<div class='tablenav-pages'>{$page_links_text}</div>";
    }
    ?>
         
<?php 
    if (count($posts) > 0) {
        ?>
    <div class="alignleft actions">
    <select name="action">
    <option value="-1" selected="selected"><?php 
        _e('Bulk Actions');
        ?>
</option>
    <?php 
        if ($bulk_sub_publish_now) {
            ?>
       <option value="publish_now"><?php 
            _e('Publish Submissions (Now)', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_sub_publish) {
            ?>
       <option value="publish"><?php 
            _e('Publish/Queue Submissions', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_sub_unpublish) {
            ?>
       <option value="unpublish"><?php 
            _e('Un-publish Submissions', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <option value="delete"><?php 
        _e('Delete Submissions', 'tdomf');
        ?>
</option>
    <?php 
        if ($bulk_sub_unlock) {
            ?>
        <option value="unlock"><?php 
            _e('Unlock Submissions', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_sub_lock) {
            ?>
        <option value="lock"><?php 
            _e('Lock Submissions', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_sub_spamit) {
            ?>
       <option value="spamit"><?php 
            _e('Mark Submissions as Spam', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_sub_hamit) {
            ?>
       <option value="hamit"><?php 
            _e('Mark Submissions as Not Spam', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_sub_hamit || $bulk_sub_spamit) {
            ?>
       <option value="spam_recheck"><?php 
            _e('Recheck Submssions for Spam', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_edit_approve) {
            ?>
        <option value="edit_approve"><?php 
            _e('Approve Edits', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    <?php 
        if ($bulk_edit_revert) {
            ?>
        <option value="edit_revert"><?php 
            _e('Revert Edits', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
   
    <?php 
        if ($bulk_edit_delete) {
            ?>
        <option value="edit_delete"><?php 
            _e('Delete Edits', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
     
    <?php 
        if ($bulk_edit_spamit) {
            ?>
        <option value="edit_spamit"><?php 
            _e('Mark Edits as Spam', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
     
    <?php 
        if ($bulk_edit_hamit) {
            ?>
        <option value="edit_hamit"><?php 
            _e('Mark Edits as not Spam', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
     
    <?php 
        if ($bulk_edit_hamit || $bulk_edit_spamit) {
            ?>
       <option value="edit_spam_recheck"><?php 
            _e('Recheck Edits for Spam', 'tdomf');
            ?>
</option>
    <?php 
        }
        ?>
    </select>
    <input type="submit" value="<?php 
        _e('Apply');
        ?>
" name="doaction" id="doaction" class="button-secondary action" />
    <?php 
        wp_nonce_field('tdomf-moderate-bulk');
    }
    ?>

    <!-- hide filters
    
    <select name='form'>
    <option value="-1" selected="selected"><?php 
    _e('Show All Forms', 'tdomf');
    ?>
</option>
    <?php 
    foreach ($form_ids as $form) {
        ?>
       <option value="<?php 
        echo $form->form_id;
        ?>
"><?php 
        printf(__('Form #%d', 'tdomf'), $form->form_id);
        ?>
</option>
    <?php 
    }
    ?>
    </select>
    
    -->
    
    <br class="clear" />

    </div> <!-- tablenav -->
    
    <br class="clear" />
    
</div> <!-- wrap -->

</form>

   <?php 
}
コード例 #6
0
function tdomf_show_form_export($form_id)
{
    if (!tdomf_form_exists($form_id)) {
        ?>
    <div><font color="red"><?php 
        printf(__("Form id %d does not exist!", "tdomf"), $form_id);
        ?>
</font></div>
  <?php 
    } else {
        ?>
    
    <div class="wrap">
    
    <h2><?php 
        printf(__("Export and Import Form %d Configuration:\"%s\"", "tdomf"), $form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id));
        ?>
</h2>
    
    <?php 
        tdomf_forms_under_title_toolbar($form_id, 'tdomf_show_form_export_menu');
        ?>
      
     <?php 
        $export_url = get_bloginfo('wpurl') . "?tdomf_export={$form_id}";
        $export_url = wp_nonce_url($export_url, 'tdomf-export-' . $form_id);
        ?>
    
     <p>
        <?php 
        printf(__('To export the configuration of this file, just <a href="%s">save this link</a>. To import, just use the form below to select a previousily exported file and click "Import"', "tdomf"), $export_url);
        ?>
     </p>
     </p>
    
     <form enctype="multipart/form-data" method="post" action="admin.php?page=tdomf_show_form_export_menu&form=<?php 
        echo $form_id;
        ?>
">
        <label for="import_file"><b><?php 
        _e("Form saved configuration to import: ");
        ?>
</b></label>
        <!-- <input type="hidden" name="MAX_FILE_SIZE" value="3000000" /> -->
        <input type="hidden" name='form_id' id='form_id' value='<?php 
        echo $form_id;
        ?>
'>
        <input type='file' name='import_file' id='import_file' size='30' />
        <input type="submit" name="tdomf_import" id="tdomf_import" value="<?php 
        _e("Import", "tdomf");
        ?>
" />
        <?php 
        wp_nonce_field('tdomf-import-' . $form_id);
        ?>
     </form>
     
  </div> <!-- wrap -->
  
  <?php 
    }
}
コード例 #7
0
// enable all PHP errors
//
if (get_option(TDOMF_OPTION_EXTRA_LOG_MESSAGES) && !get_option(TDOMF_OPTION_DISABLE_ERROR_MESSAGES)) {
    error_reporting(E_ALL);
}
// loading text domain for language translation
//
load_plugin_textdomain('tdomf', PLUGINDIR . DIRECTORY_SEPARATOR . TDOMF_FOLDER);
// Form id
//
if (!isset($_POST['tdomf_form_id'])) {
    tdomf_log_message("tdomf-form-post: No Form ID set!", TDOMF_LOG_BAD);
    exit(__("TDOMF: No Form id!", "tdomf"));
}
$form_id = intval($_POST['tdomf_form_id']);
if (!tdomf_form_exists($form_id)) {
    tdomf_log_message("tdomf-form-post: Bad form id %d!", TDOMF_LOG_BAD);
    exit(__("TDOMF: Bad Form Id", "tdomf"));
}
// Submit or Edit?
//
$is_edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id);
// Get Form Data for verficiation check
//
$form_data = tdomf_get_form_data($form_id);
// Get Post ID if there is one
//
$post_id = false;
if ($is_edit) {
    if (isset($form_data['tdomf_post_id'])) {
        $post_id = $form_data['tdomf_post_id'];
コード例 #8
0
function tdomf_content_adminbuttons_filter($content = '')
{
    global $post;
    $post_ID = 0;
    if (isset($post)) {
        $post_ID = $post->ID;
    } else {
        if ($post_ID == 0) {
            return $content;
        }
    }
    // use some form of the form_id
    $form_id = get_post_meta($post_ID, TDOMF_KEY_FORM_ID, true);
    if ($form_id == false || !tdomf_form_exists($form_id)) {
        $form_id = tdomf_get_first_form_id();
    }
    if (get_post_meta($post_ID, TDOMF_KEY_FLAG, true) && $post->post_status == 'draft' && current_user_can('publish_posts')) {
        $output = "<p>";
        $queue = intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id));
        if ($queue > 0) {
            $queue = true;
        } else {
            $queue = false;
        }
        if ($queue) {
            $publishnow_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_mod_posts_menu&action=publish&post={$post_ID}&nofuture=1";
            $publishnow_link = wp_nonce_url($publishnow_link, 'tdomf-publish_' . $post_ID);
        }
        $publish_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_mod_posts_menu&action=publish&post={$post_ID}";
        $publish_link = wp_nonce_url($publish_link, 'tdomf-publish_' . $post_ID);
        $delete_link = get_bloginfo('wpurl') . "/wp-admin/post.php?action=delete&post={$post_ID}";
        $delete_link = wp_nonce_url($delete_link, 'delete-post_' . $post_ID);
        if ($queue) {
            $output .= sprintf(__('[<a href="%s">Publish Now</a>] [<a href="%s">Add to Queue</a>] [<a href="%s">Delete</a>]', "tdomf"), $publishnow_link, $publish_link, $delete_link);
        } else {
            $output .= sprintf(__('[<a href="%s">Publish</a>] [<a href="%s">Delete</a>]', "tdomf"), $publish_link, $delete_link);
        }
        if (get_option(TDOMF_OPTION_SPAM)) {
            $spam_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_mod_posts_menu&action=spamit&post={$post_ID}";
            $spam_link = wp_nonce_url($spam_link, 'tdomf-spamit_' . $post_ID);
            $ham_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_mod_posts_menu&action=hamit&post={$post_ID}";
            $ham_link = wp_nonce_url($ham_link, 'tdomf-hamit_' . $post_ID);
            if (get_post_meta($post_ID, TDOMF_KEY_SPAM)) {
                $output .= sprintf(__(' [<a href="%s">Not Spam</a>]', "tdomf"), $ham_link);
            } else {
                return $content . sprintf(__(' [<a href="%s">Spam</a>]', "tdomf"), $spam_link);
            }
        }
        $output .= '</p>';
        return $content . $output;
    }
    return $content;
}
コード例 #9
0
function tdomf_show_form_hacker()
{
    global $wp_version;
    $form_id = false;
    if (isset($_REQUEST['form'])) {
        $form_id = $_REQUEST['form'];
    } else {
        $form_id = tdomf_get_first_form_id();
    }
    if ($form_id == false || !tdomf_form_exists($form_id)) {
        ?>
    <div class="wrap">
       <h2><?php 
        _e('Form Hacker', 'tdomf');
        ?>
</h2>
       <p><?php 
        if (is_numeric($form_id)) {
            printf(__('Invalid Form ID %s specified!'), $form_id);
        } else {
            _e('No Form ID specified!');
        }
        ?>
</p>
    </div>
  <?php 
    } else {
        if (isset($_REQUEST['diff'])) {
            ?>
    <div class="wrap">
          <?php 
            tdomf_form_hacker_diff($form_id);
            ?>
    </div> <!-- wrap -->
  <?php 
        } else {
            $mode = tdomf_generate_default_form_mode($form_id);
            $mode .= '-hack';
            tdomf_form_hacker_actions($form_id);
            $message = tdomf_get_error_messages(true, $form_id);
            if (!empty($message)) {
                ?>
        <div id="message" class="updated fade"><p><?php 
                echo $message;
                ?>
</p></div>
    <?php 
            }
            tdomf_forms_top_toolbar($form_id, 'tdomf_show_form_hacker');
            $form_ids = tdomf_get_form_ids();
            ?>
        
        <div class="wrap">
        <?php 
            if (!isset($_REQUEST['text'])) {
                ?>
          <h2><?php 
                printf(__("Form Hacker for Form %d: \"%s\"", "tdomf"), $form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id));
                ?>
</h2>            
        <?php 
            } else {
                ?>
          <h2><?php 
                printf(__("Message Hacker for Form %d: \"%s\"", "tdomf"), $form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id));
                ?>
</h2>            
        <?php 
            }
            ?>

          <script type="text/javascript">
            function tdomfHideHelp() {
                jQuery('#tdomf_help').attr('class','hidden');
                jQuery('#tdomf_show_help').attr('class','');
                jQuery('#tdomf_hide_help').attr('class','hidden');
            }
            function tdomfShowHelp() {
                jQuery('#tdomf_help').attr('class','');
                jQuery('#tdomf_show_help').attr('class','hidden');
                jQuery('#tdomf_hide_help').attr('class','');
            }
          </script>
          
          <?php 
            tdomf_forms_under_title_toolbar($form_id, 'tdomf_show_form_hacker');
            ?>
    
          <?php 
            if (isset($_REQUEST['text'])) {
                ?>
           
          <!-- <div id="tdomf_help" class='hidden'> -->
          
          <?php 
                $code_on = false;
                if (isset($_REQUEST['code'])) {
                    $code_on = true;
                }
                ?>
          
          <p><?php 
                _e("You can use this page to modify any messages outputed from TDOMF for your form. From here you can change the post published messages, post held in moderation, etc. etc.", "tdomf");
                ?>
</p>
            
          <?php 
                if (version_compare($wp_version, "2.8-beta2", ">=")) {
                    if (!$code_on) {
                        ?>
              <p><a href="admin.php?page=tdomf_show_form_hacker&text&code&form=<?php 
                        echo $form_id;
                        ?>
"><?php 
                        _e("Enable Code Syntax Highlighting...", 'tdomf');
                        ?>
</a></p>
          <?php 
                    } else {
                        ?>
              <p><a href="admin.php?page=tdomf_show_form_hacker&text&form=<?php 
                        echo $form_id;
                        ?>
"><?php 
                        _e("Disable Code Syntax Highlighting...", 'tdomf');
                        ?>
</a></p>
          <?php 
                    }
                }
                ?>
          
          <?php 
                $form_edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id);
                ?>
 
          
          <p><?php 
                _e("PHP code can be included in the hacked messages. Also TDOMF will automatically expand these macro strings:", "tdomf");
                ?>
             <ul>
             <li><?php 
                printf(__("<code>%s</code> - User name of the currently logged in user", "tdomf"), TDOMF_MACRO_USERNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - IP of the current visitor", "tdomf"), TDOMF_MACRO_IP);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The ID of the current form (which is currently %d)", "tdomf"), TDOMF_MACRO_FORMID, $form_id);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Name of the Form (set in options)", "tdomf"), TDOMF_MACRO_FORMNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Form Description (set in options)", "tdomf"), TDOMF_MACRO_FORMDESCRIPTION);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Submission Errors", "tdomf"), TDOMF_MACRO_SUBMISSIONERRORS);
                ?>
             <?php 
                if ($form_edit) {
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - URL of Post/Page being edited", "tdomf"), TDOMF_MACRO_SUBMISSIONURL);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Original Submission Date", "tdomf"), TDOMF_MACRO_SUBMISSIONDATE);
                    ?>
             
             <li><?php 
                    printf(__("<code>%s</code> - Original Submission Time", "tdomf"), TDOMF_MACRO_SUBMISSIONTIME);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Title of Post/Page being edited", "tdomf"), TDOMF_MACRO_SUBMISSIONTITLE);
                    ?>
             <?php 
                } else {
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - URL of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONURL);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Date of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONDATE);
                    ?>
             
             <li><?php 
                    printf(__("<code>%s</code> - Time of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONTIME);
                    ?>
             <li><?php 
                    printf(__("<code>%s</code> - Title of Submission", "tdomf"), TDOMF_MACRO_SUBMISSIONTITLE);
                    ?>
             <?php 
                }
                ?>
             </ul>
          </p>
          
          <!-- </div> -->
          
          <form method="post" name="formhackermsgs" id="formhackermsgs">
          <?php 
                if (function_exists('wp_nonce_field')) {
                    wp_nonce_field('tdomf-form-hacker');
                }
                ?>
          
          <p class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_save" name="tdomf_hack_messages_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_reset" name="tdomf_hack_messages_reset" />
          </p>
          
          <?php 
                if (!tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id) && !tdomf_get_option_form(TDOMF_OPTION_REDIRECT, $form_id)) {
                    ?>
              <h3><?php 
                    if ($form_edit) {
                        _e('Contribution Approved', 'tdomf');
                    } else {
                        _e('Submission Published', 'tdomf');
                    }
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_publish" id="tdomf_msg_sub_publish" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_PUBLISH, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
                    
          <?php 
                if (intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id)) > 0 && !tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id)) {
                    ?>
              <h3><?php 
                    _e('Submission Queued', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_future" id="tdomf_msg_sub_future" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_FUTURE, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (get_option(TDOMF_OPTION_SPAM)) {
                    ?>
              <h3><?php 
                    if ($form_edit) {
                        _e('Contribution is Spam', 'tdomf');
                    } else {
                        _e('Submission is Spam', 'tdomf');
                    }
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_spam" id="tdomf_msg_sub_spam" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_SPAM, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (tdomf_get_option_form(TDOMF_OPTION_MODERATION, $form_id)) {
                    ?>
              <h3><?php 
                    if ($form_edit) {
                        _e('Contribution awaiting Moderation', 'tdomf');
                    } else {
                        _e('Submission awaiting Moderation', 'tdomf');
                    }
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_mod" id="tdomf_msg_sub_mod" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_MOD, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <h3><?php 
                if ($form_edit) {
                    _e('Contribution contains Errors', 'tdomf');
                } else {
                    _e('Submission contains Errors', 'tdomf');
                }
                ?>
</h3>
          <textarea title="true" rows="5" cols="70" name="tdomf_msg_sub_error" id="tdomf_msg_sub_error" <?php 
                if ($code_on) {
                    ?>
class="codepress .php"<?php 
                }
                ?>
 ><?php 
                echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SUB_ERROR, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
          <br/><br/>
          
          <h3><?php 
                _e('Banned User', 'tdomf');
                ?>
</h3>
          <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_banned_user" id="tdomf_msg_perm_banned_user" <?php 
                if ($code_on) {
                    ?>
class="codepress .php"<?php 
                }
                ?>
 ><?php 
                echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_BANNED_USER, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
          <br/><br/>

          <h3><?php 
                _e('Banned IP', 'tdomf');
                ?>
</h3>          
          <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_banned_ip" id="tdomf_msg_perm_banned_ip" <?php 
                if ($code_on) {
                    ?>
class="codepress .php"<?php 
                }
                ?>
 ><?php 
                echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_BANNED_IP, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
          <br/><br/>
          
          <?php 
                $throttle_rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
                if (is_array($throttle_rules) && !empty($throttle_rules)) {
                    ?>
              <h3><?php 
                    _e('Throttled Submission', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_throttle" id="tdomf_msg_perm_throttle" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_THROTTLE, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (!tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id)) {
                    ?>
              <h3><?php 
                    _e('Denied User', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_invalid_user" id="tdomf_msg_perm_invalid_user" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_INVALID_USER, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>
          
          <?php 
                if (!tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id)) {
                    ?>
              <h3><?php 
                    _e('Banned Unregistered User', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_perm_invalid_nouser" id="tdomf_msg_perm_invalid_nouser" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_PERM_INVALID_NOUSER, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
          <?php 
                }
                ?>

          <?php 
                if ($form_edit) {
                    ?>

              <?php 
                    /*if(tdomf_get_option_form(TDOMF_OPTION_AJAX_EDIT,$form_id)) {*/
                    ?>
              
                 <h3><?php 
                    _e('\'Edit Post\' Link Text', 'tdomf');
                    ?>
</h3>
                 <textarea title="true" rows="5" cols="70" name="tdomf_msg_edit_post_link" id="tdomf_msg_edit_post_link" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_ADD_EDIT_LINK_TEXT, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
                 <br/><br/>
             
              <?php 
                    /*}*/
                    ?>
              
              <h3><?php 
                    _e('Invalid Post for Form', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_invalid_post" id="tdomf_msg_invalid_post" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_INVALID_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
              
              <h3><?php 
                    _e('Invalid Form for Post', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_invalid_form" id="tdomf_msg_invalid_form" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_INVALID_FORM, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
              
              <h3><?php 
                    _e('Locked Post', 'tdomf');
                    ?>
</h3>
              <textarea title="true" rows="5" cols="70" name="tdomf_msg_locked_post" id="tdomf_msg_locked_post" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_LOCKED_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
              <br/><br/>
              
              <?php 
                    if (get_option(TDOMF_OPTION_SPAM)) {
                        ?>

                 <h3><?php 
                        _e('Spam Edit on Post', 'tdomf');
                        ?>
</h3>
                 <textarea title="true" rows="5" cols="70" name="tdomf_msg_spam_edit_on_post" id="tdomf_msg_spam_edit_on_post" <?php 
                        if ($code_on) {
                            ?>
class="codepress .php"<?php 
                        }
                        ?>
 ><?php 
                        echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_SPAM_EDIT_ON_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                        ?>
</textarea>
                 <br/><br/>
                  
              <?php 
                    }
                    ?>
              
             <h3><?php 
                    _e('Unapproved Edit on Post', 'tdomf');
                    ?>
</h3>
             <textarea title="true" rows="5" cols="70" name="tdomf_msg_unapproved_edit_on_post" id="tdomf_msg_unapproved_edit_on_post" <?php 
                    if ($code_on) {
                        ?>
class="codepress .php"<?php 
                    }
                    ?>
 ><?php 
                    echo htmlentities(tdomf_get_message(TDOMF_OPTION_MSG_UNAPPROVED_EDIT_ON_POST, $form_id), ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
             <br/><br/>

          <?php 
                }
                ?>
          
          <?php 
                do_action('tdomf_form_hacker_messages_bottom', $form_id, $mode);
                ?>
                    
          <span class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_save" name="tdomf_hack_messages_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_hack_messages_reset" name="tdomf_hack_messages_reset" />
          </span>
          
          </form>
          
          <?php 
            } else {
                ?>
          
          <!-- <div id="tdomf_help" class='hidden'> -->
          
          <p><?php 
                _e("You can use this page to hack the generated HTML code for your form without modifing the code of TDOMF. Please only do this if you know what you are doing. From here you can modify titles, default values, re-arrange fields, etc. etc.", "tdomf");
                ?>
</p>
             
          <p><?php 
                _e('Do not modify or remove the "name" and "id" attributes of fields as this is what the widgets and TDOMF use to get input values for processing', 'tdomf');
                ?>
</p>
             
          <p><?php 
                printf(__("Every time a form is generated, it creates a unique key. If you hack the form, make sure you keep <code>%s</code> (and also <code>%s</code>) within the form. TDOMF will replace this string with the unique key.", "tdomf"), TDOMF_MACRO_FORMKEY, TDOMF_MACRO_FORMURL);
                ?>
</p>
          
          <p><?php 
                _e("PHP code can be included in the hacked form. Also TDOMF will automatically expand these macro strings:", "tdomf");
                ?>
             <ul>
             <li><?php 
                printf(__("<code>%s</code> - User name of the currently logged in user", "tdomf"), TDOMF_MACRO_USERNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - IP of the current visitor", "tdomf"), TDOMF_MACRO_IP);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The form's unique key", "tdomf"), TDOMF_MACRO_FORMKEY);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The current URL of the form", "tdomf"), TDOMF_MACRO_FORMURL);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - The ID of the current form (which is currently %d)", "tdomf"), TDOMF_MACRO_FORMID, $form_id);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Name of the Form (set in options)", "tdomf"), TDOMF_MACRO_FORMNAME);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Form Description (set in options)", "tdomf"), TDOMF_MACRO_FORMDESCRIPTION);
                ?>
             <li><?php 
                printf(__("<code>%s</code> - Form Output (such as preview, errors, etc.). This is automatically encapsulated in a div called tdomf_form_message (and tdomf_form_preview for preview)", "tdomf"), TDOMF_MACRO_FORMMESSAGE);
                ?>
             <li><?php 
                printf(__("<code>%swidget-name%s</code> - Original, unmodified output from 'widget-name'", "tdomf"), TDOMF_MACRO_WIDGET_START, TDOMF_MACRO_END);
                ?>
             </ul>
          </p>
          
          <!-- </div> -->
 
          <form method="post" name="formhacker" id="formhacker">
          <?php 
                if (function_exists('wp_nonce_field')) {
                    wp_nonce_field('tdomf-form-hacker');
                }
                ?>
      
          <p class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_save" name="tdomf_form_hack_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_reset" name="tdomf_form_hack_reset" />
          </p>
          
          <?php 
                if (tdomf_widget_is_preview_avaliable($form_id)) {
                    ?>
          
              <h3><?php 
                    _e('Core Form', 'tdomf');
                    ?>
</h3>
              
          <?php 
                }
                ?>
          
            <?php 
                $cur_form = tdomf_generate_form($form_id, $mode);
                $form = $cur_form;
                $hacked_form = tdomf_get_option_form(TDOMF_OPTION_FORM_HACK, $form_id);
                if ($hacked_form != false) {
                    $form = $hacked_form;
                }
                ?>
                  
            <?php 
                if ($hacked_form != false) {
                    ?>
              <?php 
                    _e("You can diff the hacked form to see what you have changed", "tdomf");
                    ?>
              <ul>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                    echo $form_id;
                    ?>
&mode=<?php 
                    echo $mode;
                    ?>
&diff&form1=hack&form2=cur"><?php 
                    _e("Diff Hacked Form with Current Form", "tdomf");
                    ?>
</a></li>
              <?php 
                    $org_form = tdomf_get_option_form(TDOMF_OPTION_FORM_HACK_ORIGINAL, $form_id);
                    if (trim($cur_form) != trim($org_form)) {
                        ?>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                        echo $form_id;
                        ?>
&mode=<?php 
                        echo $mode;
                        ?>
&diff&form2=hack&form1=org"><?php 
                        _e("Diff Hacked Form with Previous Form", "tdomf");
                        ?>
</a></li>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                        echo $form_id;
                        ?>
&mode=<?php 
                        echo $mode;
                        ?>
&diff&form2=cur&form1=org"><?php 
                        _e("Diff Current Form with Previous Form", "tdomf");
                        ?>
</a></li>
                    <?php 
                    }
                    ?>
              </ul>
            <?php 
                }
                ?>
                  
            <textarea title="true" rows="30" cols="100" name="tdomf_form_hack" id="tdomf_form_hack" class="codepress .php" ><?php 
                echo htmlentities($form, ENT_NOQUOTES, get_bloginfo('charset'));
                ?>
</textarea>
            
          <br/><br/>
          
          <?php 
                if (tdomf_widget_is_preview_avaliable($form_id)) {
                    ?>
          
              <h3><?php 
                    _e('Form Preview', 'tdomf');
                    ?>
</h3>
              
              <?php 
                    $cur_preview = tdomf_preview_form(array('tdomf_form_id' => $form_id), $mode);
                    $preview = $cur_preview;
                    $hacked_preview = tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK, $form_id);
                    if ($hacked_preview != false) {
                        $preview = $hacked_preview;
                    }
                    ?>
              
              <?php 
                    if ($hacked_preview != false) {
                        ?>
              <?php 
                        _e("You can diff the hacked preview to see what you have changed", "tdomf");
                        ?>
              <ul>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                        echo $form_id;
                        ?>
&mode=<?php 
                        echo $mode;
                        ?>
&diff&form1=hack&form2=cur&type=preview"><?php 
                        _e("Diff Hacked Preview with Current Preview", "tdomf");
                        ?>
</a></li>
              <?php 
                        $org_preview = tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK_ORIGINAL, $form_id);
                        if (trim($cur_preview) != trim($org_preview)) {
                            ?>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                            echo $form_id;
                            ?>
&mode=<?php 
                            echo $mode;
                            ?>
&diff&form2=hack&form1=org&type=preview"><?php 
                            _e("Diff Hacked Preview with Previous Preview", "tdomf");
                            ?>
</a></li>
              <li><a href="admin.php?page=tdomf_show_form_hacker&form=<?php 
                            echo $form_id;
                            ?>
&mode=<?php 
                            echo $mode;
                            ?>
&diff&form2=cur&form1=org&type=preview"><?php 
                            _e("Diff Current Preview with Previous Preview", "tdomf");
                            ?>
</a></li>
                    <?php 
                        }
                        ?>
              </ul>
            <?php 
                    }
                    ?>
                    
                    
              <textarea title="true" rows="15" cols="100" name="tdomf_form_preview_hack" id="tdomf_form_preview_hack" class="codepress .php"><?php 
                    echo htmlentities($preview, ENT_NOQUOTES, get_bloginfo('charset'));
                    ?>
</textarea>
                
              <br/><br/>
                
          <?php 
                }
                ?>

          <!-- @TODO Validation Message Hacker -->
          <!-- @TODO Upload Form Hacker -->     
          <?php 
                do_action('tdomf_form_hacker_bottom', $form_id, $mode);
                ?>
          
          <span class="submit">
          <input type="submit" value="<?php 
                _e('Save &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_save" name="tdomf_form_hack_save" />
          <input type="submit" value="<?php 
                _e('Reset &raquo;', 'tdomf');
                ?>
" id="tdomf_form_hack_reset" name="tdomf_form_hack_reset" />
          </span>
          
          </form>
          
          <!-- @TODO: warning about updated form (with dismiss link) -->
          
          <?php 
            }
            ?>
          
        </div>
    <?php 
        }
    }
}
コード例 #10
0
function tdomf_widget_categories_init($form_id, $mode)
{
    if (tdomf_form_exists($form_id) && strpos($mode, 'new-post') !== false) {
        $count = tdomf_get_option_widget('tdomf_categories_widget_count', $form_id);
        $max = tdomf_get_option_form(TDOMF_OPTION_WIDGET_INSTANCES, $form_id);
        if ($max <= 1) {
            $count = 1;
        } else {
            if ($count > $max + 1) {
                $count = $max + 1;
            }
        }
        tdomf_register_form_widget("categories", "Categories 1", 'tdomf_widget_categories', array(), 1);
        tdomf_register_form_widget_hack("categories", "Categories 1", 'tdomf_widget_categories', array(), 1);
        tdomf_register_form_widget_control("categories", "Categories 1", 'tdomf_widget_categories_control', 370, 610, array(), 1);
        tdomf_register_form_widget_preview("categories", "Categories 1", 'tdomf_widget_categories_preview', array(), 1);
        tdomf_register_form_widget_preview_hack("categories", "Categories 1", 'tdomf_widget_categories_preview_hack', array(), 1);
        tdomf_register_form_widget_post("categories", "Categories 1", 'tdomf_widget_categories_post', array(), 1);
        tdomf_register_form_widget_adminemail("categories", "Categories 1", 'tdomf_widget_categories_adminemail', array(), 1);
        tdomf_register_form_widget_admin_error("categories", "Categories 1", 'tdomf_widget_categories_admin_error', array(), 1);
        for ($i = 2; $i <= $count; $i++) {
            tdomf_register_form_widget("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories', array(), $i);
            tdomf_register_form_widget_hack("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories', array(), $i);
            tdomf_register_form_widget_control("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_control', 370, 610, array(), $i);
            tdomf_register_form_widget_preview("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_preview', array(), $i);
            tdomf_register_form_widget_preview_hack("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_preview_hack', array(), $i);
            tdomf_register_form_widget_post("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_post', array(), $i);
            tdomf_register_form_widget_adminemail("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_adminemail', array(), $i);
            tdomf_register_form_widget_admin_error("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_admin_error', array(), $i);
        }
    }
}
コード例 #11
0
function tdomf_show_edit_post_panel()
{
    global $post;
    // don't show on new post
    if ($post->ID > 0) {
        $can_edit = false;
        if (current_user_can('publish_posts')) {
            $can_edit = true;
        }
        $is_tdomf = false;
        $tdomf_flag = get_post_meta($post->ID, TDOMF_KEY_FLAG, true);
        if (!empty($tdomf_flag)) {
            $is_tdomf = true;
        }
        $locked = get_post_meta($post->ID, TDOMF_KEY_LOCK, true);
        $submitter_id = get_post_meta($post->ID, TDOMF_KEY_USER_ID, true);
        $submitter_ip = get_post_meta($post->ID, TDOMF_KEY_IP, true);
        $form_id = get_post_meta($post->ID, TDOMF_KEY_FORM_ID, true);
        $is_spam = get_option(TDOMF_OPTION_SPAM) && get_post_meta($post->ID, TDOMF_KEY_SPAM, true);
        // use JavaScript SACK library for AJAX
        wp_print_scripts(array('sack'));
        // I could stick this AJAX call into the Admin header, however, I don't want
        // it hanging around on every admin page and potentially being called
        // accidentially from some other TDOMF page
        ?>
         <script type="text/javascript">
         //<![CDATA[
         function tdomf_ajax_edit_post( flag, is_user, user, name, email, web, locked )
         {
           var mysack = new sack( "<?php 
        bloginfo('wpurl');
        ?>
/wp-admin/admin-ajax.php" );
           mysack.execute = 1;
           mysack.method = 'POST';
           mysack.setVar( "action", "tdomf_edit_post" );
           mysack.setVar( "post_ID", "<?php 
        echo $post->ID;
        ?>
" );
           mysack.setVar( "tdomf_flag", flag.checked );
           mysack.setVar( "tdomf_locked", locked.checked );
           if(is_user.checked) {
              mysack.setVar( "tdomf_user", user.value);
           } else {
              mysack.setVar( "tdomf_name", name.value );
              mysack.setVar( "tdomf_email", email.value );
              mysack.setVar( "tdomf_web", web.value );
           }
           mysack.encVar( "cookie", document.cookie, false );
           mysack.onError = function() { alert('<?php 
        _e('AJAX error in looking up tdomf', 'tdomf');
        ?>
' )};
           mysack.runAJAX();

           return true;
         }

         function tdomf_update_panel() {
          <?php 
        if ($can_edit) {
            ?>
            var flag = document.getElementById("tdomf_flag").checked;
            if(flag) {
              //document.getElementById("tdomf_submitter").disabled = false;
              document.getElementById("tdomf_submitter_is_user").disabled = false;
              document.getElementById("tdomf_submitter_not_user").disabled = false;
              var is_user = document.getElementById("tdomf_submitter_is_user").checked;
              document.getElementById("tdomf_submitter_user").disabled = !is_user;
              document.getElementById("tdomf_submitter_name").disabled = is_user;
              document.getElementById("tdomf_submitter_email").disabled = is_user;
              document.getElementById("tdomf_submitter_web").disabled = is_user;
            } else {
              // disable everything
              //document.getElementById("tdomf_submitter").disabled = true;
              document.getElementById("tdomf_submitter_is_user").disabled = true;
              document.getElementById("tdomf_submitter_user").disabled = true;
              document.getElementById("tdomf_submitter_not_user").disabled = true;
              document.getElementById("tdomf_submitter_name").disabled = true;
              document.getElementById("tdomf_submitter_email").disabled = true;
              document.getElementById("tdomf_submitter_web").disabled = true;
            }
          <?php 
        } else {
            ?>
            // nothing can be enabled
            //document.getElementById("tdomf_submitter").disabled = true;
            document.getElementById("tdomf_flag").disabled = true;
            document.getElementById("tdomf_submitter_is_user").disabled = true;
            document.getElementById("tdomf_submitter_user").disabled = true;
            document.getElementById("tdomf_submitter_not_user").disabled = true;
            document.getElementById("tdomf_submitter_name").disabled = true;
            document.getElementById("tdomf_submitter_email").disabled = true;
            document.getElementById("tdomf_submitter_web").disabled = true;
          <?php 
        }
        ?>
        }
        //]]>
        </SCRIPT>

     <?php 
        if (!function_exists('add_meta_box')) {
            ?>
        <fieldset class="dbx-box">
        <h3 id="posttdomf" class="dbx-handle"><?php 
            _e('TDO Mini Forms', "tdomf");
            ?>
</h3>
                <div class="dbx-content">
     <?php 
        }
        ?>
                
                <fieldset>
                
                <legend>
                <input id="tdomf_flag" type="checkbox" name="tdomf_flag" <?php 
        if ($tdomf_flag) {
            ?>
checked<?php 
        }
        ?>
 <?php 
        if (!$can_edit) {
            ?>
 disabled <?php 
        }
        ?>
 onClick="tdomf_update_panel();" />
                <label for="tdomf_flag"><?php 
        _e("Include in TDO Mini Forms Moderation", "tdomf");
        ?>
</label>
                </legend>

                <br/>
                
                <input id="tdomf_locked" type="checkbox" name="tdomf_locked" <?php 
        if ($tdomf_locked) {
            ?>
checked<?php 
        }
        ?>
 <?php 
        if (!$can_edit) {
            ?>
 disabled <?php 
        }
        ?>
 onClick="tdomf_update_panel();" />
                <label for="tdomf_locked"><?php 
        _e('Disable Editing by TDO Mini Form Forms', 'tdomf');
        ?>
</label>
                
                <br/><br/>
                                
                <?php 
        if (!empty($submitter_id) && $submitter_id == get_option(TDOMF_DEFAULT_AUTHOR)) {
            ?>
                  <span style="color:red;font-size:larger;"><?php 
            _e('The submitter of this post is set as the "default user"! Please correct!', 'tdomf');
            ?>
</span>
                  <br/><br/>
                <?php 
        }
        ?>

                <label for="tdomf_submitter_is_user" class="selectit">
                <input id="tdomf_submitter_is_user" type="radio" name="tdomf_submitter" value="tdomf_submitter_is_user" <?php 
        if (!empty($submitter_id)) {
            ?>
checked<?php 
        }
        ?>
 <?php 
        if (!$can_edit || !$tdomf_flag) {
            ?>
 disabled <?php 
        }
        ?>
 onChange="tdomf_update_panel();" />
                <?php 
        _e('Submitter is an existing user', 'tdomf');
        ?>
</label>

                <?php 
        if (function_exists('add_meta_box')) {
            ?>
                  <br/><br/>
                <?php 
        }
        ?>
                
                <?php 
        if (tdomf_get_all_users_count() < TDOMF_MAX_USERS_TO_DISPLAY) {
            ?>
                <select id="tdomf_submitter_user" name="tdomf_submitter_user" <?php 
            if (!$can_edit || !$tdomf_flag || empty($submitter_id)) {
                ?>
 disabled <?php 
            }
            ?>
 onChange="tdomf_update_panel();" >
                <?php 
            $users = tdomf_get_all_users();
            foreach ($users as $user) {
                $status = get_usermeta($user->ID, TDOMF_KEY_STATUS);
                if ($user->ID == $submitter_id || $user->ID != get_option(TDOMF_DEFAULT_AUTHOR)) {
                    ?>
                          <option value="<?php 
                    echo $user->ID;
                    ?>
" <?php 
                    if ($user->ID == $submitter_id) {
                        ?>
 selected <?php 
                    }
                    ?>
 ><?php 
                    echo $user->user_login;
                    if ($user->ID == get_option(TDOMF_DEFAULT_AUTHOR)) {
                        _e("(Default User)", "tdomf");
                    }
                    if (!empty($status) && $status == TDOMF_USER_STATUS_BANNED) {
                        _e("(Banned User)", "tdomf");
                    }
                    ?>
</option>
                      <?php 
                }
            }
            ?>
               </select>
                <?php 
        } else {
            $submitter_username = "";
            if (!empty($submitter_id)) {
                $user_obj = new WP_User($submitter_id);
                $submitter_username = $user_obj->user_login;
            }
            ?>
                    <input type="text" 
                           name="tdomf_submitter_user" id="tdomf_submitter_user" 
                           size="20" 
                           value="<?php 
            echo htmlentities($submitter_username, ENT_QUOTES, get_bloginfo('charset'));
            ?>
" 
                           <?php 
            if (!$can_edit || !$tdomf_flag) {
                ?>
 disabled <?php 
            }
            ?>
 />
                <?php 
        }
        ?>

                <br/><br/>

                <label for="tdomf_submitter_not_user" class="selectit">
                <input id="tdomf_submitter_not_user" type="radio" name="tdomf_submitter" value="tdomf_submitter_not_user" <?php 
        if (empty($submitter_id)) {
            ?>
checked<?php 
        }
        ?>
 <?php 
        if (!$can_edit || !$tdomf_flag) {
            ?>
 disabled <?php 
        }
        ?>
 onChange="tdomf_update_panel();" />
                <?php 
        _e("Submitter does not have a user account", "tdomf");
        ?>
</label>

                <?php 
        if (function_exists('add_meta_box')) {
            ?>
                  <br/><br/>
                <?php 
        }
        ?>

                <?php 
        if (!function_exists('add_meta_box')) {
            ?>
                <label for="tdomf_submitter_name" class="selectit"><?php 
            _e("Name", "tdomf");
            ?>
                <?php 
        }
        ?>
                <input type="textfield" value="<?php 
        echo htmlentities(get_post_meta($post->ID, TDOMF_KEY_NAME, true), ENT_QUOTES, get_bloginfo('charset'));
        ?>
" name="tdomf_submitter_name" id="tdomf_submitter_name" onClick="tdomf_update_panel();" <?php 
        if (!$can_edit || !$tdomf_flag || !empty($submitter_id)) {
            ?>
 disabled <?php 
        }
        ?>
 />
                <?php 
        if (function_exists('add_meta_box')) {
            ?>
                <label for="tdomf_submitter_name" class="selectit"><?php 
            _e("Name", "tdomf");
            ?>
                <?php 
        }
        ?>
                </label>

                <?php 
        if (function_exists('add_meta_box')) {
            ?>
                  <br/><br/>
                <?php 
        }
        ?>
                
                <?php 
        if (!function_exists('add_meta_box')) {
            ?>
                <label for="tdomf_submitter_email" class="selectit"><?php 
            _e("Email", "tdomf");
            ?>
                <?php 
        }
        ?>
                <input type="textfield" value="<?php 
        echo htmlentities(get_post_meta($post->ID, TDOMF_KEY_EMAIL, true), ENT_QUOTES, get_bloginfo('charset'));
        ?>
" name="tdomf_submitter_email" id="tdomf_submitter_email" onClick="tdomf_update_panel();" <?php 
        if (!$can_edit || !$tdomf_flag || !empty($submitter_id)) {
            ?>
 disabled <?php 
        }
        ?>
 />
                <?php 
        if (function_exists('add_meta_box')) {
            ?>
                <label for="tdomf_submitter_email" class="selectit"><?php 
            _e("Email", "tdomf");
            ?>
                <?php 
        }
        ?>
                </label>

                <?php 
        if (function_exists('add_meta_box')) {
            ?>
                  <br/><br/>
                <?php 
        }
        ?>
                
                <?php 
        if (!function_exists('add_meta_box')) {
            ?>
                <label for="tdomf_submitter_web" class="selectit"><?php 
            _e("Webpage", "tdomf");
            ?>
                <?php 
        }
        ?>
                <input type="textfield" value="<?php 
        echo htmlentities(get_post_meta($post->ID, TDOMF_KEY_WEB, true), ENT_QUOTES, get_bloginfo('charset'));
        ?>
" name="tdomf_submitter_web" id="tdomf_submitter_web" onClick="tdomf_update_panel();" <?php 
        if (!$can_edit || !$tdomf_flag || !empty($submitter_id)) {
            ?>
 disabled <?php 
        }
        ?>
 />
                <?php 
        if (function_exists('add_meta_box')) {
            ?>
                <label for="tdomf_submitter_web" class="selectit"><?php 
            _e("Webpage", "tdomf");
            ?>
                <?php 
        }
        ?>
                </label>

                <br/><br/>

                <?php 
        if ($is_spam) {
            ?>
                    <span style="color:red;font-size:larger;"><?php 
            _e("Akismet thinks this submission is spam!", 'tdomf');
            ?>
</span>
                <?php 
        }
        ?>
              
                <?php 
        if (!empty($submitter_ip)) {
            ?>
                  <?php 
            printf(__("This post was submitted from IP %s.", "tdomf"), $submitter_ip);
            ?>
                <?php 
        } else {
            ?>
                  <?php 
            _e("No IP was recorded when this post was submitted.", "tdomf");
            ?>
                <?php 
        }
        ?>
                <?php 
        if ($form_id != false && tdomf_form_exists($form_id)) {
            printf(__("Submitted from Form %d.", "tdomf"), $form_id);
        }
        ?>
                </fieldset>

                 <p><input type="button" value="<?php 
        _e("Update &raquo;", "tdomf");
        ?>
" onclick="tdomf_ajax_edit_post(this.form.tdomf_flag, tdomf_submitter_is_user, tdomf_submitter_user, tdomf_submitter_name, tdomf_submitter_email, tdomf_submitter_web, this.form.tdomf_locked);" />

     <?php 
        if (!function_exists('add_meta_box')) {
            ?>
                </div>
        </fieldset>
     <?php 
        }
        ?>

<?php 
    }
}
コード例 #12
0
ファイル: tdomf-db.php プロジェクト: TheReaCompany/pooplog
function tdomf_delete_form($form_id)
{
    if (tdomf_form_exists($form_id)) {
        global $wpdb, $wp_roles;
        // Delete pages created with this form
        //
        $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES, $form_id);
        if ($pages != false) {
            foreach ($pages as $page_id) {
                if (get_permalink($page_id) != false) {
                    wp_delete_post($page_id);
                }
            }
        }
        // Delete form options
        //
        $table_name = $wpdb->prefix . TDOMF_DB_TABLE_FORMS;
        $query = "DELETE FROM {$table_name}\n              WHERE form_id = '" . $wpdb->escape($form_id) . "'";
        $wpdb->query($query);
        // Delete widget options
        //
        $table_name = $wpdb->prefix . TDOMF_DB_TABLE_WIDGETS;
        $query = "DELETE FROM {$table_name}\n              WHERE form_id = '" . $wpdb->escape($form_id) . "'";
        $wpdb->query($query);
        // Remove capablitiies from roles
        //
        $roles = $wp_roles->role_objects;
        foreach ($roles as $role) {
            if (isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id);
            }
        }
        return true;
    }
    return false;
}
コード例 #13
0
function tdomf_import_form_from_file()
{
    $form_id = $_REQUEST['form_id'];
    $ok = true;
    $message = false;
    if (!tdomf_form_exists($form_id)) {
        tdomf_log_message("tdomf_import_form_from_file: bad form id: {$form_id}", TDOMF_LOG_ERROR);
        $ok = false;
    }
    if (!current_user_can('manage_options')) {
        $ok = false;
    }
    if ($ok) {
        check_admin_referer('tdomf-import-' . $form_id);
    }
    if ($ok) {
        if (isset($_FILES["import_file"])) {
            $thefile = $_FILES["import_file"];
            # tmp_name, name, error, size, type
            if (@is_uploaded_file($thefile['tmp_name'])) {
                tdomf_log_message("Import File Found");
                $fh = @fopen($thefile['tmp_name'], 'r');
                if ($fh != false) {
                    $form_import = fread($fh, filesize($thefile['tmp_name']));
                    fclose($fh);
                } else {
                    tdomf_log_message("Error opening file!");
                    $message = __("Error importing form", "tdomf", TDOMF_LOG_ERROR);
                    $ok = false;
                }
                @unlink($thefile['tmp_name']);
            } else {
                tdomf_log_message("Error uploading file! <pre>" . var_export($_FILES["import_file"], true) . "</pre>", TDOMF_LOG_ERROR);
                $message = __("Error importing form", "tdomf");
                $ok = false;
            }
        } else {
            tdomf_log_message("Error no 'import_file' value: <pre>" . var_export($_FILES, true) . "</pre>", TDOMF_LOG_ERROR);
            $message = __("Error importing form", "tdomf", TDOMF_LOG_ERROR);
            $ok = false;
        }
        /*$fh = @fopen('/storage/home/associat/c/cammy/form_export_1.txt', 'r');
          if($fh != false)
          {
             #$form_import = fread($fh, filesize('/storage/home/associat/c/cammy/form_export_1.txt') + 100);
             while (!feof($fh)) {
                 $form_import .= fread($fh, 8192);
             }
             fclose($fh);
             tdomf_log_message("Seralized form data: <pre>" . htmlentities($form_import) . "</pre>");
          } else {
              tdomf_log_message("Error opening file!" );
              $message = __("Error importing form","tdomf",TDOMF_LOG_ERROR);
              $ok = false;
          }*/
    }
    if ($ok) {
        #error_reporting(E_ALL);
        $form_data = unserialize($form_import);
        if (is_array($form_data)) {
            tdomf_import_form($form_id, $form_data['options'], $form_data['widgets'], $form_data['caps']);
            tdomf_log_message("Form import succeeded <pre>" . htmlentities(var_export($form_data, true)) . "</pre>", TDOMF_LOG_GOOD);
            $message = __("Form import successful", "tdomf");
        } else {
            if ($form_data == false) {
                tdomf_log_message("Form import failed. Couldn't unserialize data: <pre>" . htmlentities($form_import) . "</pre>", TDOMF_LOG_ERROR);
                $message = __("Failed to unserialize form data: Form import failed", "tdomf");
            } else {
                tdomf_log_message("Form import failed: Data invalid: <pre>" . htmlentities(var_export($form_data, true)) . "</pre>", TDOMF_LOG_ERROR);
                $message = __("Form import failed", "tdomf");
            }
            $ok = false;
        }
    }
    return $message;
}
コード例 #14
0
function tdomf_handle_form_options_actions()
{
    global $wpdb, $wp_roles;
    $message = "";
    $retValue = false;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->role_objects;
    $caps = tdomf_get_all_caps();
    $remove_throttle_rule = false;
    $rule_id = 0;
    if (isset($_REQUEST['tdomf_form_id'])) {
        $form_id = intval($_REQUEST['tdomf_form_id']);
        $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
        if (is_array($rules)) {
            foreach ($rules as $id => $r) {
                if (isset($_REQUEST["tdomf_remove_throttle_rule_{$id}"])) {
                    $remove_throttle_rule = true;
                    $rule_id = $id;
                    break;
                }
            }
        }
    }
    if ($remove_throttle_rule) {
        check_admin_referer('tdomf-options-save');
        unset($rules[$rule_id]);
        tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES, $rules, $form_id);
        $message .= "Throttle rule removed!<br/>";
        tdomf_log_message("Removed throttle rule");
    } else {
        if (isset($_REQUEST['tdomf_add_throttle_rule'])) {
            check_admin_referer('tdomf-options-save');
            $form_id = intval($_REQUEST['tdomf_form_id']);
            $rule = array();
            $rule['sub_type'] = $_REQUEST['tdomf_throttle_rule_sub_type'];
            $rule['count'] = $_REQUEST['tdomf_throttle_rule_count'];
            $rule['type'] = $_REQUEST['tdomf_throttle_rule_user_type'];
            $rule['opt1'] = isset($_REQUEST['tdomf_throttle_rule_opt1']);
            $rule['time'] = intval($_REQUEST['tdomf_throttle_rule_time']);
            $rules = tdomf_get_option_form(TDOMF_OPTION_THROTTLE_RULES, $form_id);
            if (!is_array($rules)) {
                $rules = array();
            }
            $rules[] = $rule;
            tdomf_set_option_form(TDOMF_OPTION_THROTTLE_RULES, $rules, $form_id);
            $message .= "Throttle rule added!<br/>";
            tdomf_log_message("Added a new throttle rule: " . var_export($rule, true));
        } else {
            if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'create_form_page') {
                check_admin_referer('tdomf-create-form-page');
                $form_id = intval($_REQUEST['form']);
                $page_id = tdomf_create_form_page($form_id);
                $message = sprintf(__("A page with the form has been created. <a href='%s'>View page &raquo;</a><br/>", "tdomf"), get_permalink($page_id));
            } else {
                if (isset($_REQUEST['save_settings']) && isset($_REQUEST['tdomf_form_id'])) {
                    check_admin_referer('tdomf-options-save');
                    $form_id = intval($_REQUEST['tdomf_form_id']);
                    // Edit or Submit
                    $edit_form = false;
                    if (isset($_REQUEST['tdomf_mode']) && $_REQUEST['tdomf_mode'] == "edit") {
                        $edit_form = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_FORM_EDIT, $edit_form, $form_id);
                    // Allow pages with forms to be editted
                    $edit_page_form = isset($_REQUEST['tdomf_edit_page_form']);
                    tdomf_set_option_form(TDOMF_OPTION_EDIT_PAGE_FORM, $edit_page_form, $form_id);
                    // Allow authors to edit
                    $author_edit = false;
                    if (isset($_REQUEST['tdomf_author_edit'])) {
                        $author_edit = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ALLOW_AUTHOR, $author_edit, $form_id);
                    // Edit post within X seconds of being published
                    $time_edit = false;
                    if (isset($_REQUEST['tdomf_time_edit'])) {
                        $time_edit = intval($_REQUEST['tdomf_time_edit']);
                        if ($time_edit <= 0) {
                            $time_edit = false;
                        }
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ALLOW_TIME, $time_edit, $form_id);
                    // Who can access the form?
                    if (isset($_REQUEST['tdomf_special_access_anyone']) && tdomf_get_option_form(TDOMF_OPTION_ALLOW_EVERYONE, $form_id) == false) {
                        tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE, true, $form_id);
                        foreach ($roles as $role) {
                            // remove cap as it's not needed
                            if (isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                                $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id);
                            }
                        }
                        tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS, array(), $form_id);
                    } else {
                        if (!isset($_REQUEST['tdomf_special_access_anyone'])) {
                            tdomf_set_option_form(TDOMF_OPTION_ALLOW_EVERYONE, false, $form_id);
                            // add cap to right roles
                            foreach ($roles as $role) {
                                if (isset($_REQUEST["tdomf_access_" . $role->name])) {
                                    $role->add_cap(TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id);
                                } else {
                                    if (isset($role->capabilities[TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id])) {
                                        $role->remove_cap(TDOMF_CAPABILITY_CAN_SEE_FORM . '_' . $form_id);
                                    }
                                }
                            }
                            // list caps that can access form
                            $allow_caps = array();
                            foreach ($caps as $cap) {
                                if (isset($_REQUEST['tdomf_access_caps_' . $cap])) {
                                    $allow_caps[] = $cap;
                                }
                            }
                            tdomf_set_option_form(TDOMF_OPTION_ALLOW_CAPS, $allow_caps, $form_id);
                            // convert user names to ids
                            $allow_users = array();
                            if (isset($_REQUEST['tdomf_access_users_list'])) {
                                $user_names = trim($_REQUEST['tdomf_access_users_list']);
                                if (!empty($user_names)) {
                                    $user_names = explode(' ', $user_names);
                                    foreach ($user_names as $user_name) {
                                        if (!empty($user_name)) {
                                            if (($userdata = get_userdatabylogin($user_name)) != false) {
                                                $allow_users[] = $userdata->ID;
                                            } else {
                                                $message .= "<font color='red'>" . sprintf(__("{$user_name} is not a valid user name. Ignoring.<br/>", "tdomf"), $form_id) . "</font>";
                                                tdomf_log_message("User login {$user_name} is not recognised by wordpress. Ignoring.", TDOMF_LOG_BAD);
                                            }
                                        }
                                    }
                                }
                            }
                            tdomf_set_option_form(TDOMF_OPTION_ALLOW_USERS, $allow_users, $form_id);
                        }
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ALLOW_PUBLISH, isset($_REQUEST['tdomf_user_publish_override']), $form_id);
                    // Who gets notified?
                    $notify_roles = "";
                    foreach ($roles as $role) {
                        if (isset($_REQUEST["tdomf_notify_" . $role->name])) {
                            $notify_roles .= $role->name . ";";
                        }
                    }
                    if (!empty($notify_roles)) {
                        tdomf_set_option_form(TDOMF_NOTIFY_ROLES, $notify_roles, $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_NOTIFY_ROLES, false, $form_id);
                    }
                    $save = true;
                    $tdomf_admin_emails = $_POST['tdomf_admin_emails'];
                    $emails = explode(',', $tdomf_admin_emails);
                    foreach ($emails as $email) {
                        if (!empty($email)) {
                            if (!tdomf_check_email_address($email)) {
                                $message .= "<font color='red'>" . sprintf(__("The email %s is not valid! Please update 'Who Gets Notified' with valid email addresses.", "tdomf"), $email) . "</font><br/>";
                                $save = false;
                                break;
                            }
                        }
                    }
                    if ($save) {
                        tdomf_set_option_form(TDOMF_OPTION_ADMIN_EMAILS, $tdomf_admin_emails, $form_id);
                    }
                    // Default Category
                    $def_cat = $_POST['tdomf_def_cat'];
                    tdomf_set_option_form(TDOMF_DEFAULT_CATEGORY, $def_cat, $form_id);
                    // Restrict editing to posts submitted by tdomf
                    $edit_restrict_tdomf = isset($_REQUEST['tdomf_edit_tdomf_only']);
                    tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_TDOMF, $edit_restrict_tdomf, $form_id);
                    $edit_restrict_cats = explode(',', trim($_REQUEST['tdomf_edit_cats']));
                    if (!empty($edit_restrict_cats)) {
                        $cats = array();
                        foreach ($edit_restrict_cats as $cat) {
                            $cat = intval(trim($cat));
                            if ($cat > 0) {
                                $cats[] = $cat;
                            }
                        }
                        $edit_restrict_cats = $cats;
                    } else {
                        $edit_restrict_cats = array();
                    }
                    tdomf_set_option_form(TDOMF_OPTION_EDIT_RESTRICT_CATS, $edit_restrict_cats, $form_id);
                    // add edit link
                    $add_edit_link = $_REQUEST['tdomf_add_edit_link'];
                    if ($add_edit_link == 'custom') {
                        $add_edit_link = $_REQUEST['tdomf_add_edit_link_custom_url'];
                    }
                    tdomf_set_option_form(TDOMF_OPTION_ADD_EDIT_LINK, $add_edit_link, $form_id);
                    $ajax_edit = isset($_REQUEST['tdomf_ajax_edit']);
                    tdomf_set_option_form(TDOMF_OPTION_AJAX_EDIT, $ajax_edit, $form_id);
                    // auto modify edit link
                    $auto_edit_link = $_REQUEST['tdomf_auto_edit_link'];
                    if ($auto_edit_link == 'custom') {
                        $auto_edit_link = $_REQUEST['tdomf_auto_edit_link_custom_url'];
                    }
                    tdomf_set_option_form(TDOMF_OPTION_AUTO_EDIT_LINK, $auto_edit_link, $form_id);
                    //Turn On/Off Moderation
                    $mod = false;
                    if (isset($_POST['tdomf_moderation'])) {
                        $mod = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_MODERATION, $mod, $form_id);
                    $tdomf_redirect = isset($_POST['tdomf_redirect']);
                    tdomf_set_option_form(TDOMF_OPTION_REDIRECT, $tdomf_redirect, $form_id);
                    //Preview
                    $preview = false;
                    if (isset($_POST['tdomf_preview'])) {
                        $preview = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_PREVIEW, $preview, $form_id);
                    //From email
                    if (trim($_POST['tdomf_from_email']) == "") {
                        tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL, false, $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_OPTION_FROM_EMAIL, $_POST['tdomf_from_email'], $form_id);
                    }
                    // Form name
                    if (trim($_POST['tdomf_form_name']) == "") {
                        tdomf_set_option_form(TDOMF_OPTION_NAME, "", $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_OPTION_NAME, strip_tags($_POST['tdomf_form_name']), $form_id);
                    }
                    // Form description
                    if (trim($_POST['tdomf_form_descp']) == "") {
                        tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION, false, $form_id);
                    } else {
                        tdomf_set_option_form(TDOMF_OPTION_DESCRIPTION, $_POST['tdomf_form_descp'], $form_id);
                    }
                    // Include on "your submissions" page
                    //
                    $include = false;
                    if (isset($_POST['tdomf_include_sub'])) {
                        $include = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS, $include, $form_id);
                    if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS) && $include) {
                        $message .= sprintf(__("Saved Options for Form %d. <a href='%s'>See your form &raquo</a>", "tdomf"), $form_id, "users.php?page=tdomf_your_submissions#tdomf_form%d") . "<br/>";
                    } else {
                        $message .= sprintf(__("Saved Options for Form %d.", "tdomf"), $form_id) . "<br/>";
                    }
                    // widget count
                    //
                    $widget_count = 10;
                    if (isset($_POST['tdomf_widget_count'])) {
                        $widget_count = intval($_POST['tdomf_widget_count']);
                    }
                    if ($widget_count < 1) {
                        $widget_count = 1;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_WIDGET_INSTANCES, $widget_count, $form_id);
                    //Submit page instead of post
                    //
                    $use_page = false;
                    if (isset($_POST['tdomf_use_type']) && $_POST['tdomf_use_type'] == 'page') {
                        $use_page = true;
                    }
                    tdomf_set_option_form(TDOMF_OPTION_SUBMIT_PAGE, $use_page, $form_id);
                    // Queue period
                    //
                    $tdomf_queue_period = intval($_POST['tdomf_queue_period']);
                    tdomf_set_option_form(TDOMF_OPTION_QUEUE_PERIOD, $tdomf_queue_period, $form_id);
                    // Queue on all
                    //
                    $tdomf_queue_on_all = isset($_POST['tdomf_queue_on_all']);
                    tdomf_set_option_form(TDOMF_OPTION_QUEUE_ON_ALL, $tdomf_queue_on_all, $form_id);
                    // ajax
                    //
                    $tdomf_ajax = isset($_POST['tdomf_ajax']);
                    tdomf_set_option_form(TDOMF_OPTION_AJAX, $tdomf_ajax, $form_id);
                    // Send moderation email even for published posts
                    //
                    $tdomf_mod_email_on_pub = isset($_POST['tdomf_mod_email_on_pub']);
                    tdomf_set_option_form(TDOMF_OPTION_MOD_EMAIL_ON_PUB, $tdomf_mod_email_on_pub, $form_id);
                    // Admin users auto-publish?
                    //
                    $tdomf_publish_no_mod = isset($_POST['tdomf_user_publish_auto']);
                    tdomf_set_option_form(TDOMF_OPTION_PUBLISH_NO_MOD, $tdomf_publish_no_mod, $form_id);
                    // Spam
                    //
                    $message .= tdomf_handle_spam_options_actions($form_id);
                    tdomf_log_message("Options Saved for Form ID {$form_id}");
                } else {
                    if (isset($_REQUEST['delete'])) {
                        $form_id = intval($_REQUEST['delete']);
                        check_admin_referer('tdomf-delete-form-' . $form_id);
                        if (tdomf_form_exists($form_id)) {
                            $count_forms = count(tdomf_get_form_ids());
                            if ($count_forms > 1) {
                                if (tdomf_delete_form($form_id)) {
                                    $message .= sprintf(__("Form %d deleted.<br/>", "tdomf"), $form_id);
                                } else {
                                    $message .= sprintf(__("Could not delete Form %d!<br/>", "tdomf"), $form_id);
                                }
                            } else {
                                $message .= sprintf(__("You cannot delete the last form! There must be at least one form in the system.<br/>", "tdomf"), $form_id);
                            }
                        } else {
                            $message .= sprintf(__("Form %d is not valid!<br/>", "tdomf"), $form_id);
                        }
                    } else {
                        if (isset($_REQUEST['copy'])) {
                            $form_id = intval($_REQUEST['copy']);
                            check_admin_referer('tdomf-copy-form-' . $form_id);
                            $copy_form_id = tdomf_copy_form($form_id);
                            if ($copy_form_id != 0) {
                                $message .= sprintf(__("Form %d copied with id %d.<br/>", "tdomf"), $form_id, $copy_form_id);
                                $retValue = $copy_form_id;
                            } else {
                                $message .= sprintf(__("Failed to copy Form %d!<br/>", "tdomf"), $form_id);
                            }
                        } else {
                            if (isset($_REQUEST['new'])) {
                                check_admin_referer('tdomf-new-form');
                                $form_id = tdomf_create_form(__('New Form', 'tdomf'), array());
                                if ($form_id != 0) {
                                    $message .= sprintf(__("New form created with %d.<br/>", "tdomf"), $form_id);
                                    $retValue = $form_id;
                                } else {
                                    $message .= __("Failed to create new Form!<br/>", "tdomf");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Warnings
    $message .= tdomf_get_error_messages(false);
    if (!empty($message)) {
        ?>
   <div id="message" class="updated fade"><p><?php 
        echo $message;
        ?>
</p></div>
   <?php 
    }
    return $retValue;
}