Refactor Appbox

This commit is contained in:
Romain Neutron
2012-02-21 16:16:25 +01:00
parent dbd0b0c437
commit ec4ec4931d
6 changed files with 17 additions and 17 deletions

View File

@@ -32,7 +32,7 @@ class Prod extends Helper
); );
$bases = $fields = $dates = array(); $bases = $fields = $dates = array();
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$user = $this->getCore()->getAuthenticatedUser(); $user = $this->getCore()->getAuthenticatedUser();

View File

@@ -481,7 +481,7 @@ class Edit extends RecordHelper
*/ */
public function execute(Request $request) public function execute(Request $request)
{ {
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
if ($request->get('act_option') == 'SAVEGRP' && $request->get('newrepresent')) if ($request->get('act_option') == 'SAVEGRP' && $request->get('newrepresent'))
{ {
try try

View File

@@ -107,7 +107,7 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
$this->selection = new \set_selection(); $this->selection = new \set_selection();
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($core);
$usr_id = $appbox->get_session()->get_usr_id(); $usr_id = $appbox->get_session()->get_usr_id();
if (trim($Request->get('ssel')) !== '') if (trim($Request->get('ssel')) !== '')

View File

@@ -98,7 +98,7 @@ class MoveCollection extends RecordHelper
*/ */
public function execute(Request $request) public function execute(Request $request)
{ {
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$user = $this->getCore()->getAuthenticatedUser(); $user = $this->getCore()->getAuthenticatedUser();
$baseId = $request->get('base_id'); $baseId = $request->get('base_id');

View File

@@ -63,7 +63,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
public function delete_users() public function delete_users()
{ {
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
foreach ($this->users as $usr_id) foreach ($this->users as $usr_id)
{ {
$user = \User_Adapter::getInstance($usr_id, $appbox); $user = \User_Adapter::getInstance($usr_id, $appbox);
@@ -92,7 +92,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
public function get_users_rights() public function get_users_rights()
{ {
$user = $this->getCore()->getAuthenticatedUser(); $user = $this->getCore()->getAuthenticatedUser();
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$list = array_keys($user->ACL()->get_granted_base(array('canadmin'))); $list = array_keys($user->ACL()->get_granted_base(array('canadmin')));
@@ -393,7 +393,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
public function apply_rights() public function apply_rights()
{ {
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = \http_request::getInstance(); $request = \http_request::getInstance();
$ACL = \User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL(); $ACL = \User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL();
@@ -543,14 +543,14 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$users = $this->users; $users = $this->users;
$user = \User_adapter::getInstance(array_pop($users), \appbox::get_instance()); $user = \User_adapter::getInstance(array_pop($users), \appbox::get_instance($this->core));
if ($user->is_template() || $user->is_special()) if ($user->is_template() || $user->is_special())
{ {
return $this; return $this;
} }
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = \http_request::getInstance(); $request = \http_request::getInstance();
@@ -592,7 +592,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
public function apply_template() public function apply_template()
{ {
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$template = \User_adapter::getInstance($this->request->get('template'), $appbox); $template = \User_adapter::getInstance($this->request->get('template'), $appbox);
@@ -627,7 +627,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
foreach ($this->users as $usr_id) foreach ($this->users as $usr_id)
{ {
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance()); $user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($this->core));
if ($this->request->get('quota')) if ($this->request->get('quota'))
$user->ACL()->set_quotas_on_base($this->base_id, $this->request->get('droits'), $this->request->get('restes')); $user->ACL()->set_quotas_on_base($this->base_id, $this->request->get('droits'), $this->request->get('restes'));
else else
@@ -650,7 +650,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
{ {
foreach ($this->users as $usr_id) foreach ($this->users as $usr_id)
{ {
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance()); $user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($this->core));
$user->ACL()->set_masks_on_base($this->base_id, $vand_and, $vand_or, $vxor_and, $vxor_or); $user->ACL()->set_masks_on_base($this->base_id, $vand_and, $vand_or, $vxor_and, $vxor_or);
} }
@@ -670,7 +670,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
foreach ($this->users as $usr_id) foreach ($this->users as $usr_id)
{ {
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance()); $user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($this->core));
$user->ACL()->set_limits($this->base_id, $activate, $dmin, $dmax); $user->ACL()->set_limits($this->base_id, $activate, $dmin, $dmax);
} }

View File

@@ -42,7 +42,7 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
public function export() public function export()
{ {
$request = $this->request; $request = $this->request;
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$offset_start = (int) $request->get('offset_start'); $offset_start = (int) $request->get('offset_start');
@@ -80,7 +80,7 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
public function search() public function search()
{ {
$request = $this->request; $request = $this->request;
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$offset_start = (int) $this->request->get('offset_start'); $offset_start = (int) $this->request->get('offset_start');
$offset_start = $offset_start < 0 ? 0 : $offset_start; $offset_start = $offset_start < 0 ? 0 : $offset_start;
@@ -165,7 +165,7 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
throw new \Exception_InvalidArgument(_('Invalid mail address')); throw new \Exception_InvalidArgument(_('Invalid mail address'));
} }
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
$sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email'; $sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email';
@@ -197,7 +197,7 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
throw new \Exception_InvalidArgument(_('Invalid template name')); throw new \Exception_InvalidArgument(_('Invalid template name'));
} }
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance($this->core);
$user = $this->getCore()->getAuthenticatedUser(); $user = $this->getCore()->getAuthenticatedUser();
$created_user = \User_Adapter::create($appbox, $name, \random::generatePassword(16), null, false, false); $created_user = \User_Adapter::create($appbox, $name, \random::generatePassword(16), null, false, false);