This commit is contained in:
Nicolas Le Goff
2011-12-27 13:06:51 +01:00
300 changed files with 3436 additions and 3162 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)
{
}
/**
@@ -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' => $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

@@ -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');

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

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

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

@@ -871,6 +871,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))
@@ -1371,7 +1376,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)))
@@ -1393,95 +1398,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

@@ -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;
}

View File

@@ -127,7 +127,7 @@ class basket_element_adapter implements cache_cacheableInterface
}
catch (Exception $e)
{
}
$sql = 'SELECT s.usr_id as owner, v.id as validate_id, v.can_see_others,
@@ -149,7 +149,7 @@ class basket_element_adapter implements cache_cacheableInterface
}
catch (Exception $e)
{
}
$first = true;
@@ -493,7 +493,7 @@ class basket_element_adapter implements cache_cacheableInterface
}
catch (Exception $e)
{
}
}
}
@@ -518,7 +518,6 @@ class basket_element_adapter implements cache_cacheableInterface
$note = strip_tags($note);
if (!$this->validate_id)
return false;
$appbox = appbox::get_instance();
@@ -554,7 +553,7 @@ class basket_element_adapter implements cache_cacheableInterface
}
catch (Exception $e)
{
}
return $this;
@@ -596,7 +595,9 @@ class basket_element_adapter implements cache_cacheableInterface
foreach ($this->choices as $key => $value)
{
if (trim($value['note']) != '')
{
$n++;
}
}
return $n;

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

@@ -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();
@@ -450,7 +450,6 @@ class databox extends base
$stmt->closeCursor();
if ($row)
return self::get_instance((int) $row['sbas_id']);
try
@@ -463,7 +462,7 @@ class databox extends base
}
catch (Exception $e)
{
}
$sql = 'USE `' . $dbname . '`';
@@ -575,7 +574,6 @@ class databox extends base
public function get_meta_structure()
{
if ($this->meta_struct)
return $this->meta_struct;
try
@@ -698,7 +696,6 @@ class databox extends base
}
}
if ($n > $limit)
return true;
return false;
@@ -725,7 +722,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,7 +957,14 @@ 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
@@ -968,7 +972,7 @@ class databox extends base
->set_indexable(isset($field['index']) ? $field['index'] : '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 +983,7 @@ class databox extends base
}
catch (Exception $e)
{
}
if (isset($field['regname']))
@@ -1213,7 +1217,6 @@ class databox extends base
public function get_structure()
{
if ($this->structure)
return $this->structure;
$this->structure = $this->retrieve_structure();
@@ -1228,7 +1231,7 @@ class databox extends base
}
catch (Exception $e)
{
}
$structure = null;
@@ -1254,7 +1257,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 +1423,6 @@ class databox extends base
public function get_cgus()
{
if ($this->cgus)
return $this->cgus;
$this->load_cgus();
@@ -1439,7 +1440,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'])
{

View File

@@ -67,17 +67,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();

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(

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");
@@ -283,7 +283,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 +497,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

@@ -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(
@@ -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,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
try
{
$value = $this->get_subdef($name);
$original_file = p4string::addEndSlash($value['path']) . $value['file'];
$original_file = p4string::addEndSlash($value->get_path()) . $value->get_file();
unlink($original_file);
}
catch (Exception $e)
@@ -1083,7 +1065,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 +1077,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 +1117,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);
@@ -1714,21 +1703,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);
foreach ($rs as $row)
$em = bootstrap::getCore()->getEntityManager();
$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 +1920,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_container_baskets()
{
if ($this->container_basket)
return $this->container_basket;
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$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;
$Core = bootstrap::getCore();
$em = $Core->getEntityManager();
$repo = $em->getRepository('\Entities\Baskets');
/* @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;
@@ -139,37 +140,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());

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

@@ -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
*

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,7 +76,7 @@ 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() . '/',
$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

@@ -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();
}

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)
{

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();

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;
}
}