1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8class Tiki_Profile_InstallHandler_Perspective extends Tiki_Profile_InstallHandler
9{
10	function getData()
11	{
12		if ($this->data) {
13			return $this->data;
14		}
15
16		$defaults = [
17			'preferences' => [],
18		];
19
20		$data = array_merge($defaults, $this->obj->getData());
21
22		$data['preferences'] = Tiki_Profile::convertLists($data['preferences'], ['enable' => 'y', 'disable' => 'n']);
23
24		$data['preferences'] = Tiki_Profile::convertYesNo($data['preferences']);
25
26		return $this->data = $data;
27	}
28
29	function canInstall()
30	{
31		$data = $this->getData();
32		if (! isset($data['name'])) {
33			return false;
34		}
35
36		return true;
37	}
38
39	function _install()
40	{
41		$perspectivelib = TikiLib::lib('perspective');
42
43		$data = $this->getData();
44
45		$this->replaceReferences($data);
46
47		if ($persp = $perspectivelib->replace_perspective(0, $data['name'])) {
48			$perspectivelib->replace_preferences($persp, $data['preferences']);
49		}
50
51		return $persp;
52	}
53}
54