1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
<?php
namespace hji\membership\models;
use hji\common\AbstractSettingsModel;
use hji\membership\Membership;
class Settings extends \hji\common\interfaces\AbstractSettingsModel
{
protected static $__CLASS__ = __CLASS__;
const KEY = 'hji-membership-settings';
public function __construct()
{
parent::__construct('membership', self::KEY);
$this->loadOptions();
$data = $this->settings;
$this->licenseKey = !empty($data['license-key']) ? trim($data['license-key']) : false;
$this->customer['name'] = !empty($data['customer']['name']) ? trim($data['customer']['name']) : null;
$this->customer['email'] = !empty($data['customer']['email']) ? trim($data['customer']['email']) : null;
$this->customer['officeName'] = !empty($data['customer']['officeName']) ? trim($data['customer']['officeName']) : null;
$this->customer['officePhone'] = !empty($data['customer']['officePhone']) ? trim($data['customer']['officePhone']) : null;
$this->customer['mobilePhone'] = !empty($data['customer']['mobilePhone']) ? trim($data['customer']['mobilePhone']) : null;
$this->customer['fax'] = !empty($data['customer']['fax']) ? trim($data['customer']['fax']) : null;
$this->customer['address']['deliveryLine'] = !empty($data['customer']['address']['deliveryLine']) ? trim($data['customer']['address']['deliveryLine']) : null;
$this->customer['address']['city'] = !empty($data['customer']['address']['city']) ? trim($data['customer']['address']['city']) : null;
$this->customer['address']['state'] = !empty($data['customer']['address']['state']) ? trim($data['customer']['address']['state']) : null;
$this->customer['address']['zip'] = !empty($data['customer']['address']['zip']) ? trim($data['customer']['address']['zip']) : null;
$this->customer['photo'] = !empty($data['customer']['photo']) ? trim($data['customer']['photo']) : null;
$this->customer['logo'] = !empty($data['customer']['logo']) ? trim($data['customer']['logo']) : null;
$this->crm = $this->getCRMOptions();
}
protected function getCRMOptions()
{
$crmOptions = get_option('ire_crm');
return (isset($crmOptions['url']) && !empty($crmOptions['url'])) ? $crmOptions : null;
}
public static function deleteOptions()
{
delete_option(self::KEY);
delete_option('ire_crm');
}
}