Commit 5a20e50b authored by patrick-proulx's avatar patrick-proulx

Patricks-Air:cd pat$ more svn-commit.tmp

[NEW] Added a new feature to be able to force the filling out of a tracker form on users if they have not already filled it out. Documentation here: https://doc.tiki.org/Force+Filled+Tracker
parent 3adccccd
......@@ -3796,6 +3796,7 @@ lib/setup/third_party.php -text
lib/setup/tikiIndex.php -text
lib/setup/tikisetup.class.php -text
lib/setup/timer.class.php -text
lib/setup/tracker_force_fill.php -text
lib/setup/twversion.class.php -text
lib/setup/user_prefs.php -text
lib/setup/userlevels.php -text
......@@ -6113,6 +6114,7 @@ templates/tiki-theme_control.tpl -text
templates/tiki-theme_control_objects.tpl -text
templates/tiki-theme_control_sections.tpl -text
templates/tiki-timesheet.tpl -text
templates/tiki-tracker_force_fill.tpl -text
templates/tiki-tracker_reports.tpl -text
templates/tiki-tracker_view_history.tpl -text
templates/tiki-upload_file.tpl -text
......
......@@ -117,5 +117,40 @@ function prefs_tracker_list()
'default' => 'y',
'dependencies' => ['feature_trackers'],
),
'tracker_force_fill' => array(
'name' => tr('Force users to fill tracker information.'),
'description' => tr("Forces a user to fill in a tracker form if they haven't already by prompting them with a module "),
'help' => 'Force+Fill+Tracker',
'type' => 'flag',
'tags' => array('advanced'),
'default' => 'n',
'dependencies' => ['feature_trackers'],
),
'tracker_force_tracker_id' => array(
'name' => tr('Tracker ID of tracker for force-filling'),
'description' => tr('The tracker that is for articles must contain an "Articles" field'),
'type' => 'text',
'tags' => array('advanced'),
'size' => '3',
'filter' => 'digits',
'default' => '',
'dependencies' => ['tracker_force_fill'],
),
'tracker_force_mandatory_field' => array(
'name' => tr('Mandatory tracker field to check for force-filling'),
'description' => tr('The permname of field that is checked to see if user has completed the form. If field is empty, user has not completed it.'),
'type' => 'text',
'tags' => array('advanced'),
'default' => '',
'dependencies' => ['tracker_force_fill'],
),
'tracker_force_tracker_fields' => array(
'name' => tr('Fields that are asked for in the modal for force-filling'),
'description' => tr('Comma-separated permnames of fields that are asked for in the modal for force-filling. If empty, all fields are asked for'),
'type' => 'text',
'tags' => array('advanced'),
'default' => '',
'dependencies' => ['tracker_force_fill'],
),
);
}
<?php
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: lib/setup/tracker_force_fill.php 57351 2016-02-23 09:03:22Z pat-proulx $
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) != FALSE) {
header('location: index.php');
exit;
}
global $user;
if (empty($user)) {
return;
}
$tracker_id = $prefs['tracker_force_tracker_id'];
$tracker_definition = Tracker_Definition::get($tracker_id);
//user field info
$user_field_id = $tracker_definition->getUserField();
$user_field = $tracker_definition->getField($user_field_id);
$user_field_permname = $user_field['permName'];
//mandatory field info
$mandatory_field_permname = $prefs['tracker_force_mandatory_field'];
$mandatory_field_info = $tracker_definition->getFieldFromPermName($mandatory_field_permname);
$mandatory_field_id = $mandatory_field_info['fieldId'];
$fields = array_map('trim', explode(',', $prefs['tracker_force_tracker_fields']));
$trackerlib = TikiLib::lib('trk');
$item = $trackerlib->get_item($tracker_id,$user_field_id,$user);
if ($item) {
//if the mandatory field is empty or if it's a checkbox and is set to 'n', force tracker input
if (empty($item[$mandatory_field_id]) || ($mandatory_field_info['type'] =='c' && $item[$mandatory_field_id] == "n")) {
$action = "update";
} else {
return; //do nothing
}
} else {
$action = "new";
}
$smarty->assign_by_ref("force_fill_action",$action);
$smarty->assign("force_fill_tracker",$tracker_id);
$smarty->assign("force_fill_user_field",$user_field_id);
$smarty->assign("force_fill_user_field_permname",$user_field_permname);
$smarty->assign("force_fill_mandatory_field",$mandatory_field_id);
$smarty->assign("force_fill_item",$item);
$smarty->assign("force_fill_fields",json_encode($fields, JSON_FORCE_OBJECT));
......@@ -82,6 +82,13 @@
</table>
</fieldset>
<fieldset class="admin">
<legend>{tr}Tracker Force-Fill Feature{/tr}</legend>
{preference name=tracker_force_fill}
{preference name=tracker_force_tracker_id}
{preference name=tracker_force_mandatory_field}
{preference name=tracker_force_tracker_fields}
</fieldset>
{/tab}
{tab name="{tr}Plugins{/tr}"}
......
......@@ -23,6 +23,9 @@
</div>
</div>
</div>
{if isset($force_fill_action)}
{include file="tiki-tracker_force_fill.tpl"}
{/if}
{if $module_pref_errors|default:null}
<div class="container modules">
{remarksbox type="warning" title="{tr}Module errors{/tr}"}
......@@ -75,4 +78,4 @@
{/if}
{if $prefs.feature_endbody_code}
{eval var=$prefs.feature_endbody_code}
{/if}
{/if}
\ No newline at end of file
{if $force_fill_action eq 'new'}
{jq}
$.openModal({
remote: $.service(
'tracker',
'insert_item',
{
trackerId: {{$force_fill_tracker}},
editable: {{$force_fill_fields}},
forced: {"{{$force_fill_user_field_permname}}":"{{$user}}"},
status:"",
title:"Please fill in the following information"
}
),
});
{/jq}
{else}
{jq}
$.openModal({
remote: $.service(
'tracker',
'update_item',
{
trackerId: {{$force_fill_tracker}},
itemId: {{$force_fill_item.itemId}},
editable: {{$force_fill_fields}},
status:"",
title:"Please fill in the following information"
}
),
});
{/jq}
{/if}
\ No newline at end of file
......@@ -170,7 +170,9 @@ require_once ('lib/setup/tikiIndex.php');
if ($prefs['useGroupHome'] == 'y') {
require_once ('lib/setup/default_homepage.php');
}
if ($prefs['tracker_force_fill'] == 'y') {
require_once ('lib/setup/tracker_force_fill.php');
}
// change $prefs['tikiIndex'] if feature_sefurl is enabled (e.g. tiki-index.php?page=HomePage becomes HomePage)
if ($prefs['feature_sefurl'] == 'y' && ! defined('TIKI_CONSOLE')) {
//TODO: need a better way to know which is the type of the tikiIndex URL (wiki page, blog, file gallery etc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment