Code Duplication    Length = 29-29 lines in 2 locations

src/Webtrees/Module/AdminTasks/TaskController.php 1 location

@@ 80-108 (lines=29) @@
77
	/**
78
	 * Task@setStatus
79
	 */
80
    public function setStatus() {          
81
        $controller = new JsonController();
82
        
83
        $task_name = Filter::get('task');
84
        $task = $this->provider->getTask($task_name, false);
85
        
86
        $controller->restrictAccess(
87
            true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
88
            &&  Auth::isAdmin() 
89
            && $task
90
        );
91
        
92
        $status = Filter::getBool('status');
93
        $res = array('task' => $task->getName() , 'error' => null);
94
        try{
95
            $this->provider->setTaskStatus($task, $status);
96
            $res['status'] = $status;
97
			Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.');
98
        }
99
        catch (\Exception $ex) {
100
            $res['error'] = $ex->getMessage();
101
			Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage());
102
        }
103
        
104
        $controller->pageHeader();
105
        if($res['error']) http_response_code(500);
106
        
107
        $controller->encode($res);
108
    }
109
	
110
	/**
111
	 * Task@edit

src/Webtrees/Module/GeoDispersion/GeoAnalysisController.php 1 location

@@ 129-157 (lines=29) @@
126
	/**
127
	 * GeoAnalysis@setStatus
128
	 */
129
    public function setStatus() {
130
        $controller = new JsonController();
131
        
132
        $ga_id = Filter::getInteger('ga_id');
133
        $ga = $this->provider->getGeoAnalysis($ga_id, false);
134
        
135
        $controller->restrictAccess(
136
            true // Filter::checkCsrf()   -- Cannot use CSRF on a GET request (modules can only work with GET requests)
137
            &&  Auth::isManager(Globals::getTree()) 
138
            && $ga !== null
139
        );
140
        
141
        $status = Filter::getBool('status');
142
        $res = array('geoanalysis' => $ga->getId() , 'error' => null);
143
        try{
144
            $this->provider->setGeoAnalysisStatus($ga, $status);
145
            $res['status'] = $status;
146
			Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.');
147
        }
148
        catch (\Exception $ex) {
149
            $res['error'] = $ex->getMessage();
150
			Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage());
151
        }
152
        
153
        $controller->pageHeader();
154
        if($res['error']) http_response_code(500);
155
        
156
        $controller->encode($res);
157
    }
158
    
159
	/**
160
     * GeoAnalysis@delete