configure('requestURI',$config['admin_url'].'/editcontent.php?'.CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY].'&content_id='.$content_id); $xajax->register(XAJAX_FUNCTION,'ajaxpreview'); $headtext = $xajax->getJavascript('../lib/xajax')."\n"; if (isset($_POST["cancel"])) { redirect("listcontent.php".$urlext); } if ($apply) { $CMS_EXCLUDE_FROM_RECENT=1; } #Get a list of content types and pick a default if necessary $gCms = cmsms(); $contentops = $gCms->GetContentOperations(); $existingtypes = $contentops->ListContentTypes(false,true); #Get current userid and make sure they have permission to add something $userid = get_userid(); $access = check_ownership($userid, $content_id) || check_permission($userid, 'Modify Any Page') || check_permission($userid, 'Manage All Content'); $adminaccess = $access; if (!$access) { $access = check_authorship($userid, $content_id); } if ($access) { // get the content object. $contentobj = ""; $content_type = 'content'; // default content type. if( !is_object($contentobj) && $content_id != -1 ) { // load the content object from the database. $contentobj = $contentops->LoadContentFromId($content_id); $content_type = $contentobj->Type(); } if( isset($_POST['content_type']) ) { $content_type = $_POST['content_type']; } $xajax->processRequest(); // validate the content type we want... if( isset($existingtypes) && count($existingtypes) > 0 && in_array($content_type,array_keys($existingtypes)) ) { // woot, it's a valid content type } else { redirect("listcontent.php".$urlext."&page=".$pagelist_id.'&error=error_contenttype'); } try { if( $content_id != -1 && strtolower(get_class($contentobj)) != strtolower($content_type) ) { // content type change... // this also updates the content object with the POST params. copycontentobj($contentobj, $content_type); } else if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ) { // we posted... so update the content object. updatecontentobj($contentobj); } cms_utils::set_app_data('editing_content',$contentobj); } catch( CmsEditContentException $e ) { $error = $e->getMessage(); } if ($submit || $apply) { try { // Fill contentobj with parameters // $contentobj->SetProperties(); // calguy should not be necessary $contentobj->FillParams($_POST,true); $error = $contentobj->ValidateData(); if ($error === FALSE) { $contentobj->SetLastModifiedBy(get_userid()); $contentobj->Save(); $contentops =& $gCms->GetContentOperations(); $contentops->SetAllHierarchyPositions(); // put mention into the admin log audit($contentobj->Id(), 'Content Item: '.$contentobj->Name(), 'Edited'); if ($submit) { redirect("listcontent.php".$urlext."&page=".$pagelist_id.'&message=contentupdated'); } } } catch( CmsEditContentException $e ) { $error = $e->getMessage(); } if ($ajax) { header('Content-Type: text/xml'); print ''; print ''; if ($error !== false) { print 'Error'; print '
' . join('
  • ', $error) . '
  • '; print ']]>
    '; } else { print 'Success'; print '
    '; } print '
    '; exit; } } } if (strlen($contentobj->Name()) > 0) { $CMS_ADMIN_SUBTITLE = $contentobj->Name(); } // Detect if a WYSIWYG is in use, and grab its form submit action $addlScriptSubmit = ''; $modobj = cms_utils::get_wysiwyg_module(); if( $modobj ) { $addlScriptSubmit .= $modobj->WYSIWYGPageFormSubmit(); } $closestr = cms_html_entity_decode(lang('close')); $cancelstr = cms_html_entity_decode(lang('confirmcancel')); $headtext .= << //

    ' + e.details + '<\/p><\/div>'; jQuery('[name=cancel]').fadeOut(); jQuery('[name=cancel]').attr('value','{$closestr}'); jQuery('[name=cancel]').fadeIn(); } else { htmlShow = '