redmine

Fixed autoclose script

... ... @@ -4,41 +4,64 @@ 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/Project.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);
function autoclose($user_id = null) {
global $redmine;
$redmine_user = $redmine;
if (!empty($user_id)) {
$user = $redmine->api('user')->show($user_id)['user'];
$redmine_user = new Redmine\Client('https://tasks.mephi.ru', $user['api_key']);
}
/* NRNU Auto-report */
$issues_search = array(
'status_id' => STATUSID_SOLVED,
'sort' => 'updated_on',
'limit' => 100000,
);
$answer = $redmine->api('issue')->all(array(
'status_id' => STATUSID_SOLVED,
'sort' => 'updated_on',
'limit' => 10000,
));
$answer = $redmine_user->api('issue')->all($issues_search);
if (!isset($answer['issues']))
exit(0);
if (!isset($answer['issues']))
return;
$curts = time();
$curts = time();
$toooldts = $curts - ISSUERESPONSE_TIMEOUT;
$toooldts = $curts - ISSUERESPONSE_TIMEOUT;
foreach ($answer['issues'] as &$issue) {
$updated_on = strtotime($issue['updated_on']);
foreach ($answer['issues'] as &$issue) {
$updated_on = strtotime($issue['updated_on']);
if ($updated_on < $toooldts) {
//print_r($issue);
$changes['status_id'] = STATUSID_CLOSED;
$changes['notes'] = "Задача переведена из статуса «Решена» в статус «Закрыта» в связи с отсутствием активности более двух недель.";
$redmine->api('issue')->update($issue['id'], $changes);
//print $issue['id']." ".print_r($changes, 1);
if ($updated_on < $toooldts) {
//print_r($issue);
$changes['status_id'] = STATUSID_CLOSED;
$changes['notes'] = "Задача переведена из статуса «Решена» в статус «Закрыта» в связи с отсутствием активности более двух недель.";
//print $issue['id']." ".print_r($changes, 1);
$redmine->api('issue')->update($issue['id'], $changes);
}
continue;
}
continue;
}
$redmine = new Redmine\Client('https://tasks.mephi.ru', REDMINE_API);
$answer = $redmine->api('user')->all(array('limit' => 1000));
autoclose(null);
foreach ($answer['users'] as $user) {
autoclose($user['id']);
}
?>
... ...
#!/bin/sh
cd /home/redmine-sched/redmine-scheduler > /dev/null
for file in daily-*.php; do
(
lockfile-check /run/redmine-schred-d-"$file".lock && exit 0
lockfile-create /run/redmine-schred-d-"$file".lock
php ./"$file"
lockfile-remove /run/redmine-schred-d-"$file".lock
) &
done
cd - > /dev/null
exit 0
... ...
#!/bin/sh
cd /home/redmine-sched/redmine-scheduler > /dev/null
for file in weekly-*.php; do
(
lockfile-check /run/redmine-schred-w-"$file".lock && exit 0
lockfile-create /run/redmine-schred-w-"$file".lock
php ./"$file"
lockfile-remove /run/redmine-schred-w-"$file".lock
) &
done
cd - > /dev/null
exit 0
... ...