Example #1
0
 /**
  * @param array $cxn
  * @param string $entity
  * @param string $action
  * @param array $params
  * @return mixed
  */
 public static function route($cxn, $entity, $action, $params)
 {
     $SUPER_PERM = array('administer CiviCRM');
     require_once 'api/v3/utils.php';
     // FIXME: Shouldn't the X-Forwarded-Proto check be part of CRM_Utils_System::isSSL()?
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL') && !CRM_Utils_System::isSSL() && strtolower(CRM_Utils_Array::value('X_FORWARDED_PROTO', CRM_Utils_System::getRequestHeaders())) != 'https') {
         return civicrm_api3_create_error('System policy requires HTTPS.');
     }
     // Note: $cxn and cxnId are authenticated before router is called.
     $dao = new CRM_Cxn_DAO_Cxn();
     $dao->cxn_id = $cxn['cxnId'];
     if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) {
         return civicrm_api3_create_error('Failed to lookup connection authorizations.');
     }
     if (!$dao->is_active) {
         return civicrm_api3_create_error('Connection is inactive.');
     }
     if (!is_string($entity) || !is_string($action) || !is_array($params)) {
         return civicrm_api3_create_error('API parameters are malformed.');
     }
     if (empty($cxn['perm']['api']) || !is_array($cxn['perm']['api']) || empty($cxn['perm']['grant']) || !(is_array($cxn['perm']['grant']) || is_string($cxn['perm']['grant']))) {
         return civicrm_api3_create_error('Connection has no permissions.');
     }
     $whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']);
     \Civi::service('dispatcher')->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist));
     CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
     if ($cxn['perm']['grant'] === '*') {
         CRM_Core_Config::singleton()->userPermissionTemp->grant($SUPER_PERM);
     } else {
         CRM_Core_Config::singleton()->userPermissionTemp->grant($cxn['perm']['grant']);
     }
     $params['check_permissions'] = 'whitelist';
     return civicrm_api($entity, $action, $params);
 }
Example #2
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;
 }
function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config = CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:k:pre";
    $longOptions = array('name=', 'pass=', 'key=', 'prefix=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('name' => 'n', 'pass' => 'p', 'key' => 'k', 'prefix' => 'pre');
    foreach ($vars as $var => $short) {
        ${$var} = NULL;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(TRUE, $name, $pass);
    //log the execution of script
    CRM_Core_Error::debug_log_message('NormalizePhone.php');
    // process all phones
    processPhones($config, $prefix);
}
Example #4
0
 /**
  * Function to build the form
  *
  * @access public
  * @return None
  */
 function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Add Contacts to Organization'));
     $this->addElement('text', 'name', ts('Find Target Organization'));
     $this->add('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + CRM_Contact_BAO_Relationship::getRelationType("Organization"), true);
     $searchRows = $this->get('searchRows');
     $searchCount = $this->get('searchCount');
     if ($searchRows) {
         $checkBoxes = array();
         $chekFlag = 0;
         foreach ($searchRows as $id => $row) {
             if (!$chekFlag) {
                 $chekFlag = $id;
             }
             $checkBoxes[$id] = $this->createElement('radio', null, null, null, $id);
         }
         $this->addGroup($checkBoxes, 'contact_check');
         if ($chekFlag) {
             $checkBoxes[$chekFlag]->setChecked(true);
         }
         $this->assign('searchRows', $searchRows);
     }
     $this->assign('searchCount', $searchCount);
     $this->assign('searchDone', $this->get('searchDone'));
     $this->assign('contact_type_display', ts('Organization'));
     $this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'form-submit'));
     $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'form-submit'));
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Add to Organization'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
Example #5
0
 /**
  * Build the form - it consists of
  *    - displaying the QILL (query in local language)
  *    - displaying elements for saving the search
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Smart Group'));
     require_once "CRM/Event/BAO/Query.php";
     // get the qill
     $query =& new CRM_Event_BAO_Query($this->get('formValues'));
     $qill = $query->qill();
     // need to save qill for the smarty template
     $this->assign('qill', $qill);
     // the name and description are actually stored with the group and not the saved search
     $this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), true);
     $this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
     // get the group id for the saved search
     $groupId = null;
     if (isset($this->_id)) {
         $params = array('saved_search_id' => $this->_id);
         require_once "CRM/Contact/BAO/Group.php";
         CRM_Contact_BAO_Group::retrieve($params, $values);
         $groupId = $values['id'];
         $this->addDefaultButtons(ts('Update Smart Group'));
     } else {
         $this->addDefaultButtons(ts('Save Smart Group'));
     }
     $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title'));
 }
Example #6
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Settings - Search Preferences'));
     // @todo remove the following adds in favour of setting via the settings array (above).
     $this->addYesNo('includeWildCardInName', ts('Automatic Wildcard'));
     $this->addYesNo('includeEmailInName', ts('Include Email'));
     $this->addYesNo('includeNickNameInName', ts('Include Nickname'));
     $this->addYesNo('includeAlphabeticalPager', ts('Include Alphabetical Pager'));
     $this->addYesNo('includeOrderByClause', ts('Include Order By Clause'));
     $this->addElement('text', 'smartGroupCacheTimeout', ts('Smart group cache timeout'), array('size' => 3, 'maxlength' => 5));
     $types = array('Contact', 'Individual', 'Organization', 'Household');
     $profiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $this->add('select', 'defaultSearchProfileID', ts('Default Contact Search Profile'), array('' => ts('- none -')) + $profiles, FALSE, array('class' => 'crm-select2 huge'));
     // Autocomplete for Contact Search (quick search etc.)
     $options = array(ts('Contact Name') => 1) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE));
     $this->addCheckBox('autocompleteContactSearch', ts('Autocomplete Contact Search'), $options, NULL, NULL, NULL, NULL, array('&nbsp;&nbsp;'));
     $element = $this->getElement('autocompleteContactSearch');
     $element->_elements[0]->_flagFrozen = TRUE;
     // Autocomplete for Contact Reference (custom fields)
     $optionsCR = array(ts('Contact Name') => 1) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE));
     $this->addCheckBox('autocompleteContactReference', ts('Contact Reference Options'), $optionsCR, NULL, NULL, NULL, NULL, array('&nbsp;&nbsp;'));
     $element = $this->getElement('autocompleteContactReference');
     $element->_elements[0]->_flagFrozen = TRUE;
     parent::buildQuickForm();
 }
Example #7
0
 /** 
  * Heart of the viewing process. The runner gets all the meta data for 
  * the contact and calls the appropriate type of page to view. 
  * 
  * @return void 
  * @access public 
  * 
  */
 function preProcess()
 {
     // Make sure case types have been configured for the component
     require_once 'CRM/Core/OptionGroup.php';
     $caseType = CRM_Core_OptionGroup::values('case_type');
     if (empty($caseType)) {
         $this->assign('notConfigured', 1);
         return;
     }
     $session =& CRM_Core_Session::singleton();
     $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session);
     CRM_Utils_System::setTitle(ts('CiviCase Dashboard'));
     $userID = $session->get('userID');
     if (!$allCases) {
         $this->assign('myCases', true);
     } else {
         $this->assign('myCases', false);
     }
     $this->assign('newClient', false);
     if (CRM_Core_Permission::check('add contacts')) {
         $this->assign('newClient', true);
     }
     require_once 'CRM/Case/BAO/Case.php';
     $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID);
     $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming');
     $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent');
     $this->assign('casesSummary', $summary);
     if (!empty($upcoming)) {
         $this->assign('upcomingCases', $upcoming);
     }
     if (!empty($recent)) {
         $this->assign('recentCases', $recent);
     }
 }
Example #8
0
 /**
  * Retrieve records.
  */
 public static function getBatchList()
 {
     $sortMapper = array(0 => 'batch.title', 1 => 'batch.type_id', 2 => '', 3 => 'batch.total', 4 => 'batch.status_id', 5 => '');
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
     $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
     $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
     $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
     $context = isset($_REQUEST['context']) ? CRM_Utils_Type::escape($_REQUEST['context'], 'String') : NULL;
     $params = $_REQUEST;
     if ($sort && $sortOrder) {
         $params['sortBy'] = $sort . ' ' . $sortOrder;
     }
     $params['page'] = $offset / $rowCount + 1;
     $params['rp'] = $rowCount;
     if ($context != 'financialBatch') {
         // data entry status batches
         $params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name');
     }
     $params['context'] = $context;
     // get batch list
     $batches = CRM_Batch_BAO_Batch::getBatchListSelector($params);
     $iFilteredTotal = $iTotal = $params['total'];
     if ($context == 'financialBatch') {
         $selectorElements = array('check', 'batch_name', 'payment_instrument', 'item_count', 'total', 'status', 'created_by', 'links');
     } else {
         $selectorElements = array('batch_name', 'type', 'item_count', 'total', 'status', 'created_by', 'links');
     }
     CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
     echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
     CRM_Utils_System::civiExit();
 }
Example #9
0
 public function run()
 {
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         }
     } else {
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
Example #10
0
 /**
  * set up variables to build the form
  *
  * @return void
  * @acess protected
  */
 function preProcess()
 {
     $this->_srcFID = CRM_Utils_Request::retrieve('fid', 'Positive', $this, true);
     $this->_srcGID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $this->_srcFID, 'custom_group_id');
     $this->_label = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $this->_srcFID, 'label');
     CRM_Utils_System::setTitle(ts('Custom Field Move: %1', array(1 => $this->_label)));
 }
 function run()
 {
     $sql = "SELECT * FROM civicrm_metrics_server ORDER BY site_name, timestamp";
     $dao =& CRM_Core_DAO::executeQuery($sql);
     $rows = array();
     while ($dao->fetch()) {
         $row = array();
         $row['id'] = $dao->id;
         $row['site_name'] = $dao->site_name;
         $row['site_url'] = $dao->site_url;
         $row['timestamp'] = $dao->timestamp;
         $row['type'] = $dao->type;
         $row['data'] = $dao->data;
         $rows[] = $row;
     }
     if (array_key_exists("export", $_REQUEST) && $_REQUEST['export'] == 'csv') {
         header('Content-type: text/csv');
         header('Content-disposition: attachment;filename=metrics_data_' . date("Ymd_HiO") . '.csv');
         $output = fopen('php://output', 'w');
         $headers = array("Id", "Site Name", "Site URL", "Timestamp", "Metric Type", "Metric Data");
         fputcsv($output, $headers);
         foreach ($rows as $row) {
             fputcsv($output, $row);
         }
         fclose($output);
         die;
     } else {
         CRM_Utils_System::setTitle(ts('Metrics Report'));
         $this->assign('data', $rows);
         $this->assign('headers', array_keys($rows[0]));
         parent::run();
     }
 }
 function __construct()
 {
     $this->initialize();
     CRM_Utils_System::authenticateScript(TRUE);
     //log the execution of script
     CRM_Core_Error::debug_log_message('CiviReportMail.php');
 }
 /**
  * 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 #14
0
 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_LocationType');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_LocationType::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected Location type has been deleted.'), ts('Record Deleted'), 'success');
         return;
     }
     // store the submitted values in an array
     $params = $this->exportValues();
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
     // action is taken depending upon the mode
     $locationType = new CRM_Core_DAO_LocationType();
     $locationType->name = $params['name'];
     $locationType->display_name = $params['display_name'];
     $locationType->vcard_name = $params['vcard_name'];
     $locationType->description = $params['description'];
     $locationType->is_active = $params['is_active'];
     $locationType->is_default = $params['is_default'];
     if ($params['is_default']) {
         $query = "UPDATE civicrm_location_type SET is_default = 0";
         CRM_Core_DAO::executeQuery($query);
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $locationType->id = $this->_id;
     }
     $locationType->save();
     CRM_Core_Session::setStatus(ts("The location type '%1' has been saved.", array(1 => $locationType->name)), ts('Saved'), 'success');
 }
 /**
  * set up variables to build the form
  *
  * @param null
  *
  * @return void
  * @acess protected
  */
 function preProcess()
 {
     $this->_fid = $this->get('fid');
     $this->_title = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $this->_fid, 'label', 'id');
     $this->assign('title', $this->_title);
     CRM_Utils_System::setTitle(ts('Confirm Price Field Delete'));
 }
Example #16
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 #17
0
 /**
  * format a monetary string
  *
  * Format a monetary string basing on the amount provided,
  * ISO currency code provided and a format string consisting of:
  *
  * %a - the formatted amount
  * %C - the currency ISO code (e.g., 'USD') if provided
  * %c - the currency symbol (e.g., '$') if available
  *
  * @param float  $amount    the monetary amount to display (1234.56)
  * @param string $currency  the three-letter ISO currency code ('USD')
  * @param string $format    the desired currency format
  *
  * @return string  formatted monetary string
  *
  * @static
  */
 static function format($amount, $currency = null, $format = null)
 {
     if (CRM_Utils_System::isNull($amount)) {
         return '';
     }
     $config =& CRM_Core_Config::singleton();
     if (!self::$_currencySymbols) {
         require_once "CRM/Core/PseudoConstant.php";
         $currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
         $currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
         self::$_currencySymbols = array_combine($currencySymbolName, $currencySymbol);
     }
     if (!$currency) {
         $currency = $config->defaultCurrency;
     }
     if (!$format) {
         $format = $config->moneyformat;
     }
     // money_format() exists only in certain PHP install (CRM-650)
     if (is_numeric($amount) and function_exists('money_format')) {
         $amount = money_format($config->moneyvalueformat, $amount);
     }
     $replacements = array('%a' => $amount, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, self::$_currencySymbols, $currency));
     return strtr($format, $replacements);
 }
Example #18
0
  function getTemplateFileName () {
    $request = CRM_Utils_System::currentPath();
    if (false !== strpos($request, '..')) {
      die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org");
    }

    $request = split ('/',$request);
    $tplfile = NULL;
    $smarty= CRM_Core_Smarty::singleton( );
    $smarty->assign("options",array());
    if (CRM_Utils_Array::value(2, $request)) {
      $tplfile = _civicrm_api_get_camel_name($request[2]);
      $tplfile = explode('?', $tplfile);
      $tpl = 'dataviz/'.$tplfile[0].'.tpl';
    }
    if (CRM_Utils_Array::value(3, $request)) {
      $r3 = _civicrm_api_get_camel_name($request[3]);
      $smarty->assign("id",$r3);
    }
    if (!$tplfile) {
      $tpl = "CRM/Civizualise/Page/Main.tpl";
    }
    if( !$smarty->template_exists($tpl) ){
      header("Status: 404 Not Found");
      die ("Can't find the requested template file templates/$tpl");
    }
    return $tpl;
  }
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     parent::preProcess();
     $participantNo = substr($this->_name, 12);
     //lets process in-queue participants.
     if ($this->_participantId && $this->_additionalParticipantIds) {
         $this->_additionalParticipantId = CRM_Utils_Array::value($participantNo, $this->_additionalParticipantIds);
     }
     $participantCnt = $participantNo + 1;
     $this->assign('formId', $participantNo);
     $this->_params = array();
     $this->_params = $this->get('params');
     $participantTot = $this->_params[0]['additional_participants'] + 1;
     $skipCount = count(array_keys($this->_params, "skip"));
     if ($skipCount) {
         $this->assign('skipCount', $skipCount);
     }
     CRM_Utils_System::setTitle(ts('Register Participant %1 of %2', array(1 => $participantCnt, 2 => $participantTot)));
     //CRM-4320, hack to check last participant.
     $this->_lastParticipant = FALSE;
     if ($participantTot == $participantCnt) {
         $this->_lastParticipant = TRUE;
     }
     $this->assign('lastParticipant', $this->_lastParticipant);
 }
Example #20
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'));
 }
Example #21
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 #22
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']);
     }
 }
 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 #24
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 #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>';
     }
 }
Example #26
0
 function run()
 {
     $config =& CRM_Core_Config::singleton();
     $ufAccessURL = CRM_Utils_System::url('admin/user/permissions');
     $this->assign('ufAccessURL', $ufAccessURL);
     return parent::run();
 }
 /**
  * @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 #28
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 for building Pledge Name combo box
  */
 function pledgeName(&$config)
 {
     $getRecords = FALSE;
     if (isset($_GET['name']) && $_GET['name']) {
         $name = CRM_Utils_Type::escape($_GET['name'], 'String');
         $name = str_replace('*', '%', $name);
         $whereClause = "p.creator_pledge_desc LIKE '%{$name}%' ";
         $getRecords = TRUE;
     }
     if (isset($_GET['id']) && is_numeric($_GET['id'])) {
         $pledgeId = CRM_Utils_Type::escape($_GET['id'], 'Integer');
         $whereClause = "p.id = {$pledgeId} ";
         $getRecords = TRUE;
     }
     if ($getRecords) {
         $query = "\nSELECT p.creator_pledge_desc, p.id\nFROM civicrm_pb_pledge p\nWHERE {$whereClause}\n";
         $dao = CRM_Core_DAO::executeQuery($query);
         $elements = array();
         while ($dao->fetch()) {
             $elements[] = array('name' => $dao->creator_pledge_desc, 'value' => $dao->id);
         }
     }
     if (empty($elements)) {
         $name = $_GET['name'];
         if (!$name && isset($_GET['id'])) {
             $name = $_GET['id'];
         }
         $elements[] = array('name' => trim($name, '*'), 'value' => trim($name, '*'));
     }
     echo CRM_Utils_JSON::encode($elements, 'value');
     CRM_Utils_System::civiExit();
 }
Example #30
0
 /**
  * Run dashboard
  *
  * @return void
  * @access public
  */
 function run()
 {
     CRM_Utils_System::setTitle(ts('Dashlets'));
     $this->assign('admin', CRM_Core_Permission::check('administer CiviCRM'));
     // get all dashlets
     $allDashlets = CRM_Core_BAO_Dashboard::getDashlets(FALSE);
     // get dashlets for logged in contact
     $currentDashlets = CRM_Core_BAO_Dashboard::getContactDashlets();
     $contactDashlets = $availableDashlets = array();
     foreach ($currentDashlets as $columnNo => $values) {
         foreach ($values as $val => $isMinimized) {
             list($weight, $dashletID) = explode('-', $val);
             $key = "{$dashletID}-{$isMinimized}";
             $contactDashlets[$columnNo][$key] = array('label' => $allDashlets[$dashletID]['label'], 'is_reserved' => $allDashlets[$dashletID]['is_reserved']);
             unset($allDashlets[$dashletID]);
         }
     }
     foreach ($allDashlets as $dashletID => $values) {
         $key = "{$dashletID}-0";
         $availableDashlets[$key] = array('label' => $values['label'], 'is_reserved' => $values['is_reserved']);
     }
     $this->assign('contactDashlets', $contactDashlets);
     $this->assign('availableDashlets', $availableDashlets);
     return parent::run();
 }