diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index f3d69835cea..4098c89e4d4 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -289,15 +289,24 @@ function exportWebSite($website) /** * Open a zip with all data of web site and load it into database. * - * @param string $filename Path of zip file + * @param string $pathtofile Path of zip file * @return int <0 if KO, >0 if OK */ -function importWebSite($filename) +function importWebSite($pathtofile) { $result = 0; + $filename = basename($pathtofile); + if (! preg_match('/^website_(.*)-(.*)$/', $filename, $reg)) + { + $this->errors[]='Bad format for filename '.$filename.'. Must be website_XXX-VERSION.'; + return -1; + } - //$sql = array("INSERT INTO ".MAIN_DB_PREFIX."website(ref, entity, description, status) values('sellyoursaas', '.$conf->entity.', Portal to sell your SaaS', 1)"); + $websitecode = $reg[1]; + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."website(ref, entity, description, status) values('".$websitecode."', ".$conf->entity.", 'Portal to sell your SaaS. Do not remove this entry.', 1)"; + $resql = $db->query($sql); return $result; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e238fe1ae75..48f023076b2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3691,8 +3691,9 @@ class Societe extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @param string $type Category type (customer or supplier) + * @param int[]|int $categories Category ID or array of Categories IDs + * @param string $type Category type ('customer' or 'supplier') + * @return int <0 if KO, >0 if OK */ public function setCategories($categories, $type) { @@ -3707,7 +3708,7 @@ class Societe extends CommonObject $type_text = 'supplier'; } else { dol_syslog(__METHOD__ . ': Type ' . $type . 'is an unknown company category type. Done nothing.', LOG_ERR); - return; + return -1; } // Handle single category @@ -3740,7 +3741,7 @@ class Societe extends CommonObject } } - return; + return 1; }