sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function render(\Zend_View_Interface $view = null) { if ($this->_getIsRendered()) { return; } $this->fixDecorators(); return parent::render($view); }
Fix the decorators the first time we try to render the form @param \Zend_View_Interface $view @return string
entailment
protected function createModel() { if (!$this->model instanceof \Gems_Tracker_Model_StandardTokenModel) { $model = $this->loader->getTracker()->getTokenModel(); $model->set('gto_id_token', 'label', $this->_('Summary'), 'formatFunction', array($this, 'getData')); $model->set('...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function processFilterAndSort(\MUtil_Model_ModelAbstract $model) { // $roundDecription = $this->request->getParam('gto_round_description'); if (!is_null($roundDecription)) { $roundDecription = html_entity_decode(urldecode($roundDecription)); $this->request->s...
Fix for forward slash in round description The round description can contain a / that is interpreted incorrect, so in TrafficLightTokenSnippet we encode it to the html entity first. This method does the reverse. @see \Gems_Snippets_Respondent_TrafficLightTokenSnippet @param \MUtil_Model_ModelAbstract $model
entailment
protected function applySurveyListValidAfter(\MUtil_Model_ModelAbstract $model, array &$itemData) { $this->_ensureRounds(); $rounds = array(); foreach ($this->_rounds as $roundId => $round) { if (($roundId == $itemData['gro_id_round'])) { continue; // Skip self...
Set the surveys to be listed as valid after choices 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 boolean True if the update changed values (usually by changed selection lists).
entailment
protected function applySurveyListValidFor(\MUtil_Model_ModelAbstract $model, array &$itemData) { $this->_ensureRounds(); $rounds = array(); foreach ($this->_rounds as $roundId => $round) { $rounds[$roundId] = $this->getRound($roundId)->getFullDescription(); } i...
Set the surveys to be listed as valid for choices 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 boolean True if the update changed values (usually by changed selection lists).
entailment
public function checkTokensFrom(\Gems_Tracker_RespondentTrack $respTrack, \Gems_Tracker_Token $startToken, $userId, \Gems_Tracker_Token $skipToken = null) { $changed = parent::checkTokensFrom($respTrack, $respTrack->getFirstToken(), $userId, $skipToken); return $changed; }
The end date of any round can depend on any token so always do a end date check of the previous tokens @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 \...
entailment
public function getRoundDefaults() { $defaults = parent::getRoundDefaults(); // Now check if the valid for depends on the same round if (count($defaults) > 1) { $lastRound = end($this->_rounds); // We need the ID to compare if ($defaults['gro_valid_for_source'] ...
Get the defaults for a new round @return array Of fieldname => default
entailment
public function getRoundModel($detailed, $action) { $model = parent::getRoundModel($detailed, $action); $model->set('gro_valid_for_id', 'default', '0'); return $model; }
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 getValidFromDate($fieldSource, $fieldName, $prevRoundId, \Gems_Tracker_Token $token, \Gems_Tracker_RespondentTrack $respTrack) { return $this->getValidUntilDate($fieldSource, $fieldName, $prevRoundId, $token, $respTrack, false); }
Returns the date to use to calculate the ValidFrom if any @param string $fieldSource Source for field from round @param string $fieldName Name from round @param int $prevRoundId Id from round @param \Gems_Tracker_Token $token @param \Gems_Tracker_RespondentTrack $respTrack @return \MUtil_Date date time or null
entailment
protected function getValidUntilDate($fieldSource, $fieldName, $prevRoundId, \Gems_Tracker_Token $token, \Gems_Tracker_RespondentTrack $respTrack, $validFrom) { $date = null; switch ($fieldSource) { case parent::ANSWER_TABLE: if ($prev = $respTrack->getActiveRoundToken($...
Returns the date to use to calculate the ValidUntil if any @param string $fieldSource Source for field from round @param string $fieldName Name from round @param int $prevRoundId Id from round @param \Gems_Tracker_Token $token @param \Gems_Tracker_RespondentTrack $respTrack @param \MUtil_Date $validFrom The calculated...
entailment
public function getAge($date = NULL) { if (is_null($date)) { $date = new \MUtil_Date(); } if ($date instanceof \MUtil_Date) { // Now calculate age $birthDate = $this->getBirthDate(); if ($birthDate instanceof \Zend_Date) { $age =...
Returns current age or at a given date when supplied @param \MUtil_Date|null $date @return int
entailment
protected function createModel() { if (! $this->model instanceof \Gems_Model_AppointmentModel) { $this->model = $this->loader->getModels()->createAppointmentModel(); $this->model->applyDetailSettings(); } $this->model->set('gap_admission_time', 'formatFunction', array...
Adds rows 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_VerticalTableBridge $bridge @param \MUtil_Model_ModelAbstract $model @return void / protected fun...
entailment
public function _createSelect(array $filter, array $sort) { $select = parent::_createSelect($filter, $sort); $config = $select->getAdapter()->getConfig(); if (isset($config['dbname'])) { $constraint = $select->getAdapter()->quoteInto(' AND TABLE_SCHEMA=?', $config['dbname']); ...
Get a select statement using a filter and sort Modified to add the information schema, only possible like this since the table has no primary key and can not be added using normal joins @param array $filter @param array $sort @return \Zend_Db_Table_Select
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { $this->addMessage($this->_('Unsubscribing not possible')); $html = $this->getHtmlSequence(); $html->h2($this->_('Unsubscribing not possible')); $p = $html->pInfo($this->_('To unsubscribe please contact the organization that ...
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 execute($tokenData = null, $userId = null) { $batch = $this->getBatch(); $tracker = $this->loader->getTracker(); $batch->addToCounter('checkedTokens'); $token = $tracker->getToken($tokenData); $wasAnswered = $token->isCompleted(); if ($result = $t...
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) { // $bridge->getTable()->setAlternateRowClass('odd', 'odd', 'even', 'even'); // \MUtil_Model::$verbose = true; $bridge->add( 'gro_round_description', ...
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 addHeader($filename) { $file = fopen($filename, 'w'); //$bom = pack("CCC", 0xef, 0xbb, 0xbf); //fwrite($file, $bom); $name = $this->getName(); $labels = $this->getLabeledColumns(); fputcsv($file, $labels, $this->delimiter, '"'); ...
Add headers to a specific file @param string $filename The temporary filename while the file is being written
entailment
public function addRow($row, $file) { $exportRow = $this->filterRow($row); $labeledCols = $this->getLabeledColumns(); $exportRow = array_replace(array_flip($labeledCols), $exportRow); $changed = false; foreach ($exportRow as $name => $value) { $type = $this->model...
Add a separate row to a file @param array $row a row in the model @param file $file The already opened file
entailment
protected function addSyntaxFile($filename) { $model = $this->model; $files = $this->getFiles(); $datFileName = array_search($filename, $files); $spsFileName = substr($datFileName, 0, -strlen($this->fileExtension)) . '.R'; $tmpFileName = substr($filename, 0, -strl...
Creates a correct syntax file and adds it to the Files array
entailment
protected function afterLoad() { if ($this->_data && ! $this->_organizations) { foreach (['gaf_filter_text1', 'gaf_filter_text2', 'gaf_filter_text3', 'gaf_filter_text4'] as $field) { if ($this->_data[$field]) { $this->_organizations[$this->_data[$field]] = $t...
Override this function when you need to perform any actions when the data is loaded. Test for the availability of variables as these objects can be loaded data first after deserialization or registry variables first after normal instantiation. That is why this function called both at the end of afterRegistry() and af...
entailment
public function matchAppointment(\Gems_Agenda_Appointment $appointment) { if ($this->_organizations) { return isset($this->_organizations[$appointment->getOrganizationId()]); } return ! $appointment->getOrganizationId(); }
Check a filter for a match @param \Gems\Agenda\Gems_Agenda_Appointment $appointment @return boolean
entailment
public function matchAppointment(\Gems_Agenda_Appointment $appointment) { if (! $this->_data['gaf_filter_text1']) { return ! $appointment->getSubject(); } $regex = '/' . str_replace(array('%', '_'), array('.*', '.{1,1}'),$this->_data['gaf_filter_text1']) . '/i'; return ...
Check a filter for a match @param \Gems\Agenda\Gems_Agenda_Appointment $appointment @return boolean
entailment
public function render($content) { $form = $this->getElement(); if (!$form instanceof \Zend_Form) { return $content; } $this->_recurseForm($form); return $content; }
Render the TabErrors We don't return anything, we just add a class to the tab so it shows the errors @param <type> $content @return <type>
entailment
public function getVerbose() { if (null !== ($verboseOpt = $this->getOption('verbose'))) { $this->_verbose = (bool) $verboseOpt; $this->removeOption('verbose'); } return $this->_verbose; }
Should the tab errors be verbose? Verbose means that apart from marking and selecting the tab that has errors we also show an error above the form. @return boolean
entailment
protected function _recurseForm(\Zend_Form $form) { $subFormsWithErrors = array(); $subFormMessages = array(); $tabId = 0; foreach ($form->getSubForms() as $subForm) { if ($subForm instanceof \Gems_Form_TabSubForm) { // See if any of the subformelements has ...
Recurse through a form object, rendering errors @param \Zend_Form $form @param \Zend_View_Interface $view @return string
entailment
public function isValid($value, $context = array()) { $this->_valid = $this->_authenticator->verify($this->_key, $value); return $this->_valid; }
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
public function execute($trackId = null, $surveyId = null) { $batch = $this->getBatch(); $select = $this->db->select(); $select->from('gems__surveys', array('gsu_export_code', 'gsu_survey_name', 'gsu_survey_description', 'gsu_surveyor_id')) ->where('gsu_id_survey = ?', $surv...
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 getPanel() { $body = Zend_Controller_Front::getInstance()->getResponse()->getBody(); $liberrors = libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->loadHtml($body); libxml_use_internal_errors($liberrors); $panel = '<h4>HTML Information<...
Gets content panel for the Debugbar @return string
entailment
public function afterRegistry() { parent::afterRegistry(); $orgId = $this->respondent->getOrganizationId(); // These values are set for the generic table snippet and // should be reset for this snippet $this->browse = false; $this->extraFilter = array("...
Called after the check that all required registry values have been set correctly has run. @return void
entailment
protected function createModel() { $translated = $this->util->getTranslated(); $model = new \MUtil_Model_TableModel('gems__tracks'); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gtr_survey_rounds', 'label', $this->_('Survey #')); $model->set('g...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
protected function _loadAllTraversable() { $data = array(); foreach (array_reverse($this->directories) as $pathData) { $mainDirectory = $pathData['path']; $location = $pathData['name']; $db = $pathData['db']; $tables = $this->l...
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 runScript(array $data, $includeResultSets = false) { $results = array(); if ($data['script']) { $queries = \MUtil_Parser_Sql_WordsParser::splitStatements($data['script'], false); $qCount = count($queries); $results[] = sprintf($this->_('Executed ...
Run a sql statement from an object loaded through this model $data is an array with the following keys: script The sql statement to be executed name The name of the table, used in messages type Type of db element (table or view), used in messages @param array $data @param boolean $includeResultSets @return ...
entailment
protected function createModel($detailed, $action) { $yesNo = $this->util->getTranslated()->getYesNo(); $model = new \Gems_Model_JoinModel('surveys', 'gems__surveys'); $model->addTable('gems__groups', array('gsu_id_primary_group' => 'ggp_id_group')); $model->addColumn( ...
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 createModel($detailed, $action) { $model = $this->loader->getModels()->createAppointmentModel(); $model->applyBrowseSettings(); 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 getDateFormat() { $model = $this->getModel(); $format = $model->get('gap_admission_time', 'dateFormat'); if (! $format) { $format = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat'); } return $format; }
Get the date format used for the appointment date @return array
entailment
public function getSearchDefaults() { if (! $this->defaultSearchData) { $org = $this->currentOrganization; $this->defaultSearchData = array( 'gap_id_organization' => $org->canHaveRespondents() ? $org->getId() : null, 'dateused' => 'gap_admis...
Function to allow the creation of search defaults in code @see getSearchFilter() @return array
entailment
protected function _checkTokenTable(array $tokenTable) { $missingFields = parent::_checkTokenTable($tokenTable); return self::addnewAttributeFields($tokenTable, $missingFields); }
Check a token table for any changes needed by this version. @param array $tokenTable @return array Fieldname => change field commands
entailment
protected function _fillAttributeMap(\Gems_Tracker_Token $token) { $values = parent::_fillAttributeMap($token); return self::addnewAttributeDefaults($values); }
Returns a list of field names that should be set in a newly inserted token. Adds the fields without default new in 2.00 @param \Gems_Tracker_Token $token @return array Of fieldname => value type
entailment
public static function addnewAttributeFields(array $tokenTable, array $missingFields) { if (! isset($tokenTable['participant_id'])) { $missingFields['participant_id'] = "ADD participant_id varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL"; } if (! isset($tokenT...
Adds the fields without default new in 2.00 @param array $tokenTable @param array $missingFields @return array Fieldname => change field commands
entailment
public function getTokenUrl(\Gems_Tracker_Token $token, $language, $surveyId, $sourceSurveyId) { if (null === $sourceSurveyId) { $sourceSurveyId = $this->_getSid($surveyId); } $tokenId = $this->_getToken($token->getTokenId()); if ($this->_isLanguage($sourceSurveyId, $lan...
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 lsDbQuery($sourceSurveyId, $sql, $bindValues=array()) { $this->_getFieldMap($sourceSurveyId)->lsDbQuery($sql, $bindValues); }
Execute a Database query on the limesurvey Database @param $sourceSurveyId int Limesurvey survey ID @param $sql mixed SQL query to perform on the limesurvey database @param array $bindValues optional bind values for the Query
entailment
protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $this->saveLabel = $this->_('Change organization'); $choices = [ 'share' => $this->_('Share between both organizations, keep tracks in old'), 'copy' => $t...
Adds elements from the model to the bridge that creates the form. Overrule this function to add different elements to the browse table, without having to recode the core table building code. @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function afterSave($changed) { // Communicate to user if ($changed) { switch ($this->formData['change_method']) { case 'share': $message = $this->_('Shared %s with %s as %s'); break; case 'copy': ...
Hook that allows actions when data was saved When not rerouted, the form will be populated afterwards @param int $changed The number of changed rows (0 or 1 usually, but can be more)
entailment
protected function getTitle() { if ($this->respondent instanceof \Gems_Tracker_Respondent) { if ($this->currentUser->areAllFieldsMaskedWhole('grs_first_name', 'grs_surname_prefix', 'grs_last_name')) { return sprintf( $this->_('Change organization of respon...
Retrieve the header title to display @return string
entailment
protected function loadFormData() { parent::loadFormData(); if (! isset($this->formData['change_method'])) { $this->formData['change_method'] = null; } $this->formData['orig_org_id'] = $this->request->getParam(\MUtil_Model::REQUEST_ID2); }
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
protected function saveData() { $this->beforeSave(); $fromOrgId = $this->request->getParam(\MUtil_Model::REQUEST_ID2); $fromPid = $this->request->getParam(\MUtil_Model::REQUEST_ID1); $fromRespId = $this->respondent->getId(); $toOrgId = $this->formData['gr2o_id_org...
Hook containing the actual save code. Calls afterSave() for user interaction. @see afterSave()
entailment
protected function saveShare($fromOrgId, $fromRespId, $toOrgId, $toPatientId) { $model = $this->getModel(); try { $result = $model->copyToOrg($fromOrgId, $fromRespId, $toOrgId, $toPatientId, $this->keepConsent); } catch (\Exception $exc) { // Maybe we could do somethi...
Copy the respondent @param int $fromOrgId @param int $fromRespId @param int $toOrgId @param string $toPatientId @return int 1 If saved
entailment
protected function saveTo($fromOrgId, $fromRespId, $toOrgId, $toPatientId) { $model = $this->getModel(); try { $model->move($fromOrgId, $fromRespId, $toOrgId, $toPatientId); } catch (\Exception $exc) { $this->addMessage($exc->getMessage()); return 0; ...
Move the respondent @param int $fromOrgId @param int $fromRespId @param int $toOrgId @param string $toPatientId @return int 1 If saved
entailment
protected function setAfterSaveRoute() { $this->routeAction = 'show'; if ($this->request->getActionName() !== $this->routeAction) { $this->afterSaveRouteUrl = array( $this->request->getControllerKey() => $this->request->getControllerName(), $this->request...
Set what to do when the form is 'finished'. @return \MUtil_Snippets_ModelFormSnippetAbstract (continuation pattern)
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
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $br = \MUtil_Html::create('br'); if ($this->showSelected) { $selectedClass = \MUtil_Lazy::iff(\MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedCo...
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 addButtons(\MUtil_Html_HtmlElement $html) { $buttonDiv = $html->buttonDiv(); $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();')); $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();')); }
Add the buttons to the result div @param \MUtil_Html_HtmlElement $html
entailment
public function addHeaderInfo(\MUtil_Html_HtmlElement $htmlDiv) { $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber())); if (! $this->currentUser->isFieldMaskedWhole('name')) { $htmlDiv->pInfo(sprintf( ...
Add elements that form the header @param \MUtil_Html_HtmlElement $htmlDiv
entailment
protected function createModel() { $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage()); $model->addColumn($this->util->getTokenData()->getStatusExpression(), 'token_status'); $model->set('gto_valid_from', 'dateFormat', $this->dateFormat); $model->set('gto_comp...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { $htmlDiv = \MUtil_Html::create()->div(array('class' => 'answer-container')); if ($this->tokenId) { if ($this->token->exists) { if ($this->showHeaders) { $this->addHeaderInfo($htmlDiv); ...
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->tokenId) { if (isset($this->token)) { $this->tokenId = $this->token->getTokenId(); } } elseif (! $this->token) { $this->token = $this->loader->getTracker()->getToken($this->tokenId); } ...
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
public function getFullDescription() { if ($this->_description) { return $this->_description; } $descr = $this->getRoundDescription(); $hasDescr = strlen(trim($descr)); $order = $this->getRoundOrder(); $survey = $this->getSurvey();...
Get a round description with order number and survey name @return string
entailment
public function getSurvey() { if (false !== $this->_survey) { return $this->_survey; } $surveyId = $this->getSurveyId(); if ($surveyId) { $this->_survey = $this->tracker->getSurvey($surveyId); } else { $this->_survey = null; } ...
Get the survey id for this round @return \Gems_Tracker_Survey
entailment
public function getRespondent() { static $respondent; if (! $respondent) { $patientNumber = $this->_getParam(\MUtil_Model::REQUEST_ID1); $organizationId = $this->_getParam(\MUtil_Model::REQUEST_ID2); $respondent = $this->loader->getRespondent($patientNumber, $o...
Get the respondent object @return \Gems_Tracker_Respondent
entailment
public function getSearchData($useRequest = true) { $data = parent::getSearchData($useRequest); // Survey action data $data['gto_id_respondent'] = $this->getRespondentId(); $orgsFor = $this->util->getOtherOrgsFor($this->_getParam(\MUtil_Model::REQUEST_ID2)); if (is_array(...
Get the data to use for searching: the values passed in the request + any defaults used in the search form (or any other search request mechanism). It does not return the actual filter used in the query. @see getSearchFilter() @param boolean $useRequest Use the request as source (when false, the session is used) @re...
entailment
public function applyBrowseSettings($addCount = true) { $conditions = $this->loader->getConditions(); $yesNo = $this->util->getTranslated()->getYesNo(); $types = $conditions->getConditionTypes(); reset($types); $default = key($types); $this->set('gcon_type', 'label...
Set those settings needed for the browse display @param boolean $addCount Add a count in rounds column @return \Gems\Model\ConditionModel
entailment
public function applyDetailSettings() { $this->applyBrowseSettings(false); $yesNo = $this->util->getTranslated()->getYesNo(); $this->resetOrder(); $this->set('gcon_type'); $this->set('gcon_class'); $this->set('gcon_name', 'description', $this->_('A name for this co...
Set those settings needed for the detailed display @return \Gems\Model\ConditionModel
entailment
public function applyEditSettings($create = false) { $this->applyDetailSettings(); // gcon_id is not needed for some validators $this->set('gcon_id', 'elementClass', 'Hidden'); $this->set('gcon_active', 'elementClass', 'Checkbox'); return $this; }
Set those values needed for editing @return \Gems\Model\ConditionModel
entailment
protected function getTabs() { $tabs['default'] = array($this->_('Default'), 'title' => $this->_('To do 2 weeks ahead and done')); $tabs['todo'] = $this->_('To do'); $tabs['done'] = $this->_('Done'); $tabs['missed'] = $this->_('Missed'); $tabs['all'] = $this->_('Al...
Function used to fill the tab bar @return array tabId => label
entailment
public function hasHtmlOutput() { $reqFilter = $this->request->getParam('filter'); switch ($reqFilter) { case 'todo': //Only actions valid now that are not already done $filter[] = 'gto_completion_time IS NULL'; $filter[] = 'gto_valid_from ...
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
public function validate($bankAccountNumber) { if (is_array($bankAccountNumber)) { $parts = $bankAccountNumber; } else { $parts = $this->parseNumber($bankAccountNumber); } if (empty($parts)) { return false; } list($firstPart, $seco...
Use full valid format YYYY-XXXXXX/ZZZZ - prefix part is optional Or use output from parseNumber method (array) @param string|array $bankAccountNumber @return bool
entailment
public function validateCheckSum($bankAccountPart) { $bankAccountPart = $this->trimZeroDigits($bankAccountPart); if (!empty($bankAccountPart)) { preg_match_all('/(\d)/', $bankAccountPart, $parts); if (!empty($parts) && !empty($parts[0])) { $parts = $parts[0];...
Count and verify checkSum based on legislative @param string $bankAccountPart - numeric part from account number (first or second - before/after separator) @return bool
entailment
public function validateBankCode($bankCode) { return self::BANK_CODE_LENGTH == strlen($bankCode) && isset($this->validBankCodes[$bankCode]); }
@param string $bankCode @return bool
entailment
public function parseNumber($bankAccountNumber) { $pattern = <<<PATTERN ~ ^ (?: ((\d{0,%1\$d})-(\d{%2\$d,%3\$d})) # account number with two parts | # or ((\d{%2\$d,%3\$d})) ...
Parse string account number in format XXXX-YYYYYY/ZZZZ or XXXXXXX/ZZZZ @param string $bankAccountNumber @return array [$firstPart, $secondPart, $bankCode] - if some part is not matched, return it null
entailment
private function getBankCodes($codesFile) { if (!is_file($codesFile)) { throw new MissingBankCodesFileException('Czech bank codes CSV file is not valid. ' . $codesFile); } $data = str_getcsv(file_get_contents($codesFile), "\n"); array_shift($data); $validBankCodes...
@param $codesFile @return array @throws MissingBankCodesFileException
entailment
protected function getUserSelect($login_name, $organization) { if ((0 == ($this->hoursResetKeyIsValid % 24)) || \Zend_Session::$_unitTestEnabled) { $resetExpr = 'CASE WHEN ADDDATE(gup_reset_requested, ' . intval($this->hoursResetKeyIsValid / 24) . ') >= CU...
A select used by subclasses to add fields to the select. @param string $login_name @param int $organization @return \Zend_Db_Select
entailment
public function execute() { $role = \Gems_Roles::getInstance(); $parents = $this->db->fetchPairs("SELECT grl_id_role, grl_parents FROM gems__roles"); // \MUtil_Echo::track($parents); if ($parents) { foreach ($parents as $id => $priv) { $values[...
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 createModel($detailed, $action) { $respondent = $this->getRespondent(); $model = $this->loader->getModels()->createEpisodeOfCareModel(); if ($detailed) { if (('edit' === $action) || ('create' === $action)) { $model->applyEditSettings($responde...
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 getContentTitle() { $respondent = $this->getRespondent(); $patientId = $respondent->getPatientNumber(); if ($patientId) { if ($this->currentUser->areAllFieldsMaskedWhole('grs_first_name', 'grs_surname_prefix', 'grs_last_name')) { return sprintf($t...
Helper function to get the informed title for the index action. @return $string
entailment
public function getRespondent() { if (! $this->_respondent) { $id = $this->_getParam(\Gems_Model::EPISODE_ID); if ($id && ! ($this->_getParam(\MUtil_Model::REQUEST_ID1) || $this->_getParam(\MUtil_Model::REQUEST_ID2))) { $episode = $this->loader->getAgenda()->getEpisod...
Get the respondent object @return \Gems_Tracker_Respondent
entailment
public function getTopic($count = 1) { $respondent = $this->getRespondent(); $patientId = $respondent->getPatientNumber(); if ($patientId) { if ($this->currentUser->areAllFieldsMaskedWhole('grs_first_name', 'grs_surname_prefix', 'grs_last_name')) { $for = sprintf...
Helper function to allow generalized statements about the items in the model. @param int $count @return $string
entailment
public function format($row, $model) { foreach ($row as $fieldname=>$value) { $row[$fieldname] = $this->_format($fieldname, $row[$fieldname], $model); } return $row; }
Formats a row of data using the given model Static method only available for single rows, for a convenient way of using on a rowset, use the class and iterate @param array $row @param \MUtil_Model_ModelAbstract $model @return array The formatted array
entailment
private function _format($name, $result, $model) { static $view = null; if (!isset($this->_options[$name])) { $this->_options[$name] = $model->get($name, array('default', 'multiOptions', 'formatFunction', 'dateFormat', 'storageFormat', 'itemDisplay')); } $options = $thi...
This is the actual format function, copied from the Exhibitor for field @param type $name @param type $result @param \MUtil_Model_ModelAbstract $model @return type
entailment
public function write($path, $contents, Config $config) { return $this->writeObject($path, $contents, $config); }
Write a new file. @param string $path @param string $contents @param Config $config Config object @return array|false false on failure file meta data on success
entailment
public function writeStream($path, $resource, Config $config) { return $this->writeObject($path, $resource, $config); }
Write a new file using a stream. @param string $path @param resource $resource @param Config $config Config object @return array|false false on failure file meta data on success
entailment
public function update($path, $contents, Config $config) { return $this->writeObject($path, $contents, $config); }
Update a file. @param string $path @param string $contents @param Config $config Config object @return array|false false on failure file meta data on success
entailment
public function updateStream($path, $resource, Config $config) { return $this->writeObject($path, $resource, $config); }
Update a file using a stream. @param string $path @param resource $resource @param Config $config Config object @return array|false false on failure file meta data on success
entailment
public function rename($path, $newpath) { $statusCopy = $this->copy($path, $newpath); $statusRemoveOld = $this->delete($path); return $statusCopy && $statusRemoveOld; }
Rename a file. @param string $path @param string $newpath @return bool
entailment
public function copy($path, $newpath) { $path = $this->applyPathPrefix($path); $newpath = $this->applyPathPrefix($newpath); $this->bucket ->object($path) ->copy($this->bucket, ['name' => $newpath]); return $this->bucket->object($newpath)->exists(); }
Copy a file. @param string $path @param string $newpath @return bool
entailment
public function delete($path) { $path = $this->applyPathPrefix($path); $object = $this->bucket->object($path); if (false === $object->exists()) { return true; } $object->delete(); return !$object->exists(); }
Delete a file. @param string $path @return bool
entailment
public function deleteDir($dirname) { $dirname = rtrim($dirname, '/').'/'; if (false === $this->has($dirname)) { return false; } $dirname = $this->applyPathPrefix($dirname); $this->bucket->object($dirname)->delete(); return !$this->bucket->object($dirn...
Delete a directory. @param string $dirname @return bool
entailment
public function createDir($dirname, Config $config) { $path = $this->applyPathPrefix($dirname); $path = rtrim($path, '/').'/'; $object = $this->bucket->upload('', ['name' => $path]); return $this->convertObjectInfo($object); }
Create a directory. @param string $dirname directory name @param Config $config @return array|false
entailment
public function setVisibility($path, $visibility) { $path = $this->applyPathPrefix($path); $object = $this->bucket->object($path); switch (true) { case $visibility === AdapterInterface::VISIBILITY_PUBLIC: $object->acl()->add('allUsers', Acl::ROLE_READER); ...
Set the visibility for a file. @param string $path @param string $visibility @return array|false file meta data
entailment
public function has($path) { $path = $this->applyPathPrefix($path); $object = $this->bucket->object($path); return $object->exists(); }
Check whether a file exists. @param string $path @return array|bool|null
entailment
public function read($path) { $path = $this->applyPathPrefix($path); $object = $this->bucket->object($path); $contents = $object->downloadAsString(); return compact('path', 'contents'); }
Read a file. @param string $path @return array|false
entailment
public function listContents($directory = '', $recursive = false) { $directory = $this->applyPathPrefix($directory); $objects = $this->bucket->objects( [ 'prefix' => $directory, ] ); $contents = []; foreach ($objects as $apiObject) { ...
List contents of a directory. @param string $directory @param bool $recursive @return array
entailment
public function getMetadata($path) { $path = $this->applyPathPrefix($path); $object = $this->bucket->object($path); if (!$object->exists()) { return false; } return $this->convertObjectInfo($object); }
Get all the meta data of a file or directory. @param string $path @return array|false
entailment
public function getVisibility($path) { $path = $this->applyPathPrefix($path); try { $allUsersAcl = $this->bucket->object($path)->acl()->get(['entity' => 'allUsers']); if ($allUsersAcl['role'] === Acl::ROLE_READER) { return ['path' => $path, 'visibility' => A...
Get the visibility of a file. @param string $path @return array|false
entailment
public function getUrl($path) { $path = $this->applyPathPrefix($path); return implode('/', [$this->baseUrl, $path]); }
@param string $path @return string
entailment
protected function convertObjectInfo($object) { $identity = $object->identity(); $objectInfo = $object->info(); $objectName = $identity['object']; // determine whether it's a file or a directory $type = 'file'; $objectNameLength = strlen($objectName); if (str...
@param $object StorageObject @return array
entailment
protected function getOptionsFromConfig(Config $config) { $options = []; if ($config->has('visibility')) { switch (true) { case $config->get('visibility') === AdapterInterface::VISIBILITY_PUBLIC: $options['predefinedAcl'] = static::GCS_VISIBILITY_PUBL...
Converts flysystem specific config to options for the underlying API client @param $config Config @return array
entailment
protected function writeObject($path, $contents, Config $config) { $path = $this->applyPathPrefix($path); $metadata = [ 'name' => $path, ]; $metadata += $this->getOptionsFromConfig($config); $uploadedObject = $this->bucket->upload($contents, $metadata); ...
Writes an object to the current @param string $path @param string|resource $contents @param Config $config @return array
entailment
public function createModel($detailed, $action) { // \MUtil_Model::$verbose = true; $model = $this->loader->getTracker()->getTokenModel(); $model->setCreate(false); $model->set('gr2o_patient_nr', 'label', $this->_('Respondent')); $model->set('gto_round_description', 'l...
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 emailAction() { $model = $this->getModel(); $model->setFilter($this->getSearchFilter(false)); $sort = array( 'gr2o_email' => SORT_ASC, 'grs_first_name' => SORT_ASC, 'grs_surname_prefix' => SORT_ASC, 'grs_last_na...
Bulk email action
entailment
public function getSearchDefaults() { if (! $this->defaultSearchData) { $inFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat'); $now = new \MUtil_Date(); $today = $now->toString($inFormat); $this->defaultSearchData = array( ...
Function to allow the creation of search defaults in code @see getSearchFilter() @return array
entailment