From cd28906c6ba08aa1017397773f06aaaaf31fd9ae Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 6 Jan 2012 18:15:27 +0100 Subject: [PATCH 1/8] Bump to version 3.5.8 --- lib/version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/version.inc b/lib/version.inc index 4f222df1a2..706048fb4c 100644 --- a/lib/version.inc +++ b/lib/version.inc @@ -15,5 +15,5 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -define('GV_version', '3.5.7.0'); +define('GV_version', '3.5.8.0'); define('GV_version_name', 'Baobab'); From e4016ccd2fc6ed10266f52ee120eb71d13a7473b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Jan 2012 18:07:01 +0100 Subject: [PATCH 2/8] Fix User_Adapter in preview short history --- lib/classes/record/preview.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php index 1078fc7ca9..d30ef62779 100644 --- a/lib/classes/record/preview.class.php +++ b/lib/classes/record/preview.class.php @@ -375,11 +375,22 @@ class record_preview extends record_adapter if (!isset($tab[$hour][$site][$action][$row['usr_id']])) { + $user = null; + + try + { + $user = \User_Adapter::getInstance($row['usr_id'], $appbox); + } + catch (Exception $e) + { + + } + $tab[$hour][$site][$action][$row['usr_id']] = array( 'final' => array() , 'comment' => array() - , 'user' => \User_Adapter::getInstance($row['usr_id'], $appbox) + , 'user' => $user ); } From 217d2e4db04506c95af5ebf459553b4f3e186121 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Jan 2012 18:24:32 +0100 Subject: [PATCH 3/8] Fix collection cache --- lib/classes/collection.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/classes/collection.class.php b/lib/classes/collection.class.php index 53f4ec6df6..03e025fdc5 100644 --- a/lib/classes/collection.class.php +++ b/lib/classes/collection.class.php @@ -200,6 +200,10 @@ class collection implements cache_cacheableInterface $stmt = $this->get_connection()->prepare($sql); $stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id())); $stmt->closeCursor(); + + $this->pub_wm = $publi; + + $this->delete_data_from_cache(); } return $this; @@ -219,6 +223,8 @@ class collection implements cache_cacheableInterface $stmt->closeCursor(); $this->name = $name; + + $this->delete_data_from_cache(); return $this; } @@ -396,6 +402,8 @@ class collection implements cache_cacheableInterface $stmt = $this->get_connection()->prepare($sql); $stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id())); $stmt->closeCursor(); + + $this->delete_data_from_cache(); return $this->prefs; } From c01efe9d379634c1cfeb80fe8034f2863a0d1875 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Jan 2012 18:24:41 +0100 Subject: [PATCH 4/8] Fix record indexation --- lib/classes/record/adapter.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 68d4e90426..17ba1ea4ed 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -1080,6 +1080,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface ':record_id' => $this->record_id ) ); + + $this->reindex(); return $this; } From 0228edec5d6bdb76f52352c6e030e9924a11e11d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Jan 2012 18:50:26 +0100 Subject: [PATCH 5/8] Fix export caption --- lib/classes/set/export.class.php | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/classes/set/export.class.php b/lib/classes/set/export.class.php index 67e97e2802..b64142b179 100644 --- a/lib/classes/set/export.class.php +++ b/lib/classes/set/export.class.php @@ -93,7 +93,7 @@ class set_export extends set_abstract { $record = new record_adapter($basrec[0], $basrec[1]); } - catch(Exception_Record_AdapterNotFound $e) + catch (Exception_Record_AdapterNotFound $e) { continue; } @@ -407,7 +407,7 @@ class set_export extends set_abstract * @param boolean $rename_title * @return Array */ - public function prepare_export(Array $subdefs, $rename_title=false) + public function prepare_export(Array $subdefs, $rename_title = false) { if (!is_array($subdefs)) { @@ -430,6 +430,7 @@ class set_export extends set_abstract foreach ($this->elements as $download_element) { + echo "eleme"; $id = count($files); $files[$id] = array( @@ -477,7 +478,7 @@ class set_export extends set_abstract $sd = $download_element->get_subdefs(); foreach ($download_element->get_downloadable() as $name => $properties) - { + { if ($properties === false || !in_array($name, $subdefs)) { continue; @@ -486,10 +487,6 @@ class set_export extends set_abstract { continue; } - if (!isset($sd[$name])) - { - continue; - } set_time_limit(100); $subdef_export = $subdef_alive = false; @@ -685,7 +682,9 @@ class set_export extends set_abstract system_file::mkdir($caption_dir); $desc = self::get_caption( - $download_element->get_base_id(), $download_element->get_record_id(), $session->get_ses_id() + $download_element->get_base_id() + , $download_element->get_record_id() + , $session->get_ses_id() ); $file = $files[$id]["export_name"] @@ -713,7 +712,11 @@ class set_export extends set_abstract $desc = self::get_caption( - $download_element->get_base_id(), $download_element->get_record_id(), $session->get_ses_id(), true, 'yaml' + $download_element->get_base_id() + , $download_element->get_record_id() + , $session->get_ses_id() + , true + , 'yaml' ); $file = $files[$id]["export_name"] @@ -732,6 +735,7 @@ class set_export extends set_abstract } } } + $this->list = array( 'files' => $files, 'names' => $file_names, @@ -739,6 +743,7 @@ class set_export extends set_abstract 'count' => $n_files ); + return $this->list; } @@ -758,7 +763,6 @@ class set_export extends set_abstract return false; } if (isset($list['complete']) && $list['complete'] === true) - return; @@ -835,7 +839,7 @@ class set_export extends set_abstract * @param boolean $check_rights * @return string */ - public static function get_caption($bas, $rec, $check_rights=true, $format = 'xml') + public static function get_caption($bas, $rec, $check_rights = true, $format = 'xml') { $dom = new DOMDocument(); $dom->formatOutput = true; @@ -950,7 +954,7 @@ class set_export extends set_abstract * @return Void */ public static function stream_file( - $file, $exportname, $mime, $disposition='attachment') + $file, $exportname, $mime, $disposition = 'attachment') { require_once dirname(__FILE__) . "/../../../lib/vendor/Silex/autoload.php"; $registry = registry::get_instance(); @@ -999,11 +1003,11 @@ class set_export extends set_abstract * @todo : merge this shitty fix with Response object. * */ - if(!headers_sent()) + if (!headers_sent()) { header("Pragma: public"); } - + $response->headers->set('Content-Type', $mime); $response->headers->set('Content-Name', $exportname); $response->headers->set('Content-Disposition', $disposition . "; filename=" . $exportname . ";"); @@ -1024,7 +1028,7 @@ class set_export extends set_abstract * @param String $disposition * @return Void */ - public static function stream_data($data, $exportname, $mime, $disposition='attachment') + public static function stream_data($data, $exportname, $mime, $disposition = 'attachment') { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @@ -1059,7 +1063,7 @@ class set_export extends set_abstract $user = false; if ($anonymous) { - + } else { From ded3cdb3cc27e3edc230401f6779fb1397fedeed Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Jan 2012 20:07:57 +0100 Subject: [PATCH 6/8] Substitution enhancement --- lib/classes/lazaretFile.class.php | 3 +- lib/classes/p4file.class.php | 307 --------------------------- lib/classes/record/adapter.class.php | 161 +++++++++----- 3 files changed, 115 insertions(+), 356 deletions(-) diff --git a/lib/classes/lazaretFile.class.php b/lib/classes/lazaretFile.class.php index 3d4fd25e06..3a4c0646a4 100644 --- a/lib/classes/lazaretFile.class.php +++ b/lib/classes/lazaretFile.class.php @@ -137,7 +137,8 @@ class lazaretFile $pathfile = $registry->get('GV_RootPath') . 'tmp/lazaret/' . $this->filepath; $record = new record_adapter($sbas_id, $record_id); - p4file::substitute($record, $pathfile, $this->filename, false); + $record->substitute_subdef('document', new system_file($pathfile)); + $this->delete(); return $this; diff --git a/lib/classes/p4file.class.php b/lib/classes/p4file.class.php index 10c38e04cb..756372b668 100644 --- a/lib/classes/p4file.class.php +++ b/lib/classes/p4file.class.php @@ -214,311 +214,4 @@ class p4file return $errors; } - public static function substitute(record_Interface $record, $new_pathfile, $filename, $update_filename = false) - { - $appbox = appbox::get_instance(); - $session = $appbox->get_session(); - $registry = $appbox->get_registry(); - - $sbas_id = $record->get_sbas_id(); - $record_id = $record->get_record_id(); - $base_id = $record->get_base_id(); - $connbas = connection::getPDOConnection($sbas_id); - - - $databox = databox::get_instance($sbas_id); - if ($baseprefs = $databox->get_sxml_structure()) - { - $pathhd = p4string::addEndSlash((string) ($baseprefs->path)); - $baseurl = (string) ($baseprefs->baseurl); - } - else - throw new Exception(_('prod::erreur : impossible de lire les preferences de base')); - - if (trim($pathhd) == "" || !is_dir($pathhd)) - throw new Exception(_('prod::substitution::erreur : impossible d\'acceder au dossier de stockage "' . $pathhd . '" ')); - - $sd = $record->get_subdefs('document'); - - if (isset($sd) && isset($sd["document"])) - { - $sd["document"]["path"] = p4string::addEndSlash($sd["document"]["path"]); - - $pathhd = p4string::addEndSlash($sd["document"]["path"]); - $filehd = $sd["document"]["file"]; - - $pathfile = $pathhd . $filehd; - - if (file_exists($pathfile) && !is_dir($pathfile)) - { - if (!@unlink($pathfile)) - throw new Exception(_('prod::substitution::erreur : impossible de supprimer l\'ancien document')); - } - } - else - { - $ext = ""; - $pitmp = pathinfo($filename); - if (isset($pitmp['extension'])) - $ext = $pitmp['extension']; - $filehd = $record_id . "_document." . $ext; - $pathhd = databox::dispatch($pathhd); - - $pathfile = $pathhd . $filehd; - } - - $sql = "DELETE FROM subdef WHERE record_id = :record_id AND name='document'"; - - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record_id)); - $stmt->closeCursor(); - - $width = $height = 0; - - if (!rename($new_pathfile, $pathfile)) - throw new Exception(_('prod::substitution::document remplace avec succes')); - - if ($tempHD = getimagesize($pathfile)) - { - $width = $tempHD[0]; - $height = $tempHD[1]; - } - - $system_file = new system_file($pathfile); - - - $sql = "INSERT INTO subdef (record_id, name, path, file, baseurl, width, height, mime, size) VALUES - (:record_id, 'document', :pathhd, :file_hd , :baseurl, :width , :height , :mime, :filesize)"; - - $params = array( - ':record_id' => $record_id - , ':pathhd' => $pathhd - , ':file_hd' => $filehd - , ':baseurl' => $baseurl - , ':width' => $width - , ':height' => $height - , ':mime' => $system_file->get_mime() - , ':filesize' => filesize($pathfile) - ); - - $stmt = $connbas->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - - $session->get_logger($record->get_databox()) - ->log($record, Session_Logger::EVENT_SUBSTITUTE, 'HD', ''); - - $desc = $record->get_xml(); - - $doc = new DOMDocument(); - $doc->loadXML($desc); - $params = $doc->getElementsByTagName('doc'); - $newname = null; - - foreach ($params as $param) - { - $oldname = $param->getAttribute('originalname'); - if ($oldname) - { - $oldpi = pathinfo($oldname); - $val = ""; - $pi = pathinfo($filename); - if (isset($pi["extension"])) - $val = $pi["extension"]; - - if ($update_filename) - $newname = $pi['basename']; - else - $newname = $oldpi['filename'] . "." . $val; - } - if ($newname) - $param->setAttribute('originalname', $newname); - $param->removeAttribute('channels'); - $param->removeAttribute('bits'); - - $param->setAttribute('height', $height); - $param->setAttribute('width', $width); - $param->setAttribute('size', filesize($pathfile)); - $param->setAttribute('mime', $system_file->get_mime()); - if (isset($tempHD["bits"])) - $param->setAttribute('bits', $tempHD["bits"]); - if (isset($tempHD["channels"])) - $param->setAttribute('channels', $tempHD["channels"]); - } - - $xp_rec = new DOMXPath($doc); - $databox = databox::get_instance($sbas_id); - $sx_struct = $databox->get_sxml_structure(); - foreach ($sx_struct->description->children() as $fn => $fv) - { - if (isset($fv["src"]) && (substr($fv["src"], 0, 2) == "tf")) - { - switch ($fv["src"]) - { - case "tf-chgdocdate": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = date('Y/m/d H:i:s', time()); - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = date('Y/m/d H:i:s', time()); - $newnode = $recdesc->appendChild($node); - } - } - break; - - case "tf-filename": - if ($newname && ($recdesc = $xp_rec->query("/record/description/$fn"))) - { - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = $newname; - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = $newname; - $newnode = $recdesc->appendChild($node); - } - } - break; - - case "tf-extension": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - $val = ""; - $pi = pathinfo($filename); - if (isset($pi["extension"])) - $val = $pi["extension"]; - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = $val; - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = $val; - $newnode = $recdesc->appendChild($node); - } - } - break; - - case "tf-mimetype": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - $val = $system_file->get_mime(); - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = $val; - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = $val; - $newnode = $recdesc->appendChild($node); - } - } - - break; - - case "tf-size": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = filesize($pathfile); - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = filesize($pathfile); - $newnode = $recdesc->appendChild($node); - } - } - break; - - case "tf-width": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = $width; - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = $width; - $newnode = $recdesc->appendChild($node); - } - } - break; - - case "tf-height": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = $height; - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = $height; - $newnode = $recdesc->appendChild($node); - } - } - break; - - case "tf-bits": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - $val = ""; - if (isset($tempHD["bits"])) - $val = $tempHD["bits"]; - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = $val; - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = $val; - $newnode = $recdesc->appendChild($node); - } - } - break; - - case "tf-channels": - if ($recdesc = $xp_rec->query("/record/description/$fn")) - { - $val = ""; - if (isset($tempHD["channels"])) - $val = $tempHD["channels"]; - if ($recdesc->item(0)) - $recdesc->item(0)->nodeValue = $val; - else - { - $recdesc = $xp_rec->query("/record/description")->item(0); - $node = $doc->createElement($fn); - $node->nodeValue = $val; - $newnode = $recdesc->appendChild($node); - } - } - break; - } - } - } - $newXml = $doc->savexml(); - - $record->set_xml($newXml); - - $sql = "UPDATE record SET status=status & ~3, moddate=NOW() - WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record_id)); - $stmt->closeCursor(); - - $record->write_metas(); - $filesToSet = null; - $filesToSet[] = $pathfile; - - return true; - } - } diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 17ba1ea4ed..190ad453e6 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -839,6 +839,43 @@ class record_adapter implements record_Interface, cache_cacheableInterface return $this->original_name; } + public function set_original_name($original_name) + { + $this->original_name = $original_name; + + foreach ($this->get_caption()->get_fields() as $field) + { + if ($field->get_databox_field()->get_source() != metadata_description_PHRASEANET_tffilename::get_source()) + { + continue; + } + + $this->set_metadatas( + array( + 'meta_struct_id' => $field->get_meta_struct_id() + , 'meta_id' => get_meta_id + , 'value' => array($original_name) + ) + ); + } + + $sql = 'UPDATE record + SET originalname = :originalname WHERE record_id = :record_id'; + + $params = array( + ':originalname' => $original_name + , ':record_id' => $this->get_record_id() + ); + + $stmt = $this->get_databox()->get_connection()->prepare($sql); + $stmt->execute($params); + $stmt->closeCursor(); + + $this->delete_data_from_cache(); + + return $this; + } + /** * * @return string @@ -946,53 +983,82 @@ class record_adapter implements record_Interface, cache_cacheableInterface . '.' . $pathfile->get_extension(); $base_url = ''; + $original_file = $subdef_def = false; - $subdefs = $this->get_databox()->get_subdef_structure(); - - foreach ($subdefs as $type => $datas) + if ($name == 'document') { - if ($this->get_type() != $type) - continue; + $baseprefs = $this->get_databox()->get_sxml_structure(); - if (!isset($datas[$name])) - throw new Exception('No available subdef declaration for this type and name'); + $pathhd = p4string::addEndSlash((string) ($baseprefs->path)); - $subdef_def = $datas[$name]; - break; + $filehd = $this->get_record_id() . "_document." . $pathfile->get_extension(true); + $pathhd = databox::dispatch($pathhd); + + copy($pathfile->getPathname(), $pathhd . $filehd); + + $system_file = new system_file($pathhd . $filehd); + + $meta_writable = true; } - - if (!$subdef_def) - throw new Exception('Unknown subdef name'); - - try + else { - $value = $this->get_subdef($name); - - if ($value->is_substituted()) + $subdefs = $this->get_databox()->get_subdef_structure(); + + foreach ($subdefs as $type => $datas) { - throw new Exception('Cannot replace a substitution'); + if ($this->get_type() != $type) + continue; + + if (!isset($datas[$name])) + throw new Exception('No available subdef declaration for this type and name'); + + $subdef_def = $datas[$name]; + break; } - - $original_file = p4string::addEndSlash($value->get_path()) . $value->get_file(); - unlink($original_file); - } - catch (Exception $e) - { - $path = databox::dispatch($subdef_def->get_path()); - system_file::mkdir($path); - $original_file = $path . $newfilename; - } - $path_file_dest = $original_file; + if (!$subdef_def) + throw new Exception('Unknown subdef name'); - if (trim($subdef_def->get_baseurl()) !== '') - { - $base_url = str_replace( - array((string) $subdef_def->get_path(), $newfilename) - , array((string) $subdef_def->get_baseurl(), '') - , $path_file_dest - ); + try + { + $value = $this->get_subdef($name); + + if ($value->is_substituted()) + { + throw new Exception('Cannot replace a substitution'); + } + + $original_file = p4string::addEndSlash($value->get_path()) . $value->get_file(); + unlink($original_file); + } + catch (Exception $e) + { + $path = databox::dispatch($subdef_def->get_path()); + system_file::mkdir($path); + $original_file = $path . $newfilename; + } + + $path_file_dest = $original_file; + + if (trim($subdef_def->get_baseurl()) !== '') + { + $base_url = str_replace( + array((string) $subdef_def->get_path(), $newfilename) + , array((string) $subdef_def->get_baseurl(), '') + , $path_file_dest + ); + } + + $registry = registry::get_instance(); + + $adapter = new binaryAdapter_image_resize($registry); + $adapter->execute($pathfile, $path_file_dest, $subdef_def->get_options()); + + $system_file = new system_file($path_file_dest); + $system_file->chmod(); + + $meta_writable = $subdef_def->meta_writeable(); } try @@ -1008,14 +1074,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface ) ); - $registry = registry::get_instance(); - - $adapter = new binaryAdapter_image_resize($registry); - $adapter->execute($pathfile, $path_file_dest, $subdef_def->get_options()); - - $system_file = new system_file($path_file_dest); - $system_file->chmod(); - $image_size = $system_file->get_technical_datas(); $sql = 'INSERT INTO subdef @@ -1025,6 +1083,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface (:record_id, :name, :baseurl, :filename, :width, :height, :mime, :path, :filesize, "1")'; + echo "substitute subdef $name with $base_url ".$system_file->getPath()." ".$system_file->getFilename()."
"; $stmt = $connbas->prepare($sql); $stmt->execute(array( @@ -1047,7 +1106,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $this->delete_data_from_cache(self::CACHE_SUBDEFS); - if ($subdef_def->meta_writeable()) + if ($meta_writable) { $this->write_metas(); } @@ -1055,12 +1114,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface { $this->rebuild_subdefs(); } + + $type = $name == 'document' ? 'HD' : $name; + + $session->get_logger($record->get_databox()) + ->log($record, Session_Logger::EVENT_SUBSTITUTE, $type, ''); } catch (Exception $e) { unset($e); } + return $this; } @@ -1080,7 +1145,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface ':record_id' => $this->record_id ) ); - + $this->reindex(); return $this; @@ -1306,7 +1371,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface * @param boolean $is_grouping * @return record_adapter */ - public static function create(collection $collection, system_file &$system_file, $original_name=false, $is_grouping = false) + public static function create(collection $collection, system_file &$system_file, $original_name = false, $is_grouping = false) { $type = $system_file->get_phrasea_type(); @@ -1841,7 +1906,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface * @param int $how_many * @return type */ - public static function get_records_by_originalname(databox $databox, $original_name, $offset_start=0, $how_many=10) + public static function get_records_by_originalname(databox $databox, $original_name, $offset_start = 0, $how_many = 10) { $offset_start = (int) ($offset_start < 0 ? 0 : $offset_start); $how_many = (int) (($how_many > 20 || $how_many < 1) ? 10 : $how_many); From de10de6a12ac0105883d9a5bfa6af1742696a945 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Jan 2012 20:09:02 +0100 Subject: [PATCH 7/8] Substitution enhancement --- www/prod/chghddocument.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/www/prod/chghddocument.php b/www/prod/chghddocument.php index 81872143cf..6e43bd878b 100644 --- a/www/prod/chghddocument.php +++ b/www/prod/chghddocument.php @@ -48,8 +48,11 @@ if (!isset($_FILES["newHD"]) || $_FILES["newHD"]["tmp_name"] == "" || $_FILES["n try { $record = new record_adapter($parm['sbas_id'], $parm['record_id']); - p4file::substitute($record, $_FILES["newHD"]["tmp_name"], $_FILES["newHD"]["name"], ($parm['ccfilename'] == '1')); -} + $record->substitute_subdef('document', new system_file($_FILES["newHD"]["tmp_name"])); + if($parm['ccfilename'] == '1') + { + $record->set_original_name($_FILES["newHD"]["name"]); + } catch (Exception $e) { echo '
', $e->getMessage(), '

'; From 0b27c161c56abf7952824e2a2358bdb00f8f0259 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Jan 2012 20:32:58 +0100 Subject: [PATCH 8/8] Fix editing records --- www/prod/jquery.edit.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/www/prod/jquery.edit.js b/www/prod/jquery.edit.js index f9db0030c7..dbfb959814 100644 --- a/www/prod/jquery.edit.js +++ b/www/prod/jquery.edit.js @@ -1836,27 +1836,27 @@ function preset_load(preset_id) { if(p4.edit.T_fields[i].preset != null) { + if(!(""+i in p4.edit.T_records[r].fields)) + { + p4.edit.T_records[r].fields[""+i] = {}; + } + if(p4.edit.T_fields[i].multi) { - p4.edit.T_records[r].fields[""+i] = { - value:[], - "meta_struct_id":p4.edit.T_fields[i].meta_struct_id, - dirty:true - };// = { - var n = 0; + p4.edit.T_records[r].fields[""+i].value = []; + p4.edit.T_records[r].fields[""+i].meta_struct_id = p4.edit.T_fields[i].meta_struct_id; + p4.edit.T_records[r].fields[""+i].dirty = true; + for(val in p4.edit.T_fields[i].preset) { - p4.edit.T_records[r].fields[""+i].value[n] = p4.edit.T_fields[i].preset[val]; - n++; + p4.edit.T_records[r].fields[""+i].push(p4.edit.T_fields[i].preset[val]); } } else { - p4.edit.T_records[r].fields[""+i] = { - "value":p4.edit.T_fields[i].preset[0], - "meta_struct_id":p4.edit.T_fields[i].meta_struct_id, - "dirty":true - }; + p4.edit.T_records[r].fields[""+i].value = p4.edit.T_fields[i].preset[0]; + p4.edit.T_records[r].fields[""+i].meta_struct_id = p4.edit.T_fields[i].meta_struct_id; + p4.edit.T_records[r].fields[""+i].dirty = true; } } }