From d94acf598ef4f4e5688ab90008af42ced4099b72 Mon Sep 17 00:00:00 2001 From: Daniel Silva <daniel.silva@flipside.org> Date: Thu, 12 Jun 2014 12:42:16 +0100 Subject: [PATCH 1/6] Fix #129. Wrong labels when exporting. Missing machine_label key from select questions --- application/controllers/survey.php | 10 +++++++--- application/helpers/or_xform_results_helper.php | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/application/controllers/survey.php b/application/controllers/survey.php index 337a23d..c90bab8 100644 --- a/application/controllers/survey.php +++ b/application/controllers/survey.php @@ -1251,10 +1251,14 @@ public function survey_export_csv($sid, $type) { $flat = $flattener->get_flatten(); $header = array(); foreach ($flat as $key => $value) { - if ($flattener->is_translated()) { - $header[] = $value[$label_key][$flattener->get_preferred_language()]; + // The language only matters when we're exporting a non system + // question in a normalised format. + if ($type == 'csv_human' && !isset($value['system']) && $flattener->is_translated()) { + $header[] = $value['label'][$flattener->get_preferred_language()]; } else { + // Machine labels are never translated and human label behave the + // same way if there's no translation. $header[] = $value[$label_key]; } } @@ -1267,7 +1271,7 @@ public function survey_export_csv($sid, $type) { header("Content-Disposition: attachment; filename=" . $filename); header("Content-Type: application/octet-stream; "); header("Content-Transfer-Encoding: binary"); - + // Open stream. $output = fopen('php://output', 'w'); diff --git a/application/helpers/or_xform_results_helper.php b/application/helpers/or_xform_results_helper.php index af4864f..f769c76 100644 --- a/application/helpers/or_xform_results_helper.php +++ b/application/helpers/or_xform_results_helper.php @@ -128,7 +128,7 @@ function __construct($xform_file) { $list[$path]['items'][(string)$item->value] = $this->_label_translation($item->label); } } - } + } } $this->flat_xform = $list; } @@ -251,6 +251,7 @@ protected function _normalize_result_item($item, $path = NULL) { // Split by space and search each term. $answer_pieces = explode(' ', $answer_key); $norm['value'] = array(); + $norm['machine_value'] = array(); foreach ($answer_pieces as $value) { if (isset($question['items'][$value])) { $norm['value'][] = $this->_get_question_item_translation($question, $value); @@ -272,7 +273,6 @@ protected function _normalize_result_item($item, $path = NULL) { $norm['value'] = NULL; $norm['machine_value'] = NULL; } - $normalised[] = $norm; } // else skip From 1ef64c49fb73fc80e87d4abd8a4371aeb3aebb47 Mon Sep 17 00:00:00 2001 From: Daniel Silva <daniel.silva@flipside.org> Date: Thu, 12 Jun 2014 12:55:26 +0100 Subject: [PATCH 2/6] Fix #128. Use correct method to get day --- src/scripts/enketo/enketo_collection_single.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/enketo/enketo_collection_single.js b/src/scripts/enketo/enketo_collection_single.js index d5dc8d7..44ff9de 100644 --- a/src/scripts/enketo/enketo_collection_single.js +++ b/src/scripts/enketo/enketo_collection_single.js @@ -384,7 +384,7 @@ requirejs(['jquery', 'Modernizr', 'enketo-js/Form'], function($, Modernizr, Form var hour = d.getHours() < 10 ? '0' + d.getHours() : d.getHours(); var min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes(); // Format 18 Mar, 2014 at 14:00 - var status_date = d.getDay() + ' ' + months[d.getMonth()] + ', ' + d.getFullYear() + ' at ' + hour + ':' + min; + var status_date = d.getDate() + ' ' + months[d.getMonth()] + ', ' + d.getFullYear() + ' at ' + hour + ':' + min; call_activity_table_data += '<tr>' + '<td>' + From 8daff84ce02a3abc4d9076c9beb754fa6962b047 Mon Sep 17 00:00:00 2001 From: Daniel Silva <daniel.silva@flipside.org> Date: Thu, 12 Jun 2014 14:12:41 +0100 Subject: [PATCH 3/6] Fix #126. Prevent single data collection on closed survey --- application/controllers/survey.php | 4 ++++ application/views/surveys/survey_call_activity.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/application/controllers/survey.php b/application/controllers/survey.php index c90bab8..33a33a5 100644 --- a/application/controllers/survey.php +++ b/application/controllers/survey.php @@ -637,6 +637,10 @@ public function survey_enketo_single($sid, $ctid) { show_403(); } } + + if (!$survey->status_allows('enketo collect data')) { + show_403(); + } $call_task = $this->call_task_model->get($ctid); $survey = $this->survey_model->get($sid); diff --git a/application/views/surveys/survey_call_activity.php b/application/views/surveys/survey_call_activity.php index 5cb078c..81b3791 100644 --- a/application/views/surveys/survey_call_activity.php +++ b/application/views/surveys/survey_call_activity.php @@ -66,7 +66,7 @@ <td><a href="#" class="expand-link" data-expand="ct-<?= $call_task_entity->ctid; ?>"><strong class="highlight"><?= $call_task_entity->number ?></strong></a></td> <?php $last_call = end($call_task_entity->activity); ?> <td><?= date('d M, Y', $last_call->created->sec) ?> <small>Last call placed</small></td> - <?php $disabled = $call_task_entity->is_resolved() ? 'disabled' : ''; ?> + <?php $disabled = $call_task_entity->is_resolved() || !$survey->status_allows('enketo collect data') ? 'disabled' : ''; ?> <td> <ul class="bttn-toolbar"> <li> From 8251ad8fa71ec895e0e72a7940bb2c5be4daf204 Mon Sep 17 00:00:00 2001 From: Daniel Silva <daniel.silva@flipside.org> Date: Thu, 12 Jun 2014 14:16:43 +0100 Subject: [PATCH 4/6] Fix #127. Add missing menu to respondents page --- application/views/surveys/survey_respondents.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/application/views/surveys/survey_respondents.php b/application/views/surveys/survey_respondents.php index 50e96c9..330d9bc 100644 --- a/application/views/surveys/survey_respondents.php +++ b/application/views/surveys/survey_respondents.php @@ -1,3 +1,12 @@ +<?php +$show_actions_enketo_data_collection = FALSE; +if (has_permission('enketo collect data any')) { + $show_actions_enketo_data_collection = TRUE; +} +else if (has_permission('enketo collect data assigned') && $survey->is_assigned_agent(current_user()->uid)){ + $show_actions_enketo_data_collection = TRUE; +} +?> <main id="site-body"> <section class="row"> <header id="page-head"> @@ -13,6 +22,11 @@ <a class="bttn-sector bttn-dropdown" href="#" data-dropdown="action-bttn"><strong>Respondents</strong></a> <ul class="action-dropdown"> <li><a href="<?= $survey->get_url_view() ?>">Summary</a></li> + + <?php if ($show_actions_enketo_data_collection) : ?> + <?php $disabled = !$survey->has_xml() || !$survey->status_allows('view call activity') ? 'disabled' : ''; ?> + <li><a href="<?= $survey->get_url_call_activity() ?>" class="<?= $disabled ?>">Call activity</a></li> + <?php endif; ?> </ul> </li> From ee43d9f5bed6faca2fefa95b81783b8884aba01b Mon Sep 17 00:00:00 2001 From: Daniel Silva <daniel.silva@flipside.org> Date: Thu, 12 Jun 2014 14:28:47 +0100 Subject: [PATCH 5/6] Fix #121. Add indication of username and email to user edit form --- application/views/users/user_form.php | 16 ++++++++++++++++ application/views/users/user_list.php | 2 ++ 2 files changed, 18 insertions(+) diff --git a/application/views/users/user_form.php b/application/views/users/user_form.php index 37e6c60..fbc97fb 100644 --- a/application/views/users/user_form.php +++ b/application/views/users/user_form.php @@ -43,6 +43,7 @@ <?= form_open(); ?> <div class="columns small-6"> <fieldset class="contained"> + <div class="form-control"> <?= form_label('Name <small>Required</small>', 'user_name'); ?> <?= form_input('user_name', set_value('user_name', property_if_not_null($user, 'name')), 'id="user_name"'); ?> @@ -64,6 +65,21 @@ <?php endif; ?> + <?php if ($action == 'edit_own' || $action == 'edit_other'): ?> + <div class="form-control"> + <?= form_label('Username', 'user_username'); ?> + <?= form_input('user_username', $user->username, 'id="user_username" disabled'); ?> + <?= form_error('user_username'); ?> + </div> + + <div class="form-control"> + <?= form_label('Email', 'user_email'); ?> + <?= form_input(array('type' => 'email', 'name' => 'user_email'), $user->email, 'id="user_email" disabled'); ?> + <?= form_error('user_email'); ?> + </div> + + <?php endif; ?> + <?php if ($action == 'edit_own'): ?> <div class="form-control"> <?= form_label('Current password', 'user_password'); ?> diff --git a/application/views/users/user_list.php b/application/views/users/user_list.php index 4267539..e8e01df 100644 --- a/application/views/users/user_list.php +++ b/application/views/users/user_list.php @@ -46,6 +46,7 @@ <tr> <th>Status</th> <th>Name</th> + <th>Username</th> <th>Roles</th> <th></th> </tr> @@ -55,6 +56,7 @@ <tr> <td><strong class="status <?= $user_entity->get_status_html_class(); ?>"><?= $user_entity->get_status_label(); ?></strong></td> <td><strong class="highlight"><?= $user_entity->name; ?></strong></td> + <td><?= $user_entity->username ?></td> <td><?= implode(', ', $user_entity->get_roles_label()); ?></td> <td> From d3152c4a778fbb861f38f69f3c028b21c21a1ebe Mon Sep 17 00:00:00 2001 From: Daniel Silva <daniel.silva@flipside.org> Date: Thu, 12 Jun 2014 14:34:18 +0100 Subject: [PATCH 6/6] Remove obsolete file --- application/views/frontend.php | 145 --------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 application/views/frontend.php diff --git a/application/views/frontend.php b/application/views/frontend.php deleted file mode 100644 index be65e2c..0000000 --- a/application/views/frontend.php +++ /dev/null @@ -1,145 +0,0 @@ -<div id="site-canvas"> - <header id="site-head"> - <h1 id="site-title"><a href="#" title="Go home"><span>Airwolf</span></a></h1> - - <nav id="primary" role="navigation"> - <ul id="nav-links" class="bttn-toolbar"> - <li> - <a href="#" class="dashboard current"><span class="visually-hidden">Dashboard</span></a> - </li> - <li> - <a href="#" class="surveys" data-dropdown="action-bttn-primary"><span class="visually-hidden">Surveys</span></a> - <ul class="action-dropdown-primary"> - <li><a href="#">View all</a></li> - <li><a href="#">Add new</a></li> - </ul> - </li> - <li> - <a href="#" class="users" data-dropdown="action-bttn-primary"><span class="visually-hidden">Users</span></a> - <ul class="action-dropdown-primary"> - <li><a href="#">View all</a></li> - <li><a href="#">Add new</a></li> - </ul> - </li> - <li> - <a href="#" class="account" data-dropdown="action-bttn-primary"><span class="visually-hidden">Account</span></a> - <ul class="action-dropdown-primary"> - <li class="logged-user">Signed in as <strong>Bruce Wayne</strong></li> - <li><a href="#">Edit profile</a></li> - <li><a href="#">Sign out</a></li> - </ul> - </li> - </ul> - </nav> - - <div id="connection-status"> - Loading... - </div> - </header> - - <main id="site-body"> - <section class="row"> - - <header id="page-head"> - - <div class="heading"> - <h1 class="hd-xl status-indicator-draft">Client Satisfaction Survey</h1> - </div> - - <nav id="secondary" role="navigation"> - <ul class="bttn-toolbar"> - <li class="sector-switcher"> - <strong class="bttn-sector">Current</strong> - </li> - <li class="sector-switcher"> - <a class="bttn-sector bttn-dropdown" href="" data-dropdown="action-bttn"><strong>Summary</strong></a> - <ul class="action-dropdown" style="display: none"> - <li><a href="#">Section</a></li> - <li><a href="#">Statistics</a></li> - <li><a href="#">The Vault</a></li> - </ul> - </li> - <li> - <a href="" class="bttn bttn-success bttn-medium bttn-dropdown" data-dropdown="action-bttn">Destroy the world</a> - <ul class="action-dropdown" style="display: none"> - <li><a href="#" class="disabled">Bomb</a></li> - <li><a href="#">Black Hole</a></li> - <li><a href="#">Banana</a></li> - </ul> - </li> - </ul> - </nav> - - </header> - - <div class="content"> - - <div class="columns small-12"> - <section class="contained"> - <header class="contained-head"> - - <ul class="bttn-group bttn-center"> - <li><a href="" class="bttn bttn-default bttn-small current">Make</a></li> - <li><a href="" class="bttn bttn-default bttn-small">my</a></li> - <li><a href="" class="bttn bttn-default bttn-small">button</a></li> - <li><a href="" class="bttn bttn-default bttn-small">bigggggggggggggger</a></li> - </ul> - - </header> - - <div class="contained-body"> - <table> - <thead> - <tr> - <th>Status</th> - <th>Title</th> - <th>Actions</th> - </tr> - </thead> - <tbody> - <tr> - <td><strong class="status-draft">Draft</strong></td> - <td><a href="">UNHCO Client Satisfaction Survey</a></td> - <td></td> - </tr> - <tr> - <td><strong class="status-open">Open</strong></td> - <td><a href="">GIZ Water Campaign February 2013</a></td> - <td></td> - </tr> - <tr> - <td><strong class="status-closed">Closed</strong></td> - <td><a href="">Lorem Ipsum Dolor Sit Amet</a></td> - <td></td> - </tr> - <tr> - <td><strong class="status-canceled">Canceled</strong></td> - <td><a href="">This will never come to be</a></td> - <td></td> - </tr> - </tbody> - </table> - </div> - - <footer class="contained-foot"> - <p>18 of 200 items</p> - <ul class="bttn-group bttn-center"> - <li><a href="" class="bttn bttn-default bttn-small"><<</a></li> - <li><a href="" class="bttn bttn-default bttn-small"><</a></li> - <li><a href="" class="bttn bttn-default bttn-small">1</a></li> - <li><a href="" class="bttn bttn-default bttn-small">2</a></li> - <li><a href="" class="bttn bttn-default bttn-small current">3</a></li> - <li><a href="" class="bttn bttn-default bttn-small">4</a></li> - <li><a href="" class="bttn bttn-default bttn-small">5</a></li> - <li><a href="" class="bttn bttn-default bttn-small">></a></li> - <li><a href="" class="bttn bttn-default bttn-small">>></a></li> - </ul> - </footer> - </section> - </div> - </div> - </div> - - </section> - </main> -</div> \ No newline at end of file