当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_DAO_Group类代码示例

本文整理汇总了PHP中CRM_Contact_DAO_Group的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_Group类的具体用法?PHP CRM_Contact_DAO_Group怎么用?PHP CRM_Contact_DAO_Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CRM_Contact_DAO_Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: browse

 /**
  * Browse all saved searches.
  *
  * @return mixed
  *   content of the parents run method
  */
 public function browse()
 {
     $rows = array();
     $savedSearch = new CRM_Contact_DAO_SavedSearch();
     $savedSearch->is_active = 1;
     $savedSearch->selectAdd();
     $savedSearch->selectAdd('id, form_values');
     $savedSearch->find();
     $properties = array('id', 'name', 'description');
     while ($savedSearch->fetch()) {
         // get name and description from group object
         $group = new CRM_Contact_DAO_Group();
         $group->saved_search_id = $savedSearch->id;
         if ($group->find(TRUE)) {
             $permissions = CRM_Group_Page_Group::checkPermission($group->id, $group->title);
             if (!CRM_Utils_System::isNull($permissions)) {
                 $row = array();
                 $row['name'] = $group->title;
                 $row['description'] = $group->description;
                 $row['id'] = $savedSearch->id;
                 $formValues = unserialize($savedSearch->form_values);
                 $query = new CRM_Contact_BAO_Query($formValues);
                 $row['query_detail'] = $query->qill();
                 $action = array_sum(array_keys(self::links()));
                 $action = $action & CRM_Core_Action::mask($permissions);
                 $row['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $row['id']), ts('more'), FALSE, 'savedSearch.manage.action', 'SavedSearch', $row['id']);
                 $rows[] = $row;
             }
         }
     }
     $this->assign('rows', $rows);
     return parent::run();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:39,代码来源:SavedSearch.php

示例2: confirm

 /**
  * Confirm a pending subscription
  *
  * @param int $contact_id       The id of the contact
  * @param int $subscribe_id     The id of the subscription event
  * @param string $hash          The hash
  *
  * @return boolean              True on success
  * @access public
  * @static
  */
 public static function confirm($contact_id, $subscribe_id, $hash)
 {
     $se =& CRM_Mailing_Event_BAO_Subscribe::verify($contact_id, $subscribe_id, $hash);
     if (!$se) {
         return FALSE;
     }
     // before we proceed lets just check if this contact is already 'Added'
     // if so, we should ignore this request and hence avoid sending multiple
     // emails - CRM-11157
     $details = CRM_Contact_BAO_GroupContact::getMembershipDetail($contact_id, $se->group_id);
     if ($details && $details->status == 'Added') {
         // This contact is already subscribed
         // lets return the group title
         return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $se->group_id, 'title');
     }
     $transaction = new CRM_Core_Transaction();
     $ce = new CRM_Mailing_Event_BAO_Confirm();
     $ce->event_subscribe_id = $se->id;
     $ce->time_stamp = date('YmdHis');
     $ce->save();
     CRM_Contact_BAO_GroupContact::addContactsToGroup(array($contact_id), $se->group_id, 'Email', 'Added', $ce->id);
     $transaction->commit();
     $config = CRM_Core_Config::singleton();
     $domain = CRM_Core_BAO_Domain::getDomain();
     list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();
     list($display_name, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($se->contact_id);
     $group = new CRM_Contact_DAO_Group();
     $group->id = $se->group_id;
     $group->find(TRUE);
     $component = new CRM_Mailing_BAO_Component();
     $component->is_default = 1;
     $component->is_active = 1;
     $component->component_type = 'Welcome';
     $component->find(TRUE);
     $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
     $html = $component->body_html;
     if ($component->body_text) {
         $text = $component->body_text;
     } else {
         $text = CRM_Utils_String::htmlToText($component->body_html);
     }
     $bao = new CRM_Mailing_BAO_Mailing();
     $bao->body_text = $text;
     $bao->body_html = $html;
     $tokens = $bao->getTokens();
     $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
     $html = CRM_Utils_Token::replaceWelcomeTokens($html, $group->title, TRUE);
     $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
     $text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->title, FALSE);
     $mailParams = array('groupName' => 'Mailing Event ' . $component->component_type, 'subject' => $component->subject, 'from' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'toEmail' => $email, 'toName' => $display_name, 'replyTo' => "do-not-reply@{$emailDomain}", 'returnPath' => "do-not-reply@{$emailDomain}", 'html' => $html, 'text' => $text);
     // send - ignore errors because the desired status change has already been successful
     $unused_result = CRM_Utils_Mail::send($mailParams);
     return $group->title;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:65,代码来源:Confirm.php

示例3: civicrm_api3_mailing_event_subscribe_create

/**
 * Subscribe from mailing group
 *
 * @param array $params Associative array of property
 *                       name/value pairs to insert in new 'survey'
 *
 * @throws API_Exception
 * @return array api result array
 * {@getfields mailing_event_subscribe_create}
 * @access public
 */
function civicrm_api3_mailing_event_subscribe_create($params)
{
    $email = $params['email'];
    $group_id = $params['group_id'];
    $contact_id = CRM_Utils_Array::value('contact_id', $params);
    $group = new CRM_Contact_DAO_Group();
    $group->is_active = 1;
    $group->id = (int) $group_id;
    if (!$group->find(TRUE)) {
        throw new API_Exception('Invalid Group id');
    }
    $subscribe = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id, $email, $contact_id);
    if ($subscribe !== NULL) {
        /* Ask the contact for confirmation */
        $subscribe->send_confirm_request($email);
        $values = array();
        $values[$subscribe->id]['contact_id'] = $subscribe->contact_id;
        $values[$subscribe->id]['subscribe_id'] = $subscribe->id;
        $values[$subscribe->id]['hash'] = $subscribe->hash;
        return civicrm_api3_create_success($values);
    }
    return civicrm_api3_create_error('Subscription failed');
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:34,代码来源:MailingEventSubscribe.php

示例4: getGroups

 /**
  * Returns array of group object(s) matching a set of one or Group properties.
  *
  * @param array $params
  *   Limits the set of groups returned.
  * @param array $returnProperties
  *   Which properties should be included in the returned group objects.
  *   (member_count should be last element.)
  * @param string $sort
  * @param int $offset
  * @param int $rowCount
  *
  * @return array
  *   Array of group objects.
  *
  *
  * @todo other BAO functions that use returnProperties (e.g. Query Objects) receive the array flipped & filled with 1s and
  * add in essential fields (e.g. id). This should follow a regular pattern like the others
  */
 public static function getGroups($params = NULL, $returnProperties = NULL, $sort = NULL, $offset = NULL, $rowCount = NULL)
 {
     $dao = new CRM_Contact_DAO_Group();
     if (!isset($params['is_active'])) {
         $dao->is_active = 1;
     }
     if ($params) {
         foreach ($params as $k => $v) {
             if ($k == 'name' || $k == 'title') {
                 $dao->whereAdd($k . ' LIKE "' . CRM_Core_DAO::escapeString($v) . '"');
             } elseif ($k == 'group_type') {
                 foreach ((array) $v as $type) {
                     $dao->whereAdd($k . " LIKE '%" . CRM_Core_DAO::VALUE_SEPARATOR . (int) $type . CRM_Core_DAO::VALUE_SEPARATOR . "%'");
                 }
             } elseif (is_array($v)) {
                 foreach ($v as &$num) {
                     $num = (int) $num;
                 }
                 $dao->whereAdd($k . ' IN (' . implode(',', $v) . ')');
             } else {
                 $dao->{$k} = $v;
             }
         }
     }
     if ($offset || $rowCount) {
         $offset = $offset > 0 ? $offset : 0;
         $rowCount = $rowCount > 0 ? $rowCount : 25;
         $dao->limit($offset, $rowCount);
     }
     if ($sort) {
         $dao->orderBy($sort);
     }
     // return only specific fields if returnproperties are sent
     if (!empty($returnProperties)) {
         $dao->selectAdd();
         $dao->selectAdd(implode(',', $returnProperties));
     }
     $dao->find();
     $flag = $returnProperties && in_array('member_count', $returnProperties) ? 1 : 0;
     $groups = array();
     while ($dao->fetch()) {
         $group = new CRM_Contact_DAO_Group();
         if ($flag) {
             $dao->member_count = CRM_Contact_BAO_Group::memberCount($dao->id);
         }
         $groups[] = clone $dao;
     }
     return $groups;
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:68,代码来源:Group.php

示例5: from

 function from()
 {
     //define table name
     $randomNum = md5(uniqid());
     $this->_tableName = "civicrm_temp_custom_{$randomNum}";
     //block for Group search
     $smartGroup = array();
     if ($this->_groups || $this->_allSearch) {
         require_once 'CRM/Contact/DAO/Group.php';
         $group = new CRM_Contact_DAO_Group();
         $group->is_active = 1;
         $group->find();
         while ($group->fetch()) {
             $allGroups[] = $group->id;
             if ($group->saved_search_id) {
                 $smartGroup[$group->saved_search_id] = $group->id;
             }
         }
         $includedGroups = implode(',', $allGroups);
         if (!empty($this->_includeGroups)) {
             $iGroups = implode(',', $this->_includeGroups);
         } else {
             //if no group selected search for all groups
             $iGroups = null;
         }
         if (is_array($this->_excludeGroups)) {
             $xGroups = implode(',', $this->_excludeGroups);
         } else {
             $xGroups = 0;
         }
         $sql = "CREATE TEMPORARY TABLE Xg_{$this->_tableName} ( contact_id int primary key) ENGINE=HEAP";
         CRM_Core_DAO::executeQuery($sql);
         //used only when exclude group is selected
         if ($xGroups != 0) {
             $excludeGroup = "INSERT INTO  Xg_{$this->_tableName} ( contact_id )\n                  SELECT  DISTINCT civicrm_group_contact.contact_id\n                  FROM civicrm_group_contact, civicrm_contact                    \n                  WHERE \n                     civicrm_contact.id = civicrm_group_contact.contact_id AND \n                     civicrm_group_contact.status = 'Added' AND\n                     civicrm_group_contact.group_id IN( {$xGroups})";
             CRM_Core_DAO::executeQuery($excludeGroup);
             //search for smart group contacts
             foreach ($this->_excludeGroups as $keys => $values) {
                 if (in_array($values, $smartGroup)) {
                     $ssId = CRM_Utils_Array::key($values, $smartGroup);
                     $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId);
                     $smartSql = $smartSql . " AND contact_a.id NOT IN ( \n                              SELECT contact_id FROM civicrm_group_contact \n                              WHERE civicrm_group_contact.group_id = {$values} AND civicrm_group_contact.status = 'Removed')";
                     $smartGroupQuery = " INSERT IGNORE INTO Xg_{$this->_tableName}(contact_id) {$smartSql}";
                     CRM_Core_DAO::executeQuery($smartGroupQuery);
                 }
             }
         }
         $sql = "CREATE TEMPORARY TABLE Ig_{$this->_tableName} ( id int PRIMARY KEY AUTO_INCREMENT,\n                                                                   contact_id int,\n                                                                   group_names varchar(64)) ENGINE=HEAP";
         CRM_Core_DAO::executeQuery($sql);
         if ($iGroups) {
             $includeGroup = "INSERT INTO Ig_{$this->_tableName} (contact_id, group_names)\n                 SELECT              civicrm_contact.id as contact_id, civicrm_group.title as group_name\n                 FROM                civicrm_contact\n                    INNER JOIN       civicrm_group_contact\n                            ON       civicrm_group_contact.contact_id = civicrm_contact.id\n                    LEFT JOIN        civicrm_group\n                            ON       civicrm_group_contact.group_id = civicrm_group.id";
         } else {
             $includeGroup = "INSERT INTO Ig_{$this->_tableName} (contact_id, group_names)\n                 SELECT              civicrm_contact.id as contact_id, ''\n                 FROM                civicrm_contact";
         }
         //used only when exclude group is selected
         if ($xGroups != 0) {
             $includeGroup .= " LEFT JOIN        Xg_{$this->_tableName}\n                                          ON       civicrm_contact.id = Xg_{$this->_tableName}.contact_id";
         }
         if ($iGroups) {
             $includeGroup .= " WHERE           \n                                     civicrm_group_contact.status = 'Added'  AND\n                                     civicrm_group_contact.group_id IN({$iGroups})";
         } else {
             $includeGroup .= " WHERE ( 1 ) ";
         }
         //used only when exclude group is selected
         if ($xGroups != 0) {
             $includeGroup .= " AND  Xg_{$this->_tableName}.contact_id IS null";
         }
         CRM_Core_DAO::executeQuery($includeGroup);
         //search for smart group contacts
         foreach ($this->_includeGroups as $keys => $values) {
             if (in_array($values, $smartGroup)) {
                 $ssId = CRM_Utils_Array::key($values, $smartGroup);
                 $smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId);
                 $smartSql .= " AND contact_a.id NOT IN ( \n                              SELECT contact_id FROM civicrm_group_contact\n                              WHERE civicrm_group_contact.group_id = {$values} AND civicrm_group_contact.status = 'Removed')";
                 //used only when exclude group is selected
                 if ($xGroups != 0) {
                     $smartSql .= " AND contact_a.id NOT IN (SELECT contact_id FROM  Xg_{$this->_tableName})";
                 }
                 $smartGroupQuery = " INSERT IGNORE INTO Ig_{$this->_tableName}(contact_id) \n                                     {$smartSql}";
                 CRM_Core_DAO::executeQuery($smartGroupQuery);
                 $insertGroupNameQuery = "UPDATE IGNORE Ig_{$this->_tableName}\n                                         SET group_names = (SELECT title FROM civicrm_group\n                                                            WHERE civicrm_group.id = {$values})\n                                         WHERE Ig_{$this->_tableName}.contact_id IS NOT NULL \n                                         AND Ig_{$this->_tableName}.group_names IS NULL";
                 CRM_Core_DAO::executeQuery($insertGroupNameQuery);
             }
         }
     }
     //group contact search end here;
     //block for Tags search
     if ($this->_tags || $this->_allSearch) {
         //find all tags
         require_once 'CRM/Core/DAO/Tag.php';
         $tag = new CRM_Core_DAO_Tag();
         $tag->is_active = 1;
         $tag->find();
         while ($tag->fetch()) {
             $allTags[] = $tag->id;
         }
         $includedTags = implode(',', $allTags);
         if (!empty($this->_includeTags)) {
             $iTags = implode(',', $this->_includeTags);
         } else {
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Group.php

示例6: getName

 /**
  * Given an id, get the name of the saved search.
  *
  * @param int $id
  *   The id of the saved search.
  *
  * @param string $value
  *
  * @return string
  *   the name of the saved search
  */
 public static function getName($id, $value = 'name')
 {
     $group = new CRM_Contact_DAO_Group();
     $group->saved_search_id = $id;
     if ($group->find(TRUE)) {
         return $group->{$value};
     }
     return NULL;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:20,代码来源:SavedSearch.php

示例7: whereGroupClause

 function whereGroupClause($clause)
 {
     $smartGroupQuery = "";
     require_once 'CRM/Contact/DAO/Group.php';
     require_once 'CRM/Contact/BAO/SavedSearch.php';
     $group = new CRM_Contact_DAO_Group();
     $group->is_active = 1;
     $group->find();
     while ($group->fetch()) {
         if (in_array($group->id, $this->_params['gid_value']) && $group->saved_search_id) {
             $smartGroups[] = $group->id;
         }
     }
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::check($smartGroups);
     if (!empty($smartGroups)) {
         $smartGroups = implode(',', $smartGroups);
         $smartGroupQuery = " UNION DISTINCT \n                  SELECT DISTINCT smartgroup_contact.contact_id                                    \n                  FROM civicrm_group_contact_cache smartgroup_contact        \n                  WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
     }
     return " {$this->_aliases['civicrm_contact']}.id IN ( \n                          SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id \n                          FROM civicrm_group_contact {$this->_aliases['civicrm_group']}\n                          WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added' \n                          {$smartGroupQuery} ) ";
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:21,代码来源:Form.php

示例8: civicrm_mailer_event_subscribe

/**
 * Handle a subscription event
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_mailer_event_subscribe($params)
{
    $errors = _civicrm_mailer_check_params($params, array('email', 'group_id'));
    if (!empty($errors)) {
        return $errors;
    }
    $email = $params['email'];
    $group_id = $params['group_id'];
    $contact_id = CRM_Utils_Array::value('contact_id', $params);
    $group = new CRM_Contact_DAO_Group();
    $group->is_active = 1;
    $group->id = (int) $group_id;
    if (!$group->find(TRUE)) {
        return civicrm_create_error(ts('Invalid Group id'));
    }
    $subscribe = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id, $email, $contact_id);
    if ($subscribe !== NULL) {
        /* Ask the contact for confirmation */
        $subscribe->send_confirm_request($email);
        $values = array();
        $values['contact_id'] = $subscribe->contact_id;
        $values['subscribe_id'] = $subscribe->id;
        $values['hash'] = $subscribe->hash;
        $values['is_error'] = 0;
        return $values;
    }
    return civicrm_create_error(ts('Subscription failed'));
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:35,代码来源:Mailer.php

示例9: getGroupList

 /**
  * Get list of all the groups and groups for a contact.
  *
  * @param int $contactId
  *   Contact id.
  *
  * @param bool $visibility
  *
  *
  * @return array
  *   this array has key-> group id and value group title
  */
 public static function getGroupList($contactId = 0, $visibility = FALSE)
 {
     $group = new CRM_Contact_DAO_Group();
     $select = $from = $where = '';
     $select = 'SELECT DISTINCT civicrm_group.id, civicrm_group.title ';
     $from = ' FROM civicrm_group ';
     $where = " WHERE civicrm_group.is_active = 1 ";
     if ($contactId) {
         $from .= ' , civicrm_group_contact ';
         $where .= " AND civicrm_group.id = civicrm_group_contact.group_id\n                        AND civicrm_group_contact.contact_id = " . CRM_Utils_Type::escape($contactId, 'Integer');
     }
     if ($visibility) {
         $where .= " AND civicrm_group.visibility != 'User and User Admin Only'";
     }
     $orderby = " ORDER BY civicrm_group.name";
     $sql = $select . $from . $where . $orderby;
     $group->query($sql);
     $values = array();
     while ($group->fetch()) {
         $values[$group->id] = $group->title;
     }
     return $values;
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:35,代码来源:GroupContact.php

示例10: isSmartGroup

 /**
  * @param int $groupId
  * @return bool
  */
 protected function isSmartGroup($groupId)
 {
     // Then decide which table to join onto the query
     $group = \CRM_Contact_DAO_Group::getTableName();
     // Get the group information
     $sql = "\nSELECT     {$group}.id, {$group}.cache_date, {$group}.saved_search_id, {$group}.children\nFROM       {$group}\nWHERE      {$group}.id = {$groupId}\n";
     $groupDAO = \CRM_Core_DAO::executeQuery($sql);
     if ($groupDAO->fetch() && !empty($groupDAO->saved_search_id)) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:16,代码来源:RecipientBuilder.php

示例11: whereGroupClause

 /**
  * Build where clause for groups.
  *
  * @param string $field
  * @param mixed $value
  * @param string $op
  *
  * @return string
  */
 public function whereGroupClause($field, $value, $op)
 {
     $smartGroupQuery = "";
     $group = new CRM_Contact_DAO_Group();
     $group->is_active = 1;
     $group->find();
     $smartGroups = array();
     while ($group->fetch()) {
         if (in_array($group->id, $this->_params['gid_value']) && $group->saved_search_id) {
             $smartGroups[] = $group->id;
         }
     }
     CRM_Contact_BAO_GroupContactCache::check($smartGroups);
     $smartGroupQuery = '';
     if (!empty($smartGroups)) {
         $smartGroups = implode(',', $smartGroups);
         $smartGroupQuery = " UNION DISTINCT\n                  SELECT DISTINCT smartgroup_contact.contact_id\n                  FROM civicrm_group_contact_cache smartgroup_contact\n                  WHERE smartgroup_contact.group_id IN ({$smartGroups}) ";
     }
     $sqlOp = $this->getSQLOperator($op);
     if (!is_array($value)) {
         $value = array($value);
     }
     $clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")";
     $contactAlias = $this->_aliases['civicrm_contact'];
     if (!empty($this->relationType) && $this->relationType == 'b_a') {
         $contactAlias = $this->_aliases['civicrm_contact_b'];
     }
     return " {$contactAlias}.id {$sqlOp} (\n                          SELECT DISTINCT {$this->_aliases['civicrm_group']}.contact_id\n                          FROM civicrm_group_contact {$this->_aliases['civicrm_group']}\n                          WHERE {$clause} AND {$this->_aliases['civicrm_group']}.status = 'Added'\n                          {$smartGroupQuery} ) ";
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:38,代码来源:Form.php

示例12: confirm

 /**
  * Confirm a pending subscription
  *
  * @param int $contact_id       The id of the contact
  * @param int $subscribe_id     The id of the subscription event
  * @param string $hash          The hash
  * @return boolean              True on success
  * @access public
  * @static
  */
 public static function confirm($contact_id, $subscribe_id, $hash)
 {
     require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
     $se =& CRM_Mailing_Event_BAO_Subscribe::verify($contact_id, $subscribe_id, $hash);
     if (!$se) {
         return false;
     }
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $ce = new CRM_Mailing_Event_BAO_Confirm();
     $ce->event_subscribe_id = $se->id;
     $ce->time_stamp = date('YmdHis');
     $ce->save();
     require_once 'CRM/Contact/BAO/GroupContact.php';
     CRM_Contact_BAO_GroupContact::updateGroupMembershipStatus($contact_id, $se->group_id, 'Email', $ce->id);
     $transaction->commit();
     $config = CRM_Core_Config::singleton();
     require_once 'CRM/Core/BAO/Domain.php';
     $domain =& CRM_Core_BAO_Domain::getDomain();
     list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();
     require_once 'CRM/Contact/BAO/Contact/Location.php';
     list($display_name, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($se->contact_id);
     require_once 'CRM/Contact/DAO/Group.php';
     $group = new CRM_Contact_DAO_Group();
     $group->id = $se->group_id;
     $group->find(true);
     require_once 'CRM/Mailing/BAO/Component.php';
     $component = new CRM_Mailing_BAO_Component();
     $component->is_default = 1;
     $component->is_active = 1;
     $component->component_type = 'Welcome';
     $component->find(true);
     require_once 'CRM/Core/BAO/MailSettings.php';
     $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
     $headers = array('Subject' => $component->subject, 'From' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'To' => $email, 'Reply-To' => "do-not-reply@{$emailDomain}", 'Return-Path' => "do-not-reply@{$emailDomain}");
     $html = $component->body_html;
     if ($component->body_text) {
         $text = $component->body_text;
     } else {
         $text = CRM_Utils_String::htmlToText($component->body_html);
     }
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $bao = new CRM_Mailing_BAO_Mailing();
     $bao->body_text = $text;
     $bao->body_html = $html;
     $tokens = $bao->getTokens();
     require_once 'CRM/Utils/Token.php';
     $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, true, $tokens['html']);
     $html = CRM_Utils_Token::replaceWelcomeTokens($html, $group->title, true);
     $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, false, $tokens['text']);
     $text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->title, false);
     $message = new Mail_mime("\n");
     $message->setHTMLBody($html);
     $message->setTxtBody($text);
     $b =& CRM_Utils_Mail::setMimeParams($message);
     $h =& $message->headers($headers);
     $mailer =& $config->getMailer();
     require_once 'CRM/Mailing/BAO/Mailing.php';
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Core_Error', 'nullHandler'));
     if (is_object($mailer)) {
         $mailer->send($email, $h, $b);
         CRM_Core_Error::setCallback();
     }
     return $group->title;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:75,代码来源:Confirm.php

示例13: groupClause

 /**
  * Get group clause for this user
  *
  * @param int $type the type of permission needed
  * @param  array $tables (reference ) add the tables that are needed for the select clause
  * @param  array $whereTables (reference ) add the tables that are needed for the where clause
  *
  * @return string the group where clause for this user
  * @access public
  */
 public static function groupClause($type, &$tables, &$whereTables)
 {
     if (!isset(self::$_viewPermissionedGroups)) {
         self::group();
     }
     if ($type == CRM_Core_Permission::EDIT) {
         if (self::$_editAdminUser) {
             $clause = ' ( 1 ) ';
         } else {
             if (empty(self::$_editPermissionedGroups)) {
                 $clause = ' ( 0 ) ';
             } else {
                 $clauses = array();
                 $groups = implode(', ', self::$_editPermissionedGroups);
                 $clauses[] = ' ( civicrm_group_contact.group_id IN ( ' . implode(', ', array_keys(self::$_editPermissionedGroups)) . " ) AND civicrm_group_contact.status = 'Added' ) ";
                 $tables['civicrm_group_contact'] = 1;
                 $whereTables['civicrm_group_contact'] = 1;
                 // foreach group that is potentially a saved search, add the saved search clause
                 foreach (array_keys(self::$_editPermissionedGroups) as $id) {
                     $group = new CRM_Contact_DAO_Group();
                     $group->id = $id;
                     if ($group->find(true) && $group->saved_search_id) {
                         require_once 'CRM/Contact/BAO/SavedSearch.php';
                         $clause = CRM_Contact_BAO_SavedSearch::whereClause($group->saved_search_id, $tables, $whereTables);
                         if (trim($clause)) {
                             $clauses[] = $clause;
                         }
                     }
                 }
                 $clause = ' ( ' . implode(' OR ', $clauses) . ' ) ';
             }
         }
     } else {
         if (self::$_viewAdminUser) {
             $clause = ' ( 1 ) ';
         } else {
             if (empty(self::$_viewPermissionedGroups)) {
                 $clause = ' ( 0 ) ';
             } else {
                 $clauses = array();
                 $groups = implode(', ', self::$_viewPermissionedGroups);
                 $clauses[] = ' ( civicrm_group_contact.group_id IN (' . implode(', ', array_keys(self::$_viewPermissionedGroups)) . " ) AND civicrm_group_contact.status = 'Added' ) ";
                 $tables['civicrm_group_contact'] = 1;
                 $whereTables['civicrm_group_contact'] = 1;
                 // foreach group that is potentially a saved search, add the saved search clause
                 foreach (array_keys(self::$_viewPermissionedGroups) as $id) {
                     $group = new CRM_Contact_DAO_Group();
                     $group->id = $id;
                     if ($group->find(true) && $group->saved_search_id) {
                         require_once 'CRM/Contact/BAO/SavedSearch.php';
                         $clause = CRM_Contact_BAO_SavedSearch::whereClause($group->saved_search_id, $tables, $whereTables);
                         if (trim($clause)) {
                             $clauses[] = $clause;
                         }
                     }
                 }
                 $clause = ' ( ' . implode(' OR ', $clauses) . ' ) ';
             }
         }
     }
     return $clause;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:72,代码来源:Drupal.php

示例14: browse

 /**
  * We need to do slightly different things for groups vs saved search groups, hence we
  * reimplement browse from Page_Basic
  * @param int $action
  *
  * @return void
  * @access public
  */
 function browse($action = null)
 {
     require_once 'CRM/Contact/BAO/GroupNesting.php';
     $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
     if ($this->_sortByCharacter == 1 || !empty($_POST)) {
         $this->_sortByCharacter = '';
         $this->set('sortByCharacter', '');
     }
     $query = " SELECT COUNT(*) FROM civicrm_group";
     $groupExists = CRM_Core_DAO::singleValueQuery($query);
     $this->assign('groupExists', $groupExists);
     $this->search();
     $config =& CRM_Core_Config::singleton();
     $params = array();
     $whereClause = $this->whereClause($params, false);
     $this->pagerAToZ($whereClause, $params);
     $params = array();
     $whereClause = $this->whereClause($params, true);
     $this->pager($whereClause, $params);
     list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
     $select = $from = $where = "";
     if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && CRM_Core_Permission::check('administer Multiple Organizations')) {
         $select = ", contact.display_name as orgName, contact.id as orgID";
         $from = " LEFT JOIN civicrm_group_organization gOrg\n                               ON gOrg.group_id = groups.id \n                        LEFT JOIN civicrm_contact contact\n                               ON contact.id = gOrg.organization_id ";
         //get the Organization ID
         $orgID = CRM_Utils_Request::retrieve('oid', 'Positive', CRM_Core_DAO::$_nullObject);
         if ($orgID) {
             $where = " AND gOrg.organization_id = {$orgID}";
         }
         $this->assign('groupOrg', true);
     }
     $query = "\n        SELECT groups.* {$select}\n        FROM  civicrm_group groups \n              {$from}\n        WHERE {$whereClause} {$where}\n        ORDER BY groups.title asc\n        LIMIT {$offset}, {$rowCount}";
     $object = CRM_Core_DAO::executeQuery($query, $params, true, 'CRM_Contact_DAO_Group');
     $groupPermission = CRM_Core_Permission::check('edit groups') ? CRM_Core_Permission::EDIT : CRM_Core_Permission::VIEW;
     $this->assign('groupPermission', $groupPermission);
     //FIXME CRM-4418, now we are handling delete separately
     //if we introduce 'delete for group' make sure to handle here.
     $groupPermissions = array(CRM_Core_Permission::VIEW);
     if (CRM_Core_Permission::check('edit groups')) {
         $groupPermissions[] = CRM_Core_Permission::EDIT;
         $groupPermissions[] = CRM_Core_Permission::DELETE;
     }
     require_once 'CRM/Core/OptionGroup.php';
     $links =& $this->links();
     $allTypes = CRM_Core_OptionGroup::values('group_type');
     $values = array();
     while ($object->fetch()) {
         $permission = $this->checkPermission($object->id, $object->title);
         if ($permission) {
             $newLinks = $links;
             $values[$object->id] = array();
             CRM_Core_DAO::storeValues($object, $values[$object->id]);
             if ($object->saved_search_id) {
                 $values[$object->id]['title'] .= ' (' . ts('Smart Group') . ')';
                 // check if custom search, if so fix view link
                 $customSearchID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $object->saved_search_id, 'search_custom_id');
                 if ($customSearchID) {
                     $newLinks[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/search/custom';
                     $newLinks[CRM_Core_Action::VIEW]['qs'] = "reset=1&force=1&ssID={$object->saved_search_id}";
                 }
             }
             $action = array_sum(array_keys($newLinks));
             if (array_key_exists('is_active', $object)) {
                 if ($object->is_active) {
                     $action -= CRM_Core_Action::ENABLE;
                 } else {
                     $action -= CRM_Core_Action::VIEW;
                     $action -= CRM_Core_Action::DISABLE;
                 }
             }
             $action = $action & CRM_Core_Action::mask($groupPermissions);
             $values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', $values[$object->id]['visibility']);
             if (isset($values[$object->id]['group_type'])) {
                 $groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values[$object->id]['group_type'], 1, -1));
                 $types = array();
                 foreach ($groupTypes as $type) {
                     $types[] = $allTypes[$type];
                 }
                 $values[$object->id]['group_type'] = implode(', ', $types);
             }
             $values[$object->id]['action'] = CRM_Core_Action::formLink($newLinks, $action, array('id' => $object->id, 'ssid' => $object->saved_search_id));
             if (array_key_exists('orgName', $object)) {
                 if ($object->orgName) {
                     $values[$object->id]['org_name'] = $object->orgName;
                     $values[$object->id]['org_id'] = $object->orgID;
                 }
             }
         }
     }
     if (isset($values)) {
         $this->assign('rows', $values);
     }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Group.php

示例15: getGroupList

 /**
  * This function to get list of groups
  *
  * @param  array   $params associated array for params
  * @access public
  */
 static function getGroupList(&$params)
 {
     $config = CRM_Core_Config::singleton();
     $whereClause = self::whereClause($params, FALSE);
     //$this->pagerAToZ( $whereClause, $params );
     if (!empty($params['rowCount']) && $params['rowCount'] > 0) {
         $limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
     }
     $orderBy = ' ORDER BY groups.title asc';
     if (CRM_Utils_Array::value('sort', $params)) {
         $orderBy = ' ORDER BY ' . CRM_Utils_Array::value('sort', $params);
     }
     $select = $from = $where = "";
     $groupOrg = FALSE;
     if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) {
         $select = ", contact.display_name as org_name, contact.id as org_id";
         $from = " LEFT JOIN civicrm_group_organization gOrg\n                               ON gOrg.group_id = groups.id\n                        LEFT JOIN civicrm_contact contact\n                               ON contact.id = gOrg.organization_id ";
         //get the Organization ID
         $orgID = CRM_Utils_Request::retrieve('oid', 'Positive', CRM_Core_DAO::$_nullObject);
         if ($orgID) {
             $where = " AND gOrg.organization_id = {$orgID}";
         }
         $groupOrg = TRUE;
     }
     $query = "\n        SELECT groups.* {$select}\n        FROM  civicrm_group groups\n              {$from}\n        WHERE {$whereClause} {$where}\n        {$orderBy}\n        {$limit}";
     $object = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contact_DAO_Group');
     //FIXME CRM-4418, now we are handling delete separately
     //if we introduce 'delete for group' make sure to handle here.
     $groupPermissions = array(CRM_Core_Permission::VIEW);
     if (CRM_Core_Permission::check('edit groups')) {
         $groupPermissions[] = CRM_Core_Permission::EDIT;
         $groupPermissions[] = CRM_Core_Permission::DELETE;
     }
     // CRM-9936
     $reservedPermission = CRM_Core_Permission::check('administer reserved groups');
     $links = self::actionLinks();
     $allTypes = CRM_Core_OptionGroup::values('group_type');
     $values = array();
     while ($object->fetch()) {
         $permission = CRM_Contact_BAO_Group::checkPermission($object->id, $object->title);
         if ($permission) {
             $newLinks = $links;
             $values[$object->id] = array();
             CRM_Core_DAO::storeValues($object, $values[$object->id]);
             if ($object->saved_search_id) {
                 $values[$object->id]['title'] .= ' (' . ts('Smart Group') . ')';
                 // check if custom search, if so fix view link
                 $customSearchID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $object->saved_search_id, 'search_custom_id');
                 if ($customSearchID) {
                     $newLinks[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/search/custom';
                     $newLinks[CRM_Core_Action::VIEW]['qs'] = "reset=1&force=1&ssID={$object->saved_search_id}";
                 }
             }
             $action = array_sum(array_keys($newLinks));
             // CRM-9936
             if (array_key_exists('is_reserved', $object)) {
                 //if group is reserved and I don't have reserved permission, suppress delete/edit
                 if ($object->is_reserved && !$reservedPermission) {
                     $action -= CRM_Core_Action::DELETE;
                     $action -= CRM_Core_Action::UPDATE;
                     $action -= CRM_Core_Action::DISABLE;
                 }
             }
             $values[$object->id]['class'] = '';
             if (array_key_exists('is_active', $object)) {
                 if ($object->is_active) {
                     $action -= CRM_Core_Action::ENABLE;
                 } else {
                     $values[$object->id]['class'] = 'disabled';
                     $action -= CRM_Core_Action::VIEW;
                     $action -= CRM_Core_Action::DISABLE;
                 }
             }
             $action = $action & CRM_Core_Action::mask($groupPermissions);
             $values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', $values[$object->id]['visibility']);
             if (isset($values[$object->id]['group_type'])) {
                 $groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values[$object->id]['group_type'], 1, -1));
                 $types = array();
                 foreach ($groupTypes as $type) {
                     $types[] = CRM_Utils_Array::value($type, $allTypes);
                 }
                 $values[$object->id]['group_type'] = implode(', ', $types);
             }
             $values[$object->id]['action'] = CRM_Core_Action::formLink($newLinks, $action, array('id' => $object->id, 'ssid' => $object->saved_search_id));
             if ($groupOrg) {
                 if ($object->org_id) {
                     $contactUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$object->org_id}");
                     $values[$object->id]['org_info'] = "<a href='{$contactUrl}'>{$object->org_name}</a>";
                 } else {
                     $values[$object->id]['org_info'] = '';
                     // Empty cell
                 }
             } else {
                 $values[$object->id]['org_info'] = NULL;
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Group.php


注:本文中的CRM_Contact_DAO_Group类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。