diff --git a/Controller/ArticleController.php b/Controller/ArticleController.php
index c0be41f2e..b2c60ae20 100644
--- a/Controller/ArticleController.php
+++ b/Controller/ArticleController.php
@@ -15,8 +15,10 @@
use FOS\RestBundle\Routing\ClassResourceInterface;
use JMS\Serializer\SerializationContext;
use ONGR\ElasticsearchBundle\Service\Manager;
+use ONGR\ElasticsearchDSL\Query\BoolQuery;
use ONGR\ElasticsearchDSL\Query\IdsQuery;
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
+use ONGR\ElasticsearchDSL\Query\MatchQuery;
use ONGR\ElasticsearchDSL\Query\MultiMatchQuery;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchDSL\Sort\FieldSort;
@@ -123,6 +125,14 @@ public function cgetAction(Request $request)
$search->addQuery(new TermQuery('type', $type));
}
+ if (null !== ($contactId = $request->get('contactId'))) {
+ $boolQuery = new BoolQuery();
+ $boolQuery->add(new MatchQuery('changer_contact_id', $contactId), BoolQuery::SHOULD);
+ $boolQuery->add(new MatchQuery('creator_contact_id', $contactId), BoolQuery::SHOULD);
+ $boolQuery->add(new MatchQuery('author_id', $contactId), BoolQuery::SHOULD);
+ $search->addQuery($boolQuery);
+ }
+
if (null === $search->getQueries()) {
$search->addQuery(new MatchAllQuery());
}
diff --git a/Document/ArticleViewDocument.php b/Document/ArticleViewDocument.php
index ef43fbca0..4cfed18d0 100644
--- a/Document/ArticleViewDocument.php
+++ b/Document/ArticleViewDocument.php
@@ -225,6 +225,27 @@ class ArticleViewDocument implements ArticleViewDocumentInterface
*/
protected $localizationState;
+ /**
+ * @var string
+ *
+ * @Property(type="string")
+ */
+ protected $authorId;
+
+ /**
+ * @var string
+ *
+ * @Property(type="string")
+ */
+ protected $creatorContactId;
+
+ /**
+ * @var string
+ *
+ * @Property(type="string")
+ */
+ protected $changerContactId;
+
/**
* @param string $uuid
*/
@@ -607,4 +628,58 @@ public function setLocalizationState(LocalizationStateViewObject $localizationSt
return $this;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setAuthorId($authorId)
+ {
+ $this->authorId = $authorId;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorId()
+ {
+ return $this->authorId;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setCreatorContactId($creatorContactId)
+ {
+ $this->creatorContactId = $creatorContactId;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCreatorContactId()
+ {
+ return $this->creatorContactId;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setChangerContactId($changerContactId)
+ {
+ $this->changerContactId = $changerContactId;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getChangerContactId()
+ {
+ return $this->changerContactId;
+ }
}
diff --git a/Document/ArticleViewDocumentInterface.php b/Document/ArticleViewDocumentInterface.php
index db11d6475..4ad2d237d 100644
--- a/Document/ArticleViewDocumentInterface.php
+++ b/Document/ArticleViewDocumentInterface.php
@@ -307,7 +307,7 @@ public function setTeaserMediaId($teaserMediaId);
/**
* Get published.
*
- * @return $this
+ * @return \DateTime
*/
public function getPublished();
@@ -323,7 +323,7 @@ public function setPublished(\DateTime $published = null);
/**
* Get published state.
*
- * @return $this
+ * @return bool
*/
public function getPublishedState();
@@ -351,4 +351,52 @@ public function getLocalizationState();
* @return $this
*/
public function setLocalizationState(LocalizationStateViewObject $localizationState);
+
+ /**
+ * Set author id.
+ *
+ * @param string $authorId
+ *
+ * @return $this
+ */
+ public function setAuthorId($authorId);
+
+ /**
+ * Get author id.
+ *
+ * @return string
+ */
+ public function getAuthorId();
+
+ /**
+ * Set creator contact id.
+ *
+ * @param string $creatorContactId
+ *
+ * @return $this
+ */
+ public function setCreatorContactId($creatorContactId);
+
+ /**
+ * Get creator contact id.
+ *
+ * @return string
+ */
+ public function getCreatorContactId();
+
+ /**
+ * Set creator contact id.
+ *
+ * @param string $changerContactId
+ *
+ * @return $this
+ */
+ public function setChangerContactId($changerContactId);
+
+ /**
+ * Get changer contact id.
+ *
+ * @return string
+ */
+ public function getChangerContactId();
}
diff --git a/Document/Index/ArticleIndexer.php b/Document/Index/ArticleIndexer.php
index 948b7baf7..fbc28a2da 100644
--- a/Document/Index/ArticleIndexer.php
+++ b/Document/Index/ArticleIndexer.php
@@ -23,7 +23,9 @@
use Sulu\Bundle\ArticleBundle\Event\IndexEvent;
use Sulu\Bundle\ArticleBundle\Metadata\ArticleTypeTrait;
use Sulu\Bundle\ArticleBundle\Metadata\ArticleViewDocumentIdTrait;
+use Sulu\Bundle\ContactBundle\Entity\Contact;
use Sulu\Bundle\ContactBundle\Entity\ContactRepository;
+use Sulu\Bundle\SecurityBundle\Entity\User;
use Sulu\Bundle\SecurityBundle\UserManager\UserManager;
use Sulu\Component\Content\Document\LocalizationState;
use Sulu\Component\Content\Document\WorkflowStage;
@@ -199,13 +201,28 @@ protected function createOrUpdateArticle(
$article->setCreated($document->getCreated());
$article->setAuthored($document->getAuthored());
if ($document->getAuthor()) {
- $article->setAuthorFullName($this->contactRepository->findById($document->getAuthor())->getFullName());
+ /** @var Contact $author */
+ $author = $this->contactRepository->findById($document->getAuthor());
+ if ($author) {
+ $article->setAuthorFullName($author->getFullName());
+ $article->setAuthorId($author->getId());
+ }
}
if ($document->getChanger()) {
- $article->setChangerFullName($this->userManager->getFullNameByUserId($document->getChanger()));
+ /** @var User $changer */
+ $changer = $this->userManager->getUserById($document->getChanger());
+ if ($changer) {
+ $article->setChangerFullName($changer->getFullName());
+ $article->setChangerContactId($changer->getContact()->getId());
+ }
}
if ($document->getCreator()) {
- $article->setCreatorFullName($this->userManager->getFullNameByUserId($document->getCreator()));
+ /** @var User $creator */
+ $creator = $this->userManager->getUserById($document->getCreator());
+ if ($creator) {
+ $article->setCreatorFullName($creator->getFullName());
+ $article->setCreatorContactId($creator->getContact()->getId());
+ }
}
$article->setType($this->getType($structureMetadata));
$article->setStructureType($document->getStructureType());
diff --git a/Resources/config/serializer/Document.ArticleViewDocument.xml b/Resources/config/serializer/Document.ArticleViewDocument.xml
index 0ce9b3681..22e4f7cb4 100644
--- a/Resources/config/serializer/Document.ArticleViewDocument.xml
+++ b/Resources/config/serializer/Document.ArticleViewDocument.xml
@@ -14,5 +14,8 @@
+
+
+
diff --git a/Resources/public/dist/components/articles/list/main.js b/Resources/public/dist/components/articles/list/main.js
index 4cfe49dd2..8bf233b6a 100644
--- a/Resources/public/dist/components/articles/list/main.js
+++ b/Resources/public/dist/components/articles/list/main.js
@@ -1 +1 @@
-define(["underscore","services/husky/storage","sulucontent/components/copy-locale-overlay/main","sulucontent/components/open-ghost-overlay/main","services/suluarticle/article-manager"],function(a,b,c,d,e){"use strict";var f={options:{config:{},storageName:"articles"},templates:{list:['
','','',''].join(""),draftIcon:'',publishedIcon:'',route:["articles","<% if (!!type) { %>:<%=type%><% } %>","/<%=locale%>"].join("")},translations:{headline:"sulu_article.list.title",unpublished:"public.unpublished",publishedWithDraft:"public.published-with-draft",openGhostOverlay:{info:"sulu_article.settings.open-ghost-overlay.info","new":"sulu_article.settings.open-ghost-overlay.new",copy:"sulu_article.settings.open-ghost-overlay.copy",ok:"sulu_article.settings.open-ghost-overlay.ok"}}};return{defaults:f,header:function(){this.storage=b.get("sulu",this.options.storageName);var c,d=this.options.config.types,e=this.options.config.typeNames,f={icon:"plus-circle",title:"public.add-new"},g=!1,h=null,i=this.options.type||this.storage.getWithDefault("type",null);return 1===e.length?f.callback=function(){this.toAdd(e[0])}.bind(this):(f.dropdownItems=a.map(e,function(a){return{title:d[a].title,callback:function(){this.toAdd(a)}.bind(this)}}.bind(this)),c=[],this.options.config.displayTabAll===!0&&c.push({name:"public.all",key:null}),a.each(e,function(a){c.push({id:a,name:d[a].title,key:a}),a===i&&(h=d[a].title)}.bind(this)),g={componentOptions:{callback:this.typeChange.bind(this),preselector:"name",preselect:h},data:c}),{noBack:!0,tabs:g,toolbar:{buttons:{addArticle:{options:f},deleteSelected:{}},languageChanger:{data:this.options.config.languageChanger,preSelected:this.options.locale}}}},layout:{content:{width:"max"}},initialize:function(){if(this.options.type)this.storage.set("type",this.options.type);else if(this.storage.has("type")){var a=this.templates.route({type:this.storage.get("type"),locale:this.options.locale});this.sandbox.emit("sulu.router.navigate",a,!1,!1),this.options.type=this.storage.get("type")}this.render(),this.bindCustomEvents()},render:function(){this.$el.html(this.templates.list()),this.sandbox.sulu.initListToolbarAndList.call(this,"article","/admin/api/articles/fields",{el:this.$find(".list-toolbar-container"),instanceName:"articles",template:this.sandbox.sulu.buttons.get({settings:{options:{dropdownItems:[{type:"columnOptions"}]}}})},{el:this.sandbox.dom.find(".datagrid-container"),url:"/admin/api/articles?sortBy=authored&sortOrder=desc&locale="+this.options.locale+(this.options.type?"&type="+this.options.type:""),storageName:this.options.storageName,searchInstanceName:"articles",searchFields:["title"],resultKey:"articles",idKey:"uuid",instanceName:"articles",actionCallback:function(a,b){"ghost"===b.localizationState.state?e.load(a,this.options.locale).then(function(b){d.openGhost.call(this,b,this.translations.openGhostOverlay).then(function(b,d){b?c.copyLocale.call(this,a,d,[this.options.locale],function(){this.toEdit(a)}.bind(this)):this.toEdit(a)}.bind(this))}.bind(this)).fail(function(a){this.sandbox.emit("sulu.article.error",a.status,data)}.bind(this)):this.toEdit(a)}.bind(this),viewOptions:{table:{actionIconColumn:"title",badges:[{column:"title",callback:function(a,b){return!(!a.localizationState||"ghost"!==a.localizationState.state||a.localizationState.locale===this.options.locale)&&(b.title=a.localizationState.locale,b)}.bind(this)},{column:"title",callback:function(a,b){var c="",d=this.translations.unpublished;return a.published&&!a.publishedState&&(d=this.translations.publishedWithDraft,c+=this.templates.publishedIcon({title:d})),a.publishedState||(c+=this.templates.draftIcon({title:d})),b.title=c,b.cssClass="badge-none",b}.bind(this)}]}}})},toEdit:function(a,b){this.sandbox.emit("sulu.router.navigate","articles/"+(b||this.options.locale)+"/edit:"+a+"/details")},toAdd:function(a,b){this.sandbox.emit("sulu.router.navigate","articles/"+(b||this.options.locale)+"/add"+(this.options.config.typeNames.length>1?":"+a:""))},toList:function(a){1!==this.options.config.typeNames.length&&this.options.type?this.sandbox.emit("sulu.router.navigate","articles:"+this.options.type+"/"+(a||this.options.locale)):this.sandbox.emit("sulu.router.navigate","articles/"+(a||this.options.locale))},deleteItems:function(b){this.sandbox.util.save("/admin/api/articles?ids="+b.join(","),"DELETE").then(function(){a.each(b,function(a){this.sandbox.emit("husky.datagrid.articles.record.remove",a)}.bind(this))}.bind(this))},typeChange:function(a){var b=this.templates.route({type:a.key,locale:this.options.locale});this.options.type=a.key,this.sandbox.emit("husky.datagrid.articles.url.update",{page:1,type:a.key}),this.sandbox.emit("sulu.router.navigate",b,!1,!1),this.storage.set("type",a.key)},getCopyLocaleUrl:function(a,b,c){return e.getCopyLocaleUrl(a,b,c)},bindCustomEvents:function(){this.sandbox.on("husky.datagrid.articles.number.selections",function(a){var b=a>0?"enable":"disable";this.sandbox.emit("sulu.header.toolbar.item."+b,"deleteSelected",!1)}.bind(this)),this.sandbox.on("sulu.toolbar.delete",function(){this.sandbox.emit("husky.datagrid.articles.items.get-selected",this.deleteItems.bind(this))}.bind(this)),this.sandbox.on("sulu.header.language-changed",function(a){a.id!==this.options.locale&&(this.sandbox.sulu.saveUserSetting(this.options.config.settingsKey,a.id),this.toList(a.id))}.bind(this))}}});
\ No newline at end of file
+define(["underscore","services/husky/storage","sulucontent/components/copy-locale-overlay/main","sulucontent/components/open-ghost-overlay/main","services/suluarticle/article-manager"],function(a,b,c,d,e){"use strict";var f={options:{config:{},storageName:"articles"},templates:{list:['','','',''].join(""),draftIcon:'',publishedIcon:'',route:["articles","<% if (!!type) { %>:<%=type%><% } %>","/<%=locale%>"].join("")},translations:{headline:"sulu_article.list.title",unpublished:"public.unpublished",publishedWithDraft:"public.published-with-draft",filterMe:"sulu_article.list.filter.me",filterAll:"sulu_article.list.filter.all",openGhostOverlay:{info:"sulu_article.settings.open-ghost-overlay.info","new":"sulu_article.settings.open-ghost-overlay.new",copy:"sulu_article.settings.open-ghost-overlay.copy",ok:"sulu_article.settings.open-ghost-overlay.ok"}}};return{defaults:f,header:function(){this.storage=b.get("sulu",this.options.storageName);var c,d=this.options.config.types,e=this.options.config.typeNames,f={icon:"plus-circle",title:"public.add-new"},g=!1,h=null,i=this.options.type||this.storage.getWithDefault("type",null);return 1===e.length?f.callback=function(){this.toAdd(e[0])}.bind(this):(f.dropdownItems=a.map(e,function(a){return{title:d[a].title,callback:function(){this.toAdd(a)}.bind(this)}}.bind(this)),c=[],this.options.config.displayTabAll===!0&&c.push({name:"public.all",key:null}),a.each(e,function(a){c.push({id:a,name:d[a].title,key:a}),a===i&&(h=d[a].title)}.bind(this)),g={componentOptions:{callback:this.typeChange.bind(this),preselector:"name",preselect:h},data:c}),{noBack:!0,tabs:g,toolbar:{buttons:{addArticle:{options:f},deleteSelected:{}},languageChanger:{data:this.options.config.languageChanger,preSelected:this.options.locale}}}},layout:{content:{width:"max"}},initialize:function(){if(this.options.type)this.storage.set("type",this.options.type);else if(this.storage.has("type")){var a=this.templates.route({type:this.storage.get("type"),locale:this.options.locale});this.sandbox.emit("sulu.router.navigate",a,!1,!1),this.options.type=this.storage.get("type")}this.render(),this.bindCustomEvents()},render:function(){this.$el.html(this.templates.list()),this.sandbox.sulu.initListToolbarAndList.call(this,"article","/admin/api/articles/fields",{el:this.$find(".list-toolbar-container"),instanceName:"articles",template:this.retrieveListToolbarTemplate()},{el:this.sandbox.dom.find(".datagrid-container"),url:"/admin/api/articles?sortBy=authored&sortOrder=desc&locale="+this.options.locale+(this.options.type?"&type="+this.options.type:""),storageName:this.options.storageName,searchInstanceName:"articles",searchFields:["title"],resultKey:"articles",idKey:"uuid",instanceName:"articles",actionCallback:function(a,b){"ghost"===b.localizationState.state?e.load(a,this.options.locale).then(function(b){d.openGhost.call(this,b,this.translations.openGhostOverlay).then(function(b,d){b?c.copyLocale.call(this,a,d,[this.options.locale],function(){this.toEdit(a)}.bind(this)):this.toEdit(a)}.bind(this))}.bind(this)).fail(function(a){this.sandbox.emit("sulu.article.error",a.status,data)}.bind(this)):this.toEdit(a)}.bind(this),viewOptions:{table:{actionIconColumn:"title",badges:[{column:"title",callback:function(a,b){return!(!a.localizationState||"ghost"!==a.localizationState.state||a.localizationState.locale===this.options.locale)&&(b.title=a.localizationState.locale,b)}.bind(this)},{column:"title",callback:function(a,b){var c="",d=this.translations.unpublished;return a.published&&!a.publishedState&&(d=this.translations.publishedWithDraft,c+=this.templates.publishedIcon({title:d})),a.publishedState||(c+=this.templates.draftIcon({title:d})),b.title=c,b.cssClass="badge-none",b}.bind(this)}]}}})},toEdit:function(a,b){this.sandbox.emit("sulu.router.navigate","articles/"+(b||this.options.locale)+"/edit:"+a+"/details")},toAdd:function(a,b){this.sandbox.emit("sulu.router.navigate","articles/"+(b||this.options.locale)+"/add"+(this.options.config.typeNames.length>1?":"+a:""))},toList:function(a){1!==this.options.config.typeNames.length&&this.options.type?this.sandbox.emit("sulu.router.navigate","articles:"+this.options.type+"/"+(a||this.options.locale)):this.sandbox.emit("sulu.router.navigate","articles/"+(a||this.options.locale))},deleteItems:function(b){this.sandbox.util.save("/admin/api/articles?ids="+b.join(","),"DELETE").then(function(){a.each(b,function(a){this.sandbox.emit("husky.datagrid.articles.record.remove",a)}.bind(this))}.bind(this))},typeChange:function(a){var b=this.templates.route({type:a.key,locale:this.options.locale});this.options.type=a.key,this.sandbox.emit("husky.datagrid.articles.url.update",{page:1,type:a.key}),this.sandbox.emit("sulu.router.navigate",b,!1,!1),this.storage.set("type",a.key)},getCopyLocaleUrl:function(a,b,c){return e.getCopyLocaleUrl(a,b,c)},bindCustomEvents:function(){this.sandbox.on("husky.datagrid.articles.number.selections",function(a){var b=a>0?"enable":"disable";this.sandbox.emit("sulu.header.toolbar.item."+b,"deleteSelected",!1)}.bind(this)),this.sandbox.on("sulu.toolbar.delete",function(){this.sandbox.emit("husky.datagrid.articles.items.get-selected",this.deleteItems.bind(this))}.bind(this)),this.sandbox.on("sulu.header.language-changed",function(a){a.id!==this.options.locale&&(this.sandbox.sulu.saveUserSetting(this.options.config.settingsKey,a.id),this.toList(a.id))}.bind(this))},retrieveListToolbarTemplate:function(){return this.sandbox.sulu.buttons.get({contactIdFilter:{options:{icon:"filter",group:2,title:this.translations.filterAll,showTitle:!0,dropdownOptions:{preSelected:"all",idAttribute:"id",markSelected:!0,changeButton:!0,callback:function(a){this.applyFilterToList.call(this,a)}.bind(this)},dropdownItems:[{id:"me",title:this.translations.filterMe},{id:"all",title:this.translations.filterAll}]}}})},applyFilterToList:function(a){var b=null;if(a.id)switch(a.id){case"me":b=this.sandbox.sulu.user.id;break;default:b=null}this.sandbox.emit("husky.datagrid.articles.url.update",{contactId:b})}}});
\ No newline at end of file
diff --git a/Resources/public/js/components/articles/list/main.js b/Resources/public/js/components/articles/list/main.js
index f88b04c1f..05d77320b 100644
--- a/Resources/public/js/components/articles/list/main.js
+++ b/Resources/public/js/components/articles/list/main.js
@@ -43,6 +43,8 @@ define([
headline: 'sulu_article.list.title',
unpublished: 'public.unpublished',
publishedWithDraft: 'public.published-with-draft',
+ filterMe: 'sulu_article.list.filter.me',
+ filterAll: 'sulu_article.list.filter.all',
openGhostOverlay: {
info: 'sulu_article.settings.open-ghost-overlay.info',
new: 'sulu_article.settings.open-ghost-overlay.new',
@@ -170,17 +172,7 @@ define([
{
el: this.$find('.list-toolbar-container'),
instanceName: 'articles',
- template: this.sandbox.sulu.buttons.get({
- settings: {
- options: {
- dropdownItems: [
- {
- type: 'columnOptions'
- }
- ]
- }
- }
- })
+ template: this.retrieveListToolbarTemplate()
},
{
el: this.sandbox.dom.find('.datagrid-container'),
@@ -335,6 +327,63 @@ define([
this.sandbox.sulu.saveUserSetting(this.options.config.settingsKey, item.id);
this.toList(item.id);
}.bind(this));
+ },
+
+ /**
+ * Generates list toolbar buttons.
+ */
+ retrieveListToolbarTemplate: function() {
+ return this.sandbox.sulu.buttons.get({
+ contactIdFilter: {
+ options: {
+ icon: 'filter',
+ group: 2,
+ title: this.translations.filterAll,
+ showTitle: true,
+ dropdownOptions: {
+ preSelected: 'all',
+ idAttribute: 'id',
+ markSelected: true,
+ changeButton: true,
+ callback: function(item) {
+ this.applyFilterToList.call(this, item);
+ }.bind(this)
+ },
+ dropdownItems: [
+ {
+ id: 'me',
+ title: this.translations.filterMe
+ },
+ {
+ id: 'all',
+ title: this.translations.filterAll
+ }
+ ]
+ }
+ }
+ });
+ },
+
+ /**
+ * Emits the url update event for the list.
+ *
+ * @param item {Object}
+ */
+ applyFilterToList: function(item) {
+ var contactId = null;
+
+ if (!!item.id) {
+ switch(item.id) {
+ case 'me':
+ contactId = this.sandbox.sulu.user.id;
+ break;
+ default:
+ contactId = null;
+ break;
+ }
+ }
+
+ this.sandbox.emit('husky.datagrid.articles.url.update', {contactId: contactId});
}
};
});
diff --git a/Resources/translations/sulu/backend.de.xlf b/Resources/translations/sulu/backend.de.xlf
index f3037cc23..1ad153196 100644
--- a/Resources/translations/sulu/backend.de.xlf
+++ b/Resources/translations/sulu/backend.de.xlf
@@ -118,6 +118,14 @@
Autor (Alphabet)
+
+
+ Nur meine
+
+
+
+ Alle
+