member_form.class.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. class member_form {
  3. var $modelid;
  4. var $fields;
  5. var $id;
  6. var $formValidator;
  7. function __construct($modelid) {
  8. $this->modelid = $modelid;
  9. $this->fields = getcache('model_field_'.$modelid,'model');
  10. }
  11. function get($data = array()) {
  12. $_roleid = param::get_cookie('_roleid');
  13. $_groupid = param::get_cookie('_groupid');
  14. $this->data = $data;
  15. if(isset($data['id'])) $this->id = $data['id'];
  16. $info = array();
  17. foreach($this->fields as $field=>$v) {
  18. if(defined('IN_ADMIN')) {
  19. if($v['disabled'] || $v['iscore'] || check_in($_roleid, $v['unsetroleids']) || check_in($_groupid, $v['unsetgroupids'])) continue;
  20. } else {
  21. if($v['disabled'] || $v['iscore'] || !$v['isadd'] || check_in($_roleid, $v['unsetroleids']) || check_in($_groupid, $v['unsetgroupids'])) continue;
  22. }
  23. $func = $v['formtype'];
  24. $value = isset($data[$field]) ? new_html_special_chars($data[$field]) : '';
  25. if($func=='pages' && isset($data['maxcharperpage'])) {
  26. $value = $data['paginationtype'].'|'.$data['maxcharperpage'];
  27. }
  28. if(!method_exists($this, $func)) continue;
  29. $form = $this->$func($field, $value, $v);
  30. if($form !== false) {
  31. $star = $v['minlength'] || $v['pattern'] ? 1 : 0;
  32. $info[$field] = array('name'=>$v['name'], 'tips'=>$v['tips'], 'form'=>$form, 'star'=>$star, 'isbase'=>$v['isbase'],'isomnipotent'=>$v['isomnipotent'],'formtype'=>$v['formtype']);
  33. }
  34. }
  35. return $info;
  36. }
  37. }?>