sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function setLevel($context, $level = null, $force = false) { if (!is_null($level) && $this->_info->$context != $level && ($force || $this->_info->$context < $level)) { $this->_info->$context = $level; $writer = new \Zend_Config_Writer_Ini(); ...
Set the upgrade level for the given $context to a certain level Will only update when the $level is higher than the achieved level, unless when $force = true when it will always update. @param string $context @param int $level @param boolean $force
entailment
protected function addAnswersToModel() { $transformer = new AddAnswersTransformer($this->survey, $this->source); $this->addTransformer($transformer); }
Does the real work @return void
entailment
public function andReceptionCodes($fields = '*') { $this->sql_select->join('gems__reception_codes', 'gems__tokens.gto_reception_code = grc_id_reception_code', $fields); // Some queries use multiple token tables $expr = str_repl...
Add reception codes and token status calculation @param string|array $fields @return \Gems_Tracker_Token_TokenSelect
entailment
public function andRespondentTracks($fields = '*', $groupBy = false) { $this->sql_select->join('gems__respondent2track', 'gto_id_respondent_track = gr2t_id_respondent_track', $fields); if ($groupBy && is_array($fields)) { $this->sql_select->group($fields); ...
Add Respondent Track info to the select statement @param string|array $fields @param boolean $groupBy Optional, add these fields to group by statement @return \Gems_Tracker_Token_TokenSelect
entailment
public function forNextTokenId($tokenId) { $this->sql_select->join('gems__tokens as ct', 'gems__tokens.gto_id_respondent_track = ct.gto_id_respondent_track AND gems__tokens.gto_id_token != ct.gto_id_token AND ((gems__tokens.gto_round_order < ct.gto...
Select the token before the current token @param string|array $fields @return \Gems_Tracker_Token_TokenSelect
entailment
public function forPreviousTokenId($tokenId) { $this->sql_select->join('gems__tokens as ct', 'gems__tokens.gto_id_respondent_track = ct.gto_id_respondent_track AND gems__tokens.gto_id_token != ct.gto_id_token AND ((gems__tokens.gto_round_order > ct.gto...
Select the token before the current token @param string|array $fields @return \Gems_Tracker_Token_TokenSelect
entailment
public function forRespondent($respondentId, $organizationId = null) { if (null !== $respondentId) { $this->sql_select->where('gto_id_respondent = ?', $respondentId); } if (null !== $organizationId) { $this->sql_select->where('gto_id_organization = ?', $organizationId); ...
Select only a specific respondent @param string $respondentId @param string $organizationId Optional @return \Gems_Tracker_Token_TokenSelect
entailment
public function forWhere($cond, $bind = null) { $this->sql_select->where($cond, $bind); return $this; }
For adding generic where statements @param string $cond SQL Where condition. @param mixed $bind optional bind values @return \Gems_Tracker_Token_TokenSelect
entailment
public function onlyActive($recentCheck = false) { $this->sql_select ->where('gto_in_source = ?', 1) ->where('gto_completion_time IS NULL'); if ($recentCheck) { $this->sql_select->where('gto_start_time > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY)'); ...
Select only active tokens Active is token already in surveyor and completiondate is null @param boolean $recentCheck Check only tokens with recent gto_start_time's @return \Gems_Tracker_Token_TokenSelect
entailment
public function render($content) { $element = $this->getElement(); $view = $element->getView(); if (null === $view) { return $content; } $jQueryParams = $this->getJQueryParams(); //Combine element attribs and decorator options!! $attribs =...
Render an jQuery UI Widget element using its associated view helper Determine view helper from 'helper' option, or, if none set, from the element type. Then call as helper($element->getName(), $element->getValue(), $element->getAttribs()) @param string $content @return string @throws \Zend_Form_Decorator_Exception i...
entailment
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { // \MUtil_Model::$verbose = true; // // Initiate data retrieval for stuff needed by links $bridge->gr2o_patient_nr; $bridge->gr2o_id_organization; $b...
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 createModel() { $model = parent::createModel(); $translated = $this->util->getTranslated(); $model->set('calc_used_date', 'formatFunction', $translated->formatDateNever, 'tdClass', 'date'); $model->set('gto_changed', ...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function hasHtmlOutput() { if ($this->menu) { $default = $this->project->getDefaultTrackId(); if ($default) { if ($this->respondent->getReceptionCode()->isSuccess()) { $track = $this->loader->getTracker()->getTrackEngine($default); ...
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 _getGemsSurveysForSynchronisation() { $select = $this->_gemsDb->select(); $select->from('gems__surveys', array('gsu_id_survey', 'gsu_surveyor_id')) ->where('gsu_id_source = ?', $this->getId()) ->order('gsu_surveyor_id'); return $this->_gems...
Returns all surveys for synchronization @return array Pairs gemsId => sourceId
entailment
protected function _getTokenFromSqlWhere($from, $fieldName) { $lsDb = $this->getSourceDatabase(); $tokField = $lsDb->quoteIdentifier($fieldName); foreach (str_split($from) as $check) { $checks[] = 'LOCATE(' . $lsDb->quote($check) . ', ' . $tokField . ')'; } retu...
Creates a where filter statement for tokens that do not have a correct name and are in a tokens table @param string $from The tokens that should not occur @param string $fieldName Name of database field to use @return string
entailment
protected function _getTokenFromToSql($from, $to, $fieldName) { $lsDb = $this->getSourceDatabase(); if ($from) { // Build the sql statement using recursion return 'REPLACE(' . $this->_getTokenFromToSql(substr($from, 1), substr($to, 1), $fieldName) . ', ' . ...
Creates a SQL update statement for tokens that do not have a correct name and are in a tokens table. @param string $from The tokens that should not occur @param string $to The tokens that replace them @param string $fieldName Name of database field to use @return string
entailment
protected function _updateGemsSurveyExists(array $surveyorSids, $userId) { $sqlWhere = 'gsu_id_source = ' . $this->_gemsDb->quote($this->getId()) . ' AND (gsu_status IS NULL OR gsu_active = 1 OR gsu_surveyor_active = 1) AND gsu_surveyor_id NOT IN (' . implode(', ', $surveyorS...
This helper function updates the surveys in the gems_surveys table that no longer exist in in the source and returns a list of their names. @param array $surveyorSids The gsu_surveyor_id's that ARE in the source @param int $userId Id of the user who takes the action (for logging) @return array The names of the surve...
entailment
protected function _updateSource(array $values, $userId) { if ($this->tracker->filterChangesOnly($this->_sourceData, $values)) { if (\Gems_Tracker::$verbose) { $echo = ''; foreach ($values as $key => $val) { $echo .= $key . ': ' . $this->_sou...
Updates this source, both in the database and in memory. @param array $values The values that this source should be set to @param int $userId The current user @return int 1 if data changed, 0 otherwise
entailment
protected function addDatabasePrefix($tableName, $addDatabaseName = true) { return ($addDatabaseName && $this->_sourceData['gso_ls_database'] ? $this->_sourceData['gso_ls_database'] . '.' : '') . $this->_sourceData['gso_ls_table_prefix'] . $tableName; }
Adds database (if needed) and tablename prefix to the table name @param return $tableName @param boolean $addDatabaseName Optional, when true (= default) and there is a database name then it is prepended to the name. @return string
entailment
protected function filterLimitOffset(&$filter, $select) { $limit = null; $offset = null; if (array_key_exists('limit', $filter)) { $limit = (int) $filter['limit']; unset($filter['limit']); } if (array_key_exists('offset', $filter)) { $offs...
Extract limit and offset from the filter and add it to a select @param array $filter @param \Zend_Db_Select $select
entailment
public function getRawTokenAnswerRowsCount(array $filter, $surveyId, $sourceSurveyId = null) { $answers = $this->getRawTokenAnswerRows($filter, $surveyId, $sourceSurveyId); return count($answers); }
Returns the recordcount for a given filter Abstract implementation is not efficient, sources should handle this as efficient as possible. @param array $filter filter array @param int $surveyId Gems Survey Id @param string $sourceSurveyId Optional Survey Id used by source @return int
entailment
public function getSourceDatabase() { if (! $this->_sourceDb) { if ($dbConfig['dbname'] = $this->_sourceData['gso_ls_database']) { // Default config values from gemsDb $gemsConfig = $this->_gemsDb->getConfig(); $gemsName = $gemsConfig['dbname']...
Get the db adapter for this source @return \Zend_Db_Adapter_Abstract
entailment
protected function getSurveyData($surveyId, $field = null) { static $cache = array(); if (! isset($cache[$surveyId])) { $cache[$surveyId] = $this->_gemsDb->fetchRow( 'SELECT * FROM gems__surveys WHERE gsu_id_survey = ? LIMIT 1', $surveyId, ...
Returns all info from the Gems surveys table for a givens Gems Survey Id Uses internal caching to prevent multiple db lookups during a program run (so no caching beyond page generation time) @param int $surveyId @param string $field Optional field to retrieve data for @return array
entailment
public function synchronizeSurveyBatch(\Gems_Task_TaskRunnerBatch $batch, $userId) { // Surveys in Gems $select = $this->_gemsDb->select(); $select->from('gems__surveys', array('gsu_id_survey', 'gsu_surveyor_id')) ->where('gsu_id_source = ?', $this->getId()) -...
Updates the gems database with the latest information about the surveys in this source adapter @param \Gems_Task_TaskRunnerBatch $batch @param int $userId Id of the user who takes the action (for logging) @return array Returns an array of messages
entailment
protected function updateTokens($userId, $updateTokens = true) { $tokenLib = $this->tracker->getTokenLibrary(); $sql = 'UPDATE gems__tokens SET gto_id_token = ' . $this->_getTokenFromToSql($tokenLib->getFrom(), $tokenLib->getTo(), 'gto_id_token') . ', gto...
Updates the gems__tokens table so all tokens stick to the (possibly) new token name rules. @param int $userId Id of the user who takes the action (for logging) @return int The number of tokens changed
entailment
protected function _createSelectElement($name, $options, $empty = null) { if ($options instanceof \MUtil_Model_ModelAbstract) { $options = $options->get($name, 'multiOptions'); } elseif (is_string($options)) { $options = $this->db->fetchPairs($options); nats...
Creates a \Zend_Form_Element_Select @param string $name Name of the select element @param string|array $options Can be a SQL select string or key/value array of options @param string $empty Text to display for the empty selector @return \Zend_Form_Element_Select
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); } // Add edit button if allowed, ...
Adds columns from the model to the bridge that creates the browse table. Adds a button column to the model, if such a button exists in the model. @param \MUtil_Model_Bridge_TableBridge $bridge @param \MUtil_Model_ModelAbstract $model @return void
entailment
public function afterSaveRoute($data) { $this->accesslog->logChange($this->request, null, $data); //Get default routing $url = $this->getAfterSaveRoute($data); //If we have a route, reroute if ($url !== null && $url !== false) { $this->_helper->redirect...
Get the afterSaveRoute and execute it @param mixed $data data array or Zend Request @return boolean
entailment
protected function aliasAction($alias) { $request = $this->getRequest(); $request->setActionName($alias); $request->setParam($request->getActionKey(), $alias); }
Set the action key in request Use this when an action is a Ajax action for retrieving information for use within the screen of another action @param string $alias
entailment
public function beforeFormDisplay ($form, $isNew) { if ($this->useTabbedForms || $form instanceof \Gems_Form_TableForm) { //If needed, add a row of link buttons to the bottom of the form if ($links = $this->createMenuLinks($isNew ? $this->menuCreateIncludeLevel : $this->menuEditI...
Perform some actions on the form, right before it is displayed but already populated Here we add the table display to the form. @param \Zend_Form $form @param bool $isNew @return \Zend_Form
entailment
public function createAction() { if ($form = $this->processForm()) { $this->setPageTitle(sprintf($this->_('New %s...'), $this->getTopic())); $this->html[] = $form; } }
Creates a form for a new record Uses $this->getModel() $this->addFormElements()
entailment
public function createForm($options = null) { if ($this->useTabbedForms) { $form = new \Gems_TabForm($options); } else { $form = parent::createForm($options); //$form = new \Gems_Form_TableForm($options); } return $form; }
Retrieve a form object and add extra decorators @param array $options @return \Gems_Form
entailment
public function deleteAction() { if ($this->isConfirmedItem($this->_('Delete %s'))) { $model = $this->getModel(); $deleted = $model->delete(); $this->addMessage(sprintf($this->_('%2$u %1$s deleted'), $this->getTopic($deleted), $deleted), 'success'); ...
Creates a form to delete a record Uses $this->getModel() $this->addFormElements()
entailment
public function editAction() { if ($form = $this->processForm()) { if ($this->useTabbedForms && method_exists($this, 'getSubject')) { $data = $this->getModel()->loadFirst(); $subject = $this->getSubject($data); $this->setPageTitle(sprintf($th...
Creates a form to edit Uses $this->getModel() $this->addFormElements()
entailment
public function excelAction() { ini_set('max_execution_time', 90); // Quickfix as long as it is not in a batchtask // Set the request cache to use the search params from the index action $this->getCachedRequestData(true, 'index'); $model = $this->getModel(); $thi...
Outputs the model to excel, applying all filters and searches needed When you want to change the output, there are two places to check: 1. $this->addExcelColumns($model), where the model can be changed to have labels for columns you need exported 2. $this->getExcelData($data, $model) where the supplied data and mode...
entailment
public function getAfterSaveRoute($data) { if ($currentItem = $this->menu->getCurrent()) { $controller = $this->_getParam('controller'); $url = null; if ($data instanceof \Zend_Controller_Request_Abstract) { $refData = $data; } elsei...
Return an array with route options depending on de $data given. @param mixed $data array or \Zend_Controller_Request_Abstract @return mixed array with route options or false when no redirect is found
entailment
protected function getAutoSearchElements(\MUtil_Model_ModelAbstract $model, array $data) { if ($model->hasTextSearchFilter()) { // Search text $element = $this->form->createElement('text', \MUtil_Model::TEXT_FILTER, array('label' => $this->_('Free search text'), 'size' => 20, 'ma...
Returns a text element for autosearch. Can be overruled. The form / html elements to search on. Elements can be grouped by inserting null's between them. That creates a distinct group of elements @param \MUtil_Model_ModelAbstract $model @param array $data The $form field values (can be usefull, but no need to set the...
entailment
protected function getAutoSearchForm($targetId) { if ($this->autoFilter) { $model = $this->getModel(); $data = $this->getCachedRequestData(); $this->form = $form = $this->createForm(array('name' => 'autosubmit', 'class' => 'form-inline', 'role' => 'form')); // Ass...
Creates an autosearch form for indexAction. @param string $targetId @return \Gems_Form|null
entailment
public function getBrowseTable(array $baseUrl = array(), $sort = null, $model = null) { $table = parent::getBrowseTable($baseUrl, $sort, $model); $table->class = 'browser table'; $table->setOnEmpty(sprintf($this->_('No %s found'), $this->getTopic(0))); $table->getOnEmpty()->cl...
Creates from the model a \MUtil_Html_TableElement that can display multiple items. Overruled to add css classes for Gems @param array $baseUrl @return \MUtil_Html_TableElement
entailment
protected function getExcelData($data, \MUtil_Model_ModelAbstract $model) { $headings = array(); $emptyMsg = sprintf($this->_('No %s found.'), $this->getTopic(0)); foreach ($model->getItemsOrdered() as $name) { if ($label = $model->get($name, 'label')) { $he...
Returns an array with all columns from the model that have a label @param array $data @param \MUtil_Model_ModelAbstract $model @return array
entailment
public function getModelForm(array &$data, $new = false) { $model = $this->getModel(); $baseform = $this->createForm(); if ($this->useMultiRowForm) { $bridge = $model->getBridgeFor('form', new \Gems_Form_SubForm()); $newData = $this->addFormElements($br...
Creates from the model a \Zend_Form using createForm and adds elements using addFormElements(). @param array $data The data that will later be loaded into the form, can be changed @param optional boolean $new Form should be for a new element @return \Zend_Form
entailment
public function getShowTable($columns = 1, $filter = null, $sort = null) { $table = parent::getShowTable($columns, $filter, $sort); $table->class = 'displayer table'; return $table; }
Creates from the model a \MUtil_Html_TableElement for display of a single item. Overruled to add css classes for Gems @param integer $columns The number of columns to use for presentation @param mixed $filter A valid filter for \MUtil_Model_ModelAbstract->load() @param mixed $sort A valid sort for \MUtil_Model_ModelA...
entailment
public function importAction() { $controller = $this->getRequest()->getControllerName(); $importLoader = $this->loader->getImportLoader(); $model = $this->getModel(); $params = array(); $params['defaultImportTranslator'] = $importLoader->getDefaultTranslator(...
Generic model based import action
entailment
public function onFakeSubmit(&$form, &$data) { if ($this->useMultiRowForm) { //Check if the insert button was pressed and act upon that if ($this->hasNew() && isset($data['insert_button']) && $data['insert_button']) { // Add a row $model ...
Performs actions when the form is submitted, but the submit button was not checked When not rerouted, the form will be populated afterwards @param \Zend_Form $form The populated form @param array $data The data-array we are working on
entailment
protected function processForm($saveLabel = null, $data = null) { $model = $this->getModel(); $mname = $model->getName(); $request = $this->getRequest(); $isNew = $request->getActionName() === 'create'; //\MUtil_Echo::r($data); if ($request->isPost()) {...
Handles a form, including population and saving to the model @param string $saveLabel A label describing the form @param array $data An array of data to use, adding to the data from the post @return \Zend_Form|null Returns a form to display or null when finished
entailment
protected function setPageTitle($title) { $this->pageTitle = $title; $args = array('class' => 'title'); $titleTag = \MUtil_Html::create('h3', $title, $args); $this->html->append($titleTag); }
Set the page title on top of a page, also store it in a public var @param string $title Title
entailment
public function showAction() { $this->setPageTitle(sprintf($this->_('Show %s'), $this->getTopic())); $model = $this->getModel(); // NEAR FUTURE: // $this->addSnippet('ModelVerticalTableSnippet', 'model', $model, 'class', 'displayer'); $repeater = $model->loadRepeat...
Shows a table displaying a single record from the model Uses: $this->getModel() $this->getShowTable();
entailment
protected function _checkFilterUsed($filter) { $filter = parent::_checkFilterUsed($filter); if (isset($filter['gr2o_id_organization'])) { // Check for option to check for any organization if (true === $filter['gr2o_id_organization']) { unset($filter['gr2o_id_...
Add an organization filter if it wasn't specified in the filter. Checks the filter on sematic correctness and replaces the text seacrh filter with the real filter. @param mixed $filter True for the filter stored in this model or a filter array @return array The filter to use
entailment
public function addLoginCheck() { if (! $this->hasAlias('gems__user_logins')) { $this->addLeftTable( 'gems__user_logins', array('gr2o_patient_nr' => 'gul_login', 'gr2o_id_organization' => 'gul_id_organization'), 'gul', ...
Add the table and field to check for respondent login checks @return \Gems_Model_RespondentModel (continuation pattern)
entailment
public static function addNameToModel(\Gems_Model_JoinModel $model, $label) { $nameExpr[] = "COALESCE(grs_last_name, '-')"; $fieldList[] = 'grs_last_name'; if ($model->has('grs_partner_last_name')) { if ($model->has('grs_partner_surname_prefix')) { $nameExpr[] =...
Add the respondent name as a caclulated field to the model @param \Gems_Model_JoinModel $model @param string $label
entailment
public function afterRegistry() { parent::afterRegistry(); $this->setOnSave('gr2o_opened', new \MUtil_Db_Expr_CurrentTimestamp()); $this->setSaveOnChange('gr2o_opened'); $this->setOnSave('gr2o_opened_by', $this->currentUser->getUserId()); $this->setSaveOnChange('gr2o_opened_...
Called after the check that all required registry values have been set correctly has run. @return void
entailment
public function applyBrowseSettings() { $dbLookup = $this->util->getDbLookup(); $translated = $this->util->getTranslated(); $this->resetOrder(); if ($this->has('gr2o_id_organization') && $this->isMultiOrganization()) { // Add for sorting $this->addTable('g...
Set those settings needed for the browse display @return \Gems_Model_RespondentModel
entailment
public function applyDetailSettings() { $dbLookup = $this->util->getDbLookup(); $localized = $this->util->getLocalized(); $translated = $this->util->getTranslated(); if ($this->loginCheck) { $this->addLoginCheck(); } $this->resetOrder(); if ($t...
Set those settings needed for the detailed display @return \Gems_Model_RespondentModel
entailment
public function applyEditSettings($create = false) { $this->applyDetailSettings(); $this->copyKeys(); // The user can edit the keys. $translated = $this->util->getTranslated(); $ucfirst = new \Zend_Filter_Callback('ucfirst'); if ($create && ($this->hashSsn !== self::SSN_...
Set those values needed for editing @param boolean $create True when creating @return \Gems_Model_RespondentModel
entailment
public function applyHash(&$filterValue, $filterKey) { if ('grs_ssn' === $filterKey) { $filterValue = $this->project->getValueHash($filterValue, $this->hashAlgorithm); } }
Apply hash function for array_walk_recursive in _checkFilterUsed() @see _checkFilterUsed() @param string $filterValue @param string $filterKey
entailment
public function copyToOrg($fromOrgId, $fromPid, $toOrgId, $toPid, $keepConsent = false) { // Maybe we should disable masking, just to be sure $this->currentUser->disableMask(); // Do some sanity checks $fromPatient = $this->loadFirst(['gr2o_id_organization' => $fromOrgId, 'gr2o_pati...
Copy a respondent to a new organization If you want to share a respondent(id) with another organization use this method. @param int $fromOrgId Id of the sending organization @param string $fromPid Respondent number of the sending organization @param int $toOrgId Id of the receiving o...
entailment
public function countTracks($patientId, $organizationId, $respondentId = null, $active = false) { $db = $this->getAdapter(); $select = $db->select(); $select->from('gems__respondent2track', array('COALESCE(COUNT(*), 0)')); if (null === $respondentId) { $respondentId = $t...
Count the number of tracks the respondent has for this organization @param string $patientId Can be empty if $respondentId is passed @param int $organizationId When null looks at all organizations @param int $respondentId Pass when at hand, is looked up otherwise @param boolean $active When true only tracks wi...
entailment
public function getReceptionCode($patientId, $organizationId, $respondentId = null) { $db = $this->getAdapter(); $select = $db->select(); $select->from('gems__respondent2org', array('gr2o_reception_code')); if ($patientId) { $select->where('gr2o_patient_nr = ?', $pat...
Get the current reception code for a respondent @param string $patientId Can be empty if $respondentId is passed @param int $organizationId @param int $respondentId Pass when at hand, is looked up otherwise @return string The current reception code
entailment
public function hasTracks($patientId, $organizationId, $respondentId = null, $active = false) { return (boolean) $this->countTracks($patientId, $organizationId, $respondentId, $active); }
Has the respondent tracks @param string $patientId Can be empty if $respondentId is passed @param int $organizationId When null looks at all organizations @param int $respondentId Pass when at hand, is looked up otherwise @param boolean $active When true we look only for tracks with a success code @return bool...
entailment
public function hideSSN($value, $isNew = false, $name = null, array $context = array(), $isPost = false) { if ($value && (! $isPost)) { return str_repeat('*', 9); } else { return $value; } }
Return a hashed version of the input value. @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 output to display
entailment
public function merge($newPid, $oldPid, $orgId) { // Maybe we should disable masking, just to be sure $this->currentUser->disableMask(); $patients = $this->load([ 'gr2o_id_organization' => $orgId, 'gr2o_patient_nr' => array($oldPid, $newPid) ]); ...
Merge two patients (in the same organization) A respondent can only exist twice in the same organization when the respondent has multiple respondent id's. When ssn is set correctly this can not happen so probably one with and one without or both without ssn. @param string $newPid @param string $oldPid @param int $org...
entailment
public function move($fromOrgId, $fromPid, $toOrgId, $toPid) { // Maybe we should disable masking, just to be sure $this->currentUser->disableMask(); $patientFrom = $this->loadFirst([ 'gr2o_id_organization' => $fromOrgId, 'gr2o_patient_nr' => $fromPid ])...
Move a respondent to a new organization and/or change it's number This not be a copy, it will be renamed. Use copyToOrg if you want to make a copy. @param int $fromOrgId Id of the sending organization @param string $fromPid Respondent number of the sending organization @param int $toOrgId ...
entailment
public function save(array $newValues, array $filter = null, array $saveTables = null) { // If the respondent id is not set, check using the // patient number and then the ssn if (! (isset($newValues['grs_id_user']) && $newValues['grs_id_user'])) { $id = false; if (i...
Save a single model item. @param array $newValues The values to store for a single model item. @param array $filter If the filter contains old key values these are used to decide on update versus insert. @return array The values as they are after saving (they may change).
entailment
public function saveSSN($value, $isNew = false, $name = null, array $context = array()) { if ($value) { return $this->project->getValueHash($value, $this->hashAlgorithm); } }
Return a hashed version of the input value. @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 salted hash as a 32-character hexadecimal num...
entailment
public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null) { if (!$newCode instanceof \Gems_Util_ReceptionCode) { $newCode = $this->util->getReceptionCode($newCode); } $userId = $this->currentUser->getUserId(); // Perfo...
Set the reception code for a respondent and cascade non-success codes to the tracks / surveys. @param string $patientId Can be empty if $respondentId is passed @param int $organizationId @param string $newCode String or \Gems_Util_ReceptionCode @param int $respondentId Pass when at hand, is looked up otherwise...
entailment
public function whenSSN($value, $isNew = false, $name = null, array $context = array()) { return $value && ($value !== $this->hideSSN($value, $isNew, $name, $context)); }
Return a hashed version of the input value. @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
protected function createModel() { if ($this->model instanceof \Gems_Model_RespondentModel) { $model = $this->model; } else { if ($this->respondent instanceof \Gems_Tracker_Respondent) { $model = $this->respondent->getRespondentModel(); } else { ...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function getReceptionCodes() { $rcLib = $this->util->getReceptionCodeLibrary(); if ($this->unDelete) { return $rcLib->getRespondentRestoreCodes(); } return $rcLib->getRespondentDeletionCodes(); }
Called after loadFormData() and isUndeleting() but before the form is created @return array code name => description
entailment
protected function loadFormData() { if (! $this->request->isPost()) { if ($this->respondent instanceof \Gems_Tracker_Respondent) { $this->formData = $this->respondent->getArrayCopy(); } } if (! $this->formData) { parent::loadFormData(); ...
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
public function setReceptionCode($newCode, $userId) { $oldCode = $this->respondent->getReceptionCode(); $code = $this->respondent->setReceptionCode($newCode); // Is the respondent really removed if ($code->isSuccess()) { $this->addMessage($this->_('Respondent restored...
Hook performing actual save @param string $newCode @param int $userId @return $changed
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { if ($this->tokenId) { $this->addMessage(sprintf($this->_('Token %s not found.'), $this->tokenId)); } else { $this->addMessage($this->_('No token specified.')); } return null; }
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 addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $bridge->gr2o_patient_nr; $bridge->gr2o_id_organization; if ($menuItem = $this->menu->find(array('controller' => 'appointment', 'action' => 'show', 'allowed' => true))) { ...
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 createModel() { if ($this->model instanceof \Gems_Model_AppointmentModel) { $model = $this->model; } else { $model = $this->loader->getModels()->createAppointmentModel(); $model->applyBrowseSettings(); } $model->addColumn(new \Z...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function formatDate($value) { return \MUtil_Html::create( 'span', // array('class' => 'date'), \MUtil_Date::format( $value, \Zend_Date::DAY_SHORT . ' ' . \Zend_Date::MONTH_NAME_SHORT . ' ' . \Zend_Date::YE...
Display the date field @param \MUtil_Date $value
entailment
public function formatTime($value) { return \MUtil_Html::create( 'span', ' ', // array('class' => 'time'), // $this->_timeImg, \MUtil_Date::format($value, 'HH:mm ' . \Zend_Date::WEEKDAY_SHORT, $this->_dateStorageFormat) ...
Display the time field @param \MUtil_Date $value
entailment
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model) { parent::processFilterAndSort($model); $eid = $this->request->getParam(\Gems_Model::EPISODE_ID); if ($eid) { $model->addFilter(['gap_id_episode' => $eid]); } }
Overrule to implement snippet specific filtering and sorting. @param \MUtil_Model_ModelAbstract $model
entailment
public function createModel($detailed, $action) { $dbLookup = $this->util->getDbLookup(); $rolesObj = \Gems_Roles::getInstance(); $userLoader = $this->loader->getUserLoader(); $model = new \MUtil_Model_TableModel('gems__groups'); // Add id for excel export 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 fixSql($where) { if ($where == parent::NO_MATCH_SQL) { return parent::MATCH_ALL_SQL; } elseif ($where == parent::MATCH_ALL_SQL) { return parent::NO_MATCH_SQL; } else { return "NOT ($where)"; } }
Standard where processing @param string $where @return string
entailment
protected function loadFormData() { parent::loadFormData(); if ($this->trackEngine instanceof \Gems_Tracker_Engine_StepEngineAbstract) { if ($this->trackEngine->updateRoundModelToItem($this->getModel(), $this->formData, $this->locale->getLanguage())) { if (isset($this->...
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
public function processTokenInsertion(\Gems_Tracker_Token $token) { if ($token->hasSuccesCode() && (! $token->isCompleted())) { // Preparation for a more general object class $surveyId = $token->getSurveyId(); $prev = $token; while ($prev = $prev->getPrevio...
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 authenticate() { $result = call_user_func_array($this->_callback, $this->_params); if ( !($result instanceof Result)) { if ($result === true) { $result = new Result(Result::SUCCESS, $this->_identity); } else { $result = new Resu...
Perform the authenticate attempt @return Result
entailment
protected function getAutoSearchElements(array $data) { $yesNo = $this->util->getTranslated()->getYesNo(); $elements = parent::getAutoSearchElements($data); $elements[] = $this->_createSelectElement('gls_when_no_user', $yesNo, $this->_('(any when no user)')); $elements[] = $this->_c...
Returns a text element for autosearch. Can be overruled. The form / html elements to search on. Elements can be grouped by inserting null's between them. That creates a distinct group of elements @param array $data The $form field values (can be usefull, but no need to set them) @return array Of \Zend_Form_Element's ...
entailment
public function createModel($detailed, $action) { $model = new \Gems_Model_JoinModel('resptrack' , 'gems__respondent2track'); $model->addTable('gems__respondent2org', array( 'gr2t_id_user' => 'gr2o_id_user', 'gr2t_id_organization' => 'gr2o_id_organization' )); ...
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 getExportModel() { $model = parent::getExportModel(); $statusColumns = $model->getColNames('label'); $everyStatus = $this->util->getTokenData()->getEveryStatus(); foreach ($statusColumns as $colName) { // For the compliance columns, we add the tr...
Get the model for export and have the option to change it before using for export @return
entailment
public function checkRegistryRequestsAnswers() { // Make sure \Gems_User_User gets userLoader variable. $extras['userLoader'] = $this; // Make sure that this code keeps working when _initSession // is removed from GemsEscort if (! $this->session instanceof \Zend_Session_Name...
Should be called after answering the request to allow the Target to check if all required registry values have been set correctly. @return boolean False if required values are missing.
entailment
public function createUser($login_name, $organization, $userClassName, $userId) { $now = new \MUtil_Db_Expr_CurrentTimestamp();; $values['gul_user_class'] = $userClassName; $values['gul_can_login'] = 1; $values['gul_changed'] = $now; $values['gul_changed_by'] = $userId; ...
Returns a user object, that may be empty if no user exist. @param string $login_name @param int $organization @param string $userClassName @param int $userId The person creating the user. @return \Gems_User_User Newly created
entailment
public function ensureDefaultUserValues(array $values, \Gems_User_UserDefinitionInterface $definition, $defName = null) { if (! isset($values['user_active'])) { $values['user_active'] = true; } if (! isset($values['user_staff'])) { $values['user_staff'] = $definition-...
Makes sure default values are set for a user @param array $values @param \Gems_User_UserDefinitionInterface $definition @param string $defName Optional @return array
entailment
public function getAvailableStaffDefinitions() { $output = array( self::USER_STAFF => $this->translate->_('Db storage'), self::USER_RADIUS => $this->translate->_('Radius storage'), ); if ($this->project->getLdapSettings()) { $output[self::USER_LDAP] = $t...
Get userclass / description array of available UserDefinitions for staff @return array
entailment
public function getChangePasswordForm($user, $args_array = null) { $args = \MUtil_Ra::args(func_get_args(), array('user' => 'Gems_User_User')); $form = $this->_loadClass('Form_ChangePasswordForm', true, array($args)); return $form; }
Returns a change password form for this user @param \Gems_user_User $user @param mixed $args_array \MUtil_Ra::args array for LoginForm initiation. @return \Gems_User_Form_ChangePasswordForm
entailment
public final function getCurrentUser() { if (! self::$currentUser) { if ($this->session->__isset('__user_definition')) { $defName = $this->session->__get('__user_definition'); // Check for during upgrade. Remove for version 1.6 if (substr($defName...
Get the currently loggin in user @return \Gems_User_User
entailment
public function getGroup($groupId) { static $groups = array(); if (! isset($groups[$groupId])) { $groups[$groupId] = $this->_loadClass('Group', true, array($groupId)); } return $groups[$groupId]; }
Returns a group object, initiated from the database or from Group::$_noGroup when the database does not yet exist. @param int $groupId Group id @return \Gems\User\Group
entailment
public function getOrganization($organizationId = null) { static $organizations = array(); if (null === $organizationId) { $user = $this->getCurrentUser(); if (! $user->isActive()) { // Check url only when not logged im $organizationId = $thi...
Returns an organization object, initiated from the database or from self::$_noOrganization when the database does not yet exist. @param int $organizationId Optional, uses current user or url when empty @return \Gems_User_Organization
entailment
public function getOrganizationIdByUrl() { $urls = $this->getOrganizationUrls(); $current = $this->util->getCurrentURI(); if (isset($urls[$current])) { return $urls[$current]; } }
Returns the current organization according to the current site url. @return int An organization id or null
entailment
public function getOrganizationUrls() { static $urls; if (! is_array($urls)) { if ($this->cache) { $cacheId = GEMS_PROJECT_NAME . '__' . strtr(get_class($this), '\\/', '__') . '__organizations_url'; $urls = $this->cache->load($cacheId); } else...
Returns the current organization according to the current site url. @static array $urls An array of url => orgId values @return array url => orgId
entailment
public function getResetRequestForm($args_array = null) { $args = \MUtil_Ra::args(func_get_args()); return $this->_loadClass('Form_ResetRequestForm', true, array($args)); }
Returns a reset form for handling both the incoming request and the outgoing reset request @param mixed $args_array \MUtil_Ra::args array for LoginForm initiation. @return \Gems_User_Form_ResetRequestForm
entailment
public function getTwoFactorAuthenticator($className) { $object = $this->_loadClass('TwoFactor_' . $className, true); if (! $object instanceof TwoFactorAuthenticatorInterface) { throw new \Gems_Exception_Coding(sprintf( 'The authenticator class %s should be an instan...
Get TwoFactorAuthenticatorInterface class @return Gems\User\TwoFactor\TwoFactorAuthenticatorInterface
entailment
public function getUser($login_name, $currentOrganization) { $user = $this->getUserClass($login_name, $currentOrganization); if ($this->allowLoginOnWithoutOrganization && (! $currentOrganization)) { $user->setCurrentOrganization($user->getBaseOrganizationId()); } else { ...
Returns a user object, that may be empty if no user exist. @param string $login_name @param int $currentOrganization @return \Gems_User_User But ! ->isActive when the user does not exist
entailment
public function getUserByResetKey($resetKey) { if ((null == $resetKey) || (0 == strlen(trim($resetKey)))) { return $this->loadUser(self::USER_NOLOGIN, null, null); } $select = $this->db->select(); $select->from('gems__user_passwords', array()) ->joinLeft(...
Get the user having the reset key specified @param string $resetKey @return \Gems_User_User But ! ->isActive when the user does not exist
entailment
public function getUserByStaffId($staff_id) { $data = $this->db->fetchRow("SELECT gsf_login, gsf_id_organization FROM gems__staff WHERE gsf_id_user = ?", $staff_id); // \MUtil_Echo::track($data); if (false == $data) { $data = array('gsf_login' => null, 'gsf_id_organization' => n...
Get a staff user using the $staff_id @param int $staff_id @return \Gems_User_User But ! ->isActive when the user does not exist
entailment
protected function getUserClass($login_name, $organization) { //First check for project user, as this one can run without a db if ((null !== $login_name) && $this->isProjectUser($login_name)) { return $this->loadUser(self::USER_PROJECT, $organization, $login_name); } if...
Returns the name of the user definition class of this user. @param string $login_name @param int $organization @return \Gems_User_User But ! ->isActive when the user does not exist
entailment