sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
private function _toCleanArray(array $data)
{
switch (count($data)) {
case 0:
return null;
case 1:
if (isset($data[0])) {
// Return array content when only one item
// with the key 0.
if (is_... | Remove password and pwd contents and clean up message status data and single item arrays
@param array $data
@return mixed | entailment |
private function _toJson($data)
{
if ($data) {
if (is_array($data)) {
return json_encode($this->_toCleanArray($data));
}
return json_encode($data);
}
} | Converts data types for storage
@param mixed $data
@return string | entailment |
protected function getMessages()
{
if (! $this->_messenger instanceof \MUtil_Controller_Action_Helper_FlashMessenger) {
$this->_messenger = new \MUtil_Controller_Action_Helper_FlashMessenger();
}
return $this->_messenger->getMessagesOnly();
} | The curent flash messenger messages
@return array | entailment |
public function log($action, \Zend_Controller_Request_Abstract $request = null, $message = null, $respondentId = null, $force = false)
{
if (null === $request) {
$request = \Zend_Controller_Front::getInstance()->getRequest();
}
$this->_logEntry($request, $action, $force, null, $m... | Logs the action for the current user with optional message and respondent id
@param string $action
@param \Zend_Controller_Request_Abstract $request
@param string $message An optional message to log with the action
@param <type> $respondentId
@param boolean $force Should we force the logentry to be inserted o... | entailment |
public function logChange(\Zend_Controller_Request_Abstract $request, $message = null, $data = null, $respondentId = null)
{
$action = $request->getControllerName() . '.' . $request->getActionName();
return $this->logEntry($request, $action, true, $message, $data, $respondentId);
} | Logs the action for the current user with optional message and respondent id
@param \Zend_Controller_Request_Abstract $request
@param mixed $message
@param mixed $data
@param int $respondentId
@return boolean True when a log entry was stored | entailment |
public function logRequest(\Zend_Controller_Request_Abstract $request, $message = null, $data = null, $respondentId = null)
{
$action = $request->getControllerName() . '.' . $request->getActionName();
if ($respondentId instanceof \Gems_Tracker_Respondent) {
if ($respondentId->exists) {
... | Logs the action for the current user with optional message and respondent id
@param \Zend_Controller_Request_Abstract $request
@param mixed $message
@param mixed $data
@param int|\Gems_Tracker_Respondent $respondentId
@return boolean True when a log entry was stored | entailment |
protected function saveData()
{
$this->addMessage($this->_('You have been subscribed succesfully.'));
$sql = "SELECT gr2o_id_user FROM gems__respondent2org
WHERE gr2o_email = ? AND gr2o_id_organization = ?";
$userId = $this->db->fetchOne($sql, [$this->formData['email'], $this->... | Hook containing the actual save code.
@return int The number of "row level" items changed | entailment |
public function getChanges(array $context, $new)
{
// Only change anything when there are filters
$filters = $this->loader->getAgenda()->getFilterList();
if (! $filters) {
return array();
}
// Load utility
$translated = $this->util->getTranslat... | Returns the changes that must be made in an array consisting of
<code>
array(
field1 => array(setting1 => $value1, setting2 => $value2, ...),
field2 => array(setting3 => $value3, setting4 => $value4, ...),
</code>
By using [] array notation in the setting name you can append to existing
values.
Use the setting 'valu... | entailment |
protected function _isTokenInFilter(\Gems_Tracker_Token $token)
{
$result = false;
// Only if token has a success code
if ($token->getReceptionCode()->isSuccess()) {
$result = true;
}
if ($result) {
$tokenInfo = array(
'code' => $... | Determines if this particular token should be included
in the report
@param \Gems_Tracker_Token $token
@return boolean This dummy implementation always returns true | entailment |
protected function _isTrackInFilter(\Gems_Tracker_RespondentTrack $track)
{
$result = false;
$trackInfo = array(
'code' => $track->getCode(),
'trackid' => $track->getTrackId(),
'resptrackid' => $track->getRespondentTrackId(),
'respid' ... | Determines if this particular track should be included
in the report
@param \Gems_Tracker_RespondentTrack $track
@return boolean This dummy implementation always returns true | entailment |
protected function _exportTrackTokens(\Gems_Tracker_RespondentTrack $track)
{
$groupSurveys = $this->_group;
$token = $track->getFirstToken();
$engine = $track->getTrackEngine();
$surveys = array();
$table = $this->html->table(array('class' => 'browser tabl... | Exports all the tokens of a single track, grouped by round
@param \Gems_Tracker_RespondentTrack $track | entailment |
protected function _exportTrack(\Gems_Tracker_RespondentTrack $respTrack)
{
if (!$this->_isTrackInFilter($respTrack)) {
return;
}
$trackModel = $this->loader->getTracker()->getRespondentTrackModel();
$trackModel->applyDetailSettings($respTrack->getTrackEngine(), false);
... | Exports a single track
@param \Gems_Tracker_RespondentTrack $respTrack | entailment |
protected function _exportRespondent($respondentId)
{
$respondentModel = $this->loader->getModels()->getRespondentModel(false);
//Insert orgId when set
if (is_array($respondentId) && isset($respondentId['gr2o_id_organization'])) {
$filter['gr2o_id_organization'] = $respondentId[... | Exports a single respondent
@param string $respondentId | entailment |
public function afterRegistry()
{
parent::afterRegistry();
$this->_pdf = $this->loader->getPdf();
$this->escort = \GemsEscort::getInstance();
$this->html = new \MUtil_Html_Sequence();
$this->request = \Zend_Controller_Front::getInstance()->getRequest();
// Do... | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
public function getForm($hideGroup = false)
{
$form = new \Gems_Form();
$form->setAttrib('target', '_blank');
if ($hideGroup) {
$element = new \Zend_Form_Element_Hidden('group');
} else {
$element = new \Zend_Form_Element_Checkbox('group');
$eleme... | Constructs the form
@param boolean $hideGroup When true group checkbox is hidden
@return \Gems_Form_TableForm | entailment |
public function render($respondents, $group = true, $format = 'html')
{
$this->_group = $group;
$this->html->snippet($this->_reportHeader);
$respondentCount = count($respondents);
$respondentIdx = 0;
foreach ($respondents as $respondentId) {
$respondentIdx++;
... | Renders the entire report (including layout)
@param array|string[] $respondentId
@param boolean $group Group same surveys or not
@param string $format html|pdf, the output format to use | entailment |
public function getFieldsTranslations()
{
$fieldList = parent::getFieldsTranslations();
// Add the key values (so organization id is present)
$keys = array_combine(array_values($this->_targetModel->getKeys()), array_values($this->_targetModel->getKeys()));
$fieldList = $fieldList + ... | Get information on the field translations
@return array of fields sourceName => targetName
@throws \MUtil_Model_ModelException | entailment |
public function translateRowValues($row, $key)
{
$row = parent::translateRowValues($row, $key);
if (! $row) {
return false;
}
if ((! isset($row['grs_id_user'])) && isset($row['gr2o_patient_nr'], $row['gr2o_id_organization'])) {
$sql = 'SELECT gr2o_id_user
... | Perform any translations necessary for the code to work
@param mixed $row array or \Traversable row
@param scalar $key
@return mixed Row array or false when errors occurred | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$seq = $this->getHtmlSequence();
$seq->h2($this->_('Checks'));
$ul = $seq->ul();
$ul->li($this->_('Updates existing token description and order to the current round description and order.'));
$ul->li($this->_('Updat... | Create the snippets content
This is a stub function either override getHtmlOutput() or override render()
@param \Zend_View_Abstract $view Just in case it is needed here
@return \MUtil_Html_HtmlInterface Something that can be rendered | entailment |
public function getChanges(array $context, $new)
{
$conditions = $this->loader->getConditions();
$options = $this->util->getTranslated()->getEmptyDropdownArray();
if (isset($context['gcon_type'])) {
$options = $conditions->listConditionsForType($context['gcon_type']);
... | Returns the changes that must be made in an array consisting of
<code>
array(
field1 => array(setting1 => $value1, setting2 => $value2, ...),
field2 => array(setting3 => $value3, setting4 => $value4, ...),
</code>
By using [] array notation in the setting name you can append to existing
values.
Use the setting 'valu... | entailment |
protected function _checkDir($directory)
{
$eDir = @dir($directory);
if (false == $eDir) {
// Dir does probably not exist
if (!is_dir($directory)) {
if (false === @mkdir($directory, 0777, true)) {
\MUtil_Echo::pre(sprintf($this->translate->... | Open the dir, suppressing possible errors and try to
create when it does not exist
@param type $directory
@return Directory | entailment |
protected function _getSourceSurveysForSynchronisation()
{
// First scan for new definitions
$this->_scanForms();
// Surveys in OpenRosa
$db = $this->getSourceDatabase();
$select = $db->select();
$select->from('gems__openrosaforms', ['gof_id']);
return $db-... | Returns all surveys for synchronization
@return array of sourceId values or false | entailment |
public function checkSourceActive($userId)
{
$active = true;
$values['gso_active'] = $active ? 1 : 0;
$values['gso_status'] = $active ? 'Active' : 'Inactive';
$this->_updateSource($values, $userId);
return $active;
} | Checks wether this particular source is active or not and should handle updating the gems-db
with the right information about this source
@param int $userId Id of the user who takes the action (for logging)
@return boolean | entailment |
public function getAnswerDateTime($fieldName, \Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
{
$answers = $token->getRawAnswers();
if (isset($answers[$fieldName]) && $answers[$fieldName]) {
if (\Zend_Date::isDate($answers[$fieldName], \Zend_Date::ISO_8601)) {
... | Returns a field from the raw answers as a date object.
A seperate function as only the source knows what format the date/time value has.
@param string $fieldName Name of answer field
@param \Gems_Tracker_Token $token Gems token object
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey I... | entailment |
public function getCompletionTime(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
{
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
if ($name = $model->getMeta('start')) {
return $this->getAnswerDateTime($name, $token, $surve... | Gets the time the survey was completed according to the source
A source always return null when it does not know this time (or does not know
it well enough). In the case \Gems_Tracker_Token will do it's best to keep
track by itself.
@param \Gems_Tracker_Token $token Gems token object
@param int $surveyId Gems Survey ... | entailment |
public function getDatesList($language, $surveyId, $sourceSurveyId = null)
{
$result = [];
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
$dateItems = $model->getItemsFor('type', Mutil_model::TYPE_DATETIME) + $model->getItemsFor('type', Mutil... | Returns an array containing fieldname => label for each date field in the survey.
Used in dropdown list etc..
@param string $language (ISO) language string
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array fieldname => label | entailment |
public function getFullQuestionList($language, $surveyId, $sourceSurveyId = null)
{
return $this->getQuestionList($language, $surveyId, $sourceSurveyId);
} | Returns an array of arrays with the structure:
question => string,
class => question|question_sub
group => is for grouping
type => (optional) source specific type
answers => string for single types,
array for selection of,
nothing for no answer
@param string $language (ISO) language string
@param int $sur... | entailment |
public function getQuestionInformation($language, $surveyId, $sourceSurveyId = null)
{
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
$result = [];
foreach($model->getItemsOrdered() as $name) {
if ($label = $model->get($name, 'labe... | Returns an array of arrays with the structure:
question => string,
class => question|question_sub
group => is for grouping
type => (optional) source specific type
answers => string for single types,
array for selection of,
nothing for no answer
@param string $language (ISO) language string
@param int $sur... | entailment |
public function getQuestionList($language, $surveyId, $sourceSurveyId = null)
{
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
$result = [];
foreach($model->getItemsOrdered() as $name) {
if ($label = $model->get($name, 'label')) {
... | Returns an array containing fieldname => label for dropdown list etc..
@param string $language (ISO) language string
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array fieldname => label | entailment |
public function getRawTokenAnswerRow($tokenId, $surveyId, $sourceSurveyId = null)
{
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
$result = $model->loadFirst(['token' => $tokenId]);
return $result;
} | Returns the answers in simple raw array format, without value processing etc.
Function may return more fields than just the answers.
@param string $tokenId Gems Token Id
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array Field => Value array | entailment |
public function getRawTokenAnswerRows(array $filter, $surveyId, $sourceSurveyId = null)
{
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
$answers = $model->load($filter);
$data = [];
foreach($answers as $key=>$answer) {
$da... | Returns the answers of multiple tokens in simple raw nested array format,
without value processing etc.
Function may return more fields than just the answers.
The $filter param is an array of filters to apply to the selection, it has
some special formatting rules. The key is the db-field to filter on and the
value cou... | entailment |
public function getRawTokenAnswerRowsSelect(array $filter, $surveyId, $sourceSurveyId = null)
{
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
$select = $model->getSelect();
$this->filterLimitOffset($filter, $select);
return $select;
... | Get the select object to use for RawTokenAnswerRows
@param array $filter
@param type $surveyId
@param type $sourceSurveyId
@return \Zend_Db_Select | entailment |
public function getSurveyInfo($sourceSurveyId)
{
$db = $this->getSourceDatabase();
$select = $db->select();
$select->from('gems__openrosaforms')
->where('gof_id = ?', $sourceSurveyId);
return $db->fetchRow($select);
} | Return info about the survey (row from gems__openrosaforms)
@param int $sourceSurveyId
@return array | entailment |
public function getSurveyAnswerModel(\Gems_Tracker_Survey $survey, $language = null, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($survey->getSurveyId());
}
$model = $this->createModel($survey);
$model->set('gto_id_to... | Returns a model for the survey answers
@param \Gems_Tracker_Survey $survey
@param string $language Optional (ISO) language string
@param string $sourceSurveyId Optional Survey Id used by source
@return \MUtil_Model_ModelAbstract | entailment |
public function getToken($tokenId)
{
$tracker = $this->loader->getTracker();
$token = $tracker->getToken($tokenId);
return $token;
} | Returns a Gems Tracker token from a token ID
@param string $tokenId Gems Token Id
@return \Gems_Tracker_Token
@deprecated | entailment |
public function getTokenUrl(\Gems_Tracker_Token $token, $language, $surveyId, $sourceSurveyId)
{
// There is no url, so return null
$basePath = \GemsEscort::getInstance()->basePath->__toString();
return $basePath . '/open-rosa-form/edit/id/' . $token->getTokenId();
} | Returns the url that (should) start the survey for this token
@param \Gems_Tracker_Token $token Gems token object
@param string $language
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return string The url to start the survey | entailment |
public function isCompleted(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
{
$result = $this->getRawTokenAnswerRow($token->getTokenId(), $surveyId);
$completed = !empty($result);
return $completed;
} | Returns true if the survey was completed according to the source
@param \Gems_Tracker_Token $token Gems token object
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return boolean True if the token has completed | entailment |
public function checkSurvey($sourceSurveyId, $surveyId, $userId)
{
$changed = 0;
$created = false;
$deleted = false;
$deletedFile = false;
$survey = $this->tracker->getSurvey($surveyId);
// Get OpenRosa data
if ($sourceSurveyId) {
... | Survey source synchronization check function
@param string $sourceSurveyId
@param int $surveyId
@param int $userId
@return mixed message string or array of messages | entailment |
public function setRawTokenAnswers(\Gems_Tracker_Token $token, array $answers, $surveyId, $sourceSurveyId = null)
{
$survey = $this->getSurvey($surveyId, $sourceSurveyId);
$model = $survey->getModel();
// new \Zend_Db_Table(array('db' => $this->getSourceDatabase(), 'name' => 'odk__etc'))
... | Sets the answers passed on.
@param \Gems_Tracker_Token $token Gems token object
@param $answers array Field => Value array
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source | entailment |
protected function sourceFileExists($filename)
{
$fullFilename = $this->formDir . $filename;
if (file_exists($fullFilename)) {
return true;
}
return false;
} | Check if the xml file still exists in the directory
@param $filename
@return bool | entailment |
private function _checkForMailSent($isNew, array $context)
{
// Never change on new tokens
if ($isNew) {
return false;
}
// Only act on existing valid from date
if (! (isset($context['gto_valid_from']) && $context['gto_valid_from'])) {
return false;
... | Function to check whether the mail_sent should be reset
@param boolean $isNew True when a new item is being saved
@param array $context The values being saved
@return boolean True when the change should be triggered | entailment |
public function addEditTracking()
{
// Old code
// $changer = new \MUtil_Model_Type_ChangeTracker($this, 1, 0);
//
// $changer->apply('gto_valid_from_manual', 'gto_valid_from');
// $changer->apply('gto_valid_until_manual', 'gto_valid_until');
$this->addDependency(new OffOnEleme... | Add tracking off manual date changes by the user
@param mixed $value The value to store when the tracked field has changed
@return \Gems_Tracker_Model_StandardTokenModel | entailment |
public function afterRegistry()
{
parent::afterRegistry();
//If we are allowed to see who filled out a survey, modify the model accordingly
if ($this->currentUser->hasPrivilege('pr.respondent.who')) {
$this->addLeftTable('gems__staff', array('gto_by' => 'gems__staff_2.gsf_id_use... | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
public function applyFormatting()
{
$this->resetOrder();
$dbLookup = $this->util->getDbLookup();
$translated = $this->util->getTranslated();
// Token id & respondent
$this->set('gto_id_token', 'label', $this->_('Token'),
'elementClass', 'Exhibito... | Sets the labels, format functions, etc...
@return \Gems_Tracker_Model_StandardTokenModel | entailment |
public function saveCheckedMailDate($value, $isNew = false, $name = null, array $context = array())
{
if ($this->_checkForMailSent($isNew, $context)) {
return null;
}
return $this->formatSaveDate($value, $isNew, $name, $context);
} | A ModelAbstract->setOnSave() function that can transform the saved item.
@see setSaveWhen()
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values being saved
@return boolean | entailment |
public function saveCheckedMailNum($value, $isNew = false, $name = null, array $context = array())
{
if ($this->_checkForMailSent($isNew, $context)) {
return 0;
}
return $value;
} | A ModelAbstract->setOnSave() function that can transform the saved item.
@see setSaveWhen()
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values being saved
@return boolean | entailment |
public function createModel($detailed, $action)
{
$model = new \MUtil_Model_TableModel('gems__mail_servers');
\Gems_Model::setChangeFieldsByPrefix($model, 'gms');
// Key can be changed by users
$model->copyKeys();
$model->set('gms_from',
'label', ... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
{
parent::processFilterAndSort($model);
$appId = $this->request->getParam(\Gems_Model::APPOINTMENT_ID);
if ($appId) {
$appKeyPrefix = $this->db->quote(FieldsDefinition::makeKey(FieldMaintenanceModel::APP... | Overrule to implement snippet specific filtering and sorting.
@param \MUtil_Model_ModelAbstract $model | entailment |
protected function _toNavigationArray(\Gems_Menu_ParameterCollector $source)
{
$result = parent::_toNavigationArray($source);
$store = self::_getSessionStore($this->get('label'));
if (isset($store->controller)) {
foreach ($result['pages'] as $page) {
if ($page['... | Returns a \Zend_Navigation creation array for this menu item, with
sub menu items in 'pages'
@param \Gems_Menu_ParameterCollector $source
@return array | entailment |
protected function applyAcl(\MUtil_Acl $acl, $userRole)
{
parent::applyAcl($acl, $userRole);
if ($this->isVisible()) {
$this->set('allowed', false);
$this->set('visible', false);
if ($this->_subItems) {
foreach ($this->_subItems as $item) {
... | Set the visibility of the menu item and any sub items in accordance
with the specified user role.
@param \Zend_Acl $acl
@param string $userRole
@return \Gems_Menu_MenuAbstract (continuation pattern) | entailment |
protected function setBranchVisible(array $activeBranch)
{
parent::setBranchVisible($activeBranch);
$child = end($activeBranch);
$store = self::_getSessionStore($this->get('label'));
$contr = $child->get('controller');
$action = $child->get('action');
$store->con... | Make sure only the active branch is visible
@param array $activeBranch Of \Gems_Menu_Menu Abstract items
@return \Gems_Menu_MenuAbstract (continuation pattern) | entailment |
public function createModel($detailed, $action)
{
$model = new \Gems\Model\ExportDbaModel($this->db, $this->escort->getDatabasePaths());
if ($this->project->databaseFileEncoding) {
$model->setFileEncoding($this->project->databaseFileEncoding);
}
$model->set('name', 'label... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
public function backupAction()
{
$filter = $this->getSearchFilter();
$model = $this->getModel();
$tables = $model->load();
$allTables = [];
$noDataTables = [];
foreach($tables as $table) {
if ($table['type'] == 'view' && (!array_key_exists('include_views'... | Action for the actual backup of the database | entailment |
protected function getDatabaseConfig()
{
$config = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$resources = $config->getOption('resources');
$dbConfig = [
'driver' => $resources['db']['adapter'],
'hostname' => $resources['db']['params']['host'],
... | Get the current database config, including a DSN
@return array | entailment |
protected function getBackupFilename($filter)
{
$directory = GEMS_ROOT_DIR . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'backup';
\MUtil_File::ensureDir($directory);
$directory .= DIRECTORY_SEPARATOR;
$backupName = 'gems_backup_';
if (!array_key_exists('include_re... | Get the string name of the backup file.
With current settings this file will be written in /var/backup/gems_backup_YYYYMMDD.sql or
/var/backup/gems_backup_no_respondent_data_YYYYMMDD.sql if respondent data is not included
@param $filter
@return string
@throws Zend_Exception | entailment |
public function getSearchFilter($useRequest = true)
{
$filter = parent::getSearchFilter($useRequest);
if (!array_key_exists('include_views', $filter) || $filter['include_views'] != '1') {
$filter['type'] = 'table';
}
return $filter;
} | Get the filter to use with the model for searching including model sorts, etc..
@param boolean $useRequest Use the request as source (when false, the session is used)
@return array or false | entailment |
public function visualBoolean($value)
{
if ($value === true) {
//return '<i>O</i>';
return \MUtil_Html::create()->i(['class' => 'fa fa-check', 'style' => 'color: green;']);
}
return \MUtil_Html::create()->i(['class' => 'fa fa-times', 'style' => 'color: red;']);
} | Show a check or cross for true or false values
@param bool $value
@return mixed | entailment |
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
if ($model->has('row_class')) {
$bridge->getTable()->tbody()->getFirst(true)->appendAttrib('class', $bridge->row_class);
}
if ($this->showMenu) {
$s... | Adds columns from the model to the bridge that creates the browse table.
Overrule this function to add different columns to the browse table, without
having to recode the core table building code.
@param \MUtil_Model_Bridge_TableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@return void | entailment |
public function createModel($detailed, $action)
{
$model = new \MUtil_Model_FolderModel(
$this->getPath($detailed, $action),
$this->getMask($detailed, $action),
$this->recursive
);
if ($this->recursive) {
$model->set('relpa... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
public function deleteAction()
{
$request = $this->getRequest();
$model = $this->getModel();
$model->applyRequest($request);
if ($model->getFilter()) {
$model->delete();
} else {
$this->addMessage($this->_('Empty delete request not allowed'));
... | Confirm has been moved to javascript | entailment |
public function getOnEmptyText()
{
static $warned;
$dir = $this->getPath(false, 'index');
if (! is_dir($dir)) {
try {
\MUtil_File::ensureDir($dir);
} catch (\Zend_Exception $e) {
$text = $e->getMessage();
if (! $warn... | Returns the on empty texts for the autofilter snippets
@static boolean $warned Listen very closely. I shall tell this only once!
@return string | entailment |
public function importAction()
{
$id = $this->_getIdParam();
$model = $this->getModel();
$data = $model->loadFirst(array('urlpath' => $id));
if (! ($data && isset($data['fullpath']))) {
$this->addMessage(sprintf($this->_('File "%s" not found on the server.'), $id));
... | Import the file | entailment |
public function processTokenData(\Gems_Tracker_Token $token)
{
if (! $token->getReceptionCode()->isSuccess()) {
return;
}
$answers = $token->getRawAnswers();
if (isset($answers['informedconsent'])) {
$consent = $this->util->getConsent($answers['informedconsen... | Process the data and return the answers that should be changed.
Storing the changed values is handled by the calling function.
@param \Gems_Tracker_Token $token Gems token object
@return array Containing the changed values | entailment |
public function filter($value)
{
// perform some transformation upon $value to arrive on $valueFiltered
$valueFiltered = strtoupper(trim($value));
if (strlen($valueFiltered) == 6) {
if (preg_match('/\d{4,4}[A-Z]{2,2}/', $valueFiltered)) {
$valueFiltered = su... | Returns the result of filtering $value
@param mixed $value
@throws \Zend_Filter_Exception If filtering $value is impossible
@return mixed | entailment |
public function getFormElements(&$form, &$data)
{
$element = $form->createElement('multiCheckbox', 'format');
$element->setLabel($this->_('Excel options'))
->setMultiOptions(array(
'formatVariable'=> $this->_('Export labels instead of field names'),
... | form elements for extra options for this particular export option
@param \MUtil_Form $form Current form to add the form elements
@param array $data current options set in the form
@return array Form elements | entailment |
protected function addheader($filename)
{
$tempFilename = str_replace($this->fileExtension, '', $filename);
$headerFilename = $tempFilename . '_header' . $this->fileExtension;
$exportName = $this->getName();
$writer = WriterFactory::create(Type::XLSX);
$writer->openToFile(... | Add headers to a specific file
@param string $filename The temporary filename while the file is being written | entailment |
public function addRows($data, $modelId, $tempFilename, $filter)
{
$this->data = $data;
$this->modelId = $modelId;
$this->model = $this->getModel();
if ($this->model) {
$this->model->setFilter($filter + $this->model->getFilter());
if ($this->batch) {
... | Add model rows to file. Can be batched
@param array $data Data submitted by export form
@param array $modelId Model Id when multiple models are passed
@param string $tempFilename The temporary filename while the file is being written
@param array $filter ... | entailment |
public function addRowWithCount($row, $writer, $rowNumber)
{
$exportRow = $this->filterRow($row);
$labeledCols = $this->getLabeledColumns();
$exportRow = array_replace(array_flip($labeledCols), $exportRow);
$writer->addRow($exportRow);
} | Add a separate row to a file
@param array $row a row in the model
@param file $file The already opened file | entailment |
public function addFooter($filename, $modelId = null)
{
parent::addFooter($filename, $modelId);
$this->model = $this->getModel();
$writer = WriterFactory::create(Type::XLSX);
$writer->openToFile($filename);
$tempFilename = str_replace($this->fileExtension, '', $file... | Add a footer to a specific file
@param string $filename The temporary filename while the file is being written | entailment |
public function createExcelDate(\DateTime $date)
{
$day = clone $date;
$endDate = $day->setTime(0, 0, 0);
$startDate = new \DateTime('1970-01-01 00:00:00');
$diff = $endDate->diff($startDate)->format('%a');
if ($endDate < $startDate) {
$daysBetween = 25569 - $dif... | Create Excel date stamp from DateTime
@param \DateTime $date
@return float number of days since 1900-01-00 | entailment |
protected function preprocessModel()
{
parent::preprocessModel();
$labeledCols = $this->getLabeledColumns();
foreach($labeledCols as $columnName) {
$options = array();
$type = $this->model->get($columnName, 'type');
switch ($type) {
case \... | Preprocess the model to add specific options | entailment |
public function getSqlAppointmentsWhere()
{
if ($this->_locations && ($this->_locations !== true)) {
$where = 'gap_id_location IN (' . implode(', ', $this->_locations) . ')';
} else {
$where = '';
}
if ($where) {
return "($where)";
} else {... | Generate a where statement to filter the appointment model
@return string | entailment |
public function matchAppointment(\Gems_Agenda_Appointment $appointment)
{
if (true !== $this->_locations) {
if (isset($this->_locations[$appointment->getLocationId()])) {
return true;
}
}
return false;
} | Check a filter for a match
@param \Gems\Agenda\Gems_Agenda_Appointment $appointment
@return boolean | entailment |
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
{
if ($this->request) {
$this->processSortOnly($model);
$model->setFilter(array('gto_id_token' => $this->token->getTokenId()));
}
} | Overrule to implement snippet specific filtering and sorting.
@param \MUtil_Model_ModelAbstract $model | entailment |
public function createModel($detailed, $action)
{
$filter = $this->getSearchFilter($action !== 'export');
// Return empty model when no track sel;ected
if (! (isset($filter['gtf_id_track']) && $filter['gtf_id_track'])) {
$model = new \Gems_Model_JoinModel('trackfields' , 'gems__... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
public function emptyCount($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
{
$value = $this->trackCount - $this->trackFilled;
return sprintf(
$this->_('%d (%d%%)'),
$value,
$this->trackCount ? round($value / $this->trac... | A ModelAbstract->setOnLoad() function that takes care of transforming a
dateformat read from the database to a \Zend_Date format
If empty or \Zend_Db_Expression (after save) it will return just the value
currently there are no checks for a valid date format.
@see \MUtil_Model_ModelAbstract
@param mixed $value The va... | entailment |
public function fillCount($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
{
$model = $this->engine->getFieldsDataStorageModel();
if (! $model instanceof FieldDataModel) {
return null;
}
$subName = $model->getModelNameForRow($context);
... | A ModelAbstract->setOnLoad() function that takes care of transforming a
dateformat read from the database to a \Zend_Date format
If empty or \Zend_Db_Expression (after save) it will return just the value
currently there are no checks for a valid date format.
@see \MUtil_Model_ModelAbstract
@param mixed $value The va... | entailment |
public function getSearchDefaults()
{
if (! isset($this->defaultSearchData['gr2t_id_organization'])) {
$orgs = $this->currentUser->getRespondentOrganizations();
$this->defaultSearchData['gr2t_id_organization'] = array_keys($orgs);
}
if (!isset($this->defaultS... | Function to allow the creation of search defaults in code
@see getSearchFilter()
@return array | entailment |
public function copyAction()
{
$trackId = $this->_getIdParam();
$engine = $this->getTrackEngine();
$newTrackId = $engine->copyTrack($trackId);
$this->_reroute(array('action' => 'edit', \MUtil_Model::REQUEST_ID => $newTrackId));
} | Action for making a copy of a track | entailment |
public function checkAllAction()
{
$batch = $this->loader->getTracker()->checkTrackRounds('trackCheckRoundsAll', $this->currentUser->getUserId());
$this->_helper->BatchRunner($batch, $this->_('Checking round assignments for all tracks.'), $this->accesslog);
$this->addSnippet('Track\\CheckRo... | Action for checking all assigned rounds using a batch | entailment |
public function checkTrackAction()
{
$id = $this->_getIdParam();
$track = $this->getTrackEngine();
$where = $this->db->quoteInto('gr2t_id_track = ?', $id);
$batch = $this->loader->getTracker()->checkTrackRounds(
'trackCheckRounds' . $id,
$this->curr... | Action for checking all assigned rounds for a single track using a batch | entailment |
public function createModel($detailed, $action)
{
$tracker = $this->loader->getTracker();
$model = $tracker->getTrackModel();
$model->applyFormatting($detailed);
$model->addFilter(array("gtr_track_class != 'SingleSurveyEngine'"));
return $model;
} | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
public function exportAction()
{
if ($this->exportSnippets) {
$params = $this->_processParameters($this->exportParameters);
$this->addSnippets($this->exportSnippets, $params);
}
} | Generic model based export action | entailment |
public function getSearchFilter($useRequest = true)
{
$filter = parent::getSearchFilter($useRequest);
if (isset($filter['org']) && strlen($filter['org'])) {
$filter[] = 'gtr_organizations LIKE "%|' . $filter['org'] . '|%"';
unset($filter['org']);
}
return $f... | Get the filter to use with the model for searching including model sorts, etc..
@param boolean $useRequest Use the request as source (when false, the session is used)
@return array or false | entailment |
public function recalcAllFieldsAction()
{
$batch = $this->loader->getTracker()->recalcTrackFields(
'trackRecalcAllFields'
);
$this->_helper->BatchRunner($batch, $this->_('Recalculating fields for all tracks.'), $this->accesslog);
$this->addSnippet('Track\\Rec... | Action for checking all assigned rounds using a batch | entailment |
public function recalcFieldsAction()
{
$id = $this->_getIdParam();
$track = $this->getTrackEngine();
$where = $this->db->quoteInto('gr2t_id_track = ?', $id);
$batch = $this->loader->getTracker()->recalcTrackFields(
'trackRecalcFields' . $id,
$where
... | Action for checking all assigned rounds for a single track using a batch | entailment |
public function showAction()
{
$showSnippets = $this->showSnippets;
$first = array_shift($showSnippets);
$next = $showSnippets;
$this->showSnippets = $first;
parent::showAction();
$this->showParameters['tagName'] = 'h3';
$this->show... | Pass the h3 tag to all snippets except the first one | entailment |
public function getCronBatch($id = 'cron')
{
$batch = $this->loader->getTaskRunnerBatch($id);
$batch->setMessageLogFile($this->project->getCronLogfile());
$batch->minimalStepDurationMs = 3000; // 3 seconds max before sending feedback
if (! $batch->isLoaded()) {
$this->lo... | Perform automatic job mail | entailment |
public function getMailer($target = null, $id = false, $orgId = false)
{
if(isset($this->mailTargets[$target])) {
$target = ucfirst($target);
return $this->_loadClass($target.'Mailer', true, array($id, $orgId));
} else {
return false;
}
} | Get the correct mailer class from the given target
@param [type] $target mailtarget (lowercase)
@param array $identifiers the identifiers needed for the specific mailtargets
@return \Gems_Mail_MailerAbstract class | entailment |
protected function loadCronBatch(\Gems_Task_TaskRunnerBatch $batch)
{
$batch->addMessage(sprintf($this->_("Starting %s mail jobs"), $this->project->getName()));
$batch->addTask('Mail\\AddAllMailJobsTask');
// Check for unprocessed tokens,
$tracker = $this->loader->getTracker();
... | Perform the actions and load the tasks needed to start the cron batch
@param \Gems_Task_TaskRunnerBatch $batch | entailment |
protected function _load(array $filter, array $sort)
{
$result = array();
foreach ($this->getItemsOrdered() as $item) {
$result[0][$item] = $item;
}
return $result;
} | Returns a nested array containing the items requested.
@param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters
@param array $sort Sort array field name => sort type
@return array Nested array or false | entailment |
protected function inlineIssueLink($excerpt)
{
if (preg_match('/([\p{L}\p{N}_-]*)\/?([\p{L}\p{N}_-]*)#(\d+)/ui', $excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) {
if (!empty($matches[1][0])) {
$project = $matches[1][0] . '/' . $matches[2][0];
} else {
... | Find links to issue on github
organization/repository#<issue> or #<issue>
@param array $excerpt
@return array | entailment |
public function isValid($value, $context = array())
{
$user = $this->_userSource->getUser();
if ($user instanceof \Gems_User_User) {
$result = $user->authenticate($value);
} else {
$result = new Result(Result::FAILURE_UNCATEGORIZED, null);
}
return $t... | Returns true if and only if $value meets the validation requirements
If $value fails validation, then this method returns false, and
getMessages() will return an array of messages that explain why the
validation failed.
@param mixed $value
@param mixed $content
@return boolean
@throws \Zend_Validate_Exception If va... | entailment |
protected function findRespondentTrackFor(array $row)
{
if (! (isset($row[$this->patientNrField], $row[$this->orgIdField]) &&
$row[$this->patientNrField] &&
$row[$this->orgIdField])) {
return null;
}
$trackId = $this->getTrackId();
if (! $... | If the token can be created find the respondent track for the token
@param array $row
@return int|null | entailment |
protected function findTokenFor(array $row)
{
if (! (isset($row[$this->patientNrField], $row[$this->orgIdField]) &&
$row[$this->patientNrField] &&
$row[$this->orgIdField] &&
$this->getSurveyId())) {
return null;
}
$select = $this->... | Find the token id using the passed row data and
the other translator parameters.
@param array $row
@return string|null | entailment |
public function getRespondentAnswerTranslations()
{
$this->_targetModel->set($this->patientNrField, 'label', $this->_('Patient ID'),
'order', 5,
'required', true,
'type', \MUtil_Model::TYPE_STRING
);
$this->_targetModel->set($this->orgI... | Get information on the field translations
@return array of fields sourceName => targetName
@throws \MUtil_Model_ModelException | entailment |
public function getFieldsTranslations()
{
if (! $this->_targetModel instanceof \MUtil_Model_ModelAbstract) {
throw new \MUtil_Model_ModelTranslateException(sprintf('Called %s without a set target model.', __FUNCTION__));
}
// \MUtil_Echo::track($this->_targetModel->getItemNames()... | Get information on the field translations
@return array of fields sourceName => targetName
@throws \MUtil_Model_ModelException | entailment |
public function getNoTokenError(array $row, $key)
{
$messages = array();
if (! (isset($row[$this->patientNrField]) && $row[$this->patientNrField])) {
$messages[] = sprintf($this->_('Missing respondent number in %s field.'), $this->patientNrField);
}
if (! (isset($row[$thi... | Get the error message for when no token exists
@return string | entailment |
public function processTokenInsertion(\Gems_Tracker_Token $token)
{
$this->token = $token;
if ($token->getReceptionCode()->isSuccess() && (!$token->isCompleted())) {
// Read questioncodes
$questions = $token->getSurvey()->getQuestionList(null);
$fields = [];
... | Process the data and return the answers that should be filled in beforehand.
Storing the changed values is handled by the calling function.
@param \Gems_Tracker_Token $token Gems token object
@return array Containing the changed values | entailment |
public function getCopyFields($requests)
{
$prefix = 'CP';
$token = $this->token;
$surveyCode = $token->getSurvey()->getCode();
$surveyId = $token->getSurveyId();
$flipRequests = array_flip($requests);
// Check from the last token back, we need to find th... | Tries to fulfill request to copy fields
Copy fields will be fulfilled by searching the track in reverse
- first to see if there is a field without the CP prefix
- then if there are fields with the CP prefix
And only return the match when (in the end) ALL fields are found. If not
it will start again for the next answer... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.