/**
     * Render the notification editor.
     *
     * @since 1.0
     */
    protected function render_notification_editor()
    {
        $editor = new Editor(Factory::make('itelic-outdated-customers'), array('mustSelectItem' => __("You must select an item", Plugin::SLUG), 'selectTemplateTag' => __("Select Template Tag", Plugin::SLUG), 'templateTag' => __("Template Tag", Plugin::SLUG), 'selectATag' => __("Select a tag", Plugin::SLUG), 'insertTag' => __("Insert", Plugin::SLUG), 'cancel' => __("Cancel", Plugin::SLUG), 'insertTemplateTag' => __("Insert Template Tag", Plugin::SLUG)));
        $editor->thickbox();
        ?>

		<div class="spacing-wrapper hidden notifications-editor">

			<h4><?php 
        _e("Send Update Reminders", Plugin::SLUG);
        ?>
</h4>

			<p class="description">
				<?php 
        printf(__('Email your customers who have not yet updated to version %1$s of %2$s.', Plugin::SLUG), $this->release->get_version(), $this->release->get_product()->post_title);
        ?>
			</p>

			<div class="notification-editor-fields-container">

				<input type="text" id="notification-subject" placeholder="<?php 
        esc_attr_e("Enter your subject", Plugin::SLUG);
        ?>
">

				<?php 
        $editor->display_template_tag_button();
        ?>

				<?php 
        wp_editor('', 'notification-body', array('teeny' => true, 'media_buttons' => false, 'editor_height' => '250px'));
        ?>

				<p class="clearfix notification-buttons">
					<a href="javascript:" class="button button-secondary" id="cancel-notification">
						<?php 
        _e("Cancel", Plugin::SLUG);
        ?>
					</a>
					<a href="javascript:" class="button button-primary" id="send-notification">
						<?php 
        _e("Send", Plugin::SLUG);
        ?>
					</a>
				</p>
			</div>
		</div>

		<?php 
    }
 /**
  * Get data to display for a single key.
  *
  * @param \ITELIC\Activation|\ITELIC\Release $release
  * @param bool                               $raw
  *
  * @return array
  */
 protected function get_fields_for_object(\ITELIC\Release $release, $raw = false)
 {
     if ($release->get_start_date()) {
         $started = $release->get_start_date()->format(DateTime::ISO8601);
     } else {
         $started = '-';
     }
     return array('ID' => $release->get_ID(), 'product' => $raw ? $release->get_product()->ID : $release->get_product()->post_title, 'version' => $release->get_version(), 'type' => $release->get_type(!$raw), 'status' => $release->get_status(!$raw), 'download' => $raw ? $release->get_download()->ID : $release->get_download()->post_title, 'started' => $started, 'changelog' => $release->get_changelog());
 }
/**
 * When a release is paused, set the last updated value to the previous release
 * in the readme product feature.
 *
 * @internal
 *
 * @since 1.0
 *
 * @param Release      $release
 * @param Release|null $prev_release
 */
function set_last_updated_value_in_readme_on_pause(Release $release, Release $prev_release = null)
{
    if ($prev_release && $release->get_product()->has_feature('licensing-readme')) {
        $release->get_product()->update_feature('licensing-readme', array('last_updated' => $prev_release->get_start_date()->getTimestamp()));
    }
}
 /**
  * Get notifications.
  *
  * @since 1.0
  *
  * @param Release $release
  * @param string  $message
  * @param string  $subject
  *
  * @return Notification[]
  */
 public function get_notifications(Release $release, $message, $subject)
 {
     /** @var $wpdb \wpdb */
     global $wpdb;
     $atn = Manager::get('itelic-activations')->get_table_name($wpdb);
     $ktn = Manager::get('itelic-keys')->get_table_name($wpdb);
     $rtn = Manager::get('itelic-releases')->get_table_name($wpdb);
     $results = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT k.customer FROM {$atn} a JOIN {$ktn} k ON ( a.lkey = k.lkey AND k.`product` = %d )\n\t\t\t WHERE a.status = %s AND a.release_id IN (\n\t\t\t SELECT r.ID FROM {$rtn} r WHERE r.product = %d AND r.`start_date` < %s )", $release->get_product()->ID, Activation::ACTIVE, $release->get_product()->ID, $release->get_start_date()->format('Y-m-d H:i:s')));
     if (empty($results)) {
         return array();
     }
     $notifications = array();
     foreach ($results as $result) {
         $to = get_user_by('id', $result->customer);
         if (!$to instanceof \WP_User) {
             continue;
         }
         $notification = new Notification($to, Factory::make('itelic-outdated-customers'), $message, $subject);
         $notification->add_data_source($release);
         $notifications[] = $notification;
     }
     return $notifications;
 }