| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * ForumRole | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * This decorator adds the needed fields and methods to the {@link Member} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @package forum | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  | class ForumRole extends DataExtension | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |      * Edit the given query object to support queries for this extension | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     public function augmentSQL(SQLQuery &$query) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 18 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |      * Update the database schema as required by this extension | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     public function augmentDatabase() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $exist = DB::tableList(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         if (!empty($exist) && array_search('ForumMember', $exist) !== false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             DB::query("UPDATE \"Member\", \"ForumMember\" " . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |                 "SET \"Member\".\"ClassName\" = 'Member'," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |                 "\"Member\".\"ForumRank\" = \"ForumMember\".\"ForumRank\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |                 "\"Member\".\"Occupation\" = \"ForumMember\".\"Occupation\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |                 "\"Member\".\"Country\" = \"ForumMember\".\"Country\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |                 "\"Member\".\"Nickname\" = \"ForumMember\".\"Nickname\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |                 "\"Member\".\"FirstNamePublic\" = \"ForumMember\".\"FirstNamePublic\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |                 "\"Member\".\"SurnamePublic\" = \"ForumMember\".\"SurnamePublic\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |                 "\"Member\".\"OccupationPublic\" = \"ForumMember\".\"OccupationPublic\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |                 "\"Member\".\"CountryPublic\" = \"ForumMember\".\"CountryPublic\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                 "\"Member\".\"EmailPublic\" = \"ForumMember\".\"EmailPublic\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |                 "\"Member\".\"AvatarID\" = \"ForumMember\".\"AvatarID\"," . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |                 "\"Member\".\"LastViewed\" = \"ForumMember\".\"LastViewed\"" . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |                 "WHERE \"Member\".\"ID\" = \"ForumMember\".\"ID\""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             echo("<div style=\"padding:5px; color:white; background-color:blue;\">" . _t('ForumRole.TRANSFERSUCCEEDED', 'The data transfer has succeeded. However, to complete it, you must delete the ForumMember table. To do this, execute the query \"DROP TABLE \'ForumMember\'\".') . "</div>" ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     private static $db =  array( | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |         'ForumRank' => 'Varchar', | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         'Occupation' => 'Varchar', | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         'Company' => 'Varchar', | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         'City' => 'Varchar', | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         'Country' => 'Varchar', | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         'Nickname' => 'Varchar', | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         'FirstNamePublic' => 'Boolean', | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |         'SurnamePublic' => 'Boolean', | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |         'OccupationPublic' => 'Boolean', | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         'CompanyPublic' => 'Boolean', | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |         'CityPublic' => 'Boolean', | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         'CountryPublic' => 'Boolean', | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |         'EmailPublic' => 'Boolean', | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         'LastViewed' => 'SS_Datetime', | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         'Signature' => 'Text', | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |         'ForumStatus' => 'Enum("Normal, Banned, Ghost", "Normal")', | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |         'SuspendedUntil' => 'Date' | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |     private static $has_one = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         'Avatar' => 'Image' | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     private static $has_many = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |         'ForumPosts' => 'Post' | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |     private static $belongs_many_many = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |         'ModeratedForums' => 'Forum' | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |     private static $defaults = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |         'ForumRank' => 'Community Member' | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |     private static $searchable_fields = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |         'Nickname' => true | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     private static $indexes = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |         'Nickname' => true | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |     private static $field_labels = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         'SuspendedUntil' => "Suspend this member from writing on forums until the specified date" | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     ); | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     public function onBeforeDelete() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         parent::onBeforeDelete(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $avatar = $this->owner->Avatar(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         if ($avatar && $avatar->exists()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             $avatar->delete(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 102 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     public function ForumRank() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $moderatedForums = $this->owner->ModeratedForums(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         if ($moderatedForums && $moderatedForums->Count() > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             return _t('MODERATOR', 'Forum Moderator'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             return $this->owner->getField('ForumRank'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 112 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     public function FirstNamePublic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         return $this->owner->FirstNamePublic || Permission::check('ADMIN'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     public function SurnamePublic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         return $this->owner->SurnamePublic || Permission::check('ADMIN'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     public function OccupationPublic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         return $this->owner->OccupationPublic || Permission::check('ADMIN'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     public function CompanyPublic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         return $this->owner->CompanyPublic || Permission::check('ADMIN'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     public function CityPublic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         return $this->owner->CityPublic || Permission::check('ADMIN'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 133 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     public function CountryPublic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         return $this->owner->CountryPublic || Permission::check('ADMIN'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     public function EmailPublic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         return $this->owner->EmailPublic || Permission::check('ADMIN'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 141 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |      * Run the Country code through a converter to get the proper Country Name | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     public function FullCountry() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $locale = new Zend_Locale(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         $locale->setLocale($this->owner->Country); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         return $locale->getRegion(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 150 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     public function NumPosts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         if (is_numeric($this->owner->ID)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |             return $this->owner->ForumPosts()->Count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |      * Checks if the current user is a moderator of the | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |      * given forum by looking in the moderator ID list. | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |      * @param Forum object to check | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |      * @return boolean | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     public function isModeratingForum($forum) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         $moderatorIds = $forum->Moderators() ? $forum->Moderators()->getIdList() : array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         return in_array($this->owner->ID, $moderatorIds); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 171 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     public function Link() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         return "ForumMemberProfile/show/" . $this->owner->ID; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 176 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  |      * Get the fields needed by the forum module | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |      * @param bool $showIdentityURL Should a field for an OpenID or an i-name | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |      *                              be shown (always read-only)? | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |      * @return FieldList Returns a FieldList containing all needed fields for | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |      *                  the registration of new users | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     public function getForumFields($showIdentityURL = false, $addmode = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $gravatarText = (DataObject::get_one("ForumHolder", "\"AllowGravatars\" = 1")) ? '<small>'. _t('ForumRole.CANGRAVATAR', 'If you use Gravatars then leave this blank') .'</small>' : ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         //Sets the upload folder to the Configurable one set via the ForumHolder or overridden via Config::inst()->update(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $avatarField = new FileField('Avatar', _t('ForumRole.AVATAR', 'Avatar Image') .' '. $gravatarText); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         $avatarField->setFolderName(Config::inst()->get('ForumHolder', 'avatars_folder')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         $avatarField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         $personalDetailsFields = new CompositeField( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             new HeaderField("PersonalDetails", _t('ForumRole.PERSONAL', 'Personal Details')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             new LiteralField("Blurb", "<p id=\"helpful\">" . _t('ForumRole.TICK', 'Tick the fields to show in public profile') . "</p>"), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             new TextField("Nickname", _t('ForumRole.NICKNAME', 'Nickname')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             new CheckableOption("FirstNamePublic", new TextField("FirstName", _t('ForumRole.FIRSTNAME', 'First name'))), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             new CheckableOption("SurnamePublic", new TextField("Surname", _t('ForumRole.SURNAME', 'Surname'))), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |             new CheckableOption("OccupationPublic", new TextField("Occupation", _t('ForumRole.OCCUPATION', 'Occupation')), true), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             new CheckableOption('CompanyPublic', new TextField('Company', _t('ForumRole.COMPANY', 'Company')), true), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |             new CheckableOption('CityPublic', new TextField('City', _t('ForumRole.CITY', 'City')), true), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |             new CheckableOption("CountryPublic", new ForumCountryDropdownField("Country", _t('ForumRole.COUNTRY', 'Country')), true), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             new CheckableOption("EmailPublic", new EmailField("Email", _t('ForumRole.EMAIL', 'Email'))), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             new ConfirmedPasswordField("Password", _t('ForumRole.PASSWORD', 'Password')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             $avatarField | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         // Don't show 'forum rank' at registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         if (!$addmode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             $personalDetailsFields->push( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |                 new ReadonlyField("ForumRank", _t('ForumRole.RATING', 'User rating')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $personalDetailsFields->setID('PersonalDetailsFields'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $fieldset = new FieldList( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |             $personalDetailsFields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         if ($showIdentityURL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             $fieldset->insertBefore( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                 new ReadonlyField('IdentityURL', _t('ForumRole.OPENIDINAME', 'OpenID/i-name')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                 'Password' | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             $fieldset->insertAfter( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                 new LiteralField( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |                     'PasswordOptionalMessage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                     '<p>' . _t('ForumRole.PASSOPTMESSAGE', 'Since you provided an OpenID respectively an i-name the password is optional. If you enter one, you will be able to log in also with your e-mail address.') . '</p>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |                 'IdentityURL' | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         if ($this->owner->IsSuspended()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             $fieldset->insertAfter( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                 new LiteralField( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |                     'SuspensionNote', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |                     '<p class="message warning suspensionWarning">' . $this->ForumSuspensionMessage() . '</p>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |                 'Blurb' | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         $this->owner->extend('updateForumFields', $fieldset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         return $fieldset; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 249 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  |      * Get the fields needed by the forum module | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  |      * @param bool $needPassword Should a password be required? | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  |      * @return Validator Returns a Validator for the fields required for the | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  |      *                              registration of new users | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     public function getForumValidator($needPassword = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |         if ($needPassword) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             $validator = new RequiredFields("Nickname", "Email", "Password"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             $validator = new RequiredFields("Nickname", "Email"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         $this->owner->extend('updateForumValidator', $validator); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |         return $validator; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 268 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     public function updateCMSFields(FieldList $fields) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         $allForums = DataObject::get('Forum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |         $fields->removeByName('ModeratedForums'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         $fields->addFieldToTab('Root.ModeratedForums', new CheckboxSetField('ModeratedForums', _t('ForumRole.MODERATEDFORUMS', 'Moderated forums'), ($allForums->exists() ? $allForums->map('ID', 'Title') : array()))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |         $suspend = $fields->dataFieldByName('SuspendedUntil'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         $suspend->setConfig('showcalendar', true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |         if (Permission::checkMember($this->owner->ID, "ACCESS_FORUM")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             $avatarField = new FileField('Avatar', _t('ForumRole.UPLOADAVATAR', 'Upload avatar')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             $avatarField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |             $fields->addFieldToTab('Root.Forum', $avatarField); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |             $fields->addFieldToTab('Root.Forum', new DropdownField("ForumRank", _t('ForumRole.FORUMRANK', "User rating"), array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |                 "Community Member" => _t('ForumRole.COMMEMBER'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |                 "Administrator" => _t('ForumRole.ADMIN', 'Administrator'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |                 "Moderator" => _t('ForumRole.MOD', 'Moderator') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             ))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             $fields->addFieldToTab('Root.Forum', $this->owner->dbObject('ForumStatus')->scaffoldFormField()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 289 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 290 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |     public function IsSuspended() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |         if ($this->owner->SuspendedUntil) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |             return strtotime(SS_Datetime::now()->Format('Y-m-d')) < strtotime($this->owner->SuspendedUntil); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 298 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     public function IsBanned() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         return $this->owner->ForumStatus == 'Banned'; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 303 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |     public function IsGhost() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |         return $this->owner->ForumStatus == 'Ghost' && $this->owner->ID !== Member::currentUserID(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 308 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 309 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 310 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 311 |  |  |      * Can the current user edit the given member? | 
            
                                                                        
                            
            
                                    
            
            
                | 312 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 313 |  |  |      * @return true if this member can be edited, false otherwise | 
            
                                                                        
                            
            
                                    
            
            
                | 314 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     public function canEdit($member = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         if (!$member) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |             $member = Member::currentUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |         if ($this->owner->ID == Member::currentUserID()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |             return true; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |         if ($member) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             return $member->can('AdminCMS'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         return false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 330 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |      * Used in preference to the Nickname field on templates | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |      * Provides a default for the nickname field (first name, or "Anonymous | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  |      * User" if that's not set) | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     public function Nickname() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         if ($this->owner->Nickname) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |             return $this->owner->Nickname; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         } elseif ($this->owner->FirstNamePublic && $this->owner->FirstName) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |             return $this->owner->FirstName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |             return _t('ForumRole.ANONYMOUS', 'Anonymous user'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 348 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |      * Return the url of the avatar or gravatar of the selected user. | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |      * Checks to see if the current user has an avatar, if they do use it | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |      * otherwise query gravatar.com | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |      * @return String | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     public function getFormattedAvatar() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |         $default = "forum/images/forummember_holder.gif"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         $currentTheme = Config::inst()->get('SSViewer', 'theme'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         if (file_exists('themes/' . $currentTheme . '_forum/images/forummember_holder.gif')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |             $default = 'themes/' . $currentTheme . '_forum/images/forummember_holder.gif'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |         // if they have uploaded an image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |         if ($this->owner->AvatarID) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |             $avatar = Image::get()->byID($this->owner->AvatarID); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |             if (!$avatar) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |                 return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             $resizedAvatar = $avatar->SetWidth(80); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |             if (!$resizedAvatar) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |                 return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |             return $resizedAvatar->URL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         //If Gravatar is enabled, allow the selection of the type of default Gravatar. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |         if ($holder = ForumHolder::get()->filter('AllowGravatars', 1)->first()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |             // If the GravatarType is one of the special types, then set it otherwise use the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |             //default image from above forummember_holder.gif | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |             if ($holder->GravatarType) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |                 $default = $holder->GravatarType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |                 // we need to get the absolute path for the default forum image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |                 return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |             // ok. no image but can we find a gravatar. Will return the default image as defined above if not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |             return "http://www.gravatar.com/avatar/".md5($this->owner->Email)."?default=".urlencode($default)."&size=80"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         return $default; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 395 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 397 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 398 |  |  |      * Conditionally includes admin email address (hence we can't simply generate this | 
            
                                                                        
                            
            
                                    
            
            
                | 399 |  |  |      * message in templates). We don't need to spam protect the email address as | 
            
                                                                        
                            
            
                                    
            
            
                | 400 |  |  |      * the note only shows to logged-in users. | 
            
                                                                        
                            
            
                                    
            
            
                | 401 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 402 |  |  |      * @return String | 
            
                                                                        
                            
            
                                    
            
            
                | 403 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |     public function ForumSuspensionMessage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |         $msg = _t('ForumRole.SUSPENSIONNOTE', 'This forum account has been suspended.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |         $adminEmail = Config::inst()->get('Email', 'admin_email'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |         if ($adminEmail) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |             $msg .= ' ' . sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |                 _t('ForumRole.SUSPENSIONEMAILNOTE', 'Please contact %s to resolve this issue.'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |                 $adminEmail | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |         return $msg; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 416 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 417 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |  * ForumRole_Validator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  * This class is used to validate the new fields added by the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  * {@link ForumRole} decorator in the CMS backend. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | class ForumRole_Validator extends Extension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |      * Client-side validation code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |      * @param string $js The javascript validation code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |      * @return string Returns the needed javascript code for client-side | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |      *                validation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |     public function updateJavascript(&$js, &$form) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |         $formID = $form->FormName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |         $passwordFieldName = $form->dataFieldByName('Password')->id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |         $passwordConfirmField = $form->dataFieldByName('ConfirmPassword'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |         if (!$passwordConfirmField) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |         $passwordConfirmFieldName = $passwordConfirmField->id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         $passwordcheck = <<<JS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | Behaviour.register({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 	"#$formID": { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 		validatePasswordConfirmation: function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 			var passEl = _CURRENT_FORM.elements['Password']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 			var confEl = _CURRENT_FORM.elements['ConfirmPassword']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 			if(passEl.value == confEl.value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 			  clearErrorMessage(confEl.parentNode); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 				validationError(confEl, "Passwords don't match.", "error"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 		}, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 		initialize: function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 			var passEl = $('$passwordFieldName'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 			var confEl = $('$passwordConfirmFieldName'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 			confEl.value = passEl.value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | JS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |         Requirements::customScript( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |             $passwordcheck, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |             'func_validatePasswordConfirmation' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |         $js .= "\$('$formID').validatePasswordConfirmation();"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |         return $js; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 482 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 483 |  |  |  | 
            
                        
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.