idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
57,800
|
public static function setDutchSsn ( \ MUtil_Model_ModelAbstract $ model , \ Zend_Translate_Adapter $ translator , $ fieldName = 'grs_ssn' ) { $ bsn = new \ MUtil_Validate_Dutch_Burgerservicenummer ( ) ; $ model -> set ( $ fieldName , 'size' , 10 , 'maxlength' , 12 , 'filter' , new \ MUtil_Filter_Dutch_Burgerservicenummer ( ) , 'validators[bsn]' , $ bsn ) ; if ( APPLICATION_ENV !== 'production' ) { $ num = mt_rand ( 100000000 , 999999999 ) ; while ( ! $ bsn -> isValid ( $ num ) ) { $ num ++ ; } $ model -> set ( $ fieldName , 'description' , sprintf ( $ translator -> _ ( 'Random Example BSN: %s' ) , $ num ) ) ; } else { $ model -> set ( $ fieldName , 'description' , $ translator -> _ ( 'Enter a 9-digit SSN number.' ) ) ; } }
|
Set the field values for a dutch social security number
|
57,801
|
public static function setDutchZipcode ( \ MUtil_Model_ModelAbstract $ model , \ Zend_Translate_Adapter $ translator , $ fieldName = 'grs_zipcode' ) { $ model -> set ( $ fieldName , 'size' , 7 , 'description' , $ translator -> _ ( 'E.g.: 0000 AA' ) , 'filter' , new \ Gems_Filter_DutchZipcode ( ) ) ; }
|
Set the field values for a dutch zipcode
|
57,802
|
public function getVersion ( ) { $ code = $ this -> runShell ( 'tika --version' , $ stdout ) ; if ( ! $ code && preg_match ( '/Apache Tika (?<version>[\.\d]+)/' , $ stdout , $ matches ) ) { return $ matches [ 'version' ] ; } return 0 ; }
|
Get the version of tika installed or 0 if not installed
|
57,803
|
protected function runShell ( $ command , & $ stdout = '' , & $ stderr = '' , $ input = '' ) { $ descriptorSpecs = [ 0 => [ "pipe" , "r" ] , 1 => [ "pipe" , "w" ] , 2 => [ "pipe" , "w" ] ] ; $ pipes = [ ] ; $ proc = proc_open ( $ command , $ descriptorSpecs , $ pipes ) ; if ( ! is_resource ( $ proc ) ) { return 255 ; } fwrite ( $ pipes [ 0 ] , $ input ) ; fclose ( $ pipes [ 0 ] ) ; $ stdout = stream_get_contents ( $ pipes [ 1 ] ) ; fclose ( $ pipes [ 1 ] ) ; $ stderr = stream_get_contents ( $ pipes [ 2 ] ) ; fclose ( $ pipes [ 2 ] ) ; return proc_close ( $ proc ) ; }
|
Runs an arbitrary and safely escaped shell command
|
57,804
|
private function _getImportantDecorator ( $ element ) { $ class = get_class ( $ element ) ; if ( strpos ( $ class , 'JQuery' ) ) { $ dec = $ element -> getDecorator ( 'UiWidgetElement' ) ; } if ( strpos ( $ class , 'File' ) ) { $ dec = $ element -> getDecorator ( 'File' ) ; } if ( ! isset ( $ dec ) || $ dec == false ) { $ dec = $ element -> getDecorator ( 'ViewHelper' ) ; } return $ dec ; }
|
Get a ViewHelper or ZendX decorator to add in front of the decorator chain
|
57,805
|
public function addDisplayGroup ( array $ elements , $ name , $ options = null ) { return parent :: addDisplayGroup ( $ elements , $ name , ( array ) $ options + array ( 'disableLoadDefaultDecorators' => true ) ) ; }
|
Add a display group to the subform
|
57,806
|
public function fixDecorators ( ) { $ this -> _alternate = new \ MUtil_Lazy_Alternate ( array ( 'odd' , 'even' ) ) ; foreach ( $ this as $ name => $ element ) { if ( $ element instanceof \ MUtil_Form_Element_Html ) { $ this -> _fixDecoratorHtml ( $ element ) ; } elseif ( $ element instanceof \ Zend_Form_Element_Hidden || $ element instanceof \ Zend_Form_Element_Submit ) { $ this -> _fixDecoratorHiddenSubmit ( $ element ) ; } elseif ( $ element instanceof \ Zend_Form_Element ) { $ this -> _fixDecoratorElement ( $ element ) ; } elseif ( $ element instanceof \ Zend_Form_DisplayGroup ) { $ this -> _fixDecoratorDisplayGroup ( $ element ) ; } } }
|
Fix the decorators so we get the table layout we want . Normally this is called only once when rendering the form .
|
57,807
|
public function render ( \ Zend_View_Interface $ view = null ) { if ( $ this -> _getIsRendered ( ) ) { return ; } $ this -> fixDecorators ( ) ; return parent :: render ( $ view ) ; }
|
Fix the decorators the first time we try to render the form
|
57,808
|
public function processFilterAndSort ( \ MUtil_Model_ModelAbstract $ model ) { $ roundDecription = $ this -> request -> getParam ( 'gto_round_description' ) ; if ( ! is_null ( $ roundDecription ) ) { $ roundDecription = html_entity_decode ( urldecode ( $ roundDecription ) ) ; $ this -> request -> setParam ( 'gto_round_description' , $ roundDecription ) ; } parent :: processFilterAndSort ( $ model ) ; }
|
Fix for forward slash in round description
|
57,809
|
public function checkTokensFrom ( \ Gems_Tracker_RespondentTrack $ respTrack , \ Gems_Tracker_Token $ startToken , $ userId , \ Gems_Tracker_Token $ skipToken = null ) { $ changed = parent :: checkTokensFrom ( $ respTrack , $ respTrack -> getFirstToken ( ) , $ userId , $ skipToken ) ; return $ changed ; }
|
The end date of any round can depend on any token so always do a end date check of the previous tokens
|
57,810
|
protected function getValidFromDate ( $ fieldSource , $ fieldName , $ prevRoundId , \ Gems_Tracker_Token $ token , \ Gems_Tracker_RespondentTrack $ respTrack ) { return $ this -> getValidUntilDate ( $ fieldSource , $ fieldName , $ prevRoundId , $ token , $ respTrack , false ) ; }
|
Returns the date to use to calculate the ValidFrom if any
|
57,811
|
public function _createSelect ( array $ filter , array $ sort ) { $ select = parent :: _createSelect ( $ filter , $ sort ) ; $ config = $ select -> getAdapter ( ) -> getConfig ( ) ; if ( isset ( $ config [ 'dbname' ] ) ) { $ constraint = $ select -> getAdapter ( ) -> quoteInto ( ' AND TABLE_SCHEMA=?' , $ config [ 'dbname' ] ) ; } else { $ constraint = '' ; } $ select -> joinLeft ( 'INFORMATION_SCHEMA.TABLES' , "table_name = convert(concat_ws('_','gems__orf_', REPLACE(gof_form_id,'.','_'),gof_form_version) USING utf8)" . $ constraint , array ( 'TABLE_ROWS' ) ) ; return $ select ; }
|
Get a select statement using a filter and sort
|
57,812
|
public function render ( $ content ) { $ form = $ this -> getElement ( ) ; if ( ! $ form instanceof \ Zend_Form ) { return $ content ; } $ this -> _recurseForm ( $ form ) ; return $ content ; }
|
Render the TabErrors
|
57,813
|
public function getVerbose ( ) { if ( null !== ( $ verboseOpt = $ this -> getOption ( 'verbose' ) ) ) { $ this -> _verbose = ( bool ) $ verboseOpt ; $ this -> removeOption ( 'verbose' ) ; } return $ this -> _verbose ; }
|
Should the tab errors be verbose?
|
57,814
|
protected function _recurseForm ( \ Zend_Form $ form ) { $ subFormsWithErrors = array ( ) ; $ subFormMessages = array ( ) ; $ tabId = 0 ; foreach ( $ form -> getSubForms ( ) as $ subForm ) { if ( $ subForm instanceof \ Gems_Form_TabSubForm ) { foreach ( $ subForm -> getElements ( ) as $ subFormElement ) { $ elementMessages = $ subFormElement -> getMessages ( ) ; if ( count ( $ elementMessages ) ) { $ subFormsWithErrors [ $ tabId ] = $ subForm -> getAttrib ( 'title' ) ; $ subForm -> setAttrib ( 'jQueryParams' , array ( 'class' => 'taberror' ) ) ; $ form -> selectTab ( $ tabId ) ; break ; } } if ( array_key_exists ( $ tabId , $ subFormsWithErrors ) ) { $ subFormMessages [ $ tabId ] = $ subForm -> getCustomMessages ( ) ; } $ tabId ++ ; } } if ( $ this -> getVerbose ( ) && ( ! empty ( $ subFormsWithErrors ) || $ form -> isErrors ( ) ) ) { $ formMessage = $ form -> getCustomMessages ( ) ; if ( ! empty ( $ formMessage ) ) { foreach ( $ formMessage as $ message ) { \ Zend_Controller_Action_HelperBroker :: getStaticHelper ( 'FlashMessenger' ) -> addMessage ( $ message ) ; } } foreach ( $ subFormsWithErrors as $ tabIdx => $ tabName ) { if ( $ tabId > 1 ) { $ translator = \ Zend_Registry :: get ( 'Zend_Translate' ) ; \ Zend_Controller_Action_HelperBroker :: getStaticHelper ( 'FlashMessenger' ) -> addMessage ( sprintf ( $ translator -> _ ( 'Error in tab "%s"' ) , $ tabName ) ) ; } foreach ( $ subFormMessages [ $ tabIdx ] as $ subFormMessage ) { foreach ( $ subFormMessage as $ message ) { \ Zend_Controller_Action_HelperBroker :: getStaticHelper ( 'FlashMessenger' ) -> addMessage ( " . $ message ) ; } } } } }
|
Recurse through a form object rendering errors
|
57,815
|
public function runScript ( array $ data , $ includeResultSets = false ) { $ results = array ( ) ; if ( $ data [ 'script' ] ) { $ queries = \ MUtil_Parser_Sql_WordsParser :: splitStatements ( $ data [ 'script' ] , false ) ; $ qCount = count ( $ queries ) ; $ results [ ] = sprintf ( $ this -> _ ( 'Executed %2$s creation script %1$s:' ) , $ data [ 'name' ] , $ this -> _ ( strtolower ( $ data [ 'type' ] ) ) ) ; $ stepCount = 1 ; $ resultSet = 1 ; foreach ( $ queries as $ query ) { $ sql = ( string ) $ query ; try { if ( isset ( $ data [ 'db' ] ) ) { $ db = $ data [ 'db' ] ; } else { $ db = $ this -> defaultDb ; if ( isset ( $ data [ 'location' ] ) ) { foreach ( $ this -> directories as $ path ) { if ( $ path [ 'name' ] === $ data [ 'location' ] ) { $ db = $ path [ 'db' ] ; break ; } } } } $ stmt = $ db -> query ( $ sql ) ; if ( $ rows = $ stmt -> rowCount ( ) ) { if ( $ includeResultSets && ( $ data = $ stmt -> fetchAll ( ) ) ) { $ results [ ] = sprintf ( $ this -> _ ( '%d record(s) returned as result set %d in step %d of %d.' ) , $ rows , $ resultSet , $ stepCount , $ qCount ) ; $ results [ ] = $ data ; $ resultSet ++ ; } else { $ results [ ] = sprintf ( $ this -> _ ( '%d record(s) updated in step %d of %d.' ) , $ rows , $ stepCount , $ qCount ) ; } } else { $ results [ ] = sprintf ( $ this -> _ ( 'Script ran step %d of %d succesfully.' ) , $ stepCount , $ qCount ) ; } } catch ( \ Zend_Db_Statement_Exception $ e ) { $ results [ ] = $ e -> getMessage ( ) . $ this -> _ ( ' in step ' ) . $ stepCount . ': ' . $ sql ; } $ stepCount ++ ; } } else { $ results [ ] = sprintf ( $ this -> _ ( 'No script for %1$s.' ) , $ data [ 'name' ] ) ; } return $ results ; }
|
Run a sql statement from an object loaded through this model
|
57,816
|
public function getDateFormat ( ) { $ model = $ this -> getModel ( ) ; $ format = $ model -> get ( 'gap_admission_time' , 'dateFormat' ) ; if ( ! $ format ) { $ format = \ MUtil_Model_Bridge_FormBridge :: getFixedOption ( 'date' , 'dateFormat' ) ; } return $ format ; }
|
Get the date format used for the appointment date
|
57,817
|
public static function addnewAttributeFields ( array $ tokenTable , array $ missingFields ) { if ( ! isset ( $ tokenTable [ 'participant_id' ] ) ) { $ missingFields [ 'participant_id' ] = "ADD participant_id varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL" ; } if ( ! isset ( $ tokenTable [ 'blacklisted' ] ) ) { $ missingFields [ 'blacklisted' ] = "ADD blacklisted varchar(17) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL" ; } return $ missingFields ; }
|
Adds the fields without default new in 2 . 00
|
57,818
|
public function lsDbQuery ( $ sourceSurveyId , $ sql , $ bindValues = array ( ) ) { $ this -> _getFieldMap ( $ sourceSurveyId ) -> lsDbQuery ( $ sql , $ bindValues ) ; }
|
Execute a Database query on the limesurvey Database
|
57,819
|
protected function saveShare ( $ fromOrgId , $ fromRespId , $ toOrgId , $ toPatientId ) { $ model = $ this -> getModel ( ) ; try { $ result = $ model -> copyToOrg ( $ fromOrgId , $ fromRespId , $ toOrgId , $ toPatientId , $ this -> keepConsent ) ; } catch ( \ Exception $ exc ) { $ this -> addMessage ( $ exc -> getMessage ( ) ) ; return 0 ; } return $ model -> getChanged ( ) ; }
|
Copy the respondent
|
57,820
|
protected function saveTo ( $ fromOrgId , $ fromRespId , $ toOrgId , $ toPatientId ) { $ model = $ this -> getModel ( ) ; try { $ model -> move ( $ fromOrgId , $ fromRespId , $ toOrgId , $ toPatientId ) ; } catch ( \ Exception $ exc ) { $ this -> addMessage ( $ exc -> getMessage ( ) ) ; return 0 ; } return $ model -> getChanged ( ) ; }
|
Move the respondent
|
57,821
|
protected function addButtons ( \ MUtil_Html_HtmlElement $ html ) { $ buttonDiv = $ html -> buttonDiv ( ) ; $ buttonDiv -> actionLink ( array ( ) , $ this -> _ ( 'Close' ) , array ( 'onclick' => 'window.close();' ) ) ; $ buttonDiv -> actionLink ( array ( ) , $ this -> _ ( 'Print' ) , array ( 'onclick' => 'window.print();' ) ) ; }
|
Add the buttons to the result div
|
57,822
|
public function addHeaderInfo ( \ MUtil_Html_HtmlElement $ htmlDiv ) { $ htmlDiv -> h3 ( sprintf ( $ this -> _ ( '%s answers for patient number %s' ) , $ this -> token -> getSurveyName ( ) , $ this -> token -> getPatientNumber ( ) ) ) ; if ( ! $ this -> currentUser -> isFieldMaskedWhole ( 'name' ) ) { $ htmlDiv -> pInfo ( sprintf ( $ this -> _ ( 'Answers for token %s, patient number %s: %s.' ) , strtoupper ( $ this -> tokenId ) , $ this -> token -> getPatientNumber ( ) , $ this -> token -> getRespondentName ( ) ) ) -> appendAttrib ( 'class' , 'noprint' ) ; } }
|
Add elements that form the header
|
57,823
|
public function getFullDescription ( ) { if ( $ this -> _description ) { return $ this -> _description ; } $ descr = $ this -> getRoundDescription ( ) ; $ hasDescr = strlen ( trim ( $ descr ) ) ; $ order = $ this -> getRoundOrder ( ) ; $ survey = $ this -> getSurvey ( ) ; $ surveyExists = $ survey ? $ survey -> exists : false ; if ( $ order ) { if ( $ hasDescr ) { if ( $ surveyExists ) { $ this -> _description = sprintf ( $ this -> _ ( '%d: %s - %s' ) , $ order , $ descr , $ survey -> getName ( ) ) ; } else { $ this -> _description = sprintf ( $ this -> _ ( '%d: %s' ) , $ order , $ descr ) ; } } elseif ( $ surveyExists ) { $ this -> _description = sprintf ( $ this -> _ ( '%d: %s' ) , $ order , $ survey -> getName ( ) ) ; } else { $ this -> _description = $ order ; } } elseif ( $ hasDescr ) { if ( $ surveyExists ) { $ this -> _description = sprintf ( $ this -> _ ( '%s - %s' ) , $ descr , $ survey -> getName ( ) ) ; } else { $ this -> _description = $ descr ; } } else { if ( $ surveyExists ) { $ this -> _description = $ survey -> getName ( ) ; } else { $ this -> _description = '' ; } } return $ this -> _description ; }
|
Get a round description with order number and survey name
|
57,824
|
public function getSurvey ( ) { if ( false !== $ this -> _survey ) { return $ this -> _survey ; } $ surveyId = $ this -> getSurveyId ( ) ; if ( $ surveyId ) { $ this -> _survey = $ this -> tracker -> getSurvey ( $ surveyId ) ; } else { $ this -> _survey = null ; } return $ this -> _survey ; }
|
Get the survey id for this round
|
57,825
|
protected function getUserSelect ( $ login_name , $ organization ) { if ( ( 0 == ( $ this -> hoursResetKeyIsValid % 24 ) ) || \ Zend_Session :: $ _unitTestEnabled ) { $ resetExpr = 'CASE WHEN ADDDATE(gup_reset_requested, ' . intval ( $ this -> hoursResetKeyIsValid / 24 ) . ') >= CURRENT_TIMESTAMP THEN 1 ELSE 0 END' ; } else { $ resetExpr = 'CASE WHEN DATE_ADD(gup_reset_requested, INTERVAL ' . $ this -> hoursResetKeyIsValid . ' HOUR) >= CURRENT_TIMESTAMP THEN 1 ELSE 0 END' ; } $ select = new \ Zend_Db_Select ( $ this -> db ) ; $ select -> from ( 'gems__user_logins' , array ( 'user_login_id' => 'gul_id_user' , 'user_two_factor_key' => 'gul_two_factor_key' , 'user_enable_2factor' => 'gul_enable_2factor' , 'user_active' => 'gul_can_login' , ) ) -> join ( 'gems__respondent2org' , 'gul_login = gr2o_patient_nr AND gul_id_organization = gr2o_id_organization' , array ( 'user_login' => 'gr2o_patient_nr' , 'user_base_org_id' => 'gr2o_id_organization' , 'user_email' => 'gr2o_email' , ) ) -> join ( 'gems__respondents' , 'gr2o_id_user = grs_id_user' , array ( 'user_id' => 'grs_id_user' , 'user_first_name' => 'grs_first_name' , 'user_surname_prefix' => 'grs_surname_prefix' , 'user_last_name' => 'grs_last_name' , 'user_gender' => 'grs_gender' , 'user_locale' => 'grs_iso_lang' , 'user_birthday' => 'grs_birthday' , 'user_zip' => 'grs_zipcode' , ) ) -> join ( 'gems__organizations' , 'gr2o_id_organization = gor_id_organization' , array ( 'user_group' => 'gor_respondent_group' , ) ) -> join ( 'gems__groups' , 'gor_respondent_group = ggp_id_group' , array ( 'user_role' => 'ggp_role' , 'user_allowed_ip_ranges' => 'ggp_allowed_ip_ranges' , ) ) -> joinLeft ( 'gems__user_passwords' , 'gul_id_user = gup_id_user' , array ( 'user_password_reset' => 'gup_reset_required' , 'user_resetkey_valid' => new \ Zend_Db_Expr ( $ resetExpr ) , 'user_password_last_changed' => 'gup_last_pwd_change' , ) ) -> joinLeft ( 'gems__reception_codes' , 'gr2o_reception_code = grc_id_reception_code' , array ( ) ) -> where ( 'ggp_group_active = 1' ) -> where ( 'grc_success = 1' ) -> where ( 'gul_can_login = 1' ) -> where ( 'gul_login = ?' ) -> where ( 'gul_id_organization = ?' ) -> limit ( 1 ) ; return $ select ; }
|
A select used by subclasses to add fields to the select .
|
57,826
|
public function getTopic ( $ count = 1 ) { $ respondent = $ this -> getRespondent ( ) ; $ patientId = $ respondent -> getPatientNumber ( ) ; if ( $ patientId ) { if ( $ this -> currentUser -> areAllFieldsMaskedWhole ( 'grs_first_name' , 'grs_surname_prefix' , 'grs_last_name' ) ) { $ for = sprintf ( $ this -> _ ( 'for respondent number %s' ) , $ patientId ) ; } else { $ for = sprintf ( $ this -> _ ( 'for respondent number %s' ) , $ patientId ) ; } $ for = ' ' . $ for ; } else { $ for = '' ; } return $ this -> plural ( 'episode of care' , 'episodes of care' , $ count ) . $ for ; }
|
Helper function to allow generalized statements about the items in the model .
|
57,827
|
public function format ( $ row , $ model ) { foreach ( $ row as $ fieldname => $ value ) { $ row [ $ fieldname ] = $ this -> _format ( $ fieldname , $ row [ $ fieldname ] , $ model ) ; } return $ row ; }
|
Formats a row of data using the given model
|
57,828
|
protected function getOptionsFromConfig ( Config $ config ) { $ options = [ ] ; if ( $ config -> has ( 'visibility' ) ) { switch ( true ) { case $ config -> get ( 'visibility' ) === AdapterInterface :: VISIBILITY_PUBLIC : $ options [ 'predefinedAcl' ] = static :: GCS_VISIBILITY_PUBLIC_READ ; break ; case $ config -> get ( 'visibility' ) === AdapterInterface :: VISIBILITY_PRIVATE : default : $ options [ 'predefinedAcl' ] = static :: GCS_VISIBILITY_PROJECT_PRIVATE ; break ; } } return $ options ; }
|
Converts flysystem specific config to options for the underlying API client
|
57,829
|
protected function writeObject ( $ path , $ contents , Config $ config ) { $ path = $ this -> applyPathPrefix ( $ path ) ; $ metadata = [ 'name' => $ path , ] ; $ metadata += $ this -> getOptionsFromConfig ( $ config ) ; $ uploadedObject = $ this -> bucket -> upload ( $ contents , $ metadata ) ; $ uploadedObject -> reload ( ) ; return $ this -> convertObjectInfo ( $ uploadedObject ) ; }
|
Writes an object to the current
|
57,830
|
public function emailAction ( ) { $ model = $ this -> getModel ( ) ; $ model -> setFilter ( $ this -> getSearchFilter ( false ) ) ; $ sort = array ( 'gr2o_email' => SORT_ASC , 'grs_first_name' => SORT_ASC , 'grs_surname_prefix' => SORT_ASC , 'grs_last_name' => SORT_ASC , 'gto_valid_from' => SORT_ASC , 'gto_round_order' => SORT_ASC , 'gsu_survey_name' => SORT_ASC , ) ; if ( $ tokensData = $ model -> load ( true , $ sort ) ) { $ params [ 'mailTarget' ] = 'token' ; $ params [ 'menu' ] = $ this -> menu ; $ params [ 'model' ] = $ model ; $ params [ 'identifier' ] = $ this -> _getIdParam ( ) ; $ params [ 'view' ] = $ this -> view ; $ params [ 'routeAction' ] = 'index' ; $ params [ 'formTitle' ] = sprintf ( $ this -> _ ( 'Send mail to: %s' ) , $ this -> getTopic ( ) ) ; $ params [ 'templateOnly' ] = ! $ this -> currentUser -> hasPrivilege ( 'pr.token.mail.freetext' ) ; $ params [ 'multipleTokenData' ] = $ tokensData ; $ this -> addSnippet ( 'Mail_TokenBulkMailFormSnippet' , $ params ) ; } else { $ this -> addMessage ( $ this -> _ ( 'No tokens found.' ) ) ; } }
|
Bulk email action
|
57,831
|
public function indexAction ( ) { if ( $ this -> checkForAnswersOnLoad ) { $ this -> loader -> getTracker ( ) -> processCompletedTokens ( null , $ this -> currentUser -> getUserId ( ) , $ this -> currentUser -> getCurrentOrganizationId ( ) , true ) ; } parent :: indexAction ( ) ; }
|
Default overview action
|
57,832
|
public function extractFileAsText ( $ disableCache = false ) { $ file = $ this -> owner ; if ( ! $ disableCache ) { $ text = $ this -> getTextCache ( ) -> load ( $ file ) ; if ( $ text ) { return $ text ; } } $ extractor = FileTextExtractor :: for_file ( $ file ) ; if ( ! $ extractor ) { return null ; } $ text = $ extractor -> getContent ( $ file ) ; if ( ! $ text ) { return null ; } if ( ! $ disableCache ) { $ this -> getTextCache ( ) -> save ( $ file , $ text ) ; } return $ text ; }
|
Tries to parse the file contents if a FileTextExtractor class exists to handle the file type and returns the text . The value is also cached into the File record itself .
|
57,833
|
public function addElement ( \ Zend_Form_Element $ element ) { $ decorators = $ element -> getDecorators ( ) ; $ decorator = array_shift ( $ decorators ) ; $ element -> setDecorators ( array ( $ decorator , array ( 'Description' , array ( 'class' => 'description' ) ) , 'Errors' , array ( array ( 'data' => 'HtmlTag' ) , array ( 'tag' => 'td' , 'class' => 'element' ) ) , array ( 'Label' ) , array ( array ( 'labelCell' => 'HtmlTag' ) , array ( 'tag' => 'td' , 'class' => 'label' ) ) , array ( array ( 'row' => 'HtmlTag' ) , array ( 'tag' => 'tr' , 'class' => $ this -> _alternate ) ) ) ) ; return parent :: addElement ( $ element ) ; }
|
Add element to stack
|
57,834
|
public function showEpisode ( $ episodeId ) { if ( ! $ episodeId ) { return null ; } $ episode = $ this -> loader -> getAgenda ( ) -> getEpisodeOfCare ( $ episodeId ) ; if ( ! $ episode -> exists ) { return $ episodeId ; } $ episodeItem = $ this -> menu -> findAllowedController ( 'care-episode' , 'show' ) ; if ( $ episodeItem ) { $ href = $ episodeItem -> toHRefAttribute ( [ 'gec_episode_of_care_id' => $ episodeId ] ) ; } else { $ href = false ; } if ( ! $ href ) { return $ episode -> getDisplayString ( ) ; } $ onclick = new \ MUtil_Html_OnClickArrayAttribute ( ) ; $ onclick -> addCancelBubble ( true ) ; return \ MUtil_Html :: create ( 'a' , $ href , $ episode -> getDisplayString ( ) , $ onclick ) ; }
|
Display the episode
|
57,835
|
public function showRelation ( $ value ) { $ display = $ this -> calculateFieldInfo ( $ value , array ( ) ) ; if ( $ value == $ display ) { $ display = $ this -> _ ( '-' ) ; } return $ display ; }
|
Display a relation as text
|
57,836
|
protected function firstAllowedMenuItem ( $ action , $ action2 = null ) { $ actions = \ MUtil_Ra :: args ( func_get_args ( ) ) ; $ controller = $ this -> _getParam ( 'controller' ) ; foreach ( $ actions as $ action ) { $ menuItem = $ this -> menu -> find ( array ( 'controller' => $ controller , 'action' => $ action , 'allowed' => true ) ) ; if ( $ menuItem ) { return $ menuItem ; } } }
|
Finds the first item with one of the actions specified as parameter and using the current controller
|
57,837
|
public function getImporter ( ) { return $ this -> loader -> getImportLoader ( ) -> getImporter ( $ this -> getRequest ( ) -> getControllerName ( ) , $ this -> getModel ( ) ) ; }
|
Get an Importer object for this actions
|
57,838
|
public function getMessenger ( ) { if ( ! $ this -> messenger ) { $ this -> setMessenger ( $ this -> loader -> getMessenger ( ) ) ; } return $ this -> messenger ; }
|
Returns a session based message store for adding messages to .
|
57,839
|
public function initHtml ( $ reset = false ) { if ( ! $ this -> html ) { \ Gems_Html :: init ( ) ; } parent :: initHtml ( $ reset ) ; }
|
Intializes the html component .
|
57,840
|
public function setMessenger ( \ Zend_Controller_Action_Helper_FlashMessenger $ messenger ) { $ this -> messenger = $ messenger ; $ this -> view -> messenger = $ messenger ; return $ this ; }
|
Set the session based message store .
|
57,841
|
protected function getPreview ( $ templateArray ) { $ multi = false ; if ( count ( $ templateArray ) > 1 ) { $ multi = true ; $ allLanguages = $ this -> util -> getLocalized ( ) -> getLanguages ( ) ; } $ htmlView = \ MUtil_Html :: create ( ) -> div ( ) ; $ textView = \ MUtil_Html :: create ( ) -> div ( ) ; foreach ( $ templateArray as $ template ) { $ content = '' ; if ( $ template [ 'gctt_subject' ] || $ template [ 'gctt_body' ] ) { if ( $ multi ) { $ htmlView -> h3 ( ) -> append ( $ allLanguages [ $ template [ 'gctt_lang' ] ] ) ; $ textView -> h3 ( ) -> append ( $ allLanguages [ $ template [ 'gctt_lang' ] ] ) ; } $ content .= '[b]' ; $ content .= $ this -> _ ( 'Subject:' ) ; $ content .= '[/b] [i]' ; $ content .= $ this -> mailer -> applyFields ( $ template [ 'gctt_subject' ] ) ; $ content .= "[/i]\n\n" ; $ content .= $ this -> mailer -> applyFields ( $ template [ 'gctt_body' ] ) ; $ htmlView -> div ( array ( 'class' => 'mailpreview' ) ) -> raw ( \ MUtil_Markup :: render ( $ content , 'Bbcode' , 'Html' ) ) ; $ textView -> pre ( array ( 'class' => 'mailpreview' ) ) -> raw ( wordwrap ( \ MUtil_Markup :: render ( $ content , 'Bbcode' , 'Text' ) , 80 ) ) ; } } return array ( 'html' => $ htmlView , 'text' => $ textView ) ; }
|
Style the template previews
|
57,842
|
protected function loadFormData ( ) { parent :: loadFormData ( ) ; $ this -> loadMailer ( ) ; if ( isset ( $ this -> formData [ 'gctt' ] ) ) { $ multi = false ; if ( count ( $ this -> formData [ 'gctt' ] ) > 1 ) { $ multi = true ; $ allLanguages = $ this -> util -> getLocalized ( ) -> getLanguages ( ) ; } $ preview = $ this -> getPreview ( $ this -> formData [ 'gctt' ] ) ; $ this -> formData [ 'preview_html' ] = $ preview [ 'html' ] ; $ this -> formData [ 'preview_text' ] = $ preview [ 'text' ] ; } if ( ! isset ( $ this -> formData [ 'to' ] ) ) { $ organization = $ this -> mailer -> getOrganization ( ) ; $ this -> formData [ 'to' ] = $ this -> formData [ 'from' ] = $ this -> currentUser -> getEmailAddress ( ) ; if ( $ organization -> getEmail ( ) ) { $ this -> formData [ 'from' ] = $ organization -> getEmail ( ) ; } elseif ( $ this -> project -> getSiteEmail ( ) ) { $ this -> formData [ 'from' ] = $ this -> project -> getSiteEmail ( ) ; } } $ this -> formData [ 'available_fields' ] = $ this -> mailElements -> displayMailFields ( $ this -> mailer -> getMailFields ( ) ) ; }
|
Load extra data not from the model into the form
|
57,843
|
protected function loadMailer ( ) { $ this -> mailTarget = false ; if ( isset ( $ this -> formData [ 'gct_target' ] ) && isset ( $ this -> mailTargets [ $ this -> formData [ 'gct_target' ] ] ) ) { $ this -> mailTarget = $ this -> formData [ 'gct_target' ] ; } else { reset ( $ this -> mailTargets ) ; $ this -> mailTarget = key ( $ this -> mailTargets ) ; } $ this -> mailer = $ this -> loader -> getMailLoader ( ) -> getMailer ( $ this -> mailTarget ) ; }
|
Loads the correct mailer
|
57,844
|
protected function onFakeSubmit ( ) { if ( $ this -> request -> isPost ( ) ) { if ( ! empty ( $ this -> formData [ 'preview' ] ) ) { $ this -> addMessage ( $ this -> _ ( 'Preview updated' ) ) ; return ; } if ( ! empty ( $ this -> formData [ 'sendtest' ] ) ) { $ this -> mailer -> setTo ( $ this -> formData [ 'to' ] ) ; $ template = reset ( $ this -> formData [ 'gctt' ] ) ; $ languageId = key ( $ this -> formData [ 'gctt' ] ) ; if ( $ this -> formData [ 'send_language' ] ) { foreach ( $ this -> formData [ 'gctt' ] as $ languageId => $ templateLanguage ) { if ( $ templateLanguage [ 'gctt_lang' ] == $ this -> formData [ 'send_language' ] ) { $ template = $ templateLanguage ; } } } $ errors = false ; if ( ! $ template [ 'gctt_subject' ] ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'Subject required for %s part.' ) , strtoupper ( $ template [ 'gctt_lang' ] ) ) ) ; $ errors = true ; } if ( ! $ template [ 'gctt_body' ] ) { $ this -> addMessage ( sprintf ( $ this -> _ ( 'Body required for %s part.' ) , strtoupper ( $ template [ 'gctt_lang' ] ) ) ) ; $ errors = true ; } if ( $ errors ) { return ; } $ this -> mailer -> setFrom ( $ this -> formData [ 'from' ] ) ; $ this -> mailer -> setSubject ( $ template [ 'gctt_subject' ] ) ; $ this -> mailer -> setBody ( $ template [ 'gctt_body' ] , 'Bbcode' ) ; $ this -> mailer -> setTemplateId ( $ this -> formData [ 'gct_id_template' ] ) ; $ this -> mailer -> send ( ) ; $ this -> addMessage ( sprintf ( $ this -> _ ( 'Test mail sent to %s' ) , $ this -> formData [ 'to' ] ) ) ; } } }
|
When the form is submitted with a non save button
|
57,845
|
protected function _getArrayRendered ( ) { $ results = parent :: _getArrayRendered ( ) ; if ( isset ( $ results [ \ MUtil_Model :: REQUEST_ID1 ] , $ results [ \ MUtil_Model :: REQUEST_ID2 ] ) && ( $ results [ \ MUtil_Model :: REQUEST_ID2 ] == $ this -> _hiddenOrgId ) ) { $ results [ \ MUtil_Model :: REQUEST_ID ] = $ results [ \ MUtil_Model :: REQUEST_ID1 ] ; unset ( $ results [ \ MUtil_Model :: REQUEST_ID1 ] , $ results [ \ MUtil_Model :: REQUEST_ID2 ] ) ; } return $ results ; }
|
Returns the rendered values of th earray elements
|
57,846
|
public function formatValues ( $ value ) { $ options = $ this -> getOptions ( ) ; if ( is_array ( $ value ) ) { if ( $ options ) { foreach ( $ value as & $ val ) { if ( isset ( $ options [ $ val ] ) ) { $ val = $ options [ $ val ] ; } } } return implode ( $ this -> _ ( '; ' ) , $ value ) ; } if ( isset ( $ options [ $ value ] ) ) { return $ options [ $ value ] ; } return $ value ; }
|
This formatFunction is needed because the options are not set before the concatenated row
|
57,847
|
protected function getOptions ( $ trackId = null ) { if ( null === $ trackId ) { $ trackId = $ this -> _trackId ; } $ appFields = $ this -> db -> fetchPairs ( " SELECT gtap_id_app_field, gtap_field_name FROM gems__track_appointments WHERE gtap_id_track = ? ORDER BY gtap_id_order" , $ trackId ) ; $ options = array ( ) ; if ( $ appFields ) { foreach ( $ appFields as $ id => $ label ) { $ key = FieldsDefinition :: makeKey ( FieldMaintenanceModel :: APPOINTMENTS_NAME , $ id ) ; $ options [ $ key ] = $ label ; } } return $ options ; }
|
Get the calculate from options
|
57,848
|
protected function processSelect ( \ Zend_Db_Select $ select ) { $ select -> join ( 'gems__surveys' , 'gto_id_survey = gsu_id_survey' , array ( ) ) ; $ select -> join ( 'gems__groups' , 'gsu_id_primary_group = ggp_id_group' , array ( ) ) ; $ select -> join ( 'gems__respondents' , 'gto_id_respondent = grs_id_user' , array ( ) ) ; $ select -> join ( 'gems__respondent2org' , '(gto_id_organization = gr2o_id_organization AND gto_id_respondent = gr2o_id_user)' , array ( ) ) ; $ select -> join ( 'gems__respondent2track' , 'gto_id_respondent_track = gr2t_id_respondent_track' , array ( ) ) ; $ select -> join ( 'gems__reception_codes' , 'gto_reception_code = grc_id_reception_code' , array ( ) ) ; $ select -> joinLeft ( 'gems__respondent_relations' , '(gto_id_relation = grr_id AND gto_id_respondent = grr_id_respondent)' , array ( ) ) ; $ select -> joinLeft ( 'gems__track_fields' , '(gto_id_relationfield = gtf_id_field AND gtf_field_type = "relation")' , array ( ) ) ; }
|
Stub function to allow extension of standard one table select .
|
57,849
|
private function addSession ( Container $ container , string $ keysession , string $ value ) : bool { if ( $ container -> offsetExists ( $ keysession ) ) { return false ; } $ container -> offsetSet ( $ keysession , $ value ) ; return true ; }
|
Add new session data .
|
57,850
|
public function getLabeledColumns ( ) { if ( ! $ this -> model -> hasMeta ( 'labeledColumns' ) ) { $ orderedCols = $ this -> model -> getItemsOrdered ( ) ; $ results = array ( ) ; foreach ( $ orderedCols as $ name ) { if ( $ this -> model -> has ( $ name , 'label' ) ) { $ results [ ] = $ name ; } } $ this -> model -> setMeta ( 'labeledColumns' , $ results ) ; } return $ this -> model -> getMeta ( 'labeledColumns' ) ; }
|
Returns an array of ordered columnnames that have a label
|
57,851
|
protected function addFile ( ) { $ exportTempDir = GEMS_ROOT_DIR . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR ; if ( ! is_dir ( $ exportTempDir ) ) { \ MUtil_File :: ensureDir ( $ exportTempDir ) ; } $ tempFilename = $ exportTempDir . 'export-' . md5 ( time ( ) . rand ( ) ) ; $ this -> tempFilename = $ tempFilename ; $ basename = $ this -> cleanupName ( $ this -> model -> getName ( ) ) ; $ filename = $ basename ; $ i = 1 ; while ( isset ( $ this -> files [ $ filename . $ this -> fileExtension ] ) ) { $ filename = $ basename . '_' . $ i ; $ i ++ ; } $ this -> filename = $ filename ; $ this -> files [ $ filename . $ this -> fileExtension ] = $ tempFilename . $ this -> fileExtension ; $ file = fopen ( $ tempFilename . $ this -> fileExtension , 'w' ) ; fclose ( $ file ) ; }
|
Creates a new file and adds it to the files array
|
57,852
|
protected function cleanupName ( $ filename ) { $ filename = str_replace ( array ( '/' , '\\' , ':' , ' ' ) , '_' , $ filename ) ; $ filename = trim ( $ filename , '.' ) ; return \ MUtil_File :: cleanupName ( $ filename ) ; }
|
Clean a proposed filename up so it can be used correctly as a filename
|
57,853
|
protected function filterCsvInjection ( $ input ) { $ dangers = [ '=' , '+' , '-' , '@' ] ; $ trimmed = trim ( $ input ) ; if ( strlen ( $ trimmed ) > 1 && in_array ( $ trimmed [ 0 ] , $ dangers ) ) { return "'" . $ input ; } else { return $ input ; } }
|
Single point for mitigating csv injection vulnerabilities
|
57,854
|
protected function filterRow ( $ row ) { $ exportRow = array ( ) ; foreach ( $ row as $ columnName => $ result ) { if ( $ this -> model -> get ( $ columnName , 'label' ) ) { $ options = $ this -> model -> get ( $ columnName , $ this -> modelFilterAttributes ) ; foreach ( $ options as $ optionName => $ optionValue ) { switch ( $ optionName ) { case 'dateFormat' : if ( array_key_exists ( 'formatFunction' , $ options ) ) { continue ; } $ result = $ this -> filterDateFormat ( $ result , $ optionValue , $ columnName ) ; break ; case 'formatFunction' : $ result = $ this -> filterFormatFunction ( $ result , $ optionValue ) ; break ; case 'itemDisplay' : $ result = $ this -> filterItemDisplay ( $ result , $ optionValue ) ; break ; case 'multiOptions' : $ result = $ this -> filterMultiOptions ( $ result , $ optionValue ) ; break ; default : break ; } } if ( $ result instanceof \ MUtil_Date ) { $ result = $ this -> filterDateFormat ( $ result , 'yyyy-MM-dd HH:mm:ss' , $ columnName ) ; } $ result = $ this -> filterHtml ( $ result ) ; $ exportRow [ $ columnName ] = $ result ; } } return $ exportRow ; }
|
Filter the data in a row so that correct values are being used
|
57,855
|
protected function getAnswerModel ( array $ filter , array $ data , $ sort ) { $ exportModelSource = $ this -> loader -> getExportModelSource ( 'AnswerExportModelSource' ) ; $ model = $ exportModelSource -> getModel ( $ filter , $ data ) ; $ noExportColumns = $ model -> getColNames ( 'noExport' ) ; foreach ( $ noExportColumns as $ colName ) { $ model -> remove ( $ colName , 'label' ) ; } $ model -> applyParameters ( $ filter , true ) ; $ model -> addSort ( $ sort ) ; return $ model ; }
|
Return the answermodel for the given filter
|
57,856
|
protected function getFiles ( ) { if ( ! $ this -> files ) { $ files = array ( ) ; if ( $ this -> batch ) { $ files = $ this -> batch -> getSessionVariable ( 'files' ) ; } else { $ files = $ this -> _session -> files ; } if ( ! is_array ( $ files ) ) { $ files = array ( ) ; } $ this -> files = $ files ; } return $ this -> files ; }
|
Returns the files array . It might be stored in the batch session or normal session .
|
57,857
|
protected function getModelCount ( $ filter = true ) { if ( $ this -> model && $ this -> model instanceof \ MUtil_Model_ModelAbstract ) { $ totalCount = $ this -> model -> loadPaginator ( ) -> getTotalItemCount ( ) ; return $ totalCount ; } return 0 ; }
|
Get the number of items in a specific model using the models paginator
|
57,858
|
protected function _translateAndSort ( array $ pairs ) { $ translations = array_map ( [ $ this -> translateAdapter , '_' ] , $ pairs ) ; asort ( $ translations ) ; return $ translations ; }
|
Translate and sort while maintaining key association
|
57,859
|
public function getRedoValues ( ) { static $ data ; if ( ! $ data ) { $ data = array ( self :: REDO_NONE => $ this -> _ ( 'No' ) , self :: REDO_ONLY => $ this -> _ ( 'Yes (forget answers)' ) , self :: REDO_COPY => $ this -> _ ( 'Yes (keep answers)' ) ) ; } return $ data ; }
|
Return the field values for the redo code .
|
57,860
|
public function getSurveyApplicationValues ( ) { static $ data ; if ( ! $ data ) { $ data = array ( self :: APPLY_NOT => $ this -> _ ( 'No' ) , self :: APPLY_DO => $ this -> _ ( 'Yes (for individual tokens)' ) , self :: APPLY_STOP => $ this -> _ ( 'Stop (for tokens in uncompleted tracks)' ) ) ; } return $ data ; }
|
Return the field values for surveys .
|
57,861
|
public function addByController ( $ controller , $ action = 'index' , $ label = null ) { $ query [ 'controller' ] = $ controller ; $ query [ 'action' ] = $ action ; if ( $ menuItem = $ this -> menu -> findFirst ( $ query ) ) { $ this -> addMenuItem ( $ menuItem , $ label ) ; } return $ this ; }
|
Add a menu item by specifying the controller
|
57,862
|
public function addCurrentChildren ( ) { foreach ( $ this -> menu -> getCurrentChildren ( ) as $ menuItem ) { $ this -> addMenuItem ( $ menuItem ) ; } return $ this ; }
|
Adds the children of the current menu item to this list
|
57,863
|
public function addCurrentGrandParent ( $ label = null ) { $ parent = $ this -> menu -> getCurrentParent ( ) ; if ( $ parent && ( ! $ parent -> isTopLevel ( ) ) ) { $ grandPa = $ parent -> getParent ( ) ; if ( $ grandPa && ( ! $ grandPa -> isTopLevel ( ) ) ) { $ this -> addMenuItem ( $ grandPa , $ label ) ; } } return $ this ; }
|
Adds the parent of parent of the current menu item
|
57,864
|
public function addCurrentParent ( $ label = null ) { $ parent = $ this -> menu -> getCurrentParent ( ) ; if ( $ parent && ( ! $ parent -> isTopLevel ( ) ) ) { $ this -> addMenuItem ( $ parent , $ label ) ; } return $ this ; }
|
Adds the parent of the current menu item
|
57,865
|
public function addMenuItem ( \ Gems_Menu_SubMenuItem $ menuItem , $ label = null ) { $ key = $ this -> _getKey ( $ menuItem -> get ( 'controller' ) , $ menuItem -> get ( 'action' ) ) ; if ( $ label ) { $ this -> altLabels [ $ key ] = $ label ; } $ this -> offsetSet ( $ key , $ menuItem ) ; return $ this ; }
|
Add a menu item to this list
|
57,866
|
public function getActionLinks ( $ remove , $ contr1 , $ action1 = null , $ contr2 = null , $ action2 = null ) { $ args = func_get_args ( ) ; $ count = func_num_args ( ) ; $ results = new \ MUtil_Html_Sequence ( ) ; $ results -> setGlue ( $ this -> getGlue ( ) ) ; for ( $ i = 1 ; $ i < $ count ; $ i += 2 ) { $ controller = $ args [ $ i ] ; $ action = $ args [ $ i + 1 ] ; $ result = $ this -> getActionLink ( $ controller , $ action , $ remove ) ; if ( $ result ) { $ results [ $ this -> _getKey ( $ controller , $ action ) ] = $ result ; } } return $ results ; }
|
Get the action links for the specified items .
|
57,867
|
public function setLabel ( $ controller , $ action , $ label ) { $ key = $ this -> _getKey ( $ controller , $ action ) ; $ this -> altLabels [ $ key ] = $ label ; return $ this ; }
|
Changes the label for a specific menu item
|
57,868
|
public function get ( $ parameter ) { return isset ( $ this -> credentials [ $ parameter ] ) ? $ this -> credentials [ $ parameter ] : null ; }
|
Get a single credential parameter .
|
57,869
|
protected function executeAction ( $ from = null , $ to = null ) { $ context = $ this -> getRequest ( ) -> getParam ( 'id' , 'gems' ) ; $ from = $ this -> getRequest ( ) -> getParam ( 'from' , $ from ) ; $ to = $ this -> getRequest ( ) -> getParam ( 'to' , $ to ) ; $ batch = $ this -> loader -> getTaskRunnerBatch ( 'upgrade' . $ context ) ; $ batch -> minimalStepDurationMs = 3000 ; if ( ! $ batch -> isLoaded ( ) ) { $ this -> _upgrades -> setBatch ( $ batch ) ; $ this -> _upgrades -> execute ( $ context , $ to , $ from ) ; } $ title = sprintf ( $ this -> _ ( 'Upgrading %s' ) , $ context ) ; $ this -> _helper -> BatchRunner ( $ batch , $ title , $ this -> accesslog ) ; $ this -> html -> br ( ) ; $ this -> compatibilityReportAction ( ) ; }
|
Executes the upgrades for a certain context
|
57,870
|
public function indexAction ( ) { $ this -> html -> h2 ( $ this -> getTopicTitle ( ) ) ; $ displayColumns = array ( 'link' => '' , 'context' => $ this -> _ ( 'Context' ) , 'maxLevel' => $ this -> _ ( 'Max level' ) , 'level' => $ this -> _ ( 'Level' ) ) ; foreach ( $ this -> _upgrades -> getUpgradesInfo ( ) as $ row ) { $ menuItem = $ this -> menu -> findAllowedController ( $ this -> _getParam ( 'controller' ) , 'show' ) ; if ( $ menuItem ) { $ row [ 'link' ] = $ menuItem -> toActionLinkLower ( $ this -> getRequest ( ) , $ row ) ; } $ data [ ] = $ row ; } $ this -> addSnippet ( 'SelectiveTableSnippet' , 'data' , $ data , 'class' , 'browser table' , 'columns' , $ displayColumns ) ; $ this -> html -> br ( ) ; $ this -> compatibilityReportAction ( ) ; }
|
Overview of available contexts max upgrade level and achieved upgrade level
|
57,871
|
public function showAction ( ) { $ this -> html -> h2 ( $ this -> getTopicTitle ( ) ) ; $ context = $ this -> _getParam ( 'id' , 'gems' ) ; $ this -> _upgrades -> setContext ( $ context ) ; if ( $ info = $ this -> _upgrades -> getUpgradesInfo ( $ context ) ) { $ this -> html -> table ( array ( 'class' => 'browser' ) ) -> tr ( ) -> th ( $ this -> _ ( 'Context' ) ) -> td ( $ info [ 'context' ] ) -> tr ( ) -> th ( $ this -> _ ( 'Level' ) ) -> td ( $ info [ 'level' ] ) ; $ data = $ this -> _upgrades -> getUpgrades ( ) ; foreach ( $ data as $ level => $ row ) { foreach ( $ this -> menu -> getCurrent ( ) -> getChildren ( ) as $ menuItem ) { if ( $ menuItem -> is ( 'allowed' , true ) ) { $ show = true ; if ( $ level <= $ info [ 'level' ] && $ menuItem -> is ( 'action' , 'execute-to' ) ) { $ show = false ; } if ( $ level <= $ info [ 'level' ] && $ menuItem -> is ( 'action' , 'execute-from' ) ) { $ show = false ; } if ( $ show ) { $ row [ 'action' ] [ ] = $ menuItem -> toActionLinkLower ( $ this -> getRequest ( ) , $ row , array ( 'from' => $ level , 'to' => $ level ) ) ; } } } $ row [ 'level' ] = $ level ; $ data [ $ level ] = $ row ; } $ displayColumns = array ( 'level' => $ this -> _ ( 'Level' ) , 'info' => $ this -> _ ( 'Description' ) , 'action' => $ this -> _ ( 'Action' ) ) ; $ this -> addSnippet ( 'SelectiveTableSnippet' , 'data' , $ data , 'class' , 'browser' , 'columns' , $ displayColumns ) ; } else { $ this -> html [ ] = sprintf ( $ this -> _ ( 'Context %s not found!' ) , $ context ) ; } if ( $ parentItem = $ this -> menu -> getCurrent ( ) -> getParent ( ) ) { $ this -> html [ ] = $ parentItem -> toActionLink ( $ this -> getRequest ( ) , $ this -> _ ( 'Cancel' ) ) ; } }
|
Show the upgrades and level for a certain context
|
57,872
|
public function getSelectedUser ( ) { static $ user = null ; if ( $ user !== null ) { return $ user ; } $ staffId = $ this -> _getIdParam ( ) ; if ( $ staffId ) { $ user = $ this -> loader -> getUserLoader ( ) -> getUserByStaffId ( $ staffId ) ; $ source = $ this -> menu -> getParameterSource ( ) ; $ user -> applyToMenuSource ( $ source ) ; } else { $ user = false ; } return $ user ; }
|
Load the user selected by the request - if any
|
57,873
|
public function executeIteration ( $ userId = 0 ) { $ tracker = $ this -> loader -> getTracker ( ) ; $ select = $ tracker -> getTokenSelect ( ) -> andReceptionCodes ( [ ] ) -> onlyCompleted ( ) -> onlySucces ( ) -> forSurveyId ( $ this -> sourceSurveyId ) -> getSelect ( ) -> limit ( 1 ) ; $ results = $ this -> db -> fetchAll ( $ select ) ; $ batch = $ this -> getBatch ( ) ; $ batch -> addToCounter ( 'movesteps' , - 1 ) ; if ( count ( $ results ) == 0 ) { $ this -> _finished = true ; return ; } $ tokenData = reset ( $ results ) ; $ token = $ tracker -> getToken ( $ tokenData ) ; $ answers = $ token -> getRawAnswers ( ) ; if ( ! empty ( $ answers ) ) { $ convertedAnswers = [ ] ; foreach ( $ this -> targetFields as $ target => $ source ) { if ( ! empty ( $ source ) && array_key_exists ( $ source , $ answers ) ) { $ convertedAnswers [ $ target ] = $ answers [ $ source ] ; } } $ values = [ 'gto_id_survey' => $ this -> targetSurveyId , ] + $ tokenData ; unset ( $ values [ 'token_status' ] ) ; $ newTokenId = $ token -> createReplacement ( sprintf ( $ this -> _ ( 'Copied from old survey: %s' ) , $ this -> sourceSurveyName ) , $ userId , $ values ) ; $ newToken = $ tracker -> getToken ( $ newTokenId ) ; $ newToken -> getSurvey ( ) -> copyTokenToSource ( $ newToken , '' ) ; $ newToken -> setRawAnswers ( $ convertedAnswers ) ; $ batch -> addToCounter ( 'moved' ) ; } else { $ batch -> addToCounter ( 'notfound' ) ; } $ token -> setReceptionCode ( $ this -> movedCode , sprintf ( $ this -> _ ( 'Copied to new survey: %s' ) , $ this -> targetSurveyName ) , $ userId ) ; }
|
Execute a single iteration of the task .
|
57,874
|
public function isFinished ( ) { $ batch = $ this -> getBatch ( ) ; if ( $ this -> _finished ) { $ batch -> resetCounter ( 'movestarted' ) ; $ moved = $ batch -> getCounter ( 'moved' ) ; $ notFound = $ batch -> getCounter ( 'notfound' ) ; $ this -> getBatch ( ) -> addMessage ( sprintf ( $ this -> _ ( '%d \'%s\' survey answers have been copied to \'%s\'.' ) , $ moved , $ this -> sourceSurveyName , $ this -> targetSurveyName ) ) ; if ( $ notFound > 0 ) { $ this -> getBatch ( ) -> addMessage ( sprintf ( $ this -> _ ( 'For %d tokens no answers were found.' ) , $ notFound ) ) ; } } else { if ( $ this -> getBatch ( ) -> getCounter ( 'movesteps' ) === 0 ) { $ this -> getBatch ( ) -> addStepCount ( 1 ) ; } } return $ this -> _finished ; }
|
Return true when the task has finished .
|
57,875
|
protected function setNonExistent ( $ nonexistent ) { if ( $ nonexistent ) { $ translatedNonexistent = [ ] ; foreach ( $ nonexistent as $ right => $ values ) { foreach ( $ values as $ key => $ value ) { if ( $ key == 'menu' ) { continue ; } $ translatedNonexistent [ $ right ] [ $ this -> _ ( ucfirst ( $ key ) ) ] = $ value ; } } $ this -> indexParameters [ 'tableTitle' ] = $ this -> _ ( 'Assigned but nonexistent privileges' ) ; $ this -> indexParameters [ 'tableData' ] = $ translatedNonexistent ; $ this -> indexParameters [ 'tableNested' ] = true ; $ this -> indexStopSnippets [ ] = 'Generic\\DataTableSnippet' ; } }
|
Set assigned but nonexistent privileges and a snippet at the bottom of the page
|
57,876
|
public function getVersion ( ) { $ version = $ this -> getProjectVersion ( ) ; if ( APPLICATION_ENV !== 'production' && APPLICATION_ENV !== 'acceptance' && APPLICATION_ENV !== 'demo' ) { $ version .= '.' . $ this -> getBuild ( ) . ' [' . APPLICATION_ENV . ']' ; } return $ version ; }
|
The long string versions
|
57,877
|
public function resampleImage ( ) { $ extension = strtolower ( $ this -> owner -> getExtension ( ) ) ; if ( $ this -> owner -> getHeight ( ) > $ this -> getMaxX ( ) || $ this -> owner -> getWidth ( ) > $ this -> getMaxY ( ) ) { $ original = $ this -> owner -> getFullPath ( ) ; $ resampled = $ original . '.tmp.' . $ extension ; $ gd = new GD ( $ original ) ; if ( $ gd -> hasImageResource ( ) ) { $ gd = $ gd -> resizeRatio ( $ this -> getMaxX ( ) , $ this -> getMaxY ( ) ) ; if ( $ gd ) { $ gd -> writeTo ( $ resampled ) ; unlink ( $ original ) ; rename ( $ resampled , $ original ) ; } } } }
|
Resamples the image to the maximum Height and Width
|
57,878
|
public function array_filter ( $ inputArray , $ model ) { $ outputArray = array ( ) ; foreach ( $ inputArray as $ key => $ value ) { if ( is_null ( $ value ) || $ value === '' ) { continue ; } if ( $ value == '0' && $ options = $ model -> get ( $ key , 'multiOptions' ) ) { if ( count ( $ options ) == 2 ) { continue ; } } $ outputArray [ $ key ] = $ value ; } return $ outputArray ; }
|
Strip elements from the array that are considered empty
|
57,879
|
protected function _createTrack ( $ filter , $ tracker ) { $ trackData = array ( 'gr2t_comment' => sprintf ( $ this -> _ ( 'Track created by %s filter' ) , $ filter -> getName ( ) ) ) ; $ fields = array ( $ filter -> getFieldId ( ) => $ this -> getId ( ) ) ; $ trackId = $ filter -> getTrackId ( ) ; $ respTrack = $ tracker -> createRespondentTrack ( $ this -> getRespondentId ( ) , $ this -> getOrganizationId ( ) , $ trackId , $ this -> currentUser -> getUserId ( ) , $ trackData , $ fields ) ; return $ respTrack ; }
|
Create a new track for this appointment and the given filter
|
57,880
|
protected function checkCreateTracks ( $ filters , $ existingTracks , $ tracker ) { $ tokenChanges = 0 ; foreach ( $ filters as $ filter ) { if ( ! $ filter -> isCreator ( ) ) { continue ; } $ createTrack = true ; $ method = $ this -> getCreatorCheckMethod ( $ filter -> getCreatorType ( ) ) ; $ trackId = $ filter -> getTrackId ( ) ; $ tracks = array_key_exists ( $ trackId , $ existingTracks ) ? $ existingTracks [ $ trackId ] : [ ] ; foreach ( $ tracks as $ respTrack ) { if ( ! $ respTrack -> hasSuccesCode ( ) ) { continue ; } $ createTrack = $ this -> $ method ( $ filter , $ respTrack ) ; if ( $ createTrack === false ) { break ; } } if ( $ createTrack ) { $ respTrack = $ this -> _createTrack ( $ filter , $ tracker ) ; $ existingTracks [ $ trackId ] [ ] = $ respTrack ; $ tokenChanges += $ respTrack -> getCount ( ) ; } } return $ tokenChanges ; }
|
Check if a track should be created for any of the filters
|
57,881
|
public function createWhenNotInThisTrack ( $ filter , $ respTrack ) { $ createTrack = true ; $ data = $ respTrack -> getFieldData ( ) ; if ( isset ( $ data [ $ filter -> getFieldId ( ) ] ) && ( $ this -> getId ( ) == $ data [ $ filter -> getFieldId ( ) ] ) ) { $ createTrack = false ; } return $ createTrack ; }
|
Create when current appointment is not assigned to this field already
|
57,882
|
public function getAdmissionTime ( ) { if ( isset ( $ this -> _gemsData [ 'gap_admission_time' ] ) && $ this -> _gemsData [ 'gap_admission_time' ] ) { if ( ! $ this -> _gemsData [ 'gap_admission_time' ] instanceof \ MUtil_Date ) { $ this -> _gemsData [ 'gap_admission_time' ] = new \ MUtil_Date ( $ this -> _gemsData [ 'gap_admission_time' ] , \ Gems_Tracker :: DB_DATETIME_FORMAT ) ; } return clone $ this -> _gemsData [ 'gap_admission_time' ] ; } }
|
Return the admission time
|
57,883
|
public function getProcedureDescription ( ) { if ( ! ( isset ( $ this -> _gemsData [ 'gap_id_procedure' ] ) && $ this -> _gemsData [ 'gap_id_procedure' ] ) ) { return null ; } if ( ! array_key_exists ( 'gapr_name' , $ this -> _gemsData ) ) { $ sql = "SELECT gapr_name FROM gems__agenda_procedures WHERE gapr_id_procedure = ?" ; $ this -> _gemsData [ 'gapr_name' ] = $ this -> db -> fetchOne ( $ sql , $ this -> _gemsData [ 'gap_id_procedure' ] ) ; if ( false === $ this -> _gemsData [ 'gapr_name' ] ) { $ this -> _gemsData [ 'gapr_name' ] = null ; } } return $ this -> _gemsData [ 'gapr_name' ] ; }
|
Return the description of the current procedure
|
57,884
|
public function getRespondent ( ) { return $ this -> loader -> getRespondent ( $ this -> getPatientNumber ( ) , $ this -> getOrganizationId ( ) , $ this -> getRespondentId ( ) ) ; }
|
Return the respondent object
|
57,885
|
public function isActive ( ) { return $ this -> exists && isset ( $ this -> _gemsData [ 'gap_status' ] ) && $ this -> agenda -> isStatusActive ( $ this -> _gemsData [ 'gap_status' ] ) ; }
|
Return true when the status is active
|
57,886
|
public function updateTracks ( ) { $ tokenChanges = 0 ; $ tracker = $ this -> loader -> getTracker ( ) ; $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__respondent2track2appointment' , array ( 'gr2t2a_id_respondent_track' ) ) -> joinInner ( 'gems__respondent2track' , 'gr2t_id_respondent_track = gr2t2a_id_respondent_track' , array ( 'gr2t_id_track' ) ) -> where ( 'gr2t2a_id_appointment = ?' , $ this -> _appointmentId ) -> distinct ( ) ; $ filters = $ this -> agenda -> matchFilters ( $ this ) ; if ( $ filters ) { $ ids = array_map ( function ( $ value ) { return $ value -> getTrackId ( ) ; } , $ filters ) ; $ respId = $ this -> getRespondentId ( ) ; $ orgId = $ this -> getOrganizationId ( ) ; $ select -> orWhere ( "gr2t_id_user = $respId AND gr2t_id_organization = $orgId AND gr2t_id_track IN (" . implode ( ', ' , $ ids ) . ")" ) ; } $ respTracks = $ this -> db -> fetchPairs ( $ select ) ; $ existingTracks = array ( ) ; if ( $ respTracks ) { foreach ( $ respTracks as $ respTrackId => $ trackId ) { $ respTrack = $ tracker -> getRespondentTrack ( $ respTrackId ) ; $ fieldsChanged = false ; $ tokenChanges += $ respTrack -> recalculateFields ( $ fieldsChanged ) ; $ existingTracks [ $ trackId ] [ ] = $ respTrack ; } } if ( $ this -> isActive ( ) && $ this -> getAdmissionTime ( ) -> isLaterOrEqual ( new \ MUtil_Date ( ) ) ) { $ tokenChanges += $ this -> checkCreateTracks ( $ filters , $ existingTracks , $ tracker ) ; } return $ tokenChanges ; }
|
Recalculate all tracks that use this appointment
|
57,887
|
private function _deleteCache ( ) { if ( $ this -> _cache instanceof \ Zend_Cache_Core ) { $ this -> _cache -> remove ( $ this -> _cacheid ) ; $ this -> _cache -> remove ( $ this -> _cacheid . 'trans' ) ; } }
|
Empty this cache instance
|
57,888
|
private function _expandRole ( & $ roleList , $ roleName , $ depth = 0 ) { $ role = $ roleList [ $ roleName ] ; if ( isset ( $ role [ 'marked' ] ) && $ role [ 'marked' ] ) { return ; } if ( $ depth > 5 ) { throw new \ Exception ( "Possible circular reference detected while expanding role '{$roleName}'" ) ; } if ( ! empty ( $ role [ 'grl_parents' ] ) ) { $ parents = $ this -> translateToRoleNames ( $ role [ 'grl_parents' ] ) ; foreach ( $ parents as $ parent ) { $ this -> _expandRole ( $ roleList , $ parent , $ depth + 1 ) ; } } else { $ parents = array ( ) ; } $ this -> _acl -> addRole ( new \ Zend_Acl_Role ( $ role [ 'grl_name' ] ) , $ parents ) ; $ privileges = array_filter ( array_map ( 'trim' , explode ( "," , $ role [ 'grl_privileges' ] ) ) ) ; if ( $ privileges ) { $ this -> _acl -> addPrivilege ( $ role [ 'grl_name' ] , $ privileges ) ; } $ roleList [ $ roleName ] [ 'marked' ] = true ; }
|
Recursively expands roles into \ Zend_Acl_Role objects
|
57,889
|
private function _initAcl ( ) { $ this -> _acl = new \ MUtil_Acl ( ) ; if ( get_class ( self :: $ _instanceOfSelf ) !== 'Gems_Roles' ) { throw new \ Gems_Exception_Coding ( "Don't use project specific roles file anymore, you can now do so by using the gems_roles tabel and setup->roles from the interface." ) ; } try { $ this -> loadDbAcl ( ) ; } catch ( \ Exception $ e ) { \ Gems_Log :: getLogger ( ) -> logError ( $ e ) ; unset ( $ this -> _acl ) ; $ this -> _acl = new \ MUtil_Acl ( ) ; $ this -> loadDefaultRoles ( ) ; $ this -> loadDefaultPrivileges ( ) ; } if ( ! $ this -> _acl -> hasRole ( 'master' ) ) { $ this -> _acl -> addRole ( 'master' ) ; } $ this -> _acl -> allow ( 'master' ) ; $ this -> _acl -> deny ( 'master' , null , 'pr.nologin' ) ; }
|
Reset de ACL en bouw opnieuw op
|
57,890
|
public static function getInstance ( ) { if ( ! isset ( self :: $ _instanceOfSelf ) ) { $ c = __CLASS__ ; self :: $ _instanceOfSelf = new $ c ; } return self :: $ _instanceOfSelf ; }
|
Static acces function
|
57,891
|
public function loadDbAcl ( ) { $ db = \ Zend_Registry :: get ( 'db' ) ; $ sql = "SELECT grl_id_role, grl_name, grl_privileges, grl_parents FROM gems__roles" ; $ roles = $ db -> fetchAll ( $ sql ) ; if ( empty ( $ roles ) ) { throw new \ Exception ( "No roles stored in db" ) ; } foreach ( $ roles as $ role ) { $ this -> _roleTranslations [ $ role [ 'grl_id_role' ] ] = $ role [ 'grl_name' ] ; } $ roleList = array_combine ( array_map ( function ( $ value ) { return $ value [ 'grl_name' ] ; } , $ roles ) , $ roles ) ; foreach ( $ roleList as $ role ) { $ this -> _expandRole ( $ roleList , $ role [ 'grl_name' ] ) ; } return true ; }
|
Load access control list from db
|
57,892
|
public function translateToRoleId ( $ role ) { $ lookup = array_flip ( $ this -> _roleTranslations ) ; if ( isset ( $ lookup [ $ role ] ) ) { return $ lookup [ $ role ] ; } return $ role ; }
|
Translate string role id to numeric role id
|
57,893
|
public function translateToRoleIds ( $ roles ) { if ( ! is_array ( $ roles ) ) { if ( $ roles ) { $ roles = explode ( "," , $ roles ) ; } else { $ roles = array ( ) ; } } $ lookup = array_flip ( $ this -> _roleTranslations ) ; foreach ( $ roles as $ key => $ role ) { if ( isset ( $ lookup [ $ role ] ) ) { $ roles [ $ key ] = $ lookup [ $ role ] ; } } return $ roles ; }
|
Translate all string role id s to numeric role ids
|
57,894
|
public function translateToRoleName ( $ role ) { if ( isset ( $ this -> _roleTranslations [ $ role ] ) ) { return $ this -> _roleTranslations [ $ role ] ; } return $ role ; }
|
Translate numeric role id to string name
|
57,895
|
public function translateToRoleNames ( $ roles ) { if ( ! is_array ( $ roles ) ) { if ( $ roles ) { $ roles = explode ( "," , $ roles ) ; } else { $ roles = array ( ) ; } } foreach ( $ roles as $ key => $ role ) { if ( isset ( $ this -> _roleTranslations [ $ role ] ) ) { $ roles [ $ key ] = $ this -> _roleTranslations [ $ role ] ; } } return $ roles ; }
|
Translate all numeric role id s to string names
|
57,896
|
public function getRespondent ( $ patientId , $ organizationId , $ respondentId = null ) { if ( $ patientId ) { if ( isset ( $ this -> _respondents [ $ organizationId ] [ $ patientId ] ) ) { return $ this -> _respondents [ $ organizationId ] [ $ patientId ] ; } } $ newResp = $ this -> _loadClass ( 'Tracker_Respondent' , true , array ( $ patientId , $ organizationId , $ respondentId ) ) ; $ patientId = $ newResp -> getPatientNumber ( ) ; if ( ! isset ( $ this -> _respondents [ $ organizationId ] [ $ patientId ] ) ) { $ this -> _respondents [ $ organizationId ] [ $ patientId ] = $ newResp ; } return $ this -> _respondents [ $ organizationId ] [ $ patientId ] ; }
|
Get a respondent object
|
57,897
|
public function getFieldId ( ) { if ( isset ( $ this -> _data [ 'gtap_id_app_field' ] ) && $ this -> _data [ 'gtap_id_app_field' ] ) { return FieldsDefinition :: makeKey ( FieldMaintenanceModel :: APPOINTMENTS_NAME , $ this -> _data [ 'gtap_id_app_field' ] ) ; } }
|
The field id as it is recognized be the track engine
|
57,898
|
public function getWaitDays ( ) { if ( isset ( $ this -> _data [ 'gtap_create_wait_days' ] , $ this -> _data [ 'gtap_create_track' ] ) && $ this -> _data [ 'gtap_create_track' ] ) { return intval ( $ this -> _data [ 'gtap_create_wait_days' ] ) ; } }
|
The number of days to wait between track creation
|
57,899
|
public function serialize ( ) { $ data = array ( ) ; foreach ( get_object_vars ( $ this ) as $ name => $ value ) { if ( ! $ this -> filterRequestNames ( $ name ) ) { $ data [ $ name ] = $ value ; } } return serialize ( $ data ) ; }
|
By default only object variables starting with _ are serialized in order to avoid serializing any resource types loaded by \ MUtil_Translate_TranslateableAbstract
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.