function falcon_load() { define('FALCON_PATH', __DIR__); define('FALCON_PLUGIN', plugin_basename(__FILE__)); spl_autoload_register('falcon_autoload'); Falcon::bootstrap(); }
/** * Add a notification hook. * * Basically `add_action` but specifically for actions to send * notifications on. Automatically registers cron tasks if running in * asynchronous mode. * * @param string $hook Name of the action to register for. * @param callback $callback Callback to register. * @param int $priority Priority to register at, larger numbers = later run. * @param int $accepted_args Number of arguments to pass through, default 0. */ protected function add_notify_action($hook, $callback, $priority = 10, $accepted_args = 0) { if (Falcon::should_send_async()) { add_action($hook, array($this, 'schedule_async_action'), $priority, $accepted_args); add_action('falcon_async-' . $hook, $callback, 10, $accepted_args); } else { add_action($hook, $callback, $priority, $accepted_args); } }
public static function parse_to($address) { $template = Falcon::get_option('bbsub_replyto'); // No plus address in saved, parse via splitting $has_match = preg_match('/\\+(\\w+)-(\\d+)-(\\d+)-(\\w+)\\@.*/i', $address, $matches); if (!$has_match) { throw new Exception(__('Reply-to not formatted correctly', 'bbsub')); } return array($matches[1], $matches[2], $matches[3], $matches[4]); }
public function send_mail($users, Falcon_Message $message) { $options = $message->get_options(); $from = Falcon::get_from_address(); $author = $message->get_author(); $messages = array(); foreach ($users as $user) { $data = array('from_email' => $from, 'to' => array(array('email' => $user->user_email, 'name' => $user->display_name)), 'subject' => $message->get_subject(), 'headers' => array('Reply-To' => $message->get_reply_address($user))); if ($author) { $data['from_name'] = $author; } if ($text = $message->get_text()) { $data['text'] = $text; } if ($html = $message->get_html()) { $data['html'] = $html; } // Set the message ID if we've got one if (!empty($options['message-id'])) { $data['headers']['Message-ID'] = $options['message-id']; } // If this is a reply, set the headers as needed if (!empty($options['in-reply-to'])) { $original = $options['in-reply-to']; if (is_array($original)) { $original = isset($options['in-reply-to'][$user->ID]) ? $options['in-reply-to'][$user->ID] : null; } if (!empty($original)) { $data['headers']['In-Reply-To'] = $original; } } if (!empty($options['references'])) { $references = implode(' ', $options['references']); $data['headers']['References'] = $references; } try { $messages[$user->ID] = $this->send_single($data); } catch (Exception $e) { $error = sprintf(__('Exception while sending: %s', 'falcon'), $e->getMessage()); trigger_error($error, E_USER_WARNING); } } return $messages; }
public function send_mail($users, Falcon_Message $message) { $options = $message->get_options(); $from = Falcon::get_from_address(); if ($author = $message->get_author()) { $from = sprintf('%s <%s>', $author, $from); } $messages = array(); foreach ($users as $user) { $data = array('From' => $from, 'ReplyTo' => $message->get_reply_address($user), 'To' => $user->user_email, 'Subject' => $message->get_subject(), 'Headers' => array()); if ($text = $message->get_text()) { $data['TextBody'] = $text; } if ($html = $message->get_html()) { $data['HtmlBody'] = $html; } // Set the message ID if we've got one if (!empty($options['message-id'])) { $data['Headers'][] = array('Name' => 'Message-ID', 'Value' => $options['message-id']); } // If this is a reply, set the headers as needed if (!empty($options['in-reply-to'])) { $original = $options['in-reply-to']; if (is_array($original)) { $original = isset($options['in-reply-to'][$user->ID]) ? $options['in-reply-to'][$user->ID] : null; } if (!empty($original)) { $data['Headers'][] = array('Name' => 'In-Reply-To', 'Value' => $original); } } if (!empty($options['references'])) { $references = implode(' ', $options['references']); $data['Headers'][] = array('Name' => 'References', 'Value' => $references); } $messages[$user->ID] = $this->send_single($data); } return $messages; }
/** * Print field for new topic notification * * @see self::init() */ public static function settings_field_topic_notification() { global $wp_roles; if (!$wp_roles) { $wp_roles = new WP_Roles(); } $options = Falcon::get_option('bbsub_topic_notification', array()); foreach ($wp_roles->get_names() as $key => $role_name) { $current = in_array($key, $options) ? $key : '0'; ?> <label> <input type="checkbox" value="<?php echo esc_attr($key); ?> " name="bbsub_topic_notification[]" <?php checked($current, $key); ?> /> <?php echo $role_name; ?> </label> <br /> <?php } echo '<span class="description">' . __('Sends new topic email and auto subscribe the users from these role to the new topic', 'bbsub') . '</span>'; }
/** * Get default notification settings * * @return array Map of type => pref value */ protected function get_default_settings() { $keys = array('post' => 'all', 'comment' => 'all'); $defaults = array(); foreach ($keys as $key => $hardcoded_default) { $option_key = $this->key_for_setting('notifications.' . $key); $value = Falcon::get_option($option_key, null); $defaults[$key] = isset($value) ? $value : $hardcoded_default; } return $defaults; }
<?php require_once "class/Falcon.class.php"; $uuid; $documentName; $document; foreach ($_POST as $key => $value) { if ($key == "datastore") { $uuid = $value; } elseif ($key == "documentName") { $documentName = $value; } else { $document[$key] = $value; } } if (!$uuid || !$documentName || !$document) { exit; } $falcon = new Falcon(); if ($falcon->connectDatastore($uuid)) { $result = $falcon->update($documentName, $falcon->buildJSONDocument($document)); } if ($result) { echo 1; } else { echo 0; }
/** * Should notifications be sent asynchronously? * * @return boolean */ public static function should_send_async() { return (bool) Falcon::get_option('bbsub_send_async', false); }
public static function settings_field_sites() { $sites = self::available_sites(); $current = Falcon::get_option('falcon_enabled_sites', array()); foreach ($sites as $site) { $details = get_blog_details($site['blog_id']); $value = absint($site['blog_id']); $enabled = in_array($value, $current); printf('<label><input type="checkbox" name="%s[]" value="%s" %s /> %s</label><br />', 'falcon_enabled_sites', esc_attr($value), checked($enabled, true, false), esc_html($details->blogname)); } echo '<p class="description">' . esc_html__('Select which sites to activate Falcon on.', 'falcon') . '</p>'; }
/** * Validate the handler-specific options via the handler's methods * * @see self::init() */ public static function validate_handler_options($input) { if (self::$wipe_handler_options) { return array(); } try { $handler = Falcon::get_handler_class(); } catch (Exception $e) { return array(); } return $handler::validate_options($input); }
<?php require_once "class/Falcon.class.php"; $falcon = new Falcon(); echo $falcon->createDatastore("owner", "description");
<?php require_once "class/Falcon.class.php"; header("Content-type: application/json"); $uuid = $_REQUEST["datastore"]; $data = $_REQUEST["data"]; $rpp = $_REQUEST["rpp"] ? $_REQUEST["rpp"] : 100; $page = $_REQUEST["page"] ? $_REQUEST["page"] : 1; $falcon = new Falcon(); if ($falcon->connectDatastore($uuid)) { echo $falcon->rpp($rpp)->page($page)->sort($falcon->DESC)->find($data); }