idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
58,400
|
public function listClasses ( $ classType , $ paths , $ nameMethod = 'getName' ) { $ results = array ( ) ; foreach ( $ paths as $ prefix => $ path ) { $ parts = explode ( '_' , $ prefix , 2 ) ; if ( $ name = reset ( $ parts ) ) { $ name = ' (' . $ name . ')' ; } try { $ globIter = new \ GlobIterator ( $ path . DIRECTORY_SEPARATOR . '*.php' ) ; } catch ( \ RuntimeException $ e ) { continue ; } foreach ( $ globIter as $ fileinfo ) { $ filename = $ fileinfo -> getFilename ( ) ; $ className = $ prefix . substr ( $ filename , 0 , - 4 ) ; $ classNsName = '\\' . strtr ( $ className , '_' , '\\' ) ; if ( isset ( $ results [ $ className ] ) ) { continue ; } if ( ! ( class_exists ( $ className , false ) || class_exists ( $ classNsName , false ) ) ) { include ( $ path . DIRECTORY_SEPARATOR . $ filename ) ; } if ( ( ! class_exists ( $ className , false ) ) && class_exists ( $ classNsName , false ) ) { $ className = $ classNsName ; } $ class = new $ className ( ) ; if ( $ class instanceof $ classType ) { if ( $ class instanceof \ MUtil_Registry_TargetInterface ) { $ this -> applySource ( $ class ) ; } $ results [ $ className ] = trim ( $ class -> $ nameMethod ( ) ) . $ name ; } } } natcasesort ( $ results ) ; return $ results ; }
|
Returns a list of selectable classes with an empty element as the first option .
|
58,401
|
public function addSurveyCompareForm ( $ tableBody , $ post ) { if ( $ this -> sourceSurveyId && $ this -> targetSurveyId ) { $ sourceSurveyData = $ this -> getSurveyData ( $ this -> sourceSurveyId ) ; $ targetSurveyData = $ this -> getSurveyData ( $ this -> targetSurveyId ) ; $ surveyCompare = $ this -> getSurveyCompare ( $ sourceSurveyData , $ targetSurveyData , $ post ) ; $ icon = \ MUtil_Html :: create ( ) -> i ( [ 'class' => 'fa fa-exclamation-triangle' , 'style' => 'color: #d43f3a; margin: 1em;' , 'renderClosingTag' => true ] ) ; foreach ( $ surveyCompare as $ question ) { if ( $ question [ 'status' ] == 'missing' ) { continue ; } $ rowMessage = false ; $ statusClass = '' ; if ( isset ( $ this -> questionStatusClasses [ $ question [ 'status' ] ] ) ) { $ statusClass = $ this -> questionStatusClasses [ $ question [ 'status' ] ] ; } if ( $ question [ 'status' ] == 'type-difference' ) { $ rowMessage = $ this -> _ ( 'Question type is not the same. Check compatibility!' ) ; } elseif ( $ question [ 'status' ] == 'new' ) { $ rowMessage = $ this -> _ ( 'Question could not be found in source. Is this a new question?' ) ; } $ row = $ tableBody -> tr ( [ 'class' => $ statusClass ] ) ; $ row -> td ( $ question [ 'target' ] ) ; $ row -> td ( $ this -> getSurveyQuestionSelect ( $ sourceSurveyData , $ question [ 'source' ] , $ question [ 'target' ] ) ) ; if ( isset ( $ targetSurveyData [ $ question [ 'target' ] ] ) ) { $ row -> td ( $ targetSurveyData [ $ question [ 'target' ] ] [ 'question' ] ) ; } else { $ row -> td ( ) ; } if ( $ rowMessage ) { $ tableBody -> tr ( [ 'class' => $ statusClass ] ) -> td ( [ 'colspan' => 3 ] ) -> append ( $ icon , $ rowMessage ) ; } } } }
|
Adds the survey compare form to the current table showing the matches between different surveys
|
58,402
|
public function calculateTrackUsage ( $ surveyId ) { $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__tracks' , array ( 'gtr_track_name' ) ) ; $ select -> joinLeft ( 'gems__rounds' , 'gro_id_track = gtr_id_track' , array ( 'useCnt' => 'COUNT(*)' ) ) -> where ( 'gro_id_survey = ?' , $ surveyId ) -> group ( 'gtr_track_name' ) ; $ usage = $ this -> db -> fetchPairs ( $ select ) ; if ( $ usage ) { $ seq = new \ MUtil_Html_Sequence ( ) ; $ seq -> setGlue ( \ MUtil_Html :: create ( 'br' ) ) ; foreach ( $ usage as $ track => $ count ) { $ seq [ ] = sprintf ( $ this -> plural ( 'Used %d time in %s track.' , 'Used %d times in %s track.' , $ count ) , $ count , $ track ) ; } return $ seq ; } else { return $ this -> _ ( 'Not used in any track.' ) ; } }
|
Gets how many times a survey is used in tracks
|
58,403
|
protected function getCategorizedResults ( $ post , $ sourceSurveyData , $ targetSurveyData ) { $ surveyCompare = $ this -> getSurveyCompare ( $ sourceSurveyData , $ targetSurveyData , $ post ) ; $ categorizedResults = [ ] ; foreach ( array_keys ( $ this -> questionStatusClasses ) as $ status ) { $ categorizedResults [ $ status ] = [ ] ; } foreach ( $ surveyCompare as $ result ) { if ( isset ( $ result [ 'status' ] ) ) { if ( $ result [ 'status' ] == 'missing' ) { $ categorizedResults [ $ result [ 'status' ] ] [ $ result [ 'source' ] ] = $ result ; } else { $ categorizedResults [ $ result [ 'status' ] ] [ $ result [ 'target' ] ] = $ result ; } } else { $ categorizedResults [ 'other' ] [ ] = $ result ; } } return $ categorizedResults ; }
|
Function to get Survey compare results sorted by status
|
58,404
|
public function getComments ( ) { $ comments = false ; $ table = \ MUtil_Html :: create ( ) -> table ( [ 'class' => 'browser table' , 'style' => 'width: auto' ] ) ; $ targetSurveyAnswers = $ this -> getNumberOfAnswers ( $ this -> targetSurveyId ) ; if ( $ targetSurveyAnswers > 0 ) { $ comments = true ; $ table -> tr ( [ 'class' => 'warning' ] ) -> td ( sprintf ( $ this -> _ ( 'Target survey already has %d answers. Is this expected?' ) , $ targetSurveyAnswers ) ) ; } if ( $ comments ) { return $ table ; } return false ; }
|
Creates a table with warnings about the survey answer transfer
|
58,405
|
protected function getCompareResultSummary ( $ post , $ sourceSurveyData , $ targetSurveyData ) { $ categorizedResults = $ this -> getCategorizedResults ( $ post , $ sourceSurveyData , $ targetSurveyData ) ; $ table = \ MUtil_Html :: create ( ) -> table ( [ 'class' => 'browser table' , 'style' => 'width: auto' ] ) ; $ row = $ table -> tr ( [ 'class' => $ this -> questionStatusClasses [ 'new' ] ] ) ; $ row -> td ( sprintf ( $ this -> _ ( '%d new questions' ) , count ( $ categorizedResults [ 'new' ] ) ) ) ; $ row -> td ( join ( ', ' , array_keys ( $ categorizedResults [ 'new' ] ) ) ) ; $ row = $ table -> tr ( [ 'class' => $ this -> questionStatusClasses [ 'same' ] ] ) ; $ row -> td ( sprintf ( $ this -> _ ( '%d questions without warnings ' ) , count ( $ categorizedResults [ 'same' ] ) ) ) ; $ row -> td ( join ( ', ' , array_keys ( $ categorizedResults [ 'same' ] ) ) ) ; $ row = $ table -> tr ( [ 'class' => $ this -> questionStatusClasses [ 'missing' ] ] ) ; $ row -> td ( sprintf ( $ this -> _ ( '%d missing questions' ) , count ( $ categorizedResults [ 'missing' ] ) ) ) ; $ row -> td ( join ( ', ' , array_keys ( $ categorizedResults [ 'missing' ] ) ) ) ; $ row = $ table -> tr ( [ 'class' => $ this -> questionStatusClasses [ 'type-difference' ] ] ) ; $ row -> td ( sprintf ( $ this -> _ ( '%d questions where the question type has changed' ) , count ( $ categorizedResults [ 'type-difference' ] ) ) ) ; $ row -> td ( join ( ', ' , array_keys ( $ categorizedResults [ 'type-difference' ] ) ) ) ; return $ table ; }
|
Creates a table with comparison summary
|
58,406
|
public function getNumberOfAnswers ( $ surveyId ) { $ fields [ 'tokenCount' ] = 'COUNT(DISTINCT gto_id_token)' ; $ select = $ this -> loader -> getTracker ( ) -> getTokenSelect ( $ fields ) -> andReceptionCodes ( [ ] ) ; $ select -> forSurveyId ( $ surveyId ) -> onlySucces ( ) -> onlyCompleted ( ) ; $ row = $ select -> fetchRow ( ) ; return sprintf ( $ this -> _ ( 'Answered surveys: %d.' ) , $ row [ 'tokenCount' ] ) ; }
|
Gets the number of answers in a survey
|
58,407
|
public function getSourceSurveyId ( $ surveyId ) { $ tracker = $ this -> loader -> getTracker ( ) ; $ survey = $ tracker -> getSurvey ( $ surveyId ) ; return $ survey -> getSourceSurveyId ( ) ; }
|
Get the survey ID in the survey source
|
58,408
|
public function getSurveyCompare ( $ sourceSurveyData , $ targetSurveyData , $ post ) { $ surveyCompareArray = [ ] ; $ missingSourceSurveyTitles = $ sourceSurveyData ; foreach ( $ targetSurveyData as $ questionCode => $ questionData ) { $ currentQuestionCode = $ questionCode ; if ( isset ( $ post [ 'target' ] ) && isset ( $ post [ 'target' ] [ $ currentQuestionCode ] ) ) { $ currentQuestionCode = $ post [ 'target' ] [ $ currentQuestionCode ] ; } $ questionCompare = [ 'target' => $ questionCode , 'source' => $ currentQuestionCode , ] ; if ( isset ( $ sourceSurveyData [ $ currentQuestionCode ] ) ) { if ( $ questionData [ 'type' ] === $ sourceSurveyData [ $ currentQuestionCode ] [ 'type' ] ) { $ questionCompare [ 'status' ] = 'same' ; } else { $ questionCompare [ 'status' ] = 'type-difference' ; } unset ( $ missingSourceSurveyTitles [ $ currentQuestionCode ] ) ; } else { $ questionCompare [ 'status' ] = 'new' ; } $ surveyCompareArray [ ] = $ questionCompare ; } foreach ( $ missingSourceSurveyTitles as $ questionId => $ questionData ) { $ surveyCompareArray [ ] = [ 'target' => null , 'source' => $ questionId , 'status' => 'missing' , ] ; } return $ surveyCompareArray ; }
|
create an array with statusses of survey questions and how they re matched in the form
|
58,409
|
public function getSurveyCompareTable ( $ bridge ) { $ post = $ this -> formData ; $ element = $ bridge -> getForm ( ) -> createElement ( 'html' , 'table' ) ; $ table = $ element -> table ( [ 'class' => 'browser table' ] ) ; $ bridge -> addElement ( $ element ) ; $ headers = [ $ this -> _ ( 'Question code' ) , $ this -> _ ( 'Source Survey' ) , $ this -> _ ( 'Target Survey' ) , ] ; $ tableHeader = $ table -> thead ( ) -> tr ( ) ; foreach ( $ headers as $ label ) { $ tableHeader -> th ( $ label ) ; } $ tableBody = $ table -> tbody ( ) ; if ( $ this -> sourceSurveyId && $ this -> targetSurveyId ) { $ row = $ tableBody -> tr ( ) ; $ row -> td ( $ this -> _ ( 'Usage' ) ) ; $ row -> td ( $ this -> getSurveyStatistics ( $ this -> sourceSurveyId ) ) ; $ row -> td ( $ this -> getSurveyStatistics ( $ this -> targetSurveyId ) ) ; $ this -> addSurveyCompareForm ( $ tableBody , $ post ) ; } }
|
Get the complete comparison table
|
58,410
|
public function getSurveyData ( $ surveyId ) { $ tracker = $ this -> loader -> getTracker ( ) ; $ survey = $ tracker -> getSurvey ( $ surveyId ) ; $ surveyInfo = $ survey -> getQuestionInformation ( $ this -> locale ) ; $ filteredSurveyInfo = $ surveyInfo ; foreach ( $ surveyInfo as $ questionCode => $ questionInfo ) { if ( $ questionInfo [ 'class' ] == 'question_sub' ) { $ parentCode = $ questionInfo [ 'title' ] ; $ parent = $ surveyInfo [ $ parentCode ] ; $ filteredSurveyInfo [ $ questionCode ] [ 'question' ] = $ parent [ 'question' ] . ' | ' . $ questionInfo [ 'question' ] ; if ( isset ( $ filteredSurveyInfo [ $ parentCode ] ) ) { unset ( $ filteredSurveyInfo [ $ parentCode ] ) ; } } } return $ filteredSurveyInfo ; }
|
Gets question information about the survey structure from a specific survey and makes the result readable
|
58,411
|
public function getSurveyName ( $ surveyId ) { $ tracker = $ this -> loader -> getTracker ( ) ; $ survey = $ tracker -> getSurvey ( $ surveyId ) ; return $ survey -> getName ( ) ; }
|
Get Survey name from Id
|
58,412
|
public function getSurveyQuestionSelect ( $ surveyData , $ currentQuestionCode , $ targetQuestionCode ) { $ name = 'target[' . $ targetQuestionCode . ']' ; if ( $ targetQuestionCode === null ) { $ name = 'notfound[]' ; } $ select = \ MUtil_Html :: create ( ) -> select ( [ 'name' => $ name ] ) ; $ select -> class = 'form-control' ; $ empty = $ this -> util -> getTranslated ( ) -> getEmptyDropdownArray ( ) ; $ select -> option ( reset ( $ empty ) , [ 'value' => '' ] ) ; foreach ( $ surveyData as $ questionCode => $ questionData ) { $ attributes = [ 'value' => $ questionCode ] ; if ( $ currentQuestionCode === $ questionCode ) { $ attributes [ 'selected' ] = 'selected' ; } $ select -> option ( $ questionData [ 'question' ] , $ attributes ) ; } return $ select ; }
|
Get the form select with all the questions in the survey and the current selected one
|
58,413
|
public function getSurveyResults ( $ post ) { $ comments = $ this -> getComments ( ) ; $ table = \ MUtil_Html :: create ( ) -> table ( [ 'class' => 'browser table' ] ) ; $ header = $ table -> thead ( ) -> tr ( ) ; $ header -> th ( $ this -> _ ( 'Source Survey' ) ) ; $ header -> th ( $ this -> _ ( 'Target Survey' ) ) ; $ header = $ table -> thead ( ) -> tr ( ) ; $ header -> th ( $ this -> surveys [ $ this -> sourceSurveyId ] ) ; $ header -> th ( $ this -> surveys [ $ this -> targetSurveyId ] ) ; $ tableBody = $ table -> tbody ( ) ; $ row = $ tableBody -> tr ( ) ; $ row -> td ( $ this -> getSurveyStatistics ( $ this -> sourceSurveyId ) ) ; $ row -> td ( $ this -> getSurveyStatistics ( $ this -> targetSurveyId ) ) ; $ tableBody -> tr ( ) -> td ( [ 'colspan' => 2 ] ) ; if ( $ this -> formData [ 'copy_answers' ] == 1 ) { $ sourceSurveyData = $ this -> getSurveyData ( $ this -> sourceSurveyId ) ; $ targetSurveyData = $ this -> getSurveyData ( $ this -> targetSurveyId ) ; $ compareResultSummary = $ this -> getCompareResultSummary ( $ post , $ sourceSurveyData , $ targetSurveyData ) ; $ tableBody -> tr ( ) -> th ( $ this -> _ ( 'Summary' ) , [ 'colspan' => 2 ] ) ; $ tableBody -> tr ( ) -> td ( $ compareResultSummary , [ 'colspan' => 2 ] ) ; } if ( $ comments ) { $ tableBody -> tr ( ) -> th ( $ this -> _ ( 'Comments' ) , [ 'colspan' => 2 ] ) ; $ tableBody -> tr ( ) -> td ( $ comments , [ 'colspan' => 2 ] ) ; } return $ table ; }
|
Creates a table showing the results of the survey compare
|
58,414
|
public function getSurveySelect ( $ name , $ post ) { $ surveys = $ this -> surveys ; $ select = \ MUtil_Html :: create ( ) -> select ( [ 'name' => $ name ] ) ; $ empty = $ this -> util -> getTranslated ( ) -> getEmptyDropdownArray ( ) ; $ select -> option ( reset ( $ empty ) , [ 'value' => '' ] ) ; return $ select ; }
|
Create a select element node with all available surveys
|
58,415
|
public function getSurveyStatistics ( $ surveyId ) { $ seq = new \ MUtil_Html_Sequence ( ) ; $ seq -> setGlue ( \ MUtil_Html :: create ( 'br' ) ) ; $ seq [ ] = $ this -> getNumberOfAnswers ( $ surveyId ) ; $ seq [ ] = $ this -> calculateTrackUsage ( $ surveyId ) ; return $ seq ; }
|
Creates a small html block of number of answers and usage in tracks of surveys
|
58,416
|
public function getSurveys ( ) { if ( ! $ this -> surveys ) { $ dbLookup = $ this -> util -> getDbLookup ( ) ; $ this -> surveys = $ dbLookup -> getSurveysWithSid ( ) ; } return $ this -> surveys ; }
|
Get all available surveys
|
58,417
|
public function bbToHtml ( $ bbcode ) { if ( empty ( $ bbcode ) ) { $ em = \ MUtil_Html :: create ( 'em' ) ; $ em -> raw ( $ this -> _ ( '«empty»' ) ) ; return $ em ; } $ text = \ MUtil_Markup :: render ( $ bbcode , 'Bbcode' , 'Html' ) ; $ div = \ MUtil_Html :: create ( 'div' , array ( 'class' => 'mailpreview' ) ) ; $ div -> raw ( $ text ) ; return $ div ; }
|
Display a template body
|
58,418
|
private function _loadPatches ( $ minimumLevel , $ maximumLevel ) { if ( ! $ this -> _loaded_patches ) { $ this -> _loaded_patches = array ( ) ; foreach ( $ this -> patch_sources as $ file => $ location ) { $ this -> _loadPatchFile ( $ file , $ location , $ minimumLevel , $ maximumLevel ) ; } } }
|
Load all patches from all patch files with the range
|
58,419
|
private function _loadPatchFile ( $ file , $ location , $ minimumLevel , $ maximumLevel ) { if ( $ sql = file_get_contents ( $ file ) ) { if ( $ this -> encoding && ( $ this -> encoding !== mb_internal_encoding ( ) ) ) { $ sql = mb_convert_encoding ( $ sql , mb_internal_encoding ( ) , $ this -> encoding ) ; } $ levels = preg_split ( '/--\s*(GEMS\s+)?VERSION:?\s*/' , $ sql ) ; array_shift ( $ levels ) ; foreach ( $ levels as $ level ) { list ( $ levelnrtext , $ leveltext ) = explode ( "\n" , $ level , 2 ) ; $ levelnr = intval ( $ levelnrtext ) ; if ( $ levelnr && ( $ levelnr >= $ minimumLevel ) && ( $ levelnr <= $ maximumLevel ) ) { $ patches = preg_split ( '/--\s*PATCH:?\s*/' , $ leveltext ) ; array_shift ( $ patches ) ; foreach ( $ patches as $ patch ) { list ( $ name , $ statements ) = explode ( "\n" , $ patch , 2 ) ; $ name = substr ( trim ( $ name ) , 0 , 30 ) ; foreach ( \ MUtil_Parser_Sql_WordsParser :: splitStatements ( $ statements , false ) as $ i => $ statement ) { $ this -> _loaded_patches [ ] = array ( 'gpa_level' => $ levelnr , 'gpa_location' => $ location , 'gpa_name' => $ name , 'gpa_order' => $ i , 'gpa_sql' => $ statement , ) ; } } } } } }
|
Load all patches from a single patch file
|
58,420
|
public function getPatchDatabase ( $ location ) { if ( isset ( $ this -> patch_databases [ $ location ] ) ) { return $ this -> patch_databases [ $ location ] ; } return $ this -> db ; }
|
Get the database for a location
|
58,421
|
public function afterCompile ( ClassType $ class ) : void { $ config = $ this -> config ; if ( $ config -> debug === true ) { $ initialize = $ class -> getMethod ( 'initialize' ) ; $ initialize -> addBody ( '$this->getService(?)->addPanel($this->getService(?));' , [ 'tracy.bar' , $ this -> prefix ( 'panel' ) ] ) ; } }
|
Show mail panel in tracy
|
58,422
|
protected function createLoginForm ( $ showToken = null , $ showPasswordLost = null ) { $ args = \ MUtil_Ra :: args ( func_get_args ( ) , array ( 'showToken' => 'is_boolean' , 'showPasswordLost' => 'is_boolean' , ) , array ( 'showToken' => $ this -> showTokenButton , 'showPasswordLost' => $ this -> showPasswordLostButton , 'labelWidthFactor' => $ this -> labelWidthFactor , 'organizationMaxLines' => $ this -> organizationMaxLines , ) ) ; \ Gems_Html :: init ( ) ; if ( $ this -> layeredLogin === true ) { $ args [ 'topOrganizationDescription' ] = $ this -> getTopOrganizationDescription ( ) ; $ args [ 'childOrganizationDescription' ] = $ this -> getChildOrganizationDescription ( ) ; return $ this -> loader -> getUserLoader ( ) -> getLayeredLoginForm ( $ args ) ; } else { return $ this -> loader -> getUserLoader ( ) -> getLoginForm ( $ args ) ; } }
|
Returns a login form
|
58,423
|
protected function createResetRequestForm ( ) { $ args = \ MUtil_Ra :: args ( func_get_args ( ) , array ( ) , array ( 'labelWidthFactor' => $ this -> labelWidthFactor , ) ) ; $ this -> initHtml ( ) ; return $ this -> loader -> getUserLoader ( ) -> getResetRequestForm ( $ args ) ; }
|
Gets a reset password form .
|
58,424
|
protected function displayResetForm ( \ Gems_Form_AutoLoadFormAbstract $ form , $ errors ) { if ( $ form instanceof \ Gems_User_Validate_GetUserInterface ) { $ user = $ form -> getUser ( ) ; } if ( $ form instanceof \ Gems_User_Form_ResetRequestForm ) { $ this -> html -> h3 ( $ this -> _ ( 'Request password reset' ) ) ; $ p = $ this -> html -> pInfo ( ) ; if ( $ form -> getOrganizationIsVisible ( ) ) { $ p -> append ( $ this -> _ ( 'Please enter your organization and your username or e-mail address. ' ) ) ; } else { $ p -> append ( $ this -> _ ( 'Please enter your username or e-mail address. ' ) ) ; } $ this -> html -> p ( $ this -> _ ( 'We will then send you an e-mail with a link. The link will bring you to a page where you can set a new password of your choice.' ) ) ; } elseif ( $ form instanceof \ Gems_User_Form_ChangePasswordForm ) { $ this -> setCurrentOrganizationTo ( $ user ) ; if ( $ user -> hasPassword ( ) ) { $ this -> html -> h3 ( $ this -> _ ( 'Execute password reset' ) ) ; $ p = $ this -> html -> pInfo ( $ this -> _ ( 'We received your password reset request.' ) ) ; } else { $ this -> html -> h3 ( sprintf ( $ this -> _ ( 'Welcome to %s' ) , $ this -> project -> getName ( ) ) ) ; $ p = $ this -> html -> pInfo ( $ this -> _ ( 'Welcome to this website.' ) ) ; } $ p -> append ( ' ' ) ; $ p -> append ( $ this -> _ ( 'Please enter your password of choice twice.' ) ) ; } if ( $ errors ) { $ this -> addMessage ( $ errors ) ; } if ( isset ( $ user ) ) { $ this -> setCurrentOrganizationTo ( $ user ) ; } $ formContainer = \ MUtil_Html :: create ( 'div' , array ( 'class' => 'resetPassword' ) , $ form ) ; $ this -> html -> append ( $ formContainer ) ; }
|
Function for overruling the display of the reset form .
|
58,425
|
public function logoffAction ( ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'Good bye: %s.' ) , $ this -> currentUser -> getFullName ( ) ) ) ; $ this -> accesslog -> logChange ( $ this -> getRequest ( ) ) ; $ this -> currentUser -> unsetAsCurrentUser ( ) ; \ Zend_Session :: destroy ( ) ; $ this -> _reroute ( array ( 'action' => 'index' ) , true ) ; }
|
Default logoff action
|
58,426
|
public function sendUserResetEMail ( \ Gems_User_User $ user ) { $ subjectTemplate = $ this -> _ ( 'Password reset requested' ) ; $ bbBodyTemplate = $ this -> _ ( "Dear {greeting},\n\n\nA new password was requested for your [b]{organization}[/b] account on the [b]{project}[/b] site, please click within {reset_in_hours} hours on [url={reset_url}]this link[/url] to enter the password of your choice.\n\n\n{organization_signature}\n\n[url={reset_url}]{reset_url}[/url]\n" ) ; return $ user -> sendMail ( $ subjectTemplate , $ bbBodyTemplate , true ) ; }
|
Send the user an e - mail with a link for password reset
|
58,427
|
protected function setCurrentOrganizationTo ( \ Gems_User_User $ user ) { if ( $ this -> currentUser !== $ user ) { $ this -> currentUser -> setCurrentOrganization ( $ user -> getCurrentOrganization ( ) ) ; } }
|
Helper function to safely switch org during login
|
58,428
|
private static function make ( $ characters , $ length ) { $ token = '' ; do { $ token .= $ characters [ random_int ( 0 , count ( $ characters ) - 1 ) ] ; } while ( strlen ( $ token ) < $ length ) ; return $ token ; }
|
Make the random string
|
58,429
|
protected function _loadClass ( $ name , $ create = false , array $ arguments = array ( ) ) { if ( $ this -> _loader instanceof Zalt \ Loader \ ProjectOverloader ) { $ className = $ this -> _loader -> find ( $ name ) ; } else { $ className = $ this -> _loader -> load ( $ name ) ; } if ( is_subclass_of ( $ className , __CLASS__ ) ) { $ create = true ; $ arguments = array ( ) ; if ( isset ( $ this -> _containers [ 0 ] ) ) { $ arguments [ ] = $ this -> _containers [ 0 ] ; } else { $ arguments [ ] = null ; } $ arguments [ ] = $ this -> _dirs ; if ( $ this -> _loader instanceof Zalt \ Loader \ ProjectOverloader ) { $ arguments [ ] = $ this -> _loader ; } } elseif ( is_subclass_of ( $ className , 'MUtil_Registry_TargetInterface' ) ) { $ create = true ; } if ( ! $ create ) { return new \ MUtil_Lazy_StaticCall ( $ className ) ; } if ( $ this -> _loader instanceof Zalt \ Loader \ ProjectOverloader ) { $ mergedArguments = array_merge ( [ 'className' => $ className ] , $ arguments ) ; $ obj = call_user_func_array ( [ $ this -> _loader , 'create' ] , $ mergedArguments ) ; } else { $ obj = $ this -> _loader -> createClass ( $ className , $ arguments ) ; } if ( $ obj instanceof \ MUtil_Registry_TargetInterface ) { if ( ( ! $ this -> applySource ( $ obj ) ) && parent :: $ verbose ) { \ MUtil_Echo :: r ( "Source apply to object of type $name failed." , __CLASS__ . '->' . __FUNCTION__ ) ; } } return $ obj ; }
|
Create or loads the class . When only loading this function returns a StaticCall object that can be invoked lazely .
|
58,430
|
private function _storeLogEntry ( \ Zend_Controller_Request_Abstract $ request , array $ row , $ force ) { if ( ! $ force ) { if ( isset ( $ this -> _sessionStore -> last ) && ( $ row === $ this -> _sessionStore -> last ) ) { return false ; } $ this -> _sessionStore -> last = $ row ; } try { $ this -> _db -> insert ( 'gems__log_activity' , $ row ) ; return true ; } catch ( \ Exception $ exc ) { \ Gems_Log :: getLogger ( ) -> logError ( $ exc , $ request ) ; $ this -> _warn ( ) ; return false ; } }
|
Stores the current log entry
|
58,431
|
private function _toCleanArray ( array $ data ) { switch ( count ( $ data ) ) { case 0 : return null ; case 1 : if ( isset ( $ data [ 0 ] ) ) { if ( is_array ( $ data [ 0 ] ) ) { return $ this -> _toCleanArray ( $ data [ 0 ] ) ; } else { return $ data [ 0 ] ; } } break ; case 2 : if ( isset ( $ data [ 0 ] , $ data [ 1 ] ) && is_string ( $ data [ 1 ] ) ) { if ( ( 'info' === $ data [ 1 ] ) || ( 'warning' === $ data [ 1 ] ) || ( 'error' === $ data [ 1 ] ) ) { if ( is_array ( $ data [ 0 ] ) ) { return $ this -> _toCleanArray ( $ data [ 0 ] ) ; } else { return $ data [ 0 ] ; } } } } $ output = array ( ) ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { $ output [ $ key ] = $ this -> _toCleanArray ( $ value ) ; } else { if ( is_string ( $ value ) ) { if ( \ MUtil_String :: contains ( $ key , 'password' , true ) || \ MUtil_String :: contains ( $ key , 'pwd' , true ) ) { $ value = '****' ; } } elseif ( $ value instanceof Zend_Date ) { $ value = $ value -> getIso ( ) ; } $ output [ $ key ] = $ value ; } } return $ output ; }
|
Remove password and pwd contents and clean up message status data and single item arrays
|
58,432
|
private function _toJson ( $ data ) { if ( $ data ) { if ( is_array ( $ data ) ) { return json_encode ( $ this -> _toCleanArray ( $ data ) ) ; } return json_encode ( $ data ) ; } }
|
Converts data types for storage
|
58,433
|
protected function getMessages ( ) { if ( ! $ this -> _messenger instanceof \ MUtil_Controller_Action_Helper_FlashMessenger ) { $ this -> _messenger = new \ MUtil_Controller_Action_Helper_FlashMessenger ( ) ; } return $ this -> _messenger -> getMessagesOnly ( ) ; }
|
The curent flash messenger messages
|
58,434
|
protected function _isTokenInFilter ( \ Gems_Tracker_Token $ token ) { $ result = false ; if ( $ token -> getReceptionCode ( ) -> isSuccess ( ) ) { $ result = true ; } if ( $ result ) { $ tokenInfo = array ( 'code' => $ token -> getSurvey ( ) -> getCode ( ) , 'surveyid' => $ token -> getSurveyId ( ) , 'tokenid' => $ token -> getTokenId ( ) ) ; if ( empty ( $ this -> tokenFilter ) ) { $ result = true ; } else { $ result = false ; foreach ( $ this -> tokenFilter as $ filter ) { $ remaining = array_diff_assoc ( $ filter , $ tokenInfo ) ; if ( empty ( $ remaining ) ) { $ result = true ; break ; } } } } return $ result ; }
|
Determines if this particular token should be included in the report
|
58,435
|
protected function _isTrackInFilter ( \ Gems_Tracker_RespondentTrack $ track ) { $ result = false ; $ trackInfo = array ( 'code' => $ track -> getCode ( ) , 'trackid' => $ track -> getTrackId ( ) , 'resptrackid' => $ track -> getRespondentTrackId ( ) , 'respid' => $ track -> getRespondentId ( ) , ) ; if ( empty ( $ this -> trackFilter ) ) { $ result = true ; } else { foreach ( $ this -> trackFilter as $ filter ) { $ remaining = array_diff_assoc ( $ filter , $ trackInfo ) ; if ( empty ( $ remaining ) ) { $ result = true ; break ; } } } if ( $ result && $ track -> getReceptionCode ( ) -> isSuccess ( ) ) { return true ; } return false ; }
|
Determines if this particular track should be included in the report
|
58,436
|
protected function _exportTrackTokens ( \ Gems_Tracker_RespondentTrack $ track ) { $ groupSurveys = $ this -> _group ; $ token = $ track -> getFirstToken ( ) ; $ engine = $ track -> getTrackEngine ( ) ; $ surveys = array ( ) ; $ table = $ this -> html -> table ( array ( 'class' => 'browser table' ) ) ; $ table -> th ( $ this -> _ ( 'Survey' ) ) -> th ( $ this -> _ ( 'Round' ) ) -> th ( $ this -> _ ( 'Token' ) ) -> th ( $ this -> _ ( 'Status' ) ) ; $ this -> html -> br ( ) ; while ( $ token ) { if ( ! $ this -> _isTokenInFilter ( $ token ) ) { $ token = $ token -> getNextToken ( ) ; continue ; } $ table -> tr ( ) -> td ( $ token -> getSurveyName ( ) ) -> td ( ( $ engine -> getTrackType ( ) == 'T' ? $ token -> getRoundDescription ( ) : $ this -> _ ( 'Single Survey' ) ) ) -> td ( strtoupper ( $ token -> getTokenId ( ) ) ) -> td ( $ token -> getStatus ( ) ) ; if ( ! $ this -> _displayToken ( $ token ) ) { $ token = $ token -> getNextToken ( ) ; continue ; } $ showToken = false ; if ( ! $ groupSurveys ) { $ showToken = true ; } else { if ( ! isset ( $ surveys [ $ token -> getSurveyId ( ) ] ) ) { $ showToken = true ; $ surveys [ $ token -> getSurveyId ( ) ] = 1 ; } } if ( $ showToken ) { $ params = array ( 'token' => $ token , 'tokenId' => $ token -> getTokenId ( ) , 'showHeaders' => false , 'showButtons' => false , 'showSelected' => false , 'showTakeButton' => false , 'grouped' => $ groupSurveys ) ; $ snippets = $ token -> getAnswerSnippetNames ( ) ; if ( ! is_array ( $ snippets ) ) { $ snippets = array ( $ snippets ) ; } list ( $ snippets , $ snippetParams ) = \ MUtil_Ra :: keySplit ( $ snippets ) ; $ params = $ params + $ snippetParams ; $ this -> html -> snippet ( 'Export_SurveyHeaderSnippet' , 'token' , $ token ) ; foreach ( $ snippets as $ snippet ) { $ this -> html -> snippet ( $ snippet , $ params ) ; } $ this -> html -> br ( ) ; } $ token = $ token -> getNextToken ( ) ; } }
|
Exports all the tokens of a single track grouped by round
|
58,437
|
protected function _exportTrack ( \ Gems_Tracker_RespondentTrack $ respTrack ) { if ( ! $ this -> _isTrackInFilter ( $ respTrack ) ) { return ; } $ trackModel = $ this -> loader -> getTracker ( ) -> getRespondentTrackModel ( ) ; $ trackModel -> applyDetailSettings ( $ respTrack -> getTrackEngine ( ) , false ) ; $ trackModel -> resetOrder ( ) ; $ trackModel -> set ( 'gtr_track_name' , 'label' , $ this -> _ ( 'Track' ) ) ; $ trackModel -> set ( 'gr2t_track_info' , 'label' , $ this -> _ ( 'Description' ) , 'description' , $ this -> _ ( 'Enter the particulars concerning the assignment to this respondent.' ) ) ; $ trackModel -> set ( 'assigned_by' , 'label' , $ this -> _ ( 'Assigned by' ) ) ; $ trackModel -> set ( 'gr2t_start_date' , 'label' , $ this -> _ ( 'Start' ) , 'formatFunction' , $ this -> util -> getTranslated ( ) -> formatDate , 'default' , \ MUtil_Date :: format ( new \ Zend_Date ( ) , 'dd-MM-yyyy' ) ) ; $ trackModel -> set ( 'gr2t_reception_code' ) ; $ trackModel -> set ( 'gr2t_comment' , 'label' , $ this -> _ ( 'Comment' ) ) ; $ trackModel -> setFilter ( array ( 'gr2t_id_respondent_track' => $ respTrack -> getRespondentTrackId ( ) ) ) ; $ trackData = $ trackModel -> loadFirst ( ) ; $ this -> html -> h4 ( $ this -> _ ( 'Track' ) . ' ' . $ trackData [ 'gtr_track_name' ] ) ; $ bridge = $ trackModel -> getBridgeFor ( 'itemTable' , array ( 'class' => 'browser table' ) ) ; $ bridge -> setRepeater ( \ MUtil_Lazy :: repeat ( array ( $ trackData ) ) ) ; $ bridge -> th ( $ this -> _ ( 'Track information' ) , array ( 'colspan' => 2 ) ) ; $ bridge -> setColumnCount ( 1 ) ; foreach ( $ trackModel -> getItemsOrdered ( ) as $ name ) { if ( $ label = $ trackModel -> get ( $ name , 'label' ) ) { $ bridge -> addItem ( $ name , $ label ) ; } } $ tableContainer = \ MUtil_Html :: create ( ) -> div ( array ( 'class' => 'table-container' ) ) ; $ tableContainer [ ] = $ bridge -> getTable ( ) ; $ this -> html [ ] = $ tableContainer ; $ this -> html -> br ( ) ; $ this -> _exportTrackTokens ( $ respTrack ) ; $ this -> html -> hr ( ) ; }
|
Exports a single track
|
58,438
|
protected function _exportRespondent ( $ respondentId ) { $ respondentModel = $ this -> loader -> getModels ( ) -> getRespondentModel ( false ) ; if ( is_array ( $ respondentId ) && isset ( $ respondentId [ 'gr2o_id_organization' ] ) ) { $ filter [ 'gr2o_id_organization' ] = $ respondentId [ 'gr2o_id_organization' ] ; $ respondentId = $ respondentId [ 'gr2o_patient_nr' ] ; } else { $ filter [ 'gr2o_id_organization' ] = array_keys ( $ this -> currentUser -> getAllowedOrganizations ( ) ) ; } $ filter [ 'gr2o_patient_nr' ] = $ respondentId ; $ respondentModel -> setFilter ( $ filter ) ; $ respondentData = $ respondentModel -> loadFirst ( ) ; $ this -> html -> snippet ( $ this -> _respondentSnippet , 'model' , $ respondentModel , 'data' , $ respondentData , 'respondentId' , $ respondentId ) ; $ tracker = $ this -> loader -> getTracker ( ) ; $ tracks = $ tracker -> getRespondentTracks ( $ respondentData [ 'gr2o_id_user' ] , $ respondentData [ 'gr2o_id_organization' ] ) ; foreach ( $ tracks as $ trackId => $ track ) { $ this -> _exportTrack ( $ track ) ; } }
|
Exports a single respondent
|
58,439
|
public function getForm ( $ hideGroup = false ) { $ form = new \ Gems_Form ( ) ; $ form -> setAttrib ( 'target' , '_blank' ) ; if ( $ hideGroup ) { $ element = new \ Zend_Form_Element_Hidden ( 'group' ) ; } else { $ element = new \ Zend_Form_Element_Checkbox ( 'group' ) ; $ element -> setLabel ( $ this -> _ ( 'Group surveys' ) ) ; } $ element -> setValue ( 1 ) ; $ form -> addElement ( $ element ) ; $ element = new \ Zend_Form_Element_Select ( 'format' ) ; $ element -> setLabel ( $ this -> _ ( 'Output format' ) ) ; $ outputFormats = array ( 'html' => 'HTML' ) ; if ( $ this -> _pdf -> hasPdfExport ( ) ) { $ outputFormats [ 'pdf' ] = 'PDF' ; $ element -> setValue ( 'pdf' ) ; } $ element -> setMultiOptions ( $ outputFormats ) ; $ form -> addElement ( $ element ) ; $ element = new \ Zend_Form_Element_Submit ( 'export' ) ; $ element -> setLabel ( $ this -> _ ( 'Export' ) ) -> setAttrib ( 'class' , 'button' ) ; $ form -> addElement ( $ element ) ; $ links = $ this -> menu -> getMenuList ( ) ; $ links -> addParameterSources ( $ this -> request , $ this -> menu -> getParameterSource ( ) ) ; $ links -> addCurrentParent ( $ this -> _ ( 'Cancel' ) ) ; if ( count ( $ links ) ) { $ element = new \ MUtil_Form_Element_Html ( 'menuLinks' ) ; $ element -> setValue ( $ links ) ; $ form -> addElement ( $ element ) ; } return $ form ; }
|
Constructs the form
|
58,440
|
protected function _checkDir ( $ directory ) { $ eDir = @ dir ( $ directory ) ; if ( false == $ eDir ) { if ( ! is_dir ( $ directory ) ) { if ( false === @ mkdir ( $ directory , 0777 , true ) ) { \ MUtil_Echo :: pre ( sprintf ( $ this -> translate -> _ ( 'Directory %s not found and unable to create' ) , $ directory ) , 'OpenRosa ERROR' ) ; } else { $ eDir = @ dir ( $ directory ) ; } } } return $ eDir ; }
|
Open the dir suppressing possible errors and try to create when it does not exist
|
58,441
|
public function checkSourceActive ( $ userId ) { $ active = true ; $ values [ 'gso_active' ] = $ active ? 1 : 0 ; $ values [ 'gso_status' ] = $ active ? 'Active' : 'Inactive' ; $ this -> _updateSource ( $ values , $ userId ) ; return $ active ; }
|
Checks wether this particular source is active or not and should handle updating the gems - db with the right information about this source
|
58,442
|
public function getToken ( $ tokenId ) { $ tracker = $ this -> loader -> getTracker ( ) ; $ token = $ tracker -> getToken ( $ tokenId ) ; return $ token ; }
|
Returns a Gems Tracker token from a token ID
|
58,443
|
protected function sourceFileExists ( $ filename ) { $ fullFilename = $ this -> formDir . $ filename ; if ( file_exists ( $ fullFilename ) ) { return true ; } return false ; }
|
Check if the xml file still exists in the directory
|
58,444
|
private function _checkForMailSent ( $ isNew , array $ context ) { if ( $ isNew ) { return false ; } if ( ! ( isset ( $ context [ 'gto_valid_from' ] ) && $ context [ 'gto_valid_from' ] ) ) { return false ; } $ hasSentDate = isset ( $ context [ 'gto_mail_sent_date' ] ) && $ context [ 'gto_mail_sent_date' ] ; if ( ! ( $ hasSentDate || ( isset ( $ context [ 'gto_mail_sent_num' ] ) && $ context [ 'gto_mail_sent_num' ] ) ) ) { return false ; } if ( ! $ hasSentDate ) { return true ; } if ( $ context [ 'gto_valid_from' ] instanceof \ Zend_Date ) { $ start = $ context [ 'gto_valid_from' ] ; } else { $ start = new \ MUtil_Date ( $ context [ 'gto_valid_from' ] , $ this -> get ( 'gto_valid_from' , 'dateFormat' ) ) ; } if ( $ context [ 'gto_mail_sent_date' ] instanceof \ Zend_Date ) { $ sent = $ context [ 'gto_mail_sent_date' ] ; } else { $ sent = new \ MUtil_Date ( $ context [ 'gto_mail_sent_date' ] , $ this -> get ( 'gto_mail_sent_date' , 'dateFormat' ) ) ; } return $ start -> isLater ( $ sent ) ; }
|
Function to check whether the mail_sent should be reset
|
58,445
|
public function addEditTracking ( ) { $ this -> addDependency ( new OffOnElementsDependency ( 'gto_valid_from_manual' , 'gto_valid_from' , 'readonly' , $ this ) ) ; $ this -> addDependency ( new OffOnElementsDependency ( 'gto_valid_until_manual' , 'gto_valid_until' , 'readonly' , $ this ) ) ; $ this -> set ( 'gto_valid_until' , 'validators[dateAfter]' , new \ MUtil_Validate_Date_DateAfter ( 'gto_valid_from' ) ) ; return $ this ; }
|
Add tracking off manual date changes by the user
|
58,446
|
public function backupAction ( ) { $ filter = $ this -> getSearchFilter ( ) ; $ model = $ this -> getModel ( ) ; $ tables = $ model -> load ( ) ; $ allTables = [ ] ; $ noDataTables = [ ] ; foreach ( $ tables as $ table ) { if ( $ table [ 'type' ] == 'view' && ( ! array_key_exists ( 'include_views' , $ filter ) || $ filter [ 'include_views' ] != '1' ) ) { continue ; } $ allTables [ ] = $ table [ 'name' ] ; if ( $ table [ 'respondentData' ] === true && ( ! array_key_exists ( 'include_respondent_data' , $ filter ) || $ filter [ 'include_respondent_data' ] != '1' ) ) { $ noDataTables [ ] = $ table [ 'name' ] ; } } $ filename = $ this -> getBackupFilename ( $ filter ) ; $ dbConfig = $ this -> getDatabaseConfig ( ) ; $ dumpSettings = [ 'include-tables' => $ allTables , 'no-data' => $ noDataTables , 'single-transaction' => true , 'lock-tables' => false , 'add-locks' => false , 'add-drop-table' => true , ] ; ini_set ( 'max_execution_time' , 300 ) ; try { $ dump = new \ Ifsnop \ Mysqldump \ Mysqldump ( $ dbConfig [ 'dsn' ] , $ dbConfig [ 'username' ] , $ dbConfig [ 'password' ] , $ dumpSettings ) ; $ dump -> start ( $ filename ) ; echo sprintf ( $ this -> _ ( 'Database backup completed. File can be found in %s' ) , $ filename ) ; } catch ( \ Exception $ e ) { echo 'mysqldump-php error: ' . $ e -> getMessage ( ) ; } }
|
Action for the actual backup of the database
|
58,447
|
protected function getDatabaseConfig ( ) { $ config = Zend_Controller_Front :: getInstance ( ) -> getParam ( 'bootstrap' ) ; $ resources = $ config -> getOption ( 'resources' ) ; $ dbConfig = [ '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' ] , 'dsn' => sprintf ( 'mysql:host=%s;dbname=%s' , $ resources [ 'db' ] [ 'params' ] [ 'host' ] , $ resources [ 'db' ] [ 'params' ] [ 'dbname' ] ) , ] ; return $ dbConfig ; }
|
Get the current database config including a DSN
|
58,448
|
public function visualBoolean ( $ value ) { if ( $ value === true ) { return \ MUtil_Html :: create ( ) -> i ( [ 'class' => 'fa fa-check' , 'style' => 'color: green;' ] ) ; } return \ MUtil_Html :: create ( ) -> i ( [ 'class' => 'fa fa-times' , 'style' => 'color: red;' ] ) ; }
|
Show a check or cross for true or false values
|
58,449
|
public function getOnEmptyText ( ) { static $ warned ; $ dir = $ this -> getPath ( false , 'index' ) ; if ( ! is_dir ( $ dir ) ) { try { \ MUtil_File :: ensureDir ( $ dir ) ; } catch ( \ Zend_Exception $ e ) { $ text = $ e -> getMessage ( ) ; if ( ! $ warned ) { $ warned = true ; $ this -> addMessage ( $ text ) ; } return $ text ; } } return parent :: getOnEmptyText ( ) ; }
|
Returns the on empty texts for the autofilter snippets
|
58,450
|
public function importAction ( ) { $ id = $ this -> _getIdParam ( ) ; $ model = $ this -> getModel ( ) ; $ data = $ model -> loadFirst ( array ( 'urlpath' => $ id ) ) ; if ( ! ( $ data && isset ( $ data [ 'fullpath' ] ) ) ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'File "%s" not found on the server.' ) , $ id ) ) ; return ; } $ importLoader = $ this -> loader -> getImportLoader ( ) ; $ importer = $ importLoader -> getFileImporter ( $ data [ 'fullpath' ] ) ; if ( ! $ importer ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'Automatic import not possible for file "%s".' ) , $ data [ 'relpath' ] ) ) ; return ; } $ batch = $ importer -> getCheckAndImportBatch ( ) ; $ title = $ this -> _ ( 'Import the file.' ) ; $ this -> _helper -> batchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> html -> pInfo ( $ this -> _ ( 'Checks this file for validity and then performs an import.' ) ) ; }
|
Import the file
|
58,451
|
public function createExcelDate ( \ DateTime $ date ) { $ day = clone $ date ; $ endDate = $ day -> setTime ( 0 , 0 , 0 ) ; $ startDate = new \ DateTime ( '1970-01-01 00:00:00' ) ; $ diff = $ endDate -> diff ( $ startDate ) -> format ( '%a' ) ; if ( $ endDate < $ startDate ) { $ daysBetween = 25569 - $ diff ; } else { $ daysBetween = 25569 + $ diff ; } $ seconds = $ date -> getTimestamp ( ) - $ endDate -> getTimestamp ( ) ; return ( float ) $ daysBetween + ( $ seconds / 86400 ) ; }
|
Create Excel date stamp from DateTime
|
58,452
|
public function copyAction ( ) { $ trackId = $ this -> _getIdParam ( ) ; $ engine = $ this -> getTrackEngine ( ) ; $ newTrackId = $ engine -> copyTrack ( $ trackId ) ; $ this -> _reroute ( array ( 'action' => 'edit' , \ MUtil_Model :: REQUEST_ID => $ newTrackId ) ) ; }
|
Action for making a copy of a track
|
58,453
|
public function exportAction ( ) { if ( $ this -> exportSnippets ) { $ params = $ this -> _processParameters ( $ this -> exportParameters ) ; $ this -> addSnippets ( $ this -> exportSnippets , $ params ) ; } }
|
Generic model based export action
|
58,454
|
public function showAction ( ) { $ showSnippets = $ this -> showSnippets ; $ first = array_shift ( $ showSnippets ) ; $ next = $ showSnippets ; $ this -> showSnippets = $ first ; parent :: showAction ( ) ; $ this -> showParameters [ 'tagName' ] = 'h3' ; $ this -> showSnippets = $ next ; parent :: showAction ( ) ; $ this -> showSnippets = array_unshift ( $ next , $ first ) ; }
|
Pass the h3 tag to all snippets except the first one
|
58,455
|
public function getMailer ( $ target = null , $ id = false , $ orgId = false ) { if ( isset ( $ this -> mailTargets [ $ target ] ) ) { $ target = ucfirst ( $ target ) ; return $ this -> _loadClass ( $ target . 'Mailer' , true , array ( $ id , $ orgId ) ) ; } else { return false ; } }
|
Get the correct mailer class from the given target
|
58,456
|
protected function loadCronBatch ( \ Gems_Task_TaskRunnerBatch $ batch ) { $ batch -> addMessage ( sprintf ( $ this -> _ ( "Starting %s mail jobs" ) , $ this -> project -> getName ( ) ) ) ; $ batch -> addTask ( 'Mail\\AddAllMailJobsTask' ) ; $ tracker = $ this -> loader -> getTracker ( ) ; $ tracker -> loadCompletedTokensBatch ( $ batch , null , $ this -> currentUser -> getUserId ( ) ) ; }
|
Perform the actions and load the tasks needed to start the cron batch
|
58,457
|
protected function _load ( array $ filter , array $ sort ) { $ result = array ( ) ; foreach ( $ this -> getItemsOrdered ( ) as $ item ) { $ result [ 0 ] [ $ item ] = $ item ; } return $ result ; }
|
Returns a nested array containing the items requested .
|
58,458
|
protected function inlineIssueLink ( $ excerpt ) { if ( preg_match ( '/([\p{L}\p{N}_-]*)\/?([\p{L}\p{N}_-]*)#(\d+)/ui' , $ excerpt [ 'context' ] , $ matches , PREG_OFFSET_CAPTURE ) ) { if ( ! empty ( $ matches [ 1 ] [ 0 ] ) ) { $ project = $ matches [ 1 ] [ 0 ] . '/' . $ matches [ 2 ] [ 0 ] ; } else { $ project = $ this -> projectName ; } $ url = sprintf ( '%s/%s/issues/%s' , $ this -> GitHub , $ project , $ matches [ 3 ] [ 0 ] ) ; $ inline = array ( 'extent' => strlen ( $ matches [ 0 ] [ 0 ] ) , 'position' => $ matches [ 0 ] [ 1 ] , 'element' => array ( 'name' => 'a' , 'text' => '#' . $ matches [ 3 ] [ 0 ] , 'attributes' => array ( 'href' => $ url , ) , ) , ) ; return $ inline ; } }
|
Find links to issue on github
|
58,459
|
protected function findRespondentTrackFor ( array $ row ) { if ( ! ( isset ( $ row [ $ this -> patientNrField ] , $ row [ $ this -> orgIdField ] ) && $ row [ $ this -> patientNrField ] && $ row [ $ this -> orgIdField ] ) ) { return null ; } $ trackId = $ this -> getTrackId ( ) ; if ( ! $ trackId ) { return null ; } $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__respondent2track' , array ( 'gr2t_id_respondent_track' ) ) -> joinInner ( 'gems__respondent2org' , 'gr2t_id_user = gr2o_id_user AND gr2t_id_organization = gr2o_id_organization' , array ( ) ) -> where ( 'gr2o_patient_nr = ?' , $ row [ $ this -> patientNrField ] ) -> where ( 'gr2o_id_organization = ?' , $ row [ $ this -> orgIdField ] ) -> where ( 'gr2t_id_track = ?' ) ; $ select -> order ( new \ Zend_Db_Expr ( "CASE WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NULL THEN 1 WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NOT NULL THEN 2 ELSE 3 END ASC" ) ) -> order ( 'gr2t_start_date DESC' ) -> order ( 'gr2t_end_date DESC' ) -> order ( 'gr2t_created' ) ; $ respTrack = $ this -> db -> fetchOne ( $ select ) ; if ( $ respTrack ) { return $ respTrack ; } return null ; }
|
If the token can be created find the respondent track for the token
|
58,460
|
public function getCopyFields ( $ requests ) { $ prefix = 'CP' ; $ token = $ this -> token ; $ surveyCode = $ token -> getSurvey ( ) -> getCode ( ) ; $ surveyId = $ token -> getSurveyId ( ) ; $ flipRequests = array_flip ( $ requests ) ; $ prev = $ token -> getRespondentTrack ( ) -> getLastToken ( ) ; do { if ( $ prev -> getReceptionCode ( ) -> isSuccess ( ) && $ prev -> isCompleted ( ) ) { if ( $ prev -> getSurveyId ( ) === $ surveyId || ( ! empty ( $ surveyCode ) && $ prev -> getSurvey ( ) -> getCode ( ) === $ surveyCode ) ) { $ answers = $ prev -> getRawAnswers ( ) ; $ answersUc = array_change_key_case ( $ answers , CASE_UPPER ) ; $ values = array_intersect_key ( $ answersUc , $ flipRequests ) ; if ( count ( $ values ) !== count ( $ requests ) ) { $ missing = array_diff_key ( $ flipRequests , $ values ) ; foreach ( $ missing as $ key => $ value ) { $ prefixKey = $ prefix . $ key ; if ( array_key_exists ( $ prefixKey , $ answersUc ) ) { $ values [ $ key ] = $ answersUc [ $ prefixKey ] ; } } } $ results = [ ] ; foreach ( $ values as $ key => $ value ) { $ newKey = $ flipRequests [ $ key ] ; $ results [ $ newKey ] = $ value ; } return $ results ; } } } while ( $ prev = $ prev -> getPreviousToken ( ) ) ; return [ ] ; }
|
Tries to fulfill request to copy fields
|
58,461
|
public function getRespondentFields ( $ requests ) { $ token = $ this -> token ; $ results = [ ] ; $ respondent = $ token -> getRespondent ( ) ; foreach ( $ requests as $ original => $ upperField ) { switch ( $ upperField ) { case 'AGE' : $ results [ $ original ] = $ respondent -> getAge ( ) ; break ; case 'SEX' : $ results [ $ original ] = $ respondent -> getGender ( ) ; break ; case 'BIRTHDATE' : $ birthDate = $ respondent -> getBirthday ( ) ; if ( ! is_null ( $ birthDate ) && $ birthDate instanceof \ MUtil_Date ) { $ birthDate = $ birthDate -> get ( 'yyyy-MM-dd' ) ; $ results [ $ original ] = $ birthDate ; } break ; default : break ; } } return $ results ; }
|
Tries to fulfill request to respondent fields
|
58,462
|
public function getTrackFields ( $ requests ) { $ token = $ this -> token ; $ results = [ ] ; $ respondentTrack = $ token -> getRespondentTrack ( ) ; $ fieldCodes = $ respondentTrack -> getCodeFields ( ) ; $ rawFieldData = $ respondentTrack -> getFieldData ( ) ; $ keysMixed = array_keys ( $ fieldCodes ) ; $ keysUpper = array_change_key_case ( $ fieldCodes , CASE_UPPER ) ; $ fieldCodesMap = array_combine ( array_keys ( $ keysUpper ) , $ keysMixed ) ; foreach ( $ requests as $ original => $ upperField ) { if ( array_key_exists ( $ upperField , $ fieldCodesMap ) ) { $ trackField = $ fieldCodesMap [ $ upperField ] ; $ value = $ fieldCodes [ $ trackField ] ; if ( array_key_exists ( $ trackField , $ rawFieldData ) && $ rawFieldData [ $ trackField ] instanceof \ MUtil_Date ) { $ value = $ rawFieldData [ $ trackField ] -> get ( 'yyyy-MM-dd HH:mm:ss' ) ; } $ results [ $ original ] = $ value ; } } return $ results ; }
|
Tries to fulfill request to track fields
|
58,463
|
protected function createMultiOption ( array $ requestData , $ name , $ email , $ extra = null , $ disabledTitle = false , $ menuFind = false ) { return $ this -> mailElements -> getEmailOption ( $ requestData , $ name , $ email , $ extra , $ disabledTitle , $ menuFind ) ; }
|
Create the option values with links for the select
|
58,464
|
protected function getModel ( ) { if ( ! $ this -> model ) { $ this -> model = $ this -> createModel ( ) ; $ this -> prepareModel ( $ this -> model ) ; } return $ this -> model ; }
|
Returns the model always use this function
|
58,465
|
protected function setAfterSendRoute ( ) { if ( $ this -> routeAction && ( $ this -> request -> getActionName ( ) !== $ this -> routeAction ) ) { $ this -> afterSendRouteUrl = array ( 'action' => $ this -> routeAction ) ; $ keys = $ this -> model -> getKeys ( ) ; if ( count ( $ keys ) == 1 ) { $ key = reset ( $ keys ) ; if ( isset ( $ this -> formData [ $ key ] ) ) { $ this -> afterSendRouteUrl [ \ MUtil_Model :: REQUEST_ID ] = $ this -> formData [ $ key ] ; } } else { $ i = 1 ; foreach ( $ keys as $ key ) { if ( isset ( $ this -> formData [ $ key ] ) ) { $ this -> afterSendRouteUrl [ \ MUtil_Model :: REQUEST_ID . $ i ] = $ this -> formData [ $ key ] ; } $ i ++ ; } } $ this -> afterSendRouteUrl [ 'controller' ] = $ this -> request -> getControllerName ( ) ; $ find [ 'action' ] = $ this -> afterSendRouteUrl [ 'action' ] ; $ find [ 'controller' ] = $ this -> afterSendRouteUrl [ 'controller' ] ; if ( null == $ this -> menu -> find ( $ find ) ) { $ this -> afterSendRouteUrl [ 'action' ] = 'index' ; $ this -> resetRoute = true ; } } }
|
Set the route destination after the mail is sent
|
58,466
|
public function shorten ( $ num ) { $ str = '' ; while ( $ num > 0 ) { $ str = $ this -> alphabet [ ( $ num % $ this -> base ) ] . $ str ; $ num = ( int ) ( $ num / $ this -> base ) ; } return $ str ; }
|
Converts the specified integer ID to a short string
|
58,467
|
public function unshorten ( $ str ) { $ num = 0 ; $ len = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ num = $ num * $ this -> base + strpos ( $ this -> alphabet , $ str [ $ i ] ) ; } return $ num ; }
|
Converts the specified short string to an integer ID
|
58,468
|
public function index ( ) { $ credit = Smsir :: credit ( ) ; $ smsir_logs = SmsirLogs :: orderBy ( 'id' , 'DESC' ) -> paginate ( config ( 'smsir.in-page' ) ) ; return view ( 'smsir::index' , compact ( 'credit' , 'smsir_logs' ) ) ; }
|
the main index page for administrators
|
58,469
|
public static function getToken ( ) { $ client = new Client ( ) ; $ body = [ 'UserApiKey' => config ( 'smsir.api-key' ) , 'SecretKey' => config ( 'smsir.secret-key' ) , 'System' => 'laravel_v_1_4' ] ; $ result = $ client -> post ( 'http://restfulsms.com/api/Token' , [ 'json' => $ body , 'connect_timeout' => 30 ] ) ; return json_decode ( $ result -> getBody ( ) , true ) [ 'TokenKey' ] ; }
|
this method used in every request to get the token at first .
|
58,470
|
public static function send ( $ messages , $ numbers , $ sendDateTime = null ) { $ client = new Client ( ) ; $ messages = ( array ) $ messages ; $ numbers = ( array ) $ numbers ; if ( $ sendDateTime === null ) { $ body = [ 'Messages' => $ messages , 'MobileNumbers' => $ numbers , 'LineNumber' => config ( 'smsir.line-number' ) ] ; } else { $ body = [ 'Messages' => $ messages , 'MobileNumbers' => $ numbers , 'LineNumber' => config ( 'smsir.line-number' ) , 'SendDateTime' => $ sendDateTime ] ; } $ result = $ client -> post ( 'http://restfulsms.com/api/MessageSend' , [ 'json' => $ body , 'headers' => [ 'x-sms-ir-secure-token' => self :: getToken ( ) ] , 'connect_timeout' => 30 ] ) ; self :: DBlog ( $ result , $ messages , $ numbers ) ; return json_decode ( $ result -> getBody ( ) , true ) ; }
|
Simple send message with sms . ir account and line number
|
58,471
|
public static function sendVerification ( $ code , $ number , $ log = false ) { $ client = new Client ( ) ; $ body = [ 'Code' => $ code , 'MobileNumber' => $ number ] ; $ result = $ client -> post ( 'http://restfulsms.com/api/VerificationCode' , [ 'json' => $ body , 'headers' => [ 'x-sms-ir-secure-token' => self :: getToken ( ) ] , 'connect_timeout' => 30 ] ) ; if ( $ log ) { self :: DBlog ( $ result , $ code , $ number ) ; } return json_decode ( $ result -> getBody ( ) , true ) ; }
|
this method send a verification code to your customer . need active the module at panel first .
|
58,472
|
public static function getReceivedMessages ( $ perPage , $ pageNumber , $ formDate , $ toDate ) { $ client = new Client ( ) ; $ result = $ client -> get ( "http://restfulsms.com/api/ReceiveMessage?Shamsi_FromDate={$formDate}&Shamsi_ToDate={$toDate}&RowsPerPage={$perPage}&RequestedPageNumber={$pageNumber}" , [ 'headers' => [ 'x-sms-ir-secure-token' => self :: getToken ( ) ] , 'connect_timeout' => 30 ] ) ; return json_decode ( $ result -> getBody ( ) -> getContents ( ) ) -> Messages ; }
|
this method used for fetch received messages
|
58,473
|
protected function validator ( ) : Validator { if ( isset ( $ this -> validator ) ) { return $ this -> validator ; } return $ this -> validator = $ this -> laravel [ 'validator' ] -> make ( $ this -> getDataToValidate ( ) , $ this -> rules ( ) , $ this -> messages ( ) , $ this -> attributes ( ) ) ; }
|
Retrieve the command input validator
|
58,474
|
protected function getDataToValidate ( ) : array { $ data = array_merge ( $ this -> argument ( ) , $ this -> option ( ) ) ; return array_filter ( $ data , function ( $ value ) { return $ value !== null ; } ) ; }
|
Retrieve the data to validate
|
58,475
|
protected function formatErrors ( ) : string { $ errors = implode ( PHP_EOL , $ this -> getErrorMessages ( ) ) ; return PHP_EOL . PHP_EOL . $ errors . PHP_EOL ; }
|
Format the validation errors
|
58,476
|
public function handle ( ) : void { $ this -> info ( 'Crafting application..' ) ; $ this -> composer -> createProject ( 'laravel-zero/laravel-zero' , $ this -> argument ( 'name' ) , [ '--prefer-dist' ] ) ; $ this -> comment ( 'Application ready! Build something amazing.' ) ; }
|
Execute the command . Here goes the code .
|
58,477
|
public function addTask ( Task $ task ) { if ( ! isset ( $ this -> tasks [ $ task -> uniq ] ) ) { $ this -> tasks [ $ task -> uniq ] = $ task ; ++ $ this -> tasksCount ; } }
|
Add a task to the set .
|
58,478
|
public function finished ( ) { if ( $ this -> tasksCount == 0 ) { if ( isset ( $ this -> callback ) ) { $ results = array ( ) ; foreach ( $ this -> tasks as $ task ) { $ results [ ] = $ task -> result ; } call_user_func ( $ this -> callback , $ results ) ; } return true ; } return false ; }
|
Is this set finished running?
|
58,479
|
private function ensureOrderColumnExists ( ) { $ attributes = $ this -> connection -> createQueryBuilder ( ) -> select ( 'metamodel.tableName' , 'attribute.colname' ) -> from ( 'tl_metamodel_attribute' , 'attribute' ) -> leftJoin ( 'attribute' , 'tl_metamodel' , 'metamodel' , 'metamodel.id=attribute.pid' ) -> where ( 'attribute.type=:type' ) -> setParameter ( 'type' , 'file' ) -> andWhere ( 'attribute.file_multiple=:multiple' ) -> setParameter ( 'multiple' , '1' ) -> execute ( ) ; while ( $ row = $ attributes -> fetch ( \ PDO :: FETCH_OBJ ) ) { if ( $ this -> fieldExists ( $ row -> colname . '__sort' , $ row -> tableName ) ) { continue ; } $ this -> connection -> exec ( \ sprintf ( 'ALTER TABLE %1$s ADD COLUMN %2$s__sort %3$s' , $ row -> tableName , $ row -> colname , 'blob NULL' ) ) ; } }
|
Ensure that the order column exists .
|
58,480
|
private function fieldExists ( $ tableName , $ columnName ) : bool { if ( ! \ array_key_exists ( $ tableName , $ this -> schemaCache ) ) { $ this -> schemaCache [ $ tableName ] = $ this -> connection -> getSchemaManager ( ) -> listTableColumns ( $ tableName ) ; } return isset ( $ this -> schemaCache [ $ tableName ] [ $ columnName ] ) ; }
|
Test if a column exists in a table .
|
58,481
|
private function quoteReservedWord ( string $ word ) : string { if ( null === $ this -> platformReservedWord ) { try { $ this -> platformReservedWord = $ this -> connection -> getDatabasePlatform ( ) -> getReservedKeywordsList ( ) ; } catch ( DBALException $ exception ) { $ this -> platformReservedWord = new NotSupportedKeywordList ( ) ; } } if ( false === $ this -> platformReservedWord -> isKeyword ( $ word ) ) { return $ word ; } return $ this -> connection -> quoteIdentifier ( $ word ) ; }
|
Quote the reserved platform key word .
|
58,482
|
public function handleUpdateAttribute ( PostPersistModelEvent $ event ) { $ model = $ event -> getModel ( ) ; if ( ( 'file' !== $ model -> getProperty ( 'type' ) ) || ( ! $ model -> getProperty ( 'file_multiple' ) ) || ( 'tl_metamodel_attribute' !== $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) ) ) { return ; } $ metaModelsName = $ this -> getFactory ( ) -> translateIdToMetaModelName ( $ model -> getProperty ( 'pid' ) ) ; $ metaModel = $ this -> getFactory ( ) -> getMetaModel ( $ metaModelsName ) ; $ attributeName = $ model -> getProperty ( 'colname' ) . '__sort' ; $ tableColumns = $ this -> connection -> getSchemaManager ( ) -> listTableColumns ( $ metaModel -> getTableName ( ) ) ; if ( \ array_key_exists ( $ attributeName , $ tableColumns ) ) { return ; } $ this -> tableManipulator -> createColumn ( $ metaModel -> getTableName ( ) , $ attributeName , 'blob NULL' ) ; }
|
Handle the update of the file attribute if switch on for file multiple .
|
58,483
|
public function version ( ) { $ this -> sendCommand ( 'version' ) ; $ res = fgets ( $ this -> conn , 4096 ) ; $ this -> checkForError ( $ res ) ; return trim ( $ res ) ; }
|
Get the version of Gearman running .
|
58,484
|
public function shutdown ( $ graceful = false ) { $ cmd = ( $ graceful ) ? 'shutdown graceful' : 'shutdown' ; $ this -> sendCommand ( $ cmd ) ; $ res = fgets ( $ this -> conn , 4096 ) ; $ this -> checkForError ( $ res ) ; $ this -> shutdown = ( trim ( $ res ) == 'OK' ) ; return $ this -> shutdown ; }
|
Shut down Gearman .
|
58,485
|
public function workers ( ) { $ this -> sendCommand ( 'workers' ) ; $ res = $ this -> recvCommand ( ) ; $ workers = array ( ) ; $ tmp = explode ( "\n" , $ res ) ; foreach ( $ tmp as $ t ) { if ( ! Connection :: stringLength ( $ t ) ) { continue ; } $ info = explode ( ' : ' , $ t ) ; list ( $ fd , $ ip , $ id ) = explode ( ' ' , $ info [ 0 ] ) ; $ abilities = isset ( $ info [ 1 ] ) ? trim ( $ info [ 1 ] ) : '' ; $ workers [ ] = array ( 'fd' => $ fd , 'ip' => $ ip , 'id' => $ id , 'abilities' => empty ( $ abilities ) ? array ( ) : explode ( ' ' , $ abilities ) , ) ; } return $ workers ; }
|
Get worker status and info .
|
58,486
|
public function setMaxQueueSize ( $ function , $ size ) { if ( ! is_numeric ( $ size ) ) { throw new Exception ( 'Queue size must be numeric' ) ; } if ( preg_match ( '/[^a-z0-9_]/i' , $ function ) ) { throw new Exception ( 'Invalid function name' ) ; } $ this -> sendCommand ( 'maxqueue ' . $ function . ' ' . $ size ) ; $ res = fgets ( $ this -> conn , 4096 ) ; $ this -> checkForError ( $ res ) ; return ( trim ( $ res ) == 'OK' ) ; }
|
Set maximum queue size for a function .
|
58,487
|
protected function sendCommand ( $ cmd ) { if ( $ this -> shutdown ) { throw new Exception ( 'This server has been shut down' ) ; } fwrite ( $ this -> conn , $ cmd . "\r\n" , Connection :: stringLength ( $ cmd . "\r\n" ) ) ; }
|
Send a command .
|
58,488
|
protected function recvCommand ( ) { $ ret = '' ; while ( true ) { $ data = fgets ( $ this -> conn , 4096 ) ; $ this -> checkForError ( $ data ) ; if ( $ data == ".\n" ) { break ; } $ ret .= $ data ; } return $ ret ; }
|
Receive a response .
|
58,489
|
public function register ( ) { $ facade = new Payment ( ) ; $ this -> app -> instance ( '\Payment' , $ facade ) ; $ this -> app -> instance ( PaymentFacade :: class , $ facade ) ; }
|
Bind two classes
|
58,490
|
public function addInformation ( CollectMetaModelAttributeInformationEvent $ event ) { if ( ! \ count ( $ information = $ event -> getAttributeInformation ( ) ) ) { return ; } if ( ! \ count ( $ fileInformation = $ this -> collectFileInformation ( $ information ) ) ) { return ; } $ event -> setAttributeInformation ( $ this -> updateInformation ( $ fileInformation , $ information ) ) ; }
|
Add the information .
|
58,491
|
private function updateInformation ( array $ inputInformation , array $ updateInformation ) { foreach ( $ inputInformation as $ name => $ information ) { $ columnName = $ information [ 'colname' ] . '__sort' ; $ position = \ array_flip ( \ array_keys ( $ updateInformation ) ) [ $ name ] ; $ updateInformation = \ array_merge ( \ array_slice ( $ updateInformation , 0 , ( $ position + 1 ) ) , [ $ columnName => [ 'colname' => $ columnName , 'type' => 'filesort' ] ] , \ array_slice ( $ updateInformation , ( $ position ? $ position - 1 : $ position + 1 ) ) ) ; } return $ updateInformation ; }
|
Update the information .
|
58,492
|
public function dispatch ( ServerRequestInterface $ request , callable $ default ) { $ handler = new Handler ( $ this -> middleware , $ default ) ; return $ handler -> handle ( $ request ) ; }
|
Dispatch the middleware stack .
|
58,493
|
final protected function getValueFromConfig ( string $ param ) { $ value = null ; $ config = self :: $ suiteConfig ; preg_match_all ( self :: $ regEx [ 'config' ] , $ param , $ args , PREG_PATTERN_ORDER ) ; foreach ( $ args [ 1 ] as $ arg ) { if ( array_key_exists ( $ arg , $ config ) ) { $ value = $ config [ $ arg ] ; if ( is_array ( $ value ) ) { $ config = $ value ; } else { break ; } } } return $ value ; }
|
Retrieve param value from current suite config
|
58,494
|
final protected function getValueFromArray ( string $ param ) { $ value = null ; preg_match_all ( self :: $ regEx [ 'array' ] , $ param , $ args ) ; $ array = Fixtures :: get ( $ args [ 'var' ] [ 0 ] ) ; if ( array_key_exists ( $ args [ 'key' ] [ 0 ] , $ array ) ) { $ value = $ array [ $ args [ 'key' ] [ 0 ] ] ; } return $ value ; }
|
Retrieve param value from array in Fixtures
|
58,495
|
final public function beforeStep ( \ Codeception \ Event \ StepEvent $ e ) { $ step = $ e -> getStep ( ) ; $ refArgs = new ReflectionProperty ( get_class ( $ step ) , 'arguments' ) ; $ refArgs -> setAccessible ( true ) ; $ args = $ refArgs -> getValue ( $ step ) ; foreach ( $ args as $ index => $ arg ) { if ( is_string ( $ arg ) ) { $ args [ $ index ] = $ this -> getValueFromParam ( $ arg ) ; } elseif ( is_a ( $ arg , '\Behat\Gherkin\Node\TableNode' ) ) { $ table = [ ] ; foreach ( $ arg -> getRows ( ) as $ i => $ row ) { foreach ( $ row as $ j => $ cell ) { $ table [ $ i ] [ $ j ] = $ this -> getValueFromParam ( $ cell ) ; } } $ args [ $ index ] = new TableNode ( $ table ) ; } } $ refArgs -> setValue ( $ step , $ args ) ; }
|
Parse scenario s step before execution
|
58,496
|
public function buildAttribute ( BuildAttributeEvent $ event ) { $ attribute = $ event -> getAttribute ( ) ; if ( ! ( $ attribute instanceof File ) || ! $ attribute -> get ( 'file_multiple' ) ) { return ; } $ container = $ event -> getContainer ( ) ; $ properties = $ container -> getPropertiesDefinition ( ) ; $ name = $ attribute -> getColName ( ) ; $ nameSort = \ sprintf ( '%s__sort' , $ name ) ; if ( $ properties -> hasProperty ( $ nameSort ) ) { $ this -> addAttributeToDefinition ( $ container , $ name ) ; $ properties -> getProperty ( $ name . '__sort' ) -> setWidgetType ( 'fileTreeOrder' ) ; return ; } $ properties -> addProperty ( $ property = new DefaultProperty ( $ name . '__sort' ) ) ; $ property -> setWidgetType ( 'fileTreeOrder' ) ; $ this -> addAttributeToDefinition ( $ container , $ name ) ; }
|
This builds the dc - general property information for the virtual file order attribute .
|
58,497
|
private function addAttributeToDefinition ( ContainerInterface $ container , $ name ) { if ( ! $ container -> hasDefinition ( 'metamodels.file-attributes' ) ) { $ container -> setDefinition ( 'metamodels.file-attributes' , new AttributeFileDefinition ( ) ) ; } $ container -> getDefinition ( 'metamodels.file-attributes' ) -> add ( $ name ) ; }
|
Add attribute to MetaModels file attributes definition .
|
58,498
|
public function getJsonObject ( ) { $ this -> sslRoutingRestrictedUrls = array_values ( array_filter ( $ this -> sslRoutingRestrictedUrls ) ) ; $ this -> maintenanceModeAuthorizedIps = array_values ( array_filter ( $ this -> maintenanceModeAuthorizedIps ) ) ; return json_encode ( get_object_vars ( $ this ) ) ; }
|
Returns all properties and their values in JSON format
|
58,499
|
function it_receives_null_when_the_api_returns_404 ( ) { $ code = 404 ; $ this -> httpClient -> sendRequest ( Argument :: type ( 'Psr\Http\Message\RequestInterface' ) ) -> willReturn ( new Response ( $ code , [ 'Content-type' => 'application/json' ] ) ) ; $ response = $ this -> getNotification ( '35836a9e-5a97-4d99-8309-0c5a2c3dbc72' ) ; $ response -> shouldBeNull ( ) ; }
|
Actions with expected errors
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.