sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function forFilterId($filterId)
{
$filter = $this->agenda->getFilter($filterId);
if ($filter) {
return $this->forFilter($filter);
}
return $this;
} | For a certain appointment filter
@param int $filterId
@return \Gems\Agenda\AppointmentSelect | entailment |
public function forRespondent($respondentId, $organizationId)
{
$this->_select->where('gap_id_user = ?', $respondentId)
->where('gap_id_organization = ?', $organizationId);
return $this;
} | For a certain respondent / organization
@param int $respondentId
@param int $organizationId
@return \Gems\Agenda\AppointmentSelect | entailment |
public function uniqueForTrackId($trackId, $respTrackId, $previousAppIds)
{
if ($previousAppIds) {
// When unique for all tracks of this type the current track
// appointment id's should also be excluded.
$this->uniqueInTrackInstance($previousAppIds);
}
$... | Add a filter for the appointment id's currently used in tracks with this track id
@param int $trackId The current trrack id
@param int $respTrackId The current respondent track id or null for new tracks
@param array $previousAppIds array of gap_id_appointment | entailment |
public function changeUiAction()
{
$request = $this->getRequest();
$orgId = urldecode($request->getParam('org'));
$oldOrg = $this->currentUser->getCurrentOrganizationId();
$origUrl = base64_decode($request->getParam('current_uri'));
$allowedOrganizations = $this->curr... | Switch the active organization | entailment |
public function checkAllAction()
{
$batch = $this->loader->getTaskRunnerBatch('orgCheckAll');
if (! $batch->isLoaded()) {
$sql = "SELECT gr2o_id_user, gr2o_id_organization
FROM gems__respondent2org INNER JOIN gems__reception_codes ON gr2o_reception_code = grc_id_... | Check a single organization | entailment |
public function checkOrgAction()
{
$go = true;
$orgId = $this->_getIdParam();
$org = $this->loader->getOrganization($orgId);
if (! $org->getRespondentChangeEventClass()) {
$go = false;
$this->addMessage(sprintf(
$this->_('Nothing to do... | Check a single organization | entailment |
public function createModel($detailed, $action)
{
if ($this->escort instanceof \Gems_Project_Layout_MultiLayoutInterface) {
$styles = \MUtil_Lazy::call(array($this->escort, 'getStyles'));
} else {
$styles = array();
}
$model = $this->loader->getModels()->getOr... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
public function getSearchFilter($useRequest = true)
{
$filter = parent::getSearchFilter();
if (isset($filter['respondentstatus'])) {
switch ($filter['respondentstatus']) {
case 'maybePatient':
$filter[] = '(gor_add_respondents = 1 OR gor_has_responden... | Get the filter to use with the model for searching including model sorts, etc..
@param boolean $useRequest Use the request as source (when false, the session is used)
@return array or false | entailment |
public function afterRegistry()
{
$this->_filters = $this->util->getTranslated()->getEmptyDropdownArray() + $this->agenda->getFilterList();
parent::afterRegistry();
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
public function getTextSettings()
{
$messages = array(
'gaf_id' => $this->_('Sub filter may not be the same as this filter.'),
$this->_('Filters may be chosen only once.')
);
return array(
'gaf_filter_text1' => array(
'lab... | Get the settings for the gaf_filter_textN fields
Fields not in this array are not shown in any way
@return array gaf_filter_textN => array(modelFieldName => fieldValue) | entailment |
protected function _checkReturnURI($sourceSurveyId, \Gems_Tracker_Survey $survey, array &$messages)
{
$lsSurvLang = $this->_getSurveyLanguagesTableName();
$sql = 'SELECT surveyls_language FROM ' . $lsSurvLang . ' WHERE surveyls_survey_id = ?';
$lsDb = $this->getSourceDatabase();
$l... | Checks the return URI in LimeSurvey and sets it to the correct one when needed
@see checkSurvey()
@param string $sourceSurveyId
@param \Gems_Tracker_Survey $survey
@param array $messages | entailment |
protected function _checkTokenTable(array $tokenTable)
{
$missingFields = array();
$tokenLength = $this->_extractFieldLength($tokenTable['token']['Type']);
$token_library = $this->tracker->getTokenLibrary();
if ($tokenLength < $token_library->getLength()) {
$tokenLength ... | Check a token table for any changes needed by this version.
@param array $tokenTable
@return array Fieldname => change field commands | entailment |
protected function _fillAttributeMap(\Gems_Tracker_Token $token)
{
$values[$this->_attributeMap['respondentid']] =
substr($token->getRespondentId(), 0, $this->attributeSize);
$values[$this->_attributeMap['organizationid']] =
substr($token->getOrganizationId(), 0, $t... | Returns a list of field names that should be set in a newly inserted token.
@param \Gems_Tracker_Token $token
@return array Of fieldname => value type | entailment |
protected function _filterAnswersOnly($sourceSurveyId, array $answers)
{
$s = $sourceSurveyId . 'X';
$l = strlen($s);
$results = array();
foreach ($answers as $key => $value) {
if (substr($key, 0, $l) == $s) {
$results[$key] = $value;
}
... | Filters an answers array, return only those fields that where answered by the user.
@param int $sourceSurveyId Survey ID
@param array $answers
@return array | entailment |
protected function _getFieldMap($sourceSurveyId, $language = null)
{
$language = $this->_getLanguage($sourceSurveyId, $language);
// \MUtil_Echo::track($language, $sourceSurveyId);
if (! isset($this->_fieldMaps[$sourceSurveyId][$language])) {
$className = $this->fieldMapClass;
... | Return a fieldmap object
@param int $sourceSurveyId Survey ID
@param string $language Optional (ISO) Language, uses default language for survey when null
@return \Gems_Tracker_Source_LimeSurvey1m9FieldMap | entailment |
protected function _getLanguage($sourceSurveyId, $language)
{
if (! is_string($language)) {
$language = (string) $language;
}
if (! isset($this->_languageMap[$sourceSurveyId][$language])) {
if ($language && $this->_isLanguage($sourceSurveyId, $language)) {
... | Returns the langauge to use for the survey when this language is specified.
Uses the requested language if it exists for the survey, the default language for the survey otherwise
@param int $sourceSurveyId Survey ID
@param string $language (ISO) Language
@return string (ISO) Language | entailment |
protected function _getReturnURIDescription($language)
{
return sprintf(
$this->translate->_('Back to %s', $language),
$this->project->getName()
);
} | Get the return URI description to set in LimeSurvey
@param string $language
@return string | entailment |
protected function _getSourceSurveysForSynchronisation()
{
// Surveys in LS
$lsDb = $this->getSourceDatabase();
$select = $lsDb->select();
$select->from($this->_getSurveysTableName(), 'sid')
->order('sid');
return $lsDb->fetchCol($select);
} | Returns all surveys for synchronization
@return array of sourceId values or false | entailment |
protected function _isLanguage($sourceSurveyId, $language)
{
if ($language && strlen($language)) {
// Check for availability of language
$sql = 'SELECT surveyls_language FROM ' . $this->_getSurveyLanguagesTableName() . ' WHERE surveyls_survey_id = ? AND surveyls_language = ?';
... | Check if the specified language is available in Lime Survey
@param int $sourceSurveyId Survey ID
@param string $language (ISO) Language
@return boolean True when the language is an existing language | entailment |
public function checkSourceActive($userId)
{
// The only method to check if it is active is by getting all the tables,
// since the surveys table may be empty so we just check for existence.
$sourceDb = $this->getSourceDatabase();
$tables = array_map('strtolower', $sourceDb->list... | Check if the tableprefix exists in the source database, and change the status of this
adapter in the gems_sources table accordingly
@param int $userId Id of the user who takes the action (for logging)
@return boolean True if the source is active | entailment |
public function checkSurvey($sourceSurveyId, $surveyId, $userId)
{
$messages = array();
$survey = $this->tracker->getSurvey($surveyId);
if (null === $sourceSurveyId) {
// Was removed
$values['gsu_active'] = 0;
$values['gsu_surveyor_active'] = 0;
... | Survey source synchronization check function
@param string $sourceSurveyId
@param int $surveyId
@param int $userId
@return mixed message string or array of messages | entailment |
public function copyTokenToSource(\Gems_Tracker_Token $token, $language, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$language = $this->_getLanguage($sourceSurveyId, $language);
$lsDb = $this... | Inserts the token in the source (if needed) and sets those attributes the source wants to set.
@param \Gems_Tracker_Token $token
@param string $language
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return int 1 of the token was inserted or changed, 0 otherwise
@t... | entailment |
protected function fixTokenAttributeDescriptions($sourceSurveyId)
{
$lsDb = $this->getSourceDatabase();
$fieldData = array();
foreach($this->_attributeMap as $fieldName)
{
// Only add the attribute fields
if (substr($fieldName, 0, 10) == 'attribute_') {
... | Fix the tokenattribute descriptions
When new token attributes are added, make sure the attributedescriptions field
in the surveys table is updated to prevent problems when using these fields
in LimeSurvey. For example by referencing them on screen.
@param int $sourceSurveyId
@return boolean | entailment |
public function getAnswerDateTime($fieldName, \Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
{
$answers = $token->getRawAnswers();
if (isset($answers[$fieldName]) && $answers[$fieldName]) {
return \MUtil_Date::ifDate(
$answers[$fieldName],
... | Returns a field from the raw answers as a date object.
A seperate function as only the source knows what format the date/time value has.
@param string $fieldName Name of answer field
@param \Gems_Tracker_Token $token Gems token object
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey ... | entailment |
public function getCompletionTime(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
{
if ($token->cacheHas('submitdate')) {
// Use cached value when it exists
$submitDate = $token->cacheGet('submitdate');
} else {
if ($token->hasAnswersLoaded()) {
... | Gets the time the survey was completed according to the source
A source always return null when it does not know this time (or does not know
it well enough). In the case \Gems_Tracker_Token will do it's best to keep
track by itself.
@param \Gems_Tracker_Token $token Gems token object
@param int $surveyId Gems Survey ... | entailment |
public function getCompletedTokens($tokenIds, $sourceSurveyId)
{
$lsDb = $this->getSourceDatabase();
$lsToken = $this->_getTokenTableName($sourceSurveyId);
// Make sure we use tokens in the format LimeSurvey likes
$tokens = array_map(array($this, '_getToken'), $tokenIds);
... | Bulk check token completion
Returns all tokens from the input array that are completed, by doing
this in bulk we saved overhead and only do a deep check on the completed
tokens.
@param array $tokenIds
@param int $sourceSurveyId
@return array | entailment |
public function getDatesList($language, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
// Not a question but it is a valid date choice
// $results['submitdate'] = $this->_('Submitdate');
$resul... | Returns an array containing fieldname => label for each date field in the survey.
Used in dropdown list etc..
@param string $language (ISO) language string
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array fieldname => label | entailment |
public function getFullQuestionList($language, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
return $this->_getFieldMap($sourceSurveyId, $language)->getFullQuestionList();
} | Returns an array containing fieldname => label for each answerable question in the survey.
Used in dropdown list etc..
@param string $language (ISO) language string
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array fieldname => label
@deprecated since ... | entailment |
public function getQuestionInformation($language, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
return $this->_getFieldMap($sourceSurveyId, $language)->getQuestionInformation();
} | Returns an array of arrays 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
@param string $language (ISO) language string
@param int $sur... | entailment |
public function getQuestionList($language, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
return $this->_getFieldMap($sourceSurveyId, $language)->getQuestionList();
} | Returns an array containing fieldname => label for each answerable question in the survey.
Used in dropdown list etc..
@param string $language (ISO) language string
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array fieldname => label | entailment |
public function getRawTokenAnswerRow($tokenId, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$lsDb = $this->getSourceDatabase();
$lsTab = $this->_getSurveyTableName($sourceSurveyId);
$token ... | Returns the answers in simple raw array format, without value processing etc.
Function may return more fields than just the answers.
@param string $tokenId Gems Token Id
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array Field => Value array | entailment |
public function getRawTokenAnswerRows(array $filter, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$select = $this->getRawTokenAnswerRowsSelect($filter, $surveyId, $sourceSurveyId);
//Now process the f... | Returns the answers of multiple tokens in simple raw nested array format,
without value processing etc.
Function may return more fields than just the answers.
@param array $filter XXXXX
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return array Of nested Field =>... | entailment |
public function getRawTokenAnswerRowsCount(array $filter, $surveyId, $sourceSurveyId = null) {
$select = $this->getRawTokenAnswerRowsSelect($filter, $surveyId, $sourceSurveyId);
$p = new \Zend_Paginator_Adapter_DbSelect($select);
$count = $p->getCountSelect()->query()->fetchColumn();
r... | Returns the recordcount for a given filter
@param array $filter filter array
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return int | entailment |
public function getRawTokenAnswerRowsSelect(array $filter, $surveyId, $sourceSurveyId = null) {
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$lsDb = $this->getSourceDatabase();
$lsSurveyTable = $this->_getSurveyTableName($sourceSurveyId);
... | Get the select object to use for RawTokenAnswerRows
@param array $filter
@param type $surveyId
@param type $sourceSurveyId
@return \Zend_Db_Select | entailment |
public function getSurveyAnswerModel(\Gems_Tracker_Survey $survey, $language = null, $sourceSurveyId = null)
{
static $cache = array(); // working with 'real' cache produces out of memory error
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($survey->getSurveyId(... | Returns a model for the survey answers
@param \Gems_Tracker_Survey $survey
@param string $language Optional (ISO) language string
@param string $sourceSurveyId Optional Survey Id used by source
@return \MUtil_Model_ModelAbstract | entailment |
public function getTokenInfo(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId, array $fields = null)
{
if (! $token->cacheHas(self::CACHE_TOKEN_INFO)) {
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$lsTokens = $this... | Retrieve all fields stored in the token table, and store them in the tokencache
@param \Gems_Tracker_Token $token
@param type $surveyId
@param type $sourceSurveyId
@param array $fields
@return type | entailment |
public function getTokenUrl(\Gems_Tracker_Token $token, $language, $surveyId, $sourceSurveyId)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$tokenId = $this->_getToken($token->getTokenId());
if ($this->_isLanguage($sourceSurveyId, $lan... | Returns the url that (should) start the survey for this token
@param \Gems_Tracker_Token $token Gems token object
@param string $language
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return string The url to start the survey | entailment |
public function getValidDates(\Gems_Tracker_Token $token)
{
$now = new \MUtil_Date();
// For extra protection, we add valid from/to dates as needed instead of leaving them in GemsTracker only
$tokenFrom = $token->getValidFrom();
$tokenUntil = $token->getValidUntil();
// Alwa... | Get valid from/to dates to send to LimeSurvey depending on the dates of the token
@param \Gems_Tracker_Token $token
@return [] | entailment |
public function inSource(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
{
$tokenInfo = $this->getTokenInfo($token, $surveyId, $sourceSurveyId);
return (boolean) $tokenInfo;
} | Checks whether the token is in the source.
@param \Gems_Tracker_Token $token Gems token object
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return boolean | entailment |
public function isCompleted(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
{
$tokenInfo = $this->getTokenInfo($token, $surveyId, $sourceSurveyId);
if (isset($tokenInfo['completed']) && $tokenInfo['completed'] != 'N') {
return true;
} else {
return fals... | Returns true if the survey was completed according to the source
@param \Gems_Tracker_Token $token Gems token object
@param int $surveyId Gems Survey Id
@param $answers array Field => Value array, can be empty
@param string $sourceSurveyId Optional Survey Id used by source
@return boolean True if the token has complet... | entailment |
public function setRawTokenAnswers(\Gems_Tracker_Token $token, array $answers, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$lsDb = $this->getSourceDatabase();
$lsTab = $this->_getSurveyTable... | Sets the answers passed on.
@param \Gems_Tracker_Token $token Gems token object
@param array $answers Field => Value array
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@return true When answers changed | entailment |
public function setTokenCompletionTime(\Gems_Tracker_Token $token, $completionTime, $surveyId, $sourceSurveyId = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$lsDb = $this->getSourceDatabase();
$lsTabSurv = $this->_getSurvey... | Sets the completion time.
@param \Gems_Tracker_Token $token Gems token object
@param \Zend_Date|null $completionTime \Zend_Date or null
@param int $surveyId Gems Survey Id (actually required)
@param string $sourceSurveyId Optional Survey Id used by source | entailment |
public function updateConsent(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null, $consentCode = null)
{
if (null === $sourceSurveyId) {
$sourceSurveyId = $this->_getSid($surveyId);
}
$lsDb = $this->getSourceDatabase();
$lsTokens = $this->_getTokenTableNam... | Updates the consent code of the the token in the source (if needed)
@param \Gems_Tracker_Token $token
@param int $surveyId Gems Survey Id
@param string $sourceSurveyId Optional Survey Id used by source
@param string $consentCode Optional consent code, otherwise code from token is used.
@return int 1 of the token was i... | entailment |
protected function afterSave($changed)
{
if ($changed) {
$this->accesslog->logChange($this->request, null, $this->formData);
// Reload the current user data
$user = $this->currentUser;
$currentOrg = $user->getCurrentOrganizationId();
$this-... | Hook that allows actions when data was saved
When not rerouted, the form will be populated afterwards
@param int $changed The number of changed rows (0 or 1 usually, but can be more) | entailment |
protected function createModel()
{
if (! $this->model instanceof \Gems_Model_StaffModel) {
$this->model = $this->loader->getModels()->getStaffModel(false);
$this->model->applyOwnAccountEdit();
}
return $this->model;
} | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
public function hasHtmlOutput()
{
if ($this->currentUser->getUserId() == \Gems_User_UserLoader::SYSTEM_USER_ID) {
$this->addMessage($this->getNotAllowedMessage());
return false;
}
return parent::hasHtmlOutput();
} | If the current user is the system user, present a message and don't allow to edit
@return boolean | entailment |
public function execute($roundId = null, $roundDescription = null)
{
$batch = $this->getBatch();
if ($batch->hasVariable('trackEngine')) {
$trackEngine = $batch->getVariable('trackEngine');
if ($trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) {
... | 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 getTag()
{
if (null === $this->_tag) {
$tag = $this->getOption('tag');
if (null !== $tag) {
$this->removeOption('tag');
} else {
$tag = 'span';
}
$this->setTag($tag);
return $tag;
... | Get HTML tag, if any, with which to surround tooltip
@return string | entailment |
public function getEscape()
{
if (null === $this->_escape) {
if (null !== ($escape = $this->getOption('escape'))) {
$this->setEscape($escape);
$this->removeOption('escape');
} else {
$this->setEscape(true);
}
}
... | Get escape flag
@return true | entailment |
public function render($content)
{
$element = $this->getElement();
$view = $element->getView();
if (null === $view) {
return $content;
}
$tooltip = $element->getAttrib('tooltip');
$tooltip = trim($tooltip);
//$element->removeAttrib('tooltip');
... | Render a tooltip
@param string $content
@return string | entailment |
public function calcultateName($value, $isNew = false, $name = null, array $context = array())
{
$output = array();
// Check all the fields
for ($i = 1; $i <= $this->_fieldCount; $i++) {
$field = 'gaf_filter_text' . $i;
if (isset($context[$field], $this->_filters[$co... | 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 createModel($detailed, $action)
{
$defaultOrgId = null;
if ($detailed) {
// Make sure the user is loaded
$user = $this->getSelectedUser();
if ($user) {
if (! ($this->currentUser->hasPrivilege('pr.staff.see.all') ||
... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
public function getDeactivateTitle()
{
$user = $this->getSelectedUser();
if ($user) {
return sprintf($this->_('Deactivate staff member %s'), $user->getLoginName());
}
return parent::getDeactivateTitle();
} | Helper function to get the title for the deactivate action.
@return $string | entailment |
public function getReactivateTitle()
{
$user = $this->getSelectedUser();
if ($user) {
return sprintf($this->_('Reactivate staff member %s'), $user->getLoginName());
}
return parent::getReactivateTitle();
} | Helper function to get the title for the reactivate action.
@return $string | entailment |
public function getSearchFilter($useRequest = true)
{
$filter = parent::getSearchFilter($useRequest);
if (! (isset($filter['gsf_id_organization']) && $filter['gsf_id_organization'])) {
$filter['gsf_id_organization'] = array_keys($this->currentUser->getAllowedOrganizations());
}
... | Get the filter to use with the model for searching including model sorts, etc..
@param boolean $useRequest Use the request as source (when false, the session is used)
@return array or false | entailment |
public function getShowTitle()
{
$user = $this->getSelectedUser();
if ($user) {
return sprintf($this->_('Show staff member %s'), $user->getLoginName());
}
return parent::getShowTitle();
} | Helper function to get the title for the show action.
@return $string | entailment |
public function mailAction()
{
if ($this->mailSnippets) {
$params = $this->_processParameters($this->mailParameters);
$this->addSnippets($this->mailSnippets, $params);
}
} | mail a staff member | entailment |
public function resetAction()
{
if ($this->resetSnippets) {
$params = $this->_processParameters($this->resetParameters);
$this->addSnippets($this->resetSnippets, $params);
}
} | reset a password | entailment |
public function reset2faAction()
{
$user = $this->getSelectedUser();
$user->clearTwoFactorKey();
$this->addMessage(
sprintf($this->_('Two factor key cleared for user %s'),
$user->getLoginName()),
'success');
$router = \Zend_Cont... | reset two factor authentication | entailment |
protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$this->_roundData = $bridge->getRow();
if ($this->trackEngine instanceof \Gems_Tracker_Engine_StepEngineAbstract) {
$this->trackEngine->updateRoundModelToItem($model... | Adds rows from the model to the bridge that creates the browse table.
Overrule this function to add different columns to the browse table, without
having to recode the core table building code.
@param \MUtil_Model_Bridge_VerticalTableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@return void | entailment |
public function execute($sourceId = null, $sourceSurveyId = null, $surveyId = null, $userId = null)
{
$batch = $this->getBatch();
$source = $this->loader->getTracker()->getSource($sourceId);
if (null === $userId) {
$userId = $this->loader->getCurrentUser()->getUserId();
... | 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 getActiveOrganizationId()
{
$request = $this->getRequest();
if ($request->isPost()) {
return $request->getParam($this->organizationFieldName);
}
} | Get the organization id that has been currently entered
@return int | entailment |
public function getCurrentOrganizationId()
{
$userLoader = $this->loader->getUserLoader();
// Url determines organization first.
if ($orgId = $userLoader->getOrganizationIdByUrl()) {
$this->_organizationFromUrl = true;
$userLoader->getCurrentUser()->setCurrentOrganiz... | Returns the organization id that should currently be used for this form.
@return int Returns the current organization id, if any | entailment |
public function getOrganizationElement()
{
$element = $this->getElement($this->organizationFieldName);
$orgId = $this->getCurrentOrganizationId();
$orgs = $this->getLoginOrganizations();
$hidden = $this->_organizationFromUrl || (count($orgs) < 2);
if ($hidden) {
... | Returns/sets an element for determining / selecting the organization.
@return \Zend_Form_Element_Xhtml | entailment |
public function getUser()
{
if (! $this->_user) {
$request = $this->getRequest();
$this->_user = $this->loader->getUser($request->getParam($this->usernameFieldName), $request->getParam($this->organizationFieldName));
}
return $this->_user;
} | Returns a user
@return \Gems_User_User | entailment |
public function getUserNameElement()
{
$element = $this->getElement($this->usernameFieldName);
if (! $element) {
// Veld inlognaam
$element = $this->createElement('text', $this->usernameFieldName);
$element->setLabel($this->translate->_('Username'));
... | Returns/sets a login name element.
@return \Zend_Form_Element_Text | entailment |
public function isValid($data, $disableTranslateValidators = null)
{
$this->_user = $this->loader->getUser(
(isset($data[$this->usernameFieldName]) ? $data[$this->usernameFieldName] : null),
(isset($data[$this->organizationFieldName]) ? $data[$this->organizationFieldName] : '... | Validate the form
As it is better for translation utilities to set the labels etc. translated,
the MUtil default is to disable translation.
However, this also disables the translation of validation messages, which we
cannot set translated. The MUtil form is extended so it can make this switch.
@param array $data
... | entailment |
public function wasSubmitted()
{
// If form was not (yet) populated, we can not use isChecked() so do this manually
$request = $this->getRequest();
if ($request->isPost() && strlen(trim($request->getPost($this->_submitFieldName)))) {
return true;
} else {
retu... | True when this form was submitted.
@return boolean | entailment |
public function addTo($newTo, $newToName = '')
{
if (is_array($newTo)) {
$this->to = array_merge($newTo, $this->to);
} else {
if (empty($newToName)) {
$this->to[] = $newTo;
} else {
$this->to[$newToName] = $newTo;
}
... | Add a To field | entailment |
public function getMailFields($marked=true)
{
if ($marked) {
if (! $this->markedMailFields) {
$this->markedMailFields = $this->markMailFields($this->mailFields);
}
return $this->markedMailFields;
} else {
return $this->mailFields;
... | Return the mailFields
@param boolean $marked Return the mailfields with their markers
@return Array List of the mailfields and their values | entailment |
public function applyFields($text)
{
$mailKeys = array_keys($this->getMailFields());
return str_replace($mailKeys, $this->mailFields, $text);
} | Replace the mailkeys with the mailfields in given text
@param string $text The text to apply the replacment to
@return string The text with replaced mailfields | entailment |
public function getLanguage()
{
if ($this->project->getEmailMultiLanguage() && $this->language) {
return $this->language;
} else {
return $this->project->getLocaleDefault();
}
} | Get the prefered template language
@return string language code | entailment |
public function getPresetTargetData()
{
$targetData = array();
if ($this->to) {
$fullDisplay = array();
foreach($this->to as $name=>$address) {
$fullTo = '';
if (!is_numeric($name)) {
$fullTo .= $name . ' ';
... | Get specific data set in the mailer
@return Array | entailment |
public function getTemplate($templateId, $language=null)
{
if (!$language) {
$language = $this->getLanguage();
}
$select = $this->db->select();
$select->from('gems__comm_template_translations')
->where('gctt_id_template = ?', $templateId)
->w... | get a specific template.
If the selected translation exists, get that translation
Else if the selected translation isn't the default, select the default translation
Else select the first not empty translation
Else return false
@param integer $templateId Template ID | entailment |
protected function loadMailFields()
{
if ($this->organization) {
$this->mailFields = array_merge($this->project->getMailFields(), $this->organization->getMailFields());
} else {
$this->mailFields = $this->project->getMailFields();
}
} | Initialize the mailfields | entailment |
protected function loadOrganization()
{
if (!$this->organizationId) {
$this->loadOrganizationId();
}
$this->organization = $this->loader->getOrganization($this->organizationId);
} | Load the organization from the given organization id | entailment |
public function markMailFields($mailFields)
{
$markedMailFields = \MUtil_Ra::braceKeys($mailFields, $this->mailFieldMarkers['start'], $this->mailFieldMarkers['end']);
return $markedMailFields;
} | Add specified markers to the mailfield keys
@param Array $mailfields
@return Array The marked mailfields | entailment |
public function send()
{
$mail = $this->loader->getMail();
$mail->setFrom($this->from);
$mail->addTo($this->to, '', $this->bounceCheck());
if (isset($this->project->email['bcc'])) {
$mail->addBcc($this->project->email['bcc']);
}
$mail->setSubject($this-... | Send the mail | entailment |
public function setFrom($newFrom)
{
$this->from = $newFrom;
$this->mailFields['from'] = $this->mailFields['reply_to'] = $newFrom;
} | set the from field | entailment |
public function setTemplate($templateId)
{
if ($template = $this->getTemplate($templateId)) {
$this->subject = $template['gctt_subject'];
$this->bodyBb = $template['gctt_body'];
$this->setTemplateId($templateId);
}
} | set a specific template as subject/body
@param integer $templateId Template ID | entailment |
public function setTemplateByCode($templateCode)
{
$select = $this->loader->getModels()->getCommTemplateModel()->getSelect();
$select->where('gct_code = ?', $templateCode);
$template = $this->db->fetchRow($select);
if ($template) {
$this->setTemplate($template['gct_id_te... | Use the Mail template code to select and set the template
@param string mail | entailment |
public function setTo($newTo, $newToName = '')
{
if (is_array($newTo)) {
$this->to = $newTo;
} else {
$this->to = array();
if (empty($newToName)) {
$this->to[] = $newTo;
} else {
$this->to[$newToName] = $newTo;
... | set the To field, overwriting earlier settings completely
@param [type] $to [description] | entailment |
protected function getAutoSearchElements(array $data)
{
$elements = [];
$this->addTrackSelect($elements, $data, 'gtf_id_track');
$this->addOrgSelect($elements, $data, 'gr2t_id_organization');
$elements[] = null;
$this->addPeriodSelect($elements, $data);
... | 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 _addJoinTables()
{
$this->addTable('gems__respondents', array('gec_id_user' => 'grs_id_user'));
if ($this->has('gec_id_organization')) {
$this->addTable(
'gems__organizations',
array('gec_id_organization' => 'gor_id_organization... | Add the join tables instead of lookup tables. | entailment |
public function applyBrowseSettings()
{
$this->_addJoinTables();
$this->resetOrder();
$agenda = $this->loader->getAgenda();
$this->setIfExists('gec_status', 'label', $this->_('Status'),
'multiOptions', $agenda->getEpisodeStatusCodes());
$this->setIfExist... | Set those settings needed for the browse display
@return \Gems_Model_AppointmentModel | entailment |
public function applyDetailSettings()
{
$this->resetOrder();
$agenda = $this->loader->getAgenda();
$dbLookup = $this->util->getDbLookup();
$empty = $this->util->getTranslated()->getEmptyDropdownArray();
$this->setIfExists('gec_id_organization', 'label', $this->_('Organ... | Set those settings needed for the detailed display
@return \Gems_Model_AppointmentModel | entailment |
public function applyEditSettings($orgId, $respId)
{
$this->applyDetailSettings();
$agenda = $this->loader->getAgenda();
$empty = $this->util->getTranslated()->getEmptyDropdownArray();
$this->setIfExists('gec_id_user', 'default', $respId,
'elementClass', 'H... | Set those values needed for editing
@param int $orgId The id of the current organization
@param int $respId The id of the current respondent
@return \Gems_Model_AppointmentModel | entailment |
public function _($text, $locale = null)
{
if (! isset($this->request)) {
// Locale is fixed by request.
$this->setException(new \Gems_Exception_Coding('Requested translation before request was made available.'));
}
return $this->translateAdapter->_($text, $locale);
... | Copy from \Zend_Translate_Adapter
Translates the given string
returns the translation
@param string $text Translation string
@param string|\Zend_Locale $locale (optional) Locale/Language to use, identical with locale
identifier, @see \Zend_Locale for more information
@return string | entailment |
protected function _checkParameters(array $params, array $posts)
{
foreach ($params as $key => $value) {
$rest = strpbrk($key, '<>=%&"\'');
if (false !== $rest) {
$this->setError(
$this->_('Illegal request parameter'),
4... | Check all parameters for security violations
All variables are checked for name contents: the <>=%&"' characters should not occur in the name.
The non-post variables are checked for value contents as well: after a <>&% there should not occur
a frame, script or img stext.
@param array $params
@param array $posts | entailment |
protected function _copyVariables($object)
{
// Store for _updateVariable
$this->_copyDestinations[] = $object;
// Extra object
$object->escort = $this;
foreach ($this->getContainer() as $key => $value) {
// Prevent self referencing
if ($value !== $o... | Function to maintain uniformity of access to variables from the bootstrap object.
Copies all variables to the target object.
@param Object $object An object who gets all variables from this object.
@return void | entailment |
protected function _initProject()
{
$projectArray = $this->includeFile(APPLICATION_PATH . '/configs/project');
if ($projectArray instanceof \Gems_Project_ProjectSettings) {
$project = $projectArray;
} else {
$project = $this->createProjectClass('Project_ProjectSettin... | Initialize the GEMS project component.
The project component contains information about this project that are not Zend specific.
For example:
-- the super administrator,
-- the project name, version and description,
-- locales used,
-- css and image directories used.
This is the place for you to store any project spe... | entailment |
protected function _initLogger()
{
$this->bootstrap('project'); // Make sure the project object is available
$logger = \Gems_Log::getLogger();
$logPath = GEMS_ROOT_DIR . '/var/logs';
try {
$writer = new \Zend_Log_Writer_Stream($logPath . '/errors.log');
} cat... | Initialize the logger
@return \Gems_Log | entailment |
protected function _initCache()
{
$this->bootstrap('project');
$useCache = $this->getResource('project')->getCache();
$cache = null;
$exists = false;
$cachePrefix = GEMS_PROJECT_NAME . '_';
// Check if APC extension is loaded and enabled
if (\MU... | Create a default file cache for the Translate and DB adapters to speed up execution
@return \Zend_Cache_Core | entailment |
protected function _initDb()
{
// DATABASE CONNECTION
$resource = $this->getPluginResource('db');
if (! $resource) {
// Do not throw error here. Error is throw in frontDispatchLoopStartup()
// and no, you should not try to access the database in any earlier
... | Initialize the database.
Use $this->db to access afterwards
@return \Zend_Db | entailment |
protected function _initLoader()
{
$loader = $this->createProjectClass('Loader', $this->getContainer(), $this->_loaderDirs);
\MUtil_Model::setSource($loader, true);
return $loader;
} | Initialize the Project or Gems loader.
Use $this->loader to access afterwards
@return \Gems_Loader | entailment |
protected function _initAccesslog()
{
$this->bootstrap(array('cache', 'db', 'loader'));
$accesslog = $this->createProjectClass('AccessLog', $this->cache, $this->db, $this->loader);
return $accesslog;
} | Initialize the access log.
Use $this->accesslog to access afterwards
@return \Gems_AccessLog | entailment |
protected function _initAcl()
{
$this->bootstrap(array('db', 'loader', 'logger'));
$acl = $this->getLoader()->getRoles($this);
return $acl->getAcl();
} | Initialize the database.
Use $this->acl to access afterwards
@return \MUtil_Acl | entailment |
protected function _initSession()
{
$this->bootstrap('project'); // Make sure the project is available
$session = new \Zend_Session_Namespace('gems.' . GEMS_PROJECT_NAME . '.session');
$idleTimeout = $this->project->getSessionTimeOut();
$session->setExpirationSeconds($idleTimeout);... | Initialize the Gems session.
The session contains information on the registered user from @see $this->loadLoginInfo($username)
This includes:
-- user_id
-- user_login
-- user_name
-- user_role
-- user_locale
-- user_organization_id
Use $this->session to access afterwards
@deprecated since 1.5
@return \Zend_Session_N... | entailment |
protected function _initLocale()
{
$this->bootstrap(array('project', 'session'));
// Get the choosen language
if (isset($this->session->user_locale)) {
$localeId = $this->session->user_locale;
// \MUtil_Echo::r('sess: ' . $localeId);
} else {
if ... | Initialize the locale.
We use this function instead of the standard application.ini setting to
simplify overruling the settings.
Also Firefox tends to overrule the locale settings.
You can overrule this function to specify your own project translation method / file.
Use $this->locale to access afterwards
@return \... | entailment |
protected function _initOpenRosa()
{
$this->bootstrap(array('loader', 'translate'));
if ($this->getOption('useOpenRosa')) {
// First handle dependencies
$this->bootstrap(array('db', 'loader', 'util'));
$this->getLoader()->addPrefixPath('OpenRosa', GEMS_LIBRARY_D... | Initialize the OpenRosa survey source | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.