Esempio n. 1
0
 function getFieldsbyPositions($published = true, $usergroups = true, $mode = 'read')
 {
     if ($published) {
         $sqlpublished = "AND f.published = 1 ";
     } else {
         $sqlpublished = "";
     }
     $this->_db->setQuery("SELECT f.* FROM #__adsmanager_fields AS f " . "WHERE f.pos != -1 {$sqlpublished} ORDER by f.posorder");
     $fields = $this->_db->loadObjectList();
     if ($this->_db->getErrorNum()) {
         echo $this->_db->stderr();
         return;
     }
     foreach ($fields as $key => $field) {
         $fields[$key]->options = json_decode($field->options);
     }
     if ($usergroups) {
         require_once JPATH_ROOT . '/components/com_adsmanager/lib/tpermissions.php';
         $fields = TPermissions::getAuthorisedFields($fields, $mode);
     }
     // establish the hierarchy of the menu
     $fDisplay = array();
     // first pass - collect children
     if (isset($fields)) {
         foreach ($fields as $f) {
             $pt = $f->pos;
             $list = @$fDisplay[$pt] ? $fDisplay[$pt] : array();
             array_push($list, $f);
             $fDisplay[$pt] = $list;
         }
     }
     return $fDisplay;
 }
Esempio n. 2
0
 function getFieldsbyPositions($published = true, $usergroups = true, $mode = 'read', $type = 'details')
 {
     if ($type == "details") {
         $where = "f.pos != -1";
         if ($published) {
             $where .= " AND f.published = 1 ";
         }
         $this->_db->setQuery("SELECT f.*,f.pos as positionid FROM #__adsmanager_fields AS f " . "WHERE {$where} ORDER by f.posorder ASC");
         $fields = $this->_db->loadObjectList();
         if ($this->_db->getErrorNum()) {
             echo $this->_db->stderr();
             return;
         }
     } else {
         $where = "1";
         if ($published) {
             $where .= " AND f.published = 1 ";
         }
         $query = "SELECT f.*,fp.positionid FROM #__adsmanager_fields AS f \n    \t\t\t\t  INNER JOIN #__adsmanager_field2position as fp ON fp.fieldid = f.fieldid\n    \t\t\t\t  WHERE {$where} ORDER by fp.ordering ASC";
         $this->_db->setQuery($query);
         $fields = $this->_db->loadObjectList();
         if ($this->_db->getErrorNum()) {
             echo $this->_db->stderr();
             return;
         }
     }
     foreach ($fields as $key => $field) {
         $fields[$key]->options = json_decode($field->options);
     }
     if ($usergroups) {
         require_once JPATH_ROOT . '/components/com_adsmanager/lib/tpermissions.php';
         $fields = TPermissions::getAuthorisedFields($fields, $mode);
     }
     // establish the hierarchy of the menu
     $fDisplay = array();
     // first pass - collect children
     if (isset($fields)) {
         foreach ($fields as $f) {
             $pt = $f->positionid;
             $list = @$fDisplay[$pt] ? $fDisplay[$pt] : array();
             array_push($list, $f);
             $fDisplay[$pt] = $list;
         }
     }
     return $fDisplay;
 }