Attachment 'template.php'

Download

   1 <?php
   2 
   3 /*
   4  +--------------------------------------------------------------------+
   5  | CiviCRM version 3.3                                                |
   6  +--------------------------------------------------------------------+
   7  | Copyright CiviCRM LLC (c) 2004-2010                                |
   8  +--------------------------------------------------------------------+
   9  | This file is a part of CiviCRM.                                    |
  10  |                                                                    |
  11  | CiviCRM is free software; you can copy, modify, and distribute it  |
  12  | under the terms of the GNU Affero General Public License           |
  13  | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
  14  |                                                                    |
  15  | CiviCRM is distributed in the hope that it will be useful, but     |
  16  | WITHOUT ANY WARRANTY; without even the implied warranty of         |
  17  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
  18  | See the GNU Affero General Public License for more details.        |
  19  |                                                                    |
  20  | You should have received a copy of the GNU Affero General Public   |
  21  | License and the CiviCRM Licensing Exception along                  |
  22  | with this program; if not, contact CiviCRM LLC                     |
  23  | at info[AT]civicrm[DOT]org. If you have questions about the        |
  24  | GNU Affero General Public License or the licensing of CiviCRM,     |
  25  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  26  +--------------------------------------------------------------------+
  27 */
  28 
  29 /**
  30  *
  31  * @package CRM
  32  * @copyright CiviCRM LLC (c) 2004-2010
  33  * $Id$
  34  *
  35  */
  36 
  37 require_once 'CRM/Contact/Form/Search/Custom/Base.php';
  38 
  39 class CRM_Contact_Form_Search_Custom_SEARCHNAME
  40    extends    CRM_Contact_Form_Search_Custom_Base
  41    implements CRM_Contact_Form_Search_Interface {
  42 
  43     function __construct( &$formValues ) {
  44         parent::__construct( $formValues );
  45 
  46         $this->_columns = array(
  47           ts('Contact Id')   => 'contact_id'  ,
  48           ts('Name')         => 'sort_name',
  49           // Add fields here
  50 				);
  51     }
  52 
  53     function buildForm( &$form ) {
  54 				$this->setTitle("SEARCHTITLE");
  55 
  56         $form->assign( 'elements', array(/* Add field names here */) );
  57 
  58     }
  59 
  60     function summary( ) {
  61         $summary = array( 'summary' => 'This is a summary',
  62                           'total' => 0 );
  63         return $summary;
  64     }
  65 
  66     function all( $offset = 0, $rowcount = 0, $sort = null,
  67                   $includeContactIDs = false ) {
  68         $selectClause = "...";
  69 
  70 				$groupBy = NULL;
  71 
  72         return $this->sql( $selectClause,
  73                            $offset, $rowcount, $sort,
  74                            $includeContactIDs, $groupBy );
  75 
  76     }
  77 
  78     function from( ) {
  79         return "FROM ...";
  80     }
  81 
  82     function where( $includeContactIDs = false ) {
  83 
  84         $where  = "...";
  85 
  86         $params = array( );
  87 
  88 				$count  = 1;
  89 				$clauses = array( );
  90 
  91 				$value = CRM_Utils_Array::value( 'FORMVALUE', $this->_formValues );
  92 				if ($value != '') {
  93 					$params[$count] = array( $value, /* CHOOSE EITHER 'Integer' 'String' ... */ );
  94 					$clauses[] = "TABLE.COLUMN = %{$count}";
  95 					$count++;
  96 				}
  97 
  98         if ( ! empty( $clauses ) ) {
  99             $where .= ' AND ' . implode( ' AND ', $clause );
 100         }
 101 
 102         return $this->whereClause( $where, $params );
 103     }
 104 
 105     function templateFile( ) {
 106         return 'CRM/Contact/Form/Search/Custom.tpl';
 107     }
 108 
 109     function setDefaultValues( ) {
 110         // return array( 'FORMVALUE'    => VALUE );
 111     }
 112 
 113     function alterRow( &$row ) {
 114         // $row['COLUMN'] = NEWVALUE;
 115     }
 116 
 117     function setTitle( $title ) {
 118         if ( $title ) {
 119             CRM_Utils_System::setTitle( $title );
 120         } else {
 121             CRM_Utils_System::setTitle(ts('Search'));
 122         }
 123     }
 124 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-04-02 21:02:00, 3.8 KB) [[attachment:template.php]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.