Exemple #1
0
 def send_main_frames(self, request):
   # get the game objects
   game = datagate.get_item(request.getvalue('global_rootid'))
   teams = game.search1(name='groups')
   team = Directory.get_group(game.id, request.session.user.id)
   if not team:
     raise 'You have not been added to a team in this game.'
   try: 
     chats = game.search1(name='chats') # just use first team's chat for now -- eventually we want to see what team the user is on and link to the chat parent for that team
   except IndexError:
     raise 'You cannot play a StrikeCom game without any teams.  Please add at least one team and try again.'
   chat = chats.search1(name=team.name)
   board = game.search1(name='board')
   turns = game.search1(name='turns')
   
   # send the html
   request.writeln(HTML_HEAD_NO_CLOSE)
   request.writeln('''
     </head>
     <frameset border="0" rows="45,*">
       <frame marginheight="0" marginwidth="0" scrolling="no" name="navigation" src="''' + request.cgi_href(subview='navigation') + '''">
       <frame marginheight="0" marginwidth="0" scrolling="no" name="game" src="''' + request.cgi_href(subview='game') + '''">
     </frameset>
     </html>
   ''')
Exemple #2
0
  def send_game(self, request):
    '''Shows the game window'''
    # get the game objects
    game = datagate.get_item(request.getvalue('global_rootid'))
    teams = game.search1(name='groups')
    team = Directory.get_group(game.id, request.session.user.id)
    if not team:
      raise 'You have not been added to a team in this game.'
    try: 
      chats = game.search1(name='chats') # just use first team's chat for now -- eventually we want to see what team the user is on and link to the chat parent for that team
    except IndexError:
      raise 'You cannot play a StrikeCom game without any teams.  Please add at least one team and try again.'
    chat = chats.search1(name=team.name)
    board = game.search1(name='board')
    turns = game.search1(name='turns')

    request.writeln(HTML_HEAD)
    request.writeln('''
      <frameset border="0" cols="*,200">  
        <frameset border="0" rows="*,50">
          <frame marginheight="0" marginwidth="0" name="playingboard" src="''' + request.cgi_href(global_rootid=turns.id, view='StrikeComPlayingBoard', frame=None) + '''">
          <frame scrolling="no" marginheight="0" marginwidth="0" name="legend" src="''' + request.cgi_href(view='StrikeComLegend', frame=None) + '''">
        </frameset>
        <frame scrolling="no" marginheight="0" marginwidth="0" name="chat" src="''' + request.cgi_href(global_rootid=chat.id, view='StrikeComCommenter', frame=None) + '''">
      </frameset>
    ''')    
Exemple #3
0
  def send_content(self, request):
    '''Main loop for this view'''
    # get the meetings this user is in
    if request.session.user.superuser == '1':
      #the superuser gets sent straight to the Administrator page
      #pm_meetings = Directory.get_meetings()
      #meetings = []
      self.forward_to_superuser(request)

    
    else:
      pm_meetings = []
      meetings = []
      for meeting in Directory.get_meetings():               
        if Directory.get_group(meeting.id, request.session.user.id) != None:
          if self.user_is_pm(meeting, request.session.user.id):
            pm_meetings.append(meeting)
          else:
            meetings.append(meeting)
    
      # send to the appropriate page
      if len(meetings)+len(pm_meetings) == 0: #and request.session.user.superuser != '1': #superuser is now redirected before this line
        self.no_meetings(request)
      
      elif len(meetings)+len(pm_meetings) == 1: #and request.session.user.superuser != '1': #superuser is now redirected before this line
        if len(meetings) == 1:
          self.forward_to_meeting(request, meetings[0])
        else:
          #self.forward_to_meeting(request, pm_meetings[0])
	  self.forward_to_pm(request, pm_meetings[0])
      
      else:
        self.show_meetings(request, meetings, pm_meetings)
Exemple #4
0
  def get_user_rights(self, request, activity=None):
    '''Returns the current user's rights for the given activity, or None if not found'''
    # is this the superuser?
    rights = {}
    if request.session.user.superuser == '1':
      for right in self.rights_list:
        rights[right] = 1
      return rights

    # compile them up for regular users 
    if activity == None:     
      activity = datagate.get_item(request.getvalue('global_rootid', ''))    
    if hasattr(activity, 'linkitemid'): # the group rights might be stored in a linked item
      activity = datagate.get_item(activity.linkitemid)
    meeting = datagate.get_item(request.getvalue('global_meetingid', ''))
    group = Directory.get_group(meeting.id, request.session.user.id)
    for right in self.rights_list:
      key = 'groupright_' + group.name + '_' + right
      if hasattr(activity, key) and getattr(activity, key) == '1':
        rights[right] = 1
      else:
        rights[right] = 0
    return rights