Changeset 11992
- Timestamp:
- Jun 23, 2009, 9:18:07 PM (14 years ago)
- Location:
- OpenPNE3/trunk/lib/model/doctrine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/trunk/lib/model/doctrine/CommunityMemberTable.class.php
r11802 r11992 120 120 return array(); 121 121 } 122 123 public function getCommunityMemberCount($communityId) 124 { 125 $communityMember = $this->createQuery() 126 ->select('COUNT(*)') 127 ->where('community_id = ?', $communityId) 128 ->addWhere('position = ?', '') 129 ->fetchArray(); 130 131 return $communityMember[0]['COUNT']; 132 } 122 133 } -
OpenPNE3/trunk/lib/model/doctrine/Member.class.php
r11691 r11992 232 232 return $result; 233 233 } 234 235 public function delete(Doctrine_Connection $conn = null) 236 { 237 $memberId = $this->getId(); 238 $communityMemberTable = Doctrine::getTable('CommunityMember'); 239 $adminCommunity = $communityMemberTable->getCommunityIdsOfAdminByMemberId($this->getId()); 240 foreach ($adminCommunity as $community) 241 { 242 $communityId = $community['community_id']; 243 $memberCount = $communityMemberTable->getCommunityMemberCount($communityId); 244 if (!$memberCount) 245 { 246 $community = Doctrine::getTable('Community')->find($communityId); 247 $community->delete(); 248 continue; 249 } 250 $communityMember = $communityMemberTable->createQuery() 251 ->where('community_id = ?', $communityId) 252 ->addWhere('position = ?', '') 253 ->orderBy('random()') 254 ->limit(1) 255 ->fetchOne(); 256 $communityMember->setPosition('admin'); 257 $communityMember->save(); 258 $communityMember = $communityMemberTable->retrieveByMemberIdAndCommunityId($memberId, $communityId); 259 $communityMember->delete(); 260 } 261 return parent::delete($conn); 262 } 234 263 }
Note: See TracChangeset
for help on using the changeset viewer.