示例#1
0
/**
 * Implementation of hook_civicrm_install
 */
function hrvisa_civicrm_install()
{
    if (!CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name')) {
        // create activity_type 'Visa Expiration'
        $params = array('weight' => 1, 'label' => 'Visa Expiration', 'filter' => 0, 'is_active' => 1, 'is_default' => 0);
        $result = civicrm_api3('activity_type', 'create', $params);
        if (CRM_Utils_Array::value('is_error', $result, FALSE)) {
            CRM_Core_Error::debug_var("Failed to create activity type 'Visa  Expiration'", $result);
            throw new CRM_Core_Exception('Failed to create activity type \'Visa  Expiration\'');
        }
        $activityTypeId = $result['values'][$result['id']]['value'];
    } else {
        $activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name');
    }
    // set weekly reminder for Visa Expiration activities (not active)
    // will be active when extension is enabled
    if (!empty($activityTypeId)) {
        $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
        $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
        // schedule reminder for Visa Expiration Creation
        $result = civicrm_api3('action_schedule', 'get', array('name' => 'Visa Expiration Reminder'));
        if (empty($result['id'])) {
            $params = array('name' => 'Visa Expiration Reminder', 'title' => 'Visa Expiration Reminder', 'recipient' => $targetID, 'limit_to' => 1, 'entity_value' => $activityTypeId, 'entity_status' => CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'), 'start_action_offset' => 1, 'start_action_unit' => 'week', 'start_action_condition' => 'before', 'start_action_date' => 'activity_date_time', 'is_repeat' => 0, 'is_active' => 0, 'body_html' => '<p>Your latest visa expiries on {activity.activity_date_time}</p>', 'subject' => 'Reminder for Visa Expiration', 'record_activity' => 1, 'mapping_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'activity_type', 'id', 'entity_value'));
            $result = civicrm_api3('action_schedule', 'create', $params);
        }
    }
    return _hrvisa_civix_civicrm_install();
}
示例#2
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     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'));
     require_once 'CRM/Contact/BAO/ContactType.php';
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
     // add select for contact type
     $contactTypeA =& $this->add('select', 'contact_types_a', ts('Contact Type A') . ' ', array('' => ts('- select -')) + $contactTypes);
     $contactTypeB =& $this->add('select', 'contact_types_b', ts('Contact Type B') . ' ', array('' => ts('- select -')) + $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();
         $url = CRM_Utils_System::url('civicrm/admin/reltype&reset=1');
         $location = "window.location='{$url}'";
         $this->addElement('button', 'done', ts('Done'), array('onclick' => $location));
     }
 }
示例#3
0
文件: Cxn.php 项目: kidaa30/yes
 /**
  * Get the AppMeta for an existing connection.
  *
  * @param string $cxnId
  * @return array
  * @throws \Civi\Cxn\Rpc\Exception\CxnException
  */
 public static function getAppMeta($cxnId)
 {
     $appMetaJson = CRM_Core_DAO::getFieldValue('CRM_Cxn_DAO_Cxn', $cxnId, 'app_meta', 'cxn_guid', TRUE);
     $appMeta = json_decode($appMetaJson, TRUE);
     \Civi\Cxn\Rpc\AppMeta::validate($appMeta);
     return $appMeta;
 }
示例#4
0
 /**
  * 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'));
         }
     }
 }
示例#5
0
 /**
  * Alter display of rows.
  *
  * Iterate through the rows retrieved via SQL and make changes for display purposes,
  * such as rendering contacts as links.
  *
  * @param array $rows
  *   Rows generated by SQL, with an array for each row.
  */
 public function alterDisplay(&$rows)
 {
     // cache for id → is_deleted mapping
     $isDeleted = array();
     foreach ($rows as &$row) {
         if (!isset($isDeleted[$row['civicrm_contact_is_deleted']])) {
             $isDeleted[$row['civicrm_contact_is_deleted']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['civicrm_contact_altered_contact_id'], 'is_deleted') !== '0';
         }
         if (!$isDeleted[$row['civicrm_contact_is_deleted']]) {
             $row['civicrm_contact_altered_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contribution_contact_id']);
             $row['civicrm_contact_altered_contact_display_name_hover'] = ts('Go to contact summary');
         }
         $row['civicrm_contact_altered_by_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contribution_log_user_id']);
         $row['civicrm_contact_altered_by_display_name_hover'] = ts('Go to contact summary');
         if ($row['civicrm_contact_altered_contact_is_deleted'] and $row['log_civicrm_contribution_log_action'] == 'Update') {
             $row['log_civicrm_contribution_log_action'] = ts('Delete');
         }
         if ($row['log_civicrm_contribution_log_action'] == 'Update') {
             $q = "reset=1&log_conn_id={$row['log_civicrm_contribution_log_conn_id']}&log_date={$row['log_civicrm_contribution_log_date']}";
             if ($this->cid) {
                 $q .= '&cid=' . $this->cid;
             }
             $url = CRM_Report_Utils_Report::getNextUrl('logging/contribute/detail', $q, FALSE, TRUE);
             $row['log_civicrm_contribution_log_action_link'] = $url;
             $row['log_civicrm_contribution_log_action_hover'] = ts('View details for this update');
             $row['log_civicrm_contribution_log_action'] = '<div class="icon ui-icon-zoomin"></div> ' . ts('Update');
         }
         unset($row['log_civicrm_contribute_log_user_id']);
         unset($row['log_civicrm_contribute_log_conn_id']);
     }
 }
 /**
  * @param string $caseType
  * @return SimpleXMLElement|FALSE
  */
 public function retrieve($caseType)
 {
     // check if xml definition is defined in db
     $definition = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $caseType, 'definition', 'name');
     if (!empty($definition)) {
         list($xml, $error) = CRM_Utils_XML::parseString($definition);
         if (!$xml) {
             throw new CRM_Core_Exception("Failed to parse CaseType XML: {$error}");
         }
         return $xml;
     }
     // TODO In 4.6 or 5.0, remove support for weird machine-names
     //if (!CRM_Case_BAO_CaseType::isValidName($caseType)) {
     //  // perhaps caller provider a the label instead of the name?
     //  throw new CRM_Core_Exception("Cannot load caseType with malformed name [$caseType]");
     //}
     if (!CRM_Utils_Array::value($caseType, $this->xml)) {
         $fileXml = $this->retrieveFile($caseType);
         if ($fileXml) {
             $this->xml[$caseType] = $fileXml;
         } else {
             return FALSE;
         }
     }
     return $this->xml[$caseType];
 }
示例#7
0
 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues(&$form)
 {
     $defaults = array();
     // Retrieve current case status
     $defaults['case_status_id'] = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $this->_caseId, 'status_id', 'id');
     return $defaults;
 }
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 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();
     }
 }
示例#9
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     // Register 'contact_1' model
     $entities = array();
     $entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
     $allowCoreTypes = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
     $allowSubTypes = array();
     // Register 'contribution_1'
     $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'financial_type_id');
     $allowCoreTypes[] = 'Contribution';
     //CRM-15427
     $allowSubTypes['ContributionType'] = array($financialTypeId);
     $entities[] = array('entity_name' => 'contribution_1', 'entity_type' => 'ContributionModel', 'entity_sub_type' => '*');
     // If applicable, register 'membership_1'
     $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     if ($member && $member['is_active']) {
         //CRM-15427
         $entities[] = array('entity_name' => 'membership_1', 'entity_type' => 'MembershipModel', 'entity_sub_type' => '*');
         $allowCoreTypes[] = 'Membership';
         $allowSubTypes['MembershipType'] = explode(',', $member['membership_types']);
     }
     //CRM-15427
     $this->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
     $this->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this);
     parent::buildQuickForm();
 }
示例#10
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     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'));
     require_once 'CRM/Core/Permission.php';
     $permissions = CRM_Core_Permission::basicPermissions(true);
     $include =& $this->addElement('advmultiselect', 'permission', ts('Permission') . ' ', $permissions, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $include->setButtonAttributes('add', array('value' => ts('Add >>')));
     $include->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $operators = array('AND' => 'AND', 'OR' => 'OR');
     $this->add('select', 'permission_operator', ts('Operator'), $operators);
     $this->add('checkbox', 'has_separator', ts('Separator?'));
     $active = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($this->_defaults['name'] == '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]);
         $parent = $this->add('select', 'parent_id', ts('Parent'), array('' => ts('-- select --')) + $parentMenu);
     }
 }
示例#11
0
 /**
  * Given a permission string, check for access requirements
  *
  * @param string $str
  *   The permission to check.
  *
  * @return bool
  *   true if yes, else false
  */
 public function check($str)
 {
     $config = CRM_Core_Config::singleton();
     $translated = $this->translateJoomlaPermission($str);
     if ($translated === CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
         return FALSE;
     }
     if ($translated === CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
         return TRUE;
     }
     // ensure that we are running in a joomla context
     // we've not yet figured out how to bootstrap joomla, so we should
     // not execute hooks if joomla is not loaded
     if (defined('_JEXEC')) {
         $user = JFactory::getUser();
         $api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
         // If we are coming from REST we don't have a user but we do have the api_key for a user.
         if ($user->id === 0 && !is_null($api_key)) {
             // This is a codeblock copied from /Civicrm/Utils/REST
             $uid = NULL;
             if (!$uid) {
                 $store = NULL;
                 $contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
                 if ($contact_id) {
                     $uid = CRM_Core_BAO_UFMatch::getUFId($contact_id);
                 }
                 $user = JFactory::getUser($uid);
             }
         }
         return $user->authorise($translated[0], $translated[1]);
     } else {
         return FALSE;
     }
 }
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if ($this->_id) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'name');
         CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Financial Type'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'name'), TRUE);
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'description'));
     $this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_deductible'));
     $this->add('checkbox', 'is_active', ts('Enabled?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_active'));
     $this->add('checkbox', 'is_reserved', ts('Reserved?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_reserved'));
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $this->assign('aid', $this->_id);
     }
     if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'is_reserved', 'vid')) {
         $this->freeze(array('is_active'));
     }
     //$this->addFormRule( array( 'CRM_Financial_Form_FinancialType', 'formRule'), $this );
 }
示例#13
0
 function fileDisplay()
 {
     // Display evidence file
     $postParams = $_POST;
     $fileID = CRM_Core_BAO_File::getEntityFile($postParams['entityTable'], $postParams['entityID']);
     if ($fileID) {
         foreach ($fileID as $k => $v) {
             $fileType = $v['mime_type'];
             $fid = $v['fileID'];
             $eid = $postParams['entityID'];
             if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || $fileType == 'image/gif' || $fileType == 'image/x-png' || $fileType == 'image/png') {
                 list($path) = CRM_Core_BAO_File::path($fid, $eid, NULL, NULL);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}", FALSE, NULL, TRUE, TRUE);
                 $file_url = "\n              <a href=\"{$url}\" class='crm-image-popup'>\n              <img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/>\n              </a>";
                 // for non image files
             } else {
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fid, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}");
                 $file_url = "<a href=\"{$url}\">{$uri}</a>";
             }
             if (isset($fid)) {
                 $deleteurl = "<div class=file-delete><a class='action-item crm-hover-button' href='javascript:void(0)' id=file_{$fid}>Delete Attached File</a></div>";
                 echo "<div id='del_{$fid}'>{$file_url}{$deleteurl}</div>";
             }
         }
     }
     CRM_Utils_System::civiExit();
 }
示例#14
0
 public function fetchExistingData(){
     $dao = new CRM_Contribite_DAO_MemberDuesDuration();
     $data['member_due_start_date'] = CRM_Core_DAO::getFieldValue('CRM_MemberDuesDuration_DAO_MemberDuesDuration', '1', 'start_date');
     $data['member_due_end_date'] = CRM_Core_DAO::getFieldValue('CRM_MemberDuesDuration_DAO_MemberDuesDuration', '1', 'end_date');
     return $data;
     
 }
示例#15
0
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('Financial Type'));
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if ($this->_id) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'name');
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'name'), TRUE);
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'description'));
     $this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_deductible'));
     $this->add('checkbox', 'is_active', ts('Enabled?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_active'));
     $this->add('checkbox', 'is_reserved', ts('Reserved?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_reserved'));
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $this->assign('aid', $this->_id);
     }
     if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'is_reserved', 'vid')) {
         $this->freeze(array('is_active'));
     }
     $this->addRule('name', ts('A financial type with this name already exists. Please select another name.'), 'objectExists', array('CRM_Financial_DAO_FinancialType', $this->_id));
 }
示例#16
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $dao = new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(TRUE)) {
         $cid = $dao->entity_id;
     }
     $dao = new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(TRUE)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
     }
     return parent::run();
 }
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('Financial Batch'));
     if (isset($this->_id)) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'title');
         CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Accounting Batch'));
         $this->assign('batchTitle', $this->_title);
         $contactID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'created_id');
         $contactName = CRM_Contact_BAO_Contact::displayName($contactID);
         $this->assign('contactName', $contactName);
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
         $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
         //unset exported status
         $exportedStatusId = CRM_Utils_Array::key('Exported', $batchStatus);
         unset($batchStatus[$exportedStatusId]);
         $this->add('select', 'status_id', ts('Batch Status'), array('' => ts('- select -')) + $batchStatus, TRUE);
         $this->freeze(array('status_id'));
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch');
     $this->add('text', 'title', ts('Batch Name'), $attributes['name'], TRUE);
     $this->add('textarea', 'description', ts('Description'), $attributes['description']);
     $this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE);
     $this->add('text', 'total', ts('Total Amount'), $attributes['total']);
     $this->add('text', 'item_count', ts('Number of Transactions'), $attributes['item_count']);
     $this->addFormRule(array('CRM_Financial_Form_FinancialBatch', 'formRule'), $this);
 }
示例#18
0
文件: SMS.php 项目: ksecor/civicrm
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Core_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $smsNumbers = CRM_Contact_BAO_Contact::allPhones($cid, 'Mobile');
         $this->_emails = array();
         $toName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name');
         foreach ($smsNumbers as $number => $item) {
             $this->_smsNumbers[$number] = '"' . $toName . '" <' . $number . '> ' . $item['locationType'];
             if ($item['is_primary']) {
                 $this->_smsNumbers[$number] .= ' ' . ts('(preferred)');
             }
             $this->_smsNumbers[$number] = htmlspecialchars($this->_emails[$email]);
         }
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
示例#19
0
 /**
  * Set variables up before form is built.
  *
  *
  * @return void
  */
 public function preProcess()
 {
     // current set id
     $this->_id = $this->get('id');
     if ($this->_id && ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_id, 'is_reserved', 'id'))) {
         CRM_Core_Error::fatal("You cannot edit the settings of a reserved custom field-set.");
     }
     // setting title for html page
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id);
         CRM_Utils_System::setTitle(ts('Edit %1', array(1 => $title)));
     } elseif ($this->_action == CRM_Core_Action::VIEW) {
         $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id);
         CRM_Utils_System::setTitle(ts('Preview %1', array(1 => $title)));
     } else {
         CRM_Utils_System::setTitle(ts('New Custom Field Set'));
     }
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Core_BAO_CustomGroup::retrieve($params, $this->_defaults);
         $subExtends = CRM_Utils_Array::value('extends_entity_column_value', $this->_defaults);
         if (!empty($subExtends)) {
             $this->_subtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subExtends, 1, -1));
         }
     }
 }
示例#20
0
 /**
  * Build the form object.
  *
  * @return void
  */
 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'));
 }
示例#21
0
 static function details($csID, $ssID = null, $gID = null)
 {
     $error = array(null, null, null);
     if (!$csID && !$ssID && !$gID) {
         return $error;
     }
     $customSearchID = $csID;
     $formValues = array();
     if ($ssID || $gID) {
         if ($gID) {
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $gID, 'saved_search_id');
         }
         $formValues = CRM_Contact_BAO_SavedSearch::getFormValues($ssID);
         $customSearchID = CRM_Utils_Array::value('customSearchID', $formValues);
     }
     if (!$customSearchID) {
         return $error;
     }
     // check that the csid exists in the db along with the right file
     // and implements the right interface
     require_once 'CRM/Core/OptionGroup.php';
     $customSearchClass = CRM_Core_OptionGroup::getLabel('custom_search', $customSearchID);
     if (!$customSearchClass) {
         return $error;
     }
     $customSearchFile = str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php';
     $error = (include_once $customSearchFile);
     if ($error == false) {
         CRM_Core_Error::fatal('Custom search file: ' . $customSearchFile . ' does not exist. Please verify your custom search settings in CiviCRM administrative panel.');
     }
     return array($customSearchID, $customSearchClass, $formValues);
 }
示例#22
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $id = CRM_Utils_Request::retrieve('id', $this);
     $dao =& new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(true)) {
         $cid = $dao->entity_id;
     }
     require_once 'CRM/SMS/DAO/History.php';
     $dao =& new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(true)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         require_once 'CRM/Utils/Menu.php';
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         require_once 'CRM/Core/BAO/CustomGroup.php';
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
     }
     parent::run();
 }
 /**
  * Add relationships from form.
  */
 public function addRelationships()
 {
     if (!is_array($this->_contactIds)) {
         // Could this really happen?
         return;
     }
     $relationshipTypeParts = explode('_', $this->params['relationship_type_id']);
     $params = array('relationship_type_id' => $relationshipTypeParts[0], 'is_active' => 1);
     $secondaryRelationshipSide = $relationshipTypeParts[1];
     $primaryRelationshipSide = $relationshipTypeParts[2];
     $primaryFieldName = 'contact_id_' . $primaryRelationshipSide;
     $secondaryFieldName = 'contact_id_' . $secondaryRelationshipSide;
     $relationshipLabel = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $params['relationship_type_id'], "label_{$secondaryRelationshipSide}_{$primaryRelationshipSide}");
     $params[$secondaryFieldName] = $this->_contactIds;
     $params[$primaryFieldName] = $this->params['contact_check'];
     $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $primaryRelationshipSide);
     $relatedContactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$primaryFieldName], 'display_name');
     $status = array(ts('%count %2 %3 relationship created', array('count' => $outcome['valid'], 'plural' => '%count %2 %3 relationships created', 2 => $relationshipLabel, 3 => $relatedContactName)));
     if ($outcome['duplicate']) {
         $status[] = ts('%count was skipped because the contact is already %2 %3', array('count' => $outcome['duplicate'], 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationshipLabel, 3 => $relatedContactName));
     }
     if ($outcome['invalid']) {
         $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array('count' => $outcome['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' => $outcome['valid'], 'plural' => 'Relationships created.')), 'success', array('expires' => 0));
 }
示例#24
0
 /**
  * create honor-contact method 
  * createHonorContact();
  */
 function testcreateAndGetHonorContact()
 {
     $this->markTestSkipped('throws fatals');
     $honorId = null;
     $params = array('honor_type_id' => 1, 'honor_prefix_id' => 3, 'honor_first_name' => 'John', 'honor_last_name' => 'Smith', 'honor_email' => '*****@*****.**');
     $contact = CRM_Contribute_BAO_Contribution::createHonorContact($params, $honorId);
     $this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contact, 'first_name', 'id', 'John', 'Database check for created honor contact record.');
     //create contribution on behalf of honary.
     $contactId = Contact::createIndividual();
     $ids = array('contribution' => null);
     $param = array('contact_id' => $contactId, 'currency' => 'USD', 'contribution_type_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Ymd'), 'total_amount' => 66, 'honor_type_id' => 1, 'honor_contact_id' => $contact);
     require_once 'CRM/Contribute/BAO/Contribution.php';
     $contribution = CRM_Contribute_BAO_Contribution::create($param, $ids);
     $id = $contribution->id;
     $this->assertDBCompareValue('CRM_Contribute_DAO_Contribution', $id, 'honor_contact_id', 'id', $contact, 'Check DB for honor contact of the contribution');
     //get honory information
     $getHonorContact = CRM_Contribute_BAO_Contribution::getHonorContacts($contact);
     $this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contact, 'first_name', 'id', 'John', 'Database check for created honor contact record.');
     //get annual contribution information
     $annual = CRM_Contribute_BAO_Contribution::annual($contactId);
     require_once 'CRM/Core/DAO.php';
     $config =& CRM_Core_Config::singleton();
     $currencySymbol = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Currency', $config->defaultCurrency, 'symbol', 'name');
     $this->assertDBCompareValue('CRM_Contribute_DAO_Contribution', $id, 'total_amount', 'id', ltrim($annual[2], $currencySymbol), 'Check DB for total amount of the contribution');
     //Delete honor contact
     Contact::delete($contact);
     //Delete contributor contact
     Contact::delete($contactId);
 }
示例#25
0
/**
 * Adjust Metadata for Create action.
 *
 * The metadata is used for setting defaults, documentation & validation.
 *
 * @param array $params
 *   Array of parameters determined by getfields.
 */
function _civicrm_api3_custom_search_create_spec(&$params)
{
    require_once 'api/v3/OptionValue.php';
    _civicrm_api3_option_value_create_spec($params);
    $params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'custom_search', 'id', 'name');
    $params['name']['api.aliases'] = array('class_name');
}
示例#26
0
文件: Event.php 项目: kidaa30/yes
 /**
  * Set default values for the form.
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $defaults = array();
     if (isset($this->_id)) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
         CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', array(1 => $title)));
         $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults);
         $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults);
         // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg
         $this->assign('pageId', $this->_id);
     }
     if (empty($defaults['id'])) {
         $defaults['target_entity_type'] = 'event';
         $defaults['is_approval_needed'] = 1;
         $defaults['is_tellfriend_enabled'] = 1;
         $defaults['tellfriend_limit'] = 5;
         $defaults['link_text'] = ts('Promote this event with a personal campaign page');
         $defaults['owner_notify_id'] = CRM_Core_OptionGroup::getDefaultValue('pcp_owner_notify');
         if ($this->_id && ($ccReceipt = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'cc_receipt'))) {
             $defaults['notify_email'] = $ccReceipt;
         }
     }
     return $defaults;
 }
 /**
  * set up variables to build the form
  *
  * @param null
  *
  * @return void
  * @acess protected
  */
 function preProcess()
 {
     $this->_fid = $this->get('fid');
     $this->_title = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $this->_fid, 'label', 'id');
     $this->assign('title', $this->_title);
     CRM_Utils_System::setTitle(ts('Confirm Price Field Delete'));
 }
示例#28
0
 /**
  * @return int|NULL
  */
 public function getTargetOptionGroupId()
 {
     if ($this->targetOptionGroupId === NULL) {
         $this->targetOptionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->targetOptionGroupName, 'id', 'name');
     }
     return $this->targetOptionGroupId;
 }
示例#29
0
文件: Provider.php 项目: kidaa30/yes
 /**
  * Singleton function used to manage this object.
  *
  * @param array $providerParams
  * @param bool $force
  *
  * @return object
  */
 public static function &singleton($providerParams = array(), $force = FALSE)
 {
     $mailingID = CRM_Utils_Array::value('mailing_id', $providerParams);
     $providerID = CRM_Utils_Array::value('provider_id', $providerParams);
     $providerName = CRM_Utils_Array::value('provider', $providerParams);
     if (!$providerID && $mailingID) {
         $providerID = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $mailingID, 'sms_provider_id', 'id');
         $providerParams['provider_id'] = $providerID;
     }
     if ($providerID) {
         $providerName = CRM_SMS_BAO_Provider::getProviderInfo($providerID, 'name');
     }
     if (!$providerName) {
         CRM_Core_Error::fatal('Provider not known or not provided.');
     }
     $providerName = CRM_Utils_Type::escape($providerName, 'String');
     $cacheKey = "{$providerName}_" . (int) $providerID . "_" . (int) $mailingID;
     if (!isset(self::$_singleton[$cacheKey]) || $force) {
         $ext = CRM_Extension_System::singleton()->getMapper();
         if ($ext->isExtensionKey($providerName)) {
             $paymentClass = $ext->keyToClass($providerName);
             require_once "{$paymentClass}.php";
         } else {
             CRM_Core_Error::fatal("Could not locate extension for {$providerName}.");
         }
         self::$_singleton[$cacheKey] = $paymentClass::singleton($providerParams, $force);
     }
     return self::$_singleton[$cacheKey];
 }
 function alterDisplay(&$rows)
 {
     // cache for id → is_deleted mapping
     $isDeleted = array();
     foreach ($rows as &$row) {
         if (!isset($isDeleted[$row['log_civicrm_contact_id']])) {
             $isDeleted[$row['log_civicrm_contact_id']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['log_civicrm_contact_id'], 'is_deleted') !== '0';
         }
         if (!$isDeleted[$row['log_civicrm_contact_id']]) {
             $row['log_civicrm_contact_altered_contact_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contact_id']);
             $row['log_civicrm_contact_altered_contact_hover'] = ts("Go to contact summary");
         }
         $row['civicrm_contact_altered_by_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contact_log_user_id']);
         $row['civicrm_contact_altered_by_hover'] = ts("Go to contact summary");
         if ($row['log_civicrm_contact_is_deleted'] and $row['log_civicrm_contact_log_action'] == 'Update') {
             $row['log_civicrm_contact_log_action'] = ts('Delete (to trash)');
         }
         if ($row['log_civicrm_contact_log_action'] == 'Update') {
             $q = "reset=1&log_conn_id={$row['log_civicrm_contact_log_conn_id']}&log_date={$row['log_civicrm_contact_log_date']}";
             $url = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', $q, false, true);
             $row['log_civicrm_contact_log_action_link'] = $url;
             $row['log_civicrm_contact_log_action_hover'] = ts("View details for this update");
             $row['log_civicrm_contact_log_action'] = '<div class="icon details-icon"></div> ' . ts('Update');
         }
         unset($row['log_civicrm_contact_log_user_id']);
         unset($row['log_civicrm_contact_log_conn_id']);
     }
 }