本文整理汇总了PHP中CRM_Utils_System::statusBounce方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::statusBounce方法的具体用法?PHP CRM_Utils_System::statusBounce怎么用?PHP CRM_Utils_System::statusBounce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::statusBounce方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: synchronize
/**
* Given a UF user object, make sure there is a contact
* object for this user. If the user has new values, we need
* to update the CRM DB with the new values
*
* @param Object $user the drupal user object
* @param boolean $update has the user object been edited
* @param $uf
*
* @return void
* @access public
* @static
*/
function synchronize(&$user, $update, $uf)
{
$session =& CRM_Core_Session::singleton();
if (!is_object($session)) {
return;
}
if ($uf == 'Drupal') {
$key = 'uid';
$mail = 'mail';
} else {
if ($uf == 'Mambo') {
$key = 'id';
$mail = 'email';
} else {
CRM_Utils_System::statusBounce(ts('Please set the user framework variable'));
}
}
// have we already processed this user, if so early
// return.
$userID = $session->get('userID');
$ufID = $session->get('ufID');
if (!$update && $ufID == $user->{$key}) {
return;
}
// reset the session if we are a different user
if ($ufID && $ufID != $user->{$key}) {
$session->reset();
}
// make sure we load the mambo object to get valid information
if ($uf == 'Mambo') {
$user->load();
}
// if the id of the object is zero (true for drupal), return early
if ($user->{$key} == 0) {
return;
}
$ufmatch =& CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $user->{$key}, $user->{$mail}, $uf);
if (!$ufmatch) {
return;
}
$session->set('ufID', $ufmatch->uf_id);
$session->set('userID', $ufmatch->contact_id);
$session->set('domainID', $ufmatch->domain_id);
$session->set('ufEmail', $ufmatch->email);
if ($update) {
// the only information we care about is email, so lets check that
if ($user->{$mail} != $ufmatch->email) {
// email has changed, so we need to change all our primary email also
$ufmatch->email = $user->{$mail};
$ufmatch->save();
$query = "\nUPDATE civicrm_contact\nLEFT JOIN civicrm_location ON ( civicrm_location.entity_table = 'civicrm_contact' AND\n civicrm_contact.id = civicrm_location.entity_id AND\n civicrm_location.is_primary = 1 )\nLEFT JOIN civicrm_email ON ( civicrm_location.id = civicrm_email.location_id AND\n civicrm_email.is_primary = 1 )\nSET civicrm_email.email = '" . $user->{$mail} . "' WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($ufmatch->contact_id, 'Integer');
CRM_Core_DAO::executeQuery($query);
}
}
}
示例2: backupData
/**
* Function to create the dump from backup.sql
*
* @param NULL
*
* @return void
*
* @access public
* @static
*/
function backupData()
{
global $civicrm_root;
$file = $civicrm_root . '/sql/civicrm_backup.mysql';
//we get the upload folder for storing the huge backup data
$config =& new CRM_Core_Config();
chdir($config->uploadDir);
$fileName = 'domainDump.sql';
//get the username and password from dsn
$values = DB::parseDSN($config->dsn);
$username = $values['username'];
$password = $values['password'];
$database = $values['database'];
if (is_file($fileName)) {
unlink($fileName);
}
//read the contents of the file into an array
$sql = file($file);
if (empty($sql)) {
CRM_Utils_System::statusBounce(ts('We could not find the backup sql script. Check %1 in the CiviCRM root directory.', array(1 => 'sql/civicrm_backup.mysql')));
}
// make sure mysqldump exists
if (!file_exists($config->mysqlPath . 'mysqldump')) {
CRM_Utils_System::statusBounce(ts('We could not find the mysqldump program. Check the configuration variable CIVICRM_MYSQL_PATH in your CiviCRM config file.'));
}
foreach ($sql as $value) {
$val = explode("|", $value);
$domainDAO =& new CRM_Core_DAO();
$domainDAO->query($val[1]);
$ids = array();
while ($domainDAO->fetch()) {
$ids[] = $domainDAO->id;
}
//if ( !empty($ids) ) {
$dumpCommand = $config->mysqlPath . "mysqldump -u" . $username . " -p" . $password . " --opt --single-transaction " . $database . " " . $val[0] . " -w 'id IN ( " . implode(",", $ids) . " ) ' >> " . $fileName;
exec($dumpCommand);
//} fixed for Issue CRM-670
}
$tarFileName = 'backupData.tgz';
if (is_file($tarFileName)) {
unlink($tarFileName);
}
$tarCommand = 'tar -czf ' . $tarFileName . ' ' . $fileName;
exec($tarCommand);
$fileSize = filesize($tarFileName);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('ContentType Extension=".tgz" ContentType="application/x-compressed" ');
header('Content-Length: ' . $fileSize);
header('Content-Disposition: attachment; filename=backupData.tgz');
readfile($tarFileName);
}
示例3: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the callback, module and activity id
$action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
$id = CRM_Utils_Request::retrieve('id', $this);
$dao =& new CRM_Core_DAO_ActivityHistory();
$dao->activity_id = $id;
$dao->activity_type = ts('Email Sent');
if ($dao->find(true)) {
$cid = $dao->entity_id;
}
$dao =& new CRM_Core_DAO_EmailHistory();
$dao->id = $id;
if ($dao->find(true)) {
// get the display name and email for the contact
list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
if (!trim($toContactName)) {
$toContactName = $toContactEmail;
}
if (trim($toContactEmail)) {
$toContactName = "\"{$toContactName}\" <{$toContactEmail}>";
}
$this->assign('toName', $toContactName);
// get the display name and email for the contact
list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
if (!trim($fromContactEmail)) {
CRM_Utils_System::statusBounce(ts('Your user record does not have a valid email address'));
}
if (!trim($fromContactName)) {
$fromContactName = $fromContactEmail;
}
$this->assign('fromName', "\"{$fromContactName}\" <{$fromContactEmail}>");
$this->assign('sentDate', $dao->sent_date);
$this->assign('subject', $dao->subject);
$this->assign('message', $dao->message);
// get the display name and images for the contact
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
require_once 'CRM/Utils/Menu.php';
// also add the cid params to the Menu array
CRM_Utils_Menu::addParam('cid', $cid);
// create menus ..
$startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
$startWeight++;
require_once 'CRM/Core/BAO/CustomGroup.php';
CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
}
parent::run();
}
示例4: preProcess
function preProcess()
{
$mailing_id = CRM_Utils_Request::retrieve('mid', $this, null);
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing =& new CRM_Mailing_BAO_Mailing();
$mailing->id = $mailing_id;
$session =& CRM_Core_Session::singleton();
$mailing->domain_id = $session->get('domainID');
if (!$mailing->find(true)) {
CRM_Utils_System::statusBounce(ts('Invalid Mailing ID'));
}
$this->assign('mailing_name', $mailing->name);
$this->set('mailing_id', $mailing->id);
$this->set('mailing_name', $mailing->name);
}
示例5: preProcess
function preProcess()
{
$job_id = CRM_Utils_Request::retrieve('jid', $this, null);
$queue_id = CRM_Utils_Request::retrieve('qid', $this, null);
$hash = CRM_Utils_Request::retrieve('h', $this, null);
$q =& CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if ($q == null) {
/** ERROR **/
CRM_Utils_System::statusBounce(ts('Invalid form parameters.'));
}
$mailing =& $q->getMailing();
/* Show the subject instead of the name here, since it's being
* displayed to external contacts/users */
CRM_Utils_System::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject)));
$this->set('queue_id', $queue_id);
$this->set('job_id', $job_id);
$this->set('hash', $hash);
}
示例6: CRM_Core_BAO_Note
/**
* takes an associative array and creates a note object
*
* the function extract all the params it needs to initialize the create a
* note object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Core_BAO_Note object
* @access public
* @static
*/
function &add(&$params)
{
$dataExists = CRM_Core_BAO_Note::dataExists($params);
if (!$dataExists) {
return null;
}
$note =& new CRM_Core_BAO_Note();
$params['modified_date'] = date("Ymd");
$params['entity_id'] = $params['entity_id'];
$params['entity_table'] = $params['entity_table'];
$note->copyValues($params);
$session =& CRM_Core_Session::singleton();
$note->contact_id = $session->get('userID');
if (!$note->contact_id) {
if ($params['entity_table'] == 'civicrm_contact') {
$note->contact_id = $params['entity_id'];
} else {
CRM_Utils_System::statusBounce(ts('We could not find your logged in user ID'));
}
}
$note->save();
return $note;
}
示例7: postProcess
/**
*
* @access public
* @return None
*/
function postProcess()
{
$session =& CRM_Core_Session::singleton();
// store the submitted values in an array
$params = $this->exportValues();
// action is taken depending upon the mode
$note =& new CRM_Core_DAO_Note();
$note->note = $params['note'];
$note->contact_id = $session->get('userID');
if (!$note->contact_id) {
CRM_Utils_System::statusBounce(ts('We could not find your logged in user ID'));
}
$note->modified_date = date("Ymd");
if ($this->_action & CRM_CORE_ACTION_DELETE) {
CRM_Core_BAO_Note::del($this->_id);
//CRM_Core_Session::setStatus( ts('Selected Note has been Deleted Successfuly.') );
return;
}
if ($this->_action & CRM_CORE_ACTION_UPDATE) {
$note->id = $this->_id;
} else {
$note->entity_table = $this->_entityTable;
$note->entity_id = $this->_entityId;
}
$note->save();
CRM_Core_Session::setStatus(ts('Your Note has been saved.'));
}
示例8: createLocation
/**
* assign smarty variables to the template that will be used by google api to plot the contacts
*
* @param array $contactIds list of contact ids that we need to plot
* @param int $locationId location_id
*
* @return string the location of the file we have created
* @access protected
*/
function createLocation($contactIds, $locationId = null)
{
$config =& CRM_Core_Config::singleton();
$this->assign('query', 'CiviCRM Search Query');
$this->assign('mapProvider', $config->mapProvider);
$this->assign('mapKey', $config->mapAPIKey);
require_once 'CRM/Contact/BAO/Contact.php';
$locations =& CRM_Contact_BAO_Contact::getMapInfo($this->_contactIds, $locationId);
if (empty($locations)) {
CRM_Utils_System::statusBounce(ts('This contact\'s primary address does not contain latitude/longitude information and can not be mapped.'));
} else {
$session =& CRM_Core_Session::singleton();
$redirect = $session->readUserContext();
$additionalBreadCrumb = "<a href=\"{$redirect}\">" . ts('Search Results') . '</a>';
CRM_Utils_System::appendBreadCrumb($additionalBreadCrumb);
}
$this->assign_by_ref('locations', $locations);
$sumLat = $sumLng = 0;
$maxLat = $maxLng = -400;
$minLat = $minLng = +400;
foreach ($locations as $location) {
$sumLat += $location['lat'];
$sumLng += $location['lng'];
if ($location['lat'] > $maxLat) {
$maxLat = $location['lat'];
}
if ($location['lat'] < $minLat) {
$minLat = $location['lat'];
}
if ($location['lng'] > $maxLng) {
$maxLng = $location['lng'];
}
if ($location['lng'] < $minLng) {
$minLng = $location['lng'];
}
}
$center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
$span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
$this->assign_by_ref('center', $center);
$this->assign_by_ref('span', $span);
}
示例9: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
function buildQuickForm()
{
if (!$this->_single) {
$toArray = array();
foreach ($this->_contactIds as $contactId) {
list($toDisplayName, $toSMS) = CRM_Contact_BAO_Contact::getPhoneDetails($contactId, 'Mobile');
if (!empty($toSMS)) {
$toArray[] = "\"{$toDisplayName}\" <{$toSMS}>";
}
}
$this->assign('to', implode(', ', $toArray));
} else {
$to =& $this->add('select', 'to', ts('To'), $this->_smsNumbers, true);
if (count($this->_smsNumbers) <= 1) {
foreach ($this->_smsNumbers as $number => $dontCare) {
$defaults = array('to' => $number);
$this->setDefaults($defaults);
}
$to->freeze();
}
}
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($fromDisplayName, $fromSMS) = CRM_Contact_BAO_Contact::getPhoneDetails($userID, 'Mobile');
if (!$fromSMS) {
CRM_Utils_System::statusBounce(ts('Your user record does not have a valid SMS number'));
}
$from = '"' . $fromDisplayName . '"' . "<{$fromSMS}>";
$this->assign('from', $from);
$this->add('textarea', 'message', ts('Message'), CRM_Core_DAO::getAttribute('CRM_SMS_DAO_History', 'message'), true);
if ($this->_single) {
// also fix the user context stack
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/activity', '&show=1&action=browse&cid=' . $this->_contactIds[0]));
$this->addDefaultButtons(ts('Send SMS'), 'next', 'cancel');
} else {
$this->addDefaultButtons(ts('Send SMS'));
}
}
示例10: 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()
{
$this->_id = CRM_Utils_Request::retrieve('id', $this);
$this->assign('id', $this->_id);
$this->_contactId = CRM_Utils_Request::retrieve('cid', $this, true);
if (!$this->_contactId) {
CRM_Utils_System::statusBounce(ts('We could not find a contact id.'));
}
$this->assign('contactId', $this->_contactId);
$this->_action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
$this->assign('action', $this->_action);
// check for permissions
$this->_permission = null;
if (CRM_Contact_BAO_Contact::permissionedContact($this->_contactId, CRM_CORE_PERMISSION_EDIT)) {
$this->assign('permission', 'edit');
$this->_permission = CRM_CORE_PERMISSION_EDIT;
} else {
if (CRM_Contact_BAO_Contact::permissionedContact($this->_contactId, CRM_CORE_PERMISSION_VIEW)) {
$this->assign('permission', 'view');
$this->_permission = CRM_CORE_PERMISSION_VIEW;
} else {
CRM_Utils_System::statusBounce(ts('You do not have the necessary permission to view this contact.'));
}
}
$this->getContactDetails();
$contactImage = $this->get('contactImage');
$displayName = $this->get('displayName');
$this->assign('displayName', $displayName);
CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId), $contactImage, $this->_contactId);
// also add the cid params to the Menu array
CRM_Utils_Menu::addParam('cid', $this->_contactId);
$this->assign('viewForm', $form);
$this->assign('showBlocks1', $showBlocks);
$this->assign('hideBlocks1', $hideBlocks);
$this->assign('groupTree', $_groupTree);
//------------
// create menus ..
$startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
$startWeight++;
CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($this->_contactId), 'civicrm/contact/view/cd', $startWeight);
//display OtherActivity link
$otherAct = CRM_Core_PseudoConstant::activityType(false);
$activityNum = count($otherAct);
$this->assign('showOtherActivityLink', $activityNum);
}
示例11: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
function buildQuickForm()
{
if (!$this->_single) {
$toArray = array();
$validMails = array();
$suppressedEmails = 0;
foreach ($this->_contactIds as $contactId) {
list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactId);
if (!trim($toDisplayName)) {
$toDisplayName = $toEmail;
}
// not sure why we have separate $validMails and $toArray and
// why we assign $toArray and not $validMails below... [Shot]
if (!empty($toEmail) and !$doNotEmail) {
$validMails[] = "\"{$toDisplayName}\" <{$toEmail}>";
}
if ($doNotEmail) {
$suppressedEmails++;
} else {
$toArray[] = "\"{$toDisplayName}\" <{$toEmail}>";
}
}
if (empty($validMails)) {
CRM_Utils_System::statusBounce(ts('Selected contact(s) does not have a valid email address'));
}
$this->assign('to', implode(', ', $toArray));
$this->assign('suppressedEmails', $suppressedEmails);
} else {
if ($this->_noEmails) {
$to = $this->add('select', 'to', ts('To'), $this->_emails);
$this->add('text', 'emailAddress', null, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'));
$this->addRule('emailAddress', ts('%1 is a required field.', array(1 => 'To')), 'required');
$this->addRule("emailAddress", ts('Email is not valid.'), 'email');
} else {
$to =& $this->add('select', 'to', ts('To'), $this->_emails, true);
}
if (count($this->_emails) <= 1) {
foreach ($this->_emails as $email => $dontCare) {
$defaults = array('to' => $email);
$this->setDefaults($defaults);
}
$to->freeze();
}
}
$this->assign('noEmails', $this->_noEmails);
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($fromDisplayName, $fromEmail, $fromDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
if (!$fromEmail) {
CRM_Utils_System::statusBounce(ts('Your user record does not have a valid email address'));
}
if (!trim($fromDisplayName)) {
$fromDisplayName = $fromEmail;
}
$from = '"' . $fromDisplayName . '"' . "<{$fromEmail}>";
$this->assign('from', $from);
$this->add('text', 'subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_EmailHistory', 'subject'), true);
$this->add('textarea', 'message', ts('Message'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_EmailHistory', 'message'), true);
if ($this->_single) {
// also fix the user context stack
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/activity', '&show=1&action=browse&cid=' . $this->_contactIds[0]));
$this->addDefaultButtons(ts('Send Email'), 'next', 'cancel');
} else {
$this->addDefaultButtons(ts('Send Email'));
}
}
示例12: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
$this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe');
$this->_duplicateButtonName = $this->getButtonName('next', 'duplicate');
if ($this->_action == CRM_CORE_ACTION_ADD) {
$this->_contactType = CRM_Utils_Request::retrieve('c_type', $this, true, null, 'REQUEST');
$this->_gid = CRM_Utils_Request::retrieve('gid', $this, false, null, 'GET');
$this->_tid = CRM_Utils_Request::retrieve('tid', $this, false, null, 'GET');
$this->_contactId = null;
} else {
// this is update mode, first get the id from the session
// else get it from the REQUEST
$ids = $this->get('ids');
$this->_contactId = CRM_Utils_Array::value('contact', $ids);
if (!$this->_contactId) {
$this->_contactId = CRM_Utils_Array::value('cid', $_REQUEST);
}
if ($this->_contactId) {
$contact =& new CRM_Contact_DAO_Contact();
$contact->id = $this->_contactId;
if (!$contact->find(true)) {
CRM_Utils_System::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
}
$this->_contactType = $contact->contact_type;
// check for permissions
if (!CRM_Contact_BAO_Contact::permissionedContact($this->_contactId, CRM_CORE_PERMISSION_EDIT)) {
CRM_Utils_System::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
}
return;
}
CRM_Utils_System::statusBounce(ts('Could not get a contact_id and/or contact_type'));
}
}
示例13: upload
/**
* upload and move the file if valid to the uploaded directory
*
* @param object $page the CRM_Core_Form object
* @param object $data the QFC data container
* @param string $pageName the name of the page which index the data container with
* @param string $uploadName the name of the uploaded file
*
* @return void
* @access private
*/
function upload(&$page, &$data, $pageName, $uploadName)
{
if (empty($uploadName)) {
return;
}
// get the element containing the upload
$element =& $page->getElement($uploadName);
if ('file' == $element->getType()) {
if ($element->isUploadedFile()) {
// rename the uploaded file with a unique number at the end
$value = $element->getValue();
$newName = uniqid("{$value['name']}.");
$status = $element->moveUploadedFile($this->_uploadDir, $newName);
if (!$status) {
CRM_Utils_System::statusBounce(ts('We could not move the uploaded file %1 to the upload directory %2. Please verify that the CIVICRM_IMAGE_UPLOADDIR setting points to a valid path which is writable by your web server.', array(1 => $value['name'], 2 => $this->_uploadDir)));
}
if (!empty($data['values'][$pageName][$uploadName])) {
@unlink($this->_uploadDir . $data['values'][$pageName][$uploadName]);
}
$data['values'][$pageName][$uploadName] = $this->_uploadDir . $newName;
}
}
}