public function action_wallet() { $data['wallets'] = ''; if ($userId = \Input::get('userId')) { $data['wallets'] = Model_Wallet::find('all', array('where' => array(array('user_id', '=', $userId)))); $data['wallet_user'] = $userId; $data['available_wallets'] = Model_Wallet::find('all', array('where' => array(array('user_id', 'is', null)))); } $this->template->title = 'Wallet Manager'; $data['users'] = Model_User::find('all'); $this->template->content = View::forge('backend/admin/wallet/index', $data); }
public static function create_wallet($userId) { $wallet = Model_Wallet::find('first', array('where' => array(array('user_id', 'is', null)))); if ($wallet === null) { \Session::set_flash('warning', 'Sorry, your wallet could not be created, please contact support. Don\'t worry, you can still choose to buy some options.'); return false; } $wallet->user_id = $userId; if (!$wallet->save()) { \Session::set_flash('error', 'There was some technical issue while trying to create your wallet, please contact support. Time to choose some options.'); } else { \Session::set_flash('success', 'Congratulations, your wallet has been created ! Time to create and buy your first options.'); } }
public function action_sendcoin() { if (Input::method() == 'POST') { $val = Model_Sendcoin::validate('create'); if ($val->run()) { $sendcoin = Model_Sendcoin::forge(array('address' => Input::post('address'), 'user_id' => Input::post('user_id'), 'quantity' => Input::post('quantity'))); if ($sendcoin and $sendcoin->save()) { Session::set_flash('success', 'Added sendcoin #' . $sendcoin->id . '.'); Response::redirect('backend/index/thankyou'); } else { Session::set_flash('error', 'Could not save sendcoin.'); } } else { Session::set_flash('error', $val->error()); } } $data['addresses'] = Model_Wallet::find('all', array('related' => array('addresses' => array('where' => array(array('coin', '=', 'GRYF')))), 'where' => array(array('user_id', '=', $this->_userId)))); $this->template->title = 'Send Money'; $data['user_id'] = $this->_userId; $this->template->content = View::forge('backend/index/sendcoin/create', $data); }