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

This commit is contained in:
Ysolyne Gresille
2012-03-08 17:27:47 +01:00
176 changed files with 16803 additions and 31803 deletions

View File

@@ -204,6 +204,25 @@ class API_V1_adapter extends API_V1_Abstract
return $result;
}
public function caption_records(Request $request, $databox_id, $record_id)
{
$result = new API_V1_result($request, $this);
$record = $this->appbox->get_databox($databox_id)->get_record($record_id);
$fields = $record->get_caption()->get_fields();
$ret = array();
foreach ($fields as $field)
{
$ret[$field->get_meta_struct_id()] = array(
'meta_structure_id' => $field->get_meta_struct_id()
, 'name' => $field->get_name()
, 'value' => $field->get_serialized_values(";")
);
}
$result->set_datas($ret);
return $result;
}
/**
* Get an API_V1_result containing the results of a records search
*

View File

@@ -130,5 +130,19 @@ class Bridge_Api_Dailymotion_Container implements Bridge_Api_ContainerInterface
{
return $this->url;
}
public function get_duration()
{
return '';
}
public function get_category()
{
return '';
}
public function is_private()
{
return null;
}
}

View File

@@ -138,4 +138,19 @@ class Bridge_Api_Flickr_Container implements Bridge_Api_ContainerInterface
return $this->type;
}
public function get_duration()
{
return '';
}
public function get_category()
{
return '';
}
public function is_private()
{
return null;
}
}

View File

@@ -210,7 +210,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
*/
public function get_category()
{
return null;
return '';
}
/**
@@ -219,7 +219,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
*/
public function get_duration()
{
return null;
return '';
}
/**
@@ -279,5 +279,4 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
{
return $this->entry["tags"];
}
}

View File

@@ -117,4 +117,20 @@ class Bridge_Api_Youtube_Container implements Bridge_Api_ContainerInterface
return $this->type;
}
public function get_duration()
{
return '';
}
public function get_category()
{
return '';
}
public function is_private()
{
return null;
}
}

View File

@@ -558,7 +558,7 @@ class Session_Handler
$browser = Browser::getInstance();
if($this->is_authenticated())
$user = User_Adapter::getInstance ($this->get_usr_id (), appbox::get_instance ());
$user = User_Adapter::getInstance ($this->get_usr_id (), appbox::get_instance (\bootstrap::getCore()));
return Session_Logger::create($databox, $browser, $this, $user);
}

View File

@@ -456,15 +456,6 @@ class appbox extends base
$cacheService = "array_cache";
if (extension_loaded('apc'))
{
$cacheService = "apc_cache";
}
elseif (extension_loaded('xcache'))
{
$cacheService = "xcache_cache";
}
$Core->getConfiguration()->setConnexions($connexion);
$services = $Core->getConfiguration()->getConfigurations();
@@ -474,7 +465,7 @@ class appbox extends base
if ($serviceName === "doctrine_prod")
{
$services["doctrine_prod"]["options"]["orm"]["cache"] = array(
$services["doctrine_prod"]["options"]["cache"] = array(
"query" => $cacheService,
"result" => $cacheService,
"metadata" => $cacheService
@@ -499,7 +490,7 @@ class appbox extends base
}
$Core->getConfiguration()->setConfigurations($arrayConf);
$Core->getConfiguration()->setEnvironnement('prod');
}
try

View File

@@ -60,11 +60,12 @@ abstract class base implements cache_cacheableInterface
/**
*
*/
const APPLICATION_BOX = 'APPLICATION_BOX';
/**
*
*/
const DATA_BOX = 'DATA_BOX';
const DATA_BOX = 'DATA_BOX';
/**
*
@@ -78,7 +79,6 @@ abstract class base implements cache_cacheableInterface
public function get_schema()
{
if ($this->schema)
return $this->schema;
$this->load_schema();
@@ -178,7 +178,7 @@ abstract class base implements cache_cacheableInterface
public function get_data_from_cache($option = null)
{
if($this->get_base_type() == self::DATA_BOX)
if ($this->get_base_type() == self::DATA_BOX)
{
\cache_databox::refresh($this->id);
}
@@ -232,7 +232,6 @@ abstract class base implements cache_cacheableInterface
{
if ($this->version)
return $this->version;
$version = '0.0.0';
@@ -245,9 +244,9 @@ abstract class base implements cache_cacheableInterface
if ($sql !== '')
{
$stmt = $this->get_connection()->prepare($sql);
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row)
$version = $row['version'];
@@ -261,10 +260,8 @@ abstract class base implements cache_cacheableInterface
public function upgradeavailable()
{
if ($this->get_version())
return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>');
else
return true;
}
@@ -281,13 +278,25 @@ abstract class base implements cache_cacheableInterface
$upgrader->add_steps(count($allTables) + 1);
$sql = "SHOW TABLE STATUS";
$sql = "SHOW TABLE STATUS";
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$ORMTables = array(
'BasketElements',
'Baskets',
'StoryWZ',
'UsrListOwners',
'UsrLists',
'UsrListsContent',
'ValidationDatas',
'ValidationParticipants',
'ValidationSessions',
);
foreach ($rs as $row)
{
$tname = $row["Name"];
@@ -296,7 +305,7 @@ abstract class base implements cache_cacheableInterface
{
$upgrader->set_current_message(sprintf(_('Updating table %s'), $tname));
$engine = strtolower(trim($allTables[$tname]->engine));
$engine = strtolower(trim($allTables[$tname]->engine));
$ref_engine = strtolower($row['Engine']);
if ($engine != $ref_engine && in_array($engine, array('innodb', 'myisam')))
@@ -311,22 +320,22 @@ abstract class base implements cache_cacheableInterface
catch (Exception $e)
{
$recommends[] = array(
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $sql
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $sql
);
}
}
$ret = self::upgradeTable($allTables[$tname]);
$ret = self::upgradeTable($allTables[$tname]);
$recommends = array_merge($recommends, $ret);
unset($allTables[$tname]);
$upgrader->add_steps_complete(1);
}
else
elseif (!in_array($tname, $ORMTables))
{
$recommends[] = array(
'message' => 'Une table pourrait etre supprime',
'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;'
'message' => 'Une table pourrait etre supprime',
'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;'
);
}
}
@@ -390,7 +399,6 @@ abstract class base implements cache_cacheableInterface
protected function load_schema()
{
if ($this->schema)
return $this;
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
@@ -434,7 +442,7 @@ abstract class base implements cache_cacheableInterface
*/
protected function createTable(SimpleXMLElement $table)
{
$field_stmt = $defaults_stmt = array();
$field_stmt = $defaults_stmt = array();
$create_stmt = "CREATE TABLE `" . $table['name'] . "` (";
@@ -451,8 +459,8 @@ abstract class base implements cache_cacheableInterface
$character_set = '';
if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext'))
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
{
$collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci';
@@ -463,8 +471,8 @@ abstract class base implements cache_cacheableInterface
}
$field_stmt[] = " `" . $field->name . "` " . $field->type . " "
. $field->extra . " " . $character_set . " "
. $is_default . " " . $isnull . "";
. $field->extra . " " . $character_set . " "
. $is_default . " " . $isnull . "";
}
@@ -482,7 +490,7 @@ abstract class base implements cache_cacheableInterface
$primary_fields[] = "`" . $field . "`";
}
$field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')';
$field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')';
break;
case "UNIQUE":
$unique_fields = array();
@@ -511,32 +519,32 @@ abstract class base implements cache_cacheableInterface
{
foreach ($table->defaults->default as $default)
{
$k = $v = $params = $dates_values = array();
$k = $v = $params = $dates_values = array();
$nonce = random::generatePassword(16);
foreach ($default->data as $data)
{
$k = trim($data['key']);
$k = trim($data['key']);
if ($k === 'usr_password')
$data = User_Adapter::salt_password($data, $nonce);
if ($k === 'nonce')
$data = $nonce;
$v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data));
$v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data));
if (trim(mb_strtolower($v)) == 'now()')
$dates_values [$k] = 'NOW()';
else
$params[$k] = (trim(mb_strtolower($v)) == 'null' ? null : $v);
$params[$k] = (trim(mb_strtolower($v)) == 'null' ? null : $v);
}
$separator = ((count($params) > 0 && count($dates_values) > 0) ? ', ' : '');
$defaults_stmt[] = array(
'sql' =>
'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params))
. $separator . implode(', ', array_keys($dates_values)) . ')
'sql' =>
'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params))
. $separator . implode(', ', array_keys($dates_values)) . ')
VALUES (:' . implode(', :', array_keys($params))
. $separator . implode(', ', array_values($dates_values)) . ') '
, 'params' => $params
. $separator . implode(', ', array_values($dates_values)) . ') '
, 'params' => $params
);
}
}
@@ -562,8 +570,8 @@ abstract class base implements cache_cacheableInterface
catch (Exception $e)
{
$recommends[] = array(
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $def['sql']
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $def['sql']
);
}
}
@@ -574,7 +582,7 @@ abstract class base implements cache_cacheableInterface
protected function upgradeTable(SimpleXMLElement $table)
{
$correct_table = array('fields' => array(), 'indexes' => array(), 'collation' => array());
$alter = $alter_pre = $return = array();
$alter = $alter_pre = $return = array();
$registry = registry::get_instance();
@@ -589,8 +597,8 @@ abstract class base implements cache_cacheableInterface
$collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci';
if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext'))
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
{
$code = array_pop(array_reverse(explode('_', $collation)));
@@ -618,7 +626,7 @@ abstract class base implements cache_cacheableInterface
foreach ($table->indexes->index as $index)
{
$i_name = (string) $index->name;
$expr = array();
$expr = array();
foreach ($index->fields->field as $field)
$expr[] = '`' . trim((string) $field) . '`';
@@ -630,25 +638,25 @@ abstract class base implements cache_cacheableInterface
$correct_table['indexes']['PRIMARY'] = 'PRIMARY KEY (' . $expr . ')';
break;
case "UNIQUE":
$correct_table['indexes'][$i_name] = 'UNIQUE KEY `' . $i_name . '` (' . $expr . ')';
$correct_table['indexes'][$i_name] = 'UNIQUE KEY `' . $i_name . '` (' . $expr . ')';
break;
case "INDEX":
$correct_table['indexes'][$i_name] = 'KEY `' . $i_name . '` (' . $expr . ')';
$correct_table['indexes'][$i_name] = 'KEY `' . $i_name . '` (' . $expr . ')';
break;
}
}
}
$sql = "SHOW FULL FIELDS FROM `" . $table['name'] . "`";
$sql = "SHOW FULL FIELDS FROM `" . $table['name'] . "`";
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs2 as $row2)
{
$f_name = $row2['Field'];
$f_name = $row2['Field'];
$expr_found = trim($row2['Type']);
$_extra = $row2['Extra'];
@@ -727,8 +735,8 @@ abstract class base implements cache_cacheableInterface
else
{
$return[] = array(
'message' => 'Un champ pourrait etre supprime',
'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;"
'message' => 'Un champ pourrait etre supprime',
'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;"
);
}
}
@@ -739,16 +747,16 @@ abstract class base implements cache_cacheableInterface
}
$tIndex = array();
$sql = "SHOW INDEXES FROM `" . $table['name'] . "`";
$sql = "SHOW INDEXES FROM `" . $table['name'] . "`";
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs2 as $row2)
{
if (!isset($tIndex[$row2['Key_name']]))
$tIndex[$row2['Key_name']] = array('unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => array());
$tIndex[$row2['Key_name']] = array('unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => array());
$tIndex[$row2['Key_name']]['columns'][(int) ($row2['Seq_in_index'])] = $row2['Column_name'];
}
@@ -786,8 +794,8 @@ abstract class base implements cache_cacheableInterface
else
{
$return[] = array(
'message' => 'Un index pourrait etre supprime',
'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';'
'message' => 'Un index pourrait etre supprime',
'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';'
);
}
}
@@ -806,8 +814,8 @@ abstract class base implements cache_cacheableInterface
catch (Exception $e)
{
$return[] = array(
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $a
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $a
);
}
}
@@ -823,8 +831,8 @@ abstract class base implements cache_cacheableInterface
catch (Exception $e)
{
$return[] = array(
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $a
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
'sql' => $a
);
}
}
@@ -882,8 +890,8 @@ abstract class base implements cache_cacheableInterface
}
$upgrader->add_steps_complete(1)
->add_steps(count($list_patches))
->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname()));
->add_steps(count($list_patches))
->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname()));
ksort($list_patches);
$success = true;

View File

@@ -50,10 +50,6 @@ class caption_record implements caption_interface, cache_cacheableInterface
$this->record = $record;
$this->databox = $databox;
$this->retrieve_fields();
return $this;
}
@@ -182,7 +178,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null)
{
$fields = array();
foreach ($this->fields as $meta_struct_id => $field)
foreach ($this->retrieve_fields() as $meta_struct_id => $field)
{
if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields))
continue;

View File

@@ -991,13 +991,6 @@ class databox extends base
{
}
if (isset($field['regname']))
$meta_struct_field->set_regname();
if (isset($field['regdate']))
$meta_struct_field->set_regdate();
if (isset($field['regdesc']))
$meta_struct_field->set_regdesc();
}
return $this;

View File

@@ -98,24 +98,6 @@ class databox_field implements cache_cacheableInterface
*/
protected $thumbtitle;
/**
*
* @var <type>
*/
protected $regdate;
/**
*
* @var <type>
*/
protected $regdesc;
/**
*
* @var <type>
*/
protected $regname;
/**
*
* @var int
@@ -163,7 +145,7 @@ class databox_field implements cache_cacheableInterface
$connbas = $this->get_connection();
$sql = "SELECT `regdate`, `regdesc`, `regname`, `thumbtitle`, `separator`
$sql = "SELECT `thumbtitle`, `separator`
, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`
, `readonly`, `indexable`, `name`, `src`
, `VocabularyControlType`, `RestrictToVocabularyControl`
@@ -216,10 +198,6 @@ class databox_field implements cache_cacheableInterface
$this->separator = $separator;
$this->thumbtitle = $row['thumbtitle'];
$this->regdesc = !!$row['regdesc'];
$this->regname = !!$row['regname'];
$this->regdate = !!$row['regdate'];
return $this;
}
@@ -621,39 +599,6 @@ class databox_field implements cache_cacheableInterface
return $this;
}
/**
*
* @return databox_field
*/
public function set_regdate()
{
$this->set_reg_attr('date');
return $this;
}
/**
*
* @return databox_field
*/
public function set_regdesc()
{
$this->set_reg_attr('desc');
return $this;
}
/**
*
* @return databox_field
*/
public function set_regname()
{
$this->set_reg_attr('name');
return $this;
}
/**
*
* @param string $attr
@@ -683,33 +628,6 @@ class databox_field implements cache_cacheableInterface
return $this;
}
/**
*
* @return boolean
*/
public function is_regname()
{
return $this->regname;
}
/**
*
* @return boolean
*/
public function is_regdesc()
{
return $this->regdesc;
}
/**
*
* @return boolean
*/
public function is_regdate()
{
return $this->regdate;
}
/**
*
* @return string
@@ -870,10 +788,10 @@ class databox_field implements cache_cacheableInterface
$sql = "INSERT INTO metadatas_structure
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
`thumbtitle`, `multi`, `regname`, `regdesc`, `regdate` ,
`thumbtitle`, `multi`,
`report`, `sorter`)
VALUES (null, :name, '', 0, 1, 'text', '',
null, 0, null, null, null,
null, 0,
1, :sorter)";
$stmt = $databox->get_connection()->prepare($sql);

View File

@@ -0,0 +1,177 @@
<?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 eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
{
const MAIL_NO_VALID = 1;
const MAIL_FAIL = 2;
/**
*
* @var string
*/
public $events = array('__EXPORT_MAIL_FAIL__');
/**
*
* @return string
*/
public function icon_url()
{
return '/skins/icons/user.png';
}
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return Void
*/
public function fire($event, $params, &$object)
{
$default = array(
'usr_id' => null
, 'lst' => ''
, 'ssttid' => ''
, 'dest' => ''
, 'reason' => ''
);
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$lst = $dom_xml->createElement('lst');
$ssttid = $dom_xml->createElement('ssttid');
$dest = $dom_xml->createElement('dest');
$reason = $dom_xml->createElement('reason');
$lst->appendChild($dom_xml->createTextNode($params['lst']));
$ssttid->appendChild($dom_xml->createTextNode($params['ssttid']));
$dest->appendChild($dom_xml->createTextNode($params['dest']));
$reason->appendChild($dom_xml->createTextNode($params['reason']));
$root->appendChild($lst);
$root->appendChild($ssttid);
$root->appendChild($dest);
$root->appendChild($reason);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['usr_id']) != '0');
if ($send_notif)
{
$user = User_Adapter::getInstance($params['usr_id'], $this->appbox);
$name = $user->get_display_name();
$to = array('email' => $user->get_email(), 'name' => $name);
$from = array(
'email' => $this->registry->get('GV_defaulmailsenderaddr'),
'name' => $this->registry->get('GV_homeTitle')
);
if (parent::email())
$mailed = true;
}
$this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
return;
}
/**
*
* @param Array $datas
* @param boolean $unread
* @return Array
*/
public function datas($datas, $unread)
{
$sx = simplexml_load_string($datas);
$usr_id = (int) $sx->usr_id;
$reason = (int) $sx->reason;
$lst = (string) $sx->lst;
$ssttid = (int) $sx->ssttid;
$dest = (string) $sx->dest;
if ($reason == self::MAIL_NO_VALID)
{
$reason = _('email is not valid');
}
elseif ($reason == self::MAIL_FAIL)
{
$reason = _('failed to send mail');
}
else
{
$reason = _('an error occured while exporting records');
}
$text = sprintf(
_("The delivery to %s failed for the following reason : %s")
, $dest
, $reason
);
$ret = array(
'text' => $text
, 'class' => ''
);
return $ret;
}
/**
*
* @return string
*/
public function get_name()
{
return _('Email export fails');
}
/**
*
* @return string
*/
public function get_description()
{
return _('Get a notification when a mail export fails');
}
/**
*
* @return boolean
*/
function is_available()
{
return true;
}
}

View File

@@ -208,8 +208,9 @@ class mail
$body = eregi_replace("[\]", '', $body);
$body .= "<br/>\n"._('Si le lien n\'est pas cliquable, copiez-collez le dans votre navigateur.')."<br/>\n";
$body .= "<br/><br/><br/><br/>\n\n\n\n";
$body .= '<div style="font-style:italic;">'._('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.').'</div>';
$body .= "<br/>\n";
$body .= '<div style="font-style:italic;">' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "</div>\n";
$body .= '<div><a href="' . $registry->get('GV_ServerName') . '">' . $registry->get('GV_ServerName') . "</a></div>\n";
$body = '<body>' . $body . '</body>';
@@ -258,7 +259,7 @@ class mail
$mail->ConfirmReadingTo = $reading_confirm_to;
}
$mail->MsgHTML(strip_tags($body, '<div><br><ul><li>'));
$mail->MsgHTML(strip_tags($body, '<div><br><ul><li><em><strong><span><br>'));
foreach ($files as $f)
{

View File

@@ -143,7 +143,7 @@ class module_console_fileConfigCheck extends Command
private function checkParse(OutputInterface $output)
{
if (!$this->configuration->getConfigurations())
if (!$this->configuration)
{
throw new \Exception("Unable to load configurations\n");
}
@@ -163,7 +163,7 @@ class module_console_fileConfigCheck extends Command
{
try
{
$this->configuration->getConfiguration();
$this->configuration;
}
catch (\Exception $e)
{
@@ -178,15 +178,8 @@ class module_console_fileConfigCheck extends Command
{
$configuration = Core\Configuration::build();
try
{
$configuration->getConfiguration();
}
catch (\Exception $e)
{
throw new \Exception(sprintf("Check get selected environment from file\n"), null, $e);
}
$output->writeln("<info>Get Selected Environment from file OK</info>");
$env = $configuration->getEnvironnement();
$output->writeln("<info>Get Selected Environment from file : ".$env."</info>");
return;
}

View File

@@ -0,0 +1,920 @@
<?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.
*/
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputInterface,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console\Output\OutputInterface,
Symfony\Component\Console\Command\Command;
use Alchemy\Phrasea\Core;
use Symfony\Component\Yaml;
/**
* @todo write tests
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class module_console_fileEnsureDevSetting extends Command
{
const ALERT = 1;
const ERROR = 0;
/**
*
* @var \Alchemy\Phrasea\Core\Configuration
*/
protected $configuration;
protected $testSuite = array(
'checkPhraseanetScope'
, 'checkDatabaseScope'
, 'checkTeamplateEngineService'
, 'checkOrmService'
, 'checkCacheService'
, 'checkOpcodeCacheService'
);
protected $errors = 0;
protected $alerts = 0;
public function __construct($name = null)
{
parent::__construct($name);
$this->setDescription('Ensure development settings');
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
$this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
return $this;
}
public function execute(InputInterface $input, OutputInterface $output)
{
$specifications = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
$environnement = $input->getArgument('conf');
$this->configuration = \Alchemy\Phrasea\Core\Configuration::build($specifications, $environnement);
if (!$this->configuration->isInstalled())
{
$output->writeln(sprintf("\nPhraseanet is not installed\n"));
}
$this->checkParse($output);
$output->writeln(sprintf("Will Ensure Production Settings on <info>%s</info>", $this->configuration->getEnvironnement()));
$this->runTests($output);
$retval = $this->errors;
if ($input->getOption('strict'))
{
$retval += $this->alerts;
}
if ($retval > 0)
{
$output->writeln("\n<error>Some errors found in your conf</error>");
}
else
{
$output->writeln("\n<info>Your dev settings are setted correctly ! Enjoy</info>");
}
$output->writeln('End');
return $retval;
}
private function runTests(OutputInterface $output)
{
foreach ($this->testSuite as $test)
{
$display = "";
switch ($test)
{
case 'checkPhraseanetScope' :
$display = "Phraseanet Configuration";
break;
case 'checkDatabaseScope' :
$display = "Database";
break;
case 'checkTeamplateEngineService' :
$display = "Template Engine";
break;
case 'checkOrmService' :
$display = "ORM";
break;
case 'checkCacheService' :
$display = "Cache";
break;
case 'checkOpcodeCacheService' :
$display = "Opcode";
break;
default:
throw new \Exception('Unknown test');
break;
}
$output->writeln(sprintf("\n||| %s", mb_strtoupper($display)));
call_user_func(array($this, $test), $output);
}
}
private function checkParse(OutputInterface $output)
{
if (!$this->configuration->getConfigurations())
{
throw new \Exception("Unable to load configurations\n");
}
if (!$this->configuration->getConnexions())
{
throw new \Exception("Unable to load connexions\n");
}
if (!$this->configuration->getServices())
{
throw new \Exception("Unable to load services\n");
}
return;
}
private function checkCacheService(OutputInterface $output)
{
$cache = $this->configuration->getCache();
if ($this->probeCacheService($output, $cache))
{
if ($this->recommendedCacheService($output, $cache, true))
{
$work_message = '<info>Works !</info>';
}
else
{
$work_message = '<comment>Cache server recommended</comment>';
$this->alerts++;
}
}
else
{
$work_message = '<error>Failed - could not connect !</error>';
$this->errors++;
}
$verification = sprintf("\t--> Verify <info>%s</info> : %s", 'MainCache', $work_message);
$this->printConf($output, "\t" . 'service', $cache, false, $verification);
$this->verifyCacheOptions($output, $cache);
}
private function checkOpcodeCacheService(OutputInterface $output)
{
$cache = $this->configuration->getOpcodeCache();
if ($this->probeCacheService($output, $cache))
{
if ($this->recommendedCacheService($output, $cache, false))
{
$work_message = '<info>Works !</info>';
}
else
{
$work_message = '<error>No cache required</error>';
$this->errors++;
}
}
else
{
$work_message = '<error>Failed - could not connect !</error>';
$this->errors++;
}
$verification = sprintf("\t--> Verify <info>%s</info> : %s", 'OpcodeCache', $work_message);
$this->printConf($output, "\t" . 'service', $cache, false, $verification);
$this->verifyCacheOptions($output, $cache);
}
private function checkPhraseanetScope(OutputInterface $output)
{
$required = array('servername', 'maintenance', 'debug', 'display_errors', 'database');
$phraseanet = $this->configuration->getPhraseanet();
foreach ($phraseanet->all() as $conf => $value)
{
switch ($conf)
{
default:
$this->alerts++;
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
break;
case 'servername':
$url = $value;
$required = array_diff($required, array($conf));
$parseUrl = parse_url($url);
if (empty($url))
{
$message = "<error>should not be empty</error>";
$this->errors++;
}
elseif ($url == 'http://sub.domain.tld/')
{
$this->alerts++;
$message = "<comment>may be wrong</comment>";
}
elseif (!filter_var($url, FILTER_VALIDATE_URL))
{
$message = "<error>not valid</error>";
$this->errors++;
}
else
{
$message = "<info>OK</info>";
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'maintenance':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== false)
{
$message = '<error>Should be true</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'debug':
case 'display_errors':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== true)
{
$message = '<error>Should be true</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'database':
$required = array_diff($required, array($conf));
try
{
$service = $this->configuration->getConnexion($value);
if ($this->verifyDatabaseConnexion($service))
{
$message = '<info>OK</info>';
}
else
{
$message = '<error>Connection not available</error>';
$this->errors++;
}
}
catch (\Exception $e)
{
$message = '<error>Unknown connection</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
}
}
if (count($required) > 0)
{
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
$this->errors++;
}
return;
}
private function checkDatabaseScope(OutputInterface $output)
{
$connexionName = $this->configuration->getPhraseanet()->get('database');
$connexion = $this->configuration->getConnexion($connexionName);
try
{
if ($this->verifyDatabaseConnexion($connexion))
{
$work_message = '<info>Works !</info>';
}
else
{
$work_message = '<error>Failed - could not connect !</error>';
$this->errors++;
}
}
catch (\Exception $e)
{
$work_message = '<error>Failed - could not connect !</error>';
$this->errors++;
}
$output->writeln(sprintf("\t--> Verify connection <info>%s</info> : %s", $connexionName, $work_message));
$required = array('driver');
if (!$connexion->has('driver'))
{
$output->writeln("\n<error>Connection has no driver</error>");
$this->errors++;
}
elseif ($connexion->get('driver') == 'pdo_mysql')
{
$required = array('driver', 'dbname', 'charset', 'password', 'user', 'port', 'host');
}
elseif ($connexion->get('driver') == 'pdo_sqlite')
{
$required = array('driver', 'path', 'charset');
}
else
{
$output->writeln("\n<error>Your driver is not managed</error>");
$this->errors++;
}
foreach ($connexion->all() as $conf => $value)
{
switch ($conf)
{
default:
$this->alerts++;
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
break;
case 'charset':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== 'UTF8')
{
$message = '<comment>Not recognized</comment>';
$this->alerts++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'path':
$required = array_diff($required, array($conf));
$message = is_writable(dirname($value)) ? '<info>OK</info>' : '<error>Not writeable</error>';
$this->printConf($output, $conf, $value, false, $message);
break;
case 'dbname':
case 'user':
case 'host':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if (!is_scalar($value))
{
$message = '<error>Should be scalar</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'port':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if (!ctype_digit($value))
{
$message = '<error>Should be ctype_digit</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'password':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if (!is_scalar($value))
{
$message = '<error>Should be scalar</error>';
$this->errors++;
}
$value = '***********';
$this->printConf($output, $conf, $value, false, $message);
break;
case 'driver':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== 'pdo_mysql')
{
$message = '<error>MySQL recommended</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
}
}
if (count($required) > 0)
{
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
$this->errors++;
}
return;
}
protected function verifyDatabaseConnexion(\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $connexion)
{
try
{
$config = new \Doctrine\DBAL\Configuration();
$conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
return true;
}
catch (\Exception $e)
{
}
return false;
}
private function checkTeamplateEngineService(OutputInterface $output)
{
$templateEngineName = $this->configuration->getTemplating();
$configuration = $this->configuration->getService($templateEngineName);
try
{
Core\Service\Builder::create(\bootstrap::getCore(), $templateEngineName, $configuration);
$work_message = '<info>Works !</info>';
}
catch (\Exception $e)
{
$work_message = '<error>Failed - could not load template engine !</error>';
$this->errors++;
}
$output->writeln(sprintf("\t--> Verify Template engine <info>%s</info> : %s", $templateEngineName, $work_message));
if (!$configuration->has('type'))
{
$output->writeln("\n<error>Configuration has no type</error>");
$this->errors++;
}
elseif ($configuration->get('type') == 'TemplateEngine\\Twig')
{
$required = array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
}
else
{
$output->writeln("\n<error>Your type is not managed</error>");
$this->errors++;
}
foreach ($configuration->all() as $conf => $value)
{
switch ($conf)
{
case 'type':
$message = '<info>OK</info>';
if ($value !== 'TemplateEngine\\Twig')
{
$message = '<error>Not recognized</error>';
$this->alerts++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'options':
$message = '<info>OK</info>';
if (!is_array($value))
{
$message = '<error>Should be array</error>';
$this->errors++;
}
$this->printConf($output, $conf, 'array()', false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
break;
}
}
foreach ($configuration->get('options') as $conf => $value)
{
switch ($conf)
{
case 'debug';
case 'strict_variables';
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== true)
{
$message = '<error>Should be false</error>';
$this->errors++;
}
$this->printConf($output, "\t" . $conf, $value, false, $message);
break;
case 'autoescape';
case 'optimizer';
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== true)
{
$message = '<error>Should be true</error>';
$this->errors++;
}
$this->printConf($output, "\t" . $conf, $value, false, $message);
break;
case 'charset';
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== 'utf-8')
{
$message = '<comment>Not recognized</comment>';
$this->alerts++;
}
$this->printConf($output, "\t" . $conf, $value, false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
break;
}
}
if (count($required) > 0)
{
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
$this->errors++;
}
return;
}
private function checkOrmService(OutputInterface $output)
{
$ormName = $this->configuration->getOrm();
$configuration = $this->configuration->getService($ormName);
try
{
$service = Core\Service\Builder::create(\bootstrap::getCore(), $ormName, $configuration);
$work_message = '<info>Works !</info>';
}
catch (\Exception $e)
{
$work_message = '<error>Failed - could not connect !</error>';
$this->errors++;
}
$output->writeln(sprintf("\t--> Verify ORM engine <info>%s</info> : %s", $ormName, $work_message));
if (!$configuration->has('type'))
{
$output->writeln("\n<error>Configuration has no type</error>");
$this->errors++;
}
elseif ($configuration->get('type') == 'Orm\\Doctrine')
{
$required = array('debug', 'dbal', 'cache');
}
else
{
$output->writeln("\n<error>Your type is not managed</error>");
$this->errors++;
}
foreach ($configuration->all() as $conf => $value)
{
switch ($conf)
{
case 'type':
$message = $value == 'Orm\\Doctrine' ? '<info>OK</info>' : '<error>Not recognized</error>';
$this->printConf($output, $conf, $value, false, $message);
break;
case 'options':
$message = '<info>OK</info>';
if (!is_array($value))
{
$message = '<error>Should be array</error>';
$this->errors++;
}
$this->printConf($output, $conf, 'array()', false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
break;
}
}
foreach ($configuration->get('options') as $conf => $value)
{
switch ($conf)
{
case 'log':
$message = '<info>OK</info>';
$this->printConf($output, $conf, $value, false, $message);
break;
case 'cache':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if (!is_array($value))
{
$message = '<error>Should be Array</error>';
$this->errors++;
}
$this->printConf($output, $conf, 'array()', false, $message);
$required_caches = array('query', 'result', 'metadata');
foreach ($value as $name => $cache_type)
{
$required_caches = array_diff($required_caches, array($name));
foreach ($cache_type as $key_cache => $value_cache)
{
switch ($key_cache)
{
case 'service':
if ($this->probeCacheService($output, $value_cache))
{
$server = $name === 'result';
if ($this->recommendedCacheService($output, $value_cache, $server))
{
$work_message = '<info>Works !</info>';
}
else
{
$this->errors++;
$work_message = '<error>No cache required</error>';
}
}
else
{
$work_message = '<error>Failed - could not connect !</error>';
$this->errors++;
}
$verification = sprintf("\t--> Verify <info>%s</info> : %s", $name, $work_message);
$this->printConf($output, "\t" . $key_cache, $value_cache, false, $verification);
$this->verifyCacheOptions($output, $value_cache);
break;
default:
$this->alerts++;
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
break;
}
if (!isset($cache_type['service']))
{
$output->writeln('<error>Miss service for %s</error>', $cache_type);
$this->errors++;
}
}
}
if (count($required_caches) > 0)
{
$output->writeln(sprintf('<error>Miss required caches %s</error>', implode(', ', $required_caches)));
$this->errors++;
}
break;
case 'debug':
$required = array_diff($required, array($conf));
$message = '<info>OK</info>';
if ($value !== true)
{
$message = '<error>Should be true</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'dbal':
$required = array_diff($required, array($conf));
try
{
$connexion = $this->configuration->getConnexion($value);
$this->verifyDatabaseConnexion($connexion);
$message = '<info>OK</info>';
}
catch (\Exception $e)
{
$message = '<error>Failed</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
break;
}
}
if (count($required) > 0)
{
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
$this->errors++;
}
return;
}
protected function verifyCacheOptions(OutputInterface $output, $ServiceName)
{
try
{
$conf = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $conf
);
}
catch (\Exception $e)
{
return false;
}
$required_options = array();
switch ($Service->getType())
{
default:
break;
case 'memcache':
$required_options = array('host', 'port');
break;
}
if ($required_options)
{
foreach ($conf->get('options') as $conf => $value)
{
switch ($conf)
{
case 'host';
$required_options = array_diff($required_options, array($conf));
$message = '<info>OK</info>';
if (!is_scalar($value))
{
$message = '<error>Should be scalar</error>';
$this->errors++;
}
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
break;
case 'port';
$required_options = array_diff($required_options, array($conf));
$message = '<info>OK</info>';
if (!ctype_digit($value))
{
$message = '<comment>Not recognized</comment>';
$this->alerts++;
}
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
break;
}
}
}
if (count($required_options) > 0)
{
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required_options)));
$this->errors++;
}
}
protected function probeCacheService(OutputInterface $output, $ServiceName)
{
try
{
$originalConfiguration = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $originalConfiguration
);
}
catch (\Exception $e)
{
return false;
}
if ($Service->getDriver()->isServer())
{
switch ($Service->getType())
{
default:
return false;
break;
case 'memcache':
if (!@memcache_connect($Service->getHost(), $Service->getPort()))
{
return false;
}
break;
}
}
return true;
}
protected function recommendedCacheService(OutputInterface $output, $ServiceName, $server)
{
try
{
$originalConfiguration = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $originalConfiguration
);
}
catch (\Exception $e)
{
return false;
}
return $Service->getType() === 'array';
}
private function printConf($output, $scope, $value, $scopage = false, $message = '')
{
if (is_array($value))
{
foreach ($value as $key => $val)
{
if ($scopage)
$key = $scope . ":" . $key;
$this->printConf($output, $key, $val, $scopage, '');
}
}
elseif (is_bool($value))
{
if ($value === false)
{
$value = 'false';
}
elseif ($value === true)
{
$value = 'true';
}
$output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
}
elseif (!empty($value))
{
$output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
}
}
}

View File

@@ -44,6 +44,7 @@ class module_console_fileEnsureProductionSetting extends Command
, 'checkOpcodeCacheService'
);
protected $errors = 0;
protected $alerts = 0;
public function __construct($name = null)
{
@@ -52,6 +53,7 @@ class module_console_fileEnsureProductionSetting extends Command
$this->setDescription('Ensure production settings');
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
$this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
return $this;
}
@@ -74,8 +76,23 @@ class module_console_fileEnsureProductionSetting extends Command
$this->runTests($output);
$retval = $this->errors;
if ($input->getOption('strict'))
{
$retval += $this->alerts;
}
if ($retval > 0)
{
$output->writeln("\n<error>Some errors found in your conf</error>");
}
else
{
$output->writeln("\n<info>Your production settings are setted correctly ! Enjoy</info>");
}
$output->writeln('End');
return 0;
return $retval;
}
private function runTests(OutputInterface $output)
@@ -112,15 +129,6 @@ class module_console_fileEnsureProductionSetting extends Command
call_user_func(array($this, $test), $output);
}
if ($this->errors)
{
$output->writeln("\n<error>Some errors found in your conf</error>");
}
else
{
$output->writeln("\n<info>Your production settings are setted correctly ! Enjoy</info>");
}
return $this->errors;
}
private function checkParse(OutputInterface $output)
@@ -156,6 +164,7 @@ class module_console_fileEnsureProductionSetting extends Command
else
{
$work_message = '<comment>Cache server recommended</comment>';
$this->alerts++;
}
}
else
@@ -185,6 +194,7 @@ class module_console_fileEnsureProductionSetting extends Command
else
{
$work_message = '<comment>Opcode recommended</comment>';
$this->alerts++;
}
}
else
@@ -211,6 +221,7 @@ class module_console_fileEnsureProductionSetting extends Command
switch ($conf)
{
default:
$this->alerts++;
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
break;
case 'servername':
@@ -226,6 +237,7 @@ class module_console_fileEnsureProductionSetting extends Command
}
elseif ($url == 'http://sub.domain.tld/')
{
$this->alerts++;
$message = "<comment>may be wrong</comment>";
}
elseif (!filter_var($url, FILTER_VALIDATE_URL))
@@ -235,6 +247,7 @@ class module_console_fileEnsureProductionSetting extends Command
}
elseif ($parseUrl["scheme"] !== "https")
{
$this->alerts++;
$message = "<comment>should be https</comment>";
}
else
@@ -247,7 +260,14 @@ class module_console_fileEnsureProductionSetting extends Command
case 'debug':
case 'display_errors':
$required = array_diff($required, array($conf));
$message = $value ? '<error>Should be false</error>' : '<info>OK</info>';
$message = '<info>OK</info>';
if ($value !== false)
{
$message = '<error>Should be false</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'database':
@@ -335,11 +355,17 @@ class module_console_fileEnsureProductionSetting extends Command
switch ($conf)
{
default:
$this->alerts++;
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
break;
case 'charset':
$required = array_diff($required, array($conf));
$message = $value == 'UTF8' ? '<info>OK</info>' : '<comment>Not recognized</comment>';
$message = '<info>OK</info>';
if ($value !== 'UTF8')
{
$message = '<comment>Not recognized</comment>';
$this->alerts++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'path':
@@ -351,23 +377,50 @@ class module_console_fileEnsureProductionSetting extends Command
case 'user':
case 'host':
$required = array_diff($required, array($conf));
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
$message = '<info>OK</info>';
if (!is_scalar($value))
{
$message = '<error>Should be scalar</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'port':
$required = array_diff($required, array($conf));
$message = ctype_digit($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
$message = '<info>OK</info>';
if (!ctype_digit($value))
{
$message = '<error>Should be ctype_digit</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'password':
$required = array_diff($required, array($conf));
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
$message = '<info>OK</info>';
if (!is_scalar($value))
{
$message = '<error>Should be scalar</error>';
$this->errors++;
}
$value = '***********';
$this->printConf($output, $conf, $value, false, $message);
break;
case 'driver':
$required = array_diff($required, array($conf));
$message = $value === 'pdo_mysql' ? '<info>OK</info>' : '<error>MySQL recommended</error>';
$message = '<info>OK</info>';
if ($value !== 'pdo_mysql')
{
$message = '<error>MySQL recommended</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
}
@@ -410,7 +463,7 @@ class module_console_fileEnsureProductionSetting extends Command
}
catch (\Exception $e)
{
$work_message = '<error>Failed - could not connect !</error>';
$work_message = '<error>Failed - could not load template engine !</error>';
$this->errors++;
}
@@ -438,14 +491,29 @@ class module_console_fileEnsureProductionSetting extends Command
switch ($conf)
{
case 'type':
$message = $value == 'TemplateEngine\\Twig' ? '<info>OK</info>' : '<error>Not recognized</error>';
$message = '<info>OK</info>';
if($value !== 'TemplateEngine\\Twig')
{
$message = '<error>Not recognized</error>';
$this->alerts++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'options':
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be array</error>';
$message = '<info>OK</info>';
if (!is_array($value))
{
$message = '<error>Should be array</error>';
$this->errors++;
}
$this->printConf($output, $conf, 'array()', false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
break;
}
@@ -458,21 +526,43 @@ class module_console_fileEnsureProductionSetting extends Command
case 'debug';
case 'strict_variables';
$required = array_diff($required, array($conf));
$message = $value == false ? '<info>OK</info>' : '<error>Should be false</error>';
$message = '<info>OK</info>';
if ($value !== false)
{
$message = '<error>Should be false</error>';
$this->errors++;
}
$this->printConf($output, "\t" . $conf, $value, false, $message);
break;
case 'autoescape';
case 'optimizer';
$required = array_diff($required, array($conf));
$message = $value == true ? '<info>OK</info>' : '<error>Should be true</error>';
$message = '<info>OK</info>';
if ($value !== true)
{
$message = '<error>Should be true</error>';
$this->errors++;
}
$this->printConf($output, "\t" . $conf, $value, false, $message);
break;
case 'charset';
$required = array_diff($required, array($conf));
$message = $value == 'utf-8' ? '<info>OK</info>' : '<comment>Not recognized</comment>';
$message = '<info>OK</info>';
if ($value !== 'utf-8')
{
$message = '<comment>Not recognized</comment>';
$this->alerts++;
}
$this->printConf($output, "\t" . $conf, $value, false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
break;
}
@@ -533,10 +623,18 @@ class module_console_fileEnsureProductionSetting extends Command
$this->printConf($output, $conf, $value, false, $message);
break;
case 'options':
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be array</error>';
$message = '<info>OK</info>';
if (!is_array($value))
{
$message = '<error>Should be array</error>';
$this->errors++;
}
$this->printConf($output, $conf, 'array()', false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
break;
}
@@ -548,12 +646,26 @@ class module_console_fileEnsureProductionSetting extends Command
switch ($conf)
{
case 'log':
$message = $value == false ? '<info>OK</info>' : '<error>Should be deactivated</error>';
$message = '<info>OK</info>';
if ($value !== false)
{
$message = '<error>Should be deactivated</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'cache':
$required = array_diff($required, array($conf));
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be Array</error>';
$message = '<info>OK</info>';
if (!is_array($value))
{
$message = '<error>Should be Array</error>';
$this->errors++;
}
$this->printConf($output, $conf, 'array()', false, $message);
$required_caches = array('query', 'result', 'metadata');
@@ -575,6 +687,7 @@ class module_console_fileEnsureProductionSetting extends Command
}
else
{
$this->alerts++;
if ($server)
{
$work_message = '<comment>Cache server recommended</comment>';
@@ -598,6 +711,7 @@ class module_console_fileEnsureProductionSetting extends Command
$this->verifyCacheOptions($output, $value_cache);
break;
default:
$this->alerts++;
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
break;
}
@@ -617,7 +731,14 @@ class module_console_fileEnsureProductionSetting extends Command
break;
case 'debug':
$required = array_diff($required, array($conf));
$message = $value == false ? '<info>OK</info>' : '<error>Should be false</error>';
$message = '<info>OK</info>';
if ($value !== false)
{
$message = '<error>Should be false</error>';
$this->errors++;
}
$this->printConf($output, $conf, $value, false, $message);
break;
case 'dbal':
@@ -636,6 +757,7 @@ class module_console_fileEnsureProductionSetting extends Command
$this->printConf($output, $conf, $value, false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
break;
}
@@ -684,15 +806,30 @@ class module_console_fileEnsureProductionSetting extends Command
{
case 'host';
$required_options = array_diff($required_options, array($conf));
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
$message = '<info>OK</info>';
if (!is_scalar($value))
{
$message = '<error>Should be scalar</error>';
$this->errors++;
}
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
break;
case 'port';
$required_options = array_diff($required_options, array($conf));
$message = ctype_digit($value) ? '<info>OK</info>' : '<comment>Not recognized</comment>';
$message = '<info>OK</info>';
if (!ctype_digit($value))
{
$message = '<comment>Not recognized</comment>';
$this->alerts++;
}
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
break;
default:
$this->alerts++;
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
break;
}
@@ -729,7 +866,7 @@ class module_console_fileEnsureProductionSetting extends Command
return false;
break;
case 'memcache':
if (!memcache_connect($Service->getHost(), $Service->getPort()))
if (!@memcache_connect($Service->getHost(), $Service->getPort()))
{
return false;
}

View File

@@ -453,7 +453,6 @@ class module_report_activity extends module_report
$this->result[$i]['total'] += 1;
$total['tot_dl'] += 1;
}
$nb_row = $i + 1;
@@ -479,7 +478,7 @@ class module_report_activity extends module_report
* @param string $on choose the field on what you want the result
* @return array
*/
public function getConnexionBase($tab = false, $on= "")
public function getConnexionBase($tab = false, $on = "")
{
//default group on user column
if (empty($on))
@@ -577,7 +576,7 @@ class module_report_activity extends module_report
* @param array $tab config for the html table
* @return array
*/
public function getDetailDownload($tab = false, $on="")
public function getDetailDownload($tab = false, $on = "")
{
empty($on) ? $on = "user" : ""; //by default always report on user
@@ -638,19 +637,37 @@ class module_report_activity extends module_report
foreach ($rs as $row)
{
$user = $row[$on];
if (($save_user != $user) && !is_null($user))
if (($save_user != $user) && !is_null($user) && !empty($user))
{
if ($i >= 0)
{
if (($this->result[$i]['nbprev'] + $this->result[$i]['nbdoc']) == 0 || ($this->result[$i]['poiddoc'] + $this->result[$i]['poidprev']) == 0)
{
unset($this->result[$i]);
}
if (isset($this->result[$i]['poiddoc']) && isset($this->result[$i]['poidprev']))
{
$this->result[$i]['poiddoc'] = p4string::format_octets($this->result[$i]['poiddoc']);
$this->result[$i]['poidprev'] = p4string::format_octets($this->result[$i]['poidprev']);
}
}
$i++;
$this->result[$i]['nbprev'] = 0;
$this->result[$i]['poidprev'] = 0;
$this->result[$i]['nbdoc'] = 0;
$this->result[$i]['poiddoc'] = 0;
}
//doc info
if ($row['final'] == 'document' &&
!is_null($user) && !is_null($row['usrid']))
{
$this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0);
$this->result[$i]['poiddoc'] = (!is_null($row['poid']) ?
p4string::format_octets($row['poid']) : 0);
if (!isset($this->result[$i]['nbprev']))
$this->result[$i]['nbprev'] = 0;
if (!isset($this->result[$i]['poidprev']))
$this->result[$i]['poidprev'] = 0;
$this->result[$i]['poiddoc'] = (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['user'] = empty($row[$on]) ?
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
$total['nbdoc'] += $this->result[$i]['nbdoc'];
@@ -658,26 +675,25 @@ class module_report_activity extends module_report
$this->result[$i]['usrid'] = $row['usrid'];
}
//preview info
if ($row['final'] == 'preview' &&
if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') &&
!is_null($user) &&
!is_null($row['usrid']))
{
if (!isset($this->result[$i]['nbdoc']))
$this->result[$i]['nbdoc'] = 0;
if (!isset($this->result[$i]['poiddoc']))
$this->result[$i]['poiddoc'] = 0;
$this->result[$i]['nbprev'] = (!is_null($row['nb']) ? $row['nb'] : 0);
$this->result[$i]['poidprev'] = (!is_null($row['poid']) ?
p4string::format_octets($row['poid']) : 0);
$this->result[$i]['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
$this->result[$i]['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['user'] = empty($row[$on]) ?
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
$total['nbprev'] += $this->result[$i]['nbprev'];
$total['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
$total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['usrid'] = $row['usrid'];
}
$save_user = $user;
}
unset($this->result[$i]);
$nb_row = $i + 1;
$this->total = $nb_row;
@@ -756,7 +772,7 @@ class module_report_activity extends module_report
}
catch (Exception $e)
{
}
}
elseif ($value == "size")

View 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_320h 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 = 'DELETE FROM basusr WHERE actif = "0"';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
return true;
}
}

View File

@@ -59,7 +59,7 @@ class patch_360 implements patchInterface
foreach ($tables as $table)
{
$sql = 'TRUNCATE ' . $table;
$sql = 'DELETE FROM ' . $table;
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();

View File

@@ -54,13 +54,19 @@ class patch_3602 implements patchInterface
function apply(base &$databox)
{
try
{
$sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
$sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
}
catch(\PDOException $e)
{
}
return true;
}

View File

@@ -95,8 +95,6 @@ interface record_Interface
public function set_binary_status($status);
public function get_reg_name();
public function get_hd_file();
public function delete();

View File

@@ -140,8 +140,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
const CACHE_GROUPING = 'grouping';
const CACHE_STATUS = 'status';
protected static $_regfields;
/**
*
* @param <int> $base_id
@@ -895,16 +893,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
{
$sbas_id = $this->get_sbas_id();
$record_id = $this->get_record_id();
if ($this->is_grouping())
{
$regfield = self::getRegFields($sbas_id, $this->get_caption());
return $regfield['regname'];
}
$title = '';
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
@@ -944,98 +932,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $title;
}
public function get_description()
{
if (!$this->is_grouping())
throw new \Exception('This record is not a story');
$regfield = self::getRegFields($this->get_sbas_id(), $this->get_caption());
return $regfield['regdesc'];
}
/**
*
* @param <type> $sbas_id
* @param caption_record $desc
* @return <type>
*/
protected static function getRegFields($sbas_id, caption_record $desc)
{
if (!self::$_regfields)
self::load_regfields();
$arrayRegFields = self::$_regfields[$sbas_id];
$array = array();
foreach ($arrayRegFields as $k => $f)
{
$array[$f] = $k;
}
$fields = array();
$fields["regname"] = "";
$fields["regdesc"] = "";
$fields["regdate"] = "";
foreach ($desc->get_fields() as $caption_field)
{
/* @var $caption_field caption_field */
$meta_struct_id = $caption_field->get_meta_struct_id();
if (array_key_exists($meta_struct_id, $array))
{
$fields[$array[$meta_struct_id]] = $caption_field->get_serialized_values();
}
}
return $fields;
}
/**
* get databox reg fields
*
* @todo change this shit
* @return array
*/
protected static function load_regfields()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
self::$_regfields = array();
foreach ($appbox->get_databoxes() as $databox)
{
self::$_regfields[$databox->get_sbas_id()] = self::searchRegFields($databox->get_meta_structure());
}
return self::$_regfields;
}
/**
*
* @param databox_descriptionStructure $meta_struct
* @return <type>
*/
protected function searchRegFields(databox_descriptionStructure $meta_struct)
{
$fields = null;
$fields["regname"] = "";
$fields["regdesc"] = "";
$fields["regdate"] = "";
foreach ($meta_struct as $meta)
{
if ($meta->is_regname())
$fields["regname"] = $meta->get_id();
elseif ($meta->is_regdesc())
$fields["regdesc"] = $meta->get_id();
elseif ($meta->is_regdate())
$fields['regdate'] = $meta->get_id();
}
return $fields;
}
/**
*
* @return media_subdef
@@ -1487,42 +1383,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this;
}
/**
*
* @return string
*/
public function get_reg_name()
{
if (!$this->is_grouping())
{
return false;
}
$balisename = '';
$struct = $this->databox->get_structure();
if ($sxe = simplexml_load_string($struct))
{
$z = $sxe->xpath('/record/description');
if ($z && is_array($z))
{
foreach ($z[0] as $ki => $vi)
{
if ($vi['regname'] == '1')
{
$balisename = $ki;
break;
}
}
}
}
$regname = '';
if ($sxe = simplexml_load_string($this->get_xml()))
$regname = (string) $sxe->description->$balisename;
return $regname;
}
/**
*

View File

@@ -631,7 +631,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
return array();
$rs = $res['results'];
$res = array_shift($rs);
if (!$res['xml'])
if (! isset($res['xml']))
return array();
$sxe = simplexml_load_string($res['xml']);
@@ -645,7 +645,8 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value);
}
$val = implode(' '.$field['separator'].' ', $val);
$separator = $field['separator'] ? $field['separator'][0] : '';
$val = implode(' '.$separator.' ', $val);
}
else
{

View File

@@ -222,14 +222,26 @@ class set_order extends set_abstract
$core = \bootstrap::getCore();
$em = $core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
$Basket = null;
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser(), false);
if($this->ssel_id)
{
$repository = $em->getRepository('\Entities\Basket');
try
{
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser(), false);
}
catch(\Exception $e)
{
$Basket = null;
}
}
if(!$Basket)
{
$Basket = new Basket();
$Basket = new \Entities\Basket();
$Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
$Basket->setOwner($this->user);
$Basket->setPusher($core->getAuthenticatedUser());
@@ -265,16 +277,15 @@ class set_order extends set_abstract
$sbas_id = phrasea::sbasFromBas($basrec['base_id']);
$record = new record_adapter($sbas_id, $basrec['record_id']);
$BasketElement = new BasketElement();
$BasketElement = new \Entities\BasketElement();
$BasketElement->setRecord($record);
$BasketElement->setBasket($Basket);
$Basket->addBasketElement($BasketElement);
$em->persist($BasketElement);
$em->merge($Basket);
$params = array(
':usr_id' => $session->get_usr_id()
, ':order_id' => $this->id

View File

@@ -607,18 +607,16 @@ class setup
if ($Core->getCache()->isServer())
{
$stats = $Core->getCache()->getStats();
echo '<li>' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '</li>';
echo "<table>";
foreach ($stats as $name => $stat)
{
echo '<li>Statistics given by `' . $name . '`</li>';
echo '<li>' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '</li>';
echo "<table>";
foreach ($stat as $key => $value)
{
echo "<tr class='even'><td>" . $key . "</td><td> " . $value . "</td></tr>";
}
echo "</table>";
echo "<tr class='even'><td>" . $name . "</td><td> " . $stat . "</td></tr>";
}
echo "</table>";
}
else
{
@@ -643,9 +641,9 @@ class setup
}
if ($found > 1)
$constraints[] = new Setup_Constraint('Multiple opcode caches', false, 'Many opcode cache load is forbidden', true);
$constraints[] = new Setup_Constraint('Multiple opcode caches', false, _('Many opcode cache load is forbidden'), true);
if ($found === 0)
$constraints[] = new Setup_Constraint('No opcode cache', false, 'No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.', false);
$constraints[] = new Setup_Constraint('No opcode cache', false, _('No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.'), false);
return new Setup_ConstraintsIterator($constraints);
}

View File

@@ -67,15 +67,17 @@ class sphinx_configuration
$defaults = array(
'sbas' => self::OPT_ALL_SBAS
, 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE)
, 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE)
, 'enable_star' => self::OPT_ENABLE_STAR_ON
, 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN
, 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN
, 'min_infix_len' => self::OPT_MIN_INFIX_LEN
, 'charset_tables' => array()
);
$options = array_merge($defaults, $options);
$options['charset_tables'] = array_unique($options['charset_tables']);
$lb = phrasea::sbas_params();
$conf = '';
@@ -439,7 +441,7 @@ class sphinx_configuration
path = /var/sphinx/datas/docs_realtime_' . $serialized . '
' . $charset_abstract . '
' . $charset_abstract . '
rt_field = value
# rt_field = meta_struct_id
@@ -593,6 +595,9 @@ searchd
# optional, default is 256
#
max_filters = 512
compat_sphinxql_magics = 0
}
';

View File

@@ -81,7 +81,7 @@ class sphinxrt
if ($rt_id)
{
$this->connection->beginTransaction();
$sql = "DELETE FROM " . $rt_id . " WHERE id = " . (int) $id . "";
$sql = "DELETE FROM " . $rt_id . " WHERE id = " . (int) $id . "";
$stmt = $this->connection->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
@@ -99,14 +99,13 @@ class sphinxrt
$cl = new SphinxClient();
if ($cl->Status() === false)
return $this;
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));
$cl->SetConnectTimeout(1);
$status = strrev($status);
$status = strrev($status);
$new_stat = array();
for ($i = 4; $i < strlen($status); $i++)
{
@@ -122,20 +121,18 @@ class sphinxrt
return $this;
}
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, Array $content, DateTime $created)
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, DateTime $created)
{
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
$crc_type = crc32($type);
$crc_type = crc32($type);
$this->connection->beginTransaction();
// foreach ($content as $value)
// {
$sql = "REPLACE INTO " . $rt_id . " VALUES (
$sql = "REPLACE INTO " . $rt_id . " VALUES (
'" . (int) $meta_id . "'
,'" . str_replace("'", "\'", implode(' ', $content)) . "'
,'" . str_replace("'", "\'", $content) . "'
,'" . (int) $tag_id . "'
," . (int) $record_id . "
," . (int) $sbas_id . "
@@ -149,7 +146,6 @@ class sphinxrt
," . (int) $created->format('U') . " )";
$stmt = $this->connection->prepare($sql);
$stmt->execute();
// }
$stmt->closeCursor();
@@ -160,9 +156,9 @@ class sphinxrt
public function replace_in_documents($rt_id, $record_id, $value, $sbas_id, $coll_id, $grouping, $type, DateTime $created)
{
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
$crc_type = crc32($type);
$crc_type = crc32($type);
$this->connection->beginTransaction();