* @see smarty_function_crmNavigationMenu
*/
static function getNavigationMenu() {
- $session = CRM_Core_Session::singleton();
- $contactID = $session->get('userID');
+ $contactID = CRM_Core_Session::singleton()->get('userID');
if ($contactID) {
// Set headers to encourage browsers to cache for a long time
- // If we want to refresh the menu we will send a different url
$year = 60*60*24*364;
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $year));
header('Content-Type: application/javascript');
header("Cache-Control: max-age=$year, public");
- // Render template as a javascript file
- $smarty = CRM_Core_Smarty::singleton();
- $navigation = CRM_Core_BAO_Navigation::createNavigation($contactID);
- $smarty->assign('timeGenerated', date('d M Y H:i:s'));
- $smarty->assign('navigation', $navigation);
- print $smarty->fetch('CRM/common/Navigation.tpl');
+ print CRM_Core_Smarty::singleton()->fetchWith('CRM/common/navigation.js.tpl', array(
+ 'navigation' => CRM_Core_BAO_Navigation::createNavigation($contactID),
+ ));
}
CRM_Utils_System::civiExit();
}
CRM_Core_Page_AJAX::returnJsonResponse($ret);
}
- static function getTagList() {
- $name = CRM_Utils_Type::escape($_GET['name'], 'String');
- $parentId = CRM_Utils_Type::escape($_GET['parentId'], 'Integer');
-
- $isSearch = NULL;
- if (isset($_GET['search'])) {
- $isSearch = CRM_Utils_Type::escape($_GET['search'], 'Integer');
- }
-
- $tags = array();
-
- // always add current search term as possible tag
- // here we append :::value to determine if existing / new tag should be created
- if (!$isSearch) {
- $tags[] = array(
- 'name' => $name,
- 'id' => $name . ":::value",
- );
- }
-
- $query = "SELECT id, name FROM civicrm_tag WHERE parent_id = {$parentId} and name LIKE '%{$name}%'";
- $dao = CRM_Core_DAO::executeQuery($query);
-
- while ($dao->fetch()) {
- // make sure we return tag name entered by user only if it does not exists in db
- if ($name == $dao->name) {
- $tags = array();
- }
- // escape double quotes, which break results js
- $tags[] = array('name' => addcslashes($dao->name, '"'),
- 'id' => $dao->id,
- );
- }
-
- echo json_encode($tags);
- CRM_Utils_System::civiExit();
- }
-
static function mergeTagList() {
$name = CRM_Utils_Type::escape($_GET['term'], 'String');
$fromId = CRM_Utils_Type::escape($_GET['fromId'], 'Integer');
}
$result[] = $row;
}
- print json_encode($result);
- CRM_Utils_System::civiExit();
- }
-
- static function processTags() {
- $skipTagCreate = $skipEntityAction = $entityId = NULL;
- $action = CRM_Utils_Type::escape($_POST['action'], 'String');
- $parentId = CRM_Utils_Type::escape($_POST['parentId'], 'Integer');
- if ($_POST['entityId']) {
- $entityId = CRM_Utils_Type::escape($_POST['entityId'], 'Integer');
- }
-
- $entityTable = CRM_Utils_Type::escape($_POST['entityTable'], 'String');
-
- if ($_POST['skipTagCreate']) {
- $skipTagCreate = CRM_Utils_Type::escape($_POST['skipTagCreate'], 'Integer');
- }
-
- if ($_POST['skipEntityAction']) {
- $skipEntityAction = CRM_Utils_Type::escape($_POST['skipEntityAction'], 'Integer');
- }
-
- // check if user has selected existing tag or is creating new tag
- // this is done to allow numeric tags etc.
- $tagValue = explode(':::', $_POST['tagID']);
-
- $createNewTag = FALSE;
- $tagID = $tagValue[0];
- if (isset($tagValue[1]) && $tagValue[1] == 'value') {
- $createNewTag = TRUE;
- }
-
- $tagInfo = array();
- // if action is select
- if ($action == 'select') {
- // check the value of tagID
- // if numeric that means existing tag
- // else create new tag
- if (!$skipTagCreate && $createNewTag) {
- $params = array(
- 'name' => $tagID,
- 'parent_id' => $parentId,
- );
-
- $tagObject = CRM_Core_BAO_Tag::add($params, CRM_Core_DAO::$_nullArray);
-
- $tagInfo = array(
- 'name' => $tagID,
- 'id' => $tagObject->id,
- 'action' => $action,
- );
- $tagID = $tagObject->id;
- }
-
- if (!$skipEntityAction && $entityId) {
- // save this tag to contact
- $params = array(
- 'entity_table' => $entityTable,
- 'entity_id' => $entityId,
- 'tag_id' => $tagID,
- );
-
- CRM_Core_BAO_EntityTag::add($params);
- }
- // if action is delete
- }
- elseif ($action == 'delete') {
- if (!is_numeric($tagID)) {
- $tagID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $tagID, 'id', 'name');
- }
- if (!$skipEntityAction && $entityId) {
- // delete this tag entry for the entity
- $params = array(
- 'entity_table' => $entityTable,
- 'entity_id' => $entityId,
- 'tag_id' => $tagID,
- );
-
- CRM_Core_BAO_EntityTag::del($params);
- }
- $tagInfo = array(
- 'id' => $tagID,
- 'action' => $action,
- );
- }
-
- echo json_encode($tagInfo);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($result);
}
function mappingList() {
}
if (!$mappingID) {
- echo json_encode(array('error_msg' => 'required params missing.'));
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
}
$selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID);
);
}
- echo json_encode($elements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($elements);
}
function mappingList1() {
}
if (!$mappingID) {
- echo json_encode(array('error_msg' => 'required params missing.'));
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
}
$selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($mappingID);
}
$elements['recipientMapping'] = $recipientMapping;
- echo json_encode($elements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($elements);
}
static function mergeTags() {
array(1 => $result['tagA'], 2 => $result['tagB'])
);
- echo json_encode($result);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($result);
}
function recipient() {
}
if (!$recipient) {
- echo json_encode(array('error_msg' => 'required params missing.'));
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output(array('error_msg' => 'required params missing.'));
}
switch ($recipient) {
);
}
- echo json_encode($elements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($elements);
}
}