Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
ut-tex
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2016-04-04 10:31:25 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fa331b313a5c253bf05bc3b89d1448e79cd0ce1b
fa331b31
1 parent
a7e0814e
decide-note.php bugfizes
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
genpdf/decide-note.php
genpdf/lib/3dparty/Inflect
genpdf/decide-note.php
View file @
fa331b3
...
...
@@ -57,6 +57,21 @@ $assignedTo = $redmine_admin->api('user' )->show($issue['assigned_to']['id'])
$api_key
=
$assignedTo
[
'user'
][
'api_key'
];
$redmine
=
new
Redmine\Client
(
'https://redmine.ut.mephi.ru'
,
$api_key
);
function
addUserToProject
(
&
$redmine
,
$user_id
,
$project_id
)
{
$current_membership
=
$redmine
->
api
(
'membership'
)
->
all
(
$project_id
);
foreach
(
$current_membership
[
'memberships'
]
as
$global_key
=>
$member
){
if
(
$member
[
'user'
][
'id'
]
==
$user_id
){
$cur_roles
=
array
();
$membership_id
=
$current_membership
[
'memberships'
][
$global_key
][
'id'
];
foreach
(
$current_membership
[
'memberships'
][
$global_key
][
'roles'
]
as
$role
)
{
$cur_roles
[]
=
$role
[
'id'
];
}
return
$redmine
->
api
(
'membership'
)
->
update
(
$membership_id
,
array
(
'role_ids'
=>
array_merge
(
$cur_roles
,
array
(
ROLE_CUSTOMER
))));
}
}
return
$redmine
->
api
(
'membership'
)
->
create
(
$project_id
,
array
(
'user_id'
=>
$user_id
,
'role_ids'
=>
array
(
ROLE_CUSTOMER
)));
}
switch
(
$_GET
[
'action'
])
{
case
'agree'
:
header
(
'Content-Type: text/plain'
);
...
...
@@ -70,28 +85,41 @@ switch ($_GET['action']) {
}
if
(
is_null
(
$recipientId
))
{
die
(
'Cannot find recipient custom field in issue: '
.
$_GET
[
'issueId'
]);
mail
(
'admin@ut.mephi.ru'
,
'Got error on decide-note.php'
,
print_r
(
$_GET
,
1
));
die
(
'Произошла ошибка. Пожалуйста, повторите попытку позже. Cannot find recipient custom field in issue: '
.
$_GET
[
'issueId'
]);
}
$recipient
=
$redmine_admin
->
api
(
'user'
)
->
show
(
$recipientId
)[
'user'
];
if
(
empty
(
$recipient
[
'mail'
]))
{
die
(
'Cannot find login of user with ID: '
.
$recipientId
);
mail
(
'admin@ut.mephi.ru'
,
'Got error on decide-note.php'
,
print_r
(
$_GET
,
1
));
die
(
'Произошла ошибка. Пожалуйста, повторите попытку позже. Cannot find login of user with ID: '
.
$recipientId
);
}
//print_r($issue);die();
/*$result = addUserToProject($redmine, $recipientId, $issue['project']['id']);
if ($result !== TRUE) {
mail('admin@ut.mephi.ru', 'Got error on decide-note.php', print_r($_GET, 1));
die('Произошла ошибка. Пожалуйста, повторите попытку позже. Cannot add user '.$recipientId.' to project '.$issue['project']['id'].': '.print_r($result, 1));
}*/
//print @json_encode($redmine->api('issue')->update($issue['id'], array('status_id' => STATUSID_NEW, 'project_id' => redmine_proj_identifier2id(strtolower(explode('@', $recipient['mail'])[0])), 'assigned_to_id' => $recipient['id'])));
$result
=
$redmine
->
api
(
'issue'
)
->
update
(
$issue
[
'id'
],
array
(
'status_id'
=>
STATUSID_NEW
,
'project_id'
=>
redmine_proj_identifier2id
(
strtolower
(
explode
(
'@'
,
$recipient
[
'mail'
])[
0
])),
'assigned_to_id'
=>
$recipient
[
'id'
]));
if
(
$result
==
true
)
{
header
(
'Location: https://tasks.mephi.ru/issues/'
.
$_GET
[
'issueId'
]);
if
(
$result
!==
TRUE
)
{
mail
(
'admin@ut.mephi.ru'
,
'Got error on decide-note.php'
,
print_r
(
$_GET
,
1
));
die
(
'Произошла ошибка. Пожалуйста, повторите попытку позже. Cannot update the issue '
.
$issue
[
'project'
][
'id'
]
.
': '
.
print_r
(
$result
,
1
));
}
header
(
'Location: https://tasks.mephi.ru/issues/'
.
$_GET
[
'issueId'
]);
break
;
case
'decline'
:
header
(
'Content-Type: text/plain'
);
//print @json_encode($redmine->api('issue')->update($_GET['issueId'], array('status_id' => STATUSID_DECLINED)));
$result
=
$redmine
->
api
(
'issue'
)
->
update
(
$_GET
[
'issueId'
],
array
(
'status_id'
=>
STATUSID_DECLINED
));
if
(
$result
==
true
)
{
header
(
'Location: https://tasks.mephi.ru/issues/'
.
$_GET
[
'issueId'
]);
if
(
$result
!==
TRUE
)
{
mail
(
'admin@ut.mephi.ru'
,
'Got error on decide-note.php'
,
print_r
(
$_GET
,
1
));
die
(
'Произошла ошибка. Пожалуйста, повторите попытку позже. Cannot decline the issue '
.
$issue
[
'project'
][
'id'
]
.
': '
.
print_r
(
$result
,
1
));
}
header
(
'Location: https://tasks.mephi.ru/issues/'
.
$_GET
[
'issueId'
]);
break
;
default
:
die
(
'Unknown action: '
.
$_GET
[
'action'
]);
...
...
Inflect
@
a60c8e42
Subproject commit
754ec13a3789333e9c0a2f858116d0aec7edd238
Subproject commit
a60c8e42622081bce1e8a04c0d18eef53791418b
...
...
Please
register
or
login
to post a comment