From bf5a3d6b1076635303ba1b02bdf30408488f4de4 Mon Sep 17 00:00:00 2001 From: Gemeinschaft Service Account Date: Sun, 22 Dec 2013 23:16:17 +0100 Subject: [PATCH 01/10] - has to be escaped in regex --- app/controllers/config_gigaset_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/config_gigaset_controller.rb b/app/controllers/config_gigaset_controller.rb index b638db14..20416f11 100644 --- a/app/controllers/config_gigaset_controller.rb +++ b/app/controllers/config_gigaset_controller.rb @@ -450,7 +450,7 @@ def phone_book phone_book_ids << phone_book.id end - ln = params[:ln].to_s.encode!('UTF-8', 'UTF-8', :invalid => :replace).gsub(/[^0-9a-zA-Z-_]/,'_') + '%' + ln = params[:ln].to_s.encode!('UTF-8', 'UTF-8', :invalid => :replace).gsub(/[^0-9a-zA-Z\-_]/,'_') + '%' hm = params[:hm].to_s + '%' @phone_book_entries = PhoneBookEntry.where(:phone_book_id => phone_book_ids).where('last_name LIKE ?', ln).order(:last_name).order(:first_name).limit(MAX_DIRECTORY_ENTRIES) From cf54031c66e608ab5cfb52ce6ba718f22afd63d0 Mon Sep 17 00:00:00 2001 From: duebel- Date: Mon, 23 Dec 2013 12:35:54 +0100 Subject: [PATCH 02/10] Update README.md --- README.md | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 50fe13db..e4b41afd 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,7 @@ GS5 === -Gemeinschaft 5 by [AMOOMA GmbH](http://amooma.de) in Germany. It is a FreeSWITCH and Ruby on Rails based PBX. This Github repository is our development environment. +Gemeinschaft 5 by AMOOMA GmbH in Germany. It is a FreeSWITCH and Ruby on Rails based PBX. -Documentation -============= -Please have a look at our [Wiki](https://github.com/amooma/GS5/wiki). +This Github repository is my development environment for bugfixes and enhancements. -Bug reports -=========== -Please open a new issue to report a bug. Please don't forget to include the URL in case you report a view related problem. - -Feature requests -================ -Please open a new issue and mark it as a feature request. - -Roadmap -======= -We don't have a public roadmap. But we do track the future work with issues. So have a look at [https://github.com/amooma/GS5/issues](https://github.com/amooma/GS5/issues) for future features. - -License -======= -We use this public repository to develop. Do not use this code on a production system! Do not give away this code to your clients! This code is strictly for development purposes and GS5 is not a GPL project. - -DO NOT USE CODE FROM THE CONTENT OF THIS REPOSITORY FOR A PRODUCTION SYSTEM! - -You can download a free and stable version of GS5 for your production system at [http://amooma.de/gemeinschaft/gs5](http://amooma.de/gemeinschaft/gs5). - -Development How-to -================== -There is a master and a develop branch in this repository. If you are familiar with [http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/) you are good to go. Please send a pull request and an e-mail to stefan.wintermeyer@amooma.de with some info about your code. Regular developer get access to the repository, a closed developer mailinglist and hardware in case they need it. - -We only accept code which was written 100% by you and were you grant us the rights for the code. \ No newline at end of file +For further information on GS5 visit [AMOOMA's repository](https://github.com/amooma/GS5) or their [website](http://amooma.de/gemeinschaft/gs5). From f2a412759ff7b6b578ad9ae274c9c5d044306c7d Mon Sep 17 00:00:00 2001 From: duebel- Date: Fri, 27 Dec 2013 16:20:17 +0100 Subject: [PATCH 03/10] backup:cleanup task added. --- lib/tasks/backup.rake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index c26bc620..d8f718f6 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -82,5 +82,12 @@ namespace :backup do restore_job.destroy end end - + desc "Cleanup backups." + task :cleanup, [:daystokeep] => :environment do |t,a| + a.with_defaults(:daystokeep => 90) + cleanuptime = Time.now - a.daystokeep.to_i.day + puts "Deleting backups to #{cleanuptime.to_s} ..." + BackupJob.where("started_at < ?",cleanuptime).find_each { |entry| entry.destroy } + puts "Done." + end end From f3ec800eda9ab44afe2a3dc49f1a65255449012f Mon Sep 17 00:00:00 2001 From: duebel- Date: Fri, 27 Dec 2013 16:34:52 +0100 Subject: [PATCH 04/10] Description for backup:cleanup added --- lib/tasks/backup.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index d8f718f6..9293c846 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -82,8 +82,10 @@ namespace :backup do restore_job.destroy end end + desc "Cleanup backups." task :cleanup, [:daystokeep] => :environment do |t,a| + # this task will purge all backups started before :daystokeep (default 90) days from disk and database to save disk space a.with_defaults(:daystokeep => 90) cleanuptime = Time.now - a.daystokeep.to_i.day puts "Deleting backups to #{cleanuptime.to_s} ..." From 79b559efe5f261f2812dbf3404df3e051cec17c0 Mon Sep 17 00:00:00 2001 From: duebel- Date: Fri, 27 Dec 2013 16:40:37 +0100 Subject: [PATCH 05/10] Usage of backup:cleanup added. --- lib/tasks/backup.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index 9293c846..30781d84 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -86,6 +86,7 @@ namespace :backup do desc "Cleanup backups." task :cleanup, [:daystokeep] => :environment do |t,a| # this task will purge all backups started before :daystokeep (default 90) days from disk and database to save disk space + # usage: rake backup:cleanup[14] a.with_defaults(:daystokeep => 90) cleanuptime = Time.now - a.daystokeep.to_i.day puts "Deleting backups to #{cleanuptime.to_s} ..." From 4b87c9c7902a481d2f3a7a9575377c26bafe852b Mon Sep 17 00:00:00 2001 From: duebel- Date: Fri, 3 Jan 2014 16:16:18 +0100 Subject: [PATCH 06/10] Added rake tasks csvphonebook:[add|delete] to manipulate phonebooks via CSV files. --- lib/tasks/csv_phonebook.rake | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 lib/tasks/csv_phonebook.rake diff --git a/lib/tasks/csv_phonebook.rake b/lib/tasks/csv_phonebook.rake new file mode 100644 index 00000000..87f9174d --- /dev/null +++ b/lib/tasks/csv_phonebook.rake @@ -0,0 +1,82 @@ +namespace :csvphonebook do + require 'csv' + require 'digest/md5' + + # CSV format (headers are inspired by LDAP attributes): + # + # givenName,sn,company,telephoneNumber,mobile,department,streetAddress,postalCode,l,title + # Max,Mustermann,Musterfirma,+123456789,+91123456789,Abteilung XY,Musterstraße 1 a,12345,Musterstadt,Musterchief + + desc "Delete phonebook entries from a CSV file." + task :delete, [:csvfile, :phonebookname] => :environment do |t,a| + + csv_data = CSV.read(a.csvfile, encoding: 'UTF-8') + phonebookid = PhoneBook.find(:first, :conditions => { :name => a.phonebookname}).id + headers = csv_data.shift.map {|i| i.to_s } + string_data = csv_data.map {|row| row.map {|cell| cell.to_s } } + entries = string_data.map {|row| Hash[*headers.zip(row).flatten] } + + entries.each do |entry| + if !(entry['givenName'].blank? || entry['sn'].blank? || entry['company'].blank?) + pbe = PhoneBookEntry.find(:first,:conditions => { + :phone_book_id => phonebookid, + :first_name => entry['givenName'], + :last_name => entry['sn'], + :organization => entry['company'] + }) + if !pbe.nil? + pbe.delete + end + end + end + end + + desc "Add new phonebook entries from CSV file." + task :add, [:csvfile, :phonebookname] => :environment do |t,a| + + csv_data = CSV.read(a.csvfile, encoding: 'UTF-8') + phonebookid = PhoneBook.find(:first, :conditions => { :name => a.phonebookname}).id + headers = csv_data.shift.map {|i| i.to_s } + string_data = csv_data.map {|row| row.map {|cell| cell.to_s } } + entries = string_data.map {|row| Hash[*headers.zip(row).flatten] } + + entries.each do |entry| + if !(entry['givenName'].blank? || entry['sn'].blank? || entry['company'].blank?) + pbe = PhoneBookEntry.new + pbe.first_name = entry['givenName'] + pbe.last_name = entry['sn'] + pbe.organization = entry['company'] + pbe.is_male = 1 + pbe.department = entry['department'] + pbe.job_title = entry['title'] + pbe.phone_book_id = phonebookid + pbe.save + + if !(entry['telephoneNumber'].blank?) + number = PhoneNumber.new + number.name = 'Office' + number.number = entry['telephoneNumber'] + number.phone_numberable_type = 'PhoneBookEntry' + number.phone_numberable_id = pbe.id + number.save + end + if !(entry['mobile'].blank?) + number = PhoneNumber.new + number.name = 'Mobile' + number.number = entry['mobile'] + number.phone_numberable_type = 'PhoneBookEntry' + number.phone_numberable_id = pbe.id + number.save + end + if !(entry['streetAddress'].blank? && entry['postalCode'].blank? && entry['l'].blank?) + addr = Address.new + addr.street = entry['streetAddress'] + addr.zip_code = entry['postalCode'] + addr.city = entry['l'] + addr.phone_book_entry_id = pbe.id + addr.save + end + end + end + end +end From 9b60762cfac251c67a565562d366b8476192b0a4 Mon Sep 17 00:00:00 2001 From: duebel- Date: Fri, 3 Jan 2014 16:21:44 +0100 Subject: [PATCH 07/10] Removed unnecessary require. --- lib/tasks/csv_phonebook.rake | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tasks/csv_phonebook.rake b/lib/tasks/csv_phonebook.rake index 87f9174d..49799a44 100644 --- a/lib/tasks/csv_phonebook.rake +++ b/lib/tasks/csv_phonebook.rake @@ -1,6 +1,5 @@ namespace :csvphonebook do require 'csv' - require 'digest/md5' # CSV format (headers are inspired by LDAP attributes): # From 1842b97465c388e3846260753e3d7408849bf219 Mon Sep 17 00:00:00 2001 From: duebel- Date: Sat, 4 Jan 2014 18:43:19 +0100 Subject: [PATCH 08/10] Usage and CSV notes added. --- lib/tasks/csv_phonebook.rake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/tasks/csv_phonebook.rake b/lib/tasks/csv_phonebook.rake index 49799a44..62ef0fde 100644 --- a/lib/tasks/csv_phonebook.rake +++ b/lib/tasks/csv_phonebook.rake @@ -1,10 +1,18 @@ namespace :csvphonebook do require 'csv' - # CSV format (headers are inspired by LDAP attributes): + # + # CSV format (headers are inspired by LDAP attributes). + # Columns givenName,sn,company are mandatory, other columns are optional. # # givenName,sn,company,telephoneNumber,mobile,department,streetAddress,postalCode,l,title # Max,Mustermann,Musterfirma,+123456789,+91123456789,Abteilung XY,Musterstraße 1 a,12345,Musterstadt,Musterchief + # + # + # usage: + # rake csvphonebook:add[/path/to/file.csv,"name of phone book"] + # rake csvphonebook:delete[/path/to/file.csv,"name of phone book"] + # desc "Delete phonebook entries from a CSV file." task :delete, [:csvfile, :phonebookname] => :environment do |t,a| From 566cc8f0973f0bf0a54b4a825815e8939c52ff4f Mon Sep 17 00:00:00 2001 From: duebel- Date: Thu, 9 Jan 2014 14:04:28 +0100 Subject: [PATCH 09/10] Remerge with upstream. --- README.md | 23 +++++++++++++++++-- .../locales/views/gemeinschaft_setups/en.yml | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4b41afd..eaebda47 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,25 @@ GS5 === Gemeinschaft 5 by AMOOMA GmbH in Germany. It is a FreeSWITCH and Ruby on Rails based PBX. -This Github repository is my development environment for bugfixes and enhancements. +MIT License +=========== +Copyright (c) 2013 AMOOMA GmbH +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -For further information on GS5 visit [AMOOMA's repository](https://github.com/amooma/GS5) or their [website](http://amooma.de/gemeinschaft/gs5). +Documentation +============= +Please have a look at our [Wiki](https://github.com/amooma/GS5/wiki). + +Bug reports +=========== +Please open a new issue to report a bug. Please don't forget to include the URL in case you report a view related problem. + +Feature requests +================ +Please open a new issue and mark it as a feature request. + +Development How-to +================== +There is a master and a develop branch in this repository. If you are familiar with [http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/) you are good to go. Pull request is your friend. diff --git a/config/locales/views/gemeinschaft_setups/en.yml b/config/locales/views/gemeinschaft_setups/en.yml index 0e1bdbed..7161df72 100644 --- a/config/locales/views/gemeinschaft_setups/en.yml +++ b/config/locales/views/gemeinschaft_setups/en.yml @@ -27,7 +27,7 @@ en: hint: '' default_area_code: label: 'Default area code' - hint: '' + hint: 'without the leading zero; e.g. 30 for Berlin' trunk_access_code: label: 'Trunk access code' hint: '' @@ -43,4 +43,4 @@ en: report_attacks: label: 'Report attacks' hint: 'Report attacks to the cloud.' - submit: 'Create this PBX' \ No newline at end of file + submit: 'Create this PBX' From 0305c17c0a49e75f8ca2b6306aca398002998c59 Mon Sep 17 00:00:00 2001 From: duebel- Date: Thu, 9 Jan 2014 14:17:54 +0100 Subject: [PATCH 10/10] Country added. --- lib/tasks/csv_phonebook.rake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/tasks/csv_phonebook.rake b/lib/tasks/csv_phonebook.rake index 62ef0fde..d757cd6e 100644 --- a/lib/tasks/csv_phonebook.rake +++ b/lib/tasks/csv_phonebook.rake @@ -5,8 +5,8 @@ namespace :csvphonebook do # CSV format (headers are inspired by LDAP attributes). # Columns givenName,sn,company are mandatory, other columns are optional. # - # givenName,sn,company,telephoneNumber,mobile,department,streetAddress,postalCode,l,title - # Max,Mustermann,Musterfirma,+123456789,+91123456789,Abteilung XY,Musterstraße 1 a,12345,Musterstadt,Musterchief + # givenName,sn,company,telephoneNumber,mobile,department,streetAddress,postalCode,l,title,co + # Max,Mustermann,Musterfirma,+123456789,+91123456789,Abteilung XY,Musterstraße 1 a,12345,Musterstadt,Musterchief,Germany # # # usage: @@ -75,11 +75,17 @@ namespace :csvphonebook do number.phone_numberable_id = pbe.id number.save end - if !(entry['streetAddress'].blank? && entry['postalCode'].blank? && entry['l'].blank?) + if !(entry['streetAddress'].blank? && entry['postalCode'].blank? && entry['l'].blank? && entry['co'].blank?) addr = Address.new addr.street = entry['streetAddress'] addr.zip_code = entry['postalCode'] addr.city = entry['l'] + if !entry['co'].blank? + country = Country.find(:first, :conditions => { :name => entry['co']}) + if !country.nil? + addr.country_id = country.id + end + end addr.phone_book_entry_id = pbe.id addr.save end