Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.7.0 #1764

Merged
merged 44 commits into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
336cfbb
1595 intercom (#1718)
willdoran May 4, 2017
8f95304
Fixed var name
willdoran May 4, 2017
c93f63e
Fix default for existing tasks
willdoran May 5, 2017
5a73da4
adding new migration to show_when_published (#1731)
Angamanga May 8, 2017
36fb68e
Changing column default for task visibility
willdoran May 8, 2017
0f53871
Repair linting
willdoran May 8, 2017
1eacec6
Fix Waffle badge
gausam May 10, 2017
5325628
Adding total to geojson collection (#1739)
willdoran May 15, 2017
479c02e
Adjusting unmapped request to incorporate it into stats (#1738)
willdoran May 16, 2017
d0fc90e
Merge pull request #1737 from samtheson/patch-1
rjmackay May 16, 2017
a9273c0
Geojson chunking (#1744)
willdoran May 16, 2017
1022486
Removing unneeded logging
willdoran May 16, 2017
9ff5c5b
Fixed issue when no posts returned by search
willdoran May 16, 2017
341ec70
Update linting setup and fix any new lint errors (#1742)
rjmackay May 16, 2017
0139fde
Fixing missing db config for unmapped query
willdoran May 17, 2017
f34277c
Merge branch 'develop' of github.com:ushahidi/platform into develop
willdoran May 17, 2017
fd530e9
Enable clustering by default
willdoran May 24, 2017
2dc41a6
Only add `tags` type attributes to the "post fields" not tasks.
rjmackay May 19, 2017
cdf2810
Remove category fields from tasks
rjmackay May 19, 2017
510d213
Turn posts_tags into a full post value table, and avoid duplicating info
rjmackay May 22, 2017
a35bb7c
Handle legacy tags values and save into first tags attribute.
rjmackay May 23, 2017
511e31f
Don't allow making tags attributes private
rjmackay May 19, 2017
2c5e3af
Make forms tests work in isolation
rjmackay May 24, 2017
38ea41a
Stop limiting tags by form, just limit tags per attribute
rjmackay May 24, 2017
138e5cc
Rename tags to categories in error messages
rjmackay May 24, 2017
77046c6
Format form tags and tag children as relations, remove tag forms form…
rjmackay May 25, 2017
d00019d
Merge pull request #1747 from ushahidi/fixes-to-improved-categories
rjmackay May 25, 2017
097429a
Remove tags?formId filter from Tag repo
rjmackay May 25, 2017
452f6b4
Merge pull request #1752 from ushahidi/further-fixes-to-categories
rjmackay May 25, 2017
91f8216
Fix validating tags when saving a post
rjmackay May 25, 2017
0bd22ff
Fix validating tags when saving a post
rjmackay May 25, 2017
7546890
Add TagRepository interface to use in Post/Tags Validator
rjmackay May 25, 2017
fdb86bb
Merge remote-tracking branch 'origin/master' into develop
rjmackay May 25, 2017
1616676
Ignore form.tags if passed when saving Form entities
rjmackay May 25, 2017
344fc16
Merge pull request #1755 from ushahidi/fix-saving-form
rjmackay May 25, 2017
c55dbfe
Add test for removing tag from attribute options when deleted
rjmackay May 26, 2017
728c4cf
Test that form.tags value is ignored during form update
rjmackay May 26, 2017
0ab29c2
Make child tags top level when parent is deleted, don't delete them
rjmackay May 26, 2017
4399b65
Reset fixtures before testing removing a tag
rjmackay May 26, 2017
071e061
Parse tag names when set as post value (not just post.tags)
rjmackay May 26, 2017
7f97320
Merge pull request #1758 from ushahidi/parse-tag-values
rjmackay May 26, 2017
91b40a2
Update to use checklist for testing
willdoran May 26, 2017
8dce10b
Fixing error message for tag (#1760)
willdoran May 29, 2017
2424f03
Incorrect length requirement
willdoran May 30, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
This pull request makes the following changes:
-

Test these changes by:
-
Test checklist:
- [ ]

Fixes ushahidi/platform# .

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Ushahidi 3
============

[![Build Status](https://travis-ci.org/ushahidi/platform.png)](https://travis-ci.org/ushahidi/platform)
[![Stories up next](https://badge.waffle.io/ushahidi/platform.png?label=Stage: Backlog&title=Backlog)](https://waffle.io/ushahidi/platform)
[![Stories up next](https://badge.waffle.io/ushahidi/platform.png?label=Stage:Backlog&title=Backlog)](https://waffle.io/ushahidi/platform)
[![Coverage Status](https://coveralls.io/repos/github/ushahidi/platform/badge.svg)](https://coveralls.io/github/ushahidi/platform)

[Download][download]
Expand All @@ -26,7 +26,7 @@ Ushahidi is an open source web application for information collection, visualiza

### I'm a developer, should I contribute to Ushahidi v3?

Yes! Development moves pretty quickly but the tech stack is getting more and more stable. If you're keen to help build something awesome, [Jump on board..][getin]
Yes! Development moves pretty quickly but the tech stack is getting more and more stable. If you're keen to help build something awesome, [jump on board..][getin]

## Using the Platform

Expand Down
35 changes: 33 additions & 2 deletions application/classes/Ushahidi/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public static function init()
and Kohana::$config->load('features.private.enabled');
});

// Intercom config settings
$di->set('site.intercomAppToken', function() use ($di) {
return Kohana::$config->load('site.intercomAppToken');
});

// Roles config settings
$di->set('roles.enabled', function() use ($di) {
return Kohana::$config->load('features.roles.enabled');
Expand Down Expand Up @@ -444,8 +449,7 @@ public static function init()
'form_stage_repo' => $di->lazyGet('repository.form_stage'),
'form_repo' => $di->lazyGet('repository.form'),
'post_value_factory' => $di->lazyGet('repository.post_value_factory'),
'bounding_box_factory' => $di->newFactory('Util_BoundingBox'),
'tag_repo' => $di->lazyGet('repository.tag')
'bounding_box_factory' => $di->newFactory('Util_BoundingBox')
];

$di->set('repository.post.datetime', $di->lazyNew('Ushahidi_Repository_Post_Datetime'));
Expand All @@ -460,6 +464,11 @@ public static function init()
$di->set('repository.post.markdown', $di->lazyNew('Ushahidi_Repository_Post_Markdown'));
$di->set('repository.post.title', $di->lazyNew('Ushahidi_Repository_Post_Title'));
$di->set('repository.post.media', $di->lazyNew('Ushahidi_Repository_Post_Media'));
$di->set('repository.post.tags', $di->lazyNew('Ushahidi_Repository_Post_Tags'));

$di->params['Ushahidi_Repository_Post_Tags'] = [
'tag_repo' => $di->lazyGet('repository.tag')
];

// The post value repo factory
$di->set('repository.post_value_factory', $di->lazyNew('Ushahidi_Repository_Post_ValueFactory'));
Expand All @@ -478,6 +487,7 @@ public static function init()
'markdown' => $di->lazyGet('repository.post.markdown'),
'title' => $di->lazyGet('repository.post.title'),
'media' => $di->lazyGet('repository.post.media'),
'tags' => $di->lazyGet('repository.post.tags'),
],
];

Expand Down Expand Up @@ -616,6 +626,10 @@ public static function init()
$di->params['Ushahidi_Validator_Post_Media'] = [
'media_repo' => $di->lazyGet('repository.media')
];
$di->set('validator.post.tags', $di->lazyNew('Ushahidi_Validator_Post_Tags'));
$di->params['Ushahidi_Validator_Post_Tags'] = [
'tags_repo' => $di->lazyGet('repository.tag')
];


$di->set('validator.post.value_factory', $di->lazyNew('Ushahidi_Validator_Post_ValueFactory'));
Expand All @@ -634,6 +648,7 @@ public static function init()
'title' => $di->lazyGet('validator.post.title'),
'media' => $di->lazyGet('validator.post.media'),
'video' => $di->lazyGet('validator.post.video'),
'tags' => $di->lazyGet('validator.post.tags'),
],
];

Expand Down Expand Up @@ -672,6 +687,22 @@ public static function init()
$di->setter['Ushahidi_Listener_PostListener']['setWebhookRepo'] =
$di->lazyGet('repository.webhook');

// Add Intercom Listener to Config
$di->setter['Ushahidi_Repository_Config']['setEvent'] = 'ConfigUpdateEvent';
$di->setter['Ushahidi_Repository_Config']['setListener'] =
$di->lazyNew('Ushahidi_Listener_IntercomListener');

// Add Intercom Listener to Form
$di->setter['Ushahidi_Repository_Form']['setEvent'] = 'FormUpdateEvent';
$di->setter['Ushahidi_Repository_Form']['setListener'] =
$di->lazyNew('Ushahidi_Listener_IntercomListener');

// Add Intercom Listener to User
$di->setter['Ushahidi_Repository_User']['setEvent'] = 'UserGetAllEvent';
$di->setter['Ushahidi_Repository_User']['setListener'] =
$di->lazyNew('Ushahidi_Listener_IntercomListener');


/**
* 1. Load the plugins
*/
Expand Down
2 changes: 1 addition & 1 deletion application/classes/Ushahidi/Formatter/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function format_updated($value)
protected function get_relation($resource, $id)
{
return !$id ? NULL : [
'id' => $id,
'id' => intval($id),
'url' => URL::site(Ushahidi_Rest::url($resource, $id), Request::current()),
];
}
Expand Down
11 changes: 11 additions & 0 deletions application/classes/Ushahidi/Formatter/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ protected function format_color($value)
$value = ltrim($value, '#');
return $value ? '#' . $value : null;
}

protected function format_tags($tags)
{
$output = [];
foreach ($tags as $tagid)
{
$output[] = $this->get_relation('tags', $tagid);
}

return $output;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __invoke($entities)
'type' => 'FeatureCollection',
'features' => []
];
$unmapped = 0;

foreach ($entities as $entity)
{
Expand All @@ -48,7 +47,7 @@ public function __invoke($entities)
{
$color = ltrim($entity->color, '#');
$color = $color ? '#' . $color : null;

$output['features'][] = [
'type' => 'Feature',
'geometry' => [
Expand All @@ -68,12 +67,7 @@ public function __invoke($entities)
]
];
}
if(empty($geometries))
{
$unmapped++;
}
}
$output['unmapped'] = $unmapped;

if ($this->search->bbox)
{
Expand All @@ -88,6 +82,11 @@ public function __invoke($entities)

$output['bbox'] = $bbox;
}

// Note: Appending total output despite it not being in the geojson Spec
// this field is used by the client so that it can determine how many requests to make
// in order to retrieve all the posts
$output['total'] = $this->total;
return $output;
}

Expand Down
4 changes: 4 additions & 0 deletions application/classes/Ushahidi/Formatter/Post/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function __invoke($records)
} else {
$data['totals'] = $this->formatTotals($records);
}

if (array_key_exists('unmapped', $records)) {
$data['unmapped'] = $records['unmapped'];
}
}

return $data;
Expand Down
14 changes: 9 additions & 5 deletions application/classes/Ushahidi/Formatter/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ protected function format_color($value)
return $value ? '#' . $value : null;
}

protected function format_forms($forms)
protected function format_children($tags)
{
$output = [];
foreach ($forms as $formid)
{
$output[] = $this->get_relation('forms', $formid);

if (is_array($tags)) {
foreach ($tags as $tagid)
{
$output[] = $this->get_relation('tags', $tagid);
//$output[] = intval($tagid);
}
}

return $output;
}
}
131 changes: 36 additions & 95 deletions application/classes/Ushahidi/FormsTagsTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**

/**
* Ushahidi FormsTags Repo Trait
* Helps Forms and Tags-repository use the same methods
** @author Ushahidi Team <team@ushahidi.com>
Expand All @@ -11,111 +11,52 @@

trait Ushahidi_FormsTagsTrait
{
//returning forms for a specific Tag-id
private function getFormsForTag($id)
{
$result = DB::select('form_id')
->from('forms_tags')
->where('tag_id', '=', $id)
->execute($this->db);
return $result->as_array(NULL, 'form_id');
}
//returning tags for a specific Form-id
private function getTagsForForm($id)
{
$result = DB::select('tag_id')
->from('forms_tags')
$attributes = DB::select('form_attributes.options')
->from('form_attributes')
->join('form_stages')->on('form_stage_id', '=', 'form_stages.id')
->join('forms')->on('form_id', '=', 'forms.id')
->where('form_id', '=', $id)
->execute($this->db);
return $result->as_array(NULL, 'tag_id');
}

// updating/adding tags to a form
private function updateFormsTags($form_id, $tags)
{
if (!$tags) {
DB::delete('forms_tags')
->where('form_id', '=', $form_id)
->execute($this->db);
} else if ($tags) {
$existing = $this->getTagsForForm($form_id);
$insert = DB::insert('forms_tags', ['form_id', 'tag_id']);
$tag_ids = [];
$new_tags = FALSE;
foreach ($tags as $tag) {
if (!in_array($tag, $existing)) {
$insert->values([$form_id, $tag]);
$new_tags = TRUE;
}
$tag_ids[] = $tag;
}
if ($new_tags) {
$insert->execute($this->db);
}
if (!empty($tag_ids)) {
DB::delete('forms_tags')
->where('tag_id', 'NOT IN', $tag_ids)
->and_where('form_id', '=', $form_id)
->execute($this->db);
}
}
}
->where('form_attributes.type', '=', 'tags')
->execute($this->db)
->as_array();

//updating/adding forms to a tag
private function updateTagForms($tag_id, $forms)
{
if (empty($forms)) {
DB::delete('forms_tags')
->where('tag_id', '=', $tag_id)
->execute($this->db);
} else {
$existing = $this->getFormsForTag($tag_id);
$insert = DB::insert('forms_tags', ['form_id', 'tag_id']);
$form_ids = [];
$new_forms = FALSE;
foreach ($forms as $form) {
if (isset($form['id'])) {
$id = $form['id'];
} else {
$id = $form;
}
if (!in_array($form, $existing)) {
$insert->values([$id, $tag_id]);
$new_forms = TRUE;
}
$form_ids[] = $id;
}

if ($new_forms) {
$insert->execute($this->db);
}

if (!empty($form_ids)) {
DB::delete('forms_tags')
->where('form_id', 'NOT IN', $form_ids)
->and_where('tag_id', '=', $tag_id)
->execute($this->db);
$tags = [];
// Combine all tag ids into 1 array
foreach ($attributes as $attr) {
$options = json_decode($attr['options'], TRUE);
if (is_array($options)) {
$tags = array_merge($tags, $options);
}
}

return $tags;
}

private function updateFormAttributes($id)
private function removeTagFromAttributeOptions($id)
{
// Grab all tags attributes
$attr = DB::select('id', 'options')
->from('form_attributes')
->where('input', '=', 'tags')
->execute($this->db)
->as_array('id', 'options');
foreach ($attr as $attr_id => $value) {
$value = json_decode($value);
if (in_array($id, $value)) {
$index = array_search($id, $value);
array_splice($value, $index, 1);
$value = json_encode($value);
->from('form_attributes')
->where('type', '=', 'tags')
->execute($this->db)
->as_array('id', 'options');

foreach ($attr as $attr_id => $options) {
$options = json_decode($options, TRUE);
if (is_array($options) && in_array($id, $options)) {
// Remove $id from options array
$index = array_search($id, $options);
array_splice($options, $index, 1);
$options = json_encode($options);

// Save it
DB::update('form_attributes')
->set(array('options' => $value))
->where('id', '=', $attr_id)
->execute($this->db);
->set(array('options' => $options))
->where('id', '=', $attr_id)
->execute($this->db);
}
}
}
Expand Down
Loading