redmine

Few changes:

* Adapted cron-mephi.php to http://rs.ut.mephi.ru/
* Disabled cron-hpc.php
* Added cron-itsupport.php
<?php
exit(0);
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/AbstractApi.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/SimpleXMLElement.php";
... ...
<?php
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/AbstractApi.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/SimpleXMLElement.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/IssueStatus.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/User.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/Issue.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Api/Attachment.php";
require_once "lib/3rdparty/php-redmine-api/lib/Redmine/Client.php";
require_once "config.php";
$redmine = new Redmine\Client('https://tasks.mephi.ru', REDMINE_API);
/* NRNU Auto-report */
$answer = $redmine->api('issue')->all(array(
'project_id' => '121', // project "it-support"
// 'status_id' => STATUSID_NEW,
));
if (!isset($answer['issues']))
exit(0);
foreach ($answer['issues'] as &$issue) {
if (!isset($issue['due_date'])) {
$changes = array();
$created_on = strtotime($issue['created_on']);
$changes['due_date'] = strftime('%Y-%m-%d', $created_on+(3600*24*3));
$redmine->api('issue')->update($issue['id'], $changes);
}
continue;
}
?>
... ...
... ... @@ -32,6 +32,8 @@ function tempdir($dir=FALSE, $prefix='php') {
$redmine = new Redmine\Client('https://redmine.ut.mephi.ru', REDMINE_API);
$configdb = new SQLite3("/var/www/rs.ut.mephi.ru/db/db");
/* NRNU Auto-report */
$answer = $redmine->api('issue')->all(array(
... ... @@ -45,7 +47,6 @@ if (!isset($answer['issues']))
$time = time();
foreach ($answer['issues'] as &$issue) {
if ($issue['status']['id'] == STATUSID_SOLVED) {
$redmine->api('issue')->addWatcher ($issue['id'], USERID_NVMALYH);
$redmine->api('issue')->addWatcher ($issue['id'], USERID_AATITOV);
... ... @@ -53,61 +54,35 @@ foreach ($answer['issues'] as &$issue) {
continue;
}
if (($issue['status']['id'] != STATUSID_NOTCONFIRMED) && ($issue['status']['id'] != STATUSID_NEW))
continue;
$timediff_c = $time-strtotime($issue['created_on']);
$timediff_u = $time-strtotime($issue['updated_on']);
$changes = array();
if ($timediff_c < 3600) {
$assigned_to_new = USERID_NVMALYH;
if ($issue['assigned_to']['id'] != $assigned_to_new) {
$issues_full = $redmine->api('issue')->show($issue['id'], array('include' => 'attachments'));
$issue_full = reset($issues_full);
$attachment_count = 0;
$dir = tempdir();
chdir($dir);
foreach ($issue_full['attachments'] as &$attachment_info) {
if ($attachment_info['filename'] == 'allfiles.zip') {
$attachment_count = 0;
break;
}
system('wget --no-check-certificate "'.str_replace('"', "'", $attachment_info['content_url']).'?key='.REDMINE_API.'" -O "'.$attachment_info['filename'].'"');
$attachment_count++;
$stages = $configdb->query('SELECT * FROM newsstages ORDER BY timeout');
$isInInterval = false;
while ($row = $stages->fetchArray()) {
if ($timediff_c < $row['timeout']) {
if ($row['assignee'] > 0) {
$assigned_to_new = $row['assignee'];
}
if ($attachment_count) {
@unlink('allfiles.zip');
system('zip allfiles.zip *');
$archive_content = file_get_contents('allfiles.zip');
$archive_upload = json_decode($redmine->api('attachment')->upload($archive_content));
print_r($archive_upload);
$attachment_info = array(
'token' => $archive_upload->upload->token,
'filename' => 'allfiles.zip',
'description' => 'An archive with all files',
'content_type' => 'application/zip',
);
$redmine->api('issue')->attach($issue['id'], $attachment_info);
if ($row['watcher'] > 0) {
$redmine->api('issue')->addWatcher ($issue['id'], $row['watcher']);
}
tempdir_cleanup($dir);
$isInInterval = true;
break;
}
}
elseif ($timediff_c < 7200)
$assigned_to_new = USERID_AATITOV;
elseif ($timediff_c < 10800) {
$assigned_to_new = USERID_NNROMANOV;
$redmine->api('issue')->addWatcher ($issue['id'], USERID_SVSOLOVYEV);
} else
if ($timediff_u < 3600)
if (!$isInInterval) {
if ($timediff_u > 3600)
$changes['notes'] = ((int)($timediff_c / 3600))." hours elapsed";
}
if ($issue['assigned_to']['id'] != $assigned_to_new)
if (!isset($issue['assigned_to']) || ($issue['assigned_to']['id'] != $assigned_to_new))
$changes['assigned_to_id'] = $assigned_to_new;
if (count($changes) > 0)
... ...