public $ajaxPopupsEnabled;
/**
- * Get or set the single instance of CRM_Core_Resources
+ * Get or set the single instance of CRM_Core_Resources.
*
* @param CRM_Core_Resources $instance
* New copy of the manager.
}
/**
- * Construct a resource manager
+ * Construct a resource manager.
*
* @param CRM_Extension_Mapper $extMapper
* Map extension names to their base path or URLs.
);
}
+ /**
+ * Export permission data to the client to enable smarter GUIs.
+ *
+ * Note: Application security stems from the server's enforcement
+ * of the security logic (e.g. in the API permissions). There's no way
+ * the client can use this info to make the app more secure; however,
+ * it can produce a better-tuned (non-broken) UI.
+ *
+ * @param array $permNames
+ * List of permission names to check/export.
+ * @return CRM_Core_Resources
+ */
+ public function addPermissions($permNames) {
+ $permNames = (array) $permNames;
+ $perms = array();
+ foreach ($permNames as $permName) {
+ $perms[$permName] = CRM_Core_Permission::check($permName);
+ }
+ return $this->addSetting(array(
+ 'permissions' => $perms,
+ ));
+ }
+
/**
* Add a JavaScript file to the current page using <SCRIPT SRC>.
*
}
/**
- * Helper fn for addSettingsFactory
+ * Helper fn for addSettingsFactory.
*/
public function getSettings() {
$result = $this->settings;
}
/**
- * Helper fn for addSetting
+ * Helper fn for addSetting.
* Render JavaScript variables for the global CRM object.
*
* @return string
foreach ((array) $text as $str) {
$translated = ts($str, array(
'domain' => ($domain == 'civicrm') ? NULL : array($domain, NULL),
+ 'raw' => TRUE,
));
// We only need to push this string to client if the translation
}
/**
- * Determine file path of a resource provided by an extension
+ * Determine file path of a resource provided by an extension.
*
* @param string $ext
* extension name; use 'civicrm' for core.
}
/**
- * Determine public URL of a resource provided by an extension
+ * Determine public URL of a resource provided by an extension.
*
* @param string $ext
* extension name; use 'civicrm' for core.
// Add global settings
$settings = array(
'config' => array(
- 'ajaxPopupsEnabled' => $this->ajaxPopupsEnabled,
'isFrontend' => $config->userFrameworkFrontend,
),
);
}
/**
- * Flushes cached translated strings
+ * Flushes cached translated strings.
* @return CRM_Core_Resources
*/
public function flushStrings() {
'contactCreate' => CRM_Core_BAO_UFGroup::getCreateLinks(),
'filters' => self::getEntityRefFilters(),
),
+ 'ajaxPopupsEnabled' => self::singleton()->ajaxPopupsEnabled,
);
print CRM_Core_Smarty::singleton()->fetchWith('CRM/common/l10n.js.tpl', $vars);
CRM_Utils_System::civiExit();
}
/**
- * List of core resources we add to every CiviCRM page
+ * List of core resources we add to every CiviCRM page.
*
* @return array
*/
"bower_components/jquery-ui/themes/smoothness/jquery-ui$min.css",
"bower_components/lodash-compat/lodash.min.js",
"packages/jquery/plugins/jquery.mousewheel$min.js",
- "packages/jquery/plugins/select2/select2$min.js",
- "packages/jquery/plugins/select2/select2.css",
+ "bower_components/select2/select2$min.js",
+ "bower_components/select2/select2.css",
"packages/jquery/plugins/jquery.tableHeader.js",
"packages/jquery/plugins/jquery.textarearesizer.js",
"packages/jquery/plugins/jquery.form$min.js",
"packages/jquery/plugins/jquery.blockUI$min.js",
"packages/jquery/plugins/DataTables/media/js/jquery.dataTables$min.js",
"packages/jquery/plugins/DataTables/media/css/jquery.dataTables$min.css",
- "packages/jquery/plugins/jquery.validate$min.js",
+ "bower_components/jquery-validation/dist/jquery.validate$min.js",
"packages/jquery/plugins/jquery.ui.datepicker.validation.pack.js",
"js/Common.js",
"js/crm.ajax.js",
// These scripts are only needed by back-office users
if (CRM_Core_Permission::check('access CiviCRM')) {
$items[] = "packages/jquery/plugins/jquery.menu$min.js";
- $items[] = "packages/jquery/css/menu.css";
+ $items[] = "css/navigation.css";
$items[] = "packages/jquery/plugins/jquery.jeditable$min.js";
$items[] = "packages/jquery/plugins/jquery.notify$min.js";
$items[] = "js/jquery/jquery.crmeditable.js";
}
/**
- * Provide a list of available entityRef filters
+ * Provide a list of available entityRef filters.
* FIXME: This function doesn't really belong in this class
* @TODO: Provide a sane way to extend this list for other entities - a hook or??
* @return array