示例#1
0
 function getUserProperties()
 {
     $result = array();
     $mainframe =& JFactory::getApplication();
     $params =& ComJea::getParams();
     $access =& ComJea::getAccess();
     $default_limit = $params->get('list_limit', 10);
     $cat = $mainframe->getUserStateFromRequest('com_jea.user.properties.cat', 'cat', -1, 'int');
     $limit = $mainframe->getUserStateFromRequest('com_jea.user.limit', 'limit', $default_limit, 'int');
     $limitstart = JRequest::getInt('limitstart', 0);
     $order = $this->_db->getEscaped(JRequest::getCmd('filter_order', 'ordering'));
     $order_dir = $this->_db->getEscaped(JRequest::getCmd('filter_order_Dir', 'asc'));
     $rows = array();
     if ($access->canEdit || $access->canEditOwn) {
         $select = $this->_getSqlBaseSelect();
         $where = '';
         if ($access->canEditOwn) {
             $user =& JFactory::getUser();
             $where = ' WHERE tp.created_by=' . intval($user->get('id'));
         }
         if ($cat >= 0) {
             if (!empty($where)) {
                 $where .= ' AND is_renting=' . $cat;
             } else {
                 $where .= ' WHERE is_renting=' . $cat;
             }
         }
         $sql = $select . $where . ' ORDER BY ' . $order . ' ' . strtoupper($order_dir);
         //echo $sql;
         $rows = $this->_getList($sql, $limitstart, $limit);
         if ($this->_db->getErrorNum()) {
             JError::raiseWarning(200, $this->_db->getErrorMsg());
             return false;
         }
     }
     $result['limitstart'] = $limitstart;
     $result['limit'] = $limit;
     $result['total'] = $this->_getListCount($sql);
     $result['rows'] = $rows;
     $result['order'] = $order;
     $result['order_dir'] = $order_dir;
     $result['cat'] = $cat;
     return $result;
 }
示例#2
0
 function deleteimg()
 {
     $access =& ComJea::getAccess();
     if ($access->canEdit || $access->canEditOwn) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'properties.php';
         $model = new JeaModelProperties();
         $id = JRequest::getInt('id', 0);
         $Itemid = JRequest::getInt('Itemid', 0);
         $model->delete_img();
         $this->setRedirect('index.php?option=com_jea&view=manage&' . 'layout=form&id=' . $id . '&Itemid=' . $Itemid);
     }
 }
示例#3
0
 function getUserProperties()
 {
     $result = array();
     $mainframe =& JFactory::getApplication();
     $params =& ComJea::getParams();
     $access =& ComJea::getAccess();
     $default_limit = $params->get('list_limit', 10);
     $user =& JFactory::getUser();
     $userid = $user->get('id');
     $usergid = $user->get('gid');
     $cat = $mainframe->getUserStateFromRequest('com_jea.user.properties.cat', 'cat', -1, 'int');
     $limit = $mainframe->getUserStateFromRequest('com_jea.user.limit', 'limit', $default_limit, 'int');
     $keyserch = @JRequest::getVar(keyserch);
     //kiem tra xem co dieu kien serch moi khong?
     $limitstart = JRequest::getInt('limitstart', 0);
     if (@JRequest::getVar(cat) || @JRequest::getVar(published) || @JRequest::getVar(type_id) || @JRequest::getVar(keyserch)) {
         $limitstart = 0;
     }
     $order = $this->_db->getEscaped(JRequest::getCmd('filter_order', 'id'));
     $order = 'id';
     $order_dir = $this->_db->getEscaped(JRequest::getCmd('filter_order_Dir', 'desc'));
     $types = $mainframe->getUserStateFromRequest('com_jea.user.properties.types', 'type_id', 0, 'int');
     $published = $mainframe->getUserStateFromRequest('com_jea.user.properties.published', 'published', -1, 'int');
     $rows = array();
     //echo "type ne $types";
     if ($access->canEdit || $access->canEditOwn) {
         $select = $this->_getSqlBaseSelect();
         $where = '';
         if ($access->canEditOwn) {
             $user =& JFactory::getUser();
             $where = ' WHERE tp.created_by=' . intval($user->get('id'));
         }
         if ($cat >= 0) {
             if (!empty($where)) {
                 $where .= ' AND kind_id=' . $cat;
             } else {
                 $where .= ' WHERE kind_id=' . $cat;
             }
         }
         if ($types) {
             if (!empty($where)) {
                 $where .= ' AND type_id=' . $types;
             } else {
                 $where .= ' WHERE type_id=' . $types;
             }
         }
         if ($published != -1) {
             if (!empty($where)) {
                 $where .= ' AND tp.published=' . $published;
             } else {
                 $where .= ' WHERE tp.published=' . $published;
             }
         }
         /* hoan: nếu là admin thì sẽ hiện all else chỉ hiện của nó */
         if ($usergid <= 24) {
             if (!empty($where)) {
                 $where .= ' AND tp.created_by = ' . $userid;
             } else {
                 $where .= ' WHERE tp.created_by =' . $userid;
             }
         }
         if ($keyserch != "") {
             if (!empty($where)) {
                 $where .= " AND tp.ref LIKE '%{$keyserch}%'";
             } else {
                 $where .= " WHERE tp.ref LIKE '%{$keyserch}%'";
             }
         }
         $sql = $select . $where . ' ORDER BY ' . $order . ' ' . strtoupper($order_dir);
         //echo $where;
         $rows = $this->_getList($sql, $limitstart, $limit);
         if ($this->_db->getErrorNum()) {
             JError::raiseWarning(200, $this->_db->getErrorMsg());
             return false;
         }
     }
     $result['limitstart'] = $limitstart;
     $result['limit'] = $limit;
     $result['total'] = $this->_getListCount($sql);
     $result['rows'] = $rows;
     $result['order'] = $order;
     $result['order_dir'] = $order_dir;
     $result['cat'] = $cat;
     $result['type_id'] = $types;
     $result['published'] = $published;
     return $result;
 }