本文整理汇总了PHP中Gems_Loader::getCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Gems_Loader::getCurrentUser方法的具体用法?PHP Gems_Loader::getCurrentUser怎么用?PHP Gems_Loader::getCurrentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gems_Loader
的用法示例。
在下文中一共展示了Gems_Loader::getCurrentUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterRegistry
/**
* Called after the check that all required registry values
* have been set correctly has run.
*
* @return void
*/
public function afterRegistry()
{
parent::afterRegistry();
if (!$this->user) {
$this->user = $this->loader->getCurrentUser();
}
}
示例2: getAutoSearchElements
/**
* 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 or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
$dbLookup = $this->util->getDbLookup();
$translated = $this->util->getTranslated();
$noRound = array(self::NoRound => $this->_('No round description'));
$empty = $translated->getEmptyDropdownArray();
$rounds = $empty + $noRound + $dbLookup->getRoundsForExport();
$surveys = $dbLookup->getSurveysForExport();
$elements[] = $this->_createSelectElement('gto_id_survey', $surveys, $this->_('(select a survey)'));
$elements[] = $this->_createSelectElement('gto_id_track', $this->util->getTrackData()->getAllTracks(), $this->_('(select a track)'));
$elements[] = $this->_createSelectElement('gto_round_description', $rounds, $this->_('(select a round)'));
$orgs = $this->loader->getCurrentUser()->getRespondentOrganizations();
if (count($orgs) > 1) {
$elements[] = $this->_createSelectElement('gto_id_organization', $orgs, $this->_('(all organizations)'));
}
$elements[] = null;
$dates = array('gto_start_date' => $this->_('Track start'), 'gto_end_date' => $this->_('Track end'), 'gto_valid_from' => $this->_('Valid from'), 'gto_valid_until' => $this->_('Valid until'));
// $dates = 'gto_valid_from';
$this->_addPeriodSelectors($elements, $dates, 'gto_valid_from');
$elements[] = null;
$element = $this->form->createElement('checkbox', 'column_identifiers');
$element->setLabel($this->_('Column Identifiers'));
$element->setDescription($this->_('Prefix the column labels with an identifier. (A) Answers, (TF) Trackfields, (D) Description'));
$elements[] = $element;
$element = $this->form->createElement('checkbox', 'show_parent');
$element->setLabel($this->_('Show parent'));
$element->setDescription($this->_('Show the parent column even if it doesn\'t have answers'));
$elements[] = $element;
$element = $this->form->createElement('checkbox', 'prefix_child');
$element->setLabel($this->_('Prefix child'));
$element->setDescription($this->_('Prefix the child column labels with parent question label'));
$elements[] = $element;
$elements[] = null;
return $elements;
}
示例3: getAutoSearchElements
/**
* 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 or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
$user = $this->loader->getCurrentUser();
if ($user->hasPrivilege('pr.respondent.select-on-track')) {
$tracks = $this->searchData['__active_tracks'];
$masks['show_all'] = $this->_('(all)');
$masks['show_without_track'] = $this->_('(no track)');
if (count($tracks) > 1) {
$masks['show_with_track'] = $this->_('(with track)');
}
if (count($tracks) > 1) {
$elements[] = $this->_createSelectElement('gr2t_id_track', $masks + $tracks);
} else {
$element = $this->_createRadioElement('gr2t_id_track', $masks + $tracks);
$element->setSeparator(' ');
$elements[] = $element;
}
$lineBreak = true;
} else {
$lineBreak = false;
}
if ($user->hasPrivilege('pr.respondent.show-deleted')) {
$elements[] = $this->_createCheckboxElement('grc_success', $this->_('Show active'));
}
if ($this->model->isMultiOrganization()) {
$element = $this->_createSelectElement(\MUtil_Model::REQUEST_ID2, $user->getRespondentOrganizations(), $this->_('(all organizations)'));
if ($lineBreak) {
$element->setLabel($this->_('Organization'))->setAttrib('onchange', 'this.form.submit();');
$elements[] = \MUtil_Html::create('br');
}
$elements[] = $element;
}
return $elements;
}
示例4: execute
/**
* 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
*/
public function execute($sourceId = null, $userId = null)
{
$batch = $this->getBatch();
$source = $this->loader->getTracker()->getSource($sourceId);
if (is_null($userId)) {
$userId = $this->loader->getCurrentUser()->getUserId();
}
$surveyCount = $batch->addToCounter('sourceSyncSources');
$batch->setMessage('sourceSyncSources', sprintf($this->plural('Check %s source', 'Check %s sources', $surveyCount), $surveyCount));
$source->synchronizeSurveyBatch($batch, $userId);
}
示例5: getAutoSearchElements
/**
* 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 or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
$this->_addPeriodSelectors($elements, 'gla_created');
$elements[] = null;
$elements[] = $this->_('Specific action');
$sql = "SELECT gls_id_action, gls_name\n FROM gems__log_setup\n WHERE gls_when_no_user = 1 OR gls_on_action = 1 OR gls_on_change = 1 OR gls_on_post = 1\n ORDER BY gls_name";
$elements[] = $this->_createSelectElement('gla_action', $sql, $this->_('(any action)'));
$elements[] = $this->_createSelectElement('gla_organization', $this->loader->getCurrentUser()->getAllowedOrganizations(), $this->_('(all organizations)'));
return $elements;
}
示例6: getAutoSearchElements
/**
* 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 or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
// Search text
$elements = parent::getAutoSearchElements($data);
$this->_addPeriodSelectors($elements, array('grco_created' => $this->_('Date sent')));
$br = \MUtil_Html::create()->br();
$elements[] = null;
$dbLookup = $this->util->getDbLookup();
$elements[] = $this->_createSelectElement('gto_id_track', $this->util->getTrackData()->getAllTracks(), $this->_('(select a track)'));
$elements[] = $this->_createSelectElement('gto_id_survey', $this->util->getTrackData()->getAllSurveys(), $this->_('(all surveys)'));
$elements[] = $this->_createSelectElement('grco_organization', $this->loader->getCurrentUser()->getRespondentOrganizations(), $this->_('(all organizations)'));
return $elements;
}
示例7: getAutoSearchElements
/**
* 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 or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
$elements[] = $this->_createSelectElement('gto_id_track', $this->util->getTrackData()->getAllTracks(), $this->_('(select a track)'));
$orgs = $this->loader->getCurrentUser()->getRespondentOrganizations();
if (count($orgs) > 1) {
$elements[] = $this->_createSelectElement('gto_id_organization', $orgs, $this->_('(all organizations)'));
}
$elements[] = null;
$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'));
// $dates = 'gto_valid_from';
$this->_addPeriodSelectors($elements, $dates, 'gto_valid_from');
$elements[] = null;
$sql = "SELECT DISTINCT ggp_id_group, ggp_name\n FROM gems__groups INNER JOIN gems__surveys ON ggp_id_group = gsu_id_primary_group\n INNER JOIN gems__rounds ON gsu_id_survey = gro_id_survey\n INNER JOIN gems__tracks ON gro_id_track = gtr_id_track\n WHERE ggp_group_active = 1 AND\n gro_active=1 AND\n gtr_active=1\n ORDER BY ggp_name";
$elements[] = $this->_createSelectElement('gsu_id_primary_group', $sql, $this->_('(all fillers)'));
return $elements;
}
示例8: saveData
/**
* Hook containing the actual save code.
*
* Call's afterSave() for user interaction.
*
* @see afterSave()
*/
protected function saveData()
{
$this->beforeSave();
$changed = $this->setReceptionCode($this->formData[$this->receptionCodeItem], $this->loader->getCurrentUser()->getUserId());
$this->afterSave($changed);
$this->accesslog->logChange($this->request, null, $this->formData);
}
示例9: getTabs
/**
* Function used to fill the tab bar
*
* @return array tabId => label
*/
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(\MUtil_Model::REQUEST_ID2);
$allowedOrgs = $user->getRespondentOrganizations();
$existingOrgs = $this->db->fetchPairs($sql, $this->respondent->getId());
$tabs = array();
foreach ($allowedOrgs as $orgId => $name) {
if (isset($existingOrgs[$orgId])) {
$tabs[$orgId] = $name;
$this->hrefs[$orgId] = array(\MUtil_Model::REQUEST_ID1 => $existingOrgs[$orgId], \MUtil_Model::REQUEST_ID2 => $orgId, 'RouteReset' => true);
}
}
return $tabs;
}
示例10: execute
/**
* 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
*/
public function execute($sourceId = null, $sourceSurveyId = null, $surveyId = null, $userId = null)
{
$batch = $this->getBatch();
$source = $this->loader->getTracker()->getSource($sourceId);
if (null === $userId) {
$userId = $this->loader->getCurrentUser()->getUserId();
}
$messages = $source->checkSurvey($sourceSurveyId, $surveyId, $userId);
$batch->addToCounter('checkedSurveys');
$batch->addToCounter('changedSurveys', $messages ? 1 : 0);
$batch->setMessage('changedSurveys', sprintf($this->_('%d of %d surveys changed.'), $batch->getCounter('changedSurveys'), $batch->getCounter('checkedSurveys')));
if ($messages) {
foreach ((array) $messages as $message) {
$batch->addMessage($message);
}
}
}
示例11: applySettings
/**
*
* @param boolean $detailed True when the current action is not in $summarizedActions.
* @param string $action The current action.
* @param int $defaultOrgId The default organization id or null if current organization
* @return \Gems_Model_StaffModel
*/
public function applySettings($detailed, $action, $defaultOrgId)
{
$this->resetOrder();
$dbLookup = $this->util->getDbLookup();
$editing = $action == 'edit' || $action == 'create';
$translated = $this->util->getTranslated();
$user = $this->loader->getCurrentUser();
$yesNo = $translated->getYesNo();
if ($editing) {
$ucfirst = new \Zend_Filter_Callback('ucfirst');
if ($this->project->isLoginShared()) {
$this->set('gsf_login', 'validator', $this->createUniqueValidator('gsf_login', array('gsf_id_user')));
} else {
// per organization
$this->set('gsf_login', 'validator', $this->createUniqueValidator(array('gsf_login', 'gsf_id_organization'), array('gsf_id_user')));
}
} else {
$ucfirst = null;
}
$this->set('gsf_login', 'label', $this->_('Username'), 'minlength', 4, 'required', true, 'size', 15);
if ($user->hasPrivilege('pr.staff.see.all') || !$editing) {
// Select organization
$options = $dbLookup->getOrganizations();
} else {
$options = $user->getAllowedOrganizations();
}
$this->set('gsf_id_organization', 'label', $this->_('Organization'), 'multiOptions', $options, 'required', true);
if ($detailed) {
$this->set('gsf_first_name', 'label', $this->_('First name'), 'filters[ucfirst]', $ucfirst);
$this->set('gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', $this->_('de, van der, \'t, etc...'));
$this->set('gsf_last_name', 'label', $this->_('Last name'), 'required', true, 'filters[ucfirst]', $ucfirst);
} else {
$this->set('name', 'label', $this->_('Name'));
}
$this->set('gsf_gender', 'label', $this->_('Gender'), 'elementClass', 'Radio', 'multiOptions', $translated->getGenders(), 'separator', ' ');
$this->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', array('MUtil_Html_AElement', 'ifmail'), 'size', 30, 'validators[email]', 'SimpleEmail');
$this->set('gsf_id_primary_group', 'label', $this->_('Primary function'), 'multiOptions', $editing ? $user->getAllowedStaffGroups() : $dbLookup->getStaffGroups());
if ($detailed) {
// Now try to load the current organization and find out if it has a default user definition
// otherwise use the defaultStaffDefinition
$organization = $this->loader->getOrganization($defaultOrgId ? $defaultOrgId : $user->getCurrentOrganizationId());
$this->set('gsf_id_organization', 'default', $organization->getId());
$this->set('gul_user_class', 'label', $this->_('User Definition'), 'default', $organization->get('gor_user_class', $this->defaultStaffDefinition), 'multiOptions', $this->loader->getUserLoader()->getAvailableStaffDefinitions());
if ($editing) {
$this->set('gul_user_class', 'order', 1, 'required', true);
}
$this->set('gsf_iso_lang', 'label', $this->_('Language'), 'default', $this->project->locale['default'], 'multiOptions', $this->util->getLocalized()->getLanguages());
$this->set('gul_can_login', 'label', $this->_('Can login'), 'default', 1, 'description', $this->_('Users can only login when this box is checked.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo);
$this->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'description', $this->_('If checked the user will logoff when answering a survey.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo);
$this->set('gsf_mail_watcher', 'label', $this->_('Check cron job mail'), 'description', $this->_('If checked the user will be mailed when the cron job does not run on time.'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo);
}
$this->set('gsf_active', 'label', $this->_('Active'), 'elementClass', 'None', 'multiOptions', $yesNo);
$this->setDeleteValues('gsf_active', 0, 'gul_can_login', 0);
if (!$user->hasPrivilege('pr.staff.edit.all')) {
$this->set('gsf_id_organization', 'elementClass', 'Exhibitor');
}
return $this;
}
示例12: getHtmlOutput
/**
* 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
*/
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$html = $this->getHtmlSequence();
$html->h3($this->_('Choose an organization'));
$user = $this->loader->getCurrentUser();
$url[$this->request->getControllerKey()] = 'organization';
$url[$this->request->getActionKey()] = 'change-ui';
if ($orgs = $user->getRespondentOrganizations()) {
$html->pInfo($this->_('This organization cannot have any respondents, please choose one that does:'));
foreach ($orgs as $orgId => $name) {
$url['org'] = $orgId;
$html->pInfo()->actionLink($url, $name)->appendAttrib('class', 'larger');
}
} else {
$html->pInfo($this->_('This organization cannot have any respondents.'));
}
return $html;
}
示例13: getAutoSearchElements
/**
* 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 or static tekst to add to the html or null for group breaks.
*/
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
if ($elements) {
$br = \MUtil_Html::create('br');
$elements[] = $this->_createSelectElement('gtr_track_class', $this->model, $this->_('(all track engines)'));
$elements[] = $br;
$optionsA = $this->util->getTranslated()->getYesNo();
$elementA = $this->_createSelectElement('gtr_active', $optionsA, $this->_('(both)'));
$elementA->setLabel($this->model->get('gtr_active', 'label'));
$elements[] = $elementA;
$user = $this->loader->getCurrentUser();
$optionsO = $user->getRespondentOrganizations();
$elementO = $this->_createSelectElement('org', $optionsO, $this->_('(all organizations)'));
$elements[] = $elementO;
}
return $elements;
}
示例14: hasHtmlOutput
/**
* 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
*/
public function hasHtmlOutput()
{
if ($this->respondent instanceof \Gems_Tracker_Respondent) {
if (!$this->patientId) {
$this->patientId = $this->respondent->getPatientNumber();
}
if (!$this->organizationId) {
$this->organizationId = $this->respondent->getOrganizationId();
}
}
// Try to get $this->respondentTrackId filled
if (!$this->respondentTrackId) {
if ($this->respondentTrack) {
$this->respondentTrackId = $this->respondentTrack->getRespondentTrackId();
} else {
$this->respondentTrackId = $this->request->getParam(\Gems_Model::RESPONDENT_TRACK);
}
}
// Try to get $this->respondentTrack filled
if ($this->respondentTrackId && !$this->respondentTrack) {
$this->respondentTrack = $this->loader->getTracker()->getRespondentTrack($this->respondentTrackId);
}
// Set the user id
if (!$this->userId) {
$this->userId = $this->loader->getCurrentUser()->getUserId();
}
if ($this->respondentTrack) {
// We are updating
$this->createData = false;
// Try to get $this->trackEngine filled
if (!$this->trackEngine) {
// Set the engine used
$this->trackEngine = $this->respondentTrack->getTrackEngine();
}
} else {
// We are inserting
$this->createData = true;
$this->saveLabel = $this->_($this->_('Add track'));
// Try to get $this->trackId filled
if (!$this->trackId) {
if ($this->trackEngine) {
$this->trackId = $this->trackEngine->getTrackId();
} else {
$this->trackId = $this->request->getParam(\Gems_Model::TRACK_ID);
}
}
// Try to get $this->trackEngine filled
if ($this->trackId && !$this->trackEngine) {
$this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->trackId);
}
if (!($this->trackEngine && $this->patientId && $this->organizationId && $this->userId)) {
throw new \Gems_Exception_Coding('Missing parameter for ' . __CLASS__ . ': could not find data for editing a respondent track nor the track engine, patientId and organizationId needed for creating one.');
}
}
return parent::hasHtmlOutput();
}
示例15: execute
/**
* 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
*/
public function execute($tokenData = null, $userId = null)
{
$batch = $this->getBatch();
$tracker = $this->loader->getTracker();
$token = $tracker->getToken($tokenData);
if ($token->isCompleted()) {
$respTrack = $token->getRespondentTrack();
$userId = $userId ? $userId : $this->loader->getCurrentUser()->getUserId();
if ($result = $respTrack->handleRoundCompletion($token, $userId)) {
$a = $batch->addToCounter('roundCompletionCauses');
$b = $batch->addToCounter('roundCompletionChanges', $result);
$batch->setMessage('roundCompletionChanges', sprintf($this->_('%d token round completion events caused changed to %d tokens.'), $a, $b));
}
$trackId = $respTrack->getRespondentTrackId();
$batch->setTask('Tracker_CheckTrackTokens', 'chktrck-' . $trackId, $trackId, $userId);
}
// Free memory
$tracker->removeToken($token);
}