Overview
Comment:Début d'intégration des plugins
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d239c2525ecda70ae75a5109be58e0f1674b27c8
User & Date: bohwaz on 2014-03-20 18:30:54
Other Links: manifest | tags
Context
2014-03-20
19:39
Suppression de plugin + vérifications check-in: 1cb7db96ca user: bohwaz tags: trunk
18:30
Début d'intégration des plugins check-in: d239c2525e user: bohwaz tags: trunk
18:29
Petit outil rapide pour packager une extension check-in: d59b16e23e user: bohwaz tags: trunk
Changes

Modified src/.htaccess from [c2c5e60ea8] to [a73862be8a].

1
2
3
4
5
6
7
<IfModule mod_alias.c>
    RedirectMatch 403 /include
    RedirectMatch 403 /cache
    RedirectMatch 403 /plugins
    RedirectMatch 403 /templates
    RedirectMatch 403 /*.sqlite
</IfModule>

|
|
|
|


1
2
3
4
5
6
7
<IfModule mod_alias.c>
    RedirectMatch 403 /include/
    RedirectMatch 403 /cache/
    RedirectMatch 403 /plugins/
    RedirectMatch 403 /templates/
    RedirectMatch 403 /*.sqlite
</IfModule>

Modified src/include/class.plugin.php from [fc8588c2e1] to [b491bcdea6].

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
53
54
55
56
57















































58
59























60
61
62
63
64
65
66






67
68
69
70
71
72
73
<?php

namespace Garradin;

class Plugin
{
	protected $id = null;
	protected $config = null;

	public function __construct($id)
	{
		$this->id = null;

	}




	public function getConfig($key = null)

	{
		if (is_null($this->config))
		{
			$db = DB::getInstance();
			$this->config = $db->simpleQuerySingle('SELECT config FROM plugins WHERE id = ?;', false, $this->id);
			$this->config = json_decode($this->config, true);

			if (!is_array($this->config))
			{
				$this->config = [];
			}
		}







		if (array_key_exists($key, $this->config))
		{
			return $this->config[$key];
		}

		return null;
	}

	public function setConfig($key, $value = null)
	{
		$this->getConfig();

		if (is_null($value))
		{
			unset($this->config[$key]);
		}
		else
		{
			$this->config[$key] = $value;
		}

		$db = DB::getInstance();
		$db->simpleUpdate('plugins', 'id = \'' . $this->id . '\'', ['config' => json_encode($this->config)]);



		return true;
	}

	public function getInfos()
	{















































		$db = DB::getInstance();
		return $db->simpleStatementFetch('SELECT * FROM plugins WHERE id = ?;', $this->id);























	}

	static public function listInstalled()
	{
		$db = DB::getInstance();
		return $db->simpleStatementFetchAssocKey('SELECT id, * FROM plugins ORDER BY nom;');
	}







	static public function listDownloaded()
	{
		$installed = self::listInstalled();

		$list = [];
		$dir = dir(PLUGINS_PATH);







|



|
>
|
>
|
>
>
|
>
|
|

<
<
|
|
<
|
|
|
|
>
|
>
>
>
>
>
|

|







<
<


|



|



|
>
>




|

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

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







>
>
>
>
>
>







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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php

namespace Garradin;

class Plugin
{
	protected $id = null;
	protected $plugin = null;

	public function __construct($id)
	{
		$db = DB::getInstance();
		$this->plugin = $db->simpleQuerySingle('SELECT * FROM plugins WHERE id = ?;', true, $id);

		if (!$this->plugin)
		{
			throw new UserException('Ce plugin n\'existe pas ou n\'est pas installé correctement.');
		}

		$this->plugin['config'] = json_decode($this->plugin['config'], true);
		
		if (!is_array($this->plugin['config']))
		{


			$this->plugin['config'] = [];
		}


		$this->id = $id;
	}

	public function getConfig($key = null)
	{
		if (is_null($key))
		{
			return $this->plugin['config'];
		}

		if (array_key_exists($key, $this->plugin['config']))
		{
			return $this->plugin['config'][$key];
		}

		return null;
	}

	public function setConfig($key, $value = null)
	{


		if (is_null($value))
		{
			unset($this->plugin['config'][$key]);
		}
		else
		{
			$this->plugin['config'][$key] = $value;
		}

		$db = DB::getInstance();
		$db->simpleUpdate('plugins', 
			['config' => json_encode($this->plugin['config'])],
			'id = \'' . $this->id . '\'');

		return true;
	}

	public function getInfos($key = null)
	{
		if (is_null($key))
		{
			return $this->plugin;
		}

		if (array_key_exists($key, $this->plugin))
		{
			return $this->plugin[$key];
		}

		return null;
	}

	public function id()
	{
		return $this->id;
	}

	public function call($file)
	{
		$forbidden = ['install.php', 'infos.ini', 'upgrade.php', 'uninstall.php', 'signals.php'];

		if (in_array($file, $forbidden))
		{
			throw new UserException('Le fichier ' . $file . ' ne peut être appelé par cette méthode.');
		}

		if (!file_exists('phar://' . PLUGINS_PATH . '/' . $this->id . '.phar/' . $file))
		{
			throw new UserException('Le fichier ' . $file . ' n\'existe pas dans le plugin ' . $this->id);
		}

		$plugin = $this;
		global $tpl, $config, $user, $membres;

		include 'phar://' . PLUGINS_PATH . '/' . $this->id . '.phar/' . $file;
	}

	public function uninstall()
	{
		if (file_exists('phar://' . PLUGINS_PATH . '/' . $this->id . '.phar/uninstall.php'))
		{
			include 'phar://' . PLUGINS_PATH . '/' . $this->id . '.phar/uninstall.php';
		}
		
		unlink(PLUGINS_PATH . '/' . $this->id . '.phar');

		$db = DB::getInstance();
		return $db->simpleExec('DELETE FROM plugins WHERE id = ?;', $this->id);
	}

	public function needUpgrade()
	{
		$infos = parse_ini_file('phar://' . PLUGINS_PATH . '/' . $this->id . '.phar/infos.ini', false);
		
		if (version_compare($this->plugin['version'], $infos['version'], '!='))
			return true;

		return false;
	}

	public function upgrade()
	{
		if (file_exists('phar://' . PLUGINS_PATH . '/' . $this->id . '.phar/upgrade.php'))
		{
			include 'phar://' . PLUGINS_PATH . '/' . $this->id . '.phar/upgrade.php';
		}

		$db = DB::getInstance();
		return $db->simpleUpdate('plugins', 
			'id = \''.$db->escapeString($this->id).'\'', 
			['version' => $infos['version']]);
	}

	static public function listInstalled()
	{
		$db = DB::getInstance();
		return $db->simpleStatementFetchAssocKey('SELECT id, * FROM plugins ORDER BY nom;');
	}

	static public function listMenu()
	{
		$db = DB::getInstance();
		return $db->simpleStatementFetchAssoc('SELECT id, nom FROM plugins WHERE menu = 1 ORDER BY nom;');
	}

	static public function listDownloaded()
	{
		$installed = self::listInstalled();

		$list = [];
		$dir = dir(PLUGINS_PATH);
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
			$context = stream_context_create($context_options);

			try {
				$result = file_get_contents(PLUGINS_URL, NULL, $context);
			}
			catch (\Exception $e)
			{
				throw new UserException('Le téléchargement de la liste des plugins a échoué : ' . $e->getMessage())
			}

			Static_Cache::store('plugins_list', $result);
		}
		else
		{
			$result = Static_Cache::get('plugins_list');







|







193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
			$context = stream_context_create($context_options);

			try {
				$result = file_get_contents(PLUGINS_URL, NULL, $context);
			}
			catch (\Exception $e)
			{
				throw new UserException('Le téléchargement de la liste des plugins a échoué : ' . $e->getMessage());
			}

			Static_Cache::store('plugins_list', $result);
		}
		else
		{
			$result = Static_Cache::get('plugins_list');
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195





196
197
198
199
200
201
202



203


204
205
206















207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
		$context = stream_context_create($context_options);

		try {
			copy($list[$id]['phar'], PLUGINS_PATH . '/' . $id . '.phar', $context);
		}
		catch (\Exception $e)
		{
			throw new \RuntimeException('Le téléchargement du plugin '.$id.' a échoué : ' . $e->getMessage())
		}

		if (!self::checkHash($id))
		{
			unlink(PLUGINS_PATH . '/' . $id . '.phar');
			throw new \RuntimeException('L\'archive du plugin '.$id.' est corrompue (le hash SHA1 ne correspond pas).');
		}

		self::install($id, true);

		return true;
	}

	static public function install($id, $official = true)
	{





		if ($official && !self::checkHash($id))
		{
			throw new \RuntimeException('L\'archive du plugin '.$id.' est corrompue (le hash SHA1 ne correspond pas).');
		}

		if (file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/install.php'))
		{



			include 'phar://' . PLUGINS_PATH . '/' . $id . '.phar/install.php';


		}

		$infos = parse_ini_file('phar://' . PLUGINS_PATH . '/' . $id . '.phar/infos.ini', false);
















		$db = DB::getInstance();
		$db->simpleInsert('plugins', [
			'id' 		=> 	$id,
			'officiel' 	=> 	(int)(bool)$official,
			'nom'		=>	$infos['nom'],
			'description'=>	$infos['description'],
			'auteur'	=>	$infos['auteur'],
			'url'		=>	$infos['url'],
			'version'	=>	$infos['version'],
			'menu'		=>	(int)(bool)$infos['menu'],
			'config'	=>	'',
		]);
	}
	
	static public function uninstall($id)
	{
		if (file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/uninstall.php'))
		{
			include 'phar://' . PLUGINS_PATH . '/' . $id . '.phar/uninstall.php';
		}
		
		$db = DB::getInstance();
		return $db->simpleExec('DELETE FROM plugins WHERE id = ?;', $id);
	}

	static public function needUpgrade($id)
	{
		$infos = parse_ini_file('phar://' . PLUGINS_PATH . '/' . $id . '.phar/infos.ini', false);
		$version = $db->simpleQuerySingle('SELECT version FROM plugins WHERE id = ?;', false, $id);

		if (version_compare($version, $infos['version'], '!='))
			return true;

		return false;
	}

	static public function upgrade($id)
	{
		if (file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/upgrade.php'))
		{
			include 'phar://' . PLUGINS_PATH . '/' . $id . '.phar/upgrade.php';
		}

		$db = DB::getInstance();
		return $db->simpleUpdate('plugins', 'id = \''.$db->escapeString($id).'\'', ['version' => $infos['version']]);
	}
}







|















>
>
>
>
>





|

>
>
>
|
>
>



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











|

|
<
<
<
|

|

|
<
<
<
<
<
<
<
<
<
<
|
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329



330
331
332
333
334










335
336

337












		$context = stream_context_create($context_options);

		try {
			copy($list[$id]['phar'], PLUGINS_PATH . '/' . $id . '.phar', $context);
		}
		catch (\Exception $e)
		{
			throw new \RuntimeException('Le téléchargement du plugin '.$id.' a échoué : ' . $e->getMessage());
		}

		if (!self::checkHash($id))
		{
			unlink(PLUGINS_PATH . '/' . $id . '.phar');
			throw new \RuntimeException('L\'archive du plugin '.$id.' est corrompue (le hash SHA1 ne correspond pas).');
		}

		self::install($id, true);

		return true;
	}

	static public function install($id, $official = true)
	{
		if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar'))
		{
			throw new \RuntimeException('Le plugin ' . $id . ' ne semble pas exister et ne peut donc être installé.');
		}

		if ($official && !self::checkHash($id))
		{
			throw new \RuntimeException('L\'archive du plugin '.$id.' est corrompue (le hash SHA1 ne correspond pas).');
		}

		if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/infos.ini'))
		{
			throw new \RuntimeException('L\'archive '.$id.'.phar ne comporte pas de fichier infos.ini : est-ce un plugin Garradin ?');
		}

		if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/index.php'))
		{
			throw new \RuntimeException('L\'archive '.$id.'.phar ne comporte pas de fichier index.php : est-ce un plugin Garradin ?');
		}

		$infos = parse_ini_file('phar://' . PLUGINS_PATH . '/' . $id . '.phar/infos.ini', false);

		if ((bool)$infos['config'])
		{
			if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/config.json'))
			{
				throw new \RuntimeException('L\'archive '.$id.'.phar ne comporte pas de fichier config.json 
					alors que le plugin nécessite le stockage d\'une configuration.');
			}

			if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/config.php'))
			{
				throw new \RuntimeException('L\'archive '.$id.'.phar ne comporte pas de fichier config.php 
					alors que le plugin nécessite le stockage d\'une configuration.');
			}
		}

		$db = DB::getInstance();
		$db->simpleInsert('plugins', [
			'id' 		=> 	$id,
			'officiel' 	=> 	(int)(bool)$official,
			'nom'		=>	$infos['nom'],
			'description'=>	$infos['description'],
			'auteur'	=>	$infos['auteur'],
			'url'		=>	$infos['url'],
			'version'	=>	$infos['version'],
			'menu'		=>	(int)(bool)$infos['menu'],
			'config'	=>	$config,
		]);




		if (file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/install.php'))
		{
			include 'phar://' . PLUGINS_PATH . '/' . $id . '.phar/install.php';
		}











		return true;
	}

}












Modified src/include/data/0.6.0.sql from [911a09f791] to [4df7c58a86].

53
54
55
56
57
58
59














60
61
62
63
64
65
66
    id INTEGER NOT NULL PRIMARY KEY,

    id_membre INTEGER NOT NULL REFERENCES membres (id),
    id_rappel INTEGER NULL REFERENCES rappels (id),
    date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    media INTEGER NOT NULL -- Média utilisé pour le rappel : 1 = email, 2 = courrier, 3 = autre
);















-- Mise à jour des catégories

CREATE TABLE membres_categories_tmp
-- Catégories de membres
(
    id INTEGER PRIMARY KEY,







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







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
    id INTEGER NOT NULL PRIMARY KEY,

    id_membre INTEGER NOT NULL REFERENCES membres (id),
    id_rappel INTEGER NULL REFERENCES rappels (id),
    date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    media INTEGER NOT NULL -- Média utilisé pour le rappel : 1 = email, 2 = courrier, 3 = autre
);

CREATE TABLE plugins
-- Plugins / extensions
(
    id TEXT PRIMARY KEY,
    officiel INTEGER NOT NULL DEFAULT 0,
    nom TEXT NOT NULL,
    description TEXT,
    auteur TEXT,
    url TEXT,
    version TEXT NOT NULL,
    menu INTEGER NOT NULL DEFAULT 0,
    config TEXT
);

-- Mise à jour des catégories

CREATE TABLE membres_categories_tmp
-- Catégories de membres
(
    id INTEGER PRIMARY KEY,

Modified src/include/lib.utils.php from [180cd8e498] to [e9a05b7ff3].

563
564
565
566
567
568
569
570

571


572

























        {
            case 'G': case 'g': return (int)$size_str * pow(1024, 3);
            case 'M': case 'm': return (int)$size_str * pow(1024, 2);
            case 'K': case 'k': return (int)$size_str * 1024;
            default: return $size_str;
        }
    }
}




?>
































|
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
        {
            case 'G': case 'g': return (int)$size_str * pow(1024, 3);
            case 'M': case 'm': return (int)$size_str * pow(1024, 2);
            case 'K': case 'k': return (int)$size_str * 1024;
            default: return $size_str;
        }
    }

    static public function deleteRecursive($path, $delete_target = false)
    {
        if (!file_exists($path))
            return false;

        $dir = dir($path);
        if (!$dir) return false;

        while ($file = $dir->read())
        {
            if ($file == '.' || $file == '..')
                continue;

            if (is_dir($path . '/' . $file))
            {
                if (!self::deleteRecursive($path . '/' . $file, true))
                    return false;
            }
            else
            {
                unlink($path . '/' . $file);
            }
        }

        $dir->close();
        rmdir($path);

        return true;
    }
}

Modified src/templates/admin/_head.tpl from [632fab4ba7] to [5c08b599fa].

70
71
72
73
74
75
76









77
78
79
80
81
82
83
                {*<li class="wiki follow{if $current == 'wiki/suivi'} current{/if}"><a href="{$admin_url}wiki/suivi.php">Mes pages suivies</a>*}
                {*<li class="wiki follow{if $current == 'wiki/contribution'} current{/if}"><a href="{$admin_url}wiki/contributions.php">Mes contributions</a>*}
            </ul>
            </li>
        {/if}
        {if $user.droits.config >= Garradin\Membres::DROIT_ADMIN}
            <li class="main config{if $current == 'config'} current{/if}"><a href="{$admin_url}config/">Configuration</a>









        {/if}
        <li class="my config{if $current == 'mes_infos'} current{/if}"><a href="{$admin_url}mes_infos.php">Mes infos personnelles</a>
            <ul>
                <li class="my cotisations{if $current == 'mes_cotisations'} current{/if}"><a href="{$admin_url}mes_cotisations.php">Mes cotisations</a></li>
            </ul>
        </li>
        {if !defined('Garradin\LOCAL_LOGIN')}







>
>
>
>
>
>
>
>
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
                {*<li class="wiki follow{if $current == 'wiki/suivi'} current{/if}"><a href="{$admin_url}wiki/suivi.php">Mes pages suivies</a>*}
                {*<li class="wiki follow{if $current == 'wiki/contribution'} current{/if}"><a href="{$admin_url}wiki/contributions.php">Mes contributions</a>*}
            </ul>
            </li>
        {/if}
        {if $user.droits.config >= Garradin\Membres::DROIT_ADMIN}
            <li class="main config{if $current == 'config'} current{/if}"><a href="{$admin_url}config/">Configuration</a>
        {/if}
        {if !empty($plugins_menu)}
            <li class="plugins">
                <ul>
                {foreach from=$plugins_menu key="id" item="name"}
                    <li class="plugins {$id|escape}{if $current == 'plugin_`$id`'} current{/if}"><a href="{$admin_url}plugin.php?id={$id|escape}">{$name|escape}</a></li>
                {/foreach}
                </ul>
            </li>
        {/if}
        <li class="my config{if $current == 'mes_infos'} current{/if}"><a href="{$admin_url}mes_infos.php">Mes infos personnelles</a>
            <ul>
                <li class="my cotisations{if $current == 'mes_cotisations'} current{/if}"><a href="{$admin_url}mes_cotisations.php">Mes cotisations</a></li>
            </ul>
        </li>
        {if !defined('Garradin\LOCAL_LOGIN')}

Modified src/templates/admin/config/_menu.tpl from [52ebd9d657] to [bf691bf8f5].

1
2
3
4
5
6

7
<ul class="actions">
    <li{if $current == 'index'} class="current"{/if}><a href="{$www_url}admin/config/">Général</a></li>
    <li{if $current == 'membres'} class="current"{/if}><a href="{$www_url}admin/config/membres.php">Fiche des membres</a></li>
    <li{if $current == 'site'} class="current"{/if}><a href="{$www_url}admin/config/site.php">Site public</a></li>
    <li{if $current == 'donnees'} class="current"{/if}><a href="{$www_url}admin/config/donnees.php">Données&nbsp;: sauvegarde et restauration</a></li>
    <li{if $current == 'import'} class="current"{/if}><a href="{$www_url}admin/config/import.php">Import &amp; export</a></li>

</ul>






>

1
2
3
4
5
6
7
8
<ul class="actions">
    <li{if $current == 'index'} class="current"{/if}><a href="{$www_url}admin/config/">Général</a></li>
    <li{if $current == 'membres'} class="current"{/if}><a href="{$www_url}admin/config/membres.php">Fiche des membres</a></li>
    <li{if $current == 'site'} class="current"{/if}><a href="{$www_url}admin/config/site.php">Site public</a></li>
    <li{if $current == 'donnees'} class="current"{/if}><a href="{$www_url}admin/config/donnees.php">Données&nbsp;: sauvegarde et restauration</a></li>
    <li{if $current == 'import'} class="current"{/if}><a href="{$www_url}admin/config/import.php">Import &amp; export</a></li>
    <li{if $current == 'plugins'} class="current"{/if}><a href="{$www_url}admin/config/plugins.php">Extensions</a></li>
</ul>

Modified src/templates/admin/config/index.tpl from [ebebaaf514] to [f1469a8682].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Garradin</legend>
        <dl>
            <dt>Version installée</dt>
            <dd class="help">{$garradin_version|escape} <a href="http://dev.kd2.org/garradin/">[Vérifier la disponibilité d'une nouvelle version]</a></dd>
            <dt>Informations système</dt>
            <dd class="help">PHP version {$php_version|escape} — SQLite version {$sqlite_version|escape}</dd>
        </dl>
    </fieldset>

    <fieldset>
        <legend>Informations sur l'association</legend>







|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Garradin</legend>
        <dl>
            <dt>Version installée</dt>
            <dd class="help">{$garradin_version|escape} <a href="{Garradin\WEBSITE}">[Vérifier la disponibilité d'une nouvelle version]</a></dd>
            <dt>Informations système</dt>
            <dd class="help">PHP version {$php_version|escape} — SQLite version {$sqlite_version|escape}</dd>
        </dl>
    </fieldset>

    <fieldset>
        <legend>Informations sur l'association</legend>

Added src/templates/admin/config/plugins.tpl version [0d772933a3].







































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{include file="admin/_head.tpl" title="Extensions" current="config"}

{include file="admin/config/_menu.tpl" current="plugins"}

{if $error}
    <p class="error">
        {$error|escape}
    </p>
{/if}

{if !empty($liste_installes)}
    <table class="list">
        <thead>
            <tr>
                <th>Extension</th>
                <td>Auteur</td>
                <td>Version installée</td>
                <td></td>
            </tr>
        </thead>
        <tbody>
            {foreach from=$liste_installes item="plugin"}
            <tr>
                <th>
                    <h4>{$plugin.nom|escape}</h4>
                    <small>{$plugin.description|escape}</small>
                </th>
                <td>
                    <a href="{$plugin.url|escape}" onclick="return !window.open(this.href);">{$plugin.auteur|escape}</a>
                </td>
                <td>
                    {$plugin.version|escape}
                </td>
                <td class="actions">
                    <a href="{$admin_url}config/plugins.php?delete={$plugin.id|escape}">Désinstaller</a>
                    {if !empty($plugin.config)}
                        | <a href="{$admin_url}plugin.php?id={$plugin.id|escape}&amp;page=config.php">Configurer</a>
                    {/if}
                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
{else}
    <p class="help">
        Aucune extension n'est installée.
        Vous pouvez consulter <a href="{Garradin\WEBSITE}">le site de Garradin</a> pour obtenir
        des extensions à télécharger.
    </p>
{/if}

{if !empty($liste_telecharges)}
<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Extensions téléchargées</legend>
        <dl>
            {foreach from=$liste_telecharges item="plugin" key="id"}
            <dt>
                <label>
                    <input type="radio" name="to_install" value="{$id|escape}" />
                    {$plugin.nom|escape}
                </label>
                (version {$plugin.version|escape})
            </dt>
            <dd>[<a href="{$plugin.url|escape}" onclick="return !window.open(this.href);">{$plugin.auteur|escape}</a>] {$plugin.description|escape}</dd>
            {/foreach}
        </dl>
    </fieldset>

    <p class="help">
        Attention : installer une extension non officielle peut présenter des risques de sécurité
        et de stabilité.
    </p>

    <p class="submit">
        {csrf_field key="install"}
        <input type="submit" name="install" value="Installer &rarr;" />
    </p>
</form>
{/if}

{include file="admin/_foot.tpl"}

Modified src/www/admin/_inc.php from [50cf88ffa0] to [c0e06fcc72].

23
24
25
26
27
28
29


30
31
32

    $tpl->assign('current', '');

    if ($user['droits']['membres'] >= Membres::DROIT_ACCES)
    {
        $tpl->assign('nb_membres', $membres->countAllButHidden());
    }


}

?>







>
>



23
24
25
26
27
28
29
30
31
32
33
34

    $tpl->assign('current', '');

    if ($user['droits']['membres'] >= Membres::DROIT_ACCES)
    {
        $tpl->assign('nb_membres', $membres->countAllButHidden());
    }

    $tpl->assign('plugins_menu', Plugin::listMenu());
}

?>

Added src/www/admin/config/plugins.php version [7c4827277c].









































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<?php

namespace Garradin;

require_once __DIR__ . '/_inc.php';

$error = false;

if (!empty($_POST['install']))
{
    if (!utils::CSRF_check('install'))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try {
            Plugin::install(utils::post('to_install'), false);
            
            utils::redirect('/admin/config/plugins.php');
        }
        catch (\Exception $e)
        {
            $error = $e->getMessage();
        }
    }
}

$tpl->assign('error', $error);

$tpl->assign('liste_telecharges', Plugin::listDownloaded());
$tpl->assign('liste_installes', Plugin::listInstalled());

$tpl->display('admin/config/plugins.tpl');

?>

Added src/www/admin/plugin.php version [c92532ef54].































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

namespace Garradin;

require_once __DIR__ . '/_inc.php';

$page = utils::get('page') ?: 'index.php';

$plugin = new Plugin(utils::get('id'));

$tpl->assign('plugin', $plugin->getInfos());

$plugin->call($page);

?>