public static function DeleteComment($id) { try { $safeId = ensureInt($id); } catch (Exception $e) { throw new Exception('删除评论时出错:' . $e->getMessage()); return null; } $commentInfo = self::GetCommentInfo($id); $cacheKey = 'postcomment_' . $commentPost['comment_post`']; $cache = getCache($cacheKey); if ($commentInfo && $cache) { while (list($key, $value) = each($cache)) { if ($value['comment_id'] == $safeId) { unset($cache[$key]); break; } } setCache($cacheKey, $cache); } $cacheKey = 'commentinfo_' . $safeId; setCache($cacheKey, null); $sql = "delete from wa_comment where comment_id = {$safeId} limit 1"; $ret = runSql($sql); if (!$ret) { throw new Exception('删除评论时出错。'); return null; } return $ret; }
public static function DeleteMsg($id, $user) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除消息时出错:' . $e->getMessage()); return false; } $msgInfo = self::GetMsgInfo($safeId); if (!$msgInfo) { return false; } if ($msgInfo['msg_sender'] == $user) { $me = 'sender'; $opposite = 'receiver'; } else { if ($msgInfo['msg_receiver'] == $user) { $me = 'receiver'; $opposite = 'sender'; } else { throw new Exception('非消息相关用户。'); return false; } } self::SetMsgRead($msgInfo['msg_id']); $cacheKey = "usermsg_"; $cacheKey .= $msgInfo['msg_' . $me] . '_' . $msgInfo['msg_' . $opposite]; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['msg_id'] = $safeId) { unset($cache[$key]); break; } } setCache($cacheKey, $cache); } $cacheKey = 'msginfo_' . $safeId; if ($msgInfo[$opposite . '_deleted']) { setCache($cacheKey, null); $sql = "delete from wa_msg where `msg_id` = {$safeId} limit 1;"; $ret = runSql($sql); } else { $cache = getCache($cacheKey); if ($cache) { $cache[$me . '_deleted'] = true; setCache($cacheKey, $cache); } $sql = "update wa_msg set `{$me}_deleted` = 1 where `msg_id` = {$safeId} limit 1"; $ret = runSql($sql); } return $ret; }
public static function DeleteWall($id) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除墙时出错:' . $e->getMessage()); return false; } $wallInfo = self::GetWallInfo($safeId); if (!$wallInfo) { throw new Exception('删除墙时出错。'); return false; } $cacheKey = 'creatorwall_' . $wallInfo['wall_creator']; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['wall_id'] == $safeId) { unset($cache[$key]); setCache($cacheKey, $cache); break; } } } $cacheKey = 'accesswall_' . $wallInfo['wall_access']; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['wall_id'] == $safeId) { unset($cache[$key]); setCache($cacheKey, $cache); break; } } } $cacheKey = 'typewall_' . $wallInfo['wall_type']; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['wall_id'] == $safeId) { unset($cache[$key]); setCache($cacheKey, $cache); break; } } } $users = self::FindUserIdsByWall($safeId); if ($users) { while (list($key, $value) = each($users)) { $cacheKey = 'userwall_' . $value['user_id']; $cache = getCache($cacheKey); if ($cache) { while (list($userKey, $userValue) = each($cache)) { if ($userValue['wall_id'] == $safeId) { unset($cache[$userKey]); setCache($cacheKey, $cache); break; } } } } } $cacheKey = 'walluser_' . $safeId; setCache($cacheKey, null); $cacheKey = 'wallinfo_' . $safeId; setCache($cacheKey, null); $wallSql = "delete from wa_wall where `wall_id` = {$safeId} limit 1;"; $wallUserSql = "delete from wa_walluser where `wall_id` = {$safeId};"; if (runSql($wallSql) && runSql($wallUserSql)) { return true; } else { throw new Exception('删除墙时出错。'); } }
public static function DeletePost($id) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除墙贴时出错:' . $e->getMessage()); return false; } $postInfo = self::GetPostInfo($safeId); $cacheKey = 'wallpost_' . $postInfo['post_wall']; $cache = getCache($cacheKey); if ($postInfo && $cache) { while (list($key, $value) = each($cache)) { if ($value['post_id'] = $safeId) { unset($cache[$key]); break; } } setCache($cacheKey, $cache); } $cacheKey = 'postinfo_' . $safeId; setCache($cacheKey, null); $sql = "delete from wa_post where `post_id` = {$safeId} limit 1"; $ret = runSql($sql); if (!$ret) { throw new Exception('删除墙贴时出错。'); return null; } return $ret; }
public static function DeleteUser($id) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除用户时出错。'); return null; } $cacheInfoKey = 'userinfo_' . $safeId; $cacheDataKey = 'userdata_' . $safeId; $cacheProfileKey = 'userprofile_' . $safeId; setCache($cacheInfoKey, null); setCache($cacheDataKey, null); setCache($cacheProfileKey, null); $sqlInfo = "delete from wa_user where user_id= {$safeId} limit 1;"; $sqlData = "delete from wa_userdata where user_id= {$safeId} limit 1;"; $sqlProfile = "delete from wa_userprofile where user_id= {$safeId} limit 1;"; $ret = runSql($sqlInfo) & runSql($sqlData) & runSql($sqlProfile); $userCache = getCache('users'); if ($userCache) { while (list($key, $value) = each($userCache)) { if ($value['user_id'] == $safeId) { unset($userCache[$key]); break; } } setCache('users', $userCache); } return $ret; }