Created
July 25, 2011 23:32
-
-
Save pnomolos/1105543 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
class ArclightML_Settings extends Backend_SettingsController | |
{ | |
public $implement = 'Db_ListBehavior, Db_FormBehavior'; | |
public $form_model_class = ''; | |
protected $access_for_groups = array(Users_Groups::admin); | |
public function config() { | |
$this->app_page_title = 'Mailing List Settings'; | |
$this->form_model_class = 'ArclightML_Setting'; | |
if (Phpr::$router->param('param1') == 'create') { | |
Core_ModuleManager::findById('arclightml')->listMailingListTypes(); | |
$settings = ArclightML_Setting::create(); | |
$class_name = Phpr::$router->param('param2'); | |
if (!Phpr::$classLoader->load($class_name)) | |
throw new Phpr_ApplicationException("Class {$class_name} not found."); | |
$settings->class_name = $class_name; | |
} else { | |
$settings = ArclightML_Setting::get(); | |
} | |
if ($settings) { | |
$settings->init_columns_info(); | |
$settings->define_form_fields(); | |
$this->viewData['form_model'] = $settings; | |
} | |
} | |
public function reset() { | |
$this->config_onReset(); | |
} | |
protected function config_onSave() { | |
try | |
{ | |
if (post('new_record')) { | |
$settings = ArclightML_Setting::create(); | |
$settings->class_name = Phpr::$router->param('param2'); | |
} else { | |
$settings = ArclightML_Setting::get(); | |
} | |
$settings->init_columns_info(); | |
$settings->define_form_fields(); | |
$settings->save(post('ArclightML_Setting')); | |
Phpr::$session->flash['success'] = 'Mailing List settings have been successfully saved.'; | |
Phpr::$response->redirect(url('arclightml/settings/config')); | |
} | |
catch (Exception $ex) | |
{ | |
Phpr::$response->ajaxReportException($ex, true, true); | |
} | |
} | |
protected function config_onReset() { | |
$settings = ArclightML_Setting::get(); | |
if ($settings) { | |
$settings->delete(); | |
} | |
Phpr::$response->redirect(url('arclightml/settings/config')); | |
} | |
protected function config_onLoadAddPopup() { | |
try | |
{ | |
$mailinglist_types = Core_ModuleManager::findById('arclightml')->listMailingListTypes(); | |
$type_list = array(); | |
foreach ($mailinglist_types as $class_name) | |
{ | |
$obj = new $class_name(); | |
$info = $obj->get_info(); | |
if (array_key_exists('name', $info)) | |
{ | |
$info['class_name'] = $class_name; | |
$type_list[] = $info; | |
} | |
} | |
// usort( $type_list, array('Shop_Payment', 'payment_method_cmp') ); | |
$this->viewData['type_list'] = $type_list; | |
} | |
catch (Exception $ex) | |
{ | |
$this->handlePageError($ex); | |
} | |
$this->renderPartial('add_method_form'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment