<?php

class Brivium_Credits_ControllerAdmin_User extends XFCP_Brivium_Credits_ControllerAdmin_User
{
	public function actionSave() {
		$GLOBALS['BRC_CAU_actionSave'] = $this;
		return parent::actionSave();
	}
	protected function _getUserAddEditResponse(array $user)
	{
		$response = parent::_getUserAddEditResponse($user);
		if (XenForo_Visitor::getInstance()->hasAdminPermission('BRC_editUserCredits'))
		{
			$response->params['currencies'] = $this->getModelFromCache('Brivium_Credits_Model_Currency')->getAllCurrencies();
		}
		return $response;
	}
	public function brcActionSave(XenForo_DataWriter_User $dw) {
		if (XenForo_Visitor::getInstance()->hasAdminPermission('BRC_editUserCredits'))
		{
			$currencies = $this->getModelFromCache('Brivium_Credits_Model_Currency')->getAllCurrencies();
			foreach($currencies AS $currency){
				$credits = 0;
				$credits = $this->_input->filterSingle($currency['column'], XenForo_Input::NUM);
				$dw->set($currency['column'], $credits);
			}
		}
	}
}