sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function createModel($detailed, $action) { $model = $this->loader->getModels()->getStaffModel(false); $model->applyOwnAccountEdit(); return $model; }
Creates a model for getModel(). Called only for each new $action. The parameters allow you to easily adapt the model to the current action. The $detailed parameter was added, because the most common use of action is a split between detailed and summarized actions. @param boolean $detailed True when the current action...
entailment
public function overviewAction() { if ($this->overviewSnippets) { $params = $this->_processParameters($this->overviewParameters); $this->addSnippets($this->overviewSnippets, $params); } }
Show log overview for the current user
entailment
public function showLogAction() { if ($this->showLogSnippets) { $params = $this->_processParameters($this->showLogParameters); $this->addSnippets($this->showLogSnippets, $params); } }
Show a log item
entailment
public function twoFactorAction() { if ($this->twoFactorSnippets) { $params = $this->_processParameters($this->twoFactorParameters); $this->addSnippets($this->twoFactorSnippets, $params); } }
Set two factor authentication
entailment
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model) { $filter[] = $this->db->quoteInto( "gr2t_id_respondent_track IN ( SELECT gr2t2a_id_respondent_track FROM gems__respondent2track2appointment WHERE gr2t2a_id_...
Overrule to implement snippet specific filtering and sorting. @param \MUtil_Model_ModelAbstract $model
entailment
protected function exportFieldData(array $data) { $replacements = array("\n" => '\\n', "\r" => '\\r', "\t" => '\\t'); foreach ($data as &$item) { $item = strtr((string) $item, $replacements); } fwrite($this->_file, implode("\t", $data) . "\r\n"); }
Write the array to the output to file @param array $data
entailment
protected function exportTypeHeader($header, $prependNewline = true) { if ($prependNewline) { fwrite($this->_file, "\r\n"); } fwrite($this->_file, "$header\r\n"); }
Write the export type to the output @param array $data With headers as the keys
entailment
public function setBatch(\MUtil_Task_TaskBatch $batch) { parent::setBatch($batch); $this->_file = $batch->getVariable('file'); return $this; }
Sets the batch this task belongs to This method will be called from the \Gems_Task_TaskRunnerBatch upon execution of the task. It allows the task to communicate with the batch queue. @param \MUtil_Task_TaskBatch $batch @return \MUtil_Task_TaskInterface (continuation pattern)
entailment
protected function translateFieldCode(FieldsDefinition $fields, $fieldId) { $field = $fields->getField($fieldId); if ($field instanceof FieldInterface) { return '{f' . $field->getOrder() . '}'; } return $fieldId; }
Translate a field code to the field order number @param FieldsDefinition $fields @param string $fieldId @return string {order} or original value
entailment
public function isTwoFactorRequired($ipAddress, $hasKey, Group $group = null) { if ($group) { return $group->isTwoFactorRequired($ipAddress, $hasKey); } return false; }
Should this user be authorized using two factor authentication? @param string $ipAddress @param boolean $hasKey @param Group $group @return boolean
entailment
protected function addFormElements(\Zend_Form $form) { // Veld inlognaam $element = $form->createElement('text', 'email'); $element->setLabel($this->_('Your E-Mail address')) ->setAttrib('size', 30) ->setRequired(true) ->addValidator('SimpleEma...
Add the elements to the form @param \Zend_Form $form
entailment
protected function saveData() { $this->addMessage($this->_('Your e-mail address has been unsubscribed')); $sql = "SELECT gr2o_patient_nr, gr2o_id_organization, gr2o_id_user, gr2o_mailable FROM gems__respondent2org WHERE gr2o_email = ? AND gr2o_id_organization = ?"; $row = $this...
Hook containing the actual save code. @return int The number of "row level" items changed
entailment
public function checkRegistryRequestsAnswers() { $escort = \GemsEscort::getInstance(); //As an upgrade almost always includes executing db patches, make a DatabasePatcher object available $this->patcher = new \Gems_Util_DatabasePatcher($this->db, 'patches.sql', $escort->getDatabasePaths(), ...
Now we have the requests answered, add the DatabasePatcher as it needs the db object @return boolean
entailment
public function send(Message $mail): void { if ($this->bounceMail !== null) { // Append this commands cause bounce email $this->commandArgs = sprintf('-f%s', $this->bounceMail); } // Trigger event $this->onSend($this, $mail); // Delegate to original mailer parent::send($mail); }
Sends email
entailment
public function execute($errors = null) { $batch = $this->getBatch(); foreach ((array) $errors as $error) { $batch->addToCounter('import_errors'); $batch->addMessage($error); } }
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 addButtons(\Gems_Menu_MenuList $menuList) { $menuList->addByController('respondent', 'show', $this->_('Show respondent')) ->addByController('track', 'index', $this->_('Show tracks')) ->addByController('track', 'show-track', $this->_('Show track')) ...
Set the menu items (allows for overruling in subclasses) @param \Gems_Menu_MenuList $menuList
entailment
protected function _cleanData($values) { $linebreak = $this->getLinebreak(); if (is_array($values)) { ksort($values); } $retVal = '<div class="pre">'; foreach ($values as $key => $value) { $key = htmlspecialchars($key); if (is_nume...
Transforms data into readable format @param array $values @return string
entailment
public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('FormElements'); if (\MUtil_Bootstrap::enabled() !== true...
Load default decorators @return void
entailment
protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); $elements[] = new \Zend_Form_Element_Hidden(\MUtil_Model::REQUEST_ID1); $elements[] = new \Zend_Form_Element_Hidden(\MUtil_Model::REQUEST_ID2); return $elements; }
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 getFixedParams() { $neededParams = parent::getFixedParams(); $neededParams[] = \MUtil_Model::REQUEST_ID1; $neededParams[] = \MUtil_Model::REQUEST_ID2; return $neededParams; }
Return the fixed parameters Normally these are the hidden parameters like ID @return array
entailment
public function filterAnswers(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model, array $currentNames) { if (! $this->token->isCompleted()) { return $currentNames; } $answers = $this->token->getRawAnswers(); $onTop = array(); // \MUti...
This function is called in addBrowseTableColumns() to filter the names displayed by AnswerModelSnippetGeneric. @see \Gems_Tracker_Snippets_AnswerModelSnippetGeneric @param \MUtil_Model_Bridge_TableBridge $bridge @param \MUtil_Model_ModelAbstract $model @param array $currentNames The current names in use (allows chain...
entailment
public function beforeDisplay() { if ($this->_csrf) { $this->_csrf->initCsrfToken(); } $links = $this->getMenuList(); if (\MUtil_Bootstrap::enabled()) { if ($links) { $element = $this->_form->createElement('html', 'menuLinks'); ...
Perform some actions on the form, right before it is displayed but already populated Here we add the table display to the form. @return \Zend_Form
entailment
protected function addBrowseColumn3(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { if (isset($this->searchFilter['grc_success']) && (! $this->searchFilter['grc_success'])) { $model->set('grc_description', 'label', $this->_('Rejection code')); $bridge->...
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
protected function addBrowseColumn4(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { if ($model->hasAlias('gems__respondent2track')) { $br = \MUtil_Html::create('br'); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('g...
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
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { // make sure search results are highlighted $this->applyTextMarker(); parent::addBrowseTableColumns($bridge, $model); $bridge->getTable()->addColumn(null,$this->_(...
Adds columns from the model to the bridge that creates the browse table. Overrule this function to add different columns to the browse table, without having to recode the core table building code. @param \MUtil_Model_Bridge_TableBridge $bridge @param \MUtil_Model_ModelAbstract $model @return void
entailment
protected function addPaginator(\MUtil_Html_TableElement $table, \Zend_Paginator $paginator) { $table->tfrow()->pagePanel($paginator, $this->request, $this->translate, array('baseUrl' => $this->baseUrl)); }
Add the paginator panel to the table. Only called when $this->browse is true. Overrule this function to define your own method. $param \Zend_Paginator $paginator
entailment
protected function getFileIcons(\MUtil_Model_Bridge_TableBridge $bridge) { $onDelete = new \MUtil_Html_OnClickArrayAttribute(); $onDelete->addConfirm(\MUtil_Lazy::call( 'sprintf', $this->_("Are you sure you want to delete '%s'?"), $bridge->relpath ...
Get the file icons @param \MUtil_Model_Bridge_TableBridge $bridge @return array $icon => $menuItem or array($menuItem, $other)
entailment
protected function addFillerSelect(array &$elements, $data, $elementId = 'fillerfilter') { $elements[] = null; if (isset($data[$this->trackFieldId]) && !empty($data[$this->trackFieldId])) { $trackId = (int) $data[$this->trackFieldId]; } else { $trackId = -1; }...
Add filler select to the elements array @param array $elements @param array $data @param string $elementId
entailment
protected function addOrgSelect(array &$elements, $data, $elementId = 'gto_id_organzation') { $orgs = $this->currentUser->getRespondentOrganizations(); if (count($orgs) > 1) { if ($this->orgIsMultiCheckbox) { $elements[$elementId] = $this->_createMultiCheckBoxElements($e...
Add organization select to the elements array @param array $elements @param array $data @param string $elementId
entailment
protected function addPeriodSelect(array &$elements, $data) { $dates = array( 'gr2t_start_date' => $this->_('Track start'), 'gr2t_end_date' => $this->_('Track end'), 'gto_valid_from' => $this->_('Valid from'), 'gto_valid_until' => $this->_('Valid until'), ...
Add period select to the elements array @param array $elements @param array $data
entailment
protected function addTrackSelect(array &$elements, $data, $elementId = 'gto_id_track') { // Store for use in addFillerSelect $this->trackFieldId = $elementId; $orgs = $this->currentUser->getRespondentOrganizations(); $tracks = $this->util->getTrackData()->getTracksForOrgs...
Add track select to the elements array @param array $elements @param array $data @param string $elementId
entailment
public function getAuthAdapter(\Gems_User_User $user, $password) { $config = $this->project->getLdapSettings(); $adapter = new LdapAdapter(); // \MUtil_Echo::track($config); foreach ($config as $server) { $adapter->setOptions([$server]); if (isset($server['...
Returns an initialized Zend\Authentication\Adapter\AdapterInterface @param \Gems_User_User $user @param string $password @return Zend\Authentication\Adapter\AdapterInterface
entailment
public function checkRegistryRequestsAnswers() { if (isset($this->project->tokens['chars'])) { $this->tokenChars = $this->project->tokens['chars']; } else { throw new \Gems_Exception_Coding('Required project.ini setting "tokens.chars" is missing.'); } if (iss...
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 values are missing.
entailment
public function createToken(array $tokenData, $userId) { $current = new \MUtil_Db_Expr_CurrentTimestamp(); $tokenData['gto_changed'] = $current; $tokenData['gto_changed_by'] = $userId; $tokenData['gto_created'] = $current; $tokenData['gto_created_by'] = $userId; ...
Creates a new token with a new random token Id @param array $tokenData @param int $userId Id of the user who takes the action (for logging) @return string The new token Id
entailment
protected function createTokenId() { $max = strlen($this->tokenChars) - 1; $len = strlen($this->tokenFormat); do { $out = ''; for ($i = 0; $i < $len; $i++) { if ('\\' == $this->tokenFormat[$i]) { $i++; $out .= $...
Generates a random token and checks for uniqueness @return string A non-existing token
entailment
public function filter($token) { // Apply replacements if ($this->tokenFrom) { $token = strtr($token, $this->tokenFrom, $this->tokenTo); } // If not case sensitive, convert to lowercase if (! $this->tokenCaseSensitive) { $token = strtolower($t...
Removes all unacceptable characters from the input token and inserts any fixed characters left out @param string $token @return string Reformatted token
entailment
public function hasHtmlOutput() { $model = $this->getModel(); $data = $model->loadFirst(); $roles = $this->currentUser->getAllowedRoles(); //\MUtil_Echo::track($data); // Perform access check here, before anything has happened!!! if (isset($data['ggp_role']) && (! ...
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 afterLoad() { if ($this->_data && $this->db instanceof \Zend_Db_Adapter_Abstract && !($this->_activities || $this->_procedures)) { if ($this->_data['gaf_filter_text1']) { $sqlActivites = "SELECT gaa_id_activity, gaa_id_ac...
Override this function when you need to perform any actions when the data is loaded. Test for the availability of variables as these objects can be loaded data first after deserialization or registry variables first after normal instantiation. That is why this function called both at the end of afterRegistry() and af...
entailment
public function getSqlAppointmentsWhere() { if ($this->_activities && ($this->_activities !== true)) { $where = 'gap_id_activity IN (' . implode(', ', $this->_activities) . ')'; if ($this->_procedures !== true) { $where .= ' AND '; } } els...
Generate a where statement to filter the appointment model @return string
entailment
public function matchAppointment(\Gems_Agenda_Appointment $appointment) { if (true !== $this->_activities) { if (! isset($this->_activities[$appointment->getActivityId()])) { return false; } } return isset($this->_procedures[$appointment->getPro...
Check a filter for a match @param \Gems\Agenda\Gems_Agenda_Appointment $appointment @return boolean
entailment
public function listClasses($classType, $paths, $nameMethod = 'getName') { $results = array(); foreach ($paths as $prefix => $path) { $parts = explode('_', $prefix, 2); if ($name = reset($parts)) { $name = ' (' . $name . ')'; } ...
Returns a list of selectable classes with an empty element as the first option. @param string $classType The class or interface that must me implemented @param array $paths Array of prefix => path to search @param string $nameMEthod The method to call to get the name of the class @return [] array of classname => name
entailment
public function hasHtmlOutput() { return ($this->respondent instanceof \Gems_Tracker_Respondent) && $this->respondent->exists && (! ($this->multiTracks || ($this->respondentTrack instanceof \Gems_Tracker_RespondentTrack))); }
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 setAfterSaveRoute() { // Default is just go to the index if ($this->routeAction && ($this->request->getActionName() !== $this->routeAction)) { $this->afterSaveRouteUrl = array( $this->request->getControllerKey() => 'track', $this->reques...
Set what to do when the form is 'finished'. @return \MUtil_Snippets_ModelFormSnippetAbstract (continuation pattern)
entailment
protected function addStepElementsFor(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model, $step) { $this->displayHeader($bridge, $this->_('Survey replace'), 'h1'); // If we don't copy answers, we skip step 2 if ($this->formData['copy_answers'] == 0 && $step > 1) ...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model @param int $step The current step
entailment
protected function addStepElementsForStep1(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $model->set('source_survey', 'elementClass', 'Select'); $this->addItems($bridge, 'source_survey', 'target_survey'); $this->addItems($bridge, 'track_replace', 'token_up...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepElementsForStep2(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $element = $bridge->getForm()->createElement('html', 'table'); $bridge->addElement($element); $table = $element->table(['class' => 'browser table']); $header...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepElementsForStep3(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { //$this->_form->append($this->getSurveyCompareTable()); //$this->addItems($bridge, 'target_survey', 'source_survey'); $element = $bridge->getForm()->createElement('htm...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepElementsForStep4(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { // Things go really wrong (at the session level) if we run this code // while the finish button was pressed if ($this->isFinishedClicked()) { return; ...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
public function addSurveyCompareForm($tableBody, $post) { if ($this->sourceSurveyId && $this->targetSurveyId) { $sourceSurveyData = $this->getSurveyData($this->sourceSurveyId); $targetSurveyData = $this->getSurveyData($this->targetSurveyId); $surveyCompare = $this->getSurv...
Adds the survey compare form to the current table, showing the matches between different surveys @param $tableBody \MUtil_Html Table object @param $post array List of Post data
entailment
public function calculateTrackUsage($surveyId) { $select = $this->db->select(); $select->from('gems__tracks', array('gtr_track_name')); $select->joinLeft('gems__rounds', 'gro_id_track = gtr_id_track', array('useCnt' => 'COUNT(*)')) ->where('gro_id_survey = ?', $surveyId) ...
Gets how many times a survey is used in tracks @param $surveyId int Gems Survey ID @return array|\MUtil_Html_Sequence translated string with track usage
entailment
protected function getCategorizedResults($post, $sourceSurveyData, $targetSurveyData) { $surveyCompare = $this->getSurveyCompare($sourceSurveyData, $targetSurveyData, $post); $categorizedResults = []; foreach (array_keys($this->questionStatusClasses) as $status) { $categorizedResult...
Function to get Survey compare results sorted by status @param $post Post request data @param $sourceSurveyData array with source survey data @param $targetSurveyData array with target survey data @return array compare results sorted by status
entailment
public function getComments() { $comments = false; $table = \MUtil_Html::create()->table(['class' => 'browser table', 'style' => 'width: auto']); $targetSurveyAnswers = $this->getNumberOfAnswers($this->targetSurveyId); if ($targetSurveyAnswers > 0) { $comments = true; ...
Creates a table with warnings about the survey answer transfer @return bool|\MUtil_Html Table with information
entailment
protected function getCompareResultSummary($post, $sourceSurveyData, $targetSurveyData) { $categorizedResults = $this->getCategorizedResults($post, $sourceSurveyData, $targetSurveyData); $table = \MUtil_Html::create()->table(['class' => 'browser table', 'style' => 'width: auto']); ...
Creates a table with comparison summary @param $post array List of post values @param $sourceSurveyData array list of survey structure @param $targetSurveyData @return mixed
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { $form = parent::getHtmlOutput($view); $html = \MUtil_Html::create()->div(['id' => 'survey-compare']); $html->append($form); return $html; }
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 getNumberOfAnswers($surveyId) { $fields['tokenCount'] = 'COUNT(DISTINCT gto_id_token)'; $select = $this->loader->getTracker()->getTokenSelect($fields)->andReceptionCodes([]); $select->forSurveyId($surveyId) ->onlySucces() ->onlyComple...
Gets the number of answers in a survey @param $surveyId int Gems Survey ID @return string translated string with number of answers
entailment
public function getSourceSurveyId($surveyId) { $tracker = $this->loader->getTracker(); $survey = $tracker->getSurvey($surveyId); return $survey->getSourceSurveyId(); }
Get the survey ID in the survey source @param $surveyId int Gems survey ID @return int source survey ID
entailment
public function getSurveyCompare($sourceSurveyData, $targetSurveyData, $post) { $surveyCompareArray = []; $missingSourceSurveyTitles = $sourceSurveyData; // show all questions that can be send to the target survey foreach ($targetSurveyData as $questionCode => $questionData) { ...
create an array with statusses of survey questions and how they're matched in the form @param $sourceSurveyData array with source survey data @param $targetSurveyData array with target survey data @param $post array List of POST data @return array status array
entailment
public function getSurveyCompareTable($bridge) { $post = $this->formData; $element = $bridge->getForm()->createElement('html', 'table'); $table = $element->table(['class' => 'browser table']); $bridge->addElement($element); $headers = [ $this->_('Question code'),...
Get the complete comparison table @return \MUtil_Html Form nodes
entailment
public function getSurveyData($surveyId) { $tracker = $this->loader->getTracker(); $survey = $tracker->getSurvey($surveyId); $surveyInfo = $survey->getQuestionInformation($this->locale); $filteredSurveyInfo = $surveyInfo; foreach ($surveyInfo as $questionCode => $questionInfo)...
Gets question information about the survey structure from a specific survey and makes the result readable @param $surveyId int ID of the survey @return array List of survey information
entailment
public function getSurveyName($surveyId) { $tracker = $this->loader->getTracker(); $survey = $tracker->getSurvey($surveyId); return $survey->getName(); }
Get Survey name from Id @param $surveyId @return string Survey name
entailment
public function getSurveyQuestionSelect($surveyData, $currentQuestionCode, $targetQuestionCode) { $name = 'target[' . $targetQuestionCode . ']'; if ($targetQuestionCode === null) { $name = 'notfound[]'; } $select = \MUtil_Html::create()->select(['name' => $name]); $s...
Get the form select with all the questions in the survey and the current selected one @param $surveyData array List of survey data @param $currentQuestionCode string Current selected question code @param $targetQuestionCode string the target question code used in the name field of the select @return \MUtil_Html Select...
entailment
public function getSurveyResults($post) { $comments = $this->getComments(); $table = \MUtil_Html::create()->table(['class' => 'browser table']); $header = $table->thead()->tr(); $header->th($this->_('Source Survey')); $header->th($this->_('Target Survey')); $header = $...
Creates a table showing the results of the survey compare @param $post array List of POST data @return \MUtil_Html Table
entailment
public function getSurveySelect($name, $post) { $surveys = $this->surveys; $select = \MUtil_Html::create()->select(['name' => $name]); $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $select->option(reset($empty), ['value' => '']); return $select; }
Create a select element node with all available surveys @param $name string name of the survey select @return mixed \MUtil_Html node
entailment
public function getSurveyStatistics($surveyId) { $seq = new \MUtil_Html_Sequence(); $seq->setGlue(\MUtil_Html::create('br')); $seq[] = $this->getNumberOfAnswers($surveyId); $seq[] = $this->calculateTrackUsage($surveyId); return $seq; }
Creates a small html block of number of answers and usage in tracks of surveys @param $surveyId int id of the survey @return \MUtil_Html_Sequence
entailment
public function getSurveys() { if (!$this->surveys) { $dbLookup = $this->util->getDbLookup(); $this->surveys = $dbLookup->getSurveysWithSid(); } return $this->surveys; }
Get all available surveys @return array Survey Id => Survey name of available surveys
entailment
protected function loadFormData() { if ($this->request->isPost()) { $this->formData = $this->request->getPost() + $this->formData; } else { foreach ($this->model->getColNames('default') as $name) { if (!(isset($this->formData[$name]) && $this->formData[$name])) { ...
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
protected function createModel() { if (! $this->model instanceof LogModel) { $this->model = $this->loader->getModels()->createLogModel(); $this->model->applyBrowseSettings(); } return $this->model; }
Creates the model @return \MUtil_Model_ModelAbstract
entailment
protected function loadFormData() { parent::loadFormData(); if (isset($this->formData['gor_id_organization']) && $this->formData['gor_id_organization']) { $model = $this->getModel(); // Strip self from list of organizations $multiOptions = $model->get('gor_acces...
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
public function createModel($detailed, $action) { $rcLib = $this->util->getReceptionCodeLibrary(); $yesNo = $this->util->getTranslated()->getYesNo(); $model = new \MUtil_Model_TableModel('gems__reception_codes'); $model->copyKeys(); // The user can edit the keys. ...
Creates a model for getModel(). Called only for each new $action. The parameters allow you to easily adapt the model to the current action. The $detailed parameter was added, because the most common use of action is a split between detailed and summarized actions. @param boolean $detailed True when the current action...
entailment
protected function createModel() { $model = parent::createModel(); foreach ($model->getItemNames() as $name) { if (! $model->has($name, 'label')) { $model->set($name, 'label', ' '); } } return $model; }
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function bbToHtml($bbcode) { if (empty($bbcode)) { $em = \MUtil_Html::create('em'); $em->raw($this->_('&laquo;empty&raquo;')); return $em; } $text = \MUtil_Markup::render($bbcode, 'Bbcode', 'Html'); $div = \MUtil_Html::create('div', array...
Display a template body @param string $bbcode @return \MUtil_Html_HtmlElement
entailment
public function createModel($detailed, $action) { $allLanguages = $this->util->getLocalized()->getLanguages(); $currentLanguage = $this->locale->getLanguage(); $markEmptyCall = array($this->util->getTranslated(), 'markEmpty'); ksort($allLanguages); $model = $this->load...
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 execute($sourceId = null, $userId = null) { $now = new \MUtil_Db_Expr_CurrentTimestamp(); $values = array('gso_last_synch' => $now, 'gso_changed' => $now, 'gso_changed_by' => $userId); $where = $this->db->quoteInto('gso_id_source = ?', $sourceId); $this->db->upda...
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 getChanges(array $context, $new) { $conditions = $this->loader->getConditions(); if (isset($context['gro_condition']) && !empty($context['gro_condition'])) { $condition = $conditions->loadCondition($context['gro_condition']); $callback = [$condition, 'isVali...
Returns the changes that must be made in an array consisting of <code> array( field1 => array(setting1 => $value1, setting2 => $value2, ...), field2 => array(setting3 => $value3, setting4 => $value4, ...), </code> By using [] array notation in the setting name you can append to existing values. Use the setting 'valu...
entailment
private function _loadPatches($minimumLevel, $maximumLevel) { if (! $this->_loaded_patches) { $this->_loaded_patches = array(); foreach ($this->patch_sources as $file => $location) { $this->_loadPatchFile($file, $location, $minimumLevel, $maximumLevel); ...
Load all patches from all patch files with the range @param int $minimumLevel @param int $maximumLevel
entailment
private function _loadPatchFile($file, $location, $minimumLevel, $maximumLevel) { if ($sql = file_get_contents($file)) { if ($this->encoding && ($this->encoding !== mb_internal_encoding())) { $sql = mb_convert_encoding($sql, mb_internal_encoding(), $this->encoding); ...
Load all patches from a single patch file @param string $file Full filename @param string $location Location description @param int $minimumLevel @param int $maximumLevel
entailment
public function getPatchDatabase($location) { if (isset($this->patch_databases[$location])) { return $this->patch_databases[$location]; } return $this->db; }
Get the database for a location @param string $location @return \Zend_Db_Adapter_Abstract
entailment
public function loadPatchBatch($patchLevel, $ignoreCompleted, $ignoreExecuted, \MUtil_Task_TaskBatch $batch) { $select = $this->db->select(); $select->from('gems__patches', array('gpa_id_patch', 'gpa_sql', 'gpa_location', 'gpa_completed')) ->where('gpa_level = ?', $patchLevel) ...
Loads execution of selected db patches for the given $patchLevel into a TaskBatch. @param int $patchLevel Only execute patches for this patchlevel @param boolean $ignoreCompleted Set to yes to skip patches that where already completed @param boolean $ignoreExecuted Set to yes to skip patches that where already execute...
entailment
public function uploadPatches($applicationLevel) { // Load current $select = $this->db->select(); $select->from( 'gems__patches', array('gpa_level', 'gpa_location', 'gpa_name', 'gpa_order', 'gpa_sql', 'gpa_id_patch') ); try { ...
Load all (new and changed) patches from all patch files into permanent storage in the database @param int $applicationLevel Highest level of patches to load (no loading of future patches)
entailment
public function loadConfiguration(): void { $builder = $this->getContainerBuilder(); $config = $this->config; if ($config->mailer === null) { throw new InvalidStateException(sprintf('"%s" must be configured.', $this->prefix('mailer'))); } $builder->addFactoryDefinition($this->prefix('messageFactory')) ...
Register services
entailment
public function beforeCompile(): void { $builder = $this->getContainerBuilder(); $config = $this->config; // Handle nette/mail configuration if ($this->name === 'mail') { return; } if ($config->mode === self::MODE_STANDALONE) { // Disable autowiring of nette.mailer if ($builder->hasDefinition('m...
Decorate services
entailment
public function afterCompile(ClassType $class): void { $config = $this->config; if ($config->debug === true) { $initialize = $class->getMethod('initialize'); $initialize->addBody( '$this->getService(?)->addPanel($this->getService(?));', ['tracy.bar', $this->prefix('panel')] ); } }
Show mail panel in tracy
entailment
public function execute($location = null, $sql = null, $completed = null, $patchId = null) { $batch = $this->getBatch(); $db = $this->patcher->getPatchDatabase($location); $data['gpa_executed'] = 1; $data['gpa_changed'] = new \MUtil_Db_Expr_CurrentTimestamp(); try { ...
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 @param string $location @param string $sql @param int $completed @param int $patchId
entailment
protected function createLoginForm($showToken = null, $showPasswordLost = null) { $args = \MUtil_Ra::args(func_get_args(), array( 'showToken' => 'is_boolean', 'showPasswordLost' => 'is_boolean', ), array( ...
Returns a login form @param boolean $showToken Optional, show 'Ask token' button, $this->showTokenButton is used when not specified @param boolean $showPasswordLost Optional, show 'Lost password' button, $this->showPasswordLostButton is used when not specified @return \Gems_User_Form_LoginForm
entailment
protected function createResetRequestForm() { $args = \MUtil_Ra::args(func_get_args(), array(), array( 'labelWidthFactor' => $this->labelWidthFactor, )); $this->initHtml(); return $this->loader->getUserLoader()->getRes...
Gets a reset password form. @return \Gems_User_Form_ResetForm
entailment
protected function displayLoginForm(\Gems_User_Form_LoginForm $form) { $this->setCurrentOrganizationTo($form->getUser()); $this->view->form = $form; }
Function for overruling the display of the login form. @param \Gems_User_Form_LoginForm $form @deprecated since version 1.8.4 no longer in use with 2FA login
entailment
protected function displayResetForm(\Gems_Form_AutoLoadFormAbstract $form, $errors) { if ($form instanceof \Gems_User_Validate_GetUserInterface) { $user = $form->getUser(); } if ($form instanceof \Gems_User_Form_ResetRequestForm) { $this->html->h3($this->_('Request p...
Function for overruling the display of the reset form. @param \Gems_Form_AutoLoadFormAbstract $form Rset password or reset request form @param mixed $errors
entailment
public function loginAction() { if ($this->loginSnippets && $this->useHtmlView) { $params = $this->_processParameters($this->loginParameters + $this->_loginDefaultParameters); $sparams['request'] = $this->getRequest(); $sparams['resetParam'] = $params['r...
Default login page
entailment
public function logoffAction() { $this->addMessage(sprintf($this->_('Good bye: %s.'), $this->currentUser->getFullName())); $this->accesslog->logChange($this->getRequest()); $this->currentUser->unsetAsCurrentUser(); \Zend_Session::destroy(); $this->_reroute(array('action' => '...
Default logoff action
entailment
public function resetpasswordAction() { $errors = array(); $form = $this->createResetRequestForm(); $request = $this->getRequest(); if ($key = $this->_getParam('key')) { $user = $this->loader->getUserLoader()->getUserByResetKey($key); if ($user->hasValid...
Reset password page.
entailment
public function sendUserResetEMail(\Gems_User_User $user) { $subjectTemplate = $this->_('Password reset requested'); // Multi line strings did not come through correctly in poEdit $bbBodyTemplate = $this->_("Dear {greeting},\n\n\nA new password was requested for your [b]{organization}[/b] a...
Send the user an e-mail with a link for password reset @param \Gems_User_User $user @return mixed string or array of Errors or null when successful.
entailment
protected function setCurrentOrganizationTo(\Gems_User_User $user) { if ($this->currentUser !== $user) { $this->currentUser->setCurrentOrganization($user->getCurrentOrganization()); } }
Helper function to safely switch org during login @param \Gems_User_User $user
entailment
public static function generate($length = 128, $type = 'alnum', $caseSensitive = true) { $characters = self::$characters; // Provided characters if (is_array($type)) { $characters = $type; } // Hexa decimal elseif ($type === 'hexa') { $characters = ar...
Generate a random string @param int $length @param mixed $type @param bool $caseSensitive @return string
entailment
private static function make($characters, $length) { $token = ''; do { $token .= $characters[random_int(0, count($characters) - 1)]; } while (strlen($token) < $length); return $token; }
Make the random string @param string $characters @param int $length @return string
entailment
protected function _cascadedDirs(array $dirs, $cascade, $fullClassnameFallback = true) { // Allow the use of the full class name instead of just the plugin part of the // name during load. if ($fullClassnameFallback) { $newdirs = array('' =>''); } else { $newd...
Add a subdirectory / sub name to a list of class load paths @param array $dirs prefix => path @param string $cascade The sub directories to cascade to @param boolean $fullClassnameFallback Allows full class name specification instead of just plugin name part @return array prefix => path
entailment
protected function _getClass($name, $className = null, array $arguments = array()) { if (! isset($this->$name)) { if (null === $className) { $className = $name; } $this->$name = $this->_loadClass($className, true, $arguments); } return $th...
Returns $this->$name, creating the item if it does not yet exist. @param string $name The $name of the variable to store this object in. @param string $className Class name or null if the same as $name, prepending $this->_dirs. @param array $arguments Class initialization arguments. @return mixed Instance of $classNam...
entailment
protected function _loadClass($name, $create = false, array $arguments = array()) { if ($this->_loader instanceof Zalt\Loader\ProjectOverloader) { $className = $this->_loader->find($name); } else { $className = $this->_loader->load($name); } // \MUtil_Echo::...
Create or loads the class. When only loading, this function returns a StaticCall object that can be invoked lazely. @see \MUtil_Lazy_StaticCall @see \MUtil_Registry_TargetInterface @param string $name The class name, minus the part in $this->_dirs. @param boolean $create Create the object, or only when an \MUtil_Regi...
entailment
public function addPrefixPath($prefix, $path, $prepend = true) { if ($this->cascade) { $newPrefix = $prefix . '_' . $this->cascade; $newPath = $path . '/' . strtr($this->cascade, '_', '/'); } else { $newPrefix = $prefix; $newPath = $path; } ...
Add prefixed paths to the registry of paths @param string $prefix @param mixed $paths String or an array of strings @param boolean $prepend Put path at the beginning of the stack (has no effect when prefix / dir already set) @return \Gems_Loader_LoaderAbstract (continuation pattern)
entailment
private function _getActionsDb() { try { $rows = $this->_db->fetchAssoc("SELECT * FROM gems__log_setup ORDER BY gls_name"); } catch (\Exception $exc) { $rows = array(); $this->_warn(); } $output = array(); foreach ((array) $rows as $row)...
Load the actions into memory from the database (and cache them)
entailment
private function _storeLogEntry(\Zend_Controller_Request_Abstract $request, array $row, $force) { if (! $force) { if (isset($this->_sessionStore->last) && ($row === $this->_sessionStore->last)) { return false; } // Now save the variables to the session to...
Stores the current log entry @param \Zend_Controller_Request_Abstract $request @param array $row @param boolean $force Should we force the logentry to be inserted or should we try to skip duplicates? @return boolean True when a log entry was stored
entailment