/**
  * 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);
     }
 }
/**
 * Implements hook_civicrm_navigationMenu().
 */
function eventpermissions_civicrm_navigationMenu(&$params)
{
    $searchParams = array('url' => 'civicrm/eventpermissions?reset=1');
    $menuItems = array();
    CRM_Core_BAO_Navigation::retrieve($searchParams, $menuItems);
    if (!empty($menuItems)) {
        return;
    }
    $searchParams = array('url' => 'civicrm/admin/options/participant_role?reset=1');
    $menuItems = array();
    CRM_Core_BAO_Navigation::retrieve($searchParams, $menuItems);
    $parent = CRM_Utils_Array::value('parent_id', $menuItems);
    $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
    if (is_int($navId)) {
        $navId++;
    }
    $basicAttrs = array('label' => ts('Event Permissions', array('domain' => 'com.aghstrategies.eventpermissions')), 'name' => 'Event Permissions', 'url' => 'civicrm/eventpermissions?reset=1', 'permission' => 'administer CiviCRM', 'active' => 1, 'navID' => $navId, 'parentID' => $parent);
    $searchParams = array('id' => $parent);
    $menuItems = array();
    CRM_Core_BAO_Navigation::retrieve($searchParams, $menuItems);
    if (empty($menuItems['parent_id'])) {
        $params[$parent]['child'][$navId] = $basicAttrs;
    } else {
        $params[$menuItems['parent_id']]['child'][$parent]['child'][$navId] = array('attributes' => $basicAttrs);
    }
}
 /**
  * Add the given menu item to the CiviCRM navigation menu if it does not exist yet.
  * @param array parent_params the params array into whose 'child' attribute the new item will be added.
  * @param array $attributes the attributes array to be added to the navigation menu
  */
 static function addNavigationMenuEntry(&$parent_params, $menu_entry_attributes)
 {
     // see if it is already in the menu...
     $menu_item_search = array('url' => $menu_entry_attributes['url']);
     $menu_items = array();
     CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items);
     if (empty($menu_items)) {
         // it's not already contained, so we want to add it to the menu
         // insert at the bottom
         $parent_params['child'][] = array('attributes' => $menu_entry_attributes);
     }
 }
function queryrunner_civicrm_navigationMenu(&$params)
{
    $menu_item_search = array('url' => 'civicrm/query-runner');
    $menu_items = array();
    CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items);
    if (!empty($menu_items)) {
        return;
    }
    $navId = CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_navigation') + 1;
    $adminID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Administer', 'id', 'name');
    $systemID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'System settings', 'id', 'name');
    $params[$adminID]['child'][$systemID]['child'][$navId] = array('attributes' => array('label' => ts('Query Runner'), 'name' => 'Query Runner', 'url' => 'civicrm/query-runner', 'permission' => 'administer CiviCRM', 'operator' => 'AND', 'separator' => null, 'parentID' => $systemID, 'navID' => $navId, 'active' => 1));
}
Beispiel #5
0
/**
 * Implementation of hook_civicrm_uninstall
 */
function hrprofile_civicrm_uninstall()
{
    $groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_UFField', 'uf_group_id', array('labelColumn' => 'name'));
    $profileId = array_search('hrstaffdir_listing', $groups);
    $isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrstaffdir', 'is_active', 'full_name');
    if ($profileId && $isEnabled) {
        $originalUrl = "civicrm/profile/table?reset=1&gid={$profileId}&force=1";
        $updatedUrl = "civicrm/profile?reset=1&gid={$profileId}&force=1";
        hrprofile_updateNavigation($originalUrl, $updatedUrl);
    } else {
        $navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile/table?reset=1&gid={$profileId}&force=1");
        $navigation = CRM_Core_BAO_Navigation::retrieve($navigationParams, $defaultParams);
        CRM_Core_BAO_Navigation::processDelete($navigation->id);
        CRM_Core_BAO_Navigation::resetNavigation();
    }
    return _hrprofile_civix_civicrm_uninstall();
}
Beispiel #6
0
 public function setDefaultValues()
 {
     $defaults = array();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Core_BAO_Navigation::retrieve($params, $defaults);
         if (CRM_Utils_Array::value('permission', $defaults)) {
             foreach (explode(',', $defaults['permission']) as $value) {
                 $components[$value] = $value;
             }
             $defaults['permission'] = $components;
         }
         //Take parent id in object variable to calculate the menu
         //weight if menu parent id changed
         $this->_currentParentID = CRM_Utils_Array::value('parent_id', $defaults);
     } else {
         $defaults['permission'] = "access CiviCRM";
     }
     // its ok if there is no element called is_active
     $defaults['is_active'] = $this->_id ? $defaults['is_active'] : 1;
     return $defaults;
 }
Beispiel #7
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('Menu Item'));
     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'));
     $permissions = array();
     foreach (CRM_Core_Permission::basicPermissions(TRUE, TRUE) as $id => $vals) {
         $permissions[] = array('id' => $id, 'label' => $vals[0], 'description' => (array) CRM_Utils_Array::value(1, $vals));
     }
     $this->add('text', 'permission', ts('Permission'), array('placeholder' => ts('Unrestricted'), 'class' => 'huge', 'data-select-params' => json_encode(array('data' => array('results' => $permissions, 'text' => 'label')))));
     $operators = array('AND' => ts('AND'), 'OR' => ts('OR'));
     $this->add('select', 'permission_operator', NULL, $operators);
     //make separator location configurable
     $separator = array(ts('None'), ts('After menu element'), ts('Before menu element'));
     $this->add('select', 'has_separator', ts('Separator'), $separator);
     $active = $this->add('advcheckbox', 'is_active', ts('Enabled'));
     if (CRM_Utils_Array::value('name', $this->_defaults) == '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]);
         $this->add('select', 'parent_id', ts('Parent'), array('' => ts('Top level')) + $parentMenu, FALSE, array('class' => 'crm-select2'));
     }
 }
/**
* This hook is used to add the web tracking report link to the navigation menu
*
*/
function webtracking_civicrm_navigationMenu(&$params)
{
    // Check that our item doesn't already exist
    $menu_item_search = array('url' => 'civicrm/report/webtracking');
    $menu_items = array();
    CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items);
    if (!empty($menu_items)) {
        return;
    }
    $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
    if (is_integer($navId)) {
        $navId++;
    }
    // Find the Report menu
    $reportID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'id', 'name');
    $params[$reportID]['child'][$navId] = array('attributes' => array('label' => ts('Web Tracking Report', array('domain' => 'org.civicrm.webtracking')), 'name' => 'Web Tracking Report', 'url' => 'civicrm/report/webtracking', 'permission' => 'access CiviReport,access CiviEvent', 'operator' => 'OR', 'separator' => 1, 'parentID' => $reportID, 'navID' => $navId, 'active' => 1));
}
/**
 * Implementation of hook_civicrm_navigationMenu
 *
 * Inject the 'civicrm/bicList' item unter the 'Search' top menu, unless it's already in there...
 *
 * based on https://github.com/Project60/sepa_dd/commit/f342a223c41d7fc940294f24999fc5bdf637b98b
 */
function bic_civicrm_navigationMenu(&$params)
{
    // see if it is already in the menu...
    $menu_item_search = array('url' => 'civicrm/bicList');
    $menu_items = array();
    CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items);
    if (empty($menu_items)) {
        // it's not already contained, so we want to add it to the menu
        // now, by default we want to add it to the Contributions menu -> find it
        $search_menu_id = 0;
        foreach ($params as $key => $value) {
            if ($value['attributes']['name'] == 'Search...') {
                $search_menu_id = $key;
                break;
            }
        }
        if (empty($search_menu_id)) {
            error_log("org.project60.bic: Cannot find 'Contributions' menu item.");
        } else {
            // insert at the bottom
            $params[$search_menu_id]['child'][] = array('attributes' => array('label' => ts('Find Banks', array('domain' => 'org.project60.bic')), 'name' => 'BankLists', 'url' => 'civicrm/bicList', 'permission' => 'access CiviContribute', 'operator' => NULL, 'separator' => 2, 'parentID' => $search_menu_id, 'navID' => bic_navhelper_create_unique_nav_id($params), 'active' => 1));
        }
    }
}
/**
 * Implementation of hook_civicrm_managed
 *
 * Add entries to the navigation menu, automatically removed on uninstall
 */
function cdntaxreceipts_civicrm_navigationMenu(&$params)
{
    // Check that our item doesn't already exist
    $cdntax_search = array('url' => 'civicrm/cdntaxreceipts/settings?reset=1');
    $cdntax_item = array();
    CRM_Core_BAO_Navigation::retrieve($cdntax_search, $cdntax_item);
    if (!empty($cdntax_item)) {
        return;
    }
    // Get the maximum key of $params using method mentioned in discussion
    // https://issues.civicrm.org/jira/browse/CRM-13803
    $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
    if (is_integer($navId)) {
        $navId++;
    }
    // Find the Memberships menu
    foreach ($params as $key => $value) {
        if ('Administer' == $value['attributes']['name']) {
            $parent_key = $key;
            foreach ($value['child'] as $child_key => $child_value) {
                if ('CiviContribute' == $child_value['attributes']['name']) {
                    $params[$parent_key]['child'][$child_key]['child'][$navId] = array('attributes' => array('label' => ts('CDN Tax Receipts', array('domain' => 'org.civicrm.cdntaxreceipts')), 'name' => 'CDN Tax Receipts', 'url' => 'civicrm/cdntaxreceipts/settings?reset=1', 'permission' => 'access CiviContribute,administer CiviCRM', 'operator' => 'AND', 'separator' => 2, 'parentID' => $child_key, 'navID' => $navId, 'active' => 1));
                }
            }
        }
    }
}
 static function setDefaultValues(&$form, &$defaults)
 {
     // we should not build form elements in dashlet mode
     if ($form->_section) {
         return;
     }
     $instanceID = $form->getVar('_id');
     $navigationDefaults = array();
     if (!isset($defaults['permission'])) {
         $permissions = array_flip(CRM_Core_Permission::basicPermissions());
         $defaults['permission'] = $permissions['CiviReport: access CiviReport'];
     }
     $config = CRM_Core_Config::singleton();
     $defaults['report_header'] = $report_header = "<html>\n  <head>\n    <title>CiviCRM Report</title>\n    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n    <style type=\"text/css\">@import url({$config->userFrameworkResourceURL}css/print.css);</style>\n  </head>\n  <body><div id=\"crm-container\">";
     $defaults['report_footer'] = $report_footer = "<p><img src=\"{$config->userFrameworkResourceURL}i/powered_by.png\" /></p></div></body>\n</html>\n";
     if ($instanceID) {
         // this is already retrieved via Form.php
         $defaults['description'] = CRM_Utils_Array::value('description', $defaults);
         $defaults['report_header'] = CRM_Utils_Array::value('header', $defaults);
         $defaults['report_footer'] = CRM_Utils_Array::value('footer', $defaults);
         if (!empty($defaults['navigation_id'])) {
             //get the default navigation parent id
             $params = array('id' => $defaults['navigation_id']);
             CRM_Core_BAO_Navigation::retrieve($params, $navigationDefaults);
             $defaults['is_navigation'] = 1;
             $defaults['parent_id'] = CRM_Utils_Array::value('parent_id', $navigationDefaults);
             if (!empty($navigationDefaults['is_active'])) {
                 $form->assign('is_navigation', TRUE);
             }
             if (!empty($navigationDefaults['id'])) {
                 $form->_navigation['id'] = $navigationDefaults['id'];
                 $form->_navigation['parent_id'] = $navigationDefaults['parent_id'];
             }
         }
         if (!empty($defaults['grouprole'])) {
             foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['grouprole']) as $value) {
                 $grouproles[] = $value;
             }
             $defaults['grouprole'] = $grouproles;
         }
     } else {
         if (property_exists($form, '_description')) {
             $defaults['description'] = $form->_description;
         }
     }
 }
 /**
  * Function to add or update Contact SubTypes 
  * 
  * @param  array $params  an assoc array of name/value pairs
  * @return object  
  * @access public
  * @static
  */
 static function add($params)
 {
     // null if empty params or doesn't contain parent_id
     if (!CRM_Utils_Array::value('parent_id', $params)) {
         return;
     }
     // label or name
     if (!CRM_Utils_Array::value('label', $params)) {
         return;
     }
     // parent_id
     if (!CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])) {
         return;
     }
     $contactType = new CRM_Contact_DAO_ContactType();
     $contactType->copyValues($params);
     $contactType->id = CRM_Utils_Array::value('id', $params);
     $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
     $contactType->save();
     if ($contactType->find(true)) {
         $contactName = $contactType->name;
         $contact = ucfirst($contactType->label);
         $active = $contactType->is_active;
     }
     if (CRM_Utils_Array::value('id', $params)) {
         $params = array('name' => "New {$contactName}");
         $newParams = array('label' => "New {$contact}", 'is_active' => $active);
         CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
     } else {
         if (CRM_Utils_Array::value('parent_id', $params)) {
             $name = self::getBasicType($contactName);
             $value = array('name' => "New {$name}");
             CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
             $navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add&ct={$name}&cst={$contactName}&reset=1", 'permission' => "add contacts", 'parent_id' => $navinfo['id'], 'is_active' => $active);
             CRM_Core_BAO_Navigation::add($navigation);
         }
     }
     CRM_Core_BAO_Navigation::resetNavigation();
     // reset the cache after adding
     self::subTypeInfo(null, false, false, true);
     return $contactType;
 }
Beispiel #13
0
 static function setDefaultValues(&$form, &$defaults)
 {
     $instanceID = $form->getVar('_id');
     $navigationDefaults = array();
     require_once 'CRM/Core/Config.php';
     $config = CRM_Core_Config::singleton();
     $defaults['report_header'] = $report_header = "<html>\n  <head>\n    <title>CiviCRM Report</title>\n    <style type=\"text/css\">@import url({$config->userFrameworkResourceURL}css/print.css);</style>\n  </head>\n  <body><div id=\"crm-container\">";
     $defaults['report_footer'] = $report_footer = "<p><img src=\"{$config->userFrameworkResourceURL}i/powered_by.png\" /></p></div></body>\n</html>\n";
     if ($instanceID) {
         // this is already retrieved via Form.php
         $defaults['description'] = $defaults['description'];
         if (CRM_Utils_Array::value('header', $defaults)) {
             $defaults['report_header'] = $defaults['header'];
         }
         if (CRM_Utils_Array::value('footer', $defaults)) {
             $defaults['report_footer'] = $defaults['footer'];
         }
         if (CRM_Utils_Array::value('navigation_id', $defaults)) {
             //get the default navigation parent id
             $params = array('id' => $defaults['navigation_id']);
             CRM_Core_BAO_Navigation::retrieve($params, $navigationDefaults);
             $defaults['is_navigation'] = 1;
             $defaults['parent_id'] = CRM_Utils_Array::value('parent_id', $navigationDefaults);
             if (CRM_Utils_Array::value('is_active', $navigationDefaults)) {
                 $form->assign('is_navigation', true);
             }
             if (CRM_Utils_Array::value('id', $navigationDefaults)) {
                 $form->_navigation['id'] = $navigationDefaults['id'];
                 $form->_navigation['parent_id'] = $navigationDefaults['parent_id'];
             }
         }
     } else {
         $defaults['description'] = $form->_description;
     }
 }
Beispiel #14
0
function _hrstaffdir_setActiveFields($oParams, $nParams)
{
    $profileId = hrstaffdir_getUFGroupID();
    $path = array('url' => "civicrm/profile?reset=1&gid={$profileId}&force=1");
    $navigationPath = CRM_Core_BAO_Navigation::retrieve($path, $defaultpath);
    if ($navigationPath) {
        $params = array('label' => 'Directory', 'url' => "civicrm/profile?reset=1&gid={$profileId}&force=1", 'is_active' => $oParams);
        $newParams = array('is_active' => $nParams);
        $navigation = CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
        CRM_Core_BAO_Navigation::resetNavigation();
    }
    //disable/enable ufgroup and uffield
    $sql = "UPDATE civicrm_uf_field JOIN civicrm_uf_group ON civicrm_uf_group.id = civicrm_uf_field.uf_group_id SET civicrm_uf_field.is_active = {$nParams} WHERE civicrm_uf_group.name = 'hrstaffdir_listing'";
    CRM_Core_DAO::executeQuery($sql);
    CRM_Core_DAO::executeQuery("UPDATE civicrm_uf_group SET is_active = {$nParams} WHERE name = 'hrstaffdir_listing'");
}
function iats_civicrm_navigationMenu(&$navMenu)
{
    $pages = array('admin_page' => array('label' => 'iATS Payments Admin', 'name' => 'iATS Payments Admin', 'url' => 'civicrm/iATSAdmin', 'parent' => array('Contributions'), 'permission' => 'access CiviContribute,administer CiviCRM', 'operator' => 'AND', 'separator' => NULL, 'active' => 1), 'settings_page' => array('label' => 'iATS Payments Settings', 'name' => 'iATS Payments Settings', 'url' => 'civicrm/admin/contribute/iatssettings', 'parent' => array('Administer', 'CiviContribute'), 'permission' => 'access CiviContribute,administer CiviCRM', 'operator' => 'AND', 'separator' => NULL, 'active' => 1));
    foreach ($pages as $item) {
        // Check that our item doesn't already exist
        $menu_item_search = array('url' => $item['url']);
        $menu_items = array();
        CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items);
        if (empty($menu_items)) {
            $path = implode('/', $item['parent']);
            unset($item['parent']);
            _iats_civix_insert_navigation_menu($navMenu, $path, $item);
        }
    }
}
 /**
  * Add or update Contact SubTypes.
  *
  * @param array $params
  *   An assoc array of name/value pairs.
  *
  * @return object|void
  */
 public static function add(&$params)
 {
     // label or name
     if (empty($params['id']) && empty($params['label'])) {
         return NULL;
     }
     if (!empty($params['parent_id']) && !CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])) {
         return NULL;
     }
     $contactType = new CRM_Contact_DAO_ContactType();
     $contactType->copyValues($params);
     $contactType->id = CRM_Utils_Array::value('id', $params);
     $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
     $contactType->save();
     if ($contactType->find(TRUE)) {
         $contactName = $contactType->name;
         $contact = ucfirst($contactType->label);
         $active = $contactType->is_active;
     }
     if (!empty($params['id'])) {
         $params = array('name' => "New {$contactName}");
         $newParams = array('label' => "New {$contact}", 'is_active' => $active);
         CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
     } else {
         $name = self::getBasicType($contactName);
         if (!$name) {
             return;
         }
         $value = array('name' => "New {$name}");
         CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
         $navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add?ct={$name}&cst={$contactName}&reset=1", 'permission' => 'add contacts', 'parent_id' => $navinfo['id'], 'is_active' => $active);
         CRM_Core_BAO_Navigation::add($navigation);
     }
     CRM_Core_BAO_Navigation::resetNavigation();
     // reset the cache after adding
     self::subTypeInfo(NULL, FALSE, FALSE, TRUE);
     return $contactType;
 }
Beispiel #17
0
function hrcase_civicrm_navigationMenu(&$params)
{
    // process only if civiCase is enabled
    if (!array_key_exists('CiviCase', CRM_Core_Component::getEnabledComponents())) {
        return;
    }
    $values = array();
    $caseMenuItems = array();
    // the parent menu
    $referenceMenuItem['name'] = 'New Case';
    CRM_Core_BAO_Navigation::retrieve($referenceMenuItem, $values);
    if (!empty($values)) {
        // fetch all the case types
        $caseTypes = CRM_Case_PseudoConstant::caseType();
        $appValue = array_search('Application', $caseTypes);
        unset($caseTypes[$appValue]);
        $parentId = $values['id'];
        $maxKey = max(array_keys($params));
        // now create nav menu items
        if (!empty($caseTypes)) {
            foreach ($caseTypes as $cTypeId => $caseTypeName) {
                $maxKey = $maxKey + 1;
                $caseMenuItems[$maxKey] = array('attributes' => array('label' => "New {$caseTypeName}", 'name' => "New {$caseTypeName}", 'url' => $values['url'] . "&ctype={$cTypeId}", 'permission' => $values['permission'], 'operator' => $values['permission_operator'], 'separator' => NULL, 'parentID' => $parentId, 'navID' => $maxKey, 'active' => 1));
            }
        }
        if (!empty($caseMenuItems)) {
            $params[$values['parent_id']]['child'][$values['id']]['child'] = $caseMenuItems;
        }
    }
}
Beispiel #18
0
 /**
  * Function to add or update Contact SubTypes 
  * 
  * @param  array $params  an assoc array of name/value pairs
  * @return object  
  * @access public
  * @static
  */
 static function add($params)
 {
     $contactType =& new CRM_Contact_DAO_ContactType();
     $contactType->copyValues($params);
     $contactType->id = CRM_Utils_Array::value('id', $params);
     if (CRM_Utils_Array::value('parent_id', $params)) {
         $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
     }
     $contactType->save();
     if ($contactType->find(true)) {
         $contactName = $contactType->name;
         $contact = ucfirst($contactType->label);
         $active = $contactType->is_active;
     }
     if (CRM_Utils_Array::value('id', $params)) {
         $params = array('name' => "New {$contactName}");
         $newParams = array('label' => "New {$contact}", 'is_active' => $active);
         CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
     } else {
         if (CRM_Utils_Array::value('parent_id', $params)) {
             $name = self::getBasicType($contactName);
             $value = array('name' => "New {$name}");
             CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
             $navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add&ct={$name}&cst={$contactName}&reset=1", 'permission' => "add contacts", 'parent_id' => $navinfo['id'], 'is_active' => $active);
             CRM_Core_BAO_Navigation::add($navigation);
         }
     }
     CRM_Core_BAO_Navigation::resetNavigation();
     return $contactType;
 }
Beispiel #19
0
 /**
  * Set default values.
  *
  * @param CRM_Core_Form $form
  * @param array $defaults
  */
 public static function setDefaultValues(&$form, &$defaults)
 {
     // we should not build form elements in dashlet mode.
     if ($form->_section) {
         return;
     }
     $instanceID = $form->getVar('_id');
     $navigationDefaults = array();
     if (!isset($defaults['permission'])) {
         $permissions = array_flip(CRM_Core_Permission::basicPermissions());
         $defaults['permission'] = $permissions['CiviReport: access CiviReport'];
     }
     $config = CRM_Core_Config::singleton();
     // Add a special region for the default HTML header of printed reports.  It
     // won't affect reports with customized headers, just ones with the default.
     $printHeaderRegion = CRM_Core_Region::instance('default-report-header', FALSE);
     $htmlHeader = $printHeaderRegion ? $printHeaderRegion->render('', FALSE) : '';
     $defaults['report_header'] = $report_header = "<html>\n  <head>\n    <title>CiviCRM Report</title>\n    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n    <style type=\"text/css\">@import url({$config->userFrameworkResourceURL}css/print.css);</style>\n    {$htmlHeader}\n  </head>\n  <body><div id=\"crm-container\">";
     $defaults['report_footer'] = $report_footer = "<p><img src=\"{$config->userFrameworkResourceURL}i/powered_by.png\" /></p></div></body>\n</html>\n";
     // CRM-17225 view_mode currently supports 'view' or 'criteria'.
     // Prior to 4.7 'view' meant reset=1 in the url & if not set
     // then show criteria.
     // From 4.7 we will pro-actively set 'force=1' but still respect the old behaviour.
     // we may look to add pdf, print_view, csv & various charts as these could simply
     // be added to the url allowing us to conceptualise 'view right now' vs saved view
     // & using a multiselect (option value?) could help here.
     // Note that accessing reports without reset=1 in the url turns out to be
     // dangerous as it seems to carry actions like 'delete' from one report to another.
     $defaults['view_mode'] = 'view';
     $output = CRM_Utils_Request::retrieve('output', 'String');
     if ($output == 'criteria') {
         $defaults['view_mode'] = 'criteria';
     }
     if ($instanceID) {
         // this is already retrieved via Form.php
         $defaults['description'] = CRM_Utils_Array::value('description', $defaults);
         if (!empty($defaults['header'])) {
             $defaults['report_header'] = $defaults['header'];
         }
         if (!empty($defaults['footer'])) {
             $defaults['report_footer'] = $defaults['footer'];
         }
         if (!empty($defaults['navigation_id'])) {
             // Get the default navigation parent id.
             $params = array('id' => $defaults['navigation_id']);
             CRM_Core_BAO_Navigation::retrieve($params, $navigationDefaults);
             $defaults['is_navigation'] = 1;
             $defaults['parent_id'] = CRM_Utils_Array::value('parent_id', $navigationDefaults);
             if (!empty($navigationDefaults['is_active'])) {
                 $form->assign('is_navigation', TRUE);
             }
             // A saved view mode will over-ride any url assumptions.
             if (strpos($navigationDefaults['url'], 'output=criteria')) {
                 $defaults['view_mode'] = 'criteria';
             }
             if (!empty($navigationDefaults['id'])) {
                 $form->_navigation['id'] = $navigationDefaults['id'];
                 $form->_navigation['parent_id'] = !empty($navigationDefaults['parent_id']) ? $navigationDefaults['parent_id'] : NULL;
             }
         }
         if (!empty($defaults['grouprole'])) {
             foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['grouprole']) as $value) {
                 $groupRoles[] = $value;
             }
             $defaults['grouprole'] = $groupRoles;
         }
     } elseif (property_exists($form, '_description')) {
         $defaults['description'] = $form->_description;
     }
 }
/**
 * Implementation of hook_civicrm_navigationMenu
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_permission
 */
function outlookapi_civicrm_navigationMenu(&$params)
{
    // Check that our item doesn't already exist
    $outlookSettingURL = array('url' => 'civicrm/outlook/settings?reset=1');
    $setting_item = array();
    CRM_Core_BAO_Navigation::retrieve($outlookSettingURL, $setting_item);
    if (!empty($setting_item)) {
        return;
    }
    // Get the maximum key of $params using method mentioned in discussion
    // https://issues.civicrm.org/jira/browse/CRM-13803
    $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
    if (is_integer($navId)) {
        $navId++;
    }
    foreach ($params as $key => $value) {
        if ('Administer' == $value['attributes']['name']) {
            $parent_key = $key;
            foreach ($value['child'] as $child_key => $child_value) {
                if ('System Settings' == $child_value['attributes']['name']) {
                    $params[$parent_key]['child'][$child_key]['child'][$navId] = array('attributes' => array('label' => ts('Outlook Settings'), 'name' => 'Outlook_Settings', 'url' => CRM_Utils_System::url('civicrm/outlook/settings', 'reset=1', TRUE), 'permission' => 'administer CiviCRM', 'separator' => 2, 'operator' => NULL, 'parentID' => $child_key, 'navID' => $navId, 'active' => 1));
                }
            }
        }
    }
}