idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
57,700
protected function _getQRCodeInline ( $ name , $ secret , $ title = null , $ params = array ( ) ) { $ url = $ this -> _getQRCodeUrl ( $ title , $ name , $ secret ) ; list ( $ width , $ height , $ level ) = $ this -> _getQRParams ( $ params ) ; $ renderer = new \ BaconQrCode \ Renderer \ Image \ Png ( ) ; $ renderer -> setWidth ( $ width ) -> setHeight ( $ height ) -> setMargin ( 0 ) ; $ bacon = new \ BaconQrCode \ Writer ( $ renderer ) ; $ data = $ bacon -> writeString ( $ urlencoded , $ encoding , \ BaconQrCode \ Common \ ErrorCorrectionLevel :: M ) ; return 'data:image/png;base64,' . base64_encode ( $ data ) ; }
Get QR - Code URL for image using inline data uri .
57,701
protected function _getQRCodeUrl ( $ title , $ name , $ secret ) { if ( empty ( $ title ) ) { return 'otpauth://totp/' . rawurlencode ( $ name ) . '?secret=' . $ secret ; } else { return 'otpauth://totp/' . rawurlencode ( $ title ) . ':' . rawurlencode ( $ name ) . '?secret=' . $ secret . '&issuer=' . rawurlencode ( $ title ) ; } }
Get otpauth url
57,702
public function addSetupFormElements ( \ Zend_Form $ form , \ Gems_User_User $ user , array & $ formData ) { $ name = $ user -> getLoginName ( ) ; $ title = $ this -> project -> getName ( ) . ' - GemsTracker' ; $ params [ 'alt' ] = $ this -> _ ( 'QR Code' ) ; $ params [ 'class' ] = 'floatLeft' ; $ params [ 'height' ] = 200 ; $ params [ 'width' ] = 200 ; $ params [ 'src' ] = \ MUtil_Html :: raw ( $ this -> _getQRCodeGoogleUrl ( $ name , $ formData [ 'twoFactorKey' ] , $ title , $ params ) ) ; $ imgElement = $ form -> createElement ( 'Html' , 'image' ) ; $ imgElement -> setLabel ( $ this -> _ ( 'Scan this QR Code' ) ) -> setDescription ( $ this -> _ ( 'Install the Google Authenticator app on your phone and scan this code.' ) ) ; $ imgElement -> img ( $ params ) ; $ form -> addElement ( $ imgElement ) ; if ( $ user -> canSaveTwoFactorKey ( ) ) { $ orElement = $ form -> createElement ( 'Html' , 'orelem' ) ; $ orElement -> setLabel ( $ this -> _ ( 'or' ) ) ; $ form -> addElement ( $ orElement ) ; $ options = [ 'label' => $ this -> _ ( 'Enter new authenticator code' ) , 'description' => $ this -> _ ( 'An uppercase string containing A through Z, 2 to 7 and maybe = at the end.' ) , 'maxlength' => 16 , 'minlength' => 16 , 'required' => true , 'size' => 30 , ] ; $ keyElement = $ form -> createElement ( 'Text' , 'twoFactorKey' , $ options ) ; $ keyElement -> addFilter ( 'StringToUpper' ) -> addValidator ( 'Base32' ) -> addValidator ( 'StringLength' , true , [ 'min' => 16 , 'max' => 16 ] ) ; $ form -> addElement ( $ keyElement ) ; } }
Add the elements to the setup form
57,703
public function getTopic ( $ count = 1 ) { if ( is_callable ( $ this -> topicCallable ) ) { return call_user_func ( $ this -> topicCallable , $ count ) ; } else { return parent :: getTopic ( $ count ) ; } }
Helper function to allow generalized statements about the items in the model to used specific item names .
57,704
public function _fixFieldData ( ) { $ fieldMap = $ this -> getTrackEngine ( ) -> getFieldCodes ( ) ; foreach ( $ this -> _fieldData as $ key => $ value ) { if ( isset ( $ fieldMap [ $ key ] ) ) { $ this -> _fieldData [ $ fieldMap [ $ key ] ] = $ value ; } } }
Adds the code fields to the fieldData array
57,705
protected function _ensureRounds ( $ reload = false ) { if ( ( null === $ this -> _rounds ) || $ reload ) { $ rounds = $ this -> getTrackEngine ( ) -> getRoundModel ( true , 'index' ) -> load ( array ( 'gro_id_track' => $ this -> getTrackId ( ) ) ) ; $ this -> _rounds = array ( ) ; foreach ( $ rounds as $ round ) { $ this -> _rounds [ $ round [ 'gro_id_round' ] ] = $ round ; } } }
Makes sure the rounds info is loaded
57,706
protected function _mergeFieldValues ( array $ newFieldData , array $ oldFieldData , \ Gems_Tracker_Engine_TrackEngineInterface $ trackEngine ) { $ fieldMap = $ trackEngine -> getFieldsDefinition ( ) -> getFieldCodes ( ) ; $ output = array ( ) ; foreach ( $ fieldMap as $ key => $ code ) { if ( $ code ) { if ( array_key_exists ( $ code , $ newFieldData ) ) { $ output [ $ key ] = $ newFieldData [ $ code ] ; $ output [ $ code ] = $ newFieldData [ $ code ] ; } elseif ( array_key_exists ( $ key , $ newFieldData ) ) { $ output [ $ key ] = $ newFieldData [ $ key ] ; $ output [ $ code ] = $ newFieldData [ $ key ] ; } elseif ( isset ( $ oldFieldData [ $ code ] ) ) { $ output [ $ key ] = $ oldFieldData [ $ code ] ; $ output [ $ code ] = $ oldFieldData [ $ code ] ; } elseif ( isset ( $ oldFieldData [ $ key ] ) ) { $ output [ $ key ] = $ oldFieldData [ $ key ] ; $ output [ $ code ] = $ oldFieldData [ $ key ] ; } else { $ output [ $ key ] = null ; $ output [ $ code ] = null ; } } else { if ( array_key_exists ( $ key , $ newFieldData ) ) { $ output [ $ key ] = $ newFieldData [ $ key ] ; } elseif ( isset ( $ oldFieldData [ $ key ] ) ) { $ output [ $ key ] = $ oldFieldData [ $ key ] ; } else { $ output [ $ key ] = null ; } } } return $ output ; }
Processes the field values and returns the new complete field data
57,707
protected function _updateTrack ( array $ values , $ userId = null ) { if ( null === $ userId ) { $ userId = $ this -> currentUser -> getUserId ( ) ; } if ( $ this -> tracker -> filterChangesOnly ( $ this -> _respTrackData , $ values ) ) { $ where = $ this -> db -> quoteInto ( 'gr2t_id_respondent_track = ?' , $ this -> _respTrackId ) ; if ( \ Gems_Tracker :: $ verbose ) { $ echo = '' ; foreach ( $ values as $ key => $ val ) { $ echo .= $ key . ': ' . $ this -> _respTrackData [ $ key ] . ' => ' . $ val . "\n" ; } \ MUtil_Echo :: r ( $ echo , 'Updated values for ' . $ this -> _respTrackId ) ; } if ( ! isset ( $ values [ 'gr2t_changed' ] ) ) { $ values [ 'gr2t_changed' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; } if ( ! isset ( $ values [ 'gr2t_changed_by' ] ) ) { $ values [ 'gr2t_changed_by' ] = $ userId ; } $ this -> _respTrackData = $ values + $ this -> _respTrackData ; return $ this -> db -> update ( 'gems__respondent2track' , $ values , $ where ) ; } else { return 0 ; } }
Save the values if any have been changed
57,708
public function assignTokensToRelations ( ) { $ relationFields = $ this -> getTrackEngine ( ) -> getFieldsOfType ( 'relation' ) ; if ( empty ( $ relationFields ) ) { return 0 ; } $ this -> _ensureRounds ( ) ; $ relationFields = $ this -> getFieldData ( ) ; $ fieldPrefix = \ Gems \ Tracker \ Model \ FieldMaintenanceModel :: FIELDS_NAME . \ Gems \ Tracker \ Engine \ FieldsDefinition :: FIELD_KEY_SEPARATOR ; $ changes = 0 ; foreach ( $ this -> getTokens ( ) as $ token ) { if ( ! $ token -> isCompleted ( ) && $ token -> getReceptionCode ( ) -> isSuccess ( ) ) { $ roundId = $ token -> getRoundId ( ) ; if ( ! array_key_exists ( $ roundId , $ this -> _rounds ) ) { $ round = $ this -> getTrackEngine ( ) -> getRoundModel ( true , 'index' ) -> loadFirst ( array ( 'gro_id_round' => $ roundId ) ) ; } else { $ round = $ this -> _rounds [ $ roundId ] ; } $ relationFieldId = null ; $ relationId = null ; if ( ! empty ( $ round ) && $ round [ 'gro_id_track' ] == $ this -> getTrackId ( ) && $ round [ 'gro_active' ] == 1 ) { if ( $ round [ 'gro_id_relationfield' ] > 0 ) { $ relationFieldId = $ round [ 'gro_id_relationfield' ] ; } } else { $ relationFieldId = $ token -> getRelationFieldId ( ) ; } if ( $ relationFieldId > 0 ) { $ fieldKey = $ fieldPrefix . $ relationFieldId ; if ( isset ( $ relationFields [ $ fieldKey ] ) ) { $ relationId = ( int ) $ relationFields [ $ fieldKey ] ; } else { $ relationId = - 1 * $ relationFieldId ; } } $ changes = $ changes + $ token -> assignTo ( $ relationId , $ relationFieldId ) ; } } if ( MUtil_Model :: $ verbose && $ changes > 0 ) { MUtil_Echo :: r ( sprintf ( '%s tokens changed due to changes in respondent relation assignments.' , $ changes ) ) ; } return $ changes ; }
Assign the tokens to the correct relation
57,709
public function calculateEndDate ( ) { $ excludeWheres [ ] = sprintf ( "gro_valid_for_source = '%s' AND gro_valid_for_field = 'gr2t_end_date'" , \ Gems_Tracker_Engine_StepEngineAbstract :: RESPONDENT_TRACK_TABLE ) ; $ excludeWheres [ ] = sprintf ( "gro_valid_after_source = '%s' AND gro_valid_after_field = 'gr2t_end_date' AND gro_id_round = gro_valid_for_id AND gro_valid_for_source = '%s' AND gro_valid_for_field = 'gto_valid_from'" , \ Gems_Tracker_Engine_StepEngineAbstract :: RESPONDENT_TRACK_TABLE , \ Gems_Tracker_Engine_StepEngineAbstract :: TOKEN_TABLE ) ; $ maxExpression = " CASE WHEN SUM( CASE WHEN COALESCE(gto_completion_time, gto_valid_until) IS NULL THEN 1 ELSE 0 END ) > 0 THEN NULL ELSE MAX(COALESCE(gto_completion_time, gto_valid_until)) END as enddate" ; $ tokenSelect = $ this -> tracker -> getTokenSelect ( array ( new \ Zend_Db_Expr ( $ maxExpression ) ) ) ; $ tokenSelect -> andReceptionCodes ( array ( ) ) -> andRounds ( array ( ) ) -> forRespondentTrack ( $ this -> _respTrackId ) -> onlySucces ( ) ; foreach ( $ excludeWheres as $ where ) { $ tokenSelect -> forWhere ( 'NOT (' . $ where . ')' ) ; } $ endDate = $ tokenSelect -> fetchOne ( ) ; if ( false === $ endDate ) { return null ; ; } else { return $ endDate ; } }
Calculates the track end date
57,710
public function checkTrackTokens ( $ userId , \ Gems_Tracker_Token $ fromToken = null , \ Gems_Tracker_Token $ skipToken = null ) { $ count = $ this -> handleTrackCalculation ( $ userId ) ; $ engine = $ this -> getTrackEngine ( ) ; $ this -> db -> beginTransaction ( ) ; if ( $ fromToken ) { $ count += $ engine -> checkTokensFrom ( $ this , $ fromToken , $ userId , $ skipToken ) ; } elseif ( $ this -> _checkStart ) { $ count += $ engine -> checkTokensFrom ( $ this , $ this -> _checkStart , $ userId ) ; } else { $ count += $ engine -> checkTokensFromStart ( $ this , $ userId ) ; } $ this -> db -> commit ( ) ; $ this -> _checkTrackCount ( $ userId ) ; return $ count ; }
Check this respondent track for changes to the tokens
57,711
public function getActiveRoundToken ( $ roundId , \ Gems_Tracker_Token $ token = null ) { if ( ( null !== $ token ) && $ token -> hasSuccesCode ( ) ) { $ this -> _activeTokens [ $ token -> getRoundId ( ) ] = $ token ; } if ( ! $ roundId ) { return null ; } if ( ! array_key_exists ( $ roundId , $ this -> _activeTokens ) ) { $ tokenSelect = $ this -> tracker -> getTokenSelect ( ) ; $ tokenSelect -> andReceptionCodes ( ) -> forRespondentTrack ( $ this -> _respTrackId ) -> forRound ( $ roundId ) -> onlySucces ( ) ; if ( $ tokenData = $ tokenSelect -> fetchRow ( ) ) { $ this -> _activeTokens [ $ roundId ] = $ this -> tracker -> getToken ( $ tokenData ) ; } else { $ this -> _activeTokens [ $ roundId ] = null ; } } return $ this -> _activeTokens [ $ roundId ] ; }
Returns a token with a success reception code for this round or null
57,712
public function getCodeFields ( ) { $ fieldDef = $ this -> getTrackEngine ( ) -> getFieldsDefinition ( ) ; $ codes = $ this -> tracker -> getAllCodeFields ( ) ; $ results = array_fill_keys ( $ codes , null ) ; $ this -> _ensureFieldData ( ) ; foreach ( $ this -> _fieldData as $ id => $ value ) { if ( ! isset ( $ codes [ $ id ] ) ) { continue ; } $ fieldCode = $ codes [ $ id ] ; $ results [ $ fieldCode ] = $ value ; $ field = $ fieldDef -> getFieldByCode ( $ fieldCode ) ; if ( ! is_null ( $ field ) ) { $ results [ $ fieldCode ] = $ field -> calculateFieldInfo ( $ value , $ this -> _fieldData ) ; } } return $ results ; }
Return all possible code fields with the values filled for those that exist for this track optionally with a prefix
57,713
public function getCurrentRound ( ) { $ isStop = false ; $ today = new \ Zend_Date ( ) ; $ tokens = $ this -> getTokens ( ) ; $ stop = $ this -> util -> getReceptionCodeLibrary ( ) -> getStopString ( ) ; foreach ( $ tokens as $ token ) { $ validUntil = $ token -> getValidUntil ( ) ; if ( ! empty ( $ validUntil ) && $ validUntil -> isEarlier ( $ today ) ) { continue ; } if ( $ token -> isCompleted ( ) ) { continue ; } $ code = $ token -> getReceptionCode ( ) ; if ( ! $ code -> isSuccess ( ) ) { if ( $ code -> getCode ( ) === $ stop ) { $ isStop = true ; } continue ; } return $ token -> getRoundDescription ( ) ; } if ( $ isStop ) { return $ this -> translate -> _ ( 'Track stopped' ) ; } return $ this -> translate -> _ ( 'Track completed' ) ; }
The round description of the first round that has not been answered .
57,714
public function getFirstToken ( ) { if ( ! $ this -> _firstToken ) { if ( ! $ this -> _tokens ) { $ this -> getTokens ( ) ; } $ this -> _firstToken = reset ( $ this -> _tokens ) ; } return $ this -> _firstToken ; }
Returns the first token in this track
57,715
public function getRespondentName ( ) { if ( ! isset ( $ this -> _respTrackData [ 'grs_first_name' ] , $ this -> _respTrackData [ 'grs_last_name' ] ) ) { $ this -> _ensureRespondentData ( ) ; } return trim ( $ this -> _respTrackData [ 'grs_first_name' ] . ' ' . $ this -> _respTrackData [ 'grs_surname_prefix' ] ) . ' ' . $ this -> _respTrackData [ 'grs_last_name' ] ; }
Return the name of the respondent
57,716
public function getRoundCode ( $ roundId ) { $ this -> _ensureRounds ( ) ; $ roundCode = null ; if ( array_key_exists ( $ roundId , $ this -> _rounds ) && array_key_exists ( 'gro_code' , $ this -> _rounds [ $ roundId ] ) ) { $ roundCode = $ this -> _rounds [ $ roundId ] [ 'gro_code' ] ; } return $ roundCode ; }
Return the round code for a given roundId
57,717
public function getTokens ( $ refresh = false ) { if ( ! $ this -> _tokens || $ refresh ) { if ( $ refresh ) { $ this -> _firstToken = null ; } $ this -> _tokens = array ( ) ; $ this -> _activeTokens = array ( ) ; $ tokenSelect = $ this -> tracker -> getTokenSelect ( ) ; $ tokenSelect -> andReceptionCodes ( ) -> forRespondentTrack ( $ this -> _respTrackId ) ; $ tokenRows = $ tokenSelect -> fetchAll ( ) ; $ prevToken = null ; foreach ( $ tokenRows as $ tokenData ) { $ token = $ this -> tracker -> getToken ( $ tokenData ) ; $ this -> _tokens [ $ token -> getTokenId ( ) ] = $ token ; if ( $ token -> hasSuccesCode ( ) ) { $ this -> _activeTokens [ $ token -> getRoundId ( ) ] = $ token ; } if ( $ prevToken ) { $ prevToken -> setNextToken ( $ token ) ; } $ prevToken = $ token ; } } return $ this -> _tokens ; }
Returns all the tokens in this track
57,718
public function handleBeforeFieldUpdate ( array $ fieldData ) { static $ running = array ( ) ; $ trackEngine = $ this -> getTrackEngine ( ) ; if ( ! $ trackEngine ) { return array ( ) ; } $ event = $ trackEngine -> getFieldBeforeUpdateEvent ( ) ; if ( ! $ event ) { return array ( ) ; } if ( isset ( $ running [ $ this -> _respTrackId ] ) ) { throw new \ Gems_Exception ( sprintf ( "Nested calls to '%s' track before field update event are not allowed." , $ trackEngine -> getName ( ) ) ) ; } $ running [ $ this -> _respTrackId ] = true ; $ output = $ event -> prepareFieldUpdate ( $ fieldData , $ this ) ; unset ( $ running [ $ this -> _respTrackId ] ) ; return $ output ; }
Find out if there are before field update events and delegate to the event if needed
57,719
public function handleFieldUpdate ( ) { static $ running = array ( ) ; $ trackEngine = $ this -> getTrackEngine ( ) ; if ( ! $ trackEngine ) { return ; } $ event = $ trackEngine -> getFieldUpdateEvent ( ) ; if ( ! $ event ) { return ; } if ( isset ( $ running [ $ this -> _respTrackId ] ) ) { throw new \ Gems_Exception ( sprintf ( "Nested calls to '%s' track after field update event are not allowed." , $ trackEngine -> getName ( ) ) ) ; } $ running [ $ this -> _respTrackId ] = true ; $ event -> processFieldUpdate ( $ this , $ this -> currentUser -> getUserId ( ) ) ; unset ( $ running [ $ this -> _respTrackId ] ) ; }
Find out if there are field update events and delegate to the event if needed
57,720
public function handleTrackCalculation ( $ userId ) { $ trackEngine = $ this -> getTrackEngine ( ) ; $ this -> assignTokensToRelations ( ) ; if ( $ event = $ trackEngine -> getTrackCalculationEvent ( ) ) { return $ event -> processTrackCalculation ( $ this , $ userId ) ; } return 0 ; }
Find out if there are track calculation events and delegate to the event if needed
57,721
public function handleTrackCompletion ( & $ values , $ userId ) { $ trackEngine = $ this -> getTrackEngine ( ) ; if ( $ event = $ trackEngine -> getTrackCompletionEvent ( ) ) { $ event -> processTrackCompletion ( $ this , $ values , $ userId ) ; } }
Find out if there are track completion events and delegate to the event if needed
57,722
public function isOpen ( ) { if ( isset ( $ this -> _respTrackData [ 'gr2t_count' ] , $ this -> _respTrackData [ 'gr2t_completed' ] ) ) { return $ this -> _respTrackData [ 'gr2t_count' ] > $ this -> _respTrackData [ 'gr2t_completed' ] ; } return true ; }
Are there still unanswered rounds
57,723
public function processFieldsBeforeSave ( array $ newFieldData ) { $ trackEngine = $ this -> getTrackEngine ( ) ; if ( ! $ trackEngine ) { return $ newFieldData ; } $ step1Data = $ this -> _mergeFieldValues ( $ newFieldData , $ this -> getFieldData ( ) , $ trackEngine ) ; $ step2Data = $ trackEngine -> getFieldsDefinition ( ) -> processBeforeSave ( $ step1Data , $ this -> _respTrackData ) ; $ step3Data = $ this -> handleBeforeFieldUpdate ( $ this -> _mergeFieldValues ( $ step2Data , $ step1Data , $ trackEngine ) ) ; if ( $ step3Data ) { return $ this -> _mergeFieldValues ( $ step3Data , $ step2Data , $ trackEngine ) ; } else { return $ step2Data ; } }
Processes the field values and and changes them as required
57,724
public function setFieldData ( $ newFieldData ) { $ trackEngine = $ this -> getTrackEngine ( ) ; if ( ! $ trackEngine ) { return $ newFieldData ; } $ this -> _fieldData = $ this -> processFieldsBeforeSave ( $ newFieldData ) ; $ changes = $ this -> saveFields ( array ( ) ) ; if ( $ changes ) { $ info = $ trackEngine -> getFieldsDefinition ( ) -> calculateFieldsInfo ( $ this -> _fieldData ) ; if ( $ info != $ this -> _respTrackData [ 'gr2t_track_info' ] ) { $ this -> _updateTrack ( array ( 'gr2t_track_info' => $ info ) , $ this -> currentUser -> getUserId ( ) ) ; } } return $ this -> _fieldData ; }
Update one or more values for this track s fields .
57,725
public function setMailable ( $ mailable ) { $ values [ 'gr2t_mailable' ] = $ mailable ? 1 : 0 ; return $ this -> _updateTrack ( $ values , $ this -> currentUser -> getUserId ( ) ) ; }
Set the mailability for this respondent track .
57,726
public function setReceptionCode ( $ code , $ comment , $ userId ) { if ( ! $ code instanceof \ Gems_Util_ReceptionCode ) { $ code = $ this -> util -> getReceptionCode ( $ code ) ; } $ changed = 0 ; if ( $ code -> isForTracks ( ) || $ code -> isOverwriter ( ) ) { $ values [ 'gr2t_reception_code' ] = $ code -> getCode ( ) ; } $ values [ 'gr2t_comment' ] = $ comment ; $ changed = $ this -> _updateTrack ( $ values , $ userId ) ; if ( $ code -> isStopCode ( ) ) { foreach ( $ this -> getTokens ( ) as $ token ) { if ( $ token -> hasSuccesCode ( ) && ( ! $ token -> isCompleted ( ) ) ) { $ changed += $ token -> setReceptionCode ( $ code , $ comment , $ userId ) ; } } $ changed = max ( $ changed , 1 ) ; $ this -> _checkTrackCount ( $ userId ) ; } elseif ( ! $ code -> isSuccess ( ) ) { foreach ( $ this -> getTokens ( ) as $ token ) { if ( $ token -> hasSuccesCode ( ) ) { $ token -> setReceptionCode ( $ code , $ comment , $ userId ) ; } } } return $ changed ; }
Set the reception code for this respondent track and make sure the necessary cascade to the tokens and thus the source takes place .
57,727
public function getCommTemplates ( $ mailTarget = false ) { static $ data ; if ( ! $ data ) { $ sql = 'SELECT gct_id_template, gct_name FROM gems__comm_templates ' ; if ( $ mailTarget ) { $ sql .= 'WHERE gct_target = ? ' ; } $ sql .= 'ORDER BY gct_name' ; if ( $ mailTarget ) { $ data = $ this -> db -> fetchPairs ( $ sql , $ mailTarget ) ; } else { $ data = $ this -> db -> fetchPairs ( $ sql ) ; } } return $ data ; }
Return the available Comm templates .
57,728
public function getFilterForMailJob ( $ job , $ respondentId = null , $ organizationId = null ) { $ filter = array ( 'can_email' => 1 , 'gtr_active' => 1 , 'gsu_active' => 1 , 'grc_success' => 1 , 'gto_completion_time' => NULL , 'gto_valid_from <= CURRENT_TIMESTAMP' , '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)' ) ; switch ( $ job [ 'gcj_filter_mode' ] ) { case 'E' : $ filter [ ] = 'gto_mail_sent_date < CURRENT_DATE() AND CURRENT_DATE() = DATE(DATE_SUB(gto_valid_until, INTERVAL ' . $ job [ 'gcj_filter_days_between' ] . ' DAY))' ; break ; case 'R' : $ filter [ ] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $ job [ 'gcj_filter_days_between' ] . ' DAY)' ; $ filter [ ] = 'gto_mail_sent_num <= ' . $ job [ 'gcj_filter_max_reminders' ] ; break ; case 'N' : default : $ filter [ 'gto_mail_sent_date' ] = NULL ; break ; } if ( $ job [ 'gcj_id_organization' ] ) { if ( $ organizationId && ( $ organizationId !== $ job [ 'gcj_id_organization' ] ) ) { $ filter [ ] = '1=0' ; return $ filter ; } $ filter [ 'gto_id_organization' ] = $ job [ 'gcj_id_organization' ] ; } if ( $ job [ 'gcj_id_track' ] ) { $ filter [ 'gto_id_track' ] = $ job [ 'gcj_id_track' ] ; } if ( $ job [ 'gcj_round_description' ] ) { if ( $ job [ 'gcj_id_track' ] ) { $ roundIds = $ this -> db -> fetchCol ( ' SELECT gro_id_round FROM gems__rounds WHERE gro_active = 1 AND gro_id_track = ? AND gro_round_description = ?' , array ( $ job [ 'gcj_id_track' ] , $ job [ 'gcj_round_description' ] ) ) ; } else { $ roundIds = $ this -> db -> fetchCol ( ' SELECT gro_id_round FROM gems__rounds WHERE gro_active = 1 AND gro_round_description = ?' , array ( $ job [ 'gcj_round_description' ] ) ) ; } $ filter [ ] = sprintf ( '(gto_id_round IN (%s)) OR (gto_id_round = 0 AND gto_round_description = %s)' , $ this -> db -> quote ( $ roundIds ) , $ this -> db -> quote ( $ job [ 'gcj_round_description' ] ) ) ; } if ( $ job [ 'gcj_id_survey' ] ) { $ filter [ 'gto_id_survey' ] = $ job [ 'gcj_id_survey' ] ; } if ( $ respondentId ) { $ filter [ 'gto_id_respondent' ] = $ respondentId ; } if ( $ job [ 'gcj_target' ] == 1 ) { $ filter [ ] = 'gto_id_relation <> 0' ; } elseif ( $ job [ 'gcj_target' ] == 2 ) { $ filter [ ] = '(gto_id_relation = 0 OR gto_id_relation IS NULL)' ; } return $ filter ; }
Get the filter to use on the tokenmodel when working with a mailjob .
57,729
public function getGroups ( ) { $ sql = "SELECT ggp_id_group, ggp_name FROM gems__groups WHERE ggp_group_active = 1 ORDER BY ggp_name" ; return $ this -> util -> getTranslated ( ) -> getEmptyDropdownArray ( ) + $ this -> _getSelectPairsCached ( __FUNCTION__ , $ sql , null , 'groups' ) ; }
The active groups
57,730
public function getOrganizations ( ) { $ sql = "SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active = 1 ORDER BY gor_name" ; try { $ organizations = $ this -> _getSelectPairsCached ( __FUNCTION__ , $ sql , null , 'organizations' , 'natsort' ) ; } catch ( \ Exception $ exc ) { $ organizations = array ( ) ; } return $ organizations ; }
Get all active organizations
57,731
public function getOrganizationsByCode ( $ code = null ) { if ( is_null ( $ code ) ) { return $ this -> getOrganizations ( ) ; } $ sql = "SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active = 1 and gor_code = ? ORDER BY gor_name" ; return $ this -> _getSelectPairsCached ( __FUNCTION__ . '_' . $ code , $ sql , $ code , 'organizations' , 'natsort' ) ; }
Get all organizations that share a given code
57,732
public function getRoles ( ) { $ roles = array ( ) ; if ( $ this -> acl ) { foreach ( $ this -> acl -> getRoles ( ) as $ role ) { $ roles [ $ role ] = ucfirst ( $ role ) ; } } asort ( $ roles ) ; return $ roles ; }
Returns the roles in the acl
57,733
public function getRolesByPrivilege ( $ privilege ) { $ roles = array ( ) ; if ( $ this -> acl ) { foreach ( $ this -> acl -> getRoles ( ) as $ role ) { if ( $ this -> acl -> isAllowed ( $ role , null , $ privilege ) ) { $ roles [ $ role ] = ucfirst ( $ role ) ; } } } return $ roles ; }
Returns the roles in the acl with the privilege
57,734
public function getRoundsForExport ( $ trackId = null , $ surveyId = null ) { $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__tokens' , array ( 'gto_round_description' , 'gto_round_description' ) ) -> distinct ( ) -> where ( 'gto_round_description IS NOT NULL AND gto_round_description != ""' ) -> order ( array ( 'gto_round_description' ) ) ; if ( ! empty ( $ trackId ) ) { $ select -> where ( 'gto_id_track = ?' , ( int ) $ trackId ) ; } if ( ! empty ( $ surveyId ) ) { $ select -> where ( 'gto_id_survey = ?' , ( int ) $ surveyId ) ; } $ result = $ this -> db -> fetchPairs ( $ select ) ; return $ result ; }
Get all round descriptions for exported
57,735
public function getSurveysForExport ( $ trackId = null , $ roundDescription = null , $ flat = false ) { $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__surveys' ) -> join ( 'gems__sources' , 'gsu_id_source = gso_id_source' ) -> where ( 'gso_active = 1' ) -> order ( array ( 'gsu_active DESC' , 'gsu_survey_name' ) ) ; if ( $ trackId ) { if ( $ roundDescription ) { $ select -> where ( 'gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ? AND gto_round_description = ' . $ this -> db -> quote ( $ roundDescription ) . ')' , $ trackId ) ; } else { $ select -> where ( 'gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_id_track = ?)' , $ trackId ) ; } } elseif ( $ roundDescription ) { $ select -> where ( 'gsu_id_survey IN (SELECT gto_id_survey FROM gems__tokens WHERE gto_round_description = ?)' , $ roundDescription ) ; } $ result = $ this -> db -> fetchAll ( $ select ) ; if ( $ result ) { $ surveys = array ( ) ; $ inactive = $ this -> _ ( 'inactive' ) ; $ sourceInactive = $ this -> _ ( 'source inactive' ) ; foreach ( $ result as $ survey ) { $ id = $ survey [ 'gsu_id_survey' ] ; $ name = $ survey [ 'gsu_survey_name' ] ; if ( $ survey [ 'gsu_surveyor_active' ] == 0 ) { if ( strpos ( $ survey [ 'gso_ls_class' ] , 'LimeSurvey' ) === false ) { if ( $ flat ) { $ surveys [ $ id ] = $ name . " ($sourceInactive) " ; } else { $ surveys [ $ sourceInactive ] [ $ id ] = $ name ; } } } elseif ( $ survey [ 'gsu_active' ] == 0 ) { if ( $ flat ) { $ surveys [ $ id ] = $ name . " ($inactive) " ; } else { $ surveys [ $ inactive ] [ $ id ] = $ name ; } } else { $ surveys [ $ id ] = $ name ; } } } else { $ surveys = array ( ) ; } return $ surveys ; }
Get all surveys that can be exported
57,736
protected function getRoundsListAndSetDefault ( ) { $ model = $ this -> getModel ( ) ; $ output = array ( ) ; $ select = $ this -> getRoundSelect ( ) ; if ( $ select instanceof \ Zend_Db_Select ) { $ rows = $ this -> db -> fetchAll ( $ select ) ; } else { $ rows = $ select ; } if ( $ rows ) { $ maxAnswered = 0 ; $ maxGroupAnswered = 0 ; $ minGroup = - 1 ; foreach ( $ rows as $ row ) { $ output [ $ row [ 'round_order' ] ] = $ row [ 'round_description' ] ; if ( $ row [ 'has_group' ] ) { if ( - 1 === $ minGroup ) { $ minGroup = $ row [ 'round_order' ] ; } if ( $ row [ 'group_answered' ] ) { $ maxGroupAnswered = $ row [ 'round_order' ] ; } } if ( $ row [ 'any_answered' ] ) { $ maxAnswered = $ row [ 'round_order' ] ; } } if ( $ maxGroupAnswered ) { $ this -> defaultRound = $ maxGroupAnswered ; $ model -> set ( 'gto_round_order' , 'description' , sprintf ( $ this -> _ ( 'The last round containing answers for surveys in the same user group is "%s".' ) , $ output [ $ this -> defaultRound ] ) ) ; } elseif ( $ maxAnswered ) { $ this -> defaultRound = $ maxAnswered ; $ model -> set ( 'gto_round_order' , 'description' , sprintf ( $ this -> _ ( 'The last round containing answers is "%s".' ) , $ output [ $ this -> defaultRound ] ) ) ; } elseif ( - 1 !== $ minGroup ) { $ this -> defaultRound = $ minGroup ; $ model -> set ( 'gto_round_order' , 'description' , sprintf ( $ this -> _ ( 'No survey has been answered, the first round with surveys in the same user group is "%s".' ) , $ output [ $ this -> defaultRound ] ) ) ; } else { reset ( $ output ) ; $ this -> defaultRound = key ( $ output ) ; $ model -> set ( 'gto_round_order' , 'description' , $ this -> _ ( 'No surveys have answers, nor are any in the same user group.' ) ) ; } } else { $ output [ 10 ] = $ this -> _ ( 'Added survey' ) ; $ this -> defaultRound = 10 ; $ model -> set ( 'gto_round_order' , 'description' , $ this -> _ ( 'No current rounds available.' ) ) ; } return $ output ; }
Get the list of rounds and set the default
57,737
protected function loadRoundSettings ( ) { $ rounds = $ this -> getRoundsListAndSetDefault ( ) ; $ model = $ this -> getModel ( ) ; $ model -> set ( 'gto_round_order' , 'multiOptions' , $ rounds , 'size' , count ( $ rounds ) ) ; if ( count ( $ rounds ) === 1 ) { $ model -> set ( 'gto_round_order' , 'elementClass' , 'Exhibitor' ) ; } if ( ! isset ( $ this -> formData [ 'gto_round_order' ] , $ rounds [ $ this -> formData [ 'gto_round_order' ] ] ) ) { $ this -> formData [ 'gto_round_order' ] = $ this -> defaultRound ; } if ( ! isset ( $ rounds [ $ this -> formData [ 'gto_round_order' ] ] ) ) { reset ( $ rounds ) ; $ this -> formData [ 'gto_round_order' ] = key ( $ rounds ) ; } }
Load the settings for the round
57,738
protected function loadSurvey ( ) { if ( ! $ this -> surveyList ) { $ this -> addMessageInvalid ( $ this -> _ ( 'Survey insertion impossible: no insertable survey exists!' ) ) ; } if ( count ( $ this -> surveyList ) === 1 ) { $ model = $ this -> getModel ( ) ; $ model -> set ( 'gto_id_survey' , 'elementClass' , 'Exhibitor' ) ; reset ( $ this -> surveyList ) ; $ this -> formData [ 'gto_id_survey' ] = key ( $ this -> surveyList ) ; } if ( isset ( $ this -> formData [ 'gto_id_survey' ] ) ) { $ this -> survey = $ this -> tracker -> getSurvey ( $ this -> formData [ 'gto_id_survey' ] ) ; $ groupId = $ this -> survey -> getGroupId ( ) ; $ groups = $ this -> util -> getDbLookup ( ) -> getGroups ( ) ; if ( isset ( $ groups [ $ groupId ] ) ) { $ this -> formData [ 'ggp_name' ] = $ groups [ $ groupId ] ; } $ this -> formData [ 'gto_valid_until' ] = $ this -> survey -> getInsertDateUntil ( $ this -> formData [ 'gto_valid_from' ] ) ; } }
Load the survey object and use it
57,739
protected function loadTrackSettings ( ) { $ respTracks = $ this -> tracker -> getRespondentTracks ( $ this -> formData [ 'gto_id_respondent' ] , $ this -> formData [ 'gto_id_organization' ] ) ; $ tracks = array ( ) ; foreach ( $ respTracks as $ respTrack ) { if ( $ respTrack instanceof \ Gems_Tracker_RespondentTrack ) { if ( $ respTrack -> hasSuccesCode ( ) ) { $ tracks [ $ respTrack -> getRespondentTrackId ( ) ] = substr ( sprintf ( $ this -> _ ( '%s - %s' ) , $ respTrack -> getTrackEngine ( ) -> getTrackName ( ) , $ respTrack -> getFieldsInfo ( ) ) , 0 , 100 ) ; } } } if ( $ tracks ) { if ( ! isset ( $ this -> formData [ 'gto_id_track' ] ) ) { reset ( $ tracks ) ; $ this -> formData [ 'gto_id_track' ] = key ( $ tracks ) ; } } else { $ this -> addMessageInvalid ( $ this -> _ ( 'Survey insertion impossible: respondent has no track!' ) ) ; $ tracks = $ this -> util -> getTranslated ( ) -> getEmptyDropdownArray ( ) ; } asort ( $ tracks ) ; $ model = $ this -> getModel ( ) ; $ model -> set ( 'gto_id_track' , 'multiOptions' , $ tracks ) ; if ( count ( $ tracks ) === 1 ) { $ model -> set ( 'gto_id_track' , 'elementClass' , 'Exhibitor' ) ; } if ( isset ( $ this -> formData [ 'gto_id_track' ] ) ) { $ this -> respondentTrack = $ respTracks [ $ this -> formData [ 'gto_id_track' ] ] ; if ( $ this -> survey && $ this -> survey -> isTakenByStaff ( ) === false ) { $ engine = $ this -> respondentTrack -> getTrackEngine ( ) ; if ( method_exists ( $ engine , 'getRespondentRelationFields' ) ) { $ empty = array ( '-1' => $ this -> _ ( 'Patient' ) ) ; $ relations = $ empty + $ engine -> getRespondentRelationFields ( ) ; $ model -> set ( 'gto_id_relationfield' , 'label' , $ this -> _ ( 'Fill out by' ) , 'multiOptions' , $ relations , 'elementClass' , 'Select' , 'required' , true ) ; } } } }
Load the settings for the survey
57,740
protected function _getScreenClass ( $ screenType ) { if ( isset ( $ this -> _screenClasses [ $ screenType ] ) ) { return $ this -> _screenClasses [ $ screenType ] ; } else { throw new \ Gems_Exception_Coding ( "No screen class exists for screen type '$screenType'." ) ; } }
Lookup screen class for a screen type . This class or interface should at the very least implement the ScreenInterface .
57,741
protected function _listScreens ( $ screenType ) { $ screenClass = $ this -> _getScreenClass ( $ screenType ) ; $ paths = $ this -> _getScreenDirs ( $ screenType ) ; return $ this -> listClasses ( $ screenClass , $ paths , 'getScreenLabel' ) ; }
Returns a list of selectable screens with an empty element as the first option .
57,742
protected function sortCalcDateCheck ( \ MUtil_Model_ModelAbstract $ model ) { $ sort = $ model -> getSort ( ) ; if ( isset ( $ sort [ 'calc_used_date' ] ) ) { $ add = true ; $ resultSort = array ( ) ; foreach ( $ sort as $ key => $ asc ) { if ( 'calc_used_date' === $ key ) { if ( $ add ) { $ resultSort [ 'is_completed' ] = $ asc ; $ resultSort [ 'gto_completion_time' ] = $ asc == SORT_ASC ? SORT_DESC : SORT_ASC ; $ resultSort [ 'calc_valid_from' ] = $ asc ; $ add = false ; } } else { $ resultSort [ $ key ] = $ asc ; } } if ( ! $ add ) { $ model -> setSort ( $ resultSort ) ; } } }
calc_used_date has special sort see bugs 108 and 127
57,743
public function getDateUnitsList ( ) { return array ( 'S' => $ this -> translate -> _ ( 'Seconds' ) , 'N' => $ this -> translate -> _ ( 'Minutes' ) , 'H' => $ this -> translate -> _ ( 'Hours' ) , 'D' => $ this -> translate -> _ ( 'Days' ) , 'W' => $ this -> translate -> _ ( 'Weeks' ) , 'M' => $ this -> translate -> _ ( 'Months' ) , 'Q' => $ this -> translate -> _ ( 'Quarters' ) , 'Y' => $ this -> translate -> _ ( 'Years' ) ) ; }
Get an array of translated labels for the date units used by this engine
57,744
public function getSurveysByCode ( $ code ) { $ cacheId = __CLASS__ . '_' . __FUNCTION__ . '_' . $ code ; if ( $ results = $ this -> cache -> load ( $ cacheId ) ) { return $ results ; } $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__surveys' , array ( 'gsu_id_survey' , 'gsu_survey_name' ) ) -> where ( "gsu_code = ?" , $ code ) -> where ( "gsu_active = 1" ) -> order ( 'gsu_survey_name' ) ; $ results = $ this -> db -> fetchPairs ( $ select ) ; $ this -> cache -> save ( $ results , $ cacheId , array ( 'surveys' ) ) ; return $ results ; }
Get all the surveys for a certain code
57,745
public function getSurveysFor ( $ organizationId ) { if ( $ organizationId !== null ) { $ where = "AND EXISTS (SELECT 1 FROM gems__rounds INNER JOIN gems__tracks ON gro_id_track = gtr_id_track WHERE gro_id_survey = gsu_id_survey AND gtr_organizations LIKE '%|" . ( int ) $ organizationId . "|%')" ; } else { $ where = "" ; } $ sql = "SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys WHERE gsu_active = 1 " . $ where . " ORDER BY gsu_survey_name ASC" ; return $ this -> _getSelectPairsCached ( __FUNCTION__ . '_' . $ organizationId , $ sql , array ( ) , 'surveys' ) ; }
Get all the surveys for a certain organization id
57,746
public function getTracksBySurvey ( $ surveyId ) { $ cacheId = __CLASS__ . '_' . __FUNCTION__ . '_' . $ surveyId ; if ( $ results = $ this -> cache -> load ( $ cacheId ) ) { return $ results ; } $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__tracks' , array ( 'gtr_id_track' , 'gtr_track_name' ) ) -> joinInner ( 'gems__rounds' , 'gtr_id_track = gro_id_track' , array ( ) ) -> where ( "gro_id_survey = ?" , $ surveyId ) -> where ( "gtr_active = 1" ) -> where ( "gro_active = 1" ) -> order ( 'gtr_track_name' ) ; $ results = $ this -> db -> fetchPairs ( $ select ) ; $ this -> cache -> save ( $ results , $ cacheId , array ( 'surveys' , 'tracks' ) ) ; return $ results ; }
Get all the tracks for a certain survey
57,747
public function getTrackTitle ( $ trackId ) { $ tracks = $ this -> getAllTracks ( ) ; if ( $ tracks && isset ( $ tracks [ $ trackId ] ) ) { return $ tracks [ $ trackId ] ; } }
Returns title of the track .
57,748
public function onBootstrap ( MvcEvent $ e ) { $ manager = Container :: getDefaultManager ( ) ; if ( ! $ manager -> sessionExists ( ) ) { return ; } $ app = $ e -> getApplication ( ) ; $ sharedEvm = $ app -> getEventManager ( ) -> getSharedManager ( ) ; $ sharedEvm -> attach ( AbstractActionController :: class , 'dispatch' , [ $ this , 'flashMessengerHandler' ] , 2 ) ; }
Bootstrap Handle FlashMessenger session show .
57,749
private function duplicateFlashMessengerSessionData ( Container $ container ) : void { $ flashToolbarContainer = new Container ( 'SanSessionToolbarFlashMessenger' ) ; foreach ( $ container -> getArrayCopy ( ) as $ key => $ row ) { foreach ( $ row -> toArray ( ) as $ keyArray => $ rowArray ) { if ( $ keyArray === 0 ) { $ flashToolbarContainer -> $ key = new SplQueue ( ) ; } $ flashToolbarContainer -> $ key -> push ( $ rowArray ) ; } } }
Used to duplicate flashMessenger data as it shown and gone .
57,750
public function flashMessengerHandler ( EventInterface $ e ) : void { $ controller = $ e -> getTarget ( ) ; if ( ! $ controller -> getPluginManager ( ) -> has ( 'flashMessenger' ) ) { return ; } $ flash = $ controller -> plugin ( 'flashMessenger' ) ; $ container = $ flash -> getContainer ( ) ; $ this -> duplicateFlashMessengerSessionData ( $ container ) ; }
Handle FlashMessenger data to be able to be seen in both app and toolbar parts .
57,751
protected function _showTable ( $ caption , $ data , $ nested = false ) { $ table = \ MUtil_Html_TableElement :: createArray ( $ data , $ caption , $ nested ) ; $ table -> class = 'browser table' ; $ div = \ MUtil_Html :: create ( ) -> div ( array ( 'class' => 'table-container' ) ) ; $ div [ ] = $ table ; $ this -> html [ ] = $ div ; }
Helper function to show a table
57,752
public function formatLongLine ( array $ privileges ) { $ output = \ MUtil_Html :: create ( 'div' ) ; if ( count ( $ privileges ) ) { $ privileges = array_combine ( $ privileges , $ privileges ) ; foreach ( $ this -> getUsedPrivileges ( ) as $ privilege => $ description ) { if ( isset ( $ privileges [ $ privilege ] ) ) { if ( count ( $ output ) > 11 ) { $ output -> append ( '...' ) ; return $ output ; } if ( \ MUtil_String :: contains ( $ description , '<br/>' ) ) { $ description = substr ( $ description , 0 , strpos ( $ description , '<br/>' ) - 1 ) ; } $ output -> raw ( $ description ) ; $ output -> br ( ) ; } } } return $ output ; }
Output for browsing rols
57,753
public function formatPrivileges ( array $ privileges ) { if ( count ( $ privileges ) ) { $ output = \ MUtil_Html_ListElement :: ul ( ) ; $ privileges = array_combine ( $ privileges , $ privileges ) ; $ output -> class = 'allowed' ; foreach ( $ this -> getUsedPrivileges ( ) as $ privilege => $ description ) { if ( isset ( $ privileges [ $ privilege ] ) ) { $ output -> li ( ) -> raw ( $ description ) ; } } if ( count ( $ output ) ) { return $ output ; } } return \ MUtil_Html :: create ( 'em' , $ this -> _ ( 'No privileges found.' ) ) ; }
Output for viewing rols
57,754
protected function getInheritedPrivileges ( array $ parents ) { if ( ! $ parents ) { return array ( ) ; } $ rolePrivileges = $ this -> acl -> getRolePrivileges ( ) ; $ inherited = array ( ) ; foreach ( $ parents as $ parent ) { if ( isset ( $ rolePrivileges [ $ parent ] ) ) { $ inherited = $ inherited + array_flip ( $ rolePrivileges [ $ parent ] [ \ Zend_Acl :: TYPE_ALLOW ] ) ; $ inherited = $ inherited + array_flip ( $ rolePrivileges [ $ parent ] [ \ MUtil_Acl :: INHERITED ] [ \ Zend_Acl :: TYPE_ALLOW ] ) ; } } unset ( $ inherited [ "" ] ) ; return $ inherited ; }
Get the privileges for thess parents
57,755
protected function getUsedPrivileges ( ) { if ( ! $ this -> usedPrivileges ) { $ privileges = $ this -> menu -> getUsedPrivileges ( ) ; asort ( $ privileges ) ; unset ( $ privileges [ 'pr.nologin' ] ) ; unset ( $ privileges [ 'pr.islogin' ] ) ; $ this -> usedPrivileges = $ privileges ; } return $ this -> usedPrivileges ; }
Get the privileges a role can have .
57,756
public function overviewAction ( ) { $ roles = array ( ) ; foreach ( $ this -> acl -> getRolePrivileges ( ) as $ role => $ privileges ) { $ roles [ $ role ] [ $ this -> _ ( 'Role' ) ] = $ role ; $ roles [ $ role ] [ $ this -> _ ( 'Parents' ) ] = $ privileges [ \ MUtil_Acl :: PARENTS ] ? implode ( ', ' , $ privileges [ \ MUtil_Acl :: PARENTS ] ) : null ; $ roles [ $ role ] [ $ this -> _ ( 'Allowed' ) ] = $ privileges [ \ Zend_Acl :: TYPE_ALLOW ] ? implode ( ', ' , $ privileges [ \ Zend_Acl :: TYPE_ALLOW ] ) : null ; $ roles [ $ role ] [ $ this -> _ ( 'Inherited' ) ] = $ privileges [ \ MUtil_Acl :: INHERITED ] [ \ Zend_Acl :: TYPE_ALLOW ] ? implode ( ', ' , $ privileges [ \ MUtil_Acl :: INHERITED ] [ \ Zend_Acl :: TYPE_ALLOW ] ) : null ; } ksort ( $ roles ) ; $ this -> html -> h2 ( $ this -> _ ( 'Project role overview' ) ) ; $ this -> _showTable ( $ this -> _ ( 'Roles' ) , $ roles , true ) ; }
Action to shw overview of all privileges
57,757
public function privilegeAction ( ) { $ privileges = array ( ) ; foreach ( $ this -> acl -> getPrivilegeRoles ( ) as $ privilege => $ roles ) { $ privileges [ $ privilege ] [ $ this -> _ ( 'Privilege' ) ] = $ privilege ; $ privileges [ $ privilege ] [ $ this -> _ ( 'Allowed' ) ] = $ roles [ \ Zend_Acl :: TYPE_ALLOW ] ? implode ( ', ' , $ roles [ \ Zend_Acl :: TYPE_ALLOW ] ) : null ; $ privileges [ $ privilege ] [ $ this -> _ ( 'Denied' ) ] = $ roles [ \ Zend_Acl :: TYPE_DENY ] ? implode ( ', ' , $ roles [ \ Zend_Acl :: TYPE_DENY ] ) : null ; } $ all_existing = $ this -> getUsedPrivileges ( ) ; $ unassigned = array_diff_key ( $ all_existing , $ privileges ) ; $ nonexistent = array_diff_key ( $ privileges , $ all_existing ) ; unset ( $ nonexistent [ 'pr.nologin' ] ) ; unset ( $ nonexistent [ 'pr.islogin' ] ) ; ksort ( $ nonexistent ) ; foreach ( $ unassigned as $ privilege => $ description ) { $ privileges [ $ privilege ] = array ( $ this -> _ ( 'Privilege' ) => $ privilege , $ this -> _ ( 'Allowed' ) => null , $ this -> _ ( 'Denied' ) => null ) ; } ksort ( $ privileges ) ; $ this -> html -> h2 ( $ this -> _ ( 'Project privileges' ) ) ; $ this -> _showTable ( $ this -> _ ( 'Privileges' ) , $ privileges , true ) ; if ( ! empty ( $ nonexistent ) ) { $ this -> _showTable ( $ this -> _ ( 'Assigned but nonexistent privileges' ) , $ nonexistent , true ) ; } }
Action to show all privileges
57,758
public function handle ( $ path = null ) { $ path = ltrim ( $ path , '/' ) ; $ cleanPrefix = rtrim ( $ this -> urlPrefix , '/' ) ; return sprintf ( '%s/%s' , $ cleanPrefix , $ path ) ; }
Executes the plugin .
57,759
protected function addSynchronizationInformation ( ) { $ this -> html -> pInfo ( $ this -> _ ( 'Check source for new surveys, changes in survey status and survey deletion. Can also perform maintenance on some sources, e.g. by changing the number of attributes.' ) ) ; $ this -> html -> pInfo ( $ this -> _ ( 'Run this code when the status of a survey in a source has changed or when the code has changed and the source must be adapted.' ) ) ; }
Displays a textual explanation what synchronization does on the page .
57,760
public function attributesAction ( ) { $ sourceId = $ this -> getSourceId ( ) ; $ where = $ this -> db -> quoteInto ( 'gsu_id_source = ?' , $ sourceId ) ; $ batch = $ this -> loader -> getTracker ( ) -> refreshTokenAttributes ( 'attributeCheck' . $ sourceId , $ where ) ; $ title = sprintf ( $ this -> _ ( 'Refreshing token attributes for %s source.' ) , $ this -> db -> fetchOne ( "SELECT gso_source_name FROM gems__sources WHERE gso_id_source = ?" , $ sourceId ) ) ; $ this -> _helper -> batchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> html -> pInfo ( $ this -> _ ( 'Refreshes the attributes for a token as stored in the source.' ) ) ; $ this -> html -> pInfo ( $ this -> _ ( 'Run this code when the number of attributes has changed or when you suspect the attributes have been corrupted somehow.' ) ) ; }
Check token attributes for a single source
57,761
public function attributesAllAction ( ) { $ batch = $ this -> loader -> getTracker ( ) -> refreshTokenAttributes ( 'attributeCheckAll' ) ; $ title = $ this -> _ ( 'Refreshing token attributes for all sources.' ) ; $ this -> _helper -> batchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> html -> pInfo ( $ this -> _ ( 'Refreshes the attributes for a token as stored in on of the sources.' ) ) ; $ this -> html -> pInfo ( $ this -> _ ( 'Run this code when the number of attributes has changed or when you suspect the attributes have been corrupted somehow.' ) ) ; }
Check all token attributes for all sources
57,762
public function checkAction ( ) { $ sourceId = $ this -> getSourceId ( ) ; $ where = $ this -> db -> quoteInto ( 'gto_id_survey IN (SELECT gsu_id_survey FROM gems__surveys WHERE gsu_id_source = ?)' , $ sourceId ) ; $ batch = $ this -> loader -> getTracker ( ) -> recalculateTokens ( 'sourceCheck' . $ sourceId , $ this -> currentUser -> getUserId ( ) , $ where ) ; $ title = sprintf ( $ this -> _ ( 'Checking all surveys in the %s source for answers.' ) , $ this -> db -> fetchOne ( "SELECT gso_source_name FROM gems__sources WHERE gso_id_source = ?" , $ sourceId ) ) ; $ this -> _helper -> batchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> addSnippet ( 'Survey\\CheckAnswersInformation' , 'itemDescription' , $ this -> _ ( 'This task checks all tokens using this source for answers .' ) ) ; }
Check all the tokens for a single source
57,763
private function getSourceById ( $ sourceId = null ) { if ( null === $ sourceId ) { $ sourceId = $ this -> getSourceId ( ) ; } return $ this -> loader -> getTracker ( ) -> getSource ( $ sourceId ) ; }
Load a source object
57,764
public function pingAction ( ) { $ source = $ this -> getSourceById ( ) ; try { if ( $ source -> checkSourceActive ( $ this -> currentUser -> getUserId ( ) ) ) { $ this -> addMessage ( $ this -> _ ( 'This installation is active.' ) , 'success' ) ; } else { $ this -> addMessage ( $ this -> _ ( 'Inactive installation.' ) , 'warning' ) ; } } catch ( \ Exception $ e ) { $ this -> addMessage ( $ this -> _ ( 'Installation error!' ) , 'danger' ) ; $ this -> addMessage ( $ e -> getMessage ( ) , 'danger' ) ; } $ this -> _reroute ( array ( $ this -> getRequest ( ) -> getActionKey ( ) => 'show' ) ) ; }
Action to check whether the source is active
57,765
public function synchronizeAction ( ) { $ sourceId = $ this -> getSourceId ( ) ; $ batch = $ this -> loader -> getTracker ( ) -> synchronizeSources ( $ sourceId , $ this -> currentUser -> getUserId ( ) ) ; $ title = sprintf ( $ this -> _ ( 'Synchronize the %s source.' ) , $ this -> db -> fetchOne ( "SELECT gso_source_name FROM gems__sources WHERE gso_id_source = ?" , $ sourceId ) ) ; $ this -> _helper -> batchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> addSynchronizationInformation ( ) ; }
Synchronize survey status for the surveys in a source
57,766
public function synchronizeAllAction ( ) { $ batch = $ this -> loader -> getTracker ( ) -> synchronizeSources ( null , $ this -> currentUser -> getUserId ( ) ) ; $ batch -> minimalStepDurationMs = 3000 ; $ title = $ this -> _ ( 'Synchronize all sources.' ) ; $ this -> _helper -> batchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> html -> actionLink ( array ( 'action' => 'index' ) , $ this -> _ ( 'Cancel' ) , array ( 'class' => 'btn-danger' ) ) ; $ this -> addSynchronizationInformation ( ) ; }
Synchronize survey status for the surveys in all sources
57,767
public function answerAction ( ) { $ this -> menu -> setVisible ( false ) ; $ token = $ this -> getToken ( ) ; $ snippets = $ token -> getAnswerSnippetNames ( ) ; if ( $ snippets ) { $ this -> setTitle ( sprintf ( $ this -> _ ( 'Token answers: %s' ) , strtoupper ( $ token -> getTokenId ( ) ) ) ) ; $ params = $ this -> _processParameters ( $ this -> answerParameters + $ this -> defaultTokenParameters ) ; $ this -> addSnippets ( $ snippets , $ params ) ; } }
Pops the answers to a survey in a separate window
57,768
public function answerExportAction ( ) { if ( $ this -> answerExportSnippets ) { $ params = $ this -> _processParameters ( $ this -> answerExportParameters + $ this -> defaultTokenParameters ) ; $ this -> addSnippets ( $ this -> answerExportSnippets , $ params ) ; } }
Export a single token
57,769
public function checkAllTracksAction ( ) { $ respondent = $ this -> getRespondent ( ) ; $ where = $ this -> db -> quoteInto ( 'gr2t_id_user = ?' , $ respondent -> getId ( ) ) ; $ batch = $ this -> loader -> getTracker ( ) -> checkTrackRounds ( 'trackCheckRoundsResp_' . $ respondent -> getId ( ) , $ this -> currentUser -> getUserId ( ) , $ where ) ; $ title = sprintf ( $ this -> _ ( 'Checking round assignments for all tracks of respondent %s, %s.' ) , $ respondent -> getPatientNumber ( ) , $ respondent -> getFullName ( ) ) ; $ this -> _helper -> BatchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> addSnippet ( 'Track\\CheckRoundsInformation' ) ; }
Action for checking all assigned rounds for this respondent using a batch
57,770
public function checkTokenAnswersAction ( ) { $ token = $ this -> getToken ( ) ; $ where = $ this -> db -> quoteInto ( 'gto_id_token = ?' , $ token -> getTokenId ( ) ) ; $ batch = $ this -> loader -> getTracker ( ) -> recalculateTokens ( 'answersCheckToken__' . $ token -> getTokenId ( ) , $ this -> currentUser -> getUserId ( ) , $ where ) ; $ batch -> autoStart = true ; $ title = sprintf ( $ this -> _ ( "Checking the token %s for answers." ) , $ token -> getTokenId ( ) ) ; $ this -> _helper -> BatchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> addSnippet ( 'Survey\\CheckAnswersInformation' , 'itemDescription' , $ this -> _ ( 'This task checks one token for answers.' ) ) ; }
Check the tokens for a single token
57,771
public function checkTrackAction ( ) { $ respondent = $ this -> getRespondent ( ) ; $ respTrackId = $ this -> getRespondentTrackId ( ) ; $ trackEngine = $ this -> getTrackEngine ( ) ; $ where = $ this -> db -> quoteInto ( 'gr2t_id_respondent_track = ?' , $ respTrackId ) ; $ batch = $ this -> loader -> getTracker ( ) -> checkTrackRounds ( 'trackCheckRoundsFor_' . $ respTrackId , $ this -> currentUser -> getUserId ( ) , $ where ) ; $ title = sprintf ( $ this -> _ ( "Checking round assignments for track '%s' of respondent %s, %s." ) , $ trackEngine -> getTrackName ( ) , $ respondent -> getPatientNumber ( ) , $ respondent -> getFullName ( ) ) ; $ this -> _helper -> BatchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> addSnippet ( 'Track\\CheckRoundsInformation' ) ; }
Action for checking all assigned rounds for a single respondent track using a batch
57,772
public function deleteTrackAction ( ) { if ( $ this -> deleteTrackSnippets ) { $ params = $ this -> _processParameters ( $ this -> deleteTrackParameters + $ this -> deleteParameters ) ; $ this -> addSnippets ( $ this -> deleteTrackSnippets , $ params ) ; } }
Delete a track
57,773
public function editAction ( ) { $ this -> editParameters = $ this -> editParameters + $ this -> defaultTokenParameters ; $ this -> createEditSnippets = $ this -> getToken ( ) -> getEditSnippetNames ( ) ; parent :: editAction ( ) ; }
Edit single token
57,774
public function editTrackAction ( ) { if ( $ this -> editTrackSnippets ) { $ params = $ this -> _processParameters ( $ this -> editTrackParameters + $ this -> createEditParameters ) ; $ this -> addSnippets ( $ this -> editTrackSnippets , $ params ) ; } }
Edit the respondent track data
57,775
public function emailAction ( ) { if ( $ this -> emailSnippets ) { $ params = $ this -> _processParameters ( $ this -> emailParameters + $ this -> defaultTokenParameters ) ; $ this -> addSnippets ( $ this -> emailSnippets , $ params ) ; } }
Email the user
57,776
public function exportTrackAction ( ) { if ( $ this -> exportTrackSnippets ) { $ params = $ this -> _processParameters ( $ this -> exportTrackParameters ) ; $ this -> addSnippets ( $ this -> exportTrackSnippets , $ params ) ; } }
Export a single track
57,777
protected function getCorrectTokenTitle ( ) { $ token = $ this -> getToken ( ) ; return sprintf ( $ this -> _ ( 'Correct answers for survey %s, round %s' ) , $ token -> getSurveyName ( ) , $ token -> getRoundDescription ( ) ) ; }
Get the title for correcting a token
57,778
protected function getTrackTitle ( ) { $ respondent = $ this -> getRespondent ( ) ; $ respTrack = $ this -> getRespondentTrack ( ) ; if ( $ respTrack ) { $ trackEngine = $ respTrack -> getTrackEngine ( ) ; if ( $ this -> currentUser -> areAllFieldsMaskedWhole ( 'grs_first_name' , 'grs_surname_prefix' , 'grs_last_name' ) ) { return sprintf ( $ this -> _ ( '%s track for respondent nr %s' ) , $ trackEngine -> getTrackName ( ) , $ respondent -> getPatientNumber ( ) ) ; } return sprintf ( $ this -> _ ( '%s track for respondent nr %s: %s' ) , $ trackEngine -> getTrackName ( ) , $ respondent -> getPatientNumber ( ) , $ respondent -> getName ( ) ) ; } }
Get the title describing the track
57,779
protected function getTokenTitle ( ) { $ token = $ this -> getToken ( ) ; $ respondent = $ token -> getRespondent ( ) ; return sprintf ( $ this -> _ ( 'Token %s in round "%s" in track "%s" for respondent nr %s: %s' ) , $ token -> getTokenId ( ) , $ token -> getRoundDescription ( ) , $ token -> getTrackName ( ) , $ respondent -> getPatientNumber ( ) , $ respondent -> getName ( ) ) ; }
Get the title describing the token
57,780
protected function getEmailTokenTitle ( ) { $ token = $ this -> getToken ( ) ; $ respondent = $ token -> getRespondent ( ) ; return sprintf ( $ this -> _ ( 'Send mail to %s respondent nr %s for token %s' ) , $ token -> getEmail ( ) , $ respondent -> getPatientNumber ( ) , $ token -> getTokenId ( ) ) ; }
Get the title for editing a track
57,781
public function getSurveyId ( ) { $ sid = $ this -> _getParam ( \ Gems_Model :: SURVEY_ID ) ; if ( $ sid ) { return $ sid ; } if ( $ this -> getTokenId ( ) ) { return $ this -> getToken ( ) -> getSurveyId ( ) ; } }
Retrieve the survey ID
57,782
public function getToken ( ) { static $ token ; if ( $ token instanceof \ Gems_Tracker_Token ) { return $ token ; } $ token = null ; $ tokenId = $ this -> getTokenId ( ) ; if ( $ tokenId ) { $ token = $ this -> loader -> getTracker ( ) -> getToken ( $ tokenId ) ; } if ( $ token && $ token -> exists ) { $ token -> applyToMenuSource ( $ this -> menu -> getParameterSource ( ) ) ; return $ token ; } throw new \ Gems_Exception ( $ this -> _ ( 'No existing token specified!' ) ) ; }
Retrieve the token
57,783
public function getTrackEngine ( ) { static $ engine ; if ( $ engine instanceof \ Gems_Tracker_Engine_TrackEngineInterface ) { return $ engine ; } try { $ respTrack = $ this -> getRespondentTrack ( ) ; if ( $ respTrack instanceof \ Gems_Tracker_RespondentTrack ) { $ engine = $ respTrack -> getTrackEngine ( ) ; } } catch ( \ Exception $ ex ) { } if ( ! $ engine instanceof \ Gems_Tracker_Engine_TrackEngineInterface ) { $ trackId = $ this -> _getParam ( \ Gems_model :: TRACK_ID ) ; if ( ! $ trackId ) { if ( $ this -> isMultiTracks ( ) ) { throw new \ Gems_Exception ( $ this -> _ ( 'No track engine specified!' ) ) ; } $ trackId = $ this -> escort -> getTrackId ( ) ; if ( ! $ trackId ) { return null ; } } $ engine = $ this -> loader -> getTracker ( ) -> getTrackEngine ( $ trackId ) ; } $ engine -> applyToMenuSource ( $ this -> menu -> getParameterSource ( ) ) ; return $ engine ; }
Retrieve the track engine
57,784
protected function getViewTrackTitle ( ) { $ trackEngine = $ this -> getTrackEngine ( ) ; if ( $ this -> isMultiTracks ( ) ) { $ respondent = $ this -> getRespondent ( ) ; return sprintf ( $ this -> _ ( '%s track assignments for respondent nr %s: %s' ) , $ trackEngine -> getTrackName ( ) , $ this -> _getParam ( \ MUtil_Model :: REQUEST_ID1 ) , $ this -> getRespondent ( ) -> getFullName ( ) ) ; } else { return sprintf ( $ this -> _ ( '%s track overview' ) , $ trackEngine -> getTrackName ( ) ) ; } }
Get the title for viewing track usage
57,785
public function init ( ) { parent :: init ( ) ; $ request = $ this -> getRequest ( ) ; if ( in_array ( $ request -> getActionName ( ) , $ this -> tokenReturnActions ) ) { $ this -> currentUser -> setSurveyReturn ( $ request ) ; } }
Initialize translate and html objects
57,786
public function insertAction ( ) { if ( $ this -> insertSnippets ) { $ params = $ this -> _processParameters ( $ this -> insertParameters ) ; $ this -> addSnippets ( $ this -> insertSnippets , $ params ) ; } }
Insert a single survey into a track
57,787
public function questionsAction ( ) { if ( ! $ this -> getTokenId ( ) ) { $ params = $ this -> _processParameters ( $ this -> questionsParameters ) ; } else { $ params = $ this -> _processParameters ( $ this -> questionsParameters + $ this -> defaultTokenParameters ) ; } if ( $ this -> questionsSnippets ) { $ params = $ this -> _processParameters ( $ this -> questionsParameters + $ this -> defaultTokenParameters ) ; $ this -> addSnippets ( $ this -> questionsSnippets , $ params ) ; } }
Shows the questions in a survey
57,788
public function showTrackAction ( ) { if ( $ this -> showTrackSnippets ) { $ params = $ this -> _processParameters ( $ this -> showTrackParameters ) ; $ this -> addSnippets ( $ this -> showTrackSnippets , $ params ) ; } }
Show information on a single track assigned to a respondent
57,789
public function undeleteAction ( ) { $ this -> deleteParameters = $ this -> deleteParameters + $ this -> defaultTokenParameters ; $ this -> deleteSnippets = $ this -> getToken ( ) -> getDeleteSnippetNames ( ) ; parent :: deleteAction ( ) ; }
Delete a single token
57,790
public function undeleteTrackAction ( ) { if ( $ this -> deleteTrackSnippets ) { $ params = $ this -> _processParameters ( $ this -> deleteTrackParameters + $ this -> deleteParameters ) ; $ this -> addSnippets ( $ this -> deleteTrackSnippets , $ params ) ; } }
Undelete a track
57,791
public function viewAction ( ) { if ( $ this -> viewSnippets ) { $ params = $ this -> _processParameters ( $ this -> viewParameters ) ; $ this -> addSnippets ( $ this -> viewSnippets , $ params ) ; } }
Show information on a single track type assigned to a respondent
57,792
public function viewSurveyAction ( ) { $ params = $ this -> _processParameters ( $ this -> viewSurveyParameters ) ; $ this -> addSnippets ( $ this -> viewSurveySnippets , $ params ) ; }
Used in AddTracksSnippet to show a preview for an insertable survey
57,793
protected function getResetPasswordMailFields ( ) { if ( $ this -> user -> getUserId ( ) ) { $ result = $ this -> user -> getResetPasswordMailFields ( ) ; } else { $ result [ 'reset_key' ] = '' ; $ result [ 'reset_url' ] = '' ; } return $ result ; }
Return the mailfields for a password reset template
57,794
public function setCreateAccountTemplate ( ) { $ templateId = $ this -> organization -> getCreateAccountTemplate ( ) ; if ( $ templateId ) { $ this -> setTemplate ( $ this -> organization -> getCreateAccountTemplate ( ) ) ; return true ; } elseif ( $ this -> project -> getEmailCreateAccount ( ) ) { $ this -> setTemplateByCode ( $ this -> project -> getEmailCreateAccount ( ) ) ; return true ; } else { return false ; } }
Set the create account Mail template from the organization or the project
57,795
public function setResetPasswordTemplate ( ) { $ templateId = $ this -> organization -> getResetPasswordTemplate ( ) ; if ( $ templateId ) { $ this -> setTemplate ( $ this -> organization -> getResetPasswordTemplate ( ) ) ; return true ; } elseif ( $ this -> project -> getEmailResetPassword ( ) ) { if ( $ this -> setTemplateByCode ( $ this -> project -> getEmailResetPassword ( ) ) ) { return true ; } else { return false ; } } else { return false ; } }
Set the reset password Mail template from the organization or the project
57,796
protected function _getObjectsAllCached ( $ cacheId , $ object , $ sql , $ binds = null , $ tags = array ( ) ) { $ output = array ( ) ; $ rows = $ this -> _getSelectAllCached ( $ cacheId , $ sql , $ binds , $ tags ) ; if ( $ rows ) { $ this -> source -> applySource ( $ object ) ; foreach ( $ rows as $ row ) { $ tmp = clone $ object ; $ tmp -> exchangeArray ( $ row ) ; $ output [ ] = $ tmp ; } } return $ output ; }
Utility function for loading a complete query from cache into objects
57,797
protected function _getSelectAllCached ( $ cacheId , $ sql , $ binds = array ( ) , $ tags = array ( ) , $ natSort = false ) { $ cacheId = strtr ( get_class ( $ this ) . '_a_' . $ cacheId , '\\/' , '__' ) ; $ result = $ this -> cache -> load ( $ cacheId ) ; if ( $ result ) { return $ result ; } try { $ result = $ this -> db -> fetchAll ( $ sql , ( array ) $ binds ) ; if ( $ natSort ) { natsort ( $ result ) ; } $ this -> cache -> save ( $ result , $ cacheId , ( array ) $ tags ) ; } catch ( \ Zend_Db_Statement_Mysqli_Exception $ e ) { $ result = array ( ) ; } return $ result ; }
Utility function for loading a complete query from cache
57,798
protected function _getSelectPairsCached ( $ cacheId , $ sql , $ binds = array ( ) , $ tags = array ( ) , $ sort = null ) { $ cacheId = strtr ( get_class ( $ this ) . '_p_' . $ cacheId , '\\/' , '__' ) ; $ result = $ this -> cache -> load ( $ cacheId ) ; if ( $ result ) { return $ result ; } try { $ result = $ this -> db -> fetchPairs ( $ sql , ( array ) $ binds ) ; if ( $ result && $ sort ) { $ this -> _sortResult ( $ result , $ sort ) ; } $ this -> cache -> save ( $ result , $ cacheId , ( array ) $ tags ) ; } catch ( \ Zend_Db_Statement_Mysqli_Exception $ e ) { $ result = array ( ) ; } return $ result ; }
Utility function for loading a query paired from cache
57,799
protected function _sortResult ( array & $ result , $ sort = 'asort' ) { switch ( $ sort ) { case 'asort' : asort ( $ result ) ; break ; case 'ksort' : ksort ( $ result ) ; break ; case 'natsort' : natsort ( $ result ) ; break ; default : $ sort ( $ result ) ; } }
Sort the array using the specified sort function