redmine

Initial commit

This diff is collapsed. Click to expand it.
  1 +require 'redmine'
  2 +
  3 +require_dependency "redmine_cps/patches/app/helpers/application_helper"
  4 +
  5 +Redmine::Plugin.register :redmine_cps do
  6 + name 'Integration to CPS plugin'
  7 + author 'Dmitry Yu Okunev'
  8 + author_url 'https://github.com/xaionaro/'
  9 + description 'A plugin to intergrate Redmine to NRNU MEPhI CPS system'
  10 + url 'https://gitlab.ut.mephi.ru/ut/redmine_cps'
  11 + version '0.0.1'
  12 +end
  1 +# encoding: UTF-8
  2 +
  3 +require 'application_helper'
  4 +
  5 +module CPS
  6 + module ApplicationHelperPatch
  7 + def self.included(base)
  8 + base.extend(ClassMethods)
  9 + base.send(:include, InstanceMethods)
  10 +
  11 + base.class_eval do
  12 + alias_method_chain :link_to_user, :cps
  13 + end
  14 + end
  15 +
  16 + module ClassMethods
  17 + end
  18 +
  19 + module InstanceMethods
  20 + def link_to_user_with_cps(user, options={})
  21 + if user.is_a?(User)
  22 + name = h(user.name(options[:format]))
  23 + if user.active? || (User.current.admin? && user.logged?)
  24 + link_to "#{name}", user_path(user), {:class => user.css_classes, :title => "#{user.lastname} #{user.firstname}; #{user.appointment}"}
  25 + else
  26 + name
  27 + end
  28 + else
  29 + h(user.to_s)
  30 + end
  31 + end
  32 + end
  33 + end
  34 +end
  35 +ApplicationHelper.send(:include, CPS::ApplicationHelperPatch)
  36 +