sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function applyToMenuSource(\Gems_Menu_ParameterSource $source)
{
$source->setTokenId($this->_tokenId);
if ($this->exists) {
if (! isset($this->_gemsData['gr2o_patient_nr'])) {
$this->_ensureRespondentData();
}
$source->setTokenId($this->_to... | Set menu parameters from this token
@param \Gems_Menu_ParameterSource $source
@return \Gems_Tracker_Token (continuation pattern) | entailment |
public function assignTo($respondentRelationId, $relationFieldId)
{
if ($this->getRelationFieldId() == $relationFieldId && $this->getRelationId() == $respondentRelationId) return 0;
return $this->_updateToken(array(
'gto_id_relation'=>$respondentRelationId,
'gto_id_relationf... | Assign this token to a specific relation
@param int $respondentRelationId
@param int $relationFieldId
@return int 1 if data changed, 0 otherwise | entailment |
public function cacheGet($key, $defaultValue = null) {
if ($this->cacheHas($key)) {
return $this->_cache[$key];
} else {
return $defaultValue;
}
} | Retrieve a certain $key from the local cache
For speeding up things the token can hold a local cache, living as long as the
token object exists in memory. Sources can use this to store reusable information.
To reset the cache on an update, the source can use the cacheReset method or the
setCache method to update the ... | entailment |
public function cacheReset($key = null) {
if (is_null($key)) {
$this->_cache = array();
} else {
unset($this->_cache[$key]);
}
} | Reset the local cache for this token
You can pass in an optional $key parameter to reset just that key, otherwise all
the cache will be reset
@param string|null $key The key to reset | entailment |
protected function calculateReturnUrl()
{
$currentUri = $this->util->getCurrentURI();
/*
// Referrer would be powerful when someone is usng multiple windows, but
// the loop does not always provide a correct referrer.
$referrer = $_SERVER["HTTP_REFERER"];
// If a ... | Returns the full url Gems should forward to after survey completion.
This fix allows multiple sites with multiple url's to share a single
installation.
@return string | entailment |
public function checkRegistryRequestsAnswers()
{
if ($this->_gemsData) {
if ($this->currentUser instanceof \Gems_User_User) {
$this->_gemsData = $this->currentUser->applyGroupMask($this->_gemsData);
}
} else {
if ($this->db instanceof \Zend_Db_Adap... | Should be called after answering the request to allow the Target
to check if all required registry values have been set correctly.
@return boolean False if required are missing. | entailment |
public function checkTokenCompletion($userId)
{
$result = self::COMPLETION_NOCHANGE;
// Some defaults
$values['gto_completion_time'] = null;
$values['gto_duration_in_sec'] = null;
$values['gto_result'] = null;
if ($this->inSource()) {
$survey = ... | Checks whether the survey for this token was completed and processes the result
@param int $userId The id of the gems user
@return int self::COMPLETION_NOCHANGE || (self::COMPLETION_DATACHANGE | self::COMPLETION_EVENTCHANGE) | entailment |
public function createReplacement($newComment, $userId, array $otherValues = array())
{
$values['gto_id_respondent_track'] = $this->_gemsData['gto_id_respondent_track'];
$values['gto_id_round'] = $this->_gemsData['gto_id_round'];
$values['gto_id_respondent'] = $this->_gemsDa... | Creates an almost exact copy of this token at the same place in the track,
only without answers and other source data
Returns the new token id
@param string $newComment Description of why the token was replaced
@param int $userId The current user
@param array $otherValues Other values to set in the token
@return stri... | entailment |
public function getAllUnansweredTokens($where = '')
{
$select = $this->tracker->getTokenSelect();
$select->andReceptionCodes()
->andRespondentTracks()
->andRounds(array())
->andSurveys(array())
->andTracks()
->forGroupId... | Get all unanswered tokens for the person answering this token
Similar to @see $this->getNextUnansweredToken()
Similar to @see $this->getTokenCountUnanswered()
@return array of tokendata | entailment |
public function getAnswerSnippetNames()
{
if ($this->exists) {
if (! $this->_loopCheck) {
// Events should not call $this->getAnswerSnippetNames() but
// $this->getTrackEngine()->getAnswerSnippetNames(). Just in
// case the code writer made a mista... | Returns a snippet name that can be used to display the answers to this token.
@return string | entailment |
public function getCopiedFrom()
{
if (null === $this->_copiedFromTokenId) {
$this->_copiedFromTokenId = $this->db->fetchOne(
"SELECT gtrp_id_token_old FROM gems__token_replacements WHERE gtrp_id_token_new = ?",
$this->_tokenId
);
... | Get the token id of the token this one was copied from, null when not loaded, false when does not exist
@return string | entailment |
public function getCopiedTo()
{
if (null === $this->_copiedToTokenIds) {
$this->_copiedToTokenIds = $this->db->fetchPairs(
"SELECT gtrp_id_token_new, gtrp_id_token_new
FROM gems__token_replacements
WHERE gtrp_id_token_old = ?",
... | The token id's of the tokens this one was copied to, null when not loaded, [] when none exist
@return array tokenId => tokenId | entailment |
public function getEmail()
{
// If staff, return null, we don't know who to email
if ($this->getSurvey()->isTakenByStaff()) {
return null;
}
// If we have a relation, return that address
if ($this->hasRelation()) {
if ($relation = $this->getRelation()... | Get the email address of the person who needs to fill out this survey.
This method will return null when no address available
@return string|null Email address of the person who needs to fill out the survey or null | entailment |
public function getNextToken()
{
if (null === $this->_nextToken) {
$tokenSelect = $this->tracker->getTokenSelect();
$tokenSelect
->andReceptionCodes()
->forPreviousTokenId($this->_tokenId);
if ($tokenData = $tokenSelect->fetchRow()... | Returns the next token in this track
@return \Gems_Tracker_Token | entailment |
public function getNextUnansweredToken()
{
$tokenSelect = $this->tracker->getTokenSelect();
$tokenSelect
->andReceptionCodes()
// ->andRespondents()
// ->andRespondentOrganizations()
// ->andConsents
->andRounds(array())... | Returns the next unanswered token for the person answering this token
@return \Gems_Tracker_Token | entailment |
public function getPreviousSuccessToken()
{
$prev = $this->getPreviousToken();
while ($prev && (! $prev->hasSuccesCode())) {
$prev = $prev->getPreviousToken();
}
return $prev;
} | Returns the previous token that has succes in this track
@return \Gems_Tracker_Token | entailment |
public function getPreviousToken()
{
if (null === $this->_previousToken) {
$tokenSelect = $this->tracker->getTokenSelect();
$tokenSelect
->andReceptionCodes()
->forNextTokenId($this->_tokenId);
if ($tokenData = $tokenSelect->fetchR... | Returns the previous token in this track
@return \Gems_Tracker_Token | entailment |
public function getRawAnswers()
{
if (! is_array($this->_sourceDataRaw)) {
$this->_sourceDataRaw = $this->getSurvey()->getRawTokenAnswerRow($this->_tokenId);
}
return $this->_sourceDataRaw;
} | Returns the answers in simple raw array format, without value processing etc.
Function may return more fields than just the answers.
@return array Field => Value array | entailment |
public function getRelation() {
if (is_null($this->_relation) || $this->_relation->getRelationId() !== $this->getRelationId()) {
$model = $this->loader->getModels()->getRespondentRelationModel();
$relationObject = $model->getRelation($this->getRespondentId(), $this->getRelationId());
... | Get the relation object if any
@return Gems_Model_RespondentRelationInstance | entailment |
public function getRelationFieldName() {
if ($relationFieldId = $this->getRelationFieldId()) {
$names = $this->getRespondentTrack()->getTrackEngine()->getFieldNames();
$fieldPrefix = \Gems\Tracker\Model\FieldMaintenanceModel::FIELDS_NAME . \Gems\Tracker\Engine\FieldsDefinition::FIELD_KEY... | Get the name of the relationfield for this token
@return string | entailment |
public function getRespondent()
{
$patientNumber = $this->getPatientNumber();
$organizationId = $this->getOrganizationId();
if (! ($this->_respondentObject instanceof \Gems_Tracker_Respondent)
|| $this->_respondentObject->getPatientNumber() !== $patientNumber
... | Get the respondent linked to this token
@return \Gems_Tracker_Respondent | entailment |
public function getRespondentGenderHello()
{
$greetings = $this->util->getTranslated()->getGenderGreeting();
$gender = $this->getRespondentGender();
if (isset($greetings[$gender])) {
return $greetings[$gender];
}
} | Returns the gender for use as part of a sentence, e.g. Dear Mr/Mrs
@return string | entailment |
public function getRespondentLanguage()
{
if (! isset($this->_gemsData['grs_iso_lang'])) {
$this->_ensureRespondentData();
if (! isset($this->_gemsData['grs_iso_lang'])) {
// Still not set in a project? The it is single language
$this->_gemsData['grs_... | Return the default language for the respondent
@return string Two letter language code | entailment |
public function getRespondentName()
{
if ($this->hasRelation()) {
if ($relation = $this->getRelation()) {
return $relation->getName();
} else {
return null;
}
}
return $this->getRespondent()->getName();
} | Get the name of the person answering this token
Could be the patient or the relation when assigned to one
@return string | entailment |
public function getRoundCode()
{
$roundCode = null;
$roundId = $this->getRoundId();
if ($roundId > 0) {
$roundCode = $this->getRespondentTrack()->getRoundCode($roundId);
}
return $roundCode;
} | Get the round code for this token
@return string|null Null when no round id is present or round no longer exists | entailment |
public function getTokenCountUnanswered()
{
$tokenSelect = $this->tracker->getTokenSelect(new \Zend_Db_Expr('COUNT(*)'));
$tokenSelect
->andReceptionCodes(array())
->andSurveys(array())
->andRounds(array())
->forRespondent($this->getRes... | Returns the number of unanswered tokens for the person answering this token,
minus this token itself
@return int | entailment |
public function handleAfterCompletion()
{
$survey = $this->getSurvey();
$event = $survey->getSurveyCompletedEvent();
if ($event) {
try {
$changed = $event->processTokenData($this);
if ($changed && is_array($changed)) {
$this-... | Survey dependent calculations / answer changes that must occur after a survey is completed
@param type $tokenId The tokend the answers are for
@param array $tokenAnswers Array with answers. May be changed in process
@return array The changed values | entailment |
public function handleBeforeAnswering()
{
$survey = $this->getSurvey();
$event = $survey->getSurveyBeforeAnsweringEvent();
if ($event) {
try {
$changed = $event->processTokenInsertion($this);
if ($changed && is_array($changed)) {
... | Survey dependent calculations / answer changes that must occur after a survey is completed
@param type $tokenId The tokend the answers are for
@param array $tokenAnswers Array with answers. May be changed in process
@return array The changed values | entailment |
public function inSource()
{
if ($this->exists) {
$survey = $this->getSurvey();
return $survey->inSource($this);
} else {
return false;
}
} | True is this token was exported to the source.
@return boolean | entailment |
public function isExpired()
{
$date = $this->getValidUntil();
if ($date instanceof \MUtil_Date) {
return $date->isEarlierOrEqual(time());
}
return false;
} | True when the valid until is set and is in the past
@return boolean | entailment |
public function isNotYetValid()
{
$date = $this->getValidFrom();
if ($date instanceof \MUtil_Date) {
return $date->isLaterOrEqual(time());
}
return true;
} | True when the valid from is in the future or not yet set
@return boolean | entailment |
public function setNextToken(\Gems_Tracker_Token $token)
{
$this->_nextToken = $token;
$token->_previousToken = $this;
return $this;
} | Sets the next token in this track
@param \Gems_Tracker_Token $token
@return \Gems_Tracker_Token (continuation pattern) | entailment |
public function setRawAnswers($answers)
{
$survey = $this->getSurvey();
$source = $survey->getSource();
$source->setRawTokenAnswers($this, $answers, $survey->getSurveyId(), $survey->getSourceSurveyId());
// They are not always loaded
if ($this->hasAnswersLoaded()) {
... | Sets answers for this token to the values defined in the $answers array. Also handles updating the
internal answercache if present
@param array $answers | entailment |
public function setReceptionCode($code, $comment, $userId)
{
// Make sure it is a \Gems_Util_ReceptionCode object
if (! $code instanceof \Gems_Util_ReceptionCode) {
$code = $this->util->getReceptionCode($code);
}
$values['gto_reception_code'] = $code->getCode();
i... | Set the reception code for this token and make sure the necessary
cascade to the source takes place.
@param string $code The new (non-success) reception code or a \Gems_Util_ReceptionCode object
@param string $comment Comment False values leave value unchanged
@param int $userId The current user
@return int 1 if the t... | entailment |
public function setRoundDescription($description, $userId)
{
$values = $this->_gemsData;
$values['gto_round_description'] = $description;
return $this->_updateToken($values, $userId);
} | Set a round description for the token
@param string The new round description
@param int $userId The current user
@return int 1 if data changed, 0 otherwise | entailment |
protected function toResponseDatabase($userId)
{
$responseDb = $this->project->getResponseDatabase();
// WHY EXPLANATION!!
//
// For some reason mysql prepared parameters do nothing with a \Zend_Db_Expr
// object and that causes an error when using CURRENT_TIMESTAMP
... | Handle sending responses to the response database (if used)
Triggered by checkTokenCompletion
@param int $userId The id of the gems user | entailment |
public function getTab()
{
$username = 'Not Authed';
$role = 'Unknown Role';
if (!$this->_auth->hasIdentity()) {
return 'Not authorized';
}
$identity = $this->_auth->getIdentity();
if (is_object($identity)) {
$username = $this->_auth->getIdent... | Gets menu tab for the Debugbar
@return string | entailment |
public function execute($trackId = null, $fieldKey = null)
{
$batch = $this->getBatch();
$engine = $this->loader->getTracker()->getTrackEngine($trackId);
$fields = $engine->getFieldsDefinition();
$model = $fields->getMaintenanceModel();
$filter = FieldsDefinition::splitKey(... | 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 _addPeriodSelectors(array &$elements, $dates, $defaultDate = null, $switchToSelect = 4)
{
if (is_array($dates) && (1 === count($dates))) {
$fromLabel = reset($dates);
$dates = key($dates);
} else {
$fromLabel = $this->_('From');
}
... | Generate two date selectors and - depending on the number of $dates passed -
either a hidden element containing the field name or an radio button or
dropdown selector for the type of date to use.
@param array $elements Search element array to which the element are added.
@param mixed $dates A string fieldName to use o... | entailment |
protected function _createCheckboxElement($name, $label, $description = null)
{
if ($name && $label) {
$element = $this->form->createElement('checkbox', $name);
$element->setLabel($label);
$element->getDecorator('Label')->setOption('placement', \Zend_Form_Decorator_Abstra... | Creates a \Zend_Form_Element_Select
If $options is a string it is assumed to contain an SQL statement.
@param string $name Name of the element
@param string $label Label for element
@param string $description Optional description
@return \Zend_Form_Element_Checkbox | entailment |
protected function _createMultiCheckBoxElements($name, $options, $separator = null, $toggleLabel = null, $breakBeforeToggle = false)
{
$elements[$name] = $this->_createMultiElement('multiCheckbox', $name, $options, null);
if (! $elements[$name]) {
return [];
}
if (null ... | Creates a \Zend_Form_Element_MultiCheckbox
If $options is a string it is assumed to contain an SQL statement.
@param string $name Name of the select element
@param string|array $options Can be a SQL select string or key/value array of options
@param mixed $separator Optional separator string
@par... | entailment |
protected function _createRadioElement($name, $options, $empty = null)
{
return $this->_createMultiElement('radio', $name, $options, $empty);
} | Creates a \Zend_Form_Element_Select
If $options is a string it is assumed to contain an SQL statement.
@param string $name Name of the select element
@param string|array $options Can be a SQL select string or key/value array of options
@param string $empty Text to display for the empty selector
@r... | entailment |
protected function _createSelectElement($name, $options, $empty = null)
{
return $this->_createMultiElement('select', $name, $options, $empty);
} | Creates a \Zend_Form_Element_Select
If $options is a string it is assumed to contain an SQL statement.
@param string $name Name of the select element
@param string|array $options Can be a SQL select string or key/value array of options
@param string $empty Text to display for the empty selector
@r... | entailment |
public function afterRegistry()
{
parent::afterRegistry();
if ($this->util && (false !== $this->searchData) && (! $this->requestCache)) {
$this->requestCache = $this->util->getRequestCache();
}
if ($this->requestCache) {
// Do not store searchButtonId
... | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function getAutoSearchElements(array $data)
{
// Search text
$element = $this->form->createElement('text', $this->model->getTextFilter(), array('label' => $this->_('Free search text'), 'size' => 20, 'maxlength' => 30));
return array($element);
} | Returns a text element for autosearch. Can be overruled.
The form / html elements to search on. Elements can be grouped by inserting null's between them.
That creates a distinct group of elements
@param array $data The $form field values (can be usefull, but no need to set them)
@return array Of (possible nested) \Ze... | entailment |
protected function getAutoSearchForm()
{
$data = $this->getSearchData();
// \MUtil_Echo::track($data);
$this->form = $form = $this->createForm(array('name' => 'autosubmit', 'class' => 'form-inline', 'role' => 'form'));
$elements = $this->getAutoSearchElements($data);
if ($... | Creates an autosearch form for indexAction.
@return \Gems_Form|null | entailment |
protected function getAutoSearchReset()
{
if ($menuItem = $this->menu->getCurrent()) {
$link = $menuItem->toActionLink($this->request, array('reset' => 1), $this->_('Reset search'));
$element = new \MUtil_Form_Element_Html('reset');
$element->setValue($link);
... | Creates a reset button for the search form
@return \Zend_Form_Element_Html or null | entailment |
public static function getPeriodFilter(array &$filter, \Zend_Db_Adapter_Abstract $db, $inFormat = null, $outFormat = null)
{
$from = array_key_exists('datefrom', $filter) ? $filter['datefrom'] : null;
$until = array_key_exists('dateuntil', $filter) ? $filter['dateuntil'] : null;
$period =... | Helper function to generate a period query string
@param array $filter A filter array or $request->getParams()
@param \Zend_Db_Adapter_Abstract $db
@param $inFormat Optional format to use for date when reading
@param $outFormat Optional format to use for date in query
@return string | entailment |
protected function createForm($options = null)
{
$optionVars = array('askCheck', 'askOld', 'checkFields', 'forceRules', 'labelWidthFactor', 'reportRules');
foreach ($optionVars as $name) {
if ($this->$name !== null) {
$options[$name] = $this->$name;
}
... | Creates an empty form. Allows overruling in sub-classes.
@param mixed $options
@return \Zend_Form | entailment |
protected function getMenuList()
{
if ($this->user->isPasswordResetRequired()) {
$this->menu->setVisible(false);
return null;
}
return parent::getMenuList();
} | overrule to add your own buttons.
@return \Gems_Menu_MenuList | entailment |
public function hasHtmlOutput()
{
if (! ($this->user->inAllowedGroup() && $this->user->canSetPassword())) {
$this->addMessage($this->getNotAllowedMessage());
return false;
}
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 saveData()
{
// If form is valid, but contains messages, do show them. Most likely these are the not enforced password rules
if ($this->_form->getMessages()) {
$this->addMessage($this->_form->getMessages());
}
$this->addMessage($this->_('New password is... | Hook containing the actual save code.
@return int The number of "row level" items changed | entailment |
protected function findTokenFor(array $row)
{
if (isset($row[$this->patientNrField], $row[$this->orgIdField], $row[$this->completionField]) &&
$row[$this->patientNrField] &&
$row[$this->orgIdField] &&
$row[$this->completionField]) {
if ($row[$this... | Find the token id using the passed row data and
the other translator parameters.
@param array $row
@return string|null | entailment |
public function getNoTokenError(array $row, $key)
{
if (! (isset($row[$this->completionField]) && $row[$this->completionField])) {
return $this->_('Missing date in completion_date field.');
}
if (isset($row[$this->patientNrField], $row[$this->orgIdField]) &&
$row[... | Get the error message for when no token exists
@return string | entailment |
public function getRespondentAnswerTranslations()
{
$this->_targetModel->set($this->completionField, 'label', $this->_('Patient ID'),
'order', 8,
'required', true,
'type', \MUtil_Model::TYPE_DATETIME
);
return parent::getRespondentAnswe... | Get information on the field translations
@return array of fields sourceName => targetName
@throws \MUtil_Model_ModelException | entailment |
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
$groups = $this->util->getDbLookup()->getGroups();
$elements[] = $this->_createSelectElement('gsu_id_primary_group', $groups, $this->_('(all groups)'));
// If more than one... | Returns a text element for autosearch. Can be overruled.
The form / html elements to search on. Elements can be grouped by inserting null's between them.
That creates a distinct group of elements
@param array $data The $form field values (can be usefull, but no need to set them)
@return array Of \Zend_Form_Element's ... | entailment |
protected function bin($program = '')
{
// Get list of allowed search paths
if ($location = $this->config()->get('binary_location')) {
$locations = [$location];
} else {
$locations = $this->config()->get('search_binary_locations');
}
// Find program i... | Accessor to get the location of the binary
@param string $program Name of binary
@return string | entailment |
protected function getRawOutput($file)
{
if (!$this->isAvailable()) {
throw new Exception("getRawOutput called on unavailable extractor");
}
$path = $file instanceof File ? $this->getPathFromFile($file) : $file;
exec(sprintf('%s %s - 2>&1', $this->bin('pdftotext'), escap... | Invoke pdftotext with the given File object
@param File|string $file
@return string Output
@throws Exception | entailment |
protected function cleanupLigatures($input)
{
$mapping = [
'ff' => 'ff',
'fi' => 'fi',
'fl' => 'fl',
'ffi' => 'ffi',
'ffl' => 'ffl',
'ſt' => 'ft',
'st' => 'st'
];
return str_replace(array_keys($mapping), array_values... | Removes utf-8 ligatures.
@link http://en.wikipedia.org/wiki/Typographic_ligature#Computer_typesetting
@param string $input
@return string | entailment |
protected function getReadableData()
{
$job = $this->monitorJob;
$data = $job->getArrayCopy();
// Skip when job is not started
if ($data['setTime'] == 0) return;
$data['firstCheck'] = date(MonitorJob::$monitorDateFormat, $data['firstCheck']);
$data[... | Create readable output
@return array | entailment |
protected function getWhere()
{
$id = intval($this->request->getParam(\MUtil_Model::REQUEST_ID));
$add = " = " . $id;
return implode($add . ' OR ', (array) $this->filterOn) . $add;
} | Get the appointment where for this snippet
@return string | entailment |
public function hasHtmlOutput()
{
if ($this->request->getParam($this->confirmParameter)) {
$this->performAction();
$redirectRoute = $this->getRedirectRoute();
return empty($redirectRoute);
} else {
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 performAction()
{
$count = $this->db->delete("gems__appointments", $this->getWhere());
$this->addMessage(sprintf($this->plural(
'%d appointment deleted.',
'%d appointments deleted.',
$count
), $count));
$th... | Overrule this function if you want to perform a different
action than deleting when the user choose 'yes'. | entailment |
protected function setAfterCleanupRoute()
{
// Default is just go to the index
if ($this->cleanupAction && ($this->request->getActionName() !== $this->cleanupAction)) {
$this->afterSaveRouteUrl = array(
$this->request->getControllerKey() => $this->request->getControllerNa... | Set what to do when the form is 'finished'. | entailment |
protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$fparams = array('class' => 'centerAlign');
$row = $bridge->getRow();
if (isset($row[$this->filterWhen]) && $row[$this->filterWhen]) {
$count = $this->... | 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 _getData()
{
$versions = $this->loader->getVersions();
$data[$this->_('Project name')] = $this->project->getName();
$data[$this->_('Project version')] = $versions->getProjectVersion();
$data[$this->_('Gems version')] = $versions->getG... | Returns the data to show in the index action
Allows to easily add or modifiy the information at project level
@return array | entailment |
protected function _showText($caption, $logFile, $emptyLabel = null, $context = null)
{
$this->html->h2($caption);
if ($emptyLabel && (1 == $this->_getParam(\MUtil_Model::REQUEST_ID)) && file_exists($logFile)) {
unlink($logFile);
}
if (file_exists($logFile)) {
... | Helper function to show content of a text file
@param string $caption
@param string $logFile
@param string $emptyLabel | entailment |
public function changelogAction()
{
$this->_showText(sprintf($this->_('Changelog %s'), $this->escort->project->name), APPLICATION_PATH . '/changelog.txt');
} | Show the project specific change log | entailment |
protected function getDirInfo($directory)
{
if (! is_dir($directory)) {
return sprintf($this->_('%s - does not exist'), $directory);
}
$free = disk_free_space($directory);
$total = disk_total_space($directory);
if ((false === $free) || (false === $total)) {
... | Tell all about it
@param string $directory
@return string | entailment |
public function maintenanceAction()
{
// Switch lock
if ($this->util->getMonitor()->reverseMaintenanceMonitor()) {
$this->accesslog->logChange($this->getRequest(), $this->_('Maintenance mode set ON'));
} else {
$this->accesslog->logChange($this->getRequest(), $this->_... | Action that switches the maintenance lock on or off. | entailment |
public function apply(\MUtil_Model_ModelAbstract $model, $valueField)
{
$model->setSaveWhenNotNull($valueField);
$model->setOnLoad($valueField, array($this, 'loadValue'));
$model->setOnSave($valueField, array($this, 'saveValue'));
if ($model instanceof \MUtil_Model_DatabaseModelAbst... | Use this function for a default application of this type to the model
@param \MUtil_Model_ModelAbstract $model
@param string $valueField The field containing the value to be encrypted
@return \Gems_Model_Type_EncryptedField (continuation pattern) | entailment |
public function loadValue($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
{
if ($value && (! $isPost)) {
if ($this->valueMask) {
return str_repeat('*', 8);
} else {
return $this->project->decrypt($value);
}
... | A ModelAbstract->setOnLoad() function that takes care of transforming a
dateformat read from the database to a \Zend_Date format
If empty or \Zend_Db_Expression (after save) it will return just the value
currently there are no checks for a valid date format.
@see \MUtil_Model_ModelAbstract
@param mixed $value The va... | entailment |
public function saveValue($value, $isNew = false, $name = null, array $context = array())
{
if ($value) {
// \MUtil_Echo::track($value);
return $this->project->encrypt($value);
}
} | A ModelAbstract->setOnSave() function that returns the input
date as a valid date.
@see \MUtil_Model_ModelAbstract
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values bein... | entailment |
public function afterRegistry()
{
parent::afterRegistry();
if (! $this->model instanceof \Gems_Model_RespondentModel) {
$this->model = $this->loader->getModels()->getRespondentModel(true);
}
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
public function checkConsent($consent)
{
static $warned;
if ($warned) {
return $consent;
}
$unknown = $this->util->getConsentUnknown();
// Value is translated by now if in bridge
if (($consent == $unknown) || ($consent == $this->_($unknown))) {
... | Check if we have the 'Unknown' consent, and present a warning. The project default consent is
normally 'Unknown' but this can be overruled in project.ini so checking for default is not right
@static boolean $warned We need only one warning in case of multiple consents
@param string $consent | entailment |
protected function getCaption($onlyNotCurrent = false)
{
$orgId = $this->request->getParam(\MUtil_Model::REQUEST_ID2);
if ($orgId == $this->loader->getCurrentUser()->getCurrentOrganizationId()) {
if ($onlyNotCurrent) {
return;
} else {
return $... | Returns the caption for this table
@param boolean $onlyNotCurrent Only return a string when the organization is different
@return string | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$bridge = $this->model->getBridgeFor('itemTable', array('class' => 'displayer table table-condensed'));
$bridge->setRepeater($this->repeater);
$bridge->setColumnCount(2); // May be overruled
$this->addTableCells($bridge);
... | 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->model) {
$this->model->setIfExists('gr2o_email', 'itemDisplay', array('MUtil_Html_AElement', 'ifmail'));
$this->model->setIfExists('gr2o_comments', 'rowspan', 2);
if ($this->showConsentWarning && $this->model->has('gr2o_consen... | 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 getHtmlOutput(\Zend_View_Abstract $view)
{
$html = $this->getHtmlSequence();
$html->h3($this->_('Choose an organization'));
$user = $this->loader->getCurrentUser();
$url[$this->request->getControllerKey()] = 'organization';
$url[$this->request->getActionKey(... | 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 |
private function _getHardAnswers($qid, $scaleId)
{
if (! is_array($this->_hardAnswers)) {
$qaTable = $this->_getAnswersTableName();
$qTable = $this->_getQuestionsTableName();
$sql = 'SELECT a.*, q.other FROM ' . $qaTable . ' AS a
LEFT JOIN ' . $qTable . ... | Returns the answers for a matrix or list type question from the answers table
Uses 1 query to retrieve all answers and serves them as needed
@param integer $qid Question ID
@param integer $scaleId Scale ID | entailment |
protected function _getMultiOptions($field)
{
$scaleId = isset($field['scale_id']) ? $field['scale_id'] : 0;
$qid = $field['qid'];
switch ($field['type']) {
case 'F':
case 'H':
case 'L':
case 'O':
case 'R':
case '1'... | Return an array with all possible answers for a given sid/field combination
@param $field Field from getFieldMap function | entailment |
private function _getPossibleAnswers($field)
{
$scaleId = isset($field['scale_id']) ? $field['scale_id'] : 0;
$code = $field['code'];
if (isset($this->_answers[$code][$scaleId])) {
return $this->_answers[$code][$scaleId];
}
$qid = $field['qid'];
... | Return an array with all possible answers for a given sid/field combination
@param $field Field from getFieldMap function | entailment |
protected function _getQuestionAttribute($qid, $attribute, $default = null)
{
if (! is_array($this->_attributes)) {
$this->_attributes = [];
$attributesTable = $this->_getQuestionAttributesTableName();
$questionsTable = $this->_getQuestionsTableName();
... | Return a certain question attribute or the default value if it does not exist.
@param string $qid
@param string $attribute
@param mxied $default
@return mixed | entailment |
private function _getTitlesMap() {
if (! is_array($this->_titlesMap)) {
$map = $this->_getMap();
$result = array();
foreach ($map as $key => $row) {
// Title does not have to be unique. So if a title is used
// twice we only use it for the... | Returns a map of databasecode => questioncode
@return array | entailment |
protected function _getType($field)
{
switch ($field['type']) {
case ':':
//Get the labels that could apply!
if ($this->_getQuestionAttribute($field['qid'], 'multiflexible_checkbox')) {
return \MUtil_Model::TYPE_STRING;
}
... | Returns
@param $field Field from _getMap function
@return int \MUtil_Model::TYPE_ constant | entailment |
public function applyToModel(\MUtil_Model_ModelAbstract $model)
{
$map = $this->_getMap();
$oldfld = null;
$parent = null;
foreach ($map as $name => $field) {
$tmpres = array();
$tmpres['thClass'] = \Gems_Tracker_SurveyModel::CLASS_MAIN_QUESTION;
... | Applies the fieldmap data to the model
@param \MUtil_Model_ModelAbstract $model | entailment |
public function getQuestionInformation()
{
$map = $this->_getMap();
$oldfld = null;
$result = array();
foreach ($map as $name => $field) {
if ($field['type'] == self::INTERNAL) {
continue;
}
$tmpres = array();
$tmpr... | Returns an array of array with the structure:
question => string,
class => question|question_sub
group => is for grouping
type => (optional) source specific type
answers => string for single types,
array for selection of,
nothing for no answer
@return array Nested array | entailment |
public function getQuestionList($forType = false)
{
$map = $this->_getMap();
$results = array();
$question = null;
foreach ($map as $name => $field) {
// Always need the last field
if (isset($field['question'])) {
$question = $this->remov... | Returns an array containing fieldname => label for dropdown list etc..
@param string $forType Optional type filter
@return array fieldname => label | entailment |
public function mapKeysToTitles(array $values)
{
$map = array_flip($this->_getTitlesMap());
$result = array();
foreach ($values as $key => $value) {
if (isset($map[$key])) {
$result[$map[$key]] = $value;
} else {
$result[$key] = $value... | Changes the keys of the values array to the more readable titles
also available in LimeSurvey
@param array $values | entailment |
public function mapTitlesToKeys(array $values)
{
$titlesMap = $this->_getTitlesMap();
$result = array();
foreach ($values as $key => $value) {
if (isset($titlesMap[$key])) {
$result[$titlesMap[$key]] = $value;
} else {
$result[$key] = ... | Changes the keys of the values array to the more readable titles
also available in LimeSurvey
@param array $values | entailment |
protected function _changeIds($array, $oldId, $newId, $keys) {
if (!is_array($array)) {
return $array;
}
$matches = array_intersect_key($array, $keys);
foreach($matches as $key => &$curId) {
if ($curId == $oldId) {
$array[$key] = $newId;
... | Helper function for setcurrentOrganization
Change value to $newId in an array if the key is in the $keys array (as key) and value is $oldId
@param array $array
@param int $oldId
@param int $newId
@param array $keys
@return array | entailment |
protected function _getRole($roleField)
{
$role = $this->_getVar($roleField);
if (intval($role)) {
$role = \Gems_Roles::getInstance()->translateToRoleName($role);
$this->_setVar($roleField, $role);
}
return $role;
} | Get a role with a check on the value in case of integers
@param string $roleField
@return mixed | entailment |
protected function _getVar($name)
{
$store = $this->_getVariableStore();
if ($store instanceof \Zend_Session_Namespace) {
if ($store->__isset($name)) {
return $store->__get($name);
}
} else {
if ($store->offsetExists($name)) {
... | Get a value in whatever store is used by this object.
@param string $name
@return mixed | entailment |
protected function _hasVar($name)
{
$store = $this->_getVariableStore();
if ($store instanceof \Zend_Session_Namespace) {
return $store->__isset($name);
} else {
return $store->offsetExists($name);
}
} | Checks for existence of a value in whatever store is used by this object.
@param string $name
@return boolean | entailment |
protected function _setVar($name, $value)
{
$store = $this->_getVariableStore();
if ($store instanceof \Zend_Session_Namespace) {
$store->__set($name, $value);
} else {
$store->offsetSet($name, $value);
}
} | Sets a value in whatever store is used by this object.
@param string $name
@param mixed $value
@return void | entailment |
protected function _unsetVar($name)
{
$store = $this->_getVariableStore();
if ($store instanceof \Zend_Session_Namespace) {
$store->__unset($name);
} else {
if ($store->offsetExists($name)) {
$store->offsetUnset($name);
}
}
} | Sets a value in whatever store is used by this object.
@param string $name
@return void | entailment |
protected function afterAuthorization(Result $result, $lastAuthorizer = null)
{
try {
$select = $this->db->select();
$select->from('gems__user_login_attempts', array('gula_failed_logins', 'gula_last_failed', 'gula_block_until', new \Zend_Db_Expr('UNIX_TIMESTAMP() - UNIX_TIMESTAMP(gul... | Process everything after authentication.
@param Zend\Authentication\Result $result | entailment |
public function applyToMenuSource(\Gems_Menu_ParameterSource $source)
{
$source->offsetSet('gsf_id_organization', $this->getBaseOrganizationId());
$source->offsetSet('gsf_active', $this->isActive() ? 1 : 0);
$source->offsetSet('accessible_role', $this->inAllowedGroup() ? 1 : 0);... | Set menu parameters from this user
@param \Gems_Menu_ParameterSource $source
@return \Gems_User_User | entailment |
public function authenticate($password, $testPassword = true)
{
$auths = $this->loadAuthorizers($password, $testPassword);
$lastAuthorizer = null;
foreach ($auths as $lastAuthorizer => $result) {
if (is_callable($result)) {
$result = call_user_func($result);
... | Authenticate a users credentials using the submitted form
@param string $password The password to test
@param boolean $testPassword Set to false to test the non-password checks only
@return Zend\Authentication\Result | entailment |
protected function authorizeBlock()
{
try {
$select = $this->db->select();
$select->from('gems__user_login_attempts', new \Zend_Db_Expr('UNIX_TIMESTAMP(gula_block_until) - UNIX_TIMESTAMP() AS wait'))
->where('gula_block_until is not null')
->wh... | Checks if the user is allowed to login or is blocked
An adapter authorizes and if the end resultis boolean, string or array
it is converted into a Zend\Authenticate\Result.
@return mixed Zend\Authentication\Adapter\AdapterInterface|Zend\Authenticate\Result|boolean|string|array | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.