Complex classes like Member often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Member, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
63 | class Member extends DataObject implements TemplateGlobalProvider { |
||
64 | |||
65 | private static $db = array( |
||
66 | 'FirstName' => 'Varchar', |
||
67 | 'Surname' => 'Varchar', |
||
68 | 'Email' => 'Varchar(254)', // See RFC 5321, Section 4.5.3.1.3. (256 minus the < and > character) |
||
69 | 'TempIDHash' => 'Varchar(160)', // Temporary id used for cms re-authentication |
||
70 | 'TempIDExpired' => 'Datetime', // Expiry of temp login |
||
71 | 'Password' => 'Varchar(160)', |
||
72 | 'AutoLoginHash' => 'Varchar(160)', // Used to auto-login the user on password reset |
||
73 | 'AutoLoginExpired' => 'Datetime', |
||
74 | // This is an arbitrary code pointing to a PasswordEncryptor instance, |
||
75 | // not an actual encryption algorithm. |
||
76 | // Warning: Never change this field after its the first password hashing without |
||
77 | // providing a new cleartext password as well. |
||
78 | 'PasswordEncryption' => "Varchar(50)", |
||
79 | 'Salt' => 'Varchar(50)', |
||
80 | 'PasswordExpiry' => 'Date', |
||
81 | 'LockedOutUntil' => 'Datetime', |
||
82 | 'Locale' => 'Varchar(6)', |
||
83 | // handled in registerFailedLogin(), only used if $lock_out_after_incorrect_logins is set |
||
84 | 'FailedLoginCount' => 'Int', |
||
85 | // In ISO format |
||
86 | 'DateFormat' => 'Varchar(30)', |
||
87 | 'TimeFormat' => 'Varchar(30)', |
||
88 | ); |
||
89 | |||
90 | private static $belongs_many_many = array( |
||
91 | 'Groups' => 'SilverStripe\\Security\\Group', |
||
92 | ); |
||
93 | |||
94 | private static $has_many = array( |
||
95 | 'LoggedPasswords' => 'SilverStripe\\Security\\MemberPassword', |
||
96 | 'RememberLoginHashes' => 'SilverStripe\\Security\\RememberLoginHash' |
||
97 | ); |
||
98 | |||
99 | private static $table_name = "Member"; |
||
100 | |||
101 | private static $default_sort = '"Surname", "FirstName"'; |
||
102 | |||
103 | private static $indexes = array( |
||
104 | 'Email' => true, |
||
105 | //Removed due to duplicate null values causing MSSQL problems |
||
106 | //'AutoLoginHash' => Array('type'=>'unique', 'value'=>'AutoLoginHash', 'ignoreNulls'=>true) |
||
|
|||
107 | ); |
||
108 | |||
109 | /** |
||
110 | * @config |
||
111 | * @var boolean |
||
112 | */ |
||
113 | private static $notify_password_change = false; |
||
114 | |||
115 | /** |
||
116 | * All searchable database columns |
||
117 | * in this object, currently queried |
||
118 | * with a "column LIKE '%keywords%' |
||
119 | * statement. |
||
120 | * |
||
121 | * @var array |
||
122 | * @todo Generic implementation of $searchable_fields on DataObject, |
||
123 | * with definition for different searching algorithms |
||
124 | * (LIKE, FULLTEXT) and default FormFields to construct a searchform. |
||
125 | */ |
||
126 | private static $searchable_fields = array( |
||
127 | 'FirstName', |
||
128 | 'Surname', |
||
129 | 'Email', |
||
130 | ); |
||
131 | |||
132 | private static $summary_fields = array( |
||
133 | 'FirstName', |
||
134 | 'Surname', |
||
135 | 'Email', |
||
136 | ); |
||
137 | |||
138 | /** |
||
139 | * Internal-use only fields |
||
140 | * |
||
141 | * @config |
||
142 | * @var array |
||
143 | */ |
||
144 | private static $hidden_fields = array( |
||
145 | 'AutoLoginHash', |
||
146 | 'AutoLoginExpired', |
||
147 | 'PasswordEncryption', |
||
148 | 'PasswordExpiry', |
||
149 | 'LockedOutUntil', |
||
150 | 'TempIDHash', |
||
151 | 'TempIDExpired', |
||
152 | 'Salt', |
||
153 | ); |
||
154 | |||
155 | /** |
||
156 | * @config |
||
157 | * @var array See {@link set_title_columns()} |
||
158 | */ |
||
159 | private static $title_format = null; |
||
160 | |||
161 | /** |
||
162 | * The unique field used to identify this member. |
||
163 | * By default, it's "Email", but another common |
||
164 | * field could be Username. |
||
165 | * |
||
166 | * @config |
||
167 | * @var string |
||
168 | */ |
||
169 | private static $unique_identifier_field = 'Email'; |
||
170 | |||
171 | /** |
||
172 | * Object for validating user's password |
||
173 | * |
||
174 | * @config |
||
175 | * @var PasswordValidator |
||
176 | */ |
||
177 | private static $password_validator = null; |
||
178 | |||
179 | /** |
||
180 | * @config |
||
181 | * The number of days that a password should be valid for. |
||
182 | * By default, this is null, which means that passwords never expire |
||
183 | */ |
||
184 | private static $password_expiry_days = null; |
||
185 | |||
186 | /** |
||
187 | * @config |
||
188 | * @var Int Number of incorrect logins after which |
||
189 | * the user is blocked from further attempts for the timespan |
||
190 | * defined in {@link $lock_out_delay_mins}. |
||
191 | */ |
||
192 | private static $lock_out_after_incorrect_logins = 10; |
||
193 | |||
194 | /** |
||
195 | * @config |
||
196 | * @var integer Minutes of enforced lockout after incorrect password attempts. |
||
197 | * Only applies if {@link $lock_out_after_incorrect_logins} greater than 0. |
||
198 | */ |
||
199 | private static $lock_out_delay_mins = 15; |
||
200 | |||
201 | /** |
||
202 | * @config |
||
203 | * @var String If this is set, then a session cookie with the given name will be set on log-in, |
||
204 | * and cleared on logout. |
||
205 | */ |
||
206 | private static $login_marker_cookie = null; |
||
207 | |||
208 | /** |
||
209 | * Indicates that when a {@link Member} logs in, Member:session_regenerate_id() |
||
210 | * should be called as a security precaution. |
||
211 | * |
||
212 | * This doesn't always work, especially if you're trying to set session cookies |
||
213 | * across an entire site using the domain parameter to session_set_cookie_params() |
||
214 | * |
||
215 | * @config |
||
216 | * @var boolean |
||
217 | */ |
||
218 | private static $session_regenerate_id = true; |
||
219 | |||
220 | |||
221 | /** |
||
222 | * Default lifetime of temporary ids. |
||
223 | * |
||
224 | * This is the period within which a user can be re-authenticated within the CMS by entering only their password |
||
225 | * and without losing their workspace. |
||
226 | * |
||
227 | * Any session expiration outside of this time will require them to login from the frontend using their full |
||
228 | * username and password. |
||
229 | * |
||
230 | * Defaults to 72 hours. Set to zero to disable expiration. |
||
231 | * |
||
232 | * @config |
||
233 | * @var int Lifetime in seconds |
||
234 | */ |
||
235 | private static $temp_id_lifetime = 259200; |
||
236 | |||
237 | /** |
||
238 | * @deprecated 4.0 Use the "Member.session_regenerate_id" config setting instead |
||
239 | */ |
||
240 | public static function set_session_regenerate_id($bool) { |
||
244 | |||
245 | /** |
||
246 | * Ensure the locale is set to something sensible by default. |
||
247 | */ |
||
248 | public function populateDefaults() { |
||
252 | |||
253 | public function requireDefaultRecords() { |
||
258 | |||
259 | /** |
||
260 | * Get the default admin record if it exists, or creates it otherwise if enabled |
||
261 | * |
||
262 | * @return Member |
||
263 | */ |
||
264 | public static function default_admin() { |
||
297 | |||
298 | /** |
||
299 | * If this is called, then a session cookie will be set to "1" whenever a user |
||
300 | * logs in. This lets 3rd party tools, such as apache's mod_rewrite, detect |
||
301 | * whether a user is logged in or not and alter behaviour accordingly. |
||
302 | * |
||
303 | * One known use of this is to bypass static caching for logged in users. This is |
||
304 | * done by putting this into _config.php |
||
305 | * <pre> |
||
306 | * Member::set_login_marker_cookie("SS_LOGGED_IN"); |
||
307 | * </pre> |
||
308 | * |
||
309 | * And then adding this condition to each of the rewrite rules that make use of |
||
310 | * the static cache. |
||
311 | * <pre> |
||
312 | * RewriteCond %{HTTP_COOKIE} !SS_LOGGED_IN=1 |
||
313 | * </pre> |
||
314 | * |
||
315 | * @deprecated 4.0 Use the "Member.login_marker_cookie" config setting instead |
||
316 | * @param $cookieName string The name of the cookie to set. |
||
317 | */ |
||
318 | public static function set_login_marker_cookie($cookieName) { |
||
322 | |||
323 | /** |
||
324 | * Check if the passed password matches the stored one (if the member is not locked out). |
||
325 | * |
||
326 | * @param string $password |
||
327 | * @return ValidationResult |
||
328 | */ |
||
329 | public function checkPassword($password) { |
||
358 | |||
359 | /** |
||
360 | * Check if this user is the currently configured default admin |
||
361 | * |
||
362 | * @return bool |
||
363 | */ |
||
364 | public function isDefaultAdmin() { |
||
368 | |||
369 | /** |
||
370 | * Returns a valid {@link ValidationResult} if this member can currently log in, or an invalid |
||
371 | * one with error messages to display if the member is locked out. |
||
372 | * |
||
373 | * You can hook into this with a "canLogIn" method on an attached extension. |
||
374 | * |
||
375 | * @return ValidationResult |
||
376 | */ |
||
377 | public function canLogIn() { |
||
395 | |||
396 | /** |
||
397 | * Returns true if this user is locked out |
||
398 | */ |
||
399 | public function isLockedOut() { |
||
402 | |||
403 | /** |
||
404 | * Regenerate the session_id. |
||
405 | * This wrapper is here to make it easier to disable calls to session_regenerate_id(), should you need to. |
||
406 | * They have caused problems in certain |
||
407 | * quirky problems (such as using the Windmill 0.3.6 proxy). |
||
408 | */ |
||
409 | public static function session_regenerate_id() { |
||
422 | |||
423 | /** |
||
424 | * Get the field used for uniquely identifying a member |
||
425 | * in the database. {@see Member::$unique_identifier_field} |
||
426 | * |
||
427 | * @deprecated 4.0 Use the "Member.unique_identifier_field" config setting instead |
||
428 | * @return string |
||
429 | */ |
||
430 | public static function get_unique_identifier_field() { |
||
434 | |||
435 | /** |
||
436 | * Set the field used for uniquely identifying a member |
||
437 | * in the database. {@see Member::$unique_identifier_field} |
||
438 | * |
||
439 | * @deprecated 4.0 Use the "Member.unique_identifier_field" config setting instead |
||
440 | * @param $field The field name to set as the unique field |
||
441 | */ |
||
442 | public static function set_unique_identifier_field($field) { |
||
446 | |||
447 | /** |
||
448 | * Set a {@link PasswordValidator} object to use to validate member's passwords. |
||
449 | * |
||
450 | * @param PasswordValidator $pv |
||
451 | */ |
||
452 | public static function set_password_validator($pv) { |
||
455 | |||
456 | /** |
||
457 | * Returns the current {@link PasswordValidator} |
||
458 | * |
||
459 | * @return PasswordValidator |
||
460 | */ |
||
461 | public static function password_validator() { |
||
464 | |||
465 | /** |
||
466 | * Set the number of days that a password should be valid for. |
||
467 | * Set to null (the default) to have passwords never expire. |
||
468 | * |
||
469 | * @deprecated 4.0 Use the "Member.password_expiry_days" config setting instead |
||
470 | */ |
||
471 | public static function set_password_expiry($days) { |
||
475 | |||
476 | /** |
||
477 | * Configure the security system to lock users out after this many incorrect logins |
||
478 | * |
||
479 | * @deprecated 4.0 Use the "Member.lock_out_after_incorrect_logins" config setting instead |
||
480 | */ |
||
481 | public static function lock_out_after_incorrect_logins($numLogins) { |
||
485 | |||
486 | |||
487 | public function isPasswordExpired() { |
||
491 | |||
492 | /** |
||
493 | * Logs this member in |
||
494 | * |
||
495 | * @param bool $remember If set to TRUE, the member will be logged in automatically the next time. |
||
496 | */ |
||
497 | public function logIn($remember = false) { |
||
536 | |||
537 | /** |
||
538 | * Trigger regeneration of TempID. |
||
539 | * |
||
540 | * This should be performed any time the user presents their normal identification (normally Email) |
||
541 | * and is successfully authenticated. |
||
542 | */ |
||
543 | public function regenerateTempID() { |
||
551 | |||
552 | /** |
||
553 | * Check if the member ID logged in session actually |
||
554 | * has a database record of the same ID. If there is |
||
555 | * no logged in user, FALSE is returned anyway. |
||
556 | * |
||
557 | * @return boolean TRUE record found FALSE no record found |
||
558 | */ |
||
559 | public static function logged_in_session_exists() { |
||
568 | |||
569 | /** |
||
570 | * Log the user in if the "remember login" cookie is set |
||
571 | * |
||
572 | * The <i>remember login token</i> will be changed on every successful |
||
573 | * auto-login. |
||
574 | */ |
||
575 | public static function autoLogin() { |
||
645 | |||
646 | /** |
||
647 | * Logs this member out. |
||
648 | */ |
||
649 | public function logOut() { |
||
676 | |||
677 | /** |
||
678 | * Utility for generating secure password hashes for this member. |
||
679 | * |
||
680 | * @param string $string |
||
681 | * @return string |
||
682 | * @throws PasswordEncryptor_NotFoundException |
||
683 | */ |
||
684 | public function encryptWithUserSettings($string) { |
||
698 | |||
699 | /** |
||
700 | * Generate an auto login token which can be used to reset the password, |
||
701 | * at the same time hashing it and storing in the database. |
||
702 | * |
||
703 | * @param int $lifetime The lifetime of the auto login hash in days (by default 2 days) |
||
704 | * |
||
705 | * @returns string Token that should be passed to the client (but NOT persisted). |
||
706 | * |
||
707 | * @todo Make it possible to handle database errors such as a "duplicate key" error |
||
708 | */ |
||
709 | public function generateAutologinTokenAndStoreHash($lifetime = 2) { |
||
725 | |||
726 | /** |
||
727 | * Check the token against the member. |
||
728 | * |
||
729 | * @param string $autologinToken |
||
730 | * |
||
731 | * @returns bool Is token valid? |
||
732 | */ |
||
733 | public function validateAutoLoginToken($autologinToken) { |
||
738 | |||
739 | /** |
||
740 | * Return the member for the auto login hash |
||
741 | * |
||
742 | * @param string $hash The hash key |
||
743 | * @param bool $login Should the member be logged in? |
||
744 | * |
||
745 | * @return Member the matching member, if valid |
||
746 | * @return Member |
||
747 | */ |
||
748 | public static function member_from_autologinhash($hash, $login = false) { |
||
760 | |||
761 | /** |
||
762 | * Find a member record with the given TempIDHash value |
||
763 | * |
||
764 | * @param string $tempid |
||
765 | * @return Member |
||
766 | */ |
||
767 | public static function member_from_tempid($tempid) { |
||
778 | |||
779 | /** |
||
780 | * Returns the fields for the member form - used in the registration/profile module. |
||
781 | * It should return fields that are editable by the admin and the logged-in user. |
||
782 | * |
||
783 | * @return FieldList Returns a {@link FieldList} containing the fields for |
||
784 | * the member form. |
||
785 | */ |
||
786 | public function getMemberFormFields() { |
||
804 | |||
805 | /** |
||
806 | * Builds "Change / Create Password" field for this member |
||
807 | * |
||
808 | * @return ConfirmedPasswordField |
||
809 | */ |
||
810 | public function getMemberPasswordField() { |
||
833 | |||
834 | |||
835 | /** |
||
836 | * Returns the {@link RequiredFields} instance for the Member object. This |
||
837 | * Validator is used when saving a {@link CMSProfileController} or added to |
||
838 | * any form responsible for saving a users data. |
||
839 | * |
||
840 | * To customize the required fields, add a {@link DataExtension} to member |
||
841 | * calling the `updateValidator()` method. |
||
842 | * |
||
843 | * @return Member_Validator |
||
844 | */ |
||
845 | public function getValidator() { |
||
852 | |||
853 | |||
854 | /** |
||
855 | * Returns the current logged in user |
||
856 | * |
||
857 | * @return Member |
||
858 | */ |
||
859 | public static function currentUser() { |
||
866 | |||
867 | /** |
||
868 | * Get the ID of the current logged in user |
||
869 | * |
||
870 | * @return int Returns the ID of the current logged in user or 0. |
||
871 | */ |
||
872 | public static function currentUserID() { |
||
881 | private static $_already_tried_to_auto_log_in = false; |
||
882 | |||
883 | |||
884 | /* |
||
885 | * Generate a random password, with randomiser to kick in if there's no words file on the |
||
886 | * filesystem. |
||
887 | * |
||
888 | * @return string Returns a random password. |
||
889 | */ |
||
890 | public static function create_new_password() { |
||
910 | |||
911 | /** |
||
912 | * Event handler called before writing to the database. |
||
913 | */ |
||
914 | public function onBeforeWrite() { |
||
997 | |||
998 | public function onAfterWrite() { |
||
1007 | |||
1008 | public function onAfterDelete() { |
||
1014 | |||
1015 | /** |
||
1016 | * Delete the MemberPassword objects that are associated to this user |
||
1017 | * |
||
1018 | * @return self |
||
1019 | */ |
||
1020 | protected function deletePasswordLogs() { |
||
1027 | |||
1028 | /** |
||
1029 | * Filter out admin groups to avoid privilege escalation, |
||
1030 | * If any admin groups are requested, deny the whole save operation. |
||
1031 | * |
||
1032 | * @param array $ids Database IDs of Group records |
||
1033 | * @return bool True if the change can be accepted |
||
1034 | */ |
||
1035 | public function onChangeGroups($ids) { |
||
1046 | |||
1047 | |||
1048 | /** |
||
1049 | * Check if the member is in one of the given groups. |
||
1050 | * |
||
1051 | * @param array|SS_List $groups Collection of {@link Group} DataObjects to check |
||
1052 | * @param boolean $strict Only determine direct group membership if set to true (Default: false) |
||
1053 | * @return bool Returns TRUE if the member is in one of the given groups, otherwise FALSE. |
||
1054 | */ |
||
1055 | public function inGroups($groups, $strict = false) { |
||
1062 | |||
1063 | |||
1064 | /** |
||
1065 | * Check if the member is in the given group or any parent groups. |
||
1066 | * |
||
1067 | * @param int|Group|string $group Group instance, Group Code or ID |
||
1068 | * @param boolean $strict Only determine direct group membership if set to TRUE (Default: FALSE) |
||
1069 | * @return bool Returns TRUE if the member is in the given group, otherwise FALSE. |
||
1070 | */ |
||
1071 | public function inGroup($group, $strict = false) { |
||
1093 | |||
1094 | /** |
||
1095 | * Adds the member to a group. This will create the group if the given |
||
1096 | * group code does not return a valid group object. |
||
1097 | * |
||
1098 | * @param string $groupcode |
||
1099 | * @param string $title Title of the group |
||
1100 | */ |
||
1101 | public function addToGroupByCode($groupcode, $title = "") { |
||
1119 | |||
1120 | /** |
||
1121 | * Removes a member from a group. |
||
1122 | * |
||
1123 | * @param string $groupcode |
||
1124 | */ |
||
1125 | public function removeFromGroupByCode($groupcode) { |
||
1132 | |||
1133 | /** |
||
1134 | * @param array $columns Column names on the Member record to show in {@link getTitle()}. |
||
1135 | * @param String $sep Separator |
||
1136 | */ |
||
1137 | public static function set_title_columns($columns, $sep = ' ') { |
||
1141 | |||
1142 | //------------------- HELPER METHODS -----------------------------------// |
||
1143 | |||
1144 | /** |
||
1145 | * Get the complete name of the member, by default in the format "<Surname>, <FirstName>". |
||
1146 | * Falls back to showing either field on its own. |
||
1147 | * |
||
1148 | * You can overload this getter with {@link set_title_format()} |
||
1149 | * and {@link set_title_sql()}. |
||
1150 | * |
||
1151 | * @return string Returns the first- and surname of the member. If the ID |
||
1152 | * of the member is equal 0, only the surname is returned. |
||
1153 | */ |
||
1154 | public function getTitle() { |
||
1177 | |||
1178 | /** |
||
1179 | * Return a SQL CONCAT() fragment suitable for a SELECT statement. |
||
1180 | * Useful for custom queries which assume a certain member title format. |
||
1181 | * |
||
1182 | * @return String SQL |
||
1183 | */ |
||
1184 | public static function get_title_sql() { |
||
1205 | |||
1206 | |||
1207 | /** |
||
1208 | * Get the complete name of the member |
||
1209 | * |
||
1210 | * @return string Returns the first- and surname of the member. |
||
1211 | */ |
||
1212 | public function getName() { |
||
1215 | |||
1216 | |||
1217 | /** |
||
1218 | * Set first- and surname |
||
1219 | * |
||
1220 | * This method assumes that the last part of the name is the surname, e.g. |
||
1221 | * <i>A B C</i> will result in firstname <i>A B</i> and surname <i>C</i> |
||
1222 | * |
||
1223 | * @param string $name The name |
||
1224 | */ |
||
1225 | public function setName($name) { |
||
1230 | |||
1231 | |||
1232 | /** |
||
1233 | * Alias for {@link setName} |
||
1234 | * |
||
1235 | * @param string $name The name |
||
1236 | * @see setName() |
||
1237 | */ |
||
1238 | public function splitName($name) { |
||
1241 | |||
1242 | /** |
||
1243 | * Override the default getter for DateFormat so the |
||
1244 | * default format for the user's locale is used |
||
1245 | * if the user has not defined their own. |
||
1246 | * |
||
1247 | * @return string ISO date format |
||
1248 | */ |
||
1249 | public function getDateFormat() { |
||
1256 | |||
1257 | /** |
||
1258 | * Override the default getter for TimeFormat so the |
||
1259 | * default format for the user's locale is used |
||
1260 | * if the user has not defined their own. |
||
1261 | * |
||
1262 | * @return string ISO date format |
||
1263 | */ |
||
1264 | public function getTimeFormat() { |
||
1271 | |||
1272 | //---------------------------------------------------------------------// |
||
1273 | |||
1274 | |||
1275 | /** |
||
1276 | * Get a "many-to-many" map that holds for all members their group memberships, |
||
1277 | * including any parent groups where membership is implied. |
||
1278 | * Use {@link DirectGroups()} to only retrieve the group relations without inheritance. |
||
1279 | * |
||
1280 | * @todo Push all this logic into Member_GroupSet's getIterator()? |
||
1281 | * @return Member_Groupset |
||
1282 | */ |
||
1283 | public function Groups() { |
||
1291 | |||
1292 | /** |
||
1293 | * @return ManyManyList |
||
1294 | */ |
||
1295 | public function DirectGroups() { |
||
1298 | |||
1299 | /** |
||
1300 | * Get a member SQLMap of members in specific groups |
||
1301 | * |
||
1302 | * If no $groups is passed, all members will be returned |
||
1303 | * |
||
1304 | * @param mixed $groups - takes a SS_List, an array or a single Group.ID |
||
1305 | * @return SS_Map Returns an SS_Map that returns all Member data. |
||
1306 | */ |
||
1307 | public static function map_in_groups($groups = null) { |
||
1334 | |||
1335 | |||
1336 | /** |
||
1337 | * Get a map of all members in the groups given that have CMS permissions |
||
1338 | * |
||
1339 | * If no groups are passed, all groups with CMS permissions will be used. |
||
1340 | * |
||
1341 | * @param array $groups Groups to consider or NULL to use all groups with |
||
1342 | * CMS permissions. |
||
1343 | * @return SS_Map Returns a map of all members in the groups given that |
||
1344 | * have CMS permissions. |
||
1345 | */ |
||
1346 | public static function mapInCMSGroups($groups = null) { |
||
1392 | |||
1393 | |||
1394 | /** |
||
1395 | * Get the groups in which the member is NOT in |
||
1396 | * |
||
1397 | * When passed an array of groups, and a component set of groups, this |
||
1398 | * function will return the array of groups the member is NOT in. |
||
1399 | * |
||
1400 | * @param array $groupList An array of group code names. |
||
1401 | * @param array $memberGroups A component set of groups (if set to NULL, |
||
1402 | * $this->groups() will be used) |
||
1403 | * @return array Groups in which the member is NOT in. |
||
1404 | */ |
||
1405 | public function memberNotInGroups($groupList, $memberGroups = null){ |
||
1417 | |||
1418 | |||
1419 | /** |
||
1420 | * Return a {@link FieldList} of fields that would appropriate for editing |
||
1421 | * this member. |
||
1422 | * |
||
1423 | * @return FieldList Return a FieldList of fields that would appropriate for |
||
1424 | * editing this member. |
||
1425 | */ |
||
1426 | public function getCMSFields() { |
||
1534 | |||
1535 | /** |
||
1536 | * @param bool $includerelations Indicate if the labels returned include relation fields |
||
1537 | * @return array |
||
1538 | */ |
||
1539 | public function fieldLabels($includerelations = true) { |
||
1557 | |||
1558 | /** |
||
1559 | * Users can view their own record. |
||
1560 | * Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions. |
||
1561 | * This is likely to be customized for social sites etc. with a looser permission model. |
||
1562 | * |
||
1563 | * @param Member $member |
||
1564 | * @return bool |
||
1565 | */ |
||
1566 | public function canView($member = null) { |
||
1588 | |||
1589 | /** |
||
1590 | * Users can edit their own record. |
||
1591 | * Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions |
||
1592 | * |
||
1593 | * @param Member $member |
||
1594 | * @return bool |
||
1595 | */ |
||
1596 | public function canEdit($member = null) { |
||
1623 | /** |
||
1624 | * Users can edit their own record. |
||
1625 | * Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions |
||
1626 | * |
||
1627 | * @param Member $member |
||
1628 | * @return bool |
||
1629 | */ |
||
1630 | public function canDelete($member = null) { |
||
1661 | |||
1662 | /** |
||
1663 | * Validate this member object. |
||
1664 | */ |
||
1665 | public function validate() { |
||
1682 | |||
1683 | /** |
||
1684 | * Change password. This will cause rehashing according to |
||
1685 | * the `PasswordEncryption` property. |
||
1686 | * |
||
1687 | * @param string $password Cleartext password |
||
1688 | * @return ValidationResult |
||
1689 | */ |
||
1690 | public function changePassword($password) { |
||
1701 | |||
1702 | /** |
||
1703 | * Tell this member that someone made a failed attempt at logging in as them. |
||
1704 | * This can be used to lock the user out temporarily if too many failed attempts are made. |
||
1705 | */ |
||
1706 | public function registerFailedLogin() { |
||
1720 | |||
1721 | /** |
||
1722 | * Tell this member that a successful login has been made |
||
1723 | */ |
||
1724 | public function registerSuccessfulLogin() { |
||
1731 | /** |
||
1732 | * Get the HtmlEditorConfig for this user to be used in the CMS. |
||
1733 | * This is set by the group. If multiple configurations are set, |
||
1734 | * the one with the highest priority wins. |
||
1735 | * |
||
1736 | * @return string |
||
1737 | */ |
||
1738 | public function getHtmlEditorConfigForCMS() { |
||
1756 | |||
1757 | public static function get_template_global_variables() { |
||
1763 | } |
||
1764 | |||
2003 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.