コード例 #1
0
 /**
  * Parse the status query.
  *
  * @since 1.0
  *
  * @return Where|null
  */
 protected function parse_status()
 {
     if ($this->args['status'] === 'any') {
         return null;
     } else {
         $white_list = Key::get_statuses();
         $statuses = (array) $this->args['status'];
         foreach ($statuses as $status) {
             if (!isset($white_list[$status])) {
                 throw new \InvalidArgumentException("Invalid status {$status}");
             }
         }
         return new Where('status', true, (array) $this->args['status']);
     }
 }
コード例 #2
0
    /**
     * Render the view.
     */
    public function render()
    {
        if (!$this->key) {
            return;
        }
        wp_enqueue_style('itelic-admin-license-detail');
        wp_enqueue_script('itelic-admin-license-detail');
        wp_localize_script('itelic-admin-license-detail', 'ITELIC', array('ajax' => admin_url('admin-ajax.php'), 'key' => $this->key->get_key(), 'disabling' => __("Deactivating", Plugin::SLUG), 'df' => it_exchange_php_date_format_to_jquery_datepicker_format($this->get_short_df()), 'update_nonce' => wp_create_nonce('itelic-update-key-' . $this->key->get_key()), 'statuses' => json_encode(Key::get_statuses())));
        $jdf = it_exchange_php_date_format_to_jquery_datepicker_format($this->get_short_df());
        $online = $this->key->is_online_product();
        $disable_activate = $this->key->get_status() != Key::ACTIVE;
        $disable_tip = __("Disabled or expired licenses cannot be activated.", Plugin::SLUG);
        $disable_title = $disable_activate ? "title=\"{$disable_tip}\"" : '';
        $disable_class = $disable_activate ? 'button-disabled' : '';
        $disabled_input = $disable_activate ? ' disabled' : '';
        ?>

		<div id="it-exchange-license-details">
			<div class="spacing-wrapper bottom-border header-block">

				<div class="status status-<?php 
        echo esc_attr($this->key->get_status());
        ?>
">
					<span data-value="<?php 
        echo esc_attr($this->key->get_status());
        ?>
" title="<?php 
        esc_attr_e("Click to edit", Plugin::SLUG);
        ?>
">
						<?php 
        echo $this->key->get_status(true);
        ?>
					</span>
				</div>

				<div class="name-block">
					<h2 class="customer-name"><?php 
        echo $this->key->get_customer()->wp_user->display_name;
        ?>
</h2>

					<h2 class="product-name"><?php 
        echo $this->key->get_product()->post_title;
        ?>
</h2>
				</div>
				<div class="key-block">
					<p>
						<label for="license-key" class="screen-reader-text"><?php 
        _e("License Key", Plugin::SLUG);
        ?>
</label>
						<input type="text" id="license-key" size="<?php 
        echo strlen($this->key->get_key());
        ?>
"
						       readonly value="<?php 
        echo esc_attr($this->key->get_key());
        ?>
">
					</p>
				</div>
			</div>

			<div class="spacing-wrapper bottom-border third-row misc-block">
				<div class="third expires">
					<h4><?php 
        _e("Expires", Plugin::SLUG);
        ?>
</h4>

					<h3 title="<?php 
        esc_attr_e("Click to edit", Plugin::SLUG);
        ?>
" data-df="<?php 
        echo $jdf;
        ?>
">
						<?php 
        if (null === ($d = $this->key->get_expires())) {
            ?>
							<?php 
            _e("Never", Plugin::SLUG);
            ?>
						<?php 
        } else {
            ?>
							<?php 
            echo \ITELIC\convert_gmt_to_local($d)->format($this->get_short_df());
            ?>
						<?php 
        }
        ?>
					</h3>
				</div>
				<div class="third transaction">
					<h4><?php 
        _e("Transaction", Plugin::SLUG);
        ?>
</h4>

					<h3>
						<a href="<?php 
        echo esc_url(get_edit_post_link($this->key->get_transaction()->ID));
        ?>
">
							<?php 
        echo it_exchange_get_transaction_order_number($this->key->get_transaction());
        ?>
						</a>
					</h3>
				</div>
				<div class="third max-activations">
					<h4><?php 
        _e("Max Activations", Plugin::SLUG);
        ?>
</h4>

					<h3 title="<?php 
        esc_attr_e("Click to edit", Plugin::SLUG);
        ?>
">
						<?php 
        echo $this->key->get_max() ? $this->key->get_max() : __('Unlimited', Plugin::SLUG);
        ?>
					</h3>
				</div>
			</div>

			<div class="spacing-wrapper activations<?php 
        echo count($this->renewals) ? ' bottom-border' : '';
        ?>
">
				<h3><?php 
        _e("Activations", Plugin::SLUG);
        ?>
</h3>

				<table id="activations-table" class="widefat">
					<thead>
					<tr>
						<th class="location-col"><?php 
        _e("Location", Plugin::SLUG);
        ?>
</th>
						<th class="status-col"><?php 
        _e("Status", Plugin::SLUG);
        ?>
</th>
						<th class="activation-col"><?php 
        _e("Activation", Plugin::SLUG);
        ?>
</th>
						<th class="deactivation-col"><?php 
        _e("Deactivation", Plugin::SLUG);
        ?>
</th>
						<th class="version-col"><?php 
        _e("Version", Plugin::SLUG);
        ?>
</th>
						<th class="delete-col">
							<span class="screen-reader-text"><?php 
        _e("Delete", Plugin::SLUG);
        ?>
</span></th>
					</tr>
					</thead>

					<tbody>
					<?php 
        foreach ($this->key->get_activations() as $activation) {
            ?>

						<?php 
            echo $this->get_activation_row_html($activation);
            ?>

					<?php 
        }
        ?>
					</tbody>
				</table>

				<h4><?php 
        _e("Remote Activate", Plugin::SLUG);
        ?>
</h4>

				<label for="remote-activate-location" class="screen-reader-text"><?php 
        _e("Install Location", Plugin::SLUG);
        ?>
</label>
				<input type="<?php 
        echo $online ? 'url' : 'text';
        ?>
" id="remote-activate-location"
				       placeholder="<?php 
        _e("Install Location", Plugin::SLUG);
        ?>
"<?php 
        echo $disabled_input;
        ?>
>
				<input type="submit" id="remote-activate-submit" class="it-exchange-button <?php 
        echo $disable_class;
        ?>
"
				       value="<?php 
        esc_attr_e("Activate", Plugin::SLUG);
        ?>
" data-tip="<?php 
        echo $disable_tip;
        ?>
"<?php 
        echo $disable_title;
        ?>
>
				<input type="hidden" id="remote-activate-key" value="<?php 
        echo esc_attr($this->key->get_key());
        ?>
">
				<?php 
        wp_nonce_field('itelic-remote-activate-key-' . $this->key->get_key());
        ?>
			</div>

			<?php 
        if (count($this->renewals)) {
            ?>

				<div class="spacing-wrapper renewals">

					<h3><?php 
            _e("Renewal History", Plugin::SLUG);
            ?>
</h3>

					<ul>
						<?php 
            foreach ($this->renewals as $renewal) {
                ?>

							<li>
								<?php 
                echo $renewal->get_renewal_date()->format(get_option('date_format'));
                ?>
								&nbsp;&mdash;&nbsp;

								<?php 
                if ($renewal->get_transaction()) {
                    ?>
									<a href="<?php 
                    echo get_edit_post_link($renewal->get_transaction()->ID);
                    ?>
">
										<?php 
                    echo it_exchange_get_transaction_order_number($renewal->get_transaction());
                    ?>
									</a>
								<?php 
                } else {
                    ?>
									<?php 
                    _e("Manual Renewal", Plugin::SLUG);
                    ?>
								<?php 
                }
                ?>
							</li>

						<?php 
            }
            ?>
					</ul>

				</div>

			<?php 
        }
        ?>

			<?php 
        /**
         * Fires at the end of the single license screen.
         *
         * @since 1.0
         *
         * @param Key $key
         */
        do_action('itelic_single_license_screen_end', $this->key);
        ?>

		</div>

		<?php 
        /**
         * Fires after the main single license screen.
         *
         * @since 1.0
         *
         * @param Key $key
         */
        do_action('itelic_single_license_screen_after', $this->key);
    }
コード例 #3
0
 /**
  * Get an associative array ( id => link ) with the list
  * of views available on this table.
  *
  * @since  1.0
  * @access protected
  *
  * @return array
  */
 protected function get_views()
 {
     $statuses = Key::get_statuses();
     $any = array('any' => __("All", Plugin::SLUG));
     $statuses = $any + $statuses;
     $links = array();
     foreach ($statuses as $status => $label) {
         $links[$status] = sprintf('<a href="%1$s">%2$s</a>', $this->get_view_link($status), $label) . " ({$this->counts[$status]})";
     }
     $selected = isset($_GET['status']) ? $_GET['status'] : 'any';
     $links[$selected] = "<strong>{$statuses[$selected]} ({$this->counts[$selected]})</strong>";
     return $links;
 }
コード例 #4
0
 public function test_statuses_exist()
 {
     $statuses = Key::get_statuses();
     $this->assertArrayHasKey('active', $statuses, 'Active status does not exist.');
     $this->assertArrayHasKey('disabled', $statuses, 'Disable status does not exist.');
     $this->assertArrayHasKey('expired', $statuses, 'Expired status does not exist.');
 }
コード例 #5
0
 /**
  * Get the chart for this report.
  *
  * @since 1.0
  *
  * @param string $date_type
  * @param int    $product
  *
  * @return Chart
  */
 public function get_chart($date_type = 'this_year', $product = 0)
 {
     $start = date('Y-m-d H:i:s', $this->convert_date($date_type));
     $end = date('Y-m-d H:i:s', $this->convert_date($date_type, true));
     $grouping = self::get_grouping_for_date_type($date_type);
     $sql = self::get_group_by($grouping, 'p.post_date');
     $group = $sql['group'];
     $per = $sql['per'];
     if ($per) {
         $per .= ' AS d, ';
     }
     if ($group) {
         $group = "GROUP BY {$group}";
     }
     /**
      * @var \wpdb $wpdb
      */
     global $wpdb;
     $ktn = Manager::get('itelic-keys')->get_table_name($wpdb);
     $ptn = $wpdb->posts;
     $raw = "SELECT {$per}COUNT(1) as c FROM {$ktn} k JOIN {$ptn} p ON (k.transaction_id = p.ID and p.post_date BETWEEN %s and %s) WHERE k.status = %s ";
     if ($product) {
         $product = absint($product);
         $raw .= "AND product = '{$product}' ";
     }
     $raw .= $group;
     $active = $wpdb->get_results($wpdb->prepare($raw, $start, $end, Key::ACTIVE));
     $expired = $wpdb->get_results($wpdb->prepare($raw, $start, $end, Key::EXPIRED));
     $disabled = $wpdb->get_results($wpdb->prepare($raw, $start, $end, Key::DISABLED));
     $active = self::fill_gaps(self::translate_results($active), $start, $end, $grouping);
     $expired = self::fill_gaps(self::translate_results($expired), $start, $end, $grouping);
     $disabled = self::fill_gaps(self::translate_results($disabled), $start, $end, $grouping);
     $labels = self::get_labels($active, $date_type);
     $chart = new Line($labels, 600, 200, array('ibdShowLegend' => '#legend-' . $this->get_slug(), 'responsive' => true));
     $statuses = Key::get_statuses();
     $chart->add_data_set(array_values($active), $statuses[Key::ACTIVE], array('fillColor' => "rgba(140,197,62,0.2)", 'strokeColor' => "rgba(140,197,62,1)", 'pointColor' => "rgba(140,197,62,1)", 'pointStrokeColor' => "#fff", 'pointHighlightFill' => "#fff", 'pointHighlightStroke' => "rgba(140,197,62,1)"));
     $chart->add_data_set(array_values($expired), $statuses[Key::EXPIRED], array('fillColor' => "rgba(255,186,0,0.2)", 'strokeColor' => "rgba(255,186,0,1)", 'pointColor' => "rgba(255,186,0,1)", 'pointStrokeColor' => "#fff", 'pointHighlightFill' => "#fff", 'pointHighlightStroke' => "rgba(255,186,0,1)"));
     $chart->add_data_set(array_values($disabled), $statuses[Key::DISABLED], array('fillColor' => "rgba(221,61,54,0.2)", 'strokeColor' => "rgba(221,61,54,1)", 'pointColor' => "rgba(221,61,54,1)", 'pointStrokeColor' => "#fff", 'pointHighlightFill' => "#fff", 'pointHighlightStroke' => "rgba(221,61,54,1)"));
     return $chart;
 }