EntityRole.php 3.26 KB
Newer Older
totten's avatar
totten committed
1 2 3
<?php
/*
 +--------------------------------------------------------------------+
yashodha's avatar
yashodha committed
4
 | CiviCRM version 4.6                                                |
totten's avatar
totten committed
5
 +--------------------------------------------------------------------+
kurund's avatar
kurund committed
6
 | Copyright CiviCRM LLC (c) 2004-2014                                |
totten's avatar
totten committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 +--------------------------------------------------------------------+
 | This file is a part of CiviCRM.                                    |
 |                                                                    |
 | CiviCRM is free software; you can copy, modify, and distribute it  |
 | under the terms of the GNU Affero General Public License           |
 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
 |                                                                    |
 | CiviCRM is distributed in the hope that it will be useful, but     |
 | WITHOUT ANY WARRANTY; without even the implied warranty of         |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
 | See the GNU Affero General Public License for more details.        |
 |                                                                    |
 | You should have received a copy of the GNU Affero General Public   |
 | License and the CiviCRM Licensing Exception along                  |
 | with this program; if not, contact CiviCRM LLC                     |
 | at info[AT]civicrm[DOT]org. If you have questions about the        |
 | GNU Affero General Public License or the licensing of CiviCRM,     |
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
26
 */
totten's avatar
totten committed
27 28 29 30

/**
 *
 * @package CRM
kurund's avatar
kurund committed
31
 * @copyright CiviCRM LLC (c) 2004-2014
totten's avatar
totten committed
32 33 34 35 36 37 38 39 40 41
 * $Id$
 *
 */

/**
 *  Access Control EntityRole
 */
class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
  static $_entityTable = NULL;

42 43 44
  /**
   * @return array|null
   */
45
  public static function entityTable() {
totten's avatar
totten committed
46 47 48 49 50 51 52 53 54
    if (!self::$_entityTable) {
      self::$_entityTable = array(
        'civicrm_contact' => ts('Contact'),
        'civicrm_group' => ts('Group'),
      );
    }
    return self::$_entityTable;
  }

55
  /**
56
   * @param array $params
57 58 59
   *
   * @return CRM_ACL_DAO_EntityRole
   */
60
  public static function create(&$params) {
totten's avatar
totten committed
61 62 63
    $dao = new CRM_ACL_DAO_EntityRole();
    $dao->copyValues($params);
    $dao->save();
64
    return $dao;
totten's avatar
totten committed
65 66
  }

67
  /**
68
   * @param array $params
69 70
   * @param $defaults
   */
71
  public static function retrieve(&$params, &$defaults) {
totten's avatar
totten committed
72 73 74 75
    CRM_Core_DAO::commonRetrieve('CRM_ACL_DAO_EntityRole', $params, $defaults);
  }

  /**
colemanw's avatar
colemanw committed
76
   * Update the is_active flag in the db
totten's avatar
totten committed
77
   *
78 79 80 81
   * @param int $id
   *   Id of the database record.
   * @param bool $is_active
   *   Value we want to set the is_active field.
totten's avatar
totten committed
82
   *
83 84
   * @return Object
   *   DAO object on sucess, null otherwise
totten's avatar
totten committed
85
   */
86
  public static function setIsActive($id, $is_active) {
totten's avatar
totten committed
87 88 89 90
    return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active);
  }

  /**
colemanw's avatar
colemanw committed
91
   * Delete Entity Role records
totten's avatar
totten committed
92
   *
93 94
   * @param int $entityRoleId
   *   ID of the EntityRole record to be deleted.
totten's avatar
totten committed
95 96
   *
   */
97
  public static function del($entityRoleId) {
totten's avatar
totten committed
98 99 100 101 102
    $entityDAO = new CRM_ACL_DAO_EntityRole();
    $entityDAO->id = $entityRoleId;
    $entityDAO->find(TRUE);
    $entityDAO->delete();
  }
103

totten's avatar
totten committed
104
}