function smarty_function_custom_conf_save($params, &$smarty) { global $site, $leht; ############## # default values extract($params); if (!isset($id)) { $id = $leht->id; } if (!$id) { return; } $objekt = new Objekt(array(objekt_id => $id, no_cache => 1)); if ($objekt->permission['U']) { $conf = new CONFIG($objekt->all['ttyyp_params']); foreach ($params as $param => $value) { if ($param == 'id') { continue; } $conf->put($param, $value); } $sql = $site->db->prepare("\r\n\t\t\tUPDATE objekt SET ttyyp_params = ?\r\n\t\t\tWHERE objekt_id = ?", $conf->Export(), $id); $sth = new SQL($sql); } else { new Log(array('action' => 'update', 'type' => 'WARNING', 'objekt_id' => $objekt->objekt_id, 'message' => sprintf("Access denied: attempt to edit %s '%s' (ID = %s)", ucfirst(translate_en($objekt->all['klass'])), $objekt->pealkiri(), $objekt->objekt_id))); } return; }
function smarty_function_init_document($params, &$smarty) { global $site, $leht, $template; $content_template =& $leht->content_template; ############## # default values extract($params); if (!isset($id)) { $id = $leht->id; } if (!isset($name)) { $name = "document"; } switch ($on_create) { case "publish": $publish = 1; break; case "hide": $publish = 0; break; default: $publish = 0; } ############### # action-buttons # by default show all if (!isset($buttons)) { $buttons = array("new", "edit", "hide", "move", "delete"); } else { $buttons = split(",", $buttons); } if (!isset($ttyyp_id)) { $ttyyp_id = 0; } ############## # luua objekt $obj = new Objekt(array(objekt_id => $id)); ############## # load variables $obj->load_sisu(); $obj->buttons = $obj->get_edit_buttons(array(tyyp_idlist => 7, asukoht => $position, publish => $publish)); $obj->id = $obj->objekt_id; $obj->href = $site->self . '?id=' . $obj->objekt_id; $obj->is_selected = $leht->parents->on_parent($obj->objekt_id); $obj->title = $obj->pealkiri; $obj->date = $site->db->MySQL_ee_short($obj->all['aeg']); $obj->datetime = $site->db->MySQL_ee($obj->all['aeg']); $obj->fdate = substr($obj->all['aeg'], 0, strpos($obj->all['aeg'], ' ')); $obj->fdatetime = $obj->all['aeg']; $obj->last_modified = date('Y', $obj->all['last_modified']) > 1970 ? date('d.m.Y H:i', $obj->all['last_modified']) : ''; ## crap data $obj->flast_modified = $obj->all['last_modified']; $obj->file = $obj->filename = $obj->all['fail']; $obj->description = $obj->all['kirjeldus']; $obj->size = $obj->all['size']; $obj->size_formated = print_filesize($obj->all['size']); $obj->author = $obj->all['author'] ? $obj->all['author'] : $obj->all['autor']; $obj->details_link = $site->self . '?id=' . $obj->objekt_id; $obj->download_link = 'doc.php?' . $obj->objekt_id; $obj->class = translate_en($obj->all[klass]); # translate it to english $obj->hit_count = $obj->all['count']; # added 15.12.2004: $obj->comment_link = $site->self . '?id=' . $obj->objekt_id . '#comm'; $obj->comment_title = $site->sys_sona(array(sona => "Kommentaarid", tyyp => "kujundus")); $obj->add_comment_link = $site->self . '?id=' . $obj->objekt_id . '#cbox'; $obj->add_comment_title = $site->sys_sona(array(sona => "Lisa kommentaar", tyyp => "kujundus")); #no UI for this: $obj->forum_allowed = $obj->all[on_foorum]; $obj->created_user_id = $obj->all['created_user_id']; $obj->created_user_name = $obj->all['created_user_name']; $obj->changed_user_id = $obj->all['changed_user_id']; $obj->changed_user_name = $obj->all['changed_user_name']; $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']); $obj->fcreated_time = $obj->all['created_time']; $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']); $obj->fchanged_time = $obj->all['changed_time']; $obj->last_commented_time = $site->db->MySQL_ee($obj->all['last_commented_time']); $obj->comment_count = $obj->all['comment_count']; $smarty->assign($name, $obj); //return $obj; # bug #1921 for {init_object} tag }
#printr($puu->objektid); ################## # sql echo " <tr> <td><b>permissions: public/ folders to CRUPD=11111</b><br></td> </tr> "; ######### loop foreach($puu->objektid as $folder_id){ ## create folder object $objekt = new Objekt(array( objekt_id => $folder_id, no_cache => 1, skip_sanity_check => 1, )); $objekt->load_sisu(); ### get this folder object permission mask directly from database $sql2 = $site->db->prepare("SELECT * FROM permissions WHERE group_id=? AND source_id = ?", 1, $folder_id); $sth2 = new SQL($sql2); $tmp = $sth2->fetch(); $perm_mask = $tmp['C'].$tmp['R'].$tmp['U'].$tmp['P'].$tmp['D']; # echo "<tr bgcolor=\"FFFFFF\"><td>"; #printr($perm_mask); # echo "</td></tr>"; #printr($objekt->all['pealkiri']. ' => '.$perm_mask.' (ID: '.$folder_id.')');
* Good luck and keep your open source minds open! * * @package SaurusCMS * @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/) * @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php) * */ # DESCRIPTION # objektide nihutamine global $site; $class_path = "../classes/"; include $class_path . "port.inc.php"; #Get debug cookie muutuja $debug = $_COOKIE["debug"] ? 1 : 0; $site = new Site(array(on_debug => $debug ? 1 : 0, on_admin_keel => 1)); $objekt = new Objekt(array(objekt_id => $site->fdat[id], parent_id => $site->fdat[parent_id])); $args[asukoht] = $objekt->all[kesk]; #################################### # GET PERMISSIONS # get object permissions for current user $site->debug->msg("EDIT: Liigutatava objekti " . $objekt->objekt_id . " õigused = " . $objekt->permission['mask']); ########################### # ACCESS allowed/denied # decide if accessing this page is allowed or not # MOVE UP/DOWN: if current object has UPDATE permission => allow if ($objekt->permission['U'] || $system_admin) { $access = 1; } else { $access = 0; } ####################
/** * This source file is is part of Saurus CMS content management software. * It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php). * Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/). * Redistribution of this file must retain the above copyright notice. * * Please note that the original authors never thought this would turn out * such a great piece of software when the work started using Perl in year 2000. * Due to organic growth, you may find parts of the software being * a bit (well maybe more than a bit) old fashioned and here's where you can help. * Good luck and keep your open source minds open! * * @package SaurusCMS * @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/) * @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php) * */ function edit_objekt() { global $site; global $objekt; global $keel; global $class_path; global $tyyp; // refreshing (fdat['refresh'] = 1) looses object data, I don't know why and because it's done in edit_object.php, I'm not going to fix it, lord knows what it'll screw up if ($site->fdat['refresh'] && $site->fdat['id']) { $obj = new Objekt(array('objekt_id' => $site->fdat['id'])); $objekt->objekt_id = $obj->objekt_id; $objekt->parent_id = $obj->parent_id; } if ($objekt->parent_id || $site->fdat['op'] == 'new') { $parent = new Objekt(array('objekt_id' => $objekt->objekt_id ? $objekt->parent_id : $site->fdat['parent_id'])); $pearubriik = $parent->all['sys_alias'] == 'home' ? 1 : 0; } else { $pearubriik = 0; } $content_templates = get_templates('CONTENT', $objekt->all['ttyyp_id']); if ($content_templates['template_variable_html']) { $template_variable_html = $content_templates['template_variable_html']; unset($content_templates['template_variable_html']); } $page_templates = get_templates('PAGE', $objekt->all['page_ttyyp_id']); $sql = $site->db->prepare('select ttyyp_id, page_ttyyp_id from keel where keel_id = ' . $keel); $default_templates = new SQL($sql); $default_templates = $default_templates->fetch('ASSOC'); foreach ($page_templates as $name => $group) { if ($group[$default_templates['page_ttyyp_id']]) { $default_page_template = array('id' => $default_templates['page_ttyyp_id'], 'group' => $name, 'name' => $group[$default_templates['page_ttyyp_id']]['nimi']); } } foreach ($content_templates as $name => $group) { if ($group[$default_templates['ttyyp_id']]) { $default_content_template = array('id' => $default_templates['ttyyp_id'], 'group' => $name, 'name' => $group[$default_templates['ttyyp_id']]['nimi']); } } // parent path if ($objekt->all['sys_alias'] == '' && $site->fdat['sys_alias'] == '') { // this needs serious rethink and optmisation: there's no need to get the entire tree, parent object's path to top is only needed include_once $class_path . 'rubloetelu.class.php'; $rubs = new RubLoetelu(array('keel' => $keel, 'required_perm' => 'C', 'ignore_perm_for_obj' => $parent ? $parent->objekt_id : 0)); #$rubs->debug->print_msg(); $topparents = $rubs->get_loetelu(); if (is_array($topparents)) { asort($topparents); } foreach ($topparents as $k => $v) { if ($parent->objekt_id == $k) { $section_name = $v; break; } } } // setup for section selection $_SESSION['parent_selection']['callback'] = 'window.opener.updateSection'; $_SESSION['parent_selection']['selectable'] = 1; $_SESSION['parent_selection']['hide_language_selection'] = '1'; $_SESSION['parent_selection']['mem_classes'] = array('rubriik'); //this sucks, really $_SESSION['parent_selection']['db_fields'] = array('select_checkbox', 'objekt_id', 'pealkiri'); $_SESSION['parent_selection']['display_fields'] = array('select_checkbox', 'pealkiri'); $publish_start = $objekt->all['avaldamisaeg_algus'] > 0 ? $site->db->MySQL_ee_long($objekt->all['avaldamisaeg_algus']) : ''; /* Don't print out time which is 00:00:00 */ if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s(\\d?\\d)[\\:\\\\.\\/\\-](\\d?\\d)/", $publish_start, $aa_reg)) { $publish_start = $aa_reg[2] == "00" && $aa_reg[3] == "00" ? $aa_reg[1] : $publish_start; } $publish_end = $objekt->all['avaldamisaeg_lopp'] > 0 ? $site->db->MySQL_ee_long($objekt->all['avaldamisaeg_lopp']) : ''; /* Don't print out time which is 23:59 */ if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s(\\d?\\d)[\\:\\\\.\\/\\-](\\d?\\d)/", $publish_end, $la_reg)) { $publish_end = $la_reg[2] == "23" && $la_reg[3] == "59" ? $la_reg[1] : $publish_end; } // to get the correct path to parent objects set use_alises on $site->CONF['use_aliases'] = 1; if ($parent) { $parent_href = $parent->get_object_href(); } else { $alias = ''; if ($site->CONF['alias_language_format']) { $languages = $site->cash(array('klass' => 'GET_LANGUAGES', 'kood' => 'ALL_LANGUAGE_INFO')); if (empty($languages)) { $sql = "select keel_id, extension, on_default from keel where on_kasutusel = 1"; $result = new SQL($sql); while ($row = $result->fetch('ASSOC')) { $languages[$row['keel_id']] = $row; } $site->cash(array('klass' => 'GET_LANGUAGES', 'kood' => 'ALL_LANGUAGE_INFO', 'sisu' => $languages)); } } // add languge alias - alias language format 0: none, 1: always, 2: for non-default lang objs if ($site->CONF['alias_language_format'] == 1) { $alias .= $languages[$objekt->all['keel']]['extension'] . '/'; } elseif ($site->CONF['alias_language_format'] == 2) { if (!$languages[$objekt->all['keel']]['on_default']) { $alias .= $languages[$objekt->all['keel']]['extension'] . '/'; } } $parent_href = '/' . $alias; } if ($parent_href && $parent_href != '/' && ($site->CONF['alias_trail_format'] == 0 || $parent->all['sys_alias'] == 'home' || $parent->all['sys_alias'] == 'trash' || $parent->all['sys_alias'] == 'system' || $parent->all['sys_alias'] == 'gallup_arhiiv')) { $parent_href = preg_replace('#' . preg_quote('/' . ($parent->all['friendly_url'] ? $parent->all['friendly_url'] : $parent->objekt_id), '#') . '/$#', '/', $parent_href); } $parent_href = $site->CONF['hostname'] . $parent_href; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title><?php echo $site->title; ?> <?php echo $site->cms_version; ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $encoding ? $encoding : $site->encoding; ?> " /> <meta http-equiv="Cache-Control" content="no-cache" /> <link rel="stylesheet" href="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /datepicker.css" /> <link rel="stylesheet" href="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /section_editor.css" /> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /yld.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /edit_popup.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /jquery.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /datepicker.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot']; ?> /common.js.php"></script> <script type="text/javascript"> var isIE = navigator.appVersion.match(/MSIE/); // assume gecko on false window.onload = function () { var title = document.getElementById('pealkiri'); resizeWindow(); var advanced_panel_state = document.getElementById('advanced_panel_state'); if(advanced_panel_state.value == 1) { togglePanel('advanced'); } this.focus(); title.focus(); } function resizeWindow() { resizeWindowTo($('#size_wrapper').width(), $('#size_wrapper').height()); } function chooseSection() { explorer_window = openpopup('explorer.php?objekt_id=home&editor=1&swk_setup=parent_selection&remove_objects=<?php echo $site->fdat['id']; ?> &pre_selected=' + document.getElementById('rubriik').value, 'cms_explorer', '800','600'); } function updateSection(sections) { explorer_window.close(); var section_name = document.getElementById('section_name'); var section_id = document.getElementById('rubriik'); var trail_path= new Array(); for(var j = 0; j < sections[0].trail.length; j++){ trail_path[j] = sections[0].trail[j].pealkiri; } section_name.innerHTML = '<a href="javascript:chooseSection();">' + trail_path.join("->") + '</a>'; section_id.value = sections[0].objekt_id; } function editAlias() { var alias_placeholder = document.getElementById('alias_placeholder'); var alias_value = document.getElementById('alias_value'); alias_placeholder.innerHTML = '<input type="text" id="alias" value="' + alias_value.value + '" onblur="saveAlias();">'; resizeWindow(); var alias = document.getElementById('alias'); alias.focus(); } function saveAlias() { var alias_placeholder = document.getElementById('alias_placeholder'); var alias_value = document.getElementById('alias_value'); var alias = document.getElementById('alias'); if(alias_value.value != alias.value) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: alias.value, language_id: '<?php echo $keel; ?> '}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; }, success: function(response) { if(response.alias) { alias_value.value = response.alias; alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; } else { alias_value.value = ''; <?php if ($objekt->objekt_id) { ?> alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + '<?php echo $objekt->objekt_id; ?> ' + '</a>'; <?php } else { ?> alias_placeholder.innerHTML = '<input type="text" id="alias" value="" onblur="saveAlias();">'; <?php } ?> } resizeWindow(); } }); } else { if(!alias.value) { alias_value.value = ''; <?php if ($objekt->objekt_id) { ?> alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + '<?php echo $objekt->objekt_id; ?> ' + '</a>'; <?php } else { ?> alias_placeholder.innerHTML = '<input type="text" id="alias" value="" onblur="saveAlias();">'; <?php } ?> } else { alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; } resizeWindow(); } } function createAlias() { var alias_value = document.getElementById('alias_value'); var title = document.getElementById('pealkiri') if(0 || (!alias_value && title.value)) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: title.value, language_id: '<?php echo $keel; ?> '}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { }, success: function(response) { var alias_cell = document.getElementById('alias_cell'); alias_cell.className = 'alias'; if(response.alias) { alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value="' + response.alias + '"><?php echo $parent_href; ?> <span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (response.alias.length > 30 ? response.alias.substring(0, 30) + '...' : response.alias) + '</a></span>'; } else { alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value=""><?php echo $parent_href; ?> <span id="alias_placeholder"><input type="text" id="alias" value="" onblur="saveAlias();"></span>'; } var alias_row = document.getElementById('alias_row'); alias_row.style.display = (isIE ? 'block' : 'table-row'); resizeWindow(); } }); } } function saveForm(op2) { var form = document.getElementById('editForm'); var title = document.getElementById('pealkiri'); if(title.value.length == 0) { alert('<?php echo $site->sys_sona(array('sona' => 'please_fill_in_the_title!', 'tyyp' => 'admin')); ?> '); return; } var alias_value = document.getElementById('alias_value'); var alias = document.getElementById('alias'); if((title.value && !alias_value) || (alias && alias_value && alias.value != alias_value.value)) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: title.value, language_id: '<?php echo $keel; ?> '}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { var form = document.getElementById('editForm'); form.op2.value = op2; form.submit(); }, success: function(response) { var alias_value = document.getElementById('alias_value'); if(!alias_value && response.alias) { var alias_cell = document.getElementById('alias_cell'); alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value="' + response.alias + '"><?php echo $parent_href; ?> <span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (response.alias.length > 30 ? response.alias.substring(0, 30) + '...' : response.alias) + '</a></span>'; } var form = document.getElementById('editForm'); form.op2.value = op2; form.submit(); } }); } else { form.op2.value = op2; form.submit(); } } </script> </head> <body> <? if ($site->fdat['op']=='edit') {?> <iframe src="checkin.php?objekt_id=<?php echo $objekt->objekt_id; ?> " style="width: 0; height: 0; display: none; visibility: hidden;"></iframe> <? } ?> <form action="edit.php" name="editForm" id="editForm" method="POST" enctype="multipart/form-data"> <input type="hidden" name="tab" value="<?php echo $site->fdat['tab']; ?> " /> <input type="hidden" id="op" name="op" value="<?php echo htmlspecialchars($site->fdat['op']); ?> " /> <input type="hidden" id="op2" name="op2" value="" /> <input type="hidden" id="refresh" name="refresh" value="0" /> <input type="hidden" name="tyyp_id" value="<?php echo $tyyp['tyyp_id']; ?> " /> <input type="hidden" name="tyyp" value="<?php echo $tyyp['klass']; ?> " /> <input type="hidden" name="pearubriik" value="<?php echo $pearubriik; ?> " /> <input type="hidden" name="id" value="<?php echo $site->fdat['id']; ?> " /> <input type="hidden" name="parent_id" value="<?php echo $site->fdat['parent_id']; ?> " /> <input type="hidden" name="previous_id" value="<?php echo $site->fdat['previous_id']; ?> " /> <input type="hidden" name="keel" value="<?php echo $keel; ?> " /> <input type="hidden" name="on_pealkiri" value="1" /> <input type="hidden" name="sorting" value="<?php echo $site->fdat['sorting']; ?> "> <input type="hidden" name="extension_path" value="<?php echo $site->fdat['extension_path']; ?> " /> <input type="hidden" name="opener_location" value="" /> <input type="hidden" name="publish" value="<?php echo $site->fdat['publish'] ? $site->fdat['publish'] : $objekt->all['on_avaldatud']; ?> " /> <input name="permanent_parent_id" type="hidden" value="<?php echo $objekt->parent_id; ?> " /> <input name="sys_alias" type="hidden" value="<?php echo $site->fdat['sys_alias'] ? $site->fdat['sys_alias'] : $objekt->all['sys_alias']; ?> " /> <input name="advanced_panel_state" id="advanced_panel_state" type="hidden" value="<?php echo $site->fdat['advanced_panel_state'] ? htmlspecialchars($site->fdat['advanced_panel_state']) : 0; ?> " /> <div id="size_wrapper" class="section_editor"> <div id="main_container"> <?php ########### Tabs ######## ?> <div id="tab_container"> <a href="javascript:void(0);" class="selected"><?php echo $site->sys_sona(array('sona' => 'tyyp_rubriik', 'tyyp' => 'System')); ?> </a> <?php if ($objekt->objekt_id) { ?> <a href="<?php echo $site->self . '?tab=seo&id=' . $site->fdat['id'] . '&keel=' . $keel . '&op=' . $site->fdat['op']; ?> " onclick="resizeDocumentHeightTo(430);"><?php echo $site->sys_sona(array('sona' => 'meta-info', 'tyyp' => 'admin')); ?> </a> <?php } else { ?> <a href="javascript:void(0);"><?php echo $site->sys_sona(array('sona' => 'meta-info', 'tyyp' => 'admin')); ?> </a> <?php } ?> <?php if ($objekt->objekt_id) { ?> <a href="<?php echo $site->self . '?tab=permissions&id=' . $site->fdat['id'] . '&keel=' . $keel . '&op=' . $site->fdat['op']; ?> " onclick="resizeDocumentHeightTo(430);"><?php echo $site->sys_sona(array('sona' => 'permissions', 'tyyp' => 'admin')); ?> </a> <?php } else { ?> <a href="javascript:void(0);"><?php echo $site->sys_sona(array('sona' => 'permissions', 'tyyp' => 'admin')); ?> </a> <?php } ?> </div> <div id="content_container"> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'Pealkiri', 'tyyp' => 'editor')); ?> :</label></td> <td class="input"><input type="text" class="text" name="pealkiri" id="pealkiri" value="<?php echo htmlspecialchars($objekt->all['pealkiri']); ?> " onblur="createAlias();" /></td> </tr> <?php if (($objekt->objekt_id || isset($objekt->all['friendly_url'])) && !($objekt->all['sys_alias'] == 'trash' || $objekt->all['sys_alias'] == 'system' || $objekt->all['sys_alias'] == 'gallup_arhiiv')) { ?> <tr> <td class="label"> </td> <td class="input"><input type="hidden" id="alias_value" name="friendly_url" name="friendly_url" value="<?php echo htmlspecialchars($objekt->all['friendly_url']); ?> " /><?php echo $parent_href; ?> <span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link"><?php echo $objekt->all['friendly_url'] ? strlen(htmlspecialchars($objekt->all['friendly_url'])) > 30 ? substr(htmlspecialchars($objekt->all['friendly_url']), 0, 30) . '...' : htmlspecialchars($objekt->all['friendly_url']) : $objekt->objekt_id; ?> </a></span></td> </tr> <?php } else { ?> <tr id="alias_row"> <td class="label"> </td> <td class="input" id="alias_cell"></td> </tr> <?php } ?> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'content template', 'tyyp' => 'editor')); ?> :</label></td> <td class="input"><select class="select" id="template_select" name="ttyyp_id" onchange="refreshForm();"><option value="0"><?php echo $site->sys_sona(array('sona' => 'default', 'tyyp' => 'admin')); ?> (<?php echo $default_content_template['name']; ?> )</option> <?php foreach ($content_templates as $template_group_name => $templates_group) { ?> <optgroup label="<?php echo $template_group_name; ?> "> <?php foreach ($templates_group as $template_id => $template) { ?> <?php if ($objekt->all['ttyyp_id'] == $template_id) { $ttyyp = $template; } ?> <option value="<?php echo $template_id; ?> "<?php echo $objekt->all['ttyyp_id'] == $template_id ? ' selected="selected" style="color: #a7a6aa;"' : ''; ?> ><?php echo $template['nimi']; ?> </option> <?php } ?> </optgroup> <?php } ?> </select></td> </tr> <?php ########### publishing ######## ?> <tr> <td class="label"><?php echo $site->sys_sona(array('sona' => 'visible_to_visitors', 'tyyp' => 'editor')); ?> </td> <td><input type="radio" name="publish" id="object_published" value="1"<?php echo $site->fdat['publish'] || $objekt->all['on_avaldatud'] ? ' checked' : ''; ?> > <label for="object_published"><?php echo $site->sys_sona(array('sona' => 'published', 'tyyp' => 'editor')); ?> </label> <input type="radio" name="publish" id="object_unpublished" value="0"<?php echo $site->fdat['publish'] == 0 && $objekt->all['on_avaldatud'] == 0 ? ' checked' : ''; ?> > <label for="object_unpublished"><?php echo $site->sys_sona(array('sona' => 'unpublished', 'tyyp' => 'editor')); ?> </label></td> </tr> </table> <br /> <?php ########### advanced ######## ?> <div class="panel_toggler" onclick="togglePanel('advanced');"> <a href="javascript:void(0);"><?php echo $site->sys_sona(array('sona' => 'Advanced', 'tyyp' => 'editor')); ?> <span id="advanced_panel_link_state">»</span></a> </div> <div id="advanced_panel" class="panel"> <?php ########### parent section ######## ?> <?php if ($section_name) { ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'Rubriigid', 'tyyp' => 'editor')); ?> :</label></td> <td class="input"> <table cellpadding="0" cellspacing="0" class="cf_container"> <tr> <th><input type="hidden" name="rubriik[]" id="rubriik" value="<?php echo $parent ? $parent->objekt_id : 0; ?> "><span id="section_name"><a href="javascript:chooseSection();"><?php echo $section_name; ?> </a></span></th> <td><a href="javascript:chooseSection();">..</a></td> </tr> </table> </td> </tr> </table> <?php } ?> <?php ########### page template ######## ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'page template', 'tyyp' => 'editor')); ?> :</label></td> <td class="input"><select class="select" name="page_ttyyp_id"><option value="0"><?php echo $site->sys_sona(array('sona' => 'default', 'tyyp' => 'admin')); ?> (<?php echo $default_page_template['name']; ?> )</option> <?php foreach ($page_templates as $template_group_name => $templates_group) { ?> <optgroup label="<?php echo $template_group_name; ?> "> <?php foreach ($templates_group as $template_id => $template) { ?> <option value="<?php echo $template_id; ?> "<?php echo $objekt->all['page_ttyyp_id'] == $template_id ? ' selected="selected" style="color: #a7a6aa;"' : ''; ?> ><?php echo $template['nimi']; ?> </option> <?php } ?> </optgroup> <?php } ?> </select></td> </tr> </table> <?php ########### hiding in menu and mailinglist ######## ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"> </td> <td><input type="checkbox" class="checkbox" id="hide_in" name="is_hided_in_menu" value="1"<?php echo $objekt->all['is_hided_in_menu'] ? ' checked="checked"' : ''; ?> /></td> <td width="145"><label for="hide_in"><?php echo $site->sys_sona(array('sona' => 'Hide in menu', 'tyyp' => 'editor')); ?> </label></td> <td><input type="checkbox" class="checkbox" id="add_mailinglist" name="on_meilinglist" value="1"<?php echo $objekt->all['on_meilinglist'] ? ' checked="checked"' : ''; ?> /></td> <td><label for="add_mailinglist"><?php echo $site->sys_sona(array('sona' => 'On meilinglist', 'tyyp' => 'editor')); ?> </label></td> </tr> </table> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"> </td> <td><label><?php echo $site->sys_sona(array('sona' => 'Avaldatud', 'tyyp' => 'editor')); ?> :</label></td> <td><input type="text" id="publish_start" name="avaldamise_algus" maxlength="16" class="text_date" value="<?php echo $publish_start; ?> " /></td> <td><a href="javascript:init_datepicker('publish_start', 'publish_start', 'publish_end');"><img src="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /gfx/calendar/cal.gif" width="16" height="15" title="Choose from calendar" alt="Choose from calendar" /></a></td> <td><label><?php echo $site->sys_sona(array('sona' => 'Kuni', 'tyyp' => 'editor')); ?> :</label></td> <td><input type="text" id="publish_end" name="avaldamise_lopp" maxlength="16" class="text_date" value="<?php echo $publish_end; ?> " /></td> <td><a href="javascript:init_datepicker('publish_end', 'publish_start', 'publish_end');"><img src="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /gfx/calendar/cal.gif" width="16" height="15" title="Choose from calendar" alt="Choose from calendar" /></a></td> </tr> </table> <?########### ONLY FOR SAURUS 3 BUILT-IN TEMPLATES: subarticles + Add print icon ########?> <?if(($objekt || $site->fdat['refresh']) && $ttyyp['ttyyp_id'] > 0 && $ttyyp['ttyyp_id'] < 1000) { # if ver3 content template?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"> </td> <?########### subarticles ########?> <td><input type="checkbox" id="on_alamartiklid" name="on_alamartiklid"<?php echo $objekt->all['on_alamartiklid'] ? ' checked="checked"' : ''; ?> /></td> <td width="145"><label for="on_alamartiklid"><?php echo $site->sys_sona(array('sona' => 'Naita alamartiklid', 'tyyp' => 'editor')); ?> </label></td> <?########### Add print icon ########?> <td><input type="checkbox" id="on_printlink" name="on_printlink" value="1" <?php echo $objekt->all['on_printlink'] ? ' checked="checked"' : ''; ?> /></td> <td><label for="on_printlink"><?php echo $site->sys_sona(array('sona' => 'Naita prindi ikoon', 'tyyp' => 'editor')); ?> </label></td> </tr> </table> <?} # if ver3 content template?> <?php if ($template_variable_html) { ?> <table cellpadding="0" cellspacing="0" class="form_row"> <?php echo $template_variable_html; ?> </table> <?php } ?> <?php ########### position ######## ?> <?php if ($site->CONF['allow_change_position']) { ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'Position', 'tyyp' => 'editor')); ?> :</label></td> <td><input type="text" maxlength="5" class="text_position" name="kesk" value="<?php echo $site->fdat['op'] == 'edit' ? $objekt->all['kesk'] : $site->fdat['kesk']; ?> " /></td> </tr> </table> <?php } else { ?> <input type="hidden" name="kesk" value="<?php echo $site->fdat['op'] == 'edit' ? $objekt->all['kesk'] : $site->fdat['kesk']; ?> " /> <?php } ?> </div> </div> </div> <div id="button_container"> <table width="100%" cellspacing="0" cellpadding="0"> <tbody> <tr> <td align="left"> <input type="button" class="button" value="<?php echo $site->sys_sona(array('sona' => 'Apply', 'tyyp' => 'editor')); ?> " onclick="saveForm('save');" /> </td> <td align="right"> <input type="button" class="button" value=" <?php echo $site->sys_sona(array('sona' => 'save_and_close', 'tyyp' => 'editor')); ?> " onclick="saveForm('saveclose');" /> <input type="button" class="button" value="<?php echo $site->sys_sona(array('sona' => 'Close', 'tyyp' => 'editor')); ?> " onclick="window.close();" /> </td> </tr> </tr> </tbody> </table> </div> </div> <!-- / size_wrapper --> </form> </body> </html> <?php }
$sql .= $where; $sql .= $order; $sql .= $pagenumbers['limit_sql']; $sth = new SQL($sql); } #print $sql; if ($sth->rows) { ################# # loop over obj_asset while ($asset = $sth->fetch()) { $baselink = $site->URI; $baselink = preg_replace("/\\&objekt_id=(\\d+)/i", "", $baselink); ##### href & is_active if ($profile_def['source_table'] == 'obj_asset') { ###### create object, to get buttons $objekt = new Objekt(array("objekt_id" => $asset['objekt_id'])); $buttons = $objekt->get_edit_buttons(array("tyyp_idlist" => $objekt->all[tyyp_id], "profile_id" => $site->fdat['profile_id'])); $href = "javascript:document.location='" . $baselink . "&objekt_id=" . $asset['objekt_id'] . "'; avaaken('" . $site->CONF['wwwroot'] . $site->CONF['adm_path'] . "/edit.php?op=edit&id=" . $asset['objekt_id'] . "', 450, 430);"; $is_active = $site->fdat['objekt_id'] == $asset['objekt_id'] ? 1 : 0; $delete_href = $site->CONF['wwwroot'] . $site->CONF['adm_path'] . "/delete.php?id=" . $asset['objekt_id'] . "&parent_id=" . $parent_id; } elseif ($external_table) { $href = "javascript:document.location='" . $baselink . "&id=" . $asset['id'] . "'; avaaken('" . $site->CONF['wwwroot'] . $site->CONF['adm_path'] . "/edit_table.php?tab=edit&op=edit&external_table=" . $external_table . "&id=" . $asset['id'] . "&profile_id=" . $asset['profile_id'] . "', 450, 430);"; $is_active = $site->fdat['id'] == $asset['id'] ? 1 : 0; $delete_href = $site->CONF['wwwroot'] . $site->CONF['adm_path'] . "/edit_table.php?op=delete&external_table=" . $external_table . "&id=" . $asset['id']; } ?> <tr <?php echo $is_active ? ' class="scms_activerow"' : ''; ?> > <?php
function Leht() { $args = func_get_arg(0); $this->BaasObjekt(); $this->id = $args[id]; $fdat = array(); # Get full path to the class folder. added by Dima 19.03.2004 $path_parts = pathinfo($_SERVER["SCRIPT_FILENAME"]); $class_path = $path_parts["dirname"]; # bugfix #1393, by merle 15.10.2004 # if path ends with "/editor", cut it off if (substr($path_parts["dirname"], -7) == '/editor') { $class_path = substr($path_parts["dirname"], 0, -7); } # if path ends with "/admin", cut it off if (substr($path_parts["dirname"], -6) == '/admin') { $class_path = substr($path_parts["dirname"], 0, -6); } $class_path .= "/classes/"; //testing: //require_once($class_path."auto.inc.php"); //auto_error_notifications(1); //auto_maillist(0, 0, 0 , 1); ################################################# # run mailinglist in CONF[maillist_interval] hour if ($this->site->CONF['next_mailinglist'] < time() && $this->site->CONF['maillist_interval'] && $this->site->CONF['enable_mailing_list']) { # set next run $sql = $this->site->db->prepare("\r\n\t\t\t\tupdate config set sisu = ? where nimi='next_mailinglist'", time() + intval($this->site->CONF['maillist_interval']) * 3600); $sth = new SQL($sql); $this->site->debug->msg($sth->debug->get_msgs()); require_once $class_path . "auto.inc.php"; auto_maillist(0, 0, 0, 1); } ######################## # run in every 10 minutes if ($this->site->CONF['next_10min'] < time()) { # set next run $sql = $this->site->db->prepare("update config set sisu = ? where nimi='next_10min'", time() + 600); $sth = new SQL($sql); $this->site->debug->msg($sth->debug->get_msgs()); require_once $class_path . "auto.inc.php"; auto_publishing(1); } ######################## # run in every hour if ($this->site->CONF['next_hour'] < time()) { # set next run $sql = $this->site->db->prepare("update config set sisu = ? where nimi='next_hour'", time() + 3600); $sth = new SQL($sql); $this->site->debug->msg($sth->debug->get_msgs()); require_once $class_path . "auto.inc.php"; # delete from cache old content: if (is_numeric($this->site->CONF['cache_expired'])) { ## delete cache by interval $cache_expired = time() + $this->site->CONF['cache_expired'] * 60 * 60; # now + interval in seconds $sql = $this->site->db->prepare("DELETE FROM cache WHERE aeg < " . $this->site->db->unix2db_datetime($cache_expired) . " AND objekt_id != ?", 0); $sth = new SQL($sql); $this->site->debug->msg($sth->debug->get_msgs()); } // error notifications, only if setting is marked as pageload if ($this->site->CONF['send_error_notifiations_setting'] == 1) { auto_error_notifications(1); } } ################################################# # We don't want to dublicate code, so will write it here: if ($this->site->admin && $this->site->fdat['empty_recycle_bin']) { $do_empty = 1; } ################################################# # run every day if ($this->site->CONF['next_day'] < time() || $do_empty) { if (!$do_empty) { # set next run $sql = $this->site->db->prepare("update config set sisu = ? where nimi='next_day'", time() + 86400); $sth = new SQL($sql); $this->site->debug->msg($sth->debug->get_msgs()); } ################################################# # empty Recycle Bin if ($this->site->CONF['trash_expires'] || $do_empty) { $sql = "SELECT keel_id FROM keel WHERE on_kasutusel = '1'"; $sth503 = new SQL($sql); $this->site->debug->msg($sth503->debug->get_msgs()); while ($tmp_keel = $sth503->fetch()) { $trash_id = $this->site->alias(array('key' => 'trash', 'keel' => $tmp_keel['keel_id'])); if ($trash_id) { # find objects which changed_time + trash.expires.in.days < NOW (Bug #2602) $sql502 = $this->site->db->prepare("SELECT objekt_objekt.* FROM objekt_objekt LEFT JOIN objekt ON objekt.objekt_id=objekt_objekt.objekt_id WHERE objekt_objekt.parent_id=? AND DATE_ADD(objekt.changed_time,INTERVAL ? DAY) < NOW() ", $trash_id, $this->site->CONF['trash_expires']); $sth502 = new SQL($sql502); $this->site->debug->msg($sth502->debug->get_msgs()); while ($ttmp = $sth502->fetch()) { $this->site->debug->msg('leht.class.php : Trying to remove object ' . $ttmp['objekt_id'] . ' from Recycle Bin...'); $del_objekt = new Objekt(array('objekt_id' => $ttmp['objekt_id'], 'superuser' => 1)); if ($del_objekt->objekt_id && $del_objekt->parent_id == $trash_id) { $del_objekt->del(); new Log(array('action' => 'delete', 'component' => 'Recycle bin', 'objekt_id' => $del_objekt->objekt_id, 'user_id' => 0, 'message' => sprintf("%s '%s' (ID = %s) %s", ucfirst(translate_en($del_objekt->all['klass'])), $del_objekt->pealkiri(), $del_objekt->objekt_id, " removed from Recycle Bin "))); } else { new Log(array('action' => 'delete', 'component' => 'Recycle bin', 'objekt_id' => $del_objekt->objekt_id, 'user_id' => 0, 'type' => 'ERROR', 'message' => "Couldn't remove object ID = '" . $ttmp['objekt_id'] . "' from Recycle Bin (Parent ID of this object ='" . $del_objekt->parent_id . "')")); } } } } } # / empty Recycle Bin ################################################# ################################################# # lock inactive users $this->site->CONF['lock_inactive_user_after_x_days'] = (int) $this->site->CONF['lock_inactive_user_after_x_days']; if ($this->site->CONF['lock_inactive_user_after_x_days']) { $sql = 'select user_id, username, last_access_time, is_predefined, firstname, lastname, username from users where is_locked = 0 and date_sub(curdate(), interval ' . $this->site->CONF['lock_inactive_user_after_x_days'] . ' day) > last_access_time'; $result = new SQL($sql); while ($row = $result->fetch('ASSOC')) { // dont lock the last supersuser if ($row['is_predefined'] == 1) { $sql = 'select user_id from users where user_id <> ' . $row['user_id'] . ' and is_predefined = 1 and is_locked = 0 limit 1'; $_result = new SQL($sql); if ($_result->rows) { $lockuser = new user(array('user_id' => $row['user_id'], 'skip_last_access_time_update' => 1)); $lockuser->lock('Superuser ' . htmlspecialchars(xss_clean($row['firstname'])) . ' ' . htmlspecialchars(xss_clean($row['lastname'])) . ' (' . htmlspecialchars(xss_clean($row['username'])) . ') locked due to inactivity. Last access time: ' . ($row['last_access_time'] != '0000-00-00 00:00:00' ? date('d.m.Y h:i', strtotime($row['last_access_time'])) : 'never'), 0); } } else { $lockuser = new user(array('user_id' => $row['user_id'], 'skip_last_access_time_update' => 1)); $lockuser->lock('User ' . htmlspecialchars(xss_clean($row['firstname'])) . ' ' . htmlspecialchars(xss_clean($row['lastname'])) . ' (' . htmlspecialchars(xss_clean($row['username'])) . ') locked due to inactivity. Last access time: ' . ($row['last_access_time'] != '0000-00-00 00:00:00' ? date('d.m.Y h:i', strtotime($row['last_access_time'])) : 'never'), 0); } } } # / lock inactive users ################################################# } # / run every day ################################################# ######################## # run every week - for alive site statistics (can be turned off from config.php by defining: disable_site_polling = 1) if ($this->site->CONF['next_week'] < time() && !$this->site->CONF['disable_site_polling']) { # set next week run $sql = $this->site->db->prepare("update config set sisu = ? where nimi='next_week'", time() + 604800); $sth = new SQL($sql); $this->site->debug->msg($sth->debug->get_msgs()); $accessed_by = 1; # "CMS weekly" $latest_ver = $this->site->site_polling($accessed_by); } ######################## # eriobjekt: op=... $eriobjekt = array("objekt_id" => $this->site->alias("rub_home_id"), "parent_id" => $this->site->alias("rub_home_id"), "on_avaldatud" => 1); if (isset($this->site->fdat['otsi']) && !$this->site->fdat['op']) { # Bug #1828: even if empty parameter "otsi" set in URL => go to search results page $sql = "select * from templ_tyyp where op='search'"; $sth = new SQL($sql); $this->debug->msg($sth->debug->get_msgs()); if ($this->template = $sth->fetch()) { $this->eritemplate = $this->template['templ_fail']; } /* $this->eritemplate = "templ_searchres.php"; $eriobjekt[pealkiri] = $this->site->sys_sona(array("sona" => 'Otsing', "tyyp"=>"kujundus")); */ } elseif ($this->site->fdat['op']) { # op v�ib olla ka mitme v��rtusega - nt "cart,saveorder" $sql = "SELECT * FROM templ_tyyp WHERE op IN('" . str_replace(",", "','", mysql_real_escape_string($this->site->fdat[op])) . "')"; $sth = new SQL($sql); $this->debug->msg($sth->debug->get_msgs()); if ($this->template = $sth->fetch()) { $this->eritemplate = $this->template[templ_fail]; # eriobjekt ehk vana fiks.op-mall (millel pole �ldse aimu, mis tema parent on) # on siis kui URL-il pole id-d antud (fixing Bug #1962,#1924) if (!$this->site->fdat['id']) { $eriobjekt[pealkiri] = $this->site->sys_sona(array("sona" => $this->template[nimi], "tyyp" => "kujundus")); } } # found op-template } # op ######################## # kui id = home id-ga, siis h�pata alla # condition "!$this->eritemplate" removed in 3.1.24 by bugfix #486 # if (!$this->eritemplate && $this->id == $this->site->alias("rub_home_id")) { if ($this->id == $this->site->alias("rub_home_id")) { $this->on_esileht = 1; } if (preg_match("/^\\d+\$/", $this->id)) { ####### PARENTS $this->parents = new vParents(array("parent" => $this->id, "on_esileht" => $this->on_esileht, "lisa_objekt" => $eriobjekt[pealkiri] && !$this->on_esileht ? new Objekt(array("ary" => $eriobjekt)) : 0, "on_custom" => 0)); if ($this->parents->denied) { # $this->parents ; } $this->id = $this->parents->aktiivne_id; $this->objekt = $this->parents->get(0); $this->meta =& $this->parents->meta; $this->debug->msg($this->parents->debug->get_msgs()); } else { # if id $this->debug->msg("Vale ID {$args['id']}"); } # if id }
/** * This source file is is part of Saurus CMS content management software. * It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php). * Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/). * Redistribution of this file must retain the above copyright notice. * * Please note that the original authors never thought this would turn out * such a great piece of software when the work started using Perl in year 2000. * Due to organic growth, you may find parts of the software being * a bit (well maybe more than a bit) old fashioned and here's where you can help. * Good luck and keep your open source minds open! * * @package SaurusCMS * @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/) * @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php) * */ function smarty_function_init_file($params, &$smarty) { global $site, $leht, $class_path; extract($params); $id = (int) $id; if (!$id) { $id = $leht->id; } if (!isset($name)) { $name = 'file'; } if (!isset($buttons)) { $buttons = array('new', 'edit', 'hide', 'move', 'delete'); } else { $buttons = split(',', $buttons); } $obj = new Objekt(array('objekt_id' => $id)); $obj->load_sisu(); $obj->id = $obj->objekt_id; $obj->parent = $obj->parent_id; $obj->title = $obj->pealkiri; $obj->class = translate_en($obj->all['klass']); $obj->date = $site->db->MySQL_ee_short($obj->all['aeg']); $obj->datetime = $site->db->MySQL_ee($obj->all['aeg']); $obj->fdate = substr($obj->all['aeg'], 0, strpos($obj->all['aeg'], ' ')); $obj->fdatetime = $obj->all['aeg']; $obj->created_user_id = $obj->all['created_user_id']; $obj->created_user_name = $obj->all['created_user_name']; $obj->changed_user_id = $obj->all['changed_user_id']; $obj->changed_user_name = $obj->all['changed_user_name']; $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']); $obj->fcreated_time = $obj->all['created_time']; $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']); $obj->fchanged_time = $obj->all['changed_time']; $obj->last_commented_time = $site->db->MySQL_ee($obj->all['last_commented_time']); $obj->comment_count = $obj->all['comment_count']; $obj->href = $site->CONF['wwwroot'] . '/file.php?' . $obj->objekt_id; $obj->fullpath = preg_replace('#/$#', '', $site->absolute_path) . $obj->all['relative_path']; unset($obj->all['fullpath']); $obj->filename = $obj->all['filename']; $obj->mimetype = $obj->all['mimetype']; $obj->profile_id = $obj->all['profile_id']; $obj->url = $site->CONF['wwwroot'] . $obj->all['relative_path']; $obj->size = print_filesize($obj->all['size']); $pathinfo = pathinfo($obj->fullpath); $obj->extension = strtolower($pathinfo['extension']); // for images give gallery thumbs and images if (strpos($obj->all['mimetype'], 'image/') === 0) { $folder = preg_replace('#/$#', '', $site->absolute_path) . str_replace($obj->all['filename'], '', $obj->all['relative_path']); $folder_url = $site->CONF['wwwroot'] . $folder; //thumbs if (file_exists($folder . '.gallery_thumbnails/' . $obj->all['filename']) && ($thumb_info = @getimagesize($folder . '.gallery_thumbnails/' . $obj->all['filename']))) { $obj->thumb_path = $folder_url . '.gallery_thumbnails/' . $obj->all['filename']; $obj->thumb_width = $thumb_info[0]; $obj->thumb_height = $thumb_info[1]; } //image if (file_exists($folder . '.gallery_pictures/' . $obj->all['filename']) && ($image_info = @getimagesize($folder . '.gallery_pictures/' . $obj->all['filename']))) { $obj->image_path = $folder_url . '.gallery_pictures/' . $obj->all['filename']; $obj->image_width = $image_info[0]; $obj->image_height = $image_info[1]; } //actual image if (file_exists($site->absolute_path . $obj->all['relative_path']) && ($actual_image_info = @getimagesize($site->absolute_path . $obj->all['relative_path']))) { $obj->actual_image_path = $obj->url; $obj->actual_image_width = $actual_image_info[0]; $obj->actual_image_height = $actual_image_info[1]; } } if ($icons) { if (!preg_match("/\\/\$/", $icons)) { $icons .= '/'; } if (file_exists($site->absolute_path . $icons . $obj->extension . '.gif')) { $obj->icon = $site->CONF['wwwroot'] . '/' . $icons . $obj->extension . '.gif'; } elseif (file_exists($site->absolute_path . $icons . 'unknown.gif')) { $obj->icon = $site->CONF['wwwroot'] . '/' . $icons . 'unknown.gif'; } } if (!$profile) { $default_profile_def = $site->get_profile(array('id' => $site->get_default_profile_id(array(source_table => 'obj_file')))); # get profile name $profile = $default_profile_def['name']; unset($default_profile_def); } ############## # put all profile names into arr if ($profile) { $profile_names = split(",", $profile); } else { $profile_names = array(); $profile_ids = array(); } # get all profile data from cash foreach ($profile_names as $profile_name) { # profile name is case insensitive $profile_name = strtolower($profile_name); $profile_def = $site->get_profile(array(name => $profile_name)); # sanity check: kui ei leitud sellise nimega profiili, anda toimetajale veateade if (!$profile_def['profile_id']) { if ($site->admin) { print "<font color=red><b>Profile '" . $profile_name . "' not found!</b></font>"; } return; } $profile_ids[] = $profile_def['profile_id']; $profile_arr[$profile_def['profile_id']] = $profile_def; } $obj->buttons = $obj->get_edit_buttons(array('nupud' => $buttons, 'tyyp_idlist' => 21, 'publish' => $publish, 'profile_id' => join(',', $profile_ids))); $profile_def = $site->get_profile(array('id' => $obj->all['profile_id'])); if ($profile_def[profile_id]) { include_once $class_path . 'profile.class.php'; $obj_profile = new Profile(array('id' => $obj->all['profile_id'])); #### 1. set profile fields as object attributes $obj_profile->set_obj_general_fields(array('obj' => &$obj, 'get_object_fields' => $get_object_fields)); ################### # get selectlist values - 1 extra sql per function; sql is fast if (is_array($obj_profile->selectlist)) { $obj_profile->selectlist = array_unique($obj_profile->selectlist); #printr($obj_profile->selectlist); } # go on if object values needs changing: if (sizeof($obj_profile->selectlist) > 0) { #### 2. save array "->asset_names" human readable NAME-s: $obj_profile->get_asset_names(array('selectlist' => $obj_profile->selectlist)); ### 3. save object rest of attributes $obj_profile->set_obj_selectlist_fields(array('obj' => &$obj, 'change_fields' => $obj_profile->change_fields)); } # if any selectvalue exist & need to change # / get selectlist values ################### } foreach ($obj->all as $fieldname => $value) { $obj->{$fieldname} = $value; } $smarty->assign($name, $obj); }
function smarty_function_init_article($params, &$smarty) { global $site, $leht, $template, $class_path; $content_template =& $leht->content_template; ############## # default values extract($params); if (!isset($id)) { $id = $leht->id; } if ($system_message || $system_alias) { $system_message = $system_alias ? $system_alias : $system_message; $id = $site->alias(array('key' => translate_ee($system_message), 'keel' => $site->keel)); } if (!isset($name)) { $name = "article"; } // on_create statements: $on_create = explode(',', $on_create); // default on_create statements: $publish = 0; $allow_comments = $site->CONF['default_comments']; // cycle statements foreach ($on_create as $on_create_statement) { $on_create_statement = trim($on_create_statement); switch ($on_create_statement) { case 'publish': $publish = 1; break; case 'hide': $publish = 0; break; case 'allow_comments': $allow_comments = 1; break; } } # if parameter "get_object_fields" is given (may be comma sep.list), then split it to array if (isset($get_object_fields)) { $get_object_fields_arr = split(",", $get_object_fields); $i = 0; foreach ($get_object_fields_arr as $tmp) { $get_object_fields_arr[$i] = trim($tmp); $i++; } } ############### # action-buttons # by default show all if (!isset($buttons)) { $buttons = array("new", "edit", "hide", "move", "delete"); } else { $buttons = split(",", $buttons); } if (!isset($ttyyp_id)) { $ttyyp_id = 0; } // system alias given but no such article, can be created under system section if (!$id) { $parent_id = $site->alias('system'); $alamlist = new Alamlist(array('parent' => $parent_id, 'klass' => 'artikkel', 'asukoht' => $position, 'start' => 0, 'limit' => 1)); $new_button = $alamlist->get_edit_buttons(array('tyyp_idlist' => 2, 'publish' => $publish, 'allow_comments' => $allow_comments, 'sys_alias' => $system_message)); $smarty->assign($name . '_newbutton', $new_button); return; } ############## # luua objekt $objSettings = array(); $objSettings['objekt_id'] = $id; $obj = new Objekt($objSettings); $allObjParents = $obj->get_obj_all_parents($objSettings['objekt_id']); if (in_array($leht->parents->list[0]->parent_id, $allObjParents)) { $objSettings['parent_id'] = $leht->parents->list[0]->parent_id; $obj = new Objekt($objSettings); } ############## # minna edasi vaid siis kui tegemist on artikliga if (!$obj->all[klass] == "artikkel") { # error pealkirja or smth # assign # exit; } ############## # load variables #PREVIOUS ARTICLE $alamlistSQL = new AlamlistSQL(array(parent => $obj->parent_id, klass => "artikkel", asukoht => 0, order => "objekt_objekt.sorteering ASC")); $alamlistSQL->add_where("sorteering>'" . $obj->all['sorteering'] . "'"); $alamlist = new Alamlist(array(alamlistSQL => $alamlistSQL, start => 0, limit => 1)); #NEXT ARTICLE $alamlistSQL2 = new AlamlistSQL(array(parent => $obj->parent_id, klass => "artikkel", asukoht => 0)); $alamlistSQL2->add_where("sorteering<'" . $obj->all['sorteering'] . "'"); $alamlist2 = new Alamlist(array(alamlistSQL => $alamlistSQL2, start => 0, limit => 1)); $prev_art = $alamlist->next(); $next_art = $alamlist2->next(); $obj->id = $obj->objekt_id; $obj->get_object_href(); $obj->is_selected = $leht->parents->on_parent($obj->objekt_id); $obj->title = $obj->pealkiri; $obj->date = $site->db->MySQL_ee_short($obj->all['aeg']); $obj->datetime = $site->db->MySQL_ee($obj->all['aeg']); $obj->fdate = substr($obj->all['aeg'], 0, strpos($obj->all['aeg'], ' ')); $obj->fdatetime = $obj->all['aeg']; $obj->show_headline = $obj->all['on_pealkiri']; $obj->details_link = $site->self . '?id=' . $obj->objekt_id; $obj->details_title = $site->sys_sona(array(sona => "loe edasi", tyyp => "kujundus")); $obj->printgif = '<a href="' . $obj->href . '&op=print" onClick="avaprintaken(this.href, 600, 400, \'print\'); return false;" target=_blank><img src="' . $site->img_path . '/print_it.gif" border=0 width=19 height=18></a>'; $obj->printlink = $site->self . '?id=' . $obj->objekt_id . '&op=print'; # added 08.11.2002: $obj->comment_link = $site->self . '?id=' . $obj->objekt_id . '#comm'; $obj->comment_title = $site->sys_sona(array(sona => "Kommentaarid", tyyp => "kujundus")); $obj->add_comment_link = $site->self . '?id=' . $obj->objekt_id . '#cbox'; $obj->add_comment_title = $site->sys_sona(array(sona => "Add", tyyp => "kujundus")); # existing already by default: $obj->comment_count $obj->forum_allowed = $obj->all[on_foorum]; $obj->last_commented_time = $site->db->MySQL_ee($obj->all['last_commented_time']); $obj->comment_count = $obj->all['comment_count']; # added 21.01.2003: $obj->author = $obj->all[author]; $obj->class = translate_en($obj->all[klass]); # translate it to english $obj->next_id = $next_art->objekt_id; $obj->prev_id = $prev_art->objekt_id; $obj->hit_count = $obj->all['count']; ############## # load sisu $obj->load_sisu(); if (0 && $context_start) { $obj->lead = $context_start . $obj->lyhi->get_text() . '</editor:context>'; $obj->body = $context_start . $obj->sisu->get_text() . '</editor:context>'; } else { $obj->lead = $obj->lyhi->get_text(); $obj->body = $obj->sisu->get_text(); } if (!$site->in_editor && $site->CONF['use_aliases'] && $site->CONF['replace_links_with_alias']) { $hostUrl = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $site->wwwroot . '/'; //body urls enclosed with " preg_match_all('{<a[^>]+href="((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))"[^>]*>.+</a>}Ui', $obj->body, $searchResults, PREG_SET_ORDER); //body urls enclosed with ' preg_match_all("{<a[^>]+href='((" . str_replace('.', '\\.', $hostUrl) . "[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))'[^>]*>.+</a>}Ui", $obj->body, $searchResults2, PREG_SET_ORDER); $searchResults = array_merge($searchResults, $searchResults2); //non-enclosed body urls preg_match_all('{<a[^>]+href=((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>\\s0-9]*))(\\s+[^>]*|)>.+</a>}Ui', $obj->body, $searchResults2, PREG_SET_ORDER); $searchResults = array_merge($searchResults, $searchResults2); //lead urls enclosed with " preg_match_all('{<a[^>]+href="((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))"[^>]*>.+</a>}Ui', $obj->lead, $searchResults2, PREG_SET_ORDER); $searchResults = array_merge($searchResults, $searchResults2); //lead urls enclosed with ' preg_match_all("{<a[^>]+href='((" . str_replace('.', '\\.', $hostUrl) . "[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))'[^>]*>.+</a>}Ui", $obj->lead, $searchResults2, PREG_SET_ORDER); $searchResults = array_merge($searchResults, $searchResults2); //non-enclosed lead urls preg_match_all('{<a[^>]+href=((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>\\s0-9]*))(\\s+[^>]*|)>.+</a>}Ui', $obj->lead, $searchResults2, PREG_SET_ORDER); $searchResults = array_merge($searchResults, $searchResults2); foreach ($searchResults as $key => $value) { //create an object with the id found in url $linkObj = new Objekt(array(objekt_id => $value[4])); $variables = array(); $separator = strpos($value[3], '&') !== false ? '&' : '&'; foreach (explode($separator, $value[3]) as $param) { $paramArray = explode('=', $param); if ($paramArray[0] != 'id') { $variables[] = $param; } } if (count($variables) > 0) { $param = '?' . implode('&', $variables); } else { $param = ''; } $replaceValue = str_replace($value[1], (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $linkObj->get_object_href() . $param, $value[0]); $obj->lead = str_replace($value[0], $replaceValue, $obj->lead); $obj->body = str_replace($value[0], $replaceValue, $obj->body); } } ############# # buttons (must be after load_sisu(), Bug #1963) $obj->buttons = $obj->get_edit_buttons(array(tyyp_idlist => $obj->all['tyyp_id'], nupud => $buttons, ttyyp_id => $ttyyp_id, profile_id => $obj->all['profile_id'], publish => $publish, 'allow_comments' => $allow_comments)); ########## KUI artiklil on Mļæ½ļæ½RATUD mļæ½ni PROFIIL, siis korja andmed "->" omadustena kokku if ($obj->all['profile_id']) { #printr($obj->objekt_id.' PROFILE_ID: '.$obj->all['profile_id']); include_once $class_path . 'profile.class.php'; $obj_profile = new Profile(array("id" => $obj->all['profile_id'])); #### 1. set profile fields as object attributes $obj_profile->set_obj_general_fields(array("obj" => &$obj, "get_object_fields" => $get_object_fields)); ################### # get selectlist values - 1 extra sql per function; sql is fast if (is_array($obj_profile->selectlist)) { $obj_profile->selectlist = array_unique($obj_profile->selectlist); #printr($obj_profile->selectlist); } # go on if object values needs changing: if (sizeof($obj_profile->selectlist) > 0) { #### 2. save array "->asset_names" human readable NAME-s: $obj_profile->get_asset_names(array("selectlist" => $obj_profile->selectlist)); #printr($obj_profile->asset_names); #printr($obj_profile->change_fields); ### 3. save object rest of attributes #print "<br>muuta ID: ".$obj->id; $obj_profile->set_obj_selectlist_fields(array("obj" => &$obj, "change_fields" => $obj_profile->change_fields)); } # if any selectvalue exist & need to change # / get selectlist values ################### } ####### / profile is set $obj->created_user_id = $obj->all['created_user_id']; $obj->created_user_name = $obj->all['created_user_name']; $obj->changed_user_id = $obj->all['changed_user_id']; $obj->changed_user_name = $obj->all['changed_user_name']; $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']); $obj->fcreated_time = $obj->all['created_time']; $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']); $obj->fchanged_time = $obj->all['changed_time']; ############## # assign to template variables $smarty->assign($name, $obj); //return $obj; # bug #1921 # for {init_object} tag }
global $site; $class_path = "../classes/"; include($class_path."port.inc.php"); #Get debug cookie muutuja $debug = $_COOKIE["debug"] ? 1:0; $site = new Site(array( on_debug=>($debug ? 1 : 0), on_admin_keel => 1 )); $objekt = new Objekt(array( objekt_id => $site->fdat[id], parent_id => $site->fdat[parent_id], )); $args[asukoht] = $objekt->all[kesk]; #################################### # GET PERMISSIONS # get object permissions for current user $site->debug->msg("EDIT: Liigutatava objekti ".$objekt->objekt_id." õigused = ".$objekt->permission['mask']); ########################### # ACCESS allowed/denied # decide if accessing this page is allowed or not # MOVE UP/DOWN: if current object has UPDATE permission => allow
* @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php) * */ # DESCRIPTION # objektide avaldamine global $site; $class_path = "../classes/"; include $class_path . "port.inc.php"; $debug = $_COOKIE["debug"] ? 1 : 0; $site = new Site(array(on_debug => $debug, on_admin_keel => 1)); $objekt = new Objekt(array(objekt_id => $site->fdat[id], no_cache => 1)); # kui objektil on rohkem, kui 1 parent, siis loodame objekti uuesti uue parentiga: if ($objekt->all['parents_count'] > 1 && $objekt->parent_id != $site->fdat['parent_id']) { $site->debug->msg("Leidsin mitu parenti (" . $objekt->all['parents_count'] . "). Kasutan parent_id=" . $site->fdat['parent_id']); unset($objekt); $objekt = new Objekt(array(objekt_id => $site->fdat['id'], parent_id => $site->fdat['parent_id'], no_cache => 1)); } # ------------------------------------- # Objekt leitud # ------------------------------------- if ($objekt) { ########################### # ACCESS allowed/denied # decide if accessing this page is allowed or not # PUBLISH: if current object has PUBLISH permission => allow if ($objekt->permission['P']) { $access = 1; } else { $access = 0; } ####################
function Parents() { $args = func_get_arg(0); $this->ObjektArray(); $this->meta = array(); if (is_object($args['parent']) && !strcasecmp(get_class($args['parent']), 'Objekt')) { # parent on objekt $this->parent_id = $args["parent"]->objekt_id; $this->debug->msg("Parents. Antud on objekt: parent_id = " . $this->parent_id); } elseif (preg_match("/^\\d+\$/", $args["parent"])) { # parent on objekti ID $this->parent_id = $args["parent"]; $this->debug->msg("Parents. Antud on objekti ID: parent_id = " . $this->parent_id); } else { # parent on vigane $this->debug->msg("vigased algandmed: \"{$args['parent']}\" pole objekt ega objekti ID"); } # merle h�mar kommentaar "lisa_objekt"-ile: mulle tundub, et see on vajalik situatsioonis, # kus URL-i peal id puudub JA tegu on vana fiks. op-malliga: siis "on meil eriobjekt" # ja oleks vaja seda op-malli n�idata HOME rubriigi all ja seep�rast lisatakse parentsi l�ppu objekt HOME. if ($args["lisa_objekt"]) { $this->add($args["lisa_objekt"]); } if ($this->parent_id) { $id = $this->parent_id; $this->debug->msg("Parents. Alguses parent_id = " . $this->parent_id); $idid = array(); # juhul kui HOME, on vaja �he sammu v�rra alla minna if ($args["on_esileht"]) { $this->debug->msg("Antud HOME rubriik, h�ppame �he taseme v�rra alla"); $alamlist = new Alamlist(array("parent" => $id, "start" => 0, "limit" => 1, "klass" => 'rubriik', "order" => "objekt.kesk asc, sorteering DESC")); $this->debug->msg($alamlist->debug->get_msgs()); if ($alamlist->size) { $obj = $alamlist->get(0); $id = $obj->objekt_id; $this->debug->msg("Uus ID = {$id}"); } else { $this->debug->msg("Kahjuks alla h�pata ei saa... Pole sobivat kohta"); } } $this->aktiivne_id = $id; ############################# # allah�ppamine $this->debug->msg("JUMP: ================START================"); $this->debug->msg("Jump down? " . ($this->site->in_editor || $this->site->in_admin ? "We are in editor-area or admin-area => abort mission" : "We are in public area => start mission")); # We are in public area => start missio: if (!($this->site->in_editor || $this->site->in_admin)) { do { $last_id = $id; $obj = new Objekt(array("objekt_id" => $id)); $this->debug->msg($obj->debug->get_msgs()); ##################### # kui objekt on rubriik JA talle pole ei lehe- ega sisumalli m��ratud # siis tuleb objekti auto avanemine ise otsustada. # variante on 2: if ($obj->all[klass] == "rubriik" && !$obj->all["page_ttyyp_id"] && !$obj->all["ttyyp_id"]) { $obj->all["on_auto_avanev"] = $this->site->master_tpl["on_auto_avanev"]; $this->debug->msg("JUMP: Auto avanemise m��rab saidi p�himall (ID=" . $this->site->master_tpl[ttyyp_id] . ")" . $this->site->master_tpl["on_auto_avanev"]); } elseif ($obj->all["page_ttyyp_id"] && !$obj->all["ttyyp_id"]) { $sql = $this->site->db->prepare("SELECT on_auto_avanev FROM templ_tyyp WHERE ttyyp_id=?", $obj->all["page_ttyyp_id"]); $sth = new SQL($sql); $obj->all["on_auto_avanev"] = $sth->fetchsingle(); } $this->debug->msg("JUMP: Tulemus: objekt " . $obj->objekt_id . " " . ($obj->all["on_auto_avanev"] ? "ON" : "EI OLE") . " auto avanev "); # juhul, kui malli on_auto_avanev = 1, # siis hakka pihta if ($obj->all["on_auto_avanev"]) { # kontrollime objektide olemasolu $alamlist = new Alamlist(array("parent" => $obj->objekt_id, "on_counter" => 1, "not_klass" => "rubriik,loginkast,kogumik,link", "order" => "sorteering DESC")); $this->debug->msg($alamlist->debug->get_msgs()); # alamlist on tyhi if ($alamlist->rows == 0) { $this->debug->msg("JUMP: Otsime esimest alamrubriiki, kuhu v�iks h�pata"); $alamlist = new Alamlist(array("parent" => $obj->objekt_id, "start" => 0, "klass" => "rubriik", "not_tyyp_nimi" => "Lingikast")); $this->debug->msg($alamlist->debug->get_msgs()); # kui leiti alamrubriik vaata talle otsa ja p��a teda lisada if ($alamlist->rows > 0) { $obj = $alamlist->next(); $this->debug->msg($alamlist->debug->get_msgs()); # kui ei �nnestunud objekti korralikult k�tte saada (polnud �iguseid) # siis nendi fakti ja �ra h�ppa alla if (!$obj->objekt_id) { $this->debug->msg("JUMP: Objekti ei tehtud, ei h�ppa alla"); } else { # JUMP REALLY DOWN here: $this->debug->msg("JUMP: H�ppasime alla ja n��d on aktiivne id = " . $obj->objekt_id); $id = $obj->objekt_id; } # kas objekt on vaatamiseks tibens } else { $this->debug->msg("JUMP: Ei h�ppa alla, sest polnud rubriiki, kuhu h�pata"); } } else { $this->debug->msg("JUMP: Ei h�ppa alla, sest leiti alamobjekte!"); } } } while ($last_id !== $id); } # to jump or not to jump $this->aktiivne_id = $id; $this->debug->msg("JUMP: ================END================"); # / allah�ppamine ############################# ############################# # loop over parents $first = 1; $i = 0; while ($id) { # hakkame antud objektist �lesse minna ####################### # if current object, do extra checks: # 1) decide which parent to use from now on # 2) check if object's language matches with site language if ($first || $i == 1) { # if first or second (if we have sub-article as current object, Bug #1955) $obj_parent = ""; # 1. ja 2. objekti p�ritakse 2 korda (pole ilus lahendus, hetkel h�davajadus): # 1. kord selleks, et teada saada tema klass $obj = new Objekt(array("objekt_id" => $id, "no_cache" => 1)); ################# # 1) if current object is article, then start searching parents (we have to find correct parent) if ($obj->all["klass"] == "artikkel") { $this->debug->msg("Current object" . ($i == 1 ? "'s parent" : "") . " is article. Start doing extra check."); # find all parent id-s of this object ##################### # 1a. if found more than 1 parent => go on and find right parent if ($obj->all['parents_count'] > 1) { $all_parents = $obj->get_obj_all_parents($obj->objekt_id); # v6ttame maha prygikasti rubriik parenti listist: if ($this->site->alias("trash")) { if (in_array($this->site->alias("trash"), $all_parents)) { $all_parents = array_diff($all_parents, array($this->site->alias("trash"))); } } $this->debug->msg("Object " . $obj->objekt_id . " has " . sizeof($all_parents) . " parents: " . join(",", $all_parents)); # get cookie with previous page current section value #$cookie_parent = $this->site->sess_get("current_section"); $cookie_parent = $_COOKIE["current_section"]; ################### # parent_id in URL (Bug #538) # new feature: parameter "parent_id" in URL, it overrides "current_section" cookie settings if ($this->site->fdat['parent_id']) { $obj_parent = $this->site->fdat['parent_id']; $this->debug->msg("Parent found in URL. Parent set to: " . $obj_parent); } elseif (is_array($_SESSION['alias'])) { #Alias being used and a direct path to the object is being shown. foreach ($_SESSION['alias'] as $cuuki) { if ($cuuki['objekt_id'] == $obj->objekt_id) { $obj_parent = $cuuki['parent_id']; } } } ################### # if cookie has value, go on if ($cookie_parent && $obj_parent == "") { $this->debug->msg("Found current_section cookie: " . $cookie_parent); # if 1 object parent is same as cookie, take this for parent if (in_array($cookie_parent, $all_parents)) { $obj_parent = $cookie_parent; $this->debug->msg("Parent set to:" . $obj_parent); } else { $this->debug->msg("Cookie doesn't match. Searching match from parents..."); foreach ($all_parents as $par) { # find all parents for parent $all_parents = $obj->get_obj_all_parents($par); # if 1 object parent is same as cookie, take this for parent if (in_array($cookie_parent, $all_parents)) { $obj_parent = $par; $this->debug->msg("Parent set to:" . $obj_parent); break; } } # foreach if (!$obj_parent) { $this->debug->msg("No match found in parents. Parent not set."); } } # if not match } else { $this->debug->msg("I have no idea, which parent to prefer => choosing just the first one"); } # / just pick first parent - we have no info which one to prefer ################### } # / if found more than 1 parent, go on ##################### } # / if current object is article, then start searching parents ################# # 2) check if object's language matches with site language # bug #2398 : skip language check and automatic langchange for folders, files. # bug #2661 : Sisuobjekti detailvaate lingile lisatud ?lang=en parameeter peab alati m�juma (site classis v�etakse fdat->keel m�lemast parameetrist juba) if ($obj->objekt_id && !in_array($obj->all['tyyp_id'], array(21, 22)) && !isset($this->site->fdat['keel'])) { $this->debug->msg("Language check: current object (ID=" . $obj->objekt_id . ") language is: " . $obj->all[keel] . "; site language is: " . $this->site->keel); # if they differ, change site language if ($obj->all[keel] != $this->site->keel) { $this->site->change_keel($obj->all[keel]); $this->debug->msg("Site language set to: " . $obj->all[keel]); } } $no_cache = 1; } else { $obj_parent = ""; $no_cache = 0; } # / if current object, decide which parent to use from now on ####################### ################### # create object $obj = new Objekt(array("objekt_id" => $id, "parent_id" => $obj_parent, "no_cache" => $no_cache)); $this->debug->msg($obj->debug->get_msgs()); # if creating object fails (because of wrong parent), do it without parent if (!$obj->objekt_id) { $obj = new Objekt(array("objekt_id" => $id, "no_cache" => 1)); $this->debug->msg($obj->debug->get_msgs()); } ############# if creating object still fails then QUIT because PARENT IS FORBIDDEN if (!$obj->objekt_id) { $this->debug->msg("PARENTS: Kuna �ks parentitest on keelatud siis l�peta kogu t�� ja reseti parents"); $this->list = array(); $this->objekts = array(); $this->set_size(); $this->index = -1; return; } elseif (!$idid["id" . $id]) { # viimases rubriigis vaatame on_peida_vmenyy v��rtus if ($obj->all["klass"] == "rubriik" && !isset($on_peida_vmenyy)) { $obj->load_sisu(); $on_peida_vmenyy = $obj->all["on_peida_vmenyy"]; $this->debug->msg("Aktiivse rubriigi on_peida_vmenyy is: " . $obj->all["on_peida_vmenyy"]); } # lisame objekt $this->add($obj); # meta if ($this->meta["keywords"] == "" && $obj->all["meta_keywords"] != "") { $this->meta["keywords"] = $obj->all["meta_keywords"]; $this->debug->msg("meta keyword = " . $this->meta["keywords"]); } if ($this->meta["description"] == "" && $obj->all["meta_description"] != "") { $this->meta["description"] = $obj->all["meta_description"]; $this->debug->msg("meta description = " . $this->meta["description"]); } if ($this->meta["title"] == "" && $obj->all["meta_title"] != "") { $this->meta["title"] = $obj->all["meta_title"]; $this->debug->msg("meta title = " . $this->meta["title"]); } $idid["id" . $id] = 1; ############################ # set next ID $id = $obj->parent_id; ############################ # set next ID exception: 18.05.03 by merle # force another parent for system article: # if object is system article, then dont proceed with its real parent (system section) # but force its parent to be first page in the site if ($first && $obj->parent_id == $this->site->alias("system") && $obj->all["klass"] == "artikkel") { $this->debug->msg("Current object is system article: " . $obj->all[sys_alias]); $home_alamlist = new Alamlist(array("parent" => $this->site->alias("rub_home_id"), "start" => 0, "limit" => 1, "tyyp" => 'rubriik')); if ($home_alamlist->size) { $home_obj = $home_alamlist->get(0); $id = $home_obj->objekt_id; $this->debug->msg("Because its system article, parent is forced to be: {$id}"); } else { $this->debug->msg("Setting new parent for system article failed - not found any section"); } } # force another parent for system article: ############################ } else { $idid["id" . $id] = 1; $id = ''; } $i++; $first = 0; } # while obj # / loop over parents #################### $this->on_peida_vmenyy = $on_peida_vmenyy; #defined("on_peida_vmenyy") ? constant("on_peida_vmenyy"):0; } # if parent }
function smarty_function_init_picture($params, &$smarty) { global $site, $leht, $template; $content_template =& $leht->content_template; ############## # default values extract($params); if (!isset($name)) { $name = "picture"; } if (!isset($id)) { $id = $leht->id; } switch ($on_create) { case "publish": $publish = 1; break; case "hide": $publish = 0; break; default: $publish = 0; } ############### # action-buttons # by default show all if (!isset($buttons)) { $buttons = array("new", "edit", "hide", "move", "delete"); } else { $buttons = split(",", $buttons); } $picture = new Objekt(array(objekt_id => $id)); # we can have 2 object classes here: "pilt" and "file" # save class of the requested object for later $picture_class = $picture->all['klass']; ############## # load variables $picture->buttons = $picture->get_edit_buttons(array(tyyp_idlist => $picture->all['tyyp_id'], nupud => $buttons, publish => $publish)); $picture->id = $picture->objekt_id; $picture->title = $picture->pealkiri; $picture->album_href = $picture->parent_id; $parent = $leht->parents->get(1); $alamlist_count = new Alamlist(array(parent => $picture->parent_id, klass => $picture_class, asukoht => 0, on_counter => 1)); #PREVIOUS PICTURE $alamlistSQL = new AlamlistSQL(array(parent => $picture->parent_id, klass => $picture_class, asukoht => 0, order => "objekt_objekt.sorteering ASC")); $alamlistSQL->add_where("sorteering>'" . $picture->all['sorteering'] . "'"); $alamlist = new Alamlist(array(alamlistSQL => $alamlistSQL, start => 0, limit => 1)); #NEXT PICTURE $alamlistSQL2 = new AlamlistSQL(array(parent => $picture->parent_id, klass => $picture_class, asukoht => 0)); $alamlistSQL2->add_where("sorteering<'" . $picture->all['sorteering'] . "'"); $alamlist2 = new Alamlist(array(alamlistSQL => $alamlistSQL2, start => 0, limit => 1)); $prev_img = $alamlist->next(); $next_img = $alamlist2->next(); ## 1. img from filesystem (Bug #2316) if ($picture_class == 'file') { $sql = $site->db->prepare("SELECT * FROM obj_file WHERE objekt_id = ?", $picture->objekt_id); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); $result = $sth->fetch(); $result['fullpath'] = preg_replace('#/$#', '', $site->absolute_path) . $result['relative_path']; //Find out if is picture or not if (preg_match("/(jpeg|png|gif)/", $result['mimetype'])) { /* is img */ if (function_exists("getimagesize")) { list($i_width, $i_height, $i_type, $i_attr) = getimagesize($result['fullpath']); } else { $i_width = 720; $i_height = 470; } $picture->image_width = $i_width; $picture->image_height = $i_height; //Find out if we are in secure or public dir if (false !== strpos($result['fullpath'], $site->CONF['secure_file_path'])) { /* SECURE */ $root_dir = $site->CONF['secure_file_path']; } else { /* PUBLIC */ $root_dir = $site->CONF['file_path']; } if (preg_match("/^.*(" . str_replace('/', '\\/', $root_dir) . ".*)\$/", $result['fullpath'], $regs)) { $root_dir = preg_replace('/\\/[^\\/]+$/i', '', $regs[1]); } else { $root_dir = '..' . $root_dir; } $filepath = $site->CONF['wwwroot'] . $root_dir . '/' . $result['filename']; $source = "<img src=\"" . $filepath . "\" border=\"0\" />"; } # if img type } elseif ($picture_class == 'pilt') { $source = "<img src=\"" . $site->CONF['wwwroot'] . ($site->admin ? "/editor" : "") . "/image.php?" . $picture->objekt_id . "\" border=\"0\" />"; $thumbnail = "<img src=\"" . $site->CONF['wwwroot'] . ($site->admin ? "/editor" : "") . "/image.php?" . $picture->objekt_id . "t\" border=\"0\" alt =\"" . $picture->all['pealkiri'] . "\" />"; } $picture->hit_count = $picture->all['count']; $picture->created_user_id = $picture->all['created_user_id']; $picture->created_user_name = $picture->all['created_user_name']; $picture->changed_user_id = $picture->all['changed_user_id']; $picture->changed_user_name = $picture->all['changed_user_name']; $picture->created_time = $site->db->MySQL_ee($picture->all['created_time']); $picture->fcreated_time = $picture->all['created_time']; $picture->changed_time = $site->db->MySQL_ee($picture->all['changed_time']); $picture->fchanged_time = $picture->all['changed_time']; $picture->last_commented_time = $site->db->MySQL_ee($picture->all['last_commented_time']); $picture->comment_count = $picture->all['comment_count']; $picture->show_headline = $picture->all['on_pealkiri']; ############## # assign to template variables $smarty->assign(array($name => $picture, $name . '_source' => $source, $name . '_thumbnail' => $thumbnail, $name . '_next' => $prev_img->objekt_id, $name . '_previous' => $next_img->objekt_id)); $smarty->assign($name, $picture); //return $picture; Bug #1921 # for {init_object} tag }
/** * convert local link to alias, * if given link is not local, returns the link unchanged * * @param string $bytes * @return string */ function convert_local_link_to_alias($link) { global $site; $objektUrl = $link; $queryArray = array(); $idValue = ''; # bug #2882 if (preg_match("/^(.*:+(\\/*))\$/i", $objektUrl)) { # in case of invalid url, the url is returned unchanged return $objektUrl; } $urlArray = parse_url($objektUrl); $separator = strpos($urlArray['query'], '&') !== false ? '&' : '&'; foreach (explode($separator, $urlArray['query']) as $value) { $query = explode('=', $value); if ($query[0] != 'id') { $queryArray[] = $value; } else { $idValue = $query[1]; } } if (count($queryArray) > 0) { $param = '?' . implode('&', $queryArray); } else { $param = ''; } // check if link is local and id parameter was given if (($urlArray['host'] == $_SERVER['SERVER_NAME'] || $urlArray['host'] == '') && ($urlArray['path'] == $site->wwwroot . '/' || $urlArray['path'] == '') && is_numeric($idValue)) { $linkObj = new Objekt(array(objekt_id => $idValue)); // if http missing, add it if (!$urlArray['scheme']) { $urlArray['scheme'] = empty($_SERVER['HTTPS']) ? 'http' : 'https'; } // replace link $objektUrl = $urlArray['scheme'] . '://' . $_SERVER['SERVER_NAME'] . $linkObj->get_object_href() . $param; } return $objektUrl; }
function smarty_function_init_message($params, &$smarty) { global $site, $leht, $template; $content_template =& $leht->content_template; ############## # default values extract($params); if (!isset($id)) { $id = $leht->id; } if (!isset($name)) { $name = "message"; } switch ($on_create) { case "publish": $publish = 1; break; case "hide": $publish = 0; break; default: $publish = 0; } ############## # luua objekt $obj = new Objekt(array(objekt_id => $id)); ############## # minna edasi vaid siis kui tegemist on kommentaariga/kirjaga if (!$obj->all[klass] == "kommentaar") { # error pealkirja or smth # assign # exit; } ############## # load variables $obj->buttons = $obj->get_edit_buttons(array(tyyp_idlist => 14, publish => $publish)); $obj->id = $obj->objekt_id; $obj->parent_href = $site->self . '?id=' . $obj->parent_id; $obj->title = $obj->pealkiri(); $obj->load_sisu(); $obj->body = nl2br(htmlspecialchars($obj->all[text])); $obj->author = $obj->all[nimi]; $obj->author_email = $obj->all[email]; $obj->hide_email = $obj->all[on_peida_email]; $obj->started = $site->db->MySQL_ee_short($obj->all[aeg]); $obj->date = $obj->started; # alternative name $obj->datetime = $site->db->MySQL_ee($obj->all['aeg']); $obj->fdate = substr($obj->all['aeg'], 0, strpos($obj->all['aeg'], ' ')); $obj->fdatetime = $obj->all['aeg']; $obj->last_modified = date('Y', $obj->all['last_modified']) > 1970 ? date('d.m.Y H:i', $obj->all['last_modified']) : ''; ## crap data $obj->flast_modified = $obj->all['last_modified']; $obj->class = translate_en($obj->all[klass]); # translate it to english # parent subject $obj->parent_subject = $leht->parents->get(1); $obj->parent_subject_id = $obj->parent_subject->objekt_id; $obj->parent_subject_title = $obj->parent_subject->pealkiri; # parent section $obj->parent_section = $leht->parents->get(2); $obj->parent_section_id = $obj->parent_section->objekt_id; $obj->parent_section_title = $obj->parent_section->pealkiri; # $obj->parent_section_href = $obj->parent_section->objekt_id; $obj->hit_count = $obj->all['count']; $obj->created_user_id = $obj->all['created_user_id']; $obj->created_user_name = $obj->all['created_user_name']; $obj->changed_user_id = $obj->all['changed_user_id']; $obj->changed_user_name = $obj->all['changed_user_name']; $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']); $obj->fcreated_time = $obj->all['created_time']; $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']); $obj->fchanged_time = $obj->all['changed_time']; $obj->last_commented_time = $site->db->MySQL_ee($obj->all['last_commented_time']); $obj->comment_count = $obj->all['comment_count']; ############## # assign to template variables $smarty->assign($name, $obj); }
function auto_publishing($is_pageloaded = 0) { global $site; ######################################## # leida objektid, mis vajavad avaldamist JA mis ei kuulu prügikasti $sql = "SELECT DISTINCT objekt.objekt_id FROM objekt LEFT JOIN objekt_objekt ON objekt_objekt.objekt_id=objekt.objekt_id "; # bug 2817 # pole praegu avaldatud JA ei ole prügikatis (Bug #1373) JA.. $sql .= " WHERE on_avaldatud=0 AND objekt_objekt.parent_id<>'" . $site->alias("trash") . "' "; # ..alguskuupäev täidetud, varasem tänasest ja lõppkuupäev täidetud/tühi, hilisem tänasest VÕI.. $sql .= " AND ( (avaldamisaeg_algus>0 AND avaldamisaeg_algus <= " . $site->db->unix2db_datetime(time()) . " AND (avaldamisaeg_lopp>=" . $site->db->unix2db_datetime(time()) . " OR NOT avaldamisaeg_lopp>0)) "; # ..alguskuupäev tühi ja lõppkuupäev täidetud, hilisem tänasest $sql .= " OR (avaldamisaeg_lopp>=" . $site->db->unix2db_datetime(time()) . " AND NOT avaldamisaeg_algus>0) )"; $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); //print_r($sql); while ($objekt_id = $sth->fetchsingle()) { # tee objekt. ja tee seda superuserina, Bug #805 ( muidu on nii, et kui pageloadi ajal püütakse avaldada objekti, millele sellel juhuslikul useril õiguseid ei ole, siis seda ka autom. avaldada ei suudeta) $obj = new Objekt(array("id" => $objekt_id, "superuser" => 1)); $sql = $site->db->prepare("UPDATE objekt SET on_avaldatud=1 WHERE objekt_id=?", $objekt_id); $sth2 = new SQL($sql); $site->debug->msg($sth2->debug->get_msgs()); new Log(array('action' => 'publish', 'objekt_id' => $obj->objekt_id, 'user_id' => $is_pageloaded ? 0 : $site->user->id, 'message' => sprintf("%s '%s' (ID = %s) %s", ucfirst(translate_en($obj->all[klass])), $obj->pealkiri(), $obj->objekt_id, "published"))); } ######################################## # leida objektid, mis vajavad peitmist $sql = "SELECT DISTINCT objekt.objekt_id FROM objekt LEFT JOIN objekt_objekt ON objekt_objekt.objekt_id=objekt.objekt_id "; # bug 2817 # on praegu avaldatud JA ei ole prügikatis (Bug #1373) JA.. $sql .= " WHERE on_avaldatud=1 AND objekt_objekt.parent_id<>'" . $site->alias("trash") . "' "; # ..alguskuupäev täidetud ja hilisem praegusest VÕI. $sql .= " AND (avaldamisaeg_algus > " . $site->db->unix2db_datetime(time()) . " "; # ..lõppkuupäev täidetud ja varasem praegusest $sql .= " OR (avaldamisaeg_lopp>0 AND avaldamisaeg_lopp < " . $site->db->unix2db_datetime(time()) . ")) "; $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); while ($objekt_id = $sth->fetchsingle()) { # tee objekt. ja tee seda superuserina, Bug #805 ( muidu on nii, et kui pageloadi ajal püütakse avaldada objekti, millele sellel juhuslikul useril õiguseid ei ole, siis seda ka autom. avaldada ei suudeta) $obj = new Objekt(array("objekt_id" => $objekt_id, "superuser" => 1)); $sql = $site->db->prepare("UPDATE objekt SET on_avaldatud=0 WHERE objekt_id=?", $objekt_id); $sth2 = new SQL($sql); $site->debug->msg($sth2->debug->get_msgs()); new Log(array('action' => 'hide', 'objekt_id' => $obj->objekt_id, 'user_id' => $is_pageloaded ? 0 : $site->user->id, 'message' => sprintf("%s '%s' (ID = %s) %s", ucfirst(translate_en($obj->all[klass])), $obj->pealkiri(), $obj->objekt_id, "hided"))); } # while }
function smarty_function_init_assets($params, &$smarty) { global $site, $leht, $template, $class_path; $content_template =& $leht->content_template; include_once $class_path . 'profile.class.php'; $assets = array(); ############## # default values extract($params); if (!isset($name)) { $name = "assets"; } if (!isset($parent)) { $parent = $leht->id; } $parent_id = trim($parent); switch ($on_create) { case "publish": $publish = 1; break; case "hide": $publish = 0; break; default: $publish = 0; } # NB! kui t��p on asset, siis PEAB alati kaasas olema ka profiili ID # (muidu ei oma custom asset m�tet); # kui pole profile parameetrit, anda toimetajale veateade ja v�ljuda: if (!$profile) { if ($site->admin) { print "<font color=red><b>Profile parameter is required!</b></font>"; } exit; } # for language compatibility, replace order with existing db field name $order = preg_replace('#\\btitle\\b#i', "pealkiri", $order); $order = preg_replace('#\\bdate\\b#i', "aeg", $order); ############## ## deprecated parameter "fields" if (isset($fields)) { $get_object_fields .= "," . $fields; } # put all fields filter into arr $get_object_fields_arr = split(",", $get_object_fields); $i = 0; foreach ($get_object_fields_arr as $tmp) { $get_object_fields_arr[$i] = trim($tmp); $i++; } ############## # put all profile names into arr $profile_names = split(",", $profile); ############## # get all profile data from cash foreach ($profile_names as $profile_name) { # profile name is case insensitive $profile_name = strtolower($profile_name); $profile_def = $site->get_profile(array(name => $profile_name)); # sanity check: kui ei leitud sellise nimega profiili, anda toimetajale veateade ja v�ljuda: if (!$profile_def[profile_id]) { if ($site->admin) { print "<font color=red><b>Profile '" . $profile_name . "' not found!</b></font>"; } exit; } $profile_ids[] = $profile_def[profile_id]; $profile_arr[$profile_def[profile_id]] = $profile_def; } if (($id || $parent_id) && sizeof($profile_ids) > 0) { # one object if ($id) { ############## # luua objekt $obj = new Objekt(array(objekt_id => $id)); $obj->load_sisu(); $obj->hit_count = $obj->all['count']; $alamlist = new ObjektArray(); $alamlist->add($obj); } elseif ($parent_id) { # loop over profile ID-s foreach ($profile_ids as $profile_id) { $where_sql[] = "obj_asset.profile_id = '" . $profile_id . "'"; $profile_def = unserialize($profile_arr[$profile_id]['data']); if (!is_array($profile_def)) { $profile_def = array(); } # loop over one profile fields foreach ($profile_def as $key => $data) { if (!$get_object_fields || sizeof($get_object_fields_arr) > 0 && in_array($data[name], $get_object_fields_arr)) { $select_sql[] = ($data['is_predefined'] ? 'objekt' : 'obj_asset') . "." . $key; if ($contains) { $contains_sql[] = ($where ? " AND " : "") . $key . $site->db->prepare(" LIKE ?", '%' . $contains . '%'); } } if ($where) { # replace technical name with field name $where = str_replace($data['name'], $key, $where); } if ($order) { $order = str_replace($data['name'], $key, $order); } if ($select) { $select = str_replace($data['name'], $key, $select); } } # / loop over one profile fields } # / loop over profile ID-s ############## # create SQL $alamlistSQL = new AlamlistSQL(array(parent => $parent_id, klass => "asset", order => $order, asukoht => $position)); $alamlistSQL->add_select("obj_asset.profile_id"); if (isset($select)) { $alamlistSQL->add_select($select); } if (sizeof($select_sql) > 0) { $alamlistSQL->add_select(join(", ", $select_sql)); } $alamlistSQL->add_from("LEFT JOIN obj_asset ON objekt.objekt_id=obj_asset.objekt_id"); $alamlistSQL->add_where("(" . join(" OR ", $where_sql) . ")"); if ($where) { $alamlistSQL->add_where($where); } if (sizeof($contains_sql) > 0) { $alamlistSQL->add_where(join(" OR ", $contains_sql)); } $alamlist = new Alamlist(array(alamlistSQL => $alamlistSQL, start => $start, limit => $limit)); $alamlist->debug->print_msg(); $alamlist_count = new Alamlist(array(alamlistSQL => $alamlistSQL, on_counter => 1)); ############## # load variables $new_button = $alamlist->get_edit_buttons(array(tyyp_idlist => "20", profile_id => join(",", $profile_ids), asukoht => $position, publish => $publish)); } # id or list $all_change_fields = array(); $all_selectlist = array(); # array of ID-s which need additional steps to convert ID-s to human readable NAME-s (assets or users/groups) if (!isset($buttons)) { $buttons = array('new', 'edit', 'hide', 'move', 'delete'); } else { $buttons = split(',', $buttons); } while ($obj = $alamlist->next()) { $obj->id =& $obj->objekt_id; $obj->class = $obj->all[klass]; # translate it to english $obj->buttons = $obj->get_edit_buttons(array('nupud' => $buttons, tyyp_idlist => "20", profile_id => join(",", $profile_ids), publish => $publish)); $obj->date = $site->db->MySQL_ee_short($obj->all['aeg']); $obj->datetime = $site->db->MySQL_ee($obj->all['aeg']); $obj->fdate = substr($obj->all['aeg'], 0, strpos($obj->all['aeg'], ' ')); $obj->fdatetime = $obj->all['aeg']; $obj->last_modified = date('d.m.Y H:i', $obj->all['last_modified']); $obj->flast_modified = $obj->all['last_modified']; $obj->details_link = $site->self . '?id=' . $obj->objekt_id; $obj->details_title = $site->sys_sona(array(sona => "loe edasi", tyyp => "kujundus")); $obj->title = $obj->pealkiri; $obj_profile = new Profile(array("id" => $obj->all['profile_id'])); // bug #2455 if (is_array($obj_profile->data)) { foreach ($obj_profile->data as $profile_key => $profile_data) { if ($profile_key != $profile_data['name'] && !isset($obj->all[$profile_data['name']])) { $obj->all[$profile_data['name']] =& $obj->all[$profile_key]; } } } // / bug #2455 $obj->profile = $obj_profile->name; # name #### 1. set profile fields as object attributes $obj_profile->set_obj_general_fields(array("obj" => &$obj, "get_object_fields" => $get_object_fields)); ## gather all selectlist values into one array: if (sizeof($obj_profile->selectlist) > 0) { $all_selectlist = array_merge($obj_profile->selectlist, $all_selectlist); } ## gather all need_change_obj values into one array: # that means object attributes has to be cahnged later. remeMber fields for each obj. if (sizeof($obj_profile->change_fields) > 0) { $all_change_fields[$obj->id] = $obj_profile->change_fields; } #printr($obj_profile->change_fields); $obj->created_user_id = $obj->all['created_user_id']; $obj->created_user_name = $obj->all['created_user_name']; $obj->changed_user_id = $obj->all['changed_user_id']; $obj->changed_user_name = $obj->all['changed_user_name']; $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']); $obj->fcreated_time = $obj->all['created_time']; $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']); $obj->fchanged_time = $obj->all['changed_time']; ### push array_push($assets, $obj); } //printr($all_selectlist); ################### # get selectlist values - 1 (or 2, if system tables involved) extra sql per function; sql is fast if (sizeof($all_selectlist) > 0) { # 2. save array "->asset_names" human readable NAME-s: $obj_profile->get_asset_names(array("selectlist" => $all_selectlist)); #printr($obj_profile->asset_names); #printr($all_change_fields); ############### # assign names to attributes #echo printr($asset_names); ############### # loop over asset objects and changes attributes values correct $i = 0; foreach ($assets as $tmp) { # pointer to array element: $obj =& $assets[$i]; # go on if object values needs changing: if (in_array($obj->id, array_keys($all_change_fields))) { #print "<br>muuta ID: ".$obj->id; ### 3. save object rest of attributes $obj_profile->set_obj_selectlist_fields(array("obj" => &$obj, "change_fields" => $all_change_fields[$obj->id])); } # if need to change $i++; } } # if any selectvalue is to get # / get selectlist values ################### } # if parameters are OK $count = $alamlist->rows; $counttotal = isset($limit) ? $alamlist_count->rows : $count; ############## # assign to template variables $smarty->assign(array($name => $assets, $name . '_newbutton' => $new_button, $name . '_counttotal' => $counttotal, $name . '_rows' => $counttotal, $name . '_count' => $count)); }
on_debug=>$debug, on_admin_keel => 1 )); $objekt = new Objekt(array( objekt_id => $site->fdat[id], no_cache => 1 )); # kui objektil on rohkem, kui 1 parent, siis loodame objekti uuesti uue parentiga: if ($objekt->all['parents_count']>1 && $objekt->parent_id!=$site->fdat['parent_id']){ $site->debug->msg("Leidsin mitu parenti (".$objekt->all['parents_count']."). Kasutan parent_id=".$site->fdat['parent_id']); unset($objekt); $objekt = new Objekt(array( objekt_id => $site->fdat['id'], parent_id => $site->fdat['parent_id'], no_cache =>1, )); } # ------------------------------------- # Objekt leitud # ------------------------------------- if ($objekt) { ########################### # ACCESS allowed/denied # decide if accessing this page is allowed or not
function smarty_function_init_album($params, &$smarty) { global $site, $leht, $template; $content_template =& $leht->content_template; $albums = array(); ############## # default values extract($params); if (!isset($name)) { $name = "album"; } switch ($on_create) { case "publish": $publish = 1; break; case "hide": $publish = 0; break; default: $publish = 0; } $album = new Objekt(array(objekt_id => $id)); $conf = new CONFIG($album->all['ttyyp_params']); $col = $conf->get("cols") > 0 ? $conf->get("cols") : 3; $row = $conf->get("rows") > 0 ? $conf->get("rows") : 3; $args['num'] = $args['col']; $alamlist_count = new Alamlist(array(parent => $album->objekt_id, klass => "pilt", asukoht => 0, on_counter => 1)); $alamlist = new Alamlist(array(parent => $album->objekt_id, klass => "pilt", asukoht => 0, start => $start, limit => $limit)); $new_button = $alamlist->get_edit_buttons(array(tyyp_idlist => "12", publish => $publish)); $edit_button = $album->get_edit_buttons(array(tyyp_idlist => "16", publish => $publish)); $title =& $album->pealkiri; while ($obj = $alamlist->next()) { $obj->load_sisu(); $obj->buttons = $obj->get_edit_buttons(array(tyyp_idlist => "12", publish => $publish)); $obj->get_object_href(); //$obj->href = $site->self.'?id='.$obj->objekt_id; $obj->title = $obj->pealkiri; $obj->date = $site->db->MySQL_ee_short($obj->all['aeg']); $obj->datetime = $site->db->MySQL_ee($obj->all['aeg']); $obj->fdate = substr($obj->all['aeg'], 0, strpos($obj->all['aeg'], ' ')); $obj->fdatetime = $obj->all['aeg']; $obj->id = $obj->objekt_id; $obj->class = translate_en($obj->all[klass]); # translate it to english $obj->thumbnail = "<a href=\"" . $site->self . "?id=" . $obj->objekt_id . "\"><img src=\"" . $site->CONF['wwwroot'] . ($site->admin ? "/editor" : "") . "/image.php?" . $obj->objekt_id . "t\" border=\"0\"></a>"; $obj->created_user_id = $obj->all['created_user_id']; $obj->created_user_name = $obj->all['created_user_name']; $obj->changed_user_id = $obj->all['changed_user_id']; $obj->changed_user_name = $obj->all['changed_user_name']; $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']); $obj->fcreated_time = $obj->all['created_time']; $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']); $obj->fchanged_time = $obj->all['changed_time']; $obj->last_commented_time = $site->db->MySQL_ee($obj->all['last_commented_time']); $obj->comment_count = $obj->all['comment_count']; $obj->forum_allowed = $obj->all['on_foorum']; #####push array_push($albums, $obj); } ############## # assign to template variables $smarty->assign(array($name => $albums, $name . '_newbutton' => $new_button, $name . '_editbutton' => $edit_button, $name . '_title' => $title, $name . '_col' => $col, $name . '_row' => $row, $name . '_count' => $alamlist_count->rows)); }
/** * edit_artikkel.php * */ function edit_objekt() { function print_profiles() { global $site, $objekt; $sql = $site->db->prepare("SELECT profile_id AS id, source_table AS parent, name FROM object_profiles WHERE source_table=? ORDER BY name",'obj_artikkel'); $sth = new SQL($sql); # get object profile if($objekt->all['profile_id']) { $profile_def = $site->get_profile(array("id"=>$objekt->all['profile_id'])); $site->fdat['profile_id'] = $profile_def['profile_id']; } # if still not found then use default profile for this class if(!$profile_def['profile_id'] && !$site->fdat['profile_id']) { $site->fdat['profile_id'] = $site->get_default_profile_id(array("source_table" => 'obj_artikkel')); $profile_def = $site->get_profile(array("id"=>$site->fdat['profile_id'])); } ?> <fieldset> <legend> <select onchange="changeProfile(this)" name="profile_id"> <?php $all_profiles_hash = array(); while ($profile_data = $sth->fetch()){ $all_profiles_hash[] = $profile_data['id']; print "<option value='".$profile_data['id']."' ".($profile_data['id']==$site->fdat['profile_id'] ? ' selected':'').">".$site->sys_sona(array(sona => $profile_data['name'], tyyp=>"custom"))."</option>"; } ?> </select> </legend> <?php foreach($all_profiles_hash as $profile_id) { ?> <div id="profile_<?= $profile_id ?>" style="display: <?=($site->fdat['profile_id'] == $profile_id ? 'block' : 'none');?>;"> <table cellpadding="0" cellspacing="0"> <?php $profile_def = $site->get_profile(array("id"=>$profile_id)); $profile_fields = unserialize($profile_def['data']); # if profile fields exist if(is_array($profile_fields) && sizeof($profile_fields)>0){ ## add suffix for each field, to get unique id-s foreach($profile_fields as $key=>$tmp_prof){ $profile_fields[$key]['html_fieldname'] = $profile_fields[$key]['name']."_".$profile_id; # field can be INPUT or READ-ONLY value - this info may be passed from triggers file "actions.inc.php", using "$site->fdat" array $profile_fields[$key]['is_readonly'] = $site->fdat['is_readonly_'.$key]; } #printr($profile_fields); ################### # print profile fields rows print_profile_fields(array( 'profile_fields' => $profile_fields, 'field_values' => $objekt->all, )); } # if profile fields exist ?> </table> </div> <?php } //foreach ?> </fieldset> <fieldset> <legend><?=$site->sys_sona(array('sona' => 'visible_to_visitors', 'tyyp' => 'editor'))?></legend> <input type="radio" name="publish" id="object_published" value="1"<?=($site->fdat['publish'] || $objekt->all['on_avaldatud'] ? ' checked' : '')?>> <label for="object_published"><?=$site->sys_sona(array('sona' => 'published', 'tyyp' => 'editor'))?></label><br> <input type="radio" name="publish" id="object_unpublished" value="0"<?=($site->fdat['publish'] == 0 && $objekt->all['on_avaldatud'] == 0 ? ' checked' : '')?>> <label for="object_unpublished"><?=$site->sys_sona(array('sona' => 'unpublished', 'tyyp' => 'editor'))?></label><br> </fieldset> <fieldset> <?php ####### dont show checkbox "Headline is visible" if config variable "killheadlineisvisible" is true in file config.php if($site->CONF['killheadlineisvisible']) { ?> <input type="hidden" id="on_pealkiri" name="on_pealkiri" value="<?=($site->fdat['op'] == 'new' ? 1 : $objekt->all['on_pealkiri'])?>"> <?php } else { # by default: show it ?> <div> <input type="checkbox" id="on_pealkiri" name="on_pealkiri" value="1" <?=($site->fdat['op'] == 'new') ? 'checked' : ($objekt->all['on_pealkiri'] ? 'checked' : null)?>> <label for="on_pealkiri"><?=$site->sys_sona(array(sona => 'Pealkiri on nahtav', tyyp => 'editor'));?></label> </div> <?php } ?> <div> <input type="checkbox" name="on_foorum" id="on_foorum" value="1" <?=($objekt->all['on_foorum'] || ($site->fdat['op'] == 'new' && ($site->CONF['default_comments'] || $site->fdat['allow_comments'])) ? 'checked' : null)?>> <label for="on_foorum"><?=$site->sys_sona(array(sona => "Foorum lubatud", tyyp=>"editor"))?></label> </div> <?php if ($site->CONF['enable_mailing_list']) { ## Bug #2590 ## fuzzy logic: if editor checks here checkbox "is mailinglist", # then field "on_saadetud" is set to "0" and that means article is included in next mailinglist routine. ?> <div> <input type="checkbox" name="on_saadetud" id="on_saadetud" value="1" <?=($objekt->all['on_saadetud'] ? null : "checked");?>> <label for="on_saadetud"><?=$site->sys_sona(array(sona => 'On meilinglist', tyyp=>'editor'));?></label> </div> <?php } ?> </fieldset> <fieldset> <table cellpadding="1" cellspacing="1" border="0" style="color: #999;"> <?php if ($objekt->all['created_user_name']) { ?> <?php if ($site->CONF['allow_change_position']) { ?> <tr> <td><?=$site->sys_sona(array('sona' => 'position', 'tyyp' => 'Editor'));?>:</td> <td> <input type="text" name="kesk" value="<?=$objekt->all['kesk']?>" style="width: 40px; text-align: right;"> </td> </tr> <?php } ?> <tr> <td><?=$site->sys_sona(array('sona' => 'object_created', 'tyyp' => 'Editor'));?>:</td> <td><?=date('d.m.Y H:i', strtotime($objekt->all['created_time']));?></td> </tr> <tr> <td></td> <td><?=$objekt->all['created_user_name'];?></td> </tr> <?php } ?> <?php if ($objekt->all['changed_user_name']) { ?> <tr> <td><?=$site->sys_sona(array('sona' => 'object_changed', 'tyyp' => 'Editor'));?>:</td> <td><?=date('d.m.Y H:i', strtotime($objekt->all['changed_time']));?></td> </tr> <tr> <td></td> <td><?=$objekt->all['changed_user_name'];?></td> </tr> <?php } ?> </table> </fieldset> <?php } // end function print_profile() function print_sections() { global $site, $objekt, $class_path, $keel; $tmpkeel = $keel; if (!is_numeric($tmpkeel)){ $sql = $site->db->prepare("SELECT keel FROM objekt WHERE objekt_id=?", $site->fdat['parent_id']); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); $tmpkeel = $sth->fetchsingle(); } $sections = array($site->fdat['parent_id']); if ($objekt->objekt_id) { $sql = $site->db->prepare("SELECT parent_id FROM objekt_objekt WHERE objekt_id=?", $objekt->objekt_id); $result = new SQL ($sql); while ($data = $result->fetch('ASSOC')) { $sections[] = $data['parent_id']; } } if ($site->fdat['permanent_parent_id'] == '') { include_once($class_path.'rubloetelu.class.php'); $all_sections = new RubLoetelu(array('keel' => $keel)); $all_sections = $all_sections->get_loetelu(); asort($all_sections); } ?> <script type="text/javascript"> // the sections list var all_sections = Array(); // for Mozilla the section list doesn't stretch dynamically so add this increment value to the containing elements height var heightIncrement = 10; function createSectionNodeSet(sectionNode, section_id, section_name) { var input = document.createElement('input'); input.type = 'hidden'; input.name = 'rubriik[]'; input.value = section_id; sectionNode.appendChild(input); var buttons = document.createElement('div'); buttons.id='button_' + section_id; if(sectionNode.parentNode) { for(var i = 0; i < sectionNode.parentNode.childNodes.length; i++) if(sectionNode.parentNode.childNodes[i].tagName == 'LI') break; if(sectionNode.id != sectionNode.parentNode.childNodes[i].id) { var del_button = document.createElement('a'); del_button.href = "javascript:deleteSection('" + section_id +"');"; del_button.innerHTML = '<img src="<?=$site->CONF['wwwroot'].$site->CONF['styles_path'];?>/gfx/editor/delete.gif">'; buttons.appendChild(del_button); } } sectionNode.appendChild(buttons); var link = document.createElement('a'); link.href = "javascript:opopup('"+ section_id +"');"; link.innerHTML = section_name; sectionNode.appendChild(link); return sectionNode; } // add a new item to the section list function opopup(section_id){ var pre_selected=''; if(section_id !=''){ pre_selected = '&pre_selected=' + section_id; explorer_window = openpopup('explorer.php?objekt_id=home&editor=1&swk_setup=current_article_parent_selection' + pre_selected, 'cms_explorer', '800','600', 'auto'); }else{ explorer_window = openpopup('explorer.php?objekt_id=home&editor=1&swk_setup=article_parent_selection', 'cms_explorer', '800','600', 'auto'); } } function addNewSection(node) { explorer_window.close(); for(var j = 0; j < node.length; j++){ var error = false; for(var i = 0; i < all_sections.length; i++){ /* no duplicates */ if (all_sections[i] == node[j].objekt_id){ //return; error = true; }else{ } } if(!error){ var trail_path= new Array(); for(var z = 0; z < node[j].trail.length; z++){ trail_path[z] = node[j].trail[z].pealkiri; } var sections = document.getElementById('sections'); var item = document.createElement('li'); item.id = 'section_' + node[j].objekt_id; sections.appendChild(item); item = createSectionNodeSet(item, node[j].objekt_id, trail_path.join("->")); var container = document.getElementById('sections_container'); container.height = Number(container.height) + heightIncrement; all_sections[all_sections.length] = node[j].objekt_id; } for(var b = 0; b < all_sections.length; b++){ var c = all_sections[b]; var x = document.getElementById("button_" + c); x.style.visibility = "visible"; } } return; } // /function addNewSection function deleteSection(section_id) { var section = document.getElementById('section_' + section_id); section.parentNode.removeChild(section); var container = document.getElementById('sections_container'); //container.height = Number(container.height) - heightIncrement; // delete from duplicate checklist var new_all_sections =new Array(); for(var i = 0; i < all_sections.length; i++){ if (all_sections[i] == section_id){ all_sections[i] = null; }else{ new_all_sections.push(all_sections[i]); } } all_sections=new_all_sections; var c = 0; var d = ''; for(var b = 0; b < all_sections.length; b++){ if (all_sections[b] != null){ c++; d=all_sections[b]; } } if(c == 1){ document.getElementById('button_' + d).style.visibility = 'hidden'; } return; } // /function deleteSection function modifySection(node,section_id) { explorer_window.close(); for(var j = 0; j < node.length; j++){ var error = false; for(var i = 0; i < all_sections.length; i++){ /* no duplicates */ if (all_sections[i] == node[j].objekt_id){ //return; error = true; }else{ } } if(!error){ var trail_path= new Array(); for(var z = 0; z < node[j].trail.length; z++){ trail_path[z] = node[j].trail[z].pealkiri; } var section = document.getElementById('section_' + section_id); section.innerHTML = ''; section = createSectionNodeSet(section, node[j].objekt_id, trail_path.join("->")); section.id = 'section_' + node[j].objekt_id; /* delete from duplicate checklist */ for(var i = 0; i < all_sections.length; i++) if (all_sections[i] == section_id) all_sections[i] = null; all_sections[all_sections.length] = node[j].objekt_id; } } return; } // /function modifySection </script> <? // setup for new section selection $_SESSION['article_parent_selection']['callback'] = 'window.opener.addNewSection'; $_SESSION['article_parent_selection']['selectable'] = 2; $_SESSION['article_parent_selection']['hide_language_selection'] = '1'; $_SESSION['article_parent_selection']['mem_classes'] = array('rubriik', ); //this sucks, really $_SESSION['article_parent_selection']['db_fields'] = array('select_checkbox', 'objekt_id', 'pealkiri', ); $_SESSION['article_parent_selection']['display_fields'] = array('select_checkbox', 'pealkiri', ); // setup for current section change $_SESSION['current_article_parent_selection']['callback'] = 'window.opener.modifySection'; $_SESSION['current_article_parent_selection']['selectable'] = 1; $_SESSION['current_article_parent_selection']['hide_language_selection'] = '1'; $_SESSION['current_article_parent_selection']['mem_classes'] = array('rubriik', ); //this sucks, really $_SESSION['current_article_parent_selection']['db_fields'] = array('select_checkbox', 'objekt_id', 'pealkiri', ); $_SESSION['current_article_parent_selection']['display_fields'] = array('select_checkbox', 'pealkiri', ); ?> <div class="sections_header"> <div> <a href="#" id="new_section" onClick="opopup(''); return false;"><?=$site->sys_sona(array(sona => "New", tyyp=>"editor"))?></a> </div> <?=$site->sys_sona(array(sona => "Rubriigid", tyyp=>"editor"))?> </div> <ul id="sections" class="sections"> <?php $home_section = $site->alias(array('key'=>'rub_home_id', 'keel'=>$tmpkeel)); $i = 0; foreach ($all_sections as $section_id => $section_name) { # Bug #2264: Uuele artiklile KAKS v�i rohkem eeldefineeritud parentit (triggers) if ($section_id != $home_section && (in_array($section_id, $sections) || (is_array($site->fdat['parents_arr']) && in_array($section_id,$site->fdat['parents_arr']))) ) { ?> <script type="text/javascript"> all_sections[all_sections.length] = <?=$section_id?>; </script> <?if($i==0){$first_section=$section_id;}?> <li id="section_<?=$section_id;?>"> <input type="hidden" name="rubriik[]" value="<?=$section_id;?>"> <div id="button_<?=$section_id;?>"><a href="javascript:deleteSection('<?=$section_id;?>');"><img src="<?=$site->CONF['wwwroot'].$site->CONF['styles_path'];?>/gfx/editor/delete.gif"></a></div> <a href="javascript:opopup('<?=$section_id;?>');"><?=$section_name;?></a> </li> <?php $i++; } } ?> </ul> <?php if($i == 1){?> <script type="text/javascript"> document.getElementById('button_<?=$first_section;?>').style.visibility = 'hidden'; </script> <?}?> <!-- /rubriigid --> <?php } /* end function print_sections2() */ global $site, $class_path, $objekt, $tyyp, $keel; include_once($class_path.'adminpage.inc.php'); include_once($class_path.'SCMSEditor.php'); include_once($class_path.'extension.class.php'); $editor = new SCMSEditor('scms_article_editor') ; if($site->fdat['op'] == 'new') { $editor->Value = ''; } else { $editor->Value = ($objekt->lyhi->get_text() ? $objekt->lyhi->get_text().'<hr class="scms_lead_body_separator" />' : '').($objekt->sisu->get_text() ? $objekt->sisu->get_text() : ''); // bug #2388 Tagaside vormist eemaldada e-maili aadress, tagasiasendus if(preg_match_all('/<input(.*?)>/', $editor->Value, $matches)) { $systemfields = array(); foreach ($matches[0] as $match) { if(strpos($match,'type="hidden"') && strpos($match,'name="systemfield"')) $systemfields[] = $match; } foreach ($systemfields as $systemfield) { if(preg_match('/value="(.*?)\|\|\|(.*?)\|\|\|(.*?)\|\|\|/', $systemfield, $matches)) { $sql = $site->db->prepare('select mail from allowed_mails where id = ?;', $matches[1]); $result = new SQL($sql); $mail = $result->fetchsingle(); $editor->Value = str_replace('value="'.$matches[1].'|||', 'value="'.$mail.'|||', $editor->Value); } } } // /form allowed mails check/insert } $editor->Height = '100%'; $editor->Width = '100%'; $editor->ToolbarSet = ''; $editor->BasePath = (empty($_SERVER['HTTPS']) ? 'http://': 'https://').$site->CONF['hostname'].$site->CONF['wwwroot'].$site->CONF['js_path'].'/fckeditor/'; // create config array $Config['CustomConfigurationsPath'] = $editor->BasePath.'scms_config.js'; $Config['SkinPath'] = $editor->BasePath.'editor/skins/scms/'; $Config['ToolbarCanCollapse'] = false; $Config['SCMSFormName'] = $site->CONF['feedbackform_form_name']; $Config['SCMSFormAction'] = $site->CONF['feedbackform_action']; $Config['SCMSFormMethod'] = $site->CONF['feedbackform_method']; $Config['SCMSFormHiddenName'] = 'systemfield'; $Config['SCMSFormHiddenString'] = $site->CONF["default_mail"].'|||index.php?id='.$site->alias(array('key'=>"error_page", 'keel'=>$keel )).'|||index.php?id='.$site->alias(array('key'=>"ok_page", 'keel'=>$keel )).'|||'.$site->CONF["subject"]; $default_toolbar = 'SCMS_simple'; if($_COOKIE['scms_toolbar']) { $default_toolbar = $_COOKIE['scms_toolbar']; } // load custom values for FCKeditor config foreach (get_extensions('DB', true) as $act_ext) { if(file_exists($act_ext['fullpath'].'/extension.config.php')) // assume this is the right one { $EXTENSION =& load_extension_config($act_ext); // set the toolbar, later TODO user based toolbars if($site->user->is_superuser) { if($EXTENSION['wysiwyg_config']['SuperUserToolbarSet']) { $editor->ToolbarSet = $EXTENSION['wysiwyg_config']['SuperUserToolbarSet']; } elseif($EXTENSION['wysiwyg_config']['DefaultToolbarSet']) { $editor->ToolbarSet = $EXTENSION['wysiwyg_config']['DefaultToolbarSet']; } else { $editor->ToolbarSet = $default_toolbar; } } else { $roles = array(); $sql = 'select role_id, name from roles;'; $result = new SQL($sql); while($row = $result->fetch('ASSOC')) { $roles[$row[role_id]] = $row['name']; } foreach((array)$EXTENSION['wysiwyg_config']['ToolbarSets'] as $role => $set) { if($role) { $key = array_search($role, $roles); if($key !== null && in_array($key, $site->user->roles)) { $editor->ToolbarSet = $set; break; } } } if(!$editor->ToolbarSet) { ($EXTENSION['wysiwyg_config']['DefaultToolbarSet'] ? $editor->ToolbarSet = $EXTENSION['wysiwyg_config']['DefaultToolbarSet'] : $editor->ToolbarSet = $default_toolbar); } } // set the config if(is_array($EXTENSION['wysiwyg_config']['Config'])) $Config = array_merge($Config, $EXTENSION['wysiwyg_config']['Config']); break; // get only the first } } if(!$editor->ToolbarSet) $editor->ToolbarSet = $default_toolbar; $editor->Config = $Config; // somethings are not allowed to be overwritten $editor->Config['PluginsPath'] = $editor->BasePath.'editor/plugins/'; $editor->Config['EditorAreaCSS'] = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://').$site->CONF['hostname'].$site->CONF['wwwroot'].'/styles.php?with_wysiwyg=1'; $editor->Config['CustomStyles'] = ''; $editor->Config['StylesXmlPath'] = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://').$site->CONF['hostname'].$site->CONF['wwwroot'].'/admin/fckstyles.php'; $editor->Config['FormatOutput'] = false; $editor->Config['AutoDetectLanguage'] = false; $editor->Config['DefaultLanguage'] = substr($_SESSION['keel_admin']['locale'], 0, 2); $editor->Config['ProcessHTMLEntities'] = false; $editor->Config['Debug'] = false; //$editor->Config['FitWindow_autoFitToResize'] = true; $editor->Config['CurrentToolbar'] = $editor->ToolbarSet; //printr($editor->Config); //printr($editor->ToolbarSet); // setup for site linking $_SESSION['site_linking']['callback'] = 'window.opener.frames[0].site_linking'; $_SESSION['site_linking']['selectable'] = 1; $_SESSION['site_linking']['mem_classes'] = array('rubriik', 'artikkel', ); //this sucks, really $_SESSION['site_linking']['db_fields'] = array('select_checkbox', 'objekt_id', 'pealkiri', 'klass',); $_SESSION['site_linking']['display_fields'] = array('select_checkbox', 'pealkiri', 'klass',); // /setup for site linking $parent = new Objekt(array('objekt_id' => $site->fdat['parent_id'])); // to get the correct path to parent objects set use_alises on $site->CONF['use_aliases'] = 1; $parent_href = $parent->get_object_href(); if($site->CONF['alias_trail_format'] == 0 || $parent->all['sys_alias'] == 'home' || $parent->all['sys_alias'] == 'trash' || $parent->all['sys_alias'] == 'system' || $parent->all['sys_alias'] == 'gallup_arhiiv') $parent_href = preg_replace('#'.preg_quote('/'.($parent->all['friendly_url'] ? $parent->all['friendly_url'] : $parent->objekt_id), '#').'/$#', '/', $parent_href); $parent_href = $site->CONF['hostname'].$parent_href; // setup file insert $_SESSION['scms_filemanager_settings']['scms_wysiwyg_insert_file'] = array( 'select_mode' => 1, // 1 - select single file 'action_text' => $site->sys_sona(array('sona' => 'fm_choose_file_into_article', 'tyyp' => 'editor')), 'action_trigger' => $site->sys_sona(array('sona' => 'fm_insert_file_into_article', 'tyyp' => 'editor')), 'callback' => 'window.opener.frames[0].SCMSImageFileInsert', ); ?> <html> <head> <title><?=$site->title;?> <?=$site->cms_version;?></title> <meta http-equiv="Content-Type" content="text/html; charset=<?=($encoding ? $encoding : $site->encoding);?>"> <meta http-equiv="Cache-Control" content="no-cache"> <link rel="stylesheet" href="<?=$site->CONF['wwwroot'].$site->CONF['styles_path'].'/article_editor.css';?>" media="screen"> <script type="text/javascript" src="<?=$site->CONF['wwwroot'].$site->CONF['js_path'];?>/yld.js"></script> <script type="text/javascript" src="<?=$site->CONF['wwwroot'].$site->CONF['js_path']?>/edit_popup.js"></script> <link rel="stylesheet" href="<?=$site->CONF['wwwroot'].$site->CONF['styles_path']?>/datepicker.css"> <script type="text/javascript" src="<?=$site->CONF['wwwroot'].$site->CONF['js_path'] ?>/jquery.js"></script> <script type="text/javascript" src="<?=$site->CONF['wwwroot'].$site->CONF['js_path'] ?>/datepicker.js"></script> <script type="text/javascript" src="<?=$site->CONF['wwwroot'];?>/common.js.php"></script> <script type="text/javascript"> function FCKeditor_OnComplete( editorInstance ) { <?php if($objekt->objekt_id) { ?> var oSCMSEditor = FCKeditorAPI.GetInstance('scms_article_editor') ; oSCMSEditor.Focus(); <?php } else { ?> document.frmEdit.pealkiri.focus(); <?php } ?> window.moveTo((screen.width - 880) / 2, (screen.height - 660) / 2); window.resizeTo(880, 660); } function editAlias() { var alias_placeholder = document.getElementById('alias_placeholder'); var alias_value = document.getElementById('alias_value'); alias_placeholder.innerHTML = '<input type="text" id="alias" value="' + alias_value.value + '" onblur="saveAlias();">'; var alias = document.getElementById('alias'); alias.focus(); } function saveAlias() { var alias_placeholder = document.getElementById('alias_placeholder'); var alias_value = document.getElementById('alias_value'); var alias = document.getElementById('alias'); if(alias_value.value != alias.value) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: alias.value, language_id: '<?=$keel;?>'}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; }, success: function(response) { if(response.alias) { alias_value.value = response.alias; alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; } else { alias_value.value = ''; <?php if($objekt->objekt_id) { ?> alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + '<?=$objekt->objekt_id;?>' + '</a>'; <?php } else { ?> alias_placeholder.innerHTML = '<input type="text" id="alias" value="" onblur="saveAlias();">'; <?php } ?> } } }); } else { if(!alias.value) { alias_value.value = ''; <?php if($objekt->objekt_id) { ?> alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + '<?=$objekt->objekt_id;?>' + '</a>'; <?php } else { ?> alias_placeholder.innerHTML = '<input type="text" id="alias" value="" onblur="saveAlias();">'; <?php } ?> } else { alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; } } } function createAlias() { var alias_value = document.getElementById('alias_value'); var title = document.getElementById('pealkiri') if(0 || (!alias_value && title.value)) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: title.value, language_id: '<?=$keel;?>'}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { }, success: function(response) { var alias_cell = document.getElementById('alias_cell'); alias_cell.className = 'alias'; if(response.alias) { alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value="' + response.alias + '"><?=$parent_href;?><span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (response.alias.length > 30 ? response.alias.substring(0, 30) + '...' : response.alias) + '</a></span>'; } else { alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value=""><?=$parent_href;?><span id="alias_placeholder"><input type="text" id="alias" value="" onblur="saveAlias();"></span>'; } } }); } } function saveForm(op2) { var form = document.getElementById('frmEdit'); var title = document.getElementById('pealkiri') var alias_value = document.getElementById('alias_value'); var alias = document.getElementById('alias'); if((title.value && !alias_value) || (alias && alias_value && alias.value != alias_value.value)) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: title.value, language_id: '<?=$keel;?>'}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { var form = document.getElementById('frmEdit'); form.op2.value = op2; form.submit(); }, success: function(response) { var alias_value = document.getElementById('alias_value'); if(!alias_value && response.alias) { var alias_cell = document.getElementById('alias_cell'); alias_cell.className = 'alias'; alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value="' + response.alias + '"><?=$parent_href;?><span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (response.alias.length > 30 ? response.alias.substring(0, 30) + '...' : response.alias) + '</a></span>'; } var form = document.getElementById('frmEdit'); form.op2.value = op2; form.submit(); } }); } else { form.op2.value = op2; form.submit(); } } </script> <?php if ($editor->browser() == 'Gecko') { ?> <style type="text/css"> table.layout td.editor div { height: 100%; } </style> <?php } ?> </head> <body id="scms_editor_popup"> <form action="edit.php" method="POST" name="frmEdit" id="frmEdit" class="article_submit_form"> <?php /* hidden form stuff */ ?> <input type=hidden name="op" value="<?=$site->fdat['op'];?>"> <input type=hidden name="op2" id="op2" value="saveclose"> <input type=hidden name="refresh" value="0"> <input type="hidden" name="tyyp_id" value="<?=$tyyp['tyyp_id'];?>"> <input type="hidden" name="tyyp" value="<?=$tyyp['klass'];?>"> <input type="hidden" name="sys_alias" value="<?=$site->fdat['sys_alias'];?>"> <input type="hidden" name="id" value="<?=$site->fdat['id'];?>"> <input type="hidden" name="kesk" value="<?=$site->fdat['kesk'];?>"> <input type="hidden" name="parent_id" value="<?=$site->fdat['parent_id'];?>"> <input type="hidden" name="previous_id" value="<?=$site->fdat['previous_id'];?>"> <input type="hidden" name="keel" value="<?=$keel;?>"> <input type="hidden" name="baseurl" value="<?=(empty($_SERVER['HTTPS']) ? 'http://': 'https://').$site->CONF['hostname'].$site->CONF['wwwroot'];?>/"> <input type="hidden" name="wwwroot" value="<?=$site->CONF['wwwroot'];?>/"> <input type="hidden" name="sorting" value="<?=$site->fdat['sorting'];?>"> <input type="hidden" name="extension_path" value="<?=$site->fdat['extension_path'];?>"> <?php /* /hidden form stuff */ ?> <table cellpadding="0" cellspacing="0" class="layout" border="0"> <tr> <td> <table cellpadding="0" cellspacing="0" class="layout" border="0"> <tr> <td class="header"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td style=" font-size: 12px;font-weight: bold;"><label for="pealkiri"><?=$site->sys_sona(array('sona' => 'Pealkiri', 'tyyp' => 'editor'))?>: </label></td> <td width="100%"><input type="text" tabindex="1" id="pealkiri" name="pealkiri" value="<?=htmlspecialchars($objekt->pealkiri);?>" onblur="createAlias();"></td> </tr> </table> </td> </tr> <?php if($objekt->objekt_id) { ?> <tr> <td class="alias"><input type="hidden" name="friendly_url" id="alias_value" value="<?=htmlspecialchars($objekt->all['friendly_url']);?>"><?=$parent_href;?><span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link"><?=($objekt->all['friendly_url'] ? (strlen(htmlspecialchars($objekt->all['friendly_url'])) > 30 ? substr(htmlspecialchars($objekt->all['friendly_url']), 0, 30).'...' : htmlspecialchars($objekt->all['friendly_url'])) : $objekt->objekt_id);?></a></span></td> </tr> <?php } else { ?> <tr> <td id="alias_cell" class="alias"> </td> </tr> <?php } ?> <tr> <td class="editor"> <?=$editor->Create();?> </td> </tr> <tr> <td id="sections_container" class="sections"> <?=print_sections();?> </td> </tr> </table> </td> <td class="profiles"> <?=print_profiles();?> </td> </tr> </table> </form> <? if ($site->fdat['op']=='edit') {?> <iframe src="checkin.php?objekt_id=<?=$objekt->objekt_id ?>" style="width: 0; height: 0; display: none; visibility: hidden;"></iframe> <? } ?> </body> </html> <?php }
/** * This source file is is part of Saurus CMS content management software. * It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php). * Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/). * Redistribution of this file must retain the above copyright notice. * * Please note that the original authors never thought this would turn out * such a great piece of software when the work started using Perl in year 2000. * Due to organic growth, you may find parts of the software being * a bit (well maybe more than a bit) old fashioned and here's where you can help. * Good luck and keep your open source minds open! * * @package SaurusCMS * @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/) * @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php) * */ function smarty_function_save_profile($params, &$smarty) { global $site, $class_path, $leht; include_once $class_path . 'adminpage.inc.php'; // for check_profile_values() $id = (int) $params['id']; unset($params['id']); $parent_id = (int) $params['parent']; if (!$parent_id) { $parent_id = $leht->id; $current_objekt = $leht->objekt; } else { $current_objekt = new Objekt(array('objekt_id' => $parent_id)); } unset($params['parent']); if (!isset($params['name'])) { $name = 'insert_id'; } else { $name = $params['name']; } unset($params['name']); // for CMS objects on_create publishing $publish = strtoupper(trim($params['on_create'])) == 'PUBLISH' ? 1 : 0; unset($params['on_create']); # get all profile data from cash # profile name is case insensitive $profile = strtolower($params['profile']); unset($params['profile']); $profile = $site->get_profile(array('name' => $profile, 'id' => (int) $params['profile_id'])); $profile_field_values = $params['fields']; unset($params['fields']); # sanity check: kui ei leitud sellise nimega profiili, anda toimetajale veateade if (!$profile['profile_id']) { if ($site->admin) { print "<font color=red><b>Profile '" . $profile['name'] . "' not found!</b></font>"; } return; } // must go to source table $params['profile_id'] = $profile['profile_id']; // special cases for source table ID columns switch ($profile['source_table']) { case 'users': $source_table_id_column = 'user_id'; break; case 'groups': $source_table_id_column = 'group_id'; break; default: $source_table_id_column = 'objekt_id'; break; } // if source_table is ext_ table if (strpos($profile['source_table'], 'ext_') === 0) { $source_table_id_column = 'id'; } //printr($profile); $source_table_columns = array(); $profile_data = unserialize($profile['data']); foreach ($profile_data as $column => $data) { if ($data['is_active']) { if ($data['is_general']) { $source_table_columns[] = 'objekt.' . $column; } else { $source_table_columns[] = $profile['source_table'] . '.' . $column; } } } //printr($source_table_columns); $profile_field_values = array(); $profile_data['id'] = 0; foreach (array_keys($profile_data) as $key) { $profile_field_values[$key] = ''; } //check profile filed values, errors go into $site->fdat['form_error'] $sql_values = check_profile_values(array('profile_def' => $profile, 'skip_non_active_fields' => true, 'use_only_profile_fields' => true)); $sql_values_skip_prepare = array(); // add additional fields to sql values foreach ($params as $field_name => $field_value) { $sql_values[$field_name] = $field_value; if (array_search($profile['source_table'] . '.' . $field_name, $source_table_columns) === false) { $source_table_columns[] = $profile['source_table'] . '.' . $field_name; } } // add profile_id if (array_search($profile['source_table'] . '.profile_id', $source_table_columns) === false) { $source_table_columns[] = $profile['source_table'] . '.profile_id'; } //$sql_values = array_unique($sql_values); // special case for users if ($profile['source_table'] == 'users') { // username is required field but readonly for already registered users if ($site->fdat['form_error']['username'] && $params['username']) { unset($site->fdat['form_error']['username']); } // username must be unique for new user if (!$id) { $sql = $site->db->prepare('select username from users where username = ?', $sql_values['username']); $result = new SQL($sql); if ($result->rows) { $site->fdat['form_error']['username'] = $site->sys_sona(array('sona' => 'user exists', 'tyyp' => 'kasutaja')); } } ############ E-MAIL: CHECK FOR CORRECT FORMAT if ($sql_values['email'] != '' && !preg_match("/^[\\w\\-\\&\\.\\d]+\\@[\\w\\-\\&\\.\\d]+\$/", $sql_values['email'])) { $site->fdat['form_error']['email'] = $site->sys_sona(array('sona' => 'wrong email format', 'tyyp' => 'kasutaja')); } ############ E-MAIL: CHECK FOR DUPLICATES if ($sql_values['email']) { $sql = $site->db->prepare("SELECT user_id FROM users WHERE email=? AND user_id<>?", $sql_values['email'], $id); $sth = new SQL($sql); if ($exists = $sth->fetchsingle()) { $site->fdat['form_error']['email'] = $site->sys_sona(array(sona => 'Email already exists', 'tyyp' => 'kasutaja')); } } ############ PASSWORD: CHECK FOR CONFIRM MATCH & ENCRYPT # if password is set if (!$id || $params['password']) { if (!$params['password']) { $site->fdat['form_error']['password'] = $site->sys_sona(array('sona' => 'field required', 'tyyp' => 'kasutaja')); } if (!$params['confirm_password']) { $site->fdat['form_error']['confirm_password'] = $site->sys_sona(array('sona' => 'field required', 'tyyp' => 'kasutaja')); } $old_user_enc_password = $site->user->all['password']; unset($site->user->all['password']); # if password expired, then check, if user inserted new password (check if this match with old one) if ($old_user_enc_password && $site->user->all['pass_expired']) { if ($old_user_enc_password == crypt($sql_values['password'], $old_user_enc_password)) { $you_inserted_old_password = 1; } } if ($you_inserted_old_password) { $site->fdat['form_error']['password'] = $site->sys_sona(array('sona' => 'Password expired message', 'tyyp' => 'kasutaja')); } elseif ($params['confirm_password'] != $sql_values['password']) { $site->fdat['form_error']['password'] = $site->sys_sona(array('sona' => 'wrong confirmation', 'tyyp' => 'kasutaja')); } elseif ($site->CONF['users_require_safe_password'] == 1 && strlen($sql_values['password']) < 8 && !(preg_match('/[a-z]/', $sql_values['password']) && preg_match('/[A-Z]/', $sql_values['password']) && preg_match('/[0-9]/', $sql_values['password']))) { $site->fdat['form_error']['password'] = $site->sys_sona(array('sona' => 'pass_not_strong', 'tyyp' => 'kasutaja')); } else { $sql_values['password'] = crypt($sql_values['password'], Chr(rand(65, 91)) . Chr(rand(65, 91))); // set pass_expiring date if (!$sql_values['pass_expires'] || $sql_values['pass_expires'] == '0000-00-00') { $source_table_columns[] = 'users.pass_expires'; $sql_values['pass_expires'] = "DATE_ADD(now(), INTERVAL " . $site->CONF['default_pass_expire_days'] . " DAY)"; $sql_values_skip_prepare['users.pass_expires'] = 1; } } # if confirm ok } else { unset($sql_values['password']); $key = array_search('users.password', $source_table_columns); if ($key !== false) { unset($source_table_columns[$key]); } } // remove confirm_password unset($sql_values['confirm_password']); $key = array_search('users.confirm_password', $source_table_columns); if ($key !== false) { unset($source_table_columns[$key]); } // set group_id only for new users if (!$sql_values['group_id'] && !$id) { $sth = new SQL('SELECT group_id FROM groups WHERE is_predefined = 1'); $site->debug->msg($sth->debug->get_msgs()); $sql_values['group_id'] = $sth->fetchsingle(); $source_table_columns[] = 'users.group_id'; } // set created_date if (!$sql_values['created_date'] && !$id) { $source_table_columns[] = 'users.created_date'; $sql_values['created_date'] = date('Y-m-d'); } } // if no erros if (!sizeof($site->fdat['form_error'])) { // UPDATE a field if ($id) { $update_source_sql = ''; $update_objekt_sql = ''; foreach ($source_table_columns as $source_table_column) { if (strpos($source_table_column, 'objekt.') === 0) { // only pealkir allowed and it must be prepared if ($source_table_column == 'objekt.pealkiri') { $title = $sql_values[substr($source_table_column, strpos($source_table_column, '.') + 1)]; $update_objekt_sql .= $site->db->prepare($source_table_column . ' = ?, ', $title); $update_objekt_sql .= $site->db->prepare('objekt.pealkiri_strip = ?, ', strip_tags($title)); } } else { if ($sql_values_skip_prepare[$source_table_column]) { $update_source_sql .= $source_table_column . ' = ' . $sql_values[substr($source_table_column, strpos($source_table_column, '.') + 1)] . ', '; } else { $update_source_sql .= $site->db->prepare($source_table_column . ' = ?, ', $sql_values[substr($source_table_column, strpos($source_table_column, '.') + 1)]); } } } // remove trailing , $update_source_sql = substr_replace($update_source_sql, '', strlen($update_source_sql) - 2); $update_objekt_sql = substr_replace($update_objekt_sql, '', strlen($update_objekt_sql) - 2); // if this is a CMS objekt if (strpos($profile['source_table'], 'obj_') === 0) { $objekt = new Objekt(array('objekt_id' => $id)); // object must have READ and UPDATE permissions if ($objekt->objekt_id && $objekt->permission['R'] && $objekt->permission['U']) { // update the object table first // changed_user_id $update_objekt_sql .= ($update_objekt_sql ? ', ' : ' ') . 'objekt.changed_user_id = ' . (int) $site->user->id; // changed_user_name $update_objekt_sql .= $site->db->prepare(', objekt.changed_user_name = ?', $site->user->name); // changed_time $update_objekt_sql .= ', objekt.changed_time = now()'; $sql = 'update objekt set ' . $update_objekt_sql . ' where objekt.objekt_id = ' . $id; //printr($sql); new SQL($sql); $sql = 'update ' . $profile['source_table'] . ' set ' . $update_source_sql . ' where ' . $profile['source_table'] . '.objekt_id = ' . $id; //printr($sql); new SQL($sql); new Log(array('action' => 'update', 'objekt_id' => $objekt->objekt_id, 'message' => sprintf("%s '%s' (ID = %s) %s", ucfirst(translate_en($objekt->all['klass'])), $title, $objekt->objekt_id, "changed"))); $smarty->assign($name, $id); } else { new Log(array('action' => 'update', 'type' => 'WARNING', 'objekt_id' => $objekt->objekt_id, 'message' => sprintf("Access denied: attempt to edit %s '%s' (ID = %s)", ucfirst(translate_en($objekt->all['klass'])), $objekt->pealkiri(), $objekt->objekt_id))); $smarty->assign($name, 0); } } else { if ($profile['source_table'] == 'users' && $site->user->all['is_readonly'] == 1) { new Log(array('action' => 'update', 'type' => 'WARNING', 'component' => 'Users', 'message' => "User '" . $site->user->all['firstname'] . ' ' . $site->user->all['lastname'] . "' tried to update an account but was unable because of a is_readonly flag")); $smarty->assign($name, 0); } else { $sql = 'update ' . $profile['source_table'] . ' set ' . $update_source_sql . ' where ' . $source_table_id_column . ' = ' . $id; //printr($sql); $result = new SQL($sql); if ($result->rows != -1) { // log values for new user if ($profile['source_table'] == 'users') { new Log(array('action' => 'update', 'component' => 'Users', 'message' => "User '" . $site->user->all['firstname'] . ' ' . $site->user->all['lastname'] . "' account updated")); } else { new Log(array('action' => 'update', 'message' => "Record (ID: " . $id . ") updated in " . $profile['source_table'])); } $smarty->assign($name, $id); } else { $smarty->assign($name, 0); } } } } else { $insert_source_sql = ''; $insert_objekt_sql = ''; foreach ($source_table_columns as $source_table_column) { if (strpos($source_table_column, 'objekt.') === 0) { // only pealkir allowed and it must be prepared if ($source_table_column == 'objekt.pealkiri') { $title = $sql_values[substr($source_table_column, strpos($source_table_column, '.') + 1)]; $insert_objekt_sql .= $site->db->prepare($source_table_column . ' = ?, ', $title); $insert_objekt_sql .= $site->db->prepare('objekt.pealkiri_strip = ?, ', strip_tags($title)); } } else { if ($sql_values_skip_prepare[$source_table_column]) { $insert_source_sql .= $source_table_column . ' = ' . $sql_values[substr($source_table_column, strpos($source_table_column, '.') + 1)] . ', '; } else { $insert_source_sql .= $site->db->prepare($source_table_column . ' = ?, ', $sql_values[substr($source_table_column, strpos($source_table_column, '.') + 1)]); } } } // remove trailing , $insert_objekt_sql = substr_replace($insert_objekt_sql, '', strlen($insert_objekt_sql) - 2); $insert_source_sql = substr_replace($insert_source_sql, '', strlen($insert_source_sql) - 2); // if this is a CMS objekt if (strpos($profile['source_table'], 'obj_') === 0) { // parent object must have create permission if ($current_objekt->permission['C']) { //must be fields and cannot be overwritten by user data // tyyp_id $class_id = (int) array_search(str_replace('obj_', '', $profile['source_table']), $site->object_tyyp_id_klass); $insert_objekt_sql .= ($insert_objekt_sql ? ', ' : ' ') . 'objekt.tyyp_id = ' . $class_id; // keel $insert_objekt_sql .= ', objekt.keel = ' . $site->keel; // kesk (position) //$insert_objekt_sql .= ', kesk = '.(int)$current_objekt->all['kesk']; // aeg $insert_objekt_sql .= ', objekt.aeg = now()'; // publishing $insert_objekt_sql .= ', objekt.on_avaldatud = ' . $publish; // created user_id $insert_objekt_sql .= ', objekt.created_user_id = ' . (int) $site->user->id; // created user_name $insert_objekt_sql .= $site->db->prepare(', objekt.created_user_name = ?', $site->user->name); // created time $insert_objekt_sql .= ', objekt.created_time = now()'; // comment_count, for less errors in database_repair.php $insert_objekt_sql .= ', objekt.comment_count = 0'; $sql = 'insert into objekt set ' . $insert_objekt_sql; //printr($sql); $result = new SQL($sql); $id = $result->insert_id; if ($id) { $sql = 'select max(sorteering)+1 from objekt_objekt'; $result = new SQL($sql); $sql = $site->db->prepare('insert into objekt_objekt set objekt_id = ?, parent_id = ?, sorteering = ?', $id, $parent_id, $result->fetchsingle()); //printr($sql); $result = new SQL($sql); $insert_source_sql .= ', ' . $profile['source_table'] . '.objekt_id = ' . $id; $sql = 'insert into ' . $profile['source_table'] . ' set ' . $insert_source_sql; //printr($sql); $result = new SQL($sql); new Log(array('action' => 'create', 'objekt_id' => $id, 'message' => sprintf("%s '%s' (ID = %s) %s", ucfirst($site->object_tyyp_id_nimi[$class_id]), $title, $id, "inserted"))); foreach (unserialize($profile['data']) as $key => $value) { unset($site->fdat[$key]); } $smarty->assign($name, $id); } else { $smarty->assign($name, 0); } } else { // no create permission new Log(array('action' => 'create', 'type' => 'WARNING', 'message' => sprintf("Access denied: attempt to create %s under restricted category ID = %s", ucfirst(translate_en(str_replace('obj_', '', $profile['source_table']))), $current_objekt->objekt_id))); $smarty->assign($name, 0); } } elseif ($profile['source_table'] == 'users' && $site->user->all['is_readonly'] == 1) { new Log(array('action' => 'update', 'component' => 'Users', 'type' => 'WARNING', 'message' => "User '" . $site->user->all['firstname'] . ' ' . $site->user->all['lastname'] . "' tried to update his account, but was unable to because of a read_only flag on his/her account")); } else { $sql = 'insert into ' . $profile['source_table'] . ' set ' . $insert_source_sql; //printr($sql); $result = new SQL($sql); if ($result->insert_id) { // log values for new user if ($profile['source_table'] == 'users') { new Log(array('action' => 'create', 'component' => 'Users', 'message' => "New user '" . $sql_field_values['username'] . "' inserted")); } else { new Log(array('action' => 'create', 'message' => "Record (ID: " . $result->insert_id . ") inserted into " . $profile['source_table'])); } foreach (unserialize($profile['data']) as $key => $value) { unset($site->fdat[$key]); } $smarty->assign($name, $result->insert_id); } else { $smarty->assign($name, 0); } } } } else { $_POST['form_error'] = $site->fdat['form_error']; $smarty->assign($name, 0); } }
function print_kast($kast, $is_custom = 0, $archive_link_on = 1) { #Muutujad mis hoiab custom stringid $custom_buttons = ''; $custom_title = ''; $custom_contents = ''; if (get_class($kast) == "Objekt" || is_subclass_of($kast, "Objekt")) { # ---------------------------- # Uudiste kogumik # ---------------------------- if ($kast->all[klass] == "kogumik") { $kast->load_sisu(); if (!$is_custom) { ?> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="1"> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " class="boxhead" height="24"> <?php echo $kast->pealkiri(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); ?> </td> </tr> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " bgcolor="<?php echo $kast->site->dbstyle("menyy_border", "color") ? $kast->site->dbstyle("menyy_border", "color") : "#CCCCCC"; ?> "> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="<?php echo $kast->site->dbstyle("menyy_taust", "color") ? $kast->site->dbstyle("menyy_taust", "color") : "#FAFAFA"; ?> "> <tr> <td align="right" valign="top"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="<?php echo $kast->site->dbstyle("menyy_laius", "layout") - 42; ?> " height="10"></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> </tr> <?php } else { //Custom print out ob_start(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); $custom_buttons .= ob_get_contents(); ob_end_clean(); $custom_title .= $kast->pealkiri(); $custom_contents .= "<ul class=\"boxlist\">"; } //if is_custom # rubriigid kus uudised otsida $sql = "SELECT objekt.objekt_id FROM objekt LEFT JOIN objekt_objekt ON objekt_objekt.objekt_id=objekt.objekt_id WHERE objekt_objekt.parent_id=" . $kast->objekt_id . " AND (objekt.kesk = 0 or objekt.kesk = 5 or objekt.kesk = 9) AND objekt.tyyp_id=1"; ####### POOLELI if (!$kast->site->in_editor) { $sql .= " AND objekt.on_avaldatud=1"; } if (!$kast->site->in_editor) { $sql .= " AND !FIND_IN_SET(objekt.objekt_id, '" . join(",", $kast->site->noaccess_hash) . "')"; } $sth = new SQL($sql); while ($rid = $sth->fetchsingle()) { $news_rubrics .= "," . $rid; } $kast->debug->msg($sth->debug->get_msgs()); $kast->debug->msg("Rubriigid: {$news_rubrics}"); $sql = "\r\n\t\t\t\t\t\t\tSELECT objekt.objekt_id, objekt.pealkiri, objekt.aeg, objekt.on_avaldatud, objekt_objekt.parent_id \r\n\t\t\t\t\t\t\tFROM objekt \r\n\t\t\t\t\t\t\tLEFT JOIN objekt_objekt ON objekt_objekt.objekt_id=objekt.objekt_id \r\n\t\t\t\t\t\t\tWHERE find_in_set(objekt_objekt.parent_id,'{$news_rubrics}') AND (objekt.kesk=0 OR objekt.kesk=6) AND (objekt.tyyp_id=2 OR objekt.tyyp_id=15)"; if (!$kast->site->in_editor) { $sql .= " AND objekt.on_avaldatud=1 "; } $sql .= " ORDER BY objekt.aeg DESC, objekt_objekt.sorteering DESC limit 0," . ($kast->all[art_arv] ? $kast->all[art_arv] : 5); $kast->debug->msg($sth->debug->get_msgs()); $sth = new SQL($sql); $kast->debug->msg("Leitud " . $sth->rows . " alamobjekte"); $esimene = 1; while ($ary = $sth->fetch()) { $kast->debug->msg("Objekt leitud: {$ary['objekt_id']}. " . $ary[pealkiri]); $obj = new Objekt(array(ary => $ary)); if (!$is_custom) { if (!$esimene) { # eraldaja ?> <tr valign="top"> <td align="right" valign="top"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> <td background="<?php echo $kast->site->img_path; ?> /stripe1.gif"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="10"></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> </tr> <?php } if ($obj->site->in_editor) { ?> <!--tr valign="top"> <td colspan="3" align=left> </td> </tr--> <?php } # if in_editor ?> <tr valign="top"> <td align="right" valign="top"><img src="<?php echo $kast->site->img_path; ?> /nupp1.gif" width="10" height="10" align="texttop"></td> <td><a href="<?php echo $kast->site->self; ?> ?id=<?php echo $obj->objekt_id; ?> " class="navi2_on"><?php echo $obj->pealkiri(); ?> </a><?php echo $kast->all[on_kp_nahtav] ? "<br><font class=txt><font class=date>" . $obj->aeg() . "</font></font>" : ""; $obj->edit_buttons(array(tyyp_idlist => 3, only_edit => 1)); ?> </td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> </tr> <?php $esimene = 0; } else { //Custom print out if ($obj->site->in_editor) { ob_start(); $obj->edit_buttons(array(tyyp_idlist => 3, only_edit => 1)); $custom_contents .= ob_get_contents(); ob_end_clean(); } if ($kast->all[on_kp_nahtav]) { $cu_date = ' <font class=date>' . $obj->aeg() . ' </font>'; } else { $cu_date = ''; } $custom_contents .= '<li class="list"><a href="' . $kast->site->self . '?id=' . $obj->objekt_id . '" class="navi2_on">' . $obj->pealkiri() . $cu_date . '</a>' . '</li>' . ($obj->site->in_editor ? "<br clear=all>" : ""); } //if is_custom } # while if (!$is_custom) { ?> <tr> <td colspan="3"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="10"></td> </tr> </table> </td> </tr> </table> <br> <?php } else { $custom_contents .= "</ul>"; } //if is_custom } else { if ($kast->all[klass] == "rubriik") { # ---------------------------- # Lingide kast # ---------------------------- if (!$is_custom) { ?> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="1"> <tr> <td width="100%" class="boxhead" height="24"> <?php echo $kast->pealkiri(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); ?> </td> </tr> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " bgcolor="<?php echo $kast->site->dbstyle("menyy_border", "color") ? $kast->site->dbstyle("menyy_border", "color") : "#CCCCCC"; ?> "> <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="<?php echo $kast->site->dbstyle("menyy_taust", "color") ? $kast->site->dbstyle("menyy_taust", "color") : "#FAFAFA"; ?> "> <tr> <td align="right" valign="top"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="<?php echo $kast->site->dbstyle("menyy_laius", "layout") - 52; ?> " height="10" border=0></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> </tr> <?php } else { //Custom print out $custom_contents .= '<div class="linkbox">'; ob_start(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); $custom_buttons .= ob_get_contents(); ob_end_clean(); $custom_title .= $kast->pealkiri(); } //if is_custom $lingi_alamlist = new Alamlist(array(parent => $kast->objekt_id, klass => "link", asukoht => $kast->all[kesk])); $esimene = 1; while ($viit = $lingi_alamlist->next()) { if (!$is_custom) { if (!$esimene) { # eraldaja ?> <tr valign="top"> <td align="right" valign="top"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> <td background="<?php echo $kast->site->img_path; ?> /stripe1.gif"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="10"></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> </tr> <?php } # if !esimene $viit->load_sisu(); if ($viit->site->in_editor) { ?> <!--tr valign="top"> <td colspan="3" align=left> </td> </tr--> <?php } # if in_editor ?> <tr valign="top"> <td align="right" valign="top"><img src="<?php echo $kast->site->img_path; ?> /nupp1.gif" width="10" height="10" align="texttop"></td> <td><a href="<?php echo $viit->all[url]; ?> " target="<?php echo $viit->all[on_uusaken] ? "_blank" : "_self"; ?> " class="navi2_on"><?php echo $viit->pealkiri(); ?> </a><?php $viit->edit_buttons(array(tyyp_idlist => 3)); ?> </td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="20" height="10"></td> </tr> <?php $esimene = 0; } else { //Custom print out $viit->load_sisu(); if ($viit->site->in_editor) { ob_start(); $viit->edit_buttons(array(tyyp_idlist => 3)); $custom_contents .= ob_get_contents(); ob_end_clean(); } $custom_contents .= '<a href="' . $viit->all[url] . '" target="' . ($viit->all[on_uusaken] ? "_blank" : "_self") . '" class="navi2_on">' . $viit->pealkiri() . '</a><br>'; } //if is_custom } # while next() if (!$is_custom) { if ($lingi_alamlist->size == 0) { ?> <tr> <td colspan="3"> <?php $lingi_alamlist->edit_buttons(array(tyyp_idlist => 3)); ?> </td> </tr> <?php } ?> <tr> <td colspan="3"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="10"></td> </tr> </table> </td> </tr> </table> <br> <?php } else { //Custom print out if ($lingi_alamlist->size == 0) { ob_start(); $lingi_alamlist->edit_buttons(array(tyyp_idlist => 3)); $custom_contents .= ob_get_contents(); ob_end_clean(); } $custom_contents .= '</div>'; } //if is_custom } else { if ($kast->all[klass] == "loginkast") { # ---------------------------- # Login kast # ---------------------------- if ($kast->all[on_pealkiri] || $kast->site->in_editor) { if (!$is_custom) { ?> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="1"> <form action="<?php echo $kast->site->self; ?> " method=post> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " class="boxhead" height="24"> <?php echo $kast->site->user->user_id ? $kast->site->sys_sona(array(sona => "tere", tyyp => "kasutaja")) . " " . $kast->site->user->all['username'] : $kast->pealkiri(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); ?> </td> </tr> <tr> <td width="100%" bgcolor="<?php echo $kast->site->dbstyle("menyy_border", "color") ? $kast->site->dbstyle("menyy_border", "color") : "#CCCCCC"; ?> "> <table width="100%" border="0" cellspacing="0" cellpadding="11" bgcolor="<?php echo $kast->site->dbstyle("menyy_taust", "color") ? $kast->site->dbstyle("menyy_taust", "color") : "#FAFAFA"; ?> "> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> "> <?php } else { //Custom print out $custom_contents .= '<div class="loginbox">'; ob_start(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); $custom_buttons .= ob_get_contents(); ob_end_clean(); $custom_title .= $kast->site->user->user_id ? $kast->site->sys_sona(array(sona => "tere", tyyp => "kasutaja")) . " " . $kast->site->user->all['username'] : $kast->pealkiri(); } //if is_custom } # pealkiri if ($is_custom) { ob_start(); } //if is_custom ?> <font class=<?php echo $kast->site->agent ? "txt" : "txt1"; ?> > <?php # kasutaja login form # vüi tema andmed ja lingid if ($kast->site->user->user_id) { ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr valign="top"> <td align="right"><img src="<?php echo $kast->site->img_path; ?> /nupp1.gif" width="10" height="10" align="texttop"></td> <td colspan=2><a href="<?php echo $kast->site->self; ?> ?id=<?php echo $kast->objekt_id; ?> &op=register" class="navi2_on"><?php echo $kast->site->sys_sona(array(sona => "Muuda oma andmeid", tyyp => "kasutaja")); ?> </a></td> </tr> <tr valign="top"> <td align="right"><img src="<?php echo $kast->site->img_path; ?> /nupp1.gif" width="10" height="10" align="texttop"></td> <td colspan=2><a href="<?php echo $kast->site->self; ?> ?id=<?php echo $kast->objekt_id; ?> &op=logout&url=<?php echo $kast->site->safeURI; ?> " class="navi2_on"><?php echo $kast->site->sys_sona(array(sona => "Logi valja", tyyp => "kasutaja")); ?> </a></td> </tr> </table> <?php } else { # ---------------- # login kast # ---------------- ?> <form action="<?php echo $kast->site->self; ?> " method=post> <input type=hidden name="op" value="login"> <input type=hidden name="url" value="<?php echo $kast->site->safeURI; ?> "> <input type=hidden name="id" value="<?php echo $kast->objekt_id; ?> "> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="1%"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="13" height="1"></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="1"></td> <td><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="62" height="1"></td> </tr> <tr> <td colspan=2 align="right"><font class=txt1><?php echo $kast->site->sys_sona(array(sona => "Login", tyyp => "kasutaja")); ?> : </font></td> <td> <input type=text class=searchbox size=3 name=user style="width:60"> </td> </tr> <tr> <td colspan=2 align="right" width="1%"><font class=txt1><?php echo $kast->site->sys_sona(array(sona => "Password", tyyp => "kasutaja")); ?> : </font></td> <td> <input type=password class=searchbox size=3 name=pass style="width:60"> </td> </tr> <tr> <td colspan=3 align=center height="34"> <INPUT class=searchbtn type=submit value="<?php echo $kast->site->sys_sona(array(sona => "nupp login", tyyp => "kasutaja")); ?> "> </td> </tr> <?php if ($kast->site->CONF['allow_forgot_password']) { ?> <tr valign="top"> <td align="right"><img src="<?php echo $kast->site->img_path; ?> /nupp1.gif" width="10" height="10" align="texttop"></td> <td colspan=2><a href="<?php echo $kast->site->self; ?> ?id=<?php echo $kast->objekt_id; ?> &op=remindpass" class="navi2_on"><?php echo $kast->site->sys_sona(array(sona => "Unustasid parooli", tyyp => "kasutaja")); ?> </a></td> </tr> <?php } if ($kast->site->CONF[users_can_register] == 1) { ?> <tr valign="top"> <td align="right"><img src="<?php echo $kast->site->img_path; ?> /nupp1.gif" width="10" height="10" align="texttop"></td> <td colspan=2><a href="<?php echo $kast->site->self; ?> ?id=<?php echo $kast->objekt_id; ?> &op=register" class="navi2_on"><?php echo $kast->site->sys_sona(array(sona => "Registeeru", tyyp => "kasutaja")); ?> </a></td> </tr> <?php } ?> </table> </form> <?php } # $kast->print_text(); ?> </font> <?php if ($is_custom) { $custom_contents .= ob_get_contents(); ob_end_clean(); $custom_contents .= '</div>'; } //if is_custom if ($kast->all[on_pealkiri] || $kast->site->in_editor) { if (!$is_custom) { ?> </td> </tr> </table> </td> </tr> </form> </table> <br> <?php } //if is_custom } else { if (!$is_custom) { echo "<br>"; } //if is_custom } } else { if ($kast->all[klass] == "artikkel") { # ---------------------------- # Artikkel kastis # ---------------------------- if ($kast->all[on_pealkiri] || $kast->site->in_editor) { if (!$is_custom) { ?> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="1"> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " class="boxhead" height="24"> <?php echo $kast->pealkiri(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); ?> </td> </tr> <tr> <td width="100%" bgcolor="<?php echo $kast->site->dbstyle("menyy_border", "color") ? $kast->site->dbstyle("menyy_border", "color") : "#CCCCCC"; ?> "> <table width="100%" border="0" cellspacing="0" cellpadding="11" bgcolor="<?php echo $kast->site->dbstyle("menyy_taust", "color") ? $kast->site->dbstyle("menyy_taust", "color") : "#FAFAFA"; ?> "> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> "> <?php } else { //Custom print out $custom_contents .= '<div class="articlebox">'; ob_start(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); $custom_buttons .= ob_get_contents(); ob_end_clean(); $custom_title .= $kast->pealkiri(); } //if is_custom } # pealkiri if (!$is_custom) { ?> <font class=<?php echo $kast->site->agent ? "txt" : "txt1"; ?> > <?php $kast->print_text(); ?> </font> <?php if ($kast->all[on_pealkiri] || $kast->site->in_editor) { ?> </td> </tr> </table> </td> </tr> </table> <br> <?php } else { echo "<br>"; } } else { //Custom print out ob_start(); echo "<font class=" . ($kast->site->agent ? "txt" : "txt1") . ">" . $kast->print_text() . "</font>"; $custom_contents .= ob_get_contents(); ob_end_clean(); $custom_contents .= '</div>'; } //if is_custom ############## GALLUP } else { if ($kast->all[klass] == "gallup") { $kast->load_sisu(); ######### HEADER ##### 1) default html if (!$is_custom) { ?> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="1"> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " class="boxhead" height="24"> <?php echo $kast->site->sys_sona(array(sona => 'Gallup', tyyp => "kujundus")); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); ?> </td> </tr> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " bgcolor="<?php echo $kast->site->dbstyle("menyy_border", "color") ? $kast->site->dbstyle("menyy_border", "color") : "#CCCCCC"; ?> "> <table width="100%" border="0" cellspacing="0" cellpadding="11" bgcolor="<?php echo $kast->site->dbstyle("menyy_taust", "color") ? $kast->site->dbstyle("menyy_taust", "color") : "#FAFAFA"; ?> "> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> "><font class="<?php echo $kast->site->agent ? "txt" : "txt1"; ?> "><?php echo $kast->pealkiri(); ?> </font> <br> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td valign="top" colspan="2"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="3"></td> </tr> <?php } else { $custom_contents .= '<div class="gallupbox">'; ob_start(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); $custom_buttons .= ob_get_contents(); ob_end_clean(); $custom_title .= ' ' . $kast->site->sys_sona(array(sona => 'Gallup', tyyp => "kujundus")); $custom_contents .= '<font class="' . ($kast->site->agent ? "txt" : "txt1") . '">' . $kast->pealkiri() . '</font><br>'; } //if is_custom ######### / HEADER ######### CHECK voting # 1) IP-based gallup if ($kast->site->CONF[gallup_ip_check] == 1) { $sql = $kast->site->db->prepare("SELECT COUNT(gi_id) FROM gallup_ip WHERE objekt_id=? AND ip LIKE ?", $kast->objekt_id, $_SERVER["REMOTE_ADDR"]); $sth = new SQL($sql); $count = $sth->fetchsingle(); $kast->debug->msg($sth->debug->get_msgs()); } else { if ($kast->site->CONF[gallup_ip_check] == 2 && $kast->site->cookie["gallup"][$kast->objekt_id] == 1) { $count = 1; } else { if ($kast->site->CONF[gallup_ip_check] == 3) { $sql = $kast->site->db->prepare("SELECT COUNT(gi_id) FROM gallup_ip WHERE objekt_id=? AND user_id=?", $kast->objekt_id, $kast->site->user->user_id); $sth = new SQL($sql); # count=1: not logged in users are not allowed to vote: $count = $kast->site->user->user_id ? $sth->fetchsingle() : 1; $kast->debug->msg($sth->debug->get_msgs()); } else { $count = 0; } } } ######### / CHECK voting ######### GET VOTES (SUMS) $sql = $kast->site->db->prepare("SELECT * FROM gallup_vastus WHERE objekt_id=?", $kast->objekt_id); $sth = new SQL($sql); if ($is_custom) { # custom html ob_start(); print '<table width="100%" border="0" cellspacing="0" cellpadding="0">'; } //if is_custom #################### 1. SHOW FORM & radio buttons if (!$count && !$kast->site->fdat[results] && !$kast->site->in_editor) { ?> <SCRIPT LANGUAGE="JavaScript"><!-- //See script on keerulisem kui see peaks olema //kuna muidu see ei tööta IE peal function do_it(vorm) { if (vorm.java_check.value==1) { return true } else { return false } } //--></SCRIPT> <form action="<?php echo $kast->site->self; ?> " method=get> <input type=hidden name="uri" value="<?php echo $kast->site->URI; ?> "> <input type=hidden name="gallup_id" value="<?php echo $kast->objekt_id; ?> "> <input type=hidden name="op" value="vote"> <?php ####### loop over VASTUS (votes sum) while ($vastus = $sth->fetch()) { ?> <tr> <td valign="top" width="15"> <input type=radio id="vastus_<?php echo $vastus[gv_id]; ?> " name=vastus value="<?php echo $vastus[gv_id]; ?> " onclick="javascript:if(this.checked){this.form.java_check.value=1;};"> </td> <td valign="top" class="<?php echo $kast->site->agent ? "txt" : "txt1"; ?> "><label for="vastus_<?php echo $vastus[gv_id]; ?> "><?php echo $vastus[vastus]; ?> </label></td> </tr> <?php } # while vastus ?> <?php ######## submit-button ?> <tr align="right"> <input type="hidden" name="java_check" value="0"> <td valign="top" colspan="2"><input type="submit" name="haaleta" value="<?php echo $kast->site->sys_sona(array(sona => 'haaleta', tyyp => "kujundus")); ?> " onclick="javascript:return do_it(this.form);" class="searchbtn"></td> </tr> </form> </table> <?php $kast->debug->msg($sth->debug->get_msgs()); } else { $sql = $kast->site->db->prepare("SELECT SUM(count) AS kokku, MAX(count) AS maksi FROM gallup_vastus WHERE objekt_id=? ", $kast->objekt_id); $sth_c = new SQL($sql); $stat = $sth_c->fetch(); $kast->debug->msg("kokku = {$stat['kokku']}, maks = {$stat['maksi']}"); $kast->debug->msg($sth_c->debug->get_msgs()); ###### voters vount: ?> <tr> <td valign="top" class="<?php echo $kast->site->agent ? "txt" : "txt1"; ?> "><?php echo $kast->site->sys_sona(array(sona => "vastajaid", tyyp => "kujundus")); ?> : <b><?php echo $stat[kokku]; ?> </b></td> </tr> <tr> <td valign="top"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="3"></td> </tr> <?php ###### one colored row while ($vastus = $sth->fetch()) { $percent = $stat[kokku] ? sprintf('%2.0f', 100 * $vastus[count] / $stat[kokku]) : 0; ?> <tr> <td valign="top" class="<?php echo $kast->site->agent ? "txt" : "txt1"; ?> "><?php echo $vastus[vastus]; ?> </td> </tr> <tr> <td valign="top"><b><font class="<?php echo $kast->site->agent ? "txt" : "txt1"; ?> ">- <?php echo $percent; ?> %</font></b> <img src="<?php echo $kast->site->img_path; ?> /gallup_bar<?php echo $stat[maksi] == $vastus[count] && $vastus[count] ? "2" : "1"; ?> .gif" width="<?php echo 110 * ($percent / 100); ?> " height=8 border="1"></td> </tr> <?php } # while vastus ############## archive link # added 12.12.2003 by Dima Bug #744 if ($archive_link_on) { ?> <tr> <td valign="top"><img src="<?php echo $kast->site->img_path; ?> /px.gif" width="1" height="3"></td> </tr> <tr align="right"> <td valign="top"><a href="<?php echo $kast->site->self; ?> ?op=gallup_arhiiv" class="navi2_on"><?php echo $kast->site->sys_sona(array(sona => 'Arhiiv', tyyp => "kujundus")); ?> </a></td> </tr> <?php } ?> </table> <?php } #################### / 2. SHOW RESULTS ##### 1) default html if (!$is_custom) { ?> </td> </tr> </table> </td> </tr> </table> <br> <?php } //if is_custom ##### 2) custom html if ($is_custom) { $custom_contents .= ob_get_contents(); ob_end_clean(); $custom_contents .= '</div>'; } //if is_custom } else { if ($kast->all[klass] == "iframekast") { $kast->load_sisu(); $conf = new CONFIG($kast->all[ttyyp_params]); $src_file = $conf->get("src_file"); $predefined = $conf->get("predefined"); $height = $conf->get("height"); # kui tegemist saidi sisese failiga, panna id juurde if (trim($predefined) != '') { $src_file .= "&id=" . ($kast->site->fdat[id] ? $kast->site->fdat[id] : $kast->site->alias("rub_home_id")); } if (!$is_custom) { ?> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="2"> <tr> <td class="boxhead" height="24"> <?php echo $kast->pealkiri(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); ?> </td> </tr> <tr valign="top"> <td class=box><?php if (strlen(trim($src_file)) > 0) { ?> <iframe name="iifreim" src="<?php echo $src_file; ?> " width="<?php echo $is_custom ? "100%" : $kast->site->dbstyle("menyy_laius", "layout"); ?> " frameborder=0 height="<?php echo $height; ?> " ></iframe><?php } ?> </td> </tr> </table> <br> <?php } else { //Custom print out $custom_contents .= '<div class="iframebox">'; ob_start(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17")); $custom_buttons .= ob_get_contents(); ob_end_clean(); $custom_title .= $kast->pealkiri(); if (strlen(trim($src_file)) > 0) { $custom_contents .= '<iframe name="iifreim" src="' . $src_file . '" width="100%" frameborder=0 height="' . $height . '" ></iframe>'; } $custom_contents .= '</div>'; } //if is_custom } } } } } } ########################################################### } else { if (get_class($kast) == "Alamlist" || is_subclass_of($kast, "Alamlist")) { # ---------------------- # kui parameetrina on alamlist, # siis teeme "uus kast" nupp # ---------------------- if (!($kast->size > 0)) { if (!$is_custom) { ?> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="1"> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " class="boxhead" height="24"> <?php echo $kast->site->sys_sona(array(sona => 'new', tyyp => "editor")); ?> <?php echo $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17", no_br => 1)); ?> </nobr></td> </tr> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " bgcolor="<?php echo $kast->site->dbstyle("menyy_border", "color") ? $kast->site->dbstyle("menyy_border", "color") : "#CCCCCC"; ?> "> <table width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> " border="0" cellspacing="0" cellpadding="11" bgcolor="<?php echo $kast->site->dbstyle("menyy_taust", "color") ? $kast->site->dbstyle("menyy_taust", "color") : "#FAFAFA"; ?> "> <tr> <td width="<?php echo $kast->site->dbstyle("menyy_laius", "layout"); ?> "> </td> </tr> </table> </td> </tr> </table> <br> <?php } else { //Custom print out ob_start(); $kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17", no_br => 1)); $custom_buttons .= ob_get_contents(); ob_end_clean(); $custom_title .= $kast->site->sys_sona(array(sona => 'new', tyyp => "editor")); } //if is_custom } # if ! size > 0 } else { $GLOBALS[site]->debug->msg("print_kast() argument \"kast\" on vale"); } } #print "<br>"; return array('buttons' => $custom_buttons, 'title' => $custom_title, 'contents' => $custom_contents); }
# DESCRIPTION # objektide kustutamine # global $site; preg_match('/\\/(admin|editor)\\//i', $_SERVER["REQUEST_URI"], $matches); if ($matches[1] == "admin" || $matches[1] == "editor") { $class_path = "../classes/"; } else { $class_path = "./classes/"; } include_once $class_path . "port.inc.php"; #Get debug cookie muutuja $debug = $_COOKIE["debug"] ? 1 : 0; $hidden_output = 0; $site = new Site(array(on_debug => $debug, on_admin_keel => 1)); $objekt = new Objekt(array(objekt_id => $site->fdat['id'])); if ($objekt) { $rub_trash_id = $site->alias(array('key' => 'trash', 'keel' => $objekt->all['keel'])); } if ($objekt->objekt_id == $rub_trash_id && $rub_trash_id) { echo "<font face=verdana size=2><b>You can not delete section \"Recycle Bin\" !</b></font>"; exit; } #################################### # GET PERMISSIONS # get object permissions for current user $site->debug->msg("EDIT: Kustutava objekti " . $objekt->objekt_id . " �igused = " . ($system_admin ? "System admin" : $objekt->permission['mask'])); ########################### # ACCESS allowed/denied # decide if accessing this page is allowed or not # DELETE: if current object has DELETE => allow
function move_files_to_folder($from_folder_id, $to_folder_id, $files) { global $site; $return = array('error' => 0, 'error_message' => '', 'moved_files' => array()); if (count($files) && $to_folder_id && $to_folder_id != $from_folder_id) { $to_folder_obj = new Objekt(array('objekt_id' => (int) $to_folder_id, 'on_sisu' => 1)); $from_folder_obj = new Objekt(array('objekt_id' => (int) $from_folder_id, 'on_sisu' => 1)); if ($to_folder_obj->objekt_id == $to_folder_id && $to_folder_obj->all['klass'] == 'folder' && $from_folder_obj->objekt_id == $from_folder_id && $from_folder_obj->all['klass'] == 'folder') { if ($to_folder_obj->permission['C'] == 1) { $to_folder_obj->all['fullpath'] = preg_replace('#/$#', '', $site->absolute_path) . $to_folder_obj->all['relative_path']; $from_folder_obj->all['fullpath'] = preg_replace('#/$#', '', $site->absolute_path) . $from_folder_obj->all['relative_path']; foreach ($files as $object_id) { $file_obj = new Objekt(array('objekt_id' => (int) $object_id, 'on_sisu' => 1)); if ($file_obj->objekt_id && $file_obj->parent_id == $from_folder_obj->objekt_id && $file_obj->all['klass'] == 'file' && $file_obj->permission['D'] == 1) { //if file exists and there is not a file with the same name in the destination folder $file_obj->all['fullpath'] = preg_replace('#/$#', '', $site->absolute_path) . $file_obj->all['relative_path']; if (file_exists($file_obj->all['fullpath']) && !file_exists($to_folder_obj->all['fullpath'] . '/' . $file_obj->all['filename'])) { $relative_path = $to_folder_obj->all['relative_path'] . '/' . $file_obj->all['filename']; if (rename($file_obj->all['fullpath'], $to_folder_obj->all['fullpath'] . '/' . $file_obj->all['filename'])) { // file successfully moved, update db object $sql = "update obj_file set relative_path = '" . $relative_path . "' where objekt_id = " . $file_obj->objekt_id; //printr($sql); new SQL($sql); // update parent -> object relation $sql = "update objekt_objekt set parent_id = " . $to_folder_obj->objekt_id . " where objekt_id = " . $file_obj->objekt_id . " and parent_id = " . $from_folder_obj->objekt_id; //printr($sql); new SQL($sql); ########## write log new Log(array('action' => 'update', 'component' => 'Files', 'objekt_id' => $file_obj->objekt_id, 'message' => "File '" . $file_obj->all['relative_path'] . "' (ID = " . $file_obj->objekt_id . ") moved to '" . $relative_path . "'")); $return['moved_files'][] = $file_obj->objekt_id; // also move thumbnails, keep quiet about success? if (file_exists($from_folder_obj->all['fullpath'] . '/.thumbnails/') . $file_obj->all['filename']) { if (!file_exists($to_folder_obj->all['fullpath'] . '/.thumbnails')) { $mask = umask(0); $thumbnails_folder = mkdir($to_folder_obj->all['fullpath'] . '/.thumbnails', 0777); umask($mask); } else { $thumbnails_folder = is_dir($to_folder_obj->all['fullpath'] . '/.thumbnails/'); } if ($thumbnails_folder) { rename($from_folder_obj->all['fullpath'] . '/.thumbnails/' . $file_obj->all['filename'], $to_folder_obj->all['fullpath'] . '/.thumbnails/' . $file_obj->all['filename']); } } } else { // file move failed new Log(array('action' => 'update', 'component' => 'Files', 'type' => 'ERROR', 'objekt_id' => $file_obj->objekt_id, 'message' => "File '" . $file_obj->all['relative_path'] . "' (ID = " . $file_obj->objekt_id . ") move to '" . $to_folder_obj->all['relative_path'] . "' failed, file system error.")); $return['error'] = 5; $return['error_message'] = 'item_error'; } } elseif (file_exists($to_folder_obj->all['fullpath'] . '/' . $file_obj->all['filename'])) { // no overwriting new Log(array('action' => 'update', 'component' => 'Files', 'type' => 'NOTICE', 'objekt_id' => $file_obj->objekt_id, 'message' => "File '" . $file_obj->all['relative_path'] . "' (ID = " . $file_obj->objekt_id . ") could not be moved to '" . $to_folder_obj->all['relative_path'] . "'. File already exists.")); $return['error'] = 4; $return['error_message'] = 'item_error'; } else { // no such file, del from db $file_obj->del(); // file is moved in a sense, to nothing $return['moved_files'][] = $file_obj->objekt_id; } } else { //no file to move or no cms permissions new Log(array('action' => 'update', 'component' => 'Files', 'type' => 'ERROR', 'objekt_id' => $file_obj->objekt_id, 'message' => "File (ID = " . $object_id . ") move to '" . $to_folder_obj->all['relative_path'] . "' failed, access denied.")); $return['error'] = 3; $return['error_message'] = 'no_permissions_to_move_files'; } } } else { //no file to move or no cms permissions new Log(array('action' => 'update', 'component' => 'Files', 'type' => 'ERROR', 'objekt_id' => $file_obj->objekt_id, 'message' => "File (ID = " . $object_id . ") move to '" . $to_folder_obj->all['relative_path'] . "' failed, access denied.")); $return['error'] = 4; $return['error_message'] = 'no_permissions_to_move_files'; } } else { $return['error'] = 2; $return['error_message'] = 'no_such_folder_object'; } } else { $return['error'] = 1; $return['error_message'] = 'parameters_missing'; } return $return; }
/** * This source file is is part of Saurus CMS content management software. * It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php). * Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/). * Redistribution of this file must retain the above copyright notice. * * Please note that the original authors never thought this would turn out * such a great piece of software when the work started using Perl in year 2000. * Due to organic growth, you may find parts of the software being * a bit (well maybe more than a bit) old fashioned and here's where you can help. * Good luck and keep your open source minds open! * * @package SaurusCMS * @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/) * @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php) * */ function edit_objekt() { global $site; global $objekt; global $keel; global $class_path; global $tyyp; // refreshing (fdat['refresh'] = 1) looses object data, I don't know why and because it's done in edit_object.php, I'm not going to fix it, lord knows what it'll screw up if ($site->fdat['refresh'] && $site->fdat['id']) { $obj = new Objekt(array('objekt_id' => $site->fdat['id'])); $objekt->objekt_id = $obj->objekt_id; $objekt->parent_id = $obj->parent_id; } $parent = new Objekt(array('objekt_id' => $objekt->objekt_id ? $objekt->parent_id : $site->fdat['parent_id'])); $pearubriik = $parent->all['sys_alias'] == 'home' ? 1 : 0; // parent path if ($objekt->all['sys_alias'] == '' && $site->fdat['sys_alias'] == '') { // this needs serious rethink and optmisation: there's no need to get the entire tree, parent object's path to top is only needed include_once $class_path . 'rubloetelu.class.php'; $rubs = new RubLoetelu(array('keel' => $keel, 'required_perm' => 'C', 'ignore_perm_for_obj' => $parent->objekt_id)); #$rubs->debug->print_msg(); $topparents = $rubs->get_loetelu(); if (is_array($topparents)) { asort($topparents); } foreach ($topparents as $k => $v) { if ($parent->objekt_id == $k) { $section_name = $v; break; } } } // publishing $publish_start = $objekt->all['avaldamisaeg_algus'] > 0 ? $site->db->MySQL_ee_long($objekt->all['avaldamisaeg_algus']) : ''; /* Don't print out time which is 00:00:00 */ if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s(\\d?\\d)[\\:\\\\.\\/\\-](\\d?\\d)/", $publish_start, $aa_reg)) { $publish_start = $aa_reg[2] == "00" && $aa_reg[3] == "00" ? $aa_reg[1] : $publish_start; } $publish_end = $objekt->all['avaldamisaeg_lopp'] > 0 ? $site->db->MySQL_ee_long($objekt->all['avaldamisaeg_lopp']) : ''; /* Don't print out time which is 23:59 */ if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s(\\d?\\d)[\\:\\\\.\\/\\-](\\d?\\d)/", $publish_end, $la_reg)) { $publish_end = $la_reg[2] == "23" && $la_reg[3] == "59" ? $la_reg[1] : $publish_end; } // to get the correct path to parent objects set use_alises on $site->CONF['use_aliases'] = 1; $parent_href = $parent->get_object_href(); if ($site->CONF['alias_trail_format'] == 0 || $parent->all['sys_alias'] == 'home' || $parent->all['sys_alias'] == 'trash' || $parent->all['sys_alias'] == 'system' || $parent->all['sys_alias'] == 'gallup_arhiiv') { $parent_href = preg_replace('#' . preg_quote('/' . ($parent->all['friendly_url'] ? $parent->all['friendly_url'] : $parent->objekt_id), '#') . '/$#', '/', $parent_href); } $parent_href = $site->CONF['hostname'] . $parent_href; // setup for section selection $_SESSION['parent_selection']['callback'] = 'window.opener.updateSection'; $_SESSION['parent_selection']['selectable'] = 1; $_SESSION['parent_selection']['hide_language_selection'] = '1'; $_SESSION['parent_selection']['mem_classes'] = array('rubriik'); //this sucks, really $_SESSION['parent_selection']['db_fields'] = array('select_checkbox', 'objekt_id', 'pealkiri'); $_SESSION['parent_selection']['display_fields'] = array('select_checkbox', 'pealkiri'); // setup folder select $_SESSION['scms_filemanager_settings']['scms_select_album_folder'] = array('select_mode' => 2, 'action_text' => $site->sys_sona(array('sona' => 'use_this_folder_for_album', 'tyyp' => 'editor')), 'action_trigger' => $site->sys_sona(array('sona' => 'use_this_folder_for_album', 'tyyp' => 'editor')), 'callback' => 'window.opener.setFolder'); $conf = new CONFIG($objekt->all['ttyyp_params']); $args['cols'] = $conf->get('cols'); $args['rows'] = $conf->get('rows'); $args['path'] = $conf->get('path'); //$args['path'] = 1; $args['tn_size'] = $conf->get('tn_size'); $args['desc'] = $conf->get('desc'); $args['pic_size'] = $conf->get('pic_size'); $args['folder_id'] = $conf->get('folder_id'); if (!$args['path']) { if ($objekt->all['pealkiri']) { $album_folder_path = $clean_path = create_alias_from_string($objekt->all['pealkiri']); } else { $result = new SQL('select max(objekt_id) + 1 from objekt'); $album_folder_path = $clean_path = $result->fetchsingle(); } $supplement = 2; // unlikely to happen if ($album_folder_path === '') { $album_folder_path = $clean_path = rand(10000, 20000); } while (file_exists($site->absolute_path . '/public/galleries/' . $album_folder_path)) { $album_folder_path = create_alias_from_string($clean_path . '-' . $supplement); $supplement++; // guard, also unlikely if ($supplement > 1000) { exit; } } $album_folder_path = 'public/galleries/' . $album_folder_path; } //printr($album_folder_path); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title><?php echo $site->title; ?> <?php echo $site->cms_version; ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $encoding ? $encoding : $site->encoding; ?> " /> <meta http-equiv="Cache-Control" content="no-cache" /> <link rel="stylesheet" href="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /datepicker.css" /> <link rel="stylesheet" href="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /album_editor.css" /> <!--[if IE 6]> <style type="text/css"> input.inline_button { padding: 0px 0px 0px 0px; height: 21px; } </style> <![endif]--> <!--[if IE 7]> <style type="text/css"> input.inline_button { padding: 0px 0px 0px 0px; height: 21px; } </style> <![endif]--> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /yld.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /edit_popup.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /jquery.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /datepicker.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot']; ?> /common.js.php"></script> <?php if ($site->CONF['fm_allow_multiple_upload'] && $parent->all['ttyyp_id'] != 39) { ?> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /swfupload/swfupload.js"></script> <script type="text/javascript" src="<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /swfupload/swfupload.queue.js"></script> <?php } ?> <script type="text/javascript"> var isIE = navigator.appVersion.match(/MSIE/); // assume gecko on false var folder_path = '<?php echo $album_folder_path; ?> '; var ajax_token = <?php echo create_form_token_json('edit-album-ajax'); ?> ; var swfu; window.onload = function () { var title = document.getElementById('pealkiri'); var advanced_panel_state = document.getElementById('advanced_panel_state'); if(advanced_panel_state.value == 1) { togglePanel('advanced'); } this.focus(); title.focus(); resizeWindow(); <?php if ($site->CONF['fm_allow_multiple_upload'] && $parent->all['ttyyp_id'] != 39) { ?> var post_params = {'<?php echo session_name(); ?> ' : '<?php echo session_id(); ?> ', 'op': 'add_image_to_album'}; $.extend(post_params, ajax_token); swfu = new SWFUpload({ flash_url : '<?php echo $site->CONF['wwwroot'] . $site->CONF['js_path']; ?> /swfupload/swfupload.swf', upload_url: '<?php echo $site->CONF['wwwroot']; ?> /admin/ajax_response.php', post_params: post_params, file_size_limit : '<?php echo is_int(ini_get('upload_max_filesize')) ? round(ini_get('upload_max_filesize') / 1024) : ini_get('upload_max_filesize') . 'B'; ?> ', file_types : '*.gif;*.png;*.jpeg;*.jpg', file_types_description : 'Images', file_upload_limit : 0, file_queue_limit : 100, custom_settings : { cancelButtonId : 'cancel_file_upload_button' }, debug: false, // Button settings button_image_url: '<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /gfx/general/album_upload_button_bg.gif', // Relative to the Flash file button_width: '95', button_height: '21', button_placeholder_id: 'span_upload_button_place_holder', button_text: '<?php echo $site->sys_sona(array('sona' => 'add_images', 'tyyp' => 'editor')); ?> ', button_text_left_padding: 8, button_text_top_padding: 1, button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT, // The event handler functions swfupload_loaded_handler: swfuLoaded, file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete //queue_complete_handler : queueComplete // Queue plugin event }); <?php } ?> } function resizeWindow() { if(jQuery.browser.webkit) { window.resizeTo(580, 380); } else { resizeWindowTo($('#size_wrapper').width(), $('#size_wrapper').height()); } } var filemanager_window; var uploadFolderPathSet = false; function chooseFolder() { filemanager_window = openpopup('filemanager.php?setup=scms_select_album_folder', 'filemanager', 980, 600); } function setFolder(data) { filemanager_window.close(); uploadFolderPathSet = true; $('input#path').attr('value', data.folders[0].relative_path.replace(/^\//, '')); $('a#images_folder_path_link').text(data.folders[0].relative_path.replace(/^\//, '')); $('td#images_folder_cf_container_cell').removeClass('hidden'); $('td#images_choose_folder_button_cell').addClass('hidden'); } function clearFolder() { $('input#path').attr('value', ''); $('td#images_folder_cf_container_cell').addClass('hidden'); $('td#images_choose_folder_button_cell').removeClass('hidden'); resizeWindow(); } function chooseSection() { explorer_window = openpopup('explorer.php?objekt_id=home&editor=1&swk_setup=parent_selection&remove_objects=<?php echo $site->fdat['id']; ?> &pre_selected=' + document.getElementById('rubriik').value, 'cms_explorer', '800','600'); } function updateSection(sections) { explorer_window.close(); var section_name = document.getElementById('section_name'); var section_id = document.getElementById('rubriik'); var trail_path= new Array(); for(var j = 0; j < sections[0].trail.length; j++){ trail_path[j] = sections[0].trail[j].pealkiri; } section_name.innerHTML = '<a href="javascript:chooseSection();">' + trail_path.join("->") + '</a>'; section_id.value = sections[0].objekt_id; } function editAlias() { var alias_placeholder = document.getElementById('alias_placeholder'); var alias_value = document.getElementById('alias_value'); alias_placeholder.innerHTML = '<input type="text" id="alias" value="' + alias_value.value + '" onblur="saveAlias();">'; resizeWindow(); var alias = document.getElementById('alias'); alias.focus(); } function saveAlias() { var alias_placeholder = document.getElementById('alias_placeholder'); var alias_value = document.getElementById('alias_value'); var alias = document.getElementById('alias'); if(alias_value.value != alias.value) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: alias.value, language_id: '<?php echo $keel; ?> '}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; }, success: function(response) { if(response.alias) { alias_value.value = response.alias; alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; } else { alias_value.value = ''; <?php if ($objekt->objekt_id) { ?> alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + '<?php echo $objekt->objekt_id; ?> ' + '</a>'; <?php } else { ?> alias_placeholder.innerHTML = '<input type="text" id="alias" value="" onblur="saveAlias();">'; <?php } ?> } resizeWindow(); } }); } else { if(!alias.value) { alias_value.value = ''; <?php if ($objekt->objekt_id) { ?> alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + '<?php echo $objekt->objekt_id; ?> ' + '</a>'; <?php } else { ?> alias_placeholder.innerHTML = '<input type="text" id="alias" value="" onblur="saveAlias();">'; <?php } ?> } else { alias_placeholder.innerHTML = '<a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (alias_value.value.length > 30 ? alias_value.value.substring(0, 30) + '...' : alias_value.value) + '</a>'; } resizeWindow(); } } function createAlias() { var alias_value = document.getElementById('alias_value'); var title = document.getElementById('pealkiri') if(0 || (!alias_value && title.value)) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: title.value, language_id: '<?php echo $keel; ?> '}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { }, success: function(response) { var alias_cell = document.getElementById('alias_cell'); alias_cell.className = 'alias'; if(response.alias) { alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value="' + response.alias + '"><?php echo $parent_href; ?> <span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (response.alias.length > 30 ? response.alias.substring(0, 30) + '...' : response.alias) + '</a></span>'; if(swfu && !swfu.uploadFolderPathSent && !uploadFolderPathSet) $('input#path').attr('value', 'public/galleries/' + response.alias); } else { alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value=""><?php echo $parent_href; ?> <span id="alias_placeholder"><input type="text" id="alias" value="" onblur="saveAlias();"></span>'; } $('a#images_folder_path_link').text($('input#path').attr('value')); $('#alias_row').show(); //var alias_row = document.getElementById('alias_row'); //alias_row.style.display = (isIE ? 'block' : 'table-row'); resizeWindow(); } }); } } function saveForm(op2) { var form = document.getElementById('editForm'); var title = document.getElementById('pealkiri'); if(title.value.length == 0) { alert('<?php echo $site->sys_sona(array('sona' => 'please_fill_in_the_title!', 'tyyp' => 'admin')); ?> '); return; } var alias_value = document.getElementById('alias_value'); var alias = document.getElementById('alias'); if((title.value && !alias_value) || (alias && alias_value && alias.value != alias_value.value)) { $.ajax({ url: 'ajax_response.php?rand=' + Math.random(9999), data: {op: 'generate_alias', string: title.value, language_id: '<?php echo $keel; ?> '}, type: 'POST', dataType: 'json', timeout: 1000, error: function() { var form = document.getElementById('editForm'); form.op2.value = op2; form.submit(); }, success: function(response) { var alias_value = document.getElementById('alias_value'); if(!alias_value && response.alias) { var alias_cell = document.getElementById('alias_cell'); alias_cell.innerHTML = '<input type="hidden" name="friendly_url" id="alias_value" value="' + response.alias + '"><?php echo $parent_href; ?> <span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link">' + (response.alias.length > 30 ? response.alias.substring(0, 30) + '...' : response.alias) + '</a></span>'; } var form = document.getElementById('editForm'); form.op2.value = op2; form.submit(); } }); } else { form.op2.value = op2; form.submit(); } } <?php if ($site->CONF['fm_allow_multiple_upload'] && $parent->all['ttyyp_id'] != 39) { ?> // SWFupload handler functions function fileQueued(file) { try { } catch (ex) { this.debug(ex); } } function fileQueueError(file, errorCode, message) { try { if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) { alert('<?php echo $site->sys_sona(array('sona' => 'upload_queue_limit', 'tyyp' => 'Files')); ?> ' + ': ' + this.settings.file_queue_limit); return; } if (errorCode === SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT) { alert(file.name + ' ' + '<?php echo $site->sys_sona(array('sona' => 'upload_limit_size', 'tyyp' => 'Files')); ?> ' + ' ' + this.settings.file_size_limit); return; } switch (errorCode) { default: if (file !== null) { alert("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); } this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; } } catch (ex) { this.debug(ex); } } function fileDialogComplete(numFilesSelected, numFilesQueued) { try { if(numFilesQueued > 0) { $('td#images_folder_cf_container_cell').addClass('hidden'); $('td#images_choose_folder_button_cell').addClass('hidden'); $('table#form_submit_buttons_table').addClass('hidden'); this.setButtonDisabled(true); this.setButtonDimensions(1, 1); $('td#upload_progress_cell').removeClass('hidden'); $('td#upload_progress_text_cell').removeClass('hidden'); $('table#upload_cancel_table').removeClass('hidden'); $('div#upload_progress_grow').width(0); this.numFilesQueued = numFilesQueued; if(!$('input#path').attr('value')) $('input#path').attr('value', folder_path); this.addPostParam('folder_path', $('input#path').attr('value')); this.uploadFolderPathSent = true; this.startUpload(); } } catch (ex) { this.debug(ex); } } function uploadStart(file) { try { $('td#upload_progress_text_cell').html(file.name + ' <span id="percent_placeholder">0</span>%'); this.progressBarWidth = $('div#upload_progress_grow').width(); } catch (ex) { this.debug(ex); } return true; } function uploadProgress(file, bytesLoaded, bytesTotal) { try { var percent = Math.round((bytesLoaded / bytesTotal) * 100); $('div#upload_progress_grow').width(this.progressBarWidth + Math.round(($('div#upload_progress_bar').width() / this.numFilesQueued * percent) / 100)); $('span#percent_placeholder').html(percent); } catch (ex) { this.debug(ex); } } function uploadSuccess(file, serverData) { try { } catch (ex) { this.debug(ex); } } function uploadError(file, errorCode, message) { try { switch (errorCode) { case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: // upload canceled break; case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: alert('Error occured while trying to connect.'); break; default: alert("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; } } catch (ex) { this.debug(ex); } } function uploadComplete(file) { $('td#upload_progress_text_cell').empty(); if (this.getStats().files_queued === 0) { // all files are finished $('td#upload_progress_cell').addClass('hidden'); $('td#upload_progress_text_cell').addClass('hidden'); $('table#upload_cancel_table').addClass('hidden'); this.setButtonDisabled(false); this.setButtonDimensions(95, 21); $('a#images_folder_path_link').text($('input#path').attr('value')); $('table#form_submit_buttons_table').removeClass('hidden'); $('td#images_folder_cf_container_cell').removeClass('hidden'); } } function swfuLoaded() { $('input#add_images_button').addClass('hidden'); } <?php } ?> </script> </head> <body> <?php if ($site->fdat['op'] == 'edit') { ?> <iframe src="checkin.php?objekt_id=<?php echo $objekt->objekt_id; ?> " style="width: 0; height: 0; display: none; visibility: hidden;"></iframe> <?php } ?> <form action="edit.php" name="editForm" id="editForm" method="POST" enctype="multipart/form-data"> <?php create_form_token('edit-album'); ?> <input type="hidden" name="tab" value="<?php echo $site->fdat['tab']; ?> " /> <input type="hidden" id="op" name="op" value="<?php echo htmlspecialchars($site->fdat['op']); ?> " /> <input type="hidden" id="op2" name="op2" value="" /> <input type="hidden" id="refresh" name="refresh" value="0" /> <input type="hidden" name="tyyp_id" value="<?php echo $tyyp['tyyp_id']; ?> " /> <input type="hidden" name="tyyp" value="<?php echo $tyyp['klass']; ?> " /> <input type="hidden" name="pearubriik" value="<?php echo $pearubriik; ?> " /> <input type="hidden" name="id" value="<?php echo $site->fdat['id']; ?> " /> <input type="hidden" name="parent_id" value="<?php echo $site->fdat['parent_id']; ?> " /> <input type="hidden" name="previous_id" value="<?php echo $site->fdat['previous_id']; ?> " /> <input type="hidden" name="keel" value="<?php echo $keel; ?> " /> <input type="hidden" name="on_pealkiri" value="1" /> <input type="hidden" name="sorting" value="<?php echo $site->fdat['sorting']; ?> "> <input type="hidden" name="opener_location" value="" /> <input type="hidden" name="publish" value="<?php echo $site->fdat['publish'] || $objekt->all['on_avaldatud'] ? 1 : 0; ?> "> <input name="permanent_parent_id" type="hidden" value="<?php echo $objekt->parent_id; ?> " /> <input name="sys_alias" type="hidden" value="<?php echo $site->fdat['sys_alias'] ? $site->fdat['sys_alias'] : $objekt->all['sys_alias']; ?> " /> <input name="advanced_panel_state" id="advanced_panel_state" type="hidden" value="<?php echo $site->fdat['advanced_panel_state'] ? htmlspecialchars($site->fdat['advanced_panel_state']) : 0; ?> " /> <div id="size_wrapper" class="section_editor"> <div id="main_container"> <?php ########### Tabs ######## ?> <div id="tab_container"> <a href="javascript:void(0);" class="selected"><?php echo $site->sys_sona(array('sona' => 'tyyp_album', 'tyyp' => 'System')); ?> </a> </div> <div id="content_container"> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'Pealkiri', 'tyyp' => 'editor')); ?> :</label></td> <td class="input"><input type="text" class="text" name="pealkiri" id="pealkiri" value="<?php echo htmlspecialchars($objekt->all['pealkiri']); ?> " onblur="createAlias();" /></td> </tr> <?php if (($objekt->objekt_id || isset($objekt->all['friendly_url'])) && !($objekt->all['sys_alias'] == 'home' || $objekt->all['sys_alias'] == 'trash' || $objekt->all['sys_alias'] == 'system' || $objekt->all['sys_alias'] == 'gallup_arhiiv')) { ?> <tr> <td class="label"> </td> <td class="input"><input type="hidden" id="alias_value" name="friendly_url" name="friendly_url" value="<?php echo htmlspecialchars($objekt->all['friendly_url']); ?> " /><?php echo $parent_href; ?> <span id="alias_placeholder"><a href="javascript:void(0);" onclick="editAlias();" id="alias_link"><?php echo $objekt->all['friendly_url'] ? strlen(htmlspecialchars($objekt->all['friendly_url'])) > 30 ? substr(htmlspecialchars($objekt->all['friendly_url']), 0, 30) . '...' : htmlspecialchars($objekt->all['friendly_url']) : $objekt->objekt_id; ?> </a></span></td> </tr> <?php } else { ?> <tr id="alias_row"> <td class="label"> </td> <td class="input" id="alias_cell"></td> </tr> <?php } ?> <?php ########### images folder ######## ?> <?php if ($parent->all['ttyyp_id'] != 39) { ?> <tr id="images_folder"> <td class="label"><?php echo $site->sys_sona(array('sona' => 'Image files directory', 'tyyp' => 'editor')); ?> :</td> <td class="input"> <table cellpadding="0" cellspacing="0" class="container" id="images_folder_cf_container_table"> <tr> <?php ########### images folder ######## ?> <td id="images_folder_cf_container_cell"<?php echo $args['path'] ? '' : ' class="hidden"'; ?> > <table cellpadding="0" cellspacing="0" class="cf_container"> <tr> <th><input type="hidden" name="path" id="path" value="<?php echo $args['path'] ? $args['path'] : ''; ?> "><span id="images_folder_path"><a href="javascript:chooseFolder();" id="images_folder_path_link" title="<?php echo $site->sys_sona(array('sona' => 'choose_a_folder', 'tyyp' => 'editor')); ?> "><?php echo $args['path']; ?> </a></span></th> <td><a href="javascript:chooseFolder();" title="<?php echo $site->sys_sona(array('sona' => 'choose_a_folder', 'tyyp' => 'editor')); ?> ">..</a></td> <td><a href="javascript:clearFolder();">X</a></td> </tr> </table> </td> <?php ########### add images ######## ?> <?php if ($site->CONF['fm_allow_multiple_upload']) { ?> <td id="images_add_button_cell"> <span id="span_upload_button_place_holder"></span> </td> <?php ########### upload progress ######## ?> <td id="upload_progress_cell" class="hidden"><div id="upload_progress_bar"><div id="upload_progress_grow"></div></div></td><!-- / scms_upload_progress --> <td id="upload_progress_text_cell" class="hidden"></td><!-- / scms_upload_text --> <?php } ?> <?php ########### choose_a_folder ######## ?> <td id="images_choose_folder_button_cell"<?php echo $args['path'] ? ' class="hidden"' : ''; ?> > <?php if ($site->CONF['fm_allow_multiple_upload']) { ?> <?php echo $site->sys_sona(array('sona' => 'or', 'tyyp' => 'editor')); } ?> <input type="button" value="<?php echo $site->sys_sona(array('sona' => 'choose_a_folder', 'tyyp' => 'editor')); ?> " class="inline_button" onclick="chooseFolder();" /> </td> </tr> </table> </td> </tr> <?php } ?> <?php ########### description ######## ?> <tr> <td class="label"><?php echo $site->sys_sona(array('sona' => 'Kirjeldus', 'tyyp' => 'editor')); ?> :</td> <td class="input"><textarea name="desc"><?php echo $args['desc'] ? $args['desc'] : ""; ?> </textarea></td> </tr> <?php ########### publishing ######## ?> <tr> <td class="label"><?php echo $site->sys_sona(array('sona' => 'visible_to_visitors', 'tyyp' => 'editor')); ?> :</td> <td><input type="radio" name="publish" id="object_published" value="1"<?php echo $site->fdat['publish'] || $objekt->all['on_avaldatud'] ? ' checked' : ''; echo $objekt->permission && !$objekt->permission['P'] || !$objekt->permission && !$parent->permission['P'] ? ' disabled="disabled"' : NULL; ?> > <label for="object_published"><?php echo $site->sys_sona(array('sona' => 'published', 'tyyp' => 'editor')); ?> </label> <input type="radio" name="publish" id="object_unpublished" value="0"<?php echo $site->fdat['publish'] == 0 && $objekt->all['on_avaldatud'] == 0 ? ' checked' : ''; echo $objekt->permission && !$objekt->permission['P'] || !$objekt->permission && !$parent->permission['P'] ? ' disabled="disabled"' : NULL; ?> > <label for="object_unpublished"><?php echo $site->sys_sona(array('sona' => 'unpublished', 'tyyp' => 'editor')); ?> </label></td> </tr> </table> <br /> <?php ########### advanced ######## ?> <div class="panel_toggler" onclick="togglePanel('advanced');"> <a href="javascript:void(0);"><?php echo $site->sys_sona(array('sona' => 'Advanced', 'tyyp' => 'editor')); ?> <span id="advanced_panel_link_state">»</span></a> </div> <div id="advanced_panel" class="panel"> <?php ########### image sizes ######## ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label">Image sizes:</td> <td><?php echo $site->sys_sona(array('sona' => 'Image size', 'tyyp' => 'editor')); ?> :</td> <td> <input name="pic_size" class="text_number" value="<?php echo $args['pic_size'] ? $args['pic_size'] : $site->CONF['image_width']; ?> " /> <input name="old_pic_size" type="hidden" value="<?php echo $args['pic_size'] ? $args['pic_size'] : $site->CONF['image_width']; ?> " /> </td> <td>px </td> <td><?php echo $site->sys_sona(array('sona' => 'Thumbnail size', 'tyyp' => 'editor')); ?> :</td> <td> <input name="tn_size" class="text_number" value="<?php echo $args['tn_size'] ? $args['tn_size'] : $site->CONF['thumb_width']; ?> " /> <input name="old_tn_size" type="hidden" value="<?php echo $args['tn_size'] ? $args['tn_size'] : $site->CONF['thumb_width']; ?> " /> </td> <td>px</td> </tr> </table> <?php ########### parent section ######## ?> <?php if ($section_name) { ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'Rubriigid', 'tyyp' => 'editor')); ?> :</label></td> <td class="input"> <table cellpadding="0" cellspacing="0" class="cf_container"> <tr> <th><input type="hidden" name="rubriik[]" id="rubriik" value="<?php echo $parent->objekt_id; ?> "><span id="section_name"><a href="javascript:chooseSection();"><?php echo $section_name; ?> </a></span></th> <td><a href="javascript:chooseSection();">..</a></td> </tr> </table> </td> </tr> </table> <?php } ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"> </td> <td><label><?php echo $site->sys_sona(array('sona' => 'Avaldatud', 'tyyp' => 'editor')); ?> :</label></td> <td><input type="text" id="publish_start" name="avaldamise_algus" maxlength="16" class="text_date" value="<?php echo $publish_start; ?> " /></td> <td><a href="javascript:init_datepicker('publish_start', 'publish_start', 'publish_end');"><img src="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /gfx/calendar/cal.gif" width="16" height="15" title="Choose from calendar" alt="Choose from calendar" /></a></td> <td><label><?php echo $site->sys_sona(array('sona' => 'Kuni', 'tyyp' => 'editor')); ?> :</label></td> <td><input type="text" id="publish_end" name="avaldamise_lopp" maxlength="16" class="text_date" value="<?php echo $publish_end; ?> " /></td> <td><a href="javascript:init_datepicker('publish_end', 'publish_start', 'publish_end');"><img src="<?php echo $site->CONF['wwwroot'] . $site->CONF['styles_path']; ?> /gfx/calendar/cal.gif" width="16" height="15" title="Choose from calendar" alt="Choose from calendar" /></a></td> </tr> </table> <?php ########### position ######## ?> <?php if ($site->CONF['allow_change_position']) { ?> <table cellpadding="0" cellspacing="0" class="form_row"> <tr> <td class="label"><label><?php echo $site->sys_sona(array('sona' => 'Position', 'tyyp' => 'editor')); ?> :</label></td> <td><input type="text" maxlength="5" class="text_position" name="kesk" value="<?php echo $site->fdat['op'] == 'edit' ? $objekt->all['kesk'] : $site->fdat['kesk']; ?> " /></td> </tr> </table> <?php } else { ?> <input type="hidden" name="kesk" value="<?php echo $site->fdat['op'] == 'edit' ? $objekt->all['kesk'] : $site->fdat['kesk']; ?> " /> <?php } ?> </div> </div> </div> <div id="button_container"> <table cellspacing="0" cellpadding="0" id="form_submit_buttons_table"> <tr> <td id="apply_button_cell"> <input type="button" class="button" value="<?php echo $site->sys_sona(array('sona' => 'Apply', 'tyyp' => 'editor')); ?> " onclick="saveForm('save');" /> </td> <td id="save_close_button_cell"> <input type="button" class="button" value=" <?php echo $site->sys_sona(array('sona' => 'save_and_close', 'tyyp' => 'editor')); ?> " onclick="saveForm('saveclose');" /> <input type="button" class="button" value="<?php echo $site->sys_sona(array('sona' => 'Close', 'tyyp' => 'editor')); ?> " onclick="window.close();" /> </td> </tr> </table> <table cellspacing="0" cellpadding="0" class="hidden" id="upload_cancel_table"> <tr> <td id="cancel_button_cell"> <input type="button" class="button" value="<?php echo $site->sys_sona(array('sona' => 'katkesta', 'tyyp' => 'editor')); ?> " onclick="swfu.cancelQueue();" /> </td> </tr> </table> </div> <!-- / button_container --> </div> <!-- / size_wrapper --> </form> </body> </html> <?php }
$adm_img_path = $site->CONF['wwwroot'] . $site->CONF['adm_img_path']; $tyyp = array(); ############ browser check if ($site->agent) { ################### # GET OBJECT by ID if ($site->fdat['id']) { $site->debug->msg("EDIT: ID = " . $site->fdat['id']); # $all_parents = $site->get_obj_all_parents($site->fdat['id']); # echo "all_parents=".printr($all_parents); $objekt = new Objekt(array(objekt_id => $site->fdat['id'], on_sisu => 1, no_cache => 1)); # kui objektil on rohkem, kui 1 parent, siis loodame objekti uuesti uue parentiga: if ($objekt->all['parents_count'] > 1 && $objekt->parent_id != $site->fdat['parent_id']) { $site->debug->msg("EDIT: Leidsin mitu parenti (" . $objekt->all['parents_count'] . "). Kasutan parent_id=" . $site->fdat['parent_id']); unset($objekt); $objekt = new Objekt(array(objekt_id => $site->fdat['id'], parent_id => $site->fdat['parent_id'], no_cache => 1, on_sisu => 1)); } $tyyp['tyyp_id'] = $objekt->all['tyyp_id']; $site->debug->msg("EDIT: " . $objekt->debug->get_msgs()); $site->debug->msg("EDIT: Tyyp_id detected: " . $tyyp['tyyp_id']); if (!$objekt->objekt_id) { $site->error("EDIT: Vale objekti ID"); } } else { # default parent for file (folder "public/") if ($site->fdat['op'] == 'new' && $site->fdat['tyyp_id'] == 21 && !$site->fdat['parent_id']) { # file object and no parent ID set # get folder ID of "public/", Bug #2342 $sql = $site->db->prepare("SELECT objekt_id FROM obj_folder WHERE relative_path = ? LIMIT 1", $site->CONF['file_path']); $sth = new SQL($sql); $tmp = $sth->fetch();
function smarty_function_init_object($params, &$smarty) { global $site, $leht, $template, $class_path; $content_template =& $leht->content_template; ############## # default values extract($params); if (!isset($id)) { $id = $leht->id; } if (!isset($name)) { $name = "object"; } ############### # action-buttons # by default show all if (!isset($buttons)) { $buttons = array("new", "edit", "hide", "move", "delete"); } else { $buttons = split(",", $buttons); } ############## # luua objekt & load sisu $obj = new Objekt(array(objekt_id => $id)); $obj->load_sisu(); ################ # object GENERAL parameters $obj->id = $obj->objekt_id; $obj->class = translate_en($obj->all[klass]); # translate it to english # kui link if ($obj->all[klass] == "link") { $objektUrl = $obj->all['url']; // replace index.php?id=xxx or ?id=xxx style local url with its alias if (!$site->in_editor && $site->CONF['use_aliases'] && $site->CONF['replace_links_with_alias']) { $objektUrl = convert_local_link_to_alias($objektUrl); } $objektUrl && $obj->all['on_uusaken'] ? $obj->href = $objektUrl . '" target="_blank' : ($obj->href = $objektUrl); } else { $obj->get_object_href(); } $obj->title = $obj->pealkiri; $obj->buttons = $obj->get_edit_buttons(array(nupud => $buttons, tyyp_idlist => $obj->all['tyyp_id'], publish => $publish)); $obj->fdate = $obj->all[aeg]; $obj->last_modified = date('Y', $obj->all['last_modified']) > 1970 ? date('d.m.Y H:i', $obj->all['last_modified']) : ''; ## crap data $obj->flast_modified = $obj->all['last_modified']; $obj->details_link = $obj->href; $obj->details_title = $site->sys_sona(array(sona => "loe edasi", tyyp => "kujundus")); $obj->printgif = '<a href="' . $obj->href . '&op=print" onClick="avaprintaken(this.href, 600, 400, \'print\'); return false;" target=_blank><img src="' . $site->img_path . '/print_it.gif" border=0 width=19 height=18></a>'; $obj->printlink = $site->self . '?id=' . $obj->objekt_id . '&op=print'; $obj->created_user_id = $obj->all['created_user_id']; $obj->created_user_name = $obj->all['created_user_name']; $obj->changed_user_id = $obj->all['changed_user_id']; $obj->changed_user_name = $obj->all['changed_user_name']; $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']); $obj->fcreated_time = $obj->all['created_time']; $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']); $obj->fchanged_time = $obj->all['changed_time']; $obj->last_commented_time = $site->db->MySQL_ee($obj->all['last_commented_time']); $obj->comment_count = $obj->all['comment_count']; ################ # ALL values, set as attributes foreach ($obj->all as $fieldname => $value) { $obj->{$fieldname} = $value; } ############### # profile values, set as attributes $profile_def = $site->get_profile(array(id => $obj->all['profile_id'])); if ($profile_def[profile_id]) { include_once $class_path . 'profile.class.php'; $obj_profile = new Profile(array("id" => $obj->all['profile_id'])); #### 1. set profile fields as object attributes $obj_profile->set_obj_general_fields(array("obj" => &$obj, "get_object_fields" => $get_object_fields)); ################### # get selectlist values - 1 extra sql per function; sql is fast if (is_array($obj_profile->selectlist)) { $obj_profile->selectlist = array_unique($obj_profile->selectlist); #printr($obj_profile->selectlist); } # go on if object values needs changing: if (sizeof($obj_profile->selectlist) > 0) { #### 2. save array "->asset_names" human readable NAME-s: $obj_profile->get_asset_names(array("selectlist" => $obj_profile->selectlist)); #printr($obj_profile->asset_names); #printr($obj_profile->change_fields); ### 3. save object rest of attributes #print "<br>muuta ID: ".$obj->id; $obj_profile->set_obj_selectlist_fields(array("obj" => &$obj, "change_fields" => $obj_profile->change_fields)); } # if any selectvalue exist & need to change # / get selectlist values ################### } ################ # object CLASS specific parameters ########## ARTICLE if ($obj->class == 'article') { //$obj = init_article(array("id"=>$obj->id), &$smarty); if (!function_exists('smarty_function_init_article')) { require_once $smarty->_get_plugin_filepath('function', 'init_article'); } smarty_function_init_article(array("id" => $obj->id, 'name' => $name), $smarty); return; } elseif ($obj->class == 'document') { if (!function_exists('smarty_function_init_document')) { require_once $smarty->_get_plugin_filepath('function', 'init_document'); } $obj = smarty_function_init_document(array("id" => $obj->id, 'name' => $name), $smarty); return; } elseif ($obj->class == 'image') { if (!function_exists('smarty_function_init_picture')) { require_once $smarty->_get_plugin_filepath('function', 'init_picture'); } $obj = smarty_function_init_picture(array("id" => $obj->id, 'name' => $name), $smarty); return; } elseif ($obj->class == 'section') { $obj->show_toolicons = $obj->all['on_printlink']; $obj->is_mailinglist = $obj->all['on_meilinglist']; $obj->show_subarticles = $obj->all['on_alamartiklid']; $obj->hide_in_menu = $obj->all['on_peida_vmenyy']; $obj->show_date = $obj->all['on_kp_nahtav']; } elseif ($obj->class == 'poll') { $obj->is_open = $obj->all['on_avatud']; $obj->expires = $obj->all['expires'] ? $site->db->MySQL_ee($obj->all['expires']) : ''; $obj->fexpires = $obj->all['expires'] ? $obj->all['expires'] : ''; $obj->is_expired = $obj->all['expires'] && (strtotime($obj->all['expires']) > 0 && strtotime($obj->all['expires']) < time()) ? 1 : 0; #printr(strtotime($obj->all['expires'])); ######### CHECK voting # 1) IP-based gallup if ($site->CONF[gallup_ip_check] == 1) { $sql = $site->db->prepare("SELECT COUNT(gi_id) FROM gallup_ip WHERE objekt_id=? AND ip LIKE ?", $obj->id, $_SERVER["REMOTE_ADDR"]); $sth = new SQL($sql); $count = $sth->fetchsingle(); } else { if ($site->CONF[gallup_ip_check] == 2 && $site->cookie["gallup"][$obj->id] == 1) { $count = 1; } else { if ($site->CONF[gallup_ip_check] == 3) { $sql = $site->db->prepare("SELECT COUNT(gi_id) FROM gallup_ip WHERE objekt_id=? AND user_id=?", $obj->id, $site->user->user_id); $sth = new SQL($sql); # count=1: not logged in users are not allowed to vote: $count = $site->user->user_id ? $sth->fetchsingle() : 1; } else { $count = 0; } } } ######### / CHECK voting ### is_voted: if user is voted this poll or not, 1/0 $obj->is_voted = $count; # not voted ### answers $sql = $site->db->prepare("SELECT * FROM gallup_vastus WHERE objekt_id=?", $obj->id); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); $obj->answers = array(); $obj->answers_count = 0; while ($vastus = $sth->fetch()) { unset($tmp); $tmp = new stdClass(); $tmp->id = $vastus[gv_id]; $tmp->answer = $vastus[vastus]; $tmp->title = $vastus[vastus]; $tmp->count = $vastus[count]; $obj->answers[$vastus[gv_id]] = $tmp; $obj->answers_count += $vastus[count]; } ### / answers ### voters (if not anonymous poll) if (!$obj->is_anonymous) { $sql = $site->db->prepare("SELECT gallup_ip.*, users.firstname, users.lastname\r\n\t\t\t\tFROM gallup_ip\r\n\t\t\t\t\tLEFT JOIN users ON users.user_id = gallup_ip.user_id\r\n\t\t\t\tWHERE objekt_id=?", $obj->id); $sth = new SQL($sql); $site->debug->msg($sth->debug->get_msgs()); $obj->voters = array(); while ($vastus = $sth->fetch()) { unset($tmp); $tmp->id = $vastus[gi_id]; $tmp->answer_id = $vastus[gv_id]; $tmp->ip = $vastus[ip]; $tmp->user_id = $vastus[user_id]; $tmp->user_firstname = $vastus[firstname]; $tmp->user_lastname = $vastus[lastname]; $tmp->time = $site->db->MySQL_ee($vastus[vote_time]); $tmp->ftime = $vastus[vote_time]; $obj->voters[$vastus[gi_id]] = $tmp; } } # if not anonymous poll ### / voters } elseif ($obj->class == 'album') { // add album config atributes $conf = new CONFIG($obj->all['ttyyp_params']); $obj->description = $conf->get('desc'); $obj->thumbnail_size = $conf->get('tn_size'); # in pixels $obj->image_size = $conf->get('pic_size'); # in pixels $obj->folder_id = $conf->get('folder_id'); # source folder ID $obj->folder_path = $conf->get('path'); # source folder path, eg "public/images" } ########## / ALBUM ############## # assign to template variables $smarty->assign($name, $obj); }
/** * save object info to database * * Uses sub-scripts to save different data for different object types. * No parameters used, only globals, it is included script. * * @package CMS * * Call: * include_once("edit_object.php"); * save_object(); */ function save_object() { global $site; global $objekt; global $class_path; global $keel; global $tyyp; verify_form_token(); ################### # 1. special case: if object is NEW picture if ($tyyp['klass'] == "pilt" && !$objekt->objekt_id) { include_once "edit_" . $tyyp['klass'] . ".php"; if (function_exists("save_objekts")) { save_objekts(array(tyyp_id => $tyyp[tyyp_id], keel => $keel)); } } else { # pealkiri peab olema! if ($site->fdat[pealkiri] == '' && $tyyp['klass'] != "kommentaar") { $errors .= $site->sys_sona(array(sona => "maaratud pealkiri", tyyp => "editor")) . "<br>"; } ################### # Salvestame tyybi parameetrid if (file_exists("edit_" . $tyyp['klass'] . ".php")) { include_once "edit_" . $tyyp['klass'] . ".php"; if (function_exists("save_tyyp_params")) { $templ_params = save_tyyp_params(array(objekt => $objekt)); } } ################### # Salvestame malli parameetrid - old ver3 style # arvestame, et malli parameetrid k�ivad ainult sisumalli kohta $sql = $site->db->prepare("SELECT ttyyp_id, templ_fail FROM templ_tyyp WHERE ttyyp_id = ?", $site->fdat['ttyyp_id']); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sth->debug->get_msgs()); $temp_ttyyp = $sth->fetch(); if ($temp_ttyyp['templ_fail'] && strpos($temp_ttyyp['templ_fail'], '../') !== 0 && file_exists("../" . $temp_ttyyp['templ_fail'])) { include_once "../" . $temp_ttyyp['templ_fail']; } if (function_exists("save_params")) { $templ_params = save_params(array(objekt => $objekt)); } ### ttyyp_params - ver3 style vs ver4. Bug #2506 if (!empty($templ_params)) { $oldstyle_tyyp_params = true; # if old-ver-style fixed params are used } else { # use new ver4 style custom conf save/load by default $oldstyle_tyyp_params = false; } ################### # if no errors occured , begin saving to database if (!$errors) { $site->debug->msg("EDIT: Objekti salvestamine"); ################### # strip HTML tags from headline, lyhi, sisu for strip-fields // folder title is folder filesystem name if ($site->fdat['tyyp_id'] == 22) { $site->fdat['pealkiri'] = safe_filename2($site->fdat['pealkiri']); } $pealkiri_strip = $site->fdat['pealkiri']; $sisu_strip = $site->fdat['scms_article_editor'] ? $site->fdat['scms_article_editor'] : ($site->fdat['sisu'] ? $site->fdat['sisu'] : $site->fdat['text']); # replace some tags with space before stripping tags (bug #1568 ) $replace_tags_arr = array("<br>", "<BR>", "<br />", "<BR />", " "); $pealkiri_strip = str_replace($replace_tags_arr, " ", $pealkiri_strip); $sisu_strip = str_replace($replace_tags_arr, " ", $sisu_strip); $replace_tags_arr = array("&"); $pealkiri_strip = str_replace($replace_tags_arr, "&", $pealkiri_strip); $sisu_strip = str_replace($replace_tags_arr, "&", $sisu_strip); $pealkiri_strip = strip_tags($pealkiri_strip); $sisu_strip = strip_tags($sisu_strip); // remove excess spaces $sisu_strip = preg_replace('/\\s+/', ' ', $sisu_strip); // overwrite catch for files, this is here so when a new file is being uploaded but // a file with a same name already exists // there wouldn't be double objects // instead use the existing object and move on as that objects update if ($site->fdat['tyyp_id'] == 21 && $_FILES['fileupload']['name']) { $parent_folder = new Objekt(array('objekt_id' => $objekt->parent_id, 'on_sisu' => 1)); $parent_folder_path = preg_replace('#/$#', '', $site->absolute_path) . $parent_folder->all['relative_path']; // delete file if (file_exists($parent_folder_path . '/' . safe_filename2($_FILES['fileupload']['name']))) { unlink($parent_folder_path . '/' . safe_filename2($_FILES['fileupload']['name'])); } $file_path = preg_replace('#/$#', '', $site->absolute_path) . $objekt->all['relative_path']; // delete the file itself (bug #2586) if ($objekt->objekt_id && file_exists($file_path)) { unlink($file_path); } $sql = $site->db->prepare('select objekt_id from obj_file where relative_path = ?', $parent_folder->all['relative_path'] . '/' . safe_filename2($_FILES['fileupload']['name'])); $result = new SQL($sql); if ($result->rows && ($existing_id = $result->fetchsingle())) { // delete the object used to overwrite // don't delete if it's the same object (bug # 2576) if ($objekt->objekt_id && $objekt->objekt_id != $existing_id) { $objekt->del(); } $objekt = new Objekt(array('objekt_id' => $existing_id, 'on_sisu' => 1, 'no_cache' => 1)); } } // / overwrite catch ################### # UPDATE if ($objekt->objekt_id) { /* Check if avaldamise_algus & avaldamise_lopp has the right format if not fix it. */ if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s?(\\d?\\d?)[\\:\\\\.\\/\\-]?(\\d?\\d?)/", $site->fdat[avaldamise_algus], $aa_reg)) { if (!$aa_reg[2] && !$aa_reg[3]) { $site->fdat['avaldamise_algus'] = $aa_reg[1] . " 00:00:00"; } else { $site->fdat['avaldamise_algus'] = $aa_reg[1] . " " . $aa_reg[2] . ":" . $aa_reg[3] . ":00"; } } if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s?(\\d?\\d?)[\\:\\\\.\\/\\-]?(\\d?\\d?)/", $site->fdat['avaldamise_lopp'], $al_reg)) { if (!$al_reg[2] && !$al_reg[3]) { $site->fdat['avaldamise_lopp'] = $al_reg[1] . " 23:59:59"; } else { $site->fdat['avaldamise_lopp'] = $al_reg[1] . " " . $al_reg[2] . ":" . $al_reg[3] . ":59"; } } /* End of check */ $sql = $site->db->prepare("UPDATE objekt SET pealkiri=?, on_pealkiri=?, on_foorum=?, on_saadetud=?, ttyyp_id=?, page_ttyyp_id=?, pealkiri_strip=?, sisu_strip=?, aeg=?, avaldamisaeg_algus=?, avaldamisaeg_lopp=?, last_modified=" . time() . ", author=?, friendly_url=?, is_hided_in_menu=?, kesk=?, check_in=?, changed_user_id=?, changed_user_name=?, changed_time=?, on_avaldatud = ? WHERE objekt_id=?", $site->fdat['pealkiri'], $site->fdat['on_pealkiri'], $site->fdat['on_foorum'] ? 1 : 0, $site->fdat['on_saadetud'] ? 0 : 1, $site->fdat['ttyyp_id'], $site->fdat['page_ttyyp_id'], $pealkiri_strip, $sisu_strip, $site->db->ee_MySQL($site->fdat['aeg']), $site->db->ee_MySQL_long($site->fdat['avaldamise_algus']), $site->db->ee_MySQL_long($site->fdat['avaldamise_lopp']), $site->fdat['author'], $site->fdat['friendly_url'], $site->fdat['is_hided_in_menu'] ? 1 : 0, $site->fdat['kesk'], 0, $site->user->id, $site->user->name, date("Y-m-d H:i:s"), isset($site->fdat['publish']) && is_numeric($site->fdat['publish']) ? (int) $site->fdat['publish'] : $objekt->all['on_avaldatud'], $objekt->objekt_id); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sth->debug->get_msgs()); # save old-ver3-style tyyp_params. Bug #2506 # this SQL should happen only as exception and not by default if ($oldstyle_tyyp_params === true) { $sql = $site->db->prepare("UPDATE objekt SET ttyyp_params = ? WHERE objekt_id=?", $templ_params ? $templ_params : 'ttyyp_params', $objekt->objekt_id); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sth->debug->get_msgs()); } # ------------------------ # Kustutame chache-ist ka # ------------------------ clear_cache("ALL"); new Log(array('action' => 'update', 'objekt_id' => $objekt->objekt_id, 'message' => sprintf("%s '%s' (ID = %s) %s", ucfirst(translate_en($objekt->all['klass'])), $objekt->pealkiri(), $objekt->objekt_id, "changed"))); } else { /* Check if avaldamise_algus & avaldamise_lopp has the right format if not fix it. */ if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s?(\\d?\\d?)[\\:\\\\.\\/\\-]?(\\d?\\d?)/", $site->fdat['avaldamise_algus'], $aa_reg)) { if (!$aa_reg[2] && !$aa_reg[3]) { $site->fdat['avaldamise_algus'] = $aa_reg[1] . " 00:00:00"; } else { $site->fdat['avaldamise_algus'] = $aa_reg[1] . " " . $aa_reg[2] . ":" . $aa_reg[3] . ":00"; } } if (preg_match("/(\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d[\\:\\\\.\\/\\-]\\d?\\d?\\d\\d)\\s?(\\d?\\d?)[\\:\\\\.\\/\\-]?(\\d?\\d?)/", $site->fdat['avaldamise_lopp'], $al_reg)) { if (!$al_reg[2] && !$al_reg[3]) { $site->fdat['avaldamise_lopp'] = $al_reg[1] . " 23:59:59"; } else { $site->fdat['avaldamise_lopp'] = $al_reg[1] . " " . $al_reg[2] . ":" . $al_reg[3] . ":59"; } } /* End of check */ $sql = $site->db->prepare("INSERT INTO objekt (pealkiri, on_pealkiri, on_foorum, on_saadetud, tyyp_id, author, on_avaldatud, keel, kesk, ttyyp_id, page_ttyyp_id, pealkiri_strip, sisu_strip, aeg, sys_alias, ttyyp_params, avaldamisaeg_algus, avaldamisaeg_lopp, last_modified, friendly_url, is_hided_in_menu, check_in, check_in_admin_id, created_user_id, created_user_name, created_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $site->fdat['pealkiri'], $site->fdat['on_pealkiri'], $site->fdat['on_foorum'], $site->fdat['on_saadetud'] ? 0 : 1, $tyyp['tyyp_id'], $site->fdat['author'], $site->fdat['sys_alias'] || $site->fdat['publish'] ? 1 : 0, $tyyp['tyyp_id'] == 21 || $tyyp['tyyp_id'] == 22 ? 1 : $keel, $site->fdat['kesk'], $site->fdat['ttyyp_id'], $site->fdat['page_ttyyp_id'], $pealkiri_strip, $sisu_strip, $site->db->ee_MySQL($site->fdat['aeg']), $site->fdat['sys_alias'], $templ_params, $site->db->ee_MySQL_long($site->fdat['avaldamise_algus']), $site->db->ee_MySQL_long($site->fdat['avaldamise_lopp']), time(), $site->fdat['friendly_url'], $site->fdat['is_hided_in_menu'] ? 1 : 0, 0, $site->user->id, $site->user->id, $site->user->name, date("Y-m-d H:i:s")); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sth->debug->get_msgs()); $obj_insert_id = $sth->insert_id; # ------------------------ # Kustutame chache-ist ka # ------------------------ clear_cache("ALL"); $objekt = new Objekt(array(objekt_id => $obj_insert_id, no_cache => 1, creating => 1)); if (!is_numeric($objekt->objekt_id)) { $objekt->objekt_id = $obj_insert_id; } $site->fdat['id'] = $objekt->objekt_id; new Log(array('action' => 'create', 'objekt_id' => $objekt->objekt_id, 'message' => sprintf("%s '%s' (ID = %s) %s", ucfirst(translate_en($objekt->all['klass'])), $objekt->pealkiri(), $objekt->objekt_id, "inserted"))); $is_new = 1; } # / INSERT ################### ################### # WHAT IS THIS? $objekt->all["on_peida_vmenyy"] = $site->fdat["on_peida_vmenyy"] ? 1 : 0; ################### # SALVESTA t��bist s�ltuv osa #$fdat{objekt}->{klass} = "artikkel" if ($fdat{objekt}->{klass} eq "oigusakt"); # INCLUDE t��bist s�ltuv fail include_once "edit_" . $tyyp['klass'] . ".php"; # salvesta objekti t��bist s�ltuv osa salvesta_objekt(); # save all profile fields: if ($site->fdat['profile_id']) { # if profile set save_obj_profile(); } # / SALVESTA t��bist s�ltuv osa ################### ################### # PARENTS (tbl 'objekt_objekt') ################### $site->debug->msg("------------ PARENTS -------------"); ################### ####################### # 1. FIND NEW PARENTS $new_parents = array(); # parentit on lubatud select-boxis muuta j�rgmistel objektidel: # artikkel, dokument, rubriik, album, asset, gallup, kommentaar # 1) kui tegu on lubatud objektiga JA vormis oli parent rubriik valitud, # siis if (($tyyp['klass'] == "artikkel" || $tyyp['klass'] == "dokument" || $tyyp['klass'] == "rubriik" || $tyyp['klass'] == "album" || $tyyp['klass'] == "asset" || $tyyp['klass'] == "gallup" || $tyyp['klass'] == "kommentaar" || $tyyp['klass'] == "link") && is_array($site->fdat['rubriik'])) { # salvesta k�ik vormis valitud rubriigid massiivi foreach ($site->fdat['rubriik'] as $value) { $new_parents[$value] = 1; } # kui parenti ID oli 0, siis what the hell siin tehakse? /* if ($site->fdat['parent_id']==0) { $new_parents[$site->fdat['parent_id']] = 1; } */ } elseif ($site->fdat['parent_id']) { $new_parents[$site->fdat['parent_id']] = 1; } ######### get parent object if ($site->fdat['parent_id']) { $parent = new Objekt(array(objekt_id => $site->fdat['parent_id'])); } # kui objektil leidub korrektne parent ja pole tegu rubriigiga, # siis pane parentiks 'parent_id' parameeter (eee, j�lle?) # Lauri: parent ise ei tohiks saada new_parentiks. seega kommentaari juures konkreetselt keelan ara if ($parent && $parent->all['klass'] != "rubriik" && $tyyp['klass'] != "kommentaar") { $new_parents[$site->fdat['parent_id']] = 1; } ######## gallupi erijuht if ($tyyp['klass'] == "gallup") { if ($site->fdat['on_avatud']) { $objekt->load_sisu(); $site->debug->msg("EDIT: vana parent rullib!"); # removed by Bug #1896: gallupit ei saa teise rubriigi alla t�sta # $new_parents = array($objekt->all["orig_parent_id"] => 1); } else { # kui suletud gallup, siis liiguta gallupi arhiivi $new_parents = array($site->alias("gallup_arhiiv") => 1); } } $site->debug->msg("EDIT: Selected new parents: " . join(",", array_keys($new_parents))); # 1. / FIND NEW PARENTS ####################### ####################### # 2. FIND CURRENT PARENTS $current_parents = array(); ########### RUBRIIK V�I LINGIKAST if ($tyyp['klass'] == "rubriik") { ######## Otsime, kas rubriik kuulub ka m�ne uudistekogu alla - need on vaja uutele parentitele vaikselt lisada $sql = $site->db->prepare("SELECT objekt_objekt.parent_id FROM objekt_objekt LEFT JOIN objekt ON objekt.objekt_id=objekt_objekt.parent_id WHERE objekt_objekt.objekt_id=? and objekt.tyyp_id=9", $objekt->objekt_id); $sth = new SQL($sql); while ($tmp_data = $sth->fetchsingle()) { $newslist_parents[$tmp_data] = 1; # lisa salaja uudistekogu ID samuti uute parentite massiivile $new_parents[$tmp_data] = 1; } unset($tmp_data); if ($sth->rows) { $site->debug->msg("EDIT: Parent news lists: " . join(",", array_keys($newslist_parents))); } ########## leia rubriigi praegused parentid $sql = $site->db->prepare("SELECT parent_id FROM objekt_objekt WHERE objekt_id=?", $objekt->objekt_id); $sth = new SQL($sql); while ($tmp_data = $sth->fetch()) { $parent_id = $tmp_data['parent_id']; $current_parents[$parent_id] = 1; } ######### K�IK �LEJ��NUD objektid v.a rubriik ja lingikast } else { # ----------------------------------- # siin on need objektid mille jaoks # on lubatud rohkem kui 1 �lema omama # ----------------------------------- $sql = $site->db->prepare("SELECT parent_id FROM objekt_objekt WHERE objekt_id=?", $objekt->objekt_id); $sth = new SQL($sql); while ($tmp_data = $sth->fetch()) { $parent_id = $tmp_data['parent_id']; $current_parents[$parent_id] = 1; } # mis siin tehakse? # Lauri: oeldakse jargmise IF-i jaoks, et ara sinna sisse mine. vaata 10 rida allapoole if ($current_parents[0]) { $new_parents[0] = 1; } } $site->debug->msg("EDIT: Current parents: " . join(",", array_keys($current_parents))); # / 2. FIND CURRENT PARENTS ####################### # kui uute parentite massiiv on t�hi, siis kasuta vormis alati kaasas olnud # peidetud v��rtust 'permanent_parent_id' if ($site->fdat['permanent_parent_id'] != "" && !count(array_keys($new_parents))) { $new_parents[$site->fdat['permanent_parent_id']] = 1; } $site->debug->msg("EDIT: Final parents: " . join(",", array_keys($new_parents))); ####################### # 3. CHECK NEW PARENTS PERMISSIONS foreach (array_keys($new_parents) as $parent_id) { if ($parent_id) { # kui uus �lem (varem polnud), siis kontrolli �iguseid if (!$current_parents[$parent_id]) { ####### check permissions $perm = get_obj_permission(array("objekt_id" => $parent_id)); # kui uuel parentil on CREATE �igus, siis luba lisada objekt selle parenti alla, # muidu mitte if ($perm['C']) { $site->debug->msg("EDIT: New parent " . $parent_id . " permissions " . $perm['mask'] . " allow to create object under it => OK"); } else { $site->debug->msg("EDIT: New parent " . $parent_id . " permissions " . $perm['mask'] . " don't allow to create object under it => FORBIDDEN"); # v�ta see parent maha uute parentite massiivist unset($new_parents[$parent_id]); } # new parent permissions } } # if parent_id } $site->debug->msg("EDIT: Final parents after permission check: " . join(",", array_keys($new_parents))); # / 3. CHECK NEW PARENTS PERMISSIONS ####################### # kui uute parentite arv on 0 st objekti ei tohi uue parenti alla lisada, # siis �ra tee �ldse midagi if (!count(array_keys($new_parents))) { $site->debug->msg("EDIT: Can't move under new parent => don't do anything at all"); $fatal_parent_error = 1; } # kui uued parentid on ainult uudistekogud (samad mis enne), siis �ra tee �ldse midagi if (sizeof($newslist_parents) > 0) { $result = array_diff(array_keys($new_parents), array_keys($newslist_parents)); if (sizeof($result) <= 0) { # kui massiivid pole erinevad $site->debug->msg("EDIT: New parents are equal to existing newslist parents => don't do anything at all"); $fatal_parent_error = 1; } } else { if (!$fatal_parent_error) { # if not fatal parent error ####################### # 4. INSERT NEW PARENTS (siin on juba ainult need parentid, mille alla v�ib objekti lisada) foreach (array_keys($new_parents) as $parent_id) { if ($parent_id) { # �lem on olemas, siis pole vaja midagi teha if ($current_parents[$parent_id]) { $current_parents[$parent_id] = 0; $site->debug->msg("EDIT: Parent {$parent_id} j��b nagu oli"); } else { if ($site->fdat["sorting"]) { $sorteering = $site->fdat["sorting"]; } else { $sql = "SELECT max(sorteering) FROM objekt_objekt"; $sth = new SQL($sql); $sorteering = $sth->fetchsingle(); } #move objects forward so new object can be inserted in the middle $sql = $site->db->prepare("UPDATE objekt_objekt SET sorteering=sorteering+1 WHERE sorteering>?", $sorteering); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); ################ INSERT $sql = $site->db->prepare("INSERT INTO objekt_objekt (objekt_id, parent_id, sorteering) VALUES (?,?,?)", $objekt->objekt_id, $parent_id, $sorteering + 1); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); if ($tyyp['klass'] == 'kommentaar') { $sql = $site->db->prepare("UPDATE objekt SET comment_count = comment_count+1 WHERE objekt_id=?", $parent_id); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); } } # uus �lem, lisa } # if parent_id } # / 4. INSERT NEW PARENTS ####################### ####################### # 5. DELETE OLD PARENTS function notnull($a) { return $a > 0; } $to_delete = join(",", array_keys(array_filter($current_parents, "notnull"))); $site->debug->msg("EDIT: Current Parents, allowed to delete: " . $to_delete); # kui vormis oli valitud m�ni parent rubriik JA objekt on lubatud t��pi (tal v�ib parentit muuta), # siis... mis tehakse? if (sizeof($site->fdat['rubriik']) > 0 && ($tyyp['klass'] == "artikkel" || $tyyp['klass'] == "dokument" || $tyyp['klass'] == "gallup" || $tyyp['klass'] == "rubriik" || $tyyp['klass'] == "album" || $tyyp['klass'] == "asset" || $tyyp['klass'] == "dokument" || $tyyp['klass'] == "gallup" || $tyyp['klass'] == "kommentaar" || $tyyp['klass'] == "link")) { $parent_ids = array(); foreach (array_unique(array_merge($site->fdat['rubriik'], array_keys($new_parents))) as $tmp_id) { if ((int) $tmp_id) { $parent_ids[] = (int) $tmp_id; } } ########### Lauri 04092009: store parents that will be deleted so we can reduce their comment_count $sql = $site->db->prepare("SELECT parent_id FROM objekt_objekt WHERE objekt_id=? AND parent_id NOT IN(" . implode(',', $parent_ids) . ")", $objekt->objekt_id); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); $parents_to_delete = array(); while ($return_row = $sth->fetch()) { $parents_to_delete[] = $return_row['parent_id']; } ############ DELETE $sql = $site->db->prepare("DELETE FROM objekt_objekt WHERE objekt_id=? AND parent_id NOT IN(" . implode(',', $parent_ids) . ")", $objekt->objekt_id); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); ########## Lauri 04092009: reduce comment count for parents from which kommentaar was deleted if ($tyyp['klass'] == 'kommentaar') { $sql = $site->db->prepare("UPDATE objekt SET comment_count = comment_count-1 WHERE objekt_id IN(" . implode(',', $parents_to_delete) . ")"); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); } } ############ DELETE # kui on parenteid, mida kustutada: if ($to_delete) { $sql = $site->db->prepare("DELETE FROM objekt_objekt WHERE objekt_id=? AND parent_id IN(?)", $objekt->objekt_id, $to_delete); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); ############ Lauri 04092009: if some more parents got removed, reduce comment_count on them too. have to make sure not to do it twice tho $comments_to_substract = array_diff((array) $to_delete, $parents_to_delete); if ($tyyp['klass'] == 'kommentaar' && count($comments_to_substract)) { $sql = $site->db->prepare("UPDATE objekt SET comment_count = comment_count-1 WHERE objekt_id IN (" . implode(',', $comments_to_substract) . ")"); $sth = new SQL($sql); $site->debug->msg("EDIT: " . $sql); } } # / 5. DELETE OLD PARENTS ####################### } } # if not fatal parent error (new parent permissions) ################################## / DATABASE SQL-s ################################## $site->debug->msg("------------ PARENTS END -------------"); # / PARENTS ################### ######################## # INSERT PERMISSIONS # lisame uuele objektile t�pselt samad �igused nagu on tema parent objektile. # OBJ class check: save permissions only for objects having class "rubriik" (1) or "folder" (22). # NB! if you change class conditions here, be sure to change them in Repair database script also! # (see also bug #1545) if ($tyyp[tyyp_id] == 1 || $tyyp[tyyp_id] == 22) { # if object is section or folder if ($is_new) { # leia k�ik parenti �igused userite/gruppide kohta: $sql = $site->db->prepare("SELECT * FROM permissions WHERE type=? AND source_id=?", 'OBJ', $parent->objekt_id); $sth = new SQL($sql); # ts�kkel �le parenti �iguste while ($perm = $sth->fetch()) { # lisa �igus uuele objektile $sql2 = $site->db->prepare("INSERT INTO permissions (type,source_id,role_id,group_id,user_id,C,R,U,P,D) VALUES (?,?,?,?,?,?,?,?,?,?)", 'OBJ', $objekt->objekt_id, $perm['role_id'], $perm['group_id'], $perm['user_id'], $perm['C'], $perm['R'], $perm['U'], $perm['P'], $perm['D']); $sth2 = new SQL($sql2); } # ts�kkel �le parenti �iguste // reload permissions for user if (!$site->user->is_superuser) { if ($site->user) { $site->user->permissions = $site->user->load_objpermissions(); } elseif ($site->guest) { $site->guest->permissions = $site->guest->load_objpermissions(); } } } # if new, just created object } # if object is section or folder # / INSERT PERMISSIONS ######################## return 1; } else { ?> <center><font class=txt> <br> <font color=red> <?php echo $errors; ?> </font> <br> <a href="javascript:history.back();"><?php echo $site->sys_sona(array(sona => "Tagasi", tyyp => "editor")); ?> </a> </font></center> <?php } # / print errors ################### } # / 2. usual case ################### }
include_once($class_path."port.inc.php"); #Get debug cookie muutuja $debug = $_COOKIE["debug"] ? 1:0; $hidden_output = 0; $site = new Site(array( on_debug=>$debug, on_admin_keel => 1 )); $objekt = new Objekt(array( objekt_id => $site->fdat['id'] )); if ($objekt){$rub_trash_id = $site->alias(array('key' => 'trash', 'keel'=>$objekt->all['keel']));} if ($objekt->objekt_id==$rub_trash_id && $rub_trash_id){ echo "<font face=verdana size=2><b>You can not delete section \"Recycle Bin\" !</b></font>"; exit(); } #################################### # GET PERMISSIONS # get object permissions for current user