mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
delete prod record module
This commit is contained in:
@@ -1,324 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class module_prod_route_records_abstract
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var set_selection
|
||||
*/
|
||||
protected $selection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $is_possible;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $elements_received;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $single_grouping;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $sbas_id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $has_many_sbas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $required_rights = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $required_sbas_rights = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $works_on_unique_sbas = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var <type>
|
||||
*/
|
||||
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 <type>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class module_prod_route_records_bridge extends module_prod_route_records_abstract
|
||||
{
|
||||
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class module_prod_route_records_feed extends module_prod_route_records_abstract
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $required_sbas_rights = array('bas_chupub');
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $works_on_unique_sbas = true;
|
||||
protected $flatten_groupings = true;
|
||||
|
||||
public function __construct(Symfony\Component\HttpFoundation\Request $request)
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
|
||||
parent::__construct($request);
|
||||
|
||||
if ($this->is_single_grouping())
|
||||
{
|
||||
$record = array_pop($this->selection->get_elements());
|
||||
foreach ($record->get_children() as $child)
|
||||
{
|
||||
$this->selection->add_element($child);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class module_prod_route_records_move extends module_prod_route_records_abstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $required_rights = array('candeleterecord');
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $available_destinations;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $works_on_unique_sbas = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return action_move
|
||||
*/
|
||||
public function __construct(Symfony\Component\HttpFoundation\Request $request)
|
||||
{
|
||||
parent::__construct($request);
|
||||
$this->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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user