Project

General

Profile

1
<?php
2

    
3
defined('_JEXEC') or die('Access denied');
4

    
5
jimport('joomla.log.log');
6

    
7
class com_openaireInstallerScript {
8
	private $parameters = array(
9
		'alertsAtomUrn' => 'urn:uuid:afdb7560-8ff4-4a6d-a9f1-6acb55269134',
10
		'alertsJdbcUri' => 'jdbc:mysql://localhost:3306/joomla-2.5.3?user=joomla&password=aighe6Ba',
11
		'alertsNewsCategory' => 8,
12
		'alertsNewsUser' => 42,
13
		'alertsPageSize' => 100,
14
		'alertsTwitterAccessToken' => '292267214-mvvJnhkzBtZ4xWv3DTCiAAO1ZRKf3TkULWG2hUMN',
15
		'alertsTwitterAccessTokenSecret' => 'qqojkHjZInqOX1ZMUYPn2owEONj4qptNjOywSLha4k',
16
		'invenioPassword' => 'password',
17
		'invenioUrl' => 'https://openaire.cern.ch/',
18
		'searchServiceUrl' => 'http://beta.services.openaire.eu:8480/search/',
19
		'statisticsDocumentChartUrl' => 'http://www.openaire.eu:18080/stats/pubchart?pubdrid=',
20
		'statisticsDocumentExistUrl' => 'http://www.openaire.eu:18080/stats/exist?pubdrid=',
21
		'statisticsRepositoryChartUrl' => 'http://www.openaire.eu:18080/stats/repchart?replink=',
22
		'statisticsRepositoryChartUrl' => 'http://www.openaire.eu:18080/stats/repchart?replink=',
23
		'statisticsProjectChartUrl' => 'http://dl114.madgik.di.uoa.gr/stats/',
24
		'statisticsRepositoryExistUrl' => 'http://www.openaire.eu:18080/stats/exist?replink=',
25
		'thriftHost' => 'rudie.di.uoa.gr',
26
		'thriftPort' => 7911,
27
		'thriftTimeout' => 1500,
28
		'validatorPassword' => 'password',
29
		'validatorUrl' => 'http://test.openaire.eu:8380/dnet-validator-openaire/portalLogin.action',
30
		'validatorPassword' => '568345',
31
		'piwikUrl' => 'http://vatopedi.di.uoa.gr/piwik/',
32
		'piwikSiteId' => 1,
33
                'addThisPubId' => 'ra-55a0e50aaa63d56f',
34
                'addThisUrl' => '//s7.addthis.com/js/300/addthis_widget.js#pubid='
35
            
36
	);
37
	
38
	public function postflight($type, $parent) {
39
		if ($type != 'install')
40
			return;
41
		JLog :: addLogger(array('text_file' => 'openaire.log'), JLog :: ALL, array('openaire'));
42
		try {
43
			$db = JFactory :: getDBO();
44
			$query = $db -> getQuery(TRUE);
45
			$query -> update('#__extensions');
46
			$query -> set('params = \'' . json_encode($this -> parameters) . '\'');
47
			$query -> where('name = \'openaire\'');
48
			$db -> setQuery($query);
49
			if ($db -> query() === FALSE)
50
				throw new Exception($db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')');
51
			$this -> populateAlertModes($db);
52
			$this -> populateTopics($db);
53
			JLog :: add('OpenAIRE installation completed successfully', JLog :: INFO, 'openaire');
54
		} catch (Exception $e) {
55
			JLog :: add('Error installing OpenAIRE: ' . $e -> getMessage(), JLog :: ERROR, 'openaire');
56
		}
57
	}
58
	
59
	private function populateAlertModes($db) {
60
		$db -> setQuery('DROP TABLE IF EXISTS `#__openaire_alert_modes`;');
61
		if ($db -> query() === FALSE)
62
			throw new Exception('Error populating alert modes: ' . $db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')');
63
		$db -> setQuery('CREATE TABLE `#__openaire_alert_modes` (`id` VARCHAR (16) NOT NULL PRIMARY KEY, `name` VARCHAR (32) NOT NULL, `description` TEXT NOT NULL, `batch` BOOLEAN NOT NULL, `adminOnly` BOOLEAN NOT NULL);');
64
		if ($db -> query() === FALSE)
65
			throw new Exception('Error populating alert modes: ' . $db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')');
66
		$db -> setQuery('INSERT INTO `#__openaire_alert_modes` (`id`, `name`, `description`, `batch`, `adminOnly`) VALUES (\'Atom\', \'Atom Feed (RSS)\', \'Post alert in OpenAIRE Atom feed.\', FALSE, TRUE), (\'JDBC\', \'OpenAIRE Portal - My Alerts\', \'Post alert in My Alerts.\', FALSE, FALSE), (\'Joomla!\', \'OpenAIRE News\', \'Post alert in OpenAIRE News.\', FALSE, TRUE), (\'SMTP\', \'Email\', \'Send alert by email.\', TRUE, FALSE), (\'twitter\', \'twitter\', \'Post alert to OpenAIRE twitter account.\', FALSE, TRUE);');	
67
		if ($db -> query() === FALSE)
68
			throw new Exception('Error populating alert modes: ' . $db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')');
69
	}
70
	
71
	private function populateTopics($db) {
72
		$db -> setQuery('DROP TABLE IF EXISTS `#__openaire_topic_hierarchy`;');
73
		if ($db -> query() === FALSE)
74
			throw new Exception('Error populating topics: ' . $db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')');
75
		$db -> setQuery('CREATE TABLE `#__openaire_topic_hierarchy` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `parent` INT, `name` TEXT NOT NULL, `description` TEXT NOT NULL, `templateId` VARCHAR (36), `notificationService` VARCHAR (255), `queryId` VARCHAR (36), `resultId` VARCHAR (36), FOREIGN KEY (`parent`) REFERENCES `#__openaire_topic_hierarchy` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);');
76
		if ($db -> query() === FALSE)
77
			throw new Exception('Error populating topics: ' . $db -> getErrorMsg() . ' (' . $db -> getErrorNum() . ')');
78
	}
79

    
80
	/*
81
	DROP TABLE IF EXISTS `#__openaire_alerts`;
82
	CREATE TABLE `#__openaire_alerts` (`username` VARCHAR (150) NOT NULL, `time` TIMESTAMP NOT NULL, `title` VARCHAR (255) NOT NULL, `message` TEXT NOT NULL, `link` TEXT, PRIMARY KEY (`username`, `time`, `title`));
83
	*/	
84
}
85

    
(1-1/2)