public function erase(User $user) { if ($user->isModerator() || $user->isAdmin()) { ModoAction::create(array('id' => ModoAction::generateId(6), 'user_id' => $user->id, 'type' => 'delete_comment', 'target' => $this->id, 'timestamp' => Utils::tps())); } ChannelAction::table()->delete(array("type" => "comment", "complementary_id" => $this->id)); $this->delete(); }
public static function generateId($length) { $idExists = true; while ($idExists) { $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $id = ''; for ($i = 0; $i < $length - 2; $i++) { $id .= $chars[rand(0, strlen($chars) - 1)]; } $id = 'a_' . $id; $idExists = ModoAction::exists(array('id' => $id)); } return $id; }
public function erase($userId) { $this->delete(); ChannelAction::table()->delete(array("target" => $this->id)); //TODO: Delete file if (Session::get()->isModerator() || Session::get()->isAdmin()) { ModoAction::create(array('id' => ModoAction::generateId(6), 'user_id' => $userId, 'type' => 'delete', 'target' => $this->id, 'timestamp' => Utils::tps())); } }