Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
2d5f1eca
Commit
2d5f1eca
authored
Mar 10, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redmine
parent
dd34ca79
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
37 deletions
+124
-37
common/modules/support/controllers/SupportController.php
common/modules/support/controllers/SupportController.php
+15
-26
common/modules/support/models/redmine/IssueHelper.php
common/modules/support/models/redmine/IssueHelper.php
+51
-0
common/modules/support/views/support/_loop.php
common/modules/support/views/support/_loop.php
+2
-2
common/modules/support/views/support/index.php
common/modules/support/views/support/index.php
+18
-8
console/migrations/m160304_091243_fix_user_table.php
console/migrations/m160304_091243_fix_user_table.php
+1
-1
console/migrations/m160310_063328_fix_support.php
console/migrations/m160310_063328_fix_support.php
+37
-0
No files found.
common/modules/support/controllers/SupportController.php
View file @
2d5f1eca
...
...
@@ -4,6 +4,7 @@ namespace common\modules\support\controllers;
use
Yii
;
use
yii\filters\AccessControl
;
use
yii\helpers\ArrayHelper
;
use
yii\web\Controller
;
use
yii\web\NotFoundHttpException
;
...
...
@@ -47,18 +48,16 @@ class SupportController extends Controller
public
function
actionIndex
()
{
$client
=
new
\Redmine\Client
(
'http://help-russia.ru'
,
Yii
::
$app
->
support
->
identity
->
redmine_key
);
$client
=
$this
->
getClient
(
);
$works
=
$client
->
issue
->
all
([
'author_id'
=>
23
$user
=
$client
->
user
->
getCurrentUser
();
$models
=
$client
->
issue
->
all
([
'author_id'
=>
$user
[
'user'
][
'id'
],
]);
return
$this
->
render
(
'index'
,
[
'works'
=>
$works
,
// 'ratings' => $ratings,
// 'tests' => $tests,
// 'approves' => $approves,
// 'accepteds' => $accepteds,
'models'
=>
$models
,
]);
}
...
...
@@ -77,9 +76,13 @@ class SupportController extends Controller
public
function
actionView
(
$id
)
{
$model
=
$this
->
findModel
(
$id
);
$client
=
$this
->
getClient
();
$user
=
$client
->
user
->
getCurrentUser
();
if
(
$model
->
author_id
!=
Yii
::
$app
->
support
->
identity
->
support_id
)
$model
=
$client
->
issue
->
show
(
$id
);
if
(
empty
(
$model
[
'issue'
])
||
$model
[
'issue'
][
'author'
][
'id'
]
!=
$user
[
'user'
][
'id'
])
{
throw
new
NotFoundHttpException
(
'Доступ запрещен!'
);
}
...
...
@@ -89,22 +92,8 @@ class SupportController extends Controller
]);
}
/**
* Finds the Post model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Post the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected
function
findModel
(
$id
)
protected
function
getClient
()
{
if
((
$model
=
Issue
::
findOne
(
$id
))
!==
null
)
{
return
$model
;
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
return
$client
=
new
\Redmine\Client
(
Settings
::
getValue
(
'redmine-url'
),
Yii
::
$app
->
support
->
identity
->
redmine_key
);
}
}
common/modules/support/models/redmine/IssueHelper.php
0 → 100644
View file @
2d5f1eca
<?php
namespace
common\modules\support\models\redmine
;
use
common\models\Settings
;
class
IssueHelper
{
public
static
function
sort
(
$issues
)
{
$settings
=
[
[
'statuses'
=>
explode
(
','
,
Settings
::
getValue
(
'support-status-work'
)),
'title'
=>
'Задачи в работе'
,
],
[
'statuses'
=>
explode
(
','
,
Settings
::
getValue
(
'support-status-new'
)),
'title'
=>
'Задачи на оценке'
,
],
[
'statuses'
=>
explode
(
','
,
Settings
::
getValue
(
'support-status-test'
)),
'title'
=>
'Задачи на тестировании'
,
],
[
'statuses'
=>
explode
(
','
,
Settings
::
getValue
(
'support-status-approve'
)),
'title'
=>
'Задачи ожидающие проверки'
,
],
[
'statuses'
=>
explode
(
','
,
Settings
::
getValue
(
'support-status-accepted'
)),
'title'
=>
'Закрытые задачи'
,
'close'
=>
true
],
];
foreach
(
$issues
as
$issue
)
{
foreach
(
$settings
as
&
$setting
)
{
if
(
in_array
(
$issue
[
'status'
][
'id'
],
$setting
[
'statuses'
]))
{
$setting
[
'models'
][]
=
$issue
;
}
}
}
unset
(
$setting
);
return
$settings
;
}
}
\ No newline at end of file
common/modules/support/views/support/_loop.php
View file @
2d5f1eca
...
...
@@ -4,7 +4,7 @@ use yii\helpers\Html;
?>
<?php
if
(
$output
[
'issues'
]
)
:
?>
<?php
if
(
$output
)
:
?>
<div
class=
"panel-group panel-group-2"
id=
"accordion_2"
>
<div
class=
"panel panel-default"
>
...
...
@@ -35,7 +35,7 @@ use yii\helpers\Html;
</div>
<div
id=
"collapse_1"
class=
"panel-collapse collapse in"
>
<?php
foreach
(
$output
[
'issues'
]
as
$model
)
:
?>
<?php
foreach
(
$output
as
$model
)
:
?>
<div
class=
"panel-body panel-body-ex-1 color_on_cursor gray_box_2"
>
<table
class=
"w100pr"
>
<tbody>
...
...
common/modules/support/views/support/index.php
View file @
2d5f1eca
...
...
@@ -4,6 +4,8 @@ use yii\helpers\Html;
use
yii\grid\GridView
;
use
yii\widgets\ActiveForm
;
use
common\modules\support\models\redmine\IssueHelper
;
?>
<div
class=
"client_interface"
>
...
...
@@ -61,13 +63,21 @@ use yii\widgets\ActiveForm;
<tr>
<td
class=
"no_pad"
>
<?=
$this
->
render
(
'_loop'
,
[
'output'
=>
$ratings
,
'title'
=>
'Задачи на оценке'
]);
?>
<?=
$this
->
render
(
'_loop'
,
[
'output'
=>
$works
,
'title'
=>
'Задачи в работе'
]);
?>
<?=
$this
->
render
(
'_loop'
,
[
'output'
=>
$tests
,
'title'
=>
'Задачи на тестировании'
]);
?>
<?=
$this
->
render
(
'_loop'
,
[
'output'
=>
$approves
,
'title'
=>
'Задачи ожидающие проверки'
]);
?>
<?php
$issues
=
IssueHelper
::
sort
(
$models
[
'issues'
]);
foreach
(
$issues
as
$issue
)
{
if
(
!
isset
(
$issue
[
'close'
]))
{
echo
$this
->
render
(
'_loop'
,
[
'output'
=>
$issue
[
'models'
],
'title'
=>
$issue
[
'title'
]]);
}
else
{
$accepteds
=
$issue
[
'models'
];
}
}
?>
</td>
</tr>
...
...
@@ -87,7 +97,7 @@ use yii\widgets\ActiveForm;
<input
type=
"checkbox"
>
</label>
<div
class=
"text-mes"
>
<p>
<?=
$model
->
subject
?>
</p>
<p>
<?=
$model
[
'subject'
]
?>
</p>
</div>
</div>
...
...
console/migrations/m160304_091243_fix_user_table.php
View file @
2d5f1eca
...
...
@@ -14,7 +14,7 @@ class m160304_091243_fix_user_table extends Migration
public
function
safeDown
()
{
$this
->
rename
Table
(
'users'
,
'redmine_key'
,
'support_id'
);
$this
->
rename
Column
(
'users'
,
'redmine_key'
,
'support_id'
);
$this
->
renameColumn
(
'users'
,
'support_id'
,
Schema
::
TYPE_INTEGER
.
'(11) DEFAULT NULL'
);
}
}
console/migrations/m160310_063328_fix_support.php
0 → 100644
View file @
2d5f1eca
<?php
use
yii\db\Schema
;
use
yii\db\Migration
;
class
m160310_063328_fix_support
extends
Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public
function
safeUp
()
{
$this
->
insert
(
'settings'
,
[
'module_id'
=>
'support'
,
'code'
=>
'redmine-key'
,
'name'
=>
'Redmine Api Key'
,
'value'
=>
'bac5a4f334595be4ce4962e6428035041f47f569'
,
'element'
=>
'text'
,
'hidden'
=>
0
,
'description'
=>
'Redmine Api Key'
,
]);
$this
->
insert
(
'settings'
,
[
'module_id'
=>
'support'
,
'code'
=>
'redmine-url'
,
'name'
=>
'Redmine Url'
,
'value'
=>
'http://help-russia.ru'
,
'element'
=>
'text'
,
'hidden'
=>
0
,
'description'
=>
'Redmine Url'
,
]);
}
public
function
safeDown
()
{
$this
->
delete
(
'settings'
,
[
'code'
=>
'redmine-key'
]);
$this
->
delete
(
'settings'
,
[
'code'
=>
'redmine-url'
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment