@@ -4,12 +4,12 @@ discard block |
||
4 | 4 | * @see http://www.php-fig.org/psr/psr-4/examples/ |
5 | 5 | */ |
6 | 6 | spl_autoload_register( |
7 | - static function ($class) { |
|
7 | + static function($class) { |
|
8 | 8 | // project-specific namespace prefix |
9 | - $prefix = 'XoopsModules\\' . \ucfirst(\basename(\dirname(__DIR__))); |
|
9 | + $prefix = 'XoopsModules\\'.\ucfirst(\basename(\dirname(__DIR__))); |
|
10 | 10 | |
11 | 11 | // base directory for the namespace prefix |
12 | - $baseDir = __DIR__ . '/../class/'; |
|
12 | + $baseDir = __DIR__.'/../class/'; |
|
13 | 13 | |
14 | 14 | // does the class use the namespace prefix? |
15 | 15 | $len = mb_strlen($prefix); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | // replace the namespace prefix with the base directory, replace namespace |
25 | 25 | // separators with directory separators in the relative class name, append |
26 | 26 | // with .php |
27 | - $file = $baseDir . \str_replace('\\', '/', $relativeClass) . '.php'; |
|
27 | + $file = $baseDir.\str_replace('\\', '/', $relativeClass).'.php'; |
|
28 | 28 | |
29 | 29 | // if the file exists, require it |
30 | 30 | if (\file_exists($file)) { |
@@ -28,6 +28,6 @@ |
||
28 | 28 | */ |
29 | 29 | public static function eventCoreIncludeCommonEnd($args) |
30 | 30 | { |
31 | - include __DIR__ . '/autoloader.php'; |
|
31 | + include __DIR__.'/autoloader.php'; |
|
32 | 32 | } |
33 | 33 | } |
@@ -45,38 +45,38 @@ |
||
45 | 45 | $GLOBALS['xoopsTpl']->assign('showItem', $rmId > 0); |
46 | 46 | |
47 | 47 | switch ($op) { |
48 | - case 'show': |
|
49 | - case 'list': |
|
50 | - default: |
|
51 | - $crReadmes = new \CriteriaCompo(); |
|
52 | - if ($rmId > 0) { |
|
53 | - $crReadmes->add(new \Criteria('rm_id', $rmId)); |
|
54 | - } |
|
55 | - $readmesCount = $readmesHandler->getCount($crReadmes); |
|
56 | - $GLOBALS['xoopsTpl']->assign('readmesCount', $readmesCount); |
|
57 | - $crReadmes->setStart($start); |
|
58 | - $crReadmes->setLimit($limit); |
|
59 | - $readmesAll = $readmesHandler->getAll($crReadmes); |
|
60 | - if ($readmesCount > 0) { |
|
61 | - $readmes = []; |
|
62 | - // Get All Readmes |
|
63 | - foreach (\array_keys($readmesAll) as $i) { |
|
64 | - $readmes[$i] = $readmesAll[$i]->getValuesReadmes(); |
|
65 | - $keywords[$i] = $readmesAll[$i]->getVar('rm_name'); |
|
66 | - } |
|
67 | - $GLOBALS['xoopsTpl']->assign('readmes', $readmes); |
|
68 | - unset($readmes); |
|
69 | - // Display Navigation |
|
70 | - if ($readmesCount > $limit) { |
|
71 | - include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
72 | - $pagenav = new \XoopsPageNav($readmesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
|
73 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
|
74 | - } |
|
75 | - $GLOBALS['xoopsTpl']->assign('type', $helper->getConfig('table_type')); |
|
76 | - $GLOBALS['xoopsTpl']->assign('divideby', $helper->getConfig('divideby')); |
|
77 | - $GLOBALS['xoopsTpl']->assign('numb_col', $helper->getConfig('numb_col')); |
|
78 | - } |
|
79 | - break; |
|
48 | + case 'show': |
|
49 | + case 'list': |
|
50 | + default: |
|
51 | + $crReadmes = new \CriteriaCompo(); |
|
52 | + if ($rmId > 0) { |
|
53 | + $crReadmes->add(new \Criteria('rm_id', $rmId)); |
|
54 | + } |
|
55 | + $readmesCount = $readmesHandler->getCount($crReadmes); |
|
56 | + $GLOBALS['xoopsTpl']->assign('readmesCount', $readmesCount); |
|
57 | + $crReadmes->setStart($start); |
|
58 | + $crReadmes->setLimit($limit); |
|
59 | + $readmesAll = $readmesHandler->getAll($crReadmes); |
|
60 | + if ($readmesCount > 0) { |
|
61 | + $readmes = []; |
|
62 | + // Get All Readmes |
|
63 | + foreach (\array_keys($readmesAll) as $i) { |
|
64 | + $readmes[$i] = $readmesAll[$i]->getValuesReadmes(); |
|
65 | + $keywords[$i] = $readmesAll[$i]->getVar('rm_name'); |
|
66 | + } |
|
67 | + $GLOBALS['xoopsTpl']->assign('readmes', $readmes); |
|
68 | + unset($readmes); |
|
69 | + // Display Navigation |
|
70 | + if ($readmesCount > $limit) { |
|
71 | + include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
72 | + $pagenav = new \XoopsPageNav($readmesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
|
73 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
|
74 | + } |
|
75 | + $GLOBALS['xoopsTpl']->assign('type', $helper->getConfig('table_type')); |
|
76 | + $GLOBALS['xoopsTpl']->assign('divideby', $helper->getConfig('divideby')); |
|
77 | + $GLOBALS['xoopsTpl']->assign('numb_col', $helper->getConfig('numb_col')); |
|
78 | + } |
|
79 | + break; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Breadcrumbs |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | use XoopsModules\Wggithub\Constants; |
26 | 26 | use XoopsModules\Wggithub\Common; |
27 | 27 | |
28 | -require __DIR__ . '/header.php'; |
|
28 | +require __DIR__.'/header.php'; |
|
29 | 29 | $GLOBALS['xoopsOption']['template_main'] = 'wggithub_readmes.tpl'; |
30 | -include_once XOOPS_ROOT_PATH . '/header.php'; |
|
30 | +include_once XOOPS_ROOT_PATH.'/header.php'; |
|
31 | 31 | |
32 | 32 | $op = Request::getCmd('op', 'list'); |
33 | 33 | $start = Request::getInt('start', 0); |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | unset($readmes); |
69 | 69 | // Display Navigation |
70 | 70 | if ($readmesCount > $limit) { |
71 | - include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
72 | - $pagenav = new \XoopsPageNav($readmesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
|
71 | + include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
72 | + $pagenav = new \XoopsPageNav($readmesCount, $limit, $start, 'start', 'op=list&limit='.$limit); |
|
73 | 73 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
74 | 74 | } |
75 | 75 | $GLOBALS['xoopsTpl']->assign('type', $helper->getConfig('table_type')); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $xoBreadcrumbs[] = ['title' => _MA_WGGITHUB_READMES]; |
84 | 84 | |
85 | 85 | // Keywords |
86 | -wggithubMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords)); |
|
86 | +wggithubMetaKeywords($helper->getConfig('keywords').', '.\implode(',', $keywords)); |
|
87 | 87 | unset($keywords); |
88 | 88 | |
89 | 89 | // Description |
@@ -91,4 +91,4 @@ discard block |
||
91 | 91 | $GLOBALS['xoopsTpl']->assign('xoops_mpageurl', WGGITHUB_URL.'/readmes.php'); |
92 | 92 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL); |
93 | 93 | |
94 | -require __DIR__ . '/footer.php'; |
|
94 | +require __DIR__.'/footer.php'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | use XoopsModules\Wggithub; |
25 | 25 | use XoopsModules\Wggithub\Constants; |
26 | 26 | |
27 | -require __DIR__ . '/header.php'; |
|
27 | +require __DIR__.'/header.php'; |
|
28 | 28 | |
29 | 29 | // Template Index |
30 | 30 | $templateMain = 'wggithub_admin_permissions.tpl'; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $op = Request::getCmd('op', 'global'); |
34 | 34 | |
35 | 35 | // Get Form |
36 | -include_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
|
36 | +include_once XOOPS_ROOT_PATH.'/class/xoopsform/grouppermform.php'; |
|
37 | 37 | \xoops_load('XoopsFormLoader'); |
38 | 38 | |
39 | 39 | $formTitle = \_AM_WGGITHUB_PERMISSIONS_GLOBAL; |
@@ -61,4 +61,4 @@ discard block |
||
61 | 61 | exit(); |
62 | 62 | } |
63 | 63 | |
64 | -require __DIR__ . '/footer.php'; |
|
64 | +require __DIR__.'/footer.php'; |
@@ -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 |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $readmesObj->setVar('rm_content', $readme['content']); |
171 | 171 | $readmesObj->setVar('rm_encoding', $readme['encoding']); |
172 | 172 | $readmesObj->setVar('rm_downloadurl', $readme['download_url']); |
173 | - $readmesObj->setVar('rm_datecreated',time()); |
|
173 | + $readmesObj->setVar('rm_datecreated', time()); |
|
174 | 174 | $readmesObj->setVar('rm_submitter', $submitter); |
175 | 175 | // Insert Data |
176 | 176 | if (!$readmesHandler->insert($readmesObj)) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $readmesObj->setVar('rm_content', $readme['content']); |
241 | 241 | $readmesObj->setVar('rm_encoding', $readme['encoding']); |
242 | 242 | $readmesObj->setVar('rm_downloadurl', $readme['download_url']); |
243 | - $readmesObj->setVar('rm_datecreated',time()); |
|
243 | + $readmesObj->setVar('rm_datecreated', time()); |
|
244 | 244 | $readmesObj->setVar('rm_submitter', $submitter); |
245 | 245 | // Insert Data |
246 | 246 | if (!$readmesHandler->insert($readmesObj)) { |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | public function updateRepoReadme() |
279 | 279 | { |
280 | 280 | // update repo_readme |
281 | - $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('wggithub_repositories') . ' INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('wggithub_readmes'); |
|
282 | - $sql .= ' ON ' . $GLOBALS['xoopsDB']->prefix('wggithub_repositories') . '.repo_id = ' . $GLOBALS['xoopsDB']->prefix('wggithub_readmes') . '.rm_repoid '; |
|
283 | - $sql .= 'SET ' . $GLOBALS['xoopsDB']->prefix('wggithub_repositories') . '.repo_readme = 1 '; |
|
284 | - $sql .= 'WHERE (((' . $GLOBALS['xoopsDB']->prefix('wggithub_readmes') . '.rm_id)>0));'; |
|
281 | + $sql = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('wggithub_repositories').' INNER JOIN '.$GLOBALS['xoopsDB']->prefix('wggithub_readmes'); |
|
282 | + $sql .= ' ON '.$GLOBALS['xoopsDB']->prefix('wggithub_repositories').'.repo_id = '.$GLOBALS['xoopsDB']->prefix('wggithub_readmes').'.rm_repoid '; |
|
283 | + $sql .= 'SET '.$GLOBALS['xoopsDB']->prefix('wggithub_repositories').'.repo_readme = 1 '; |
|
284 | + $sql .= 'WHERE ((('.$GLOBALS['xoopsDB']->prefix('wggithub_readmes').'.rm_id)>0));'; |
|
285 | 285 | $GLOBALS['xoopsDB']->queryF($sql); |
286 | 286 | |
287 | 287 | return true; |
@@ -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 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | Utility |
25 | 25 | }; |
26 | 26 | |
27 | -require_once dirname(__DIR__, 3) . '/include/cp_header.php'; |
|
28 | -require \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
27 | +require_once dirname(__DIR__, 3).'/include/cp_header.php'; |
|
28 | +require \dirname(__DIR__).'/preloads/autoloader.php'; |
|
29 | 29 | |
30 | 30 | $op = \Xmf\Request::getCmd('op', ''); |
31 | 31 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | loadSampleData(); |
46 | 46 | } else { |
47 | 47 | xoops_cp_header(); |
48 | - xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK')), \constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
48 | + xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \sprintf(\constant('CO_'.$moduleDirNameUpper.'_'.'ADD_SAMPLEDATA_OK')), \constant('CO_'.$moduleDirNameUpper.'_'.'CONFIRM'), true); |
|
49 | 49 | xoops_cp_footer(); |
50 | 50 | } |
51 | 51 | break; |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
69 | 69 | |
70 | 70 | $language = 'english/'; |
71 | - if (\is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
72 | - $language = $xoopsConfig['language'] . '/'; |
|
71 | + if (\is_dir(__DIR__.'/'.$xoopsConfig['language'])) { |
|
72 | + $language = $xoopsConfig['language'].'/'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // load module tables |
76 | 76 | foreach ($tables as $table) { |
77 | - $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
77 | + $tabledata = Yaml::readWrapped($language.$table.'.yml'); |
|
78 | 78 | TableLoad::truncateTable($table); |
79 | 79 | TableLoad::loadTableFromArray($table, $tabledata); |
80 | 80 | } |
81 | 81 | |
82 | 82 | // load permissions |
83 | 83 | $table = 'group_permission'; |
84 | - $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
84 | + $tabledata = Yaml::readWrapped($language.$table.'.yml'); |
|
85 | 85 | $mid = Helper::getHelper($moduleDirName)->getModule()->getVar('mid'); |
86 | 86 | loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid); |
87 | 87 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $utility::rcopy($src, $dest); |
95 | 95 | } |
96 | 96 | } |
97 | - \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); |
|
97 | + \redirect_header('../admin/index.php', 1, \constant('CO_'.$moduleDirNameUpper.'_'.'SAMPLEDATA_SUCCESS')); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | function saveSampleData() |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | |
109 | 109 | $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
110 | 110 | |
111 | - $languageFolder = __DIR__ . '/' . $xoopsConfig['language']; |
|
112 | - if (!\file_exists($languageFolder . '/')) { |
|
113 | - Utility::createFolder($languageFolder . '/'); |
|
111 | + $languageFolder = __DIR__.'/'.$xoopsConfig['language']; |
|
112 | + if (!\file_exists($languageFolder.'/')) { |
|
113 | + Utility::createFolder($languageFolder.'/'); |
|
114 | 114 | } |
115 | - $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; |
|
115 | + $exportFolder = $languageFolder.'/Exports-'.date('Y-m-d-H-i-s').'/'; |
|
116 | 116 | Utility::createFolder($exportFolder); |
117 | 117 | |
118 | 118 | // save module tables |
119 | 119 | foreach ($tables as $table) { |
120 | - TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); |
|
120 | + TableLoad::saveTableToYamlFile($table, $exportFolder.$table.'.yml'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // save permissions |
124 | 124 | $criteria = new \CriteriaCompo(); |
125 | 125 | $criteria->add(new \Criteria('gperm_modid', Helper::getHelper($moduleDirName)->getModule()->getVar('mid'))); |
126 | 126 | $skipColumns[] = 'gperm_id'; |
127 | - TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns); |
|
127 | + TableLoad::saveTableToYamlFile('group_permission', $exportFolder.'group_permission.yml', $criteria, $skipColumns); |
|
128 | 128 | unset($criteria); |
129 | 129 | |
130 | 130 | // --- COPY test folder files --------------- |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | Utility::rcopy($src, $dest); |
136 | 136 | } |
137 | 137 | } |
138 | - \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS')); |
|
138 | + \redirect_header('../admin/index.php', 1, \constant('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA_SUCCESS')); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | function exportSchema() |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | // |
151 | 151 | // \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); |
152 | 152 | } catch (\Exception $e) { |
153 | - exit(\constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); |
|
153 | + exit(\constant('CO_'.$moduleDirNameUpper.'_'.'EXPORT_SCHEMA_ERROR')); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | } |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
174 | 174 | $prefixedTable = $db->prefix($table); |
175 | 175 | $count = 0; |
176 | - $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace); |
|
176 | + $sql = 'DELETE FROM '.$prefixedTable.' WHERE `'.$search.'`='.$db->quote($replace); |
|
177 | 177 | $db->queryF($sql); |
178 | 178 | foreach ($data as $row) { |
179 | - $insertInto = 'INSERT INTO ' . $prefixedTable . ' ('; |
|
179 | + $insertInto = 'INSERT INTO '.$prefixedTable.' ('; |
|
180 | 180 | $valueClause = ' VALUES ('; |
181 | 181 | $first = true; |
182 | 182 | foreach ($row as $column => $value) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $valueClause .= $db->quote($value); |
194 | 194 | } |
195 | 195 | } |
196 | - $sql = $insertInto . ') ' . $valueClause . ')'; |
|
196 | + $sql = $insertInto.') '.$valueClause.')'; |
|
197 | 197 | $result = $db->queryF($sql); |
198 | 198 | if (false !== $result) { |
199 | 199 | ++$count; |
@@ -31,96 +31,96 @@ |
||
31 | 31 | */ |
32 | 32 | class SettingsHandler extends \XoopsPersistableObjectHandler |
33 | 33 | { |
34 | - /** |
|
35 | - * Constructor |
|
36 | - * |
|
37 | - * @param \XoopsDatabase $db |
|
38 | - */ |
|
39 | - public function __construct(\XoopsDatabase $db) |
|
40 | - { |
|
41 | - parent::__construct($db, 'wggithub_settings', Settings::class, 'set_id', 'set_token'); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @param bool $isNew |
|
46 | - * |
|
47 | - * @return object |
|
48 | - */ |
|
49 | - public function create($isNew = true) |
|
50 | - { |
|
51 | - return parent::create($isNew); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * retrieve a field |
|
56 | - * |
|
57 | - * @param int $i field id |
|
58 | - * @param null fields |
|
59 | - * @return mixed reference to the {@link Get} object |
|
60 | - */ |
|
61 | - public function get($i = null, $fields = null) |
|
62 | - { |
|
63 | - return parent::get($i, $fields); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * get inserted id |
|
68 | - * |
|
69 | - * @param null |
|
70 | - * @return int reference to the {@link Get} object |
|
71 | - */ |
|
72 | - public function getInsertId() |
|
73 | - { |
|
74 | - return $this->db->getInsertId(); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Get Count Settings in the database |
|
79 | - * @param int $start |
|
80 | - * @param int $limit |
|
81 | - * @param string $sort |
|
82 | - * @param string $order |
|
83 | - * @return int |
|
84 | - */ |
|
85 | - public function getCountSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_token', $order = 'ASC') |
|
86 | - { |
|
87 | - $crCountSettings = new \CriteriaCompo(); |
|
88 | - $crCountSettings = $this->getSettingsCriteria($crCountSettings, $start, $limit, $sort, $order); |
|
89 | - return $this->getCount($crCountSettings); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Get All Settings in the database |
|
94 | - * @param int $start |
|
95 | - * @param int $limit |
|
96 | - * @param string $sort |
|
97 | - * @param string $order |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public function getAllSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_token', $order = 'ASC') |
|
101 | - { |
|
102 | - $crAllSettings = new \CriteriaCompo(); |
|
103 | - $crAllSettings = $this->getSettingsCriteria($crAllSettings, $start, $limit, $sort, $order); |
|
104 | - return $this->getAll($crAllSettings); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Get Criteria Settings |
|
109 | - * @param $crSettings |
|
110 | - * @param int $start |
|
111 | - * @param int $limit |
|
112 | - * @param string $sort |
|
113 | - * @param string $order |
|
114 | - * @return int |
|
115 | - */ |
|
116 | - private function getSettingsCriteria($crSettings, $start, $limit, $sort, $order) |
|
117 | - { |
|
118 | - $crSettings->setStart($start); |
|
119 | - $crSettings->setLimit($limit); |
|
120 | - $crSettings->setSort($sort); |
|
121 | - $crSettings->setOrder($order); |
|
122 | - return $crSettings; |
|
123 | - } |
|
34 | + /** |
|
35 | + * Constructor |
|
36 | + * |
|
37 | + * @param \XoopsDatabase $db |
|
38 | + */ |
|
39 | + public function __construct(\XoopsDatabase $db) |
|
40 | + { |
|
41 | + parent::__construct($db, 'wggithub_settings', Settings::class, 'set_id', 'set_token'); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @param bool $isNew |
|
46 | + * |
|
47 | + * @return object |
|
48 | + */ |
|
49 | + public function create($isNew = true) |
|
50 | + { |
|
51 | + return parent::create($isNew); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * retrieve a field |
|
56 | + * |
|
57 | + * @param int $i field id |
|
58 | + * @param null fields |
|
59 | + * @return mixed reference to the {@link Get} object |
|
60 | + */ |
|
61 | + public function get($i = null, $fields = null) |
|
62 | + { |
|
63 | + return parent::get($i, $fields); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * get inserted id |
|
68 | + * |
|
69 | + * @param null |
|
70 | + * @return int reference to the {@link Get} object |
|
71 | + */ |
|
72 | + public function getInsertId() |
|
73 | + { |
|
74 | + return $this->db->getInsertId(); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Get Count Settings in the database |
|
79 | + * @param int $start |
|
80 | + * @param int $limit |
|
81 | + * @param string $sort |
|
82 | + * @param string $order |
|
83 | + * @return int |
|
84 | + */ |
|
85 | + public function getCountSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_token', $order = 'ASC') |
|
86 | + { |
|
87 | + $crCountSettings = new \CriteriaCompo(); |
|
88 | + $crCountSettings = $this->getSettingsCriteria($crCountSettings, $start, $limit, $sort, $order); |
|
89 | + return $this->getCount($crCountSettings); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Get All Settings in the database |
|
94 | + * @param int $start |
|
95 | + * @param int $limit |
|
96 | + * @param string $sort |
|
97 | + * @param string $order |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public function getAllSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_token', $order = 'ASC') |
|
101 | + { |
|
102 | + $crAllSettings = new \CriteriaCompo(); |
|
103 | + $crAllSettings = $this->getSettingsCriteria($crAllSettings, $start, $limit, $sort, $order); |
|
104 | + return $this->getAll($crAllSettings); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Get Criteria Settings |
|
109 | + * @param $crSettings |
|
110 | + * @param int $start |
|
111 | + * @param int $limit |
|
112 | + * @param string $sort |
|
113 | + * @param string $order |
|
114 | + * @return int |
|
115 | + */ |
|
116 | + private function getSettingsCriteria($crSettings, $start, $limit, $sort, $order) |
|
117 | + { |
|
118 | + $crSettings->setStart($start); |
|
119 | + $crSettings->setLimit($limit); |
|
120 | + $crSettings->setSort($sort); |
|
121 | + $crSettings->setOrder($order); |
|
122 | + return $crSettings; |
|
123 | + } |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Get Primary Setting |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function setPrimarySetting($setId) |
150 | 150 | { |
151 | - $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
151 | + $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
152 | 152 | $settingsObj = null; |
153 | 153 | $settingsHandler = $helper->getHandler('Settings'); |
154 | 154 | if (isset($setId)) { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | // reset all |
161 | - $strSQL = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('wggithub_settings') . ' SET ' . $GLOBALS['xoopsDB']->prefix('wggithub_settings') . '.set_primary = 0'; |
|
161 | + $strSQL = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('wggithub_settings').' SET '.$GLOBALS['xoopsDB']->prefix('wggithub_settings').'.set_primary = 0'; |
|
162 | 162 | $GLOBALS['xoopsDB']->queryF($strSQL); |
163 | 163 | // Set Vars |
164 | 164 | $settingsObj->setVar('set_primary', 1); |
@@ -31,107 +31,107 @@ |
||
31 | 31 | // Request log_id |
32 | 32 | $logId = Request::getInt('log_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_logs.tpl'; |
|
41 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
42 | - $adminObject->addItemButton(_AM_WGGITHUB_ADD_LOG, 'logs.php?op=new', 'add'); |
|
43 | - $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
44 | - $logsCount = $logsHandler->getCountLogs(); |
|
45 | - $logsAll = $logsHandler->getAllLogs($start, $limit); |
|
46 | - $GLOBALS['xoopsTpl']->assign('logs_count', $logsCount); |
|
47 | - $GLOBALS['xoopsTpl']->assign('wggithub_url', WGGITHUB_URL); |
|
48 | - $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL); |
|
49 | - // Table view logs |
|
50 | - if ($logsCount > 0) { |
|
51 | - foreach (\array_keys($logsAll) as $i) { |
|
52 | - $log = $logsAll[$i]->getValuesLogs(); |
|
53 | - $GLOBALS['xoopsTpl']->append('logs_list', $log); |
|
54 | - unset($log); |
|
55 | - } |
|
56 | - // Display Navigation |
|
57 | - if ($logsCount > $limit) { |
|
58 | - include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
59 | - $pagenav = new \XoopsPageNav($logsCount, $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_LOGS); |
|
64 | - } |
|
65 | - break; |
|
66 | - case 'new': |
|
67 | - $templateMain = 'wggithub_admin_logs.tpl'; |
|
68 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
69 | - $adminObject->addItemButton(_AM_WGGITHUB_LOGS_LIST, 'logs.php', 'list'); |
|
70 | - $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
71 | - // Form Create |
|
72 | - $logsObj = $logsHandler->create(); |
|
73 | - $form = $logsObj->getFormLogs(); |
|
74 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
75 | - break; |
|
76 | - case 'save': |
|
77 | - // Security Check |
|
78 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
79 | - \redirect_header('logs.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
80 | - } |
|
81 | - if ($logId > 0) { |
|
82 | - $logsObj = $logsHandler->get($logId); |
|
83 | - } else { |
|
84 | - $logsObj = $logsHandler->create(); |
|
85 | - } |
|
86 | - // Set Vars |
|
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_logs.tpl'; |
|
41 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
42 | + $adminObject->addItemButton(_AM_WGGITHUB_ADD_LOG, 'logs.php?op=new', 'add'); |
|
43 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
44 | + $logsCount = $logsHandler->getCountLogs(); |
|
45 | + $logsAll = $logsHandler->getAllLogs($start, $limit); |
|
46 | + $GLOBALS['xoopsTpl']->assign('logs_count', $logsCount); |
|
47 | + $GLOBALS['xoopsTpl']->assign('wggithub_url', WGGITHUB_URL); |
|
48 | + $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL); |
|
49 | + // Table view logs |
|
50 | + if ($logsCount > 0) { |
|
51 | + foreach (\array_keys($logsAll) as $i) { |
|
52 | + $log = $logsAll[$i]->getValuesLogs(); |
|
53 | + $GLOBALS['xoopsTpl']->append('logs_list', $log); |
|
54 | + unset($log); |
|
55 | + } |
|
56 | + // Display Navigation |
|
57 | + if ($logsCount > $limit) { |
|
58 | + include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
59 | + $pagenav = new \XoopsPageNav($logsCount, $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_LOGS); |
|
64 | + } |
|
65 | + break; |
|
66 | + case 'new': |
|
67 | + $templateMain = 'wggithub_admin_logs.tpl'; |
|
68 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
69 | + $adminObject->addItemButton(_AM_WGGITHUB_LOGS_LIST, 'logs.php', 'list'); |
|
70 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
71 | + // Form Create |
|
72 | + $logsObj = $logsHandler->create(); |
|
73 | + $form = $logsObj->getFormLogs(); |
|
74 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
75 | + break; |
|
76 | + case 'save': |
|
77 | + // Security Check |
|
78 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
79 | + \redirect_header('logs.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
80 | + } |
|
81 | + if ($logId > 0) { |
|
82 | + $logsObj = $logsHandler->get($logId); |
|
83 | + } else { |
|
84 | + $logsObj = $logsHandler->create(); |
|
85 | + } |
|
86 | + // Set Vars |
|
87 | 87 | $logsObj->setVar('log_type', Request::getInt('log_type', 0)); |
88 | - $logsObj->setVar('log_details', Request::getString('log_details', '')); |
|
89 | - $logsObj->setVar('log_result', Request::getString('log_result', '')); |
|
90 | - $logDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('log_datecreated')); |
|
91 | - $logsObj->setVar('log_datecreated', $logDatecreatedObj->getTimestamp()); |
|
92 | - $logsObj->setVar('log_submitter', Request::getInt('log_submitter', 0)); |
|
93 | - // Insert Data |
|
94 | - if ($logsHandler->insert($logsObj)) { |
|
95 | - \redirect_header('logs.php?op=list', 2, _AM_WGGITHUB_FORM_OK); |
|
96 | - } |
|
97 | - // Get Form |
|
98 | - $GLOBALS['xoopsTpl']->assign('error', $logsObj->getHtmlErrors()); |
|
99 | - $form = $logsObj->getFormLogs(); |
|
100 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
101 | - break; |
|
102 | - case 'edit': |
|
103 | - $templateMain = 'wggithub_admin_logs.tpl'; |
|
104 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
105 | - $adminObject->addItemButton(_AM_WGGITHUB_ADD_LOG, 'logs.php?op=new', 'add'); |
|
106 | - $adminObject->addItemButton(_AM_WGGITHUB_LOGS_LIST, 'logs.php', 'list'); |
|
107 | - $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
108 | - // Get Form |
|
109 | - $logsObj = $logsHandler->get($logId); |
|
110 | - $form = $logsObj->getFormLogs(); |
|
111 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
112 | - break; |
|
113 | - case 'delete': |
|
114 | - $templateMain = 'wggithub_admin_logs.tpl'; |
|
115 | - $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
116 | - $logsObj = $logsHandler->get($logId); |
|
117 | - $reqRequest = $logsObj->getVar('log_details'); |
|
118 | - if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
|
119 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
120 | - \redirect_header('logs.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
|
121 | - } |
|
122 | - if ($logsHandler->delete($logsObj)) { |
|
123 | - \redirect_header('logs.php', 3, _AM_WGGITHUB_FORM_DELETE_OK); |
|
124 | - } else { |
|
125 | - $GLOBALS['xoopsTpl']->assign('error', $logsObj->getHtmlErrors()); |
|
126 | - } |
|
127 | - } else { |
|
128 | - $xoopsconfirm = new Common\XoopsConfirm( |
|
129 | - ['ok' => 1, 'log_id' => $logId, 'op' => 'delete'], |
|
130 | - $_SERVER['REQUEST_URI'], |
|
131 | - \sprintf(_AM_WGGITHUB_FORM_SURE_DELETE, $logsObj->getVar('log_details'))); |
|
132 | - $form = $xoopsconfirm->getFormXoopsConfirm(); |
|
133 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
134 | - } |
|
135 | - break; |
|
88 | + $logsObj->setVar('log_details', Request::getString('log_details', '')); |
|
89 | + $logsObj->setVar('log_result', Request::getString('log_result', '')); |
|
90 | + $logDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('log_datecreated')); |
|
91 | + $logsObj->setVar('log_datecreated', $logDatecreatedObj->getTimestamp()); |
|
92 | + $logsObj->setVar('log_submitter', Request::getInt('log_submitter', 0)); |
|
93 | + // Insert Data |
|
94 | + if ($logsHandler->insert($logsObj)) { |
|
95 | + \redirect_header('logs.php?op=list', 2, _AM_WGGITHUB_FORM_OK); |
|
96 | + } |
|
97 | + // Get Form |
|
98 | + $GLOBALS['xoopsTpl']->assign('error', $logsObj->getHtmlErrors()); |
|
99 | + $form = $logsObj->getFormLogs(); |
|
100 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
101 | + break; |
|
102 | + case 'edit': |
|
103 | + $templateMain = 'wggithub_admin_logs.tpl'; |
|
104 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
105 | + $adminObject->addItemButton(_AM_WGGITHUB_ADD_LOG, 'logs.php?op=new', 'add'); |
|
106 | + $adminObject->addItemButton(_AM_WGGITHUB_LOGS_LIST, 'logs.php', 'list'); |
|
107 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
108 | + // Get Form |
|
109 | + $logsObj = $logsHandler->get($logId); |
|
110 | + $form = $logsObj->getFormLogs(); |
|
111 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
112 | + break; |
|
113 | + case 'delete': |
|
114 | + $templateMain = 'wggithub_admin_logs.tpl'; |
|
115 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('logs.php')); |
|
116 | + $logsObj = $logsHandler->get($logId); |
|
117 | + $reqRequest = $logsObj->getVar('log_details'); |
|
118 | + if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
|
119 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
120 | + \redirect_header('logs.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
|
121 | + } |
|
122 | + if ($logsHandler->delete($logsObj)) { |
|
123 | + \redirect_header('logs.php', 3, _AM_WGGITHUB_FORM_DELETE_OK); |
|
124 | + } else { |
|
125 | + $GLOBALS['xoopsTpl']->assign('error', $logsObj->getHtmlErrors()); |
|
126 | + } |
|
127 | + } else { |
|
128 | + $xoopsconfirm = new Common\XoopsConfirm( |
|
129 | + ['ok' => 1, 'log_id' => $logId, 'op' => 'delete'], |
|
130 | + $_SERVER['REQUEST_URI'], |
|
131 | + \sprintf(_AM_WGGITHUB_FORM_SURE_DELETE, $logsObj->getVar('log_details'))); |
|
132 | + $form = $xoopsconfirm->getFormXoopsConfirm(); |
|
133 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
134 | + } |
|
135 | + break; |
|
136 | 136 | } |
137 | 137 | require __DIR__ . '/footer.php'; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | use XoopsModules\Wggithub\Constants; |
26 | 26 | use XoopsModules\Wggithub\Common; |
27 | 27 | |
28 | -require __DIR__ . '/header.php'; |
|
28 | +require __DIR__.'/header.php'; |
|
29 | 29 | // It recovered the value of argument op in URL$ |
30 | 30 | $op = Request::getCmd('op', 'list'); |
31 | 31 | // Request log_id |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | } |
56 | 56 | // Display Navigation |
57 | 57 | if ($logsCount > $limit) { |
58 | - include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
59 | - $pagenav = new \XoopsPageNav($logsCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
|
58 | + include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
59 | + $pagenav = new \XoopsPageNav($logsCount, $limit, $start, 'start', 'op=list&limit='.$limit); |
|
60 | 60 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
61 | 61 | } |
62 | 62 | } else { |
@@ -134,4 +134,4 @@ discard block |
||
134 | 134 | } |
135 | 135 | break; |
136 | 136 | } |
137 | -require __DIR__ . '/footer.php'; |
|
137 | +require __DIR__.'/footer.php'; |