| @@ -61,7 +61,7 @@ | ||
| 61 | 61 | * @return string $WT_RAPHAEL_JS_URL | 
| 62 | 62 | */ | 
| 63 | 63 |  	public static function WT_RAPHAEL_JS_URL() { | 
| 64 | - return WT_STATIC_URL . 'packages/raphael-2.1.4/raphael-min.js'; | |
| 64 | + return WT_STATIC_URL.'packages/raphael-2.1.4/raphael-min.js'; | |
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | 67 | } | 
| 68 | 68 | \ No newline at end of file | 
| @@ -30,11 +30,16 @@ | ||
| 30 | 30 | $place_id = 0; | 
| 31 | 31 |  			for ($i=0; $i<count($parent); $i++) { | 
| 32 | 32 | $parent[$i] = trim($parent[$i]); | 
| 33 | - if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , , | |
| 33 | +				if (empty($parent[$i])) { | |
| 34 | + $parent[$i]='unknown'; | |
| 35 | + } | |
| 36 | + // GoogleMap module uses "unknown" while GEDCOM uses , , | |
| 34 | 37 |  				$pl_id=Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') | 
| 35 | 38 | ->execute(array($i, $place_id, $parent[$i])) | 
| 36 | 39 | ->fetchOne(); | 
| 37 | - if (empty($pl_id)) break; | |
| 40 | +				if (empty($pl_id)) { | |
| 41 | + break; | |
| 42 | + } | |
| 38 | 43 | $place_id = $pl_id; | 
| 39 | 44 | } | 
| 40 | 45 | return $place_id; | 
| @@ -25,14 +25,14 @@ discard block | ||
| 25 | 25 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getProviderPlaceId() | 
| 26 | 26 | */ | 
| 27 | 27 |  	public function getProviderPlaceId(\Fisharebest\Webtrees\Place $place) { | 
| 28 | -		if(!$place->isEmpty()) { | |
| 29 | -			$parent = explode (',', $place->getGedcomName()); | |
| 28 | +		if (!$place->isEmpty()) { | |
| 29 | +			$parent = explode(',', $place->getGedcomName()); | |
| 30 | 30 | $place_id = 0; | 
| 31 | 31 | $nb_levels = count($parent); | 
| 32 | -			for ($i=0; $i < $nb_levels; $i++) { | |
| 32 | +			for ($i = 0; $i < $nb_levels; $i++) { | |
| 33 | 33 | $parent[$i] = trim($parent[$i]); | 
| 34 | - if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , , | |
| 35 | -				$pl_id=Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') | |
| 34 | + if (empty($parent[$i])) $parent[$i] = 'unknown'; // GoogleMap module uses "unknown" while GEDCOM uses , , | |
| 35 | +				$pl_id = Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') | |
| 36 | 36 | ->execute(array($i, $place_id, $parent[$i])) | 
| 37 | 37 | ->fetchOne(); | 
| 38 | 38 | if (empty($pl_id)) break; | 
| @@ -48,12 +48,12 @@ discard block | ||
| 48 | 48 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getPlaceIcon() | 
| 49 | 49 | */ | 
| 50 | 50 |  	public function getPlaceIcon(\Fisharebest\Webtrees\Place $place) { | 
| 51 | -		if(!$place->isEmpty()){ | |
| 51 | +		if (!$place->isEmpty()) { | |
| 52 | 52 | $place_details = | 
| 53 | 53 |  				Database::prepare("SELECT SQL_CACHE pl_icon FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place")	 | 
| 54 | 54 | ->execute(array($this->getProviderPlaceId($place))) | 
| 55 | 55 | ->fetchOneRow(); | 
| 56 | -			if($place_details){ | |
| 56 | +			if ($place_details) { | |
| 57 | 57 | return WT_MODULES_DIR.'googlemap/'.$place_details->pl_icon; | 
| 58 | 58 | } | 
| 59 | 59 | } | 
| @@ -61,7 +61,7 @@ discard block | ||
| 61 | 61 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtender::hExtendIndiHeaderIcons() | 
| 62 | 62 | */ | 
| 63 | 63 |  	public function hExtendIndiHeaderIcons(IndividualController $ctrlIndi) { | 
| 64 | -	    if($ctrlIndi){ | |
| 64 | +	    if ($ctrlIndi) { | |
| 65 | 65 | $dindi = new Individual($ctrlIndi->getSignificantIndividual()); | 
| 66 | 66 | if ($dindi->canDisplayIsSourced()) | 
| 67 | 67 |  	            return FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, 'large'); | 
| @@ -85,19 +85,19 @@ discard block | ||
| 85 | 85 |  	 * {@inheritDoc} | 
| 86 | 86 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\RecordNameTextExtender::hRecordNamePrepend() | 
| 87 | 87 | */ | 
| 88 | -	public function hRecordNamePrepend(GedcomRecord $grec){ } | |
| 88 | +	public function hRecordNamePrepend(GedcomRecord $grec) { } | |
| 89 | 89 | |
| 90 | 90 | /** | 
| 91 | 91 |  	 * {@inheritDoc} | 
| 92 | 92 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\RecordNameTextExtender::hRecordNameAppend() | 
| 93 | 93 | */ | 
| 94 | -	public function hRecordNameAppend(GedcomRecord $grec){ | |
| 94 | +	public function hRecordNameAppend(GedcomRecord $grec) { | |
| 95 | 95 | $html = ''; | 
| 96 | -	    if($grec instanceof \Fisharebest\Webtrees\Individual){ | |
| 96 | +	    if ($grec instanceof \Fisharebest\Webtrees\Individual) { | |
| 97 | 97 | $dindi = new Individual($grec); | 
| 98 | 98 |  	        $html .= FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, 'small'); | 
| 99 | 99 |  	        $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isBirthSourced(), 'BIRT', 1, 'small'); | 
| 100 | - if($grec->isDead()) | |
| 100 | + if ($grec->isDead()) | |
| 101 | 101 |  	            $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1, 'small'); | 
| 102 | 102 | } | 
| 103 | 103 | return $html; | 
| @@ -115,7 +115,7 @@ discard block | ||
| 115 | 115 |  	 * {@inheritDoc} | 
| 116 | 116 | * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent() | 
| 117 | 117 | */ | 
| 118 | -	public function hasSidebarContent(){  | |
| 118 | +	public function hasSidebarContent() {  | |
| 119 | 119 | return true; | 
| 120 | 120 | } | 
| 121 | 121 | |
| @@ -145,24 +145,24 @@ discard block | ||
| 145 | 145 | echo ' | 
| 146 | 146 | <table class="issourcedtable"> | 
| 147 | 147 | <tr> | 
| 148 | -	                       <td class="slabel"> ' . GedcomTag::getLabel('INDI') . '</td> | |
| 148 | +	                       <td class="slabel"> ' . GedcomTag::getLabel('INDI').'</td> | |
| 149 | 149 |  	                       <td class="svalue">' . FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1).'</td> | 
| 150 | 150 | </tr> | 
| 151 | 151 | <tr> | 
| 152 | -	                       <td class="slabel">' . GedcomTag::getLabel('BIRT') . '</td> | |
| 152 | +	                       <td class="slabel">' . GedcomTag::getLabel('BIRT').'</td> | |
| 153 | 153 |  	                       <td class="svalue">' . FunctionsPrint::formatIsSourcedIcon('E', $dindi->isBirthSourced(), 'BIRT', 1).'</td> | 
| 154 | 154 | </tr>'; | 
| 155 | 155 | |
| 156 | 156 | $fams = $root->getSpouseFamilies(); | 
| 157 | - ($ct = count($fams)) > 1 ? $nb=1 : $nb=' '; | |
| 158 | -	            foreach($fams as $fam){ | |
| 157 | + ($ct = count($fams)) > 1 ? $nb = 1 : $nb = ' '; | |
| 158 | +	            foreach ($fams as $fam) { | |
| 159 | 159 | $dfam = new Family($fam); | 
| 160 | 160 | echo ' | 
| 161 | 161 | <tr> | 
| 162 | 162 | <td class="slabel right"> | 
| 163 | -	                           <a href="' . $fam->getHtmlUrl() . '"> '. GedcomTag::getLabel('MARR'); | |
| 164 | -	                if($ct > 1){ | |
| 165 | - echo ' ',$nb; | |
| 163 | +	                           <a href="' . $fam->getHtmlUrl().'"> '.GedcomTag::getLabel('MARR'); | |
| 164 | +	                if ($ct > 1) { | |
| 165 | + echo ' ', $nb; | |
| 166 | 166 | $nb++; | 
| 167 | 167 | } | 
| 168 | 168 | echo ' </a> | 
| @@ -171,10 +171,10 @@ discard block | ||
| 171 | 171 | </tr>'; | 
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | - if( $root->isDead() ) | |
| 174 | + if ($root->isDead()) | |
| 175 | 175 | echo ' | 
| 176 | 176 | <tr> | 
| 177 | -	                       <td class="slabel">' . GedcomTag::getLabel('DEAT') . '</td> | |
| 177 | +	                       <td class="slabel">' . GedcomTag::getLabel('DEAT').'</td> | |
| 178 | 178 |  	                       <td class="svalue">' . FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1).'</td> | 
| 179 | 179 | </tr>'; | 
| 180 | 180 | |
| @@ -63,8 +63,9 @@ discard block | ||
| 63 | 63 |  	public function hExtendIndiHeaderIcons(IndividualController $ctrlIndi) { | 
| 64 | 64 |  	    if($ctrlIndi){ | 
| 65 | 65 | $dindi = new Individual($ctrlIndi->getSignificantIndividual()); | 
| 66 | - if ($dindi->canDisplayIsSourced()) | |
| 67 | -	            return FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, 'large'); | |
| 66 | +	        if ($dindi->canDisplayIsSourced()) { | |
| 67 | +	        	            return FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, 'large'); | |
| 68 | + } | |
| 68 | 69 | } | 
| 69 | 70 | return ''; | 
| 70 | 71 | } | 
| @@ -97,8 +98,9 @@ discard block | ||
| 97 | 98 | $dindi = new Individual($grec); | 
| 98 | 99 |  	        $html .= FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, 'small'); | 
| 99 | 100 |  	        $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isBirthSourced(), 'BIRT', 1, 'small'); | 
| 100 | - if($grec->isDead()) | |
| 101 | -	            $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1, 'small'); | |
| 101 | +	        if($grec->isDead()) { | |
| 102 | +	        	            $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1, 'small'); | |
| 103 | + } | |
| 102 | 104 | } | 
| 103 | 105 | return $html; | 
| 104 | 106 | } | 
| @@ -171,12 +173,13 @@ discard block | ||
| 171 | 173 | </tr>'; | 
| 172 | 174 | } | 
| 173 | 175 | |
| 174 | - if( $root->isDead() ) | |
| 175 | - echo ' | |
| 176 | +	            if( $root->isDead() ) { | |
| 177 | + echo ' | |
| 176 | 178 | <tr> | 
| 177 | 179 |  	                       <td class="slabel">' . GedcomTag::getLabel('DEAT') . '</td> | 
| 178 | 180 |  	                       <td class="svalue">' . FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1).'</td> | 
| 179 | 181 | </tr>'; | 
| 182 | + } | |
| 180 | 183 | |
| 181 | 184 | echo '</table>'; | 
| 182 | 185 | } | 
| @@ -69,7 +69,7 @@ discard block | ||
| 69 | 69 | |
| 70 | 70 | $tasks = $this->provider->getTasksToRun($token == $token_submitted, $task_name); | 
| 71 | 71 | |
| 72 | -		foreach($tasks as $task) { | |
| 72 | +		foreach ($tasks as $task) { | |
| 73 | 73 | $task->execute(); | 
| 74 | 74 | } | 
| 75 | 75 | } | 
| @@ -90,19 +90,19 @@ discard block | ||
| 90 | 90 | ); | 
| 91 | 91 | |
| 92 | 92 |          $status = Filter::getBool('status'); | 
| 93 | -        $res = array('task' => $task->getName() , 'error' => null); | |
| 94 | -        try{ | |
| 93 | +        $res = array('task' => $task->getName(), 'error' => null); | |
| 94 | +        try { | |
| 95 | 95 | $this->provider->setTaskStatus($task, $status); | 
| 96 | 96 | $res['status'] = $status; | 
| 97 | -			Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); | |
| 97 | +			Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '.($status ? 'enabled' : 'disabled').'.'); | |
| 98 | 98 | } | 
| 99 | 99 |          catch (\Exception $ex) { | 
| 100 | 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()); | |
| 101 | +			Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); | |
| 102 | 102 | } | 
| 103 | 103 | |
| 104 | 104 | $controller->pageHeader(); | 
| 105 | - if($res['error']) http_response_code(500); | |
| 105 | + if ($res['error']) http_response_code(500); | |
| 106 | 106 | |
| 107 | 107 | echo \Zend_Json::encode($res); | 
| 108 | 108 | } | 
| @@ -139,9 +139,9 @@ discard block | ||
| 139 | 139 | |
| 140 | 140 | $data = new ViewBag(); | 
| 141 | 141 |          $data->set('title', $controller->getPageTitle()); | 
| 142 | -		$data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); | |
| 142 | +		$data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$WT_TREE->getNameUrl()); | |
| 143 | 143 |          $data->set('module_title', $this->module->getTitle()); | 
| 144 | -		$data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $WT_TREE->getNameUrl()); | |
| 144 | +		$data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=Task@save&ged='.$WT_TREE->getNameUrl()); | |
| 145 | 145 |  		$data->set('task', $task); | 
| 146 | 146 | |
| 147 | 147 |          ViewFactory::make('TaskEdit', $this, $controller, $data)->render();	 | 
| @@ -158,17 +158,17 @@ discard block | ||
| 158 | 158 | && Filter::checkCsrf() | 
| 159 | 159 | ); | 
| 160 | 160 | |
| 161 | -		$task_name      = Filter::post('task'); | |
| 162 | -        $frequency    	= Filter::postInteger('frequency'); | |
| 163 | -        $is_limited  	= Filter::postInteger('is_limited', 0, 1); | |
| 164 | -        $nb_occur       = Filter::postInteger('nb_occur'); | |
| 161 | +		$task_name = Filter::post('task'); | |
| 162 | +        $frequency = Filter::postInteger('frequency'); | |
| 163 | +        $is_limited = Filter::postInteger('is_limited', 0, 1); | |
| 164 | +        $nb_occur = Filter::postInteger('nb_occur'); | |
| 165 | 165 | |
| 166 | 166 | $task = $this->provider->getTask($task_name, false); | 
| 167 | 167 | |
| 168 | 168 | $success = false; | 
| 169 | -        if($task) { | |
| 169 | +        if ($task) { | |
| 170 | 170 | $task->setFrequency($frequency); | 
| 171 | -			if($is_limited == 1) { | |
| 171 | +			if ($is_limited == 1) { | |
| 172 | 172 | $task->setRemainingOccurrences($nb_occur); | 
| 173 | 173 | } | 
| 174 | 174 |  			else { | 
| @@ -177,34 +177,34 @@ discard block | ||
| 177 | 177 | |
| 178 | 178 | $res = $task->save(); | 
| 179 | 179 | |
| 180 | -			if($res) {						 | |
| 181 | -				if($task instanceof MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface) { | |
| 180 | +			if ($res) {						 | |
| 181 | +				if ($task instanceof MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface) { | |
| 182 | 182 | $res = $task->saveConfig(); | 
| 183 | 183 | |
| 184 | -					if(!$res) { | |
| 184 | +					if (!$res) { | |
| 185 | 185 |  						FlashMessages::addMessage(I18N::translate('An error occured while updating the specific settings of administrative task ā%sā', $task->getTitle()), 'danger'); | 
| 186 | -						Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'. $task->getName() .'ā specific settings could not be updated. See error log.'); | |
| 186 | +						Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'.$task->getName().'ā specific settings could not be updated. See error log.'); | |
| 187 | 187 | } | 
| 188 | 188 | } | 
| 189 | 189 | |
| 190 | -				if($res) { | |
| 190 | +				if ($res) { | |
| 191 | 191 |  					FlashMessages::addMessage(I18N::translate('The administrative task ā%sā has been successfully updated', $task->getTitle()), 'success'); | 
| 192 | -					Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'.$task->getName() .'ā has been updated.'); | |
| 192 | +					Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'.$task->getName().'ā has been updated.'); | |
| 193 | 193 | $success = true; | 
| 194 | 194 | } | 
| 195 | 195 | } | 
| 196 | 196 |  			else { | 
| 197 | 197 |  				FlashMessages::addMessage(I18N::translate('An error occured while updating the administrative task ā%sā', $task->getTitle()), 'danger'); | 
| 198 | -				Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'. $task->getName() .'ā could not be updated. See error log.'); | |
| 198 | +				Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'.$task->getName().'ā could not be updated. See error log.'); | |
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | 201 | } | 
| 202 | 202 | |
| 203 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; | |
| 204 | -        if(!$success) { | |
| 205 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task='. $task->getName(); | |
| 203 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig'; | |
| 204 | +        if (!$success) { | |
| 205 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='.$task->getName(); | |
| 206 | 206 | } | 
| 207 | -        header('Location: ' . WT_BASE_URL . $redirection_url); | |
| 207 | +        header('Location: '.WT_BASE_URL.$redirection_url); | |
| 208 | 208 | } | 
| 209 | 209 | |
| 210 | 210 | } | 
| 211 | 211 | \ No newline at end of file | 
| @@ -95,14 +95,15 @@ discard block | ||
| 95 | 95 | $this->provider->setTaskStatus($task, $status); | 
| 96 | 96 | $res['status'] = $status; | 
| 97 | 97 |  			Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); | 
| 98 | - } | |
| 99 | -        catch (\Exception $ex) { | |
| 98 | +        } catch (\Exception $ex) { | |
| 100 | 99 | $res['error'] = $ex->getMessage(); | 
| 101 | 100 |  			Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); | 
| 102 | 101 | } | 
| 103 | 102 | |
| 104 | 103 | $controller->pageHeader(); | 
| 105 | - if($res['error']) http_response_code(500); | |
| 104 | +        if($res['error']) { | |
| 105 | + http_response_code(500); | |
| 106 | + } | |
| 106 | 107 | |
| 107 | 108 | echo \Zend_Json::encode($res); | 
| 108 | 109 | } | 
| @@ -170,8 +171,7 @@ discard block | ||
| 170 | 171 | $task->setFrequency($frequency); | 
| 171 | 172 |  			if($is_limited == 1) { | 
| 172 | 173 | $task->setRemainingOccurrences($nb_occur); | 
| 173 | - } | |
| 174 | -			else { | |
| 174 | +			} else { | |
| 175 | 175 | $task->setRemainingOccurrences(0); | 
| 176 | 176 | } | 
| 177 | 177 | |
| @@ -192,8 +192,7 @@ discard block | ||
| 192 | 192 |  					Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'.$task->getName() .'ā has been updated.'); | 
| 193 | 193 | $success = true; | 
| 194 | 194 | } | 
| 195 | - } | |
| 196 | -			else { | |
| 195 | +			} else { | |
| 197 | 196 |  				FlashMessages::addMessage(I18N::translate('An error occured while updating the administrative task ā%sā', $task->getTitle()), 'danger'); | 
| 198 | 197 |  				Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask ā'. $task->getName() .'ā could not be updated. See error log.'); | 
| 199 | 198 | } | 
| @@ -236,7 +236,9 @@ discard block | ||
| 236 | 236 | * @return bool | 
| 237 | 237 | */ | 
| 238 | 238 |  	public function save() { | 
| 239 | -	    if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); | |
| 239 | +	    if(!$this->provider) { | |
| 240 | +	    	throw new \Exception('The task has not been initialised with a provider.'); | |
| 241 | + } | |
| 240 | 242 | return $this->provider->updateTask($this); | 
| 241 | 243 | } | 
| 242 | 244 | |
| @@ -246,8 +248,9 @@ discard block | ||
| 246 | 248 | */ | 
| 247 | 249 |      public function execute(){ | 
| 248 | 250 | |
| 249 | -        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) | |
| 250 | - $this->is_running = false; | |
| 251 | +        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) { | |
| 252 | + $this->is_running = false; | |
| 253 | + } | |
| 251 | 254 | |
| 252 | 255 |          if(!$this->is_running){  //TODO put in place a time_out for running... | 
| 253 | 256 | //TODO Log the executions in the logs | 
| @@ -261,7 +264,9 @@ discard block | ||
| 261 | 264 | $this->last_updated = new \DateTime(); | 
| 262 | 265 |                  if($this->nb_occurrences > 0){ | 
| 263 | 266 | $this->nb_occurrences--; | 
| 264 | - if($this->nb_occurrences == 0) $this->is_enabled = false; | |
| 267 | +                    if($this->nb_occurrences == 0) { | |
| 268 | + $this->is_enabled = false; | |
| 269 | + } | |
| 265 | 270 | } | 
| 266 | 271 | } | 
| 267 | 272 | $this->is_running = false; | 
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | * @param string $file Filename containing the task object | 
| 81 | 81 | * @param TaskProviderInterface $provider Provider for tasks | 
| 82 | 82 | */ | 
| 83 | -    public function __construct($file, TaskProviderInterface $provider = null){ | |
| 83 | +    public function __construct($file, TaskProviderInterface $provider = null) { | |
| 84 | 84 | $this->name = trim(basename($file, '.php')); | 
| 85 | 85 | $this->provider = $provider; | 
| 86 | 86 | } | 
| @@ -90,7 +90,7 @@ discard block | ||
| 90 | 90 | * | 
| 91 | 91 | * @return TaskProviderInterface | 
| 92 | 92 | */ | 
| 93 | -    public function getProvider(){ | |
| 93 | +    public function getProvider() { | |
| 94 | 94 | return $this->provider; | 
| 95 | 95 | } | 
| 96 | 96 | |
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 | * @param TaskProviderInterface $provider | 
| 101 | 101 | * @return self Enable method-chaining | 
| 102 | 102 | */ | 
| 103 | -    public function setProvider(TaskProviderInterface $provider){ | |
| 103 | +    public function setProvider(TaskProviderInterface $provider) { | |
| 104 | 104 | $this->provider = $provider; | 
| 105 | 105 | return $this; | 
| 106 | 106 | } | 
| @@ -115,7 +115,7 @@ discard block | ||
| 115 | 115 | * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited | 
| 116 | 116 | * @param bool $is_running Indicates if the task is currently running | 
| 117 | 117 | */ | 
| 118 | -    public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ | |
| 118 | +    public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running) { | |
| 119 | 119 | $this->is_enabled = $is_enabled; | 
| 120 | 120 | $this->last_updated = $last_updated; | 
| 121 | 121 | $this->last_result = $last_result; | 
| @@ -129,7 +129,7 @@ discard block | ||
| 129 | 129 | * | 
| 130 | 130 | * @return string | 
| 131 | 131 | */ | 
| 132 | -    public function getName(){ | |
| 132 | +    public function getName() { | |
| 133 | 133 | return $this->name; | 
| 134 | 134 | } | 
| 135 | 135 | |
| @@ -139,7 +139,7 @@ discard block | ||
| 139 | 139 | * | 
| 140 | 140 | * @return boolean True if enabled | 
| 141 | 141 | */ | 
| 142 | -    public function isEnabled(){ | |
| 142 | +    public function isEnabled() { | |
| 143 | 143 | return $this->is_enabled; | 
| 144 | 144 | } | 
| 145 | 145 | |
| @@ -148,7 +148,7 @@ discard block | ||
| 148 | 148 | * | 
| 149 | 149 | * @return \DateTime | 
| 150 | 150 | */ | 
| 151 | -    public function getLastUpdated(){ | |
| 151 | +    public function getLastUpdated() { | |
| 152 | 152 | return $this->last_updated; | 
| 153 | 153 | } | 
| 154 | 154 | |
| @@ -157,7 +157,7 @@ discard block | ||
| 157 | 157 | * | 
| 158 | 158 | * @return bool | 
| 159 | 159 | */ | 
| 160 | -    public function isLastRunSuccess(){ | |
| 160 | +    public function isLastRunSuccess() { | |
| 161 | 161 | return $this->last_result; | 
| 162 | 162 | } | 
| 163 | 163 | |
| @@ -166,7 +166,7 @@ discard block | ||
| 166 | 166 | * | 
| 167 | 167 | * @return int | 
| 168 | 168 | */ | 
| 169 | -    public function getFrequency(){ | |
| 169 | +    public function getFrequency() { | |
| 170 | 170 | return $this->frequency; | 
| 171 | 171 | } | 
| 172 | 172 | |
| @@ -176,7 +176,7 @@ discard block | ||
| 176 | 176 | * @param int $frequency | 
| 177 | 177 | * @return self Enable method-chaining | 
| 178 | 178 | */ | 
| 179 | -    public function setFrequency($frequency){ | |
| 179 | +    public function setFrequency($frequency) { | |
| 180 | 180 | $this->frequency = $frequency; | 
| 181 | 181 | return $this; | 
| 182 | 182 | } | 
| @@ -186,7 +186,7 @@ discard block | ||
| 186 | 186 | * | 
| 187 | 187 | * @return int | 
| 188 | 188 | */ | 
| 189 | -    public function getRemainingOccurrences(){ | |
| 189 | +    public function getRemainingOccurrences() { | |
| 190 | 190 | return $this->nb_occurrences; | 
| 191 | 191 | } | 
| 192 | 192 | |
| @@ -196,7 +196,7 @@ discard block | ||
| 196 | 196 | * @param int $nb_occur | 
| 197 | 197 | * @return self Enable method-chaining | 
| 198 | 198 | */ | 
| 199 | -    public function setRemainingOccurrences($nb_occur){ | |
| 199 | +    public function setRemainingOccurrences($nb_occur) { | |
| 200 | 200 | $this->nb_occurrences = $nb_occur; | 
| 201 | 201 | return $this; | 
| 202 | 202 | } | 
| @@ -206,7 +206,7 @@ discard block | ||
| 206 | 206 | * | 
| 207 | 207 | * @return bool | 
| 208 | 208 | */ | 
| 209 | -    public function isRunning(){ | |
| 209 | +    public function isRunning() { | |
| 210 | 210 | return $this->is_running; | 
| 211 | 211 | } | 
| 212 | 212 | |
| @@ -235,7 +235,7 @@ discard block | ||
| 235 | 235 | * @return bool | 
| 236 | 236 | */ | 
| 237 | 237 |  	public function save() { | 
| 238 | -	    if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); | |
| 238 | +	    if (!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); | |
| 239 | 239 | return $this->provider->updateTask($this); | 
| 240 | 240 | } | 
| 241 | 241 | |
| @@ -243,23 +243,23 @@ discard block | ||
| 243 | 243 | * Execute the task, default skeleton | 
| 244 | 244 | * | 
| 245 | 245 | */ | 
| 246 | -    public function execute(){ | |
| 246 | +    public function execute() { | |
| 247 | 247 | |
| 248 | -        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) | |
| 248 | +        if ($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) | |
| 249 | 249 | $this->is_running = false; | 
| 250 | 250 | |
| 251 | -        if(!$this->is_running){ | |
| 251 | +        if (!$this->is_running) { | |
| 252 | 252 | $this->last_result = false; | 
| 253 | 253 | $this->is_running = true; | 
| 254 | 254 | $this->save(); | 
| 255 | 255 | |
| 256 | 256 |              Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); | 
| 257 | 257 | $this->last_result = $this->executeSteps(); | 
| 258 | -            if($this->last_result){ | |
| 258 | +            if ($this->last_result) { | |
| 259 | 259 | $this->last_updated = new \DateTime(); | 
| 260 | -                if($this->nb_occurrences > 0){ | |
| 260 | +                if ($this->nb_occurrences > 0) { | |
| 261 | 261 | $this->nb_occurrences--; | 
| 262 | - if($this->nb_occurrences == 0) $this->is_enabled = false; | |
| 262 | + if ($this->nb_occurrences == 0) $this->is_enabled = false; | |
| 263 | 263 | } | 
| 264 | 264 | } | 
| 265 | 265 | $this->is_running = false; | 
| @@ -42,15 +42,15 @@ discard block | ||
| 42 | 42 | */ | 
| 43 | 43 |  	protected function loadTask($task_name) { | 
| 44 | 44 |  		try { | 
| 45 | -			if (file_exists($this->root_path . $task_name .'.php')) { | |
| 46 | - $task = include $this->root_path . $task_name .'.php'; | |
| 47 | -				if($task instanceof AbstractTask) { | |
| 45 | +			if (file_exists($this->root_path.$task_name.'.php')) { | |
| 46 | + $task = include $this->root_path.$task_name.'.php'; | |
| 47 | +				if ($task instanceof AbstractTask) { | |
| 48 | 48 | $task->setProvider($this); | 
| 49 | 49 | return $task; | 
| 50 | 50 | } | 
| 51 | 51 | } | 
| 52 | 52 | } | 
| 53 | -		catch(\Exception $ex) { } | |
| 53 | +		catch (\Exception $ex) { } | |
| 54 | 54 | |
| 55 | 55 | return null; | 
| 56 | 56 | } | 
| @@ -72,7 +72,7 @@ discard block | ||
| 72 | 72 |      protected function loadTaskFromRow($row) { | 
| 73 | 73 | $task = $this->loadTask($row['majat_name']); | 
| 74 | 74 | |
| 75 | -		if($task) { | |
| 75 | +		if ($task) { | |
| 76 | 76 | $task->setParameters( | 
| 77 | 77 | $row['majat_status'] == 'enabled', | 
| 78 | 78 | new \DateTime($row['majat_last_run']), | 
| @@ -95,21 +95,21 @@ discard block | ||
| 95 | 95 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getTask() | 
| 96 | 96 | */ | 
| 97 | 97 |      public function getTask($task_name, $only_enabled = true) { | 
| 98 | - $args = array ( | |
| 98 | + $args = array( | |
| 99 | 99 | 'task_name' => $task_name | 
| 100 | 100 | ); | 
| 101 | 101 | |
| 102 | - $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' . | |
| 103 | - ' FROM `##maj_admintasks`' . | |
| 102 | + $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running'. | |
| 103 | + ' FROM `##maj_admintasks`'. | |
| 104 | 104 | ' WHERE majat_name = :task_name'; | 
| 105 | -        if($only_enabled) { | |
| 105 | +        if ($only_enabled) { | |
| 106 | 106 | $sql .= ' AND majat_status = :status'; | 
| 107 | 107 | $args['status'] = 'enabled'; | 
| 108 | 108 | } | 
| 109 | 109 | |
| 110 | 110 | $task_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); | 
| 111 | 111 | |
| 112 | -        if($task_array) { | |
| 112 | +        if ($task_array) { | |
| 113 | 113 | return $this->loadTaskFromRow($task_array); | 
| 114 | 114 | } | 
| 115 | 115 | |
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::updateTask() | 
| 137 | 137 | */ | 
| 138 | 138 |      public function updateTask(AbstractTask $task) {         | 
| 139 | -        try{ | |
| 139 | +        try { | |
| 140 | 140 | Database::prepare( | 
| 141 | 141 | 'UPDATE `##maj_admintasks`'. | 
| 142 | 142 | ' SET majat_status = :status,'. | 
| @@ -169,7 +169,7 @@ discard block | ||
| 169 | 169 | */ | 
| 170 | 170 |      public function getTasksCount() { | 
| 171 | 171 | return Database::prepare( | 
| 172 | - 'SELECT COUNT(majat_name)' . | |
| 172 | + 'SELECT COUNT(majat_name)'. | |
| 173 | 173 | ' FROM `##maj_admintasks`' | 
| 174 | 174 | )->execute()->fetchOne(); | 
| 175 | 175 | } | 
| @@ -194,20 +194,20 @@ discard block | ||
| 194 | 194 | 'time_out' => AbstractTask::TASK_TIME_OUT | 
| 195 | 195 | ); | 
| 196 | 196 | |
| 197 | -		if(!$force) { | |
| 197 | +		if (!$force) { | |
| 198 | 198 | $sql .= ' AND (DATE_ADD(majat_last_run, INTERVAL majat_frequency MINUTE) <= NOW() OR majat_last_result = 0)'; | 
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | -		if($task_name) { | |
| 201 | +		if ($task_name) { | |
| 202 | 202 | $sql .= ' AND majat_name = :task_name'; | 
| 203 | 203 | $args['task_name'] = $task_name; | 
| 204 | 204 | } | 
| 205 | 205 | |
| 206 | 206 | $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); | 
| 207 | 207 | |
| 208 | -		foreach($data as $task_row) { | |
| 208 | +		foreach ($data as $task_row) { | |
| 209 | 209 | $task = $this->loadTaskFromRow($task_row); | 
| 210 | - if($task) | |
| 210 | + if ($task) | |
| 211 | 211 |  			{ | 
| 212 | 212 | $res[] = $task; | 
| 213 | 213 | } | 
| @@ -220,10 +220,10 @@ discard block | ||
| 220 | 220 |  	 * {@inheritDoc} | 
| 221 | 221 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getFilteredTasksList() | 
| 222 | 222 | */ | 
| 223 | -    public function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null){ | |
| 223 | +    public function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null) { | |
| 224 | 224 | $res = array(); | 
| 225 | 225 | |
| 226 | - $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' . | |
| 226 | + $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running'. | |
| 227 | 227 | ' FROM `##maj_admintasks`'; | 
| 228 | 228 | |
| 229 | 229 | $args = array(); | 
| @@ -238,10 +238,10 @@ discard block | ||
| 238 | 238 | |
| 239 | 239 |                  switch ($value['dir']) { | 
| 240 | 240 | case 'asc': | 
| 241 | - $sql .= $value['column'] . ' ASC '; | |
| 241 | + $sql .= $value['column'].' ASC '; | |
| 242 | 242 | break; | 
| 243 | 243 | case 'desc': | 
| 244 | - $sql .= $value['column'] . ' DESC '; | |
| 244 | + $sql .= $value['column'].' DESC '; | |
| 245 | 245 | break; | 
| 246 | 246 | } | 
| 247 | 247 | $i++; | 
| @@ -258,9 +258,9 @@ discard block | ||
| 258 | 258 | |
| 259 | 259 | $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); | 
| 260 | 260 | |
| 261 | -        foreach($data as $ga) { | |
| 261 | +        foreach ($data as $ga) { | |
| 262 | 262 | $task = $this->loadTaskFromRow($ga); | 
| 263 | - if($task && (empty($search) || ($search && strpos($task->getTitle(), $search) !== false))) | |
| 263 | + if ($task && (empty($search) || ($search && strpos($task->getTitle(), $search) !== false))) | |
| 264 | 264 |  			{ | 
| 265 | 265 | $res[] = $task; | 
| 266 | 266 | } | 
| @@ -275,13 +275,13 @@ discard block | ||
| 275 | 275 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getInstalledTasks() | 
| 276 | 276 | */ | 
| 277 | 277 |  	public function getInstalledTasks() { | 
| 278 | - $tasks=array(); | |
| 279 | - $dir=opendir($this->root_path); | |
| 280 | -		while (($file=readdir($dir))!==false){  | |
| 278 | + $tasks = array(); | |
| 279 | + $dir = opendir($this->root_path); | |
| 280 | +		while (($file = readdir($dir)) !== false) {  | |
| 281 | 281 |  			try { | 
| 282 | - if($file == '.' || $file == '..') continue; | |
| 283 | - $task = include $this->root_path . $file; | |
| 284 | -				if($task ) { | |
| 282 | + if ($file == '.' || $file == '..') continue; | |
| 283 | + $task = include $this->root_path.$file; | |
| 284 | +				if ($task) { | |
| 285 | 285 | $task->setProvider($this); | 
| 286 | 286 | Database::prepare( | 
| 287 | 287 | 'INSERT IGNORE INTO `##maj_admintasks`'. | 
| @@ -300,7 +300,7 @@ discard block | ||
| 300 | 300 | } | 
| 301 | 301 | } | 
| 302 | 302 |  			catch (\Exception $ex) { | 
| 303 | -				Log::addErrorLog('An error occured while trying to load the task in file ' . $file . '. Exception: ' . $ex->getMessage()); | |
| 303 | +				Log::addErrorLog('An error occured while trying to load the task in file '.$file.'. Exception: '.$ex->getMessage()); | |
| 304 | 304 | } | 
| 305 | 305 | } | 
| 306 | 306 | return $tasks; | 
| @@ -311,14 +311,14 @@ discard block | ||
| 311 | 311 |  	 * {inhericDoc} | 
| 312 | 312 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::deleteTask() | 
| 313 | 313 | */ | 
| 314 | -	public function deleteTask($task_name){ | |
| 315 | -		try{ | |
| 314 | +	public function deleteTask($task_name) { | |
| 315 | +		try { | |
| 316 | 316 | Database::beginTransaction(); | 
| 317 | 317 | |
| 318 | 318 |  			Database::prepare('DELETE FROM  `##maj_admintasks` WHERE majat_name= :task_name') | 
| 319 | 319 |  				->execute(array('task_name' => $task_name)); | 
| 320 | 320 |  			Database::prepare('DELETE FROM  `##gedcom_setting` WHERE setting_name LIKE :setting_name') | 
| 321 | -				->execute(array('setting_name' => 'MAJ_AT_' . $task_name .'%')); | |
| 321 | +				->execute(array('setting_name' => 'MAJ_AT_'.$task_name.'%')); | |
| 322 | 322 | |
| 323 | 323 | Database::commit(); | 
| 324 | 324 | |
| @@ -326,10 +326,10 @@ discard block | ||
| 326 | 326 | |
| 327 | 327 | return true; | 
| 328 | 328 | } | 
| 329 | -		catch(\Exception $ex) { | |
| 329 | +		catch (\Exception $ex) { | |
| 330 | 330 | Database::rollback(); | 
| 331 | 331 | |
| 332 | -			Log::addErrorLog('An error occurred while deleting Admin Task '.$task_name.'. Exception: '. $ex->getMessage()); | |
| 332 | +			Log::addErrorLog('An error occurred while deleting Admin Task '.$task_name.'. Exception: '.$ex->getMessage()); | |
| 333 | 333 | return false; | 
| 334 | 334 | } | 
| 335 | 335 | } | 
| @@ -49,8 +49,7 @@ discard block | ||
| 49 | 49 | return $task; | 
| 50 | 50 | } | 
| 51 | 51 | } | 
| 52 | - } | |
| 53 | -		catch(\Exception $ex) { } | |
| 52 | +		} catch(\Exception $ex) { } | |
| 54 | 53 | |
| 55 | 54 | return null; | 
| 56 | 55 | } | 
| @@ -83,8 +82,7 @@ discard block | ||
| 83 | 82 | ); | 
| 84 | 83 | |
| 85 | 84 | return $task; | 
| 86 | - } | |
| 87 | -		else { | |
| 85 | +		} else { | |
| 88 | 86 | $this->deleteTask($row['majat_name']); | 
| 89 | 87 | } | 
| 90 | 88 | return null; | 
| @@ -156,8 +154,7 @@ discard block | ||
| 156 | 154 | 'is_running' => $task->isRunning() ? 1 : 0 | 
| 157 | 155 | )); | 
| 158 | 156 | return true; | 
| 159 | - } | |
| 160 | -        catch (\Exception $ex) { | |
| 157 | +        } catch (\Exception $ex) { | |
| 161 | 158 |              Log::addErrorLog(sprintf('Error while updating the Admin Task %s. Exception: %s', $task->getName(), $ex->getMessage())); | 
| 162 | 159 | return false; | 
| 163 | 160 | } | 
| @@ -279,7 +276,9 @@ discard block | ||
| 279 | 276 | $dir=opendir($this->root_path); | 
| 280 | 277 |  		while (($file=readdir($dir))!==false){  | 
| 281 | 278 |  			try { | 
| 282 | - if($file == '.' || $file == '..') continue; | |
| 279 | +			    if($file == '.' || $file == '..') { | |
| 280 | + continue; | |
| 281 | + } | |
| 283 | 282 | $task = include $this->root_path . $file; | 
| 284 | 283 |  				if($task ) { | 
| 285 | 284 | $task->setProvider($this); | 
| @@ -294,12 +293,10 @@ discard block | ||
| 294 | 293 | )); | 
| 295 | 294 | |
| 296 | 295 | $tasks[] = $task; | 
| 297 | - } | |
| 298 | -				else { | |
| 296 | +				} else { | |
| 299 | 297 | throw new \Exception; | 
| 300 | 298 | } | 
| 301 | - } | |
| 302 | -			catch (\Exception $ex) { | |
| 299 | +			} catch (\Exception $ex) { | |
| 303 | 300 |  				Log::addErrorLog('An error occured while trying to load the task in file ' . $file . '. Exception: ' . $ex->getMessage()); | 
| 304 | 301 | } | 
| 305 | 302 | } | 
| @@ -325,8 +322,7 @@ discard block | ||
| 325 | 322 |  			Log::addConfigurationLog('Admin Task '.$task_name.' has been deleted from disk - deleting it from DB'); | 
| 326 | 323 | |
| 327 | 324 | return true; | 
| 328 | - } | |
| 329 | -		catch(\Exception $ex) { | |
| 325 | +		} catch(\Exception $ex) { | |
| 330 | 326 | Database::rollback(); | 
| 331 | 327 | |
| 332 | 328 |  			Log::addErrorLog('An error occurred while deleting Admin Task '.$task_name.'. Exception: '. $ex->getMessage()); | 
| @@ -185,8 +185,7 @@ discard block | ||
| 185 | 185 |  						I18N::translate('Error').Mail::EOL. | 
| 186 | 186 |  						str_repeat('-', $nb_char_count_title)."\t".str_repeat('-', $nb_char_type)."\t".str_repeat('-', 20)."\t".str_repeat('-', strlen(I18N::translate('Error'))).Mail::EOL. | 
| 187 | 187 | $tmp_message.Mail::EOL; | 
| 188 | - } | |
| 189 | -				else{ | |
| 188 | +				} else{ | |
| 190 | 189 |  					$message .= I18N::translate('No errors', $nb_errors).Mail::EOL.Mail::EOL; | 
| 191 | 190 | } | 
| 192 | 191 | |
| @@ -251,8 +250,7 @@ discard block | ||
| 251 | 250 | } | 
| 252 | 251 | } | 
| 253 | 252 | return true; | 
| 254 | - } | |
| 255 | -		catch (\Exception $ex) { | |
| 253 | +		} catch (\Exception $ex) { | |
| 256 | 254 |  			Log::addErrorLog(sprintf('Error while updating the Admin Task "%s". Exception: %s', $this->getName(), $ex->getMessage())); | 
| 257 | 255 | return false; | 
| 258 | 256 | } | 
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency() | 
| 43 | 43 | */ | 
| 44 | 44 |      public function getDefaultFrequency() { | 
| 45 | - return 10080; // = 1 week = 7 * 24 * 60 min | |
| 45 | + return 10080; // = 1 week = 7 * 24 * 60 min | |
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | /** | 
| @@ -55,9 +55,9 @@ discard block | ||
| 55 | 55 | |
| 56 | 56 | // Get the number of days to take into account, either last 7 days or since last check | 
| 57 | 57 | $interval_sincelast = 0; | 
| 58 | -		if($this->last_updated){ | |
| 58 | +		if ($this->last_updated) { | |
| 59 | 59 |  			$tmpInt = $this->last_updated->diff(new \DateTime('now'), true); | 
| 60 | - $interval_sincelast = ( $tmpInt->days * 24 + $tmpInt->h ) * 60 + $tmpInt->i; | |
| 60 | + $interval_sincelast = ($tmpInt->days * 24 + $tmpInt->h) * 60 + $tmpInt->i; | |
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | 63 | $interval = max($this->frequency, $interval_sincelast); | 
| @@ -66,17 +66,17 @@ discard block | ||
| 66 | 66 | // Check for updates | 
| 67 | 67 | $latest_version_txt = Functions::fetchLatestVersion(); | 
| 68 | 68 |          if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { | 
| 69 | -        	list($latest_version, , $download_url) = explode('|', $latest_version_txt); | |
| 69 | +        	list($latest_version,, $download_url) = explode('|', $latest_version_txt); | |
| 70 | 70 |          } else { | 
| 71 | 71 | // Cannot determine the latest version | 
| 72 | -        	list($latest_version, , $download_url) = explode('|', '||'); | |
| 72 | +        	list($latest_version,, $download_url) = explode('|', '||'); | |
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | 75 | // Users statistics | 
| 76 | 76 | $warnusers = 0; | 
| 77 | 77 | $nverusers = 0; | 
| 78 | 78 | $applusers = 0; | 
| 79 | -		foreach(User::all() as $user) { | |
| 79 | +		foreach (User::all() as $user) { | |
| 80 | 80 |  			if (((date("U") - (int)$user->getPreference('reg_timestamp')) > 604800) && !$user->getPreference('verified')) { | 
| 81 | 81 | $warnusers++; | 
| 82 | 82 | } | 
| @@ -90,20 +90,20 @@ discard block | ||
| 90 | 90 | |
| 91 | 91 | // Tree specifics checks | 
| 92 | 92 | $one_tree_done = false; | 
| 93 | -		foreach(Tree::getAll() as $tree){ | |
| 93 | +		foreach (Tree::getAll() as $tree) { | |
| 94 | 94 |  			$isTreeEnabled = $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED'); | 
| 95 | -			if((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))){ | |
| 95 | +			if ((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))) { | |
| 96 | 96 |  				I18N::init($webmaster->getPreference('language')); | 
| 97 | 97 | |
| 98 | 98 |  				$subject = I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->getTitle()); | 
| 99 | 99 | $message = | 
| 100 | -					I18N::translate('Health Check Report for the last %d days', $nbdays). Mail::EOL. Mail::EOL. | |
| 100 | +					I18N::translate('Health Check Report for the last %d days', $nbdays).Mail::EOL.Mail::EOL. | |
| 101 | 101 |  					I18N::translate('Tree %s', $tree->getTitle()).Mail::EOL. | 
| 102 | 102 | '=========================================='.Mail::EOL.Mail::EOL; | 
| 103 | 103 | |
| 104 | 104 | // News | 
| 105 | 105 | $message_version = ''; | 
| 106 | -				if($latest_version && version_compare(WT_VERSION, $latest_version)<0){ | |
| 106 | +				if ($latest_version && version_compare(WT_VERSION, $latest_version) < 0) { | |
| 107 | 107 |  					$message_version = I18N::translate('News').Mail::EOL. | 
| 108 | 108 | '-------------'.Mail::EOL. | 
| 109 | 109 |  							I18N::translate('A new version of *webtrees* is available: %s. Upgrade as soon as possible.', $latest_version).Mail::EOL. | 
| @@ -119,7 +119,7 @@ discard block | ||
| 119 | 119 |  						I18N::translate('Not verified by the user')."\t\t".$applusers.Mail::EOL. | 
| 120 | 120 |  						I18N::translate('Not approved by an administrator')."\t".$nverusers.Mail::EOL. | 
| 121 | 121 | Mail::EOL; | 
| 122 | - $message .= $message_users; | |
| 122 | + $message .= $message_users; | |
| 123 | 123 | |
| 124 | 124 | // Statistics tree: | 
| 125 | 125 | $stats = new Stats($tree); | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | ' AND log_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)'. | 
| 160 | 160 | ' GROUP BY log_message, gedcom_id'. | 
| 161 | 161 | ' ORDER BY lastoccurred DESC'; | 
| 162 | - $errors=Database::prepare($sql)->execute(array( | |
| 162 | + $errors = Database::prepare($sql)->execute(array( | |
| 163 | 163 | 'log_type' => Log::TYPE_ERROR, | 
| 164 | 164 | 'gedcom_id' => $tree->getTreeId(), | 
| 165 | 165 | 'nb_days' => $nbdays | 
| @@ -175,7 +175,7 @@ discard block | ||
| 175 | 175 |  					$tmp_message .= str_replace("\n", "\n\t\t\t\t\t\t", $error->log_message).Mail::EOL; | 
| 176 | 176 | $nb_errors += $error->nblogs; | 
| 177 | 177 | } | 
| 178 | -				if($nb_errors > 0){ | |
| 178 | +				if ($nb_errors > 0) { | |
| 179 | 179 |  					$message .= I18N::translate('Errors [%d]', $nb_errors).Mail::EOL. | 
| 180 | 180 | '-------------'.Mail::EOL. | 
| 181 | 181 | WT_BASE_URL.'admin_site_logs.php'.Mail::EOL. | 
| @@ -186,12 +186,12 @@ discard block | ||
| 186 | 186 |  						str_repeat('-', $nb_char_count_title)."\t".str_repeat('-', $nb_char_type)."\t".str_repeat('-', 20)."\t".str_repeat('-', strlen(I18N::translate('Error'))).Mail::EOL. | 
| 187 | 187 | $tmp_message.Mail::EOL; | 
| 188 | 188 | } | 
| 189 | -				else{ | |
| 189 | +				else { | |
| 190 | 190 |  					$message .= I18N::translate('No errors', $nb_errors).Mail::EOL.Mail::EOL; | 
| 191 | 191 | } | 
| 192 | 192 | |
| 193 | 193 | $tmpres = true; | 
| 194 | -				if($webmaster->getPreference('contactmethod') !== 'messaging'  | |
| 194 | +				if ($webmaster->getPreference('contactmethod') !== 'messaging'  | |
| 195 | 195 |  						&& $webmaster->getPreference('contactmethod') !== 'none') { | 
| 196 | 196 | $tmpres = Mail::systemMessage($tree, $webmaster, $subject, $message); | 
| 197 | 197 | } | 
| @@ -213,24 +213,24 @@ discard block | ||
| 213 | 213 | $html = ' | 
| 214 | 214 | <div class="form-group"> | 
| 215 | 215 | <label class="control-label col-sm-3"> '. | 
| 216 | -    				I18N::translate('Enable healthcheck emails for') . | |
| 216 | +    				I18N::translate('Enable healthcheck emails for'). | |
| 217 | 217 | '</label> | 
| 218 | 218 | <div class="col-sm-9">'; | 
| 219 | 219 | |
| 220 | -		foreach(Tree::getAll() as $tree){ | |
| 221 | -			if(Auth::isManager($tree)){	 | |
| 220 | +		foreach (Tree::getAll() as $tree) { | |
| 221 | +			if (Auth::isManager($tree)) {	 | |
| 222 | 222 | $html .= '<div class="form-group row"> | 
| 223 | 223 | <span class="col-sm-3 control-label">' . | 
| 224 | - $tree->getTitle() . | |
| 224 | + $tree->getTitle(). | |
| 225 | 225 | '</span> | 
| 226 | 226 | <div class="col-sm-2">'; | 
| 227 | -				$html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); | |
| 227 | +				$html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); | |
| 228 | 228 | $html .= '</div></div>'; | 
| 229 | 229 | } | 
| 230 | 230 | } | 
| 231 | 231 | |
| 232 | 232 | $html .= ' <p class="small text-muted">'. | 
| 233 | -    					I18N::translate('Enable the health check emails for each of the selected trees.') . | |
| 233 | +    					I18N::translate('Enable the health check emails for each of the selected trees.'). | |
| 234 | 234 | '</p> | 
| 235 | 235 | </div> | 
| 236 | 236 | </div>'; | 
| @@ -244,9 +244,9 @@ discard block | ||
| 244 | 244 | */ | 
| 245 | 245 |  	public function saveConfig() { | 
| 246 | 246 |  		try { | 
| 247 | -			foreach(Tree::getAll() as $tree){		 | |
| 248 | -				if(Auth::isManager($tree)){ | |
| 249 | -					$tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), 0, 1); | |
| 247 | +			foreach (Tree::getAll() as $tree) {		 | |
| 248 | +				if (Auth::isManager($tree)) { | |
| 249 | +					$tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), 0, 1); | |
| 250 | 250 |  					$tree->setPreference('MAJ_AT_'.$this->getName().'_ENABLED', $tree_enabled); | 
| 251 | 251 | } | 
| 252 | 252 | } | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 | ->setPageTitle($this->module->getTitle()); | 
| 69 | 69 | |
| 70 | 70 |  		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); | 
| 71 | -		if(is_null($token)) { | |
| 71 | +		if (is_null($token)) { | |
| 72 | 72 | $token = Functions::generateRandomToken(); | 
| 73 | 73 |  			$this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token); | 
| 74 | 74 | } | 
| @@ -76,12 +76,12 @@ discard block | ||
| 76 | 76 | $data = new ViewBag(); | 
| 77 | 77 |          $data->set('title', $controller->getPageTitle()); | 
| 78 | 78 | |
| 79 | - $table_id = 'table-admintasks-' . Uuid::uuid4(); | |
| 79 | + $table_id = 'table-admintasks-'.Uuid::uuid4(); | |
| 80 | 80 |          $data->set('table_id', $table_id); | 
| 81 | 81 | |
| 82 | 82 |  		$data->set('trigger_url_root', WT_BASE_URL.'module.php?mod='.$this->module->getName().'&mod_action=Task@trigger'); | 
| 83 | 83 |  		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); | 
| 84 | -		if(is_null($token)) { | |
| 84 | +		if (is_null($token)) { | |
| 85 | 85 | $token = Functions::generateRandomToken(); | 
| 86 | 86 |  			$this->module->setSetting('MAJ_AT_FORCE_EXEC_TOKEN', $token); | 
| 87 | 87 | } | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | processing: true, | 
| 107 | 107 | serverSide : true, | 
| 108 | 108 |  					ajax : { | 
| 109 | - url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonTasksList&ged='. $WT_TREE->getNameUrl().'", | |
| 109 | + url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonTasksList&ged='.$WT_TREE->getNameUrl().'", | |
| 110 | 110 | type : "POST" | 
| 111 | 111 | }, | 
| 112 | 112 | columns: [ | 
| @@ -143,14 +143,14 @@ discard block | ||
| 143 | 143 | url: "module.php", | 
| 144 | 144 | type: "GET", | 
| 145 | 145 |                              data: { | 
| 146 | - mod: "' . $this->module->getName() .'", | |
| 146 | + mod: "' . $this->module->getName().'", | |
| 147 | 147 | mod_action: "Task@setStatus", | 
| 148 | 148 | task: task, | 
| 149 | 149 | status: status | 
| 150 | 150 | }, | 
| 151 | 151 |                              error: function(result, stat, error) { | 
| 152 | 152 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; | 
| 153 | -                                alert("' . I18N::translate('An error occured while editing this task:') . '" + err); | |
| 153 | +                                alert("' . I18N::translate('An error occured while editing this task:').'" + err); | |
| 154 | 154 | }, | 
| 155 | 155 |                              complete: function(result, stat) { | 
| 156 | 156 | adminTasksTable.ajax.reload(null, false); | 
| @@ -187,14 +187,14 @@ discard block | ||
| 187 | 187 | |
| 188 | 188 | // Generate an AJAX/JSON response for datatables to load a block of rows | 
| 189 | 189 |          $search = Filter::postArray('search'); | 
| 190 | - if($search) $search = $search['value']; | |
| 190 | + if ($search) $search = $search['value']; | |
| 191 | 191 |          $start  = Filter::postInteger('start'); | 
| 192 | 192 |          $length = Filter::postInteger('length'); | 
| 193 | 193 |          $order  = Filter::postArray('order'); | 
| 194 | 194 | |
| 195 | 195 | $order_by_name = false; | 
| 196 | -        foreach($order as $key => &$value) { | |
| 197 | -            switch($value['column']) { | |
| 196 | +        foreach ($order as $key => &$value) { | |
| 197 | +            switch ($value['column']) { | |
| 198 | 198 | case 3: | 
| 199 | 199 | $order_by_name = true; | 
| 200 | 200 | unset($order[$key]); | 
| @@ -211,14 +211,14 @@ discard block | ||
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); | 
| 214 | -		if($order_by_name) { | |
| 214 | +		if ($order_by_name) { | |
| 215 | 215 |  			usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); }); | 
| 216 | 216 | } | 
| 217 | 217 | $recordsFiltered = count($list); | 
| 218 | 218 | $recordsTotal = $this->provider->getTasksCount(); | 
| 219 | 219 | |
| 220 | 220 | $data = array(); | 
| 221 | -        foreach($list as $task) {     | |
| 221 | +        foreach ($list as $task) {     | |
| 222 | 222 | $datum = array(); | 
| 223 | 223 | |
| 224 | 224 | $datum[0] = ' | 
| @@ -229,37 +229,34 @@ discard block | ||
| 229 | 229 | <ul class="dropdown-menu" role="menu"> | 
| 230 | 230 | <li> | 
| 231 | 231 | <a href="#" onclick="return set_admintask_status(\''. $task->getName().'\', '.($task->isEnabled() ? 'false' : 'true').');"> | 
| 232 | -                                <i class="fa fa-fw '.($task->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . ' | |
| 232 | +                                <i class="fa fa-fw '.($task->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).' | |
| 233 | 233 | </a> | 
| 234 | 234 | </li> | 
| 235 | 235 | <li> | 
| 236 | - <a href="module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='. $task->getName().'"> | |
| 237 | -                                <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . ' | |
| 236 | + <a href="module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='.$task->getName().'"> | |
| 237 | +                                <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').' | |
| 238 | 238 | </a> | 
| 239 | 239 | </li> | 
| 240 | 240 | </ul> | 
| 241 | 241 | </div>'; | 
| 242 | 242 | $datum[1] = $task->getName(); | 
| 243 | 243 | $datum[2] = $task->isEnabled() ? | 
| 244 | -				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' :  | |
| 245 | -				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; | |
| 244 | +				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; | |
| 246 | 245 | $datum[3] = $task->getTitle(); | 
| 247 | -            $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; | |
| 246 | +            $date_format = str_replace('%', '', I18N::dateFormat()).' H:i:s'; | |
| 248 | 247 | $datum[4] = $task->getLastUpdated()->format($date_format); | 
| 249 | 248 | $datum[5] = $task->isLastRunSuccess() ? | 
| 250 | -				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' :  | |
| 251 | -				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; | |
| 249 | +				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; | |
| 252 | 250 |              $dtF = new \DateTime('@0'); | 
| 253 | -            $dtT = new \DateTime('@' . ($task->getFrequency() * 60));             | |
| 251 | +            $dtT = new \DateTime('@'.($task->getFrequency() * 60));             | |
| 254 | 252 |              $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); | 
| 255 | 253 |  			$datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited'); | 
| 256 | 254 | $datum[8] = $task->isRunning() ? | 
| 257 | -				'<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' :  | |
| 258 | -				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>'; | |
| 259 | -			if($task->isEnabled() && !$task->isRunning()) { | |
| 255 | +				'<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>'; | |
| 256 | +			if ($task->isEnabled() && !$task->isRunning()) { | |
| 260 | 257 | $datum[9] = ' | 
| 261 | - <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')"> | |
| 262 | -    			         <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> | |
| 258 | + <button id="bt_runtask_'. $task->getName().'" class="btn btn-primary" href="#" onclick="return run_admintask(\''.$task->getName().'\')"> | |
| 259 | +    			         <div id="bt_runtasktext_'. $task->getName().'"><i class="fa fa-cog fa-fw" ></i>'.I18N::translate('Run').'</div> | |
| 263 | 260 | </button>'; | 
| 264 | 261 | } | 
| 265 | 262 |  			else { | 
| @@ -187,7 +187,9 @@ discard block | ||
| 187 | 187 | |
| 188 | 188 | // Generate an AJAX/JSON response for datatables to load a block of rows | 
| 189 | 189 |          $search = Filter::postArray('search'); | 
| 190 | - if($search) $search = $search['value']; | |
| 190 | +        if($search) { | |
| 191 | + $search = $search['value']; | |
| 192 | + } | |
| 191 | 193 |          $start  = Filter::postInteger('start'); | 
| 192 | 194 |          $length = Filter::postInteger('length'); | 
| 193 | 195 |          $order  = Filter::postArray('order'); | 
| @@ -261,8 +263,7 @@ discard block | ||
| 261 | 263 | <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')"> | 
| 262 | 264 |      			         <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> | 
| 263 | 265 | </button>'; | 
| 264 | - } | |
| 265 | -			else { | |
| 266 | +			} else { | |
| 266 | 267 | $datum[9] = ''; | 
| 267 | 268 | } | 
| 268 | 269 | |
| @@ -104,7 +104,7 @@ | ||
| 104 | 104 | </div> | 
| 105 | 105 | </div> | 
| 106 | 106 | |
| 107 | -			<?php if($task instanceof ConfigurableTaskInterface) { ?> | |
| 107 | +			<?php if ($task instanceof ConfigurableTaskInterface) { ?> | |
| 108 | 108 | |
| 109 | 109 |  			<h3><?php echo I18N::translate('Options for ā%sā', $task->getTitle()); ?></h3> | 
| 110 | 110 | |