mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
initial import
This commit is contained in:
117
lib/classes/patch/303.class.php
Normal file
117
lib/classes/patch/303.class.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
class patch_303 implements patch
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
31
lib/classes/patch/304.class.php
Normal file
31
lib/classes/patch/304.class.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
class patch_304 implements patch
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
28
lib/classes/patch/305.class.php
Normal file
28
lib/classes/patch/305.class.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
class patch_305 implements patch
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
61
lib/classes/patch/306.class.php
Normal file
61
lib/classes/patch/306.class.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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);
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
169
lib/classes/patch/310.class.php
Normal file
169
lib/classes/patch/310.class.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
class patch_310 implements patch
|
||||
{
|
||||
|
||||
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"));
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
53
lib/classes/patch/3102.class.php
Normal file
53
lib/classes/patch/3102.class.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
class patch_3102 implements patch
|
||||
{
|
||||
|
||||
private $release = '3.1.0';
|
||||
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);
|
||||
|
||||
|
||||
if(!function_exists('phrasea_uuid_create'))
|
||||
{
|
||||
echo "<div style='padding:5px;background-color:red;color:black;'>".
|
||||
sprintf(_('Attention, la fonction %s est indisponible, vous devriez mettre a jour lextension phrasea dans sa derniere version'), 'phrasea_uuid_create').
|
||||
"</div>";
|
||||
}
|
||||
if(!function_exists('phrasea_uuid_is_valid'))
|
||||
{
|
||||
echo "<div style='padding:5px;background-color:red;color:black;'>".
|
||||
sprintf(_('Attention, la fonction %s est indisponible, vous devriez mettre a jour lextension phrasea dans sa derniere version'), 'phrasea_uuid_is_valid').
|
||||
"</div>";
|
||||
}
|
||||
if(!function_exists('phrasea_uuid_compare'))
|
||||
{
|
||||
echo "<div style='padding:5px;background-color:red;color:black;'>".
|
||||
sprintf(_('Attention, la fonction %s est indisponible, vous devriez mettre a jour lextension phrasea dans sa derniere version'), 'phrasea_uuid_compare').
|
||||
"</div>";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
80
lib/classes/patch/3103.class.php
Normal file
80
lib/classes/patch/3103.class.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
class patch_3103 implements patch
|
||||
{
|
||||
|
||||
private $release = '3.1.0';
|
||||
private $concern = array('application_box');
|
||||
|
||||
function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
function apply($id)
|
||||
{
|
||||
$conn = connection::getInstance();
|
||||
|
||||
if (!$conn || !$conn->isok())
|
||||
return true;
|
||||
|
||||
$validate_process = array();
|
||||
|
||||
$sql = 'SELECT id, ssel_id, usr_id FROM validate';
|
||||
|
||||
if ($rs = $conn->query($sql))
|
||||
{
|
||||
while ($row = $conn->fetch_assoc($rs))
|
||||
{
|
||||
$validate_process[$row['ssel_id']][$row['usr_id']] = $row['id'];
|
||||
}
|
||||
$conn->free_result($rs);
|
||||
}
|
||||
|
||||
$sql = 'SELECT u.*, s.ssel_id 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))
|
||||
{
|
||||
while ($row = $conn->fetch_assoc($rs))
|
||||
{
|
||||
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, 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']) . '")';
|
||||
|
||||
if ($conn->query($sql))
|
||||
{
|
||||
$validate_process[$row['ssel_id']][$row['usr_id']] = $conn->insert_id();
|
||||
}
|
||||
}
|
||||
|
||||
//insert ligne d'avis
|
||||
|
||||
$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);
|
||||
}
|
||||
$conn->free_result($rs);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
33
lib/classes/patch/311.class.php
Normal file
33
lib/classes/patch/311.class.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class patch_311 implements patch
|
||||
{
|
||||
|
||||
private $release = '3.1.1';
|
||||
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 = 'UPDATE record SET jeton=' . (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF) . '';
|
||||
$connbas->query($sql);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user