mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
V 3.5 RC 1
This commit is contained in:
@@ -1,117 +1,148 @@
|
||||
<?php
|
||||
class patch_303 implements patch
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_303 implements patchInterface
|
||||
{
|
||||
|
||||
private $release = '3.0.3';
|
||||
private $concern = array('application_box');
|
||||
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
{
|
||||
$this->update_users_log_datas();
|
||||
$this->update_users_search_datas();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function update_users_log_datas()
|
||||
{
|
||||
$conn = connection::getInstance();
|
||||
|
||||
$col = array('fonction','societe','activite','pays');
|
||||
|
||||
$sql = " SELECT * FROM sbas";
|
||||
if($rs = $conn->query($sql))
|
||||
{
|
||||
while($row = $conn->fetch_assoc($rs))
|
||||
$tab_sbas[$row['sbas_id']] = array('dbname' => $row['dbname']);
|
||||
$conn->free_result($rs);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.0.3';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
$f_req = "";
|
||||
foreach($col as $key => $column)
|
||||
$f_req .= (($f_req) ? ',': '') . $column;
|
||||
|
||||
$sql = "SELECT usr_id, ".$f_req." FROM usr";
|
||||
if($rs = $conn->query($sql))
|
||||
{
|
||||
while($row = $conn->fetch_assoc($rs))
|
||||
$tab_usr[$row['usr_id']] = array('fonction' => $row['fonction'], 'societe' => $row['societe'], 'activite' => $row['activite'], 'pays' => $row['pays']);
|
||||
$conn->free_result($rs);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
foreach($tab_sbas as $sbasid => $name)
|
||||
{
|
||||
$f_req = '';
|
||||
|
||||
$connbas = connection::getInstance($sbasid);
|
||||
|
||||
if($connbas)
|
||||
{
|
||||
foreach($tab_usr as $id => $columns)
|
||||
{
|
||||
foreach($columns as $column => $value)
|
||||
$f_req .= (($f_req) ? ',': '') . $column." = '".$connbas->escape_string($value)."'" ;
|
||||
|
||||
$sql = "UPDATE log SET ".$f_req." WHERE usrid = '".$connbas->escape_string($id)."' AND site='".GV_sit."'";
|
||||
$connbas->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update_users_search_datas()
|
||||
{
|
||||
$conn = connection::getInstance();
|
||||
|
||||
|
||||
$sql = " SELECT * FROM sbas";
|
||||
if($rs = $conn->query($sql))
|
||||
{
|
||||
while($row = $conn->fetch_assoc($rs))
|
||||
$tab_sbas[$row['sbas_id']] = array('dbname' => $row['dbname']);
|
||||
$conn->free_result($rs);
|
||||
}
|
||||
|
||||
foreach($tab_sbas as $sbasid => $name)
|
||||
{
|
||||
$f_req = "";
|
||||
|
||||
$connbas = connection::getInstance($sbasid);
|
||||
|
||||
if($connbas)
|
||||
{
|
||||
$date_debut = '0000-00-00 00:00:00';
|
||||
|
||||
$sql = 'SELECT MAX(date) as debut FROM `log_search`';
|
||||
if($rs = $connbas->query($sql))
|
||||
{
|
||||
if($row = $connbas->fetch_assoc($rs))
|
||||
$date_debut = $row['debut'];
|
||||
$connbas->free_result($rs);
|
||||
}
|
||||
|
||||
$sql = 'REPLACE INTO log_search (SELECT null as id, logid as log_id, date, askquest as search, nbrep as results, coll_id FROM quest WHERE `date` > "'.$date_debut.'")';
|
||||
$connbas->query($sql);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$this->update_users_log_datas($appbox);
|
||||
$this->update_users_search_datas($appbox);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return patch_303
|
||||
*/
|
||||
function update_users_log_datas(appbox &$appbox)
|
||||
{
|
||||
$col = array('fonction', 'societe', 'activite', 'pays');
|
||||
|
||||
$f_req = implode(', ', $col);
|
||||
|
||||
$sql = "SELECT usr_id, " . $f_req . " FROM usr";
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
$tab_usr[$row['usr_id']] = array(
|
||||
'fonction' => $row['fonction'],
|
||||
'societe' => $row['societe'],
|
||||
'activite' => $row['activite'],
|
||||
'pays' => $row['pays']
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox)
|
||||
{
|
||||
foreach ($tab_usr as $id => $columns)
|
||||
{
|
||||
$f_req = array();
|
||||
$params = array(':usr_id' => $id, ':site' => $appbox->get_registry()->get('GV_sit'));
|
||||
foreach ($columns as $column => $value)
|
||||
{
|
||||
$column = trim($column);
|
||||
$f_req[] = $column . " = :" . $column;
|
||||
$params[':' . $column] = $value;
|
||||
}
|
||||
$f_req = implode(', ', $f_req);
|
||||
$sql = "UPDATE log SET " . $f_req . "
|
||||
WHERE usrid = :usr_id AND site = :site";
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return patch_303
|
||||
*/
|
||||
function update_users_search_datas(appbox &$appbox)
|
||||
{
|
||||
foreach ($appbox->get_databoxes() as $databox)
|
||||
{
|
||||
$date_debut = '0000-00-00 00:00:00';
|
||||
|
||||
$sql = 'SELECT MAX(date) as debut FROM `log_search`';
|
||||
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$date_debut = $row['debut'];
|
||||
}
|
||||
|
||||
$sql = 'REPLACE INTO log_search
|
||||
(SELECT null as id, logid as log_id, date, askquest as search,
|
||||
nbrep as results, coll_id
|
||||
FROM quest
|
||||
WHERE `date` > :date)';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':date' => $date_debut));
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,31 +1,78 @@
|
||||
<?php
|
||||
class patch_304 implements patch
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_304 implements patchInterface
|
||||
{
|
||||
|
||||
private $release = '3.0.4';
|
||||
private $concern = array('data_box');
|
||||
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
{
|
||||
$connbas = connection::getInstance($id);
|
||||
|
||||
if(!$connbas || !$connbas->isok())
|
||||
return true;
|
||||
|
||||
$sql = 'INSERT INTO pref (id, prop, value, locale, updated_on, created_on)
|
||||
VALUES (null, "indexes", "1", "", NOW(), NOW())';
|
||||
$connbas->query($sql);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.0.4';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$databox)
|
||||
{
|
||||
$sql = 'SELECT id FROM pref WHERE prop = "indexes"';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rowcount = $stmt->rowCount();
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($rowcount == 0)
|
||||
{
|
||||
$sql = 'INSERT INTO pref
|
||||
(id, prop, value, locale, updated_on, created_on)
|
||||
VALUES
|
||||
(null, "indexes", "1", "", NOW(), NOW())';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,28 +1,69 @@
|
||||
<?php
|
||||
class patch_305 implements patch
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_305 implements patchInterface
|
||||
{
|
||||
|
||||
private $release = '3.0.5';
|
||||
private $concern = array('application_box');
|
||||
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
{
|
||||
$conn = connection::getInstance();
|
||||
|
||||
$sql = 'INSERT INTO usr_settings (SELECT usr_id, "start_page_query" as prop, last_query as value FROM usr WHERE model_of="0" AND usr_login NOT LIKE "(#deleted_%")';
|
||||
|
||||
$conn->query($sql);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.0.5';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$sql = 'REPLACE INTO usr_settings
|
||||
(SELECT usr_id, "start_page_query" as prop, last_query as value
|
||||
FROM usr
|
||||
WHERE model_of="0" AND usr_login NOT LIKE "(#deleted_%")';
|
||||
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,61 +1,86 @@
|
||||
<?php
|
||||
class patch_306 implements patch
|
||||
{
|
||||
|
||||
private $release = '3.0.6';
|
||||
private $concern = array('data_box');
|
||||
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
{
|
||||
$connbas = connection::getInstance($id);
|
||||
|
||||
if(!$connbas || !$connbas->isok())
|
||||
return true;
|
||||
|
||||
$dom = databox::get_dom_structure($id);
|
||||
|
||||
$xpath = databox::get_xpath_structure($id);
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_306 implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.0.6';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$databox)
|
||||
{
|
||||
$dom = $databox->get_dom_structure();
|
||||
$xpath = $databox->get_xpath_structure();
|
||||
$res = $xpath->query('/record/subdefs/preview/type');
|
||||
|
||||
foreach ($res as $type)
|
||||
{
|
||||
if ($type->nodeValue == 'video')
|
||||
{
|
||||
$preview = $type->parentNode;
|
||||
|
||||
$to_add = array(
|
||||
'acodec' => 'faac',
|
||||
'vcodec' => 'libx264',
|
||||
'bitrate' => '700'
|
||||
);
|
||||
foreach ($to_add as $k => $v)
|
||||
{
|
||||
$el = $dom->createElement($k);
|
||||
$el->appendChild($dom->createTextNode($v));
|
||||
$preview->appendChild($el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$databox->saveStructure($dom);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$res = $xpath->query('/record/subdefs/preview/type');
|
||||
|
||||
foreach($res as $type)
|
||||
{
|
||||
if($type->nodeValue == 'video')
|
||||
{
|
||||
$preview = $type->parentNode;
|
||||
|
||||
$to_add = array(
|
||||
'acodec'=>'faac',
|
||||
'vcodec'=>'libx264',
|
||||
'bitrate'=>'700'
|
||||
);
|
||||
foreach($to_add as $k=>$v)
|
||||
{
|
||||
$el = $dom->createElement($k);
|
||||
$el->appendChild($dom->createTextNode($v));
|
||||
$preview->appendChild($el);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE pref SET value='" . $connbas->escape_string($dom->saveXML()) . "', updated_on=NOW() WHERE prop='structure'" ;
|
||||
$connbas->query($sql);
|
||||
|
||||
$cache_appbox = cache_appbox::getInstance();
|
||||
$cache_appbox->delete('list_bases');
|
||||
|
||||
cache_databox::update($id,'structure');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,169 +1,177 @@
|
||||
<?php
|
||||
class patch_310 implements patch
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_310 implements patchInterface
|
||||
{
|
||||
|
||||
private $release = '3.1.0';
|
||||
private $concern = array('data_box');
|
||||
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
{
|
||||
|
||||
$connbas = connection::getInstance($id);
|
||||
|
||||
if(!$connbas || !$connbas->isok())
|
||||
return false;
|
||||
|
||||
$sql = 'SELECT value FROM pref WHERE prop="structure"';
|
||||
|
||||
$structure = false;
|
||||
|
||||
if($rs = $connbas->query($sql))
|
||||
{
|
||||
if($row = $connbas->fetch_assoc($rs))
|
||||
$structure = $row['value'];
|
||||
$connbas->free_result($rs);
|
||||
}
|
||||
|
||||
if(!$structure)
|
||||
exit('Impossible de charger la structure depuis la base de donnnee '.$id.' '.$connbas->last_error());
|
||||
|
||||
$dom_structure = new DOMDocument();
|
||||
$dom_structure->formatOutput = true;
|
||||
$dom_structure->preserveWhiteSpace = false;
|
||||
|
||||
if(!$dom_structure->loadXML($structure))
|
||||
exit('Impossible de charger la structure en DOM ');
|
||||
|
||||
if(($sx_structure = simplexml_load_string($structure)) === false)
|
||||
exit('Impossible de charger la structure en sxml ');
|
||||
|
||||
$subdefs = $sx_structure->xpath('/record/subdefs');
|
||||
|
||||
if(count($subdefs) > 1)
|
||||
exit('La structure semble erronnée, veuillez la corriger');
|
||||
|
||||
|
||||
$new_subefs_node = $dom_structure->createElement('subdefs');
|
||||
|
||||
$subdefs_groups = array();
|
||||
|
||||
foreach($subdefs[0] as $k=>$v)
|
||||
{
|
||||
$type = isset($v->type) ? (string)$v->type : 'image';
|
||||
|
||||
if($type == 'image')
|
||||
$media = 'image';
|
||||
elseif($type == 'audio')
|
||||
{
|
||||
if($v->method == 'MP3')
|
||||
$media = "audio";
|
||||
else
|
||||
$media = "image";
|
||||
}
|
||||
elseif($type == 'video')
|
||||
{
|
||||
if($v->method == 'AnimGIF')
|
||||
$media = "gif";
|
||||
elseif($$v->method == 'JPG')
|
||||
$media = "image";
|
||||
else
|
||||
$media = 'video';
|
||||
}
|
||||
|
||||
echo 'found '.$k.' node with type '.$type.'<br>';
|
||||
|
||||
if(!isset($subdefs_groups[$type]))
|
||||
{
|
||||
$subdefs_groups[$type] = $dom_structure->createElement('subdefgroup');
|
||||
$subdefs_groups[$type]->setAttribute('name',$type);
|
||||
}
|
||||
|
||||
$dom_subdef = $dom_structure->createElement('subdef');
|
||||
$dom_subdef->setAttribute('class', ($k == 'preview' ? 'preview' : 'thumbnail'));
|
||||
$dom_subdef->setAttribute('name', $k);
|
||||
$dom_subdef->setAttribute('downloadable', 'true');
|
||||
|
||||
foreach($v as $tag=>$value)
|
||||
{
|
||||
if(in_array($tag,array('type','name')))
|
||||
continue;
|
||||
|
||||
$dom_element = $dom_structure->createElement($tag, $value);
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
|
||||
}
|
||||
$dom_element = $dom_structure->createElement('mediatype', $media);
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
|
||||
if($media == 'video')
|
||||
{
|
||||
$dom_element = $dom_structure->createElement('threads', '1');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
|
||||
|
||||
//preview, thumbnail et thumbnailGIF
|
||||
if($k == 'preview')
|
||||
{
|
||||
$dom_element = $dom_structure->createElement('label', 'Prévisualisation');
|
||||
$dom_element->setAttribute('lang','fr');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
$dom_element = $dom_structure->createElement('label', 'Preview');
|
||||
$dom_element->setAttribute('lang','en');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
elseif($k == 'thumbnailGIF')
|
||||
{
|
||||
$dom_element = $dom_structure->createElement('label', 'Animation GIF');
|
||||
$dom_element->setAttribute('lang','fr');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
$dom_element = $dom_structure->createElement('label', 'GIF animation');
|
||||
$dom_element->setAttribute('lang','en');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
else
|
||||
{
|
||||
$dom_element = $dom_structure->createElement('label', 'Imagette');
|
||||
$dom_element->setAttribute('lang','fr');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
$dom_element = $dom_structure->createElement('label', 'Thumbnail');
|
||||
$dom_element->setAttribute('lang','en');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
|
||||
$subdefs_groups[$type]->appendChild($dom_subdef);
|
||||
}
|
||||
|
||||
foreach($subdefs_groups as $type=>$node)
|
||||
$new_subefs_node->appendChild($node);
|
||||
|
||||
$record = $dom_structure->documentElement;
|
||||
|
||||
$record->replaceChild($new_subefs_node, $record->getElementsByTagName('subdefs')->item(0));
|
||||
|
||||
$record->setAttribute("modification_date", $now = date("YmdHis"));
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.1.0';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$databox)
|
||||
{
|
||||
$dom_structure = $databox->get_dom_structure();
|
||||
$sx_structure = $databox->get_sxml_structure();
|
||||
|
||||
$subdefgroups = $sx_structure->xpath('//subdefgroup');
|
||||
|
||||
if (count($subdefgroups) > 0)
|
||||
|
||||
return;
|
||||
|
||||
$subdefs = $sx_structure->xpath('/record/subdefs');
|
||||
|
||||
if (count($subdefs) > 1)
|
||||
exit('La structure semble erronnée, veuillez la corriger');
|
||||
|
||||
$new_subefs_node = $dom_structure->createElement('subdefs');
|
||||
|
||||
$subdefs_groups = array();
|
||||
|
||||
foreach ($subdefs[0] as $k => $v)
|
||||
{
|
||||
$type = isset($v->type) ? (string) $v->type : 'image';
|
||||
|
||||
if ($type == 'image')
|
||||
$media = 'image';
|
||||
elseif ($type == 'audio')
|
||||
{
|
||||
if ($v->method == 'MP3')
|
||||
$media = "audio";
|
||||
else
|
||||
$media = "image";
|
||||
}
|
||||
elseif ($type == 'video')
|
||||
{
|
||||
if ($v->method == 'AnimGIF')
|
||||
$media = "gif";
|
||||
elseif ($v->method == 'JPG')
|
||||
$media = "image";
|
||||
else
|
||||
$media = 'video';
|
||||
}
|
||||
|
||||
if (!isset($subdefs_groups[$type]))
|
||||
{
|
||||
$subdefs_groups[$type] = $dom_structure->createElement('subdefgroup');
|
||||
$subdefs_groups[$type]->setAttribute('name', $type);
|
||||
}
|
||||
|
||||
$dom_subdef = $dom_structure->createElement('subdef');
|
||||
$class = ($k == 'preview' ? 'preview' : 'thumbnail');
|
||||
$dom_subdef->setAttribute('class', $class);
|
||||
$dom_subdef->setAttribute('name', $k);
|
||||
$dom_subdef->setAttribute('downloadable', 'true');
|
||||
|
||||
foreach ($v as $tag => $value)
|
||||
{
|
||||
if (in_array($tag, array('type', 'name')))
|
||||
continue;
|
||||
|
||||
$dom_element = $dom_structure->createElement($tag, $value);
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
$dom_element = $dom_structure->createElement('mediatype', $media);
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
|
||||
if ($media == 'video')
|
||||
{
|
||||
$dom_element = $dom_structure->createElement('threads', '1');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
|
||||
|
||||
//preview, thumbnail et thumbnailGIF
|
||||
if ($k == 'preview')
|
||||
{
|
||||
$dom_element =
|
||||
$dom_structure->createElement('label', 'Prévisualisation');
|
||||
$dom_element->setAttribute('xml:lang', 'fr');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
$dom_element = $dom_structure->createElement('label', 'Preview');
|
||||
$dom_element->setAttribute('lang', 'en');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
elseif ($k == 'thumbnailGIF')
|
||||
{
|
||||
$dom_element = $dom_structure->createElement('label', 'Animation GIF');
|
||||
$dom_element->setAttribute('lang', 'fr');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
$dom_element = $dom_structure->createElement('label', 'GIF animation');
|
||||
$dom_element->setAttribute('lang', 'en');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
else
|
||||
{
|
||||
$dom_element = $dom_structure->createElement('label', 'Imagette');
|
||||
$dom_element->setAttribute('lang', 'fr');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
$dom_element = $dom_structure->createElement('label', 'Thumbnail');
|
||||
$dom_element->setAttribute('lang', 'en');
|
||||
$dom_subdef->appendChild($dom_element);
|
||||
}
|
||||
|
||||
$subdefs_groups[$type]->appendChild($dom_subdef);
|
||||
}
|
||||
|
||||
foreach ($subdefs_groups as $type => $node)
|
||||
$new_subefs_node->appendChild($node);
|
||||
|
||||
$record = $dom_structure->documentElement;
|
||||
|
||||
$record->replaceChild(
|
||||
$new_subefs_node,
|
||||
$record->getElementsByTagName('subdefs')->item(0)
|
||||
);
|
||||
|
||||
$databox->saveStructure($dom_structure);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql = "UPDATE pref SET value='" . $connbas->escape_string($dom_structure->saveXML()) . "',
|
||||
updated_on='" . $now . "' WHERE prop='structure'" ;
|
||||
$connbas->query($sql);
|
||||
|
||||
$cache_appbox = cache_appbox::getInstance();
|
||||
$cache_appbox->delete('list_bases');
|
||||
|
||||
cache_databox::update($id,'structure');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,37 +1,96 @@
|
||||
<?php
|
||||
class patch_3102 implements patch
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_3102 implements patchInterface
|
||||
{
|
||||
|
||||
private $release = '3.1.20';
|
||||
private $concern = array('application_box');
|
||||
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
{
|
||||
$conn = connection::getInstance();
|
||||
|
||||
$task_id = $conn->getId('task');
|
||||
|
||||
$sql = 'INSERT INTO `task2`
|
||||
(`task_id`, `usr_id_owner`, `pid`, `status`, `crashed`, `active`, `name`, `last_exec_time`, `class`, `settings`, `completed`)
|
||||
VALUES
|
||||
("'.$conn->escape_string($task_id).'", 0, 0, "stopped", 0, 1, "upgrade to v3.1", "0000-00-00 00:00:00", "task_upgradetov31",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<tasksettings>\r\n</tasksettings>", -1)';
|
||||
|
||||
$conn->query($sql);
|
||||
|
||||
$sql = 'UPDATE record SET sha256 = "" WHERE sha256 IS NULL AND parent_record_id = 0';
|
||||
$conn->query($sql);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.1.20';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX, base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$base)
|
||||
{
|
||||
$conn = connection::getPDOConnection();
|
||||
|
||||
$sql = 'SELECT task_id FROM task2 WHERE `class` = "task_period_upgradetov31"';
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rowcount = $stmt->rowCount();
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($rowcount == 0)
|
||||
{
|
||||
$sql = 'INSERT INTO `task2`
|
||||
(`task_id`, `usr_id_owner`, `pid`, `status`, `crashed`,
|
||||
`active`, `name`, `last_exec_time`, `class`, `settings`, `completed`)
|
||||
VALUES
|
||||
(null, 0, 0, "stopped", 0, 1, "upgrade to v3.1",
|
||||
"0000-00-00 00:00:00", "task_period_upgradetov31",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>' .
|
||||
'<tasksettings></tasksettings>", -1)';
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
|
||||
if ($base->get_base_type() == base::DATA_BOX)
|
||||
{
|
||||
$sql = 'UPDATE record SET sha256 = ""
|
||||
WHERE sha256 IS NULL AND parent_record_id = 0';
|
||||
$stmt = $base->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,77 +1,147 @@
|
||||
<?php
|
||||
|
||||
class patch_3103 implements patch
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_3103 implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.1.0';
|
||||
private $concern = array('application_box');
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$conn = connection::getInstance();
|
||||
|
||||
if (!$conn || !$conn->isok())
|
||||
return true;
|
||||
$conn = $appbox->get_connection();
|
||||
|
||||
$validate_process = array();
|
||||
|
||||
$sql = 'SELECT id, ssel_id, usr_id FROM validate';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($rs = $conn->query($sql))
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
while ($row = $conn->fetch_assoc($rs))
|
||||
{
|
||||
$validate_process[$row['ssel_id']][$row['usr_id']] = $row['id'];
|
||||
}
|
||||
$conn->free_result($rs);
|
||||
$validate_process[$row['ssel_id']][$row['usr_id']] = $row['id'];
|
||||
}
|
||||
|
||||
$sql = 'SELECT u.*, s.ssel_id FROM sselcontusr u, sselcont c, ssel s' .
|
||||
$sql = 'SELECT u.*, s.ssel_id, c.base_id, c.record_id , s.usr_id as pushFrom
|
||||
FROM sselcontusr u, sselcont c, ssel s' .
|
||||
' WHERE s.ssel_id = c.ssel_id AND u.sselcont_id = c.sselcont_id' .
|
||||
' AND s.deleted="0" ' .
|
||||
' ORDER BY s.ssel_id ASC, c.sselcont_id ASC';
|
||||
|
||||
if ($rs = $conn->query($sql))
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
while ($row = $conn->fetch_assoc($rs))
|
||||
if (!isset($validate_process[$row['ssel_id']]) ||
|
||||
!array_key_exists($row['usr_id'], $validate_process[$row['ssel_id']])
|
||||
)
|
||||
{
|
||||
if (!isset($validate_process[$row['ssel_id']]) || !array_key_exists($row['usr_id'], $validate_process[$row['ssel_id']]))
|
||||
{
|
||||
//insert ligne de process
|
||||
|
||||
$expire = new DateTime($row['dateFin']);
|
||||
$expire = $expire->format('u') == 0 ? null : phraseadate::format_mysql($expire);
|
||||
$sql = 'INSERT INTO validate
|
||||
(id, ssel_id, created_on, updated_on, expires_on, last_reminder,
|
||||
usr_id, confirmed, can_agree, can_see_others)
|
||||
VALUES
|
||||
(null, :ssel_id, :created_on, :updated_on, :expires_on, null,
|
||||
:usr_id, "0", :can_agree, :can_see)';
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
||||
$expire = new DateTime($row['dateFin']);
|
||||
$expire = $expire->format('u') == 0 ?
|
||||
null : phraseadate::format_mysql($expire);
|
||||
|
||||
|
||||
$sql = 'INSERT INTO validate
|
||||
(id, ssel_id, created_on, updated_on, expires_on, last_reminder, usr_id, confirmed, can_agree, can_see_others, can_hd) VALUES
|
||||
(null, "' . $conn->escape_string($row['ssel_id']) . '", "' . $conn->escape_string($row['date_maj']) . '", "' . $conn->escape_string($row['date_maj']) . '", ' . ($expire == null ? 'null' : '"' . $conn->escape_string($expire) . '"') . ',
|
||||
null, "' . $conn->escape_string($row['usr_id']) . '", "0", "' . $conn->escape_string($row['canAgree']) . '", "' . $conn->escape_string($row['canSeeOther']) . '", "' . $conn->escape_string($row['canHD']) . '")';
|
||||
$params = array(
|
||||
':ssel_id' => $row['ssel_id']
|
||||
, ':created_on' => $row['date_maj']
|
||||
, ':updated_on' => $row['date_maj']
|
||||
, ':expires_on' => $expire
|
||||
, ':usr_id' => $row['usr_id']
|
||||
, ':can_agree' => $row['canAgree']
|
||||
, ':can_see' => $row['canSeeOther']
|
||||
);
|
||||
$stmt->execute($params);
|
||||
|
||||
if ($conn->query($sql))
|
||||
{
|
||||
$validate_process[$row['ssel_id']][$row['usr_id']] = $conn->insert_id();
|
||||
}
|
||||
}
|
||||
$validate_process[$row['ssel_id']][$row['usr_id']] = $conn->lastInsertId();
|
||||
$stmt->closeCursor();
|
||||
|
||||
//insert ligne d'avis
|
||||
$sbas_id = phrasea::sbasFromBas($row['base_id']);
|
||||
$record = new record_adapter($sbas_id, $row['record_id']);
|
||||
|
||||
$sql = 'INSERT INTO validate_datas
|
||||
(id, validate_id, sselcont_id, updated_on, agreement)
|
||||
VALUES (null, "' . $conn->escape_string($validate_process[$row['ssel_id']][$row['usr_id']]) . '", "' . $conn->escape_string($row['sselcont_id']) . '", "' . $conn->escape_string($row['date_maj']) . '", "' . $conn->escape_string($row['agree']) . '")';
|
||||
$conn->query($sql);
|
||||
$user = User_Adapter::getInstance($row['usr_id'], $appbox);
|
||||
$pusher = User_Adapter::getInstance($row['pushFrom'], $appbox);
|
||||
|
||||
if ($row['canHD'])
|
||||
$user->ACL()->grant_hd_on($record, $pusher, 'validate');
|
||||
else
|
||||
$user->ACL()->grant_preview_on($record, $pusher, 'validate');
|
||||
}
|
||||
$conn->free_result($rs);
|
||||
|
||||
$sql = 'REPLACE INTO validate_datas
|
||||
(id, validate_id, sselcont_id, updated_on, agreement)
|
||||
VALUES
|
||||
(null, :validate_id, :sselcont_id, :updated_on, :agreement)';
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
||||
$params = array(
|
||||
':validate_id' => $validate_process[$row['ssel_id']][$row['usr_id']]
|
||||
, ':sselcont_id' => $row['sselcont_id']
|
||||
, ':updated_on' => $row['date_maj']
|
||||
, ':agreement' => $row['agree']
|
||||
);
|
||||
$stmt->execute($params);
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -1,31 +1,66 @@
|
||||
<?php
|
||||
|
||||
class patch_311 implements patch
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_311 implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.1.1';
|
||||
private $concern = array('data_box');
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
function apply(base &$databox)
|
||||
{
|
||||
$sql = 'UPDATE record SET jeton = '
|
||||
. (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF);
|
||||
|
||||
$connbas = connection::getInstance($id);
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
if (!$connbas || !$connbas->isok())
|
||||
return false;
|
||||
|
||||
$sql = 'UPDATE record SET jeton=' . (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF) . '';
|
||||
$connbas->query($sql);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
67
lib/classes/patch/320.class.php
Normal file
67
lib/classes/patch/320.class.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320 implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a1';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$databox)
|
||||
{
|
||||
$sql = 'UPDATE record SET parent_record_id = "1"
|
||||
WHERE parent_record_id != "0"';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
104
lib/classes/patch/320a.class.php
Normal file
104
lib/classes/patch/320a.class.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320a implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a2';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$sql = 'SELECT * FROM usr WHERE nonce IS NULL';
|
||||
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'UPDATE usr SET nonce = :nonce WHERE usr_id = :usr_id';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
$nonce = random::generatePassword(16);
|
||||
$params = array(':usr_id' => $row['usr_id'], ':nonce' => $nonce);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
|
||||
|
||||
$sql = 'SELECT task_id, `class` FROM task2';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$tasks = array();
|
||||
|
||||
$sql = 'UPDATE task2 SET `class` = :class WHERE task_id = :task_id';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
if (strpos($row['class'], 'task_period_') !== false)
|
||||
continue;
|
||||
|
||||
$params = array(
|
||||
':task_id' => $row['task_id']
|
||||
, ':class' => str_replace('task_', 'task_period_', $row['class'])
|
||||
);
|
||||
|
||||
$stmt->execute($params);
|
||||
}
|
||||
|
||||
$stmt->closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
112
lib/classes/patch/320aa.class.php
Normal file
112
lib/classes/patch/320aa.class.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320aa implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a1';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
define('GV_STATIC_URL', '');
|
||||
define('GV_sphinx', false);
|
||||
define('GV_sphinx_host', '');
|
||||
define('GV_sphinx_port', '');
|
||||
define('GV_sphinx_rt_host', '');
|
||||
define('GV_sphinx_rt_port', '');
|
||||
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
foreach ($GV as $section => $datas_section)
|
||||
{
|
||||
foreach ($datas_section['vars'] as $datas)
|
||||
{
|
||||
|
||||
$registry->un_set($datas['name']);
|
||||
eval('$test = defined("' . $datas["name"] . '");');
|
||||
if (!$test)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
eval('$val = ' . $datas["name"] . ';');
|
||||
|
||||
$val = $val === true ? '1' : $val;
|
||||
$val = $val === false ? '0' : $val;
|
||||
|
||||
if($datas['name'] == 'GV_exiftool' && strpos($val, 'lib/exiftool/exiftool') !== false)
|
||||
{
|
||||
$val = str_replace('lib/exiftool/exiftool', 'lib/vendor/exiftool/exiftool', $val);
|
||||
}
|
||||
|
||||
switch ($datas['type'])
|
||||
{
|
||||
case registry::TYPE_ENUM_MULTI:
|
||||
case registry::TYPE_INTEGER:
|
||||
case registry::TYPE_BOOLEAN:
|
||||
case registry::TYPE_STRING:
|
||||
case registry::TYPE_ARRAY:
|
||||
$type = $datas['type'];
|
||||
break;
|
||||
default:
|
||||
$type = registry::TYPE_STRING;
|
||||
break;
|
||||
}
|
||||
$registry->set($datas['name'], $val, $type);
|
||||
}
|
||||
}
|
||||
$registry->un_set('registry_loaded');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
71
lib/classes/patch/320ab.class.php
Normal file
71
lib/classes/patch/320ab.class.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320ab implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a1';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$sql = 'REPLACE INTO records_rights
|
||||
(SELECT null as id, usr_id, b.sbas_id, record_id, "1" as document
|
||||
, null as preview, "push" as `case`, pushFrom as pusher_usr_id
|
||||
FROM sselcont c, ssel s, bas b
|
||||
WHERE c.ssel_id = s.ssel_id
|
||||
AND b.base_id = c.base_id AND c.canHD = 1
|
||||
)';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
67
lib/classes/patch/320b.class.php
Normal file
67
lib/classes/patch/320b.class.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
|
||||
class patch_320b implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a3';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$sql = 'UPDATE basusr SET nowatermark=1 WHERE needwatermark=0';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
unset($stmt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
166
lib/classes/patch/320c.class.php
Normal file
166
lib/classes/patch/320c.class.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320c implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a4';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$databox)
|
||||
{
|
||||
$sql = 'TRUNCATE metadatas';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'TRUNCATE metadatas_structure';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'TRUNCATE technical_datas';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
|
||||
$phrasea_maps = array(
|
||||
'pdftext' => '/rdf:RDF/rdf:Description/PHRASEANET:pdftext'
|
||||
, 'tf-archivedate' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-archivedate'
|
||||
, 'tf-atime' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-atime'
|
||||
, 'tf-chgdocdate' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-chgdocdate'
|
||||
, 'tf-ctime' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-ctime'
|
||||
, 'tf-editdate' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-editdate'
|
||||
, 'tf-mtime' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-mtime'
|
||||
, 'tf-parentdir' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-parentdir'
|
||||
, 'tf-bits' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-bits'
|
||||
, 'tf-channels' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-channels'
|
||||
, 'tf-extension' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-extension'
|
||||
, 'tf-filename' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename'
|
||||
, 'tf-filepath' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-filepath'
|
||||
, 'tf-height' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-height'
|
||||
, 'tf-mimetype' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-mimetype'
|
||||
, 'tf-recordid' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-recordid'
|
||||
, 'tf-size' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-size'
|
||||
, 'tf-width' => '/rdf:RDF/rdf:Description/PHRASEANET:tf-width'
|
||||
);
|
||||
|
||||
$sxe = $databox->get_sxml_structure();
|
||||
$dom_struct = $databox->get_dom_structure();
|
||||
$xp_struct = $databox->get_xpath_structure();
|
||||
|
||||
foreach ($sxe->description->children() as $fname => $field)
|
||||
{
|
||||
$src = trim(isset($field['src']) ? $field['src'] : '');
|
||||
|
||||
if (array_key_exists($src, $phrasea_maps))
|
||||
{
|
||||
$src = $phrasea_maps[$src];
|
||||
}
|
||||
|
||||
$nodes = $xp_struct->query('/record/description/' . $fname);
|
||||
if ($nodes->length > 0)
|
||||
{
|
||||
$node = $nodes->item(0);
|
||||
$node->setAttribute('src', $src);
|
||||
$node->removeAttribute('meta_id');
|
||||
}
|
||||
}
|
||||
|
||||
$databox->saveStructure($dom_struct);
|
||||
|
||||
$ext_databox = new extended_databox($databox->get_sbas_id());
|
||||
$ext_databox->migrate_fields();
|
||||
|
||||
$databox->delete_data_from_cache(databox::CACHE_STRUCTURE);
|
||||
$databox->delete_data_from_cache(databox::CACHE_META_STRUCT);
|
||||
|
||||
|
||||
$conn = connection::getPDOConnection();
|
||||
$sql = 'INSERT INTO `task2`
|
||||
(`task_id`, `usr_id_owner`, `pid`, `status`, `crashed`,
|
||||
`active`, `name`, `last_exec_time`, `class`, `settings`, `completed`)
|
||||
VALUES
|
||||
(null, 0, 0, "stopped", 0, 1, "upgrade to v3.2 for sbas ' . $databox->get_sbas_id() . '",
|
||||
"0000-00-00 00:00:00", "task_period_upgradetov32",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>' .
|
||||
'<tasksettings><sbas_id>' . $databox->get_sbas_id() . '</sbas_id></tasksettings>", -1)';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'DELETE FROM `task2` WHERE class="readmeta"';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
unset($stmt);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class extended_databox extends databox
|
||||
{
|
||||
public function __construct($sbas_id)
|
||||
{
|
||||
parent::__construct($sbas_id);
|
||||
}
|
||||
|
||||
|
||||
public function migrate_fields()
|
||||
{
|
||||
$this->feed_meta_fields();
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
82
lib/classes/patch/320d.class.php
Normal file
82
lib/classes/patch/320d.class.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320d implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a5';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
|
||||
$sql = 'SELECT base_id, usr_id FROM order_masters';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'UPDATE basusr SET order_master="1"
|
||||
WHERE base_id = :base_id AND usr_id = :usr_id';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
$params = array(
|
||||
':base_id' => $row['base_id'],
|
||||
':usr_id' => $row['usr_id']
|
||||
);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
|
||||
$stmt->closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
96
lib/classes/patch/320e.class.php
Normal file
96
lib/classes/patch/320e.class.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320e implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a6';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::DATA_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$databox)
|
||||
{
|
||||
$sql = 'UPDATE record r, subdef s
|
||||
SET r.mime = s.mime
|
||||
WHERE r.record_id = s.record_id AND s.name="document"';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'UPDATE subdef s, record r
|
||||
SET s.updated_on = r.moddate, s.created_on = r.credate
|
||||
WHERE s.record_id = r.record_id';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'UPDATE subdef SET `name` = LOWER( `name` )';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
|
||||
$dom = $databox->get_dom_structure();
|
||||
$xpath = $databox->get_xpath_structure();
|
||||
|
||||
$nodes = $xpath->query('//record/subdefs/subdefgroup/subdef');
|
||||
|
||||
foreach ($nodes as $node)
|
||||
{
|
||||
$name = mb_strtolower(trim($node->getAttribute('name')));
|
||||
if ($name === '')
|
||||
continue;
|
||||
$node->setAttribute('name', $name);
|
||||
}
|
||||
|
||||
$databox->saveStructure($dom);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
195
lib/classes/patch/320f.class.php
Normal file
195
lib/classes/patch/320f.class.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320f implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a4';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$feeds = array();
|
||||
|
||||
$sql = 'SELECT ssel_id, usr_id, name, descript, pub_date
|
||||
, updater, pub_restrict, homelink
|
||||
FROM ssel WHERE public = "1" or homelink="1"';
|
||||
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$date_ref = new DateTime();
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
$user = User_Adapter::getInstance($row['usr_id'], $appbox);
|
||||
|
||||
$feed = $this->get_feed($appbox, $user, $row['pub_restrict'], $row['homelink']);
|
||||
|
||||
|
||||
$entry = Feed_Entry_Adapter::create($appbox, $feed, array_shift($feed->get_publishers()), $row['name'], $row['descript'], $user->get_display_name(), $user->get_email());
|
||||
$date_create = new DateTime($row['pub_date']);
|
||||
if ($date_create < $date_ref)
|
||||
{
|
||||
$date_ref = $date_create;
|
||||
}
|
||||
$entry->set_created_on($date_create);
|
||||
if ($row['updater'] != '0000-00-00 00:00:00')
|
||||
{
|
||||
$date_update = new DateTime($row['updater']);
|
||||
$entry->set_updated_on($date_update);
|
||||
}
|
||||
|
||||
$sql = 'SELECT sselcont_id, ssel_id, base_id, record_id
|
||||
FROM sselcont WHERE ssel_id = :ssel_id ORDER BY ord ASC';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':ssel_id' => $row['ssel_id']));
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
try
|
||||
{
|
||||
$record = new record_adapter(phrasea::sbasFromBas($row['base_id']), $row['record_id']);
|
||||
$item = Feed_Entry_Item::create($appbox, $entry, $record);
|
||||
}
|
||||
catch (Exception_NotFound $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'UPDATE ssel SET deleted = "1" WHERE ssel_id = :ssel_id';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':ssel_id' => $row['ssel_id']));
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
$this->set_feed_dates($date_ref);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function set_feed_dates(DateTime $date_ref)
|
||||
{
|
||||
foreach (self::$feeds as $array_feeds)
|
||||
{
|
||||
foreach ($array_feeds as $feed)
|
||||
{
|
||||
$feed->set_created_on($date_ref);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
protected static $feeds = array();
|
||||
|
||||
protected function get_feed(appbox &$appbox, User_Adapter &$user, $pub_restrict, $homelink)
|
||||
{
|
||||
$user_key = 'user_' . $user->get_id();
|
||||
if ($homelink == '1')
|
||||
$feed_key = 'feed_homelink';
|
||||
elseif ($pub_restrict == '1')
|
||||
$feed_key = 'feed_restricted';
|
||||
else
|
||||
$feed_key = 'feed_public';
|
||||
|
||||
if (!array_key_exists($user_key, self::$feeds) || !isset(self::$feeds[$user_key][$feed_key]))
|
||||
{
|
||||
if ($homelink == '1')
|
||||
$title = $user->get_display_name() . ' - ' . 'homelink Feed';
|
||||
elseif ($pub_restrict == '1')
|
||||
$title = $user->get_display_name() . ' - ' . 'private Feed';
|
||||
else
|
||||
$title = $user->get_display_name() . ' - ' . 'public Feed';
|
||||
|
||||
$feed = Feed_Adapter::create($appbox, $user, $title, '');
|
||||
|
||||
if ($homelink)
|
||||
{
|
||||
$feed->set_public(true);
|
||||
}
|
||||
elseif ($pub_restrict == 1)
|
||||
{
|
||||
$collection = array_shift($user->ACL()->get_granted_base());
|
||||
if (!($collection instanceof collection))
|
||||
{
|
||||
foreach ($appbox->get_databoxes() as $databox)
|
||||
{
|
||||
foreach ($databox->get_collections() as $coll)
|
||||
{
|
||||
$collection = $coll;
|
||||
break;
|
||||
}
|
||||
if ($collection instanceof collection)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!($collection instanceof collection))
|
||||
{
|
||||
echo "unable to find a collection to protect feeds";
|
||||
|
||||
return false;
|
||||
}
|
||||
$feed->set_collection($collection);
|
||||
}
|
||||
self::$feeds[$user_key][$feed_key] = $feed;
|
||||
}
|
||||
else
|
||||
{
|
||||
$feed = self::$feeds[$user_key][$feed_key];
|
||||
}
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
}
|
66
lib/classes/patch/320g.class.php
Normal file
66
lib/classes/patch/320g.class.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class patch_320g implements patchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.2.0.0.a8';
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
$sql = 'INSERT INTO bridge_site (id, `type`) VALUES (null, "dailymotion")';
|
||||
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user