| @@ -14,11 +14,11 @@ | ||
| 14 | 14 | class Model_E2pdf_License extends Model_E2pdf_Model { |
| 15 | 15 | |
| 16 | 16 | private $license; |
| 17 | 17 | |
| 18 | - public function __construct() { | |
| 18 | + public function __construct($license) { | |
| 19 | 19 | parent::__construct(); |
| 20 | - $this->load_license(); | |
| 20 | + $this->license = $license; | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function get($key) { |
| 24 | 24 | if (isset($this->license[$key])) { |
| @@ -24,52 +24,7 @@ | ||
| 24 | 24 | if (isset($this->license[$key])) { |
| 25 | 25 | return $this->license[$key]; |
| 26 | 26 | } else { |
| 27 | 27 | return false; |
| 28 | - } | |
| 29 | - } | |
| 30 | - | |
| 31 | - // load license | |
| 32 | - public function load_license() { | |
| 33 | - $model_e2pdf_api = new Model_E2pdf_Api(); | |
| 34 | - $model_e2pdf_api->set( | |
| 35 | - [ | |
| 36 | - 'action' => 'license/info', | |
| 37 | - ] | |
| 38 | - ); | |
| 39 | - $license = $model_e2pdf_api->request(); | |
| 40 | - $this->license = $license; | |
| 41 | - } | |
| 42 | - | |
| 43 | - // reload license | |
| 44 | - public function reload_license() { | |
| 45 | - $this->load_license(); | |
| 46 | - } | |
| 47 | - | |
| 48 | - // load templates | |
| 49 | - public function load_templates() { | |
| 50 | - global $wpdb; | |
| 51 | - | |
| 52 | - $condition = [ | |
| 53 | - 'activated' => [ | |
| 54 | - 'condition' => '=', | |
| 55 | - 'value' => '1', | |
| 56 | - 'type' => '%d', | |
| 57 | - ], | |
| 58 | - 'uid' => [ | |
| 59 | - 'condition' => '=', | |
| 60 | - 'value' => '', | |
| 61 | - 'type' => '%s', | |
| 62 | - ], | |
| 63 | - ]; | |
| 64 | - $where = $this->helper->load('db')->prepare_where($condition); | |
| 65 | - $model_e2pdf_template = new Model_E2pdf_Template(); | |
| 66 | - | |
| 67 | - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare | |
| 68 | - $tpls = $wpdb->get_results($wpdb->prepare('SELECT `ID` FROM `' . $model_e2pdf_template->get_table() . '`' . $where['sql'] . '', $where['filter'])); | |
| 69 | - foreach ($tpls as $key => $tpl) { | |
| 70 | - $template = new Model_E2pdf_Template(); | |
| 71 | - $template->load($tpl->ID, false); | |
| 72 | - $template->activate(); | |
| 73 | 28 | } |
| 74 | 29 | } |
| 75 | 30 | } |