Exemple #1
0
    def handler(self, context):
        import HaloRadio.WallListMaker as WallListMaker
        import HaloRadio.Wall as Wall
        import HaloRadio.Exception as HaloException

        u = User.User(self.session.userid)
        #if u.GetPostAccess():
        context.addGlobal("canpost", u.GetPostAccess())

        wlm = WallListMaker.WallListMaker()
        wlm.GetRecent(75)
        walls = []
        for wallid in wlm.list:
            wall = Wall.Wall(wallid)
            line = wall.line
            user = wall.GetUser()
            entity = {}
            if line[0:4] == "/me ":
                entity['line'] = "%s %s" % (user.GetDisplayName(), line[4:])
                entity['username'] = ""
            else:
                entity['line'] = line
                entity['username'] = user.GetDisplayName()
            entity['userlink'] = "%s?action=userInfo&id=%s" % (
                self.config['general.cgi_url'], user.id)
            entity['date'] = wall.date
            walls.append(entity)
        context.addGlobal("walllist", walls)

        context.addGlobal("formaction", self.config['general.cgi_url'])
Exemple #2
0
	def handler(self, context):
		import HaloRadio.User as User
		import HaloRadio.UserListMaker as UserListMaker

                if self.form.has_key("days"):
                        days = int(self.form['days'].value)
                else:
                        days = 7
		context.addGlobal ("days", days)

		ulm = UserListMaker.UserListMaker()
		ulm.GetAll()
		users = []
		for userid in ulm.list:
			user = User.User(userid)
			entity = {}
			entity['username'] = user.GetDisplayName()
			users.append(entity)

		fields = []
		for field in ['path','artist','album','title']:
			entity = {}
			entity['fieldname'] = field
			fields.append(entity)

		context.addGlobal ("fieldlist", fields)
		context.addGlobal ("userlist", users)
		context.addGlobal ("formaction", self.config['general.cgi_url'])
Exemple #3
0
    def handler(self, context):
        import HaloRadio.Util as Util
        import HaloRadio.Kill as Kill
        import HaloRadio.User as User
        import HaloRadio.PlayHistListMaker as PlayHistListMaker

        songid = 0

        if self.form.has_key("songid"):
            songid = int(self.form['songid'].value)

        cur_song_id = int(songid)
        u = User.User(self.session.userid)
        if songid == 0:
            if self.do_authorize(u.rights, "a"):
                k = Kill.Kill(0, cur_song_id, self.session.userid)
        elif not self.do_authorize(
                u.rights,
                "GU") or self.config['general.guest_has_kill'] == "1":
            phlm = PlayHistListMaker.PlayHistListMaker()
            phlm.GetRecentPlays(1)
            ph = phlm.GetPlayHist(0)
            if ph.requestby == 0:
                k = Kill.Kill(0, cur_song_id, self.session.userid)
            elif ph.requestby == u.id or self.do_authorize(u.rights, "am"):
                k = Kill.Kill(0, cur_song_id, self.session.userid)

        request_url = "%s?action=CurrentInfo" % (
            self.config['general.cgi_url'])

        context.addGlobal("refresh", "2;URL=%s" % (request_url))
        context.addGlobal("requesturl", request_url)
Exemple #4
0
    def handler(self, context):
        if self.form.has_key("id"):
            songid = self.form['id'].value
        else:
            raise "songInfo without an id, duh!"
        s = Song.Song(songid)
        context.addGlobal("sngname", s.GetDisplayName())
        context.addGlobal("path", s.path)
        context.addGlobal("id3artist", s.artist)
        context.addGlobal("id3album", s.album)
        context.addGlobal("id3track", s.track)
        context.addGlobal("id3title", s.GetDisplayName())
        context.addGlobal("id3genre", s.genre)
        context.addGlobal("id3year", s.year)
        context.addGlobal("id3comment", s.comment)
        context.addGlobal("mime", s.mime)
        context.addGlobal("sample", s.samplerate)
        context.addGlobal("length", s.GetDisplayLength())
        context.addGlobal("requests", s.requests)
        context.addGlobal("plays", s.plays)
        context.addGlobal("kills", s.kills)
        context.addGlobal(
            "requesturl", "%s?action=request&songids=%s" %
            (self.config['general.cgi_url'], s.id))
        context.addGlobal(
            "downloadurl",
            "%s/%s" % (self.config['general.download_url'], s.path))

        import HaloRadio.UserSongStatsListMaker as UserSongStatsListMaker
        import HaloRadio.UserSongStats as UserSongStats
        import HaloRadio.User as User

        usslm = UserSongStatsListMaker.UserSongStatsListMaker()
        usslm.GetBySong(s.id)
        killedby = []
        requestedby = []
        for ussid in usslm.list:
            uss = UserSongStats.UserSongStats(ussid)
            try:
                user = User.User(uss.userid)
                username = user.GetDisplayName()
            except:
                username = "******"

            if uss.kills > 0:
                kentity = {}
                kentity['name'] = username
                kentity['num'] = uss.kills
                killedby.append(kentity)
            if uss.requests > 0:
                rentity = {}
                rentity['name'] = username
                rentity['num'] = uss.requests
                requestedby.append(rentity)
        context.addGlobal("killedby", killedby)
        context.addGlobal("requestedby", requestedby)
Exemple #5
0
    def handler(self, context):
        import HaloRadio.User as User
        # do access checks here :

        u = User.User(1)
        self.session.SetUser(u)

        refresh_url = "%s?action=Welcome" % (self.config['general.cgi_url'])

        context.addGlobal("refresh", "0;URL=%s" % (refresh_url))
        context.addGlobal("refreshurl", refresh_url)
Exemple #6
0
    def handler(self, context):
        import HaloRadio.Wall as Wall
        if self.form.has_key("line"):
            line = self.form['line'].value
        u = User.User(self.session.userid)
        if not u.GetPostAccess():
            self.do_error("You do not have access to post to the wall.")

        w = Wall.Wall(0, self.session.userid, line)

        refresh_url = "%s?action=Wall" % (self.config['general.cgi_url'])

        context.addGlobal("refresh", "1;URL=%s" % (refresh_url))
        context.addGlobal("refreshurl", refresh_url)
Exemple #7
0
    def Authenticate(self, user, password):
        import HaloRadio.User as User

        authenticated = 1
        try:
            m = User.User(-1, user, password)
        except:
            authenticated = 0

        if authenticated:
            self.do_my_do(
                """UPDATE %s SET userid=%d,active_time=NOW() WHERE id="%s";"""
                % (self.tablename, m.id, self.id))
            self.userid = m.id
Exemple #8
0
def SwapRequests( id1, id2):
   import HaloRadio.Request as Request
   try:
      r1 = Request.Request( id1)
      r2 = Request.Request( id2)
   except:
      return

   if self.userid == 1 and ( r1.requestby != 1 or r2.requestby !=1 ):

      return
   if self.userid > 1 and ( r1.requestby > 1 or r2.requestby > 1):
      import HaloRadio.User as User
      u = User.User(self.userid)
      if not u.admin and ( r1.requestby != self.userid or r2.requestby != self.userid):
         return
         u1 = User.User( r1.requestby )
         u2 = User.User( r2.requestby )
         
   saved_songid = r1.songid
   saved_reqby = r1.requestby

   r1.Update(r2.songid, r2.requestby)
   r2.Update(saved_songid, saved_reqby)
Exemple #9
0
	def handler(self, context):

		context.addGlobal ("action", "playHistory")
                if self.form.has_key("numlines"):
                        numlines = int(self.form['numlines'].value)
                else:
                        numlines = 25

		context.addGlobal ("numlines", numlines )

                if self.form.has_key("i"):
                        i = int(self.form['i'].value)
                else:
                        i = 0
		i = i+1

		histlen=numlines
		phlm = PlayHistListMaker.PlayHistListMaker()
		phlm.GetRecentPlays(histlen)

		prevsngs = []


		for i in range(0,histlen):
			try:
				ph = phlm.GetPlayHist(i)
			except:
				continue
			if ph.requestby !=0:
				u = User.User(ph.requestby)
				curreqby = u.GetDisplayName()
			else:
				curreqby = ""

			try:
				cur_song = ph.GetSong()
			except Exception.SongNotFound:
				continue
			listitem = {}
			listitem['sngurl']="%s?action=songInfo&id=%d"%(
				self.config['general.cgi_url'], cur_song.id )
			listitem['sng']=cur_song.GetDisplayName()
			listitem['reqby']=curreqby
			listitem['date']=ph.date
			prevsngs.append(listitem)
		context.addGlobal ("prevsngs", prevsngs)
Exemple #10
0
    def handler(self, context):
        import HaloRadio.Util as Util

        context.addGlobal("listeners", Util.GetListeners())

        graphlist = []
        timelist = ('daily', 'weekly', 'monthly', 'yearly')
        #timelist=('daily','weekly', 'monthly')

        for time in timelist:
            entity = {}
            entity['url'] = "%s/halostat--activity-%s.png" % (
                self.config['general.root_url'], time)
            graphlist.append(entity)
        context.addGlobal("graphs", graphlist)

        # Recently Active Users
        import HaloRadio.UserListMaker as UserListMaker
        import HaloRadio.User as User
        import datetime, time
        from operator import itemgetter
        users = []
        ACTIVITY_TIMEOUT = 31536000
        ulm = UserListMaker.UserListMaker()
        ulm.GetAll()
        for user_id in ulm.list:
            u = User.User(user_id)
            if u.name == "Anonymous":
                continue
            last_seen = u.LastSeen()
            if last_seen != None:
                now = time.mktime(datetime.datetime.now().timetuple())
                if time.mktime(last_seen.timetuple()) > now - ACTIVITY_TIMEOUT:
                    entity = {}
                    entity['username'] = u.name
                    entity['userlink'] = "%s?action=userInfo&id=%s" % (
                        self.config['general.cgi_url'], u.id)
                    entity['seen_on'] = u.LastSeen()
                    users.append(entity)
        sorted_users = sorted(users, key=itemgetter('seen_on'))
        sorted_users.reverse()
        context.addGlobal("users", sorted_users)
Exemple #11
0
    def handler(self, context):
        import string
        if self.form.has_key("id"):
            userid = int(self.form['id'].value)

        import HaloRadio.User as User

        try:
            u = User.User(userid)
        except:
            self.do_error("user doesn't exist")

        if (self.do_authorize(self.user.rights, "a")
                and not self.do_authorize(u.rights, "a")):
            u.ChangeAccess()
        elif (self.configdb.GetConfigItem('moderator_enable_access') == "1"
              and self.do_authorize(self.user.rights, "m")
              and not self.do_authorize(u.rights, "a")
              and not self.do_authorize(u.rights, "m")):
            u.ChangeAccess()

        request_url = "%s?action=UserList" % (self.config['general.cgi_url'])
        context.addGlobal("refresh", "0;URL=%s" % (request_url))
        context.addGlobal("requesturl", request_url)
Exemple #12
0
 def GetUser(self):
     import HaloRadio.User as User
     user = User.User(self.userid)
     return user
Exemple #13
0
    def handler(self, context):

        histlen = 6
        phlm = PlayHistListMaker.PlayHistListMaker()
        phlm.GetRecentPlays(histlen)
        try:
            ph = phlm.GetPlayHist(0)
        except:
            print "No Info to Display, run the daemon.\n"
            import sys
            sys.exit(0)
        currelay = int(self.configdb.GetConfigItem("current_relay"))
        cursong = int(self.configdb.GetConfigItem("current_song"))
        haverelay = 0
        havesong = 0
        if currelay != 0 and cursong == 0:
            haverelay = 1
            import HaloRadio.Relay as Relay
            r = Relay.Relay(currelay)
            context.addGlobal("currelay", r.GetDisplayName())
            context.addGlobal(
                "killurl",
                "%s?action=kill&songid=0" % (self.config['general.cgi_url']))
            refresh_delay = 150
        else:
            havesong = 1
            cur_song = ph.GetSong()

            if ph.requestby != 0:
                u = User.User(ph.requestby)
                curreqby = u.GetDisplayName()
            else:
                curreqby = ""

            context.addGlobal(
                "cursngurl", "%s?action=songInfo&id=%d" %
                (self.config['general.cgi_url'], cur_song.id))
            context.addGlobal("cursng", cur_song.GetDisplayName())
            context.addGlobal(
                "killurl", "%s?action=kill&songid=%d" %
                (self.config['general.cgi_url'], cur_song.id))
            context.addGlobal("curreqby", curreqby)
            context.addGlobal("curlength", cur_song.GetDisplayLength())
            curprcnt = int(self.configdb.GetConfigItem("current_percent"))

            context.addGlobal("curprcnt", curprcnt)
        context.addGlobal("haverelay", haverelay)
        context.addGlobal("havesong", havesong)
        prevsngs = []

        for i in range(1, histlen):
            try:
                ph = phlm.GetPlayHist(i)
            except:
                continue
            if ph.requestby != 0:
                u = User.User(ph.requestby)
                curreqby = u.GetDisplayName()
            else:
                curreqby = ""

            try:
                cur_song = ph.GetSong()
            except Exception.SongNotFound:
                continue
            listitem = {}
            listitem['sngurl'] = "%s?action=songInfo&id=%d" % (
                self.config['general.cgi_url'], cur_song.id)
            listitem['sng'] = cur_song.GetDisplayName()
            listitem['reqby'] = curreqby
            prevsngs.append(listitem)
        context.addGlobal("prevsngs", prevsngs)
        context.addGlobal(
            "playhisturl",
            "%s?action=playHistory" % (self.config['general.cgi_url']))
        havenextsng = 0
        rlm = RequestListMaker.RequestListMaker()
        rlm.Get()
        if len(rlm.list) != 0:
            havenextsng = 1
            r = rlm.GetNextRequest()
            if r != None:
                s = r.GetSong()
                u = User.User(r.requestby)
                context.addGlobal("nextsng", s.GetDisplayName())
                context.addGlobal(
                    "nextsngurl", "%s?action=songInfo&id=%d" %
                    (self.config['general.cgi_url'], s.id))
                context.addGlobal("nextsngreqby", u.GetDisplayName())
                context.addGlobal("nextlength", s.GetDisplayLength())
            else:
                havenextsng = 0
        context.addGlobal("havenextsng", havenextsng)

        # Active Users
        active_users = []
        slm = SessionListMaker.SessionListMaker()
        slm.GetActive()
        for i in range(0, len(slm.list)):
            user = {}
            s = slm.GetSession(i)
            u = s.GetUser()
            user['name'] = u.GetDisplayName()
            if u.id == 1 or self.do_authorize(self.user.rights,
                                              "am"):  # Annymous Guest, eh ?
                user['host'] = s.host
            user['last_active'] = s.GetActivity()
            active_users.append(user)
        context.addGlobal("active_users", active_users)
Exemple #14
0
    def handler(self, context):
        import HaloRadio.UserSongStatsListMaker as UserSongStatsListMaker
        import HaloRadio.UserSongStats as UserSongStats
        import HaloRadio.Song as Song
        import HaloRadio.User as User
        import HaloRadio.Exception as Exception

        # Username
        if self.form.has_key("id"):
            userid = int(self.form['id'].value)
        #if ( userid != self.user.id and
        #	not self.do_authorize(self.user.rights,"am")
        #):
        #	self.do_error("Unautherized")
        else:
            userid = self.user.id

        if self.form.has_key("numtop"):
            numtop = int(self.form['numtop'].value)
        else:
            numtop = 25
        if self.form.has_key("numbottom"):
            numbottom = int(self.form['numbottom'].value)
        else:
            numbottom = 25
        user = User.User(userid)
        context.addGlobal("numtop", numtop)
        context.addGlobal("numbottom", numbottom)
        context.addGlobal("id", userid)
        context.addGlobal("action", "userInfo")
        context.addGlobal("username", user.GetDisplayName())
        context.addGlobal("rights", user.GetDisplayRights())

        context.addGlobal("createdate", user.create_time)
        seen = user.LastSeen()
        if not seen:
            seen = user.create_time
        context.addGlobal("seendate", seen)

        # Return my top 100
        slm = UserSongStatsListMaker.UserSongStatsListMaker()
        slm.GetTopRank(user.id, numtop)
        songs = []
        for (songid, requests, kills) in slm.list:
            try:
                song = Song.Song(songid)
            except Exception.SongNotFound:
                continue
            entity = {}
            entity['songlink'] = "%s?action=songInfo&id=%s" % (
                self.config['general.cgi_url'], song.id)
            entity['songname'] = song.GetDisplayName()
            entity['requests'] = requests
            entity['kills'] = kills
            songs.append(entity)
        context.addGlobal("songlist", songs)

        slm.GetBottomRank(user.id, numbottom)
        songs2 = []
        for (songid, kills, requests) in slm.list:
            try:
                song = Song.Song(songid)
            except Exception.SongNotFound:
                continue
            entity = {}
            entity['songlink'] = "%s?action=songInfo&id=%s" % (
                self.config['general.cgi_url'], song.id)
            entity['songname'] = song.GetDisplayName()
            entity['requests'] = requests
            entity['kills'] = kills
            songs2.append(entity)
        context.addGlobal("bsonglist", songs2)
Exemple #15
0
	def GetUser ( self, index ):
		import HaloRadio.User as User
		user = User.User(self.list[index])
		return user
Exemple #16
0
	def handler(self, context):
		import HaloRadio.UserSongStatsListMaker as UserSongStatsListMaker
		import HaloRadio.UserSongStats as UserSongStats
		import HaloRadio.Song as Song
		import HaloRadio.User as User
		import HaloRadio.Exception as Exception

		# Username
		if self.form.has_key("id"):
                        userid = int(self.form['id'].value)
		else:
			userid = self.user.id

		user = User.User(userid)
		if (self.do_authorize(self.user.rights, "a")):
			is_user=0
			canmod_user=1
			ro_user=0
			canmod_rights=1
			ro_rights=0
			canmod_email=1
			ro_email=0
			canmod_passwd=1
			ro_passwd=0
		elif (self.do_authorize(self.user.rights, "m")):
			is_user=0
			canmod_user=0
			ro_user=1
			canmod_rights=0
			ro_rights=1
			canmod_email=1
			ro_email=0
			canmod_passwd=1
			ro_passwd=0
		else:
			is_user=1
			canmod_user=0
			ro_user=1
			canmod_rights=0
			ro_rights=1
			canmod_email=0
			ro_email=1
			canmod_passwd=1
			ro_passwd=0

		context.addGlobal ("is_user", is_user)
		context.addGlobal ("canmod_user", canmod_user )
		context.addGlobal ("ro_user", ro_user)
		context.addGlobal ("canmod_rights", canmod_rights)
		context.addGlobal ("ro_rights", ro_rights)
		context.addGlobal ("canmod_email", canmod_email)
		context.addGlobal ("ro_email", ro_email)
		context.addGlobal ("canmod_passwd", canmod_passwd)
		context.addGlobal ("ro_passwd", ro_passwd)
		context.addGlobal ("userid", userid )
		context.addGlobal ("username", user.name )
		context.addGlobal ("email", user.email )
		context.addGlobal ("rights", user.rights )
		context.addGlobal ("createdate", user.create_time )
		slm = StyleListMaker.StyleListMaker()
		slm.GetAll()
		styles = []
		for styleid in slm.list:
			style = Style.Style(styleid)
			entity = {}
			entity['style'] = style.GetName()
			entity['id'] = style.GetId()
			styles.append(entity)
		context.addGlobal ("styles", styles )
Exemple #17
0
    def handler(self, context):
        import string
        if self.form.has_key("user"):
            user = self.form['user'].value
        if self.form.has_key("email"):
            email = self.form['email'].value

        if len(user) < 3 or len(user) > 12:
            self.do_error(
                "username must be greater than 2 and less than 13 characters.")
        if string.find(email, "@") == -1:
            self.do_error(
                "gimme a real email. i need it to verify your existence. :-P")
        if len(email) < 3:
            self.do_error(
                "gimme a real email. i need it to verify your existence. :-P")

        import HaloRadio.User as User

        try:
            u = User.User(0, user, 'blahblahblah', email)
        except:
            self.do_error("user exists.")

        hash = u.GetNewHash()

        import sendmail

        emailstr = """From: %(from)s
To: %(to)s
Bcc: %(bcc)s
Subject: %(site_name)s email verification

%(to)s - 

  your email address was used to request an account for halo_radio. you've
chosen the name of %(user)s, which is in bad taste, but we'll let it slide
this time.

 click here : 
%(siteurl)s/?action=verify&user=%(user)s&hash=%(code)s


 or, your authorization code is:
%(code)s
 ( to manually enter on the page )


---- end transmission.
""" % {
            "from": "halo_radio@%s" % (self.config["general.hostname"]),
            "to": email,
            "site_name": self.config["general.site_name"],
            "bcc": self.config["general.admin_email"],
            "code": hash,
            "user": u.name,
            "siteurl": self.config["general.cgi_url"]
        }

        sendmail.sendmail("halo_radio@%s" % (self.config["general.hostname"]),
                          [email, self.config["general.admin_email"]],
                          emailstr)

        context.addGlobal("formaction", self.config['general.cgi_url'])
        context.addGlobal("user", u.name)
Exemple #18
0
    import HaloRadio.PlaylistListMaker as PlaylistListMaker
    plm = PlaylistListMaker.PlaylistListMaker()
    plm.GetAll()
    print "system playlists :"
    for plid in plm.list:
        p = Playlist.Playlist(plid)
        print " %d: %s" % (plid, p.GetDisplayName())
    sys.exit(1)
elif list_users != 0:
    import HaloRadio.User as User
    import HaloRadio.UserListMaker as UserListMaker
    ulm = UserListMaker.UserListMaker()
    ulm.GetAll()
    print "system users :"
    for ulid in ulm.list:
        u = User.User(ulid)
        print " %d: %s" % (ulid, u.GetDisplayName())
    sys.exit(1)

elif playlist != 0:
    import HaloRadio.Playlist as Playlist
    import HaloRadio.Song as Song
    cur_playlist = Playlist.Playlist(playlist)
    cur_playlist.GetList()
    for i in cur_playlist.list:
        s = Song.Song(i)
        print "%s/%s" % (HaloRadio.conf['path.root'], s.path)

elif user != 0:

    import HaloRadio.UserListMaker as UserListMaker
Exemple #19
0
 def GetUser(self):
     import HaloRadio.User as User
     user = User.User(self.killby)
     return user
Exemple #20
0
    def handler(self, context):
        import string
        username = None
        rights = None
        email = None
        oldpasswd = None
        newpasswd = None
        newpasswd2 = None
        style = None
        if self.form.has_key("userid"):
            userid = int(self.form['userid'].value)
        if self.form.has_key("username"):
            username = self.form['username'].value
        if self.form.has_key("rights"):
            rights = self.form['rights'].value
        if self.form.has_key("email"):
            email = self.form['email'].value
        if self.form.has_key("oldpasswd"):
            oldpasswd = self.form['oldpasswd'].value
        if self.form.has_key("newpasswd"):
            newpasswd = self.form['newpasswd'].value
        if self.form.has_key("newpasswd2"):
            newpasswd2 = self.form['newpasswd2'].value
        if self.form.has_key("style"):
            style = self.form['style'].value
            style = int(style)

        import HaloRadio.User as User

        try:
            u = User.User(userid)
        except:
            self.do_error("user doesn't exist")

        if (self.do_authorize(self.user.rights, "a")):
            if len(rights) < 1:
                self.do_error("you are required to give them something")
            if newpasswd != newpasswd2:
                self.do_error("new passwords do not match.")
            u.SetPassword(newpasswd)
            u.UpdateRights(rights)
            u.UpdateName(username)
            u.UpdateEmail(email)
            u.UpdateStyle(style)
        elif (self.do_authorize(self.user.rights, "m")
              and not self.do_authorize(u.rights, "a")
              and not self.do_authorize(rights, "a")):
            if len(rights) < 1:
                self.do_error("you are required to give them something")
            if newpasswd != newpasswd2:
                self.do_error("new passwords do not match.")
            u.SetPassword(newpasswd)
            u.UpdateRights(rights)
            u.UpdateName(username)
            u.UpdateEmail(email)
            u.UpdateStyle(style)
        if (self.user.id == userid):
            u.UpdateStyle(style)
            # Verrify old passwd here (TODO)
            if newpasswd != newpasswd2:
                self.do_error("new passwords do not match.")
            u.SetPassword(newpasswd)

        request_url = "%s?action=Preferences&id=%d" % (
            self.config['general.cgi_url'], userid)
        context.addGlobal("refresh", "0;URL=%s" % (request_url))
        context.addGlobal("requesturl", request_url)
Exemple #21
0
def update_dbversion():
    cfg = Config.Config()

    dbversion = int(cfg.GetConfigItem("dbversion"))

    if dbversion < 1:
        c = HaloRadio.db.cursor()
        c._do_query("""
ALTER TABLE `users` ADD COLUMN `style` int(10) DEFAULT 1;
			""")
        c._do_query("""
CREATE TABLE `styles` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `style` tinytext NOT NULL,
  PRIMARY KEY (`id`)
) TYPE=MyISAM;
			""")
        c._do_query("""

INSERT INTO `styles` VALUES (1,'style.css');
			""")
        c._do_query("""
INSERT INTO `styles` VALUES (2,'no_style.css');
			""")
        c._do_query("""
INSERT INTO `styles` VALUES (3,'style_green.css');
			""")
        c._do_query("""
INSERT INTO `styles` VALUES (4,'style_pink.css');
			""")

        cfg.SetConfigItem("dbversion", "1")
    if dbversion < 2:
        c = HaloRadio.db.cursor()
        c._do_query("""
ALTER TABLE `users` ADD COLUMN `post` tinyint(1) DEFAULT 1;
			""")
        cfg.SetConfigItem("dbversion", "2")
    if dbversion < 3:
        c = HaloRadio.db.cursor()
        c._do_query("""
ALTER TABLE `users` ADD COLUMN `enable` tinyint(1) DEFAULT 1;
			""")
        cfg.SetConfigItem("dbversion", "3")
    if dbversion < 4:
        cfg.NewConfigItem("moderator_enable_access", "1")
        cfg.NewConfigItem("moderator_wall_enable_access", "1")
        cfg.SetConfigItem("dbversion", "4")
    if dbversion < 5:
        c = HaloRadio.db.cursor()
        c._do_query("""
ALTER TABLE users ADD COLUMN active_time datetime;
			""")
        import HaloRadio.UserListMaker as ULM
        import HaloRadio.User as U
        ulm = ULM.UserListMaker()
        ulm.GetAll()
        for userid in ulm.list:
            u = U.User(userid)
            date = u.OldLastSeen()
            u.UpdateActivity(date)
        cfg.SetConfigItem("dbversion", "5")
    if dbversion < 6:
        c = HaloRadio.db.cursor()
        c._do_query("""
alter table songs change column mpeg_samplerate samplerate float unsigned default 0;
			""")
        c._do_query("""
alter table songs change column mpeg_length length mediumint(9) default 0;
			""")
        for column_name in ("mpeg_emphasis", "mpeg_mode", "mpeg_bitrate",
                            "mpeg_version"):
            c._do_query("""
alter table songs drop column %s;
			""" % (column_name))
        c._do_query("""
alter table songs add column mime tinytext;
			""")
        cfg.SetConfigItem("dbversion", "6")
    return None
Exemple #22
0
	def GetUser( self ):
		import HaloRadio.User as User
		user = User.User(self.requestby)
		return user
Exemple #23
0
    def handler(self, context):
        import HaloRadio.UserListMaker as UserListMaker
        import HaloRadio.User as User

        ulm = UserListMaker.UserListMaker()
        ulm.GetAll()
        users = []
        is_admin = 0
        enable = 0
        wall_enable = 0
        if (self.do_authorize(self.user.rights, "a")):
            is_admin = 1
            enable = 1
            wall_enable = 1
        elif self.do_authorize(self.user.rights, "m"):
            is_admin = 0
            enable = 0
            wall_enable = 0
            if self.configdb.GetConfigItem('moderator_enable_access') == "1":
                enable = 1
            if self.configdb.GetConfigItem(
                    'moderator_wall_enable_access') == "1":
                wall_enable = 1
        context.addGlobal("is_admin", is_admin)
        context.addGlobal("enable", enable)
        context.addGlobal("wall_enable", wall_enable)
        for userid in ulm.list:
            user = User.User(userid)
            entity = {}
            entity['userid'] = user.id
            entity['userlink'] = "%s?action=userInfo&id=%s" % (
                self.config['general.cgi_url'], user.id)
            entity['username'] = user.GetDisplayName()
            entity['editlink'] = "%s?action=Preferences&id=%s" % (
                self.config['general.cgi_url'], user.id)
            entity[
                'wallenablelink'] = "%s?action=changeUserWallPostAccess&id=%s" % (
                    self.config['general.cgi_url'], user.id)
            entity['enablelink'] = "%s?action=changeUserAccess&id=%s" % (
                self.config['general.cgi_url'], user.id)

            entity['email'] = "<hidden>"
            entity['mailto'] = ""
            if is_admin:
                entity['email'] = user.email
                entity['mailto'] = "mailto:%s" % (user.email)
            if enable:
                if user.GetAccess():
                    entity['enabled'] = "enabled"
                    entity['class'] = "resultsrow"
                else:
                    entity['enabled'] = "disabled"
                    entity['class'] = "resultsrowdark"
            if wall_enable:
                if user.GetPostAccess():
                    entity['wallenabled'] = "enabled"
                    entity['wallclass'] = "resultsrow"
                else:
                    entity['wallenabled'] = "disabled"
                    entity['wallclass'] = "resultsrowdark"

            entity['rights'] = user.rights
            entity['requests'] = user.requests
            entity['kills'] = user.kills

            users.append(entity)
        context.addGlobal("userlist", users)