Module: deluge
Branch: multiuser
Commit: 99145b67317f26527ab21e14ae623b2a33281313

Author: Pedro Algarvio <[email protected]>
Date:   Sun Dec 12 18:19:51 2010 +0000

Respect the torrents ownership and unless the logged in user is an admin, only 
return his own torrents plus all other public torrents.

---

 deluge/core/torrentmanager.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index 4a2bfaf..2c4fa73 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -51,6 +51,7 @@ from deluge.event import *
 from deluge.error import *
 import deluge.component as component
 from deluge.configmanager import ConfigManager, get_config_dir
+from deluge.core.authmanager import AUTH_LEVEL_ADMIN
 from deluge.core.torrent import Torrent
 from deluge.core.torrent import TorrentOptions
 import deluge.core.oldstateupgrader
@@ -278,7 +279,16 @@ class TorrentManager(component.Component):
 
     def get_torrent_list(self):
         """Returns a list of torrent_ids"""
-        return self.torrents.keys()
+        torrent_ids = self.torrents.keys()
+        if component.get("RPCServer").get_session_auth_level() == 
AUTH_LEVEL_ADMIN:
+            return torrent_ids
+
+        current_user = component.get("RPCServer").get_session_user()
+        for torrent_id in torrent_ids[:]:
+            torrent_status = self[torrent_id].get_status(["owner", "public"])
+            if torrent_status["owner"] != current_user and 
torrent_status["public"] == False:
+                torrent_ids.pop(torrent_ids.index(torrent_id))
+        return torrent_ids
 
     def get_torrent_info_from_file(self, filepath):
         """Returns a torrent_info for the file specified or None"""

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to