diff --git a/modules/backend.module b/modules/backend.module index 9c3b2bdcc61..217762ac746 100644 --- a/modules/backend.module +++ b/modules/backend.module @@ -2,6 +2,7 @@ $module = array("page" => "backend_page", "cron" => "backend_cron", + "block" => "backend_block", "admin" => "backend_admin"); include "includes/theme.inc"; @@ -50,6 +51,24 @@ function backend_cron() { } } +function backend_block() { + $result = db_query("SELECT * FROM channel"); + while ($channel = db_fetch_object($result)) { + $backend = new Backend($channel->id); + + $content = ""; + for (reset($backend->headlines); $headline = current($backend->headlines); next($backend->headlines)) { + $content .= "
  • $headline
  • \n"; + } + + $blocks[$channel->id]["subject"] = $backend->site; + $blocks[$channel->id]["content"] = $content; + $blocks[$channel->id]["info"] = "$backend->site headlines"; + $blocks[$channel->id]["link"] = $backend->url; + } + return $blocks; +} + function backend_admin_main() { global $theme; @@ -57,7 +76,7 @@ function backend_admin_main() { $result = db_query("SELECT * FROM channel ORDER BY id"); $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($channel = db_fetch_object($result)) { // Load backend from database: @@ -66,7 +85,7 @@ function backend_admin_main() { $output .= "\n"; $output .= " \n"; $output .= " \n"; - $output .= " \n"; + $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "\n"; @@ -86,7 +105,7 @@ function backend_admin_main() { $output .= "

    \n"; $output .= "

    \n"; $output .= " Backend file:
    \n"; - $output .= " \n"; + $output .= " \n"; $output .= "

    \n"; $output .= "

    \n"; $output .= " Contact information:
    \n"; @@ -99,7 +118,7 @@ function backend_admin_main() { } function backend_admin() { - global $op, $id, $site, $url, $file, $contact; + global $op, $id, $site, $url, $backend, $contact; switch($op) { case "refresh": @@ -114,7 +133,7 @@ function backend_admin() { backend_admin_main(); break; case "Add backend": - $backend = new backend($id, $site, $url, $file, $contact); + $backend = new backend($id, $site, $url, $backend, $contact); $backend->add(); // fall through: default: diff --git a/modules/block.module b/modules/block.module new file mode 100644 index 00000000000..b3b9be774c2 --- /dev/null +++ b/modules/block.module @@ -0,0 +1,53 @@ + "block_admin"); + +function block_admin_save($edit) { + foreach ($edit as $key=>$value) { + db_query("UPDATE blocks SET status = '$value' WHERE name = '$key'"); + } +} + +function block_admin_display() { + global $repository; + + $result = db_query("SELECT * FROM blocks"); + + // Generate output: + $output .= "
    \n"; + $output .= "

    sitecontactlast updatedoperations
    sitecontactlast updateoperations
    url\">$backend->sitecontact\">$backend->contact". round((time() - $backend->timestamp) / 60) ." min. ago". format_interval(time() - $backend->timestamp) ." agoid\">refreshid\">delete
    \n"; + $output .= " \n"; + + while ($block = db_fetch_object($result)) { + $module = ($repository[$block->module]["admin"]) ? "module\">$block->module" : $block->module; + + $status .= "\n"; + + $output .= " \n"; + + unset($status); + } + + $output .= "
    blockmodulestatus
    ". $block->name ."$module$status
    \n"; + $output .= "\n"; + $output .= "\n"; + + print $output; +} + +function block_admin() { + global $op, $edit; + + switch ($op) { + case "Save blocks": + block_admin_save($edit); + break; + } + + block_admin_display(); +} + +?> diff --git a/modules/block/block.module b/modules/block/block.module new file mode 100644 index 00000000000..b3b9be774c2 --- /dev/null +++ b/modules/block/block.module @@ -0,0 +1,53 @@ + "block_admin"); + +function block_admin_save($edit) { + foreach ($edit as $key=>$value) { + db_query("UPDATE blocks SET status = '$value' WHERE name = '$key'"); + } +} + +function block_admin_display() { + global $repository; + + $result = db_query("SELECT * FROM blocks"); + + // Generate output: + $output .= "
    \n"; + $output .= "\n"; + $output .= " \n"; + + while ($block = db_fetch_object($result)) { + $module = ($repository[$block->module]["admin"]) ? "module\">$block->module" : $block->module; + + $status .= "\n"; + + $output .= " \n"; + + unset($status); + } + + $output .= "
    blockmodulestatus
    ". $block->name ."$module$status
    \n"; + $output .= "\n"; + $output .= "
    \n"; + + print $output; +} + +function block_admin() { + global $op, $edit; + + switch ($op) { + case "Save blocks": + block_admin_save($edit); + break; + } + + block_admin_display(); +} + +?> diff --git a/modules/calendar.class b/modules/calendar.class new file mode 100644 index 00000000000..1bd8b795e1b --- /dev/null +++ b/modules/calendar.class @@ -0,0 +1,76 @@ +date = $date; + } + + function display() { + // Extract information from the given date: + $month = date("n", $this->date); + $year = date("Y", $this->date); + $day = date("d", $this->date); + + // Extract first day of the month: + $first = date("w", mktime(0, 0, 0, $month, 1, $year)); + + // Extract last day of the month: + $last = date("t", mktime(0, 0, 0, $month, 1, $year)); + + // Calculate previous and next months dates: + $prev = mktime(0, 0, 0, $month - 1, $day, $year); + $next = mktime(0, 0, 0, $month + 1, $day, $year); + + // Generate calendar header: + $output .= "\n\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + + // Initialize temporary variables: + $nday = 1; + $sday = $first; + + // Loop through all the days of the month: + while ($nday <= $last) { + // Set up blank days for first week of the month: + if ($first) { + $output .= " \n"; + $first = 0; + } + + // Start every week on a new line: + if ($sday == 0) $output .= " \n"; + + // Print one cell: + $date = mktime(24, 0, 0, $month, $nday, $year); + if ($nday == $day) $output .= " \n"; + else if ($date > time()) $output .= " \n"; + else $output .= " \n"; + + // Start every week on a new line: + if ($sday == 6) $output .= " \n"; + + // Update temporary variables: + $sday++; + $sday = $sday % 7; + $nday++; + } + + // Complete the calendar: + if ($sday) { + $end = 7 - $sday; + $output .= " \n \n"; + } + $output .= "
    <   ". date("F Y", $this->date) ."   >
    SMTWTFS
     
    $nday$nday$nday
     
    \n\n"; + + // Return calendar: + return $output; + } +} + +?> diff --git a/modules/calendar.module b/modules/calendar.module index d6c0443897e..fe79beea5a1 100644 --- a/modules/calendar.module +++ b/modules/calendar.module @@ -1,78 +1,19 @@ "calendar_block"); -class Calendar { - var $date; +function calendar_block() { + global $date; - function calendar($date) { - $this->date = $date; - } + include "modules/calendar.class"; - function display() { - global $PHP_SELF; + $calendar = new Calendar($date); - // Extract information from the given date: - $month = date("n", $this->date); - $year = date("Y", $this->date); - $day = date("d", $this->date); - - // Extract first day of the month: - $first = date("w", mktime(0, 0, 0, $month, 1, $year)); - - // Extract last day of the month: - $last = date("t", mktime(0, 0, 0, $month, 1, $year)); - - // Calculate previous and next months dates: - $prev = mktime(0, 0, 0, $month - 1, $day, $year); - $next = mktime(0, 0, 0, $month + 1, $day, $year); - - // Generate calendar header: - $output .= "\n\n"; - $output .= "\n"; - $output .= " \n"; - $output .= " \n"; + $block[0]["subject"] = "Browse archives"; + $block[0]["content"] = $calendar->display(); + $block[0]["info"] = "calendar"; - // Initialize temporary variables: - $nday = 1; - $sday = $first; - - // Loop through all the days of the month: - while ($nday <= $last) { - // Set up blank days for first week of the month: - if ($first) { - $output .= " \n"; - $first = 0; - } - - // Start every week on a new line: - if ($sday == 0) $output .= " \n"; - - // Print one cell: - $date = mktime(24, 0, 0, $month, $nday, $year); - if ($nday == $day) $output .= " \n"; - else if ($date > time()) $output .= " \n"; - else $output .= " \n"; - - // Start every week on a new line: - if ($sday == 6) $output .= " \n"; - - // Update temporary variables: - $sday++; - $sday = $sday % 7; - $nday++; - } - - // Complete the calendar: - if ($sday) { - $end = 7 - $sday; - $output .= " \n \n"; - } - $output .= "
    <   ". date("F Y", $this->date) ."   >
    SMTWTFS
     
    $nday$nday$nday
     
    \n\n"; - - // Return calendar: - return $output; - } + return $block; } ?> diff --git a/modules/cron.module b/modules/cron.module index f0f091a9ded..89ec2994aad 100644 --- a/modules/cron.module +++ b/modules/cron.module @@ -4,14 +4,9 @@ $module = array("admin" => "cron_admin"); include_once "includes/function.inc"; - -function cron_reset($name) { - cron_delete($name); -} - function cron_save($edit) { foreach ($edit as $key=>$value) { - db_query("UPDATE cron SET scheduled = '$value' WHERE module = '$key'"); + db_query("UPDATE crons SET scheduled = '$value' WHERE module = '$key'"); } } @@ -19,15 +14,15 @@ function cron_display() { $intervals = array(300, 900, 1800, 3600, 7200, 10800, 21600, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200); // Perform query: - $result = db_query("SELECT * FROM cron"); + $result = db_query("SELECT * FROM crons"); // Generate output: $output .= "
    \n"; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($cron = db_fetch_object($result)) { foreach ($intervals as $value) $period .= "\n"; - $output .= " \n"; + $output .= " \n"; unset($period); } $output .= "
    moduleperiodlast executionoperations
    moduleperiodlast executionoperations
    ". check_output($cron->module) ."". format_interval(time() - $cron->timestamp) ." agoexecutemodule\">reset
    ". check_output($cron->module) ."". format_interval(time() - $cron->timestamp) ." agoexecute
    \n"; @@ -40,9 +35,6 @@ function cron_admin() { global $op, $edit, $name; switch($op) { - case "reset": - cron_reset($name); - break; case "Save crons": cron_save($edit); break; diff --git a/modules/development.module b/modules/development.module index a379cf11ed5..3c96ff91a6f 100644 --- a/modules/development.module +++ b/modules/development.module @@ -113,5 +113,4 @@ function development_page() { - +?> \ No newline at end of file diff --git a/modules/diary.module b/modules/diary.module index f2688347774..7e49e03e69d 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -1,6 +1,7 @@ "diary_page", + "block" => "diary_block", "admin" => "diary_admin"); @@ -191,6 +192,25 @@ function diary_page() { } } +function diary_block() { + $result = db_query("SELECT u.userid, d.timestamp FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY timestamp DESC LIMIT 20"); + + while ($diary = db_fetch_object($result)) { + if ($time != date("F jS", $diary->timestamp)) { + $content .= "

    ". date("l, M jS", $diary->timestamp) ."

    \n"; + $time = date("F jS", $diary->timestamp); + } + $content .= "
  • userid\">$diary->userid
  • \n"; + } + + $block[0]["subject"] = "Recent diary entries"; + $block[0]["content"] = $content; + $block[0]["info"] = "recent diary entries"; + $block[0]["link"] = "module.php?mod=diary"; + + return $block; +} + function diary_admin_edit($id) { $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id WHERE d.id = $id"); diff --git a/modules/module.module b/modules/module.module new file mode 100644 index 00000000000..f07b46a68ef --- /dev/null +++ b/modules/module.module @@ -0,0 +1,56 @@ + "module_admin"); + +function module_admin_rehash() { + global $repository; + + $result = db_query("SELECT * FROM modules"); + while ($module = db_fetch_object($result)) { + module_rehash($module->name); + } + + foreach ($repository as $name=>$module) { + module_rehash($name); + } +} + +function module_admin_display() { + global $output; + + function module_row($name, $module) { + global $output; + + $view = ($module["page"]) ? "view" : " "; + $admin = ($module["admin"]) ? "admin" : " "; + $output .= " $name$view$adminrehash\n"; + } + + $output .= "\n"; + $output .= "\n"; + $output .= " \n"; + + module_iterate("module_row"); + + $output .= "
    moduleoperations
    \n"; + $output .= "\n"; + $output .= "
    \n"; + print $output; +} + +function module_admin() { + global $op, $name; + + switch ($op) { + case "Rehash modules": + module_admin_rehash(); + break; + case "rehash": + module_rehash($name); + break; + } + + module_admin_display(); +} + +?> diff --git a/modules/modules.module b/modules/modules.module deleted file mode 100644 index 8e02bf5d966..00000000000 --- a/modules/modules.module +++ /dev/null @@ -1,20 +0,0 @@ - "modules_admin"); - -function modules_admin() { - $output .= "

    Installed or available modules:

    \n"; - $output .= " \n"; - - print $output; -} - -?> diff --git a/modules/wishlist.module b/modules/wishlist.module index d95c10d32c7..661e9897340 100644 --- a/modules/wishlist.module +++ b/modules/wishlist.module @@ -75,3 +75,4 @@ function wishlist_page() { } ?> +