idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
59,800
public function export ( ) { $ rows = [ ] ; foreach ( $ this -> messages as $ message ) { list ( $ text , $ level , $ category , $ timestamp ) = $ message ; if ( ! is_string ( $ text ) ) { if ( $ text instanceof \ Throwable || $ text instanceof \ Exception ) { $ text = ( string ) $ text ; } else { $ text = VarDumper ::...
Stores log messages to MongoDB collection .
59,801
public function complete ( ) { $ this -> flushBuffer ( true ) ; $ document = $ this -> insertFile ( ) ; $ this -> _isComplete = true ; return $ document ; }
Completes upload .
59,802
public function cancel ( ) { $ this -> _buffer = null ; $ this -> collection -> getChunkCollection ( ) -> remove ( [ 'files_id' => $ this -> _documentId ] , [ 'limit' => 0 ] ) ; $ this -> collection -> remove ( [ '_id' => $ this -> _documentId ] , [ 'limit' => 1 ] ) ; $ this -> _isComplete = true ; }
Cancels the upload .
59,803
private function insertChunk ( $ data ) { $ chunkDocument = [ 'files_id' => $ this -> _documentId , 'n' => $ this -> chunkCount , 'data' => new Binary ( $ data , Binary :: TYPE_GENERIC ) , ] ; hash_update ( $ this -> _hashContext , $ data ) ; $ this -> collection -> getChunkCollection ( ) -> insert ( $ chunkDocument ) ...
Inserts file chunk .
59,804
protected function extractFileName ( $ file ) { if ( $ file instanceof UploadedFile ) { return $ file -> tempName ; } elseif ( is_string ( $ file ) ) { if ( file_exists ( $ file ) ) { return $ file ; } throw new InvalidParamException ( "File '{$file}' does not exist." ) ; } throw new InvalidParamException ( 'Unsupporte...
Extracts filename from given raw file value .
59,805
public function getFileContent ( ) { $ file = $ this -> getAttribute ( 'file' ) ; if ( empty ( $ file ) && ! $ this -> getIsNewRecord ( ) ) { $ file = $ this -> refreshFile ( ) ; } if ( empty ( $ file ) ) { return null ; } elseif ( $ file instanceof Download ) { $ fileSize = $ file -> getSize ( ) ; return empty ( $ fil...
Returns the associated file content .
59,806
public function writeFile ( $ filename ) { $ file = $ this -> getAttribute ( 'file' ) ; if ( empty ( $ file ) && ! $ this -> getIsNewRecord ( ) ) { $ file = $ this -> refreshFile ( ) ; } if ( empty ( $ file ) ) { throw new InvalidParamException ( 'There is no file associated with this object.' ) ; } elseif ( $ file ins...
Writes the the internal file content into the given filename .
59,807
public function getFileResource ( ) { $ file = $ this -> getAttribute ( 'file' ) ; if ( empty ( $ file ) && ! $ this -> getIsNewRecord ( ) ) { $ file = $ this -> refreshFile ( ) ; } if ( empty ( $ file ) ) { throw new InvalidParamException ( 'There is no file associated with this object.' ) ; } elseif ( $ file instance...
This method returns a stream resource that can be used with all file functions in PHP which deal with reading files . The contents of the file are pulled out of MongoDB on the fly so that the whole file does not have to be loaded into memory first .
59,808
public function getQueryBuilder ( ) { if ( ! is_object ( $ this -> _queryBuilder ) ) { $ this -> _queryBuilder = Yii :: createObject ( $ this -> _queryBuilder , [ $ this ] ) ; } return $ this -> _queryBuilder ; }
Returns the query builder for the this MongoDB connection .
59,809
public function getLogBuilder ( ) { if ( ! is_object ( $ this -> _logBuilder ) ) { $ this -> _logBuilder = Yii :: createObject ( $ this -> _logBuilder ) ; } return $ this -> _logBuilder ; }
Returns log builder for this connection .
59,810
public function getDatabase ( $ name = null , $ refresh = false ) { if ( $ name === null ) { $ name = $ this -> getDefaultDatabaseName ( ) ; } if ( $ refresh || ! array_key_exists ( $ name , $ this -> _databases ) ) { $ this -> _databases [ $ name ] = $ this -> selectDatabase ( $ name ) ; } return $ this -> _databases ...
Returns the MongoDB database with the given name .
59,811
public function getCollection ( $ name , $ refresh = false ) { if ( is_array ( $ name ) ) { list ( $ dbName , $ collectionName ) = $ name ; return $ this -> getDatabase ( $ dbName ) -> getCollection ( $ collectionName , $ refresh ) ; } return $ this -> getDatabase ( ) -> getCollection ( $ name , $ refresh ) ; }
Returns the MongoDB collection with the given name .
59,812
public function getFileCollection ( $ prefix = 'fs' , $ refresh = false ) { if ( is_array ( $ prefix ) ) { list ( $ dbName , $ collectionPrefix ) = $ prefix ; if ( ! isset ( $ collectionPrefix ) ) { $ collectionPrefix = 'fs' ; } return $ this -> getDatabase ( $ dbName ) -> getFileCollection ( $ collectionPrefix , $ ref...
Returns the MongoDB GridFS collection .
59,813
public function open ( ) { if ( $ this -> manager === null ) { if ( empty ( $ this -> dsn ) ) { throw new InvalidConfigException ( $ this -> className ( ) . '::dsn cannot be empty.' ) ; } $ token = 'Opening MongoDB connection: ' . $ this -> dsn ; try { Yii :: trace ( $ token , __METHOD__ ) ; Yii :: beginProfile ( $ tok...
Establishes a Mongo connection . It does nothing if a MongoDB connection has already been established .
59,814
public function run ( $ seq , $ tag ) { $ this -> controller -> loadData ( $ tag ) ; $ timings = $ this -> panel -> calculateTimings ( ) ; if ( ! isset ( $ timings [ $ seq ] ) ) { throw new HttpException ( 404 , 'Log message not found.' ) ; } $ query = $ timings [ $ seq ] [ 'info' ] ; if ( strpos ( $ query , 'find({' )...
Runs the explain action
59,815
protected function explainQuery ( $ queryString ) { $ connection = $ this -> panel -> getDb ( ) ; $ queryInfo = Json :: decode ( $ queryString ) ; if ( ! isset ( $ queryInfo [ 'ns' ] ) ) { return false ; } list ( $ databaseName , $ collectionName ) = explode ( '.' , $ queryInfo [ 'ns' ] , 2 ) ; unset ( $ queryInfo [ 'n...
Runs explain command over the query
59,816
private function prepareQueryFiler ( $ query ) { $ result = [ ] ; foreach ( $ query as $ key => $ value ) { if ( is_array ( $ value ) ) { $ result [ $ key ] = $ this -> prepareQueryFiler ( $ value ) ; } elseif ( is_string ( $ value ) && preg_match ( '#^(MongoDB\\\\BSON\\\\[A-Za-z]+)\\((.*)\\)$#s' , $ value , $ matches ...
Prepare query filer for explain . Converts BSON object log entries into actual objects .
59,817
public function getInstanceForWorkflow ( ) { $ instanceClass = $ this -> config ( ) -> get ( 'instance_class' ) ; $ instance = new $ instanceClass ( ) ; $ instance -> BaseActionID = $ this -> ID ; return $ instance ; }
Gets an object that is used for saving the actual state of things during a running workflow . It still uses the workflow action def for managing the functional execution however if you need to store additional data for the state you can specify your own WorkflowActionInstance instead of the default to capture these ele...
59,818
public function onAfterDelete ( ) { parent :: onAfterDelete ( ) ; $ wfActionInstances = WorkflowActionInstance :: get ( ) -> leftJoin ( 'WorkflowInstance' , '"WorkflowInstance"."ID" = "WorkflowActionInstance"."WorkflowID"' ) -> where ( sprintf ( '"BaseActionID" = %d AND ("WorkflowStatus" IN (\'Active\',\'Paused\'))' , ...
When deleting an action from a workflow definition make sure that workflows currently paused on that action are deleted Also removes all outbound transitions
59,819
public function export ( ) { if ( ! Permission :: check ( 'CMS_ACCESS_SecurityAdmin' ) ) { throw new Exception ( _t ( 'SilverStripe\\ErrorPage\\ErrorPage.CODE_403' , '403 - Forbidden' ) , 403 ) ; } $ def = $ this -> getDefinition ( ) ; $ templateData = new ArrayData ( array ( 'ExportMetaData' => $ this -> ExportMetaDat...
Runs the export
59,820
public function format ( $ templateData ) { $ viewer = SSViewer :: execute_template ( [ 'type' => 'Includes' , 'WorkflowDefinitionExport' ] , $ templateData ) ; $ processed = str_replace ( '&' , '&' , $ viewer ) ; return preg_replace ( "#^\R+|^[\t\s]*\R+#m" , '' , $ processed ) ; }
Format the exported data as YAML .
59,821
public function ExportMetaData ( ) { $ def = $ this -> getDefinition ( ) ; return new ArrayData ( array ( 'ExportHost' => preg_replace ( "#http(s)?://#" , '' , Director :: protocolAndHost ( ) ) , 'ExportDate' => date ( 'd/m/Y H-i-s' ) , 'ExportUser' => $ this -> member -> FirstName . ' ' . $ this -> member -> Surname ,...
Generate template vars for metadata
59,822
private function ssVersion ( ) { $ versionSapphire = str_replace ( ':' , '' , singleton ( SapphireInfo :: class ) -> Version ( ) ) ; $ versionLeftMain = str_replace ( ':' , '' , singleton ( LeftAndMain :: class ) -> CMSVersion ( ) ) ; if ( $ versionSapphire != _t ( 'SilverStripe\\Admin\\LeftAndMain.VersionUnknown' , 'U...
Try different ways of obtaining the current SilverStripe version for YAML output .
59,823
public function doFrontEndAction ( array $ data , Form $ form , HTTPRequest $ request ) { if ( ! $ obj = $ this -> getContextObject ( ) ) { throw new Exception ( _t ( 'FrontEndWorkflowController.FRONTENDACTION_CONTEXT_EXCEPTION' , 'Context Object Not Found' ) ) ; } if ( ! $ this -> getCurrentTransition ( ) -> canExecut...
Save the Form Data to the defined Context Object
59,824
public function Title ( ) { if ( ! $ this -> Title ) { if ( $ this -> getContextObject ( ) ) { if ( $ workflow = $ this -> contextObj -> getWorkflowInstance ( ) ) { $ this -> Title = $ workflow -> currentAction ( ) -> BaseAction ( ) -> PageTitle ? $ workflow -> currentAction ( ) -> BaseAction ( ) -> PageTitle : $ workf...
checks to see if there is a title set on the current workflow action uses that or falls back to controller - > Title
59,825
public function createRelations ( $ definition = null ) { $ actions = array ( ) ; $ transitions = new ArrayObject ( ) ; $ sort = 1 ; foreach ( $ this -> structure as $ relationName => $ relationTemplate ) { $ isAction = isset ( $ relationTemplate [ 'type' ] ) ; $ isUsers = ( $ relationName == 'users' ) ; $ isGroups = (...
Creates the relevant data objects for this structure returning an array of actions in the order they ve been created
59,826
protected function createAction ( $ name , $ actionTemplate , WorkflowDefinition $ definition = null ) { $ type = $ actionTemplate [ 'type' ] ; if ( ! $ type || ! class_exists ( $ type ) ) { throw new Exception ( _t ( 'WorkflowTemplate.INVALID_TEMPLATE_ACTION' , 'Invalid action class specified in template' ) ) ; } $ ac...
Create a workflow action based on a template
59,827
protected function createUsers ( $ users , WorkflowDefinition $ definition , $ clear = false ) { $ source = array ( 'users' => $ users ) ; $ this -> addManyManyToObject ( $ definition , $ source , $ clear ) ; }
Create a WorkflowDefinition - > Users relation based on template data . But only if the related groups from the export can be foud in the target environment s DB .
59,828
protected function createGroups ( $ groups , WorkflowDefinition $ definition , $ clear = false ) { $ source = array ( 'groups' => $ groups ) ; $ this -> addManyManyToObject ( $ definition , $ source , $ clear ) ; }
Create a WorkflowDefinition - > Groups relation based on template data But only if the related groups from the export can be foud in the target environment s DB .
59,829
protected function updateActionTransitions ( $ actionTemplate , $ action ) { $ transitions = array ( ) ; if ( isset ( $ actionTemplate [ 'transitions' ] ) && is_array ( $ actionTemplate [ 'transitions' ] ) ) { $ existing = $ action -> Transitions ( ) ; $ transitionMap = array ( ) ; foreach ( $ existing as $ transition ...
Update the transitions for a given action
59,830
public function updateDefinition ( WorkflowDefinition $ definition ) { $ existingActions = array ( ) ; $ existing = $ definition -> Actions ( ) -> column ( 'Title' ) ; $ structure = array_keys ( $ this -> structure ) ; $ removeNames = array_diff ( $ existing , $ structure ) ; foreach ( $ definition -> Actions ( ) as $ ...
Update a workflow definition
59,831
public function getAssignedMembers ( ) { $ members = $ this -> Users ( ) ; $ groups = $ this -> Groups ( ) ; $ _members = ArrayList :: create ( ) ; $ members -> each ( function ( $ item ) use ( $ _members ) { $ _members -> push ( $ item ) ; } ) ; $ _groups = ArrayList :: create ( ) ; $ groups -> each ( function ( $ ite...
Returns a set of all Members that are assigned to this WorkflowAction subclass either directly or via a group .
59,832
public function getNamedTemplate ( $ name ) { if ( $ importedTemplate = singleton ( WorkflowDefinitionImporter :: class ) -> getImportedWorkflows ( $ name ) ) { return $ importedTemplate ; } if ( ! is_array ( $ this -> templates ) ) { return ; } foreach ( $ this -> templates as $ template ) { if ( $ template -> getName...
Get a template by name
59,833
public function getDefinitionFor ( DataObject $ dataObject ) { if ( $ dataObject -> hasExtension ( WorkflowApplicable :: class ) || $ dataObject -> hasExtension ( FileWorkflowApplicable :: class ) ) { if ( $ dataObject -> WorkflowDefinitionID ) { return DataObject :: get_by_id ( WorkflowDefinition :: class , $ dataObje...
Gets the workflow definition for a given dataobject if there is one
59,834
public function getDefinitionByID ( $ object , $ workflowID ) { $ workflow = null ; if ( $ object -> hasExtension ( WorkflowApplicable :: class ) || $ object -> hasExtension ( FileWorkflowApplicable :: class ) ) { if ( ( $ object -> WorkflowDefinitionID == $ workflowID ) || ( $ workflow = $ object -> AdditionalWorkflow...
Retrieves a workflow definition by ID for a data object .
59,835
public function getDefinitionsFor ( $ object ) { $ default = $ this -> getDefinitionFor ( $ object ) ; if ( $ default ) { return array_merge ( array ( $ default ) , $ object -> AdditionalWorkflowDefinitions ( ) -> toArray ( ) ) ; } return null ; }
Retrieves and collates the workflow definitions for a data object where the first element will be the main workflow definition .
59,836
public function getWorkflowFor ( $ item , $ includeComplete = false ) { $ id = $ item ; if ( $ item instanceof WorkflowAction ) { $ id = $ item -> WorkflowID ; return DataObject :: get_by_id ( WorkflowInstance :: class , $ id ) ; } elseif ( is_object ( $ item ) && ( $ item -> hasExtension ( WorkflowApplicable :: class ...
Gets the workflow for the given item
59,837
public function getWorkflowHistoryFor ( $ item , $ limit = null ) { if ( $ active = $ this -> getWorkflowFor ( $ item , true ) ) { $ limit = $ limit ? "0,$limit" : '' ; return $ active -> Actions ( '' , 'ID DESC ' , null , $ limit ) ; } }
Get all the workflow action instances for an item
59,838
public function startWorkflow ( DataObject $ object , $ workflowID = null ) { $ existing = $ this -> getWorkflowFor ( $ object ) ; if ( $ existing ) { throw new ExistingWorkflowException ( _t ( 'WorkflowService.EXISTING_WORKFLOW_ERROR' , "That object already has a workflow running" ) ) ; } $ definition = null ; if ( $ ...
Starts the workflow for the given data object assuming it or a parent has a definition specified .
59,839
public function usersWorkflows ( Member $ user ) { $ groupIds = $ user -> Groups ( ) -> column ( 'ID' ) ; $ groupInstances = null ; $ filter = array ( '' ) ; if ( is_array ( $ groupIds ) ) { $ groupInstances = DataList :: create ( WorkflowInstance :: class ) -> filter ( array ( 'Group.ID:ExactMatchMulti' => $ groupIds ...
Get all the workflows that this user is responsible for
59,840
public function userPendingItems ( Member $ user ) { $ userInstances = DataList :: create ( WorkflowInstance :: class ) -> where ( '"WorkflowStatus" != \'Complete\'' ) -> sort ( 'LastEdited DESC' ) ; if ( Permission :: checkMember ( $ user , 'ADMIN' ) ) { return $ userInstances ; } $ instances = new ArrayList ( ) ; for...
Get items that the passed - in user has awaiting for them to action
59,841
public function userSubmittedItems ( Member $ user ) { $ userInstances = DataList :: create ( WorkflowInstance :: class ) -> where ( '"WorkflowStatus" != \'Complete\'' ) -> sort ( 'LastEdited DESC' ) ; if ( ! Permission :: checkMember ( $ user , 'ADMIN' ) ) { $ userInstances = $ userInstances -> filter ( 'InitiatorID:E...
Get items that the passed - in user has submitted for workflow review
59,842
public function defineFromTemplate ( WorkflowDefinition $ definition , $ templateName ) { $ template = null ; if ( ! is_array ( $ this -> templates ) ) { return ; } $ template = $ this -> getNamedTemplate ( $ templateName ) ; if ( ! $ template ) { return ; } $ template -> createRelations ( $ definition ) ; if ( ! $ def...
Generate a workflow definition based on a template
59,843
public function reorder ( $ objects , $ newOrder ) { $ sortVals = array_values ( $ objects -> map ( 'ID' , 'Sort' ) -> toArray ( ) ) ; sort ( $ sortVals ) ; foreach ( $ newOrder as $ key => $ id ) { if ( ! $ id ) { continue ; } $ object = $ objects -> find ( 'ID' , $ id ) ; $ object -> Sort = $ sortVals [ $ key ] ; $ o...
Reorders actions within a definition
59,844
public function getCMSFields ( ) { $ fields = new FieldList ( ) ; $ fields -> push ( new TabSet ( 'Root' , new Tab ( 'Main' ) ) ) ; if ( Permission :: check ( 'REASSIGN_ACTIVE_WORKFLOWS' ) ) { if ( $ this -> WorkflowStatus == 'Paused' || $ this -> WorkflowStatus == 'Active' ) { $ cmsUsers = Member :: mapInCMSGroups ( )...
Get the CMS view of the instance . This is used to display the log of this workflow and options to reassign if the workflow hasn t been finished yet
59,845
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; $ vars = $ this -> record ; if ( isset ( $ vars [ 'DirectUpdate' ] ) ) { unset ( $ this -> record [ 'DirectUpdate' ] ) ; $ this -> updateWorkflow ( $ vars ) ; } }
See if we ve been saved in context of managing the workflow directly
59,846
public function updateWorkflow ( $ data ) { $ action = $ this -> CurrentAction ( ) ; if ( ! $ this -> getTarget ( ) || ! $ this -> getTarget ( ) -> canEditWorkflow ( ) ) { return ; } $ allowedFields = $ this -> getWorkflowFields ( ) -> saveableFields ( ) ; unset ( $ allowedFields [ 'TransitionID' ] ) ; foreach ( $ allo...
Update the current state of the workflow
59,847
public function getTarget ( $ getLive = false ) { if ( $ this -> TargetID && $ this -> TargetClass ) { $ versionable = Injector :: inst ( ) -> get ( $ this -> TargetClass ) -> has_extension ( Versioned :: class ) ; $ targetObject = null ; if ( ! $ versionable && $ getLive ) { return ; } if ( $ versionable ) { $ targetO...
Get the target - object that this WorkflowInstance points to .
59,848
public function getTargetDiff ( ) { $ liveTarget = $ this -> Target ( true ) ; $ draftTarget = $ this -> Target ( ) ; $ diff = DataDifferencer :: create ( $ liveTarget , $ draftTarget ) ; $ diff -> ignoreFields ( $ this -> config ( ) -> get ( 'diff_ignore_fields' ) ) ; $ fields = ArrayList :: create ( ) ; try { $ field...
Returns the field differences between the older version and current version of Target
59,849
public function beginWorkflow ( WorkflowDefinition $ definition , DataObject $ for = null ) { if ( ! $ this -> ID ) { $ this -> write ( ) ; } if ( $ for && ( $ for -> hasExtension ( WorkflowApplicable :: class ) || $ for -> hasExtension ( FileWorkflowApplicable :: class ) ) ) { $ this -> TargetClass = DataObject :: get...
Start a workflow based on a particular definition for a particular object .
59,850
public function execute ( ) { if ( ! $ this -> CurrentActionID ) { throw new Exception ( sprintf ( _t ( 'WorkflowInstance.EXECUTE_EXCEPTION' , 'Attempted to start an invalid workflow instance #%s!' ) , $ this -> ID ) ) ; } $ action = $ this -> CurrentAction ( ) ; $ transition = false ; if ( $ action -> Finished ) { $ t...
Execute this workflow . In rare cases this will actually execute all actions but typically it will stop and wait for the user to input something
59,851
protected function checkTransitions ( WorkflowActionInstance $ action ) { $ transitions = $ action -> getValidTransitions ( ) ; if ( $ transitions && $ transitions -> count ( ) == 1 ) { return $ transitions -> First ( ) ; } }
Evaluate all the transitions of an action and determine whether we should follow any of them yet .
59,852
public function performTransition ( WorkflowTransition $ transition ) { $ action = $ this -> CurrentAction ( ) ; $ allTransitions = $ action -> BaseAction ( ) -> Transitions ( ) ; $ valid = $ allTransitions -> find ( 'ID' , $ transition -> ID ) ; if ( ! $ valid ) { throw new Exception ( sprintf ( _t ( 'WorkflowInstance...
Transitions a workflow to the next step defined by the given transition .
59,853
public function getAssignedMembers ( ) { $ list = new ArrayList ( ) ; $ groups = $ this -> Groups ( ) ; $ list -> merge ( $ this -> Users ( ) ) ; foreach ( $ groups as $ group ) { $ list -> merge ( $ group -> Members ( ) ) ; } $ list -> removeDuplicates ( ) ; return $ list ; }
Returns a list of all Members that are assigned to this instance either directly or via a group .
59,854
protected function userHasAccess ( $ member ) { if ( ! $ member ) { if ( ! Security :: getCurrentUser ( ) ) { return false ; } $ member = Security :: getCurrentUser ( ) ; } if ( Permission :: checkMember ( $ member , "ADMIN" ) ) { return true ; } $ inWorkflowGroupOrUserTables = ( $ member -> inGroups ( $ this -> Groups...
Checks whether the given user is in the list of users assigned to this workflow
59,855
public function canViewTarget ( ) { $ action = $ this -> CurrentAction ( ) ; if ( $ action ) { return $ action -> canViewTarget ( $ this -> getTarget ( ) ) ; } return true ; }
Does this action restrict viewing of the document?
59,856
public function validTransitions ( ) { $ action = $ this -> CurrentAction ( ) ; $ transitions = $ action -> getValidTransitions ( ) ; return $ transitions -> filterByCallback ( function ( $ transition ) { return $ transition -> canExecute ( $ this ) ; } ) ; }
Get the current set of transitions that are valid for the current workflow state and are available to the current user .
59,857
public function getWorkflowFields ( ) { $ action = $ this -> CurrentAction ( ) ; $ options = $ this -> validTransitions ( ) ; $ wfOptions = $ options -> map ( 'ID' , 'Title' , ' ' ) ; $ fields = new FieldList ( ) ; $ fields -> push ( new HeaderField ( 'WorkflowHeader' , $ action -> Title ) ) ; $ fields -> push ( Hidden...
Gets fields for managing this workflow instance in its current step
59,858
public function getFrontEndWorkflowFields ( ) { $ action = $ this -> CurrentAction ( ) ; $ fields = new FieldList ( ) ; $ action -> updateFrontEndWorkflowFields ( $ fields ) ; return $ fields ; }
Gets Front - End form fields from current Action
59,859
public function getFrontEndWorkflowActions ( ) { $ action = $ this -> CurrentAction ( ) ; $ options = $ action -> getValidTransitions ( ) ; $ actions = new FieldList ( ) ; $ hide_disabled_actions_on_frontend = $ this -> config ( ) -> hide_disabled_actions_on_frontend ; foreach ( $ options as $ option ) { $ btn = new Fo...
Gets Transitions for display as Front - End Form Actions
59,860
public function getCurrentAction ( ) { $ join = '"WorkflowAction"."ID" = "WorkflowActionInstance"."BaseActionID"' ; $ action = WorkflowAction :: get ( ) -> leftJoin ( 'WorkflowActionInstance' , $ join ) -> where ( '"WorkflowActionInstance"."ID" = ' . $ this -> CurrentActionID ) -> first ( ) ; if ( ! $ action ) { return...
Simple method to retrieve the current action on the current WorkflowInstance
59,861
public function onBeforeWrite ( ) { if ( ! $ this -> Sort ) { $ this -> Sort = DB :: query ( 'SELECT MAX("Sort") + 1 FROM "WorkflowTransition"' ) -> value ( ) ; } parent :: onBeforeWrite ( ) ; }
Before saving make sure we re not in an infinite loop
59,862
public function canExecute ( WorkflowInstance $ workflow ) { $ return = true ; $ members = $ this -> getAssignedMembers ( ) ; if ( ! Permission :: check ( 'ADMIN' ) && $ members -> exists ( ) ) { if ( ! $ members -> find ( 'ID' , Security :: getCurrentUser ( ) -> ID ) ) { $ return = false ; } } if ( $ return ) { $ exte...
Check if the current user can execute this transition
59,863
public function canCreate ( $ member = null , $ context = array ( ) ) { return $ this -> Action ( ) -> WorkflowDef ( ) -> canCreate ( $ member , $ context ) ; }
Allows users who have permission to create a WorkflowDefinition to create actions on it too .
59,864
public function getAssignedMembers ( ) { $ members = ArrayList :: create ( $ this -> Users ( ) -> toArray ( ) ) ; $ groups = $ this -> Groups ( ) ; foreach ( $ groups as $ group ) { $ members -> merge ( $ group -> Members ( ) ) ; } $ members -> removeDuplicates ( ) ; return $ members ; }
Returns a set of all Members that are assigned to this transition either directly or via a group .
59,865
public function updateEditForm ( Form $ form ) { Requirements :: javascript ( 'symbiote/silverstripe-advancedworkflow:client/dist/js/advancedworkflow.js' ) ; $ service = singleton ( WorkflowService :: class ) ; $ record = $ form -> getRecord ( ) ; $ active = $ service -> getWorkflowFor ( $ record ) ; if ( $ active ) { ...
Need to update the edit form AFTER it s been transformed to read only so that the workflow stuff is still allowed to be added with write permissions
59,866
public function updateworkflow ( $ data , Form $ form , $ request ) { $ service = singleton ( WorkflowService :: class ) ; $ record = $ form -> getRecord ( ) ; $ workflow = $ service -> getWorkflowFor ( $ record ) ; if ( ! $ workflow ) { return null ; } $ action = $ workflow -> CurrentAction ( ) ; if ( ! $ record || ! ...
Update a workflow based on user input .
59,867
public function clearPublishJob ( ) { $ job = $ this -> owner -> PublishJob ( ) ; if ( $ job && $ job -> exists ( ) ) { $ job -> delete ( ) ; } $ this -> owner -> PublishJobID = 0 ; }
Clears any existing publish job against this dataobject
59,868
public function clearUnPublishJob ( ) { $ job = $ this -> owner -> UnPublishJob ( ) ; if ( $ job && $ job -> exists ( ) ) { $ job -> delete ( ) ; } $ this -> owner -> UnPublishJobID = 0 ; }
Clears any existing unpublish job
59,869
protected function ensurePublishJob ( $ when ) { if ( $ this -> owner -> PublishJobID ) { $ job = $ this -> owner -> PublishJob ( ) ; if ( $ job && $ job -> exists ( ) && DBDatetime :: create ( ) -> setValue ( $ job -> StartAfter ) -> getTimestamp ( ) == $ when ) { return ; } $ this -> clearPublishJob ( ) ; } $ job = n...
Ensure the existence of a publish job at the specified time
59,870
protected function ensureUnPublishJob ( $ when ) { if ( $ this -> owner -> UnPublishJobID ) { $ job = $ this -> owner -> UnPublishJob ( ) ; if ( $ job && $ job -> exists ( ) && DBDatetime :: create ( ) -> setValue ( $ job -> StartAfter ) -> getTimestamp ( ) == $ when ) { return ; } $ this -> clearUnPublishJob ( ) ; } $...
Ensure the existence of an unpublish job at the specified time
59,871
public function updateStatusFlags ( & $ flags ) { $ embargo = $ this -> getIsPublishScheduled ( ) ; $ expiry = $ this -> getIsUnPublishScheduled ( ) ; if ( $ embargo || $ expiry ) { unset ( $ flags [ 'addedtodraft' ] , $ flags [ 'modified' ] ) ; } if ( $ embargo && $ expiry ) { $ flags [ 'embargo_expiry' ] = array ( 't...
Add badges to the site tree view to show that a page has been scheduled for publishing or unpublishing
59,872
public function extendedRequiredFieldsEmbargoExpiry ( $ data ) { $ response = array ( 'fieldName' => 'DesiredUnPublishDate[date]' , 'fieldField' => null , 'fieldMsg' => null , 'fieldValid' => true ) ; if ( isset ( $ data [ 'DesiredPublishDate' ] , $ data [ 'DesiredUnPublishDate' ] ) ) { $ publish = DBDatetime :: create...
This is called in the AWRequiredFields class this validates whether an Embargo and Expiry are not equal and that Embargo is before Expiry returning the appropriate message when it fails .
59,873
public function getIsPublishScheduled ( ) { if ( ! $ this -> owner -> PublishOnDate ) { return false ; } $ now = DBDatetime :: now ( ) -> getTimestamp ( ) ; $ publish = $ this -> owner -> dbObject ( 'PublishOnDate' ) -> getTimestamp ( ) ; return $ now < $ publish ; }
Returns whether a publishing date has been set and is after the current date
59,874
public function getIsUnPublishScheduled ( ) { if ( ! $ this -> owner -> UnPublishOnDate ) { return false ; } $ now = DBDatetime :: now ( ) -> getTimestamp ( ) ; $ unpublish = $ this -> owner -> dbObject ( 'UnPublishOnDate' ) -> getTimestamp ( ) ; return $ now < $ unpublish ; }
Returns whether an unpublishing date has been set and is after the current date
59,875
public function canEdit ( $ member ) { if ( ! Permission :: check ( 'EDIT_EMBARGOED_WORKFLOW' ) && ! $ this -> owner -> AllowEmbargoedEditing ) { $ publishTime = $ this -> owner -> dbObject ( 'PublishOnDate' ) ; if ( $ publishTime && $ publishTime -> InFuture ( ) || ( ! $ publishTime && $ this -> owner -> PublishJobID ...
Add edit check for when publishing has been scheduled and if any workflow definitions want the item to be disabled .
59,876
public function export ( HTTPRequest $ request ) { $ url = explode ( '/' , $ request -> getURL ( ) ) ; $ definitionID = end ( $ url ) ; if ( $ definitionID && is_numeric ( $ definitionID ) ) { $ exporter = new WorkflowDefinitionExporter ( $ definitionID ) ; $ exportFilename = WorkflowDefinitionExporter :: config ( ) ->...
Spits out an exported version of the selected WorkflowDefinition for download .
59,877
public function ImportForm ( ) { $ form = parent :: ImportForm ( ) ; if ( ! $ form ) { return ; } $ form -> unsetAllActions ( ) ; $ newActionList = new FieldList ( array ( new FormAction ( 'import' , _t ( 'AdvancedWorkflowAdmin.IMPORT' , 'Import workflow' ) ) ) ) ; $ form -> Fields ( ) -> fieldByName ( '_CsvFile' ) -> ...
Required so we can simply change the visible label of the Import button and lose some redundant form - fields .
59,878
public function updateWorkflowFields ( $ fields ) { $ fieldDiff = $ this -> Workflow ( ) -> getTargetDiff ( ) ; foreach ( $ fieldDiff as $ field ) { $ display = ReadonlyField :: create ( 'workflow-' . $ field -> Name , $ field -> Title , DBField :: create_field ( 'HTMLText' , $ field -> Diff ) ) -> addExtraClass ( 'wor...
Gets fields for when this is part of an active workflow
59,879
public function getFrontEndDataObject ( ) { $ obj = null ; $ ba = $ this -> BaseAction ( ) ; if ( $ ba -> hasMethod ( 'getFrontEndDataObject' ) ) { $ obj = $ ba -> getFrontEndDataObject ( ) ; } else { $ obj = $ this -> Workflow ( ) -> getTarget ( ) ; } return $ obj ; }
Gets Front - End DataObject
59,880
public function getValidTransitions ( ) { $ available = $ this -> BaseAction ( ) -> Transitions ( ) ; $ valid = new ArrayList ( ) ; if ( $ available ) { foreach ( $ available as $ transition ) { if ( $ transition -> isValid ( $ this -> Workflow ( ) ) ) { $ valid -> push ( $ transition ) ; } } } $ this -> extend ( 'upda...
Returns all the valid transitions that lead out from this action .
59,881
public function actionComplete ( WorkflowTransition $ transition ) { $ this -> MemberID = Member :: currentUserID ( ) ; $ this -> write ( ) ; $ this -> extend ( 'onActionComplete' , $ transition ) ; }
Called when this action has been completed within the workflow
59,882
public function getMemberFields ( Member $ member = null ) { if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } $ result = array ( ) ; if ( $ member ) { foreach ( $ member -> summaryFields ( ) as $ field => $ title ) { $ result [ $ field ] = $ member -> $ field ; } } if ( $ member && ! array_key_exists (...
Builds an array with the member information
59,883
public function getFormattingHelp ( ) { $ note = _t ( 'NotifyUsersWorkflowAction.FORMATTINGNOTE' , 'Notification emails can contain HTML formatting. The following special variables are replaced with their respective values in the email subject, email from and template/body.' ) ; $ member = _t ( 'NotifyUsersWorkflowAc...
Returns a basic set of instructions on how email templates are populated with variables .
59,884
public function AbsoluteEditLink ( ) { $ CMSEditLink = null ; if ( $ this -> owner instanceof CMSPreviewable ) { $ CMSEditLink = $ this -> owner -> CMSEditLink ( ) ; } elseif ( $ this -> owner -> hasMethod ( 'WorkflowLink' ) ) { $ CMSEditLink = $ this -> owner -> WorkflowLink ( ) ; } if ( $ CMSEditLink === null ) { ret...
Included in CMS - generated email templates for a NotifyUsersWorkflowAction . Returns an absolute link to the CMS UI for a Page object
59,885
public function LinkToPendingItems ( ) { $ urlBase = Director :: absoluteBaseURL ( ) ; $ urlFrag = 'admin/workflows/WorkflowDefinition/EditForm/field' ; $ urlInst = $ this -> getWorkflowInstance ( ) ; return Controller :: join_links ( $ urlBase , $ urlFrag , 'PendingObjects' , 'item' , $ urlInst -> ID , 'edit' ) ; }
Included in CMS - generated email templates for a NotifyUsersWorkflowAction . Allows users to select a link in an email for direct access to the transition - selection dropdown in the CMS UI .
59,886
public function onAfterWrite ( ) { $ instance = $ this -> getWorkflowInstance ( ) ; if ( $ instance && $ instance -> CurrentActionID ) { $ action = $ instance -> CurrentAction ( ) -> BaseAction ( ) -> targetUpdated ( $ instance ) ; } }
After a workflow item is written we notify the workflow so that it can take action if needbe
59,887
public function getWorkflowInstance ( ) { if ( ! $ this -> currentInstance ) { $ this -> currentInstance = $ this -> getWorkflowService ( ) -> getWorkflowFor ( $ this -> owner ) ; } return $ this -> currentInstance ; }
Gets the current instance of workflow
59,888
public function RecentWorkflowComment ( $ limit = 10 ) { if ( $ actions = $ this -> getWorkflowHistory ( $ limit ) ) { foreach ( $ actions as $ action ) { if ( $ action -> Comment != '' ) { return $ action ; } } } }
Check all recent WorkflowActionIntances and return the most recent one with a Comment
59,889
public function canPublish ( ) { if ( $ this -> isPublishJobRunning ( ) ) { return true ; } if ( $ active = $ this -> getWorkflowInstance ( ) ) { $ publish = $ active -> canPublishTarget ( $ this -> owner ) ; if ( ! is_null ( $ publish ) ) { return $ publish ; } } $ definition = $ this -> getWorkflowService ( ) -> getD...
Content can never be directly publishable if there s a workflow applied .
59,890
public function canEdit ( $ member ) { if ( $ this -> isPublishJobRunning ( ) ) { return true ; } if ( $ active = $ this -> getWorkflowInstance ( ) ) { return $ active -> canEditTarget ( ) ; } }
Can only edit content that s NOT in another person s content changeset
59,891
public function getImportedWorkflows ( $ name = null ) { $ imports = DataObject :: get ( ImportedWorkflowTemplate :: class ) ; $ importedDefs = array ( ) ; foreach ( $ imports as $ import ) { if ( ! $ import -> Content ) { continue ; } $ structure = unserialize ( $ import -> Content ) ; $ struct = $ structure [ Injecto...
Generates an array of WorkflowTemplate Objects of all uploaded workflows .
59,892
public function parseYAMLImport ( $ source ) { if ( is_file ( $ source ) ) { $ source = file_get_contents ( $ source ) ; } $ convertLF = str_replace ( array ( "\r\n" , "\r" ) , "\n" , $ source ) ; $ converted = preg_replace ( "#('[^:\n][^']+)(:)([^']+')#" , "$1;$3" , $ convertLF ) ; $ parts = preg_split ( '#^---$#m' , ...
Handles finding and parsing YAML input as a string or from the contents of a file .
59,893
protected function createImport ( $ name , $ filename , $ record ) { $ import = ImportedWorkflowTemplate :: create ( ) ; $ import -> Name = $ name ; $ import -> Filename = $ filename ; $ import -> Content = serialize ( $ record ) ; $ import -> write ( ) ; return $ import ; }
Create the ImportedWorkflowTemplate record for the uploaded YML file .
59,894
public function onBeforeWrite ( ) { if ( ! $ this -> Sort ) { $ this -> Sort = DB :: query ( 'SELECT MAX("Sort") + 1 FROM "WorkflowDefinition"' ) -> value ( ) ; } if ( ! $ this -> ID && ! $ this -> Title ) { $ this -> Title = $ this -> getDefaultWorkflowTitle ( ) ; } parent :: onBeforeWrite ( ) ; }
Ensure a sort value is set and we get a useable initial workflow title .
59,895
public function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; $ posted = Controller :: curr ( ) -> getRequest ( ) -> postVars ( ) ; if ( isset ( $ posted [ '_CsvFile' ] ) && $ this -> TemplateVersion ) { $ this -> TemplateVersion = null ; } if ( $ this -> numChildren ( ) == 0 && $ this -> Template && ! $ this -> Temp...
After we ve been written check whether we ve got a template and to then create the relevant actions etc .
59,896
public function incomingTitle ( ) { $ req = Controller :: curr ( ) -> getRequest ( ) ; if ( isset ( $ req [ '_CsvFile' ] [ 'name' ] ) && ! empty ( $ req [ '_CsvFile' ] [ 'name' ] ) ) { $ import = ImportedWorkflowTemplate :: get ( ) -> filter ( 'Filename' , $ req [ '_CsvFile' ] [ 'name' ] ) -> first ( ) ; $ incomingTitl...
Return the workflow definition title according to the source
59,897
public function canWorkflowPublish ( $ member , $ target ) { $ publish = $ this -> extendedCan ( 'canWorkflowPublish' , $ member , $ target ) ; if ( is_null ( $ publish ) ) { $ publish = Permission :: checkMember ( $ member , 'ADMIN' ) ; } return $ publish ; }
Determines if target can be published directly when no workflow has started yet Opens extension hook to allow an extension to determine if this is allowed as well
59,898
protected function userHasAccess ( $ member ) { if ( ! $ member ) { if ( ! Security :: getCurrentUser ( ) ) { return false ; } $ member = Security :: getCurrentUser ( ) ; } if ( Permission :: checkMember ( $ member , "VIEW_ACTIVE_WORKFLOWS" ) ) { return true ; } }
Checks whether the passed user is able to view this ModelAdmin
59,899
protected function createForConnection ( $ name , array $ config = [ ] ) { if ( isset ( $ this -> customCreators [ $ name ] ) ) { return $ this -> callCustom ( $ name , compact ( 'config' ) ) ; } }
Create a new driver instance for the given connection .