function __construct($module) { $this->module = $module; if (defined('NEWSLETTER_LOG_LEVEL')) { $this->level = NEWSLETTER_LOG_LEVEL; } else { $this->level = get_option('newsletter_log_level', self::ERROR); } $secret = get_option('newsletter_logger_secret'); if (strlen($secret) < 8) { $secret = NewsletterModule::get_token(8); update_option('newsletter_logger_secret', $secret); } if (!wp_mkdir_p(NEWSLETTER_LOG_DIR)) { $this->level = self::NONE; } $this->file = NEWSLETTER_LOG_DIR . '/' . $module . '-' . $secret . '.txt'; }
/** * NEVER CHANGE THIS METHOD SIGNATURE, USER BY THIRD PARTY PLUGINS. * * Saves a new user on the database. Return false if the email (that must be unique) is already * there. For a new users set the token and creation time if not passed. * * @param array|object $user */ function save_user($user, $return_format = OBJECT) { if (is_object($user)) { $user = (array) $user; } if (empty($user['id'])) { $existing = $this->get_user($user['email']); if ($existing != null) { return false; } if (empty($user['token'])) { $user['token'] = NewsletterModule::get_token(); } //if (empty($user['created'])) $user['created'] = time(); // Database default //if (empty($user['status'])) $user['status'] = 'S'; } // Due to the unique index on email field, this can fail. return $this->store->save(NEWSLETTER_USERS_TABLE, $user, $return_format); }