sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function _initTranslate()
{
$this->bootstrap('locale');
$language = $this->locale->getLanguage();
/*
* Scan for files with -<languagecode> and disable notices when the requested
* language is not found
*/
$options = array( 'adapter' => '... | Initialize the translate component.
Scans the application and project dirs for available translations
Use $this->translate to access afterwards
Also sets $this->translateAdapter to access afterwards
@return \Zend_Translate | entailment |
protected function _initView()
{
$this->bootstrap('project');
// Initialize view
$view = new \Zend_View();
$view->addHelperPath('MUtil/View/Helper', 'MUtil_View_Helper');
$view->addHelperPath('MUtil/Less/View/Helper', 'MUtil_Less_View_Helper');
$view->addHelperPath('... | Initialize the view component and sets some project specific values.
Actions taken here can take advantage that the full framework has
been activated by now, including session data, etc.
Use $this->view to access afterwards
@return \Zend_View | entailment |
protected function _initCurrentUser()
{
$this->bootstrap(array('acl', 'basepath', 'cache', 'db', 'loader', 'project', 'session', 'translate', 'util'));
// Fix for _init resourcea being case insensitive
$container = $this->getContainer();
$user = $this->loader->getCurrentUser();... | Initialize the currentUser component.
You can overrule this function to specify your own project translation method / file.
Use $this->currentUser to access afterwards
@return \Gems_User_User | entailment |
protected function _initZFDebug()
{
if ((APPLICATION_ENV === 'production') || (APPLICATION_ENV === 'acceptance') || Zend_Session::$_unitTestEnabled ) {
// Never on on production systems
return;
}
$debug = $this->getOption('zfdebug');
if (! isset($debug['activ... | Add ZFDebug info to the page output.
@return void | entailment |
protected function _layoutContact(array $args = null)
{
if ($this->menu instanceof \Gems_Menu) {
$menuItem = $this->menu->find(array('controller' => 'contact', 'action' => 'index'));
if ($menuItem) {
$contactDiv = \MUtil_Html::create()->div(
$args... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutCrumbs(array $args = null)
{
// Must be called after _layoutNavigation()
if ($this->menu && $this->menu->isVisible()) {
$path = $this->menu->getActivePath($this->request);
$last = array_pop($path);
// Only display when there is a path o... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutCss()
{
// Set CSS stylescheet(s)
$projectCss = isset($this->project->css) ? (array) $this->project->css : [];
$projectCss = array_reverse($projectCss);
foreach ($projectCss as $css) {
if (is_array($css)) {
$media = $css['media']... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutFavicon()
{
// FAVICON
$icon = isset($this->project->favicon) ? $this->project->favicon : 'favicon.ico';
if (file_exists(GEMS_WEB_DIR . '/' . $icon)) {
$this->view->headLink(
array(
'rel' => 'shortcut icon',
... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutGroupSwitcher(array $args = null)
{
if ($this->currentUser->isActive() && $this->currentUser->hasPrivilege('pr.group.switch', false)) {
$groups = $this->currentUser->getAllowedStaffGroups(false);
if (count($groups) > 1) {
// Group switcher
... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutJQuery()
{
// JQUERY
if (\MUtil_JQuery::usesJQuery($this->view)) {
$jquery = $this->view->jQuery();
$jquery->uiEnable(); // enable user interface
$jqueryCss = isset($this->project->jquerycss) ? (array) $this->project->jquerycss : [];
... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutLocaleSet(array $args = null)
{
// LOCALE
$currentUri = base64_encode($this->view->url());
$localeDiv = \MUtil_Html::create('div', $args, array('id' => 'languages'));
// There will always be a localeDiv, but it can be empty
if (isset($this->project-... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutLogin(array $args = null)
{
// During error reporting the user or menu are not always known.
if ($this->currentUser && $this->menu) {
$div = \MUtil_Html::create('div', array('id' => 'login'), $args);
$p = $div->p();
if ($this->currentUse... | Display either a link to the login screen or displays the name of the current user
and a logoff link.
Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the... | entailment |
protected function _layoutMenuHtml()
{
// ACL && Menu
if ($this->menu && $this->menu->isVisible()) {
// Make sure the actual $request and $controller in use at the end
// of the dispatchloop is used and make \Zend_Navigation object
return $this->menu->render($thi... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutNavigation()
{
// ACL && Menu
if ($this->menu && $this->menu->isVisible()) {
// Make sure the actual $request and $controller in use at the end
// of the dispatchloop is used and make \Zend_Navigation object
$nav = $this->menu->toZendNav... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutOrganizationSwitcher(array $args = null)
{
if ($this->currentUser->isActive() && ($orgs = $this->currentUser->getAllowedOrganizations())) {
if (count($orgs) > 1) {
// Organization switcher
return $this->getUiSwitcher($orgs, $this->current... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutProjectName(array $args = null)
{
if (isset($args['tagName'])) {
$tagName = $args['tagName'];
unset($args['tagName']);
} else {
$tagName = 'h1';
}
return \MUtil_Html::create($tagName, $this->project->name, $args);
} | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutTitle(array $args = null)
{
if (is_array($args) && array_key_exists('separator', $args)) {
$separator = $args['separator'];
} else {
$separator = ' - ';
}
if ($this->controller instanceof \MUtil_Controller_Action) {
if ($... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutUser(array $args = null)
{
if ($this->currentUser->isActive()) {
return \MUtil_Html::create()->div(
sprintf($this->_('User: %s'), $this->currentUser->getFullName()),
$args,
array('id' => 'username')
);
... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _layoutVersion(array $args = null)
{
$div = \MUtil_Html::create()->div($args, array('id' => 'version'));
if ($this->currentUser->isActive()) {
$version = $this->loader->getVersions()->getVersion();
} else {
$version = $this->loader->getVersions()->g... | Function called if specified in the Project.ini layoutPrepare section before
the layout is drawn, but after the rest of the program has run it's course.
@return mixed If null nothing is set, otherwise the name of
the function is used as \Zend_View variable name. | entailment |
protected function _updateVariable($name)
{
if (!$this->_copyDestinations) {
return;
}
$names = (array) $name;
foreach ($this->_copyDestinations as $object) {
foreach ($names as $key) {
$object->$key = $this->_container->$key;
}
... | Function to maintain uniformity of access to variables from the bootstrap object.
Updates selected variable(s) to the objects targeted in _copyVariables.
Do this when an object is created or when a non-object variable has changed.
You do not need to call this method for changes to objects .
@param String|Array $name ... | entailment |
public function addMessage()
{
$messages = \MUtil_Ra::flatten(func_get_args());
$messenger = $this->getMessenger();
foreach ($messages as $message) {
$messenger->addMessage($message);
}
return $this;
} | Adds one or more messages to the session based message store.
@param mixed ...$messages Can be an array or multiple argements. Each sub element is a single message string
@return \MUtil_Controller_Action | entailment |
public function controllerBeforeAction(\Zend_Controller_Action $actionController = null)
{
// Test for Zend_Session::$_unitTestEnabled: db is not yet loaded in tests
if (method_exists($actionController, 'getRespondent') && (!\Zend_Session::$_unitTestEnabled)) {
$this->accesslog->logReque... | Hook 10: Called before the $controller->preDispatch() and $controller->{name}Action
methods have been called.
Here you can change or check all values set in $controller->init(). All output echoed
here is captured for the output.
Previous hook: controllerInit()
Actions since: $controller->init(); ob_start(); $controll... | entailment |
public function controllerInit(\Zend_Controller_Action $actionController = null)
{
$this->_copyVariables($actionController ? $actionController : $this->controllerAfterAction);
$this->prepareController();
$imgUrl = $this->getUtil()->getImageUri('datepicker.png');
$jstUrl = $this->ba... | Hook 9: During action controller initialization.
This hook is called in the constructor of the controller. Nothing is done and
$controller->init has not been called, so this is a good moment to change settings
that should influence $controller->init().
Previous hook: preDispatch()
Actions since: $dispatcher->dispatch... | entailment |
protected function createProjectClass($className)
{
$arguments = func_get_args();
array_shift($arguments);
return $this->_projectLoader->createClass($className, $arguments);
} | Creates an object of the specified className seareching the loader dirs path
@param string $className
@param mixed ...$arguments Optional parameters
@return object | entailment |
public function dispatchLoopStartup(\Zend_Controller_Request_Abstract $request)
{
// Check the installation
if (! isset($this->db)) {
$this->setException(new \Gems_Exception_Coding(
'No database registered in ' . GEMS_PROJECT_NAME . 'Application.ini for key resources.... | Hook 7: Called before \Zend_Controller_Front enters its dispatch loop.
This events enables you to adjust the request after the routing has been done.
This is the final hook before the dispatchLoop starts. All the hooks in the dispatchLoop
can be executed more then once.
Not yet initialized is the $controller object ... | entailment |
public function getDatabasePaths()
{
$path = APPLICATION_PATH . '/configs/db';
if (file_exists($path)) {
$paths[] = array(
'path' => $path,
'name' => GEMS_PROJECT_NAME,
'db' => $this->db,
);
}
$path = GEMS... | Return the directories where the Database Administrator Model (DbaModel)
should look for sql creation files.
@return array Of index => array('path' =>, 'name' =>, 'db' =>,) | entailment |
public function getMessenger()
{
if (! isset($this->view->messenger)) {
$this->view->messenger = $this->loader->getMessenger();
}
return $this->view->messenger;
} | Retrieves / sets the messenger
@return \Zend_Controller_Action_Helper_FlashMessenger | entailment |
public function hasPrivilege($privilege, $role = null)
{
if (is_null($role)) $role = $this->session->user_role;
return (! $this->acl) || $this->acl->isAllowed($role, null, $privilege);
} | Returns true if the given role or role of the current user has the given privilege
@param string $privilege
@param string $role
@return bool
@deprecated Since 1.7.2 Replaced by $this->currentUser->hasPrivilege(); | entailment |
protected function includeFile($fileName)
{
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
if (! $extension) {
$extension = $this->findExtension($fileName, array('inc', 'ini', 'php', 'xml'));
$fileName .= '.' . $extension;
}
if (file_exists($fileName)... | Searches and loads ini, xml, php or inc file
When no extension is specified the system looks for a file with the right extension,
in the order: .ini, .php, .xml, .inc.
.php and .inc files run within the context of this object and thus can access all
$this-> variables and functions.
@param string $fileName A filename... | entailment |
public function isAllowedHost($fullHost)
{
$host = \MUtil_String::stripToHost($fullHost);
$request = $this->request;
if ($request instanceof \Zend_Controller_Request_Http) {
if ($host == \MUtil_String::stripToHost($request->getServer('HTTP_HOST'))) {
return true;
... | Is the host name one allowed by the system
@param string $fullHost
@return boolean | entailment |
public function passwordHash($value, $isNew = false, $name = null, array $context = array())
{
return $this->project->getValueHash($value);
} | Return a hashed version of the input value.
@deprecated Since 1.5
@param string $value The value to hash.
@param boolean $new Optional is new, is here for ModelAbstract setOnSave compatibility
@param string $name Optional name, is here for ModelAbstract setOnSave compatibility
@param array $context Optional, the othe... | entailment |
public function getRandomPassword()
{
$salt = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ0123456789";
$pass = "";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7)
{
$num = rand() % strlen($salt);
$tmp = substr($salt, $num, 1);... | Generate random password
@return string | entailment |
public function postDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request->isDispatched()) {
$headers = $this->project->getResponseHeaders();
foreach ($headers as $name => $value) {
$this->response->setHeader($name, $value, true);
}
... | Hook 12: Called after an action is dispatched by \Zend_Controller_Dispatcher.
This callback allows for proxy or filter behavior. By altering the
request and resetting its dispatched flag (via {@link
\Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
a new action may be specified for dispatching... | entailment |
public function preDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
$mvc = \Zend_Layout::getMvcInstance();
if ($mvc instanceof \Zend_Layout) {
$mvc->disableLayout();
... | Hook 8: Start of dispatchLoop. Called before an action is dispatched
by \Zend_Controller_Dispatcher.
This callback allows for proxy or filter behavior. By altering the request
and resetting its dispatched flag (via {@link \Zend_Controller_Request_Abstract::setDispatched()
setDispatched(false)}), the current action may... | entailment |
public function prepareController()
{
// Do the layout switch here, when view is set the layout can still be changed, but
// Bootstrap can no longer be switched on/off
if ($this instanceof \Gems_Project_Layout_MultiLayoutInterface) {
$this->layoutSwitch();
}
if (... | Hook function called during controllerInit
return @void | entailment |
public function requestChanged(\Zend_Controller_Request_Abstract $request)
{
if ($this->project->isMultiLocale()) {
// Get the choosen language
$localeId = \Gems_Cookies::getLocale($request);
// Change when $localeId exists and is different from session
if ($... | Hook 3: Called in $this->setRequest.
All resources have been loaded and the $request object is created.
Theoretically this event can be triggered multiple times, but this does
not happen in a standard Zend application.
Not initialized are the $response and $controller objects.
Previous hook: beforeRun()
Actions sinc... | entailment |
public function routeShutdown(\Zend_Controller_Request_Abstract $request)
{
$loader = $this->getLoader();
// Load the menu. As building the menu can depend on all resources and the request, we do it here.
//
// PS: The REQUEST is needed because otherwise the locale for translate is ... | Hook 6: Called after \Zend_Controller_Router has determined the route set by the request.
This events enables you to adjust the route after the routing has run it's course.
Not initialized is the $controller object.
Previous hook: routeStartup()
Actions since: $router->route()
Actions after: nothing, but the route c... | entailment |
public function setError($message, $code = 200, $info = null, $isSecurity = false)
{
if ($isSecurity) {
$e = new \Gems_Exception_Security($message, $code, null, $info);
} else {
$e = new \Gems_Exception($message, $code, null, $info);
}
$this->setException($e);... | Create an exception for the error, depending on processing position we either
set the response exception or throw the exception if the response is
@param string $message
@param int $code
@param string $info
@param boolean $isSecurity
@throws exception | entailment |
public function setException(exception $e)
{
if (isset($this->response)) {
$this->response->setException($e);
} else {
throw $e;
}
} | Handle the exception depending on processing position we either
set the response exception or throw the exception if the response is
@param exception $e
@throws exception | entailment |
public function processTokenData(\Gems_Tracker_Token $token)
{
$tokenAnswers = $token->getRawAnswers();
if (isset($tokenAnswers['LENGTH'], $tokenAnswers['WEIGHT']) && $tokenAnswers['LENGTH'] && $tokenAnswers['WEIGHT']) {
$length = $tokenAnswers['LENGTH'] / 100;
$newValue = r... | Process the data and return the answers that should be changed.
Storing the changed values is handled by the calling function.
@param \Gems_Tracker_Token $token Gems token object
@return array Containing the changed values | entailment |
protected function _getOrganizationsList()
{
$html = new \MUtil_Html_Sequence();
$sql = '
SELECT *
FROM gems__organizations
WHERE gor_active=1 AND gor_url IS NOT NULL AND gor_task IS NOT NULL
ORDER BY gor_name';
// $organizations = ar... | A list of all participating organizations.
@return \MUtil_Html_HtmlElement | entailment |
public function aboutAction()
{
$this->initHtml();
$this->html->h3()->sprintf($this->_('About %s'), $this->project->getName());
$this->html->pInfo(\MUtil_Html_Raw::raw($this->project->getLongDescription($this->locale->getLanguage())));
$this->html->append($this->_getOrganizati... | Shows an about page | entailment |
public function gemsAction()
{
$this->initHtml();
$this->html->h3()->sprintf($this->_('About %s'), $this->_('GemsTracker'));
$this->html->pInfo($this->_(
'GemsTracker (GEneric Medical Survey Tracker) is a software package for (complex) distribution of questionnaires an... | Show screen telling people about gems | entailment |
public function indexAction()
{
$this->initHtml();
$this->html->h3($this->_('Contact'));
$this->html->h4(sprintf($this->_('The %s project'), $this->project->getName()));
$this->html->append($this->_getOrganizationsList());
$this->html->h4($this->_('Information on ... | General contact page | entailment |
public function supportAction()
{
$this->initHtml();
$this->html->h3($this->_('Support'));
$this->html->pInfo()->sprintf(
$this->_('There is more than one way to get support for %s.'),
$this->project->getName()
);
if ($url =... | Shows a support page | entailment |
public function isValid($value, $context = array())
{
if (parent::isValid($value, $context)) {
$value .= '/admin/lsrc.server.php';
if (parent::isValid($value, $context)) {
return true;
}
$this->_setValue($value);
$this... | Returns true if and only if $value meets the validation requirements
If $value fails validation, then this method returns false, and
getMessages() will return an array of messages that explain why the
validation failed.
@param mixed $value
@return boolean
@throws \Zend_Valid_Exception If validation of $value is impo... | entailment |
protected function getTabs()
{
$user = $this->loader->getCurrentUser();
$sql = "SELECT gr2o_id_organization, gr2o_patient_nr FROM gems__respondent2org WHERE gr2o_id_user = ?";
$this->defaultTab = $user->getCurrentOrganizationId();
$this->currentTab = $this->request->getParam(\MUti... | Function used to fill the tab bar
@return array tabId => label | entailment |
public function render($content)
{
$form = $this->getElement();
$view = $form->getView();
/*
* Check if this is a form that should autosubmit. If so, add script to head and onload
*/
if ($form->isAutoSubmit()) {
$form->addScript($this->localScriptFiles);
... | Render a form
Replaces $content entirely from currently set element.
@param string $content
@return string | entailment |
public function checkHasRespondents($userId, $check = false)
{
$sql = "CASE
WHEN EXISTS (SELECT * FROM gems__respondent2org WHERE gr2o_id_organization = gor_id_organization)
THEN 1
ELSE 0
END";
$values['gor_has_respondents'] = new \Zend_Db_Expr($sql);
... | Check whether the organization still has at least one respondent attached to it.
Does nothing if this is already known.
@param int $userId The current user
@return \Gems_User_Organization (continuation pattern) | entailment |
public function getAllowedUserClasses()
{
$output = $this->_allowedProjectUserClasses;
if (\Gems_User_UserLoader::USER_RADIUS !== $this->_get('gor_user_class')) {
unset($output[\Gems_User_UserLoader::USER_RADIUS]);
}
return $output;
} | Get the available user class for new users in this organization
@return array Of type class name => class label | entailment |
public function getMailFields()
{
$result['organization'] = $this->getName();
$result['organization_location'] = $this->_get('gor_location');
$result['organization_login_url'] = $this->getLoginUrl();
$result['organization_reply_name'] = $this->_get('gor_contact_name');
... | Array of field name => values for sending E-Mail
@return array | entailment |
protected function loadData($id)
{
if (\Gems_User_UserLoader::SYSTEM_NO_ORG === $id) {
$data = false;
} else {
try {
$sql = "SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1";
$data = $this->db->fetchRow($sql, intval($id)... | Load the data when the cache is empty.
@param mixed $id
@return array The array of data values | entailment |
public function setAsCurrentOrganization()
{
$organizationId = $this->getId();
if ($organizationId && (! \Gems_Cookies::setOrganization($organizationId, $this->basepath->getBasePath()))) {
throw new \Exception('Cookies must be enabled for this site.');
}
$escort = \Gems... | Set this organization as the one currently active
@return \Gems_User_Organization (continuation pattern) | entailment |
public function setHasRespondents($userId)
{
if (! $this->_get('gor_has_respondents')) {
$values['gor_has_respondents'] = 1;
$values['gor_changed'] = new \MUtil_Db_Expr_CurrentTimestamp();
$values['gor_changed_by'] = $userId;
$where = $this->db->... | Tell the organization there is at least one respondent attached to it.
Does nothing if this is already known.
@param int $userId The current user
@return \Gems_User_Organization (continuation pattern) | entailment |
private function _checkUserId($userId = null)
{
if (empty($userId) && $this->currentUser instanceof \Gems_User_User) {
$userId = $this->currentUser->getUserId();
if (0 === $userId) {
$userId = null;
}
}
return $userId;
} | Replaces a null or empty userId with that of the current user
@param int $userId
@return int | entailment |
public function createToken(array $tokenData, $userId = null)
{
$userId = $this->_checkUserId($userId);
return $this->getTokenLibrary()->createToken($tokenData, $userId);
} | Creates a new token with a new random token Id
@param array $tokenData The other new data for the token
@param int $userId Id of the user who takes the action (for logging)
@return string | entailment |
public function filterChangesOnly(array $oldValues, array &$newValues)
{
if ($newValues && $oldValues) {
// \MUtil_Echo::track($newValues);
// Remove up unchanged values
foreach ($newValues as $name => $value) {
if (array_key_exists($name, $oldValues)) {
... | Utility function for detecting unchanged values.
@param array $oldValues
@param array $newValues
@return array | entailment |
public function getAllCodeFields()
{
static $fields = false; // Using static so it will be refreshed once per request
if ($fields === false) {
$fields = array();
$model = $this->createTrackClass('Model\\FieldMaintenanceModel');
$rows = $model->load(array('gtf_... | Returns an array of all field id's for all tracks that have a code id
@return array id => code | entailment |
public function getRespondentTracks($respondentId, $organizationId, $order = array('gr2t_start_date'))
{
$select = $this->db->select()
->from('gems__respondent2track')
->joinInner('gems__tracks', 'gr2t_id_track = gtr_id_track')
->joinInner('gems__reception_cod... | Get all tracks for a respondent
Specify the optional $order to sort other than on start date
@param int $respondentId
@param int $organizationId
@param mixed $order The column(s) and direction to order by
@return \Gems_Tracker_RespondentTrack[] | entailment |
public function getSource($sourceData)
{
if (is_array($sourceData)) {
$sourceId = $sourceData['gso_id_source'];
} else {
$sourceId = $sourceData;
$sourceData = false;
}
if (! isset($this->_sources[$sourceId])) {
if (! $sourceData) {
... | Retrieve a SourceInterface with a given id
Should only be called by \Gems_Tracker, \Gems_Tracker_Survey or \Gems_Tracker_Token (or should
this one use \Gems_Tracker_Survey instead?)
@param mixed $sourceData Gems source id or array containing gems source data
@return \Gems_Tracker_Source_SourceInterface | entailment |
public function getTokenLibrary()
{
if (! $this->_tokenLibrary) {
$this->_tokenLibrary = $this->_loadClass('Token_TokenLibrary', true);
}
return $this->_tokenLibrary;
} | Use this function only within \Gems_Tracker!!
@return \Gems_Tracker_Token_TokenLibrary | entailment |
public function getTokenModel($modelClass = 'StandardTokenModel')
{
if (! isset($this->_tokenModels[$modelClass])) {
$this->_tokenModels[$modelClass] = $this->_loadClass('Model_' . $modelClass, true);
$this->_tokenModels[$modelClass]->applyFormatting();
}
return $thi... | Returns a token model of the specified class with full display information
@param string $modelClass Optional class to use instead of StandardTokenModel. Must be subclass.
@return \Gems_Tracker_Model_StandardTokenModel | entailment |
public function getTokenSelect($fields = '*')
{
return $this->_loadClass('Token_TokenSelect', true, array($this->db, $fields, $this->loader->getUtil()));
} | Create a select statement on the token table
@return \Gems_Tracker_Token_TokenSelect | entailment |
public function getTrackDisplayGroups()
{
return array(
'tracks' => $this->translate->_('Tracks'),
'respondents' => $this->translate->_('Respondent'),
'staff' => $this->translate->_('Staff'),
);
} | Get the allowed display groups for tracks in this project.
@return array | entailment |
public function getTrackEngineClasses()
{
static $dummyClasses;
if (! $dummyClasses) {
$dummyTrackData['gtr_id_track'] = 0;
foreach ($this->getTrackEngineClassNames() as $className) {
$dummyClasses[$className] = $this->_loadClass('Engine_' . $className, true... | Returns dummy objects for all registered track engines class names
Instead of creating another object layer all classes defined by
getTrackEngineClassNames() are loaded with dummy data so that the
TrackEngineInterface functions containing general class information
can be used.
@see getTrackEngineClassNames()
@static... | entailment |
public function getTrackEngineList($extended = false, $userCreatableOnly = false)
{
$results = array();
$dummyTrackData['gtr_id_track'] = 0;
foreach ($this->getTrackEngineClasses() as $className => $cls) {
if ((! $userCreatableOnly) || $cls->isUserCreatable()) {
... | Returns all registered track engines classes for use in drop down lists.
@param boolean $extended When true return a longer name.
@param boolean $userCreatableOnly Return only the classes that can be created by the user interface
@return array Of classname => description | entailment |
public function loadCompletedTokensBatch(\Gems_Task_TaskRunnerBatch $batch, $respondentId = null, $userId = null, $orgId = null, $quickCheck = false)
{
$userId = $this->_checkUserId($userId);
$tokenSelect = $this->getTokenSelect(array('gto_id_token'));
$tokenSelect->onlyActive($quickCheck)
... | Checks the token table to see if there are any answered surveys to be processed and loads those tasks
If the survey was started (and the token was forwarded to limesurvey) we need to check
if is was completed. If so, we might want to check the track the survey is in to enable
or disable future rounds
Does not reflect... | entailment |
public function processCompletedTokens($respondentId, $userId = null, $orgId = null, $quickCheck = false)
{
$batch = $this->loader->getTaskRunnerBatch('completed');
if (! $batch->isLoaded()) {
$this->loadCompletedTokensBatch($batch, $respondentId, $userId, $orgId, $quickCheck);
... | Checks the token table to see if there are any answered surveys to be processed
If the survey was started (and the token was forwarded to limesurvey) we need to check
if is was completed. If so, we might want to check the track the survey is in to enable
or disable future rounds
Does not reflect changes to tracks or ... | entailment |
protected function processTokensBatch($batch_id, \Gems_Tracker_Token_TokenSelect $tokenSelect, $userId)
{
$where = implode(' ', $tokenSelect->getSelect()->getPart(\Zend_Db_Select::WHERE));
$batch = $this->loader->getTaskRunnerBatch($batch_id);
//Now set the step duration
$batch->mi... | Checks the token table to see if there are any answered surveys to be processed
If the survey was started (and the token was forwarded to limesurvey) we need to check
if is was completed. If so, we might want to check the track the survey is in to enable
or disable future rounds
Does not reflect changes to tracks or ... | entailment |
public function recalculateTokens($batch_id, $userId = null, $cond = null)
{
$userId = $this->_checkUserId($userId);
$tokenSelect = $this->getTokenSelect(array('gto_id_token'));
$tokenSelect->andReceptionCodes(array())
->andRespondents(array())
->andRe... | Recalculates all token dates, timing and results
and outputs text messages.
Does not reflect changes to tracks or rounds.
@param string $batch_id A unique identifier for the current batch
@param int $userId Id of the user who takes the action (for logging)
@param string $cond
@return \Gems_Task_TaskRunnerBatch A batc... | entailment |
public function recalcTrackFields($batchId, $cond = null)
{
$respTrackSelect = $this->db->select();
$respTrackSelect->from('gems__respondent2track', array('gr2t_id_respondent_track'));
$respTrackSelect->join('gems__reception_codes', 'gr2t_reception_code = grc_id_reception_code', array());
... | Recalculates the fields in tracks.
Does recalculate changed tracks
@param string $batchId A unique identifier for the current batch
@param string $cond Optional where statement for selecting tracks
@return \Gems_Task_TaskRunnerBatch A batch to process the changes | entailment |
public function refreshTokenAttributes($batch_id, $cond = null)
{
$batch = $this->loader->getTaskRunnerBatch($batch_id);
if (! $batch->isLoaded()) {
$tokenSelect = $this->getTokenSelect(array('gto_id_token'));
$tokenSelect->andSurveys(array())
->forWh... | Refreshes the tokens in the source
@param string $batch_id A unique identifier for the current batch
@param string $cond An optional where statement
@return \Gems_Task_TaskRunnerBatch A batch to process the changes | entailment |
public function removeToken($token)
{
if ($token instanceof \Gems_Tracker_Token) {
$tokenId = $token->getTokenId();
} else {
$tokenId = $token;
}
unset($this->_tokens[$tokenId]);
return $this;
} | Remove token from cache for saving memory
@param string|\Gems_Tracker_Token $token
@return \Gems_Tracker (continuation pattern) | entailment |
public function synchronizeSources($sourceId = null, $userId = null)
{
$batch_id = 'source_synch' . ($sourceId ? '_' . $sourceId : '');
$batch = $this->loader->getTaskRunnerBatch($batch_id);
if (! $batch->isLoaded()) {
if ($sourceId) {
$sources = array($sourceId)... | Recalculates all token dates, timing and results
and outputs text messages.
Does not reflect changes to tracks or rounds.
@param int $sourceId A source identifier
@param int $userId Id of the user who takes the action (for logging)
@return \Gems_Task_TaskRunnerBatch A batch to process the synchronization | entailment |
public function afterRegistry()
{
parent::afterRegistry();
$this->contentTitle = sprintf($this->_('Rounds in %s track'), $this->trackEngine->getTrackName());
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
public function checkRegistryRequestsAnswers()
{
return $this->db instanceof \Zend_Db_Adapter_Abstract &&
$this->logger instanceof \Gems_Log &&
$this->project instanceof \Gems_Project_ProjectSettings &&
$this->tracker instanceof \Gems_Tracker_TrackerInterface ... | 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 isValid($value)
{
if ($throttleSettings = $this->project->getAskThrottleSettings()) {
// Prune the database for (very) old attempts
$where = $this->db->quoteInto(
"gta_datetime < DATE_SUB(NOW(), INTERVAL ? second) AND gta_activated = 0",
... | Returns true if and only if $value meets the validation requirements
If $value fails validation, then this method returns false, and
getMessages() will return an array of messages that explain why the
validation failed.
@param mixed $value
@return boolean
@throws \Zend_Valid_Exception If validation of $value is impo... | entailment |
protected function isValidToken($value)
{
// Make sure the value has the right format
$value = $this->tracker->filterToken($value);
$library = $this->tracker->getTokenLibrary();
$format = $library->getFormat();
$reuse = $library->hasReuse() ? $library->getReuse() : -1;
... | Seperate the incorrect tokens from the right tokens
@param mixed $value
@return boolean | entailment |
public function formatDetailed($value)
{
//\MUtil_Echo::track($value);
if (is_array($value)) {
$group = $this->currentUser->getGroup();
if ($group) {
$value = $group->applyGroupToData($value);
}
}
return parent::formatDetailed($va... | Displays the content
@param string $value
@return string | entailment |
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
$elements = $elements + $this->getExportTypeElements($data);
$elements[] = null;
return $elements;
} | Creates the form itself
@param array $options
@return \Gems_Form
/
protected function createForm($options = null)
{
$form = parent::createForm($options);
$form->setAction($this->basepath->getBasePath() . '/' .
$this->request->getControllerName() . '/' .
$this->request->getActionName() .
'/step/batch');
return $form;... | entailment |
protected function getExportTypeElements(array $data)
{
$export = $this->loader->getExport();
$exportTypes = $export->getExportClasses();
if (isset($data['type'])) {
$currentType = $data['type'];
} else {
reset($exportTypes);
$currentType = key($e... | Returns export field elements for auto search.
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 or static ... | entailment |
protected function getSurveySelectElements(array $data)
{
$dbLookup = $this->util->getDbLookup();
$translated = $this->util->getTranslated();
// $noRound = array(self::NoRound => $this->_('No round description'));
// $empty = $translated->getEmptyDropdownArray()... | Returns start elements for auto search.
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 or static tekst t... | entailment |
public function init()
{
parent::init();
/**
* If not in the index action, add the following to the head section
* <meta name="robots" content="noindex">
*/
$action = $this->getRequest()->getActionName();
if ($action !== 'index') {
... | Leave on top, so we won't miss this | entailment |
protected function _initToken()
{
if ($this->tracker) {
return $this->token && $this->token->exists;
}
$this->tracker = $this->loader->getTracker();
$this->tokenId = $this->tracker->filterToken($this->_getParam(\MUtil_Model::REQUEST_ID));
// Now check if the toke... | Common handler utility to initialize tokens from parameters
@return boolean True if there is a real token specified in the request | entailment |
protected function displayTokenForm(\Gems_Tracker_Form_AskTokenForm $form)
{
$form->setDescription(sprintf($this->_('Enter your %s token'), $this->project->name));
$this->html->h3($form->getDescription());
$this->html[] = $form;
$this->html->pInfo($this->_('Tokens identify a survey t... | Function for overruling the display of the login form.
@param \Gems_Tracker_Form_AskTokenForm $form | entailment |
public function forwardAction()
{
/**************
* Find token *
**************/
if (! $this->_initToken()) {
if ($this->tokenId) {
// There is a token but is incorrect
$this->addMessage(sprintf(
$this->_('The tok... | Show the user a screen with token information and a button to take at least one survey
@return void | entailment |
public function indexAction()
{
if ($this->util->getMaintenanceLock()->isLocked()) {
$this->addSnippet($this->maintenanceModeSnippets);
return;
}
// Make sure to return to the forward screen
$this->currentUser->setSurveyReturn();
$request = $this->ge... | Ask the user for a token
@return void | entailment |
public function returnAction()
{
if (! $this->_initToken()) {
// In all other cases: the action that generates meaningfull warnings and is reachable for everyone
$this->_forward('forward');
return;
}
if ($url = $this->token->getReturnUrl()) {
... | The action where survey sources should return to after survey completion | entailment |
public function toSurveyAction()
{
if (! $this->_initToken()) {
// Default option
$this->_forward('index');
return;
}
$language = $this->locale->getLanguage();
try {
$url = $this->token->getUrl(
$language,
... | Go directly to url | entailment |
protected function addEscortReport()
{
$this->html->h3('Project and escort class report');
$escortClass = get_class($this->escort);
$foundNone = true;
$projectName = $this->project->getName();
$oldInterfaces = array(
'Gems_Project_Log_LogRespondentAccess... | A specific report on the escort class | entailment |
protected function addFileReport(\SplFileInfo $fileinfo)
{
// $extension = strtolower($fileinfo->getExtension());
$extension = strtolower(pathinfo($fileinfo, PATHINFO_EXTENSION));
if (('php' !== $extension) && ('phtml' !== $extension)) {
return false;
}
$content ... | A specific report on a code file
@param \SplFileInfo $filename
@return boolean | entailment |
protected function addFileReports()
{
$sCode = $this->html->sequence();
$output = false;
$filenames = $this->_getFilenames();
foreach ($filenames as $filename) {
$output = $this->addFileReport($filename) || $output;
}
if ($this->appNamespaceError) {
... | A reports on code files | entailment |
protected function addProjectIniReport()
{
$h3 = $this->html->h3();
$issues = false;
if (! $this->project->offsetExists('headers')) {
$this->html->pInfo('No headers section found.');
$issues = true;
}
if (!$this->project->offsetExists('meta')) {
... | A reports on the project ini | entailment |
public function afterRegistry()
{
$this->codeVersion = $this->loader->getVersions()->getBuild();
foreach ($this->escort->getLoaderDirs() as $prefix => $dir) {
$this->projectDirs[$prefix . '_'] = $prefix;
}
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function getRecursiveDirectoryIterator($dir)
{
return new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($dir, \FilesystemIterator::CURRENT_AS_FILEINFO),
\RecursiveIteratorIterator::SELF_FIRST,
\RecursiveIteratorIterator::CATCH_GET_CHILD... | Iterator for looping thorugh all files in a directory and i's sub directories
@param string $dir
@return \RecursiveIteratorIterator | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$this->html = $this->getHtmlSequence();
$versions = $this->loader->getVersions();
$this->html->h2(sprintf(
'Upgrade compatibility report for GemsTracker %s, build %d',
$versions->getGemsVersion(),
... | 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 render($content)
{
$useBootstrap = \MUtil_Bootstrap::enabled();
if ((null === ($element = $this->getElement())) ||
(null === ($view = $element->getView()))) {
return $content;
}
$cellDecorators = $this->getCellDecorators();
... | Render the element
@param string $content Content to decorate
@return string | entailment |
public function setOption($key, $value)
{
switch ($key) {
case 'cellDecorator':
$value = $this->getCellDecorators() + array($value);
case 'cellDecorators':
$this->_cellDecorators = $value;
break;
default:
... | Set a single option
@param string $key
@param mixed $value
@return \Zend_Form_Decorator_Interface | entailment |
public function getChanges(array $context, $new)
{
$conditions = $this->loader->getConditions();
if (isset($context['gcon_type'],$context['gcon_class']) && !empty($context['gcon_class'])) {
$condition = $conditions->loadConditionForType($context['gcon_type'],$context['gcon_class']);
... | 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 |
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$bridge->tr()->class = $bridge->row_class;
if ($showMenuItem = $this->getShowMenuItem()) {
$bridge->addItemLink($showMenuItem->toActionLinkLower($this->request, $bridge... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.