noalyss Version-9
package_core.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
21
22/**
23 * @file
24 * @brief Class Package Core to install the core , if possible
25 */
26
27/**
28 * @class Package_Core
29 * @brief Class Package Core to install the core , if possible
30 */
32{
33
34 /**
35 * @brief check if it is possible to install
36 * Are the folder html and include writeable ?
37 */
38 public function can_install()
39 {
40 if (! is_writable(NOALYSS_HOME)) {
41 return 0;
42 }
43 if ( !is_writable(NOALYSS_INCLUDE)) {
44 return 0;
45 }
46 return 1;
47 }
48
49 /**
50 * Unzip the file and overwrite current implementation, the databases and modele are not upgraded.
51 *It must be done after.
52 * In this package the install is given and must be delete manually
53 * @throws Exception 1 : cannot extract content of the zip , 2: cannot open zip file
54 */
55 public function install()
56 {
57 if ( $this->can_install() == 0 )
58 {
59 throw new Exception(sprintf(_("Permission incorrecte : ne peut écrire dans %s ou %s"),NOALYSS_HOME,NOALYSS_INCLUDE),3);
60 }
61 $zip=new ZipArchive ();
62 // open the file
63 if ($zip->open(NOALYSS_HOME."/tmp/".$this->get_file()))
64 {
65 // try to unzip and overwrite current
66 if (!$zip->extractTo(NOALYSS_HOME."/../"))
67 {
68 throw new Exception(_("Echec mise à jour"), 1);
69 }
70 }
71 else
72 {
73 throw new Exception(_("Ce n'est pas un fichier valide"), 2);
74 }
75
76 }
77
78}
Class Package Core to install the core , if possible.
can_install()
check if it is possible to install Are the folder html and include writeable ?
install()
Unzip the file and overwrite current implementation, the databases and modele are not upgraded.
package noalyss is the mother class of the class to install and download package