Overview
Comment:Utiliser le répertoire de cache défini par XDG_CACHE_HOME
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9417cb378856831424bd456a0d5e68a311460afb
User & Date: bohwaz on 2015-01-15 01:23:43
Other Links: manifest | tags
Context
2015-01-15
18:43
la suppression de membre était cassée à cause des contraintes de foreign keys, réparons cela check-in: 40c40f1cca user: bohwaz tags: trunk
01:23
Utiliser le répertoire de cache défini par XDG_CACHE_HOME check-in: 9417cb3788 user: bohwaz tags: trunk
2015-01-07
17:50
Débuts version 0.7.0 : possibilité pour les plugins de gérer des nouveaux types de boucles check-in: d4f28a592b user: bohwaz tags: trunk
Changes

Modified debian/config.debian.php from [5d75045997] to [d4c3b1b5ce].

2
3
4
5
6
7
8

9
10
11
12
13






14
15
16
17
18
19
20
21
22
23
24
25













26
27
28
29
30
31
32
..
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

namespace Garradin;

if (!empty($_ENV['GARRADIN_STANDALONE']))
{
	$home = $_ENV['HOME'];


	if (empty($_ENV['XDG_CONFIG_HOME']))
	{
		$_ENV['XDG_CONFIG_HOME'] = $home . '/.config';
	}







	if (empty($_ENV['XDG_DATA_HOME']))
	{
		$_ENV['XDG_DATA_HOME'] = $home . '/.local/share';
	}

	if (!file_exists($_ENV['XDG_DATA_HOME'] . '/garradin'))
	{
		mkdir($_ENV['XDG_DATA_HOME'] . '/garradin');
	}

	define('Garradin\DATA_ROOT', $_ENV['XDG_DATA_HOME'] . '/garradin');














	$last_file = $_ENV['XDG_CONFIG_HOME'] . '/garradin/last';

	if ($_ENV['GARRADIN_STANDALONE'] != 1)
	{
		$last_sqlite = trim($_ENV['GARRADIN_STANDALONE']);
	}
	else if (file_exists($last_file))
................................................................................
		$last_sqlite = trim(file_get_contents($last_file));
	}
	else 
	{
		$last_sqlite = $_ENV['XDG_DATA_HOME'] . '/garradin/association.sqlite';
	}

	if (!file_exists($_ENV['XDG_CONFIG_HOME'] . '/garradin'))
	{
		mkdir($_ENV['XDG_CONFIG_HOME'] . '/garradin');
	}

	file_put_contents($last_file, $last_sqlite);
	
	define('Garradin\DB_FILE', $last_sqlite);
	define('Garradin\LOCAL_LOGIN', 1);
}







>





>
>
>
>
>
>







|




>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
<
<
<
<





2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
54
55
56
57
58
59
60





61
62
63
64
65

namespace Garradin;

if (!empty($_ENV['GARRADIN_STANDALONE']))
{
	$home = $_ENV['HOME'];

	// Config directory
	if (empty($_ENV['XDG_CONFIG_HOME']))
	{
		$_ENV['XDG_CONFIG_HOME'] = $home . '/.config';
	}

	if (!file_exists($_ENV['XDG_CONFIG_HOME'] . '/garradin'))
	{
		mkdir($_ENV['XDG_CONFIG_HOME'] . '/garradin', 0700, true);
	}

	// Data directory: where the data will go
	if (empty($_ENV['XDG_DATA_HOME']))
	{
		$_ENV['XDG_DATA_HOME'] = $home . '/.local/share';
	}

	if (!file_exists($_ENV['XDG_DATA_HOME'] . '/garradin'))
	{
		mkdir($_ENV['XDG_DATA_HOME'] . '/garradin', 0700, true);
	}

	define('Garradin\DATA_ROOT', $_ENV['XDG_DATA_HOME'] . '/garradin');

	// Cache directory: temporary stuff
	if (empty($_ENV['XDG_CACHE_HOME']))
	{
		$_ENV['XDG_CACHE_HOME'] = $home . '/.cache';
	}

	if (!file_exists($_ENV['XDG_CACHE_HOME'] . '/garradin'))
	{
		mkdir($_ENV['XDG_CACHE_HOME'] . '/garradin', 0700, true);
	}

	define('Garradin\CACHE_ROOT', $_ENV['XDG_CACHE_HOME'] . '/garradin');

	$last_file = $_ENV['XDG_CONFIG_HOME'] . '/garradin/last';

	if ($_ENV['GARRADIN_STANDALONE'] != 1)
	{
		$last_sqlite = trim($_ENV['GARRADIN_STANDALONE']);
	}
	else if (file_exists($last_file))
................................................................................
		$last_sqlite = trim(file_get_contents($last_file));
	}
	else 
	{
		$last_sqlite = $_ENV['XDG_DATA_HOME'] . '/garradin/association.sqlite';
	}






	file_put_contents($last_file, $last_sqlite);
	
	define('Garradin\DB_FILE', $last_sqlite);
	define('Garradin\LOCAL_LOGIN', 1);
}

Modified debian/makedeb.sh from [ee35aa24d9] to [6b1badb692].

4
5
6
7
8
9
10

11
12
13
14
15
16
17
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
DEB_REV=${1-1} # .deb package build/revision number.
PACKAGE_DEBNAME=garradin
THISDIR=${PWD}

DEB_ARCH_NAME=all

SRCDIR=$(cd ..; pwd)/src

test -e ${SRCDIR} || {
    echo "This script must be run from a BUILT copy of the source tree."
    exit 1
}

DEBROOT=$PWD/deb.tmp
test -d ${DEBROOT} && rm -fr ${DEBROOT}
................................................................................
Section: web
Priority: optional
Maintainer: Garradin <garradin@kd2.org>
Architecture: ${DEB_ARCH_NAME}
Depends: dash | bash, php5-cli (>=5.4), php5-sqlite
Version: ${PACKAGE_DEB_VERSION}
Suggests: www-browser
Homepage: http://garradin.kd2.org/
Description: Garradin is a tool to manage non-profit organizations.
 It's only available in french.
Description-fr: Gestionnaire d'association en interface web ou CLI.
 Garradin est un gestionnaire d'association à but non lucratif.
 Il permet de gérer les membres, leur adhésion et leurs contributions financières.
 Les membres peuvent se connecter eux-même et modifier leurs informations
 ou communiquer entre eux par e-mail. Une gestion précise des droits et







>







 







|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
DEB_REV=${1-1} # .deb package build/revision number.
PACKAGE_DEBNAME=garradin
THISDIR=${PWD}

DEB_ARCH_NAME=all

SRCDIR=$(cd ..; pwd)/src
SRCDIR='/tmp/garradin-0.6.3'
test -e ${SRCDIR} || {
    echo "This script must be run from a BUILT copy of the source tree."
    exit 1
}

DEBROOT=$PWD/deb.tmp
test -d ${DEBROOT} && rm -fr ${DEBROOT}
................................................................................
Section: web
Priority: optional
Maintainer: Garradin <garradin@kd2.org>
Architecture: ${DEB_ARCH_NAME}
Depends: dash | bash, php5-cli (>=5.4), php5-sqlite
Version: ${PACKAGE_DEB_VERSION}
Suggests: www-browser
Homepage: http://dev.kd2.org/garradin/
Description: Garradin is a tool to manage non-profit organizations.
 It's only available in french.
Description-fr: Gestionnaire d'association en interface web ou CLI.
 Garradin est un gestionnaire d'association à but non lucratif.
 Il permet de gérer les membres, leur adhésion et leurs contributions financières.
 Les membres peuvent se connecter eux-même et modifier leurs informations
 ou communiquer entre eux par e-mail. Une gestion précise des droits et

Modified src/include/init.php from [4c2c1512df] to [b9b3bbdd71].

57
58
59
60
61
62
63





64
65
66
67
68
69
70
    define('Garradin\ROOT', dirname(__DIR__));
}

if (!defined('Garradin\DATA_ROOT'))
{
    define('Garradin\DATA_ROOT', ROOT);
}






if (!defined('Garradin\DB_FILE'))
{
    define('Garradin\DB_FILE', DATA_ROOT . '/association.sqlite');
}

if (!defined('Garradin\DB_SCHEMA'))







>
>
>
>
>







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    define('Garradin\ROOT', dirname(__DIR__));
}

if (!defined('Garradin\DATA_ROOT'))
{
    define('Garradin\DATA_ROOT', ROOT);
}

if (!defined('Garradin\CACHE_ROOT'))
{
    define('Garradin\CACHE_ROOT', DATA_ROOT . '/cache');
}

if (!defined('Garradin\DB_FILE'))
{
    define('Garradin\DB_FILE', DATA_ROOT . '/association.sqlite');
}

if (!defined('Garradin\DB_SCHEMA'))

Modified src/include/lib/Garradin/Squelette.php from [2b931bda50] to [708fed8a81].

619
620
621
622
623
624
625
626
627
628
629
630
631
632
633

        $this->display($skel);
    }

    static private function compile_get_path($path)
    {
        $hash = sha1($path);
        return DATA_ROOT . '/cache/compiled/s_' . $hash . '.php';
    }

    static private function compile_check($tpl, $check)
    {
        if (!file_exists(self::compile_get_path($tpl)))
            return false;








|







619
620
621
622
623
624
625
626
627
628
629
630
631
632
633

        $this->display($skel);
    }

    static private function compile_get_path($path)
    {
        $hash = sha1($path);
        return CACHE_ROOT . '/compiled/s_' . $hash . '.php';
    }

    static private function compile_check($tpl, $check)
    {
        if (!file_exists(self::compile_get_path($tpl)))
            return false;

Modified src/include/lib/Garradin/Static_Cache.php from [6a9d022131] to [f40cd20c85].

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Static_Cache
{
	const EXPIRE = 3600; // 1h
	const CLEAN_EXPIRE = 86400; // 1 day

	protected static function _getCacheDir()
	{
		return DATA_ROOT . '/cache/static';
	}

	protected static function _getCachePath($id)
	{
		$id = 'cache_' . sha1($id);
		return self::_getCacheDir() . '/' . $id;
	}







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Static_Cache
{
	const EXPIRE = 3600; // 1h
	const CLEAN_EXPIRE = 86400; // 1 day

	protected static function _getCacheDir()
	{
		return CACHE_ROOT . '/static';
	}

	protected static function _getCachePath($id)
	{
		$id = 'cache_' . sha1($id);
		return self::_getCacheDir() . '/' . $id;
	}

Modified src/include/lib/Garradin/Template.php from [0b9f38d0e7] to [5f9337c020].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

    public function __construct()
    {
        parent::__construct();

        $this->cache = false;

        $this->compile_dir = DATA_ROOT . '/cache/compiled';
        $this->template_dir = ROOT . '/templates';

        $this->compile_check = true;

        $this->reserved_template_varname = 'tpl';

        $this->assign('www_url', WWW_URL);







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

    public function __construct()
    {
        parent::__construct();

        $this->cache = false;

        $this->compile_dir = CACHE_ROOT . '/compiled';
        $this->template_dir = ROOT . '/templates';

        $this->compile_check = true;

        $this->reserved_template_varname = 'tpl';

        $this->assign('www_url', WWW_URL);

Modified src/include/lib/Garradin/Utils.php from [5778268a49] to [87835fc037].

456
457
458
459
460
461
462
463
464
465







466
467
468
469
470
471
472
        }
        else
        {
            return mail($to, $subject, $content, $headers);
        }
    }

    static public function clearCaches()
    {
        $path = DATA_ROOT . '/cache/compiled';







        $dir = dir($path);

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
            {
                unlink($path . '/' . $file);







|

|
>
>
>
>
>
>
>







456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
        }
        else
        {
            return mail($to, $subject, $content, $headers);
        }
    }

    static public function clearCaches($path = false)
    {
        if (!$path)
        {
            self::clearCaches('compiled');
            self::clearCaches('static');
            return true;
        }

        $path = CACHE_ROOT . '/' . $path;
        $dir = dir($path);

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
            {
                unlink($path . '/' . $file);

Modified src/www/admin/install.php from [a2dfc42c24] to [06c22a3a12].

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
);

const INSTALL_PROCESS = true;

require_once __DIR__ . '/../../include/init.php';

// Vérifier que les répertoires vides existent, sinon les créer
$paths = [DATA_ROOT . '/cache', DATA_ROOT . '/cache/static', DATA_ROOT . '/cache/compiled'];

foreach ($paths as $path)
{
    if (!file_exists($path))
        mkdir($path);

    test_requis(







|







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
);

const INSTALL_PROCESS = true;

require_once __DIR__ . '/../../include/init.php';

// Vérifier que les répertoires vides existent, sinon les créer
$paths = [CACHE_ROOT, CACHE_ROOT . '/static', CACHE_ROOT . '/compiled'];

foreach ($paths as $path)
{
    if (!file_exists($path))
        mkdir($path);

    test_requis(