sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
$elements[] = new \Zend_Form_Element_Hidden(\MUtil_Model::REQUEST_ID);
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 |
public function writeTo($filename)
{
parent::writeTo($filename);
if ($this->optimiserService instanceof ImageOptimiserInterface) {
$this->optimiserService->optimiseImage($filename);
}
} | Calls the original writeTo function and then after that completes optimises the image
@param string $filename | entailment |
public function canResetPassword(\Gems_User_User $user = null)
{
if ($user) {
// Depends on the user.
if ($user->hasEmailAddress() && $user->canSetPassword()) {
$email = $user->getEmailAddress();
if (empty($email)) {
return false;
... | Return true if a password reset key can be created.
Returns the setting for the definition whan no user is passed, otherwise
returns the answer for this specific user.
@param \Gems_User_User $user Optional, the user whose password might change
@return boolean | entailment |
public function checkRehash(\Gems_User_User $user, $password)
{
if (! $this->canSaveNewHash()) {
return false;
}
$model = new \MUtil_Model_TableModel('gems__user_passwords');
$row = $model->loadFirst(['gup_id_user' => $user->getUserLoginId()]);
if ($row && pas... | Checks if the current users hashed password uses the current hash algorithm.
If not it rehashes and saves the current password
@param \Gems_User_User $user Current logged in user
@param integer $password Raw password
@return boolean password has been rehashed | entailment |
public function getAuthAdapter(\Gems_User_User $user, $password)
{
$db2 = $this->getDb2();
$credentialValidationCallback = $this->getCredentialValidationCallback();
$adapter = new CallbackCheckAdapter($db2, 'gems__user_passwords', 'gul_login', 'gup_password', $credentialValidationCallback)... | Returns an initialized Zend\Authentication\Adapter\AdapterInterface
@param \Gems_User_User $user
@param string $password
@return Zend\Authentication\Adapter\AdapterInterface | entailment |
public function getCredentialValidationCallback()
{
if ($this->checkOldHashes) {
$credentialValidationCallback = function($dbCredential, $requestCredential) {
if (password_verify($requestCredential, $dbCredential)) {
return true;
} elseif ($dbC... | get the credential validation callback function for the callback check adapter
@return callback Function | entailment |
protected function getDb2()
{
if (!$this->db2 instanceof Adapter) {
$config = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$resources = $config->getOption('resources');
$dbConfig = array(
'driver' => $resources['db']['adapter'],
... | Create a Zend DB 2 Adapter needed for the Zend\Authentication library
@return Zend\Db\Adapter\Adapter Zend Db Adapter | entailment |
public function getPasswordResetKey(\Gems_User_User $user)
{
$model = new \MUtil_Model_TableModel('gems__user_passwords');
\Gems_Model::setChangeFieldsByPrefix($model, 'gup', $user->getUserId());
$data['gup_id_user'] = $user->getUserLoginId();
$filter = $data;
if ((0 == ($t... | Return a password reset key
@param \Gems_User_User $user The user to create a key for.
@return string | entailment |
public function getUserData($login_name, $organization)
{
$select = $this->getUserSelect($login_name, $organization);
try {
$result = $this->db->fetchRow($select, array($login_name, $organization), \Zend_Db::FETCH_ASSOC);
} catch (\Zend_Db_Statement_Exception $e) {
/... | Returns a user object, that may be empty if the user is unknown.
@param string $login_name
@param int $organization
@return array Of data to fill the user with. | entailment |
public function hasPassword(\Gems_User_User $user)
{
$sql = "SELECT CASE WHEN gup_password IS NULL THEN 0 ELSE 1 END FROM gems__user_passwords WHERE gup_id_user = ?";
return (boolean) $this->db->fetchOne($sql, $user->getUserLoginId());
} | Return true if the user has a password.
@param \Gems_User_User $user The user to check
@return boolean | entailment |
public function setPassword(\Gems_User_User $user, $password)
{
$data['gup_id_user'] = $user->getUserLoginId();
$data['gup_reset_key'] = null;
$data['gup_reset_requested'] = null;
$data['gup_reset_required'] = 0;
if (null === $password) {
// Passwor... | Set the password, if allowed for this user type.
@param \Gems_User_User $user The user whose password to change
@param string $password
@return \Gems_User_UserDefinitionInterface (continuation pattern) | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$messages = false;
if ($this->wasAnswered) {
$this->currentToken = $this->token->getNextUnansweredToken();
} else {
$validator = $this->loader->getTracker()->getTokenValidator();
if ($validator->... | 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 Upgrade143to150()
{
$this->_batch->addTask('Db_AddPatches', 42);
$this->_batch->addTask('Db_AddPatches', 43);
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Echo', $this->_('Syncing surveys for all sources'));
//Now sync the db source... | To upgrade from 143 to 15 we need to do some work:
1. execute db patches 42 and 43
2. create new tables | entailment |
public function Upgrade154to155()
{
$this->_batch->addTask('Db_AddPatches', 48);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
return true;
} | To upgrade to 1.5.5 just execute patchlevel 48 | entailment |
public function Upgrade155to156()
{
$this->_batch->addTask('Db_AddPatches', 49);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
return true;
} | To upgrade to 1.5.6 just execute patchlevel 49 | entailment |
public function Upgrade157to16()
{
$this->_batch->addTask('Db_AddPatches', 51);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
return true;
} | To upgrade to 1.6 just execute patchlevel 51 | entailment |
public function Upgrade16to161()
{
$this->_batch->addTask('Db_AddPatches', 52);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
return true;
} | To upgrade to 1.6.1 just execute patchlevel 52 | entailment |
public function Upgrade161to162()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 53);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
return true;
} | To upgrade to 1.6.2 just execute patchlevel 53 | entailment |
public function Upgrade162to163()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 54);
$this->_batch->addTask('Updates_UpdateRoleIds');
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructi... | To upgrade to 1.6.3 just execute patchlevel 54 | entailment |
public function Upgrade163to164()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 55);
$this->_batch->addTask('Updates_CompileTemplates');
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instru... | To upgrade to 1.6.4 just execute patchlevel 55 | entailment |
public function Upgrade164to170()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 56);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
return true;
} | To upgrade to 1.7.0 | entailment |
public function Upgrade170to171()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 57);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
$this->_batch->addTask('Echo', $this->_('... | To upgrade to 1.7.1 | entailment |
public function Upgrade171to172()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 58);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
$this->_batch->addTask('Echo', $this->_('... | To upgrade to 1.7.2 | entailment |
public function Upgrade172to181()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 59);
$this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
$this->_batch->addTask('Echo', $this->_('... | To upgrade to 1.8.1 | entailment |
public function Upgrade181to182()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 60);
// Use AddTask task to execute after patches
$this->_batch->addTask('AddTask', 'Updates\\FillTokenReplacementsTask');
$this->_batch->addTask('AddTa... | To upgrade to 1.8.2 | entailment |
public function Upgrade182to183()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 61);
// Use AddTask task to execute after patches
$this->_batch->addTask('AddTask', 'Echo', $this->_('Make sure to read the changelog as it contains important in... | To upgrade to 1.8.3 | entailment |
public function Upgrade183to184()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 62);
$this->_batch->addTask('Updates_CompileTemplates');
// Use AddTask task to execute after patches
$this->_batch->addTask('AddTask', 'Echo', $this->_(... | To upgrade to 1.8.4 | entailment |
public function Upgrade184to185()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 63);
// Use AddTask task to execute after patches
$this->_batch->addTask('AddTask', 'Echo', $this->_('Make sure to read the changelog as it contains important in... | To upgrade to 1.8.5 | entailment |
public function Upgrade185to186()
{
$this->_batch->addTask('Db_CreateNewTables');
$this->_batch->addTask('Db_AddPatches', 64);
// Use AddTask task to execute after patches
$this->_batch->addTask('AddTask', 'Updates_EncryptPasswords', 'gems__sources', 'gso_id_source', 'gso_ls_passwor... | To upgrade to 1.8.6 | entailment |
protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$items = $model->getItemsOrdered();
foreach($items as $name) {
if ($model->get($name, 'type') === \MUtil_Model::TYPE_CHILD_MODEL) {
$submodel = $... | 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 getHtmlOutput(\Zend_View_Abstract $view)
{
$model = $this->getModel();
if ($this->trackUsage) {
$model->trackUsage();
}
$table = $this->getShowTable($model);
$table->setRepeater($this->getRepeater($model));
return $table;
} | 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 addElement($element, $name = null, $options = null)
{
if ($this->currentTab) {
return $this->currentTab->addElement($element, $name, $options);
} else {
parent::addElement($element, $name, $options);
if (is_string($element)) {
$ele... | Add an element to the form, when a tab (subform) had been added, it will return
the subform instead of the form, keep this in mind when chaining methods
@param string|\Zend_Form_Element $element
@param string $name
@param array|\Zend_Config $options
@throws \Zend_Form_Exception on invalid element
@return \Gems_TabF... | entailment |
public function addTab($name, $title)
{
if ($title instanceof \MUtil_Html_HtmlInterface) {
$title = $title->render($this->getView());
}
$tab = new \Gems_Form_TabSubForm(array('name' => $name, 'title' => strip_tags($title)));
$this->currentTab = $tab;
$this->addSub... | Add a tab to the form
@param string $name
@param string $title
@return \Gems_Form_TabSubForm | entailment |
public function addToOtherGroup($element)
{
if ($element instanceof \Zend_Form_Element) {
if ($group = $this->getDisplayGroup(self::GROUP_OTHER)) {
$group->addElement($element);
} else {
$this->addDisplayGroup(array($element), self::GROUP_OTHER);
... | Add to the group all non-tab elements are in
@param mixed $element
@return \Gems_TabForm | entailment |
public function addDisplayGroup(array $elements, $name, $options = null) {
if ($this->currentTab) {
return $this->currentTab->addDisplayGroup($elements, $name, $options);
} else {
//Add the group as usual
parent::addDisplayGroup($elements, $name, $options);
... | Add an element to the form, when a tab (subform) had been added, it will return
the subform instead of the form, keep this in mind when chaining methods
@param array $elements
@param string $name
@param array|\Zend_Config $options
@return \Gems_TabForm|\Gems_Form_TabSubForm
@throws \Zend_Form_Exception if no valid ... | entailment |
public function getDisplayGroup($name)
{
if ($group = parent::getDisplayGroup($name)) {
return $group;
} else {
$subforms = $this->getSubForms();
foreach($subforms as $subform) {
if ($group = $subform->getDisplayGroup($name)) {
... | Return a display group, use recursive search in subforms to provide a transparent experience
with tabs
@param string $name
@return \Zend_Form_DisplayGroup|null | entailment |
public function getElement($name)
{
if ($element = parent::getElement($name)) {
return $element;
} else {
$subforms = $this->getSubForms();
foreach($subforms as $subform) {
if ($element = $subform->getElement($name)) {
return $e... | Retrieve a single element, use recursive search in subforms to provide a transparent experience
with tabs
@param string $name
@return \Zend_Form_Element|null | entailment |
public function getTab($name)
{
$tab = $this->getSubForm($name);
$this->currentTab = $tab;
return $tab;
} | Retrieve a named tab (subform) and set the active tab to this one
@param string $name
@return \Gems_Form_TabSubForm | entailment |
public function loadDefaultDecorators() {
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->setDecorators(array(
'TabErrors',
array(array('SubformElements' => '... | Load the default decorators
@return void | entailment |
public function setVerbose($bool)
{
$decorator = $this->getDecorator('TabErrors');
if ($decorator) {
$decorator->setOption('verbose', (bool) $bool);
}
} | Set the form to be verbose, showing above the form what tabs have errors and
possibly add custom (sub)formlevel error messages
@param boolean $bool | entailment |
public function setView(\Zend_View_Interface $view = null) {
/**
* If the form is populated... and we have a tab set... select it
*/
$tab = $this->getValue('tab');
if ($tab > 0) {
$this->selectTab($tab);
}
parent::setView($view);
if ($this-... | Set the view object
@param \Zend_View_Interface $view
@return \Gems_TabForm | entailment |
public function getValues($suppressArrayNotation = false)
{
$values = parent::getValues($suppressArrayNotation);
foreach ($this->getSubForms() as $key => $subForm) {
$values = $this->_array_replace_recursive($values, $values[$key]);
}
return $values;
} | Retrieve all form element values
Fix for ZF error where subform values will be pushed into an array with key: formname
for compatibility both are now in the result array
@param bool $suppressArrayNotation
@return array | entailment |
public function applyFormatting($detailed = false, $edit = false)
{
$translated = $this->util->getTranslated();
$translator = $this->getTranslateAdapter();
if ($edit) {
$dateFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat');
} else {
... | Sets the labels, format functions, etc...
@param boolean $detailed True when shopwing detailed information
@param boolean $edit When true use edit settings
@return \Gems_Tracker_Model_TrackModel | entailment |
public function delete($filter = true)
{
$this->setChanged(0);
$tracks = $this->load($filter);
if ($tracks) {
foreach ($tracks as $row) {
if (isset($row['gtr_id_track'])) {
$trackId = $row['gtr_id_track'];
if ($this->isDele... | Delete items from the model
This method also takes care of cascading to track fields and rounds
@param mixed $filter True to use the stored filter, array to specify a different filter
@return int The number of items deleted | entailment |
public function isDeleteable($trackId)
{
if (! $trackId) {
return true;
}
$sql = "SELECT gto_id_token FROM gems__tokens WHERE gto_id_track = ? AND gto_start_time IS NOT NULL";
return (boolean) ! $this->db->fetchOne($sql, $trackId);
} | Can this track be deleted as is?
@param int $trackId
@return boolean | entailment |
protected function _getFinalSql($tablePrefix, $repeat = false)
{
$db = \Zend_Registry::getInstance()->get('db');
$sqlSuffix = $db->quoteIdentifier($tablePrefix . '_changed') . " timestamp NOT NULL,\n"
. $db->quoteIdentifier($tablePrefix . '_changed_by') . " bigint(20) NOT NULL,\n"
... | Add the changed/created by fields and add primary key
@param string $tablePrefix
@return string | entailment |
protected function _processAnswer($key, $input, $type)
{
$output = array();
$modelName = str_replace('/', '_', $key);
if (array_key_exists($key, $input))
{
$value = $input[$key];
} else {
return $output;
}
switch ($type) {
... | If needed process the answer
@param string $key
@param mixed $value
@param string $type
@return array | entailment |
private function flattenBody($xml, $context = '')
{
foreach ($xml as $elementName => $element) {
//Check ref first
$elementContext = $context;
foreach ($element->attributes() as $name => $value) {
if ($name == 'ref' || $name == 'nodeset' ) {
... | Return flattend element
@param SimpleXMLElement $xml
@param type $context | entailment |
public function getDeviceIdField()
{
if (empty($this->deviceIdField)) {
foreach ($this->_xml->children('h', true)->head->children()->model->bind as $bind) {
if ($presets = $bind->attributes('jr', true)) {
foreach ($presets as $value) {
... | Returns what field (path) contains the attributes jr:preload="property" jr:preloadParams="deviceid"
from the moden -> bind elements
@return string | entailment |
public function getFormID()
{
if (empty($this->formID)) {
foreach ($this->_xml->children('h', true)->head->children()->model->instance->children() as $element) {
if (!empty($element->attributes()->id)) {
$this->formID = $element->attributes()->id->__toString()... | Returns the formID from the instance element id attribute
@return string | entailment |
public function getFormVersion()
{
if (empty($this->formVersion)) {
foreach ($this->_xml->children('h', true)->head->children()->model->instance->children() as $element) {
if (!empty($element->attributes()->version)) {
$this->formVersion = $element->attributes... | Returns the formVersion from the instance element version attribute
@return string | entailment |
public function getTitle()
{
if (empty($this->title)) {
$this->title = $this->_xml->children('h', true)->head->children('h', true)->title;
}
return $this->title;
} | Returns the form title from the h:title element
@return string | entailment |
public function getChanges(array $context, $new)
{
$multi = explode(FieldAbstract::FIELD_SEP, $context['gtf_field_values']);
return array(
'gtf_field_values' => array(
'label' => $this->_('Values'),
'description' => $this->_('Separate multiple... | 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 |
public function isValid($value)
{
foreach ((array) $value as $val) {
if (\MUtil_String::contains($val, $this->_options[0])) {
return true;
}
}
return false;
} | IS the comparison valid?
Settings should already be in place by the construtor.
@param mixed $value The id of the condition
@return bool | entailment |
public function afterRegistry()
{
parent::afterRegistry();
$this->browse = true;
$this->caption = $this->_('Rounds with this condition');
$this->onEmpty = $this->_('No rounds using this condition found');
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function createModel()
{
if (! $this->_model instanceof RoundModel) {
$this->_model = new RoundModel();
$this->_model->addTable('gems__tracks', ['gro_id_track' => 'gtr_id_track']);
$this->_model->addTable('gems__surveys', ['gro_id_survey' => 'gsu_id_survey']);
... | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
protected function processFilterAndSort(\MUtil_Model_ModelAbstract $model)
{
$conditionId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
//\MUtil_Model::$verbose = true;
if ($conditionId) {
$model->addFilter(['gro_condition' => $conditionId]);
}
$this->pr... | Overrule to implement snippet specific filtering and sorting.
@param \MUtil_Model_ModelAbstract $model | entailment |
public function execute($tableData = array())
{
$batch = $this->getBatch();
$batch->addToCounter('createTableStep');
$result = $this->dbaModel->runScript($tableData);
$result[] = sprintf(
$this->_('Finished %s %s creation script for object %d of %d'),
... | 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 |
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
if ($model->has('row_class')) {
$bridge->getTable()->tbody()->getFirst(true)->appendAttrib('class', $bridge->row_class);
}
if ($this->showMenu) {
$s... | 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 |
public function afterRegistry()
{
parent::afterRegistry();
if (! $this->menuActionController) {
$this->menuActionController = $this->request->getControllerName();
}
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function applyTextMarker()
{
$model = $this->getModel();
$textKey = $model->getTextFilter();
$filter = $model->getFilter();
if (isset($filter[$textKey])) {
$searchText = $filter[$textKey];
// \MUtil_Echo::r('[' . $searchText . ']');
$m... | Make sure generic search text results are marked
@return void | entailment |
protected function findMenuItem($defaultController, $actions = 'index')
{
foreach ((array) $actions as $key => $action) {
$controller = is_int($key) ? $defaultController : $key;
$item = $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)... | Finds a specific active menu item
@param string $defaultController
@param string|array $actions
@return \Gems_Menu_SubMenuItem The first that
@deprecated since 1.7.1, use findMenuItems() | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$table = parent::getHtmlOutput($view);
$table->getOnEmpty()->class = 'centerAlign';
if (($this->containingId || $this->keyboard) && (! self::$keyboardUsed)) {
// Assign keyboard tracking only once
self::$keyb... | 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 getHtmlOutput(\Zend_View_Abstract $view)
{
$html = $this->getHtmlSequence();
if (! $this->trackData) {
$html->h2($this->_('Unknown track'));
$this->addMessage(sprintf($this->_('Unknown track id %s'), $this->trackId));
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 hasHtmlOutput()
{
if (! $this->multiTracks) {
return false;
}
if (! $this->trackData) {
if (! $this->trackId) {
if ($this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) {
$this->trackId ... | The place to check if the data set in the snippet is valid
to generate the snippet.
When invalid data should result in an error, you can throw it
here but you can also perform the check in the
checkRegistryRequestsAnswers() function from the
{@see \MUtil_Registry_TargetInterface}.
@return boolean | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
if ($this->request->isPost()) {
$this->export->render(
$this->getRespondentIds(),
$this->request->getParam('group'),
$this->request->getParam('format')
);
... | Create the snippets content
This is a stub function either override getHtmlOutput() or override render()
@param \Zend_View_Abstract $view Just in case it is needed here
@return \MUtil_Html_HtmlInterface Something that can be rendered | entailment |
protected function _ensureRounds()
{
if (! is_array($this->_rounds)) {
$roundSelect = $this->db->select();
$roundSelect->from('gems__rounds')
->where('gro_id_track = ?', $this->_trackId)
->order('gro_id_order');
// \MUtil_Echo::r((string) ... | Loads the rounds data for this type of track engine.
Can be overruled by sub classes. | entailment |
protected function _getAvailableIcons()
{
$dir = GEMS_WEB_DIR . '/gems-responsive/images/icons';
if (!file_exists($dir)) {
$dir = GEMS_WEB_DIR . '/gems/icons';
}
$icons = array();
if (file_exists($dir)) {
$iterator = new DirectoryIterator($dir);
... | Returns a list of available icons under 'htdocs/pulse/icons'
@return string[] | entailment |
private function _update(array $values, $userId)
{
if ($this->tracker->filterChangesOnly($this->_trackData, $values)) {
if (\Gems_Tracker::$verbose) {
$echo = '';
foreach ($values as $key => $val) {
$echo .= $key . ': ' . $this->_trackData[$ke... | Update the track, both in the database and in memory.
@param array $values The values that this token should be set to
@param int $userId The current user
@return int 1 if data changed, 0 otherwise | entailment |
public function addFieldsToModel(\MUtil_Model_ModelAbstract $model, $addDependency = true, $respTrackId = false)
{
if ($this->_fieldsDefinition->exists) {
// Add the data to the load / save
$transformer = new AddTrackFieldsTransformer($this->loader, $this->_fieldsDefinition, $respTra... | Integrate field loading en showing and editing
@param \MUtil_Model_ModelAbstract $model
@param boolean $addDependency True when editing, can be false in all other cases
@param string $respTrackId Optional Database column name where Respondent Track Id is set
@return \Gems_Tracker_Engine_TrackEngineAbstract | entailment |
protected function addNewTokens(\Gems_Tracker_RespondentTrack $respTrack, $userId)
{
$orgId = $respTrack->getOrganizationId();
$respId = $respTrack->getRespondentId();
$respTrackId = $respTrack->getRespondentTrackId();
// $this->t
$sql = "SELECT gro_id_round, gro... | Creates all tokens that should exist, but do not exist
NOTE: When overruling this function you should not create tokens because they
were deleted by the user
@param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
@param int $userId Id of the user who takes the action (for logging)
@return int T... | entailment |
public function afterRegistry()
{
parent::afterRegistry();
$this->_fieldsDefinition = $this->tracker->createTrackClass('Engine\\FieldsDefinition', $this->_trackId);
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
public function applyToMenuSource(\Gems_Menu_ParameterSource $source)
{
$source->setTrackId($this->_trackId);
$source->offsetSet('gtr_active', isset($this->_trackData['gtr_active']) ? $this->_trackData['gtr_active'] : 0);
return $this;
} | Set menu parameters from this track engine
@param \Gems_Menu_ParameterSource $source
@return \Gems_Tracker_Engine_TrackEngineInterface (continuation pattern) | entailment |
protected function checkExistingRoundsFor(\Gems_Tracker_RespondentTrack $respTrack, $userId)
{
// FOR TESTING: sqlite can not de update and joins, so when testing just return zero for now
if (\Zend_Session::$_unitTestEnabled === true) return 0;
// @@ TODO Make this testable and not db depend... | Checks all existing tokens and updates any changes to the original rounds (when necessary)
@param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
@param int $userId Id of the user who takes the action (for logging)
@return int The number of tokens changed by this code | entailment |
public function checkRoundsFor(\Gems_Tracker_RespondentTrack $respTrack, $userId, \Gems_Task_TaskRunnerBatch $batch = null)
{
if (null === $batch) {
$batch = new \Gems_Task_TaskRunnerBatch('tmp-tack-' . $respTrack->getRespondentTrackId());
}
// Step one: update existing tokens
... | Check for the existence of all tokens and create them otherwise
@param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
@param int $userId Id of the user who takes the action (for logging)
@param \Gems_Task_TaskRunnerBatch $changes batch for counters | entailment |
public function copyTrack($oldTrackId)
{
$trackModel = $this->tracker->getTrackModel();
$roundModel = $this->getRoundModel(true, 'rounds');
$fieldModel = $this->getFieldsMaintenanceModel();
// First load the track
$trackModel->applyParameters(array('id' => $oldTrackId));
... | Copy a track and all it's related data (rounds/fields etc)
@param inte $oldTrackId The id of the track to copy
@return int The id of the copied track | entailment |
public function getConversionTargets(array $options)
{
$classParts = explode('_', get_class($this));
$className = end($classParts);
return array($className => $options[$className]);
} | Returns a list of classnames this track engine can be converted into.
Should always contain at least the class itself.
@see convertTo()
@param array $options The track engine class options available in as a "track engine class names" => "descriptions" array
@return array Filter or adaptation of $options | entailment |
public function getFieldBeforeUpdateEvent()
{
if (isset($this->_trackData['gtr_beforefieldupdate_event']) && $this->_trackData['gtr_beforefieldupdate_event']) {
return $this->events->loadBeforeTrackFieldUpdateEvent($this->_trackData['gtr_beforefieldupdate_event']);
}
} | Get the FieldUpdateEvent for this trackId
@return \Gems\Event\TrackBeforeFieldUpdateEventInterface | null | entailment |
public function getFieldUpdateEvent()
{
if (isset($this->_trackData['gtr_fieldupdate_event']) && $this->_trackData['gtr_fieldupdate_event']) {
return $this->events->loadTrackFieldUpdateEvent($this->_trackData['gtr_fieldupdate_event']);
}
} | Get the FieldUpdateEvent for this trackId
@return \Gems_Event_TrackFieldUpdateEventInterface | null | entailment |
public function getNextRoundId($roundId)
{
$this->_ensureRounds();
if ($this->_rounds && $roundId) {
$next = false;
foreach ($this->_rounds as $currentRoundId => $round) {
if ($next) {
return $currentRoundId;
}
if (... | Look up the round id for the next round
@param int $roundId Gems round id
@return int Gems round id | entailment |
public function getPreviousRoundId($roundId, $roundOrder = null)
{
$this->_ensureRounds();
if ($this->_rounds && $roundId) {
$returnId = null;
foreach ($this->_rounds as $currentRoundId => $round) {
if (($currentRoundId == $roundId) || ($roundOrder && ($round['gro... | Look up the round id for the previous round
@param int $roundId Gems round id
@param int $roundOrder Optional extra round order, for when the current round may have changed.
@return int Gems round id | entailment |
public function getRound($roundId)
{
$this->_ensureRounds();
if (! isset($this->_rounds[$roundId])) {
return null;
}
if (! isset($this->_roundObjects[$roundId])) {
$this->_roundObjects[$roundId] = $this->tracker->createTrackClass('Round', $this->_rounds[$roun... | Get the round object
@param int $roundId Gems round id
@return \Gems\Tracker\Round | entailment |
public function getRoundAnswerSnippets(\Gems_Tracker_Token $token)
{
$this->_ensureRounds();
$roundId = $token->getRoundId();
if (isset($this->_rounds[$roundId]['gro_display_event']) && $this->_rounds[$roundId]['gro_display_event']) {
$event = $this->events->loadSurveyDisplayEve... | Returns a snippet name that can be used to display the answers to the token or nothing.
@param \Gems_Tracker_Token $token
@return array Of snippet names | entailment |
public function getRoundChangedEvent($roundId)
{
$this->_ensureRounds();
if (isset($this->_rounds[$roundId]['gro_changed_event']) && $this->_rounds[$roundId]['gro_changed_event']) {
return $this->events->loadRoundChangedEvent($this->_rounds[$roundId]['gro_changed_event']);
}
... | Return the Round Changed event name for this round
@param int $roundId
@return \Gems_Event_RoundChangedEventInterface event instance or null | entailment |
public function getRoundDefaults()
{
$this->_ensureRounds();
if ($this->_rounds) {
$defaults = end($this->_rounds);
unset($defaults['gro_id_round'], $defaults['gro_id_survey']);
$defaults['gro_id_order'] = $defaults['gro_id_order'] + 10;
} else {
... | Get the defaults for a new round
@return array Of fieldname => default | entailment |
public function getRoundDescriptions()
{
$this->_ensureRounds();
$output = array();
foreach ($this->getRounds() as $roundId => $round) {
if ($round instanceof Round) {
$output[$roundId] = $round->getFullDescription();
}
}
return $outp... | The round descriptions for this track
@return array roundId => string | entailment |
public function getRoundModel($detailed, $action)
{
$model = $this->createRoundModel();
$translated = $this->util->getTranslated();
// Set the keys to the parameters in use.
$model->setKeys(array(\MUtil_Model::REQUEST_ID => 'gro_id_track', \Gems_Model::ROUND_ID => 'gro_id_round... | Returns a model that can be used to retrieve or save the data.
@param boolean $detailed Create a model for the display of detailed item data or just a browse table
@param string $action The current action
@return \MUtil_Model_ModelAbstract | entailment |
public function getRounds()
{
$this->_ensureRounds();
foreach ($this->_rounds as $roundId => $roundData) {
if (! isset($this->_roundObjects[$roundId])) {
$this->_roundObjects[$roundId] = $this->tracker->createTrackClass('Round', $roundData);
}
}
... | Get all the round objects
@return array of roundId => \Gems\Tracker\Round | entailment |
public function getTrackCalculationEvent()
{
if (isset($this->_trackData['gtr_calculation_event']) && $this->_trackData['gtr_calculation_event']) {
return $this->events->loadTrackCalculationEvent($this->_trackData['gtr_calculation_event']);
}
} | Get the TrackCompletedEvent for this trackId
@return \Gems_Event_TrackCalculationEventInterface | null | entailment |
public function getTrackCompletionEvent()
{
if (isset($this->_trackData['gtr_completed_event']) && $this->_trackData['gtr_completed_event']) {
return $this->events->loadTrackCompletionEvent($this->_trackData['gtr_completed_event']);
}
} | Get the TrackCompletedEvent for this trackId
@return \Gems_Event_TrackCompletedEventInterface|null | entailment |
protected function removeInactiveRounds(\Gems_Tracker_RespondentTrack $respTrack, $userId)
{
$qTrackId = $this->db->quote($this->_trackId);
$qRespTrackId = $this->db->quote($respTrack->getRespondentTrackId());
$orgId = $this->db->quote($respTrack->getOrganizationId());
$w... | Remove the unanswered tokens for inactive rounds.
@param \Gems_Tracker_RespondentTrack $respTrack The respondent track to check
@param int $userId Id of the user who takes the action (for logging)
@return int The number of tokens changed by this code | entailment |
public function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$model->set('gr2o_patient_nr', 'label', $this->_('Respondent'));
$model->set('gto_round_description', 'label', $this->_('Round / Details'));
$model->set('gto_valid_from',... | 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 |
public function execute($context, $toLevel = null, $fromLevel = null)
{
if(is_null($toLevel)) {
$toLevel = $this->getMaxLevel($context);
}
if(is_null($fromLevel)) {
$fromLevel = $this->getNextLevel($context);
if ($fromLevel > $toLevel) {
$... | Execute upgrades for the given $context
When no $to or $from are given, the given $context will be upgraded from the current level
to the max level. Otherwise the $from and/or $to will be used to determine what upgrades
to execute.
@param string $context The context to execute the upgrades for
@param int|null $toLeve... | entailment |
public function getLevel($context)
{
if(isset($this->_info->$context)) {
return intval($this->_info->$context);
} else {
$level = $this->getMaxLevel($context);
$this->setLevel($context, $level);
return $level;
}
} | Get the current upgrade level for the given $context
@param string $context
@return int | entailment |
public function getMaxLevel($context = null)
{
if (! $context) {
$context = $this->getContext();
}
if (isset($this->_upgradeStack[$context])) {
$values = array_keys($this->_upgradeStack[$context]);
$values[] = 0;
$index = intval(max($values));... | Get the highest level for the given $context
@param string|null $context
@return int | entailment |
public function getNextLevel($context = null, $level = null) {
if (is_null($context)) {
$context = $this->getContext();
}
if (is_null($level)) {
$level = $this->getLevel($context);
}
//Get all the levels
$currentContext = $this->_upgradeStack[$con... | Get the next level for a given level and context
When context is null, it will get the current context
When level is null, it will get the current level
@param type $level
@param type $context
@return type | entailment |
public function getUpgrades($context = null) {
if (! $context) {
$context = $this->getContext();
}
if (isset($this->_upgradeStack[$context])) {
return $this->_upgradeStack[$context];
}
return array();
} | Retrieve the upgrades for a certain context, will return an empty array when nothing present.
@param string $context
@return array | entailment |
public function getUpgradesInfo($requestedContext = null)
{
$result = array();
foreach(array_keys($this->_upgradeStack) as $context) {
$row = array();
$row['context'] = $context;
$row['maxLevel'] = $this->getMaxLevel($context);
$row['level'] = $this->... | Retrieve info about the $requestedContext or all contexts when omitted
@param string $requestedContext
@return array | entailment |
protected function initUpgradeFile()
{
touch($this->upgradeFile);
$this->_info = new \Zend_Config_Ini($this->upgradeFile, null, array('allowModifications' => true));
foreach(array_keys($this->_upgradeStack) as $context) {
$maxLevel = $this->getMaxLevel($context);
... | When upgrade file does not exist, create it and default to the max
level since no upgrades should be needed after a clean install | entailment |
public function register($callback, $info = null, $index = null, $context = null)
{
if (is_string($callback)) {
$callback = array($this, $callback);
}
if (!is_callable($callback)) {
return false;
}
if (!$context) {
$contex... | Register an upgrade in the stack, it can be executed by using $this->execute
Index and context are optional and will be generated when omitted. For the
user interface to be clear $info should provide a good description of what
the upgrade does.
@param array|string $callback A valid callback, either string for a metho... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.