Skip to content

Commit

Permalink
Merge pull request civicrm#7 from PalanteJon/status-page
Browse files Browse the repository at this point in the history
CRM-13283 - xml for StatusPreference entity
  • Loading branch information
agh1 committed Apr 26, 2015
2 parents 09e1efe + 2292065 commit 1039eae
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 1 deletion.
76 changes: 76 additions & 0 deletions CRM/Core/BAO/StatusPreference.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| 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 |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/

/**
* This class contains functions for managing Action Logs
*/
class CRM_Core_BAO_StatusPreference extends CRM_Core_DAO_StatusPreference {

/**
* Create or update a Status Preference entry.
*
* @param array $params
*
* @return array
*/
public static function create($params) {
$statusPreference = new CRM_Core_DAO_StatusPreference();
if (array_key_exists("domain_id", $params) === FALSE) {
$params["domain_id"] = CRM_Core_Config::domainID();
}

$statusPreference->copyValues($params);

$edit = ($statusPreference->id) ? TRUE : FALSE;
if ($edit) {
CRM_Utils_Hook::pre('edit', 'StatusPreference', $statusPreference->id, $statusPreference);
}
else {
CRM_Utils_Hook::pre('create', 'StatusPreference', NULL, $statusPreference);
}

$statusPreference->save();

if ($edit) {
CRM_Utils_Hook::post('edit', 'StatusPreference', $statusPreference->id, $statusPreference);
}
else {
CRM_Utils_Hook::post('create', 'StatusPreference', NULL, $statusPreference);
}

return $statusPreference;
}

}
77 changes: 77 additions & 0 deletions api/v3/StatusPreference.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| 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 |
+--------------------------------------------------------------------+
*/

/**
* This api exposes CiviCRM Status Preferences.
*
* @package CiviCRM_APIv3
*/

/**
* Save a Status Preference.
*
* @param array $params
*
* @return array
*/
function civicrm_api3_status_preference_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* Get an Acl.
*
* @param array $params
*
* @return array
* Array of retrieved Acl property values.
*/
function civicrm_api3_status_preference_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* Delete an Acl.
*
* @param array $params
*
* @return array
* Array of deleted values.
*/
function civicrm_api3_status_preference_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* Adjust Metadata for Create action.
*
* @param array $params
* Array of parameters determined by getfields.
*/
function _civicrm_api3_status_preference_create_spec(&$params) {
$params['name']['api.required'] = 1;
}
81 changes: 81 additions & 0 deletions xml/schema/Core/StatusPreference.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="iso-8859-1" ?>

<table>
<base>CRM/Core</base>
<class>StatusPreference</class>
<name>civicrm_status_pref</name>
<comment>Preferences controlling status checks called in system.check.</comment>
<add>4.7</add>
<field>
<name>id</name>
<type>int unsigned</type>
<title>Status Preference ID</title>
<required>true</required>
<comment>Unique Status Preference ID</comment>
<add>4.7</add>
</field>
<primaryKey>
<name>id</name>
<autoincrement>true</autoincrement>
</primaryKey>
<field>
<name>domain_id</name>
<title>Setting Domain</title>
<type>int unsigned</type>
<required>true</required>
<pseudoconstant>
<table>civicrm_domain</table>
<keyColumn>id</keyColumn>
<labelColumn>name</labelColumn>
</pseudoconstant>
<comment>Which Domain is this Status Preference for</comment>
<add>4.7</add>
</field>
<foreignKey>
<name>domain_id</name>
<table>civicrm_domain</table>
<key>id</key>
<add>4.7</add>
</foreignKey>
<field>
<name>name</name>
<title>Status Check Name</title>
<type>varchar</type>
<length>255</length>
<import>true</import>
<required>true</required>
<comment>Name of the status check this preference references.</comment>
<add>4.7</add>
</field>
<index>
<name>UI_status_pref_name</name>
<fieldName>name</fieldName>
<unique>true</unique>
<add>4.7</add>
</index>
<field>
<name>hush_until</name>
<title>Hush Status Notifications Until</title>
<type>date</type>
<import>true</import>
<comment>expires minimum_date_severity. NULL never hushes.</comment>
<default>NULL</default>
<add>4.7</add>
</field>
<field>
<name>minimum_report_severity</name>
<title>Minimum Report Severity</title>
<type>int unsigned</type>
<import>true</import>
<comment>Hush messages up to but excluding this severity.</comment>
<add>4.7</add>
</field>
<field>
<name>prefs</name>
<title>Status Preferences</title>
<type>varchar</type>
<length>255</length>
<comment>These settings are per-check, and can't be compared across checks.</comment>
<add>4.7</add>
</field>
</table>
1 change: 1 addition & 0 deletions xml/schema/Core/files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@
<xi:include href="PrintLabel.xml" parse="xml" />
<xi:include href="WordReplacement.xml" parse="xml" />
<xi:include href="RecurringEntity.xml" parse="xml" />
<xi:include href="StatusPreference.xml" parse="xml" />
</tables>
2 changes: 1 addition & 1 deletion xml/version.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<version>
<version_no>4.6.3</version_no>
<version_no>4.7.alpha1</version_no>
</version>

0 comments on commit 1039eae

Please sign in to comment.