/** * Extra treatment dealing with non latin encoding * Tricky solution */ function setVar($key, $value, $not_gpc = false) { if ($key == 'field_options' && is_array($value)) { foreach (array_keys($value) as $idx) { $value[$idx] = base64_encode($value[$idx]); } } parent::setVar($key, $value, $not_gpc); }
/** * assign a value to a variable * * @access public * @param string $key name of the variable to assign * @param mixed $value value to assign * @param bool $not_gpc */ function setVar($key, $value, $not_gpc = false) { $uservars = array_keys($this->getVars()); if (!in_array($key, $uservars)) { return $this->_profile->setVar($key, $value, $not_gpc); } return parent::setVar($key, $value, $not_gpc); }
public function setVar($key, $value, $not_gpc = false) { if ("form_handle" == $key) { $value = self::sanitize_handle_name($value); } parent::setVar($key, $value, $not_gpc); if ("on_before_save" == $key) { $this->cache_on_before_save_code(); } if ("on_after_save" == $key) { $this->cache_on_after_save_code(); } if ("custom_edit_check" == $key) { // Added for custom_edit_check var $this->cache_custom_edit_check_code(); } }
public function setVar($key, $value, $not_gpc = false) { if ("ele_handle" == $key) { $value = self::sanitize_handle_name($value); } parent::setVar($key, $value, $not_gpc); }
/** * save a profile field in the database * * @param XoopsObject|ProfileField $obj reference to the object * @param bool $force whether to force the query execution despite security settings * * @internal param bool $checkObject check if the object is dirty and clean the attributes * @return bool FALSE if failed, TRUE if already present and unchanged or successful */ public function insert(XoopsObject $obj, $force = false) { if (!$obj instanceof $this->className) { return false; } $profile_handler = xoops_getModuleHandler('profile', 'profile'); $obj->setVar('field_name', str_replace(' ', '_', $obj->getVar('field_name'))); $obj->cleanVars(); $defaultstring = ''; switch ($obj->getVar('field_type')) { case 'datetime': case 'date': $obj->setVar('field_valuetype', XOBJ_DTYPE_INT); $obj->setVar('field_maxlength', 10); break; case 'longdate': $obj->setVar('field_valuetype', XOBJ_DTYPE_MTIME); break; case 'yesno': $obj->setVar('field_valuetype', XOBJ_DTYPE_INT); $obj->setVar('field_maxlength', 1); break; case 'textbox': if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) { $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX); } break; case 'autotext': if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) { $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA); } break; case 'group_multi': case 'select_multi': case 'checkbox': $obj->setVar('field_valuetype', XOBJ_DTYPE_ARRAY); break; case 'language': case 'timezone': case 'theme': $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX); break; case 'dhtml': case 'textarea': $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA); break; } if ($obj->getVar('field_valuetype') === '') { $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX); } if (!in_array($obj->getVar('field_name'), $this->getUserVars()) && isset($_REQUEST['field_required'])) { if ($obj->isNew()) { //add column to table $changetype = 'ADD'; } else { //update column information $changetype = 'CHANGE `' . $obj->getVar('field_name', 'n') . '`'; } $maxlengthstring = $obj->getVar('field_maxlength') > 0 ? '(' . $obj->getVar('field_maxlength') . ')' : ''; //set type switch ($obj->getVar('field_valuetype')) { default: case XOBJ_DTYPE_ARRAY: case XOBJ_DTYPE_UNICODE_ARRAY: $type = 'mediumtext'; break; case XOBJ_DTYPE_UNICODE_EMAIL: case XOBJ_DTYPE_UNICODE_TXTBOX: case XOBJ_DTYPE_UNICODE_URL: case XOBJ_DTYPE_EMAIL: case XOBJ_DTYPE_TXTBOX: case XOBJ_DTYPE_URL: $type = 'varchar'; // varchars must have a maxlength if (!$maxlengthstring) { //so set it to max if maxlength is not set - or should it fail? $maxlengthstring = '(255)'; $obj->setVar('field_maxlength', 255); } break; case XOBJ_DTYPE_INT: $type = 'int'; break; case XOBJ_DTYPE_DECIMAL: $type = 'decimal(14,6)'; break; case XOBJ_DTYPE_FLOAT: $type = 'float(15,9)'; break; case XOBJ_DTYPE_OTHER: case XOBJ_DTYPE_UNICODE_TXTAREA: case XOBJ_DTYPE_TXTAREA: $type = 'text'; $maxlengthstring = ''; break; case XOBJ_DTYPE_MTIME: $type = 'date'; $maxlengthstring = ''; break; } $sql = 'ALTER TABLE `' . $profile_handler->table . '` ' . $changetype . ' `' . $obj->cleanVars['field_name'] . '` ' . $type . $maxlengthstring . ' NULL'; $result = $force ? $this->db->queryF($sql) : $this->db->query($sql); if (!$result) { return false; } } //change this to also update the cached field information storage $obj->setDirty(); if (!parent::insert($obj, $force)) { return false; } return $obj->getVar('field_id'); }
/** * @param XoopsObject|SystemBlock $obj * * @return int|bool object id on success, otherwise false */ public function insert(XoopsObject $obj, $force = true) { if (!$obj instanceof $this->className) { return false; } $obj->setVar('last_modified', time()); return parent::insert($obj, $force); }
/** * save a profile field in the database * * @param XoopsObject|ProfileField $obj reference to the object * @param bool $force whether to force the query execution despite security settings * @return bool FALSE if failed, TRUE if already present and unchanged or successful */ public function insertFields(XoopsObject $obj, $force = false) { $xoops = Xoops::getInstance(); $profile_handler = $xoops->getModuleHandler('profile', 'profile'); $obj->setVar('field_name', str_replace(' ', '_', $obj->getVar('field_name'))); $obj->cleanVars(false); //Don't quote switch ($obj->getVar('field_type')) { case "datetime": case "date": $obj->setVar('field_valuetype', XOBJ_DTYPE_INT); $obj->setVar('field_maxlength', 10); break; case "longdate": $obj->setVar('field_valuetype', XOBJ_DTYPE_MTIME); break; case "yesno": $obj->setVar('field_valuetype', XOBJ_DTYPE_INT); $obj->setVar('field_maxlength', 1); break; case "textbox": if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) { $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX); } break; case "autotext": if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) { $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA); } break; case "group_multi": case "select_multi": case "checkbox": $obj->setVar('field_valuetype', XOBJ_DTYPE_ARRAY); break; case "language": case "timezone": case "theme": $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX); break; case "dhtml": case "textarea": $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA); break; } if ($obj->getVar('field_valuetype') == "") { $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX); } if (!in_array($obj->getVar('field_name'), $this->getUserVars())) { if ($obj->isNew()) { //add column to table $changetype = "ADD"; } else { //update column information $changetype = "CHANGE `" . $obj->getVar('field_name', 'n') . "`"; } $maxlengthstring = $obj->getVar('field_maxlength') > 0 ? "(" . $obj->getVar('field_maxlength') . ")" : ""; //set type switch ($obj->getVar('field_valuetype')) { default: case XOBJ_DTYPE_ARRAY: case XOBJ_DTYPE_EMAIL: case XOBJ_DTYPE_TXTBOX: case XOBJ_DTYPE_URL: $type = "varchar"; // varchars must have a maxlength if (!$maxlengthstring) { //so set it to max if maxlength is not set - or should it fail? $maxlengthstring = "(255)"; $obj->setVar('field_maxlength', 255); } break; case XOBJ_DTYPE_INT: $type = "int"; break; case XOBJ_DTYPE_DECIMAL: $type = "decimal(14,6)"; break; case XOBJ_DTYPE_FLOAT: $type = "float(15,9)"; break; case XOBJ_DTYPE_OTHER: case XOBJ_DTYPE_TXTAREA: $type = "text"; $maxlengthstring = ""; break; case XOBJ_DTYPE_MTIME: $type = "date"; $maxlengthstring = ""; break; } $sql = "ALTER TABLE `" . $profile_handler->table . "` " . $changetype . " `" . $obj->cleanVars['field_name'] . "` " . $type . $maxlengthstring . ' NULL'; if (!$this->db->query($sql)) { return false; } } //change this to also update the cached field information storage $obj->setDirty(); if (!parent::insert($obj, $force)) { return false; } return $obj->getVar('field_id'); }