| Conditions | 8 |
| Paths | 40 |
| Total Lines | 87 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 64 | function mct_show_form() { |
||
| 65 | $_consenttypes = BoincConsentType::enum(null, "ORDER BY project_specific ASC"); |
||
| 66 | |||
| 67 | if (!in_rops()) { |
||
| 68 | echo "<strong>HELP: ProjectSpecific=0 consent types are defined by BOINC. You may add and remove project-specific consent types using this form.</strong>"; |
||
| 69 | } |
||
| 70 | start_table(""); |
||
| 71 | table_header( |
||
| 72 | "Name", |
||
| 73 | "Description", |
||
| 74 | "Enabled", |
||
| 75 | "ProjectSpecific", |
||
| 76 | "PrivacyPrefs", |
||
| 77 | "" |
||
| 78 | ); |
||
| 79 | |||
| 80 | foreach ($_consenttypes as $ct) { |
||
| 81 | echo "<tr><form action=manage_consent_types.php method=POST>\n"; |
||
| 82 | |||
| 83 | // Name |
||
| 84 | echo "<input type=hidden name=consent_type_id value=$ct->id>"; |
||
| 85 | echo " <td>$ct->shortname</td>"; |
||
| 86 | |||
| 87 | // Description |
||
| 88 | echo " <td>$ct->description</td>"; |
||
| 89 | |||
| 90 | // Enabled toggle |
||
| 91 | if (!in_rops()) { |
||
| 92 | if (!($ct->enabled)) { |
||
| 93 | echo " <td><input class=\"btn btn-default\" name=toggleenabled type=submit value=\"Click to Enable\"></td>"; |
||
| 94 | } |
||
| 95 | else { |
||
| 96 | echo " <td><input class=\"btn btn-default\" name=toggleenabled type=submit value=\"Click to Disable\"></td>"; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | else { |
||
| 100 | echo " <td>$ct->enabled</td>"; |
||
| 101 | } |
||
| 102 | |||
| 103 | // Project_specific) consent type |
||
| 104 | echo " <td>$ct->project_specific</td>"; |
||
| 105 | |||
| 106 | // Privacypref toggle |
||
| 107 | if (!in_rops()) { |
||
| 108 | if (!($ct->privacypref)) { |
||
| 109 | echo " <td><input class=\"btn btn-default\" name=toggleprivacypref type=submit value=\"Click to Enable\"></td>"; |
||
| 110 | } |
||
| 111 | else { |
||
| 112 | echo " <td><input class=\"btn btn-default\" name=toggleprivacypref type=submit value=\"Click to Disable\"></td>"; |
||
| 113 | } |
||
| 114 | } |
||
| 115 | else { |
||
| 116 | echo " <td>$ct->privacypref</td>"; |
||
| 117 | } |
||
| 118 | |||
| 119 | echo "</form></tr>"; |
||
| 120 | } |
||
| 121 | end_table(); |
||
| 122 | |||
| 123 | // Entry form to create a new consent type |
||
| 124 | if (in_rops()) { |
||
| 125 | return; |
||
| 126 | } |
||
| 127 | |||
| 128 | echo"<P> |
||
|
|
|||
| 129 | <h2>Add consent type</h2> |
||
| 130 | <p> |
||
| 131 | <p><strong>HELP: To add a consent type, provide a name and description. Then you may toggle the Enabled and PrivacyPrefs settings in the table above.</strong></p> |
||
| 132 | <p>For Name, please stick to this convention: an ALLCAPS short name, without any spaces. Example: FORUM</p> |
||
| 133 | <p>For Description: if your consent type will be part of the privacy preferences, it is best to use a full sentence with a question mark at the end. Example: Do you want SPAM, bacon, sausage, and SPAM?</p> |
||
| 134 | <p><em>Why can't I delete consent types?</em> Consent types cannot be deleted once created. This is to preserve and audit trail that may be legally necessary. You may disable a consent type if it is no longer needed.</p> |
||
| 135 | <form action=manage_consent_types.php method=POST> |
||
| 136 | "; |
||
| 137 | |||
| 138 | start_table("align='center' "); |
||
| 139 | |||
| 140 | table_header("Name", "Description", " "); |
||
| 141 | |||
| 142 | echo "<TR> |
||
| 143 | <TD> <input type='text' size='10' name='add_name' value=''> </TD> |
||
| 144 | <TD> <input type='text' size='35' name='add_description' value=''> </TD> |
||
| 145 | <TD align='center' > |
||
| 146 | <input type='submit' name='add_consenttype' value='Add Consent Type'></TD> |
||
| 147 | </TR>\n"; |
||
| 148 | |||
| 149 | end_table(); |
||
| 150 | echo "</form><p>\n"; |
||
| 151 | |||
| 172 |