diff --git a/lib/classes/module/prod/route/records/abstract.class.php b/lib/classes/module/prod/route/records/abstract.class.php deleted file mode 100644 index b477f62b93..0000000000 --- a/lib/classes/module/prod/route/records/abstract.class.php +++ /dev/null @@ -1,324 +0,0 @@ - - */ - protected $request; - protected $flatten_groupings = false; - - /** - * - * @var boolean - */ - protected $is_basket = false; - - /** - * - * @var basket_adapter - */ - protected $original_basket; - - /** - * - * @return action_move - */ - public function __construct(Symfony\Component\HttpFoundation\Request $request) - { -// $parm = $this->request->get_parms("lst", "ssel"); - - $this->request = $request; - $this->selection = new set_selection(); - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - - if (trim($request->get('ssel')) !== '') - { - $basket = basket_adapter::getInstance($appbox, $request->get('ssel'), $usr_id); - - if ($basket->is_grouping() && $this->flatten_groupings === true) - { - foreach ($basket->get_elements() as $basket_element) - { - /* @var $basket_element basket_element_adapter */ - $this->selection->add_element($basket_element->get_record()); - } - } - elseif($basket->is_grouping()) - { - $grouping = new record_adapter($basket->get_sbas_id(), $basket->get_record_id()); - $this->selection->add_element($grouping); - } - else - { - $this->selection->load_basket($basket); - $this->is_basket = true; - } - $this->original_basket = $basket; - } - else - { - $this->selection->load_list(explode(";", $request->get('lst')), $this->flatten_groupings); - } - $this->elements_received = $this->selection->get_count(); - - $this->single_grouping = ($this->get_count_actionable() == 1 && - $this->get_count_actionable_groupings() == 1); - - $this->examinate_selection(); - - return $this; - } - - /** - * Tells if the original selection was a basket - * - * @return boolean - */ - public function is_basket() - { - return $this->is_basket; - } - - /** - * If the original selection was a basket, returns the basket object - * - * @return basket_adapter - */ - public function get_original_basket() - { - return $this->original_basket; - } - - protected function examinate_selection() - { - $this->selection->grep_authorized($this->required_rights, $this->required_sbas_rights); - - if ($this->works_on_unique_sbas === true) - { - $this->sbas_ids = $this->selection->get_distinct_sbas_ids(); - - $this->is_possible = count($this->sbas_ids) == 1; - - $this->has_many_sbas = count($this->sbas_ids) > 1; - - $this->sbas_id = $this->is_possible ? array_pop($this->sbas_ids) : false; - } - - return $this; - } - - /** - * Is action applies on single grouping - * - * @return - */ - public function is_single_grouping() - { - return $this->single_grouping; - } - - /** - * When action on a single grouping, returns the image of himself - * - * @return record_adapter - */ - public function get_grouping_head() - { - if (!$this->is_single_grouping()) - throw new Exception('Cannot use ' . __METHOD__ . ' here'); - foreach ($this->get_elements() as $record) - - return $record; - } - - /** - * Get elements for the action - * - * @return Array - */ - public function get_elements() - { - return $this->selection->get_elements(); - } - - /** - * Returns true if elements comes from many sbas - * - * @return boolean - */ - public function has_many_sbas() - { - return $this->has_many_sbas; - } - - /** - * Returns true if the action is possible with the current elements - * for the user - * - * @return boolean - */ - public function is_possible() - { - return $this->is_possible; - } - - /** - * Returns the number of elements on which the action can not be done - * - * @return int - */ - public function get_count_not_actionable() - { - return $this->get_count_element_received() - $this->get_count_actionable(); - } - - /** - * Returns the number of elements on which the action can be done - * - * @return int - */ - public function get_count_actionable() - { - return $this->selection->get_count(); - } - - /** - * Returns the number of groupings on which the action can be done - * - * @return int - */ - public function get_count_actionable_groupings() - { - return $this->selection->get_count_groupings(); - } - - /** - * Return the number of elements receveid when starting action - * - * @return int - */ - public function get_count_element_received() - { - return $this->elements_received; - } - - /** - * Return sbas_ids of the current selection - * - * @return int - */ - public function get_sbas_id() - { - return $this->sbas_id; - } - - /** - * Get the selection as a serialized string base_id"_"record_id - * - * @return string - */ - public function get_serialize_list() - { - if ($this->is_single_grouping()) - - return $this->get_grouping_head()->get_serialize_key(); - else - - return $this->selection->serialize_list(); - } - - public function get_request() - { - return $this->request; - } - - public function set_request($request) - { - $this->request = $request; - } - - public function grep_records(Closure $closure) - { - foreach ($this->selection->get_elements() as $record) - { - if (!$closure($record)) - $this->selection->remove_element($record); - } - - return $this; - } - -} diff --git a/lib/classes/module/prod/route/records/bridge.class.php b/lib/classes/module/prod/route/records/bridge.class.php deleted file mode 100644 index 3e055e4c65..0000000000 --- a/lib/classes/module/prod/route/records/bridge.class.php +++ /dev/null @@ -1,21 +0,0 @@ -is_single_grouping()) - { - $record = array_pop($this->selection->get_elements()); - foreach ($record->get_children() as $child) - { - $this->selection->add_element($child); - } - } - - return $this; - } - -} diff --git a/lib/classes/module/prod/route/records/move.class.php b/lib/classes/module/prod/route/records/move.class.php deleted file mode 100644 index cf9786f306..0000000000 --- a/lib/classes/module/prod/route/records/move.class.php +++ /dev/null @@ -1,127 +0,0 @@ -evaluate_destinations(); - - return $this; - } - /** - * Check which collections can receive the documents - * - * @return action_move - */ - protected function evaluate_destinations() - { - $this->available_destinations = array(); - - if (!$this->is_possible) - - return $this; - - $appbox = appbox::get_instance(); - $session = $appbox->get_session(); - $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); - - $this->available_destinations = array_keys($user->ACL()->get_granted_base(array('canaddrecord'), array($this->sbas_id))); - - return $this; - } - - /** - * Returns an array of base_id - * - * @return Array - */ - public function available_destination() - { - return $this->available_destinations; - } - - public function propose() - { - return $this; - } - - /** - * - * @param http_request $request - * @return action_move - */ - public function execute(Symfony\Component\HttpFoundation\Request $request) - { - $appbox = appbox::get_instance(); - $session = $appbox->get_session(); - $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); - - $base_dest = - $user->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord') ? - $request->get('base_id') : false; - - if (!$this->is_possible()) - throw new Exception('This action is not possible'); - - if ($request->get("chg_coll_son") == "1") - { - foreach ($this->selection as $record) - { - if (!$record->is_grouping()) - continue; - foreach ($record->get_children() as $child) - { - if (!$user->ACL()->has_right_on_base( - $child->get_base_id(), 'candeleterecord')) - continue; - $this->selection->add_element($child); - } - } - } - - $collection = collection::get_from_base_id($base_dest); - - foreach ($this->selection as $record) - { - $record->move_to_collection($collection, $appbox); - } - - return $this; - } -}