<?php
namespace admin\factory;

class ArticlesArchive
{  
  public static function article_restore( $article_id )
  {
    global $mdb;
    return $mdb -> update( 'pp_articles', [ 'status' => 0 ], [ 'id' => (int)$article_id ] );
    
  }
  
  public static function article_delete( $article_id )
  {
    global $mdb;
    $mdb -> delete( 'pp_articles_pages', [ 'article_id' => (int)$article_id ] );
    $mdb -> delete( 'pp_articles_langs', [ 'article_id' => (int)$article_id ] );
    $mdb -> delete( 'pp_articles_images', [ 'article_id' => (int)$article_id ] );
    $mdb -> delete( 'pp_articles_files', [ 'article_id' => (int)$article_id ] );
    $mdb -> delete( 'pp_articles_tags', [ 'article_id' => (int)$article_id ] );
    $mdb -> delete( 'pp_articles', [ 'id' => (int)$article_id ] );
    
    \S::delete_dir( '../upload/article_images/article_' . (int)$article_id . '/' );
    \S::delete_dir( '../upload/article_files/article_' . (int)$article_id . '/' );
    
    return true;
    
  }
}
