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

class Twitterclone_Model_DbTable_Dashboardlinks extends Engine_Db_Table {

  protected $_rowClass = "Twitterclone_Model_Dashboardlink";

  public function getInfo($params = array()) {

    $socialTable = Engine_Api::_()->getDbTable('dashboardlinks', 'twitterclone');
    $select = $socialTable->select()->order('order DESC');

    if (isset($params['enabled']) && !empty($params['enabled'])) {
      $select = $select->where('enabled = ?', 1);
    }

    if (isset($params['sublink'])) {
      $select = $select->where('sublink = ?', $params['sublink']);
    }

    return $socialTable->fetchAll($select);
  }

  public function getDashboardName($params = array()) {

    return $this->select()
                    ->from($this->info('name'), array('name'))
                    ->where('enabled = ?', 1)
                    ->where('dashboardlink_id =?', $params['dashboardlink_id'])
                    ->query()
                    ->fetchColumn();
  }
  
  public function order($categoryTypeId, $categoryType = 'category_id') {
    $select = $this->select()
            ->from($this->info('name'), 'dashboardlink_id')
            ->order('order DESC');
    if ($categoryType != 'dashboardlink_id')
      $currentOrder = $select->where($categoryType . ' = ?', $categoryTypeId);
    else
      $select = $select->where('sublink = ?', 0);
    return $select->query()->fetchAll(Zend_Db::FETCH_COLUMN);
  }
}
