function tdomf_editpostlink_filter($url, $post_id)
{
    $form_ids = tdomf_get_form_ids();
    foreach ($form_ids as $form_id) {
        if (tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id->form_id) && tdomf_check_permissions_form($form_id->form_id, $post_ID) == NULL) {
            $edit_link_style = tdomf_get_option_form(TDOMF_OPTION_AUTO_EDIT_LINK, $form_id->form_id);
            if ($edit_link_style != 'none' && $edit_link_style != false) {
                if ($edit_link_style == 'page') {
                    $pages = tdomf_get_option_form(TDOMF_OPTION_CREATEDPAGES, $form_id->form_id);
                    $url = get_permalink($pages[0]);
                    if (strpos($url, '?') !== false) {
                        $url .= '&tdomf_post_id=' . $post_ID;
                    } else {
                        $url .= '?tdomf_post_id=' . $post_ID;
                    }
                } else {
                    if ($edit_link_style == 'your_submissions') {
                        $url = trailingslashit(get_bloginfo('wpurl')) . 'wp-admin/users.php?page=tdomf_your_submissions&tdomf_post_id=' . $post_ID . '#tdomf_form' . $form_id->form_id . '_' . $post_ID;
                    } else {
                        if ($edit_link_style != 'none') {
                            $url = $edit_link_style;
                            if (strpos($url, '?') !== false) {
                                $url .= '&tdomf_post_id=' . $post_ID;
                            } else {
                                $url = trailingslashit($url) . '?tdomf_post_id=' . $post_ID;
                            }
                        }
                    }
                }
                // once we find one, use it!
                break;
            }
        }
    }
    return $url;
}
Ejemplo n.º 2
0
            $array = stripslashes($array);
            return str_replace("\\'", "'", $array);
        }
    }
    #}
    return $array;
}
function tdomf_fixslashesargs()
{
    $_COOKIE = stripslashes_deep($_COOKIE);
    $_POST = tdomf_stripslashes_deep($_POST);
    $_REQUEST = tdomf_stripslashes_deep($_REQUEST);
}
// Double check user permissions
//
$message = tdomf_check_permissions_form($form_id, $post_id);
// Remove magic quote slashes and additionally ones Wordpress "cleverly" adds
tdomf_fixslashesargs();
// Now either generate a preview or create a post
//
$save_post_info = FALSE;
$hide_form = true;
$publish = false;
if ($message == NULL) {
    if ($is_edit) {
        $form_tag = $form_id . '_' . $post_id;
    } else {
        $form_tag = $form_id;
    }
    if (isset($_POST['tdomf_form' . $form_tag . '_send'])) {
        tdomf_log_message("Someone is attempting to submit something");
function tdomf_show_your_submissions_menu()
{
    global $current_user;
    // how many of the recently published/approved entries to see
    //
    $limit = 10;
    get_currentuserinfo();
    $tdomf_flag = get_usermeta($current_user->ID, TDOMF_KEY_FLAG);
    $sub_total = tdomf_get_users_submitted_posts_count($current_user->ID);
    $app_total = tdomf_get_users_published_posts_count($current_user->ID);
    $user_status = get_usermeta($current_user->ID, TDOMF_KEY_STATUS);
    $app_posts = tdomf_get_user_published_posts($current_user->ID, 0, $limit);
    $mod_posts = tdomf_get_user_draft_posts($current_user->ID);
    $mod_total = count($mod_posts);
    $fut_posts = tdomf_get_user_scheduled_posts($current_user->ID);
    $fut_total = count($fut_posts);
    $unapp_edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'user_id' => $current_user->ID));
    $app_edits = tdomf_get_edits(array('state' => 'approved', 'unique_post_ids' => true, 'user_id' => $current_user->ID, 'limit' => $limit));
    ?>

  <div class="wrap">
    <h2><?php 
    _e('Your Submissions', 'tdomf');
    ?>
</h2>
    
    <?php 
    if (in_array($_REQUEST['REMOTE_ADDR'], tdomf_get_ips_banned())) {
        ?>
      <?php 
        printf(__("You are logged on from the banned IP %s. If this is in error please contact the <a href='mailto:%s'>admins</a>.", "tdomf"), $_SERVER['REMOTE_ADDR'], get_bloginfo('admin_email'));
        ?>
    <?php 
    } else {
        if ($user_status == TDOMF_USER_STATUS_BANNED) {
            ?>
      <?php 
            printf(__("You are banned from using this functionality on this site. If this is in error please contact the <a href='mailto:%s'>admins</a>.", "tdomf"), get_bloginfo('admin_email'));
            ?>
    <?php 
        } else {
            ?>

      <p>
      <?php 
            if ($user_status == TDOMF_USER_STATUS_TRUSTED) {
                ?>
        <?php 
                printf(__("Good to see you again <b>%s</b>! ", "tdomf"), $current_user->display_name);
                ?>
      <?php 
            } else {
                if ($tdomf_flag) {
                    ?>
        <?php 
                    printf(__("Welcome back <b>%s</b>!", "tdomf"), $current_user->display_name);
                    ?>
      <?php 
                } else {
                    ?>
        <?php 
                    printf(__("Welcome <b>%s</b>.", "tdomf"), $current_user->display_name);
                    ?>
      <?php 
                }
            }
            ?>
      </p>
      
      <p><?php 
            printf(__("From here you can submit posts to the %s using the form below and check on the status of your submissions.", "tdomf"), get_bloginfo());
            ?>
</p>
      
      <?php 
            if (current_user_can('edit_others_posts') || current_user_can('manage_options')) {
                ?>
      <ul>
      <?php 
                if (current_user_can('manage_options')) {
                    ?>
      <li><a href="admin.php?page=tdomf_show_options_menu"><?php 
                    _e("Configure Options", "tdomf");
                    ?>
</a></li>
      <li><a href="admin.php?page=tdomf_show_form_menu"><?php 
                    _e("Modify Form", "tdomf");
                    ?>
</a></li>
      <?php 
                }
                ?>
      <li><a href="admin.php?page=tdomf_show_mod_posts_menu"><?php 
                _e("Moderate Submissions", "tdomf");
                ?>
</a></li>
      </ul>
      <?php 
            }
            ?>

    <?php 
            if ($tdomf_flag && ($sub_total > 0 || $app_total > 0)) {
                ?>
        
        <?php 
                if ($fut_total > 0) {
                    ?>
            <h3><?php 
                    printf(__('Your Next %d Scheduled Submissions', 'tdomf'), $fut_total);
                    ?>
</h3>
            <ul>
         <?php 
                    foreach ($fut_posts as $p) {
                        ?>
          <li>
          <?php 
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $p->post_date;
                        $time = tdomf_get_post_time('G', true, $p);
                        if (abs(time() - $time) < 86400) {
                            $h_time = sprintf(__('%s from now'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                        ?>
                <?php 
                        printf(__("<a href='%s'>%s</a> will be published %s", "tdomf"), get_permalink($p->ID), $p->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                        ?>
          </li>
         <?php 
                    }
                    ?>
    	  </ul>
        <?php 
                }
                ?>
        
       <?php 
                if ($app_total > 0) {
                    ?>
         <h3><?php 
                    printf(__('Your Last %d Published Submissions', 'tdomf'), $app_total < 5 ? $app_total : 5);
                    ?>
</h3>
         <ul>
         <?php 
                    foreach ($app_posts as $p) {
                        ?>
          <li>
          <?php 
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $p->post_date;
                        $time = tdomf_get_post_time('G', true, $p);
                        if (abs(time() - $time) < 86400) {
                            $h_time = sprintf(__('%s ago'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                        ?>
                <?php 
                        printf(__("<a href='%s'>%s</a> approved %s", "tdomf"), get_permalink($p->ID), $p->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                        ?>
          </li>
         <?php 
                    }
                    ?>
    	  </ul>
       <?php 
                }
                ?>
       
       <?php 
                if ($mod_total > 0) {
                    ?>
         <h3><?php 
                    _e('Your Sumissions awaiting Moderation', 'tdomf');
                    ?>
</h3>
         <ul>
         <?php 
                    foreach ($mod_posts as $p) {
                        ?>
          <li>"<?php 
                        echo $p->post_title;
                        ?>
"</li>
         <?php 
                    }
                    ?>
    	  </ul>
       <?php 
                }
                ?>
    <?php 
            }
            ?>
      
      
    <?php 
            if (!empty($app_edits)) {
                $num = number_format_i18n(count($app_edits));
                $text = __ngettext('Your Last Approved Contribution', 'Your Last %d Approved Contributions', count($app_edits));
                ?>
        <h3><?php 
                printf($text, count($app_edits));
                ?>
</h3>
        <ul>
        <?php 
                foreach ($app_edits as $app_edit) {
                    ?>
            <li>
            <?php 
                    $edit = tdomf_get_edits(array('state' => 'approved', 'post_id' => $app_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
                    $edit = $edit[0];
                    $t_time = get_the_time(__('Y/m/d g:i:s A'));
                    $h_time = mysql2date(__('Y/m/d'), $edit->date);
                    $post = get_post($app_edit->post_id);
                    printf(__("<a href='%s'>%s</a> edited %s", "tdomf"), get_permalink($app_edit->post_id), $post->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                    ?>
            </li>
        <?php 
                }
                ?>
        </ul>
    <?php 
            }
            ?>
    
    <?php 
            if (!empty($unapp_edits)) {
                $num = number_format_i18n(count($unapp_edits));
                $text = __ngettext('Your Contribution awaiting Moderation', 'Your Contributions awaiting Moderation', count($unapp_edits));
                ?>
        <h3><?php 
                printf($text, count($unapp_edits));
                ?>
</h3>
        <ul>
        <?php 
                foreach ($unapp_edits as $unapp_edit) {
                    ?>
            <li>
            <?php 
                    $edit = tdomf_get_edits(array('state' => 'unapproved', 'post_id' => $unapp_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
                    $edit = $edit[0];
                    $t_time = get_the_time(__('Y/m/d g:i:s A'));
                    $h_time = mysql2date(__('Y/m/d'), $edit->date);
                    $post = get_post($unapp_edit->post_id);
                    printf(__("<a href='%s'>%s</a> edited %s", "tdomf"), get_permalink($unapp_edit->post_id), $post->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                    ?>
            </li>
        <?php 
                }
                ?>
        </ul>
    <?php 
            }
            ?>
    
     </div>
      
     <!-- Form formatting -->     
     <style>
     .tdomf_form {
     }
     .tdomf_form fieldset legend {
       #border-bottom: 1px dotted black;
       font-weight: bold;
       padding: 0px;
       margin: 0px;
       padding-bottom: 10px;
     }
     .tdomf_form_preview {
       border: 1px dotted black;
       padding: 5px;
       margin: 5px;
       margin-bottom: 20px;
     }
     .tdomf_form_preview p {
       margin-left: 15px;
     }
     .tdomf_form .required {
       color: red;
     }
     .tdomf_form fieldset {
       margin-bottom: 10px;
       border: 0;
     }
     </style>
      
    <?php 
            $form_ids = tdomf_get_form_ids();
            if (!empty($form_ids)) {
                foreach ($form_ids as $form_id) {
                    if (tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS, $form_id->form_id)) {
                        $edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id->form_id);
                        $post_id = false;
                        if (isset($_REQUEST['tdomf_post_id'])) {
                            $post_id = intval($_REQUEST['tdomf_post_id']);
                        }
                        $good = true;
                        if ($edit && tdomf_check_permissions_form($form_id->form_id, $post_id) != NULL) {
                            $good = false;
                        }
                        if ($good) {
                            ?>
     <div class="wrap">
        <h2><?php 
                            echo tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id->form_id);
                            ?>
</h2>
        <p><?php 
                            echo tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION, $form_id->form_id);
                            ?>
</p>
        <?php 
                            echo tdomf_generate_form($form_id->form_id);
                            ?>
        <br/><br/>
     </div>
          <?php 
                        }
                    }
                }
            }
            ?>
    <?php 
        }
    }
    ?>
    
  </div>

  <p><center><?php 
    _e('Powered by the <a href="http://thedeadone.net/software/tdo-mini-forms-wordpress-plugin/">TDO Mini Forms Plugin.', 'tdomf');
    ?>
</a></center></p>
  
<?php 
}