/** * Move images to temp location so they can be recaptured later * @param array $files */ public static function tempStore($files) { $destination = ModUtil::getVar('News', 'picupload_uploaddir') . '/' . "PREVIEW"; if (!is_dir($destination)) { News_ImageUtil::mkdir($destination); } $newfiles = array(); foreach ($files as $key => $file) { if ($file['resize']) { $filename = $file['name']; $uploadfile = $file['tmp_name']; $file['tmp_name'] = DataUtil::formatForOS("$destination/$filename"); move_uploaded_file($uploadfile, $file['tmp_name']); $newfiles[] = $file; } } return $newfiles; }
/** * This is a standard function to update the configuration parameters of the * module given the information passed back by the modification form * @author Mark West * @param int 'itemsperpage' number of articles per page * @return bool true */ public function updateconfig() { $this->checkCsrfToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('News::', '::', ACCESS_ADMIN), LogUtil::getErrorMsgPermission()); // Update module variables $modvars = array(); $refereronprint = (int)FormUtil::getPassedValue('refereronprint', 0, 'POST'); if ($refereronprint != 0 && $refereronprint != 1) { $refereronprint = 0; } $modvars['refereronprint'] = $refereronprint; $modvars['itemsperpage'] = (int)FormUtil::getPassedValue('itemsperpage', 25, 'POST'); $modvars['itemsperadminpage'] = (int)FormUtil::getPassedValue('itemsperadminpage', 15, 'POST'); $modvars['storyhome'] = (int)FormUtil::getPassedValue('storyhome', 10, 'POST'); $modvars['storyorder'] = (int)FormUtil::getPassedValue('storyorder', 1, 'POST'); $modvars['enablecategorization'] = (bool)FormUtil::getPassedValue('enablecategorization', false, 'POST'); $modvars['enableattribution'] = (bool)FormUtil::getPassedValue('enableattribution', false, 'POST'); $catimagepath = FormUtil::getPassedValue('catimagepath', '/images/categories/', 'POST'); if (substr($catimagepath, -1) != '/') { $catimagepath .= '/'; // add slash if needed } $modvars['catimagepath'] = $catimagepath; $modvars['enableajaxedit'] = (bool)FormUtil::getPassedValue('enableajaxedit', false, 'POST'); $modvars['enablemorearticlesincat'] = (bool)FormUtil::getPassedValue('enablemorearticlesincat', false, 'POST'); $modvars['morearticlesincat'] = (int)FormUtil::getPassedValue('morearticlesincat', 0, 'POST'); $modvars['enabledescriptionvar'] = (bool)FormUtil::getPassedValue('enabledescriptionvar', false, 'POST'); $modvars['descriptionvarchars'] = (int)FormUtil::getPassedValue('descriptionvarchars', 250, 'POST'); $modvars['enablecategorybasedpermissions'] = (bool)FormUtil::getPassedValue('enablecategorybasedpermissions', false, 'POST'); $modvars['notifyonpending'] = (bool)FormUtil::getPassedValue('notifyonpending', false, 'POST'); $modvars['notifyonpending_fromname'] = FormUtil::getPassedValue('notifyonpending_fromname', '', 'POST'); $modvars['notifyonpending_fromaddress'] = FormUtil::getPassedValue('notifyonpending_fromaddress', '', 'POST'); $modvars['notifyonpending_toname'] = FormUtil::getPassedValue('notifyonpending_toname', '', 'POST'); $modvars['notifyonpending_toaddress'] = FormUtil::getPassedValue('notifyonpending_toaddress', '', 'POST'); $modvars['notifyonpending_subject'] = FormUtil::getPassedValue('notifyonpending_subject', '', 'POST'); $modvars['notifyonpending_html'] = (bool)FormUtil::getPassedValue('notifyonpending_html', true, 'POST'); $modvars['pdflink'] = (bool)FormUtil::getPassedValue('pdflink', false, 'POST'); $modvars['pdflink_tcpdfpath'] = FormUtil::getPassedValue('pdflink_tcpdfpath', '', 'POST'); $modvars['pdflink_tcpdflang'] = FormUtil::getPassedValue('pdflink_tcpdflang', '', 'POST'); $modvars['pdflink_headerlogo'] = FormUtil::getPassedValue('pdflink_headerlogo', '', 'POST'); $modvars['pdflink_headerlogo_width'] = FormUtil::getPassedValue('pdflink_headerlogo_width', '', 'POST'); $modvars['pdflink_enablecache'] = (bool)FormUtil::getPassedValue('pdflink_enablecache', false, 'POST'); $modvars['picupload_enabled'] = (bool)FormUtil::getPassedValue('picupload_enabled', false, 'POST'); $modvars['picupload_allowext'] = str_replace(array(' ', '.'), '', FormUtil::getPassedValue('picupload_allowext', 'jpg,gif,png', 'POST')); $modvars['picupload_index_float'] = FormUtil::getPassedValue('picupload_index_float', 'left', 'POST'); $modvars['picupload_article_float'] = FormUtil::getPassedValue('picupload_article_float', 'left', 'POST'); $modvars['picupload_maxfilesize'] = (int)FormUtil::getPassedValue('picupload_maxfilesize', '500000', 'POST'); $modvars['picupload_maxpictures'] = (int)FormUtil::getPassedValue('picupload_maxpictures', 3, 'POST'); $modvars['picupload_sizing'] = FormUtil::getPassedValue('picupload_sizing', '0', 'POST'); $modvars['picupload_picmaxwidth'] = (int)FormUtil::getPassedValue('picupload_picmaxwidth', 600, 'POST'); $modvars['picupload_picmaxheight'] = (int)FormUtil::getPassedValue('picupload_picmaxheight', 600, 'POST'); $modvars['picupload_thumbmaxwidth'] = (int)FormUtil::getPassedValue('picupload_thumbmaxwidth', 150, 'POST'); $modvars['picupload_thumbmaxheight'] = (int)FormUtil::getPassedValue('picupload_thumbmaxheight', 150, 'POST'); $modvars['picupload_thumb2maxwidth'] = (int)FormUtil::getPassedValue('picupload_thumb2maxwidth', 200, 'POST'); $modvars['picupload_thumb2maxheight'] = (int)FormUtil::getPassedValue('picupload_thumb2maxheight', 200, 'POST'); $modvars['picupload_uploaddir'] = FormUtil::getPassedValue('picupload_uploaddir', '', 'POST'); $createfolder = (bool)FormUtil::getPassedValue('picupload_createfolder', false, 'POST'); // create picture upload folder if needed if ($modvars['picupload_enabled']) { if ($createfolder && !empty($modvars['picupload_uploaddir'])) { News_ImageUtil::mkdir($modvars['picupload_uploaddir']); } } $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news'); $properties = array_keys($catregistry); $topicproperty = FormUtil::getPassedValue('topicproperty', null, 'POST'); $modvars['topicproperty'] = $properties[$topicproperty]; $permalinkformat = FormUtil::getPassedValue('permalinkformat', null, 'POST'); if ($permalinkformat == 'custom') { $permalinkformat = FormUtil::getPassedValue('permalinkstructure', null, 'POST'); } $modvars['permalinkformat'] = $permalinkformat; $modvars['shorturls26x'] = (bool)FormUtil::getPassedValue('shorturls26x', false, 'POST'); $this->setVars($modvars); // the module configuration has been updated successfuly LogUtil::registerStatus($this->__('Done! Saved module settings.')); return $this->redirect(ModUtil::url('News', 'admin', 'view')); }