<?php

/**
 * @Copyright Copyright (C) 2009-2010 Ahmad Bilal
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * Company:     Buruj Solutions
 + Contact:     https://www.burujsolutions.com , info@burujsolutions.com
 * Created on:  Nov 22, 2010
 ^
 + Project:     JS Jobs
 ^ 
 */
 
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.model');
jimport('joomla.html.html');
$option = JFactory::getApplication()->input->get('option', 'com_jsjobs');

class JSJobsModelAges extends JSModel {

    var $_uid = null;
    var $_ages = null;
    var $_client_auth_key = null;
    var $_siteurl = null;

    function __construct() { // clean it.
        parent::__construct();
        $this->_client_auth_key = $this->getJSModel('common')->getClientAuthenticationKey();
        $this->_siteurl = JURI::root();
        $user = JFactory::getUser();
        $this->_uid = $user->id;
    }

    function getAges($title) {
        if (!$this->_ages) {// make problem with age from, age to
            try{
                $db = JFactory::getDBO();
                $query = "SELECT id, title FROM `#__js_job_ages` WHERE status = 1";
                if ($this->_client_auth_key != "")
                    $query.=" AND serverid != '' AND serverid != 0";
                $query.=" ORDER BY ordering ASC ";
                $db->setQuery($query);
                $rows = $db->loadObjectList();
                $this->_ages = $rows;
            }catch (RuntimeException $e){
                echo $db->stderr();
                return false;
            }
        }
        $ages = array();
        if ($title)
            $ages[] = array('value' => JText::_(''), 'text' => $title);
        foreach ($this->_ages as $row) {
            $ages[] = array('value' => $row->id, 'text' => JText::_($row->title));
        }
        return $ages;
    }

}
?>	
