$real_filename = basename(str_replace('TMP_' . $objectID . '-', '', $found_temp_template_files[count($found_temp_template_files) - 1])); $real_filename = explode('-', $real_filename); array_shift($real_filename); $real_filename = implode('', $real_filename); rename($found_temp_template_files[count($found_temp_template_files) - 1], $templatedir . $real_filename); // Get new file mode to set from configfile (and set it) $newFileMode = octdec(sConfig()->getVar('CONFIG/UPLOAD_PERMISSIONS')); if ($newFileMode) { chmod($templatedir . $real_filename, $newFileMode); } $found_temp_template_files_to_del = glob($templatedir . 'TMP_' . $objectID . '-*'); foreach ($found_temp_template_files_to_del as $found_temp_template_file_to_del) { unlink($found_temp_template_file_to_del); } $templateMgr->setPath($objectID, ''); $templateMgr->setFilename($objectID, basename($real_filename)); // Check for added/removed contentareas $filecontentareas = $templateMgr->getContentareasFromFile($objectID); $contentareas = $templateMgr->getContentareas($objectID); $a = 0; $r = 0; $afilecontentareas = array(); $rfilecontentareas = array(); for ($s = 0; $s < count($filecontentareas); $s++) { $alreadythere = false; for ($s2 = 0; $s2 < count($contentareas); $s2++) { if ($filecontentareas[$s]['CODE'] == $contentareas[$s2]['CODE']) { $alreadythere = true; } } if ($alreadythere == false) {