@@ -31,109 +31,109 @@ |
||
31 | 31 | // Request dir_id |
32 | 32 | $dirId = Request::getInt('dir_id'); |
33 | 33 | switch ($op) { |
34 | - case 'list': |
|
35 | - default: |
|
36 | - // Define Stylesheet |
|
37 | - $GLOBALS['xoTheme']->addStylesheet($style, null); |
|
38 | - $start = Request::getInt('start', 0); |
|
39 | - $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
|
40 | - $templateMain = 'wggithub_admin_directories.tpl'; |
|
41 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
42 | - $adminObject->addItemButton(_AM_WGGITHUB_ADD_DIRECTORY, 'directories.php?op=new', 'add'); |
|
43 | - $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
44 | - $directoriesCount = $directoriesHandler->getCountDirectories(); |
|
45 | - $directoriesAll = $directoriesHandler->getAllDirectories($start, $limit); |
|
46 | - $GLOBALS['xoopsTpl']->assign('directories_count', $directoriesCount); |
|
47 | - $GLOBALS['xoopsTpl']->assign('wggithub_url', WGGITHUB_URL); |
|
48 | - $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL); |
|
49 | - // Table view directories |
|
50 | - if ($directoriesCount > 0) { |
|
51 | - foreach (\array_keys($directoriesAll) as $i) { |
|
52 | - $directory = $directoriesAll[$i]->getValuesDirectories(); |
|
53 | - $GLOBALS['xoopsTpl']->append('directories_list', $directory); |
|
54 | - unset($directory); |
|
55 | - } |
|
56 | - // Display Navigation |
|
57 | - if ($directoriesCount > $limit) { |
|
58 | - include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
59 | - $pagenav = new \XoopsPageNav($directoriesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
|
60 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
|
61 | - } |
|
62 | - } else { |
|
63 | - $GLOBALS['xoopsTpl']->assign('error', _AM_WGGITHUB_THEREARENT_DIRECTORIES); |
|
64 | - } |
|
65 | - break; |
|
66 | - case 'new': |
|
67 | - $templateMain = 'wggithub_admin_directories.tpl'; |
|
68 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
69 | - $adminObject->addItemButton(_AM_WGGITHUB_DIRECTORIES_LIST, 'directories.php', 'list'); |
|
70 | - $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
71 | - // Form Create |
|
72 | - $directoriesObj = $directoriesHandler->create(); |
|
73 | - $form = $directoriesObj->getFormDirectories(); |
|
74 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
75 | - break; |
|
76 | - case 'save': |
|
77 | - // Security Check |
|
78 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
79 | - \redirect_header('directories.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
80 | - } |
|
81 | - if ($dirId > 0) { |
|
82 | - $directoriesObj = $directoriesHandler->get($dirId); |
|
83 | - } else { |
|
84 | - $directoriesObj = $directoriesHandler->create(); |
|
85 | - } |
|
86 | - // Set Vars |
|
87 | - $directoriesObj->setVar('dir_name', Request::getString('dir_name', '')); |
|
88 | - $directoriesObj->setVar('dir_type', Request::getInt('dir_type', 0)); |
|
89 | - $directoriesObj->setVar('dir_autoupdate', Request::getInt('dir_autoupdate', 0)); |
|
90 | - $directoriesObj->setVar('dir_online', Request::getInt('dir_online', 0)); |
|
34 | + case 'list': |
|
35 | + default: |
|
36 | + // Define Stylesheet |
|
37 | + $GLOBALS['xoTheme']->addStylesheet($style, null); |
|
38 | + $start = Request::getInt('start', 0); |
|
39 | + $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
|
40 | + $templateMain = 'wggithub_admin_directories.tpl'; |
|
41 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
42 | + $adminObject->addItemButton(_AM_WGGITHUB_ADD_DIRECTORY, 'directories.php?op=new', 'add'); |
|
43 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
44 | + $directoriesCount = $directoriesHandler->getCountDirectories(); |
|
45 | + $directoriesAll = $directoriesHandler->getAllDirectories($start, $limit); |
|
46 | + $GLOBALS['xoopsTpl']->assign('directories_count', $directoriesCount); |
|
47 | + $GLOBALS['xoopsTpl']->assign('wggithub_url', WGGITHUB_URL); |
|
48 | + $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL); |
|
49 | + // Table view directories |
|
50 | + if ($directoriesCount > 0) { |
|
51 | + foreach (\array_keys($directoriesAll) as $i) { |
|
52 | + $directory = $directoriesAll[$i]->getValuesDirectories(); |
|
53 | + $GLOBALS['xoopsTpl']->append('directories_list', $directory); |
|
54 | + unset($directory); |
|
55 | + } |
|
56 | + // Display Navigation |
|
57 | + if ($directoriesCount > $limit) { |
|
58 | + include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
59 | + $pagenav = new \XoopsPageNav($directoriesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
|
60 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
|
61 | + } |
|
62 | + } else { |
|
63 | + $GLOBALS['xoopsTpl']->assign('error', _AM_WGGITHUB_THEREARENT_DIRECTORIES); |
|
64 | + } |
|
65 | + break; |
|
66 | + case 'new': |
|
67 | + $templateMain = 'wggithub_admin_directories.tpl'; |
|
68 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
69 | + $adminObject->addItemButton(_AM_WGGITHUB_DIRECTORIES_LIST, 'directories.php', 'list'); |
|
70 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
71 | + // Form Create |
|
72 | + $directoriesObj = $directoriesHandler->create(); |
|
73 | + $form = $directoriesObj->getFormDirectories(); |
|
74 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
75 | + break; |
|
76 | + case 'save': |
|
77 | + // Security Check |
|
78 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
79 | + \redirect_header('directories.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
80 | + } |
|
81 | + if ($dirId > 0) { |
|
82 | + $directoriesObj = $directoriesHandler->get($dirId); |
|
83 | + } else { |
|
84 | + $directoriesObj = $directoriesHandler->create(); |
|
85 | + } |
|
86 | + // Set Vars |
|
87 | + $directoriesObj->setVar('dir_name', Request::getString('dir_name', '')); |
|
88 | + $directoriesObj->setVar('dir_type', Request::getInt('dir_type', 0)); |
|
89 | + $directoriesObj->setVar('dir_autoupdate', Request::getInt('dir_autoupdate', 0)); |
|
90 | + $directoriesObj->setVar('dir_online', Request::getInt('dir_online', 0)); |
|
91 | 91 | $directoriesObj->setVar('dir_filterrelease', Request::getInt('dir_filterrelease', 0)); |
92 | - $directoryDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('dir_datecreated')); |
|
93 | - $directoriesObj->setVar('dir_datecreated', $directoryDatecreatedObj->getTimestamp()); |
|
94 | - $directoriesObj->setVar('dir_submitter', Request::getInt('dir_submitter', 0)); |
|
95 | - // Insert Data |
|
96 | - if ($directoriesHandler->insert($directoriesObj)) { |
|
97 | - \redirect_header('directories.php?op=list', 2, _AM_WGGITHUB_FORM_OK); |
|
98 | - } |
|
99 | - // Get Form |
|
100 | - $GLOBALS['xoopsTpl']->assign('error', $directoriesObj->getHtmlErrors()); |
|
101 | - $form = $directoriesObj->getFormDirectories(); |
|
102 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
103 | - break; |
|
104 | - case 'edit': |
|
105 | - $templateMain = 'wggithub_admin_directories.tpl'; |
|
106 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
107 | - $adminObject->addItemButton(_AM_WGGITHUB_ADD_DIRECTORY, 'directories.php?op=new', 'add'); |
|
108 | - $adminObject->addItemButton(_AM_WGGITHUB_DIRECTORIES_LIST, 'directories.php', 'list'); |
|
109 | - $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
110 | - // Get Form |
|
111 | - $directoriesObj = $directoriesHandler->get($dirId); |
|
112 | - $form = $directoriesObj->getFormDirectories(); |
|
113 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
114 | - break; |
|
115 | - case 'delete': |
|
116 | - $templateMain = 'wggithub_admin_directories.tpl'; |
|
117 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
118 | - $directoriesObj = $directoriesHandler->get($dirId); |
|
119 | - $dirName = $directoriesObj->getVar('dir_name'); |
|
120 | - if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
|
121 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
122 | - \redirect_header('directories.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
|
123 | - } |
|
124 | - if ($directoriesHandler->delete($directoriesObj)) { |
|
125 | - \redirect_header('directories.php', 3, _AM_WGGITHUB_FORM_DELETE_OK); |
|
126 | - } else { |
|
127 | - $GLOBALS['xoopsTpl']->assign('error', $directoriesObj->getHtmlErrors()); |
|
128 | - } |
|
129 | - } else { |
|
130 | - $xoopsconfirm = new Common\XoopsConfirm( |
|
131 | - ['ok' => 1, 'dir_id' => $dirId, 'op' => 'delete'], |
|
132 | - $_SERVER['REQUEST_URI'], |
|
133 | - \sprintf(_AM_WGGITHUB_FORM_SURE_DELETE, $directoriesObj->getVar('dir_name'))); |
|
134 | - $form = $xoopsconfirm->getFormXoopsConfirm(); |
|
135 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
136 | - } |
|
137 | - break; |
|
92 | + $directoryDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('dir_datecreated')); |
|
93 | + $directoriesObj->setVar('dir_datecreated', $directoryDatecreatedObj->getTimestamp()); |
|
94 | + $directoriesObj->setVar('dir_submitter', Request::getInt('dir_submitter', 0)); |
|
95 | + // Insert Data |
|
96 | + if ($directoriesHandler->insert($directoriesObj)) { |
|
97 | + \redirect_header('directories.php?op=list', 2, _AM_WGGITHUB_FORM_OK); |
|
98 | + } |
|
99 | + // Get Form |
|
100 | + $GLOBALS['xoopsTpl']->assign('error', $directoriesObj->getHtmlErrors()); |
|
101 | + $form = $directoriesObj->getFormDirectories(); |
|
102 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
103 | + break; |
|
104 | + case 'edit': |
|
105 | + $templateMain = 'wggithub_admin_directories.tpl'; |
|
106 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
107 | + $adminObject->addItemButton(_AM_WGGITHUB_ADD_DIRECTORY, 'directories.php?op=new', 'add'); |
|
108 | + $adminObject->addItemButton(_AM_WGGITHUB_DIRECTORIES_LIST, 'directories.php', 'list'); |
|
109 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
110 | + // Get Form |
|
111 | + $directoriesObj = $directoriesHandler->get($dirId); |
|
112 | + $form = $directoriesObj->getFormDirectories(); |
|
113 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
114 | + break; |
|
115 | + case 'delete': |
|
116 | + $templateMain = 'wggithub_admin_directories.tpl'; |
|
117 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('directories.php')); |
|
118 | + $directoriesObj = $directoriesHandler->get($dirId); |
|
119 | + $dirName = $directoriesObj->getVar('dir_name'); |
|
120 | + if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
|
121 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
122 | + \redirect_header('directories.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
|
123 | + } |
|
124 | + if ($directoriesHandler->delete($directoriesObj)) { |
|
125 | + \redirect_header('directories.php', 3, _AM_WGGITHUB_FORM_DELETE_OK); |
|
126 | + } else { |
|
127 | + $GLOBALS['xoopsTpl']->assign('error', $directoriesObj->getHtmlErrors()); |
|
128 | + } |
|
129 | + } else { |
|
130 | + $xoopsconfirm = new Common\XoopsConfirm( |
|
131 | + ['ok' => 1, 'dir_id' => $dirId, 'op' => 'delete'], |
|
132 | + $_SERVER['REQUEST_URI'], |
|
133 | + \sprintf(_AM_WGGITHUB_FORM_SURE_DELETE, $directoriesObj->getVar('dir_name'))); |
|
134 | + $form = $xoopsconfirm->getFormXoopsConfirm(); |
|
135 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
136 | + } |
|
137 | + break; |
|
138 | 138 | } |
139 | 139 | require __DIR__ . '/footer.php'; |
@@ -33,74 +33,74 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class Directories extends \XoopsObject |
35 | 35 | { |
36 | - /** |
|
37 | - * Constructor |
|
38 | - * |
|
39 | - * @param null |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - $this->initVar('dir_id', \XOBJ_DTYPE_INT); |
|
44 | - $this->initVar('dir_name', \XOBJ_DTYPE_TXTBOX); |
|
45 | - $this->initVar('dir_type', \XOBJ_DTYPE_INT); |
|
36 | + /** |
|
37 | + * Constructor |
|
38 | + * |
|
39 | + * @param null |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + $this->initVar('dir_id', \XOBJ_DTYPE_INT); |
|
44 | + $this->initVar('dir_name', \XOBJ_DTYPE_TXTBOX); |
|
45 | + $this->initVar('dir_type', \XOBJ_DTYPE_INT); |
|
46 | 46 | $this->initVar('dir_autoupdate', XOBJ_DTYPE_INT); |
47 | 47 | $this->initVar('dir_online', XOBJ_DTYPE_INT); |
48 | 48 | $this->initVar('dir_filterrelease', XOBJ_DTYPE_INT); |
49 | - $this->initVar('dir_datecreated', \XOBJ_DTYPE_INT); |
|
50 | - $this->initVar('dir_submitter', \XOBJ_DTYPE_INT); |
|
51 | - } |
|
49 | + $this->initVar('dir_datecreated', \XOBJ_DTYPE_INT); |
|
50 | + $this->initVar('dir_submitter', \XOBJ_DTYPE_INT); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @static function &getInstance |
|
55 | - * |
|
56 | - * @param null |
|
57 | - */ |
|
58 | - public static function getInstance() |
|
59 | - { |
|
60 | - static $instance = false; |
|
61 | - if (!$instance) { |
|
62 | - $instance = new self(); |
|
63 | - } |
|
64 | - } |
|
53 | + /** |
|
54 | + * @static function &getInstance |
|
55 | + * |
|
56 | + * @param null |
|
57 | + */ |
|
58 | + public static function getInstance() |
|
59 | + { |
|
60 | + static $instance = false; |
|
61 | + if (!$instance) { |
|
62 | + $instance = new self(); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * The new inserted $Id |
|
68 | - * @return inserted id |
|
69 | - */ |
|
70 | - public function getNewInsertedIdDirectories() |
|
71 | - { |
|
72 | - $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
73 | - return $newInsertedId; |
|
74 | - } |
|
66 | + /** |
|
67 | + * The new inserted $Id |
|
68 | + * @return inserted id |
|
69 | + */ |
|
70 | + public function getNewInsertedIdDirectories() |
|
71 | + { |
|
72 | + $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
73 | + return $newInsertedId; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @public function getForm |
|
78 | - * @param bool $action |
|
79 | - * @return \XoopsThemeForm |
|
80 | - */ |
|
81 | - public function getFormDirectories($action = false) |
|
82 | - { |
|
83 | - $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
84 | - if (!$action) { |
|
85 | - $action = $_SERVER['REQUEST_URI']; |
|
86 | - } |
|
87 | - $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
|
76 | + /** |
|
77 | + * @public function getForm |
|
78 | + * @param bool $action |
|
79 | + * @return \XoopsThemeForm |
|
80 | + */ |
|
81 | + public function getFormDirectories($action = false) |
|
82 | + { |
|
83 | + $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
84 | + if (!$action) { |
|
85 | + $action = $_SERVER['REQUEST_URI']; |
|
86 | + } |
|
87 | + $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
|
88 | 88 | |
89 | - // Title |
|
90 | - $title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_DIRECTORY_ADD) : \sprintf(\_AM_WGGITHUB_DIRECTORY_EDIT); |
|
91 | - // Get Theme Form |
|
92 | - \xoops_load('XoopsFormLoader'); |
|
93 | - $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
94 | - $form->setExtra('enctype="multipart/form-data"'); |
|
95 | - // Form Text dirName |
|
96 | - $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_DIRECTORY_NAME, 'dir_name', 50, 255, $this->getVar('dir_name')), true); |
|
97 | - // Directories Handler |
|
98 | - $directoriesHandler = $helper->getHandler('Directories'); |
|
99 | - // Form Select dirType |
|
100 | - $dirTypeSelect = new \XoopsFormSelect(\_AM_WGGITHUB_DIRECTORY_TYPE, 'dir_type', $this->getVar('dir_type'), 5); |
|
101 | - $dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_USER, \_AM_WGGITHUB_DIRECTORY_TYPE_USER); |
|
102 | - $dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_ORG, \_AM_WGGITHUB_DIRECTORY_TYPE_ORG); |
|
103 | - $form->addElement($dirTypeSelect, true); |
|
89 | + // Title |
|
90 | + $title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_DIRECTORY_ADD) : \sprintf(\_AM_WGGITHUB_DIRECTORY_EDIT); |
|
91 | + // Get Theme Form |
|
92 | + \xoops_load('XoopsFormLoader'); |
|
93 | + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
94 | + $form->setExtra('enctype="multipart/form-data"'); |
|
95 | + // Form Text dirName |
|
96 | + $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_DIRECTORY_NAME, 'dir_name', 50, 255, $this->getVar('dir_name')), true); |
|
97 | + // Directories Handler |
|
98 | + $directoriesHandler = $helper->getHandler('Directories'); |
|
99 | + // Form Select dirType |
|
100 | + $dirTypeSelect = new \XoopsFormSelect(\_AM_WGGITHUB_DIRECTORY_TYPE, 'dir_type', $this->getVar('dir_type'), 5); |
|
101 | + $dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_USER, \_AM_WGGITHUB_DIRECTORY_TYPE_USER); |
|
102 | + $dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_ORG, \_AM_WGGITHUB_DIRECTORY_TYPE_ORG); |
|
103 | + $form->addElement($dirTypeSelect, true); |
|
104 | 104 | // Form Radio Yes/No dirAutoupdate |
105 | 105 | $dirAutoupdate = $this->isNew() ?: $this->getVar('dir_autoupdate'); |
106 | 106 | $form->addElement(new \XoopsFormRadioYN(_AM_WGGITHUB_DIRECTORY_AUTOUPDATE, 'dir_autoupdate', $dirAutoupdate)); |
@@ -110,51 +110,51 @@ discard block |
||
110 | 110 | // Form Radio Yes/No dirFilterrelease |
111 | 111 | $dirFilterrelease = $this->isNew() ?: $this->getVar('dir_filterrelease'); |
112 | 112 | $form->addElement(new \XoopsFormRadioYN(_AM_WGGITHUB_DIRECTORY_FILTERRELEASE, 'dir_filterrelease', $dirFilterrelease)); |
113 | - // Form Text Date Select dirDatecreated |
|
114 | - $dirDatecreated = $this->isNew() ?: $this->getVar('dir_datecreated'); |
|
115 | - $form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_DIRECTORY_DATECREATED, 'dir_datecreated', '', $dirDatecreated)); |
|
116 | - // Form Select User dirSubmitter |
|
117 | - $form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_DIRECTORY_SUBMITTER, 'dir_submitter', false, $this->getVar('dir_submitter'))); |
|
118 | - // To Save |
|
119 | - $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
120 | - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
121 | - return $form; |
|
122 | - } |
|
113 | + // Form Text Date Select dirDatecreated |
|
114 | + $dirDatecreated = $this->isNew() ?: $this->getVar('dir_datecreated'); |
|
115 | + $form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_DIRECTORY_DATECREATED, 'dir_datecreated', '', $dirDatecreated)); |
|
116 | + // Form Select User dirSubmitter |
|
117 | + $form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_DIRECTORY_SUBMITTER, 'dir_submitter', false, $this->getVar('dir_submitter'))); |
|
118 | + // To Save |
|
119 | + $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
120 | + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
121 | + return $form; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Get Values |
|
126 | - * @param null $keys |
|
127 | - * @param null $format |
|
128 | - * @param null $maxDepth |
|
129 | - * @return array |
|
130 | - */ |
|
131 | - public function getValuesDirectories($keys = null, $format = null, $maxDepth = null) |
|
132 | - { |
|
133 | - $ret = $this->getValues($keys, $format, $maxDepth); |
|
134 | - $ret['id'] = $this->getVar('dir_id'); |
|
135 | - $ret['name'] = $this->getVar('dir_name'); |
|
136 | - $ret['type'] = $this->getVar('dir_type'); |
|
124 | + /** |
|
125 | + * Get Values |
|
126 | + * @param null $keys |
|
127 | + * @param null $format |
|
128 | + * @param null $maxDepth |
|
129 | + * @return array |
|
130 | + */ |
|
131 | + public function getValuesDirectories($keys = null, $format = null, $maxDepth = null) |
|
132 | + { |
|
133 | + $ret = $this->getValues($keys, $format, $maxDepth); |
|
134 | + $ret['id'] = $this->getVar('dir_id'); |
|
135 | + $ret['name'] = $this->getVar('dir_name'); |
|
136 | + $ret['type'] = $this->getVar('dir_type'); |
|
137 | 137 | $ret['type_text'] = Constants::DIRECTORY_TYPE_USER == $this->getVar('dir_type') ? \_AM_WGGITHUB_DIRECTORY_TYPE_USER : \_AM_WGGITHUB_DIRECTORY_TYPE_ORG; |
138 | 138 | $ret['autoupdate'] = (int)$this->getVar('dir_autoupdate') > 0 ? _YES : _NO; |
139 | 139 | $ret['online'] = (int)$this->getVar('dir_online') > 0 ? _YES : _NO; |
140 | 140 | $ret['filterrelease'] = (int)$this->getVar('dir_filterrelease') > 0 ? _YES : _NO; |
141 | - $ret['datecreated'] = \formatTimestamp($this->getVar('dir_datecreated'), 's'); |
|
142 | - $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('dir_submitter')); |
|
143 | - return $ret; |
|
144 | - } |
|
141 | + $ret['datecreated'] = \formatTimestamp($this->getVar('dir_datecreated'), 's'); |
|
142 | + $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('dir_submitter')); |
|
143 | + return $ret; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * Returns an array representation of the object |
|
148 | - * |
|
149 | - * @return array |
|
150 | - */ |
|
151 | - public function toArrayDirectories() |
|
152 | - { |
|
153 | - $ret = []; |
|
154 | - $vars = $this->getVars(); |
|
155 | - foreach (\array_keys($vars) as $var) { |
|
156 | - $ret[$var] = $this->getVar('"{$var}"'); |
|
157 | - } |
|
158 | - return $ret; |
|
159 | - } |
|
146 | + /** |
|
147 | + * Returns an array representation of the object |
|
148 | + * |
|
149 | + * @return array |
|
150 | + */ |
|
151 | + public function toArrayDirectories() |
|
152 | + { |
|
153 | + $ret = []; |
|
154 | + $vars = $this->getVars(); |
|
155 | + foreach (\array_keys($vars) as $var) { |
|
156 | + $ret[$var] = $this->getVar('"{$var}"'); |
|
157 | + } |
|
158 | + return $ret; |
|
159 | + } |
|
160 | 160 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | interface Constants |
30 | 30 | { |
31 | - // Constants for tables |
|
31 | + // Constants for tables |
|
32 | 32 | public const TABLE_SETTINGS = 0; |
33 | 33 | public const TABLE_REPOSITORIES = 1; |
34 | 34 | public const TABLE_DIRECTORIES = 2; |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | public const DIRECTORY_TYPE_USER = 1; |
40 | 40 | public const DIRECTORY_TYPE_ORG = 2; |
41 | 41 | |
42 | - // Constants for status |
|
43 | - public const STATUS_NONE = 0; |
|
42 | + // Constants for status |
|
43 | + public const STATUS_NONE = 0; |
|
44 | 44 | public const STATUS_NEW = 1; |
45 | 45 | public const STATUS_UPDATED = 2; |
46 | - public const STATUS_UPTODATE = 3; |
|
46 | + public const STATUS_UPTODATE = 3; |
|
47 | 47 | |
48 | - // Constants for permissions |
|
49 | - public const PERM_GLOBAL_NONE = 0; |
|
50 | - public const PERM_GLOBAL_VIEW = 1; |
|
51 | - public const PERM_GLOBAL_READ = 2; |
|
52 | - public const PERM_README_UPDATE = 3; |
|
48 | + // Constants for permissions |
|
49 | + public const PERM_GLOBAL_NONE = 0; |
|
50 | + public const PERM_GLOBAL_VIEW = 1; |
|
51 | + public const PERM_GLOBAL_READ = 2; |
|
52 | + public const PERM_README_UPDATE = 3; |
|
53 | 53 | |
54 | 54 | } |
@@ -35,96 +35,96 @@ |
||
35 | 35 | */ |
36 | 36 | class ReadmesHandler extends \XoopsPersistableObjectHandler |
37 | 37 | { |
38 | - /** |
|
39 | - * Constructor |
|
40 | - * |
|
41 | - * @param \XoopsDatabase $db |
|
42 | - */ |
|
43 | - public function __construct(\XoopsDatabase $db) |
|
44 | - { |
|
45 | - parent::__construct($db, 'wggithub_readmes', Readmes::class, 'rm_id', 'rm_name'); |
|
46 | - } |
|
38 | + /** |
|
39 | + * Constructor |
|
40 | + * |
|
41 | + * @param \XoopsDatabase $db |
|
42 | + */ |
|
43 | + public function __construct(\XoopsDatabase $db) |
|
44 | + { |
|
45 | + parent::__construct($db, 'wggithub_readmes', Readmes::class, 'rm_id', 'rm_name'); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param bool $isNew |
|
50 | - * |
|
51 | - * @return object |
|
52 | - */ |
|
53 | - public function create($isNew = true) |
|
54 | - { |
|
55 | - return parent::create($isNew); |
|
56 | - } |
|
48 | + /** |
|
49 | + * @param bool $isNew |
|
50 | + * |
|
51 | + * @return object |
|
52 | + */ |
|
53 | + public function create($isNew = true) |
|
54 | + { |
|
55 | + return parent::create($isNew); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * retrieve a field |
|
60 | - * |
|
61 | - * @param int $i field id |
|
62 | - * @param null fields |
|
63 | - * @return mixed reference to the {@link Get} object |
|
64 | - */ |
|
65 | - public function get($i = null, $fields = null) |
|
66 | - { |
|
67 | - return parent::get($i, $fields); |
|
68 | - } |
|
58 | + /** |
|
59 | + * retrieve a field |
|
60 | + * |
|
61 | + * @param int $i field id |
|
62 | + * @param null fields |
|
63 | + * @return mixed reference to the {@link Get} object |
|
64 | + */ |
|
65 | + public function get($i = null, $fields = null) |
|
66 | + { |
|
67 | + return parent::get($i, $fields); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * get inserted id |
|
72 | - * |
|
73 | - * @param null |
|
74 | - * @return int reference to the {@link Get} object |
|
75 | - */ |
|
76 | - public function getInsertId() |
|
77 | - { |
|
78 | - return $this->db->getInsertId(); |
|
79 | - } |
|
70 | + /** |
|
71 | + * get inserted id |
|
72 | + * |
|
73 | + * @param null |
|
74 | + * @return int reference to the {@link Get} object |
|
75 | + */ |
|
76 | + public function getInsertId() |
|
77 | + { |
|
78 | + return $this->db->getInsertId(); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Get Count Readmes in the database |
|
83 | - * @param int $start |
|
84 | - * @param int $limit |
|
85 | - * @param string $sort |
|
86 | - * @param string $order |
|
87 | - * @return int |
|
88 | - */ |
|
89 | - public function getCountReadmes($start = 0, $limit = 0, $sort = 'rm_id ASC, rm_name', $order = 'ASC') |
|
90 | - { |
|
91 | - $crCountReadmes = new \CriteriaCompo(); |
|
92 | - $crCountReadmes = $this->getReadmesCriteria($crCountReadmes, $start, $limit, $sort, $order); |
|
93 | - return $this->getCount($crCountReadmes); |
|
94 | - } |
|
81 | + /** |
|
82 | + * Get Count Readmes in the database |
|
83 | + * @param int $start |
|
84 | + * @param int $limit |
|
85 | + * @param string $sort |
|
86 | + * @param string $order |
|
87 | + * @return int |
|
88 | + */ |
|
89 | + public function getCountReadmes($start = 0, $limit = 0, $sort = 'rm_id ASC, rm_name', $order = 'ASC') |
|
90 | + { |
|
91 | + $crCountReadmes = new \CriteriaCompo(); |
|
92 | + $crCountReadmes = $this->getReadmesCriteria($crCountReadmes, $start, $limit, $sort, $order); |
|
93 | + return $this->getCount($crCountReadmes); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Get All Readmes in the database |
|
98 | - * @param int $start |
|
99 | - * @param int $limit |
|
100 | - * @param string $sort |
|
101 | - * @param string $order |
|
102 | - * @return array |
|
103 | - */ |
|
104 | - public function getAllReadmes($start = 0, $limit = 0, $sort = 'rm_id ASC, rm_name', $order = 'ASC') |
|
105 | - { |
|
106 | - $crAllReadmes = new \CriteriaCompo(); |
|
107 | - $crAllReadmes = $this->getReadmesCriteria($crAllReadmes, $start, $limit, $sort, $order); |
|
108 | - return $this->getAll($crAllReadmes); |
|
109 | - } |
|
96 | + /** |
|
97 | + * Get All Readmes in the database |
|
98 | + * @param int $start |
|
99 | + * @param int $limit |
|
100 | + * @param string $sort |
|
101 | + * @param string $order |
|
102 | + * @return array |
|
103 | + */ |
|
104 | + public function getAllReadmes($start = 0, $limit = 0, $sort = 'rm_id ASC, rm_name', $order = 'ASC') |
|
105 | + { |
|
106 | + $crAllReadmes = new \CriteriaCompo(); |
|
107 | + $crAllReadmes = $this->getReadmesCriteria($crAllReadmes, $start, $limit, $sort, $order); |
|
108 | + return $this->getAll($crAllReadmes); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Get Criteria Readmes |
|
113 | - * @param $crReadmes |
|
114 | - * @param int $start |
|
115 | - * @param int $limit |
|
116 | - * @param string $sort |
|
117 | - * @param string $order |
|
118 | - * @return int |
|
119 | - */ |
|
120 | - private function getReadmesCriteria($crReadmes, $start, $limit, $sort, $order) |
|
121 | - { |
|
122 | - $crReadmes->setStart($start); |
|
123 | - $crReadmes->setLimit($limit); |
|
124 | - $crReadmes->setSort($sort); |
|
125 | - $crReadmes->setOrder($order); |
|
126 | - return $crReadmes; |
|
127 | - } |
|
111 | + /** |
|
112 | + * Get Criteria Readmes |
|
113 | + * @param $crReadmes |
|
114 | + * @param int $start |
|
115 | + * @param int $limit |
|
116 | + * @param string $sort |
|
117 | + * @param string $order |
|
118 | + * @return int |
|
119 | + */ |
|
120 | + private function getReadmesCriteria($crReadmes, $start, $limit, $sort, $order) |
|
121 | + { |
|
122 | + $crReadmes->setStart($start); |
|
123 | + $crReadmes->setLimit($limit); |
|
124 | + $crReadmes->setSort($sort); |
|
125 | + $crReadmes->setOrder($order); |
|
126 | + return $crReadmes; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Update table requests |
@@ -33,110 +33,110 @@ |
||
33 | 33 | */ |
34 | 34 | class PermissionsHandler extends \XoopsPersistableObjectHandler |
35 | 35 | { |
36 | - /** |
|
37 | - * Constructor |
|
38 | - * |
|
39 | - * @param null |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - } |
|
36 | + /** |
|
37 | + * Constructor |
|
38 | + * |
|
39 | + * @param null |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @public function getPermGlobalRead |
|
47 | - * returns global right for reading from github |
|
48 | - * |
|
49 | - * @param null |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - public function getPermGlobalRead() |
|
53 | - { |
|
54 | - global $xoopsUser, $xoopsModule; |
|
55 | - $currentuid = 0; |
|
56 | - if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
57 | - if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
58 | - return true; |
|
59 | - } |
|
60 | - $currentuid = $xoopsUser->uid(); |
|
61 | - } |
|
62 | - $grouppermHandler = \xoops_getHandler('groupperm'); |
|
63 | - $mid = $xoopsModule->mid(); |
|
64 | - $memberHandler = \xoops_getHandler('member'); |
|
65 | - if (0 == $currentuid) { |
|
66 | - $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
67 | - } else { |
|
68 | - $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
69 | - } |
|
70 | - if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_GLOBAL_READ, $my_group_ids, $mid)) { |
|
71 | - return true; |
|
72 | - } |
|
73 | - return false; |
|
74 | - } |
|
45 | + /** |
|
46 | + * @public function getPermGlobalRead |
|
47 | + * returns global right for reading from github |
|
48 | + * |
|
49 | + * @param null |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + public function getPermGlobalRead() |
|
53 | + { |
|
54 | + global $xoopsUser, $xoopsModule; |
|
55 | + $currentuid = 0; |
|
56 | + if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
57 | + if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
58 | + return true; |
|
59 | + } |
|
60 | + $currentuid = $xoopsUser->uid(); |
|
61 | + } |
|
62 | + $grouppermHandler = \xoops_getHandler('groupperm'); |
|
63 | + $mid = $xoopsModule->mid(); |
|
64 | + $memberHandler = \xoops_getHandler('member'); |
|
65 | + if (0 == $currentuid) { |
|
66 | + $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
67 | + } else { |
|
68 | + $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
69 | + } |
|
70 | + if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_GLOBAL_READ, $my_group_ids, $mid)) { |
|
71 | + return true; |
|
72 | + } |
|
73 | + return false; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @public function permGlobalSubmit |
|
78 | - * returns right for global view |
|
79 | - * |
|
80 | - * @param null |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - public function getPermGlobalView() |
|
84 | - { |
|
85 | - global $xoopsUser, $xoopsModule; |
|
76 | + /** |
|
77 | + * @public function permGlobalSubmit |
|
78 | + * returns right for global view |
|
79 | + * |
|
80 | + * @param null |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + public function getPermGlobalView() |
|
84 | + { |
|
85 | + global $xoopsUser, $xoopsModule; |
|
86 | 86 | |
87 | 87 | if ($this->getPermGlobalRead()) { |
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | |
91 | - $currentuid = 0; |
|
92 | - if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
93 | - if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
94 | - return true; |
|
95 | - } |
|
96 | - $currentuid = $xoopsUser->uid(); |
|
97 | - } |
|
98 | - $grouppermHandler = \xoops_getHandler('groupperm'); |
|
99 | - $mid = $xoopsModule->mid(); |
|
100 | - $memberHandler = \xoops_getHandler('member'); |
|
101 | - if (0 == $currentuid) { |
|
102 | - $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
103 | - } else { |
|
104 | - $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
105 | - } |
|
106 | - if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_GLOBAL_VIEW, $my_group_ids, $mid)) { |
|
107 | - return true; |
|
108 | - } |
|
109 | - return false; |
|
110 | - } |
|
91 | + $currentuid = 0; |
|
92 | + if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
93 | + if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
94 | + return true; |
|
95 | + } |
|
96 | + $currentuid = $xoopsUser->uid(); |
|
97 | + } |
|
98 | + $grouppermHandler = \xoops_getHandler('groupperm'); |
|
99 | + $mid = $xoopsModule->mid(); |
|
100 | + $memberHandler = \xoops_getHandler('member'); |
|
101 | + if (0 == $currentuid) { |
|
102 | + $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
103 | + } else { |
|
104 | + $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
105 | + } |
|
106 | + if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_GLOBAL_VIEW, $my_group_ids, $mid)) { |
|
107 | + return true; |
|
108 | + } |
|
109 | + return false; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * @public function getPermReadmeUpdate |
|
114 | - * returns right for updating existing readme |
|
115 | - * |
|
116 | - * @param null |
|
117 | - * @return bool |
|
118 | - */ |
|
119 | - public function getPermReadmeUpdate() |
|
120 | - { |
|
121 | - global $xoopsUser, $xoopsModule; |
|
122 | - $currentuid = 0; |
|
123 | - if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
124 | - if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
125 | - return true; |
|
126 | - } |
|
127 | - $currentuid = $xoopsUser->uid(); |
|
128 | - } |
|
129 | - $grouppermHandler = \xoops_getHandler('groupperm'); |
|
130 | - $mid = $xoopsModule->mid(); |
|
131 | - $memberHandler = \xoops_getHandler('member'); |
|
132 | - if (0 == $currentuid) { |
|
133 | - $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
134 | - } else { |
|
135 | - $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
136 | - } |
|
137 | - if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_README_UPDATE, $my_group_ids, $mid)) { |
|
138 | - return true; |
|
139 | - } |
|
140 | - return false; |
|
141 | - } |
|
112 | + /** |
|
113 | + * @public function getPermReadmeUpdate |
|
114 | + * returns right for updating existing readme |
|
115 | + * |
|
116 | + * @param null |
|
117 | + * @return bool |
|
118 | + */ |
|
119 | + public function getPermReadmeUpdate() |
|
120 | + { |
|
121 | + global $xoopsUser, $xoopsModule; |
|
122 | + $currentuid = 0; |
|
123 | + if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
124 | + if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
125 | + return true; |
|
126 | + } |
|
127 | + $currentuid = $xoopsUser->uid(); |
|
128 | + } |
|
129 | + $grouppermHandler = \xoops_getHandler('groupperm'); |
|
130 | + $mid = $xoopsModule->mid(); |
|
131 | + $memberHandler = \xoops_getHandler('member'); |
|
132 | + if (0 == $currentuid) { |
|
133 | + $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
134 | + } else { |
|
135 | + $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
136 | + } |
|
137 | + if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_README_UPDATE, $my_group_ids, $mid)) { |
|
138 | + return true; |
|
139 | + } |
|
140 | + return false; |
|
141 | + } |
|
142 | 142 | } |