Example #1
0
 protected function add(PHPBoostAccess $pba, stdClass $cat)
 {
     // Gestion de la catégorie parente
     $parent_id = 0;
     if (!is_null($cat->parent_slug)) {
         $cats = $pba->getAllNewsCats();
         if (array_key_exists($cat->parent_slug, $cats)) {
             $parent_id = $cats[$cat->parent_slug]->id;
         }
     }
     $query = $pba->getSql()->prepare('
         INSERT INTO ' . $pba->getPrefix() . 'news_cats(name, rewrited_name, description, c_order, image, id_parent)
         VALUES(:name, :rewrited_name, :description, :c_order, :image, :id_parent)
     ');
     $query->execute(array('name' => $cat->name, 'rewrited_name' => $cat->slug, 'description' => $cat->description, 'c_order' => 1, 'image' => PHPBOOST_CAT_IMAGE, 'id_parent' => $parent_id));
 }
 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;
 }
 public function updateCommentsCount(PHPBoostAccess $PHPBoostAccess, $topic_id)
 {
     $update = $PHPBoostAccess->getSql()->prepare('
         UPDATE ' . $PHPBoostAccess->getPrefix() . 'comments_topic ct
         SET number_comments = (SELECT COUNT(*) FROM ' . $PHPBoostAccess->getPrefix() . 'comments c WHERE c.id_topic = ct.id_topic)
         WHERE id_topic = :id_topic
     ');
     $update->execute(array('id_topic' => $topic_id));
 }
Example #4
0
 protected function addUser(PHPBoostAccess $pba, stdClass $wpUser)
 {
     $query = $pba->getSql()->prepare('INSERT INTO ' . $pba->getPrefix() . 'member(login, password, level, user_mail, user_show_mail, timestamp, last_connect) VALUES(:login, :password, :level, :user_mail, :user_show_mail, :timestamp, :last_connect)');
     $query->execute(array('login' => $wpUser->user_login, 'password' => '', 'level' => '0', 'user_mail' => substr($wpUser->user_email, 0, 50), 'user_show_mail' => 0, 'timestamp' => (new DateTime($wpUser->user_registered))->getTimestamp(), 'last_connect' => '0'));
 }