Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Empires & Allies Hack Cheat Trainer v5.4.1
Eve Onnline 60 Days Time Card Generator v2
Xbox Lve Generator v3
Better way to get content via jQuery $.get()
Free CarTown Blue Points Generator and CarTown Templates
Steam Wallet Hack 2012
Diablo 3 error 37 & error 3006 fix
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
PAYPAL REMOVE ACCESS LIMITED ACCOUNT 100% Working
Pastable version of
iCal subscription
<pre class='prettyprint' language='ruby'>class IcalController < ApplicationController ## # Build the iCal subscription fom the given first_letters for the user # If none first_letters given than build the complete subscription for all users. ## def subscribe require "icalendar" first_letters = params[:id] #build time frame start_at = Time.now.beginning_of_day - 14.days # Kijk 14 dagen in het verleden end_at = Time.now.end_of_day + 13.months # Kijk 13 maanden in de toekomst if !first_letters.nil? user = User.find_by_jobfunction(first_letters, :select => ["Username, id"]) # Initials saved in jobfunction database field!! plannings = Planning.find_active_plannings_for_user_between(user.id,start_at, end_at) else plannings = Planning.find_active_plannings_between(start_at, end_at) end #pp plannings calendar = Icalendar::Calendar.new calendar.custom_property("METHOD", "PUBLISH") plannings.each do |planning| begin company = Company.find(planning.company_id, :select => ["id, strCompanyName, strPhone, strOfficeStreet, strOfficeZip, strOfficeCity"]) planning.description = "" if planning.description.nil? body = "" body << company.strCompanyName body << " " body << company.strPhone if not company.strPhone.nil? body << "tel onbekend" if company.strPhone.nil? body << " " body << User.find(planning.user_id).Username if user.nil? body << user.Username if not user.nil? body << "" event = Icalendar::Event.new event.klass "Public" event.dtstart icaldate(planning.start_at) event.dtend icaldate(planning.end_at) event.summary "" << body event.description "" << planning.description event.location "" + company.strOfficeStreet + " - " + company.strOfficeZip + " - " + company.strOfficeCity event.dtstamp DateTime.now.to_datetime event.uid "event-#{planning.id.to_s}" event.priority 3 event.sequence 0 calendar.add_event(event) rescue Exception => error puts "Dat ging fout: #{error.message}" end end respond_to do |format| format.ics {render :text => calendar.to_ical} format.html {render :text => calendar.to_ical} end end end class Planning < ActiveRecord::Base belongs_to :user, :select => ["Username, id, jobfunction"] belongs_to :company, :select => ["id, strCompanyName, strPhone, strOfficeStreet, strOfficeZip, strOfficeCity"] def self.find_active_plannings_for_user_between(user, start_date, end_date) plannings = self.find(:all, :conditions => ["bitDeleted = 0 AND user_id = ? AND start_at BETWEEN ? AND ?", user, start_date, end_date], :select => ["start_at, end_at, description, id"], :include => [:user, :company]) return plannings end def self.find_active_plannings_between(start_date, end_date) plannings = self.find(:all, :conditions => ["bitDeleted = 0 AND start_at BETWEEN ? AND ?", start_date, end_date], :select => ["start_at, end_at, description, id"]) return plannings end end class Company < ActiveRecord::Base has_many :contacts, :select => ["id, strContactName, strLastName, strMiddleName, strFirstName, strPhone, strEmail, strMobile"], :conditions => ["bitDeleted < 1"] end class User < ActiveRecord::Base has_many :plannings end</pre> <a href="http://www.refactormycode.com/codes/1307-ical-subscription" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>