Finalise optimisation of getSccpModelInformation

Use foreach with reference instead of iterator.
This commit is contained in:
steve-lad 2021-08-01 12:13:49 +02:00
parent 28bb5a63da
commit 7ab6eba556

View file

@ -1085,44 +1085,45 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
$dir_list = $this->findAllFiles($dir, $file_ext, 'dirFileBaseName'); $dir_list = $this->findAllFiles($dir, $file_ext, 'dirFileBaseName');
break; break;
} }
$raw_settings = $this->dbinterface->getDb_model_info($get, $format_list, $filter); $modelList = $this->dbinterface->getDb_model_info($get, $format_list, $filter);
if ($validate) { if ($validate) {
for ($i = 0; $i < count($raw_settings); $i++) { foreach ($modelList as &$raw_settings) {
if (!empty($raw_settings[$i]['loadimage'])) { if (!empty($raw_settings['loadimage'])) {
$raw_settings[$i]['validate'] = 'no;'; $raw_settings['validate'] = 'no;';
switch ($search_mode) { switch ($search_mode) {
case 'pro': case 'pro':
case 'on': case 'on':
case 'internal': case 'internal':
if (in_array($raw_settings[$i]['loadimage'], $dir_list, true)) { if (in_array($raw_settings['loadimage'], $dir_list, true)) {
$raw_settings[$i]['validate'] = 'yes;'; $raw_settings['validate'] = 'yes;';
} }
break; break;
case 'internal2': case 'internal2':
break; break;
case 'off': case 'off':
default: // Place in root TFTP dir default: // Place in root TFTP dir
if (in_array("{$dir}/{$raw_settings[$i]['loadimage']}", $dir_list, true)) { if (in_array("{$dir}/{$raw_settings['loadimage']}", $dir_list, true)) {
$raw_settings[$i]['validate'] = 'yes;'; $raw_settings['validate'] = 'yes;';
} }
break; break;
} }
} else { } else {
$raw_settings[$i]['validate'] = '-;'; $raw_settings['validate'] = '-;';
} }
if (!empty($raw_settings[$i]['nametemplate'])) { if (!empty($raw_settings['nametemplate'])) {
$file = $this->sccppath['tftp_templates_path'] . '/' . $raw_settings[$i]['nametemplate']; $file = $this->sccppath['tftp_templates_path'] . '/' . $raw_settings['nametemplate'];
if (file_exists($file)) { if (file_exists($file)) {
$raw_settings[$i]['validate'] .= 'yes'; $raw_settings['validate'] .= 'yes';
} else { } else {
$raw_settings[$i]['validate'] .= 'no'; $raw_settings['validate'] .= 'no';
} }
} else { } else {
$raw_settings[$i]['validate'] .= '-'; $raw_settings['validate'] .= '-';
} }
} }
} }
return $raw_settings; unset($raw_settings);
return $modelList;
} }
function getHintInformation($sort = true, $filter = array()) { function getHintInformation($sort = true, $filter = array()) {