/** * @file * @brief */ require_once NOALYSS_INCLUDE."/class/package_noalyss.class.php"; /** * @brief * */ class Package_Template extends Package_Noalyss { public function can_install() { return TRUE; } /** * Install the template */ public function install() { // make temp dir $tmp=NOALYSS_HOME."/tmp/"; $tmpdir=$tmp."db-".microtime(TRUE); mkdir($tmpdir); // unzip Archive file $db=new ZipArchive; $db->open($tmp."/".$this->get_file()); $db->extractTo($tmpdir); // create database $cn=new Database(); $seq=$cn->get_value("select nextval('s_modid')"); $sql=sprintf(" create database %smod%d encoding='utf8'", domaine, $seq); $cn->exec_sql($sql); $newdb=new Database($seq, 'mod'); // Execute SQL Script $newdb->execute_script($tmpdir.'/schema.sql'); $newdb->execute_script($tmpdir.'/data.sql'); $newdb->execute_script($tmpdir.'/constraint.sql'); // Register into account_repository, we add the seq number for avoiding duplicate $description = sprintf(_("Installé le %s"),date("d-m-Y h:i:s")); $cn->exec_sql(" insert into modeledef (mod_id,mod_name,mod_desc) values ($1,$2,$3)", [$seq,$seq."-".$this->get_name(),$this->get_description()." ".$description]); } }