[opw-web] Add 'org_opinion' and UI to set
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [opw-web] Add 'org_opinion' and UI to set
- Date: Mon, 10 Mar 2014 04:32:48 +0000 (UTC)
commit c14773922da7224b8588863f8378d187c23c19be
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Mar 9 18:53:53 2014 -0400
Add 'org_opinion' and UI to set
lang/en-gb.php | 6 +++
modules/mod_rank_projects.php | 34 ++++++++++++-------
schema.sql | 7 ++++
skins/easterngreen/html/tpl_rank_projects.html | 4 +-
.../easterngreen/html/tpl_rank_projects_item.html | 2 +-
utils.php | 25 ++++++++++++++
6 files changed, 62 insertions(+), 16 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 49978ed..c7a3551 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -140,6 +140,12 @@ $lang_data = array(
'no_projects_for_organization' => 'No projects were found for this organization',
'applicant' => 'Applicant',
'rank' => 'Rank',
+ 'status' => 'Status',
+ 'opinion_n' => 'No contribution',
+ 'opinion_c' => 'Contribution, under review',
+ 'opinion_x' => 'Contribution, will not accept',
+ 'opinion_w' => 'Want to accept, need funding',
+ 'opinion_f' => 'Will accept, have funding',
/* Module: view_projects */
'submit_proposal' => 'Submit a proposal',
diff --git a/modules/mod_rank_projects.php b/modules/mod_rank_projects.php
index b1d8741..26c9c4b 100644
--- a/modules/mod_rank_projects.php
+++ b/modules/mod_rank_projects.php
@@ -70,10 +70,10 @@ if ($organization_id > 0) {
if ($rankings_save) {
foreach ($list_data as &$row) {
$project_id = $row['project_id'];
- $field_name = 'ranking' . $project_id;
+ $ranking_field_name = 'ranking' . $project_id;
- if (isset($_POST[$field_name])) {
- $value = trim($_POST[$field_name]);
+ if (isset($_POST[$ranking_field_name])) {
+ $value = trim($_POST[$ranking_field_name]);
if ($value === '')
$new_ranking = -1;
else
@@ -91,6 +91,19 @@ if ($rankings_save) {
$row['ranking'] = $new_ranking;
}
}
+
+ $opinion_field_name = 'opinion' . $project_id;
+ if (isset($_POST[$opinion_field_name])) {
+ $value = $_POST[$opinion_field_name];
+ if (opinion_is_valid($value)) {
+ $sql = "UPDATE {$db->prefix}projects " .
+ "SET org_opinion = :org_opinion " .
+ "WHERE id = :project_id";
+ $db->query($sql, array('org_opinion' => $value,
+ 'project_id' => $project_id));
+ $row['org_opinion'] = $value;
+ }
+ }
}
}
@@ -123,10 +136,11 @@ $return_url = urlencode($core->request_uri());
$projects_list = '';
-foreach ($list_data as $row)
+$a = 1;
+
+foreach ($list_data as &$row)
{
$project_title = htmlspecialchars($row['title']);
- $project_desc = htmlspecialchars($row['description']);
$username = $row['username'];
$profile = $user->profile($username);
@@ -136,12 +150,6 @@ foreach ($list_data as $row)
$project_title = trim(substr($project_title, 0, 60)) . '…';
}
- // Trim the description to 150 characters
- if (strlen($project_desc) > 150)
- {
- $project_desc = trim(substr($project_desc, 0, 150)) . '…';
- }
-
if ($row['ranking'] < 0)
$ranking = '';
else
@@ -150,10 +158,10 @@ foreach ($list_data as $row)
// Assign data for each project
$skin->assign(array(
'project_title' => $project_title,
- 'project_description' => nl2br($project_desc),
'project_applicant' => $profile,
'ranking' => $ranking,
- 'rankingName' => 'ranking' . $row['project_id'],
+ 'ranking_name' => 'ranking' . $row['project_id'],
+ 'opinion_select' => build_opinion_select($row['org_opinion'], 'opinion' . $row['project_id']),
'project_url' => "?q=view_projects&prg={$program_id}&p={$row['id']}",
'approve_url' => "?q=view_projects&a=approve&prg={$program_id}" .
"&p={$row['id']}&r={$return_url}",
diff --git a/schema.sql b/schema.sql
index 77c8a05..763865b 100644
--- a/schema.sql
+++ b/schema.sql
@@ -35,6 +35,13 @@ CREATE TABLE `opw_projects` (
`is_accepted` tinyint(1) NOT NULL DEFAULT -1,
`is_complete` tinyint(1) NOT NULL DEFAULT 0,
`ranking` float NOT NULL DEFAULT -1,
+ /* 'n' - No contribution
+ * 'c' - Contribution, under review
+ * 'x' - Contribution, will not accept
+ * 'w' - Want to accept, need funding
+ * 'f' - Will accept, have funding
+ */
+ `org_opinion` char(1) NOT NULL DEFAULT 'n',
PRIMARY KEY (`id`),
FOREIGN KEY (`program_id`) REFERENCES `opw_programs`(`id`),
FOREIGN KEY (`organization_id`) REFERENCES `opw_programs`(`id`)
diff --git a/skins/easterngreen/html/tpl_rank_projects.html b/skins/easterngreen/html/tpl_rank_projects.html
index 5b2ebb2..f1cb606 100644
--- a/skins/easterngreen/html/tpl_rank_projects.html
+++ b/skins/easterngreen/html/tpl_rank_projects.html
@@ -8,7 +8,7 @@
<div class="[[select_visibility]]">
[[organization_select]]
- <button onclick='go_organization(event);' class="btn">{{go}}</button>
+ <a onclick='go_organization(event);' href="#" class="btn">{{go}}</a>
<script type="text/javascript">
function go_organization(e) {
e.preventDefault();
@@ -40,7 +40,7 @@
</th>
<th>
- {{description}}
+ {{status}}
</th>
<th>
diff --git a/skins/easterngreen/html/tpl_rank_projects_item.html
b/skins/easterngreen/html/tpl_rank_projects_item.html
index b03c8cf..a4a51ab 100644
--- a/skins/easterngreen/html/tpl_rank_projects_item.html
+++ b/skins/easterngreen/html/tpl_rank_projects_item.html
@@ -10,7 +10,7 @@
</td>
<td>
- [[project_description]]
+ [[opinion_select]]
</td>
<td>
diff --git a/utils.php b/utils.php
index c1b48c6..0ddcb02 100644
--- a/utils.php
+++ b/utils.php
@@ -32,4 +32,29 @@ function build_organization_select($program_id, $current, $include_other, $name=
return $organization_select;
}
+
+$VALID_OPINIONS = array('n', 'c', 'x', 'w', 'f');
+
+function build_opinion_select($current, $name) {
+ global $VALID_OPINIONS, $lang;
+
+ $result = "<select name='{$name}'>";
+
+ foreach ($VALID_OPINIONS as $opinion) {
+ $selected = $opinion == $current ? ' selected' : '';
+ $name = $lang->get("opinion_" . $opinion);
+ $result .= "<option value='{$opinion}'{$selected}>{$name}</option>";
+ }
+
+ $result .= "</selected>";
+
+ return $result;
+}
+
+function opinion_is_valid($value) {
+ global $VALID_OPINIONS;
+
+ return in_array($value, $VALID_OPINIONS);
+}
+
?>
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]