Fork me on GitHub




« 1 (2)


Re: Séparation de message (split) impossible dans mon forum
Régulier
Inscrit: 04/02/2003 08:53
De Paris
Messages: 312
Merci beaucoup Babouille. Ça marchait très bien avec mes anciennes versions, mais je ne sais plus trop lesquelles.
J'ai fouillé xoops.org, sans résultat.

Posté le : 25/07/2019 16:39

Open in new window
18 ans sous XOOPS !
Partager Twitter Partagez cette article sur GG+
Re: Séparation de message (split) impossible dans mon forum
Régulier
Inscrit: 04/02/2003 08:53
De Paris
Messages: 312

Posté le : 25/07/2019 21:32

Open in new window
18 ans sous XOOPS !
Partager Twitter Partagez cette article sur GG+
Re: Séparation de message (split) impossible dans mon forum
Admin Frxoops
Inscrit: 04/02/2003 06:41
Messages: 923
Bon, je viens de tester vite fait avant de me concentrer sur le barbecue et cette ancienne version fonctionne pour le Split (pas testé les autres vu que j'ai pas de lien du tout).

Bon, par contre, on fait cela carrément en aveugle, il recolle une nouvelle page sans pouvoir modifier le titre ni la rubrique qu'il faut faire à la main par la suite. Bref, pas top !

Le code en question à des fins de tests et qui ne doit pas remplacer la dernière version du fichier action.post.php

<?php
// $Id: action.post.php,v 1.1.1.1 2005/10/19 16:23:23 phppp Exp $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>   ... nbsp;   //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
//  Author: phppp (D.J., infomax@gmail.com)                                  //
//  URL: http://xoopsforge.comhttp://xoops.org.cn    ... nbsp;   //
//  Project: Article Project                                                 //
//  ------------------------------------------------------------------------ //
include 'header.php';

$topic_id = isset($_POST['topic_id']) ? intval($_POST['topic_id']) : 0;
$post_id = !empty($_GET['post_id']) ? intval($_GET['post_id']) : 0;
$post_id = !empty($_POST['post_id']) ? $_POST['post_id'] : $post_id;
$uid = !empty($_POST['uid']) ? $_POST['uid'] : 0;
$op = !empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op']:"");
$op in_array($op, array("approve""delete""restore""split"))? $op "";
$mode = !empty($_GET['mode']) ? intval($_GET['mode']) : 1;

if ( empty(
$post_id) || empty($op)) {
    
redirect_header("javascript:history.go(-1);"2_MD_NORIGHTTOACCESS);
    exit();
}

$post_handler =& xoops_getmodulehandler('post''newbb');
$topic_handler =& xoops_getmodulehandler('topic''newbb');
$forum_handler =& xoops_getmodulehandler('forum''newbb');
if(empty(
$topic_id)){
    
$viewtopic_forum null;
}else{
    
$forumtopic =& $topic_handler->get($topic_id);
    
$forum_id $forumtopic->getVar('forum_id');
    
$viewtopic_forum =& $forum_handler->get($forum_id);
}
$isadmin newbb_isAdmin($viewtopic_forum);

if(!
$isadmin){
    
redirect_header("index.php"2_MD_NORIGHTTOACCESS);
    exit();
}

switch(
$op){
    case 
"restore":
        
$post_id array_values($post_id);
        
sort($post_id);
        
$topics=array();
        
$forums=array();
        foreach(
$post_id as $post){
            
$post_obj =& $post_handler->get($post);
            if(!empty(
$topic_id) && $topic_id!=$post_obj->getVar("topic_id")) continue;
            
$post_handler->approve($post_obj);
            
$topics[$post_obj->getVar("topic_id")] =1;
            
$forums[$post_obj->getVar("forum_id")] =1;
            unset(
$post_obj);
        }
        foreach(
array_keys($topics) as $topic){
            
$topic_handler->synchronization($topic);
        }
        foreach(
array_keys($forums) as $forum){
            
$forum_handler->synchronization($forum);
        }
        break;
    case 
"approve":
        
$post_id array_values($post_id);
        
sort($post_id);
        
$topics=array();
        
$forums=array();
        
$criteria = new Criteria("post_id""(".implode(","$post_id).")""IN");
        
$posts_obj =& $post_handler->getObjects($criteriatrue);
        foreach(
$post_id as $post){
            
$post_obj =& $posts_obj[$post];
            if(!empty(
$topic_id) && $topic_id!=$post_obj->getVar("topic_id")) continue;
            
$post_handler->approve($post_obj);
            
$topics[$post_obj->getVar("topic_id")] = $post;
            
$forums[$post_obj->getVar("forum_id")] = 1;
        }
        foreach(
array_keys($topics) as $topic){
            
$topic_handler->synchronization($topic);
        }
        foreach(
array_keys($forums) as $forum){
            
$forum_handler->synchronization($forum);
        }
        
        if(empty(
$xoopsModuleConfig['notification_enabled'])) break;
        
        
$criteria_topic = new Criteria("topic_id""(".implode(","array_keys($topics)).")""IN");
        
$topic_list =& $topic_handler->getList($criteria_topictrue);
        
        
$criteria_forum = new Criteria("forum_id""(".implode(","array_keys($forums)).")""IN");
        
$forum_list =& $forum_handler->getList($criteria_forum);
            
        include_once 
'include/notification.inc.php';
        
$notification_handler =& xoops_gethandler('notification');
        foreach(
$post_id as $post){
            
$tags = array();
            
$tags['THREAD_NAME'] = $topic_list[$posts_obj[$post]->getVar("topic_id")];
            
$tags['THREAD_URL'] = XOOPS_URL '/modules/' $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' $posts_obj[$post]->getVar("topic_id").'&amp;forum=' $posts_obj[$post]->getVar('forum_id');
            
$tags['FORUM_NAME'] = $forum_list[$posts_obj[$post]->getVar('forum_id')];
            
$tags['FORUM_URL'] = XOOPS_URL '/modules/' $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' $posts_obj[$post]->getVar('forum_id');
            
$tags['POST_URL'] = $tags['THREAD_URL'].'#forumpost' $post;
            
$notification_handler->triggerEvent('thread'$posts_obj[$post]->getVar("topic_id"), 'new_post'$tags);
            
$notification_handler->triggerEvent('forum'$posts_obj[$post]->getVar('forum_id'), 'new_post'$tags);
            
$notification_handler->triggerEvent('global'0'new_post'$tags);
            
$tags['POST_CONTENT'] = $posts_obj[$post]->getVar("post_text");
            
$tags['POST_NAME'] = $posts_obj[$post]->getVar("subject");
            
$notification_handler->triggerEvent('global'0'new_fullpost'$tags);
            
$notification_handler->triggerEvent('forum'$posts_obj[$post]->getVar('forum_id'), 'new_fullpost'$tags);
        }
        break;
    case 
"delete":
        
$post_id array_values($post_id);
        
rsort($post_id);
        
$topics=array();
        
$forums=array();
        foreach(
$post_id as $post){
            
$post_obj =& $post_handler->get($post);
            if(!empty(
$topic_id) && $topic_id!=$post_obj->getVar("topic_id")) continue;
            
$topics[$post_obj->getVar("topic_id")] =1;
            
$forums[$post_obj->getVar("forum_id")] =1;
            
$post_handler->delete($post_obj);
            unset(
$post_obj);
        }
        foreach(
array_keys($topics) as $topic){
            
$topic_handler->synchronization($topic);
        }
        foreach(
array_keys($forums) as $forum){
            
$forum_handler->synchronization($forum);
        }
        break;
    case 
"split":
        
$post_obj =& $post_handler->get($post_id);
        if(empty(
$post_id) || $post_obj->isTopic()) {
            break;
        }
        
$topic_id $post_obj->getVar("topic_id");
        
        
$newtopic =& $topic_handler->create();
        
$newtopic->setVar("topic_title"$post_obj->getVar("subject"), true);
        
$newtopic->setVar("topic_poster"$post_obj->getVar("uid"), true);
        
$newtopic->setVar("forum_id"$post_obj->getVar("forum_id"), true);
        
$newtopic->setVar("topic_time"$post_obj->getVar("post_time"), true);
        
$newtopic->setVar("poster_name"$post_obj->getVar("poster_name"), true);
        
$newtopic->setVar("approved"1true);
        
$topic_handler->insert($newtopictrue);        
        
$new_topic_id $newtopic->getVar('topic_id');
        
        
$pid $post_obj->getVar("pid");
        
        
$post_obj->setVar("topic_id"$new_topic_idtrue);
        
$post_obj->setVar("pid"0true);
        
$post_handler->insert($post_obj);
        
        
/* split a single post */
        
if($mode==1){
            
$criteria = new CriteriaCompo(new Criteria("topic_id"$topic_id));
            
$criteria->add(new Criteria('pid',$post_id));
            
$post_handler->updateAll("pid"$pid$criteriatrue);
        
/* split a post and its children posts */
        
}elseif($mode==2){
            include_once(
XOOPS_ROOT_PATH "/class/xoopstree.php");
            
$mytree = new XoopsTree($xoopsDB->prefix("bb_posts"), "post_id""pid");
            
$posts $mytree->getAllChildId($post_id);
            if(
count($posts)>0){
                
$criteria = new Criteria('post_id'"(".implode(","$posts).")""IN");
                
$post_handler->updateAll("topic_id"$new_topic_id$criteriatrue);
            }
        
/* split a post and all posts coming after */
        
}elseif($mode==3){
            
$criteria = new CriteriaCompo(new Criteria("topic_id"$topic_id));
            
$criteria->add(new Criteria('post_id',$post_id">"));
            
$post_handler->updateAll("topic_id"$new_topic_id$criteriatrue);
            
            unset(
$criteria);
            
$criteria = new CriteriaCompo(new Criteria("topic_id"$new_topic_id));
            
$criteria->add(new Criteria('post_id',$post_id">"));
            
$post_handler->identifierName "pid";
            
$posts $post_handler->getList($criteria);
            
            unset(
$criteria);
            
$post_update = array();
            foreach(
$posts as $postid=>$pid){
                if(!
in_array($pidarray_keys($posts))){
                    
$post_update[] = $pid
                }
            }
            if(
count($post_update)){
                
$criteria = new Criteria('post_id'"(".implode(","$post_update).")""IN");
                
$post_handler->updateAll("pid"$post_id$criteriatrue);
            }
        }
        
        
$forum_id $post_obj->getVar("forum_id");
        
$topic_handler->synchronization($topic_id);
        
$topic_handler->synchronization($new_topic_id);
        
$sql sprintf("UPDATE %s SET forum_topics = forum_topics+1 WHERE forum_id = %u"$xoopsDB->prefix("bb_forums"), $forum_id);
        
$result $xoopsDB->queryF($sql);
        
        break;
}
if(!empty(
$topic_id)){
    
redirect_header("viewtopic.php?topic_id=$topic_id"2_MD_DBUPDATED);
}elseif(!empty(
$forum_id)){
    
redirect_header("viewforum.php?forum=$forum_id"2_MD_DBUPDATED);
}else{
    
redirect_header("viewpost.php?uid=$uid"2_MD_DBUPDATED);
}

include 
XOOPS_ROOT_PATH.'/footer.php';
?>


Dès que j'ai un peu plus de temps, je me penche dessus sinon tu peux voir ce qui merde

Posté le : 28/07/2019 12:48

Quand tu montres la lune du doigt, l'imbécile regarde le doigt.
Infos sur TSO et tutos PC sur Tutoriaux PC
Partager Twitter Partagez cette article sur GG+
Re: Séparation de message (split) impossible dans mon forum
Admin Frxoops
Inscrit: 04/02/2003 06:41
Messages: 923
Bon, ce qui semble fonctionner c'est de remplacer le début par
$topic_id = isset($_POST['topic_id']) ? intval($_POST['topic_id']) : 0;
$post_id = !empty($_GET['post_id']) ? intval($_GET['post_id']) : 0;
$post_id = !empty($_POST['post_id']) ? $_POST['post_id'] : $post_id;
$uid = !empty($_POST['uid']) ? $_POST['uid'] : 0;
$op = !empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op']:"");
$op in_array($op, array("approve""delete""restore""split"))? $op "";
$mode = !empty($_GET['mode']) ? intval($_GET['mode']) : 1;

Donc il y a une coucougniette dans la manière dont les variables sont récupérées.

Par contre, j'ai droit à un "0" dans le type de sujet au niveau du title du coup, dans l'autre topic il était en "résolu". Bon, c'est surement une couille de ma part dans le site de dev.

Posté le : 28/07/2019 13:02

Quand tu montres la lune du doigt, l'imbécile regarde le doigt.
Infos sur TSO et tutos PC sur Tutoriaux PC
Partager Twitter Partagez cette article sur GG+
Re: Séparation de message (split) impossible dans mon forum
Admin Frxoops
Inscrit: 04/02/2003 06:41
Messages: 923
Après test du matin à la fraiche, il semble que l'array pose problème (d'ailleurs je me demande pourquoi c'est un array alors qu'il n'y a qu'une variable).

Bon, j'ai remplacé
$post_id XoopsRequest::getArray('post_id'XoopsRequest::getArray('post_id'0'POST'), 'GET');

par
$post_id XoopsRequest::getInt('post_id'0'GET');

Et cela semble fonctionner.

Posté le : 29/07/2019 09:24

Edité par babouille sur 19/08/2019 14:42:49

Quand tu montres la lune du doigt, l'imbécile regarde le doigt.
Infos sur TSO et tutos PC sur Tutoriaux PC
Partager Twitter Partagez cette article sur GG+
Re: Séparation de message (split) impossible dans mon forum
Régulier
Inscrit: 04/02/2003 08:53
De Paris
Messages: 312
Un grand merci babouille !! Retour de vacances, et hop, un problème de résolu qui me cassait les pieds depuis un bout de temps.
Mamba est arrivé à la même conclusion que toi, et c'est à priori corrigé dans la dernière version 5.

Posté le : 19/08/2019 10:09

Open in new window
18 ans sous XOOPS !
Partager Twitter Partagez cette article sur GG+

 Haut   Précédent   Suivant
« 1 (2)



Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

47 Personne(s) en ligne (27 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 47 | Plus ...