XOOPS  2.6.0
xoops_smilies.php
Go to the documentation of this file.
1 <?php
15 
17 if (!$helper) {
18  ob_end_flush();
19  return;
20 }
21 
22 require_once dirname(__FILE__).'/../../../../../../mainfile.php';
23 
25 $xoops->disableErrorReporting();
26 $xoops->simpleHeader(false);
27 
28 $helper->loadLanguage('admin');
29 $helper->loadLanguage('tinymce');
30 
31 $op = Request::getCmd('op', '');
32 if ($op == 'save') {
33  if (!$xoops->security()->check()) {
34  $xoops->redirect('xoops_xlanguage.php', 2, implode(',', $xoops->security()->getErrors()));
35  }
36 
37  XoopsLoad::load('system', 'system');
39 
40  $obj = $helper->getHandlerSmilies()->create();
41 
42  $obj->setVar('smiley_code', Request::getString('smiley_code', ''));
43  $obj->setVar('smiley_emotion', Request::getString('smiley_emotion', ''));
44  $obj->setVar('smiley_display', Request::getBool('smiley_display', 1));
45  $obj->setVar('smiley_url', 'smilies/' . Request::getPath('smiley_url', ''));
46  $xoops_upload_file = Request::getArray('xoops_upload_file', array());
47 
48  $mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
49  $upload_size = 500000;
50  $uploader = new XoopsMediaUploader(\XoopsBaseConfig::get('uploads-path') . '/smilies', $mimetypes, $upload_size, null, null);
51  if ($uploader->fetchMedia($xoops_upload_file[0])) {
52  $uploader->setPrefix('smil');
53  if (!$uploader->upload()) {
54  $msg[] = $uploader->getErrors();
55  $obj->setVar('smiley_url', 'blank.gif');
56  } else {
57  $obj->setVar('smiley_url', 'smilies/' . $uploader->getSavedFileName());
58  }
59  }
60 
61  if ($helper->getHandlerSmilies()->insert($obj)) {
62  $xoops->redirect('xoops_smilies.php', 2, implode('<br />', $msg));
63  }
64 }
65 
67 if ($op == 'more') {
68  $xoopsTpl->assign('smileys', Xoops\Module\Helper::getHelper('smilies')->getHandlerSmilies()->getSmilies(0, 0, false));
69 } else {
70  $xoopsTpl->assign('smileys', Xoops\Module\Helper::getHelper('smilies')->getHandlerSmilies()->getActiveSmilies(false));
71 }
72 
73 // check user/group
74 $groups = $xoops->getUserGroups();
75 $gperm_handler = $xoops->getHandlerGroupperm();
76 $admin = $gperm_handler->checkRight('system_admin', $xoops->getHandlerModule()->getByDirName('smilies')->getVar('mid'), $groups);
77 
78 if ($admin) {
79  $xoopsTpl->assign('form_add', $helper->getForm($helper->getHandlerSmilies()->create(), 'smilies')->render());
80 }
81 $xoopsTpl->display('module:smilies/smilies_tinymce.tpl');
82 $xoops->simpleFooter();
$xoops
static getInstance()
Definition: Xoops.php:160
$helper
$gperm_handler
static get($name)
$admin
if($op== 'save') $xoopsTpl
static getHelper($dirname= 'system')
Definition: Helper.php:27
static load($name, $type="core")
Definition: xoopsload.php:65
$upload_size
if(!is_object($module)||!$module->getVar('isactive')) $msg
Definition: groupperm.php:38
$groups
const _AM_SMILIES_SAVE
Definition: admin.php:38
$mimetypes