redmine

case Custom - latinspecialchars_latex issue

... ... @@ -7,11 +7,11 @@ if ($s === FALSE || (@$s[9]+3600*24) < time()) {
$apiKey = trim(file_get_contents('/etc/apikey-voip'));
$subscribers = json_decode(file_get_contents('http://new.voip.mephi.ru/subscribers.json?limit=65535&renderFilter=subscribers&apiKey='.urlencode($apiKey)), 1)['subscribers'];
foreach ($subscribers as &$subscriber) {
if (empty($subscriber['Login']['String']))
if (empty($subscriber['Login']))
continue;
foreach ($subscriber['Appointments'] as &$_a)
$stfcardid2login[$_a['StfCardId']] = $subscriber['Login']['String'];
$stfcardid2login[$_a['StfCardId']] = $subscriber['Login'];
}
if (count($stfcardid2login) > 1000) {
... ...
... ... @@ -60,31 +60,32 @@ $redmine = new Redmine\Client('https://redmine.ut.mephi.ru', $api_key);
function addUserToProject(&$redmine, $user_id, $project_id, $role_id) {
error_log("addUserToProject(redmine, $user_id, $project_id, $role_id)");
$current_membership = $redmine->api('membership')->all($project_id);
$current_membership = $redmine->api('membership')->all($project_id, array('limit' => '1000'));
//mail('dyokunev@ut.mephi.ru', 'memberships', print_r($current_membership['memberships'], 1));
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) {
if ($role['id'] == $role_id) {
//print "already there!\n";
error_log("already there!");
return true;
}
$cur_roles[] = $role['id'];
}
$role_ids = array('role_ids' => array_merge($cur_roles, array($role_id)));
//print "updating\n";
error_log("updating");
//print_r($role_ids);
return $redmine->api('membership')->update($membership_id, $role_ids);
}
}
//print "creating\n";
error_log("creating");
return $redmine->api('membership')->create($project_id, array('user_id' => $user_id, 'role_ids' => array($role_id)));
}
function removeUserFromProject(&$redmine, $user_id, $project_id, $role_id) {
error_log("removeUserFromProject(redmine, $user_id, $project_id, $role_id)");
$current_membership = $redmine->api('membership')->all($project_id);
$current_membership = $redmine->api('membership')->all($project_id, array('limit' => '1000'));
foreach ($current_membership['memberships'] as $global_key => $member){
if ($member['user']['id'] == $user_id){
$role_ids=array();
... ... @@ -117,7 +118,7 @@ switch ($_GET['action']) {
header('Content-Type: text/html');
mail('admin@ut.mephi.ru', 'Already confirmed in decide-note.php', print_r($_GET, 1));
//die('Произошла ошибка. Пожалуйста, повторите попытку позже. Cannot find recipient custom field in issue: '.$_GET['issueId']);
?><html><head><title>Служебная записка уже подтверждена</title><meta charset="UTF-8"><meta http-equiv="refresh" content="5; https://tasks.mephi.ru/issues/<?=$_GET['issueId']?>" /></head><body><h1>Служебная записка <a href='https://tasks.mephi.ru/issues/<?=$_GET['issueId']?>'>#<?=$_GET['issueId']?></a> уже подтверждена. Через 5 секунд будет произведено перенаправление в систему «Задачи».</h1></body></html><?php
?><html><head><title>Служебная записка уже подтверждена</title><meta charset="UTF-8"><meta http-equiv="refresh" content="2; https://tasks.mephi.ru/issues/<?=$_GET['issueId']?>" /></head><body><h1>Служебная записка <a href='https://tasks.mephi.ru/issues/<?=$_GET['issueId']?>'>#<?=$_GET['issueId']?></a> уже подтверждена.</h1></body></html><?php
exit(0);
}
... ... @@ -133,6 +134,7 @@ switch ($_GET['action']) {
$project_id = redmine_proj_identifier2id(strtolower(explode('@', $recipient['mail'])[0]));
addUserToProject($redmine_admin, $assignedTo['id'], $project_id, ROLE_CUSTOMER);
addUserToProject($redmine_admin, $assignedTo['id'], 15971, ROLE_MOVER);
addUserToProject($redmine_admin, $assignedTo['id'], $project_id, ROLE_MOVER);
/*$result =*/
/*if ($result !== TRUE) {
... ... @@ -143,13 +145,20 @@ switch ($_GET['action']) {
//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'])));
$issue_props = array(
'project_id' => $project_id,
'assigned_to_id' => $recipient['id']
//'project_id' => $project_id,
'assigned_to_id' => $recipient['id'],
'tracker_id' => TRACKERID_TASK,
);
if ($_GET['action'] == 'agree')
$issue_props['status_id'] = STATUSID_NEW;
//print_r($issue_props);die();
$result = $redmine->api('issue')->update($issue['id'], $issue_props);
$issue_props = array(
'project_id' => $project_id,
'notes' => "h1. Подтверждаю служебную записку.\n@ @\n@ @",
);
$result = $redmine->api('issue')->update($issue['id'], $issue_props);
removeUserFromProject($redmine_admin, $assignedTo['id'], $project_id, ROLE_MOVER);
... ...
... ... @@ -13,6 +13,15 @@ require_once "lib/3rdparty/Inflect/Inflect.php";
require_once "config.php";
// Anti-repeater:
$request_hash = sha1(serialize($_GET).serialize($_POST));
foreach(split("\n", file_get_contents("/tmp/gethashes")) as $request_hash_already) {
if ($request_hash == $request_hash_already) {
//die('Такой запрос уже был сгенерирован сегодня');
}
}
file_put_contents("/tmp/gethashes", $GEThash."\n", FILE_APPEND|LOCK_EX);
/*
$user_redmine
... ... @@ -255,6 +264,10 @@ foreach (array('contact', 'user', 'recipient') as $key) {
if (empty($_GET[$key.'-appointment-id']))
continue;
if ($key == 'user' && !empty($_GET['user-fullname'])) {
continue;
}
$w_id = $_GET[$key.'-appointment-id'];
$appointment = json_decode(file_get_contents("https://cps.mephi.ru/?cmd=getworkpositioninfo&w_id=".urlencode($w_id) ));
... ... @@ -262,7 +275,7 @@ foreach (array('contact', 'user', 'recipient') as $key) {
considerAppointment($key, $appointment);
}
//print_r($redmine);print_r($_GET);die();
//if (!empty($_COOKIE['debug'])) { print_r($redmine);print_r($_GET);die(); }
$dont_inflect_patterns = array(
'/^нач\./',
... ... @@ -677,9 +690,10 @@ $issue_id = NULL;
$files = split(',', $_GET['file']);
$pdfs = array();
//if (!empty($_COOKIE['debug'])) { print_r($files);die(); }
$replacement_is_already_done = false;
foreach ($files as $file) {
$split_appointments = false;
// $replacement_is_already_done = false;
$file_eff = $file;
switch ($file) {
... ... @@ -778,13 +792,12 @@ foreach ($files as $file) {
if (isset($_GET['resourse-sshrequired'])) {
$project_id = 102;
$custom_fields_keys = array (4 => 'signer-subdivs', 85=> 'domainnames');
$_GET['domainnames']=$_GET['resourse-domain'];
// print_r($_GET['resourse-domain']);die('.uck');
//$_GET['signer-subdivs']=NULL
;
//print_r($_GET['resourse-domain']);die('.uck');
//$_GET['signer-subdivs']=NULL;
}
break;
... ... @@ -836,7 +849,7 @@ foreach ($files as $file) {
if (!is_null($me)) {
// $membership = $redmine_admin->api('user')->show($me['id'], array('include' => array('memberships',)));
$current_membership = $redmine_admin->api('membership')->all($project_id);
$current_membership = $redmine_admin->api('membership')->all($project_id, array('limit' => '1000'));
... ... @@ -1137,6 +1150,10 @@ foreach ($files as $file) {
'subject' => $memo_subject,
'description' => $text,
);
if ($project_id == 102) {
$issue_props['assigned_to_id'] = USERID_AMGLADTSIN;
}
//if ($project_id == 102) {print_r($issue_props);die();}
break;
case 'request/nix-hosting':
$issue_props =
... ... @@ -1188,18 +1205,26 @@ foreach ($files as $file) {
case 'request/custom':
$issue_props = array();
if ($_GET['user-appointment-id'] != $_GET['signer-appointment-id']) {
$assigned_to_id = redmine_login2id($_GET['user-login']);
$issue_props =
array(
'tracker_id' => TRACKERID_NOTE,
);
} else {
$assigned_to_id = redmine_login2id($_GET['recepient-login']);
}
$issue_props =
array(
'assigned_to_id' => $assigned_to_id,
'project_id' => $project_id,
'subject' => 'Служебная записка '.$_GET['to-recipient-name'].' от '.$_GET['of-user-name'].', '.date(" Y.m.d, H:i:s"),
'description' => "<pre>".$text."</pre>",
array_merge(
$issue_props,
array(
'assigned_to_id' => $assigned_to_id,
'project_id' => $project_id,
'subject' => 'Служебная записка '.$_GET['to-recipient-name'].' от '.$_GET['of-user-name'].', '.date(" Y.m.d, H:i:s"),
'description' => "<pre>".$text."</pre>",
)
);
break;
... ... @@ -1289,9 +1314,9 @@ foreach ($files as $file) {
{\small
\begin{tabular}{ r l }
\multicolumn{2}{ l }{ Подготовлено: } \\\\
ФИО: & '.$_GET['signer-name'].' \\\\
Тел.: & '.$_GET['signer-phonenumber'].' \\\\
Email: & '.$_GET['signer-email'].' \\\\
ФИО: & '.latexSpecialChars1($_GET['signer-name']).' \\\\
Тел.: & '.latexSpecialChars1($_GET['signer-phonenumber']).' \\\\
Email: & '.latexSpecialChars1($_GET['signer-email']).' \\\\
\end{tabular}
}
\end{flushleft}';
... ... @@ -1313,7 +1338,7 @@ foreach ($files as $file) {
case 'request/cps':
case 'request/voip3':
case 'request/voip-softphone':
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_NNROMANOV);
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_AMGLADTSIN);
$redmine_admin->api('issue')->addWatcher($issue_id, USERID_DYOKUNEV);
break;
case 'request/lanmodern':
... ... @@ -1388,4 +1413,6 @@ if ($count > 1) {
exit(0);
}
//if (!empty($_COOKIE['debug'])) { die(); }
?>
... ...
Прошу [{problem-description}] [{contact-place}] [{contact-phonenumber}]
... ...
... ... @@ -21,10 +21,10 @@
\textbf{Администратор веб-ресурса}
\\
\begin{tabular}{ l l }
ФИО полностью & [{user-fullname}] \\
Должность & [{user-appointment}] \\
Контактный тел. (ip или моб.) & [{user-phonenumber}] \\
Эл. почта (@mephi.ru) & [{user-email}] \\
ФИО полностью & [{admin-fullname}] \\
Должность & [{admin-appointment}] \\
Контактный тел. (ip или моб.) & [{admin-phonenumber}] \\
Эл. почта (@mephi.ru) & [{admin-email}] \\
\end{tabular}
\\
\\
... ...