HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
SiteDelete.php
Go to the documentation of this file.
1 <?php
2 
7 class SiteDelete
8 {
9  protected $opLog = 'SITE_DELETE';
10  protected $operation = 'Delete';
11 
21  public function commandDelete($id, $type)
22  {
23  $this->operation = "Delete";
24  $json = array(
25  'id' => $id,
26  'taskType' => (int)$type
27  );
28  Logger::log("Opertion ->SITE_DELETE", false);
29  Logger::log("Request ->\n" . print_r($json, true), false);
30  $json = CJSON::encode($json);
31  $resFile = tempnam(Yii::app()->getBasePath() . '/json_temp', '');
32  $response = fopen($resFile, "w");
33  fwrite($response, $json);
34  fclose($response);
35  $api = Yii::app()->params['api'];
36  $path = Yii::app()->getBasePath() . '/shell/';
37  $cmd = "sh " . $path . "site_delete.sh $api $resFile";
38  $json = shell_exec($cmd);
39  $error = Errors::isError($json);
40  if ($error !== 0) {
41  Yii::app()->user->setFlash('error1', $this->operation . ' ERROR: ' . $error);
42  } else {
43  Yii::app()->user->setFlash('success1', $this->operation . ': SUCCESS');
44  }
45  Logger::log("Response >>>" . $json);
46  unlink($resFile);
47 
48  $UsersSitesRights = new UsersSitesRights();
49  $UsersSitesRights->setRightsSingleRecord(
50  array(
51  'userId' => Yii::app()->user->id,
52  'siteId' => $id,
53  'rights' => array()
54  )
55  );
56 
57  return true;
58  }
59 }