add icons for Character groups

This commit is contained in:
coderkun 2014-04-29 14:18:04 +02:00
commit f2de7c3de7
7 changed files with 88 additions and 20 deletions

View file

@ -24,14 +24,15 @@
*
* @var array
*/
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries');
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries', 'charactergroups');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'index' => array('admin', 'moderator', 'user', 'guest')
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user', 'guest')
);
/**
* User seminary permissions
@ -39,7 +40,8 @@
* @var array
*/
public $seminaryPermissions = array(
'seminary' => array('admin', 'moderator', 'user', 'guest')
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user')
);
@ -102,6 +104,67 @@
}
}
// Get file
$file = $this->getUploadFile($upload);
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
}
/**
* Action: charactergroup.
*
* Display the icon of a Character group.
*
* @throws IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $groupsgroupUrl URL-Title of a Character groups-group
* @param string $groupUrl URL-Title of a Character group
*/
public function charactergroup($seminaryUrl, $groupsgroupUrl, $groupUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Character groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character group
$group = $this->Charactergroups->getGroupByUrl($groupsgroup['id'], $groupUrl);
// Get Upload
$upload = $this->Uploads->getSeminaryuploadById($group['seminaryupload_id']);
// Get file
$file = $this->getUploadFile($upload);
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
}
/**
* Determine the file for an upload.
*
* @throws IdNotFoundException
* @param array $upload Upload to get file for
* @return object File for the upload (or null if upload is cached)
*/
private function getUploadFile($upload)
{
// Set content-type
$this->response->addHeader("Content-type: ".$upload['mimetype']."");
@ -113,23 +176,14 @@
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return;
return null;
}
// Load file
$file = file_get_contents($upload['filename']);
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
return file_get_contents($upload['filename']);
}
/**
* Determine file information and set the HTTP-header for
* caching accordingly.