Skip to content
Snippets Groups Projects
Commit ee6d4b7c authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #25564 : fix tags to validate count

parent 612bb6b1
Branches
Tags
9 merge requests!1553Master,!1502Master,!1501Stable,!1363Master,!1362Master,!1360Master,!1336Master,!1335Hotline master,!1334Hotline#25564 la moderations des tags notices est defectieuse
- ticket #25564 : Modération : Correction du compteur de tags notices à modérer
\ No newline at end of file
......@@ -16,18 +16,13 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Moderer {
private $_session = null;
private $sql;
private $_moderation_avis;
public function __construct() {
$this->_session = Zend_Registry::get('session');
$this->sql = Zend_Registry::get('sql');
}
class Class_Moderer {
use Trait_Translator;
protected $_stats;
public function getAllAvisCmsAModerer() {
return Class_Avis::findAllBy(['statut' => 0,
......@@ -35,7 +30,6 @@ class Class_Moderer {
}
public function modererUserNonValid($action, $id_user) {
if ('2' == $action)
sqlExecute('delete from bib_admin_users_non_valid where ID_USER=' . $id_user);
......@@ -43,25 +37,30 @@ class Class_Moderer {
public function getAllTagsAModerer() {
$liste = Class_CodifTags::findAllBy(['where' => 'a_moderer > \'\'']);
if (empty($liste))
return [];
foreach ($liste as $tag) {
$notices = explode(';', $tag->getAModerer());
foreach ($notices as $id_notice) {
if (!$id_notice)
continue;
$r['id_tag'] = $tag->getId();
$r['libelle'] = $tag->getLibelle();
$r['id_notice'] = $id_notice;
$tags[] = $r;
}
}
$tags = [];
foreach (Class_CodifTags::findAllBy(['where' => 'a_moderer > \'\'']) as $tag)
$this->_getTagToValidate($tag, $tags);
return $tags;
}
protected function _getTagToValidate($tag, &$tags) {
foreach (explode(';', $tag->getAModerer()) as $id)
$this->_getTagToValidateForRecord($id, $tag, $tags);
}
protected function _getTagToValidateForRecord($id, $tag, &$tags) {
if (!$id || !Class_Notice::countBy(['id_notice' => $id]))
return;
$tags[] = ['id_tag' => $tag->getId(),
'libelle' => $tag->getLibelle(),
'id_notice' => $id];
}
public function modererTag($action, $id_tag, $id_notice) {
$cls_tag = new Class_TagNotice();
......@@ -69,45 +68,47 @@ class Class_Moderer {
$cls_tag->validerTagNotice($id_tag, $id_notice);
return;
}
if ('2' == $action) {
$cls_tag->supprimerTagNotice($id_tag, $id_notice);
return;
}
return false;
}
public function getModerationStats() {
$translate = Zend_Registry::get('translate');
if (!isset($this->_moderation_stats)) {
$moderations = ['avis_notices' => ['label' => $translate->_('Avis sur les notices'),
'url' => BASE_URL . '/admin/modo/avisnotice',
'count' => Class_AvisNotice::countBy(['statut' => 0])],
'avis_articles' => ['label' => $translate->_('Avis sur les articles'),
'url' => BASE_URL . '/admin/modo/aviscms',
'count' => Class_Avis::countBy(['statut' => 0])],
'tags_notices' => ['label' => $translate->_('Tags sur les notices'),
'url' => BASE_URL . '/admin/modo/tagnotice',
'count' => count((new Class_Moderer())->getAllTagsAModerer())],
'demandes_inscription' => ['label' => $translate->_('Demandes d\'inscription'),
'url' => BASE_URL . '/admin/modo/membreview',
'count' => Class_UsersNonValid::count()],
'suggestions_achat' => ['label' => $translate->_('Suggestions d\'achat'),
'url' => BASE_URL . '/admin/modo/suggestion-achat',
'count' => Class_SuggestionAchat::count()],
];
if (Class_AdminVar::isCmsFormulairesEnabled()) {
$moderations['formulaires'] =['label' => $translate->_('Formulaires'),
'url' => BASE_URL . '/admin/modo/formulaires',
'count' => Class_Formulaire::countNotValidated()];
}
$this->_moderation_stats = $moderations;
if ($this->_stats)
return $this->_stats;
$stats = ['avis_notices' => ['label' => $this->_('Avis sur les notices'),
'url' => BASE_URL . '/admin/modo/avisnotice',
'count' => Class_AvisNotice::countBy(['statut' => 0])],
'avis_articles' => ['label' => $this->_('Avis sur les articles'),
'url' => BASE_URL . '/admin/modo/aviscms',
'count' => Class_Avis::countBy(['statut' => 0])],
'tags_notices' => ['label' => $this->_('Tags sur les notices'),
'url' => BASE_URL . '/admin/modo/tagnotice',
'count' => count($this->getAllTagsAModerer())],
'demandes_inscription' => ['label' => $this->_('Demandes d\'inscription'),
'url' => BASE_URL . '/admin/modo/membreview',
'count' => Class_UsersNonValid::count()],
'suggestions_achat' => ['label' => $this->_('Suggestions d\'achat'),
'url' => BASE_URL . '/admin/modo/suggestion-achat',
'count' => Class_SuggestionAchat::count()],
];
if (Class_AdminVar::isCmsFormulairesEnabled()) {
$stats['formulaires'] = ['label' => $this->_('Formulaires'),
'url' => BASE_URL . '/admin/modo/formulaires',
'count' => Class_Formulaire::countNotValidated()];
}
return $this->_moderation_stats;
return $this->_stats = $stats;
}
}
\ No newline at end of file
......@@ -18,7 +18,6 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once realpath(dirname(__FILE__)) . '/AdminAbstractControllerTestCase.php';
abstract class ModoControllerIndexActionTestCase extends Admin_AbstractControllerTestCase {
......@@ -42,9 +41,9 @@ abstract class ModoControllerIndexActionTestCase extends Admin_AbstractControlle
'code_alpha' => 'LITTERATURES ESPAGNOL']);
$this->fixture('Class_CodifTags', ['id' => 2,
'a_moderer' => '1002;1003',
'a_moderer' => '1002;1003;8890',
'libelle' => 'muerto',
'code_alpha' => 'LITTERATURES ESPAGNOL']);
'code_alpha' => 'MUERTO']);
$this->fixture('Class_Avis', ['id' => 1,
'id_notice' => 1002,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment