function __get($name) { if ($name == 'mc_api') { require_once dirname(__FILE__) . '/library/MCAPI.class.php'; $api_key = $this->model->get_mc_key(); if (!$api_key) { return NULL; } $this->mc_api = new MCAPI($api_key); return $this->mc_api; } if ($name == 'cm_general') { require_once dirname(__FILE__) . '/library/csrest_general.php'; $api_key = $this->model->get_cm_key(); if (!$api_key) { return NULL; } $this->cm_general = new CS_REST_General($api_key); return $this->cm_general; } if (in_array(strtolower($name), array('cm_clients', 'cm_lists', 'cm_subscribers'))) { $lib = str_replace('cm_', '', strtolower($name)); require_once dirname(__FILE__) . '/library/csrest_' . $lib . '.php'; $api_key = $this->model->get_cm_key(); if (!$api_key) { return NULL; } $class_name = 'CS_REST_' . ucfirst($lib); $this->{'cm_' . $lib} = new $class_name('', $api_key); return $this->{'cm_' . $lib}; } return parent::__get($name); }