redmine

Completed news requests handler

config.php
... ...
<?php
define('REDMINE_LOGIN', 'redmine-scheduler');
define('REDMINE_PASSWORD', 'VerySecretPassword');
?>
... ...
<?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://redmine.ut.mephi.ru', REDMINE_LOGIN, REDMINE_PASSWORD);
/* NRNU Auto-report */
$answer = $redmine->api('issue')->all(array(
'project_id' => '96', // project "news"
'status_id' => 'open', // only opened task
));
if (!isset($answer['issues']))
exit(0);
$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);
$redmine->api('issue')->update ($issue['id'], array('status_id' => STATUSID_CLOSED));
continue;
}
$timediff = $time-strtotime($issue['created_on']);
if ($timediff < 3600)
$assigned_to_new = USERID_NVMALYH;
elseif ($timediff < 7200)
$assigned_to_new = USERID_AATITOV;
else
$assigned_to_new = USERID_NNROMANOV;
if ($issue['assigned_to']['id'] != $assigned_to_new)
$redmine->api('issue')->update($issue['id'], array('assigned_to_id' => $assigned_to_new));
}
?>
... ...
<?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/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";
?>
#!/bin/sh
for file in cron-*.php; do
php ./"$file"
done
exit 0
... ...
php-redmine-api @ 5c60d96b
Subproject commit 50d0bb57421e3e416cdfcdd0a3dcf657995ad542
Subproject commit 5c60d96bd87ec55844a2d75bc729e788671781e4
... ...