Permalink
Browse files

Merge pull request #1190 from matzoman/Retroactive-posse

Retroactive posse
  • Loading branch information...
benwerd committed Feb 5, 2016
2 parents 56df186 + d64ceb3 commit d685c6a5a78acf1795eb36d61aeb67739ff39990
View
@@ -427,16 +427,36 @@ function getNotificationTitle()
return '';
}
/**
* Saves this entity - either creating a new entry, or
* overwriting the existing one.
* Publishes this entity - either creating a new entry, or
* overwriting the existing one. Then it will add it optionally
* to the feed
* Finally it will syndicate the entity
*
* @param bool $add_to_feed If set to true, will add this item to the activity stream feed if this object is being newly created
* @param string $feed_verb If this item is added to the feed, this is the verb that will be used
*/
function publish($add_to_feed = false, $feed_verb = 'post')
{
if ($this->save()) {
if ($add_to_feed) {
$this->addToFeed($feed_verb);
}
$this->syndicate();
return true;
} else {
return false;
}
}
/**
* Saves this entity - either creating a new entry, or
* overwriting the existing one.
*
*/
function save($add_to_feed = false, $feed_verb = 'post')
function save()
{
// Adding this entity's owner (if we don't know already)
@@ -489,10 +509,6 @@ function save($add_to_feed = false, $feed_verb = 'post')
$this->_id = $result;
$this->uuid = $this->getUUID();
\Idno\Core\Idno::site()->db()->saveObject($this);
if ($add_to_feed) {
$this->addToFeed($feed_verb);
}
$this->syndicate();
\Idno\Core\Idno::site()->triggerEvent('saved', ['object' => $this]);
} else {
\Idno\Core\Idno::site()->triggerEvent('updated', ['object' => $this]);
View
@@ -103,11 +103,14 @@ function drawPage($echo = true)
/**
* Draw syndication buttons relating to a particular content type
* @param $content_type
* @param $posse_links containing Entity::getPosseLinks()
* @return \Bonita\false|string
*/
function drawSyndication($content_type)
function drawSyndication($content_type, $posse_links)
{
return $this->__(array('services' => \Idno\Core\Idno::site()->syndication()->getServices($content_type), 'content_type' => $content_type))->draw('content/syndication');
return $this->__(array('services' => \Idno\Core\Idno::site()->syndication()->getServices($content_type),
'content_type' => $content_type,
'posseLinks' => $posse_links))->draw('content/syndication');
}
/**
@@ -62,7 +62,7 @@ function saveDataFromInput()
$this->address = $user_address;
$this->setAccess($access);
$this->tags = $tags;
if ($this->save($new)) {
if ($this->publish($new)) {
if ($new && $access == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
}
@@ -152,7 +152,7 @@ function errorPosition() {
])->draw('forms/input/richtext')?>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to" value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?=$this->draw('entity/tags/input');?>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('place'); ?>
<?php echo $this->drawSyndication('place', $vars['object']->getPosseLinks()); ?>
<?= $this->draw('content/access'); ?>
<p class="button-bar ">
<input type="button" class="btn btn-cancel" value="Cancel" onclick="hideContentCreateForm();"/>
@@ -84,7 +84,7 @@ function saveDataFromInput()
}
}
$this->setAccess(\Idno\Core\Idno::site()->currentPage()->getInput('access','PUBLIC'));
if ($this->save($new)) {
if ($this->publish($new)) {
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
@@ -48,7 +48,7 @@
</div>
<?=$this->draw('entity/tags/input');?>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to" value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('article'); ?>
<?php echo $this->drawSyndication('article', $vars['object']->getPosseLinks()); ?>
<p>
<?= \Idno\Core\Idno::site()->actions()->signForm('/text/edit') ?>
<input type="submit" class="btn btn-primary" value="Save" />
@@ -70,7 +70,7 @@ function saveDataFromInput() {
}
$this->setAccess($access);
if ($this->save($new)) {
if ($this->publish($new)) {
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
}
@@ -73,7 +73,7 @@ function saveDataFromInput() {
$this->rsvp = $rsvp;
$this->inreplyto = \Idno\Core\Idno::site()->currentPage()->getInput('inreplyto');
$this->setAccess($access);
if ($this->save($new)) {
if ($this->publish($new)) {
if ($access == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
}
@@ -43,7 +43,7 @@
<input type="text" name="endtime" id="endtime" placeholder="Type in the end day and time" value="<?=htmlspecialchars($vars['object']->endtime)?>" class="form-control" />
</div>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('event'); ?>
<?php echo $this->drawSyndication('event', $vars['object']->getPosseLinks()); ?>
</div>
<div class="col-md-4 ">
@@ -39,7 +39,7 @@
</div>
<?=$this->draw('entity/tags/input');?>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to" value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('note'); ?>
<?php echo $this->drawSyndication('note', $vars['object']->getPosseLinks()); ?>
<?= $this->draw('content/access'); ?>
<p class="button-bar">
<?= \Idno\Core\Idno::site()->actions()->signForm('/status/edit') ?>
@@ -120,7 +120,7 @@ function saveDataFromInput() {
return false;
}
$this->setAccess($access);
if ($this->save($new)) {
if ($this->publish($new)) {
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
}
@@ -67,7 +67,7 @@
])->draw('forms/input/richtext') ?>
</div>
<?= $this->draw('entity/tags/input'); ?>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('bookmark'); ?>
<?php echo $this->drawSyndication('bookmark', $vars['object']->getPosseLinks()); ?>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to"
value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?= $this->draw('content/access'); ?>
@@ -131,7 +131,7 @@ function saveDataFromInput()
return false;
}
if ($this->save($new)) {
if ($this->publish($new)) {
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
@@ -52,7 +52,7 @@
'label' => 'Description',
])->draw('forms/input/richtext')?>
<?=$this->draw('entity/tags/input');?>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('media'); ?>
<?php echo $this->drawSyndication('media', $vars['object']->getPosseLinks()); ?>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to" value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?= $this->draw('content/access'); ?>
<p class="button-bar ">
@@ -161,7 +161,7 @@ function saveDataFromInput()
}
}
if ($this->save($new)) {
if ($this->publish($new)) {
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
@@ -79,8 +79,8 @@ class="col-md-9 form-control"
<small><a href="#" onclick="$('#photo-details').show(); $('#photo-details-toggle').hide(); return false;">+ Add details</a></small>
</p>
</div>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('image'); ?>
<?php echo $this->drawSyndication('image', $vars['object']->getPosseLinks()); ?>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to"
value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?= $this->draw('content/access'); ?>
@@ -115,7 +115,7 @@ function saveDataFromInput()
$this->hide_title = $hide_title;
$this->setAccess($access);
if ($result = $this->save()) {
if ($result = $this->publish()) {
return true;
}
@@ -105,7 +105,7 @@ function saveDataFromInput()
}
}
$this->setAccess($access);
if ($this->save($new)) {
if ($this->publish($new)) {
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
@@ -92,7 +92,7 @@ class="form-control inreplyto" value="<?= htmlspecialchars($inreplyto) ?>" oncha
</div>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to" value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('note'); ?>
<?php echo $this->drawSyndication('note', $vars['object']->getPosseLinks()); ?>
<?= $this->draw('content/access'); ?>
<p class="button-bar">
@@ -90,7 +90,7 @@ function saveDataFromInput()
}
}
if ($this->save($new)) {
if ($this->publish($new)) {
$autosave = new Autosave();
$autosave->clearContext('entry');
@@ -60,7 +60,7 @@
])->draw('forms/input/richtext')?>
<?= $this->draw('entity/tags/input'); ?>
<?php if (empty($vars['object']->_id)) echo $this->drawSyndication('article'); ?>
<?php echo $this->drawSyndication('article', $vars['object']->getPosseLinks()); ?>
<?php if (empty($vars['object']->_id)) { ?><input type="hidden" name="forward-to" value="<?= \Idno\Core\Idno::site()->config()->getDisplayURL() . 'content/all/'; ?>" /><?php } ?>
<?= $this->draw('content/access'); ?>
@@ -14,19 +14,29 @@
$button = $this->draw('content/syndication/' . $service);
if (empty($button)) {
$disabled = '';
$posse_links = $vars['posseLinks'];
if ($accounts = \Idno\Core\Idno::site()->syndication()->getServiceAccounts($service)) {
foreach($accounts as $account) {
$posse_service = $posse_links[$service];
foreach ($posse_service as $key => $posse_account) {
if ($posse_account['account_id'] === $account['name']) {
$disabled = 'disabled';
}
}
$service_details[$service][] = ['username' => $account['username'], 'name' => $account['name']];
$button .= $this->__(array('service' => $service, 'username' => $account['username'], 'name' => $account['name'], 'selected' => \Idno\Core\Idno::site()->triggerEvent('syndication/selected/' . $service, [
$button .= $this->__(array('service' => $service, 'disabled' => $disabled, 'username' => $account['username'], 'name' => $account['name'], 'selected' => \Idno\Core\Idno::site()->triggerEvent('syndication/selected/' . $service, [
'service' => $service,
'username' => $account['username'],
'reply-to' => \Idno\Core\Idno::site()->currentPage()->getInput('share_url')
], false)))->draw('content/syndication/account');
}
} else {
$button = $this->__(array('service' => $service, 'selected' => \Idno\Core\Idno::site()->triggerEvent('syndication/selected/' . $service, [
if (array_key_exists($service, $posse_links)) {
$disabled = 'disabled';
}
$button = $this->__(array('service' => $service, 'disabled' => $disabled, 'selected' => \Idno\Core\Idno::site()->triggerEvent('syndication/selected/' . $service, [
'service' => $service,
//'username' => $account['username'],
'reply-to' => \Idno\Core\Idno::site()->currentPage()->getInput('share_url')
@@ -17,7 +17,7 @@
?>
<span class="syndication-toggle">
<input type="checkbox" class="checkbox" name="syndication[]" id="syndication_<?=$vars['service']?>_<?=$identifier?>_toggle" value="<?=$vars['service']?>::<?=htmlentities($vars['username'])?>" data-toggle="toggle" data-onstyle="info" data-on="<?=$human_icon;?>&nbsp;<?=$human_name;?>" data-off="<?=$human_icon;?>&nbsp;<?=$human_name;?>" <?php if ($vars['selected'] == true) echo 'checked'; ?>>
<input type="checkbox" class="checkbox" <?=$vars['disabled']?> name="syndication[]" id="syndication_<?=$vars['service']?>_<?=$identifier?>_toggle" value="<?=$vars['service']?>::<?=htmlentities($vars['username'])?>" data-toggle="toggle" data-onstyle="info" data-on="<?=$human_icon;?>&nbsp;<?=$human_name;?>" data-off="<?=$human_icon;?>&nbsp;<?=$human_name;?>" <?php if ($vars['selected'] == true) echo 'checked'; ?>>
</span>
<?php
@@ -19,7 +19,7 @@
?>
<span class="syndication-toggle">
<input type="checkbox" name="syndication[]" class="checkbox" id="syndication_<?=$vars['service']?>_toggle" value="<?=$vars['service']?>" data-toggle="toggle" data-onstyle="info" data-on="<?=$human_icon?>&nbsp;<?=$human_name?>" data-off="<?=$human_icon?>&nbsp;<?=$human_name;?>" <?php if ($vars['selected'] == true) echo 'checked'; ?>>
<input type="checkbox" name="syndication[]" class="checkbox" <?=$vars['disabled']?> id="syndication_<?=$vars['service']?>_toggle" value="<?=$vars['service']?>" data-toggle="toggle" data-onstyle="info" data-on="<?=$human_icon?>&nbsp;<?=$human_name?>" data-off="<?=$human_icon?>&nbsp;<?=$human_name;?>" <?php if ($vars['selected'] == true) echo 'checked'; ?>>
</span>
<?php

0 comments on commit d685c6a

Please sign in to comment.