Example #1
0
 function &main()
 {
     $items = array(array('path' => 'civicrm/contribute/transact', 'qs' => 'reset=1', 'title' => ts('CiviContribute'), 'access' => CRM_Utils_System::checkPermission('make online contributions'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/admin/contribute', 'title' => ts('Configure Online Contribution Pages'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => 'CiviContribute', 'icon' => 'admin/online_contribution_pages.png', 'weight' => 360), array('path' => 'civicrm/admin/contribute/managePremiums', 'title' => ts('Manage Premiums'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => 'CiviContribute', 'icon' => 'admin/Premiums.png', 'weight' => 365), array('path' => 'civicrm/admin/contribute/contributionType', 'title' => ts('Contribution Types'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => 'CiviContribute', 'icon' => 'admin/contribution_types.png', 'weight' => 370), array('path' => 'civicrm/admin/contribute/paymentInstrument', 'title' => ts('Payment Instruments'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => 'CiviContribute', 'icon' => 'admin/payment_instruments.png', 'weight' => 380), array('path' => 'civicrm/admin/contribute/acceptCreditCard', 'title' => ts('Accepted Credit Cards'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => 'CiviContribute', 'icon' => 'admin/accepted_creditcards.png', 'weight' => 395), array('path' => 'civicrm/contact/view/contribution', 'qs' => 'reset=1&force=1&cid=%%cid%%', 'access' => CRM_Utils_System::checkPermission('access CiviContribute'), 'title' => ts('Contributions'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'weight' => 1), array('path' => 'civicrm/contribute', 'qs' => 'reset=1', 'title' => ts('CiviContribute'), 'access' => CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 500), array('path' => 'civicrm/contribute/search', 'qs' => 'reset=1', 'title' => ts('Find Contributions'), 'access' => CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 510), array('path' => 'civicrm/contribute/import', 'qs' => 'reset=1', 'title' => ts('Import Contributions'), 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 520));
     $config =& CRM_Core_Config::singleton();
     if ($config->paymentProcessor == 'PayPal' || $config->paymentProcessor == 'PayPal_Express') {
         $items[] = array('path' => 'civicrm/admin/contribute/createPPD', 'title' => ts('Create PayPal API Profile'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviContribute'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => 'CiviContribute', 'icon' => 'admin/PayPal_mark_37x23.gif', 'weight' => 400);
     }
     return $items;
 }
Example #2
0
 /**
  * Given a contact id and a field set, return the values from the db
  * for this contact
  *
  * @param int     $id       the contact id
  * @param array   $fields   the profile fields of interest
  * @param array   $values   the values for the above fields
  * @return void
  * @access public
  * @static
  */
 function getValues($cid, &$fields, &$values)
 {
     $options = array();
     // get the contact details (hier)
     $returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($fields);
     $params = array('id' => $cid);
     $query =& new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
     $options =& $query->_options;
     $details = $query->searchQuery();
     if (!$details->fetch()) {
         return;
     }
     require_once 'CRM/Core/PseudoConstant.php';
     $locationTypes = CRM_Core_PseudoConstant::locationType();
     //start of code to set the default values
     foreach ($fields as $name => $field) {
         $index = $field['title'];
         $params[$index] = $values[$index] = '';
         if ($details->{$name} || $name == 'group' || $name == 'tag') {
             //hack for CRM-665
             //to handle custom data (checkbox) to be written
             // to handle gender / suffix / prefix
             if (in_array($name, array('gender', 'individual_prefix', 'individual_suffix'))) {
                 $values[$index] = $details->{$name};
                 $name = $name . '_id';
                 $params[$index] = $details->{$name};
             } else {
                 if (in_array($name, array('state_province', 'country'))) {
                     $values[$index] = $details->{$name};
                     $idx = $name . '_id';
                     $params[$index] = $details->{$idx};
                 } else {
                     if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') {
                         if ($details->{$name}) {
                             $values[$index] = '[ x ]';
                         }
                     } else {
                         if ($name == 'group') {
                             $groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', null, false, true);
                             $title = array();
                             $ids = array();
                             foreach ($groups as $g) {
                                 if ($g['visibility'] != 'User and User Admin Only') {
                                     $title[] = $g['title'];
                                     if ($g['visibility'] == 'Public User Pages and Listings') {
                                         $ids[] = $g['group_id'];
                                     }
                                 }
                             }
                             $values[$index] = implode(', ', $title);
                             $params[$index] = implode(',', $ids);
                         } else {
                             if ($name == 'tag') {
                                 require_once 'CRM/Core/BAO/EntityTag.php';
                                 $entityTags =& CRM_Core_BAO_EntityTag::getTag('civicrm_contact', $cid);
                                 $allTags =& CRM_Core_PseudoConstant::tag();
                                 $title = array();
                                 foreach ($entityTags as $tagId) {
                                     $title[] = $allTags[$tagId];
                                 }
                                 $values[$index] = implode(', ', $title);
                                 $params[$index] = implode(',', $entityTags);
                             } else {
                                 require_once 'CRM/Core/BAO/CustomField.php';
                                 if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                                     $params[$index] = $details->{$name};
                                     $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($details->{$name}, $cfID, $options);
                                 } else {
                                     $values[$index] = $details->{$name};
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if (strpos($name, '-') !== false) {
                 list($fieldName, $id, $type) = explode('-', $name);
                 $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
                 if (!$locationTypeName) {
                     continue;
                 }
                 $detailName = "{$locationTypeName}-{$fieldName}";
                 if (in_array($fieldName, array('phone', 'im', 'email'))) {
                     if ($type) {
                         $detailName .= "-{$type}";
                     } else {
                         $detailName .= '-1';
                     }
                 }
                 if (in_array($fieldName, array('state_province', 'country'))) {
                     $values[$index] = $details->{$detailName};
                     $idx = $detailName . '_id';
                     $params[$index] = $details->{$idx};
                 } else {
                     $values[$index] = $params[$index] = $details->{$detailName};
                 }
             }
         }
         if ($field['visibility'] == "Public User Pages and Listings" && CRM_Utils_System::checkPermission('profile listings and forms')) {
             if (CRM_Utils_System::isNull($params[$index])) {
                 $params[$index] = $values[$index];
             }
             if (empty($params[$index])) {
                 continue;
             }
             $fieldName = $field['name'];
             $url = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($params[$index]));
             if (!empty($values[$index])) {
                 $values[$index] = '<a href="' . $url . '">' . $values[$index] . '</a>';
             }
         }
     }
 }
Example #3
0
 function &main()
 {
     $items = array(array('path' => 'civicrm/mailing', 'title' => ts('CiviMail'), 'access' => CRM_Utils_System::checkPermission('access CiviMail'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 600), array('path' => 'civicrm/mailing/component', 'title' => ts('Mailing Header / Footer'), 'access' => CRM_Utils_System::checkPermission('access CiviMail'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 610), array('path' => 'civicrm/mailing/send', 'title' => ts('Send Mailing'), 'access' => CRM_Utils_System::checkPermission('access CiviMail'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 620), array('path' => 'civicrm/mailing/browse', 'title' => ts('Browse Sent Mailings'), 'access' => CRM_Utils_System::checkPermission('access CiviMail'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 630));
     return $items;
 }
Example #4
0
 function accessCiviContribute()
 {
     $config =& CRM_Core_Config::singleton();
     if (CRM_Utils_System::checkPermission('access CiviContribute') && in_array('CiviContribute', $config->enableComponents)) {
         return true;
     }
     return false;
 }
Example #5
0
 /**
  * Get all groups from database, filtered by permissions
  * for this user
  *
  * @access public
  * @static
  *
  * @return array - array reference of all groups.
  *
  */
 function &group()
 {
     if (!isset($GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'])) {
         $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'] = $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermissionedGroups'] = array();
         $groups =& CRM_Core_PseudoConstant::allGroup();
         if (CRM_Utils_System::checkPermission('edit all contacts')) {
             // this is the most powerful permission, so we return
             // immediately rather than dilute it further
             $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editAdminUser'] = $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewAdminUser'] = true;
             $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermission'] = $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermission'] = true;
             $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermissionedGroups'] = $groups;
             $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'] = $groups;
             return $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'];
         } else {
             if (CRM_Utils_System::checkPermission('view all contacts')) {
                 $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewAdminUser'] = true;
                 $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermission'] = true;
                 $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'] = $groups;
             }
         }
         foreach ($groups as $id => $title) {
             if (CRM_Utils_System::checkPermission(CRM_CORE_PERMISSION_EDIT_GROUPS . $title)) {
                 $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermissionedGroups'][$id] = $title;
                 $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'][$id] = $title;
                 $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermission'] = true;
             } else {
                 if (CRM_Utils_System::checkPermission(CRM_CORE_PERMISSION_VIEW_GROUPS . $title)) {
                     $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'][$id] = $title;
                     $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermission'] = true;
                 }
             }
         }
     }
     return $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'];
 }
Example #6
0
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the  
  * type of action and executes that action. 
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     $template =& CRM_Core_Smarty::singleton();
     if ($this->_id && $this->_gid) {
         require_once 'CRM/Core/BAO/UFGroup.php';
         $values = array();
         $fields = CRM_Core_BAO_UFGroup::getFields($this->_gid, false, CRM_CORE_ACTION_VIEW);
         // make sure we dont expose all fields based on permission
         $admin = false;
         $session =& CRM_Core_Session::singleton();
         if (CRM_Utils_System::checkPermission('administer users') || $this->_id == $session->get('userID')) {
             $admin = true;
         }
         if (!$admin) {
             foreach ($fields as $name => $field) {
                 // make sure that there is enough permission to expose this field
                 if ($field['visibility'] == 'User and User Admin Only') {
                     unset($fields[$name]);
                 }
             }
         }
         CRM_Core_BAO_UFGroup::getValues($this->_id, $fields, $values);
         $template->assign_by_ref('row', $values);
     }
     return trim($template->fetch('CRM/Profile/Page/Dynamic.tpl'));
 }
Example #7
0
 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = null)
 {
     $result = $this->_query->searchQuery($offset, $rowCount, $sort, false, false, false, false, false, $this->_contributionClause);
     // process the result of the query
     $rows = array();
     // check is the user has view/edit contribution permission
     $permission = CRM_CORE_PERMISSION_VIEW;
     if (CRM_Utils_System::checkPermission('edit contributions')) {
         $permission = CRM_CORE_PERMISSION_EDIT;
     }
     $mask = CRM_Core_Action::mask($permission);
     while ($result->fetch()) {
         $row = array();
         // the columns we are interested in
         foreach ($GLOBALS['_CRM_CONTRIBUTE_SELECTOR_SEARCH']['_properties'] as $property) {
             $row[$property] = $result->{$property};
         }
         $row['checkbox'] = CRM_CORE_FORM_CB_PREFIX . $result->contribution_id;
         $row['action'] = CRM_Core_Action::formLink(CRM_Contribute_Selector_Search::links(), $mask, array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context));
         $config =& CRM_Core_Config::singleton();
         $contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
         switch ($result->contact_type) {
             case 'Individual':
                 $contact_type .= 'ind.gif" alt="' . ts('Individual') . '" />';
                 break;
             case 'Household':
                 $contact_type .= 'house.png" alt="' . ts('Household') . '" height="16" width="16" />';
                 break;
             case 'Organization':
                 $contact_type .= 'org.gif" alt="' . ts('Organization') . '" height="16" width="18" />';
                 break;
         }
         $row['contact_type'] = $contact_type;
         $rows[] = $row;
     }
     return $rows;
 }
Example #8
0
 /**
  * make sure that the user has permission to access this group
  *
  * @param int $id   the id of the object
  * @param int $name the name or title of the object
  *
  * @return string   the permission that the user has (or null)
  * @access public
  * @static
  */
 function checkPermission($id, $title)
 {
     if (CRM_Utils_System::checkPermission('edit all contacts') || CRM_Utils_System::checkPermission(CRM_CORE_PERMISSION_EDIT_GROUPS . $title)) {
         return CRM_CORE_PERMISSION_EDIT;
     }
     if (CRM_Utils_System::checkPermission('view all contacts') || CRM_Utils_System::checkPermission(CRM_CORE_PERMISSION_VIEW_GROUPS . $title)) {
         return CRM_CORE_PERMISSION_VIEW;
     }
     return null;
 }
Example #9
0
 /**
  * We need to do slightly different things for groups vs saved search groups, hence we
  * reimplement browse from Page_Basic
  * @param int $action
  *
  * @return void
  * @access public
  */
 function browse($action = null)
 {
     $config =& CRM_Core_Config::singleton();
     $values = array();
     $object =& new CRM_Contact_BAO_Group();
     $object->domain_id = $config->domainID();
     $object->orderBy('title asc');
     $object->find();
     $groupPermission = CRM_Utils_System::checkPermission('edit groups') ? CRM_CORE_PERMISSION_EDIT : CRM_CORE_PERMISSION_VIEW;
     $this->assign('groupPermission', $groupPermission);
     while ($object->fetch()) {
         $permission = $this->checkPermission($object->id, $object->title);
         if ($permission) {
             $values[$object->id] = array();
             CRM_Core_DAO::storeValues($object, $values[$object->id]);
             if ($object->saved_search_id) {
                 $values[$object->id]['title'] = $values[$object->id]['title'] . ' (' . ts('Smart Group') . ')';
                 $links =& $this->links();
             } else {
                 $links =& $this->links();
             }
             if ($action == null) {
                 $action = array_sum(array_keys($links));
             }
             $action = $action & CRM_Core_Action::mask($groupPermission);
             $newAction = $action;
             if (array_key_exists('is_active', $object)) {
                 if ($object->is_active) {
                     $newAction -= CRM_CORE_ACTION_ENABLE;
                 } else {
                     $newAction -= CRM_CORE_ACTION_VIEW;
                     $newAction -= CRM_CORE_ACTION_DISABLE;
                 }
             }
             // make sure we only allow those actions that the user is permissioned for
             $newAction = $newAction & CRM_Core_Action::mask($permission);
             $values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', $values[$object->id]['visibility']);
             $values[$object->id]['action'] = CRM_Core_Action::formLink($links, $newAction, array('id' => $object->id, 'ssid' => $object->saved_search_id));
         }
     }
     $this->assign('rows', $values);
 }
Example #10
0
 /**
  * Given an id creates a subject/content array
  *
  * @param int $id id of the block
  *
  * @return array
  * @access public
  */
 function getContent($id)
 {
     CRM_Core_Block::setTemplateValues($id);
     $block = array();
     if (!CRM_Core_Block::getProperty($id, 'active')) {
         return null;
     }
     if (($id == CRM_CORE_BLOCK_ADD || $id == CRM_CORE_BLOCK_SHORTCUTS) && !CRM_Utils_System::checkPermission('add contacts') && !CRM_Utils_System::checkPermission('edit groups')) {
         return null;
     }
     $block['name'] = 'block-civicrm';
     $block['id'] = $block['name'] . '_' . $id;
     $block['subject'] = CRM_Core_Block::fetch($id, 'Subject.tpl', array('subject' => CRM_Core_Block::getProperty($id, 'subject')));
     $block['content'] = CRM_Core_Block::fetch($id, CRM_Core_Block::getProperty($id, 'template'), CRM_Core_Block::getProperty($id, 'templateValues'));
     return $block;
 }
Example #11
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 function buildQuickForm()
 {
     if ($this->_mode != CRM_PROFILE_FORM_MODE_REGISTER) {
         //check for mix profile (eg:  individual + other contact type)
         require_once "CRM/Core/BAO/UFField.php";
         if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
             CRM_Utils_System::setUFMessage(ts("This Profile includes fields for contact types other than 'Individuals' and can not be used to create/update contacts."));
             $config =& CRM_Core_Config::singleton();
             CRM_Utils_System::redirect($config->userFrameworkBaseURL);
         }
     }
     $this->assign('mode', $this->_mode);
     $this->assign('action', $this->_action);
     $this->assign('fields', $this->_fields);
     $this->assign('fieldset', $this->_fieldset);
     /*  if ($this->_mode & self::MODE_EDIT) {
             $group =& new CRM_Core_DAO_UFGroup();
             $group->id = $this->_gid;
             if ($group->find(true)) {
                 $this->assign('help_pre',  $group->help_pre);
                 $this->assign('help_post', $group->help_post);
             }
         }*/
     // do we need inactive options ?
     if ($this->_action & CRM_CORE_ACTION_VIEW) {
         $inactiveNeeded = true;
     } else {
         $inactiveNeeded = false;
     }
     // should we restrict what we display
     $admin = true;
     if ($this->_mode == CRM_PROFILE_FORM_MODE_EDIT) {
         $admin = false;
         $session =& CRM_Core_Session::singleton();
         // show all fields that are visibile: if we are a admin or the same user or in registration mode
         if (CRM_Utils_System::checkPermission('administer users') || $this->_id == $session->get('userID')) {
             $admin = true;
         }
     }
     require_once "CRM/Contribute/PseudoConstant.php";
     // add the form elements
     foreach ($this->_fields as $name => $field) {
         // make sure that there is enough permission to expose this field
         if (!$admin && $field['visibility'] == 'User and User Admin Only') {
             unset($this->_fields[$name]);
             continue;
         }
         // since the CMS manages the email field, suppress the email display if in
         // register mode which occur within the CMS form
         if ($this->_mode == CRM_PROFILE_FORM_MODE_REGISTER && substr($name, 0, 5) == 'email') {
             unset($this->_fields[$name]);
             continue;
         }
         $required = $this->_mode == CRM_PROFILE_FORM_MODE_SEARCH ? false : $field['is_required'];
         //if ( $field['name'] === 'state_province' ) {
         if (substr($field['name'], 0, 14) === 'state_province') {
             $this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(), $required);
         } else {
             if (substr($field['name'], 0, 7) === 'country') {
                 $this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required);
             } else {
                 if ($field['name'] === 'birth_date') {
                     $this->add('date', $field['name'], $field['title'], CRM_Core_SelectValues::date('birth'), $required);
                 } else {
                     if ($field['name'] === 'gender') {
                         $genderOptions = array();
                         $gender = CRM_Core_PseudoConstant::gender();
                         foreach ($gender as $key => $var) {
                             $genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key);
                         }
                         $this->addGroup($genderOptions, $field['name'], $field['title']);
                         if ($required) {
                             $this->addRule($field['name'], ts('%1 is a required field.', array(1 => $field['title'])), 'required');
                         }
                     } else {
                         if ($field['name'] === 'individual_prefix') {
                             $this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualPrefix(), $required);
                         } else {
                             if ($field['name'] === 'individual_suffix') {
                                 $this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualSuffix(), $required);
                             } else {
                                 if ($field['name'] === 'preferred_communication_method') {
                                     $this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_SelectValues::pcm());
                                 } else {
                                     if ($field['name'] === 'preferred_mail_format') {
                                         $this->add('select', $name, $field['title'], CRM_Core_SelectValues::pmf());
                                     } else {
                                         if (substr($field['name'], 0, 3) === 'is_' or substr($field['name'], 0, 7) === 'do_not_') {
                                             $this->add('checkbox', $name, $field['title'], $field['attributes'], $required);
                                         } else {
                                             if ($field['name'] === 'group') {
                                                 require_once 'CRM/Contact/Form/GroupTag.php';
                                                 CRM_Contact_Form_GroupTag::buildGroupTagBlock($this, $this->_id, CRM_CONTACT_FORM_GROUPTAG_GROUP, true, $required, $field['title'], null);
                                             } else {
                                                 if ($field['name'] === 'tag') {
                                                     require_once 'CRM/Contact/Form/GroupTag.php';
                                                     CRM_Contact_Form_GroupTag::buildGroupTagBlock($this, $this->_id, CRM_CONTACT_FORM_GROUPTAG_TAG, false, $required, null, $field['title']);
                                                 } else {
                                                     if (substr($field['name'], 0, 6) === 'custom') {
                                                         $customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name']);
                                                         CRM_Core_BAO_CustomField::addQuickFormElement($this, $name, $customFieldID, $inactiveNeeded, $required, false, $field['title']);
                                                         CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, $this->_id, $this->_mode);
                                                     } else {
                                                         if (in_array($field['name'], array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
                                                             $this->add('date', $field['name'], $field['title'], CRM_Core_SelectValues::date('manual', 3, 1), $required);
                                                             $this->addRule($field['name'], ts('Select a valid date.'), 'qfDate');
                                                         } else {
                                                             if ($field['name'] == 'payment_instrument') {
                                                                 $this->add('select', 'payment_instrument', ts('Paid By'), array('' => ts('-select-')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
                                                             } else {
                                                                 if ($field['name'] == 'contribution_type') {
                                                                     $this->add('select', 'contribution_type', ts('Contribution Type'), array('' => ts('-select-')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
                                                                 } else {
                                                                     $this->add('text', $name, $field['title'], $field['attributes'], $required);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (in_array($field['name'], array('non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) {
             $this->addRule($field['name'], ts('Please enter a valid amount.'), 'money');
         }
         if ($field['rule']) {
             if ($field['rule'] == 'email' && $this->_mode == CRM_PROFILE_FORM_MODE_SEARCH) {
                 continue;
             } else {
                 $this->addRule($name, ts('Please enter a valid %1', array(1 => $field['title'])), $field['rule']);
             }
         }
     }
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_CORE_ACTION_VIEW) {
         $this->freeze();
     }
     $this->setDefaults($defaults);
 }
Example #12
0
 /**
  * This function defines information for various menu items
  *
  * @static
  * @access public
  */
 function &items()
 {
     // helper variable for nicer formatting
     $drupalSyncExtra = ts('Synchronize Users to Contacts:') . ' ' . ts('CiviCRM will check each user record for a contact record. A new contact record will be created for each user where one does not already exist.') . '\\n\\n' . ts('Do you want to continue?');
     $backupDataExtra = ts('Backup Your Data:') . ' ' . ts('CiviCRM will create an SQL dump file with all of your existing data, and allow you to download it to your local computer. This process may take a long time and generate a very large file if you have a large number of records.') . '\\n\\n' . ts('Do you want to continue?');
     if (!$GLOBALS['_CRM_UTILS_MENU']['_items']) {
         // This is the minimum information you can provide for a menu item.
         $GLOBALS['_CRM_UTILS_MENU']['_items'] = array(array('path' => 'civicrm/admin', 'title' => ts('Administer CiviCRM'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 40), array('path' => 'civicrm/admin/access', 'title' => ts('Access Control'), 'type' => CRM_UTILS_MENU_CALLBACK, 'adminGroup' => ts('Manage'), 'icon' => 'admin/03.png', 'weight' => 110), array('path' => 'civicrm/admin/backup', 'title' => ts('Backup Data'), 'type' => CRM_UTILS_MENU_CALLBACK, 'extra' => 'onclick = "return confirm(\'' . $backupDataExtra . '\');"', 'adminGroup' => ts('Manage'), 'icon' => 'admin/14.png', 'weight' => 120), array('path' => 'civicrm/admin/synchUser', 'title' => ts('Synchronize Users-to-Contacts'), 'type' => CRM_UTILS_MENU_CALLBACK, 'extra' => 'onclick = "if (confirm(\'' . $drupalSyncExtra . '\')) this.href+=\'&amp;confirmed=1\'; else return false;"', 'adminGroup' => ts('Manage'), 'icon' => 'admin/Synch_user.png', 'weight' => 130), array('path' => 'civicrm/admin/activityType', 'title' => ts('Activity Types'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/05.png', 'weight' => 210), array('path' => 'civicrm/admin/uf/group', 'title' => ts('CiviCRM Profile'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/Profile.png', 'weight' => 220), array('path' => 'civicrm/admin/uf/group/field', 'title' => ts('CiviCRM Profile Fields'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 221), array('path' => 'civicrm/admin/custom/group', 'title' => ts('Custom Data'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/custm_data.png', 'weight' => 230), array('path' => 'civicrm/admin/custom/group/field', 'title' => ts('Custom Data Fields'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 231), array('path' => 'civicrm/admin/locationType', 'title' => ts('Location Types (Home, Work...)'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/13.png', 'weight' => 240), array('path' => 'civicrm/admin/tag', 'title' => ts('Tags (Categories)'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/11.png', 'weight' => 260), array('path' => 'civicrm/contact/domain', 'title' => ts('Edit Domain Information'), 'qs' => 'reset=1&action=update', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/domain.png', 'weight' => 270), array('path' => 'civicrm/admin/reltype', 'title' => ts('Relationship Types'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/rela_type.png', 'weight' => 250), array('path' => 'civicrm/admin/dupematch', 'title' => ts('Duplicate Matching'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Configure'), 'icon' => 'admin/duplicate_matching.png', 'weight' => 239), array('path' => 'civicrm/admin/gender', 'title' => ts('Gender Options (Male, Female...)'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Setup'), 'icon' => 'admin/01.png', 'weight' => 310), array('path' => 'civicrm/admin/IMProvider', 'title' => ts('Instant Messenger Services'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Setup'), 'icon' => 'admin/07.png', 'weight' => 320), array('path' => 'civicrm/admin/mobileProvider', 'title' => ts('Mobile Phone Providers'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Setup'), 'icon' => 'admin/08.png', 'weight' => 339), array('path' => 'civicrm/admin/prefix', 'title' => ts('Individual Prefixes (Ms, Mr...)'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Setup'), 'icon' => 'admin/title.png', 'weight' => 340), array('path' => 'civicrm/admin/suffix', 'title' => ts('Individual Suffixes (Jr, Sr...)'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'adminGroup' => ts('Setup'), 'icon' => 'admin/10.png', 'weight' => 350), array('path' => 'civicrm', 'title' => ts('CiviCRM'), 'access' => CRM_Utils_System::checkPermission('access CiviCRM'), 'callback' => 'civicrm_invoke', 'type' => CRM_UTILS_MENU_NORMAL_ITEM, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/quickreg', 'title' => ts('Quick Registration'), 'access' => 1, 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/contact/search', 'title' => ts('Contacts'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_ROOT_LOCAL_TASK, 'access' => CRM_Utils_System::checkPermission('access CiviCRM'), 'weight' => 10), array('path' => 'civicrm/contact/search/basic', 'title' => ts('Find Contacts'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_DEFAULT_LOCAL_TASK | CRM_UTILS_MENU_NORMAL_ITEM, 'access' => CRM_Utils_System::checkPermission('access CiviCRM'), 'weight' => 0), array('path' => 'civicrm/contact/search/advanced', 'qs' => 'force=1', 'title' => ts('Advanced Search'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'weight' => 1), array('path' => 'civicrm/contact/addI', 'title' => ts('New Individual'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('add contacts') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 1), array('path' => 'civicrm/contact/addO', 'title' => ts('New Organization'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('add contacts') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 1), array('path' => 'civicrm/contact/addH', 'title' => ts('New Household'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('add contacts') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 1), array('path' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%cid%%', 'title' => ts('View Contact'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_ROOT_LOCAL_TASK, 'weight' => 0), array('path' => 'civicrm/contact/view/basic', 'qs' => 'reset=1&cid=%%cid%%', 'title' => ts('Contact Summary'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_DEFAULT_LOCAL_TASK, 'weight' => 0), array('path' => 'civicrm/contact/view/activity', 'qs' => 'show=1&reset=1&cid=%%cid%%', 'title' => ts('Activities'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'weight' => 2), array('path' => 'civicrm/contact/view/rel', 'qs' => 'reset=1&cid=%%cid%%', 'title' => ts('Relationships'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'weight' => 3), array('path' => 'civicrm/contact/view/group', 'qs' => 'reset=1&cid=%%cid%%', 'title' => ts('Groups'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'weight' => 4), array('path' => 'civicrm/contact/view/note', 'qs' => 'reset=1&cid=%%cid%%', 'title' => ts('Notes'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'weight' => 5), array('path' => 'civicrm/contact/view/tag', 'qs' => 'reset=1&cid=%%cid%%', 'title' => ts('Tags'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_LOCAL_TASK, 'weight' => 6), array('path' => 'civicrm/contact/view/cd', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/group', 'title' => ts('Manage Groups'), 'qs' => 'reset=1', 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'access' => CRM_Utils_System::checkPermission('access CiviCRM'), 'weight' => 20), array('path' => 'civicrm/group/search', 'title' => ts('Group Members'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK), array('path' => 'civicrm/group/add', 'title' => ts('Create New Group'), 'access' => CRM_Utils_System::checkPermission('edit groups') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/import', 'title' => ts('Import'), 'qs' => 'reset=1', 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 400), array('path' => 'civicrm/import/contact', 'qs' => 'reset=1', 'title' => ts('Contacts'), 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 410), array('path' => 'civicrm/import/activityHistory', 'qs' => 'reset=1', 'title' => ts('Activity History'), 'access' => CRM_Utils_System::checkPermission('administer CiviCRM') && CRM_Utils_System::checkPermission('access CiviCRM'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_NORMAL_ITEM, 'weight' => 420), array('path' => 'civicrm/export/contact', 'title' => ts('Export Contacts'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/history/activity/detail', 'title' => ts('Activity Detail'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/history/activity/delete', 'title' => ts('Delete Activity'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/history/email', 'title' => ts('Sent Email Message'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/profile', 'title' => ts('Contact Information'), 'access' => CRM_Utils_System::checkPermission('profile listings and forms'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/profile/create', 'title' => ts('Add Contact Information'), 'access' => CRM_Utils_System::checkPermission('profile listings and forms'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0), array('path' => 'civicrm/profile/note', 'title' => ts('Notes about the Person'), 'access' => CRM_Utils_System::checkPermission('profile listings and forms'), 'type' => CRM_UTILS_MENU_CALLBACK, 'crmType' => CRM_UTILS_MENU_CALLBACK, 'weight' => 0));
         $config =& CRM_Core_Config::singleton();
         if (in_array('CiviContribute', $config->enableComponents)) {
             require_once 'CRM/Contribute/Menu.php';
             $items =& CRM_Contribute_Menu::main();
             $GLOBALS['_CRM_UTILS_MENU']['_items'] = array_merge($GLOBALS['_CRM_UTILS_MENU']['_items'], $items);
         }
         if (in_array('CiviMail', $config->enableComponents)) {
             require_once 'CRM/Mailing/Menu.php';
             $items =& CRM_Mailing_Menu::main();
             $GLOBALS['_CRM_UTILS_MENU']['_items'] = array_merge($GLOBALS['_CRM_UTILS_MENU']['_items'], $items);
         }
         CRM_Utils_Menu::initialize();
     }
     return $GLOBALS['_CRM_UTILS_MENU']['_items'];
 }