sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function getUserClassSelect($login_name, $organization)
{
$select = $this->db->select();
/**
* tolerance field:
* 1 - login and organization match
* 2 - login found in an organization with access to the requested organization
* 3 - login found in anothe... | Returns a select statement to find a corresponding user.
@param string $login_name
@param int $organization
@return \Zend_Db_Select | entailment |
protected function loadUser($defName, $userOrganization, $userName)
{
$definition = $this->getUserDefinition($defName);
$values = $definition->getUserData($userName, $userOrganization);
// \MUtil_Echo::track($defName, $login_name, $userOrganization, $values);
$values = $this->ensur... | Returns a loaded user object
@param string $defName
@param int $userOrganization
@param string $userName
@return \Gems_User_User But ! ->isActive when the user does not exist | entailment |
public function setCurrentUser(\Gems_User_User $user)
{
if ($user !== self::$currentUser) {
$this->unsetCurrentUser();
self::$currentUser = $user;
// Update the escort variable used by loader
if ($escort = GemsEscort::getInstance()) {
$escort-... | Sets a new user as the current user.
@param \Gems_User_User $user
@return \Gems_User_UserLoader (continuation pattern) | entailment |
public function unsetCurrentUser()
{
// Remove if the currentUser still sees itself as the current user.
if ((self::$currentUser instanceof \Gems_User_User) && self::$currentUser->isCurrentUser()) {
self::$currentUser->unsetAsCurrentUser(false);
}
self::$currentUser = nul... | Removes the current user
@return \Gems_User_UserLoader (continuation pattern) | entailment |
public function afterRegistry()
{
parent::afterRegistry();
// Load the pdf class from the project settings if available
if (isset($this->project->export) && isset($this->project->export['pdfExportCommand'])) {
$this->_pdfExportCommand = $this->project->export['pdfExportCommand']... | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function addTokenToDocument(\Zend_Pdf $pdf, $tokenId, $surveyId)
{
$token = strtoupper($tokenId);
foreach (array('Title', 'Subject', 'Keywords') as $name) {
if (isset($pdf->properties[$name])) {
$orgValue = $pdf->properties[$name];
if (mb_detect... | Add the token to every page of a pdf
@param \Zend_Pdf $pdf
@param string $tokenId
@param int $surveyId | entailment |
protected function addTokenToPage(\Zend_Pdf_Page $page, $tokenId)
{
// Set $this->pageFont to false to prevent drawing of tokens on page.
if ($this->pageFont) {
$font = \Zend_Pdf_Font::fontWithName($this->pageFont);
if ($this->pageXfromLeft) {
$x = $this->pag... | Add the token to a pdf page
@param \Zend_Pdf_Page $page
@param string $tokenId | entailment |
protected function echoPdf(\Zend_Pdf $pdf, $filename, $download = false, $exit = true)
{
$content = $pdf->render();
$this->echoPdfContent($content, $filename, $download);
if ($exit) {
// No further output
exit;
}
} | Echos the pdf as output with the specified filename.
When download is true the file is returned as a download link,
otherwise the pdf is shown in the browser.
@param \Zend_Pdf $pdf
@param string $filename
@param boolean $download
@param boolean $exit Should the application stop running after output | entailment |
public function echoPdfContent($content, $filename, $download = false)
{
// \MUtil_Echo::track($filename);
if ($download) {
// Download & save
header('Content-Type: application/x-download');
} else {
//We send to a browser
header('Content-Type: applicat... | Output the pdf with the right headers.
@param string $content The content to echo
@param string $filename The filename as reported to the downloader
@param boolean $download Download to file or when false: show in browser | entailment |
public function echoPdfBySurveyId($surveyId)
{
$pdf = $this->getSurveyPdf($surveyId);
$this->echoPdf($pdf, $surveyId . '.pdf');
} | Reads the survey pdf and outputs the result (without token id's etc..
@param string $tokenId | entailment |
public function echoPdfByTokenId($tokenId)
{
$surveyId = $this->db->fetchOne('SELECT gto_id_survey FROM gems__tokens WHERE gto_id_token = ?', $tokenId);
$pdf = $this->getSurveyPdf($surveyId);
$this->addTokenToDocument($pdf, $tokenId, $surveyId);
foreach ($pdf->pages as $page) {
... | Reads the survey pdf belonging to this token, puts the token id
on de pages and outputs the result.
@param string $tokenId | entailment |
public function getUploadDir($subdir = null)
{
$dir = GEMS_ROOT_DIR . '/var/uploads';
if ($subdir) {
if (($subdir[0] == '/') || ($subdir[0] == '\\') || (substr($subdir, 1, 2) == ':\\')) {
$dir = rtrim($subdir, '\//');
} else {
$dir .= DIRECTOR... | Return upload directory, optionally with specified sub directory.
You can overrule this function to specify your own directory.
@param string $subdir Optional sub-directory, when starting with / or x:\ only $subdir is used. Function creates subdirectory if it does not exist.
@return string | entailment |
protected function throwLastError($msg)
{
if ($last = \MUtil_Error::getLastPhpErrorMessage()) {
$msg .= sprintf($this->translate->_(' The error message is: %s'), $last);
}
throw new \Gems_Exception_Coding($msg);
} | Helper function for error handling
@param string $msg
@throws \Gems_Exception_Coding | entailment |
public function convertFromHtml($content)
{
\MUtil_File::ensureDir(GEMS_ROOT_DIR . '/var/tmp');
$tempInputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.html';
$tempOutputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.pdf';
if (\... | Calls the PDF convertor (wkhtmltopdf / phantom.js) to convert HTML to PDF
@param string $content The HTML source
@return string The converted PDF file
@throws \Exception | entailment |
public function addMessage($message, $status=null)
{
$messenger = $this->getMessenger();
$messenger->addMessage($message, $status);
return $this;
} | Adds one or more messages to the session based message store.
@param mixed $message_args Can be an array or multiple argemuents. Each sub element is a single message string
@return \MUtil_Controller_Action | entailment |
public function transformLoad(\MUtil_Model_ModelAbstract $model, array $data, $new = false, $isPostData = false)
{
foreach($data as $tokenId=>$row) {
if (isset($row['gto_id_respondent_track'])) {
if (!isset($this->trackFieldsByRespondentTrack[$row['gto_id_respondent_track']])) {
... | The transform function performs the actual transformation of the data and is called after
the loading of the data in the source model.
@param \MUtil_Model_ModelAbstract $model The parent model
@param array $data Nested array
@param boolean $new True when loading a new item
@param boolean $isPostData With post data, un... | entailment |
private function _applyParameterFilter(\Gems_Menu_ParameterCollector $source, $raiseConditions, &$condition)
{
foreach ($this->_parameterFilter as $name => $testValue) {
$paramValue = $source->getMenuParameter($name);
$testValue = (array) $testValue;
if ($paramValue ins... | Return true when then $source does NOT contain all items in the parameterFilter
@param \Gems_Menu_ParameterCollector $source
@param boolean $raiseConditions
@param mixed $condition
@return boolean | entailment |
private function _applyParameterSources(\Gems_Menu_ParameterCollector $source, array &$parameters, $raiseConditions)
{
// \Gems_Menu::$verbose = true;
// \MUtil_Echo::r($this->get('label'));
$condition = true;
if ($this->_applyParameterFilter($source, $raiseConditions, $condition)) ... | A function that determines the parameters that this menu item should have using these paramter
sources.
@param \Gems_Menu_ParameterCollector $source A source of parameter values
@param array $parameters A usually empty array of parameters that is filled from the sources
@param boolean $raiseConditions When true, no la... | entailment |
private function _toHRef(\Gems_Menu_ParameterCollector $source, &$condition)
{
if ($this->get('allowed')) {
$parameters = array();
if ($condition = $this->_applyParameterSources($source, $parameters, ! $condition)) {
if ($this->_hiddenOrgId) {
$u... | Generate a hrf attribute using these sources
@param \Gems_Menu_ParameterCollector $source A parameter source collection
@param boolean $condition When true the system may create a Lazy condition for the url
@return \MUtil_Html_HrefArrayAttribute | entailment |
protected function _toNavigationArray(\Gems_Menu_ParameterCollector $source)
{
$result = $this->_itemOptions;
if ($result['visible']) {
$parameters = array();
if ($this->_applyParameterSources($source, $parameters, true)) {
$result['params'] = $parameters;
... | Returns a \Zend_Navigation creation array for this menu item, with
sub menu items in 'pages'
@param \Gems_Menu_ParameterCollector $source
@return array | entailment |
public function addAction($label, $privilege = null, $action = 'index', array $other = array())
{
$other['label'] = $label;
$other['controller'] = $this->get('controller');
$other['action'] = $action;
if (null === $privilege) {
$privilege = $this->get('privilege... | Add an action to the current subMenuItem
@param string $label The label to display for the menu item
@param string $privilege The privilege for the item
@param string $action The name of the action
@param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class',... | entailment |
public function addActionButton($label, $privilege = null, $action = 'index', array $other = array())
{
$other['button_only'] = true;
return $this->addAction($label, $privilege, $action, $other);
} | Add a button only action to the current subMenuItem
@param string $label The label to display for the menu item
@param string $privilege The privilege for the item
@param string $action The name of the action
@param array $other Array of extra options for this item, e.g. 'visible', 'allowed... | entailment |
public function addCreateAction($privilege = null, array $other = array())
{
if (isset($other['label'])) {
$label = $other['label'];
unset($other['label']);
} else {
$label = $this->_('New');
}
if (null === $privilege) {
$privilege = $... | Add an "Create new" action to the current subMenuItem
@param string $privilege The privilege for the item, defaults to parent + .create when not specified
@param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only'
@return \Gems_Menu_SubMen... | entailment |
public function addDeReactivateAction($checkField, $deactivateOn = 1, $reactivateOn = 1, array $otherDeact = array(), array $otherReact = array())
{
$pages = array();
if (null !== $deactivateOn) {
if (isset($otherDeact['privilege'])) {
$privilege = $otherDeact['privilege... | Add a standard deactivate action and optional reactivate action to the current menu item
@param string $checkField The name of the field to filter on for deactivation
@param string $deactivateOn The value to check against for deactivation, no menu item when null
@param string $reactivateOn The value to check against... | entailment |
public function addEditAction($privilege = null, array $other = array())
{
if (isset($other['label'])) {
$label = $other['label'];
unset($other['label']);
} else {
$label = $this->_('Edit');
}
if (null === $privilege) {
$privilege = $t... | Add a standard edit action to the current menu item
@param string $privilege A privilege name, defaults to parent + .edit when not specified
@param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only'
@return \Gems_Menu_SubmenuItem | entailment |
public function addExcelAction()
{
$options = array(
'class' => 'excel',
//'rel' => 'external',
'target' => null,
'title' => $this->_('Export the current data set to Excel'),
//'type' => 'application/vnd.ms-excel',
);
return... | Add a standard edit action to the current menu item
@deprecated Since 1.8.1
@return \Gems_Menu_SubmenuItem | entailment |
public function addExportAction()
{
$options = array(
'class' => 'model-export',
'target' => null,
'title' => $this->_('Export the current data set'),
);
return $this->addActionButton($this->_('Export'), $this->get('privilege') . '.export', 'export', $o... | Add a standard edit action to the current menu item
@return \Gems_Menu_SubmenuItem | entailment |
public function addHiddenParameter($name, $value = null)
{
if (null === $value) {
unset($this->_hiddenParameters[$name]);
} else {
$this->_hiddenParameters[$name] = $value;
}
return $this;
} | Add parameter values that should not show in the url but that
must be added to the request when this menu item is current.
@see applyHiddenParameters
@param string $name Name of parameter
@param mixed $value
@return \Gems_Menu_SubMenuItem (continuation pattern | entailment |
public function addImportAction($privilege = null, array $other = array())
{
if (isset($other['label'])) {
$label = $other['label'];
unset($other['label']);
} else {
$label = $this->_('Import');
}
if (null === $privilege) {
$privilege ... | Add a standard import action to the current menu item
@param string $privilege A privilege name, defaults to parent + .import when not specified
@param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only'
@return \Gems_Menu_SubmenuItem | entailment |
public function addNamedParameters($arrayOrKey1 = null, $altName1 = null)
{
$params = \MUtil_Ra::pairs(func_get_args());
foreach ($params as $param => $name) {
if (is_int($param)) {
$param = $name;
}
$this->_requiredParameters[$param] = $name;
... | Add required parameters - shown in the url - for this
menu item.
Numeric array keys are changed into the same string as the
array value.
@param mixed $arrayOrKey1 \MUtil_Ra::pairs named array
@param mixed $key2
@return \Gems_Menu_SubMenuItem (continuation pattern) | entailment |
public function addShowAction($privilege = null, array $other = array())
{
if (isset($other['label'])) {
$label = $other['label'];
unset($other['label']);
} else {
$label = $this->_('Show');
}
$menu = $this->addAction($label, $privilege, 'show', $... | Add a standard show action to the current menu item
@param string $privilege A privilege name, defaults to parent + .show when not specified
@param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only'
@return \Gems_Menu_SubmenuItem | entailment |
public function checkParameterFilter($arrayOrKey1, $value1 = null)
{
$checks = \MUtil_Ra::pairs(func_get_args());
foreach($checks as $name => $value) {
// \MUtil_Echo::track($name, $value, $this->_parameterFilter[$name]);
if (null === $value) {
if (isset($th... | Check if a menu item contains these parameter settings
@param mixed $arrayOrKey1 \MUtil_Ra:pairs() name => value argument pairs
@param mixed $value1 The value should be identical or when null, should not exist or be null
@return boolean True if all values where set | entailment |
public function setModelParameters($idCount)
{
$params = array();
if (1 == $idCount) {
$params[\MUtil_Model::REQUEST_ID] = \MUtil_Model::REQUEST_ID;
} else {
for ($idx = 1; $idx <= $idCount; $idx++) {
$params[\MUtil_Model::REQUEST_ID . $idx] = \MUtil_M... | Defines the number of named parameters using the model naming
convention: id=x or id1=x id2=y
@see setNamedParamenters()
@param int $idCount The number of parameters to define
@return \Gems_Menu_SubMenuItem (continuation pattern) | entailment |
public function setNamedParameters($arrayOrKey1 = null, $key2 = null)
{
$params = \MUtil_Ra::pairs(func_get_args());
$this->removeParameters();
$this->addNamedParameters($params);
return $this;
} | Set the required parameters - shown in the url - for this
menu item.
Numeric array keys are changed into the same string as the
array value.
@param mixed $arrayOrKey1 \MUtil_Ra::pairs named array
@param mixed $key2
@return \Gems_Menu_SubMenuItem (continuation pattern) | entailment |
protected function addModelSettings(array &$settings)
{
$empty = [];
if (!$this->_fieldDefinition['gtf_required'] || $this->_fieldDefinition['gtf_field_default'] === null) {
$empty = $this->util->getTranslated()->getEmptyDropdownArray();
}
$multi = explode(parent::FIELD_... | 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 execute($lineNr = null, $roundData = null)
{
$batch = $this->getBatch();
$events = $this->loader->getEvents();
$import = $batch->getVariable('import');
if (isset($roundData['gro_id_order']) && $roundData['gro_id_order']) {
$import['roundOrder'][$roundDat... | 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 writeRespondent(\Gems_Communication_RespondentContainer $respondent, &$userId)
{
$parameters = $this->_model->applyParameters(
array(
'grs_ssn' => $respondent->getBsn(),
'gr2o_reception_code' => \GemsEscort::RECEPTION_OK,
'gr2o_pati... | - Fetches respondent based on bsn / reception code and patient nr
- Creates the respondent if it does not exist, updates otherwise
@see \Gems_Model_RespondentModel
@see \Gems_Communication_RespondentWriter::writeRespondent()
@param \Gems_Communication_RespondentContainer $respondent
@param int $userId
@return boole... | entailment |
public function itemToString(\stdClass $item)
{
$attributes = (array) $item;
if (isset($attributes['type']) &&
(($attributes['type'] == 'text/css') || ($attributes['type'] == 'text/less'))) {
// This is a stylesheet, consider extension and compile .less to .css
... | Create HTML link element from data item
@param \stdClass $item
@return string | entailment |
public function calcultateName($value, $isNew = false, $name = null, array $context = array())
{
$fields = $this->agenda->getFieldLabels();
$output = array();
if (isset($context['gaf_filter_text1'], $fields[$context['gaf_filter_text1']], $context['gaf_filter_text2']) &&
$con... | 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 getFieldLabels()
{
$output = array(
'gap_id_organization' => $this->_('Organization'),
'gap_source' => $this->_('Source of appointment'),
'gap_id_attended_by' => $this->_('With'),
'gap_id_referred_by' => $this->_('Referrer'),
... | Get the field names in appontments with their labels as the value
@return array fieldname => label | entailment |
public function getTextSettings()
{
$fields = $this->agenda->getFieldLabels();
$description = sprintf($this->_(
"Use the %%-sign to search for zero or more random characters and an _ for a single random character."
));
return array(
'gaf_filter_te... | 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 |
public function processChangedRespondent(\Gems_Tracker_Respondent $respondent)
{
$changes = 0;
$tracker = $this->loader->getTracker();
$respTracks = $tracker->getRespondentTracks($respondent->getId(), $respondent->getOrganizationId());
$userId = $this->currentUser->getUserI... | Process the respondent and return true when data has changed.
The event has to handle the actual storage of the changes.
@param \Gems_Tracker_Respondent $respondent
@param int $userId The current user
@return boolean True when something changed | entailment |
public function addPrefixPath($prefix, $path, $prepend = true)
{
if ($prepend) {
$this->_dirs = array($prefix => $path) + $this->_dirs;
} else {
$this->_dirs[$prefix] = $path;
}
if ($this->_loader instanceof Zalt\Loader\ProjectOverloader) {
$this-... | Add prefixed paths to the registry of paths
@param string $prefix
@param string $path
@param boolean $prepend
@return \MUtil_Snippets_SnippetLoaderInterface | entailment |
public function getSnippet($filename, array $extraSourceParameters = null)
{
try {
$this->addRegistryContainer($extraSourceParameters, 'tmpContainer');
$snippet = $this->_loadClass($filename, true);
$this->removeRegistryContainer('tmpContainer');
if (self::$ve... | Searches and loads a .php snippet file.
@param string $filename The name of the snippet
@param array $extraSourceParameters name/value pairs to add to the source for this snippet
@return \MUtil_Snippets_SnippetInterface The snippet | entailment |
public function removePrefixPath($prefix, $path = null)
{
$this->_loader->removePrefixPath($prefix, $path);
return $this;
} | Remove a prefix (or prefixed-path) from the registry
@param string $prefix
@param string $path OPTIONAL
@return \MUtil_Snippets_SnippetLoaderInterface | entailment |
private function _enableAutoSubmitElement($element)
{
if ($element instanceof \Zend_Form || $element instanceof \Zend_Form_DisplayGroup) {
foreach ($element->getElements() as $sub) {
$this->_enableAutoSubmitElement($sub);
}
} elseif ($element instanceof ... | Change all elements into an autosubmit element
Call only when $_autoSubmit is set
@param mixed $element | entailment |
public function activateJQuery()
{
if ($this->_no_jquery) {
parent::activateJQuery();
$this->addPrefixPath('Gems_JQuery_Form_Decorator', 'Gems/JQuery/Form/Decorator/', \Zend_Form::DECORATOR);
$this->addPrefixPath('Gems_JQuery_Form_Element', 'Gems/JQuery/Form/Elemen... | Activate JQuery for this form
@return \MUtil_Form (continuation pattern) | entailment |
public function addElement($element, $name = null, $options = null)
{
parent::addElement($element, $name, $options);
if ($this->isAutoSubmit()) {
if (null !== $name) {
$element = $this->getElement($name);
}
$this->_enableAutoSubmitElement(... | Add a new element
$element may be either a string element type, or an object of type
\Zend_Form_Element. If a string element type is provided, $name must be
provided, and $options may be optionally provided for configuring the
element.
If a \Zend_Form_Element is provided, $name may be optionally provided,
and any pro... | entailment |
public function setAutoSubmit($submitUrl, $targetId, $selective = false)
{
// Filter out elements passed by type
$args = \MUtil_Ra::args(func_get_args(),
array(
'submitUrl' => array('MUtil_Html_UrlArrayAttribute', 'is_array', 'is_string'),
'targetId'... | Change the form into an autosubmit form
@param mixed $submitUrl Url as \MUtil_Html_UrlArrayAttribute, array or string
@param mixed $targetId Id of html element whose content is replaced by the submit result: \MUtil_Html_ElementInterface or string
@param boolean $selective When true autosubmit is applied only to elemen... | entailment |
public function getRedirectRoute()
{
// Clean up
$this->loginStatusTracker->destroySession();
return [
$this->request->getControllerKey() => null,
$this->request->getActionKey() => null,
];
} | When hasHtmlOutput() is false a snippet code user should check
for a redirectRoute. Otherwise the redirect calling render() will
execute the redirect.
This function should never return a value when the snippet does
not redirect.
Also when hasHtmlOutput() is true this function should not be
called.
@see \Zend_Control... | entailment |
protected function addBrowseColumn3(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
if ($model->hasAlias('gems__respondent2track')) {
parent::addBrowseColumn3($bridge, $model);
}
} | Add first columns (group) from the model to the bridge that creates the browse table.
You can actually add more than one column in this function, but just call all four functions
with the default columns in each
Overrule this function to add different columns to the browse table, without
having to recode the core tab... | entailment |
public function addSeparator($token)
{
$this->row->addGenerator($this->generator);
$this->generator = $this->documentGenerator->getInlineGenerator($this->generatorName);
$this->wikiContent .= $this->wikiContentArr[$this->separatorCount];
++$this->separatorCount;
$this->curre... | called by the inline parser, when it found a separator.
@param string $token | entailment |
public function createModel($detailed, $action)
{
$model = parent::createModel($detailed, $action);
$model->set('grs_birthday', 'label', $this->_('Birthday'));
$model->set('grs_city', 'label', $this->_('City'));
$model->addColumn("CONCAT(gr2t_completed, '" . $this->_(' of ')... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
protected function _filterData($data, array $filters)
{
$limit = false;
if (isset($filters['limit'])) {
$limit = $filters['limit'];
unset($filters['limit']);
}
$filteredData = parent::_filterData($data, $filters);
if ($limit) {
if (is_arr... | Filters the data array using a model filter
@param \Traversable $data
@param array $filters
@return \Traversable | entailment |
public function getItemCount($filter = true, $sort = true)
{
$data = $this->_loadAllTraversable();
if ($filter) {
$data = $this->_filterData($data, $filter);
}
return count($data);
} | Calculates the total number of items in a model result with certain filters
@param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters
@param array $sort Sort array field name => sort type
@return integer number of total items in model result
@throws Zend_Db_Select_Exce... | entailment |
protected function _addDefaultFieldsToExportModel(\MUtil_Model_ModelAbstract $model, array $data, array &$prefixes)
{
if (!$model->checkJoinExists('gems__respondent2org.gr2o_id_user', 'gems__tokens.gto_id_respondent')) {
$model->addTable('gems__respondent2org', array(
'gems__resp... | Add the default fields and optionally joins to the model
@param MUtil_Model_ModelAbstract $model
@param array $data
@param array $prefixes | entailment |
protected function _addExtraDataToExportModel(\MUtil_Model_ModelAbstract $model, array $data, array &$prefixes)
{
$this->_addExtraTrackFields($model, $data, $prefixes); // Create the first 'P' fields after this
$this->_addExtraRespondentNumber($model, $data, $prefixes);
$this->_addExtra... | Extensible function for added project specific data extensions
@param \MUtil_Model_ModelAbstract $model
@param array $data
@param array $prefixes | entailment |
protected function _addNestedFieldsToExportModel(\MUtil_Model_ModelAbstract $model, array $data, array &$prefixes)
{
// Set labels in the main model for the submodel fields
if ($model->getMeta('nested', false)) {
$nestedNames = $model->getMeta('nestedNames');
foreach($nestedN... | Add nested model fields to the export model
@param MUtil_Model_ModelAbstract $model
@param array $data
@param array $prefixes | entailment |
protected function _addSurveyAnswersToExportModel(\MUtil_Model_ModelAbstract $model, \Gems_Tracker_Survey $survey, array $data, array &$prefixes)
{
$prefixes['A'] = [];
$language = $this->locale->getLanguage();
$questions = $survey->getQuestionList($language);
$questionInformation = ... | Add all survey answers to the export model
@param MUtil_Model_ModelAbstract $model
@param Gems_Tracker_Survey $survey
@param array $data
@param array $prefixes | entailment |
protected function _addSurveySourceAttributesToExportModel(\MUtil_Model_ModelAbstract $model, \Gems_Tracker_Survey $survey, array $data, array &$prefixes)
{
$source = $survey->getSource();
$attributes = $source->getAttributes();
$preExistingFields = $model->getColNames('label');
$att... | Add the survey source attributes to the export model that have not yet been set.
@param MUtil_Model_ModelAbstract $model
@param Gems_Tracker_Survey $survey
@param array $data
@param array $prefixes
@throws Gems_Exception | entailment |
public function getExtraDataFormElements(\Gems_Form $form, $data)
{
$this->form = $form;
$elements = [];
if (isset($data['gto_id_track']) && $data['gto_id_track']) {
$elements['add_track_fields'] = $this->_createCheckboxElement(
'add_track_fields',
... | Get form elements for the specific Export
@param \Gems_Form $form existing form type
@param array data existing options set in the form
@return array of form elements | entailment |
public function getModel($filter = array(), $data = array())
{
if ($filter !== $this->filter || !$this->model) {
$this->filter = $filter;
$surveyId = $filter['gto_id_survey'];
$language = $this->locale->getLanguage();
$survey = $this->loader->getTracker()->getSurve... | Get the model to export
@param array $filter Filter for the model
@param array $data Data from the form options
@return \MUtil_Model_ModelAbstract | entailment |
public function subscribeAction()
{
$orgId = urldecode($this->getRequest()->getParam('org'));
if ($orgId && ($orgId != $this->currentUser->getCurrentOrganizationId())) {
$allowedOrganizations = $this->currentUser->getAllowedOrganizations();
if ((! $this->currentUser->isActiv... | Ask the user which organization to participate with
@return void | entailment |
public function unsubscribeAction()
{
$orgId = urldecode($this->getRequest()->getParam('org'));
if ($orgId && ($orgId != $this->currentUser->getCurrentOrganizationId())) {
$allowedOrganizations = $this->currentUser->getAllowedOrganizations();
if ((! $this->currentUser->isAct... | Ask the user which organization to unsubscribe from
@return void | entailment |
public function unsubscribeToOrgAction()
{
$request = $this->getRequest();
$orgId = urldecode($request->getParam('org'));
$allowedOrganizations = $this->currentUser->getAllowedOrganizations();
if ((! $this->currentUser->isActive()) || isset($allowedOrganizations[$orgId])) {
... | Ask the user which organization to participate with
@return void | entailment |
public function removesessionAction()
{
$success = false;
$request = $this->getEvent()->getRequest();
if ($request instanceof Request && $request->isPost()) {
$containerName = $request->getPost('containerName', 'Default');
$keysession = $request->getPost('keysession',... | Remove Session by Container and its key. | entailment |
public function reloadsessionAction()
{
$sessionData = $this->sessionManager->getSessionData(false);
$renderedContent = $this->viewRenderer
->render('zend-developer-tools/toolbar/session-data-list', ['sessionData' => $sessionData]);
return new JsonModel([
... | Reload Session data. | entailment |
public function clearsessionAction()
{
$request = $this->getEvent()->getRequest();
if ($request instanceof Request && $request->isPost()) {
$this->sessionManager->clearSession($request->getPost('byContainer'));
}
$sessionData = $this->sessionManager->getSessionData();
... | Clear Session data. | entailment |
public function savesessionAction()
{
$processSetOrAddSessionData = ['success' => false, 'errorMessage' => ''];
$request = $this->getEvent()->getRequest();
if ($request instanceof Request && $request->isPost()) {
$processSetOrAddSessionData = $this->setOrAddSession($request);
... | Save Session by Container and its key. | entailment |
private function setOrAddSession(Request $request)
{
$containerName = $request->getPost('containerName', 'Default');
$keysession = $request->getPost('keysession', '');
$sessionValue = $request->getPost('sessionvalue', '');
$new = (bool) $request->getPost('new', false);
$notE... | Set or Add Session Data Process.
@param Request $request
@return array | entailment |
public function calculateFieldValue($currentValue, array $fieldData, array $trackData)
{
if (null === $currentValue && isset($this->_fieldDefinition['gtf_field_default'])) {
return $this->_fieldDefinition['gtf_field_default'];
}
return $currentValue;
} | Calculate the field value using the current values
@param array $currentValue The current value
@param array $fieldData The other known field values
@param array $trackData The currently available track data (track id may be empty)
@return mixed the new value | entailment |
public function getCalculationFields(array $fieldData)
{
$output = array();
// Perform automatic calculation
if (isset($this->_fieldDefinition['gtf_calculate_using'])) {
$sources = explode(self::FIELD_SEP, $this->_fieldDefinition['gtf_calculate_using']);
foreach ($s... | Get the fields that should be used for calculation,
first field to use first.
I.e. the last selected field in field maintenance
is the first field in the output array.
@param array $fieldData The fields being saved
@return array [fieldKey => fieldValue] | entailment |
protected function _getSelectForm()
{
$form = new \Gems_Form(array('name' => 'autosubmit', 'class' => 'form-inline', 'role' => 'form'));
$form->setHtml('div');
$div = $form->getHtml();
$div->class = 'search';
$span = $div->div(array('class' => 'panel panel-default'))->div(a... | The form for selecting the patch level
@return \Gems_Form | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
if (! $this->patchLevels) {
$this->addMessage($this->_('This new project has no structural changes to show.'));
return;
}
$patchLevel = $this->getPatchLevel();
$seq = $this->getHtmlSequence();
... | 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 getStructuralPatches($patchLevel)
{
$patches = $this->db->fetchAll(
"SELECT * FROM gems__patches WHERE gpa_level = ? ORDER BY gpa_location, gpa_name, gpa_order",
$patchLevel
);
foreach ($patches as $patchId => $patch) {
if ... | Get the structural patches for the given patch level
@param int $patchLevel
@return array | entailment |
public function getTextOutput()
{
$patchLevel = $this->getPatchLevel();
$commands = array(sprintf('-- Patch level %d structural changes', $patchLevel));
$lastLocation = '';
$lastName = '';
$noOutput = true;
foreach ($this->getStructuralPatches($patchLevel... | Get the content as text
@return \MUtil_Html_HtmlInterface Something that can be rendered | entailment |
protected function getPatchLevel()
{
if (isset($this->searchData['gpa_level']) && $this->searchData['gpa_level']) {
return $this->searchData['gpa_level'];
}
return reset($this->patchLevels);
} | Current patch level
@return int | entailment |
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('Tabs', $this->_decoratorOptions)
->addDecorator('... | Load default decorators
@return void | entailment |
protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
{
if (! $this->createData) {
$bridge->addHidden('gtr_id_track');
}
$bridge->addText('gtr_track_name');
// gtr_track_class
if ($this->trackEngine... | Adds elements from the model to the bridge that creates the form.
Overrule this function to add different elements to the browse table, without
having to recode the core table building code.
@param \MUtil_Model_Bridge_FormBridgeInterface $bridge
@param \MUtil_Model_ModelAbstract $model | entailment |
protected function createModel()
{
$model = $this->loader->getTracker()->getTrackModel();
$model->applyFormatting(true, true);
return $model;
} | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
public function hasHtmlOutput()
{
if ($this->trackEngine && (! $this->trackId)) {
$this->trackId = $this->trackEngine->getTrackId();
}
if ($this->trackId) {
// We are updating
$this->createData = false;
// Try to get $this->trackEngine filled... | 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();
// feature request #200
if (isset($this->formData['gtr_organizations']) && (! is_array($this->formData['gtr_organizations']))) {
$this->formData['gtr_organizations'] = explode('|', trim($this->formData['gtr_organization... | Hook that loads the form data from $_POST or the model
Or from whatever other source you specify here. | entailment |
protected function saveData()
{
// feature request #200
if (isset($this->formData['gtr_organizations']) && is_array($this->formData['gtr_organizations'])) {
$this->formData['gtr_organizations'] = '|' . implode('|', $this->formData['gtr_organizations']) . '|';
}
if ($this-... | Hook containing the actual save code.
Call's afterSave() for user interaction.
@see afterSave() | entailment |
public function execute($tokenData = null, $userId = null)
{
$batch = $this->getBatch();
$tracker = $this->loader->getTracker();
$token = $tracker->getToken($tokenData);
if ($token->isCompleted()) {
$respTrack = $token->getRespondentTrack();
$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 getAnswerDisplaySnippets(\Gems_Tracker_Token $token)
{
$this->token = $token;
$snippets = (array) $token->getTrackEngine()->getAnswerSnippetNames();
$snippets['answerFilter'] = $this;
return $snippets;
} | Function that returns the snippets to use for this display.
@param \Gems_Tracker_Token $token The token to get the snippets for
@return array of Snippet names or nothing | entailment |
protected function getHeaders(\MUtil_Model_ModelAbstract $model, array $currentNames)
{
$lastParent = null;
$results = array();
foreach ($currentNames as $name) {
if ($model->is($name, 'type', \MUtil_Model::TYPE_NOVALUE)) {
$results[$name] = $name;
... | Returns only the headers
@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 restoreHeaderPositions(\MUtil_Model_ModelAbstract $model, array $currentNames)
{
$lastParent = null;
$results = array();
foreach ($currentNames as $name) {
if ($model->is($name, 'type', \MUtil_Model::TYPE_NOVALUE)) {
// Skip header types that... | Restores the header position of question before their corresponding question_sub
When sub-questions with the same parent are shown continuous the parent is shown
once before them. When the sub-questions are displayed in seperate groups the
parent is shown once at their start.
Stand alone headers without any correspon... | entailment |
protected function getControllerTargetModel($controller)
{
switch ($controller) {
case 'respondent':
$model = $this->loader->getModels()->getRespondentModel(true);
$model->applyEditSettings();
return $model;
case 'calendar':
... | The model to use with a controller
@param string $controller Name of controller (or other id)
@return \MUtil_Model_ModelAbstract or null when not found | entailment |
public function getFilenameController($filename)
{
$filename = strtolower(basename($filename));
if (preg_match('/^respondent/', $filename)) {
return 'respondent';
}
if (preg_match('/^appointment/', $filename)) {
return 'calendar';
}
return fal... | Get the controller that should be linked to the filename
@param string $filename Name of file to import
@return string or false if none found. | entailment |
public function getOrganizationCode()
{
if (! $this->_orgCode) {
$this->_orgCode = $this->currentOrganization->getCode();
if (! $this->_orgCode) {
$this->_orgCode = \MUtil_File::cleanupName($this->currentOrganization->getName());
}
}
retu... | Get the organization name/code used by the long term filename
@return string | entailment |
public function getLongtermFileName($controller, $dateValue = null)
{
if ($dateValue instanceof \Zend_Date) {
$date = $dateValue;
} else {
$date = new \MUtil_Date($dateValue);
}
$name[] = $controller;
$name[] = $date->toString('YYYY-MM-ddTHH-mm-ss');
... | The file name to use for final storage, minus the extension
@param string $controller Name of controller (or other id)
@param mixed $dateValue Optional date item to use in filename, timestamp, or DateObject or MUtil_Date
@return string | entailment |
public function getTranslators($controller, $filename = null)
{
$translator = $this->getTranslateAdapter();
switch ($controller) {
case 'answers':
$output['default'] = new \Gems_Model_Translator_TokenAnswerTranslator(
$translator->_('Link by token... | Get the possible translators for the import snippet.
@param string $controller Name of controller (or other id)
@param string $filename Optional, name of file to import
@return \MUtil_Model_ModelTranslatorInterface[] | entailment |
public static function addWhenChanged($name, $value, array &$results, array $tokenAnswers)
{
if ($value != $tokenAnswers[$name]) {
$results[$name] = $value;
return true;
} else {
return false;
}
} | Adds value to $results when it is different from the value in $tokenAnswers.
@param string $name The name of the values
@param mixed $value The value to compare to
@param array $results The results to add to
@param array $tokenAnswers The answers to compare to
@return boolean True when the value changed. | entailment |
private static function _arrayFindName(array $tokenAnswers, $fieldNames)
{
$results = array();
foreach ($tokenAnswers as $fieldName => $value) {
if (strpos($fieldName, $fieldNames) !== false) {
$results[] = $fieldName;
}
}
// \MUtil_Echo::tra... | Finds those tokenAnswers array keys that contain "fieldNames" in their key.
@param array $tokenAnswers
@param string $fieldNames
@return array | entailment |
public static function averageInt(array $tokenAnswers, $fieldNames)
{
if (is_string($fieldNames)) {
$fieldNames = self::_arrayFindName($tokenAnswers, $fieldNames);
}
$count = 0;
$sum = 0;
foreach ($fieldNames as $name) {
if (isset($tokenAnswers[$nam... | Returns the avarage over those $fieldNames values that exist in $tokenAnswers and are integers.
@param array $tokenAnswers Array containing the answers
@param mixed $fieldNames An array of those names that should be used or a string that should occur in all names that have to be selected.
@return float | entailment |
public static function checkFloatChanged(array $values, array $tokenAnswers)
{
$results = array();
foreach($values as $name => $result) {
if (! ((null === $result) && (null === $tokenAnswers[$name]))) {
$result = round(floatval($result), 13);
if (((string... | Checks all $values for a change against $tokenAnswers as floats
@param array $values
@param array $tokenAnswers
@return array Those values that were changed. | entailment |
public static function checkIntegerChanged(array $values, array $tokenAnswers)
{
$results = array();
foreach($values as $name => $result) {
$result = intval($result);
if (($tokenAnswers[$name] != $result) || ($tokenAnswers[$name] === null)) {
$results[$name] ... | Checks all $values for a change against $tokenAnswers as integer
@param array $values
@param array $tokenAnswers
@return array Those values that were changed. | entailment |
public static function roundFixed($value, $decimals = 2)
{
$value = round($value, $decimals);
$pos = strpos($value, '.');
if ($pos === false) {
$value .= '.' . str_repeat('0', $decimals);
} else {
$extra = $decimals - strlen($value) + $pos + 1;
i... | Rounds the value with a fixed number of decimals, padding
zeros when required.
@param numeric $value
@param int $decimals
@return string | entailment |
public static function sumInt(array $tokenAnswers, $fieldNames)
{
if (is_string($fieldNames)) {
$fieldNames = self::_arrayFindName($tokenAnswers, $fieldNames);
}
$sum = 0;
foreach ($fieldNames as $name) {
if (isset($tokenAnswers[$name]) && (is_int($tokenAnswe... | Returns the sum over those $fieldNames values that exist in $tokenAnswers and are integers
@param array $tokenAnswers Array containing the answers
@param mixed $fieldNames An array of those names that should be used or a string that should occur in all names that have to be selected.
@return int | entailment |
public function getPanel()
{
$this->_request = Zend_Controller_Front::getInstance()->getRequest();
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if ($viewRenderer->view && method_exists($viewRenderer->view, 'getVars')) {
$viewVars = $this->... | Gets content panel for the Debugbar
@return string | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.