Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add user type Manager to Authors setup #1703

Merged
merged 3 commits into from

2 participants

@designermonkey

Adjustment for #1692

This allows a user type Manager to be selected when creating Authors. This Manager user type is allowed to access the Authors section to manage Authors with a user type of Manager or Author. Developers are hidden from this user type for obvious reasons.

The Authors section alterations are the only difference between a simple Author type and Manager, so all other System and Blueprint pages are accessed in exactly the same way as Authors.

This is a very small change, for some really helpful and useful additional functionality for clients who expect to be able to manage website Authors.

@brendo

balls. will fix.

@designermonkey

Sorry about that.

@brendo brendo merged commit d1205db into symphonycms:integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2013
  1. @designermonkey
Commits on Mar 25, 2013
  1. @designermonkey
  2. @designermonkey

    Fix a little mistake

    designermonkey authored
This page is out of date. Refresh to see the latest.
View
2  install/includes/install.sql
@@ -9,7 +9,7 @@ CREATE TABLE `tbl_authors` (
`last_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_seen` datetime DEFAULT '0000-00-00 00:00:00',
- `user_type` enum('author','developer') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'author',
+ `user_type` enum('author','manager','developer') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'author',
`primary` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no',
`default_area` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`auth_token_active` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no',
View
48 install/migrations/2.3.3.php
@@ -0,0 +1,48 @@
+<?php
+
+ Class migration_233 extends Migration{
+
+ static function run($function, $existing_version = null) {
+ self::$existing_version = $existing_version;
+
+ try{
+ $canProceed = self::$function();
+
+ return ($canProceed === false) ? false : true;
+ }
+ catch(DatabaseException $e) {
+ Symphony::Log()->writeToLog('Could not complete upgrading. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getMessage(), E_ERROR, true);
+
+ return false;
+ }
+ catch(Exception $e){
+ Symphony::Log()->writeToLog('Could not complete upgrading because of the following error: ' . $e->getMessage(), E_ERROR, true);
+
+ return false;
+ }
+ }
+
+ static function getVersion(){
+ return '2.3.3';
+ }
+
+ static function getReleaseNotes(){
+ return 'http://getsymphony.com/download/releases/version/2.3.3/';
+ }
+
+ static function upgrade(){
+ // Update DB for the new author role #1692
+ if(version_compare(self::$existing_version, '2.3.2', '<=')) {
+ Symphony::Database()->query(sprintf(
+ "ALTER TABLE `tbl_authors` CHANGE `user_type` `user_type` enum('author', 'manager', 'developer') DEFAULT 'author'",
+ $field
+ ));
+ }
+ return true;
+ }
+
+ static function preUpdateNotes(){
+ return false;
+ }
+
+ }
View
49 symphony/content/content.systemauthors.php
@@ -31,7 +31,7 @@ public function __viewIndex(){
$this->setPageType('table');
$this->setTitle(__('%1$s &ndash; %2$s', array(__('Authors'), __('Symphony'))));
- if (Administration::instance()->Author->isDeveloper()) {
+ if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) {
$this->appendSubheading(__('Authors'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL().'new/', __('Create a new author'), 'create button', NULL, array('accesskey' => 'c')));
} else $this->appendSubheading(__('Authors'));
@@ -55,7 +55,7 @@ public function __viewIndex(){
)
);
- if (Administration::instance()->Author->isDeveloper()) {
+ if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) {
$columns = array_merge($columns, array(
array(
'label' => __('User Type'),
@@ -83,8 +83,15 @@ public function __viewIndex(){
}
else{
foreach($authors as $a){
+
+ if(Administration::instance()->Author->isManager() && $a->isDeveloper()) {
+ continue;
+ }
// Setup each cell
- if(Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
+ if(
+ (Administration::instance()->Author->isDeveloper() || (Administration::instance()->Author->isManager() && !$a->isDeveloper()))
+ || Administration::instance()->Author->get('id') == $a->get('id')
+ ) {
$td1 = Widget::TableData(
Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author')
);
@@ -102,23 +109,34 @@ public function __viewIndex(){
$td3 = Widget::TableData(__('Unknown'), 'inactive');
}
- $td4 = Widget::TableData($a->isDeveloper()? __("Developer") : __("Author"));
+ if($a->isDeveloper()) {
+ $type = 'Developer';
+ }
+ elseif($a->isManager()) {
+ $type = 'Manager';
+ }
+ else {
+ $type = 'Author';
+ }
+ $td4 = Widget::TableData(__($type));
$languages = Lang::getAvailableLanguages();
$td5 = Widget::TableData($a->get("language") == NULL ? __("System Default") : $languages[$a->get("language")]);
- if (Administration::instance()->Author->isDeveloper()) {
+ if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) {
if ($a->get('id') != Administration::instance()->Author->get('id')) {
$td3->appendChild(Widget::Input('items['.$a->get('id').']', NULL, 'checkbox'));
}
}
// Add a row to the body array, assigning each cell to the row
- if(Administration::instance()->Author->isDeveloper())
+ if(Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) {
$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
- else
+ }
+ else {
$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
+ }
}
}
@@ -131,7 +149,7 @@ public function __viewIndex(){
$this->Form->appendChild($table);
- if(Administration::instance()->Author->isDeveloper()) {
+ if(Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) {
$tableActions = new XMLElement('div');
$tableActions->setAttribute('class', 'actions');
@@ -230,7 +248,7 @@ public function __form(){
// Handle unknown context
if(!in_array($this->_context[0], array('new', 'edit'))) Administration::instance()->errorPageNotFound();
- if($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper()) {
+ if($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper() && !Administration::instance()->Author->isManager()) {
Administration::instance()->throwCustomError(
__('You are not authorised to access this page.'),
__('Access Denied'),
@@ -286,7 +304,7 @@ public function __form(){
if($this->_context[0] == 'edit' && $author->get('id') == Administration::instance()->Author->get('id')) $isOwner = true;
- if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper()) {
+ if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper() && !Administration::instance()->Author->isManager()) {
Administration::instance()->throwCustomError(
__('You are not authorised to edit other authors.'),
__('Access Denied'),
@@ -337,7 +355,7 @@ public function __form(){
$div->appendChild((isset($this->_errors['username']) ? Widget::Error($label, $this->_errors['username']) : $label));
// Only developers can change the user type. Primary account should NOT be able to change this
- if (Administration::instance()->Author->isDeveloper() && !$author->isPrimaryAccount()) {
+ if ((Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) && !$author->isPrimaryAccount()) {
// Create columns
$div->setAttribute('class', 'two columns');
@@ -348,6 +366,7 @@ public function __form(){
$options = array(
array('author', false, __('Author')),
+ array('manager', $author->isManager(), __('Manager')),
array('developer', $author->isDeveloper(), __('Developer'))
);
@@ -365,7 +384,7 @@ public function __form(){
$fieldset->appendChild($help);
// Password reset
- if($this->_context[0] == 'edit' && (!Administration::instance()->Author->isDeveloper() || $isOwner === true)) {
+ if($this->_context[0] == 'edit' && (!Administration::instance()->Author->isDeveloper() || !Administration::instance()->Author->isManager() || $isOwner === true)) {
$fieldset->setAttribute('class', 'three columns');
$label = Widget::Label(NULL, NULL, 'column');
@@ -388,7 +407,7 @@ public function __form(){
$group->appendChild($fieldset);
// Auth token
- if(Administration::instance()->Author->isDeveloper()) {
+ if(Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) {
$label = Widget::Label();
$group->appendChild(Widget::Input('fields[auth_token_active]', 'no', 'hidden'));
$input = Widget::Input('fields[auth_token_active]', 'yes', 'checkbox');
@@ -410,7 +429,7 @@ public function __form(){
// If the Author is the Developer, allow them to set the Default Area to
// be the Sections Index.
- if($author->isDeveloper()) {
+ if($author->isDeveloper() || $author->isManager()) {
$options[] = array('/blueprints/sections/', $author->get('default_area') == '/blueprints/sections/', __('Sections Index'));
}
@@ -593,7 +612,7 @@ public function __actionEdit(){
if ($this->_Author->isPrimaryAccount() || ($isOwner && Administration::instance()->Author->isDeveloper())){
$this->_Author->set('user_type', 'developer'); // Primary accounts are always developer, Developers can't lower their level
}
- elseif (Administration::instance()->Author->isDeveloper() && isset($fields['user_type'])){
+ elseif ((Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->isManager()) && isset($fields['user_type'])){
$this->_Author->set('user_type', $fields['user_type']); // Only developer can change user type
}
View
11 symphony/lib/toolkit/class.author.php
@@ -76,6 +76,17 @@ public function isDeveloper(){
return ($this->get('user_type') == 'developer');
}
+ /**
+ * Returns boolean if the current Author is of the manager
+ * user type.
+ *
+ * @since 2.3.3
+ * @return boolean
+ */
+ public function isManager(){
+ return ($this->get('user_type') == 'manager');
+ }
+
/**
* Returns boolean if the current Author is the original creator
* of this Symphony installation.
Something went wrong with that request. Please try again.