public static function validate_tags(Module_Links $module, $arg) { $errors = array(); $new = 0; $arg = explode(',', trim($arg)); $taken = array(); $minlen = 3; $maxlen = $module->cfgMaxTagLen(); foreach ($arg as $tag) { $tag = trim($tag); if (strlen($tag) === 0) { continue; } if (false === GWF_LinksTag::getByName($tag)) { if (self::isValidTagName($tag, $minlen, $maxlen)) { $taken[] = $tag; $new++; } else { $errors[] = $module->lang('err_tag', array(GWF_HTML::display($tag), $minlen, $maxlen)); } } else { $taken[] = $tag; } } if (count($taken) === 0) { $errors[] = $module->lang('err_no_tag'); } $_POST['link_tags'] = implode(',', $taken); if (count($errors) === 0) { return false; } return implode('<br/>', $errors); }
/** * Check if we have permission to view that link. In case we do, return empty string. else return verbose permission text. * @param Module_Links $module * @param GWF_User $user * @return string */ public function getPermissionText(Module_Links $module, $user) { static $text = NULL; if ($text === NULL) { $text = array($module->lang('permtext_in_mod'), $module->lang('permtext_score', array('%1%')), $module->lang('permtext_member'), $module->lang('permtext_group', array('%1%'))); } if ($this->isInModeration()) { return $text[0]; } $score = $user === false ? 0 : $user->getLevel(); # Check score $need_score = $this->getVar('link_score'); if ($score < $need_score) { return str_replace('%1%', $need_score, $text[1]); } # Check memberlink if ($user === false && $this->isMemberLink()) { return $text[2]; } # Check group $need_gid = $this->getGroupID(); if ($need_gid > 0) { if ($user === false || !$user->isInGroupID($need_gid)) { return str_replace('%1%', GWF_Group::getByID($need_gid)->displayName(), $text[3]); } } return ''; }