Example #1
0
}
// Get page link URL
$sql = 'SELECT `link` FROM `' . TABLE_PREFIX . 'pages` WHERE `page_id`=' . (int) $page_id;
$oldLink = $database->get_one($sql);
// Include WB functions file
require_once WB_PATH . '/framework/functions.php';
// Work-out what the link should be
$newLink = '/posts/' . page_filename($title) . PAGE_SPACER . $post_id;
// create new accessfile
createNewsAccessFile($newLink, $oldLink, $page_id, $section_id, $post_id);
// get publisedwhen and publisheduntil
$publishedwhen = jscalendar_to_timestamp($admin->get_post_escaped('publishdate'));
if ($publishedwhen == '' || $publishedwhen < 1) {
    $publishedwhen = 0;
}
$publisheduntil = jscalendar_to_timestamp($admin->get_post_escaped('enddate'), $publishedwhen);
if ($publisheduntil == '' || $publisheduntil < 1) {
    $publisheduntil = 0;
}
// Update row
$sql = 'UPDATE `' . TABLE_PREFIX . 'mod_news_posts` ';
$sql .= 'SET `group_id`=' . (int) $group_id . ', ';
$sql .= '`title`=\'' . $title . '\', ';
$sql .= '`link`=\'' . $newLink . '\', ';
$sql .= '`content_short`=\'' . $short . '\', ';
$sql .= '`content_long`=\'' . $long . '\', ';
$sql .= '`commenting`=\'' . $commenting . '\', ';
$sql .= '`active`=' . (int) $active . ', ';
$sql .= '`published_when`=' . (int) $publishedwhen . ', ';
$sql .= '`published_until`=' . (int) $publisheduntil . ', ';
$sql .= '`posted_when`=' . time() . ', ';
 if (isset($_POST['comp_date']) && $_POST['comp_date'] != "") {
     if ($resultquery != "") {
         $resultquery .= ") AND";
     }
     $resultquery .= " (login_when";
     $xmlstoresearch .= "<datelastlogin>";
     if ($_POST['datesearch'] == "after") {
         $resultquery .= ">";
         $xmlstoresearch .= "<after>true</after>";
     } else {
         $resultquery .= "<";
         $xmlstoresearch .= "<before>true</before>";
     }
     // convert date to timestamp format to compare
     $resultquery .= jscalendar_to_timestamp($_POST['comp_date'], TIMEZONE);
     $xmlstoresearch .= "<date>" . jscalendar_to_timestamp($_POST['comp_date'], TIMEZONE) . "</date>";
     $xmlstoresearch .= "</datelastlogin>";
 }
 // if a group was choosen modify the sql query
 if (isset($_POST['groups']) && $_POST['groups'] != "-1") {
     $g_id = $_POST['groups'];
     if ($resultquery != "") {
         $resultquery .= ") AND";
     }
     $g_id = str_replace(",", '%', $g_id);
     $resultquery .= " (groups_id LIKE '%{$g_id}%'";
     $xmlstoresearch .= "<idgroup>" . $g_id . "</idgroup>";
     // retrieve the group name
     $result = $database->query("SELECT name from `" . TABLE_PREFIX . "groups` WHERE group_id = '{$g_id}'");
     $group_name = $result->fetchRow();
     $xmlstoresearch .= "<groupname>" . $group_name["name"] . "</groupname>";
            }
            // named sections patch
            if (isset($_POST['namesection' . $section_id])) {
                $sql .= ", namesection = '" . $admin->add_slashes($_POST['namesection' . $section_id]) . "'";
            }
            // update publ_start and publ_end, trying to make use of the strtotime()-features like "next week", "+1 month", ...
            if (isset($_POST['start_date' . $section_id]) && isset($_POST['end_date' . $section_id])) {
                if (trim($_POST['start_date' . $section_id]) == '0' || trim($_POST['start_date' . $section_id]) == '') {
                    $publ_start = 0;
                } else {
                    $publ_start = jscalendar_to_timestamp($_POST['start_date' . $section_id]);
                }
                if (trim($_POST['end_date' . $section_id]) == '0' || trim($_POST['end_date' . $section_id]) == '') {
                    $publ_end = 0;
                } else {
                    $publ_end = jscalendar_to_timestamp($_POST['end_date' . $section_id], $publ_start);
                }
                if ($sql != '') {
                    $sql .= ",";
                }
                $sql .= " publ_start = '" . $admin->add_slashes($publ_start) . "'";
                $sql .= ", publ_end = '" . $admin->add_slashes($publ_end) . "'";
            }
            $query = "UPDATE " . TABLE_PREFIX . "sections SET {$sql} WHERE section_id = '{$section_id}' LIMIT 1";
            if ($sql != '') {
                $database->query($query);
            }
        }
    }
}
// Check for error or print success message