use AppConfig instead of database table to configure mimetypes for questtype ?Submit?
This commit is contained in:
parent
37d33bc636
commit
05a1daf177
3 changed files with 21 additions and 32 deletions
|
|
@ -153,6 +153,10 @@
|
||||||
array(
|
array(
|
||||||
'mimetype' => 'image/png',
|
'mimetype' => 'image/png',
|
||||||
'size' => 1048576
|
'size' => 1048576
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'mimetype' => 'application/pdf',
|
||||||
|
'size' => 1048576
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'map' => array(
|
'map' => array(
|
||||||
|
|
|
||||||
|
|
@ -1865,29 +1865,6 @@ CREATE TABLE `questtypes_submit_characters_comments` (
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
|
||||||
-- Table structure for table `questtypes_submit_mimetypes`
|
|
||||||
--
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `questtypes_submit_mimetypes`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
|
||||||
CREATE TABLE `questtypes_submit_mimetypes` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
`created_user_id` int(11) NOT NULL,
|
|
||||||
`seminary_id` int(11) NOT NULL,
|
|
||||||
`mimetype` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
||||||
`size` int(10) unsigned NOT NULL DEFAULT '0',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `mimetype` (`mimetype`,`seminary_id`),
|
|
||||||
KEY `created_user_id` (`created_user_id`),
|
|
||||||
KEY `seminary_id` (`seminary_id`),
|
|
||||||
CONSTRAINT `questtypes_submit_mimetypes_ibfk_1` FOREIGN KEY (`created_user_id`) REFERENCES `users` (`id`),
|
|
||||||
CONSTRAINT `questtypes_submit_mimetypes_ibfk_2` FOREIGN KEY (`seminary_id`) REFERENCES `seminaries` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `questtypes_submit_similarities`
|
-- Table structure for table `questtypes_submit_similarities`
|
||||||
--
|
--
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
const SIMILARITY_MIN = 0.8;
|
const SIMILARITY_MIN = 0.8;
|
||||||
|
/**
|
||||||
|
* Supported mimetypes
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
const mimetypes = array('application/pdf');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
|
|
@ -144,18 +150,20 @@
|
||||||
/**
|
/**
|
||||||
* Get allowed mimetypes for uploading a file.
|
* Get allowed mimetypes for uploading a file.
|
||||||
*
|
*
|
||||||
* @param int $seminaryId ID of Seminary
|
* @param int $seminaryId ID of Seminary
|
||||||
* @return array Allowed mimetypes
|
* @return array Allowed mimetypes
|
||||||
*/
|
*/
|
||||||
public function getAllowedMimetypes($seminaryId)
|
public function getAllowedMimetypes($seminaryId)
|
||||||
{
|
{
|
||||||
return $this->db->query(
|
$mimetypes = array();
|
||||||
'SELECT id, mimetype, size '.
|
foreach(\nre\configs\AppConfig::$mimetypes['questtypes'] as $mimetype) {
|
||||||
'FROM questtypes_submit_mimetypes '.
|
if(in_array($mimetype['mimetype'], self::mimetypes)) {
|
||||||
'WHERE seminary_id = ?',
|
$mimetypes[] = $mimetype;
|
||||||
'i',
|
}
|
||||||
$seminaryId
|
}
|
||||||
);
|
|
||||||
|
|
||||||
|
return $mimetypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue