cards.php
9.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
// $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]/";
$key = 'a9960d785e22df5c053541adeb2aabc3';
$groupnm = '';
$groupid = '';
$userid = '';
$token = '';
if(isset($_GET['userid']) && $_GET['userid'] != '' && isset($_GET['groupid']) && $_GET['groupid'] != '' && isset($_GET['token']) && $_GET['token'] != '') {
$groupnm = $_GET['groupnm'];
$groupid = $_GET['groupid'];
$userid = $_GET['userid'];
$token = $_GET['token'];
$url_orgs = "https://api.trello.com/1/members/{$userid}?fields=username,fullName,url&boards=all&board_fields=name&organizations=all&organization_fields=displayName&&key=$key&token=$token";
$response = @file_get_contents($url_orgs, false, null);
if($response === FALSE) {
header("Location: $url");
die();
} else {
// header('Content-type: application/json');
// echo $response;
// die();
}
$response = json_decode($response);
} else {
header("Location: $url");
die();
}
// die();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Show only my trello cards">
<meta name="author" content="irul@20170411">
<link rel="icon" href="favicon.ico">
<title><?=ucwords($response->fullName);?>'s Task</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
body {
padding-bottom: 50px;
}
.affix {
top: 20px;
}
@media (min-width: 992px) {
.affix {
position: fixed;
width: inherit;
}
}
@media (max-width: 991px) {
.affix {
position: static;
}
}
small code {
padding: 0px !important;
}
</style>
</head>
<body>
<div class="container">
<div class="page-header">
<h1><a href="/"><?=ucwords($response->fullName);?>'s Task</a>
<small>Do an easy and affordable task first.</small>
</h1>
</div>
<h3><?=$groupnm;?> Cards: </h3>
<div class="row">
<div class="col-md-8">
<?php
$url_orgs = "https://api.trello.com/1/organizations/{$groupid}/members/{$userid}/cards?actions=createCard,commentCard&fields=id,name,desc,dateLastActivity,shortUrl&board=true&board_fields=id,name&list=true&list_fields=id,name&key=$key&token=$token";
$response = file_get_contents($url_orgs, false, null);
$cinfo = array();
$cards = json_decode($response);
echo '<ol>';
foreach ($cards as $card) {
echo '<li data-list="', $card->list->id, '" data-board="', $card->board->id,
'" list-name="', strtoupper(str_replace(' ', '', $card->list->name)), '">';
echo '<h4><a href="', $card->shortUrl, '" target="_blank">', $card->name, '</a><br>',
//(trim($card->desc) != '' ? '<small>' . nl2br($card->desc) . '</small>' : ''), '</h4>';
(trim($card->desc) != '' ? '<small><code>' . nl2br(str_replace('`', '', $card->desc)) . '</code></small>' : ''), '</h4>';
echo '<span class="label label-default">',
'<a name="boards" id="', $card->board->id ,'"href="#" style="color: #fff;">', strtoupper($card->board->name), '</a></span> ';
echo '<span class="label ' .
(strtoupper(str_replace(' ', '', $card->list->name)) == 'TODO' ? 'label-danger' :
(strtoupper(str_replace(' ', '', $card->list->name)) == 'DOING' ? 'label-warning' :
(strtoupper(str_replace(' ', '', $card->list->name)) == 'STAGING' ? 'label-primary' :
(strtoupper(str_replace(' ', '', $card->list->name)) == 'CHECKING' ? 'label-info' : 'label-success')))) . '">',
'<a name="lists" id="', strtoupper(str_replace(' ', '', $card->list->name)) ,'"href="#" style="color: #fff;">',
strtoupper(str_replace(' ', '', $card->list->name)), '</a></span> ';
//echo '<span class="label label-default">', date('Y-m-d', strtotime($card->dateLastActivity)), '</span> ';
$comments = array();
$comments = $card->actions;
if (count($comments)) {
echo '<br>';
foreach ($comments as $comment) {
echo '<small><strong><span class="text-danger"># <span class="text-muted">'.date('Y-m-d H:i:s', strtotime($comment->date)).
'</span> <span class="text-uppercase">'. $comment->memberCreator->fullName.'</span> : </span>'.
'</strong> '. ($comment->data->text ? $comment->data->text : 'Create task.') .'</small><br>';
}
}
echo '</li>';
$info = array(
'list' => $card->list,
'board' => $card->board,
);
$cinfo[] = $info;
}
echo '</ol>';
?>
</div>
<div class="col-md-4">
<blockquote class="blockquote" data-spy="affix" data-offset-top="200">
<!--a href="/" class="btn btn-sm btn-default" style="margin-bottom: 2px;">HOME</a-->
<button class="btn btn-sm btn-default" style="margin-bottom: 2px;" id="btn_reset">
ALL CARDS <span class="badge">RESET</span>
</button>
<!--br><br-->
<div data-toggle="buttons">
<?php
$cinfo = array_map("unserialize", array_unique(array_map("serialize", $cinfo)));
// $cinfo = array_unique($cinfo);
// sorting
array_multisort(array_map(function($elements) {
return $elements['board']->name;
}, $cinfo), SORT_ASC, $cinfo);
foreach ($cinfo as $info) {
$list = $info['list'];
$board = $info['board'];
echo '<label class="btn btn-sm ',
(strtoupper(str_replace(' ', '', $list->name)) == 'TODO' ? 'btn-danger' :
(strtoupper(str_replace(' ', '', $list->name)) == 'DOING' ? 'btn-warning' :
(strtoupper(str_replace(' ', '', $list->name)) == 'STAGING' ? 'btn-primary' :
(strtoupper(str_replace(' ', '', $list->name)) == 'CHECKING' ? 'btn-info' : 'btn-success')))),
'" style="margin-bottom: 2px;">';
echo '<input type="radio" name="options" id="', $list->id, '">',strtoupper($board->name),
' <span class="badge">', strtoupper(str_replace(' ', '', $list->name)), '</span> ',
'</input>';
echo '</label><br>';
}
?>
</div>
</blockquote>
</div>
</div>
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script>
function uncheck_radio() {
$("input:radio").closest("label").removeClass("active");
$("input:radio").prop('checked', false);
}
$("#btn_reset").click(function() {
uncheck_radio();
$("li").each(function(i, obj) {
$(this).removeClass('hide');
});
});
$("input[name='options']").on('change', function () {
$("li").each(function(i, obj) {
$(this).addClass('hide');
});
var list_id = $(this).attr('id');
$("li[data-list='"+list_id+"'").each(function(i, obj) {
$(this).removeClass('hide');
});
});
$("a[name='boards']").on('click', function (event) {
uncheck_radio();
event.preventDefault();
$("li").each(function(i, obj) {
$(this).addClass('hide');
});
var board_id = $(this).attr('id');
$("li[data-board='"+board_id+"'").each(function(i, obj) {
$(this).removeClass('hide');
});
});
$("a[name='lists']").on('click', function (event) {
uncheck_radio();
event.preventDefault();
$("li").each(function(i, obj) {
$(this).addClass('hide');
});
var list_name = $(this).attr('id');
$("li[list-name='"+list_name+"'").each(function(i, obj) {
$(this).removeClass('hide');
});
});
</script>
</body>
</html>