sutherlandesign

Hi all, does this code look right to you? having trouble with the part 'elseif', need some advice on that. See code below:

Files: Requires logging in with Slack to view/download
Untitled
wmk

Sounds like a good candidate for object calesthenics and a refactoring

sutherlandesign
  1. if ($this->owner->NeedsApproval) {
  2. $note = _t(
  3. 'MemberProfiles.NOLOGINUNTILAPPROVED',
  4. 'This member has not yet been approved. They cannot log in until their account is approved. Also check in \'RAP\' tab if member has applied for NZSL Tutor Registration.'
  5. );
  6.  
  7. if (!$this->owner->RequireApproval) {
  8. $fields->addFieldsToTab('Root.NZSLTA', array(
  9. // ApprovalAnchor is used by MemberApprovalController (2017-02-01)
  10. new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),
  11. new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'Registration Approval')),
  12. new LiteralField('ApprovalNote', "<p>$note</p>"),
  13. new DropdownField('NeedsApproval', '', array(
  14. true => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),
  15. false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')
  16. ))
  17. ));
  18. } elseif (!$this->owner->RequireRenewApproval) {
  19. $fields->addFieldsToTab('Root.NZSLTA', array(
  20. // ApprovalAnchor is used by MemberApprovalController (2017-02-01)
  21. new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),
  22. new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'Renew Approval')),
  23. new LiteralField('ApprovalNote', "<p>$note</p>"),
  24. new DropdownField('NeedsApproval', '', array(
  25. true => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),
  26. false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')
  27. ))
  28. ));
  29. } elseif (!$this->owner->RequireTraineeApproval) {
  30. $fields->addFieldsToTab('Root.NZSLTA', array(
  31. // ApprovalAnchor is used by MemberApprovalController (2017-02-01)
  32. new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),
  33. new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'Trainee Approval')),
  34. new LiteralField('ApprovalNote', "<p>This member has not yet been approved. They cannot access to Level One Unit 4-5 resources until their application has been approved.</p><p><strong>PLEASE NOTE</strong> - once approved, three steps need to do: change the 'RAP Category' status to 'Trainee', add today's date into 'Year Trainee' field and update two access groups for to access the full resources.</p>"),
  35. new DropdownField('NeedsApproval', '', array(
  36. true => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),
  37. false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')
  38. ))
  39. ));
  40. } elseif (!$this->owner->RequireRapApproval) {
  41. $fields->addFieldsToTab('Root.RAP', array(
  42. // ApprovalAnchor is used by MemberApprovalController (2017-02-01)
  43. new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),
  44. new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'RAP Approval')),
  45. new LiteralField('ApprovalNote', "<p>This member has not yet been approved. They cannot access to full resources until their application has been approved.</p><p><strong>PLEASE NOTE</strong> - once approved, three steps need to do: change the 'RAP Category' status to 'Provisional' or 'Qualified', add today's date into 'Year Provisional' or 'Year Qualified' field and update two access groups for to access the full resources.</p>"),
  46. new DropdownField('NeedsApproval', '', array(
  47. true => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),
  48. false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')
  49. ))
  50. ));
  51. }
  52. }
sutherlandesign

if ($this->owner->NeedsApproval) { $note = _t( 'MemberProfiles.NOLOGINUNTILAPPROVED', 'This member has not yet been approved. They cannot log in until their account is approved. Also check in \'RAP\' tab if member has applied for NZSL Tutor Registration.' );

        `if (!$this->owner->RequireApproval) {`
            `$fields->addFieldsToTab('Root.NZSLTA', array(`
                `// ApprovalAnchor is used by MemberApprovalController (2017-02-01)`
                `new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),`
                `new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'Registration Approval')),`
                `new LiteralField('ApprovalNote', "<p>$note</p>"),`
                `new DropdownField('NeedsApproval', '', array(`
                    `true  => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),`
                    `false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')`
                `))`
            `));`
        `} elseif (!$this->owner->RequireRenewApproval) {`
                `$fields->addFieldsToTab('Root.NZSLTA', array(`
                    `// ApprovalAnchor is used by MemberApprovalController (2017-02-01)`
                    `new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),`
                    `new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'Renew Approval')),`
                    `new LiteralField('ApprovalNote', "<p>$note</p>"),`
                    `new DropdownField('NeedsApproval', '', array(`
                        `true  => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),`
                        `false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')`
                    `))`
                `));`
        `} elseif (!$this->owner->RequireTraineeApproval) {`
                `$fields->addFieldsToTab('Root.NZSLTA', array(`
                    `// ApprovalAnchor is used by MemberApprovalController (2017-02-01)`
                    `new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),`
                    `new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'Trainee Approval')),`
                    `new LiteralField('ApprovalNote', "<p>This member has not yet been approved. They cannot access to Level One Unit 4-5 resources until their application has been approved.</p><p><strong>PLEASE NOTE</strong> - once approved, three steps need to do: change the 'RAP Category' status to 'Trainee', add today's date into 'Year Trainee' field and update two access groups for to access the full resources.</p>"),`
                    `new DropdownField('NeedsApproval', '', array(`
                        `true  => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),`
                        `false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')`
                    `))`
                `));`
        `} elseif (!$this->owner->RequireRapApproval) {`
                `$fields->addFieldsToTab('Root.RAP', array(`
                    `// ApprovalAnchor is used by MemberApprovalController (2017-02-01)`
                    `new LiteralField('ApprovalAnchor', "<div id=\"MemberProfileRegistrationApproval\"></div>"),`
                    `new HeaderField('ApprovalHeader', _t('MemberProfiles.REGAPPROVAL', 'RAP Approval')),`
                    `new LiteralField('ApprovalNote', "<p>This member has not yet been approved. They cannot access to full resources until their application has been approved.</p><p><strong>PLEASE NOTE</strong> - once approved, three steps need to do: change the 'RAP Category' status to 'Provisional' or 'Qualified', add today's date into 'Year Provisional' or 'Year Qualified' field and update two access groups for to access the full resources.</p>"),`
                    `new DropdownField('NeedsApproval', '', array(`
                        `true  => _t('MemberProfiles.DONOTCHANGE', 'Do not change'),`
                        `false => _t('MemberProfiles.APPROVETHISMEMBER', 'Approve this member')`
                    `))`
                `));`
            `}`
    `}`
sutherlandesign

I've managed to get the Framework issue fixed, but getting failed error this time about the PHP version, it only requires 5.3.3 but mine is php 7.0.15, don't think that module hasn't upgrade to php 7 yet, unless there is already?

sutherlandesign

    - silverstripe/framework 3.5.x-dev requires php >=5.3.3,<7 -> your PHP version (7.1.32) overridden by "config.platform.php" version (7.0.15) does not satisfy that requirement.
    - silverstripe/framework 3.5.8-rc1 requires php >=5.3.3,<7 -> your PHP version (7.1.32) overridden by "config.platform.php" version (7.0.15) does not satisfy that requirement.
    - silverstripe/framework 3.5.8 requires php >=5.3.3,<7 -> your PHP version (7.1.32) overridden by "config.platform.php" version (7.0.15) does not satisfy that requirement.
    - silverstripe/framework 3.5.7 requires php >=5.3.3,<7 -> your PHP version (7.1.32) overridden by "config.platform.php" version (7.0.15) does not satisfy that requirement.
    - silverstripe/framework 3.5.6-rc1 requires php >=5.3.3,<7 -> your PHP version (7.1.32) overridden by "config.platform.php" version (7.0.15) does not satisfy that requirement.
    - silverstripe/framework 3.5.6 requires php >=5.3.3,<7 -> your PHP version (7.1.32) overridden by "config.platform.php" version (7.0.15) does not satisfy that requirement.
    etc... etc... as too long to post it here....
    - Installation request for unclecheese/dropzone 1.4.14 -> satisfiable by unclecheese/dropzone[1.4.14].
    - Conclusion: remove silverstripe/framework 4.4.4
    - Conclusion: don't install silverstripe/framework 4.4.4
    - unclecheese/dropzone 1.4.14 requires silverstripe/framework 3.* -> satisfiable by silverstripe/framework[3.0.10, 3.0.10-rc1, 3.0.11, 3.0.11-rc1, 3.0.12, 3.0.13, 3.0.14, 3.0.2.1, 3.0.3, 3.0.3-rc1, 3.0.3-rc2, 3.0.4, 3.0.5, 3.0.6, 3.0.6-rc1, 3.0.6-rc2, 3.0.7, 3.0.7-rc1, 3.0.8, 3.0.9, 3.0.9-rc1, 3.0.x-dev, 3.1.0, 3.1.0-beta1, 3.1.0-beta2, 3.1.0-beta3, 3.1.0-rc1, 3.1.0-rc2, 3.1.0-rc3, 3.1.1, 3.1.10, 3.1.10-rc1, 3.1.10-rc2, 3.1.11, 3.1.11-rc1, 3.1.12, 3.1.13, 3.1.13-rc1, 3.1.14, 3.1.14-rc1, 3.1.15, 3.1.16, 3.1.16-rc1, 3.1.17, 3.1.17-rc1, 3.1.17-rc2, 3.1.18, 3.1.18-rc1, 3.1.18-rc2, 3.1.19, 3.1.19-rc1, 3.1.2, 3.1.2-rc1, 3.1.20, 3.1.20-rc1, 3.1.20-rc2, 3.1.21, 3.1.3, 3.1.3-rc1, 3.1.3-rc2, 3.1.4, 3.1.4-rc1, 3.1.5, 3.1.5-rc1, 3.1.6, 3.1.6-rc1, 3.1.6-rc2, 3.1.6-rc3, 3.1.7, 3.1.7-rc1, 3.1.8, 3.1.9, 3.1.9-rc1, 3.2.0, 3.2.0-beta1, 3.2.0-beta2, 3.2.0-rc1, 3.2.0-rc2, 3.2.1, 3.2.1-rc1, 3.2.1-rc2, 3.2.2, 3.2.2-rc1, 3.2.2-rc2, 3.2.3, 3.2.3-rc1, 3.2.3-rc2, 3.2.4, 3.2.4-rc1, 3.2.5, 3.2.5-rc1, 3.2.5-rc2, 3.2.6, 3.3.0, 3.3.0-beta1, 3.3.0-rc1, 3.3.0-rc2, 3.3.0-rc3, 3.3.1, 3.3.1-rc1, 3.3.1-rc2, 3.3.2, 3.3.2-rc1, 3.3.3, 3.3.3-rc1, 3.3.3-rc2, 3.3.4, 3.4.0, 3.4.0-rc1, 3.4.1, 3.4.1-rc1, 3.4.1-rc2, 3.4.2, 3.4.3, 3.4.3-rc1, 3.4.4, 3.4.4-rc1, 3.4.5, 3.4.5-rc1, 3.4.6, 3.4.6-rc1, 3.4.6-rc2, 3.5.0, 3.5.0-rc1, 3.5.0-rc2, 3.5.0-rc3, 3.5.1, 3.5.1-rc1, 3.5.1-rc2, 3.5.2, 3.5.2-rc1, 3.5.3, 3.5.3-rc1, 3.5.4, 3.5.4-rc1, 3.5.5, 3.5.5-beta1, 3.5.5-beta2, 3.5.6, 3.5.6-rc1, 3.5.7, 3.5.8, 3.5.8-rc1, 3.5.x-dev, 3.6.0, 3.6.0-beta1, 3.6.0-beta2, 3.6.0-rc1, 3.6.1, 3.6.1-alpha2, 3.6.2, 3.6.2-beta1, 3.6.2-beta2, 3.6.3, 3.6.3-rc2, 3.6.4, 3.6.5, 3.6.6, 3.6.6-rc1, 3.6.7, 3.6.8, 3.6.x-dev, 3.7.0, 3.7.1, 3.7.1-rc1, 3.7.2, 3.7.3, 3.7.4, 3.7.x-dev, 3.x-dev].
    - Can only install one of: silverstripe/framework[3.0.10, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.10-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.11, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.11-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.12, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.13, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.14, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.2.1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.3, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.3-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.3-rc2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.4, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.5, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.6, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.6-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.6-rc2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.7, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.7-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.8, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.9, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.9-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.0.x-dev, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.0, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.0-beta1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.0-beta2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.0-beta3, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.0-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.0-rc2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.0-rc3, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.10, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.10-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.10-rc2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.11, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.11-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.12, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.13, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.13-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.2-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.3, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.3-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.3-rc2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.4, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.4-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.5, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.5-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.6, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.6-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.6-rc2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.6-rc3, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.7, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.7-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.8, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.9, 4.4.4].
    - Can only install one of: silverstripe/framework[3.1.9-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.2.0-beta1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.2.0-beta2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.0, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.0-beta1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.0-beta2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.0-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.1-alpha2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.2-beta1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.2-beta2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.3, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.3-rc2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.4, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.5, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.6, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.6-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.7, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.8, 4.4.4].
    - Can only install one of: silverstripe/framework[3.6.x-dev, 4.4.4].
    - Can only install one of: silverstripe/framework[3.7.0, 4.4.4].
    - Can only install one of: silverstripe/framework[3.7.1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.7.1-rc1, 4.4.4].
    - Can only install one of: silverstripe/framework[3.7.2, 4.4.4].
    - Can only install one of: silverstripe/framework[3.7.3, 4.4.4].
    - Can only install one of: silverstripe/framework[3.7.4, 4.4.4].
    - Can only install one of: silverstripe/framework[3.7.x-dev, 4.4.4].
    - Can only install one of: silverstripe/framework[3.x-dev, 4.4.4].
    - Installation request for silverstripe/framework (locked at 4.4.4) -> satisfiable by silverstripe/framework[4.4.4].```