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

This commit is contained in:
Nicolas Le Goff
2012-01-04 16:57:48 +01:00
8 changed files with 92 additions and 61 deletions

View File

@@ -321,7 +321,7 @@ class ACL implements cache_cacheableInterface
$this->give_access_to_base($bas_to_acces); $this->give_access_to_base($bas_to_acces);
foreach ($rights_to_give as $sbas_id => $rights) foreach ($rights_to_give as $base_id => $rights)
{ {
$this->update_rights_to_base($base_id, $rights); $this->update_rights_to_base($base_id, $rights);
} }

View File

@@ -24,121 +24,145 @@ class basket_adapter implements cache_cacheableInterface
* @var string * @var string
*/ */
protected $name = false; protected $name = false;
/** /**
* *
* @var string * @var string
*/ */
protected $desc = false; protected $desc = false;
/** /**
* *
* @var DateTime * @var DateTime
*/ */
protected $created_on; protected $created_on;
/** /**
* *
* @var DateTime * @var DateTime
*/ */
protected $updated_on; protected $updated_on;
/** /**
* *
* @var User_Adapter * @var User_Adapter
*/ */
protected $pusher; protected $pusher;
/** /**
* *
* @var boolean * @var boolean
*/ */
protected $noview = false; protected $noview = false;
/** /**
* *
* @var string * @var string
*/ */
protected $instance_key; protected $instance_key;
/** /**
* *
* @var mixed * @var mixed
*/ */
protected $valid = false; protected $valid = false;
/** /**
* *
* @var boolean * @var boolean
*/ */
protected $is_grouping = false; protected $is_grouping = false;
/** /**
* *
* @var int * @var int
*/ */
protected $record_id; protected $record_id;
/** /**
* *
* @var boolean * @var boolean
*/ */
protected $is_mine = false; protected $is_mine = false;
/** /**
* *
* @var int * @var int
*/ */
protected $usr_id; protected $usr_id;
/** /**
* *
* @var array * @var array
*/ */
protected $elements; protected $elements;
/** /**
* *
* @var int * @var int
*/ */
protected $ssel_id; protected $ssel_id;
/** /**
* *
* @var array * @var array
*/ */
protected $validating_users = array(); protected $validating_users = array();
/** /**
* *
* @var boolean * @var boolean
*/ */
protected $validation_see_others = false; protected $validation_see_others = false;
/** /**
* *
* @var boolean * @var boolean
*/ */
protected $validation_end_date = false; protected $validation_end_date = false;
/** /**
* *
* @var boolean * @var boolean
*/ */
protected $validation_is_confirmed = false; protected $validation_is_confirmed = false;
/** /**
* *
* @var int * @var int
*/ */
protected $sbas_id; protected $sbas_id;
/** /**
* *
* @var int * @var int
*/ */
protected $coll_id; protected $coll_id;
/** /**
* *
* @var int * @var int
*/ */
protected $base_id; protected $base_id;
/** /**
* *
* @var boolean * @var boolean
*/ */
protected $owner_changed = false; protected $owner_changed = false;
/** /**
* *
* @var array * @var array
*/ */
static $_regfields = null; static $_regfields = null;
/** /**
* *
* @var appbox * @var appbox
*/ */
protected $appbox; protected $appbox;
/** /**
* *
* @var boolean * @var boolean
@@ -303,7 +327,6 @@ class basket_adapter implements cache_cacheableInterface
public function get_first_element() public function get_first_element()
{ {
foreach ($this->get_elements() as $basket_element) foreach ($this->get_elements() as $basket_element)
return $basket_element; return $basket_element;
return null; return null;
} }
@@ -315,7 +338,6 @@ class basket_adapter implements cache_cacheableInterface
public function get_validation_end_date() public function get_validation_end_date()
{ {
if (!$this->valid || !$this->validation_end_date) if (!$this->valid || !$this->validation_end_date)
return null; return null;
return $this->validation_end_date; return $this->validation_end_date;
} }
@@ -327,7 +349,6 @@ class basket_adapter implements cache_cacheableInterface
public function is_validation_finished() public function is_validation_finished()
{ {
if (!$this->valid || !$this->validation_end_date) if (!$this->valid || !$this->validation_end_date)
return null; return null;
$now = new DateTime(); $now = new DateTime();
@@ -341,7 +362,6 @@ class basket_adapter implements cache_cacheableInterface
public function is_confirmed() public function is_confirmed()
{ {
if (!$this->valid) if (!$this->valid)
return null; return null;
return $this->validation_is_confirmed; return $this->validation_is_confirmed;
@@ -350,17 +370,14 @@ class basket_adapter implements cache_cacheableInterface
public function is_releasable() public function is_releasable()
{ {
if (!$this->valid) if (!$this->valid)
return false; return false;
if ($this->is_confirmed()) if ($this->is_confirmed())
return false; return false;
foreach($this->get_elements() as $element) foreach ($this->get_elements() as $element)
{ {
if($element->get_my_agreement() == '0') if ($element->get_my_agreement() == '0')
return false; return false;
} }
@@ -494,7 +511,6 @@ class basket_adapter implements cache_cacheableInterface
$this->desc = $row['descript']; $this->desc = $row['descript'];
$this->created_on = new DateTime($row['date']); $this->created_on = new DateTime($row['date']);
$this->updated_on = new DateTime($row['updater']); $this->updated_on = new DateTime($row['updater']);
$this->usr_id = (int) $row['owner'];
$this->noview = !!$row['noview']; $this->noview = !!$row['noview'];
$this->is_mine = ($row['owner'] == $this->usr_id); $this->is_mine = ($row['owner'] == $this->usr_id);
@@ -569,7 +585,6 @@ class basket_adapter implements cache_cacheableInterface
public function sort($order) public function sort($order)
{ {
if (!$this->valid || !in_array($order, array('asc', 'desc'))) if (!$this->valid || !in_array($order, array('asc', 'desc')))
return; return;
$this->load_elements(); $this->load_elements();
@@ -1001,7 +1016,6 @@ class basket_adapter implements cache_cacheableInterface
public function set_read() public function set_read()
{ {
if (!$this->noview) if (!$this->noview)
return true; return true;
$session = $this->appbox->get_session(); $session = $this->appbox->get_session();
@@ -1112,19 +1126,15 @@ class basket_adapter implements cache_cacheableInterface
if ($this->is_mine) if ($this->is_mine)
{ {
if ($this->is_validation_finished()) if ($this->is_validation_finished())
return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1));
else else
return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1));
} }
else else
{ {
if ($this->validation_see_others) if ($this->validation_see_others)
return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1)); return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1));
else else
return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name()); return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name());
} }
} }
@@ -1135,7 +1145,7 @@ class basket_adapter implements cache_cacheableInterface
*/ */
public function set_released() public function set_released()
{ {
if(!$this->is_valid()) if (!$this->is_valid())
throw new Exception('Not a validation basket'); throw new Exception('Not a validation basket');
$session = $this->appbox->get_session(); $session = $this->appbox->get_session();
@@ -1164,12 +1174,26 @@ class basket_adapter implements cache_cacheableInterface
if ($row) if ($row)
{ {
$expires = new DateTime('+10 days');
$url = $this->appbox->get_registry()->get('GV_ServerName')
. 'lightbox/index.php?LOG=' . random::getUrlToken(
'validate'
, $session->get_usr_id()
, $expires
, $this->get_ssel_id()
);
$to = $row['usr_id']; $to = $row['usr_id'];
$params = array( $params = array(
'ssel_id' => $this->ssel_id, 'ssel_id' => $this->ssel_id,
'from' => $session->get_usr_id(), 'from' => $session->get_usr_id(),
'url' => $url,
'to' => $to 'to' => $to
); );
$evt_mngr->trigger('__VALIDATION_DONE__', $params); $evt_mngr->trigger('__VALIDATION_DONE__', $params);
} }
@@ -1219,7 +1243,6 @@ class basket_adapter implements cache_cacheableInterface
protected function load_elements() protected function load_elements()
{ {
if (!is_null($this->elements)) if (!is_null($this->elements))
return; return;
$this->elements = array(); $this->elements = array();
@@ -1497,14 +1520,11 @@ class basket_adapter implements cache_cacheableInterface
public function remove_from_ssel($sselcont_id) public function remove_from_ssel($sselcont_id)
{ {
if (!$this->is_mine) if (!$this->is_mine)
return array('error' => 'error', 'status' => 0); return array('error' => 'error', 'status' => 0);
if ($this->is_grouping) if ($this->is_grouping)
return $this->remove_grouping_elements($sselcont_id); return $this->remove_grouping_elements($sselcont_id);
else else
return $this->remove_basket_elements($sselcont_id); return $this->remove_basket_elements($sselcont_id);
} }
@@ -1521,14 +1541,14 @@ class basket_adapter implements cache_cacheableInterface
foreach ($this->get_validating_users() as $user_data) foreach ($this->get_validating_users() as $user_data)
{ {
$keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id(); $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id();
$keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id().'_'.self::CACHE_ELEMENTS; $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id() . '_' . self::CACHE_ELEMENTS;
$keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id().'_'.self::CACHE_VALIDATING_USERS; $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id() . '_' . self::CACHE_VALIDATING_USERS;
} }
} }
$keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id(); $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id();
$keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id().'_'.self::CACHE_ELEMENTS; $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id() . '_' . self::CACHE_ELEMENTS;
$keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id().'_'.self::CACHE_VALIDATING_USERS; $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id() . '_' . self::CACHE_VALIDATING_USERS;
$this->appbox->delete_data_from_cache($keys); $this->appbox->delete_data_from_cache($keys);

View File

@@ -151,9 +151,8 @@ class basketCollection
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
$session = $appbox->get_session(); $session = $appbox->get_session();
$sql = 'SELECT n.ssel_id FROM sselnew n, ssel s $sql = 'SELECT n.ssel_id FROM sselnew n
WHERE s.ssel_id = n.ssel_id AND n.usr_id = :usr_id WHERE n.usr_id = :usr_id ';
AND n.usr_id = s.usr_id';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':usr_id' => $session->get_usr_id())); $stmt->execute(array(':usr_id' => $session->get_usr_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -161,9 +160,19 @@ class basketCollection
$baskets = array(); $baskets = array();
foreach($rs as $row) foreach($rs as $row)
{
try
{ {
$baskets[] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id()); $baskets[] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id());
} }
catch(Exception $e)
{
$sql = 'DELETE FROM sselnew WHERE ssel_id = :ssel_id AND usr_id = :usr_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':usr_id' => $session->get_usr_id(), ':ssel_id' => $row['ssel_id']));
$stmt->closeCursor();
}
}
return $baskets; return $baskets;
} }

View File

@@ -110,7 +110,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
'name' => $user_from->get_display_name() 'name' => $user_from->get_display_name()
); );
if (self::mail($to, $from, $params['ssel_id'])) if (self::mail($to, $from, $params['ssel_id'], $params['url']))
$mailed = true; $mailed = true;
} }
@@ -189,7 +189,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
* @param int $ssel_id * @param int $ssel_id
* @return boolean * @return boolean
*/ */
function mail($to, $from, $ssel_id) function mail($to, $from, $ssel_id, $url)
{ {
try try
{ {
@@ -211,7 +211,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$from['name'] $from['name']
) . "</div>\n"; ) . "</div>\n";
$body .= "<br/>\n" . $this->registry->get('GV_ServerName') . 'lightbox/validate/' . $ssel_id; $body .= "<br/>\n" . $url;
return mail::send_mail($subject, $body, $to, $from, array()); return mail::send_mail($subject, $body, $to, $from, array());
} }

View File

@@ -76,7 +76,6 @@ class gatekeeper
$session = $appbox->get_session(); $session = $appbox->get_session();
if (http_request::is_command_line()) if (http_request::is_command_line())
return; return;
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF']))
@@ -122,7 +121,6 @@ class gatekeeper
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php' if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php' || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
return; return;
phrasea::redirect('/login/?redirect=/thesaurus2'); phrasea::redirect('/login/?redirect=/thesaurus2');
break; break;
@@ -131,7 +129,6 @@ class gatekeeper
break; break;
case 'admin': case 'admin':
if ($this->_script_name === 'runscheduler.php') if ($this->_script_name === 'runscheduler.php')
return; return;
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
break; break;
@@ -151,7 +148,6 @@ class gatekeeper
return; return;
case 'setup': case 'setup':
if ($appbox->upgradeavailable()) if ($appbox->upgradeavailable())
return; return;
else else
phrasea::redirect('/login/'); phrasea::redirect('/login/');
@@ -161,7 +157,7 @@ class gatekeeper
break; break;
case 'lightbox': case 'lightbox':
$this->token_access(); $this->token_access();
if(!$session->is_authenticated()) if (!$session->is_authenticated())
{ {
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
} }
@@ -268,13 +264,12 @@ class gatekeeper
$parm = $request->get_parms('LOG'); $parm = $request->get_parms('LOG');
if (is_null($parm["LOG"])) if (is_null($parm["LOG"]))
return $this; return $this;
try try
{ {
if($session->is_authenticated()) if ($session->is_authenticated())
$session->logout (); $session->logout();
$auth = new Session_Authentication_Token($appbox, $parm['LOG']); $auth = new Session_Authentication_Token($appbox, $parm['LOG']);
$session->authenticate($auth); $session->authenticate($auth);
} }
@@ -286,6 +281,7 @@ class gatekeeper
try try
{ {
$datas = random::helloToken($parm['LOG']); $datas = random::helloToken($parm['LOG']);
return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
} }
catch (Exception_NotFound $e) catch (Exception_NotFound $e)
{ {

View File

@@ -375,8 +375,14 @@ class record_preview extends record_adapter
$tab[$hour][$site][$action] = array(); $tab[$hour][$site][$action] = array();
if (!isset($tab[$hour][$site][$action][$row['usr_id']])) if (!isset($tab[$hour][$site][$action][$row['usr_id']]))
{
$tab[$hour][$site][$action][$row['usr_id']] = $tab[$hour][$site][$action][$row['usr_id']] =
array('final' => array(), 'comment' => array()); array(
'final' => array()
, 'comment' => array()
, 'user' => \User_Adapter::getInstance($row['usr_id'], $appbox)
);
}
if (!in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final'])) if (!in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final']))
$tab[$hour][$site][$action][$row['usr_id']]['final'][] = $tab[$hour][$site][$action][$row['usr_id']]['final'][] =

View File

@@ -3,7 +3,7 @@
{% for hour, sites in record.get_short_history() %} {% for hour, sites in record.get_short_history() %}
{% for site, actions in sites %} {% for site, actions in sites %}
{% for action, users in actions %} {% for action, users in actions %}
{% for current_user, done in users %} {% for done in users %}
<div style="margin:3px 0"> <div style="margin:3px 0">
@@ -55,9 +55,9 @@
{% endif %} {% endif %}
<span class="actor"> <span class="actor">
{% if user.ACL().has_right_on_base(record.get_base_id(), 'canreport') %} {% if user.ACL().has_right_on_base(record.get_base_id(), 'canreport') %}
{% set user_infos = user.getInfos(current_user) %} {% if done['user'].get_id() != session.get_usr_id() %}
{% if current_user != session.get_usr_id() and user_infos %} {% set user_infos = done['user'].get_display_name() %}
{% trans %}report:: par {{user_infos}}{% endtrans %} {% trans %}report:: par {{ user_infos }}{% endtrans %}
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@@ -366,7 +366,7 @@ function manageSession(data, showMessages)
if($('.notification.unread',box).length > 0) if($('.notification.unread',box).length > 0)
{ {
var trigger = $('#notification_trigger') ; var trigger = $('#notification_trigger') ;
$('.counter div',trigger) $('.counter',trigger)
.empty() .empty()
.append($('.notification.unread',box).length); .append($('.notification.unread',box).length);
$('.counter',trigger).css('visibility','visible'); $('.counter',trigger).css('visibility','visible');