Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Add listing of contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitrisp2 committed Oct 18, 2018
1 parent 36d715d commit e9924ff
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/head.php
Expand Up @@ -42,6 +42,7 @@
<div class="navbar-nav">
<a class="nav-item nav-link active" href="index.php">Home</a>
<a class="nav-item nav-link" href="projects.php">Projects</a>
<a class="nav-item nav-link" href="contributions.php">Contributions</a>
<a class="nav-item nav-link" href="tasks.php">Tasks</a>
<a class="nav-item nav-link" href="users.php">Users</a>
<div class="btn-group">
Expand Down
30 changes: 30 additions & 0 deletions contributions.php
@@ -0,0 +1,30 @@
<?php
$page = "Contribution Posts";
include("functions.php");
if (isset($_GET['a'])) {
$action = $_GET['a'];
} else {
$action = "list";
}

if ($action == "list") {
$pagecontent = "<table class=\"table table-striped table-hover\"><thead><tr><th>Project</th><th>Translator</th><th>Submit</th><th>Review</th><th>Links</th><th>Utopian</th><th></th></tr></thead><tbody>";
$pagecontent .= GetContributionList();
} else {

}
include("common/head.php");
?>

<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<?php echo $pagecontent; ?>
</div>
</div>
</div>
<?php
include("common/foot.php");
?>


52 changes: 52 additions & 0 deletions functions.php
Expand Up @@ -172,6 +172,58 @@ function GetUserID($username) {
}
}

///////////////////
// CONTRIBUTIONS //
///////////////////

function GetContributionList($user = NULL, $project = NULL) {
// prepare SQL action if either or both $user and $project are set.
if ((!is_null($user)) || (!is_null($project))) {
$sqlaction = "WHERE ";
if (!is_null($user)) {
$sqlaction = $sqlaction . "`translator` = " . $user . " ";
} else if (!is_null($project)) {
$sqlaction = $sqlaction . "`project` = " . $project . " ";
}
} else {
$sqlaction = "";
}
$result = mysqli_query($GLOBALS['sqlcon'], "SELECT `c`.`id` AS `cid`, `c`.`translator` AS `tid`, `c`.`proofreader` AS `pid`, `c`.`link` AS `contrlink`, `c`.`submit` AS `submitdate`, `c`.`review` AS `reviewdate`, `c`.`vote-utopian` AS `vote-utopian`, `p`.`name` AS `projectname`, `p`.`crowdin` AS `crowdinlink`, `u1`.`username` AS `translator`, `u2`.`username` AS `proofreader` FROM `contributions` AS `c` LEFT JOIN `users` AS `u1` on `c`.`translator` = `u1`.`id` LEFT JOIN `users` AS `u2` on `c`.`proofreader` = `u2`.`id` LEFT JOIN `projects` AS `p` ON `c`.`project` = `p`.`id` ORDER BY `c`.`submit` DESC");

if ($result) {
// Initialise an empty variable to store the content
$contributionlist = "";
// Get all projects
while ($row = mysqli_fetch_assoc($result)) {
// fields:
// translator^v, proofreader^v, submitdate^v, reviewdate^v, vote-utopian^v
// projectname^v, crowdinlink^v, contrlink^v, cid
$translator = $row['translator'];
$submit = date("d/m/Y", strtotime($row['submitdate']));
$project = $row['projectname'];
$contributionlink = $row['contrlink'];
$crowdin = $row['crowdinlink'];
if ($row['reviewdate'] == NULL) {
$review = "Not yet";
} else {
$review = date("d/m/Y", strtotime($row['reviewdate'])) . " (".$row['proofreader'].")";
}

if ($row['vote-utopian'] == 0) {
$voteutopian = "Not Voted";
} else {
$voteutopian = "Voted";
}

// Add the project to the list
$contributionlist .= "<tr><td>".$project."</td><td>".$translator."</td><td>".$submit."</td><td>".$review."</td><td><a href=\"".$contributionlink."\" target=\"_blank\">Post</a> | <a href=\"".$crowdin."\" target=\"_blank\">CrowdIn</a></td><td>".$voteutopian."</td><td>(TBC)</td>";
}
return $contributionlist;
} else {
// Error running the query. Return error.
echo "unexpectederror";
}
}

///////////
// LOGIN //
Expand Down

0 comments on commit e9924ff

Please sign in to comment.