idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
58,000
public function getTokenTableStructure ( ) { $ tableName = $ this -> _getTokenTableName ( ) ; $ table = new \ Zend_DB_Table ( array ( 'name' => $ tableName , 'db' => $ this -> lsDb ) ) ; $ info = $ table -> info ( ) ; $ metaData = $ info [ 'metadata' ] ; return $ metaData ; }
Get the table structure of the token table
58,001
public function parse ( $ line ) { $ this -> error = false ; $ this -> currentTextLineContainer = $ this -> textLineContainers [ $ this -> config -> defaultTextLineContainer ] ; $ firsttag = clone ( $ this -> currentTextLineContainer -> tag ) ; $ this -> str = preg_split ( $ this -> currentTextLineContainer -> pattern , $ line , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ this -> end = count ( $ this -> str ) ; if ( $ this -> end > 1 ) { $ pos = - 1 ; $ this -> _parse ( $ firsttag , $ pos ) ; return $ firsttag -> getContent ( ) ; } else { $ firsttag -> addContentString ( $ line ) ; return $ firsttag -> getContent ( ) ; } }
Main function which parses a line of wiki content .
58,002
protected function downloadExportFile ( ) { $ this -> view -> layout ( ) -> disableLayout ( ) ; \ Zend_Controller_Action_HelperBroker :: getExistingHelper ( 'viewRenderer' ) -> setNoRender ( true ) ; $ batch = $ this -> getExportBatch ( false ) ; $ downloadName = $ batch -> getSessionVariable ( 'downloadname' ) ; $ localFilename = $ batch -> getSessionVariable ( 'filename' ) ; header ( "Content-Type: application/download" ) ; header ( "Content-Disposition: attachment; filename=\"$downloadName\"" ) ; header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ) ; header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . " GMT" ) ; header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ) ; header ( "Pragma: cache" ) ; readfile ( $ localFilename ) ; exit ( ) ; }
Performs actual download
58,003
public function validationApplies ( ) { $ return = true ; if ( $ criteria = $ this -> owner -> validationLogicCriteria ) { $ fields = $ this -> owner -> rootFieldList ( ) ; if ( eval ( $ criteria -> phpEvalString ( ) ) === false ) { throw new Exception ( "There is a syntax error in the constaint logic phpEvalString \"{$criteria->phpEvalString()}\"" ) ; } $ return = eval ( 'return ' . $ criteria -> phpEvalString ( ) ) ; } return $ return ; }
Checks to see if any ValidationLogicCriteria has been set and if so should the validation constraints still be applied
58,004
public function checkTransport ( $ from ) { if ( ! array_key_exists ( $ from , self :: $ mailServers ) ) { $ sql = 'SELECT * FROM gems__mail_servers WHERE ? LIKE gms_from ORDER BY LENGTH(gms_from) DESC LIMIT 1' ; $ serverData = $ this -> db -> fetchRow ( $ sql , $ from ) ; if ( isset ( $ serverData [ 'gms_server' ] ) ) { $ options = array ( ) ; if ( isset ( $ serverData [ 'gms_user' ] , $ serverData [ 'gms_password' ] ) ) { $ options [ 'auth' ] = 'login' ; $ options [ 'username' ] = $ serverData [ 'gms_user' ] ; $ options [ 'password' ] = $ this -> project -> decrypt ( $ serverData [ 'gms_password' ] ) ; } if ( isset ( $ serverData [ 'gms_port' ] ) ) { $ options [ 'port' ] = $ serverData [ 'gms_port' ] ; } if ( isset ( $ serverData [ 'gms_ssl' ] ) ) { switch ( $ serverData [ 'gms_ssl' ] ) { case self :: MAIL_SSL : $ options [ 'ssl' ] = 'ssl' ; break ; case self :: MAIL_TLS : $ options [ 'ssl' ] = 'tls' ; break ; default : } } self :: $ mailServers [ $ from ] = new \ Zend_Mail_Transport_Smtp ( $ serverData [ 'gms_server' ] , $ options ) ; } else { self :: $ mailServers [ $ from ] = $ this -> getDefaultTransport ( ) ; } } return self :: $ mailServers [ $ from ] ; }
Returns \ Zend_Mail_Transport_Abstract when something else than the default mail protocol should be used .
58,005
public function setTemplateStyle ( $ style = null ) { if ( null == $ style ) { $ style = GEMS_PROJECT_NAME ; } $ this -> setHtmlTemplateFile ( APPLICATION_PATH . '/configs/email/' . $ style . '.html' ) ; return $ this ; }
Set the template using style as basis
58,006
public function isDeleteable ( $ roundId ) { if ( ! $ roundId ) { return true ; } $ sql = "SELECT gto_id_token FROM gems__tokens WHERE gto_id_round = ? AND gto_start_time IS NOT NULL" ; return ( boolean ) ! $ this -> db -> fetchOne ( $ sql , $ roundId ) ; }
Can this round be deleted as is?
58,007
private function _ ( $ messageId , $ locale = null ) { if ( $ this -> translate ) { return $ this -> translate -> _ ( $ messageId , $ locale ) ; } return $ messageId ; }
proxy for easy access to translations
58,008
public function reset ( $ id ) { $ template = $ this -> load ( array ( 'name' => $ id ) ) ; $ result = false ; if ( count ( $ template ) == 1 ) { if ( unlink ( $ this -> _path . '/template-local.ini' ) ) { $ this -> _templates = false ; $ this -> _template = '' ; $ template = $ this -> load ( array ( 'name' => $ id ) ) ; $ this -> saveTemplate ( $ id , $ template [ $ id ] ) ; $ result = true ; } } return $ result ; }
Reset a template to it s default values by deleteing template - local . ini
58,009
protected function getEveryOption ( ) { return [ 'notmailed' => $ this -> _ ( 'Not emailed' ) , 'tomail' => $ this -> _ ( 'To email' ) , 'toremind' => $ this -> _ ( 'Needs reminder' ) , 'hasnomail' => $ this -> _ ( 'Missing email' ) , 'notmailable' => $ this -> _ ( 'Not allowed to email' ) , ] ; }
The sued options
58,010
public function errorAction ( ) { $ errors = $ this -> _getParam ( 'error_handler' ) ; $ exception = $ errors -> exception ; $ info = null ; $ message = 'Application error' ; $ responseCode = 200 ; switch ( $ errors -> type ) { case \ Zend_Controller_Plugin_ErrorHandler :: EXCEPTION_NO_CONTROLLER : case \ Zend_Controller_Plugin_ErrorHandler :: EXCEPTION_NO_ACTION : $ responseCode = 404 ; $ message = 'Page not found' ; break ; case \ Zend_Controller_Plugin_ErrorHandler :: EXCEPTION_OTHER : if ( $ exception instanceof \ Gems_Exception ) { $ responseCode = $ exception -> getCode ( ) ; $ message = $ exception -> getMessage ( ) ; $ info = $ exception -> getInfo ( ) ; break ; } default : $ message = $ exception -> getMessage ( ) ; break ; } \ Gems_Log :: getLogger ( ) -> logError ( $ errors -> exception , $ errors -> request ) ; if ( \ MUtil_Console :: isConsole ( ) ) { $ this -> _helper -> viewRenderer -> setNoRender ( true ) ; echo $ message . "\n\n" ; if ( $ info ) { echo $ info . "\n\n" ; } $ next = $ exception -> getPrevious ( ) ; while ( $ next ) { echo ' ' . $ next -> getMessage ( ) . "\n" ; $ next = $ next -> getPrevious ( ) ; } echo $ exception -> getTraceAsString ( ) ; } else { if ( $ responseCode ) { $ this -> getResponse ( ) -> setHttpResponseCode ( $ responseCode ) ; } $ this -> view -> exception = $ exception ; $ this -> view -> message = $ message ; $ this -> view -> request = $ errors -> request ; if ( $ info ) { $ this -> view -> info = $ info ; } } }
Action for displaying an error CLI as well as HTTP
58,011
public function getEveryStatus ( ) { static $ status ; if ( $ status ) { return $ status ; } $ status = array ( 'U' => $ this -> _ ( 'Valid from date unknown' ) , 'W' => $ this -> _ ( 'Valid from date in the future' ) , 'O' => $ this -> _ ( 'Open - can be answered now' ) , 'P' => $ this -> _ ( 'Open - partially answered' ) , 'A' => $ this -> _ ( 'Answered' ) , 'I' => $ this -> _ ( 'Incomplete - missed deadline' ) , 'M' => $ this -> _ ( 'Missed deadline' ) , 'D' => $ this -> _ ( 'Token does not exist' ) , ) ; return $ status ; }
Returns a status code = > decription array
58,012
public function getStatusDescription ( $ value ) { $ status = $ this -> getEveryStatus ( ) ; if ( isset ( $ status [ $ value ] ) ) { return $ status [ $ value ] ; } return $ status [ 'D' ] ; }
Returns the description to add to the answer
58,013
public function getStatusIcon ( $ value ) { $ status = $ this -> getStatusIcons ( ) ; if ( isset ( $ status [ $ value ] ) ) { return $ status [ $ value ] ; } return $ status [ 'D' ] ; }
Returns the decription to add to the answer
58,014
public function getTokenEmailLink ( $ tokenId , $ tokenStatus , $ canMail ) { if ( $ canMail && ( 'O' == $ tokenStatus || 'P' == $ tokenStatus ) ) { $ menuItem = $ this -> _getEmailMenuItem ( ) ; $ link = $ menuItem -> toActionLinkLower ( [ 'gto_id_token' => $ tokenId , 'can_be_taken' => 1 , 'can_email' => 1 , \ Gems_Model :: ID_TYPE => 'token' , ] ) ; if ( $ link ) { $ link -> title = sprintf ( $ this -> _ ( 'Send email for token %s' ) , strtoupper ( $ tokenId ) ) ; return $ link ; } } }
Generate a menu link for email screen
58,015
public function getTokenShowLinkForBridge ( \ MUtil_Model_Bridge_TableBridgeAbstract $ bridge , $ plusLabel = true ) { if ( ! $ this -> currentUser -> hasPrivilege ( $ this -> _getShowMenuItem ( ) -> getPrivilege ( ) ) ) { return null ; } return \ MUtil_Lazy :: method ( $ this , 'getTokenShowLink' , $ bridge -> getLazy ( 'gto_id_token' ) , $ plusLabel ) ; }
De a lazy show link for bridges
58,016
public function getTokenStatusDescriptionForBridge ( \ MUtil_Model_Bridge_TableBridgeAbstract $ bridge , $ addDescription = false ) { return \ MUtil_Lazy :: method ( $ this , 'getStatusDescription' , $ bridge -> getLazy ( 'token_status' ) ) ; }
De a lazy status description text for bridges
58,017
public function orIf ( $ master = null ) { if ( $ this -> logicalOperator == "and" ) { throw new Exception ( "ValidationLogicCriteria: Cannot declare a logical operator more than once. (Specified orIf() after calling andIf()). Use a nested ValidationLogicCriteriaSet to combine conjunctive and disjuctive logic." ) ; } if ( $ master ) { $ this -> master = $ master ; } $ this -> logicalOperator = "or" ; return $ this ; }
Adds a new criterion and makes this set use disjunctive logic
58,018
private function _updateSurvey ( array $ values , $ userId ) { if ( $ this -> tracker -> filterChangesOnly ( $ this -> _gemsSurvey , $ values ) ) { if ( \ Gems_Tracker :: $ verbose ) { $ echo = '' ; foreach ( $ values as $ key => $ val ) { $ old = isset ( $ this -> _gemsSurvey [ $ key ] ) ? $ this -> _gemsSurvey [ $ key ] : null ; $ echo .= $ key . ': ' . $ old . ' => ' . $ val . "\n" ; } \ MUtil_Echo :: r ( $ echo , 'Updated values for ' . $ this -> _surveyId ) ; } if ( ! isset ( $ values [ 'gsu_changed' ] ) ) { $ values [ 'gsu_changed' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; } if ( ! isset ( $ values [ 'gsu_changed_by' ] ) ) { $ values [ 'gsu_changed_by' ] = $ userId ; } if ( $ this -> exists ) { $ this -> _gemsSurvey = $ values + $ this -> _gemsSurvey ; return $ this -> db -> update ( 'gems__surveys' , $ values , array ( 'gsu_id_survey = ?' => $ this -> _surveyId ) ) ; } else { if ( ! isset ( $ values [ 'gsu_created' ] ) ) { $ values [ 'gsu_created' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; } if ( ! isset ( $ values [ 'gsu_created_by' ] ) ) { $ values [ 'gsu_created_by' ] = $ userId ; } $ this -> _gemsSurvey = $ values + $ this -> _gemsSurvey ; unset ( $ this -> _gemsSurvey [ 'gsu_id_survey' ] ) ; $ this -> _surveyId = $ this -> db -> insert ( 'gems__surveys' , $ this -> _gemsSurvey ) ; $ this -> _gemsSurvey [ 'gsu_id_survey' ] = $ this -> _surveyId ; $ this -> exists = true ; return 1 ; } } else { return 0 ; } }
Update the survey both in the database and in memory .
58,019
public function calculateHash ( ) { $ answerModel = $ this -> getAnswerModel ( 'en' ) ; foreach ( $ answerModel -> getItemsOrdered ( ) as $ item ) { $ result = $ answerModel -> get ( $ item , [ 'label' , 'type' , 'multiOptions' , 'parent_question' , 'thClass' , 'group' , 'description' ] ) ; if ( array_key_exists ( 'label' , $ result ) ) { $ items [ $ item ] = $ result ; } } $ hash = md5 ( serialize ( $ items ) ) ; return $ hash ; }
Calculate a hash for this survey taking into account the questions and answers
58,020
public function getAnswerModel ( $ language ) { $ source = $ this -> getSource ( ) ; return $ source -> getSurveyAnswerModel ( $ this , $ language , $ this -> _gemsSurvey [ 'gsu_surveyor_id' ] ) ; }
Returns a model for displaying the answers to this survey in the requested language .
58,021
public function getCompletionTime ( \ Gems_Tracker_Token $ token ) { $ source = $ this -> getSource ( ) ; return $ source -> getCompletionTime ( $ token , $ this -> _surveyId , $ this -> _gemsSurvey [ 'gsu_surveyor_id' ] ) ; }
The time the survey was completed according to the source
58,022
public function getInsertDateUntil ( \ MUtil_Date $ from ) { return Period :: applyPeriod ( $ from , $ this -> _gemsSurvey [ 'gsu_valid_for_unit' ] , $ this -> _gemsSurvey [ 'gsu_valid_for_length' ] ) ; }
Calculate the until date for single survey insertion
58,023
public function getQuestionList ( $ language ) { return $ this -> getSource ( ) -> getQuestionList ( $ language , $ this -> _surveyId , $ this -> _gemsSurvey [ 'gsu_surveyor_id' ] ) ; }
Returns a fieldlist with the field names as key and labels as array .
58,024
public function getRawTokenAnswerRowsCount ( $ filter = array ( ) ) { $ source = $ this -> getSource ( ) ; return $ source -> getRawTokenAnswerRowsCount ( ( array ) $ filter , $ this -> _surveyId , $ this -> _gemsSurvey [ 'gsu_surveyor_id' ] ) ; }
Returns the number of answers of multiple tokens
58,025
public function getStartTime ( \ Gems_Tracker_Token $ token ) { $ source = $ this -> getSource ( ) ; return $ source -> getStartTime ( $ token , $ this -> _surveyId , $ this -> _gemsSurvey [ 'gsu_surveyor_id' ] ) ; }
The time the survey was started according to the source
58,026
public function formatCompletion ( \ MUtil_Date $ dateTime ) { $ days = abs ( $ dateTime -> diffDays ( ) ) ; switch ( $ days ) { case 0 : return $ this -> _ ( 'We have received your answers today. Thank you!' ) ; case 1 : return $ this -> _ ( 'We have received your answers yesterday. Thank you!' ) ; case 2 : return $ this -> _ ( 'We have received your answers 2 days ago. Thank you.' ) ; default : if ( $ days <= 14 ) { return sprintf ( $ this -> _ ( 'We have received your answers %d days ago. Thank you.' ) , $ days ) ; } return sprintf ( $ this -> _ ( 'We have received your answers on %s. ' ) , $ dateTime -> toString ( $ this -> dateFormat ) ) ; } }
Formats an completion date for this display
58,027
public function formatUntil ( \ MUtil_Date $ dateTime = null ) { if ( false === $ this -> showUntil ) { return ; } if ( null === $ dateTime ) { return $ this -> _ ( 'Survey has no time limit.' ) ; } $ days = $ dateTime -> diffDays ( ) ; switch ( $ days ) { case 0 : return array ( \ MUtil_Html :: create ( 'strong' , $ this -> _ ( 'Warning!!!' ) ) , ' ' , $ this -> _ ( 'This survey must be answered today!' ) ) ; case 1 : return array ( \ MUtil_Html :: create ( 'strong' , $ this -> _ ( 'Warning!!' ) ) , ' ' , $ this -> _ ( 'This survey can only be answered until tomorrow!' ) ) ; case 2 : return $ this -> _ ( 'Warning! This survey can only be answered for another 2 days!' ) ; default : if ( $ days <= 14 ) { return sprintf ( $ this -> _ ( 'Please answer this survey within %d days.' ) , $ days ) ; } if ( $ days <= 0 ) { return $ this -> _ ( 'This survey can no longer be answered.' ) ; } return sprintf ( $ this -> _ ( 'Please answer this survey before %s.' ) , $ dateTime -> toString ( $ this -> dateFormat ) ) ; } }
Formats an until date for this display
58,028
protected function getTokenHref ( \ Gems_Tracker_Token $ token ) { $ params = array ( $ this -> request -> getActionKey ( ) => 'to-survey' , \ MUtil_Model :: REQUEST_ID => $ token -> getTokenId ( ) , 'RouteReset' => false , ) ; return new \ MUtil_Html_HrefArrayAttribute ( $ params ) ; }
Get the href for a token
58,029
protected function _getOrgTo ( $ monitorName ) { switch ( $ monitorName ) { case 'maintenancemode' : $ where = "1 = 0" ; break ; case 'cronmail' : default : $ where = 'gor_mail_watcher = 1' ; break ; } $ orgTo = $ this -> db -> fetchCol ( "SELECT DISTINCT gor_contact_email FROM gems__organizations WHERE LENGTH(gor_contact_email) > 5 AND gor_active = 1 AND $where" ) ; return $ orgTo ; }
Return an array of organization recipients for the given monitorName
58,030
protected function _getMailTo ( $ monitorName ) { $ projTo = explode ( ',' , $ this -> project -> getMonitorTo ( $ monitorName ) ) ; $ userTo = $ this -> _getUserTo ( $ monitorName ) ; $ orgTo = $ this -> _getOrgTo ( $ monitorName ) ; $ mailtos = array_merge ( $ projTo , $ userTo , $ orgTo ) ; return array_values ( array_unique ( array_filter ( array_map ( 'trim' , $ mailtos ) ) ) ) ; }
Get the mail addresses for a monitor
58,031
protected function _getUserTo ( $ monitorName ) { switch ( $ monitorName ) { case 'maintenancemode' : $ roles = $ this -> util -> getDbLookup ( ) -> getRolesByPrivilege ( 'pr.maintenance.maintenance-mode' ) ; if ( $ roles ) { $ joins = "JOIN gems__groups ON gsf_id_primary_group = ggp_id_group JOIN gems__roles ON ggp_role = grl_id_role" ; $ where = 'grl_name IN (' . implode ( ', ' , array_map ( array ( $ this -> db , 'quote' ) , array_keys ( $ roles ) ) ) . ')' ; } else { return [ ] ; } break ; case 'cronmail' : default : $ joins = '' ; $ where = 'gsf_mail_watcher = 1' ; break ; } $ userTo = $ this -> db -> fetchCol ( "SELECT DISTINCT gsf_email FROM gems__staff $joins WHERE LENGTH(gsf_email) > 5 AND gsf_active = 1 AND $where" ) ; return $ userTo ; }
Return an array of user recipients for the given monitorName
58,032
public function getReverseMaintenanceMonitorTemplate ( $ locale ) { switch ( $ locale ) { case 'nl' : $ initSubject = "{name} is aangezet" ; $ initBbText = "L.S.,De [b]{name}[/b] is op {setTime} aangezet.Zolang dit aan blijft staan kan u regelmatig waarschuwingen krijgen.Dit is een automatisch bericht." ; $ subject = "{name} staat al meer dan {periodHours} uur aan" ; $ messageBbText = "L.S.,De [b]{name}[/b] is op {setTime} aangezet en staat nog steeds aan.Dit is waarschuwing nummer [b]{mailCount}[/b]. Controleer s.v.p. of de onderhouds modus nog steeds nodig is.Dit is een automatische waarschuwing." ; break ; default : $ initSubject = "{name} has been turned on" ; $ initBbText = "L.S.,The [b]{name}[/b] was activated at {setTime}.As long as maintenance mode is active the system may send you warning messages.This messages was send automatically." ; $ subject = "{name} has been active for over {periodHours} hours" ; $ messageBbText = "L.S.,The [b]{name}[/b] was activated at {setTime} and is still active.This is notice number {mailCount}. Please check whether the maintenance mode is still required.This messages was send automatically." ; break ; } return array ( $ initSubject , $ initBbText , $ subject , $ messageBbText ) ; }
Return the mail template to use for sending ReverseMaintenanceMonitor messages
58,033
public static function solve ( array $ sudoku , $ checkInput = false ) { if ( $ checkInput && ! self :: checkInput ( $ sudoku ) ) { throw new \ InvalidArgumentException ( 'The input is no valid Sudoku array.' ) ; } return self :: recursive_solve ( $ sudoku , count ( $ sudoku ) ) ; }
Solves the Sudoku .
58,034
public static function checkSolution ( array $ solution , array $ task = null ) { if ( ! self :: checkInput ( $ solution ) ) { throw new \ InvalidArgumentException ( 'Input is no Sudoku array.' ) ; } $ dim = count ( $ solution ) ; if ( $ task !== null ) { if ( count ( $ task ) !== $ dim ) return false ; for ( $ i = 0 ; $ i < $ dim ; $ i ++ ) { for ( $ j = 0 ; $ j < $ dim ; $ j ++ ) { if ( $ task [ $ i ] [ $ j ] !== null && $ solution [ $ i ] [ $ j ] !== $ task [ $ i ] [ $ j ] ) return false ; } } } for ( $ row = 0 ; $ row < $ dim ; $ row ++ ) { $ valueFound = array_fill ( 1 , $ dim , false ) ; for ( $ col = 0 ; $ col < $ dim ; $ col ++ ) { if ( $ solution [ $ row ] [ $ col ] === null || $ valueFound [ $ solution [ $ row ] [ $ col ] ] === true ) return false ; else $ valueFound [ $ solution [ $ row ] [ $ col ] ] = true ; } } for ( $ col = 0 ; $ col < $ dim ; $ col ++ ) { $ valueFound = array_fill ( 1 , $ dim , false ) ; for ( $ row = 0 ; $ row < $ dim ; $ row ++ ) { if ( $ valueFound [ $ solution [ $ row ] [ $ col ] ] === true ) return false ; else $ valueFound [ $ solution [ $ row ] [ $ col ] ] = true ; } } $ blockSize = self :: $ blockSizes [ $ dim ] ; for ( $ row = 0 ; $ row < $ dim ; $ row += $ blockSize ) { for ( $ col = 0 ; $ col < $ dim ; $ col += $ blockSize ) { $ valueFound = array_fill ( 1 , $ dim , false ) ; for ( $ blockRow = 0 ; $ blockRow < $ blockSize ; $ blockRow ++ ) { for ( $ blockCol = 0 ; $ blockCol < $ blockSize ; $ blockCol ++ ) { if ( $ valueFound [ $ solution [ $ row + $ blockRow ] [ $ col + $ blockCol ] ] === true ) return false ; else $ valueFound [ $ solution [ $ row + $ blockRow ] [ $ col + $ blockCol ] ] = true ; } } } } return true ; }
Checks if the input is a valid sudoku solution .
58,035
protected function getConditions ( ) { $ conditionLoader = $ this -> loader -> getConditions ( ) ; $ conditions = [ ] ; for ( $ number = 1 ; $ number <= 4 ; $ number ++ ) { $ element = 'gcon_condition_text' . $ number ; $ conditionId = ( int ) $ this -> _data [ $ element ] ; if ( $ conditionId > 0 ) { $ conditions [ ] = $ conditionLoader -> loadCondition ( $ conditionId ) ; } } return $ conditions ; }
Load the conditions
58,036
public function find ( ) { foreach ( $ this -> getSupportedMailers ( ) as $ mailer ) { $ class = Helper :: getMailerClassName ( $ mailer ) ; if ( class_exists ( $ class ) ) { $ this -> register ( $ mailer ) ; } } ksort ( $ this -> mailers ) ; return $ this -> all ( ) ; }
Automatically find and register all officially supported mailers
58,037
public function getContent ( \ WikiRenderer \ Markup \ Trac \ Config $ config , \ WikiRenderer \ Generator \ DocumentGeneratorInterface $ documentGenerator , $ wikiContent ) { preg_match ( '/^Image\(([^\)]+)\)$/' , $ wikiContent , $ attributes ) ; $ image = $ documentGenerator -> getInlineGenerator ( 'image' ) ; $ params = preg_split ( '/\s*,\s*/' , $ attributes [ 1 ] ) ; $ file = $ config -> getLinkProcessor ( ) -> processLink ( trim ( array_shift ( $ params ) ) , 'image' ) ; $ image -> setAttribute ( 'src' , $ file [ 0 ] ) ; $ width = null ; $ nolink = false ; foreach ( $ params as $ p ) { $ p = trim ( $ p ) ; if ( in_array ( $ p , array ( 'right' , 'left' , 'top' , 'bottom' ) ) ) { $ image -> setAttribute ( 'align' , $ p ) ; } elseif ( $ p == 'nolink' ) { $ nolink = true ; } elseif ( preg_match ( '/^(\d+)(px|em|\%)?$/' , $ p ) ) { if ( $ width === null ) { $ width = $ p ; $ image -> setAttribute ( 'width' , $ p ) ; } else { $ image -> setAttribute ( 'height' , $ p ) ; } } elseif ( preg_match ( '/^(align|width|height|alt|title|longdesc|class|id)=(.*)$/' , $ p , $ m ) ) { $ image -> setAttribute ( $ m [ 1 ] , $ m [ 2 ] ) ; } } if ( $ nolink ) { return $ image ; } else { $ link = $ documentGenerator -> getInlineGenerator ( 'link' ) ; $ link -> addContent ( $ image ) ; $ link -> setAttribute ( 'href' , $ file [ 0 ] ) ; return $ link ; } }
returns the generator corresponding to the macro .
58,038
protected function getTranslateAdapter ( ) { if ( $ this -> translate instanceof \ Zend_Translate ) { return $ this -> translate -> getAdapter ( ) ; } if ( ! $ this -> translate instanceof \ Zend_Translate_Adapter ) { $ this -> translate = new \ MUtil_Translate_Adapter_Potemkin ( ) ; } return $ this -> translate ; }
Returns a translate adaptor
58,039
public function setConstraint ( $ fieldName , $ constraint ) { $ class = get_class ( $ constraint ) ; if ( $ this -> getConstraint ( $ fieldName , $ class ) ) { $ this -> removeConstraint ( $ fieldName , $ class ) ; } $ this -> constraints [ $ fieldName ] [ $ class ] = $ constraint ; if ( $ this -> form ) { $ dataField = $ this -> form -> Fields ( ) -> dataFieldByName ( $ fieldName ) ; $ constraint -> setField ( $ dataField ) ; if ( $ this -> parsleyEnabled ) { if ( ! $ dataField ) { throw new Exception ( "You have set a constraint on '$fieldName' but it does not exist in the FieldList." ) ; } $ constraint -> applyParsley ( ) ; } } return $ this ; }
setConstraint - sets a ZenValidatorContraint on this validator
58,040
public function setConstraints ( $ constraints ) { foreach ( $ constraints as $ fieldName => $ v ) { if ( is_array ( $ v ) ) { foreach ( $ v as $ constraintFromArray ) { $ this -> setConstraint ( $ fieldName , $ constraintFromArray ) ; } } else { $ this -> setConstraint ( $ fieldName , $ v ) ; } } return $ this ; }
setConstraints - sets multiple constraints on this validator
58,041
public function getConstraint ( $ fieldName , $ constraintName ) { if ( isset ( $ this -> constraints [ $ fieldName ] [ $ constraintName ] ) ) { return $ this -> constraints [ $ fieldName ] [ $ constraintName ] ; } }
get a constraint by fieldName constraintName
58,042
public function removeConstraint ( $ fieldName , $ constraintName ) { if ( $ constraint = $ this -> getConstraint ( $ fieldName , $ constraintName ) ) { if ( $ this -> form ) { $ constraint -> removeParsley ( ) ; } $ class = get_class ( $ constraint ) ; unset ( $ this -> constraints [ $ fieldName ] [ $ class ] ) ; unset ( $ constraint ) ; } return $ this ; }
remove a constraint from a field
58,043
public function removeConstraints ( $ fieldName ) { if ( $ constraints = $ this -> getConstraints ( $ fieldName ) ) { foreach ( $ constraints as $ k => $ v ) { $ this -> removeConstraint ( $ fieldName , $ k ) ; } unset ( $ this -> constraints [ $ fieldName ] ) ; } return $ this ; }
remove all constraints from a field
58,044
public function addRequiredFields ( $ fields , ... $ otherFields ) { if ( ! is_array ( $ fields ) ) { $ fields = [ $ fields ] ; } if ( ! empty ( $ otherFields ) ) { $ fields = array_merge ( $ fields , $ otherFields ) ; } if ( ArrayLib :: is_associative ( $ fields ) ) { foreach ( $ fields as $ k => $ v ) { $ constraint = Constraint_required :: create ( ) ; if ( $ v ) { $ constraint -> setMessage ( $ v ) ; } $ this -> setConstraint ( $ k , $ constraint ) ; } } else { foreach ( $ fields as $ field ) { $ this -> setConstraint ( $ field , Constraint_required :: create ( ) ) ; } } return $ this ; }
A quick way of adding required constraints to a number of fields
58,045
public function php ( $ data ) { $ valid = true ; if ( get_class ( $ this -> form -> getRequestHandler ( ) -> buttonClicked ( ) ) === 'FormActionNoValidation' ) { return $ valid ; } $ fields = $ this -> form -> Fields ( ) ; foreach ( $ fields as $ field ) { $ valid = ( $ field -> validate ( $ this ) && $ valid ) ; } foreach ( $ this -> constraints as $ fieldName => $ constraints ) { $ field = $ this -> form -> Fields ( ) -> dataFieldByName ( $ fieldName ) ; if ( ! $ field ) { continue ; } if ( $ field -> validationApplies ( ) ) { foreach ( $ constraints as $ constraint ) { if ( ! $ constraint -> validate ( $ data [ $ fieldName ] ) ) { $ this -> validationError ( $ fieldName , $ constraint -> getMessage ( ) , 'required' ) ; $ valid = false ; $ this -> debug ( "Validation (" . get_class ( $ constraint ) . ") failed for $fieldName with message: " . $ constraint -> getMessage ( ) ) ; } } } } return $ valid ; }
Performs the php validation on all ZenValidatorConstraints attached to this validator
58,046
public function removeAllValidation ( ) { if ( $ this -> form ) { foreach ( $ this -> constraints as $ fieldName => $ constraints ) { foreach ( $ constraints as $ constraint ) { $ constraint -> removeParsley ( ) ; unset ( $ constraint ) ; } } } $ this -> constraints = array ( ) ; }
Removes all constraints from this validator .
58,047
protected function checkRequired ( $ exportCode , array $ roundsData ) { $ rounds = array ( ) ; foreach ( $ roundsData as $ roundData ) { if ( $ roundData [ 'survey_export_code' ] == $ exportCode ) { $ rounds [ $ roundData [ 'gro_id_order' ] ] = $ roundData [ 'gro_id_order' ] ; } } if ( ! $ rounds ) { return false ; } foreach ( $ roundsData as $ roundData ) { if ( isset ( $ roundData [ 'gro_valid_after_source' ] , $ roundData [ 'valid_after' ] ) ) { if ( $ this -> checkSourceRequired ( $ roundData [ 'gro_valid_after_source' ] , $ roundData [ 'valid_after' ] , $ rounds ) ) { return true ; } } if ( isset ( $ roundData [ 'gro_valid_after_source' ] , $ roundData [ 'valid_for' ] ) ) { if ( $ this -> checkSourceRequired ( $ roundData [ 'gro_valid_for_source' ] , $ roundData [ 'valid_for' ] , $ rounds ) ) { return true ; } } } return false ; }
Returns tru if another round depends on a round using this export code
58,048
protected function checkSourceRequired ( $ source , $ field , array $ rounds ) { if ( ( $ source == \ Gems_Tracker_Engine_StepEngineAbstract :: ANSWER_TABLE ) || ( $ source == \ Gems_Tracker_Engine_StepEngineAbstract :: TOKEN_TABLE ) ) { return isset ( $ rounds [ $ field ] ) && $ rounds [ $ field ] ; } }
Returns true when thw valid_for_source and valid_for combo uses any round .
58,049
public function getShowFilter ( ) { $ filter = $ this -> loader -> getAgenda ( ) -> getFilter ( $ this -> _getIdParam ( ) ) ; if ( $ filter ) { return $ filter ; } }
Get an agenda filter for the current shown item
58,050
public function setProgramParams ( array $ programParams ) { $ this -> _programParams = $ programParams ; if ( ! $ this -> _readonly ) { $ this -> session -> requestCache [ $ this -> getStorageKey ( ) ] = $ programParams ; } return $ this ; }
Set the keys stored fot this cache
58,051
public static function set ( $ name , $ value , $ days = 30 , $ basepath = '/' ) { if ( ! $ basepath ) { $ basepath = '/' ; } if ( \ Zend_Session :: $ _unitTestEnabled ) { return true ; } return setcookie ( $ name , $ value , time ( ) + ( $ days * 86400 ) , $ basepath , '' , ( APPLICATION_ENV == 'production' ) , true ) ; }
Store this cookie in a generic save method that works for both sub - directory installations and own url installations .
58,052
public static function setOrganization ( $ organization , $ basepath = '/' ) { if ( $ organization ) { return self :: set ( self :: ORGANIZATION_COOKIE , $ organization , 30 , $ basepath ) ; } }
Store the organization in a cookie .
58,053
public function forFilterId ( $ filterId ) { $ filter = $ this -> agenda -> getFilter ( $ filterId ) ; if ( $ filter ) { return $ this -> forFilter ( $ filter ) ; } return $ this ; }
For a certain appointment filter
58,054
public function uniqueForTrackId ( $ trackId , $ respTrackId , $ previousAppIds ) { if ( $ previousAppIds ) { $ this -> uniqueInTrackInstance ( $ previousAppIds ) ; } $ sql = "gap_id_appointment NOT IN (SELECT gr2t2a_id_appointment FROM gems__respondent2track2appointment INNER JOIN gems__respondent2track ON gr2t2a_id_respondent_track = gr2t_id_respondent_track WHERE gr2t2a_id_appointment IS NOT NULL AND gr2t_id_track = $trackId" ; if ( $ respTrackId ) { $ sql .= " AND NOT (gr2t2a_id_respondent_track = $respTrackId)" ; } $ sql .= ")" ; $ this -> _select -> where ( $ sql ) ; }
Add a filter for the appointment id s currently used in tracks with this track id
58,055
public function changeUiAction ( ) { $ request = $ this -> getRequest ( ) ; $ orgId = urldecode ( $ request -> getParam ( 'org' ) ) ; $ oldOrg = $ this -> currentUser -> getCurrentOrganizationId ( ) ; $ origUrl = base64_decode ( $ request -> getParam ( 'current_uri' ) ) ; $ allowedOrganizations = $ this -> currentUser -> getAllowedOrganizations ( ) ; if ( isset ( $ allowedOrganizations [ $ orgId ] ) ) { $ this -> currentUser -> setCurrentOrganization ( $ orgId ) ; if ( $ origUrl ) { if ( strpos ( $ origUrl , '/' . \ MUtil_Model :: REQUEST_ID1 . '/' ) === false ) { foreach ( $ this -> currentUser -> possibleOrgIds as $ key ) { $ finds [ ] = '/' . $ key . '/' . $ oldOrg ; $ replaces [ ] = '/' . $ key . '/' . $ orgId ; } $ correctUrl = str_replace ( $ finds , $ replaces , $ origUrl ) ; } else { $ correctUrl = $ origUrl ; } $ this -> getResponse ( ) -> setRedirect ( $ correctUrl ) ; } else { $ this -> currentUser -> gotoStartPage ( $ this -> menu , $ request ) ; } return ; } throw new \ Gems_Exception ( $ this -> _ ( 'Inaccessible or unknown organization' ) , 403 , null , sprintf ( $ this -> _ ( 'Access to this page is not allowed for current role: %s.' ) , $ this -> currentUser -> getRole ( ) ) ) ; }
Switch the active organization
58,056
protected function _checkReturnURI ( $ sourceSurveyId , \ Gems_Tracker_Survey $ survey , array & $ messages ) { $ lsSurvLang = $ this -> _getSurveyLanguagesTableName ( ) ; $ sql = 'SELECT surveyls_language FROM ' . $ lsSurvLang . ' WHERE surveyls_survey_id = ?' ; $ lsDb = $ this -> getSourceDatabase ( ) ; $ languages = $ lsDb -> fetchAll ( $ sql , array ( $ sourceSurveyId ) ) ; $ langChanges = 0 ; foreach ( $ languages as $ language ) { $ langChanges = $ langChanges + $ lsDb -> update ( $ lsSurvLang , array ( 'surveyls_urldescription' => $ this -> _getReturnURIDescription ( $ language [ 'surveyls_language' ] ) ) , array ( 'surveyls_survey_id = ?' => $ sourceSurveyId , 'surveyls_language = ?' => $ language ) ) ; } if ( $ langChanges > 0 ) { $ messages [ ] = sprintf ( $ this -> _ ( 'The description of the exit url description was changed for %s languages in survey \'%s\'.' ) , $ langChanges , $ survey -> getName ( ) ) ; } }
Checks the return URI in LimeSurvey and sets it to the correct one when needed
58,057
protected function _filterAnswersOnly ( $ sourceSurveyId , array $ answers ) { $ s = $ sourceSurveyId . 'X' ; $ l = strlen ( $ s ) ; $ results = array ( ) ; foreach ( $ answers as $ key => $ value ) { if ( substr ( $ key , 0 , $ l ) == $ s ) { $ results [ $ key ] = $ value ; } } return $ results ; }
Filters an answers array return only those fields that where answered by the user .
58,058
protected function _getFieldMap ( $ sourceSurveyId , $ language = null ) { $ language = $ this -> _getLanguage ( $ sourceSurveyId , $ language ) ; if ( ! isset ( $ this -> _fieldMaps [ $ sourceSurveyId ] [ $ language ] ) ) { $ className = $ this -> fieldMapClass ; $ this -> _fieldMaps [ $ sourceSurveyId ] [ $ language ] = new $ className ( $ sourceSurveyId , $ language , $ this -> getSourceDatabase ( ) , $ this -> translate , $ this -> addDatabasePrefix ( '' ) , $ this -> cache , $ this -> getId ( ) ) ; } return $ this -> _fieldMaps [ $ sourceSurveyId ] [ $ language ] ; }
Return a fieldmap object
58,059
protected function _getLanguage ( $ sourceSurveyId , $ language ) { if ( ! is_string ( $ language ) ) { $ language = ( string ) $ language ; } if ( ! isset ( $ this -> _languageMap [ $ sourceSurveyId ] [ $ language ] ) ) { if ( $ language && $ this -> _isLanguage ( $ sourceSurveyId , $ language ) ) { $ this -> _languageMap [ $ sourceSurveyId ] [ $ language ] = $ language ; } else { $ lsDb = $ this -> getSourceDatabase ( ) ; $ sql = 'SELECT language FROM ' . $ this -> _getSurveysTableName ( ) . ' WHERE sid = ?' ; $ this -> _languageMap [ $ sourceSurveyId ] [ $ language ] = $ lsDb -> fetchOne ( $ sql , $ sourceSurveyId ) ; } } return $ this -> _languageMap [ $ sourceSurveyId ] [ $ language ] ; }
Returns the langauge to use for the survey when this language is specified .
58,060
protected function _getReturnURIDescription ( $ language ) { return sprintf ( $ this -> translate -> _ ( 'Back to %s' , $ language ) , $ this -> project -> getName ( ) ) ; }
Get the return URI description to set in LimeSurvey
58,061
protected function _isLanguage ( $ sourceSurveyId , $ language ) { if ( $ language && strlen ( $ language ) ) { $ sql = 'SELECT surveyls_language FROM ' . $ this -> _getSurveyLanguagesTableName ( ) . ' WHERE surveyls_survey_id = ? AND surveyls_language = ?' ; $ lsDb = $ this -> getSourceDatabase ( ) ; return $ lsDb -> fetchOne ( $ sql , array ( $ sourceSurveyId , $ language ) ) ; } return false ; }
Check if the specified language is available in Lime Survey
58,062
public function checkSourceActive ( $ userId ) { $ sourceDb = $ this -> getSourceDatabase ( ) ; $ tables = array_map ( 'strtolower' , $ sourceDb -> listTables ( ) ) ; $ tableName = $ this -> addDatabasePrefix ( self :: SURVEYS_TABLE , false ) ; $ active = strtolower ( in_array ( $ tableName , $ tables ) ) ; $ values [ 'gso_active' ] = $ active ? 1 : 0 ; $ values [ 'gso_status' ] = $ active ? 'Active' : 'Inactive' ; $ this -> _updateSource ( $ values , $ userId ) ; return $ active ; }
Check if the tableprefix exists in the source database and change the status of this adapter in the gems_sources table accordingly
58,063
protected function fixTokenAttributeDescriptions ( $ sourceSurveyId ) { $ lsDb = $ this -> getSourceDatabase ( ) ; $ fieldData = array ( ) ; foreach ( $ this -> _attributeMap as $ fieldName ) { if ( substr ( $ fieldName , 0 , 10 ) == 'attribute_' ) { $ fieldData [ $ fieldName ] = array ( 'description' => $ fieldName , 'mandatory' => 'N' , 'show_register' => 'N' , 'cpdbmap' => '' ) ; } } $ fields = array ( $ this -> _attributeDescriptionsField => json_encode ( $ fieldData ) ) ; return ( boolean ) $ lsDb -> update ( $ this -> _getSurveysTableName ( ) , $ fields , $ lsDb -> quoteInto ( 'sid = ?' , $ sourceSurveyId ) ) ; }
Fix the tokenattribute descriptions
58,064
public function getCompletedTokens ( $ tokenIds , $ sourceSurveyId ) { $ lsDb = $ this -> getSourceDatabase ( ) ; $ lsToken = $ this -> _getTokenTableName ( $ sourceSurveyId ) ; $ tokens = array_map ( array ( $ this , '_getToken' ) , $ tokenIds ) ; $ sql = $ lsDb -> select ( ) -> from ( $ lsToken , array ( 'token' ) ) -> where ( 'token IN (?)' , $ tokens ) -> where ( 'completed != ?' , 'N' ) ; $ completedTokens = $ lsDb -> fetchCol ( $ sql ) ; if ( $ completedTokens ) { $ translatedTokens = array ( ) ; foreach ( $ completedTokens as $ token ) { $ translatedTokens [ ] = $ this -> _getToken ( $ token , true ) ; } return $ translatedTokens ; } return $ completedTokens ; }
Bulk check token completion
58,065
public function getTokenInfo ( \ Gems_Tracker_Token $ token , $ surveyId , $ sourceSurveyId , array $ fields = null ) { if ( ! $ token -> cacheHas ( self :: CACHE_TOKEN_INFO ) ) { if ( null === $ sourceSurveyId ) { $ sourceSurveyId = $ this -> _getSid ( $ surveyId ) ; } $ lsTokens = $ this -> _getTokenTableName ( $ sourceSurveyId ) ; $ tokenId = $ this -> _getToken ( $ token -> getTokenId ( ) ) ; $ sql = 'SELECT * FROM ' . $ lsTokens . ' WHERE token = ? LIMIT 1' ; try { $ result = $ this -> getSourceDatabase ( ) -> fetchRow ( $ sql , $ tokenId ) ; } catch ( \ Zend_Db_Statement_Exception $ exception ) { $ this -> logger -> logError ( $ exception , $ this -> request ) ; $ result = false ; } $ token -> cacheSet ( self :: CACHE_TOKEN_INFO , $ result ) ; } else { $ result = $ token -> cacheGet ( self :: CACHE_TOKEN_INFO ) ; } if ( $ fields !== null ) $ result = array_intersect_key ( ( array ) $ result , array_flip ( $ fields ) ) ; return $ result ; }
Retrieve all fields stored in the token table and store them in the tokencache
58,066
public function setTokenCompletionTime ( \ Gems_Tracker_Token $ token , $ completionTime , $ surveyId , $ sourceSurveyId = null ) { if ( null === $ sourceSurveyId ) { $ sourceSurveyId = $ this -> _getSid ( $ surveyId ) ; } $ lsDb = $ this -> getSourceDatabase ( ) ; $ lsTabSurv = $ this -> _getSurveyTableName ( $ sourceSurveyId ) ; $ lsTabTok = $ this -> _getTokenTableName ( $ sourceSurveyId ) ; $ lsTokenId = $ this -> _getToken ( $ token -> getTokenId ( ) ) ; $ where = $ lsDb -> quoteInto ( "token = ?" , $ lsTokenId ) ; $ current = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; if ( $ completionTime instanceof \ Zend_Date ) { $ answers [ 'submitdate' ] = $ completionTime -> toString ( self :: LS_DB_DATETIME_FORMAT ) ; $ tokenData [ 'completed' ] = $ completionTime -> toString ( self :: LS_DB_COMPLETION_FORMAT ) ; } else { $ answers [ 'submitdate' ] = null ; $ tokenData [ 'completed' ] = 'N' ; } if ( $ lsDb -> fetchOne ( "SELECT token FROM $lsTabSurv WHERE token = ?" , $ lsTokenId ) ) { $ lsDb -> update ( $ lsTabSurv , $ answers , $ where ) ; } elseif ( $ completionTime instanceof \ Zend_Date ) { $ answers [ 'token' ] = $ lsTokenId ; $ answers [ 'startlanguage' ] = $ this -> locale -> getLanguage ( ) ; $ answers [ 'datestamp' ] = $ current ; $ answers [ 'startdate' ] = $ current ; $ lsDb -> insert ( $ lsTabSurv , $ answers ) ; } if ( $ lsDb -> fetchOne ( "SELECT token FROM $lsTabTok WHERE token = ?" , $ lsTokenId ) ) { $ lsDb -> update ( $ lsTabTok , $ tokenData , $ where ) ; } elseif ( $ completionTime instanceof \ Zend_Date ) { $ tokenData [ 'token' ] = $ lsTokenId ; $ tokenData = $ tokenData + $ this -> _fillAttributeMap ( $ token ) ; $ lsDb -> insert ( $ lsTabTok , $ tokenData ) ; } $ token -> cacheReset ( ) ; }
Sets the completion time .
58,067
public function hasHtmlOutput ( ) { if ( $ this -> currentUser -> getUserId ( ) == \ Gems_User_UserLoader :: SYSTEM_USER_ID ) { $ this -> addMessage ( $ this -> getNotAllowedMessage ( ) ) ; return false ; } return parent :: hasHtmlOutput ( ) ; }
If the current user is the system user present a message and don t allow to edit
58,068
public function getTag ( ) { if ( null === $ this -> _tag ) { $ tag = $ this -> getOption ( 'tag' ) ; if ( null !== $ tag ) { $ this -> removeOption ( 'tag' ) ; } else { $ tag = 'span' ; } $ this -> setTag ( $ tag ) ; return $ tag ; } return $ this -> _tag ; }
Get HTML tag if any with which to surround tooltip
58,069
public function getEscape ( ) { if ( null === $ this -> _escape ) { if ( null !== ( $ escape = $ this -> getOption ( 'escape' ) ) ) { $ this -> setEscape ( $ escape ) ; $ this -> removeOption ( 'escape' ) ; } else { $ this -> setEscape ( true ) ; } } return $ this -> _escape ; }
Get escape flag
58,070
public function getDeactivateTitle ( ) { $ user = $ this -> getSelectedUser ( ) ; if ( $ user ) { return sprintf ( $ this -> _ ( 'Deactivate staff member %s' ) , $ user -> getLoginName ( ) ) ; } return parent :: getDeactivateTitle ( ) ; }
Helper function to get the title for the deactivate action .
58,071
public function getReactivateTitle ( ) { $ user = $ this -> getSelectedUser ( ) ; if ( $ user ) { return sprintf ( $ this -> _ ( 'Reactivate staff member %s' ) , $ user -> getLoginName ( ) ) ; } return parent :: getReactivateTitle ( ) ; }
Helper function to get the title for the reactivate action .
58,072
public function getShowTitle ( ) { $ user = $ this -> getSelectedUser ( ) ; if ( $ user ) { return sprintf ( $ this -> _ ( 'Show staff member %s' ) , $ user -> getLoginName ( ) ) ; } return parent :: getShowTitle ( ) ; }
Helper function to get the title for the show action .
58,073
public function mailAction ( ) { if ( $ this -> mailSnippets ) { $ params = $ this -> _processParameters ( $ this -> mailParameters ) ; $ this -> addSnippets ( $ this -> mailSnippets , $ params ) ; } }
mail a staff member
58,074
public function resetAction ( ) { if ( $ this -> resetSnippets ) { $ params = $ this -> _processParameters ( $ this -> resetParameters ) ; $ this -> addSnippets ( $ this -> resetSnippets , $ params ) ; } }
reset a password
58,075
public function reset2faAction ( ) { $ user = $ this -> getSelectedUser ( ) ; $ user -> clearTwoFactorKey ( ) ; $ this -> addMessage ( sprintf ( $ this -> _ ( 'Two factor key cleared for user %s' ) , $ user -> getLoginName ( ) ) , 'success' ) ; $ router = \ Zend_Controller_Action_HelperBroker :: getStaticHelper ( 'redirector' ) ; $ router -> gotoRoute ( [ 'controller' => 'staff' , 'action' => 'show' ] , null , false ) ; }
reset two factor authentication
58,076
public function getUser ( ) { if ( ! $ this -> _user ) { $ request = $ this -> getRequest ( ) ; $ this -> _user = $ this -> loader -> getUser ( $ request -> getParam ( $ this -> usernameFieldName ) , $ request -> getParam ( $ this -> organizationFieldName ) ) ; } return $ this -> _user ; }
Returns a user
58,077
public function wasSubmitted ( ) { $ request = $ this -> getRequest ( ) ; if ( $ request -> isPost ( ) && strlen ( trim ( $ request -> getPost ( $ this -> _submitFieldName ) ) ) ) { return true ; } else { return false ; } }
True when this form was submitted .
58,078
public function addTo ( $ newTo , $ newToName = '' ) { if ( is_array ( $ newTo ) ) { $ this -> to = array_merge ( $ newTo , $ this -> to ) ; } else { if ( empty ( $ newToName ) ) { $ this -> to [ ] = $ newTo ; } else { $ this -> to [ $ newToName ] = $ newTo ; } } }
Add a To field
58,079
public function getMailFields ( $ marked = true ) { if ( $ marked ) { if ( ! $ this -> markedMailFields ) { $ this -> markedMailFields = $ this -> markMailFields ( $ this -> mailFields ) ; } return $ this -> markedMailFields ; } else { return $ this -> mailFields ; } }
Return the mailFields
58,080
public function applyFields ( $ text ) { $ mailKeys = array_keys ( $ this -> getMailFields ( ) ) ; return str_replace ( $ mailKeys , $ this -> mailFields , $ text ) ; }
Replace the mailkeys with the mailfields in given text
58,081
public function getLanguage ( ) { if ( $ this -> project -> getEmailMultiLanguage ( ) && $ this -> language ) { return $ this -> language ; } else { return $ this -> project -> getLocaleDefault ( ) ; } }
Get the prefered template language
58,082
public function getTemplate ( $ templateId , $ language = null ) { if ( ! $ language ) { $ language = $ this -> getLanguage ( ) ; } $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__comm_template_translations' ) -> where ( 'gctt_id_template = ?' , $ templateId ) -> where ( 'gctt_lang = ?' , $ language ) ; $ template = $ this -> db -> fetchRow ( $ select ) ; if ( $ template && ! empty ( $ template [ 'gctt_subject' ] ) ) { return $ template ; } if ( $ language !== $ this -> project -> getLocaleDefault ( ) ) { $ language = $ this -> project -> getLocaleDefault ( ) ; $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__comm_template_translations' ) -> where ( 'gctt_id_template = ?' , $ templateId ) -> where ( 'gctt_lang = ?' , $ language ) ; $ template = $ this -> db -> fetchRow ( $ select ) ; if ( $ template && ! empty ( $ template [ 'gctt_subject' ] ) ) { return $ template ; } } $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__comm_template_translations' ) -> where ( 'gctt_id_template = ?' , $ templateId ) -> where ( 'gctt_subject <> ""' ) -> where ( 'gctt_body <> ""' ) ; $ template = $ this -> db -> fetchRow ( $ select ) ; if ( $ template && ! empty ( $ template [ 'gctt_subject' ] ) ) { return $ template ; } else { return false ; } }
get a specific template . If the selected translation exists get that translation Else if the selected translation isn t the default select the default translation Else select the first not empty translation Else return false
58,083
protected function loadMailFields ( ) { if ( $ this -> organization ) { $ this -> mailFields = array_merge ( $ this -> project -> getMailFields ( ) , $ this -> organization -> getMailFields ( ) ) ; } else { $ this -> mailFields = $ this -> project -> getMailFields ( ) ; } }
Initialize the mailfields
58,084
protected function loadOrganization ( ) { if ( ! $ this -> organizationId ) { $ this -> loadOrganizationId ( ) ; } $ this -> organization = $ this -> loader -> getOrganization ( $ this -> organizationId ) ; }
Load the organization from the given organization id
58,085
public function markMailFields ( $ mailFields ) { $ markedMailFields = \ MUtil_Ra :: braceKeys ( $ mailFields , $ this -> mailFieldMarkers [ 'start' ] , $ this -> mailFieldMarkers [ 'end' ] ) ; return $ markedMailFields ; }
Add specified markers to the mailfield keys
58,086
public function setFrom ( $ newFrom ) { $ this -> from = $ newFrom ; $ this -> mailFields [ 'from' ] = $ this -> mailFields [ 'reply_to' ] = $ newFrom ; }
set the from field
58,087
public function setTemplateByCode ( $ templateCode ) { $ select = $ this -> loader -> getModels ( ) -> getCommTemplateModel ( ) -> getSelect ( ) ; $ select -> where ( 'gct_code = ?' , $ templateCode ) ; $ template = $ this -> db -> fetchRow ( $ select ) ; if ( $ template ) { $ this -> setTemplate ( $ template [ 'gct_id_template' ] ) ; return true ; } else { return false ; } }
Use the Mail template code to select and set the template
58,088
public function setTo ( $ newTo , $ newToName = '' ) { if ( is_array ( $ newTo ) ) { $ this -> to = $ newTo ; } else { $ this -> to = array ( ) ; if ( empty ( $ newToName ) ) { $ this -> to [ ] = $ newTo ; } else { $ this -> to [ $ newToName ] = $ newTo ; } } }
set the To field overwriting earlier settings completely
58,089
protected function _checkParameters ( array $ params , array $ posts ) { foreach ( $ params as $ key => $ value ) { $ rest = strpbrk ( $ key , '<>=%&"\'' ) ; if ( false !== $ rest ) { $ this -> setError ( $ this -> _ ( 'Illegal request parameter' ) , 422 , sprintf ( $ this -> _ ( 'Illegal character %s in parameter name.' ) , $ rest [ 0 ] ) , true ) ; } if ( $ value && ( ! is_object ( $ value ) ) && ( ! array_key_exists ( $ key , $ posts ) ) ) { foreach ( ( array ) $ value as $ val ) { if ( is_array ( $ val ) ) { continue ; } $ checks = [ 'iframe' , 'img' , 'script' ] ; $ pattern = '/([<>%&])(' . join ( '|' , $ checks ) . ')/i' ; if ( preg_match ( $ pattern , $ val , $ matches ) ) { $ this -> setError ( $ this -> _ ( 'Illegal request parameter' ) , 422 , sprintf ( $ this -> _ ( 'Illegal parameter value containing the text "%s" after a %s character.' ) , $ matches [ 2 ] , $ matches [ 1 ] ) , true ) ; } } } } }
Check all parameters for security violations
58,090
protected function _copyVariables ( $ object ) { $ this -> _copyDestinations [ ] = $ object ; $ object -> escort = $ this ; foreach ( $ this -> getContainer ( ) as $ key => $ value ) { if ( $ value !== $ object ) { $ object -> $ key = $ value ; } } foreach ( get_object_vars ( $ this ) as $ name => $ value ) { if ( '_' != $ name [ 0 ] ) { $ object -> $ name = $ value ; } } }
Function to maintain uniformity of access to variables from the bootstrap object . Copies all variables to the target object .
58,091
protected function _initProject ( ) { $ projectArray = $ this -> includeFile ( APPLICATION_PATH . '/configs/project' ) ; if ( $ projectArray instanceof \ Gems_Project_ProjectSettings ) { $ project = $ projectArray ; } else { $ project = $ this -> createProjectClass ( 'Project_ProjectSettings' , $ projectArray ) ; } return $ project ; }
Initialize the GEMS project component .
58,092
protected function _initLogger ( ) { $ this -> bootstrap ( 'project' ) ; $ logger = \ Gems_Log :: getLogger ( ) ; $ logPath = GEMS_ROOT_DIR . '/var/logs' ; try { $ writer = new \ Zend_Log_Writer_Stream ( $ logPath . '/errors.log' ) ; } catch ( Exception $ exc ) { try { \ MUtil_File :: ensureDir ( $ logPath ) ; $ writer = new \ Zend_Log_Writer_Stream ( $ logPath . '/errors.log' ) ; } catch ( Exception $ exc ) { $ this -> bootstrap ( array ( 'locale' , 'translate' ) ) ; die ( str_replace ( GEMS_ROOT_DIR . '/' , '' , sprintf ( $ this -> translateAdapter -> _ ( 'Path %s not writable' ) . "\n%s\n" , $ logPath , $ exc -> getMessage ( ) ) ) ) ; } } $ filter = new \ Zend_Log_Filter_Priority ( $ this -> project -> getLogLevel ( ) ) ; $ writer -> addFilter ( $ filter ) ; $ logger -> addWriter ( $ writer ) ; if ( $ this -> _startFirebird ) { $ logger -> addWriter ( new \ Zend_Log_Writer_Firebug ( ) ) ; } \ Zend_Registry :: set ( 'logger' , $ logger ) ; return $ logger ; }
Initialize the logger
58,093
protected function _initCache ( ) { $ this -> bootstrap ( 'project' ) ; $ useCache = $ this -> getResource ( 'project' ) -> getCache ( ) ; $ cache = null ; $ exists = false ; $ cachePrefix = GEMS_PROJECT_NAME . '_' ; if ( \ MUtil_Console :: isConsole ( ) && ! ini_get ( 'apc.enable_cli' ) && $ useCache === 'apc' ) { $ useCache = "File" ; } if ( $ useCache === 'apc' && extension_loaded ( 'apc' ) && ini_get ( 'apc.enabled' ) ) { $ cachePrefix .= md5 ( APPLICATION_PATH ) ; $ cacheBackendOptions = array ( 'cache_id_prefix' => $ cachePrefix ) ; $ cacheBackend = new \ Gems \ Cache \ Backend \ Apc ( $ cacheBackendOptions ) ; $ exists = true ; } else { $ cacheBackend = 'File' ; $ cacheDir = GEMS_ROOT_DIR . "/var/cache/" ; $ cacheBackendOptions = array ( 'cache_dir' => $ cacheDir ) ; if ( ! file_exists ( $ cacheDir ) ) { if ( @ mkdir ( $ cacheDir , 0777 , true ) ) { $ exists = true ; } } else { $ exists = true ; } } if ( $ exists && $ useCache <> 'none' ) { $ cacheFrontendOptions = array ( 'automatic_serialization' => true , 'cache_id_prefix' => $ cachePrefix , 'automatic_cleaning_factor' => 0 ) ; $ cache = \ Zend_Cache :: factory ( 'Core' , $ cacheBackend , $ cacheFrontendOptions , $ cacheBackendOptions ) ; } else { $ cache = \ Zend_Cache :: factory ( 'Core' , 'Static' , array ( 'caching' => false ) , array ( 'disable_caching' => true ) ) ; } \ Zend_Db_Table_Abstract :: setDefaultMetadataCache ( $ cache ) ; \ Zend_Translate :: setCache ( $ cache ) ; \ Zend_Locale :: setCache ( $ cache ) ; return $ cache ; }
Create a default file cache for the Translate and DB adapters to speed up execution
58,094
protected function _initLoader ( ) { $ loader = $ this -> createProjectClass ( 'Loader' , $ this -> getContainer ( ) , $ this -> _loaderDirs ) ; \ MUtil_Model :: setSource ( $ loader , true ) ; return $ loader ; }
Initialize the Project or Gems loader .
58,095
protected function _initAccesslog ( ) { $ this -> bootstrap ( array ( 'cache' , 'db' , 'loader' ) ) ; $ accesslog = $ this -> createProjectClass ( 'AccessLog' , $ this -> cache , $ this -> db , $ this -> loader ) ; return $ accesslog ; }
Initialize the access log .
58,096
protected function _initSession ( ) { $ this -> bootstrap ( 'project' ) ; $ session = new \ Zend_Session_Namespace ( 'gems.' . GEMS_PROJECT_NAME . '.session' ) ; $ idleTimeout = $ this -> project -> getSessionTimeOut ( ) ; $ session -> setExpirationSeconds ( $ idleTimeout ) ; if ( ! isset ( $ session -> user_role ) ) { $ session -> user_role = 'nologin' ; } $ this -> staticSession = new \ Zend_Session_Namespace ( 'gems.' . GEMS_PROJECT_NAME . '.sessionStatic' ) ; return $ session ; }
Initialize the Gems session .
58,097
protected function _initLocale ( ) { $ this -> bootstrap ( array ( 'project' , 'session' ) ) ; if ( isset ( $ this -> session -> user_locale ) ) { $ localeId = $ this -> session -> user_locale ; } else { if ( isset ( $ this -> project -> locale , $ this -> project -> locale [ 'default' ] ) ) { $ localeId = $ this -> project -> locale [ 'default' ] ; } elseif ( isset ( $ this -> project -> locales ) ) { $ localeId = reset ( $ this -> project -> locales ) ; } else { $ localeId = 'en' ; } $ this -> session -> user_locale = $ localeId ; } $ locale = new \ Zend_Locale ( $ localeId ) ; \ Zend_Registry :: set ( 'Zend_Locale' , $ locale ) ; return $ locale ; }
Initialize the locale .
58,098
protected function _initOpenRosa ( ) { $ this -> bootstrap ( array ( 'loader' , 'translate' ) ) ; if ( $ this -> getOption ( 'useOpenRosa' ) ) { $ this -> bootstrap ( array ( 'db' , 'loader' , 'util' ) ) ; $ this -> getLoader ( ) -> addPrefixPath ( 'OpenRosa' , GEMS_LIBRARY_DIR . '/classes/OpenRosa' , true ) ; $ tracker = $ this -> loader -> getTracker ( ) ; $ tracker -> addSourceClasses ( array ( 'OpenRosa' => 'OpenRosa form' ) ) ; } }
Initialize the OpenRosa survey source
58,099
protected function _initTranslate ( ) { $ this -> bootstrap ( 'locale' ) ; $ language = $ this -> locale -> getLanguage ( ) ; $ options = array ( 'adapter' => 'gettext' , 'content' => GEMS_LIBRARY_DIR . '/languages/' , 'disableNotices' => true , 'scan' => \ Zend_Translate :: LOCALE_FILENAME ) ; $ translate = new \ Zend_Translate ( $ options ) ; if ( ! $ translate -> isAvailable ( $ language ) ) { $ translate = \ MUtil_Translate_Adapter_Potemkin :: create ( ) ; } $ projectLanguageDir = APPLICATION_PATH . '/languages/' ; if ( file_exists ( $ projectLanguageDir ) ) { $ options [ 'content' ] = $ projectLanguageDir ; $ options [ 'disableNotices' ] = true ; $ projectTranslations = new \ Zend_Translate ( $ options ) ; if ( $ projectTranslations -> isAvailable ( $ language ) ) { $ translate -> addTranslation ( array ( 'content' => $ projectTranslations ) ) ; } unset ( $ projectTranslations ) ; } $ translate -> setLocale ( $ language ) ; \ Zend_Registry :: set ( 'Zend_Translate' , $ translate ) ; $ container = $ this -> getContainer ( ) ; $ adapter = $ translate -> getAdapter ( ) ; $ container -> translateAdapter = $ adapter ; $ this -> translateAdapter = $ adapter ; return $ translate ; }
Initialize the translate component .