Exemple #1
0
 /**
  * We have collected all the info we need to create our mini-audit
  * custom post.
  */
 function create_post($record)
 {
     $this->record = $record;
     $content = $this->get_post_content();
     if ($content === null) {
         $this->failure = "FAIL: Could create content type";
         return null;
     }
     $path = pathinfo($record['report']);
     $title = $path['filename'];
     if ($title === null || $title === '') {
         $this->failure = "FAIL: to find the report " . $record['domain'];
         return null;
     }
     $post = array('comment_status' => 'open', 'post_name' => $record['domain'], 'post_status' => 'pending', 'post_title' => $title, 'post_type' => 'miniaudit', 'post_content' => $content);
     $id = wp_insert_post($post, true);
     if (is_object($id)) {
         $this->failure = print_r($id, true);
         return null;
     }
     LPOP_Logger::logit("Created Audit {$id}: {$title}");
     $this->post_id = $id;
     /*
      * Now add the post meta data data
      */
     foreach ($record as $k => $v) {
         add_post_meta($id, $k, $v);
     }
     return $id;
 }
Exemple #2
0
function lpop_gform_get_entry($attrs)
{
    /* Parse the id */
    $entry = RGFormsModel::get_lead(1);
    $form = GFFormsModel::get_form_meta($entry['form_id']);
    LPOP_Logger::logit("Loading Mini Audits: Form =  " . $form['title'] . ", Entry = " . $entry['id']);
    LPOP_Mini_Audits::process_mini_audit_entry($entry);
    LPOP_Logger::flush();
}
Exemple #3
0
 public static function flush()
 {
     if (count(self::$logs) < 0) {
         return;
     }
     $comment = '';
     foreach (self::$logs as $line) {
         $comment .= $line . '<br/>';
     }
     self::$meta['comment_content'] = $comment;
     self::$meta['approved'] = true;
     $user = wp_get_current_user();
     self::$meta['comment_author'] = $user->user_login;
     self::$meta['comment_author_email'] = $user->user_email;
     self::$meta['comment_author_email'] = $user->user_email;
     self::$meta['comment_author_email'] = $user->ID;
     /*
      * now write the content to the page.
      */
     wp_insert_comment(self::$meta);
     // Resent the logs.
     self::$logs = array();
 }
Exemple #4
0
 static function process_audit_dirs()
 {
     /**
      * Scan the directories and determine the .csv files vs. the html
      * files.  Also the raw vs. the non-raw html files need to be matched
      * up with the records in the .csv files.
      */
     if (!is_array(self::$dirs)) {
         die("process dirs self::{$dirs} is not an array ");
     }
     while (count(self::$dirs) > 0) {
         $dir = array_shift(self::$dirs);
         self::process_dir($dir);
     }
     /*
      * Process the .csv files.
      */
     foreach (self::$csvfiles as $csv) {
         // Will append to $all_recordsn
         $records = self::process_csv($csv);
     }
     LPOP_Logger::logit("Total records processed: " . count(self::$all_records));
 }