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

class Stories_Model_DbTable_Mutes extends Engine_Db_Table {

  protected $_rowClass = "Stories_Model_Mute";

  public function getAllMutesMembers($params = array()) {
    $select = $this->select()
    ->from($this->info('name'),array('*'))
    ->where('user_id =?',$params['user_id'])
    ->group('resource_id');
    $results = $this->fetchAll($select);
    $mutesUserIds = array();
    if(engine_count($results) > 0) {
      foreach($results as $result) {
        $mutesUserIds[] = $result->resource_id;
      }
    }
    return $mutesUserIds;
  }

  public function getMuteStory($resource_id)
  {
    $viewer = Engine_Api::_()->user()->getViewer();
    $viewer_id = $viewer->getIdentity();
    $select = $this->select()
    ->from($this->info('name'),array('mute_id'))
    ->where('resource_id =?',$resource_id)
    ->where('user_id =?',$viewer_id);
    return $this->fetchRow($select);
  }
}
