<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Acppro_AdminSettingsController extends Core_Controller_Action_Admin {

  public function indexAction() {

    $db = Engine_Db_Table::getDefaultAdapter();
		$viewer = Engine_Api::_()->user()->getViewer();
    if(!$viewer->isSuperAdmin()) {
      return $this->_redirectCustom($this->view->url(array('module'=>'core', 'controller'=>'index','action' => 'index')));
    }

    $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('acppro_admin_main', array(), 'acppro_admin_main_settings');

    $this->view->form = $form = new Acppro_Form_Admin_Settings_Global();

    if ($this->getRequest()->isPost() && $form->isValid($this->_getAllParams())) {
      $values = $form->getValues();
			foreach ($values as $key => $value) {
				Engine_Api::_()->getApi('settings', 'core')->setSetting($key, $value);
			}
			$form->addNotice('Your changes have been saved.');
    }
  }
}
