本文整理汇总了PHP中CRM_Core_Session类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Session类的具体用法?PHP CRM_Core_Session怎么用?PHP CRM_Core_Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* 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.'));
}
}
示例2: run
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();
}
示例3: formatUnitSize
/**
* 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;
}
}
示例4: run
/**
* 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'));
}
示例5: preProcess
/**
* 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);
}
}
示例6: create
/**
* 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;
}
示例7: buildForm
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'));
}
示例8: sendEmail
/**
* 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);
}
示例9: invalidKey
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);
}
示例10: postProcess
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();
}
示例11: noverwrite_civicrm_buildForm
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"));
}
示例12: postProcess
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']}"));
}
示例13: run
/**
* 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();
}
示例14: postProcess
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();
}
示例15: edit
/**
* 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();
}