<?php

use Twilio\Values;

/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Authorizepmnt_AdminSettingsController extends Core_Controller_Action_Admin
{

	public function indexAction()
	{
		$this->view->navigation = Engine_Api::_()->getApi('menus', 'core')
			->getNavigation('authorizepmnt_admin_main', array(), 'authorizepmnt_admin_main_settings');

		$this->view->form  = $form = new Authorizepmnt_Form_Admin_Global();
		if (_ENGINE_ADMIN_NEUTER) {
			$form->authorizepmnt_licensekey->setValue("**********");
			return;
		}

		if ($this->getRequest()->isPost() && $form->isValid($this->_getAllParams())) {
			$values = $form->getValues();
			unset($values['authorizepmnt_paymentlink']);

			include_once APPLICATION_PATH . "/application/modules/Authorizepmnt/controllers/License.php";
			if (Engine_Api::_()->getApi('settings', 'core')->getSetting('authorizepmnt.pluginactivated')) {
				foreach ($values as $key => $value) {
					if (Engine_Api::_()->getApi('settings', 'core')->hasSetting($key))
						Engine_Api::_()->getApi('settings', 'core')->removeSetting($key);
					Engine_Api::_()->getApi('settings', 'core')->setSetting($key, $value);
				}
				$form->addNotice('Your changes have been saved.');
				if ($error)
					$this->_helper->redirector->gotoRoute(array());
			}
		}
	}
}
