예제 #1
0
 /**
  * GeoAnalysis@setStatus
  */
 public function setStatus()
 {
     global $WT_TREE;
     $controller = new JsonController();
     $ga_id = Filter::getInteger('ga_id');
     $ga = $this->provider->getGeoAnalysis($ga_id, false);
     $controller->restrictAccess(true && Auth::isManager($WT_TREE) && $ga !== null);
     $status = Filter::getBool('status');
     $res = array('geoanalysis' => $ga->getId(), 'error' => null);
     try {
         $this->provider->setGeoAnalysisStatus($ga, $status);
         $res['status'] = $status;
         Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis ID "' . $ga->getId() . '" has been ' . ($status ? 'enabled' : 'disabled') . '.');
     } catch (\Exception $ex) {
         $res['error'] = $ex->getMessage();
         Log::addErrorLog('Module ' . $this->module->getName() . ' : Geo Analysis ID "' . $ga->getId() . '" could not be ' . ($status ? 'enabled' : 'disabled') . '. Error: ' . $ex->getMessage());
     }
     $controller->pageHeader();
     if ($res['error']) {
         http_response_code(500);
     }
     $controller->encode($res);
 }