sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function addCurrentParent($label = null)
{
$parent = $this->menu->getCurrentParent();
if ($parent && (! $parent->isTopLevel())) {
$this->addMenuItem($parent, $label);
}
return $this;
} | Adds the parent of the current menu item
Does nothing when the parent is a top level item (has no
controllor or is the \Gems_menu itself).
@param string $label Optional alternative label
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
public function addCurrentSiblings($anyParameters = false, $includeCurrent = false)
{
if ($current = $this->menu->getCurrent()) {
if ($parent = $current->getParent()) {
$parameters = $current->getParameters();
if ($includeCurrent) {
$current = null;
}
foreach ($parent->getChildren() as $menuItem) {
// Add any menu item that is not the current menu item
// and that has the same parameters, unless $anyParameters is true.
if (($menuItem !== $current) && ($anyParameters || ($menuItem->getParameters() == $parameters))) {
$this->addMenuItem($menuItem);
}
}
}
}
return $this;
} | Adds the siblings (= other children of the parent) of the current menu item to this list
@param boolean $anyParameters When false, siblings must have the same parameter set as the current menu item
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
public function addMenuItem(\Gems_Menu_SubMenuItem $menuItem, $label = null)
{
$key = $this->_getKey($menuItem->get('controller'), $menuItem->get('action'));
if ($label) {
$this->altLabels[$key] = $label;
}
$this->offsetSet($key, $menuItem);
return $this;
} | Add a menu item to this list
@param \Gems_Menu_SubMenuItem $menuItem
@param string $label Optional alternative label
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
public function getActionLink($controller, $action = 'index', $remove = false)
{
$key = $this->_getKey($controller, $action);
if ($this->offsetExists($key)) {
$result = $this->toActionLink($key);
if ($remove) {
$this->offsetUnset($key);
}
return $result;
}
} | Get the action link for a specific item.
@param string $controller Controller name
@param string $action Action name
@param boolean $remove Optional, set to true to remove the item from this list.
@return \MUtil_Html_HtmlElement | entailment |
public function getActionLinks($remove, $contr1, $action1 = null, $contr2 = null, $action2 = null)
{
$args = func_get_args();
$count = func_num_args();
$results = new \MUtil_Html_Sequence();
$results->setGlue($this->getGlue());
for ($i = 1; $i < $count; $i += 2) {
$controller = $args[$i];
$action = $args[$i + 1];
$result = $this->getActionLink($controller, $action, $remove);
if ($result) {
$results[$this->_getKey($controller, $action)] = $result;
}
}
return $results;
} | Get the action links for the specified items.
@param boolean $remove Optional, set to true to remove the item from this list.
@param string $contr1 Controller name
@param string $action1 Action name, continues in pairs
@return \MUtil_Html_Sequence | entailment |
public function getFirstAction($remove = true)
{
foreach ($this->getArrayCopy() as $key => $item) {
if ($result = $this->toActionLink($key)) {
if ($remove) {
$this->offsetUnset($key);
}
return $result;
}
}
} | Get the action link for a specific item.
@param boolean $remove Optional, set to true to remove the item from this list.
@return \MUtil_Html_HtmlElement | entailment |
public function render(\Zend_View_Abstract $view)
{
$html = '';
$glue = $this->getGlue();
foreach ($this->getIterator() as $key => $item) {
$html .= $glue;
if ($item instanceof \Gems_Menu_SubMenuItem) {
$item = $this->toActionLink($key);
}
$html .= \MUtil_Html::renderAny($view, $item);
}
return substr($html, strlen($glue));
} | 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 |
public function setLabel($controller, $action, $label)
{
$key = $this->_getKey($controller, $action);
$this->altLabels[$key] = $label;
return $this;
} | Changes the label for a specific menu item
@param string $controller Controller name
@param string $action Action name
@param string $label Alternative label
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
public function showDisabled($value = true)
{
$this->sources[self::KEY_DISABLED] = (boolean) $value;
return $this;
} | Switches showing disabled menu items on or off (= default)
@param boolean $value
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
public function get($parameter)
{
return isset($this->credentials[$parameter]) ? $this->credentials[$parameter] : null;
} | Get a single credential parameter.
@param string $parameter
@return mixed|null | entailment |
public function execute($respTrackData = null)
{
$batch = $this->getBatch();
$tracker = $this->loader->getTracker();
$respTrack = $tracker->getRespondentTrack($respTrackData);
$fieldsChanged = false;
$tokensChanged = $respTrack->recalculateFields($fieldsChanged);
$t = $batch->addToCounter('trackFieldsChecked');
if ($fieldsChanged) {
$i = $batch->addToCounter('trackFieldsChanged');
} else {
$i = $batch->getCounter('trackFieldsChanged');
}
if ($tokensChanged) {
$j = $batch->addToCounter('trackTokensChanged');
} else {
$j = $batch->getCounter('trackTokensChanged');
}
$batch->setMessage(
'trackFieldsCheck',
sprintf($this->_('%d tracks checked, %d fields changed, %d token changed.'), $t, $i, $j));
} | 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 execute($tokenId = null)
{
$batch = $this->getBatch();
$tracker = $this->loader->getTracker();
$token = $tracker->getToken($tokenId);
$checked = $batch->addToCounter('ta-checkedTokens');
if ($token->inSource()) {
$survey = $token->getSurvey();
if ($survey->copyTokenToSource($token, '')) {
$batch->addToCounter('ta-changedTokens');
}
}
$cTokens = $batch->getCounter('ta-changedTokens');
$batch->setMessage('ta-check', sprintf(
$this->plural('%d token out of %d tokens changed.', '%d tokens out of %d tokens changed.', $cTokens),
$cTokens,
$checked
));
} | 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()
{
if (! $this->model instanceof LogModel) {
$this->model = $this->loader->getModels()->createLogModel();
$this->model->applyDetailSettings();
}
return $this->model;
} | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
{
if ($this->request->getParam('log')) {
$model->setFilter(array('gla_id' => $this->request->getParam('log')));
parent::processSortOnly($model);
} else {
parent::processFilterAndSort($model);
}
} | Overrule to implement snippet specific filtering and sorting.
@param \MUtil_Model_ModelAbstract $model | entailment |
protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$row = $bridge->getRow();
parent::setShowTableFooter($bridge, $model);
if (isset($row['gla_respondent_id'], $row['gla_organization']) &&
($this->menuList instanceof \Gems_Menu_MenuList)) {
try {
$patientNr = $this->util->getDbLookup()->getPatientNr($row['gla_respondent_id'], $row['gla_organization']);
$this->menuList->addParameterSources(array(
'gr2o_patient_nr' => $patientNr,
'gr2o_id_organization' => $row['gla_organization'],
));
$this->menuList->addByController('respondent', 'show', $this->_('Show respondent'));
} catch (Exception $exc) {
// Retrieving the patient van fail when an incorrect organization was logged.
// We silently fail and do not add thwe 'Show respondent' button
}
}
} | Set the footer of the browse table.
Overrule this function to set the header differently, without
having to recode the core table building code.
@param \MUtil_Model_Bridge_VerticalTableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@return void | entailment |
protected function executeAction($from = null, $to = null)
{
$context = $this->getRequest()->getParam('id', 'gems');
$from = $this->getRequest()->getParam('from', $from);
$to = $this->getRequest()->getParam('to', $to);
$batch = $this->loader->getTaskRunnerBatch('upgrade' . $context);
$batch->minimalStepDurationMs = 3000; // 3 seconds max before sending feedback
if (!$batch->isLoaded()) {
$this->_upgrades->setBatch($batch);
$this->_upgrades->execute($context, $to, $from);
}
$title = sprintf($this->_('Upgrading %s'), $context);
$this->_helper->BatchRunner($batch, $title, $this->accesslog);
$this->html->br();
$this->compatibilityReportAction();
} | Executes the upgrades for a certain context
optional: give from and to levels
usage: execute/context/<context>{/from/int/to/int} | entailment |
public function indexAction()
{
$this->html->h2($this->getTopicTitle());
$displayColumns = array('link' => '',
'context' => $this->_('Context'),
'maxLevel' => $this->_('Max level'),
'level' => $this->_('Level'));
foreach($this->_upgrades->getUpgradesInfo() as $row) {
$menuItem = $this->menu->findAllowedController($this->_getParam('controller'), 'show');
if ($menuItem) {
$row['link'] = $menuItem->toActionLinkLower($this->getRequest(), $row);
}
$data[] = $row;
}
$this->addSnippet('SelectiveTableSnippet', 'data', $data, 'class', 'browser table', 'columns', $displayColumns);
$this->html->br();
$this->compatibilityReportAction();
} | Overview of available contexts, max upgrade level and achieved upgrade level | entailment |
public function showAction()
{
$this->html->h2($this->getTopicTitle());
$context = $this->_getParam('id', 'gems');
$this->_upgrades->setContext($context);
if ($info = $this->_upgrades->getUpgradesInfo($context)) {
$this->html->table(array('class'=>'browser'))->tr()
->th($this->_('Context'))->td($info['context'])
->tr()
->th($this->_('Level'))->td($info['level']);
$data = $this->_upgrades->getUpgrades();
foreach($data as $level => $row) {
foreach($this->menu->getCurrent()->getChildren() as $menuItem) {
if ($menuItem->is('allowed', true)) {
$show = true;
if ($level <= $info['level'] && $menuItem->is('action','execute-to')) {
//When this level is < current level don't allow to execute from current level to this one
$show = false;
}
if ($level <= $info['level'] && $menuItem->is('action','execute-from')) {
//When this level is < current level don't allow to execute from current level to this one
$show = false;
}
if ($show) {
$row['action'][] = $menuItem->toActionLinkLower($this->getRequest(), $row, array('from'=>$level, 'to'=>$level));
}
}
}
$row['level'] = $level;
$data[$level] = $row;
}
$displayColumns = array('level' => $this->_('Level'),
'info' => $this->_('Description'),
'action' => $this->_('Action'));
$this->addSnippet('SelectiveTableSnippet', 'data', $data, 'class', 'browser', 'columns', $displayColumns);
} else {
$this->html[] = sprintf($this->_('Context %s not found!'), $context);
}
if ($parentItem = $this->menu->getCurrent()->getParent()) {
$this->html[] = $parentItem->toActionLink($this->getRequest(), $this->_('Cancel'));
}
} | Show the upgrades and level for a certain context
Usage: show/context/<context> | entailment |
protected function createModel($detailed, $action)
{
// Make sure the user is loaded
$user = $this->getSelectedUser();
if ($user) {
if (! ($this->currentUser->hasPrivilege('pr.staff.see.all') ||
$this->currentUser->isAllowedOrganization($user->getBaseOrganizationId()))) {
throw new \Gems_Exception($this->_('No access to page'), 403, null, sprintf(
$this->_('You have no right to access users from the organization %s.'),
$user->getBaseOrganization()->getName()
));
}
}
return parent::createModel($detailed, $action);
} | 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 is not in $summarizedActions.
@param string $action The current action.
@return \MUtil_Model_ModelAbstract | entailment |
public function getSearchDefaults()
{
$data = parent::getSearchDefaults();
if (! isset($data[\MUtil_Model::REQUEST_ID])) {
$data[\MUtil_Model::REQUEST_ID] = intval($this->_getIdParam());
}
return $data;
} | Function to allow the creation of search defaults in code
@see getSearchFilter()
@return array | entailment |
public function getSelectedUser()
{
static $user = null;
if ($user !== null) {
return $user;
}
$staffId = $this->_getIdParam();
if ($staffId) {
$user = $this->loader->getUserLoader()->getUserByStaffId($staffId);
$source = $this->menu->getParameterSource();
$user->applyToMenuSource($source);
} else {
$user = false;
}
return $user;
} | Load the user selected by the request - if any
@staticvar \Gems_User_User $user
@return \Gems_User_User or false when not available | entailment |
public function hasHtmlOutput()
{
if ($this->trackEngine && (! $this->trackId)) {
$this->trackId = $this->trackEngine->getTrackId();
}
if ($this->trackId) {
// Try to get $this->trackEngine filled
if (! $this->trackEngine) {
// Set the engine used
$this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->trackId);
}
} else {
return false;
}
if (! $this->roundId) {
$this->roundId = $this->request->getParam(\Gems_Model::ROUND_ID);
}
$this->createData = (! $this->roundId);
return parent::hasHtmlOutput();
} | 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 loadFormData()
{
parent::loadFormData();
if ($this->createData && !$this->request->isPost()) {
$this->formData = $this->trackEngine->getRoundDefaults() + $this->formData;
}
// Check the survey name
$surveys = $this->util->getTrackData()->getAllSurveys();
if (isset($surveys[$this->formData['gro_id_survey']])) {
$this->formData['gro_survey_name'] = $surveys[$this->formData['gro_id_survey']];
} else {
// Currently required
$this->formData['gro_survey_name'] = '';
}
} | Hook that loads the form data from $_POST or the model
Or from whatever other source you specify here. | entailment |
protected function saveData()
{
parent::saveData();
if ($this->createData && (! $this->roundId)) {
$this->roundId = $this->formData['gro_id_round'];
}
if ($this->formData['gro_valid_for_source'] == 'tok'
&& $this->formData['gro_valid_for_field'] == 'gto_valid_from'
&& empty($this->formData['gro_valid_for_id'])) {
// Special case we should insert the current roundID here
$this->formData['gro_valid_for_id'] = $this->roundId;
// Now save, don't call saveData again to keep changed message as is
$model = $this->getModel();
$this->formData = $model->save($this->formData);
}
$this->trackEngine->updateRoundCount($this->loader->getCurrentUser()->getUserId());
} | Hook containing the actual save code.
Call's afterSave() for user interaction.
@see afterSave() | entailment |
public function getRespondent()
{
if (! $this->_respondent) {
$patientNumber = $this->_getParam(\MUtil_Model::REQUEST_ID1);
$organizationId = $this->_getParam(\MUtil_Model::REQUEST_ID2);
$this->_respondent = $this->loader->getRespondent($patientNumber, $organizationId);
if ((! $this->_respondent->exists) && $patientNumber && $organizationId) {
throw new \Gems_Exception(sprintf($this->_('Unknown respondent %s.'), $patientNumber));
}
$this->_respondent->applyToMenuSource($this->menu->getParameterSource());
}
return $this->_respondent;
} | Get the respondent object
@return \Gems_Tracker_Respondent | entailment |
public function execute($userId = 0)
{
$batch = $this->getBatch();
if ($batch->getCounter('movestarted') === 0) {
$batch->addToCounter('movestarted');
$select = $this->loader->getTracker()->getTokenSelect(['total' => new \Zend_Db_Expr('count(*)')])->andReceptionCodes([])->onlyCompleted()->onlySucces()->forSurveyId($this->sourceSurveyId)->getSelect();
$count = $this->db->fetchOne($select);
$batch->addStepCount($count - 1); // For progressbar
$batch->resetCounter('movesteps');
$batch->addToCounter('movesteps', $count);
}
$this->executeIteration($userId);
} | 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 executeIteration($userId = 0)
{
$tracker = $this->loader->getTracker();
$select = $tracker->getTokenSelect()->andReceptionCodes([])->onlyCompleted()->onlySucces()->forSurveyId($this->sourceSurveyId)->getSelect()->limit(1);
$results = $this->db->fetchAll($select);
$batch = $this->getBatch();
$batch->addToCounter('movesteps', -1);
if (count($results) == 0) {
$this->_finished = true;
return;
}
/**
* The real work:
* - load the token
* - retrieve answers
* - change token to point to new survey
* - inject answers (based on question_code mappings
*/
// Load token and retrieve current answers
$tokenData = reset($results);
$token = $tracker->getToken($tokenData);
$answers = $token->getRawAnswers();
// Change answer codes
if (!empty($answers)) {
$convertedAnswers = [];
foreach ($this->targetFields as $target => $source) {
if (!empty($source) && array_key_exists($source, $answers)) {
$convertedAnswers[$target] = $answers[$source];
}
}
// Create a new token
$values = [
'gto_id_survey' => $this->targetSurveyId,
] + $tokenData;
unset($values['token_status']);
$newTokenId = $token->createReplacement(sprintf($this->_('Copied from old survey: %s'), $this->sourceSurveyName), $userId, $values);
$newToken = $tracker->getToken($newTokenId);
$newToken->getSurvey()->copyTokenToSource($newToken, ''); // Take no language, so we get the default
$newToken->setRawAnswers($convertedAnswers);
$batch->addToCounter('moved');
} else {
$batch->addToCounter('notfound');
}
$token->setReceptionCode($this->movedCode, sprintf($this->_('Copied to new survey: %s'), $this->targetSurveyName), $userId);
} | Execute a single iteration of the task.
@param array $params The parameters to the execute function | entailment |
public function isFinished()
{
$batch = $this->getBatch();
if ($this->_finished) {
$batch->resetCounter('movestarted');
$moved = $batch->getCounter('moved');
$notFound = $batch->getCounter('notfound');
$this->getBatch()->addMessage(
sprintf($this->_('%d \'%s\' survey answers have been copied to \'%s\'.'),
$moved,
$this->sourceSurveyName,
$this->targetSurveyName));
if ($notFound > 0) {
$this->getBatch()->addMessage(sprintf($this->_('For %d tokens no answers were found.'), $notFound));
}
} else {
if ($this->getBatch()->getCounter('movesteps') === 0) {
// Add 1 to the counter to keep going
$this->getBatch()->addStepCount(1);
}
}
return $this->_finished;
} | Return true when the task has finished.
@return boolean | entailment |
public function applyBrowseSettings()
{
$dbLookup = $this->util->getDbLookup();
$definitions = $this->loader->getUserLoader()->getAvailableStaffDefinitions();
$localized = $this->util->getLocalized();
$projectName = $this->project->getName();
$yesNo = $this->util->getTranslated()->getYesNo();
$this->resetOrder();
$this->set('gor_name', 'label', $this->_('Name'), 'tab', $this->_('General'));
$this->set('gor_location', 'label', $this->_('Location'));
$this->set('gor_task', 'label', $this->_('Task'),
'description', sprintf($this->_('Task in %s project'), $projectName)
);
$this->set('gor_url', 'label', $this->_('Company url'));
$this->setIfExists('gor_url_base', 'label', $this->_("Login url's"),
'description', sprintf(
$this->_("Always switch to this organization when %s is accessed from one of these space separated url's. The first url is used for mails."),
$projectName
)
);
$this->setIfExists('gor_code', 'label', $this->_('Organization code'),
'description', $this->_('Optional code name to link the organization to program code.')
);
$this->set('gor_provider_id', 'label', $this->_('Healthcare provider id'),
'description', $this->_('An interorganizational id used for import and export.')
);
$this->setIfExists('gor_active', 'label', $this->_('Active'),
'description', $this->_('Can the organization be used?'),
'multiOptions', $yesNo
);
$this->set('gor_contact_name', 'label', $this->_('Contact name'));
$this->set('gor_contact_email', 'label', $this->_('Contact email'));
// Determine order for details, but do not show in browse
$this->set('gor_welcome');
$this->set('gor_signature');
$this->set('gor_create_account_template');
$this->set('gor_reset_pass_template');
$this->set('gor_has_login', 'label', $this->_('Login'),
'description', $this->_('Can people login for this organization?'),
'multiOptions', $yesNo
);
$this->set('gor_add_respondents', 'label', $this->_('Accepting'),
'description', $this->_('Can new respondents be added to the organization?'),
'multiOptions', $yesNo
);
$this->set('gor_has_respondents', 'label', $this->_('Respondents'),
'description', $this->_('Does the organization have respondents?'),
'multiOptions', $yesNo
);
$this->set('gor_respondent_group', 'label', $this->_('Respondent group'),
'description', $this->_('Allows respondents to login.'),
'multiOptions', $dbLookup->getAllowedRespondentGroups()
);
$this->set('gor_accessible_by', 'label', $this->_('Accessible by'),
'description', $this->_('Checked organizations see this organizations respondents.'),
'multiOptions', $dbLookup->getOrganizations()
);
$tp = new \MUtil_Model_Type_ConcatenatedRow(':', ', ');
$tp->apply($this, 'gor_accessible_by');
$this->setIfExists('gor_allowed_ip_ranges');
if ($definitions) {
reset($definitions);
$this->setIfExists('gor_user_class', 'label', $this->_('User Definition'),
'default', key($definitions),
'multiOptions', $definitions
);
if (1 == count($definitions)) {
$this->setIfExists('gor_user_class',
'elementClass', 'None'
);
}
}
$groupLevel = [
'' => $this->_('Defer to user group setting'),
];
$screenLoader = $this->loader->getScreenLoader();
$this->setIfExists('gor_respondent_edit', 'label', $this->_('Respondent edit screen'),
'multiOptions', $groupLevel + $screenLoader->listRespondentEditScreens()
);
$this->setIfExists('gor_respondent_show', 'label', $this->_('Respondent show screen'),
'multiOptions', $groupLevel + $screenLoader->listRespondentShowScreens()
);
$this->setIfExists('gor_respondent_subscribe', 'label', $this->_('Subscribe screen'),
'multiOptions', $screenLoader->listSubscribeScreens()
);
$this->setIfExists('gor_respondent_unsubscribe', 'label', $this->_('Unsubscribe screen'),
'multiOptions', $screenLoader->listUnsubscribeScreens()
);
$this->setIfExists('gor_token_ask', 'label', $this->_('Token ask screen'),
'multiOptions', $screenLoader->listTokenAskScreens()
);
$this->setIfExists('gor_resp_change_event', 'label', $this->_('Respondent change event'),
'multiOptions', $this->loader->getEvents()->listRespondentChangedEvents()
);
$this->setIfExists('gor_iso_lang', 'label', $this->_('Language'),
'multiOptions', $localized->getLanguages()
);
if ($this->_styles) {
$this->setIfExists('gor_style', 'label', $this->_('Style'), 'multiOptions', $this->_styles);
}
return $this;
} | Set those settings needed for the browse display
@return \Gems_Model_OrganizationModel | entailment |
public function applyDetailSettings()
{
$commUtil = $this->util->getCommTemplateUtil();
$staffTemplates = $commUtil->getCommTemplatesForTarget('staffPassword', null, true);
$this->applyBrowseSettings();
$this->set('gor_welcome', 'label', $this->_('Greeting'),
'description', $this->_('For emails and token forward screen.'), 'elementClass', 'Textarea', 'rows', 5);
$this->set('gor_signature', 'label', $this->_('Signature'),
'description', $this->_('For emails and token forward screen.'), 'elementClass', 'Textarea', 'rows', 5);
$this->set('gor_create_account_template', 'label', $this->_('Create Account template'),
'default', $commUtil->getCommTemplateForCode('accountCreate', 'staffPassword'),
'multiOptions', $staffTemplates);
$this->set('gor_reset_pass_template', 'label', $this->_('Reset Password template'),
'default', $commUtil->getCommTemplateForCode('passwordReset', 'staffPassword'),
'multiOptions', $staffTemplates);
$this->setIfExists('gor_allowed_ip_ranges', 'label', $this->_('Allowed IP Ranges'),
'description', $this->_('Separate with | examples: 10.0.0.0-10.0.0.255, 10.10.*.*, 10.10.151.1 or 10.10.151.1/25')
);
if ($this->project->multiLocale) {
$this->set('gor_name', 'description', 'ENGLISH please! Use translation file to translate.');
$this->set('gor_url', 'description', 'ENGLISH link preferred. Use translation file to translate.');
}
return $this;
} | Set those settings needed for the detailed display
@return \Gems_Model_OrganizationModel | entailment |
public function applyEditSettings()
{
$this->applyDetailSettings();
$this->resetOrder();
$yesNo = $this->util->getTranslated()->getYesNo();
// GENERAL TAB
$this->set('gor_name',
'size', 25,
'validator', $this->createUniqueValidator('gor_name')
);
$this->set('gor_location',
'size', 50,
'maxlength', 255
);
$this->set('gor_task',
'size', 25);
$this->set('gor_url',
'size', 50
);
$this->setIfExists('gor_url_base',
'size', 50,
'filter', 'TrailingSlash'
);
$this->setIfExists('gor_code',
'size', 10
);
$this->set('gor_provider_id');
$this->setIfExists('gor_active',
'elementClass', 'Checkbox'
);
// EMAIL TAB
$this->set('gor_contact_name', 'tab', $this->_('Email') . ' & ' . $this->_('Token'),
'order', $this->getOrder('gor_active') + 1000,
'size', 25
);
$this->set('gor_contact_email',
'size', 50,
'validator', 'SimpleEmail'
);
$this->set('gor_mail_watcher', 'label', $this->_('Check cron job mail'),
'description', $this->_('If checked the organization contact will be mailed when the cron job does not run on time.'),
'elementClass', 'Checkbox',
'multiOptions', $yesNo
);
$this->set('gor_welcome',
'elementClass', 'Textarea',
'rows', 5
);
$this->set('gor_signature',
'elementClass', 'Textarea',
'rows', 5
);
$this->set('gor_create_account_template');
$this->set('gor_reset_pass_template');
// ACCESS TAB
$this->set('gor_has_login', 'tab', $this->_('Access'),
'order', $this->getOrder('gor_reset_pass_template') + 1000,
'elementClass', 'CheckBox'
);
$this->set('gor_add_respondents',
'elementClass', 'CheckBox'
);
$this->set('gor_has_respondents',
'elementClass', 'Exhibitor'
);
$this->set('gor_respondent_group');
$this->set('gor_accessible_by',
'elementClass', 'MultiCheckbox'
);
$this->set('allowed',
'label', $this->_('Can access'),
'elementClass', 'Html'
);
$this->setIfExists('gor_allowed_ip_ranges',
'elementClass', 'Textarea',
'rows', 4,
'validator', new \Gems_Validate_IPRanges()
);
$this->setIfExists('gor_user_class');
$definitions = $this->get('gor_user_class', 'multiOptions');
if ($definitions && (count($definitions) > 1)) {
reset($definitions);
// MD: Removed onchange because it does not play nice with the processAfterLoad and save methods in this class
// @@TODO: See if we can enable it when these methods are changed into a dependency
$this->setIfExists('gor_user_class', 'default', key($definitions), 'required', true/*, 'onchange', 'this.form.submit();'*/);
}
// INTERFACE TAB
$this->setIfExists('gor_respondent_edit', 'tab', $this->_('Interface'),
'default', '',
'elementClass', 'Radio'
);
$this->setIfExists('gor_respondent_show',
'default', '',
'elementClass', 'Radio'
);
$this->setIfExists('gor_respondent_subscribe',
'default', '',
'elementClass', 'Radio'
);
$this->setIfExists('gor_respondent_unsubscribe',
'default', '',
'elementClass', 'Radio'
);
$this->setIfExists('gor_token_ask',
'default', 'Gems\\Screens\\Token\\Ask\\ProjectDefaultAsk',
'elementClass', 'Radio'
);
$this->setIfExists('gor_resp_change_event',
'order', $this->getOrder('gor_user_class') + 1000
);
$this->setIfExists('gor_iso_lang',
'order', $this->getOrder('gor_user_class') + 1010,
'default', $this->project->getLocaleDefault()
);
if ($this->_styles) {
$this->setIfExists('gor_style');
}
return $this;
} | Set those values needed for editing
@return \Gems_Model_OrganizationModel | entailment |
public function processAfterLoad($data, $new = false, $isPostData = false)
{
$data = parent::processAfterLoad($data, $new, $isPostData);
if ($data instanceof \Traversable) {
$data = iterator_to_array($data);
}
foreach ($data as &$row) {
if (isset($row['gor_user_class']) && !empty($row['gor_user_class'])) {
$definition = $this->loader->getUserLoader()->getUserDefinition($row['gor_user_class']);
if ($definition instanceof \Gems_User_UserDefinitionConfigurableInterface && $definition->hasConfig()) {
$definition->addConfigFields($this);
$row = $row + $definition->loadConfig($row);
}
}
}
return $data;
} | Helper function that procesess the raw data after a load.
@see \MUtil_Model_SelectModelPaginator
@param mixed $data Nested array or \Traversable containing rows or iterator
@param boolean $new True when it is a new item
@param boolean $isPostData With post data, unselected multiOptions values are not set so should be added
@return array or \Traversable Nested | entailment |
public function save(array $newValues, array $filter = null, array $saveTables = null)
{
//First perform a save
$savedValues = parent::save($newValues, $filter, $saveTables);
//Now check if we need to save config values
if (isset($newValues['gor_user_class']) && !empty($newValues['gor_user_class'])) {
$definition = $this->loader->getUserLoader()->getUserDefinition($newValues['gor_user_class']);
if ($definition instanceof \Gems_User_UserDefinitionConfigurableInterface && $definition->hasConfig()) {
$savedValues = $definition->saveConfig($savedValues, $newValues);
if ($definition->getConfigChanged()>0 && $this->getChanged()<1) {
$this->setChanged(1);
}
}
}
return $savedValues;
} | Save a single model item.
Makes sure the password is saved too using the userclass
@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.
@param array $saveTables Optional array containing the table names to save,
otherwise the tables set to save at model level will be saved.
@return array The values as they are after saving (they may change). | entailment |
protected function getExportModel()
{
$model = parent::getExportModel();
$model->del('allowed', 'formatFunction');
$model->del('denied', 'formatFunction');
$model->set('menu', 'formatFunction', [$this, 'changeArrow']);
return $model;
} | Get the model for export and have the option to change it before using for export
@return | entailment |
protected function getPrivileges()
{
if (!$this->privileges) {
$privileges = [];
$allExisting = $this->getUsedPrivileges();
foreach ($this->acl->getPrivilegeRoles() as $privilege => $roles) {
$privileges[$privilege]['privilege'] = $privilege;
$privileges[$privilege]['menu'] = isset($allExisting[$privilege]) ? $allExisting[$privilege] : null;
$privileges[$privilege]['allowed'] = $roles[\Zend_Acl::TYPE_ALLOW] ? implode(', ', $roles[\Zend_Acl::TYPE_ALLOW]) : null;
$privileges[$privilege]['denied'] = $roles[\Zend_Acl::TYPE_DENY] ? implode(', ', $roles[\Zend_Acl::TYPE_DENY]) : null;
}
// Add unassigned rights to the array too
$unassigned = array_diff_key($allExisting, $privileges);
$nonexistent = array_diff_key($privileges, $allExisting);
unset($nonexistent['pr.nologin']);
unset($nonexistent['pr.islogin']);
ksort($nonexistent);
foreach ($unassigned as $privilege => $description) {
$privileges[$privilege] = array(
'privilege' => $privilege,
'menu' => isset($allExisting[$privilege]) ? $allExisting[$privilege] : null,
'allowed' => null,
'denied' => null
);
}
ksort($privileges);
$this->setNonExistent($nonexistent);
$this->privileges = $privileges;
}
return $this->privileges;
} | Get list of privileges, their menu options and which role is allowed or denied this specific privilege
@return array list of privileges | entailment |
protected function setNonExistent($nonexistent)
{
if ($nonexistent) {
$translatedNonexistent = [];
foreach($nonexistent as $right=>$values) {
foreach($values as $key=>$value) {
if ($key == 'menu') {
continue;
}
$translatedNonexistent[$right][$this->_(ucfirst($key))] = $value;
}
}
$this->indexParameters['tableTitle'] = $this->_('Assigned but nonexistent privileges');
$this->indexParameters['tableData'] = $translatedNonexistent;
$this->indexParameters['tableNested'] = true;
$this->indexStopSnippets[] = 'Generic\\DataTableSnippet';
}
} | Set assigned but nonexistent privileges and a snippet at the bottom of the page
@param array $nonexistent list of assigned but nonexistent privileges | entailment |
public function getVersion()
{
$version = $this->getProjectVersion();
if (APPLICATION_ENV !== 'production' && APPLICATION_ENV !== 'acceptance' && APPLICATION_ENV !== 'demo') {
$version .= '.' . $this->getBuild() . ' [' . APPLICATION_ENV . ']';
}
return $version;
} | The long string versions
@return string | entailment |
public function resampleImage()
{
$extension = strtolower($this->owner->getExtension());
if($this->owner->getHeight() > $this->getMaxX() || $this->owner->getWidth() > $this->getMaxY()) {
$original = $this->owner->getFullPath();
$resampled = $original. '.tmp.'. $extension;
$gd = new GD($original);
if($gd->hasImageResource()) {
$gd = $gd->resizeRatio($this->getMaxX(), $this->getMaxY());
if($gd) {
$gd->writeTo($resampled);
unlink($original);
rename($resampled, $original);
}
}
}
} | Resamples the image to the maximum Height and Width | entailment |
protected function addModelSettings(array &$settings)
{
$concatter = new \MUtil_Model_Type_ConcatenatedRow(parent::FIELD_SEP, ' ', false);
$multi = explode(parent::FIELD_SEP, $this->_fieldDefinition['gtf_field_values']);
$settings = $concatter->getSettings() + $settings;
$settings['elementClass'] = 'MultiCheckbox';
$settings['multiOptions'] = array_combine($multi, $multi);
} | Add the model settings like the elementClass for this field.
elementClass is overwritten when this field is read only, unless you override it again in getDataModelSettings()
@param array $settings The settings set so far | entailment |
public function onFieldDataSave($currentValue, array $fieldData)
{
if (is_array($currentValue)) {
return implode(parent::FIELD_SEP, $currentValue);
}
return $currentValue;
} | Converting the field value when saving to a respondent track
@param array $currentValue The current value
@param array $fieldData The other values loaded so far
@return mixed the new value | entailment |
public function filter($value)
{
$values = explode(' ', $value);
foreach ($values as &$val) {
if (substr($val, -1) === '/') {
$val = substr($val, 0, -1);
}
}
return implode(' ', $values);
} | Returns the result of filtering $value
@param mixed $value
@throws \Zend_Filter_Exception If filtering $value is impossible
@return mixed | entailment |
public function array_filter($inputArray, $model)
{
$outputArray = array();
foreach ($inputArray as $key => $value) {
// Null and empty string are skipped
if (is_null($value) || $value === '') {
continue;
}
// Maybe do a check on multiOptions for checkboxes etc. to disable some 0 values $model->get($key, 'multiOptions');
if ($value == '0' && $options = $model->get($key, 'multiOptions')) {
if (count($options) == 2) {
// Probably a checkbox (multi flexi in limesurvey)
continue;
}
}
$outputArray[$key] = $value;
}
return $outputArray;
} | Strip elements from the array that are considered empty
Empty is NULL or empty string, values of 0 are NOT empty unless they are a checkbox
@param type $inputArray
@param type $model
@return boolean | entailment |
public function filterAnswers(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model, array $currentNames)
{
$rows = $bridge->getRows();
if (! $rows) {
return $currentNames;
}
$keys = array();
foreach ($rows as $row) {
// Add the keys that contain values.
$keys += $this->array_filter($row, $model);
}
$results = array_intersect($currentNames, array_keys($keys), array_keys($this->token->getRawAnswers()));
// \MUtil_Echo::track($results);
$results = $this->restoreHeaderPositions($model, $results);
if ($results) {
return $results;
}
return $this->getHeaders($model, $currentNames);
} | This function is called in addBrowseTableColumns() to filter the names displayed
by AnswerModelSnippetGeneric.
@see \Gems_Tracker_Snippets_AnswerModelSnippetGeneric
@param \MUtil_Model_Bridge_TableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@param array $currentNames The current names in use (allows chaining)
@return array Of the names of labels that should be shown | entailment |
protected function afterLoad()
{
if ($this->_data) {
$this->_value = $this->_data['gaf_filter_text4'];
$filter[] = $this->_data['gaf_filter_text1'];
$filter[] = $this->_data['gaf_filter_text2'];
$filter[] = $this->_data['gaf_filter_text3'];
$this->_filter = array_filter($filter);
}
} | 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 after exchangeArray(),
but NOT after unserialize().
After this the object should be ready for serialization | entailment |
public function matchEpisode(EpisodeOfCare $episode)
{
$data = $episode->getDiagnosisData();
if (! $data) {
return true;
}
if (!is_string($data)) {
$data = json_encode($data);
}
$regex = $this->getRegex();
if ((boolean) preg_match($regex, $data)) {
return true;
}
return false;
} | Check a filter for a match
@param \Gems\Agenda\EpisodeOfCare $episode
@return boolean | entailment |
public function createModel($detailed, $action)
{
$model = $this->loader->getModels()->getCommLogModel($detailed);
if (! $detailed) {
$model->addFilter(array(
'gr2o_patient_nr' => $this->_getParam(\MUtil_Model::REQUEST_ID1),
'gr2o_id_organization' => $this->_getParam(\MUtil_Model::REQUEST_ID2),
));
}
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 is not in $summarizedActions.
@param string $action The current action.
@return \MUtil_Model_ModelAbstract | entailment |
public function getContentTitle()
{
$respondent = $this->getRespondent();
if ($respondent) {
return sprintf(
$this->_('Communication activity log for respondent %s: %s'),
$respondent->getPatientNumber(),
$respondent->getName()
);
}
return $this->getIndexTitle();
} | Helper function to get the informed title for the index action.
@return $string | entailment |
public function getRespondent()
{
if (! $this->_respondent instanceof \Gems_Tracker_Respondent) {
if ($this->_getParam(\MUtil_Model::REQUEST_ID1) && $this->_getParam(\MUtil_Model::REQUEST_ID2)) {
$this->_respondent = parent::getRespondent();
} else {
$id = $this->_getParam(\MUtil_Model::REQUEST_ID);
if ($id) {
$model = $this->getModel();
$row = $model->loadFirst(array('grco_id_action' => $id));
if ($row) {
$this->_respondent = $this->loader->getRespondent(
$row['gr2o_patient_nr'],
$row['gr2o_id_organization']
);
if (! $this->_respondent->exists) {
throw new \Gems_Exception($this->_('Unknown respondent.'));
}
$this->_respondent->applyToMenuSource($this->menu->getParameterSource());
}
}
}
}
return $this->_respondent;
} | Get the respondent object
@return \Gems_Tracker_Respondent | entailment |
public function getSearchFilter($useRequest = true)
{
$filter = parent::getSearchFilter($useRequest);
$where = \Gems_Snippets_AutosearchFormSnippet::getPeriodFilter($filter, $this->db);
if ($where) {
$filter[] = $where;
}
return $filter;
} | Get the filter to use with the model for searching
@param boolean $useRequest Use the request as source (when false, the session is used)
@return array or false | entailment |
public function isValid($value, $context = array())
{
$result = $this->_user->authenticate($value);
return $this->setAuthResult($result);
} | 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 validation of $value is impossible | entailment |
public function execute($lineNr = null, $roundData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
if (! (isset($import['trackId']) && $import['trackId'])) {
// Do nothing
return;
}
// Only save when export code is known and set
if (! isset($roundData['survey_export_code'], $import['surveyCodes'][$roundData['survey_export_code']])) {
// Do nothing, no survey export code or no known export code
return;
}
if (! $import['surveyCodes'][$roundData['survey_export_code']]) {
// Export code not set to skip import of round
return;
}
$fieldCodes = isset($import['fieldCodes']) ? $import['fieldCodes'] : array();
$roundOrders = isset($import['roundOrders']) ? $import['roundOrders'] : array();
$conditions = isset($import['importConditions']) ? $import['importConditions'] : array();
$tracker = $this->loader->getTracker();
$trackEngine = $tracker->getTrackEngine($import['trackId']);
$model = $trackEngine->getRoundModel(true, 'create');
$roundData['gro_id_track'] = $import['trackId'];
$roundData['gro_id_survey'] = $import['surveyCodes'][$roundData['survey_export_code']];
$survey = $tracker->getSurvey($roundData['gro_id_survey']);
if ($survey) {
$roundData['gro_survey_name'] = $survey->getName();
} else {
$roundData['gro_survey_name'] = '';
}
if (isset($roundData['gro_id_relationfield'], $fieldCodes[$roundData['gro_id_relationfield']]) &&
$roundData['gro_id_relationfield']) {
if (! (is_integer($roundData['gro_id_relationfield']) && $roundData['gro_id_relationfield'] < 0)) {
// -1 means the respondent itself, also gro_id_relationfield stores a "bare"
// field id, not one with a table prefix
$keys = FieldsDefinition::splitKey($fieldCodes[$roundData['gro_id_relationfield']]);
if (isset($keys['gtf_id_field'])) {
$roundData['gro_id_relationfield'] = $keys['gtf_id_field'];
}
}
}
if (isset($roundData['valid_after']) && $roundData['valid_after']) {
if (isset($roundOrders[$roundData['valid_after']]) && $roundOrders[$roundData['valid_after']]) {
$roundData['gro_valid_after_id'] = $roundOrders[$roundData['valid_after']];
} else {
$batch->addTask(
'Tracker\\Import\\UpdateRoundValidTask',
$lineNr,
$roundData['gro_id_order'],
$roundData['valid_after'],
'gro_valid_after_id'
);
}
}
if (isset($roundData['gro_valid_after_source'], $roundData['gro_valid_after_field'])) {
switch ($roundData['gro_valid_after_source']) {
case \Gems_Tracker_Engine_StepEngineAbstract::APPOINTMENT_TABLE:
case \Gems_Tracker_Engine_StepEngineAbstract::RESPONDENT_TRACK_TABLE:
if (isset($fieldCodes[$roundData['gro_valid_after_field']])) {
$roundData['gro_valid_after_field'] = $fieldCodes[$roundData['gro_valid_after_field']];
}
}
}
if (isset($roundData['valid_for']) && $roundData['valid_for']) {
if (isset($roundOrders[$roundData['valid_for']]) && $roundOrders[$roundData['valid_for']]) {
$roundData['gro_valid_for_id'] = $roundOrders[$roundData['valid_for']];
} else {
$batch->addTask(
'Tracker\\Import\\UpdateRoundValidTask',
$lineNr,
$roundData['gro_id_order'],
$roundData['valid_for'],
'gro_valid_for_id'
);
}
}
if (isset($roundData['gro_valid_for_source'], $roundData['gro_valid_for_field'])) {
switch ($roundData['gro_valid_for_source']) {
case \Gems_Tracker_Engine_StepEngineAbstract::APPOINTMENT_TABLE:
case \Gems_Tracker_Engine_StepEngineAbstract::RESPONDENT_TRACK_TABLE:
if (isset($fieldCodes[$roundData['gro_valid_for_field']])) {
$roundData['gro_valid_for_field'] = $fieldCodes[$roundData['gro_valid_for_field']];
}
}
}
if (isset($roundData['gro_condition']) && $roundData['gro_condition']) {
if (isset($conditions[$roundData['gro_condition']]) && $conditions[$roundData['gro_condition']]) {
$roundData['gro_condition'] = $conditions[$roundData['gro_condition']];
} else {
// This should not happen!
$roundData['gro_condition'] = null;
}
}
$roundData = $model->save($roundData);
$import['rounds'][$lineNr]['gro_id_round'] = $roundData['gro_id_round'];
$import['roundOrders'][$roundData['gro_id_order']] = $roundData['gro_id_round'];
} | 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 _createTrack($filter, $tracker)
{
$trackData = array('gr2t_comment' => sprintf(
$this->_('Track created by %s filter'),
$filter->getName()
));
$fields = array($filter->getFieldId() => $this->getId());
$trackId = $filter->getTrackId();
$respTrack = $tracker->createRespondentTrack(
$this->getRespondentId(),
$this->getOrganizationId(),
$trackId,
$this->currentUser->getUserId(),
$trackData,
$fields
);
return $respTrack;
} | Create a new track for this appointment and the given filter
@param \Gems\Agenda\AppointmentFilterInterface $filter
@param \Gems_Tracker $tracker | entailment |
protected function _ensureRespondentOrgData()
{
if (! isset($this->_gemsData['gr2o_id_user'], $this->_gemsData['gco_code'])) {
$sql = "SELECT *
FROM gems__respondents INNER JOIN
gems__respondent2org ON grs_id_user = gr2o_id_user INNER JOIN
gems__consents ON gr2o_consent = gco_description
WHERE gr2o_id_user = ? AND gr2o_id_organization = ? LIMIT 1";
$respId = $this->_gemsData['gap_id_user'];
$orgId = $this->_gemsData['gap_id_organization'];
// \MUtil_Echo::track($this->_gemsData);
if ($row = $this->db->fetchRow($sql, array($respId, $orgId))) {
$this->_gemsData = $this->_gemsData + $row;
} else {
$appId = $this->_appointmentId;
throw new \Gems_Exception("Respondent data missing for appointment id $appId.");
}
}
} | Makes sure the respondent data is part of the $this->_gemsData | entailment |
protected function checkCreateTracks($filters, $existingTracks, $tracker)
{
$tokenChanges = 0;
// Check for tracks that should be created
foreach ($filters as $filter) {
if (!$filter->isCreator()) {
continue;
}
$createTrack = true;
// Find the method to use for this creator type
$method = $this->getCreatorCheckMethod($filter->getCreatorType());
$trackId = $filter->getTrackId();
$tracks = array_key_exists($trackId, $existingTracks) ? $existingTracks[$trackId] : [];
foreach($tracks as $respTrack) {
/* @var $respTrack \Gems_Tracker_RespondentTrack */
if (!$respTrack->hasSuccesCode()) { continue; }
$createTrack = $this->$method($filter, $respTrack);
if ($createTrack === false) {
break; // Stop checking
}
}
// \MUtil_Echo::track($trackId, $createTrack, $filter->getName(), $filter->getSqlAppointmentsWhere(), $filter->getFilterId());
if ($createTrack) {
$respTrack = $this->_createTrack($filter, $tracker);
$existingTracks[$trackId][] = $respTrack;
$tokenChanges += $respTrack->getCount();
}
}
return $tokenChanges;
} | Check if a track should be created for any of the filters
@param \Gems\Agenda\AppointmentFilterInterface[] $filters
@param array $existingTracks
@param \Gems_Tracker $tracker
@return int Number of tokenchanges | entailment |
public function createAfterWaitDays($filter, $respTrack)
{
$createTrack = true;
$curr = $this->getAdmissionTime();
$end = $respTrack->getEndDate();
$wait = $filter->getWaitDays();
if ( (! $end) || ($curr->diffDays($end) <= $wait)) {
$createTrack = false;
}
return $createTrack;
} | Has the track ended <wait days> ago?
@param \Gems\Agenda\AppointmentFilterInterface $filter
@param \Gems_Tracker_RespondentTrack $respTrack
@return boolean | entailment |
public function createAlways($filter, $respTrack)
{
$createTrack = $this->createAfterWaitDays($filter, $respTrack);
if ($createTrack) {
$createTrack = $this->createWhenNotInThisTrack($filter, $respTrack);
}
return $createTrack;
} | Always report the track should be created
@param \Gems\Agenda\AppointmentFilterInterface $filter
@param \Gems_Tracker_RespondentTrack $respTrack
@return boolean | entailment |
public function createFromStart($filter, $respTrack)
{
$createTrack = true;
$curr = $this->getAdmissionTime();
$start = $respTrack->getStartDate();
$wait = $filter->getWaitDays();
if ((! $start) || ($curr->diffDays($start) <= $wait)) {
$createTrack = false;
}
return $createTrack;
} | Always report the track should be created
@param \Gems\Agenda\AppointmentFilterInterface $filter
@param \Gems_Tracker_RespondentTrack $respTrack
@return boolean | entailment |
public function createNoOpen($filter, $respTrack)
{
// If an open track of this type exists: do not create a new one
$createTrack = !$respTrack->isOpen();
if ($createTrack) {
$createTrack = $this->createWhenNotInThisTrack($filter, $respTrack);
}
return $createTrack;
} | Only return true when no open track exists
@param \Gems\Agenda\AppointmentFilterInterface $filter
@param \Gems_Tracker_RespondentTrack $respTrack
@return boolean | entailment |
public function createWhenNotInThisTrack($filter, $respTrack)
{
$createTrack = true;
$data = $respTrack->getFieldData();
if (isset($data[$filter->getFieldId()]) &&
($this->getId() == $data[$filter->getFieldId()])) {
$createTrack = false;
}
return $createTrack;
} | Create when current appointment is not assigned to this field already
@param \Gems\Agenda\AppointmentFilterInterface $filter
@param \Gems_Tracker_RespondentTrack $respTrack
@return boolean | entailment |
public function createWhenNoOpen($filter, $respTrack)
{
// If an open track of this type exists: do not create a new one
$createTrack = !$respTrack->isOpen();
if ($createTrack) {
$createTrack = $this->createAfterWaitDays($filter, $respTrack);
}
if ($createTrack) {
$createTrack = $this->createWhenNotInThisTrack($filter, $respTrack);
}
return $createTrack;
} | Only return true when no open track exists
@param \Gems\Agenda\AppointmentFilterInterface $filter
@param \Gems_Tracker_RespondentTrack $respTrack
@return boolean | entailment |
public function getAdmissionTime()
{
if (isset($this->_gemsData['gap_admission_time']) && $this->_gemsData['gap_admission_time']) {
if (! $this->_gemsData['gap_admission_time'] instanceof \MUtil_Date) {
$this->_gemsData['gap_admission_time'] =
new \MUtil_Date($this->_gemsData['gap_admission_time'], \Gems_Tracker::DB_DATETIME_FORMAT);
}
// Clone to make sure calculations can be performed without changing this object
return clone $this->_gemsData['gap_admission_time'];
}
} | Return the admission time
@return \MUtil_Date Admission time as a date or null | entailment |
public function getDisplayString()
{
$results[] = $this->getAdmissionTime()->toString($this->agenda->appointmentDisplayFormat);
$results[] = $this->getActivityDescription();
$results[] = $this->getProcedureDescription();
$results[] = $this->getLocationDescription();
$results[] = $this->getSubject();
return implode($this->_('; '), array_filter($results));
} | Get a general description of this appointment
@see \Gems_Agenda->getAppointmentDisplay()
@return string | entailment |
public function getProcedureDescription()
{
if (! (isset($this->_gemsData['gap_id_procedure']) && $this->_gemsData['gap_id_procedure'])) {
return null;
}
if (!array_key_exists('gapr_name', $this->_gemsData)) {
$sql = "SELECT gapr_name FROM gems__agenda_procedures WHERE gapr_id_procedure = ?";
$this->_gemsData['gapr_name'] = $this->db->fetchOne($sql, $this->_gemsData['gap_id_procedure']);
// Cleanup db result
if (false === $this->_gemsData['gapr_name']) {
$this->_gemsData['gapr_name'] = null;
}
}
return $this->_gemsData['gapr_name'];
} | Return the description of the current procedure
@return string or null when not found | entailment |
public function getRespondent()
{
return $this->loader->getRespondent(
$this->getPatientNumber(),
$this->getOrganizationId(),
$this->getRespondentId())
;
} | Return the respondent object
@return \Gems_Tracker_Respondent | entailment |
public function isActive()
{
return $this->exists &&
isset($this->_gemsData['gap_status']) &&
$this->agenda->isStatusActive($this->_gemsData['gap_status']);
} | Return true when the status is active
@return type | entailment |
public function updateTracks()
{
$tokenChanges = 0;
$tracker = $this->loader->getTracker();
// Find all the fields that use this agenda item
$select = $this->db->select();
$select->from('gems__respondent2track2appointment', array('gr2t2a_id_respondent_track'))
->joinInner(
'gems__respondent2track',
'gr2t_id_respondent_track = gr2t2a_id_respondent_track',
array('gr2t_id_track')
)
->where('gr2t2a_id_appointment = ?', $this->_appointmentId)
->distinct();
// AND find the filters for any new fields to fill
$filters = $this->agenda->matchFilters($this);
if ($filters) {
$ids = array_map(function ($value) {
return $value->getTrackId();
}, $filters);
// \MUtil_Echo::track(array_keys($filters), $ids);
$respId = $this->getRespondentId();
$orgId = $this->getOrganizationId();
$select->orWhere(
"gr2t_id_user = $respId AND gr2t_id_organization = $orgId AND gr2t_id_track IN (" .
implode(', ', $ids) . ")"
);
// \MUtil_Echo::track($this->getId(), implode(', ', $ids));
}
// \MUtil_Echo::track($select->__toString());
// Now find all the existing tracks that should be checked
$respTracks = $this->db->fetchPairs($select);
// \MUtil_Echo::track($respTracks);
$existingTracks = array();
if ($respTracks) {
foreach ($respTracks as $respTrackId => $trackId) {
$respTrack = $tracker->getRespondentTrack($respTrackId);
// Recalculate this track
$fieldsChanged = false;
$tokenChanges += $respTrack->recalculateFields($fieldsChanged);
// Store the track for creation checking
$existingTracks[$trackId][] = $respTrack;
}
}
// Only check if we need to create when this appointment is active and today or later
if ($this->isActive() && $this->getAdmissionTime()->isLaterOrEqual(new \MUtil_Date())) {
$tokenChanges += $this->checkCreateTracks($filters, $existingTracks, $tracker);
}
return $tokenChanges;
} | Recalculate all tracks that use this appointment
@return int The number of tokens changed by this code | entailment |
private function _deleteCache()
{
if ($this->_cache instanceof \Zend_Cache_Core) {
$this->_cache->remove($this->_cacheid);
$this->_cache->remove($this->_cacheid . 'trans');
}
} | Empty this cache instance | entailment |
private function _expandRole(&$roleList, $roleName, $depth = 0)
{
$role = $roleList[$roleName];
if (isset($role['marked']) && $role['marked']) {
return;
}
// possible circular reference!
if ($depth > 5) {
throw new \Exception("Possible circular reference detected while expanding role '{$roleName}'");
}
if (!empty($role['grl_parents'])) {
$parents = $this->translateToRoleNames($role['grl_parents']);
foreach ($parents as $parent) {
$this->_expandRole($roleList, $parent, $depth + 1);
}
} else {
$parents = array();
}
$this->_acl->addRole(new \Zend_Acl_Role($role['grl_name']), $parents);
$privileges = array_filter(array_map('trim', explode(",", $role['grl_privileges'])));
if ($privileges) {
$this->_acl->addPrivilege($role['grl_name'], $privileges);
}
$roleList[$roleName]['marked'] = true;
} | Recursively expands roles into \Zend_Acl_Role objects
@param array $roleList
@param string $roleName | entailment |
private function _initAcl()
{
$this->_acl = new \MUtil_Acl();
if (get_class(self::$_instanceOfSelf)!=='Gems_Roles') {
throw new \Gems_Exception_Coding("Don't use project specific roles file anymore, you can now do so by using the gems_roles tabel and setup->roles from the interface.");
}
// Probeer eerst uit db in te lezen met fallback als dat niet lukt
try {
$this->loadDbAcl();
} catch (\Exception $e) {
\Gems_Log::getLogger()->logError($e);
// Reset all roles
unset($this->_acl);
$this->_acl = new \MUtil_Acl();
//Voeg standaard rollen en privileges in
$this->loadDefaultRoles();
$this->loadDefaultPrivileges();
}
// Now allow 'master' all access, except for the actions that have the
// nologin privilege (->the login action)
if (!$this->_acl->hasRole('master')) {
//Add role if not already present
$this->_acl->addRole('master');
}
$this->_acl->allow('master');
$this->_acl->deny('master', null, 'pr.nologin');
} | Reset de ACL en bouw opnieuw op | entailment |
private function _save()
{
if ($this->_cache instanceof \Zend_Cache_Core) {
if (! (
$this->_cache->save($this->_acl, $this->_cacheid, array('roles'), null) &&
$this->_cache->save($this->_roleTranslations, $this->_cacheid . 'trans', array('roles'), null)
)) {
throw new \Gems_Exception('Failed to save acl to cache');
}
}
} | Save to cache
@throws \Gems_Exception | entailment |
public static function getInstance()
{
if (!isset(self::$_instanceOfSelf)) {
$c = __CLASS__;
self::$_instanceOfSelf = new $c;
}
return self::$_instanceOfSelf;
} | Static acces function
@return \Gems_Roles | entailment |
public function load()
{
if ($this->_cache instanceof \Zend_Cache_Core) {
$cache = $this->_cache;
if (! ($cache->test($this->_cacheid) && $cache->test($this->_cacheid . 'trans'))) {
// cache miss
$this->build();
} else {
// cache hit
$this->_acl = $cache->load($this->_cacheid);
$this->_roleTranslations = $cache->load($this->_cacheid . 'trans');
}
} else {
$this->build();
}
} | Load the ACL values either from the cache or from build() | entailment |
public function loadDbAcl()
{
$db = \Zend_Registry::get('db');
$sql = "SELECT grl_id_role, grl_name, grl_privileges, grl_parents FROM gems__roles";
$roles = $db->fetchAll($sql);
if (empty($roles)) {
throw new \Exception("No roles stored in db");
}
// Set role id to name tranlations
foreach ($roles as $role) {
$this->_roleTranslations[$role['grl_id_role']] = $role['grl_name'];
}
$roleList = array_combine(array_map(function($value) { return $value['grl_name']; }, $roles), $roles);
foreach ($roleList as $role) {
$this->_expandRole($roleList, $role['grl_name']);
}
return true;
} | Load access control list from db
@throws \Exception | entailment |
public function translateToRoleId($role)
{
$lookup = array_flip($this->_roleTranslations);
if (isset($lookup[$role])) {
return $lookup[$role];
}
return $role;
} | Translate string role id to numeric role id
@param string $role
@return array Of role id's | entailment |
public function translateToRoleIds($roles)
{
if (!is_array($roles)) {
if ($roles) {
$roles = explode(",", $roles);
} else {
$roles = array();
}
}
$lookup = array_flip($this->_roleTranslations);
foreach ($roles as $key => $role) {
if (isset($lookup[$role])) {
$roles[$key] = $lookup[$role];
}
}
return $roles;
} | Translate all string role id's to numeric role ids
@param mixed $roles string or array
@return array Of role id's | entailment |
public function translateToRoleName($role)
{
if (isset($this->_roleTranslations[$role])) {
return $this->_roleTranslations[$role];
}
return $role;
} | Translate numeric role id to string name
@param int $role
@return string | entailment |
public function translateToRoleNames($roles)
{
if (!is_array($roles)) {
if ($roles) {
$roles = explode(",", $roles);
} else {
$roles = array();
}
}
foreach ($roles as $key => $role) {
if (isset($this->_roleTranslations[$role])) {
$roles[$key] = $this->_roleTranslations[$role];
}
}
return $roles;
} | Translate all numeric role id's to string names
@param mixed $roles string or array
@return array | entailment |
public function getTab()
{
//pseudo constructor to catch more constants
$constants = get_defined_constants(true);
$this->_userConstants = $constants['user'];
ksort($this->_userConstants);
$count = count($this->_userConstants);
return "Constants ($count)";
} | Gets menu tab for the Debugbar
@return string | entailment |
public function getInstance($name, $model, $data)
{
$instance = $this->_loadClass($name, true, array($model, $data));
return $instance;
} | Returns an instance (row) of the the model, this allows for easy loading of instances
Best usage would be to load from within the model, so return type can be
fixed there and code completion would work like desired
@param string $name
@param \MUtil_Model_ModelAbstract $model
@param array $data
@return mixed | entailment |
public function getRespondent($patientId, $organizationId, $respondentId = null)
{
if ($patientId) {
if (isset($this->_respondents[$organizationId][$patientId])) {
return $this->_respondents[$organizationId][$patientId];
}
}
$newResp = $this->_loadClass('Tracker_Respondent', true, array($patientId, $organizationId, $respondentId));
$patientId = $newResp->getPatientNumber();
if (! isset($this->_respondents[$organizationId][$patientId])) {
$this->_respondents[$organizationId][$patientId] = $newResp;
}
return $this->_respondents[$organizationId][$patientId];
} | Get a respondent object
@param string $patientId Patient number, you can use $respondentId instead
@param int $organizationId Organization id
@param int $respondentId Optional respondent id, used when patient id is empty
@return \Gems_Tracker_Respondent | entailment |
public function getFieldId()
{
if (isset($this->_data['gtap_id_app_field']) && $this->_data['gtap_id_app_field']) {
return FieldsDefinition::makeKey(
FieldMaintenanceModel::APPOINTMENTS_NAME,
$this->_data['gtap_id_app_field']
);
}
} | The field id as it is recognized be the track engine
@return string | entailment |
public function getWaitDays()
{
if (isset($this->_data['gtap_create_wait_days'], $this->_data['gtap_create_track']) &&
$this->_data['gtap_create_track']) {
return intval($this->_data['gtap_create_wait_days']);
}
} | The number of days to wait between track creation
@return int or null when no track creation or no wait days | entailment |
public function serialize() {
$data = array();
foreach (get_object_vars($this) as $name => $value) {
if (! $this->filterRequestNames($name)) {
$data[$name] = $value;
}
}
return serialize($data);
} | By default only object variables starting with '_' are serialized in order to
avoid serializing any resource types loaded by
\MUtil_Translate_TranslateableAbstract
@return string | entailment |
function GeSHi($source = '', $language = '', $path = '') {
if (!empty($source)) {
$this->set_source($source);
}
if (!empty($language)) {
$this->set_language($language);
}
$this->set_language_path($path);
} | Creates a new GeSHi object, with source and language
@param string The source code to highlight
@param string The language to highlight the source with
@param string The path to the language file directory. <b>This
is deprecated!</b> I've backported the auto path
detection from the 1.1.X dev branch, so now it
should be automatically set correctly. If you have
renamed the language directory however, you will
still need to set the path using this parameter or
{@link GeSHi->set_language_path()}
@since 1.0.0 | entailment |
function error() {
if ($this->error) {
//Put some template variables for debugging here ...
$debug_tpl_vars = array(
'{LANGUAGE}' => $this->language,
'{PATH}' => $this->language_path
);
$msg = str_replace(
array_keys($debug_tpl_vars),
array_values($debug_tpl_vars),
$this->error_messages[$this->error]);
return "<br /><strong>GeSHi Error:</strong> $msg (code {$this->error})<br />";
}
return false;
} | Returns an error message associated with the last GeSHi operation,
or false if no error has occured
@return string|false An error message if there has been an error, else false
@since 1.0.0 | entailment |
function set_language($language, $force_reset = false) {
if ($force_reset) {
$this->loaded_language = false;
}
//Clean up the language name to prevent malicious code injection
$language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language);
$language = strtolower($language);
//Retreive the full filename
$file_name = $this->language_path . $language . '.php';
if ($file_name == $this->loaded_language) {
// this language is already loaded!
return;
}
$this->language = $language;
$this->error = false;
$this->strict_mode = GESHI_NEVER;
//Check if we can read the desired file
if (!is_readable($file_name)) {
$this->error = GESHI_ERROR_NO_SUCH_LANG;
return;
}
// Load the language for parsing
$this->load_language($file_name);
} | Sets the language for this object
@note since 1.0.8 this function won't reset language-settings by default anymore!
if you need this set $force_reset = true
@param string The name of the language to use
@since 1.0.0 | entailment |
function set_language_path($path) {
if ($path) {
$this->language_path = ('/' == $path[strlen($path) - 1]) ? $path : $path . '/';
$this->set_language($this->language); // otherwise set_language_path has no effect
}
} | Sets the path to the directory containing the language files. Note
that this path is relative to the directory of the script that included
geshi.php, NOT geshi.php itself.
@param string The path to the language directory
@since 1.0.0
@deprecated The path to the language files should now be automatically
detected, so this method should no longer be needed. The
1.1.X branch handles manual setting of the path differently
so this method will disappear in 1.2.0. | entailment |
function set_keyword_group_style($key, $style, $preserve_defaults = false) {
//Set the style for this keyword group
if (!$preserve_defaults) {
$this->language_data['STYLES']['KEYWORDS'][$key] = $style;
} else {
$this->language_data['STYLES']['KEYWORDS'][$key] .= $style;
}
//Update the lexic permissions
if (!isset($this->lexic_permissions['KEYWORDS'][$key])) {
$this->lexic_permissions['KEYWORDS'][$key] = true;
}
} | Sets the style for a keyword group. If $preserve_defaults is
true, then styles are merged with the default styles, with the
user defined styles having priority
@param int The key of the keyword group to change the styles of
@param string The style to make the keywords
@param boolean Whether to merge the new styles with the old or just
to overwrite them
@since 1.0.0 | entailment |
function set_keyword_group_highlighting($key, $flag = true) {
$this->lexic_permissions['KEYWORDS'][$key] = ($flag) ? true : false;
} | Turns highlighting on/off for a keyword group
@param int The key of the keyword group to turn on or off
@param boolean Whether to turn highlighting for that group on or off
@since 1.0.0 | entailment |
function set_symbols_style($style, $preserve_defaults = false, $group = 0) {
// Update the style of symbols
if (!$preserve_defaults) {
$this->language_data['STYLES']['SYMBOLS'][$group] = $style;
} else {
$this->language_data['STYLES']['SYMBOLS'][$group] .= $style;
}
// For backward compatibility
if (0 == $group) {
$this->set_brackets_style ($style, $preserve_defaults);
}
} | Sets the styles for symbols. If $preserve_defaults is
true, then styles are merged with the default styles, with the
user defined styles having priority
@param string The style to make the symbols
@param boolean Whether to merge the new styles with the old or just
to overwrite them
@param int Tells the group of symbols for which style should be set.
@since 1.0.1 | entailment |
function set_symbols_highlighting($flag) {
// Update lexic permissions for this symbol group
$this->lexic_permissions['SYMBOLS'] = ($flag) ? true : false;
// For backward compatibility
$this->set_brackets_highlighting ($flag);
} | Turns highlighting on/off for symbols
@param boolean Whether to turn highlighting for symbols on or off
@since 1.0.0 | entailment |
function set_regexps_style($key, $style, $preserve_defaults = false) {
if (!$preserve_defaults) {
$this->language_data['STYLES']['REGEXPS'][$key] = $style;
} else {
$this->language_data['STYLES']['REGEXPS'][$key] .= $style;
}
} | Sets the styles for regexps. If $preserve_defaults is
true, then styles are merged with the default styles, with the
user defined styles having priority
@param string The style to make the regular expression matches
@param boolean Whether to merge the new styles with the old or just
to overwrite them
@since 1.0.0 | entailment |
function add_keyword_group($key, $styles, $case_sensitive = true, $words = array()) {
$words = (array) $words;
if (empty($words)) {
// empty word lists mess up highlighting
return false;
}
//Add the new keyword group internally
$this->language_data['KEYWORDS'][$key] = $words;
$this->lexic_permissions['KEYWORDS'][$key] = true;
$this->language_data['CASE_SENSITIVE'][$key] = $case_sensitive;
$this->language_data['STYLES']['KEYWORDS'][$key] = $styles;
//NEW in 1.0.8, cache keyword regexp
if ($this->parse_cache_built) {
$this->optimize_keyword_group($key);
}
} | Creates a new keyword group
@param int The key of the keyword group to create
@param string The styles for the keyword group
@param boolean Whether the keyword group is case sensitive ornot
@param array The words to use for the keyword group
@since 1.0.0 | entailment |
function optimize_keyword_group($key) {
$this->language_data['CACHED_KEYWORD_LISTS'][$key] =
$this->optimize_regexp_list($this->language_data['KEYWORDS'][$key]);
} | compile optimized regexp list for keyword group
@param int The key of the keyword group to compile & optimize
@since 1.0.8 | entailment |
function handle_multiline_regexps($matches) {
$before = $this->_hmr_before;
$after = $this->_hmr_after;
if ($this->_hmr_replace) {
$replace = $this->_hmr_replace;
$search = array();
foreach (array_keys($matches) as $k) {
$search[] = '\\' . $k;
}
$before = str_replace($search, $matches, $before);
$after = str_replace($search, $matches, $after);
$replace = str_replace($search, $matches, $replace);
} else {
$replace = $matches[0];
}
return $before
. '<|!REG3XP' . $this->_hmr_key .'!>'
. str_replace("\n", "|>\n<|!REG3XP" . $this->_hmr_key . '!>', $replace)
. '|>'
. $after;
} | handles newlines in REGEXPS matches. Set the _hmr_* vars before calling this
@note this is a callback, don't use it directly
@param array the matches array
@return string
@since 1.0.8
@access private | entailment |
function header() {
// Get attributes needed
/**
* @todo Document behaviour change - class is outputted regardless of whether
* we're using classes or not. Same with style
*/
$attributes = ' class="' . $this->language;
if ($this->overall_class != '') {
$attributes .= " ".$this->overall_class;
}
$attributes .= '"';
if ($this->overall_id != '') {
$attributes .= " id=\"{$this->overall_id}\"";
}
if ($this->overall_style != '') {
$attributes .= ' style="' . $this->overall_style . '"';
}
$ol_attributes = '';
if ($this->line_numbers_start != 1) {
$ol_attributes .= ' start="' . $this->line_numbers_start . '"';
}
// Get the header HTML
$header = $this->header_content;
if ($header) {
if ($this->header_type == GESHI_HEADER_PRE || $this->header_type == GESHI_HEADER_PRE_VALID) {
$header = str_replace("\n", '', $header);
}
$header = $this->replace_keywords($header);
if ($this->use_classes) {
$attr = ' class="head"';
} else {
$attr = " style=\"{$this->header_content_style}\"";
}
if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) {
$header = "<thead><tr><td colspan=\"2\" $attr>$header</td></tr></thead>";
} else {
$header = "<div$attr>$header</div>";
}
}
if (GESHI_HEADER_NONE == $this->header_type) {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
return "$header<ol$attributes$ol_attributes>";
}
return $header . ($this->force_code_block ? '<div>' : '');
}
// Work out what to return and do it
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
if ($this->header_type == GESHI_HEADER_PRE) {
return "<pre$attributes>$header<ol$ol_attributes>";
} else if ($this->header_type == GESHI_HEADER_DIV ||
$this->header_type == GESHI_HEADER_PRE_VALID) {
return "<div$attributes>$header<ol$ol_attributes>";
} else if ($this->header_type == GESHI_HEADER_PRE_TABLE) {
return "<table$attributes>$header<tbody><tr class=\"li1\">";
}
} else {
if ($this->header_type == GESHI_HEADER_PRE) {
return "<pre$attributes>$header" .
($this->force_code_block ? '<div>' : '');
} else {
return "<div$attributes>$header" .
($this->force_code_block ? '<div>' : '');
}
}
} | Creates the header for the code block (with correct attributes)
@return string The header for the code block
@since 1.0.0
@access private | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
if ($this->contentTitle) {
return \MUtil_Html::create($this->tagName, $this->contentTitle, array('class' => 'title'));
}
} | 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 addCancelButton()
{
$cancelUrl = [
$this->request->getControllerKey() => $this->request->getControllerName(),
$this->request->getActionKey() => $this->request->getActionName(),
$this->resetParam => 1,
];
$element = $this->_form->createElement('html', 'reset');
$element->setLabel(html_entity_decode(' '));
$element->setValue(\Gems_Html::actionLink($cancelUrl, $this->_('Cancel login')));
$this->_form->addElement($element);
} | Simple default function for making sure there is a $this->_saveButton.
As the save button is not part of the model - but of the interface - it
does deserve it's own function. | entailment |
protected function addFormElements(\Zend_Form $form)
{
if (! $this->user->hasTwoFactor()) {
return;
}
$this->saveLabel = $this->_('Check code');
$options = [
'label' => $this->_('Enter authenticator code'),
'description' => $this->_('From the Google app on your phone.'),
'maxlength' => 6,
'minlength' => 6,
'required' => true,
'size' => 8,
];
$element = $form->createElement('Text', 'TwoFactor', $options);
$element->addValidator(new TwoFactorAuthenticateValidator(
$this->user->getTwoFactorAuthenticator(),
$this->user->getTwoFactorKey(),
$this->translate
));
$form->addElement($element);
} | Add the elements to the form
@param \Zend_Form $form | entailment |
public function afterRegistry()
{
parent::afterRegistry();
$this->routeController = $this->request->getControllerName();
$this->routeAction = $this->request->getActionName();
if ($this->loginStatusTracker->hasUser()) {
$this->user = $this->loginStatusTracker->getUser();
}
} | Called after the check that all required registry values
have been set correctly has run.
This function is no needed if the classes are setup correctly
@return void | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.