Browse Source

Add TaskFloor Messages app

tags/1.0beta
Skylar Ittner 2 years ago
parent
commit
b561e14282
3 changed files with 56 additions and 1 deletions
  1. 2
    1
      .gitignore
  2. 53
    0
      apps/taskfloor_messages.php
  3. 1
    0
      pages.php

+ 2
- 1
.gitignore View File

@@ -2,4 +2,5 @@
/vendor
/database.mwb.bak
/nbproject/private
*.sync-conflict*
*.sync-conflict*
test*

+ 53
- 0
apps/taskfloor_messages.php View File

@@ -0,0 +1,53 @@
<?php

dieifnotloggedin();
addMultiLangStrings(["en_us" => [
"messages" => "Messages",
"no messages" => "No messages found."
]
]);
$APPS["taskfloor_messages"]["i18n"] = TRUE;
$APPS["taskfloor_messages"]["title"] = "messages";
$APPS["taskfloor_messages"]["icon"] = "comments";
try {
$client = new GuzzleHttp\Client();

$response = $client->request('POST', TASKFLOOR_API, ['form_params' => [
'action' => "getmsgs",
'username' => $_SESSION['username'],
'password' => $_SESSION['password'],
'max' => 5
]]);

$resp = json_decode($response->getBody(), TRUE);
if ($resp['status'] == "OK") {
if (count($resp['messages']) > 0) {
$content = '<div class="list-group">';
foreach ($resp['messages'] as $msg) {
$content .= '<div class="list-group-item">';
$content .= $msg['text'];
$fromuser = $msg['from']['username'];
$fromname = $msg['from']['name'];
$touser = $msg['to']['username'];
$toname = $msg['to']['name'];
$content .= <<<END
<br />
<span class="small">
<span data-toggle="tooltip" title="$fromuser">$fromname</span>
<i class="fa fa-caret-right"></i>
<span data-toggle="tooltip" title="$touser">$toname</span>
</span>
END;
$content .= '</div>';
}
$content .= "</div>";
} else {
$content = "<div class=\"alert alert-info\">" . lang("no messages", false) . "</div>";
}
}
} catch (Exception $e) {
$content = "<div class=\"alert alert-danger\">" . lang("error loading widget", false) . " " . $e->getMessage() . "</div>";
}
$content .= '<a href="' . TASKFLOOR_HOME . '" class="btn btn-primary btn-block">' . lang("open app", false) . ' &nbsp;<i class="fa fa-external-link-square"></i></a>';
$APPS["taskfloor_messages"]["content"] = $content;
?>

+ 1
- 0
pages.php View File

@@ -17,6 +17,7 @@ define("PAGES", [
define("APPS", [
"home" => [
"taskfloor_tasks",
"taskfloor_messages",
"sample_app"
],
"security" => [

Loading…
Cancel
Save