<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
class CRM_Contact_Form_Task_AddToOrganization extends CRM_Contact_Form_Task {
/**
- * Build the form
+ * Build the form object
*
- * @access public
*
* @return void
*/
- function preProcess() {
+ public function preProcess() {
// initialize the task and row fields
parent::preProcess();
}
/**
- * Function to build the form
+ * Build the form object
*
- * @access public
*
- * @return None
+ * @return void
*/
- function buildQuickForm() {
+ public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Add Contacts to Organization'));
$this->addElement('text', 'name', ts('Find Target Organization'));
'relationship_type_id',
ts('Relationship Type'),
array(
- '' => ts('- select -')) +
+ '' => ts('- select -'),
+ ) +
CRM_Contact_BAO_Relationship::getRelationType("Organization"), TRUE
);
$this->assign('searchRows', $searchRows);
}
-
$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', ts('Organization'));
- $this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'form-submit'));
- $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'form-submit'));
-
+ $this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit'));
+ $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit'));
$this->addButtons(array(
array(
}
/**
- * process the form after the input has been submitted and validated
+ * Process the form after the input has been submitted and validated
*
- * @access public
*
- * @return None
+ * @return void
*/
public function postProcess() {
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$this->set('searchDone', 0);
- if (CRM_Utils_Array::value('_qf_AddToOrganization_refresh', $_POST)) {
+ if (!empty($_POST['_qf_AddToOrganization_refresh'])) {
$searchParams['contact_type'] = array('Organization' => 'Organization');
$searchParams['rel_contact'] = $params['name'];
CRM_Contact_Form_Task_AddToHousehold::search($this, $searchParams);
}
if (CRM_Contact_BAO_Relationship::checkDuplicateRelationship($params,
- CRM_Utils_Array::value('contact', $ids),
- // step 2
- $params['contact_check']
- )) {
+ CRM_Utils_Array::value('contact', $ids),
+ // step 2
+ $params['contact_check']
+ )
+ ) {
$duplicate++;
continue;
}
list($rtype, $a_b) = explode('_', $data['relationship_type_id'], 2);
$relationship = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $rtype, "label_$a_b");
- $status = array(ts('%count %2 %3 relationship created', array('count' => $valid, 'plural' => '%count %2 %3 relationships created', 2 => $relationship, 3 => $org)));
+ $status = array(
+ ts('%count %2 %3 relationship created', array(
+ 'count' => $valid,
+ 'plural' => '%count %2 %3 relationships created',
+ 2 => $relationship,
+ 3 => $org,
+ )),
+ );
if ($duplicate) {
- $status[] = ts('%count was skipped because the contact is already %2 %3', array('count' => $duplicate, 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationship, 3 => $org));
+ $status[] = ts('%count was skipped because the contact is already %2 %3', array(
+ 'count' => $duplicate,
+ 'plural' => '%count were skipped because the contacts are already %2 %3',
+ 2 => $relationship,
+ 3 => $org,
+ ));
}
if ($invalid) {
- $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array('count' => $invalid, 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship'));
+ $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array(
+ 'count' => $invalid,
+ 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship',
+ ));
}
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
- CRM_Core_Session::setStatus($status, ts('Relationship Created', array('count' => $valid, 'plural' => 'Relationships Created')), 'success', array('expires' => 0));
+ CRM_Core_Session::setStatus($status, ts('Relationship created.', array(
+ 'count' => $valid,
+ 'plural' => 'Relationships created.',
+ )), 'success', array('expires' => 0));
}
}