function link_errors($link) { $error = false; // Errors if (!check_link_key() || intval($_POST['randkey']) != $link->randkey) { add_submit_error(_("clave incorrecta")); $error = true; } if ($link->status != 'discard') { add_submit_error(_("la historia ya está en cola") . ": {$link->status}"); $error = true; } if (strlen($link->title) < 8 || strlen($link->content) < 30) { add_submit_error(_("título o texto incompletos")); $error = true; } if (get_uppercase_ratio($link->title) > 0.4 || get_uppercase_ratio($link->content) > 0.25) { add_submit_error(_("demasiadas mayúsculas en el título o texto")); $error = true; } if (mb_strlen(html_entity_decode($link->title, ENT_COMPAT, 'UTF-8'), 'UTF-8') > 120 || mb_strlen(html_entity_decode($link->content, ENT_COMPAT, 'UTF-8'), 'UTF-8') > 550) { add_submit_error(_("título o texto demasiado largos")); $error = true; } if (strlen($link->tags) < 3) { add_submit_error(_("no has puesto etiquetas")); $error = true; } if (preg_match('/.*http:\\//', $link->title)) { add_submit_error(_("por favor, no pongas URLs en el título, no ofrece información")); $error = true; } if (!$link->category > 0) { add_submit_error(_("categoría no seleccionada")); $error = true; } return $error; }
function link_errors($link) { global $globals, $current_user, $site_key; $error = false; // Errors if (!check_link_key() || intval($_POST['randkey']) != $link->randkey) { add_submit_error(_("clave incorrecta")); $error = true; } if ($link->sub_id > 0 && !SitesMgr::can_send($link->sub_id)) { add_submit_error(_("envío deshabilitados en") . " {$link->sub_name}"); $error = true; } if ($link->status != 'discard') { add_submit_error(_("la historia ya está en cola") . ": {$link->status}"); $error = true; } // TODO: simplify this, return just $errors as array() // as in editlink $res = $link->check_field_errors(); if (!empty($res)) { $error = true; foreach ($res as $e) { add_submit_error($e); } } return $error; }