2014-07-06 08:18:11 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
|
|
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
|
|
|
|
|
|
|
class PreferencesController extends BaseController
|
|
|
|
{
|
|
|
|
protected $accounts;
|
|
|
|
protected $preferences;
|
|
|
|
|
|
|
|
public function __construct(ARI $accounts, PHI $preferences)
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->accounts = $accounts;
|
|
|
|
$this->preferences = $preferences;
|
|
|
|
View::share('menu', 'home');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$accounts = $this->accounts->getDefault();
|
|
|
|
|
2014-07-14 23:58:08 -05:00
|
|
|
$viewRange = $this->preferences->get('viewRange','1M');
|
|
|
|
$viewRangeValue = $viewRange->data;
|
|
|
|
|
2014-07-06 08:18:11 -05:00
|
|
|
// pref:
|
|
|
|
$frontpage = $this->preferences->get('frontpageAccounts', []);
|
2014-07-14 23:58:08 -05:00
|
|
|
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)->with('viewRange',$viewRangeValue);
|
2014-07-06 08:18:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function postIndex()
|
|
|
|
{
|
2014-07-14 23:58:08 -05:00
|
|
|
|
|
|
|
// frontpage accounts
|
2014-07-06 08:18:11 -05:00
|
|
|
$frontpageAccounts = [];
|
|
|
|
foreach(Input::get('frontpageAccounts') as $id) {
|
|
|
|
$frontpageAccounts[] = intval($id);
|
|
|
|
}
|
|
|
|
$this->preferences->set('frontpageAccounts',$frontpageAccounts);
|
2014-07-14 23:58:08 -05:00
|
|
|
|
|
|
|
// view range:
|
|
|
|
$this->preferences->set('viewRange',Input::get('viewRange'));
|
|
|
|
// forget session values:
|
|
|
|
Session::forget('start');
|
|
|
|
Session::forget('end');
|
|
|
|
Session::forget('range');
|
|
|
|
|
2014-07-06 08:18:11 -05:00
|
|
|
Session::flash('success', 'Preferences saved!');
|
|
|
|
return Redirect::route('preferences');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|