From d1576a61fff0fc4df5743dcc7da03134a029cd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Mon, 5 Dec 2016 09:23:25 +0100 Subject: [PATCH] First commit for the Community feature --- app/controllers/GroupController.php | 6 +- app/controllers/PostController.php | 15 ++ app/models/item/Item.php | 4 +- app/models/item/ItemDAO.php | 49 ++++-- app/views/group.tpl | 27 +++- app/views/news.tpl | 7 +- app/views/post.tpl | 16 ++ app/widgets/Communities/Communities.php | 61 ++++++++ app/widgets/Communities/_communities.tpl | 63 ++++++++ app/widgets/Communities/communities.js | 3 + app/widgets/Communities/communities.tpl | 1 + .../CommunitiesServer/CommunitiesServer.php | 143 ++++++++++++++++++ .../CommunitiesServer/_communitiesserver.tpl | 88 +++++++++++ .../_communitiesserver_add.tpl | 21 +++ .../CommunitiesServer/communitiesserver.js | 6 + .../CommunitiesServer/communitiesserver.tpl | 1 + .../CommunityAffiliations.php | 36 +++++ .../_communityaffiliations.tpl | 22 +++ .../communityaffiliations.tpl | 3 + app/widgets/CommunityData/CommunityData.php | 44 ++++++ app/widgets/CommunityData/_communitydata.tpl | 9 ++ app/widgets/CommunityData/communitydata.tpl | 3 + .../CommunityHeader/CommunityHeader.php | 47 ++++++ .../CommunityHeader/_communityheader.tpl | 36 +++++ .../CommunityHeader/communityheader.tpl | 3 + app/widgets/Group/Group.php | 141 ++++++++--------- app/widgets/Group/_group_header.tpl | 57 ------- app/widgets/Group/_group_posts.tpl | 19 +-- app/widgets/Group/group.js | 2 + app/widgets/Group/group.tpl | 5 +- app/widgets/Groups/Groups.php | 19 --- app/widgets/Menu/Menu.php | 8 + app/widgets/Menu/_menu_list.tpl | 49 ++++-- app/widgets/Menu/_menu_refresh.tpl | 2 +- app/widgets/Menu/menu.css | 4 - app/widgets/Navigation/navigation.tpl | 6 +- app/widgets/NewsNav/NewsNav.php | 22 +++ app/widgets/NewsNav/newsnav.tpl | 115 ++++++++++++++ app/widgets/Post/Post.php | 9 +- app/widgets/Post/_post.tpl | 2 +- app/widgets/Post/_post_card.tpl | 81 ++++++++++ linker.php | 4 +- locales/locales.ini | 1 + src/Movim/Bootstrap.php | 5 +- src/Movim/Route.php | 1 + themes/material/css/article.css | 23 +++ themes/material/css/icon.css | 4 + themes/material/css/listn.css | 2 +- themes/material/css/style.css | 33 +++- 49 files changed, 1099 insertions(+), 229 deletions(-) create mode 100644 app/controllers/PostController.php create mode 100644 app/views/post.tpl create mode 100644 app/widgets/Communities/Communities.php create mode 100644 app/widgets/Communities/_communities.tpl create mode 100644 app/widgets/Communities/communities.js create mode 100644 app/widgets/Communities/communities.tpl create mode 100644 app/widgets/CommunitiesServer/CommunitiesServer.php create mode 100644 app/widgets/CommunitiesServer/_communitiesserver.tpl create mode 100644 app/widgets/CommunitiesServer/_communitiesserver_add.tpl create mode 100644 app/widgets/CommunitiesServer/communitiesserver.js create mode 100644 app/widgets/CommunitiesServer/communitiesserver.tpl create mode 100644 app/widgets/CommunityAffiliations/CommunityAffiliations.php create mode 100644 app/widgets/CommunityAffiliations/_communityaffiliations.tpl create mode 100644 app/widgets/CommunityAffiliations/communityaffiliations.tpl create mode 100644 app/widgets/CommunityData/CommunityData.php create mode 100644 app/widgets/CommunityData/_communitydata.tpl create mode 100644 app/widgets/CommunityData/communitydata.tpl create mode 100644 app/widgets/CommunityHeader/CommunityHeader.php create mode 100644 app/widgets/CommunityHeader/_communityheader.tpl create mode 100644 app/widgets/CommunityHeader/communityheader.tpl delete mode 100644 app/widgets/Group/_group_header.tpl create mode 100644 app/widgets/NewsNav/NewsNav.php create mode 100644 app/widgets/NewsNav/newsnav.tpl create mode 100644 app/widgets/Post/_post_card.tpl diff --git a/app/controllers/GroupController.php b/app/controllers/GroupController.php index d9e09b3ed..889c63252 100644 --- a/app/controllers/GroupController.php +++ b/app/controllers/GroupController.php @@ -3,11 +3,13 @@ use Movim\Controller\Base; class GroupController extends Base { - function load() { + function load() + { $this->session_only = true; } - function dispatch() { + function dispatch() + { $this->page->setTitle(__('page.groups')); $user = new User(); diff --git a/app/controllers/PostController.php b/app/controllers/PostController.php new file mode 100644 index 000000000..60ed5bca3 --- /dev/null +++ b/app/controllers/PostController.php @@ -0,0 +1,15 @@ +session_only = true; + } + + function dispatch() + { + $this->page->setTitle(__('page.post')); + } +} diff --git a/app/models/item/Item.php b/app/models/item/Item.php index 984522a33..d21d4c261 100644 --- a/app/models/item/Item.php +++ b/app/models/item/Item.php @@ -128,10 +128,10 @@ class Item extends Model } } - public function getLogo() + public function getLogo($size = 120) { $p = new Picture; - return $p->get($this->server.$this->node, 120); + return $p->get($this->server.$this->node, $size); } public function getName() diff --git a/app/models/item/ItemDAO.php b/app/models/item/ItemDAO.php index 731581f80..242c084e7 100644 --- a/app/models/item/ItemDAO.php +++ b/app/models/item/ItemDAO.php @@ -91,9 +91,9 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'node' => 'urn:xmpp:microblog:0:comments%' - ) + ] ); return $this->run('Server'); @@ -172,9 +172,9 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'server' => $server - ) + ] ); return $this->run('Item'); @@ -190,9 +190,9 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'server' => $server - ) + ] ); return $this->run('Item', 'item'); @@ -207,9 +207,9 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'server' => $server - ) + ] ); return $this->run('Item', 'item'); @@ -230,9 +230,9 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'node' => 'urn:xmpp:microblog%' - ) + ] ); return $this->run('Item'); @@ -245,9 +245,9 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'server' => $server - ) + ] ); return $this->run('Item'); @@ -261,15 +261,32 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'server' => $server, 'node' => $item - ) + ] ); return $this->run('Item'); } + function getJid($jid) { + $this->_sql = ' + select * from item + where + jid = :jid + and node = \'\''; + + $this->prepare( + 'Item', + [ + 'jid' => $jid + ] + ); + + return $this->run('Item', 'item'); + } + function getItem($server, $item) { $this->_sql = ' select * from item @@ -279,10 +296,10 @@ class ItemDAO extends SQL $this->prepare( 'Item', - array( + [ 'node' => $item, 'server' => $server - ) + ] ); return $this->run('Item', 'item'); diff --git a/app/views/group.tpl b/app/views/group.tpl index 5805c7932..37762ca12 100644 --- a/app/views/group.tpl +++ b/app/views/group.tpl @@ -9,9 +9,28 @@
-
- widget('Groups'); ?> - widget('Group'); ?> - widget('Publish'); ?> +
+ + + widget('Communities'); ?> + + + widget('CommunitiesServer'); ?> + + +
+ widget('CommunityHeader'); ?> + widget('Groups'); ?> + widget('Group'); ?> + widget('Publish'); ?> +
+
diff --git a/app/views/news.tpl b/app/views/news.tpl index 5ea70d41f..4ac0e2d07 100644 --- a/app/views/news.tpl +++ b/app/views/news.tpl @@ -10,9 +10,10 @@
-
+
+ widget('Menu');?> - widget('Post');?> - widget('Publish');?> + widget('Post');?> + widget('Publish');?>
diff --git a/app/views/post.tpl b/app/views/post.tpl new file mode 100644 index 000000000..dbebf8a1f --- /dev/null +++ b/app/views/post.tpl @@ -0,0 +1,16 @@ +widget('Init');?> +widget('VisioLink');?> +widget('Notification');?> +widget('Upload');?> +widget('Search');?> + + + +
+
+ widget('Post');?> +
+
diff --git a/app/widgets/Communities/Communities.php b/app/widgets/Communities/Communities.php new file mode 100644 index 000000000..b04a27a18 --- /dev/null +++ b/app/widgets/Communities/Communities.php @@ -0,0 +1,61 @@ +registerEvent('disco_items_handle', 'onDisco'); + $this->addjs('communities.js'); + } + + function onDisco($packet) + { + $this->ajaxGet(); + } + + function ajaxDisco($server) + { + if(!$this->validateServer($server)) { + Notification::append(null, $this->__('groups.disco_error')); + return; + } + + RPC::call('MovimTpl.fill', '#groups_widget', ''); + + $r = new Items; + $r->setTo($server)->request(); + } + + function ajaxGet() + { + RPC::call('MovimTpl.fill', '#communities', $this->prepareCommunities()); + } + + function prepareCommunities() + { + $id = new \Modl\ItemDAO(); + + $view = $this->tpl(); + $view->assign('servers', $id->getGroupServers()); + + return $view->draw('_communities', true); + } + + /** + * @brief Validate the server + * + * @param string $server + */ + private function validateServer($server) + { + $validate_server = Validator::noWhitespace()->alnum('.-_')->length(6, 40); + return ($validate_server->validate($server)); + } + + public function display() + { + } +} diff --git a/app/widgets/Communities/_communities.tpl b/app/widgets/Communities/_communities.tpl new file mode 100644 index 000000000..7a79036f7 --- /dev/null +++ b/app/widgets/Communities/_communities.tpl @@ -0,0 +1,63 @@ +
+ +
+ + diff --git a/app/widgets/Communities/communities.js b/app/widgets/Communities/communities.js new file mode 100644 index 000000000..1104786d9 --- /dev/null +++ b/app/widgets/Communities/communities.js @@ -0,0 +1,3 @@ +MovimWebsocket.attach(function() { + Communities_ajaxGet(); +}); diff --git a/app/widgets/Communities/communities.tpl b/app/widgets/Communities/communities.tpl new file mode 100644 index 000000000..783f2bb49 --- /dev/null +++ b/app/widgets/Communities/communities.tpl @@ -0,0 +1 @@ +
diff --git a/app/widgets/CommunitiesServer/CommunitiesServer.php b/app/widgets/CommunitiesServer/CommunitiesServer.php new file mode 100644 index 000000000..52faa0b24 --- /dev/null +++ b/app/widgets/CommunitiesServer/CommunitiesServer.php @@ -0,0 +1,143 @@ +registerEvent('disco_items_handle', 'onDisco'); + $this->registerEvent('disco_items_error', 'onDiscoError'); + $this->registerEvent('pubsub_create_handle', 'onCreate'); + $this->registerEvent('pubsub_testcreate_handle', 'onTestCreate'); + $this->registerEvent('pubsub_testcreate_error', 'onTestCreateError'); + + $this->addjs('communitiesserver.js'); + } + + function onCreate($packet) + { + Notification::append(null, $this->__('groups.created')); + + list($server, $node) = array_values($packet->content); + $this->ajaxDisco($server); + } + + function onDisco($packet) + { + $server = $packet->content; + + RPC::call('MovimTpl.fill', '#communities_server', $this->prepareCommunitiesServer($server)); + } + + function onDiscoError($packet) + { + $server = $packet->content; + + $id = new \Modl\ItemDAO(); + $id->deleteItems($server); + + RPC::call('MovimTpl.fill', '#communities_server', $this->prepareCommunitiesServer($server)); + + Notification::append(null, $this->__('groups.disco_error')); + } + + function onTestCreate($packet) + { + $server = $packet->content; + + $view = $this->tpl(); + $view->assign('server', $server); + + Dialog::fill($view->draw('_communitiesserver_add', true)); + } + + function onTestCreateError($packet) + { + Notification::append(null, $this->__('groups.no_creation')); + } + + function ajaxDisco($server) + { + if(!$this->validateServer($server)) { + Notification::append(null, $this->__('groups.disco_error')); + return; + } + + RPC::call('MovimTpl.fill', '#communities_server', ''); + + $r = new Items; + $r->setTo($server)->request(); + } + + /* + * Seriously ? We need to put this hack because of buggy XEP-0060... + */ + function ajaxTestAdd($server) + { + if(!$this->validateServer($server)) return; + + $t = new TestCreate; + $t->setTo($server) + ->request(); + } + + function ajaxAddConfirm($server, $form) + { + if(!$this->validateServer($server)) return; + + $validate_name = Validator::stringType()->length(4, 80); + if(!$validate_name->validate($form->name->value)) { + Notification::append(null, $this->__('groups.name_error')); + return; + } + + $slugify = new Slugify(); + $uri = $slugify->slugify($form->name->value); + + if($uri == '') { + Notification::append(null, $this->__('groups.name_error')); + return; + } + + $c = new Create; + $c->setTo($server) + ->setNode($uri) + ->setName($form->name->value) + ->request(); + } + + public function prepareCommunitiesServer($server) + { + $id = new \Modl\ItemDAO; + + $view = $this->tpl(); + $view->assign('item', $id->getJid($server)); + $view->assign('nodes', $id->getItems($server)); + $view->assign('server', $server); + + return $view->draw('_communitiesserver', true); + } + + /** + * @brief Validate the server + * + * @param string $server + */ + private function validateServer($server) + { + $validate_server = Validator::noWhitespace()->alnum('.-_')->length(6, 40); + return ($validate_server->validate($server)); + } + + public function display() + { + $this->view->assign('server', $this->get('s')); + } +} diff --git a/app/widgets/CommunitiesServer/_communitiesserver.tpl b/app/widgets/CommunitiesServer/_communitiesserver.tpl new file mode 100644 index 000000000..0893d9fbd --- /dev/null +++ b/app/widgets/CommunitiesServer/_communitiesserver.tpl @@ -0,0 +1,88 @@ +
+ +
+{if="$nodes == null"} + +{else} + +{/if} + + + diff --git a/app/widgets/CommunitiesServer/_communitiesserver_add.tpl b/app/widgets/CommunitiesServer/_communitiesserver_add.tpl new file mode 100644 index 000000000..7d36c06ef --- /dev/null +++ b/app/widgets/CommunitiesServer/_communitiesserver_add.tpl @@ -0,0 +1,21 @@ +
+
+

{$c->__('groups.add', $server)}

+ +
+ + +
+
+
+ + {$c->__('button.close')} + + + {$c->__('button.add')} + +
+ + diff --git a/app/widgets/CommunitiesServer/communitiesserver.js b/app/widgets/CommunitiesServer/communitiesserver.js new file mode 100644 index 000000000..a353015fa --- /dev/null +++ b/app/widgets/CommunitiesServer/communitiesserver.js @@ -0,0 +1,6 @@ +MovimWebsocket.attach(function() { + var parts = MovimUtils.urlParts(); + if(parts.params.length > 0) { + CommunitiesServer_ajaxDisco(parts.params[0]); + } +}); diff --git a/app/widgets/CommunitiesServer/communitiesserver.tpl b/app/widgets/CommunitiesServer/communitiesserver.tpl new file mode 100644 index 000000000..08e0840d6 --- /dev/null +++ b/app/widgets/CommunitiesServer/communitiesserver.tpl @@ -0,0 +1 @@ +
diff --git a/app/widgets/CommunityAffiliations/CommunityAffiliations.php b/app/widgets/CommunityAffiliations/CommunityAffiliations.php new file mode 100644 index 000000000..d2e799dca --- /dev/null +++ b/app/widgets/CommunityAffiliations/CommunityAffiliations.php @@ -0,0 +1,36 @@ +registerEvent('pubsub_getaffiliations_handle', 'onAffiliations'); + } + + function onAffiliations($packet) + { + list($affiliations, $server, $node) = array_values($packet->content); + + $role = null; + + foreach($affiliations as $r) { + if($r[0] == $this->user->getLogin()) + $role = (string)$r[1]; + } + + $id = new \Modl\ItemDAO; + $item = $id->getItem($server, $node); + + $view = $this->tpl(); + $view->assign('role', $role); + $view->assign('item', $item); + + RPC::call('MovimTpl.fill', '#community_affiliation', $view->draw('_communityaffiliations', true)); + } + + public function display() + { + } +} diff --git a/app/widgets/CommunityAffiliations/_communityaffiliations.tpl b/app/widgets/CommunityAffiliations/_communityaffiliations.tpl new file mode 100644 index 000000000..6c5f1f3ec --- /dev/null +++ b/app/widgets/CommunityAffiliations/_communityaffiliations.tpl @@ -0,0 +1,22 @@ +{if="$role == 'owner'"} + +{/if} diff --git a/app/widgets/CommunityAffiliations/communityaffiliations.tpl b/app/widgets/CommunityAffiliations/communityaffiliations.tpl new file mode 100644 index 000000000..a61b5d861 --- /dev/null +++ b/app/widgets/CommunityAffiliations/communityaffiliations.tpl @@ -0,0 +1,3 @@ + diff --git a/app/widgets/CommunityData/CommunityData.php b/app/widgets/CommunityData/CommunityData.php new file mode 100644 index 000000000..fb602656e --- /dev/null +++ b/app/widgets/CommunityData/CommunityData.php @@ -0,0 +1,44 @@ +registerEvent('pubsub_getmetadata_handle', 'onMetadata'); + } + + function onMetadata($packet) + { + list($server, $node) = $packet->content; + + RPC::call('MovimTpl.fill', '#community_data', $this->prepareData($server, $node)); + } + + public function prepareData($server, $node) + { + $id = new \Modl\ItemDAO; + $item = $id->getItem($server, $node); + + if($item && !$item->logo) { + $item->setPicture(); + $id->set($item); + } + + $pd = new \Modl\SubscriptionDAO; + $subscription = $pd->get($server, $node); + + $view = $this->tpl(); + $view->assign('item', $item); + $view->assign('subscription', $subscription); + + return $view->draw('_communitydata', true); + } + + public function display() + { + $this->view->assign('server', $this->get('s')); + $this->view->assign('node', $this->get('n')); + } +} diff --git a/app/widgets/CommunityData/_communitydata.tpl b/app/widgets/CommunityData/_communitydata.tpl new file mode 100644 index 000000000..df4f35b7a --- /dev/null +++ b/app/widgets/CommunityData/_communitydata.tpl @@ -0,0 +1,9 @@ +
+{if="$item->logo"} +
  • +

    + +

    +

    {$item->created|strtotime|prepareDate:true,true}

    +
  • +{/if} diff --git a/app/widgets/CommunityData/communitydata.tpl b/app/widgets/CommunityData/communitydata.tpl new file mode 100644 index 000000000..fda7617aa --- /dev/null +++ b/app/widgets/CommunityData/communitydata.tpl @@ -0,0 +1,3 @@ + diff --git a/app/widgets/CommunityHeader/CommunityHeader.php b/app/widgets/CommunityHeader/CommunityHeader.php new file mode 100644 index 000000000..ed7d9e34c --- /dev/null +++ b/app/widgets/CommunityHeader/CommunityHeader.php @@ -0,0 +1,47 @@ +registerEvent('pubsub_getmetadata_handle', 'onMetadata'); + } + + function onMetadata($packet) + { + list($server, $node) = $packet->content; + + RPC::call('MovimTpl.fill', '#community_header', $this->prepareHeader($server, $node)); + } + + public function prepareHeader($server, $node) + { + $id = new \Modl\ItemDAO; + $item = $id->getItem($server, $node); + + if($item && !$item->logo) { + $item->setPicture(); + $id->set($item); + } + + $pd = new \Modl\SubscriptionDAO; + $subscription = $pd->get($server, $node); + + $view = $this->tpl(); + + $view->assign('item', $item); + $view->assign('subscription', $subscription); + $view->assign('node', $node); + $view->assign('server', $server); + + return $view->draw('_communityheader', true); + } + + public function display() + { + $this->view->assign('server', $this->get('s')); + $this->view->assign('node', $this->get('n')); + } +} diff --git a/app/widgets/CommunityHeader/_communityheader.tpl b/app/widgets/CommunityHeader/_communityheader.tpl new file mode 100644 index 000000000..af71a71cb --- /dev/null +++ b/app/widgets/CommunityHeader/_communityheader.tpl @@ -0,0 +1,36 @@ + diff --git a/app/widgets/CommunityHeader/communityheader.tpl b/app/widgets/CommunityHeader/communityheader.tpl new file mode 100644 index 000000000..df1ca7fd1 --- /dev/null +++ b/app/widgets/CommunityHeader/communityheader.tpl @@ -0,0 +1,3 @@ +
    + {$c->prepareHeader($server, $node)} +
    diff --git a/app/widgets/Group/Group.php b/app/widgets/Group/Group.php index 089ee7a12..eb94fcee5 100644 --- a/app/widgets/Group/Group.php +++ b/app/widgets/Group/Group.php @@ -18,6 +18,8 @@ use Moxl\Xec\Action\Pubsub\Delete; use Respect\Validation\Validator; use Cocur\Slugify\Slugify; +include_once WIDGETS_PATH.'Post/Post.php'; + class Group extends \Movim\Widget\Base { private $_paging = 8; @@ -25,24 +27,27 @@ class Group extends \Movim\Widget\Base function load() { - $this->registerEvent('pubsub_getitem_handle', 'onItems', 'groups'); - $this->registerEvent('pubsub_getitems_handle', 'onItems', 'groups'); - $this->registerEvent('pubsub_getitemsid_handle', 'onItems', 'groups'); - $this->registerEvent('pubsub_getitems_error', 'onItemsError', 'groups'); - $this->registerEvent('pubsub_getitemsid_error', 'onItemsError', 'groups'); - $this->registerEvent('pubsub_getmetadata_handle', 'onMetadata', 'groups'); + $this->registerEvent('pubsub_getitem_handle', 'onItems'); + $this->registerEvent('pubsub_getitems_handle', 'onItems'); + $this->registerEvent('pubsub_getitemsid_handle', 'onItems'); + $this->registerEvent('pubsub_getitems_error', 'onItemsError'); + $this->registerEvent('pubsub_getitemsid_error', 'onItemsError'); +// $this->registerEvent('pubsub_getmetadata_handle', 'onMetadata'); $this->registerEvent('pubsub_subscribe_handle', 'onSubscribed'); $this->registerEvent('pubsub_unsubscribe_handle', 'onUnsubscribed'); - $this->registerEvent('pubsub_getaffiliations_handle', 'onAffiliations'); + //$this->registerEvent('pubsub_getaffiliations_handle', 'onAffiliations'); $this->registerEvent('pubsub_getsubscriptions_handle', 'onSubscriptions'); - $this->registerEvent('disco_items_handle', 'onDisco', 'groups'); - $this->registerEvent('pubsub_delete_handle', 'onDisco'); + //$this->registerEvent('disco_items_handle', 'onDisco', 'groups'); + //$this->registerEvent('pubsub_delete_handle', 'onDisco'); $this->registerEvent('pubsub_getconfig_handle', 'onConfig'); $this->registerEvent('pubsub_setconfig_handle', 'onConfigSaved'); - $this->registerEvent('bookmark_set_handle', 'onBookmark'); + + $this->registerEvent('pubsub_delete_handle', 'onDelete'); + $this->registerEvent('pubsub_delete_error', 'onDeleteError'); + //$this->registerEvent('bookmark_set_handle', 'onBookmark'); $this->addjs('group.js'); } @@ -51,27 +56,27 @@ class Group extends \Movim\Widget\Base list($server, $node) = array_values($packet->content); $this->ajaxGetMetadata($server, $node); - $this->ajaxGetAffiliations($server, $node); + //$this->ajaxGetAffiliations($server, $node); $this->displayItems($server, $node); - RPC::call('Group.clearLoad'); - RPC::call('MovimTpl.showPanel'); + //RPC::call('Group.clearLoad'); + //RPC::call('MovimTpl.showPanel'); } - function onDisco($packet) + /*function onDisco($packet) { $this->ajaxClear(); - } + }*/ - function onBookmark() + /*function onBookmark() { $this->ajaxClear(); $g = new Groups; $g->ajaxHeader(); $g->ajaxSubscriptions(); - } + }*/ function onItemsError($packet) { @@ -94,33 +99,6 @@ class Group extends \Movim\Widget\Base } } - function onMetadata($packet) - { - list($server, $node) = $packet->content; - - RPC::call('MovimTpl.fill', '#group_widget > header', $this->prepareHeader($server, $node)); - } - - function onAffiliations($packet) - { - list($affiliations, $server, $node) = array_values($packet->content); - - foreach($affiliations as $r) { - if($r[0] == $this->user->getLogin()) - $this->_role = (string)$r[1]; - } - - RPC::call('MovimTpl.fill', '#group_widget > header', $this->prepareHeader($server, $node)); - - //if(isset($this->_role) - //&& ($this->_role == 'owner' || $this->_role == 'publisher')) { - // $view = $this->tpl(); - // $view->assign('server', $server); - // $view->assign('node', $node); - // RPC::call('MovimTpl.append', '#group_widget', $view->draw('_group_publish', true)); - //} - } - function onSubscriptions($packet) { list($subscriptions, $server, $node) = array_values($packet->content); @@ -158,12 +136,14 @@ class Group extends \Movim\Widget\Base function onSubscribed($packet) { - $arr = $packet->content; + list($server, $node) = array_values($packet->content); // Set the bookmark $r = new Rooms; $r->setBookmark(); + $this->ajaxGetMetadata($server, $node); + Notification::append(null, $this->__('group.subscribed')); // Set the public list @@ -183,19 +163,43 @@ class Group extends \Movim\Widget\Base function onUnsubscribed($packet) { + list($server, $node) = array_values($packet->content); + // Set the bookmark $r = new Rooms; $r->setBookmark(); + $this->ajaxGetMetadata($server, $node); + Notification::append(null, $this->__('group.unsubscribed')); } + function onDelete($packet) + { + Notification::append(null, $this->__('groups.deleted')); + + list($server, $node) = array_values($packet->content); + $this->rpc('MovimUtils.redirect', $this->route('group', $server)); + //$this->displayServer($server); + } + + function onDeleteError($packet) + { + Notification::append(null, $this->__('groups.deleted')); + + $m = new Rooms; + $m->setBookmark(); + + list($server, $node) = array_values($packet->content); + $this->rpc('MovimUtils.redirect', $this->route('group', $server)); + //$this->ajaxSubscriptions(); + } + private function displayItems($server, $node) { if(!$this->validateServerNode($server, $node)) return; $html = $this->prepareGroup($server, $node); - $slugify = new Slugify(); RPC::call('MovimTpl.fill', '#group_widget.'.$slugify->slugify($server.'_'.$node), $html); @@ -262,9 +266,9 @@ class Group extends \Movim\Widget\Base if(!$this->validateServerNode($server, $node)) return; $slugify = new Slugify(); - RPC::call('Group.addLoad', $slugify->slugify($server.'_'.$node)); - RPC::call('MovimUtils.pushState', $this->route('group', [$server, $node])); - RPC::call('MovimTpl.fill', '#group_widget.'.$slugify->slugify($server.'_'.$node), ''); + //RPC::call('Group.addLoad', $slugify->slugify($server.'_'.$node)); + //RPC::call('MovimUtils.pushState', $this->route('group', [$server, $node])); + //RPC::call('MovimTpl.fill', '#group_widget.'.$slugify->slugify($server.'_'.$node), ''); $r = new GetItemsId; $r->setTo($server) @@ -402,45 +406,29 @@ class Group extends \Movim\Widget\Base return $html; } - /* public function preparePost($p) { - $pw = new Post; - return $pw->preparePost($p, true); + $pw = new \Post; + return $pw->preparePost($p, true, true, true); } - */ - private function prepareHeader($server, $node) + private function prepareGroup($server, $node, $page = 0) { + $pd = new \Modl\PostnDAO; + $posts = $pd->getNodeUnfiltered($server, $node, $page*$this->_paging, $this->_paging); + $id = new \Modl\ItemDAO; $item = $id->getItem($server, $node); - if($item && !$item->logo) { - $item->setPicture(); - $id->set($item); - } - $pd = new \Modl\SubscriptionDAO; $subscription = $pd->get($server, $node); - $view = $this->tpl(); - - $view->assign('item', $item); - $view->assign('subscription', $subscription); - $view->assign('role', $this->_role); - - return $view->draw('_group_header', true); - } - - private function prepareGroup($server, $node, $page = 0) - { - $pd = new \Modl\PostnDAO; - $posts = $pd->getNodeUnfiltered($server, $node, $page*$this->_paging, $this->_paging); - $view = $this->tpl(); $view->assign('server', $server); $view->assign('node', $node); $view->assign('page', $page); $view->assign('posts', $posts); + $view->assign('item', $item); + $view->assign('subscription', $subscription); $view->assign('paging', $this->_paging); $html = $view->draw('_group_posts', true); @@ -467,11 +455,14 @@ class Group extends \Movim\Widget\Base function display() { - $this->view->assign('server', false); + $slugify = new Slugify(); + /*$this->view->assign('server', false); $this->view->assign('node', false); if($this->validateServerNode($this->get('s'), $this->get('n'))) { $this->view->assign('server', $this->get('s')); $this->view->assign('node', $this->get('n')); - } + }*/ + $this->view->assign('class', $slugify->slugify($this->get('s').'_'.$this->get('n'))); + $this->view->assign('html', $this->prepareGroup($this->get('s'), $this->get('n'))); } } diff --git a/app/widgets/Group/_group_header.tpl b/app/widgets/Group/_group_header.tpl deleted file mode 100644 index 9dcdede8b..000000000 --- a/app/widgets/Group/_group_header.tpl +++ /dev/null @@ -1,57 +0,0 @@ - - -{if="$role == 'owner'"} - -{/if} - - - - diff --git a/app/widgets/Group/_group_posts.tpl b/app/widgets/Group/_group_posts.tpl index fb0efefb7..58fabf8e9 100644 --- a/app/widgets/Group/_group_posts.tpl +++ b/app/widgets/Group/_group_posts.tpl @@ -1,19 +1,7 @@ -{if="$page == 0"} -
    - -
    -{/if} - {if="!empty($posts)"} - {/if} @@ -26,11 +40,11 @@ {if="$items"} {if="$page == 0"} - + {/if} {elseif="$page == 0"} diff --git a/app/widgets/Menu/_menu_refresh.tpl b/app/widgets/Menu/_menu_refresh.tpl index 82fc1ba0b..40ec58bfd 100644 --- a/app/widgets/Menu/_menu_refresh.tpl +++ b/app/widgets/Menu/_menu_refresh.tpl @@ -1,4 +1,4 @@ -