Commit d9408156 authored by jaapjansma's avatar jaapjansma
Browse files

update clean up of iida api call. And fixed new contact sub menu item

parent 0bba81d7
......@@ -27,49 +27,4 @@ class CRM_Civiconfig_Entity_ContactType extends CRM_Civiconfig_Entity {
parent::prepareParams($params, $existing);
}
/**
* Method to create contact type.
*
* @param array $params
* @return int $id ID of created contact type
* @throws Exception when error from API ContactType Create
*/
public function create(array $params) {
$id = parent::create($params);
$this->updateNavigationMenuUrl($params);
return $id;
}
/**
* Method to check if there is a navigation menu option for the contact type
* and if so, update name and url
*
* @param array $params
* @access private
*/
private function updateNavigationMenuUrl($params) {
// check if there is a "New <label>" entry in the navigation table
$query = "SELECT * FROM civicrm_navigation WHERE label = %1";
$label = "New ".$params['label'];
$dao = CRM_Core_DAO::executeQuery($query, array(1 => array($label, 'String')));
$validParent = array("New Organization", "New Individual", "New Household");
$newUrl = 'civicrm/contact/add&ct=Organization&cst='.$params['name'].'&reset=1';
$newName = "New ".$params['name'];
while ($dao->fetch()) {
// parent should be either New Organization, New Individual or New Household
if (isset($dao->parent_id)) {
$parentQuery = "SELECT name FROM civicrm_navigation WHERE id = %1";
$parentName = CRM_Core_DAO::singleValueQuery($parentQuery, array(1 => array($dao->parent_id, 'Integer')));
if (in_array($parentName, $validParent)) {
$update = "UPDATE civicrm_navigation SET url = %1, name = %2 WHERE id = %3";
$params = array(
1 => array($newUrl, 'String'),
2 => array($newName, 'String'),
3 => array($dao->id, 'Integer')
);
CRM_Core_DAO::executeQuery($update, $params);
}
}
}
}
}
\ No newline at end of file
}
<?php
/**
* IidaConfig.Update API method.
* Kept for backwards compatibility: calls are forwarded to the Civiconfig.LoadJson API.
*/
require_once __DIR__ . '/../Civiconfig/LoadJson.php';
/**
* @param array $params API call parameters
* @return mixed API call results
* @deprecated
*/
function civicrm_api3_iida_config_update($params = []) {
return civicrm_api3_civiconfig_load_json($params);
}
......@@ -14,8 +14,8 @@
<url desc="Support">https://www.civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-03-13</releaseDate>
<version>1.2.6</version>
<releaseDate>2020-03-25</releaseDate>
<version>1.2.7</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.4</ver>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment