Project

General

Profile

1
<?php
2

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

    
5
jimport('joomla.application.component.view');
6
jimport('joomla.environment.request');
7
jimport('joomla.log.log');
8

    
9
class OpenAireViewClaim3 extends JViewLegacy{
10
	const MODEL = 'claim';
11
	const REMOVE_PROJECT = 'removeProject';
12
	const REMOVE_CONCEPT = 'removeConcept';
13
	const REMOVE_PUBLICATION = 'removePublication';
14
	const OPEN = 'OPEN';
15
	const CLOSED = 'CLOSED';
16
	const EMBARGO = 'EMBARGO';
17
	const RESTRICTED = 'RESTRICTED';
18
	const DATACITE = 'datacite';
19
	const MAX_TITLE = 32;
20
	const OPENAIRE = 'openaire';
21
	const LOG = 'openaire';
22
	
23
	function display($template = NULL) {
24
		$this -> itemId = JRequest :: getUInt('Itemid', NULL);
25
		$application = JFactory :: getApplication();
26
 		$model = $this -> getModel(self :: MODEL);
27
		if (JFactory :: getUser() -> guest) {
28
			$application -> redirect(JRoute :: _('index.php?option=com_users&view=login&return=' . base64_encode(JRoute :: _('index.php?option=com_openaire&view=claim1&Itemid=' . $this -> itemId, FALSE)), FALSE));
29
			return TRUE;
30
		}
31
		switch (JRequest :: getString('action')) {
32
		case self :: REMOVE_PROJECT:
33
			$model -> removeSelectedProject(JRequest :: getString('projectId'));
34
			$application -> redirect(JRoute :: _('index.php?option=com_openaire&view=claim3'.(($this->itemId!==null)?'&Itemid=' . $this->itemId:''), FALSE));
35
			return TRUE;
36
		case self :: REMOVE_PUBLICATION:
37
			$model -> removeSelectedPublication(JRequest :: getString('source'), JRequest :: getString('publicationId'));
38
			$application -> redirect(JRoute :: _('index.php?option=com_openaire&view=claim3'.(($this->itemId!==null)?'&Itemid=' . $this->itemId:''), FALSE));
39
			return TRUE;
40
		}
41
		$this -> selectedProjects = $model -> getSelectedProjects();
42
		$this -> selectedConcepts = $model -> getSelectedConcepts();
43
		if ($this -> selectedProjects == NULL && $this -> selectedConcepts == NULL) {
44
			$application -> redirect(JRoute :: _('index.php?option=com_openaire&view=claim1'.(($this->itemId!==null)?'&Itemid=' . $this->itemId:''), FALSE));
45
			return TRUE;
46
		}
47
		$this -> selectedPublications = $model -> getSelectedPublications();
48
		if ($this -> selectedPublications == NULL) {
49
			$application -> redirect(JRoute :: _('index.php?option=com_openaire&view=claim2'.(($this->itemId!==null)?'&Itemid=' . $this->itemId:''), FALSE));
50
			return TRUE;
51
		}
52
		if (count($errors = $this -> get('Errors')) > 0) {
53
			JLog :: add('Error viewing claim3: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
54
			return FALSE;
55
		}
56
		parent :: display($template);
57
	}
58
}
59

    
(2-2/2)