/** * Function to process the form * * @access public * * @return None */ public function postProcess() { $params = $this->controller->exportValues($this->_name); if (self::updateSettingsWithDAO($params)) { CRM_Core_Session::setStatus(ts('Training settings saved.')); } }
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(); }
/** * 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; } }
/** * 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')); }
/** * 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); } }
/** * Takes an associative array and creates a Survey object. * * the function extract all the params it needs to initialize the create a * survey object. * * * @param array $params * * @return CRM_Survey_DAO_Survey */ public static function create(&$params) { if (empty($params)) { return FALSE; } if (!empty($params['is_default'])) { $query = "UPDATE civicrm_survey SET is_default = 0"; CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); } if (!CRM_Utils_Array::value('id', $params)) { if (!CRM_Utils_Array::value('created_id', $params)) { $session = CRM_Core_Session::singleton(); $params['created_id'] = $session->get('userID'); } if (!CRM_Utils_Array::value('created_date', $params)) { $params['created_date'] = date('YmdHis'); } } $dao = new CRM_Campaign_DAO_Survey(); $dao->copyValues($params); $dao->save(); if (!empty($params['custom']) && is_array($params['custom'])) { CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_survey', $dao->id); } return $dao; }
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')); }
/** * send the message to all the contacts and also insert a * contact activity in each contacts record * * @param array $contactIds the array of contact ids to send the email * @param string $subject the subject of the message * @param string $message the message contents * @param string $emailAddress use this 'to' email address instead of the default Primary address * * @return array (total, added, notAdded) count of emails sent * @access public * @static */ function sendEmail(&$contactIds, &$subject, &$message, $emailAddress) { $session =& CRM_Core_Session::singleton(); $userID = $session->get('userID'); list($fromDisplayName, $fromEmail, $fromDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID); if (!$fromEmail) { return array(count($contactIds), 0, count($contactIds)); } if (!trim($fromDisplayName)) { $fromDisplayName = $fromEmail; } $from = CRM_Utils_Mail::encodeAddressHeader($fromDisplayName, $fromEmail); // create the meta level record first $email =& new CRM_Core_BAO_EmailHistory(); $email->subject = $subject; $email->message = $message; $email->contact_id = $userID; $email->sent_date = date('Ymd'); $email->save(); $sent = $notSent = 0; foreach ($contactIds as $contactId) { if (CRM_Core_BAO_EmailHistory::sendMessage($from, $contactId, $subject, $message, $emailAddress, $email->id)) { $sent++; } else { $notSent++; } } return array(count($contactIds), $sent, $notSent); }
public function invalidKey() { $message = ts('Because your session timed out, we have reset the search page.'); CRM_Core_Session::setStatus($message); // see if we can figure out the url and redirect to the right search form // note that this happens really early on, so we cant use any of the form or controller // variables $config = CRM_Core_Config::singleton(); $qString = $_GET[$config->userFrameworkURLVar]; $args = "reset=1"; $path = 'civicrm/contact/search/advanced'; if (strpos($qString, 'basic') !== FALSE) { $path = 'civicrm/contact/search/basic'; } else { if (strpos($qString, 'builder') !== FALSE) { $path = 'civicrm/contact/search/builder'; } else { if (strpos($qString, 'custom') !== FALSE && isset($_REQUEST['csid'])) { $path = 'civicrm/contact/search/custom'; $args = "reset=1&csid={$_REQUEST['csid']}"; } } } $url = CRM_Utils_System::url($path, $args); CRM_Utils_System::redirect($url); }
function postProcess() { // define some stats $activities_total = count($this->_activityHolderIds); $activities_processed = 0; $activities_detected = 0; $activities_fixed = 0; // filter for relevant activities $activity_type_id = (int) CRM_Householdmerge_Logic_Configuration::getCheckHouseholdActivityTypeID(); $activity_status_ids = CRM_Householdmerge_Logic_Configuration::getFixableActivityStatusIDs(); $activity_ids = implode(',', $this->_activityHolderIds); $filter_query = "SELECT id AS activity_id FROM civicrm_activity\n WHERE civicrm_activity.activity_type_id = {$activity_type_id} \n AND civicrm_activity.status_id IN ({$activity_status_ids})\n AND civicrm_activity.id IN ({$activity_ids});"; $filtered_activities = CRM_Core_DAO::executeQuery($filter_query); // go through all activites and try to fix them while ($filtered_activities->fetch()) { $activities_processed += 1; $problem = CRM_Householdmerge_Logic_Problem::extractProblem($filtered_activities->activity_id); if ($problem) { $activities_detected += 1; if ($problem->fix()) { $activities_fixed += 1; } } } // show stats CRM_Core_Session::setStatus(ts('%1 of the %2 selected activities were processed, %3 of them could be fixed.', array(1 => $activities_detected, 2 => $activities_total, 3 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')), ts('%1 Household Problems Fixed', array(1 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')), $activities_fixed > 0 ? 'info' : 'warn'); parent::postProcess(); }
function noverwrite_civicrm_buildForm($formName, &$form) { $names = array("CRM_Profile_Form_Edit", "CRM_Event_Form_Registration_Register", "CRM_Contribute_Form_Contribution_Main"); if (!in_array($formName, $names)) { return; } // Don't invoke if we're using CiviMobile, since CiviMobile depends on users being able // to edit records via profiles. $path = CRM_Utils_Array::value('HTTP_REFERER', $_SERVER); if ($formName == 'CRM_Profile_Form_Edit' && preg_match('#civicrm/mobile#', $path)) { return; } $session = CRM_Core_Session::singleton(); if (!$session->get('userID') && !array_key_exists("cs", $_GET)) { return; // anonymous user, nothing to bloc } foreach (array('first_name', 'middle_name', 'last_name') as $f) { if (!$form->elementExists($f)) { continue; } $field = $form->getElement($f); if ($field && $field->_attributes["value"]) { $form->freeze($f); } } // if you want to bloc it at the js level only, uncomment the next line and comment out the freeze // CRM_Core_Resources::singleton()->addScript(file_get_contents(dirname( __FILE__ ) ."/js/noverwrite.js")); }
function postProcess() { $session = CRM_Core_Session::singleton(); $params = $this->exportValues(); $result = civicrm_api3('OptionValue', 'create', array('value' => $params['hour_value'], 'id' => CRM_Utils_Array::key($params['hour_type_select'], $this->_id))); $session->pushUserContext(CRM_Utils_System::url('civicrm/hour/editoption', "&value={$params['hour_value']}")); }
/** * Run the page. * * This method is called after the page is created. It checks for the * type of action and executes that action. * Finally it calls the parent's run method. * * @return void * @access public * */ function run() { // get the requested action $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); // assign vars to templates $this->assign('action', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); // set breadcrumb to append to 2nd layer pages $breadCrumb = array(array('title' => ts('Manage Items'), 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'))); // what action to take ? if ($action & CRM_Core_Action::DISABLE) { require_once 'CRM/Auction/BAO/Auction.php'; CRM_Auction_BAO_Auction::setIsActive($id, 0); } elseif ($action & CRM_Core_Action::ENABLE) { require_once 'CRM/Auction/BAO/Auction.php'; CRM_Auction_BAO_Auction::setIsActive($id, 1); } elseif ($action & CRM_Core_Action::DELETE) { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse')); $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Auction_Delete', 'Delete Auction', $action); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); $controller->set('id', $id); $controller->process(); return $controller->run(); } // finally browse the auctions $this->browse(); // parent run parent::run(); }
public function postProcess() { $values = $this->exportValues(); $options = $this->getColorOptions(); CRM_Core_Session::setStatus(ts('You picked color "%1"', array(1 => $options[$values['favorite_color']]))); parent::postProcess(); }
/** * 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(); }
/** * 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(); }
/** * Get AngularJS modules and their dependencies * * @return array * list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules) * @see CRM_Utils_Hook::angularModules */ public function getAngularModules() { // load angular files only if valid permissions are granted to the user if (!CRM_Core_Permission::check('access CiviMail') && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) { return array(); } $result = array(); $result['crmMailing'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailing.js', 'ang/crmMailing/*.js'), 'css' => array('ang/crmMailing.css'), 'partials' => array('ang/crmMailing')); $result['crmMailingAB'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailingAB.js', 'ang/crmMailingAB/*.js', 'ang/crmMailingAB/*/*.js'), 'css' => array('ang/crmMailingAB.css'), 'partials' => array('ang/crmMailingAB')); $result['crmD3'] = array('ext' => 'civicrm', 'js' => array('ang/crmD3.js', 'bower_components/d3/d3.min.js')); $config = CRM_Core_Config::singleton(); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); // Get past mailings // CRM-16155 - Limit to a reasonable number $civiMails = civicrm_api3('Mailing', 'get', array('is_completed' => 1, 'mailing_type' => array('IN' => array('standalone', 'winner')), 'return' => array('id', 'name', 'scheduled_date'), 'sequential' => 1, 'options' => array('limit' => 500, 'sort' => 'is_archived asc, scheduled_date desc'))); // Generic params $params = array('options' => array('limit' => 0), 'sequential' => 1); $groupNames = civicrm_api3('Group', 'get', $params + array('is_active' => 1, 'check_permissions' => TRUE, 'return' => array('title', 'visibility', 'group_type', 'is_hidden'))); $headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array('is_active' => 1, 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'))); $emailAdd = civicrm_api3('Email', 'get', array('sequential' => 1, 'return' => "email", 'contact_id' => $contactID)); $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array('sequential' => 1, 'is_active' => 1, 'return' => array("id", "msg_title"), 'workflow_id' => array('IS NULL' => ""))); $mailTokens = civicrm_api3('Mailing', 'gettokens', array('entity' => array('contact', 'mailing'), 'sequential' => 1)); $fromAddress = civicrm_api3('OptionValue', 'get', $params + array('option_group_id' => "from_email_address", 'domain_id' => CRM_Core_Config::domainID())); CRM_Core_Resources::singleton()->addSetting(array('crmMailing' => array('civiMails' => $civiMails['values'], 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents), 'groupNames' => $groupNames['values'], 'headerfooterList' => $headerfooterList['values'], 'mesTemplate' => $mesTemplate['values'], 'emailAdd' => $emailAdd['values'], 'mailTokens' => $mailTokens['values'], 'contactid' => $contactID, 'requiredTokens' => CRM_Utils_Token::getRequiredTokens(), 'enableReplyTo' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo'), 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check'), 'fromAddress' => $fromAddress['values'], 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array('id' => 'user_contact_id', 'return' => 'email')), 'visibility' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::groupVisibility()), 'workflowEnabled' => CRM_Mailing_Info::workflowEnabled())))->addPermissions(array('view all contacts', 'access CiviMail', 'create mailings', 'schedule mailings', 'approve mailings', 'delete in CiviMail', 'edit message templates')); return $result; }
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); }
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); } }
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); }
/** * Add relationships from form. */ public function addRelationships() { if (!is_array($this->_contactIds)) { // Could this really happen? return; } $relationshipTypeParts = explode('_', $this->params['relationship_type_id']); $params = array('relationship_type_id' => $relationshipTypeParts[0], 'is_active' => 1); $secondaryRelationshipSide = $relationshipTypeParts[1]; $primaryRelationshipSide = $relationshipTypeParts[2]; $primaryFieldName = 'contact_id_' . $primaryRelationshipSide; $secondaryFieldName = 'contact_id_' . $secondaryRelationshipSide; $relationshipLabel = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $params['relationship_type_id'], "label_{$secondaryRelationshipSide}_{$primaryRelationshipSide}"); $params[$secondaryFieldName] = $this->_contactIds; $params[$primaryFieldName] = $this->params['contact_check']; $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $primaryRelationshipSide); $relatedContactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$primaryFieldName], 'display_name'); $status = array(ts('%count %2 %3 relationship created', array('count' => $outcome['valid'], 'plural' => '%count %2 %3 relationships created', 2 => $relationshipLabel, 3 => $relatedContactName))); if ($outcome['duplicate']) { $status[] = ts('%count was skipped because the contact is already %2 %3', array('count' => $outcome['duplicate'], 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationshipLabel, 3 => $relatedContactName)); } if ($outcome['invalid']) { $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array('count' => $outcome['invalid'], 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship')); } $status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>'; CRM_Core_Session::setStatus($status, ts('Relationship created.', array('count' => $outcome['valid'], 'plural' => 'Relationships created.')), 'success', array('expires' => 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); }
/** * List activities as dashlet * * @return none * * @access public */ function run() { $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); // a user can always view their own activity // if they have access CiviCRM permission $permission = CRM_Core_Permission::VIEW; // make the permission edit if the user has edit permission on the contact require_once 'CRM/Contact/BAO/Contact/Permission.php'; if (CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) { $permission = CRM_Core_Permission::EDIT; } $admin = CRM_Core_Permission::check('view all activities') || CRM_Core_Permission::check('administer CiviCRM'); require_once 'CRM/Core/Selector/Controller.php'; $output = CRM_Core_Selector_Controller::SESSION; require_once 'CRM/Activity/Selector/Activity.php'; $selector = new CRM_Activity_Selector_Activity($contactID, $permission, $admin, 'home'); $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output); $controller->setEmbedded(true); $controller->run(); $controller->moveFromSessionToTemplate(); return parent::run(); }
/** * Run dashboard. * * @return void */ public function run() { // Add dashboard js and css $resources = CRM_Core_Resources::singleton(); $resources->addScriptFile('civicrm', 'js/jquery/jquery.dashboard.js', 0, 'html-header', FALSE); $resources->addStyleFile('civicrm', 'css/dashboard.css'); $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); CRM_Utils_System::setTitle(ts('CiviCRM Home')); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($resetCache) { CRM_Core_BAO_Dashboard::resetDashletCache($contactID); } // call hook to get html from other modules // ignored but needed to prevent warnings $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW; $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement); if (is_array($html)) { $this->assign_by_ref('hookContent', $html); $this->assign('hookContentPlacement', $contentPlacement); } $communityMessages = CRM_Core_CommunityMessages::create(); if ($communityMessages->isEnabled()) { $message = $communityMessages->pick(); if ($message) { $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup'])); } } return parent::run(); }
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')); }
/** * 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 ''; }
/** * Simple ping function to test for liveness. * * @param string $var * The string to be echoed. * * @return string */ public static function ping($var = NULL) { $session = CRM_Core_Session::singleton(); $key = $session->get('key'); //$session->set( 'key', $var ); return self::simple(array('message' => "PONG: {$key}")); }
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; } } } }
/** * Method to build where part of query */ function where() { $clauses = array(); foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); // if user id value contains 0 for current user, replace value with current user if ($fieldName == 'account_id') { foreach ($this->_params['account_id_value'] as $paramKey => $userIdValue) { if ($userIdValue == 0) { $session = CRM_Core_Session::singleton(); $this->_params['account_id_value'][$paramKey] = $session->get('userID'); } } } $clause = $this->whereClause($field, $op, CRM_Utils_Array::value("{$fieldName}_value", $this->_params), CRM_Utils_Array::value("{$fieldName}_min", $this->_params), CRM_Utils_Array::value("{$fieldName}_max", $this->_params)); if (!empty($clause)) { $clauses[] = $clause; } } } } if (empty($clauses)) { $this->_where = ""; } else { $this->_where = "WHERE " . implode(' AND ', $clauses); } }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { $session =& CRM_Core_Session::singleton(); //this is done to unset searchRows variable assign during AddToHousehold and AddToOrganization $this->set('searchRows', ''); $context = $this->get('context'); if ($context == 'smog' || $context == 'amtg') { $url = CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid='); if ($this->get('context') == 'smog') { $session->replaceUserContext($url . $this->get('gid')); } else { $session->replaceUserContext($url . $this->get('amtgID')); } return; } $ssID = $this->get('ssID'); if (isset($ssID)) { if ($this->_action == CRM_CORE_ACTION_BASIC) { $fragment = 'search'; } else { $fragment = 'search/advanced'; } $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, 'reset=1&force=1&ssID=' . $ssID); $session->replaceUserContext($url); return; } }