Merge branch '3.6' of github.com:alchemy-fr/Phraseanet into 3.6

This commit is contained in:
jygaulier
2012-01-02 11:59:07 +01:00
418 changed files with 10286 additions and 9531 deletions

View File

@@ -47,6 +47,7 @@ class ACL implements cache_cacheableInterface
* @var Array
*/
protected $_rights_records_preview;
/**
*
* @var Array
@@ -242,47 +243,88 @@ class ACL implements cache_cacheableInterface
if (count($base_ids) == 0)
return $this;
$params = array(
':usr_id' => $this->user->get_id()
, ':template_id' => $template_user->get_id()
$sbas_ids = array();
foreach ($base_ids as $base_id)
{
$sbas_ids[] = phrasea::sbasFromBas($base_id);
}
$sbas_ids = array_unique($sbas_ids);
$sbas_rights = array('bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub');
$sbas_to_acces = array();
$rights_to_give = array();
foreach ($template_user->ACL()->get_granted_sbas() as $databox)
{
$sbas_id = $databox->get_sbas_id();
if (!in_array($sbas_id, $sbas_ids))
continue;
if (!$this->has_access_to_sbas($sbas_id))
{
$sbas_to_acces[] = $sbas_id;
}
foreach ($sbas_rights as $right)
{
if ($template_user->ACL()->has_right_on_sbas($sbas_id, $right))
{
$rights_to_give[$sbas_id][$right] = '1';
}
}
}
$this->give_access_to_sbas($sbas_to_acces);
foreach ($rights_to_give as $sbas_id => $rights)
{
$this->update_rights_to_sbas($sbas_id, $rights);
}
$bas_rights = array('canputinalbum', 'candwnldhd'
, 'candwnldpreview', 'cancmd'
, 'canadmin', 'actif', 'canreport', 'canpush'
, 'canaddrecord', 'canmodifrecord', 'candeleterecord'
, 'chgstatus', 'imgtools'
, 'manage', 'modify_struct'
, 'nowatermark', 'order_master'
);
$sql = 'INSERT INTO sbasusr
(SELECT distinct null as sbasusr_id, sb.sbas_id, :usr_id as usr_id, bas_manage
, bas_modify_struct,bas_modif_th,bas_chupub
FROM sbasusr sb, bas b
WHERE b.base_id IN (' . implode(', ', $base_ids) . ')
AND b.sbas_id = sb.sbas_id
AND usr_id = :template_id)';
$bas_to_acces = array();
$rights_to_give = array();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
foreach ($template_user->ACL()->get_granted_base() as $collection)
{
$base_id = $collection->get_base_id();
$this->delete_data_from_cache(self::CACHE_RIGHTS_SBAS);
if (!in_array($base_id, $base_ids))
continue;
$sql = "INSERT INTO basusr
(SELECT null as id, base_id, :usr_id as usr_id, canputinalbum
, candwnldhd, candwnldsubdef, candwnldpreview, cancmd
, canadmin, actif, canreport, canpush, now() as creationdate
, basusr_infousr, mask_and, mask_xor, restrict_dwnld
, month_dwnld_max, remain_dwnld, time_limited, limited_from
, limited_to, canaddrecord, canmodifrecord, candeleterecord
, chgstatus, '0000-00-00 00:00:00' as lastconn, imgtools
, manage, modify_struct, bas_manage, bas_modify_struct
, nowatermark, order_master
FROM basusr
WHERE usr_id =
(SELECT usr_id
FROM usr WHERE usr_id = :template_id)
AND base_id IN (" . implode(', ', $base_ids) . "))";
if (!$this->has_access_to_base($base_id))
{
$bas_to_acces[] = $base_id;
}
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
foreach ($bas_rights as $right)
{
if ($template_user->ACL()->has_right_on_base($base_id, $right))
{
$rights_to_give[$base_id][$right] = '1';
}
}
}
$this->inject_rights();
$this->delete_data_from_cache(self::CACHE_RIGHTS_BAS);
$this->give_access_to_base($bas_to_acces);
foreach ($rights_to_give as $sbas_id => $rights)
{
$this->update_rights_to_base($base_id, $rights);
}
$this->user->set_last_template($template_user);
@@ -315,7 +357,7 @@ class ACL implements cache_cacheableInterface
{
return false;
}
if (!isset($this->_rights_bas[$base_id][$right]))
throw new Exception('right ' . $right . ' does not exists');
@@ -750,7 +792,7 @@ class ACL implements cache_cacheableInterface
{
if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited))
return $this;
try
{
$this->_rights_bas = $this->get_data_from_cache(self::CACHE_RIGHTS_BAS);
@@ -1399,12 +1441,12 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas();
$datetime = new DateTime();
if (!isset($this->_limited[$base_id]))
{
return false;
}
$ret = ($this->_limited[$base_id]['dmin'] > $datetime
|| $this->_limited[$base_id]['dmax'] < $datetime);

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../../vendor/oauth2/lib/OAuth2.inc';
require_once __DIR__ . '/../../../vendor/oauth2/lib/OAuth2.inc';
/**
*

View File

@@ -41,7 +41,7 @@ class API_OAuth2_Autoloader
*/
static public function autoload($class)
{
if (file_exists($file = dirname(__FILE__) . '/../../../vendor/oauth2/lib/' . str_replace(array('_', "\0"), array('/', ''), $class) . '.inc'))
if (file_exists($file = __DIR__ . '/../../../vendor/oauth2/lib/' . str_replace(array('_', "\0"), array('/', ''), $class) . '.inc'))
{
require $file;
}

View File

@@ -34,6 +34,13 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected $appbox;
/**
* Phraseanet Core
*
* @var \Alchemy\Phrasea\Core
*/
protected $core;
/**
* API constructor
*
@@ -41,9 +48,10 @@ class API_V1_adapter extends API_V1_Abstract
* @param appbox $appbox Appbox object
* @return API_V1_adapter
*/
public function __construct($auth_token, appbox &$appbox)
public function __construct($auth_token, appbox &$appbox, Alchemy\Phrasea\Core $core)
{
$this->appbox = $appbox;
$this->core = $core;
return $this;
}
@@ -332,7 +340,7 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array();
foreach ($containers as $basket)
{
$ret[$basket->get_ssel_id()] = $this->list_basket($basket);
$ret[$basket->getId()] = $this->list_basket($basket);
}
$result->set_datas(array("baskets" => $ret));
@@ -549,7 +557,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
public function add_record_tobasket(Request $request, $databox_id, $record_id)
{
}
/**
@@ -577,16 +585,16 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_baskets($usr_id)
{
$basket_coll = new basketCollection($this->appbox, $usr_id);
$em = $this->core->getEntityManager();
$repo = $em->getRepository('\Entities\Basket');
/* @var $repo \Repositories\BasketRepository */
$baskets = $repo->findActiveByUser($this->core->getAuthenticatedUser());
$ret = array();
foreach ($basket_coll->get_baskets() as $basktype => $baskets)
foreach ($baskets as $basket)
{
if (!in_array($basktype, array('recept', 'baskets')))
continue;
foreach ($baskets as $basket)
$ret[$basket->get_ssel_id()] = $this->list_basket($basket);
$ret[$basket->getId()] = $this->list_basket($basket);
}
return $ret;
@@ -607,10 +615,18 @@ class API_V1_adapter extends API_V1_Abstract
if (trim(strip_tags($name)) === '')
throw new API_V1_exception_badrequest ();
$user = User_Adapter::getInstance($this->appbox->get_session()->get_usr_id(), $this->appbox);
$basket = basket_adapter::create($this->appbox, $name, $user);
$user = $this->core->getAuthenticatedUser();
$Basket = new \Entities\Basket();
$Basket->setOwner($user);
$Basket->setName($name);
$em = $this->core->getEntityManager();
$em->persist($Basket);
$em->flush();
$ret = array();
$ret[$basket->get_ssel_id()] = $this->list_basket($basket);
$ret[$Basket->getId()] = $this->list_basket($Basket);
$result->set_datas(array("basket" => $ret));
return $result;
@@ -627,12 +643,15 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($request, $this);
$basket = basket_adapter::getInstance(
$this->appbox
, $basket_id
, $this->appbox->get_session()->get_usr_id()
);
$basket->delete();
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser());
$em->remove($Basket);
$em->flush();
return $this->search_baskets($request);
}
@@ -647,21 +666,21 @@ class API_V1_adapter extends API_V1_Abstract
public function get_basket(Request $request, $basket_id)
{
$result = new API_V1_result($request, $this);
try
{
$basket = basket_adapter::getInstance($this->appbox, $basket_id, $this->appbox->get_session()->get_usr_id());
$result->set_datas(
array("basket_elements" =>
array(
$basket->get_ssel_id() => $this->list_basket_content($basket)
)
)
);
}
catch (Exception $e)
{
}
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser());
$result->set_datas(
array("basket_elements" =>
array(
$Basket->getId() => $this->list_basket_content($Basket)
)
)
);
return $result;
}
@@ -669,16 +688,18 @@ class API_V1_adapter extends API_V1_Abstract
/**
* Retrieve elements of one basket
*
* @param basket_adapter $basket
* @param \Entities\Basket $Basket
* @return type
*/
protected function list_basket_content(basket_adapter $basket)
protected function list_basket_content(\Entities\Basket $Basket)
{
$ret = $this->list_basket($basket);
$ret = $this->list_basket($Basket);
$ret['basket_elements'] = array();
foreach ($basket->get_elements() as $basket_element)
foreach ($Basket->getElements() as $basket_element)
{
$ret['basket_elements'][$basket_element->get_sselcont_id()] = $this->list_basket_element($basket_element);
$ret['basket_elements'][$basket_element->getId()] = $this->list_basket_element($basket_element);
}
return $ret;
@@ -687,23 +708,46 @@ class API_V1_adapter extends API_V1_Abstract
/**
* Retrieve detailled informations about a basket element
*
* @param basket_element_adapter $basket_element
* @param \Entities\BasketElement $basket_element
* @return type
*/
protected function list_basket_element(basket_element_adapter $basket_element)
protected function list_basket_element(\Entities\BasketElement $basket_element)
{
$ret = array(
'basket_element_id' => $basket_element->get_sselcont_id()
, 'order' => $basket_element->get_order()
, 'record' => $this->list_record($basket_element->get_record())
, 'validation_item' => $basket_element->is_validation_item()
'basket_element_id' => $basket_element->getId()
, 'order' => $basket_element->getOrd()
, 'record' => $this->list_record($basket_element->getRecord())
, 'validation_item' => !!$basket_element->getValidationDatas()
);
if ($basket_element->is_validation_item())
if ($basket_element->getValidationDatas())
{
$ret['choices'] = $basket_element->get_choices();
$ret['agreement'] = $basket_element->get_my_agreement();
$ret['note'] = $basket_element->get_my_note();
$choices = array();
$agreement = $note = null;
foreach ($basket_element->getValidationDatas() as $validation_datas)
{
$user = $validation_datas->getParticipant()->getUser();
/* @var $validation_datas Entities\ValidationData */
$choices[$user->get_id()] = array(
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'is_mine' => $user->get_id() == $this->core->getAuthenticatedUser()->get_id(),
'agreement' => $validation_datas->getAgreement(),
'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM),
'note' => $validation_datas->getNote()
);
if($user->get_id() == $this->core->getAuthenticatedUser()->get_id())
{
$agreement = $validation_datas->getAgreement();
$note = $validation_datas->getNote();
}
}
$ret['choices'] = $choices();
$ret['agreement'] = $agreement();
$ret['note'] = $note();
}
return $ret;
@@ -721,12 +765,23 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($request, $this);
$name = $request->get('name');
$basket = basket_adapter::getInstance($this->appbox, $basket_id, $this->appbox->get_session()->get_usr_id());
$basket->set_name($name);
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser());
$Basket->setName($name);
$em->merge($Basket);
$em->flush();
$result->set_datas(
array(
"basket" =>
array($basket->get_ssel_id() => $this->list_basket_content($basket)
array($Basket->getId() => $this->list_basket_content($Basket)
)
)
);
@@ -746,12 +801,23 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($request, $this);
$desc = $request->get('description');
$basket = basket_adapter::getInstance($this->appbox, $basket_id, $this->appbox->get_session()->get_usr_id());
$basket->set_description($desc);
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser());
$Basket->setDescription($desc);
$em->merge($Basket);
$em->flush();
$result->set_datas(
array(
"basket" =>
array($basket->get_ssel_id() => $this->list_basket_content($basket)
array($Basket->getId() => $this->list_basket_content($Basket)
)
)
);
@@ -791,7 +857,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
public function remove_publications(Request $request, $publication_id)
{
}
/**
@@ -919,7 +985,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
public function search_users(Request $request)
{
}
/**
@@ -929,7 +995,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
public function get_user_acces(Request $request, $usr_id)
{
}
/**
@@ -938,7 +1004,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
public function add_user(Request $request)
{
}
/**
@@ -1032,7 +1098,6 @@ class API_V1_adapter extends API_V1_Abstract
* @todo ajouter une option pour avoir les values serialisées
* dans un cas multi
*/
return array(
'meta_id' => $field->get_meta_id()
, 'meta_structure_id' => $field->get_meta_struct_id()
@@ -1044,30 +1109,53 @@ class API_V1_adapter extends API_V1_Abstract
/**
* Retirve information about one basket
*
* @param basket_adapter $basket
* @param \Entities\Basket $basket
* @return array
*/
protected function list_basket(basket_adapter $basket)
protected function list_basket(\Entities\Basket $basket)
{
$ret = array(
'created_on' => $basket->get_create_date()->format(DATE_ATOM)
, 'description' => $basket->get_description()
, 'name' => $basket->get_name()
, 'pusher_usr_id' => $basket->get_pusher() ? $basket->get_pusher()->get_id() : null
, 'ssel_id' => $basket->get_ssel_id()
, 'updated_on' => $basket->get_update_date()->format(DATE_ATOM)
, 'unread' => $basket->is_unread()
'created_on' => $basket->getCreated()->format(DATE_ATOM)
, 'description' => (string) $basket->getDescription()
, 'name' => $basket->getName()
, 'pusher_usr_id' => $basket->getPusherId()
, 'ssel_id' => $basket->getId()
, 'updated_on' => $basket->getUpdated()->format(DATE_ATOM)
, 'unread' => !$basket->getIsRead()
);
if ($basket->is_valid())
if ($basket->getValidation())
{
$users = array();
foreach ($basket->getValidation()->getParticipants() as $participant)
{
/* @var $participant \Entities\ValidationParticipant */
$user = $participant->getUser();
$users[$user->get_id()] = array(
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers()
);
}
$expires_on_atom = $basket->getValidation()->getExpires();
if ($expires_on_atom instanceof DateTime)
$expires_on_atom = $expires_on_atom->format(DATE_ATOM);
$user = \User_Adapter::getInstance($this->appbox->get_session()->get_usr_id(), $this->appbox);
$ret = array_merge(
array(
'validation_users' => $basket->get_validating_users()
, 'validation_end_date' => ($basket->get_validation_end_date() instanceof DateTime ? $basket->get_validation_end_date()->format(DATE_ATOM) : null)
, 'validation_infos' => $basket->get_validation_infos()
, 'validation_confirmed' => $basket->is_confirmed()
, 'mine' => $basket->is_mine()
'validation_users' => $users
, 'validation_end_date' => $expires_on_atom
, 'validation_infos' => $basket->getValidation()->getValidationString($user)
, 'validation_confirmed' => $basket->getValidation()->getParticipant($user)->getIsConfirmed()
, 'mine' => $basket->getValidation()->isInitiator($user)
)
, $ret
);

View File

@@ -1,6 +1,6 @@
<?php
require_once dirname(__FILE__) . "/../../../../lib/vendor/oauth2/lib/OAuth2.inc";
require_once __DIR__ . "/../../../../lib/vendor/oauth2/lib/OAuth2.inc";
/*
* This file is part of Phraseanet
*

View File

@@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
$new_include_path = dirname(__FILE__) . "/../../../../vendor/" . PATH_SEPARATOR . get_include_path();
$new_include_path = __DIR__ . "/../../../../vendor/" . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
require_once dirname(__FILE__) . "/../../../../vendor/Phlickr/Api.php";
require_once dirname(__FILE__) . "/../../../../vendor/Phlickr/Uploader.php";
require_once __DIR__ . "/../../../../vendor/Phlickr/Api.php";
require_once __DIR__ . "/../../../../vendor/Phlickr/Uploader.php";
/**
*

View File

@@ -88,7 +88,7 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_
$response = json_decode($response_json, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS);
if (!is_array($response) || !isset($response['refresh_token']) || !isset($response['access_token']))
throw new Bridge_Exception_ApiConnectorAccessTokenFailed('Unable to retrive tokens');
throw new Bridge_Exception_ApiConnectorAccessTokenFailed('Unable to retrieve tokens');
return array('refresh_token' => $response['refresh_token'], 'auth_token' => $response['access_token']);
}

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . "/../../../classes/DailymotionWithoutOauth2.php";
require_once __DIR__ . "/../../../classes/DailymotionWithoutOauth2.php";
use \Symfony\Component\HttpFoundation\Request;

View File

@@ -9,13 +9,13 @@
* file that was distributed with this source code.
*/
$new_include_path = dirname(__FILE__) . "/../../../vendor/" . PATH_SEPARATOR . get_include_path();
$new_include_path = __DIR__ . "/../../../vendor/" . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
use \Symfony\Component\HttpFoundation\Request;
require_once dirname(__FILE__) . "/../../../vendor/Phlickr/Api.php";
require_once dirname(__FILE__) . "/../../../vendor/Phlickr/Uploader.php";
require_once __DIR__ . "/../../../vendor/Phlickr/Api.php";
require_once __DIR__ . "/../../../vendor/Phlickr/Uploader.php";
/**
*

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
$new_include_path = dirname(__FILE__) . '/../../../vendor/gdata/' . PATH_SEPARATOR . get_include_path();
$new_include_path = __DIR__ . '/../../../vendor/gdata/' . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
require_once('Zend/Loader.php');
@@ -245,7 +245,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter
break;
default:
throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type);
throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object);
break;
}
}

View File

@@ -15,7 +15,7 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Bridge_Exception extends Exception
class Bridge_Exception extends \Exception
{
}

View File

@@ -15,7 +15,7 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Bridge_Exception_ApiConnectorNotConfigured extends Bridge_Exception
class Bridge_Exception_ApiConnectorNotConfigured extends \Bridge_Exception
{
}

View File

@@ -15,7 +15,7 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Bridge_Exception_ApiConnectorNotConnected extends Bridge_Exception
class Bridge_Exception_ApiConnectorNotConnected extends \Bridge_Exception
{
}

View File

@@ -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.
*/
/**
*
* @package Exception
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Exception_Basket_NotFound extends Exception_NotFound
{
}

View File

@@ -25,6 +25,10 @@ abstract class Feed_Abstract
*
*/
const FORMAT_ATOM = 'atom';
/**
*
*/
const FORMAT_COOLIRIS = 'cooliris';
/**
*

View File

@@ -57,6 +57,8 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
const CACHE_ENTRY_NUMBER = 'entrynumber';
const CACHE_USER_TOKEN = 'usr_token';
const MAX_ENTRIES = 20;
/**
*
@@ -561,7 +563,7 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
public function get_entries($offset_start, $how_many)
{
$offset_start = (int) $offset_start;
$how_many = $how_many > 20 ? 20 : (int) $how_many;
$how_many = $how_many > self::MAX_ENTRIES ? self::MAX_ENTRIES : (int) $how_many;
$sql = 'SELECT id
FROM feed_entries

View File

@@ -158,6 +158,16 @@ class Feed_Aggregate extends Feed_Abstract implements Feed_Interface
, 'application/atom+xml'
);
break;
case self::FORMAT_COOLIRIS:
return new Feed_Link(
sprintf('%sfeeds/cooliris/%s'
, $registry->get('GV_ServerName')
, ($page ? '?page=' . $page : '')
)
, sprintf('%s - %s', $this->get_title(), 'RSS')
, 'application/rss+xml'
);
break;
default:
case self::FORMAT_RSS:
return new Feed_Link(

View File

@@ -0,0 +1,459 @@
<?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 Feeds
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
{
/**
* RSS version
*/
const VERSION = '2.0';
/**
*
* @var Array
*/
protected $required_fields = array('title', 'subtitle', 'link');
/**
*
* @var string
*/
protected $language;
/**
*
* @var string
*/
protected $copyright;
/**
*
* @var string
*/
protected $managingEditor;
/**
*
* @var string
*/
protected $webMaster;
/**
*
* @var DateTime
*/
protected $lastBuildDate;
/**
*
* @var string
*/
protected $categories;
/**
*
* @var string
*/
protected $docs = 'http://blogs.law.harvard.edu/tech/rss';
/**
*
* @var int
*/
protected $ttl;
/**
*
* @var Feed_XML_RSS_Image
*/
protected $image;
/**
*
* @var string
*/
protected $skipHours = array();
/**
*
* @var string
*/
protected $skipDays = array();
/**
*
* @var string
*/
protected $mimetype = 'application/rss+xml';
/**
*
* @param string $language
* @return Feed_XML_RSS
*/
public function set_language($language)
{
$this->language = $language;
return $this;
}
/**
*
* @param string $language
* @return Feed_XML_RSS
*/
public function set_copyright($copyright)
{
$this->copyright = $copyright;
return $this;
}
/**
*
* @param string $managingEditor
* @return Feed_XML_RSS
*/
public function set_managingEditor($managingEditor)
{
$this->managingEditor = $managingEditor;
return $this;
}
/**
*
* @param string $webMaster
* @return Feed_XML_RSS
*/
public function set_webMaster($webMaster)
{
$this->webMaster = $webMaster;
return $this;
}
/**
*
* @param DateTime $lastBuildDate
* @return Feed_XML_RSS
*/
public function set_lastBuildDate(DateTime $lastBuildDate)
{
$this->lastBuildDate = $lastBuildDate;
return $this;
}
/**
*
* @param string $category
* @return Feed_XML_RSS
*/
public function set_category($category)
{
$this->categories[] = $category;
return $this;
}
/**
*
* @param string $docs
* @return Feed_XML_RSS
*/
public function set_docs($docs)
{
$this->docs = $docs;
return $this;
}
/**
*
* @param int $ttl
* @return Feed_XML_RSS
*/
public function set_ttl($ttl)
{
$this->ttl = $ttl;
return $this;
}
/**
*
* @param Feed_XML_RSS_Image $image
* @return Feed_XML_RSS
*/
public function set_image(Feed_XML_RSS_Image $image)
{
$this->image = $image;
return $this;
}
/**
*
* @param string $skipHours
* @return Feed_XML_RSS
*/
public function set_skipHour($hour)
{
$this->skipHours[] = (int) $hour;
return $this;
}
/**
*
* @param string $skipDays
* @return Feed_XML_RSS
*/
public function set_skipDays($day)
{
$this->skipDays[] = $day;
return $this;
}
/**
*
* @return string
*/
public function render()
{
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$doc->standalone = true;
$root = $this->addTag($doc, $doc, 'rss');
$root->setAttribute('version', self::VERSION);
$root->setAttribute('xmlns:media', 'http://search.yahoo.com/mrss/');
$root->setAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
$root->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$channel = $this->addTag($doc, $root, 'channel');
$this->addTag($doc, $channel, 'title', $this->title);
$this->addTag($doc, $channel, 'dc:title', $this->title);
$this->addTag($doc, $channel, 'description', $this->subtitle);
if ($this->link instanceof Feed_Link)
$this->addTag($doc, $channel, 'link', $this->link->get_href());
if ($this->language)
$this->addTag($doc, $channel, 'language', $this->language);
if ($this->copyright)
$this->addTag($doc, $channel, 'copyright', $this->copyright);
if ($this->managingEditor)
$this->addTag($doc, $channel, 'managingEditor', $this->managingEditor);
if ($this->webMaster)
$this->addTag($doc, $channel, 'webMaster', $this->webMaster);
if ($this->updated_on instanceof DateTime)
{
$updated_on = $this->updated_on->format(DATE_RFC2822);
$this->addTag($doc, $channel, 'pubDate', $updated_on);
}
if ($this->lastBuildDate instanceof DateTime)
{
$last_build = $this->lastBuildDate->format(DATE_RFC2822);
$this->addTag($doc, $channel, 'lastBuildDate', $last_build);
}
if (count($this->categories) > 0)
{
foreach ($this->categories as $category)
{
$this->addTag($doc, $channel, 'category', $category);
}
}
if ($this->generator)
$this->addTag($doc, $channel, 'generator', $this->generator);
if ($this->docs)
$this->addTag($doc, $channel, 'docs', $this->docs);
if ($this->ttl)
$this->addTag($doc, $channel, 'ttl', $this->ttl);
if ($this->image instanceof Feed_XML_RSS_Image)
{
$image = $this->addTag($doc, $channel, 'image');
$this->addTag($doc, $image, 'url', $this->image->get_url());
$this->addTag($doc, $image, 'title', $this->image->get_title());
$this->addTag($doc, $image, 'link', $this->image->get_link());
if ($this->image->get_width())
$this->addTag($doc, $image, 'width', $this->image->get_width());
if ($this->image->get_height())
$this->addTag($doc, $image, 'height', $this->image->get_height());
if ($this->image->get_description())
$this->addTag($doc, $image, 'description', $this->image->get_description());
}
if (count($this->skipHours))
{
$skipHours = $this->addTag($doc, $channel, 'skipHours');
foreach ($this->skipHours as $hour)
{
$this->addTag($doc, $skipHours, 'hour', $hour);
}
}
if (count($this->skipDays) > 0)
{
$skipDays = $this->addTag($doc, $channel, 'skipDays');
foreach ($this->skipDays as $day)
{
$this->addTag($doc, $skipDays, 'day', $day);
}
}
if ($this->link instanceof Feed_Link)
{
$self_link = $this->addTag($doc, $channel, 'atom:link');
$self_link->setAttribute('rel', 'self');
$self_link->setAttribute('href', $this->link->get_href());
}
$this->add_navigation($doc, $channel, true);
foreach ($this->items as $item)
{
$this->add_item($doc, $channel, $item);
}
return $doc->saveXML();
}
/**
*
* @param DOMDocument $document
* @param DOMNode $node
* @param Feed_Entry_Adapter $entry
* @return DOMElement
*/
protected function add_item(DOMDocument $document, DOMNode $node, Feed_Entry_Adapter $entry)
{
foreach ($entry->get_content() as $content)
{
$this->addContent($document, $node, $entry, $content);
}
return;
}
/**
*
* @param DOMDocument $document
* @param DOMNode $item
* @param Feed_Entry_Item $content
* @return Feed_XML_Interface
*/
protected function addContent(DOMDocument $document, DOMNode $node, Feed_Entry_Adapter $entry, Feed_Entry_Item $content)
{
$preview_sd = $content->get_record()->get_subdef('preview');
$preview_permalink = $preview_sd->get_permalink();
$thumbnail_sd = $content->get_record()->get_thumbnail();
$thumbnail_permalink = $thumbnail_sd->get_permalink();
$medium = strtolower($content->get_record()->get_type());
if (!in_array($medium, array('image', 'audio', 'video')))
return $this;
if (!$preview_permalink || !$thumbnail_permalink)
return $this;
//add item node to channel node
$item = $this->addTag($document, $node, 'item');
$title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title);
if ($title_field)
{
$str_title = $title_field->get_value(true, ' ');
}
else
{
$str_title = $content->get_record()->get_title();
}
//attach tile node to item node
$title = $this->addTag($document, $item, 'title', $str_title);
$desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description);
if ($desc_field)
{
$str_desc = $desc_field->get_value(true, ' ');
}
else
{
$str_desc = '';
}
//attach desc node to item node
$desc = $this->addTag($document, $item, 'description', $str_desc);
$duration = $content->get_record()->get_duration();
if ($preview_permalink)
{
$preview = $this->addTag($document, $item, 'media:content');
$preview->setAttribute('url', $preview_permalink->get_url());
$preview->setAttribute('fileSize', $preview_sd->get_size());
$preview->setAttribute('type', $preview_sd->get_mime());
$preview->setAttribute('medium', $medium);
$preview->setAttribute('expression', 'full');
$preview->setAttribute('isDefault', 'true');
if ($preview_sd->get_width())
$preview->setAttribute('width', $preview_sd->get_width());
if ($preview_sd->get_height())
$preview->setAttribute('height', $preview_sd->get_height());
if ($duration)
$preview->setAttribute('duration', $duration);
}
if ($thumbnail_permalink)
{
$thumbnail = $this->addTag($document, $item, 'media:thumbnail');
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
if ($thumbnail_sd->get_width())
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
if ($thumbnail_sd->get_height())
$thumbnail->setAttribute('height', $thumbnail_sd->get_height());
$thumbnail = $this->addTag($document, $item, 'media:content');
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
$thumbnail->setAttribute('medium', $medium);
$thumbnail->setAttribute('isDefault', 'false');
if ($thumbnail_sd->get_width())
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
if ($thumbnail_sd->get_height())
$thumbnail->setAttribute('height', $thumbnail_sd->get_height());
if ($duration)
$thumbnail->setAttribute('duration', $duration);
}
return $this;
}
}

View File

@@ -0,0 +1,3 @@
<?php
require_once __DIR__ . '/../vendor/PHPShortener/phpshortener.class.php';

View File

@@ -88,8 +88,7 @@ class Session_Handler
if (!$this->is_authenticated())
return;
$user = User_Adapter::getInstance($this->get_usr_id(), $this->appbox);
$user->ACL()->delete_injected_rights();
$this->storage()->reset();
$this->close_phrasea_session();
@@ -568,10 +567,12 @@ class Session_Handler
return $this;
}
$registry = $this->appbox->get_registry();
$Core = bootstrap::getCore();
$registry = $Core->getRegistry();
$date_two_day = new DateTime('+' . (int) $registry->get('GV_validation_reminder') . ' days');
$events_mngr = eventsmanager_broker::getInstance($this->appbox);
$events_mngr = eventsmanager_broker::getInstance($this->appbox, $Core);
$sql = 'SELECT v.id as validate_id, v.usr_id, v.ssel_id
, s.usr_id as owner, t.value

View File

@@ -179,7 +179,7 @@ class Setup_Upgrade
*/
public static function get_lock_file()
{
return dirname(__FILE__) . '/../../../tmp/upgrade.lock';
return __DIR__ . '/../../../tmp/upgrade.lock';
}
/**

View File

@@ -894,6 +894,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this->is_template;
}
public function get_template_owner()
{
return $this->template_owner;
}
public static function get_usr_id_from_email($email)
{
if(is_null($email))
@@ -1298,7 +1303,8 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected function load_notifications_preferences()
{
$evt_mngr = eventsmanager_broker::getInstance($this->appbox);
$Core = bootstrap::getCore();
$evt_mngr = eventsmanager_broker::getInstance($this->appbox, $Core);
$notifications = $evt_mngr->list_notifications_available($this->id);
foreach ($notifications as $notification_group => $nots)
@@ -1401,7 +1407,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$lngs = array();
$path = dirname(__FILE__) . "/../../../locale";
$path = __DIR__ . "/../../../locale";
if ($hdir = opendir($path))
{
while (false !== ($file = readdir($hdir)))
@@ -1423,95 +1429,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $lngs;
}
public static function detectLanguage(registryInterface $registry, $setLng = null)
{
$avLanguages = self::avLanguages();
$sel = $askLng = $askLocale = '';
if ($setLng !== null)
{
$askLng = substr($setLng, 0, 2);
$askLocale = $setLng;
}
elseif (Session_Handler::isset_cookie('locale'))
{
$askLng = substr(Session_Handler::get_cookie('locale'), 0, 2);
$askLocale = Session_Handler::get_cookie('locale');
}
elseif (strlen($registry->get('GV_default_lng')) > 2)
{
$askLng = substr($registry->get('GV_default_lng'), 0, 2);
$askLocale = $registry->get('GV_default_lng');
}
if ($askLng != '' && isset($avLanguages[$askLng]) && isset($avLanguages[$askLng][$askLocale]))
{
$avLanguages[$askLng][$askLocale]['selected'] = true;
$sel = $askLocale;
}
if ($sel === '' && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
$languages = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$found = false;
foreach ($languages as $language)
{
$language = explode(',', strtolower($language));
if (count($language) != 2)
continue;
foreach ($language as $lang)
{
if (strpos($lang, '-') == 2 && strlen($lang) == 5)
{
$l = explode('-', $lang);
$l[0] = strtolower($l[0]);
$l[1] = strtoupper($l[1]);
if ($sel != '')
{
$found = true;
break;
}
$lang = implode('_', $l);
if (isset($avLanguages[$l[0]]))
{
if (!isset($avLanguages[$l[0]][$lang]))
{
$lang = end(array_keys($avLanguages[$l[0]]));
}
$avLanguages[$l[0]][$lang]['selected'] = true;
$sel = $lang;
$found = true;
break;
}
}
}
if ($found)
break;
}
if (!$found && array_key_exists(substr($registry->get('GV_default_lng'), 0, 2), $avLanguages))
{
$avLanguages[substr($registry->get('GV_default_lng'), 0, 2)][$registry->get('GV_default_lng')]['selected'] = true;
$sel = $registry->get('GV_default_lng');
}
}
if ($sel == '')
{
$key = end(array_keys($avLanguages));
$lang = end(array_keys($avLanguages[$key]));
$avLanguages[$key][$lang]['selected'] = true;
$sel = $lang;
}
Session_Handler::set_locale($sel);
$sel = explode('_', $sel);
return $avLanguages;
}
public static function get_wrong_email_users(appbox $appbox)
{

View File

@@ -147,8 +147,6 @@ interface User_Interface
public static function avLanguages();
public static function detectLanguage(registryInterface $registry, $setLng = null);
public function setPrefs($prop, $value);
public function getPrefs($prop);

View File

@@ -88,6 +88,11 @@ class User_Query implements User_QueryInterface
* @var boolean
*/
protected $include_templates = false;
/**
*
* @var boolean
*/
protected $only_templates = false;
/**
*
* @var Array
@@ -123,10 +128,10 @@ class User_Query implements User_QueryInterface
const SORT_FIRSTNAME= 'usr_prenom';
const SORT_LASTNAME= 'usr_nom';
const SORT_COMPANY = 'societe';
const SORT_LOGIN = 'login';
const SORT_LOGIN = 'usr_login';
const SORT_EMAIL = 'usr_mail';
const SORT_ID = 'usr_id';
const SORT_CREATIONDATE = 'creationdate';
const SORT_CREATIONDATE = 'usr_creationdate';
const SORT_COUNTRY = 'pays';
const SORT_LASTMODEL = 'lastModel';
@@ -191,18 +196,22 @@ class User_Query implements User_QueryInterface
$sql .= ' AND usr_login NOT LIKE "(#deleted_%" ';
if ($this->include_invite)
if (!$this->include_invite)
{
$sql .= ' AND usr.invite=0 ';
}
if ($this->include_templates === false)
if ($this->only_templates === true)
{
$sql .= ' AND model_of = ' . $session->get_usr_id();
}
elseif ($this->include_templates === false)
{
$sql .= ' AND model_of=0';
}
else
{
$sql .= ' AND (model_of=0 OR model_of= ' . $session->get_usr_id() . ' ) ';
$sql .= ' AND (model_of=0 OR model_of = ' . $session->get_usr_id() . ' ) ';
}
$baslist = array();
@@ -355,6 +364,17 @@ class User_Query implements User_QueryInterface
return $this;
}
/**
*
* @param boolean $boolean
* @return User_Query
*/
public function only_templates($boolean)
{
$this->only_templates = !!$boolean;
return $this;
}
/**
*
@@ -390,6 +410,8 @@ class User_Query implements User_QueryInterface
case self::SORT_COMPANY:
case self::SORT_LOGIN:
case self::SORT_EMAIL:
$sorter[$k] = ' usr.`' . $sort . '` COLLATE utf8_unicode_ci ';
break;
case self::SORT_ID:
case self::SORT_CREATIONDATE:
case self::SORT_COUNTRY:
@@ -410,7 +432,7 @@ class User_Query implements User_QueryInterface
$sorter[$k] .= ' ASC ';
break;
case self::ORD_DESC:
$sorter[$k] .= ' ASC ';
$sorter[$k] .= ' DESC ';
break;
}
}

View File

@@ -74,7 +74,7 @@ class appbox extends base
$this->registry = $registry;
$this->session = Session_Handler::getInstance($this);
require dirname(__FILE__) . '/../../config/connexion.inc';
require __DIR__ . '/../../config/connexion.inc';
$this->host = $hostname;
$this->port = $port;
@@ -371,15 +371,17 @@ class appbox extends base
protected function post_upgrade(Setup_Upgrade &$upgrader)
{
$Core = bootstrap::getCore();
$upgrader->add_steps(1 + count($this->get_databoxes()));
$this->apply_patches($this->get_version(), GV_version, true, $upgrader);
$this->setVersion(GV_version);
$this->apply_patches($this->get_version(), $Core->getVersion()->getNumber(), true, $upgrader);
$this->setVersion($Core->getVersion()->getNumber());
$upgrader->add_steps_complete(1);
foreach ($this->get_databoxes() as $databox)
{
$databox->apply_patches($databox->get_version(), GV_version, true, $upgrader);
$databox->setVersion(GV_version);
$databox->apply_patches($databox->get_version(), $Core->getVersion()->getNumber(), true, $upgrader);
$databox->setVersion($Core->getVersion()->getNumber());
$upgrader->add_steps_complete(1);
}
@@ -407,7 +409,7 @@ class appbox extends base
{
$credentials['dbname'] = $dbname;
}
$connexion = dirname(__FILE__) . "/../../config/connexion.inc";
$connexion = __DIR__ . "/../../config/connexion.inc";
if (is_file($connexion))
unlink($connexion);
@@ -420,7 +422,7 @@ class appbox extends base
}
if (!file_put_contents($connexion, $connexionINI, FILE_APPEND) !== false)
throw new Exception(sprintf(_('Impossible d\'ecrire dans le dossier %s'), dirname(dirname(__FILE__)) . "/config/"));
throw new Exception(sprintf(_('Impossible d\'ecrire dans le dossier %s'), dirname(__DIR__) . "/config/"));
if (function_exists('chmod'))
chmod($connexion, 0700);
@@ -543,7 +545,7 @@ class appbox extends base
public static function list_databox_templates()
{
$files = array();
$dir = new DirectoryIterator(dirname(__FILE__) . '/../conf.d/data_templates/');
$dir = new DirectoryIterator(__DIR__ . '/../conf.d/data_templates/');
foreach ($dir as $fileinfo)
{
if ($fileinfo->isFile())

View File

@@ -257,9 +257,10 @@ abstract class base implements cache_cacheableInterface
public function upgradeavailable()
{
$Core = bootstrap::getCore();
if ($this->get_version())
return version_compare(GV_version, $this->get_version(), '>');
return version_compare($Core->getVersion()->getNumber(), $this->get_version(), '>');
else
return true;
@@ -267,7 +268,7 @@ abstract class base implements cache_cacheableInterface
protected function upgradeDb($apply_patches, Setup_Upgrade &$upgrader)
{
require_once dirname(__FILE__) . '/../version.inc';
require_once __DIR__ . '/../version.inc';
$recommends = array();
@@ -338,10 +339,12 @@ abstract class base implements cache_cacheableInterface
}
$current_version = $this->get_version();
$Core = bootstrap::getCore();
$upgrader->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname()));
if ($apply_patches)
{
$this->apply_patches($current_version, GV_version, false, $upgrader);
$this->apply_patches($current_version, $Core->getVersion()->getNumber(), false, $upgrader);
}
$upgrader->add_steps_complete(1);
@@ -390,7 +393,7 @@ abstract class base implements cache_cacheableInterface
return $this;
$structure = simplexml_load_file(dirname(__FILE__) . "/../../lib/conf.d/bases_structure.xml");
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
if (!$structure)
throw new Exception('Unable to load schema');
@@ -418,8 +421,8 @@ abstract class base implements cache_cacheableInterface
$this->createTable($table);
}
if (defined('GV_version'))
$this->setVersion(GV_version);
$Core = bootstrap::getCore();
$this->setVersion($Core->getVersion()->getNumber());
return $this;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,831 +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 Basket
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class basket_element_adapter implements cache_cacheableInterface
{
/**
*
* @var Array
*/
protected $choices;
/**
*
* @var boolean
*/
protected $is_validation_item = false;
/**
*
* @var int
*/
protected $validate_id;
/**
*
* @var int
*/
protected $my_agreement;
/**
*
* @var string
*/
protected $my_note;
/**
*
* @var int
*/
protected $avrAgree;
/**
*
* @var int
*/
protected $avrDisAgree;
/**
*
* @var int
*/
protected $sselcont_id;
/**
*
* @var int
*/
protected $parent_record_id;
/**
*
* @var int
*/
protected $ssel_id;
/**
*
* @var record_adapter
*/
protected $record;
protected $usr_id;
/**
*
* @var array
*/
protected static $_instance = array();
public function __construct($sselcont_id)
{
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$this->usr_id = $session->get_usr_id();
$this->sselcont_id = (int) $sselcont_id;
$this->load();
return $this;
}
protected function load()
{
try
{
$datas = $this->get_data_from_cache();
$this->ssel_id = $datas['ssel_id'];
$this->order = $datas['order'];
$this->record = new record_adapter($datas['sbas_id'], $datas['record_id'], $this->order);
$this->avrDisAgree = $datas['avrDisAgree'];
$this->avrAgree = $datas['avrAgree'];
$this->is_validation_item = $datas['is_validation_item'];
$this->my_agreement = $datas['my_agreement'];
$this->my_note = $datas['my_note'];
$this->validate_id = $datas['validate_id'];
$this->choices = $datas['choices'];
$this->avrAgree = $datas['avrAgree'];
$this->avrDisAgree = $datas['avrDisAgree'];
return $this;
}
catch (Exception $e)
{
}
$sql = 'SELECT s.usr_id as owner, v.id as validate_id, v.can_see_others,
c.base_id, c.record_id, c.ord, c.ssel_id, v.usr_id,
d.agreement, d.note, d.updated_on
FROM (sselcont c, ssel s)
LEFT JOIN (validate v, validate_datas d)
ON (d.sselcont_id = c.sselcont_id AND d.validate_id = v.id )
WHERE s.ssel_id = c.ssel_id
AND c.sselcont_id = :sselcont_id';
try
{
$conn = connection::getPDOConnection();
$stmt = $conn->prepare($sql);
$stmt->execute(array(':sselcont_id' => $this->sselcont_id));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
}
catch (Exception $e)
{
}
$first = true;
foreach ($rs as $row)
{
if ($row['validate_id'])
{
$this->is_validation_item = true;
if ($row['owner'] == $this->usr_id)
$see_others = true;
else
$see_others = ($row['can_see_others'] == '1');
if (!$see_others)
{
if ($row['usr_id'] != $this->usr_id)
continue;
}
}
if ($first)
{
$sbas_id = (int) phrasea::sbasFromBas($row['base_id']);
$record_id = (int) $row['record_id'];
$this->ssel_id = (int) $row['ssel_id'];
$this->order = $number = (int) $row['ord'];
$this->record = new record_adapter($sbas_id, $record_id, $number);
if ($this->is_validation_item)
{
$this->choices = array();
$this->avrAgree = 0;
$this->avrDisAgree = 0;
}
$first = false;
}
if ($this->is_validation_item)
{
if ($row['usr_id'] == $this->usr_id)
{
$this->my_agreement = (int) $row['agreement'];
$this->my_note = $row['note'];
$this->validate_id = (int) $row['validate_id'];
}
$this->choices[$row['usr_id']] = array(
'usr_id' => $row['usr_id'],
'usr_name' => User_Adapter::getInstance($row['usr_id'], appbox::get_instance())->get_display_name(),
'is_mine' => ($row['usr_id'] == $this->usr_id),
'agreement' => $row['agreement'],
'updated_on' => $row['updated_on'],
'note' => $row['note']
);
$this->avrAgree += $row["agreement"] > 0 ? 1 : 0;
$this->avrDisAgree += $row["agreement"] < 0 ? 1 : 0;
}
}
$datas = array(
'ssel_id' => $this->ssel_id
, 'sbas_id' => (int) $sbas_id
, 'record_id' => $record_id
, 'order' => $this->order
, 'is_validation_item' => $this->is_validation_item
, 'my_agreement' => $this->my_agreement
, 'my_note' => $this->my_note
, 'validate_id' => $this->validate_id
, 'choices' => $this->choices
, 'avrAgree' => $this->avrAgree
, 'avrDisAgree' => $this->avrDisAgree
);
$this->set_data_to_cache($datas);
return $this;
}
public function get_record()
{
return $this->record;
}
/**
*
* @return int
*/
public function get_order()
{
return $this->order;
}
/**
*
* @param int $number
* @return basket_element_adapter
*/
public function set_order($order)
{
$this->order = (int) $order;
return $this;
}
/**
* @return basket_element_adapter
*/
public static function getInstance($sselcont_id)
{
if (!isset(self::$_instance[$sselcont_id]))
{
self::$_instance[$sselcont_id] = new self($sselcont_id);
}
return array_key_exists($sselcont_id, self::$_instance) ? self::$_instance[$sselcont_id] : false;
}
/**
*
* @param basket_adapter $basket
* @param int $base_id
* @param int $record_id
* @param int $parent_record_id
* @param string $adjust_validation_datas
* @param boolean $fixing
* @return basket_element_adapter
*/
public static function create(basket_adapter $basket, $base_id, $record_id, $parent_record_id, $adjust_validation_datas, $fixing)
{
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$sbas_id = phrasea::sbasFromBas($base_id);
$record = new record_adapter($sbas_id, $record_id);
$ssel_id = $basket->get_ssel_id();
if (!$user->ACL()->has_right_on_base($base_id, 'canputinalbum'))
throw new Exception('You do not have rights' .
' to use this document in basket.');
$exists = false;
$sql = 'SELECT sselcont_id FROM sselcont
WHERE ssel_id = :ssel_id AND base_id = :base_id AND record_id = :record_id ';
$stmt = $appbox->get_connection()->prepare($sql);
$params = array(
':ssel_id' => $basket->get_ssel_id()
, ':base_id' => $base_id
, ':record_id' => $record_id
);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row)
{
return new self($row['sselcont_id']);
}
$connbas = connection::getPDOConnection($sbas_id);
if (!$sbas_id)
throw new Exception('Unknown database');
if ($parent_record_id && $fixing === false)
{
if (!$user->ACL()->has_right_on_base($base_id, 'canaddrecord'))
throw new Exception('You do not have the right');
if ($record->is_grouping())
throw new Exception('Can\'t add grouping to grouping');
$ord = 0;
$sql = "SELECT (max(ord)+1) as ord
FROM regroup WHERE rid_parent = :parent_record_id";
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':parent_record_id' => $parent_record_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row)
{
$ord = is_null($row["ord"]) ? 0 : $row["ord"];
}
else
{
$ord = 0;
}
$sql = 'INSERT INTO regroup (id, rid_parent, rid_child, dateadd, ord)
VALUES (null, :parent_record_id, :record_id, NOW(), :ord)';
$params = array(
':parent_record_id' => $parent_record_id
, ':record_id' => $record_id
, ':ord' => $ord
);
$stmt = $connbas->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :parent_record_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':parent_record_id' => $parent_record_id));
$stmt->closeCursor();
}
$sql = 'SELECT max(ord) as ord FROM sselcont WHERE ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $basket->get_ssel_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row)
{
$ord = (int) $row['ord'] + 1;
}
else
{
$ord = 0;
}
$sql = ' INSERT INTO sselcont
(sselcont_id, ssel_id, base_id, record_id, ord)
VALUES (null, :ssel_id, :base_id, :record_id, :ord) ';
$stmt = $appbox->get_connection()->prepare($sql);
$params = array(
':ssel_id' => $basket->get_ssel_id()
, ':base_id' => $base_id
, ':record_id' => $record_id
, ':ord' => $ord
);
$stmt->execute($params);
$stmt->closeCursor();
$sselcont_id = $appbox->get_connection()->lastInsertId();
$ret['error'] = false;
$ret['datas'][] = $sselcont_id;
$sql = 'UPDATE ssel SET updater=NOW() WHERE ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $basket->get_ssel_id()));
$stmt->closeCursor();
if ($adjust_validation_datas == 'myvalid')
{
$sql = 'INSERT INTO validate_datas
(SELECT distinct null as id, id as validate_id
, :sselcont_id as sselcont_id
, null as updated_on, 0 as agreement, "" as note
FROM validate
WHERE ssel_id = :ssel_id)';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':sselcont_id' => $sselcont_id, ':ssel_id' => $basket->get_ssel_id()));
$stmt->closeCursor();
$sql = 'SELECT usr_id FROM validate WHERE ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $basket->get_ssel_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
if ($session->get_usr_id() != $row['usr_id'])
{
$basket->set_unread($row['usr_id']);
}
}
}
if ($parent_record_id)
{
$sql = 'SELECT null as id, ssel_id, usr_id
FROM ssel
WHERE usr_id != :usr_id AND rid = :parent_record_id
AND sbas_id = :sbas_id AND temporaryType="1"';
$stmt = $appbox->get_connection()->prepare($sql);
$params = array(
':usr_id' => $session->get_usr_id()
, ':parent_record_id' => $parent_record_id
, ':sbas_id' => $sbas_id
);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
$sql = 'SELECT max(ord) as ord FROM sselcont WHERE ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $row['ssel_id']));
$row2 = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row)
{
$ord = (int) $row2['ord'] + 1;
}
else
{
$ord = 0;
}
$sqlUp = ' INSERT INTO sselcont
(sselcont_id, ssel_id, base_id, record_id,ord)
VALUES (null, :ssel_id, :base_id, :record_id, :ord) ';
$stmt = $appbox->get_connection()->prepare($sql);
$params = array(
':ssel_id' => $row['ssel_id']
, ':base_id' => $base_id
, ':record_id' => $record_id
, ':ord' => $ord
);
$stmt->execute($params);
$stmt->closeCursor();
$sql = 'UPDATE ssel SET updater=NOW() WHERE ssel_id = :ssel_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $row['ssel_id']));
$stmt->closeCursor();
try
{
$basket_to_clean = basket_adapter::getInstance($appbox, $row['ssel_id'], $user->get_id());
$basket_to_clean->set_unread($row['usr_id']);
}
catch (Exception $e)
{
}
}
}
$basket->delete_cache();
return new self($sselcont_id);
}
/**
*
* @param string $note
* @return boolean
*/
function set_note($note)
{
if (!$this->is_validation_item)
{
throw new Exception('Element ' . $this->sselcont_id . ' is not a validation item');
}
$note = strip_tags($note);
if (!$this->validate_id)
return false;
$appbox = appbox::get_instance();
$usr_id = $appbox->get_session()->get_usr_id();
$sql = 'UPDATE validate_datas SET note = :note
WHERE sselcont_id = :sselcont_id AND validate_id = :validate_id ';
$stmt = $appbox->get_connection()->prepare($sql);
$params = array(
':note' => $note
, ':sselcont_id' => $this->sselcont_id
, ':validate_id' => $this->validate_id
);
$stmt->execute($params);
$stmt->closeCursor();
$this->my_note = $note;
foreach ($this->choices as $key => $values)
{
if ($values['is_mine'])
{
$this->choices[$key]['note'] = $note;
break;
}
}
try
{
$basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id);
$basket->delete_cache();
}
catch (Exception $e)
{
}
return $this;
}
/**
*
* @return void
*/
function load_users_infos()
{
if (!$this->is_validation_item)
{
throw new Exception('Element is not a validation item');
return false;
}
foreach ($this->choices as $key => $value)
{
$this->choices[$key]['usr_display'] = User_Adapter::getInstance($value['usr_id'], appbox::get_instance())->get_display_name();
}
}
/**
*
* @return int
*/
function get_note_count()
{
if (!$this->is_validation_item)
{
throw new Exception('Element is not a validation item');
return false;
}
$n = 0;
foreach ($this->choices as $key => $value)
{
if (trim($value['note']) != '')
$n++;
}
return $n;
}
/**
*
* @param boolean $boolean
* @return string
*/
function set_agreement($boolean)
{
if (!$this->is_validation_item)
{
throw new Exception('not a validation item');
}
if (!$this->validate_id)
throw new Exception('not a validation item');
$appbox = appbox::get_instance();
$usr_id = $appbox->get_session()->get_usr_id();
$boolean = in_array($boolean, array('1', '-1')) ? $boolean : '0';
$sql = 'UPDATE validate_datas
SET agreement = :agreement
WHERE sselcont_id = :sselcont_id
AND validate_id = :validate_id';
$params = array(
':agreement' => $boolean
, ':sselcont_id' => $this->sselcont_id
, ':validate_id' => $this->validate_id
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->delete_data_from_cache();
$basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id);
$basket->delete_cache();
return $this;
}
/**
*
* @return int
*/
public function get_sselcont_id()
{
return $this->sselcont_id;
}
/**
*
* @return boolean
*/
public function is_validation_item()
{
return $this->is_validation_item;
}
/**
*
* @return int
*/
public function get_my_agreement()
{
return $this->my_agreement;
}
/**
*
* @return string
*/
public function get_my_note()
{
return $this->my_note;
}
/**
*
* @return Array
*/
public function get_choices()
{
return $this->choices;
}
/**
*
* @return int
*/
public function get_ssel_id()
{
return $this->ssel_id;
}
public static function is_in_validation_session(record_Interface $record, User_Interface $user)
{
$conn = connection::getPDOConnection();
$sql = 'SELECT v.id FROM sselcont c, validate v
WHERE c.base_id = :base_id AND c.record_id = :record_id
AND v.usr_id = :usr_id AND c.ssel_id = v.ssel_id';
$params = array(
':base_id' => $record->get_base_id()
, ':record_id' => $record->get_record_id()
, ':usr_id' => $user->get_id()
);
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return!!$row;
}
public static function has_been_received(record_Interface $record, User_Interface $user)
{
$conn = connection::getPDOConnection();
$sql = 'SELECT sselcont_id FROM sselcont c, ssel s
WHERE c.ssel_id=s.ssel_id AND c.record_id = :record_id
AND c.base_id = :base_id AND s.pushFrom > 0
AND s.usr_id = :usr_id';
$params = array(
':base_id' => $record->get_base_id()
, ':record_id' => $record->get_record_id()
, ':usr_id' => $user->get_id()
);
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return!!$row;
}
public function get_avrAgree()
{
return $this->avrAgree;
}
public function get_avrDisAgree()
{
return $this->avrDisAgree;
}
public function validate(user_adapter $from_user, User_Adapter $to_user, $validate_id, $can_hd)
{
$appbox = appbox::get_instance();
if ($can_hd)
$to_user->ACL()->grant_hd_on($this->get_record(), $from_user, 'validate');
else
$to_user->ACL()->grant_preview_on($this->get_record(), $from_user, 'validate');
$sql = 'REPLACE INTO validate_datas
(id, validate_id, sselcont_id, updated_on, agreement)
VALUES
(null, :validate_id, :sselcont_id, null, 0)';
$stmt = $appbox->get_connection()->prepare($sql);
$params = array(
':validate_id' => $validate_id
, ':sselcont_id' => $this->get_sselcont_id()
);
$stmt->execute($params);
$stmt->closeCursor();
if (!$this->is_validation_item)
{
$this->choices = array();
$this->avrAgree = 0;
$this->avrDisAgree = 0;
}
$this->is_validation_item = true;
$this->choices[$to_user->get_id()] = array(
'usr_id' => $to_user->get_id(),
'usr_name' => $to_user->get_display_name(),
'is_mine' => ($to_user->get_id() == $this->usr_id),
'agreement' => 0,
'updated_on' => new DateTime(),
'note' => ''
);
if ($to_user->get_id() == $this->usr_id)
{
$this->validate_id = (int) $validate_id;
}
$this->delete_data_from_cache();
return $this;
}
public function get_cache_key($option = null)
{
return 'basket_element_' . $this->usr_id . '_' . $this->sselcont_id . ($option ? '_' . $option : '');
;
}
public function get_data_from_cache($option = null)
{
$appbox = appbox::get_instance();
return $appbox->get_data_from_cache($this->get_cache_key($option));
}
public function set_data_to_cache($value, $option = null, $duration = 0)
{
$appbox = appbox::get_instance();
return $appbox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
}
public function delete_data_from_cache($option = null)
{
$appbox = appbox::get_instance();
return $appbox->delete_data_from_cache($this->get_cache_key($option));
}
}

View File

@@ -1,179 +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.
*/
class basketCollection
{
private $baskets = array();
/**
* @param string $order (optionnal name_asc or date_desc - defaut to name_asc)
* @param array $except (array of element not return. available values are regroup baskets and recept)
* @return basketCollectionObject
*/
function __construct(appbox $appbox, $usr_id, $order='name asc', $except = array())
{
$user = User_Adapter::getInstance($usr_id, $appbox);
$current_timestamp_obj = new DateTime();
$current_timestamp = $current_timestamp_obj->format('U');
$sql = 'SELECT ssel_id FROM ssel WHERE usr_id = :usr_id
AND temporaryType="0"';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $usr_id));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (count($rs) === 0)
{
$basket = basket_adapter::create($appbox, '', $user);
}
$baskets = array();
$baskets['baskets'] = $baskets['recept'] = $baskets['regroup'] = array();
$core = bootstrap::getCore();
$em = $core->getEntityManager();
$baskets['baskets'] = $em->getRepository('Entities\Basket')
->findBy(array('usr_id' => $usr_id, 'pusher_id' => null));
$baskets['regroup'] = $em->getRepository('Entities\StoryWZ')
->findBy(array('usr_id' => $usr_id));
// $sql = 'SELECT s.ssel_id, s.usr_id as owner, v.id as validate_id,
// s.temporaryType, s.pushFrom, v.expires_on FROM ssel s
// LEFT JOIN validate v
// ON (v.ssel_id = s.ssel_id AND v.usr_id = :usr_id_v)
// WHERE (s.usr_id = :usr_id_o OR v.id IS NOT NULL)';
//
// $stmt = $appbox->get_connection()->prepare($sql);
// $stmt->execute(array(':usr_id_o' => $usr_id, ':usr_id_v' => $usr_id));
// $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
// $stmt->closeCursor();
// foreach ($rs as $row)
// {
// $is_mine = ($row['owner'] == $usr_id);
//
// $expires_on_obj = new DateTime($row['expires_on']);
// $expires_on = $expires_on_obj->format('U');
//
// if ($row['validate_id'] != null && !$is_mine && $expires_on < $current_timestamp)
// continue;
//
// if ($row['temporaryType'] == '1')
// $baskets['regroup'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id);
// elseif (!is_null($row['validate_id']))
// {
//// $baskets['baskets'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id);
// }
// elseif ((int) $row['pushFrom'] > 0)
// $baskets['recept'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id);
//// else
//// $baskets['baskets'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id);
// }
$to_remove = array_intersect(array('recept', 'regroup', 'baskets'), $except);
foreach ($to_remove as $type)
$baskets[$type] = array();
if ($order == 'name asc')
{
uasort($baskets['baskets'], array('basketCollection', 'story_name_sort'));
uasort($baskets['regroup'], array('basketCollection', 'story_name_sort'));
uasort($baskets['recept'], array('basketCollection', 'story_name_sort'));
}
if ($order == 'date desc')
{
uasort($baskets['baskets'], array('basketCollection', 'story_date_sort'));
uasort($baskets['regroup'], array('basketCollection', 'story_date_sort'));
uasort($baskets['recept'], array('basketCollection', 'story_date_sort'));
}
$this->baskets = $baskets;
return $this;
}
public function get_baskets()
{
return $this->baskets;
}
function get_names()
{
$array_names = array();
foreach ($this->baskets as $type_name => $type)
{
foreach ($type as $basket)
{
$array_names[] = array('ssel_id' => $basket->get_ssel_id(), 'name' => $basket->get_name(), 'type' => $type_name);
}
}
return $array_names;
}
function story_date_sort($a, $b)
{
if (!$a->create || !$b->create)
return 0;
$comp = strcasecmp($a->create, $b->create);
if ($comp == 0)
return 0;
return $comp < 0 ? -1 : 1;
}
function story_name_sort($a, $b)
{
if (!$a->getName() || !$b->getName())
{
return 0;
}
$comp = strcasecmp($a->getName(), $b->getName());
if ($comp == 0)
return 0;
return $comp < 0 ? -1 : 1;
}
public static function get_updated_baskets()
{
$appbox = appbox::get_instance();
$conn = $appbox->get_connection();
$session = $appbox->get_session();
$sql = 'SELECT ssel_id FROM sselnew WHERE usr_id = :usr_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':usr_id' => $session->get_usr_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$baskets = array();
foreach ($rs as $row)
{
$baskets[] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id());
}
return $baskets;
}
}

View File

@@ -1,5 +1,5 @@
<?php
require_once dirname(__FILE__) . '/../../../../vendor/moov/relocator.class.php';
require_once __DIR__ . '/../../../../vendor/moov/relocator.class.php';
/*
* This file is part of Phraseanet
*

View File

@@ -32,14 +32,14 @@ class bootstrap
*
* @return Alchemy\Phrasea\Core
*/
public static function execute()
public static function execute($env = 'main')
{
if(static::$core)
{
return static::$core;
}
static::$core = new Alchemy\Phrasea\Core();
static::$core = new Alchemy\Phrasea\Core($env);
return static::$core;
}

View File

@@ -206,6 +206,9 @@ class caption_field implements cache_cacheableInterface
*/
protected static function serialize_value(Array $value, $separator)
{
if(strlen($separator) > 1)
$separator = $separator[0];
if (trim($separator) === '')
$separator = ' ';
else
@@ -346,9 +349,9 @@ class caption_field implements cache_cacheableInterface
if ($this->databox_field->is_multi() === true)
{
if ($as_string === true && $custom_separator === false)
{
return $this->value;
}
$separator = $this->databox_field->get_separator();
$array_values = self::get_multi_values($this->value, $separator);

View File

@@ -59,8 +59,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
protected function retrieve_fields()
{
if(is_array($this->fields))
if (is_array($this->fields))
return $this->fields;
$fields = array();
@@ -97,7 +96,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
}
catch (Exception $e)
{
}
}
$this->fields = $rec_fields;
@@ -134,7 +133,6 @@ class caption_record implements caption_interface, cache_cacheableInterface
{
$fields = $this->retrieve_fields();
if (isset($this->dces_elements[$label]))
return $fields[$this->dces_elements[$label]];
return null;
}
@@ -172,7 +170,10 @@ class caption_record implements caption_interface, cache_cacheableInterface
, $field->highlight_thesaurus()
);
$fields[$field->get_name()] = $value;
$fields[$field->get_name()] = array(
'value' => $value
, 'separator' => $field->get_databox_field()->get_separator()
);
}
if ($searchEngine instanceof searchEngine_adapter)
@@ -185,7 +186,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
foreach ($fields as $key => $value)
{
$fields[$key] = $ret[$n];
$fields[$key]['value'] = $ret[$n];
$n++;
}
}

View File

@@ -134,9 +134,9 @@ class connection
}
else
{
if (!is_file(dirname(__FILE__) . '/../../config/connexion.inc'))
if (!is_file(__DIR__ . '/../../config/connexion.inc'))
throw new Exception('Unable to load config file');
require (dirname(__FILE__) . '/../../config/connexion.inc');
require (__DIR__ . '/../../config/connexion.inc');
}
if (isset($connection_params[$name]))
{

View File

@@ -88,7 +88,7 @@ class connection_pdo extends connection_abstract implements connection_interface
*/
protected function log($message)
{
file_put_contents(dirname(__FILE__) . '/../../../logs/sql_log.log', $message . "\n", FILE_APPEND);
file_put_contents(__DIR__ . '/../../../logs/sql_log.log', $message . "\n", FILE_APPEND);
return $this;
}

View File

@@ -142,7 +142,7 @@ class databox extends base
}
catch (Exception $e)
{
}
}
@@ -157,7 +157,7 @@ class databox extends base
}
catch (Exception $e)
{
}
$conn = connection::getPDOConnection();
@@ -277,6 +277,7 @@ class databox extends base
SUM(1) AS n, SUM(size) AS siz FROM (record, subdef)
LEFT JOIN coll ON record.coll_id=coll.coll_id
WHERE record.record_id = subdef.record_id
GROUP BY record.coll_id, name
UNION
SELECT coll.coll_id, 0, asciiname, '_' AS name, 0 AS n, 0 AS siz
FROM coll LEFT JOIN record ON record.coll_id=coll.coll_id
@@ -450,7 +451,6 @@ class databox extends base
$stmt->closeCursor();
if ($row)
return self::get_instance((int) $row['sbas_id']);
try
@@ -463,7 +463,7 @@ class databox extends base
}
catch (Exception $e)
{
}
$sql = 'USE `' . $dbname . '`';
@@ -575,7 +575,6 @@ class databox extends base
public function get_meta_structure()
{
if ($this->meta_struct)
return $this->meta_struct;
try
@@ -698,7 +697,6 @@ class databox extends base
}
}
if ($n > $limit)
return true;
return false;
@@ -725,7 +723,7 @@ class databox extends base
public static function get_available_metadatas()
{
$available_fields = array();
$dir = dirname(__FILE__) . '/metadata/description/';
$dir = __DIR__ . '/metadata/description/';
$registry = registry::get_instance();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
{
@@ -960,15 +958,24 @@ class databox extends base
$this->saveStructure($dom_struct);
$type = isset($field['type']) ? $field['type'] : 'string';
$type = in_array($type, array(databox_field::TYPE_DATE, databox_field::TYPE_NUMBER, databox_field::TYPE_TEXT)) ? $type : databox_field::TYPE_TEXT;
$type = in_array($type
, array(
databox_field::TYPE_DATE
, databox_field::TYPE_NUMBER
, databox_field::TYPE_STRING
, databox_field::TYPE_TEXT
)
) ? $type : databox_field::TYPE_STRING;
$meta_struct_field = databox_field::create($this, $fname);
$meta_struct_field
->set_readonly(isset($field['readonly']) ? $field['readonly'] : 0)
->set_indexable(isset($field['index']) ? $field['index'] : '1')
->set_separator(isset($field['separator']) ? $field['separator'] : '')
->set_required((isset($field['required']) && $field['required'] == 1))
->set_type($type)
->set_tbranch(isset($field['tbranch']) ? $field['tbranch'] : '')
->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : '0')
->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
->set_multi(isset($field['multi']) ? $field['multi'] : 0)
->set_report(isset($field['report']) ? $field['report'] : '1')
->save();
@@ -979,7 +986,7 @@ class databox extends base
}
catch (Exception $e)
{
}
if (isset($field['regname']))
@@ -1213,7 +1220,6 @@ class databox extends base
public function get_structure()
{
if ($this->structure)
return $this->structure;
$this->structure = $this->retrieve_structure();
@@ -1228,7 +1234,7 @@ class databox extends base
}
catch (Exception $e)
{
}
$structure = null;
@@ -1254,7 +1260,6 @@ class databox extends base
public function get_cterms()
{
if ($this->cterms)
return $this->cterms;
$sql = "SELECT value FROM pref WHERE prop='cterms'";
@@ -1421,7 +1426,6 @@ class databox extends base
public function get_cgus()
{
if ($this->cgus)
return $this->cgus;
$this->load_cgus();
@@ -1439,7 +1443,7 @@ class databox extends base
}
catch (Exception $e)
{
}
$sql = 'SELECT value, locale, updated_on FROM pref WHERE prop ="ToU"';

View File

@@ -124,6 +124,7 @@ class databox_field implements cache_cacheableInterface
const TYPE_TEXT = "text";
const TYPE_DATE = "date";
const TYPE_STRING = "string";
const TYPE_NUMBER = "number";
/**
@@ -176,7 +177,7 @@ class databox_field implements cache_cacheableInterface
$this->required = !!$row['required'];
$this->multi = !!$row['multi'];
$this->report = !!$row['report'];
$this->type = $row['type'];
$this->type = $row['type'] ?: self::TYPE_STRING;
$this->tbranch = $row['tbranch'];
if ($row['dces_element'])
{
@@ -551,6 +552,9 @@ class databox_field implements cache_cacheableInterface
*/
public function set_separator($separator)
{
if (strpos($separator, ';') === false)
$separator .= ';';
$this->separator = $separator;
return $this;

View File

@@ -17,13 +17,16 @@
*/
function deleteRecord($lst, $del_children)
{
$Core = bootstrap::getCore();
$em = $Core->getEntityManager();
$BE_repository = $em->getRepository('\Entities\BasketElement');
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$registry = $appbox->get_registry();
$registry = $Core->getRegistry();
$usr_id = $session->get_usr_id();
$ACL = User_Adapter::getInstance($usr_id, $appbox)->ACL();
$user = $Core->getAuthenticatedUser();
$ACL = $user->ACL();
$lst = explode(";", $lst);
@@ -103,84 +106,14 @@ function deleteRecord($lst, $del_children)
}
}
$sql = array();
$params = array();
$n = 0;
foreach ($ret as $key=>$basrec)
$basket_elements = $BE_repository->findElementsByRecord($record);
foreach($basket_elements as $basket_element)
{
$br = explode('_', $basrec);
$sql[] = '(base_id = :base_id' . $n . ' AND record_id = :record_id' . $n . ')';
$params[':base_id' . $n] = $br[2];
$params[':record_id' . $n] = $br[1];
$sql_ssel = 'SELECT ssel_id, usr_id FROM ssel
WHERE sbas_id = :sbas_id AND rid = :record_id';
$stmt = $conn->prepare($sql_ssel);
$stmt->execute(array(':sbas_id' => $br[0], ':record_id' => $br[1]));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
try
{
$basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $row['usr_id']);
$basket->delete_cache();
unset($basket);
}
catch (Exception $e)
{
}
}
$sql_ssel = 'DELETE FROM ssel WHERE sbas_id = :sbas_id AND rid = :record_id';
$stmt = $conn->prepare($sql_ssel);
$stmt->execute(array(':sbas_id' => $br[0], ':record_id' => $br[1]));
$stmt->closeCursor();
unset($br[2]);
$ret[$key] = implode('_', $br);
$n++;
$em->remove($basket_element);
}
if (count($sql) > 0)
{
$sql_res = 'SELECT DISTINCT ssel.usr_id, ssel.ssel_id FROM sselcont ,ssel
WHERE (' . implode(' OR ', $sql) . ')
AND sselcont.ssel_id = ssel.ssel_id AND ssel.usr_id = :usr_id';
$params[':usr_id'] = $usr_id;
$stmt = $conn->prepare($sql_res);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
try
{
$basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id);
$basket->delete_cache();
}
catch (Exception $e)
{
}
}
$sql = 'DELETE FROM sselcont WHERE (' . implode(' OR ', $sql) . ')
AND ssel_id IN (SELECT ssel_id FROM ssel WHERE usr_id = :usr_id)';
$stmt = $conn->prepare($sql_res);
$stmt->execute($params);
$stmt->closeCursor();
}
$em->flush();
return p4string::jsonencode($ret);
}

View File

@@ -1486,6 +1486,7 @@ function getUsrInfos($usr, $arrayUsrs)
function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse)
{
$Core = bootstrap::getCore();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$registry = $appbox->get_registry();
@@ -1507,6 +1508,8 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse)
$reading_confirm_to = $me->get_email();
}
$em = $Core->getEntityManager();
foreach ($users as $oneuser => $rights)
{
$new_basket = null;
@@ -1516,20 +1519,40 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse)
$user = User_Adapter::getInstance($oneuser, $appbox);
$pusher = User_Adapter::getInstance($usr, $appbox);
$new_basket = basket_adapter::create($appbox, $newBask, $user, '', $pusher);
$new_basket->set_unread();
$new_basket = new \Entities\Basket();
$new_basket->setName($newBask);
$new_basket->setIsRead(false);
$new_basket->setPusher($pusher);
$new_basket->setOwner($user);
$em->persist($new_basket);
$nbchu++;
$new_basket->push_list($parmLST, false);
foreach($parmLST as $basrec)
{
$basrec = explode('_', $basrec);
$record = new record_adapter($basrec[0], $basrec[1]);
$BasketElement = new Entities\BasketElement();
$BasketElement->setRecord($record);
$BasketElement->setBasket($new_basket);
$em->persist($BasketElement);
$new_basket->addBasketElement($BasketElement);
}
$em->flush();
$finalUsers[] = $user->get_id();
$canSendHD = sendHdOk($usr, $parmLST);
foreach ($new_basket->get_elements() as $element)
foreach ($new_basket->getElements() as $element)
{
$record = $element->get_record();
$record = $element->getRecord();
if ($rights['canHD'] && in_array($record->get_base_id(), $canSendHD))
$user->ACL()->grant_hd_on($record, $me, 'push');
else
@@ -1541,7 +1564,7 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse)
$from = trim($me->get_email()) != "" ? $me->get_email() : false;
$url = $registry->get('GV_ServerName') . 'lightbox/index.php?LOG=' . random::getUrlToken('view', $user->get_id(), null, $new_basket->get_ssel_id());
$url = $registry->get('GV_ServerName') . 'lightbox/index.php?LOG=' . random::getUrlToken('view', $user->get_id(), null, $new_basket->getId());
if ($me->get_id() == $user->get_id())
$my_link = $url;
@@ -1557,11 +1580,11 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse)
, 'url' => $url
, 'accuse' => $reading_confirm_to
, 'message' => $mail_content
, 'ssel_id' => $new_basket->get_ssel_id()
, 'ssel_id' => $new_basket->getId()
);
$evt_mngr = eventsmanager_broker::getInstance($appbox);
$evt_mngr = eventsmanager_broker::getInstance($appbox, $Core);
$evt_mngr->trigger('__PUSH_DATAS__', $params);
}
catch (Exception $e)
@@ -1575,6 +1598,7 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse)
function pushValidation($usr, $ssel_id, $listUsrs, $time, $mail_content, $accuse)
{
$Core = bootstrap::getCore();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$registry = $appbox->get_registry();
@@ -1605,10 +1629,16 @@ function pushValidation($usr, $ssel_id, $listUsrs, $time, $mail_content, $accuse
$expires = null;
}
$em = $Core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($ssel_id, $Core->getAuthenticatedUser());
$basket = basket_adapter::getInstance($appbox, $ssel_id, $session->get_usr_id());
$basket->set_unread();
$basket->setIsRead(false);
$em->merge($basket);
$em->flush();
foreach ($listUsrs as $oneuser => $rights)
{
@@ -1637,7 +1667,7 @@ function pushValidation($usr, $ssel_id, $listUsrs, $time, $mail_content, $accuse
, 'accuse' => $reading_confirm_to
);
$evt_mngr = eventsmanager_broker::getInstance($appbox);
$evt_mngr = eventsmanager_broker::getInstance($appbox, $Core);
$evt_mngr->trigger('__PUSH_VALIDATION__', $params);
if ($me->get_id() == $user->get_id())

View File

@@ -12,10 +12,16 @@ class eventsmanager_broker
* @var appbox
*/
protected $appbox;
/**
*
* @var \Alchemy\Phrasea\Core
*/
protected $core;
private function __construct(appbox &$appbox)
private function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core)
{
$this->appbox = $appbox;
$this->core = $core;
return $this;
}
@@ -23,11 +29,11 @@ class eventsmanager_broker
/**
* @return eventsmanager
*/
public static function getInstance(appbox &$appbox)
public static function getInstance(appbox &$appbox, \Alchemy\Phrasea\Core $core)
{
if (!self::$_instance)
{
self::$_instance = new self($appbox);
self::$_instance = new self($appbox, $core);
}
return self::$_instance;
@@ -50,7 +56,7 @@ class eventsmanager_broker
{
continue;
}
$this->pool_classes[$classname] = new $classname($this->appbox, $this->appbox->get_registry(), $this);
$this->pool_classes[$classname] = new $classname($this->appbox, $this->core, $this);
foreach ($this->pool_classes[$classname]->get_events() as $event)
$this->bind($event, $classname);
@@ -67,17 +73,17 @@ class eventsmanager_broker
{
$iterators_pool = array();
$root = dirname(__FILE__) . '/../../';
$root = __DIR__ . '/../../';
if ($type == 'event')
{
$iterators_pool['event'][] = new DirectoryIterator(dirname(__FILE__) . '/event/');
if (file_exists(dirname(__FILE__) . '/event/'))
$iterators_pool['event'][] = new DirectoryIterator(dirname(__FILE__) . '/event/');
$iterators_pool['event'][] = new DirectoryIterator(__DIR__ . '/event/');
if (file_exists(__DIR__ . '/event/'))
$iterators_pool['event'][] = new DirectoryIterator(__DIR__ . '/event/');
}
if ($type == 'notify')
{
$iterators_pool['notify'][] = new DirectoryIterator(dirname(__FILE__) . '/notify/');
$iterators_pool['notify'][] = new DirectoryIterator(__DIR__ . '/notify/');
}
$ret = array();
@@ -100,7 +106,7 @@ class eventsmanager_broker
{
continue;
}
$obj = new $classname($this->appbox, $this->appbox->get_registry(), $this);
$obj = new $classname($this->appbox, $this->core, $this);
$ret[$classname] = $obj->get_name();
}

View File

@@ -15,6 +15,11 @@ abstract class eventsmanager_eventAbstract
* @var registryInterface
*/
protected $registry;
/**
*
* @var \Alchemy\Phrasea\Core
*/
protected $core;
/**
*
* @var eventsmanager
@@ -22,10 +27,11 @@ abstract class eventsmanager_eventAbstract
protected $broker;
public function __construct(appbox &$appbox, registryInterface $registry, eventsmanager_broker &$broker)
public function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->appbox = $appbox;
$this->registry = $registry;
$this->registry = $core->getRegistry();
$this->core = $core;
$this->broker = $broker;
return $this;

View File

@@ -28,10 +28,10 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
*
* @return notify_orderdeliver
*/
function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Commande');
parent::__construct($appbox, $registry, $broker);
parent::__construct($appbox, $core, $broker);
return $this;
}
@@ -147,7 +147,10 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
try
{
$basket = basket_adapter::getInstance($this->appbox, $ssel_id, $this->appbox->get_session()->get_usr_id());
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser());
}
catch (Exception $e)
{
@@ -159,7 +162,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
$sender, $n,
'<a href="/lightbox/compare/'
. (string) $sx->ssel_id . '/" target="_blank">'
. $basket->get_name() . '</a>'
. $basket->getName() . '</a>'
)
, 'class' => ''
);
@@ -196,7 +199,10 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
{
try
{
$basket = basket_adapter::getInstance($this->appbox, $ssel_id, $this->appbox->get_session()->get_usr_id());
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser());
}
catch (Exception $e)
{
@@ -204,7 +210,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
}
$subject = sprintf(
_('push::mail:: Reception de votre commande %s'),
$basket->get_name()
$basket->getName()
);
$body = "<div>"

View File

@@ -24,10 +24,10 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
*/
public $events = array('__ORDER_NOT_DELIVERED__');
function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Commande');
parent::__construct($appbox, $registry, $broker);
parent::__construct($appbox, $core, $broker);
return $this;
}

View File

@@ -28,10 +28,10 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
*
* @return notify_validate
*/
function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Validation');
parent::__construct($appbox, $registry, $broker);
parent::__construct($appbox, $core, $broker);
return $this;
}
@@ -140,9 +140,12 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
try
{
$basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id());
$basket_name = (trim($basket->get_name()) != '' ?
$basket->get_name() : _('Une selection'));
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser());
$basket_name = trim($basket->getName()) ?: _('Une selection');
}
catch (Exception $e)
{

View File

@@ -28,10 +28,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
*
* @return notify_validationdone
*/
function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Validation');
parent::__construct($appbox, $registry, $broker);
parent::__construct($appbox, $core, $broker);
return $this;
}
@@ -143,7 +143,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
try
{
$basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id());
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser());
}
catch (Exception $e)
{
@@ -156,7 +159,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$sender,
'<a href="/lightbox/validate/'
. (string) $sx->ssel_id . '/" target="_blank">'
. $basket->get_name() . '</a>'
. $basket->getName() . '</a>'
)
, 'class' => ''
);
@@ -193,7 +196,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
{
try
{
$basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id());
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser());
}
catch (Exception $e)
{
@@ -203,7 +209,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$subject = sprintf(
_('push::mail:: Rapport de validation de %1$s pour %2$s'),
$to['name'],
$basket->get_name()
$basket->getName()
);
$body = "<div>" . sprintf(

View File

@@ -28,10 +28,10 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
*
* @return notify_validationreminder
*/
function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Validation');
parent::__construct($appbox, $registry, $broker);
parent::__construct($appbox, $core, $broker);
return $this;
}
@@ -156,9 +156,12 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
try
{
$basket = basket_adapter::getInstance($this->appbox, $ssel_id, $this->appbox->get_session()->get_usr_id());
$basket_name = (trim($basket->get_name()) != '' ?
$basket->get_name() : _('Une selection'));
$em = $this->core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser());
$basket_name = trim($basket->getName()) ? : _('Une selection');
}
catch (Exception $e)
{

View File

@@ -192,6 +192,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->path = $registry->get('GV_RootPath') . 'www/skins/icons/';
$this->file = 'deleted.png';
$this->is_physically_present = false;
$this->is_substituted = true;
}
if (!$row || !file_exists($this->path . $this->file))
{
@@ -204,6 +205,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->path = $registry->get('GV_RootPath')
. 'www/skins/icons/substitution/';
$this->file = 'regroup_thumb.png';
$this->is_substituted = true;
}
else
{
@@ -217,6 +219,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->path = $registry->get('GV_RootPath')
. 'www/skins/icons/substitution/';
$this->file = str_replace('+', '%20', $mime) . '.png';
$this->is_substituted = true;
}
$this->is_physically_present = false;
if (!file_exists($this->path . $this->file))
@@ -225,6 +228,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->path = $registry->get('GV_RootPath')
. 'www/skins/icons/';
$this->file = 'substitution.png';
$this->is_substituted = true;
}
}

View File

@@ -37,7 +37,7 @@ class module_console_aboutAuthors extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../AUTHORS'));
$output->writeln(file_get_contents(__DIR__ . '/../../../../AUTHORS'));
return;
}

View File

@@ -37,7 +37,7 @@ class module_console_aboutLicense extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../LICENSE'));
$output->writeln(file_get_contents(__DIR__ . '/../../../../LICENSE'));
return;
}

View File

@@ -45,7 +45,7 @@ class module_console_schedulerStart extends Command
throw new RuntimeException('Phraseanet is not set up');
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$scheduler = new task_Scheduler();
$scheduler->run($output, true);

View File

@@ -40,7 +40,7 @@ class module_console_schedulerState extends Command
throw new RuntimeException('Phraseanet is not set up');
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$appbox = appbox::get_instance();
$task_manager = new task_manager($appbox);

View File

@@ -40,7 +40,7 @@ class module_console_schedulerStop extends Command
throw new RuntimeException('Phraseanet is not set up');
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$appbox = appbox::get_instance();
$task_manager = new task_manager($appbox);

View File

@@ -31,7 +31,7 @@ class module_console_systemBackupDB extends Command
$dir = sprintf(
'%s/config/'
, dirname(dirname(dirname(dirname(dirname(__FILE__)))))
, dirname(dirname(dirname(dirname(__DIR__))))
);
$this->setDescription('Backup Phraseanet Databases');
@@ -48,7 +48,7 @@ class module_console_systemBackupDB extends Command
throw new RuntimeException('Phraseanet is not set up');
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$output->write('Phraseanet is going to be backup...', true);

View File

@@ -44,8 +44,8 @@ class module_console_systemClearCache extends Command
->exclude('.git')
->exclude('.svn')
->in(array(
dirname(__FILE__) . '/../../../../tmp/cache_minify/'
, dirname(__FILE__) . '/../../../../tmp/cache_twig/'
__DIR__ . '/../../../../tmp/cache_minify/'
, __DIR__ . '/../../../../tmp/cache_twig/'
))
;
$count = 1;
@@ -59,8 +59,8 @@ class module_console_systemClearCache extends Command
$finder
->directories()
->in(array(
dirname(__FILE__) . '/../../../../tmp/cache_minify'
, dirname(__FILE__) . '/../../../../tmp/cache_twig'
__DIR__ . '/../../../../tmp/cache_minify'
, __DIR__ . '/../../../../tmp/cache_twig'
))
->exclude('.git')
->exclude('.svn')

View File

@@ -36,16 +36,16 @@ class module_console_systemTemplateGenerator extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
require_once dirname(__FILE__) . '/../../../../lib/vendor/Twig/lib/Twig/Autoloader.php';
require_once dirname(__FILE__) . '/../../../../lib/vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php';
require_once __DIR__ . '/../../../../lib/vendor/Twig/lib/Twig/Autoloader.php';
require_once __DIR__ . '/../../../../lib/vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php';
Twig_Autoloader::register();
Twig_Extensions_Autoloader::register();
$tplDir = dirname(__FILE__) . '/../../../../templates/';
$tmpDir = dirname(__FILE__) . '/../../../../tmp/cache_twig/';
$tplDir = __DIR__ . '/../../../../templates/';
$tmpDir = __DIR__ . '/../../../../tmp/cache_twig/';
$loader = new Twig_Loader_Filesystem($tplDir);
$twig = new Twig_Environment($loader, array(
@@ -81,6 +81,7 @@ class module_console_systemTemplateGenerator extends Command
$twig->addFilter('formatdate', new Twig_Filter_Function('phraseadate::getDate'));
$twig->addFilter('getPrettyDate', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('prettyDate', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('prettyString', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('formatoctet', new Twig_Filter_Function('p4string::format_octet'));
$twig->addFilter('getDate', new Twig_Filter_Function('phraseadate::getDate'));
$twig->addFilter('geoname_name_from_id', new Twig_Filter_Function('geonames::name_from_id'));

View File

@@ -39,9 +39,9 @@ class module_console_systemUpgrade extends Command
if (!setup::is_installed())
{
if (file_exists(dirname(__FILE__) . "/../../../../config/connexion.inc")
&& !file_exists(dirname(__FILE__) . "/../../../../config/config.inc")
&& file_exists(dirname(__FILE__) . "/../../../../config/_GV.php"))
if (file_exists(__DIR__ . "/../../../../config/connexion.inc")
&& !file_exists(__DIR__ . "/../../../../config/config.inc")
&& file_exists(__DIR__ . "/../../../../config/_GV.php"))
{
$output->writeln('This version of Phraseanet requires a config/config.inc');
@@ -76,7 +76,7 @@ class module_console_systemUpgrade extends Command
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$output->write('Phraseanet is going to be upgraded', true);
$dialog = $this->getHelperSet()->get('dialog');

View File

@@ -42,7 +42,7 @@ class module_console_tasklist extends Command
throw new RuntimeException('Phraseanet is not set up');
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$appbox = appbox::get_instance();
$task_manager = new task_manager($appbox);

View File

@@ -50,7 +50,7 @@ class module_console_taskrun extends Command
throw new RuntimeException('Phraseanet is not set up');
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$task_id = (int) $input->getArgument('task_id');

View File

@@ -54,9 +54,9 @@ class patch_320aa implements patchInterface
function apply(base &$appbox)
{
if(is_file(dirname(__FILE__) . '/../../../config/_GV.php'))
require dirname(__FILE__) . '/../../../config/_GV.php';
require dirname(__FILE__) . '/../../../lib/conf.d/_GV_template.inc';
if(is_file(__DIR__ . '/../../../config/_GV.php'))
require __DIR__ . '/../../../config/_GV.php';
require __DIR__ . '/../../../lib/conf.d/_GV_template.inc';
define('GV_STATIC_URL', '');
define('GV_sphinx', false);

View File

@@ -105,7 +105,7 @@ class phrasea
public static function start()
{
require (dirname(__FILE__) . '/../../config/connexion.inc');
require (__DIR__ . '/../../config/connexion.inc');
if (!extension_loaded('phrasea2'))
printf("Missing Extension php-phrasea");
@@ -269,12 +269,6 @@ class phrasea
return $user->ACL()->get_granted_base() > 0;
}
public static function load_events()
{
$events = eventsmanager_broker::getInstance(appbox::get_instance());
$events->start();
}
public static function use_i18n($locale, $textdomain = 'phraseanet')
{
$codeset = "UTF-8";
@@ -283,7 +277,7 @@ class phrasea
putenv('LANGUAGE=' . $locale . '.' . $codeset);
bind_textdomain_codeset($textdomain, 'UTF-8');
bindtextdomain($textdomain, dirname(__FILE__) . '/../../locale/');
bindtextdomain($textdomain, __DIR__ . '/../../locale/');
setlocale(LC_ALL
, $locale . '.UTF-8'
, $locale . '.UTF8'
@@ -497,7 +491,7 @@ class phrasea
else
{
$request->set_code($code);
include(dirname(__FILE__) . '/../../www/include/error.php');
include(__DIR__ . '/../../www/include/error.php');
}
die();
break;

View File

@@ -97,8 +97,6 @@ interface record_Interface
public function get_reg_name();
public function get_bitly_link();
public function get_hd_file();
public function delete();

View File

@@ -479,23 +479,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function move_to_collection(collection &$collection, appbox &$appbox)
{
$sql = 'UPDATE sselcont
SET base_id = :base_id
WHERE record_id = :record_id
AND base_id IN (SELECT base_id FROM bas WHERE sbas_id = :sbas_id)';
$params = array(
':base_id' => $collection->get_base_id(),
':record_id' => $this->get_record_id(),
':sbas_id' => $this->get_sbas_id()
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
basket_adapter::revoke_baskets_record($this, $appbox);
$sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id";
$params = array(
@@ -880,9 +863,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$titles = array();
foreach ($retrieved_fields as $key => $value)
{
if (trim($value === ''))
if (trim($value['value'] === ''))
continue;
$titles[] = $value;
$titles[] = $value['value'];
}
$title = trim(implode(' - ', $titles));
}
@@ -1047,7 +1030,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$base_url = '';
$original_file = $subdef_def = false;
$subdefs = $this->get_databox()->get_subdef_structure();
foreach ($subdefs as $type => $datas)
@@ -1068,7 +1050,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
try
{
$value = $this->get_subdef($name);
$original_file = p4string::addEndSlash($value['path']) . $value['file'];
if ($value->is_substituted())
{
throw new Exception('Cannot replace a substitution');
}
$original_file = p4string::addEndSlash($value->get_path()) . $value->get_file();
unlink($original_file);
}
catch (Exception $e)
@@ -1083,7 +1071,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (trim($subdef_def->get_baseurl()) !== '')
{
$base_url = str_replace(
array((string) $subdef_def->get_path(), $newfilename), array((string) $subdef_def->get_baseurl(), ''), $path_file_dest
array((string) $subdef_def->get_path(), $newfilename)
, array((string) $subdef_def->get_baseurl(), '')
, $path_file_dest
);
}
@@ -1093,7 +1083,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->record_id, ':name' => $name));
$stmt->execute(
array(
':record_id' => $this->record_id
, ':name' => $name
)
);
$registry = registry::get_instance();
@@ -1128,7 +1123,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id';
$stmt = $connbas->prepare($sql);
$stmt->bindParam(':record_id', $this->get_record_id());
$stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->execute();
$this->delete_data_from_cache(self::CACHE_SUBDEFS);
@@ -1381,54 +1376,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $regname;
}
/**
*
* @return string
*/
public function get_bitly_link()
{
$registry = registry::get_instance();
if ($this->bitly_link !== null)
return $this->bitly_link;
$this->bitly_link = false;
if (trim($registry->get('GV_bitly_user')) == ''
&& trim($registry->get('GV_bitly_key')) == '')
return $this->bitly_link;
try
{
$short = new PHPShortener();
$bitly = $short->encode($url . 'view/', 'bit.ly', $registry);
if (preg_match('/^(http:\/\/)?(www\.)?([^\/]*)\/(.*)$/', $bitly, $results))
{
if ($results[3] && $results[4])
{
$hash = 'http://bit.ly/' . $results[4];
$sql = 'UPDATE record SET bitly = :hash WHERE record_id = :record_id';
$connbas = connection::getPDOConnection($this->get_sbas_id());
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':hash' => $hash, ':record_id' => $this->get_record_id()));
$stmt->closeCursor();
$this->bitly_link = 'http://bit.ly/' . $hash;
}
}
}
catch (Exception $e)
{
unset($e);
}
$this->delete_data_from_cache();
return $this->bitly_link;
}
/**
*
* @param collection $collection
@@ -1714,21 +1661,17 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor();
$sql = 'SELECT s.ssel_id, c.sselcont_id, s.usr_id
FROM sselcont c, ssel s
WHERE c.base_id = :base_id AND c.record_id = :record_id
AND s.ssel_id = c.ssel_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id(), ':base_id' => $this->get_base_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$em = bootstrap::getCore()->getEntityManager();
foreach ($rs as $row)
$repository = $em->getRepository('\Entities\BasketElement');
/* @var $repository \Repositories\BasketElementRepository */
foreach ($repository->findElementsByRecord($this) as $basket_element)
{
$basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $row['usr_id']);
$basket->remove_from_ssel($row['sselcont_id']);
$em->remove($basket_element);
}
$stmt->closeCursor();
$em->flush();
foreach ($ftodel as $f)
@unlink($f);
@@ -1935,37 +1878,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_container_baskets()
{
if ($this->container_basket)
return $this->container_basket;
$Core = bootstrap::getCore();
$em = $Core->getEntityManager();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$repo = $em->getRepository('\Entities\Basket');
$baskets = array();
$sql = 'SELECT s.ssel_id FROM ssel s, sselcont c
WHERE s.ssel_id = c.ssel_id
AND c.base_id = :base_id AND record_id = :record_id
AND usr_id = :usr_id AND temporaryType="0"';
$params = array(
':base_id' => $this->get_base_id()
, ':record_id' => $this->get_record_id()
, ':usr_id' => $session->get_usr_id()
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
$baskets[$row['ssel_id']] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id());
}
$this->container_basket = $baskets;
return $this->container_basket;
/* @var $$repo \Repositories\BasketRepository */
return $repo->findContainingRecord($this);
}
/**

View File

@@ -89,6 +89,7 @@ class record_preview extends record_adapter
public function __construct($env, $pos, $contId, $reload_train, searchEngine_adapter $search_engine =null, $query='')
{
$appbox = appbox::get_instance();
$Core = bootstrap::getCore();
$number = null;
$this->env = $env;
@@ -112,8 +113,7 @@ class record_preview extends record_adapter
break;
case "REG":
$contId = explode('_', $contId);
$base_id = $contId[0];
$sbas_id = phrasea::sbasFromBas($base_id);
$sbas_id = $contId[0];
$record_id = $contId[1];
$this->container = new record_adapter($sbas_id, $record_id);
@@ -139,37 +139,42 @@ class record_preview extends record_adapter
break;
case "BASK":
$basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id());
$em = $Core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($contId, $Core->getAuthenticatedUser());
$this->container = $basket;
$this->total = count($basket->get_elements());
/* @var $Basket \Entities\Basket */
$this->container = $Basket;
$this->total = $Basket->getElements()->count();
$i = 0;
$first = true;
foreach ($basket->get_elements() as $element)
foreach ($Basket->getElements() as $element)
{
/* @var $element \Entities\BasketElement */
$i++;
if ($first)
{
$sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id();
$this->name = $basket->get_name();
$number = $element->get_order();
$sbas_id = $element->getRecord()->get_sbas_id();
$record_id = $element->getRecord()->get_record_id();
$this->name = $Basket->getName();
$number = $element->getOrd();
}
$first = false;
if ($element->get_order() == $pos)
if ($element->getOrd() == $pos)
{
$sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id();
$this->name = $basket->get_name();
$number = $element->get_order();
$sbas_id = $element->getRecord()->get_sbas_id();
$record_id = $element->getRecord()->get_record_id();
$this->name = $Basket->getName();
$number = $element->getOrd();
}
}
break;
case "FEED":
$entry = Feed_Entry_Adapter::load_from_id($appbox, $contId);
// $basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id());
$this->container = $entry;
$this->total = count($entry->get_content());
@@ -219,7 +224,7 @@ class record_preview extends record_adapter
$this->train = $results->get_datas();
break;
case 'BASK':
$this->train = $this->container->get_elements();
$this->train = $this->container->getElements();
break;
case 'REG':
$this->train = $this->container->get_children();

View File

@@ -41,7 +41,7 @@ class registry implements registryInterface
*/
public static function get_instance()
{
$prefix = crc32(dirname(__FILE__));
$prefix = crc32(__DIR__);
if (!self::$_instance instanceof self)
self::$_instance = new self(new cache_opcode_adapter($prefix));
@@ -57,8 +57,8 @@ class registry implements registryInterface
{
$this->cache = $cache;
require dirname(__FILE__) . '/../../config/config.inc';
$this->cache->set('GV_RootPath', dirname(dirname(dirname(__FILE__))) . '/');
require __DIR__ . '/../../config/config.inc';
$this->cache->set('GV_RootPath', dirname(dirname(__DIR__)) . '/');
$this->cache->set('GV_ServerName', p4string::addEndSlash($servername));
$this->cache->set('GV_debug', !!$debug);
$this->cache->set('GV_maintenance', !!$maintenance);

View File

@@ -639,9 +639,20 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
foreach ($fields as $name => $field)
{
if ($sxe->description->$name)
$ret[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $sxe->description->$name);
{
$val = array();
foreach($sxe->description->$name as $value)
{
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value);
}
$val = implode(' '.$field['separator'].' ', $val);
}
else
$ret[] = $field;
{
$val = $field['value'];
}
$ret[] = $val;
}
return $ret;

View File

@@ -1,6 +1,6 @@
<?php
require_once dirname(__FILE__) . '/../../../../vendor/sphinx/sphinxapi.php';
require_once __DIR__ . '/../../../../vendor/sphinx/sphinxapi.php';
/*
* This file is part of Phraseanet
*
@@ -752,8 +752,15 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
'before_match' => "<em>",
'after_match' => "</em>"
);
$fields_to_send = array();
foreach($fields as $k=>$f)
{
$fields_to_send[$k] = $f['value'];
}
return $this->sphinx->BuildExcerpts($fields, $index, $query, $opts);
return $this->sphinx->BuildExcerpts($fields_to_send, $index, $query, $opts);
}
}

View File

@@ -36,25 +36,31 @@ class set_export extends set_abstract
*/
public function __construct($lst, $sstid)
{
$Core = bootstrap::getCore();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$registry = $appbox->get_registry();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$user = $Core->getAuthenticatedUser();
$download_list = array();
$remain_hd = array();
if ($sstid != "")
{
$basket = basket_adapter::getInstance($appbox, $sstid, $user->get_id());
$em = $Core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($sstid, $user);
foreach ($basket->get_elements() as $basket_element)
foreach ($Basket->getElements() as $basket_element)
{
$base_id = $basket_element->get_record()->get_base_id();
$record_id = $basket_element->get_record()->get_record_id();
/* @var $basket_element \Entities\BasketElement */
$base_id = $basket_element->getRecord()->get_base_id();
$record_id = $basket_element->getRecord()->get_record_id();
if (!isset($remain_hd[$base_id]))
{
@@ -70,9 +76,9 @@ class set_export extends set_abstract
$current_element = $download_list[] =
new record_exportElement(
$basket_element->get_record()->get_sbas_id(),
$basket_element->getRecord()->get_sbas_id(),
$record_id,
$basket->get_name() . '/',
$basket->getName() . '/',
$remain_hd[$base_id]
);
@@ -950,7 +956,7 @@ class set_export extends set_abstract
public static function stream_file(
$file, $exportname, $mime, $disposition='attachment')
{
require_once dirname(__FILE__) . "/../../../lib/vendor/Silex/autoload.php";
require_once __DIR__ . "/../../../lib/vendor/Silex/autoload.php";
$registry = registry::get_instance();
$disposition = in_array($disposition, array('inline', 'attachment')) ?

View File

@@ -27,6 +27,8 @@ class set_exportorder extends set_export
*/
public function order_available_elements($from_usr_id, $usage, $deadline)
{
$Core = bootstrap::getCore();
$lst = $this->get_orderable_lst();
$conn = connection::getPDOConnection();
@@ -89,7 +91,7 @@ class set_exportorder extends set_export
return false;
}
$evt_mngr = eventsmanager_broker::getInstance(appbox::get_instance());
$evt_mngr = eventsmanager_broker::getInstance(appbox::get_instance(), $Core);
$params = array(
'order_id' => $order_id,

View File

@@ -219,19 +219,29 @@ class set_order extends set_abstract
}
}
try
$core = \bootstrap::getCore();
$em = $core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser());
if(!$Basket)
{
$basket = basket_adapter::getInstance($appbox, $this->ssel_id, $session->get_usr_id());
}
catch (Exception $e)
{
$basket = basket_adapter::create($appbox, sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')), $this->user, '', $pusher);
$this->ssel_id = $basket->get_ssel_id();
$Basket = new Basket();
$Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
$Basket->setOwner($this->user);
$Basket->setPusher($core->getAuthenticatedUser());
$em->persist($Basket);
$em->flush();
$this->ssel_id = $Basket->getId();
$sql = 'UPDATE `order` SET ssel_id = :ssel_id WHERE id = :order_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':ssel_id' => $basket->get_ssel_id(), ':order_id' => $this->id));
$stmt->execute(array(':ssel_id' => $Basket->getId(), ':order_id' => $this->id));
$stmt->closeCursor();
}
@@ -254,20 +264,28 @@ class set_order extends set_abstract
{
$sbas_id = phrasea::sbasFromBas($basrec['base_id']);
$record = new record_adapter($sbas_id, $basrec['record_id']);
$ret = $basket->push_element($record, false, false);
if ($ret['error'] === false)
{
$params = array(
':usr_id' => $session->get_usr_id()
, ':order_id' => $this->id
, ':order_element_id' => $order_element_id
);
$BasketElement = new BasketElement();
$BasketElement->setRecord($record);
$BasketElement->setBasket($Basket);
$Basket->addBasketElement($BasketElement);
$em->persist($BasketElement);
$em->merge($Basket);
$params = array(
':usr_id' => $session->get_usr_id()
, ':order_id' => $this->id
, ':order_element_id' => $order_element_id
);
$stmt->execute($params);
$stmt->execute($params);
$n++;
$this->user->ACL()->grant_hd_on($record, $pusher, 'order');
}
$n++;
$this->user->ACL()->grant_hd_on($record, $pusher, 'order');
unset($record);
}
catch (Exception $e)
@@ -275,11 +293,13 @@ class set_order extends set_abstract
}
}
$em->flush();
$stmt->closeCursor();
if ($n > 0)
{
$evt_mngr = eventsmanager_broker::getInstance($appbox);
$evt_mngr = eventsmanager_broker::getInstance($appbox, $core);
$params = array(
'ssel_id' => $this->ssel_id,
@@ -301,6 +321,7 @@ class set_order extends set_abstract
*/
public function deny_elements(Array $elements_ids)
{
$Core = bootstrap::getCore();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$conn = $appbox->get_connection();
@@ -328,7 +349,7 @@ class set_order extends set_abstract
if ($n > 0)
{
$evt_mngr = eventsmanager_broker::getInstance($appbox);
$evt_mngr = eventsmanager_broker::getInstance($appbox, $Core);
$params = array(
'from' => $session->get_usr_id(),

View File

@@ -31,21 +31,14 @@ class set_selection extends set_abstract
/**
*
* @param basket_adapter $basket
* @param boolean $flatten_if_grouping
* @param \Entities\Basket $basket
* @return set_selection
*/
public function load_basket(basket_adapter $basket, $flatten_if_grouping = true)
public function load_basket(\Entities\Basket $Basket)
{
if ($basket->is_grouping() && !$flatten_if_grouping)
foreach ($Basket->getElements() as $basket_element)
{
$record = new record_adapter($basket->get_sbas_id(), $basket->get_record_id(), count($this->elements));
$this->add_element($record);
}
else
{
foreach ($basket->get_elements() as $basket_element)
$this->add_element($basket_element->get_record());
$this->add_element($basket_element->getRecord());
}
return $this;

View File

@@ -68,13 +68,13 @@ class setup
public static function is_installed()
{
return file_exists(dirname(__FILE__) . "/../../config/connexion.inc")
&& file_exists(dirname(__FILE__) . "/../../config/config.inc");
return file_exists(__DIR__ . "/../../config/connexion.inc")
&& file_exists(__DIR__ . "/../../config/config.inc");
}
function create_global_values(registryInterface &$registry, $datas=array())
{
require(dirname(__FILE__) . "/../../lib/conf.d/_GV_template.inc");
require(__DIR__ . "/../../lib/conf.d/_GV_template.inc");
if ($registry->is_set('GV_timezone'))
@@ -257,12 +257,12 @@ class setup
{
if (system_server::get_platform() == 'WINDOWS')
{
$exiftool = dirname(dirname(__FILE__)) . '/vendor/exiftool/exiftool.exe';
$indexer = dirname(dirname(dirname(__FILE__))) . '/bin/phraseanet_indexer.exe';
$exiftool = dirname(__DIR__) . '/vendor/exiftool/exiftool.exe';
$indexer = dirname(dirname(__DIR__)) . '/bin/phraseanet_indexer.exe';
}
else
{
$exiftool = dirname(dirname(__FILE__)) . '/vendor/exiftool/exiftool';
$exiftool = dirname(__DIR__) . '/vendor/exiftool/exiftool';
$indexer = null;
}
@@ -453,7 +453,7 @@ class setup
public static function check_writability(registryInterface $registry)
{
$root = p4string::addEndSlash(realpath(dirname(__FILE__) . '/../../'));
$root = p4string::addEndSlash(realpath(__DIR__ . '/../../'));
$pathes = array(
$root . 'config',
@@ -765,17 +765,17 @@ class setup
public static function get_config_filepath()
{
return dirname(__FILE__) . '/../../config/config.inc';
return __DIR__ . '/../../config/config.inc';
}
public static function get_connexion_filepath()
{
return dirname(__FILE__) . '/../../config/connexion.inc';
return __DIR__ . '/../../config/connexion.inc';
}
public static function rollback(connection_pdo $conn, connection_pdo $connbas =null)
{
$structure = simplexml_load_file(dirname(__FILE__) . "/../../lib/conf.d/bases_structure.xml");
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
if (!$structure)
throw new Exception('Unable to load schema');
@@ -814,7 +814,7 @@ class setup
}
}
}
$connexion = dirname(__FILE__) . "/../../config/connexion.inc";
$connexion = __DIR__ . "/../../config/connexion.inc";
if (file_exists($connexion))
unlink($connexion);

View File

@@ -37,7 +37,7 @@ class sphinx_configuration
public function get_available_charsets()
{
$available_charsets = array();
$dir = dirname(__FILE__) . '/charsetTable/';
$dir = __DIR__ . '/charsetTable/';
echo $dir;
$registry = registry::get_instance();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)

View File

@@ -111,6 +111,7 @@ class supertwig
$this->addFilter(array('round' => 'round'));
$this->addFilter(array('nl2br' => 'nl2br'));
$this->addFilter(array('prettyString' => 'phraseadate::getPrettyString'));
$this->addFilter(array('get_collection_logo' => 'collection::getLogo'));
}
catch (Exception $e)
{
@@ -249,6 +250,7 @@ class supertwig
}
$core = bootstrap::getCore();
$eventsmanager = eventsmanager_broker::getInstance($appbox, $core);
$this->default_vars = array(
'session' => $session,
@@ -257,6 +259,7 @@ class supertwig
'core' => $core,
'browser' => $browser,
'request' => $request,
'events' => $eventsmanager,
'display_chrome_frame' => $registry->is_set('GV_display_gcf') ? $registry->get('GV_display_gcf') : true,
'user' => $user,
'current_date' => new DateTime(),

View File

@@ -45,14 +45,14 @@ class task_Scheduler
protected static function get_connection()
{
require dirname(__FILE__) . '/../../../config/connexion.inc';
require __DIR__ . '/../../../config/connexion.inc';
return new connection_pdo('appbox', $hostname, $port, $user, $password, $dbname);
}
public function run(OutputInterface $output = null, $log_tasks = true)
{
require_once dirname(__FILE__) . '/../../bootstrap.php';
require_once __DIR__ . '/../../bootstrap.php';
$this->output = $output;
$appbox = appbox::get_instance();
$registry = $appbox->get_registry();
@@ -108,11 +108,16 @@ class task_Scheduler
foreach ($task_manager->get_tasks() as $task)
{
if (!$task->is_active())
{
continue;
}
$tid = $task->get_task_id();
if (!$task->is_running())
{
/* @var $task task_abstract */
$task->reset_crash_counter();
$task->set_status(task_abstract::STATUS_TOSTART);
}
}

View File

@@ -38,8 +38,9 @@ abstract class task_appboxAbstract extends task_abstract
$this->log(("Warning : abox connection lost, restarting in 10 min."));
sleep(60 * 10);
$this->running = false;
$this->return_value = self::RETURNSTATUS_TORESTART;
return('');
return;
}
$this->set_last_exec_time();
@@ -85,7 +86,7 @@ abstract class task_appboxAbstract extends task_abstract
$this->pause($duration);
}
return($this->return_value);
return;
}
/**

View File

@@ -46,8 +46,9 @@ abstract class task_databoxAbstract extends task_abstract
$this->log(("Warning : abox connection lost, restarting in 10 min."));
sleep(60 * 10);
$this->running = false;
$this->return_value = self::RETURNSTATUS_TORESTART;
return('');
return;
}
$this->set_last_exec_time();
@@ -104,7 +105,7 @@ abstract class task_databoxAbstract extends task_abstract
$this->pause($duration);
}
return($this->return_value);
return;
}
/**

View File

@@ -112,5 +112,44 @@ class task_manager
return $row;
}
public static function getAvailableTasks()
{
$registry = registry::get_instance();
$taskdir = array( $registry->get('GV_RootPath') . "lib/classes/task/period/"
, $registry->get('GV_RootPath') . "config/classes/task/period/"
);
$tasks = array();
foreach($taskdir as $path)
{
if( ($hdir = @opendir($path)) )
{
$tskin = array();
$max = 9999;
while (($max-- > 0) && (($file = readdir($hdir)) !== false))
{
if (!is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php")
continue;
$classname = 'task_period_' . substr($file, 0, strlen($file) - 10);
try
{
// $testclass = new $classname(null);
if ($classname::interfaceAvailable())
{
$tasks[] = array("class" => $classname, "name" => $classname::getName(), "err" => null);
}
}
catch (Exception $e)
{
}
}
closedir($hdir);
}
}
return $tasks;
}
}

View File

@@ -145,6 +145,7 @@ class task_period_apibridge extends task_appboxAbstract
*/
protected function update_element(Bridge_Element &$element)
{
$Core = bootstrap::getCore();
$account = $element->get_account();
$connector_status = $account->get_api()->get_element_status($element);
@@ -176,7 +177,7 @@ class task_period_apibridge extends task_appboxAbstract
, 'sbas_id' => $element->get_record()->get_sbas_id()
, 'record_id' => $element->get_record()->get_record_id()
);
$events_mngr = eventsmanager_broker::getInstance(appbox::get_instance());
$events_mngr = eventsmanager_broker::getInstance(appbox::get_instance(), $Core);
$events_mngr->trigger('__BRIDGE_UPLOAD_FAIL__', $params);
break;

View File

@@ -67,8 +67,8 @@ class task_period_upgradetov32 extends task_abstract
if (!$this->sbas_id)
{
printf("sbas_id '" . $this->sbas_id . "' invalide\n");
return 'stopped';
$this->return_value = self::RETURNSTATUS_STOPPED;
return;
}
try
@@ -78,6 +78,8 @@ class task_period_upgradetov32 extends task_abstract
}
catch (Exception $e)
{
$this->return_value = self::RETURNSTATUS_STOPPED;
return;
}
@@ -94,6 +96,7 @@ class task_period_upgradetov32 extends task_abstract
catch (Exception $e)
{
printf("Please verify all your databox meta fields before migrating, It seems somes are wrong\n");
$this->return_value = self::RETURNSTATUS_STOPPED;
return 'stopped';
}
@@ -194,7 +197,7 @@ class task_period_upgradetov32 extends task_abstract
$sql = 'select record_id, coll_id, xml, BIN(status) as status
FROM record
WHERE record_id NOT IN (select distinct record_id from technical_datas)
WHERE migrated="0" AND record_id NOT IN (select distinct record_id from technical_datas)
LIMIT 0, 500';
$stmt = $connbas->prepare($sql);
@@ -238,7 +241,7 @@ class task_period_upgradetov32 extends task_abstract
}
catch (Exception $e)
{
}
}
@@ -280,9 +283,6 @@ class task_period_upgradetov32 extends task_abstract
{
$record = new record_adapter($this->sbas_id, $row['record_id']);
// $sbas_id = $this->sbas_id;
$metas = $databox->get_meta_structure();
$metadatas = array();
@@ -367,12 +367,16 @@ class task_period_upgradetov32 extends task_abstract
$memory = memory_get_usage() >> 20;
if ($n_done >= 5000)
return task_abstract::RETURNSTATUS_TORESTART;
{
$this->return_value = task_abstract::RETURNSTATUS_TORESTART;
return;
}
if ($memory > 100)
return task_abstract::RETURNSTATUS_TORESTART;
}
{
$this->return_value = task_abstract::RETURNSTATUS_TORESTART;
return;
}
}
catch (Exception $e)
{
@@ -393,8 +397,6 @@ class task_period_upgradetov32 extends task_abstract
$conn = connection::getPDOConnection();
$ret = 'stopped';
printf("taskid %s ending." . PHP_EOL, $this->get_task_id());
sleep(1);
printf("good bye world I was task upgrade to version 3.2" . PHP_EOL);
@@ -406,11 +408,12 @@ class task_period_upgradetov32 extends task_abstract
$stmt->closeCursor();
$this->setProgress(0, 0);
$ret = 'todelete';
$this->return_value = self::RETURNSTATUS_TODELETE;
flush();
return $ret;
return;
}
}