Merge pull request #2383 from mike-esokia/PHRAS-1736_PORT-165_and_1593

PHRAS-1736 port PHRAS-165 and PHRAS-1593
This commit is contained in:
Nicolas Maillat
2018-01-08 12:12:20 +01:00
committed by GitHub
13 changed files with 330 additions and 205 deletions

View File

@@ -1,3 +1,4 @@
{
"directory" : "www/bower_components"
"directory" : "www/bower_components",
"timeout": 1200000
}

View File

@@ -23,44 +23,71 @@ class ShareController extends Controller
*/
public function shareRecord($base_id, $record_id)
{
$outputVars = [
'isAvailable' => false,
'preview' => [
'permalinkUrl' => '',
'permaviewUrl' => '',
'embedUrl' => '',
'width' => '',
'height' => ''
]
];
$record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id);
if (!$this->getAclForUser()->has_access_to_subdef($record, 'preview')) {
$this->app->abort(403);
}
//get list of subdefs
$subdefs = $record->get_subdefs();
$preview = $record->get_preview();
$databoxSubdefs = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType());
$acl = $this->getAclForUser();
$subdefList = [];
$defaultKey = null;
foreach ($subdefs as $subdef) {
$subdefName = $subdef->get_name();
if ($subdefName == 'document') {
if (!$acl->has_right_on_base($record->getBaseId(), \ACL::CANDWNLDHD)) {
continue;
}
$label = $this->app->trans('prod::tools: document');
}
elseif ($databoxSubdefs->hasSubdef($subdefName)) {
if (!$acl->has_access_to_subdef($record, $subdefName)) {
continue;
}
$label = $databoxSubdefs->getSubdef($subdefName)->get_label($this->app['locale']);
}
else {
// this subdef does no exists anymore in databox structure ?
continue; // don't publish it
}
$value = $subdef->get_name();
$preview = $record->get_subdef($value);
$defaultKey = $value; // will set a default option if neither preview,thumbnail or document is present
if (null !== $previewLink = $preview->get_permalink()) {
$permalinkUrl = $previewLink->get_url();
$permaviewUrl = $previewLink->get_page();
$previewWidth = $preview->get_width();
$previewHeight = $preview->get_height();
$embedUrl = $this->app->url('alchemy_embed_view', ['url' => (string)$permalinkUrl]);
$outputVars = [
'isAvailable' => true,
'preview' => [
if ( ($previewLink = $preview->get_permalink()) !== null ) {
$permalinkUrl = $previewLink->get_url()->__toString();
$permaviewUrl = $previewLink->get_page();
$previewWidth = $preview->get_width();
$previewHeight = $preview->get_height();
$embedUrl = $this->app->url('alchemy_embed_view', ['url' => (string)$permalinkUrl]);
$previewData = [
'label' => $label,
'permalinkUrl' => $permalinkUrl,
'permaviewUrl' => $permaviewUrl,
'embedUrl' => $embedUrl,
'width' => $previewWidth,
'height' => $previewHeight
]
];
'embedUrl' => $embedUrl,
'width' => $previewWidth,
'height' => $previewHeight
];
$subdefList[$value] = $previewData;
}
}
// candidates as best default selected option
foreach(["preview", "thumbnail", "document"] as $k) {
if (array_key_exists($k, $subdefList)) {
$defaultKey = $k;
break;
}
}
// if no subdef was sharable, subdefList is empty and defaultKey is null
// the twig MUST handle that
$outputVars = [
'isAvailable' => !empty($subdefList),
'subdefList' => $subdefList,
'defaultKey' => $defaultKey
];
return $this->renderResponse('prod/Share/record.html.twig', $outputVars);
}
}

View File

@@ -47,10 +47,22 @@ class Share implements ControllerProviderInterface, ServiceProviderInterface
$controllers->get('/record/{base_id}/{record_id}/', 'controller.prod.share:shareRecord')
->before(function (Request $request) use ($app, $firewall) {
$firewall->requireRightOnSbas(
\phrasea::sbasFromBas($app, $request->attributes->get('base_id')),
\ACL::BAS_CHUPUB
);
$socialTools = $app['conf']->get(['registry', 'actions', 'social-tools']);
if($socialTools === "all") {
return;
}
elseif($socialTools === "none") {
$app->abort(403, 'social tools disabled');
}
elseif($socialTools === "publishers") {
$firewall->requireRightOnSbas(
\phrasea::sbasFromBas($app, $request->attributes->get('base_id')),
\ACL::BAS_CHUPUB
);
}
else {
throw new \Exception("bad value \"" . $socialTools . "\" for social tools");
}
})
->bind('share_record');

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:34:06Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:35:13Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -2265,7 +2265,7 @@
<trans-unit id="ac930a136ebd04a19bc5f2ce1769fc065efb7bdf" resname="Detailed view URL" approved="yes">
<source>Detailed view URL</source>
<target state="translated">Detailansicht URL</target>
<jms:reference-file line="32">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="44">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="dc3decbb93847518f1a049dcf49d0d7c6560bcc6" resname="Details" approved="yes">
<source>Details</source>
@@ -2580,7 +2580,7 @@
<trans-unit id="7884b9b422d77cabded5da8a9a56524a84481930" resname="Embed code" approved="yes">
<source>Embed code</source>
<target state="translated">Embed-Code</target>
<jms:reference-file line="41">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="53">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="e5afbbe7023486a123b45581f49820899571c415" resname="Empty a collection" approved="yes">
<source>Empty a collection</source>
@@ -4245,7 +4245,7 @@
<trans-unit id="8c123d8ad43d08cc48c3d6a7676e65f71eea59df" resname="No URL available" approved="yes">
<source>No URL available</source>
<target state="translated">keine verfügbare URL</target>
<jms:reference-file line="57">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="120">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="486829367591dc8209f3fc6960814c0bdd8930d1" resname="No account yet?" approved="yes">
<source>No account yet?</source>
@@ -5461,7 +5461,7 @@
<trans-unit id="8e78cff6cd2bb8595029060cb53dba7a4ba72b8a" resname="Resource URL" approved="yes">
<source>Resource URL</source>
<target state="translated">Resource URL</target>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="34">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="2479ef7e025d9d4c6e5463dc366c2d6c79aaefbe" resname="Resquest access" approved="yes">
<source>Resquest access</source>
@@ -5739,12 +5739,12 @@
<trans-unit id="6ff7a49e36b0e5c8302603f98e4eb1c7dec4a56e" resname="Send to Facebook" approved="yes">
<source>Send to Facebook</source>
<target state="translated">Auf Facebook teilen</target>
<jms:reference-file line="16">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="29f82ee42eeecce87dfe9223d5d7ff716dc68ead" resname="Send to Twitter" approved="yes">
<source>Send to Twitter</source>
<target state="translated">Auf Twitter teilen</target>
<jms:reference-file line="10">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="35f49dcfbfb2e03fdce327671e82bf173b1ccb8b" resname="Sent" approved="yes">
<source>Sent</source>
@@ -9325,9 +9325,9 @@
<trans-unit id="a70a59b9120185471e5b45630f8ba24d5516f590" resname="copyClipboardLabel" approved="yes">
<source>copyClipboardLabel</source>
<target state="translated">in der Zwischenablage kopieren</target>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="36">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="49">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="40">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="61">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="fc97186645dc71dae8e3221c8ce53c56e6d611bf" resname="dans %category%" approved="yes">
<source>dans %category%</source>
@@ -10652,9 +10652,9 @@
<trans-unit id="7ac5447a13806c0a2e2602b51644729fe8464e0e" resname="previewLinkLabel" approved="yes">
<source>previewLinkLabel</source>
<target state="translated">ansichten</target>
<jms:reference-file line="27">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="35">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="39">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="47">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="60">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="6f25fd9ac189dce63bc51d1eccc253051ada2bf4" resname="print:: image de choix et description" approved="yes">
<source>print:: image de choix et description</source>
@@ -10967,6 +10967,7 @@
<trans-unit id="6ad73c8fd370f62ccd3bf50cd9cc3563aed5273c" resname="prod::tools: document" approved="yes">
<source>prod::tools: document</source>
<target state="translated">Dokument</target>
<jms:reference-file line="41">Controller/Prod/ShareController.php</jms:reference-file>
<jms:reference-file line="70">Controller/Prod/ToolsController.php</jms:reference-file>
</trans-unit>
<trans-unit id="61c9b2b17db77a27841bbeeabff923448b0f6388" resname="public" approved="yes">
@@ -12107,6 +12108,16 @@
<target state="translated">Test E-Mail Überprüfungen</target>
<jms:reference-file line="127">web/admin/dashboard.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="5107f9819cd4c0812c1d78cc07d24aff304c58fa" resname="share::share-record: advance">
<source>share::share-record: advance</source>
<target state="new">share::share-record: advance</target>
<jms:reference-file line="9">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="f51d8ca24dc67572beccf115c79671ba1c3f545a" resname="share::share-record: select-shared-def">
<source>share::share-record: select-shared-def</source>
<target state="new">share::share-record: select-shared-def</target>
<jms:reference-file line="11">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="8ab6a8a0cf069e3783c6f59163ad03a051310556" resname="sport" approved="yes">
<source>sport</source>
<target state="translated">Sport</target>

View File

@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:34:47Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:35:58Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -2265,7 +2265,7 @@
<trans-unit id="ac930a136ebd04a19bc5f2ce1769fc065efb7bdf" resname="Detailed view URL" approved="yes">
<source>Detailed view URL</source>
<target state="translated">URL of the detailed view</target>
<jms:reference-file line="32">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="44">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="dc3decbb93847518f1a049dcf49d0d7c6560bcc6" resname="Details" approved="yes">
<source>Details</source>
@@ -2580,7 +2580,7 @@
<trans-unit id="7884b9b422d77cabded5da8a9a56524a84481930" resname="Embed code" approved="yes">
<source>Embed code</source>
<target state="translated">Embed code</target>
<jms:reference-file line="41">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="53">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="e5afbbe7023486a123b45581f49820899571c415" resname="Empty a collection" approved="yes">
<source>Empty a collection</source>
@@ -4245,7 +4245,7 @@
<trans-unit id="8c123d8ad43d08cc48c3d6a7676e65f71eea59df" resname="No URL available" approved="yes">
<source>No URL available</source>
<target state="translated">No URL available</target>
<jms:reference-file line="57">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="120">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="486829367591dc8209f3fc6960814c0bdd8930d1" resname="No account yet?" approved="yes">
<source>No account yet?</source>
@@ -5461,7 +5461,7 @@
<trans-unit id="8e78cff6cd2bb8595029060cb53dba7a4ba72b8a" resname="Resource URL" approved="yes">
<source>Resource URL</source>
<target state="translated">Resource URL</target>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="34">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="2479ef7e025d9d4c6e5463dc366c2d6c79aaefbe" resname="Resquest access" approved="yes">
<source>Resquest access</source>
@@ -5739,12 +5739,12 @@
<trans-unit id="6ff7a49e36b0e5c8302603f98e4eb1c7dec4a56e" resname="Send to Facebook" approved="yes">
<source>Send to Facebook</source>
<target state="translated">Send to Facebook</target>
<jms:reference-file line="16">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="29f82ee42eeecce87dfe9223d5d7ff716dc68ead" resname="Send to Twitter" approved="yes">
<source>Send to Twitter</source>
<target state="translated">Send to Twitter</target>
<jms:reference-file line="10">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="35f49dcfbfb2e03fdce327671e82bf173b1ccb8b" resname="Sent" approved="yes">
<source>Sent</source>
@@ -9326,9 +9326,9 @@
<trans-unit id="a70a59b9120185471e5b45630f8ba24d5516f590" resname="copyClipboardLabel" approved="yes">
<source>copyClipboardLabel</source>
<target state="translated">Copy to clipboard</target>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="36">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="49">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="40">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="61">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="fc97186645dc71dae8e3221c8ce53c56e6d611bf" resname="dans %category%" approved="yes">
<source>dans %category%</source>
@@ -10653,9 +10653,9 @@
<trans-unit id="7ac5447a13806c0a2e2602b51644729fe8464e0e" resname="previewLinkLabel" approved="yes">
<source>previewLinkLabel</source>
<target state="translated">Preview</target>
<jms:reference-file line="27">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="35">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="39">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="47">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="60">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="6f25fd9ac189dce63bc51d1eccc253051ada2bf4" resname="print:: image de choix et description" approved="yes">
<source>print:: image de choix et description</source>
@@ -10968,6 +10968,7 @@
<trans-unit id="6ad73c8fd370f62ccd3bf50cd9cc3563aed5273c" resname="prod::tools: document" approved="yes">
<source>prod::tools: document</source>
<target state="translated">Document</target>
<jms:reference-file line="41">Controller/Prod/ShareController.php</jms:reference-file>
<jms:reference-file line="70">Controller/Prod/ToolsController.php</jms:reference-file>
</trans-unit>
<trans-unit id="61c9b2b17db77a27841bbeeabff923448b0f6388" resname="public" approved="yes">
@@ -12108,6 +12109,16 @@
<target state="translated">E-mails send test</target>
<jms:reference-file line="127">web/admin/dashboard.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="5107f9819cd4c0812c1d78cc07d24aff304c58fa" resname="share::share-record: advance">
<source>share::share-record: advance</source>
<target state="new">share::share-record: advance</target>
<jms:reference-file line="9">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="f51d8ca24dc67572beccf115c79671ba1c3f545a" resname="share::share-record: select-shared-def">
<source>share::share-record: select-shared-def</source>
<target state="new">share::share-record: select-shared-def</target>
<jms:reference-file line="11">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="8ab6a8a0cf069e3783c6f59163ad03a051310556" resname="sport" approved="yes">
<source>sport</source>
<target state="translated">sport</target>

View File

@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:35:35Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:36:50Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -2265,7 +2265,7 @@
<trans-unit id="ac930a136ebd04a19bc5f2ce1769fc065efb7bdf" resname="Detailed view URL" approved="yes">
<source>Detailed view URL</source>
<target state="translated">URL de la vue détaillée</target>
<jms:reference-file line="32">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="44">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="dc3decbb93847518f1a049dcf49d0d7c6560bcc6" resname="Details" approved="yes">
<source>Details</source>
@@ -2580,7 +2580,7 @@
<trans-unit id="7884b9b422d77cabded5da8a9a56524a84481930" resname="Embed code" approved="yes">
<source>Embed code</source>
<target state="translated">Code d'intégration (Embed code)</target>
<jms:reference-file line="41">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="53">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="e5afbbe7023486a123b45581f49820899571c415" resname="Empty a collection" approved="yes">
<source>Empty a collection</source>
@@ -4245,7 +4245,7 @@
<trans-unit id="8c123d8ad43d08cc48c3d6a7676e65f71eea59df" resname="No URL available" approved="yes">
<source>No URL available</source>
<target state="translated">Aucune URL de disponible</target>
<jms:reference-file line="57">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="120">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="486829367591dc8209f3fc6960814c0bdd8930d1" resname="No account yet?" approved="yes">
<source>No account yet?</source>
@@ -5463,7 +5463,7 @@ Pour les utilisateurs authentifiés, la demande de validation est également dis
<trans-unit id="8e78cff6cd2bb8595029060cb53dba7a4ba72b8a" resname="Resource URL" approved="yes">
<source>Resource URL</source>
<target state="translated">URL de la ressource</target>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="34">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="2479ef7e025d9d4c6e5463dc366c2d6c79aaefbe" resname="Resquest access" approved="yes">
<source>Resquest access</source>
@@ -5741,12 +5741,12 @@ Pour les utilisateurs authentifiés, la demande de validation est également dis
<trans-unit id="6ff7a49e36b0e5c8302603f98e4eb1c7dec4a56e" resname="Send to Facebook" approved="yes">
<source>Send to Facebook</source>
<target state="translated">Envoyer vers Facebook</target>
<jms:reference-file line="16">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="29f82ee42eeecce87dfe9223d5d7ff716dc68ead" resname="Send to Twitter" approved="yes">
<source>Send to Twitter</source>
<target state="translated">Envoyer vers Twitter</target>
<jms:reference-file line="10">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="35f49dcfbfb2e03fdce327671e82bf173b1ccb8b" resname="Sent" approved="yes">
<source>Sent</source>
@@ -9329,9 +9329,9 @@ Si vous recevez cet e-mail sans l'avoir sollicité, merci de l'ignorer ou de le
<trans-unit id="a70a59b9120185471e5b45630f8ba24d5516f590" resname="copyClipboardLabel" approved="yes">
<source>copyClipboardLabel</source>
<target state="translated">Copier dans le presse-papier</target>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="36">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="49">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="40">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="61">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="fc97186645dc71dae8e3221c8ce53c56e6d611bf" resname="dans %category%" approved="yes">
<source>dans %category%</source>
@@ -10656,9 +10656,9 @@ Si vous recevez cet e-mail sans l'avoir sollicité, merci de l'ignorer ou de le
<trans-unit id="7ac5447a13806c0a2e2602b51644729fe8464e0e" resname="previewLinkLabel" approved="yes">
<source>previewLinkLabel</source>
<target state="translated">Prévisualiser</target>
<jms:reference-file line="27">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="35">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="39">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="47">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="60">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="6f25fd9ac189dce63bc51d1eccc253051ada2bf4" resname="print:: image de choix et description" approved="yes">
<source>print:: image de choix et description</source>
@@ -10971,6 +10971,7 @@ Si vous recevez cet e-mail sans l'avoir sollicité, merci de l'ignorer ou de le
<trans-unit id="6ad73c8fd370f62ccd3bf50cd9cc3563aed5273c" resname="prod::tools: document" approved="yes">
<source>prod::tools: document</source>
<target state="translated">Document</target>
<jms:reference-file line="41">Controller/Prod/ShareController.php</jms:reference-file>
<jms:reference-file line="70">Controller/Prod/ToolsController.php</jms:reference-file>
</trans-unit>
<trans-unit id="61c9b2b17db77a27841bbeeabff923448b0f6388" resname="public" approved="yes">
@@ -12111,6 +12112,16 @@ Si vous recevez cet e-mail sans l'avoir sollicité, merci de l'ignorer ou de le
<target state="translated">Tests d'envois d'e-mails</target>
<jms:reference-file line="127">web/admin/dashboard.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="5107f9819cd4c0812c1d78cc07d24aff304c58fa" resname="share::share-record: advance">
<source>share::share-record: advance</source>
<target state="new">share::share-record: advance</target>
<jms:reference-file line="9">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="f51d8ca24dc67572beccf115c79671ba1c3f545a" resname="share::share-record: select-shared-def">
<source>share::share-record: select-shared-def</source>
<target state="new">share::share-record: select-shared-def</target>
<jms:reference-file line="11">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="8ab6a8a0cf069e3783c6f59163ad03a051310556" resname="sport" approved="yes">
<source>sport</source>
<target state="translated">sport</target>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:36:28Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:37:51Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -2269,7 +2269,7 @@
<trans-unit id="ac930a136ebd04a19bc5f2ce1769fc065efb7bdf" resname="Detailed view URL" approved="yes">
<source>Detailed view URL</source>
<target state="translated">Gedetailleerde weergave URL</target>
<jms:reference-file line="32">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="44">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="dc3decbb93847518f1a049dcf49d0d7c6560bcc6" resname="Details">
<source>Details</source>
@@ -2584,7 +2584,7 @@
<trans-unit id="7884b9b422d77cabded5da8a9a56524a84481930" resname="Embed code" approved="yes">
<source>Embed code</source>
<target state="translated">Sluit de code in</target>
<jms:reference-file line="41">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="53">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="e5afbbe7023486a123b45581f49820899571c415" resname="Empty a collection">
<source>Empty a collection</source>
@@ -4249,7 +4249,7 @@
<trans-unit id="8c123d8ad43d08cc48c3d6a7676e65f71eea59df" resname="No URL available" approved="yes">
<source>No URL available</source>
<target state="translated">Geen URL beschikbaar</target>
<jms:reference-file line="57">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="120">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="486829367591dc8209f3fc6960814c0bdd8930d1" resname="No account yet?" approved="yes">
<source>No account yet?</source>
@@ -5465,7 +5465,7 @@
<trans-unit id="8e78cff6cd2bb8595029060cb53dba7a4ba72b8a" resname="Resource URL" approved="yes">
<source>Resource URL</source>
<target state="translated">Bron URL</target>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="34">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="2479ef7e025d9d4c6e5463dc366c2d6c79aaefbe" resname="Resquest access" approved="yes">
<source>Resquest access</source>
@@ -5743,12 +5743,12 @@
<trans-unit id="6ff7a49e36b0e5c8302603f98e4eb1c7dec4a56e" resname="Send to Facebook" approved="yes">
<source>Send to Facebook</source>
<target state="translated">Verstuur naar Facebook</target>
<jms:reference-file line="16">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="29f82ee42eeecce87dfe9223d5d7ff716dc68ead" resname="Send to Twitter" approved="yes">
<source>Send to Twitter</source>
<target state="translated">Verstuur naar Twitter</target>
<jms:reference-file line="10">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="22">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="35f49dcfbfb2e03fdce327671e82bf173b1ccb8b" resname="Sent" approved="yes">
<source>Sent</source>
@@ -9329,9 +9329,9 @@
<trans-unit id="a70a59b9120185471e5b45630f8ba24d5516f590" resname="copyClipboardLabel">
<source>copyClipboardLabel</source>
<target state="new">copyClipboardLabel</target>
<jms:reference-file line="28">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="36">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="49">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="40">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="61">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="fc97186645dc71dae8e3221c8ce53c56e6d611bf" resname="dans %category%" approved="yes">
<source>dans %category%</source>
@@ -10656,9 +10656,9 @@
<trans-unit id="7ac5447a13806c0a2e2602b51644729fe8464e0e" resname="previewLinkLabel">
<source>previewLinkLabel</source>
<target state="new">previewLinkLabel</target>
<jms:reference-file line="27">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="35">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="48">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="39">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="47">prod/Share/record.html.twig</jms:reference-file>
<jms:reference-file line="60">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="6f25fd9ac189dce63bc51d1eccc253051ada2bf4" resname="print:: image de choix et description" approved="yes">
<source>print:: image de choix et description</source>
@@ -10971,6 +10971,7 @@
<trans-unit id="6ad73c8fd370f62ccd3bf50cd9cc3563aed5273c" resname="prod::tools: document">
<source>prod::tools: document</source>
<target state="new">prod::tools: document</target>
<jms:reference-file line="41">Controller/Prod/ShareController.php</jms:reference-file>
<jms:reference-file line="70">Controller/Prod/ToolsController.php</jms:reference-file>
</trans-unit>
<trans-unit id="61c9b2b17db77a27841bbeeabff923448b0f6388" resname="public" approved="yes">
@@ -12111,6 +12112,16 @@
<target state="translated">Testen voor het versturen van mail</target>
<jms:reference-file line="127">web/admin/dashboard.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="5107f9819cd4c0812c1d78cc07d24aff304c58fa" resname="share::share-record: advance">
<source>share::share-record: advance</source>
<target state="new">share::share-record: advance</target>
<jms:reference-file line="9">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="f51d8ca24dc67572beccf115c79671ba1c3f545a" resname="share::share-record: select-shared-def">
<source>share::share-record: select-shared-def</source>
<target state="new">share::share-record: select-shared-def</target>
<jms:reference-file line="11">prod/Share/record.html.twig</jms:reference-file>
</trans-unit>
<trans-unit id="8ab6a8a0cf069e3783c6f59163ad03a051310556" resname="sport">
<source>sport</source>
<target>sport</target>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:34:06Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:35:14Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:34:47Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:35:58Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:35:35Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:36:50Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2017-11-21T11:36:29Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<file date="2017-11-24T12:37:51Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>

View File

@@ -1,59 +1,122 @@
{% if not isAvailable %}
<p>{{ 'No permalink available.' | trans }}</p>
{% else %}
{% if preview.permalinkUrl is not empty %}
{% if subdefList is not empty %}
{% set defKey = defaultKey %}
<div id="share">
<div id="tweet" class="well-large">
<p>
<a href="http://www.twitter.com/home/?status={{ preview.permaviewUrl }}" target="_blank">
<img src="/assets/common/images/icons/twitter.png" title="share this on twitter" style="width:25px;vertical-align:middle;padding:0 5px;"/>
{% trans %}Send to Twitter{% endtrans %}
</a>
</p>
<p>
<a href="http://www.facebook.com/sharer.php?u={{ preview.permaviewUrl }}" target="_blank">
<img src="/assets/common/images/icons/facebook.png" title="share on facebook" style="width:25px;vertical-align:middle;padding:0 5px;"/>
{% trans %}Send to Facebook{% endtrans %}
</a>
</p>
<form action="#">
<div class="form-group clearfix">
<label>{% trans %}Resource URL{% endtrans %}</label>
<input class="input-block-level" readonly="readonly" type="text" value="{{ preview.permalinkUrl }}"
id="permalinkUrl"/>
<p class="pull-right">
<a href="{{ preview.permalinkUrl }}" target="_blank">{{ 'previewLinkLabel' | trans }}</a> &nbsp;&nbsp;
<a href="#" class="" id="permalinkUrlCopy">{{ 'copyClipboardLabel' | trans }}</a>
</p>
</div>
<div class="form-group clearfix">
<label>{% trans %}Detailed view URL{% endtrans %}</label>
<input class="input-block-level" readonly="readonly" type="text" value="{{ preview.permaviewUrl }}" id="permaviewUrl"/>
<p class="pull-right">
<a href="{{ preview.permaviewUrl }}" target="_blank">{{ 'previewLinkLabel' | trans }}</a> &nbsp;&nbsp;
<a href="#" class="" id="permaviewUrlCopy">{{ 'copyClipboardLabel' | trans }}</a>
</p>
</div>
<div class="form-group clearfix">
{#{% if type == 'image' %}#}
<label>{% trans %}Embed code{% endtrans %}</label>
{% spaceless %}
<textarea class="input-block-level" rows="4" readonly="true" id="embedRecordUrl">
<iframe width="{{ preview.width }}" height="{{ preview.height }}" src="{{ preview.embedUrl }}" frameborder="0" allowfullscreen></iframe>
</textarea>
{% endspaceless %}
<p class="pull-right">
<a href="{{ preview.embedUrl }}" target="_blank">{{ 'previewLinkLabel' | trans }}</a> &nbsp;&nbsp;
<a href="#" class="" id="embedCopy">{{ 'copyClipboardLabel' | trans }}</a>
</p>
</div>
{#{% endif %}#}
</form>
<div id="tweet" class="well-large">
<p>
<a href="#" id="advance-share">{{ 'share::share-record: advance' | trans }}</a>
<span id="shared-def">
{{ 'share::share-record: select-shared-def' | trans }}
<select name="resource_type" id="resource_type_sel" class="input-small">
{% for key,value in subdefList %}
<option value={{ key }} {% if key == defKey %}selected{% endif %}>{{ value.label }}</option>
{% endfor %}
</select>
</span>
</p>
<p>
<a id="twitter-link" href="http://www.twitter.com/home/?status={{ subdefList[defKey].permaviewUrl }}" target="_blank">
<img src="/assets/common/images/icons/twitter.png" title="share this on twitter" style="width:25px;vertical-align:middle;padding:0 5px;"/>
{% trans %}Send to Twitter{% endtrans %}
</a>
</p>
<p>
<a id="facebook-link" href="http://www.facebook.com/sharer.php?u={{ subdefList[defKey].permaviewUrl }}" target="_blank">
<img src="/assets/common/images/icons/facebook.png" title="share on facebook" style="width:25px;vertical-align:middle;padding:0 5px;"/>
{% trans %}Send to Facebook{% endtrans %}
</a>
</p>
<form action="#">
<div class="form-group clearfix">
<label style="display:inline-block;">{% trans %}Resource URL{% endtrans %}</label>
<input class="input-block-level" readonly="readonly" type="text" value="{{ subdefList[defKey].permalinkUrl }}"
id="permalinkUrl"/>
<p class="pull-right">
<a id="permalinkUrl-link" href="{{ subdefList[defKey].permalinkUrl }}" target="_blank">{{ 'previewLinkLabel' | trans }}</a> &nbsp;&nbsp;
<a href="#" class="" id="permalinkUrlCopy">{{ 'copyClipboardLabel' | trans }}</a>
</p>
</div>
<div class="form-group clearfix">
<label>{% trans %}Detailed view URL{% endtrans %}</label>
<input class="input-block-level" readonly="readonly" type="text" value="{{ subdefList[defKey].permaviewUrl }}" id="permaviewUrl"/>
<p class="pull-right">
<a id="permaviewUrl-link" href="{{ subdefList[defKey].permaviewUrl }}" target="_blank">{{ 'previewLinkLabel' | trans }}</a> &nbsp;&nbsp;
<a href="#" class="" id="permaviewUrlCopy">{{ 'copyClipboardLabel' | trans }}</a>
</p>
</div>
<div class="form-group clearfix">
{#{% if type == 'image' %}#}
<label>{% trans %}Embed code{% endtrans %}</label>
{% spaceless %}
<textarea class="input-block-level" rows="4" readonly="true" id="embedRecordUrl">
<iframe width="{{ subdefList[defKey].width }}" height="{{ subdefList[defKey].height }}" src="{{ subdefList[defKey].embedUrl }}" frameborder="0" allowfullscreen></iframe>
</textarea>
{% endspaceless %}
<p class="pull-right">
<a id="embedRecordUrl-link" href="{{ subdefList[defKey].embedUrl }}" target="_blank">{{ 'previewLinkLabel' | trans }}</a> &nbsp;&nbsp;
<a href="#" class="" id="embedCopy">{{ 'copyClipboardLabel' | trans }}</a>
</p>
</div>
{#{% endif %}#}
</form>
</div>
<script language="javascript">
// var subdefListObj = JSON.parse(subdefList); // to convert json into a javascript object
$(document).ready(function(){
var subdefList = JSON.parse('{{ subdefList | json_encode | escape('js') }}');
$('#resource_type_sel').on('change', function() {
assignPermalinks(this.value);
});
$('input.ui-state-default').hover(
function(){$(this).addClass('ui-state-hover');},
function(){$(this).removeClass('ui-state-hover');}
);
$('#permalinkUrlCopy').on('click', function(event) {
event.preventDefault();
return copyElContentClipboard('permalinkUrl');
});
$('#permaviewUrlCopy').on('click', function(event) {
event.preventDefault();
return copyElContentClipboard('permaviewUrl');
});
$('#embedCopy').on('click', function(event) {
event.preventDefault();
return copyElContentClipboard('embedRecordUrl');
});
$('#advance-share').on('click', function() {
$('#shared-def').show();
});
var copyElContentClipboard = function(elId) {
var copyEl = document.getElementById(elId);
copyEl.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('unable to copy');
}
}
var assignPermalinks = function(resourceType) {
$('#twitter-link').attr('href', 'http://www.twitter.com/home/?status=' + subdefList[resourceType].permaviewUrl);
$('#facebook-link').attr('href', 'http://www.facebook.com/sharer.php?u=' + subdefList[resourceType].permaviewUrl);
$('#permalinkUrl').val(subdefList[resourceType].permalinkUrl);
$('#permalinkUrl-link').attr('href', subdefList[resourceType].permalinkUrl);
$('#permaviewUrl').val(subdefList[resourceType].permaviewUrl);
$('#permaviewUrl-link').attr('href', subdefList[resourceType].permaviewUrl);
var html = '<iframe width="' + subdefList[resourceType].width
+ '" height="' + subdefList[resourceType].height + '" src="' + subdefList[resourceType].embedUrl + '" frameborder="0" allowfullscreen></iframe>';
$('#embedRecordUrl').val(html);
$('#embedRecordUrl-link').attr('href', subdefList[resourceType].embedUrl);
}
});
</script>
{% else %}
<div>{{ 'No URL available' | trans }}</div>
{% endif %}
{% endif %}
{% endif %}

View File

@@ -2,6 +2,7 @@
namespace Alchemy\Tests\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Controller\Prod\ShareController;
use Alchemy\Phrasea\ControllerProvider\Prod\Share;
use Symfony\Component\HttpKernel\Exception\HttpException;
@@ -19,86 +20,63 @@ class ShareTest extends \PhraseanetAuthenticatedWebTestCase
/**
* @covers Alchemy\Phrasea\Controller\Prod\Share::shareRecord
* @covers Alchemy\Phrasea\Controller\Prod\Share::connect
* @covers Alchemy\Phrasea\Controller\Prod\Share::call
*/
public function testMountedRouteSlash()
public function testRouteSlashALL()
{
$url = sprintf('/prod/share/record/%d/%d/', self::$DI['record_1']->get_base_id(), self::$DI['record_1']->get_record_id());
self::$DI['client']->request('GET', $url);
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->_RouteSlash("all", [0=>true, 1=>true, 2=>true, 3=>true]);
}
/**
* @covers Alchemy\Phrasea\Controller\Prod\Share::shareRecord
* @covers Alchemy\Phrasea\Controller\Prod\Share::connect
*/
public function testRouteSlash()
public function testRouteSlashPublishers()
{
$stubbedACL = $this->stubACL();
//has_right_on_base return true
$stubbedACL->expects($this->once())
->method('has_right_on_sbas')
->will($this->returnValue(true));
//has_access_to_subdef return true
$stubbedACL->expects($this->once())
->method('has_access_to_subdef')
->will($this->returnValue(true));
$url = sprintf('/prod/share/record/%d/%d/', self::$DI['record_1']->get_base_id(), self::$DI['record_1']->get_record_id());
self::$DI['client']->request('GET', $url);
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->_RouteSlash("publishers", [0=>false, 1=>true, 2=>false, 3=>true]);
}
public function testRouteSlashNone()
{
$this->_RouteSlash("none", [0=>false, 1=>false, 2=>false, 3=>false]);
}
private function _RouteSlash($setting, $expected)
{
$app = $this->getApplication();
$_conf = $app['conf'];
$app['conf'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\PropertyAccess')
->disableOriginalConstructor()
->getMock();
$app['conf']
->expects($this->any())
->method('get')
->will($this->returnCallback(function ($param, $default) use ($_conf, $setting) {
switch ($param) {
case ['registry', 'actions', 'social-tools']:
return $setting;
}
return $_conf->get($param, $default);
}));
$result = [];
foreach($expected as $flags=>$v) {
$stubbedACL = $this->stubACL();
// "has_right_on_sbas" IS checked by the route->before(), the url will return 403
$stubbedACL->expects($this->any())
->method('has_right_on_sbas')
->will($this->returnValue(($flags & 1) ? true:false));
// but "has_access_to_subdef" IS NOT checked (the url will return a 200 with a message "no subdef to share")
$stubbedACL->expects($this->any())
->method('has_access_to_subdef')
->will($this->returnValue(($flags & 2) ? true:false));
$url = sprintf('/prod/share/record/%d/%d/', self::$DI['record_1']->get_base_id(), self::$DI['record_1']->get_record_id());
self::$DI['client']->request('GET', $url);
$result[$flags] = self::$DI['client']->getResponse()->isOk();
}
$this->assertEquals($expected, $result);
}
/**
* @covers Alchemy\Phrasea\Controller\Prod\Share::shareRecord
*/
public function testShareRecord()
{
$share = new ShareController(self::$DI['app']);
/** @var \record_adapter $record_1 */
$record_1 = self::$DI['record_1'];
$response = $share->shareRecord($record_1->getBaseId(), $record_1->getRecordId());
$this->assertTrue($response->isOk());
}
/**
* @covers Alchemy\Phrasea\Controller\Prod\Share::shareRecord
*/
public function testShareRecordBadAccess()
{
$share = new ShareController(self::$DI['app']);
$stubbedACL = $this->getMockBuilder('\ACL')
->disableOriginalConstructor()
->getMock();
//has_access_to_subdef return false
$stubbedACL->expects($this->once())
->method('has_access_to_subdef')
->will($this->returnValue(false));
$aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider')
->disableOriginalConstructor()
->getMock();
$aclProvider->expects($this->any())
->method('get')
->will($this->returnValue($stubbedACL));
self::$DI['app']['acl'] = $aclProvider;
try {
$share->shareRecord(self::$DI['record_1']->get_base_id(), self::$DI['record_1']->get_record_id());
} catch (HttpException $exception) {
$this->assertEquals(403, $exception->getStatusCode());
return;
}
$this->fail('An access denied exception should have been thrown.');
}
}