| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Symbiote\AdvancedWorkflow\Actions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use SilverStripe\Control\Email\Email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SilverStripe\Forms\HeaderField; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SilverStripe\Forms\LiteralField; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SilverStripe\Forms\TextareaField; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SilverStripe\Forms\TextField; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SilverStripe\Forms\ToggleCompositeField; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use SilverStripe\ORM\CMSPreviewable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use SilverStripe\ORM\DataObject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use SilverStripe\ORM\FieldType\DBDatetime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use SilverStripe\Security\Member; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use SilverStripe\Security\Security; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use SilverStripe\View\ArrayData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use SilverStripe\View\SSViewer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Swift_RfcComplianceException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * A workflow action that notifies users attached to the workflow path that they have a task awaiting them. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @license    BSD License (http://silverstripe.org/bsd-license/) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @package    advancedworkflow | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @subpackage actions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | class NotifyUsersWorkflowAction extends WorkflowAction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @var bool Should templates be constrained to just known-safe variables. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     private static $whitelist_template_variables = false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     private static $db = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         'EmailSubject'  => 'Varchar(100)', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         'EmailFrom'     => 'Varchar(50)', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         'EmailTemplate' => 'Text' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     private static $icon = 'symbiote/silverstripe-advancedworkflow:images/notify.png'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     private static $table_name = 'NotifyUsersWorkflowAction'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function getCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $fields = parent::getCMSFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $fields->addFieldsToTab('Root.Main', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             new HeaderField('NotificationEmail', $this->fieldLabel('NotificationEmail')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             new LiteralField('NotificationNote', '<p>' . $this->fieldLabel('NotificationNote') . '</p>'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             new TextField('EmailSubject', $this->fieldLabel('EmailSubject')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             new TextField('EmailFrom', $this->fieldLabel('EmailFrom')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             new TextareaField('EmailTemplate', $this->fieldLabel('EmailTemplate')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             new ToggleCompositeField( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                 'FormattingHelpContainer', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 $this->fieldLabel('FormattingHelp'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 new LiteralField('FormattingHelp', $this->getFormattingHelp()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->extend('updateNotifyUsersCMSFields', $fields); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     public function fieldLabels($relations = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         return array_merge(parent::fieldLabels($relations), array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             'NotificationEmail' => _t('NotifyUsersWorkflowAction.NOTIFICATIONEMAIL', 'Notification Email'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             'NotificationNote'  => _t( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 'NotifyUsersWorkflowAction.NOTIFICATIONNOTE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 'All users attached to the workflow will be sent an email when this action is run.' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             'EmailSubject'      => _t('NotifyUsersWorkflowAction.EMAILSUBJECT', 'Email subject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             'EmailFrom'         => _t('NotifyUsersWorkflowAction.EMAILFROM', 'Email from'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             'EmailTemplate'     => _t('NotifyUsersWorkflowAction.EMAILTEMPLATE', 'Email template'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             'FormattingHelp'    => _t('NotifyUsersWorkflowAction.FORMATTINGHELP', 'Formatting Help') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     public function execute(WorkflowInstance $workflow) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $members = $workflow->getAssignedMembers(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         if (!$members || !count($members)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $member = Security::getCurrentUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $initiator = $workflow->Initiator(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $contextFields   = $this->getContextFields($workflow->getTarget()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $memberFields    = $this->getMemberFields($member); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $initiatorFields = $this->getMemberFields($initiator); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $variables = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         foreach ($contextFields as $field => $val) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             $variables["\$Context.$field"] = $val; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         foreach ($memberFields as $field => $val) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             $variables["\$Member.$field"] = $val; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         foreach ($initiatorFields as $field => $val) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             $variables["\$Initiator.$field"] = $val; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $pastActions = $workflow->Actions()->sort('Created DESC'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $variables["\$CommentHistory"] = $this->customise([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             'PastActions' => $pastActions, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             'Now' => DBDatetime::now() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         ])->renderWith('Includes/CommentHistory'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $from = str_replace(array_keys($variables), array_values($variables), $this->EmailFrom); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $subject = str_replace(array_keys($variables), array_values($variables), $this->EmailSubject); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         if ($this->config()->get('whitelist_template_variables')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             $item = ArrayData::create([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                 'Initiator' => ArrayData::create($initiatorFields), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 'Member' => ArrayData::create($memberFields), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 'Context' => ArrayData::create($contextFields), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                 'CommentHistory' => $variables["\$CommentHistory"] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             $item = $workflow->customise([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |                 'Items' => $workflow->Actions(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 'Member' => $member, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 'Context' => ArrayData::create($contextFields), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                 'CommentHistory' => $variables["\$CommentHistory"] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $view = SSViewer::fromString($this->EmailTemplate); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         $this->extend('updateView', $view); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         foreach ($members as $member) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |             if ($member->Email) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                 // We bind in the assignee at this point, as it changes each loop iteration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                 $assigneeVars = $this->getMemberFields($member); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                 if (count($assigneeVars)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                     $item->Assignee = ArrayData::create($assigneeVars); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                 $body = $view->process($item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                 $email = Email::create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                 try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                     $email->setTo($member->Email); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 } catch (Swift_RfcComplianceException $exception) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                     // If the email address isn't valid we should skip it rather than break | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                     // the rest of the processing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                     continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                 $email->setSubject($subject); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                 $email->setFrom($from); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 $email->setBody($body); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                 $email->send(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @param  DataObject $target | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 172 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  |     public function getContextFields(DataObject $target) | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  |         $result = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  |         if (!$target) { | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  |             return $result; | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  |         $fields = $target->getSchema()->fieldSpecs($target); | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |         unset($fields['ID']); | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |         foreach ($fields as $field => $fieldDesc) { | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |             $result[$field] = $target->$field; | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |         if ($target instanceof CMSPreviewable) { | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |             $result['CMSLink'] = $target->CMSEditLink(); | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  |         } elseif ($target->hasMethod('WorkflowLink')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  |             $result['CMSLink'] = $target->WorkflowLink(); | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 192 |  |  |         $result['AbsoluteEditLink'] = isset($result['CMSLink']) ? $result['CMSLink'] : ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 194 |  |  |         if ($target->hasMethod('AbsoluteLink')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  |             $result['AbsoluteLink'] = $target->AbsoluteLink(); | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  |         return $result; | 
            
                                                                        
                            
            
                                    
            
            
                | 199 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      * Builds an array with the member information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |      * @param Member $member An optional member to use. If null, will use the current logged in member | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     public function getMemberFields(Member $member = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         if (!$member) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             $member = Security::getCurrentUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         $result = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         if ($member) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             foreach ($member->summaryFields() as $field => $title) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 $result[$field] = $member->$field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         if ($member && !array_key_exists('Name', $result)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |             $result['Name'] = $member->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      * Returns a basic set of instructions on how email templates are populated with variables. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     public function getFormattingHelp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $note = _t( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             'NotifyUsersWorkflowAction.FORMATTINGNOTE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             'Notification emails can contain HTML formatting. The following special variables are replaced with their | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 			respective values in the email subject, email from and template/body.' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         $member = _t( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             'NotifyUsersWorkflowAction.MEMBERNOTE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             'These fields will be populated from the member that initiates the notification action. For example, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 			{$Member.FirstName}.' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $initiator = _t( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             'NotifyUsersWorkflowAction.INITIATORNOTE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             'These fields will be populated from the member that initiates the workflow request. For example, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 			{$Initiator.Email}.' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         $context = _t( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |             'NotifyUsersWorkflowAction.CONTEXTNOTE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |             'Any summary fields from the workflow target will be available. For example, {$Context.Title}. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 			Additionally, the {$Context.AbsoluteEditLink} variable will contain a link to edit the workflow target in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 			the CMS (if it is a Page), and the {$Context.LinkToPendingItems} variable will generate a link to the CMS\'' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             . 'workflow admin, useful for allowing users to enact workflow transitions, directly from emails.' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $fieldName = _t('NotifyUsersWorkflowAction.FIELDNAME', 'Field name'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         $commentHistory = _t('NotifyUsersWorkflowAction.COMMENTHISTORY', 'Comment history up to this notification.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         $memberFields = implode(', ', array_keys($this->getMemberFields())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         return "<p>$note</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 			<p><strong>{\$Member.($memberFields)}</strong><br>$member</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 			<p><strong>{\$Initiator.($memberFields)}</strong><br>$initiator</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 			<p><strong>{\$Context.($fieldName)}</strong><br>$context</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 			<p><strong>{\$CommentHistory}</strong><br>$commentHistory</p>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 267 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 268 |  |  |  | 
            
                        
This check marks private properties in classes that are never used. Those properties can be removed.