diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index d1df0cce7b..ce4641886a 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -109,6 +109,28 @@ class Bridge implements ControllerProviderInterface return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-elements/' . $account->get_api()->get_connector()->get_default_element_type() . '/'); })->assert('account_id', '\d+'); + $controllers->post('/adapter/{account_id}/delete/' + , function($account_id) use ($app) { + $success = false; + $message = ''; + try { + $account = \Bridge_Account::load_account($app['phraseanet.appbox'], $account_id); + + if ($account->get_user()->get_id() !== $app->getAuthenticatedUser()->get_id()) { + throw new HttpException(403, 'Access forbiden'); + } + + $account->delete(); + $success = true; + } catch(\Bridge_Exception_AccountNotFound $e) { + $message = _('Account is not found.'); + } catch(\Exception $e) { + $message = _('Something went wrong, please contact an administrator'); + } + + return $app->json(array('success' => $success, 'message' => $message)); + })->assert('account_id', '\d+'); + $controllers->get('/adapter/{account_id}/load-records/', function(Application $app, $account_id) { $page = max((int) $app['request']->query->get('page'), 0); $quantity = 10; diff --git a/lib/Alchemy/Phrasea/Helper/Prod.php b/lib/Alchemy/Phrasea/Helper/Prod.php index 36f6ceda27..87f596e271 100644 --- a/lib/Alchemy/Phrasea/Helper/Prod.php +++ b/lib/Alchemy/Phrasea/Helper/Prod.php @@ -88,7 +88,7 @@ class Prod extends Helper continue; } - if (simplexml_load_string($databox->get_cterms())) { + if (false !== simplexml_load_string($databox->get_cterms())) { $bases[$sbas_id]['cterms'] = true; } } diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php index c7bcfc22e6..7b38053255 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDF.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -349,8 +349,9 @@ class PDF $collection = \collection::get_from_base_id($this->app, $rec->get_base_id()); $vn = ""; - if ($str = simplexml_load_string($collection->get_prefs())) + if (false !== $str = simplexml_load_string($collection->get_prefs())) { $vn = (string) ($str->pdfPrintappear); + } if ($vn == "" || $vn == "1") { $RIGHT_TEXT = \phrasea::bas_names($rec->get_base_id(), $this->app); diff --git a/lib/classes/Bridge/Api/Youtube.class.php b/lib/classes/Bridge/Api/Youtube.class.php index ad09e3ec98..86338732ea 100644 --- a/lib/classes/Bridge/Api/Youtube.class.php +++ b/lib/classes/Bridge/Api/Youtube.class.php @@ -631,7 +631,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $xml = simplexml_load_string($string); libxml_clear_errors(); - if ( ! $xml) { + if (false === $xml) { return false; } @@ -723,11 +723,10 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $cat = array(); $url_cat = sprintf('%s?hl=%s', self::CATEGORY_URL, $this->get_locale()); - $cxml = @simplexml_load_file($url_cat); - - if ( ! $cxml) + if (false === $cxml = simplexml_load_file($url_cat)) { throw new Bridge_Exception_ApiConnectorRequestFailed('Failed to retrive youtube categories'); - + } + $cxml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); $categories = $cxml->xpath('//atom:category'); diff --git a/lib/classes/base.class.php b/lib/classes/base.class.php index 5f35d10960..a1fbcfc926 100644 --- a/lib/classes/base.class.php +++ b/lib/classes/base.class.php @@ -358,10 +358,9 @@ abstract class base implements cache_cacheableInterface return $this; } - $structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml"); - - if ( ! $structure) + if (false === $structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml")) { throw new Exception('Unable to load schema'); + } if ($this->get_base_type() === self::APPLICATION_BOX) $this->schema = $structure->appbox; diff --git a/lib/classes/databox.class.php b/lib/classes/databox.class.php index 73bf0c4f98..6b6ea9199e 100644 --- a/lib/classes/databox.class.php +++ b/lib/classes/databox.class.php @@ -1009,7 +1009,7 @@ class databox extends base $thesaurus = $this->get_thesaurus(); - if ($thesaurus && ($tmp = simplexml_load_string($thesaurus)) !== false) + if ($thesaurus && false !== $tmp = simplexml_load_string($thesaurus)) self::$_sxml_thesaurus[$sbas_id] = $tmp; else self::$_sxml_thesaurus[$sbas_id] = false; @@ -1174,7 +1174,7 @@ class databox extends base $structure = $this->get_structure(); - if ($structure && ($tmp = simplexml_load_string($structure)) !== false) + if ($structure && false !== $tmp = simplexml_load_string($structure)) $this->_sxml_structure = $tmp; else $this->_sxml_structure = false; diff --git a/lib/classes/databox/status.class.php b/lib/classes/databox/status.class.php index 35615380dc..637886962e 100644 --- a/lib/classes/databox/status.class.php +++ b/lib/classes/databox/status.class.php @@ -78,7 +78,7 @@ class databox_status $xmlpref = $databox->get_structure(); $sxe = simplexml_load_string($xmlpref); - if ($sxe) { + if ($sxe !== false) { foreach ($sxe->statbits->bit as $sb) { $bit = (int) ($sb["n"]); diff --git a/lib/classes/deprecated/inscript.api.php b/lib/classes/deprecated/inscript.api.php index 99840b6460..749e3cd2ac 100644 --- a/lib/classes/deprecated/inscript.api.php +++ b/lib/classes/deprecated/inscript.api.php @@ -112,7 +112,7 @@ function giveMeBases(Application $app, $usr = null) $collInscript = $baseInscript; $defined = false; $cguSpec = false; - if ($xml = simplexml_load_string($collection->get_prefs())) { + if (false !== $xml = simplexml_load_string($collection->get_prefs())) { $defined = true; foreach ($xml->xpath('/baseprefs/caninscript') as $caninscript) { $tmp = (string) $caninscript; diff --git a/lib/classes/geonames.class.php b/lib/classes/geonames.class.php index 17f5193abf..eb6f8de9b1 100644 --- a/lib/classes/geonames.class.php +++ b/lib/classes/geonames.class.php @@ -33,7 +33,7 @@ class geonames $sxe = simplexml_load_string($xml); - if ($sxe && ($geoname = $sxe->geoname)) { + if ($sxe !== false && ($geoname = $sxe->geoname)) { $ret = (string) $geoname->city . ', ' . (string) $geoname->country; } } @@ -56,7 +56,7 @@ class geonames if ($xml) { $sxe = simplexml_load_string($xml); - if ($sxe && ($geoname = $sxe->geoname)) { + if ($sxe !== false && ($geoname = $sxe->geoname)) { $ret = (string) $geoname->country; } } @@ -76,7 +76,7 @@ class geonames if ($xml) { $sxe = simplexml_load_string($xml); - if ($sxe && ($geoname = $sxe->geoname)) { + if ($sxe !== false && ($geoname = $sxe->geoname)) { $ret = (string) $geoname->country_code; } } @@ -157,7 +157,7 @@ class geonames $xml = http_query::getUrl($url); if ($xml) { $sxe = simplexml_load_string($xml); - if ($sxe && $sxe->geoname) { + if ($sxe !== false && $sxe->geoname) { $output['city'] = (string) $sxe->geoname->city; $output['country_code'] = (string) $sxe->geoname->country_code; $output['country'] = (string) $sxe->geoname->country; diff --git a/lib/classes/patch/370a8.class.php b/lib/classes/patch/370a8.class.php index 64c4dbfa59..7edf8fb3b8 100644 --- a/lib/classes/patch/370a8.class.php +++ b/lib/classes/patch/370a8.class.php @@ -83,7 +83,7 @@ class patch_370a8 implements patchInterface * migrating task 'workflow01' or 'task_period_ftv' */ $x = $task['settings']; - if (($sx = simplexml_load_string($x)) !== FALSE) { + if (false !== $sx = simplexml_load_string($x)) { $period = (int) ($sx->period); if ( ! array_key_exists('_' . $period, $tdom)) { diff --git a/lib/classes/queries.class.php b/lib/classes/queries.class.php index 41b5f00c63..7c3ad3ded4 100644 --- a/lib/classes/queries.class.php +++ b/lib/classes/queries.class.php @@ -35,8 +35,8 @@ class queries } $cssTopics = ''; - if ($xmlTopics && ($sxTopics = simplexml_load_file($xmlTopics))) { - $cssTopics = (string) ($sxTopics->display->css); + if ($xmlTopics && false !== $sxTopics = simplexml_load_file($xmlTopics)) { + $cssTopics = (string) $sxTopics->display->css; } $out .= '