-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**New Features** - Added Field Level Locking to Surveys - Improved Survey UX - Added Task Level Visibility - Added Webhook Support - Added Webhook UX - Added Webhook events fro Create, Update of Post - Added Survey Duplication - Added Task Duplication - Added Support for OSS deployment with Ushahidi Mobile - Added Deeplinking for iOS and Android - Added Banner ads for iOS and Android - Adding Location Search Picker for Maps in Posts - Added reply to twitter via Post feature - Added support for hierarchical categories - Added Category field type to Survey - Added Markdown field type to Survey - Add tags dynamically directly from Posts - Added language switching for all users **Minor improvements and fixes** - Adding uglify-friendly code to colors - Confirming on delete for unsaved surveys, tasks and fields - Upgrade node to v6 - Resolved twitter duplication bug - Display number of unmapped posts to timeline - Moved Savedsearches to Modal - Moved Filter to Modal
- Loading branch information
Showing
57 changed files
with
1,739 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?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> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
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') | ||
->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); | ||
} | ||
} | ||
} | ||
|
||
//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); | ||
} | ||
} | ||
} | ||
|
||
private function updateFormAttributes($id) | ||
{ | ||
$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); | ||
DB::update('form_attributes') | ||
->set(array('options' => $value)) | ||
->where('id', '=', $attr_id) | ||
->execute($this->db); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.