idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
58,100
protected function _initView ( ) { $ this -> bootstrap ( 'project' ) ; $ view = new \ Zend_View ( ) ; $ view -> addHelperPath ( 'MUtil/View/Helper' , 'MUtil_View_Helper' ) ; $ view -> addHelperPath ( 'MUtil/Less/View/Helper' , 'MUtil_Less_View_Helper' ) ; $ view -> addHelperPath ( 'Gems/View/Helper' , 'Gems_View_Helper' ) ; $ view -> addScriptPath ( GEMS_LIBRARY_DIR . '/views/scripts' ) ; $ view -> headTitle ( $ this -> project -> getName ( ) ) ; $ view -> setEncoding ( 'UTF-8' ) ; $ metas = $ this -> project -> getMetaHeaders ( ) ; $ headMeta = $ view -> headMeta ( ) ; foreach ( $ metas as $ httpEquiv => $ content ) { $ headMeta -> appendHttpEquiv ( $ httpEquiv , $ content ) ; } if ( $ this -> useHtml5 ) { $ view -> doctype ( \ Zend_View_Helper_Doctype :: HTML5 ) ; } else { $ view -> doctype ( \ Zend_View_Helper_Doctype :: XHTML1_STRICT ) ; } $ viewRenderer = \ Zend_Controller_Action_HelperBroker :: getStaticHelper ( 'ViewRenderer' ) ; $ viewRenderer -> setView ( $ view ) ; return $ view ; }
Initialize the view component and sets some project specific values .
58,101
protected function _initCurrentUser ( ) { $ this -> bootstrap ( array ( 'acl' , 'basepath' , 'cache' , 'db' , 'loader' , 'project' , 'session' , 'translate' , 'util' ) ) ; $ container = $ this -> getContainer ( ) ; $ user = $ this -> loader -> getCurrentUser ( ) ; $ container -> currentUser = $ user ; return $ user ; }
Initialize the currentUser component .
58,102
protected function _initZFDebug ( ) { if ( ( APPLICATION_ENV === 'production' ) || ( APPLICATION_ENV === 'acceptance' ) || Zend_Session :: $ _unitTestEnabled ) { return ; } $ debug = $ this -> getOption ( 'zfdebug' ) ; if ( ! isset ( $ debug [ 'activate' ] ) || ( '1' !== $ debug [ 'activate' ] ) ) { return ; } $ this -> bootstrap ( 'db' ) ; $ db = $ this -> getPluginResource ( 'db' ) ; $ this -> bootstrap ( 'cache' ) ; $ cache = $ this -> cache ; $ options = array ( 'plugins' => array ( 'Variables' , 'Database' => array ( 'adapter' => $ db -> getDbAdapter ( ) ) , 'File' => array ( 'basePath' => GEMS_ROOT_DIR ) , 'Cache' => array ( 'backend' => $ cache -> getBackend ( ) ) , 'Exception' ) ) ; $ debugPlugin = new \ ZFDebug_Controller_Plugin_Debug ( $ options ) ; $ this -> bootstrap ( 'frontController' ) ; $ frontController = $ this -> getResource ( 'frontController' ) ; $ frontController -> registerPlugin ( $ debugPlugin ) ; }
Add ZFDebug info to the page output .
58,103
protected function _layoutLogin ( array $ args = null ) { if ( $ this -> currentUser && $ this -> menu ) { $ div = \ MUtil_Html :: create ( 'div' , array ( 'id' => 'login' ) , $ args ) ; $ p = $ div -> p ( ) ; if ( $ this -> currentUser -> isActive ( ) ) { $ p -> append ( sprintf ( $ this -> _ ( 'You are logged in as %s' ) , $ this -> currentUser -> getFullName ( ) ) ) ; $ item = $ this -> menu -> findController ( 'index' , 'logoff' ) ; $ p -> a ( $ item -> toHRefAttribute ( ) , $ this -> _ ( 'Logoff' ) , array ( 'class' => 'logout' ) ) ; $ item -> set ( 'visible' , false ) ; } else { $ item = $ this -> menu -> findController ( 'index' , 'login' ) ; $ p -> a ( $ item -> toHRefAttribute ( ) , $ this -> _ ( 'You are not logged in' ) , array ( 'class' => 'logout' ) ) ; } return $ div ; } }
Display either a link to the login screen or displays the name of the current user and a logoff link .
58,104
protected function createProjectClass ( $ className ) { $ arguments = func_get_args ( ) ; array_shift ( $ arguments ) ; return $ this -> _projectLoader -> createClass ( $ className , $ arguments ) ; }
Creates an object of the specified className seareching the loader dirs path
58,105
public function hasPrivilege ( $ privilege , $ role = null ) { if ( is_null ( $ role ) ) $ role = $ this -> session -> user_role ; return ( ! $ this -> acl ) || $ this -> acl -> isAllowed ( $ role , null , $ privilege ) ; }
Returns true if the given role or role of the current user has the given privilege
58,106
protected function includeFile ( $ fileName ) { $ extension = pathinfo ( $ fileName , PATHINFO_EXTENSION ) ; if ( ! $ extension ) { $ extension = $ this -> findExtension ( $ fileName , array ( 'inc' , 'ini' , 'php' , 'xml' ) ) ; $ fileName .= '.' . $ extension ; } if ( file_exists ( $ fileName ) ) { switch ( $ extension ) { case 'ini' : $ config = new \ Zend_Config_Ini ( $ fileName , APPLICATION_ENV ) ; break ; case 'xml' : $ config = new \ Zend_Config_Xml ( $ fileName , APPLICATION_ENV ) ; break ; case 'php' : case 'inc' : unset ( $ extension ) ; return include ( $ fileName ) ; break ; default : throw new \ Zend_Application_Exception ( 'Invalid configuration file provided; unknown config type ' . $ extension ) ; } return $ config -> toArray ( ) ; } return false ; }
Searches and loads ini xml php or inc file
58,107
public function isAllowedHost ( $ fullHost ) { $ host = \ MUtil_String :: stripToHost ( $ fullHost ) ; $ request = $ this -> request ; if ( $ request instanceof \ Zend_Controller_Request_Http ) { if ( $ host == \ MUtil_String :: stripToHost ( $ request -> getServer ( 'HTTP_HOST' ) ) ) { return true ; } } if ( isset ( $ this -> project ) ) { foreach ( $ this -> project -> getAllowedHosts ( ) as $ allowedHost ) { if ( $ host == \ MUtil_String :: stripToHost ( $ allowedHost ) ) { return true ; } } } $ loader = $ this -> getLoader ( ) ; foreach ( $ loader -> getUserLoader ( ) -> getOrganizationUrls ( ) as $ url => $ orgId ) { if ( $ host == \ MUtil_String :: stripToHost ( $ url ) ) { return true ; } } return false ; }
Is the host name one allowed by the system
58,108
public function getRandomPassword ( ) { $ salt = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ0123456789" ; $ pass = "" ; srand ( ( double ) microtime ( ) * 1000000 ) ; $ i = 0 ; while ( $ i <= 7 ) { $ num = rand ( ) % strlen ( $ salt ) ; $ tmp = substr ( $ salt , $ num , 1 ) ; $ pass = $ pass . $ tmp ; $ i ++ ; } return $ pass ; }
Generate random password
58,109
public function prepareController ( ) { if ( $ this instanceof \ Gems_Project_Layout_MultiLayoutInterface ) { $ this -> layoutSwitch ( ) ; } if ( $ this -> useBootstrap ) { $ bootstrap = \ MUtil_Bootstrap :: bootstrap ( array ( 'fontawesome' => true ) ) ; \ MUtil_Bootstrap :: enableView ( $ this -> view ) ; } if ( \ MUtil_Console :: isConsole ( ) ) { $ layout = $ this -> view -> layout ( ) ; $ layout -> setLayoutPath ( GEMS_LIBRARY_DIR . "/layouts/scripts" ) ; $ layout -> setLayout ( 'cli' ) ; } }
Hook function called during controllerInit
58,110
public function setError ( $ message , $ code = 200 , $ info = null , $ isSecurity = false ) { if ( $ isSecurity ) { $ e = new \ Gems_Exception_Security ( $ message , $ code , null , $ info ) ; } else { $ e = new \ Gems_Exception ( $ message , $ code , null , $ info ) ; } $ this -> setException ( $ e ) ; }
Create an exception for the error depending on processing position we either set the response exception or throw the exception if the response is
58,111
public function setException ( exception $ e ) { if ( isset ( $ this -> response ) ) { $ this -> response -> setException ( $ e ) ; } else { throw $ e ; } }
Handle the exception depending on processing position we either set the response exception or throw the exception if the response is
58,112
protected function _getOrganizationsList ( ) { $ html = new \ MUtil_Html_Sequence ( ) ; $ sql = ' SELECT * FROM gems__organizations WHERE gor_active=1 AND gor_url IS NOT NULL AND gor_task IS NOT NULL ORDER BY gor_name' ; $ organizations = $ this -> db -> fetchAll ( $ sql ) ; $ orgCount = count ( $ organizations ) ; switch ( $ orgCount ) { case 0 : return $ html -> pInfo ( sprintf ( $ this -> _ ( '%s is still under development.' ) , $ this -> project -> getName ( ) ) ) ; case 1 : $ organization = reset ( $ organizations ) ; $ p = $ html -> pInfo ( sprintf ( $ this -> _ ( '%s is run by: ' ) , $ this -> project -> getName ( ) ) ) ; $ p -> a ( $ organization [ 'gor_url' ] , $ organization [ 'gor_name' ] ) ; $ p -> append ( '.' ) ; $ html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'Please contact the %s if you have any questions regarding %s.' ) , $ organization [ 'gor_name' ] , $ this -> project -> getName ( ) ) ; return $ html ; default : $ p = $ html -> pInfo ( sprintf ( $ this -> _ ( '%s is a collaboration of these organizations:' ) , $ this -> project -> getName ( ) ) ) ; $ data = \ MUtil_Lazy :: repeat ( $ organizations ) ; $ ul = $ p -> ul ( $ data , array ( 'class' => 'indent' ) ) ; $ li = $ ul -> li ( ) ; $ li -> a ( $ data -> gor_url -> call ( $ this , '_' ) , $ data -> gor_name , array ( 'rel' => 'external' ) ) ; $ li -> append ( ' (' ) ; $ li -> append ( $ data -> gor_task -> call ( array ( $ this , '_' ) ) ) ; $ li -> append ( ')' ) ; $ html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'You can contact any of these organizations if you have questions regarding %s.' ) , $ this -> project -> getName ( ) ) ; return $ html ; } }
A list of all participating organizations .
58,113
public function aboutAction ( ) { $ this -> initHtml ( ) ; $ this -> html -> h3 ( ) -> sprintf ( $ this -> _ ( 'About %s' ) , $ this -> project -> getName ( ) ) ; $ this -> html -> pInfo ( \ MUtil_Html_Raw :: raw ( $ this -> project -> getLongDescription ( $ this -> locale -> getLanguage ( ) ) ) ) ; $ this -> html -> append ( $ this -> _getOrganizationsList ( ) ) ; }
Shows an about page
58,114
public function gemsAction ( ) { $ this -> initHtml ( ) ; $ this -> html -> h3 ( ) -> sprintf ( $ this -> _ ( 'About %s' ) , $ this -> _ ( 'GemsTracker' ) ) ; $ this -> html -> pInfo ( $ this -> _ ( 'GemsTracker (GEneric Medical Survey Tracker) is a software package for (complex) distribution of questionnaires and forms during clinical research and for quality registration in healthcare.' ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( '%s is a project built using GemsTracker as a foundation.' ) , $ this -> project -> getName ( ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'GemsTracker is an open source project hosted on %s.' ) ) -> a ( 'https://github.com/GemsTracker/gemstracker-library' , 'GitHub' , array ( 'rel' => 'external' , 'target' => 'sourceforge' ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'More information about GemsTracker is available on the %s website.' ) ) -> a ( 'http://gemstracker.org/' , 'GemsTracker.org' , array ( 'rel' => 'external' , 'target' => 'gemstracker' ) ) ; }
Show screen telling people about gems
58,115
public function indexAction ( ) { $ this -> initHtml ( ) ; $ this -> html -> h3 ( $ this -> _ ( 'Contact' ) ) ; $ this -> html -> h4 ( sprintf ( $ this -> _ ( 'The %s project' ) , $ this -> project -> getName ( ) ) ) ; $ this -> html -> append ( $ this -> _getOrganizationsList ( ) ) ; $ this -> html -> h4 ( $ this -> _ ( 'Information on this application' ) ) ; $ this -> html -> pInfo ( $ this -> _ ( 'Links concerning this web application:' ) ) ; $ menuItem = $ this -> menu -> getCurrent ( ) ; $ ul = $ menuItem -> toUl ( $ this -> getRequest ( ) ) ; $ ul -> class = 'indent' ; $ this -> html [ ] = $ ul ; }
General contact page
58,116
public function supportAction ( ) { $ this -> initHtml ( ) ; $ this -> html -> h3 ( $ this -> _ ( 'Support' ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'There is more than one way to get support for %s.' ) , $ this -> project -> getName ( ) ) ; if ( $ url = $ this -> project -> getDocumentationUrl ( ) ) { $ this -> html -> h4 ( $ this -> _ ( 'Documentation' ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'All available documentation is gathered at: %s' ) ) -> a ( $ url , array ( 'rel' => 'external' , 'target' => 'documentation' ) ) ; } if ( $ url = $ this -> project -> getManualUrl ( ) ) { $ this -> html -> h4 ( $ this -> _ ( 'Manual' ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'The manual is available here: %s' ) ) -> a ( $ url , array ( 'rel' => 'external' , 'target' => 'manual' ) ) ; } if ( $ url = $ this -> project -> getForumUrl ( ) ) { $ this -> html -> h4 ( $ this -> _ ( 'The forum' ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'You will find questions asked by other users and ask new questions at our forum site: %s' ) ) -> a ( $ url , array ( 'rel' => 'external' , 'target' => 'forum' ) ) ; } if ( $ url = $ this -> project -> getSupportUrl ( ) ) { $ this -> html -> h4 ( $ this -> _ ( 'Support site' ) ) ; $ this -> html -> pInfo ( ) -> sprintf ( $ this -> _ ( 'Check our support site at %s.' ) ) -> a ( $ url , array ( 'rel' => 'external' , 'target' => 'support' ) ) ; } $ this -> html -> h4 ( $ this -> _ ( 'Or contact' ) ) ; $ this -> html -> append ( $ this -> _getOrganizationsList ( ) ) ; }
Shows a support page
58,117
public function render ( $ content ) { $ form = $ this -> getElement ( ) ; $ view = $ form -> getView ( ) ; if ( $ form -> isAutoSubmit ( ) ) { $ form -> addScript ( $ this -> localScriptFiles ) ; $ jquery = $ view -> jQuery ( ) ; $ jquery -> enable ( ) ; $ params = $ form -> getAutoSubmit ( ) ; if ( ( $ view instanceof \ Zend_View_Abstract ) && ( $ params [ 'submitUrl' ] instanceof \ MUtil_Html_HtmlInterface ) ) { $ params [ 'submitUrl' ] = $ params [ 'submitUrl' ] -> render ( $ view ) ; } $ js = sprintf ( '%s("#%s").%s(%s);' , \ ZendX_JQuery_View_Helper_JQuery :: getJQueryHandler ( ) , $ form -> getId ( ) , $ this -> localScriptName , \ ZendX_JQuery :: encodeJson ( $ params ) ) ; $ jquery -> addOnLoad ( $ js ) ; } $ scripts = $ form -> getScripts ( ) ; $ css = $ form -> getCss ( ) ; if ( ! is_null ( $ scripts ) && is_array ( $ scripts ) ) { $ baseUrl = $ view -> serverUrl ( ) . $ view -> baseUrl ( ) ; $ headscript = $ view -> headScript ( ) ; foreach ( $ scripts as $ script ) { $ headscript -> appendFile ( $ baseUrl . $ script ) ; } } if ( ! is_null ( $ css ) && is_array ( $ css ) ) { $ baseUrl = $ view -> serverUrl ( ) . $ view -> baseUrl ( ) ; $ headLink = $ view -> headLink ( ) ; foreach ( $ css as $ cssFile => $ media ) { $ headLink -> appendStylesheet ( $ baseUrl . $ cssFile , $ media ) ; } } $ content = parent :: render ( $ content ) ; return $ content ; }
Render a form
58,118
public function checkHasRespondents ( $ userId , $ check = false ) { $ sql = "CASE WHEN EXISTS (SELECT * FROM gems__respondent2org WHERE gr2o_id_organization = gor_id_organization) THEN 1 ELSE 0 END" ; $ values [ 'gor_has_respondents' ] = new \ Zend_Db_Expr ( $ sql ) ; $ values [ 'gor_changed' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; $ values [ 'gor_changed_by' ] = $ userId ; $ where = $ this -> db -> quoteInto ( 'gor_id_organization = ?' , $ this -> _id ) ; if ( $ this -> db -> update ( 'gems__organizations' , $ values , $ where ) ) { $ this -> loadData ( $ this -> _id ) ; } return $ this ; }
Check whether the organization still has at least one respondent attached to it .
58,119
public function getAllowedUserClasses ( ) { $ output = $ this -> _allowedProjectUserClasses ; if ( \ Gems_User_UserLoader :: USER_RADIUS !== $ this -> _get ( 'gor_user_class' ) ) { unset ( $ output [ \ Gems_User_UserLoader :: USER_RADIUS ] ) ; } return $ output ; }
Get the available user class for new users in this organization
58,120
public function setAsCurrentOrganization ( ) { $ organizationId = $ this -> getId ( ) ; if ( $ organizationId && ( ! \ Gems_Cookies :: setOrganization ( $ organizationId , $ this -> basepath -> getBasePath ( ) ) ) ) { throw new \ Exception ( 'Cookies must be enabled for this site.' ) ; } $ escort = \ GemsEscort :: getInstance ( ) ; if ( $ escort instanceof \ Gems_Project_Layout_MultiLayoutInterface ) { $ escort -> layoutSwitch ( $ this -> getStyle ( ) ) ; } return $ this ; }
Set this organization as the one currently active
58,121
public function setHasRespondents ( $ userId ) { if ( ! $ this -> _get ( 'gor_has_respondents' ) ) { $ values [ 'gor_has_respondents' ] = 1 ; $ values [ 'gor_changed' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; $ values [ 'gor_changed_by' ] = $ userId ; $ where = $ this -> db -> quoteInto ( 'gor_id_organization = ?' , $ this -> _id ) ; $ this -> db -> update ( 'gems__organizations' , $ values , $ where ) ; $ this -> _set ( 'gor_has_respondents' , 1 ) ; } return $ this ; }
Tell the organization there is at least one respondent attached to it .
58,122
private function _checkUserId ( $ userId = null ) { if ( empty ( $ userId ) && $ this -> currentUser instanceof \ Gems_User_User ) { $ userId = $ this -> currentUser -> getUserId ( ) ; if ( 0 === $ userId ) { $ userId = null ; } } return $ userId ; }
Replaces a null or empty userId with that of the current user
58,123
public function filterChangesOnly ( array $ oldValues , array & $ newValues ) { if ( $ newValues && $ oldValues ) { foreach ( $ newValues as $ name => $ value ) { if ( array_key_exists ( $ name , $ oldValues ) ) { if ( $ value instanceof \ Zend_Date ) { $ value = $ value -> toString ( \ Gems_Tracker :: DB_DATETIME_FORMAT ) ; } if ( $ oldValues [ $ name ] instanceof \ Zend_Date ) { $ oldValues [ $ name ] = $ oldValues [ $ name ] -> toString ( \ Gems_Tracker :: DB_DATETIME_FORMAT ) ; } if ( ( $ value === $ oldValues [ $ name ] ) || ( $ value === $ oldValues [ $ name ] . ' 00:00:00' ) ) { unset ( $ newValues [ $ name ] ) ; } } } } return $ newValues ; }
Utility function for detecting unchanged values .
58,124
public function getAllCodeFields ( ) { static $ fields = false ; if ( $ fields === false ) { $ fields = array ( ) ; $ model = $ this -> createTrackClass ( 'Model\\FieldMaintenanceModel' ) ; $ rows = $ model -> load ( array ( 'gtf_field_code IS NOT NULL' ) , array ( 'gtf_field_code' => SORT_ASC ) ) ; if ( $ rows ) { foreach ( $ rows as $ row ) { $ key = FieldsDefinition :: makeKey ( $ row [ 'sub' ] , $ row [ 'gtf_id_field' ] ) ; $ fields [ $ key ] = $ row [ 'gtf_field_code' ] ; } } } return $ fields ; }
Returns an array of all field id s for all tracks that have a code id
58,125
public function getRespondentTracks ( $ respondentId , $ organizationId , $ order = array ( 'gr2t_start_date' ) ) { $ select = $ this -> db -> select ( ) -> from ( 'gems__respondent2track' ) -> joinInner ( 'gems__tracks' , 'gr2t_id_track = gtr_id_track' ) -> joinInner ( 'gems__reception_codes' , 'gr2t_reception_code = grc_id_reception_code' ) -> where ( 'gr2t_id_user = ? AND gr2t_id_organization = ?' ) ; if ( ! is_null ( $ order ) ) { $ select -> order ( $ order ) ; } $ rows = $ this -> db -> fetchAll ( $ select , array ( $ respondentId , $ organizationId ) ) ; $ tracks = array ( ) ; foreach ( $ rows as $ row ) { $ tracks [ $ row [ 'gr2t_id_respondent_track' ] ] = $ this -> getRespondentTrack ( $ row ) ; } return $ tracks ; }
Get all tracks for a respondent
58,126
public function getSource ( $ sourceData ) { if ( is_array ( $ sourceData ) ) { $ sourceId = $ sourceData [ 'gso_id_source' ] ; } else { $ sourceId = $ sourceData ; $ sourceData = false ; } if ( ! isset ( $ this -> _sources [ $ sourceId ] ) ) { if ( ! $ sourceData ) { $ sourceData = $ this -> db -> fetchRow ( "SELECT * FROM gems__sources WHERE gso_id_source = ?" , $ sourceId ) ; } if ( ! isset ( $ sourceData [ 'gso_ls_class' ] ) ) { throw new \ Gems_Exception_Coding ( 'Missing source class for source ID: ' . $ sourceId ) ; } $ this -> _sources [ $ sourceId ] = $ this -> _loadClass ( 'source_' . $ sourceData [ 'gso_ls_class' ] , true , array ( $ sourceData , $ this -> db ) ) ; } return $ this -> _sources [ $ sourceId ] ; }
Retrieve a SourceInterface with a given id
58,127
public function getTokenLibrary ( ) { if ( ! $ this -> _tokenLibrary ) { $ this -> _tokenLibrary = $ this -> _loadClass ( 'Token_TokenLibrary' , true ) ; } return $ this -> _tokenLibrary ; }
Use this function only within \ Gems_Tracker!!
58,128
public function getTokenModel ( $ modelClass = 'StandardTokenModel' ) { if ( ! isset ( $ this -> _tokenModels [ $ modelClass ] ) ) { $ this -> _tokenModels [ $ modelClass ] = $ this -> _loadClass ( 'Model_' . $ modelClass , true ) ; $ this -> _tokenModels [ $ modelClass ] -> applyFormatting ( ) ; } return $ this -> _tokenModels [ $ modelClass ] ; }
Returns a token model of the specified class with full display information
58,129
public function getTokenSelect ( $ fields = '*' ) { return $ this -> _loadClass ( 'Token_TokenSelect' , true , array ( $ this -> db , $ fields , $ this -> loader -> getUtil ( ) ) ) ; }
Create a select statement on the token table
58,130
public function getTrackDisplayGroups ( ) { return array ( 'tracks' => $ this -> translate -> _ ( 'Tracks' ) , 'respondents' => $ this -> translate -> _ ( 'Respondent' ) , 'staff' => $ this -> translate -> _ ( 'Staff' ) , ) ; }
Get the allowed display groups for tracks in this project .
58,131
public function getTrackEngineClasses ( ) { static $ dummyClasses ; if ( ! $ dummyClasses ) { $ dummyTrackData [ 'gtr_id_track' ] = 0 ; foreach ( $ this -> getTrackEngineClassNames ( ) as $ className ) { $ dummyClasses [ $ className ] = $ this -> _loadClass ( 'Engine_' . $ className , true , array ( $ dummyTrackData ) ) ; } } return $ dummyClasses ; }
Returns dummy objects for all registered track engines class names
58,132
public function getTrackEngineList ( $ extended = false , $ userCreatableOnly = false ) { $ results = array ( ) ; $ dummyTrackData [ 'gtr_id_track' ] = 0 ; foreach ( $ this -> getTrackEngineClasses ( ) as $ className => $ cls ) { if ( ( ! $ userCreatableOnly ) || $ cls -> isUserCreatable ( ) ) { if ( $ extended ) { $ results [ $ className ] = \ MUtil_Html :: raw ( sprintf ( '<strong>%s</strong> %s' , $ cls -> getName ( ) , $ cls -> getDescription ( ) ) ) ; } else { $ results [ $ className ] = $ cls -> getName ( ) ; } } } return $ results ; }
Returns all registered track engines classes for use in drop down lists .
58,133
public function loadCompletedTokensBatch ( \ Gems_Task_TaskRunnerBatch $ batch , $ respondentId = null , $ userId = null , $ orgId = null , $ quickCheck = false ) { $ userId = $ this -> _checkUserId ( $ userId ) ; $ tokenSelect = $ this -> getTokenSelect ( array ( 'gto_id_token' ) ) ; $ tokenSelect -> onlyActive ( $ quickCheck ) -> forRespondent ( $ respondentId ) -> andSurveys ( array ( 'gsu_surveyor_id' ) ) -> forWhere ( 'gsu_surveyor_active = 1' ) -> order ( 'gsu_surveyor_id' ) ; if ( null !== $ orgId ) { $ tokenSelect -> forWhere ( 'gto_id_organization = ?' , $ orgId ) ; } $ statement = $ tokenSelect -> getSelect ( ) -> query ( ) ; $ tokens = array ( ) ; $ tokencount = 0 ; $ activeId = 0 ; $ maxCount = 100 ; while ( $ tokenData = $ statement -> fetch ( ) ) { $ tokenId = $ tokenData [ 'gto_id_token' ] ; $ surveyorId = $ tokenData [ 'gsu_surveyor_id' ] ; if ( $ activeId <> $ surveyorId || count ( $ tokens ) > $ maxCount ) { if ( count ( $ tokens ) > 0 ) { $ batch -> addTask ( 'Tracker_BulkCheckTokenCompletion' , $ tokens , $ userId ) ; } $ activeId = $ surveyorId ; $ tokens = array ( ) ; } $ tokens [ ] = $ tokenId ; $ batch -> addToCounter ( 'tokens' ) ; } if ( count ( $ tokens ) > 0 ) { $ batch -> addTask ( 'Tracker_BulkCheckTokenCompletion' , $ tokens , $ userId ) ; } }
Checks the token table to see if there are any answered surveys to be processed and loads those tasks
58,134
public function recalcTrackFields ( $ batchId , $ cond = null ) { $ respTrackSelect = $ this -> db -> select ( ) ; $ respTrackSelect -> from ( 'gems__respondent2track' , array ( 'gr2t_id_respondent_track' ) ) ; $ respTrackSelect -> join ( 'gems__reception_codes' , 'gr2t_reception_code = grc_id_reception_code' , array ( ) ) ; $ respTrackSelect -> join ( 'gems__tracks' , 'gr2t_id_track = gtr_id_track' , array ( ) ) ; if ( $ cond ) { $ respTrackSelect -> where ( $ cond ) ; } $ respTrackSelect -> where ( 'gr2t_active = 1' ) ; $ respTrackSelect -> where ( 'grc_success = 1' ) ; $ respTrackSelect -> where ( 'gtr_active = 1' ) ; $ batch = $ this -> loader -> getTaskRunnerBatch ( $ batchId ) ; $ batch -> minimalStepDurationMs = 3000 ; if ( ! $ batch -> isLoaded ( ) ) { $ statement = $ respTrackSelect -> query ( ) ; while ( $ respTrackData = $ statement -> fetch ( ) ) { $ respTrackId = $ respTrackData [ 'gr2t_id_respondent_track' ] ; $ batch -> setTask ( 'Tracker_RecalculateFields' , 'trkfcalc-' . $ respTrackId , $ respTrackId ) ; $ batch -> addToCounter ( 'resptracks' ) ; } } return $ batch ; }
Recalculates the fields in tracks .
58,135
public function refreshTokenAttributes ( $ batch_id , $ cond = null ) { $ batch = $ this -> loader -> getTaskRunnerBatch ( $ batch_id ) ; if ( ! $ batch -> isLoaded ( ) ) { $ tokenSelect = $ this -> getTokenSelect ( array ( 'gto_id_token' ) ) ; $ tokenSelect -> andSurveys ( array ( ) ) -> forWhere ( 'gsu_surveyor_active = 1' ) -> forWhere ( 'gto_in_source = 1' ) ; if ( $ cond ) { $ tokenSelect -> andReceptionCodes ( array ( ) ) -> andRespondents ( array ( ) ) -> andRespondentOrganizations ( array ( ) ) -> andConsents ( array ( ) ) -> forWhere ( $ cond ) ; } foreach ( $ this -> db -> fetchCol ( $ tokenSelect -> getSelect ( ) ) as $ token ) { $ batch -> addTask ( 'Tracker_RefreshTokenAttributes' , $ token ) ; } } self :: $ verbose = true ; return $ batch ; }
Refreshes the tokens in the source
58,136
public function removeToken ( $ token ) { if ( $ token instanceof \ Gems_Tracker_Token ) { $ tokenId = $ token -> getTokenId ( ) ; } else { $ tokenId = $ token ; } unset ( $ this -> _tokens [ $ tokenId ] ) ; return $ this ; }
Remove token from cache for saving memory
58,137
protected function isValidToken ( $ value ) { $ value = $ this -> tracker -> filterToken ( $ value ) ; $ library = $ this -> tracker -> getTokenLibrary ( ) ; $ format = $ library -> getFormat ( ) ; $ reuse = $ library -> hasReuse ( ) ? $ library -> getReuse ( ) : - 1 ; if ( strlen ( $ value ) !== strlen ( $ format ) ) { $ this -> _messages = sprintf ( $ this -> translate -> _ ( 'Not a valid token. The format for valid tokens is: %s.' ) , $ format ) ; return false ; } $ token = $ this -> tracker -> getToken ( $ value ) ; if ( $ token && $ token -> exists && $ token -> getReceptionCode ( ) -> isSuccess ( ) ) { $ currentDate = new \ MUtil_Date ( ) ; if ( $ completionTime = $ token -> getCompletionTime ( ) ) { if ( $ reuse >= 0 ) { if ( $ currentDate -> diffDays ( $ completionTime ) <= $ reuse ) { return true ; } } $ this -> _messages = $ this -> translate -> _ ( 'This token is no longer valid.' ) ; return false ; } $ fromDate = $ token -> getValidFrom ( ) ; if ( ( null === $ fromDate ) || $ currentDate -> isEarlier ( $ fromDate ) ) { $ this -> _messages = $ this -> translate -> _ ( 'This token cannot (yet) be used.' ) ; return false ; } if ( $ untilDate = $ token -> getValidUntil ( ) ) { if ( $ currentDate -> isLater ( $ untilDate ) ) { $ this -> _messages = $ this -> translate -> _ ( 'This token is no longer valid.' ) ; return false ; } } return true ; } else { $ this -> _messages = $ this -> translate -> _ ( 'Unknown token.' ) ; return false ; } }
Seperate the incorrect tokens from the right tokens
58,138
public function formatDetailed ( $ value ) { if ( is_array ( $ value ) ) { $ group = $ this -> currentUser -> getGroup ( ) ; if ( $ group ) { $ value = $ group -> applyGroupToData ( $ value ) ; } } return parent :: formatDetailed ( $ value ) ; }
Displays the content
58,139
protected function getExportTypeElements ( array $ data ) { $ export = $ this -> loader -> getExport ( ) ; $ exportTypes = $ export -> getExportClasses ( ) ; if ( isset ( $ data [ 'type' ] ) ) { $ currentType = $ data [ 'type' ] ; } else { reset ( $ exportTypes ) ; $ currentType = key ( $ exportTypes ) ; } $ elements [ 'type_label' ] = $ this -> _ ( 'Export to' ) ; $ elements [ 'type' ] = $ this -> _createSelectElement ( 'type' , $ exportTypes ) ; $ elements [ 'type' ] -> setAttrib ( 'onchange' , 'this.form.submit();' ) ; $ exportClass = $ export -> getExport ( $ currentType ) ; $ exportName = $ exportClass -> getName ( ) ; $ exportFormElements = $ exportClass -> getFormElements ( $ this -> form , $ data ) ; if ( $ exportFormElements ) { $ elements [ 'firstCheck' ] = $ this -> form -> createElement ( 'hidden' , $ currentType ) ; foreach ( $ exportFormElements as $ key => $ formElement ) { $ elements [ 'type_br_' . $ key ] = \ MUtil_Html :: create ( 'br' ) ; $ elements [ 'type_el_' . $ key ] = $ formElement ; } } return $ elements ; }
Returns export field elements for auto search .
58,140
public function init ( ) { parent :: init ( ) ; $ action = $ this -> getRequest ( ) -> getActionName ( ) ; if ( $ action !== 'index' ) { $ view = Zend_Controller_Front :: getInstance ( ) -> getParam ( 'bootstrap' ) -> getResource ( 'view' ) ; $ this -> view -> getHelper ( 'headMeta' ) -> appendName ( 'robots' , 'noindex, nofollow' ) ; } }
Leave on top so we won t miss this
58,141
protected function _initToken ( ) { if ( $ this -> tracker ) { return $ this -> token && $ this -> token -> exists ; } $ this -> tracker = $ this -> loader -> getTracker ( ) ; $ this -> tokenId = $ this -> tracker -> filterToken ( $ this -> _getParam ( \ MUtil_Model :: REQUEST_ID ) ) ; $ validator = $ this -> tracker -> getTokenValidator ( ) ; if ( ! $ this -> tokenId || $ validator -> isValid ( $ this -> tokenId ) === false ) { return false ; } $ this -> token = $ this -> tracker -> getToken ( $ this -> tokenId ) ; if ( ! $ this -> token -> exists ) { return false ; } if ( ! ( $ this -> currentUser -> isActive ( ) || $ this -> token -> getSurvey ( ) -> isTakenByStaff ( ) ) ) { $ tokenLang = strtolower ( $ this -> token -> getRespondentLanguage ( ) ) ; if ( $ tokenLang != $ this -> locale -> getLanguage ( ) ) { $ this -> currentUser -> switchLocale ( $ tokenLang ) ; } $ currentOrg = $ this -> loader -> getOrganization ( ) ; $ tokenOrgId = $ this -> token -> getOrganizationId ( ) ; if ( $ tokenOrgId != $ currentOrg -> getId ( ) ) { $ this -> loader -> getOrganization ( $ tokenOrgId ) -> setAsCurrentOrganization ( ) ; } } return true ; }
Common handler utility to initialize tokens from parameters
58,142
public function forwardAction ( ) { if ( ! $ this -> _initToken ( ) ) { if ( $ this -> tokenId ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'The token %s does not exist (any more).' ) , strtoupper ( $ this -> tokenId ) ) ) ; } $ this -> _forward ( 'index' ) ; return ; } if ( $ this -> util -> getMaintenanceLock ( ) -> isLocked ( ) ) { $ this -> addSnippet ( $ this -> maintenanceModeSnippets , [ 'token' => $ this -> token ] ) ; return ; } $ this -> tracker -> processCompletedTokens ( $ this -> token -> getRespondentId ( ) , $ this -> token -> getChangedBy ( ) , $ this -> token -> getOrganizationId ( ) ) ; $ screen = $ this -> token -> getOrganization ( ) -> getTokenAskScreen ( ) ; if ( $ screen ) { $ params = $ screen -> getParameters ( $ this -> token ) ; $ snippets = $ screen -> getSnippets ( $ this -> token ) ; if ( false !== $ snippets ) { $ this -> forwardSnippets = $ snippets ; } } $ params [ 'token' ] = $ this -> token ; if ( $ this -> html -> snippet ( $ this -> forwardSnippets , $ params ) ) { return ; } if ( $ this -> getRequest ( ) -> getActionName ( ) == 'return' ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'Thank you for answering. At the moment we have no further surveys for you to take.' ) , strtoupper ( $ this -> tokenId ) ) ) ; } else { $ this -> addMessage ( sprintf ( $ this -> _ ( 'The survey for token %s has been answered and no further surveys are open.' ) , strtoupper ( $ this -> tokenId ) ) ) ; } $ this -> _reroute ( array ( 'controller' => 'ask' , 'action' => 'index' ) , true ) ; }
Show the user a screen with token information and a button to take at least one survey
58,143
public function indexAction ( ) { if ( $ this -> util -> getMaintenanceLock ( ) -> isLocked ( ) ) { $ this -> addSnippet ( $ this -> maintenanceModeSnippets ) ; return ; } $ this -> currentUser -> setSurveyReturn ( ) ; $ request = $ this -> getRequest ( ) ; $ tracker = $ this -> loader -> getTracker ( ) ; $ form = $ tracker -> getAskTokenForm ( array ( 'displayOrder' => array ( 'element' , 'description' , 'errors' ) , 'labelWidthFactor' => 0.8 ) ) ; if ( $ request -> isPost ( ) && $ form -> isValid ( $ request -> getParams ( ) ) ) { $ this -> _forward ( 'forward' ) ; return ; } $ form -> populate ( $ request -> getParams ( ) ) ; $ this -> displayTokenForm ( $ form ) ; }
Ask the user for a token
58,144
public function returnAction ( ) { if ( ! $ this -> _initToken ( ) ) { $ this -> _forward ( 'forward' ) ; return ; } if ( $ url = $ this -> token -> getReturnUrl ( ) ) { $ this -> tracker -> processCompletedTokens ( $ this -> token -> getRespondentId ( ) , $ this -> token -> getChangedBy ( ) , $ this -> token -> getOrganizationId ( ) ) ; header ( 'Location: ' . $ url ) ; exit ( ) ; } if ( ! $ this -> currentUser -> isActive ( ) ) { $ this -> _forward ( 'forward' ) ; return ; } $ this -> tracker -> processCompletedTokens ( $ this -> token -> getRespondentId ( ) , $ this -> currentUser -> getUserId ( ) ) ; $ parameters = $ this -> currentUser -> getSurveyReturn ( ) ; if ( ! $ parameters ) { $ request = $ this -> getRequest ( ) ; $ parameters [ $ request -> getControllerKey ( ) ] = 'respondent' ; $ parameters [ $ request -> getActionKey ( ) ] = 'show' ; $ parameters [ \ MUtil_Model :: REQUEST_ID ] = $ this -> token -> getPatientNumber ( ) ; } $ this -> _reroute ( $ parameters , true ) ; }
The action where survey sources should return to after survey completion
58,145
public function toSurveyAction ( ) { if ( ! $ this -> _initToken ( ) ) { $ this -> _forward ( 'index' ) ; return ; } $ language = $ this -> locale -> getLanguage ( ) ; try { $ url = $ this -> token -> getUrl ( $ language , $ this -> currentUser -> getUserId ( ) ? $ this -> currentUser -> getUserId ( ) : $ this -> token -> getRespondentId ( ) ) ; if ( $ this -> currentUser -> isLogoutOnSurvey ( ) ) { $ this -> currentUser -> unsetAsCurrentUser ( ) ; } header ( 'Location: ' . $ url ) ; exit ( ) ; } catch ( \ Gems_Tracker_Source_SurveyNotFoundException $ e ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'The survey for token %s is no longer active.' ) , strtoupper ( $ this -> tokenId ) ) ) ; $ this -> _forward ( 'index' ) ; } }
Go directly to url
58,146
protected function addEscortReport ( ) { $ this -> html -> h3 ( 'Project and escort class report' ) ; $ escortClass = get_class ( $ this -> escort ) ; $ foundNone = true ; $ projectName = $ this -> project -> getName ( ) ; $ oldInterfaces = array ( 'Gems_Project_Log_LogRespondentAccessInterface' , 'Gems_Project_Organization_MultiOrganizationInterface' , 'Gems_Project_Organization_SingleOrganizationInterface' , 'Gems_Project_Tracks_FixedTracksInterface' , 'Gems_Project_Tracks_StandAloneSurveysInterface' , 'Gems_Project_Tracks_TracksOnlyInterface' , ) ; foreach ( $ oldInterfaces as $ interface ) { if ( $ this -> escort instanceof $ interface ) { $ foundNone = false ; $ this -> html -> pInfo ( sprintf ( '%s implements the deprecated %s interface. Remove this interface.' , $ escortClass , $ interface ) ) ; } } $ snippetsDir = APPLICATION_PATH . '\snippets' ; if ( file_exists ( $ snippetsDir ) ) { $ foundNone = false ; $ this -> html -> pInfo ( sprintf ( '%s still uses the deprecated %s directory for snippets. This directory is deprecated and will be removed in 1.7.2.' , $ projectName , $ snippetsDir ) ) ; } if ( $ foundNone ) { $ this -> html -> pInfo ( sprintf ( '%s and %s are up to date.' , $ projectName , $ escortClass ) ) ; } }
A specific report on the escort class
58,147
protected function addFileReport ( \ SplFileInfo $ fileinfo ) { $ extension = strtolower ( pathinfo ( $ fileinfo , PATHINFO_EXTENSION ) ) ; if ( ( 'php' !== $ extension ) && ( 'phtml' !== $ extension ) ) { return false ; } $ content = file_get_contents ( $ fileinfo ) ; $ messages = array ( ) ; if ( preg_match ( '/Single.*Survey/' , $ fileinfo -> getFilename ( ) ) ) { $ messages [ ] = "This seems to be a file for (obsolete) SingleSurveys. This file can probably be removed." ; } $ this -> _checkCodingChanged ( $ fileinfo , $ content , $ messages ) ; if ( \ MUtil_String :: endsWith ( $ fileinfo -> getPath ( ) , 'controllers' ) ) { $ this -> _checkControllersChanged ( $ fileinfo , $ content , $ messages ) ; } else { $ this -> _checkSnippetsChanged ( $ fileinfo , $ content , $ messages ) ; } $ this -> _checkTablesChanged ( $ fileinfo , $ content , $ messages ) ; $ this -> _checkVariablesChanged ( $ fileinfo , $ content , $ messages ) ; $ this -> _checkDepreciations ( $ fileinfo , $ content , $ messages ) ; if ( ! $ messages ) { return false ; } $ this -> html -> h3 ( sprintf ( 'Report on file %s' , substr ( $ fileinfo -> getPathname ( ) , strlen ( GEMS_ROOT_DIR ) + 1 ) ) ) ; foreach ( $ messages as $ message ) { $ this -> html -> pInfo ( $ message ) ; } return true ; }
A specific report on a code file
58,148
protected function addFileReports ( ) { $ sCode = $ this -> html -> sequence ( ) ; $ output = false ; $ filenames = $ this -> _getFilenames ( ) ; foreach ( $ filenames as $ filename ) { $ output = $ this -> addFileReport ( $ filename ) || $ output ; } if ( $ this -> appNamespaceError ) { $ sCode -> h3 ( 'Code change issues found' ) ; $ sCode -> pInfo ( 'The application code has code change issues. You can try to fix them by running this phing script:' ) ; $ sCode -> pre ( 'cd ' . APPLICATION_PATH . "\n" . 'phing -f ' . GEMS_LIBRARY_DIR . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'namespacer.xml' ) ; $ p = $ sCode -> pInfo ( 'To use this script you have to install ' ) ; $ p -> a ( 'https://www.phing.info/' , 'Phing' ) ; $ p -> append ( '. Then run the script and check again for issues not fixed by the script.' ) ; } elseif ( ! $ output ) { $ this -> html -> h3 ( 'Code change report' ) ; $ this -> html -> pInfo ( 'No compatibility issues found in the code for this project.' ) ; } }
A reports on code files
58,149
protected function addProjectIniReport ( ) { $ h3 = $ this -> html -> h3 ( ) ; $ issues = false ; if ( ! $ this -> project -> offsetExists ( 'headers' ) ) { $ this -> html -> pInfo ( 'No headers section found.' ) ; $ issues = true ; } if ( ! $ this -> project -> offsetExists ( 'meta' ) ) { $ this -> html -> pInfo ( 'No meta headers section found.' ) ; $ issues = true ; } else { if ( isset ( $ this -> project [ 'meta' ] [ 'Content-Security-Policy' ] ) ) { $ this -> html -> pInfo ( 'meta.Content-Security-Policy should be moved to headers section' ) ; $ issues = true ; } if ( isset ( $ this -> project [ 'meta' ] [ 'Strict-Transport-Security' ] ) ) { $ this -> html -> pInfo ( 'meta.Strict-Transport-Security should be moved to headers section' ) ; $ issues = true ; } } if ( isset ( $ this -> project [ 'headers' ] [ 'Content-Security-Policy' ] ) && preg_match ( '/img-src\s.*?data:.*?;/' , $ this -> project [ 'headers' ] [ 'Content-Security-Policy' ] ) !== 1 ) { $ this -> html -> pInfo ( 'The headers.Content-Security-Policy setting img-src should have data: for Two Factor Authentication.' ) ; $ issues = true ; } if ( $ this -> project -> offsetExists ( 'jquerycss' ) ) { $ this -> html -> pInfo ( 'Separate JQuery CSS no longer in use. Remove jquerycss setting.' ) ; $ issues = true ; } if ( ! isset ( $ this -> project [ 'security' ] , $ this -> project [ 'security' ] [ 'methods' ] ) ) { $ this -> html -> pInfo ( 'No OpenSSL cipher methods defined in security.methods.' ) ; $ issues = true ; } if ( $ issues ) { $ h3 -> append ( 'Project.ini issues found' ) ; $ this -> html -> pInfo ( ) -> strong ( 'See project.example.ini for examples of fixes.' ) ; } else { $ h3 -> append ( 'Project.ini report' ) ; $ this -> html -> pInfo ( 'No compatibility issues found in project.ini.' ) ; } }
A reports on the project ini
58,150
protected function getRecursiveDirectoryIterator ( $ dir ) { return new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ dir , \ FilesystemIterator :: CURRENT_AS_FILEINFO ) , \ RecursiveIteratorIterator :: SELF_FIRST , \ RecursiveIteratorIterator :: CATCH_GET_CHILD ) ; }
Iterator for looping thorugh all files in a directory and i s sub directories
58,151
public function setOption ( $ key , $ value ) { switch ( $ key ) { case 'cellDecorator' : $ value = $ this -> getCellDecorators ( ) + array ( $ value ) ; case 'cellDecorators' : $ this -> _cellDecorators = $ value ; break ; default : $ this -> _options [ $ key ] = $ value ; break ; } return $ this ; }
Set a single option
58,152
public function writeTo ( $ filename ) { parent :: writeTo ( $ filename ) ; if ( $ this -> optimiserService instanceof ImageOptimiserInterface ) { $ this -> optimiserService -> optimiseImage ( $ filename ) ; } }
Calls the original writeTo function and then after that completes optimises the image
58,153
public function canResetPassword ( \ Gems_User_User $ user = null ) { if ( $ user ) { if ( $ user -> hasEmailAddress ( ) && $ user -> canSetPassword ( ) ) { $ email = $ user -> getEmailAddress ( ) ; if ( empty ( $ email ) ) { return false ; } else { return true ; } } } else { return true ; } }
Return true if a password reset key can be created .
58,154
public function checkRehash ( \ Gems_User_User $ user , $ password ) { if ( ! $ this -> canSaveNewHash ( ) ) { return false ; } $ model = new \ MUtil_Model_TableModel ( 'gems__user_passwords' ) ; $ row = $ model -> loadFirst ( [ 'gup_id_user' => $ user -> getUserLoginId ( ) ] ) ; if ( $ row && password_needs_rehash ( $ row [ 'gup_password' ] , $ this -> getHashAlgorithm ( ) , $ this -> getHashOptions ( ) ) ) { $ data [ 'gup_id_user' ] = $ user -> getUserLoginId ( ) ; $ data [ 'gup_password' ] = $ this -> hashPassword ( $ password ) ; $ model = new \ MUtil_Model_TableModel ( 'gems__user_passwords' ) ; \ Gems_Model :: setChangeFieldsByPrefix ( $ model , 'gup' , $ user -> getUserId ( ) ) ; $ model -> save ( $ data ) ; return true ; } return false ; }
Checks if the current users hashed password uses the current hash algorithm . If not it rehashes and saves the current password
58,155
public function getCredentialValidationCallback ( ) { if ( $ this -> checkOldHashes ) { $ credentialValidationCallback = function ( $ dbCredential , $ requestCredential ) { if ( password_verify ( $ requestCredential , $ dbCredential ) ) { return true ; } elseif ( $ dbCredential == $ this -> hashOldPassword ( $ requestCredential ) ) { return true ; } return false ; } ; } else { $ credentialValidationCallback = function ( $ dbCredential , $ requestCredential ) { if ( password_verify ( $ requestCredential , $ dbCredential ) ) { return true ; } return false ; } ; } return $ credentialValidationCallback ; }
get the credential validation callback function for the callback check adapter
58,156
protected function getDb2 ( ) { if ( ! $ this -> db2 instanceof Adapter ) { $ config = Zend_Controller_Front :: getInstance ( ) -> getParam ( 'bootstrap' ) ; $ resources = $ config -> getOption ( 'resources' ) ; $ dbConfig = array ( 'driver' => $ resources [ 'db' ] [ 'adapter' ] , 'hostname' => $ resources [ 'db' ] [ 'params' ] [ 'host' ] , 'database' => $ resources [ 'db' ] [ 'params' ] [ 'dbname' ] , 'username' => $ resources [ 'db' ] [ 'params' ] [ 'username' ] , 'password' => $ resources [ 'db' ] [ 'params' ] [ 'password' ] , 'charset' => $ resources [ 'db' ] [ 'params' ] [ 'charset' ] , ) ; $ this -> db2 = new Adapter ( $ dbConfig ) ; } return $ this -> db2 ; }
Create a Zend DB 2 Adapter needed for the Zend \ Authentication library
58,157
public function getPasswordResetKey ( \ Gems_User_User $ user ) { $ model = new \ MUtil_Model_TableModel ( 'gems__user_passwords' ) ; \ Gems_Model :: setChangeFieldsByPrefix ( $ model , 'gup' , $ user -> getUserId ( ) ) ; $ data [ 'gup_id_user' ] = $ user -> getUserLoginId ( ) ; $ filter = $ data ; if ( ( 0 == ( $ this -> hoursResetKeyIsValid % 24 ) ) || \ Zend_Session :: $ _unitTestEnabled ) { $ filter [ ] = 'ADDDATE(gup_reset_requested, ' . intval ( $ this -> hoursResetKeyIsValid / 24 ) . ') >= CURRENT_TIMESTAMP' ; } else { $ filter [ ] = 'DATE_ADD(gup_reset_requested, INTERVAL ' . $ this -> hoursResetKeyIsValid . ' HOUR) >= CURRENT_TIMESTAMP' ; } $ row = $ model -> loadFirst ( $ filter ) ; if ( $ row && $ row [ 'gup_reset_key' ] ) { $ data [ 'gup_reset_key' ] = $ row [ 'gup_reset_key' ] ; } else { $ data [ 'gup_reset_key' ] = hash ( 'sha256' , time ( ) . $ user -> getEmailAddress ( ) ) ; } $ data [ 'gup_reset_requested' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; while ( true ) { try { $ model -> save ( $ data ) ; return $ data [ 'gup_reset_key' ] ; } catch ( \ Zend_Db_Exception $ zde ) { $ data [ 'gup_reset_key' ] = hash ( 'sha256' , time ( ) . $ user -> getEmailAddress ( ) ) ; } } }
Return a password reset key
58,158
public function getUserData ( $ login_name , $ organization ) { $ select = $ this -> getUserSelect ( $ login_name , $ organization ) ; try { $ result = $ this -> db -> fetchRow ( $ select , array ( $ login_name , $ organization ) , \ Zend_Db :: FETCH_ASSOC ) ; } catch ( \ Zend_Db_Statement_Exception $ e ) { $ sql = $ select -> __toString ( ) ; $ sql = str_replace ( [ '`gems__user_logins`.`gul_two_factor_key`' , '`gems__user_logins`.`gul_enable_2factor`' ] , 'NULL' , $ sql ) ; try { $ result = $ this -> db -> fetchRow ( $ sql , array ( $ login_name , $ organization ) , \ Zend_Db :: FETCH_ASSOC ) ; } catch ( \ Zend_Db_Statement_Exception $ e ) { $ sql = str_replace ( 'gup_last_pwd_change' , 'gup_changed' , $ sql ) ; $ result = $ this -> db -> fetchRow ( $ sql , array ( $ login_name , $ organization ) , \ Zend_Db :: FETCH_ASSOC ) ; } } if ( $ result == false ) { $ result = \ Gems_User_NoLoginDefinition :: getNoLoginDataFor ( $ login_name , $ organization ) ; } return $ result ; }
Returns a user object that may be empty if the user is unknown .
58,159
public function hasPassword ( \ Gems_User_User $ user ) { $ sql = "SELECT CASE WHEN gup_password IS NULL THEN 0 ELSE 1 END FROM gems__user_passwords WHERE gup_id_user = ?" ; return ( boolean ) $ this -> db -> fetchOne ( $ sql , $ user -> getUserLoginId ( ) ) ; }
Return true if the user has a password .
58,160
public function Upgrade154to155 ( ) { $ this -> _batch -> addTask ( 'Db_AddPatches' , 48 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 5 . 5 just execute patchlevel 48
58,161
public function Upgrade155to156 ( ) { $ this -> _batch -> addTask ( 'Db_AddPatches' , 49 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 5 . 6 just execute patchlevel 49
58,162
public function Upgrade157to16 ( ) { $ this -> _batch -> addTask ( 'Db_AddPatches' , 51 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 6 just execute patchlevel 51
58,163
public function Upgrade16to161 ( ) { $ this -> _batch -> addTask ( 'Db_AddPatches' , 52 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 6 . 1 just execute patchlevel 52
58,164
public function Upgrade161to162 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 53 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 6 . 2 just execute patchlevel 53
58,165
public function Upgrade162to163 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 54 ) ; $ this -> _batch -> addTask ( 'Updates_UpdateRoleIds' ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 6 . 3 just execute patchlevel 54
58,166
public function Upgrade163to164 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 55 ) ; $ this -> _batch -> addTask ( 'Updates_CompileTemplates' ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 6 . 4 just execute patchlevel 55
58,167
public function Upgrade164to170 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 56 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; return true ; }
To upgrade to 1 . 7 . 0
58,168
public function Upgrade170to171 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 57 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 7 . 1
58,169
public function Upgrade171to172 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 58 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 7 . 2
58,170
public function Upgrade172to181 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 59 ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 8 . 1
58,171
public function Upgrade181to182 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 60 ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Updates\\FillTokenReplacementsTask' ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 8 . 2
58,172
public function Upgrade182to183 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 61 ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 8 . 3
58,173
public function Upgrade183to184 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 62 ) ; $ this -> _batch -> addTask ( 'Updates_CompileTemplates' ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 8 . 4
58,174
public function Upgrade184to185 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 63 ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 8 . 5
58,175
public function Upgrade185to186 ( ) { $ this -> _batch -> addTask ( 'Db_CreateNewTables' ) ; $ this -> _batch -> addTask ( 'Db_AddPatches' , 64 ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Updates_EncryptPasswords' , 'gems__sources' , 'gso_id_source' , 'gso_ls_password' ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Updates_EncryptPasswords' , 'gems__mail_servers' , 'gms_from' , 'gms_password' ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Updates_EncryptPasswords' , 'gems__radius_config' , 'grcfg_id' , 'grcfg_secret' ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Make sure to read the changelog as it contains important instructions' ) ) ; $ this -> _batch -> addTask ( 'AddTask' , 'Echo' , $ this -> _ ( 'Check the Code compatibility report for any issues with project specific code!' ) ) ; return true ; }
To upgrade to 1 . 8 . 6
58,176
public function addTab ( $ name , $ title ) { if ( $ title instanceof \ MUtil_Html_HtmlInterface ) { $ title = $ title -> render ( $ this -> getView ( ) ) ; } $ tab = new \ Gems_Form_TabSubForm ( array ( 'name' => $ name , 'title' => strip_tags ( $ title ) ) ) ; $ this -> currentTab = $ tab ; $ this -> addSubForm ( $ tab , $ name ) ; return $ tab ; }
Add a tab to the form
58,177
public function addToOtherGroup ( $ element ) { if ( $ element instanceof \ Zend_Form_Element ) { if ( $ group = $ this -> getDisplayGroup ( self :: GROUP_OTHER ) ) { $ group -> addElement ( $ element ) ; } else { $ this -> addDisplayGroup ( array ( $ element ) , self :: GROUP_OTHER ) ; } } return $ this ; }
Add to the group all non - tab elements are in
58,178
public function getDisplayGroup ( $ name ) { if ( $ group = parent :: getDisplayGroup ( $ name ) ) { return $ group ; } else { $ subforms = $ this -> getSubForms ( ) ; foreach ( $ subforms as $ subform ) { if ( $ group = $ subform -> getDisplayGroup ( $ name ) ) { return $ group ; } } return ; } }
Return a display group use recursive search in subforms to provide a transparent experience with tabs
58,179
public function getElement ( $ name ) { if ( $ element = parent :: getElement ( $ name ) ) { return $ element ; } else { $ subforms = $ this -> getSubForms ( ) ; foreach ( $ subforms as $ subform ) { if ( $ element = $ subform -> getElement ( $ name ) ) { return $ element ; } } return ; } }
Retrieve a single element use recursive search in subforms to provide a transparent experience with tabs
58,180
public function loadDefaultDecorators ( ) { if ( $ this -> loadDefaultDecoratorsIsDisabled ( ) ) { return ; } $ decorators = $ this -> getDecorators ( ) ; if ( empty ( $ decorators ) ) { $ this -> setDecorators ( array ( 'TabErrors' , array ( array ( 'SubformElements' => 'FormElements' ) ) , array ( 'HtmlTag' , array ( 'tag' => 'div' , 'id' => 'tabContainer' , 'class' => 'mainForm' ) ) , array ( 'TabContainer' , array ( 'id' => 'tabContainer' , 'style' => 'width: 99%;' ) ) , 'FormElements' , 'Form' ) ) ; } }
Load the default decorators
58,181
public function getValues ( $ suppressArrayNotation = false ) { $ values = parent :: getValues ( $ suppressArrayNotation ) ; foreach ( $ this -> getSubForms ( ) as $ key => $ subForm ) { $ values = $ this -> _array_replace_recursive ( $ values , $ values [ $ key ] ) ; } return $ values ; }
Retrieve all form element values
58,182
public function isDeleteable ( $ trackId ) { if ( ! $ trackId ) { return true ; } $ sql = "SELECT gto_id_token FROM gems__tokens WHERE gto_id_track = ? AND gto_start_time IS NOT NULL" ; return ( boolean ) ! $ this -> db -> fetchOne ( $ sql , $ trackId ) ; }
Can this track be deleted as is?
58,183
protected function _processAnswer ( $ key , $ input , $ type ) { $ output = array ( ) ; $ modelName = str_replace ( '/' , '_' , $ key ) ; if ( array_key_exists ( $ key , $ input ) ) { $ value = $ input [ $ key ] ; } else { return $ output ; } switch ( $ type ) { case 'dateTime' : if ( empty ( $ value ) ) { $ value = null ; } $ output [ $ modelName ] = new \ Zend_Date ( $ value , \ Zend_Date :: ISO_8601 ) ; break ; case 'select' : $ items = explode ( ' ' , $ value ) ; foreach ( $ items as $ idx => $ answer ) { $ multiName = $ modelName . '_' . $ answer ; $ output [ $ multiName ] = 1 ; } break ; case 'geopoint' : $ items = explode ( ' ' , $ value ) ; if ( count ( $ items ) == 4 ) { $ output [ $ modelName . '_lat' ] = $ items [ 0 ] ; $ output [ $ modelName . '_long' ] = $ items [ 1 ] ; $ output [ $ modelName . '_alt' ] = $ items [ 2 ] ; $ output [ $ modelName . '_acc' ] = $ items [ 3 ] ; } break ; default : $ output [ $ modelName ] = $ value ; break ; } return $ output ; }
If needed process the answer
58,184
public function getFormID ( ) { if ( empty ( $ this -> formID ) ) { foreach ( $ this -> _xml -> children ( 'h' , true ) -> head -> children ( ) -> model -> instance -> children ( ) as $ element ) { if ( ! empty ( $ element -> attributes ( ) -> id ) ) { $ this -> formID = $ element -> attributes ( ) -> id -> __toString ( ) ; break ; } } } return $ this -> formID ; }
Returns the formID from the instance element id attribute
58,185
public function getFormVersion ( ) { if ( empty ( $ this -> formVersion ) ) { foreach ( $ this -> _xml -> children ( 'h' , true ) -> head -> children ( ) -> model -> instance -> children ( ) as $ element ) { if ( ! empty ( $ element -> attributes ( ) -> version ) ) { $ this -> formVersion = $ element -> attributes ( ) -> version ; break ; } } } return $ this -> formVersion ; }
Returns the formVersion from the instance element version attribute
58,186
public function isValid ( $ value ) { foreach ( ( array ) $ value as $ val ) { if ( \ MUtil_String :: contains ( $ val , $ this -> _options [ 0 ] ) ) { return true ; } } return false ; }
IS the comparison valid?
58,187
protected function applyTextMarker ( ) { $ model = $ this -> getModel ( ) ; $ textKey = $ model -> getTextFilter ( ) ; $ filter = $ model -> getFilter ( ) ; if ( isset ( $ filter [ $ textKey ] ) ) { $ searchText = $ filter [ $ textKey ] ; $ marker = new \ MUtil_Html_Marker ( $ model -> getTextSearches ( $ searchText ) , 'strong' , 'UTF-8' ) ; foreach ( $ model -> getItemNames ( ) as $ name ) { if ( $ model -> get ( $ name , 'label' ) ) { $ model -> set ( $ name , 'markCallback' , array ( $ marker , 'mark' ) ) ; } } } }
Make sure generic search text results are marked
58,188
protected function findMenuItem ( $ defaultController , $ actions = 'index' ) { foreach ( ( array ) $ actions as $ key => $ action ) { $ controller = is_int ( $ key ) ? $ defaultController : $ key ; $ item = $ this -> menu -> find ( array ( 'controller' => $ controller , 'action' => $ action , 'allowed' => true ) ) ; if ( $ item ) { return $ item ; } } }
Finds a specific active menu item
58,189
protected function _ensureRounds ( ) { if ( ! is_array ( $ this -> _rounds ) ) { $ roundSelect = $ this -> db -> select ( ) ; $ roundSelect -> from ( 'gems__rounds' ) -> where ( 'gro_id_track = ?' , $ this -> _trackId ) -> order ( 'gro_id_order' ) ; $ this -> _rounds = array ( ) ; foreach ( $ roundSelect -> query ( ) -> fetchAll ( ) as $ round ) { $ this -> _rounds [ $ round [ 'gro_id_round' ] ] = $ round ; } } }
Loads the rounds data for this type of track engine .
58,190
private function _update ( array $ values , $ userId ) { if ( $ this -> tracker -> filterChangesOnly ( $ this -> _trackData , $ values ) ) { if ( \ Gems_Tracker :: $ verbose ) { $ echo = '' ; foreach ( $ values as $ key => $ val ) { $ echo .= $ key . ': ' . $ this -> _trackData [ $ key ] . ' => ' . $ val . "\n" ; } \ MUtil_Echo :: r ( $ echo , 'Updated values for ' . $ this -> _trackId ) ; } if ( ! isset ( $ values [ 'gto_changed' ] ) ) { $ values [ 'gtr_changed' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; } if ( ! isset ( $ values [ 'gtr_changed_by' ] ) ) { $ values [ 'gtr_changed_by' ] = $ userId ; } $ this -> _trackData = $ values + $ this -> _trackData ; return $ this -> db -> update ( 'gems__tracks' , $ values , array ( 'gtr_id_track = ?' => $ this -> _trackId ) ) ; } else { return 0 ; } }
Update the track both in the database and in memory .
58,191
public function addFieldsToModel ( \ MUtil_Model_ModelAbstract $ model , $ addDependency = true , $ respTrackId = false ) { if ( $ this -> _fieldsDefinition -> exists ) { $ transformer = new AddTrackFieldsTransformer ( $ this -> loader , $ this -> _fieldsDefinition , $ respTrackId ) ; $ model -> addTransformer ( $ transformer ) ; if ( $ addDependency ) { $ dependency = $ this -> _fieldsDefinition -> getDataModelDependency ( ) ; if ( $ dependency instanceof DependencyInterface ) { $ model -> addDependency ( $ dependency ) ; } } } return $ this ; }
Integrate field loading en showing and editing
58,192
protected function addNewTokens ( \ Gems_Tracker_RespondentTrack $ respTrack , $ userId ) { $ orgId = $ respTrack -> getOrganizationId ( ) ; $ respId = $ respTrack -> getRespondentId ( ) ; $ respTrackId = $ respTrack -> getRespondentTrackId ( ) ; $ sql = "SELECT gro_id_round, gro_id_survey, gro_id_order, gro_icon_file, gro_round_description FROM gems__rounds WHERE gro_id_track = ? AND gro_active = 1 AND gro_id_round NOT IN (SELECT gto_id_round FROM gems__tokens WHERE gto_id_respondent_track = ?) AND (gro_organizations IS NULL OR gro_organizations LIKE CONCAT('%|',?,'|%')) ORDER BY gro_id_order" ; $ newRounds = $ this -> db -> fetchAll ( $ sql , array ( $ this -> _trackId , $ respTrackId , $ orgId ) ) ; $ this -> db -> beginTransaction ( ) ; foreach ( $ newRounds as $ round ) { $ values = array ( ) ; $ values [ 'gto_id_respondent_track' ] = $ respTrackId ; $ values [ 'gto_id_respondent' ] = $ respId ; $ values [ 'gto_id_organization' ] = $ orgId ; $ values [ 'gto_id_track' ] = $ this -> _trackId ; $ values [ 'gto_id_round' ] = $ round [ 'gro_id_round' ] ; $ values [ 'gto_id_survey' ] = $ round [ 'gro_id_survey' ] ; $ values [ 'gto_round_order' ] = $ round [ 'gro_id_order' ] ; $ values [ 'gto_icon_file' ] = $ round [ 'gro_icon_file' ] ; $ values [ 'gto_round_description' ] = $ round [ 'gro_round_description' ] ; $ this -> tracker -> createToken ( $ values , $ userId ) ; } $ this -> db -> commit ( ) ; return count ( $ newRounds ) ; }
Creates all tokens that should exist but do not exist
58,193
public function applyToMenuSource ( \ Gems_Menu_ParameterSource $ source ) { $ source -> setTrackId ( $ this -> _trackId ) ; $ source -> offsetSet ( 'gtr_active' , isset ( $ this -> _trackData [ 'gtr_active' ] ) ? $ this -> _trackData [ 'gtr_active' ] : 0 ) ; return $ this ; }
Set menu parameters from this track engine
58,194
public function checkRoundsFor ( \ Gems_Tracker_RespondentTrack $ respTrack , $ userId , \ Gems_Task_TaskRunnerBatch $ batch = null ) { if ( null === $ batch ) { $ batch = new \ Gems_Task_TaskRunnerBatch ( 'tmp-tack-' . $ respTrack -> getRespondentTrackId ( ) ) ; } $ i = $ batch -> addToCounter ( 'roundChangeUpdates' , $ this -> checkExistingRoundsFor ( $ respTrack , $ userId ) ) ; $ batch -> setMessage ( 'roundChangeUpdates' , sprintf ( $ this -> _ ( 'Round changes propagated to %d tokens.' ) , $ i ) ) ; $ i = $ batch -> addToCounter ( 'deletedTokens' , $ this -> removeInactiveRounds ( $ respTrack , $ userId ) ) ; $ batch -> setMessage ( 'deletedTokens' , sprintf ( $ this -> _ ( '%d tokens deleted by round changes.' ) , $ i ) ) ; $ i = $ batch -> addToCounter ( 'createdTokens' , $ this -> addNewTokens ( $ respTrack , $ userId ) ) ; $ batch -> setMessage ( 'createdTokens' , sprintf ( $ this -> _ ( '%d tokens created to by round changes.' ) , $ i ) ) ; $ changed = $ respTrack -> checkTrackTokens ( $ userId ) ; $ ica = $ batch -> addToCounter ( 'tokenDateCauses' , $ changed ? 1 : 0 ) ; $ ich = $ batch -> addToCounter ( 'tokenDateChanges' , $ changed ) ; $ batch -> setMessage ( 'tokenDateChanges' , sprintf ( $ this -> _ ( '%2$d token date changes in %1$d tracks.' ) , $ ica , $ ich ) ) ; $ i = $ batch -> addToCounter ( 'checkedRespondentTracks' ) ; $ batch -> setMessage ( 'checkedRespondentTracks' , sprintf ( $ this -> _ ( 'Checked %d tracks.' ) , $ i ) ) ; }
Check for the existence of all tokens and create them otherwise
58,195
public function getNextRoundId ( $ roundId ) { $ this -> _ensureRounds ( ) ; if ( $ this -> _rounds && $ roundId ) { $ next = false ; foreach ( $ this -> _rounds as $ currentRoundId => $ round ) { if ( $ next ) { return $ currentRoundId ; } if ( $ currentRoundId == $ roundId ) { $ next = true ; } } return null ; } elseif ( $ this -> _rounds ) { end ( $ this -> _rounds ) ; return key ( $ this -> _rounds ) ; } }
Look up the round id for the next round
58,196
public function getPreviousRoundId ( $ roundId , $ roundOrder = null ) { $ this -> _ensureRounds ( ) ; if ( $ this -> _rounds && $ roundId ) { $ returnId = null ; foreach ( $ this -> _rounds as $ currentRoundId => $ round ) { if ( ( $ currentRoundId == $ roundId ) || ( $ roundOrder && ( $ round [ 'gro_id_order' ] >= $ roundOrder ) ) ) { return $ returnId ; } $ returnId = $ currentRoundId ; } throw new \ Gems_Exception_Coding ( "Requested non existing previous round id for round $roundId." ) ; } elseif ( $ this -> _rounds ) { end ( $ this -> _rounds ) ; $ key = key ( $ this -> _rounds ) ; if ( empty ( $ key ) && ! is_null ( $ key ) ) { prev ( $ this -> _rounds ) ; } return key ( $ this -> _rounds ) ; } }
Look up the round id for the previous round
58,197
public function getRound ( $ roundId ) { $ this -> _ensureRounds ( ) ; if ( ! isset ( $ this -> _rounds [ $ roundId ] ) ) { return null ; } if ( ! isset ( $ this -> _roundObjects [ $ roundId ] ) ) { $ this -> _roundObjects [ $ roundId ] = $ this -> tracker -> createTrackClass ( 'Round' , $ this -> _rounds [ $ roundId ] ) ; } return $ this -> _roundObjects [ $ roundId ] ; }
Get the round object
58,198
public function getRoundChangedEvent ( $ roundId ) { $ this -> _ensureRounds ( ) ; if ( isset ( $ this -> _rounds [ $ roundId ] [ 'gro_changed_event' ] ) && $ this -> _rounds [ $ roundId ] [ 'gro_changed_event' ] ) { return $ this -> events -> loadRoundChangedEvent ( $ this -> _rounds [ $ roundId ] [ 'gro_changed_event' ] ) ; } }
Return the Round Changed event name for this round
58,199
public function getRoundDescriptions ( ) { $ this -> _ensureRounds ( ) ; $ output = array ( ) ; foreach ( $ this -> getRounds ( ) as $ roundId => $ round ) { if ( $ round instanceof Round ) { $ output [ $ roundId ] = $ round -> getFullDescription ( ) ; } } return $ output ; }
The round descriptions for this track