Exemplo n.º 1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    session = Session.getInstance(getActivity().getApplicationContext());
    authUser = session.getAuthUser();
    Collections.sort(authUser.getSyncs());
  }
Exemplo n.º 2
0
  @Override
  public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain)
      throws IOException, ServletException {
    chain.doFilter(arg0, arg1);

    try {
      HttpServletRequest request = (HttpServletRequest) arg0;
      String url = request.getPathInfo();
      String method = request.getMethod();

      Long schoolId = null;
      Long userId = null;

      String rsessionid = null;
      Cookie[] cookies = request.getCookies();
      if (cookies != null) {
        for (Cookie cookie : cookies) {
          if ("rsessionid".equals(cookie.getName())) {
            rsessionid = cookie.getValue();
            break;
          }
        }
      }
      if (rsessionid != null) {
        Session session = Session.getInstance(rsessionid);
        if (session != null) {
          School school = session.get("school");
          if (school != null) {
            schoolId = school.getId();
          }

          Teacher teacher = session.get("teacher");
          if (teacher != null) {
            userId = teacher.getId();
          }
          Parents parents = session.get("parents");
          if (parents != null) {
            userId = parents.getId();
          }
        }
      }

      Log log = new Log();
      log.setSchoolId(schoolId);
      log.setUserId(userId);
      log.setUrl(url);
      log.setMethod(method);
      log.setTime(new java.sql.Timestamp(System.currentTimeMillis()));

      LogService logService = ServiceFactory.getService(LogService.class);
      logService.insert(log);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 3
0
 public boolean shouldShowForum() {
   if (Session.getInstance().getClientConfig() != null
       && !Session.getInstance().getClientConfig().isFeedbackEnabled()) return false;
   return showForum;
 }
Exemplo n.º 4
0
 public int getForumId() {
   if (forumId == -1 && Session.getInstance().getClientConfig() != null)
     return Session.getInstance().getClientConfig().getDefaultForumId();
   return forumId;
 }
Exemplo n.º 5
0
 public boolean shouldShowKnowledgeBase() {
   if (Session.getInstance().getClientConfig() != null
       && !Session.getInstance().getClientConfig().isTicketSystemEnabled()) return false;
   return showKnowledgeBase;
 }
Exemplo n.º 6
0
  @Override
  public void onReceive(Context context, Intent intent) {
    Log.v(TAG, intent.toString());

    session = Session.getInstance(context);
    String action = intent.getAction();
    Bundle data = intent.getExtras();
    final NotificationManager nm =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final NotificationCompat.Builder ncb;

    if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {

      session.registerAlarms();

    } else if (action.equals(SR.CLEAN_DB_CACHE)
        || action.equals(SR.GDRIVE_SYNCNOW)
        || action.equals(SR.CHECK_TVDB_RSS)) {

      session.registerAlarms();
      WakefulIntentService.sendWakefulWork(
          context, new Intent(context, Service.class).setAction(action));

    } else if (action.equals(SN.CONNECT_FAIL)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_error);
      ncb.setContentTitle(session.getString(R.string.notif_gac_fail));
      ncb.setContentIntent(newPI(newAI(SN.CONNECT_FAIL), false));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_CONNECT_FAIL, ncb.build());

    } else if (action.equals(Commons.SN.GENERAL_FAIL)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_error);
      ncb.setContentTitle(session.getString(R.string.notif_srv_fail));
      ncb.setContentText(data.getString("what"));
      ncb.setContentIntent(newPI(newAI(SN.GENERAL_FAIL), false));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_GENERAL_FAIL, ncb.build());

    } else if (action.equals(Commons.SN.GENERAL_INFO)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_info);
      ncb.setContentTitle(session.getString(R.string.notif_srv_info));
      ncb.setContentText(data.getString("what"));
      ncb.setContentIntent(newPI(newAI(SN.GENERAL_INFO), false));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_GENERAL_INFO, ncb.build());

    } else if (action.equals(SN.MOV_WLST)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_movie);
      ncb.setContentTitle(session.getString(R.string.notif_mov_wlst));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.MOVIE_INFO).putExtra("imdb_id", data.getString("imdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.MOV_COLL)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_movie);
      ncb.setContentTitle(session.getString(R.string.notif_mov_coll));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.MOVIE_INFO).putExtra("imdb_id", data.getString("imdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.SER_WLST)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_series);
      ncb.setContentTitle(session.getString(R.string.notif_ser_wlst));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.SERIES_INFO).putExtra("tvdb_id", data.getString("tvdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.SER_COLL)) {

      EID eid = new EID(data.getString("series"), data.getInt("season"), data.getInt("episode"));
      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_series);
      ncb.setContentTitle(session.getString(R.string.notif_ser_coll));
      ncb.setContentText(
          eid.readable() + " " + data.getString("name", session.getString(R.string.unknown_title)));
      ncb.setContentIntent(
          newPI(
              newAI(MA.EPISODE_INFO)
                  .putExtra("series", eid.series)
                  .putExtra("season", eid.season)
                  .putExtra("episode", eid.episode),
              true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.SER_PREM)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_premiere);
      ncb.setContentTitle(session.getString(R.string.notif_ser_prem));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.SERIES_INFO).putExtra("tvdb_id", data.getString("tvdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      String plot = data.getString("plot");
      if (!TextUtils.isEmpty(plot))
        ncb.setStyle(new NotificationCompat.BigTextStyle().bigText(plot));
      String purl = data.getString("poster");
      if (TextUtils.isEmpty(purl)) nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
      else
        session
            .picasso()
            .load(purl)
            .placeholder(R.drawable.ic_notification_premiere)
            .into(
                new Target() {
                  @Override
                  public void onPrepareLoad(Drawable arg0) {}

                  @Override
                  public void onBitmapLoaded(Bitmap bitmap, LoadedFrom source) {
                    ncb.setLargeIcon(bitmap);
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }

                  @Override
                  public void onBitmapFailed(Drawable arg0) {
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }
                });

    } else if (action.equals(SN.SER_CANC)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_deleted);
      ncb.setContentTitle(session.getString(R.string.notif_ser_canc));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.SERIES_INFO).putExtra("tvdb_id", data.getString("tvdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      String purl = data.getString("poster");
      if (TextUtils.isEmpty(purl)) nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
      else
        session
            .picasso()
            .load(purl)
            .placeholder(R.drawable.ic_notification_deleted)
            .into(
                new Target() {
                  @Override
                  public void onPrepareLoad(Drawable arg0) {}

                  @Override
                  public void onBitmapLoaded(Bitmap bitmap, LoadedFrom source) {
                    ncb.setLargeIcon(bitmap);
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }

                  @Override
                  public void onBitmapFailed(Drawable arg0) {
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }
                });

    } else if (action.equals(SN.DBG_TVDB_RSS)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_info);
      ncb.setContentTitle(session.getString(R.string.notif_dbg_rsst));
      ncb.setContentText(
          String.format(
              session.getString(R.string.notif_dbg_rssm),
              data.getInt("tot"),
              data.getInt("chk"),
              data.getInt("oks")));
      ncb.setContentIntent(newPI(newAI(SN.GENERAL_INFO), false));
      nm.notify(NOTIF_GENERAL_INFO, ncb.build());
    }
  }