Ejemplo n.º 1
0
 /**
  * {inhericDoc}
  * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::deleteTask()
  */
 public function deleteTask($task_name)
 {
     try {
         Database::beginTransaction();
         Database::prepare('DELETE FROM  `##maj_admintasks` WHERE majat_name= :task_name')->execute(array('task_name' => $task_name));
         Database::prepare('DELETE FROM  `##gedcom_setting` WHERE setting_name LIKE :setting_name')->execute(array('setting_name' => 'MAJ_AT_' . $task_name . '%'));
         Database::commit();
         Log::addConfigurationLog('Admin Task ' . $task_name . ' has been deleted from disk - deleting it from DB');
         return true;
     } catch (\Exception $ex) {
         Database::rollback();
         Log::addErrorLog('An error occurred while deleting Admin Task ' . $task_name . '. Exception: ' . $ex->getMessage());
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * Update a geodispersion analysis in the database, in transactional manner.
  * When successful, returns the updated GeoAnalysis object
  *  
  * @param GeoAnalysis $ga
  * @return GeoAnalysis
  */
 public function updateGeoAnalysis(GeoAnalysis $ga)
 {
     try {
         Database::beginTransaction();
         Database::prepare('UPDATE `##maj_geodispersion`' . ' SET majgd_descr = :description,' . ' majgd_sublevel = :analysis_level,' . ' majgd_map = :map,' . ' majgd_toplevel = :map_top_level,' . ' majgd_useflagsgen = :use_flags,' . ' majgd_detailsgen = :gen_details' . ' WHERE majgd_file = :gedcom_id AND majgd_id = :ga_id')->execute(array('gedcom_id' => $this->tree->getTreeId(), 'ga_id' => $ga->getId(), 'description' => $ga->getTitle(), 'analysis_level' => $ga->getAnalysisLevel(), 'use_flags' => $ga->getOptions() && $ga->getOptions()->isUsingFlags() ? 'yes' : 'no', 'gen_details' => $ga->getOptions() ? $ga->getOptions()->getMaxDetailsInGen() : 0, 'map' => $ga->hasMap() ? $ga->getOptions()->getMap()->getFileName() : null, 'map_top_level' => $ga->hasMap() ? $ga->getOptions()->getMapLevel() : -100));
         $ga = $this->getGeoAnalysis($ga->getId(), false);
         Database::commit();
     } catch (\Exception $ex) {
         Database::rollback();
         Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: ' . $ex->getMessage());
         $ga = null;
     }
     return $ga;
 }