Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Plg parentassociations #17881

Closed
Closed
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
93316f8
Update joomla.sql
christianboulbi Aug 31, 2017
4b84f8a
Update joomla.sql
christianboulbi Aug 31, 2017
ee85e1a
Update default.php
christianboulbi Aug 31, 2017
8abb641
Update AssociationsHelper.php
christianboulbi Aug 31, 2017
c0260e2
First Version of parentassociations plugin
christianboulbi Sep 1, 2017
95ca61c
Restore sample testing files
christianboulbi Sep 1, 2017
a9c17f9
Update articleassociations.xml
christianboulbi Sep 6, 2017
4042619
Update default.php
christianboulbi Sep 6, 2017
0d76dcb
Update default.php
christianboulbi Sep 6, 2017
a74c77c
Update articleassociations.xml
christianboulbi Sep 6, 2017
eec4a61
Update default.php
christianboulbi Sep 6, 2017
44412c3
Update default.php
christianboulbi Sep 6, 2017
cb73dc6
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
501ed15
Update joomla.sql
christianboulbi Sep 6, 2017
2340d12
Update joomla.sql
christianboulbi Sep 6, 2017
78801f5
Update articleassociations.php
christianboulbi Sep 6, 2017
26ac16b
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
e6e9114
Update articleassociations.xml
christianboulbi Sep 6, 2017
3c46478
Update articleassociations.xml
christianboulbi Sep 6, 2017
bedfca9
Update articleassociations.php
christianboulbi Sep 6, 2017
3511d68
Update joomla.sql
christianboulbi Sep 6, 2017
9ec58f5
Update default.php
christianboulbi Sep 6, 2017
6aba9f7
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
5b760b4
Update articleassociations.xml
christianboulbi Sep 6, 2017
0424019
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
38825cc
Update articleassociations.php
christianboulbi Sep 6, 2017
4eb770a
Update joomla.sql
christianboulbi Sep 6, 2017
2168e1e
Update joomla.sql
christianboulbi Sep 6, 2017
0c1d977
Update articleassociations.php
christianboulbi Sep 6, 2017
b21e025
Update articleassociations.php
christianboulbi Sep 6, 2017
239c66a
Update articleassociations.php
christianboulbi Sep 6, 2017
ff4e41d
Update articleassociations.php
christianboulbi Sep 6, 2017
c5f3b63
Update articleassociations.php
christianboulbi Sep 6, 2017
8bd1af9
Update articleassociations.php
christianboulbi Sep 6, 2017
f2dd35d
Update articleassociations.php
christianboulbi Sep 6, 2017
538442b
Update articleassociations.php
christianboulbi Sep 6, 2017
d3555e8
Update articleassociations.php
christianboulbi Sep 6, 2017
542522f
Update articleassociations.php
christianboulbi Sep 6, 2017
e291013
Update articleassociations.php
christianboulbi Sep 6, 2017
82fe241
Update articleassociations.php
christianboulbi Sep 6, 2017
57bf3c7
Update articleassociations.php
christianboulbi Sep 6, 2017
23ba4a4
Update articleassociations.php
christianboulbi Sep 6, 2017
bc8b651
Update articleassociations.php
christianboulbi Sep 6, 2017
0a527e8
Update articleassociations.php
christianboulbi Sep 6, 2017
45798f7
Update articleassociations.php
christianboulbi Sep 6, 2017
39f1cd2
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
6ad1f44
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
e1814dd
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
fa2d94c
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
47f444e
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
a9c6fdf
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
48a8b27
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
b7a819a
Update AssociationsHelper.php
christianboulbi Sep 6, 2017
a0e7ad2
Update default.php
christianboulbi Sep 6, 2017
a7a1377
Update default.php
christianboulbi Sep 6, 2017
6a55daa
Update Association.php
perrez Sep 6, 2017
2049c8a
Update Association.php
perrez Sep 6, 2017
eccae50
Update Html.php
perrez Sep 6, 2017
9fda340
Update edit.php
perrez Sep 6, 2017
a64fbf0
Update en-GB.com_associations.ini
perrez Sep 6, 2017
d8becf2
Update Association.php
perrez Sep 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update articleassociations.php
  • Loading branch information
christianboulbi committed Sep 6, 2017
commit 78801f5b902ba1f723a208dbc5a1e7ea0cb3b5bc
72 changes: 34 additions & 38 deletions plugins/content/articleassociations/articleassociations.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* @version $Id: articleassociations.php revision date lasteditedby $
* @package Joomla
* @subpackage Content
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* @version $Id: articleassociations.php revision date lasteditedby $
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure these are aligned

* @package Joomla
* @subpackage Content
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
Expand All @@ -13,7 +13,7 @@
*/

// no direct access
defined( '_JEXEC' ) or die;
defined('_JEXEC') or die;

class plgContentarticleassociations extends JPlugin
{
Expand Down Expand Up @@ -41,14 +41,19 @@ public function onContentAfterSave($context, $article, $isNew)

// If not parent exists, add it
if ($this->getParentCount($id) !== 1)
{
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove trailing whitespace

$query = $this->db->getQuery(true);
$columns = array('id', 'parentid', 'approved');
$values = array($id, 0, 1);
$query
->insert($this->db->quoteName('#__item_associations'))
->columns($this->db->quoteName($columns))
->values(implode(',', $values));
$columns = array(
'id',
'parentid',
'approved'
);
$values = array(
$id,
0,
1
);
$query->insert($this->db->quoteName('#__item_associations'))->columns($this->db->quoteName($columns))->values(implode(',', $values));

$this->db->setQuery($query)->execute();
}
Expand All @@ -58,7 +63,7 @@ public function onContentAfterSave($context, $article, $isNew)

public function onContentAfterSaveAssociations($context, $article, $isNew)
{
$id = $article->id;
$id = $article->id;
// Get a db connection.
// Create a new query object.
$query = $this->db->getQuery(true);
Expand All @@ -74,30 +79,28 @@ public function onContentAfterSaveAssociations($context, $article, $isNew)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

// if slave article is edit
if ((int) $this->getParentId($id) !== 0)
{
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove trailing whitespace

$query = $this->db->getQuery(true);
$fields = array(
$this->db->quoteName('approved') . ' =0'
);

$conditions = array($this->db->quoteName('id') . ' = ' . $this->db->quote($id));
$conditions = array(
$this->db->quoteName('id') . ' = ' . $this->db->quote($id)
);
$query->update($this->db->quoteName('#__item_associations'))->set($fields)->where($conditions);
$this->db->setQuery($query)->execute();
}

// if master article is edit

$query->clear()
->select(array('#__item_associations.id'))
->from($this->db->quoteName('#__item_associations'))
->join('INNER', $this->db->quoteName('#__associations') . ' ON (' . $this->db->quoteName('#__associations.id') . ' = ' . $this->db->quoteName('#__item_associations.id') . ')')
->where($this->db->quoteName('#__associations.key') . ' =' . $this->db->quote($result),'AND')
->where($this->db->quoteName('#__item_associations.parentid') . ' = 0');
$query->clear()->select(array('#__item_associations.id'))
->from($this->db->quoteName('#__item_associations'))->join('INNER', $this->db->quoteName('#__associations') . ' ON (' . $this->db->quoteName('#__associations.id') . ' = ' . $this->db->quoteName('#__item_associations.id') . ')')->where($this->db->quoteName('#__associations.key') . ' =' . $this->db->quote($result), 'AND')->where($this->db->quoteName('#__item_associations.parentid') . ' = 0');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put query clauses on separate lines, as Travis will start moaning about line length

$this->db->setQuery($query);
$liste1 = $this->db->loadRowList();

if ($result && strcmp($this->getParentId($id), "0") == 0)
{
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove trailing whitespace

$db = JFactory::getDbo();
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName(array('id')));
Expand All @@ -106,21 +109,20 @@ public function onContentAfterSaveAssociations($context, $article, $isNew)
$this->db->setQuery($query);
$list = $this->db->loadRowList();
foreach ($list as $res)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new line before foreach

{
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove trailing whitespace

foreach ($res as $association_id)
{

if ($id != $association_id)
{


$query = $this->db->getQuery(true);
$fields = array(
$this->db->quoteName('approved') . ' =0',
$this->db->quoteName('parentid') . ' =' . $this->db->quote($id)
);

$conditions = array($this->db->quoteName('id') . ' =' . $this->db->quote($association_id));
$conditions = array(
$this->db->quoteName('id') . ' =' . $this->db->quote($association_id)
);
$query->update($this->db->quoteName('#__item_associations'))->set($fields)->where($conditions);
$this->db->setQuery($query);
$res = $this->db->execute();
Expand All @@ -140,26 +142,20 @@ public function onContentAfterSaveAssociations($context, $article, $isNew)

public function getParentCount($id)
{
$query = $this->db->getQuery(true)
->select(COUNT($this->db->quoteName(array('parentid'))))
->from($this->db->quoteName('#__item_associations'))
->where($this->db->quoteName('id') . ' = ' . (int) $id);
$query = $this->db->getQuery(true)->select(COUNT($this->db->quoteName(array('parentid'))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put query clauses on separate lines

->from($this->db->quoteName('#__item_associations'))->where($this->db->quoteName('id') . ' = ' . (int) $id);
$this->db->setQuery($query);
$parentid = $this->db->loadResult();

return (int) $parentid;
}


public function getParentId($id)
{
$query = $this->db->getQuery(true)
->select($this->db->quoteName(array('parentid')))
->from($this->db->quoteName('#__item_associations'))
->where($this->db->quoteName('id') . ' = ' . (int) $id);
$query = $this->db->getQuery(true)->select($this->db->quoteName(array('parentid')))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put query clauses on separate lines

->from($this->db->quoteName('#__item_associations'))->where($this->db->quoteName('id') . ' = ' . (int) $id);
$this->db->setQuery($query);
$parentid = $this->db->loadResult();

return (int) $parentid;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty lines


Expand Down