Skip to content

Commit

Permalink
Merge pull request #130 from flipside-org/hotfix-issues_walkthrough
Browse files Browse the repository at this point in the history
Hotfix issues walkthrough
  • Loading branch information
olafveerman committed Jun 12, 2014
2 parents 394d9ef + d3152c4 commit 097fcdb
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 152 deletions.
14 changes: 11 additions & 3 deletions application/controllers/survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1251,10 +1255,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];
}
}
Expand All @@ -1267,7 +1275,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');

Expand Down
4 changes: 2 additions & 2 deletions application/helpers/or_xform_results_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function __construct($xform_file) {
$list[$path]['items'][(string)$item->value] = $this->_label_translation($item->label);
}
}
}
}
}
$this->flat_xform = $list;
}
Expand Down Expand Up @@ -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);
Expand All @@ -272,7 +273,6 @@ protected function _normalize_result_item($item, $path = NULL) {
$norm['value'] = NULL;
$norm['machine_value'] = NULL;
}

$normalised[] = $norm;
}
// else skip
Expand Down
145 changes: 0 additions & 145 deletions application/views/frontend.php

This file was deleted.

2 changes: 1 addition & 1 deletion application/views/surveys/survey_call_activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
14 changes: 14 additions & 0 deletions application/views/surveys/survey_respondents.php
Original file line number Diff line number Diff line change
@@ -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">
Expand All @@ -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>

Expand Down
16 changes: 16 additions & 0 deletions application/views/users/user_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"'); ?>
Expand All @@ -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'); ?>
Expand Down
2 changes: 2 additions & 0 deletions application/views/users/user_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<tr>
<th>Status</th>
<th>Name</th>
<th>Username</th>
<th>Roles</th>
<th></th>
</tr>
Expand All @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/enketo/enketo_collection_single.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>' +
Expand Down

0 comments on commit 097fcdb

Please sign in to comment.