Example #1
0
 /**
  * Retrieve display elements
  *
  * @return array
  */
 public function getDisplayElements()
 {
     global $log, $login, $members_fields_cats;
     $display_elements = array();
     if (!count($this->_form_elements) > 0) {
         $categories = FieldsCategories::getList();
         try {
             foreach ($categories as $c) {
                 $cpk = FieldsCategories::PK;
                 $cat_label = null;
                 foreach ($members_fields_cats as $conf_cat) {
                     if ($conf_cat['id'] == $c->{$cpk}) {
                         $cat_label = $conf_cat['category'];
                         break;
                     }
                 }
                 if ($cat_label === null) {
                     $cat_label = $c->category;
                 }
                 $cat = (object) array('id' => $c->{$cpk}, 'label' => $cat_label, 'elements' => array());
                 $elements = $this->_categorized_fields[$c->{$cpk}];
                 $cat->elements = array();
                 foreach ($elements as $elt) {
                     $o = (object) $elt;
                     if (in_array($o->field_id, $this->_non_display_elements)) {
                         continue;
                     }
                     if (!($o->visible == self::ADMIN && (!$login->isAdmin() && !$login->isStaff()))) {
                         if ($o->visible == self::HIDDEN) {
                             continue;
                         }
                         $cat->elements[$o->field_id] = $o;
                     }
                 }
                 if (count($cat->elements) > 0) {
                     $display_elements[] = $cat;
                 }
             }
         } catch (Exception $e) {
             $log->log('An error occured getting display elements', Analog::ERROR);
         }
     }
     return $display_elements;
 }
Example #2
0
            $required = $_POST[$field . '_required'];
        } else {
            $required = false;
        }
        $res[$current_cat][] = array('field_id' => $field, 'label' => $_POST[$field . '_label'], 'category' => $_POST[$field . '_category'], 'visible' => $_POST[$field . '_visible'], 'required' => $required);
        $pos++;
    }
    //okay, we've got the new array, we send it to the
    //Object that will store it in the database
    $success = $fc->setFields($res);
    FieldsCategories::setCategories($_POST['categories']);
    if ($success === true) {
        $success_detected[] = _T("Fields configuration has been successfully stored");
    } else {
        $error_detected[] = _T("An error occured while storing fields configuration :(");
    }
}
$tpl->assign('page_title', _T("Fields configuration"));
$tpl->assign('time', time());
$tpl->assign('categories', FieldsCategories::getList());
$tpl->assign('categorized_fields', $fc->getCategorizedFields());
$tpl->assign('non_required', $fc->getNonRequired());
$tpl->assign('current', $current);
$tpl->assign('require_dialog', true);
$tpl->assign('require_sorter', true);
$tpl->assign('success_detected', $success_detected);
$tpl->assign('error_detected', $error_detected);
//$tpl->assign('require_sorter', true);
$content = $tpl->fetch('config_fields.tpl');
$tpl->assign('content', $content);
$tpl->display('page.tpl');