idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
57,600
|
public function getPreviousToken ( ) { if ( null === $ this -> _previousToken ) { $ tokenSelect = $ this -> tracker -> getTokenSelect ( ) ; $ tokenSelect -> andReceptionCodes ( ) -> forNextTokenId ( $ this -> _tokenId ) ; if ( $ tokenData = $ tokenSelect -> fetchRow ( ) ) { $ this -> _previousToken = $ this -> tracker -> getToken ( $ tokenData ) ; $ this -> _previousToken -> _nextToken = $ this ; } else { $ this -> _previousToken = false ; } } return $ this -> _previousToken ; }
|
Returns the previous token in this track
|
57,601
|
public function getRelation ( ) { if ( is_null ( $ this -> _relation ) || $ this -> _relation -> getRelationId ( ) !== $ this -> getRelationId ( ) ) { $ model = $ this -> loader -> getModels ( ) -> getRespondentRelationModel ( ) ; $ relationObject = $ model -> getRelation ( $ this -> getRespondentId ( ) , $ this -> getRelationId ( ) ) ; $ this -> _relation = $ relationObject ; } return $ this -> _relation ; }
|
Get the relation object if any
|
57,602
|
public function getRelationFieldName ( ) { if ( $ relationFieldId = $ this -> getRelationFieldId ( ) ) { $ names = $ this -> getRespondentTrack ( ) -> getTrackEngine ( ) -> getFieldNames ( ) ; $ fieldPrefix = \ Gems \ Tracker \ Model \ FieldMaintenanceModel :: FIELDS_NAME . \ Gems \ Tracker \ Engine \ FieldsDefinition :: FIELD_KEY_SEPARATOR ; $ key = $ fieldPrefix . $ relationFieldId ; return array_key_exists ( $ key , $ names ) ? lcfirst ( $ names [ $ key ] ) : null ; } return null ; }
|
Get the name of the relationfield for this token
|
57,603
|
public function getRespondent ( ) { $ patientNumber = $ this -> getPatientNumber ( ) ; $ organizationId = $ this -> getOrganizationId ( ) ; if ( ! ( $ this -> _respondentObject instanceof \ Gems_Tracker_Respondent ) || $ this -> _respondentObject -> getPatientNumber ( ) !== $ patientNumber || $ this -> _respondentObject -> getOrganizationId ( ) !== $ organizationId ) { $ this -> _respondentObject = $ this -> loader -> getRespondent ( $ patientNumber , $ organizationId ) ; } return $ this -> _respondentObject ; }
|
Get the respondent linked to this token
|
57,604
|
public function getRespondentName ( ) { if ( $ this -> hasRelation ( ) ) { if ( $ relation = $ this -> getRelation ( ) ) { return $ relation -> getName ( ) ; } else { return null ; } } return $ this -> getRespondent ( ) -> getName ( ) ; }
|
Get the name of the person answering this token
|
57,605
|
public function getRoundCode ( ) { $ roundCode = null ; $ roundId = $ this -> getRoundId ( ) ; if ( $ roundId > 0 ) { $ roundCode = $ this -> getRespondentTrack ( ) -> getRoundCode ( $ roundId ) ; } return $ roundCode ; }
|
Get the round code for this token
|
57,606
|
public function getTokenCountUnanswered ( ) { $ tokenSelect = $ this -> tracker -> getTokenSelect ( new \ Zend_Db_Expr ( 'COUNT(*)' ) ) ; $ tokenSelect -> andReceptionCodes ( array ( ) ) -> andSurveys ( array ( ) ) -> andRounds ( array ( ) ) -> forRespondent ( $ this -> getRespondentId ( ) ) -> forGroupId ( $ this -> getSurvey ( ) -> getGroupId ( ) ) -> onlySucces ( ) -> onlyValid ( ) -> forWhere ( 'gsu_active = 1' ) -> forWhere ( 'gro_active = 1 OR gro_active IS NULL' ) -> withoutToken ( $ this -> _tokenId ) ; $ this -> _addRelation ( $ tokenSelect ) ; return $ tokenSelect -> fetchOne ( ) ; }
|
Returns the number of unanswered tokens for the person answering this token minus this token itself
|
57,607
|
public function inSource ( ) { if ( $ this -> exists ) { $ survey = $ this -> getSurvey ( ) ; return $ survey -> inSource ( $ this ) ; } else { return false ; } }
|
True is this token was exported to the source .
|
57,608
|
public function isExpired ( ) { $ date = $ this -> getValidUntil ( ) ; if ( $ date instanceof \ MUtil_Date ) { return $ date -> isEarlierOrEqual ( time ( ) ) ; } return false ; }
|
True when the valid until is set and is in the past
|
57,609
|
public function isNotYetValid ( ) { $ date = $ this -> getValidFrom ( ) ; if ( $ date instanceof \ MUtil_Date ) { return $ date -> isLaterOrEqual ( time ( ) ) ; } return true ; }
|
True when the valid from is in the future or not yet set
|
57,610
|
public function setNextToken ( \ Gems_Tracker_Token $ token ) { $ this -> _nextToken = $ token ; $ token -> _previousToken = $ this ; return $ this ; }
|
Sets the next token in this track
|
57,611
|
public function setReceptionCode ( $ code , $ comment , $ userId ) { if ( ! $ code instanceof \ Gems_Util_ReceptionCode ) { $ code = $ this -> util -> getReceptionCode ( $ code ) ; } $ values [ 'gto_reception_code' ] = $ code -> getCode ( ) ; if ( $ comment ) { $ values [ 'gto_comment' ] = $ comment ; } $ changed = $ this -> _updateToken ( $ values , $ userId ) ; if ( $ changed ) { if ( $ code -> isOverwriter ( ) || ( ! $ code -> isSuccess ( ) ) ) { $ survey = $ this -> getSurvey ( ) ; if ( $ survey -> inSource ( $ this ) ) { $ survey -> updateConsent ( $ this ) ; } } } return $ changed ; }
|
Set the reception code for this token and make sure the necessary cascade to the source takes place .
|
57,612
|
public function setRoundDescription ( $ description , $ userId ) { $ values = $ this -> _gemsData ; $ values [ 'gto_round_description' ] = $ description ; return $ this -> _updateToken ( $ values , $ userId ) ; }
|
Set a round description for the token
|
57,613
|
protected function _createMultiCheckBoxElements ( $ name , $ options , $ separator = null , $ toggleLabel = null , $ breakBeforeToggle = false ) { $ elements [ $ name ] = $ this -> _createMultiElement ( 'multiCheckbox' , $ name , $ options , null ) ; if ( ! $ elements [ $ name ] ) { return [ ] ; } if ( null === $ separator ) { $ separator = ' ' ; } $ elements [ $ name ] -> setSeparator ( $ separator ) ; if ( false === $ toggleLabel ) { return $ elements ; } if ( $ breakBeforeToggle ) { $ elements [ 'break_' . $ name ] = \ MUtil_Html :: create ( 'br' ) ; } $ tName = 'toggle_' . $ name ; $ options = [ 'label' => $ toggleLabel ? $ toggleLabel : $ this -> _ ( 'Toggle' ) , 'selector' => "input[name^=$name]" , ] ; $ elements [ $ tName ] = $ this -> form -> createElement ( 'ToggleCheckboxes' , $ tName , $ options ) ; return $ elements ; }
|
Creates a \ Zend_Form_Element_MultiCheckbox
|
57,614
|
protected function getAutoSearchReset ( ) { if ( $ menuItem = $ this -> menu -> getCurrent ( ) ) { $ link = $ menuItem -> toActionLink ( $ this -> request , array ( 'reset' => 1 ) , $ this -> _ ( 'Reset search' ) ) ; $ element = new \ MUtil_Form_Element_Html ( 'reset' ) ; $ element -> setValue ( $ link ) ; return $ element ; } }
|
Creates a reset button for the search form
|
57,615
|
protected function bin ( $ program = '' ) { if ( $ location = $ this -> config ( ) -> get ( 'binary_location' ) ) { $ locations = [ $ location ] ; } else { $ locations = $ this -> config ( ) -> get ( 'search_binary_locations' ) ; } foreach ( $ locations as $ location ) { $ path = "{$location}/{$program}" ; if ( file_exists ( $ path ) ) { return $ path ; } if ( file_exists ( $ path . '.exe' ) ) { return $ path . '.exe' ; } } return null ; }
|
Accessor to get the location of the binary
|
57,616
|
protected function getRawOutput ( $ file ) { if ( ! $ this -> isAvailable ( ) ) { throw new Exception ( "getRawOutput called on unavailable extractor" ) ; } $ path = $ file instanceof File ? $ this -> getPathFromFile ( $ file ) : $ file ; exec ( sprintf ( '%s %s - 2>&1' , $ this -> bin ( 'pdftotext' ) , escapeshellarg ( $ path ) ) , $ content , $ err ) ; if ( $ err ) { if ( ! is_array ( $ err ) && $ err == 1 ) { $ err = $ content ; } throw new Exception ( sprintf ( 'PDFTextExtractor->getContent() failed for %s: %s' , $ path , implode ( PHP_EOL , $ err ) ) ) ; } return implode ( PHP_EOL , $ content ) ; }
|
Invoke pdftotext with the given File object
|
57,617
|
protected function getReadableData ( ) { $ job = $ this -> monitorJob ; $ data = $ job -> getArrayCopy ( ) ; if ( $ data [ 'setTime' ] == 0 ) return ; $ data [ 'firstCheck' ] = date ( MonitorJob :: $ monitorDateFormat , $ data [ 'firstCheck' ] ) ; $ data [ 'checkTime' ] = date ( MonitorJob :: $ monitorDateFormat , $ data [ 'checkTime' ] ) ; $ data [ 'setTime' ] = date ( MonitorJob :: $ monitorDateFormat , $ data [ 'setTime' ] ) ; $ period = $ data [ 'period' ] ; $ mins = $ period % 3600 ; $ secs = $ mins % 60 ; $ hours = ( $ period - $ mins ) / 3600 ; $ mins = ( $ mins - $ secs ) / 60 ; $ data [ 'period' ] = sprintf ( '%2d:%02d:%02d' , $ hours , $ mins , $ secs ) ; return $ data ; }
|
Create readable output
|
57,618
|
protected function getWhere ( ) { $ id = intval ( $ this -> request -> getParam ( \ MUtil_Model :: REQUEST_ID ) ) ; $ add = " = " . $ id ; return implode ( $ add . ' OR ' , ( array ) $ this -> filterOn ) . $ add ; }
|
Get the appointment where for this snippet
|
57,619
|
protected function _getData ( ) { $ versions = $ this -> loader -> getVersions ( ) ; $ data [ $ this -> _ ( 'Project name' ) ] = $ this -> project -> getName ( ) ; $ data [ $ this -> _ ( 'Project version' ) ] = $ versions -> getProjectVersion ( ) ; $ data [ $ this -> _ ( 'Gems version' ) ] = $ versions -> getGemsVersion ( ) ; $ data [ $ this -> _ ( 'Gems build' ) ] = $ versions -> getBuild ( ) ; $ data [ $ this -> _ ( 'Gems project' ) ] = GEMS_PROJECT_NAME ; $ data [ $ this -> _ ( 'Gems web directory' ) ] = $ this -> getDirInfo ( GEMS_WEB_DIR ) ; $ data [ $ this -> _ ( 'Gems root directory' ) ] = $ this -> getDirInfo ( GEMS_ROOT_DIR ) ; $ data [ $ this -> _ ( 'Gems code directory' ) ] = $ this -> getDirInfo ( GEMS_LIBRARY_DIR ) ; $ data [ $ this -> _ ( 'Gems variable directory' ) ] = $ this -> getDirInfo ( GEMS_ROOT_DIR . '/var' ) ; $ data [ $ this -> _ ( 'MUtil version' ) ] = \ MUtil_Version :: get ( ) ; $ data [ $ this -> _ ( 'Zend version' ) ] = \ Zend_Version :: VERSION ; $ data [ $ this -> _ ( 'Application environment' ) ] = APPLICATION_ENV ; $ data [ $ this -> _ ( 'Application baseuri' ) ] = $ this -> loader -> getUtil ( ) -> getCurrentURI ( ) ; $ data [ $ this -> _ ( 'Application directory' ) ] = $ this -> getDirInfo ( APPLICATION_PATH ) ; $ data [ $ this -> _ ( 'Application encoding' ) ] = APPLICATION_ENCODING ; $ data [ $ this -> _ ( 'PHP version' ) ] = phpversion ( ) ; $ data [ $ this -> _ ( 'Server Hostname' ) ] = php_uname ( 'n' ) ; $ data [ $ this -> _ ( 'Server OS' ) ] = php_uname ( 's' ) ; $ data [ $ this -> _ ( 'Time on server' ) ] = date ( 'r' ) ; $ driveVars = array ( $ this -> _ ( 'Session directory' ) => \ Zend_Session :: getOptions ( 'save_path' ) , $ this -> _ ( 'Temporary files directory' ) => realpath ( getenv ( 'TMP' ) ) , ) ; if ( $ system = getenv ( 'SystemDrive' ) ) { $ driveVars [ $ this -> _ ( 'System Drive' ) ] = realpath ( $ system ) ; } foreach ( $ driveVars as $ name => $ drive ) { $ data [ $ name ] = $ this -> getDirInfo ( $ drive ) ; } return $ data ; }
|
Returns the data to show in the index action
|
57,620
|
protected function _showText ( $ caption , $ logFile , $ emptyLabel = null , $ context = null ) { $ this -> html -> h2 ( $ caption ) ; if ( $ emptyLabel && ( 1 == $ this -> _getParam ( \ MUtil_Model :: REQUEST_ID ) ) && file_exists ( $ logFile ) ) { unlink ( $ logFile ) ; } if ( file_exists ( $ logFile ) ) { if ( is_readable ( $ logFile ) ) { $ content = trim ( file_get_contents ( $ logFile ) ) ; if ( $ content ) { $ error = false ; } else { $ error = $ this -> _ ( 'empty file' ) ; } } else { $ error = $ this -> _ ( 'file content not readable' ) ; } } else { $ content = null ; $ error = $ this -> _ ( 'file not found' ) ; } if ( $ emptyLabel ) { $ buttons = $ this -> html -> buttonDiv ( ) ; if ( $ error ) { $ buttons -> actionDisabled ( $ emptyLabel ) ; } else { $ buttons -> actionLink ( array ( \ MUtil_Model :: REQUEST_ID => 1 ) , $ emptyLabel ) ; } } if ( $ error ) { $ this -> html -> pre ( $ error , array ( 'class' => 'disabled logFile' ) ) ; } elseif ( substr ( $ logFile , - 3 ) == '.md' ) { $ parseDown = new \ Gems \ Parsedown ( $ context ) ; $ this -> html -> div ( array ( 'class' => 'logFile' ) ) -> raw ( $ parseDown -> parse ( $ content ) ) ; } else { $ this -> html -> pre ( $ content , array ( 'class' => 'logFile' ) ) ; } if ( $ emptyLabel ) { $ this -> html [ ] = $ buttons ; } }
|
Helper function to show content of a text file
|
57,621
|
public function changelogAction ( ) { $ this -> _showText ( sprintf ( $ this -> _ ( 'Changelog %s' ) , $ this -> escort -> project -> name ) , APPLICATION_PATH . '/changelog.txt' ) ; }
|
Show the project specific change log
|
57,622
|
protected function getDirInfo ( $ directory ) { if ( ! is_dir ( $ directory ) ) { return sprintf ( $ this -> _ ( '%s - does not exist' ) , $ directory ) ; } $ free = disk_free_space ( $ directory ) ; $ total = disk_total_space ( $ directory ) ; if ( ( false === $ free ) || ( false === $ total ) ) { return sprintf ( $ this -> _ ( '%s - no disk information available' ) , $ directory ) ; } $ percent = intval ( $ free / $ total * 100 ) ; return sprintf ( $ this -> _ ( '%s - %s free of %s = %d%% available' ) , $ directory , \ MUtil_File :: getByteSized ( $ free ) , \ MUtil_File :: getByteSized ( $ total ) , $ percent ) ; }
|
Tell all about it
|
57,623
|
public function maintenanceAction ( ) { if ( $ this -> util -> getMonitor ( ) -> reverseMaintenanceMonitor ( ) ) { $ this -> accesslog -> logChange ( $ this -> getRequest ( ) , $ this -> _ ( 'Maintenance mode set ON' ) ) ; } else { $ this -> accesslog -> logChange ( $ this -> getRequest ( ) , $ this -> _ ( 'Maintenance mode set OFF' ) ) ; $ this -> escort -> getMessenger ( ) -> clearCurrentMessages ( ) ; $ this -> escort -> getMessenger ( ) -> clearMessages ( ) ; \ MUtil_Echo :: out ( ) ; } $ request = $ this -> getRequest ( ) ; $ this -> _reroute ( array ( $ request -> getActionKey ( ) => 'index' ) ) ; }
|
Action that switches the maintenance lock on or off .
|
57,624
|
public function apply ( \ MUtil_Model_ModelAbstract $ model , $ valueField ) { $ model -> setSaveWhenNotNull ( $ valueField ) ; $ model -> setOnLoad ( $ valueField , array ( $ this , 'loadValue' ) ) ; $ model -> setOnSave ( $ valueField , array ( $ this , 'saveValue' ) ) ; if ( $ model instanceof \ MUtil_Model_DatabaseModelAbstract ) { $ model -> setOnTextFilter ( $ valueField , false ) ; } return $ this ; }
|
Use this function for a default application of this type to the model
|
57,625
|
public function checkConsent ( $ consent ) { static $ warned ; if ( $ warned ) { return $ consent ; } $ unknown = $ this -> util -> getConsentUnknown ( ) ; if ( ( $ consent == $ unknown ) || ( $ consent == $ this -> _ ( $ unknown ) ) ) { $ warned = true ; $ msg = $ this -> _ ( 'Please settle the informed consent form for this respondent.' ) ; if ( $ this -> view instanceof \ Zend_View ) { $ url [ $ this -> request -> getControllerKey ( ) ] = 'respondent' ; $ url [ $ this -> request -> getActionKey ( ) ] = 'edit' ; $ url [ \ MUtil_Model :: REQUEST_ID1 ] = $ this -> request -> getParam ( \ MUtil_Model :: REQUEST_ID1 ) ; $ url [ \ MUtil_Model :: REQUEST_ID2 ] = $ this -> request -> getParam ( \ MUtil_Model :: REQUEST_ID2 ) ; $ urlString = $ this -> view -> url ( $ url ) . '#tabContainer-frag-4' ; $ this -> addMessage ( \ MUtil_Html :: create ( ) -> a ( $ urlString , $ msg ) ) ; } else { $ this -> addMessage ( $ msg ) ; } } return $ consent ; }
|
Check if we have the Unknown consent and present a warning . The project default consent is normally Unknown but this can be overruled in project . ini so checking for default is not right
|
57,626
|
protected function getCaption ( $ onlyNotCurrent = false ) { $ orgId = $ this -> request -> getParam ( \ MUtil_Model :: REQUEST_ID2 ) ; if ( $ orgId == $ this -> loader -> getCurrentUser ( ) -> getCurrentOrganizationId ( ) ) { if ( $ onlyNotCurrent ) { return ; } else { return $ this -> _ ( 'Respondent information' ) ; } } else { return sprintf ( $ this -> _ ( '%s respondent information' ) , $ this -> loader -> getOrganization ( $ orgId ) -> getName ( ) ) ; } }
|
Returns the caption for this table
|
57,627
|
private function _getHardAnswers ( $ qid , $ scaleId ) { if ( ! is_array ( $ this -> _hardAnswers ) ) { $ qaTable = $ this -> _getAnswersTableName ( ) ; $ qTable = $ this -> _getQuestionsTableName ( ) ; $ sql = 'SELECT a.*, q.other FROM ' . $ qaTable . ' AS a LEFT JOIN ' . $ qTable . ' AS q ON q.qid = a.qid AND q.language = a.language WHERE q.sid = ? AND q.language = ? ORDER BY a.qid, a.scale_id, sortorder' ; $ this -> _hardAnswers = array ( ) ; if ( $ rows = $ this -> lsDb -> fetchAll ( $ sql , array ( $ this -> sourceSurveyId , $ this -> language ) ) ) { foreach ( $ rows as $ row ) { $ this -> _hardAnswers [ $ row [ 'qid' ] ] [ $ row [ 'scale_id' ] ] [ $ row [ 'code' ] ] = $ row [ 'answer' ] ; if ( $ row [ 'other' ] == 'Y' ) { $ this -> _hardAnswers [ $ row [ 'qid' ] ] [ $ row [ 'scale_id' ] ] [ '-oth-' ] = $ this -> _getQuestionAttribute ( $ row [ 'qid' ] , 'other_replace_text' , $ this -> translate -> _ ( 'Other' ) ) ; } } } } if ( array_key_exists ( $ qid , $ this -> _hardAnswers ) && array_key_exists ( $ scaleId , $ this -> _hardAnswers [ $ qid ] ) ) { return $ this -> _hardAnswers [ $ qid ] [ $ scaleId ] ; } return false ; }
|
Returns the answers for a matrix or list type question from the answers table
|
57,628
|
protected function _getQuestionAttribute ( $ qid , $ attribute , $ default = null ) { if ( ! is_array ( $ this -> _attributes ) ) { $ this -> _attributes = [ ] ; $ attributesTable = $ this -> _getQuestionAttributesTableName ( ) ; $ questionsTable = $ this -> _getQuestionsTableName ( ) ; $ surveyTable = $ this -> _getSurveysTableName ( ) ; $ sql = 'SELECT a.qid, a.attribute, a.value FROM ' . $ attributesTable . ' AS a LEFT JOIN ' . $ questionsTable . ' AS q ON q.qid = a.qid LEFT JOIN ' . $ surveyTable . ' AS s ON s.sid = q.sid AND q.language = s.language WHERE s.sid = ?' ; $ attributes = $ this -> lsDb -> fetchAll ( $ sql , $ this -> sourceSurveyId ) ; if ( false === $ attributes ) { return $ default ; } foreach ( $ attributes as $ attrib ) { $ this -> _attributes [ $ attrib [ 'qid' ] ] [ $ attrib [ 'attribute' ] ] = $ attrib [ 'value' ] ; } } if ( isset ( $ this -> _attributes [ $ qid ] [ $ attribute ] ) && strlen ( trim ( $ this -> _attributes [ $ qid ] [ $ attribute ] ) ) ) { return $ this -> _attributes [ $ qid ] [ $ attribute ] ; } else { return $ default ; } }
|
Return a certain question attribute or the default value if it does not exist .
|
57,629
|
private function _getTitlesMap ( ) { if ( ! is_array ( $ this -> _titlesMap ) ) { $ map = $ this -> _getMap ( ) ; $ result = array ( ) ; foreach ( $ map as $ key => $ row ) { if ( isset ( $ row [ 'code' ] ) && $ row [ 'code' ] && ( ! isset ( $ result [ $ row [ 'code' ] ] ) ) ) { $ result [ $ row [ 'code' ] ] = $ key ; } } $ this -> _titlesMap = $ result ; } return $ this -> _titlesMap ; }
|
Returns a map of databasecode = > questioncode
|
57,630
|
protected function _changeIds ( $ array , $ oldId , $ newId , $ keys ) { if ( ! is_array ( $ array ) ) { return $ array ; } $ matches = array_intersect_key ( $ array , $ keys ) ; foreach ( $ matches as $ key => & $ curId ) { if ( $ curId == $ oldId ) { $ array [ $ key ] = $ newId ; } } return $ array ; }
|
Helper function for setcurrentOrganization
|
57,631
|
protected function _getRole ( $ roleField ) { $ role = $ this -> _getVar ( $ roleField ) ; if ( intval ( $ role ) ) { $ role = \ Gems_Roles :: getInstance ( ) -> translateToRoleName ( $ role ) ; $ this -> _setVar ( $ roleField , $ role ) ; } return $ role ; }
|
Get a role with a check on the value in case of integers
|
57,632
|
protected function _getVar ( $ name ) { $ store = $ this -> _getVariableStore ( ) ; if ( $ store instanceof \ Zend_Session_Namespace ) { if ( $ store -> __isset ( $ name ) ) { return $ store -> __get ( $ name ) ; } } else { if ( $ store -> offsetExists ( $ name ) ) { return $ store -> offsetGet ( $ name ) ; } } return null ; }
|
Get a value in whatever store is used by this object .
|
57,633
|
protected function _hasVar ( $ name ) { $ store = $ this -> _getVariableStore ( ) ; if ( $ store instanceof \ Zend_Session_Namespace ) { return $ store -> __isset ( $ name ) ; } else { return $ store -> offsetExists ( $ name ) ; } }
|
Checks for existence of a value in whatever store is used by this object .
|
57,634
|
protected function afterAuthorization ( Result $ result , $ lastAuthorizer = null ) { try { $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__user_login_attempts' , array ( 'gula_failed_logins' , 'gula_last_failed' , 'gula_block_until' , new \ Zend_Db_Expr ( 'UNIX_TIMESTAMP() - UNIX_TIMESTAMP(gula_last_failed) AS since_last' ) ) ) -> where ( 'gula_login = ?' , $ this -> getLoginName ( ) ) -> where ( 'gula_id_organization = ?' , $ this -> getCurrentOrganizationId ( ) ) -> limit ( 1 ) ; $ values = $ this -> db -> fetchRow ( $ select ) ; if ( ! $ values ) { $ values [ 'gula_login' ] = $ this -> getLoginName ( ) ; $ values [ 'gula_id_organization' ] = $ this -> getCurrentOrganizationId ( ) ; $ values [ 'gula_failed_logins' ] = 0 ; $ values [ 'gula_last_failed' ] = null ; $ values [ 'gula_block_until' ] = null ; $ values [ 'since_last' ] = $ this -> failureIgnoreTime + 1 ; } if ( $ result -> isValid ( ) ) { $ values [ 'gula_failed_logins' ] = 0 ; $ values [ 'gula_last_failed' ] = null ; $ values [ 'gula_block_until' ] = null ; } else { if ( $ values [ 'since_last' ] > $ this -> failureIgnoreTime ) { $ values [ 'gula_failed_logins' ] = 1 ; } elseif ( $ lastAuthorizer === 'pwd' ) { $ values [ 'gula_failed_logins' ] += 1 ; } if ( $ values [ 'gula_block_until' ] ) { unset ( $ values [ 'gula_block_until' ] ) ; } else { if ( $ this -> failureBlockCount <= $ values [ 'gula_failed_logins' ] ) { $ values [ 'gula_block_until' ] = new \ Zend_Db_Expr ( 'DATE_ADD(CURRENT_TIMESTAMP, INTERVAL ' . $ this -> failureIgnoreTime . ' SECOND)' ) ; } } $ values [ 'gula_last_failed' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; $ values [ 'gula_failed_logins' ] = max ( 1 , $ values [ 'gula_failed_logins' ] ) ; $ sleepTime = min ( $ values [ 'gula_failed_logins' ] - 1 , 10 ) * 2 ; sleep ( $ sleepTime ) ; } unset ( $ values [ 'since_last' ] ) ; if ( isset ( $ values [ 'gula_login' ] ) ) { $ this -> db -> insert ( 'gems__user_login_attempts' , $ values ) ; } else { $ where = $ this -> db -> quoteInto ( 'gula_login = ? AND ' , $ this -> getLoginName ( ) ) ; $ where .= $ this -> db -> quoteInto ( 'gula_id_organization = ?' , $ this -> getCurrentOrganizationId ( ) ) ; $ this -> db -> update ( 'gems__user_login_attempts' , $ values , $ where ) ; } } catch ( \ Zend_Db_Exception $ e ) { } }
|
Process everything after authentication .
|
57,635
|
public function applyToMenuSource ( \ Gems_Menu_ParameterSource $ source ) { $ source -> offsetSet ( 'gsf_id_organization' , $ this -> getBaseOrganizationId ( ) ) ; $ source -> offsetSet ( 'gsf_active' , $ this -> isActive ( ) ? 1 : 0 ) ; $ source -> offsetSet ( 'accessible_role' , $ this -> inAllowedGroup ( ) ? 1 : 0 ) ; $ source -> offsetSet ( 'can_mail' , $ this -> hasEmailAddress ( ) ? 1 : 0 ) ; $ source -> offsetSet ( 'has_2factor' , $ this -> isTwoFactorEnabled ( ) ? 2 : 0 ) ; }
|
Set menu parameters from this user
|
57,636
|
public function authenticate ( $ password , $ testPassword = true ) { $ auths = $ this -> loadAuthorizers ( $ password , $ testPassword ) ; $ lastAuthorizer = null ; foreach ( $ auths as $ lastAuthorizer => $ result ) { if ( is_callable ( $ result ) ) { $ result = call_user_func ( $ result ) ; } if ( $ result instanceof AdapterInterface ) { $ result = $ result -> authenticate ( ) ; } if ( $ result instanceof Result ) { if ( ! $ result -> isValid ( ) ) { break ; } } else { if ( true === $ result ) { $ result = new Result ( Result :: SUCCESS , $ this -> getLoginName ( ) ) ; } else { if ( $ result === false ) { $ code = Result :: FAILURE_CREDENTIAL_INVALID ; $ result = array ( ) ; } else { $ code = Result :: FAILURE_UNCATEGORIZED ; if ( is_string ( $ result ) ) { $ result = array ( $ result ) ; } } $ result = new Result ( $ code , $ this -> getLoginName ( ) , $ result ) ; break ; } } } if ( $ result -> isValid ( ) && $ this -> definition instanceof \ Gems_User_DbUserDefinitionAbstract ) { $ this -> definition -> checkRehash ( $ this , $ password ) ; } $ this -> afterAuthorization ( $ result , $ lastAuthorizer ) ; $ this -> _authResult = $ result ; return $ result ; }
|
Authenticate a users credentials using the submitted form
|
57,637
|
protected function authorizeBlock ( ) { try { $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__user_login_attempts' , new \ Zend_Db_Expr ( 'UNIX_TIMESTAMP(gula_block_until) - UNIX_TIMESTAMP() AS wait' ) ) -> where ( 'gula_block_until is not null' ) -> where ( 'gula_login = ?' , $ this -> getLoginName ( ) ) -> where ( 'gula_id_organization = ?' , $ this -> getCurrentOrganizationId ( ) ) -> limit ( 1 ) ; if ( $ block = $ this -> db -> fetchOne ( $ select ) ) { if ( $ block > 0 ) { $ minutes = intval ( $ block / 60 ) + 1 ; return sprintf ( $ this -> plural ( 'Your account is temporarily blocked, please wait a minute.' , 'Your account is temporarily blocked, please wait %d minutes.' , $ minutes ) , $ minutes ) ; } else { $ values [ 'gula_failed_logins' ] = 0 ; $ values [ 'gula_last_failed' ] = null ; $ values [ 'gula_block_until' ] = null ; $ where = $ this -> db -> quoteInto ( 'gula_login = ? AND ' , $ this -> getLoginName ( ) ) ; $ where .= $ this -> db -> quoteInto ( 'gula_id_organization = ?' , $ this -> getCurrentOrganizationId ( ) ) ; $ this -> db -> update ( 'gems__user_login_attempts' , $ values , $ where ) ; } } } catch ( \ Zend_Db_Exception $ e ) { } return true ; }
|
Checks if the user is allowed to login or is blocked
|
57,638
|
protected function authorizeIp ( ) { $ request = $ this -> getRequest ( ) ; if ( ! $ request instanceof \ Zend_Controller_Request_Http ) { return true ; } $ remoteIp = $ request -> getServer ( 'REMOTE_ADDR' ) ; if ( $ this -> util -> isAllowedIP ( $ remoteIp , $ this -> getAllowedIPRanges ( ) ) ) { return true ; } return $ this -> _ ( 'You are not allowed to login from this location.' ) ; }
|
Checks if the user is allowed to login using the current IP address according to the group he is in
|
57,639
|
protected function authorizeOrgIp ( ) { if ( $ this -> project -> getSuperAdminName ( ) == $ this -> getLoginName ( ) ) { return true ; } $ request = $ this -> getRequest ( ) ; if ( ! $ request instanceof \ Zend_Controller_Request_Http ) { return true ; } $ remoteIp = $ request -> getServer ( 'REMOTE_ADDR' ) ; if ( $ this -> util -> isAllowedIP ( $ remoteIp , $ this -> getBaseOrganization ( ) -> getAllowedIpRanges ( ) ) ) { return true ; } return $ this -> _ ( 'You are not allowed to login from this location.' ) ; }
|
Checks if the user is allowed to login using the current IP address according to his BASE organization
|
57,640
|
public function canLoginHere ( ) { if ( ! $ this -> _hasVar ( 'can_login_here' ) ) { $ this -> _setVar ( 'can_login_here' , true ) ; if ( $ orgId = $ this -> userLoader -> getOrganizationIdByUrl ( ) ) { if ( ! $ this -> isAllowedOrganization ( $ orgId ) ) { $ this -> _setVar ( 'can_login_here' , false ) ; ; } } } return $ this -> _getVar ( 'can_login_here' ) ; }
|
True when the current url is one where this user is allowed to login .
|
57,641
|
public function clearTwoFactorKey ( ) { $ this -> _setVar ( 'user_two_factor_key' , null ) ; $ this -> definition -> setTwoFactorKey ( $ this , null ) ; return $ this ; }
|
Clear the two factor authentication key
|
57,642
|
public function getAllowedRoles ( ) { $ userRole = $ this -> getRole ( ) ; if ( $ userRole === 'master' ) { $ output = $ this -> acl -> getRoles ( ) ; return array_combine ( $ output , $ output ) ; } $ output = array ( $ userRole => $ userRole ) ; foreach ( $ this -> acl -> getRoles ( ) as $ role ) { if ( ! $ this -> acl -> inheritsRole ( $ role , $ userRole , true ) ) { $ output [ $ role ] = $ role ; } } unset ( $ output [ 'master' ] ) ; return $ output ; }
|
Returns the current roles a user may set .
|
57,643
|
public function getChangePasswordForm ( $ args_array = null ) { if ( ! $ this -> canSetPassword ( ) ) { return ; } $ args = \ MUtil_Ra :: args ( func_get_args ( ) ) ; if ( isset ( $ args [ 'askCheck' ] ) && $ args [ 'askCheck' ] ) { $ args [ 'checkFields' ] = $ this -> loadResetPasswordCheckFields ( ) ; } return $ this -> userLoader -> getChangePasswordForm ( $ this , $ args ) ; }
|
Returns a form to change the possword for this user .
|
57,644
|
public function getCurrentOrganizationId ( ) { $ orgId = $ this -> _getVar ( 'user_organization_id' ) ; if ( $ this -> isCurrentUser ( ) && ( ( null === $ orgId ) || ( \ Gems_User_UserLoader :: SYSTEM_NO_ORG === $ orgId ) ) ) { $ request = $ this -> getRequest ( ) ; if ( $ request ) { $ orgId = \ Gems_Cookies :: getOrganization ( $ this -> getRequest ( ) ) ; } if ( ! $ orgId ) { $ orgId = 0 ; } $ this -> _setVar ( 'user_organization_id' , $ orgId ) ; } return $ orgId ; }
|
Returns the organization id that is currently used by this user .
|
57,645
|
public function getFrom ( ) { $ sources [ ] = $ this -> getBaseOrganization ( ) ; if ( $ this -> getBaseOrganizationId ( ) != $ this -> getCurrentOrganizationId ( ) ) { $ sources [ ] = $ this -> getCurrentOrganization ( ) ; } $ sources [ ] = $ this -> project ; foreach ( $ sources as $ source ) { if ( $ from = $ source -> getFrom ( ) ) { return $ from ; } } return $ this -> getEmailAddress ( ) ; }
|
Returns the from address
|
57,646
|
public function getGreeting ( $ locale = null ) { if ( ! $ this -> _getVar ( 'user_greeting' ) ) { $ greeting [ ] = $ this -> getGenderGreeting ( $ locale ) ; if ( $ this -> _getVar ( 'user_last_name' ) ) { $ greeting [ ] = $ this -> _getVar ( 'user_surname_prefix' ) ; $ greeting [ ] = $ this -> _getVar ( 'user_last_name' ) ; } else { $ name = $ this -> getLoginName ( ) ; if ( $ name ) { $ name = substr ( $ name , 0 , 3 ) . str_repeat ( '*' , strlen ( $ name ) - 2 ) ; $ greeting [ ] = $ name ; } } array_filter ( $ greeting ) ; $ this -> _setVar ( 'user_greeting' , implode ( ' ' , $ greeting ) ) ; } return $ this -> _getVar ( 'user_greeting' ) ; }
|
Returns a standard greeting for the current user .
|
57,647
|
public function getGroup ( ) { if ( ! $ this -> _group ) { $ this -> _group = $ this -> userLoader -> getGroup ( $ this -> getGroupId ( ) ) ; } return $ this -> _group ; }
|
Returns the group of this user .
|
57,648
|
public function getGroupId ( $ current = true ) { if ( $ current && $ this -> _hasVar ( 'current_user_group' ) ) { return $ this -> _getVar ( 'current_user_group' ) ; } return $ this -> _getVar ( 'user_group' ) ; }
|
Returns the group number of this user .
|
57,649
|
public function getPasswordAge ( ) { $ date = \ MUtil_Date :: ifDate ( $ this -> _getVar ( 'user_password_last_changed' ) , array ( \ Gems_Tracker :: DB_DATETIME_FORMAT , \ Gems_Tracker :: DB_DATE_FORMAT , \ Zend_Date :: ISO_8601 ) ) ; if ( $ date instanceof \ MUtil_Date ) { return abs ( $ date -> diffDays ( ) ) ; } else { return 0 ; } }
|
Return the number of days since last change of password
|
57,650
|
public function getRequest ( ) { if ( ! $ this -> request ) { $ this -> request = \ Zend_Controller_Front :: getInstance ( ) -> getRequest ( ) ; } return $ this -> request ; }
|
Return the Request object
|
57,651
|
public function getResetPasswordMailFields ( $ locale = null ) { $ result [ 'reset_key' ] = $ this -> getPasswordResetKey ( ) ; $ result [ 'reset_url' ] = $ this -> getBaseOrganization ( ) -> getLoginUrl ( ) . '/index/resetpassword/key/' . $ result [ 'reset_key' ] ; $ result [ 'reset_in_hours' ] = $ this -> definition -> getResetKeyDurationInHours ( ) ; return $ result + $ this -> getMailFields ( $ locale ) ; }
|
Array of field name = > values for sending a reset password E - Mail
|
57,652
|
public function getRespondentOrganizations ( ) { if ( ! $ this -> _hasVar ( '__allowedRespOrgs' ) ) { $ availableOrganizations = $ this -> util -> getDbLookup ( ) -> getOrganizationsWithRespondents ( ) ; $ allowedOrganizations = $ this -> getAllowedOrganizations ( ) ; $ this -> _setVar ( '__allowedRespOrgs' , array_intersect ( $ availableOrganizations , $ allowedOrganizations ) ) ; } return $ this -> _getVar ( '__allowedRespOrgs' ) ; }
|
Get an array of OrgId = > Org Name for all allowed organizations that can have respondents for the current logged in user
|
57,653
|
public function getRole ( $ current = true ) { if ( $ current && $ this -> _hasVar ( 'current_user_role' ) ) { return $ this -> _getRole ( 'current_user_role' ) ; } return $ this -> _getRole ( 'user_role' ) ; }
|
Returns the current user role .
|
57,654
|
public function hasPrivilege ( $ privilege , $ current = true ) { if ( ! $ this -> acl ) { return true ; } $ role = $ this -> getRole ( $ current ) ; return $ this -> acl -> isAllowed ( $ role , null , $ privilege ) ; }
|
Returns true if the role of the current user has the given privilege
|
57,655
|
public function inAllowedGroup ( ) { if ( $ this -> isCurrentUser ( ) || ( ! $ this -> isStaff ( ) ) ) { return true ; } $ group = $ this -> getGroupId ( ) ; $ groups = $ this -> util -> getDbLookup ( ) -> getActiveStaffGroups ( ) ; if ( ! isset ( $ groups [ $ group ] ) ) { return true ; } $ allowedGroups = $ this -> userLoader -> getCurrentUser ( ) -> getAllowedStaffGroups ( ) ; if ( $ allowedGroups ) { return ( boolean ) isset ( $ allowedGroups [ $ group ] ) ; } else { return false ; } }
|
Return true if this user has a role that is accessible by the current user i . e . is the current user allowed to change this specific user
|
57,656
|
public function isAllowedOrganization ( $ organizationId ) { $ orgs = $ this -> getAllowedOrganizations ( ) ; return isset ( $ orgs [ $ organizationId ] ) || ( \ Gems_User_UserLoader :: SYSTEM_NO_ORG == $ organizationId ) ; }
|
Is this organization in the list of currently allowed organizations?
|
57,657
|
public function refreshAllowedOrganizations ( ) { if ( $ this -> hasPrivilege ( 'pr.organization-switch' ) ) { $ orgs = $ this -> util -> getDbLookup ( ) -> getOrganizations ( ) ; } else { $ org = $ this -> getBaseOrganization ( ) ; $ orgs = array ( $ org -> getId ( ) => $ org -> getName ( ) ) + $ org -> getAllowedOrganizations ( ) ; } $ this -> _setVar ( '__allowedOrgs' , $ orgs ) ; $ this -> _unsetVar ( '__allowedRespOrgs' ) ; return $ this ; }
|
Allowes a refresh of the existing list of organizations for this user .
|
57,658
|
public function sendMail ( $ subjectTemplate , $ bbBodyTemplate , $ useResetFields = false , $ locale = null ) { if ( $ useResetFields && ( ! $ this -> canResetPassword ( ) ) ) { return $ this -> _ ( 'Trying to send a password reset to a user that cannot be reset.' ) ; } $ mail = $ this -> loader -> getMail ( ) ; $ mail -> setTemplateStyle ( $ this -> getBaseOrganization ( ) -> getStyle ( ) ) ; $ mail -> setFrom ( $ this -> getFrom ( ) ) ; $ mail -> addTo ( $ this -> getEmailAddress ( ) , $ this -> getFullName ( ) , $ this -> project -> getStaffBounce ( ) ) ; if ( $ bcc = $ this -> project -> getEmailBcc ( ) ) { $ mail -> addBcc ( $ bcc ) ; } if ( $ useResetFields ) { $ fields = $ this -> getResetPasswordMailFields ( $ locale ) ; } else { $ fields = $ this -> getMailFields ( $ locale ) ; } $ fields = \ MUtil_Ra :: braceKeys ( $ fields , '{' , '}' ) ; $ mail -> setSubject ( strtr ( $ subjectTemplate , $ fields ) ) ; $ mail -> setBodyBBCode ( strtr ( $ bbBodyTemplate , $ fields ) ) ; try { $ mail -> send ( ) ; return null ; } catch ( \ Exception $ e ) { return array ( $ this -> _ ( 'Unable to send e-mail.' ) , $ e -> getMessage ( ) ) ; } }
|
Send an e - mail to this user
|
57,659
|
public function setAsCurrentUser ( $ signalLoader = true , $ resetSessionId = true ) { $ oldStore = $ this -> _getVariableStore ( ) ; if ( ! $ this -> isCurrentUser ( ) ) { $ this -> userLoader -> unsetCurrentUser ( ) ; if ( $ resetSessionId ) { \ Zend_Session :: regenerateId ( ) ; } $ this -> _vars = $ this -> session ; foreach ( $ oldStore as $ name => $ value ) { $ this -> _vars -> __set ( $ name , $ value ) ; } $ this -> switchLocale ( ) ; if ( $ signalLoader ) { $ this -> userLoader -> setCurrentUser ( $ this ) ; } } $ this -> getCurrentOrganization ( ) -> setAsCurrentOrganization ( ) ; return $ this ; }
|
Set this user as the current user .
|
57,660
|
public function setCurrentOrganization ( $ organization ) { if ( ! ( $ organization instanceof \ Gems_User_Organization ) ) { $ organization = $ this -> userLoader -> getOrganization ( $ organization ) ; } $ organizationId = $ organization -> getId ( ) ; $ oldOrganizationId = $ this -> getCurrentOrganizationId ( ) ; if ( $ organizationId != $ oldOrganizationId ) { $ this -> _setVar ( 'user_organization_id' , $ organizationId ) ; if ( $ this -> isCurrentUser ( ) ) { $ this -> getCurrentOrganization ( ) -> setAsCurrentOrganization ( ) ; if ( $ organization -> canHaveRespondents ( ) ) { $ usedOrganizationId = $ organizationId ; } else { $ usedOrganizationId = null ; } $ keysArray = array_flip ( $ this -> possibleOrgIds ) ; $ requestCache = $ this -> session -> requestCache ; if ( $ requestCache ) { foreach ( $ requestCache as $ key => & $ elements ) { $ elements = $ this -> _changeIds ( $ elements , $ oldOrganizationId , $ usedOrganizationId , $ keysArray ) ; } $ this -> session -> requestCache = $ requestCache ; } $ searchSession = new \ Zend_Session_Namespace ( 'ModelSnippetActionAbstract_getSearchData' ) ; foreach ( $ searchSession as $ id => $ data ) { $ searchSession -> $ id = $ this -> _changeIds ( $ data , $ oldOrganizationId , $ usedOrganizationId , $ keysArray ) ; } } } return $ this ; }
|
Set the currently selected organization for this user
|
57,661
|
public function setSurveyReturn ( $ return = null ) { if ( null === $ return ) { $ this -> _unsetVar ( 'surveyReturn' ) ; return $ this ; } if ( $ return instanceof \ Zend_Controller_Request_Abstract ) { $ return = $ return -> getParams ( ) ; } elseif ( ! is_array ( $ return ) ) { $ return = \ MUtil_Ra :: to ( $ return ) ; } if ( 'autofilter' == $ return [ 'action' ] ) { $ return [ 'action' ] = 'index' ; } $ return = array_filter ( $ return ) ; $ this -> _setVar ( 'surveyReturn' , $ return ) ; return $ this ; }
|
Set the parameters where the survey should return to
|
57,662
|
public function switchLocale ( $ locale = null ) { if ( null === $ locale ) { $ locale = $ this -> getLocale ( ) ; } elseif ( $ this -> getLocale ( ) != $ locale ) { $ this -> setLocale ( $ locale ) ; } $ this -> locale -> setLocale ( $ locale ) ; $ this -> translateAdapter -> setLocale ( $ locale ) ; return \ Gems_Cookies :: setLocale ( $ locale , $ this -> basepath -> getBasePath ( ) ) ; }
|
Switch to new locale
|
57,663
|
public function unsetAsCurrentUser ( $ signalLoader = true ) { if ( $ this -> isCurrentUser ( ) ) { $ oldStore = $ this -> _vars ; $ this -> _vars = new \ ArrayObject ( ) ; $ this -> _vars -> setFlags ( \ ArrayObject :: STD_PROP_LIST ) ; foreach ( $ oldStore as $ name => $ value ) { $ this -> _vars -> offsetSet ( $ name , $ value ) ; } $ oldStore -> unsetAll ( ) ; if ( $ signalLoader ) { $ this -> userLoader -> unsetCurrentUser ( ) ; } } return $ this ; }
|
Unsets this user as the current user .
|
57,664
|
protected function getRespondentMailfields ( ) { if ( $ this -> respondent ) { $ result = array ( ) ; $ result [ 'bcc' ] = $ this -> mailFields [ 'project_bcc' ] ; $ result [ 'email' ] = $ this -> respondent -> getEmailAddress ( ) ; $ result [ 'from' ] = '' ; $ result [ 'first_name' ] = $ this -> respondent -> getFirstName ( ) ; $ result [ 'full_name' ] = $ this -> respondent -> getFullName ( ) ; $ result [ 'greeting' ] = $ this -> respondent -> getGreeting ( ) ; $ result [ 'last_name' ] = $ this -> respondent -> getLastName ( ) ; $ result [ 'name' ] = $ this -> respondent -> getName ( ) ; } else { $ result = array ( 'email' => '' , 'from' => '' , 'first_name' => '' , 'full_name' => '' , 'greeting' => '' , 'last_name' => '' , 'name' => '' ) ; } $ result [ 'reply_to' ] = $ result [ 'from' ] ; $ result [ 'to' ] = $ result [ 'email' ] ; $ result [ 'reset_ask' ] = '' ; if ( $ this -> mailFields [ 'organization_login_url' ] ) { $ result [ 'reset_ask' ] = $ this -> mailFields [ 'organization_login_url' ] . '/index/resetpassword' ; } return $ result ; }
|
Get the respondent mailfields
|
57,665
|
public function getTab ( ) { $ tab = " Log" ; if ( $ this -> _writer -> getErrorCount ( ) ) { $ tab .= " (" . $ this -> _writer -> getErrorCount ( ) . ")" ; $ _COOKIE [ 'ZFDebugCollapsed' ] = 'ZFDebug_' . $ this -> getIdentifier ( ) ; } return $ tab ; }
|
Has to return html code for the menu tab
|
57,666
|
public function getPanel ( ) { $ request = Zend_Controller_Front :: getInstance ( ) -> getRequest ( ) ; $ module = $ request -> getModuleName ( ) ; if ( 'default' !== $ module ) { $ module = " ($module module)" ; } else { $ module = '' ; } $ controller = $ request -> getControllerName ( ) ; $ action = $ request -> getActionName ( ) ; $ panel = "<h4>Event log for {$controller}Controller->{$action}Action() {$module}</h4>" ; $ panel .= '<table cellpadding="0" cellspacing="0">' . implode ( '' , $ this -> _writer -> getMessages ( ) ) . '</table>' ; return $ panel ; }
|
Has to return html code for the content panel
|
57,667
|
public function addField ( FieldInterface $ field ) { $ key = $ field -> getFieldKey ( ) ; $ this -> addDependsOn ( $ field -> getDataModelDependsOn ( ) ) ; $ this -> addEffected ( $ key , $ field -> getDataModelEffecteds ( ) ) ; $ this -> _fields [ $ key ] = $ field ; return $ this ; }
|
Add a field to this dependency
|
57,668
|
public function showAppointment ( $ value ) { if ( ! $ value ) { return $ this -> _ ( 'Unknown' ) ; } if ( $ value instanceof \ Gems_Agenda_Appointment ) { $ appointment = $ value ; } else { $ appointment = $ this -> loader -> getAgenda ( ) -> getAppointment ( $ value ) ; } if ( $ appointment instanceof \ Gems_Agenda_Appointment ) { if ( ! $ this -> menu instanceof \ Gems_Menu ) { $ this -> menu = $ this -> loader -> getMenu ( ) ; } $ menuItem = $ this -> menu -> findAllowedController ( 'appointment' , 'show' ) ; if ( $ menuItem ) { if ( ! $ this -> request ) { $ this -> request = \ Zend_Controller_Front :: getInstance ( ) -> getRequest ( ) ; } $ href = $ menuItem -> toHRefAttribute ( array ( 'gap_id_appointment' => $ appointment -> getId ( ) ) , $ this -> request ) ; if ( $ href ) { return \ MUtil_Html :: create ( 'a' , $ href , $ appointment -> getDisplayString ( ) ) ; } } return $ appointment -> getDisplayString ( ) ; } return $ value ; }
|
Dispaly an appoitment as text
|
57,669
|
public function cronLockAction ( ) { $ this -> util -> getCronJobLock ( ) -> reverse ( ) ; $ request = $ this -> getRequest ( ) ; $ this -> _reroute ( $ this -> menu -> getCurrentParent ( ) -> toRouteUrl ( ) ) ; }
|
Action that switches the cron job lock on or off .
|
57,670
|
public function indexAction ( ) { $ this -> initHtml ( ) ; if ( $ this -> util -> getMaintenanceLock ( ) -> isLocked ( ) ) { $ this -> addMessage ( $ this -> _ ( 'Cannot run cron job in maintenance mode.' ) ) ; } elseif ( $ this -> util -> getCronJobLock ( ) -> isLocked ( ) ) { $ this -> addMessage ( $ this -> _ ( 'Cron jobs turned off.' ) ) ; } else { $ this -> commJob ( ) ; } $ this -> util -> getMonitor ( ) -> startCronMailMonitor ( ) ; }
|
The general do the jobs action
|
57,671
|
protected function getDefaultFormValues ( ) { if ( $ this -> formData ) { return $ this -> formData ; } if ( $ this -> user -> hasTwoFactor ( ) ) { $ authKey = $ this -> user -> getTwoFactorKey ( ) ; } else { $ authKey = null ; } if ( ! $ authKey ) { $ authKey = $ this -> authenticator -> createSecret ( ) ; $ this -> addMessage ( sprintf ( $ this -> _ ( 'A new random two factor key was saved for %s.' ) , $ this -> user -> getFullName ( ) ) ) ; $ this -> addMessage ( $ this -> _ ( 'Click save to enable two factor authentication.' ) ) ; $ this -> user -> setTwoFactorKey ( $ this -> authenticator , $ authKey , false ) ; $ output [ 'twoFactorEnabled' ] = 1 ; } else { $ output [ 'twoFactorEnabled' ] = $ this -> user -> isTwoFactorEnabled ( ) ? 1 : 0 ; if ( ! $ output [ 'twoFactorEnabled' ] ) { $ this -> addMessage ( $ this -> _ ( 'Two factor authentication not active!' ) ) ; } } $ output [ 'twoFactorKey' ] = $ authKey ; return $ output ; }
|
Return the default values for the form
|
57,672
|
protected function getDefaultRow ( ) { $ results = array ( ) ; foreach ( $ this -> getFields ( ) as $ name => $ field ) { $ results [ $ name ] = $ field -> getDefault ( ) ; } return $ results ; }
|
Returns defaults for all field values . Can be overruled .
|
57,673
|
public function getFilter ( \ Zend_Controller_Request_Abstract $ request , array $ filter = array ( ) , $ dateField = null ) { $ this -> _actionKey = $ request -> getActionKey ( ) ; $ filter = $ this -> processFilter ( $ request , $ filter ) ; if ( $ filter ) { $ model = $ this -> getModel ( ) ; $ model -> addFilter ( $ filter ) ; } $ newfilter = $ filter ; if ( $ this -> dateCurrentStart && $ this -> dateCurrentEnd ) { if ( null === $ dateField ) { $ dateField = $ this -> dateFrom ; } $ start = $ this -> dateCurrentStart -> getIso ( ) ; $ end = $ this -> dateCurrentEnd -> getIso ( ) ; $ newfilter [ ] = "$dateField BETWEEN '$start' AND '$end'" ; } if ( $ this -> dateGroup ) { $ fields = $ this -> getFields ( ) ; if ( isset ( $ fields [ $ this -> dateGroup ] ) ) { if ( $ groupfilter = $ fields [ $ this -> dateGroup ] -> getFilter ( ) ) { $ newfilter [ ] = $ groupfilter ; } } } return $ newfilter ; }
|
Prcesses the filter for the date selector and return the filter to use instead
|
57,674
|
protected function _getPasswordRules ( array $ current , array $ codes , array & $ rules ) { foreach ( $ current as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( isset ( $ codes [ strtolower ( $ key ) ] ) ) { $ this -> _getPasswordRules ( $ value , $ codes , $ rules ) ; } } else { $ rules [ $ key ] = $ value ; } } }
|
Add recursively the rules active for this specific set of codes .
|
57,675
|
public function checkRequiredValues ( ) { $ missing = array ( ) ; foreach ( $ this -> requiredKeys as $ key => $ names ) { if ( is_array ( $ names ) ) { if ( ! ( $ this -> offsetExists ( $ key ) && $ this -> offsetGet ( $ key ) ) ) { $ subarray = array ( ) ; } else { $ subarray = $ this -> offsetGet ( $ key ) ; } foreach ( $ names as $ name ) { if ( ! isset ( $ subarray [ $ name ] ) ) { $ missing [ ] = $ key . '.' . $ name ; } } } else { if ( ! ( $ this -> offsetExists ( $ names ) && $ this -> offsetGet ( $ names ) ) ) { $ missing [ ] = $ names ; } } } if ( ! \ MUtil_Https :: on ( ) ) { if ( $ this -> isHttpsRequired ( ) ) { \ MUtil_Https :: enforce ( ) ; } } if ( $ missing ) { if ( count ( $ missing ) == 1 ) { $ error = sprintf ( "Missing required project setting: '%s'." , reset ( $ missing ) ) ; } else { $ error = sprintf ( "Missing required project settings: '%s'." , implode ( "', '" , $ missing ) ) ; } throw new \ Gems_Exception_Coding ( $ error ) ; } $ superPassword = $ this -> getSuperAdminPassword ( ) ; if ( ( 'production' === APPLICATION_ENV || 'acceptance' === APPLICATION_ENV ) && $ this -> getSuperAdminName ( ) && $ superPassword ) { if ( strlen ( $ superPassword ) < $ this -> minimumSuperPasswordLength ) { $ error = sprintf ( "Project setting 'admin.pwd' is shorter than %d characters. That is not allowed." , $ this -> minimumSuperPasswordLength ) ; throw new \ Gems_Exception_Coding ( $ error ) ; } } }
|
This function checks for the required project settings .
|
57,676
|
public function getAskDelay ( \ Zend_Controller_Request_Abstract $ request , $ wasAnswered ) { if ( $ request -> getParam ( 'delay_cancelled' , false ) ) { return - 1 ; } $ delay = $ request -> getParam ( 'delay' , null ) ; if ( null != $ delay ) { return $ delay ; } if ( $ wasAnswered ) { if ( $ this -> offsetExists ( 'askNextDelay' ) ) { return $ this -> offsetGet ( 'askNextDelay' ) ; } } else { if ( $ this -> offsetExists ( 'askDelay' ) ) { return $ this -> offsetGet ( 'askDelay' ) ; } } return - 1 ; }
|
Calculate the delay between surveys being asked for this request . Zero means forward at once a negative value means wait forever .
|
57,677
|
public function getConsoleRole ( ) { if ( $ this -> offsetExists ( 'console' ) ) { $ cons = $ this -> offsetGet ( 'console' ) ; if ( isset ( $ cons [ 'role' ] ) ) { return $ cons [ 'role' ] ; } } return false ; }
|
Get the specified role for the console user from the project setttings .
|
57,678
|
public function getCronLogfile ( ) { if ( ! ( $ this -> offsetExists ( 'cron' ) && isset ( $ this -> cron [ 'logfile' ] ) ) ) { return null ; } $ file = trim ( $ this -> cron [ 'logfile' ] ) ; if ( \ MUtil_File :: isRootPath ( $ file ) ) { return $ file ; } return GEMS_ROOT_DIR . '/var/logs/' . $ file ; }
|
The logfile for cron jobs
|
57,679
|
public function getEmailBounce ( ) { if ( $ this -> offsetExists ( 'email' ) && isset ( $ this -> email [ 'bounce' ] ) ) { return ( boolean ) $ this -> email [ 'bounce' ] ; } return false ; }
|
Should all mail be bounced to the sender?
|
57,680
|
public function getEmailCreateAccount ( ) { if ( $ this -> offsetExists ( 'email' ) && isset ( $ this -> email [ 'createAccountTemplate' ] ) ) { return ( string ) $ this -> email [ 'createAccountTemplate' ] ; } return false ; }
|
The default Email Template for Create Account
|
57,681
|
public function getEmailMultiLanguage ( ) { if ( $ this -> offsetExists ( 'email' ) && isset ( $ this -> email [ 'multiLanguage' ] ) ) { return ( boolean ) $ this -> email [ 'multiLanguage' ] ; } else { return true ; } }
|
Check if multiple language mail templates is supported
|
57,682
|
public function getEmailResetPassword ( ) { if ( $ this -> offsetExists ( 'email' ) && isset ( $ this -> email [ 'resetPasswordTemplate' ] ) ) { return ( string ) $ this -> email [ 'resetPasswordTemplate' ] ; } return false ; }
|
The default Email template for Reset password
|
57,683
|
public function getLogLevel ( ) { if ( isset ( $ this [ 'logLevel' ] ) ) { $ logLevel = $ this [ 'logLevel' ] ; } else { $ logLevel = $ this -> getLogLevelDefault ( ) ; } return ( int ) $ logLevel ; }
|
Get the logLevel to use with the \ Gems_Log
|
57,684
|
public function getLogLevelDefault ( ) { if ( 'development' == APPLICATION_ENV || 'testing' == APPLICATION_ENV ) { $ logLevel = \ Zend_Log :: DEBUG ; } else { $ logLevel = \ Zend_Log :: ERR ; } return $ logLevel ; }
|
Return the default logLevel to use with the \ Gems_Log
|
57,685
|
public function getLongDescription ( $ language ) { if ( isset ( $ this [ 'longDescr' . ucfirst ( $ language ) ] ) ) { return $ this [ 'longDescr' . ucfirst ( $ language ) ] ; } if ( isset ( $ this [ 'longDescr' ] ) ) { return $ this [ 'longDescr' ] ; } }
|
Return a long description in the correct language if available
|
57,686
|
public function getMonitorFrom ( $ name = null ) { if ( $ name ) { if ( isset ( $ this [ 'monitor' ] , $ this [ 'monitor' ] [ $ name ] , $ this [ 'monitor' ] [ $ name ] [ 'from' ] ) && trim ( $ this [ 'monitor' ] [ $ name ] [ 'from' ] ) ) { return $ this [ 'monitor' ] [ $ name ] [ 'from' ] ; } } if ( isset ( $ this [ 'monitor' ] , $ this [ 'monitor' ] [ 'default' ] , $ this [ 'monitor' ] [ 'default' ] [ 'from' ] ) && trim ( $ this [ 'monitor' ] [ 'default' ] [ 'from' ] ) ) { return $ this [ 'monitor' ] [ 'default' ] [ 'from' ] ; } $ email = $ this -> getSiteEmail ( ) ; if ( $ email ) { return $ email ; } return 'noreply@gemstracker.org' ; }
|
Get the form address for monitor messages
|
57,687
|
public function getMonitorPeriod ( $ name = null ) { if ( $ name ) { if ( isset ( $ this [ 'monitor' ] , $ this [ 'monitor' ] [ $ name ] , $ this [ 'monitor' ] [ $ name ] [ 'period' ] ) && strlen ( trim ( $ this [ 'monitor' ] [ $ name ] [ 'period' ] ) ) ) { return $ this [ 'monitor' ] [ $ name ] [ 'period' ] ; } } if ( isset ( $ this [ 'monitor' ] , $ this [ 'monitor' ] [ 'default' ] , $ this [ 'monitor' ] [ 'default' ] [ 'period' ] ) && strlen ( trim ( $ this [ 'monitor' ] [ 'default' ] [ 'period' ] ) ) ) { return $ this [ 'monitor' ] [ 'default' ] [ 'period' ] ; } return '25h' ; }
|
Get the period for monitor messages optionally for a name
|
57,688
|
public function getMonitorTo ( $ name = null ) { if ( $ name ) { if ( isset ( $ this [ 'monitor' ] , $ this [ 'monitor' ] [ $ name ] , $ this [ 'monitor' ] [ $ name ] [ 'to' ] ) && trim ( $ this [ 'monitor' ] [ $ name ] [ 'to' ] ) ) { return $ this [ 'monitor' ] [ $ name ] [ 'to' ] ; } } if ( isset ( $ this [ 'monitor' ] , $ this [ 'monitor' ] [ 'default' ] , $ this [ 'monitor' ] [ 'default' ] [ 'to' ] ) && trim ( $ this [ 'monitor' ] [ 'default' ] [ 'to' ] ) ) { return $ this [ 'monitor' ] [ 'default' ] [ 'to' ] ; } return null ; }
|
Get the to addresses for monitor messages optionally for a name
|
57,689
|
public function getPasswordRules ( array $ codes ) { $ codes = array_change_key_case ( array_flip ( array_filter ( $ codes ) ) ) ; $ rules = array ( ) ; if ( $ this -> offsetExists ( 'passwords' ) && is_array ( $ this -> passwords ) ) { $ this -> _getPasswordRules ( $ this -> passwords , $ codes , $ rules ) ; } return $ rules ; }
|
Get the rules active for this specific set of codes .
|
57,690
|
public function getMetaHeaders ( ) { if ( $ this -> offsetExists ( 'meta' ) && is_array ( $ this -> meta ) ) { $ meta = $ this -> meta ; } else { $ meta = [ ] ; } if ( ! array_key_exists ( 'Content-Type' , $ meta ) ) { $ meta [ 'Content-Type' ] = 'text/html;charset=UTF-8' ; } return array_filter ( $ meta ) ; }
|
Get additional meta headers
|
57,691
|
public function getResponseDatabase ( ) { if ( ( ! $ this -> _responsesDb ) && $ this -> hasResponseDatabase ( ) ) { $ adapter = $ this [ 'responses' ] [ 'adapter' ] ; if ( isset ( $ this [ 'responses' ] , $ this [ 'responses' ] [ 'params' ] ) ) { $ options = $ this [ 'responses' ] [ 'params' ] ; if ( ! isset ( $ options [ 'charset' ] , $ options [ 'host' ] , $ options [ 'dbname' ] , $ options [ 'username' ] , $ options [ 'password' ] ) ) { $ db = \ Zend_Registry :: get ( 'db' ) ; if ( $ db instanceof \ Zend_Db_Adapter_Abstract ) { $ options = $ options + $ db -> getConfig ( ) ; } } $ this -> _responsesDb = \ Zend_Db :: factory ( $ adapter , $ options ) ; } else { $ db = \ Zend_Registry :: get ( 'db' ) ; if ( $ db instanceof \ Zend_Db_Adapter_Abstract ) { $ this -> _responsesDb = $ db ; } } } return $ this -> _responsesDb ; }
|
The response database with a table with one row for each token answer .
|
57,692
|
public function getResponseHeaders ( ) { if ( $ this -> offsetExists ( 'headers' ) && is_array ( $ this -> headers ) ) { $ headers = $ this -> headers ; } else { $ headers = [ ] ; } if ( ! array_key_exists ( 'X-UA-Compatible' , $ headers ) ) { $ headers [ 'X-UA-Compatible' ] = 'IE=edge,chrome=1' ; } return array_filter ( $ headers ) ; }
|
Get additional response headers
|
57,693
|
public function getSessionTimeOut ( ) { if ( $ this -> offsetExists ( 'session' ) && isset ( $ this -> session [ 'idleTimeout' ] ) ) { return $ this -> session [ 'idleTimeout' ] ; } else { return $ this -> defaultSessionTimeout ; } }
|
Timeout for sessions in seconds .
|
57,694
|
public function getStaffBounce ( ) { if ( $ this -> offsetExists ( 'email' ) && isset ( $ this -> email [ 'staffBounce' ] ) ) { return ( boolean ) $ this -> email [ 'staffBounce' ] ; } return $ this -> getEmailBounce ( ) ; }
|
Should staff mail be bounced to the sender?
|
57,695
|
public function getSuperAdminTwoFactorIpExclude ( ) { if ( $ this -> offsetExists ( 'admin' ) && isset ( $ this -> admin [ '2fa' ] , $ this -> admin [ '2fa' ] [ 'exclude' ] ) ) { return trim ( $ this -> admin [ '2fa' ] [ 'exclude' ] ) ; } }
|
Get the super admin two factor authentication ip exclude range
|
57,696
|
public function getSuperAdminTwoFactorKey ( ) { if ( $ this -> offsetExists ( 'admin' ) && isset ( $ this -> admin [ '2fa' ] , $ this -> admin [ '2fa' ] [ 'key' ] ) ) { return trim ( $ this -> admin [ '2fa' ] [ 'key' ] ) ; } }
|
Get the super admin two factor authentication key
|
57,697
|
public function getValueHash ( $ value , $ algorithm = null ) { $ salt = $ this -> offsetExists ( 'salt' ) ? $ this -> offsetGet ( 'salt' ) : '' ; if ( false === strpos ( $ salt , '%s' ) ) { $ salted = $ salt . $ value ; } else { $ salted = sprintf ( $ salt , $ value ) ; } if ( null == $ algorithm ) { return md5 ( $ salted , false ) ; } return hash ( $ algorithm , $ value , false ) ; }
|
Returns a salted hash optionally using the specified hash algorithm
|
57,698
|
public function hasAnySupportUrl ( ) { return isset ( $ this [ 'contact' ] ) && ( isset ( $ this [ 'contact' ] [ 'docsUrl' ] ) || isset ( $ this [ 'contact' ] [ 'forumUrl' ] ) || isset ( $ this [ 'contact' ] [ 'manualUrl' ] ) || isset ( $ this [ 'contact' ] [ 'supportUrl' ] ) ) ; }
|
True at least one support url exists .
|
57,699
|
public function isConsoleAllowed ( ) { if ( $ this -> offsetExists ( 'console' ) ) { $ cons = $ this -> offsetGet ( 'console' ) ; if ( isset ( $ cons [ 'allow' ] ) ) { return ( boolean ) $ cons [ 'allow' ] ; } } return false ; }
|
Is running GemsTracker from the console allowed
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.