public function createCommentsTopic(WordPressAccess $wordPressAccess, PHPBoostAccess $PHPBoostAccess, stdClass $news) { // Récupération du statut des commentaires (ouvert/fermé) dans Wordpress $posts = $wordPressAccess->getAllPosts(); if (isset($posts[$news->rewrited_name])) { $commentsOpen = $posts[$news->rewrited_name]->comment_status != 'open'; } $count = $PHPBoostAccess->getSql()->prepare(' SELECT id_topic FROM ' . $PHPBoostAccess->getPrefix() . 'comments_topic WHERE module_id="news" AND id_in_module = :id '); $count->execute(array('id' => $news->id)); $nb = $count->rowCount(); if ($nb < 1) { $path = '/news/?url=/' . $news->category_id . '-' . $news->category_slug . '/' . $news->id . '-' . $news->rewrited_name . '/'; // Creation du comments topic $insert = $PHPBoostAccess->getSql()->prepare(' INSERT INTO ' . $PHPBoostAccess->getPrefix() . 'comments_topic(module_id, topic_identifier, id_in_module, is_locked, number_comments, path) VALUES (:module_id, :topic_identifier, :id_in_module, :is_locked, :number_comments, :path) '); $insert->execute(array('module_id' => 'news', 'topic_identifier' => 'default', 'id_in_module' => $news->id, 'is_locked' => $commentsOpen, 'number_comments' => 0, 'path' => $path)); return $PHPBoostAccess->getSql()->lastInsertId(); } else { $id_topic = $count->fetchObject()->id_topic; $update = $PHPBoostAccess->getSql()->prepare(' UPDATE ' . $PHPBoostAccess->getPrefix() . 'comments_topic SET is_locked = :is_locked WHERE id_topic = :id_topic '); $update->execute(array('is_locked' => $commentsOpen, 'id_topic' => $id_topic)); return $id_topic; } }
public function import(IOManager $io, WordPressAccess $wordPressAccess, PHPBoostAccess $phpBoostAccess) { // Récupération de la liste des categories existants dans PHPBoost $phpBoostCat = $phpBoostAccess->getAllNewsCats(); // Récupération de la liste des categories existants dans Wordpress $wordPressCat = $wordPressAccess->getAllCats(); // Parcours des différents utilisateurs WordPress foreach ($wordPressCat as $cat) { if (!array_key_exists($cat->slug, $phpBoostCat)) { // Si l'utilisateur n'existe pas $this->add($phpBoostAccess, $cat); $io->writeln('Info: Categorie ' . $cat->slug . ' ajouté.'); } else { // Si l'utilisateur existe $io->writeln('Erreur: La catégorie ' . $cat->slug . ' existe déjà.'); } } }
public function import(IOManager $io, WordPressAccess $wordPressAccess, PHPBoostAccess $phpBoostAccess) { // Récupération de la liste des utilisateurs existants dans PHPBoost $phpBoostUsers = $phpBoostAccess->getAllUsers(); // Récupération de la liste des utilisateurs existants dans Wordpress $wordPressUsers = $wordPressAccess->getAllUsers(); // Parcours des différents utilisateurs WordPress foreach ($wordPressUsers as $currentUser) { if (!array_key_exists($currentUser->user_login, $phpBoostUsers)) { // Si l'utilisateur n'existe pas $this->addUser($phpBoostAccess, $currentUser); $io->writeln('Info: Utilisateur ' . $currentUser->user_login . ' ajouté.'); } else { // Si l'utilisateur existe $io->writeln('Erreur: L\'utilisateur ' . $currentUser->user_login . ' existe déjà.'); } } }
public function importMedia(stdClass $media, $userId, WordPressAccess $wordPressAccess, PHPBoostAccess $phpBoostAccess) { $src = $wordPressAccess->getPath() . 'wp-content/uploads/' . $media->path; $dest = $phpBoostAccess->getPath() . FILESYSTEM_IMPORT_LOCATION . $media->path; if (!is_dir(dirname($dest))) { mkdir(dirname($dest), 0777, true); } if (!file_exists($dest) && file_exists($src)) { copy($src, $dest); $file = pathinfo($dest); // Ajout dans la base de données $insert = $phpBoostAccess->getSql()->prepare(' INSERT IGNORE INTO ' . $phpBoostAccess->getPrefix() . 'upload(name, path, user_id, size, type, timestamp) VALUES (:name, :path, :user_id, :size, :type, :timestamp) '); $insert->execute(array('name' => $file['basename'], 'path' => str_replace('upload/', '', FILESYSTEM_IMPORT_LOCATION . $media->path), 'user_id' => $userId, 'size' => round(filesize($dest) / 1024), 'type' => $file['extension'], 'timestamp' => filemtime($dest))); return true; } return false; }