Blame view

php/classes/AmdaAction.php 44 KB
16035364   Benjamin Renard   First commit
1
2
3
<?php
/**
 * @class AmdaAction
aa94fd24   elena   Merge with last svn
4
 * @version $Id: AmdaAction.php 2976 2015-07-01 15:05:40Z benjamin $
9e3cbd95   Elena.Budnik   merge AMDA_IHM AM...
5
 * @brief
16035364   Benjamin Renard   First commit
6
 */
10200969   Roipoussiere   Remove whitespace...
7
class AmdaAction
735c653b   Elena.Budnik   rank at observato...
8
{
10200969   Roipoussiere   Remove whitespace...
9
	private $xmlFiles  = array('localParam' => 'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml',
735c653b   Elena.Budnik   rank at observato...
10
										'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml',
10200969   Roipoussiere   Remove whitespace...
11
12
										'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',
										'myData' => 'Files.xml',
735c653b   Elena.Budnik   rank at observato...
13
14
15
16
17
										'request' => 'Request.xml', 'condition' => 'Request.xml',
										'bkgWorks' => 'jobs.xml');

	private $user, $amdaStat;

10200969   Roipoussiere   Remove whitespace...
18
19
	public function __construct()
	{
735c653b   Elena.Budnik   rank at observato...
20
21
22
23
24
		$dd = new UserMgr();
		$this->user = $dd->user;
		if (!defined('NEWKERNEL_DEBUG') || !NEWKERNEL_DEBUG)
					$this->amdaStat = new AmdaStats($dd->user);
	}
16035364   Benjamin Renard   First commit
25

10200969   Roipoussiere   Remove whitespace...
26
	private function getUrlDirs($url)
735c653b   Elena.Budnik   rank at observato...
27
28
29
	{
		//TODO replace by ftp php class methods: ftp_nlist() etc
		require_once "simple_html_dom.php";
10200969   Roipoussiere   Remove whitespace...
30
31

		$url = html_entity_decode($url);
735c653b   Elena.Budnik   rank at observato...
32
		$trimmed_url = trim($url);
10200969   Roipoussiere   Remove whitespace...
33
		if (strrpos($trimmed_url, "/") == strlen($trimmed_url) - 1)
735c653b   Elena.Budnik   rank at observato...
34
		{
10200969   Roipoussiere   Remove whitespace...
35
			if (file_exists("temp.html")) unlink("temp.html");
735c653b   Elena.Budnik   rank at observato...
36
			exec("wget -O temp.html ".$url);
10200969   Roipoussiere   Remove whitespace...
37

735c653b   Elena.Budnik   rank at observato...
38
39
			$html = file_get_html('temp.html');
			$dirs = $html->find('a[href]');
10200969   Roipoussiere   Remove whitespace...
40
			foreach ($dirs as $dir)
735c653b   Elena.Budnik   rank at observato...
41
			{
6acb8d2a   Elena.Budnik   checkRequest in R...
42
43
				$name =  $dir->innertext; //$dir->href;
				$isLeaf = strrpos($name, "/") !== strlen($name) - 1;
10200969   Roipoussiere   Remove whitespace...
44
				$childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name, 'nodeType' => 'url', 'leaf' => $isLeaf);
735c653b   Elena.Budnik   rank at observato...
45
			}
10200969   Roipoussiere   Remove whitespace...
46

735c653b   Elena.Budnik   rank at observato...
47
		}
10200969   Roipoussiere   Remove whitespace...
48
49
50

		return $childrenToReturn;

735c653b   Elena.Budnik   rank at observato...
51
	}
10200969   Roipoussiere   Remove whitespace...
52

16035364   Benjamin Renard   First commit
53
54
/*****************************************************************
*                           PUBLIC FUNCTIONS
10200969   Roipoussiere   Remove whitespace...
55
56
*****************************************************************/

735c653b   Elena.Budnik   rank at observato...
57
58
59
60
	/*
	*   $obj = { id: node.id,  nodeType: node.nodeType }
	*/
	public function getTree($obj) {
735c653b   Elena.Budnik   rank at observato...
61
		$node = $obj->node;
10200969   Roipoussiere   Remove whitespace...
62

735c653b   Elena.Budnik   rank at observato...
63
		$nodeType = $obj->nodeType;
0fea5567   Benjamin Renard   First step for re...
64

735c653b   Elena.Budnik   rank at observato...
65
66
		$remoteBase = false;
		$isRemoteDataSet = false;
16035364   Benjamin Renard   First commit
67

10200969   Roipoussiere   Remove whitespace...
68
		if ($nodeType == 'url')
735c653b   Elena.Budnik   rank at observato...
69
		{
10200969   Roipoussiere   Remove whitespace...
70
			$url = $node == 'root' ? $obj->baseId : $node;
735c653b   Elena.Budnik   rank at observato...
71
72
			return  $this->getUrlDirs($url);
		}
16035364   Benjamin Renard   First commit
73

e57cb025   Benjamin Renard   Fix most of error...
74
		if (isset($obj->baseId)) $remoteBase = true;
16035364   Benjamin Renard   First commit
75

735c653b   Elena.Budnik   rank at observato...
76
		if ($node == 'root' && $remoteBase)  $node = $obj->baseId;
16035364   Benjamin Renard   First commit
77

10200969   Roipoussiere   Remove whitespace...
78
79
		if ($node == 'root' && !$remoteBase)
		{
e57cb025   Benjamin Renard   Fix most of error...
80
81
82
83
84
85
86
87
88
89
90
91
			if (file_exists(DATAPATH.$nodeType.'.json')) {
				$json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
				if (empty($json_o)) {
					$childrenToReturn = array();
				}
				else {
					$childrenToReturn = $json_o->nodes;
				}
			}
			else {
				$childrenToReturn = array();
			}
10200969   Roipoussiere   Remove whitespace...
92
93
		}
		else
735c653b   Elena.Budnik   rank at observato...
94
95
96
		{
			$Dom = new DomDocument("1.0");

10200969   Roipoussiere   Remove whitespace...
97
			switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
98
99
100
101
102
			{
				case 'sharedtimeTable':
				case 'sharedcatalog':
					$xmlName = SHAREDPATH.'/SharedObjectTree.xml';
					break;
10200969   Roipoussiere   Remove whitespace...
103
				case 'bkgWorks':
84db3b67   Nathanael Jourdane   Improve job toolt...
104
					// data/<user>/JOBS/jobs.xml
735c653b   Elena.Budnik   rank at observato...
105
106
107
					$xmlName = USERJOBDIR.$this->xmlFiles[$nodeType];
					break;
				case 'source':
10200969   Roipoussiere   Remove whitespace...
108
109
110
111
					$xmlName = DATAPATH.'RemoteData/'.$obj->baseId.'/base.xml';
					break;
				case 'destination':
					$xmlName = USERWSDIR.'RemoteParams.xml';
735c653b   Elena.Budnik   rank at observato...
112
					break;
735c653b   Elena.Budnik   rank at observato...
113
114
115
				default:
					$xmlName = USERWSDIR.$this->xmlFiles[$nodeType];
			}
16035364   Benjamin Renard   First commit
116

a0f13ed1   Elena.Budnik   small format + ti...
117
			if ($remoteBase){
735c653b   Elena.Budnik   rank at observato...
118
				$nodeType = 'remoteParam';
10200969   Roipoussiere   Remove whitespace...
119
120
			}

e57cb025   Benjamin Renard   Fix most of error...
121
			@$Dom->load($xmlName);
10200969   Roipoussiere   Remove whitespace...
122

a0f13ed1   Elena.Budnik   small format + ti...
123
			if ($node == "myRemoteSimuData-treeRootNode") $node = "myRemoteData-treeRootNode";
10200969   Roipoussiere   Remove whitespace...
124

735c653b   Elena.Budnik   rank at observato...
125
			$nodeToOpen = $Dom->getElementById($node);
e57cb025   Benjamin Renard   Fix most of error...
126
			$children = empty($nodeToOpen->childNodes) ? array() : $nodeToOpen->childNodes;
16035364   Benjamin Renard   First commit
127

10200969   Roipoussiere   Remove whitespace...
128
129
			foreach ($children as $child)
				if ($child->nodeType == XML_ELEMENT_NODE)
735c653b   Elena.Budnik   rank at observato...
130
131
				{
					$isLeaf = true;
735c653b   Elena.Budnik   rank at observato...
132
					if ($child->hasChildNodes())
10200969   Roipoussiere   Remove whitespace...
133
134
						foreach ($child->childNodes as $grandChild)
							if ($grandChild -> nodeType == XML_ELEMENT_NODE)
735c653b   Elena.Budnik   rank at observato...
135
136
137
138
139
140
							{
									$isLeaf = false;
									break;
							}
					if ($child->tagName == 'folder')  $isLeaf = false;

10200969   Roipoussiere   Remove whitespace...
141
142
					//TODO MAKE PROPERLY  as function of nodetype !!!!
					$info = '';
8ba47f72   Benjamin Renard   rest actualisatio...
143
144
					$dim_1 = 1;
					$dim_2 = 1;
735c653b   Elena.Budnik   rank at observato...
145
					$id =  $child->getAttribute('xml:id');
10200969   Roipoussiere   Remove whitespace...
146
					$name = $child->getAttribute('name');
735c653b   Elena.Budnik   rank at observato...
147
					$help = $child->getAttribute('att');
735c653b   Elena.Budnik   rank at observato...
148
149
150
151
152

					$specialNode = false;
					$isParameter = false;
					$isAddable =  false;
					$isSimulation = false;
735c653b   Elena.Budnik   rank at observato...
153
					$rank = null;
e57cb025   Benjamin Renard   Fix most of error...
154
					$skip = FALSE;
735c653b   Elena.Budnik   rank at observato...
155

10200969   Roipoussiere   Remove whitespace...
156
					switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
157
					{
10200969   Roipoussiere   Remove whitespace...
158
						case 'bkgWorks':
735c653b   Elena.Budnik   rank at observato...
159
							$specialNode = true;
84db3b67   Nathanael Jourdane   Improve job toolt...
160
161
162
163
164
165
							$childrenToReturn[] = [
								'text'     => $name,
								'id'       => $id,
								'nodeType' => $nodeType,
								'leaf'     => $isLeaf,
								'pid'      => $child->getAttribute('pid'),
b4bca467   Nathanael Jourdane   job tooltip: use ...
166
								'status'   => $child->getAttribute('status'),
84db3b67   Nathanael Jourdane   Improve job toolt...
167
								'jobType'  => $child->getAttribute('jobType'),
812bc03d   Nathanael Jourdane   update job info o...
168
								'info'     => $child->getAttribute('info')
84db3b67   Nathanael Jourdane   Improve job toolt...
169
							];
b4bca467   Nathanael Jourdane   job tooltip: use ...
170
							break;
735c653b   Elena.Budnik   rank at observato...
171
172

						case 'condition':
638db58d   Benjamin Renard   RequestMgr constr...
173
							$objectMgr = new RequestMgr($nodeType);
10200969   Roipoussiere   Remove whitespace...
174
175
							$info = $objectMgr->getObject($id)->expression;
						break;
735c653b   Elena.Budnik   rank at observato...
176

10200969   Roipoussiere   Remove whitespace...
177
						case 'request':
638db58d   Benjamin Renard   RequestMgr constr...
178
						$objectMgr = new RequestMgr($nodeType);
10200969   Roipoussiere   Remove whitespace...
179
						$objplot = $objectMgr->getObject($id);
f31bea1c   Benjamin Renard   wip for save plot
180
181
182
183
184
185
						if (isset($objplot->name)) {
							$info = $objplot->name;
						}
						else {
							$info = $id;
						}
10200969   Roipoussiere   Remove whitespace...
186
						break;
8b6bb092   Elena.Budnik   icones if rank is...
187
						
735c653b   Elena.Budnik   rank at observato...
188
						case 'timeTable':
10200969   Roipoussiere   Remove whitespace...
189
						case 'catalog':
735c653b   Elena.Budnik   rank at observato...
190
191
							if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
						break;
10200969   Roipoussiere   Remove whitespace...
192

735c653b   Elena.Budnik   rank at observato...
193
194
						case 'sharedtimeTable':
						case 'sharedcatalog':
10200969   Roipoussiere   Remove whitespace...
195
							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
196
197
198
199
							{
								$info = '<b>Nb intervals:</b> '.$child->getAttribute('nbIntervals').'<br/>';
								$info .= '<b>Shared by:</b> '.$child->getAttribute('sharedBy').' ('.$child->getAttribute('sharedDate').')<br/>';
								$info .= '<b>Description:</b> '.$child->getAttribute('description');
8b6bb092   Elena.Budnik   icones if rank is...
200
							} 
735c653b   Elena.Budnik   rank at observato...
201
202
203
						break;
						case 'derivedParam':
							$info = $child->getAttribute('buildchain');
0fea5567   Benjamin Renard   First step for re...
204

8ba47f72   Benjamin Renard   rest actualisatio...
205
206
207
208
209
210
211
							if ($child->hasAttribute('dim_1')) {
								$dim_1 = $child->getAttribute('dim_1');
							}
					                if ($child->hasAttribute('dim_2')) {
                                                                $dim_2 = $child->getAttribute('dim_2');
                                                        }

735c653b   Elena.Budnik   rank at observato...
212
213
214
215
216
217
218
219
220
221
222
							if ($isLeaf) $isParameter = true;
						break;

						case 'localParam':

							$globalStart = null;
							$globalStop = null;
							$timeRestriction = false;
							$specialNode = true;
							$isParameter = false;
							$needsArgs = false;
10200969   Roipoussiere   Remove whitespace...
223
							$isSpectra = false;
dc9e2c14   Elena.Budnik   init + message + ...
224
							$is2dSpectra = false;
735c653b   Elena.Budnik   rank at observato...
225
							$isStack = false;
e57cb025   Benjamin Renard   Fix most of error...
226
							$not_yet = false;
735c653b   Elena.Budnik   rank at observato...
227

10200969   Roipoussiere   Remove whitespace...
228
229
							if ($child->hasAttribute('desc'))
							{
735c653b   Elena.Budnik   rank at observato...
230
								$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
231

c57c57c9   Elena.Budnik   info message depe...
232
								if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
67bd6ed6   Elena.Budnik   rm 8375
233
234
235
236
237
238
239
240
241
242
243
244
245
                                    $dataStart = $child->getAttribute('dataStart');
                                    // check UTC format
                                    if ( !preg_match('/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/', $dataStart ) ) {
                                        if ( $dataStart == "MissionDependent" )
                                            $info .= "<br/>Time Range : depending on mission selection"; 
                                        else 
                                            $info .= "<br/>Time Range : undefined"; 
                                        $child->setAttribute('dataStart', date("Y-m-d\TH:i:s\Z", strtotime(' -1 day')));
                                        $child->setAttribute('dataStop', date("Y-m-d\TH:i:s\Z", time()));                                        
                                    } else {
                                        $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
                                    }
                                    
a7316784   Elena.Budnik   add LastUpdate to...
246
247
248
									if ($child->hasAttribute('lastUpdate')) {
										$info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate');
									}
735c653b   Elena.Budnik   rank at observato...
249
								}
735c653b   Elena.Budnik   rank at observato...
250
							}
10200969   Roipoussiere   Remove whitespace...
251

cbbbdc34   Elena.Budnik   param description...
252
							if ($child->hasAttribute('units')) {
0fea5567   Benjamin Renard   First step for re...
253

cbbbdc34   Elena.Budnik   param description...
254
								$units = $child->getAttribute('units');
0fea5567   Benjamin Renard   First step for re...
255

cbbbdc34   Elena.Budnik   param description...
256
257
								if ($child->hasAttribute('description'))
									$info = $child->getAttribute('description')."<br/>".$units;
0fea5567   Benjamin Renard   First step for re...
258
								else
cbbbdc34   Elena.Budnik   param description...
259
260
									$info = $units;
							}
0fea5567   Benjamin Renard   First step for re...
261

f29c5e66   Elena.Budnik   plot only option
262
							if ($child->tagName == 'parameter') {
735c653b   Elena.Budnik   rank at observato...
263
								$isParameter = true;
67bd6ed6   Elena.Budnik   rm 8375
264
265
                                if ($child->hasAttribute('TemplatedParameter'))
                                    $needsArgs = true;
2fa56f95   Benjamin Renard   Predefined templa...
266
267
268

				if ($child->hasAttribute('PredefinedTemplatedParameter'))
					$predefinedArgs = true;
67bd6ed6   Elena.Budnik   rm 8375
269
                                    
c57c57c9   Elena.Budnik   info message depe...
270
								if ($child->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
271
									$globalStart = $child->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
272
									$globalStop = $child->parentNode->getAttribute('dataStop');
735c653b   Elena.Budnik   rank at observato...
273
								}
0fea5567   Benjamin Renard   First step for re...
274

f29c5e66   Elena.Budnik   plot only option
275
276
277
278
								if ($child->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
279
								}
3afe4f59   Benjamin Renard   Add datasets time...
280
281
282
283

								if ($child->parentNode->hasAttribute('timeRestriction')) {
									$timeRestriction = $child->parentNode->getAttribute('timeRestriction');
								}
735c653b   Elena.Budnik   rank at observato...
284
							}
10200969   Roipoussiere   Remove whitespace...
285

735c653b   Elena.Budnik   rank at observato...
286
287
288
289
							$component_info = array();
							if ($child->tagName == 'component')
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
290

c57c57c9   Elena.Budnik   info message depe...
291
								if ($child->parentNode->parentNode->hasAttribute('dataStart')) {
735c653b   Elena.Budnik   rank at observato...
292
									$globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
10200969   Roipoussiere   Remove whitespace...
293
294
									$globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
								}
0fea5567   Benjamin Renard   First step for re...
295

f29c5e66   Elena.Budnik   plot only option
296
297
298
299
								if ($child->parentNode->parentNode->hasAttribute('restriction')) {
									if ($child->parentNode->parentNode->getAttribute('restriction') == "plotOnly") {
										$not_yet = true;
									}
10200969   Roipoussiere   Remove whitespace...
300
								}
3afe4f59   Benjamin Renard   Add datasets time...
301
302
303
304

								if ($child->parentNode->parentNode->hasAttribute('timeRestriction')) {
									$timeRestriction = $child->parentNode->parentNode->getAttribute('timeRestriction');
								}
735c653b   Elena.Budnik   rank at observato...
305
306
307
308
309

								if ($child->hasAttribute("index1"))
									$component_info["index1"] = $child->getAttribute('index1');
								if ($child->hasAttribute("index2"))
									$component_info["index2"] = $child->getAttribute('index2');
10200969   Roipoussiere   Remove whitespace...
310

735c653b   Elena.Budnik   rank at observato...
311
312
								$component_info["parentId"] = $child->parentNode->getAttribute('xml:id');
							}
10200969   Roipoussiere   Remove whitespace...
313

f29c5e66   Elena.Budnik   plot only option
314
							if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')){
c57c57c9   Elena.Budnik   info message depe...
315
								if ($child->getAttribute('display_type') == 'spectrogram') {
10200969   Roipoussiere   Remove whitespace...
316
317
										$needsArgs = true;
										$isSpectra = true;
dc9e2c14   Elena.Budnik   init + message + ...
318
319
										if (strpos($child->getAttribute('name'),'2D') !== false)
											$is2dSpectra = true;
735c653b   Elena.Budnik   rank at observato...
320
								}
c57c57c9   Elena.Budnik   info message depe...
321
								elseif ($child->getAttribute('display_type') == 'stackplot') {
735c653b   Elena.Budnik   rank at observato...
322
										$isStack = true;
735c653b   Elena.Budnik   rank at observato...
323
								}
10200969   Roipoussiere   Remove whitespace...
324
325
							}

f31bea1c   Benjamin Renard   wip for save plot
326

c57c57c9   Elena.Budnik   info message depe...
327
							if ($isParameter) {
735c653b   Elena.Budnik   rank at observato...
328
329
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);
c3b20775   Elena.Budnik   not show ID for p...
330
331
								
                                if (! ($child->parentNode->hasAttribute('group') || $child->parentNode->parentNode->hasAttribute('group'))) $info .= '</br><i>ID : '.$id.'</i>';
661293d7   Elena.Budnik   parse ## and @@ i...
332
								$childrenToReturn[] = array('text' => $name,'alias' => $alias,
735c653b   Elena.Budnik   rank at observato...
333
334
									'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
									'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
dc9e2c14   Elena.Budnik   init + message + ...
335
									'leaf' => $isLeaf, 'isParameter' => $isParameter,'isSpectra' => $isSpectra,
2fa56f95   Benjamin Renard   Predefined templa...
336
									'is2dSpectra' => $is2dSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'predefinedArgs' => $predefinedArgs, 'help' => $help, 'notyet' => $not_yet);
735c653b   Elena.Budnik   rank at observato...
337
							}
c57c57c9   Elena.Budnik   info message depe...
338
							else {
8b6bb092   Elena.Budnik   icones if rank is...
339
								if ($child->hasAttribute('rank')) {
735c653b   Elena.Budnik   rank at observato...
340
341
									$rank = $child->getAttribute('rank');
								}
0fea5567   Benjamin Renard   First step for re...
342

3afe4f59   Benjamin Renard   Add datasets time...
343
344
345
346
								if ($child->hasAttribute("timeRestriction")) {
									$timeRestriction = $child->getAttribute("timeRestriction");
								}
								$disable = TRUE;
acf87705   Elena.Budnik   bug in disable param
347

3afe4f59   Benjamin Renard   Add datasets time...
348
								if ($child->hasAttribute('group')) {
c3976709   Elena.Budnik   rm 7589 + clean u...
349
350
									if ($child->getAttribute("group") === "TBD") {
											$info .=  "<br/><b>Under Testing</b>";
3afe4f59   Benjamin Renard   Add datasets time...
351
									}
10200969   Roipoussiere   Remove whitespace...
352
									else {
c3976709   Elena.Budnik   rm 7589 + clean u...
353
										$info .= "<br/><b>Restricted Access : Group ".$child->getAttribute('group')."</b>";
3afe4f59   Benjamin Renard   Add datasets time...
354
355
356
357
										if (!empty($timeRestriction)) {
											$disable = FALSE;
											$info .= "<br/><b>Time Restriction : ".$timeRestriction."</b>";
										}
735c653b   Elena.Budnik   rank at observato...
358
									}
0fea5567   Benjamin Renard   First step for re...
359
								}
acf87705   Elena.Budnik   bug in disable param
360
								else {
3afe4f59   Benjamin Renard   Add datasets time...
361
									$disable = FALSE;
acf87705   Elena.Budnik   bug in disable param
362
363
									if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly')
										$info .=  "<br/><b>Plot Only!!!</b>";
735c653b   Elena.Budnik   rank at observato...
364
365
								}

10200969   Roipoussiere   Remove whitespace...
366
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'info' => $info,
3afe4f59   Benjamin Renard   Add datasets time...
367
									'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank, 'timeRestriction' => $timeRestriction);
735c653b   Elena.Budnik   rank at observato...
368
369
370
371
							}
						break;

						case 'remoteSimuParam' :
10200969   Roipoussiere   Remove whitespace...
372

bf74fc2d   Elena.Budnik   IMPEX
373
							$globalStart = null;
6657f68b   Elena.Budnik   monitor impex ser...
374
							$service_down = false;
735c653b   Elena.Budnik   rank at observato...
375
							$isSimulation = true;
10200969   Roipoussiere   Remove whitespace...
376
377

			            if ($child->getAttribute('isAddable')) // 'spase://IMPEX/SimulationModel/FMI/GUMICS'
735c653b   Elena.Budnik   rank at observato...
378
379
380
381
							{
								$isLeaf = false;
								$isAddable = true;
							}
10200969   Roipoussiere   Remove whitespace...
382
383

							if ($child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
384
							{
10200969   Roipoussiere   Remove whitespace...
385
								if ($child->getAttribute('isSimulation'))
6657f68b   Elena.Budnik   monitor impex ser...
386
								{
10200969   Roipoussiere   Remove whitespace...
387
388
									$service_down = !($child->getAttribute('available'));
									break;
6657f68b   Elena.Budnik   monitor impex ser...
389
								}
10200969   Roipoussiere   Remove whitespace...
390
								else
735c653b   Elena.Budnik   rank at observato...
391
392
393
394
395
								{
									$skip = true;
									break;
								}
							}
10200969   Roipoussiere   Remove whitespace...
396
397

							if ($child->hasAttribute('rank'))
735c653b   Elena.Budnik   rank at observato...
398
399
400
							{
								$rank = $child->getAttribute('rank');
							}
10200969   Roipoussiere   Remove whitespace...
401

bf74fc2d   Elena.Budnik   IMPEX
402
403
							if ( $child->tagName == 'parameter')
							{
abb54096   Elena.Budnik   time interval by ...
404
								if ($child->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
405
									{
abb54096   Elena.Budnik   time interval by ...
406
407
										$globalStart = $child->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
408
409
									}
							}
10200969   Roipoussiere   Remove whitespace...
410

bf74fc2d   Elena.Budnik   IMPEX
411
412
							if ( $child->tagName == 'component')
							{
abb54096   Elena.Budnik   time interval by ...
413
								if ($child->parentNode->parentNode->hasAttribute('globalStart'))
bf74fc2d   Elena.Budnik   IMPEX
414
									{
abb54096   Elena.Budnik   time interval by ...
415
416
										$globalStart = $child->parentNode->parentNode->getAttribute('globalStart');
										$globalStop = $child->parentNode->parentNode->getAttribute('globalStop');
bf74fc2d   Elena.Budnik   IMPEX
417
418
									}
							}
10200969   Roipoussiere   Remove whitespace...
419

735c653b   Elena.Budnik   rank at observato...
420
						case 'remoteParam' :
10200969   Roipoussiere   Remove whitespace...
421
422

							if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter')
735c653b   Elena.Budnik   rank at observato...
423
424
425
426
427
428
429
							{
								$skip = true;
								break;
							}

							$isDeletable = $child->hasAttribute('isDeletable');
							$specialNode = true;
10200969   Roipoussiere   Remove whitespace...
430
431
432
433
434
							$isParameter = false;

							$isSpectra = false;

							switch ($id)
735c653b   Elena.Budnik   rank at observato...
435
							{
10200969   Roipoussiere   Remove whitespace...
436
								case 'CDAWEB'  :
735c653b   Elena.Budnik   rank at observato...
437
438
439
								case 'THEMIS' :
									$rank = 5;
									break;
735c653b   Elena.Budnik   rank at observato...
440
441
								default:
							}
10200969   Roipoussiere   Remove whitespace...
442

735c653b   Elena.Budnik   rank at observato...
443
444
							$info = $child->getAttribute('desc');

10200969   Roipoussiere   Remove whitespace...
445
446
							if ($info && !$isSimulation)
							{
735c653b   Elena.Budnik   rank at observato...
447
								$info = str_replace(';', "<br/>Time Range: ", $info);
10200969   Roipoussiere   Remove whitespace...
448
449
450
							}

							if (($child->tagName == 'parameter') || ($child->tagName == 'component'))
735c653b   Elena.Budnik   rank at observato...
451
452
							{
								$isParameter = true;
735c653b   Elena.Budnik   rank at observato...
453
							}
10200969   Roipoussiere   Remove whitespace...
454

9a63b7f6   Elena.Budnik   needsArgs to Simu...
455
							$needsArgs =  $child->getAttribute('needsArgs');
735c653b   Elena.Budnik   rank at observato...
456

10200969   Roipoussiere   Remove whitespace...
457
							if ($remoteBase)
735c653b   Elena.Budnik   rank at observato...
458
							{
10200969   Roipoussiere   Remove whitespace...
459
								if ($child->tagName == 'dataset') $isRemoteDataSet = true;
735c653b   Elena.Budnik   rank at observato...
460
							}
0fea5567   Benjamin Renard   First step for re...
461

a0f13ed1   Elena.Budnik   small format + ti...
462
463
464
465
466
467
							if ($child->tagName == 'parameter'){
								if ($child->parentNode->hasAttribute('dataStart')){
									$globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
								}
							}
735c653b   Elena.Budnik   rank at observato...
468

a0f13ed1   Elena.Budnik   small format + ti...
469
470
471
472
473
474
							if ( $child->tagName == 'component'){
								if ($child->parentNode->parentNode->hasAttribute('dataStart')){
									$globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart')));
									$globalStop = date('Y-m-d\TH:i:s\Z',  strtotime($child->parentNode->getAttribute('dataStop')));
								}
							}
0fea5567   Benjamin Renard   First step for re...
475

10200969   Roipoussiere   Remove whitespace...
476
							if ($isParameter)
735c653b   Elena.Budnik   rank at observato...
477
							{
10200969   Roipoussiere   Remove whitespace...
478
								$disable = $child->parentNode->getAttribute('disabled');
735c653b   Elena.Budnik   rank at observato...
479
480
481
482
483
								$objectMgr = new AliasMgr();
								$alias = $objectMgr->getAlias($id);

								if ($child->hasAttribute('display_type') && $child->getAttribute('display_type') == 'spectrogram')
								{
10200969   Roipoussiere   Remove whitespace...
484
									$needsArgs = true;
735c653b   Elena.Budnik   rank at observato...
485
									$isSpectra = true;
10200969   Roipoussiere   Remove whitespace...
486
								}
bf74fc2d   Elena.Budnik   IMPEX
487
								if ($globalStart)
10200969   Roipoussiere   Remove whitespace...
488
								 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
489
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,  'globalStart' => $globalStart,
10200969   Roipoussiere   Remove whitespace...
490
										'globalStop' => $globalStop, 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
491
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => isset($component_info) ? $component_info : NULL);
bf74fc2d   Elena.Budnik   IMPEX
492
								else
10200969   Roipoussiere   Remove whitespace...
493
									$childrenToReturn[] = array('text' => $name,'alias' => $alias,
bf74fc2d   Elena.Budnik   IMPEX
494
										'id' => $id,'nodeType' => $nodeType,  'info' => $info, 'help' => $help,
10200969   Roipoussiere   Remove whitespace...
495
										'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
1c007ca2   Elena.Budnik   vector icon for M...
496
										'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
735c653b   Elena.Budnik   rank at observato...
497
							}
10200969   Roipoussiere   Remove whitespace...
498
499
							else
							{
e57cb025   Benjamin Renard   Fix most of error...
500
								$restricted = FALSE;
0fea5567   Benjamin Renard   First step for re...
501

735c653b   Elena.Budnik   rank at observato...
502
								if ($child->tagName == 'dataset')
6657f68b   Elena.Budnik   monitor impex ser...
503
								{
735c653b   Elena.Budnik   rank at observato...
504
									$nonavailable = ($child->getAttribute('disabled'));
6657f68b   Elena.Budnik   monitor impex ser...
505
								}
735c653b   Elena.Budnik   rank at observato...
506
								else
6657f68b   Elena.Budnik   monitor impex ser...
507
								{
735c653b   Elena.Budnik   rank at observato...
508
									$nonavailable = false;
6657f68b   Elena.Budnik   monitor impex ser...
509
								}
10200969   Roipoussiere   Remove whitespace...
510

735c653b   Elena.Budnik   rank at observato...
511
512
513
514
515
516
								if ($nonavailable)
									$info .= "<br/><b>Not available yet</b>";

								if ($child->getAttribute('url'))
									$info .= "<br/>".$child->getAttribute('url');

10200969   Roipoussiere   Remove whitespace...
517
								if ($child->hasAttribute('obsolete'))
735c653b   Elena.Budnik   rank at observato...
518
519
520
521
522
523
524
525
								{
									$info = $child->getAttribute('desc');
									$obsolete = true;
								}
								else
									$obsolete = false;

								$disable = $restricted || $nonavailable || $obsolete;
10200969   Roipoussiere   Remove whitespace...
526

735c653b   Elena.Budnik   rank at observato...
527
								$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType,  'isAddable' => $isAddable,
10200969   Roipoussiere   Remove whitespace...
528
529
530
								'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
								'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
							}
735c653b   Elena.Budnik   rank at observato...
531
						break;
10200969   Roipoussiere   Remove whitespace...
532
533
534

						case 'myData' :
							$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
735c653b   Elena.Budnik   rank at observato...
535
536
537
538
539
540
541
542
						break;

						case 'myDataParam' :

							$globalStart = null;
							$globalStop = null;
							$specialNode = true;
							$size = $child->getAttribute('size');
735c653b   Elena.Budnik   rank at observato...
543
							$mask = $child->getAttribute('mask');
19dcd963   Elena.Budnik   redmine #4903 : s...
544
							$sampling = null;
0fea5567   Benjamin Renard   First step for re...
545
							if ($child->hasAttribute('minsampling'))
19dcd963   Elena.Budnik   redmine #4903 : s...
546
								$sampling = $child->getAttribute('minsampling');
735c653b   Elena.Budnik   rank at observato...
547
							$isSpectra = false;
10200969   Roipoussiere   Remove whitespace...
548
549

							if ($isLeaf)
735c653b   Elena.Budnik   rank at observato...
550
551
552
							{
									$isParameter = true;
									$info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
19dcd963   Elena.Budnik   redmine #4903 : s...
553
554
									if ($sampling)
										$info .= "<br/> Sampling : ".$sampling;
735c653b   Elena.Budnik   rank at observato...
555
556
557
									$isSpectra = $child->getAttribute('plottype') === 'Spectra';
							}

10200969   Roipoussiere   Remove whitespace...
558
							if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
559
560
561
562
563
							{
									$globalStart = substr($child->getAttribute('desc'), 0, 19);
									$globalStop =  substr($child->getAttribute('desc'), 20);
							}

10200969   Roipoussiere   Remove whitespace...
564
							$childrenToReturn[] = array('text' => $name, 'size' =>  $size, 'id' => $id,
735c653b   Elena.Budnik   rank at observato...
565
								'globalStart' => $globalStart, 'globalStop' => $globalStop,
1c007ca2   Elena.Budnik   vector icon for M...
566
								'nodeType' => $nodeType, 'info' => $info,  'leaf' => $isLeaf,
735c653b   Elena.Budnik   rank at observato...
567
568
569
								'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);

						break;
10200969   Roipoussiere   Remove whitespace...
570
						default:
735c653b   Elena.Budnik   rank at observato...
571
					}
10200969   Roipoussiere   Remove whitespace...
572
573

					if (!$specialNode && !$skip)
735c653b   Elena.Budnik   rank at observato...
574
					{
10200969   Roipoussiere   Remove whitespace...
575
						if ($child->hasAttribute('desc'))
735c653b   Elena.Budnik   rank at observato...
576
							$info = $child->getAttribute('desc');
10200969   Roipoussiere   Remove whitespace...
577
578

						if ($isSimulation && $service_down)
6657f68b   Elena.Budnik   monitor impex ser...
579
580
581
						{
							$info = "<b>Service is currently down</b>";
						}
10200969   Roipoussiere   Remove whitespace...
582
583

						$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
2048f5bc   Benjamin Renard   Fix save & edit plot
584
													'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2,
0fea5567   Benjamin Renard   First step for re...
585
													'component_info' => isset($component_info) ? $component_info : NULL,
cbbbdc34   Elena.Budnik   param description...
586
													'iconCls' => isset($iconCls) ? $iconCls : NULL );
735c653b   Elena.Budnik   rank at observato...
587
588
589
					}
				}
				// if $childrenToReturn we have to return []
e57cb025   Benjamin Renard   Fix most of error...
590
				if (empty($childrenToReturn))
10200969   Roipoussiere   Remove whitespace...
591
				{
735c653b   Elena.Budnik   rank at observato...
592
593
594
					$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
				}
			}
16035364   Benjamin Renard   First commit
595
      return  $childrenToReturn;
735c653b   Elena.Budnik   rank at observato...
596
	}
16035364   Benjamin Renard   First commit
597

0dc31ba8   Elena.Budnik   remoteParamManage...
598
599
600
	/*
	*  add Remote Parameter to user RemoteParams.xml
	*  send request to DDServer to AddVi if Vi doesn't exist
0fea5567   Benjamin Renard   First step for re...
601
	*  create Remote Parameter Description
0dc31ba8   Elena.Budnik   remoteParamManage...
602
	*/
10200969   Roipoussiere   Remove whitespace...
603
	public  function saveTree($obj)
735c653b   Elena.Budnik   rank at observato...
604
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
605
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
606
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
607

2b8ea2a7   Elena.Budnik   RemoteParamManage...
608
609
		if ($res['success'])
			return $paramMgr->saveTree($obj);
0fea5567   Benjamin Renard   First step for re...
610
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
611
			return $res;
735c653b   Elena.Budnik   rank at observato...
612
	}
0fea5567   Benjamin Renard   First step for re...
613

0dc31ba8   Elena.Budnik   remoteParamManage...
614
615
616
	/*
	*  delete Remote Parameter from user RemoteParams.xml
	*/
10200969   Roipoussiere   Remove whitespace...
617
618
	public  function deleteFromTree($obj)
	{
0dc31ba8   Elena.Budnik   remoteParamManage...
619
		$paramMgr = new RemoteParamManager();
2b8ea2a7   Elena.Budnik   RemoteParamManage...
620
		$res = $paramMgr->init();
0fea5567   Benjamin Renard   First step for re...
621

2b8ea2a7   Elena.Budnik   RemoteParamManage...
622
623
		if ($res['success'])
			return $paramMgr->deleteFromTree($obj);
0fea5567   Benjamin Renard   First step for re...
624
		else
2b8ea2a7   Elena.Budnik   RemoteParamManage...
625
			return $res;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
626
	}
0fea5567   Benjamin Renard   First step for re...
627

0dc31ba8   Elena.Budnik   remoteParamManage...
628
629
630
631
	public  function doNothing($obj)
	{
		return array("res" => 'ok');
	}
16035364   Benjamin Renard   First commit
632

0dc31ba8   Elena.Budnik   remoteParamManage...
633
634
635
	/*
	*  get temporary object from Upload
	*/
9a63b7f6   Elena.Budnik   needsArgs to Simu...
636
	public  function getUploadedObject($name, $format, $nodeType)
10200969   Roipoussiere   Remove whitespace...
637
	{
5f8bd1f5   Nathanaël Jourdane   Fix Windows-files...
638
639
640
		$fileContent = preg_replace(['~\R~u', "/\t/"], ["\n", ' '], trim(file_get_contents(USERTEMPDIR . $name)));
		file_put_contents(USERTEMPDIR . $name, $fileContent);

42e2e019   Benjamin Renard   Next step for cac...
641
		$isTTCat = FALSE;
10200969   Roipoussiere   Remove whitespace...
642
		switch ($nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
643
		{
10200969   Roipoussiere   Remove whitespace...
644
645
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
42e2e019   Benjamin Renard   Next step for cac...
646
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
647
				break;
10200969   Roipoussiere   Remove whitespace...
648
649
650
651
652
			case 'myDataParam' :
				$objectMgr = new FilesMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
42e2e019   Benjamin Renard   Next step for cac...
653
				$isTTCat = TRUE;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
654
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
655
656
657
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
42e2e019   Benjamin Renard   Next step for cac...
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
		if ($isTTCat) {
			//Pre-process: convert to INTERNAL format if needed
			if (($format == 'ASCII') || ($format == 'VOT')) {
				$result = $this->executeRequest((Object) array(
					'compression' => 'none',
					'fileformat' => 'internal',
					'sendToSamp' => FALSE,
					'list' => array(
						(Object) array(
							'path' => USERTEMPDIR . $name,
							'format' => $format,
							'name' => pathinfo($name, PATHINFO_FILENAME),
						)
					),
				), FunctionTypeEnumClass::TTCONVERT);
				if (!$result['success']) {
					return array("error" => "Error during file conversion");
				}
				$name = basename($result['download']);
				$convertedFile = USERDIR.'/DOWNLOAD.TEMP/'.$name;
				if (!file_exists($convertedFile)) {
					return array("error" => "Error during file conversion");
				}

				$format = 'internal';
				rename($convertedFile, USERTEMPDIR . '/' . $name);
			}
		}
bf74fc2d   Elena.Budnik   IMPEX
686
		return  $objectMgr->getUploadedObject($name, $format, true);
10200969   Roipoussiere   Remove whitespace...
687
	}
16035364   Benjamin Renard   First commit
688

0dc31ba8   Elena.Budnik   remoteParamManage...
689
690
691
	/*
	*  fill ascii file into grid
	*/
10200969   Roipoussiere   Remove whitespace...
692
693
694
	public  function getAsciiFile($obj)
	{
		$objectMgr = new FilesMgr();
bf74fc2d   Elena.Budnik   IMPEX
695
		return  $objectMgr->getAsciiFile($obj->fileName);
735c653b   Elena.Budnik   rank at observato...
696
	}
10200969   Roipoussiere   Remove whitespace...
697
698
699
700

	public function getMyParamInfo($object)
	{
		$objectMgr = new FilesMgr();
bf74fc2d   Elena.Budnik   IMPEX
701
		return  $objectMgr->getParamInfo($object);
10200969   Roipoussiere   Remove whitespace...
702
	}
16035364   Benjamin Renard   First commit
703

0dc31ba8   Elena.Budnik   remoteParamManage...
704
705
706
	/*
	*  get temporary object from Search
	*/
10200969   Roipoussiere   Remove whitespace...
707
708
709
	public  function getTmpObject($folderId, $name, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
710
		{
10200969   Roipoussiere   Remove whitespace...
711
712
713
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
714
			case 'catalog' :
10200969   Roipoussiere   Remove whitespace...
715
716
				$objectMgr = new CatalogMgr();
			break;
735c653b   Elena.Budnik   rank at observato...
717
718
719
			default:
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
720
		return  $objectMgr->getTmpObject($folderId, $name, true);
fdf1413b   Elena.Budnik   TT download
721
	}
735c653b   Elena.Budnik   rank at observato...
722

10200969   Roipoussiere   Remove whitespace...
723
724
725
726

	public  function getObject($id, $nodeType)
	{
		switch ($nodeType)
735c653b   Elena.Budnik   rank at observato...
727
728
		{
			case 'myDataParam':
10200969   Roipoussiere   Remove whitespace...
729
730
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($nodeType);
735c653b   Elena.Budnik   rank at observato...
731
				break;
10200969   Roipoussiere   Remove whitespace...
732
			case 'timeTable' :
735c653b   Elena.Budnik   rank at observato...
733
			case 'sharedtimeTable' :
10200969   Roipoussiere   Remove whitespace...
734
735
				$objectMgr = new TimeTableMgr();
				break;
735c653b   Elena.Budnik   rank at observato...
736
737
			case 'catalog' :
			case 'sharedcatalog' :
10200969   Roipoussiere   Remove whitespace...
738
739
740
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
741
			case 'request' :
10200969   Roipoussiere   Remove whitespace...
742
743
				$objectMgr = new RequestMgr($nodeType);
				break;
0fea5567   Benjamin Renard   First step for re...
744
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
745
746
747
				return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
				break;
			case 'myData' :
10200969   Roipoussiere   Remove whitespace...
748
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
749
				break;
10200969   Roipoussiere   Remove whitespace...
750
			default:
735c653b   Elena.Budnik   rank at observato...
751
752
				return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
		}
bf74fc2d   Elena.Budnik   IMPEX
753
		return  $objectMgr->getObject($id, $nodeType);
fdf1413b   Elena.Budnik   TT download
754
	}
10200969   Roipoussiere   Remove whitespace...
755

16035364   Benjamin Renard   First commit
756
757
758
/*
*   $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
10200969   Roipoussiere   Remove whitespace...
759
760
761
762
763
764
765
	public  function deleteObject($obj)
	{
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
766
				break;
10200969   Roipoussiere   Remove whitespace...
767
768
769
770
771
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
735c653b   Elena.Budnik   rank at observato...
772
				break;
10200969   Roipoussiere   Remove whitespace...
773
			case 'condition' :
735c653b   Elena.Budnik   rank at observato...
774
			case 'request' :
10200969   Roipoussiere   Remove whitespace...
775
				$objectMgr = new RequestMgr($obj->nodeType);
735c653b   Elena.Budnik   rank at observato...
776
777
778
779
				break;
			case 'alias' :
				$objectMgr = new AliasMgr();
				$obj->id = substr($obj->id,strlen('alias_'));
10200969   Roipoussiere   Remove whitespace...
780
				break;
735c653b   Elena.Budnik   rank at observato...
781
			case 'bkgWorks' :
735c653b   Elena.Budnik   rank at observato...
782
783
784
				return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);

			case 'myData' :
16035364   Benjamin Renard   First commit
785
				$objectMgr = new FilesMgr();
735c653b   Elena.Budnik   rank at observato...
786
787
788
789
790
791
				break;
			default:
					return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> deleteObject($obj);
	}
16035364   Benjamin Renard   First commit
792
793
794
795

/*
*   $obj = { id: node.id, old_name: node.text, name: value,  parent : node.parentNode.id, leaf: node.leaf, nodeType: node.nodeType }
*/
10200969   Roipoussiere   Remove whitespace...
796
797
798
	public  function renameObject($obj)
	{
		switch ($obj->nodeType)
735c653b   Elena.Budnik   rank at observato...
799
		{
10200969   Roipoussiere   Remove whitespace...
800

16035364   Benjamin Renard   First commit
801
		  case 'myDataParam' :
10200969   Roipoussiere   Remove whitespace...
802
803
804
805
806
		  case 'derivedParam' :
			   $objectMgr = new DerivedParamMgr($obj->nodeType);
			   break;
		  case 'timeTable' :
			   $objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
807
			   break;
10200969   Roipoussiere   Remove whitespace...
808
809
		  case 'catalog' :
			   $objectMgr = new CatalogMgr();
d18b535d   elena   catalog draft + c...
810
			   break;
10200969   Roipoussiere   Remove whitespace...
811
812
		  case 'condition' :
		  case 'request' :
10200969   Roipoussiere   Remove whitespace...
813
			   $objectMgr = new RequestMgr($obj->nodeType);
16035364   Benjamin Renard   First commit
814
815
			   break;
		  case 'alias' :
10200969   Roipoussiere   Remove whitespace...
816
817
		  	   $objectMgr = new AliasMgr();
		  	   break;
16035364   Benjamin Renard   First commit
818
819
		  default:
			    return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
735c653b   Elena.Budnik   rank at observato...
820
		}
16035364   Benjamin Renard   First commit
821

735c653b   Elena.Budnik   rank at observato...
822
823
		return  $objectMgr -> renameObject($obj);
	}
16035364   Benjamin Renard   First commit
824

10200969   Roipoussiere   Remove whitespace...
825
/*
16035364   Benjamin Renard   First commit
826
827
*   $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
828
829
830
	public  function createObject($obj, $folder)
	{
		switch ($obj->nodeType)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
831
		{
10200969   Roipoussiere   Remove whitespace...
832
			case 'myDataParam' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
833
			case 'derivedParam' :
10200969   Roipoussiere   Remove whitespace...
834
				if ($obj->nodeType == 'derivedParam' &&  $this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
835
						$this->amdaStat->addTask($this->user, 'create', null);
10200969   Roipoussiere   Remove whitespace...
836
				$objectMgr = new DerivedParamMgr($obj->nodeType);
8ba47f72   Benjamin Renard   rest actualisatio...
837
                 	break;
10200969   Roipoussiere   Remove whitespace...
838
839
840
841
842
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
				break;
			case 'catalog' :
				$objectMgr = new CatalogMgr();
16035364   Benjamin Renard   First commit
843
			   break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
844
			case 'condition' :
10200969   Roipoussiere   Remove whitespace...
845
846
847
			case 'request' :
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
848
			case 'alias' :
10200969   Roipoussiere   Remove whitespace...
849
850
				$objectMgr = new AliasMgr();
				break;
9a63b7f6   Elena.Budnik   needsArgs to Simu...
851
852
853
854
855
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> createObject($obj, $folder);
	}
16035364   Benjamin Renard   First commit
856

10200969   Roipoussiere   Remove whitespace...
857
/*
16035364   Benjamin Renard   First commit
858
859
*   $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
10200969   Roipoussiere   Remove whitespace...
860
	public  function modifyObject($obj)
9a63b7f6   Elena.Budnik   needsArgs to Simu...
861
	{
10200969   Roipoussiere   Remove whitespace...
862
863
864
865
866
		switch ($obj->nodeType)
		{
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
867
				break;
10200969   Roipoussiere   Remove whitespace...
868
869
			case 'timeTable' :
				$objectMgr = new TimeTableMgr();
9a63b7f6   Elena.Budnik   needsArgs to Simu...
870
				break;
10200969   Roipoussiere   Remove whitespace...
871
872
873
874
			case 'catalog' :
				$objectMgr = new CatalogMgr();
				break;
			case 'condition' :
9a63b7f6   Elena.Budnik   needsArgs to Simu...
875
			case 'request' :
10200969   Roipoussiere   Remove whitespace...
876
				$objectMgr = new RequestMgr($obj->nodeType);
9a63b7f6   Elena.Budnik   needsArgs to Simu...
877
878
879
880
881
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}
		return  $objectMgr -> modifyObject($obj);
10200969   Roipoussiere   Remove whitespace...
882
	}
16035364   Benjamin Renard   First commit
883
884
885
886
887
888
889
890
891
892
/*
 * {obj.name, obj.nodeType, obj.leaf}
 */
    public function validNameObject($obj) {
		switch ($obj->nodeType) {
			case 'myDataParam' :
			case 'derivedParam' :
				$objectMgr = new DerivedParamMgr($obj->nodeType);
				break;
			case 'timeTable' :
d18b535d   elena   catalog draft + c...
893
			case 'sharedtimeTable' :
16035364   Benjamin Renard   First commit
894
895
				$objectMgr = new TimeTableMgr();
				break;
d18b535d   elena   catalog draft + c...
896
			case 'catalog' :
169f14d2   Benjamin Renard   Add shared object...
897
			case 'sharedcatalog' :
d18b535d   elena   catalog draft + c...
898
899
				$objectMgr = new CatalogMgr();
				break;
16035364   Benjamin Renard   First commit
900
901
			case 'condition' :
			case 'request' :
16035364   Benjamin Renard   First commit
902
903
904
905
906
907
908
909
910
911
				$objectMgr = new RequestMgr($obj->nodeType);
				break;
			default:
				return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
		}

		return  $objectMgr -> validNameObject($obj);
    }

/*
bae6f5da   Nathanael Jourdane   bugFix fileName f...
912
*   Get running jobs
16035364   Benjamin Renard   First commit
913
*/
bae6f5da   Nathanael Jourdane   bugFix fileName f...
914
	public function getJobs($obj = null)
6acb8d2a   Elena.Budnik   checkRequest in R...
915
	{
812bc03d   Nathanael Jourdane   update job info o...
916
		$obj = (object) array();
10200969   Roipoussiere   Remove whitespace...
917
		return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
6acb8d2a   Elena.Budnik   checkRequest in R...
918
	}
16035364   Benjamin Renard   First commit
919
920
921
922
923
924
925


	/* AKKA-KERNEL-INT
	Move user check from RequestMgr.php to AmdaAction.php
	*/
	private function checkUser($obj)
	{
32bb889b   Elena.Budnik   #5532 to process ...
926
		if (defined('NEWKERNEL_DEBUG') && NEWKERNEL_DEBUG){
16035364   Benjamin Renard   First commit
927
928
929
			$this->user = NEWKERNEL_DEBUG_USER;
			return array('success' => true);
		}
10200969   Roipoussiere   Remove whitespace...
930

16035364   Benjamin Renard   First commit
931
		if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
735c653b   Elena.Budnik   rank at observato...
932
		{
e5ab198f   Nathanael Jourdane   simple getStatus
933
			$dd = new WSUserMgr();
039d19ac   Benjamin Renard   Fix getParameter ...
934
			$dd->initWS($obj->username,$obj->password,$obj->sessionID, false, false);
735c653b   Elena.Budnik   rank at observato...
935
		}
a21497cc   Elena.Budnik   redmine #5645
936
		else {
16035364   Benjamin Renard   First commit
937
			$dd = new UserMgr();
a21497cc   Elena.Budnik   redmine #5645
938
939
			$dd->setSpecialSettings();
		}
10200969   Roipoussiere   Remove whitespace...
940
941

		//TODO error handling
32bb889b   Elena.Budnik   #5532 to process ...
942
		if (($res = $dd->ddCheckUser()) != 0) {
10200969   Roipoussiere   Remove whitespace...
943
			if ($res == 156)
6acb8d2a   Elena.Budnik   checkRequest in R...
944
				return array('success' => false, 'message' => 'Your AMDA session is expired.<br/> Login please!');
16035364   Benjamin Renard   First commit
945

735c653b   Elena.Budnik   rank at observato...
946
947
			return array('success' => false, 'message' => 'ddLogin error: '.$res);
		}
16035364   Benjamin Renard   First commit
948

98c5bd44   Benjamin Renard   Introduce anonymo...
949
		if ($dd->user == WSConfigClass::getAnonymousUserName())
16035364   Benjamin Renard   First commit
950
951
952
		{
			//if ($dd->getWsSize() > DISK_QUOTA * 100)
			//	error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu');
e5ab198f   Nathanael Jourdane   simple getStatus
953
//			return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
6acb8d2a   Elena.Budnik   checkRequest in R...
954
		}
32bb889b   Elena.Budnik   #5532 to process ...
955
		else {
0fea5567   Benjamin Renard   First step for re...
956
			// check disk space
2c7f2cb6   Benjamin Renard   Remove old log fi...
957
958
959
960
961
962
			if ($dd->getWsSize() > DISK_QUOTA) {
				//Try to delete log files - cf. #6245
				if ($dd->getWsSize(TRUE) > DISK_QUOTA) {
					return array('success' => false, 'message' => 'Please clean up your workspace.<br/>No more space is available');
				}
			}
735c653b   Elena.Budnik   rank at observato...
963
		}
10200969   Roipoussiere   Remove whitespace...
964

735c653b   Elena.Budnik   rank at observato...
965
		$this->user = $dd->user;
10200969   Roipoussiere   Remove whitespace...
966

32bb889b   Elena.Budnik   #5532 to process ...
967
		return array('success' => true, 'userHost' => $dd->getIPclient());
16035364   Benjamin Renard   First commit
968
	}
10200969   Roipoussiere   Remove whitespace...
969

6acb8d2a   Elena.Budnik   checkRequest in R...
970
	private function executeRequest($obj, $function)
0fea5567   Benjamin Renard   First step for re...
971
972
	{

32bb889b   Elena.Budnik   #5532 to process ...
973
974
975
		// Check user if access to DD Server and / or possible 'space consuming' action
		if (  $function == FunctionTypeEnumClass::PARAMS ||
				$function == FunctionTypeEnumClass::ACTION ||
8ba47f72   Benjamin Renard   rest actualisatio...
976
977
				$function == FunctionTypeEnumClass::PARAMSGEN ||
				$function == FunctionTypeEnumClass::PARAMSINFOGEN )
32bb889b   Elena.Budnik   #5532 to process ...
978
		{
7ac3e07e   Elena.Budnik   do not check user...
979
980
981
			$res = $this->checkUser($obj);
			if (!$res['success']) return $res;
		}
8ba47f72   Benjamin Renard   rest actualisatio...
982

16035364   Benjamin Renard   First commit
983
		$requestManager = new RequestManagerClass();
32bb889b   Elena.Budnik   #5532 to process ...
984
		try {
e57cb025   Benjamin Renard   Fix most of error...
985
			$res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
32bb889b   Elena.Budnik   #5532 to process ...
986
		} catch (Exception $e) {
16035364   Benjamin Renard   First commit
987
			return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
10200969   Roipoussiere   Remove whitespace...
988
		}
16035364   Benjamin Renard   First commit
989
990
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
991
992
993

/*
*    Main EXECUTE PROCEDURE
16035364   Benjamin Renard   First commit
994
*/
735c653b   Elena.Budnik   rank at observato...
995
996
	public  function execute($node, $obj)
	{
fdf1413b   Elena.Budnik   TT download
997
998
999
1000
		// just convert TT / Catalog
		if ($obj->nodeType == "download" &&  $obj->downloadSrc == "1")
			return $this->executeRequest($obj, FunctionTypeEnumClass::TTCONVERT);
		else if (isset($obj->action))
16035364   Benjamin Renard   First commit
1001
			return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
10200969   Roipoussiere   Remove whitespace...
1002
1003
		else
		{
6acb8d2a   Elena.Budnik   checkRequest in R...
1004
1005
			$res = RequestMgr::checkRequest($obj);
			if (!$res['success']) return $res;
10200969   Roipoussiere   Remove whitespace...
1006

16035364   Benjamin Renard   First commit
1007
			return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMS);
6acb8d2a   Elena.Budnik   checkRequest in R...
1008
		}
fdf1413b   Elena.Budnik   TT download
1009
	}
10200969   Roipoussiere   Remove whitespace...
1010

16035364   Benjamin Renard   First commit
1011
/*
a0b3d64e   Benjamin Renard   Derived parameter...
1012
1013
 * Generate derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1014
1015
	public function compilParam($obj)
	{
735c653b   Elena.Budnik   rank at observato...
1016
1017
		return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
	}
a0b3d64e   Benjamin Renard   Derived parameter...
1018

8ba47f72   Benjamin Renard   rest actualisatio...
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030

/*
 * Generate parameter info for display (e.g size)
 */
        public function generateParamInfo($obj)
        {
                return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSINFOGEN);
        }




a0b3d64e   Benjamin Renard   Derived parameter...
1031
1032
1033
/*
 * Delete derived parameter compilation
 */
735c653b   Elena.Budnik   rank at observato...
1034
1035
	public function compilParamDelete($obj)
	{
a0b3d64e   Benjamin Renard   Derived parameter...
1036
		$res = $this->checkUser($obj);
10200969   Roipoussiere   Remove whitespace...
1037

a0b3d64e   Benjamin Renard   Derived parameter...
1038
1039
		if (!$res['success'])
			return $res;
10200969   Roipoussiere   Remove whitespace...
1040

a0b3d64e   Benjamin Renard   Derived parameter...
1041
1042
1043
1044
		IHMConfigClass::setUserName($this->user);
		$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
		if (file_exists($libParamPath))
			unlink($libParamPath);
735c653b   Elena.Budnik   rank at observato...
1045
1046
		return array("success" => true);
	}
10200969   Roipoussiere   Remove whitespace...
1047

a0b3d64e   Benjamin Renard   Derived parameter...
1048
/*
e6e5b259   Benjamin Renard   Add kill plot req...
1049
 * kill plot process
16035364   Benjamin Renard   First commit
1050
 */
10200969   Roipoussiere   Remove whitespace...
1051

735c653b   Elena.Budnik   rank at observato...
1052
	public function killPlotRequest()
10200969   Roipoussiere   Remove whitespace...
1053
	{
735c653b   Elena.Budnik   rank at observato...
1054
1055
		return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
	}
16035364   Benjamin Renard   First commit
1056
1057
1058
1059

/*
 * merge time tables
 */
10200969   Roipoussiere   Remove whitespace...
1060
	public  function merge($obj)
735c653b   Elena.Budnik   rank at observato...
1061
1062
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1063
			$this->amdaStat->addTask( $this->user, 'ttoper', null);
10200969   Roipoussiere   Remove whitespace...
1064

735c653b   Elena.Budnik   rank at observato...
1065
		$objectMgr = new TimeTableMgr();
16035364   Benjamin Renard   First commit
1066

735c653b   Elena.Budnik   rank at observato...
1067
1068
		return  $objectMgr -> merge($obj);
	}
16035364   Benjamin Renard   First commit
1069

10200969   Roipoussiere   Remove whitespace...
1070

16035364   Benjamin Renard   First commit
1071
1072
1073
/*
 * intersect time tables
 */
10200969   Roipoussiere   Remove whitespace...
1074
	public  function intersect($obj)
735c653b   Elena.Budnik   rank at observato...
1075
1076
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1077
				$this->amdaStat->addTask($this->user, 'ttoper', null);
16035364   Benjamin Renard   First commit
1078

735c653b   Elena.Budnik   rank at observato...
1079
1080
		$objectMgr = new TimeTableMgr();
		$result = $objectMgr -> intersect($obj);
16035364   Benjamin Renard   First commit
1081

735c653b   Elena.Budnik   rank at observato...
1082
1083
		return  $result;
	}
10200969   Roipoussiere   Remove whitespace...
1084

0fea5567   Benjamin Renard   First step for re...
1085
	public function initObjectCache($isCatalog = false, $nparams = 1)
735c653b   Elena.Budnik   rank at observato...
1086
1087
1088
	{
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else              $cacheMgr = new CatalogCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1089

0fea5567   Benjamin Renard   First step for re...
1090
		return $cacheMgr->initObjectCache(array('nparams' => $nparams));
735c653b   Elena.Budnik   rank at observato...
1091
	}
10200969   Roipoussiere   Remove whitespace...
1092
1093


342b20ca   Benjamin Renard   Fix inheritence b...
1094
	public function initObjectCacheFromObject($id, $type)
735c653b   Elena.Budnik   rank at observato...
1095
1096
1097
	{
		if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1098

0fea5567   Benjamin Renard   First step for re...
1099
		return $cacheMgr->initFromObject($id, $type);
735c653b   Elena.Budnik   rank at observato...
1100
	}
10200969   Roipoussiere   Remove whitespace...
1101

0fea5567   Benjamin Renard   First step for re...
1102
	public function initObjectCacheFromCatalog($id, $type)
d547a559   Hacene SI HADJ MOHAND   rm_6903 ok
1103
1104
1105
1106
1107
1108
        {
                $cacheMgr = new TimeTableCacheMgr();

                return $cacheMgr->initFromCatalog($id, $type);
        }

19eca0a6   Hacene SI HADJ MOHAND   ok
1109
1110
1111
1112
1113
1114
1115
        public function initObjectCacheFromTimeTable($id, $type, $nparams)
        {
                $cacheMgr = new CatalogCacheMgr();

                return $cacheMgr->initFromTimeTable($id, $nparams);
        }

0fea5567   Benjamin Renard   First step for re...
1116
	public function initObjectCacheFromTmpObject($folderId, $name, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1117
	{
10200969   Roipoussiere   Remove whitespace...
1118
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1119
1120
1121
1122
		else  $cacheMgr = new CatalogCacheMgr();

		return $cacheMgr->initFromTmpObject($folderId, $name);
	}
10200969   Roipoussiere   Remove whitespace...
1123

0fea5567   Benjamin Renard   First step for re...
1124
	public function initObjectCacheFromUploadedFile($name, $format, $isCatalog = false)
735c653b   Elena.Budnik   rank at observato...
1125
	{
901ba3f3   Elena.Budnik   upload catalog
1126
1127
		if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
		else  $cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1128
1129
		return $cacheMgr->initFromUploadedFile($name, $format);
	}
10200969   Roipoussiere   Remove whitespace...
1130

342b20ca   Benjamin Renard   Fix inheritence b...
1131
	public function readCacheIntervals($o)
735c653b   Elena.Budnik   rank at observato...
1132
	{
e57cb025   Benjamin Renard   Fix most of error...
1133
		if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) $cacheMgr = new CatalogCacheMgr();
735c653b   Elena.Budnik   rank at observato...
1134
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1135

e57cb025   Benjamin Renard   Fix most of error...
1136
		return $cacheMgr->getIntervals($o->start,$o->limit,isset($o->sort) ? $o->sort : NULL, isset($o->filter) ? $o->filter : NULL);
735c653b   Elena.Budnik   rank at observato...
1137
	}
10200969   Roipoussiere   Remove whitespace...
1138

735c653b   Elena.Budnik   rank at observato...
1139
1140
	public function readIntervalsForChart($o)
	{
1a0151a5   Benjamin Renard   wip
1141
		$objMgr = new CatalogCacheMgr(TRUE);
b0720b91   Benjamin Renard   Finalize catalog ...
1142
		$objMgr->initFromObject($o->id, $o->type);
1a0151a5   Benjamin Renard   wip
1143
		return $objMgr->getIntervalsForChart();
735c653b   Elena.Budnik   rank at observato...
1144
	}
10200969   Roipoussiere   Remove whitespace...
1145

735c653b   Elena.Budnik   rank at observato...
1146
1147
1148
	public function saveTTCacheIntervalsInTT($o)
	{
		$cacheMgr = new TimeTableCacheMgr();
0fea5567   Benjamin Renard   First step for re...
1149
		return $cacheMgr->saveInObject($o->ttId,$o->action,$o->cacheToken);
735c653b   Elena.Budnik   rank at observato...
1150
	}
10200969   Roipoussiere   Remove whitespace...
1151

342b20ca   Benjamin Renard   Fix inheritence b...
1152
	public function addCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1153
1154
1155
1156
1157
1158
	{
		if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

		return $cacheMgr->addInterval($o->index, $o->start, $o->stop);
	}
10200969   Roipoussiere   Remove whitespace...
1159

735c653b   Elena.Budnik   rank at observato...
1160
1161
1162
1163
1164
1165
1166
	public function removeTTCacheIntervalFromId($id, $isCatalog = false)
	{
		if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
		else $cacheMgr = new TimeTableCacheMgr();

		return $cacheMgr->removeIntervalFromId($id);
	}
10200969   Roipoussiere   Remove whitespace...
1167

342b20ca   Benjamin Renard   Fix inheritence b...
1168
	public function modifyCacheInterval($o)
735c653b   Elena.Budnik   rank at observato...
1169
	{
10200969   Roipoussiere   Remove whitespace...
1170
		if ($o->isCatalog)
735c653b   Elena.Budnik   rank at observato...
1171
		{
f9c8b272   elena   edit catalog
1172
			$cacheMgr = new CatalogCacheMgr();
f9c8b272   elena   edit catalog
1173
		}
735c653b   Elena.Budnik   rank at observato...
1174
		else $cacheMgr = new TimeTableCacheMgr();
10200969   Roipoussiere   Remove whitespace...
1175

342b20ca   Benjamin Renard   Fix inheritence b...
1176
		return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->data);
735c653b   Elena.Budnik   rank at observato...
1177
	}
10200969   Roipoussiere   Remove whitespace...
1178

735c653b   Elena.Budnik   rank at observato...
1179
1180
1181
1182
1183
	public function operationTTCacheIntervals($extendTime, $shiftTime)
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->operationIntervals($extendTime, $shiftTime);
	}
10200969   Roipoussiere   Remove whitespace...
1184

735c653b   Elena.Budnik   rank at observato...
1185
1186
1187
1188
1189
	public function mergeTTCacheIntervals()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->mergeIntervals();
	}
10200969   Roipoussiere   Remove whitespace...
1190

0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1191
	public function getTTCacheStatistics($obj)
735c653b   Elena.Budnik   rank at observato...
1192
	{
0fea5567   Benjamin Renard   First step for re...
1193
                if($obj->name == "timeTableUi"){
0318dbe6   Hacene SI HADJ MOHAND   rm_6998 ok
1194
1195
1196
1197
1198
1199
				$cacheMgr = new TimeTableCacheMgr();
                 }elseif($obj->name == "catalogUI"){
                      $cacheMgr = new CatalogCacheMgr();
                 }else{
                      return array('success' => false, 'message' => 'unkown type: '.$obj->name);
               }
735c653b   Elena.Budnik   rank at observato...
1200
1201
		return $cacheMgr->getStatistics();
	}
10200969   Roipoussiere   Remove whitespace...
1202

735c653b   Elena.Budnik   rank at observato...
1203
1204
1205
1206
1207
	public function getTTCacheStatus()
	{
		$cacheMgr = new TimeTableCacheMgr();
		return $cacheMgr->getStatus();
	}
aa94fd24   elena   Merge with last svn
1208

16035364   Benjamin Renard   First commit
1209
1210
/*
 * Send a feedback
10200969   Roipoussiere   Remove whitespace...
1211
 *
16035364   Benjamin Renard   First commit
1212
 */
735c653b   Elena.Budnik   rank at observato...
1213
1214
1215
1216
1217
	public function sendFeedback($feed)
	{
		$feedMgr = new FeedbackMgr();
		return $feedMgr->addFeedback($feed->user, $feed->interface, $feed->subject, $feed->userText, $feed->userAgent, $feed->attach);
	}
10200969   Roipoussiere   Remove whitespace...
1218

16035364   Benjamin Renard   First commit
1219
1220
/*
 * Save state
10200969   Roipoussiere   Remove whitespace...
1221
 *
16035364   Benjamin Renard   First commit
1222
 */
735c653b   Elena.Budnik   rank at observato...
1223
1224
1225
1226
1227
	public function saveState($datas)
	{
		$myStateMgr = new StateMgr();
		return $myStateMgr->saveState($datas);
	}
10200969   Roipoussiere   Remove whitespace...
1228

16035364   Benjamin Renard   First commit
1229
1230
/*
 * Load state
10200969   Roipoussiere   Remove whitespace...
1231
1232
 *
 */
735c653b   Elena.Budnik   rank at observato...
1233
	public function loadState($o)
10200969   Roipoussiere   Remove whitespace...
1234
	{
735c653b   Elena.Budnik   rank at observato...
1235
1236
1237
		$myStateMgr = new StateMgr();
		return $myStateMgr->loadState();
	}
10200969   Roipoussiere   Remove whitespace...
1238
1239

/*
16035364   Benjamin Renard   First commit
1240
1241
 * HST Images
 */
735c653b   Elena.Budnik   rank at observato...
1242
1243
1244
	public function getHstImagesUrl($o)
	{
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1245
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1246

735c653b   Elena.Budnik   rank at observato...
1247
1248
1249
1250
1251
1252
		$myHstMgr = new HstMgr();
		$res = $myHstMgr->getImagesUrl($o->startTime, $o->stopTime, $o->planet);
		//if ($domRes->length <= 0)
		//	return array('success' => false, 'message' => 'Cannot find HST Images for this request.');
		return array('success' => true, 'result' => $res);
	}
10200969   Roipoussiere   Remove whitespace...
1253

735c653b   Elena.Budnik   rank at observato...
1254
1255
	public function getAPISImagesUrl($o)
	{
10200969   Roipoussiere   Remove whitespace...
1256
		if ($this->amdaStat->success)
2dab1b1b   Elena.Budnik   change input args...
1257
			$this->amdaStat->addTask($this->user, 'images', null);
10200969   Roipoussiere   Remove whitespace...
1258

735c653b   Elena.Budnik   rank at observato...
1259
1260
1261
1262
		$apisMgr = new APISMgr();
		$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);

		return $res;
10200969   Roipoussiere   Remove whitespace...
1263
	}
16035364   Benjamin Renard   First commit
1264
1265
1266
/*
 * Filters
 */
e57cb025   Benjamin Renard   Fix most of error...
1267
	public function loadFilterList()
735c653b   Elena.Budnik   rank at observato...
1268
	{
10200969   Roipoussiere   Remove whitespace...
1269
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1270
1271
1272
		$res = $filtersMgr->loadList();
		return $res;
	}
16035364   Benjamin Renard   First commit
1273

735c653b   Elena.Budnik   rank at observato...
1274
1275
1276
1277
1278
1279
1280
1281
1282
	public function loadFilters($o)
	{
		$filtersMgr = new FiltersMgr();
		if (isset($o->id))
			$res = $filtersMgr->loadFilter($o->id);
		else
			$res = $filtersMgr->loadAll();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1283

735c653b   Elena.Budnik   rank at observato...
1284
1285
	public function saveFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1286
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1287
1288
		return $filtersMgr->save($o);
	}
10200969   Roipoussiere   Remove whitespace...
1289

735c653b   Elena.Budnik   rank at observato...
1290
1291
	public function createFilter($o)
	{
10200969   Roipoussiere   Remove whitespace...
1292
		$filtersMgr = new FiltersMgr();
735c653b   Elena.Budnik   rank at observato...
1293
1294
		return $filtersMgr->create($o);
	}
10200969   Roipoussiere   Remove whitespace...
1295

735c653b   Elena.Budnik   rank at observato...
1296
1297
1298
1299
1300
1301
	public function destroyFilter($o)
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->delete($o);
		return;
	}
10200969   Roipoussiere   Remove whitespace...
1302

735c653b   Elena.Budnik   rank at observato...
1303
1304
1305
1306
1307
1308
1309
	public function getCrtFilterId()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->getCrtId();
		return $res;
	}

fdf1413b   Elena.Budnik   TT download
1310
1311
	public function getCrtFilterResult()
	{
10200969   Roipoussiere   Remove whitespace...
1312
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1313
1314
		return $filtersMgr->getCrtResult();
	}
10200969   Roipoussiere   Remove whitespace...
1315

fdf1413b   Elena.Budnik   TT download
1316
1317
	public function setCrtFilterId($o)
	{
10200969   Roipoussiere   Remove whitespace...
1318
		$filtersMgr = new FiltersMgr();
fdf1413b   Elena.Budnik   TT download
1319
1320
		return $filtersMgr->setCrtId($o->id);
	}
10200969   Roipoussiere   Remove whitespace...
1321

fdf1413b   Elena.Budnik   TT download
1322
1323
1324
1325
1326
1327
	public function resetFilter()
	{
		$filtersMgr = new FiltersMgr();
		$res = $filtersMgr->reset();
		return $res;
	}
10200969   Roipoussiere   Remove whitespace...
1328

16035364   Benjamin Renard   First commit
1329
1330
	public function logout($isGuest)
	{
10200969   Roipoussiere   Remove whitespace...
1331
		if ($isGuest)
735c653b   Elena.Budnik   rank at observato...
1332
		{
fdf1413b   Elena.Budnik   TT download
1333
1334
1335
			$guestMgr = new Guest($this->user);
			$guestMgr->deleteGuest();
		}
10200969   Roipoussiere   Remove whitespace...
1336
		else
735c653b   Elena.Budnik   rank at observato...
1337
		{
fdf1413b   Elena.Budnik   TT download
1338
			$this->cleanUserWS();
10200969   Roipoussiere   Remove whitespace...
1339
		}
16035364   Benjamin Renard   First commit
1340
		return;
10200969   Roipoussiere   Remove whitespace...
1341
	}
16035364   Benjamin Renard   First commit
1342

fdf1413b   Elena.Budnik   TT download
1343
1344
	public function getInfo($obj)
	{
10200969   Roipoussiere   Remove whitespace...
1345
		if (file_exists(HELPPATH.$obj->name))
fdf1413b   Elena.Budnik   TT download
1346
		{
10200969   Roipoussiere   Remove whitespace...
1347
			$content = file_get_contents(HELPPATH.$obj->name);
fdf1413b   Elena.Budnik   TT download
1348
1349
			return  array('success' => true, 'result' => $content);
		}
10200969   Roipoussiere   Remove whitespace...
1350
1351
1352
		return array('success' => false);
	}

fdf1413b   Elena.Budnik   TT download
1353
1354
1355
1356
1357
	public function getUserInfo()
	{
		$dd = new UserMgr();
		return $dd->getUserInfo();
	}
16035364   Benjamin Renard   First commit
1358

fdf1413b   Elena.Budnik   TT download
1359
1360
1361
1362
1363
1364
	// $obj ={"Object":"Earth","RunCount":"2",
	// "SW_Density_value":"10","SW_Density_weight":"1","SW_Density_scale":"7","SW_Temperature_value":"100", ....}
	public function getRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
		$res = $myBestRunsMgr->getRun($obj);
10200969   Roipoussiere   Remove whitespace...
1365
1366

		return  $res;
fdf1413b   Elena.Budnik   TT download
1367
	}
10200969   Roipoussiere   Remove whitespace...
1368
1369

	//$obj = array of IDs
fdf1413b   Elena.Budnik   TT download
1370
1371
1372
	public function addRun($obj)
	{
		$myBestRunsMgr = new BestRunsMgr();
10200969   Roipoussiere   Remove whitespace...
1373

bf74fc2d   Elena.Budnik   IMPEX
1374
		$ok = $myBestRunsMgr->init();
10200969   Roipoussiere   Remove whitespace...
1375

bf74fc2d   Elena.Budnik   IMPEX
1376
1377
		if (!$ok)
			return array('success'=>false,'message'=>'cannot init addRun');
10200969   Roipoussiere   Remove whitespace...
1378

fdf1413b   Elena.Budnik   TT download
1379
		$myBestRunsMgr->addRuns($obj);
10200969   Roipoussiere   Remove whitespace...
1380

bf74fc2d   Elena.Budnik   IMPEX
1381
		return array('success'=>true,'addedRuns'=>$obj);
10200969   Roipoussiere   Remove whitespace...
1382
1383
	}

fdf1413b   Elena.Budnik   TT download
1384
1385
1386
1387
	//AKKA - New action to clean user WS
	public function cleanUserWS()
	{
		$this->rrmdir(USERDIR.'DOWNLOAD.TEMP');
278185de   Benjamin Renard   Upload catalog fr...
1388
		$this->rrmdir(USERDIR.'TEMP');
bf74fc2d   Elena.Budnik   IMPEX
1389
		IHMConfigClass::setUserName($this->user);
10200969   Roipoussiere   Remove whitespace...
1390
1391

		// delete impex params and data
bf74fc2d   Elena.Budnik   IMPEX
1392
1393
		$impexParamMgr = new ImpexParamManager();
		$impexParamMgr->deleteImpexStaff();
10200969   Roipoussiere   Remove whitespace...
1394

e57cb025   Benjamin Renard   Fix most of error...
1395
		$obj = (object) array();
fdf1413b   Elena.Budnik   TT download
1396
1397
		return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSCLEAN);
	}
10200969   Roipoussiere   Remove whitespace...
1398

fdf1413b   Elena.Budnik   TT download
1399
1400
1401
	public function rrmdir($dir){
		if (is_dir($dir)) {
			$objects = scandir($dir);
10200969   Roipoussiere   Remove whitespace...
1402
1403
			foreach ($objects as $object) { // Recursively delete a directory that is not empty and directorys in directory
				if ($object != "." && $object != "..") {  // If object isn't a directory recall recursively this function
fdf1413b   Elena.Budnik   TT download
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
					if (filetype($dir."/".$object) == "dir")
						$this->rrmdir($dir."/".$object);
					else
						unlink($dir."/".$object);
				}
			}
			reset($objects);
			rmdir($dir);
		}
	}

	public function deleteSpecialInfo($name)
	{
10200969   Roipoussiere   Remove whitespace...
1417
		if (file_exists(USERDIR.$name))
fdf1413b   Elena.Budnik   TT download
1418
1419
1420
					unlink(USERDIR.$name);
		return array('success' => true);
	}
10200969   Roipoussiere   Remove whitespace...
1421

46c5751e   Benjamin Renard   Cleanup
1422
	public function interactivePlot($obj)
fdf1413b   Elena.Budnik   TT download
1423
	{
fdf1413b   Elena.Budnik   TT download
1424
1425
		$inputobj = (Object)array(
			'action' => $obj,
fdf1413b   Elena.Budnik   TT download
1426
1427
1428
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
	}
10200969   Roipoussiere   Remove whitespace...
1429

735c653b   Elena.Budnik   rank at observato...
1430
1431
	public function getParamPlotInit($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1432
1433
1434
1435
1436
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_plot_init';
		else
		   $type = 'plot_init';
10200969   Roipoussiere   Remove whitespace...
1437

735c653b   Elena.Budnik   rank at observato...
1438
1439
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
bf74fc2d   Elena.Budnik   IMPEX
1440
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1441
1442
1443
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
10200969   Roipoussiere   Remove whitespace...
1444

735c653b   Elena.Budnik   rank at observato...
1445
1446
	public function getParamInfo($obj)
	{
bf74fc2d   Elena.Budnik   IMPEX
1447
1448
1449
1450
1451
		// IMPEX param
		if (preg_match("#^spase___IMPEX_#",$obj->paramId))
			$type = 'impex_param_info';
		else
		   $type = 'param_info';
10200969   Roipoussiere   Remove whitespace...
1452

735c653b   Elena.Budnik   rank at observato...
1453
1454
		$inputobj = (Object)array(
				'paramId' => $obj->paramId,
2fa56f95   Benjamin Renard   Predefined templa...
1455
				'predefinedArgs' => !empty($obj->predefinedArgs),
bf74fc2d   Elena.Budnik   IMPEX
1456
				'type' => $type
735c653b   Elena.Budnik   rank at observato...
1457
1458
1459
		);
		return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
	}
bf776dc8   Benjamin Renard   working
1460
	public function getDerivedParamInfo($obj)
0fea5567   Benjamin Renard   First step for re...
1461
	{
bf776dc8   Benjamin Renard   working
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
                 $dom = new DomDocument("1.0");
                 $xmlName=USERWSDIR.$this->xmlFiles['derivedParam'];
		 @$dom->load($xmlName);
		 $params=$dom->getElementsByTagName("param");
		 foreach($params as $param)
		 {
                        if($param->hasAttribute("name") && ("ws_" . ($param->getAttribute("name")))==$obj->paramId)
		        {
                         $dim_1=$param->getAttribute("dim_1");
			 $dim_2=$param->getAttribute("dim_2");
		   	 return $this->createDerivedParamInfo($dim_1,$dim_2,$obj->paramId);
		  	}
0fea5567   Benjamin Renard   First step for re...
1474

bf776dc8   Benjamin Renard   working
1475
		}
0fea5567   Benjamin Renard   First step for re...
1476
		return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
bf776dc8   Benjamin Renard   working
1477
	}
0fea5567   Benjamin Renard   First step for re...
1478

22d8d756   Hacene SI HADJ MOHAND   resolu
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
       public function getMyDataParamInfo($obj)
        {
                 $dom = new DomDocument("1.0");
                 $xmlName=USERWSDIR.$this->xmlFiles['derivedParam'];
                 @$dom->load($xmlName);
                 $params=$dom->getElementsByTagName("mydata");
                 foreach($params as $param)
                 {
                        if($param->hasAttribute("name") && ("wsd_" . ($param->getAttribute("name")))==$obj->paramId)
                        {
                         $dim_1=$param->getAttribute("size");
                         $dim_2=1;
                         return $this->createDerivedParamInfo($dim_1,$dim_2,$obj->paramId);
                        }

                }
                return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
        }


bf776dc8   Benjamin Renard   working
1499
1500
1501
1502
1503
1504
	public function createDerivedParamInfo($dim_1,$dim_2,$paramId)
	{
		/* case of constant */
		if($dim_1*$dim_2==1)
		{
		return array('success'=>false,'msg'=>"dim1=1 dim2=1 no arguments for this parameter");
0fea5567   Benjamin Renard   First step for re...
1505
		}elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) )
bf776dc8   Benjamin Renard   working
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
		/* case of vector */
                {

	        $dims=array(
				'dim1'=>$dim_1,
				'dim2'=>$dim_2
			      );

		$compts=array();

		for($i=0;$i<($dim_1*$dim_2);++$i)
			{

			$c=array(

				'index_1'=>($dim_1>$dim_2)?(string)$i:"",
				'index_2'=>($dim_1<$dim_2)?$i:"",
				'name'=>$paramId.'('.$i.')'
				);
			array_push($compts,$c);

			}

		$data=array(
				'dimensions'=>$dims,
				'components'=>$compts
			    );
0fea5567   Benjamin Renard   First step for re...
1533

10200969   Roipoussiere   Remove whitespace...
1534

bf776dc8   Benjamin Renard   working
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
			return array('success'=>true,'data'=>$data);
		}else
		/* case of spectro*/
		{
		  $sizes=array($dim_1,$dim_2);
		  $dims=array(
				'dim1'=>$dim_1,
				'dim2'=>$dim_2
			      );
		$channels=array();
 		$tables=array();
		for($j=0;$j<count($sizes);$j++)
			{
		       $compts=array();
0fea5567   Benjamin Renard   First step for re...
1549

bf776dc8   Benjamin Renard   working
1550
1551
1552
1553
1554
1555
1556
			for($i=0;$i<$sizes[$j];$i++)
				{
				$c=array('min'=>'L' . $i,'max'=>'L' . ($i+1));
				array_push($compts,$c);
				}

			$tab=array(
0fea5567   Benjamin Renard   First step for re...
1557
				'relatedDim'=>'dim' . ($j+1),
bf776dc8   Benjamin Renard   working
1558
1559
1560
1561
1562
1563
1564
1565
1566
				'name'=>'component' . ($j+1),
				'units'=>"",
				'variable'=>"",
				'channels'=>$compts,
				'minmax'=>""
				);

			array_push($tables,$tab);
			}
0fea5567   Benjamin Renard   First step for re...
1567

bf776dc8   Benjamin Renard   working
1568
1569
1570
1571
1572
1573
                  $data=array(
				'dimensions'=>$dims,
				'tables'=>$tables
			     );
		return array('success'=>true,'data'=>$data);
                }
0fea5567   Benjamin Renard   First step for re...
1574

bf776dc8   Benjamin Renard   working
1575
	}
735c653b   Elena.Budnik   rank at observato...
1576
1577
1578
1579
1580
1581
	public function getSharedObjectFolders($obj)
	{
		$mgr = new SharedObjectsMgr();
		$folders = $mgr->getFolders($obj->type);
		return array('success' => true, 'folders' => $folders);
	}
10200969   Roipoussiere   Remove whitespace...
1582

735c653b   Elena.Budnik   rank at observato...
1583
1584
1585
	public function shareObjects($obj)
	{
		$mgr = new SharedObjectsMgr();
10200969   Roipoussiere   Remove whitespace...
1586
		switch ($obj->type)
735c653b   Elena.Budnik   rank at observato...
1587
1588
1589
1590
1591
		{
			case 'timeTable' :
			case 'catalog' :
				$src_object_path = USERTTDIR.$obj->object->id.".xml";
				break;
10200969   Roipoussiere   Remove whitespace...
1592

735c653b   Elena.Budnik   rank at observato...
1593
1594
1595
			default:
				return array('success' => false, 'message' => 'Unknown object type');
		}
10200969   Roipoussiere   Remove whitespace...
1596

735c653b   Elena.Budnik   rank at observato...
1597
1598
1599
		$result = $mgr->add($obj->type, $obj->name, $obj->folder, $src_object_path, $obj->description, $this->user);
		if (!$result['success'])
			return $result;
10200969   Roipoussiere   Remove whitespace...
1600

735c653b   Elena.Budnik   rank at observato...
1601
1602
1603
		$mgr->updateTree();
		return $result;
	}
10200969   Roipoussiere   Remove whitespace...
1604

735c653b   Elena.Budnik   rank at observato...
1605
1606
1607
1608
1609
1610
	public function isSharedObjectNameAlreadyUsed($obj)
	{
		$mgr = new SharedObjectsMgr();
		$alreadyUsed = $mgr->isNameAlreadyUsed($obj->type, $obj->name);
		return array('success' => true, 'alreadyUsed' => $alreadyUsed);
	}
10200969   Roipoussiere   Remove whitespace...
1611

0bda97f3   Benjamin Renard   Fix SAMP export f...
1612
1613
	public function getRequestByProcessId($obj)
	{
0bda97f3   Benjamin Renard   Fix SAMP export f...
1614
1615
		return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST);
	}
2fa56f95   Benjamin Renard   Predefined templa...
1616
1617
1618
1619
1620
1621
1622
1623
1624

	public function parseTemplatedParam($paramTemplateId)
	{
		$args = (Object)array(
			'paramId' => $paramTemplateId,
			'type' => 'param_parse_template'
		);
		return $this->executeRequest($args, FunctionTypeEnumClass::PARAMINFO);
	}
16035364   Benjamin Renard   First commit
1625
1626
}
?>