cvs.module 2.34 KB
Newer Older
Dries's avatar
 
Dries committed
1
<?php
2
// $Id$
Dries's avatar
 
Dries committed
3

Dries's avatar
 
Dries committed
4
function cvs_perm() {
Dries's avatar
 
Dries committed
5 6 7 8 9
  return array("access cvs messages");
}

function cvs_link($type) {
  if ($type == "page" && user_access("access cvs messages")) {
Dries's avatar
 
Dries committed
10
    $links[] = "<a href=\"module.php?mod=cvs\">" . t("cvs messages") . "</a>";
Dries's avatar
 
Dries committed
11 12 13
  }

  return $links ? $links : array();
Dries's avatar
 
Dries committed
14 15
}

Dries's avatar
 
Dries committed
16
function cvs_cron() {
Dries's avatar
 
Dries committed
17 18
  if (time() - variable_get("cvs_cron_last", 0) > variable_get("cvs_cron_time", time())) {
    variable_set("cvs_cron_last", time());
Dries's avatar
 
Dries committed
19

Dries's avatar
 
Dries committed
20 21 22 23 24 25
    $result = db_query("SELECT * FROM cvs WHERE status = '0' ORDER BY timestamp DESC LIMIT 50");
    while ($cvs = db_fetch_object($result)) {
      $body .= "File: $cvs->files\nDate: ". format_date($cvs->timestamp) ."\nUser: $cvs->user\n\n$cvs->message\n----------------------------------------------------------------------\n";
    }
    $result = db_query("UPDATE cvs SET status = '1'");

Dries's avatar
 
Dries committed
26
    if ($body) mail(variable_get(cvs_mail, "root@localhost"), "cvs log messages", $body, "From: no-reply");
Dries's avatar
 
Dries committed
27
  }
Dries's avatar
 
Dries committed
28 29
}

Dries's avatar
CHANGES  
Dries committed
30
function cvs_conf_options() {
Dries's avatar
 
Dries committed
31
  $period = array(43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600));
Dries's avatar
 
Dries committed
32 33
  $output .= form_textfield("Digest recepients", "cvs_mail", variable_get("cvs_mail", "root@localhost"), 30, 55, "The e-mail address to mail the CVS log messages to.  Multiple recipients can be specified by putting a comma between each address.");
  $output .= form_select("Digest interval", "cvs_cron_time" , variable_get("cvs_cron_time", 86400), $period, "The time interval at which batched CVS digests are dispatched.  Requires crontab.");
Dries's avatar
 
Dries committed
34
  return $output;
Dries's avatar
 
Dries committed
35 36 37
}

function cvs_page() {
Dries's avatar
 
Dries committed
38
  global $theme;
Dries's avatar
 
Dries committed
39

Dries's avatar
 
Dries committed
40
  if (user_access("access cvs messages")) {
Dries's avatar
 
Dries committed
41
    $result = db_query("SELECT * FROM cvs ORDER BY timestamp DESC LIMIT 50");
Dries's avatar
 
Dries committed
42

Dries's avatar
 
Dries committed
43 44 45 46 47 48
    while ($cvs = db_fetch_object($result)) {
      $output .= "<b>File:</b> $cvs->files<br />";
      $output .= "<b>Date:</b> ". format_date($cvs->timestamp) ."<br />";
      $output .= "<b>User:</b> $cvs->user<br />";
      $output .= "\n". nl2br(htmlentities($cvs->message)) ."<hr />";
    }
Dries's avatar
 
Dries committed
49

Dries's avatar
 
Dries committed
50 51 52 53 54 55 56 57 58
    $theme->header();
    $theme->box("CVS commit messages", "<div style=\"font-family: monospace;\">$output</div>");
    $theme->footer();
  }
  else {
    $theme->header();
    $theme->box(t("Access denied"), message_access());
    $theme->footer();
  }
Dries's avatar
 
Dries committed
59
}
Dries's avatar
 
Dries committed
60

Dries's avatar
 
Dries committed
61
?>