3
* © Copyright 2009 IntraHealth International, Inc.
5
* This File is part of I2CE
7
* I2CE is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
* @package ihris-common
21
* @author Carl Leitner <litlfred@ibiblio.org>
27
* Class iHRIS_Module_PrivateFacility
33
class iHRIS_Module_PrivateFacility extends I2CE_Module {
38
* Return the array of hooks available in this module.
41
public static function getHooks() {
43
'validate_form_privatefacility' => 'validate_form_privatefacility',
48
* Perform extra validation for the privatefacility form.
49
* A new privatefacility record needs to verify there aren't any existing
50
* records with the same name.
51
* @param I2CE_Form $form
53
public function validate_form_privatefacility( $form ) {
57
if ( isset( $form->name_ignore ) ) {
58
$name_ignore = $form->name_ignore;
60
if ( I2CE_ModuleFactory::instance()->isEnabled('forms-storage')
61
&& $form->getId() == 0 && !$name_ignore
62
&& I2CE_Validate::checkString( $form->name )) {
67
'operator'=>'FIELD_LIMIT',
69
'style'=>'lowerequals',
70
'data'=>array('value'=>strtolower($form->name))
74
$results = I2CE_FormStorage::listFields('privatefacility',array('name'),false,$where,array('name'));
75
if( count($results) > 0 ) {
76
foreach ($results as $id=>&$data) {
77
$data = implode(', ', $data);
79
$form->getField('name')->setInvalid( "Duplicate records match this record's name:",
80
array( "view?id=" => $results ) );
90
# c-default-style: "bsd"
91
# indent-tabs-mode: nil