public function load_from_post() { $this->item = $_REQUEST['comment-item']; $this->user = $_REQUEST['comment-user']; $this->name = $_REQUEST['comment-name']; $this->email = $_REQUEST['comment-email']; $this->url = $_REQUEST['comment-url']; $this->status = intval($_REQUEST['comment-status']); $this->message = $_REQUEST['comment-message']; $this->reply_to = $_REQUEST['comment-reply_to']; $this->date_created = core_date2ts($_REQUEST['comment-date_created']); }
public function load_from_post() { global $website; // it can only be extension options! if (!empty($this->definition->options)) { foreach ($this->definition->options as $extension_option) { // get property info $property = new property(); $property->load_from_object($extension_option, $this->settings->{$extension_option->id}, $this); $value = ''; switch ($property->type) { case 'text': case 'textarea': // multilang $value = array(); foreach ($website->languages_list as $lang) { $value[$lang] = $_REQUEST['property-' . $extension_option->id . '-' . $lang]; } break; case 'link': // multilang and title+link $value = array(); foreach ($website->languages_list as $lang) { $value[$lang] = $_REQUEST['property-' . $extension_option->id . '-' . $lang . '-link'] . '##' . $_REQUEST['property-' . $extension_option->id . '-' . $lang . '-title']; } break; case 'date': case 'datetime': $value = core_date2ts($_REQUEST['property-' . $extension_option->id]); break; case 'moption': $value = implode(',', $_REQUEST['property-' . $extension_option->id]); break; case 'coordinates': $value = $_REQUEST['property-' . $extension_option->id . '-latitude'] . '#' . $_REQUEST['property-' . $extension_option->id . '-longitude']; break; case 'boolean': $value = 0; if ($_REQUEST['property-' . $extension_option->id] == '1') { $value = 1; } break; default: // direct value $value = $_REQUEST['property-' . $extension_option->id]; } $this->settings[$extension_option->id] = $value; } } }
public function load_from_post() { global $theme; global $user; $ws_theme = $theme; if ($this->theme != $theme->name) { $ws_theme = new theme(); $ws_theme->load($this->theme); } $this->name = $_REQUEST['title']; $this->protocol = $_REQUEST['protocol']; $this->subdomain = $_REQUEST['subdomain']; $this->domain = $_REQUEST['domain']; $this->folder = $_REQUEST['folder']; $this->word_separator = $_REQUEST['word_separator']; $this->redirect_to = $_REQUEST['redirect_to']; $this->wrong_path_action = $_REQUEST['wrong_path_action']; $this->wrong_path_redirect = $_REQUEST['wrong_path_redirect']; $this->empty_path_action = $_REQUEST['empty_path_action']; $this->date_format = $_REQUEST['date_format']; $this->tinymce_css = $_REQUEST['tinymce_css']; $this->resize_uploaded_images = intval($_REQUEST['resize_uploaded_images']); $this->comments_enabled_for = intval($_REQUEST['comments_enabled_for']); $this->comments_default_moderator = $_REQUEST['comments_default_moderator']; $this->share_files_media_browser = intval($_REQUEST['share_files_media_browser']); $this->additional_scripts = $_REQUEST['additional_scripts']; if (empty($_REQUEST['homepage_from_structure'])) { $this->homepage = $_REQUEST['homepage']; } $this->permission = intval($_REQUEST['permission']); $this->default_timezone = $_REQUEST['default_timezone']; $this->mail_mailer = $_REQUEST['mail_mailer'][0]; $this->mail_server = $_REQUEST['mail_server']; $this->mail_port = intval($_REQUEST['mail_port']); $this->mail_security = intval($_REQUEST['mail_security']); $this->mail_user = $_REQUEST['mail_user']; $this->mail_address = $_REQUEST['mail_address']; if (!empty($_REQUEST['mail_password'])) { $this->mail_password = $_REQUEST['mail_password']; } $ce = explode("\n", $_REQUEST['contact_emails']); $this->contact_emails = array(); foreach ($ce as $cemail) { $cemail = trim($cemail); if (empty($cemail)) { continue; } $this->contact_emails[] = $cemail; } $this->favicon = intval($_REQUEST['website-favicon']); // languages and locales $this->languages = array(); $this->languages_published = array(); for ($li = 0; $li < count($_REQUEST['language-id']); $li++) { $variant = trim($_REQUEST['language-variant-code'][$li]); $code = $_REQUEST['language-id'][$li]; if (!empty($variant)) { $code .= '_' . $variant; } $this->languages[$code] = array('language' => $_REQUEST['language-id'][$li], 'variant' => $variant, 'code' => $code, 'system_locale' => $_REQUEST['language-locale'][$li]); $this->languages_published[] = $_REQUEST['language-published'][$li] == '1' ? $code : ''; } // Website metatags $this->metatag_description = array(); $this->metatag_keywords = array(); $this->metatags = array(); foreach ($this->languages as $language) { $lcode = $language['code']; $this->metatag_description[$lcode] = $_REQUEST['metatag_description-' . $lcode]; $this->metatag_keywords[$lcode] = $_REQUEST['metatag_keywords-' . $lcode]; $this->metatags[$lcode] = $_REQUEST['metatags-' . $lcode]; } // website aliases $this->aliases = array(); if (empty($_POST['website-aliases-alias'])) { $_POST['website-aliases-alias'] = array(); } foreach ($_POST['website-aliases-alias'] as $key => $value) { $value = trim($value); if (!empty($value)) { $value_real = trim($_POST['website-aliases-real'][$key]); if (!empty($value_real)) { $this->aliases[$value] = $value_real; } } } $this->theme_options = array(); // Theme style (common property) $this->theme_options['style'] = $_REQUEST['property-style']; if (!empty($ws_theme->options)) { foreach ($ws_theme->options as $theme_option) { // get property info $property = new property(); $property->load_from_theme($theme_option, NULL, NULL, NULL, $this->id); $value = ''; switch ($property->type) { case 'text': case 'textarea': case 'rich_textarea': // multilang $value = array(); if (!is_array($this->languages_list)) { $this->languages_list = array(); } foreach ($this->languages_list as $lang) { $value[$lang] = $_REQUEST['property-' . $theme_option->id . '-' . $lang]; } break; case 'link': // multilang and title+link $value = array(); foreach ($this->languages_list as $lang) { $value[$lang] = $_REQUEST['property-' . $theme_option->id . '-' . $lang . '-link'] . '##' . $_REQUEST['property-' . $theme_option->id . '-' . $lang . '-title']; } break; case 'date': case 'datetime': $value = core_date2ts($_REQUEST['property-' . $theme_option->id]); break; case 'moption': $value = implode(',', $_REQUEST['property-' . $theme_option->id]); break; case 'coordinates': $value = $_REQUEST['property-' . $theme_option->id . '-latitude'] . '#' . $_REQUEST['property-' . $theme_option->id . '-longitude']; break; case 'decimal': $value = $_REQUEST['property-' . $theme_option->id]; $value = core_string2decimal($value); break; default: // direct value $value = $_REQUEST['property-' . $theme_option->id]; } $this->theme_options[$theme_option->id] = $value; } } }
public function load_from_post() { global $website; global $user; $this->association = $_REQUEST['association'][0]; $this->category = intval($_REQUEST['category']); $this->embedding = $_REQUEST['embedding'][0] != '1' || $this->association == 'free' ? '0' : '1'; $this->template = $this->embedding == '0' || $this->association == 'free' ? $_REQUEST['template'] : ''; $this->author = intval($_REQUEST['item-author']); $this->date_to_display = empty($_REQUEST['date_to_display']) ? '' : core_date2ts($_REQUEST['date_to_display']); $this->date_published = empty($_REQUEST['date_published']) ? '' : core_date2ts($_REQUEST['date_published']); $this->date_unpublish = empty($_REQUEST['date_unpublish']) ? '' : core_date2ts($_REQUEST['date_unpublish']); $this->access = intval($_REQUEST['access']); $this->groups = $_REQUEST['groups']; if ($this->access < 3) { $this->groups = array(); } if ($user->permission("items.publish") != 'false') { $this->permission = intval($_REQUEST['permission']); } // if comment settings were not visible, keep the original values if (isset($_REQUEST['item-comments_enabled_to'])) { $this->comments_enabled_to = intval($_REQUEST['item-comments_enabled_to']); $this->comments_moderator = intval($_REQUEST['item-comments_moderator']); } // language strings and options $this->dictionary = array(); $this->paths = array(); $template = $this->load_template(); //$fields = array('title', 'body'); $fields = array('title', 'tags'); if (!is_array($template->sections)) { $template->sections = array('id' => 'main'); } foreach ($template->sections as $section) { if (is_object($section)) { $section = (array) $section; } // compatibility fix: auto-correct template sections with missing ID (only "code" provided) if (!isset($section['id'])) { $section['id'] = $section['code']; } if (is_array($section)) { $section = $section['id']; } $fields[] = 'section-' . $section; } foreach ($_REQUEST as $key => $value) { if (empty($value)) { continue; } foreach ($fields as $field) { if (substr($key, 0, strlen($field . '-')) == $field . '-') { $this->dictionary[substr($key, strlen($field . '-'))][$field] = $value; } } if (substr($key, 0, strlen('path-')) == 'path-') { // set a path only if "Free" or "Category/Own Path" associations if ($this->association == 'free' || $this->association == 'category' && $this->embedding == 0) { $this->paths[substr($key, strlen('path-'))] = $value; } } } // image galleries $this->galleries = array(); $items = explode("#", $_REQUEST['items-gallery-elements-order']); if (!is_array($items)) { $items = array(); } $gallery_items = array(); $gallery_items[0] = array(); if (!is_array($website->languages)) { $website->languages = array(); } foreach ($items as $item) { if (empty($item)) { continue; } // capture image captions $gallery_items[0][$item] = array(); foreach ($website->languages_list as $lang) { $gallery_items[0][$item][$lang] = $_REQUEST['items-gallery-item-' . $item . '-dictionary-' . $lang]; } } $this->galleries = $gallery_items; // galleries[0] = array( [id-file] => array(es => '', ca => '',.. ), [id-file-2] => array... ) }
public function load_from_post() { //$this->website = $_REQUEST['webuser-website']; $this->username = trim($_REQUEST['webuser-username']); if (!empty($_REQUEST['webuser-password'])) { $this->set_password($_REQUEST['webuser-password']); } $this->email = $_REQUEST['webuser-email']; $this->groups = $_REQUEST['webuser-groups']; $this->fullname = $_REQUEST['webuser-fullname']; $this->gender = $_REQUEST['webuser-gender'][0]; $this->avatar = $_REQUEST['webuser-avatar']; if (!empty($_REQUEST['webuser-birthdate'])) { $this->birthdate = core_date2ts($_REQUEST['webuser-birthdate']); } else { $this->birthdate = ''; } $this->language = $_REQUEST['webuser-language']; $this->newsletter = $_REQUEST['webuser-newsletter'] == '1' ? '1' : '0'; $this->access = $_REQUEST['webuser-access']; $this->access_begin = empty($_REQUEST['webuser-access-begin']) ? '' : core_date2ts($_REQUEST['webuser-access-begin']); $this->access_end = empty($_REQUEST['webuser-access-end']) ? '' : core_date2ts($_REQUEST['webuser-access-end']); $this->country = $_REQUEST['webuser-country']; $this->timezone = $_REQUEST['webuser-timezone']; $this->address = $_REQUEST['webuser-address']; $this->zipcode = $_REQUEST['webuser-zipcode']; $this->location = $_REQUEST['webuser-location']; $this->phone = $_REQUEST['webuser-phone']; $this->social_website = $_REQUEST['webuser-social_website']; $this->private_comment = $_REQUEST['webuser-private_comment']; // social profiles is a navigate cms private field }
public static function save_properties_from_post($object_type, $object_id, $template = null, $element = null, $object_uid = null) { global $DB; global $website; global $theme; $dictionary = array(); // load properties associated with the element type if ($object_type == 'block_group_block') { $block = block::block_group_block($template, $element); $properties = $block->properties; if (!is_numeric($object_id)) { $block_group_id = $DB->query_single('MAX(id)', 'nv_block_groups', ' code = ' . protect($template) . ' AND website = ' . $website->id); $object_id = $block_group_id; if (empty($block_group_id)) { $object_id = 0; } } } else { if ($object_type == 'extension_block') { // in this case, the parameters must match the following: // $element => (not used) // $template => type of the block in the extension definition // $object_type => "extension_block" // $object_id => type of the block_group (f.e. "sidebar" or the one defined in the theme definition) // $object_uid => the unique id assigned to the block in the block_group // find the extension block definition, to get the list of properties $extensions_blocks = extension::blocks(); for ($eb = 0; $eb < count($extensions_blocks); $eb++) { if ($extensions_blocks[$eb]->id == $template) { $properties = $extensions_blocks[$eb]->properties; break; } } // we must find the REAL numeric block group ID (based on its code) to get the assigned property values // $object_id MUST BE the numeric ID of the block group (we have only its codename, not the numeric ID) if (!empty($template)) { $block_group_id = $DB->query_single('MAX(id)', 'nv_block_groups', ' code = ' . protect($object_id) . ' AND website = ' . $website->id); $object_id = $block_group_id; if (empty($block_group_id)) { $object_id = 0; } } $object_type = "block_group-extension-block"; } else { if ($object_type == 'webuser') { // the properties set in the theme definition $properties = $theme->webusers['properties']; } else { if (empty($template)) { $template = $_REQUEST['property-template']; } if (empty($element)) { $element = $_REQUEST['property-element']; } $properties = property::elements($template, $element); } } } if (!is_array($properties)) { $properties = array(); } foreach ($properties as $property) { // ALWAYS SAVE the property value, even if it is empty $property_value = $_REQUEST['property-' . $property->id]; // multilanguage property? if (in_array($property->type, array('text', 'textarea', 'link', 'rich_textarea')) || @$property->multilanguage == 'true' || @$property->multilanguage === true) { $property_value = '[dictionary]'; } // date/datetime property? if ($property->type == 'date' || $property->type == 'datetime') { $property_value = core_date2ts($_REQUEST['property-' . $property->id]); } if ($property->type == 'moption' && !empty($_REQUEST['property-' . $property->id])) { $property_value = implode(',', $_REQUEST['property-' . $property->id]); } if ($property->type == 'coordinates') { $property_value = $_REQUEST['property-' . $property->id . '-latitude'] . '#' . $_REQUEST['property-' . $property->id . '-longitude']; } if ($property->type == 'decimal') { $property_value = core_string2decimal($_REQUEST['property-' . $property->id]); } if ($property->type == 'webuser_groups' && !empty($_REQUEST['property-' . $property->id])) { $property_value = 'g' . implode(',g', $_REQUEST['property-' . $property->id]); } // boolean (checkbox): if not checked, form does not send the value if ($property->type == 'boolean' && !isset($_REQUEST['property-' . $property->id])) { $property_value = 0; } // item (select2): if no selection, the form does not send a value (HTML); // if we don't set an empty value, Navigate would take that as non-existant field and would set the default value, // which is different as the user may really want to set "empty" as the value if (($property->type == 'element' || $property->type == 'item') && !isset($_REQUEST['property-' . $property->id])) { $property_value = ""; } // remove the old property row $DB->execute(' DELETE FROM nv_properties_items WHERE property_id = ' . protect($property->id) . ' AND element = ' . protect($object_type) . ' AND node_id = ' . protect($object_id) . (empty($object_uid) ? '' : ' AND node_uid = ' . protect($object_uid)) . ' AND website = ' . $website->id); // now insert the new row $DB->execute(' INSERT INTO nv_properties_items (id, website, property_id, element, node_id, node_uid, name, value) VALUES ( 0, :website, :property_id, :type, :object_id, :object_uid, :name, :value )', array(':website' => $website->id, ':property_id' => $property->id, ':type' => $object_type, ':object_id' => value_or_default($object_id, 0), ':object_uid' => value_or_default($object_uid, ""), ':name' => value_or_default($property->name, $property->id), ':value' => value_or_default($property_value, ""))); // save in the dictionary the multilanguage properties $default_language = ''; if ($property->multilanguage === 'false' || $property->multilanguage === false) { $default_language = $website->languages_list[0]; } if (in_array($property->type, array('text', 'textarea', 'rich_textarea')) || @$property->multilanguage == 'true' || @$property->multilanguage === true) { foreach ($website->languages_list as $lang) { if (!empty($default_language)) { // property is NOT multilanguage, use the first value for all languages $_REQUEST['property-' . $property->id . '-' . $lang] = $_REQUEST['property-' . $property->id . '-' . $default_language]; } $dictionary[$lang]['property-' . $property->id . '-' . $lang] = $_REQUEST['property-' . $property->id . '-' . $lang]; } } else { if ($property->type == 'link') { foreach ($website->languages_list as $lang) { $link = $_REQUEST['property-' . $property->id . '-' . $lang . '-link'] . '##' . $_REQUEST['property-' . $property->id . '-' . $lang . '-title'] . '##' . $_REQUEST['property-' . $property->id . '-' . $lang . '-target']; $dictionary[$lang]['property-' . $property->id . '-' . $lang] = $link; if (!empty($default_language)) { // property is NOT multilanguage, use the first value for all languages $dictionary[$lang]['property-' . $property->id . '-' . $lang] = $dictionary[$lang]['property-' . $property->id . '-' . $default_language]; } } } } } if (!empty($dictionary)) { $property_element = $_REQUEST['property-element']; if ($object_type == 'block_group_block') { $property_element = 'block_group_block'; } else { if ($object_type == 'block_group-extension-block') { $property_element = 'block_group-extension-block'; } } webdictionary::save_element_strings('property-' . $property_element, $object_id, $dictionary, $website->id, $object_uid); } return true; }
public function load_from_post() { global $DB; global $website; $this->type = $_REQUEST['type']; $this->date_published = empty($_REQUEST['date_published']) ? '' : core_date2ts($_REQUEST['date_published']); $this->date_unpublish = empty($_REQUEST['date_unpublish']) ? '' : core_date2ts($_REQUEST['date_unpublish']); $this->access = intval($_REQUEST['access']); $this->groups = $_REQUEST['groups']; if ($this->access < 3) { $this->groups = array(); } $this->enabled = intval($_REQUEST['enabled']); $this->notes = pquotes($_REQUEST['notes']); $this->categories = ''; if (!empty($_REQUEST['categories'])) { $this->categories = explode(',', $_REQUEST['categories']); } $this->exclusions = ''; if (!empty($_REQUEST['exclusions'])) { $this->exclusions = explode(',', $_REQUEST['exclusions']); } if ($_REQUEST['all_categories'] == '1' || is_array($_REQUEST['all_categories']) && $_REQUEST['all_categories'][0] == '1') { $this->categories = array(); $this->exclusions = array(); } $this->elements = array(); if (!empty($_REQUEST['elements_selection']) && $_REQUEST['elements_display'][0] != 'all') { $this->elements = array($_REQUEST['elements_display'][0] => $_REQUEST['elements_selection']); } $this->dictionary = array(); // for titles $this->trigger = array(); $this->action = array(); if (empty($this->class)) { $this->class = 'block'; } switch ($this->class) { case 'poll': foreach ($website->languages_list as $lang) { $this->dictionary[$lang]['title'] = $_REQUEST['title-' . $lang]; $this->trigger[$lang] = array(); $answers_order = explode("#", $_REQUEST['poll-answers-table-order-' . $lang]); foreach ($_REQUEST['poll-answers-table-title-' . $lang] as $fcode => $fval) { $pos = array_search("poll-answers-table-row-" . $fcode, $answers_order); if ($pos === false) { $pos = $fcode; } $fval = trim($fval); if (empty($fval)) { continue; } $this->trigger[$lang][$pos] = array('title' => $fval, 'code' => $fcode, 'votes' => intval($_REQUEST['poll-answers-table-votes-' . $lang][$fcode])); } ksort($this->trigger[$lang]); } break; case 'block': case 'theme': default: $fields_title = array('title'); $fields_trigger = array('trigger-type', 'trigger-title', 'trigger-image', 'trigger-rollover', 'trigger-rollover-active', 'trigger-video', 'trigger-flash', 'trigger-html', 'trigger-links', 'trigger-content'); $fields_action = array('action-type', 'action-web', 'action-javascript', 'action-file', 'action-image'); foreach ($_REQUEST as $key => $value) { if (empty($value)) { continue; } foreach ($fields_title as $field) { if (substr($key, 0, strlen($field . '-')) == $field . '-') { $this->dictionary[substr($key, strlen($field . '-'))]['title'] = $value; } } foreach ($fields_trigger as $field) { // f.e., Does this REQUEST field begins with "trigger-content-"? if (substr($key, 0, strlen($field . '-')) == $field . '-') { switch ($field) { case 'trigger-html': $this->trigger[$field][substr($key, strlen($field . '-'))] = htmlspecialchars($value); break; case 'trigger-content': $this->trigger[$field][substr($key, strlen($field . '-'))] = $value; break; case 'trigger-links': $key_parts = explode("-", $key); $key_lang = array_pop($key_parts); $key_name = array_pop($key_parts); if (!is_array($value)) { $value = array($value); } $value = array_filter($value); if (empty($key_name)) { continue; } if ($key_name == "link") { // trim & clean the links foreach ($value as $vkey => $vval) { $vval = trim($vval); $vval = preg_replace("//", "", $vval); // remove "zero width space" ​ $value[$vkey] = $vval; } } $this->trigger[$field][$key_lang][$key_name] = $value; break; default: $this->trigger[$field][substr($key, strlen($field . '-'))] = pquotes($value); break; } } } foreach ($fields_action as $field) { if (substr($key, 0, strlen($field . '-')) == $field . '-') { $this->action[$field][substr($key, strlen($field . '-'))] = $value; } } } // end default case } }
public function load_from_post() { global $DB; if (intval($_REQUEST['parent']) != $this->id) { // protection against selecting this same category as parent of itself $this->parent = intval($_REQUEST['parent']); } $this->template = $_REQUEST['template']; $this->access = intval($_REQUEST['access']); $this->groups = $_REQUEST['groups']; if ($this->access < 3) { $this->groups = array(); } $this->permission = intval($_REQUEST['permission']); $this->visible = intval($_REQUEST['visible']); $this->date_published = empty($_REQUEST['date_published']) ? '' : core_date2ts($_REQUEST['date_published']); $this->date_unpublish = empty($_REQUEST['date_unpublish']) ? '' : core_date2ts($_REQUEST['date_unpublish']); // language strings and options $this->dictionary = array(); $this->paths = array(); $fields = array('title', 'action-type', 'action-jump-item', 'action-jump-branch', 'action-new-window'); //, 'path', 'visible'); foreach ($_REQUEST as $key => $value) { if (empty($value)) { continue; } foreach ($fields as $field) { if (substr($key, 0, strlen($field . '-')) == $field . '-') { $this->dictionary[substr($key, strlen($field . '-'))][$field] = $value; } } if (substr($key, 0, strlen('path-')) == 'path-') { $this->paths[substr($key, strlen('path-'))] = $value; } } }