idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
57,900
function GeSHi ( $ source = '' , $ language = '' , $ path = '' ) { if ( ! empty ( $ source ) ) { $ this -> set_source ( $ source ) ; } if ( ! empty ( $ language ) ) { $ this -> set_language ( $ language ) ; } $ this -> set_language_path ( $ path ) ; }
Creates a new GeSHi object with source and language
57,901
function error ( ) { if ( $ this -> error ) { $ debug_tpl_vars = array ( '{LANGUAGE}' => $ this -> language , '{PATH}' => $ this -> language_path ) ; $ msg = str_replace ( array_keys ( $ debug_tpl_vars ) , array_values ( $ debug_tpl_vars ) , $ this -> error_messages [ $ this -> error ] ) ; return "<br /><strong>GeSHi Error:</strong> $msg (code {$this->error})<br />" ; } return false ; }
Returns an error message associated with the last GeSHi operation or false if no error has occured
57,902
function add_keyword_group ( $ key , $ styles , $ case_sensitive = true , $ words = array ( ) ) { $ words = ( array ) $ words ; if ( empty ( $ words ) ) { return false ; } $ this -> language_data [ 'KEYWORDS' ] [ $ key ] = $ words ; $ this -> lexic_permissions [ 'KEYWORDS' ] [ $ key ] = true ; $ this -> language_data [ 'CASE_SENSITIVE' ] [ $ key ] = $ case_sensitive ; $ this -> language_data [ 'STYLES' ] [ 'KEYWORDS' ] [ $ key ] = $ styles ; if ( $ this -> parse_cache_built ) { $ this -> optimize_keyword_group ( $ key ) ; } }
Creates a new keyword group
57,903
protected function onInValid ( ) { if ( $ this -> _csrf ) { if ( $ this -> _csrf -> getMessages ( ) ) { $ this -> addMessage ( $ this -> _ ( 'The form was open for too long or was opened in multiple windows.' ) ) ; } } }
Hook that allows actions when the input is invalid
57,904
public function getSelect ( ) { $ select = $ this -> db -> select ( ) ; $ fields [ 'answered' ] = new \ Zend_Db_Expr ( "SUM( CASE WHEN grc_success = 1 AND gto_completion_time IS NOT NULL THEN 1 ELSE 0 END )" ) ; $ fields [ 'missed' ] = new \ Zend_Db_Expr ( 'SUM( CASE WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_until < CURRENT_TIMESTAMP AND (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP) THEN 1 ELSE 0 END )' ) ; $ fields [ 'open' ] = new \ Zend_Db_Expr ( 'SUM( CASE WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_from <= CURRENT_TIMESTAMP AND (gto_valid_until >= CURRENT_TIMESTAMP OR gto_valid_until IS NULL) THEN 1 ELSE 0 END )' ) ; $ fields [ 'total' ] = new \ Zend_Db_Expr ( 'SUM( CASE WHEN grc_success = 1 AND ( gto_completion_time IS NOT NULL OR (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP) ) THEN 1 ELSE 0 END )' ) ; $ fields [ 'filler' ] = new \ Zend_Db_Expr ( 'COALESCE(gems__track_fields.gtf_field_name, gems__groups.ggp_name)' ) ; $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__tokens' , $ fields ) -> joinInner ( 'gems__reception_codes' , 'gto_reception_code = grc_id_reception_code' , array ( ) ) -> joinInner ( 'gems__rounds' , 'gto_id_round = gro_id_round' , array ( 'gro_round_description' , 'gro_id_survey' ) ) -> joinInner ( 'gems__surveys' , 'gro_id_survey = gsu_id_survey' , array ( 'gsu_survey_name' ) ) -> joinInner ( 'gems__groups' , 'gsu_id_primary_group = ggp_id_group' , array ( ) ) -> joinLeft ( 'gems__track_fields' , 'gto_id_relationfield = gtf_id_field AND gtf_field_type = "relation"' , array ( ) ) -> group ( array ( 'gro_id_order' , 'gro_round_description' , 'gsu_survey_name' , 'filler' ) ) ; $ filter = $ this -> getSearchFilter ( ) ; if ( array_key_exists ( 'fillerfilter' , $ filter ) ) { $ select -> having ( 'filler = ?' , $ filter [ 'fillerfilter' ] ) ; } return $ select ; }
Select creation function allowes overruling in child classes
57,905
public function addLeftTable ( $ table , array $ joinFields , $ fieldPrefix = null , $ saveable = null ) { parent :: addLeftTable ( $ table , $ joinFields , $ this -> _checkSaveable ( $ saveable , $ fieldPrefix ) ) ; if ( $ fieldPrefix ) { \ Gems_Model :: setChangeFieldsByPrefix ( $ this , $ fieldPrefix ) ; } return $ this ; }
Add a table to the model with a left join
57,906
protected function addCheckFields ( ) { $ check = 1 ; foreach ( $ this -> checkFields as $ label => & $ value ) { if ( $ value instanceof \ Zend_Form_Element ) { $ element = $ value ; } else { if ( $ value ) { $ element = new \ Zend_Form_Element_Text ( 'check_' . $ check ) ; $ element -> setAllowEmpty ( false ) ; $ element -> setLabel ( $ label ) ; $ validator = new \ Zend_Validate_Identical ( $ value ) ; $ validator -> setMessage ( sprintf ( $ this -> _ ( '%s is not correct.' ) , $ label ) , \ Zend_Validate_Identical :: NOT_SAME ) ; $ element -> addValidator ( $ validator ) ; $ value = $ element ; $ check ++ ; } else { unset ( $ this -> checkFields [ $ label ] ) ; continue ; } } $ this -> addElement ( $ element ) ; } }
Add user defined checkfields
57,907
public function getAskOld ( ) { if ( null === $ this -> askOld ) { $ this -> askOld = ( ! $ this -> user -> isPasswordResetRequired ( ) ) ; } return $ this -> askOld && $ this -> user -> hasPassword ( ) ; }
Should the for asking for an old password
57,908
public function addListModel ( \ MUtil_Model_ModelAbstract $ model , array $ joins , $ name = null ) { if ( null === $ name ) { $ name = $ model -> getName ( ) ; } $ trans = new \ MUtil_Model_Transform_NestedTransformer ( ) ; $ trans -> skipSave = true ; $ trans -> addModel ( $ model , $ joins ) ; $ this -> addTransformer ( $ trans ) ; $ this -> set ( $ name , 'model' , $ model , 'elementClass' , 'FormTable' , 'type' , \ MUtil_Model :: TYPE_CHILD_MODEL ) ; $ bridge = $ model -> getBridgeFor ( 'table' ) ; $ this -> set ( $ name , 'formatFunction' , array ( $ bridge , 'displayListTable' ) ) ; return $ trans ; }
Add a submodel field to the model .
57,909
public function processBeforeSave ( array $ row ) { if ( $ this -> getMeta ( 'nested' , false ) ) { $ nestedNames = $ this -> getMeta ( 'nestedNames' ) ; foreach ( $ nestedNames as $ nestedName ) { if ( isset ( $ row [ $ nestedName ] ) ) { foreach ( $ row [ $ nestedName ] as $ key => $ answer ) { $ a = array_shift ( $ answer ) ; if ( empty ( $ a ) ) { unset ( $ row [ $ nestedName ] [ $ key ] ) ; } } } } } if ( ! isset ( $ row [ 'gto_completion_time' ] ) || $ row [ 'gto_completion_time' ] ) { $ row [ 'gto_completion_time' ] = new \ MUtil_Date ; } $ row = parent :: processBeforeSave ( $ row ) ; return $ row ; }
Helper function that procesess the raw data before a save .
57,910
protected function capsCount ( $ parameter , $ password ) { $ len = intval ( $ parameter ) ; $ results = array ( ) ; if ( $ len && ( preg_match_all ( '/[A-Z]/' , $ password , $ results ) < $ len ) ) { $ this -> _addError ( sprintf ( $ this -> translate -> plural ( 'should contain at least one uppercase character' , 'should contain at least %d uppercase characters' , $ len ) , $ len ) ) ; } }
Test the password for minimum number of upper case characters .
57,911
protected function minLength ( $ parameter , $ password ) { $ len = intval ( $ parameter ) ; if ( $ len && ( strlen ( $ password ) < $ len ) ) { $ this -> _addError ( sprintf ( $ this -> translate -> _ ( 'should be at least %d characters long' ) , $ len ) ) ; } }
Test the password for minimum length .
57,912
protected function notAlphaNumCount ( $ parameter , $ password ) { $ len = intval ( $ parameter ) ; if ( $ len ) { $ results = array ( ) ; $ count = strlen ( $ password ) - preg_match_all ( '/[0-9A-Za-z]/' , $ password , $ results ) ; if ( ( $ len > 0 ) && ( $ count < $ len ) ) { $ this -> _addError ( sprintf ( $ this -> translate -> plural ( 'should contain at least one non alphanumeric character' , 'should contain at least %d non alphanumeric characters' , $ len ) , $ len ) ) ; } elseif ( ( $ len < 0 ) && ( ( $ count > 0 ) || ( null === $ password ) ) ) { $ this -> _addError ( $ this -> translate -> _ ( 'should not contain non alphanumeric characters' ) ) ; } } }
Test the password for minimum number not alphanumeric characters .
57,913
protected function notTheName ( $ parameter , $ password ) { $ on = $ parameter != 0 ; if ( $ on ) { $ lpwd = strtolower ( $ password ) ; if ( ( false !== strpos ( $ lpwd , strtolower ( $ this -> user -> getLoginName ( ) ) ) ) || ( null === $ password ) ) { $ this -> _addError ( $ this -> translate -> _ ( 'should not contain your login name' ) ) ; } } }
The password should not contain the name of the user or the login name .
57,914
protected function _getEventClass ( $ eventType ) { if ( isset ( $ this -> _eventClasses [ $ eventType ] ) ) { return $ this -> _eventClasses [ $ eventType ] ; } else { throw new \ Gems_Exception_Coding ( "No event class exists for event type '$eventType'." ) ; } }
Lookup event class for an event type . This class or interface should at the very least implement the EventInterface .
57,915
protected function _listEvents ( $ eventType ) { $ classType = $ this -> _getEventClass ( $ eventType ) ; $ paths = $ this -> _getEventDirs ( $ eventType ) ; return $ this -> util -> getTranslated ( ) -> getEmptyDropdownArray ( ) + $ this -> listClasses ( $ classType , $ paths , 'getEventName' ) ; }
Returns a list of selectable events with an empty element as the first option .
57,916
public function translateRowValues ( $ row , $ key ) { $ row = parent :: translateRowValues ( $ row , $ key ) ; if ( ! $ row ) { return false ; } if ( ! isset ( $ row [ 'gsf_active' ] ) ) { $ row [ 'gsf_active' ] = 1 ; } if ( ! isset ( $ row [ 'gul_can_login' ] ) ) { $ row [ 'gul_can_login' ] = 1 ; } if ( ! isset ( $ row [ 'gsf_id_organization' ] ) ) { $ row [ 'gsf_id_organization' ] = $ this -> _organization -> getId ( ) ; } if ( ! isset ( $ row [ 'gul_user_class' ] ) ) { $ row [ 'gul_user_class' ] = $ this -> loader -> getUserLoader ( ) -> getOrganization ( $ row [ 'gsf_id_organization' ] ) -> get ( 'gor_user_class' ) ; } return $ row ; }
Add organization id and gul_user_class when needed
57,917
protected function _set ( $ name , $ value ) { $ this -> _data [ $ name ] = $ value ; $ this -> invalidateCache ( ) ; return $ this ; }
Changes a value and signals the cache .
57,918
public function invalidateCache ( ) { if ( $ this -> cache ) { $ cacheId = $ this -> _getCacheId ( ) ; $ this -> cache -> remove ( $ cacheId ) ; } return $ this ; }
Empty the cache of the organization
57,919
public function questionsAction ( ) { $ this -> addSnippet ( 'Survey\\SurveyQuestionsSnippet' , 'menu' , $ this -> menu , 'surveyId' , $ this -> _getParam ( \ Gems_Model :: SURVEY_ID ) , 'trackId' , $ this -> _getIdParam ( ) ) ; }
Show the questions in a survey
57,920
public function executeAction ( $ preview = false ) { $ jobId = intval ( $ this -> getParam ( \ MUtil_Model :: REQUEST_ID ) ) ; $ batch = $ this -> loader -> getTaskRunnerBatch ( 'commjob-execute-' . $ jobId ) ; $ batch -> setMessageLogFile ( $ this -> project -> getCronLogfile ( ) ) ; $ batch -> minimalStepDurationMs = 3000 ; if ( ! $ batch -> isLoaded ( ) && ! is_null ( ( $ jobId ) ) ) { $ batch -> addMessage ( sprintf ( $ this -> _ ( 'Starting single %s mail job %s' ) , $ this -> project -> getName ( ) , $ jobId ) ) ; $ tracker = $ this -> loader -> getTracker ( ) ; $ tracker -> loadCompletedTokensBatch ( $ batch , null , $ this -> currentUser -> getUserId ( ) ) ; $ sql = $ this -> db -> select ( ) -> from ( 'gems__comm_jobs' , array ( 'gcj_id_job' ) ) -> where ( 'gcj_active > 0' ) -> where ( 'gcj_id_job = ?' , $ jobId ) ; $ job = $ this -> db -> fetchOne ( $ sql ) ; if ( ! empty ( $ job ) ) { $ batch -> addTask ( 'Mail\\ExecuteMailJobTask' , $ job , null , null , $ preview ) ; } else { $ batch -> reset ( ) ; $ this -> addMessage ( $ this -> _ ( "Mailjob is inactive and won't be executed" ) , 'danger' ) ; } if ( $ preview === true ) { $ batch -> autoStart = true ; } } if ( $ batch -> isFinished ( ) ) { $ messages = $ batch -> getMessages ( true ) ; if ( count ( $ messages ) ) { $ this -> addMessage ( $ messages , 'info' ) ; } $ this -> _reroute ( array ( 'action' => 'show' ) ) ; } if ( $ preview === true ) { $ title = sprintf ( $ this -> _ ( 'Preview single mail job %s' ) , $ jobId ) ; } else { $ title = sprintf ( $ this -> _ ( 'Executing single mail job %s' ) , $ jobId ) ; } $ this -> _helper -> BatchRunner ( $ batch , $ title , $ this -> accesslog ) ; }
Execute a single mail job
57,921
public function executeAllAction ( ) { $ this -> _helper -> BatchRunner ( $ this -> loader -> getMailLoader ( ) -> getCronBatch ( 'commjob-execute-all' ) , $ this -> _ ( 'Execute all mail jobs' ) , $ this -> accesslog ) ; }
Execute all mail jobs
57,922
protected function getBulkMailFromOptions ( ) { $ results [ 'O' ] = $ this -> _ ( 'Use organizational from address' ) ; if ( isset ( $ project -> email [ 'site' ] ) && $ project -> email [ 'site' ] ) { $ results [ 'S' ] = sprintf ( $ this -> _ ( 'Use site %s address' ) , $ project -> email [ 'site' ] ) ; } $ results [ 'U' ] = $ this -> _ ( "Use the 'By staff member' address" ) ; $ results [ 'F' ] = $ this -> _ ( 'Other' ) ; return $ results ; }
Options for from address use .
57,923
public function roundselectAction ( ) { \ Zend_Layout :: resetMvcInstance ( ) ; $ trackId = $ this -> getRequest ( ) -> getParam ( 'sourceValue' ) ; $ rounds = $ this -> db -> fetchPairs ( $ this -> roundDescQuery , $ trackId ) ; echo json_encode ( $ rounds ) ; }
Ajax return function for round selection
57,924
public function ajaxAction ( $ table , $ idField , $ orderField ) { $ request = $ this -> getRequest ( ) ; if ( $ request -> isPost ( ) ) { $ ids = $ request -> getPost ( 'ids' ) ; foreach ( $ ids as $ id ) { $ cleanIds [ ] = ( int ) $ id ; } $ db = $ this -> getActionController ( ) -> db ; $ select = $ db -> select ( ) -> from ( $ table , array ( $ idField , $ orderField ) ) -> where ( $ idField . ' in(?)' , $ cleanIds ) -> order ( $ orderField ) ; $ oldOrder = $ db -> fetchPairs ( $ select ) ; if ( count ( $ oldOrder ) == count ( $ cleanIds ) ) { $ newOrder = array_combine ( $ cleanIds , $ oldOrder ) ; $ changed = 0 ; foreach ( $ newOrder as $ id => $ order ) { $ changed = $ changed + $ db -> update ( $ table , array ( $ orderField => $ order ) , $ db -> quoteInto ( $ idField . ' = ?' , $ id ) ) ; } $ this -> getActionController ( ) -> addMessage ( sprintf ( $ this -> getActionController ( ) -> plural ( '%s record updated due to sorting.' , '%s records updated due to sorting.' , $ changed ) , $ changed ) ) ; return ; } } throw new \ Gems_Exception ( $ this -> _ ( 'Sorting failed' ) , 403 ) ; }
Handles sort in an ajax request
57,925
public function direct ( $ sortAction = 'sort' , $ urlIdParam = 'id' ) { $ view = $ this -> getView ( ) ; \ MUtil_JQuery :: enableView ( $ view ) ; $ jquery = $ view -> jQuery ( ) ; $ jquery -> enable ( ) ; $ handler = \ ZendX_JQuery_View_Helper_JQuery :: getJQueryHandler ( ) ; $ url = $ view -> serverUrl ( ) . $ view -> baseUrl ( ) . '/' . $ this -> getRequest ( ) -> getControllerName ( ) . '/' . $ sortAction ; $ script = file_get_contents ( __DIR__ . '/js/SortableTable.js' ) ; $ fields = array ( 'jQuery' => $ handler , 'AJAXURL' => $ url , 'IDPARAM' => $ urlIdParam ) ; $ js = str_replace ( array_keys ( $ fields ) , $ fields , $ script ) ; $ jquery -> addOnLoad ( $ js ) ; $ buttons = \ Mutil_Html :: div ( ) ; $ buttons -> class = 'buttons pull-right' ; $ buttons -> div ( $ this -> getActionController ( ) -> _ ( 'Sort' ) , array ( 'id' => 'sort' , 'class' => "btn" ) ) ; $ buttons -> div ( $ this -> getActionController ( ) -> _ ( 'Ok' ) , array ( 'id' => 'sort-ok' , 'class' => "btn btn-success" , 'style' => 'display:none;' ) ) ; $ buttons -> div ( $ this -> getActionController ( ) -> _ ( 'Cancel' ) , array ( 'id' => 'sort-cancel' , 'class' => "btn btn-warning" , 'style' => 'display:none;' ) ) ; return $ buttons ; }
Get the sort buttons to add under the table with sortable rows
57,926
public function getView ( ) { $ controller = $ this -> getActionController ( ) ; if ( null === $ controller ) { $ controller = $ this -> getFrontController ( ) ; } return $ controller -> view ; }
Get the view
57,927
public function continueClicked ( ) { $ html = $ this -> getHtmlSequence ( ) ; $ org = $ this -> token -> getOrganization ( ) ; $ html -> h3 ( $ this -> _ ( 'Token' ) ) ; $ mailLoader = $ this -> loader -> getMailLoader ( ) ; $ mail = $ mailLoader -> getMailer ( 'token' , $ this -> showToken -> getTokenId ( ) ) ; $ mail -> setFrom ( $ this -> showToken -> getOrganization ( ) -> getFrom ( ) ) ; if ( $ mail -> setTemplateByCode ( 'continue' ) ) { $ lastMailedDate = \ MUtil_Date :: ifDate ( $ this -> showToken -> getMailSentDate ( ) , 'yyyy-MM-dd' ) ; if ( ! is_null ( $ lastMailedDate ) && $ lastMailedDate -> isToday ( ) ) { $ html -> pInfo ( $ this -> _ ( 'An email with information to continue later was already sent to your registered email address today.' ) ) ; } else { $ mail -> send ( ) ; $ html -> pInfo ( $ this -> _ ( 'An email with information to continue later was sent to your registered email address.' ) ) ; } $ html -> pInfo ( $ this -> _ ( 'Delivery can take a while. If you do not receive an email please check your spam-box.' ) ) ; } if ( $ sig = $ org -> getSignature ( ) ) { $ html -> pInfo ( ) -> raw ( \ MUtil_Markup :: render ( $ this -> _ ( $ sig ) , 'Bbcode' , 'Html' ) ) ; } return $ html ; }
Handle the situation when the continue later link was clicked
57,928
public function lastCompleted ( ) { $ html = $ this -> getHtmlSequence ( ) ; $ org = $ this -> token -> getOrganization ( ) ; $ html -> h3 ( $ this -> _ ( 'Token' ) ) ; $ this -> addWelcome ( $ html ) ; $ html -> pInfo ( $ this -> _ ( 'Thank you for answering. At the moment we have no further surveys for you to take.' ) ) ; if ( $ sig = $ org -> getSignature ( ) ) { $ html -> pInfo ( ) -> raw ( \ MUtil_Markup :: render ( $ this -> _ ( $ sig ) , 'Bbcode' , 'Html' ) ) ; } return $ html ; }
The last token was answered there are no more tokens to answer
57,929
protected function getLookup ( $ respondentId = null , $ organizationId = null ) { if ( $ respondentId !== null && $ organizationId !== null ) { $ respondentTracks = $ this -> loader -> getTracker ( ) -> getRespondentTracks ( $ respondentId , $ organizationId ) ; $ respondentTrackPairs = [ ] ; foreach ( $ respondentTracks as $ respondentTrack ) { $ name = $ respondentTrack -> getTrackName ( ) ; $ startDate = $ respondentTrack -> getStartDate ( ) ; if ( $ startDate ) { $ name .= ' (' . $ startDate -> toString ( 'dd-MM-yyyy' ) . ')' ; } $ respondentTrackPairs [ $ respondentTrack -> getRespondentTrackId ( ) ] = $ name ; } return $ respondentTrackPairs ; } return [ ] ; }
Return the lookup array for this field
57,930
public function showTrack ( $ value ) { $ empty = $ this -> util -> getTranslated ( ) -> getEmptyDropdownArray ( ) ; if ( ! $ value || in_array ( $ value , $ empty ) ) { return null ; } if ( ! $ value instanceof \ Gems_Tracker_RespondentTrack ) { $ value = $ this -> loader -> getTracker ( ) -> getRespondentTrack ( $ value ) ; } if ( ! $ value instanceof \ Gems_Tracker_RespondentTrack ) { return null ; } $ name = $ value -> getTrackName ( ) ; if ( ! $ this -> menu instanceof \ Gems_Menu ) { $ this -> menu = $ this -> loader -> getMenu ( ) ; } $ menuItem = $ this -> menu -> findAllowedController ( 'track' , 'show-track' ) ; if ( $ menuItem instanceof \ Gems_Menu_SubMenuItem ) { if ( ! $ this -> request ) { $ this -> request = \ Zend_Controller_Front :: getInstance ( ) -> getRequest ( ) ; } $ href = $ menuItem -> toHRefAttribute ( [ 'gr2t_id_respondent' => $ value -> getPatientNumber ( ) , 'gr2t_id_organization' => $ value -> getOrganizationId ( ) , 'gr2t_id_respondent_track' => $ value -> getRespondentTrackId ( ) , ] , $ this -> request ) ; if ( $ href ) { return \ MUtil_Html :: create ( 'a' , $ href , $ name ) ; } } return $ name ; }
Display a respondent track as text
57,931
public function processFieldUpdate ( \ Gems_Tracker_RespondentTrack $ respTrack , $ userId ) { $ agenda = $ this -> loader -> getAgenda ( ) ; $ change = false ; $ token = $ respTrack -> getFirstToken ( ) ; if ( ! $ token ) { return ; } do { if ( $ token -> isCompleted ( ) ) { continue ; } $ appId = $ respTrack -> getRoundAfterAppointmentId ( $ token -> getRoundId ( ) ) ; if ( $ appId !== false ) { if ( $ appId ) { $ appointment = $ agenda -> getAppointment ( $ appId ) ; } else { $ appointment = null ; } if ( $ appointment && $ appointment -> isActive ( ) ) { $ newCode = \ GemsEscort :: RECEPTION_OK ; $ newText = null ; } else { $ newCode = 'skip' ; $ newText = $ this -> _ ( 'Skipped until appointment is set' ) ; } $ oldCode = \ GemsEscort :: RECEPTION_OK === $ newCode ? 'skip' : \ GemsEscort :: RECEPTION_OK ; $ curCode = $ token -> getReceptionCode ( ) -> getCode ( ) ; if ( ( $ oldCode === $ curCode ) && ( $ curCode !== $ newCode ) ) { $ change = true ; $ token -> setReceptionCode ( $ newCode , $ newText , $ userId ) ; } } } while ( $ token = $ token -> getNextToken ( ) ) ; if ( $ change ) { $ respTrack -> refresh ( ) ; } }
Process the data and do what must be done
57,932
protected function checkPatient ( $ patientNr , $ orgId ) { if ( ! ( $ patientNr && $ orgId ) ) { return false ; } $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__respondent2org' , array ( 'gr2o_id_user' ) ) -> where ( 'gr2o_patient_nr = ?' , $ patientNr ) -> where ( 'gr2o_id_organization = ?' , $ orgId ) ; return $ this -> db -> fetchOne ( $ select ) ; }
Check should a patient be imported
57,933
public function validateRowValues ( array $ row , $ key ) { $ row = parent :: validateRowValues ( $ row , $ key ) ; $ token = $ this -> loader -> getTracker ( ) -> getToken ( $ row [ 'token' ] ? $ row [ 'token' ] : 'emptytoken' ) ; if ( $ token -> exists ) { if ( $ token -> isCompleted ( ) ) { switch ( $ this -> getTokenCompleted ( ) ) { case self :: TOKEN_SKIP : return false ; case self :: TOKEN_ERROR : $ this -> _addErrors ( sprintf ( $ this -> _ ( 'Token %s is completed.' ) , $ token -> getTokenId ( ) ) , $ key ) ; break ; } } } else { switch ( $ this -> getNoToken ( ) ) { case self :: TOKEN_SKIP : return false ; case self :: TOKEN_ERROR : $ this -> _addErrors ( $ this -> getNoTokenError ( $ row , $ key ) , $ key ) ; break ; default : $ respTrack = $ this -> findRespondentTrackFor ( $ row ) ; if ( $ respTrack ) { $ row [ 'resp_track_id' ] == $ respTrack ; } else { $ this -> _addErrors ( sprintf ( $ this -> _ ( 'No track for inserting found for %s.' ) , implode ( " / " , $ row ) ) , $ key ) ; } } } return $ row ; }
Validate the data against the target form
57,934
protected function getRespondentName ( ) { if ( $ this -> respondentTrack instanceof \ Gems_Tracker_RespondentTrack ) { return $ this -> respondentTrack -> getRespondentName ( ) ; } else { $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__respondents' ) -> joinInner ( 'gems__respondent2org' , 'grs_id_user = gr2o_id_user' , array ( ) ) -> where ( 'gr2o_patient_nr = ?' , $ this -> patientId ) -> where ( 'gr2o_id_organization = ?' , $ this -> organizationId ) ; $ data = $ this -> db -> fetchRow ( $ select ) ; if ( $ data ) { return trim ( $ data [ 'grs_first_name' ] . ' ' . $ data [ 'grs_surname_prefix' ] ) . ' ' . $ data [ 'grs_last_name' ] ; } } return '' ; }
Get a display version of the patient name
57,935
protected function addNextButton ( ) { parent :: addNextButton ( ) ; if ( ! ( isset ( $ this -> formData [ 'survey' ] ) && $ this -> formData [ 'survey' ] ) ) { $ this -> _nextButton -> setAttrib ( 'disabled' , 'disabled' ) ; } }
Add the next button
57,936
protected function getImportTranslator ( ) { $ translator = parent :: getImportTranslator ( ) ; if ( $ translator instanceof \ Gems_Model_Translator_AnswerTranslatorAbstract ) { $ surveyId = isset ( $ this -> formData [ 'survey' ] ) ? $ this -> formData [ 'survey' ] : null ; $ tokenCompleted = isset ( $ this -> formData [ 'tokenCompleted' ] ) ? $ this -> formData [ 'tokenCompleted' ] : \ Gems_Model_Translator_AnswerTranslatorAbstract :: TOKEN_ERROR ; $ skipUnknownPatients = isset ( $ this -> formData [ 'skipUnknownPatients' ] ) && $ this -> formData [ 'skipUnknownPatients' ] ; $ noToken = isset ( $ this -> formData [ 'noToken' ] ) ? $ this -> formData [ 'noToken' ] : \ Gems_Model_Translator_AnswerTranslatorAbstract :: TOKEN_ERROR ; $ trackId = isset ( $ this -> formData [ 'track' ] ) ? $ this -> formData [ 'track' ] : null ; $ translator -> setSurveyId ( $ surveyId ) ; $ translator -> setSkipUnknownPatients ( $ skipUnknownPatients ) ; $ translator -> setTokenCompleted ( $ tokenCompleted ) ; $ translator -> setNoToken ( $ noToken ) ; $ translator -> setTrackId ( $ trackId ) ; } return $ translator ; }
Try to get the current translator
57,937
protected function _applyOptions ( \ MUtil_Model_ModelAbstract $ model , $ fieldName , array $ options , array & $ itemData ) { if ( $ options ) { $ model -> set ( $ fieldName , 'multiOptions' , $ options ) ; if ( ! array_key_exists ( $ itemData [ $ fieldName ] , $ options ) ) { reset ( $ options ) ; $ itemData [ $ fieldName ] = key ( $ options ) ; return true ; } } else { $ model -> del ( $ fieldName , 'label' ) ; } return false ; }
Helper function for default handling of multi options value sets
57,938
protected function _sourceUsesSurvey ( $ source ) { switch ( $ source ) { case self :: APPOINTMENT_TABLE : case self :: NO_TABLE : case self :: RESPONDENT_TRACK_TABLE : return false ; default : return true ; } }
Returns true if the source uses values from another token .
57,939
protected function applyRespondentRelation ( \ MUtil_Model_ModelAbstract $ model , array & $ itemData ) { $ model -> set ( 'gro_id_survey' , 'onchange' , 'this.form.submit();' ) ; if ( ! empty ( $ itemData [ 'gro_id_survey' ] ) && $ model -> has ( 'gro_id_relationfield' ) ) { $ forStaff = $ this -> tracker -> getSurvey ( $ itemData [ 'gro_id_survey' ] ) -> isTakenByStaff ( ) ; if ( ! $ forStaff ) { $ empty = array ( '-1' => $ this -> _ ( 'Patient' ) ) ; $ relations = $ this -> getRespondentRelationFields ( ) ; if ( ! empty ( $ relations ) ) { $ relations = $ empty + $ relations ; $ model -> set ( 'gro_id_relationfield' , 'label' , $ this -> _ ( 'Assigned to' ) , 'multiOptions' , $ relations , 'order' , 25 ) ; } $ model -> del ( 'ggp_name' ) ; } else { $ model -> set ( 'ggp_name' , 'label' , $ this -> translateAdapter -> _ ( 'Assigned to' ) , 'elementClass' , 'Exhibitor' , 'order' , 25 ) ; $ model -> set ( 'gro_id_relationfield' , 'elementClass' , 'hidden' ) ; $ itemData [ 'ggp_name' ] = $ this -> db -> fetchOne ( 'select ggp_name from gems__groups join gems__surveys on ggp_id_group = gsu_id_primary_group and gsu_id_survey = ?' , $ itemData [ 'gro_id_survey' ] ) ; if ( ! is_null ( $ itemData [ 'gro_id_relationfield' ] ) ) { $ itemData [ 'gro_id_relationfield' ] = null ; } } } else { $ model -> del ( 'gro_id_relationfield' , 'label' ) ; $ model -> del ( 'ggp_name' ) ; if ( $ model -> has ( 'gro_id_relationfield' ) ) { $ itemData [ 'gro_id_relationfield' ] = null ; } } }
Apply respondent relation settings to the round model
57,940
protected function checkTokenDates ( $ token , $ round , $ userId ) { if ( $ token -> isCompleted ( ) || ! $ token -> getReceptionCode ( ) -> isSuccess ( ) || ( $ token -> isValidFromManual ( ) && $ token -> isValidUntilManual ( ) ) ) { return 0 ; } $ respTrack = $ token -> getRespondentTrack ( ) ; if ( $ token -> isValidFromManual ( ) ) { $ validFrom = $ token -> getValidFrom ( ) ; } else { $ fromDate = $ this -> getValidFromDate ( $ round [ 'gro_valid_after_source' ] , $ round [ 'gro_valid_after_field' ] , $ round [ 'gro_valid_after_id' ] , $ token , $ respTrack ) ; $ validFrom = $ this -> calculateFromDate ( $ fromDate , $ round [ 'gro_valid_after_unit' ] , $ round [ 'gro_valid_after_length' ] ) ; } if ( $ token -> isValidUntilManual ( ) ) { $ validUntil = $ token -> getValidUntil ( ) ; } else { $ untilDate = $ this -> getValidUntilDate ( $ round [ 'gro_valid_for_source' ] , $ round [ 'gro_valid_for_field' ] , $ round [ 'gro_valid_for_id' ] , $ token , $ respTrack , $ validFrom ) ; $ validUntil = $ this -> calculateUntilDate ( $ untilDate , $ round [ 'gro_valid_for_unit' ] , $ round [ 'gro_valid_for_length' ] ) ; } return $ token -> setValidFrom ( $ validFrom , $ validUntil , $ userId ) ; }
Check the valid from and until dates for this token
57,941
public function checkTokensFrom ( \ Gems_Tracker_RespondentTrack $ respTrack , \ Gems_Tracker_Token $ startToken , $ userId , \ Gems_Tracker_Token $ skipToken = null ) { $ this -> _ensureRounds ( ) ; $ respTrack -> getTokens ( ) ; $ changed = 0 ; $ token = $ startToken ; while ( $ token ) { $ round = false ; $ changes = 0 ; if ( array_key_exists ( $ token -> getRoundId ( ) , $ this -> _rounds ) ) { $ round = $ this -> _rounds [ $ token -> getRoundId ( ) ] ; } if ( $ round && $ token !== $ skipToken ) { $ changes = $ this -> checkTokenDates ( $ token , $ round , $ userId ) ; $ changes += $ this -> checkTokenCondition ( $ token , $ round , $ userId ) ; } $ changed += min ( $ changes , 1 ) ; $ token = $ token -> getNextToken ( ) ; } return $ changed ; }
Check the valid from and until dates in the track starting at a specified token
57,942
public function checkTokensFromStart ( \ Gems_Tracker_RespondentTrack $ respTrack , $ userId ) { $ token = $ respTrack -> getFirstToken ( ) ; if ( $ token instanceof \ Gems_Tracker_Token ) { return $ this -> checkTokensFrom ( $ respTrack , $ respTrack -> getFirstToken ( ) , $ userId ) ; } else { return 0 ; } }
Check the valid from and until dates in the track
57,943
protected function getDateOptionsFor ( $ sourceType , $ roundId , $ language , $ validAfter ) { switch ( $ sourceType ) { case self :: NO_TABLE : return array ( ) ; case self :: ANSWER_TABLE : if ( ! isset ( $ this -> _rounds [ $ roundId ] , $ this -> _rounds [ $ roundId ] [ 'gro_id_survey' ] ) ) { return array ( ) ; } $ surveyId = $ this -> _rounds [ $ roundId ] [ 'gro_id_survey' ] ; $ survey = $ this -> tracker -> getSurvey ( $ surveyId ) ; return $ survey -> getDatesList ( $ language ) ; case self :: APPOINTMENT_TABLE : return $ this -> _fieldsDefinition -> getFieldLabelsOfType ( FieldsDefinition :: TYPE_APPOINTMENT ) ; case self :: RESPONDENT_TRACK_TABLE : $ results = array ( 'gr2t_start_date' => $ this -> _ ( 'Track start' ) , 'gr2t_end_date' => $ this -> _ ( 'Track end' ) , ) ; return $ results + $ this -> _fieldsDefinition -> getFieldLabelsOfType ( array ( FieldsDefinition :: TYPE_DATE , FieldsDefinition :: TYPE_DATETIME , ) ) ; case self :: TOKEN_TABLE : return array ( 'gto_valid_from' => $ this -> _ ( 'Valid from' ) , 'gto_valid_until' => $ this -> _ ( 'Valid until' ) , 'gto_start_time' => $ this -> _ ( 'Start time' ) , 'gto_completion_time' => $ this -> _ ( 'Completion date' ) , ) ; } }
Returns the date fields selectable using the current source
57,944
public function getRespondentRelationFields ( ) { $ fields = array ( ) ; $ relationFields = $ this -> getFieldsOfType ( 'relation' ) ; if ( ! empty ( $ relationFields ) ) { $ fieldNames = $ this -> getFieldNames ( ) ; $ fieldPrefix = FieldMaintenanceModel :: FIELDS_NAME . FieldsDefinition :: FIELD_KEY_SEPARATOR ; foreach ( $ this -> getFieldsOfType ( 'relation' ) as $ key => $ field ) { $ id = str_replace ( $ fieldPrefix , '' , $ key ) ; $ fields [ $ id ] = $ fieldNames [ $ key ] ; } } return $ fields ; }
Get all respondent relation fields
57,945
protected function getSourceList ( $ validAfter , $ firstRound , $ detailed = true ) { if ( ! ( $ validAfter || $ this -> project -> isValidUntilRequired ( ) ) ) { $ results [ self :: NO_TABLE ] = array ( $ this -> _ ( 'Does not expire' ) ) ; } if ( ! ( $ validAfter && $ firstRound ) ) { $ results [ self :: ANSWER_TABLE ] = array ( $ this -> _ ( 'Answers' ) , $ this -> _ ( 'Use an answer from a survey.' ) ) ; } if ( $ this -> _fieldsDefinition -> hasAppointmentFields ( ) ) { $ results [ self :: APPOINTMENT_TABLE ] = array ( $ this -> _ ( 'Appointment' ) , $ this -> _ ( 'Use an appointment linked to this track.' ) , ) ; } if ( ! ( $ validAfter && $ firstRound ) ) { $ results [ self :: TOKEN_TABLE ] = array ( $ this -> _ ( 'Token' ) , $ this -> _ ( 'Use a standard token date.' ) ) ; } $ results [ self :: RESPONDENT_TRACK_TABLE ] = array ( $ this -> _ ( 'Track' ) , $ this -> _ ( 'Use a track level date.' ) ) ; if ( $ detailed ) { foreach ( $ results as $ key => $ value ) { if ( is_array ( $ value ) ) { $ results [ $ key ] = \ MUtil_Html :: raw ( sprintf ( '<strong>%s</strong> %s' , reset ( $ value ) , next ( $ value ) ) ) ; } } } else { foreach ( $ results as $ key => $ value ) { if ( is_array ( $ value ) ) { $ results [ $ key ] = reset ( $ value ) ; } } } return $ results ; }
Returns the source choices in an array .
57,946
protected function getSurveyId ( $ roundId ) { $ this -> _ensureRounds ( ) ; if ( isset ( $ this -> _rounds [ $ roundId ] [ 'gro_id_survey' ] ) ) { return $ this -> _rounds [ $ roundId ] [ 'gro_id_survey' ] ; } throw new \ Gems_Exception_Coding ( "Requested non existing survey id for round $roundId." ) ; }
Look up the survey id associated with a round
57,947
public function getTokenShowSnippetNames ( \ Gems_Tracker_Token $ token ) { $ output [ ] = 'Token\\ShowTrackTokenSnippet' ; if ( $ token -> isCompleted ( ) && $ this -> currentUser -> hasPrivilege ( 'pr.token.answers' ) ) { $ output [ ] = 'Tracker_Answers_SingleTokenAnswerModelSnippet' ; } elseif ( $ this -> currentUser -> hasPrivilege ( 'pr.project.questions' ) ) { $ output [ ] = 'Survey\\SurveyQuestionsSnippet' ; } return $ output ; }
An array of snippet names for displaying a token
57,948
protected function setDateListFor ( \ MUtil_Model_ModelAbstract $ model , $ fieldName , $ source , $ roundId , $ language , $ validAfter ) { $ dateOptions = $ this -> getDateOptionsFor ( $ source , $ roundId , $ language , $ validAfter ) ; switch ( count ( $ dateOptions ) ) { case 0 : $ model -> del ( $ fieldName , 'label' ) ; break ; case 1 : $ model -> set ( $ fieldName , 'elementClass' , 'exhibitor' ) ; default : $ model -> set ( $ fieldName , 'multiOptions' , $ dateOptions ) ; break ; } }
The logic to set the display of the valid_X_field date list field .
57,949
public function updateRoundModelToItem ( \ MUtil_Model_ModelAbstract $ model , array & $ itemData , $ language ) { $ this -> _ensureRounds ( ) ; $ first = ! $ this -> getPreviousRoundId ( $ itemData [ 'gro_id_round' ] , $ itemData [ 'gro_id_order' ] ) ; if ( isset ( $ this -> _rounds [ $ itemData [ 'gro_id_round' ] ] ) ) { $ this -> _rounds [ $ itemData [ 'gro_id_round' ] ] = $ itemData + $ this -> _rounds [ $ itemData [ 'gro_id_round' ] ] ; } else { $ this -> _rounds [ $ itemData [ 'gro_id_round' ] ] = $ itemData ; } $ result = false ; if ( ! $ this -> _sourceUsesSurvey ( $ itemData [ 'gro_valid_after_source' ] ) ) { $ model -> del ( 'gro_valid_after_id' , 'label' ) ; } else { $ result = $ this -> applySurveyListValidAfter ( $ model , $ itemData ) || $ result ; } $ result = $ this -> _applyOptions ( $ model , 'gro_valid_after_source' , $ this -> getSourceList ( true , $ first ) , $ itemData ) || $ result ; $ result = $ this -> applyDatesValidAfter ( $ model , $ itemData , $ language ) || $ result ; if ( ! $ this -> _sourceUsesSurvey ( $ itemData [ 'gro_valid_for_source' ] ) ) { $ model -> del ( 'gro_valid_for_id' , 'label' ) ; } else { $ result = $ this -> applySurveyListValidFor ( $ model , $ itemData ) || $ result ; } $ result = $ this -> _applyOptions ( $ model , 'gro_valid_for_source' , $ this -> getSourceList ( false , $ first ) , $ itemData ) || $ result ; $ result = $ this -> applyDatesValidFor ( $ model , $ itemData , $ language ) || $ result ; $ result = $ this -> applyRespondentRelation ( $ model , $ itemData ) || $ result ; return $ result ; }
Updates the model to reflect the values for the current item data
57,950
public function createActionButtons ( \ MUtil_Model_Bridge_TableBridge $ bridge ) { $ tData = $ this -> util -> getTokenData ( ) ; $ actionLinks [ 'ask' ] = $ tData -> getTokenAskLinkForBridge ( $ bridge , true ) ; $ actionLinks [ 'email' ] = $ tData -> getTokenEmailLinkForBridge ( $ bridge ) ; $ actionLinks [ 'answer' ] = $ tData -> getTokenAnswerLinkForBridge ( $ bridge ) ; $ output = [ ] ; foreach ( $ actionLinks as $ key => $ actionLink ) { if ( $ actionLink ) { $ output [ ] = ' ' ; $ output [ $ key ] = \ MUtil_Html :: create ( 'div' , $ actionLink , [ 'class' => 'rightFloat' , 'renderWithoutContent' => false , 'style' => 'clear: right;' ] ) ; } } return $ output ; }
Return a list of possible action buttons for the token
57,951
protected function createEditPrepare ( ) { $ this -> createEditSnippets = $ this -> getTrackEngine ( ) -> getRoundEditSnippetNames ( ) ; \ MUtil_JQuery :: enableView ( $ this -> view ) ; $ this -> view -> headScript ( ) -> appendFile ( $ this -> basepath -> getBasePath ( ) . '/gems/js/jquery.showOnChecked.js' ) ; if ( \ MUtil_Bootstrap :: enabled ( ) ) { $ this -> view -> headScript ( ) -> appendScript ( "jQuery(document).ready(function($) { $('input[name=\"organizations[]\"]').closest('div').showOnChecked( { showInput: $('#org_specific_round-1') }); });" ) ; } else { $ this -> view -> headScript ( ) -> appendScript ( "jQuery(document).ready(function($) { $('input[name=\"organizations[]\"]').closest('tr').showOnChecked( { showInput: $('#org_specific_round-1') }); });" ) ; } }
Preparations for creating and editing
57,952
private function _setMenuParameters ( array $ data ) { $ source = $ this -> menu -> getParameterSource ( ) ; $ source [ 'script' ] = $ data [ 'script' ] ? true : false ; $ source [ 'exists' ] = $ data [ 'exists' ] ? true : false ; }
Set the parameters needed by the menu .
57,953
private function _cleanCache ( ) { if ( $ this -> cache instanceof \ Zend_Cache_Core ) { $ this -> cache -> clean ( ) ; $ this -> addMessage ( $ this -> _ ( 'Cache cleaned' ) ) ; } }
Make sure the cache is cleaned .
57,954
public function showChangesAction ( ) { $ patchLevels = $ this -> db -> fetchPairs ( 'SELECT DISTINCT gpa_level, gpa_level FROM gems__patches ORDER BY gpa_level DESC' ) ; $ searchData [ 'gpa_level' ] = reset ( $ patchLevels ) ; if ( $ this -> request instanceof \ Zend_Controller_Request_Abstract ) { $ searchData = $ this -> request -> getParams ( ) + $ searchData ; } $ snippet = $ this -> addSnippet ( 'Database\\StructuralChanges' , 'patchLevels' , $ patchLevels , 'searchData' , $ searchData ) ; if ( 1 == $ this -> request -> getParam ( 'download' ) ) { $ snippet -> outputText ( $ this -> view , $ this -> _helper ) ; } }
Show the changes in the database
57,955
private function _setMulti ( $ value , $ name1 , $ name2 = null ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; foreach ( $ args as $ key ) { $ this -> offsetSet ( $ key , $ value ) ; } }
Helper function to set more than one array key to the same value
57,956
protected function createRequest ( $ class , array $ parameters ) { if ( ! isset ( $ parameters [ 'credentials' ] ) ) { $ parameters [ 'credentials' ] = new Credentials ( array_intersect_key ( $ this -> getCredentialFields ( ) , $ parameters ) ) ; } return new $ class ( $ parameters ) ; }
Initialize a request object
57,957
public function addAskPage ( $ label ) { $ page = $ this -> addPage ( $ label , null , 'ask' ) ; $ page -> addAction ( null , null , 'forward' ) ; $ page -> addAction ( null , null , 'return' ) ; $ page -> addAction ( null , null , 'to-survey' ) -> setModelParameters ( 1 ) ; $ page -> addAction ( null , null , 'token' ) ; return $ page ; }
Shortcut function to create a ask menu with hidden options .
57,958
public function addContactPage ( $ label ) { $ project = $ this -> escort -> project ; $ page = $ this -> addPage ( $ label , null , 'contact' ) ; $ page -> addAction ( sprintf ( $ this -> _ ( 'About %s' ) , $ project -> getName ( ) ) , null , 'about' ) ; $ page -> addAction ( sprintf ( $ this -> _ ( 'About %s' ) , $ this -> _ ( 'GemsTracker' ) ) , 'pr.contact.gems' , 'gems' ) ; $ page -> addAction ( $ this -> _ ( 'Reporting bugs' ) , 'pr.contact.bugs' , 'bugs' ) ; $ page -> addAction ( $ this -> _ ( 'Support' ) , 'pr.contact.support' , 'support' ) ; return $ page ; }
Shortcut function to create a contact container .
57,959
public function addHiddenPrivilege ( $ privilege , $ label = null ) { if ( null === $ label ) { $ label = $ this -> _ ( 'Stand-alone privilege: %s' ) ; } $ this -> _hiddenPrivileges [ $ privilege ] = sprintf ( $ label , $ privilege ) ; return $ this ; }
Use this to add a privilege that is not associated with a menu item .
57,960
public function addOpenRosaContainer ( $ label , $ parent = null ) { if ( $ this -> escort -> getOption ( 'useOpenRosa' ) ) { if ( is_null ( $ parent ) ) { $ parent = $ this ; } $ page = $ parent -> addBrowsePage ( $ label , 'pr.openrosa' , 'openrosa' ) ; $ page -> addButtonOnly ( $ this -> _ ( 'Scan Responses' ) , 'pr.openrosa.scan' , 'openrosa' , 'scanresponses' ) ; $ this -> addPage ( null , null , 'openrosa' , 'submission' ) ; $ this -> addPage ( null , null , 'openrosa' , 'formList' ) ; $ this -> addPage ( null , null , 'openrosa' , 'download' ) ; $ this -> addPage ( null , null , 'openrosa' , 'barcode' ) ; $ this -> addPage ( null , 'pr.islogin' , 'openrosa' , 'image' ) ; $ this -> addPage ( null , null , 'open-rosa-form' , 'edit' ) ; } }
Shortcut function to add all items needed for OpenRosa
57,961
public function addParticipatePage ( $ label ) { $ participate = $ this -> addContainer ( $ label ) ; $ subscr = $ participate -> addPage ( $ this -> _ ( 'Subscribe' ) , 'pr.participate.subscribe' , 'participate' , 'subscribe' ) ; $ subscr -> addPage ( null , 'pr.participate.subscribe' , 'participate' , 'subscribe-thanks' ) ; $ unsub = $ participate -> addPage ( $ this -> _ ( 'Unsubscribe' ) , 'pr.participate.unsubscribe' , 'participate' , 'unsubscribe' ) ; $ unsub -> addPage ( null , 'pr.participate.unsubscribe' , 'participate' , 'unsubscribe-thanks' ) ; return $ participate ; }
Shortcut function to create a participate page
57,962
public function getCurrentMenuList ( \ Zend_Controller_Request_Abstract $ request , $ parentLabel = null ) { $ controller = $ request -> getControllerName ( ) ; $ action = $ request -> getActionName ( ) ; $ menuList = $ this -> getMenuList ( ) ; if ( $ controller !== 'index' ) { $ menuList -> addByController ( $ controller , 'index' , $ parentLabel ) ; } foreach ( $ this -> getCurrent ( ) -> getChildren ( ) as $ child ) { if ( $ child instanceof \ Gems_Menu_SubMenuItem ) { $ chAction = $ child -> get ( 'action' ) ; $ chContr = $ child -> get ( 'controller' ) ; if ( ! ( $ controller == $ chContr && $ action == $ chAction ) ) { $ menuList -> addByController ( $ chContr , $ chAction ) ; } } } return $ menuList ; }
Menulist populated with current items
57,963
protected function renderItems ( \ MUtil_Html_ListElement $ ul , array $ items , $ cascade ) { foreach ( $ items as $ item ) { if ( isset ( $ item [ 'visible' ] , $ item [ 'label' ] ) && $ item [ 'visible' ] && $ item [ 'label' ] ) { $ url = $ item [ 'params' ] ; $ url [ 'controller' ] = $ item [ 'controller' ] ; $ url [ 'action' ] = $ item [ 'action' ] ; $ url [ 'RouteReset' ] = true ; $ li = $ ul -> li ( ) ; if ( isset ( $ item [ 'active' ] ) && $ item [ 'active' ] ) { $ li -> class = 'active' ; } if ( isset ( $ item [ 'liClass' ] ) && $ item [ 'liClass' ] ) { $ li -> appendAttrib ( 'class' , $ item [ 'liClass' ] ) ; } $ a = $ li -> a ( $ url , $ item [ 'label' ] ) ; if ( isset ( $ item [ 'class' ] ) ) { $ a -> class = $ item [ 'class' ] ; } if ( isset ( $ item [ 'target' ] ) ) { $ a -> target = $ item [ 'target' ] ; } if ( $ cascade && isset ( $ item [ 'pages' ] ) && is_array ( $ item [ 'pages' ] ) ) { $ this -> renderItems ( $ li -> ul ( array ( 'class' => 'subnav ' . $ this -> _menuUlClass ) ) , $ item [ 'pages' ] , true ) ; } } } }
Helper function to load the menu items to the html element .
57,964
public function toZendNavigation ( \ Zend_Controller_Request_Abstract $ request , $ actionController = null ) { if ( $ this -> _onlyActiveBranchVisible ) { $ activePath = $ this -> _findPath ( $ request ) ; $ this -> setBranchVisible ( $ activePath ) ; } $ parameterSources = func_get_args ( ) ; if ( $ this -> _menuParameters ) { $ parameterSources [ ] = $ this -> _menuParameters ; } $ source = new \ Gems_Menu_ParameterCollector ( $ parameterSources ) ; $ nav = new \ Zend_Navigation ( $ this -> _toNavigationArray ( $ source ) ) ; return $ nav ; }
Generates a \ Zend_Navigation object from the current menu
57,965
public function addExport ( $ data , $ modelId = false ) { $ this -> files = $ this -> getFiles ( ) ; $ this -> data = $ data ; $ this -> modelId = $ modelId ; if ( $ model = $ this -> getModel ( ) ) { if ( $ this -> model -> getMeta ( 'nested' , false ) ) { $ this -> rowsPerBatch = $ this -> nestedRowsPerBatch ; } $ totalRows = $ this -> getModelCount ( ) ; $ this -> addFile ( ) ; $ this -> addHeader ( $ this -> tempFilename . $ this -> fileExtension ) ; $ currentRow = 0 ; do { $ filter [ 'limit' ] = array ( $ this -> rowsPerBatch , $ currentRow ) ; if ( $ this -> batch ) { $ this -> batch -> addTask ( 'Export_ExportCommand' , $ data [ 'type' ] , 'addRows' , $ data , $ modelId , $ this -> tempFilename , $ filter ) ; } else { $ this -> addRows ( $ data , $ modelId , $ this -> tempFilename , $ filter ) ; } $ currentRow = $ currentRow + $ this -> rowsPerBatch ; } while ( $ currentRow < $ totalRows ) ; if ( $ this -> batch ) { $ this -> batch -> addTask ( 'Export_ExportCommand' , $ data [ 'type' ] , 'addFooter' , $ this -> tempFilename . $ this -> fileExtension , $ modelId ) ; $ this -> batch -> setSessionVariable ( 'files' , $ this -> files ) ; } else { $ this -> addFooter ( $ this -> tempFilename . $ this -> fileExtension , $ modelId ) ; $ this -> _session = new \ Zend_Session_Namespace ( __CLASS__ ) ; $ this -> _session -> files = $ this -> files ; } } }
Add an export command with specific details . Can be batched .
57,966
protected function addUserLogin ( \ Gems_Model_JoinModel $ model , $ loginField , $ organizationField ) { $ model -> addTable ( 'gems__user_logins' , array ( $ loginField => 'gul_login' , $ organizationField => 'gul_id_organization' ) , 'gul' , \ MUtil_Model_DatabaseModelAbstract :: SAVE_MODE_INSERT | \ MUtil_Model_DatabaseModelAbstract :: SAVE_MODE_UPDATE | \ MUtil_Model_DatabaseModelAbstract :: SAVE_MODE_DELETE ) ; if ( $ model -> has ( 'gul_enable_2factor' ) && $ model -> has ( 'gul_two_factor_key' ) ) { $ model -> addColumn ( new \ Zend_Db_Expr ( "CASE WHEN gul_enable_2factor IS NULL THEN -1 WHEN gul_enable_2factor = 1 AND gul_two_factor_key IS NULL THEN 1 WHEN gul_enable_2factor = 1 AND gul_two_factor_key IS NOT NULL THEN 2 ELSE 0 END" ) , 'has_2factor' ) ; } }
Link the model to the user_logins table .
57,967
public function createGemsUserId ( $ value , $ isNew = false , $ name = null , array $ context = array ( ) ) { if ( $ value ) { return $ value ; } $ creationTime = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; do { $ out = mt_rand ( 1 , 9 ) ; for ( $ i = 1 ; $ i < $ this -> userIdLen ; $ i ++ ) { $ out .= mt_rand ( 0 , 9 ) ; } $ out = intval ( $ out ) ; try { if ( 0 === $ this -> db -> insert ( 'gems__user_ids' , array ( 'gui_id_user' => $ out , 'gui_created' => $ creationTime ) ) ) { $ out = null ; } } catch ( \ Zend_Db_Exception $ e ) { $ out = null ; } } while ( null === $ out ) ; return $ out ; }
Create a Gems project wide unique user id
57,968
public function getCommLogModel ( $ detailed ) { $ model = $ this -> _loadClass ( 'CommLogModel' , true ) ; $ model -> applySetting ( $ detailed ) ; return $ model ; }
Load the comm log model
57,969
public function getRespondentModel ( $ detailed ) { static $ isDetailed ; static $ model ; if ( $ model && ( $ isDetailed === $ detailed ) ) { return $ model ; } $ isDetailed = $ detailed ; $ model = $ this -> createRespondentModel ( ) ; if ( $ detailed ) { $ model -> applyDetailSettings ( ) ; } else { $ model -> applyBrowseSettings ( ) ; } return $ model ; }
Load project specific respondent model or general Gems model otherwise
57,970
public function getStaffModel ( $ addLogin = true ) { $ model = $ this -> _loadClass ( 'StaffModel' , true ) ; if ( $ addLogin ) { $ this -> addUserLogin ( $ model , 'gsf_login' , 'gsf_id_organization' ) ; } $ this -> setAsGemsUserId ( $ model , 'gsf_id_user' ) ; return $ model ; }
Load the staffmodel
57,971
public function setAsGemsUserId ( \ MUtil_Model_DatabaseModelAbstract $ model , $ idField ) { $ model -> setAutoSave ( $ idField ) ; $ model -> setOnSave ( $ idField , array ( $ this , 'createGemsUserId' ) ) ; }
Set a field in this model as a gems unique user id
57,972
public static function setChangeFieldsByPrefix ( \ MUtil_Model_DatabaseModelAbstract $ model , $ prefix , $ userid = null ) { $ changed_field = $ prefix . '_changed' ; $ changed_by_field = $ prefix . '_changed_by' ; $ created_field = $ prefix . '_created' ; $ created_by_field = $ prefix . '_created_by' ; foreach ( array ( $ changed_field , $ changed_by_field , $ created_field , $ created_by_field ) as $ field ) { $ model -> set ( $ field , 'elementClass' , 'none' ) ; } $ model -> setOnSave ( $ changed_field , new \ MUtil_Db_Expr_CurrentTimestamp ( ) ) ; $ model -> setSaveOnChange ( $ changed_field ) ; $ model -> setOnSave ( $ created_field , new \ MUtil_Db_Expr_CurrentTimestamp ( ) ) ; $ model -> setSaveWhenNew ( $ created_field ) ; if ( ! $ userid && self :: $ currentUserId ) { $ userid = self :: $ currentUserId ; } if ( ! $ userid ) { $ escort = \ GemsEscort :: getInstance ( ) ; if ( $ escort ) { $ currentUser = $ escort -> currentUser ; if ( $ currentUser instanceof Gems_User_User ) { $ userid = $ currentUser -> getUserId ( ) ; } if ( ! $ userid ) { $ userid = 1 ; } } } if ( $ userid ) { $ model -> setOnSave ( $ changed_by_field , $ userid ) ; $ model -> setSaveOnChange ( $ changed_by_field ) ; $ model -> setOnSave ( $ created_by_field , $ userid ) ; $ model -> setSaveWhenNew ( $ created_by_field ) ; } }
Function that automatically fills changed changed_by created and created_by fields with a certain prefix .
57,973
public function getChildOrganizations ( $ parentId = null ) { static $ children ; if ( is_null ( $ parentId ) ) { return array ( ) ; } if ( ! isset ( $ children [ $ parentId ] ) ) { $ organizations = $ this -> db -> fetchPairs ( 'SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_has_login=1 AND (gor_accessible_by LIKE ' . $ this -> db -> quote ( '%:' . $ parentId . ':%' ) . ' OR gor_id_organization = ' . $ this -> db -> quote ( $ parentId ) . ') ORDER BY gor_name' ) ; natsort ( $ organizations ) ; $ children [ $ parentId ] = $ organizations ; } return $ children [ $ parentId ] ; }
Return array of organizations that are a child of the given parentId
57,974
public function getCurrentTopOrganizationId ( ) { $ userLoader = $ this -> loader -> getUserLoader ( ) ; if ( $ orgId = $ userLoader -> getOrganizationIdByUrl ( ) ) { $ this -> _organizationFromUrl = true ; return ' ' ; } $ request = $ this -> getRequest ( ) ; if ( $ request -> isPost ( ) && ( $ orgId = $ request -> getParam ( $ this -> topOrganizationFieldName ) ) ) { \ Gems_Cookies :: set ( 'gems_toporganization' , $ orgId ) ; return $ orgId ; } else { $ orgs = array_keys ( $ this -> getTopOrganizations ( ) ) ; $ firstId = reset ( $ orgs ) ; return \ Gems_Cookies :: get ( $ this -> getRequest ( ) , 'gems_toporganization' , $ firstId ) ; } }
Returns the top organization id that should currently be used for this form .
57,975
public function getTopOrganizations ( ) { try { $ organizations = $ this -> db -> fetchPairs ( 'SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_has_login=1 AND (gor_accessible_by IS NULL OR gor_accessible_by = "::") ORDER BY gor_name' ) ; } catch ( \ Exception $ e ) { try { $ organizations = $ this -> db -> fetchPairs ( 'SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_accessible_by IS NULL ORDER BY gor_name' ) ; } catch ( \ Exception $ e ) { $ organizations = array ( ) ; } } natsort ( $ organizations ) ; return $ organizations ; }
Return a list of organizations that are considered top - organizations in this case organizations that are not accessible by others as they are considered the children of the top organizations . Feel free to modify to suit your needs .
57,976
public function loadDefaultElements ( ) { if ( is_null ( $ this -> topOrganizationDescription ) ) { $ this -> topOrganizationDescription = $ this -> translate -> _ ( 'Organization' ) ; } if ( is_null ( $ this -> childOrganizationDescription ) ) { $ this -> childOrganizationDescription = $ this -> translate -> _ ( 'Department' ) ; } $ this -> getTopOrganizationElement ( ) ; parent :: loadDefaultElements ( ) ; return $ this ; }
Load the elements starting with the extra top organization element and continue with the other elements like in the standard login form
57,977
public function getExportModelSource ( ) { if ( ! $ this -> _exportModelSource ) { $ this -> _exportModelSource = $ this -> loader -> getExportModelSource ( $ this -> exportModelSourceClass ) ; } return $ this -> _exportModelSource ; }
Function to get a model source for this export
57,978
protected function replaceCreateView ( \ Gems_Tracker_Survey $ survey , \ MUtil_Model_ModelAbstract $ answerModel ) { $ viewName = $ this -> getViewName ( $ survey ) ; $ responseDb = $ this -> project -> getResponseDatabase ( ) ; $ fieldSql = '' ; foreach ( $ answerModel -> getItemsOrdered ( ) as $ name ) { if ( true === $ answerModel -> get ( $ name , 'survey_question' ) && ! in_array ( $ name , array ( 'submitdate' , 'startdate' , 'datestamp' ) ) && ! $ answerModel -> is ( $ name , 'type' , \ MUtil_Model :: TYPE_NOVALUE ) ) { $ fieldSql .= ',MAX(IF(gdr_answer_id = ' . $ responseDb -> quote ( $ name ) . ', gdr_response, NULL)) AS ' . $ responseDb -> quoteIdentifier ( $ name ) ; } } if ( $ fieldSql > '' ) { $ dbConfig = $ this -> db -> getConfig ( ) ; $ tokenTable = $ this -> db -> quoteIdentifier ( $ dbConfig [ 'dbname' ] . '.gems__tokens' ) ; $ createViewSql = 'CREATE OR REPLACE VIEW ' . $ responseDb -> quoteIdentifier ( $ viewName ) . ' AS SELECT gdr_id_token' ; $ createViewSql .= $ fieldSql ; $ createViewSql .= "FROM gemsdata__responses join " . $ tokenTable . " on (gto_id_token=gdr_id_token and gto_id_survey=" . $ survey -> getSurveyId ( ) . ") GROUP BY gdr_id_token;" ; try { $ responseDb -> query ( $ createViewSql ) -> execute ( ) ; } catch ( Exception $ exc ) { $ responseConfig = $ responseDb -> getConfig ( ) ; $ dbUser = $ this -> db -> quoteIdentifier ( $ responseConfig [ 'username' ] ) . '@' . $ this -> db -> quoteIdentifier ( $ responseConfig [ 'host' ] ) ; $ statement = "GRANT SELECT ON " . $ tokenTable . " TO " . $ dbUser ; $ batch = $ this -> getBatch ( ) ; $ batch -> addMessage ( sprintf ( $ this -> _ ( "View creation failed for survey %s with message: '%s'" ) , $ survey -> getName ( ) , $ exc -> getMessage ( ) ) ) ; $ batch -> addMessage ( sprintf ( $ this -> _ ( "View creation statement: %s" ) , $ createViewSql ) ) ; $ batch -> addMessage ( sprintf ( $ this -> _ ( "Try adding rights using this statement: %s" ) , $ statement ) ) ; } } }
Handles creating or replacing the view for this survey
57,979
private function getPercentage ( $ value ) { $ percentage = ( $ value - $ this -> min ) / ( $ this -> max - $ this -> min ) * 100 ; return $ percentage ; }
Return the percentage in the range between min and max for this chart
57,980
public function calculateFieldsInfo ( array $ data ) { if ( ! $ this -> exists ) { return null ; } $ output = array ( ) ; foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field instanceof FieldInterface ) { if ( $ field -> toTrackInfo ( ) ) { $ inVal = isset ( $ data [ $ key ] ) ? $ data [ $ key ] : null ; $ outVal = $ field -> calculateFieldInfo ( $ inVal , $ data ) ; if ( $ outVal && $ field -> isLabelInTrackInfo ( ) ) { $ label = $ field -> getLabel ( ) ; if ( $ label ) { $ output [ ] = $ label ; } } if ( is_array ( $ outVal ) ) { $ output = array_merge ( $ output , array_filter ( $ outVal ) ) ; } elseif ( $ outVal || ( $ outVal == 0 ) ) { $ output [ ] = $ outVal ; } } } } return substr ( trim ( implode ( ' ' , $ output ) ) , 0 , $ this -> maxTrackInfoChars ) ; }
Calculate the content for the track info field using the other fields
57,981
public function getDataModelDependency ( ) { if ( ! $ this -> exists ) { return null ; } $ dependency = new FieldDataDependency ( ) ; foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field instanceof FieldInterface ) { $ dependsOn = $ field -> getDataModelDependsOn ( ) ; if ( $ field -> hasDataModelDependencies ( ) ) { $ dependency -> addField ( $ field ) ; } } } if ( $ dependency -> getFieldCount ( ) ) { return $ dependency ; } else { return null ; } }
Get model dependency that changes model settings for each row when loaded
57,982
public function getDataModelSettings ( ) { if ( ! $ this -> exists ) { return array ( ) ; } $ fieldSettings = array ( ) ; foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field instanceof FieldInterface ) { $ fieldSettings [ $ key ] = $ field -> getDataModelSettings ( ) ; } } return $ fieldSettings ; }
Get a big array with model settings for fields in a track
57,983
public function getDataStorageModel ( ) { if ( ! $ this -> _dataModel instanceof FieldDataModel ) { $ this -> _dataModel = $ this -> tracker -> createTrackClass ( 'Model\\FieldDataModel' ) ; } return $ this -> _dataModel ; }
Get the storage model for field values
57,984
public function getFieldByCode ( $ code ) { foreach ( $ this -> _fields as $ field ) { if ( $ field instanceof FieldInterface ) { if ( $ field -> getCode ( ) == $ code ) { return $ field ; } } } return null ; }
Get a specific field by field code
57,985
public function getFieldByOrder ( $ order ) { foreach ( $ this -> _fields as $ field ) { if ( $ field instanceof FieldInterface ) { if ( $ field -> getOrder ( ) == $ order ) { return $ field ; } } } return null ; }
Get a specific field by field order
57,986
public function getFieldsDataFor ( $ respTrackId ) { if ( ! $ this -> _fields ) { return array ( ) ; } $ output = array_fill_keys ( array_keys ( $ this -> _fields ) , null ) ; if ( ! $ respTrackId ) { return $ output ; } $ model = $ this -> getDataStorageModel ( ) ; $ rows = $ model -> load ( array ( 'gr2t2f_id_respondent_track' => $ respTrackId ) ) ; if ( $ rows ) { foreach ( $ rows as $ row ) { $ key = self :: makeKey ( $ row [ 'sub' ] , $ row [ 'gr2t2f_id_field' ] ) ; if ( isset ( $ this -> _fields [ $ key ] ) && ( $ this -> _fields [ $ key ] instanceof FieldInterface ) ) { $ value = $ this -> _fields [ $ key ] -> onFieldDataLoad ( $ row [ 'gr2t2f_value' ] , $ output , $ respTrackId ) ; } else { $ value = $ row [ 'gr2t2f_value' ] ; } $ output [ $ key ] = $ value ; } } return $ output ; }
Returns the field data for the respondent track id .
57,987
public function getMaintenanceModel ( $ detailed = false , $ action = 'index' ) { if ( isset ( $ this -> _maintenanceModels [ $ action ] ) ) { return $ this -> _maintenanceModels [ $ action ] ; } $ model = $ this -> tracker -> createTrackClass ( 'Model\\FieldMaintenanceModel' ) ; if ( $ detailed ) { if ( ( 'edit' === $ action ) || ( 'create' === $ action ) ) { $ model -> applyEditSettings ( ) ; if ( 'create' === $ action ) { $ model -> set ( 'gtf_id_track' , 'default' , $ this -> _trackId ) ; $ row = $ model -> loadFirst ( array ( 'gtf_id_track' => $ this -> _trackId ) , array ( 'gtf_id_order' => SORT_DESC ) , false ) ; if ( $ row && isset ( $ row [ 'gtf_id_order' ] ) ) { $ newOrder = $ row [ 'gtf_id_order' ] + 10 ; $ model -> set ( 'gtf_id_order' , 'default' , $ newOrder ) ; } } } else { $ model -> applyDetailSettings ( ) ; } } else { $ model -> applyBrowseSettings ( ) ; } $ this -> _maintenanceModels [ $ action ] = $ model ; return $ model ; }
Returns a model that can be used to retrieve or save the field definitions for the track editor .
57,988
public function hasAppointmentFields ( ) { if ( null === $ this -> _hasAppointmentFields ) { $ this -> _hasAppointmentFields = false ; foreach ( $ this -> _trackFields as $ field ) { if ( self :: TYPE_APPOINTMENT == $ field [ 'gtf_field_type' ] ) { $ this -> _hasAppointmentFields = true ; break ; } } } return $ this -> _hasAppointmentFields ; }
True when this track contains appointment fields
57,989
public function isAppointment ( $ fieldName ) { return isset ( $ this -> _trackFields [ $ fieldName ] ) && ( self :: TYPE_APPOINTMENT == $ this -> _trackFields [ $ fieldName ] [ 'gtf_field_type' ] ) ; }
Is the field an appointment type
57,990
public function processBeforeSave ( array $ fieldData , array $ trackData ) { $ this -> changed = false ; if ( ! $ this -> exists ) { return null ; } foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field instanceof FieldInterface ) { $ field -> calculationStart ( $ trackData ) ; } } $ output = array ( ) ; foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field instanceof FieldInterface ) { $ inVal = isset ( $ fieldData [ $ key ] ) ? $ fieldData [ $ key ] : null ; $ outVal = $ field -> calculateFieldValue ( $ inVal , $ fieldData , $ trackData ) ; if ( is_array ( $ outVal ) || is_array ( $ inVal ) ) { if ( is_array ( $ outVal ) && is_array ( $ inVal ) ) { $ changedNow = ( $ outVal != $ inVal ) ; } else { $ changedNow = true ; } } else { $ changedNow = ( ( string ) $ inVal !== ( string ) $ outVal ) ; } $ this -> changed = $ this -> changed || $ changedNow ; $ fieldData [ $ key ] = $ outVal ; $ output [ $ key ] = $ outVal ; } } return $ output ; }
Processes the values and and changes them as required
57,991
public static function splitKey ( $ key ) { if ( strpos ( $ key , self :: FIELD_KEY_SEPARATOR ) === false ) { return null ; } list ( $ sub , $ fieldId ) = explode ( self :: FIELD_KEY_SEPARATOR , $ key , 2 ) ; return array ( 'sub' => $ sub , 'gtf_id_field' => $ fieldId ) ; }
Split an external field key in component parts
57,992
protected function onFakeSubmit ( ) { if ( isset ( $ this -> formData [ 'create_account' ] ) && $ this -> formData [ 'create_account' ] ) { $ mail = $ this -> loader -> getMailLoader ( ) -> getMailer ( 'staffPassword' , $ this -> user -> getUserId ( ) ) ; if ( $ mail -> setCreateAccountTemplate ( ) ) { $ mail -> send ( ) ; $ this -> addMessage ( $ this -> _ ( 'Create account mail sent' ) ) ; $ this -> setAfterSaveRoute ( ) ; } else { $ this -> addMessage ( $ this -> _ ( 'No default Create Account mail template set in organization or project' ) ) ; } return ; } if ( isset ( $ this -> formData [ 'reset_password' ] ) && $ this -> formData [ 'reset_password' ] ) { $ mail = $ this -> loader -> getMailLoader ( ) -> getMailer ( 'staffPassword' , $ this -> user -> getUserId ( ) ) ; if ( $ mail -> setResetPasswordTemplate ( ) ) { $ mail -> send ( ) ; $ this -> addMessage ( $ this -> _ ( 'Reset password mail sent' ) ) ; $ this -> setAfterSaveRoute ( ) ; } else { $ this -> addMessage ( $ this -> _ ( 'No default Reset Password mail template set in organization or project' ) ) ; } } }
Hook that allows actions when the form is submitted but it was not the submit button that was checked
57,993
public function render ( $ text ) { $ text = $ this -> config -> onStart ( $ text ) ; $ linesIterator = new \ ArrayIterator ( preg_split ( "/\015\012|\015|\012/" , $ text ) ) ; $ this -> documentGenerator -> clear ( ) ; $ this -> errors = array ( ) ; while ( $ linesIterator -> valid ( ) ) { $ line = $ linesIterator -> current ( ) ; if ( $ line != '' ) { $ blockGen = $ this -> parseBlock ( $ linesIterator , $ line , null ) ; if ( is_object ( $ blockGen ) ) { $ this -> documentGenerator -> addBlock ( $ blockGen ) ; continue ; } } if ( trim ( $ line ) == '' ) { $ blockGenerator = new Generator \ SingleLineBlock ( $ this -> documentGenerator -> getConfig ( ) ) ; } else { $ inline = $ this -> inlineParser -> parse ( $ line ) ; $ blockGenerator = $ this -> documentGenerator -> getDefaultBlock ( $ inline ) ; if ( ! $ blockGenerator ) { $ blockGenerator = new Generator \ SingleLineBlock ( $ this -> documentGenerator -> getConfig ( ) ) ; $ blockGenerator -> setLineAsString ( $ inline ) ; } } $ this -> documentGenerator -> addBlock ( $ blockGenerator ) ; $ this -> nextLine ( $ linesIterator ) ; } $ result = $ this -> documentGenerator -> generate ( ) ; if ( $ this -> documentGenerator -> getConfig ( ) -> generateHeaderFooter ) { $ result = $ this -> documentGenerator -> generateHeader ( ) . $ result . $ this -> documentGenerator -> generateFooter ( ) ; } return $ this -> config -> onParse ( $ result ) ; }
Main method to call to convert a wiki text into an other format according to the rules given to the constructor .
57,994
protected function _getIncludedFiles ( ) { if ( null !== $ this -> _includedFiles ) { return $ this -> _includedFiles ; } $ this -> _includedFiles = get_included_files ( ) ; sort ( $ this -> _includedFiles ) ; return $ this -> _includedFiles ; }
Gets included files
57,995
protected function beforeSave ( ) { if ( isset ( $ this -> formData [ 'grl_parents' ] ) && ( ! is_array ( $ this -> formData [ 'grl_parents' ] ) ) ) { $ this -> formData [ 'grl_parents' ] = explode ( ',' , $ this -> formData [ 'grl_parents' ] ) ; } if ( isset ( $ this -> formData [ 'grl_parents' ] ) && is_array ( $ this -> formData [ 'grl_parents' ] ) ) { $ this -> formData [ 'grl_parents' ] = implode ( ',' , \ Gems_Roles :: getInstance ( ) -> translateToRoleIds ( $ this -> formData [ 'grl_parents' ] ) ) ; } if ( isset ( $ this -> formData [ 'grl_name' ] ) && $ this -> formData [ 'grl_name' ] == 'nologin' ) { $ this -> formData [ 'grl_privileges' ] [ ] = 'pr.nologin' ; } elseif ( isset ( $ this -> formData [ 'grl_name' ] ) && $ this -> formData [ 'grl_name' ] !== 'nologin' ) { $ this -> formData [ 'grl_privileges' ] [ ] = 'pr.islogin' ; } if ( isset ( $ this -> formData [ 'grl_privileges' ] ) ) { $ this -> formData [ 'grl_privileges' ] = implode ( ',' , $ this -> formData [ 'grl_privileges' ] ) ; } }
Perform some actions to the data before it is saved to the database
57,996
public function getSqlAppointmentsWhere ( ) { $ where = $ this -> getSqlEpisodeWhere ( ) ; if ( ( $ where == parent :: NO_MATCH_SQL ) || ( $ where == parent :: MATCH_ALL_SQL ) ) { return $ where ; } return sprintf ( "gap_id_episode IN (SELECT gec_episode_of_care_id FROM gems__episodes_of_care WHERE %s)" , $ where ) ; }
Generate a where statement to filter an appointment model
57,997
public function isTwoFactorRequired ( $ ipAddress , $ hasKey ) { if ( $ hasKey ) { switch ( $ this -> _get ( 'ggp_2factor_set' ) ) { case self :: TWO_FACTOR_SET_REQUIRED : return true ; case self :: TWO_FACTOR_SET_OUTSIDE_ONLY : return ! $ this -> util -> isAllowedIP ( $ ipAddress , $ this -> _get ( 'ggp_no_2factor_ip_ranges' ) ) ; } } else { switch ( $ this -> _get ( 'ggp_2factor_not_set' ) ) { case self :: NO_TWO_FACTOR_INSIDE_ONLY : return ! $ this -> util -> isAllowedIP ( $ ipAddress , $ this -> _get ( 'ggp_no_2factor_ip_ranges' ) ) ; } } return false ; }
Should a user be authorized using two factor authentication?
57,998
protected function _getConditionClass ( $ conditionType ) { if ( isset ( $ this -> _conditionClasses [ $ conditionType ] ) ) { return $ this -> _conditionClasses [ $ conditionType ] ; } else { throw new Gems_Exception_Coding ( "No condition class exists for condition type '$conditionType'." ) ; } }
Lookup condition class for an event type . This class or interface should at the very least implement the ConditionInterface .
57,999
protected function _listConditions ( $ conditionType ) { $ classType = $ this -> _getConditionClass ( $ conditionType ) ; $ paths = $ this -> _getConditionDirs ( $ conditionType ) ; return $ this -> util -> getTranslated ( ) -> getEmptyDropdownArray ( ) + $ this -> listClasses ( $ classType , $ paths ) ; }
Returns a list of selectable conditions with an empty element as the first option .