aboutsummaryrefslogtreecommitdiff
path: root/ratatoeskr/sys/models.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2012-06-08 22:28:49 +0200
committerKevin Chabowski <kevin@kch42.de>2012-06-08 22:28:49 +0200
commitfb1b7e104b6dc672572a4467ff4337c50139a36e (patch)
tree167a2731668ff7bd9fcebc83c1df5517ecb8dcdd /ratatoeskr/sys/models.php
parent709fd51d0681fe28753205d24d2fea3ccee76672 (diff)
downloadratatoeskr-cms-fb1b7e104b6dc672572a4467ff4337c50139a36e.tar.gz
ratatoeskr-cms-fb1b7e104b6dc672572a4467ff4337c50139a36e.tar.bz2
ratatoeskr-cms-fb1b7e104b6dc672572a4467ff4337c50139a36e.zip
Tag::test_name implemented.
Diffstat (limited to 'ratatoeskr/sys/models.php')
-rw-r--r--ratatoeskr/sys/models.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php
index 95a500f..a20f726 100644
--- a/ratatoeskr/sys/models.php
+++ b/ratatoeskr/sys/models.php
@@ -1678,6 +1678,21 @@ class Tag extends BySQLRowEnabled
public $title;
/*
+ * Function: test_name
+ * Test, if a name is a valid tag name.
+ *
+ * Parameters:
+ * $name - Name to test.
+ *
+ * Returns:
+ * True, if the name is valid, False otherwise.
+ */
+ public static function test_name($name)
+ {
+ return (strpos($name, ",") === False) and (strpos($name, " ") === False);
+ }
+
+ /*
* Function: get_id
*/
public function get_id() { return $this->id; }
@@ -1701,6 +1716,9 @@ class Tag extends BySQLRowEnabled
*/
public static function create($name)
{
+ if(!self::test_name($name))
+ throw new InvalidDataError("invalid_tag_name");
+
try
{
$obj = self::by_name($name);
@@ -1818,6 +1836,9 @@ WHERE `b`.`tag` = '%d'" , $this->id);
*/
public function save()
{
+ if(!self::test_name($name))
+ throw new InvalidDataError("invalid_tag_name");
+
$result = qdb("SELECT COUNT(*) AS `n` FROM `PREFIX_tags` WHERE `name` = '%s' AND `id` != %d", $this->name, $this->id);
$sqlrow = mysql_fetch_assoc($result);
if($sqlrow["n"] > 0)