mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 01:34:31 +02:00
Various minor module updates
This commit is contained in:
@@ -46,6 +46,25 @@ class Permissions extends PagesType {
|
||||
'user-admin-all' => 'user-admin',
|
||||
);
|
||||
|
||||
/**
|
||||
* Permissions that can reduce existing access upon installation
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
*/
|
||||
protected $reducerPermissions = array(
|
||||
'page-hide',
|
||||
'page-publish',
|
||||
'page-edit-created',
|
||||
'page-edit-images',
|
||||
'page-rename',
|
||||
'page-edit-lang-',
|
||||
'page-edit-lang-none',
|
||||
'user-admin-',
|
||||
'user-admin-all',
|
||||
'page-lister-',
|
||||
);
|
||||
|
||||
/**
|
||||
* Does the system have a permission with the given name?
|
||||
*
|
||||
@@ -158,7 +177,9 @@ class Permissions extends PagesType {
|
||||
$languages = $this->wire('languages');
|
||||
if($languages) {
|
||||
$label = $this->_('Edit fields on a page in language: %s');
|
||||
$a["page-edit-lang-default"] = sprintf($label, 'default') . ' ' . $this->_('(also required to create or delete pages)');
|
||||
$alsoLabel = $this->_('(also required to create or delete pages)');
|
||||
$a["page-edit-lang-default"] = sprintf($label, 'default') . ' ' . $alsoLabel;
|
||||
$a["page-edit-lang-none"] = $this->_('Edit single-language fields on multi-language page');
|
||||
foreach($languages as $language) {
|
||||
if($language->isDefault()) continue;
|
||||
$a["page-edit-lang-$language->name"] = sprintf($label, $language->name);
|
||||
@@ -180,6 +201,32 @@ class Permissions extends PagesType {
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permission names that can reduce existing access, when installed
|
||||
*
|
||||
* Returned permission names that end with a "-" indicate that given permission name is a prefix
|
||||
* that applies for anything that appears after it.
|
||||
*
|
||||
* @return array Array of permission names where both index and value are permission name
|
||||
*
|
||||
*/
|
||||
public function getReducerPermissions() {
|
||||
$a = $this->reducerPermissions;
|
||||
$languages = $this->wire('languages');
|
||||
if($languages && $this->wire('modules')->isInstalled('LanguageSupportFields')) {
|
||||
foreach($languages as $language) {
|
||||
$a[] = "page-edit-lang-$language->name";
|
||||
}
|
||||
}
|
||||
foreach($this->wire('roles') as $role) {
|
||||
$a[] = "user-admin-$role->name";
|
||||
}
|
||||
$a = array_flip($a);
|
||||
foreach($a as $k => $v) $a[$k] = $k;
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return array of permission names that are delegated to another when not installed
|
||||
*
|
||||
|
@@ -34,9 +34,14 @@ class FieldtypePassword extends Fieldtype {
|
||||
|
||||
/**
|
||||
* Return the associated Inputfield
|
||||
*
|
||||
* @param Page $page
|
||||
* @param Field $field
|
||||
* @return InputfieldPassword
|
||||
*
|
||||
*/
|
||||
public function getInputfield(Page $page, Field $field) {
|
||||
/** @var InputfieldPassword $inputfield */
|
||||
$inputfield = $this->modules->get('InputfieldPassword');
|
||||
$inputfield->class = $this->className();
|
||||
$inputfield->setPage($page);
|
||||
@@ -45,6 +50,9 @@ class FieldtypePassword extends Fieldtype {
|
||||
|
||||
/**
|
||||
* Return all Fieldtypes derived from FieldtypeText, which we will consider compatible
|
||||
*
|
||||
* @param Field $field
|
||||
* @return null|array
|
||||
*
|
||||
*/
|
||||
public function ___getCompatibleFieldtypes(Field $field) {
|
||||
@@ -53,6 +61,11 @@ class FieldtypePassword extends Fieldtype {
|
||||
|
||||
/**
|
||||
* Sanitize value for runtime
|
||||
*
|
||||
* @param Page $page
|
||||
* @param Field $field
|
||||
* @param Password|string $value
|
||||
* @return Password
|
||||
*
|
||||
*/
|
||||
public function sanitizeValue(Page $page, Field $field, $value) {
|
||||
@@ -72,6 +85,10 @@ class FieldtypePassword extends Fieldtype {
|
||||
|
||||
/**
|
||||
* Get a blank password item object
|
||||
*
|
||||
* @param Page $page
|
||||
* @param Field $field
|
||||
* @return Password
|
||||
*
|
||||
*/
|
||||
public function getBlankValue(Page $page, Field $field) {
|
||||
@@ -124,6 +141,9 @@ class FieldtypePassword extends Fieldtype {
|
||||
|
||||
/**
|
||||
* Return the database schema in specified format
|
||||
*
|
||||
* @param Field $field
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function getDatabaseSchema(Field $field) {
|
||||
@@ -138,6 +158,9 @@ class FieldtypePassword extends Fieldtype {
|
||||
|
||||
/**
|
||||
* Return the fields required to configure an instance of FieldtypePassword
|
||||
*
|
||||
* @param Field $field
|
||||
* @return InputfieldWrapper
|
||||
*
|
||||
*/
|
||||
public function ___getConfigInputfields(Field $field) {
|
||||
|
@@ -167,7 +167,7 @@ class ProcessPageType extends Process implements ConfigurableModule, WirePageEdi
|
||||
$templateID = (int) $this->wire('input')->get('templates_id');
|
||||
if(!$templateID) $templateID = (int) $this->wire('session')->get($this->className() . 'TemplatesID');
|
||||
$selector = $templateID ? "templates_id=$templateID, " : "";
|
||||
return $this->renderList($selector . "limit=25, status<" . Page::statusMax);
|
||||
return $this->renderList($selector . "limit=100, status<" . Page::statusMax);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -48,16 +48,25 @@ class ProcessPermission extends ProcessPageType {
|
||||
$optionalPermissions = $this->wire('permissions')->getOptionalPermissions();
|
||||
|
||||
if(count($optionalPermissions)) {
|
||||
$reducerPermissions = $this->wire('permissions')->getReducerPermissions();
|
||||
|
||||
$f = $this->wire('modules')->get('InputfieldCheckboxes');
|
||||
$f->name = 'install_permissions';
|
||||
$f->label = $this->_('Check the box next to each optional permission you would like to install.');
|
||||
$f->table = true;
|
||||
|
||||
|
||||
foreach($optionalPermissions as $name => $label) {
|
||||
$f->addOption($name, "$name|$label");
|
||||
$displayName = $name;
|
||||
if(isset($reducerPermissions[$name])) $displayName .= '*';
|
||||
$f->addOption($name, "$displayName|$label");
|
||||
}
|
||||
|
||||
$f->notes = '*' .
|
||||
$this->_('When installed, user must have this permission to complete described task.') . ' ' .
|
||||
$this->_('When NOT installed, permission is assumed if user already has edit access to described resource.') . ' ' .
|
||||
$this->_('As a result, if installed, this permission may remove existing access until it is assigned to roles.');
|
||||
|
||||
$fieldset->add($f);
|
||||
|
||||
$button = $this->wire('modules')->get('InputfieldSubmit');
|
||||
|
@@ -168,6 +168,8 @@ class ProcessProfile extends Process implements ConfigurableModule, WirePageEdit
|
||||
if(strlen($inputfield->value)) {
|
||||
$passRequiredInputfields[] = $inputfield;
|
||||
}
|
||||
} else if($field->name === 'tfa_type') {
|
||||
$passRequiredInputfields[] = $inputfield;
|
||||
}
|
||||
|
||||
$fieldset->add($inputfield);
|
||||
@@ -264,6 +266,7 @@ class ProcessProfile extends Process implements ConfigurableModule, WirePageEdit
|
||||
}
|
||||
|
||||
$v = $user->get($field->name);
|
||||
if($field->type instanceof FieldtypeModule) $v = "$v";
|
||||
|
||||
if($inputfield->isChanged() || $v !== $value) {
|
||||
|
||||
|
@@ -259,8 +259,8 @@ class ProcessTemplateExportImport extends Wire {
|
||||
$attr = array('checked' => 'checked');
|
||||
}
|
||||
|
||||
if($new) $optionValue = "$property|$newValue";
|
||||
else $optionValue = "$property|$oldValue|$newValue";
|
||||
if($new) $optionValue = " $property|$newValue";
|
||||
else $optionValue = " $property|$oldValue|$newValue";
|
||||
|
||||
$f->addOption($property, $optionValue, $attr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user