GetGlobalContentOperations(); $userid = get_userid(); $adminaccess = check_permission($userid, 'Modify Global Content Blocks'); $isowner = $gcbops->CheckOwnership($htmlblob_id,$userid); $access = $adminaccess || $isowner || $gcbops->CheckAuthorship($htmlblob_id, $userid); if (isset($_POST["cancel"])) { redirect("listhtmlblobs.php".$urlext); return; } $the_blob = ''; if( $htmlblob_id > 0 ) { $the_blob = $gcbops->LoadHtmlBlobById($htmlblob_id); } else { $the_blob = new GlobalContent(); } $htmlblob = $the_blob->name; $oldhtmlblob = $the_blob->name; $owner_id = $the_blob->owner; $content = $the_blob->content; $use_wysiwyg = $the_blob->use_wysiwyg; $description = $the_blob->description; $ajax = false; $error = ""; if (isset($_POST['htmlblob'])) $htmlblob = trim($_POST['htmlblob']); if (isset($_POST['oldhtmlblob'])) $oldhtmlblob = trim($_POST['oldhtmlblob']); if (isset($_POST['content'])) $content = $_POST['content']; if (isset($_POST['use_wysiwyg']) ) $use_wysiwyg = (int)$_POST['use_wysiwyg']; if (isset($_POST['description']) ) $description = trim($_POST['description']); if (isset($_POST['owner_id'])) $owner_id = $_POST['owner_id']; if (isset($_POST['ajax']) && $_POST['ajax']) $ajax = true; $gcb_wysiwyg = (get_site_preference('nogcbwysiwyg','0') == '0') ? 1 : 0; if( $gcb_wysiwyg ) { $gcb_wysiwyg = get_preference($userid, 'gcb_wysiwyg', 1); } if ($access) { if (isset($_POST["submit2"]) || isset($_POST['apply']) || $ajax) { $validinfo = true; if ($htmlblob == "") { $error .= "
  • ".lang('nofieldgiven', array(lang('name')))."
  • "; $validinfo = false; } else if ($htmlblob != $oldhtmlblob && $gcbops->CheckExistingHtmlBlobName($htmlblob, $htmlblob_id)) { $error .= "
  • ".lang('blobexists')."
  • "; $validinfo = false; } elseif(preg_match('<^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$>', $htmlblob) == 0) { $error .= "
  • ".lang('illegalcharacters',lang('name'))."
  • "; $validinfo = false; } else if($content == ""){ $error .= '
  • '.lang('nofieldgiven',array('content')).'
  • '; $validinfo = false; } if ($validinfo) { $the_blob->id = $htmlblob_id; $the_blob->use_wysiwyg = $use_wysiwyg; $the_blob->description = $description; $the_blob->name = $htmlblob; $the_blob->content = $content; $the_blob->owner = $owner_id; if ($adminaccess || $isowner) $the_blob->ClearAuthors(); if (isset($_POST["additional_editors"])) { foreach ($_POST["additional_editors"] as $addt_user_id) { $the_blob->AddAuthor($addt_user_id); } } Events::SendEvent('Core', 'EditGlobalContentPre', array('global_content' => &$the_blob)); $result = $the_blob->save(); if ($result) { // put mention into the admin log audit($the_blob->id, 'Global Content Block: '.$the_blob->name, 'Edited'); #Clear cache $smarty = cmsms()->GetSmarty(); $smarty->clear_all_cache(); $smarty->clear_compiled_tpl(); Events::SendEvent('Core', 'EditGlobalContentPost', array('global_content' => &$the_blob)); if (!isset($_POST['apply'])) { redirect('listhtmlblobs.php'.$urlext); return; } } else { $error .= "
  • ".lang('errorinsertingblob')."
  • "; } } if ($ajax) { header('Content-Type: text/xml'); print ''; print ''; if ($error) { print 'Error'; print '
    '; } else { print 'Success'; print '
    '; } print '
    '; exit; } } } if (strlen($htmlblob) > 0) { $CMS_ADMIN_SUBTITLE = $htmlblob; } // Detect if a WYSIWYG is in use, and grab its form submit action (copied from editcotent.php) $addlScriptSubmit = ''; if( $gcb_wysiwyg && $use_wysiwyg ) { $modobj = cms_utils::get_wysiwyg_module(); if( $modobj ) { $addlScriptSubmit .= $modobj->WYSIWYGPageFormSubmit(); } } $closestr = cms_html_entity_decode(lang('close')); $headtext = << //

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