本文整理汇总了PHP中CRM_Mailing_Info类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Mailing_Info类的具体用法?PHP CRM_Mailing_Info怎么用?PHP CRM_Mailing_Info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Mailing_Info类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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.
*/
public function preProcess()
{
$this->_unscheduled = $this->_archived = $archiveLinks = FALSE;
$this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
$this->_sms = CRM_Utils_Request::retrieve('sms', 'Positive', $this);
$this->assign('sms', $this->_sms);
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
$this->assign('action', $this->_action);
$showLinks = TRUE;
if (CRM_Mailing_Info::workflowEnabled()) {
if (CRM_Core_Permission::check('create mailings')) {
$archiveLinks = TRUE;
}
if (!CRM_Core_Permission::check('access CiviMail') && !CRM_Core_Permission::check('create mailings')) {
$showLinks = FALSE;
}
}
$this->assign('showLinks', $showLinks);
if (CRM_Core_Permission::check('access CiviMail')) {
$archiveLinks = TRUE;
}
if ($archiveLinks == TRUE) {
$this->assign('archiveLinks', $archiveLinks);
}
}
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:31,代码来源:Browse.php
示例2: getAngularModules
/**
* 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;
}
开发者ID:vincent1892,项目名称:contact_report,代码行数:34,代码来源:Info.php
示例3: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
if (CRM_Mailing_Info::workflowEnabled()) {
if (!CRM_Core_Permission::check('approve mailings') && !CRM_Core_Permission::check('access CiviMail')) {
$this->redirectToListing();
}
} else {
$this->redirectToListing();
}
// when user come from search context.
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
//retrieve mid from different wizard and url contexts
$this->_mailingID = $this->get('mailing_id');
$this->_approveFormOnly = FALSE;
if (!$this->_mailingID) {
$this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, TRUE);
$this->_approveFormOnly = TRUE;
}
$session = CRM_Core_Session::singleton();
$this->_contactID = $session->get('userID');
$this->_mailing = new CRM_Mailing_BAO_Mailing();
$this->_mailing->id = $this->_mailingID;
if (!$this->_mailing->find(TRUE)) {
$this->redirectToListing();
}
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:29,代码来源:Approve.php
示例4: __construct
/**
* class constructor
*
* @param object CRM_Mailing_Controller
* @param int $action
*
* @return object CRM_Mailing_StateMachine
*/
function __construct($controller, $action = CRM_Core_Action::NONE)
{
parent::__construct($controller, $action);
$this->_pages = array('CRM_Mailing_Form_Group' => null, 'CRM_Mailing_Form_Settings' => null, 'CRM_Mailing_Form_Upload' => null, 'CRM_Mailing_Form_Test' => null);
require_once 'CRM/Mailing/Info.php';
if (CRM_Mailing_Info::workflowEnabled()) {
if (CRM_Core_Permission::check('schedule mailings')) {
$this->_pages['CRM_Mailing_Form_Schedule'] = null;
}
} else {
$this->_pages['CRM_Mailing_Form_Schedule'] = null;
}
$this->addSequentialPages($this->_pages, $action);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:22,代码来源:Send.php
示例5: __construct
/**
* class constructor
*
* @param object CRM_Mailing_Controller
* @param int $action
*
* @return object CRM_Mailing_StateMachine
*/
function __construct($controller, $action = CRM_Core_Action::NONE)
{
parent::__construct($controller, $action);
$this->_pages = array('CRM_Mailing_Form_Group' => NULL, 'CRM_Mailing_Form_Settings' => NULL, 'CRM_Mailing_Form_Upload' => NULL, 'CRM_Mailing_Form_Test' => NULL);
if (CRM_Mailing_Info::workflowEnabled()) {
if (CRM_Core_Permission::check('schedule mailings')) {
$this->_pages['CRM_Mailing_Form_Schedule'] = NULL;
}
if (CRM_Core_Permission::check('approve mailings')) {
$this->_pages['CRM_Mailing_Form_Approve'] = NULL;
}
} else {
$this->_pages['CRM_Mailing_Form_Schedule'] = NULL;
}
$this->addSequentialPages($this->_pages, $action);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:24,代码来源:Send.php
示例6: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Mailing/Info.php';
if (CRM_Mailing_Info::workflowEnabled()) {
if (!CRM_Core_Permission::check('approve mailings')) {
$this->redirectToListing();
}
} else {
$this->redirectToListing();
}
$this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, true);
$session =& CRM_Core_Session::singleton();
$this->_contactID = $session->get('userID');
require_once 'CRM/Mailing/BAO/Mailing.php';
$this->_mailing = new CRM_Mailing_BAO_Mailing();
$this->_mailing->id = $this->_mailingID;
if (!$this->_mailing->find(true)) {
$this->redirectToListing();
}
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:26,代码来源:Approve.php
示例7: initTasks
public static function initTasks()
{
if (!self::$_tasks) {
self::$_tasks = array(self::GROUP_CONTACTS => array('title' => ts('Group - add contacts'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), self::REMOVE_CONTACTS => array('title' => ts('Group - remove contacts'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), self::TAG_CONTACTS => array('title' => ts('Tag - add to contacts'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), self::REMOVE_TAGS => array('title' => ts('Tag - remove from contacts'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), self::EXPORT_CONTACTS => array('title' => ts('Export contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), self::EMAIL_CONTACTS => array('title' => ts('Email - send now (to 50 or less)'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), self::DELETE_CONTACTS => array('title' => ts('Delete contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::RECORD_CONTACTS => array('title' => ts('Add activity'), 'class' => 'CRM_Activity_Form_Activity'), self::SAVE_SEARCH => array('title' => ts('Smart group - create'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), self::SAVE_SEARCH_UPDATE => array('title' => ts('Smart group - update'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), self::PRINT_CONTACTS => array('title' => ts('Print selected rows'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), self::LABEL_CONTACTS => array('title' => ts('Mailing labels - print'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), self::BATCH_UPDATE => array('title' => ts('Batch update contacts via profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), self::PRINT_FOR_CONTACTS => array('title' => ts('PDF letters - print'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), self::EMAIL_UNHOLD => array('title' => ts('Email - unhold addresses'), 'class' => 'CRM_Contact_Form_Task_Unhold'), self::COMMUNICATION_PREFS => array('title' => ts('Communication preferences - alter'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore contacts from trash'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE));
//CRM-16329, if SMS provider is configured show sms action.
$providersCount = CRM_SMS_BAO_Provider::activeProviderCount();
if ($providersCount) {
self::$_tasks[self::SMS_CONTACTS] = array('title' => ts('SMS - schedule/send'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE);
}
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$label = CRM_Contact_BAO_ContactType::getLabel('household');
self::$_tasks[self::HOUSEHOLD_CONTACTS] = array('title' => ts('Add relationship - to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold');
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$label = CRM_Contact_BAO_ContactType::getLabel('organization');
self::$_tasks[self::ORGANIZATION_CONTACTS] = array('title' => ts('Add relationship - to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization');
}
if (CRM_Core_Permission::check('merge duplicate contacts')) {
self::$_tasks[self::MERGE_CONTACTS] = array('title' => ts('Merge contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE);
}
//CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
unset(self::$_tasks[self::DELETE_CONTACTS]);
}
//show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
// should fix this to be more flexible as providers are added ??
$config = CRM_Core_Config::singleton();
if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) {
self::$_tasks[self::MAP_CONTACTS] = array('title' => ts('Map contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE);
}
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[self::ADD_EVENT] = array('title' => ts('Register participants for event'), 'class' => 'CRM_Event_Form_Participant');
}
if (CRM_Core_Permission::access('CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Email - schedule/send via CiviMail'), 'class' => 'CRM_Mailing_Form_Task_AdhocMailing', 'result' => FALSE);
}
self::$_tasks += CRM_Core_Component::taskList();
CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
asort(self::$_tasks);
}
}
开发者ID:nganivet,项目名称:civicrm-core,代码行数:41,代码来源:Task.php
示例8: civicrm_api3_mailing_create
/**
* Handle a create event.
*
* @param array $params
*
* @return array
* API Success Array
* @throws \API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
function civicrm_api3_mailing_create($params)
{
if (CRM_Mailing_Info::workflowEnabled()) {
// Note: 'schedule mailings' and 'approve mailings' can update certain fields, but can't create.
if (empty($params['id'])) {
if (!CRM_Core_Permission::check('access CiviMail') && !CRM_Core_Permission::check('create mailings')) {
throw new \Civi\API\Exception\UnauthorizedException("Cannot create new mailing. Required permission: 'access CiviMail' or 'create mailings'");
}
}
$safeParams = array();
$fieldPerms = CRM_Mailing_BAO_Mailing::getWorkflowFieldPerms();
foreach (array_keys($params) as $field) {
if (CRM_Core_Permission::check($fieldPerms[$field])) {
$safeParams[$field] = $params[$field];
}
}
} else {
$safeParams = $params;
}
$safeParams['_evil_bao_validator_'] = 'CRM_Mailing_BAO_Mailing::checkSendable';
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $safeParams);
}
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:32,代码来源:Mailing.php
示例9: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
//create radio buttons to select existing group or add a new group
$options = array(ts('Add Contact To Existing Group'), ts('Create New Group'));
if (!$this->_id) {
$this->addRadio('group_option', ts('Group Options'), $options, array('onclick' => "return showElements();"));
$this->add('text', 'title', ts('Group Name:') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'));
$this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $this->_id, 'title'));
$this->add('textarea', 'description', ts('Description:') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
$groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
if (!CRM_Core_Permission::access('CiviMail')) {
$isWorkFlowEnabled = CRM_Mailing_Info::workflowEnabled();
if ($isWorkFlowEnabled && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
unset($groupTypes['Mailing List']);
}
}
if (!empty($groupTypes)) {
$this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, ' ');
}
}
// add select for groups
$group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup();
$groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, FALSE, array('class' => 'crm-select2 huge'));
$this->_title = $group[$this->_id];
if ($this->_context === 'amtg') {
$groupElement->freeze();
// also set the group title
$groupValues = array('id' => $this->_id, 'title' => $this->_title);
$this->assign_by_ref('group', $groupValues);
}
// Set dynamic page title for 'Add Members Group (confirm)'
if ($this->_id) {
CRM_Utils_System::setTitle(ts('Add Contacts: %1', array(1 => $this->_title)));
} else {
CRM_Utils_System::setTitle(ts('Add Contacts to A Group'));
}
$this->addDefaultButtons(ts('Add to Group'));
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:41,代码来源:AddToGroup.php
示例10: runJobs_pre
public static function runJobs_pre($offset = 200)
{
$job = new CRM_Mailing_BAO_Job();
$config = CRM_Core_Config::singleton();
$jobTable = CRM_Mailing_DAO_Job::getTableName();
$mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
$currentTime = date('YmdHis');
$mailingACL = CRM_Mailing_BAO_Mailing::mailingACL('m');
// add an additional check and only process
// jobs that are approved
$workflowClause = null;
require_once 'CRM/Mailing/Info.php';
if (CRM_Mailing_Info::workflowEnabled()) {
require_once 'CRM/Core/OptionGroup.php';
$approveOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status', 'Approved', 'name');
if ($approveOptionID) {
$workflowClause = " AND m.approval_status_id = {$approveOptionID} ";
}
}
// Select all the mailing jobs that are created from
// when the mailing is submitted or scheduled.
$query = "\n\t\tSELECT j.*\n\t\t FROM {$jobTable} j,\n\t\t\t\t {$mailingTable} m\n\t\t WHERE m.id = j.mailing_id\n {$workflowClause}\n\t\t AND j.is_test = 0\n\t\t AND ( ( j.start_date IS null\n\t\t AND j.scheduled_date <= {$currentTime}\n\t\t AND j.status = 'Scheduled'\n\t\t AND j.end_date IS null ) )\n\t\t AND ((j.job_type is NULL) OR (j.job_type <> 'child'))\n\t\tORDER BY j.scheduled_date,\n\t\t\t\t j.start_date";
$job->query($query);
require_once 'CRM/Core/Lock.php';
// For reach of the "Parent Jobs" we find, we split them into
// X Number of child jobs
while ($job->fetch()) {
// still use job level lock for each child job
$lockName = "civimail.job.{$job->id}";
$lock = new CRM_Core_Lock($lockName);
if (!$lock->isAcquired()) {
continue;
}
// refetch the job status in case things
// changed between the first query and now
// avoid race conditions
$job->status = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Job', $job->id, 'status');
if ($job->status != 'Scheduled') {
$lock->release();
continue;
}
$job->split_job($offset);
// update the status of the parent job
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$saveJob = new CRM_Mailing_DAO_Job();
$saveJob->id = $job->id;
$saveJob->start_date = date('YmdHis');
$saveJob->status = 'Running';
$saveJob->save();
$transaction->commit();
// Release the job lock
$lock->release();
}
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:55,代码来源:Job.php
示例11: upgrade_3_3_2
function upgrade_3_3_2($rev)
{
$dropMailingIndex = FALSE;
$indexes = CRM_Core_DAO::executeQuery('SHOW INDEXES FROM civicrm_mailing_job');
while ($indexes->fetch()) {
if ($indexes->Key_name == 'parent_id') {
$dropMailingIndex = TRUE;
break;
}
}
//CRM-7137
// get membership type for each membership block.
$sql = "SELECT id, membership_types FROM civicrm_membership_block ";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$memType = explode(',', $dao->membership_types);
$memTypeSerialize = array();
foreach ($memType as $k => $v) {
$memTypeSerialize[$v] = 0;
}
// save membership type as an serialized array along w/ auto_renew defalt value zero.
$memBlock = new CRM_Member_DAO_MembershipBlock();
$memBlock->id = $dao->id;
$memBlock->membership_types = serialize($memTypeSerialize);
$memBlock->save();
}
//CRM-7172
if (CRM_Mailing_Info::workflowEnabled()) {
$config = CRM_Core_Config::singleton();
if (is_callable(array($config->userSystem, 'replacePermission'))) {
$config->userSystem->replacePermission('access CiviMail', array('access CiviMail', 'create mailings', 'approve mailings', 'schedule mailings'));
}
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('dropMailingIndex', $dropMailingIndex);
$upgrade->processSQL($rev);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:37,代码来源:ThreeThree.php
示例12: isExtensionSafe
/**
* @param $ext
*
* @return bool
*/
public static function isExtensionSafe($ext)
{
static $extensions = NULL;
if (!$extensions) {
$extensions = CRM_Core_OptionGroup::values('safe_file_extension', TRUE);
// make extensions to lowercase
$extensions = array_change_key_case($extensions, CASE_LOWER);
// allow html/htm extension ONLY if the user is admin
// and/or has access CiviMail
if (!(CRM_Core_Permission::check('access CiviMail') || CRM_Core_Permission::check('administer CiviCRM') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings'))) {
unset($extensions['html']);
unset($extensions['htm']);
}
}
// support lower and uppercase file extensions
return isset($extensions[strtolower($ext)]) ? TRUE : FALSE;
}
开发者ID:routinet,项目名称:civicrm-core,代码行数:22,代码来源:File.php
示例13: isExtensionSafe
static function isExtensionSafe($ext)
{
static $extensions = null;
if (!$extensions) {
require_once 'CRM/Core/OptionGroup.php';
$extensions = CRM_Core_OptionGroup::values('safe_file_extension', true);
//make extensions to lowercase
$extensions = array_change_key_case($extensions, CASE_LOWER);
// allow html/htm extension ONLY if the user is admin
// and/or has access CiviMail
require_once 'CRM/Mailing/Info.php';
require_once 'CRM/Core/Permission.php';
if (!(CRM_Core_Permission::check('access CiviMail') || CRM_Core_Permission::check('administer CiviCRM') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings'))) {
unset($extensions['html']);
unset($extensions['htm']);
}
}
//support lower and uppercase file extensions
return isset($extensions[strtolower($ext)]) ? true : false;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:20,代码来源:File.php
示例14: md5
/**
* Get the list Activities.
*
* @param array $input
* Array of parameters.
* Keys include
* - contact_id int contact_id whose activities we want to retrieve
* - offset int which row to start from ?
* - rowCount int how many rows to fetch
* - sort object|array object or array describing sort order for sql query.
* - admin boolean if contact is admin
* - caseId int case ID
* - context string page on which selector is build
* - activity_type_id int|string the activitiy types we want to restrict by
*
* @return array
* Relevant data object values of open activities
*/
public static function &getActivities($input)
{
// Step 1: Get the basic activity data.
$bulkActivityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$config = CRM_Core_Config::singleton();
$randomNum = md5(uniqid());
$activityTempTable = "civicrm_temp_activity_details_{$randomNum}";
$tableFields = array('activity_id' => 'int unsigned', 'activity_date_time' => 'datetime', 'source_record_id' => 'int unsigned', 'status_id' => 'int unsigned', 'subject' => 'varchar(255)', 'source_contact_name' => 'varchar(255)', 'activity_type_id' => 'int unsigned', 'activity_type' => 'varchar(128)', 'case_id' => 'int unsigned', 'case_subject' => 'varchar(255)', 'campaign_id' => 'int unsigned');
$sql = "CREATE TEMPORARY TABLE {$activityTempTable} ( ";
$insertValueSQL = array();
// The activityTempTable contains the sorted rows
// so in order to maintain the sort order as-is we add an auto_increment
// field; we can sort by this later to ensure the sort order stays correct.
$sql .= " fixed_sort_order INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,";
foreach ($tableFields as $name => $desc) {
$sql .= "{$name} {$desc},\n";
$insertValueSQL[] = $name;
}
// add unique key on activity_id just to be sure
// this cannot be primary key because we need that for the auto_increment
// fixed_sort_order field
$sql .= "\n UNIQUE KEY ( activity_id )\n ) ENGINE=HEAP DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci\n ";
CRM_Core_DAO::executeQuery($sql);
$insertSQL = "INSERT INTO {$activityTempTable} (" . implode(',', $insertValueSQL) . " ) ";
$order = $limit = $groupBy = '';
$groupBy = " GROUP BY tbl.activity_id ";
if (!empty($input['sort'])) {
if (is_a($input['sort'], 'CRM_Utils_Sort')) {
$orderBy = $input['sort']->orderBy();
if (!empty($orderBy)) {
$order = " ORDER BY {$orderBy}";
}
} elseif (trim($input['sort'])) {
$sort = CRM_Utils_Type::escape($input['sort'], 'String');
$order = " ORDER BY {$sort} ";
}
}
if (empty($order)) {
// context = 'activity' in Activities tab.
$order = CRM_Utils_Array::value('context', $input) == 'activity' ? " ORDER BY tbl.activity_date_time desc " : " ORDER BY tbl.status_id asc, tbl.activity_date_time asc ";
}
if (!empty($input['rowCount']) && $input['rowCount'] > 0) {
$limit = " LIMIT {$input['offset']}, {$input['rowCount']} ";
}
$input['count'] = FALSE;
list($sqlClause, $params) = self::getActivitySQLClause($input);
$query = "{$insertSQL}\n SELECT DISTINCT tbl.* from ( {$sqlClause} )\nas tbl ";
// Filter case activities - CRM-5761.
$components = self::activityComponents();
if (!in_array('CiviCase', $components)) {
$query .= "\nLEFT JOIN civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.activity_id )\n WHERE civicrm_case_activity.id IS NULL";
}
$query = $query . $groupBy . $order . $limit;
$dao = CRM_Core_DAO::executeQuery($query, $params);
// step 2: Get target and assignee contacts for above activities
// create temp table for target contacts
$activityContactTempTable = "civicrm_temp_activity_contact_{$randomNum}";
$query = "CREATE TEMPORARY TABLE {$activityContactTempTable} (\n activity_id int unsigned, contact_id int unsigned, record_type_id varchar(16),\n contact_name varchar(255), is_deleted int unsigned, counter int unsigned, INDEX index_activity_id( activity_id ) )\n ENGINE=MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
CRM_Core_DAO::executeQuery($query);
// note that we ignore bulk email for targets, since we don't show it in selector
$query = "\nINSERT INTO {$activityContactTempTable} ( activity_id, contact_id, record_type_id, contact_name, is_deleted )\nSELECT ac.activity_id,\n ac.contact_id,\n ac.record_type_id,\n c.sort_name,\n c.is_deleted\nFROM {$activityTempTable}\nINNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id )\nINNER JOIN civicrm_activity_contact ac ON ( ac.activity_id = {$activityTempTable}.activity_id )\nINNER JOIN civicrm_contact c ON c.id = ac.contact_id\nWHERE ac.record_type_id != %1\n";
$params = array(1 => array($targetID, 'Integer'));
CRM_Core_DAO::executeQuery($query, $params);
// for each activity insert one target contact
// if we load all target contacts the performance will suffer a lot for mass-activities.
$query = "\nINSERT INTO {$activityContactTempTable} ( activity_id, contact_id, record_type_id, contact_name, is_deleted, counter )\nSELECT ac.activity_id,\n ac.contact_id,\n ac.record_type_id,\n c.sort_name,\n c.is_deleted,\n count(ac.contact_id)\nFROM {$activityTempTable}\nINNER JOIN civicrm_activity a ON ( a.id = {$activityTempTable}.activity_id )\nINNER JOIN civicrm_activity_contact ac ON ( ac.activity_id = {$activityTempTable}.activity_id )\nINNER JOIN civicrm_contact c ON c.id = ac.contact_id\nWHERE ac.record_type_id = %1\nGROUP BY ac.activity_id\n";
CRM_Core_DAO::executeQuery($query, $params);
// step 3: Combine all temp tables to get final query for activity selector
// sort by the original sort order, stored in fixed_sort_order
$query = "\nSELECT {$activityTempTable}.*,\n {$activityContactTempTable}.contact_id,\n {$activityContactTempTable}.record_type_id,\n {$activityContactTempTable}.contact_name,\n {$activityContactTempTable}.is_deleted,\n {$activityContactTempTable}.counter,\n re.parent_id as is_recurring_activity\nFROM {$activityTempTable}\nINNER JOIN {$activityContactTempTable} on {$activityTempTable}.activity_id = {$activityContactTempTable}.activity_id\nLEFT JOIN civicrm_recurring_entity re on {$activityContactTempTable}.activity_id = re.entity_id\nORDER BY fixed_sort_order\n ";
$dao = CRM_Core_DAO::executeQuery($query);
// CRM-3553, need to check user has access to target groups.
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
$accessCiviMail = CRM_Core_Permission::check('access CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings');
// Get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$values = array();
while ($dao->fetch()) {
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php
示例15: md5
/**
* function to get the list Actvities
*
* @param array $input array of parameters
* Keys include
* - contact_id int contact_id whose activties we want to retrieve
* - offset int which row to start from ?
* - rowCount int how many rows to fetch
* - sort object|array object or array describing sort order for sql query.
* - admin boolean if contact is admin
* - caseId int case ID
* - context string page on which selector is build
* - activity_type_id int|string the activitiy types we want to restrict by
*
* @return array (reference) $values the relevant data object values of open activitie
*
* @access public
* @static
*/
static function &getActivities($input)
{
//step 1: Get the basic activity data
$bulkActivityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
$config = CRM_Core_Config::singleton();
$randomNum = md5(uniqid());
$activityTempTable = "civicrm_temp_activity_details_{$randomNum}";
$tableFields = array('activity_id' => 'int unsigned', 'activity_date_time' => 'datetime', 'status_id' => 'int unsigned', 'subject' => 'varchar(255)', 'source_contact_id' => 'int unsigned', 'source_record_id' => 'int unsigned', 'source_contact_name' => 'varchar(255)', 'activity_type_id' => 'int unsigned', 'activity_type' => 'varchar(128)', 'case_id' => 'int unsigned', 'case_subject' => 'varchar(255)', 'campaign_id' => 'int unsigned');
$sql = "CREATE TEMPORARY TABLE {$activityTempTable} ( ";
$insertValueSQL = array();
foreach ($tableFields as $name => $desc) {
$sql .= "{$name} {$desc},\n";
$insertValueSQL[] = $name;
}
$sql .= "\n PRIMARY KEY ( activity_id )\n ) ENGINE=HEAP DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci\n ";
CRM_Core_DAO::executeQuery($sql);
$insertSQL = "INSERT INTO {$activityTempTable} (" . implode(',', $insertValueSQL) . " ) ";
$order = $limit = $groupBy = '';
//$groupBy = " GROUP BY tbl.activity_id";
if (!empty($input['sort'])) {
if (is_a($input['sort'], 'CRM_Utils_Sort')) {
$orderBy = $input['sort']->orderBy();
if (!empty($orderBy)) {
$order = " ORDER BY {$orderBy}";
}
} elseif (trim($input['sort'])) {
$order = " ORDER BY {$input['sort']}";
}
}
if (empty($order)) {
$order = CRM_Utils_Array::value('context', $input) == 'activity' ? " ORDER BY tbl.activity_date_time desc " : " ORDER BY tbl.status_id asc, tbl.activity_date_time asc ";
}
if (!empty($input['rowCount']) && $input['rowCount'] > 0) {
$limit = " LIMIT {$input['offset']}, {$input['rowCount']} ";
}
$input['count'] = FALSE;
list($sqlClause, $params) = self::getActivitySQLClause($input);
$query = "{$insertSQL}\n SELECT DISTINCT tbl.* from ( {$sqlClause} )\nas tbl ";
//filter case activities - CRM-5761
$components = self::activityComponents();
if (!in_array('CiviCase', $components)) {
$query .= "\nLEFT JOIN civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.activity_id )\n WHERE civicrm_case_activity.id IS NULL";
}
$query = $query . $groupBy . $order . $limit;
$dao = CRM_Core_DAO::executeQuery($query, $params);
$notbulkActivityClause = '';
if ($bulkActivityTypeID) {
$notbulkActivityClause = " AND {$activityTempTable}.activity_type_id <> {$bulkActivityTypeID} ";
}
// step 2: Get target and assignee contacts for above activities
// create temp table for target contacts
$activityTargetContactTempTable = "civicrm_temp_target_contact_{$randomNum}";
$query = "CREATE TEMPORARY TABLE {$activityTargetContactTempTable} (\n activity_id int unsigned, target_contact_id int unsigned, target_contact_name varchar(255) )\n ENGINE=MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
CRM_Core_DAO::executeQuery($query);
// note that we ignore bulk email for targets, since we don't show it in selector
$query = "INSERT INTO {$activityTargetContactTempTable} ( activity_id, target_contact_id, target_contact_name )\n SELECT at.activity_id,\n at.target_contact_id ,\n c.sort_name\n FROM civicrm_activity_target at\n INNER JOIN {$activityTempTable} ON ( at.activity_id = {$activityTempTable}.activity_id\n {$notbulkActivityClause} )\n INNER JOIN civicrm_contact c ON c.id = at.target_contact_id\n WHERE c.is_deleted = 0";
CRM_Core_DAO::executeQuery($query);
// create temp table for assignee contacts
$activityAssigneetContactTempTable = "civicrm_temp_assignee_contact_{$randomNum}";
$query = "CREATE TEMPORARY TABLE {$activityAssigneetContactTempTable} (\n activity_id int unsigned, assignee_contact_id int unsigned, assignee_contact_name varchar(255) )\n ENGINE=MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
CRM_Core_DAO::executeQuery($query);
// note that we ignore bulk email for assignee, since we don't show it in selector
$query = "INSERT INTO {$activityAssigneetContactTempTable} ( activity_id, assignee_contact_id, assignee_contact_name )\n SELECT DISTINCT ( aa.activity_id ) ,\n aa.assignee_contact_id,\n c.sort_name\n FROM civicrm_activity_assignment aa\n INNER JOIN {$activityTempTable} ON ( aa.activity_id = {$activityTempTable}.activity_id\n {$notbulkActivityClause} )\n INNER JOIN civicrm_contact c ON c.id = aa.assignee_contact_id\n WHERE c.is_deleted = 0";
CRM_Core_DAO::executeQuery($query);
// step 3: Combine all temp tables to get final query for activity selector
$query = "\n SELECT {$activityTempTable}.*,\n {$activityTargetContactTempTable}.target_contact_id,{$activityTargetContactTempTable}.target_contact_name,\n {$activityAssigneetContactTempTable}.assignee_contact_id, {$activityAssigneetContactTempTable}.assignee_contact_name\n FROM {$activityTempTable}\n LEFT JOIN {$activityTargetContactTempTable} on {$activityTempTable}.activity_id = {$activityTargetContactTempTable}.activity_id\n LEFT JOIN {$activityAssigneetContactTempTable} on {$activityTempTable}.activity_id = {$activityAssigneetContactTempTable}.activity_id\n ";
$dao = CRM_Core_DAO::executeQuery($query);
//CRM-3553, need to check user has access to target groups.
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
$accessCiviMail = CRM_Core_Permission::check('access CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings');
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$values = array();
while ($dao->fetch()) {
$activityID = $dao->activity_id;
$values[$activityID]['activity_id'] = $dao->activity_id;
$values[$activityID]['source_record_id'] = $dao->source_record_id;
$values[$activityID]['activity_type_id'] = $dao->activity_type_id;
$values[$activityID]['activity_type'] = $dao->activity_type;
$values[$activityID]['activity_date_time'] = $dao->activity_date_time;
$values[$activityID]['status_id'] = $dao->status_id;
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Activity.php
示例16: postProcess
/**
* Process the posted form values. Create and schedule a mailing.
*
* @param
*
* @return void
* @access public
*/
public function postProcess()
{
$params = array();
$params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
if (empty($params['mailing_id'])) {
CRM_Core_Error::fatal(ts('Could not find a mailing id'));
}
foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
$params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
}
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $ids['mailing_id'];
if ($mailing->find(TRUE)) {
$job = new CRM_Mailing_BAO_Job();
$job->mailing_id = $mailing->id;
$job->is_test = 0;
if ($job->find(TRUE)) {
CRM_Core_Error::fatal(ts('A job for this mailing already exists'));
}
if (empty($mailing->is_template)) {
$job->status = 'Scheduled';
if ($params['now']) {
$job->scheduled_date = date('YmdHis');
} else {
$job->scheduled_date = CRM_Utils_Date::processDate($params['start_da
|
请发表评论