Permalink
Browse files

Site: Changed site to use new 'shortname' for uploaded files, etc. in…

…stead of 'id'. BC-BREAKING change. Here's to living on the edge :)
  • Loading branch information...
1 parent 6c143e5 commit 01d0b401309165ceb5f45beaf453fb1d7f657006 @vlucas vlucas committed Jul 12, 2011
Showing with 14 additions and 3 deletions.
  1. +13 −1 app/Module/Site/Entity.php
  2. +1 −1 app/Plugin/Stackbox/Plugin.php
  3. +0 −1 app/www/site/1/files/index.html
View
@@ -1,6 +1,6 @@
<?php
namespace Module\Site;
-use Stackbox;
+use Stackbox, Spot;
/**
* Site entity - what properties define a site
@@ -20,6 +20,7 @@ public static function fields() {
return array(
'id' => array('type' => 'int', 'primary' => true, 'serial' => true),
'reseller_id' => array('type' => 'int', 'index' => true, 'default' => 0),
+ 'shortname' => array('type' => 'string', 'required' => true, 'unique' => true),
'title' => array('type' => 'string', 'required' => true),
'theme' => array('type' => 'string'),
'status' => array('type' => 'int', 'length' => 1, 'default' => self::STATUS_ACTIVE),
@@ -45,6 +46,17 @@ public static function relations() {
/**
+ * Formats shortname on save
+ * All lowercase, alphanumeric characters only
+ */
+ public function beforeSave(Spot\Mapper $mapper)
+ {
+ $this->__set('shortname', strtolower(preg_replace("/[^a-zA-Z0-9]/g", "", $this->__get('shortname'))));
+ return parent::beforeSave($mapper);
+ }
+
+
+ /**
* Get array of themes available to site for use
*/
public function themes()
@@ -51,7 +51,7 @@ public function __construct(Alloy\Kernel $kernel)
});
// Set site files directory based on id
- $siteFilesDir = 'site/' . $site->id . '/';
+ $siteFilesDir = 'site/' . $site->shortname . '/';
// Add config settings
$kernel->config(array(
@@ -1 +0,0 @@
-<p>Contents not viewable.</p>

0 comments on commit 01d0b40

Please sign in to comment.