First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,359 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* This class contains all the function that are called using AJAX.
*/
class CRM_Admin_Page_AJAX {
/**
* CRM-12337 Output navigation menu as executable javascript.
*
* @see smarty_function_crmNavigationMenu
*/
public static function getNavigationMenu() {
$contactID = CRM_Core_Session::singleton()->get('userID');
if ($contactID) {
CRM_Core_Page_AJAX::setJsHeaders();
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('includeEmail', civicrm_api3('setting', 'getvalue', array('name' => 'includeEmailInName', 'group' => 'Search Preferences')));
print $smarty->fetchWith('CRM/common/navigation.js.tpl', array(
'navigation' => CRM_Core_BAO_Navigation::createNavigation($contactID),
));
}
CRM_Utils_System::civiExit();
}
/**
* Process drag/move action for menu tree.
*/
public static function menuTree() {
CRM_Core_BAO_Navigation::processNavigation($_GET);
}
/**
* Build status message while enabling/ disabling various objects.
*/
public static function getStatusMsg() {
require_once 'api/v3/utils.php';
$recordID = CRM_Utils_Type::escape($_GET['id'], 'Integer');
$entity = CRM_Utils_Type::escape($_GET['entity'], 'String');
$ret = array();
if ($recordID && $entity && $recordBAO = _civicrm_api3_get_BAO($entity)) {
switch ($recordBAO) {
case 'CRM_Core_BAO_UFGroup':
$method = 'getUFJoinRecord';
$result = array($recordBAO, $method);
$ufJoin = call_user_func_array(($result), array($recordID, TRUE));
if (!empty($ufJoin)) {
$ret['content'] = ts('This profile is currently used for %1.', array(1 => implode(', ', $ufJoin))) . ' <br/><br/>' . ts('If you disable the profile - it will be removed from these forms and/or modules. Do you want to continue?');
}
else {
$ret['content'] = ts('Are you sure you want to disable this profile?');
}
break;
case 'CRM_Price_BAO_PriceSet':
$usedBy = CRM_Price_BAO_PriceSet::getUsedBy($recordID);
$priceSet = CRM_Price_BAO_PriceSet::getTitle($recordID);
if (!CRM_Utils_System::isNull($usedBy)) {
$template = CRM_Core_Smarty::singleton();
$template->assign('usedBy', $usedBy);
$comps = array(
'Event' => 'civicrm_event',
'Contribution' => 'civicrm_contribution_page',
'EventTemplate' => 'civicrm_event_template',
);
$contexts = array();
foreach ($comps as $name => $table) {
if (array_key_exists($table, $usedBy)) {
$contexts[] = $name;
}
}
$template->assign('contexts', $contexts);
$ret['illegal'] = TRUE;
$table = $template->fetch('CRM/Price/Page/table.tpl');
$ret['content'] = ts('Unable to disable the \'%1\' price set - it is currently in use by one or more active events, contribution pages or contributions.', array(
1 => $priceSet,
)) . "<br/> $table";
}
else {
$ret['content'] = ts('Are you sure you want to disable \'%1\' Price Set?', array(1 => $priceSet));
}
break;
case 'CRM_Event_BAO_Event':
$ret['content'] = ts('Are you sure you want to disable this Event?');
break;
case 'CRM_Core_BAO_UFField':
$ret['content'] = ts('Are you sure you want to disable this CiviCRM Profile field?');
break;
case 'CRM_Contribute_BAO_ManagePremiums':
$ret['content'] = ts('Are you sure you want to disable this premium? This action will remove the premium from any contribution pages that currently offer it. However it will not delete the premium record - so you can re-enable it and add it back to your contribution page(s) at a later time.');
break;
case 'CRM_Contact_BAO_Relationship':
$ret['content'] = ts('Are you sure you want to disable this relationship?');
break;
case 'CRM_Contact_BAO_RelationshipType':
$ret['content'] = ts('Are you sure you want to disable this relationship type?') . '<br/><br/>' . ts('Users will no longer be able to select this value when adding or editing relationships between contacts.');
break;
case 'CRM_Financial_BAO_FinancialType':
$ret['content'] = ts('Are you sure you want to disable this financial type?');
break;
case 'CRM_Financial_BAO_FinancialAccount':
if (!CRM_Financial_BAO_FinancialAccount::getARAccounts($recordID)) {
$ret['illegal'] = TRUE;
$ret['content'] = ts('The selected financial account cannot be disabled because at least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance).');
}
else {
$ret['content'] = ts('Are you sure you want to disable this financial account?');
}
break;
case 'CRM_Financial_BAO_PaymentProcessor':
$ret['content'] = ts('Are you sure you want to disable this payment processor?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing transaction pages.');
break;
case 'CRM_Financial_BAO_PaymentProcessorType':
$ret['content'] = ts('Are you sure you want to disable this payment processor type?');
break;
case 'CRM_Core_BAO_LocationType':
$ret['content'] = ts('Are you sure you want to disable this location type?') . ' <br/><br/>' . ts('Users will no longer be able to select this value when adding or editing contact locations.');
break;
case 'CRM_Event_BAO_ParticipantStatusType':
$ret['content'] = ts('Are you sure you want to disable this Participant Status?') . '<br/><br/> ' . ts('Users will no longer be able to select this value when adding or editing Participant Status.');
break;
case 'CRM_Mailing_BAO_Component':
$ret['content'] = ts('Are you sure you want to disable this component?');
break;
case 'CRM_Core_BAO_CustomField':
$ret['content'] = ts('Are you sure you want to disable this custom data field?');
break;
case 'CRM_Core_BAO_CustomGroup':
$ret['content'] = ts('Are you sure you want to disable this custom data group? Any profile fields that are linked to custom fields of this group will be disabled.');
break;
case 'CRM_Core_BAO_MessageTemplate':
$ret['content'] = ts('Are you sure you want to disable this message tempate?');
break;
case 'CRM_ACL_BAO_ACL':
$ret['content'] = ts('Are you sure you want to disable this ACL?');
break;
case 'CRM_ACL_BAO_EntityRole':
$ret['content'] = ts('Are you sure you want to disable this ACL Role Assignment?');
break;
case 'CRM_Member_BAO_MembershipType':
$ret['content'] = ts('Are you sure you want to disable this membership type?');
break;
case 'CRM_Member_BAO_MembershipStatus':
$ret['content'] = ts('Are you sure you want to disable this membership status rule?');
break;
case 'CRM_Price_BAO_PriceField':
$ret['content'] = ts('Are you sure you want to disable this price field?');
break;
case 'CRM_Contact_BAO_Group':
$ret['content'] = ts('Are you sure you want to disable this Group?');
break;
case 'CRM_Core_BAO_OptionGroup':
$ret['content'] = ts('Are you sure you want to disable this Option?');
break;
case 'CRM_Contact_BAO_ContactType':
$ret['content'] = ts('Are you sure you want to disable this Contact Type?');
break;
case 'CRM_Core_BAO_OptionValue':
$label = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $recordID, 'label');
$ret['content'] = ts('Are you sure you want to disable the \'%1\' option ?', array(1 => $label));
$ret['content'] .= '<br /><br />' . ts('WARNING - Disabling an option which has been assigned to existing records will result in that option being cleared when the record is edited.');
break;
case 'CRM_Contribute_BAO_ContributionRecur':
$recurDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recordID);
$ret['content'] = ts('Are you sure you want to mark this recurring contribution as cancelled?');
$ret['content'] .= '<br /><br /><strong>' . ts('WARNING - This action sets the CiviCRM recurring contribution status to Cancelled, but does NOT send a cancellation request to the payment processor. You will need to ensure that this recurring payment (subscription) is cancelled by the payment processor.') . '</strong>';
if ($recurDetails->membership_id) {
$ret['content'] .= '<br /><br /><strong>' . ts('This recurring contribution is linked to an auto-renew membership. If you cancel it, the associated membership will no longer renew automatically. However, the current membership status will not be affected.') . '</strong>';
}
break;
default:
$ret['content'] = ts('Are you sure you want to disable this record?');
break;
}
}
else {
$ret = array('status' => 'error', 'content' => 'Error: Unknown entity type.', 'illegal' => TRUE);
}
CRM_Core_Page_AJAX::returnJsonResponse($ret);
}
/**
* Get a list of mappings.
*
* This appears to be only used by scheduled reminders.
*/
static public function mappingList() {
if (empty($_GET['mappingID'])) {
CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.'));
}
$mapping = CRM_Core_BAO_ActionSchedule::getMapping($_GET['mappingID']);
$dateFieldLabels = $mapping ? $mapping->getDateFields() : array();
// The UX here is quirky -- for "Activity" types, there's a simple drop "Recipients"
// dropdown which is always displayed. For other types, the "Recipients" drop down is
// conditional upon the weird isLimit ('Limit To / Also Include / Neither') dropdown.
$noThanksJustKidding = !$_GET['isLimit'];
if ($mapping instanceof CRM_Activity_ActionMapping || !$noThanksJustKidding) {
$entityRecipientLabels = $mapping ? ($mapping->getRecipientTypes() + CRM_Core_BAO_ActionSchedule::getAdditionalRecipients()) : array();
}
else {
$entityRecipientLabels = CRM_Core_BAO_ActionSchedule::getAdditionalRecipients();
}
$recipientMapping = array_combine(array_keys($entityRecipientLabels), array_keys($entityRecipientLabels));
$output = array(
'sel4' => CRM_Utils_Array::toKeyValueRows($dateFieldLabels),
'sel5' => CRM_Utils_Array::toKeyValueRows($entityRecipientLabels),
'recipientMapping' => $recipientMapping,
);
CRM_Utils_JSON::output($output);
}
/**
* (Scheduled Reminders) Get the list of possible recipient filters.
*
* Ex: GET /civicrm/ajax/recipientListing?mappingID=contribpage&recipientType=
*/
public static function recipientListing() {
$mappingID = filter_input(INPUT_GET, 'mappingID', FILTER_VALIDATE_REGEXP, array(
'options' => array(
'regexp' => '/^[a-zA-Z0-9_\-]+$/',
),
));
$recipientType = filter_input(INPUT_GET, 'recipientType', FILTER_VALIDATE_REGEXP, array(
'options' => array(
'regexp' => '/^[a-zA-Z0-9_\-]+$/',
),
));
CRM_Utils_JSON::output(array(
'recipients' => CRM_Utils_Array::toKeyValueRows(CRM_Core_BAO_ActionSchedule::getRecipientListing($mappingID, $recipientType)),
));
}
/**
* Outputs one branch in the tag tree
*
* Used by jstree to incrementally load tags
*/
public static function getTagTree() {
$parent = CRM_Utils_Type::escape(CRM_Utils_Array::value('parent_id', $_GET, 0), 'Integer');
$result = array();
$parentClause = $parent ? "AND parent_id = $parent" : 'AND parent_id IS NULL';
$sql = "SELECT *
FROM civicrm_tag
WHERE is_tagset <> 1 $parentClause
GROUP BY id
ORDER BY name";
// fetch all child tags in Array('parent_tag' => array('child_tag_1', 'child_tag_2', ...)) format
$childTagIDs = CRM_Core_BAO_Tag::getChildTags();
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$style = '';
if ($dao->color) {
$style = "background-color: {$dao->color}; color: " . CRM_Utils_Color::getContrast($dao->color);
}
$hasChildTags = empty($childTagIDs[$dao->id]) ? FALSE : TRUE;
$usedFor = (array) explode(',', $dao->used_for);
$result[] = array(
'id' => $dao->id,
'text' => $dao->name,
'icon' => FALSE,
'li_attr' => array(
'title' => ((string) $dao->description) . ($dao->is_reserved ? ' (*' . ts('Reserved') . ')' : ''),
'class' => $dao->is_reserved ? 'is-reserved' : '',
),
'a_attr' => array(
'style' => $style,
'class' => 'crm-tag-item',
),
'children' => $hasChildTags,
'data' => array(
'description' => (string) $dao->description,
'is_selectable' => (bool) $dao->is_selectable,
'is_reserved' => (bool) $dao->is_reserved,
'used_for' => $usedFor,
'color' => $dao->color ? $dao->color : '#ffffff',
'usages' => civicrm_api3('EntityTag', 'getcount', array(
'entity_table' => array('IN' => $usedFor),
'tag_id' => $dao->id,
)),
),
);
}
if (!empty($_REQUEST['is_unit_test'])) {
return $result;
}
CRM_Utils_JSON::output($result);
}
}

View file

@ -0,0 +1,227 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Api Explorer
*/
class CRM_Admin_Page_APIExplorer extends CRM_Core_Page {
/**
* Run page.
*
* @return string
*/
public function run() {
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'templates/CRM/Admin/Page/APIExplorer.js')
->addScriptFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.js', 99)
->addStyleFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.css', 99)
->addVars('explorer', array('max_joins' => \Civi\API\Api3SelectQuery::MAX_JOINS));
$this->assign('operators', CRM_Core_DAO::acceptedSQLOperators());
// List example directories
$examples = array();
foreach (scandir(\Civi::paths()->getPath('[civicrm.root]/api/v3/examples')) as $item) {
if ($item && strpos($item, '.') === FALSE) {
$examples[] = $item;
}
}
$this->assign('examples', $examples);
return parent::run();
}
/**
* Get user context.
*
* @return string
* user context.
*/
public function userContext() {
return 'civicrm/api';
}
/**
* AJAX callback to fetch examples.
*/
public static function getExampleFile() {
if (!empty($_GET['entity']) && strpos($_GET['entity'], '.') === FALSE) {
$examples = array();
foreach (scandir(\Civi::paths()->getPath("[civicrm.root]/api/v3/examples/{$_GET['entity']}")) as $item) {
$item = str_replace('.php', '', $item);
if ($item && strpos($item, '.') === FALSE) {
$examples[] = array('key' => $item, 'value' => $item);
}
}
CRM_Utils_JSON::output($examples);
}
if (!empty($_GET['file']) && strpos($_GET['file'], '.') === FALSE) {
$fileName = \Civi::paths()->getPath("[civicrm.root]/api/v3/examples/{$_GET['file']}.php");
if (file_exists($fileName)) {
echo file_get_contents($fileName);
}
else {
echo "Not found.";
}
CRM_Utils_System::civiExit();
}
CRM_Utils_System::permissionDenied();
}
/**
* Ajax callback to display code docs.
*/
public static function getDoc() {
// Verify the API handler we're talking to is valid.
$entities = civicrm_api3('Entity', 'get');
$entity = CRM_Utils_Array::value('entity', $_GET);
if (!empty($entity) && in_array($entity, $entities['values']) && strpos($entity, '.') === FALSE) {
$action = CRM_Utils_Array::value('action', $_GET);
$doc = self::getDocblock($entity, $action);
$result = array(
'doc' => $doc ? self::formatDocBlock($doc[0]) : 'Not found.',
'code' => $doc ? $doc[1] : NULL,
'file' => $doc ? $doc[2] : NULL,
);
if (!$action) {
$actions = civicrm_api3($entity, 'getactions');
$result['actions'] = CRM_Utils_Array::makeNonAssociative(array_combine($actions['values'], $actions['values']));
}
CRM_Utils_JSON::output($result);
}
CRM_Utils_System::permissionDenied();
}
/**
* Get documentation block.
*
* @param string $entity
* @param string|null $action
* @return array|bool
* [docblock, code]
*/
private static function getDocBlock($entity, $action) {
if (!$entity) {
return FALSE;
}
$file = "api/v3/$entity.php";
$contents = file_get_contents($file, FILE_USE_INCLUDE_PATH);
if (!$contents) {
// Api does not exist
return FALSE;
}
$docblock = $code = array();
// Fetch docblock for the api file
if (!$action) {
if (preg_match('#/\*\*\n.*?\n \*/\n#s', $contents, $docblock)) {
return array($docblock[0], NULL, $file);
}
}
// Fetch block for a specific action
else {
$action = strtolower($action);
$fnName = 'civicrm_api3_' . _civicrm_api_get_entity_name_from_camel($entity) . '_' . $action;
// Support the alternate "1 file per action" structure
$actionFile = "api/v3/$entity/" . ucfirst($action) . '.php';
$actionFileContents = file_get_contents("api/v3/$entity/" . ucfirst($action) . '.php', FILE_USE_INCLUDE_PATH);
if ($actionFileContents) {
$file = $actionFile;
$contents = $actionFileContents;
}
// If action isn't in this file, try generic
if (strpos($contents, "function $fnName") === FALSE) {
$fnName = "civicrm_api3_generic_$action";
$file = "api/v3/Generic/" . ucfirst($action) . '.php';
$contents = file_get_contents($file, FILE_USE_INCLUDE_PATH);
if (!$contents) {
$file = "api/v3/Generic.php";
$contents = file_get_contents($file, FILE_USE_INCLUDE_PATH);
}
}
if (preg_match('#(/\*\*(\n \*.*)*\n \*/\n)function[ ]+' . $fnName . '#i', $contents, $docblock)) {
// Fetch the code in a separate regex to preserve sanity
preg_match("#^function[ ]+$fnName.*?^}#ism", $contents, $code);
return array($docblock[1], $code[0], $file);
}
}
}
/**
* Format a docblock to be a bit more readable
* Not a proper doc parser... patches welcome :)
*
* @param string $text
* @return string
*/
public static function formatDocBlock($text) {
// Normalize #leading spaces.
$lines = explode("\n", $text);
$lines = preg_replace('/^ +\*/', ' *', $lines);
$text = implode("\n", $lines);
// Get rid of comment stars
$text = str_replace(array("\n * ", "\n *\n", "\n */\n", "/**\n"), array("\n", "\n\n", '', ''), $text);
// Format for html
$text = htmlspecialchars($text);
// Extract code blocks - save for later to skip html conversion
$code = array();
preg_match_all('#@code(.*?)@endcode#is', $text, $code);
$text = preg_replace('#@code.*?@endcode#is', '<pre></pre>', $text);
// Convert @annotations to titles
$text = preg_replace_callback(
'#^[ ]*@(\w+)([ ]*)#m',
function($matches) {
return "<strong>" . ucfirst($matches[1]) . "</strong>" . (empty($matches[2]) ? '' : ': ');
},
$text);
// Preserve indentation
$text = str_replace("\n ", "\n&nbsp;&nbsp;&nbsp;&nbsp;", $text);
// Convert newlines
$text = nl2br($text);
// Add unformatted code blocks back in
if ($code && !empty($code[1])) {
foreach ($code[1] as $block) {
$text = preg_replace('#<pre></pre>#', "<pre>$block</pre>", $text, 1);
}
}
return $text;
}
}

View file

@ -0,0 +1,82 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Dashboard page for managing Access Control.
*
* For initial version, this page only contains static links - so this class is empty for now.
*/
class CRM_Admin_Page_Access extends CRM_Core_Page {
/**
* @return string
*/
public function run() {
$config = CRM_Core_Config::singleton();
switch ($config->userFramework) {
case 'Drupal':
$this->assign('ufAccessURL', url('admin/people/permissions'));
break;
case 'Drupal6':
$this->assign('ufAccessURL', url('admin/user/permissions'));
break;
case 'Joomla':
//condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value
if (version_compare(JVERSION, '3.0', 'lt')) {
JHTML::_('behavior.modal');
$url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component';
$jparams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"';
$this->assign('ufAccessURL', $url);
$this->assign('jAccessParams', $jparams);
}
else {
$uri = (string) JUri::getInstance();
$return = urlencode(base64_encode($uri));
$url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return;
$this->assign('ufAccessURL', $url);
$this->assign('jAccessParams', '');
}
break;
case 'WordPress':
$this->assign('ufAccessURL', CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1'));
break;
}
return parent::run();
}
}

View file

@ -0,0 +1,112 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying Administer CiviCRM Control Panel.
*/
class CRM_Admin_Page_Admin extends CRM_Core_Page {
/**
* Run page.
*
* @return string
*/
public function run() {
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
$this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
$groups = array(
'Customize Data and Screens' => ts('Customize Data and Screens'),
'Communications' => ts('Communications'),
'Localization' => ts('Localization'),
'Users and Permissions' => ts('Users and Permissions'),
'System Settings' => ts('System Settings'),
);
$config = CRM_Core_Config::singleton();
if (in_array('CiviContribute', $config->enableComponents)) {
$groups['CiviContribute'] = ts('CiviContribute');
}
if (in_array('CiviMember', $config->enableComponents)) {
$groups['CiviMember'] = ts('CiviMember');
}
if (in_array('CiviEvent', $config->enableComponents)) {
$groups['CiviEvent'] = ts('CiviEvent');
}
if (in_array('CiviMail', $config->enableComponents)) {
$groups['CiviMail'] = ts('CiviMail');
}
if (in_array('CiviCase', $config->enableComponents)) {
$groups['CiviCase'] = ts('CiviCase');
}
if (in_array('CiviReport', $config->enableComponents)) {
$groups['CiviReport'] = ts('CiviReport');
}
if (in_array('CiviCampaign', $config->enableComponents)) {
$groups['CiviCampaign'] = ts('CiviCampaign');
}
$values = CRM_Core_Menu::getAdminLinks();
$this->_showHide = new CRM_Core_ShowHideBlocks();
foreach ($groups as $group => $title) {
$groupId = str_replace(' ', '_', $group);
$this->_showHide->addShow("id_{$groupId}_show");
$this->_showHide->addHide("id_{$groupId}");
$v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
if (isset($values[$group])) {
$adminPanel[$groupId] = $values[$group];
$adminPanel[$groupId]['show'] = $v['show'];
$adminPanel[$groupId]['hide'] = $v['hide'];
$adminPanel[$groupId]['title'] = $title;
}
else {
$adminPanel[$groupId] = array();
$adminPanel[$groupId]['show'] = '';
$adminPanel[$groupId]['hide'] = '';
$adminPanel[$groupId]['title'] = $title;
}
}
$this->assign('adminPanel', $adminPanel);
$this->_showHide->addToTemplate();
return parent::run();
}
}

View file

@ -0,0 +1,290 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for configuring CKEditor options.
*
* Note that while this is implemented as a CRM_Core_Page, it is actually a form.
* Because the form needs to be submitted and refreshed via javascript, it seemed like
* Quickform and CRM_Core_Form/Controller might get in the way.
*/
class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
const CONFIG_FILEPATH = '[civicrm.files]/persist/crm-ckeditor-';
/**
* Settings that cannot be configured in "advanced options"
*
* @var array
*/
public $blackList = array(
'on',
'skin',
'extraPlugins',
'toolbarGroups',
'removeButtons',
'filebrowserBrowseUrl',
'filebrowserImageBrowseUrl',
'filebrowserFlashBrowseUrl',
'filebrowserUploadUrl',
'filebrowserImageUploadUrl',
'filebrowserFlashUploadUrl',
);
public $preset;
/**
* Run page.
*
* @return string
*/
public function run() {
$this->preset = CRM_Utils_Array::value('preset', $_REQUEST, 'default');
// If the form was submitted, take appropriate action.
if (!empty($_POST['revert'])) {
self::deleteConfigFile($this->preset);
self::setConfigDefault();
}
elseif (!empty($_POST['config'])) {
$this->save($_POST);
}
$settings = $this->getConfigSettings();
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'bower_components/ckeditor/ckeditor.js', 0, 'page-header')
->addScriptFile('civicrm', 'bower_components/ckeditor/samples/toolbarconfigurator/js/fulltoolbareditor.js', 1)
->addScriptFile('civicrm', 'bower_components/ckeditor/samples/toolbarconfigurator/js/abstracttoolbarmodifier.js', 2)
->addScriptFile('civicrm', 'bower_components/ckeditor/samples/toolbarconfigurator/js/toolbarmodifier.js', 3)
->addScriptFile('civicrm', 'js/wysiwyg/admin.ckeditor-configurator.js', 10)
->addStyleFile('civicrm', 'bower_components/ckeditor/samples/toolbarconfigurator/css/fontello.css')
->addStyleFile('civicrm', 'bower_components/ckeditor/samples/css/samples.css')
->addVars('ckConfig', array(
'plugins' => array_values($this->getCKPlugins()),
'blacklist' => $this->blackList,
'settings' => $settings,
));
$configUrl = self::getConfigUrl($this->preset);
if (!$configUrl) {
$configUrl = self::getConfigUrl('default');
}
$this->assign('preset', $this->preset);
$this->assign('presets', CRM_Core_OptionGroup::values('wysiwyg_presets', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name'));
$this->assign('skins', $this->getCKSkins());
$this->assign('skin', CRM_Utils_Array::value('skin', $settings));
$this->assign('extraPlugins', CRM_Utils_Array::value('extraPlugins', $settings));
$this->assign('configUrl', $configUrl);
$this->assign('revertConfirm', htmlspecialchars(ts('Are you sure you want to revert all changes?', array('escape' => 'js'))));
CRM_Utils_System::appendBreadCrumb(array(array(
'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'),
'title' => ts('Display Preferences'),
)));
return parent::run();
}
/**
* Generate the config js file based on posted data.
*
* @param array $params
*/
public function save($params) {
$config = self::fileHeader()
// Standardize line-endings
. preg_replace('~\R~u', "\n", $params['config']);
// Use all params starting with config_
foreach ($params as $key => $val) {
$val = trim($val);
if (strpos($key, 'config_') === 0 && strlen($val)) {
if ($val != 'true' && $val != 'false' && $val != 'null' && $val[0] != '{' && $val[0] != '[' && !is_numeric($val)) {
$val = json_encode($val);
}
$pos = strrpos($config, '};');
$key = preg_replace('/^config_/', 'config.', $key);
$setting = "\n\t{$key} = {$val};\n";
$config = substr_replace($config, $setting, $pos, 0);
}
}
self::saveConfigFile($this->preset, $config);
if (!empty($params['save'])) {
CRM_Core_Session::setStatus(ts("You may need to clear your browser's cache to see the changes in CiviCRM."), ts('CKEditor Saved'), 'success');
}
}
/**
* Get available CKEditor plugin list.
*
* @return array
*/
private function getCKPlugins() {
$plugins = array();
$pluginDir = Civi::paths()->getPath('[civicrm.root]/bower_components/ckeditor/plugins');
foreach (glob($pluginDir . '/*', GLOB_ONLYDIR) as $dir) {
$dir = rtrim(str_replace('\\', '/', $dir), '/');
$name = substr($dir, strrpos($dir, '/') + 1);
$dir = CRM_Utils_file::addTrailingSlash($dir, '/');
if (is_file($dir . 'plugin.js')) {
$plugins[$name] = array(
'id' => $name,
'text' => ucfirst($name),
'icon' => NULL,
);
if (is_dir($dir . "icons")) {
if (is_file($dir . "icons/$name.png")) {
$plugins[$name]['icon'] = "bower_components/ckeditor/plugins/$name/icons/$name.png";
}
elseif (glob($dir . "icons/*.png")) {
$icon = CRM_Utils_Array::first(glob($dir . "icons/*.png"));
$icon = rtrim(str_replace('\\', '/', $icon), '/');
$plugins[$name]['icon'] = "bower_components/ckeditor/plugins/$name/icons/" . substr($icon, strrpos($icon, '/') + 1);
}
}
}
}
return $plugins;
}
/**
* Get available CKEditor skins.
*
* @return array
*/
private function getCKSkins() {
$skins = array();
$skinDir = Civi::paths()->getPath('[civicrm.root]/bower_components/ckeditor/skins');
foreach (glob($skinDir . '/*', GLOB_ONLYDIR) as $dir) {
$dir = rtrim(str_replace('\\', '/', $dir), '/');
$skins[] = substr($dir, strrpos($dir, '/') + 1);
}
return $skins;
}
/**
* @return array
*/
private function getConfigSettings() {
$matches = $result = array();
$file = self::getConfigFile($this->preset);
if (!$file) {
$file = self::getConfigFile('default');
}
$result['skin'] = 'moono';
if ($file) {
$contents = file_get_contents($file);
preg_match_all("/\sconfig\.(\w+)\s?=\s?([^;]*);/", $contents, $matches);
foreach ($matches[1] as $i => $match) {
$result[$match] = trim($matches[2][$i], ' "\'');
}
}
return $result;
}
/**
* @param string $preset
* Omit to get an array of all presets
* @return array|null|string
*/
public static function getConfigUrl($preset = NULL) {
$items = array();
$presets = CRM_Core_OptionGroup::values('wysiwyg_presets', FALSE, FALSE, FALSE, NULL, 'name');
foreach ($presets as $key => $name) {
if (self::getConfigFile($name)) {
$items[$name] = Civi::paths()->getUrl(self::CONFIG_FILEPATH . $name . '.js', 'absolute');
}
}
return $preset ? CRM_Utils_Array::value($preset, $items) : $items;
}
/**
* @param string $preset
*
* @return null|string
*/
public static function getConfigFile($preset = 'default') {
$fileName = Civi::paths()->getPath(self::CONFIG_FILEPATH . $preset . '.js');
return is_file($fileName) ? $fileName : NULL;
}
/**
* @param string $contents
*/
public static function saveConfigFile($preset, $contents) {
$file = Civi::paths()->getPath(self::CONFIG_FILEPATH . $preset . '.js');
file_put_contents($file, $contents);
}
/**
* Delete config file.
*/
public static function deleteConfigFile($preset) {
$file = self::getConfigFile($preset);
if ($file) {
unlink($file);
}
}
/**
* Create default config file if it doesn't exist
*/
public static function setConfigDefault() {
if (!self::getConfigFile()) {
$config = self::fileHeader() . "CKEDITOR.editorConfig = function( config ) {\n\tconfig.allowedContent = true;\n};\n";
// Make sure directories exist
if (!is_dir(Civi::paths()->getPath('[civicrm.files]/persist'))) {
mkdir(Civi::paths()->getPath('[civicrm.files]/persist'));
}
$newFileName = Civi::paths()->getPath('[civicrm.files]/persist/crm-ckeditor-default.js');
file_put_contents($newFileName, $config);
}
}
/**
* @return string
*/
public static function fileHeader() {
return "/**\n"
. " * CKEditor config file auto-generated by CiviCRM (" . date('Y-m-d H:i:s') . ").\n"
. " *\n"
. " * Note: This file will be overwritten if settings are modified at:\n"
. " * @link " . CRM_Utils_System::url('civicrm/admin/ckeditor', NULL, TRUE, NULL, FALSE) . "\n"
. " */\n";
}
}

View file

@ -0,0 +1,62 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of site configuration tasks with links to each setting form.
*/
class CRM_Admin_Page_ConfigTaskList extends CRM_Core_Page {
/**
* Run page.
*
* @return string
*/
public function run() {
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
CRM_Utils_System::setTitle(ts("Configuration Checklist"));
$this->assign('recentlyViewed', FALSE);
$destination = CRM_Utils_System::url('civicrm/admin/configtask',
'reset=1',
FALSE, NULL, FALSE
);
$destination = urlencode($destination);
$this->assign('destination', $destination);
$this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
return parent::run();
}
}

View file

@ -0,0 +1,170 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of contact Subtypes.
*/
class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Contact_BAO_ContactType';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/options/subtype',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Contact Type'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Contact Type'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Contact Type'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/options/subtype',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Contact Type'),
),
);
}
return self::$_links;
}
/**
* Run page.
*/
public function run() {
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
$this->assign('action', $action);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
if (!$action) {
$this->browse();
}
return parent::run();
}
/**
* Browse contact types.
*/
public function browse() {
$rows = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE);
foreach ($rows as $key => $value) {
$mask = NULL;
if (!empty($value['is_reserved'])) {
$mask = CRM_Core_Action::UPDATE;
}
else {
$mask -= CRM_Core_Action::DELETE - 2;
if (!empty($value['is_active'])) {
$mask -= CRM_Core_Action::ENABLE;
}
else {
$mask -= CRM_Core_Action::DISABLE;
}
}
$rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask,
array('id' => $value['id']),
ts('more'),
FALSE,
'contactType.manage.action',
'ContactType',
$value['id']
);
}
$this->assign('rows', $rows);
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_ContactType';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Contact Types';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/options/subtype';
}
}

View file

@ -0,0 +1,171 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of event templates.
*/
class CRM_Admin_Page_EventTemplate extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Event_BAO_Event';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
// helper variable for nicer formatting
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/event/manage/settings',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Event Template'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/event/manage',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Event Template'),
),
);
}
return self::$_links;
}
/**
* Browse all event templates.
*/
public function browse() {
//get all event templates.
$allEventTemplates = array();
$eventTemplate = new CRM_Event_DAO_Event();
$eventTypes = CRM_Event_PseudoConstant::eventType();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$participantListings = CRM_Event_PseudoConstant::participantListing();
//find all event templates.
$eventTemplate->is_template = TRUE;
$eventTemplate->find();
while ($eventTemplate->fetch()) {
CRM_Core_DAO::storeValues($eventTemplate, $allEventTemplates[$eventTemplate->id]);
//get listing types.
if ($eventTemplate->participant_listing_id) {
$allEventTemplates[$eventTemplate->id]['participant_listing'] = $participantListings[$eventTemplate->participant_listing_id];
}
//get participant role
if ($eventTemplate->default_role_id) {
$allEventTemplates[$eventTemplate->id]['participant_role'] = $participantRoles[$eventTemplate->default_role_id];
}
//get event type.
if (isset($eventTypes[$eventTemplate->event_type_id])) {
$allEventTemplates[$eventTemplate->id]['event_type'] = $eventTypes[$eventTemplate->event_type_id];
}
//form all action links
$action = array_sum(array_keys($this->links()));
//add action links.
$allEventTemplates[$eventTemplate->id]['action'] = CRM_Core_Action::formLink(self::links(), $action,
array('id' => $eventTemplate->id),
ts('more'),
FALSE,
'eventTemplate.manage.action',
'Event',
$eventTemplate->id
);
}
$this->assign('rows', $allEventTemplates);
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(),
'reset=1&action=browse'
));
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_EventTemplate';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Event Templates';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/eventTemplate';
}
}

View file

@ -0,0 +1,328 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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 is a part of CiviCRM extension management functionality.
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This page displays the list of extensions registered in the system.
*/
class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Obtains the group name from url and sets the title.
*/
public function preProcess() {
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
CRM_Utils_System::setTitle(ts('CiviCRM Extensions'));
$destination = CRM_Utils_System::url('civicrm/admin/extensions',
'reset=1');
$destination = urlencode($destination);
$this->assign('destination', $destination);
}
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_Extension';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::ADD => array(
'name' => ts('Install'),
'url' => 'civicrm/admin/extensions',
'qs' => 'action=add&id=%%id%%&key=%%key%%',
'title' => ts('Install'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'url' => 'civicrm/admin/extensions',
'qs' => 'action=enable&id=%%id%%&key=%%key%%',
'ref' => 'enable-action',
'title' => ts('Enable'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'url' => 'civicrm/admin/extensions',
'qs' => 'action=disable&id=%%id%%&key=%%key%%',
'title' => ts('Disable'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Uninstall'),
'url' => 'civicrm/admin/extensions',
'qs' => 'action=delete&id=%%id%%&key=%%key%%',
'title' => ts('Uninstall Extension'),
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Download'),
'url' => 'civicrm/admin/extensions',
'qs' => 'action=update&id=%%id%%&key=%%key%%',
'title' => ts('Download Extension'),
),
);
}
return self::$_links;
}
/**
* Run the basic page (run essentially starts execution for that page).
*/
public function run() {
$this->preProcess();
return parent::run();
}
/**
* Browse all options.
*/
public function browse() {
// build announcements at the top of the page
$this->assign('extAddNewEnabled', CRM_Extension_System::singleton()->getBrowser()->isEnabled());
$reqs = CRM_Extension_System::singleton()->getDownloader()->checkRequirements();
if (empty($reqs)) {
$reqs = CRM_Extension_System::singleton()->getBrowser()->checkRequirements();
}
if (empty($reqs)) {
$reqs = CRM_Extension_System::singleton()->getDefaultContainer()->checkRequirements();
}
$this->assign('extAddNewReqs', $reqs);
$this->assign('extDbUpgrades', CRM_Extension_Upgrades::hasPending());
$this->assign('extDbUpgradeUrl', CRM_Utils_System::url('civicrm/admin/extensions/upgrade', 'reset=1'));
// TODO: Debate whether to immediately detect changes in underlying source tree
// $manager->refresh();
$localExtensionRows = $this->formatLocalExtensionRows();
$this->assign('localExtensionRows', $localExtensionRows);
$remoteExtensionRows = $this->formatRemoteExtensionRows($localExtensionRows);
$this->assign('remoteExtensionRows', $remoteExtensionRows);
}
/**
* Get the list of local extensions and format them as a table with
* status and action data.
*
* @return array
*/
public function formatLocalExtensionRows() {
$mapper = CRM_Extension_System::singleton()->getMapper();
$manager = CRM_Extension_System::singleton()->getManager();
$localExtensionRows = array(); // array($pseudo_id => extended_CRM_Extension_Info)
$keys = array_keys($manager->getStatuses());
sort($keys);
foreach ($keys as $key) {
try {
$obj = $mapper->keyToInfo($key);
}
catch (CRM_Extension_Exception $ex) {
CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key)));
continue;
}
$row = self::createExtendedInfo($obj);
$row['id'] = $obj->key;
// assign actions
$action = 0;
switch ($row['status']) {
case CRM_Extension_Manager::STATUS_UNINSTALLED:
$action += CRM_Core_Action::ADD;
break;
case CRM_Extension_Manager::STATUS_DISABLED:
$action += CRM_Core_Action::ENABLE;
$action += CRM_Core_Action::DELETE;
break;
case CRM_Extension_Manager::STATUS_DISABLED_MISSING:
$action += CRM_Core_Action::DELETE;
break;
case CRM_Extension_Manager::STATUS_INSTALLED:
case CRM_Extension_Manager::STATUS_INSTALLED_MISSING:
$action += CRM_Core_Action::DISABLE;
break;
default:
}
// TODO if extbrowser is enabled and extbrowser has newer version than extcontainer,
// then $action += CRM_Core_Action::UPDATE
$row['action'] = CRM_Core_Action::formLink(self::links(),
$action,
array(
'id' => $row['id'],
'key' => $obj->key,
),
ts('more'),
FALSE,
'extension.local.action',
'Extension',
$row['id']
);
// Key would be better to send, but it's not an integer. Moreover, sending the
// values to hook_civicrm_links means that you can still get at the key
$localExtensionRows[$row['id']] = $row;
}
return $localExtensionRows;
}
/**
* Get the list of local extensions and format them as a table with
* status and action data.
*
* @param array $localExtensionRows
* @return array
*/
public function formatRemoteExtensionRows($localExtensionRows) {
try {
$remoteExtensions = CRM_Extension_System::singleton()->getBrowser()->getExtensions();
}
catch (CRM_Extension_Exception $e) {
$remoteExtensions = array();
CRM_Core_Session::setStatus($e->getMessage(), ts('Extension download error'), 'error');
}
// build list of available downloads
$remoteExtensionRows = array();
foreach ($remoteExtensions as $info) {
$row = (array) $info;
$row['id'] = $info->key;
$action = CRM_Core_Action::UPDATE;
$row['action'] = CRM_Core_Action::formLink(self::links(),
$action,
array(
'id' => $row['id'],
'key' => $row['key'],
),
ts('more'),
FALSE,
'extension.remote.action',
'Extension',
$row['id']
);
if (isset($localExtensionRows[$info->key])) {
if (array_key_exists('version', $localExtensionRows[$info->key])) {
if (version_compare($localExtensionRows[$info->key]['version'], $info->version, '<')) {
$row['is_upgradeable'] = TRUE;
}
}
}
$remoteExtensionRows[$row['id']] = $row;
}
return $remoteExtensionRows;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_Extensions';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'CRM_Admin_Form_Extensions';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/extensions';
}
/**
* Get userContext params.
*
* @param int $mode
* Mode that we are in.
*
* @return string
*/
public function userContextParams($mode = NULL) {
return 'reset=1&action=browse';
}
/**
* Take an extension's raw XML info and add information about the
* extension's status on the local system.
*
* The result format resembles the old CRM_Core_Extensions_Extension.
*
* @param CRM_Extension_Info $obj
*
* @return array
*/
public static function createExtendedInfo(CRM_Extension_Info $obj) {
return CRM_Extension_System::createExtendedInfo($obj);
}
}

View file

@ -0,0 +1,39 @@
<?php
require_once 'CRM/Core/Page.php';
/**
* Display a page which displays a progress bar while executing
* upgrade tasks.
*/
class CRM_Admin_Page_ExtensionsUpgrade extends CRM_Core_Page {
const END_URL = 'civicrm/admin/extensions';
const END_PARAMS = 'reset=1';
/**
* Run Page.
*/
public function run() {
$queue = CRM_Extension_Upgrades::createQueue();
$runner = new CRM_Queue_Runner(array(
'title' => ts('Database Upgrades'),
'queue' => $queue,
'errorMode' => CRM_Queue_Runner::ERROR_ABORT,
'onEnd' => array('CRM_Admin_Page_ExtensionsUpgrade', 'onEnd'),
'onEndUrl' => !empty($_GET['destination']) ? $_GET['destination'] : CRM_Utils_System::url(self::END_URL, self::END_PARAMS),
));
CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Start upgrades');
$runner->runAllViaWeb(); // does not return
}
/**
* Handle the final step of the queue.
*
* @param \CRM_Queue_TaskContext $ctx
*/
public static function onEnd(CRM_Queue_TaskContext $ctx) {
CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Finish upgrades');
}
}

View file

@ -0,0 +1,221 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of jobs.
*/
class CRM_Admin_Page_Job extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_Job';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::FOLLOWUP => array(
'name' => ts('View Job Log'),
'url' => 'civicrm/admin/joblog',
'qs' => 'jid=%%id%%&reset=1',
'title' => ts('See log entries for this Scheduled Job'),
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/job',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Scheduled Job'),
),
CRM_Core_Action::EXPORT => array(
'name' => ts('Execute Now'),
'url' => 'civicrm/admin/job',
'qs' => 'action=export&id=%%id%%&reset=1',
'title' => ts('Execute Scheduled Job Now'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Scheduled Job'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Scheduled Job'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/job',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Scheduled Job'),
),
);
}
return self::$_links;
}
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*/
public function run() {
// set title and breadcrumb
CRM_Utils_System::setTitle(ts('Settings - Scheduled Jobs'));
$breadCrumb = array(
array(
'title' => ts('Scheduled Jobs'),
'url' => CRM_Utils_System::url('civicrm/admin',
'reset=1'
),
),
);
CRM_Utils_System::appendBreadCrumb($breadCrumb);
$this->_id = CRM_Utils_Request::retrieve('id', 'String',
$this, FALSE, 0
);
$this->_action = CRM_Utils_Request::retrieve('action', 'String',
$this, FALSE, 0
);
if ($this->_action == 'export') {
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin/job', 'reset=1'));
}
return parent::run();
}
/**
* Browse all jobs.
*
* @param null $action
*/
public function browse($action = NULL) {
// check if non-prod mode is enabled.
if (CRM_Core_Config::environment() != 'Production') {
CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter.'), ts("Non-production Environment"), "warning", array('expires' => 0));
}
// using Export action for Execute. Doh.
if ($this->_action & CRM_Core_Action::EXPORT) {
$jm = new CRM_Core_JobManager();
$jm->executeJobById($this->_id);
CRM_Core_Session::setStatus(ts('Selected Scheduled Job has been executed. See the log for details.'), ts("Executed"), "success");
}
$sj = new CRM_Core_JobManager();
$rows = $temp = array();
foreach ($sj->jobs as $job) {
$action = array_sum(array_keys($this->links()));
// update enable/disable links.
// CRM-9868- remove enable action for jobs that should never be run automatically via execute action or runjobs url
if ($job->api_action == 'process_membership_reminder_date' || $job->api_action == 'update_greeting') {
$action -= CRM_Core_Action::ENABLE;
$action -= CRM_Core_Action::DISABLE;
}
elseif ($job->is_active) {
$action -= CRM_Core_Action::ENABLE;
}
else {
$action -= CRM_Core_Action::DISABLE;
}
$job->action = CRM_Core_Action::formLink(self::links(), $action,
array('id' => $job->id),
ts('more'),
FALSE,
'job.manage.action',
'Job',
$job->id
);
$rows[] = get_object_vars($job);
}
$this->assign('rows', $rows);
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_Job';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Scheduled Jobs';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/job';
}
}

View file

@ -0,0 +1,160 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of jobs.
*/
class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_Job';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
return self::$_links;
}
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*/
public function run() {
// set title and breadcrumb
CRM_Utils_System::setTitle(ts('Settings - Scheduled Jobs Log'));
$breadCrumb = array(
array(
'title' => ts('Administration'),
'url' => CRM_Utils_System::url('civicrm/admin',
'reset=1'
),
),
);
CRM_Utils_System::appendBreadCrumb($breadCrumb);
return parent::run();
}
/**
* Browse all jobs.
*
* @param null $action
*/
public function browse($action = NULL) {
$jid = CRM_Utils_Request::retrieve('jid', 'Positive', $this);
$sj = new CRM_Core_JobManager();
$jobName = NULL;
if ($jid) {
$jobName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $jid);
}
$this->assign('jobName', $jobName);
$dao = new CRM_Core_DAO_JobLog();
$dao->orderBy('id desc');
// limit to last 1000 records
$dao->limit(1000);
if ($jid) {
$dao->job_id = $jid;
}
$dao->find();
$rows = array();
while ($dao->fetch()) {
unset($row);
CRM_Core_DAO::storeValues($dao, $row);
$rows[$dao->id] = $row;
}
$this->assign('rows', $rows);
$this->assign('jobId', $jid);
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_Job';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Scheduled Jobs';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/job';
}
}

View file

@ -0,0 +1,167 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright (C) 2011 Marty Wright |
| Licensed to CiviCRM under the Academic Free License version 3.0. |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of Label Formats.
*/
class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_LabelFormat';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
// helper variable for nicer formatting
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/labelFormats',
'qs' => 'action=update&id=%%id%%&group=%%group%%&reset=1',
'title' => ts('Edit Label Format'),
),
CRM_Core_Action::COPY => array(
'name' => ts('Copy'),
'url' => 'civicrm/admin/labelFormats',
'qs' => 'action=copy&id=%%id%%&group=%%group%%&reset=1',
'title' => ts('Copy Label Format'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/labelFormats',
'qs' => 'action=delete&id=%%id%%&group=%%group%%&reset=1',
'title' => ts('Delete Label Format'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_LabelFormats';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Mailing Label Formats';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/labelFormats';
}
/**
* Browse all Label Format settings.
*
* @param null $action
*/
public function browse($action = NULL) {
// Get list of configured Label Formats
$labelFormatList = CRM_Core_BAO_LabelFormat::getList();
$nameFormatList = CRM_Core_BAO_LabelFormat::getList(FALSE, 'name_badge');
// Add action links to each of the Label Formats
foreach ($labelFormatList as & $format) {
$action = array_sum(array_keys($this->links()));
if (!empty($format['is_reserved'])) {
$action -= CRM_Core_Action::DELETE;
}
$format['groupName'] = ts('Mailing Label');
$format['action'] = CRM_Core_Action::formLink(self::links(), $action,
array('id' => $format['id'], 'group' => 'label_format'),
ts('more'),
FALSE,
'labelFormat.manage.action',
'LabelFormat',
$format['id']
);
}
// Add action links to each of the Label Formats
foreach ($nameFormatList as & $format) {
$format['groupName'] = ts('Name Badge');
}
$labelFormatList = array_merge($labelFormatList, $nameFormatList);
// Order Label Formats by weight
$returnURL = CRM_Utils_System::url(self::userContext());
CRM_Core_BAO_LabelFormat::addOrder($labelFormatList, $returnURL);
$this->assign('rows', $labelFormatList);
}
}

View file

@ -0,0 +1,126 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of location types.
*/
class CRM_Admin_Page_LocationType extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_LocationType';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/locationType',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Location Type'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Location Type'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Location Type'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/locationType',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Location Type'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_LocationType';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Location Types';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/locationType';
}
}

View file

@ -0,0 +1,160 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of Mail account settings.
*/
class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_MailSettings';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
// helper variable for nicer formatting
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/mailSettings',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Mail Settings'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/mailSettings',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Mail Settings'),
),
);
}
return self::$_links;
}
/**
* Browse all mail settings.
*/
public function browse() {
//get all mail settings.
$allMailSettings = array();
$mailSetting = new CRM_Core_DAO_MailSettings();
$allProtocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol');
//multi-domain support for mail settings. CRM-5244
$mailSetting->domain_id = CRM_Core_Config::domainID();
//find all mail settings.
$mailSetting->find();
while ($mailSetting->fetch()) {
//replace protocol value with name
$mailSetting->protocol = CRM_Utils_Array::value($mailSetting->protocol, $allProtocols);
CRM_Core_DAO::storeValues($mailSetting, $allMailSettings[$mailSetting->id]);
//form all action links
$action = array_sum(array_keys($this->links()));
// disallow the DELETE action for the default set of settings
if ($mailSetting->is_default) {
$action &= ~CRM_Core_Action::DELETE;
}
//add action links.
$allMailSettings[$mailSetting->id]['action'] = CRM_Core_Action::formLink(self::links(), $action,
array('id' => $mailSetting->id),
ts('more'),
FALSE,
'mailSetting.manage.action',
'MailSetting',
$mailSetting->id
);
}
$this->assign('rows', $allMailSettings);
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_MailSettings';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Mail Settings';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/mailSettings';
}
}

View file

@ -0,0 +1,146 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of categories.
*/
class CRM_Admin_Page_Mapping extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_Mapping';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
// helper variable for nicer formatting
$deleteExtra = ts('Are you sure you want to delete this mapping?') . ' ' . ts('This operation cannot be undone.');
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/mapping',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Mapping'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/mapping',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Mapping'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_Mapping';
}
/**
* Get form name for edit form.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Mapping';
}
/**
* Get form name for delete form.
*
* @return string
* name of this page.
*/
public function deleteName() {
return 'Mapping';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/mapping';
}
/**
* Get name of delete form.
*
* @return string
* Classname of delete form.
*/
public function deleteForm() {
return 'CRM_Admin_Form_Mapping';
}
/**
* Run the basic page.
*/
public function run() {
$sort = 'mapping_type asc';
return parent::run($sort);
}
}

View file

@ -0,0 +1,294 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of message templates.
*/
class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
// ids of templates which diverted from the default ones and can be reverted
protected $_revertible = array();
// set to the id that were reverting at the given moment (if we are)
protected $_revertedId;
/**
* @param null $title
* @param null $mode
*/
public function __construct($title = NULL, $mode = NULL) {
parent::__construct($title, $mode);
// fetch the ids of templates which diverted from defaults and can be reverted
// these templates have the same workflow_id as the defaults; defaults are reserved
$sql = '
SELECT diverted.id, orig.id orig_id
FROM civicrm_msg_template diverted JOIN civicrm_msg_template orig ON (
diverted.workflow_id = orig.workflow_id AND
orig.is_reserved = 1 AND (
diverted.msg_subject != orig.msg_subject OR
diverted.msg_text != orig.msg_text OR
diverted.msg_html != orig.msg_html
)
)
';
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$this->_revertible[$dao->id] = $dao->orig_id;
}
}
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_MessageTemplate';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
$confirm = ts('Are you sure you want to revert this template to the default for this workflow? You will lose any customizations you have made.', array('escape' => 'js')) . '\n\n' . ts('We recommend that you save a copy of the your customized Text and HTML message content to a text file before reverting so you can combine your changes with the system default messages as needed.', array('escape' => 'js'));
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/messageTemplates/add',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit this message template'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable this message template'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable this message template'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/messageTemplates',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete this message template'),
),
CRM_Core_Action::REVERT => array(
'name' => ts('Revert to Default'),
'extra' => "onclick = 'return confirm(\"$confirm\");'",
'url' => 'civicrm/admin/messageTemplates',
'qs' => 'action=revert&id=%%id%%&selectedChild=workflow',
'title' => ts('Revert this workflow message template to the system default'),
),
CRM_Core_Action::VIEW => array(
'name' => ts('View Default'),
'url' => 'civicrm/admin/messageTemplates',
'qs' => 'action=view&id=%%orig_id%%&reset=1',
'title' => ts('View the system default for this workflow message template'),
),
);
}
return self::$_links;
}
/**
* @param CRM_Core_DAO $object
* @param int $action
* @param array $values
* @param array $links
* @param string $permission
* @param bool $forceAction
*/
public function action(&$object, $action, &$values, &$links, $permission, $forceAction = FALSE) {
if ($object->workflow_id) {
// do not expose action link for reverting to default if the template did not diverge or we just reverted it now
if (!in_array($object->id, array_keys($this->_revertible)) or
($this->_action & CRM_Core_Action::REVERT and $object->id == $this->_revertedId)
) {
$action &= ~CRM_Core_Action::REVERT;
$action &= ~CRM_Core_Action::VIEW;
}
// default workflow templates shouldnt be deletable
// workflow templates shouldnt have disable/enable actions (at least for CiviCRM 3.1)
if ($object->workflow_id) {
$action &= ~CRM_Core_Action::DISABLE;
$action &= ~CRM_Core_Action::DELETE;
}
// rebuild the action links HTML, as we need to handle %%orig_id%% for revertible templates
$values['action'] = CRM_Core_Action::formLink($links, $action, array(
'id' => $object->id,
'orig_id' => CRM_Utils_Array::value($object->id, $this->_revertible),
),
ts('more'),
FALSE,
'messageTemplate.manage.action',
'MessageTemplate',
$object->id
);
}
else {
$action &= ~CRM_Core_Action::REVERT;
$action &= ~CRM_Core_Action::VIEW;
parent::action($object, $action, $values, $links, $permission);
}
}
/**
* @param null $args
* @param null $pageArgs
* @param null $sort
*
* @throws Exception
*/
public function run($args = NULL, $pageArgs = NULL, $sort = NULL) {
// handle the revert action and offload the rest to parent
if (CRM_Utils_Request::retrieve('action', 'String', $this) & CRM_Core_Action::REVERT) {
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (!$this->checkPermission($id, NULL)) {
CRM_Core_Error::fatal(ts('You do not have permission to revert this template.'));
}
$this->_revertedId = $id;
CRM_Core_BAO_MessageTemplate::revert($id);
}
$selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'String', $this);
if (in_array($selectedChild, array('user', 'workflow'))) {
$this->assign('selectedChild', $selectedChild);
}
return parent::run($args, $pageArgs, $sort);
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_MessageTemplates';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return ts('Message Template');
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/messageTemplates';
}
/**
* Browse all entities.
*/
public function browse() {
$action = func_num_args() ? func_get_arg(0) : NULL;
if ($this->_action & CRM_Core_Action::ADD) {
return;
}
$links = $this->links();
if ($action == NULL) {
if (!empty($links)) {
$action = array_sum(array_keys($links));
}
}
if ($action & CRM_Core_Action::DISABLE) {
$action -= CRM_Core_Action::DISABLE;
}
if ($action & CRM_Core_Action::ENABLE) {
$action -= CRM_Core_Action::ENABLE;
}
$messageTemplate = new CRM_Core_BAO_MessageTemplate();
$messageTemplate->orderBy('msg_title' . ' asc');
$userTemplates = array();
$workflowTemplates = array();
// find all objects
$messageTemplate->find();
while ($messageTemplate->fetch()) {
$values[$messageTemplate->id] = array();
CRM_Core_DAO::storeValues($messageTemplate, $values[$messageTemplate->id]);
// populate action links
$this->action($messageTemplate, $action, $values[$messageTemplate->id], $links, CRM_Core_Permission::EDIT);
if (!$messageTemplate->workflow_id) {
$userTemplates[$messageTemplate->id] = $values[$messageTemplate->id];
}
elseif (!$messageTemplate->is_reserved) {
$workflowTemplates[$messageTemplate->id] = $values[$messageTemplate->id];
}
}
$rows = array(
'userTemplates' => $userTemplates,
'workflowTemplates' => $workflowTemplates,
);
$this->assign('rows', $rows);
}
}

View file

@ -0,0 +1,112 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of location types.
*/
class CRM_Admin_Page_Navigation extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_Navigation';
}
/**
* Get action Links.
*
* @return array|NULL
* (reference) of action links
*/
public function &links() {
return NULL;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_Navigation';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'CiviCRM Navigation';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/menu';
}
/**
* Browse all menus.
*/
public function browse() {
// assign home id to the template
$homeMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Home', 'id', 'name');
$this->assign('homeMenuId', $homeMenuId);
// Add jstree support
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'bower_components/jstree/dist/jstree.min.js', 0, 'html-header')
->addStyleFile('civicrm', 'bower_components/jstree/dist/themes/default/style.min.css');
}
}

View file

@ -0,0 +1,286 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of Gender.
*/
class CRM_Admin_Page_Options extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* The option group name.
*
* @var array
*/
static $_gName = NULL;
/**
* The option group name in display format (capitalized, without underscores...etc)
*
* @var array
*/
static $_gLabel = NULL;
/**
* The option group id.
*
* @var array
*/
static $_gId = NULL;
/**
* A boolean determining if you can add options to this group in the GUI.
*
* @var boolean
*/
static $_isLocked = FALSE;
/**
* Obtains the group name from url string or id from $_GET['gid'].
*
* Sets the title.
*/
public function preProcess() {
if (!self::$_gName && !empty($this->urlPath[3])) {
self::$_gName = $this->urlPath[3];
}
// If an id arg is passed instead of a group name in the path
elseif (!self::$_gName && !empty($_GET['gid'])) {
self::$_gId = $_GET['gid'];
self::$_gName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gId, 'name');
self::$_isLocked = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gId, 'is_locked');
$breadCrumb = array(
'title' => ts('Option Groups'),
'url' => CRM_Utils_System::url('civicrm/admin/options', 'reset=1'),
);
CRM_Utils_System::appendBreadCrumb(array($breadCrumb));
}
if (!self::$_gName) {
self::$_gName = $this->get('gName');
}
// If we don't have a group we will browse all groups
if (!self::$_gName) {
return;
}
$this->set('gName', self::$_gName);
if (!self::$_gId) {
self::$_gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gName, 'id', 'name');
}
self::$_gLabel = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gId, 'title');
if (!self::$_gLabel) {
self::$_gLabel = ts('Option');
}
$this->assign('gName', self::$_gName);
$this->assign('gLabel', self::$_gLabel);
if (self::$_gName == 'acl_role') {
CRM_Utils_System::setTitle(ts('Manage ACL Roles'));
// set breadcrumb to append to admin/access
$breadCrumb = array(
array(
'title' => ts('Access Control'),
'url' => CRM_Utils_System::url('civicrm/admin/access',
'reset=1'
),
),
);
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
else {
CRM_Utils_System::setTitle(ts("%1 Options", array(1 => self::$_gLabel)));
}
if (in_array(self::$_gName,
array(
'from_email_address',
'email_greeting',
'postal_greeting',
'addressee',
'communication_style',
'case_status',
'encounter_medium',
'case_type',
'payment_instrument',
'soft_credit_type',
'website_type',
)
)) {
$this->assign('showIsDefault', TRUE);
}
if (self::$_gName == 'participant_role') {
$this->assign('showCounted', TRUE);
}
$this->assign('isLocked', self::$_isLocked);
$config = CRM_Core_Config::singleton();
if (self::$_gName == 'activity_type') {
$this->assign('showComponent', TRUE);
}
}
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return self::$_gName ? 'CRM_Core_BAO_OptionValue' : 'CRM_Core_BAO_OptionGroup';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/options/' . self::$_gName,
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit %1', array(1 => self::$_gName)),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable %1', array(1 => self::$_gName)),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable %1', array(1 => self::$_gName)),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/options/' . self::$_gName,
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete %1 Type', array(1 => self::$_gName)),
),
);
if (self::$_gName == 'custom_search') {
$runLink = array(
CRM_Core_Action::FOLLOWUP => array(
'name' => ts('Run'),
'url' => 'civicrm/contact/search/custom',
'qs' => 'reset=1&csid=%%value%%',
'title' => ts('Run %1', array(1 => self::$_gName)),
'class' => 'no-popup',
),
);
self::$_links = $runLink + self::$_links;
}
}
return self::$_links;
}
/**
* Run the basic page (run essentially starts execution for that page).
*/
public function run() {
$this->preProcess();
return parent::run();
}
/**
* Browse all options.
*/
public function browse() {
if (!self::$_gName) {
return parent::browse();
}
$groupParams = array('name' => self::$_gName);
$optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
$gName = self::$_gName;
$returnURL = CRM_Utils_System::url("civicrm/admin/options/$gName",
"reset=1&group=$gName"
);
$filter = "option_group_id = " . self::$_gId;
CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue',
'id', $returnURL, $filter
);
// retrieve financial account name for the payment method page
if ($gName = "payment_instrument") {
foreach ($optionValue as $key => $option) {
$optionValue[$key]['financial_account'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($key, NULL, 'civicrm_option_value', 'financial_account_id.name');
}
}
$this->assign('rows', $optionValue);
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return self::$_gName ? 'CRM_Admin_Form_Options' : 'CRM_Admin_Form_OptionGroup';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return self::$_gLabel;
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/options' . (self::$_gName ? '/' . self::$_gName : '');
}
}

View file

@ -0,0 +1,146 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* Get BAO name.
*
* @return string
*/
public function getBAOName() {
return 'CRM_Event_BAO_ParticipantStatusType';
}
/**
* @return array
*/
public function &links() {
static $links = NULL;
if ($links === NULL) {
$links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/participant_status',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Status'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/participant_status',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Status'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Status'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Status'),
),
);
}
return $links;
}
public function browse() {
$statusTypes = array();
$dao = new CRM_Event_DAO_ParticipantStatusType();
$dao->orderBy('weight');
$dao->find();
$visibilities = CRM_Core_PseudoConstant::visibility();
// these statuses are reserved, but disabled by default - so should be disablable after being enabled
$disablable = array(
'On waitlist',
'Awaiting approval',
'Pending from waitlist',
'Pending from approval',
'Rejected',
);
while ($dao->fetch()) {
CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]);
$action = array_sum(array_keys($this->links()));
if ($dao->is_reserved) {
$action -= CRM_Core_Action::DELETE;
if (!in_array($dao->name, $disablable)) {
$action -= CRM_Core_Action::DISABLE;
}
}
$action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE;
$statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(
self::links(),
$action,
array('id' => $dao->id),
ts('more'),
FALSE,
'participantStatusType.manage.action',
'ParticipantStatusType',
$dao->id
);
$statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id];
}
$this->assign('rows', $statusTypes);
}
/**
* @return string
*/
public function editForm() {
return 'CRM_Admin_Form_ParticipantStatusType';
}
/**
* @return string
*/
public function editName() {
return 'Participant Status';
}
/**
* @param null $mode
*
* @return string
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/participant_status';
}
}

View file

@ -0,0 +1,197 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of payment processors.
*/
class CRM_Admin_Page_PaymentProcessor extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Financial_BAO_PaymentProcessor';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/paymentProcessor',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Payment Processor'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Payment Processor'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Payment Processor'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/paymentProcessor',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Payment Processor'),
),
);
}
return self::$_links;
}
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*/
public function run() {
// set title and breadcrumb
CRM_Utils_System::setTitle(ts('Settings - Payment Processor'));
//CRM-15546
$paymentProcessorTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', array(
'labelColumn' => 'name',
'flip' => 1,
));
$this->assign('defaultPaymentProcessorType', $paymentProcessorTypes['PayPal']);
$breadCrumb = array(
array(
'title' => ts('Administration'),
'url' => CRM_Utils_System::url('civicrm/admin',
'reset=1'
),
),
);
CRM_Utils_System::appendBreadCrumb($breadCrumb);
return parent::run();
}
/**
* Browse all payment processors.
*
* @param null $action
*/
public function browse($action = NULL) {
// get all custom groups sorted by weight
$paymentProcessor = array();
$dao = new CRM_Financial_DAO_PaymentProcessor();
$dao->is_test = 0;
$dao->domain_id = CRM_Core_Config::domainID();
$dao->orderBy('name');
$dao->find();
while ($dao->fetch()) {
$paymentProcessor[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $paymentProcessor[$dao->id]);
$paymentProcessor[$dao->id]['payment_processor_type'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType',
$paymentProcessor[$dao->id]['payment_processor_type_id']);
// form all action links
$action = array_sum(array_keys($this->links()));
// update enable/disable links.
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
}
else {
$action -= CRM_Core_Action::DISABLE;
}
$paymentProcessor[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action,
array('id' => $dao->id),
ts('more'),
FALSE,
'paymentProcessor.manage.action',
'PaymentProcessor',
$dao->id
);
$paymentProcessor[$dao->id]['financialAccount'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($dao->id, NULL, 'civicrm_payment_processor', 'financial_account_id.name');
}
$this->assign('rows', $paymentProcessor);
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_PaymentProcessor';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Payment Processors';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/paymentProcessor';
}
}

View file

@ -0,0 +1,124 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of payment processors.
*/
class CRM_Admin_Page_PaymentProcessorType extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Financial_BAO_PaymentProcessorType';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/paymentProcessorType',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Payment ProcessorType'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Payment ProcessorType'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Payment ProcessorType'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/paymentProcessorType',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Payment ProcessorType'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_PaymentProcessorType';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Payment Processor Type';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/paymentProcessorType';
}
}

View file

@ -0,0 +1,150 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright (C) 2011 Marty Wright |
| Licensed to CiviCRM under the Academic Free License version 3.0. |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of PDF Page Formats.
*/
class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_PdfFormat';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
// helper variable for nicer formatting
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/pdfFormats',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit PDF Page Format'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/pdfFormats',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete PDF Page Format'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_PdfFormats';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'PDF Page Formats';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/pdfFormats';
}
/**
* Browse all PDF Page Formats.
*
* @param null $action
*/
public function browse($action = NULL) {
// Get list of configured PDF Page Formats
$pdfFormatList = CRM_Core_BAO_PdfFormat::getList();
// Add action links to each of the PDF Page Formats
$action = array_sum(array_keys($this->links()));
foreach ($pdfFormatList as & $format) {
$format['action'] = CRM_Core_Action::formLink(
self::links(),
$action,
array('id' => $format['id']),
ts('more'),
FALSE,
'pdfFormat.manage.action',
'PdfFormat',
$format['id']
);
}
// Order Label Formats by weight
$returnURL = CRM_Utils_System::url(self::userContext());
CRM_Core_BAO_PdfFormat::addOrder($pdfFormatList, $returnURL);
$this->assign('rows', $pdfFormatList);
}
}

View file

@ -0,0 +1,147 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying Parent Information Section tabs
*/
class CRM_Admin_Page_Persistent extends CRM_Core_Page {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
private static $_stringActionLinks;
private static $_customizeActionLinks;
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &stringActionLinks() {
// check if variable _actionsLinks is populated
if (!isset(self::$_stringActionLinks)) {
self::$_stringActionLinks = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/tplstrings/add',
'qs' => 'reset=1&action=update&id=%%id%%',
'title' => ts('Configure'),
),
);
}
return self::$_stringActionLinks;
}
/**
* @return array
*/
public function &customizeActionLinks() {
// check if variable _actionsLinks is populated
if (!isset(self::$_customizeActionLinks)) {
self::$_customizeActionLinks = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/tplstrings/add',
'qs' => 'reset=1&action=update&id=%%id%%&config=1',
'title' => ts('Configure'),
),
);
}
return self::$_customizeActionLinks;
}
/**
* Run the basic page (run essentially starts execution for that page).
*/
public function run() {
CRM_Utils_System::setTitle(ts('DB Template Strings'));
$this->browse();
return parent::run();
}
/**
* Browse all options.
*/
public function browse() {
$permission = FALSE;
$this->assign('editClass', FALSE);
if (CRM_Core_Permission::check('access CiviCRM')) {
$this->assign('editClass', TRUE);
$permission = TRUE;
}
$daoResult = new CRM_Core_DAO_Persistent();
$daoResult->find();
$schoolValues = array();
while ($daoResult->fetch()) {
$values[$daoResult->id] = array();
CRM_Core_DAO::storeValues($daoResult, $values[$daoResult->id]);
if ($daoResult->is_config == 1) {
$values[$daoResult->id]['action'] = CRM_Core_Action::formLink(self::customizeActionLinks(),
NULL,
array('id' => $daoResult->id),
ts('more'),
FALSE,
'persistent.config.actions',
'Persistent',
$daoResult->id
);
$values[$daoResult->id]['data'] = implode(',', unserialize($daoResult->data));
$configCustomization[$daoResult->id] = $values[$daoResult->id];
}
if ($daoResult->is_config == 0) {
$values[$daoResult->id]['action'] = CRM_Core_Action::formLink(self::stringActionLinks(),
NULL,
array('id' => $daoResult->id),
ts('more'),
FALSE,
'persistent.row.actions',
'Persistent',
$daoResult->id
);
$configStrings[$daoResult->id] = $values[$daoResult->id];
}
}
$rows = array(
'configTemplates' => $configStrings,
'customizeTemplates' => $configCustomization,
);
$this->assign('rows', $rows);
}
}

View file

@ -0,0 +1,123 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of location types.
*/
class CRM_Admin_Page_PreferencesDate extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
public $useLivePageJS = TRUE;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_PreferencesDate';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/setting/preferences/date',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Date Type'),
),
);
}
return self::$_links;
}
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*/
public function run() {
// set title and breadcrumb
CRM_Utils_System::setTitle(ts('Settings - Date Preferences'));
return parent::run();
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_PreferencesDate';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Date Preferences';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/setting/preferences/date';
}
}

View file

@ -0,0 +1,132 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of relationship types.
*/
class CRM_Admin_Page_RelationshipType extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Contact_BAO_RelationshipType';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'url' => 'civicrm/admin/reltype',
'qs' => 'action=view&id=%%id%%&reset=1',
'title' => ts('View Relationship Type'),
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/reltype',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Relationship Type'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Relationship Type'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Relationship Type'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/reltype',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Reletionship Type'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_RelationshipType';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Relationship Types';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/reltype';
}
}

View file

@ -0,0 +1,169 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of Reminders.
*/
class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic {
public $useLivePageJS = TRUE;
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Core_BAO_ActionSchedule';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
// helper variable for nicer formatting
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/scheduleReminders',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Schedule Reminders'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Label Format'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Label Format'),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/scheduleReminders',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Schedule Reminders'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Admin_Form_ScheduleReminders';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'ScheduleReminders';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/admin/scheduleReminders';
}
/**
* Browse all Scheduled Reminders settings.
*
* @param null $action
*/
public function browse($action = NULL) {
//CRM-16777: Do not permit access to user, for page 'Administer->Communication->Schedule Reminder',
//when do not have 'administer CiviCRM' permission.
if (!CRM_Core_Permission::check('administer CiviCRM')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
// Get list of configured reminders
$reminderList = CRM_Core_BAO_ActionSchedule::getList();
if (is_array($reminderList)) {
// Add action links to each of the reminders
foreach ($reminderList as & $format) {
$action = array_sum(array_keys($this->links()));
if ($format['is_active']) {
$action -= CRM_Core_Action::ENABLE;
}
else {
$action -= CRM_Core_Action::DISABLE;
}
$format['action'] = CRM_Core_Action::formLink(
self::links(),
$action,
array('id' => $format['id']),
ts('more'),
FALSE,
'actionSchedule.manage.action',
'ActionSchedule',
$format['id']
);
}
}
$this->assign('rows', $reminderList);
}
}

View file

@ -0,0 +1,51 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| 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-2017
*/
/**
* Page for displaying list of categories for Settings.
*/
class CRM_Admin_Page_Setting extends CRM_Core_Page {
/**
* Run page.
*
* @return string
* @throws Exception
*/
public function run() {
CRM_Core_Error::fatal('This page is deprecated. If you have followed a link or have been redirected here, please change link or redirect to Admin Console (/civicrm/admin?reset=1)');
CRM_Utils_System::setTitle(ts("Global Settings"));
return parent::run();
}
}