sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function execute($trackId = null, $exportOrganizations = false)
{
$versions = $this->loader->getVersions();
$data = array(
'gems_version' => $versions->getGemsVersion(),
'project' => $this->project->getName(),
'project_env' => APPLICATION_EN... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task | entailment |
public function addSaveTask(\MUtil_Task_TaskBatch $importBatch, $key, array $row)
{
$importBatch->setTask(
$this->saveTask,
'import-' . $key,
$key,
$this->getNoToken(),
$this->getTokenCompleted()
);
retu... | Add the current row to a (possibly separate) batch that does the importing.
@param \MUtil_Task_TaskBatch $importBatch The import batch to impor this row into
@param string $key The current iterator key
@param array $row translated and validated row
@return \MUtil_Model_ModelTranslatorAbstract (continuation pattern) | entailment |
public function afterRegistry()
{
parent::afterRegistry();
$this->orgTranslations = $this->db->fetchPairs('
SELECT gor_provider_id, gor_id_organization
FROM gems__organizations
WHERE gor_provider_id IS NOT NULL
ORDER BY gor_provider_id');
... | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function checkPatient($patientNr, $orgId)
{
if (! ($patientNr && $orgId)) {
return false;
}
$select = $this->db->select();
$select->from('gems__respondent2org', array('gr2o_id_user'))
->where('gr2o_patient_nr = ?', $patientNr)
->where('g... | Check should a patient be imported
@param string $patientNr
@param int $orgId
@return boolean | entailment |
public function getFieldsTranslations()
{
$this->_targetModel->set('completion_date', 'label', $this->_('Completion date'),
'order', 9,
'type', \MUtil_Model::TYPE_DATETIME
);
$fieldList = array('completion_date' => 'completion_date');
foreach... | 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;
}
// Get the real organization from the provider_id or code if it exists
if (isset($row[$this->orgIdField], $this->orgTranslations[$row[$t... | 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 validateRowValues(array $row, $key)
{
$row = parent::validateRowValues($row, $key);
$token = $this->loader->getTracker()->getToken($row['token'] ? $row['token'] : 'emptytoken');
if ($token->exists) {
// If token is not completed we can use it, otherwise it depen... | Validate the data against the target form
@param array $row
@param scalar $key
@return mixed Row array or false when errors occurred | entailment |
protected function createModel()
{
$model = $this->loader->getTracker()->getRespondentTrackModel();
$model->set('gtr_track_name', 'label', $this->_('Track'));
$model->set('gr2t_track_info', 'label', $this->_('Description'),
'description', $this->_('Enter the particulars con... | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$seq = $this->getHtmlSequence();
$seq->h3($this->getTitle());
$table = parent::getHtmlOutput($view);
$this->applyHtmlAttributes($table);
$seq->append($table);
return $seq;
} | 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 |
protected function getRespondentName()
{
if ($this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) {
return $this->respondentTrack->getRespondentName();
} else {
$select = $this->db->select();
$select->from('gems__respondents')
->joi... | Get a display version of the patient name
@return string | entailment |
public function hasHtmlOutput()
{
// Try to set $this->respondentTrackId, it can be ok when not set
if (! $this->respondentTrackId) {
if ($this->respondentTrack) {
$this->respondentTrackId = $this->respondentTrack->getRespondentTrackId();
} else {
... | The place to check if the data set in the snippet is valid
to generate the snippet.
When invalid data should result in an error, you can throw it
here but you can also perform the check in the
checkRegistryRequestsAnswers() function from the
{@see \MUtil_Registry_TargetInterface}.
@return boolean | entailment |
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
{
if ($this->request) {
$this->processSortOnly($model);
}
$filter['gtr_id_track'] = $this->trackId;
$filter['gr2o_patient_nr'] = $this->patientId;
$filter['gr2o_id_organizatio... | Overrule to implement snippet specific filtering and sorting.
@param \MUtil_Model_ModelAbstract $model | entailment |
public function execute($tokenData = null, $userId = null)
{
$tracker = $this->loader->getTracker();
$token = $tracker->getToken($tokenData[0]);
$survey = $token->getSurvey();
$source = $survey->getSource();
if (method_exists($source, 'getCompletedTokens')) {
... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task | entailment |
protected function addNextButton()
{
parent::addNextButton();
if (! (isset($this->formData['survey']) && $this->formData['survey'])) {
$this->_nextButton->setAttrib('disabled', 'disabled');
}
} | Add the next button | entailment |
protected function createModel()
{
if (! $this->importModel instanceof \MUtil_Model_ModelAbstract) {
$surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
if ($surveyId) {
$this->formData['survey'] = $surveyId;
$this->_survey = $t... | Called after the check that all required registry values
have been set correctly has run.
@return void
/
public function afterRegistry()
{
parent::afterRegistry();
}
Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
protected function getFormFor($step)
{
$model = $this->getModel();
$baseform = $this->createForm();
if ((\MUtil_Bootstrap::enabled() !== true) && ($baseform instanceof \MUtil_Form)) {
$table = new \MUtil_Html_TableElement();
$table->setAsFormLayout($baseform, true... | Creates from the model a \Zend_Form using createForm and adds elements
using addFormElements().
@param int $step The current step
@return \Zend_Form | entailment |
protected function getImportTranslator()
{
$translator = parent::getImportTranslator();
if ($translator instanceof \Gems_Model_Translator_AnswerTranslatorAbstract) {
// Set answer specific options
$surveyId = isset($this->formData['survey']) ? $this->formData['survey'] : nul... | Try to get the current translator
@return \MUtil_Model_ModelTranslatorInterface or false if none is current | entailment |
protected function loadFormData()
{
parent::loadFormData();
$surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
if (isset($this->formData['survey']) &&
$this->formData['survey'] &&
(! $this->_survey instanceof \Gems_Tracker_Survey)) {
... | Hook that loads the form data from $_POST or the model
Or from whatever other source you specify here. | entailment |
public function execute($surveyId = null, $questionId = null, $order = null)
{
$batch = $this->getBatch();
$survey = $this->loader->getTracker()->getSurvey($surveyId);
// Now save the questions
$answerModel = $survey->getAnswerModel('en');
$questionModel = new \MUtil_Mode... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task | entailment |
protected function _applyOptions(\MUtil_Model_ModelAbstract $model, $fieldName, array $options, array &$itemData)
{
if ($options) {
$model->set($fieldName, 'multiOptions', $options);
if (! array_key_exists($itemData[$fieldName], $options)) {
// Set the value to the f... | Helper function for default handling of multi options value sets
@param \MUtil_Model_ModelAbstract $model
@param string $fieldName
@param array $options
@param array $itemData The current items data
@param boolean True if the update changed values (usually by changed selection lists). | entailment |
protected function _sourceUsesSurvey($source)
{
switch ($source) {
case self::APPOINTMENT_TABLE:
case self::NO_TABLE:
case self::RESPONDENT_TRACK_TABLE:
return false;
default:
return true;
}
} | Returns true if the source uses values from another token.
@param string $source The current source
@return boolean | entailment |
protected function applyDatesValidAfter(\MUtil_Model_ModelAbstract $model, array &$itemData, $language)
{
// Set the after date fields that can be chosen for the current values
$dateOptions = $this->getDateOptionsFor($itemData['gro_valid_after_source'], $itemData['gro_valid_after_id'], $language, tr... | Set the after dates to be listed for this item and the way they are displayed (if at all)
@param \MUtil_Model_ModelAbstract $model The round model
@param array $itemData The current items data
@param string $language (ISO) language string
@param boolean True if the update changed values (usually by changed select... | entailment |
protected function applyDatesValidFor(\MUtil_Model_ModelAbstract $model, array &$itemData, $language)
{
$dateOptions = $this->getDateOptionsFor($itemData['gro_valid_for_source'], $itemData['gro_valid_for_id'], $language, true);
if ($itemData['gro_id_round'] == $itemData['gro_valid_for_id']) {
... | Set the for dates to be listed for this item and the way they are displayed (if at all)
@param \MUtil_Model_ModelAbstract $model The round model
@param array $itemData The current items data
@param string $language (ISO) language string
@param boolean True if the update changed values (usually by changed selectio... | entailment |
protected function applyRespondentRelation(\MUtil_Model_ModelAbstract $model, array &$itemData)
{
$model->set('gro_id_survey', 'onchange', 'this.form.submit();');
if (!empty($itemData['gro_id_survey']) && $model->has('gro_id_relationfield')) {
$forStaff = $this->tracker->getSurvey($itemD... | Apply respondent relation settings to the round model
For respondent surveys, we allow to set a relation, with possible choices:
null => the respondent
0 => undefined (specifiy when assigning)
>0 => the id of the track field of type relation to use
@param \MUtil_Model_ModelAbstract $model The round model
@param... | entailment |
protected function checkTokenCondition(\GemS_Tracker_Token $token, $round, $userId)
{
$skipCode = $this->util->getReceptionCodeLibrary()->getSkipString();
// Only if we have a condition, the token is not yet completed and
// receptioncode is ok or skip we evaluate the condition
... | Check if the token should be enabled / disabled due to conditions
@param \GemS_Tracker_Token $token
@param array $round
@param int $userId Id of the user who takes the action (for logging)
@return int The number of tokens changed by this code | entailment |
protected function checkTokenDates($token, $round, $userId)
{
// Change only not-completed tokens with a positive successcode where at least one date
// is not set by user input
if ($token->isCompleted() || !$token->getReceptionCode()->isSuccess() || ($token->isValidFromManual() && $token->i... | Check the valid from and until dates for this token
@param \GemS_Tracker_Token $token
@param array $round
@param int $userId Id of the user who takes the action (for logging)
@return int 1 if the token has changed | entailment |
public function checkTokensFrom(\Gems_Tracker_RespondentTrack $respTrack, \Gems_Tracker_Token $startToken, $userId, \Gems_Tracker_Token $skipToken = null)
{
// Make sure the rounds are loaded
$this->_ensureRounds();
// Make sure the tokens are loaded and linked.
$respTrack->getToken... | Check the valid from and until dates in the track starting at a specified token
@param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
@param \Gems_Tracker_Token $startToken The token to start at
@param int $userId Id of the user who takes the action (for logging)
@param \Gems_Tracker_Token $ski... | entailment |
public function checkTokensFromStart(\Gems_Tracker_RespondentTrack $respTrack, $userId)
{
$token = $respTrack->getFirstToken();
if ($token instanceof \Gems_Tracker_Token) {
return $this->checkTokensFrom($respTrack, $respTrack->getFirstToken(), $userId);
} else {
retur... | Check the valid from and until dates in the track
@param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
@param int $userId Id of the user who takes the action (for logging)
@return int The number of tokens changed by this code | entailment |
public function displayDateCalculation($value, $new, $name, array $context = array())
{
$fieldBase = substr($name, 0, -5); // Strip field
$validAfter = (bool) strpos($fieldBase, 'after');
// When always valid, just return nothing
if ($context[$fieldBase . 'source'] == self::NO_TABL... | Changes the display of gro_valid_[after|for]_field into something readable
@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 string The value to use | entailment |
public function displayRoundId($value, $new, $name, array $context = array())
{
$fieldSource = substr($name, 0, -2) . 'source';
if ($this->_sourceUsesSurvey($context[$fieldSource])) {
return $value;
}
return '';
} | Changes the display of gro_valid_[for|after]_id into something readable
Makes it empty when not applicable
@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
... | entailment |
protected function getDateOptionsFor($sourceType, $roundId, $language, $validAfter)
{
switch ($sourceType) {
case self::NO_TABLE:
return array();
case self::ANSWER_TABLE:
if (! isset($this->_rounds[$roundId], $this->_rounds[$roundId]['gro_id_survey'])... | Returns the date fields selectable using the current source
@param string $source The date list source as defined by this object
@param int $roundId Gems round id
@param string $language (ISO) language string
@param boolean $validAfter True if it concenrs _valid_after_ dates
@return type | entailment |
public function getRespondentRelationFields() {
$fields = array();
$relationFields = $this->getFieldsOfType('relation');
if (!empty($relationFields)) {
$fieldNames = $this->getFieldNames();
$fieldPrefix = FieldMaintenanceModel::FIELDS_NAME . FieldsDefinition::FIELD_KEY_S... | Get all respondent relation fields
Returns an array of field id => field name
@return array | entailment |
public function getRoundModel($detailed, $action)
{
$model = parent::getRoundModel($detailed, $action);
// Add information about surveys and groups
$model->addLeftTable('gems__surveys', array('gro_id_survey' => 'gsu_id_survey'));
$model->addLeftTable('gems__groups', array('gsu_id_pr... | Returns a model that can be used to retrieve or save the data.
@param boolean $detailed Create a model for the display of detailed item data or just a browse table
@param string $action The current action
@return \MUtil_Model_ModelAbstract | entailment |
protected function getSourceList($validAfter, $firstRound, $detailed = true)
{
if (! ($validAfter || $this->project->isValidUntilRequired())) {
$results[self::NO_TABLE] = array($this->_('Does not expire'));
}
if (! ($validAfter && $firstRound)) {
$results[self::ANSWER... | Returns the source choices in an array.
@param boolean $validAfter True if it concerns _valid_after_ dates
@param boolean $firstRound List for first round
@param boolean $detailed Return extended info
@return array source_name => label | entailment |
protected function getSurveyId($roundId)
{
$this->_ensureRounds();
if (isset($this->_rounds[$roundId]['gro_id_survey'])) {
return $this->_rounds[$roundId]['gro_id_survey'];
}
throw new \Gems_Exception_Coding("Requested non existing survey id for round $roundId.");
} | Look up the survey id associated with a round
@param int $roundId Gems round id
@return int Gems survey id | entailment |
public function getTokenShowSnippetNames(\Gems_Tracker_Token $token)
{
$output[] = 'Token\\ShowTrackTokenSnippet';
if ($token->isCompleted() && $this->currentUser->hasPrivilege('pr.token.answers')) {
$output[] = 'Tracker_Answers_SingleTokenAnswerModelSnippet';
} elseif ($this->c... | An array of snippet names for displaying a token
@param \Gems_Tracker_Token $token Allows token status dependent show snippets
@return array of string snippet names | entailment |
protected function setDateListFor(\MUtil_Model_ModelAbstract $model, $fieldName, $source, $roundId, $language, $validAfter)
{
$dateOptions = $this->getDateOptionsFor($source, $roundId, $language, $validAfter);
switch (count($dateOptions)) {
case 0:
$model->del($fieldName... | The logic to set the display of the valid_X_field date list field.
@param \MUtil_Model_ModelAbstract $model The round model
@param string $fieldName The valid_X_field to set
@param string $source The date list source as defined by this object
@param int $roundId Optional a round id
@param string $language (ISO) lang... | entailment |
public function updateRoundModelToItem(\MUtil_Model_ModelAbstract $model, array &$itemData, $language)
{
$this->_ensureRounds();
// Is this the first token?
$first = ! $this->getPreviousRoundId($itemData['gro_id_round'], $itemData['gro_id_order']);
// Update the current round data... | Updates the model to reflect the values for the current item data
@param \MUtil_Model_ModelAbstract $model The round model
@param array $itemData The current items data
@param string $language (ISO) language string
@param boolean True if the update changed values (usually by changed selection lists). | entailment |
public function createActionButtons(\MUtil_Model_Bridge_TableBridge $bridge)
{
$tData = $this->util->getTokenData();
// Action links
$actionLinks['ask'] = $tData->getTokenAskLinkForBridge($bridge, true);
$actionLinks['email'] = $tData->getTokenEmailLinkForBridge($bridge);
... | Return a list of possible action buttons for the token
@param \MUtil_Model_Bridge_TableBridge $bridge
@return array of HtmlElements | entailment |
protected function createInfoPlusCol(\MUtil_Model_Bridge_TableBridge $bridge)
{
$tData = $this->util->getTokenData();
return [
'class' => 'text-right',
$tData->getTokenStatusLinkForBridge($bridge),
' ',
$tData->getTokenShowLinkForBridge($bridge, true)... | Returns a '+' token button
@param \MUtil_Model_Bridge_TableBridge $bridge
@return \MUtil_Html_AElement | entailment |
protected function createShowTokenButton(\MUtil_Model_Bridge_TableBridge $bridge)
{
$link = $this->util->getTokenData()->getTokenShowLinkForBridge($bridge, true);
if ($link) {
return $link;
}
} | Returns a '+' token button
@param \MUtil_Model_Bridge_TableBridge $bridge
@return \MUtil_Html_AElement | entailment |
public function execute($trackId = null)
{
$batch = $this->getBatch();
$select = $this->db->select();
// Join conditions on rounds, handle and / or conditions when implemented
$select->from('gems__conditions', array(
'gcon_id', 'gcon_type', 'gcon_class', 'gcon_name', 'gc... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task | entailment |
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$tData = $this->util->getTokenData();
// Signal the bridge that we need these values
$bridge->gr2t_id_respondent_track;
$bridge->gr2o_patient_nr;
$bridge->... | 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 getHtmlOutput(\Zend_View_Abstract $view)
{
$table = parent::getHtmlOutput($view);
$table->class = $this->class;
$this->applyHtmlAttributes($table);
$this->class = false;
$tableContainer = \MUtil_Html::create()->div(array('class' => 'table-container'), $table)... | 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 hasHtmlOutput()
{
if (! $this->respondentTrackId) {
if (isset($this->trackData['gr2t_id_respondent_track'])) {
$this->respondentTrackId = $this->trackData['gr2t_id_respondent_track'];
} elseif (isset($this->trackData['gto_id_respondent_track'])) {
... | The place to check if the data set in the snippet is valid
to generate the snippet.
When invalid data should result in an error, you can throw it
here but you can also perform the check in the
checkRegistryRequestsAnswers() function from the
{@see \MUtil_Registry_TargetInterface}.
@return boolean | entailment |
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
{
$model->setFilter(array('gto_id_respondent_track' => $this->respondentTrackId));
$this->processSortOnly($model);
} | Overrule to implement snippet specific filtering and sorting.
@param \MUtil_Model_ModelAbstract $model | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$tabs = $this->getTabs();
$tabCount = count($tabs);
if ($tabs && ($this->displaySingleTab || $tabCount > 1)) {
// Is there a better helper to include JS?
$view->headScript()->appendFile($this->basepa... | 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 |
protected function createEditPrepare()
{
$this->createEditSnippets = $this->getTrackEngine()->getRoundEditSnippetNames();
\MUtil_JQuery::enableView($this->view);
$this->view->headScript()->appendFile($this->basepath->getBasePath() . '/gems/js/jquery.showOnChecked.js');
if (\MUtil... | Preparations for creating and editing | entailment |
public function createModel($detailed, $action)
{
$trackEngine = $this->getTrackEngine();
$trackId = $trackEngine->getTrackId();
$model = $trackEngine->getRoundModel($detailed, $action);
$model->set('gro_id_track', 'default', $trackId);
if ($detailed) {
if (... | 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 setAfterDeleteRoute()
{
parent::setAfterDeleteRoute();
if ($this->afterSaveRouteUrl) {
$this->afterSaveRouteUrl[\Gems_Model::APPOINTMENT_ID] = $this->request->getParam(\Gems_Model::APPOINTMENT_ID);
}
} | Set what to do when the form is 'finished'.
@return \MUtil_Snippets_ModelYesNoDeleteSnippetAbstract | entailment |
private function _setMenuParameters(array $data)
{
$source = $this->menu->getParameterSource();
$source['script'] = $data['script'] ? true : false;
$source['exists'] = $data['exists'] ? true : false;
} | Set the parameters needed by the menu.
@param array $data The current model item | entailment |
private function _cleanCache()
{
if ($this->cache instanceof \Zend_Cache_Core) {
$this->cache->clean();
$this->addMessage($this->_('Cache cleaned'));
}
} | Make sure the cache is cleaned.
As a lot of cache depends on the database, it is best to clean the cache
now since import tables might have changed.
@return void | entailment |
public function createModel($detailed, $action)
{
$moreDetails = ! in_array($action, array('run', 'deleted'));
$model = new \Gems_Model_DbaModel($this->db, $this->escort->getDatabasePaths());
if ($this->project->databaseFileEncoding) {
$model->setFileEncoding($this->project->dat... | 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 getShowTable($columns = 1, $filter = null, $sort = null)
{
$model = $this->getModel();
$bridge = $model->getBridgeFor('itemTable');
$bridge->setColumnCount($columns);
foreach($model->getItemsOrdered() as $name) {
if ($label = $model->get($name, 'label'))... | Creates from the model a \MUtil_Html_TableElement for display of a single item.
It can and will display multiple items, but that is not what this function is for.
@param integer $columns The number of columns to use for presentation
@param mixed $filter A valid filter for \MUtil_Model_ModelAbstract->load()
@param mix... | entailment |
public function showChangesAction()
{
$patchLevels = $this->db->fetchPairs('SELECT DISTINCT gpa_level, gpa_level FROM gems__patches ORDER BY gpa_level DESC');
$searchData['gpa_level'] = reset($patchLevels);
if ($this->request instanceof \Zend_Controller_Request_Abstract) {
$sea... | Show the changes in the database | entailment |
private function _setMulti($value, $name1, $name2 = null)
{
$args = func_get_args();
array_shift($args);
foreach ($args as $key) {
$this->offsetSet($key, $value);
}
} | Helper function to set more than one array key to the same value
@param mixed $value The value to set
@param string $name1 The first key to set
@param string $name2 Optional, second key, number of keys is unlimited | entailment |
protected function createRequest($class, array $parameters)
{
if (!isset($parameters['credentials'])) {
$parameters['credentials'] = new Credentials(array_intersect_key($this->getCredentialFields(), $parameters));
}
return new $class($parameters);
} | Initialize a request object
This function is usually used to initialise objects of type
BaseRequest (or a non-abstract subclass of it)
using existing parameters from this gateway.
If a client has been set on this class it will passed through,
allowing a mock guzzle client to be used for testing.
Example:
<code>
fun... | entailment |
public function getTokenElement()
{
$element = $this->getElement($this->_tokenFieldName);
if (! $element) {
$tokenLib = $this->tracker->getTokenLibrary();
$max_length = $tokenLib->getLength();
// Veld token
$element = new \Zend_Form_Element_Text($t... | Returns/sets a password element.
@return \Zend_Form_Element_Password | entailment |
public function addAskPage($label)
{
$page = $this->addPage($label, null, 'ask');
// Routes for token controller
$page->addAction(null, null, 'forward');
$page->addAction(null, null, 'return');
$page->addAction(null, null, 'to-survey')->setModelParameters(1);
$page->... | Shortcut function to create a ask menu, with hidden options.
This function is in \Gems_Menu instead of AbstractMenu because
you should ALWAYS put this menu in the root menu.
@param string $label Label for the whole menu | entailment |
public function addContactPage($label)
{
$project = $this->escort->project;
$page = $this->addPage($label, null, 'contact');
$page->addAction(sprintf($this->_('About %s'), $project->getName()), null, 'about');
$page->addAction(sprintf($this->_('About %s'), $this->_('GemsTracker')),... | Shortcut function to create a contact container.
This function is in \Gems_Menu instead of AbstractMenu because
you should ALWAYS put this menu in the root menu.
@param string $label Label for the whole menu
@return \Gems_Menu_MenuAbstract The new contact page | entailment |
public function addGemsSetupContainer($label)
{
$setup = $this->addContainer($label);
// PROJECT LEVEL
$cont = $setup->addProjectInfoPage($this->_('Project setup'));
// DATABASE CONTROLLER
$page = $setup->addPage($this->_('Database'), 'pr.database', 'database');
$pa... | Shortcut function to create a setup container.
This function is in \Gems_Menu instead of AbstractMenu because
you should ALWAYS put this menu in the root menu.
@param string $label Label for the whole menu
@param string $privilegeShow The limited privilege (look and edit some items)
@param string $privilegeEdits The ... | entailment |
public function addHiddenPrivilege($privilege, $label = null)
{
if (null === $label) {
$label = $this->_('Stand-alone privilege: %s');
}
$this->_hiddenPrivileges[$privilege] = sprintf($label, $privilege);
return $this;
} | Use this to add a privilege that is not associated with a menu item.
@param string $privilege
@param string $label
@return \Gems_Menu | entailment |
public function addOpenRosaContainer($label, $parent = null)
{
if ($this->escort->getOption('useOpenRosa')) {
if (is_null($parent)) {
$parent = $this;
}
$page = $parent->addBrowsePage($label, 'pr.openrosa','openrosa');
$page->addButtonOnly($thi... | Shortcut function to add all items needed for OpenRosa
Should be enabled in application.ini by using useOpenRosa = 1
@param string $label Label for the container | entailment |
public function addParticipatePage($label)
{
$participate = $this->addContainer($label);
$subscr = $participate->addPage($this->_('Subscribe'), 'pr.participate.subscribe', 'participate', 'subscribe');
$subscr->addPage(null, 'pr.participate.subscribe', 'participate', 'subscribe-thanks');
... | Shortcut function to create a participate page
This function is in \Gems_Menu instead of AbstractMenu because
you should ALWAYS put this menu in the root menu.
@param string $label Label for the whole menu | entailment |
public function addRespondentPage($label)
{
$orgId = $this->user->getCurrentOrganizationId();
$params = array(\MUtil_Model::REQUEST_ID1 => 'gr2o_patient_nr', \MUtil_Model::REQUEST_ID2 => 'gr2o_id_organization');
// MAIN RESPONDENTS ITEM
$page = $this->addPage($label, 'pr.responden... | Shortcut function to create the respondent page.
@param string $label Label for the container
@return \Gems_Menu_MenuAbstract The new respondent page | entailment |
public function getCurrentMenuList(\Zend_Controller_Request_Abstract $request, $parentLabel = null)
{
$controller = $request->getControllerName();
$action = $request->getActionName();
$menuList = $this->getMenuList();
if ($controller !== 'index') {
$menuList->addByC... | Menulist populated with current items
@param \Zend_Controller_Request_Abstract $request
@param $parentLabel
@return \Gems_Menu_MenuList | entailment |
public function loadDefaultMenu()
{
// MAIN RESPONDENTS ITEM
$this->addRespondentPage($this->_('Respondents'));
// MAIN CALENDAR ITEM
$this->addCalendarPage($this->_('Calendar'));
// MAIN PLANNING ITEM
$this->addPlanPage($this->_('Overview'));
// PROJECT IN... | This is where we load the default menu, be very careful to overload this function
as it makes upgrading a lot more difficult | entailment |
public function render(\Zend_View_Abstract $view)
{
$request = $this->_getOriginalRequest();
if ($this->_onlyActiveBranchVisible) {
$activePath = $this->_findPath($request);
// \MUtil_Echo::r($activePath);
$this->setBranchVisible($activePath);
}
... | Renders the element into a html string
The $view is used to correctly encode and escape the output
@param \Zend_View_Abstract $view
@return string Correctly encoded and escaped html output | entailment |
protected function renderItems(\MUtil_Html_ListElement $ul, array $items, $cascade)
{
foreach ($items as $item) {
if (isset($item['visible'], $item['label']) && $item['visible'] && $item['label']) {
$url = $item['params'];
$url['controller'] = $item['controller'];... | Helper function to load the menu items to the html element.
Allows overloading by sub classes.
@param \MUtil_Html_ListElement $ul
@param array $items
@param boolean $cascade render nested items | entailment |
public function toActiveBranchElement()
{
$request = $this->_getOriginalRequest();
$activePath = $this->_findPath($request);
if (! $activePath) {
return null;
}
$this->setBranchVisible($activePath);
$activeItem = array_pop($activePath);
if (... | Renders the top level menu items into a html element
@return \MUtil_Html_HtmlElement | entailment |
public function toTopLevelElement()
{
$request = $this->_getOriginalRequest();
$activeItems = $this->_findPath($request);
$this->setBranchVisible($activeItems);
foreach ($activeItems as $activeItem) {
if ($activeItem instanceof \Gems_Menu_SubMenuItem) {
... | Renders the top level menu items into a html element
@return \MUtil_Html_HtmlElement | entailment |
public function toZendNavigation(\Zend_Controller_Request_Abstract $request, $actionController = null)
{
if ($this->_onlyActiveBranchVisible) {
$activePath = $this->_findPath($request);
// \MUtil_Echo::r($activePath);
$this->setBranchVisible($activePath);
}
... | Generates a \Zend_Navigation object from the current menu
@param \Zend_Controller_Request_Abstract $request
@param mixed $actionController
@return \Zend_Navigation | entailment |
public function addExport($data, $modelId = false)
{
$this->files = $this->getFiles();
$this->data = $data;
$this->modelId = $modelId;
if ($model = $this->getModel()) {
if ($this->model->getMeta('nested', false)) {
$this->rowsPerBatch = $this->nested... | Add an export command with specific details. Can be batched.
COPIED from ExportAbstract to add $modelId to footer.
@param array $data Data submitted by export form
@param array $modelId Model Id when multiple models are passed | 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());
... | 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->startElement('o');
$writer->writeAttribute('num', $rowNu... | 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)
{
$tempFilename = str_replace($this->fileExtension, '', $filename);
$this->model = $this->getModel();
$this->modelId = $modelId;
if ($this->batch) {
$iteration = $this->batch->getSessionVariable('iteration');
... | Add a footer to a specific file
@param string $filename The temporary filename while the file is being written | entailment |
protected function preprocessModel()
{
parent::preprocessModel();
$labeledCols = $this->getLabeledColumns();
$newColNames = array();
foreach($labeledCols as $columnName) {
$options = array();
$this->model->remove($columnName, 'dateFormat');
... | Preprocess the model to add specific options | entailment |
public function getChanges(array $context, $new)
{
if (isset($context['gsf_id_organization'])) {
$org = $this->loader->getOrganization($context['gsf_id_organization']);
if ($org instanceof \Gems_User_Organization) {
return ['gul_user_class' => ['multiOptions' => $org... | 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 |
public function getFieldInfo(\MUtil_Model_ModelAbstract $model)
{
// Many definitions use load transformers
$model->setMeta(\MUtil_Model_ModelAbstract::LOAD_TRANSFORMER, true);
return $this->fieldsDefinition->getDataModelSettings();
} | If the transformer add's fields, these should be returned here.
Called in $model->AddTransformer(), so the transformer MUST
know which fields to add by then (optionally using the model
for that).
@param \MUtil_Model_ModelAbstract $model The parent model
@return array Of filedname => set() values | entailment |
public function transformLoad(\MUtil_Model_ModelAbstract $model, array $data, $new = false, $isPostData = false)
{
if ($isPostData) {
return $data;
}
$empty = false;
foreach ($data as $key => $row) {
if (isset($row[$this->respTrackIdField]) && $row[$this->r... | The transform function performs the actual transformation of the data and is called after
the loading of the data in the source model.
@param \MUtil_Model_ModelAbstract $model The parent model
@param array $data Nested array
@param boolean $new True when loading a new item
@param boolean $isPostData With post data, un... | entailment |
public function transformRowAfterSave(\MUtil_Model_ModelAbstract $model, array $row)
{
if (isset($row[$this->respTrackIdField]) && $row[$this->respTrackIdField]) {
if (! $this->tracker) {
$this->tracker = $this->loader->getTracker();
}
if ((! $this... | This transform function performs the actual save (if any) of the transformer data and is called after
the saving of the data in the source model.
@param \MUtil_Model_ModelAbstract $model The parent model
@param array $row Array containing row
@return array Row array containing (optionally) transformed data | entailment |
protected function addUserLogin(\Gems_Model_JoinModel $model, $loginField, $organizationField)
{
$model->addTable(
'gems__user_logins',
array($loginField => 'gul_login', $organizationField => 'gul_id_organization'),
'gul',
\MUtil_Model_Database... | Link the model to the user_logins table.
@param \Gems_Model_JoinModel $model
@param string $loginField Field that links to login name field.
@param string $organizationField Field that links to the organization field. | entailment |
public function createGemsUserId($value, $isNew = false, $name = null, array $context = array())
{
if ($value) {
return $value;
}
$creationTime = new \MUtil_Db_Expr_CurrentTimestamp();
do {
$out = mt_rand(1, 9);
for ($i = 1; $i < $this->userIdLen... | Create a Gems project wide unique user id
@see \Gems_Model_RespondentModel
@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 int | entailment |
public function getCommLogModel($detailed)
{
$model = $this->_loadClass('CommLogModel', true);
$model->applySetting($detailed);
return $model;
} | Load the comm log model
@param boolean $detailed True when the current action is not in $summarizedActions.
@return \Gems\Model\CommLogModel | entailment |
public function getRespondentModel($detailed)
{
static $isDetailed;
static $model;
if ($model && ($isDetailed === $detailed)) {
return $model;
}
$isDetailed = $detailed;
$model = $this->createRespondentModel();
if ($detailed) {
... | Load project specific respondent model or general Gems model otherwise
@param boolean $detail When true more information needed for individual item display is added to the model.
@return \Gems_Model_RespondentModel | entailment |
public function getStaffModel($addLogin = true)
{
$model = $this->_loadClass('StaffModel', true);
if ($addLogin) {
$this->addUserLogin($model, 'gsf_login', 'gsf_id_organization');
}
$this->setAsGemsUserId($model, 'gsf_id_user');
return $model;
} | Load the staffmodel
@param boolean $addLogin Add the login tables to the model
@return \Gems_Model_StaffModel | entailment |
public function setAsGemsUserId(\MUtil_Model_DatabaseModelAbstract $model, $idField)
{
// Make sure field is added to save when not there
$model->setAutoSave($idField);
// Make sure the fields get a userid when empty
$model->setOnSave($idField, array($this, 'createGemsUserId'));
... | Set a field in this model as a gems unique user id
@param \MUtil_Model_DatabaseModelAbstract $model
@param string $idField Field that uses global id. | entailment |
public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
{
$changed_field = $prefix . '_changed';
$changed_by_field = $prefix . '_changed_by';
$created_field = $prefix . '_created';
$created_by_field = $prefix . '_create... | Function that automatically fills changed, changed_by, created and created_by fields with a certain prefix.
@param \MUtil_Model_DatabaseModelAbstract $model
@param string $prefix Three letter code
@param int $userid Gems user id | entailment |
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$br = \MUtil_Html::create('br');
$tData = $this->util->getTokenData();
// Add link to patient to overview
$menuItems = $this->findMenuItems('respondent', 'show')... | 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 |
protected function _loadAllTraversable()
{
$data = parent::_loadAllTraversable();
$dataExportWhitelist = $this->getDataExportWhitelist();
foreach($data as $key=>$row) {
if (in_array($row['group'], $this->excludeGroups)) {
unset($data[$key]);
contin... | An ArrayModel assumes that (usually) all data needs to be loaded before any load
action, this is done using the iterator returned by this function.
@return \Traversable Return an iterator over or an array of all the rows in this object | entailment |
public function afterRegistry()
{
parent::afterRegistry();
if (empty($this->trackId)) {
throw new Gems_Exception_Coding('Provide a trackId to this snippet!');
}
$model = $this->getModel();
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function createModel()
{
if (!$this->_model instanceof \MUtil_Model_SelectModel) {
$trackId = $this->trackId;
$db = $this->db;
$select = $db->select()->distinct()->from('gems__rounds', ['gro_round_description', 'gro_round_description'])->where('gro_id_track... | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
public function getActiveOrganizationId()
{
$request = $this->getRequest();
if ($request->isPost()) {
$orgId = parent::getActiveOrganizationId();
$topId = $request->getParam($this->topOrganizationFieldName);
$children = $this->getChildOrganizations($topId);
... | Get the organization id that has been currently entered
@return int | entailment |
public function getChildOrganizations($parentId = null)
{
static $children;
if (is_null($parentId)) {
return array();
}
if (! isset($children[$parentId])) {
$organizations = $this->db->fetchPairs(
'SELECT gor_id_organization, gor_name
... | Return array of organizations that are a child of the given parentId
@param int $parentId
@return array | entailment |
public function getCurrentOrganizationId()
{
$userLoader = $this->loader->getUserLoader();
if ($this->getElement($this->organizationFieldName) instanceof \Zend_Form_Element_Hidden) {
// Url determines organization first when there is only one organization
// and thus the ele... | Returns the organization id that should currently be used for this form.
@return int Returns the current organization id, if any | entailment |
public function getCurrentTopOrganizationId()
{
$userLoader = $this->loader->getUserLoader();
// Url determines organization first.
if ($orgId = $userLoader->getOrganizationIdByUrl()) {
$this->_organizationFromUrl = true;
return ' ';
}
$request = $th... | Returns the top organization id that should currently be used for this form.
@return int Returns the current organization id, if any | entailment |
public function getOrganizationElement()
{
$element = $this->getElement($this->organizationFieldName);
$orgId = $this->getCurrentOrganizationId();
$parentId = $this->getParentId();
$childOrgs = $this->getChildOrganizations($parentId);
if (!empty($childOrgs)) {
... | Returns/sets an element for determining / selecting the organization.
Depends on the top-organization
@return \Zend_Form_Element_Xhtml | entailment |
public function getTopOrganizations()
{
try {
$organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_has_login=1 AND (gor_accessible_by IS NULL OR gor_accessible_by = "::") ORDER BY gor_name');
} catch (\Exception ... | Return a list of organizations that are considered top-organizations, in this
case organizations that are not accessible by others as they are considered
the children of the top organizations. Feel free to modify to suit your
needs.
@return array | entailment |
public function getTopOrganizationElement()
{
$element = $this->getElement($this->topOrganizationFieldName);
$orgId = $this->getCurrentTopOrganizationId();
$orgs = $this->getTopOrganizations();
$hidden = $this->_organizationFromUrl || (count($orgs) < 2);
if ($this->_or... | Returns/sets an element for determining / selecting the top-organization.
@return null|\Zend_Form_Element_Select | entailment |
public function loadDefaultElements()
{
// If not already set, set some defaults for organization elements
if (is_null($this->topOrganizationDescription)) {
$this->topOrganizationDescription = $this->translate->_('Organization');
}
if (is_null($this->childOrganizationDes... | Load the elements, starting with the extra top organization element and
continue with the other elements like in the standard login form
@return \Gems_User_Form_LayeredLoginForm | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.