First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
565
sites/all/modules/civicrm/CONTRIBUTORS.txt
Normal file
565
sites/all/modules/civicrm/CONTRIBUTORS.txt
Normal file
|
@ -0,0 +1,565 @@
|
|||
The following people and organizations sponsored and/or contributed new and improved features to the project.
|
||||
|
||||
************************************************
|
||||
Key Contributors and Sponsors for 4.7
|
||||
************************************************
|
||||
|
||||
CiviCRM Team - Atif Shaikh, Coleman Watts, David Greenberg, Eileen McNaughton,
|
||||
Jitendra Purohit, Josh Gowan, Kurund Jalmi,
|
||||
Michael McAndrew, Monish Deb, Rohan Ramesh Katkar, Tim Otten,
|
||||
Yashodha Chaku
|
||||
|
||||
AGH Strategies - Andrew Hunt, Tyrell Cook, Nikki Murray
|
||||
Agileware - Justin Freeman, Francis Whittle, Iris Abarquez, Vaibhav Sagar
|
||||
Andrew West
|
||||
Aputsiaĸ Niels Janussen
|
||||
Aron Novak
|
||||
Backoffice Thinking
|
||||
Barbara Miller
|
||||
Borislav Zlatanov
|
||||
Brian Dombrowski
|
||||
Caroline Badley
|
||||
Christian Wach
|
||||
Charlie DeTar
|
||||
Chirojeugd Vlaanderen - Johan Vervloet
|
||||
Circle Interactive - Dave Jenkins
|
||||
CiviCoop - Jaap Jansma
|
||||
CiviDesk - Nicolas Ganivet, Sunil Pawar, Virginie Ganivet
|
||||
Compucorp - Guanhuan Chen, Jamie Novick
|
||||
CiviCoop - Jaap Jansma
|
||||
Coop SymbioTIC - Mathieu Lutfy, Samuel Vanhove
|
||||
Dave D
|
||||
David Hayes
|
||||
Dhanesh Dhuri
|
||||
Dmitry Smirnov
|
||||
Elin Waring
|
||||
Emphanos LLC - Allen Shaw
|
||||
Esantanche
|
||||
Freeform Solutions - Lola Slade, Stephanie Gray, Herb van den Dool
|
||||
Future First - David Knoll, John Prescott
|
||||
Fuzion NZ - Chris Burgess, Eileen McNaughton, Peter Davis, Torrance Hodgson
|
||||
Giant Rabbit - Peter Haight
|
||||
Ginkgo Street Labs - Frank Gomez, Galata Tona, Michael Daryabeygi, Roshani Kothari, Toby Lounsbury
|
||||
Jake Martin White
|
||||
Joanne Chester
|
||||
Joe McLaughlin
|
||||
John P Kirk
|
||||
Joris
|
||||
JMA Consulting - Joe Murray, Pradeep Nayak, Edsel Lopez
|
||||
gah242s
|
||||
Greenleaf Advancement - Guy Iaccarino
|
||||
K Sneed Consulting - Kate Sneed
|
||||
Kemal Bay
|
||||
Ken West
|
||||
Kevin Levie
|
||||
Korlon - Stuart Gaston
|
||||
kreynen
|
||||
Laryn
|
||||
Lesley Evensen (zorgalina)
|
||||
Lighthouse Consulting and Design - Brian Shaughnessy
|
||||
Marty Wright
|
||||
Matthew Wire
|
||||
Mattias Michaux
|
||||
Megaphone Technology Consulting - Jon Goldberg
|
||||
Mohit Aggarwal
|
||||
National Urban League - Lisa Taliano
|
||||
Nicholai Burton
|
||||
Niels Heinemann
|
||||
New York City Council
|
||||
New York State Senate - Ken Zalewski
|
||||
Northbridge Digital - Oliver Gibson
|
||||
Olaf Buddenhagen
|
||||
Palante Technology Cooperative - Joseph Lacey
|
||||
Paul Campbell
|
||||
Progressive Tech Project - Alice Aguilar, Jamie McClelland
|
||||
Richard Van Oosterhout
|
||||
RocXa
|
||||
Saurabh Batra
|
||||
Seamus Lee
|
||||
Seb35
|
||||
Semper IT - Karin Gerritsen
|
||||
Shawn Holt
|
||||
Skvare - Jeremy Proffitt, Peter Petrik
|
||||
Smiling Heart Enterprises - Neil Planchon
|
||||
Squiffle Consulting - Aidan Saunders
|
||||
Stephen Palmstrom
|
||||
Symbiotic - Mathieu Lutfy, Samuel Vanhove
|
||||
Systopia - Björn Endres, Niko Bochan
|
||||
Tadpole - Dana Skallman, Kevin Cristiano
|
||||
Tech to the People - Xavier Dutoit
|
||||
Thomas Leichtuss
|
||||
Tim Mallezie
|
||||
Torenware Networks - Rob Thorne
|
||||
University of Cambridge – Alex Corr, John Kingsnorth
|
||||
Veda Consulting - Parvez Saleh, Deepak Srivastava, Kajan
|
||||
Wanna Pixel - Nathan Porter, Marisa Porter
|
||||
Web Access - Sudha Bisht
|
||||
Wikimedia Foundation - Adam Wight
|
||||
yurg
|
||||
zarandras
|
||||
|
||||
************************************************
|
||||
Key Contributors and Sponsors for 4.6
|
||||
************************************************
|
||||
|
||||
CiviCRM Team - Atif Shaikh, Coleman Watts, David Greenberg, Donald Lobo,
|
||||
Eileen McNaughton, Jitendra Purohit, Josh Gowan, Kurund Jalmi,
|
||||
Michael McAndrew, Monish Deb, Rohan Ramesh Katkar, Tim Otten,
|
||||
Yashodha Chaku
|
||||
ADG Communications - Steve Binkowski
|
||||
AGH Strategies - Andrew Hunt, Jane Hanley, Tommy Bobo, Tyrell Cook
|
||||
Agileware - Justin Freeman, Francis Whittle, Iris Abarquez, Vaibhav Sagar
|
||||
Alex C
|
||||
Allan Chappell
|
||||
Amnesty International Spain - Carlos Capote
|
||||
Andreas Hennings
|
||||
Andy Clark
|
||||
Arete Imagine - Marisa Porter, Nate Porter
|
||||
Asylum Hill Congregational Church
|
||||
Blackfly Solutions - Alan Dixon
|
||||
Botanical Society of America - Toby Lounsbury
|
||||
Chirojeugd Vlaanderen - Johan Vervloet
|
||||
Christian Wach
|
||||
Chris Ward
|
||||
Circle Interactive - Dave Moreton, Andrew Walker, Dave Jenkins, Maya Gibbs
|
||||
CiviCoop - Erik Hommel, Jaap Jansma
|
||||
CiviDesk - Nicolas Ganivet, Sunil Pawar
|
||||
Community Human Services Corporation - Paul Mosey
|
||||
Compucorp - Jamie Novick, Greg Meszeros, Robin Mitra, Guanhuan Chen, Chanun Chirattikanon
|
||||
David Hepper
|
||||
Detlev Sieber
|
||||
Drishtant - Ruchi Kumar
|
||||
Drupal Association - Neil Drumm
|
||||
Elliott Eggleston
|
||||
Freeform Solutions - Lola Slade
|
||||
Future First - David Knoll, John Prescott, Vitor Nobrega
|
||||
Fuzion, NZ - Chris Burgess, Eileen McNaughton, Peter Davis
|
||||
Giantrabbit - Anthony Nemirovsky, Peter Haight
|
||||
Ginkgo Street Labs - Frank J. Gómez, Michael Daryabeygi
|
||||
GMVCO Databases - Jon-man Cheung, Alex Lee, Craig Almond
|
||||
Google Summer of Code - Aditya Nambiar, Siddhant Rajagopalan, Torrance Hodgeson
|
||||
Gnu.org - David Thompson
|
||||
Jaka Kranjc
|
||||
JMA Consulting - Joe Murray, Pradeep Nayak, Edsel Lopez
|
||||
Joanne Chester
|
||||
John Kingsnorth
|
||||
jsnyder83
|
||||
Kathryn Benedicto
|
||||
Han Velthuis
|
||||
Ken West
|
||||
Kirk Jackson
|
||||
Korlon - Stuart Gaston
|
||||
Lighthouse Consulting and Design - Brian Shaughnessy
|
||||
Mattias Michaux
|
||||
Max
|
||||
MC3 - Graham Mitchell
|
||||
Mission Matters - Joshua Aranda
|
||||
Mobius - Jeremy Proffitt
|
||||
Northbridge Digital - Oliver Gibson
|
||||
Symbiotic - Mathieu Lutfy, Samuel Vanhove
|
||||
National Democratic Institute - Chris Doten
|
||||
New York State Senate - Ken Zalewski
|
||||
Niro Solutions
|
||||
Palente Technology Cooperative - Jon Goldberg, Joseph Lacey
|
||||
Paul Campbell
|
||||
Pogstone - Sarah Gladstone
|
||||
Progressive Tech Project - Alice Aguilar, Jamie McClelland
|
||||
Registered Nurses Association of Ontario - Stan Dragnev
|
||||
Richard Van Oosterhout
|
||||
Seamus Lee
|
||||
Semper IT - Karin Gerritsen
|
||||
Skvare - Mark Hanna, Peter Petrik
|
||||
Squiffle Consulting - Aidan Saunders
|
||||
Stephen Palmstrom
|
||||
Systopia - Björn Endres, Fabian Schuttenberg, Martin Peth, Niko Bochan
|
||||
Tadpole - Dana Skallman, Kevin Cristiano
|
||||
Tech to the People - Xavier Dutoit
|
||||
TeNNoX
|
||||
Tim Mallezie
|
||||
Toke Høiland-Jørgensen
|
||||
Veda Consulting - Priyanka Karan, Parvez Saleh, Deepak Srivastava
|
||||
William Theaker
|
||||
Web Access - Tony Mazzerella, Nileema Jadhav, Parag Bhilkar, Pratiksha Dubey, Manish More
|
||||
Wikimedia Foundation - Adam Wight
|
||||
Zing - Simon West, Andrew Tombs, Vivek Arora
|
||||
|
||||
************************************************
|
||||
Key Contributors and Sponsors for 4.5
|
||||
************************************************
|
||||
|
||||
CiviCRM Team - Coleman Watts, David Greenberg, Donald Lobo,
|
||||
Kurund Jalmi, Michael McAndrew, Monish Deb, Pratik Joshi,
|
||||
Tim Otten, Yashodha Chaku, Eileen McNaughton
|
||||
AGH Strategies - Andrew Hunt, Maggie Epps, Tyrell Cook
|
||||
Allan Chappell
|
||||
Amnesty International Spain - Carlos Capote
|
||||
Andy Clark
|
||||
Arete Imagine - Marisa Porter, Nate Porter
|
||||
Botanical Society of America - Toby Lounsbury
|
||||
Chris Burgess
|
||||
Chris Ward
|
||||
Circle Interactive - Andrew Walker, Dave Jenkins
|
||||
CiviDesk - Nicolas Ganivet, Sunil Pawar
|
||||
Compucorp - Jamie Novick, Erawat Chamanont
|
||||
CiviCoop - Erik Hommel, Jaap Jansma
|
||||
Detlev Sieber
|
||||
Drishtant - Ruchi Kumar
|
||||
Drupal Association - Neil Drumm
|
||||
Electronic Frontier Foundation - Mark Burdett, Max Hunter, Leez Wright
|
||||
Freeform Solutions - Lola Slade
|
||||
Fuzion, NZ - Eileen McNaughton, Peter Davis, Torrance Hodgeson
|
||||
Giant Rabbit - Peter Haight, Anthony Nemirovsky
|
||||
Ginkgo Street Labs - Frank J. Gómez, Michael Daryabeygi
|
||||
Graham Mitchell
|
||||
Great Lakes Planetarium Association - Geoff Holt
|
||||
Jennifer Simonis
|
||||
Jeremy Proffitt
|
||||
Jim Meehan
|
||||
Jimmy Huang
|
||||
JMA Consulting - Joe Murray
|
||||
Joanne Chester
|
||||
Ken West
|
||||
Kirk Jackson
|
||||
Korlon - Stuart Gaston
|
||||
Koumbit - Samuel Vanhove
|
||||
Lighthouse Consulting and Design - Brian Shaughnessy
|
||||
Mathieu Lutfy
|
||||
Mission Matters - Joshua Aranda
|
||||
National Democratic Institute - Chris Doten
|
||||
New York State Senate - Ken Zalewski
|
||||
Niro Solutions
|
||||
Palente Technology Cooperative - Jon Goldberg, Joseph Lacey
|
||||
Pogstone - Sarah Gladstone
|
||||
Progressive Tech Project - Alice Aguilar, Jamie McClelland
|
||||
Semper IT - Karin Gerritsen
|
||||
Skvare - Mark Hanna, Peter Petrik
|
||||
Systopia - Björn Endres
|
||||
Tadpole - Dana Skallman
|
||||
Tech to the People - Xavier Dutoit
|
||||
Veda Consulting - Parvez Saleh, Deepak Srivastava
|
||||
Web Access - Pradeep Nayak, Tony Mazzarella
|
||||
Wikimedia Foundation - Adam Wight
|
||||
Zing - Simon West, Andrew Tombs
|
||||
|
||||
************************************************
|
||||
Key Contributors and Sponsors for 4.4
|
||||
************************************************
|
||||
|
||||
CiviCRM Team - Coleman Watts, David Greenberg, Donald Lobo,
|
||||
Kurund Jalmi, Michael McAndrew, Monish Deb,
|
||||
Tim Otten, Yashodha Chaku, Eileen McNaughton
|
||||
AGH Strategies - Andrew Hunt
|
||||
Backoffice Thinking
|
||||
Chris Burgess
|
||||
Circle Interactive - Andrew Walker, Dave Jenkins
|
||||
CiviDesk - Nicolas Ganivet
|
||||
CiviCoop - Erik Hommel, Jaap Jansma
|
||||
CiviHosting - Hershel Robinson
|
||||
CompuCorp - Jamie Novick, Erawat Chamanont
|
||||
Confluence - Frank Gomez, Michael Daryabeygi
|
||||
Dave D
|
||||
Detlev Sieber
|
||||
Drupal Association - Neil Drumm
|
||||
Electronic Frontier Foundation - Micah Lee, Kellie Brownell
|
||||
Emphanos - Allen Shaw
|
||||
Freeform Solutions - Lola Slade
|
||||
Fuzion, NZ - Eileen McNaughton, Peter Davis, Torrance Hodgeson
|
||||
Giant Rabbit - Anna Heath
|
||||
Jim Meehan
|
||||
JMA Consulting - Joe Murray
|
||||
Joanne Chester
|
||||
Keith Morgan
|
||||
Ken West
|
||||
Korlon - Stuart Gaston
|
||||
Koumbit - Samuel Vanhove
|
||||
Lighthouse Consulting and Design - Brian Shaughnessy
|
||||
Mathieu Lutfy
|
||||
National Democratic Institute - Chris Doten
|
||||
New York State Senate - Ken Zalewski
|
||||
NfP Services (MTL Software Group) - Jag Kandasamy, Rajesh Sundararajan
|
||||
Niro Solutions
|
||||
Noah Miller
|
||||
Orgis - Hans Idink
|
||||
Palente Technology Cooperative - Jon Goldberg, Joseph Lacey
|
||||
Paul Delbar
|
||||
Pogstone - Sarah Gladstone
|
||||
Progressive Tech Project - Alice Aguilar, Jamie McClelland
|
||||
Registered Nurses Association of Ontario
|
||||
San Francisco Baykeeper - Eliet Henderson
|
||||
Tadpole - Dana Skallman
|
||||
Tallyfox
|
||||
Tech to the People - Xavier Dutoit
|
||||
Veda Consulting - Parvez Saleh, Deepak Srivastava
|
||||
Web Access - Pradeep Nayak
|
||||
Wikimedia Foundation - Adam Wight
|
||||
Zing - Simon West, Andrew Tombs
|
||||
|
||||
************************************************
|
||||
Key Contributors and Sponsors for 4.3
|
||||
************************************************
|
||||
|
||||
CiviCRM Team - Coleman Watts, David Greenberg, Deepak Srivastava, Donald Lobo,
|
||||
Kurund Jalmi, Michael McAndrew, Pratik Joshi, Ravish Nair,
|
||||
Tim Otten, Yashodha Chaku, Eileen McNaughton
|
||||
AGH Strategies - Andrew Hunt
|
||||
Backoffice Thinking
|
||||
Chris Burgess
|
||||
Circle Interactive - Andrew Walker, Dave Jenkins
|
||||
CiviDesk - Nicolas Ganivet
|
||||
CiviHosting - Hershel Robinson
|
||||
Community Builders
|
||||
Compucorp
|
||||
Dave D
|
||||
EE-atWork - Erik Hommel
|
||||
Electronic Frontier Foundation - Micah Lee, Kellie Brownell
|
||||
Emphanos - Allen Shaw
|
||||
Fuzion, NZ - Eileen McNaughton, Peter Davis, Torrance Hodgeson
|
||||
Ginkgo Street Labs - Frank J. Gómez, Michael Daryabeygi
|
||||
Jim Meehan
|
||||
JMA Consulting - Joe Murray, Pradeep Nayak
|
||||
Keith Morgan
|
||||
Ken West
|
||||
Korlon - Stuart Gaston
|
||||
Koumbit - Samuel Vanhove
|
||||
Lighthouse Consulting and Design - Brian Shaughnessy
|
||||
Mathieu Lutfy
|
||||
New York State Senate - Ken Zalewski
|
||||
NfP Services (MTL Software Group) - Jag Kandasamy, Rajesh Sundararajan
|
||||
Niro Solutions
|
||||
Noah Miller
|
||||
Palente Technology Cooperative - Jon Goldberg
|
||||
Progressive Tech Project - Alice Aguilar, Jamie McClelland
|
||||
Paul Delbar
|
||||
Registered Nurses Association of Ontario
|
||||
San Francisco Baykeeper - Eliet Henderson
|
||||
Tech to the People - Xavier Dutoit
|
||||
Third Sector Design
|
||||
Veda Consulting - Parvez Saleh
|
||||
Web Access
|
||||
Zing - Simon West, Andrew Tombs
|
||||
|
||||
|
||||
************************************************
|
||||
Sponsors and key contributors for 4.2
|
||||
************************************************
|
||||
The following people and organizations sponsored and/or contributed new and improved features for the 4.2 release.
|
||||
|
||||
Abril Rocabert
|
||||
Adam Wight
|
||||
Alice Aguilar
|
||||
Allen Shaw
|
||||
Andres Spagarino
|
||||
Andrew Hunt
|
||||
Anthony Camilleri
|
||||
Ariel Gold
|
||||
Brian Shaughnessy
|
||||
Chris Ward
|
||||
Dave Moreton
|
||||
Eileen McNaughton
|
||||
Eliet Henderson
|
||||
Erik Hommel
|
||||
Frank Gomez
|
||||
Graylin Kim
|
||||
Jamie McClelland
|
||||
Jane Hanley
|
||||
Jason Bertolacci
|
||||
Joe Murray
|
||||
John Derry
|
||||
Jon Goldberg
|
||||
Kasia Wakarecy
|
||||
Katie Horn
|
||||
Katy Jockelson
|
||||
|
||||
Ken Zalewski
|
||||
Lisa Jervis
|
||||
Mathieu Lutfy
|
||||
Matt Neimayer
|
||||
Micah Lee
|
||||
Michael McAndrew
|
||||
Nicolas Ganivet
|
||||
Noah Miller
|
||||
Parvez Saleh
|
||||
Peter Gehres
|
||||
Peter McAndrew
|
||||
Robyn Perry
|
||||
Samuel Vanhove
|
||||
Simon West
|
||||
Stéphane Lussier
|
||||
Stuart Gaston
|
||||
Xavier Dutoit
|
||||
|
||||
Art of Living
|
||||
Backoffice Thinking
|
||||
Community Builders
|
||||
DC Road Runners
|
||||
EE atWork
|
||||
Electronic Frontier Foundation
|
||||
Freeform Solutions
|
||||
Free Software Foundation
|
||||
Fuzion NZ
|
||||
Gingko Street Consulting
|
||||
JMA Consulting
|
||||
Korlon
|
||||
Koumbit
|
||||
Lighthouse Consulting
|
||||
National Democratic Institute
|
||||
New York State Senate
|
||||
NS Web Solutions
|
||||
Progressive Technology Project
|
||||
San Francisco Baykeeper
|
||||
Tech to the People
|
||||
The Monthly.com
|
||||
Veda Consulting
|
||||
Xstreme Media
|
||||
Zing
|
||||
|
||||
************************************************
|
||||
Sponsors and key contributors for 4.1
|
||||
************************************************
|
||||
The following people and organizations sponsored and/or contributed new and improved features for the 4.1 release.
|
||||
|
||||
Adam Wight
|
||||
Andrew Harris
|
||||
Alice Aguilar
|
||||
Andre Gurgel
|
||||
Brian Shaugnessy
|
||||
Coleman Watts
|
||||
Dave D
|
||||
Dave Moreton
|
||||
Eileen McNaughton
|
||||
Erik Brower
|
||||
Erik Hommel
|
||||
Henry Bennett
|
||||
Jamie McClelland
|
||||
Jim Taylor
|
||||
Jonathan Mark
|
||||
Joe Murray
|
||||
Marianela Zucotti Bozzano
|
||||
Michael McAndrew
|
||||
Steve Colson
|
||||
Stuart Gaston
|
||||
Tim Otten
|
||||
Tom Kirkpatrick
|
||||
Xavier Dutoit
|
||||
|
||||
AGH Strategies
|
||||
Amigos Library Services
|
||||
Association for Learning Technology
|
||||
Attendee Management
|
||||
Benton Consulting
|
||||
Circle Interactive
|
||||
CivicActions
|
||||
Community Builders
|
||||
EE-atWork
|
||||
Fuzion (NZ)
|
||||
Giant Rabbit
|
||||
Kindling Trust
|
||||
Korlon
|
||||
International Mountain Biking Association
|
||||
International Society for Bayesian Analysis
|
||||
Josiesque Designs
|
||||
Michigan Parents for Schools
|
||||
New York State Senate
|
||||
Nonprofit Association of Oregon
|
||||
Nonprofit Solutions
|
||||
Powered by Action
|
||||
Progressive Technology Project
|
||||
Resolutions Northwest
|
||||
River Pool at Beacon
|
||||
Rooty Hollow
|
||||
San Francisco Baykeeper
|
||||
Scotland's Colleges
|
||||
Switchback
|
||||
System Seed
|
||||
Tech to the People
|
||||
The San Francisco Orff-Schulwerk
|
||||
Third Sector Design
|
||||
Voluntary Action Westminster
|
||||
Vpod Schweiz
|
||||
Woven
|
||||
|
||||
************************************************
|
||||
Sponsors for 3.4 / 4.0 Make-it-Happen Projects
|
||||
************************************************
|
||||
The following people and organizations sponsored new and improved features for the 3.4 / 4.0 release.
|
||||
|
||||
ACORN Canada http://acorncanada.org
|
||||
Allora Consulting http://alloraconsulting.com
|
||||
American Friends Service Committee http://afsc.org/
|
||||
Australian Greens http://greens.org.au
|
||||
BREAZE http://breaze.org.au
|
||||
Canadian Paramedics http://www.peelparamedics.com
|
||||
Community Builders Australia Pty Ltd
|
||||
Corvair Society of America (CORSA) http://www.corvair.org/
|
||||
Donor Depot http://donordepot.com
|
||||
Energetica http://energetica.com.au
|
||||
Fuzion http://fuzion.co.nz
|
||||
Gold Strategy Group http://www.goldstrategygroup.com
|
||||
JMA Consulting http://jmaconsulting.biz
|
||||
Joomkit Ltd http://joomkit.com
|
||||
Kabissa - Space for Change in Africa http://kabissa.org
|
||||
NS Web Solutions http://nswebsolutions.com
|
||||
NAMI Louisville http://namilouisville.org
|
||||
Progressive Technology Project http://www.progressivetech.org
|
||||
RVTC http://rvtc.us
|
||||
Volunteer Honduras http://www.volunteerhonduras.org
|
||||
|
||||
Briney, Matthew
|
||||
Brownsberger, Will
|
||||
Burden, Monica
|
||||
Calleeuw, Bart
|
||||
Cimpian, Casti
|
||||
Clarke, Jill
|
||||
Davis, Peter
|
||||
Day, Janette
|
||||
Gold, Ariel
|
||||
Hadar, Kehilat
|
||||
Malkoun, Anthony
|
||||
Matsushita, Jun
|
||||
McNaughton, Eileen
|
||||
Murray, Joe
|
||||
Shaughnessy, Brian
|
||||
Spagarino, Andres
|
||||
Speleo
|
||||
Stuart, josh
|
||||
Tabletguy
|
||||
Watts, Danny
|
||||
Wistreich, Nic
|
||||
|
||||
****************************************
|
||||
Sponsors for 3.3 Make-it-Happen Projects
|
||||
****************************************
|
||||
The following people and organizations sponsored new and improved features for the 3.3 release.
|
||||
|
||||
JMA Consulting: http://jmaconsulting.biz/
|
||||
Emergency Picnic: http://emergencypicnic.net/
|
||||
Thomas Carlson
|
||||
Micheas Herman
|
||||
T.J. Hellman
|
||||
Gold Strategy Group: http://www.goldstrategygroup.com
|
||||
Laura Velkei
|
||||
John Barclay
|
||||
Matthew Briney: http://emotivellc.com
|
||||
2020Media: http://www.2020media.com/
|
||||
Social Contxt: http://socialcontxt.com/
|
||||
Impari Systems Inc: http://www.imparisystems.com/
|
||||
Alpha: http://uk.alpha.org
|
||||
Cambridge Union: http://www.cus.org
|
||||
St Ethelburga's: http://stethelburgas.org
|
||||
Joomkit: http://www.joomkit.com
|
||||
International Mountain Biking Association: http://www.imba.com/
|
||||
Niro Solutions: http://www.nirosolutions.com/
|
||||
Fuzion: http://fuzion.co.nz
|
||||
ArtD Webdesign
|
||||
CivicActions: http://civicactions.com/
|
||||
NES Alumni and Friends Nonprofit Partnership: https://www.nesalumni.org/en
|
||||
Gold Strategy Group: http://www.goldstrategygroup.com
|
||||
Creative Commons: http://creativecommons.org/
|
||||
Community Builders Australia Pty Ltd: http://www.communitybuilders.com.au/
|
||||
Australian Greens: http://greens.org.au/
|
||||
NES Alumni and Friends Nonprofit Partnership: https://www.nesalumni.org/en
|
||||
Data-Scribe: http://www.datascribe.biz/
|
||||
Rayogram: http://www.rayogram.com/
|
||||
GingerFeet LLC: http://www.gingerfeet.com/
|
||||
Kabissa: http://kabissa.org
|
||||
Beth Hynes-Ciernia
|
221
sites/all/modules/civicrm/CRM/ACL/API.php
Normal file
221
sites/all/modules/civicrm/CRM/ACL/API.php
Normal file
|
@ -0,0 +1,221 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_ACL_API {
|
||||
|
||||
/**
|
||||
* The various type of permissions.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const EDIT = 1;
|
||||
const VIEW = 2;
|
||||
const DELETE = 3;
|
||||
const CREATE = 4;
|
||||
const SEARCH = 5;
|
||||
const ALL = 6;
|
||||
|
||||
/**
|
||||
* Given a permission string, check for access requirements
|
||||
*
|
||||
* @param string $str
|
||||
* The permission to check.
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
*
|
||||
* @return bool
|
||||
* true if yes, else false
|
||||
*/
|
||||
public static function check($str, $contactID = NULL) {
|
||||
if ($contactID == NULL) {
|
||||
$contactID = CRM_Core_Session::getLoggedInContactID();
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
// anonymous user
|
||||
$contactID = 0;
|
||||
}
|
||||
|
||||
return CRM_ACL_BAO_ACL::check($str, $contactID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissioned where clause for the user.
|
||||
*
|
||||
* @param int $type
|
||||
* The type of permission needed.
|
||||
* @param array $tables
|
||||
* (reference ) add the tables that are needed for the select clause.
|
||||
* @param array $whereTables
|
||||
* (reference ) add the tables that are needed for the where clause.
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
* @param bool $onlyDeleted
|
||||
* Whether to include only deleted contacts.
|
||||
* @param bool $skipDeleteClause
|
||||
* Don't add delete clause if this is true,.
|
||||
* this means it is handled by generating query
|
||||
* @param bool $skipOwnContactClause
|
||||
* Do not add 'OR contact_id = $userID' to the where clause.
|
||||
* This is a hideously inefficient query and should be avoided
|
||||
* wherever possible.
|
||||
*
|
||||
* @return string
|
||||
* the group where clause for this user
|
||||
*/
|
||||
public static function whereClause(
|
||||
$type,
|
||||
&$tables,
|
||||
&$whereTables,
|
||||
$contactID = NULL,
|
||||
$onlyDeleted = FALSE,
|
||||
$skipDeleteClause = FALSE,
|
||||
$skipOwnContactClause = FALSE
|
||||
) {
|
||||
// the default value which is valid for the final AND
|
||||
$deleteClause = ' ( 1 ) ';
|
||||
if (!$skipDeleteClause) {
|
||||
if (CRM_Core_Permission::check('access deleted contacts') and $onlyDeleted) {
|
||||
$deleteClause = '(contact_a.is_deleted)';
|
||||
}
|
||||
else {
|
||||
// CRM-6181
|
||||
$deleteClause = '(contact_a.is_deleted = 0)';
|
||||
}
|
||||
}
|
||||
|
||||
// first see if the contact has edit / view all contacts
|
||||
if (CRM_Core_Permission::check('edit all contacts') ||
|
||||
($type == self::VIEW && CRM_Core_Permission::check('view all contacts'))
|
||||
) {
|
||||
return $deleteClause;
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
$contactID = CRM_Core_Session::getLoggedInContactID();
|
||||
}
|
||||
$contactID = (int) $contactID;
|
||||
|
||||
$where = implode(' AND ',
|
||||
array(
|
||||
CRM_ACL_BAO_ACL::whereClause($type,
|
||||
$tables,
|
||||
$whereTables,
|
||||
$contactID
|
||||
),
|
||||
$deleteClause,
|
||||
)
|
||||
);
|
||||
|
||||
// Add permission on self if we really hate our server or have hardly any contacts.
|
||||
if (!$skipOwnContactClause && $contactID && (CRM_Core_Permission::check('edit my contact') ||
|
||||
$type == self::VIEW && CRM_Core_Permission::check('view my contact'))
|
||||
) {
|
||||
$where = "(contact_a.id = $contactID OR ($where))";
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the groups the user has access to for the given operation.
|
||||
*
|
||||
* @param int $type
|
||||
* The type of permission needed.
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param null $allGroups
|
||||
* @param null $includedGroups
|
||||
*
|
||||
* @return array
|
||||
* the ids of the groups for which the user has permissions
|
||||
*/
|
||||
public static function group(
|
||||
$type,
|
||||
$contactID = NULL,
|
||||
$tableName = 'civicrm_saved_search',
|
||||
$allGroups = NULL,
|
||||
$includedGroups = NULL
|
||||
) {
|
||||
if ($contactID == NULL) {
|
||||
$contactID = CRM_Core_Session::getLoggedInContactID();
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
// anonymous user
|
||||
$contactID = 0;
|
||||
}
|
||||
|
||||
return CRM_ACL_BAO_ACL::group($type, $contactID, $tableName, $allGroups, $includedGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user has access to this group for operation $type
|
||||
*
|
||||
* @param int $type
|
||||
* The type of permission needed.
|
||||
* @param int $groupID
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
* @param string $tableName
|
||||
* @param null $allGroups
|
||||
* @param null $includedGroups
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function groupPermission(
|
||||
$type,
|
||||
$groupID,
|
||||
$contactID = NULL,
|
||||
$tableName = 'civicrm_saved_search',
|
||||
$allGroups = NULL,
|
||||
$includedGroups = NULL
|
||||
) {
|
||||
|
||||
if (!isset(Civi::$statics[__CLASS__]) || !isset(Civi::$statics[__CLASS__]['group_permission'])) {
|
||||
Civi::$statics[__CLASS__]['group_permission'] = array();
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
$contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
|
||||
}
|
||||
|
||||
$key = "{$tableName}_{$type}_{$contactID}";
|
||||
if (!array_key_exists($key, Civi::$statics[__CLASS__]['group_permission'])) {
|
||||
Civi::$statics[__CLASS__]['group_permission'][$key] = self::group($type, $contactID, $tableName, $allGroups, $includedGroups);
|
||||
}
|
||||
|
||||
return in_array($groupID, Civi::$statics[__CLASS__]['group_permission'][$key]);
|
||||
}
|
||||
|
||||
}
|
1006
sites/all/modules/civicrm/CRM/ACL/BAO/ACL.php
Normal file
1006
sites/all/modules/civicrm/CRM/ACL/BAO/ACL.php
Normal file
File diff suppressed because it is too large
Load diff
172
sites/all/modules/civicrm/CRM/ACL/BAO/Cache.php
Normal file
172
sites/all/modules/civicrm/CRM/ACL/BAO/Cache.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Access Control Cache.
|
||||
*/
|
||||
class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache {
|
||||
|
||||
static $_cache = NULL;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function &build($id) {
|
||||
if (!self::$_cache) {
|
||||
self::$_cache = array();
|
||||
}
|
||||
|
||||
if (array_key_exists($id, self::$_cache)) {
|
||||
return self::$_cache[$id];
|
||||
}
|
||||
|
||||
// check if this entry exists in db
|
||||
// if so retrieve and return
|
||||
self::$_cache[$id] = self::retrieve($id);
|
||||
if (self::$_cache[$id]) {
|
||||
return self::$_cache[$id];
|
||||
}
|
||||
|
||||
self::$_cache[$id] = CRM_ACL_BAO_ACL::getAllByContact($id);
|
||||
self::store($id, self::$_cache[$id]);
|
||||
return self::$_cache[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function retrieve($id) {
|
||||
$query = "
|
||||
SELECT acl_id
|
||||
FROM civicrm_acl_cache
|
||||
WHERE contact_id = %1
|
||||
";
|
||||
$params = array(1 => array($id, 'Integer'));
|
||||
|
||||
if ($id == 0) {
|
||||
$query .= " OR contact_id IS NULL";
|
||||
}
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
|
||||
$cache = array();
|
||||
while ($dao->fetch()) {
|
||||
$cache[$dao->acl_id] = 1;
|
||||
}
|
||||
return $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param array $cache
|
||||
*/
|
||||
public static function store($id, &$cache) {
|
||||
foreach ($cache as $aclID => $data) {
|
||||
$dao = new CRM_ACL_DAO_Cache();
|
||||
if ($id) {
|
||||
$dao->contact_id = $id;
|
||||
}
|
||||
$dao->acl_id = $aclID;
|
||||
|
||||
$cache[$aclID] = 1;
|
||||
|
||||
$dao->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public static function deleteEntry($id) {
|
||||
if (self::$_cache &&
|
||||
array_key_exists($id, self::$_cache)
|
||||
) {
|
||||
unset(self::$_cache[$id]);
|
||||
}
|
||||
|
||||
$query = "
|
||||
DELETE FROM civicrm_acl_cache
|
||||
WHERE contact_id = %1
|
||||
";
|
||||
$params = array(1 => array($id, 'Integer'));
|
||||
CRM_Core_DAO::executeQuery($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public static function updateEntry($id) {
|
||||
// rebuilds civicrm_acl_cache
|
||||
self::deleteEntry($id);
|
||||
self::build($id);
|
||||
|
||||
// rebuilds civicrm_acl_contact_cache
|
||||
CRM_Contact_BAO_Contact_Permission::cache($id, CRM_Core_Permission::VIEW, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all the cache entries.
|
||||
*/
|
||||
public static function resetCache() {
|
||||
if (!CRM_Core_Config::isPermitCacheFlushMode()) {
|
||||
return;
|
||||
}
|
||||
// reset any static caching
|
||||
self::$_cache = NULL;
|
||||
|
||||
$query = "
|
||||
DELETE
|
||||
FROM civicrm_acl_cache
|
||||
WHERE modified_date IS NULL
|
||||
OR (modified_date <= %1)
|
||||
";
|
||||
$params = array(1 => array(CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(), 'String'));
|
||||
CRM_Core_DAO::singleValueQuery($query, $params);
|
||||
|
||||
// CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); // No, force-commits transaction
|
||||
// CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); // Transaction-safe
|
||||
if (CRM_Core_Transaction::isActive()) {
|
||||
CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function () {
|
||||
CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache");
|
||||
});
|
||||
}
|
||||
else {
|
||||
CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
104
sites/all/modules/civicrm/CRM/ACL/BAO/EntityRole.php
Normal file
104
sites/all/modules/civicrm/CRM/ACL/BAO/EntityRole.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Access Control EntityRole.
|
||||
*/
|
||||
class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
|
||||
static $_entityTable = NULL;
|
||||
|
||||
/**
|
||||
* Get entity table.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function entityTable() {
|
||||
if (!self::$_entityTable) {
|
||||
self::$_entityTable = array(
|
||||
'civicrm_contact' => ts('Contact'),
|
||||
'civicrm_group' => ts('Group'),
|
||||
);
|
||||
}
|
||||
return self::$_entityTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return CRM_ACL_DAO_EntityRole
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
$dao = new CRM_ACL_DAO_EntityRole();
|
||||
$dao->copyValues($params);
|
||||
$dao->save();
|
||||
return $dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param $defaults
|
||||
*/
|
||||
public static function retrieve(&$params, &$defaults) {
|
||||
CRM_Core_DAO::commonRetrieve('CRM_ACL_DAO_EntityRole', $params, $defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the is_active flag in the db.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of the database record.
|
||||
* @param bool $is_active
|
||||
* Value we want to set the is_active field.
|
||||
*
|
||||
* @return Object
|
||||
* DAO object on success, null otherwise
|
||||
*/
|
||||
public static function setIsActive($id, $is_active) {
|
||||
return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Entity Role records.
|
||||
*
|
||||
* @param int $entityRoleId
|
||||
* ID of the EntityRole record to be deleted.
|
||||
*
|
||||
*/
|
||||
public static function del($entityRoleId) {
|
||||
$entityDAO = new CRM_ACL_DAO_EntityRole();
|
||||
$entityDAO->id = $entityRoleId;
|
||||
$entityDAO->find(TRUE);
|
||||
$entityDAO->delete();
|
||||
}
|
||||
|
||||
}
|
358
sites/all/modules/civicrm/CRM/ACL/DAO/ACL.php
Normal file
358
sites/all/modules/civicrm/CRM/ACL/DAO/ACL.php
Normal file
|
@ -0,0 +1,358 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/ACL/ACL.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:f56c9ad63ff247e68abf2c7c70ff65ba)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_ACL_DAO_ACL constructor.
|
||||
*/
|
||||
class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_acl';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
* Unique table ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* ACL Name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Is this ACL entry Allow (0) or Deny (1) ?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $deny;
|
||||
/**
|
||||
* Table of the object possessing this ACL entry (Contact, Group, or ACL Group)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_table;
|
||||
/**
|
||||
* ID of the object possessing this ACL
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $entity_id;
|
||||
/**
|
||||
* What operation does this ACL entry control?
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $operation;
|
||||
/**
|
||||
* The table of the object controlled by this ACL entry
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $object_table;
|
||||
/**
|
||||
* The ID of the object controlled by this ACL entry
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $object_id;
|
||||
/**
|
||||
* If this is a grant/revoke entry, what table are we granting?
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $acl_table;
|
||||
/**
|
||||
* ID of the ACL or ACL group being granted/revoked
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $acl_id;
|
||||
/**
|
||||
* Is this property active?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_acl';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL ID') ,
|
||||
'description' => 'Unique table ID',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Name') ,
|
||||
'description' => 'ACL Name.',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'deny' => array(
|
||||
'name' => 'deny',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Deny ACL?') ,
|
||||
'description' => 'Is this ACL entry Allow (0) or Deny (1) ?',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Radio',
|
||||
) ,
|
||||
) ,
|
||||
'entity_table' => array(
|
||||
'name' => 'entity_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Entity') ,
|
||||
'description' => 'Table of the object possessing this ACL entry (Contact, Group, or ACL Group)',
|
||||
'required' => true,
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'entity_id' => array(
|
||||
'name' => 'entity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Entity ID') ,
|
||||
'description' => 'ID of the object possessing this ACL',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'operation' => array(
|
||||
'name' => 'operation',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Operation') ,
|
||||
'description' => 'What operation does this ACL entry control?',
|
||||
'required' => true,
|
||||
'maxlength' => 8,
|
||||
'size' => CRM_Utils_Type::EIGHT,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_ACL_BAO_ACL::operation',
|
||||
)
|
||||
) ,
|
||||
'object_table' => array(
|
||||
'name' => 'object_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Object') ,
|
||||
'description' => 'The table of the object controlled by this ACL entry',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'object_id' => array(
|
||||
'name' => 'object_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Object ID') ,
|
||||
'description' => 'The ID of the object controlled by this ACL entry',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'acl_table' => array(
|
||||
'name' => 'acl_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Table') ,
|
||||
'description' => 'If this is a grant/revoke entry, what table are we granting?',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'acl_id' => array(
|
||||
'name' => 'acl_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Group ID') ,
|
||||
'description' => 'ID of the ACL or ACL group being granted/revoked',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('ACL Is Active?') ,
|
||||
'description' => 'Is this property active?',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
) ,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_acl_id' => array(
|
||||
'name' => 'index_acl_id',
|
||||
'field' => array(
|
||||
0 => 'acl_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl::0::acl_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
223
sites/all/modules/civicrm/CRM/ACL/DAO/Cache.php
Normal file
223
sites/all/modules/civicrm/CRM/ACL/DAO/Cache.php
Normal file
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/ACL/Cache.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:f65002b394a3b1f9c18de75751364acc)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_ACL_DAO_Cache constructor.
|
||||
*/
|
||||
class CRM_ACL_DAO_Cache extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_acl_cache';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
* Unique table ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Foreign Key to Contact
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contact_id;
|
||||
/**
|
||||
* Foreign Key to ACL
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $acl_id;
|
||||
/**
|
||||
* When was this cache entry last modified
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $modified_date;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_acl_cache';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'acl_id', 'civicrm_acl', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Cache ID') ,
|
||||
'description' => 'Unique table ID',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'contact_id' => array(
|
||||
'name' => 'contact_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Cache Contact') ,
|
||||
'description' => 'Foreign Key to Contact',
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
) ,
|
||||
'acl_id' => array(
|
||||
'name' => 'acl_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Cache ACL') ,
|
||||
'description' => 'Foreign Key to ACL',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_ACL_DAO_ACL',
|
||||
) ,
|
||||
'modified_date' => array(
|
||||
'name' => 'modified_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Cache Modified Date') ,
|
||||
'description' => 'When was this cache entry last modified',
|
||||
'required' => false,
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl_cache', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl_cache', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_acl_id' => array(
|
||||
'name' => 'index_acl_id',
|
||||
'field' => array(
|
||||
0 => 'acl_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl_cache::0::acl_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
248
sites/all/modules/civicrm/CRM/ACL/DAO/EntityRole.php
Normal file
248
sites/all/modules/civicrm/CRM/ACL/DAO/EntityRole.php
Normal file
|
@ -0,0 +1,248 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/ACL/EntityRole.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:b6780a8cf74433fd38a0c7f9e6161986)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_ACL_DAO_EntityRole constructor.
|
||||
*/
|
||||
class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_acl_entity_role';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
* Unique table ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $acl_role_id;
|
||||
/**
|
||||
* Table of the object joined to the ACL Role (Contact or Group)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_table;
|
||||
/**
|
||||
* ID of the group/contact object being joined
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $entity_id;
|
||||
/**
|
||||
* Is this property active?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_acl_entity_role';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Entity Role') ,
|
||||
'description' => 'Unique table ID',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'acl_role_id' => array(
|
||||
'name' => 'acl_role_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Role ID') ,
|
||||
'description' => 'Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'entity_table' => array(
|
||||
'name' => 'entity_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Entity Table') ,
|
||||
'description' => 'Table of the object joined to the ACL Role (Contact or Group)',
|
||||
'required' => true,
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'entity_id' => array(
|
||||
'name' => 'entity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Entity ID') ,
|
||||
'description' => 'ID of the group/contact object being joined',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('ACL Entity Role is Active') ,
|
||||
'description' => 'Is this property active?',
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl_entity_role', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl_entity_role', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_role' => array(
|
||||
'name' => 'index_role',
|
||||
'field' => array(
|
||||
0 => 'acl_role_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl_entity_role::0::acl_role_id',
|
||||
) ,
|
||||
'index_entity' => array(
|
||||
'name' => 'index_entity',
|
||||
'field' => array(
|
||||
0 => 'entity_table',
|
||||
1 => 'entity_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl_entity_role::0::entity_table::entity_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
300
sites/all/modules/civicrm/CRM/ACL/Form/ACL.php
Normal file
300
sites/all/modules/civicrm/CRM/ACL/Form/ACL.php
Normal file
|
@ -0,0 +1,300 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_ACL_Form_ACL extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
$defaults['object_type'] = 1;
|
||||
}
|
||||
|
||||
$showHide = new CRM_Core_ShowHideBlocks();
|
||||
|
||||
if (isset($defaults['object_table'])) {
|
||||
switch ($defaults['object_table']) {
|
||||
case 'civicrm_saved_search':
|
||||
$defaults['group_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 1;
|
||||
$showHide->addShow("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
break;
|
||||
|
||||
case 'civicrm_uf_group':
|
||||
$defaults['uf_group_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 2;
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addShow("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
break;
|
||||
|
||||
case 'civicrm_custom_group':
|
||||
$defaults['custom_group_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 3;
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addShow("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
break;
|
||||
|
||||
case 'civicrm_event':
|
||||
$defaults['event_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 4;
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addShow("id-event-acl");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
|
||||
// Don't assign showHide elements to template in DELETE mode (fields to be shown and hidden don't exist)
|
||||
if (!($this->_action & CRM_Core_Action::DELETE)) {
|
||||
$showHide->addToTemplate();
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
$this->setPageTitle(ts('ACL'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL');
|
||||
|
||||
$this->add('text', 'name', ts('Description'), CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL', 'name'), TRUE);
|
||||
|
||||
$operations = array('' => ts('- select -')) + CRM_ACL_BAO_ACL::operation();
|
||||
$this->add('select',
|
||||
'operation',
|
||||
ts('Operation'),
|
||||
$operations, TRUE
|
||||
);
|
||||
|
||||
$objTypes = array(
|
||||
'1' => ts('A group of contacts'),
|
||||
'2' => ts('A profile'),
|
||||
'3' => ts('A set of custom data fields'),
|
||||
);
|
||||
|
||||
if (CRM_Core_Permission::access('CiviEvent')) {
|
||||
$objTypes['4'] = ts('Events');
|
||||
}
|
||||
|
||||
$extra = array('onclick' => "showObjectSelect();");
|
||||
$this->addRadio('object_type',
|
||||
ts('Type of Data'),
|
||||
$objTypes,
|
||||
$extra,
|
||||
' ', TRUE
|
||||
);
|
||||
|
||||
$label = ts('Role');
|
||||
$role = array(
|
||||
'-1' => ts('- select role -'),
|
||||
'0' => ts('Everyone'),
|
||||
) + CRM_Core_OptionGroup::values('acl_role');
|
||||
$this->add('select', 'entity_id', $label, $role, TRUE);
|
||||
|
||||
$group = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Groups'),
|
||||
) + CRM_Core_PseudoConstant::group();
|
||||
|
||||
$customGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Custom Groups'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
|
||||
|
||||
$ufGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Profiles'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
|
||||
|
||||
$event = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Events'),
|
||||
) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
|
||||
|
||||
$this->add('select', 'group_id', ts('Group'), $group);
|
||||
$this->add('select', 'custom_group_id', ts('Custom Data'), $customGroup);
|
||||
$this->add('select', 'uf_group_id', ts('Profile'), $ufGroup);
|
||||
$this->add('select', 'event_id', ts('Event'), $event);
|
||||
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
|
||||
$this->addFormRule(array('CRM_ACL_Form_ACL', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function formRule($params) {
|
||||
$showHide = new CRM_Core_ShowHideBlocks();
|
||||
|
||||
// Make sure role is not -1
|
||||
if ($params['entity_id'] == -1) {
|
||||
$errors['entity_id'] = ts('Please assign this permission to a Role.');
|
||||
}
|
||||
|
||||
$validOperations = array('View', 'Edit');
|
||||
$operationMessage = ts("Only 'View' and 'Edit' operations are valid for this type of data");
|
||||
|
||||
// Figure out which type of object we're permissioning on and make sure user has selected a value.
|
||||
switch ($params['object_type']) {
|
||||
case 1:
|
||||
if ($params['group_id'] == -1) {
|
||||
$errors['group_id'] = ts('Please select a Group (or ALL Groups).');
|
||||
$showHide->addShow("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
if (!in_array($params['operation'], $validOperations)) {
|
||||
$errors['operation'] = $operationMessage;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ($params['uf_group_id'] == -1) {
|
||||
$errors['uf_group_id'] = ts('Please select a Profile (or ALL Profiles).');
|
||||
$showHide->addShow("id-profile-acl");
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ($params['custom_group_id'] == -1) {
|
||||
$errors['custom_group_id'] = ts('Please select a set of Custom Data (or ALL Custom Data).');
|
||||
$showHide->addShow("id-custom-acl");
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
if (!in_array($params['operation'], $validOperations)) {
|
||||
$errors['operation'] = $operationMessage;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ($params['event_id'] == -1) {
|
||||
$errors['event_id'] = ts('Please select an Event (or ALL Events).');
|
||||
$showHide->addShow("id-event-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
}
|
||||
if (!in_array($params['operation'], $validOperations)) {
|
||||
$errors['operation'] = $operationMessage;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$showHide->addToTemplate();
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// note this also resets any ACL cache
|
||||
CRM_Core_BAO_Cache::deleteGroup('contact fields');
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_ACL_BAO_ACL::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
|
||||
$params['deny'] = 0;
|
||||
$params['entity_table'] = 'civicrm_acl_role';
|
||||
|
||||
// Figure out which type of object we're permissioning on and set object_table and object_id.
|
||||
switch ($params['object_type']) {
|
||||
case 1:
|
||||
$params['object_table'] = 'civicrm_saved_search';
|
||||
$params['object_id'] = $params['group_id'];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$params['object_table'] = 'civicrm_uf_group';
|
||||
$params['object_id'] = $params['uf_group_id'];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$params['object_table'] = 'civicrm_custom_group';
|
||||
$params['object_id'] = $params['custom_group_id'];
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$params['object_table'] = 'civicrm_event';
|
||||
$params['object_id'] = $params['event_id'];
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->_id) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
CRM_ACL_BAO_ACL::create($params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
151
sites/all/modules/civicrm/CRM/ACL/Form/ACLBasic.php
Normal file
151
sites/all/modules/civicrm/CRM/ACL/Form/ACLBasic.php
Normal file
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_ACL_Form_ACLBasic extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
if ($this->_id ||
|
||||
$this->_id === '0'
|
||||
) {
|
||||
$defaults['entity_id'] = $this->_id;
|
||||
|
||||
$query = "
|
||||
SELECT object_table
|
||||
FROM civicrm_acl
|
||||
WHERE entity_id = %1
|
||||
AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
|
||||
";
|
||||
$params = array(1 => array($this->_id, 'Integer'));
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
$defaults['object_table'] = array();
|
||||
while ($dao->fetch()) {
|
||||
$defaults['object_table'][$dao->object_table] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permissions = array_flip(CRM_Core_Permission::basicPermissions());
|
||||
$this->addCheckBox('object_table',
|
||||
ts('ACL Type'),
|
||||
$permissions,
|
||||
NULL, NULL, TRUE, NULL,
|
||||
array('</td><td>', '</td></tr><tr><td>')
|
||||
);
|
||||
|
||||
$label = ts('Role');
|
||||
$role = array(
|
||||
'-1' => ts('- select role -'),
|
||||
'0' => ts('Everyone'),
|
||||
) + CRM_Core_OptionGroup::values('acl_role');
|
||||
$entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
|
||||
|
||||
if ($this->_id) {
|
||||
$entityID->freeze();
|
||||
}
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
|
||||
$this->addFormRule(array('CRM_ACL_Form_ACLBasic', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function formRule($params) {
|
||||
if ($params['entity_id'] == -1) {
|
||||
$errors = array('entity_id' => ts('Role is a required field'));
|
||||
return $errors;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_ACL_BAO_Cache::resetCache();
|
||||
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
if ($this->_id ||
|
||||
$this->_id === '0'
|
||||
) {
|
||||
$query = "
|
||||
DELETE
|
||||
FROM civicrm_acl
|
||||
WHERE entity_id = %1
|
||||
AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
|
||||
";
|
||||
$deleteParams = array(1 => array($this->_id, 'Integer'));
|
||||
CRM_Core_DAO::executeQuery($query, $deleteParams);
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Core_Session::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$params['operation'] = 'All';
|
||||
$params['deny'] = 0;
|
||||
$params['is_active'] = 1;
|
||||
$params['entity_table'] = 'civicrm_acl_role';
|
||||
$params['name'] = 'Core ACL';
|
||||
|
||||
foreach ($params['object_table'] as $object_table => $value) {
|
||||
if ($value) {
|
||||
$newParams = $params;
|
||||
unset($newParams['object_table']);
|
||||
$newParams['object_table'] = $object_table;
|
||||
CRM_ACL_BAO_ACL::create($newParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
78
sites/all/modules/civicrm/CRM/ACL/Form/EntityRole.php
Normal file
78
sites/all/modules/civicrm/CRM/ACL/Form/EntityRole.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_ACL_Form_EntityRole extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$aclRoles = array('' => ts('- select -')) + CRM_Core_OptionGroup::values('acl_role');
|
||||
$this->add('select', 'acl_role_id', ts('ACL Role'),
|
||||
$aclRoles, TRUE
|
||||
);
|
||||
|
||||
$label = ts('Assigned to');
|
||||
$group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access');
|
||||
$this->add('select', 'entity_id', $label, $group, TRUE, array('class' => 'crm-select2 huge'));
|
||||
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_ACL_BAO_Cache::resetCache();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_ACL_BAO_EntityRole::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected Entity Role has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
if ($this->_id) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
$params['entity_table'] = 'civicrm_group';
|
||||
CRM_ACL_BAO_EntityRole::create($params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
198
sites/all/modules/civicrm/CRM/ACL/Form/WordPress/Permissions.php
Normal file
198
sites/all/modules/civicrm/CRM/ACL/Form/WordPress/Permissions.php
Normal file
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to Grant access to CiviCRM components and other CiviCRM permissions.
|
||||
*/
|
||||
class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
CRM_Utils_System::setTitle('Wordpress Access Control');
|
||||
|
||||
// Get the core permissions array
|
||||
$permissionsArray = self::getPermissionArray();
|
||||
$permissionsDesc = self::getPermissionArray(TRUE);
|
||||
|
||||
// Get the wordpress roles, default capabilities and assign to the form
|
||||
// TODO: Create a new wordpress role (Anonymous user) and define capabilities in Wordpress Access Control
|
||||
global $wp_roles;
|
||||
if (!isset($wp_roles)) {
|
||||
$wp_roles = new WP_Roles();
|
||||
}
|
||||
foreach ($wp_roles->role_names as $role => $name) {
|
||||
// Dont show the permissions options for administrator, as they have all permissions
|
||||
if ($role !== 'administrator') {
|
||||
$roleObj = $wp_roles->get_role($role);
|
||||
if (!empty($roleObj->capabilities)) {
|
||||
foreach ($roleObj->capabilities as $ckey => $cname) {
|
||||
if (array_key_exists($ckey, $permissionsArray)) {
|
||||
$elementName = $role . '[' . $ckey . ']';
|
||||
$defaults[$elementName] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compose the checkbox array for each role, to assign to form
|
||||
$rolePerms[$role] = $permissionsArray;
|
||||
foreach ($rolePerms[$role] as $key => $value) {
|
||||
$elementName = $role . '[' . $key . ']';
|
||||
$this->add('checkbox', $elementName, $value);
|
||||
}
|
||||
$roles[$role] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setDefaults($defaults);
|
||||
|
||||
$descArray = array();
|
||||
foreach ($permissionsDesc as $perm => $attr) {
|
||||
if (count($attr) > 1) {
|
||||
$descArray[$perm] = $attr[1];
|
||||
}
|
||||
}
|
||||
$this->assign('permDesc', $descArray);
|
||||
$this->assign('rolePerms', $rolePerms);
|
||||
$this->assign('roles', $roles);
|
||||
|
||||
$this->addButtons(
|
||||
array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'spacing' => '',
|
||||
'isDefault' => FALSE,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$permissionsArray = self::getPermissionArray();
|
||||
|
||||
// Function to get Wordpress roles
|
||||
global $wp_roles;
|
||||
if (!isset($wp_roles)) {
|
||||
$wp_roles = new WP_Roles();
|
||||
}
|
||||
foreach ($wp_roles->role_names as $role => $name) {
|
||||
$roleObj = $wp_roles->get_role($role);
|
||||
|
||||
//Remove all civicrm capabilities for the role, as there may be some capabilities checkbox unticked
|
||||
foreach ($permissionsArray as $key => $capability) {
|
||||
$roleObj->remove_cap($key);
|
||||
}
|
||||
|
||||
//Add the selected wordpress capabilities for the role
|
||||
$rolePermissions = $params[$role];
|
||||
if (!empty($rolePermissions)) {
|
||||
foreach ($rolePermissions as $key => $capability) {
|
||||
$roleObj->add_cap($key);
|
||||
}
|
||||
}
|
||||
|
||||
if ($role == 'anonymous_user') {
|
||||
// Get the permissions into a format that matches what we get from WP
|
||||
$allWarningPermissions = CRM_Core_Permission::getAnonymousPermissionsWarnings();
|
||||
foreach ($allWarningPermissions as $key => $permission) {
|
||||
$allWarningPermissions[$key] = CRM_Utils_String::munge(strtolower($permission));
|
||||
}
|
||||
$warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions));
|
||||
$warningPermissionNames = array();
|
||||
foreach ($warningPermissions as $permission) {
|
||||
$warningPermissionNames[$permission] = $permissionsArray[$permission];
|
||||
}
|
||||
if (!empty($warningPermissionNames)) {
|
||||
CRM_Core_Session::setStatus(
|
||||
ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', array(
|
||||
1 => $wp_roles->role_names[$role],
|
||||
2 => implode(', ', $warningPermissionNames),
|
||||
)),
|
||||
ts('Unsafe Permission Settings')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// Changed the 'access_civicrm_nav_link' capability in civicrm.php file
|
||||
// But for some reason, if i remove 'Access CiviCRM' administrator and save, it is showing
|
||||
// 'You do not have sufficient permissions to access this page'
|
||||
// which should not happen for Super Admin and Administrators, as checking permissions for Super
|
||||
// Admin and Administrators always gives TRUE
|
||||
wp_civicrm_capability();
|
||||
|
||||
CRM_Core_Session::setStatus("", ts('Wordpress Access Control Updated'), "success");
|
||||
|
||||
// rebuild the menus to comply with the new permisssions/capabilites
|
||||
CRM_Core_Invoke::rebuildMenuAndCaches();
|
||||
|
||||
CRM_Utils_System::redirect('admin.php?page=CiviCRM&q=civicrm/admin/access&reset=1');
|
||||
CRM_Utils_System::civiExit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the core civicrm permissions array.
|
||||
* This function should be shared from a similar one in
|
||||
* distmaker/utils/joomlaxml.php
|
||||
*
|
||||
* @param bool $descriptions
|
||||
* Whether to return permission descriptions
|
||||
*
|
||||
* @return array
|
||||
* civicrm permissions
|
||||
*/
|
||||
public static function getPermissionArray($descriptions = FALSE) {
|
||||
global $civicrm_root;
|
||||
|
||||
$permissions = CRM_Core_Permission::basicPermissions(FALSE, $descriptions);
|
||||
|
||||
$perms_array = array();
|
||||
foreach ($permissions as $perm => $title) {
|
||||
//order matters here, but we deal with that later
|
||||
$perms_array[CRM_Utils_String::munge(strtolower($perm))] = $title;
|
||||
}
|
||||
|
||||
return $perms_array;
|
||||
}
|
||||
|
||||
}
|
262
sites/all/modules/civicrm/CRM/ACL/Page/ACL.php
Normal file
262
sites/all/modules/civicrm/CRM/ACL/Page/ACL.php
Normal file
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic {
|
||||
|
||||
public $useLivePageJS = TRUE;
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_ACL_BAO_ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/acl',
|
||||
'qs' => 'reset=1&action=update&id=%%id%%',
|
||||
'title' => ts('Edit ACL'),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Disable ACL'),
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable ACL'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/acl',
|
||||
'qs' => 'reset=1&action=delete&id=%%id%%',
|
||||
'title' => ts('Delete ACL'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* Set the breadcrumb before beginning the standard page run.
|
||||
*/
|
||||
public function run() {
|
||||
// set breadcrumb to append to admin/access
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Access Control'),
|
||||
'url' => CRM_Utils_System::url('civicrm/admin/access',
|
||||
'reset=1'
|
||||
),
|
||||
),
|
||||
);
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
|
||||
// parent run
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all acls.
|
||||
*/
|
||||
public function browse() {
|
||||
// get all acl's sorted by weight
|
||||
$acl = array();
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM civicrm_acl
|
||||
WHERE ( object_table IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group', 'civicrm_event' ) )
|
||||
ORDER BY entity_id
|
||||
";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$roles = CRM_Core_OptionGroup::values('acl_role');
|
||||
|
||||
$group = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Groups'),
|
||||
) + CRM_Core_PseudoConstant::group();
|
||||
$customGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Custom Groups'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
|
||||
$ufGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Profiles'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
|
||||
|
||||
$event = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Events'),
|
||||
) + CRM_Event_PseudoConstant::event();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$acl[$dao->id] = array();
|
||||
$acl[$dao->id]['name'] = $dao->name;
|
||||
$acl[$dao->id]['operation'] = $dao->operation;
|
||||
$acl[$dao->id]['entity_id'] = $dao->entity_id;
|
||||
$acl[$dao->id]['entity_table'] = $dao->entity_table;
|
||||
$acl[$dao->id]['object_table'] = $dao->object_table;
|
||||
$acl[$dao->id]['object_id'] = $dao->object_id;
|
||||
$acl[$dao->id]['is_active'] = $dao->is_active;
|
||||
|
||||
if ($acl[$dao->id]['entity_id']) {
|
||||
$acl[$dao->id]['entity'] = CRM_Utils_Array::value($acl[$dao->id]['entity_id'], $roles);
|
||||
}
|
||||
else {
|
||||
$acl[$dao->id]['entity'] = ts('Everyone');
|
||||
}
|
||||
|
||||
switch ($acl[$dao->id]['object_table']) {
|
||||
case 'civicrm_saved_search':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $group);
|
||||
$acl[$dao->id]['object_name'] = ts('Group');
|
||||
break;
|
||||
|
||||
case 'civicrm_uf_group':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $ufGroup);
|
||||
$acl[$dao->id]['object_name'] = ts('Profile');
|
||||
break;
|
||||
|
||||
case 'civicrm_custom_group':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $customGroup);
|
||||
$acl[$dao->id]['object_name'] = ts('Custom Group');
|
||||
break;
|
||||
|
||||
case 'civicrm_event':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $event);
|
||||
$acl[$dao->id]['object_name'] = ts('Event');
|
||||
break;
|
||||
}
|
||||
|
||||
// form all action links
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
|
||||
if ($dao->is_active) {
|
||||
$action -= CRM_Core_Action::ENABLE;
|
||||
}
|
||||
else {
|
||||
$action -= CRM_Core_Action::DISABLE;
|
||||
}
|
||||
|
||||
$acl[$dao->id]['action'] = CRM_Core_Action::formLink(
|
||||
self::links(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'ACL.manage.action',
|
||||
'ACL',
|
||||
$dao->id
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $acl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_ACL_Form_ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/acl';
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an ACL.
|
||||
*
|
||||
* @param int $mode
|
||||
* What mode for the form ?.
|
||||
* @param int $id
|
||||
* Id of the entity (for update, view operations).
|
||||
* @param bool $imageUpload
|
||||
* Not used in this case, but extended from CRM_Core_Page_Basic.
|
||||
* @param bool $pushUserContext
|
||||
* Not used in this case, but extended from CRM_Core_Page_Basic.
|
||||
*/
|
||||
public function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = TRUE) {
|
||||
if ($mode & (CRM_Core_Action::UPDATE)) {
|
||||
if (isset($id)) {
|
||||
$aclName = CRM_Core_DAO::getFieldValue('CRM_ACL_DAO_ACL', $id);
|
||||
CRM_Utils_System::setTitle(ts('Edit ACL – %1', array(1 => $aclName)));
|
||||
}
|
||||
}
|
||||
parent::edit($mode, $id, $imageUpload, $pushUserContext);
|
||||
}
|
||||
|
||||
}
|
196
sites/all/modules/civicrm/CRM/ACL/Page/ACLBasic.php
Normal file
196
sites/all/modules/civicrm/CRM/ACL/Page/ACLBasic.php
Normal file
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic {
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_ACL_BAO_ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/acl/basic',
|
||||
'qs' => 'reset=1&action=update&id=%%id%%',
|
||||
'title' => ts('Edit ACL'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/acl/basic',
|
||||
'qs' => 'reset=1&action=delete&id=%%id%%',
|
||||
'title' => ts('Delete ACL'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* This method is called after the page is created. It checks for the
|
||||
* type of action and executes that action.
|
||||
* Finally it calls the parent's run method.
|
||||
*/
|
||||
public function run() {
|
||||
$id = $this->getIdAndAction();
|
||||
|
||||
// set breadcrumb to append to admin/access
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Access Control'),
|
||||
'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'),
|
||||
),
|
||||
);
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
|
||||
// what action to take ?
|
||||
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
|
||||
$this->edit($this->_action, $id);
|
||||
}
|
||||
|
||||
// finally browse the acl's
|
||||
$this->browse();
|
||||
|
||||
// This replaces parent run, but do parent's parent run
|
||||
return CRM_Core_Page::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all acls.
|
||||
*/
|
||||
public function browse() {
|
||||
|
||||
// get all acl's sorted by weight
|
||||
$acl = array();
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM civicrm_acl
|
||||
WHERE ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
|
||||
ORDER BY entity_id
|
||||
";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$roles = CRM_Core_OptionGroup::values('acl_role');
|
||||
|
||||
$permissions = CRM_Core_Permission::basicPermissions();
|
||||
while ($dao->fetch()) {
|
||||
if (!array_key_exists($dao->entity_id, $acl)) {
|
||||
$acl[$dao->entity_id] = array();
|
||||
$acl[$dao->entity_id]['name'] = $dao->name;
|
||||
$acl[$dao->entity_id]['entity_id'] = $dao->entity_id;
|
||||
$acl[$dao->entity_id]['entity_table'] = $dao->entity_table;
|
||||
$acl[$dao->entity_id]['object_table'] = CRM_Utils_Array::value($dao->object_table, $permissions);
|
||||
$acl[$dao->entity_id]['is_active'] = 1;
|
||||
|
||||
if ($acl[$dao->entity_id]['entity_id']) {
|
||||
$acl[$dao->entity_id]['entity'] = $roles[$acl[$dao->entity_id]['entity_id']];
|
||||
}
|
||||
else {
|
||||
$acl[$dao->entity_id]['entity'] = ts('Any Role');
|
||||
}
|
||||
|
||||
// form all action links
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
|
||||
$acl[$dao->entity_id]['action'] = CRM_Core_Action::formLink(
|
||||
self::links(),
|
||||
$action,
|
||||
array('id' => $dao->entity_id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'aclRole.manage.action',
|
||||
'ACLRole',
|
||||
$dao->entity_id
|
||||
);
|
||||
}
|
||||
elseif (!empty($permissions[$dao->object_table])) {
|
||||
$acl[$dao->entity_id]['object_table'] .= ", {$permissions[$dao->object_table]}";
|
||||
}
|
||||
}
|
||||
$this->assign('rows', $acl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_ACL_Form_ACLBasic';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'Core ACLs';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/acl/basic';
|
||||
}
|
||||
|
||||
}
|
206
sites/all/modules/civicrm/CRM/ACL/Page/EntityRole.php
Normal file
206
sites/all/modules/civicrm/CRM/ACL/Page/EntityRole.php
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic {
|
||||
|
||||
public $useLivePageJS = TRUE;
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_ACL_BAO_EntityRole';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/acl/entityrole',
|
||||
'qs' => 'action=update&id=%%id%%',
|
||||
'title' => ts('Edit ACL Role Assignment'),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Disable ACL Role Assignment'),
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable ACL Role Assignment'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/acl/entityrole',
|
||||
'qs' => 'action=delete&id=%%id%%',
|
||||
'title' => ts('Delete ACL Role Assignment'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* This method is called after the page is created. It checks for the
|
||||
* type of action and executes that action.
|
||||
* Finally it calls the parent's run method.
|
||||
*/
|
||||
public function run() {
|
||||
$id = $this->getIdAndAction();
|
||||
|
||||
// set breadcrumb to append to admin/access
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Access Control'),
|
||||
'url' => CRM_Utils_System::url('civicrm/admin/access',
|
||||
'reset=1'
|
||||
),
|
||||
),
|
||||
);
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
CRM_Utils_System::setTitle(ts('Assign Users to Roles'));
|
||||
|
||||
// what action to take ?
|
||||
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
|
||||
$this->edit($this->_action, $id);
|
||||
}
|
||||
|
||||
// reset cache if enabled/disabled
|
||||
if ($this->_action & (CRM_Core_Action::DISABLE | CRM_Core_Action::ENABLE)) {
|
||||
CRM_ACL_BAO_Cache::resetCache();
|
||||
}
|
||||
|
||||
// finally browse the acl's
|
||||
if ($this->_action & CRM_Core_Action::BROWSE) {
|
||||
$this->browse();
|
||||
}
|
||||
|
||||
// This replaces parent run, but do parent's parent run
|
||||
return CRM_Core_Page::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all acls.
|
||||
*/
|
||||
public function browse() {
|
||||
|
||||
// get all acl's sorted by weight
|
||||
$entityRoles = array();
|
||||
$dao = new CRM_ACL_DAO_EntityRole();
|
||||
$dao->find();
|
||||
|
||||
$aclRoles = CRM_Core_OptionGroup::values('acl_role');
|
||||
$groups = CRM_Core_PseudoConstant::staticGroup();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$entityRoles[$dao->id] = array();
|
||||
CRM_Core_DAO::storeValues($dao, $entityRoles[$dao->id]);
|
||||
|
||||
$entityRoles[$dao->id]['acl_role'] = CRM_Utils_Array::value($dao->acl_role_id, $aclRoles);
|
||||
$entityRoles[$dao->id]['entity'] = $groups[$dao->entity_id];
|
||||
|
||||
// form all action links
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
if ($dao->is_active) {
|
||||
$action -= CRM_Core_Action::ENABLE;
|
||||
}
|
||||
else {
|
||||
$action -= CRM_Core_Action::DISABLE;
|
||||
}
|
||||
|
||||
$entityRoles[$dao->id]['action'] = CRM_Core_Action::formLink(
|
||||
self::links(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'entityRole.manage.action',
|
||||
'EntityRole',
|
||||
$dao->id
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $entityRoles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_ACL_Form_EntityRole';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'ACL EntityRole';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/acl/entityrole';
|
||||
}
|
||||
|
||||
}
|
138
sites/all/modules/civicrm/CRM/Activity/ActionMapping.php
Normal file
138
sites/all/modules/civicrm/CRM/Activity/ActionMapping.php
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
use Civi\ActionSchedule\RecipientBuilder;
|
||||
|
||||
/**
|
||||
* Class CRM_Activity_ActionMapping
|
||||
*
|
||||
* This defines the scheduled-reminder functionality for contact
|
||||
* entities. It is useful for, e.g., sending a reminder based on
|
||||
* birth date, modification date, or other custom dates on
|
||||
* the contact record.
|
||||
*/
|
||||
class CRM_Activity_ActionMapping extends \Civi\ActionSchedule\Mapping {
|
||||
|
||||
/**
|
||||
* The value for civicrm_action_schedule.mapping_id which identifies the
|
||||
* "Activity" mapping.
|
||||
*
|
||||
* Note: This value is chosen to match legacy DB IDs.
|
||||
*/
|
||||
const ACTIVITY_MAPPING_ID = 1;
|
||||
|
||||
/**
|
||||
* Register Activity-related action mappings.
|
||||
*
|
||||
* @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations
|
||||
*/
|
||||
public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) {
|
||||
$registrations->register(CRM_Activity_ActionMapping::create(array(
|
||||
'id' => CRM_Activity_ActionMapping::ACTIVITY_MAPPING_ID,
|
||||
'entity' => 'civicrm_activity',
|
||||
'entity_label' => ts('Activity'),
|
||||
'entity_value' => 'activity_type',
|
||||
'entity_value_label' => ts('Activity Type'),
|
||||
'entity_status' => 'activity_status',
|
||||
'entity_status_label' => ts('Activity Status'),
|
||||
'entity_date_start' => 'activity_date_time',
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of recipient types.
|
||||
*
|
||||
* Note: A single schedule may filter on *zero* or *one* recipient types.
|
||||
* When an admin chooses a value, it's stored in $schedule->recipient.
|
||||
*
|
||||
* @return array
|
||||
* array(string $value => string $label).
|
||||
* Ex: array('assignee' => 'Activity Assignee').
|
||||
*/
|
||||
public function getRecipientTypes() {
|
||||
return \CRM_Core_OptionGroup::values('activity_contacts');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a query to locate recipients who match the given
|
||||
* schedule.
|
||||
*
|
||||
* @param \CRM_Core_DAO_ActionSchedule $schedule
|
||||
* The schedule as configured by the administrator.
|
||||
* @param string $phase
|
||||
* See, e.g., RecipientBuilder::PHASE_RELATION_FIRST.
|
||||
*
|
||||
* @param array $defaultParams
|
||||
*
|
||||
* @return \CRM_Utils_SQL_Select
|
||||
* @see RecipientBuilder
|
||||
*/
|
||||
public function createQuery($schedule, $phase, $defaultParams) {
|
||||
$selectedValues = (array) \CRM_Utils_Array::explodePadded($schedule->entity_value);
|
||||
$selectedStatuses = (array) \CRM_Utils_Array::explodePadded($schedule->entity_status);
|
||||
|
||||
$query = \CRM_Utils_SQL_Select::from("{$this->entity} e")->param($defaultParams);
|
||||
$query['casAddlCheckFrom'] = 'civicrm_activity e';
|
||||
$query['casContactIdField'] = 'r.contact_id';
|
||||
$query['casEntityIdField'] = 'e.id';
|
||||
$query['casContactTableAlias'] = NULL;
|
||||
$query['casDateField'] = 'e.activity_date_time';
|
||||
|
||||
if (!is_null($schedule->limit_to)) {
|
||||
$activityContacts = \CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
if ($schedule->limit_to == 0 || !isset($activityContacts[$schedule->recipient])) {
|
||||
$recipientTypeId = \CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
}
|
||||
else {
|
||||
$recipientTypeId = $schedule->recipient;
|
||||
}
|
||||
$query->join('r', "INNER JOIN civicrm_activity_contact r ON r.activity_id = e.id AND record_type_id = {$recipientTypeId}");
|
||||
}
|
||||
// build where clause
|
||||
if (!empty($selectedValues)) {
|
||||
$query->where("e.activity_type_id IN (#selectedValues)")
|
||||
->param('selectedValues', $selectedValues);
|
||||
}
|
||||
else {
|
||||
$query->where("e.activity_type_id IS NULL");
|
||||
}
|
||||
|
||||
if (!empty($selectedStatuses)) {
|
||||
$query->where("e.status_id IN (#selectedStatuss)")
|
||||
->param('selectedStatuss', $selectedStatuses);
|
||||
}
|
||||
$query->where('e.is_current_revision = 1 AND e.is_deleted = 0');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
}
|
3134
sites/all/modules/civicrm/CRM/Activity/BAO/Activity.php
Normal file
3134
sites/all/modules/civicrm/CRM/Activity/BAO/Activity.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is for activity assignment functions.
|
||||
*/
|
||||
class CRM_Activity_BAO_ActivityAssignment extends CRM_Activity_DAO_ActivityContact {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add activity assignment.
|
||||
*
|
||||
* @param array $params
|
||||
* (reference ) an assoc array of name/value pairs.
|
||||
*
|
||||
* @return object
|
||||
* activity type of object that is added
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
$assignment = new CRM_Activity_BAO_ActivityContact();
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
|
||||
$assignment->copyValues($params);
|
||||
$assignment->record_type_id = $assigneeID;
|
||||
|
||||
return $assignment->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve assignee_id by activity_id.
|
||||
*
|
||||
* @param int $activity_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function retrieveAssigneeIdsByActivityId($activity_id) {
|
||||
$assigneeArray = array();
|
||||
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
|
||||
return $assigneeArray;
|
||||
}
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
|
||||
$sql = "
|
||||
SELECT contact_id
|
||||
FROM civicrm_activity_contact
|
||||
INNER JOIN civicrm_contact ON contact_id = civicrm_contact.id
|
||||
WHERE activity_id = %1
|
||||
AND record_type_id = $assigneeID
|
||||
AND civicrm_contact.is_deleted = 0
|
||||
";
|
||||
$assignment = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer')));
|
||||
while ($assignment->fetch()) {
|
||||
$assigneeArray[] = $assignment->contact_id;
|
||||
}
|
||||
|
||||
return $assigneeArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve assignee names by activity_id.
|
||||
*
|
||||
* @param array $activityIDs
|
||||
* IDs of the activities.
|
||||
* @param bool $isDisplayName
|
||||
* If set returns display names of assignees.
|
||||
* @param bool $skipDetails
|
||||
* If false returns all details of assignee contact.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAssigneeNames($activityIDs, $isDisplayName = FALSE, $skipDetails = TRUE) {
|
||||
$assigneeNames = array();
|
||||
if (empty($activityIDs)) {
|
||||
return $assigneeNames;
|
||||
}
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
|
||||
$whereClause = "";
|
||||
if (!$skipDetails) {
|
||||
$whereClause = " AND ce.is_primary= 1";
|
||||
}
|
||||
$inClause = implode(",", $activityIDs);
|
||||
|
||||
$query = "
|
||||
SELECT contact_a.id, contact_a.sort_name, contact_a.display_name, ce.email,
|
||||
civicrm_activity_contact.activity_id
|
||||
FROM civicrm_contact contact_a
|
||||
INNER JOIN civicrm_activity_contact ON civicrm_activity_contact.contact_id = contact_a.id
|
||||
LEFT JOIN civicrm_email ce ON ce.contact_id = contact_a.id
|
||||
WHERE civicrm_activity_contact.activity_id IN ( $inClause )
|
||||
AND contact_a.is_deleted = 0
|
||||
AND civicrm_activity_contact.record_type_id = $assigneeID
|
||||
{$whereClause}
|
||||
";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
while ($dao->fetch()) {
|
||||
if (!$isDisplayName) {
|
||||
$assigneeNames[$dao->id] = $dao->sort_name;
|
||||
}
|
||||
else {
|
||||
if ($skipDetails) {
|
||||
$assigneeNames[$dao->id] = $dao->display_name;
|
||||
}
|
||||
else {
|
||||
$assigneeNames[$dao->id]['contact_id'] = $dao->id;
|
||||
$assigneeNames[$dao->id]['display_name'] = $dao->display_name;
|
||||
$assigneeNames[$dao->id]['sort_name'] = $dao->sort_name;
|
||||
$assigneeNames[$dao->id]['email'] = $dao->email;
|
||||
$assigneeNames[$dao->id]['role'] = ts('Activity Assignee');
|
||||
$assigneeNames[$dao->id]['activity_id'] = $dao->activity_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $assigneeNames;
|
||||
}
|
||||
|
||||
}
|
159
sites/all/modules/civicrm/CRM/Activity/BAO/ActivityContact.php
Normal file
159
sites/all/modules/civicrm/CRM/Activity/BAO/ActivityContact.php
Normal file
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is for activity assignment functions.
|
||||
*/
|
||||
class CRM_Activity_BAO_ActivityContact extends CRM_Activity_DAO_ActivityContact {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add activity contact.
|
||||
*
|
||||
* @param array $params
|
||||
* The values for this table: activity id, contact id, record type.
|
||||
*
|
||||
* @return object
|
||||
* activity_contact object
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
$activityContact = new CRM_Activity_DAO_ActivityContact();
|
||||
|
||||
$activityContact->copyValues($params);
|
||||
if (!$activityContact->find(TRUE)) {
|
||||
return $activityContact->save();
|
||||
}
|
||||
return $activityContact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve names of contact by activity_id.
|
||||
*
|
||||
* @param int $activityID
|
||||
* @param int $recordTypeID
|
||||
* @param bool $alsoIDs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getNames($activityID, $recordTypeID, $alsoIDs = FALSE) {
|
||||
$names = array();
|
||||
$ids = array();
|
||||
|
||||
if (empty($activityID)) {
|
||||
return $alsoIDs ? array($names, $ids) : $names;
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT contact_a.id, contact_a.sort_name
|
||||
FROM civicrm_contact contact_a
|
||||
INNER JOIN civicrm_activity_contact ON civicrm_activity_contact.contact_id = contact_a.id
|
||||
WHERE civicrm_activity_contact.activity_id = %1
|
||||
AND civicrm_activity_contact.record_type_id = %2
|
||||
AND contact_a.is_deleted = 0
|
||||
";
|
||||
$params = array(
|
||||
1 => array($activityID, 'Integer'),
|
||||
2 => array($recordTypeID, 'Integer'),
|
||||
);
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
while ($dao->fetch()) {
|
||||
$names[$dao->id] = $dao->sort_name;
|
||||
$ids[] = $dao->id;
|
||||
}
|
||||
|
||||
return $alsoIDs ? array($names, $ids) : $names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve id of target contact by activity_id.
|
||||
*
|
||||
* @param int $activityID
|
||||
* @param int $recordTypeID
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function retrieveContactIdsByActivityId($activityID, $recordTypeID) {
|
||||
$activityContact = array();
|
||||
if (!CRM_Utils_Rule::positiveInteger($activityID) ||
|
||||
!CRM_Utils_Rule::positiveInteger($recordTypeID)
|
||||
) {
|
||||
return $activityContact;
|
||||
}
|
||||
|
||||
$sql = " SELECT contact_id
|
||||
FROM civicrm_activity_contact
|
||||
INNER JOIN civicrm_contact ON contact_id = civicrm_contact.id
|
||||
WHERE activity_id = %1
|
||||
AND record_type_id = %2
|
||||
AND civicrm_contact.is_deleted = 0
|
||||
";
|
||||
$params = array(
|
||||
1 => array($activityID, 'Integer'),
|
||||
2 => array($recordTypeID, 'Integer'),
|
||||
);
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($sql, $params);
|
||||
while ($dao->fetch()) {
|
||||
$activityContact[] = $dao->contact_id;
|
||||
}
|
||||
return $activityContact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the links associate array as defined by the links.ini file.
|
||||
*
|
||||
* Experimental... -
|
||||
* Should look a bit like
|
||||
* [local_col_name] => "related_tablename:related_col_name"
|
||||
*
|
||||
* @see DB_DataObject::getLinks()
|
||||
* @see DB_DataObject::getLink()
|
||||
*
|
||||
* @return array|null
|
||||
* array = if there are links defined for this table.
|
||||
* empty array - if there is a links.ini file, but no links on this table
|
||||
* null - if no links.ini exists for this database (hence try auto_links).
|
||||
*/
|
||||
public function links() {
|
||||
$link = array('activity_id' => 'civicrm_activity:id');
|
||||
return $link;
|
||||
}
|
||||
|
||||
}
|
129
sites/all/modules/civicrm/CRM/Activity/BAO/ActivityTarget.php
Normal file
129
sites/all/modules/civicrm/CRM/Activity/BAO/ActivityTarget.php
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is for activity assignment functions.
|
||||
*/
|
||||
class CRM_Activity_BAO_ActivityTarget extends CRM_Activity_DAO_ActivityContact {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add activity target.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return object
|
||||
* activity type of object that is added
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
$target = new CRM_Activity_BAO_ActivityContact();
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
|
||||
$target->copyValues($params);
|
||||
$target->record_type_id = $targetID;
|
||||
return $target->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve id of target contact by activity_id.
|
||||
*
|
||||
* @param int $activity_id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function retrieveTargetIdsByActivityId($activity_id) {
|
||||
$targetArray = array();
|
||||
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
|
||||
return $targetArray;
|
||||
}
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
|
||||
$sql = "
|
||||
SELECT contact_id
|
||||
FROM civicrm_activity_contact
|
||||
INNER JOIN civicrm_contact ON contact_id = civicrm_contact.id
|
||||
WHERE activity_id = %1
|
||||
AND record_type_id = $targetID
|
||||
AND civicrm_contact.is_deleted = 0
|
||||
";
|
||||
$target = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer')));
|
||||
while ($target->fetch()) {
|
||||
$targetArray[] = $target->contact_id;
|
||||
}
|
||||
return $targetArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve names of target contact by activity_id.
|
||||
*
|
||||
* @param int $activityID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTargetNames($activityID) {
|
||||
$targetNames = array();
|
||||
|
||||
if (empty($activityID)) {
|
||||
return $targetNames;
|
||||
}
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
|
||||
$query = "
|
||||
SELECT contact_a.id, contact_a.sort_name
|
||||
FROM civicrm_contact contact_a
|
||||
INNER JOIN civicrm_activity_contact ON civicrm_activity_contact.contact_id = contact_a.id
|
||||
WHERE civicrm_activity_contact.activity_id = %1
|
||||
AND civicrm_activity_contact.record_type_id = $targetID
|
||||
AND contact_a.is_deleted = 0
|
||||
";
|
||||
$queryParam = array(1 => array($activityID, 'Integer'));
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $queryParam);
|
||||
while ($dao->fetch()) {
|
||||
$targetNames[$dao->id] = $dao->sort_name;
|
||||
}
|
||||
|
||||
return $targetNames;
|
||||
}
|
||||
|
||||
}
|
137
sites/all/modules/civicrm/CRM/Activity/BAO/ICalendar.php
Normal file
137
sites/all/modules/civicrm/CRM/Activity/BAO/ICalendar.php
Normal file
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate ical invites for activities.
|
||||
*/
|
||||
class CRM_Activity_BAO_ICalendar {
|
||||
|
||||
/**
|
||||
* @var object The activity for which we're generating ical.
|
||||
*/
|
||||
protected $activity;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object $act
|
||||
* Reference to an activity object.
|
||||
*
|
||||
* @return \CRM_Activity_BAO_ICalendar
|
||||
*/
|
||||
public function __construct(&$act) {
|
||||
$this->activity = $act;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an ics attachment to the input array.
|
||||
*
|
||||
* @param array $attachments
|
||||
* Reference to array in same format returned from CRM_Core_BAO_File::getEntityFile().
|
||||
* @param array $contacts
|
||||
* Array of contacts (attendees).
|
||||
*
|
||||
* @return string|null
|
||||
* Array index of the added attachment in the $attachments array, else NULL.
|
||||
*/
|
||||
public function addAttachment(&$attachments, $contacts) {
|
||||
// Check preferences setting
|
||||
if (Civi::settings()->get('activity_assignee_notification_ics')) {
|
||||
$config = &CRM_Core_Config::singleton();
|
||||
$this->icsfile = tempnam($config->customFileUploadDir, 'ics');
|
||||
if ($this->icsfile !== FALSE) {
|
||||
rename($this->icsfile, $this->icsfile . '.ics');
|
||||
$this->icsfile .= '.ics';
|
||||
$icsFileName = basename($this->icsfile);
|
||||
|
||||
// get logged in user's primary email
|
||||
// TODO: Is there a better way to do this?
|
||||
$organizer = $this->getPrimaryEmail();
|
||||
|
||||
$template = CRM_Core_Smarty::singleton();
|
||||
$template->assign('activity', $this->activity);
|
||||
$template->assign('organizer', $organizer);
|
||||
$template->assign('contacts', $contacts);
|
||||
$template->assign('timezone', date_default_timezone_get());
|
||||
$calendar = $template->fetch('CRM/Activity/Calendar/ICal.tpl');
|
||||
if (file_put_contents($this->icsfile, $calendar) !== FALSE) {
|
||||
if (empty($attachments)) {
|
||||
$attachments = array();
|
||||
}
|
||||
$attachments['activity_ics'] = array(
|
||||
'mime_type' => 'text/calendar',
|
||||
'fileName' => $icsFileName,
|
||||
'cleanName' => $icsFileName,
|
||||
'fullPath' => $this->icsfile,
|
||||
);
|
||||
return 'activity_ics';
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove temp file.
|
||||
*/
|
||||
public function cleanup() {
|
||||
if (!empty ($this->icsfile)) {
|
||||
@unlink($this->icsfile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Is there a better way to do this?
|
||||
* @return string
|
||||
*/
|
||||
private function getPrimaryEmail() {
|
||||
$uid = CRM_Core_Session::getLoggedInContactID();
|
||||
$primary = '';
|
||||
$emails = CRM_Core_BAO_Email::allEmails($uid);
|
||||
foreach ($emails as $eid => $e) {
|
||||
if ($e['is_primary']) {
|
||||
if ($e['email']) {
|
||||
$primary = $e['email'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($emails) == 1) {
|
||||
$primary = $e['email'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $primary;
|
||||
}
|
||||
|
||||
}
|
652
sites/all/modules/civicrm/CRM/Activity/BAO/Query.php
Normal file
652
sites/all/modules/civicrm/CRM/Activity/BAO/Query.php
Normal file
|
@ -0,0 +1,652 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Activity_BAO_Query {
|
||||
|
||||
/**
|
||||
* Build select for Case.
|
||||
*
|
||||
* @param CRM_Contact_BAO_Query $query
|
||||
*/
|
||||
public static function select(&$query) {
|
||||
if (!empty($query->_returnProperties['activity_id'])) {
|
||||
$query->_select['activity_id'] = 'civicrm_activity.id as activity_id';
|
||||
$query->_element['activity_id'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_type_id'])) {
|
||||
$query->_select['activity_type_id'] = 'activity_type.value as activity_type_id';
|
||||
$query->_element['activity_type_id'] = 1;
|
||||
$query->_tables['civicrm_activity'] = 1;
|
||||
$query->_tables['activity_type'] = 1;
|
||||
$query->_whereTables['civicrm_activity'] = 1;
|
||||
$query->_whereTables['activity_type'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_type'])) {
|
||||
$query->_select['activity_type'] = 'activity_type.label as activity_type';
|
||||
$query->_element['activity_type'] = 1;
|
||||
$query->_tables['civicrm_activity'] = 1;
|
||||
$query->_tables['activity_type'] = 1;
|
||||
$query->_whereTables['civicrm_activity'] = 1;
|
||||
$query->_whereTables['activity_type'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_subject'])) {
|
||||
$query->_select['activity_subject'] = 'civicrm_activity.subject as activity_subject';
|
||||
$query->_element['activity_subject'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_date_time'])) {
|
||||
$query->_select['activity_date_time'] = 'civicrm_activity.activity_date_time as activity_date_time';
|
||||
$query->_element['activity_date_time'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_status_id'])) {
|
||||
$query->_select['activity_status_id'] = 'civicrm_activity.status_id as activity_status_id';
|
||||
$query->_element['activity_status_id'] = 1;
|
||||
$query->_tables['civicrm_activity'] = 1;
|
||||
$query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_status'])) {
|
||||
$query->_select['activity_status'] = 'activity_status.label as activity_status,
|
||||
civicrm_activity.status_id as status_id';
|
||||
$query->_element['activity_status'] = 1;
|
||||
$query->_tables['civicrm_activity'] = 1;
|
||||
$query->_tables['activity_status'] = 1;
|
||||
$query->_whereTables['civicrm_activity'] = 1;
|
||||
$query->_whereTables['activity_status'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_duration'])) {
|
||||
$query->_select['activity_duration'] = 'civicrm_activity.duration as activity_duration';
|
||||
$query->_element['activity_duration'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_location'])) {
|
||||
$query->_select['activity_location'] = 'civicrm_activity.location as activity_location';
|
||||
$query->_element['activity_location'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_details'])) {
|
||||
$query->_select['activity_details'] = 'civicrm_activity.details as activity_details';
|
||||
$query->_element['activity_details'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['source_record_id'])) {
|
||||
$query->_select['source_record_id'] = 'civicrm_activity.source_record_id as source_record_id';
|
||||
$query->_element['source_record_id'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_is_test'])) {
|
||||
$query->_select['activity_is_test'] = 'civicrm_activity.is_test as activity_is_test';
|
||||
$query->_element['activity_is_test'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_campaign_id'])) {
|
||||
$query->_select['activity_campaign_id'] = 'civicrm_activity.campaign_id as activity_campaign_id';
|
||||
$query->_element['activity_campaign_id'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_engagement_level'])) {
|
||||
$query->_select['activity_engagement_level'] = 'civicrm_activity.engagement_level as activity_engagement_level';
|
||||
$query->_element['activity_engagement_level'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['source_contact'])) {
|
||||
$query->_select['source_contact'] = 'source_contact.sort_name as source_contact';
|
||||
$query->_element['source_contact'] = 1;
|
||||
$query->_tables['source_contact'] = $query->_whereTables['source_contact'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_result'])) {
|
||||
$query->_select['activity_result'] = 'civicrm_activity.result as activity_result';
|
||||
$query->_element['result'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
|
||||
if (CRM_Utils_Array::value('parent_id', $query->_returnProperties)) {
|
||||
$query->_tables['parent_id'] = 1;
|
||||
$query->_whereTables['parent_id'] = 1;
|
||||
$query->_element['parent_id'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($query->_returnProperties['activity_priority'])) {
|
||||
$query->_select['activity_priority'] = 'activity_priority.label as activity_priority,
|
||||
civicrm_activity.priority_id as priority_id';
|
||||
$query->_element['activity_priority'] = 1;
|
||||
$query->_tables['activity_priority'] = 1;
|
||||
$query->_whereTables['activity_priority'] = 1;
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a list of conditions in query generate the required where clause.
|
||||
*
|
||||
* @param $query
|
||||
*/
|
||||
public static function where(&$query) {
|
||||
foreach (array_keys($query->_params) as $id) {
|
||||
if (substr($query->_params[$id][0], 0, 9) == 'activity_') {
|
||||
if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
|
||||
$query->_useDistinct = TRUE;
|
||||
}
|
||||
$query->_params[$id][3];
|
||||
self::whereClauseSingle($query->_params[$id], $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Where clause for a single field.
|
||||
*
|
||||
* @param array $values
|
||||
* @param CRM_Contact_BAO_Query $query
|
||||
*/
|
||||
public static function whereClauseSingle(&$values, &$query) {
|
||||
list($name, $op, $value, $grouping) = $values;
|
||||
|
||||
$fields = CRM_Activity_BAO_Activity::exportableFields();
|
||||
$query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1;
|
||||
if ($query->_mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
|
||||
$query->_skipDeleteClause = TRUE;
|
||||
}
|
||||
|
||||
switch ($name) {
|
||||
case 'activity_type_id':
|
||||
case 'activity_status_id':
|
||||
case 'activity_engagement_level':
|
||||
case 'activity_id':
|
||||
case 'activity_campaign_id':
|
||||
case 'activity_priority_id':
|
||||
// We no longer expect "subject" as a specific criteria (as of CRM-19447),
|
||||
// but we still use activity_subject in Activity.Get API
|
||||
case 'activity_subject':
|
||||
|
||||
$qillName = $name;
|
||||
if (in_array($name, array('activity_engagement_level', 'activity_id'))) {
|
||||
$name = $qillName = str_replace('activity_', '', $name);
|
||||
}
|
||||
if (in_array($name, array('activity_status_id', 'activity_subject', 'activity_priority_id'))) {
|
||||
$name = str_replace('activity_', '', $name);
|
||||
$qillName = str_replace('_id', '', $qillName);
|
||||
}
|
||||
if ($name == 'activity_campaign_id') {
|
||||
$name = 'campaign_id';
|
||||
}
|
||||
|
||||
$dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
|
||||
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.$name", $op, $value, $dataType);
|
||||
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op);
|
||||
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
|
||||
break;
|
||||
|
||||
case 'activity_text':
|
||||
self::whereClauseSingleActivityText($values, $query);
|
||||
break;
|
||||
|
||||
case 'activity_type':
|
||||
case 'activity_status':
|
||||
case 'activity_priority':
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, 'String');
|
||||
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op);
|
||||
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value));
|
||||
$query->_tables[$name] = $query->_whereTables[$name] = 1;
|
||||
break;
|
||||
|
||||
case 'activity_survey_id':
|
||||
if (!$value) {
|
||||
break;
|
||||
}
|
||||
$value = CRM_Utils_Type::escape($value, 'Integer');
|
||||
$query->_where[$grouping][] = " civicrm_activity.source_record_id = $value";
|
||||
$query->_qill[$grouping][] = ts('Survey') . ' - ' . CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $value, 'title');
|
||||
break;
|
||||
|
||||
case 'activity_role':
|
||||
CRM_Contact_BAO_Query::$_activityRole = $values[2];
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
|
||||
if ($values[2]) {
|
||||
$query->_tables['civicrm_activity_contact'] = $query->_whereTables['civicrm_activity_contact'] = 1;
|
||||
if ($values[2] == 1) {
|
||||
$query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $sourceID";
|
||||
$query->_qill[$grouping][] = ts('Activity created by');
|
||||
}
|
||||
elseif ($values[2] == 2) {
|
||||
$query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $assigneeID";
|
||||
$query->_qill[$grouping][] = ts('Activity assigned to');
|
||||
}
|
||||
elseif ($values[2] == 3) {
|
||||
$query->_where[$grouping][] = " civicrm_activity_contact.record_type_id = $targetID";
|
||||
$query->_qill[$grouping][] = ts('Activity targeted to');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'activity_test':
|
||||
// We don't want to include all tests for sql OR CRM-7827
|
||||
if (!$value || $query->getOperator() != 'OR') {
|
||||
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.is_test", $op, $value, "Boolean");
|
||||
if ($value) {
|
||||
$query->_qill[$grouping][] = ts('Activity is a Test');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'activity_date':
|
||||
case 'activity_date_low':
|
||||
case 'activity_date_high':
|
||||
$query->dateQueryBuilder($values,
|
||||
'civicrm_activity', 'activity_date', 'activity_date_time', ts('Activity Date')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'activity_taglist':
|
||||
$taglist = $value;
|
||||
$value = array();
|
||||
foreach ($taglist as $val) {
|
||||
if ($val) {
|
||||
$val = explode(',', $val);
|
||||
foreach ($val as $tId) {
|
||||
if (is_numeric($tId)) {
|
||||
$value[$tId] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case 'activity_tags':
|
||||
$value = array_keys($value);
|
||||
$activityTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
|
||||
|
||||
$names = array();
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
$names[] = $activityTags[$v];
|
||||
}
|
||||
}
|
||||
$query->_where[$grouping][] = "civicrm_activity_tag.tag_id IN (" . implode(",", $value) . ")";
|
||||
$query->_qill[$grouping][] = ts('Activity Tag %1', array(1 => $op)) . ' ' . implode(' ' . ts('OR') . ' ', $names);
|
||||
$query->_tables['civicrm_activity_tag'] = $query->_whereTables['civicrm_activity_tag'] = 1;
|
||||
break;
|
||||
|
||||
case 'activity_result':
|
||||
if (is_array($value)) {
|
||||
$safe = NULL;
|
||||
while (list(, $k) = each($value)) {
|
||||
$safe[] = "'" . CRM_Utils_Type::escape($k, 'String') . "'";
|
||||
}
|
||||
$query->_where[$grouping][] = "civicrm_activity.result IN (" . implode(',', $safe) . ")";
|
||||
$query->_qill[$grouping][] = ts("Activity Result - %1", array(1 => implode(' or ', $safe)));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'parent_id':
|
||||
if ($value == 1) {
|
||||
$query->_where[$grouping][] = "parent_id.parent_id IS NOT NULL";
|
||||
$query->_qill[$grouping][] = ts('Activities which have Followup Activities');
|
||||
}
|
||||
elseif ($value == 2) {
|
||||
$query->_where[$grouping][] = "parent_id.parent_id IS NULL";
|
||||
$query->_qill[$grouping][] = ts('Activities without Followup Activities');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'followup_parent_id':
|
||||
if ($value == 1) {
|
||||
$query->_where[$grouping][] = "civicrm_activity.parent_id IS NOT NULL";
|
||||
$query->_qill[$grouping][] = ts('Activities which are Followup Activities');
|
||||
}
|
||||
elseif ($value == 2) {
|
||||
$query->_where[$grouping][] = "civicrm_activity.parent_id IS NULL";
|
||||
$query->_qill[$grouping][] = ts('Activities which are not Followup Activities');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $mode
|
||||
* @param $side
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public static function from($name, $mode, $side) {
|
||||
$from = NULL;
|
||||
switch ($name) {
|
||||
case 'civicrm_activity':
|
||||
//CRM-7480 we are going to civicrm_activity table either
|
||||
//from civicrm_activity_target or civicrm_activity_assignment.
|
||||
//as component specific activities does not have entry in
|
||||
//activity target table so lets consider civicrm_activity_assignment.
|
||||
$from .= " $side JOIN civicrm_activity_contact
|
||||
ON ( civicrm_activity_contact.contact_id = contact_a.id ) ";
|
||||
$from .= " $side JOIN civicrm_activity
|
||||
ON ( civicrm_activity.id = civicrm_activity_contact.activity_id
|
||||
AND civicrm_activity.is_deleted = 0 AND civicrm_activity.is_current_revision = 1 )";
|
||||
// Do not show deleted contact's activity
|
||||
$from .= " INNER JOIN civicrm_contact
|
||||
ON ( civicrm_activity_contact.contact_id = civicrm_contact.id and civicrm_contact.is_deleted != 1 )";
|
||||
break;
|
||||
|
||||
case 'activity_status':
|
||||
$from .= " $side JOIN civicrm_option_group option_group_activity_status ON (option_group_activity_status.name = 'activity_status')";
|
||||
$from .= " $side JOIN civicrm_option_value activity_status ON (civicrm_activity.status_id = activity_status.value
|
||||
AND option_group_activity_status.id = activity_status.option_group_id ) ";
|
||||
break;
|
||||
|
||||
case 'activity_type':
|
||||
$from .= " $side JOIN civicrm_option_group option_group_activity_type ON (option_group_activity_type.name = 'activity_type')";
|
||||
$from .= " $side JOIN civicrm_option_value activity_type ON (civicrm_activity.activity_type_id = activity_type.value
|
||||
AND option_group_activity_type.id = activity_type.option_group_id ) ";
|
||||
break;
|
||||
|
||||
case 'activity_priority':
|
||||
$from .= " $side JOIN civicrm_option_group option_group_activity_priority ON (option_group_activity_priority.name = 'priority')";
|
||||
$from .= " $side JOIN civicrm_option_value activity_priority ON (civicrm_activity.priority_id = activity_priority.value
|
||||
AND option_group_activity_priority.id = activity_priority.option_group_id ) ";
|
||||
break;
|
||||
|
||||
case 'civicrm_activity_tag':
|
||||
$from .= " $side JOIN civicrm_entity_tag as civicrm_activity_tag ON ( civicrm_activity_tag.entity_table = 'civicrm_activity' AND civicrm_activity_tag.entity_id = civicrm_activity.id ) ";
|
||||
break;
|
||||
|
||||
case 'source_contact':
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$from = "
|
||||
LEFT JOIN civicrm_activity_contact ac
|
||||
ON ( ac.activity_id = civicrm_activity_contact.activity_id AND ac.record_type_id = {$sourceID})
|
||||
INNER JOIN civicrm_contact source_contact ON (ac.contact_id = source_contact.id)";
|
||||
break;
|
||||
|
||||
case 'parent_id':
|
||||
$from = "$side JOIN civicrm_activity AS parent_id ON civicrm_activity.id = parent_id.parent_id";
|
||||
break;
|
||||
}
|
||||
|
||||
return $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the elements shared between case activity search and advanced search.
|
||||
*
|
||||
* @param CRM_Core_Form $form
|
||||
*/
|
||||
public static function buildSearchForm(&$form) {
|
||||
$form->addSelect('activity_type_id',
|
||||
array('entity' => 'activity', 'label' => ts('Activity Type(s)'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
|
||||
);
|
||||
|
||||
CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
|
||||
$form->addElement('hidden', 'activity_date_range_error');
|
||||
$form->addFormRule(array('CRM_Activity_BAO_Query', 'formRule'), $form);
|
||||
|
||||
$followUpActivity = array(
|
||||
1 => ts('Yes'),
|
||||
2 => ts('No'),
|
||||
);
|
||||
$form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
|
||||
$form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
|
||||
$activityRoles = array(
|
||||
3 => ts('With'),
|
||||
2 => ts('Assigned to'),
|
||||
1 => ts('Added by'),
|
||||
);
|
||||
$form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
|
||||
$form->setDefaults(array('activity_role' => 3));
|
||||
$activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name'));
|
||||
$form->addSelect('status_id',
|
||||
array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
|
||||
);
|
||||
$ssID = $form->get('ssID');
|
||||
$status = array($activityStatus['Completed'], $activityStatus['Scheduled']);
|
||||
//If status is saved in smart group.
|
||||
if (!empty($ssID) && !empty($form->_formValues['activity_status_id'])) {
|
||||
$status = $form->_formValues['activity_status_id'];
|
||||
}
|
||||
$form->setDefaults(array('status_id' => $status));
|
||||
|
||||
$form->addElement('text', 'activity_text', ts('Activity Text'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
|
||||
|
||||
$form->addRadio('activity_option', '', CRM_Core_SelectValues::activityTextOptions());
|
||||
$form->setDefaults(array('activity_option' => 'both'));
|
||||
|
||||
$priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
|
||||
$form->addSelect('priority_id',
|
||||
array('entity' => 'activity', 'label' => ts('Priority'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
|
||||
);
|
||||
|
||||
$form->addYesNo('activity_test', ts('Activity is a Test?'));
|
||||
$activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
|
||||
if ($activity_tags) {
|
||||
foreach ($activity_tags as $tagID => $tagName) {
|
||||
$form->_tagElement = &$form->addElement('checkbox', "activity_tags[$tagID]",
|
||||
NULL, $tagName
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
|
||||
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
|
||||
|
||||
$surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
|
||||
if ($surveys) {
|
||||
$form->add('select', 'activity_survey_id', ts('Survey / Petition'),
|
||||
array('' => ts('- none -')) + $surveys, FALSE,
|
||||
array('class' => 'crm-select2')
|
||||
);
|
||||
}
|
||||
|
||||
CRM_Core_BAO_Query::addCustomFormFields($form, array('Activity'));
|
||||
|
||||
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
|
||||
|
||||
// Add engagement level CRM-7775.
|
||||
$buildEngagementLevel = FALSE;
|
||||
$buildSurveyResult = FALSE;
|
||||
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() &&
|
||||
CRM_Campaign_BAO_Campaign::accessCampaign()
|
||||
) {
|
||||
$buildEngagementLevel = TRUE;
|
||||
$form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search'));
|
||||
|
||||
// Add survey result field.
|
||||
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
|
||||
$resultOptions = array();
|
||||
foreach ($optionGroups as $gid => $name) {
|
||||
if ($name) {
|
||||
$value = CRM_Core_OptionGroup::values($name);
|
||||
if (!empty($value)) {
|
||||
while (list($k, $v) = each($value)) {
|
||||
$resultOptions[$v] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If no survey result options have been created, don't build
|
||||
// the field to avoid clutter.
|
||||
if (count($resultOptions) > 0) {
|
||||
$buildSurveyResult = TRUE;
|
||||
asort($resultOptions);
|
||||
$form->add('select', 'activity_result', ts("Survey Result"),
|
||||
$resultOptions, FALSE,
|
||||
array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$form->assign('buildEngagementLevel', $buildEngagementLevel);
|
||||
$form->assign('buildSurveyResult', $buildSurveyResult);
|
||||
$form->setDefaults(array('activity_test' => 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mode
|
||||
* @param bool $includeCustomFields
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function defaultReturnProperties($mode, $includeCustomFields = TRUE) {
|
||||
$properties = NULL;
|
||||
if ($mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
|
||||
$properties = array(
|
||||
'activity_id' => 1,
|
||||
'contact_type' => 1,
|
||||
'contact_sub_type' => 1,
|
||||
'sort_name' => 1,
|
||||
'display_name' => 1,
|
||||
'activity_type' => 1,
|
||||
'activity_type_id' => 1,
|
||||
'activity_subject' => 1,
|
||||
'activity_date_time' => 1,
|
||||
'activity_duration' => 1,
|
||||
'activity_location' => 1,
|
||||
'activity_details' => 1,
|
||||
'activity_status' => 1,
|
||||
'activity_priority' => 1,
|
||||
'source_contact' => 1,
|
||||
'source_record_id' => 1,
|
||||
'activity_is_test' => 1,
|
||||
'activity_campaign_id' => 1,
|
||||
'result' => 1,
|
||||
'activity_engagement_level' => 1,
|
||||
'parent_id' => 1,
|
||||
);
|
||||
|
||||
if ($includeCustomFields) {
|
||||
// also get all the custom activity properties
|
||||
$fields = CRM_Core_BAO_CustomField::getFieldsForImport('Activity');
|
||||
if (!empty($fields)) {
|
||||
foreach ($fields as $name => $dontCare) {
|
||||
$properties[$name] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of fields required to populate the selector.
|
||||
*
|
||||
* The default return properties array returns far too many fields for 'everyday use. Every field you add to this array
|
||||
* kills a small kitten so add carefully.
|
||||
*/
|
||||
public static function selectorReturnProperties() {
|
||||
$properties = array(
|
||||
'activity_id' => 1,
|
||||
'contact_type' => 1,
|
||||
'contact_sub_type' => 1,
|
||||
'sort_name' => 1,
|
||||
'display_name' => 1,
|
||||
'activity_type_id' => 1,
|
||||
'activity_subject' => 1,
|
||||
'activity_date_time' => 1,
|
||||
'activity_status_id' => 1,
|
||||
'source_contact' => 1,
|
||||
'source_record_id' => 1,
|
||||
'activity_is_test' => 1,
|
||||
'activity_campaign_id' => 1,
|
||||
'activity_engagement_level' => 1,
|
||||
);
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom form rules.
|
||||
*
|
||||
* @param array $fields
|
||||
* @param array $files
|
||||
* @param CRM_Core_Form $form
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public static function formRule($fields, $files, $form) {
|
||||
$errors = array();
|
||||
|
||||
if (empty($fields['activity_date_low']) || empty($fields['activity_date_high'])) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CRM_Utils_Rule::validDateRange($fields, 'activity_date', $errors, ts('Activity Date'));
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where/qill clause for notes
|
||||
*
|
||||
* @param array $values
|
||||
*/
|
||||
public static function whereClauseSingleActivityText(&$values, &$query) {
|
||||
list($name, $op, $value, $grouping, $wildcard) = $values;
|
||||
$activityOptionValues = $query->getWhereValues('activity_option', $grouping);
|
||||
$activityOption = CRM_Utils_Array::value(2, $activityOptionValues, 6);
|
||||
|
||||
$query->_useDistinct = TRUE;
|
||||
|
||||
$label = ts('Activity Text (%1)', array(1 => CRM_Utils_Array::value($activityOption, CRM_Core_SelectValues::activityTextOptions())));
|
||||
$clauses = array();
|
||||
if ($activityOption % 2 == 0) {
|
||||
$clauses[] = $query->buildClause('civicrm_activity.details', $op, $value, 'String');
|
||||
}
|
||||
if ($activityOption % 3 == 0) {
|
||||
$clauses[] = $query->buildClause('civicrm_activity.subject', $op, $value, 'String');
|
||||
}
|
||||
|
||||
$query->_where[$grouping][] = "( " . implode(' OR ', $clauses) . " )";
|
||||
list($qillOp, $qillVal) = $query->buildQillForFieldValue(NULL, $name, $value, $op);
|
||||
$query->_qill[$grouping][] = ts("%1 %2 '%3'", array(1 => $label, 2 => $qillOp, 3 => $qillVal));
|
||||
}
|
||||
|
||||
}
|
76
sites/all/modules/civicrm/CRM/Activity/Controller/Search.php
Normal file
76
sites/all/modules/civicrm/CRM/Activity/Controller/Search.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used by the Search functionality.
|
||||
*
|
||||
* - the search controller is used for building/processing multiform
|
||||
* searches.
|
||||
*
|
||||
* Typically the first form will display the search criteria and it's results
|
||||
*
|
||||
* The second form is used to process search results with the associated actions
|
||||
*
|
||||
*/
|
||||
class CRM_Activity_Controller_Search extends CRM_Core_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param null $title
|
||||
* @param bool $modal
|
||||
* @param int|mixed|null $action
|
||||
*/
|
||||
public function __construct($title = NULL, $modal = TRUE, $action = CRM_Core_Action::NONE) {
|
||||
|
||||
parent::__construct($title, $modal);
|
||||
|
||||
$this->_stateMachine = new CRM_Activity_StateMachine_Search($this, $action);
|
||||
|
||||
// Create and instantiate the pages.
|
||||
$this->addPages($this->_stateMachine, $action);
|
||||
|
||||
// Add all the actions.
|
||||
$this->addActions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for selectorName.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function selectorName() {
|
||||
return $this->get('selectorName');
|
||||
}
|
||||
|
||||
}
|
808
sites/all/modules/civicrm/CRM/Activity/DAO/Activity.php
Normal file
808
sites/all/modules/civicrm/CRM/Activity/DAO/Activity.php
Normal file
|
@ -0,0 +1,808 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Activity/Activity.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:dfa63754ef6ea1a9c7148e735dd6ff8a)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Activity_DAO_Activity constructor.
|
||||
*/
|
||||
class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_activity';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = true;
|
||||
/**
|
||||
* Unique Other Activity ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $source_record_id;
|
||||
/**
|
||||
* FK to civicrm_option_value.id, that has to be valid, registered activity type.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $activity_type_id;
|
||||
/**
|
||||
* The subject/purpose/short description of the activity.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $subject;
|
||||
/**
|
||||
* Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
public $activity_date_time;
|
||||
/**
|
||||
* Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $duration;
|
||||
/**
|
||||
* Location of the activity (optional, open text).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $location;
|
||||
/**
|
||||
* Phone ID of the number called (optional - used if an existing phone number is selected).
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $phone_id;
|
||||
/**
|
||||
* Phone number in case the number does not exist in the civicrm_phone table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $phone_number;
|
||||
/**
|
||||
* Details about the activity (agenda, notes, etc).
|
||||
*
|
||||
* @var longtext
|
||||
*/
|
||||
public $details;
|
||||
/**
|
||||
* ID of the status this activity is currently in. Foreign key to civicrm_option_value.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $status_id;
|
||||
/**
|
||||
* ID of the priority given to this activity. Foreign key to civicrm_option_value.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $priority_id;
|
||||
/**
|
||||
* Parent meeting ID (if this is a follow-up item). This is not currently implemented
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $parent_id;
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_test;
|
||||
/**
|
||||
* Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $medium_id;
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_auto;
|
||||
/**
|
||||
* FK to Relationship ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $relationship_id;
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_current_revision;
|
||||
/**
|
||||
* Activity ID of the first activity record in versioning chain.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $original_id;
|
||||
/**
|
||||
* Currently being used to store result id for survey activity, FK to option value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $result;
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_deleted;
|
||||
/**
|
||||
* The campaign for which this activity has been triggered.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $campaign_id;
|
||||
/**
|
||||
* Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $engagement_level;
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $weight;
|
||||
/**
|
||||
* Activity marked as favorite.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_star;
|
||||
/**
|
||||
* When was the activity was created.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $created_date;
|
||||
/**
|
||||
* When was the activity (or closely related entity) was created or modified or deleted.
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $modified_date;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_activity';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'phone_id', 'civicrm_phone', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_activity', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'relationship_id', 'civicrm_relationship', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'original_id', 'civicrm_activity', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'activity_id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Activity ID') ,
|
||||
'description' => 'Unique Other Activity ID',
|
||||
'required' => true,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.id',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'source_record_id' => array(
|
||||
'name' => 'source_record_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Source Record') ,
|
||||
'description' => 'Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'activity_type_id' => array(
|
||||
'name' => 'activity_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Activity Type ID') ,
|
||||
'description' => 'FK to civicrm_option_value.id, that has to be valid, registered activity type.',
|
||||
'required' => true,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.activity_type_id',
|
||||
'headerPattern' => '/(activity.)?type(.id$)/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'default' => '1',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'activity_type',
|
||||
'optionEditPath' => 'civicrm/admin/options/activity_type',
|
||||
)
|
||||
) ,
|
||||
'activity_subject' => array(
|
||||
'name' => 'subject',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Subject') ,
|
||||
'description' => 'The subject/purpose/short description of the activity.',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.subject',
|
||||
'headerPattern' => '/(activity.)?subject/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'activity_date_time' => array(
|
||||
'name' => 'activity_date_time',
|
||||
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
|
||||
'title' => ts('Activity Date') ,
|
||||
'description' => 'Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.activity_date_time',
|
||||
'headerPattern' => '/(activity.)?date(.time$)?/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select Date',
|
||||
'formatType' => 'activityDateTime',
|
||||
) ,
|
||||
) ,
|
||||
'activity_duration' => array(
|
||||
'name' => 'duration',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Duration') ,
|
||||
'description' => 'Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.duration',
|
||||
'headerPattern' => '/(activity.)?duration(s)?$/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'activity_location' => array(
|
||||
'name' => 'location',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Location') ,
|
||||
'description' => 'Location of the activity (optional, open text).',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.location',
|
||||
'headerPattern' => '/(activity.)?location$/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'phone_id' => array(
|
||||
'name' => 'phone_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Phone (called) ID') ,
|
||||
'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Core_DAO_Phone',
|
||||
'html' => array(
|
||||
'type' => 'EntityRef',
|
||||
) ,
|
||||
) ,
|
||||
'phone_number' => array(
|
||||
'name' => 'phone_number',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Phone (called) Number') ,
|
||||
'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'activity_details' => array(
|
||||
'name' => 'details',
|
||||
'type' => CRM_Utils_Type::T_LONGTEXT,
|
||||
'title' => ts('Details') ,
|
||||
'description' => 'Details about the activity (agenda, notes, etc).',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.details',
|
||||
'headerPattern' => '/(activity.)?detail(s)?$/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'RichTextEditor',
|
||||
) ,
|
||||
) ,
|
||||
'activity_status_id' => array(
|
||||
'name' => 'status_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Activity Status') ,
|
||||
'description' => 'ID of the status this activity is currently in. Foreign key to civicrm_option_value.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.status_id',
|
||||
'headerPattern' => '/(activity.)?status(.label$)?/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'activity_status',
|
||||
'optionEditPath' => 'civicrm/admin/options/activity_status',
|
||||
)
|
||||
) ,
|
||||
'priority_id' => array(
|
||||
'name' => 'priority_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Priority') ,
|
||||
'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'priority',
|
||||
'optionEditPath' => 'civicrm/admin/options/priority',
|
||||
)
|
||||
) ,
|
||||
'parent_id' => array(
|
||||
'name' => 'parent_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Parent Activity Id') ,
|
||||
'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Activity_DAO_Activity',
|
||||
) ,
|
||||
'activity_is_test' => array(
|
||||
'name' => 'is_test',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Test') ,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.is_test',
|
||||
'headerPattern' => '/(is.)?test(.activity)?/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
) ,
|
||||
'activity_medium_id' => array(
|
||||
'name' => 'medium_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Activity Medium') ,
|
||||
'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'encounter_medium',
|
||||
'optionEditPath' => 'civicrm/admin/options/encounter_medium',
|
||||
)
|
||||
) ,
|
||||
'is_auto' => array(
|
||||
'name' => 'is_auto',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Auto') ,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'relationship_id' => array(
|
||||
'name' => 'relationship_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Relationship Id') ,
|
||||
'description' => 'FK to Relationship ID',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Relationship',
|
||||
) ,
|
||||
'is_current_revision' => array(
|
||||
'name' => 'is_current_revision',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Is this activity a current revision in versioning chain?') ,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.is_current_revision',
|
||||
'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'default' => '1',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
) ,
|
||||
) ,
|
||||
'original_id' => array(
|
||||
'name' => 'original_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Original Activity ID ') ,
|
||||
'description' => 'Activity ID of the first activity record in versioning chain.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Activity_DAO_Activity',
|
||||
) ,
|
||||
'activity_result' => array(
|
||||
'name' => 'result',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Result') ,
|
||||
'description' => 'Currently being used to store result id for survey activity, FK to option value.',
|
||||
'maxlength' => 255,
|
||||
'size' => CRM_Utils_Type::HUGE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'activity_is_deleted' => array(
|
||||
'name' => 'is_deleted',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Activity is in the Trash') ,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.is_deleted',
|
||||
'headerPattern' => '/(activity.)?(trash|deleted)/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'activity_campaign_id' => array(
|
||||
'name' => 'campaign_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Campaign') ,
|
||||
'description' => 'The campaign for which this activity has been triggered.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.campaign_id',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Campaign_DAO_Campaign',
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'table' => 'civicrm_campaign',
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'title',
|
||||
)
|
||||
) ,
|
||||
'activity_engagement_level' => array(
|
||||
'name' => 'engagement_level',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Engagement Index') ,
|
||||
'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.engagement_level',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'engagement_index',
|
||||
'optionEditPath' => 'civicrm/admin/options/engagement_index',
|
||||
)
|
||||
) ,
|
||||
'weight' => array(
|
||||
'name' => 'weight',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Order') ,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'is_star' => array(
|
||||
'name' => 'is_star',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Is Starred') ,
|
||||
'description' => 'Activity marked as favorite.',
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity.is_star',
|
||||
'headerPattern' => '/(activity.)?(star|favorite)/i',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'activity_created_date' => array(
|
||||
'name' => 'created_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Created Date') ,
|
||||
'description' => 'When was the activity was created.',
|
||||
'required' => false,
|
||||
'export' => true,
|
||||
'where' => 'civicrm_activity.created_date',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'activity_modified_date' => array(
|
||||
'name' => 'modified_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Modified Date') ,
|
||||
'description' => 'When was the activity (or closely related entity) was created or modified or deleted.',
|
||||
'required' => false,
|
||||
'export' => true,
|
||||
'where' => 'civicrm_activity.modified_date',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'activity', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'activity', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'UI_source_record_id' => array(
|
||||
'name' => 'UI_source_record_id',
|
||||
'field' => array(
|
||||
0 => 'source_record_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity::0::source_record_id',
|
||||
) ,
|
||||
'UI_activity_type_id' => array(
|
||||
'name' => 'UI_activity_type_id',
|
||||
'field' => array(
|
||||
0 => 'activity_type_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity::0::activity_type_id',
|
||||
) ,
|
||||
'index_activity_date_time' => array(
|
||||
'name' => 'index_activity_date_time',
|
||||
'field' => array(
|
||||
0 => 'activity_date_time',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity::0::activity_date_time',
|
||||
) ,
|
||||
'index_status_id' => array(
|
||||
'name' => 'index_status_id',
|
||||
'field' => array(
|
||||
0 => 'status_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity::0::status_id',
|
||||
) ,
|
||||
'index_medium_id' => array(
|
||||
'name' => 'index_medium_id',
|
||||
'field' => array(
|
||||
0 => 'medium_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity::0::medium_id',
|
||||
) ,
|
||||
'index_is_current_revision' => array(
|
||||
'name' => 'index_is_current_revision',
|
||||
'field' => array(
|
||||
0 => 'is_current_revision',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity::0::is_current_revision',
|
||||
) ,
|
||||
'index_is_deleted' => array(
|
||||
'name' => 'index_is_deleted',
|
||||
'field' => array(
|
||||
0 => 'is_deleted',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity::0::is_deleted',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
247
sites/all/modules/civicrm/CRM/Activity/DAO/ActivityContact.php
Normal file
247
sites/all/modules/civicrm/CRM/Activity/DAO/ActivityContact.php
Normal file
|
@ -0,0 +1,247 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/Activity/ActivityContact.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:7a410e20f48318deeb83f3dd1900983a)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_Activity_DAO_ActivityContact constructor.
|
||||
*/
|
||||
class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_activity_contact';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = true;
|
||||
/**
|
||||
* Activity contact id
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Foreign key to the activity for this record.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $activity_id;
|
||||
/**
|
||||
* Foreign key to the contact for this record.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contact_id;
|
||||
/**
|
||||
* Nature of this contact's role in the activity: 1 assignee, 2 creator, 3 focus or target.
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $record_type_id;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_activity_contact';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'activity_id', 'civicrm_activity', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Activity Contact ID') ,
|
||||
'description' => 'Activity contact id',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_activity_contact',
|
||||
'entity' => 'ActivityContact',
|
||||
'bao' => 'CRM_Activity_BAO_ActivityContact',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'activity_id' => array(
|
||||
'name' => 'activity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Activity ID') ,
|
||||
'description' => 'Foreign key to the activity for this record.',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_activity_contact',
|
||||
'entity' => 'ActivityContact',
|
||||
'bao' => 'CRM_Activity_BAO_ActivityContact',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Activity_DAO_Activity',
|
||||
) ,
|
||||
'contact_id' => array(
|
||||
'name' => 'contact_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Contact ID (match to contact)') ,
|
||||
'description' => 'Foreign key to the contact for this record.',
|
||||
'required' => true,
|
||||
'import' => true,
|
||||
'where' => 'civicrm_activity_contact.contact_id',
|
||||
'headerPattern' => '',
|
||||
'dataPattern' => '',
|
||||
'export' => true,
|
||||
'table_name' => 'civicrm_activity_contact',
|
||||
'entity' => 'ActivityContact',
|
||||
'bao' => 'CRM_Activity_BAO_ActivityContact',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
) ,
|
||||
'record_type_id' => array(
|
||||
'name' => 'record_type_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Record Type ID') ,
|
||||
'description' => 'Nature of this contact\'s role in the activity: 1 assignee, 2 creator, 3 focus or target.',
|
||||
'table_name' => 'civicrm_activity_contact',
|
||||
'entity' => 'ActivityContact',
|
||||
'bao' => 'CRM_Activity_BAO_ActivityContact',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'activity_contacts',
|
||||
'optionEditPath' => 'civicrm/admin/options/activity_contacts',
|
||||
)
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'activity_contact', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'activity_contact', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'UI_activity_contact' => array(
|
||||
'name' => 'UI_activity_contact',
|
||||
'field' => array(
|
||||
0 => 'contact_id',
|
||||
1 => 'activity_id',
|
||||
2 => 'record_type_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'unique' => true,
|
||||
'sig' => 'civicrm_activity_contact::1::contact_id::activity_id::record_type_id',
|
||||
) ,
|
||||
'index_record_type' => array(
|
||||
'name' => 'index_record_type',
|
||||
'field' => array(
|
||||
0 => 'activity_id',
|
||||
1 => 'record_type_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_activity_contact::0::activity_id::record_type_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
1159
sites/all/modules/civicrm/CRM/Activity/Form/Activity.php
Normal file
1159
sites/all/modules/civicrm/CRM/Activity/Form/Activity.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Activity Filter.
|
||||
*/
|
||||
class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form {
|
||||
public function buildQuickForm() {
|
||||
// add activity search filter
|
||||
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
|
||||
asort($activityOptions);
|
||||
|
||||
$this->add('select', 'activity_type_filter_id', ts('Include'), array('' => ts('- all activity type(s) -')) + $activityOptions);
|
||||
$this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), array('' => ts('- select activity type -')) + $activityOptions);
|
||||
CRM_Core_Form_Date::buildDateRange(
|
||||
$this, 'activity_date', 1,
|
||||
'_low', '_high', ts('From:'),
|
||||
FALSE, array(), 'searchDate',
|
||||
FALSE, array('class' => 'crm-select2 medium')
|
||||
);
|
||||
$this->addSelect('status_id',
|
||||
array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
|
||||
);
|
||||
|
||||
$this->assign('suppressForm', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* This virtual function is used to set the default values of
|
||||
* various form elements
|
||||
*
|
||||
* access public
|
||||
*
|
||||
* @return array
|
||||
* reference to the array of default values
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
// CRM-11761 retrieve user's activity filter preferences
|
||||
$defaults = array();
|
||||
if (Civi::settings()->get('preserve_activity_tab_filter') && ($userID = CRM_Core_Session::getLoggedInContactID())) {
|
||||
$defaults = Civi::service('settings_manager')
|
||||
->getBagByContact(NULL, $userID)
|
||||
->get('activity_tab_filter');
|
||||
}
|
||||
// set Activity status 'Scheduled' by default only for dashlet
|
||||
elseif (strstr(CRM_Utils_Array::value('q', $_GET), 'dashlet')) {
|
||||
$defaults['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled');
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
}
|
107
sites/all/modules/civicrm/CRM/Activity/Form/ActivityLinks.php
Normal file
107
sites/all/modules/civicrm/CRM/Activity/Form/ActivityLinks.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Activity Links.
|
||||
*/
|
||||
class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form {
|
||||
public function buildQuickForm() {
|
||||
self::commonBuildQuickForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $self
|
||||
*/
|
||||
public static function commonBuildQuickForm($self) {
|
||||
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $self);
|
||||
if (!$contactId) {
|
||||
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
|
||||
}
|
||||
$urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype=";
|
||||
|
||||
$allTypes = CRM_Utils_Array::value('values', civicrm_api3('OptionValue', 'get', array(
|
||||
'option_group_id' => 'activity_type',
|
||||
'is_active' => 1,
|
||||
'options' => array('limit' => 0, 'sort' => 'weight'),
|
||||
)));
|
||||
|
||||
$activityTypes = array();
|
||||
|
||||
foreach ($allTypes as $act) {
|
||||
$url = 'civicrm/activity/add';
|
||||
if ($act['name'] == 'Email') {
|
||||
if (!CRM_Utils_Mail::validOutBoundMail() || !$contactId) {
|
||||
continue;
|
||||
}
|
||||
list($name, $email, $doNotEmail, $onHold, $isDeceased) = CRM_Contact_BAO_Contact::getContactDetails($contactId);
|
||||
if (!$doNotEmail && $email && !$isDeceased) {
|
||||
$url = 'civicrm/activity/email/add';
|
||||
$act['label'] = ts('Send an Email');
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
elseif ($act['name'] == 'SMS') {
|
||||
if (!$contactId || !CRM_SMS_BAO_Provider::activeProviderCount()) {
|
||||
continue;
|
||||
}
|
||||
// Check for existence of a mobile phone and ! do not SMS privacy setting
|
||||
$mobileTypeID = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile');
|
||||
list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location::getPhoneDetails($contactId, $mobileTypeID);
|
||||
if (!$doNotSMS && $phone) {
|
||||
$url = 'civicrm/activity/sms/add';
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
elseif ($act['name'] == 'Print PDF Letter') {
|
||||
$url = 'civicrm/activity/pdf/add';
|
||||
}
|
||||
elseif (!empty($act['filter']) || (!empty($act['component_id']) && $act['component_id'] != '1')) {
|
||||
continue;
|
||||
}
|
||||
$act['url'] = CRM_Utils_System::url($url,
|
||||
"{$urlParams}{$act['value']}", FALSE, NULL, FALSE
|
||||
);
|
||||
$act += array('icon' => 'fa-plus-square-o');
|
||||
$activityTypes[$act['value']] = $act;
|
||||
}
|
||||
|
||||
$self->assign('activityTypes', $activityTypes);
|
||||
|
||||
$self->assign('suppressForm', TRUE);
|
||||
}
|
||||
|
||||
}
|
128
sites/all/modules/civicrm/CRM/Activity/Form/ActivityView.php
Normal file
128
sites/all/modules/civicrm/CRM/Activity/Form/ActivityView.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class handle activity view mode.
|
||||
*/
|
||||
class CRM_Activity_Form_ActivityView extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*/
|
||||
public function preProcess() {
|
||||
// Get the activity values.
|
||||
$activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
|
||||
// Check for required permissions, CRM-6264.
|
||||
if ($activityId &&
|
||||
!CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
if (!in_array($context, array(
|
||||
'home',
|
||||
'dashlet',
|
||||
'dashletFullscreen',
|
||||
))
|
||||
) {
|
||||
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
|
||||
}
|
||||
else {
|
||||
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
|
||||
}
|
||||
|
||||
$session->pushUserContext($url);
|
||||
$defaults = array();
|
||||
$params = array('id' => $activityId);
|
||||
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
|
||||
|
||||
// Set activity type name and description to template.
|
||||
list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
|
||||
|
||||
$this->assign('activityTypeName', $activityTypeName);
|
||||
$this->assign('activityTypeDescription', $activityTypeDescription);
|
||||
|
||||
if (!empty($defaults['mailingId'])) {
|
||||
$this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
|
||||
$mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE);
|
||||
CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
|
||||
$this->assign('mailingReport', $mailingReport);
|
||||
|
||||
$full_open_report = CRM_Mailing_Event_BAO_Opened::getRows(
|
||||
$this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, $cid);
|
||||
$this->assign('openreport', $full_open_report);
|
||||
|
||||
$click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
|
||||
$this->assign('clickreport', $click_thru_report);
|
||||
}
|
||||
|
||||
foreach ($defaults as $key => $value) {
|
||||
if (substr($key, -3) != '_id') {
|
||||
$values[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the campaign.
|
||||
if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
|
||||
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
|
||||
$values['campaign'] = $campaigns[$campaignId];
|
||||
}
|
||||
if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) {
|
||||
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
|
||||
$values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
|
||||
}
|
||||
|
||||
$values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
|
||||
$this->assign('values', $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Done'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
417
sites/all/modules/civicrm/CRM/Activity/Form/Search.php
Normal file
417
sites/all/modules/civicrm/CRM/Activity/Form/Search.php
Normal file
|
@ -0,0 +1,417 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is for activity search.
|
||||
*/
|
||||
class CRM_Activity_Form_Search extends CRM_Core_Form_Search {
|
||||
|
||||
/**
|
||||
* The params that are sent to the query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_queryParams;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_limit = NULL;
|
||||
|
||||
/**
|
||||
* Prefix for the controller.
|
||||
*/
|
||||
protected $_prefix = "activity_";
|
||||
|
||||
/**
|
||||
* The saved search ID retrieved from the GET vars.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_ssID;
|
||||
|
||||
/**
|
||||
* Processing needed for buildForm and later.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->set('searchFormName', 'Search');
|
||||
|
||||
// set the button names
|
||||
$this->_searchButtonName = $this->getButtonName('refresh');
|
||||
$this->_actionButtonName = $this->getButtonName('next', 'action');
|
||||
|
||||
$this->_done = FALSE;
|
||||
$this->defaults = array();
|
||||
|
||||
// we allow the controller to set force/reset externally, useful when we are being
|
||||
// driven by the wizard framework
|
||||
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
|
||||
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
|
||||
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
|
||||
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search');
|
||||
|
||||
$this->assign("context", $this->_context);
|
||||
|
||||
// get user submitted values
|
||||
// get it from controller only if form has been submitted, else preProcess has set this
|
||||
if (!empty($_POST) && !$this->controller->isModal()) {
|
||||
$this->_formValues = $this->controller->exportValues($this->_name);
|
||||
}
|
||||
else {
|
||||
$this->_formValues = $this->get('formValues');
|
||||
|
||||
if ($this->_force) {
|
||||
// If we force the search then merge form values with url values
|
||||
// and set submit values to form values.
|
||||
$this->_formValues = array_merge((array) $this->_formValues, CRM_Utils_Request::exportValues());
|
||||
$this->_submitValues = $this->_formValues;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->_formValues)) {
|
||||
if (isset($this->_ssID)) {
|
||||
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_force) {
|
||||
$this->postProcess();
|
||||
$this->set('force', 0);
|
||||
}
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
$selector = new CRM_Activity_Selector_Search($this->_queryParams,
|
||||
$this->_action,
|
||||
NULL,
|
||||
$this->_single,
|
||||
$this->_limit,
|
||||
$this->_context
|
||||
);
|
||||
$prefix = NULL;
|
||||
if ($this->_context == 'user') {
|
||||
$prefix = $this->_prefix;
|
||||
}
|
||||
|
||||
$this->assign("{$prefix}limit", $this->_limit);
|
||||
$this->assign("{$prefix}single", $this->_single);
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller($selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$sortID,
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::TRANSFER,
|
||||
$prefix
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->moveFromSessionToTemplate();
|
||||
|
||||
$this->assign('summary', $this->get('summary'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->addSortNameField();
|
||||
|
||||
CRM_Activity_BAO_Query::buildSearchForm($this);
|
||||
|
||||
$rows = $this->get('rows');
|
||||
if (is_array($rows)) {
|
||||
if (!$this->_single) {
|
||||
$this->addRowSelectors($rows);
|
||||
}
|
||||
|
||||
$permission = CRM_Core_Permission::getPermission();
|
||||
|
||||
$this->addTaskMenu(CRM_Activity_Task::permissionedTaskTitles($permission));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The post processing of the form gets done here.
|
||||
*
|
||||
* Key things done during post processing are
|
||||
* - check for reset or next request. if present, skip post procesing.
|
||||
* - now check if user requested running a saved search, if so, then
|
||||
* the form values associated with the saved search are used for searching.
|
||||
* - if user has done a submit with new values the regular post submissing is
|
||||
* done.
|
||||
*
|
||||
* The processing consists of using a Selector / Controller framework for getting the
|
||||
* search results.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_done = TRUE;
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$this->_formValues = $this->controller->exportValues($this->_name);
|
||||
$specialParams = array(
|
||||
'activity_type_id',
|
||||
'status_id',
|
||||
'priority_id',
|
||||
'activity_text',
|
||||
);
|
||||
$changeNames = array(
|
||||
'status_id' => 'activity_status_id',
|
||||
'priority_id' => 'activity_priority_id',
|
||||
);
|
||||
|
||||
CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames);
|
||||
}
|
||||
|
||||
$this->fixFormValues();
|
||||
|
||||
if (isset($this->_ssID) && empty($_POST)) {
|
||||
// if we are editing / running a saved search and the form has not been posted
|
||||
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
|
||||
}
|
||||
|
||||
// We don't show test records in summaries or dashboards
|
||||
if (empty($this->_formValues['activity_test']) && $this->_force) {
|
||||
$this->_formValues["activity_test"] = 0;
|
||||
}
|
||||
|
||||
CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
|
||||
$this->set('formValues', $this->_formValues);
|
||||
$this->set('queryParams', $this->_queryParams);
|
||||
|
||||
$buttonName = $this->controller->getButtonName();
|
||||
if ($buttonName == $this->_actionButtonName) {
|
||||
// check actionName and if next, then do not repeat a search, since we are going to the next page
|
||||
// hack, make sure we reset the task values
|
||||
$stateMachine = $this->controller->getStateMachine();
|
||||
$formName = $stateMachine->getTaskFormName();
|
||||
$this->controller->resetPage($formName);
|
||||
return;
|
||||
}
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
|
||||
|
||||
$selector = new CRM_Activity_Selector_Search($this->_queryParams,
|
||||
$this->_action,
|
||||
NULL,
|
||||
$this->_single,
|
||||
$this->_limit,
|
||||
$this->_context
|
||||
);
|
||||
$selector->setKey($this->controller->_key);
|
||||
|
||||
$prefix = NULL;
|
||||
if ($this->_context == 'basic' || $this->_context == 'user') {
|
||||
$prefix = $this->_prefix;
|
||||
}
|
||||
|
||||
$controller = new CRM_Core_Selector_Controller($selector,
|
||||
$this->get(CRM_Utils_Pager::PAGE_ID),
|
||||
$sortID,
|
||||
CRM_Core_Action::VIEW,
|
||||
$this,
|
||||
CRM_Core_Selector_Controller::SESSION,
|
||||
$prefix
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$query = &$selector->getQuery();
|
||||
|
||||
if ($this->_context == 'user') {
|
||||
$query->setSkipPermission(TRUE);
|
||||
}
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
public function fixFormValues() {
|
||||
if (!$this->_force) {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = CRM_Utils_Request::retrieve('status', 'String', $this);
|
||||
if ($status) {
|
||||
$this->_formValues['activity_status_id'] = $status;
|
||||
$this->_defaults['activity_status_id'] = $status;
|
||||
}
|
||||
|
||||
$survey = CRM_Utils_Request::retrieve('survey', 'Positive');
|
||||
|
||||
if ($survey) {
|
||||
$this->_formValues['activity_survey_id'] = $this->_defaults['activity_survey_id'] = $survey;
|
||||
$sid = CRM_Utils_Array::value('activity_survey_id', $this->_formValues);
|
||||
$activity_type_id = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $sid, 'activity_type_id');
|
||||
|
||||
// since checkbox are replaced by multiple select option
|
||||
$this->_formValues['activity_type_id'] = $activity_type_id;
|
||||
$this->_defaults['activity_type_id'] = $activity_type_id;
|
||||
}
|
||||
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
|
||||
if ($cid) {
|
||||
$cid = CRM_Utils_Type::escape($cid, 'Integer');
|
||||
if ($cid > 0) {
|
||||
$this->_formValues['contact_id'] = $cid;
|
||||
|
||||
$activity_role = CRM_Utils_Request::retrieve('activity_role', 'Positive', $this);
|
||||
|
||||
if ($activity_role) {
|
||||
$this->_formValues['activity_role'] = $activity_role;
|
||||
}
|
||||
else {
|
||||
$this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
|
||||
}
|
||||
// also assign individual mode to the template
|
||||
$this->_single = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Added for membership search
|
||||
|
||||
$signupType = CRM_Utils_Request::retrieve('signupType', 'Positive');
|
||||
|
||||
if ($signupType) {
|
||||
$this->_formValues['activity_role'] = 1;
|
||||
$this->_defaults['activity_role'] = 1;
|
||||
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
|
||||
|
||||
$renew = CRM_Utils_Array::key('Membership Renewal', $activityTypes);
|
||||
$signup = CRM_Utils_Array::key('Membership Signup', $activityTypes);
|
||||
|
||||
switch ($signupType) {
|
||||
case 3: // signups and renewals
|
||||
$this->_formValues['activity_type_id'][$renew] = 1;
|
||||
$this->_defaults['activity_type_id'][$renew] = 1;
|
||||
case 1: // signups only
|
||||
$this->_formValues['activity_type_id'][$signup] = 1;
|
||||
$this->_defaults['activity_type_id'][$signup] = 1;
|
||||
break;
|
||||
|
||||
case 2: // renewals only
|
||||
$this->_formValues['activity_type_id'][$renew] = 1;
|
||||
$this->_defaults['activity_type_id'][$renew] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$dateLow = CRM_Utils_Request::retrieve('dateLow', 'String');
|
||||
|
||||
if ($dateLow) {
|
||||
$dateLow = date('m/d/Y', strtotime($dateLow));
|
||||
$this->_formValues['activity_date_relative'] = 0;
|
||||
$this->_defaults['activity_date_relative'] = 0;
|
||||
$this->_formValues['activity_date_low'] = $dateLow;
|
||||
$this->_defaults['activity_date_low'] = $dateLow;
|
||||
}
|
||||
|
||||
$dateHigh = CRM_Utils_Request::retrieve('dateHigh', 'String');
|
||||
|
||||
if ($dateHigh) {
|
||||
// Activity date time assumes midnight at the beginning of the date
|
||||
// This sets it to almost midnight at the end of the date
|
||||
/* if ($dateHigh <= 99999999) {
|
||||
$dateHigh = 1000000 * $dateHigh + 235959;
|
||||
} */
|
||||
$dateHigh = date('m/d/Y', strtotime($dateHigh));
|
||||
$this->_formValues['activity_date_relative'] = 0;
|
||||
$this->_defaults['activity_date_relative'] = 0;
|
||||
$this->_formValues['activity_date_high'] = $dateHigh;
|
||||
$this->_defaults['activity_date_high'] = $dateHigh;
|
||||
}
|
||||
|
||||
// Enable search activity by custom value
|
||||
$requestParams = CRM_Utils_Request::exportValues();
|
||||
foreach (array_keys($requestParams) as $key) {
|
||||
if (substr($key, 0, 7) != 'custom_') {
|
||||
continue;
|
||||
}
|
||||
elseif (empty($requestParams[$key])) {
|
||||
continue;
|
||||
}
|
||||
$customValue = CRM_Utils_Request::retrieve($key, 'String', $this);
|
||||
if ($customValue) {
|
||||
$this->_formValues[$key] = $customValue;
|
||||
$this->_defaults[$key] = $customValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->_defaults)) {
|
||||
$this->setDefaults($this->_defaults);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getFormValues() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a descriptive name for the page, used in wizard header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return ts('Find Activities');
|
||||
}
|
||||
|
||||
}
|
207
sites/all/modules/civicrm/CRM/Activity/Form/Task.php
Normal file
207
sites/all/modules/civicrm/CRM/Activity/Form/Task.php
Normal file
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for activity task actions.
|
||||
*/
|
||||
class CRM_Activity_Form_Task extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The task being performed.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_task;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_componentClause = NULL;
|
||||
|
||||
/**
|
||||
* The array that holds all the component ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_componentIds;
|
||||
|
||||
/**
|
||||
* The array that holds all the contact ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_contactIds;
|
||||
|
||||
/**
|
||||
* The array that holds all the member ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_activityHolderIds;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
self::preProcessCommon($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common pre-process function.
|
||||
*
|
||||
* @param CRM_Core_Form $form
|
||||
* @param bool $useTable
|
||||
*/
|
||||
public static function preProcessCommon(&$form, $useTable = FALSE) {
|
||||
$form->_activityHolderIds = array();
|
||||
|
||||
$values = $form->controller->exportValues($form->get('searchFormName'));
|
||||
|
||||
$form->_task = $values['task'];
|
||||
$activityTasks = CRM_Activity_Task::tasks();
|
||||
$form->assign('taskName', $activityTasks[$form->_task]);
|
||||
|
||||
$ids = array();
|
||||
if ($values['radio_ts'] == 'ts_sel') {
|
||||
foreach ($values as $name => $value) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
$ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$queryParams = $form->get('queryParams');
|
||||
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_ACTIVITY
|
||||
);
|
||||
$query->_distinctComponentClause = '( civicrm_activity.id )';
|
||||
$query->_groupByComponentClause = " GROUP BY civicrm_activity.id ";
|
||||
|
||||
// CRM-12675
|
||||
$activityClause = NULL;
|
||||
|
||||
$components = CRM_Core_Component::getNames();
|
||||
$componentClause = array();
|
||||
foreach ($components as $componentID => $componentName) {
|
||||
if ($componentName != 'CiviCase' && !CRM_Core_Permission::check("access $componentName")) {
|
||||
$componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) ";
|
||||
}
|
||||
}
|
||||
if (!empty($componentClause)) {
|
||||
$activityClause = implode(' AND ', $componentClause);
|
||||
}
|
||||
$result = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $activityClause);
|
||||
|
||||
while ($result->fetch()) {
|
||||
if (!empty($result->activity_id)) {
|
||||
$ids[] = $result->activity_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($ids)) {
|
||||
$form->_componentClause = ' civicrm_activity.id IN ( ' . implode(',', $ids) . ' ) ';
|
||||
$form->assign('totalSelectedActivities', count($ids));
|
||||
}
|
||||
|
||||
$form->_activityHolderIds = $form->_componentIds = $ids;
|
||||
|
||||
// Set the context for redirection for any task actions.
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
|
||||
$urlParams = 'force=1';
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$searchFormName = strtolower($form->get('searchFormName'));
|
||||
if ($searchFormName == 'search') {
|
||||
$session->replaceUserContext(CRM_Utils_System::url('civicrm/activity/search', $urlParams));
|
||||
}
|
||||
else {
|
||||
$session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/$searchFormName",
|
||||
$urlParams
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the membership id, compute the contact id
|
||||
* since it's used for things like send email.
|
||||
*/
|
||||
public function setContactIDs() {
|
||||
$IDs = implode(',', $this->_activityHolderIds);
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$query = "
|
||||
SELECT contact_id
|
||||
FROM civicrm_activity_contact
|
||||
WHERE activity_id IN ( $IDs ) AND
|
||||
record_type_id = {$sourceID}";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
while ($dao->fetch()) {
|
||||
$contactIDs[] = $dao->contact_id;
|
||||
}
|
||||
$this->_contactIds = $contactIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple shell that derived classes can call to add buttons to
|
||||
* the form with a customized title for the main Submit
|
||||
*
|
||||
* @param string $title
|
||||
* Title of the main button.
|
||||
* @param string $nextType
|
||||
* Button type for the form after processing.
|
||||
* @param string $backType
|
||||
* @param bool $submitOnce
|
||||
*/
|
||||
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => $nextType,
|
||||
'name' => $title,
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => $backType,
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
154
sites/all/modules/civicrm/CRM/Activity/Form/Task/AddToTag.php
Normal file
154
sites/all/modules/civicrm/CRM/Activity/Form/Task/AddToTag.php
Normal file
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to delete a group of
|
||||
* contacts. This class provides functionality for the actual
|
||||
* addition of contacts to groups.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Name of the tag.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* All the tags in the system.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_tags;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// add select for tag
|
||||
$this->_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
|
||||
|
||||
foreach ($this->_tags as $tagID => $tagName) {
|
||||
$this->_tagElement = &$this->addElement('checkbox', "tag[$tagID]", NULL, $tagName);
|
||||
}
|
||||
|
||||
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
|
||||
|
||||
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity');
|
||||
|
||||
$this->addDefaultButtons(ts('Tag Activities'));
|
||||
}
|
||||
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_Form_Task_AddToTag', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
* @param $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function formRule($form, $rule) {
|
||||
$errors = array();
|
||||
if (empty($form['tag']) && empty($form['activity_taglist'])) {
|
||||
$errors['_qf_default'] = ts("Please select at least one tag.");
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// Get the submitted values in an array.
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
$activityTags = $tagList = array();
|
||||
|
||||
// check if contact tags exists
|
||||
if (!empty($params['tag'])) {
|
||||
$activityTags = $params['tag'];
|
||||
}
|
||||
|
||||
// check if tags are selected from taglists
|
||||
if (!empty($params['activity_taglist'])) {
|
||||
foreach ($params['activity_taglist'] as $val) {
|
||||
if ($val) {
|
||||
if (is_numeric($val)) {
|
||||
$tagList[$val] = 1;
|
||||
}
|
||||
else {
|
||||
$tagIDs = explode(',', $val);
|
||||
if (!empty($tagIDs)) {
|
||||
foreach ($tagIDs as $tagID) {
|
||||
if (is_numeric($tagID)) {
|
||||
$tagList[$tagID] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tagSets = CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_activity', FALSE, TRUE);
|
||||
|
||||
foreach ($tagSets as $key => $value) {
|
||||
$this->_tags[$key] = $value['name'];
|
||||
}
|
||||
|
||||
// merge activity and taglist tags
|
||||
$allTags = CRM_Utils_Array::crmArrayMerge($activityTags, $tagList);
|
||||
|
||||
$this->_name = array();
|
||||
foreach ($allTags as $key => $dnc) {
|
||||
$this->_name[] = $this->_tags[$key];
|
||||
|
||||
list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_activityHolderIds, $key,
|
||||
'civicrm_activity', FALSE);
|
||||
|
||||
$status = array(ts('Activity tagged', array('count' => $added, 'plural' => '%count activities tagged')));
|
||||
if ($notAdded) {
|
||||
$status[] = ts('1 activity already had this tag', array(
|
||||
'count' => $notAdded,
|
||||
'plural' => '%count activities already had this tag',
|
||||
));
|
||||
}
|
||||
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
|
||||
CRM_Core_Session::setStatus($status, ts("Added Tag <em>%1</em>", array(1 => $this->_tags[$key])), 'success', array('expires' => 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
258
sites/all/modules/civicrm/CRM/Activity/Form/Task/Batch.php
Normal file
258
sites/all/modules/civicrm/CRM/Activity/Form/Task/Batch.php
Normal file
|
@ -0,0 +1,258 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality for batch profile update for Activities
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Maximum profile fields that will be displayed.
|
||||
*/
|
||||
protected $_maxFields = 9;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
|
||||
// Initialize the task and row fields.
|
||||
parent::preProcess();
|
||||
|
||||
// Get the contact read only fields to display.
|
||||
$readOnlyFields = array_merge(array('sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')),
|
||||
CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'contact_autocomplete_options',
|
||||
TRUE, NULL, FALSE, 'name', TRUE
|
||||
)
|
||||
);
|
||||
|
||||
// Get the read only field data.
|
||||
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
|
||||
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_activityHolderIds,
|
||||
'Activity', $returnProperties
|
||||
);
|
||||
$readOnlyFields['assignee_display_name'] = ts('Assigned to');
|
||||
if (!empty($contactDetails)) {
|
||||
foreach ($contactDetails as $key => $value) {
|
||||
$assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key);
|
||||
foreach ($assignee as $values) {
|
||||
$assigneeContact[] = CRM_Contact_BAO_Contact::displayName($values);
|
||||
}
|
||||
$contactDetails[$key]['assignee_display_name'] = !empty($assigneeContact) ? implode(';', $assigneeContact) : NULL;
|
||||
}
|
||||
}
|
||||
$this->assign('contactDetails', $contactDetails);
|
||||
$this->assign('readOnlyFields', $readOnlyFields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$ufGroupId = $this->get('ufGroupId');
|
||||
|
||||
if (!$ufGroupId) {
|
||||
throw new CRM_Core_Exception('The profile id is missing');
|
||||
}
|
||||
$this->_title = ts('Update multiple activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
|
||||
CRM_Utils_System::setTitle($this->_title);
|
||||
|
||||
$this->addDefaultButtons(ts('Save'));
|
||||
$this->_fields = array();
|
||||
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
|
||||
|
||||
// remove file type field and then limit fields
|
||||
$suppressFields = FALSE;
|
||||
$removehtmlTypes = array('File', 'Autocomplete-Select');
|
||||
foreach ($this->_fields as $name => $field) {
|
||||
if (CRM_Core_BAO_CustomField::getKeyID($name) &&
|
||||
in_array($this->_fields[$name]['html_type'], $removehtmlTypes)
|
||||
) {
|
||||
$suppressFields = TRUE;
|
||||
unset($this->_fields[$name]);
|
||||
}
|
||||
|
||||
// Fix to reduce size as we are using this field in grid.
|
||||
if (is_array($field['attributes']) && !empty($this->_fields[$name]['attributes']['size']) && $this->_fields[$name]['attributes']['size'] > 19) {
|
||||
// Shrink class to "form-text-medium".
|
||||
$this->_fields[$name]['attributes']['size'] = 19;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'name' => ts('Update Activities'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
));
|
||||
|
||||
$this->assign('profileTitle', $this->_title);
|
||||
$this->assign('componentIds', $this->_activityHolderIds);
|
||||
|
||||
// Load all campaigns.
|
||||
if (array_key_exists('activity_campaign_id', $this->_fields)) {
|
||||
$this->_componentCampaigns = array();
|
||||
CRM_Core_PseudoConstant::populate($this->_componentCampaigns,
|
||||
'CRM_Activity_DAO_Activity',
|
||||
TRUE, 'campaign_id', 'id',
|
||||
' id IN (' . implode(' , ', array_values($this->_activityHolderIds)) . ' ) '
|
||||
);
|
||||
}
|
||||
|
||||
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');
|
||||
// It is possible to have fields that are required in CiviCRM not be required in the
|
||||
// profile. Overriding that here. Perhaps a better approach would be to
|
||||
// make them required in the schema & read that up through getFields functionality.
|
||||
$requiredFields = array('activity_date_time');
|
||||
|
||||
foreach ($this->_activityHolderIds as $activityId) {
|
||||
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
|
||||
foreach ($this->_fields as $name => $field) {
|
||||
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
|
||||
$customValue = CRM_Utils_Array::value($customFieldID, $customFields);
|
||||
if (!empty($customValue['extends_entity_column_value'])) {
|
||||
$entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
$customValue['extends_entity_column_value']
|
||||
);
|
||||
}
|
||||
if (!empty($entityColumnValue[$typeId]) ||
|
||||
CRM_Utils_System::isNull($entityColumnValue[$typeId])
|
||||
) {
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Handle non custom fields.
|
||||
if (in_array($field['name'], $requiredFields)) {
|
||||
$field['is_required'] = TRUE;
|
||||
}
|
||||
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('fields', $this->_fields);
|
||||
|
||||
// Don't set the status message when form is submitted.
|
||||
// $buttonName = $this->controller->getButtonName('submit');
|
||||
|
||||
if ($suppressFields) {
|
||||
CRM_Core_Session::setStatus(ts("File or Autocomplete-Select type field(s) in the selected profile are not supported for Update multiple activities."), ts('Some Fields Excluded'), 'info');
|
||||
}
|
||||
|
||||
$this->addDefaultButtons(ts('Update Activities'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if (empty($this->_fields)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = array();
|
||||
foreach ($this->_activityHolderIds as $activityId) {
|
||||
CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $activityId, 'Activity');
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->exportValues();
|
||||
|
||||
if (isset($params['field'])) {
|
||||
foreach ($params['field'] as $key => $value) {
|
||||
|
||||
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($value,
|
||||
$key, 'Activity'
|
||||
);
|
||||
$value['id'] = $key;
|
||||
|
||||
if (!empty($value['activity_status_id'])) {
|
||||
$value['status_id'] = $value['activity_status_id'];
|
||||
}
|
||||
|
||||
if (!empty($value['activity_details'])) {
|
||||
$value['details'] = $value['activity_details'];
|
||||
}
|
||||
|
||||
if (!empty($value['activity_location'])) {
|
||||
$value['location'] = $value['activity_location'];
|
||||
}
|
||||
|
||||
if (!empty($value['activity_subject'])) {
|
||||
$value['subject'] = $value['activity_subject'];
|
||||
}
|
||||
|
||||
$activityId = civicrm_api3('activity', 'create', $value);
|
||||
|
||||
// @todo this would be done by the api call above if the parames were passed through.
|
||||
if (!empty($value['custom']) &&
|
||||
is_array($value['custom'])
|
||||
) {
|
||||
CRM_Core_BAO_CustomValueTable::store($value['custom'], 'civicrm_activity', $activityId['id']);
|
||||
}
|
||||
}
|
||||
CRM_Core_Session::setStatus("", ts("Updates Saved"), "success");
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus("", ts("No Updates Saved"), "info");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Delete.php
Normal file
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Delete.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to delete a group of
|
||||
* Activities. This class provides functionality for the actual
|
||||
* deletion.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Delete extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. deleting one
|
||||
* specific Activity?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addDefaultButtons(ts('Delete Activities'), 'done');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$deleted = $failed = 0;
|
||||
foreach ($this->_activityHolderIds as $activityId['id']) {
|
||||
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']);
|
||||
if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) {
|
||||
$deleted++;
|
||||
}
|
||||
else {
|
||||
$failed++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
$msg = ts('%count activity deleted.', array('plural' => '%count activities deleted.', 'count' => $deleted));
|
||||
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
96
sites/all/modules/civicrm/CRM/Activity/Form/Task/Email.php
Normal file
96
sites/all/modules/civicrm/CRM/Activity/Form/Task/Email.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to email a group of contacts.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Email extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. sending email to one
|
||||
* specific contact?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_single = FALSE;
|
||||
|
||||
public $_noEmails = FALSE;
|
||||
|
||||
/**
|
||||
* All the existing templates in the system.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_templates = NULL;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
|
||||
parent::preProcess();
|
||||
|
||||
// we have all the contribution ids, so now we get the contact ids
|
||||
parent::setContactIDs();
|
||||
|
||||
$this->assign('single', $this->_single);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// Enable form element.
|
||||
$this->assign('emailTask', TRUE);
|
||||
|
||||
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Contact_Form_Task_EmailCommon::postProcess($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* List available tokens for this form.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTokens() {
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
}
|
124
sites/all/modules/civicrm/CRM/Activity/Form/Task/FileOnCase.php
Normal file
124
sites/all/modules/civicrm/CRM/Activity/Form/Task/FileOnCase.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to email a group of contacts
|
||||
*/
|
||||
class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Variable to store contact Ids.
|
||||
*/
|
||||
public $_contacts;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_userContext = $session->readUserContext();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('File on Case'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addEntityRef('unclosed_case_id', ts('Select Case'), array('entity' => 'Case'), TRUE);
|
||||
$this->addDefaultButtons(ts('Save'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$formparams = $this->exportValues();
|
||||
$caseId = $formparams['unclosed_case_id'];
|
||||
$filedActivities = 0;
|
||||
foreach ($this->_activityHolderIds as $key => $id) {
|
||||
$targetContactValues = $defaults = array();
|
||||
$params = array('id' => $id);
|
||||
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
|
||||
if (CRM_Case_BAO_Case::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) {
|
||||
|
||||
if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
|
||||
$targetContactValues = array_combine(array_unique($defaults['target_contact']),
|
||||
explode(';', trim($defaults['target_contact_value']))
|
||||
);
|
||||
$targetContactValues = implode(',', array_keys($targetContactValues));
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'caseID' => $caseId,
|
||||
'activityID' => $id,
|
||||
'newSubject' => empty($defaults['subject']) ? '' : $defaults['subject'],
|
||||
'targetContactIds' => $targetContactValues,
|
||||
'mode' => 'file',
|
||||
);
|
||||
|
||||
$error_msg = CRM_Activity_Page_AJAX::_convertToCaseActivity($params);
|
||||
if (empty($error_msg['error_msg'])) {
|
||||
$filedActivities++;
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus($error_msg['error_msg'], ts("Error"), "error");
|
||||
}
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', array(
|
||||
1 => empty($defaults['subject']) ? '' : $defaults['subject'],
|
||||
2 => $defaults['activity_date_time'],
|
||||
)),
|
||||
ts("Error"), "error");
|
||||
}
|
||||
}
|
||||
|
||||
CRM_Core_Session::setStatus($filedActivities, ts("Filed Activities"), "success");
|
||||
CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info");
|
||||
}
|
||||
|
||||
}
|
173
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickOption.php
Normal file
173
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickOption.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to email a group of contacts.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Maximum Activities that should be allowed to update.
|
||||
*/
|
||||
protected $_maxActivities = 100;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Variable to store contact Ids.
|
||||
*/
|
||||
public $_contacts;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
|
||||
// initialize the task and row fields.
|
||||
parent::preProcess();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_userContext = $session->readUserContext();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Send Email to Contacts'));
|
||||
|
||||
$validate = FALSE;
|
||||
//validations
|
||||
if (count($this->_activityHolderIds) > $this->_maxActivities) {
|
||||
CRM_Core_Session::setStatus(ts("The maximum number of Activities you can select to send an email is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(
|
||||
1 => $this->_maxActivities,
|
||||
2 => count($this->_activityHolderIds),
|
||||
)), ts("Maximum Exceeded"), "error");
|
||||
$validate = TRUE;
|
||||
}
|
||||
// then redirect
|
||||
if ($validate) {
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addElement('checkbox', 'with_contact', ts('With Contact'));
|
||||
$this->addElement('checkbox', 'assigned_to', ts('Assigned to Contact'));
|
||||
$this->addElement('checkbox', 'created_by', ts('Created by'));
|
||||
$this->setDefaults(array('with_contact' => 1));
|
||||
$this->addDefaultButtons(ts('Continue'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add local and global form rules.
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_Form_Task_PickOption', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $fields
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* list of errors to be posted back to the form
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
if (!isset($fields['with_contact']) &&
|
||||
!isset($fields['assigned_to']) &&
|
||||
!isset($fields['created_by'])
|
||||
) {
|
||||
return array('with_contact' => ts('You must select at least one email recipient type.'));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// Clear any formRule errors from Email form in case they came back here via Cancel button
|
||||
$this->controller->resetPage('Email');
|
||||
$params = $this->exportValues();
|
||||
$this->_contacts = array();
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
// Get assignee contacts.
|
||||
if (!empty($params['assigned_to'])) {
|
||||
foreach ($this->_activityHolderIds as $key => $id) {
|
||||
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $assigneeID));
|
||||
$this->_contacts = array_merge($this->_contacts, $ids);
|
||||
}
|
||||
}
|
||||
// Get target contacts.
|
||||
if (!empty($params['with_contact'])) {
|
||||
foreach ($this->_activityHolderIds as $key => $id) {
|
||||
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID));
|
||||
$this->_contacts = array_merge($this->_contacts, $ids);
|
||||
}
|
||||
}
|
||||
// Get 'Added by' contacts.
|
||||
if (!empty($params['created_by'])) {
|
||||
parent::setContactIDs();
|
||||
if (!empty($this->_contactIds)) {
|
||||
$this->_contacts = array_merge($this->_contacts, $this->_contactIds);
|
||||
}
|
||||
}
|
||||
$this->_contacts = array_unique($this->_contacts);
|
||||
|
||||
// Bounce to pick option if no contacts to send to.
|
||||
if (empty($this->_contacts)) {
|
||||
$urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}";
|
||||
$urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams);
|
||||
CRM_Core_Error::statusBounce(
|
||||
ts('It appears you have no contacts with email addresses from the selected recipients.'),
|
||||
$urlRedirect
|
||||
);
|
||||
}
|
||||
|
||||
$this->set('contacts', $this->_contacts);
|
||||
}
|
||||
|
||||
}
|
161
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickProfile.php
Normal file
161
sites/all/modules/civicrm/CRM/Activity/Form/Task/PickProfile.php
Normal file
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality for batch profile update for Activity.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* The title of the group.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Maximum Activities that should be allowed to update.
|
||||
*/
|
||||
protected $_maxActivities = 100;
|
||||
|
||||
/**
|
||||
* Variable to store redirect path.
|
||||
*/
|
||||
protected $_userContext;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
|
||||
// Initialize the task and row fields.
|
||||
parent::preProcess();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_userContext = $session->readUserContext();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Update multiple activities'));
|
||||
|
||||
$validate = FALSE;
|
||||
// Validations.
|
||||
if (count($this->_activityHolderIds) > $this->_maxActivities) {
|
||||
CRM_Core_Session::setStatus(ts("The maximum number of activities you can select for Update multiple activities is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array(
|
||||
1 => $this->_maxActivities,
|
||||
2 => count($this->_activityHolderIds),
|
||||
)), ts('Maximum Exceeded'), 'error');
|
||||
$validate = TRUE;
|
||||
}
|
||||
|
||||
// Then redirect.
|
||||
if ($validate) {
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$types = array('Activity');
|
||||
$profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE);
|
||||
|
||||
$activityTypeIds = array_flip(CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name'));
|
||||
$nonEditableActivityTypeIds = array(
|
||||
$activityTypeIds['Email'],
|
||||
$activityTypeIds['Bulk Email'],
|
||||
$activityTypeIds['Contribution'],
|
||||
$activityTypeIds['Inbound Email'],
|
||||
$activityTypeIds['Pledge Reminder'],
|
||||
$activityTypeIds['Membership Signup'],
|
||||
$activityTypeIds['Membership Renewal'],
|
||||
$activityTypeIds['Event Registration'],
|
||||
$activityTypeIds['Pledge Acknowledgment'],
|
||||
);
|
||||
$notEditable = FALSE;
|
||||
foreach ($this->_activityHolderIds as $activityId) {
|
||||
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
|
||||
if (in_array($typeId, $nonEditableActivityTypeIds)) {
|
||||
$notEditable = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($profiles)) {
|
||||
CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple activities. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts("No Profile Configured"), "alert");
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
elseif ($notEditable) {
|
||||
CRM_Core_Session::setStatus("", ts("Some of the selected activities are not editable."), "alert");
|
||||
CRM_Utils_System::redirect($this->_userContext);
|
||||
}
|
||||
|
||||
$ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'),
|
||||
array(
|
||||
'' => ts('- select profile -'),
|
||||
) + $profiles, TRUE
|
||||
);
|
||||
$this->addDefaultButtons(ts('Continue'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add local and global form rules.
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_Form_Task_PickProfile', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $fields
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* list of errors to be posted back to the form
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->exportValues();
|
||||
|
||||
$this->set('ufGroupId', $params['uf_group_id']);
|
||||
|
||||
// also reset the batch page so it gets new values from the db
|
||||
$this->controller->resetPage('Batch');
|
||||
}
|
||||
|
||||
}
|
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Print.php
Normal file
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/Print.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to print activity records.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_Print extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preprocess();
|
||||
|
||||
// set print view, so that print templates are called
|
||||
$this->controller->setPrint(1);
|
||||
|
||||
// get the formatted params
|
||||
$queryParams = $this->get('queryParams');
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$selector = new CRM_Activity_Selector_Search($queryParams, $this->_action, $this->_componentClause);
|
||||
$controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* Consists of
|
||||
* - displaying the QILL (query in local language)
|
||||
* - displaying elements for saving the search
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
// just need to add a javacript to popup the window for printing
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Print Activities'),
|
||||
'js' => array('onclick' => 'window.print()'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Done'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to remove tags of contact(s).
|
||||
*/
|
||||
class CRM_Activity_Form_Task_RemoveFromTag extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Name of the tag
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* All the tags in the system
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_tags;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// add select for tag
|
||||
$this->_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
|
||||
foreach ($this->_tags as $tagID => $tagName) {
|
||||
$this->_tagElement = &$this->addElement('checkbox', "tag[$tagID]", NULL, $tagName);
|
||||
}
|
||||
|
||||
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
|
||||
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE);
|
||||
|
||||
$this->addDefaultButtons(ts('Remove Tags from activities'));
|
||||
}
|
||||
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Activity_Form_Task_RemoveFromTag', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
* @param $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function formRule($form, $rule) {
|
||||
$errors = array();
|
||||
if (empty($form['tag']) && empty($form['activity_taglist'])) {
|
||||
$errors['_qf_default'] = "Please select atleast one tag.";
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
//get the submitted values in an array
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$activityTags = $tagList = array();
|
||||
|
||||
// check if contact tags exists
|
||||
if (!empty($params['tag'])) {
|
||||
$activityTags = $params['tag'];
|
||||
}
|
||||
|
||||
// check if tags are selected from taglists
|
||||
if (!empty($params['activity_taglist'])) {
|
||||
foreach ($params['activity_taglist'] as $val) {
|
||||
if ($val) {
|
||||
if (is_numeric($val)) {
|
||||
$tagList[$val] = 1;
|
||||
}
|
||||
else {
|
||||
list($label, $tagID) = explode(',', $val);
|
||||
$tagList[$tagID] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tagSets = CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_activity', FALSE, TRUE);
|
||||
|
||||
foreach ($tagSets as $key => $value) {
|
||||
$this->_tags[$key] = $value['name'];
|
||||
}
|
||||
// merge contact and taglist tags
|
||||
$allTags = CRM_Utils_Array::crmArrayMerge($activityTags, $tagList);
|
||||
|
||||
$this->_name = array();
|
||||
foreach ($allTags as $key => $dnc) {
|
||||
$this->_name[] = $this->_tags[$key];
|
||||
|
||||
list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeEntitiesFromTag($this->_activityHolderIds,
|
||||
$key, 'civicrm_activity', FALSE);
|
||||
|
||||
$status = array(
|
||||
ts('%count activity un-tagged', array(
|
||||
'count' => $removed,
|
||||
'plural' => '%count activities un-tagged',
|
||||
)),
|
||||
);
|
||||
if ($notRemoved) {
|
||||
$status[] = ts('1 activity already did not have this tag', array(
|
||||
'count' => $notRemoved,
|
||||
'plural' => '%count activities already did not have this tag',
|
||||
));
|
||||
}
|
||||
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
|
||||
CRM_Core_Session::setStatus($status, ts("Removed Tag <em>%1</em>", array(1 => $this->_tags[$key])), 'success', array('expires' => 0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/SMS.php
Normal file
88
sites/all/modules/civicrm/CRM/Activity/Form/Task/SMS.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to sms a group of contacts.
|
||||
*/
|
||||
class CRM_Activity_Form_Task_SMS extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Are we operating in "single mode", i.e. sending sms to one
|
||||
* specific contact?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $_single = FALSE;
|
||||
|
||||
/**
|
||||
* All the existing templates in the system.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_templates = NULL;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
CRM_Contact_Form_Task_SMSCommon::preProcessProvider($this);
|
||||
$this->assign('single', $this->_single);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// Enable form element.
|
||||
$this->assign('SMSTask', TRUE);
|
||||
CRM_Contact_Form_Task_SMSCommon::buildQuickForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Contact_Form_Task_SMSCommon::postProcess($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* List available tokens for this form.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTokens() {
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to save a search
|
||||
* Saved Searches are used for saving frequently used queries
|
||||
*/
|
||||
class CRM_Activity_Form_Task_SearchTaskHookSample extends CRM_Activity_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$rows = array();
|
||||
// display name and activity details of all selected contacts
|
||||
$activityIDs = implode(',', $this->_activityHolderIds);
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$query = "
|
||||
SELECT at.subject as subject,
|
||||
ov.label as activity_type,
|
||||
at.activity_date_time as activity_date,
|
||||
ct.display_name as display_name
|
||||
FROM civicrm_activity at
|
||||
LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = at.id AND ac.record_type_id = {$sourceID} )
|
||||
INNER JOIN civicrm_contact ct ON ( ac.contact_id = ct.id )
|
||||
LEFT JOIN civicrm_option_group og ON ( og.name = 'activity_type' )
|
||||
LEFT JOIN civicrm_option_value ov ON (at.activity_type_id = ov.value AND og.id = ov.option_group_id )
|
||||
WHERE at.id IN ( $activityIDs )";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$rows[] = array(
|
||||
'subject' => $dao->subject,
|
||||
'activity_type' => $dao->activity_type,
|
||||
'activity_date' => $dao->activity_date,
|
||||
'display_name' => $dao->display_name,
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'done',
|
||||
'name' => ts('Done'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
60
sites/all/modules/civicrm/CRM/Activity/Import/Controller.php
Normal file
60
sites/all/modules/civicrm/CRM/Activity/Import/Controller.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Activity_Import_Controller extends CRM_Core_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param string $title
|
||||
* @param bool|int $action
|
||||
* @param bool $modal
|
||||
*/
|
||||
public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) {
|
||||
parent::__construct($title, $modal);
|
||||
|
||||
// lets get around the time limit issue if possible, CRM-2113
|
||||
if (!ini_get('safe_mode')) {
|
||||
set_time_limit(0);
|
||||
}
|
||||
|
||||
$this->_stateMachine = new CRM_Import_StateMachine($this, $action);
|
||||
|
||||
// create and instantiate the pages
|
||||
$this->addPages($this->_stateMachine, $action);
|
||||
|
||||
// add all the actions
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$this->addActions($config->uploadDir, array('uploadFile'));
|
||||
}
|
||||
|
||||
}
|
123
sites/all/modules/civicrm/CRM/Activity/Import/Field.php
Normal file
123
sites/all/modules/civicrm/CRM/Activity/Import/Field.php
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Activity_Import_Field {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* Name of the field
|
||||
*/
|
||||
public $_name;
|
||||
|
||||
/**
|
||||
* Title of the field to be used in display
|
||||
*/
|
||||
public $_title;
|
||||
|
||||
/**
|
||||
* Type of field
|
||||
* @var enum
|
||||
*/
|
||||
public $_type;
|
||||
|
||||
/**
|
||||
* Is this field required
|
||||
* @var boolean
|
||||
*/
|
||||
public $_required;
|
||||
|
||||
/**
|
||||
* Data to be carried for use by a derived class
|
||||
* @var object
|
||||
*/
|
||||
public $_payload;
|
||||
|
||||
/**
|
||||
* Regexp to match the CSV header of this column/field
|
||||
* @var string
|
||||
*/
|
||||
public $_headerPattern;
|
||||
|
||||
/**
|
||||
* Regexp to match the pattern of data from various column/fields
|
||||
* @var string
|
||||
*/
|
||||
public $_dataPattern;
|
||||
|
||||
/**
|
||||
* Value of this field
|
||||
* @var object
|
||||
*/
|
||||
public $_value;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $title
|
||||
* @param int $type
|
||||
* @param string $headerPattern
|
||||
* @param string $dataPattern
|
||||
*/
|
||||
public function __construct($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') {
|
||||
$this->_name = $name;
|
||||
$this->_title = $title;
|
||||
$this->_type = $type;
|
||||
$this->_headerPattern = $headerPattern;
|
||||
$this->_dataPattern = $dataPattern;
|
||||
|
||||
$this->_value = NULL;
|
||||
}
|
||||
|
||||
public function resetValue() {
|
||||
$this->_value = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value is in string format. convert the value to the type of this field
|
||||
* and set the field value with the appropriate type
|
||||
* @param $value
|
||||
*/
|
||||
public function setValue($value) {
|
||||
$this->_value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function validate() {
|
||||
|
||||
if (CRM_Utils_System::isNull($this->_value)) {
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class gets the name of the file to upload.
|
||||
*/
|
||||
class CRM_Activity_Import_Form_DataSource extends CRM_Import_Form_DataSource {
|
||||
|
||||
const PATH = 'civicrm/import/activity';
|
||||
|
||||
const IMPORT_ENTITY = 'Activity';
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
// FIXME: This 'onDuplicate' form element is never used -- copy/paste error?
|
||||
$duplicateOptions = array();
|
||||
$duplicateOptions[] = $this->createElement('radio',
|
||||
NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP
|
||||
);
|
||||
$duplicateOptions[] = $this->createElement('radio',
|
||||
NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE
|
||||
);
|
||||
$duplicateOptions[] = $this->createElement('radio',
|
||||
NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL
|
||||
);
|
||||
|
||||
$this->addGroup($duplicateOptions, 'onDuplicate',
|
||||
ts('On duplicate entries')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the uploaded file.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$this->storeFormValues(array(
|
||||
'onDuplicate',
|
||||
'dateFormats',
|
||||
'savedMapping',
|
||||
));
|
||||
|
||||
$this->submitFileForMapping('CRM_Activity_Import_Parser_Activity');
|
||||
}
|
||||
|
||||
}
|
471
sites/all/modules/civicrm/CRM/Activity/Import/Form/MapField.php
Normal file
471
sites/all/modules/civicrm/CRM/Activity/Import/Form/MapField.php
Normal file
|
@ -0,0 +1,471 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class gets the name of the file to upload.
|
||||
*/
|
||||
class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
|
||||
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_mapperFields = $this->get('fields');
|
||||
unset($this->_mapperFields['id']);
|
||||
asort($this->_mapperFields);
|
||||
|
||||
$this->_columnCount = $this->get('columnCount');
|
||||
$this->assign('columnCount', $this->_columnCount);
|
||||
$this->_dataValues = $this->get('dataValues');
|
||||
$this->assign('dataValues', $this->_dataValues);
|
||||
|
||||
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
|
||||
|
||||
if ($skipColumnHeader) {
|
||||
$this->assign('skipColumnHeader', $skipColumnHeader);
|
||||
$this->assign('rowDisplayCount', 3);
|
||||
// If we had a column header to skip, stash it for later.
|
||||
|
||||
$this->_columnHeaders = $this->_dataValues[0];
|
||||
}
|
||||
else {
|
||||
$this->assign('rowDisplayCount', 2);
|
||||
}
|
||||
$highlightedFields = array();
|
||||
$requiredFields = array(
|
||||
'activity_date_time',
|
||||
'activity_type_id',
|
||||
'activity_label',
|
||||
'target_contact_id',
|
||||
'activity_subject',
|
||||
);
|
||||
foreach ($requiredFields as $val) {
|
||||
$highlightedFields[] = $val;
|
||||
}
|
||||
$this->assign('highlightedFields', $highlightedFields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// To save the current mappings.
|
||||
if (!$this->get('savedMapping')) {
|
||||
$saveDetailsName = ts('Save this field mapping');
|
||||
$this->applyFilter('saveMappingName', 'trim');
|
||||
$this->add('text', 'saveMappingName', ts('Name'));
|
||||
$this->add('text', 'saveMappingDesc', ts('Description'));
|
||||
}
|
||||
else {
|
||||
$savedMapping = $this->get('savedMapping');
|
||||
// Mapping is to be loaded from database.
|
||||
|
||||
list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingRelation) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping);
|
||||
|
||||
// Get loaded Mapping Fields.
|
||||
$mappingName = CRM_Utils_Array::value('1', $mappingName);
|
||||
$mappingContactType = CRM_Utils_Array::value('1', $mappingContactType);
|
||||
$mappingLocation = CRM_Utils_Array::value('1', $mappingLocation);
|
||||
$mappingPhoneType = CRM_Utils_Array::value('1', $mappingPhoneType);
|
||||
$mappingRelation = CRM_Utils_Array::value('1', $mappingRelation);
|
||||
|
||||
$this->assign('loadedMapping', $savedMapping);
|
||||
$this->set('loadedMapping', $savedMapping);
|
||||
|
||||
$params = array('id' => $savedMapping);
|
||||
$temp = array();
|
||||
$mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
|
||||
|
||||
$this->assign('savedName', $mappingDetails->name);
|
||||
|
||||
$this->add('hidden', 'mappingId', $savedMapping);
|
||||
|
||||
$this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
|
||||
$saveDetailsName = ts('Save as a new field mapping');
|
||||
$this->add('text', 'saveMappingName', ts('Name'));
|
||||
$this->add('text', 'saveMappingDesc', ts('Description'));
|
||||
}
|
||||
|
||||
$this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
|
||||
|
||||
$this->addFormRule(array('CRM_Activity_Import_Form_MapField', 'formRule'));
|
||||
|
||||
//-------- end of saved mapping stuff ---------
|
||||
|
||||
$defaults = array();
|
||||
$mapperKeys = array_keys($this->_mapperFields);
|
||||
|
||||
$hasHeaders = !empty($this->_columnHeaders);
|
||||
$headerPatterns = $this->get('headerPatterns');
|
||||
$dataPatterns = $this->get('dataPatterns');
|
||||
$hasLocationTypes = $this->get('fieldTypes');
|
||||
|
||||
// Initialize all field usages to false.
|
||||
|
||||
foreach ($mapperKeys as $key) {
|
||||
$this->_fieldUsed[$key] = FALSE;
|
||||
}
|
||||
$this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
|
||||
$sel1 = $this->_mapperFields;
|
||||
|
||||
$sel2[''] = NULL;
|
||||
|
||||
$js = "<script type='text/javascript'>\n";
|
||||
$formName = 'document.forms.' . $this->_name;
|
||||
|
||||
// Used to warn for mismatch column count or mismatch mapping.
|
||||
$warning = 0;
|
||||
|
||||
for ($i = 0; $i < $this->_columnCount; $i++) {
|
||||
$sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', array(1 => $i)), NULL);
|
||||
$jsSet = FALSE;
|
||||
if ($this->get('savedMapping')) {
|
||||
if (isset($mappingName[$i])) {
|
||||
if ($mappingName[$i] != ts('- do not import -')) {
|
||||
|
||||
$mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);
|
||||
|
||||
if (!isset($locationId) || !$locationId) {
|
||||
$js .= "{$formName}['mapper[$i][1]'].style.display = 'none';\n";
|
||||
}
|
||||
|
||||
if (!isset($phoneType) || !$phoneType) {
|
||||
$js .= "{$formName}['mapper[$i][2]'].style.display = 'none';\n";
|
||||
}
|
||||
|
||||
$js .= "{$formName}['mapper[$i][3]'].style.display = 'none';\n";
|
||||
$defaults["mapper[$i]"] = array(
|
||||
$mappingHeader[0],
|
||||
(isset($locationId)) ? $locationId : "",
|
||||
(isset($phoneType)) ? $phoneType : "",
|
||||
);
|
||||
$jsSet = TRUE;
|
||||
}
|
||||
else {
|
||||
$defaults["mapper[$i]"] = array();
|
||||
}
|
||||
if (!$jsSet) {
|
||||
for ($k = 1; $k < 4; $k++) {
|
||||
$js .= "{$formName}['mapper[$i][$k]'].style.display = 'none';\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// this load section to help mapping if we ran out of saved columns when doing Load Mapping
|
||||
$js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_" . $i . "_');\n";
|
||||
|
||||
if ($hasHeaders) {
|
||||
$defaults["mapper[$i]"] = array(
|
||||
$this->defaultFromHeader($this->_columnHeaders[$i],
|
||||
$headerPatterns
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$defaults["mapper[$i]"] = array($this->defaultFromData($dataPatterns, $i));
|
||||
}
|
||||
}
|
||||
// End of load mapping.
|
||||
}
|
||||
else {
|
||||
$js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_" . $i . "_');\n";
|
||||
if ($hasHeaders) {
|
||||
// Infer the default from the skipped headers if we have them
|
||||
$defaults["mapper[$i]"] = array(
|
||||
$this->defaultFromHeader($this->_columnHeaders[$i],
|
||||
$headerPatterns
|
||||
),
|
||||
0,
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Otherwise guess the default from the form of the data
|
||||
$defaults["mapper[$i]"] = array(
|
||||
$this->defaultFromData($dataPatterns, $i),
|
||||
0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$sel->setOptions(array($sel1, $sel2, (isset($sel3)) ? $sel3 : "", (isset($sel4)) ? $sel4 : ""));
|
||||
}
|
||||
$js .= "</script>\n";
|
||||
$this->assign('initHideBoxes', $js);
|
||||
|
||||
// Set warning if mismatch in more than.
|
||||
if (isset($mappingName)) {
|
||||
if (($this->_columnCount != count($mappingName))) {
|
||||
$warning++;
|
||||
}
|
||||
}
|
||||
if ($warning != 0 && $this->get('savedMapping')) {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->setStatus(ts('The data columns in this import file appear to be different from the saved mapping. Please verify that you have selected the correct saved mapping before continuing.'));
|
||||
}
|
||||
else {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->setStatus(NULL);
|
||||
}
|
||||
|
||||
$this->setDefaults($defaults);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Previous'),
|
||||
),
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Continue'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $fields
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* list of errors to be posted back to the form
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
$errors = array();
|
||||
// define so we avoid notices below
|
||||
$errors['_qf_default'] = '';
|
||||
|
||||
$fieldMessage = NULL;
|
||||
if (!array_key_exists('savedMapping', $fields)) {
|
||||
$importKeys = array();
|
||||
foreach ($fields['mapper'] as $mapperPart) {
|
||||
$importKeys[] = $mapperPart[0];
|
||||
}
|
||||
// FIXME: should use the schema titles, not redeclare them
|
||||
$requiredFields = array(
|
||||
'target_contact_id' => ts('Contact ID'),
|
||||
'activity_date_time' => ts('Activity Date'),
|
||||
'activity_subject' => ts('Activity Subject'),
|
||||
'activity_type_id' => ts('Activity Type ID'),
|
||||
);
|
||||
|
||||
$params = array(
|
||||
'used' => 'Unsupervised',
|
||||
'contact_type' => 'Individual',
|
||||
);
|
||||
list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
|
||||
$weightSum = 0;
|
||||
foreach ($importKeys as $key => $val) {
|
||||
if (array_key_exists($val, $ruleFields)) {
|
||||
$weightSum += $ruleFields[$val];
|
||||
}
|
||||
}
|
||||
foreach ($ruleFields as $field => $weight) {
|
||||
$fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
|
||||
}
|
||||
foreach ($requiredFields as $field => $title) {
|
||||
if (!in_array($field, $importKeys)) {
|
||||
if ($field == 'target_contact_id') {
|
||||
if ($weightSum >= $threshold || in_array('external_identifier', $importKeys)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$errors['_qf_default'] .= ts('Missing required contact matching fields.')
|
||||
. $fieldMessage . ' '
|
||||
. ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold))
|
||||
. '<br />';
|
||||
}
|
||||
}
|
||||
elseif ($field == 'activity_type_id') {
|
||||
if (in_array('activity_label', $importKeys)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$errors['_qf_default'] .= ts('Missing required field: Provide %1 or %2',
|
||||
array(
|
||||
1 => $title,
|
||||
2 => 'Activity Type Label',
|
||||
)) . '<br />';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fields['saveMapping'])) {
|
||||
$nameField = CRM_Utils_Array::value('saveMappingName', $fields);
|
||||
if (empty($nameField)) {
|
||||
$errors['saveMappingName'] = ts('Name is required to save Import Mapping');
|
||||
}
|
||||
else {
|
||||
$mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name');
|
||||
if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
|
||||
$errors['saveMappingName'] = ts('Duplicate Import Mapping Name');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errors['_qf_default'])) {
|
||||
unset($errors['_qf_default']);
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
if (!empty($errors['saveMappingName'])) {
|
||||
$_flag = 1;
|
||||
$assignError = new CRM_Core_Page();
|
||||
$assignError->assign('mappingDetailsError', $_flag);
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the mapped fields and map it into the uploaded file.
|
||||
*
|
||||
* Preview the file and extract some summary statistics
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues('MapField');
|
||||
// Reload the mapfield if load mapping is pressed.
|
||||
if (!empty($params['savedMapping'])) {
|
||||
$this->set('savedMapping', $params['savedMapping']);
|
||||
$this->controller->resetPage($this->_name);
|
||||
return;
|
||||
}
|
||||
|
||||
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
|
||||
$seperator = $this->controller->exportValue('DataSource', 'fieldSeparator');
|
||||
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
|
||||
|
||||
$mapperKeys = array();
|
||||
$mapper = array();
|
||||
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
|
||||
$mapperKeysMain = array();
|
||||
$mapperLocType = array();
|
||||
$mapperPhoneType = array();
|
||||
|
||||
for ($i = 0; $i < $this->_columnCount; $i++) {
|
||||
$mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]];
|
||||
$mapperKeysMain[$i] = $mapperKeys[$i][0];
|
||||
|
||||
if ((CRM_Utils_Array::value(1, $mapperKeys[$i])) && (is_numeric($mapperKeys[$i][1]))) {
|
||||
$mapperLocType[$i] = $mapperKeys[$i][1];
|
||||
}
|
||||
else {
|
||||
$mapperLocType[$i] = NULL;
|
||||
}
|
||||
|
||||
if ((CRM_Utils_Array::value(2, $mapperKeys[$i])) && (!is_numeric($mapperKeys[$i][2]))) {
|
||||
$mapperPhoneType[$i] = $mapperKeys[$i][2];
|
||||
}
|
||||
else {
|
||||
$mapperPhoneType[$i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$this->set('mapper', $mapper);
|
||||
// store mapping Id to display it in the preview page
|
||||
if (!empty($params['mappingId'])) {
|
||||
$this->set('loadMappingId', $params['mappingId']);
|
||||
}
|
||||
|
||||
// Updating Mapping Records.
|
||||
if (!empty($params['updateMapping'])) {
|
||||
|
||||
$mappingFields = new CRM_Core_DAO_MappingField();
|
||||
$mappingFields->mapping_id = $params['mappingId'];
|
||||
$mappingFields->find();
|
||||
|
||||
$mappingFieldsId = array();
|
||||
while ($mappingFields->fetch()) {
|
||||
if ($mappingFields->id) {
|
||||
$mappingFieldsId[$mappingFields->column_number] = $mappingFields->id;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $this->_columnCount; $i++) {
|
||||
$updateMappingFields = new CRM_Core_DAO_MappingField();
|
||||
$updateMappingFields->id = $mappingFieldsId[$i];
|
||||
$updateMappingFields->mapping_id = $params['mappingId'];
|
||||
$updateMappingFields->column_number = $i;
|
||||
|
||||
$updateMappingFields->name = $mapper[$i];
|
||||
$updateMappingFields->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Saving Mapping Details and Records.
|
||||
if (!empty($params['saveMapping'])) {
|
||||
$mappingParams = array(
|
||||
'name' => $params['saveMappingName'],
|
||||
'description' => $params['saveMappingDesc'],
|
||||
'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
|
||||
'Import Activity',
|
||||
'name'
|
||||
),
|
||||
);
|
||||
$saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
|
||||
|
||||
for ($i = 0; $i < $this->_columnCount; $i++) {
|
||||
$saveMappingFields = new CRM_Core_DAO_MappingField();
|
||||
$saveMappingFields->mapping_id = $saveMapping->id;
|
||||
$saveMappingFields->column_number = $i;
|
||||
|
||||
$saveMappingFields->name = $mapper[$i];
|
||||
$saveMappingFields->save();
|
||||
}
|
||||
$this->set('savedMapping', $saveMappingFields->mapping_id);
|
||||
}
|
||||
|
||||
$parser = new CRM_Activity_Import_Parser_Activity($mapperKeysMain, $mapperLocType, $mapperPhoneType);
|
||||
$parser->run($fileName, $seperator, $mapper, $skipColumnHeader,
|
||||
CRM_Import_Parser::MODE_PREVIEW
|
||||
);
|
||||
|
||||
// add all the necessary variables to the form
|
||||
$parser->set($this);
|
||||
}
|
||||
|
||||
}
|
188
sites/all/modules/civicrm/CRM/Activity/Import/Form/Preview.php
Normal file
188
sites/all/modules/civicrm/CRM/Activity/Import/Form/Preview.php
Normal file
|
@ -0,0 +1,188 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class previews the uploaded file and returns summary statistics.
|
||||
*/
|
||||
class CRM_Activity_Import_Form_Preview extends CRM_Import_Form_Preview {
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
|
||||
|
||||
// Get the data from the session.
|
||||
$dataValues = $this->get('dataValues');
|
||||
$mapper = $this->get('mapper');
|
||||
$invalidRowCount = $this->get('invalidRowCount');
|
||||
$conflictRowCount = $this->get('conflictRowCount');
|
||||
$mismatchCount = $this->get('unMatchCount');
|
||||
|
||||
// Get the mapping name displayed if the mappingId is set.
|
||||
$mappingId = $this->get('loadMappingId');
|
||||
if ($mappingId) {
|
||||
$mapDAO = new CRM_Core_DAO_Mapping();
|
||||
$mapDAO->id = $mappingId;
|
||||
$mapDAO->find(TRUE);
|
||||
$this->assign('loadedMapping', $mappingId);
|
||||
$this->assign('savedName', $mapDAO->name);
|
||||
}
|
||||
|
||||
if ($skipColumnHeader) {
|
||||
$this->assign('skipColumnHeader', $skipColumnHeader);
|
||||
$this->assign('rowDisplayCount', 3);
|
||||
}
|
||||
else {
|
||||
$this->assign('rowDisplayCount', 2);
|
||||
}
|
||||
|
||||
if ($invalidRowCount) {
|
||||
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
}
|
||||
|
||||
if ($conflictRowCount) {
|
||||
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
}
|
||||
|
||||
if ($mismatchCount) {
|
||||
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
}
|
||||
|
||||
$properties = array(
|
||||
'mapper',
|
||||
'dataValues',
|
||||
'columnCount',
|
||||
'totalRowCount',
|
||||
'validRowCount',
|
||||
'invalidRowCount',
|
||||
'conflictRowCount',
|
||||
'downloadErrorRecordsUrl',
|
||||
'downloadConflictRecordsUrl',
|
||||
'downloadMismatchRecordsUrl',
|
||||
);
|
||||
|
||||
foreach ($properties as $property) {
|
||||
$this->assign($property, $this->get($property));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the mapped fields and map it into the uploaded file.
|
||||
*
|
||||
* Preview the file and extract some summary statistics
|
||||
*/
|
||||
public function postProcess() {
|
||||
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
|
||||
$seperator = $this->controller->exportValue('DataSource', 'fieldSeparator');
|
||||
$skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
|
||||
$invalidRowCount = $this->get('invalidRowCount');
|
||||
$conflictRowCount = $this->get('conflictRowCount');
|
||||
$onDuplicate = $this->get('onDuplicate');
|
||||
|
||||
$mapper = $this->controller->exportValue('MapField', 'mapper');
|
||||
$mapperKeys = array();
|
||||
$mapperLocType = array();
|
||||
$mapperPhoneType = array();
|
||||
|
||||
foreach ($mapper as $key => $value) {
|
||||
$mapperKeys[$key] = $mapper[$key][0];
|
||||
|
||||
if (!empty($mapper[$key][1]) && is_numeric($mapper[$key][1])) {
|
||||
$mapperLocType[$key] = $mapper[$key][1];
|
||||
}
|
||||
else {
|
||||
$mapperLocType[$key] = NULL;
|
||||
}
|
||||
|
||||
if (!empty($mapper[$key][2]) && (!is_numeric($mapper[$key][2]))) {
|
||||
$mapperPhoneType[$key] = $mapper[$key][2];
|
||||
}
|
||||
else {
|
||||
$mapperPhoneType[$key] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$parser = new CRM_Activity_Import_Parser_Activity($mapperKeys, $mapperLocType, $mapperPhoneType);
|
||||
|
||||
$mapFields = $this->get('fields');
|
||||
|
||||
foreach ($mapper as $key => $value) {
|
||||
$header = array();
|
||||
if (isset($mapFields[$mapper[$key][0]])) {
|
||||
$header[] = $mapFields[$mapper[$key][0]];
|
||||
}
|
||||
$mapperFields[] = implode(' - ', $header);
|
||||
}
|
||||
$parser->run($fileName, $seperator,
|
||||
$mapperFields,
|
||||
$skipColumnHeader,
|
||||
CRM_Import_Parser::MODE_IMPORT,
|
||||
$onDuplicate
|
||||
);
|
||||
|
||||
// add all the necessary variables to the form
|
||||
$parser->set($this, CRM_Import_Parser::MODE_IMPORT);
|
||||
|
||||
// check if there is any error occurred
|
||||
|
||||
$errorStack = CRM_Core_Error::singleton();
|
||||
$errors = $errorStack->getErrors();
|
||||
$errorMessage = array();
|
||||
|
||||
if (is_array($errors)) {
|
||||
foreach ($errors as $key => $value) {
|
||||
$errorMessage[] = $value['message'];
|
||||
}
|
||||
|
||||
$errorFile = $fileName['name'] . '.error.log';
|
||||
|
||||
if ($fd = fopen($errorFile, 'w')) {
|
||||
fwrite($fd, implode('\n', $errorMessage));
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
$this->set('errorFile', $errorFile);
|
||||
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
110
sites/all/modules/civicrm/CRM/Activity/Import/Form/Summary.php
Normal file
110
sites/all/modules/civicrm/CRM/Activity/Import/Form/Summary.php
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class summarizes the import results.
|
||||
*/
|
||||
class CRM_Activity_Import_Form_Summary extends CRM_Import_Form_Summary {
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*/
|
||||
public function preProcess() {
|
||||
// set the error message path to display
|
||||
$this->assign('errorFile', $this->get('errorFile'));
|
||||
|
||||
$totalRowCount = $this->get('totalRowCount');
|
||||
$relatedCount = $this->get('relatedCount');
|
||||
$totalRowCount += $relatedCount;
|
||||
$this->set('totalRowCount', $totalRowCount);
|
||||
|
||||
$invalidRowCount = $this->get('invalidRowCount');
|
||||
$conflictRowCount = $this->get('conflictRowCount');
|
||||
$duplicateRowCount = $this->get('duplicateRowCount');
|
||||
$onDuplicate = $this->get('onDuplicate');
|
||||
$mismatchCount = $this->get('unMatchCount');
|
||||
if ($duplicateRowCount > 0) {
|
||||
$urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
}
|
||||
elseif ($mismatchCount) {
|
||||
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser';
|
||||
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
|
||||
}
|
||||
else {
|
||||
$duplicateRowCount = 0;
|
||||
$this->set('duplicateRowCount', $duplicateRowCount);
|
||||
}
|
||||
|
||||
$this->assign('dupeError', FALSE);
|
||||
|
||||
if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
|
||||
$dupeActionString = ts('These records have been updated with the imported data.');
|
||||
}
|
||||
elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
|
||||
$dupeActionString = ts('These records have been filled in with the imported data.');
|
||||
}
|
||||
else {
|
||||
// Skip by default.
|
||||
|
||||
$dupeActionString = ts('These records have not been imported.');
|
||||
|
||||
$this->assign('dupeError', TRUE);
|
||||
|
||||
// Only subtract dupes from successful import if we're skipping.
|
||||
|
||||
$this->set('validRowCount', $totalRowCount - $invalidRowCount -
|
||||
$conflictRowCount - $duplicateRowCount - $mismatchCount
|
||||
);
|
||||
}
|
||||
$this->assign('dupeActionString', $dupeActionString);
|
||||
|
||||
$properties = array(
|
||||
'totalRowCount',
|
||||
'validRowCount',
|
||||
'invalidRowCount',
|
||||
'conflictRowCount',
|
||||
'downloadConflictRecordsUrl',
|
||||
'downloadErrorRecordsUrl',
|
||||
'duplicateRowCount',
|
||||
'downloadDuplicateRecordsUrl',
|
||||
'downloadMismatchRecordsUrl',
|
||||
'groupAdditions',
|
||||
'unMatchCount',
|
||||
);
|
||||
foreach ($properties as $property) {
|
||||
$this->assign($property, $this->get($property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
398
sites/all/modules/civicrm/CRM/Activity/Import/Parser.php
Normal file
398
sites/all/modules/civicrm/CRM/Activity/Import/Parser.php
Normal file
|
@ -0,0 +1,398 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser {
|
||||
|
||||
protected $_fileName;
|
||||
|
||||
/**
|
||||
* Imported file size.
|
||||
*/
|
||||
protected $_fileSize;
|
||||
|
||||
/**
|
||||
* Separator being used.
|
||||
*/
|
||||
protected $_seperator;
|
||||
|
||||
/**
|
||||
* Total number of lines in file.
|
||||
*/
|
||||
protected $_lineCount;
|
||||
|
||||
/**
|
||||
* Whether the file has a column header or not.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_haveColumnHeader;
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
* @param string $seperator
|
||||
* @param $mapper
|
||||
* @param bool $skipColumnHeader
|
||||
* @param int $mode
|
||||
* @param int $onDuplicate
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function run(
|
||||
$fileName,
|
||||
$seperator = ',',
|
||||
&$mapper,
|
||||
$skipColumnHeader = FALSE,
|
||||
$mode = self::MODE_PREVIEW,
|
||||
$onDuplicate = self::DUPLICATE_SKIP
|
||||
) {
|
||||
if (!is_array($fileName)) {
|
||||
CRM_Core_Error::fatal();
|
||||
}
|
||||
$fileName = $fileName['name'];
|
||||
|
||||
$this->init();
|
||||
|
||||
$this->_haveColumnHeader = $skipColumnHeader;
|
||||
|
||||
$this->_seperator = $seperator;
|
||||
|
||||
$fd = fopen($fileName, "r");
|
||||
if (!$fd) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_lineCount = $this->_warningCount = 0;
|
||||
$this->_invalidRowCount = $this->_validCount = 0;
|
||||
$this->_totalCount = $this->_conflictCount = 0;
|
||||
|
||||
$this->_errors = array();
|
||||
$this->_warnings = array();
|
||||
$this->_conflicts = array();
|
||||
|
||||
$this->_fileSize = number_format(filesize($fileName) / 1024.0, 2);
|
||||
|
||||
if ($mode == self::MODE_MAPFIELD) {
|
||||
$this->_rows = array();
|
||||
}
|
||||
else {
|
||||
$this->_activeFieldCount = count($this->_activeFields);
|
||||
}
|
||||
|
||||
while (!feof($fd)) {
|
||||
$this->_lineCount++;
|
||||
|
||||
$values = fgetcsv($fd, 8192, $seperator);
|
||||
if (!$values) {
|
||||
continue;
|
||||
}
|
||||
|
||||
self::encloseScrub($values);
|
||||
|
||||
// skip column header if we're not in mapfield mode
|
||||
if ($mode != self::MODE_MAPFIELD && $skipColumnHeader) {
|
||||
$skipColumnHeader = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Trim whitespace around the values.
|
||||
|
||||
$empty = TRUE;
|
||||
foreach ($values as $k => $v) {
|
||||
$values[$k] = trim($v, " \t\r\n");
|
||||
}
|
||||
|
||||
if (CRM_Utils_System::isNull($values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->_totalCount++;
|
||||
|
||||
if ($mode == self::MODE_MAPFIELD) {
|
||||
$returnCode = $this->mapField($values);
|
||||
}
|
||||
elseif ($mode == self::MODE_PREVIEW) {
|
||||
$returnCode = $this->preview($values);
|
||||
}
|
||||
elseif ($mode == self::MODE_SUMMARY) {
|
||||
$returnCode = $this->summary($values);
|
||||
}
|
||||
elseif ($mode == self::MODE_IMPORT) {
|
||||
$returnCode = $this->import($onDuplicate, $values);
|
||||
}
|
||||
else {
|
||||
$returnCode = self::ERROR;
|
||||
}
|
||||
|
||||
// note that a line could be valid but still produce a warning
|
||||
if ($returnCode & self::VALID) {
|
||||
$this->_validCount++;
|
||||
if ($mode == self::MODE_MAPFIELD) {
|
||||
$this->_rows[] = $values;
|
||||
$this->_activeFieldCount = max($this->_activeFieldCount, count($values));
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnCode & self::WARNING) {
|
||||
$this->_warningCount++;
|
||||
if ($this->_warningCount < $this->_maxWarningCount) {
|
||||
$this->_warningCount[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnCode & self::ERROR) {
|
||||
$this->_invalidRowCount++;
|
||||
if ($this->_invalidRowCount < $this->_maxErrorCount) {
|
||||
$recordNumber = $this->_lineCount;
|
||||
if ($this->_haveColumnHeader) {
|
||||
$recordNumber--;
|
||||
}
|
||||
array_unshift($values, $recordNumber);
|
||||
$this->_errors[] = $values;
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnCode & self::CONFLICT) {
|
||||
$this->_conflictCount++;
|
||||
$recordNumber = $this->_lineCount;
|
||||
if ($this->_haveColumnHeader) {
|
||||
$recordNumber--;
|
||||
}
|
||||
array_unshift($values, $recordNumber);
|
||||
$this->_conflicts[] = $values;
|
||||
}
|
||||
|
||||
if ($returnCode & self::DUPLICATE) {
|
||||
if ($returnCode & self::MULTIPLE_DUPE) {
|
||||
// TODO: multi-dupes should be counted apart from singles
|
||||
// on non-skip action.
|
||||
}
|
||||
$this->_duplicateCount++;
|
||||
$recordNumber = $this->_lineCount;
|
||||
if ($this->_haveColumnHeader) {
|
||||
$recordNumber--;
|
||||
}
|
||||
array_unshift($values, $recordNumber);
|
||||
$this->_duplicates[] = $values;
|
||||
if ($onDuplicate != self::DUPLICATE_SKIP) {
|
||||
$this->_validCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// we give the derived class a way of aborting the process
|
||||
// note that the return code could be multiple code or'ed together
|
||||
if ($returnCode & self::STOP) {
|
||||
break;
|
||||
}
|
||||
|
||||
// if we are done processing the maxNumber of lines, break
|
||||
if ($this->_maxLinesToProcess > 0 && $this->_validCount >= $this->_maxLinesToProcess) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fd);
|
||||
|
||||
if ($mode == self::MODE_PREVIEW || $mode == self::MODE_IMPORT) {
|
||||
$customHeaders = $mapper;
|
||||
|
||||
$customfields = CRM_Core_BAO_CustomField::getFields('Activity');
|
||||
foreach ($customHeaders as $key => $value) {
|
||||
if ($id = CRM_Core_BAO_CustomField::getKeyID($value)) {
|
||||
$customHeaders[$key] = $customfields[$id][0];
|
||||
}
|
||||
}
|
||||
if ($this->_invalidRowCount) {
|
||||
// removed view url for invlaid contacts
|
||||
$headers = array_merge(array(
|
||||
ts('Line Number'),
|
||||
ts('Reason'),
|
||||
),
|
||||
$customHeaders
|
||||
);
|
||||
$this->_errorFileName = self::errorFileName(self::ERROR);
|
||||
self::exportCSV($this->_errorFileName, $headers, $this->_errors);
|
||||
}
|
||||
if ($this->_conflictCount) {
|
||||
$headers = array_merge(array(
|
||||
ts('Line Number'),
|
||||
ts('Reason'),
|
||||
),
|
||||
$customHeaders
|
||||
);
|
||||
$this->_conflictFileName = self::errorFileName(self::CONFLICT);
|
||||
self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts);
|
||||
}
|
||||
if ($this->_duplicateCount) {
|
||||
$headers = array_merge(array(
|
||||
ts('Line Number'),
|
||||
ts('View Activity History URL'),
|
||||
),
|
||||
$customHeaders
|
||||
);
|
||||
|
||||
$this->_duplicateFileName = self::errorFileName(self::DUPLICATE);
|
||||
self::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates);
|
||||
}
|
||||
}
|
||||
return $this->fini();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a list of the importable field keys that the user has selected set the active fields array to this list.
|
||||
*
|
||||
* @param array $fieldKeys
|
||||
*/
|
||||
public function setActiveFields($fieldKeys) {
|
||||
$this->_activeFieldCount = count($fieldKeys);
|
||||
foreach ($fieldKeys as $key) {
|
||||
if (empty($this->_fields[$key])) {
|
||||
$this->_activeFields[] = new CRM_Activity_Import_Field('', ts('- do not import -'));
|
||||
}
|
||||
else {
|
||||
$this->_activeFields[] = clone($this->_fields[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the field values for input to the api.
|
||||
*
|
||||
* @return array
|
||||
* (reference ) associative array of name/value pairs
|
||||
*/
|
||||
public function &getActiveFieldParams() {
|
||||
$params = array();
|
||||
for ($i = 0; $i < $this->_activeFieldCount; $i++) {
|
||||
if (isset($this->_activeFields[$i]->_value)
|
||||
&& !isset($params[$this->_activeFields[$i]->_name])
|
||||
&& !isset($this->_activeFields[$i]->_related)
|
||||
) {
|
||||
|
||||
$params[$this->_activeFields[$i]->_name] = $this->_activeFields[$i]->_value;
|
||||
}
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $title
|
||||
* @param int $type
|
||||
* @param string $headerPattern
|
||||
* @param string $dataPattern
|
||||
*/
|
||||
public function addField($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') {
|
||||
if (empty($name)) {
|
||||
$this->_fields['doNotImport'] = new CRM_Activity_Import_Field($name, $title, $type, $headerPattern, $dataPattern);
|
||||
}
|
||||
else {
|
||||
|
||||
$tempField = CRM_Contact_BAO_Contact::importableFields('Individual', NULL);
|
||||
if (!array_key_exists($name, $tempField)) {
|
||||
$this->_fields[$name] = new CRM_Activity_Import_Field($name, $title, $type, $headerPattern, $dataPattern);
|
||||
}
|
||||
else {
|
||||
$this->_fields[$name] = new CRM_Contact_Import_Field($name, $title, $type, $headerPattern, $dataPattern, CRM_Utils_Array::value('hasLocationType', $tempField[$name]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store parser values.
|
||||
*
|
||||
* @param CRM_Core_Session $store
|
||||
*
|
||||
* @param int $mode
|
||||
*/
|
||||
public function set($store, $mode = self::MODE_SUMMARY) {
|
||||
$store->set('fileSize', $this->_fileSize);
|
||||
$store->set('lineCount', $this->_lineCount);
|
||||
$store->set('seperator', $this->_seperator);
|
||||
$store->set('fields', $this->getSelectValues());
|
||||
$store->set('fieldTypes', $this->getSelectTypes());
|
||||
|
||||
$store->set('headerPatterns', $this->getHeaderPatterns());
|
||||
$store->set('dataPatterns', $this->getDataPatterns());
|
||||
$store->set('columnCount', $this->_activeFieldCount);
|
||||
|
||||
$store->set('totalRowCount', $this->_totalCount);
|
||||
$store->set('validRowCount', $this->_validCount);
|
||||
$store->set('invalidRowCount', $this->_invalidRowCount);
|
||||
$store->set('conflictRowCount', $this->_conflictCount);
|
||||
|
||||
if ($this->_invalidRowCount) {
|
||||
$store->set('errorsFileName', $this->_errorFileName);
|
||||
}
|
||||
if ($this->_conflictCount) {
|
||||
$store->set('conflictsFileName', $this->_conflictFileName);
|
||||
}
|
||||
if (isset($this->_rows) && !empty($this->_rows)) {
|
||||
$store->set('dataValues', $this->_rows);
|
||||
}
|
||||
|
||||
if ($mode == self::MODE_IMPORT) {
|
||||
$store->set('duplicateRowCount', $this->_duplicateCount);
|
||||
if ($this->_duplicateCount) {
|
||||
$store->set('duplicatesFileName', $this->_duplicateFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export data to a CSV file.
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param array $header
|
||||
* @param array $data
|
||||
*/
|
||||
public static function exportCSV($fileName, $header, $data) {
|
||||
$output = array();
|
||||
$fd = fopen($fileName, 'w');
|
||||
|
||||
foreach ($header as $key => $value) {
|
||||
$header[$key] = "\"$value\"";
|
||||
}
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$output[] = implode($config->fieldSeparator, $header);
|
||||
|
||||
foreach ($data as $datum) {
|
||||
foreach ($datum as $key => $value) {
|
||||
$datum[$key] = "\"$value\"";
|
||||
}
|
||||
$output[] = implode($config->fieldSeparator, $datum);
|
||||
}
|
||||
fwrite($fd, implode("\n", $output));
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,400 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class to parse activity csv files.
|
||||
*/
|
||||
class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
|
||||
|
||||
protected $_mapperKeys;
|
||||
|
||||
private $_contactIdIndex;
|
||||
private $_activityTypeIndex;
|
||||
private $_activityLabelIndex;
|
||||
private $_activityDateIndex;
|
||||
|
||||
/**
|
||||
* Array of successfully imported activity id's
|
||||
*
|
||||
* @array
|
||||
*/
|
||||
protected $_newActivity;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param array $mapperKeys
|
||||
* @param int $mapperLocType
|
||||
* @param int $mapperPhoneType
|
||||
*/
|
||||
public function __construct(&$mapperKeys, $mapperLocType = NULL, $mapperPhoneType = NULL) {
|
||||
parent::__construct();
|
||||
$this->_mapperKeys = &$mapperKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function of undocumented functionality required by the interface.
|
||||
*/
|
||||
protected function fini() {}
|
||||
|
||||
/**
|
||||
* The initializer code, called before the processing.
|
||||
*/
|
||||
public function init() {
|
||||
$activityContact = CRM_Activity_BAO_ActivityContact::import();
|
||||
$activityTarget['target_contact_id'] = $activityContact['contact_id'];
|
||||
$fields = array_merge(CRM_Activity_BAO_Activity::importableFields(),
|
||||
$activityTarget
|
||||
);
|
||||
|
||||
$fields = array_merge($fields, array(
|
||||
'source_contact_id' => array(
|
||||
'title' => ts('Source Contact'),
|
||||
'headerPattern' => '/Source.Contact?/i',
|
||||
),
|
||||
'activity_label' => array(
|
||||
'title' => ts('Activity Type Label'),
|
||||
'headerPattern' => '/(activity.)?type label?/i',
|
||||
),
|
||||
));
|
||||
|
||||
foreach ($fields as $name => $field) {
|
||||
$field['type'] = CRM_Utils_Array::value('type', $field, CRM_Utils_Type::T_INT);
|
||||
$field['dataPattern'] = CRM_Utils_Array::value('dataPattern', $field, '//');
|
||||
$field['headerPattern'] = CRM_Utils_Array::value('headerPattern', $field, '//');
|
||||
$this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']);
|
||||
}
|
||||
|
||||
$this->_newActivity = array();
|
||||
|
||||
$this->setActiveFields($this->_mapperKeys);
|
||||
|
||||
// FIXME: we should do this in one place together with Form/MapField.php
|
||||
$this->_contactIdIndex = -1;
|
||||
$this->_activityTypeIndex = -1;
|
||||
$this->_activityLabelIndex = -1;
|
||||
$this->_activityDateIndex = -1;
|
||||
|
||||
$index = 0;
|
||||
foreach ($this->_mapperKeys as $key) {
|
||||
switch ($key) {
|
||||
case 'target_contact_id':
|
||||
case 'external_identifier':
|
||||
$this->_contactIdIndex = $index;
|
||||
break;
|
||||
|
||||
case 'activity_label':
|
||||
$this->_activityLabelIndex = $index;
|
||||
break;
|
||||
|
||||
case 'activity_type_id':
|
||||
$this->_activityTypeIndex = $index;
|
||||
break;
|
||||
|
||||
case 'activity_date_time':
|
||||
$this->_activityDateIndex = $index;
|
||||
break;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the values in mapField mode.
|
||||
*
|
||||
* @param array $values
|
||||
* The array of values belonging to this line.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function mapField(&$values) {
|
||||
return CRM_Import_Parser::VALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the values in preview mode.
|
||||
*
|
||||
* @param array $values
|
||||
* The array of values belonging to this line.
|
||||
*
|
||||
* @return bool
|
||||
* the result of this processing
|
||||
*/
|
||||
public function preview(&$values) {
|
||||
return $this->summary($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the values in summary mode.
|
||||
*
|
||||
* @param array $values
|
||||
* The array of values belonging to this line.
|
||||
*
|
||||
* @return bool
|
||||
* the result of this processing
|
||||
*/
|
||||
public function summary(&$values) {
|
||||
$erroneousField = NULL;
|
||||
$this->setActiveFieldValues($values, $erroneousField);
|
||||
$index = -1;
|
||||
|
||||
if ($this->_activityTypeIndex > -1 && $this->_activityLabelIndex > -1) {
|
||||
array_unshift($values, ts('Please select either Activity Type ID OR Activity Type Label.'));
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
elseif ($this->_activityLabelIndex > -1) {
|
||||
$index = $this->_activityLabelIndex;
|
||||
}
|
||||
elseif ($this->_activityTypeIndex > -1) {
|
||||
$index = $this->_activityTypeIndex;
|
||||
}
|
||||
|
||||
if ($index < 0 or $this->_activityDateIndex < 0) {
|
||||
$errorRequired = TRUE;
|
||||
}
|
||||
else {
|
||||
$errorRequired = !CRM_Utils_Array::value($index, $values) || !CRM_Utils_Array::value($this->_activityDateIndex, $values);
|
||||
}
|
||||
|
||||
if ($errorRequired) {
|
||||
array_unshift($values, ts('Missing required fields'));
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
|
||||
$params = &$this->getActiveFieldParams();
|
||||
|
||||
$errorMessage = NULL;
|
||||
|
||||
// For date-Formats
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$dateType = $session->get('dateTypes');
|
||||
if (!isset($params['source_contact_id'])) {
|
||||
$params['source_contact_id'] = $session->get('userID');
|
||||
}
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key == 'activity_date_time') {
|
||||
if ($val) {
|
||||
$dateValue = CRM_Utils_Date::formatDate($val, $dateType);
|
||||
if ($dateValue) {
|
||||
$params[$key] = $dateValue;
|
||||
}
|
||||
else {
|
||||
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Activity date', $errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($key == 'activity_engagement_level' && $val &&
|
||||
!CRM_Utils_Rule::positiveInteger($val)
|
||||
) {
|
||||
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Activity Engagement Index', $errorMessage);
|
||||
}
|
||||
}
|
||||
// Date-Format part ends.
|
||||
|
||||
// Checking error in custom data.
|
||||
$params['contact_type'] = isset($this->_contactType) ? $this->_contactType : 'Activity';
|
||||
|
||||
CRM_Contact_Import_Parser_Contact::isErrorInCustomData($params, $errorMessage);
|
||||
|
||||
if ($errorMessage) {
|
||||
$tempMsg = "Invalid value for field(s) : $errorMessage";
|
||||
array_unshift($values, $tempMsg);
|
||||
$errorMessage = NULL;
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
|
||||
return CRM_Import_Parser::VALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the values in import mode.
|
||||
*
|
||||
* @param int $onDuplicate
|
||||
* The code for what action to take on duplicates.
|
||||
* @param array $values
|
||||
* The array of values belonging to this line.
|
||||
*
|
||||
* @return bool
|
||||
* the result of this processing
|
||||
*/
|
||||
public function import($onDuplicate, &$values) {
|
||||
// First make sure this is a valid line
|
||||
$response = $this->summary($values);
|
||||
|
||||
if ($response != CRM_Import_Parser::VALID) {
|
||||
return $response;
|
||||
}
|
||||
$params = &$this->getActiveFieldParams();
|
||||
$activityLabel = array_search('activity_label', $this->_mapperKeys);
|
||||
if ($activityLabel) {
|
||||
$params = array_merge($params, array('activity_label' => $values[$activityLabel]));
|
||||
}
|
||||
// For date-Formats.
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$dateType = $session->get('dateTypes');
|
||||
if (!isset($params['source_contact_id'])) {
|
||||
$params['source_contact_id'] = $session->get('userID');
|
||||
}
|
||||
|
||||
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
|
||||
if ($key == 'activity_date_time' && $val) {
|
||||
$params[$key] = CRM_Utils_Date::formatDate($val, $dateType);
|
||||
}
|
||||
elseif (!empty($customFields[$customFieldID]) && $customFields[$customFieldID]['data_type'] == 'Date') {
|
||||
CRM_Contact_Import_Parser_Contact::formatCustomDate($params, $params, $dateType, $key);
|
||||
}
|
||||
elseif (!empty($customFields[$customFieldID]) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
|
||||
$params[$key] = CRM_Utils_String::strtoboolstr($val);
|
||||
}
|
||||
}
|
||||
elseif ($key == 'activity_date_time') {
|
||||
$params[$key] = CRM_Utils_Date::formatDate($val, $dateType);
|
||||
}
|
||||
elseif ($key == 'activity_subject') {
|
||||
$params['subject'] = $val;
|
||||
}
|
||||
}
|
||||
// Date-Format part ends.
|
||||
require_once 'CRM/Utils/DeprecatedUtils.php';
|
||||
$formatError = _civicrm_api3_deprecated_activity_formatted_param($params, $params, TRUE);
|
||||
|
||||
if ($formatError) {
|
||||
array_unshift($values, $formatError['error_message']);
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
|
||||
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
|
||||
NULL,
|
||||
'Activity'
|
||||
);
|
||||
|
||||
if ($this->_contactIdIndex < 0) {
|
||||
|
||||
// Retrieve contact id using contact dedupe rule.
|
||||
// Since we are supporting only individual's activity import.
|
||||
$params['contact_type'] = 'Individual';
|
||||
$params['version'] = 3;
|
||||
$error = _civicrm_api3_deprecated_duplicate_formatted_contact($params);
|
||||
|
||||
if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
|
||||
$matchedIDs = explode(',', $error['error_message']['params'][0]);
|
||||
if (count($matchedIDs) > 1) {
|
||||
array_unshift($values, 'Multiple matching contact records detected for this row. The activity was not imported');
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
else {
|
||||
$cid = $matchedIDs[0];
|
||||
$params['target_contact_id'] = $cid;
|
||||
$params['version'] = 3;
|
||||
$newActivity = civicrm_api('activity', 'create', $params);
|
||||
if (!empty($newActivity['is_error'])) {
|
||||
array_unshift($values, $newActivity['error_message']);
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
|
||||
$this->_newActivity[] = $newActivity['id'];
|
||||
return CRM_Import_Parser::VALID;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Using new Dedupe rule.
|
||||
$ruleParams = array(
|
||||
'contact_type' => 'Individual',
|
||||
'used' => 'Unsupervised',
|
||||
);
|
||||
$fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
|
||||
|
||||
$disp = NULL;
|
||||
foreach ($fieldsArray as $value) {
|
||||
if (array_key_exists(trim($value), $params)) {
|
||||
$paramValue = $params[trim($value)];
|
||||
if (is_array($paramValue)) {
|
||||
$disp .= $params[trim($value)][0][trim($value)] . " ";
|
||||
}
|
||||
else {
|
||||
$disp .= $params[trim($value)] . " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['external_identifier'])) {
|
||||
if ($disp) {
|
||||
$disp .= "AND {$params['external_identifier']}";
|
||||
}
|
||||
else {
|
||||
$disp = $params['external_identifier'];
|
||||
}
|
||||
}
|
||||
|
||||
array_unshift($values, 'No matching Contact found for (' . $disp . ')');
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!empty($params['external_identifier'])) {
|
||||
$targetContactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
|
||||
$params['external_identifier'], 'id', 'external_identifier'
|
||||
);
|
||||
|
||||
if (!empty($params['target_contact_id']) &&
|
||||
$params['target_contact_id'] != $targetContactId
|
||||
) {
|
||||
array_unshift($values, 'Mismatch of External ID:' . $params['external_identifier'] . ' and Contact Id:' . $params['target_contact_id']);
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
elseif ($targetContactId) {
|
||||
$params['target_contact_id'] = $targetContactId;
|
||||
}
|
||||
else {
|
||||
array_unshift($values, 'No Matching Contact for External ID:' . $params['external_identifier']);
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
$params['version'] = 3;
|
||||
$newActivity = civicrm_api('activity', 'create', $params);
|
||||
if (!empty($newActivity['is_error'])) {
|
||||
array_unshift($values, $newActivity['error_message']);
|
||||
return CRM_Import_Parser::ERROR;
|
||||
}
|
||||
|
||||
$this->_newActivity[] = $newActivity['id'];
|
||||
return CRM_Import_Parser::VALID;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
469
sites/all/modules/civicrm/CRM/Activity/Page/AJAX.php
Normal file
469
sites/all/modules/civicrm/CRM/Activity/Page/AJAX.php
Normal file
|
@ -0,0 +1,469 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains all the function that are called using AJAX (jQuery)
|
||||
*/
|
||||
class CRM_Activity_Page_AJAX {
|
||||
public static function getCaseActivity() {
|
||||
// Should those params be passed through the validateParams method?
|
||||
$caseID = CRM_Utils_Type::validate($_GET['caseID'], 'Integer');
|
||||
$contactID = CRM_Utils_Type::validate($_GET['cid'], 'Integer');
|
||||
$userID = CRM_Utils_Type::validate($_GET['userID'], 'Integer');
|
||||
$context = CRM_Utils_Type::validate(CRM_Utils_Array::value('context', $_GET), 'String');
|
||||
|
||||
$optionalParameters = array(
|
||||
'source_contact_id' => 'Integer',
|
||||
'status_id' => 'Integer',
|
||||
'activity_deleted' => 'Boolean',
|
||||
'activity_type_id' => 'Integer',
|
||||
'activity_date_low' => 'Date',
|
||||
'activity_date_high' => 'Date',
|
||||
);
|
||||
|
||||
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
|
||||
$params += CRM_Core_Page_AJAX::validateParams(array(), $optionalParameters);
|
||||
|
||||
// get the activities related to given case
|
||||
$activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
|
||||
|
||||
CRM_Utils_JSON::output($activities);
|
||||
}
|
||||
|
||||
public static function getCaseGlobalRelationships() {
|
||||
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
|
||||
|
||||
// get the activities related to given case
|
||||
$globalGroupInfo = array();
|
||||
|
||||
// get the total row count
|
||||
CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, NULL, FALSE, TRUE, NULL, NULL);
|
||||
// limit the rows
|
||||
$relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, $params['sortBy'], $showLinks = TRUE, FALSE, $params['offset'], $params['rp']);
|
||||
|
||||
$relationships = array();
|
||||
// after sort we can update username fields to be a url
|
||||
foreach ($relGlobal as $key => $value) {
|
||||
$relationship = array();
|
||||
$relationship['sort_name'] = $value['sort_name'];
|
||||
$relationship['phone'] = $value['phone'];
|
||||
$relationship['email'] = $value['email'];
|
||||
|
||||
array_push($relationships, $relationship);
|
||||
}
|
||||
|
||||
$globalRelationshipsDT = array();
|
||||
$globalRelationshipsDT['data'] = $relationships;
|
||||
$globalRelationshipsDT['recordsTotal'] = count($relationships);
|
||||
$globalRelationshipsDT['recordsFiltered'] = count($relationships);
|
||||
|
||||
CRM_Utils_JSON::output($globalRelationshipsDT);
|
||||
}
|
||||
|
||||
public static function getCaseClientRelationships() {
|
||||
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
|
||||
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
|
||||
|
||||
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
|
||||
|
||||
// Retrieve ALL client relationships
|
||||
$relClient = CRM_Contact_BAO_Relationship::getRelationship($contactID,
|
||||
CRM_Contact_BAO_Relationship::CURRENT,
|
||||
0, 0, 0, NULL, NULL, FALSE
|
||||
);
|
||||
|
||||
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
|
||||
|
||||
// Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles
|
||||
// so they don't show up twice.
|
||||
$clientRelationships = array();
|
||||
foreach ($relClient as $r) {
|
||||
if (!array_key_exists($r['id'], $caseRelationships)) {
|
||||
$clientRelationships[] = $r;
|
||||
}
|
||||
}
|
||||
|
||||
// sort clientRelationships array using jquery call params
|
||||
foreach ($clientRelationships as $key => $row) {
|
||||
$sortArray[$key] = $row[$params['_raw_values']['sort'][0]];
|
||||
}
|
||||
$sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]);
|
||||
array_multisort($sortArray, constant($sort_type), $clientRelationships);
|
||||
|
||||
$relationships = array();
|
||||
// after sort we can update username fields to be a url
|
||||
foreach ($clientRelationships as $key => $value) {
|
||||
$relationship = array();
|
||||
$relationship['relation'] = $value['relation'];
|
||||
$relationship['name'] = '<a href=' . CRM_Utils_System::url('civicrm/contact/view',
|
||||
'action=view&reset=1&cid=' . $clientRelationships[$key]['cid']) . '>' . $clientRelationships[$key]['name'] . '</a>';
|
||||
$relationship['phone'] = $value['phone'];
|
||||
$relationship['email'] = $value['email'];
|
||||
|
||||
array_push($relationships, $relationship);
|
||||
}
|
||||
|
||||
$clientRelationshipsDT = array();
|
||||
$clientRelationshipsDT['data'] = $relationships;
|
||||
$clientRelationshipsDT['recordsTotal'] = count($relationships);
|
||||
$clientRelationshipsDT['recordsFiltered'] = count($relationships);
|
||||
|
||||
CRM_Utils_JSON::output($clientRelationshipsDT);
|
||||
}
|
||||
|
||||
|
||||
public static function getCaseRoles() {
|
||||
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
|
||||
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
|
||||
|
||||
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
|
||||
|
||||
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
|
||||
$caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
|
||||
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
|
||||
$caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
|
||||
|
||||
$hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
|
||||
|
||||
$managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
|
||||
|
||||
foreach ($caseRelationships as $key => $value) {
|
||||
// This role has been filled
|
||||
unset($caseRoles[$value['relation_type']]);
|
||||
// mark original case relationships record to use on setting edit links below
|
||||
$caseRelationships[$key]['source'] = 'caseRel';
|
||||
}
|
||||
|
||||
$caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
|
||||
|
||||
// move/transform caseRoles array data to caseRelationships
|
||||
// for sorting and display
|
||||
// CRM-14466 added cid to the non-client array to avoid php notice
|
||||
foreach ($caseRoles as $id => $value) {
|
||||
if ($id != "client") {
|
||||
$rel = array();
|
||||
$rel['relation'] = $value;
|
||||
$rel['relation_type'] = $id;
|
||||
$rel['name'] = '(not assigned)';
|
||||
$rel['phone'] = '';
|
||||
$rel['email'] = '';
|
||||
$rel['source'] = 'caseRoles';
|
||||
$caseRelationships[] = $rel;
|
||||
}
|
||||
else {
|
||||
foreach ($value as $clientRole) {
|
||||
$relClient = array();
|
||||
$relClient['relation'] = 'Client';
|
||||
$relClient['name'] = $clientRole['sort_name'];
|
||||
$relClient['phone'] = $clientRole['phone'];
|
||||
$relClient['email'] = $clientRole['email'];
|
||||
$relClient['cid'] = $clientRole['contact_id'];
|
||||
$relClient['source'] = 'contact';
|
||||
$caseRelationships[] = $relClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort clientRelationships array using jquery call params
|
||||
foreach ($caseRelationships as $key => $row) {
|
||||
$sortArray[$key] = $row[$params['_raw_values']['sort'][0]];
|
||||
}
|
||||
$sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]);
|
||||
array_multisort($sortArray, constant($sort_type), $caseRelationships);
|
||||
|
||||
$relationships = array();
|
||||
|
||||
// set user name, email and edit columns links
|
||||
foreach ($caseRelationships as $key => &$row) {
|
||||
$typeLabel = $row['relation'];
|
||||
// Add "<br />(Case Manager)" to label
|
||||
if (!empty($row['relation_type']) && $row['relation_type'] == $managerRoleId) {
|
||||
$row['relation'] .= '<br />' . '(' . ts('Case Manager') . ')';
|
||||
}
|
||||
// view user links
|
||||
if (!empty($row['cid'])) {
|
||||
$row['name'] = '<a class="view-contact" title="' . ts('View Contact') . '" href=' . CRM_Utils_System::url('civicrm/contact/view',
|
||||
'action=view&reset=1&cid=' . $row['cid']) . '>' . $row['name'] . '</a>';
|
||||
}
|
||||
// email column links/icon
|
||||
if ($row['email']) {
|
||||
$row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><i class="crm-i fa-envelope"></i></a>';
|
||||
}
|
||||
// edit links
|
||||
$row['actions'] = '';
|
||||
if ($hasAccessToAllCases) {
|
||||
$contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
|
||||
$contactType = $contactType == 'Contact' ? '' : $contactType;
|
||||
switch ($row['source']) {
|
||||
case 'caseRel':
|
||||
$row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Reassign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-rel_id="' . $row['rel_id'] . '"data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' .
|
||||
'<i class="crm-i fa-pencil"></i>' .
|
||||
'</a>' .
|
||||
'<a href="#deleteCaseRoleDialog" title="' . ts('Remove %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/delcaserole') . '">' .
|
||||
'<span class="icon delete-icon"></span>' .
|
||||
'</a>';
|
||||
break;
|
||||
|
||||
case 'caseRoles':
|
||||
$row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Assign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_a_b" data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' .
|
||||
'<i class="crm-i fa-pencil"></i>' .
|
||||
'</a>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($row['cid']);
|
||||
unset($row['relation_type']);
|
||||
unset($row['rel_id']);
|
||||
unset($row['client_id']);
|
||||
unset($row['source']);
|
||||
array_push($relationships, $row);
|
||||
}
|
||||
$params['total'] = count($relationships);
|
||||
|
||||
$caseRelationshipsDT = array();
|
||||
$caseRelationshipsDT['data'] = $relationships;
|
||||
$caseRelationshipsDT['recordsTotal'] = $params['total'];
|
||||
$caseRelationshipsDT['recordsFiltered'] = $params['total'];
|
||||
|
||||
CRM_Utils_JSON::output($caseRelationshipsDT);
|
||||
|
||||
}
|
||||
|
||||
public static function convertToCaseActivity() {
|
||||
$params = array('caseID', 'activityID', 'contactID', 'newSubject', 'targetContactIds', 'mode');
|
||||
$vals = array();
|
||||
foreach ($params as $param) {
|
||||
$vals[$param] = CRM_Utils_Array::value($param, $_POST);
|
||||
}
|
||||
|
||||
CRM_Utils_JSON::output(self::_convertToCaseActivity($vals));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function _convertToCaseActivity($params) {
|
||||
if (!$params['activityID'] || !$params['caseID']) {
|
||||
return (array('error_msg' => 'required params missing.'));
|
||||
}
|
||||
|
||||
$otherActivity = new CRM_Activity_DAO_Activity();
|
||||
$otherActivity->id = $params['activityID'];
|
||||
if (!$otherActivity->find(TRUE)) {
|
||||
return (array('error_msg' => 'activity record is missing.'));
|
||||
}
|
||||
$actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
|
||||
|
||||
// Create new activity record.
|
||||
$mainActivity = new CRM_Activity_DAO_Activity();
|
||||
$mainActVals = array();
|
||||
CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
|
||||
|
||||
// Get new activity subject.
|
||||
if (!empty($params['newSubject'])) {
|
||||
$mainActVals['subject'] = $params['newSubject'];
|
||||
}
|
||||
|
||||
$mainActivity->copyValues($mainActVals);
|
||||
$mainActivity->id = NULL;
|
||||
$mainActivity->activity_date_time = $actDateTime;
|
||||
// Make sure this is current revision.
|
||||
$mainActivity->is_current_revision = TRUE;
|
||||
// Drop all relations.
|
||||
$mainActivity->parent_id = $mainActivity->original_id = NULL;
|
||||
|
||||
$mainActivity->save();
|
||||
$mainActivityId = $mainActivity->id;
|
||||
CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
|
||||
$mainActivity->free();
|
||||
|
||||
// Mark previous activity as deleted. If it was a non-case activity
|
||||
// then just change the subject.
|
||||
if (in_array($params['mode'], array(
|
||||
'move',
|
||||
'file',
|
||||
))) {
|
||||
$caseActivity = new CRM_Case_DAO_CaseActivity();
|
||||
$caseActivity->case_id = $params['caseID'];
|
||||
$caseActivity->activity_id = $otherActivity->id;
|
||||
if ($params['mode'] == 'move' || $caseActivity->find(TRUE)) {
|
||||
$otherActivity->is_deleted = 1;
|
||||
}
|
||||
else {
|
||||
$otherActivity->subject = ts('(Filed on case %1)', array(
|
||||
1 => $params['caseID'],
|
||||
)) . ' ' . $otherActivity->subject;
|
||||
}
|
||||
$otherActivity->activity_date_time = $actDateTime;
|
||||
$otherActivity->save();
|
||||
|
||||
$caseActivity->free();
|
||||
}
|
||||
$otherActivity->free();
|
||||
|
||||
$targetContacts = array();
|
||||
if (!empty($params['targetContactIds'])) {
|
||||
$targetContacts = array_unique(explode(',', $params['targetContactIds']));
|
||||
}
|
||||
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
|
||||
$sourceContactID = CRM_Activity_BAO_Activity::getSourceContactID($params['activityID']);
|
||||
$src_params = array(
|
||||
'activity_id' => $mainActivityId,
|
||||
'contact_id' => $sourceContactID,
|
||||
'record_type_id' => $sourceID,
|
||||
);
|
||||
CRM_Activity_BAO_ActivityContact::create($src_params);
|
||||
|
||||
foreach ($targetContacts as $key => $value) {
|
||||
$targ_params = array(
|
||||
'activity_id' => $mainActivityId,
|
||||
'contact_id' => $value,
|
||||
'record_type_id' => $targetID,
|
||||
);
|
||||
CRM_Activity_BAO_ActivityContact::create($targ_params);
|
||||
}
|
||||
|
||||
//CRM-21114 retrieve assignee contacts from original case; allow overriding from params
|
||||
$assigneeContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($params['activityID'], $assigneeID);
|
||||
if (!empty($params['assigneeContactIds'])) {
|
||||
$assigneeContacts = array_unique(explode(',', $params['assigneeContactIds']));
|
||||
}
|
||||
foreach ($assigneeContacts as $key => $value) {
|
||||
$assigneeParams = array(
|
||||
'activity_id' => $mainActivityId,
|
||||
'contact_id' => $value,
|
||||
'record_type_id' => $assigneeID,
|
||||
);
|
||||
CRM_Activity_BAO_ActivityContact::create($assigneeParams);
|
||||
}
|
||||
|
||||
// Attach newly created activity to case.
|
||||
$caseActivity = new CRM_Case_DAO_CaseActivity();
|
||||
$caseActivity->case_id = $params['caseID'];
|
||||
$caseActivity->activity_id = $mainActivityId;
|
||||
$caseActivity->save();
|
||||
$error_msg = $caseActivity->_lastError;
|
||||
$caseActivity->free();
|
||||
|
||||
$params['mainActivityId'] = $mainActivityId;
|
||||
CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
|
||||
|
||||
return (array('error_msg' => $error_msg, 'newId' => $mainActivity->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get activities for the contact.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getContactActivity() {
|
||||
$requiredParameters = array(
|
||||
'cid' => 'Integer',
|
||||
);
|
||||
|
||||
$optionalParameters = array(
|
||||
'context' => 'String',
|
||||
'activity_type_id' => 'Integer',
|
||||
'activity_type_exclude_id' => 'Integer',
|
||||
'activity_status_id' => 'String',
|
||||
'activity_date_relative' => 'String',
|
||||
'activity_date_low' => 'String',
|
||||
'activity_date_high' => 'String',
|
||||
);
|
||||
|
||||
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
|
||||
$params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters);
|
||||
|
||||
// To be consistent, the cid parameter should be renamed to contact_id in
|
||||
// the template file, see templates/CRM/Activity/Selector/Selector.tpl
|
||||
$params['contact_id'] = $params['cid'];
|
||||
unset($params['cid']);
|
||||
|
||||
// get the contact activities
|
||||
$activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
|
||||
|
||||
foreach ($activities['data'] as $key => $value) {
|
||||
// Check if recurring activity.
|
||||
if (!empty($value['is_recurring_activity'])) {
|
||||
$repeat = $value['is_recurring_activity'];
|
||||
$activities['data'][$key]['activity_type'] .= '<br/><span class="bold">' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// store the activity filter preference CRM-11761
|
||||
if (Civi::settings()->get('preserve_activity_tab_filter') && ($userID = CRM_Core_Session::getLoggedInContactID())) {
|
||||
unset($optionalParameters['context']);
|
||||
foreach ($optionalParameters as $searchField => $dataType) {
|
||||
$formSearchField = $searchField;
|
||||
if ($searchField == 'activity_type_id') {
|
||||
$formSearchField = 'activity_type_filter_id';
|
||||
}
|
||||
elseif ($searchField == 'activity_type_exclude_id') {
|
||||
$formSearchField = 'activity_type_exclude_filter_id';
|
||||
}
|
||||
if (!empty($params[$searchField])) {
|
||||
$activityFilter[$formSearchField] = CRM_Utils_Type::escape($params[$searchField], $dataType);
|
||||
if (in_array($searchField, array('activity_date_low', 'activity_date_high'))) {
|
||||
$activityFilter['activity_date_relative'] = 0;
|
||||
}
|
||||
elseif ($searchField == 'activity_status_id') {
|
||||
$activityFilter['status_id'] = explode(',', $activityFilter[$searchField]);
|
||||
}
|
||||
}
|
||||
elseif (in_array($searchField, array('activity_type_id', 'activity_type_exclude_id'))) {
|
||||
$activityFilter[$formSearchField] = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var \Civi\Core\SettingsBag $cSettings
|
||||
*/
|
||||
$cSettings = Civi::service('settings_manager')->getBagByContact(CRM_Core_Config::domainID(), $userID);
|
||||
$cSettings->set('activity_tab_filter', $activityFilter);
|
||||
}
|
||||
if (!empty($_GET['is_unit_test'])) {
|
||||
return array($activities, $activityFilter);
|
||||
}
|
||||
|
||||
CRM_Utils_JSON::output($activities);
|
||||
}
|
||||
|
||||
}
|
219
sites/all/modules/civicrm/CRM/Activity/Page/Tab.php
Normal file
219
sites/all/modules/civicrm/CRM/Activity/Page/Tab.php
Normal file
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main page for viewing activities,
|
||||
*/
|
||||
class CRM_Activity_Page_Tab extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* Browse all activities for a particular contact.
|
||||
*/
|
||||
public function browse() {
|
||||
$this->assign('admin', FALSE);
|
||||
$this->assign('context', 'activity');
|
||||
|
||||
// also create the form element for the activity filter box
|
||||
$controller = new CRM_Core_Controller_Simple(
|
||||
'CRM_Activity_Form_ActivityFilter',
|
||||
ts('Activity Filter'),
|
||||
NULL,
|
||||
FALSE, FALSE, TRUE
|
||||
);
|
||||
$controller->set('contactId', $this->_contactId);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit tab.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit() {
|
||||
// used for ajax tabs
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$this->assign('context', $context);
|
||||
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this);
|
||||
|
||||
$this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Integer', $this);
|
||||
|
||||
$activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
|
||||
|
||||
// Email and Create Letter activities use a different form class
|
||||
$emailTypeValue = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity',
|
||||
'activity_type_id',
|
||||
'Email'
|
||||
);
|
||||
|
||||
$letterTypeValue = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity',
|
||||
'activity_type_id',
|
||||
'Print PDF Letter'
|
||||
);
|
||||
|
||||
switch ($activityTypeId) {
|
||||
case $emailTypeValue:
|
||||
$wrapper = new CRM_Utils_Wrapper();
|
||||
$arguments = array('attachUpload' => 1);
|
||||
return $wrapper->run('CRM_Contact_Form_Task_Email', ts('Email a Contact'), $arguments);
|
||||
|
||||
case $letterTypeValue:
|
||||
$wrapper = new CRM_Utils_Wrapper();
|
||||
$arguments = array('attachUpload' => 1);
|
||||
return $wrapper->run('CRM_Contact_Form_Task_PDF', ts('Create PDF Letter'), $arguments);
|
||||
|
||||
default:
|
||||
$controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_Activity',
|
||||
ts('Contact Activities'),
|
||||
$this->_action,
|
||||
FALSE, FALSE, FALSE, TRUE
|
||||
);
|
||||
}
|
||||
|
||||
$controller->setEmbedded(TRUE);
|
||||
|
||||
$controller->set('contactId', $this->_contactId);
|
||||
$controller->set('atype', $activityTypeId);
|
||||
$controller->set('id', $this->_id);
|
||||
$controller->set('pid', $this->get('pid'));
|
||||
$controller->set('action', $this->_action);
|
||||
$controller->set('context', $context);
|
||||
|
||||
$controller->process();
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Heart of the viewing process.
|
||||
*
|
||||
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
|
||||
$this->assign('contactId', $this->_contactId);
|
||||
// FIXME: need to fix this conflict
|
||||
$this->assign('contactID', $this->_contactId);
|
||||
|
||||
// check logged in url permission
|
||||
CRM_Contact_Page_View::checkUserPermission($this);
|
||||
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
|
||||
$this->assign('action', $this->_action);
|
||||
|
||||
// also create the form element for the activity links box
|
||||
$controller = new CRM_Core_Controller_Simple(
|
||||
'CRM_Activity_Form_ActivityLinks',
|
||||
ts('Activity Links'),
|
||||
NULL,
|
||||
FALSE, FALSE, TRUE
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$controller = new CRM_Core_Controller_Simple(
|
||||
'CRM_Activity_Form_Activity',
|
||||
ts('Activity Record'),
|
||||
$this->_action
|
||||
);
|
||||
$controller->set('id', $this->_id);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->process();
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform actions and display for activities.
|
||||
*/
|
||||
public function run() {
|
||||
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
|
||||
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
|
||||
// Do check for view/edit operation.
|
||||
if ($this->_id &&
|
||||
in_array($action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW))
|
||||
) {
|
||||
if (!CRM_Activity_BAO_Activity::checkPermission($this->_id, $action)) {
|
||||
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($context == 'standalone' || (!$contactId && ($action != CRM_Core_Action::DELETE) && !$this->_id)) {
|
||||
$this->_action = CRM_Core_Action::ADD;
|
||||
$this->assign('action', $this->_action);
|
||||
}
|
||||
else {
|
||||
// we should call contact view, preprocess only for activity in contact summary
|
||||
$this->preProcess();
|
||||
}
|
||||
|
||||
// route behaviour of contact/view/activity based on action defined
|
||||
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::VIEW)
|
||||
) {
|
||||
$this->edit();
|
||||
$activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
|
||||
|
||||
// Email and Create Letter activities use a different form class
|
||||
$emailTypeValue = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity',
|
||||
'activity_type_id',
|
||||
'Email'
|
||||
);
|
||||
|
||||
$letterTypeValue = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity',
|
||||
'activity_type_id',
|
||||
'Print PDF Letter'
|
||||
);
|
||||
|
||||
if (in_array($activityTypeId, array(
|
||||
$emailTypeValue,
|
||||
$letterTypeValue,
|
||||
))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
elseif ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::DETACH)) {
|
||||
$this->delete();
|
||||
}
|
||||
else {
|
||||
$this->browse();
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is for building event(participation) block on user dashboard.
|
||||
*/
|
||||
class CRM_Activity_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard {
|
||||
|
||||
/**
|
||||
* List participations for the UF user.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function listActivities() {
|
||||
|
||||
$controller
|
||||
= new CRM_Core_Controller_Simple(
|
||||
'CRM_Activity_Form_Search', ts('Activities'),
|
||||
NULL,
|
||||
FALSE, FALSE, TRUE, FALSE
|
||||
);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->reset();
|
||||
$controller->set('context', 'user');
|
||||
$controller->set('cid', $this->_contactId);
|
||||
// Limit to status "Scheduled" and "Available"
|
||||
$controller->set('status', array('IN' => array(1, 7)));
|
||||
$controller->set('activity_role', 2);
|
||||
$controller->set('force', 1);
|
||||
$controller->process();
|
||||
$controller->run();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main function that is called when the page loads.
|
||||
*
|
||||
* It decides the which action has to be taken for the page.
|
||||
*/
|
||||
public function run() {
|
||||
parent::preProcess();
|
||||
$this->listActivities();
|
||||
}
|
||||
|
||||
}
|
546
sites/all/modules/civicrm/CRM/Activity/Selector/Activity.php
Normal file
546
sites/all/modules/civicrm/CRM/Activity/Selector/Activity.php
Normal file
|
@ -0,0 +1,546 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to retrieve and display activities for a contact.
|
||||
*/
|
||||
class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
|
||||
|
||||
/**
|
||||
* We use desc to remind us what that column is, name is used in the tpl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_columnHeaders;
|
||||
|
||||
/**
|
||||
* ContactId - contact id of contact whose activies are displayed
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_contactId;
|
||||
|
||||
protected $_admin;
|
||||
|
||||
protected $_context;
|
||||
|
||||
protected $_activityTypeIDs;
|
||||
|
||||
protected $_viewOptions;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param int $contactId
|
||||
* Contact whose activities we want to display.
|
||||
* @param int $permission
|
||||
* The permission we have for this contact.
|
||||
*
|
||||
* @param bool $admin
|
||||
* @param string $context
|
||||
* @param null $activityTypeIDs
|
||||
*
|
||||
* @return \CRM_Activity_Selector_Activity
|
||||
*/
|
||||
public function __construct(
|
||||
$contactId,
|
||||
$permission,
|
||||
$admin = FALSE,
|
||||
$context = 'activity',
|
||||
$activityTypeIDs = NULL) {
|
||||
$this->_contactId = $contactId;
|
||||
$this->_permission = $permission;
|
||||
$this->_admin = $admin;
|
||||
$this->_context = $context;
|
||||
$this->_activityTypeIDs = $activityTypeIDs;
|
||||
|
||||
// get all enabled view componentc (check if case is enabled)
|
||||
$this->_viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'contact_view_options', TRUE, NULL, TRUE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the action links that are given for each search row.
|
||||
* currently the action links added for each row are
|
||||
*
|
||||
* - View
|
||||
*
|
||||
* @param int $activityTypeId
|
||||
* @param int $sourceRecordId
|
||||
* @param bool $accessMailingReport
|
||||
* @param int $activityId
|
||||
* @param null $key
|
||||
* @param null $compContext
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function actionLinks(
|
||||
$activityTypeId,
|
||||
$sourceRecordId = NULL,
|
||||
$accessMailingReport = FALSE,
|
||||
$activityId = NULL,
|
||||
$key = NULL,
|
||||
$compContext = NULL) {
|
||||
static $activityActTypes = NULL;
|
||||
//CRM-14277 added addtitional param to handle activity search
|
||||
$extraParams = "&searchContext=activity";
|
||||
|
||||
$extraParams .= ($key) ? "&key={$key}" : NULL;
|
||||
if ($compContext) {
|
||||
$extraParams .= "&compContext={$compContext}";
|
||||
}
|
||||
|
||||
$showView = TRUE;
|
||||
$showUpdate = $showDelete = FALSE;
|
||||
$qsUpdate = NULL;
|
||||
|
||||
if (!$activityActTypes) {
|
||||
$activeActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
|
||||
}
|
||||
$activityTypeName = CRM_Utils_Array::value($activityTypeId, $activeActTypes);
|
||||
|
||||
// CRM-7607
|
||||
// Lets allow to have normal operation for only activity types.
|
||||
// When activity type is disabled or no more exists give only delete.
|
||||
switch ($activityTypeName) {
|
||||
case 'Event Registration':
|
||||
case 'Change Registration':
|
||||
$url = 'civicrm/contact/view/participant';
|
||||
$qsView = "action=view&reset=1&id={$sourceRecordId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
break;
|
||||
|
||||
case 'Contribution':
|
||||
$url = 'civicrm/contact/view/contribution';
|
||||
$qsView = "action=view&reset=1&id={$sourceRecordId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
break;
|
||||
|
||||
case 'Payment':
|
||||
case 'Refund':
|
||||
$participantId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $sourceRecordId, 'participant_id', 'contribution_id');
|
||||
if (!empty($participantId)) {
|
||||
$url = 'civicrm/contact/view/participant';
|
||||
$qsView = "action=view&reset=1&id={$participantId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Membership Signup':
|
||||
case 'Membership Renewal':
|
||||
case 'Change Membership Status':
|
||||
case 'Change Membership Type':
|
||||
$url = 'civicrm/contact/view/membership';
|
||||
$qsView = "action=view&reset=1&id={$sourceRecordId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
break;
|
||||
|
||||
case 'Pledge Reminder':
|
||||
case 'Pledge Acknowledgment':
|
||||
$url = 'civicrm/contact/view/activity';
|
||||
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
break;
|
||||
|
||||
case 'Email':
|
||||
case 'Bulk Email':
|
||||
$url = 'civicrm/activity/view';
|
||||
$delUrl = 'civicrm/activity';
|
||||
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
if ($activityTypeName == 'Email') {
|
||||
$showDelete = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Inbound Email':
|
||||
$url = 'civicrm/contact/view/activity';
|
||||
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
break;
|
||||
|
||||
case 'Open Case':
|
||||
case 'Change Case Type':
|
||||
case 'Change Case Status':
|
||||
case 'Change Case Start Date':
|
||||
$showUpdate = $showDelete = FALSE;
|
||||
$url = 'civicrm/activity';
|
||||
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
$qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
break;
|
||||
|
||||
default:
|
||||
$url = 'civicrm/activity';
|
||||
$showView = $showDelete = $showUpdate = TRUE;
|
||||
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
$qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
|
||||
// When type is not available lets hide view and update.
|
||||
if (empty($activityTypeName)) {
|
||||
$showView = $showUpdate = FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$qsDelete = "atype={$activityTypeId}&action=delete&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
|
||||
|
||||
$actionLinks = array();
|
||||
|
||||
if ($showView) {
|
||||
$actionLinks += array(
|
||||
CRM_Core_Action::
|
||||
VIEW => array(
|
||||
'name' => ts('View'),
|
||||
'url' => $url,
|
||||
'qs' => $qsView,
|
||||
'title' => ts('View Activity'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ($showUpdate) {
|
||||
$updateUrl = 'civicrm/activity/add';
|
||||
if ($activityTypeName == 'Email') {
|
||||
$updateUrl = 'civicrm/activity/email/add';
|
||||
}
|
||||
elseif ($activityTypeName == 'Print PDF Letter') {
|
||||
$updateUrl = 'civicrm/activity/pdf/add';
|
||||
}
|
||||
if (CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::UPDATE)) {
|
||||
$actionLinks += array(
|
||||
CRM_Core_Action::
|
||||
UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => $updateUrl,
|
||||
'qs' => $qsUpdate,
|
||||
'title' => ts('Update Activity'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
$activityTypeName &&
|
||||
CRM_Case_BAO_Case::checkPermission($activityId, 'File On Case', $activityTypeId)
|
||||
) {
|
||||
$actionLinks += array(
|
||||
CRM_Core_Action::
|
||||
ADD => array(
|
||||
'name' => ts('File on Case'),
|
||||
'url' => '#',
|
||||
'extra' => 'onclick="javascript:fileOnCase( \'file\', \'%%id%%\', null, this ); return false;"',
|
||||
'title' => ts('File on Case'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ($showDelete) {
|
||||
if (!isset($delUrl) || !$delUrl) {
|
||||
$delUrl = $url;
|
||||
}
|
||||
$actionLinks += array(
|
||||
CRM_Core_Action::
|
||||
DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => $delUrl,
|
||||
'qs' => $qsDelete,
|
||||
'title' => ts('Delete Activity'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ($accessMailingReport) {
|
||||
$actionLinks += array(
|
||||
CRM_Core_Action::
|
||||
BROWSE => array(
|
||||
'name' => ts('Mailing Report'),
|
||||
'url' => 'civicrm/mailing/report',
|
||||
'qs' => "mid={$sourceRecordId}&reset=1&cid=%%cid%%&context=activitySelector",
|
||||
'title' => ts('View Mailing Report'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $actionLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for array of the parameters required for creating pager.
|
||||
*
|
||||
* @param $action
|
||||
* @param array $params
|
||||
*/
|
||||
public function getPagerParams($action, &$params) {
|
||||
$params['status'] = ts('Activities %%StatusMessage%%');
|
||||
$params['csvString'] = NULL;
|
||||
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
|
||||
|
||||
$params['buttonTop'] = 'PagerTopButton';
|
||||
$params['buttonBottom'] = 'PagerBottomButton';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column headers as an array of tuples:
|
||||
* (name, sortName (key to the sort array))
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return array
|
||||
* the column headers that need to be displayed
|
||||
*/
|
||||
public function &getColumnHeaders($action = NULL, $output = NULL) {
|
||||
if ($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) {
|
||||
$csvHeaders = array(ts('Activity Type'), ts('Description'), ts('Activity Date'));
|
||||
foreach (self::_getColumnHeaders() as $column) {
|
||||
if (array_key_exists('name', $column)) {
|
||||
$csvHeaders[] = $column['name'];
|
||||
}
|
||||
}
|
||||
return $csvHeaders;
|
||||
}
|
||||
else {
|
||||
return self::_getColumnHeaders();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total number of rows for the query.
|
||||
*
|
||||
* @param string $action
|
||||
* Action being performed.
|
||||
*
|
||||
* @param null $case
|
||||
*
|
||||
* @return int
|
||||
* Total number of rows
|
||||
*/
|
||||
public function getTotalCount($action, $case = NULL) {
|
||||
$params = array(
|
||||
'contact_id' => $this->_contactId,
|
||||
'admin' => $this->_admin,
|
||||
'caseId' => $case,
|
||||
'context' => $this->_context,
|
||||
'activity_type_id' => $this->_activityTypeIDs,
|
||||
'offset' => 0,
|
||||
'rowCount' => 0,
|
||||
'sort' => NULL,
|
||||
);
|
||||
return CRM_Activity_BAO_Activity::deprecatedGetActivitiesCount($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the rows in the given offset and rowCount.
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param int $offset
|
||||
* The row number to start from.
|
||||
* @param int $rowCount
|
||||
* The number of rows to return.
|
||||
* @param string $sort
|
||||
* The sql string that describes the sort order.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @param null $case
|
||||
*
|
||||
* @return int
|
||||
* the total number of rows for this action
|
||||
*/
|
||||
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $case = NULL) {
|
||||
$params = array(
|
||||
'contact_id' => $this->_contactId,
|
||||
'admin' => $this->_admin,
|
||||
'caseId' => $case,
|
||||
'context' => $this->_context,
|
||||
'activity_type_id' => $this->_activityTypeIDs,
|
||||
'offset' => $offset,
|
||||
'rowCount' => $rowCount,
|
||||
'sort' => $sort,
|
||||
);
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$rows = CRM_Activity_BAO_Activity::deprecatedGetActivities($params);
|
||||
|
||||
if (empty($rows)) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
|
||||
|
||||
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
|
||||
|
||||
// CRM-4418
|
||||
$permissions = array($this->_permission);
|
||||
if (CRM_Core_Permission::check('delete activities')) {
|
||||
$permissions[] = CRM_Core_Permission::DELETE;
|
||||
}
|
||||
$mask = CRM_Core_Action::mask($permissions);
|
||||
|
||||
foreach ($rows as $k => $row) {
|
||||
$row = &$rows[$k];
|
||||
|
||||
// DRAFTING: provide a facility for db-stored strings
|
||||
// localize the built-in activity names for display
|
||||
// (these are not enums, so we can't use any automagic here)
|
||||
switch ($row['activity_type']) {
|
||||
case 'Meeting':
|
||||
$row['activity_type'] = ts('Meeting');
|
||||
break;
|
||||
|
||||
case 'Phone Call':
|
||||
$row['activity_type'] = ts('Phone Call');
|
||||
break;
|
||||
|
||||
case 'Email':
|
||||
$row['activity_type'] = ts('Email');
|
||||
break;
|
||||
|
||||
case 'SMS':
|
||||
$row['activity_type'] = ts('SMS');
|
||||
break;
|
||||
|
||||
case 'Event':
|
||||
$row['activity_type'] = ts('Event');
|
||||
break;
|
||||
}
|
||||
|
||||
// add class to this row if overdue
|
||||
if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $row))
|
||||
&& CRM_Utils_Array::value('status_id', $row) == 1
|
||||
) {
|
||||
$row['overdue'] = 1;
|
||||
$row['class'] = 'status-overdue';
|
||||
}
|
||||
else {
|
||||
$row['overdue'] = 0;
|
||||
$row['class'] = 'status-ontime';
|
||||
}
|
||||
|
||||
$row['status'] = $row['status_id'] ? $activityStatus[$row['status_id']] : NULL;
|
||||
|
||||
if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $row)) {
|
||||
$row['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
|
||||
}
|
||||
|
||||
// CRM-3553
|
||||
$accessMailingReport = FALSE;
|
||||
if (!empty($row['mailingId'])) {
|
||||
$accessMailingReport = TRUE;
|
||||
}
|
||||
|
||||
$actionLinks = $this->actionLinks(CRM_Utils_Array::value('activity_type_id', $row),
|
||||
CRM_Utils_Array::value('source_record_id', $row),
|
||||
$accessMailingReport,
|
||||
CRM_Utils_Array::value('activity_id', $row),
|
||||
$this->_key
|
||||
);
|
||||
|
||||
$actionMask = array_sum(array_keys($actionLinks)) & $mask;
|
||||
|
||||
if ($output != CRM_Core_Selector_Controller::EXPORT && $output != CRM_Core_Selector_Controller::SCREEN) {
|
||||
$row['action'] = CRM_Core_Action::formLink($actionLinks,
|
||||
$actionMask,
|
||||
array(
|
||||
'id' => $row['activity_id'],
|
||||
'cid' => $this->_contactId,
|
||||
'cxt' => $this->_context,
|
||||
'caseid' => CRM_Utils_Array::value('case_id', $row),
|
||||
),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'activity.selector.action',
|
||||
'Activity',
|
||||
$row['activity_id']
|
||||
);
|
||||
}
|
||||
|
||||
unset($row);
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of export file.
|
||||
*
|
||||
* @param string $output
|
||||
* Type of output.
|
||||
*
|
||||
* @return string
|
||||
* name of the file
|
||||
*/
|
||||
public function getExportFileName($output = 'csv') {
|
||||
return ts('CiviCRM Activity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colunmn headers for search selector.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function &_getColumnHeaders() {
|
||||
if (!isset(self::$_columnHeaders)) {
|
||||
self::$_columnHeaders = array(
|
||||
array(
|
||||
'name' => ts('Type'),
|
||||
'sort' => 'activity_type',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Subject'),
|
||||
'sort' => 'subject',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Added By'),
|
||||
'sort' => 'source_contact_name',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array('name' => ts('With')),
|
||||
array('name' => ts('Assigned')),
|
||||
array(
|
||||
'name' => ts('Date'),
|
||||
'sort' => 'activity_date_time',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Status'),
|
||||
'sort' => 'status_id',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array('desc' => ts('Actions')),
|
||||
);
|
||||
}
|
||||
|
||||
return self::$_columnHeaders;
|
||||
}
|
||||
|
||||
}
|
459
sites/all/modules/civicrm/CRM/Activity/Selector/Search.php
Normal file
459
sites/all/modules/civicrm/CRM/Activity/Selector/Search.php
Normal file
|
@ -0,0 +1,459 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to retrieve and display a range of contacts that match the given criteria.
|
||||
*
|
||||
* Specifically for results of advanced search options.
|
||||
*/
|
||||
class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
|
||||
|
||||
/**
|
||||
* This defines two actions- View and Edit.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* We use desc to remind us what that column is, name is used in the tpl
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_columnHeaders;
|
||||
|
||||
/**
|
||||
* Properties of contact we're interested in displaying
|
||||
* @var array
|
||||
*/
|
||||
|
||||
static $_properties = array(
|
||||
'contact_id',
|
||||
'contact_type',
|
||||
'contact_sub_type',
|
||||
'sort_name',
|
||||
'display_name',
|
||||
'activity_id',
|
||||
'activity_date_time',
|
||||
'activity_status_id',
|
||||
'activity_status',
|
||||
'activity_subject',
|
||||
'source_record_id',
|
||||
'activity_type_id',
|
||||
'activity_type',
|
||||
'activity_is_test',
|
||||
'activity_campaign_id',
|
||||
'activity_engagement_level',
|
||||
);
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_single = FALSE;
|
||||
|
||||
/**
|
||||
* Are we restricting ourselves to a single contact.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_limit = NULL;
|
||||
|
||||
/**
|
||||
* What context are we being invoked from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = NULL;
|
||||
|
||||
/**
|
||||
* What component context are we being invoked from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_compContext = NULL;
|
||||
|
||||
/**
|
||||
* QueryParams is the array returned by exportValues called on.
|
||||
* the HTML_QuickForm_Controller for that page.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_queryParams;
|
||||
|
||||
/**
|
||||
* Represent the type of selector.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_action;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_activityClause = NULL;
|
||||
|
||||
/**
|
||||
* The query object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_query;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param array $queryParams
|
||||
* Array of parameters for query.
|
||||
* @param \const|int $action - action of search basic or advanced.
|
||||
* @param string $activityClause
|
||||
* If the caller wants to further restrict the search (used in activities).
|
||||
* @param bool $single
|
||||
* Are we dealing only with one contact?.
|
||||
* @param int $limit
|
||||
* How many activities do we want returned.
|
||||
*
|
||||
* @param string $context
|
||||
* @param null $compContext
|
||||
*
|
||||
* @return \CRM_Activity_Selector_Search
|
||||
*/
|
||||
public function __construct(
|
||||
&$queryParams,
|
||||
$action = CRM_Core_Action::NONE,
|
||||
$activityClause = NULL,
|
||||
$single = FALSE,
|
||||
$limit = NULL,
|
||||
$context = 'search',
|
||||
$compContext = NULL
|
||||
) {
|
||||
// submitted form values
|
||||
$this->_queryParams = &$queryParams;
|
||||
|
||||
$this->_single = $single;
|
||||
$this->_limit = $limit;
|
||||
$this->_context = $context;
|
||||
$this->_compContext = $compContext;
|
||||
|
||||
$this->_activityClause = $activityClause;
|
||||
|
||||
// CRM-12675
|
||||
$components = CRM_Core_Component::getNames();
|
||||
$componentClause = array();
|
||||
foreach ($components as $componentID => $componentName) {
|
||||
// CRM-19201: Add support for searching CiviCampaign and CiviCase
|
||||
// activities. For CiviCase, "access all cases and activities" is
|
||||
// required here rather than "access my cases and activities" to
|
||||
// prevent those with only the later permission from seeing a list
|
||||
// of all cases which might present a privacy issue.
|
||||
if (!CRM_Core_Permission::access($componentName, TRUE, TRUE)) {
|
||||
$componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) ";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($componentClause)) {
|
||||
$componentRestriction = implode(' AND ', $componentClause);
|
||||
if (empty($this->_activityClause)) {
|
||||
$this->_activityClause = $componentRestriction;
|
||||
}
|
||||
else {
|
||||
$this->_activityClause .= ' AND ' . $componentRestriction;
|
||||
}
|
||||
}
|
||||
|
||||
// type of selector
|
||||
$this->_action = $action;
|
||||
$this->_query = new CRM_Contact_BAO_Query($this->_queryParams,
|
||||
CRM_Activity_BAO_Query::selectorReturnProperties(),
|
||||
NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_ACTIVITY
|
||||
);
|
||||
$this->_query->_distinctComponentClause = '( civicrm_activity.id )';
|
||||
$this->_query->_groupByComponentClause = " GROUP BY civicrm_activity.id ";
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for array of the parameters required for creating pager.
|
||||
*
|
||||
* @param $action
|
||||
* @param array $params
|
||||
*/
|
||||
public function getPagerParams($action, &$params) {
|
||||
$params['status'] = ts('Activities %%StatusMessage%%');
|
||||
$params['csvString'] = NULL;
|
||||
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
|
||||
$params['buttonTop'] = 'PagerTopButton';
|
||||
$params['buttonBottom'] = 'PagerBottomButton';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total number of rows for the query.
|
||||
*
|
||||
* @param string $action
|
||||
*
|
||||
* @return int
|
||||
* Total number of rows
|
||||
*/
|
||||
public function getTotalCount($action) {
|
||||
return $this->_query->searchQuery(0, 0, NULL,
|
||||
TRUE, FALSE,
|
||||
FALSE, FALSE,
|
||||
FALSE,
|
||||
$this->_activityClause
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the rows in the given offset and rowCount.
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param int $offset
|
||||
* The row number to start from.
|
||||
* @param int $rowCount
|
||||
* The number of rows to return.
|
||||
* @param string $sort
|
||||
* The sql string that describes the sort order.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return array
|
||||
* rows in the given offset and rowCount
|
||||
*/
|
||||
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
|
||||
$result = $this->_query->searchQuery(
|
||||
$offset, $rowCount, $sort,
|
||||
FALSE, FALSE,
|
||||
FALSE, FALSE,
|
||||
FALSE,
|
||||
$this->_activityClause
|
||||
);
|
||||
$rows = array();
|
||||
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
|
||||
$accessCiviMail = CRM_Core_Permission::check('access CiviMail');
|
||||
|
||||
// Get all campaigns.
|
||||
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
|
||||
|
||||
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
|
||||
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
|
||||
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
|
||||
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
|
||||
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
|
||||
// Get all activity types
|
||||
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
|
||||
|
||||
while ($result->fetch()) {
|
||||
$row = array();
|
||||
|
||||
// Ignore rows where we dont have an activity id.
|
||||
if (empty($result->activity_id)) {
|
||||
continue;
|
||||
}
|
||||
$this->_query->convertToPseudoNames($result);
|
||||
|
||||
// the columns we are interested in
|
||||
foreach (self::$_properties as $property) {
|
||||
if (isset($result->$property)) {
|
||||
$row[$property] = $result->$property;
|
||||
}
|
||||
}
|
||||
|
||||
$contactId = CRM_Utils_Array::value('contact_id', $row);
|
||||
if (!$contactId) {
|
||||
$contactId = CRM_Utils_Array::value('source_contact_id', $row);
|
||||
}
|
||||
|
||||
$row['target_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $targetID);
|
||||
$row['assignee_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $assigneeID);
|
||||
list($row['source_contact_name'], $row['source_contact_id']) = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $sourceID, TRUE);
|
||||
$row['source_contact_name'] = implode(',', array_values($row['source_contact_name']));
|
||||
$row['source_contact_id'] = implode(',', $row['source_contact_id']);
|
||||
|
||||
if ($this->_context == 'search') {
|
||||
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->activity_id;
|
||||
}
|
||||
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
|
||||
);
|
||||
$accessMailingReport = FALSE;
|
||||
$activityTypeId = $row['activity_type_id'];
|
||||
if ($row['activity_is_test']) {
|
||||
$row['activity_type'] = $row['activity_type'] . " (test)";
|
||||
}
|
||||
$bulkActivityTypeID = CRM_Utils_Array::key('Bulk Email', $activityTypes);
|
||||
$row['mailingId'] = '';
|
||||
if (
|
||||
$accessCiviMail &&
|
||||
($mailingIDs === TRUE || in_array($result->source_record_id, $mailingIDs)) &&
|
||||
($bulkActivityTypeID == $activityTypeId)
|
||||
) {
|
||||
$row['mailingId'] = CRM_Utils_System::url('civicrm/mailing/report',
|
||||
"mid={$result->source_record_id}&reset=1&cid={$contactId}&context=activitySelector"
|
||||
);
|
||||
$row['recipients'] = ts('(recipients)');
|
||||
$row['target_contact_name'] = '';
|
||||
$row['assignee_contact_name'] = '';
|
||||
$accessMailingReport = TRUE;
|
||||
}
|
||||
$activityActions = new CRM_Activity_Selector_Activity($result->contact_id, NULL);
|
||||
$actionLinks = $activityActions->actionLinks($activityTypeId,
|
||||
CRM_Utils_Array::value('source_record_id', $row),
|
||||
$accessMailingReport,
|
||||
CRM_Utils_Array::value('activity_id', $row),
|
||||
$this->_key,
|
||||
$this->_compContext
|
||||
);
|
||||
$row['action'] = CRM_Core_Action::formLink($actionLinks, NULL,
|
||||
array(
|
||||
'id' => $result->activity_id,
|
||||
'cid' => $contactId,
|
||||
'cxt' => $this->_context,
|
||||
),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'activity.selector.row',
|
||||
'Activity',
|
||||
$result->activity_id
|
||||
);
|
||||
|
||||
// Carry campaign to selector.
|
||||
$row['campaign'] = CRM_Utils_Array::value($result->activity_campaign_id, $allCampaigns);
|
||||
$row['campaign_id'] = $result->activity_campaign_id;
|
||||
|
||||
if ($engagementLevel = CRM_Utils_Array::value('activity_engagement_level', $row)) {
|
||||
$row['activity_engagement_level'] = CRM_Utils_Array::value($engagementLevel,
|
||||
$engagementLevels, $engagementLevel
|
||||
);
|
||||
}
|
||||
|
||||
// Check if recurring activity.
|
||||
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['activity_id'], 'civicrm_activity');
|
||||
$row['repeat'] = '';
|
||||
if ($repeat) {
|
||||
$row['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
|
||||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* which contains an array of strings
|
||||
*/
|
||||
public function getQILL() {
|
||||
return $this->_query->qill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column headers as an array of tuples:
|
||||
* (name, sortName (key to the sort array))
|
||||
*
|
||||
* @param string $action
|
||||
* The action being performed.
|
||||
* @param string $output
|
||||
* What should the result set include (web/email/csv).
|
||||
*
|
||||
* @return array
|
||||
* the column headers that need to be displayed
|
||||
*/
|
||||
public function &getColumnHeaders($action = NULL, $output = NULL) {
|
||||
if (!isset(self::$_columnHeaders)) {
|
||||
self::$_columnHeaders = array(
|
||||
array(
|
||||
'name' => ts('Type'),
|
||||
'sort' => 'activity_type_id',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Subject'),
|
||||
'sort' => 'activity_subject',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Added By'),
|
||||
'sort' => 'source_contact',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array('name' => ts('With')),
|
||||
array('name' => ts('Assigned')),
|
||||
array(
|
||||
'name' => ts('Date'),
|
||||
'sort' => 'activity_date_time',
|
||||
'direction' => CRM_Utils_Sort::DESCENDING,
|
||||
),
|
||||
array(
|
||||
'name' => ts('Status'),
|
||||
'sort' => 'activity_status',
|
||||
'direction' => CRM_Utils_Sort::DONTCARE,
|
||||
),
|
||||
array(
|
||||
'desc' => ts('Actions'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_columnHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function alphabetQuery() {
|
||||
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function &getQuery() {
|
||||
return $this->_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of export file.
|
||||
*
|
||||
* @param string $output
|
||||
* Type of output.
|
||||
*
|
||||
* @return string
|
||||
* name of the file
|
||||
*/
|
||||
public function getExportFileName($output = 'csv') {
|
||||
return ts('CiviCRM Activity Search');
|
||||
}
|
||||
|
||||
}
|
114
sites/all/modules/civicrm/CRM/Activity/StateMachine/Search.php
Normal file
114
sites/all/modules/civicrm/CRM/Activity/StateMachine/Search.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Activity_StateMachine_Search extends CRM_Core_StateMachine {
|
||||
|
||||
/**
|
||||
* The task that the wizard is currently processing.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_task;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param object $controller
|
||||
* @param \const|int $action
|
||||
*/
|
||||
public function __construct($controller, $action = CRM_Core_Action::NONE) {
|
||||
parent::__construct($controller, $action);
|
||||
|
||||
$this->_pages = array();
|
||||
|
||||
$this->_pages['CRM_Activity_Form_Search'] = NULL;
|
||||
list($task, $result) = $this->taskName($controller, 'Search');
|
||||
$this->_task = $task;
|
||||
|
||||
if (is_array($task)) {
|
||||
foreach ($task as $t) {
|
||||
$this->_pages[$t] = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->_pages[$task] = NULL;
|
||||
}
|
||||
|
||||
$this->addSequentialPages($this->_pages, $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the form name based on the action. This allows us
|
||||
* to avoid using conditional state machine, much more efficient
|
||||
* and simpler
|
||||
*
|
||||
* @param CRM_Core_Controller $controller
|
||||
* The controller object.
|
||||
*
|
||||
* @param string $formName
|
||||
*
|
||||
* @return string
|
||||
* the name of the form that will handle the task
|
||||
*/
|
||||
public function taskName($controller, $formName = 'Search') {
|
||||
// total hack, check POST vars and then session to determine stuff
|
||||
$value = CRM_Utils_Array::value('task', $_POST);
|
||||
if (!isset($value)) {
|
||||
$value = $this->_controller->get('task');
|
||||
}
|
||||
$this->_controller->set('task', $value);
|
||||
return CRM_Activity_Task::getTask($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the form name of the task.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTaskFormName() {
|
||||
return CRM_Utils_String::getClassName($this->_task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the controller reset the session.
|
||||
* In some cases, specifically search we want to remember
|
||||
* state across various actions and want to go back to the
|
||||
* beginning from the final state, but retain the same session
|
||||
* values
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldReset() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
206
sites/all/modules/civicrm/CRM/Activity/Task.php
Normal file
206
sites/all/modules/civicrm/CRM/Activity/Task.php
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to represent the actions that can be performed on a group of contacts used by the search forms.
|
||||
*/
|
||||
class CRM_Activity_Task {
|
||||
const
|
||||
DELETE_ACTIVITIES = 1,
|
||||
PRINT_ACTIVITIES = 2,
|
||||
EXPORT_ACTIVITIES = 3,
|
||||
BATCH_ACTIVITIES = 4,
|
||||
EMAIL_CONTACTS = 5,
|
||||
EMAIL_SMS = 6;
|
||||
|
||||
/**
|
||||
* The task array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_tasks = NULL;
|
||||
|
||||
/**
|
||||
* The optional task array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_optionalTasks = NULL;
|
||||
|
||||
/**
|
||||
* These tasks are the core set of tasks that the user can perform
|
||||
* on a contact / group of contacts.
|
||||
*
|
||||
* @return array
|
||||
* the set of tasks for a group of contacts
|
||||
*/
|
||||
public static function &tasks() {
|
||||
if (!(self::$_tasks)) {
|
||||
self::$_tasks = array(
|
||||
1 => array(
|
||||
'title' => ts('Delete activities'),
|
||||
'class' => 'CRM_Activity_Form_Task_Delete',
|
||||
'result' => FALSE,
|
||||
),
|
||||
2 => array(
|
||||
'title' => ts('Print selected rows'),
|
||||
'class' => 'CRM_Activity_Form_Task_Print',
|
||||
'result' => FALSE,
|
||||
),
|
||||
3 => array(
|
||||
'title' => ts('Export activities'),
|
||||
'class' => array(
|
||||
'CRM_Export_Form_Select',
|
||||
'CRM_Export_Form_Map',
|
||||
),
|
||||
'result' => FALSE,
|
||||
),
|
||||
4 => array(
|
||||
'title' => ts('Update multiple activities'),
|
||||
'class' => array(
|
||||
'CRM_Activity_Form_Task_PickProfile',
|
||||
'CRM_Activity_Form_Task_Batch',
|
||||
),
|
||||
'result' => FALSE,
|
||||
),
|
||||
5 => array(
|
||||
'title' => ts('Email - send now'),
|
||||
'class' => array(
|
||||
'CRM_Activity_Form_Task_PickOption',
|
||||
'CRM_Activity_Form_Task_Email',
|
||||
),
|
||||
'result' => FALSE,
|
||||
),
|
||||
6 => array(
|
||||
'title' => ts('SMS - send reply'),
|
||||
'class' => 'CRM_Activity_Form_Task_SMS',
|
||||
'result' => FALSE,
|
||||
),
|
||||
7 => array(
|
||||
'title' => ts('Tag - add to activities'),
|
||||
'class' => 'CRM_Activity_Form_Task_AddToTag',
|
||||
'result' => FALSE,
|
||||
),
|
||||
8 => array(
|
||||
'title' => ts('Tag - remove from activities'),
|
||||
'class' => 'CRM_Activity_Form_Task_RemoveFromTag',
|
||||
'result' => FALSE,
|
||||
),
|
||||
);
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
if (in_array('CiviCase', $config->enableComponents)) {
|
||||
if (CRM_Core_Permission::check('access all cases and activities') ||
|
||||
CRM_Core_Permission::check('access my cases and activities')
|
||||
) {
|
||||
self::$_tasks[6] = array(
|
||||
'title' => ts('File on case'),
|
||||
'class' => 'CRM_Activity_Form_Task_FileOnCase',
|
||||
'result' => FALSE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// CRM-4418, check for delete
|
||||
if (!CRM_Core_Permission::check('delete activities')) {
|
||||
unset(self::$_tasks[1]);
|
||||
}
|
||||
|
||||
CRM_Utils_Hook::searchTasks('activity', self::$_tasks);
|
||||
asort(self::$_tasks);
|
||||
}
|
||||
|
||||
return self::$_tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* These tasks are the core set of task titles on activity.
|
||||
*
|
||||
* @return array
|
||||
* the set of task titles
|
||||
*/
|
||||
public static function &taskTitles() {
|
||||
self::tasks();
|
||||
$titles = array();
|
||||
foreach (self::$_tasks as $id => $value) {
|
||||
$titles[$id] = $value['title'];
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show tasks selectively based on the permission level of the user.
|
||||
*
|
||||
* @param int $permission
|
||||
*
|
||||
* @return array
|
||||
* set of tasks that are valid for the user
|
||||
*/
|
||||
public static function &permissionedTaskTitles($permission) {
|
||||
$tasks = array();
|
||||
if ($permission == CRM_Core_Permission::EDIT) {
|
||||
$tasks = self::taskTitles();
|
||||
}
|
||||
else {
|
||||
$tasks = array(
|
||||
3 => self::$_tasks[3]['title'],
|
||||
);
|
||||
|
||||
//CRM-4418,
|
||||
if (CRM_Core_Permission::check('delete activities')) {
|
||||
$tasks[1] = self::$_tasks[1]['title'];
|
||||
}
|
||||
}
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* These tasks are the core set of tasks that the user can perform on activity.
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return array
|
||||
* the set of tasks for a group of activity
|
||||
*/
|
||||
public static function getTask($value) {
|
||||
self::tasks();
|
||||
if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
|
||||
// make the print task by default
|
||||
$value = 2;
|
||||
}
|
||||
return array(
|
||||
self::$_tasks[$value]['class'],
|
||||
self::$_tasks[$value]['result'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
121
sites/all/modules/civicrm/CRM/Activity/Tokens.php
Normal file
121
sites/all/modules/civicrm/CRM/Activity/Tokens.php
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class CRM_Member_Tokens
|
||||
*
|
||||
* Generate "activity.*" tokens.
|
||||
*
|
||||
* This TokenSubscriber was produced by refactoring the code from the
|
||||
* scheduled-reminder system with the goal of making that system
|
||||
* more flexible. The current implementation is still coupled to
|
||||
* scheduled-reminders. It would be good to figure out a more generic
|
||||
* implementation which is not tied to scheduled reminders, although
|
||||
* that is outside the current scope.
|
||||
*/
|
||||
class CRM_Activity_Tokens extends \Civi\Token\AbstractTokenSubscriber {
|
||||
|
||||
/**
|
||||
* CRM_Activity_Tokens constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct('activity', array_merge(
|
||||
array(
|
||||
'activity_id' => ts('Activity ID'),
|
||||
'activity_type' => ts('Activity Type'),
|
||||
'subject' => ts('Activity Subject'),
|
||||
'details' => ts('Activity Details'),
|
||||
'activity_date_time' => ts('Activity Date-Time'),
|
||||
),
|
||||
CRM_Utils_Token::getCustomFieldTokens('Activity')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function checkActive(\Civi\Token\TokenProcessor $processor) {
|
||||
// Extracted from scheduled-reminders code. See the class description.
|
||||
return
|
||||
!empty($processor->context['actionMapping'])
|
||||
&& $processor->context['actionMapping']->getEntity() === 'civicrm_activity';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQueryEvent $e) {
|
||||
if ($e->mapping->getEntity() !== 'civicrm_activity') {
|
||||
return;
|
||||
}
|
||||
|
||||
// The joint expression for activities needs some extra nuance to handle.
|
||||
// Multiple revisions of the activity.
|
||||
// Q: Could we simplify & move the extra AND clauses into `where(...)`?
|
||||
$e->query->param('casEntityJoinExpr', 'e.id = reminder.entity_id AND e.is_current_revision = 1 AND e.is_deleted = 0');
|
||||
|
||||
$e->query->select('e.*'); // FIXME: seems too broad.
|
||||
$e->query->select('ov.label as activity_type, e.id as activity_id');
|
||||
|
||||
$e->query->join("og", "!casMailingJoinType civicrm_option_group og ON og.name = 'activity_type'");
|
||||
$e->query->join("ov", "!casMailingJoinType civicrm_option_value ov ON e.activity_type_id = ov.value AND ov.option_group_id = og.id");
|
||||
|
||||
// if CiviCase component is enabled, join for caseId.
|
||||
$compInfo = CRM_Core_Component::getEnabledComponents();
|
||||
if (array_key_exists('CiviCase', $compInfo)) {
|
||||
$e->query->select("civicrm_case_activity.case_id as case_id");
|
||||
$e->query->join('civicrm_case_activity', "LEFT JOIN `civicrm_case_activity` ON `e`.`id` = `civicrm_case_activity`.`activity_id`");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) {
|
||||
$actionSearchResult = $row->context['actionSearchResult'];
|
||||
|
||||
if (in_array($field, array('activity_date_time'))) {
|
||||
$row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->$field));
|
||||
}
|
||||
elseif (isset($actionSearchResult->$field)) {
|
||||
$row->tokens($entity, $field, $actionSearchResult->$field);
|
||||
}
|
||||
elseif ($cfID = \CRM_Core_BAO_CustomField::getKeyID($field)) {
|
||||
$row->customToken($entity, $cfID, $actionSearchResult->entity_id);
|
||||
}
|
||||
else {
|
||||
$row->tokens($entity, $field, '');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
155
sites/all/modules/civicrm/CRM/Admin/Form.php
Normal file
155
sites/all/modules/civicrm/CRM/Admin/Form.php
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for admin forms.
|
||||
*/
|
||||
class CRM_Admin_Form extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The id of the object being edited / created
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* The default values for form fields.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_values;
|
||||
|
||||
/**
|
||||
* The name of the BAO object for this form.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_BAOName;
|
||||
|
||||
/**
|
||||
* Explicitly declare the form context.
|
||||
*/
|
||||
public function getDefaultContext() {
|
||||
return 'create';
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic setup.
|
||||
*/
|
||||
public function preProcess() {
|
||||
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
|
||||
Civi::resources()->addScriptFile('civicrm', 'js/crm.admin.js');
|
||||
|
||||
$this->_id = $this->get('id');
|
||||
$this->_BAOName = $this->get('BAOName');
|
||||
$this->_values = array();
|
||||
if (isset($this->_id)) {
|
||||
$params = array('id' => $this->_id);
|
||||
// this is needed if the form is outside the CRM name space
|
||||
$baoName = $this->_BAOName;
|
||||
$baoName::retrieve($params, $this->_values);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form. Note that in edit/view mode
|
||||
* the default values are retrieved from the database
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
// Fetch defaults from the db
|
||||
if (!empty($this->_id) && empty($this->_values) && CRM_Utils_Rule::positiveInteger($this->_id)) {
|
||||
$this->_values = array();
|
||||
$params = array('id' => $this->_id);
|
||||
$baoName = $this->_BAOName;
|
||||
$baoName::retrieve($params, $this->_values);
|
||||
}
|
||||
$defaults = $this->_values;
|
||||
|
||||
// Allow defaults to be set from the url
|
||||
if (empty($this->_id) && $this->_action & CRM_Core_Action::ADD) {
|
||||
foreach ($_GET as $key => $val) {
|
||||
if ($this->elementExists($key)) {
|
||||
$defaults[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_action == CRM_Core_Action::DELETE &&
|
||||
isset($defaults['name'])
|
||||
) {
|
||||
$this->assign('delName', $defaults['name']);
|
||||
}
|
||||
|
||||
// its ok if there is no element called is_active
|
||||
$defaults['is_active'] = ($this->_id) ? CRM_Utils_Array::value('is_active', $defaults) : 1;
|
||||
if (!empty($defaults['parent_id'])) {
|
||||
$this->assign('is_parent', TRUE);
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add standard buttons.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
if ($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::PREVIEW) {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Done'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
89
sites/all/modules/civicrm/CRM/Admin/Form/CMSUser.php
Normal file
89
sites/all/modules/civicrm/CRM/Admin/Form/CMSUser.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Synchronizing CMS Users
|
||||
*/
|
||||
class CRM_Admin_Form_CMSUser extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('OK'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$result = CRM_Utils_System::synchronizeUsers();
|
||||
|
||||
$status = ts('Checked one user record.',
|
||||
array(
|
||||
'count' => $result['contactCount'],
|
||||
'plural' => 'Checked %count user records.',
|
||||
)
|
||||
);
|
||||
if ($result['contactMatching']) {
|
||||
$status .= '<br />' . ts('Found one matching contact record.',
|
||||
array(
|
||||
'count' => $result['contactMatching'],
|
||||
'plural' => 'Found %count matching contact records.',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$status .= '<br />' . ts('Created one new contact record.',
|
||||
array(
|
||||
'count' => $result['contactCreated'],
|
||||
'plural' => 'Created %count new contact records.',
|
||||
)
|
||||
);
|
||||
CRM_Core_Session::setStatus($status, ts('Synchronize Complete'), 'success');
|
||||
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
|
||||
}
|
||||
|
||||
}
|
149
sites/all/modules/civicrm/CRM/Admin/Form/ContactType.php
Normal file
149
sites/all/modules/civicrm/CRM/Admin/Form/ContactType.php
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for ContactSub Type.
|
||||
*/
|
||||
class CRM_Admin_Form_ContactType extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->setPageTitle(ts('Contact Type'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
$this->add('text', 'label', ts('Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_ContactType', 'label'),
|
||||
TRUE
|
||||
);
|
||||
$contactType = $this->add('select', 'parent_id', ts('Basic Contact Type'),
|
||||
CRM_Contact_BAO_ContactType::basicTypePairs(FALSE, 'id')
|
||||
);
|
||||
$enabled = $this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$contactType->freeze();
|
||||
// We'll display actual "name" for built-in types (for reference) when editing their label / image_URL
|
||||
$contactTypeName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $this->_id, 'name');
|
||||
$this->assign('contactTypeName', $contactTypeName);
|
||||
|
||||
$this->_parentId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $this->_id, 'parent_id');
|
||||
// Freeze Enabled field for built-in contact types (parent_id is NULL for these)
|
||||
if (is_null($this->_parentId)) {
|
||||
$enabled->freeze();
|
||||
}
|
||||
}
|
||||
$this->addElement('text', 'image_URL', ts('Image URL'));
|
||||
$this->add('text', 'description', ts('Description'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_ContactType', 'description')
|
||||
);
|
||||
|
||||
$this->assign('cid', $this->_id);
|
||||
$this->addFormRule(array('CRM_Admin_Form_ContactType', 'formRule'), $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
*
|
||||
* @param $files
|
||||
* @param $self
|
||||
*
|
||||
* @return bool|array
|
||||
* true if no errors, else array of errors
|
||||
*/
|
||||
public static function formRule($fields, $files, $self) {
|
||||
|
||||
$errors = array();
|
||||
|
||||
if ($self->_id) {
|
||||
$contactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $self->_id, 'name');
|
||||
}
|
||||
else {
|
||||
$contactName = ucfirst(CRM_Utils_String::munge($fields['label']));
|
||||
}
|
||||
|
||||
if (!CRM_Core_DAO::objectExists($contactName, 'CRM_Contact_DAO_ContactType', $self->_id)) {
|
||||
$errors['label'] = ts('This contact type name already exists in database. Contact type names must be unique.');
|
||||
}
|
||||
|
||||
$reservedKeyWords = CRM_Core_SelectValues::customGroupExtends();
|
||||
//restrict "name" from being a reserved keyword when a new contact subtype is created
|
||||
if (!$self->_id && in_array($contactName, array_keys($reservedKeyWords))) {
|
||||
$errors['label'] = ts('Contact type names should not use reserved keywords.');
|
||||
}
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Utils_System::flushCache();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
$isDelete = CRM_Contact_BAO_ContactType::del($this->_id);
|
||||
if ($isDelete) {
|
||||
CRM_Core_Session::setStatus(ts('Selected contact type has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts("Selected contact type can not be deleted. Make sure contact type doesn't have any associated custom data or group."), ts('Sorry'), 'error');
|
||||
}
|
||||
return;
|
||||
}
|
||||
// store the submitted values in an array
|
||||
$params = $this->exportValues();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$params['id'] = $this->_id;
|
||||
// Force Enabled = true for built-in contact types to fix problems caused by CRM-6471 (parent_id is NULL for these types)
|
||||
if (is_null($this->_parentId)) {
|
||||
$params['is_active'] = 1;
|
||||
}
|
||||
}
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
$params['name'] = ucfirst(CRM_Utils_String::munge($params['label']));
|
||||
}
|
||||
$contactType = CRM_Contact_BAO_ContactType::add($params);
|
||||
CRM_Core_Session::setStatus(ts("The Contact Type '%1' has been saved.",
|
||||
array(1 => $contactType->label)
|
||||
), ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
}
|
225
sites/all/modules/civicrm/CRM/Admin/Form/Extensions.php
Normal file
225
sites/all/modules/civicrm/CRM/Admin/Form/Extensions.php
Normal file
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Extensions.
|
||||
*/
|
||||
class CRM_Admin_Form_Extensions extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Form pre-processing.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
|
||||
$mainPage = new CRM_Admin_Page_Extensions();
|
||||
$localExtensionRows = $mainPage->formatLocalExtensionRows();
|
||||
$this->assign('localExtensionRows', $localExtensionRows);
|
||||
|
||||
$remoteExtensionRows = $mainPage->formatRemoteExtensionRows($localExtensionRows);
|
||||
$this->assign('remoteExtensionRows', $remoteExtensionRows);
|
||||
|
||||
$this->_key = CRM_Utils_Request::retrieve('key', 'String',
|
||||
$this, FALSE, 0
|
||||
);
|
||||
if (!CRM_Utils_Type::validate($this->_key, 'ExtensionKey') && !empty($this->_key)) {
|
||||
throw new CRM_Core_Exception('Extension Key does not match expected standard');
|
||||
}
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$url = CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1&action=browse');
|
||||
$session->pushUserContext($url);
|
||||
$this->assign('id', $this->_id);
|
||||
$this->assign('key', $this->_key);
|
||||
|
||||
switch ($this->_action) {
|
||||
case CRM_Core_Action::ADD:
|
||||
case CRM_Core_Action::DELETE:
|
||||
case CRM_Core_Action::ENABLE:
|
||||
case CRM_Core_Action::DISABLE:
|
||||
$info = CRM_Extension_System::singleton()->getMapper()->keyToInfo($this->_key);
|
||||
$extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
|
||||
$this->assign('extension', $extInfo);
|
||||
break;
|
||||
|
||||
case CRM_Core_Action::UPDATE:
|
||||
if (!CRM_Extension_System::singleton()->getBrowser()->isEnabled()) {
|
||||
CRM_Core_Error::fatal(ts('The system administrator has disabled this feature.'));
|
||||
}
|
||||
$info = CRM_Extension_System::singleton()->getBrowser()->getExtension($this->_key);
|
||||
$extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
|
||||
$this->assign('extension', $extInfo);
|
||||
break;
|
||||
|
||||
default:
|
||||
CRM_Core_Error::fatal(ts('Unsupported action'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
switch ($this->_action) {
|
||||
case CRM_Core_Action::ADD:
|
||||
$buttonName = ts('Install');
|
||||
$title = ts('Install "%1"?', array(
|
||||
1 => $this->_key,
|
||||
));
|
||||
break;
|
||||
|
||||
case CRM_Core_Action::UPDATE:
|
||||
$buttonName = ts('Download and Install');
|
||||
$title = ts('Download and Install "%1"?', array(
|
||||
1 => $this->_key,
|
||||
));
|
||||
break;
|
||||
|
||||
case CRM_Core_Action::DELETE:
|
||||
$buttonName = ts('Uninstall');
|
||||
$title = ts('Uninstall "%1"?', array(
|
||||
1 => $this->_key,
|
||||
));
|
||||
break;
|
||||
|
||||
case CRM_Core_Action::ENABLE:
|
||||
$buttonName = ts('Enable');
|
||||
$title = ts('Enable "%1"?', array(
|
||||
1 => $this->_key,
|
||||
));
|
||||
break;
|
||||
|
||||
case CRM_Core_Action::DISABLE:
|
||||
$buttonName = ts('Disable');
|
||||
$title = ts('Disable "%1"?', array(
|
||||
1 => $this->_key,
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->assign('title', $title);
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => $buttonName,
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
* @param array $files
|
||||
* The uploaded files if any.
|
||||
* @param array $self
|
||||
* This object.
|
||||
*
|
||||
* @return bool|array
|
||||
* true if no errors, else an array of errors
|
||||
*/
|
||||
public static function formRule($fields, $files, $self) {
|
||||
$errors = array();
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Utils_System::flushCache();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
try {
|
||||
CRM_Extension_System::singleton()->getManager()->uninstall(array($this->_key));
|
||||
CRM_Core_Session::setStatus("", ts('Extension Uninstalled'), "success");
|
||||
}
|
||||
catch (CRM_Extension_Exception_DependencyException $e) {
|
||||
// currently only thrown for payment-processor dependencies
|
||||
CRM_Core_Session::setStatus(ts('Cannot uninstall this extension - there is at least one payment processor using the payment processor type provided by it.'), ts('Uninstall Error'), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
civicrm_api3('Extension', 'install', array('keys' => $this->_key));
|
||||
CRM_Core_Session::setStatus("", ts('Extension Installed'), "success");
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::ENABLE) {
|
||||
civicrm_api3('Extension', 'enable', array('keys' => $this->_key));
|
||||
CRM_Core_Session::setStatus("", ts('Extension Enabled'), "success");
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DISABLE) {
|
||||
CRM_Extension_System::singleton()->getManager()->disable(array($this->_key));
|
||||
CRM_Core_Session::setStatus("", ts('Extension Disabled'), "success");
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$result = civicrm_api('Extension', 'download', array(
|
||||
'version' => 3,
|
||||
'key' => $this->_key,
|
||||
));
|
||||
if (!CRM_Utils_Array::value('is_error', $result, FALSE)) {
|
||||
CRM_Core_Session::setStatus("", ts('Extension Upgraded'), "success");
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus($result['error_message'], ts('Extension Upgrade Failed'), "error");
|
||||
}
|
||||
}
|
||||
|
||||
CRM_Utils_System::redirect(
|
||||
CRM_Utils_System::url(
|
||||
'civicrm/admin/extensions',
|
||||
'reset=1&action=browse'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
242
sites/all/modules/civicrm/CRM/Admin/Form/Job.php
Normal file
242
sites/all/modules/civicrm/CRM/Admin/Form/Job.php
Normal file
|
@ -0,0 +1,242 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for configuring jobs.
|
||||
*/
|
||||
class CRM_Admin_Form_Job extends CRM_Admin_Form {
|
||||
protected $_id = NULL;
|
||||
|
||||
public function preProcess() {
|
||||
|
||||
parent::preProcess();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Manage - Scheduled Jobs'));
|
||||
|
||||
if ($this->_id) {
|
||||
$refreshURL = CRM_Utils_System::url('civicrm/admin/job',
|
||||
"reset=1&action=update&id={$this->_id}",
|
||||
FALSE, NULL, FALSE
|
||||
);
|
||||
}
|
||||
else {
|
||||
$refreshURL = CRM_Utils_System::url('civicrm/admin/job',
|
||||
"reset=1&action=add",
|
||||
FALSE, NULL, FALSE
|
||||
);
|
||||
}
|
||||
|
||||
$this->assign('refreshURL', $refreshURL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @param bool $check
|
||||
*/
|
||||
public function buildQuickForm($check = FALSE) {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Job');
|
||||
|
||||
$this->add('text', 'name', ts('Name'),
|
||||
$attributes['name'], TRUE
|
||||
);
|
||||
|
||||
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
|
||||
'CRM_Core_DAO_Job',
|
||||
$this->_id,
|
||||
));
|
||||
|
||||
$this->add('text', 'description', ts('Description'),
|
||||
$attributes['description']
|
||||
);
|
||||
|
||||
$this->add('text', 'api_entity', ts('API Call Entity'),
|
||||
$attributes['api_entity'], TRUE
|
||||
);
|
||||
|
||||
$this->add('text', 'api_action', ts('API Call Action'),
|
||||
$attributes['api_action'], TRUE
|
||||
);
|
||||
|
||||
$this->add('select', 'run_frequency', ts('Run frequency'), CRM_Core_SelectValues::getJobFrequency());
|
||||
|
||||
// CRM-17686
|
||||
$this->add('datepicker', 'scheduled_run_date', ts('Scheduled Run Date'), NULL, FALSE, array('minDate' => time()));
|
||||
|
||||
$this->add('textarea', 'parameters', ts('Command parameters'),
|
||||
"cols=50 rows=6"
|
||||
);
|
||||
|
||||
// is this job active ?
|
||||
$this->add('checkbox', 'is_active', ts('Is this Scheduled Job active?'));
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_Job', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
*
|
||||
* @return array|bool
|
||||
* @throws API_Exception
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
|
||||
$errors = array();
|
||||
|
||||
require_once 'api/api.php';
|
||||
|
||||
/** @var \Civi\API\Kernel $apiKernel */
|
||||
$apiKernel = \Civi::service('civi_api_kernel');
|
||||
$apiRequest = \Civi\API\Request::create($fields['api_entity'], $fields['api_action'], array('version' => 3), NULL);
|
||||
try {
|
||||
$apiKernel->resolve($apiRequest);
|
||||
}
|
||||
catch (\Civi\API\Exception\NotImplementedException $e) {
|
||||
$errors['api_action'] = ts('Given API command is not defined.');
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
if (!$this->_id) {
|
||||
$defaults['is_active'] = $defaults['is_default'] = 1;
|
||||
return $defaults;
|
||||
}
|
||||
$domainID = CRM_Core_Config::domainID();
|
||||
|
||||
$dao = new CRM_Core_DAO_Job();
|
||||
$dao->id = $this->_id;
|
||||
$dao->domain_id = $domainID;
|
||||
if (!$dao->find(TRUE)) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
CRM_Core_DAO::storeValues($dao, $defaults);
|
||||
|
||||
// CRM-17686
|
||||
if (!empty($dao->scheduled_run_date)) {
|
||||
$ts = strtotime($dao->scheduled_run_date);
|
||||
$defaults['scheduled_run_date'] = date("Y-m-d H:i:s", $ts);
|
||||
}
|
||||
|
||||
// CRM-10708
|
||||
// job entity thats shipped with core is all lower case.
|
||||
// this makes sure camel casing is followed for proper working of default population.
|
||||
if (!empty($defaults['api_entity'])) {
|
||||
$defaults['api_entity'] = ucfirst($defaults['api_entity']);
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
|
||||
CRM_Utils_System::flushCache('CRM_Core_DAO_Job');
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Core_BAO_Job::del($this->_id);
|
||||
CRM_Core_Session::setStatus("", ts('Scheduled Job Deleted.'), "success");
|
||||
return;
|
||||
}
|
||||
|
||||
$values = $this->controller->exportValues($this->_name);
|
||||
$domainID = CRM_Core_Config::domainID();
|
||||
|
||||
$dao = new CRM_Core_DAO_Job();
|
||||
|
||||
$dao->id = $this->_id;
|
||||
$dao->domain_id = $domainID;
|
||||
$dao->run_frequency = $values['run_frequency'];
|
||||
$dao->parameters = $values['parameters'];
|
||||
$dao->name = $values['name'];
|
||||
$dao->api_entity = $values['api_entity'];
|
||||
$dao->api_action = $values['api_action'];
|
||||
$dao->description = $values['description'];
|
||||
$dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
|
||||
|
||||
// CRM-17686
|
||||
$ts = strtotime($values['scheduled_run_date']);
|
||||
// if a date/time is supplied and not in the past, then set the next scheduled run...
|
||||
if ($ts > time()) {
|
||||
$dao->scheduled_run_date = CRM_Utils_Date::currentDBDate($ts);
|
||||
// warn about monthly/quarterly scheduling, if applicable
|
||||
if (($dao->run_frequency == 'Monthly') || ($dao->run_frequency == 'Quarter')) {
|
||||
$info = getdate($ts);
|
||||
if ($info['mday'] > 28) {
|
||||
CRM_Core_Session::setStatus(
|
||||
ts('Relative month values are calculated based on the length of month(s) that they pass through.
|
||||
The result will land on the same day of the month except for days 29-31 when the target month contains fewer days than the previous month.
|
||||
For example, if a job is scheduled to run on August 31st, the following invocation will occur on October 1st, and then the 1st of every month thereafter.
|
||||
To avoid this issue, please schedule Monthly and Quarterly jobs to run within the first 28 days of the month.'),
|
||||
ts('Warning'), 'info', array('expires' => 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
// ...otherwise, if this isn't a new scheduled job, clear the next scheduled run
|
||||
elseif ($dao->id) {
|
||||
$job = new CRM_Core_ScheduledJob(array('id' => $dao->id));
|
||||
$job->clearScheduledRunDate();
|
||||
}
|
||||
|
||||
$dao->save();
|
||||
|
||||
// CRM-11143 - Give warning message if update_greetings is Enabled (is_active) since it generally should not be run automatically via execute action or runjobs url.
|
||||
if ($values['api_action'] == 'update_greeting' && CRM_Utils_Array::value('is_active', $values) == 1) {
|
||||
// pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
|
||||
$docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
|
||||
$msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', array(1 => $docLink));
|
||||
CRM_Core_Session::setStatus($msg, ts('Warning: Update Greeting job enabled'), 'alert');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
250
sites/all/modules/civicrm/CRM/Admin/Form/LabelFormats.php
Normal file
250
sites/all/modules/civicrm/CRM/Admin/Form/LabelFormats.php
Normal file
|
@ -0,0 +1,250 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright (C) 2011 Marty Wright |
|
||||
| Licensed to CiviCRM under the Academic Free License version 3.0. |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Label Format Settings.
|
||||
*/
|
||||
class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Label Format ID.
|
||||
*/
|
||||
protected $_id = NULL;
|
||||
|
||||
/**
|
||||
* Group name, label format or name badge
|
||||
*/
|
||||
protected $_group = NULL;
|
||||
|
||||
public function preProcess() {
|
||||
$this->_id = $this->get('id');
|
||||
$this->_group = CRM_Utils_Request::retrieve('group', 'String', $this, FALSE, 'label_format');
|
||||
$this->_values = array();
|
||||
if (isset($this->_id)) {
|
||||
$params = array('id' => $this->_id);
|
||||
CRM_Core_BAO_LabelFormat::retrieve($params, $this->_values, $this->_group);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::COPY)) {
|
||||
$formatName = CRM_Core_BAO_LabelFormat::getFieldValue('CRM_Core_BAO_LabelFormat', $this->_id, 'label');
|
||||
$this->assign('formatName', $formatName);
|
||||
return;
|
||||
}
|
||||
|
||||
$disabled = array();
|
||||
$required = TRUE;
|
||||
$is_reserved = $this->_id ? CRM_Core_BAO_LabelFormat::getFieldValue('CRM_Core_BAO_LabelFormat', $this->_id, 'is_reserved') : FALSE;
|
||||
if ($is_reserved) {
|
||||
$disabled['disabled'] = 'disabled';
|
||||
$required = FALSE;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat');
|
||||
$this->add('text', 'label', ts('Name'), $attributes['label'] + $disabled, $required);
|
||||
$this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE));
|
||||
$this->add('checkbox', 'is_default', ts('Is this Label Format the default?'));
|
||||
|
||||
// currently we support only mailing label creation, hence comment below code
|
||||
/*
|
||||
$options = array(
|
||||
'label_format' => ts('Mailing Label'),
|
||||
'name_badge' => ts('Name Badge'),
|
||||
);
|
||||
|
||||
$labelType = $this->addRadio('label_type', ts('Used For'), $options, null, ' ');
|
||||
|
||||
if ($this->_action != CRM_Core_Action::ADD) {
|
||||
$labelType->freeze();
|
||||
}
|
||||
*/
|
||||
|
||||
$this->add('select', 'paper_size', ts('Sheet Size'),
|
||||
array(
|
||||
0 => ts('- default -'),
|
||||
) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE,
|
||||
array(
|
||||
'onChange' => "selectPaper( this.value );",
|
||||
) + $disabled
|
||||
);
|
||||
$this->add('static', 'paper_dimensions', NULL, ts('Sheet Size (w x h)'));
|
||||
$this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_LabelFormat::getPageOrientations(), FALSE,
|
||||
array(
|
||||
'onChange' => "updatePaperDimensions();",
|
||||
) + $disabled
|
||||
);
|
||||
$this->add('select', 'font_name', ts('Font Name'), CRM_Core_BAO_LabelFormat::getFontNames($this->_group));
|
||||
$this->add('select', 'font_size', ts('Font Size'), CRM_Core_BAO_LabelFormat::getFontSizes());
|
||||
$this->add('static', 'font_style', ts('Font Style'));
|
||||
$this->add('checkbox', 'bold', ts('Bold'));
|
||||
$this->add('checkbox', 'italic', ts('Italic'));
|
||||
$this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_LabelFormat::getUnits(), FALSE,
|
||||
array('onChange' => "selectMetric( this.value );")
|
||||
);
|
||||
$this->add('text', 'width', ts('Label Width'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
|
||||
$this->add('text', 'height', ts('Label Height'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
|
||||
$this->add('text', 'NX', ts('Labels Per Row'), array('size' => 3, 'maxlength' => 3) + $disabled, $required);
|
||||
$this->add('text', 'NY', ts('Labels Per Column'), array('size' => 3, 'maxlength' => 3) + $disabled, $required);
|
||||
$this->add('text', 'tMargin', ts('Top Margin'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
|
||||
$this->add('text', 'lMargin', ts('Left Margin'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
|
||||
$this->add('text', 'SpaceX', ts('Horizontal Spacing'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
|
||||
$this->add('text', 'SpaceY', ts('Vertical Spacing'), array('size' => 8, 'maxlength' => 8) + $disabled, $required);
|
||||
$this->add('text', 'lPadding', ts('Left Padding'), array('size' => 8, 'maxlength' => 8), $required);
|
||||
$this->add('text', 'tPadding', ts('Top Padding'), array('size' => 8, 'maxlength' => 8), $required);
|
||||
$this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat', 'weight'), TRUE);
|
||||
|
||||
$this->addRule('label', ts('Name already exists in Database.'), 'objectExists', array(
|
||||
'CRM_Core_BAO_LabelFormat',
|
||||
$this->_id,
|
||||
));
|
||||
$this->addRule('NX', ts('Please enter a valid integer.'), 'integer');
|
||||
$this->addRule('NY', ts('Please enter a valid integer.'), 'integer');
|
||||
$this->addRule('tMargin', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('lMargin', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('SpaceX', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('SpaceY', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('lPadding', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('tPadding', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('width', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('height', ts('Please enter a valid number.'), 'numeric');
|
||||
$this->addRule('weight', ts('Please enter a valid integer.'), 'integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
$defaults['weight'] = CRM_Utils_Array::value('weight', CRM_Core_BAO_LabelFormat::getDefaultValues($this->_group), 0);
|
||||
}
|
||||
else {
|
||||
$defaults = $this->_values;
|
||||
// Convert field names that are illegal PHP/SMARTY variable names
|
||||
$defaults['paper_size'] = $defaults['paper-size'];
|
||||
unset($defaults['paper-size']);
|
||||
$defaults['font_name'] = $defaults['font-name'];
|
||||
unset($defaults['font-name']);
|
||||
$defaults['font_size'] = $defaults['font-size'];
|
||||
unset($defaults['font-size']);
|
||||
|
||||
$defaults['bold'] = (stripos($defaults['font-style'], 'B') !== FALSE);
|
||||
$defaults['italic'] = (stripos($defaults['font-style'], 'I') !== FALSE);
|
||||
unset($defaults['font-style']);
|
||||
}
|
||||
|
||||
$defaults['label_type'] = $this->_group;
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
// delete Label Format
|
||||
CRM_Core_BAO_LabelFormat::del($this->_id, $this->_group);
|
||||
CRM_Core_Session::setStatus(ts('Selected Label Format has been deleted.'), ts('Record Deleted'), 'success');
|
||||
return;
|
||||
}
|
||||
if ($this->_action & CRM_Core_Action::COPY) {
|
||||
// make a copy of the Label Format
|
||||
$labelFormat = CRM_Core_BAO_LabelFormat::getById($this->_id, $this->_group);
|
||||
$newlabel = ts('Copy of %1', array(1 => $labelFormat['label']));
|
||||
|
||||
$list = CRM_Core_BAO_LabelFormat::getList(TRUE, $this->_group);
|
||||
$count = 1;
|
||||
|
||||
while (in_array($newlabel, $list)) {
|
||||
$count++;
|
||||
$newlabel = ts('Copy %1 of %2', array(1 => $count, 2 => $labelFormat['label']));
|
||||
}
|
||||
|
||||
$labelFormat['label'] = $newlabel;
|
||||
$labelFormat['grouping'] = CRM_Core_BAO_LabelFormat::customGroupName();
|
||||
$labelFormat['is_default'] = 0;
|
||||
$labelFormat['is_reserved'] = 0;
|
||||
|
||||
$bao = new CRM_Core_BAO_LabelFormat();
|
||||
$bao->saveLabelFormat($labelFormat, NULL, $this->_group);
|
||||
CRM_Core_Session::setStatus(ts('%1 has been created.', array(1 => $labelFormat['label'])), ts('Saved'), 'success');
|
||||
return;
|
||||
}
|
||||
|
||||
$values = $this->controller->exportValues($this->getName());
|
||||
|
||||
// since we currently support only mailing label format
|
||||
$values['label_type'] = 'label_format';
|
||||
|
||||
$values['is_default'] = isset($values['is_default']);
|
||||
|
||||
// Restore field names that were converted because they are illegal PHP/SMARTY variable names
|
||||
if (isset($values['paper_size'])) {
|
||||
$values['paper-size'] = $values['paper_size'];
|
||||
unset($values['paper_size']);
|
||||
}
|
||||
if (isset($values['font_name'])) {
|
||||
$values['font-name'] = $values['font_name'];
|
||||
unset($values['font_name']);
|
||||
}
|
||||
if (isset($values['font_size'])) {
|
||||
$values['font-size'] = $values['font_size'];
|
||||
unset($values['font_size']);
|
||||
}
|
||||
|
||||
$style = '';
|
||||
if (isset($values['bold'])) {
|
||||
$style .= 'B';
|
||||
}
|
||||
if (isset($values['italic'])) {
|
||||
$style .= 'I';
|
||||
}
|
||||
$values['font-style'] = $style;
|
||||
|
||||
$bao = new CRM_Core_BAO_LabelFormat();
|
||||
$bao->saveLabelFormat($values, $this->_id, $values['label_type']);
|
||||
|
||||
$status = ts('Your new Label Format titled <strong>%1</strong> has been saved.', array(1 => $values['label']));
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$status = ts('Your Label Format titled <strong>%1</strong> has been updated.', array(1 => $values['label']));
|
||||
}
|
||||
CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
}
|
127
sites/all/modules/civicrm/CRM/Admin/Form/LocationType.php
Normal file
127
sites/all/modules/civicrm/CRM/Admin/Form/LocationType.php
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Location Type.
|
||||
*/
|
||||
class CRM_Admin_Form_LocationType extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->setPageTitle(ts('Location Type'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
$this->add('text',
|
||||
'name',
|
||||
ts('Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'name'),
|
||||
TRUE
|
||||
);
|
||||
$this->addRule('name',
|
||||
ts('Name already exists in Database.'),
|
||||
'objectExists',
|
||||
array('CRM_Core_DAO_LocationType', $this->_id)
|
||||
);
|
||||
$this->addRule('name',
|
||||
ts('Name can only consist of alpha-numeric characters'),
|
||||
'variable'
|
||||
);
|
||||
|
||||
$this->add('text', 'display_name', ts('Display Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'display_name'), TRUE);
|
||||
$this->add('text', 'vcard_name', ts('vCard Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'vcard_name'));
|
||||
|
||||
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'description'));
|
||||
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
$this->add('checkbox', 'is_default', ts('Default?'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_reserved')) {
|
||||
$this->freeze(array('name', 'description', 'is_active'));
|
||||
}
|
||||
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_default')) {
|
||||
$this->freeze(array('is_default'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Utils_System::flushCache('CRM_Core_DAO_LocationType');
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Core_BAO_LocationType::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected Location type has been deleted.'), ts('Record Deleted'), 'success');
|
||||
return;
|
||||
}
|
||||
|
||||
// store the submitted values in an array
|
||||
$params = $this->exportValues();
|
||||
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
|
||||
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
|
||||
|
||||
// action is taken depending upon the mode
|
||||
$locationType = new CRM_Core_DAO_LocationType();
|
||||
$locationType->name = $params['name'];
|
||||
$locationType->display_name = $params['display_name'];
|
||||
$locationType->vcard_name = $params['vcard_name'];
|
||||
$locationType->description = $params['description'];
|
||||
$locationType->is_active = $params['is_active'];
|
||||
$locationType->is_default = $params['is_default'];
|
||||
|
||||
if ($params['is_default']) {
|
||||
$query = "UPDATE civicrm_location_type SET is_default = 0";
|
||||
CRM_Core_DAO::executeQuery($query);
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$locationType->id = $this->_id;
|
||||
}
|
||||
|
||||
$locationType->save();
|
||||
|
||||
CRM_Core_Session::setStatus(ts("The location type '%1' has been saved.",
|
||||
array(1 => $locationType->name)
|
||||
), ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
}
|
199
sites/all/modules/civicrm/CRM/Admin/Form/MailSettings.php
Normal file
199
sites/all/modules/civicrm/CRM/Admin/Form/MailSettings.php
Normal file
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class handles mail account settings.
|
||||
*
|
||||
*/
|
||||
class CRM_Admin_Form_MailSettings extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->setPageTitle(ts('Mail Account'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
|
||||
//get the attributes.
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_MailSettings');
|
||||
|
||||
//build setting form
|
||||
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
|
||||
|
||||
$this->add('text', 'domain', ts('Email Domain'), $attributes['domain'], TRUE);
|
||||
$this->addRule('domain', ts('Email domain must use a valid internet domain format (e.g. \'example.org\').'), 'domain');
|
||||
|
||||
$this->add('text', 'localpart', ts('Localpart'), $attributes['localpart']);
|
||||
|
||||
$this->add('text', 'return_path', ts('Return-Path'), $attributes['return_path']);
|
||||
$this->addRule('return_path', ts('Return-Path must use a valid email address format.'), 'email');
|
||||
|
||||
$this->add('select', 'protocol',
|
||||
ts('Protocol'),
|
||||
array('' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'),
|
||||
TRUE
|
||||
);
|
||||
|
||||
$this->add('text', 'server', ts('Server'), $attributes['server']);
|
||||
|
||||
$this->add('text', 'username', ts('Username'), array('autocomplete' => 'off'));
|
||||
|
||||
$this->add('password', 'password', ts('Password'), array('autocomplete' => 'off'));
|
||||
|
||||
$this->add('text', 'source', ts('Source'), $attributes['source']);
|
||||
|
||||
$this->add('checkbox', 'is_ssl', ts('Use SSL?'));
|
||||
|
||||
$usedfor = array(
|
||||
1 => ts('Bounce Processing'),
|
||||
0 => ts('Email-to-Activity Processing'),
|
||||
);
|
||||
$this->add('select', 'is_default', ts('Used For?'), $usedfor);
|
||||
$this->addField('activity_status', array('placeholder' => FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add local and global form rules.
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Admin_Form_MailSettings', 'formRule'));
|
||||
}
|
||||
|
||||
public function getDefaultEntity() {
|
||||
return 'MailSettings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add local and global form rules.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
|
||||
// Set activity status to "Completed" by default.
|
||||
if ($this->_action != CRM_Core_Action::DELETE &&
|
||||
(!$this->_id || !CRM_Core_DAO::getFieldValue('CRM_Core_BAO_MailSettings', $this->_id, 'activity_status'))
|
||||
) {
|
||||
$defaults['activity_status'] = 'Completed';
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $fields
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* list of errors to be posted back to the form
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
$errors = array();
|
||||
// Check for default from email address and organization (domain) name. Force them to change it.
|
||||
if ($fields['domain'] == 'EXAMPLE.ORG') {
|
||||
$errors['domain'] = ts('Please enter a valid domain for this mailbox account (the part after @).');
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Core_BAO_MailSettings::deleteMailSettings($this->_id);
|
||||
CRM_Core_Session::setStatus("", ts('Mail Setting Deleted.'), "success");
|
||||
return;
|
||||
}
|
||||
|
||||
//get the submitted form values.
|
||||
$formValues = $this->controller->exportValues($this->_name);
|
||||
|
||||
//form fields.
|
||||
$fields = array(
|
||||
'name',
|
||||
'domain',
|
||||
'localpart',
|
||||
'server',
|
||||
'return_path',
|
||||
'protocol',
|
||||
'port',
|
||||
'username',
|
||||
'password',
|
||||
'source',
|
||||
'is_ssl',
|
||||
'is_default',
|
||||
'activity_status',
|
||||
);
|
||||
|
||||
$params = array();
|
||||
foreach ($fields as $f) {
|
||||
if (in_array($f, array(
|
||||
'is_default',
|
||||
'is_ssl',
|
||||
))) {
|
||||
$params[$f] = CRM_Utils_Array::value($f, $formValues, FALSE);
|
||||
}
|
||||
else {
|
||||
$params[$f] = CRM_Utils_Array::value($f, $formValues);
|
||||
}
|
||||
}
|
||||
|
||||
$params['domain_id'] = CRM_Core_Config::domainID();
|
||||
|
||||
// assign id only in update mode
|
||||
$status = ts('Your New Email Settings have been saved.');
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$params['id'] = $this->_id;
|
||||
$status = ts('Your Email Settings have been updated.');
|
||||
}
|
||||
|
||||
$mailSettings = CRM_Core_BAO_MailSettings::create($params);
|
||||
|
||||
if ($mailSettings->id) {
|
||||
CRM_Core_Session::setStatus($status, ts("Saved"), "success");
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus("", ts('Changes Not Saved.'), "info");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
110
sites/all/modules/civicrm/CRM/Admin/Form/Mapping.php
Normal file
110
sites/all/modules/civicrm/CRM/Admin/Form/Mapping.php
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Mapping.
|
||||
*/
|
||||
class CRM_Admin_Form_Mapping extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$mapping = new CRM_Core_DAO_Mapping();
|
||||
$mapping->id = $this->_id;
|
||||
$mapping->find(TRUE);
|
||||
$this->assign('mappingName', $mapping->name);
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->setPageTitle(ts('Field Mapping'));
|
||||
|
||||
if ($this->_action == CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
|
||||
$this->add('text', 'name', ts('Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'name'), TRUE
|
||||
);
|
||||
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
|
||||
'CRM_Core_DAO_Mapping',
|
||||
$this->_id,
|
||||
));
|
||||
|
||||
$this->addElement('text', 'description', ts('Description'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'description')
|
||||
);
|
||||
|
||||
$mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id'));
|
||||
|
||||
if ($this->_action == CRM_Core_Action::UPDATE) {
|
||||
$mappingType->freeze();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// store the submitted values in an array
|
||||
$params = $this->exportValues();
|
||||
|
||||
if ($this->_action == CRM_Core_Action::DELETE) {
|
||||
if ($this->_id) {
|
||||
CRM_Core_BAO_Mapping::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected mapping has been deleted successfully.'), ts('Deleted'), 'success');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->_id) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
CRM_Core_BAO_Mapping::add($params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
304
sites/all/modules/civicrm/CRM/Admin/Form/MessageTemplates.php
Normal file
304
sites/all/modules/civicrm/CRM/Admin/Form/MessageTemplates.php
Normal file
|
@ -0,0 +1,304 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Message templates
|
||||
* used by membership, contributions, event registrations, etc.
|
||||
*/
|
||||
class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form {
|
||||
// which (and whether) mailing workflow this template belongs to
|
||||
protected $_workflow_id = NULL;
|
||||
|
||||
// Is document file is already loaded as default value?
|
||||
protected $_is_document = FALSE;
|
||||
|
||||
public function preProcess() {
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String',
|
||||
$this, FALSE, 'add'
|
||||
);
|
||||
$this->assign('action', $this->_action);
|
||||
|
||||
$this->_BAOName = 'CRM_Core_BAO_MessageTemplate';
|
||||
$this->set('BAOName', $this->_BAOName);
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*
|
||||
* The default values are retrieved from the database.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = $this->_values;
|
||||
|
||||
if (empty($defaults['pdf_format_id'])) {
|
||||
$defaults['pdf_format_id'] = 'null';
|
||||
}
|
||||
if (empty($defaults['file_type'])) {
|
||||
$defaults['file_type'] = 0;
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
$defaults['is_active'] = 1;
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $this->_id, TRUE);
|
||||
if (!empty($documentInfo)) {
|
||||
$defaults['file_type'] = 1;
|
||||
$this->_is_document = TRUE;
|
||||
$this->assign('attachment', $documentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// For VIEW we only want Done button
|
||||
if ($this->_action & CRM_Core_Action::VIEW) {
|
||||
// currently, the above action is used solely for previewing default workflow templates
|
||||
$cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1');
|
||||
$cancelURL = str_replace('&', '&', $cancelURL);
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Done'),
|
||||
'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
$this->_workflow_id = CRM_Utils_Array::value('workflow_id', $this->_values);
|
||||
$this->assign('workflow_id', $this->_workflow_id);
|
||||
|
||||
if ($this->_workflow_id) {
|
||||
$selectedChild = 'workflow';
|
||||
}
|
||||
else {
|
||||
$selectedChild = 'user';
|
||||
}
|
||||
|
||||
$cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', "selectedChild={$selectedChild}&reset=1");
|
||||
$cancelURL = str_replace('&', '&', $cancelURL);
|
||||
$buttons[] = array(
|
||||
'type' => 'upload',
|
||||
'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
);
|
||||
if (!($this->_action & CRM_Core_Action::DELETE)) {
|
||||
$buttons[] = array(
|
||||
'type' => 'submit',
|
||||
'name' => ts('Save and Done'),
|
||||
'subName' => 'done',
|
||||
);
|
||||
}
|
||||
$buttons[] = array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"),
|
||||
);
|
||||
$this->addButtons($buttons);
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Message Templates'),
|
||||
'url' => CRM_Utils_System::url('civicrm/admin/messageTemplates',
|
||||
'action=browse&reset=1'
|
||||
),
|
||||
),
|
||||
);
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
$this->add('text', 'msg_title', ts('Message Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_MessageTemplate', 'msg_title'), TRUE);
|
||||
|
||||
$options = array(ts('Compose On-screen'), ts('Upload Document'));
|
||||
$element = $this->addRadio('file_type', ts('Source'), $options);
|
||||
if ($this->_id) {
|
||||
$element->freeze();
|
||||
}
|
||||
|
||||
$this->addElement('file', "file_id", ts('Upload Document'), 'size=30 maxlength=255');
|
||||
$this->addUploadElement("file_id");
|
||||
|
||||
$this->add('text', 'msg_subject',
|
||||
ts('Message Subject'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_MessageTemplate', 'msg_subject')
|
||||
);
|
||||
|
||||
//get the tokens.
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
|
||||
$this->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens));
|
||||
|
||||
// if not a system message use a wysiwyg editor, CRM-5971
|
||||
if ($this->_id &&
|
||||
CRM_Core_DAO::getFieldValue('CRM_Core_DAO_MessageTemplate',
|
||||
$this->_id,
|
||||
'workflow_id'
|
||||
)
|
||||
) {
|
||||
$this->add('textarea', 'msg_html', ts('HTML Message'),
|
||||
"cols=50 rows=6"
|
||||
);
|
||||
}
|
||||
else {
|
||||
$this->add('wysiwyg', 'msg_html', ts('HTML Message'),
|
||||
array(
|
||||
'cols' => '80',
|
||||
'rows' => '8',
|
||||
'onkeyup' => "return verify(this)",
|
||||
'preset' => 'civimail',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->add('textarea', 'msg_text', ts('Text Message'),
|
||||
"cols=50 rows=6"
|
||||
);
|
||||
|
||||
$this->add('select', 'pdf_format_id', ts('PDF Page Format'),
|
||||
array(
|
||||
'null' => ts('- default -'),
|
||||
) + CRM_Core_BAO_PdfFormat::getList(TRUE), FALSE
|
||||
);
|
||||
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
$this->addFormRule(array(__CLASS__, 'formRule'), $this);
|
||||
|
||||
if ($this->_action & CRM_Core_Action::VIEW) {
|
||||
$this->freeze();
|
||||
CRM_Utils_System::setTitle(ts('View System Default Message Template'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $params
|
||||
* The input form values.
|
||||
* @param array $files
|
||||
* The uploaded files if any.
|
||||
* @param array $self
|
||||
*
|
||||
* @return array
|
||||
* array of errors
|
||||
*/
|
||||
public static function formRule($params, $files, $self) {
|
||||
// If user uploads non-document file other than odt/docx
|
||||
if (!empty($files['file_id']['tmp_name']) &&
|
||||
array_search($files['file_id']['type'], CRM_Core_SelectValues::documentApplicationType()) == NULL
|
||||
) {
|
||||
$errors['file_id'] = ts('Invalid document file format');
|
||||
}
|
||||
// If default is not set and no document file is uploaded
|
||||
elseif (empty($files['file_id']['tmp_name']) && !empty($params['file_type']) && !$self->_is_document) {
|
||||
//On edit page of docx/odt message template if user changes file type but forgot to upload document
|
||||
$errors['file_id'] = ts('Please upload document');
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Core_BAO_MessageTemplate::del($this->_id);
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::VIEW) {
|
||||
// currently, the above action is used solely for previewing default workflow templates
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'));
|
||||
}
|
||||
else {
|
||||
// store the submitted values in an array
|
||||
$params = $this->controller->exportValues();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
if (!empty($params['file_type'])) {
|
||||
unset($params['msg_html']);
|
||||
unset($params['msg_text']);
|
||||
CRM_Utils_File::formatFile($params, 'file_id');
|
||||
}
|
||||
// delete related file references if html/text/pdf template are chosen over document
|
||||
elseif (!empty($this->_id)) {
|
||||
$entityFileDAO = new CRM_Core_DAO_EntityFile();
|
||||
$entityFileDAO->entity_id = $this->_id;
|
||||
$entityFileDAO->entity_table = 'civicrm_msg_template';
|
||||
if ($entityFileDAO->find(TRUE)) {
|
||||
$fileDAO = new CRM_Core_DAO_File();
|
||||
$fileDAO->id = $entityFileDAO->file_id;
|
||||
$fileDAO->find(TRUE);
|
||||
$entityFileDAO->delete();
|
||||
$fileDAO->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$this->_workflow_id = CRM_Utils_Array::value('workflow_id', $this->_values);
|
||||
if ($this->_workflow_id) {
|
||||
$params['workflow_id'] = $this->_workflow_id;
|
||||
$params['is_active'] = TRUE;
|
||||
}
|
||||
|
||||
$messageTemplate = CRM_Core_BAO_MessageTemplate::add($params);
|
||||
CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', array(1 => $messageTemplate->msg_title)), ts('Saved'), 'success');
|
||||
|
||||
if (isset($this->_submitValues['_qf_MessageTemplates_upload'])) {
|
||||
// Save button was pressed
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates/add', "action=update&id={$messageTemplate->id}&reset=1"));
|
||||
}
|
||||
// Save and done button was pressed
|
||||
if ($this->_workflow_id) {
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'));
|
||||
}
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=user&reset=1'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
154
sites/all/modules/civicrm/CRM/Admin/Form/Navigation.php
Normal file
154
sites/all/modules/civicrm/CRM/Admin/Form/Navigation.php
Normal file
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Navigation.
|
||||
*/
|
||||
class CRM_Admin_Form_Navigation extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* The parent id of the navigation menu.
|
||||
*/
|
||||
protected $_currentParentID = NULL;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
$this->setPageTitle(ts('Menu Item'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($this->_id)) {
|
||||
$params = array('id' => $this->_id);
|
||||
CRM_Core_BAO_Navigation::retrieve($params, $this->_defaults);
|
||||
}
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
$this->add('text',
|
||||
'label',
|
||||
ts('Title'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_Navigation', 'label'),
|
||||
TRUE
|
||||
);
|
||||
|
||||
$this->add('text', 'url', ts('Url'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Navigation', 'url'));
|
||||
|
||||
$this->add('text', 'icon', ts('Icon'), array('class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE));
|
||||
|
||||
$permissions = array();
|
||||
foreach (CRM_Core_Permission::basicPermissions(TRUE, TRUE) as $id => $vals) {
|
||||
$permissions[] = array('id' => $id, 'label' => $vals[0], 'description' => (array) CRM_Utils_Array::value(1, $vals));
|
||||
}
|
||||
$this->add('text', 'permission', ts('Permission'),
|
||||
array('placeholder' => ts('Unrestricted'), 'class' => 'huge', 'data-select-params' => json_encode(array('data' => array('results' => $permissions, 'text' => 'label'))))
|
||||
);
|
||||
|
||||
$operators = array('AND' => ts('AND'), 'OR' => ts('OR'));
|
||||
$this->add('select', 'permission_operator', NULL, $operators);
|
||||
|
||||
//make separator location configurable
|
||||
$separator = array(ts('None'), ts('After menu element'), ts('Before menu element'));
|
||||
$this->add('select', 'has_separator', ts('Separator'), $separator);
|
||||
|
||||
$active = $this->add('advcheckbox', 'is_active', ts('Enabled'));
|
||||
|
||||
if (CRM_Utils_Array::value('name', $this->_defaults) == 'Home') {
|
||||
$active->freeze();
|
||||
}
|
||||
else {
|
||||
$parentMenu = CRM_Core_BAO_Navigation::getNavigationList();
|
||||
|
||||
if (isset($this->_id)) {
|
||||
unset($parentMenu[$this->_id]);
|
||||
}
|
||||
|
||||
// also unset home.
|
||||
$homeMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Home', 'id', 'name');
|
||||
unset($parentMenu[$homeMenuId]);
|
||||
|
||||
$this->add('select', 'parent_id', ts('Parent'), array('' => ts('Top level')) + $parentMenu, FALSE, array('class' => 'crm-select2'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
if (isset($this->_id)) {
|
||||
//Take parent id in object variable to calculate the menu
|
||||
//weight if menu parent id changed
|
||||
$this->_currentParentID = CRM_Utils_Array::value('parent_id', $this->_defaults);
|
||||
}
|
||||
else {
|
||||
$defaults['permission'] = "access CiviCRM";
|
||||
}
|
||||
|
||||
// its ok if there is no element called is_active
|
||||
$defaults['is_active'] = ($this->_id) ? $this->_defaults['is_active'] : 1;
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// get the submitted form values.
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
if (isset($this->_id)) {
|
||||
$params['id'] = $this->_id;
|
||||
$params['current_parent_id'] = $this->_currentParentID;
|
||||
}
|
||||
|
||||
if (!empty($params['icon'])) {
|
||||
$params['icon'] = 'crm-i ' . $params['icon'];
|
||||
}
|
||||
|
||||
$navigation = CRM_Core_BAO_Navigation::add($params);
|
||||
|
||||
// also reset navigation
|
||||
CRM_Core_BAO_Navigation::resetNavigation();
|
||||
|
||||
CRM_Core_Session::setStatus(ts('Menu \'%1\' has been saved.',
|
||||
array(1 => $navigation->label)
|
||||
), ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
}
|
133
sites/all/modules/civicrm/CRM/Admin/Form/OptionGroup.php
Normal file
133
sites/all/modules/civicrm/CRM/Admin/Form/OptionGroup.php
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Option Group.
|
||||
*/
|
||||
class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Explicitly declare the entity api name.
|
||||
*/
|
||||
public function getDefaultEntity() {
|
||||
return 'OptionGroup';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
CRM_Utils_System::setTitle(ts('Dropdown Options'));
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
$this->add('text',
|
||||
'name',
|
||||
ts('Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'),
|
||||
TRUE
|
||||
);
|
||||
$this->addRule('name',
|
||||
ts('Name already exists in Database.'),
|
||||
'objectExists',
|
||||
array('CRM_Core_DAO_OptionGroup', $this->_id)
|
||||
);
|
||||
|
||||
$this->add('text',
|
||||
'title',
|
||||
ts('Group Title'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title')
|
||||
);
|
||||
|
||||
$this->add('text',
|
||||
'description',
|
||||
ts('Description'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description')
|
||||
);
|
||||
|
||||
$this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), TRUE);
|
||||
|
||||
$element = $this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
if (in_array($this->_values['name'], array(
|
||||
'encounter_medium',
|
||||
'case_type',
|
||||
'case_status',
|
||||
))) {
|
||||
static $caseCount = NULL;
|
||||
if (!isset($caseCount)) {
|
||||
$caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
|
||||
}
|
||||
|
||||
if ($caseCount > 0) {
|
||||
$element->freeze();
|
||||
}
|
||||
}
|
||||
if (!empty($this->_values['is_reserved'])) {
|
||||
$this->freeze(array('name', 'is_active'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('id', $this->_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Utils_System::flushCache();
|
||||
|
||||
$params = $this->exportValues();
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Core_BAO_OptionGroup::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected option group has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
|
||||
$params = $ids = array();
|
||||
// store the submitted values in an array
|
||||
$params = $this->exportValues();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$ids['optionGroup'] = $this->_id;
|
||||
}
|
||||
|
||||
$optionGroup = CRM_Core_BAO_OptionGroup::add($params, $ids);
|
||||
CRM_Core_Session::setStatus(ts('The Option Group \'%1\' has been saved.', array(1 => $optionGroup->name)), ts('Saved'), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
511
sites/all/modules/civicrm/CRM/Admin/Form/Options.php
Normal file
511
sites/all/modules/civicrm/CRM/Admin/Form/Options.php
Normal file
|
@ -0,0 +1,511 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Options.
|
||||
*/
|
||||
class CRM_Admin_Form_Options extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* The option group name.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_gName;
|
||||
|
||||
/**
|
||||
* The option group name in display format (capitalized, without underscores...etc)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_gLabel;
|
||||
|
||||
/**
|
||||
* Is this Option Group Domain Specific
|
||||
* @var bool
|
||||
*/
|
||||
protected $_domainSpecific = FALSE;
|
||||
|
||||
/**
|
||||
* Pre-process
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
if (!$this->_gName && !empty($this->urlPath[3])) {
|
||||
$this->_gName = $this->urlPath[3];
|
||||
}
|
||||
if (!$this->_gName && !empty($_GET['gid'])) {
|
||||
$this->_gName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', (int) $_GET['gid'], 'name');
|
||||
}
|
||||
if ($this->_gName) {
|
||||
$this->set('gName', $this->_gName);
|
||||
}
|
||||
else {
|
||||
$this->_gName = $this->get('gName');
|
||||
}
|
||||
$this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
|
||||
$this->_gName,
|
||||
'id',
|
||||
'name'
|
||||
);
|
||||
$this->_gLabel = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gid, 'title');
|
||||
$this->_domainSpecific = in_array($this->_gName, CRM_Core_OptionGroup::$_domainIDGroups);
|
||||
$url = "civicrm/admin/options/{$this->_gName}";
|
||||
$params = "reset=1";
|
||||
|
||||
if (($this->_action & CRM_Core_Action::DELETE) &&
|
||||
in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee'))
|
||||
) {
|
||||
// Don't allow delete if the option value belongs to addressee, postal or email greetings and is in use.
|
||||
$findValue = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'value');
|
||||
$queryParam = array(1 => array($findValue, 'Integer'));
|
||||
$columnName = $this->_gName . "_id";
|
||||
$sql = "SELECT count(id) FROM civicrm_contact WHERE " . $columnName . " = %1";
|
||||
$isInUse = CRM_Core_DAO::singleValueQuery($sql, $queryParam);
|
||||
if ($isInUse) {
|
||||
$scriptURL = "<a href='" . CRM_Utils_System::docURL2('Update Greetings and Address Data for Contacts', TRUE, NULL, NULL, NULL, "wiki") . "'>" . ts('Learn more about a script that can automatically update contact addressee and greeting options.') . "</a>";
|
||||
CRM_Core_Session::setStatus(ts('The selected %1 option has <strong>not been deleted</strong> because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', array(
|
||||
1 => $this->_gLabel,
|
||||
2 => $scriptURL,
|
||||
)), ts('Sorry'), 'error');
|
||||
$redirect = CRM_Utils_System::url($url, $params);
|
||||
CRM_Utils_System::redirect($redirect);
|
||||
}
|
||||
}
|
||||
|
||||
$session->pushUserContext(CRM_Utils_System::url($url, $params));
|
||||
$this->assign('id', $this->_id);
|
||||
|
||||
if ($this->_id && in_array($this->_gName, CRM_Core_OptionGroup::$_domainIDGroups)) {
|
||||
$domainID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'domain_id', 'id');
|
||||
if (CRM_Core_Config::domainID() != $domainID) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
|
||||
// Default weight & value
|
||||
$fieldValues = array('option_group_id' => $this->_gid);
|
||||
foreach (array('weight', 'value') as $field) {
|
||||
if (empty($defaults[$field])) {
|
||||
$defaults[$field] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, $field);
|
||||
}
|
||||
}
|
||||
|
||||
//setDefault of contact types for email greeting, postal greeting, addressee, CRM-4575
|
||||
if (in_array($this->_gName, array(
|
||||
'email_greeting',
|
||||
'postal_greeting',
|
||||
'addressee',
|
||||
))) {
|
||||
$defaults['contactOptions'] = (CRM_Utils_Array::value('filter', $defaults)) ? $defaults['filter'] : NULL;
|
||||
}
|
||||
// CRM-11516
|
||||
if ($this->_gName == 'payment_instrument' && $this->_id) {
|
||||
$defaults['financial_account_id'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($this->_id, NULL, 'civicrm_option_value');
|
||||
}
|
||||
if (empty($this->_id) || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'color')) {
|
||||
$defaults['color'] = '#ffffff';
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->setPageTitle(ts('%1 Option', array(1 => $this->_gLabel)));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
|
||||
$isReserved = FALSE;
|
||||
if ($this->_id) {
|
||||
$isReserved = (bool) CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'is_reserved');
|
||||
}
|
||||
|
||||
$this->add('text',
|
||||
'label',
|
||||
ts('Label'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'),
|
||||
TRUE
|
||||
);
|
||||
|
||||
if ($this->_gName != 'activity_type') {
|
||||
$this->add('text',
|
||||
'value',
|
||||
ts('Value'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'),
|
||||
TRUE
|
||||
);
|
||||
$this->addRule('value',
|
||||
ts('This Value already exists in the database for this option group. Please select a different Value.'),
|
||||
'optionExists',
|
||||
array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'value', $this->_domainSpecific)
|
||||
);
|
||||
}
|
||||
else {
|
||||
$this->add('text', 'icon', ts('Icon'), array('class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE));
|
||||
}
|
||||
|
||||
if (in_array($this->_gName, array('activity_status', 'case_status'))) {
|
||||
$this->add('color', 'color', ts('Color'));
|
||||
}
|
||||
|
||||
if (!in_array($this->_gName, array(
|
||||
'email_greeting',
|
||||
'postal_greeting',
|
||||
'addressee',
|
||||
)) && !$isReserved
|
||||
) {
|
||||
$this->addRule('label',
|
||||
ts('This Label already exists in the database for this option group. Please select a different Label.'),
|
||||
'optionExists',
|
||||
array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label', $this->_domainSpecific)
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->_gName == 'case_status') {
|
||||
$classes = array(
|
||||
'Opened' => ts('Opened'),
|
||||
'Closed' => ts('Closed'),
|
||||
);
|
||||
|
||||
$grouping = $this->add('select',
|
||||
'grouping',
|
||||
ts('Status Class'),
|
||||
$classes
|
||||
);
|
||||
if ($isReserved) {
|
||||
$grouping->freeze();
|
||||
}
|
||||
}
|
||||
// CRM-11516
|
||||
if ($this->_gName == 'payment_instrument') {
|
||||
$accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
|
||||
$financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
|
||||
|
||||
$this->add('select', 'financial_account_id', ts('Financial Account'),
|
||||
array('' => ts('- select -')) + $financialAccount,
|
||||
TRUE
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->_gName == 'activity_status') {
|
||||
$this->add('select',
|
||||
'filter',
|
||||
ts('Status Type'),
|
||||
array(
|
||||
CRM_Activity_BAO_Activity::INCOMPLETE => ts('Incomplete'),
|
||||
CRM_Activity_BAO_Activity::COMPLETED => ts('Completed'),
|
||||
CRM_Activity_BAO_Activity::CANCELLED => ts('Cancelled'),
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($this->_gName == 'redaction_rule') {
|
||||
$this->add('checkbox',
|
||||
'filter',
|
||||
ts('Regular Expression?')
|
||||
);
|
||||
}
|
||||
if ($this->_gName == 'participant_listing') {
|
||||
$this->add('text',
|
||||
'description',
|
||||
ts('Description'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description')
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Hard-coding attributes here since description is still stored as varchar and not text in the schema. dgg
|
||||
$this->add('wysiwyg', 'description',
|
||||
ts('Description'),
|
||||
array('rows' => 4, 'cols' => 80),
|
||||
$this->_gName == 'custom_search'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->_gName == 'event_badge') {
|
||||
$this->add('text',
|
||||
'name',
|
||||
ts('Class Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'name')
|
||||
);
|
||||
}
|
||||
|
||||
$this->add('text',
|
||||
'weight',
|
||||
ts('Order'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'),
|
||||
TRUE
|
||||
);
|
||||
$this->addRule('weight', ts('is a numeric field'), 'numeric');
|
||||
|
||||
// If CiviCase enabled AND "Add" mode OR "edit" mode for non-reserved activities, only allow user to pick Core or CiviCase component.
|
||||
// FIXME: Each component should define whether adding new activity types is allowed.
|
||||
$config = CRM_Core_Config::singleton();
|
||||
if ($this->_gName == 'activity_type' && in_array("CiviCase", $config->enableComponents) &&
|
||||
(($this->_action & CRM_Core_Action::ADD) || !$isReserved)
|
||||
) {
|
||||
$caseID = CRM_Core_Component::getComponentID('CiviCase');
|
||||
$components = array('' => ts('Contacts AND Cases'), $caseID => ts('Cases Only'));
|
||||
$this->add('select',
|
||||
'component_id',
|
||||
ts('Component'),
|
||||
$components, FALSE
|
||||
);
|
||||
}
|
||||
|
||||
$enabled = $this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
|
||||
if ($isReserved) {
|
||||
$enabled->freeze();
|
||||
}
|
||||
|
||||
//fix for CRM-3552, CRM-4575
|
||||
$showIsDefaultGroups = array(
|
||||
'email_greeting',
|
||||
'postal_greeting',
|
||||
'addressee',
|
||||
'from_email_address',
|
||||
'case_status',
|
||||
'encounter_medium',
|
||||
'case_type',
|
||||
'payment_instrument',
|
||||
'communication_style',
|
||||
'soft_credit_type',
|
||||
'website_type',
|
||||
);
|
||||
|
||||
if (in_array($this->_gName, $showIsDefaultGroups)) {
|
||||
$this->assign('showDefault', TRUE);
|
||||
$this->add('checkbox', 'is_default', ts('Default Option?'));
|
||||
}
|
||||
|
||||
//get contact type for which user want to create a new greeting/addressee type, CRM-4575
|
||||
if (in_array($this->_gName, array(
|
||||
'email_greeting',
|
||||
'postal_greeting',
|
||||
'addressee',
|
||||
)) && !$isReserved
|
||||
) {
|
||||
$values = array(
|
||||
1 => ts('Individual'),
|
||||
2 => ts('Household'),
|
||||
3 => ts('Organization'),
|
||||
4 => ts('Multiple Contact Merge'),
|
||||
);
|
||||
$this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, TRUE);
|
||||
$this->assign('showContactFilter', TRUE);
|
||||
}
|
||||
|
||||
if ($this->_gName == 'participant_status') {
|
||||
// For Participant Status options, expose the 'filter' field to track which statuses are "Counted", and the Visibility field
|
||||
$element = $this->add('checkbox', 'filter', ts('Counted?'));
|
||||
$this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
|
||||
}
|
||||
if ($this->_gName == 'participant_role') {
|
||||
// For Participant Role options, expose the 'filter' field to track which statuses are "Counted"
|
||||
$this->add('checkbox', 'filter', ts('Counted?'));
|
||||
}
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_Options', 'formRule'), $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
* @param array $files
|
||||
* The uploaded files if any.
|
||||
* @param array $self
|
||||
* Current form object.
|
||||
*
|
||||
* @return array
|
||||
* array of errors / empty array.
|
||||
*/
|
||||
public static function formRule($fields, $files, $self) {
|
||||
$errors = array();
|
||||
if ($self->_gName == 'case_status' && empty($fields['grouping'])) {
|
||||
$errors['grouping'] = ts('Status class is a required field');
|
||||
}
|
||||
|
||||
if (in_array($self->_gName, array(
|
||||
'email_greeting',
|
||||
'postal_greeting',
|
||||
'addressee',
|
||||
)) && empty($self->_defaultValues['is_reserved'])
|
||||
) {
|
||||
$label = $fields['label'];
|
||||
$condition = " AND v.label = '{$label}' ";
|
||||
$values = CRM_Core_OptionGroup::values($self->_gName, FALSE, FALSE, FALSE, $condition, 'filter');
|
||||
$checkContactOptions = TRUE;
|
||||
|
||||
if ($self->_id && ($self->_defaultValues['contactOptions'] == $fields['contactOptions'])) {
|
||||
$checkContactOptions = FALSE;
|
||||
}
|
||||
|
||||
if ($checkContactOptions && in_array($fields['contactOptions'], $values)) {
|
||||
$errors['label'] = ts('This Label already exists in the database for the selected contact type.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($self->_gName == 'from_email_address') {
|
||||
$formEmail = CRM_Utils_Mail::pluckEmailFromHeader($fields['label']);
|
||||
if (!CRM_Utils_Rule::email($formEmail)) {
|
||||
$errors['label'] = ts('Please enter a valid email address.');
|
||||
}
|
||||
|
||||
$formName = explode('"', $fields['label']);
|
||||
if (empty($formName[1]) || count($formName) != 3) {
|
||||
$errors['label'] = ts('Please follow the proper format for From Email Address');
|
||||
}
|
||||
}
|
||||
|
||||
$dataType = self::getOptionGroupDataType($self->_gName);
|
||||
if ($dataType && $self->_gName !== 'activity_type') {
|
||||
$validate = CRM_Utils_Type::validate($fields['value'], $dataType, FALSE);
|
||||
if (!$validate) {
|
||||
CRM_Core_Session::setStatus(
|
||||
ts('Data Type of the value field for this option value does not match ' . $dataType),
|
||||
ts('Value field Data Type mismatch'));
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DataType for a specified Option Group.
|
||||
*
|
||||
* @param string $optionGroupName name of the option group
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getOptionGroupDataType($optionGroupName) {
|
||||
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupName, 'id', 'name');
|
||||
|
||||
$dataType = CRM_Core_BAO_OptionGroup::getDataType($optionGroupId);
|
||||
return $dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
$fieldValues = array('option_group_id' => $this->_gid);
|
||||
$wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
|
||||
|
||||
if (CRM_Core_BAO_OptionValue::del($this->_id)) {
|
||||
if ($this->_gName == 'phone_type') {
|
||||
CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues));
|
||||
}
|
||||
|
||||
CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_gLabel)), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_gLabel)), ts('Sorry'), 'error');
|
||||
CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ids = array();
|
||||
$params = $this->exportValues();
|
||||
|
||||
// allow multiple defaults within group.
|
||||
$allowMultiDefaults = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address');
|
||||
if (in_array($this->_gName, $allowMultiDefaults)) {
|
||||
if ($this->_gName == 'from_email_address') {
|
||||
$params['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID());
|
||||
}
|
||||
elseif ($filter = CRM_Utils_Array::value('contactOptions', $params)) {
|
||||
$params['filter'] = $filter;
|
||||
$params['reset_default_for'] = array('filter' => "0, " . $params['filter']);
|
||||
}
|
||||
|
||||
//make sure we should has to have space, CRM-6977
|
||||
if ($this->_gName == 'from_email_address') {
|
||||
$params['label'] = str_replace('"<', '" <', $params['label']);
|
||||
}
|
||||
}
|
||||
|
||||
// set value of filter if not present in params
|
||||
if ($this->_id && !array_key_exists('filter', $params)) {
|
||||
if ($this->_gName == 'participant_role') {
|
||||
$params['filter'] = 0;
|
||||
}
|
||||
else {
|
||||
$params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['color']) && strtolower($params['color']) == '#ffffff') {
|
||||
$params['color'] = 'null';
|
||||
}
|
||||
|
||||
$groupParams = array('name' => ($this->_gName));
|
||||
$optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
|
||||
|
||||
// CRM-11516
|
||||
if (!empty($params['financial_account_id'])) {
|
||||
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
|
||||
$params = array(
|
||||
'entity_table' => 'civicrm_option_value',
|
||||
'entity_id' => $optionValue->id,
|
||||
'account_relationship' => $relationTypeId,
|
||||
'financial_account_id' => $params['financial_account_id'],
|
||||
);
|
||||
CRM_Financial_BAO_FinancialTypeAccount::add($params);
|
||||
}
|
||||
|
||||
CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(
|
||||
1 => $this->_gLabel,
|
||||
2 => $optionValue->label,
|
||||
)), ts('Saved'), 'success');
|
||||
|
||||
$this->ajaxResponse['optionValue'] = $optionValue->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Explicitly declare the entity api name.
|
||||
*/
|
||||
public function getDefaultEntity() {
|
||||
return 'ParticipantStatusType';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build form.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_ParticipantStatusType');
|
||||
|
||||
$this->add('text', 'name', ts('Name'), NULL, TRUE);
|
||||
|
||||
$this->add('text', 'label', ts('Label'), $attributes['label'], TRUE);
|
||||
|
||||
$this->addSelect('class', array('required' => TRUE));
|
||||
|
||||
$this->add('checkbox', 'is_active', ts('Active?'));
|
||||
$this->add('checkbox', 'is_counted', ts('Counted?'));
|
||||
|
||||
$this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
|
||||
|
||||
$this->addSelect('visibility_id', array('label' => ts('Visibility'), 'required' => TRUE));
|
||||
|
||||
$this->assign('id', $this->_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
if (empty($defaults['weight'])) {
|
||||
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Event_DAO_ParticipantStatusType');
|
||||
}
|
||||
$this->_isReserved = CRM_Utils_Array::value('is_reserved', $defaults);
|
||||
if ($this->_isReserved) {
|
||||
$this->freeze(array('name', 'class', 'is_active'));
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
if (CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($this->_id)) {
|
||||
CRM_Core_Session::setStatus(ts('Selected participant status has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts('Selected participant status has <strong>NOT</strong> been deleted; there are still participants with this status.'), ts('Sorry'), 'error');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$formValues = $this->controller->exportValues($this->_name);
|
||||
|
||||
$params = array(
|
||||
'name' => CRM_Utils_Array::value('name', $formValues),
|
||||
'label' => CRM_Utils_Array::value('label', $formValues),
|
||||
'class' => CRM_Utils_Array::value('class', $formValues),
|
||||
'is_active' => CRM_Utils_Array::value('is_active', $formValues, FALSE),
|
||||
'is_counted' => CRM_Utils_Array::value('is_counted', $formValues, FALSE),
|
||||
'weight' => CRM_Utils_Array::value('weight', $formValues),
|
||||
'visibility_id' => CRM_Utils_Array::value('visibility_id', $formValues),
|
||||
);
|
||||
|
||||
// make sure a malicious POST does not change these on reserved statuses
|
||||
if ($this->_isReserved) {
|
||||
unset($params['name'], $params['class'], $params['is_active']);
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
|
||||
$params['id'] = $this->_id;
|
||||
|
||||
}
|
||||
|
||||
if ($this->_id) {
|
||||
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantStatusType', $this->_id, 'weight', 'id');
|
||||
}
|
||||
else {
|
||||
$oldWeight = 0;
|
||||
}
|
||||
$params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Event_DAO_ParticipantStatusType', $oldWeight, $params['weight']);
|
||||
|
||||
$participantStatus = CRM_Event_BAO_ParticipantStatusType::create($params);
|
||||
|
||||
if ($participantStatus->id) {
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
CRM_Core_Session::setStatus(ts('The Participant Status has been updated.'), ts('Saved'), 'success');
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts('The new Participant Status has been saved.'), ts('Saved'), 'success');
|
||||
}
|
||||
}
|
||||
else {
|
||||
CRM_Core_Session::setStatus(ts('The changes have not been saved.'), ts('Saved'), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
436
sites/all/modules/civicrm/CRM/Admin/Form/PaymentProcessor.php
Normal file
436
sites/all/modules/civicrm/CRM/Admin/Form/PaymentProcessor.php
Normal file
|
@ -0,0 +1,436 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Payment Processor.
|
||||
*/
|
||||
class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
|
||||
protected $_id = NULL;
|
||||
|
||||
protected $_testID = NULL;
|
||||
|
||||
protected $_fields = NULL;
|
||||
|
||||
protected $_ppDAO;
|
||||
|
||||
/**
|
||||
* Get the name of the base entity being edited.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultEntity() {
|
||||
return 'PaymentProcessor';
|
||||
}
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
|
||||
if ($this->_id) {
|
||||
$this->_ppType = CRM_Utils_Request::retrieve('pp', 'String', $this, FALSE, NULL);
|
||||
if (!$this->_ppType) {
|
||||
$this->_ppType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor',
|
||||
$this->_id,
|
||||
'payment_processor_type_id'
|
||||
);
|
||||
}
|
||||
$this->set('pp', $this->_ppType);
|
||||
}
|
||||
else {
|
||||
$this->_ppType = CRM_Utils_Request::retrieve('pp', 'String', $this, TRUE, NULL);
|
||||
}
|
||||
|
||||
$this->assign('ppType', $this->_ppType);
|
||||
$ppTypeName = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType',
|
||||
$this->_ppType,
|
||||
'name'
|
||||
);
|
||||
$this->assign('ppTypeName', $ppTypeName);
|
||||
|
||||
$this->_ppDAO = new CRM_Financial_DAO_PaymentProcessorType();
|
||||
$this->_ppDAO->id = $this->_ppType;
|
||||
|
||||
$this->_ppDAO->find(TRUE);
|
||||
|
||||
if ($this->_id) {
|
||||
$refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor',
|
||||
"reset=1&action=update&id={$this->_id}",
|
||||
FALSE, NULL, FALSE
|
||||
);
|
||||
}
|
||||
else {
|
||||
$refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor',
|
||||
"reset=1&action=add",
|
||||
FALSE, NULL, FALSE
|
||||
);
|
||||
}
|
||||
|
||||
//CRM-4129
|
||||
$destination = CRM_Utils_Request::retrieve('civicrmDestination', 'String', $this);
|
||||
if ($destination) {
|
||||
$destination = urlencode($destination);
|
||||
$refreshURL .= "&civicrmDestination=$destination";
|
||||
}
|
||||
|
||||
$this->assign('refreshURL', $refreshURL);
|
||||
|
||||
$this->assign('is_recur', $this->_ppDAO->is_recur);
|
||||
|
||||
$this->_fields = array(
|
||||
array(
|
||||
'name' => 'user_name',
|
||||
'label' => $this->_ppDAO->user_name_label,
|
||||
),
|
||||
array(
|
||||
'name' => 'password',
|
||||
'label' => $this->_ppDAO->password_label,
|
||||
),
|
||||
array(
|
||||
'name' => 'signature',
|
||||
'label' => $this->_ppDAO->signature_label,
|
||||
),
|
||||
array(
|
||||
'name' => 'subject',
|
||||
'label' => $this->_ppDAO->subject_label,
|
||||
),
|
||||
array(
|
||||
'name' => 'url_site',
|
||||
'label' => ts('Site URL'),
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
);
|
||||
|
||||
if ($this->_ppDAO->is_recur) {
|
||||
$this->_fields[] = array(
|
||||
'name' => 'url_recur',
|
||||
'label' => ts('Recurring Payments URL'),
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($this->_ppDAO->url_button_default)) {
|
||||
$this->_fields[] = array(
|
||||
'name' => 'url_button',
|
||||
'label' => ts('Button URL'),
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($this->_ppDAO->url_api_default)) {
|
||||
$this->_fields[] = array(
|
||||
'name' => 'url_api',
|
||||
'label' => ts('API URL'),
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @param bool $check
|
||||
*/
|
||||
public function buildQuickForm($check = FALSE) {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_PaymentProcessor');
|
||||
|
||||
$this->add('text', 'name', ts('Name'),
|
||||
$attributes['name'], TRUE
|
||||
);
|
||||
|
||||
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
|
||||
'CRM_Financial_DAO_PaymentProcessor',
|
||||
$this->_id,
|
||||
'name',
|
||||
CRM_Core_Config::domainID(),
|
||||
));
|
||||
|
||||
$this->add('text', 'description', ts('Description'),
|
||||
$attributes['description']
|
||||
);
|
||||
|
||||
$types = CRM_Core_PseudoConstant::paymentProcessorType();
|
||||
$this->add('select', 'payment_processor_type_id', ts('Payment Processor Type'), $types, TRUE,
|
||||
array('onchange' => "reload(true)")
|
||||
);
|
||||
|
||||
// Financial Account of account type asset CRM-11515
|
||||
$accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
|
||||
$financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
|
||||
if ($fcount = count($financialAccount)) {
|
||||
$this->assign('financialAccount', $fcount);
|
||||
}
|
||||
$this->add('select', 'financial_account_id', ts('Financial Account'),
|
||||
array('' => ts('- select -')) + $financialAccount,
|
||||
TRUE
|
||||
);
|
||||
$this->addSelect('payment_instrument_id',
|
||||
array(
|
||||
'entity' => 'contribution',
|
||||
'label' => ts('Payment Method'),
|
||||
'placeholder' => NULL,
|
||||
)
|
||||
);
|
||||
|
||||
// is this processor active ?
|
||||
$this->add('checkbox', 'is_active', ts('Is this Payment Processor active?'));
|
||||
$this->add('checkbox', 'is_default', ts('Is this Payment Processor the default?'));
|
||||
$creditCardTypes = CRM_Contribute_PseudoConstant::creditCard();
|
||||
$this->addCheckBox('accept_credit_cards', ts('Accepted Credit Card Type(s)'),
|
||||
$creditCardTypes, NULL, NULL, NULL, NULL, ' ');
|
||||
foreach ($this->_fields as $field) {
|
||||
if (empty($field['label'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->addField($field['name'], array('label' => $field['label']));
|
||||
|
||||
$fieldSpec = civicrm_api3($this->getDefaultEntity(), 'getfield', array(
|
||||
'name' => $field['name'],
|
||||
'action' => 'create',
|
||||
));
|
||||
$this->add($fieldSpec['values']['html']['type'], "test_{$field['name']}",
|
||||
$field['label'], $attributes[$field['name']]
|
||||
);
|
||||
if (!empty($field['rule'])) {
|
||||
$this->addRule($field['name'], $field['msg'], $field['rule']);
|
||||
$this->addRule("test_{$field['name']}", $field['msg'], $field['rule']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_PaymentProcessor', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
|
||||
// make sure that at least one of live or test is present
|
||||
// and we have at least name and url_site
|
||||
// would be good to make this processor specific
|
||||
$errors = array();
|
||||
|
||||
if (!(self::checkSection($fields, $errors) ||
|
||||
self::checkSection($fields, $errors, 'test')
|
||||
)
|
||||
) {
|
||||
$errors['_qf_default'] = ts('You must have at least the test or live section filled');
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
* @param $errors
|
||||
* @param null $section
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkSection(&$fields, &$errors, $section = NULL) {
|
||||
$names = array('user_name');
|
||||
|
||||
$present = FALSE;
|
||||
$allPresent = TRUE;
|
||||
foreach ($names as $name) {
|
||||
if ($section) {
|
||||
$name = "{$section}_$name";
|
||||
}
|
||||
if (!empty($fields[$name])) {
|
||||
$present = TRUE;
|
||||
}
|
||||
else {
|
||||
$allPresent = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($present) {
|
||||
if (!$allPresent) {
|
||||
$errors['_qf_default'] = ts('You must have at least the user_name specified');
|
||||
}
|
||||
}
|
||||
return $present;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
if (!$this->_id) {
|
||||
$defaults['is_active'] = $defaults['is_default'] = 1;
|
||||
$defaults['url_site'] = $this->_ppDAO->url_site_default;
|
||||
$defaults['url_api'] = $this->_ppDAO->url_api_default;
|
||||
$defaults['url_recur'] = $this->_ppDAO->url_recur_default;
|
||||
$defaults['url_button'] = $this->_ppDAO->url_button_default;
|
||||
$defaults['test_url_site'] = $this->_ppDAO->url_site_test_default;
|
||||
$defaults['test_url_api'] = $this->_ppDAO->url_api_test_default;
|
||||
$defaults['test_url_recur'] = $this->_ppDAO->url_recur_test_default;
|
||||
$defaults['test_url_button'] = $this->_ppDAO->url_button_test_default;
|
||||
$defaults['payment_instrument_id'] = $this->_ppDAO->payment_instrument_id;
|
||||
// When user changes payment processor type, it is passed in via $this->_ppType so update defaults array.
|
||||
if ($this->_ppType) {
|
||||
$defaults['payment_processor_type_id'] = $this->_ppType;
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
$domainID = CRM_Core_Config::domainID();
|
||||
|
||||
$dao = new CRM_Financial_DAO_PaymentProcessor();
|
||||
$dao->id = $this->_id;
|
||||
$dao->domain_id = $domainID;
|
||||
if (!$dao->find(TRUE)) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
CRM_Core_DAO::storeValues($dao, $defaults);
|
||||
// When user changes payment processor type, it is passed in via $this->_ppType so update defaults array.
|
||||
if ($this->_ppType) {
|
||||
$defaults['payment_processor_type_id'] = $this->_ppType;
|
||||
}
|
||||
$cards = json_decode(CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor',
|
||||
$this->_id,
|
||||
'accepted_credit_cards'
|
||||
), TRUE);
|
||||
$acceptedCards = array();
|
||||
if (!empty($cards)) {
|
||||
foreach ($cards as $card => $val) {
|
||||
$acceptedCards[$card] = 1;
|
||||
}
|
||||
}
|
||||
$defaults['accept_credit_cards'] = $acceptedCards;
|
||||
unset($defaults['accepted_credit_cards']);
|
||||
// now get testID
|
||||
$testDAO = new CRM_Financial_DAO_PaymentProcessor();
|
||||
$testDAO->name = $dao->name;
|
||||
$testDAO->is_test = 1;
|
||||
$testDAO->domain_id = $domainID;
|
||||
if ($testDAO->find(TRUE)) {
|
||||
$this->_testID = $testDAO->id;
|
||||
|
||||
foreach ($this->_fields as $field) {
|
||||
$testName = "test_{$field['name']}";
|
||||
$defaults[$testName] = $testDAO->{$field['name']};
|
||||
}
|
||||
}
|
||||
$defaults['financial_account_id'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($dao->id, NULL, 'civicrm_payment_processor');
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Financial_BAO_PaymentProcessor::del($this->_id);
|
||||
CRM_Core_Session::setStatus("", ts('Payment Processor Deleted.'), "success");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$values = $this->controller->exportValues($this->_name);
|
||||
$domainID = CRM_Core_Config::domainID();
|
||||
|
||||
if (!empty($values['is_default'])) {
|
||||
$query = "UPDATE civicrm_payment_processor SET is_default = 0 WHERE domain_id = $domainID";
|
||||
CRM_Core_DAO::executeQuery($query);
|
||||
}
|
||||
|
||||
$this->updatePaymentProcessor($values, $domainID, FALSE);
|
||||
$this->updatePaymentProcessor($values, $domainID, TRUE);
|
||||
CRM_Core_Session::setStatus(ts('Payment processor %1 has been saved.', array(1 => "<em>{$values['name']}</em>")), ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a payment processor.
|
||||
*
|
||||
* @param array $values
|
||||
* @param int $domainID
|
||||
* @param bool $test
|
||||
*/
|
||||
public function updatePaymentProcessor(&$values, $domainID, $test) {
|
||||
if ($test) {
|
||||
foreach (array('user_name', 'password', 'signature', 'url_site', 'url_recur', 'url_api', 'url_button', 'subject') as $field) {
|
||||
$values[$field] = empty($values["test_{$field}"]) ? CRM_Utils_Array::value($field, $values) : $values["test_{$field}"];
|
||||
}
|
||||
}
|
||||
if (!empty($values['accept_credit_cards'])) {
|
||||
$creditCards = array();
|
||||
$accptedCards = array_keys($values['accept_credit_cards']);
|
||||
$creditCardTypes = CRM_Contribute_PseudoConstant::creditCard();
|
||||
foreach ($creditCardTypes as $type => $val) {
|
||||
if (in_array($type, $accptedCards)) {
|
||||
$creditCards[$type] = $creditCardTypes[$type];
|
||||
}
|
||||
}
|
||||
$creditCards = json_encode($creditCards);
|
||||
}
|
||||
else {
|
||||
$creditCards = "NULL";
|
||||
}
|
||||
$params = array_merge(array(
|
||||
'id' => $test ? $this->_testID : $this->_id,
|
||||
'domain_id' => $domainID,
|
||||
'is_test' => $test,
|
||||
'is_active' => 0,
|
||||
'is_default' => 0,
|
||||
'is_recur' => $this->_ppDAO->is_recur,
|
||||
'billing_mode' => $this->_ppDAO->billing_mode,
|
||||
'class_name' => $this->_ppDAO->class_name,
|
||||
'payment_type' => $this->_ppDAO->payment_type,
|
||||
'payment_instrument_id' => $this->_ppDAO->payment_instrument_id,
|
||||
'financial_account_id' => $values['financial_account_id'],
|
||||
'accepted_credit_cards' => $creditCards,
|
||||
), $values);
|
||||
|
||||
civicrm_api3('PaymentProcessor', 'create', $params);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Location Type.
|
||||
*/
|
||||
class CRM_Admin_Form_PaymentProcessorType extends CRM_Admin_Form {
|
||||
protected $_id = NULL;
|
||||
|
||||
protected $_fields = NULL;
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
|
||||
$this->_fields = array(
|
||||
array(
|
||||
'name' => 'name',
|
||||
'label' => ts('Name'),
|
||||
'required' => TRUE,
|
||||
),
|
||||
array(
|
||||
'name' => 'title',
|
||||
'label' => ts('Title'),
|
||||
'required' => TRUE,
|
||||
),
|
||||
array(
|
||||
'name' => 'billing_mode',
|
||||
'label' => ts('Billing Mode'),
|
||||
'required' => TRUE,
|
||||
'rule' => 'positiveInteger',
|
||||
'msg' => ts('Enter a positive integer'),
|
||||
),
|
||||
array(
|
||||
'name' => 'description',
|
||||
'label' => ts('Description'),
|
||||
),
|
||||
array(
|
||||
'name' => 'user_name_label',
|
||||
'label' => ts('User Name Label'),
|
||||
),
|
||||
array(
|
||||
'name' => 'password_label',
|
||||
'label' => ts('Password Label'),
|
||||
),
|
||||
array(
|
||||
'name' => 'signature_label',
|
||||
'label' => ts('Signature Label'),
|
||||
),
|
||||
array(
|
||||
'name' => 'subject_label',
|
||||
'label' => ts('Subject Label'),
|
||||
),
|
||||
array(
|
||||
'name' => 'class_name',
|
||||
'label' => ts('PHP class name'),
|
||||
'required' => TRUE,
|
||||
),
|
||||
array(
|
||||
'name' => 'url_site_default',
|
||||
'label' => ts('Live Site URL'),
|
||||
'required' => TRUE,
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
array(
|
||||
'name' => 'url_api_default',
|
||||
'label' => ts('Live API URL'),
|
||||
'required' => FALSE,
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
array(
|
||||
'name' => 'url_recur_default',
|
||||
'label' => ts('Live Recurring Payments URL'),
|
||||
'required' => TRUE,
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
array(
|
||||
'name' => 'url_button_default',
|
||||
'label' => ts('Live Button URL'),
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
array(
|
||||
'name' => 'url_site_test_default',
|
||||
'label' => ts('Test Site URL'),
|
||||
'required' => TRUE,
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
array(
|
||||
'name' => 'url_api_test_default',
|
||||
'label' => ts('Test API URL'),
|
||||
'required' => FALSE,
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
array(
|
||||
'name' => 'url_recur_test_default',
|
||||
'label' => ts('Test Recurring Payments URL'),
|
||||
'required' => TRUE,
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
array(
|
||||
'name' => 'url_button_test_default',
|
||||
'label' => ts('Test Button URL'),
|
||||
'rule' => 'url',
|
||||
'msg' => ts('Enter a valid URL'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*
|
||||
* @param bool $check
|
||||
*/
|
||||
public function buildQuickForm($check = FALSE) {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_PaymentProcessorType');
|
||||
|
||||
foreach ($this->_fields as $field) {
|
||||
$required = CRM_Utils_Array::value('required', $field, FALSE);
|
||||
$this->add('text', $field['name'],
|
||||
$field['label'], $attributes['name'], $required
|
||||
);
|
||||
if (!empty($field['rule'])) {
|
||||
$this->addRule($field['name'], $field['msg'], $field['rule']);
|
||||
}
|
||||
}
|
||||
|
||||
// is this processor active ?
|
||||
$this->add('checkbox', 'is_active', ts('Is this Payment Processor Type active?'));
|
||||
$this->add('checkbox', 'is_default', ts('Is this Payment Processor Type the default?'));
|
||||
$this->add('checkbox', 'is_recur', ts('Does this Payment Processor Type support recurring donations?'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
if (!$this->_id) {
|
||||
$defaults['is_active'] = $defaults['is_default'] = 1;
|
||||
$defaults['user_name_label'] = ts('User Name');
|
||||
$defaults['password_label'] = ts('Password');
|
||||
$defaults['signature_label'] = ts('Signature');
|
||||
$defaults['subject_label'] = ts('Subject');
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
$dao = new CRM_Financial_DAO_PaymentProcessorType();
|
||||
$dao->id = $this->_id;
|
||||
|
||||
if (!$dao->find(TRUE)) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
CRM_Core_DAO::storeValues($dao, $defaults);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_Utils_System::flushCache('CRM_Financial_DAO_PaymentProcessorType');
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Financial_BAO_PaymentProcessorType::del($this->_id);
|
||||
return;
|
||||
}
|
||||
|
||||
$values = $this->controller->exportValues($this->_name);
|
||||
|
||||
if (!empty($values['is_default'])) {
|
||||
$query = "
|
||||
UPDATE civicrm_payment_processor SET is_default = 0";
|
||||
CRM_Core_DAO::executeQuery($query);
|
||||
}
|
||||
|
||||
$dao = new CRM_Financial_DAO_PaymentProcessorType();
|
||||
|
||||
$dao->id = $this->_id;
|
||||
$dao->is_default = CRM_Utils_Array::value('is_default', $values, 0);
|
||||
$dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
|
||||
$dao->is_recur = CRM_Utils_Array::value('is_recur', $values, 0);
|
||||
|
||||
$dao->name = $values['name'];
|
||||
$dao->description = $values['description'];
|
||||
|
||||
foreach ($this->_fields as $field) {
|
||||
$dao->{$field['name']} = trim($values[$field['name']]);
|
||||
if (empty($dao->{$field['name']})) {
|
||||
$dao->{$field['name']} = 'null';
|
||||
}
|
||||
}
|
||||
$dao->save();
|
||||
}
|
||||
|
||||
}
|
129
sites/all/modules/civicrm/CRM/Admin/Form/PdfFormats.php
Normal file
129
sites/all/modules/civicrm/CRM/Admin/Form/PdfFormats.php
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright (C) 2011 Marty Wright |
|
||||
| Licensed to CiviCRM under the Academic Free License version 3.0. |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for PDF Page Format Settings.
|
||||
*/
|
||||
class CRM_Admin_Form_PdfFormats extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* PDF Page Format ID.
|
||||
*/
|
||||
protected $_id = NULL;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
$formatName = CRM_Core_BAO_PdfFormat::getFieldValue('CRM_Core_BAO_PdfFormat', $this->_id, 'name');
|
||||
$this->assign('formatName', $formatName);
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat');
|
||||
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
|
||||
$this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE));
|
||||
$this->add('checkbox', 'is_default', ts('Is this PDF Page Format the default?'));
|
||||
|
||||
$this->add('select', 'paper_size', ts('Paper Size'),
|
||||
array(
|
||||
0 => ts('- default -'),
|
||||
) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE,
|
||||
array('onChange' => "selectPaper( this.value );")
|
||||
);
|
||||
|
||||
$this->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
|
||||
$this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE,
|
||||
array('onChange' => "updatePaperDimensions();")
|
||||
);
|
||||
$this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE,
|
||||
array('onChange' => "selectMetric( this.value );")
|
||||
);
|
||||
$this->add('text', 'margin_left', ts('Left Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
|
||||
$this->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
|
||||
$this->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
|
||||
$this->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
|
||||
$this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE);
|
||||
|
||||
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
|
||||
'CRM_Core_BAO_PdfFormat',
|
||||
$this->_id,
|
||||
));
|
||||
$this->addRule('margin_left', ts('Margin must be numeric'), 'numeric');
|
||||
$this->addRule('margin_right', ts('Margin must be numeric'), 'numeric');
|
||||
$this->addRule('margin_top', ts('Margin must be numeric'), 'numeric');
|
||||
$this->addRule('margin_bottom', ts('Margin must be numeric'), 'numeric');
|
||||
$this->addRule('weight', ts('Weight must be integer'), 'integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
$defaults['weight'] = CRM_Utils_Array::value('weight', CRM_Core_BAO_PdfFormat::getDefaultValues(), 0);
|
||||
}
|
||||
else {
|
||||
$defaults = $this->_values;
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
// delete PDF Page Format
|
||||
CRM_Core_BAO_PdfFormat::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected PDF Page Format has been deleted.'), ts('Record Deleted'), 'success');
|
||||
return;
|
||||
}
|
||||
|
||||
$values = $this->controller->exportValues($this->getName());
|
||||
$values['is_default'] = isset($values['is_default']);
|
||||
$bao = new CRM_Core_BAO_PdfFormat();
|
||||
$bao->savePdfFormat($values, $this->_id);
|
||||
|
||||
$status = ts('Your new PDF Page Format titled <strong>%1</strong> has been saved.', array(1 => $values['name']), ts('Saved'), 'success');
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$status = ts('Your PDF Page Format titled <strong>%1</strong> has been updated.', array(1 => $values['name']), ts('Saved'), 'success');
|
||||
}
|
||||
CRM_Core_Session::setStatus($status);
|
||||
}
|
||||
|
||||
}
|
107
sites/all/modules/civicrm/CRM/Admin/Form/Persistent.php
Normal file
107
sites/all/modules/civicrm/CRM/Admin/Form/Persistent.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Customize the output to meet our specific requirements.
|
||||
*/
|
||||
class CRM_Admin_Form_Persistent extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Pre-process form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_indexID = CRM_Utils_Request::retrieve('id', 'Integer', $this, FALSE);
|
||||
$this->_config = CRM_Utils_Request::retrieve('config', 'Integer', $this, 0);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin/tplstrings', 'reset=1'));
|
||||
CRM_Utils_System::setTitle(ts('DB Template Strings'));
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
if ($this->_indexID && ($this->_action & (CRM_Core_Action::UPDATE))) {
|
||||
$params = array('id' => $this->_indexID);
|
||||
CRM_Core_BAO_Persistent::retrieve($params, $defaults);
|
||||
if (CRM_Utils_Array::value('is_config', $defaults) == 1) {
|
||||
$defaults['data'] = implode(',', $defaults['data']);
|
||||
}
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
$this->add('text', 'context', ts('Context:'), NULL, TRUE);
|
||||
$this->add('text', 'name', ts('Name:'), NULL, TRUE);
|
||||
$this->add('textarea', 'data', ts('Data:'), array('rows' => 4, 'cols' => 50), TRUE);
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'name' => ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$params = $ids = array();
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$params['is_config'] = $this->_config;
|
||||
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
CRM_Core_Session::setStatus(ts('DB Template has been added successfully.'), ts("Saved"), "success");
|
||||
}
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$ids['persistent'] = $this->_indexID;
|
||||
CRM_Core_Session::setStatus(ts('DB Template has been updated successfully.'), ts("Saved"), "success");
|
||||
}
|
||||
CRM_Core_BAO_Persistent::add($params, $ids);
|
||||
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/tplstrings', "reset=1"));
|
||||
}
|
||||
|
||||
}
|
305
sites/all/modules/civicrm/CRM/Admin/Form/Preferences.php
Normal file
305
sites/all/modules/civicrm/CRM/Admin/Form/Preferences.php
Normal file
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for settings forms.
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences extends CRM_Core_Form {
|
||||
protected $_system = FALSE;
|
||||
protected $_contactID = NULL;
|
||||
public $_action = NULL;
|
||||
|
||||
protected $_checkbox = NULL;
|
||||
|
||||
protected $_varNames = NULL;
|
||||
|
||||
protected $_config = NULL;
|
||||
|
||||
protected $_params = NULL;
|
||||
|
||||
public function preProcess() {
|
||||
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive',
|
||||
$this, FALSE
|
||||
);
|
||||
$this->_system = CRM_Utils_Request::retrieve('system', 'Boolean',
|
||||
$this, FALSE, TRUE
|
||||
);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String',
|
||||
$this, FALSE, 'update'
|
||||
);
|
||||
if (isset($action)) {
|
||||
$this->assign('action', $action);
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
$this->_config = new CRM_Core_DAO();
|
||||
|
||||
if ($this->_system) {
|
||||
if (CRM_Core_Permission::check('administer CiviCRM')) {
|
||||
$this->_contactID = NULL;
|
||||
}
|
||||
else {
|
||||
CRM_Utils_System::fatal('You do not have permission to edit preferences');
|
||||
}
|
||||
$this->_config->contact_id = NULL;
|
||||
}
|
||||
else {
|
||||
if (!$this->_contactID) {
|
||||
$this->_contactID = $session->get('userID');
|
||||
if (!$this->_contactID) {
|
||||
CRM_Utils_System::fatal('Could not retrieve contact id');
|
||||
}
|
||||
$this->set('cid', $this->_contactID);
|
||||
}
|
||||
$this->_config->contact_id = $this->_contactID;
|
||||
}
|
||||
|
||||
$settings = Civi::settings();
|
||||
foreach ($this->_varNames as $groupName => $settingNames) {
|
||||
foreach ($settingNames as $settingName => $options) {
|
||||
$this->_config->$settingName = $settings->get($settingName);
|
||||
}
|
||||
}
|
||||
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
foreach ($this->_varNames as $groupName => $settings) {
|
||||
foreach ($settings as $settingName => $settingDetails) {
|
||||
$defaults[$settingName] = isset($this->_config->$settingName) ? $this->_config->$settingName : CRM_Utils_Array::value('default', $settingDetails, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $defaults
|
||||
*/
|
||||
public function cbsDefaultValues(&$defaults) {
|
||||
|
||||
foreach ($this->_varNames as $groupName => $groupValues) {
|
||||
foreach ($groupValues as $settingName => $fieldValue) {
|
||||
if ($fieldValue['html_type'] == 'checkboxes') {
|
||||
if (isset($this->_config->$settingName) &&
|
||||
$this->_config->$settingName
|
||||
) {
|
||||
$value = explode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
substr($this->_config->$settingName, 1, -1)
|
||||
);
|
||||
if (!empty($value)) {
|
||||
$defaults[$settingName] = array();
|
||||
foreach ($value as $n => $v) {
|
||||
$defaults[$settingName][$v] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if (!empty($this->_varNames)) {
|
||||
foreach ($this->_varNames as $groupName => $groupValues) {
|
||||
$formName = CRM_Utils_String::titleToVar($groupName);
|
||||
$this->assign('formName', $formName);
|
||||
$fields = array();
|
||||
foreach ($groupValues as $fieldName => $fieldValue) {
|
||||
$fields[$fieldName] = $fieldValue;
|
||||
|
||||
switch ($fieldValue['html_type']) {
|
||||
case 'text':
|
||||
$this->addElement('text',
|
||||
$fieldName,
|
||||
$fieldValue['title'],
|
||||
array(
|
||||
'maxlength' => 64,
|
||||
'size' => 32,
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
case 'checkbox':
|
||||
$this->add($fieldValue['html_type'],
|
||||
$fieldName,
|
||||
$fieldValue['title']
|
||||
);
|
||||
break;
|
||||
|
||||
case 'radio':
|
||||
$options = CRM_Core_OptionGroup::values($fieldName, FALSE, FALSE, TRUE);
|
||||
$this->addRadio($fieldName, $fieldValue['title'], $options, NULL, ' ');
|
||||
break;
|
||||
|
||||
case 'YesNo':
|
||||
$this->addRadio($fieldName, $fieldValue['title'], array(0 => 'No', 1 => 'Yes'), NULL, ' ');
|
||||
break;
|
||||
|
||||
case 'checkboxes':
|
||||
$options = array_flip(CRM_Core_OptionGroup::values($fieldName, FALSE, FALSE, TRUE));
|
||||
$newOptions = array();
|
||||
foreach ($options as $key => $val) {
|
||||
$newOptions[$key] = $val;
|
||||
}
|
||||
$this->addCheckBox($fieldName,
|
||||
$fieldValue['title'],
|
||||
$newOptions,
|
||||
NULL, NULL, NULL, NULL,
|
||||
array(' ', ' ', '<br/>')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select':
|
||||
$this->addElement('select',
|
||||
$fieldName,
|
||||
$fieldValue['title'],
|
||||
$fieldValue['option_values']
|
||||
);
|
||||
break;
|
||||
|
||||
case 'wysiwyg':
|
||||
$this->add('wysiwyg', $fieldName, $fieldValue['title'], $fieldValue['attributes']);
|
||||
break;
|
||||
|
||||
case 'entity_reference':
|
||||
$this->addEntityRef($fieldName, $fieldValue['title'], CRM_Utils_Array::value('options', $fieldValue, array()));
|
||||
}
|
||||
}
|
||||
|
||||
$fields = CRM_Utils_Array::crmArraySortByField($fields, 'weight');
|
||||
$this->assign('fields', $fields);
|
||||
}
|
||||
}
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ($this->_action == CRM_Core_Action::VIEW) {
|
||||
$this->freeze();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
if ($this->_action == CRM_Core_Action::VIEW) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$this->postProcessCommon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcessCommon() {
|
||||
foreach ($this->_varNames as $groupName => $groupValues) {
|
||||
foreach ($groupValues as $settingName => $fieldValue) {
|
||||
switch ($fieldValue['html_type']) {
|
||||
case 'checkboxes':
|
||||
if (!empty($this->_params[$settingName]) &&
|
||||
is_array($this->_params[$settingName])
|
||||
) {
|
||||
$this->_config->$settingName = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
array_keys($this->_params[$settingName])
|
||||
) . CRM_Core_DAO::VALUE_SEPARATOR;
|
||||
}
|
||||
else {
|
||||
$this->_config->$settingName = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
$this->_config->$settingName = !empty($this->_params[$settingName]) ? 1 : 0;
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
case 'select':
|
||||
case 'radio':
|
||||
case 'YesNo':
|
||||
case 'entity_reference':
|
||||
$this->_config->$settingName = CRM_Utils_Array::value($settingName, $this->_params);
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
$value = CRM_Utils_Array::value($settingName, $this->_params);
|
||||
if ($value) {
|
||||
$value = trim($value);
|
||||
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
||||
}
|
||||
$this->_config->$settingName = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->_varNames as $groupName => $groupValues) {
|
||||
foreach ($groupValues as $settingName => $fieldValue) {
|
||||
$settingValue = isset($this->_config->$settingName) ? $this->_config->$settingName : NULL;
|
||||
Civi::settings()->set($settingName, $settingValue);
|
||||
}
|
||||
}
|
||||
// Update any settings stored in dynamic js
|
||||
CRM_Core_Resources::singleton()->resetCacheCode();
|
||||
|
||||
CRM_Core_Session::setStatus(ts('Your changes have been saved.'), ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
}
|
192
sites/all/modules/civicrm/CRM/Admin/Form/Preferences/Address.php
Normal file
192
sites/all/modules/civicrm/CRM/Admin/Form/Preferences/Address.php
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Address Section.
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences {
|
||||
public function preProcess() {
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Settings - Addresses'));
|
||||
|
||||
// Address Standardization
|
||||
$addrProviders = array(
|
||||
'' => '- select -',
|
||||
) + CRM_Core_SelectValues::addressProvider();
|
||||
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
|
||||
'address_options' => array(
|
||||
'html_type' => 'checkboxes',
|
||||
'title' => ts('Address Fields'),
|
||||
'weight' => 1,
|
||||
),
|
||||
'address_format' => array(
|
||||
'html_type' => 'textarea',
|
||||
'title' => ts('Display Format'),
|
||||
'description' => NULL,
|
||||
'weight' => 2,
|
||||
),
|
||||
'mailing_format' => array(
|
||||
'html_type' => 'textarea',
|
||||
'title' => ts('Mailing Label Format'),
|
||||
'description' => NULL,
|
||||
'weight' => 3,
|
||||
),
|
||||
'hideCountryMailingLabels' => array(
|
||||
'html_type' => 'YesNo',
|
||||
'title' => ts('Hide Country in Mailing Labels when same as domain country'),
|
||||
'weight' => 4,
|
||||
),
|
||||
),
|
||||
CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME => array(
|
||||
'address_standardization_provider' => array(
|
||||
'html_type' => 'select',
|
||||
'title' => ts('Provider'),
|
||||
'option_values' => $addrProviders,
|
||||
'weight' => 5,
|
||||
),
|
||||
'address_standardization_userid' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('User ID'),
|
||||
'description' => NULL,
|
||||
'weight' => 6,
|
||||
),
|
||||
'address_standardization_url' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('Web Service URL'),
|
||||
'description' => NULL,
|
||||
'weight' => 7,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
$defaults['address_standardization_provider'] = $this->_config->address_standardization_provider;
|
||||
$defaults['address_standardization_userid'] = $this->_config->address_standardization_userid;
|
||||
$defaults['address_standardization_url'] = $this->_config->address_standardization_url;
|
||||
|
||||
$this->addressSequence = isset($newSequence) ? $newSequence : "";
|
||||
|
||||
$defaults['address_format'] = $this->_config->address_format;
|
||||
$defaults['mailing_format'] = $this->_config->mailing_format;
|
||||
$defaults['hideCountryMailingLabels'] = $this->_config->hideCountryMailingLabels;
|
||||
|
||||
parent::cbsDefaultValues($defaults);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_Preferences_Address', 'formRule'));
|
||||
|
||||
//get the tokens for Mailing Label field
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
$this->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens));
|
||||
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
$p = $fields['address_standardization_provider'];
|
||||
$u = $fields['address_standardization_userid'];
|
||||
$w = $fields['address_standardization_url'];
|
||||
|
||||
// make sure that there is a value for all of them
|
||||
// if any of them are set
|
||||
if ($p || $u || $w) {
|
||||
if (!CRM_Utils_System::checkPHPVersion(5, FALSE)) {
|
||||
$errors['_qf_default'] = ts('Address Standardization features require PHP version 5 or greater.');
|
||||
return $errors;
|
||||
}
|
||||
|
||||
if (!($p && $u && $w)) {
|
||||
$errors['_qf_default'] = ts('You must provide values for all three Address Standarization fields.');
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action == CRM_Core_Action::VIEW) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_params = $this->controller->exportValues($this->_name);
|
||||
|
||||
// check if county option has been set
|
||||
$options = CRM_Core_OptionGroup::values('address_options', FALSE, FALSE, TRUE);
|
||||
foreach ($options as $key => $title) {
|
||||
if ($title == ts('County')) {
|
||||
// check if the $key is present in $this->_params
|
||||
if (isset($this->_params['address_options']) &&
|
||||
!empty($this->_params['address_options'][$key])
|
||||
) {
|
||||
// print a status message to the user if county table seems small
|
||||
$countyCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_county");
|
||||
if ($countyCount < 10) {
|
||||
CRM_Core_Session::setStatus(ts('You have enabled the County option. Please ensure you populate the county table in your CiviCRM Database. You can find extensions to populate counties in the <a %1>CiviCRM Extensions Directory</a>.', array(1 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', array('reset' => 1), TRUE, 'extensions-addnew') . '"')),
|
||||
ts('Populate counties'),
|
||||
"info"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->postProcessCommon();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for the display preferences
|
||||
*
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Campaign extends CRM_Admin_Form_Preferences {
|
||||
public function preProcess() {
|
||||
CRM_Utils_System::setTitle(ts('CiviCampaign Component Settings'));
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => array(
|
||||
'tag_unconfirmed' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('Tag for Unconfirmed Petition Signers'),
|
||||
'weight' => 1,
|
||||
'description' => ts('If set, new contacts that are created when signing a petition are assigned a tag of this name.'),
|
||||
),
|
||||
'petition_contacts' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('Petition Signers Group'),
|
||||
'weight' => 2,
|
||||
'description' => ts('All contacts that have signed a CiviCampaign petition will be added to this group. The group will be created if it does not exist (it is required for email verification).'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for the display preferences.
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
|
||||
protected $_settings = array(
|
||||
'cvv_backoffice_required' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
'update_contribution_on_membership_type_change' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
'acl_financial_type' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
'always_post_to_accounts_receivable' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
'deferred_revenue_enabled' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
'default_invoice_page' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
'invoicing' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
CRM_Utils_System::setTitle(ts('CiviContribute Component Settings'));
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME => array(
|
||||
'invoice_prefix' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('Invoice Prefix'),
|
||||
'weight' => 1,
|
||||
'description' => ts('Enter prefix to be display on PDF for invoice'),
|
||||
),
|
||||
'credit_notes_prefix' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('Credit Notes Prefix'),
|
||||
'weight' => 2,
|
||||
'description' => ts('Enter prefix to be display on PDF for credit notes.'),
|
||||
),
|
||||
'due_date' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('Due Date'),
|
||||
'weight' => 3,
|
||||
),
|
||||
'due_date_period' => array(
|
||||
'html_type' => 'select',
|
||||
'title' => ts('For transmission'),
|
||||
'weight' => 4,
|
||||
'description' => ts('Select the interval for due date.'),
|
||||
'option_values' => array(
|
||||
'select' => ts('- select -'),
|
||||
'days' => ts('Days'),
|
||||
'months' => ts('Months'),
|
||||
'years' => ts('Years'),
|
||||
),
|
||||
),
|
||||
'notes' => array(
|
||||
'html_type' => 'wysiwyg',
|
||||
'title' => ts('Notes or Standard Terms'),
|
||||
'weight' => 5,
|
||||
'description' => ts('Enter note or message to be displayed on PDF invoice or credit notes '),
|
||||
'attributes' => array('rows' => 2, 'cols' => 40),
|
||||
),
|
||||
'is_email_pdf' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Automatically email invoice when user purchases online'),
|
||||
'weight' => 6,
|
||||
),
|
||||
'tax_term' => array(
|
||||
'html_type' => 'text',
|
||||
'title' => ts('Tax Term'),
|
||||
'weight' => 7,
|
||||
),
|
||||
'tax_display_settings' => array(
|
||||
'html_type' => 'select',
|
||||
'title' => ts('Tax Display Settings'),
|
||||
'weight' => 8,
|
||||
'option_values' => array(
|
||||
'Do_not_show' => ts('Do not show breakdown, only show total -i.e ' .
|
||||
$config->defaultCurrencySymbol . '120.00'),
|
||||
'Inclusive' => ts('Show [tax term] inclusive price - i.e. ' .
|
||||
$config->defaultCurrencySymbol .
|
||||
'120.00 (includes [tax term] of ' .
|
||||
$config->defaultCurrencySymbol . '20.00)'),
|
||||
'Exclusive' => ts('Show [tax term] exclusive price - i.e. ' .
|
||||
$config->defaultCurrencySymbol . '100.00 + ' .
|
||||
$config->defaultCurrencySymbol . '20.00 [tax term]'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$htmlFields = array();
|
||||
foreach ($this->_settings as $setting => $group) {
|
||||
$settingMetaData = civicrm_api3('setting', 'getfields', array('name' => $setting));
|
||||
$props = $settingMetaData['values'][$setting];
|
||||
if (isset($props['quick_form_type'])) {
|
||||
$add = 'add' . $props['quick_form_type'];
|
||||
if ($add == 'addElement') {
|
||||
if (in_array($props['html_type'], array('checkbox', 'textarea'))) {
|
||||
$this->add($props['html_type'],
|
||||
$setting,
|
||||
$props['title']
|
||||
);
|
||||
}
|
||||
else {
|
||||
if ($props['html_type'] == 'select') {
|
||||
$functionName = CRM_Utils_Array::value('name', CRM_Utils_Array::value('pseudoconstant', $props));
|
||||
if ($functionName) {
|
||||
$props['option_values'] = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::$functionName();
|
||||
}
|
||||
}
|
||||
$this->$add(
|
||||
$props['html_type'],
|
||||
$setting,
|
||||
ts($props['title']),
|
||||
CRM_Utils_Array::value($props['html_type'] == 'select' ? 'option_values' : 'html_attributes', $props, array()),
|
||||
$props['html_type'] == 'select' ? CRM_Utils_Array::value('html_attributes', $props) : NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif ($add == 'addMonthDay') {
|
||||
$this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d'));
|
||||
}
|
||||
elseif ($add == 'addDate') {
|
||||
$this->addDate($setting, ts($props['title']), FALSE, array('formatType' => $props['type']));
|
||||
}
|
||||
else {
|
||||
$this->$add($setting, ts($props['title']));
|
||||
}
|
||||
}
|
||||
$htmlFields[$setting] = ts($props['description']);
|
||||
}
|
||||
$this->assign('htmlFields', $htmlFields);
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*
|
||||
* default values are retrieved from the database
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = Civi::settings()->get('contribution_invoice_settings');
|
||||
//CRM-16691: Changes made related to settings of 'CVV'.
|
||||
foreach (array('cvv_backoffice_required') as $setting) {
|
||||
$defaults[$setting] = civicrm_api3('setting', 'getvalue',
|
||||
array(
|
||||
'name' => $setting,
|
||||
'group' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,
|
||||
)
|
||||
);
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// store the submitted values in an array
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
unset($params['qfKey']);
|
||||
unset($params['entryURL']);
|
||||
Civi::settings()->set('contribution_invoice_settings', $params);
|
||||
Civi::settings()->set('update_contribution_on_membership_type_change',
|
||||
CRM_Utils_Array::value('update_contribution_on_membership_type_change', $params)
|
||||
);
|
||||
|
||||
// to set default value for 'Invoices / Credit Notes' checkbox on display preferences
|
||||
$values = CRM_Core_BAO_Setting::getItem("CiviCRM Preferences");
|
||||
$optionValues = CRM_Core_OptionGroup::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
|
||||
$setKey = array_search('Invoices / Credit Notes', $optionValues);
|
||||
|
||||
if (isset($params['invoicing'])) {
|
||||
$value = array($setKey => $optionValues[$setKey]);
|
||||
$setInvoice = CRM_Core_DAO::VALUE_SEPARATOR .
|
||||
implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value)) .
|
||||
CRM_Core_DAO::VALUE_SEPARATOR;
|
||||
Civi::settings()->set('user_dashboard_options', $values['user_dashboard_options'] . $setInvoice);
|
||||
}
|
||||
else {
|
||||
$setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1));
|
||||
$invoiceKey = array_search($setKey, $setting);
|
||||
if ($invoiceKey !== FALSE) {
|
||||
unset($setting[$invoiceKey]);
|
||||
}
|
||||
$settingName = CRM_Core_DAO::VALUE_SEPARATOR .
|
||||
implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) .
|
||||
CRM_Core_DAO::VALUE_SEPARATOR;
|
||||
Civi::settings()->set('user_dashboard_options', $settingName);
|
||||
}
|
||||
//CRM-16691: Changes made related to settings of 'CVV'.
|
||||
$settings = array_intersect_key($params, array('cvv_backoffice_required' => 1));
|
||||
$result = civicrm_api3('setting', 'create', $settings);
|
||||
CRM_Core_Session::setStatus(ts('Your changes have been saved.'), ts('Changes Saved'), "success");
|
||||
}
|
||||
|
||||
}
|
197
sites/all/modules/civicrm/CRM/Admin/Form/Preferences/Display.php
Normal file
197
sites/all/modules/civicrm/CRM/Admin/Form/Preferences/Display.php
Normal file
|
@ -0,0 +1,197 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for the display preferences.
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
|
||||
public function preProcess() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - Display Preferences'));
|
||||
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
|
||||
'contact_view_options' => array(
|
||||
'html_type' => 'checkboxes',
|
||||
'title' => ts('Viewing Contacts'),
|
||||
'weight' => 1,
|
||||
),
|
||||
'contact_smart_group_display' => array(
|
||||
'html_type' => 'radio',
|
||||
'title' => ts('Viewing Smart Groups'),
|
||||
'weight' => 2,
|
||||
),
|
||||
'contact_edit_options' => array(
|
||||
'html_type' => 'checkboxes',
|
||||
'title' => ts('Editing Contacts'),
|
||||
'weight' => 3,
|
||||
),
|
||||
'advanced_search_options' => array(
|
||||
'html_type' => 'checkboxes',
|
||||
'title' => ts('Contact Search'),
|
||||
'weight' => 4,
|
||||
),
|
||||
'activity_assignee_notification' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Notify Activity Assignees'),
|
||||
'weight' => 5,
|
||||
),
|
||||
'activity_assignee_notification_ics' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Include ICal Invite to Activity Assignees'),
|
||||
'weight' => 6,
|
||||
),
|
||||
'preserve_activity_tab_filter' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Preserve activity filters as a user preference'),
|
||||
'weight' => 7,
|
||||
),
|
||||
'contact_ajax_check_similar' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Check for Similar Contacts'),
|
||||
'weight' => 8,
|
||||
),
|
||||
'user_dashboard_options' => array(
|
||||
'html_type' => 'checkboxes',
|
||||
'title' => ts('Contact Dashboard'),
|
||||
'weight' => 9,
|
||||
),
|
||||
'display_name_format' => array(
|
||||
'html_type' => 'textarea',
|
||||
'title' => ts('Individual Display Name Format'),
|
||||
'weight' => 10,
|
||||
),
|
||||
'sort_name_format' => array(
|
||||
'html_type' => 'textarea',
|
||||
'title' => ts('Individual Sort Name Format'),
|
||||
'weight' => 11,
|
||||
),
|
||||
'editor_id' => array(
|
||||
'html_type' => NULL,
|
||||
'weight' => 12,
|
||||
),
|
||||
'ajaxPopupsEnabled' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable Popup Forms'),
|
||||
'weight' => 13,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
parent::cbsDefaultValues($defaults);
|
||||
|
||||
if ($this->_config->display_name_format) {
|
||||
$defaults['display_name_format'] = $this->_config->display_name_format;
|
||||
}
|
||||
if ($this->_config->sort_name_format) {
|
||||
$defaults['sort_name_format'] = $this->_config->sort_name_format;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$wysiwyg_options = CRM_Core_OptionGroup::values('wysiwyg_editor', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name');
|
||||
|
||||
//changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
|
||||
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
|
||||
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
|
||||
$this->assign('invoicing', $invoicing);
|
||||
$extra = array();
|
||||
|
||||
$this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra);
|
||||
$this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor'));
|
||||
|
||||
$editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
|
||||
$this->assign('editOptions', $editOptions);
|
||||
|
||||
$contactBlocks = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1');
|
||||
$this->assign('contactBlocks', $contactBlocks);
|
||||
|
||||
$nameFields = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2');
|
||||
$this->assign('nameFields', $nameFields);
|
||||
|
||||
$this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences'));
|
||||
|
||||
$optionValues = CRM_Core_OptionGroup::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
|
||||
$invoicesKey = array_search('Invoices / Credit Notes', $optionValues);
|
||||
$this->assign('invoicesKey', $invoicesKey);
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action == CRM_Core_Action::VIEW) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_params = $this->controller->exportValues($this->_name);
|
||||
|
||||
if (!empty($this->_params['contact_edit_preferences'])) {
|
||||
$preferenceWeights = explode(',', $this->_params['contact_edit_preferences']);
|
||||
foreach ($preferenceWeights as $key => $val) {
|
||||
if (!$val) {
|
||||
unset($preferenceWeights[$key]);
|
||||
}
|
||||
}
|
||||
$opGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name');
|
||||
CRM_Core_BAO_OptionValue::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
|
||||
}
|
||||
|
||||
$this->_config->editor_id = $this->_params['editor_id'];
|
||||
|
||||
$this->postProcessCommon();
|
||||
|
||||
// If "Configure CKEditor" button was clicked
|
||||
if (!empty($this->_params['ckeditor_config'])) {
|
||||
// Suppress the "Saved" status message and redirect to the CKEditor Config page
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->getStatus(TRUE);
|
||||
$url = CRM_Utils_System::url('civicrm/admin/ckeditor', 'reset=1');
|
||||
$session->pushUserContext($url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for the display preferences
|
||||
*
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Event extends CRM_Admin_Form_Preferences {
|
||||
public function preProcess() {
|
||||
CRM_Utils_System::setTitle(ts('CiviEvent Component Settings'));
|
||||
// pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
|
||||
$docLink = CRM_Utils_System::docURL2("CiviEvent Cart Checkout", NULL, NULL, NULL, NULL, "wiki");
|
||||
// build an array containing all selectable option values for show_events
|
||||
$optionValues = array();
|
||||
for ($i = 10; $i <= 100; $i += 10) {
|
||||
$optionValues[$i] = $i;
|
||||
}
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array(
|
||||
'enable_cart' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Use Shopping Cart Style Event Registration'),
|
||||
'weight' => 1,
|
||||
'description' => ts('This feature allows users to register for more than one event at a time. When enabled, users will add event(s) to a "cart" and then pay for them all at once. Enabling this setting will affect online registration for all active events. The code is an alpha state, and you will potentially need to have developer resources to debug and fix sections of the codebase while testing and deploying it. %1',
|
||||
array(1 => $docLink)),
|
||||
),
|
||||
'show_events' => array(
|
||||
'html_type' => 'select',
|
||||
'title' => ts('Dashboard entries'),
|
||||
'weight' => 2,
|
||||
'description' => ts('Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.'),
|
||||
'option_values' => array('' => ts('- select -')) + $optionValues + array(-1 => ts('show all')),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
}
|
139
sites/all/modules/civicrm/CRM/Admin/Form/Preferences/Mailing.php
Normal file
139
sites/all/modules/civicrm/CRM/Admin/Form/Preferences/Mailing.php
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for the component preferences
|
||||
*
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
|
||||
public function preProcess() {
|
||||
CRM_Utils_System::setTitle(ts('CiviMail Component Settings'));
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array(
|
||||
'profile_double_optin' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable Double Opt-in for Profile Group(s) field'),
|
||||
'weight' => 1,
|
||||
'description' => ts('When CiviMail is enabled, users who "subscribe" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.'),
|
||||
),
|
||||
'profile_add_to_group_double_optin' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable Double Opt-in for Profiles which use the "Add to Group" setting'),
|
||||
'weight' => 2,
|
||||
'description' => ts('When CiviMail is enabled and a profile uses the "Add to Group" setting, users who complete the profile form will receive a confirmation email. They must respond (opt-in) before they are added to the group.'),
|
||||
),
|
||||
'track_civimail_replies' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Track replies using VERP in Reply-To header'),
|
||||
'weight' => 3,
|
||||
'description' => ts('If checked, mailings will default to tracking replies using VERP-ed Reply-To.'),
|
||||
),
|
||||
'civimail_workflow' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable workflow support for CiviMail'),
|
||||
'weight' => 4,
|
||||
'description' => ts('Drupal-only. Rules module must be enabled (beta feature - use with caution).'),
|
||||
),
|
||||
'civimail_multiple_bulk_emails' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable multiple bulk email address for a contact.'),
|
||||
'weight' => 5,
|
||||
'description' => ts('CiviMail will deliver a copy of the email to each bulk email listed for the contact.'),
|
||||
),
|
||||
'civimail_server_wide_lock' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable global server wide lock for CiviMail'),
|
||||
'weight' => 6,
|
||||
'description' => NULL,
|
||||
),
|
||||
'include_message_id' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable CiviMail to generate Message-ID header'),
|
||||
'weight' => 7,
|
||||
'description' => NULL,
|
||||
),
|
||||
'write_activity_record' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable CiviMail to create activities on delivery'),
|
||||
'weight' => 8,
|
||||
'description' => NULL,
|
||||
),
|
||||
'disable_mandatory_tokens_check' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Disable check for mandatory tokens'),
|
||||
'weight' => 9,
|
||||
'description' => ts('Don\'t check for presence of mandatory tokens (domain address; unsubscribe/opt-out) before sending mailings. WARNING: Mandatory tokens are a safe-guard which facilitate compliance with the US CAN-SPAM Act. They should only be disabled if your organization adopts other mechanisms for compliance or if your organization is not subject to CAN-SPAM.'),
|
||||
),
|
||||
'dedupe_email_default' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('CiviMail dedupes e-mail addresses by default'),
|
||||
'weight' => 10,
|
||||
'description' => NULL,
|
||||
),
|
||||
'hash_mailing_url' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Hashed Mailing URL\'s'),
|
||||
'weight' => 11,
|
||||
'description' => 'If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
// check if mailing tab is enabled, if not prompt user to enable the tab if "write_activity_record" is disabled
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
if (empty($params['write_activity_record'])) {
|
||||
$existingViewOptions = Civi::settings()->get('contact_view_options');
|
||||
|
||||
$displayValue = CRM_Core_OptionGroup::getValue('contact_view_options', 'CiviMail', 'name');
|
||||
$viewOptions = explode(CRM_Core_DAO::VALUE_SEPARATOR, $existingViewOptions);
|
||||
|
||||
if (!in_array($displayValue, $viewOptions)) {
|
||||
$existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR;
|
||||
|
||||
Civi::settings()->set('contact_view_options', $existingViewOptions);
|
||||
CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens
|
||||
so that you can view mailings sent to each contact.'), ts('Saved'), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for component preferences.
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Member extends CRM_Admin_Form_Preferences {
|
||||
public function preProcess() {
|
||||
CRM_Utils_System::setTitle(ts('CiviMember Component Settings'));
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => array(
|
||||
'default_renewal_contribution_page' => array(
|
||||
'html_type' => 'select',
|
||||
'title' => ts('Default online membership renewal page'),
|
||||
'option_values' => array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(),
|
||||
'weight' => 1,
|
||||
'description' => ts('If you select a default online contribution page for self-service membership renewals, a "renew" link pointing to that page will be displayed on the Contact Dashboard for memberships which were entered offline. You will need to ensure that the membership block for the selected online contribution page includes any currently available memberships.'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
* $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for multi site preferences
|
||||
*
|
||||
*/
|
||||
class CRM_Admin_Form_Preferences_Multisite extends CRM_Admin_Form_Preferences {
|
||||
public function preProcess() {
|
||||
$msDoc = CRM_Utils_System::docURL2('Multi Site Installation', NULL, NULL, NULL, NULL, "wiki");
|
||||
CRM_Utils_System::setTitle(ts('Multi Site Settings'));
|
||||
$this->_varNames = array(
|
||||
CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array(
|
||||
'is_enabled' => array(
|
||||
'html_type' => 'checkbox',
|
||||
'title' => ts('Enable Multi Site Configuration'),
|
||||
'weight' => 1,
|
||||
'description' => ts('Make CiviCRM aware of multiple domains. You should configure a domain group if enabled') . ' ' . $msDoc,
|
||||
),
|
||||
/** Remove this checkbox until some one knows what this setting does
|
||||
* 'uniq_email_per_site' => array(
|
||||
* 'html_type' => 'checkbox',
|
||||
* 'title' => ts('Ensure multi sites have a unique email per site'),
|
||||
* 'weight' => 2,
|
||||
* 'description' => NULL,
|
||||
* ),
|
||||
*/
|
||||
'domain_group_id' => array(
|
||||
'html_type' => 'entity_reference',
|
||||
'title' => ts('Domain Group'),
|
||||
'weight' => 3,
|
||||
'options' => array('entity' => 'group', 'select' => array('minimumInputLength' => 0)),
|
||||
'description' => ts('Contacts created on this site are added to this group'),
|
||||
),
|
||||
/** Remove this checkbox until some one knows what this setting does
|
||||
* 'event_price_set_domain_id' => array(
|
||||
* 'html_type' => 'text',
|
||||
* 'title' => ts('Domain for event price sets'),
|
||||
* 'weight' => 4,
|
||||
* 'description' => NULL,
|
||||
* ),
|
||||
*/
|
||||
),
|
||||
);
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
}
|
136
sites/all/modules/civicrm/CRM/Admin/Form/PreferencesDate.php
Normal file
136
sites/all/modules/civicrm/CRM/Admin/Form/PreferencesDate.php
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Location Type.
|
||||
*/
|
||||
class CRM_Admin_Form_PreferencesDate extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_PreferencesDate');
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
$name = &$this->add('text',
|
||||
'name',
|
||||
ts('Name'),
|
||||
$attributes['name'],
|
||||
TRUE
|
||||
);
|
||||
$name->freeze();
|
||||
|
||||
$this->add('text', 'description', ts('Description'), $attributes['description'], FALSE);
|
||||
$this->add('text', 'start', ts('Start Offset'), $attributes['start'], TRUE);
|
||||
$this->add('text', 'end', ts('End Offset'), $attributes['end'], TRUE);
|
||||
|
||||
$formatType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PreferencesDate', $this->_id, 'name');
|
||||
|
||||
if ($formatType == 'creditCard') {
|
||||
$this->add('text', 'date_format', ts('Format'), $attributes['date_format'], TRUE);
|
||||
}
|
||||
else {
|
||||
$this->add('select', 'date_format', ts('Format'),
|
||||
array('' => ts('- default input format -')) + CRM_Core_SelectValues::getDatePluginInputFormats()
|
||||
);
|
||||
$this->add('select', 'time_format', ts('Time'),
|
||||
array('' => ts('- none -')) + CRM_Core_SelectValues::getTimeFormats()
|
||||
);
|
||||
}
|
||||
$this->addRule('start', ts('Value must be an integer.'), 'integer');
|
||||
$this->addRule('end', ts('Value must be an integer.'), 'integer');
|
||||
|
||||
// add a form rule
|
||||
$this->addFormRule(array('CRM_Admin_Form_PreferencesDate', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $fields
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* if errors then list of errors to be posted back to the form,
|
||||
* true otherwise
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
$errors = array();
|
||||
|
||||
if ($fields['name'] == 'activityDateTime' && !$fields['time_format']) {
|
||||
$errors['time_format'] = ts('Time is required for this format.');
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if (!($this->_action & CRM_Core_Action::UPDATE)) {
|
||||
CRM_Core_Session::setStatus(ts('Preferences Date Options can only be updated'), ts('Sorry'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// store the submitted values in an array
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
// action is taken depending upon the mode
|
||||
$dao = new CRM_Core_DAO_PreferencesDate();
|
||||
$dao->id = $this->_id;
|
||||
$dao->description = $params['description'];
|
||||
$dao->start = $params['start'];
|
||||
$dao->end = $params['end'];
|
||||
$dao->date_format = $params['date_format'];
|
||||
$dao->time_format = $params['time_format'];
|
||||
|
||||
$dao->save();
|
||||
|
||||
// Update dynamic js to reflect new date settings
|
||||
CRM_Core_Resources::singleton()->resetCacheCode();
|
||||
|
||||
CRM_Core_Session::setStatus(ts("The date type '%1' has been saved.",
|
||||
array(1 => $params['name'])
|
||||
), ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
}
|
173
sites/all/modules/civicrm/CRM/Admin/Form/RelationshipType.php
Normal file
173
sites/all/modules/civicrm/CRM/Admin/Form/RelationshipType.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Relationship Type.
|
||||
*/
|
||||
class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->setPageTitle(ts('Relationship Type'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->applyFilter('__ALL__', 'trim');
|
||||
|
||||
$this->add('text', 'label_a_b', ts('Relationship Label-A to B'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_a_b'), TRUE
|
||||
);
|
||||
$this->addRule('label_a_b', ts('Label already exists in Database.'),
|
||||
'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b')
|
||||
);
|
||||
|
||||
$this->add('text', 'label_b_a', ts('Relationship Label-B to A'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_b_a')
|
||||
);
|
||||
|
||||
$this->addRule('label_b_a', ts('Label already exists in Database.'),
|
||||
'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a')
|
||||
);
|
||||
|
||||
$this->add('text', 'description', ts('Description'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'description')
|
||||
);
|
||||
|
||||
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '__');
|
||||
|
||||
// add select for contact type
|
||||
$contactTypeA = &$this->add('select', 'contact_types_a', ts('Contact Type A') . ' ',
|
||||
array(
|
||||
'' => ts('All Contacts'),
|
||||
) + $contactTypes
|
||||
);
|
||||
$contactTypeB = &$this->add('select', 'contact_types_b', ts('Contact Type B') . ' ',
|
||||
array(
|
||||
'' => ts('All Contacts'),
|
||||
) + $contactTypes
|
||||
);
|
||||
|
||||
$isActive = &$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
|
||||
//only selected field should be allow for edit, CRM-4888
|
||||
if ($this->_id &&
|
||||
CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved')
|
||||
) {
|
||||
foreach (array('contactTypeA', 'contactTypeB', 'isActive') as $field) {
|
||||
$$field->freeze();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_action & CRM_Core_Action::VIEW) {
|
||||
$this->freeze();
|
||||
}
|
||||
|
||||
$this->assign('relationship_type_id', $this->_id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if ($this->_action != CRM_Core_Action::DELETE &&
|
||||
isset($this->_id)
|
||||
) {
|
||||
$defaults = $params = array();
|
||||
$params = array('id' => $this->_id);
|
||||
$baoName = $this->_BAOName;
|
||||
$baoName::retrieve($params, $defaults);
|
||||
$defaults['contact_types_a'] = CRM_Utils_Array::value('contact_type_a', $defaults);
|
||||
if (!empty($defaults['contact_sub_type_a'])) {
|
||||
$defaults['contact_types_a'] .= '__' . $defaults['contact_sub_type_a'];
|
||||
}
|
||||
|
||||
$defaults['contact_types_b'] = CRM_Utils_Array::value('contact_type_b', $defaults);
|
||||
if (!empty($defaults['contact_sub_type_b'])) {
|
||||
$defaults['contact_types_b'] .= '__' . $defaults['contact_sub_type_b'];
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
else {
|
||||
return parent::setDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Contact_BAO_RelationshipType::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected Relationship type has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
$ids = array();
|
||||
|
||||
// store the submitted values in an array
|
||||
$params = $this->exportValues();
|
||||
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$ids['relationshipType'] = $this->_id;
|
||||
}
|
||||
|
||||
$cTypeA = CRM_Utils_System::explode('__',
|
||||
$params['contact_types_a'],
|
||||
2
|
||||
);
|
||||
$cTypeB = CRM_Utils_System::explode('__',
|
||||
$params['contact_types_b'],
|
||||
2
|
||||
);
|
||||
|
||||
$params['contact_type_a'] = $cTypeA[0];
|
||||
$params['contact_type_b'] = $cTypeB[0];
|
||||
|
||||
$params['contact_sub_type_a'] = $cTypeA[1] ? $cTypeA[1] : 'NULL';
|
||||
$params['contact_sub_type_b'] = $cTypeB[1] ? $cTypeB[1] : 'NULL';
|
||||
|
||||
$result = CRM_Contact_BAO_RelationshipType::add($params, $ids);
|
||||
|
||||
$this->ajaxResponse['relationshipType'] = $result->toArray();
|
||||
|
||||
CRM_Core_Session::setStatus(ts('The Relationship Type has been saved.'), ts('Saved'), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
685
sites/all/modules/civicrm/CRM/Admin/Form/ScheduleReminders.php
Normal file
685
sites/all/modules/civicrm/CRM/Admin/Form/ScheduleReminders.php
Normal file
|
@ -0,0 +1,685 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Scheduling Reminders.
|
||||
*/
|
||||
class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Scheduled Reminder ID.
|
||||
*/
|
||||
protected $_id = NULL;
|
||||
|
||||
public $_freqUnits;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
$this->_mappingID = $mappingID = NULL;
|
||||
$providersCount = CRM_SMS_BAO_Provider::activeProviderCount();
|
||||
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
|
||||
|
||||
//CRM-16777: Don't provide access to administer schedule reminder page, with user that does not have 'administer CiviCRM' permission
|
||||
if (empty($this->_context) && !CRM_Core_Permission::check('administer CiviCRM')) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
//CRM-16777: When user have ACLs 'edit' permission for specific event, do not give access to add, delete & updtae
|
||||
//schedule reminder for other events.
|
||||
else {
|
||||
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
|
||||
if (!CRM_Event_BAO_Event::checkPermission($this->_compId, CRM_Core_Permission::EDIT)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_action & (CRM_Core_Action::DELETE)) {
|
||||
$reminderName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'title');
|
||||
if ($this->_context == 'event') {
|
||||
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
|
||||
}
|
||||
$this->assign('reminderName', $reminderName);
|
||||
return;
|
||||
}
|
||||
elseif ($this->_action & (CRM_Core_Action::UPDATE)) {
|
||||
$this->_mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'mapping_id');
|
||||
if ($this->_context == 'event') {
|
||||
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
|
||||
}
|
||||
}
|
||||
elseif (!empty($this->_context)) {
|
||||
if ($this->_context == 'event') {
|
||||
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
|
||||
$isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_compId, 'is_template');
|
||||
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array(
|
||||
'id' => $isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID,
|
||||
)));
|
||||
if ($mapping) {
|
||||
$this->_mappingID = $mapping->getId();
|
||||
}
|
||||
else {
|
||||
CRM_Core_Error::fatal('Could not find mapping for event scheduled reminders.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST) && !empty($_POST['entity']) && empty($this->_context)) {
|
||||
$mappingID = $_POST['entity'][0];
|
||||
}
|
||||
elseif ($this->_mappingID) {
|
||||
$mappingID = $this->_mappingID;
|
||||
if ($this->_context == 'event') {
|
||||
$this->add('hidden', 'mappingID', $mappingID);
|
||||
}
|
||||
}
|
||||
|
||||
$this->add(
|
||||
'text',
|
||||
'title',
|
||||
ts('Title'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionSchedule', 'title'),
|
||||
TRUE
|
||||
);
|
||||
|
||||
$mappings = CRM_Core_BAO_ActionSchedule::getMappings();
|
||||
$selectedMapping = $mappings[$mappingID ? $mappingID : 1];
|
||||
$entityRecipientLabels = $selectedMapping->getRecipientTypes() + CRM_Core_BAO_ActionSchedule::getAdditionalRecipients();
|
||||
$this->assign('entityMapping', json_encode(
|
||||
CRM_Utils_Array::collectMethod('getEntity', $mappings)
|
||||
));
|
||||
$this->assign('recipientMapping', json_encode(
|
||||
array_combine(array_keys($entityRecipientLabels), array_keys($entityRecipientLabels))
|
||||
));
|
||||
|
||||
if (empty($this->_context)) {
|
||||
$sel = &$this->add(
|
||||
'hierselect',
|
||||
'entity',
|
||||
ts('Entity'),
|
||||
array(
|
||||
'name' => 'entity[0]',
|
||||
'style' => 'vertical-align: top;',
|
||||
)
|
||||
);
|
||||
$sel->setOptions(array(
|
||||
CRM_Utils_Array::collectMethod('getLabel', $mappings),
|
||||
CRM_Core_BAO_ActionSchedule::getAllEntityValueLabels(),
|
||||
CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels(),
|
||||
));
|
||||
|
||||
if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) {
|
||||
// make second selector a multi-select -
|
||||
$sel->_elements[1]->setMultiple(TRUE);
|
||||
$sel->_elements[1]->setSize(5);
|
||||
}
|
||||
|
||||
if (is_a($sel->_elements[2], 'HTML_QuickForm_select')) {
|
||||
// make third selector a multi-select -
|
||||
$sel->_elements[2]->setMultiple(TRUE);
|
||||
$sel->_elements[2]->setSize(5);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Dig deeper - this code is sublimely stupid.
|
||||
$allEntityStatusLabels = CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels();
|
||||
$options = $allEntityStatusLabels[$this->_mappingID][0];
|
||||
$attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]);
|
||||
unset($options[0]);
|
||||
$this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes);
|
||||
$this->assign('context', $this->_context);
|
||||
}
|
||||
|
||||
//get the frequency units.
|
||||
$this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits();
|
||||
|
||||
//reminder_interval
|
||||
$this->add('number', 'start_action_offset', ts('When'), array('class' => 'six', 'min' => 0));
|
||||
$this->addRule('start_action_offset', ts('Value should be a positive number'), 'positiveInteger');
|
||||
|
||||
$isActive = ts('Send email');
|
||||
$recordActivity = ts('Record activity for automated email');
|
||||
if ($providersCount) {
|
||||
$this->assign('sms', $providersCount);
|
||||
$isActive = ts('Send email or SMS');
|
||||
$recordActivity = ts('Record activity for automated email or SMS');
|
||||
$options = CRM_Core_OptionGroup::values('msg_mode');
|
||||
$this->add('select', 'mode', ts('Send as'), $options);
|
||||
|
||||
$providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc');
|
||||
|
||||
$providerSelect = array();
|
||||
foreach ($providers as $provider) {
|
||||
$providerSelect[$provider['id']] = $provider['title'];
|
||||
}
|
||||
$this->add('select', 'sms_provider_id', ts('SMS Provider'), $providerSelect, TRUE);
|
||||
}
|
||||
|
||||
foreach ($this->_freqUnits as $val => $label) {
|
||||
$freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label));
|
||||
}
|
||||
|
||||
$this->addDate('absolute_date', ts('Start Date'), FALSE, array('formatType' => 'mailing'));
|
||||
|
||||
//reminder_frequency
|
||||
$this->add('select', 'start_action_unit', ts('Frequency'), $freqUnitsDisplay, TRUE);
|
||||
|
||||
$condition = array(
|
||||
'before' => ts('before'),
|
||||
'after' => ts('after'),
|
||||
);
|
||||
//reminder_action
|
||||
$this->add('select', 'start_action_condition', ts('Action Condition'), $condition);
|
||||
|
||||
$this->add('select', 'start_action_date', ts('Date Field'), $selectedMapping->getDateFields(), TRUE);
|
||||
|
||||
$this->addElement('checkbox', 'record_activity', $recordActivity);
|
||||
|
||||
$this->addElement('checkbox', 'is_repeat', ts('Repeat'),
|
||||
NULL, array('onchange' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);")
|
||||
);
|
||||
|
||||
$this->add('select', 'repetition_frequency_unit', ts('every'), $freqUnitsDisplay);
|
||||
$this->add('number', 'repetition_frequency_interval', ts('every'), array('class' => 'six', 'min' => 0));
|
||||
$this->addRule('repetition_frequency_interval', ts('Value should be a positive number'), 'positiveInteger');
|
||||
|
||||
$this->add('select', 'end_frequency_unit', ts('until'), $freqUnitsDisplay);
|
||||
$this->add('number', 'end_frequency_interval', ts('until'), array('class' => 'six', 'min' => 0));
|
||||
$this->addRule('end_frequency_interval', ts('Value should be a positive number'), 'positiveInteger');
|
||||
|
||||
$this->add('select', 'end_action', ts('Repetition Condition'), $condition, TRUE);
|
||||
$this->add('select', 'end_date', ts('Date Field'), $selectedMapping->getDateFields(), TRUE);
|
||||
|
||||
$this->add('text', 'from_name', ts('From Name'));
|
||||
$this->add('text', 'from_email', ts('From Email'));
|
||||
|
||||
$recipientListingOptions = array();
|
||||
|
||||
if ($mappingID) {
|
||||
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array(
|
||||
'id' => $mappingID,
|
||||
)));
|
||||
}
|
||||
|
||||
$limitOptions = array('' => '-neither-', 1 => ts('Limit to'), 0 => ts('Also include'));
|
||||
|
||||
$recipientLabels = array('activity' => ts('Recipients'), 'other' => ts('Limit or Add Recipients'));
|
||||
$this->assign('recipientLabels', $recipientLabels);
|
||||
|
||||
$this->add('select', 'limit_to', ts('Limit Options'), $limitOptions, FALSE, array('onChange' => "showHideByValue('limit_to','','recipient', 'select','select',true);"));
|
||||
|
||||
$this->add('select', 'recipient', $recipientLabels['other'], $entityRecipientLabels,
|
||||
FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
|
||||
);
|
||||
|
||||
if (!empty($this->_submitValues['recipient_listing'])) {
|
||||
if (!empty($this->_context)) {
|
||||
$recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_mappingID, $this->_submitValues['recipient']);
|
||||
}
|
||||
else {
|
||||
$recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($_POST['entity'][0], $_POST['recipient']);
|
||||
}
|
||||
}
|
||||
elseif (!empty($this->_values['recipient_listing'])) {
|
||||
$recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_values['mapping_id'], $this->_values['recipient']);
|
||||
}
|
||||
|
||||
$this->add('select', 'recipient_listing', ts('Recipient Roles'), $recipientListingOptions, FALSE,
|
||||
array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE));
|
||||
|
||||
$this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => TRUE, 'create' => TRUE));
|
||||
|
||||
$this->add('select', 'group_id', ts('Group'),
|
||||
CRM_Core_PseudoConstant::nestedGroup('Mailing'), FALSE, array('class' => 'crm-select2 huge')
|
||||
);
|
||||
|
||||
// multilingual only options
|
||||
$multilingual = CRM_Core_I18n::isMultilingual();
|
||||
if ($multilingual) {
|
||||
$smarty = CRM_Core_Smarty::singleton();
|
||||
$smarty->assign('multilingual', $multilingual);
|
||||
|
||||
$languages = CRM_Core_I18n::languages(TRUE);
|
||||
$languageFilter = $languages + array(CRM_Core_I18n::NONE => ts('Contacts with no preferred language'));
|
||||
$element = $this->add('select', 'filter_contact_language', ts('Recipients language'), $languageFilter, FALSE,
|
||||
array('multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => TRUE));
|
||||
|
||||
$communicationLanguage = array(
|
||||
'' => ts('System default language'),
|
||||
CRM_Core_I18n::AUTO => ts('Follow recipient preferred language'),
|
||||
);
|
||||
$communicationLanguage = $communicationLanguage + $languages;
|
||||
$this->add('select', 'communication_language', ts('Communication language'), $communicationLanguage);
|
||||
}
|
||||
|
||||
CRM_Mailing_BAO_Mailing::commonCompose($this);
|
||||
|
||||
$this->add('text', 'subject', ts('Subject'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionSchedule', 'subject')
|
||||
);
|
||||
|
||||
$this->add('checkbox', 'is_active', $isActive);
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule'), $this);
|
||||
|
||||
$this->setPageTitle(ts('Scheduled Reminder'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
* @param array $files
|
||||
* @param CRM_Admin_Form_ScheduleReminders $self
|
||||
*
|
||||
* @return array|bool
|
||||
* True if no errors, else array of errors
|
||||
*/
|
||||
public static function formRule($fields, $files, $self) {
|
||||
$errors = array();
|
||||
if ((array_key_exists(1, $fields['entity']) && $fields['entity'][1][0] === 0) ||
|
||||
(array_key_exists(2, $fields['entity']) && $fields['entity'][2][0] == 0)
|
||||
) {
|
||||
$errors['entity'] = ts('Please select appropriate value');
|
||||
}
|
||||
|
||||
if (!empty($fields['is_active']) &&
|
||||
CRM_Utils_System::isNull($fields['subject'])
|
||||
) {
|
||||
$errors['subject'] = ts('Subject is a required field.');
|
||||
}
|
||||
if (!empty($fields['is_active']) &&
|
||||
CRM_Utils_System::isNull(trim(strip_tags($fields['html_message'])))
|
||||
) {
|
||||
$errors['html_message'] = ts('The HTML message is a required field.');
|
||||
}
|
||||
|
||||
if (empty($self->_context) && CRM_Utils_System::isNull(CRM_Utils_Array::value(1, $fields['entity']))) {
|
||||
$errors['entity'] = ts('Please select entity value');
|
||||
}
|
||||
|
||||
if (!CRM_Utils_System::isNull($fields['absolute_date'])) {
|
||||
if (CRM_Utils_Date::format(CRM_Utils_Date::processDate($fields['absolute_date'], NULL)) < CRM_Utils_Date::format(date('Ymd'))) {
|
||||
$errors['absolute_date'] = ts('Absolute date cannot be earlier than the current time.');
|
||||
}
|
||||
}
|
||||
|
||||
$recipientKind = array(
|
||||
'participant_role' => array(
|
||||
'name' => 'participant role',
|
||||
'target_id' => 'recipient_listing',
|
||||
),
|
||||
'manual' => array(
|
||||
'name' => 'recipient',
|
||||
'target_id' => 'recipient_manual_id',
|
||||
),
|
||||
);
|
||||
if ($fields['limit_to'] != '' && array_key_exists($fields['recipient'], $recipientKind) && empty($fields[$recipientKind[$fields['recipient']]['target_id']])) {
|
||||
$errors[$recipientKind[$fields['recipient']]['target_id']] = ts('If "Also include" or "Limit to" are selected, you must specify at least one %1', array(1 => $recipientKind[$fields['recipient']]['name']));
|
||||
}
|
||||
|
||||
$actionSchedule = $self->parseActionSchedule($fields);
|
||||
if ($actionSchedule->mapping_id) {
|
||||
$mapping = CRM_Core_BAO_ActionSchedule::getMapping($actionSchedule->mapping_id);
|
||||
CRM_Utils_Array::extend($errors, $mapping->validateSchedule($actionSchedule));
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
$defaults['is_active'] = 1;
|
||||
$defaults['mode'] = 'Email';
|
||||
$defaults['record_activity'] = 1;
|
||||
}
|
||||
else {
|
||||
$defaults = $this->_values;
|
||||
$entityValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_value', $defaults));
|
||||
$entityStatus = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_status', $defaults));
|
||||
if (empty($this->_context)) {
|
||||
$defaults['entity'][0] = CRM_Utils_Array::value('mapping_id', $defaults);
|
||||
$defaults['entity'][1] = $entityValue;
|
||||
$defaults['entity'][2] = $entityStatus;
|
||||
}
|
||||
else {
|
||||
$defaults['entity'] = $entityStatus;
|
||||
}
|
||||
if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $defaults)) {
|
||||
list($date, $time) = CRM_Utils_Date::setDateDefaults($absoluteDate);
|
||||
$defaults['absolute_date'] = $date;
|
||||
}
|
||||
|
||||
if ($recipientListing = CRM_Utils_Array::value('recipient_listing', $defaults)) {
|
||||
$defaults['recipient_listing'] = explode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
$recipientListing
|
||||
);
|
||||
}
|
||||
$defaults['text_message'] = CRM_Utils_Array::value('body_text', $defaults);
|
||||
$defaults['html_message'] = CRM_Utils_Array::value('body_html', $defaults);
|
||||
$defaults['sms_text_message'] = CRM_Utils_Array::value('sms_body_text', $defaults);
|
||||
$defaults['template'] = CRM_Utils_Array::value('msg_template_id', $defaults);
|
||||
$defaults['SMStemplate'] = CRM_Utils_Array::value('sms_template_id', $defaults);
|
||||
if (!empty($defaults['group_id'])) {
|
||||
$defaults['recipient'] = 'group';
|
||||
}
|
||||
elseif (!empty($defaults['recipient_manual'])) {
|
||||
$defaults['recipient'] = 'manual';
|
||||
$defaults['recipient_manual_id'] = $defaults['recipient_manual'];
|
||||
}
|
||||
if ($contactLanguage = CRM_Utils_Array::value('filter_contact_language', $defaults)) {
|
||||
$defaults['filter_contact_language'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contactLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
// delete reminder
|
||||
CRM_Core_BAO_ActionSchedule::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected Reminder has been deleted.'), ts('Record Deleted'), 'success');
|
||||
if ($this->_context == 'event' && $this->_compId) {
|
||||
$url = CRM_Utils_System::url('civicrm/event/manage/reminder',
|
||||
"reset=1&action=browse&id={$this->_compId}&component={$this->_context}&setTab=1"
|
||||
);
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($url);
|
||||
}
|
||||
return;
|
||||
}
|
||||
$values = $this->controller->exportValues($this->getName());
|
||||
$bao = $this->parseActionSchedule($values)->save();
|
||||
|
||||
// we need to set this on the form so that hooks can identify the created entity
|
||||
$this->set('id', $bao->id);
|
||||
$bao->free();
|
||||
|
||||
$status = ts("Your new Reminder titled %1 has been saved.",
|
||||
array(1 => "<strong>{$values['title']}</strong>")
|
||||
);
|
||||
|
||||
if ($this->_action) {
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$status = ts("Your Reminder titled %1 has been updated.",
|
||||
array(1 => "<strong>{$values['title']}</strong>")
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->_context == 'event' && $this->_compId) {
|
||||
$url = CRM_Utils_System::url('civicrm/event/manage/reminder', "reset=1&action=browse&id={$this->_compId}&component={$this->_context}&setTab=1");
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($url);
|
||||
}
|
||||
}
|
||||
CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
* The submitted form values.
|
||||
* @return CRM_Core_DAO_ActionSchedule
|
||||
*/
|
||||
public function parseActionSchedule($values) {
|
||||
$params = array();
|
||||
|
||||
$keys = array(
|
||||
'title',
|
||||
'subject',
|
||||
'absolute_date',
|
||||
'group_id',
|
||||
'record_activity',
|
||||
'limit_to',
|
||||
'mode',
|
||||
'sms_provider_id',
|
||||
'from_name',
|
||||
'from_email',
|
||||
);
|
||||
foreach ($keys as $key) {
|
||||
$params[$key] = CRM_Utils_Array::value($key, $values);
|
||||
}
|
||||
|
||||
$params['is_repeat'] = CRM_Utils_Array::value('is_repeat', $values, 0);
|
||||
|
||||
$moreKeys = array(
|
||||
'start_action_offset',
|
||||
'start_action_unit',
|
||||
'start_action_condition',
|
||||
'start_action_date',
|
||||
'repetition_frequency_unit',
|
||||
'repetition_frequency_interval',
|
||||
'end_frequency_unit',
|
||||
'end_frequency_interval',
|
||||
'end_action',
|
||||
'end_date',
|
||||
);
|
||||
|
||||
if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $params)) {
|
||||
$params['absolute_date'] = CRM_Utils_Date::processDate($absoluteDate);
|
||||
}
|
||||
else {
|
||||
$params['absolute_date'] = 'null';
|
||||
}
|
||||
foreach ($moreKeys as $mkey) {
|
||||
if ($params['absolute_date'] != 'null' && CRM_Utils_String::startsWith($mkey, 'start_action')) {
|
||||
$params[$mkey] = 'null';
|
||||
continue;
|
||||
}
|
||||
$params[$mkey] = CRM_Utils_Array::value($mkey, $values);
|
||||
}
|
||||
|
||||
$params['body_text'] = CRM_Utils_Array::value('text_message', $values);
|
||||
$params['sms_body_text'] = CRM_Utils_Array::value('sms_text_message', $values);
|
||||
$params['body_html'] = CRM_Utils_Array::value('html_message', $values);
|
||||
|
||||
if (CRM_Utils_Array::value('recipient', $values) == 'manual') {
|
||||
$params['recipient_manual'] = CRM_Utils_Array::value('recipient_manual_id', $values);
|
||||
$params['group_id'] = $params['recipient'] = $params['recipient_listing'] = 'null';
|
||||
}
|
||||
elseif (CRM_Utils_Array::value('recipient', $values) == 'group') {
|
||||
$params['group_id'] = $values['group_id'];
|
||||
$params['recipient_manual'] = $params['recipient'] = $params['recipient_listing'] = 'null';
|
||||
}
|
||||
elseif (isset($values['recipient_listing']) && isset($values['limit_to']) && !CRM_Utils_System::isNull($values['recipient_listing']) && !CRM_Utils_System::isNull($values['limit_to'])) {
|
||||
$params['recipient'] = CRM_Utils_Array::value('recipient', $values);
|
||||
$params['recipient_listing'] = implode(CRM_Core_DAO::VALUE_SEPARATOR,
|
||||
CRM_Utils_Array::value('recipient_listing', $values)
|
||||
);
|
||||
$params['group_id'] = $params['recipient_manual'] = 'null';
|
||||
}
|
||||
else {
|
||||
$params['recipient'] = CRM_Utils_Array::value('recipient', $values);
|
||||
$params['group_id'] = $params['recipient_manual'] = $params['recipient_listing'] = 'null';
|
||||
}
|
||||
|
||||
if (!empty($this->_mappingID) && !empty($this->_compId)) {
|
||||
$params['mapping_id'] = $this->_mappingID;
|
||||
$params['entity_value'] = $this->_compId;
|
||||
$params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $values['entity']);
|
||||
}
|
||||
else {
|
||||
$params['mapping_id'] = $values['entity'][0];
|
||||
if ($params['mapping_id'] == 1) {
|
||||
$params['limit_to'] = 1;
|
||||
}
|
||||
|
||||
$entity_value = CRM_Utils_Array::value(1, $values['entity'], array());
|
||||
$entity_status = CRM_Utils_Array::value(2, $values['entity'], array());
|
||||
$params['entity_value'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $entity_value);
|
||||
$params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $entity_status);
|
||||
}
|
||||
|
||||
$params['is_active'] = CRM_Utils_Array::value('is_active', $values, 0);
|
||||
|
||||
if (CRM_Utils_Array::value('is_repeat', $values) == 0) {
|
||||
$params['repetition_frequency_unit'] = 'null';
|
||||
$params['repetition_frequency_interval'] = 'null';
|
||||
$params['end_frequency_unit'] = 'null';
|
||||
$params['end_frequency_interval'] = 'null';
|
||||
$params['end_action'] = 'null';
|
||||
$params['end_date'] = 'null';
|
||||
}
|
||||
|
||||
// multilingual options
|
||||
$params['filter_contact_language'] = CRM_Utils_Array::value('filter_contact_language', $values, array());
|
||||
$params['filter_contact_language'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['filter_contact_language']);
|
||||
$params['communication_language'] = CRM_Utils_Array::value('communication_language', $values, NULL);
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::ADD) {
|
||||
// we do this only once, so name never changes
|
||||
$params['name'] = CRM_Utils_String::munge($params['title'], '_', 64);
|
||||
}
|
||||
|
||||
$modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS');
|
||||
|
||||
if ($params['mode'] == 'Email' || empty($params['sms_provider_id'])) {
|
||||
unset($modePrefixes['SMS']);
|
||||
}
|
||||
elseif ($params['mode'] == 'SMS') {
|
||||
unset($modePrefixes['Mail']);
|
||||
}
|
||||
|
||||
//TODO: handle postprocessing of SMS and/or Email info based on $modePrefixes
|
||||
|
||||
$composeFields = array(
|
||||
'template',
|
||||
'saveTemplate',
|
||||
'updateTemplate',
|
||||
'saveTemplateName',
|
||||
);
|
||||
$msgTemplate = NULL;
|
||||
//mail template is composed
|
||||
|
||||
foreach ($modePrefixes as $prefix) {
|
||||
$composeParams = array();
|
||||
foreach ($composeFields as $key) {
|
||||
$key = $prefix . $key;
|
||||
if (!empty($values[$key])) {
|
||||
$composeParams[$key] = $values[$key];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($composeParams[$prefix . 'updateTemplate'])) {
|
||||
$templateParams = array('is_active' => TRUE);
|
||||
if ($prefix == 'SMS') {
|
||||
$templateParams += array(
|
||||
'msg_text' => $params['sms_body_text'],
|
||||
'is_sms' => TRUE,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$templateParams += array(
|
||||
'msg_text' => $params['body_text'],
|
||||
'msg_html' => $params['body_html'],
|
||||
'msg_subject' => $params['subject'],
|
||||
);
|
||||
}
|
||||
$templateParams['id'] = $values[$prefix . 'template'];
|
||||
|
||||
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
|
||||
}
|
||||
|
||||
if (!empty($composeParams[$prefix . 'saveTemplate'])) {
|
||||
$templateParams = array('is_active' => TRUE);
|
||||
if ($prefix == 'SMS') {
|
||||
$templateParams += array(
|
||||
'msg_text' => $params['sms_body_text'],
|
||||
'is_sms' => TRUE,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$templateParams += array(
|
||||
'msg_text' => $params['body_text'],
|
||||
'msg_html' => $params['body_html'],
|
||||
'msg_subject' => $params['subject'],
|
||||
);
|
||||
}
|
||||
$templateParams['msg_title'] = $composeParams[$prefix . 'saveTemplateName'];
|
||||
|
||||
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
|
||||
}
|
||||
|
||||
if ($prefix == 'SMS') {
|
||||
if (isset($msgTemplate->id)) {
|
||||
$params['sms_template_id'] = $msgTemplate->id;
|
||||
}
|
||||
else {
|
||||
$params['sms_template_id'] = CRM_Utils_Array::value('SMStemplate', $values);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isset($msgTemplate->id)) {
|
||||
$params['msg_template_id'] = $msgTemplate->id;
|
||||
}
|
||||
else {
|
||||
$params['msg_template_id'] = CRM_Utils_Array::value('template', $values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$actionSchedule = new CRM_Core_DAO_ActionSchedule();
|
||||
$actionSchedule->copyValues($params);
|
||||
return $actionSchedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* List available tokens for this form.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTokens() {
|
||||
$tokens = CRM_Core_SelectValues::contactTokens();
|
||||
$tokens = array_merge(CRM_Core_SelectValues::activityTokens(), $tokens);
|
||||
$tokens = array_merge(CRM_Core_SelectValues::eventTokens(), $tokens);
|
||||
$tokens = array_merge(CRM_Core_SelectValues::membershipTokens(), $tokens);
|
||||
$tokens = array_merge(CRM_Core_SelectValues::contributionTokens(), $tokens);
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
}
|
306
sites/all/modules/civicrm/CRM/Admin/Form/Setting.php
Normal file
306
sites/all/modules/civicrm/CRM/Admin/Form/Setting.php
Normal file
|
@ -0,0 +1,306 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components generic to CiviCRM settings.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting extends CRM_Core_Form {
|
||||
|
||||
protected $_settings = array();
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*
|
||||
* Default values are retrieved from the database.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if (!$this->_defaults) {
|
||||
$this->_defaults = array();
|
||||
$formArray = array('Component', 'Localization');
|
||||
$formMode = FALSE;
|
||||
if (in_array($this->_name, $formArray)) {
|
||||
$formMode = TRUE;
|
||||
}
|
||||
|
||||
CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
|
||||
|
||||
// we can handle all the ones defined in the metadata here. Others to be converted
|
||||
foreach ($this->_settings as $setting => $group) {
|
||||
$this->_defaults[$setting] = civicrm_api('setting', 'getvalue', array(
|
||||
'version' => 3,
|
||||
'name' => $setting,
|
||||
'group' => $group,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_defaults['contact_autocomplete_options'] = self::getAutocompleteContactSearch();
|
||||
$this->_defaults['contact_reference_options'] = self::getAutocompleteContactReference();
|
||||
$this->_defaults['enableSSL'] = Civi::settings()->get('enableSSL');
|
||||
$this->_defaults['verifySSL'] = Civi::settings()->get('verifySSL');
|
||||
$this->_defaults['environment'] = CRM_Core_Config::environment();
|
||||
$this->_defaults['enableComponents'] = Civi::settings()->get('enable_components');
|
||||
}
|
||||
|
||||
return $this->_defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$descriptions = array();
|
||||
$settingMetaData = $this->getSettingsMetaData();
|
||||
foreach ($settingMetaData as $setting => $props) {
|
||||
if (isset($props['quick_form_type'])) {
|
||||
if (isset($props['pseudoconstant'])) {
|
||||
$options = civicrm_api3('Setting', 'getoptions', array(
|
||||
'field' => $setting,
|
||||
));
|
||||
}
|
||||
else {
|
||||
$options = NULL;
|
||||
}
|
||||
|
||||
$add = 'add' . $props['quick_form_type'];
|
||||
if ($add == 'addElement') {
|
||||
$this->$add(
|
||||
$props['html_type'],
|
||||
$setting,
|
||||
ts($props['title']),
|
||||
($options !== NULL) ? $options['values'] : CRM_Utils_Array::value('html_attributes', $props, array()),
|
||||
($options !== NULL) ? CRM_Utils_Array::value('html_attributes', $props, array()) : NULL
|
||||
);
|
||||
}
|
||||
elseif ($add == 'addSelect') {
|
||||
$this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props));
|
||||
}
|
||||
elseif ($add == 'addCheckBox') {
|
||||
$this->addCheckBox($setting, ts($props['title']), $options['values'], NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, array(' '));
|
||||
}
|
||||
elseif ($add == 'addChainSelect') {
|
||||
$this->addChainSelect($setting, array(
|
||||
'label' => ts($props['title']),
|
||||
));
|
||||
}
|
||||
elseif ($add == 'addMonthDay') {
|
||||
$this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d'));
|
||||
}
|
||||
else {
|
||||
$this->$add($setting, ts($props['title']));
|
||||
}
|
||||
// Migrate to using an array as easier in smart...
|
||||
$descriptions[$setting] = ts($props['description']);
|
||||
$this->assign("{$setting}_description", ts($props['description']));
|
||||
if ($setting == 'max_attachments') {
|
||||
//temp hack @todo fix to get from metadata
|
||||
$this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
|
||||
}
|
||||
if ($setting == 'maxFileSize') {
|
||||
//temp hack
|
||||
$this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// setting_description should be deprecated - see Mail.tpl for metadata based tpl.
|
||||
$this->assign('setting_descriptions', $descriptions);
|
||||
$this->assign('settings_fields', $settingMetaData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default entity.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultEntity() {
|
||||
return 'Setting';
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// store the submitted values in an array
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
self::commonProcess($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common Process.
|
||||
*
|
||||
* @todo Document what I do.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function commonProcess(&$params) {
|
||||
|
||||
// save autocomplete search options
|
||||
if (!empty($params['contact_autocomplete_options'])) {
|
||||
Civi::settings()->set('contact_autocomplete_options',
|
||||
CRM_Utils_Array::implodePadded(array_keys($params['contact_autocomplete_options'])));
|
||||
unset($params['contact_autocomplete_options']);
|
||||
}
|
||||
|
||||
// save autocomplete contact reference options
|
||||
if (!empty($params['contact_reference_options'])) {
|
||||
Civi::settings()->set('contact_reference_options',
|
||||
CRM_Utils_Array::implodePadded(array_keys($params['contact_reference_options'])));
|
||||
unset($params['contact_reference_options']);
|
||||
}
|
||||
|
||||
// save components to be enabled
|
||||
if (array_key_exists('enableComponents', $params)) {
|
||||
civicrm_api3('setting', 'create', array(
|
||||
'enable_components' => $params['enableComponents'],
|
||||
));
|
||||
unset($params['enableComponents']);
|
||||
}
|
||||
|
||||
foreach (array('verifySSL', 'enableSSL') as $name) {
|
||||
if (isset($params[$name])) {
|
||||
Civi::settings()->set($name, $params[$name]);
|
||||
unset($params[$name]);
|
||||
}
|
||||
}
|
||||
$settings = array_intersect_key($params, $this->_settings);
|
||||
$result = civicrm_api('setting', 'create', $settings + array('version' => 3));
|
||||
foreach ($settings as $setting => $settingGroup) {
|
||||
//@todo array_diff this
|
||||
unset($params[$setting]);
|
||||
}
|
||||
if (!empty($result['error_message'])) {
|
||||
CRM_Core_Session::setStatus($result['error_message'], ts('Save Failed'), 'error');
|
||||
}
|
||||
|
||||
//CRM_Core_BAO_ConfigSetting::create($params);
|
||||
$params = CRM_Core_BAO_ConfigSetting::filterSkipVars($params);
|
||||
if (!empty($params)) {
|
||||
CRM_Core_Error::fatal('Unrecognized setting. This may be a config field which has not been properly migrated to a setting. (' . implode(', ', array_keys($params)) . ')');
|
||||
}
|
||||
|
||||
CRM_Core_Config::clearDBCache();
|
||||
CRM_Utils_System::flushCache();
|
||||
CRM_Core_Resources::singleton()->resetCacheCode();
|
||||
|
||||
CRM_Core_Session::setStatus(" ", ts('Changes Saved'), "success");
|
||||
}
|
||||
|
||||
public function rebuildMenu() {
|
||||
// ensure config is set with new values
|
||||
$config = CRM_Core_Config::singleton(TRUE, TRUE);
|
||||
|
||||
// rebuild menu items
|
||||
CRM_Core_Menu::store();
|
||||
|
||||
// also delete the IDS file so we can write a new correct one on next load
|
||||
$configFile = $config->uploadDir . 'Config.IDS.ini';
|
||||
@unlink($configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ugh, this shouldn't exist.
|
||||
*
|
||||
* Get the selected values of "contact_reference_options" formatted for checkboxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAutocompleteContactReference() {
|
||||
$cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
|
||||
FALSE, FALSE, TRUE, NULL, 'name'
|
||||
));
|
||||
$cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'contact_reference_options'
|
||||
);
|
||||
$cRSearchFields = array();
|
||||
if (!empty($cRlist) && !empty($cRlistEnabled)) {
|
||||
$cRSearchFields = array_combine($cRlist, $cRlistEnabled);
|
||||
}
|
||||
return array(
|
||||
'1' => 1,
|
||||
) + $cRSearchFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ugh, this shouldn't exist.
|
||||
*
|
||||
* Get the selected values of "contact_autocomplete_options" formatted for checkboxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAutocompleteContactSearch() {
|
||||
$list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
|
||||
FALSE, FALSE, TRUE, NULL, 'name'
|
||||
));
|
||||
$listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'contact_autocomplete_options'
|
||||
);
|
||||
$autoSearchFields = array();
|
||||
if (!empty($list) && !empty($listEnabled)) {
|
||||
$autoSearchFields = array_combine($list, $listEnabled);
|
||||
}
|
||||
//Set defaults for autocomplete and contact reference options
|
||||
return array(
|
||||
'1' => 1,
|
||||
) + $autoSearchFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata relating to the settings on the form, ordered by the keys in $this->_settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getSettingsMetaData() {
|
||||
$allSettingMetaData = civicrm_api3('setting', 'getfields', array());
|
||||
$settingMetaData = array_intersect_key($allSettingMetaData['values'], $this->_settings);
|
||||
// This array_merge re-orders to the key order of $this->_settings.
|
||||
$settingMetaData = array_merge($this->_settings, $settingMetaData);
|
||||
return $settingMetaData;
|
||||
}
|
||||
|
||||
}
|
54
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Case.php
Normal file
54
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Case.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for CiviCase.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Case extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'civicaseRedactActivityEmail' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'civicaseAllowMultipleClients' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'civicaseNaturalActivityTypeSort' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'civicaseActivityRevisions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - CiviCase'));
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
}
|
173
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Component.php
Normal file
173
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Component.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Component.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting {
|
||||
protected $_components;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - Enable Components'));
|
||||
$components = $this->_getComponentSelectValues();
|
||||
$include = &$this->addElement('advmultiselect', 'enableComponents',
|
||||
ts('Components') . ' ', $components,
|
||||
array(
|
||||
'size' => 5,
|
||||
'style' => 'width:150px',
|
||||
'class' => 'advmultiselect',
|
||||
)
|
||||
);
|
||||
|
||||
$include->setButtonAttributes('add', array('value' => ts('Enable >>')));
|
||||
$include->setButtonAttributes('remove', array('value' => ts('<< Disable')));
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_Setting_Component', 'formRule'), $this);
|
||||
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
* @param array $files
|
||||
* The uploaded files if any.
|
||||
* @param array $options
|
||||
* Additional user data.
|
||||
*
|
||||
* @return bool|array
|
||||
* true if no errors, else array of errors
|
||||
*/
|
||||
public static function formRule($fields, $files, $options) {
|
||||
$errors = array();
|
||||
|
||||
if (array_key_exists('enableComponents', $fields) && is_array($fields['enableComponents'])) {
|
||||
if (in_array('CiviPledge', $fields['enableComponents']) &&
|
||||
!in_array('CiviContribute', $fields['enableComponents'])
|
||||
) {
|
||||
$errors['enableComponents'] = ts('You need to enable CiviContribute before enabling CiviPledge.');
|
||||
}
|
||||
if (in_array('CiviCase', $fields['enableComponents']) &&
|
||||
!CRM_Core_DAO::checkTriggerViewPermission(TRUE, FALSE)
|
||||
) {
|
||||
$errors['enableComponents'] = ts('CiviCase requires CREATE VIEW and DROP VIEW permissions for the database.');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function _getComponentSelectValues() {
|
||||
$ret = array();
|
||||
$this->_components = CRM_Core_Component::getComponents();
|
||||
foreach ($this->_components as $name => $object) {
|
||||
$ret[$name] = $object->info['translatedName'];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
parent::commonProcess($params);
|
||||
|
||||
// reset navigation when components are enabled / disabled
|
||||
CRM_Core_BAO_Navigation::resetNavigation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load case sample data.
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param bool $lineMode
|
||||
*/
|
||||
public static function loadCaseSampleData($fileName, $lineMode = FALSE) {
|
||||
$dao = new CRM_Core_DAO();
|
||||
$db = $dao->getDatabaseConnection();
|
||||
|
||||
$domain = new CRM_Core_DAO_Domain();
|
||||
$domain->find(TRUE);
|
||||
$multiLingual = (bool) $domain->locales;
|
||||
$smarty = CRM_Core_Smarty::singleton();
|
||||
$smarty->assign('multilingual', $multiLingual);
|
||||
$smarty->assign('locales', explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales));
|
||||
|
||||
if (!$lineMode) {
|
||||
|
||||
$string = $smarty->fetch($fileName);
|
||||
// change \r\n to fix windows issues
|
||||
$string = str_replace("\r\n", "\n", $string);
|
||||
|
||||
//get rid of comments starting with # and --
|
||||
|
||||
$string = preg_replace("/^#[^\n]*$/m", "\n", $string);
|
||||
$string = preg_replace("/^(--[^-]).*/m", "\n", $string);
|
||||
|
||||
$queries = preg_split('/;$/m', $string);
|
||||
foreach ($queries as $query) {
|
||||
$query = trim($query);
|
||||
if (!empty($query)) {
|
||||
$res = &$db->query($query);
|
||||
if (PEAR::isError($res)) {
|
||||
die("Cannot execute $query: " . $res->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$fd = fopen($fileName, "r");
|
||||
while ($string = fgets($fd)) {
|
||||
$string = preg_replace("/^#[^\n]*$/m", "\n", $string);
|
||||
$string = preg_replace("/^(--[^-]).*/m", "\n", $string);
|
||||
|
||||
$string = trim($string);
|
||||
if (!empty($string)) {
|
||||
$res = &$db->query($string);
|
||||
if (PEAR::isError($res)) {
|
||||
die("Cannot execute $string: " . $res->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
62
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Date.php
Normal file
62
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Date.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Date Formatting.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Date extends CRM_Admin_Form_Setting {
|
||||
|
||||
public $_settings = array(
|
||||
'dateformatDatetime' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'dateformatFull' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'dateformatPartial' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'dateformatYear' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'dateformatTime' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'dateformatFinancialBatch' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'dateformatshortdate' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'weekBegins' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'dateInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'timeInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'fiscalYearStart' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - Date'));
|
||||
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Error Handling and Debugging.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Debugging extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'debug_enabled' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
|
||||
'backtrace' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
|
||||
'fatalErrorHandler' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
|
||||
'assetCache' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
|
||||
'environment' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts(' Settings - Debugging and Error Handling '));
|
||||
if (CRM_Core_Config::singleton()->userSystem->supports_UF_Logging == '1') {
|
||||
$this->_settings['userFrameworkLogging'] = CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME;
|
||||
}
|
||||
|
||||
parent::buildQuickForm();
|
||||
if (Civi::settings()->getMandatory('environment') !== NULL) {
|
||||
$element = $this->getElement('environment');
|
||||
$element->freeze();
|
||||
CRM_Core_Session::setStatus(ts('The environment settings have been disabled because it has been overridden in the settings file.'), ts('Environment settings'), 'info');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,393 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Localization.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'contact_default_language' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'countryLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'customTranslateFunction' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'defaultContactCountry' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'defaultContactStateProvince' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'defaultCurrency' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'fieldSeparator' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'inheritLocale' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'lcMessages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'legacyEncoding' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'monetaryThousandSeparator' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'monetaryDecimalPoint' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'moneyformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'moneyvalueformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
'provinceLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Settings - Localization'));
|
||||
|
||||
$warningTitle = json_encode(ts("Warning"));
|
||||
$defaultLocaleOptions = CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions();
|
||||
|
||||
$domain = new CRM_Core_DAO_Domain();
|
||||
$domain->find(TRUE);
|
||||
|
||||
if ($domain->locales) {
|
||||
// add language limiter and language adder
|
||||
$this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($defaultLocaleOptions), NULL, NULL, NULL, NULL, ' ');
|
||||
$this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff(CRM_Core_I18n::languages(), $defaultLocaleOptions)));
|
||||
|
||||
// add the ability to return to single language
|
||||
$warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).');
|
||||
$this->assign('warning', $warning);
|
||||
$warning = json_encode($warning);
|
||||
$this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'),
|
||||
NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)")
|
||||
);
|
||||
}
|
||||
else {
|
||||
$warning = ts('Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.');
|
||||
$this->assign('warning', $warning);
|
||||
$warning = json_encode($warning);
|
||||
$validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(TRUE);
|
||||
|
||||
if ($validTriggerPermission &&
|
||||
!\Civi::settings()->get('logging')
|
||||
) {
|
||||
$this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'),
|
||||
NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)")
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->addElement('select', 'contact_default_language', ts('Default Language for users'),
|
||||
CRM_Admin_Form_Setting_Localization::getDefaultLanguageOptions());
|
||||
|
||||
$includeCurrency = &$this->addElement('advmultiselect', 'currencyLimit',
|
||||
ts('Available Currencies') . ' ', self::getCurrencySymbols(),
|
||||
array(
|
||||
'size' => 5,
|
||||
'style' => 'width:150px',
|
||||
'class' => 'advmultiselect',
|
||||
)
|
||||
);
|
||||
|
||||
$includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>')));
|
||||
$includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove')));
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule'));
|
||||
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
$errors = array();
|
||||
if (CRM_Utils_Array::value('monetaryThousandSeparator', $fields) ==
|
||||
CRM_Utils_Array::value('monetaryDecimalPoint', $fields)
|
||||
) {
|
||||
$errors['monetaryThousandSeparator'] = ts('Thousands Separator and Decimal Delimiter can not be the same.');
|
||||
}
|
||||
|
||||
if (strlen($fields['monetaryThousandSeparator']) == 0) {
|
||||
$errors['monetaryThousandSeparator'] = ts('Thousands Separator can not be empty. You can use a space character instead.');
|
||||
}
|
||||
|
||||
if (strlen($fields['monetaryThousandSeparator']) > 1) {
|
||||
$errors['monetaryThousandSeparator'] = ts('Thousands Separator can not have more than 1 character.');
|
||||
}
|
||||
|
||||
if (strlen($fields['monetaryDecimalPoint']) > 1) {
|
||||
$errors['monetaryDecimalPoint'] = ts('Decimal Delimiter can not have more than 1 character.');
|
||||
}
|
||||
|
||||
if (trim($fields['customTranslateFunction']) &&
|
||||
!function_exists(trim($fields['customTranslateFunction']))
|
||||
) {
|
||||
$errors['customTranslateFunction'] = ts('Please define the custom translation function first.');
|
||||
}
|
||||
|
||||
// CRM-7962, CRM-7713, CRM-9004
|
||||
if (!empty($fields['defaultContactCountry']) &&
|
||||
(!empty($fields['countryLimit']) &&
|
||||
(!in_array($fields['defaultContactCountry'], $fields['countryLimit']))
|
||||
)
|
||||
) {
|
||||
$errors['defaultContactCountry'] = ts('Please select a default country that is in the list of available countries.');
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default values for the form.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
parent::setDefaultValues();
|
||||
|
||||
// CRM-1496
|
||||
// retrieve default values for currencyLimit
|
||||
$this->_defaults['currencyLimit'] = array_keys(CRM_Core_OptionGroup::values('currencies_enabled'));
|
||||
|
||||
$this->_defaults['languageLimit'] = Civi::settings()->get('languageLimit');
|
||||
|
||||
// CRM-5111: unset these two unconditionally, we don’t want them to stick – ever
|
||||
unset($this->_defaults['makeMultilingual']);
|
||||
unset($this->_defaults['makeSinglelingual']);
|
||||
return $this->_defaults;
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$values = $this->exportValues();
|
||||
|
||||
//cache contact fields retaining localized titles
|
||||
//though we changed localization, so reseting cache.
|
||||
CRM_Core_BAO_Cache::deleteGroup('contact fields');
|
||||
|
||||
//CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
|
||||
CRM_Core_BAO_Cache::deleteGroup('navigation');
|
||||
|
||||
// we do this only to initialize monetary decimal point and thousand separator
|
||||
$config = CRM_Core_Config::singleton();
|
||||
|
||||
// save enabled currencies and default currency in option group 'currencies_enabled'
|
||||
// CRM-1496
|
||||
if (empty($values['currencyLimit'])) {
|
||||
$values['currencyLimit'] = array($values['defaultCurrency']);
|
||||
}
|
||||
elseif (!in_array($values['defaultCurrency'], $values['currencyLimit'])) {
|
||||
$values['currencyLimit'][] = $values['defaultCurrency'];
|
||||
}
|
||||
|
||||
self::updateEnabledCurrencies($values['currencyLimit'], $values['defaultCurrency']);
|
||||
|
||||
// unset currencyLimit so we dont store there
|
||||
unset($values['currencyLimit']);
|
||||
|
||||
// make the site multi-lang if requested
|
||||
if (!empty($values['makeMultilingual'])) {
|
||||
CRM_Core_I18n_Schema::makeMultilingual($values['lcMessages']);
|
||||
$values['languageLimit'][$values['lcMessages']] = 1;
|
||||
// make the site single-lang if requested
|
||||
}
|
||||
elseif (!empty($values['makeSinglelingual'])) {
|
||||
CRM_Core_I18n_Schema::makeSinglelingual($values['lcMessages']);
|
||||
$values['languageLimit'] = '';
|
||||
}
|
||||
|
||||
// add a new db locale if the requested language is not yet supported by the db
|
||||
if (!CRM_Utils_Array::value('makeSinglelingual', $values) and CRM_Utils_Array::value('addLanguage', $values)) {
|
||||
$domain = new CRM_Core_DAO_Domain();
|
||||
$domain->find(TRUE);
|
||||
if (!substr_count($domain->locales, $values['addLanguage'])) {
|
||||
CRM_Core_I18n_Schema::addLocale($values['addLanguage'], $values['lcMessages']);
|
||||
}
|
||||
$values['languageLimit'][$values['addLanguage']] = 1;
|
||||
}
|
||||
|
||||
// if we manipulated the language list, return to the localization admin screen
|
||||
$return = (bool) (CRM_Utils_Array::value('makeMultilingual', $values) or CRM_Utils_Array::value('addLanguage', $values));
|
||||
|
||||
$filteredValues = $values;
|
||||
unset($filteredValues['makeMultilingual']);
|
||||
unset($filteredValues['makeSinglelingual']);
|
||||
unset($filteredValues['addLanguage']);
|
||||
unset($filteredValues['languageLimit']);
|
||||
|
||||
Civi::settings()->set('languageLimit', CRM_Utils_Array::value('languageLimit', $values));
|
||||
|
||||
// save all the settings
|
||||
parent::commonProcess($filteredValues);
|
||||
|
||||
if ($return) {
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/localization', 'reset=1'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace available currencies by the ones provided
|
||||
*
|
||||
* @param $currencies array of currencies ['USD', 'CAD']
|
||||
* @param $default default currency
|
||||
*/
|
||||
public static function updateEnabledCurrencies($currencies, $default) {
|
||||
|
||||
// sort so that when we display drop down, weights have right value
|
||||
sort($currencies);
|
||||
|
||||
// get labels for all the currencies
|
||||
$options = array();
|
||||
|
||||
$currencySymbols = CRM_Admin_Form_Setting_Localization::getCurrencySymbols();
|
||||
for ($i = 0; $i < count($currencies); $i++) {
|
||||
$options[] = array(
|
||||
'label' => $currencySymbols[$currencies[$i]],
|
||||
'value' => $currencies[$i],
|
||||
'weight' => $i + 1,
|
||||
'is_active' => 1,
|
||||
'is_default' => $currencies[$i] == $default,
|
||||
);
|
||||
}
|
||||
|
||||
$dontCare = NULL;
|
||||
CRM_Core_OptionGroup::createAssoc('currencies_enabled', $options, $dontCare);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getAvailableCountries() {
|
||||
$i18n = CRM_Core_I18n::singleton();
|
||||
$country = array();
|
||||
CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
|
||||
$i18n->localizeArray($country, array('context' => 'country'));
|
||||
asort($country);
|
||||
return $country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default locale options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getDefaultLocaleOptions() {
|
||||
$domain = new CRM_Core_DAO_Domain();
|
||||
$domain->find(TRUE);
|
||||
$locales = CRM_Core_I18n::languages();
|
||||
if ($domain->locales) {
|
||||
// for multi-lingual sites, populate default language drop-down with available languages
|
||||
$defaultLocaleOptions = array();
|
||||
foreach ($locales as $loc => $lang) {
|
||||
if (substr_count($domain->locales, $loc)) {
|
||||
$defaultLocaleOptions[$loc] = $lang;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$defaultLocaleOptions = $locales;
|
||||
}
|
||||
return $defaultLocaleOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of currencies (with their symbols).
|
||||
*
|
||||
* @return array
|
||||
* Array('USD' => 'USD ($)').
|
||||
*/
|
||||
public static function getCurrencySymbols() {
|
||||
$symbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array(
|
||||
'labelColumn' => 'symbol',
|
||||
'orderColumn' => TRUE,
|
||||
));
|
||||
$_currencySymbols = array();
|
||||
foreach ($symbols as $key => $value) {
|
||||
$_currencySymbols[$key] = "$key";
|
||||
if ($value) {
|
||||
$_currencySymbols[$key] .= " ($value)";
|
||||
}
|
||||
}
|
||||
return $_currencySymbols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update session and uf_match table when the locale is updated.
|
||||
*
|
||||
* @param string $oldLocale
|
||||
* @param string $newLocale
|
||||
* @param array $metadata
|
||||
* @param int $domainID
|
||||
*/
|
||||
public static function onChangeLcMessages($oldLocale, $newLocale, $metadata, $domainID) {
|
||||
if ($oldLocale == $newLocale) {
|
||||
return;
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
if ($newLocale && $session->get('userID')) {
|
||||
$ufm = new CRM_Core_DAO_UFMatch();
|
||||
$ufm->contact_id = $session->get('userID');
|
||||
if ($newLocale && $ufm->find(TRUE)) {
|
||||
$ufm->language = $newLocale;
|
||||
$ufm->save();
|
||||
$session->set('lcMessages', $newLocale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function onChangeDefaultCurrency($oldCurrency, $newCurrency, $metadata) {
|
||||
if ($oldCurrency == $newCurrency) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure that default currency is always in the list of enabled currencies
|
||||
$currencies = array_keys(CRM_Core_OptionGroup::values('currencies_enabled'));
|
||||
if (!in_array($newCurrency, $currencies)) {
|
||||
if (empty($currencies)) {
|
||||
$currencies = array($values['defaultCurrency']);
|
||||
}
|
||||
else {
|
||||
$currencies[] = $newCurrency;
|
||||
}
|
||||
|
||||
CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies($currencies, $newCurrency);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getDefaultLanguageOptions() {
|
||||
return array(
|
||||
'*default*' => ts('Use default site language'),
|
||||
'undefined' => ts('Leave undefined'),
|
||||
'current_site_language' => ts('Use language in use at the time'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
80
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Mail.php
Normal file
80
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Mail.php
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for CiviMail.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Mail extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'mailerBatchLimit' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
|
||||
'mailThrottleTime' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
|
||||
'mailerJobSize' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
|
||||
'mailerJobsMax' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
|
||||
'verpSeparator' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
|
||||
'replyTo' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - CiviMail'));
|
||||
$this->addFormRule(array('CRM_Admin_Form_Setting_Mail', 'formRule'));
|
||||
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
$errors = array();
|
||||
|
||||
if (CRM_Utils_Array::value('mailerJobSize', $fields) > 0) {
|
||||
if (CRM_Utils_Array::value('mailerJobSize', $fields) < 1000) {
|
||||
$errors['mailerJobSize'] = ts('The job size must be at least 1000 or set to 0 (unlimited).');
|
||||
}
|
||||
elseif (CRM_Utils_Array::value('mailerJobSize', $fields) <
|
||||
CRM_Utils_Array::value('mailerBatchLimit', $fields)
|
||||
) {
|
||||
$errors['mailerJobSize'] = ts('A job size smaller than the batch limit will negate the effect of the batch limit.');
|
||||
}
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
}
|
90
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Mapping.php
Normal file
90
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Mapping.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Mapping and Geocoding.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Mapping extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'mapAPIKey' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
|
||||
'mapProvider' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
|
||||
'geoAPIKey' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
|
||||
'geoProvider' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - Mapping and Geocoding Providers'));
|
||||
parent::buildQuickForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
*
|
||||
* @return bool|array
|
||||
* true if no errors, else array of errors
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
$errors = array();
|
||||
|
||||
if (!CRM_Utils_System::checkPHPVersion(5, FALSE)) {
|
||||
$errors['_qf_default'] = ts('Mapping features require PHP version 5 or greater');
|
||||
}
|
||||
|
||||
if (!$fields['mapAPIKey'] && ($fields['mapProvider'] != '' && $fields['mapProvider'] == 'Yahoo')) {
|
||||
$errors['mapAPIKey'] = "Map Provider key is a required field.";
|
||||
}
|
||||
|
||||
if ($fields['mapProvider'] == 'OpenStreetMaps' && $fields['geoProvider'] == '') {
|
||||
$errors['geoProvider'] = "Please select a Geocoding Provider - Open Street Maps does not provide geocoding.";
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the rules (mainly global rules) for form.
|
||||
*
|
||||
* All local rules are added near the element
|
||||
*/
|
||||
public function addRules() {
|
||||
$this->addFormRule(array('CRM_Admin_Form_Setting_Mapping', 'formRule'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Miscellaneous.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'max_attachments' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'contact_undelete' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'empoweredBy' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'logging' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'maxFileSize' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'recordGeneratedLetters' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'secondDegRelPermissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'checksum_timeout' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'recaptchaOptions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'recaptchaPublicKey' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'recaptchaPrivateKey' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'wkhtmltopdfPath' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'recentItemsMaxCount' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'recentItemsProviders' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'dedupe_default_limit' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
'remote_profile_submissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
public $_uploadMaxSize;
|
||||
|
||||
/**
|
||||
* Basic setup.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_uploadMaxSize = (int) ini_get('upload_max_filesize');
|
||||
// check for post max size
|
||||
CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
|
||||
// This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but
|
||||
// we haven't worked through NOT doing that. These settings have been un-hardcoded.
|
||||
$this->assign('pure_config_settings', array(
|
||||
'empoweredBy',
|
||||
'max_attachments',
|
||||
'maxFileSize',
|
||||
'secondDegRelPermissions',
|
||||
'recentItemsMaxCount',
|
||||
'recentItemsProviders',
|
||||
'dedupe_default_limit',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
|
||||
|
||||
$this->assign('validTriggerPermission', CRM_Core_DAO::checkTriggerViewPermission(FALSE));
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
|
||||
|
||||
parent::buildQuickForm();
|
||||
$this->addRule('checksum_timeout', ts('Value should be a positive number'), 'positiveInteger');
|
||||
}
|
||||
|
||||
/**
|
||||
* Global form rule.
|
||||
*
|
||||
* @param array $fields
|
||||
* The input form values.
|
||||
* @param array $files
|
||||
* The uploaded files if any.
|
||||
* @param array $options
|
||||
* Additional user data.
|
||||
*
|
||||
* @return bool|array
|
||||
* true if no errors, else array of errors
|
||||
*/
|
||||
public static function formRule($fields, $files, $options) {
|
||||
$errors = array();
|
||||
|
||||
// validate max file size
|
||||
if ($fields['maxFileSize'] > $options->_uploadMaxSize) {
|
||||
$errors['maxFileSize'] = ts("Maximum file size cannot exceed Upload max size ('upload_max_filesize') as defined in PHP.ini.");
|
||||
}
|
||||
|
||||
// validate recent items stack size
|
||||
if ($fields['recentItemsMaxCount'] && ($fields['recentItemsMaxCount'] < 1 || $fields['recentItemsMaxCount'] > CRM_Utils_Recent::MAX_ITEMS)) {
|
||||
$errors['recentItemsMaxCount'] = ts("Illegal stack size. Use values between 1 and %1.", array(1 => CRM_Utils_Recent::MAX_ITEMS));
|
||||
}
|
||||
|
||||
if (!empty($fields['wkhtmltopdfPath'])) {
|
||||
// check and ensure that thi leads to the wkhtmltopdf binary
|
||||
// and it is a valid executable binary
|
||||
// Only check the first space separated piece to allow for a value
|
||||
// such as /usr/bin/xvfb-run -- wkhtmltopdf (CRM-13292)
|
||||
$pieces = explode(' ', $fields['wkhtmltopdfPath']);
|
||||
$path = $pieces[0];
|
||||
if (
|
||||
!file_exists($path) ||
|
||||
!is_executable($path)
|
||||
) {
|
||||
$errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid');
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
}
|
81
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Path.php
Normal file
81
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Path.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for File System Path.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Path extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'uploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
|
||||
'imageUploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
|
||||
'customFileUploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
|
||||
'customTemplateDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
|
||||
'customPHPPathDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
|
||||
'extensionsDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - Upload Directories'));
|
||||
parent::buildQuickForm();
|
||||
|
||||
$directories = array(
|
||||
'uploadDir' => ts('Temporary Files'),
|
||||
'imageUploadDir' => ts('Images'),
|
||||
'customFileUploadDir' => ts('Custom Files'),
|
||||
'customTemplateDir' => ts('Custom Templates'),
|
||||
'customPHPPathDir' => ts('Custom PHP Path Directory'),
|
||||
'extensionsDir' => ts('CiviCRM Extensions Directory'),
|
||||
);
|
||||
foreach ($directories as $name => $title) {
|
||||
//$this->add('text', $name, $title);
|
||||
$this->addRule($name,
|
||||
ts("'%1' directory does not exist",
|
||||
array(1 => $title)
|
||||
),
|
||||
'settingPath'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
parent::postProcess();
|
||||
|
||||
parent::rebuildMenu();
|
||||
}
|
||||
|
||||
}
|
108
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Search.php
Normal file
108
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Search.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Search Parameters
|
||||
*
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting {
|
||||
|
||||
protected $_settings = array(
|
||||
'contact_reference_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'contact_autocomplete_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'search_autocomplete_count' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'enable_innodb_fts' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'includeWildCardInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'includeEmailInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'includeNickNameInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'includeAlphabeticalPager' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'includeOrderByClause' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'smartGroupCacheTimeout' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'defaultSearchProfileID' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
'searchPrimaryDetailsOnly' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
|
||||
);
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::setTitle(ts('Settings - Search Preferences'));
|
||||
|
||||
parent::buildQuickForm();
|
||||
|
||||
// @todo remove the following adds in favour of setting via the settings array (above).
|
||||
|
||||
// Autocomplete for Contact Search (quick search etc.)
|
||||
$element = $this->getElement('contact_autocomplete_options');
|
||||
$element->_elements[0]->_flagFrozen = TRUE;
|
||||
|
||||
// Autocomplete for Contact Reference (custom fields)
|
||||
$element = $this->getElement('contact_reference_options');
|
||||
$element->_elements[0]->_flagFrozen = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getContactAutocompleteOptions() {
|
||||
return array(
|
||||
ts('Contact Name') => 1,
|
||||
) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
|
||||
FALSE, FALSE, TRUE
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getAvailableProfiles() {
|
||||
return array('' => ts('- none -')) + CRM_Core_BAO_UFGroup::getProfiles(array(
|
||||
'Contact',
|
||||
'Individual',
|
||||
'Organization',
|
||||
'Household',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getContactReferenceOptions() {
|
||||
return array(
|
||||
ts('Contact Name') => 1,
|
||||
) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
|
||||
FALSE, FALSE, TRUE
|
||||
));
|
||||
}
|
||||
|
||||
}
|
265
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Smtp.php
Normal file
265
sites/all/modules/civicrm/CRM/Admin/Form/Setting/Smtp.php
Normal file
|
@ -0,0 +1,265 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Smtp Server.
|
||||
*/
|
||||
class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
|
||||
protected $_testButtonName;
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
$outBoundOption = array(
|
||||
CRM_Mailing_Config::OUTBOUND_OPTION_MAIL => ts('mail()'),
|
||||
CRM_Mailing_Config::OUTBOUND_OPTION_SMTP => ts('SMTP'),
|
||||
CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL => ts('Sendmail'),
|
||||
CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED => ts('Disable Outbound Email'),
|
||||
CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB => ts('Redirect to Database'),
|
||||
);
|
||||
$this->addRadio('outBound_option', ts('Select Mailer'), $outBoundOption);
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Settings - Outbound Mail'));
|
||||
$this->add('text', 'sendmail_path', ts('Sendmail Path'));
|
||||
$this->add('text', 'sendmail_args', ts('Sendmail Argument'));
|
||||
$this->add('text', 'smtpServer', ts('SMTP Server'));
|
||||
$this->add('text', 'smtpPort', ts('SMTP Port'));
|
||||
$this->addYesNo('smtpAuth', ts('Authentication?'));
|
||||
$this->addElement('text', 'smtpUsername', ts('SMTP Username'));
|
||||
$this->addElement('password', 'smtpPassword', ts('SMTP Password'));
|
||||
|
||||
$this->_testButtonName = $this->getButtonName('refresh', 'test');
|
||||
|
||||
$this->addFormRule(array('CRM_Admin_Form_Setting_Smtp', 'formRule'));
|
||||
parent::buildQuickForm();
|
||||
$buttons = $this->getElement('buttons')->getElements();
|
||||
$buttons[] = $this->createElement('submit', $this->_testButtonName, ts('Save & Send Test Email'), array('crm-icon' => 'fa-envelope-o'));
|
||||
$this->getElement('buttons')->setElements($buttons);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// flush caches so we reload details for future requests
|
||||
// CRM-11967
|
||||
CRM_Utils_System::flushCache();
|
||||
|
||||
$formValues = $this->controller->exportValues($this->_name);
|
||||
|
||||
$buttonName = $this->controller->getButtonName();
|
||||
// check if test button
|
||||
if ($buttonName == $this->_testButtonName) {
|
||||
if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) {
|
||||
CRM_Core_Session::setStatus(ts('You have selected "Disable Outbound Email". A test email can not be sent.'), ts("Email Disabled"), "error");
|
||||
}
|
||||
elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB) {
|
||||
CRM_Core_Session::setStatus(ts('You have selected "Redirect to Database". A test email can not be sent.'), ts("Email Disabled"), "error");
|
||||
}
|
||||
else {
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$userID = $session->get('userID');
|
||||
list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
|
||||
|
||||
//get the default domain email address.CRM-4250
|
||||
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
|
||||
|
||||
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
|
||||
$fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1');
|
||||
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
|
||||
}
|
||||
|
||||
if (!$toEmail) {
|
||||
CRM_Core_Error::statusBounce(ts('Cannot send a test email because your user record does not have a valid email address.'));
|
||||
}
|
||||
|
||||
if (!trim($toDisplayName)) {
|
||||
$toDisplayName = $toEmail;
|
||||
}
|
||||
|
||||
$to = '"' . $toDisplayName . '"' . "<$toEmail>";
|
||||
$from = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
|
||||
$testMailStatusMsg = ts('Sending test email. FROM: %1 TO: %2.<br />', array(
|
||||
1 => $domainEmailAddress,
|
||||
2 => $toEmail,
|
||||
));
|
||||
|
||||
$params = array();
|
||||
if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
|
||||
$subject = "Test for SMTP settings";
|
||||
$message = "SMTP settings are correct.";
|
||||
|
||||
$params['host'] = $formValues['smtpServer'];
|
||||
$params['port'] = $formValues['smtpPort'];
|
||||
|
||||
if ($formValues['smtpAuth']) {
|
||||
$params['username'] = $formValues['smtpUsername'];
|
||||
$params['password'] = $formValues['smtpPassword'];
|
||||
$params['auth'] = TRUE;
|
||||
}
|
||||
else {
|
||||
$params['auth'] = FALSE;
|
||||
}
|
||||
|
||||
// set the localhost value, CRM-3153, CRM-9332
|
||||
$params['localhost'] = $_SERVER['SERVER_NAME'];
|
||||
|
||||
// also set the timeout value, lets set it to 30 seconds
|
||||
// CRM-7510, CRM-9332
|
||||
$params['timeout'] = 30;
|
||||
|
||||
$mailerName = 'smtp';
|
||||
}
|
||||
elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) {
|
||||
$subject = "Test for Sendmail settings";
|
||||
$message = "Sendmail settings are correct.";
|
||||
$params['sendmail_path'] = $formValues['sendmail_path'];
|
||||
$params['sendmail_args'] = $formValues['sendmail_args'];
|
||||
$mailerName = 'sendmail';
|
||||
}
|
||||
elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MAIL) {
|
||||
$subject = "Test for PHP mail settings";
|
||||
$message = "mail settings are correct.";
|
||||
$mailerName = 'mail';
|
||||
}
|
||||
|
||||
$headers = array(
|
||||
'From' => $from,
|
||||
'To' => $to,
|
||||
'Subject' => $subject,
|
||||
);
|
||||
|
||||
$mailer = Mail::factory($mailerName, $params);
|
||||
|
||||
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
|
||||
$result = $mailer->send($toEmail, $headers, $message);
|
||||
unset($errorScope);
|
||||
if (defined('CIVICRM_MAIL_LOG')) {
|
||||
CRM_Core_Session::setStatus($testMailStatusMsg . ts('You have defined CIVICRM_MAIL_LOG - no mail will be sent. Your %1 settings have not been tested.', array(1 => strtoupper($mailerName))), ts("Mail not sent"), "warning");
|
||||
}
|
||||
elseif (!is_a($result, 'PEAR_Error')) {
|
||||
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', array(1 => strtoupper($mailerName))), ts("Mail Sent"), "success");
|
||||
}
|
||||
else {
|
||||
$message = CRM_Utils_Mail::errorMessage($mailer, $result);
|
||||
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Oops. Your %1 settings are incorrect. No test mail has been sent.', array(1 => strtoupper($mailerName))) . $message, ts("Mail Not Sent"), "error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mailingBackend = Civi::settings()->get('mailing_backend');
|
||||
|
||||
if (!empty($mailingBackend)) {
|
||||
$formValues = array_merge($mailingBackend, $formValues);
|
||||
}
|
||||
|
||||
// if password is present, encrypt it
|
||||
if (!empty($formValues['smtpPassword'])) {
|
||||
$formValues['smtpPassword'] = CRM_Utils_Crypt::encrypt($formValues['smtpPassword']);
|
||||
}
|
||||
|
||||
Civi::settings()->set('mailing_backend', $formValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global validation rules for the form.
|
||||
*
|
||||
* @param array $fields
|
||||
* Posted values of the form.
|
||||
*
|
||||
* @return array
|
||||
* list of errors to be posted back to the form
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
if ($fields['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
|
||||
if (empty($fields['smtpServer'])) {
|
||||
$errors['smtpServer'] = 'SMTP Server name is a required field.';
|
||||
}
|
||||
if (empty($fields['smtpPort'])) {
|
||||
$errors['smtpPort'] = 'SMTP Port is a required field.';
|
||||
}
|
||||
if (!empty($fields['smtpAuth'])) {
|
||||
if (empty($fields['smtpUsername'])) {
|
||||
$errors['smtpUsername'] = 'If your SMTP server requires authentication please provide a valid user name.';
|
||||
}
|
||||
if (empty($fields['smtpPassword'])) {
|
||||
$errors['smtpPassword'] = 'If your SMTP server requires authentication, please provide a password.';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($fields['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) {
|
||||
if (!$fields['sendmail_path']) {
|
||||
$errors['sendmail_path'] = 'Sendmail Path is a required field.';
|
||||
}
|
||||
if (!$fields['sendmail_args']) {
|
||||
$errors['sendmail_args'] = 'Sendmail Argument is a required field.';
|
||||
}
|
||||
}
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
if (!$this->_defaults) {
|
||||
$this->_defaults = array();
|
||||
|
||||
$mailingBackend = Civi::settings()->get('mailing_backend');
|
||||
if (!empty($mailingBackend)) {
|
||||
$this->_defaults = $mailingBackend;
|
||||
|
||||
if (!empty($this->_defaults['smtpPassword'])) {
|
||||
$this->_defaults['smtpPassword'] = CRM_Utils_Crypt::decrypt($this->_defaults['smtpPassword']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!isset($this->_defaults['smtpServer'])) {
|
||||
$this->_defaults['smtpServer'] = 'localhost';
|
||||
$this->_defaults['smtpPort'] = 25;
|
||||
$this->_defaults['smtpAuth'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($this->_defaults['sendmail_path'])) {
|
||||
$this->_defaults['sendmail_path'] = '/usr/sbin/sendmail';
|
||||
$this->_defaults['sendmail_args'] = '-i';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->_defaults;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue