function indexAction()
 {
     $minimum = Site::getResource('cashout_minimum');
     $session = new Zend_Session_Namespace('user');
     if ($session->user->balance < $minimum) {
         $this->view->cashout_failedMinimum = true;
     }
     if ($this->getRequest()->isPost()) {
         $this->request();
         $this->view->cashout_showConfirmation = true;
     }
 }
 function approveAction()
 {
     $user = $this->getRequest()->getParam('user');
     $cashout = Cashout_Models_Cashout::getUsersLastPendingCashout($user);
     if ($cashout != null) {
         $cashout->completionDate = date('Y-m-d');
         $cashout->approve();
         $user = User_Models_User::getUser($user);
         $pay[$user->paymentEmail] = $cashout->amount;
         //now send the payment to the user
         $paymentGateway = Site::getInstance(Site::getResource('payment_gateway'));
         $paymentGateway->pay($pay);
     }
     $this->getResponse()->setRedirect('/cashout/admin/requests');
 }
 function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     //make sure the requested module is not disabled
     $module = $this->getRequest()->getModuleName();
     if ($module != 'default') {
         $module = ModuleInfo::getModule($this->getRequest()->getModuleName());
         if (isset($module['status']) && $module['status'] != 'active') {
             $this->getResponse()->setRedirect('/');
         }
     }
     $front = Zend_Controller_Front::getInstance();
     $layout = Zend_Layout::getMvcInstance();
     $savedMenus = unserialize(Site::getResource('site_menu'));
     $menus = array();
     $sections = self::getSections();
     foreach ($savedMenus as $moduleMenus) {
         self::getModulePages($sections, $moduleMenus, $menus);
     }
     $layout->getView()->navigation(new Zend_Navigation($menus));
 }
 public function isValid($value)
 {
     $min = Site::getResource('fund_min');
     $max = Site::getResource('fund_max');
     $this->_messageTemplates[self::MSG_MIN_ERROR] = str_replace('%d', $min, $this->_messageTemplates[self::MSG_MIN_ERROR]);
     $this->_messageTemplates[self::MSG_MAX_ERROR] = str_replace('%d', $max, $this->_messageTemplates[self::MSG_MAX_ERROR]);
     if (!preg_match('/^(\\d{2,})\\.\\d{2}$/', $value)) {
         $this->_error(self::MSG_INVALID);
         return FALSE;
     } else {
         if ($value < $min) {
             $this->_error(self::MSG_MIN_ERROR);
             return FALSE;
         } else {
             if ($value > $max) {
                 $this->_error(self::MSG_MAX_ERROR);
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
 function indexAction()
 {
     $session = new Zend_Session_Namespace('user');
     $form = new Fund_Models_Forms_Fund();
     $minimum = Site::getResource('fund_minimum');
     $maximum = Site::getResource('fund_maximum');
     if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
         $fund = Fund_Models_FundAccount::getUsersLastFundAccount('pending');
         if ($fund == NULL) {
             $args = array('ownerID' => $session->user->accountID, 'startDate' => date('Y-m-d'), 'status' => 'pending', 'amount' => $form->getValue('amount'));
             $fund = new Fund_Models_FundAccount($args);
         }
         $fund->amount = $form->getValue('amount');
         $fund->save();
         $session->user->lastFundTransaction = $fund;
         //display pay button
         $paymentGateway = Site::getInstance(Site::getResource('payment_gateway'));
         $paymentGateway->returnUrl = 'http://www.project.supersaid.net/fund/complete';
         $paymentGateway->cancelUrl = 'http://www.project.supersaid.net/fund/cancel';
         $this->view->form = $paymentGateway->getForm($fund);
     } else {
         $this->view->form = $form;
     }
 }