/**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return array
  */
 function getOptions($form_id, $postfix = '')
 {
     $defaults = array('question' => __("What year is it?", "tdomf"), 'answer' => __("2009", "tdomf"));
     $options = TDOMF_Widget::getOptions($form_id, $postfix);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return array
  */
 function getOptions($form_id, $postfix = '')
 {
     $defaults = array('message' => "");
     $options = TDOMF_Widget::getOptions($form_id, $postfix);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return array
  */
 function getOptions($form_id, $index = '')
 {
     $defaults = array('text' => "");
     $options = TDOMF_Widget::getOptions($form_id, $index);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return array
  */
 function getOptions($form_id)
 {
     $defaults = array('text' => __("I agree with the <a href='#'>posting policy</a>.", "tdomf"), 'error-text' => __("You must agree with <a href='#'>posting policy</a> policy before submission!", "tdomf"));
     $options = TDOMF_Widget::getOptions($form_id);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return String
  */
 function getOptions($form_id)
 {
     $defaults = array('excerpt-title' => __('Excerpt Text', 'tdomf'), 'excerpt-use-filter' => 'preview', 'excerpt-filter' => 'the_excerpt', 'excerpt-kses' => false, 'excerpt-default_text' => "");
     $options = TDOMF_Widget::getOptions($form_id);
     $options = wp_parse_args($options, $defaults);
     # convert previous textarea options to new utility textarea options
     if (isset($options['text-required'])) {
         $options['excerpt-required'] = $options['text-required'];
         unset($options['text-required']);
     }
     if (isset($options['text-cols'])) {
         $options['excerpt-cols'] = $options['text-cols'];
         unset($options['text-cols']);
     }
     if (isset($options['text-rows'])) {
         $options['excerpt-rows'] = $options['text-rows'];
         unset($options['text-rows']);
     }
     if (isset($options['quicktags'])) {
         $options['excerpt-quicktags'] = $options['quicktags'];
         unset($options['quicktags']);
     }
     if (isset($options['restrict-tags'])) {
         $options['excerpt-restrict-tags'] = $options['restrict-tags'];
         unset($options['restrict-tags']);
     }
     if (isset($options['allowable-tags'])) {
         $options['excerpt-allowable-tags'] = $options['allowable-tags'];
         unset($options['allowable-tags']);
     }
     if (isset($options['char-limit'])) {
         $options['excerpt-char-limit'] = $options['char-limit'];
         unset($options['char-limit']);
     }
     if (isset($options['word-limit'])) {
         $options['excerpt-word-limit'] = $options['word-limit'];
         unset($options['word-limit']);
     }
     # now grab defaults for textarea
     $options = $this->textarea->getOptions($options);
     return $options;
 }
Esempio n. 6
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 
}
 /** 
  * Override the default Wordpress update_post_meta so we can add
  * custom field data to revisions
  *
  * @see update_post_meta()
  * @access private
  */
 function updatePostMeta($post_id, $meta_key, $meta_value, $prev_value = '')
 {
     global $wpdb;
     // Make sure we *can* add post meta to a revision
     /*// make sure meta is added to the post, not a revision
       if ( $the_post = wp_is_post_revision($post_id) )
       $post_id = $the_post;*/
     // expected_slashed ($meta_key)
     $meta_key = stripslashes($meta_key);
     if (!$meta_key) {
         return false;
     }
     if (!$wpdb->get_var($wpdb->prepare("SELECT meta_key FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id = %d", $meta_key, $post_id))) {
         return TDOMF_Widget::addPostMeta($post_id, $meta_key, $meta_value);
     }
     $meta_value = maybe_serialize(stripslashes_deep($meta_value));
     $data = compact('meta_value');
     $where = compact('meta_key', 'post_id');
     if (!empty($prev_value)) {
         $prev_value = maybe_serialize($prev_value);
         $where['meta_value'] = $prev_value;
     }
     $wpdb->update($wpdb->postmeta, $data, $where);
     wp_cache_delete($post_id, 'post_meta');
     return true;
 }
 function getOptions($form_id, $postfix = '')
 {
     $defaults = array('path' => ABSPATH . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'tdomf', 'types' => ".jpg .gif", 'size' => 2097152, 'min' => 0, 'max' => 1, 'cmd' => '', 'attach' => true, 'a' => true, 'img' => false, 'custom' => true, 'custom-key' => __("Download Link", "tdomf"), 'post-title' => false, 'attach-a' => false, 'post-thumb-a' => false, 'thumb-a' => false, 'url' => trailingslashit(get_bloginfo('wpurl')) . 'wp-content/uploads/tdomf/', 'nohandler' => true);
     $options = TDOMF_Widget::getOptions($form_id, $postfix);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }
 /**
  * Validate widget input
  * 
  * @access public
  * @return Mixed
  */
 function validate($args, $options, $preview)
 {
     if ($preview) {
         return NULL;
     }
     extract($args);
     $form_data = tdomf_get_form_data($tdomf_form_id);
     $form_tag = $tdomf_form_id;
     if (TDOMF_Widget::isEditForm($mode, $tdomf_form_id)) {
         $form_tag = $tdomf_form_id . '_' . $tdomf_post_id;
     }
     // all freeCap words are lowercase.
     // font #4 looks uppercase, but trust me, it's not...
     if ($form_data['hash_func_' . $form_tag](strtolower($args["imagecaptcha_" . $form_tag])) == $form_data['freecap_word_hash_' . $form_tag]) {
         // reset freeCap session vars
         // cannot stress enough how important it is to do this
         // defeats re-use of known image with spoofed session id
         $form_data['freecap_attempts_' . $form_tag] = 0;
         $form_data['freecap_word_hash_' . $form_tag] = false;
         tdomf_save_form_data($tdomf_form_id, $form_data);
     } else {
         return __("You must enter the word in the image as you see it.", "tdomf");
     }
     return NULL;
 }
 /**
  * Validate widget input
  * 
  * @access public
  * @return Mixed
  */
 function validate($args, $options, $preview)
 {
     if (!$options['title-enable'] && !$options['text-enable']) {
         return "";
     }
     extract($args);
     $output = "";
     if (TDOMF_Widget::isEditForm($mode, $tdomf_form_id)) {
         // when it goes to validation, the tdomf_post_id will be the
         // real post id
         $post =& get_post($tdomf_post_id);
         // set default texts to the original post contents
         $options['content-text-default-text'] = $post->post_content;
         $options['content-title-default-text'] = $post->post_title;
     }
     if ($options['title-enable']) {
         $tf_output = $this->textfield->validate($args, $options, $preview, 'content_title');
         if (!empty($tf_output)) {
             if ($output != "") {
                 $output .= "<br/>";
             }
             $output .= $tf_output;
         }
     }
     if ($options['text-enable']) {
         $ta_output = $this->textarea->validate($args, $options, $preview, 'content_content');
         if (!empty($ta_output)) {
             if ($output != "") {
                 $output .= "<br/>";
             }
             $output .= $ta_output;
         }
     }
     // return output if any
     if ($output != "") {
         return $output;
     } else {
         return NULL;
     }
 }
 /**
  * Process form input for widget
  * 
  * @access public
  * @return Mixed
  */
 function post($args, $options)
 {
     global $current_user;
     get_currentuserinfo();
     extract($args);
     // if sumbitting a new post (as opposed to editing)
     // make sure to *append* to post_content. For editing, overwrite.
     //
     if (TDOMF_Widget::isEditForm($mode)) {
         $edit_data = tdomf_get_data_edit($edit_id);
         if (isset($whoami_name)) {
             $edit_data[TDOMF_KEY_NAME] = tdomf_protect_input($whoami_name);
         } else {
             $whoami_name = "";
         }
         if (isset($whoami_webpage)) {
             $edit_data[TDOMF_KEY_WEB] = $whoami_webpage;
         } else {
             $whoami_webpage = "";
         }
         if (isset($whoami_email)) {
             $edit_data[TDOMF_KEY_EMAIL] = $whoami_email;
         } else {
             $whoami_email = "";
         }
         if (is_user_logged_in()) {
             if ($current_user->ID != get_option(TDOMF_DEFAULT_AUTHOR)) {
                 $edit_data[TDOMF_KEY_USER_ID] = $current_user->ID;
                 $edit_data[TDOMF_KEY_USER_NAME] = $current_user->user_login;
                 $edit_data[TDOMF_KEY_NAME] = $current_user->display_name;
                 $edit_data[TDOMF_KEY_EMAIL] = $current_user->user_email;
                 $edit_data[TDOMF_KEY_WEB] = $current_user->user_url;
                 update_usermeta($current_user->ID, TDOMF_KEY_FLAG, true);
             }
         }
         tdomf_set_data_edit($edit_data, $edit_id);
     } else {
         if (isset($whoami_name)) {
             add_post_meta($post_ID, TDOMF_KEY_NAME, tdomf_protect_input($whoami_name), true);
         } else {
             $whoami_name = "";
         }
         if (isset($whoami_webpage)) {
             add_post_meta($post_ID, TDOMF_KEY_WEB, $whoami_webpage, true);
         } else {
             $whoami_webpage = "";
         }
         if (isset($whoami_email)) {
             add_post_meta($post_ID, TDOMF_KEY_EMAIL, $whoami_email, true);
         } else {
             $whoami_email = "";
         }
         if (is_user_logged_in()) {
             if ($current_user->ID != get_option(TDOMF_DEFAULT_AUTHOR)) {
                 add_post_meta($post_ID, TDOMF_KEY_USER_ID, $current_user->ID, true);
                 add_post_meta($post_ID, TDOMF_KEY_USER_NAME, $current_user->user_login, true);
                 add_post_meta($post_ID, TDOMF_KEY_NAME, $current_user->display_name, true);
                 add_post_meta($post_ID, TDOMF_KEY_EMAIL, $current_user->user_email, true);
                 add_post_meta($post_ID, TDOMF_KEY_WEB, $current_user->user_url, true);
                 update_usermeta($current_user->ID, TDOMF_KEY_FLAG, true);
             }
         }
     }
     TDOMF_WidgetWhoami::tdomf_widget_whoami_store_cookies(tdomf_protect_input($whoami_name), $whoami_email, $whoami_webpage);
     return NULL;
 }
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return String
  */
 function getOptions($form_id)
 {
     $defaults = array('required' => false, 'append' => true);
     $options = TDOMF_Widget::getOptions($form_id);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }
 function formHack($args, $options, $postfix = '')
 {
     $output = "";
     $field = $this->getField($options['type'], $this->index);
     if ($field != false) {
         extract($args);
         $options = $this->updateFieldOptions($options, $options['type'], $this->index);
         if (TDOMF_Widget::isEditForm($mode, $tdomf_form_id)) {
             #$fieldPrefix = $this->getFieldPrefix($options['type'],$this->index);
             $original_value = get_post_meta($args['post_ID'], $options['key'], true);
             $output .= "\t\t" . '<?php if(strpos($mode,\'-preview\') === false) {' . "\n";
             $output .= "\t\t\t" . '$post = get_post($post_id); if($post) {' . "\n";
             $output .= "\t\t\t\t" . 'if(!isset($post_args[\'' . $field->getId() . '\'])) {' . "\n";
             $output .= "\t\t\t\t\t" . '$post_args[\'' . $field->getId() . '\'] = get_post_meta($post_id,\'' . $options['key'] . '\',true); }' . "\n";
             $output .= "\t\t" . '} } ?>' . "\n\n";
         }
         $output .= $field->formHack($args, $options);
     } else {
         tdomf_log_message('TDOMF_WidgetCustomFields->formHack(): ERROR: Cant find field', TDOMF_LOG_ERROR);
     }
     return $output;
 }
Esempio n. 14
0
function tdomf_get_message_default($key, $mode)
{
    switch ($key) {
        case TDOMF_OPTION_MSG_SUB_PUBLISH:
            $retVal = __("Your submission \"%%SUBMISSIONTITLE%%\" has been automatically published. You can see it <a href='%%SUBMISSIONURL%%'>here</a>. Thank you for using this service.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_SUB_FUTURE:
            $retVal = __("Your submission has been accepted and will be published on %%SUBMISSIONDATE%% at %%SUBMISSIONTIME%%. Thank you for using this service.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_SUB_SPAM:
            $retVal = __("Your submission is being flagged as spam! Sorry", "tdomf");
            break;
        case TDOMF_OPTION_MSG_SUB_MOD:
            $retVal = __("Your post submission has been added to the moderation queue. It should appear in the next few days. Thank you for using this service.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_SUB_ERROR:
            $retVal = __("Your submission contained errors:<br/><br/>%%SUBMISSIONERRORS%%<br/><br/>Please correct and resubmit.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_PERM_BANNED_USER:
            $retVal = __("You (%%USERNAME%%) are banned from using this form.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_PERM_BANNED_IP:
            $retVal = __("Your IP %%IP%% does not currently have permissions to use this form.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_PERM_THROTTLE:
            $retVal = __("You have hit your submissions quota. Please wait until your existing submissions are approved.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_PERM_INVALID_USER:
            $retVal = __("You (%%USERNAME%%) do not currently have permissions to use this form.", "tdomf");
            break;
        case TDOMF_OPTION_MSG_PERM_INVALID_NOUSER:
            $retVal = __("Unregistered users do not currently have permissions to use this form.", "tdomf");
            break;
        case TDOMF_OPTION_ADD_EDIT_LINK_TEXT:
            $retVal = __("Edit", "tdomf");
            break;
        case TDOMF_OPTION_MSG_INVALID_POST:
            $retVal = __("That post you are attempting to edit is invalid", 'tdomf');
            break;
        case TDOMF_OPTION_MSG_INVALID_FORM:
            $retVal = __("You cannot use this form to edit this post", 'tdomf');
            break;
        case TDOMF_OPTION_MSG_SPAM_EDIT_ON_POST:
            $retVal = __("You cannot edit this post as there is a pending contribution to be resolved.", 'tdomf');
            break;
        case TDOMF_OPTION_MSG_UNAPPROVED_EDIT_ON_POST:
            $retVal = __("You cannot edit this post as there is a pending contribution to be approved.", 'tdomf');
            break;
        case TDOMF_OPTION_MSG_LOCKED_POST:
            $retVal = __("You cannot edit this post as it has been locked from editing.", 'tdomf');
            break;
        default:
            $retVal = "";
            break;
    }
    // Edit form changes some of the defaults
    if ($mode && TDOMF_Widget::isEditForm($mode)) {
        switch ($key) {
            case TDOMF_OPTION_MSG_SUB_PUBLISH:
                $retVal = __("Your contribution on post \"%%SUBMISSIONTITLE%%\" has been automatically approved. You can see it <a href='%%SUBMISSIONURL%%'>here</a>. Thank you for using this service.", "tdomf");
                break;
            case TDOMF_OPTION_MSG_SUB_FUTURE:
                $retVal = __("Your contribution has been approved and will be published on %%SUBMISSIONDATE%% at %%SUBMISSIONTIME%%. Thank you for using this service.", "tdomf");
                break;
            case TDOMF_OPTION_MSG_SUB_SPAM:
                $retVal = __("Your contribution has being flagged as spam! Sorry", "tdomf");
                break;
            case TDOMF_OPTION_MSG_SUB_MOD:
                $retVal = __("Your contribution has been added to the moderation queue. It should appear in the next few days. Thank you for using this service.", "tdomf");
                break;
            case TDOMF_OPTION_MSG_SUB_ERROR:
                $retVal = __("Your contribution contained errors:<br/><br/>%%SUBMISSIONERRORS%%<br/><br/>Please correct and resubmit.", "tdomf");
                break;
            case TDOMF_OPTION_MSG_PERM_THROTTLE:
                $retVal = __("You have hit your contributions quota. Please wait until your existing contributions are approved.", "tdomf");
                break;
        }
    }
    return $retVal;
}
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return String
  */
 function getOptions($form_id)
 {
     $defaults = array('required' => false, 'default' => 'http://', 'test' => false);
     $options = TDOMF_Widget::getOptions($form_id);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return String
  */
 function getOptions($form_id)
 {
     $defaults = array('publickey' => '', 'privatekey' => '', 'theme' => 'red', 'language' => 'en', 'xhtml' => false, 'plugin' => false, 'text-rows' => 10, 'quicktags' => false, 'restrict-tags' => true, 'allowable-tags' => "<p><b><em><u><strong><a><img><table><tr><td><blockquote><ul><ol><li><br><sup>", 'char-limit' => 0, 'word-limit' => 0);
     $recaptcha_options = get_option('recaptcha');
     if ($recaptcha_options != false) {
         $defaults['publickey'] = $recaptcha_options['pubkey'];
         $defaults['privatekey'] = $recaptcha_options['privkey'];
         $defaults['theme'] = $recaptcha_options['re_theme'];
         $defaults['language'] = $recaptcha_options['re_lang'];
         $defaults['xhtml'] = $recaptcha_options['re_xhtml'];
     }
     $options = TDOMF_Widget::getOptions($form_id);
     $options = wp_parse_args($options, $defaults);
     if ($options['plugin'] && $recaptcha_options != false) {
         $options['publickey'] = $recaptcha_options['pubkey'];
         $options['privatekey'] = $recaptcha_options['privkey'];
         $options['theme'] = $recaptcha_options['re_theme'];
         $options['language'] = $recaptcha_options['re_lang'];
         $options['xhtml'] = $recaptcha_options['re_xhtml'];
     }
     return $options;
 }
 /**
  * Overrides "getOptions" with defaults for this widget
  * 
  * @access public
  * @return String
  */
 function getOptions($form_id)
 {
     $defaults = array('subject' => sprintf(__("Your submission '%s' has been recieved!", "tdomf"), TDOMF_MACRO_SUBMISSIONTITLE), 'body' => sprintf(__("Hi %s,\n\nYour submission %s has been recieved and will be online shortly\nThank you for using this service\nBest Regards\n%s", "tdomf"), TDOMF_MACRO_USERNAME, TDOMF_MACRO_SUBMISSIONTITLE, "<?php echo get_bloginfo('title'); ?>"), 'link' => false);
     $options = TDOMF_Widget::getOptions($form_id);
     $options = wp_parse_args($options, $defaults);
     return $options;
 }