Add curly braces

This commit is contained in:
Romain Neutron
2012-04-26 01:55:12 +02:00
parent ade22295ad
commit 33b10d6746
86 changed files with 2969 additions and 2698 deletions

View File

@@ -36,12 +36,13 @@ return call_user_func(function() {
$app->get('/', function() use ($app) {
$browser = \Browser::getInstance();
if ($browser->isMobile())
if ($browser->isMobile()) {
return $app->redirect("/login/?redirect=/lightbox");
elseif ($browser->isNewGeneration())
} elseif ($browser->isNewGeneration()) {
return $app->redirect("/login/?redirect=/prod");
else
} else {
return $app->redirect("/login/?redirect=/client");
}
});
$app->get('/robots.txt', function() use ($app) {

View File

@@ -56,10 +56,11 @@ return call_user_func(function() {
$app->get('/', function() use ($app) {
if ($app['install'] === true)
if ($app['install'] === true) {
return $app->redirect('/setup/installer/');
if ($app['upgrade'] === true)
}if ($app['upgrade'] === true) {
return $app->redirect('/setup/upgrader/');
}
});

View File

@@ -83,8 +83,9 @@ class Publications implements ControllerProviderInterface
$feed = new \Feed_Adapter($appbox, $id);
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
if ( ! $feed->is_owner($user))
if ( ! $feed->is_owner($user)) {
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
}
$request = $app['request'];
@@ -107,29 +108,35 @@ class Publications implements ControllerProviderInterface
$feed = new \Feed_Adapter($appbox, $id);
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
if ( ! $feed->is_owner($user))
if ( ! $feed->is_owner($user)) {
return new Response('ERROR:you are not allowed');
}
$request = $app["request"];
$fileData = $request->files->get("Filedata");
if ($fileData['error'] !== 0)
if ($fileData['error'] !== 0) {
return new Response('ERROR:error while upload');
}
$file = new \system_file($fileData['tmp_name']);
if ( ! in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
if ( ! in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif'))) {
return new Response('ERROR:bad filetype');
}
if ($file->getSize() > 200000)
if ($file->getSize() > 200000) {
return new Response('ERROR:file too large');
}
$datas = $file->get_technical_datas();
if ( ! isset($datas[\system_file::TC_DATAS_WIDTH]) || ! isset($datas[\system_file::TC_DATAS_HEIGHT]))
if ( ! isset($datas[\system_file::TC_DATAS_WIDTH]) || ! isset($datas[\system_file::TC_DATAS_HEIGHT])) {
return new Response('ERROR:file is not square');
}
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT])
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT]) {
return new Response('ERROR:file is not square');
}
$feed->set_icon($file);
unlink($file->getPathname());

View File

@@ -62,8 +62,9 @@ class MoveCollection extends RecordHelper
{
$this->available_destinations = array();
if ( ! $this->is_possible)
if ( ! $this->is_possible) {
return $this;
}
$this->available_destinations = array_keys(
$this->getCore()->getAuthenticatedUser()->ACL()->get_granted_base(

View File

@@ -291,8 +291,9 @@ class Basket
}
}
if ($total_el1 === $total_el2)
if ($total_el1 === $total_el2) {
return 0;
}
return $total_el1 < $total_el2 ? 1 : -1;
}
@@ -313,8 +314,9 @@ class Basket
}
}
if ($total_el1 === $total_el2)
if ($total_el1 === $total_el2) {
return 0;
}
return $total_el1 < $total_el2 ? 1 : -1;
}

View File

@@ -121,8 +121,9 @@ class ACL implements cache_cacheableInterface
$key = $record->get_serialize_key();
if (array_key_exists($key, $this->_rights_records_document))
if (array_key_exists($key, $this->_rights_records_document)) {
return true;
}
return false;
}
@@ -229,8 +230,9 @@ class ACL implements cache_cacheableInterface
*/
public function apply_model(User_Interface $template_user, Array $base_ids)
{
if (count($base_ids) == 0)
if (count($base_ids) == 0) {
return $this;
}
$sbas_ids = array();
@@ -378,8 +380,9 @@ class ACL implements cache_cacheableInterface
{
$this->load_rights_bas();
if ( ! $this->has_access_to_base($base_id))
if ( ! $this->has_access_to_base($base_id)) {
return false;
}
if ($this->is_limited($base_id)) {
return false;
@@ -463,8 +466,9 @@ class ACL implements cache_cacheableInterface
{
$this->load_rights_bas();
if ( ! $this->has_access_to_base($base_id))
if ( ! $this->has_access_to_base($base_id)) {
return false;
}
return $this->_rights_bas[$base_id]['restrict_dwnld'];
}
@@ -479,8 +483,9 @@ class ACL implements cache_cacheableInterface
{
$this->load_rights_bas();
if ( ! $this->has_access_to_base($base_id))
if ( ! $this->has_access_to_base($base_id)) {
return false;
}
return (int) $this->_rights_bas[$base_id]['remain_dwnld'];
}
@@ -496,8 +501,9 @@ class ACL implements cache_cacheableInterface
{
$this->load_rights_bas();
if ( ! $this->has_access_to_base($base_id))
if ( ! $this->has_access_to_base($base_id)) {
return false;
}
$this->_rights_bas[$base_id]['remain_dwnld'] =
$this->_rights_bas[$base_id]['remain_dwnld'] - (int) $n;
@@ -535,14 +541,16 @@ class ACL implements cache_cacheableInterface
{
$this->load_rights_sbas();
if ( ! isset($this->_rights_sbas[$sbas_id]))
if ( ! isset($this->_rights_sbas[$sbas_id])) {
return false;
}
if ( ! isset($this->_rights_sbas[$sbas_id][$right]))
throw new Exception('This right does not exists');
if ($this->_rights_sbas[$sbas_id][$right] === true)
if ($this->_rights_sbas[$sbas_id][$right] === true) {
return true;
}
return false;
}
@@ -556,8 +564,9 @@ class ACL implements cache_cacheableInterface
public function get_mask_and($base_id)
{
$this->load_rights_bas();
if ( ! $this->has_access_to_base($base_id))
if ( ! $this->has_access_to_base($base_id)) {
return false;
}
return $this->_rights_bas[$base_id]['mask_and'];
}
@@ -571,8 +580,9 @@ class ACL implements cache_cacheableInterface
public function get_mask_xor($base_id)
{
$this->load_rights_bas();
if ( ! $this->has_access_to_base($base_id))
if ( ! $this->has_access_to_base($base_id)) {
return false;
}
return $this->_rights_bas[$base_id]['mask_xor'];
}
@@ -698,8 +708,9 @@ class ACL implements cache_cacheableInterface
protected function load_hd_grant()
{
if ($this->_rights_records_preview)
if ($this->_rights_records_preview) {
return $this;
}
try {
$tmp_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_RECORDS);
@@ -747,8 +758,9 @@ class ACL implements cache_cacheableInterface
protected function load_rights_sbas()
{
if ($this->_rights_sbas && $this->_global_rights)
if ($this->_rights_sbas && $this->_global_rights) {
return $this;
}
try {
$this->_rights_sbas = $this->get_data_from_cache(self::CACHE_RIGHTS_SBAS);
@@ -804,8 +816,9 @@ class ACL implements cache_cacheableInterface
*/
protected function load_rights_bas()
{
if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited))
if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) {
return $this;
}
try {
$this->_rights_bas = $this->get_data_from_cache(self::CACHE_RIGHTS_BAS);
@@ -1286,8 +1299,9 @@ class ACL implements cache_cacheableInterface
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ( ! $row)
if ( ! $row) {
return $this;
}
$this->give_access_to_base(array($base_id_dest));
@@ -1445,8 +1459,10 @@ class ACL implements cache_cacheableInterface
public function get_limits($base_id)
{
$this->load_rights_bas();
if ( ! isset($this->_limited[$base_id]))
if ( ! isset($this->_limited[$base_id])) {
return null;
}
return ($this->_limited[$base_id]);
}

View File

@@ -194,8 +194,9 @@ class API_OAuth2_Adapter extends OAuth2
try {
$application = API_OAuth2_Application::load_from_client_id($this->appbox, $client_id);
if ($client_secret === NULL)
if ($client_secret === NULL) {
return true;
}
$crypted = $this->crypt_secret($client_secret, $application->get_nonce());
@@ -610,13 +611,16 @@ class API_OAuth2_Adapter extends OAuth2
$token_param = $this->getAccessTokenParams();
if ($token_param === FALSE) // Access token was not provided
if ($token_param === FALSE) { // Access token was not provided
return $exit_not_present ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_BAD_REQUEST, $realm, OAUTH2_ERROR_INVALID_REQUEST, 'The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.', NULL, $scope) : FALSE;
}
// Get the stored token data (from the implementing subclass)
$token = $this->getAccessToken($token_param);
if ($token === NULL)
if ($token === NULL) {
return $exit_invalid ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_INVALID_TOKEN, 'The access token provided is invalid.', NULL, $scope) : FALSE;
}
if (isset($token['revoked']) && $token['revoked']) {
return $exit_invalid ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_INVALID_TOKEN, 'End user has revoked access to his personal datas for your application.', NULL, $scope) : FALSE;
@@ -624,14 +628,15 @@ class API_OAuth2_Adapter extends OAuth2
if ($this->enable_expire) {
// Check token expiration (I'm leaving this check separated, later we'll fill in better error messages)
if (isset($token["expires"]) && time() > $token["expires"])
if (isset($token["expires"]) && time() > $token["expires"]) {
return $exit_expired ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_UNAUTHORIZED, $realm, OAUTH2_ERROR_EXPIRED_TOKEN, 'The access token provided has expired.', NULL, $scope) : FALSE;
}
}
// Check scope, if provided
// If token doesn't have a scope, it's NULL/empty, or it's insufficient, then throw an error
if ($scope && ( ! isset($token["scope"]) || ! $token["scope"] || ! $this->checkScope($scope, $token["scope"])))
if ($scope && ( ! isset($token["scope"]) || ! $token["scope"] || ! $this->checkScope($scope, $token["scope"]))) {
return $exit_scope ? $this->errorWWWAuthenticateResponseHeader(OAUTH2_HTTP_FORBIDDEN, $realm, OAUTH2_ERROR_INSUFFICIENT_SCOPE, 'The request requires higher privileges than provided by the access token.', NULL, $scope) : FALSE;
}
//save token's linked ses_id
$this->session_id = $token['session_id'];
$this->usr_id = $token['usr_id'];

View File

@@ -1116,6 +1116,7 @@ class API_V1_adapter extends API_V1_Abstract
* @todo ajouter une option pour avoir les values serialisées
* dans un cas multi
*/
return array(
'meta_id' => $value->getId()
, 'meta_structure_id' => $field->get_meta_struct_id()

View File

@@ -112,8 +112,9 @@ class API_V1_result
protected function parse_response_type()
{
if (trim($this->request->get('callback')) !== '')
if (trim($this->request->get('callback')) !== '') {
return $this->response_type = self::FORMAT_JSONP;
}
$accept = $this->request->getAcceptableContentTypes();
$response_types = array();

View File

@@ -108,8 +108,10 @@ class Bridge_Api
*/
public function is_disabled()
{
if ($this->disable_time === null)
if ($this->disable_time === null) {
return false;
}
$date_obj = new DateTime();
if ($date_obj > $this->disable_time) {
$this->enable();

View File

@@ -647,14 +647,17 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
public function is_configured()
{
if ( ! $this->registry->get('GV_dailymotion_api'))
if ( ! $this->registry->get('GV_dailymotion_api')) {
return false;
}
if (trim($this->registry->get('GV_dailymotion_client_id')) === '')
if (trim($this->registry->get('GV_dailymotion_client_id')) === '') {
return false;
}
if (trim($this->registry->get('GV_dailymotion_client_secret')) === '')
if (trim($this->registry->get('GV_dailymotion_client_secret')) === '') {
return false;
}
return true;
}

View File

@@ -353,8 +353,10 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
$response = $this->_api->executeMethod('flickr.photosets.addPhoto', $params);
if ( ! $response->isOk()) {
if ($response->err_code === 3) //Already exists in photoset
if ($response->err_code === 3) { //Already exists in photoset
return;
}
throw new Bridge_Exception_ApiConnectorRequestFailed();
}
break;
@@ -626,14 +628,17 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
public function is_configured()
{
if ( ! $this->registry->get('GV_flickr_api'))
if ( ! $this->registry->get('GV_flickr_api')) {
return false;
}
if (trim($this->registry->get('GV_flickr_client_id')) === '')
if (trim($this->registry->get('GV_flickr_client_id')) === '') {
return false;
}
if (trim($this->registry->get('GV_flickr_client_secret')) === '')
if (trim($this->registry->get('GV_flickr_client_secret')) === '') {
return false;
}
return true;
}

View File

@@ -98,8 +98,10 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
private function generate_page_url($entry)
{
if (isset($entry["owner"]) && isset($entry["id"]))
if (isset($entry["owner"]) && isset($entry["id"])) {
return sprintf("http://www.flickr.com/%ss/%s/%s/", $this->type, (string) $entry["owner"], (string) $entry["id"]);
}
return "";
}
@@ -112,27 +114,30 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
*/
private function generate_thumb_url($entry, $size = '', $extension = '')
{
if (isset($entry["url_t"]))
if (isset($entry["url_t"])) {
return (string) $entry["url_t"];
}
if ( ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]))
if ( ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"])) {
return '';
}
$farm = (string) $entry["farm"];
$server_id = (string) $entry["server"];
$id_photo = (string) $entry["id"];
$secret = (string) $entry["secret"];
if (empty($size) && empty($extension))
if (empty($size) && empty($extension)) {
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s.jpg', $farm, $server_id, $id_photo, $secret);
elseif ( ! empty($size) && ! empty($extension))
} elseif ( ! empty($size) && ! empty($extension)) {
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size);
elseif ( ! empty($size))
} elseif ( ! empty($size)) {
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size, '.jpg');
elseif ( ! empty($extension))
} elseif ( ! empty($extension)) {
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_o.%s', $farm, $server_id, $id_photo, $secret, $extension);
else
} else {
return "";
}
}
/**

View File

@@ -632,8 +632,9 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter
$xml = simplexml_load_string($string);
libxml_clear_errors();
if ( ! $xml)
if ( ! $xml) {
return false;
}
if (isset($xml->HEAD) || isset($xml->head)) {
return array();
@@ -793,14 +794,17 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter
public function is_configured()
{
if ( ! $this->registry->get('GV_youtube_api'))
if ( ! $this->registry->get('GV_youtube_api')) {
return false;
}
if (trim($this->registry->get('GV_youtube_client_id')) === '')
if (trim($this->registry->get('GV_youtube_client_id')) === '') {
return false;
}
if (trim($this->registry->get('GV_youtube_dev_key')) === '')
if (trim($this->registry->get('GV_youtube_dev_key')) === '') {
return false;
}
return true;
}

View File

@@ -63,8 +63,9 @@ class Bridge_Api_Youtube_Element implements Bridge_Api_ElementInterface
$video_thumbnails = $this->entry->getVideoThumbnails();
foreach ($video_thumbnails as $thumb) {
if (120 == $thumb['width'] && 90 == $thumb['height'])
if (120 == $thumb['width'] && 90 == $thumb['height']) {
return $thumb['url'];
}
}
}

View File

@@ -130,8 +130,9 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
*/
public function get_icon_url()
{
if ($this->icon_url)
if ($this->icon_url) {
return $this->icon_url;
}
$url = '/skins/icons/rss32.gif';

View File

@@ -83,8 +83,9 @@ class Feed_Aggregate extends Feed_Abstract implements Feed_Interface
{
$result = new Feed_Entry_Collection();
if (count($this->feeds) === 0)
if (count($this->feeds) === 0) {
return $result;
}
$offset_start = (int) $offset_start;
$how_many = $how_many > 20 ? 20 : (int) $how_many;
@@ -117,8 +118,10 @@ class Feed_Aggregate extends Feed_Abstract implements Feed_Interface
*/
public function get_count_total_entries()
{
if (count($this->feeds) === 0)
if (count($this->feeds) === 0) {
return 0;
}
$sql = 'SELECT count(id) as number
FROM feed_entries
WHERE feed_id

View File

@@ -406,8 +406,9 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
*/
public function get_content()
{
if ($this->items)
if ($this->items) {
return $this->items;
}
$rs = $this->retrieve_elements();
$items = array();

View File

@@ -210,7 +210,9 @@ class Feed_Publisher_Adapter implements Feed_Publisher_Interface, cache_cacheabl
{
foreach ($feed->get_publishers() as $publisher) {
if ($publisher->get_user()->get_id() === $user->get_id())
{
return $publisher;
}
}
throw new Exception_Feed_PublisherNotFound('Publisher not found');
}

View File

@@ -227,11 +227,13 @@ abstract class Feed_XML_Abstract
$medium = strtolower($content->get_record()->get_type());
if ( ! in_array($medium, array('image', 'audio', 'video')))
if ( ! in_array($medium, array('image', 'audio', 'video'))) {
return $this;
}
if ( ! $preview_permalink || ! $thumbnail_permalink)
if ( ! $preview_permalink || ! $thumbnail_permalink) {
return $this;
}
$group = $this->addTag($document, $item, 'media:group');

View File

@@ -357,11 +357,13 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
$medium = strtolower($content->get_record()->get_type());
if ( ! in_array($medium, array('image', 'audio', 'video')))
if ( ! in_array($medium, array('image', 'audio', 'video'))) {
return $this;
}
if ( ! $preview_permalink || ! $thumbnail_permalink)
if ( ! $preview_permalink || ! $thumbnail_permalink) {
return $this;
}
//add item node to channel node
$item = $this->addTag($document, $node, 'item');

View File

@@ -260,8 +260,9 @@ class Session_Authentication_Native implements Session_Authentication_Interface
$row_count = $stmt->rowCount();
$stmt->closeCursor();
if ($row_count == 0)
if ($row_count == 0) {
return $this;
}
if ($this->captcha_challenge_result === true) {
$sql = 'UPDATE badlog SET locked="0" WHERE (login=:login OR ip=:ip)';

View File

@@ -79,8 +79,9 @@ class Session_Handler
public function logout()
{
// $this->remove_cookies();
if ( ! $this->is_authenticated())
if ( ! $this->is_authenticated()) {
return;
}
$this->storage()->reset();
$this->close_phrasea_session();
@@ -240,12 +241,13 @@ class Session_Handler
*/
public static function get_cookie($name, $default_value = null)
{
if (http_request::is_command_line() && isset(self::$_cookie[$name]))
if (http_request::is_command_line() && isset(self::$_cookie[$name])) {
return self::$_cookie[$name];
elseif ( ! http_request::is_command_line() && isset($_COOKIE[$name]))
} elseif ( ! http_request::is_command_line() && isset($_COOKIE[$name])) {
return $_COOKIE[$name];
elseif ($default_value !== null)
} elseif ($default_value !== null) {
return $default_value;
}
return null;
}
@@ -279,10 +281,11 @@ class Session_Handler
else
unset($_COOKIE[$name]);
}
if ( ! http_request::is_command_line())
if ( ! http_request::is_command_line()) {
return setcookie($name, $value, $expire, '/', '', $https, $http_only);
else
} else {
return true;
}
}
/**
@@ -292,10 +295,11 @@ class Session_Handler
*/
public static function isset_cookie($name)
{
if (http_request::is_command_line())
if (http_request::is_command_line()) {
return isset(self::$_cookie[$name]);
else
return isset($_COOKIE[$name]);
}
return isset($_COOKIE[$name]);
}
public function renew_phrasea_session()
@@ -417,8 +421,9 @@ class Session_Handler
$basks = array();
$oldusr = self::get_cookie('invite-usr_id');
if ($oldusr == $this->get_usr_id())
if ($oldusr == $this->get_usr_id()) {
return $this;
}
$sql = 'SELECT sselcont_id, s.ssel_id
FROM sselcont c, ssel s

View File

@@ -125,8 +125,10 @@ class Setup_Upgrade
*/
protected function get_percentage()
{
if ($this->total_steps === 0)
if ($this->total_steps === 0) {
return 1;
}
return round(max(min(($this->completed_steps / $this->total_steps), 1), 0), 2);
}

View File

@@ -891,8 +891,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public static function get_usr_id_from_email($email)
{
if (is_null($email))
if (is_null($email)) {
return false;
}
$conn = connection::getPDOConnection();
$sql = 'SELECT usr_id FROM usr
@@ -1260,8 +1261,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected function load_preferences()
{
if ($this->_prefs)
if ($this->_prefs) {
return $this;
}
$registry = \registry::get_instance();
@@ -1484,8 +1486,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
if ( ! $session->is_authenticated())
if ( ! $session->is_authenticated()) {
return;
}
$ses_id = $session->get_ses_id();
$usr_id = $session->get_usr_id();
@@ -1733,8 +1736,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public function get_nonce()
{
if ($this->nonce)
if ($this->nonce) {
return $this->nonce;
}
$nonce = false;
$sql = 'SELECT nonce FROM usr WHERE usr_id = :usr_id ';

View File

@@ -540,8 +540,9 @@ class User_Query implements User_QueryInterface
*/
public function get_total()
{
if ($this->total)
if ($this->total) {
return $this->total;
}
$conn = $this->appbox->get_connection();
@@ -698,8 +699,9 @@ class User_Query implements User_QueryInterface
*/
public function on_base_ids(Array $base_ids = null)
{
if ( ! $base_ids)
if ( ! $base_ids) {
return $this;
}
$this->bases_restrictions = true;
@@ -722,8 +724,9 @@ class User_Query implements User_QueryInterface
*/
public function on_sbas_ids(Array $sbas_ids = null)
{
if ( ! $sbas_ids)
if ( ! $sbas_ids) {
return $this;
}
$this->sbas_restrictions = true;

View File

@@ -140,12 +140,14 @@ class appbox extends base
}
$custom_path.= $collection->get_base_id();
if (is_null($pathfile))
if (is_null($pathfile)) {
return $this;
}
$datas = file_get_contents($pathfile->getPathname());
if (is_null($datas))
if (is_null($datas)) {
return $this;
}
file_put_contents($file, $datas);
file_put_contents($custom_path, $datas);
@@ -190,12 +192,14 @@ class appbox extends base
}
$custom_path.= $pic_type . '_' . $databox->get_sbas_id();
if (is_null($pathfile))
if (is_null($pathfile)) {
return $this;
}
$datas = file_get_contents($pathfile->getPathname());
if (is_null($datas))
if (is_null($datas)) {
return $this;
}
file_put_contents($file, $datas);
file_put_contents($custom_path, $datas);
@@ -515,8 +519,9 @@ class appbox extends base
*/
public function get_databoxes()
{
if ($this->databoxes)
if ($this->databoxes) {
return $this->databoxes;
}
$ret = array();
foreach ($this->retrieve_sbas_ids() as $sbas_id) {

View File

@@ -76,8 +76,9 @@ abstract class base implements cache_cacheableInterface
*/
public function get_schema()
{
if ($this->schema)
if ($this->schema) {
return $this->schema;
}
$this->load_schema();
@@ -223,9 +224,9 @@ abstract class base implements cache_cacheableInterface
public function get_version()
{
if ($this->version)
if ($this->version) {
return $this->version;
}
$version = '0.0.0';
@@ -251,10 +252,11 @@ abstract class base implements cache_cacheableInterface
public function upgradeavailable()
{
if ($this->get_version())
if ($this->get_version()) {
return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>');
else
} else {
return true;
}
}
protected function upgradeDb($apply_patches, Setup_Upgrade &$upgrader)
@@ -375,8 +377,9 @@ abstract class base implements cache_cacheableInterface
*/
protected function load_schema()
{
if ($this->schema)
if ($this->schema) {
return $this;
}
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");

View File

@@ -203,8 +203,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
public function get_field($fieldname)
{
foreach ($this->get_fields() as $meta_struct_id => $field) {
if ($field->get_name() == $fieldname)
if ($field->get_name() == $fieldname) {
return $field;
}
}
throw new \Exception('Field not found');

View File

@@ -52,8 +52,10 @@ class connection
public static function printLog()
{
$registry = registry::get_instance();
if ( ! $registry->get('GV_debug'))
if ( ! $registry->get('GV_debug')) {
return;
}
$totalTime = 0;
foreach (self::$log as $entry) {
@@ -109,9 +111,9 @@ class connection
$name = 'appbox';
} elseif (is_int((int) $name)) {
$name = (int) $name;
}
else
} else {
return false;
}
if ( ! isset(self::$_PDO_instance[$name])) {
$hostname = $port = $user = $password = $dbname = false;
@@ -149,8 +151,10 @@ class connection
throw new Exception('Connection not available');
}
}
if (array_key_exists($name, self::$_PDO_instance))
if (array_key_exists($name, self::$_PDO_instance)) {
return self::$_PDO_instance[$name];
}
throw new Exception('Connection not available');
}

View File

@@ -65,10 +65,11 @@ class connection_pdo extends connection_abstract implements connection_interface
*/
public function prepare($statement, $driver_options = array())
{
if ($this->registry->get('GV_debug'))
if ($this->registry->get('GV_debug')) {
return new connection_pdoStatementDebugger(parent::prepare($statement, $driver_options));
else
} else {
return parent::prepare($statement, $driver_options);
}
}
/**

View File

@@ -429,8 +429,9 @@ class databox extends base
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row)
if ($row) {
return self::get_instance((int) $row['sbas_id']);
}
try {
$sql = 'CREATE DATABASE `' . $dbname . '`
@@ -664,8 +665,9 @@ class databox extends base
}
}
}
if ($n > $limit)
if ($n > $limit) {
return true;
}
return false;
}
@@ -1151,8 +1153,10 @@ class databox extends base
*/
public function get_structure()
{
if ($this->structure)
if ($this->structure) {
return $this->structure;
}
$this->structure = $this->retrieve_structure();
return $this->structure;
@@ -1187,8 +1191,9 @@ class databox extends base
*/
public function get_cterms()
{
if ($this->cterms)
if ($this->cterms) {
return $this->cterms;
}
$sql = "SELECT value FROM pref WHERE prop='cterms'";
$stmt = $this->get_connection()->prepare($sql);
@@ -1343,8 +1348,9 @@ class databox extends base
public function get_cgus()
{
if ($this->cgus)
if ($this->cgus) {
return $this->cgus;
}
$this->load_cgus();

View File

@@ -95,8 +95,9 @@ class databox_descriptionStructure implements IteratorAggregate
{
$name = databox_field::generateName($name);
if (isset($this->cache_name_id[$name]))
if (isset($this->cache_name_id[$name])) {
return $this->elements[$this->cache_name_id[$name]];
}
foreach ($this->elements as $id => $meta) {
if ($meta->get_name() === $name) {

View File

@@ -62,8 +62,9 @@ class databox_status
$sbas_params = phrasea::sbas_params();
$registry = registry::get_instance();
if ( ! isset($sbas_params[$sbas_id]))
if ( ! isset($sbas_params[$sbas_id])) {
return;
}
$path = $this->path = $registry->get('GV_RootPath') . "config/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
$url = $this->url = "/custom/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
@@ -115,8 +116,9 @@ class databox_status
public static function getDisplayStatus()
{
if (self::$_statuses)
if (self::$_statuses) {
return self::$_statuses;
}
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
@@ -243,8 +245,9 @@ class databox_status
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
return false;
}
$status = self::getStatus($sbas_id);
@@ -295,8 +298,9 @@ class databox_status
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
return false;
}
$status = self::getStatus($sbas_id);
@@ -372,15 +376,17 @@ class databox_status
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
return false;
}
$status = self::getStatus($sbas_id);
$switch = in_array($switch, array('on', 'off')) ? $switch : false;
if ( ! $switch)
if ( ! $switch) {
return false;
}
if ($status[$bit]['img_' . $switch]) {
if (isset($status[$bit]['path_' . $switch]))

View File

@@ -44,8 +44,9 @@ function giveMeBases($usr = null)
$rsU = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (count($rsU) == 0)
if (count($rsU) == 0) {
return null;
}
foreach ($rsU as $rowU) {
if ( ! isset($usrerRegis[$rowU['dbname']]))

View File

@@ -316,8 +316,9 @@ class eventsmanager_broker
function read(Array $notifications, $usr_id)
{
if (count($notifications) == 0)
if (count($notifications) == 0) {
return false;
}
$sql = 'UPDATE notifications SET unread="0"
WHERE usr_id = :usr_id

View File

@@ -49,8 +49,9 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$params = array_merge($default, $params);
$base_ids = array_keys($params['autoregister']);
if (count($base_ids) == 0)
if (count($base_ids) == 0) {
return;
}
$mailColl = array();
@@ -261,8 +262,9 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
{
$bool = false;
$session = $this->appbox->get_session();
if ( ! $session->is_authenticated() || ! login::register_enabled())
if ( ! $session->is_authenticated() || ! login::register_enabled()) {
return false;
}
try {
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);

View File

@@ -73,9 +73,9 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
}
if (count($users) == 0)
if (count($users) == 0) {
return;
}
$dom_xml = new DOMDocument('1.0', 'UTF-8');
@@ -239,8 +239,9 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
{
$bool = false;
$session = $this->appbox->get_session();
if ( ! $session->is_authenticated())
if ( ! $session->is_authenticated()) {
return false;
}
try {
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);

View File

@@ -49,8 +49,9 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$params = array_merge($default, $params);
$base_ids = $params['demand'];
if (count($base_ids) == 0)
if (count($base_ids) == 0) {
return;
}
$mailColl = array();
@@ -267,8 +268,9 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$bool = false;
$session = $this->appbox->get_session();
if ( ! $session->is_authenticated() || ! login::register_enabled())
if ( ! $session->is_authenticated() || ! login::register_enabled()) {
return false;
}
try {
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);

View File

@@ -212,8 +212,9 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$bool = false;
$session = $this->appbox->get_session();
if ( ! $session->is_authenticated())
if ( ! $session->is_authenticated()) {
return false;
}
try {
$user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox);

View File

@@ -169,8 +169,9 @@ class ftpclient
public function mkdir($remote_directory)
{
$remote_directory = $this->get_absolute_path($remote_directory);
if (isset($this->cached_dirs[$remote_directory]))
if (isset($this->cached_dirs[$remote_directory])) {
return $this;
}
if ($this->debug)
echo "Creation du dossier $remote_directory\n<br>";
@@ -311,8 +312,10 @@ class ftpclient
{
if ($this->debug)
echo "Fermeture de la connexion\n<br>";
if ( ! $this->connexion)
if ( ! $this->connexion) {
return $this;
}
if ((ftp_close($this->connexion)) === false) {
throw new Exception('Impossible de fermer la connexion');
}
@@ -334,8 +337,9 @@ class ftpclient
protected function get_absolute_path($file)
{
$file = str_replace('//', '/', $file);
if ($this->is_absolute_path($file))
if ($this->is_absolute_path($file)) {
return $file;
}
$pwd = $this->add_end_slash($this->pwd());
@@ -346,8 +350,9 @@ class ftpclient
{
$path = trim($path);
if ($path == "" || $path == '/' || $path == '//')
if ($path == "" || $path == '/' || $path == '//') {
return("/");
}
if (substr($path, -1, 1) != "/")
$path .= "/";

View File

@@ -77,8 +77,9 @@ class gatekeeper
$appbox = appbox::get_instance($this->Core);
$session = $appbox->get_session();
if (http_request::is_command_line())
if (http_request::is_command_line()) {
return;
}
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) {
$this->_PHP_SELF = $_SERVER['PHP_SELF'];
@@ -119,16 +120,18 @@ class gatekeeper
case 'thesaurus2':
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') {
return;
}
phrasea::redirect('/login/?redirect=/thesaurus2');
break;
case 'report':
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
break;
case 'admin':
if ($this->_script_name === 'runscheduler.php')
if ($this->_script_name === 'runscheduler.php') {
return;
}
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
break;
case 'login':
@@ -145,10 +148,11 @@ class gatekeeper
case '':
return;
case 'setup':
if ($appbox->upgradeavailable())
if ($appbox->upgradeavailable()) {
return;
else
} else {
phrasea::redirect('/login/');
}
break;
default:
phrasea::redirect('/login/');
@@ -246,8 +250,9 @@ class gatekeeper
$session = $appbox->get_session();
$parm = $request->get_parms('LOG');
if (is_null($parm["LOG"]))
if (is_null($parm["LOG"])) {
return $this;
}
try {
if ($session->is_authenticated())

View File

@@ -91,8 +91,9 @@ class geonames
$output = array();
$cityName = self::clean_input($cityName);
if (strlen($cityName) === 0)
if (strlen($cityName) === 0) {
return $output;
}
$registry = registry::get_instance();
$url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
@@ -128,8 +129,9 @@ class geonames
public function find_geoname_from_ip($ip)
{
if (array_key_exists($ip, $this->cache_ips))
if (array_key_exists($ip, $this->cache_ips)) {
return $this->cache_ips[$ip];
}
$output = array(
'city' => '',

View File

@@ -25,11 +25,13 @@ class http_query
*/
public static function getHttpCodeFromUrl($url)
{
if ( ! is_scalar($url))
if ( ! is_scalar($url)) {
return null;
}
if (trim($url) === '')
if (trim($url) === '') {
return null;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -51,11 +53,14 @@ class http_query
public static function getHttpHeaders($url)
{
if ( ! is_scalar($url))
if ( ! is_scalar($url)) {
return null;
}
if (trim($url) === '')
if (trim($url) === '') {
return null;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -82,11 +87,13 @@ class http_query
*/
public static function getUrl($url, $post_data = false)
{
if ( ! is_scalar($url))
if ( ! is_scalar($url)) {
return null;
}
if (trim($url) === '')
if (trim($url) === '') {
return null;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

View File

@@ -87,8 +87,10 @@ class http_request
public function is_ajax()
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
return true;
}
return false;
}

View File

@@ -33,8 +33,9 @@ class lazaret extends set_abstract
$base_ids = array_keys($user->ACL()->get_granted_base(array('canaddrecord')));
if (count($base_ids) == 0)
if (count($base_ids) == 0) {
return $this;
}
$sql = "SELECT id, filepath, filename, base_id,
uuid, errors, created_on, usr_id

View File

@@ -190,8 +190,9 @@ class mail
$registry = registry::get_instance();
if ( ! isset($to['email']) || ! PHPMailer::ValidateAddress($to['email']))
if ( ! isset($to['email']) || ! PHPMailer::ValidateAddress($to['email'])) {
return false;
}
$mail = new PHPMailer();

View File

@@ -105,10 +105,11 @@ abstract class media_abstract
*/
public function get_orientation()
{
if ($this->width > $this->height)
if ($this->width > $this->height) {
return self::PAYSAGE;
else
} else {
return self::PORTRAIT;
}
}
/**

View File

@@ -152,10 +152,11 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
*/
public function isValid()
{
if (isset($this->dashboard) && sizeof($this->dashboard) > 0)
if (isset($this->dashboard) && sizeof($this->dashboard) > 0) {
return true;
else
} else {
return false;
}
}
/**

View File

@@ -228,10 +228,11 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
*/
public function isValid()
{
if (isset($this->report) && sizeof($this->report) > 0)
if (isset($this->report) && sizeof($this->report) > 0) {
return true;
else
} else {
return false;
}
}
}

View File

@@ -69,10 +69,11 @@ class module_report_dashboard_group implements module_report_dashboard_component
*/
public function isValid()
{
if (isset($this->group_dash) && sizeof($this->group_dash) > 0)
if (isset($this->group_dash) && sizeof($this->group_dash) > 0) {
return true;
else
} else {
return false;
}
}
/**

View File

@@ -121,10 +121,11 @@ class module_report_dashboard_merge implements module_report_dashboard_component
*/
public function isValid()
{
if (isset($this->sorted) && sizeof($this->sorted) > 0)
if (isset($this->sorted) && sizeof($this->sorted) > 0) {
return true;
else
} else {
return false;
}
}
/**

View File

@@ -122,10 +122,11 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function isValid()
{
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0)
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0) {
return true;
else
} else {
return false;
}
}
public function getDash()
@@ -135,8 +136,9 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function getTop($nbtop)
{
if ( ! is_int($nbtop))
if ( ! is_int($nbtop)) {
return array();
}
$tmp = array();

View File

@@ -113,10 +113,11 @@ class module_report_sql
public function getTransQuery($champ)
{
$tanslation = $this->filter->getCorFilter();
if (array_key_exists($champ, $tanslation))
if (array_key_exists($champ, $tanslation)) {
return $tanslation[$champ];
else
} else {
return $champ;
}
}
/**

View File

@@ -184,8 +184,9 @@ class module_report_sqlfilter
$this->filter['collection'] = false;
$coll_filter = array();
if ($report->getUserId() == '')
if ($report->getUserId() == '') {
return;
}
$tab = explode(",", $report->getListCollId());
if (count($tab) > 0) {

View File

@@ -59,8 +59,9 @@ class patch_310 implements patchInterface
$subdefgroups = $sx_structure->xpath('//subdefgroup');
if (count($subdefgroups) > 0)
if (count($subdefgroups) > 0) {
return;
}
$subdefs = $sx_structure->xpath('/record/subdefs');

View File

@@ -215,8 +215,9 @@ class phrasea
public static function sbas_params()
{
if (self::$_sbas_params)
if (self::$_sbas_params) {
return self::$_sbas_params;
}
$appbox = appbox::get_instance(\bootstrap::getCore());
try {
@@ -247,8 +248,9 @@ class phrasea
public static function guest_allowed()
{
$usr_id = User_Adapter::get_usr_id_from_login('invite');
if ( ! $usr_id)
if ( ! $usr_id) {
return false;
}
$appbox = appbox::get_instance(\bootstrap::getCore());
$user = User_Adapter::getInstance($usr_id, $appbox);

View File

@@ -68,8 +68,9 @@ class phraseadate
*/
public static function getPrettyString(DateTime $date = null)
{
if (is_null($date))
if (is_null($date)) {
return null;
}
$compareTo = new DateTime('now');
$diff = $compareTo->format('U') - $date->format('U');

View File

@@ -71,11 +71,13 @@ class queries
$session = $appbox->get_session();
$registry = $appbox->get_registry();
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics_' . $session->get_I18n() . '.xml'))
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics_' . $session->get_I18n() . '.xml')) {
return true;
}
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics.xml'))
if (file_exists($registry->get('GV_RootPath') . 'config/topics/topics.xml')) {
return true;
}
return false;
}
@@ -239,8 +241,10 @@ class queries
private static function hastopics(&$topics)
{
foreach ($topics->topics as $subtopic)
foreach ($topics->topics as $subtopic) {
return true;
}
return false;
}

View File

@@ -255,10 +255,11 @@ class record_exportElement extends record_adapter
*/
public function get_size($name = false)
{
if ($name)
if ($name) {
return $this->size[$name];
else
} else {
return $this->size;
}
}
/**

View File

@@ -196,8 +196,9 @@ class record_preview extends record_adapter
public function get_train($pos = 0, $query = '', searchEngine_adapter $search_engine = null)
{
if ($this->train)
if ($this->train) {
return $this->train;
}
switch ($this->env) {
case 'RESULT':
@@ -257,8 +258,9 @@ class record_preview extends record_adapter
*/
public function get_title($highlight = '', searchEngine_adapter $search_engine = null)
{
if ($this->title)
if ($this->title) {
return $this->title;
}
$this->title = collection::getLogo($this->get_base_id()) . ' ';

View File

@@ -74,13 +74,15 @@ class recordutils_image extends recordutils
$registry = registry::get_instance();
$debug = false;
if ( ! $registry->get('GV_imagick'))
if ( ! $registry->get('GV_imagick')) {
return false;
}
$sbas_id = phrasea::sbasFromBas($bas);
if ( ! isset($sbas_id))
if ( ! isset($sbas_id)) {
return false;
}
$connSbas = connection::getPDOConnection($sbas_id);
@@ -114,8 +116,9 @@ class recordutils_image extends recordutils
);
}
if ($domprefs === FALSE || $sxxml === FALSE)
if ($domprefs === FALSE || $sxxml === FALSE) {
return false;
}
$xpprefs = new DOMXPath($domprefs);
@@ -124,8 +127,9 @@ class recordutils_image extends recordutils
$pathTmpStamp = $registry->get('GV_RootPath') . 'tmp/'
. time() . '-stamptmp_' . $file['file'];
if ( ! is_file($pathIn))
if ( ! is_file($pathIn)) {
return false;
}
if ($file['type'] != 'image' ||
$xpprefs->query('/baseprefs/stamp')->length == 0) {
@@ -151,8 +155,9 @@ class recordutils_image extends recordutils
}
// ------------- CACHING !
if (is_file($pathOut))
if (is_file($pathOut)) {
return $pathOut;
}
$fields = $xpprefs->query('/baseprefs/stamp/*/field');
for ($i = 0; $i < $fields->length; $i ++ ) {
@@ -174,9 +179,9 @@ class recordutils_image extends recordutils
$collname = phrasea::bas_names($bas);
if ( ! ($tailleimg = @getimagesize($pathIn)))
if ( ! ($tailleimg = @getimagesize($pathIn))) {
return false;
}
$image_width = $tailleimg[0];
$image_height = $tailleimg[1];
@@ -326,8 +331,9 @@ class recordutils_image extends recordutils
unlink($pathTmpStamp);
if (is_file($pathOut))
if (is_file($pathOut)) {
return $pathOut;
}
return false;
}
@@ -346,8 +352,9 @@ class recordutils_image extends recordutils
$sbas_id = phrasea::sbasFromBas($bas);
if ( ! isset($sbas_id))
if ( ! isset($sbas_id)) {
return false;
}
$connSbas = connection::getPDOConnection($sbas_id);
@@ -360,8 +367,9 @@ class recordutils_image extends recordutils
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ( ! $row)
if ( ! $row) {
return false;
}
$file = array(
'type' => $row['type']
@@ -374,12 +382,13 @@ class recordutils_image extends recordutils
$pathOut = $file['path'] . 'watermark_' . $file['file'];
if ( ! is_file($pathIn))
if ( ! is_file($pathIn)) {
return false;
}
if (is_file($pathOut))
if (is_file($pathOut)) {
return $pathOut;
}
if ($registry->get('GV_pathcomposite') &&
file_exists($registry->get('GV_RootPath') . 'config/wm/' . $bas)) { // si il y a un WM
@@ -469,8 +478,9 @@ class recordutils_image extends recordutils
}
}
if (is_file($pathOut))
if (is_file($pathOut)) {
return $pathOut;
}
return false;
}

View File

@@ -131,10 +131,11 @@ class registry implements registryInterface
if ( ! $this->cache->contains($key))
$this->load();
if ( ! $this->cache->contains($key) && ! is_null($defaultvalue))
if ( ! $this->cache->contains($key) && ! is_null($defaultvalue)) {
return $defaultvalue;
else
return $this->cache->fetch($key);
}
return $this->cache->fetch($key);
}
/**

View File

@@ -607,7 +607,10 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
);
if ( ! isset($res['results']) || ! is_array($res['results']))
{
return array();
}
$rs = $res['results'];
$res = array_shift($rs);
if ( ! isset($res['xml'])) {

View File

@@ -118,11 +118,14 @@ class searchEngine_adapter_phrasea_queryParser
$this->proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array());
$this->phq = $this->mb_trim($phq, 'UTF-8');
if ($this->phq != "")
if ($this->phq != "") {
return($this->maketree(0));
else {
if ($this->errmsg != "")
} else {
if ($this->errmsg != "") {
$this->errmsg .= sprintf("\\n");
}
$this->errmsg .= _('qparser::la question est vide');
return(null);
@@ -133,32 +136,37 @@ class searchEngine_adapter_phrasea_queryParser
{
switch ($tree["CLASS"]) {
case "SIMPLE":
if (is_array($tree["VALUE"]))
if (is_array($tree["VALUE"])) {
return(implode(" ", $tree["VALUE"]));
else
} else {
return($tree["VALUE"]);
}
break;
case "QSIMPLE":
if (is_array($tree["VALUE"]))
if (is_array($tree["VALUE"])) {
return("\"" . implode(" ", $tree["VALUE"]) . "\"");
else
} else {
return("\"" . $tree["VALUE"] . "\"");
}
break;
case "PHRASEA_KW_ALL":
return($tree["VALUE"][0]);
break;
case "PHRASEA_KW_LAST":
if ($tree["PNUM"] !== null)
if ($tree["PNUM"] !== null) {
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
else
} else {
return($tree["VALUE"][0]);
}
break;
case "OPS":
case "OPK":
if (isset($tree["PNUM"]))
if (isset($tree["PNUM"])) {
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext($tree["RB"]) . ")");
else
} else {
return("(" . $this->astext($tree["LB"]) . " " . $tree["VALUE"] . " " . $this->astext($tree["RB"]) . ")");
}
break;
}
}
@@ -176,10 +184,11 @@ class searchEngine_adapter_phrasea_queryParser
function calc_complexity(&$tree)
{
if ($tree) {
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
return($tree["COMPLEXITY"] = $this->calc_complexity($tree["LB"]) + $this->calc_complexity($tree["RB"]));
else
} else {
return($tree["COMPLEXITY"] = 1);
}
}
}
@@ -338,8 +347,10 @@ class searchEngine_adapter_phrasea_queryParser
function priority_opk(&$tree, $depth = 0)
{
if ( ! $tree)
if ( ! $tree) {
return;
}
if ($tree["CLASS"] == "OPK" && ($tree["LB"]["CLASS"] == "OPS" || $tree["LB"]["CLASS"] == "OPK")) {
// on a un truc du genre ((a ou b) < 5), on le transforme en (a ou (b < 5))
$t = $tree["LB"];
@@ -347,16 +358,19 @@ class searchEngine_adapter_phrasea_queryParser
$t["RB"] = $tree;
$tree = $t;
}
if (isset($tree["LB"]))
if (isset($tree["LB"])) {
$this->priority_opk($tree["LB"], $depth + 1);
if (isset($tree["RB"]))
}if (isset($tree["RB"])) {
$this->priority_opk($tree["RB"], $depth + 1);
}
}
function distrib_opk(&$tree, $depth = 0)
{
if ( ! $tree)
if ( ! $tree) {
return;
}
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS")) {
// on a un truc du genre (a = (5 ou 6)), on le transforme en ((a = 5) ou (a = 6))
$tmp = array("CLASS" => $tree["CLASS"],
@@ -380,8 +394,10 @@ class searchEngine_adapter_phrasea_queryParser
function thesaurus2_apply(&$tree, $bid)
{
if ( ! $tree)
if ( ! $tree) {
return;
}
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") && isset($tree["SREF"]) && isset($tree["SREF"]["TIDS"])) {
$tids = array();
foreach ($tree["SREF"]["TIDS"] as $tid) {
@@ -440,8 +456,10 @@ class searchEngine_adapter_phrasea_queryParser
{
if ($depth == 0)
$ret = $tree;
if ( ! $useThesaurus)
if ( ! $useThesaurus) {
return; // full-text only : inchangé
}
if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE")) {
if (isset($tree["CONTEXT"]))
$copy = $this->_extendToThesaurus_Simple($tree, false, $keepfuzzy, $path);
@@ -565,8 +583,9 @@ class searchEngine_adapter_phrasea_queryParser
if ($depth == 0)
$this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
if ( ! $tree)
if ( ! $tree) {
return(0);
}
$ambigus = 0;
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON) {
@@ -686,17 +705,19 @@ class searchEngine_adapter_phrasea_queryParser
return($tree["VALUE"][0]);
break;
case "PHRASEA_KW_LAST":
if ($tree["PNUM"] !== null)
if ($tree["PNUM"] !== null) {
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
else
} else {
return($tree["VALUE"][0]);
}
break;
case "OPS":
case "OPK":
if (isset($tree["PNUM"]))
if (isset($tree["PNUM"])) {
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . '[' . $tree["PNUM"] . '] ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
else
} else {
return('(' . $this->_queryAsHTML($tree["LB"], $depth + 1) . ' ' . $tree["VALUE"] . ' ' . $this->_queryAsHTML($tree["RB"], $depth + 1) . ')');
}
break;
}
}
@@ -841,10 +862,12 @@ class searchEngine_adapter_phrasea_queryParser
function containsColonOperator(&$tree)
{
if ( ! $tree)
if ( ! $tree) {
return(false);
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE"))
}
if ($tree["CLASS"] == "OPK" && $tree["NODETYPE"] == PHRASEA_OP_COLON && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE")) {
return(true);
}
$ret = false;
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
$ret |= $this->containsColonOperator($tree["LB"]);
@@ -950,25 +973,29 @@ class searchEngine_adapter_phrasea_queryParser
return($tree["VALUE"][0]);
break;
case "PHRASEA_KW_LAST":
if ($tree["PNUM"] !== null)
if ($tree["PNUM"] !== null) {
return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
else
} else {
return($tree["VALUE"][0]);
}
break;
case "OPS":
case "OPK":
if (isset($tree["PNUM"]))
if (isset($tree["PNUM"])) {
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
else
} else {
return("(" . $this->astext_ambigu($tree["LB"], $ambiguites, $mouseCallback, $depth + 1) . " " . $tree["VALUE"] . " " . $this->astext_ambigu($tree["RB"], $ambiguites, $mouseCallback, $depth + 1) . ")");
}
break;
}
}
function get_ambigu(&$tree, $mouseCallback = "void", $depth = 0)
{
if ( ! $tree)
if ( ! $tree) {
return("");
}
unset($tree["DEPTH"]);
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
$this->get_ambigu($tree["LB"], $mouseCallback, $depth + 1);
@@ -987,16 +1014,19 @@ class searchEngine_adapter_phrasea_queryParser
function set_default(&$tree, &$emptyw, $depth = 0)
{
if ( ! $tree)
if ( ! $tree) {
return(true);
}
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") {
if ($tree["CLASS"] == "OPS") {
if ( ! $this->set_default($tree["LB"], $emptyw, $depth + 1))
if ( ! $this->set_default($tree["LB"], $emptyw, $depth + 1)) {
return(false);
if ( ! $this->set_default($tree["RB"], $emptyw, $depth + 1))
}
if ( ! $this->set_default($tree["RB"], $emptyw, $depth + 1)) {
return(false);
}
else { // OPK !
}
} else { // OPK !
// jy 20041223 : ne pas appliquer d'op. par def. derriere un op arith.
// ex : "d < 1/2/2003" : grouper la liste "1","2","2004" en "mot" unique
if ( ! $tree["LB"] || ($tree["LB"]["CLASS"] != "SIMPLE" && $tree["LB"]["CLASS"] != "QSIMPLE") || (is_array($tree["LB"]["VALUE"]) && count($tree["LB"]["VALUE"]) != 1)) {
@@ -1473,10 +1503,10 @@ class searchEngine_adapter_phrasea_queryParser
if ($inquote) {
// quand on est entre guillements les tokens perdent leur signification
$tree = $this->addtotree($tree, $t, $depth, $inquote);
if ( ! $tree)
if ( ! $tree) {
return(null);
}
else {
}
} else {
if ($depth <= 0) { // ')' : retour de récursivité
if ($this->errmsg != "")
$this->errmsg .= sprintf("\\n");
@@ -1492,10 +1522,10 @@ class searchEngine_adapter_phrasea_queryParser
if ($inquote) {
// quand on est entre guillements les tokens perdent leur signification
$tree = $this->addtotree($tree, $t, $depth, $inquote);
if ( ! $tree)
if ( ! $tree) {
return(null);
}
else { // '(' : appel récursif
}
} else { // '(' : appel récursif
if ( ! $tree)
$tree = $this->maketree($depth + 1);
else {
@@ -1515,8 +1545,9 @@ class searchEngine_adapter_phrasea_queryParser
"RB" => $this->maketree($depth + 1));
}
}
if ( ! $tree)
if ( ! $tree) {
return(null);
}
}
break;
case "TOK_VOID":
@@ -1562,8 +1593,9 @@ class searchEngine_adapter_phrasea_queryParser
"RB" => $this->maketree($depth + 1, true));
}
}
if ( ! $tree)
if ( ! $tree) {
return(null);
}
}
break;
default:
@@ -1573,8 +1605,9 @@ class searchEngine_adapter_phrasea_queryParser
var_dump($tree);
print("-------------------------\n");
}
if ( ! $tree)
if ( ! $tree) {
return(null);
}
break;
}
}
@@ -1597,8 +1630,10 @@ class searchEngine_adapter_phrasea_queryParser
print("-------------------------\n");
}
if ( ! $t)
if ( ! $t) {
return($tree);
}
switch ($t["CLASS"]) {
case "TOK_CONTEXT":
// if($this->debug)
@@ -1823,8 +1858,10 @@ class searchEngine_adapter_phrasea_queryParser
function nexttoken($inquote = false)
{
if ($this->phq == "")
if ($this->phq == "") {
return(null);
}
switch ($c = substr($this->phq, 0, 1)) {
case "<":
case ">":
@@ -1940,10 +1977,11 @@ class searchEngine_adapter_phrasea_queryParser
// le délimiteur était une simple ponctuation, on le saute
$this->phq = $this->mb_ltrim(mb_substr($this->phq, $i + 1, 99999, 'UTF-8'), 'UTF-8');
}
if ($t != "")
if ($t != "") {
return(array("CLASS" => "TOK_WORD", "VALUE" => $t));
else
} else {
return(array("CLASS" => "TOK_VOID", "VALUE" => $t));
}
break;
}
}

View File

@@ -100,8 +100,10 @@ abstract class set_abstract implements IteratorAggregate
public function __isset($key)
{
trigger_error("Unable to use magic method get for key $key");
if (isset($this->$key))
if (isset($this->$key)) {
return true;
}
return false;
}

View File

@@ -136,8 +136,9 @@ class set_ordermanager extends set_abstract
{
$comp = strcasecmp($a['usage'], $b['usage']);
if ($comp == 0)
if ($comp == 0) {
return 0;
}
return $comp < 0 ? -1 : 1;
}
@@ -152,8 +153,9 @@ class set_ordermanager extends set_abstract
{
$comp = strcasecmp($a['usr_display'], $b['usr_display']);
if ($comp == 0)
if ($comp == 0) {
return 0;
}
return $comp < 0 ? -1 : 1;
}
@@ -168,8 +170,9 @@ class set_ordermanager extends set_abstract
{
$comp = $b->format('U') - $a->format('U');
if ($comp == 0)
if ($comp == 0) {
return 0;
}
return $comp < 0 ? -1 : 1;
}

View File

@@ -268,12 +268,14 @@ class setup
protected static function discover_binary($binary, array $look_here = array())
{
if (system_server::get_platform() == 'WINDOWS')
if (system_server::get_platform() == 'WINDOWS') {
return null;
}
foreach ($look_here as $place) {
if (is_executable($place))
if (is_executable($place)) {
return $place;
}
}
return exec(sprintf('which %s', $binary));
@@ -283,23 +285,24 @@ class setup
{
$registry = registry::get_instance();
if ($registry->get('GV_h264_streaming') !== true)
if ($registry->get('GV_h264_streaming') !== true) {
return;
}
?>
<h1>mod_auth_token configuration </h1>
<ul class="setup">
<?php
$fileName = $registry->get('GV_mod_auth_token_directory_path') . '/test_mod_auth_token.txt'; // The file to access
<?php
$fileName = $registry->get('GV_mod_auth_token_directory_path') . '/test_mod_auth_token.txt'; // The file to access
touch($fileName);
touch($fileName);
$url = $registry->get('GV_ServerName') . p4file::apache_tokenize($fileName);
$url = $registry->get('GV_ServerName') . p4file::apache_tokenize($fileName);
if (http_query::getHttpCodeFromUrl($url) == 200)
echo '<li>' . _('mod_auth_token correctement configure') . '</li>';
else
echo '<li class="blocker">' . _('mod_auth_token mal configure') . '</li>';
?>
if (http_query::getHttpCodeFromUrl($url) == 200)
echo '<li>' . _('mod_auth_token correctement configure') . '</li>';
else
echo '<li class="blocker">' . _('mod_auth_token mal configure') . '</li>';
?>
</ul>
<?php
}
@@ -310,9 +313,9 @@ class setup
?>
<h1>Apache Server mods avalaibility</h1>
<div style="position:relative;float:left;">
<?php
echo _('Attention, seul le test de l\'activation des mods est effectue, leur bon fonctionnement ne l\'est pas ')
?>
<?php
echo _('Attention, seul le test de l\'activation des mods est effectue, leur bon fonctionnement ne l\'est pas ')
?>
</div>
<ul id="apache_mods_checker" class="setup">
@@ -322,27 +325,27 @@ class setup
</li>
<li class="blocker">
<a href="#" onclick="check_apache_mod(this,'xsendfile');return false;">mod_xsendfile (optionnal)</a>
<?php
if ($registry->get('GV_modxsendfile')) {
?>
<?php
if ($registry->get('GV_modxsendfile')) {
?>
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration xsendfile, actuellement activee dans le setup'); ?></div>
<?php } ?>
<?php } ?>
</li>
<li class="blocker">
<a href="#" onclick="check_apache_mod(this,'authtoken');return false;">mod_auth_token (optionnal)</a>
<?php
if ($registry->get('GV_h264_streaming')) {
?>
<?php
if ($registry->get('GV_h264_streaming')) {
?>
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration h264_streaming, actuellement activee dans le setup'); ?></div>
<?php } ?>
<?php } ?>
</li>
<li class="blocker">
<a href="#" onclick="check_apache_mod(this,'h264');return false;">mod_h264_streaming (optionnal)</a>
<?php
if ($registry->get('GV_h264_streaming')) {
?>
<?php
if ($registry->get('GV_h264_streaming')) {
?>
<div class="infos"><img style="vertical-align:middle" src="/skins/icons/alert.png"/> <?php echo _('Attention, veuillez verifier la configuration h264_streaming, actuellement activee dans le setup'); ?></div>
<?php } ?>
<?php } ?>
</li>
<style type="text/css">
#apache_mods_checker div.infos{
@@ -387,96 +390,96 @@ class setup
}
</script>
<?php
echo '</ul>';
}
<?php
echo '</ul>';
}
public static function check_phrasea()
{
$constraints = array();
if (function_exists('phrasea_info')) {
foreach (phrasea_info() as $name => $value) {
switch ($name) {
default:
$result = true;
$message = $name . ' = ' . $value;
break;
case 'temp_writable':
$result = $value == '1';
if ($result)
$message = 'Directory is writeable';
else
$message = 'Directory MUST be writable';
break;
case 'version':
$result = version_compare($value, '1.18.0.3', '>=');
if ($result)
$message = sprintf('Phrasea version %s is ok', $value);
else
$message = sprintf('Phrasea version %s is NOT ok', $value);
break;
public static function check_phrasea()
{
$constraints = array();
if (function_exists('phrasea_info')) {
foreach (phrasea_info() as $name => $value) {
switch ($name) {
default:
$result = true;
$message = $name . ' = ' . $value;
break;
case 'temp_writable':
$result = $value == '1';
if ($result)
$message = 'Directory is writeable';
else
$message = 'Directory MUST be writable';
break;
case 'version':
$result = version_compare($value, '1.18.0.3', '>=');
if ($result)
$message = sprintf('Phrasea version %s is ok', $value);
else
$message = sprintf('Phrasea version %s is NOT ok', $value);
break;
}
$blocker = $name == 'temp_writable' ? ($value ? '' : 'blocker') : '';
$constraints[] = new Setup_Constraint($name, $result, $message, true);
}
$blocker = $name == 'temp_writable' ? ($value ? '' : 'blocker') : '';
$constraints[] = new Setup_Constraint($name, $result, $message, true);
}
}
return new Setup_ConstraintsIterator($constraints);
}
public static function check_writability(registryInterface $registry)
{
$root = p4string::addEndSlash(realpath(__DIR__ . '/../../'));
$pathes = array(
$root . 'config',
$root . 'config/stamp',
$root . 'config/status',
$root . 'config/minilogos',
$root . 'config/templates',
$root . 'config/topics',
$root . 'config/wm',
$root . 'logs',
$root . 'tmp',
$root . 'www/custom',
$root . 'tmp/locks',
$root . 'tmp/cache_twig',
$root . 'tmp/cache_minify',
$root . 'tmp/lazaret',
$root . 'tmp/desc_tmp',
$root . 'tmp/download',
$root . 'tmp/batches');
if ($registry->is_set('GV_base_datapath_web')) {
$pathes[] = $registry->get('GV_base_datapath_web');
}
if ($registry->is_set('GV_base_datapath_noweb')) {
$pathes[] = $registry->get('GV_base_datapath_noweb');
}
$constraints = array();
foreach ($pathes as $p) {
if ( ! is_writable($p)) {
$message = sprintf('%s not writeable', $p);
} else {
$message = sprintf('%s OK', $p);
}
$constraints[] = new Setup_Constraint(
'Writeability test', is_writable($p), $message, true
);
return new Setup_ConstraintsIterator($constraints);
}
$php_constraints = new Setup_ConstraintsIterator($constraints);
return $php_constraints;
}
public static function check_writability(registryInterface $registry)
{
$root = p4string::addEndSlash(realpath(__DIR__ . '/../../'));
function check_mail_form()
{
echo '<h1>' . _('setup::Tests d\'envois d\'emails') . '</h1>';
?>
$pathes = array(
$root . 'config',
$root . 'config/stamp',
$root . 'config/status',
$root . 'config/minilogos',
$root . 'config/templates',
$root . 'config/topics',
$root . 'config/wm',
$root . 'logs',
$root . 'tmp',
$root . 'www/custom',
$root . 'tmp/locks',
$root . 'tmp/cache_twig',
$root . 'tmp/cache_minify',
$root . 'tmp/lazaret',
$root . 'tmp/desc_tmp',
$root . 'tmp/download',
$root . 'tmp/batches');
if ($registry->is_set('GV_base_datapath_web')) {
$pathes[] = $registry->get('GV_base_datapath_web');
}
if ($registry->is_set('GV_base_datapath_noweb')) {
$pathes[] = $registry->get('GV_base_datapath_noweb');
}
$constraints = array();
foreach ($pathes as $p) {
if ( ! is_writable($p)) {
$message = sprintf('%s not writeable', $p);
} else {
$message = sprintf('%s OK', $p);
}
$constraints[] = new Setup_Constraint(
'Writeability test', is_writable($p), $message, true
);
}
$php_constraints = new Setup_ConstraintsIterator($constraints);
return $php_constraints;
}
function check_mail_form()
{
echo '<h1>' . _('setup::Tests d\'envois d\'emails') . '</h1>';
?>
<form method="post" action="/admin/sitestruct.php" target="_self">
<label>Email : </label><input name="email" type="text" />
<input type="submit" value="<?php echo _('boutton::valider'); ?>"/>
@@ -643,8 +646,9 @@ class setup
{
$constraints = array();
if ( ! extension_loaded('gettext'))
if ( ! extension_loaded('gettext')) {
return new Setup_ConstraintsIterator($constraints);
}
foreach (User_Adapter::$locales as $code => $language_name) {
phrasea::use_i18n($code, 'test');
@@ -670,14 +674,19 @@ class setup
if ($is_flag)
$current = strtolower($current);
if (($current === '' || $current === 'off' || $current === '0') && $is_flag)
if ($value === 'off' || $value === '0' || $value === '')
if (($current === '' || $current === 'off' || $current === '0') && $is_flag) {
if ($value === 'off' || $value === '0' || $value === '') {
return $current;
if (($current === '1' || $current === 'on') && $is_flag)
if ($value === 'on' || $value === '1')
}
}
if (($current === '1' || $current === 'on') && $is_flag) {
if ($value === 'on' || $value === '1') {
return $current;
if ($current === $value)
}
}
if ($current === $value) {
return $current;
}
}
public static function rollback(connection_pdo $conn, connection_pdo $connbas = null)

View File

@@ -250,8 +250,10 @@ class system_file extends SplFileObject
, 'x3f' => 'image/x-tika-sigma');
if (in_array($this->get_mime(), $raws))
if (in_array($this->get_mime(), $raws)) {
return true;
}
return false;
}
@@ -275,10 +277,11 @@ class system_file extends SplFileObject
$extension = isset($pi['extension']) ? $pi['extension'] : '';
}
if ($lowercase)
if ($lowercase) {
return mb_strtolower($extension);
else
return $extension;
}
return $extension;
}
public function get_sha256()
@@ -452,8 +455,9 @@ class system_file extends SplFileObject
$this->technical_datas = array();
if ( ! is_executable($registry->get('GV_mplayer')))
if ( ! is_executable($registry->get('GV_mplayer'))) {
return $this;
}
$cmd = $registry->get('GV_mplayer')
. ' -identify '
@@ -669,8 +673,9 @@ class system_file extends SplFileObject
public function read_uuid()
{
if ($this->uuid)
if ($this->uuid) {
return $this->uuid;
}
$datas = exiftool::extract_metadatas($this, exiftool::EXTRACT_XML_RDF);
$domrdf = new DOMDocument();
@@ -701,8 +706,9 @@ class system_file extends SplFileObject
public function is_new_in_base($sbas_id)
{
if ( ! $this->uuid)
if ( ! $this->uuid) {
return true;
}
$connbas = connection::getPDOConnection($sbas_id);
@@ -764,8 +770,9 @@ class system_file extends SplFileObject
if (($v = $x->firstChild) && $v->nodeType == XML_TEXT_NODE) {
$value = $base64_encoded ? base64_decode($v->nodeValue) : $v->nodeValue;
if (uuid::is_valid($value))
if (uuid::is_valid($value)) {
return $value;
}
}
}
}
@@ -859,8 +866,10 @@ class system_file extends SplFileObject
public function get_phrasea_tech_field($field)
{
if (isset($this->phrasea_tech_field[$field]))
if (isset($this->phrasea_tech_field[$field])) {
return $this->phrasea_tech_field[$field];
}
return null;
}
@@ -1151,16 +1160,17 @@ class system_file extends SplFileObject
if (mb_convert_encoding(mb_convert_encoding($s, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32') == $s) {
$mac = mb_convert_encoding($s, 'windows-1252', 'UTF-8');
for ($i = strlen($mac); $i;) {
if (strpos($macchars, $mac[ -- $i]) !== false)
if (strpos($macchars, $mac[ -- $i]) !== false) {
return(iconv('MACINTOSH', 'UTF-8', $mac));
}
}
return($s);
}
else {
} else {
for ($i = strlen($s); $i;) {
if (strpos($macchars, $s[ -- $i]) !== false)
if (strpos($macchars, $s[ -- $i]) !== false) {
return(iconv('MACINTOSH', 'UTF-8', $s));
}
}
return(iconv('windows-1252', 'UTF-8', $s));

View File

@@ -42,8 +42,10 @@ class system_server
*/
public function is_nginx()
{
if (strpos($this->_server_software, 'nginx') !== false)
if (strpos($this->_server_software, 'nginx') !== false) {
return true;
}
return false;
}
@@ -54,8 +56,10 @@ class system_server
*/
public function is_lighttpd()
{
if (strpos($this->_server_software, 'lighttpd') !== false)
if (strpos($this->_server_software, 'lighttpd') !== false) {
return true;
}
return false;
}
@@ -66,8 +70,10 @@ class system_server
*/
public function is_apache()
{
if (strpos($this->_server_software, 'apache') !== false)
if (strpos($this->_server_software, 'apache') !== false) {
return true;
}
return false;
}
@@ -82,8 +88,10 @@ class system_server
static $_system = NULL;
if ($_system === NULL) {
$_system = strtoupper(php_uname('s'));
if ($_system == 'WINDOWS NT')
if ($_system == 'WINDOWS NT') {
$_system = 'WINDOWS';
}
}
return($_system);

View File

@@ -34,8 +34,10 @@ class task_manager
public function old_get_tasks($refresh = false)
{
if ($this->tasks && ! $refresh)
if ($this->tasks && ! $refresh) {
return $this->tasks;
}
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute();
@@ -62,8 +64,9 @@ class task_manager
public function get_tasks($refresh = false)
{
if ($this->tasks && ! $refresh)
if ($this->tasks && ! $refresh) {
return $this->tasks;
}
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
$stmt = $this->appbox->get_connection()->prepare($sql);

View File

@@ -153,9 +153,9 @@ class task_period_apibridge extends task_appboxAbstract
}
$element->set_connector_status($connector_status);
if ($status === $previous_status)
if ($status === $previous_status) {
return;
}
switch ($status) {
case Bridge_Element::STATUS_ERROR:

File diff suppressed because it is too large Load Diff

View File

@@ -273,17 +273,17 @@ class task_period_cindexer extends task_abstract
<br/>
<?php echo _('task::cindexer:host') ?>&nbsp;:&nbsp;<input type="text" name="host" style="width:100px;" onchange="chgxmltxt(this, 'host');" value="">
<br/>
<?php echo _('task::cindexer:port') ?>&nbsp;:&nbsp;<input type="text" name="port" style="width:100px;" onchange="chgxmltxt(this, 'port');" value="">
<?php echo _('task::cindexer:port') ?>&nbsp;:&nbsp;<input type="text" name="port" style="width:100px;" onchange="chgxmltxt(this, 'port');" value="">
<br/>
<?php echo _('task::cindexer:base') ?>&nbsp;:&nbsp;<input type="text" name="base" style="width:200px;" onchange="chgxmltxt(this, 'base');" value="">
<?php echo _('task::cindexer:base') ?>&nbsp;:&nbsp;<input type="text" name="base" style="width:200px;" onchange="chgxmltxt(this, 'base');" value="">
<br/>
<?php echo _('task::cindexer:user') ?>&nbsp;:&nbsp;<input type="text" name="user" style="width:200px;" onchange="chgxmltxt(this, 'user');" value="">
<br/>
<?php echo _('task::cindexer:password') ?>&nbsp;:&nbsp;<input type="text" name="password" style="width:200px;" onchange="chgxmltxt(this, 'password');" value="">
<?php echo _('task::cindexer:password') ?>&nbsp;:&nbsp;<input type="text" name="password" style="width:200px;" onchange="chgxmltxt(this, 'password');" value="">
<br/>
<br/>
<?php echo _('task::cindexer:control socket') ?>&nbsp;:&nbsp;<input type="text" name="socket" style="width:200px;" onchange="chgxmltxt(this, 'socket');" value="">
<?php echo _('task::cindexer:control socket') ?>&nbsp;:&nbsp;<input type="text" name="socket" style="width:200px;" onchange="chgxmltxt(this, 'socket');" value="">
<br/>
<br/>
@@ -292,7 +292,7 @@ class task_period_cindexer extends task_abstract
<br/>
</div>
<?php echo _('task::cindexer:MySQL charset') ?>&nbsp;:&nbsp;<input type="text" name="charset" style="width:200px;" onchange="chgxmltxt(this, 'charset');" value="">
<?php echo _('task::cindexer:MySQL charset') ?>&nbsp;:&nbsp;<input type="text" name="charset" style="width:200px;" onchange="chgxmltxt(this, 'charset');" value="">
<br/>
<br/>
@@ -315,60 +315,60 @@ class task_period_cindexer extends task_abstract
<center>
<div style="margin:10px; padding:5px; border:1px #000000 solid; font-family:monospace; font-size:16px; text-align:left; color:#00e000; background-color:#404040" id="cmd">cmd</div>
</center>
<?php
$out = ob_get_clean();
<?php
$out = ob_get_clean();
return $out;
return $out;
}
/**
*
* @param SimpleXMLElement $sx_task_settings
* @return task_cindexer
*/
protected function load_settings(SimpleXMLElement $sx_task_settings)
{
$this->host = trim($sx_task_settings->host);
$this->port = trim($sx_task_settings->port);
$this->base = trim($sx_task_settings->base);
$this->user = trim($sx_task_settings->user);
$this->password = trim($sx_task_settings->password);
$this->socket = trim($sx_task_settings->socket);
$this->use_sbas = p4field::isyes(trim($sx_task_settings->use_sbas));
$this->charset = trim($sx_task_settings->charset);
$this->nolog = p4field::isyes(trim($sx_task_settings->nolog));
$this->winsvc_run = p4field::isyes(trim($sx_task_settings->winsvc_run));
$this->binpath = p4string::addEndSlash(trim($sx_task_settings->binpath));
parent::load_settings($sx_task_settings);
return $this;
}
/**
*
* @return string
*/
protected function run2()
{
$this->method = self::METHOD_PROC_OPEN;
$this->method = self::METHOD_FORK;
$this->method = self::METHOD_EXEC;
$cmd = $this->binpath . 'phraseanet_indexer';
$nullfile = '/dev/null';
if ($this->system == 'WINDOWS') {
$cmd .= '.exe';
$nullfile = 'NULL';
}
/**
*
* @param SimpleXMLElement $sx_task_settings
* @return task_cindexer
*/
protected function load_settings(SimpleXMLElement $sx_task_settings)
{
$this->host = trim($sx_task_settings->host);
$this->port = trim($sx_task_settings->port);
$this->base = trim($sx_task_settings->base);
$this->user = trim($sx_task_settings->user);
$this->password = trim($sx_task_settings->password);
$this->socket = trim($sx_task_settings->socket);
$this->use_sbas = p4field::isyes(trim($sx_task_settings->use_sbas));
$this->charset = trim($sx_task_settings->charset);
$this->nolog = p4field::isyes(trim($sx_task_settings->nolog));
$this->winsvc_run = p4field::isyes(trim($sx_task_settings->winsvc_run));
$this->binpath = p4string::addEndSlash(trim($sx_task_settings->binpath));
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
parent::load_settings($sx_task_settings);
return $this;
return;
}
/**
*
* @return string
*/
protected function run2()
{
$this->method = self::METHOD_PROC_OPEN;
$this->method = self::METHOD_FORK;
$this->method = self::METHOD_EXEC;
$cmd = $this->binpath . 'phraseanet_indexer';
$nullfile = '/dev/null';
if ($this->system == 'WINDOWS') {
$cmd .= '.exe';
$nullfile = 'NULL';
}
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
return;
}
// $cmd .= $this->host ? " -h=" . $this->host : '';
// $cmd .= $this->port ? " -P=" . $this->port : '';
// $cmd .= $this->base ? " -b=" . $this->base : '';
@@ -380,196 +380,135 @@ class task_period_cindexer extends task_abstract
// $cmd .= $this->nolog ? " -n" : '';
// $cmd .= $this->winsvc_run ? " --run" : '';
$args = array();
if ($this->host)
$args[] = '-h=' . $this->host;
if ($this->port)
;
$args[] = '-P=' . $this->port;
if ($this->base)
$args[] = '-b=' . $this->base;
if ($this->user)
$args[] = '-u=' . $this->user;
if ($this->password)
$args[] = '-p=' . $this->password;
if ($this->socket)
$args[] = '--socket=' . $this->socket;
if ($this->use_sbas)
$args[] = '-o';
if ($this->charset)
$args[] = '--default-character-set=' . $this->charset;
if ($this->nolog)
$args[] = '-n';
if ($this->winsvc_run)
$args[] = '--run';
$args = array();
if ($this->host)
$args[] = '-h=' . $this->host;
if ($this->port)
;
$args[] = '-P=' . $this->port;
if ($this->base)
$args[] = '-b=' . $this->base;
if ($this->user)
$args[] = '-u=' . $this->user;
if ($this->password)
$args[] = '-p=' . $this->password;
if ($this->socket)
$args[] = '--socket=' . $this->socket;
if ($this->use_sbas)
$args[] = '-o';
if ($this->charset)
$args[] = '--default-character-set=' . $this->charset;
if ($this->nolog)
$args[] = '-n';
if ($this->winsvc_run)
$args[] = '--run';
$registry = registry::get_instance();
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
$registry = registry::get_instance();
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
$this->return_value = self::RETURNSTATUS_STOPPED; // will be normal ending
$this->return_value = self::RETURNSTATUS_STOPPED; // will be normal ending
if ($this->method == self::METHOD_PROC_OPEN) {
$descriptors = array();
if ($this->method == self::METHOD_PROC_OPEN) {
$descriptors = array();
// $descriptors[1] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".log", "a+");
// $descriptors[2] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".error.log", "a+");
$descriptors[1] = array("file", $nullfile, "a+");
$descriptors[2] = array("file", $nullfile, "a+");
$descriptors[1] = array("file", $nullfile, "a+");
$descriptors[2] = array("file", $nullfile, "a+");
$pipes = array();
$pipes = array();
$this->log(sprintf('cmd=\'%s %s\'', $cmd, implode(' ', $args)));
$process = proc_open($cmd . ' ' . implode(' ', $args), $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true));
$this->log(sprintf('cmd=\'%s %s\'', $cmd, implode(' ', $args)));
$process = proc_open($cmd . ' ' . implode(' ', $args), $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true));
$pid = NULL;
if (is_resource($process)) {
$proc_status = proc_get_status($process);
if ($proc_status['running'])
$pid = $proc_status['pid'];
}
$qsent = '';
$timetokill = NULL;
$sock = NULL;
$this->running = true;
while ($this->running) {
$this->check_task_status();
if ($this->task_status == self::STATUS_TOSTOP && $this->socket > 0) {
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
socket_write($sock, 'Q', 1);
socket_write($sock, "\r\n", strlen("\r\n"));
for ($i = 0; $this->running && $i < 5; $i ++ )
sleep(1);
$qsent = 'Q';
$timetokill = time() + 10;
} else {
socket_close($sock);
$sock = NULL;
}
}
}
$proc_status = proc_get_status($process);
if ( ! $proc_status['running']) {
// the cindexer died
if ($qsent == 'Q') {
$this->log(_('task::cindexer:the cindexer clean-quit'));
} elseif ($qsent == 'K') {
$this->log(_('task::cindexer:the cindexer has been killed'));
} else {
$this->log(_('task::cindexer:the cindexer crashed'));
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
}
$this->running = false;
} else {
if ($qsent == 'Q') {
if (time() > $timetokill) {
// must kill cindexer
$this->log(_('task::cindexer:killing the cindexer'));
$qsent = 'K';
proc_terminate($process); // sigint
}
}
}
for ($i = 0; $this->running && $i < 5; $i ++ )
sleep(1);
}
if ($sock) {
socket_close($sock);
$sock = NULL;
}
foreach (array_keys($pipes) as $offset) {
if (is_resource($pipes[$offset]))
fclose($pipes[$offset]);
}
proc_terminate($process); // sigint
proc_close($process);
$pid = NULL;
if (is_resource($process)) {
$proc_status = proc_get_status($process);
if ($proc_status['running'])
$pid = $proc_status['pid'];
}
elseif ($this->method == self::METHOD_FORK) {
$pid = pcntl_fork();
if ($pid == -1) {
die("failed to fork");
} elseif ($pid == 0) {
// child
umask(0);
// openlog('MyLog', LOG_PID | LOG_PERROR, LOG_LOCAL0);
if (posix_setsid() < 0)
die("Forked process could not detach from terminal\n");
//chdir(dirname(__FILE__));
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
$fdIN = fopen($nullfile, 'r');
// $fdOUT = fopen($nullfile, 'a+');
// $fdERR = fopen($nullfile, 'a+');
$fdOUT = fopen($logdir . "/task_o_" . $this->get_task_id() . ".log", "a+");
$fdERR = fopen($logdir . "/task_e_" . $this->get_task_id() . ".log", "a+");
pcntl_exec($cmd, $args);
$qsent = '';
$timetokill = NULL;
$sock = NULL;
sleep(2);
}
else {
// parent
$this->running = true;
$this->running = true;
$sigsent = NULL;
while ($this->running) {
// is the cindexer alive ?
if ( ! posix_kill($pid, 0)) {
// dead...
if ($sigsent === NULL) {
// but it's not my fault
$this->log(_('task::cindexer:the cindexer crashed'));
$this->running = false;
// return self::RETURNSTATUS_STOPPED;
break;
}
}
while ($this->running) {
$this->check_task_status();
$this->check_task_status();
if ($this->task_status == self::STATUS_TOSTOP) {
posix_kill($pid, ($sigsent = SIGINT));
sleep(2);
}
$status = NULL;
if (pcntl_wait($status, WNOHANG) == $pid) {
// child (indexer) has exited
if ($sigsent == SIGINT) {
$this->log(_('task::cindexer:the cindexer clean-quit'));
} elseif ($sigsent == SIGKILL) {
$this->log(_('task::cindexer:the cindexer has been killed'));
} else {
$this->log(_('task::cindexer:the cindexer crashed'));
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
}
$this->running = false;
if ($this->task_status == self::STATUS_TOSTOP && $this->socket > 0) {
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
socket_write($sock, 'Q', 1);
socket_write($sock, "\r\n", strlen("\r\n"));
for ($i = 0; $this->running && $i < 5; $i ++ )
sleep(1);
$qsent = 'Q';
$timetokill = time() + 10;
} else {
if ($sigsent == SIGINT && time() > $timetokill) {
// must kill cindexer
$this->log(_('task::cindexer:killing the cindexer'));
$qsent = 'K';
posix_kill($pid, ($sigsent = SIGKILL));
}
sleep(2);
socket_close($sock);
$sock = NULL;
}
} // while running (method fork)
}
}
} elseif ($this->method == self::METHOD_EXEC) {
$proc_status = proc_get_status($process);
if ( ! $proc_status['running']) {
// the cindexer died
if ($qsent == 'Q') {
$this->log(_('task::cindexer:the cindexer clean-quit'));
} elseif ($qsent == 'K') {
$this->log(_('task::cindexer:the cindexer has been killed'));
} else {
$this->log(_('task::cindexer:the cindexer crashed'));
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
}
$this->running = false;
} else {
if ($qsent == 'Q') {
if (time() > $timetokill) {
// must kill cindexer
$this->log(_('task::cindexer:killing the cindexer'));
$qsent = 'K';
proc_terminate($process); // sigint
}
}
}
for ($i = 0; $this->running && $i < 5; $i ++ )
sleep(1);
}
if ($sock) {
socket_close($sock);
$sock = NULL;
}
foreach (array_keys($pipes) as $offset) {
if (is_resource($pipes[$offset]))
fclose($pipes[$offset]);
}
proc_terminate($process); // sigint
proc_close($process);
}
elseif ($this->method == self::METHOD_FORK) {
$pid = pcntl_fork();
if ($pid == -1) {
die("failed to fork");
} elseif ($pid == 0) {
// child
umask(0);
// openlog('MyLog', LOG_PID | LOG_PERROR, LOG_LOCAL0);
if (posix_setsid() < 0)
die("Forked process could not detach from terminal\n");
//chdir(dirname(__FILE__));
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
$fdIN = fopen($nullfile, 'r');
// $fdOUT = fopen($nullfile, 'a+');
// $fdERR = fopen($nullfile, 'a+');
$fdOUT = fopen($logdir . "/task_o_" . $this->get_task_id() . ".log", "a+");
$fdERR = fopen($logdir . "/task_e_" . $this->get_task_id() . ".log", "a+");
@@ -577,8 +516,69 @@ class task_period_cindexer extends task_abstract
sleep(2);
}
else {
// parent
$this->running = true;
return($this->return_value);
$sigsent = NULL;
while ($this->running) {
// is the cindexer alive ?
if ( ! posix_kill($pid, 0)) {
// dead...
if ($sigsent === NULL) {
// but it's not my fault
$this->log(_('task::cindexer:the cindexer crashed'));
$this->running = false;
// return self::RETURNSTATUS_STOPPED;
break;
}
}
$this->check_task_status();
if ($this->task_status == self::STATUS_TOSTOP) {
posix_kill($pid, ($sigsent = SIGINT));
sleep(2);
}
$status = NULL;
if (pcntl_wait($status, WNOHANG) == $pid) {
// child (indexer) has exited
if ($sigsent == SIGINT) {
$this->log(_('task::cindexer:the cindexer clean-quit'));
} elseif ($sigsent == SIGKILL) {
$this->log(_('task::cindexer:the cindexer has been killed'));
} else {
$this->log(_('task::cindexer:the cindexer crashed'));
$this->return_value = NULL; // NOT normal ending will enforce restart from scheduler
}
$this->running = false;
} else {
if ($sigsent == SIGINT && time() > $timetokill) {
// must kill cindexer
$this->log(_('task::cindexer:killing the cindexer'));
$qsent = 'K';
posix_kill($pid, ($sigsent = SIGKILL));
}
sleep(2);
}
} // while running (method fork)
}
} elseif ($this->method == self::METHOD_EXEC) {
umask(0);
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
$fdIN = fopen($nullfile, 'r');
$fdOUT = fopen($logdir . "/task_o_" . $this->get_task_id() . ".log", "a+");
$fdERR = fopen($logdir . "/task_e_" . $this->get_task_id() . ".log", "a+");
pcntl_exec($cmd, $args);
sleep(2);
}
}
return($this->return_value);
}
}

View File

@@ -160,542 +160,543 @@ class task_period_ftp extends task_appboxAbstract
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');">
&nbsp;<?php echo('task::_common_:secondes (unite temporelle)') ?><br/>
</form>
<?php
$out = ob_get_clean();
<?php
$out = ob_get_clean();
return $out;
}
return $out;
}
public function saveChanges(connection_pdo $conn, $taskid, &$taskrow)
{
$request = http_request::getInstance();
public function saveChanges(connection_pdo $conn, $taskid, &$taskrow)
{
$request = http_request::getInstance();
$parm = $request->get_parms("xml", "name", "active", "proxy", "proxyport", "period", "debug");
$parm = $request->get_parms("xml", "name", "active", "proxy", "proxyport", "period", "debug");
if ($parm["xml"] === null) {
// pas de xml 'raw' : on accepte les champs 'graphic view'
if ($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"])) {
$xmlchanged = false;
foreach (array("proxy", "proxyport", "period") as $f) {
if ($parm[$f] !== NULL) {
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
while (($n = $ns->firstChild))
$ns->removeChild($n);
} else {
// le champ n'existait pas dans le xml, on le cree
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
$ns = $domTaskSettings->documentElement->appendChild($domTaskSettings->createElement($f));
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\n"));
}
// on fixe sa valeur
$ns->appendChild($domTaskSettings->createTextNode($parm[$f]));
$xmlchanged = true;
if ($parm["xml"] === null) {
// pas de xml 'raw' : on accepte les champs 'graphic view'
if ($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"])) {
$xmlchanged = false;
foreach (array("proxy", "proxyport", "period") as $f) {
if ($parm[$f] !== NULL) {
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
while (($n = $ns->firstChild))
$ns->removeChild($n);
} else {
// le champ n'existait pas dans le xml, on le cree
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
$ns = $domTaskSettings->documentElement->appendChild($domTaskSettings->createElement($f));
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\n"));
}
// on fixe sa valeur
$ns->appendChild($domTaskSettings->createTextNode($parm[$f]));
$xmlchanged = true;
}
if ($xmlchanged)
$parm["xml"] = $domTaskSettings->saveXML();
}
if ($xmlchanged)
$parm["xml"] = $domTaskSettings->saveXML();
}
}
// si on doit changer le xml, on verifie qu'il est valide
if ($parm["xml"] && ! @DOMDocument::loadXML($parm["xml"]))
return(false);
// si on doit changer le xml, on verifie qu'il est valide
if ($parm["xml"] && ! @DOMDocument::loadXML($parm["xml"])) {
return(false);
}
$sql = "";
$params = array(':task_id' => $taskid);
if ($parm["xml"] !== NULL) {
$sql .= ( $sql ? " ," : "") . "settings = :settings";
$params[':settings'] = $parm['xml'];
}
if ($parm["name"] !== NULL) {
$sql .= ( $sql ? " ," : "") . "name = :name";
$params[':name'] = $parm['name'];
}
if ($parm["active"] !== NULL) {
$sql .= ( $sql ? " ," : "") . "active = :active";
$params[':active'] = $parm['active'];
}
$sql = "";
$params = array(':task_id' => $taskid);
if ($parm["xml"] !== NULL) {
$sql .= ( $sql ? " ," : "") . "settings = :settings";
$params[':settings'] = $parm['xml'];
}
if ($parm["name"] !== NULL) {
$sql .= ( $sql ? " ," : "") . "name = :name";
$params[':name'] = $parm['name'];
}
if ($parm["active"] !== NULL) {
$sql .= ( $sql ? " ," : "") . "active = :active";
$params[':active'] = $parm['active'];
}
if ($sql) {
try {
$sql = "UPDATE task2 SET $sql WHERE task_id = :task_id";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
if ($sql) {
try {
$sql = "UPDATE task2 SET $sql WHERE task_id = :task_id";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return true;
} catch (Exception $e) {
return false;
}
} else {
return true;
} catch (Exception $e) {
return false;
}
} else {
return true;
}
protected $proxy;
protected $proxyport;
protected $debug;
}
protected $proxy;
protected $proxyport;
protected $debug;
protected function load_settings(SimpleXMLElement $sx_task_settings)
{
$this->proxy = (string) $sx_task_settings->proxy;
$this->proxyport = (string) $sx_task_settings->proxyport;
protected function load_settings(SimpleXMLElement $sx_task_settings)
{
$this->proxy = (string) $sx_task_settings->proxy;
$this->proxyport = (string) $sx_task_settings->proxyport;
parent::load_settings($sx_task_settings);
parent::load_settings($sx_task_settings);
return $this;
}
return $this;
}
protected function retrieve_content(appbox $appbox)
{
$conn = $appbox->get_connection();
protected function retrieve_content(appbox $appbox)
{
$conn = $appbox->get_connection();
$time2sleep = null;
$ftp_exports = array();
$time2sleep = null;
$ftp_exports = array();
$period = $this->period;
$time2sleep = (int) ($period);
$period = $this->period;
$time2sleep = (int) ($period);
$sql = "SELECT id FROM ftp_export WHERE crash>=nbretry
$sql = "SELECT id FROM ftp_export WHERE crash>=nbretry
AND date < :date";
$params = array(':date' => phraseadate::format_mysql(new DateTime('-30 days')));
$params = array(':date' => phraseadate::format_mysql(new DateTime('-30 days')));
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $rowtask) {
$sql = "DELETE FROM ftp_export WHERE id = :export_id";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->execute(array(':export_id' => $rowtask['id']));
$stmt->closeCursor();
foreach ($rs as $rowtask) {
$sql = "DELETE FROM ftp_export WHERE id = :export_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $rowtask['id']));
$stmt->closeCursor();
$sql = "DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $rowtask['id']));
$stmt->closeCursor();
}
$sql = "SELECT * FROM ftp_export WHERE crash<nbretry ORDER BY id";
$sql = "DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id";
$stmt = $conn->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->execute(array(':export_id' => $rowtask['id']));
$stmt->closeCursor();
}
foreach ($rs as $row) {
$ftp_exports[$row["id"]] = array_merge(array('files' => array()), $row);
}
$sql = "SELECT * FROM ftp_export WHERE crash<nbretry ORDER BY id";
$stmt = $conn->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = "SELECT e.* from ftp_export f
foreach ($rs as $row) {
$ftp_exports[$row["id"]] = array_merge(array('files' => array()), $row);
}
$sql = "SELECT e.* from ftp_export f
INNER JOIN ftp_export_elements e
ON (f.id=e.ftp_export_id AND f.crash<f.nbretry
AND (e.done = 0 or error=1))
ORDER BY f.id";
$stmt = $conn->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $conn->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $rowtask) {
if (isset($ftp_exports[$rowtask["ftp_export_id"]]))
$ftp_exports[$rowtask["ftp_export_id"]]["files"][] = $rowtask;
}
return $ftp_exports;
foreach ($rs as $rowtask) {
if (isset($ftp_exports[$rowtask["ftp_export_id"]]))
$ftp_exports[$rowtask["ftp_export_id"]]["files"][] = $rowtask;
}
protected function process_one_content(appbox $appbox, Array $ftp_export)
{
$conn = $appbox->get_connection();
$registry = $appbox->get_registry();
return $ftp_exports;
}
$id = $ftp_export['id'];
$ftp_export[$id]["crash"] = $ftp_export["crash"];
$ftp_export[$id]["nbretry"] = $ftp_export["nbretry"] < 1 ? 3 : (int) $ftp_export["nbretry"];
protected function process_one_content(appbox $appbox, Array $ftp_export)
{
$conn = $appbox->get_connection();
$registry = $appbox->get_registry();
$state = "";
$ftp_server = $ftp_export["addr"];
$ftp_user_name = $ftp_export["login"];
$ftp_user_pass = $ftp_export["pwd"];
$usr_id = (int) $ftp_export["usr_id"];
$id = $ftp_export['id'];
$ftp_export[$id]["crash"] = $ftp_export["crash"];
$ftp_export[$id]["nbretry"] = $ftp_export["nbretry"] < 1 ? 3 : (int) $ftp_export["nbretry"];
$ftpLog = $ftp_user_name . "@" . p4string::addEndSlash($ftp_server) . $ftp_export["destfolder"];
$state = "";
$ftp_server = $ftp_export["addr"];
$ftp_user_name = $ftp_export["login"];
$ftp_user_pass = $ftp_export["pwd"];
$usr_id = (int) $ftp_export["usr_id"];
if ($ftp_export["crash"] == 0) {
$state .= $line = sprintf(
_('task::ftp:Etat d\'envoi FTP vers le serveur' .
' "%1$s" avec le compte "%2$s" et pour destination le dossier : "%3$s"') . PHP_EOL
, $ftp_server
, $ftp_user_name
, $ftp_export["destfolder"]
);
if ($this->debug)
echo $line;
}
$ftpLog = $ftp_user_name . "@" . p4string::addEndSlash($ftp_server) . $ftp_export["destfolder"];
if ($ftp_export["crash"] == 0) {
$state .= $line = sprintf(
_("task::ftp:TENTATIVE no %s, %s")
, $ftp_export["crash"] + 1
, " (" . date('r') . ")"
) . PHP_EOL;
_('task::ftp:Etat d\'envoi FTP vers le serveur' .
' "%1$s" avec le compte "%2$s" et pour destination le dossier : "%3$s"') . PHP_EOL
, $ftp_server
, $ftp_user_name
, $ftp_export["destfolder"]
);
if ($this->debug)
echo $line;
}
if (($ses_id = phrasea_create_session($usr_id)) == null) {
echo "Unable to create session\n";
continue;
$state .= $line = sprintf(
_("task::ftp:TENTATIVE no %s, %s")
, $ftp_export["crash"] + 1
, " (" . date('r') . ")"
) . PHP_EOL;
if ($this->debug)
echo $line;
if (($ses_id = phrasea_create_session($usr_id)) == null) {
echo "Unable to create session\n";
continue;
}
if ( ! ($ph_session = phrasea_open_session($ses_id, $usr_id))) {
echo "Unable to open session\n";
phrasea_close_session($ses_id);
continue;
}
try {
$ssl = ($ftp_export['ssl'] == '1');
$ftp_client = new ftpclient($ftp_server, 21, 300, $ssl, $this->proxy, $this->proxyport);
$ftp_client->login($ftp_user_name, $ftp_user_pass);
if ($ftp_export["passif"] == "1") {
try {
$ftp_client->passive(true);
} catch (Exception $e) {
echo $e->getMessage();
}
}
if ( ! ($ph_session = phrasea_open_session($ses_id, $usr_id))) {
echo "Unable to open session\n";
phrasea_close_session($ses_id);
continue;
if (trim($ftp_export["destfolder"]) != '') {
try {
$ftp_client->chdir($ftp_export["destfolder"]);
$ftp_export["destfolder"] = '/' . $ftp_export["destfolder"];
} catch (Exception $e) {
echo $e->getMessage();
}
} else {
$ftp_export["destfolder"] = '/';
}
try {
$ssl = ($ftp_export['ssl'] == '1');
$ftp_client = new ftpclient($ftp_server, 21, 300, $ssl, $this->proxy, $this->proxyport);
$ftp_client->login($ftp_user_name, $ftp_user_pass);
if ($ftp_export["passif"] == "1") {
try {
$ftp_client->passive(true);
} catch (Exception $e) {
echo $e->getMessage();
}
if (trim($ftp_export["foldertocreate"]) != '') {
try {
$ftp_client->mkdir($ftp_export["foldertocreate"]);
} catch (Exception $e) {
echo $e->getMessage();
}
if (trim($ftp_export["destfolder"]) != '') {
try {
$ftp_client->chdir($ftp_export["destfolder"]);
$ftp_export["destfolder"] = '/' . $ftp_export["destfolder"];
} catch (Exception $e) {
echo $e->getMessage();
}
} else {
$ftp_export["destfolder"] = '/';
try {
$new_dir = $ftp_client->add_end_slash($ftp_export["destfolder"])
. $ftp_export["foldertocreate"];
$ftp_client->chdir($new_dir);
} catch (Exception $e) {
echo $e->getMessage();
}
}
if (trim($ftp_export["foldertocreate"]) != '') {
try {
$ftp_client->mkdir($ftp_export["foldertocreate"]);
} catch (Exception $e) {
echo $e->getMessage();
}
try {
$new_dir = $ftp_client->add_end_slash($ftp_export["destfolder"])
. $ftp_export["foldertocreate"];
$ftp_client->chdir($new_dir);
} catch (Exception $e) {
echo $e->getMessage();
}
}
$obj = array();
$obj = array();
$basefolder = '';
if ( ! in_array(trim($ftp_export["destfolder"]), array('.', './', '')))
$basefolder = p4string::addEndSlash($ftp_export["destfolder"]);
$basefolder = '';
if ( ! in_array(trim($ftp_export["destfolder"]), array('.', './', '')))
$basefolder = p4string::addEndSlash($ftp_export["destfolder"]);
$basefolder .= $ftp_export["foldertocreate"];
$basefolder .= $ftp_export["foldertocreate"];
if (in_array(trim($basefolder), array('.', './', '')))
$basefolder = '/';
if (in_array(trim($basefolder), array('.', './', '')))
$basefolder = '/';
foreach ($ftp_export['files'] as $fileid => $file) {
$base_id = $file["base_id"];
$record_id = $file["record_id"];
$subdef = $file['subdef'];
foreach ($ftp_export['files'] as $fileid => $file) {
$base_id = $file["base_id"];
$record_id = $file["record_id"];
$subdef = $file['subdef'];
try {
$sbas_id = phrasea::sbasFromBas($base_id);
$record = new record_adapter($sbas_id, $record_id);
try {
$sbas_id = phrasea::sbasFromBas($base_id);
$record = new record_adapter($sbas_id, $record_id);
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
$remotefile = $file["filename"];
$remotefile = $file["filename"];
if ($subdef == 'caption') {
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
if ($subdef == 'caption') {
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) {
throw new Exception('Impossible de creer un fichier temporaire');
}
} elseif ($subdef == 'caption-yaml') {
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $ftp_export["businessfields"]);
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) {
throw new Exception('Impossible de creer un fichier temporaire');
}
} elseif ($subdef == 'caption-yaml') {
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $ftp_export["businessfields"]);
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) {
throw new Exception('Impossible de creer un fichier temporaire');
}
} else {
$sd = $record->get_subdefs();
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) {
throw new Exception('Impossible de creer un fichier temporaire');
}
} else {
$sd = $record->get_subdefs();
if ( ! $sd || ! isset($sd[$subdef])) {
continue;
}
$localfile = $sd[$subdef]->get_pathfile();
if ( ! file_exists($localfile)) {
throw new Exception('Le fichier local n\'existe pas');
}
if ( ! $sd || ! isset($sd[$subdef])) {
continue;
}
$current_folder = p4string::delEndSlash(str_replace('//', '/', $basefolder . $file['folder']));
if ($ftp_client->pwd() != $current_folder) {
try {
$ftp_client->chdir($current_folder);
} catch (Exception $e) {
echo $e->getMessage();
}
$localfile = $sd[$subdef]->get_pathfile();
if ( ! file_exists($localfile)) {
throw new Exception('Le fichier local n\'existe pas');
}
}
$ftp_client->put($remotefile, $localfile);
$current_folder = p4string::delEndSlash(str_replace('//', '/', $basefolder . $file['folder']));
$obj[] = array(
"name" => $subdef, "size" => filesize($localfile),
"shortXml" => ($sdcaption ? $sdcaption : '')
);
if ($subdef == 'caption') {
unlink($localfile);
if ($ftp_client->pwd() != $current_folder) {
try {
$ftp_client->chdir($current_folder);
} catch (Exception $e) {
echo $e->getMessage();
}
}
$sql = "UPDATE ftp_export_elements
$ftp_client->put($remotefile, $localfile);
$obj[] = array(
"name" => $subdef, "size" => filesize($localfile),
"shortXml" => ($sdcaption ? $sdcaption : '')
);
if ($subdef == 'caption') {
unlink($localfile);
}
$sql = "UPDATE ftp_export_elements
SET done='1', error='0' WHERE id = :file_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':file_id' => $file['id']));
$stmt->closeCursor();
$this->logexport($appbox->get_session(), $record, $obj, $ftpLog);
} catch (Exception $e) {
$state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' .
' (Export du Document) : Transfert cancelled (le document n\'existe plus)')
, basename($localfile), $record_id
, phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n<br/>";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':file_id' => $file['id']));
$stmt->closeCursor();
$this->logexport($appbox->get_session(), $record, $obj, $ftpLog);
} catch (Exception $e) {
$state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' .
' (Export du Document) : Transfert cancelled (le document n\'existe plus)')
, basename($localfile), $record_id
, phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n<br/>";
if ($this->debug)
echo $line;
$done = $file['error'];
$sql = "UPDATE ftp_export_elements
SET done = :done, error='1' WHERE id = :file_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':done' => $done, ':file_id' => $file['id']));
$stmt->closeCursor();
}
}
if ($ftp_export['logfile']) {
if ($this->debug)
echo "\nlogfile \n";
echo $line;
$date = new DateTime();
$remote_file = $date->format('U');
$done = $file['error'];
$sql = 'SELECT filename, folder
$sql = "UPDATE ftp_export_elements
SET done = :done, error='1' WHERE id = :file_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':done' => $done, ':file_id' => $file['id']));
$stmt->closeCursor();
}
}
if ($ftp_export['logfile']) {
if ($this->debug)
echo "\nlogfile \n";
$date = new DateTime();
$remote_file = $date->format('U');
$sql = 'SELECT filename, folder
FROM ftp_export_elements
WHERE ftp_export_id = :ftp_export_id
AND error = "0" AND done="1"';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':ftp_export_id' => $id));
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$buffer = '#transfert finished ' . $date->format(DATE_ATOM) . "\n\n";
foreach ($rs as $row) {
$filename = $row['filename'];
$folder = $row['folder'];
$root = $ftp_export['foldertocreate'];
$buffer .= $root . '/' . $folder . $filename . "\n";
}
$tmpfile = $registry->get('GV_RootPath') . 'tmp/tmpftpbuffer' . $date->format('U') . '.txt';
file_put_contents($tmpfile, $buffer);
$remotefile = $date->format('U') . '-transfert.log';
$ftp_client->chdir($ftp_export["destfolder"]);
$ftp_client->put($remotefile, $tmpfile);
unlink($tmpfile);
}
$ftp_client->close();
unset($ftp_client);
} catch (Exception $e) {
$state .= $line = $e . "\n";
if ($this->debug)
echo $line;
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()
WHERE id = :export_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $ftp_export['id']));
$stmt->execute(array(':ftp_export_id' => $id));
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($ftp_client);
}
$this->finalize($appbox, $id);
phrasea_close_session($ses_id);
}
$buffer = '#transfert finished ' . $date->format(DATE_ATOM) . "\n\n";
foreach ($rs as $row) {
$filename = $row['filename'];
$folder = $row['folder'];
$root = $ftp_export['foldertocreate'];
$buffer .= $root . '/' . $folder . $filename . "\n";
}
$tmpfile = $registry->get('GV_RootPath') . 'tmp/tmpftpbuffer' . $date->format('U') . '.txt';
file_put_contents($tmpfile, $buffer);
$remotefile = $date->format('U') . '-transfert.log';
$ftp_client->chdir($ftp_export["destfolder"]);
$ftp_client->put($remotefile, $tmpfile);
unlink($tmpfile);
}
$ftp_client->close();
unset($ftp_client);
} catch (Exception $e) {
$state .= $line = $e . "\n";
if ($this->debug)
echo $line;
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()
WHERE id = :export_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $ftp_export['id']));
$stmt->closeCursor();
unset($ftp_client);
}
$this->finalize($appbox, $id);
phrasea_close_session($ses_id);
}
protected function post_process_one_content(appbox $appbox, Array $row)
{
return $this;
}
function finalize(appbox $appbox, $id)
{
$conn = $appbox->get_connection();
$sql = 'SELECT crash, nbretry FROM ftp_export
WHERE id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row && $row['crash'] >= $row['nbretry']) {
$this->send_mails($appbox, $id);
protected function post_process_one_content(appbox $appbox, Array $row)
{
return $this;
}
function finalize(appbox $appbox, $id)
{
$conn = $appbox->get_connection();
$sql = 'SELECT crash, nbretry FROM ftp_export
WHERE id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row && $row['crash'] >= $row['nbretry']) {
$this->send_mails($appbox, $id);
return $this;
}
$sql = 'SELECT count(id) as total, sum(error) as errors, sum(done) as done
$sql = 'SELECT count(id) as total, sum(error) as errors, sum(done) as done
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row && $row['done'] == (int) $row['total']) {
$this->send_mails($appbox, $id);
if ($row && $row['done'] == (int) $row['total']) {
$this->send_mails($appbox, $id);
if ((int) $row['errors'] === 0) {
$sql = 'DELETE FROM ftp_export WHERE id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$stmt->closeCursor();
$sql = 'DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$stmt->closeCursor();
} else {
$sql = 'UPDATE ftp_export SET crash = nbretry';
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'DELET FROM ftp_export_elements WHERE ftp_export_id = :export_id AND error="0"';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$stmt->closeCursor();
}
return $this;
}
}
function send_mails(appbox $appbox, $id)
{
$conn = $appbox->get_connection();
$registry = registry::get_instance();
$sql = 'SELECT filename, base_id, record_id, subdef, error, done
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
$transferts = array();
$transfert_status = _('task::ftp:Tous les documents ont ete transferes avec succes');
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
if ($row['error'] == '0' && $row['done'] == '1') {
$transferts[] =
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"]))
, phrasea::bas_names($row['base_id']), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>';
} else {
$transferts[] =
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"])), phrasea::bas_names($row['base_id'])
, $row['subdef']) . ' : ' . _('Transfert Annule') . '</li>';
$transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes');
}
}
$sql = 'SELECT addr, crash, nbretry, sendermail, mail, text_mail_sender, text_mail_receiver
FROM ftp_export WHERE id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row) {
if ($row['crash'] >= $row['nbretry'])
$connection_status = _('Des difficultes ont ete rencontres a la connection au serveur distant');
else
$connection_status = _('La connection vers le serveur distant est OK');
$text_mail_sender = $row['text_mail_sender'];
$text_mail_receiver = $row['text_mail_receiver'];
$mail = $row['mail'];
$sendermail = $row['sendermail'];
$ftp_server = $row['addr'];
}
$message = "\n<br/>----------------------------------------<br/>\n";
$message = "<div>" . $connection_status . "</div>\n";
$message .= "<div>" . $transfert_status . "</div>\n";
$message .= "<div>" . _("task::ftp:Details des fichiers") . "</div>\n";
$message .= "<ul>";
$message .= implode("\n", $transferts);
$message .= "</ul>";
$sender_message = $text_mail_sender . $message;
$receiver_message = $text_mail_receiver . $message;
$subject = sprintf(
_('task::ftp:Status about your FTP transfert from %1$s to %2$s')
, $registry->get('GV_homeTitle'), $ftp_server
);
mail::ftp_sent($sendermail, $subject, $sender_message);
mail::ftp_receive($mail, $receiver_message);
}
function logexport(Session_Handler $session, record_adapter $record, $obj, $ftpLog)
{
foreach ($obj as $oneObj) {
$session->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_EXPORTFTP, $ftpLog, '');
if ((int) $row['errors'] === 0) {
$sql = 'DELETE FROM ftp_export WHERE id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$stmt->closeCursor();
$sql = 'DELETE FROM ftp_export_elements WHERE ftp_export_id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$stmt->closeCursor();
} else {
$sql = 'UPDATE ftp_export SET crash = nbretry';
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'DELET FROM ftp_export_elements WHERE ftp_export_id = :export_id AND error="0"';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$stmt->closeCursor();
}
return $this;
}
}
function send_mails(appbox $appbox, $id)
{
$conn = $appbox->get_connection();
$registry = registry::get_instance();
$sql = 'SELECT filename, base_id, record_id, subdef, error, done
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
$transferts = array();
$transfert_status = _('task::ftp:Tous les documents ont ete transferes avec succes');
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
if ($row['error'] == '0' && $row['done'] == '1') {
$transferts[] =
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"]))
, phrasea::bas_names($row['base_id']), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>';
} else {
$transferts[] =
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($row["base_id"])), phrasea::bas_names($row['base_id'])
, $row['subdef']) . ' : ' . _('Transfert Annule') . '</li>';
$transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes');
}
}
$sql = 'SELECT addr, crash, nbretry, sendermail, mail, text_mail_sender, text_mail_receiver
FROM ftp_export WHERE id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($row) {
if ($row['crash'] >= $row['nbretry'])
$connection_status = _('Des difficultes ont ete rencontres a la connection au serveur distant');
else
$connection_status = _('La connection vers le serveur distant est OK');
$text_mail_sender = $row['text_mail_sender'];
$text_mail_receiver = $row['text_mail_receiver'];
$mail = $row['mail'];
$sendermail = $row['sendermail'];
$ftp_server = $row['addr'];
}
$message = "\n<br/>----------------------------------------<br/>\n";
$message = "<div>" . $connection_status . "</div>\n";
$message .= "<div>" . $transfert_status . "</div>\n";
$message .= "<div>" . _("task::ftp:Details des fichiers") . "</div>\n";
$message .= "<ul>";
$message .= implode("\n", $transferts);
$message .= "</ul>";
$sender_message = $text_mail_sender . $message;
$receiver_message = $text_mail_receiver . $message;
$subject = sprintf(
_('task::ftp:Status about your FTP transfert from %1$s to %2$s')
, $registry->get('GV_homeTitle'), $ftp_server
);
mail::ftp_sent($sendermail, $subject, $sender_message);
mail::ftp_receive($mail, $receiver_message);
}
function logexport(Session_Handler $session, record_adapter $record, $obj, $ftpLog)
{
foreach ($obj as $oneObj) {
$session->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_EXPORTFTP, $ftpLog, '');
}
return $this;
}
}

View File

@@ -139,14 +139,14 @@ class task_period_ftpPull extends task_appboxAbstract
?>
<form name="graphicForm" onsubmit="return(false);" method="post">
<br/>
<?php echo('task::ftp:proxy') ?>
<?php echo('task::ftp:proxy') ?>
<input type="text" name="proxy" style="width:400px;" onchange="chgxmltxt(this, 'proxy');"><br/>
<br/>
<?php echo('task::ftp:proxy port') ?>
<?php echo('task::ftp:proxy port') ?>
<input type="text" name="proxyport" style="width:400px;" onchange="chgxmltxt(this, 'proxyport');"><br/>
<br/>
<?php echo('task::ftp:host') ?>
<?php echo('task::ftp:host') ?>
<input type="text" name="host" style="width:400px;" onchange="chgxmltxt(this, 'host');"><br/>
<br/>
<?php echo('task::ftp:port') ?>
@@ -155,13 +155,13 @@ class task_period_ftpPull extends task_appboxAbstract
<?php echo('task::ftp:user') ?>
<input type="text" name="user" style="width:400px;" onchange="chgxmltxt(this, 'user');"><br/>
<br/>
<?php echo('task::ftp:password') ?>
<?php echo('task::ftp:password') ?>
<input type="password" name="password" style="width:400px;" onchange="chgxmltxt(this, 'password');"><br/>
<br/>
<?php echo('task::ftp:chemin distant') ?>
<?php echo('task::ftp:chemin distant') ?>
<input type="text" name="ftppath" style="width:400px;" onchange="chgxmltxt(this, 'ftppath');"><br/>
<br/>
<?php echo('task::ftp:localpath') ?>
<?php echo('task::ftp:localpath') ?>
<input type="text" name="localpath" style="width:400px;" onchange="chgxmltxt(this, 'localpath');"><br/>
<br/>
@@ -218,8 +218,9 @@ class task_period_ftpPull extends task_appboxAbstract
}
// si on doit changer le xml, on verifie qu'il est valide
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"]))
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"])) {
return(false);
}
$sql = "";
$params = array(':task_id' => $taskid);

View File

@@ -399,16 +399,16 @@ class task_period_outofdate extends task_abstract
$sbas_list = $user->ACL()->get_granted_sbas(array('bas_manage'));
?>
<form name="graphicForm" onsubmit="return(false);" method="post">
<?php echo _('task::outofdate:Base') ?>&nbsp;:&nbsp;
<?php echo _('task::outofdate:Base') ?>&nbsp;:&nbsp;
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
<option value="">...</option>
<?php
foreach ($sbas_list as $databox) {
$selected = '';
print("\t\t\t\t<option value=\"" . $databox->get_sbas_id() . "\" $selected>" . p4string::MakeString($databox->get_viewname(), "form") . "</option>\n");
}
?>
<?php
foreach ($sbas_list as $databox) {
$selected = '';
print("\t\t\t\t<option value=\"" . $databox->get_sbas_id() . "\" $selected>" . p4string::MakeString($databox->get_viewname(), "form") . "</option>\n");
}
?>
</select>
&nbsp;
@@ -416,9 +416,9 @@ class task_period_outofdate extends task_abstract
<br/>
<br/>
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
<br/>
<table id="OUTOFDATETAB" style="margin-right:10px; ">
@@ -427,7 +427,7 @@ class task_period_outofdate extends task_abstract
&nbsp;
</td>
<td style="width:20%;">
<?php echo _('task::outofdate:before') ?>&nbsp;
<?php echo _('task::outofdate:before') ?>&nbsp;
</td>
<td colspan="2" style="width:20%; white-space:nowrap;">
<select style="width:100px" name="field1" id="field1" onchange="chgxmlpopup(this, 'field1');"></select>
@@ -439,7 +439,7 @@ class task_period_outofdate extends task_abstract
<input name="fieldDv1" id="fieldDv1" onchange="chgxmltxt(this, 'fieldDv1');" type="text" style="width:30px" value="0"></input>&nbsp;<?php echo _('admin::taskoutofdate: days ') ?>
</td>
<td style="width:20%; padding-left:20px; padding-right:20px;">
<?php echo _('task::outofdate:between') ?>&nbsp;
<?php echo _('task::outofdate:between') ?>&nbsp;
</td>
<td colspan="2" style="width:20%; white-space:nowrap;">
<select style="width:100px" name="field2" id="field2" onchange="chgxmlpopup(this, 'field2');"></select>
@@ -451,12 +451,12 @@ class task_period_outofdate extends task_abstract
<input name="fieldDv2" id="fieldDv2" onchange="chgxmltxt(this, 'fieldDv2');" type="text" style="width:30px" value="0"></input>&nbsp;<?php echo _('admin::taskoutofdate: days ') ?>
</td>
<td style="width:20%;">
<?php echo _('task::outofdate:after') ?>&nbsp;
<?php echo _('task::outofdate:after') ?>&nbsp;
</td>
</tr>
<tr>
<td style="white-space:nowrap;">
<?php echo _('task::outofdate:coll.') ?>&nbsp;:
<?php echo _('task::outofdate:coll.') ?>&nbsp;:
</td>
<td colspan="2" style="border-right:1px solid #000000">
<select name="coll0" id="coll0" onchange="chgxmlpopup(this, 'coll0');"></select>
@@ -470,7 +470,7 @@ class task_period_outofdate extends task_abstract
</tr>
<tr>
<td style="white-space:nowrap;">
<?php echo _('task::outofdate:status') ?>&nbsp;:<br/>
<?php echo _('task::outofdate:status') ?>&nbsp;:<br/>
</td>
<td colspan="2" style="border-right:1px solid #000000">
<select name="status0" id="status0" onchange="chgxmlpopup(this, 'status0');"></select>

View File

@@ -215,104 +215,104 @@ class task_period_subdef extends task_databoxAbstract
?>
<form name="graphicForm" onsubmit="return(false);" method="post">
<br/>
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
<br/>
<?php echo sprintf(_("task::_common_:passer tous les %s records a l'etape suivante"), '<input type="text" name="flush" style="width:40px;" onchange="chgxmltxt(this, \'flush\');" value="">'); ?>
<?php echo sprintf(_("task::_common_:passer tous les %s records a l'etape suivante"), '<input type="text" name="flush" style="width:40px;" onchange="chgxmltxt(this, \'flush\');" value="">'); ?>
<br/>
<br/>
<?php echo _('task::_common_:relancer la tache tous les') ?>&nbsp;
<?php echo _('task::_common_:relancer la tache tous les') ?>&nbsp;
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>&nbsp;
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
Mo
<br/>
</form>
<?php
$out = ob_get_clean();
<?php
$out = ob_get_clean();
return $out;
}
return $out;
}
protected function flush_records_sbas()
{
$sql = implode(', ', $this->recs_to_write);
protected function flush_records_sbas()
{
$sql = implode(', ', $this->recs_to_write);
if ($sql != '') {
$this->log(sprintf(
'setting %d record(s) to subdef meta writing'
, count($this->recs_to_write)
));
if ($sql != '') {
$this->log(sprintf(
'setting %d record(s) to subdef meta writing'
, count($this->recs_to_write)
));
try {
$connbas = connection::getPDOConnection($this->sbas_id);
$sql = 'UPDATE record
try {
$connbas = connection::getPDOConnection($this->sbas_id);
$sql = 'UPDATE record
SET status=(status & ~0x03),
jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ')
WHERE record_id IN (' . $sql . ')';
$stmt = $connbas->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
} catch (Exception $e) {
$this->log($e->getMessage());
}
$stmt = $connbas->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
} catch (Exception $e) {
$this->log($e->getMessage());
}
$this->recs_to_write = array();
return $this;
}
$this->recs_to_write = array();
public function retrieve_sbas_content(databox $databox)
{
$connbas = $databox->get_connection();
return $this;
}
$sql = 'SELECT coll_id, record_id
public function retrieve_sbas_content(databox $databox)
{
$connbas = $databox->get_connection();
$sql = 'SELECT coll_id, record_id
FROM record
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
AND parent_record_id = 0
ORDER BY record_id DESC LIMIT 0, 20';
$stmt = $connbas->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $connbas->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $rs;
return $rs;
}
public function process_one_content(databox $databox, Array $row)
{
$record_id = $row['record_id'];
$this->log(sprintf(
"Generate subdefs for : sbas_id %s / record %s "
, $this->sbas_id, $record_id));
$record = new record_adapter($this->sbas_id, $record_id);
$record->generate_subdefs($databox, null);
$this->recs_to_write[] = $record->get_record_id();
if (count($this->recs_to_write) >= $this->record_buffer_size) {
$this->flush_records_sbas();
}
unset($record);
public function process_one_content(databox $databox, Array $row)
{
$record_id = $row['record_id'];
$this->log(sprintf(
"Generate subdefs for : sbas_id %s / record %s "
, $this->sbas_id, $record_id));
$record = new record_adapter($this->sbas_id, $record_id);
return $this;
}
$record->generate_subdefs($databox, null);
$this->recs_to_write[] = $record->get_record_id();
if (count($this->recs_to_write) >= $this->record_buffer_size) {
$this->flush_records_sbas();
}
unset($record);
return $this;
}
protected function post_process_one_content(databox $databox, Array $row)
{
$connbas = $databox->get_connection();
$sql = 'UPDATE record
protected function post_process_one_content(databox $databox, Array $row)
{
$connbas = $databox->get_connection();
$sql = 'UPDATE record
SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW()
WHERE record_id=:record_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $row['record_id']));
$stmt->closeCursor();
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $row['record_id']));
$stmt->closeCursor();
return $this;
}
return $this;
}
}

View File

@@ -115,7 +115,7 @@ class task_period_workflow01 extends task_databoxAbstract
parent.chgsbas(<?php echo $form ?>[pops[j].name]);
}
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
parent.calccmd();
parent.calccmd();
</script>
<?php
return("");
@@ -305,16 +305,16 @@ class task_period_workflow01 extends task_databoxAbstract
ob_start();
?>
<form name="graphicForm" onsubmit="return(false);" method="post">
<?php echo _('task::outofdate:Base') ?>&nbsp;:&nbsp;
<?php echo _('task::outofdate:Base') ?>&nbsp;:&nbsp;
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
<option value="">...</option>
<?php
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
foreach ($sbas_ids as $databox) {
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
}
?>
<?php
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
foreach ($sbas_ids as $databox) {
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
}
?>
</select>
&nbsp;
@@ -322,9 +322,9 @@ class task_period_workflow01 extends task_databoxAbstract
<br/>
<br/>
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
<br/>
<table id="OUTOFDATETAB" style="margin-right:10px; ">

View File

@@ -183,188 +183,188 @@ class task_period_writemeta extends task_databoxAbstract
?>
<form name="graphicForm" onsubmit="return(false);" method="post">
<br/>
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
<br/>
<input type="checkbox" name="cleardoc" onchange="chgxmlck(this)">
<?php echo _('task::writemeta:effacer les metadatas non presentes dans la structure') ?>
<?php echo _('task::writemeta:effacer les metadatas non presentes dans la structure') ?>
<br/>
<br/>
<?php echo _('task::_common_:relancer la tache tous les') ?>&nbsp;
<?php echo _('task::_common_:relancer la tache tous les') ?>&nbsp;
<input type="text" name="maxrecs" style="width:40px;" onchange="chgxmltxt(this, 'maxrecs');" value="">
<?php echo _('task::_common_:records, ou si la memoire depasse') ?>&nbsp;
<input type="text" name="maxmegs" style="width:40px;" onchange="chgxmltxt(this, 'maxmegs');" value="">
Mo
<br/>
</form>
<?php
}
$out = ob_get_clean();
return $out;
<?php
}
$out = ob_get_clean();
protected function retrieve_sbas_content(databox $databox)
{
$connbas = $databox->get_connection();
$subdefgroups = $databox->get_subdef_structure();
$metasubdefs = array();
foreach ($subdefgroups as $type => $subdefs) {
foreach ($subdefs as $sub) {
$name = $sub->get_name();
if ($sub->meta_writeable())
$metasubdefs[$name . '_' . $type] = true;
}
}
$this->metasubdefs = $metasubdefs;
$sql = 'SELECT record_id, coll_id, jeton
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)';
$stmt = $connbas->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $rs;
}
protected function format_value($type, $value)
{
if ($type == 'date') {
$value = str_replace(array("-", ":", "/", "."), array(" ", " ", " ", " "), $value);
$ip_date_yyyy = 0;
$ip_date_mm = 0;
$ip_date_dd = 0;
$ip_date_hh = 0;
$ip_date_nn = 0;
$ip_date_ss = 0;
switch (sscanf($value, "%d %d %d %d %d %d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd, $ip_date_hh, $ip_date_nn, $ip_date_ss)) {
case 1:
$value = sprintf("%04d:00:00", $ip_date_yyyy);
break;
case 2:
$value = sprintf("%04d:%02d:00", $ip_date_yyyy, $ip_date_mm);
break;
case 3:
case 4:
case 5:
case 6:
$value = sprintf("%04d:%02d:%02d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd);
break;
default:
$value = '0000:00:00';
}
}
return $value;
}
protected function process_one_content(databox $databox, Array $row)
{
$coll_id = $row['coll_id'];
$record_id = $row['record_id'];
$jeton = $row['jeton'];
$record = new record_adapter($this->sbas_id, $record_id);
$type = $record->get_type();
$subdefs = $record->get_subdefs();
$tsub = array();
foreach ($subdefs as $name => $subdef) {
$write_document = (($jeton & JETON_WRITE_META_DOC) && $name == 'document');
$write_subdef = (($jeton & JETON_WRITE_META_SUBDEF) && isset($this->metasubdefs[$name . '_' . $type]));
if ($write_document || $write_subdef) {
$tsub[$name] = $subdef->get_pathfile();
}
}
$registry = $databox->get_registry();
$fields = $record->get_caption()->get_fields();
$subCMD = '';
if ($record->get_uuid()) {
$subCMD .= ' -XMP-exif:ImageUniqueID=';
$subCMD .= escapeshellarg($record->get_uuid());
$subCMD .= ' -IPTC:UniqueDocumentID=';
$subCMD .= escapeshellarg($record->get_uuid());
}
foreach ($fields as $field) {
$meta = $field->get_databox_field();
/* @var $meta \databox_field */
if (trim($meta->get_metadata_source()) === '') {
continue;
}
$multi = $meta->is_multi();
$type = $meta->get_type();
$datas = $field->get_values();
if ($multi) {
foreach ($datas as $value) {
$value = $this->format_value($type, $value->getValue());
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
$subCMD .= escapeshellarg($value) . ' ';
}
} else {
$value = array_pop($datas);
$datas = $this->format_value($type, $value->getValue());
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
$subCMD .= escapeshellarg($datas) . ' ';
}
}
foreach ($tsub as $name => $file) {
$cmd = '';
if ($this->system == 'WINDOWS')
$cmd = 'start /B /LOW ';
$cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original ');
if ($name != 'document' || $this->clear_doc)
$cmd .= ' -all:all= ';
$cmd .= ' -codedcharacterset=utf8 ';
$cmd .= $subCMD . ' ' . escapeshellarg($file);
$this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name));
$s = trim(shell_exec($cmd));
$this->log("\t" . $s);
}
return $this;
}
protected function flush_records_sbas()
{
return $this;
}
protected function post_process_one_content(databox $databox, Array $row)
{
$connbas = $databox->get_connection();
$sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . '
WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $row['record_id']));
$stmt->closeCursor();
return $this;
}
return $out;
}
protected function retrieve_sbas_content(databox $databox)
{
$connbas = $databox->get_connection();
$subdefgroups = $databox->get_subdef_structure();
$metasubdefs = array();
foreach ($subdefgroups as $type => $subdefs) {
foreach ($subdefs as $sub) {
$name = $sub->get_name();
if ($sub->meta_writeable())
$metasubdefs[$name . '_' . $type] = true;
}
}
$this->metasubdefs = $metasubdefs;
$sql = 'SELECT record_id, coll_id, jeton
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)';
$stmt = $connbas->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $rs;
}
protected function format_value($type, $value)
{
if ($type == 'date') {
$value = str_replace(array("-", ":", "/", "."), array(" ", " ", " ", " "), $value);
$ip_date_yyyy = 0;
$ip_date_mm = 0;
$ip_date_dd = 0;
$ip_date_hh = 0;
$ip_date_nn = 0;
$ip_date_ss = 0;
switch (sscanf($value, "%d %d %d %d %d %d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd, $ip_date_hh, $ip_date_nn, $ip_date_ss)) {
case 1:
$value = sprintf("%04d:00:00", $ip_date_yyyy);
break;
case 2:
$value = sprintf("%04d:%02d:00", $ip_date_yyyy, $ip_date_mm);
break;
case 3:
case 4:
case 5:
case 6:
$value = sprintf("%04d:%02d:%02d", $ip_date_yyyy, $ip_date_mm, $ip_date_dd);
break;
default:
$value = '0000:00:00';
}
}
return $value;
}
protected function process_one_content(databox $databox, Array $row)
{
$coll_id = $row['coll_id'];
$record_id = $row['record_id'];
$jeton = $row['jeton'];
$record = new record_adapter($this->sbas_id, $record_id);
$type = $record->get_type();
$subdefs = $record->get_subdefs();
$tsub = array();
foreach ($subdefs as $name => $subdef) {
$write_document = (($jeton & JETON_WRITE_META_DOC) && $name == 'document');
$write_subdef = (($jeton & JETON_WRITE_META_SUBDEF) && isset($this->metasubdefs[$name . '_' . $type]));
if ($write_document || $write_subdef) {
$tsub[$name] = $subdef->get_pathfile();
}
}
$registry = $databox->get_registry();
$fields = $record->get_caption()->get_fields();
$subCMD = '';
if ($record->get_uuid()) {
$subCMD .= ' -XMP-exif:ImageUniqueID=';
$subCMD .= escapeshellarg($record->get_uuid());
$subCMD .= ' -IPTC:UniqueDocumentID=';
$subCMD .= escapeshellarg($record->get_uuid());
}
foreach ($fields as $field) {
$meta = $field->get_databox_field();
/* @var $meta \databox_field */
if (trim($meta->get_metadata_source()) === '') {
continue;
}
$multi = $meta->is_multi();
$type = $meta->get_type();
$datas = $field->get_values();
if ($multi) {
foreach ($datas as $value) {
$value = $this->format_value($type, $value->getValue());
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
$subCMD .= escapeshellarg($value) . ' ';
}
} else {
$value = array_pop($datas);
$datas = $this->format_value($type, $value->getValue());
$subCMD .= ' -' . $meta->get_metadata_namespace() . ':' . $meta->get_metadata_tagname() . '=';
$subCMD .= escapeshellarg($datas) . ' ';
}
}
foreach ($tsub as $name => $file) {
$cmd = '';
if ($this->system == 'WINDOWS')
$cmd = 'start /B /LOW ';
$cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original ');
if ($name != 'document' || $this->clear_doc)
$cmd .= ' -all:all= ';
$cmd .= ' -codedcharacterset=utf8 ';
$cmd .= $subCMD . ' ' . escapeshellarg($file);
$this->log(sprintf(('writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)'), $this->sbas_id, $record_id, $name));
$s = trim(shell_exec($cmd));
$this->log("\t" . $s);
}
return $this;
}
protected function flush_records_sbas()
{
return $this;
}
protected function post_process_one_content(databox $databox, Array $row)
{
$connbas = $databox->get_connection();
$sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . '
WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $row['record_id']));
$stmt->closeCursor();
return $this;
}
}

View File

@@ -17,8 +17,9 @@ class uuid
*/
public static function generate_v3($namespace, $name)
{
if ( ! self::is_valid($namespace))
if ( ! self::is_valid($namespace)) {
return false;
}
// Get hexadecimal components of namespace
$nhex = str_replace(array('-', '{', '}'), '', $namespace);
@@ -82,8 +83,9 @@ class uuid
*/
public static function generate_v5($namespace, $name)
{
if ( ! self::is_valid($namespace))
if ( ! self::is_valid($namespace)) {
return false;
}
// Get hexadecimal components of namespace
$nhex = str_replace(array('-', '{', '}'), '', $namespace);

View File

@@ -66,6 +66,7 @@ if ( ! is_null($parm['token'])) {
</body>
</html>
<?php
return;
} catch (Exception $e) {
?>
@@ -95,6 +96,7 @@ if ( ! is_null($parm['token'])) {
</body>
</html>
<?php
return;
}
}

View File

@@ -272,8 +272,9 @@ function doUserConf($conf, $param)
return $new_conf;
}
else
else {
return $conf;
}
}
function displayListColumn($conf, $param, $twig)

View File

@@ -318,8 +318,9 @@ function doUserConf($conf, $param)
return $new_conf;
}
else
else {
return $conf;
}
}
function displayListColumn($conf, $param, $twig)

View File

@@ -108,11 +108,17 @@ class patch_th_2_0_3
function fixRejected(connection_pdo &$connbas, &$node, $rejected)
{
global $debug;
if ($node->nodeType != XML_ELEMENT_NODE)
if ($node->nodeType != XML_ELEMENT_NODE) {
return;
}
$id = $node->getAttribute("id");
if (substr($id, 0, 1) == "R")
if (substr($id, 0, 1) == "R") {
$rejected = true;
}
if ($rejected) {
$newid = "R" . substr($id, 1);
if ($newid != $id) {

View File

@@ -111,11 +111,17 @@ class patch_th_2_0_4
function fixRejected(connection_pdo &$connbas, &$node, $rejected)
{
global $debug;
if ($node->nodeType != XML_ELEMENT_NODE)
if ($node->nodeType != XML_ELEMENT_NODE) {
return;
}
$id = $node->getAttribute("id");
if (substr($id, 0, 1) == "R")
if (substr($id, 0, 1) == "R") {
$rejected = true;
}
if ($rejected) {
$newid = "R" . substr($id, 1);
if ($newid != $id) {