Browse Source

Enable blog privacy feature, can be switched between private (presence only) and open

Complete the CHANGELOG
pull/1202/head
Timothée Jaussoin 3 years ago
parent
commit
5de63d07ed
  1. 4
      CHANGELOG.md
  2. 15
      app/widgets/CommunityPosts/CommunityPosts.php
  3. 5
      app/widgets/CommunityPosts/_communityposts_presencerequired.tpl
  4. 6
      app/widgets/CommunityPosts/locales.ini
  5. 39
      app/widgets/Config/Config.php
  6. 41
      app/widgets/Config/_config_blog.tpl
  7. 1
      app/widgets/Config/config.js
  8. 1
      app/widgets/Config/config.tpl
  9. 8
      app/widgets/Config/locales.ini
  10. 36
      composer.lock
  11. 4
      lib/moxl/src/Stanza/Pubsub.php
  12. 8
      lib/moxl/src/Xec/Action/Pubsub/GetItems.php
  13. 6
      lib/moxl/src/Xec/Handler.php

4
CHANGELOG.md

@ -3,6 +3,10 @@ Movim Changelog
v0.22 (trunk)
---------------------------
* Enable blog privacy feature, can be switched between private (presence only) and open
* Fix vcard-temp refresh
* Fix #1177 Refresh Ad-Hoc commande list when command finished
* Fix #1163 Ad-hoc command returns only one item (Prosŏdy)
v0.21.1
---------------------------

15
app/widgets/CommunityPosts/CommunityPosts.php

@ -18,6 +18,7 @@ class CommunityPosts extends Base
$this->registerEvent('pubsub_getitems_handle', 'onItemsId');
$this->registerEvent('pubsub_getitems_error', 'onItemsError');
$this->registerEvent('pubsub_getitemsid_error', 'onItemsError');
$this->registerEvent('pubsub_getitems_errorpresencesubscriptionrequired', 'onItemsErrorPresenceSubscriptionRequired');
$this->addjs('communityposts.js');
}
@ -30,6 +31,20 @@ class CommunityPosts extends Base
$this->displayItems($origin, $node, $ids, $first, $last, $count, $paginated, $before, $after, $query);
}
public function onItemsErrorPresenceSubscriptionRequired($packet)
{
list($origin, $node) = array_values($packet->content);
$view = $this->tpl();
$slugify = new Slugify;
$this->rpc(
'MovimTpl.fill',
'#communityposts.'.$slugify->slugify('c'.$origin.'_'.$node),
$view->draw('_communityposts_presencerequired')
);
}
public function onItemsError($packet)
{
list($origin, $node) = array_values($packet->content);

5
app/widgets/CommunityPosts/_communityposts_presencerequired.tpl

@ -0,0 +1,5 @@
<div class="placeholder">
<i class="material-icons">admin_panel_settings</i>
<h1>{$c->__('communityposts.presencerequired')}</h1>
<h4>{$c->__('communityposts.presencerequired_text')}</h4>
</div>

6
app/widgets/CommunityPosts/locales.ini

@ -1,3 +1,5 @@
[communityposts]
empty_me_text = No publication yet? Write your first post to make people discover your profile
empty_me_button = Publish my first post
empty_me_text = No publication yet? Write your first post to make people discover your profile
empty_me_button = Publish my first post
presencerequired = Private account
presencerequired_text = Follow it to see the content

39
app/widgets/Config/Config.php

@ -5,7 +5,8 @@ use Movim\Widget\Base;
use Moxl\Xec\Action\Storage\Set;
use Moxl\Xec\Action\MAM\GetConfig;
use Moxl\Xec\Action\MAM\SetConfig;
use Moxl\Xec\Action\Pubsub\GetConfig as PubsubGetConfig;
use Moxl\Xec\Action\Pubsub\SetConfig as PubsubSetConfig;
use Respect\Validation\Validator;
class Config extends Base
@ -15,6 +16,8 @@ class Config extends Base
$this->registerEvent('storage_set_handle', 'onConfig');
$this->registerEvent('mam_getconfig_handle', 'onMAMConfig');
$this->registerEvent('mam_setconfig_handle', 'onMAMConfigSaved');
$this->registerEvent('pubsub_getconfig_handle', 'onBlogConfig');
$this->registerEvent('pubsub_setconfig_handle', 'onBlogConfigSaved');
$this->addjs('config.js');
}
@ -53,6 +56,23 @@ class Config extends Base
Toast::send($this->__('config.mam_saved'));
}
public function onBlogConfigSaved()
{
Toast::send($this->__('config.blog_saved'));
}
public function onBlogConfig($package)
{
$view = $this->tpl();
$value = $package->content['config']->xpath('//field[@var=\'pubsub#access_model\']/value/text()');
if (is_array($value)) {
$view->assign('default', (string)$value[0]);
$this->rpc('MovimTpl.fill', '#config_widget_blog', $view->draw('_config_blog'));
}
}
public function ajaxMAMGetConfig()
{
if ($this->user->hasMAM()) {
@ -67,6 +87,23 @@ class Config extends Base
->request();
}
public function ajaxBlogGetConfig()
{
if ($this->user->hasPubsub()) {
(new PubsubGetConfig)->setNode('urn:xmpp:microblog:0')->request();
}
}
public function ajaxBlogSetConfig($data)
{
if ($this->user->hasPubsub()) {
$r = new PubsubSetConfig;
$r->setNode('urn:xmpp:microblog:0')
->setData($data)
->request();
}
}
public function ajaxSubmit($data)
{
if (!validateForm($data)) {

41
app/widgets/Config/_config_blog.tpl

@ -0,0 +1,41 @@
<form id="config_blog" onchange="Config_ajaxBlogSetConfig(MovimUtils.formToJson('config_blog'))">
<div>
<ul class="list middle labeled fill">
<li>
<span class="primary icon gray">
<i class="material-icons">public</i>
</span>
<span class="control">
<div class="radio">
<input name="pubsub#access_model" value="open"
id="access_model_open" type="radio"
{if="$default == 'open'"}checked{/if}>
<label for="access_model_open"></label>
</div>
</span>
<div>
<p>{$c->__('config.blog_open_title')}</p>
<p>{$c->__('config.blog_open_text')}</p>
</div>
</li>
<li>
<span class="primary icon gray">
<i class="material-icons">admin_panel_settings</i>
</span>
<span class="control">
<div class="radio">
<input name="pubsub#access_model" value="presence"
id="access_model_presence" type="radio"
{if="$default == 'presence'"}checked{/if}>
<label for="access_model_presence"></label>
</div>
</span>
<div>
<p>{$c->__('config.blog_presence_title')}</p>
<p>{$c->__('config.blog_presence_text')}</p>
</div>
</li>
</ul>
<label>{$c->__('config.blog_text')}</label>
</div>
</form>

1
app/widgets/Config/config.js

@ -7,4 +7,5 @@ var Config = {
MovimWebsocket.attach(function() {
Config_ajaxMAMGetConfig();
Config_ajaxBlogGetConfig();
});

1
app/widgets/Config/config.tpl

@ -1,4 +1,5 @@
<div class="tabelem padded_top_bottom" title="{$c->__('page.configuration')}" data-mobileicon="settings" id="config_widget">
<div id="config_widget_form">{autoescape="off"}{$form}{/autoescape}</div>
<div id="config_widget_mam"></div>
<div id="config_widget_blog"></div>
</div>

8
app/widgets/Config/locales.ini

@ -17,4 +17,10 @@ chatmain_text = Make the chat page as the default one
mam_text = Server-side archiving preferences
mam_always = Always
mam_never = Never
mam_saved = Archiving preferences saved
mam_saved = Archiving preferences saved
blog_text = Personnal blog confidentiality
blog_open_title = Public blog
blog_open_text = Accessible to everyone
blog_presence_title = Private blog
blog_presence_text = Restricted to subscribers only
blog_saved = Personnal blog confidentiality saved

36
composer.lock

@ -5061,16 +5061,16 @@
},
{
"name": "symfony/console",
"version": "v5.4.22",
"version": "v5.4.23",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "3cd51fd2e6c461ca678f84d419461281bd87a0a8"
"reference": "90f21e27d0d88ce38720556dd164d4a1e4c3934c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/3cd51fd2e6c461ca678f84d419461281bd87a0a8",
"reference": "3cd51fd2e6c461ca678f84d419461281bd87a0a8",
"url": "https://api.github.com/repos/symfony/console/zipball/90f21e27d0d88ce38720556dd164d4a1e4c3934c",
"reference": "90f21e27d0d88ce38720556dd164d4a1e4c3934c",
"shasum": ""
},
"require": {
@ -5140,7 +5140,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v5.4.22"
"source": "https://github.com/symfony/console/tree/v5.4.23"
},
"funding": [
{
@ -5156,7 +5156,7 @@
"type": "tidelift"
}
],
"time": "2023-03-25T09:27:28+00:00"
"time": "2023-04-24T18:47:29+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -5227,16 +5227,16 @@
},
{
"name": "symfony/filesystem",
"version": "v5.4.21",
"version": "v5.4.23",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "e75960b1bbfd2b8c9e483e0d74811d555ca3de9f"
"reference": "b2f79d86cd9e7de0fff6d03baa80eaed7a5f38b5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/e75960b1bbfd2b8c9e483e0d74811d555ca3de9f",
"reference": "e75960b1bbfd2b8c9e483e0d74811d555ca3de9f",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/b2f79d86cd9e7de0fff6d03baa80eaed7a5f38b5",
"reference": "b2f79d86cd9e7de0fff6d03baa80eaed7a5f38b5",
"shasum": ""
},
"require": {
@ -5271,7 +5271,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v5.4.21"
"source": "https://github.com/symfony/filesystem/tree/v5.4.23"
},
"funding": [
{
@ -5287,20 +5287,20 @@
"type": "tidelift"
}
],
"time": "2023-02-14T08:03:56+00:00"
"time": "2023-03-02T11:38:35+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v5.4.22",
"version": "v5.4.23",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "05cd1acdd0e3ce8473aaba1d86c188321d85f313"
"reference": "af9fbb378f5f956c8f29d4886644c84c193780ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/05cd1acdd0e3ce8473aaba1d86c188321d85f313",
"reference": "05cd1acdd0e3ce8473aaba1d86c188321d85f313",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/af9fbb378f5f956c8f29d4886644c84c193780ac",
"reference": "af9fbb378f5f956c8f29d4886644c84c193780ac",
"shasum": ""
},
"require": {
@ -5347,7 +5347,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-foundation/tree/v5.4.22"
"source": "https://github.com/symfony/http-foundation/tree/v5.4.23"
},
"funding": [
{
@ -5363,7 +5363,7 @@
"type": "tidelift"
}
],
"time": "2023-03-28T07:28:17+00:00"
"time": "2023-04-18T06:30:11+00:00"
},
{
"name": "symfony/polyfill-ctype",

4
lib/moxl/src/Stanza/Pubsub.php

@ -338,10 +338,10 @@ class Pubsub
*/
if ($node == 'urn:xmpp:microblog:0') {
$field = $dom->createElement('field');
/*$field = $dom->createElement('field');
$field->setAttribute('var', 'pubsub#access_model');
$field->appendChild($dom->createElement('value', 'presence'));
$x->appendChild($field);
$x->appendChild($field);*/
/*
$field = $dom->createElement('field');

8
lib/moxl/src/Xec/Action/Pubsub/GetItems.php

@ -136,4 +136,12 @@ class GetItems extends Action
$this->pack(['server' => $this->_to, 'node' => $this->_node]);
$this->deliver();
}
public function errorPresenceSubscriptionRequired(string $errorId, ?string $message = null)
{
$this->pack(['server' => $this->_to, 'node' => $this->_node]);
$this->deliver();
return false; // Don't proparage to the general error() handler
}
}

6
lib/moxl/src/Xec/Handler.php

@ -43,14 +43,16 @@ class Handler
\Utils::info('Handler : '.get_class($action).' '.$id.' - '.$errorid);
$propagate = true;
// If the action has defined a special handler for this error
if (method_exists($action, $errorid)) {
$action->method($errorid);
$action->$errorid($errorid, $message);
$propagate = $action->$errorid($errorid, $message);
}
// We also call a global error handler
if (method_exists($action, 'error')) {
if (method_exists($action, 'error') && $propagate == true) {
\Utils::info('Handler : Global error - '.$id.' - '.$errorid);
$action->method('error');
$action->error($errorid, $message);

Loading…
Cancel
Save