static function getRunner($skipEndUrl = FALSE)
 {
     // Setup the Queue
     $queue = CRM_Queue_Service::singleton()->create(array('name' => self::QUEUE_NAME, 'type' => 'Sql', 'reset' => TRUE));
     // reset pull stats.
     CRM_Core_BAO_Setting::setItem(array(), CRM_Mailchimp_Form_Setting::MC_SETTING_GROUP, 'pull_stats');
     $stats = array();
     // We need to process one list at a time.
     $groups = CRM_Mailchimp_Utils::getGroupsToSync(array(), null, $membership_only = TRUE);
     if (!$groups) {
         // Nothing to do.
         return FALSE;
     }
     // Each list is a task.
     $listCount = 1;
     foreach ($groups as $group_id => $details) {
         $stats[$details['list_id']] = array('mc_count' => 0, 'c_count' => 0, 'in_sync' => 0, 'added' => 0, 'removed' => 0);
         $identifier = "List " . $listCount++ . " " . $details['civigroup_title'];
         $task = new CRM_Queue_Task(array('CRM_Mailchimp_Form_Pull', 'syncPullList'), array($details['list_id'], $identifier), "Preparing queue for {$identifier}");
         // Add the Task to the Queue
         $queue->createItem($task);
     }
     // Setup the Runner
     $runnerParams = array('title' => ts('Import From Mailchimp'), 'queue' => $queue, 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, 'onEndUrl' => CRM_Utils_System::url(self::END_URL, self::END_PARAMS, TRUE, NULL, FALSE));
     // Skip End URL to prevent redirect
     // if calling from cron job
     if ($skipEndUrl == TRUE) {
         unset($runnerParams['onEndUrl']);
     }
     $runner = new CRM_Queue_Runner($runnerParams);
     static::updatePullStats($stats);
     return $runner;
 }
 /**
  * Format size.
  *
  */
 public static function formatUnitSize($size, $checkForPostMax = FALSE)
 {
     if ($size) {
         $last = strtolower($size[strlen($size) - 1]);
         switch ($last) {
             // The 'G' modifier is available since PHP 5.1.0
             case 'g':
                 $size *= 1024;
             case 'm':
                 $size *= 1024;
             case 'k':
                 $size *= 1024;
         }
         if ($checkForPostMax) {
             $maxImportFileSize = self::formatUnitSize(ini_get('upload_max_filesize'));
             $postMaxSize = self::formatUnitSize(ini_get('post_max_size'));
             if ($maxImportFileSize > $postMaxSize && $postMaxSize == $size) {
                 CRM_Core_Session::setStatus(ts("Note: Upload max filesize ('upload_max_filesize') should not exceed Post max size ('post_max_size') as defined in PHP.ini, please check with your system administrator."), ts("Warning"), "alert");
             }
             //respect php.ini upload_max_filesize
             if ($size > $maxImportFileSize && $size !== $postMaxSize) {
                 $size = $maxImportFileSize;
                 CRM_Core_Session::setStatus(ts("Note: Please verify your configuration for Maximum File Size (in MB) <a href='%1'>Administrator >> System Settings >> Misc</a>. It should support 'upload_max_size' as defined in PHP.ini.Please check with your system administrator.", array(1 => CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1'))), ts("Warning"), "alert");
             }
         }
         return $size;
     }
 }
 /**
  * @param CRM_Core_Form $form
  *
  * @return array
  */
 public static function process(&$form)
 {
     if ($form->getVar('_surveyId') <= 0) {
         return NULL;
     }
     $tabs = array('main' => array('title' => ts('Main Information'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'questions' => array('title' => ts('Questions'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'results' => array('title' => ts('Results'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE));
     $surveyID = $form->getVar('_surveyId');
     $class = $form->getVar('_name');
     $class = CRM_Utils_String::getClassName($class);
     $class = strtolower($class);
     if (array_key_exists($class, $tabs)) {
         $tabs[$class]['current'] = TRUE;
         $qfKey = $form->get('qfKey');
         if ($qfKey) {
             $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
         }
     }
     if ($surveyID) {
         $reset = !empty($_GET['reset']) ? 'reset=1&' : '';
         foreach ($tabs as $key => $value) {
             if (!isset($tabs[$key]['qfKey'])) {
                 $tabs[$key]['qfKey'] = NULL;
             }
             $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/survey/configure/{$key}", "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}");
             $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
         }
     }
     return $tabs;
 }
Example #4
0
 function buildForm(&$form)
 {
     $this->setTitle(ts('Include / Exclude Search'));
     $groups = CRM_Core_PseudoConstant::group();
     $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     if (count($groups) == 0 || count($tags) == 0) {
         CRM_Core_Session::setStatus(ts("At least one Group and Tag must be present for Custom Group / Tag search."), ts('Missing Group/Tag'));
         $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1');
         CRM_Utils_System::redirect($url);
     }
     $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $andOr = array('1' => ts('Show contacts that meet the Groups criteria AND the Tags criteria'), '0' => ts('Show contacts that meet the Groups criteria OR  the Tags criteria'));
     $form->addRadio('andOr', ts('AND/OR'), $andOr, NULL, '<br />', TRUE);
     $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     //add/remove buttons for groups
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     //add/remove buttons for tags
     $int->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outt->setButtonAttributes('add', array('value' => ts('Add >>')));
     $int->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outt->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags'));
 }
 function run()
 {
     $session = CRM_Core_Session::singleton();
     $apiURL = "https://graph.facebook.com/v2.3";
     $redirect_uri = rawurldecode(CRM_Utils_System::url('civicrm/civisocial/facebookcallback', NULL, TRUE));
     // Retreive client_id and client_secret from settings
     $is_enabled = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'enable_facebook'));
     if (!$is_enabled) {
         die("Backend not enabled.");
     }
     $client_secret = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'facebook_secret'));
     $client_id = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'facebook_app_id'));
     // Facebook sends a code to the callback url, this is further used to acquire
     // access token from facebook, which is needed to get all the data from facebook
     if (array_key_exists('code', $_GET)) {
         $facebook_code = $_GET['code'];
     } else {
         die("FACEBOOK FATAL: the request returned without the code. Please try loging in again.");
     }
     // Get the access token from facebook for the user
     $access_token = "";
     $access_token_response = $this->get_response($apiURL, "oauth/access_token", FALSE, array("client_id" => $client_id, "client_secret" => $client_secret, "code" => $facebook_code, "redirect_uri" => $redirect_uri));
     if (array_key_exists("error", $access_token_response)) {
         die($access_token_response["error"]);
         $access_token = "";
     } else {
         $access_token = $access_token_response["access_token"];
     }
     $user_data_response = $this->get_response($apiURL, "me", FALSE, array("access_token" => $access_token));
     $contact_id = CRM_Civisocial_BAO_CivisocialUser::handle_facebook_data($user_data_response);
     $this->assign('status', $contact_id);
     $session->set('userID', $contact_id);
     parent::run();
 }
Example #6
0
 public function postProcess()
 {
     $values = $this->exportValues();
     // check if EmailTyped matches Email address
     $result = CRM_Utils_String::compareStr($this->_email, $values['email_confirm'], TRUE);
     $job_id = $this->_job_id;
     $queue_id = $this->_queue_id;
     $hash = $this->_hash;
     $confirmURL = CRM_Utils_System::url("civicrm/mailing/{$this->_type}", "reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1");
     $this->assign('confirmURL', $confirmURL);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($confirmURL);
     if ($result == TRUE) {
         // Email address verified
         if (CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_domain($job_id, $queue_id, $hash)) {
             CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, NULL, TRUE, $job_id);
         }
         $statusMsg = ts('Email: %1 has been successfully opted out', array(1 => $values['email_confirm']));
         CRM_Core_Session::setStatus($statusMsg, '', 'success');
     } elseif ($result == FALSE) {
         // Email address not verified
         $statusMsg = ts('The email address: %1 you have entered does not match the email associated with this opt out request.', array(1 => $values['email_confirm']));
         CRM_Core_Session::setStatus($statusMsg, '', 'fail');
     }
 }
Example #7
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));
     }
 }
 public function postProcess()
 {
     $session = CRM_Core_Session::singleton();
     $session->setStatus('Rule ' . $this->rule->label . ' parameters updated', 'Rule parameters updated', 'success');
     $redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id=' . $this->rule->id, TRUE);
     CRM_Utils_System::redirect($redirectUrl);
 }
Example #9
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('Your do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         CRM_Report_BAO_Instance::delete($instanceId);
         CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.'));
     } else {
         require_once 'CRM/Core/OptionGroup.php';
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         if (strstr($templateInfo['name'], '_Form')) {
             $instanceInfo = array();
             CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper =& new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], null, null);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'));
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
Example #10
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm($check = FALSE)
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $types = CRM_Booking_BAO_Resource::buildOptions('type_id', 'create');
     $this->add('select', 'type_id', ts('Resource type'), array('' => ts('- select -')) + $types, TRUE, array());
     $this->add('text', 'label', ts('Label'), array('size' => 50, 'maxlength' => 255), TRUE);
     $this->add('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Booking_DAO_Resource', 'description'), FALSE);
     /*
         $this->addWysiwyg('description',
             ts('Description'),
             CRM_Core_DAO::getAttribute('CRM_Booking_DAO_Resource', 'description')
         );*/
     $this->add('text', 'weight', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Booking_DAO_Resource', 'weight'), TRUE);
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     $this->add('checkbox', 'is_unlimited', ts('Is Unlimited?'));
     $configSets = array('' => ts('- select -'));
     try {
         $activeSets = civicrm_api3('ResourceConfigSet', 'get', array('is_active' => 1, 'is_deleted' => 0));
         foreach ($activeSets['values'] as $key => $set) {
             $configSets[$key] = $set['title'];
         }
     } catch (CiviCRM_API3_Exception $e) {
     }
     $this->add('select', 'set_id', ts('Resource configuration set'), $configSets, TRUE);
     $locations = CRM_Booking_BAO_Resource::buildOptions('location_id', 'create');
     $this->add('select', 'location_id', ts('Resource Location'), array('' => ts('- select -')) + $locations, FALSE, array());
     $this->addFormRule(array('CRM_Admin_Form_Resource', 'formRule'), $this);
     $cancelURL = CRM_Utils_System::url('civicrm/admin/resource', "&reset=1");
     $cancelURL = str_replace('&amp;', '&', $cancelURL);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"))));
 }
Example #11
0
 public function preProcess()
 {
     require_once 'CRM/Contact/BAO/SearchCustom.php';
     $csID = CRM_Utils_Request::retrieve('csid', 'Integer', $this);
     $ssID = CRM_Utils_Request::retrieve('ssID', 'Integer', $this);
     $gID = CRM_Utils_Request::retrieve('gid', 'Integer', $this);
     list($this->_customSearchID, $this->_customSearchClass, $formValues) = CRM_Contact_BAO_SearchCustom::details($csID, $ssID, $gID);
     if (!$this->_customSearchID) {
         CRM_Core_Error::fatal('Could not get details for custom search.');
     }
     if (!empty($formValues)) {
         $this->_formValues = $formValues;
     }
     // set breadcrumb to return to Custom Search listings page
     $breadCrumb = array(array('title' => ts('Custom Searches'), 'url' => CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     // use the custom selector
     require_once 'CRM/Contact/Selector/Custom.php';
     $this->_selectorName = 'CRM_Contact_Selector_Custom';
     $this->set('customSearchID', $this->_customSearchID);
     $this->set('customSearchClass', $this->_customSearchClass);
     parent::preProcess();
     // instantiate the new class
     eval('$this->_customClass = new ' . $this->_customSearchClass . '( $this->_formValues );');
 }
 static function postProcess(&$form)
 {
     $values = $form->exportValues();
     $teamId = $values['pcp_team_contact'];
     $teampcpId = CRM_Pcpteams_Utils::getPcpIdByContactAndEvent($form->get('component_page_id'), $teamId);
     $userId = CRM_Pcpteams_Utils::getloggedInUserId();
     // Create Team Member of relation to this Team
     $cfpcpab = CRM_Pcpteams_Utils::getPcpABCustomFieldId();
     $cfpcpba = CRM_Pcpteams_Utils::getPcpBACustomFieldId();
     $customParams = array("custom_{$cfpcpab}" => $form->get('page_id'), "custom_{$cfpcpba}" => $teampcpId);
     CRM_Pcpteams_Utils::createTeamRelationship($userId, $teamId, $customParams);
     $form->_teamName = CRM_Contact_BAO_Contact::displayName($teamId);
     $form->set('teamName', $form->_teamName);
     $form->set('teamContactID', $teamId);
     $form->set('teamPcpId', $teampcpId);
     $teamAdminId = CRM_Pcpteams_Utils::getTeamAdmin($teampcpId);
     // Team Join: create activity
     $actParams = array('target_contact_id' => $teamId, 'assignee_contact_id' => $teamAdminId);
     CRM_Pcpteams_Utils::createPcpActivity($actParams, CRM_Pcpteams_Constant::C_AT_REQ_MADE);
     CRM_Core_Session::setStatus(ts('A notification has been sent to the team. Once approved, team should be visible on your page.'), ts('Team Request Sent'));
     //send email once the team request has done.
     list($teamAdminName, $teamAdminEmail) = CRM_Contact_BAO_Contact::getContactDetails($teamAdminId);
     $contactDetails = civicrm_api('Contact', 'get', array('version' => 3, 'sequential' => 1, 'id' => $userId));
     $emailParams = array('tplParams' => array('teamAdminName' => $teamAdminName, 'userFirstName' => $contactDetails['values'][0]['first_name'], 'userlastName' => $contactDetails['values'][0]['last_name'], 'teamName' => $form->_teamName, 'pageURL' => CRM_Utils_System::url('civicrm/pcp/manage', "reset=1&id={$teampcpId}", TRUE, NULL, FALSE, TRUE)), 'email' => array($teamAdminName => array('first_name' => $teamAdminName, 'last_name' => $teamAdminName, 'email-Primary' => $teamAdminEmail, 'display_name' => $teamAdminName)), 'valueName' => CRM_Pcpteams_Constant::C_MSG_TPL_JOIN_REQUEST);
     $sendEmail = CRM_Pcpteams_Utils::sendMail($userId, $emailParams);
 }
Example #13
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
     $args = func_get_args();
     $check = reset($args);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     foreach ($this->_settings as $setting => $group) {
         $settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
         $props = $settingMetaData['values'][$setting];
         if (isset($props['quick_form_type'])) {
             $add = 'add' . $props['quick_form_type'];
             if ($add == 'addElement') {
                 $this->{$add}($props['html_type'], $setting, ts($props['title']), CRM_Utils_Array::value($props['html_type'] == 'select' ? 'option_values' : 'html_attributes', $props, array()), $props['html_type'] == 'select' ? CRM_Utils_Array::value('html_attributes', $props) : NULL);
             } elseif ($add == 'addSelect') {
                 $options = civicrm_api3('Setting', 'getoptions', array('field' => $setting));
                 $this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props));
             } else {
                 $this->{$add}($setting, ts($props['title']));
             }
             $this->assign("{$setting}_description", ts($props['description']));
             if ($setting == 'max_attachments') {
                 //temp hack @todo fix to get from metadata
                 $this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
             }
             if ($setting == 'maxFileSize') {
                 //temp hack
                 $this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
             }
         }
     }
 }
/**
 * Implementation of hook_civicrm_enable
 */
function normalize_civicrm_enable()
{
    // jump to the setup screen after enabling extension
    $session = CRM_Core_Session::singleton();
    $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/setting/reformat'));
    return _normalize_civix_civicrm_enable();
}
Example #15
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     if (!CRM_Core_Permission::check('administer Reports')) {
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
     }
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl();
     $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value', 'String', FALSE);
     $extKey = strpos(CRM_Utils_Array::value('name', $templateInfo), '.');
     $reportClass = NULL;
     if ($extKey !== FALSE) {
         $ext = CRM_Extension_System::singleton()->getMapper();
         $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
         $templateInfo['name'] = $reportClass;
     }
     if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) {
         CRM_Utils_System::setTitle($templateInfo['label'] . ' - Template');
         $this->assign('reportTitle', $templateInfo['label']);
         $session = CRM_Core_Session::singleton();
         $session->set('reportDescription', $templateInfo['description']);
         $wrapper = new CRM_Utils_Wrapper();
         return $wrapper->run($templateInfo['name'], NULL, NULL);
     }
     if ($optionVal) {
         CRM_Core_Session::setStatus(ts('Could not find the report template. Make sure the report template is registered and / or url is correct.'), ts('Template Not Found'), 'error');
     }
     return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
 }
/**
 * Output navigation script tag
 *
 * @param array $params
 *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
 * @param CRM_Core_Smarty $smarty
 *   The Smarty object.
 *
 * @return string
 *   HTML
 */
function smarty_function_crmNavigationMenu($params, &$smarty)
{
    $config = CRM_Core_Config::singleton();
    //check if logged in user has access CiviCRM permission and build menu
    $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
    if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
        $buildNavigation = FALSE;
    }
    if ($config->userFrameworkFrontend) {
        $buildNavigation = FALSE;
    }
    if ($buildNavigation) {
        $session = CRM_Core_Session::singleton();
        $contactID = $session->get('userID');
        if ($contactID) {
            // These params force the browser to refresh the js file when switching user, domain, or language
            // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url
            // @see CRM_Admin_Page_AJAX::getNavigationMenu
            $lang = $config->lcMessages;
            $domain = CRM_Core_Config::domainID();
            $key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
            $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}");
            // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup
            $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE);
            return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>';
        }
    }
    return '';
}
Example #17
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']);
     }
 }
Example #18
0
 function __construct()
 {
     parent::__construct();
     $check = CRM_Core_Permission::check('access Contact Dashboard');
     if (!$check) {
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
         break;
     }
     $this->_contactId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $session =& CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     if (!$this->_contactId) {
         $this->_contactId = $userID;
     } else {
         if ($this->_contactId != $userID) {
             require_once 'CRM/Contact/BAO/Contact/Permission.php';
             if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::VIEW)) {
                 CRM_Core_Error::fatal(ts('You do not have permission to view this contact'));
             }
             if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
                 $this->_edit = false;
             }
         }
     }
 }
Example #19
0
 function run()
 {
     $config =& CRM_Core_Config::singleton();
     $ufAccessURL = CRM_Utils_System::url('admin/user/permissions');
     $this->assign('ufAccessURL', $ufAccessURL);
     return parent::run();
 }
Example #20
0
 /**
  * called when action is update.
  *
  * @param int $groupId
  *
  * @return null
  */
 public function edit($groupId = NULL)
 {
     $this->assign('edit', $this->_edit);
     if (!$this->_edit) {
         return NULL;
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'browse');
     if ($action == CRM_Core_Action::DELETE) {
         $groupContactId = CRM_Utils_Request::retrieve('gcid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
         $status = CRM_Utils_Request::retrieve('st', 'String', CRM_Core_DAO::$_nullObject, TRUE);
         if (is_numeric($groupContactId) && $status) {
             CRM_Contact_Page_View_GroupContact::del($groupContactId, $status, $this->_contactId);
         }
         $url = CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}");
         CRM_Utils_System::redirect($url);
     }
     $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_GroupContact', ts("Contact's Groups"), CRM_Core_Action::ADD, FALSE, FALSE, TRUE, FALSE);
     $controller->setEmbedded(TRUE);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}"), FALSE);
     $controller->reset();
     $controller->set('contactId', $this->_contactId);
     $controller->set('groupId', $groupId);
     $controller->set('context', 'user');
     $controller->set('onlyPublicGroups', $this->_onlyPublicGroups);
     $controller->process();
     $controller->run();
 }
Example #21
0
 /**
  * @return string
  */
 public function run()
 {
     $config = CRM_Core_Config::singleton();
     switch ($config->userFramework) {
         case 'Drupal':
             $this->assign('ufAccessURL', url('admin/people/permissions'));
             break;
         case 'Drupal6':
             $this->assign('ufAccessURL', url('admin/user/permissions'));
             break;
         case 'Joomla':
             //condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value
             if (version_compare(JVERSION, '3.0', 'lt')) {
                 JHTML::_('behavior.modal');
                 $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component';
                 $jparams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"';
                 $this->assign('ufAccessURL', $url);
                 $this->assign('jAccessParams', $jparams);
             } else {
                 $uri = (string) JUri::getInstance();
                 $return = urlencode(base64_encode($uri));
                 $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return;
                 $this->assign('ufAccessURL', $url);
                 $this->assign('jAccessParams', '');
             }
             break;
         case 'WordPress':
             $this->assign('ufAccessURL', CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1'));
             break;
     }
     return parent::run();
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/member/import', 'reset=1'));
     // check for post max size
     CRM_Core_Config_Defaults::formatUnitSize(ini_get('post_max_size'), TRUE);
 }
Example #23
0
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     $this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, FALSE, TRUE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
     if (isset($action)) {
         $this->assign('action', $action);
     }
     $session = CRM_Core_Session::singleton();
     $this->_config = new CRM_Core_DAO();
     if ($this->_system) {
         if (CRM_Core_Permission::check('administer CiviCRM')) {
             $this->_contactID = NULL;
         } else {
             CRM_Utils_System::fatal('You do not have permission to edit preferences');
         }
         $this->_config->contact_id = NULL;
     } else {
         if (!$this->_contactID) {
             $this->_contactID = $session->get('userID');
             if (!$this->_contactID) {
                 CRM_Utils_System::fatal('Could not retrieve contact id');
             }
             $this->set('cid', $this->_contactID);
         }
         $this->_config->contact_id = $this->_contactID;
     }
     $settings = Civi::settings();
     foreach ($this->_varNames as $groupName => $settingNames) {
         foreach ($settingNames as $settingName => $options) {
             $this->_config->{$settingName} = $settings->get($settingName);
         }
     }
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
 }
Example #24
0
 public function preProcess()
 {
     $this->set('searchFormName', 'Custom');
     $this->set('context', 'custom');
     $csID = CRM_Utils_Request::retrieve('csid', 'Integer', $this);
     $ssID = CRM_Utils_Request::retrieve('ssID', 'Integer', $this);
     $gID = CRM_Utils_Request::retrieve('gid', 'Integer', $this);
     list($this->_customSearchID, $this->_customSearchClass, $formValues) = CRM_Contact_BAO_SearchCustom::details($csID, $ssID, $gID);
     if (!$this->_customSearchID) {
         CRM_Core_Error::fatal('Could not get details for custom search.');
     }
     // stash this as a hidden element so we can potentially go there if the session
     // is reset but this is available in the POST
     $this->addElement('hidden', 'csid', $csID);
     if (!empty($formValues)) {
         $this->_formValues = $formValues;
     }
     // set breadcrumb to return to Custom Search listings page
     $breadCrumb = array(array('title' => ts('Custom Searches'), 'url' => CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     // use the custom selector
     self::$_selectorName = 'CRM_Contact_Selector_Custom';
     $this->set('customSearchID', $this->_customSearchID);
     $this->set('customSearchClass', $this->_customSearchClass);
     parent::preProcess();
     // instantiate the new class
     $this->_customClass = new $this->_customSearchClass($this->_formValues);
     // CRM-12747
     if (isset($this->_customClass->_permissionedComponent) && !self::isPermissioned($this->_customClass->_permissionedComponent)) {
         CRM_Utils_System::permissionDenied();
     }
 }
Example #25
0
 /**
  * Compute any messages which should be displayed after upgrade.
  *
  * @param string $postUpgradeMessage
  *   alterable.
  * @param string $rev
  *   an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
  * @return void
  */
 public function setPostUpgradeMessage(&$postUpgradeMessage, $rev)
 {
     if ($rev == '4.7.alpha1') {
         $config = CRM_Core_Config::singleton();
         // FIXME: Performing an upgrade step during postUpgrade message phase is probably bad
         $editor_id = self::updateWysiwyg();
         $msg = NULL;
         $ext_href = 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1') . '"';
         $dsp_href = 'href="' . CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1') . '"';
         $blog_href = 'href="https://civicrm.org/blogs/colemanw/big-changes-wysiwyg-editing-47"';
         switch ($editor_id) {
             // TinyMCE
             case 1:
                 $msg = ts('Your configured editor "TinyMCE" is no longer part of the main CiviCRM download. To continue using it, visit the <a %1>Manage Extensions</a> page to download and install the TinyMCE extension.', array(1 => $ext_href));
                 break;
                 // Drupal/Joomla editor
             // Drupal/Joomla editor
             case 3:
             case 4:
                 $msg = ts('CiviCRM no longer integrates with the "%1 Default Editor." Your wysiwyg setting has been reset to the built-in CKEditor. <a %2>Learn more...</a>', array(1 => $config->userFramework, 2 => $blog_href));
                 break;
         }
         if ($msg) {
             $postUpgradeMessage .= '<p>' . $msg . '</p>';
         }
         $postUpgradeMessage .= '<p>' . ts('CiviCRM now includes the easy-to-use CKEditor Configurator. To customize the features and display of your wysiwyg editor, visit the <a %1>Display Preferences</a> page. <a %2>Learn more...</a>', array(1 => $dsp_href, 2 => $blog_href)) . '</p>';
         $postUpgradeMessage .= '<br /><br />' . ts('Default version of the following System Workflow Message Templates have been modified: <ul><li>Personal Campaign Pages - Owner Notification</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).');
         $postUpgradeMessage .= '<p>' . ts('The custom fatal error template setting has been removed.') . '</p>';
     }
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     // reset action from the session
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $rcid = CRM_Utils_Request::retrieve('rcid', 'Positive', $this);
     $rcid = $rcid ? "&id={$rcid}" : '';
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1{$rcid}"));
     if ($this->_contactId) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_contactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
         }
         $this->_contactType = $contact->contact_type;
         // check for permissions
         if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
             CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
         }
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
         CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
     } else {
         CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
     }
 }
Example #27
0
 function run()
 {
     $upgrade = new CRM_Upgrade_Form();
     $message = ts('CiviCRM upgrade successful');
     if ($upgrade->checkVersion($upgrade->latestVersion)) {
         $message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $upgrade->latestVersion));
     } elseif ($upgrade->checkVersion('2.1.2') || $upgrade->checkVersion('2.1.3') || $upgrade->checkVersion('2.1.4') || $upgrade->checkVersion('2.1.5')) {
         // do nothing, db version is changed for all upgrades
     } elseif ($upgrade->checkVersion('2.1.0') || $upgrade->checkVersion('2.1') || $upgrade->checkVersion('2.1.1')) {
         // 2.1 to 2.1.2
         $this->runTwoOneTwo();
     } else {
         // 2.0 to 2.1
         for ($i = 1; $i <= 4; $i++) {
             $this->runForm($i);
         }
         // 2.1 to 2.1.2
         $this->runTwoOneTwo();
     }
     // just change the ver in the db, since nothing to upgrade
     $upgrade->setVersion($upgrade->latestVersion);
     // also cleanup the templates_c directory
     $config = CRM_Core_Config::singleton();
     $config->cleanup(1);
     $template = CRM_Core_Smarty::singleton();
     $template->assign('message', $message);
     $template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $upgrade->latestVersion)));
     $template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1'));
     $contents = $template->fetch('CRM/common/success.tpl');
     echo $contents;
 }
Example #28
0
 function buildForm(&$form)
 {
     $groups =& CRM_Core_PseudoConstant::group();
     $tags =& CRM_Core_PseudoConstant::tag();
     if (count($groups) == 0 || count($tags) == 0) {
         CRM_Core_Session::setStatus(ts("Atleast one Group and Tag must be present, for Custom Group / Tag search."));
         $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1');
         CRM_Utils_System::redirect($url);
     }
     $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $andOr =& $form->addElement('checkbox', 'andOr', 'Combine With (AND, Uncheck For OR)', null, array('checked' => 'checked'));
     $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     //add/remove buttons for groups
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     //add/remove buttons for tags
     $int->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outt->setButtonAttributes('add', array('value' => ts('Add >>')));
     $int->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outt->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags'));
 }
Example #29
0
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = TRUE;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 1\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query);
     if ($count != 0) {
         CRM_Core_Error::statusBounce("Please select only online contributions with Completed status.");
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams);
     $breadCrumb = array(array('url' => $url, 'title' => ts('Search Results')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     CRM_Utils_System::setTitle(ts('Print Contribution Receipts'));
 }
 function buildRows($sql, &$rows)
 {
     // safeguard for when there aren’t any log entries yet
     if (!$this->log_conn_id or !$this->log_date) {
         return;
     }
     $params = array(1 => array($this->log_conn_id, 'Integer'), 2 => array($this->log_date, 'String'));
     // let the template know who updated whom when
     $sql = "\n            SELECT who.id who_id, who.display_name who_name, whom.id whom_id, whom.display_name whom_name, l.is_deleted\n            FROM `{$this->loggingDB}`.log_civicrm_contact l\n            JOIN civicrm_contact who ON (l.log_user_id = who.id)\n            JOIN civicrm_contact whom ON (l.id = whom.id)\n            WHERE log_action = 'Update' AND log_conn_id = %1 AND log_date = %2 ORDER BY log_date DESC LIMIT 1\n        ";
     $dao =& CRM_Core_DAO::executeQuery($sql, $params);
     $dao->fetch();
     $this->assign('who_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->who_id}"));
     $this->assign('whom_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->whom_id}"));
     $this->assign('who_name', $dao->who_name);
     $this->assign('whom_name', $dao->whom_name);
     $this->assign('log_date', $this->log_date);
     // link back to summary report
     require_once 'CRM/Report/Utils/Report.php';
     $this->assign('summaryReportURL', CRM_Report_Utils_Report::getNextUrl('logging/contact/summary', 'reset=1', false, true));
     $rows = $this->diffsInTable('log_civicrm_contact');
     // add custom data changes
     $dao = CRM_Core_DAO::executeQuery("SHOW TABLES FROM `{$this->loggingDB}` LIKE 'log_civicrm_value_%'");
     while ($dao->fetch()) {
         $table = $dao->toValue("Tables_in_{$this->loggingDB}_(log_civicrm_value_%)");
         $rows = array_merge($rows, $this->diffsInTable($table));
     }
 }