<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class User_Model_DbTable_Block extends Engine_Db_Table {

  public function anyOneBlocked($params = array()) {
    $viewer = Engine_Api::_()->user()->getViewer();
    $rName = $this->info('name');
    $select = $this->select()
              ->where("user_id = ".$viewer->getIdentity().' || user_id = '.$params['user_id'])
              ->Where("blocked_user_id = ".$viewer->getIdentity().' || blocked_user_id = '.$params['user_id']);
    return $this->fetchRow($select);
  }

  public function isBlocked($params = array()) {
    $viewer = Engine_Api::_()->user()->getViewer();
    $rName = $this->info('name');
    $select = $this->select()
              ->where("user_id =?",$viewer->getIdentity())
              ->where("blocked_user_id =?",$params["user_id"]);

    $row = $this->fetchRow($select);
    if(!empty($params["remove"])){
      if($row){
        $row->delete();
        return "delete";
      }
    }
    return $row;
  }
}
