Passed
Push — master ( 3d7fba...dbde9b )
by Goffy
03:57
created
class/RequestsHandler.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -31,94 +31,94 @@
 block discarded – undo
31 31
  */
32 32
 class RequestsHandler 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_requests', Requests::class, 'req_id', 'req_request');
42
-	}
34
+    /**
35
+     * Constructor
36
+     *
37
+     * @param \XoopsDatabase $db
38
+     */
39
+    public function __construct(\XoopsDatabase $db)
40
+    {
41
+        parent::__construct($db, 'wggithub_requests', Requests::class, 'req_id', 'req_request');
42
+    }
43 43
 
44
-	/**
45
-	 * @param bool $isNew
46
-	 *
47
-	 * @return object
48
-	 */
49
-	public function create($isNew = true)
50
-	{
51
-		return parent::create($isNew);
52
-	}
44
+    /**
45
+     * @param bool $isNew
46
+     *
47
+     * @return object
48
+     */
49
+    public function create($isNew = true)
50
+    {
51
+        return parent::create($isNew);
52
+    }
53 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
-	}
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 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
-	}
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 76
 
77
-	/**
78
-	 * Get Count Requests 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 getCountRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC')
86
-	{
87
-		$crCountRequests = new \CriteriaCompo();
88
-		$crCountRequests = $this->getRequestsCriteria($crCountRequests, $start, $limit, $sort, $order);
89
-		return $this->getCount($crCountRequests);
90
-	}
77
+    /**
78
+     * Get Count Requests 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 getCountRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC')
86
+    {
87
+        $crCountRequests = new \CriteriaCompo();
88
+        $crCountRequests = $this->getRequestsCriteria($crCountRequests, $start, $limit, $sort, $order);
89
+        return $this->getCount($crCountRequests);
90
+    }
91 91
 
92
-	/**
93
-	 * Get All Requests 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 getAllRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC')
101
-	{
102
-		$crAllRequests = new \CriteriaCompo();
103
-		$crAllRequests = $this->getRequestsCriteria($crAllRequests, $start, $limit, $sort, $order);
104
-		return $this->getAll($crAllRequests);
105
-	}
92
+    /**
93
+     * Get All Requests 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 getAllRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC')
101
+    {
102
+        $crAllRequests = new \CriteriaCompo();
103
+        $crAllRequests = $this->getRequestsCriteria($crAllRequests, $start, $limit, $sort, $order);
104
+        return $this->getAll($crAllRequests);
105
+    }
106 106
 
107
-	/**
108
-	 * Get Criteria Requests
109
-	 * @param        $crRequests
110
-	 * @param int    $start
111
-	 * @param int    $limit
112
-	 * @param string $sort
113
-	 * @param string $order
114
-	 * @return int
115
-	 */
116
-	private function getRequestsCriteria($crRequests, $start, $limit, $sort, $order)
117
-	{
118
-		$crRequests->setStart($start);
119
-		$crRequests->setLimit($limit);
120
-		$crRequests->setSort($sort);
121
-		$crRequests->setOrder($order);
122
-		return $crRequests;
123
-	}
107
+    /**
108
+     * Get Criteria Requests
109
+     * @param        $crRequests
110
+     * @param int    $start
111
+     * @param int    $limit
112
+     * @param string $sort
113
+     * @param string $order
114
+     * @return int
115
+     */
116
+    private function getRequestsCriteria($crRequests, $start, $limit, $sort, $order)
117
+    {
118
+        $crRequests->setStart($start);
119
+        $crRequests->setLimit($limit);
120
+        $crRequests->setSort($sort);
121
+        $crRequests->setOrder($order);
122
+        return $crRequests;
123
+    }
124 124
 }
Please login to merge, or discard this patch.
class/Github/Github.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
         return $repos;
82 82
     }
83
-    */
83
+     */
84 84
 
85 85
     /**
86 86
      * Get data of all repositories of given organisation
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         return $repos;
97 97
     }
98
-    */
98
+     */
99 99
 
100 100
     /**
101 101
      * Get primary setting
Please login to merge, or discard this patch.
class/Requests.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -32,106 +32,106 @@
 block discarded – undo
32 32
  */
33 33
 class Requests extends \XoopsObject
34 34
 {
35
-	/**
36
-	 * Constructor
37
-	 *
38
-	 * @param null
39
-	 */
40
-	public function __construct()
41
-	{
42
-		$this->initVar('req_id', \XOBJ_DTYPE_INT);
43
-		$this->initVar('req_request', \XOBJ_DTYPE_TXTBOX);
44
-		$this->initVar('req_result', \XOBJ_DTYPE_TXTBOX);
45
-		$this->initVar('req_datecreated', \XOBJ_DTYPE_INT);
46
-		$this->initVar('req_submitter', \XOBJ_DTYPE_INT);
47
-	}
35
+    /**
36
+     * Constructor
37
+     *
38
+     * @param null
39
+     */
40
+    public function __construct()
41
+    {
42
+        $this->initVar('req_id', \XOBJ_DTYPE_INT);
43
+        $this->initVar('req_request', \XOBJ_DTYPE_TXTBOX);
44
+        $this->initVar('req_result', \XOBJ_DTYPE_TXTBOX);
45
+        $this->initVar('req_datecreated', \XOBJ_DTYPE_INT);
46
+        $this->initVar('req_submitter', \XOBJ_DTYPE_INT);
47
+    }
48 48
 
49
-	/**
50
-	 * @static function &getInstance
51
-	 *
52
-	 * @param null
53
-	 */
54
-	public static function getInstance()
55
-	{
56
-		static $instance = false;
57
-		if (!$instance) {
58
-			$instance = new self();
59
-		}
60
-	}
49
+    /**
50
+     * @static function &getInstance
51
+     *
52
+     * @param null
53
+     */
54
+    public static function getInstance()
55
+    {
56
+        static $instance = false;
57
+        if (!$instance) {
58
+            $instance = new self();
59
+        }
60
+    }
61 61
 
62
-	/**
63
-	 * The new inserted $Id
64
-	 * @return inserted id
65
-	 */
66
-	public function getNewInsertedIdRequests()
67
-	{
68
-		$newInsertedId = $GLOBALS['xoopsDB']->getInsertId();
69
-		return $newInsertedId;
70
-	}
62
+    /**
63
+     * The new inserted $Id
64
+     * @return inserted id
65
+     */
66
+    public function getNewInsertedIdRequests()
67
+    {
68
+        $newInsertedId = $GLOBALS['xoopsDB']->getInsertId();
69
+        return $newInsertedId;
70
+    }
71 71
 
72
-	/**
73
-	 * @public function getForm
74
-	 * @param bool $action
75
-	 * @return \XoopsThemeForm
76
-	 */
77
-	public function getFormRequests($action = false)
78
-	{
79
-		$helper = \XoopsModules\Wggithub\Helper::getInstance();
80
-		if (!$action) {
81
-			$action = $_SERVER['REQUEST_URI'];
82
-		}
83
-		$isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid());
84
-		// Title
85
-		$title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_REQUEST_ADD) : \sprintf(\_AM_WGGITHUB_REQUEST_EDIT);
86
-		// Get Theme Form
87
-		\xoops_load('XoopsFormLoader');
88
-		$form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
89
-		$form->setExtra('enctype="multipart/form-data"');
90
-		// Form Text reqRequest
91
-		$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REQUEST_REQUEST, 'req_request', 50, 255, $this->getVar('req_request')), true);
92
-		// Form Text reqResult
93
-		$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REQUEST_RESULT, 'req_result', 50, 255, $this->getVar('req_result')));
94
-		// Form Text Date Select reqDatecreated
95
-		$reqDatecreated = $this->isNew() ?: $this->getVar('req_datecreated');
96
-		$form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_REQUEST_DATECREATED, 'req_datecreated', '', $reqDatecreated));
97
-		// Form Select User reqSubmitter
98
-		$form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_REQUEST_SUBMITTER, 'req_submitter', false, $this->getVar('req_submitter')));
99
-		// To Save
100
-		$form->addElement(new \XoopsFormHidden('op', 'save'));
101
-		$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
102
-		return $form;
103
-	}
72
+    /**
73
+     * @public function getForm
74
+     * @param bool $action
75
+     * @return \XoopsThemeForm
76
+     */
77
+    public function getFormRequests($action = false)
78
+    {
79
+        $helper = \XoopsModules\Wggithub\Helper::getInstance();
80
+        if (!$action) {
81
+            $action = $_SERVER['REQUEST_URI'];
82
+        }
83
+        $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid());
84
+        // Title
85
+        $title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_REQUEST_ADD) : \sprintf(\_AM_WGGITHUB_REQUEST_EDIT);
86
+        // Get Theme Form
87
+        \xoops_load('XoopsFormLoader');
88
+        $form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
89
+        $form->setExtra('enctype="multipart/form-data"');
90
+        // Form Text reqRequest
91
+        $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REQUEST_REQUEST, 'req_request', 50, 255, $this->getVar('req_request')), true);
92
+        // Form Text reqResult
93
+        $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REQUEST_RESULT, 'req_result', 50, 255, $this->getVar('req_result')));
94
+        // Form Text Date Select reqDatecreated
95
+        $reqDatecreated = $this->isNew() ?: $this->getVar('req_datecreated');
96
+        $form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_REQUEST_DATECREATED, 'req_datecreated', '', $reqDatecreated));
97
+        // Form Select User reqSubmitter
98
+        $form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_REQUEST_SUBMITTER, 'req_submitter', false, $this->getVar('req_submitter')));
99
+        // To Save
100
+        $form->addElement(new \XoopsFormHidden('op', 'save'));
101
+        $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
102
+        return $form;
103
+    }
104 104
 
105
-	/**
106
-	 * Get Values
107
-	 * @param null $keys
108
-	 * @param null $format
109
-	 * @param null $maxDepth
110
-	 * @return array
111
-	 */
112
-	public function getValuesRequests($keys = null, $format = null, $maxDepth = null)
113
-	{
114
-		$ret = $this->getValues($keys, $format, $maxDepth);
115
-		$ret['id']          = $this->getVar('req_id');
116
-		$ret['request']     = $this->getVar('req_request');
117
-		$ret['result']      = $this->getVar('req_result');
118
-		$ret['datecreated'] = \formatTimestamp($this->getVar('req_datecreated'), 's');
119
-		$ret['submitter']   = \XoopsUser::getUnameFromId($this->getVar('req_submitter'));
120
-		return $ret;
121
-	}
105
+    /**
106
+     * Get Values
107
+     * @param null $keys
108
+     * @param null $format
109
+     * @param null $maxDepth
110
+     * @return array
111
+     */
112
+    public function getValuesRequests($keys = null, $format = null, $maxDepth = null)
113
+    {
114
+        $ret = $this->getValues($keys, $format, $maxDepth);
115
+        $ret['id']          = $this->getVar('req_id');
116
+        $ret['request']     = $this->getVar('req_request');
117
+        $ret['result']      = $this->getVar('req_result');
118
+        $ret['datecreated'] = \formatTimestamp($this->getVar('req_datecreated'), 's');
119
+        $ret['submitter']   = \XoopsUser::getUnameFromId($this->getVar('req_submitter'));
120
+        return $ret;
121
+    }
122 122
 
123
-	/**
124
-	 * Returns an array representation of the object
125
-	 *
126
-	 * @return array
127
-	 */
128
-	public function toArrayRequests()
129
-	{
130
-		$ret = [];
131
-		$vars = $this->getVars();
132
-		foreach (\array_keys($vars) as $var) {
133
-			$ret[$var] = $this->getVar('"{$var}"');
134
-		}
135
-		return $ret;
136
-	}
123
+    /**
124
+     * Returns an array representation of the object
125
+     *
126
+     * @return array
127
+     */
128
+    public function toArrayRequests()
129
+    {
130
+        $ret = [];
131
+        $vars = $this->getVars();
132
+        foreach (\array_keys($vars) as $var) {
133
+            $ret[$var] = $this->getVar('"{$var}"');
134
+        }
135
+        return $ret;
136
+    }
137 137
 }
Please login to merge, or discard this patch.
admin/broken.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -42,22 +42,22 @@
 block discarded – undo
42 42
 $crRepositories->setStart($start);
43 43
 $crRepositories->setLimit($limit);
44 44
 if ($repositoriesCount > 0) {
45
-	$repositoriesAll = $repositoriesHandler->getAll($crRepositories);
46
-	foreach (\array_keys($repositoriesAll) as $i) {
47
-		$repository['table'] = 'Repositories';
48
-		$repository['key'] = 'repo_id';
49
-		$repository['keyval'] = $repositoriesAll[$i]->getVar('repo_id');
50
-		$repository['main'] = $repositoriesAll[$i]->getVar('repo_name');
51
-		$GLOBALS['xoopsTpl']->append('repositories_list', $repository);
52
-	}
53
-	// Display Navigation
54
-	if ($repositoriesCount > $limit) {
55
-		include_once \XOOPS_ROOT_PATH . '/class/pagenav.php';
56
-		$pagenav = new \XoopsPageNav($repositoriesCount, $limit, $start, 'startRepositories', 'op=list&limitRepositories=' . $limit);
57
-		$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
58
-	}
45
+    $repositoriesAll = $repositoriesHandler->getAll($crRepositories);
46
+    foreach (\array_keys($repositoriesAll) as $i) {
47
+        $repository['table'] = 'Repositories';
48
+        $repository['key'] = 'repo_id';
49
+        $repository['keyval'] = $repositoriesAll[$i]->getVar('repo_id');
50
+        $repository['main'] = $repositoriesAll[$i]->getVar('repo_name');
51
+        $GLOBALS['xoopsTpl']->append('repositories_list', $repository);
52
+    }
53
+    // Display Navigation
54
+    if ($repositoriesCount > $limit) {
55
+        include_once \XOOPS_ROOT_PATH . '/class/pagenav.php';
56
+        $pagenav = new \XoopsPageNav($repositoriesCount, $limit, $start, 'startRepositories', 'op=list&limitRepositories=' . $limit);
57
+        $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
58
+    }
59 59
 } else {
60
-	$GLOBALS['xoopsTpl']->assign('nodataRepositories', \sprintf(\_AM_WGGITHUB_BROKEN_NODATA, 'Repositories'));
60
+    $GLOBALS['xoopsTpl']->assign('nodataRepositories', \sprintf(\_AM_WGGITHUB_BROKEN_NODATA, 'Repositories'));
61 61
 }
62 62
 unset($crRepositories);
63 63
 
Please login to merge, or discard this patch.
admin/requests.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -31,106 +31,106 @@
 block discarded – undo
31 31
 // Request req_id
32 32
 $reqId = Request::getInt('req_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_requests.tpl';
41
-		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
42
-		$adminObject->addItemButton(\_AM_WGGITHUB_ADD_REQUEST, 'requests.php?op=new', 'add');
43
-		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
44
-		$requestsCount = $requestsHandler->getCountRequests();
45
-		$requestsAll = $requestsHandler->getAllRequests($start, $limit);
46
-		$GLOBALS['xoopsTpl']->assign('requests_count', $requestsCount);
47
-		$GLOBALS['xoopsTpl']->assign('wggithub_url', WGGITHUB_URL);
48
-		$GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL);
49
-		// Table view requests
50
-		if ($requestsCount > 0) {
51
-			foreach (\array_keys($requestsAll) as $i) {
52
-				$request = $requestsAll[$i]->getValuesRequests();
53
-				$GLOBALS['xoopsTpl']->append('requests_list', $request);
54
-				unset($request);
55
-			}
56
-			// Display Navigation
57
-			if ($requestsCount > $limit) {
58
-				include_once \XOOPS_ROOT_PATH . '/class/pagenav.php';
59
-				$pagenav = new \XoopsPageNav($requestsCount, $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_REQUESTS);
64
-		}
65
-		break;
66
-	case 'new':
67
-		$templateMain = 'wggithub_admin_requests.tpl';
68
-		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
69
-		$adminObject->addItemButton(\_AM_WGGITHUB_REQUESTS_LIST, 'requests.php', 'list');
70
-		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
71
-		// Form Create
72
-		$requestsObj = $requestsHandler->create();
73
-		$form = $requestsObj->getFormRequests();
74
-		$GLOBALS['xoopsTpl']->assign('form', $form->render());
75
-		break;
76
-	case 'save':
77
-		// Security Check
78
-		if (!$GLOBALS['xoopsSecurity']->check()) {
79
-			\redirect_header('requests.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
80
-		}
81
-		if ($reqId > 0) {
82
-			$requestsObj = $requestsHandler->get($reqId);
83
-		} else {
84
-			$requestsObj = $requestsHandler->create();
85
-		}
86
-		// Set Vars
87
-		$requestsObj->setVar('req_request', Request::getString('req_request', ''));
88
-		$requestsObj->setVar('req_result', Request::getString('req_result', ''));
89
-		$requestDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('req_datecreated'));
90
-		$requestsObj->setVar('req_datecreated', $requestDatecreatedObj->getTimestamp());
91
-		$requestsObj->setVar('req_submitter', Request::getInt('req_submitter', 0));
92
-		// Insert Data
93
-		if ($requestsHandler->insert($requestsObj)) {
94
-			\redirect_header('requests.php?op=list', 2, \_AM_WGGITHUB_FORM_OK);
95
-		}
96
-		// Get Form
97
-		$GLOBALS['xoopsTpl']->assign('error', $requestsObj->getHtmlErrors());
98
-		$form = $requestsObj->getFormRequests();
99
-		$GLOBALS['xoopsTpl']->assign('form', $form->render());
100
-		break;
101
-	case 'edit':
102
-		$templateMain = 'wggithub_admin_requests.tpl';
103
-		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
104
-		$adminObject->addItemButton(\_AM_WGGITHUB_ADD_REQUEST, 'requests.php?op=new', 'add');
105
-		$adminObject->addItemButton(\_AM_WGGITHUB_REQUESTS_LIST, 'requests.php', 'list');
106
-		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
107
-		// Get Form
108
-		$requestsObj = $requestsHandler->get($reqId);
109
-		$form = $requestsObj->getFormRequests();
110
-		$GLOBALS['xoopsTpl']->assign('form', $form->render());
111
-		break;
112
-	case 'delete':
113
-		$templateMain = 'wggithub_admin_requests.tpl';
114
-		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
115
-		$requestsObj = $requestsHandler->get($reqId);
116
-		$reqRequest = $requestsObj->getVar('req_request');
117
-		if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
118
-			if (!$GLOBALS['xoopsSecurity']->check()) {
119
-				\redirect_header('requests.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
120
-			}
121
-			if ($requestsHandler->delete($requestsObj)) {
122
-				\redirect_header('requests.php', 3, \_AM_WGGITHUB_FORM_DELETE_OK);
123
-			} else {
124
-				$GLOBALS['xoopsTpl']->assign('error', $requestsObj->getHtmlErrors());
125
-			}
126
-		} else {
127
-			$xoopsconfirm = new Common\XoopsConfirm(
128
-				['ok' => 1, 'req_id' => $reqId, 'op' => 'delete'],
129
-				$_SERVER['REQUEST_URI'],
130
-				\sprintf(\_AM_WGGITHUB_FORM_SURE_DELETE, $requestsObj->getVar('req_request')));
131
-			$form = $xoopsconfirm->getFormXoopsConfirm();
132
-			$GLOBALS['xoopsTpl']->assign('form', $form->render());
133
-		}
134
-		break;
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_requests.tpl';
41
+        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
42
+        $adminObject->addItemButton(\_AM_WGGITHUB_ADD_REQUEST, 'requests.php?op=new', 'add');
43
+        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
44
+        $requestsCount = $requestsHandler->getCountRequests();
45
+        $requestsAll = $requestsHandler->getAllRequests($start, $limit);
46
+        $GLOBALS['xoopsTpl']->assign('requests_count', $requestsCount);
47
+        $GLOBALS['xoopsTpl']->assign('wggithub_url', WGGITHUB_URL);
48
+        $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL);
49
+        // Table view requests
50
+        if ($requestsCount > 0) {
51
+            foreach (\array_keys($requestsAll) as $i) {
52
+                $request = $requestsAll[$i]->getValuesRequests();
53
+                $GLOBALS['xoopsTpl']->append('requests_list', $request);
54
+                unset($request);
55
+            }
56
+            // Display Navigation
57
+            if ($requestsCount > $limit) {
58
+                include_once \XOOPS_ROOT_PATH . '/class/pagenav.php';
59
+                $pagenav = new \XoopsPageNav($requestsCount, $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_REQUESTS);
64
+        }
65
+        break;
66
+    case 'new':
67
+        $templateMain = 'wggithub_admin_requests.tpl';
68
+        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
69
+        $adminObject->addItemButton(\_AM_WGGITHUB_REQUESTS_LIST, 'requests.php', 'list');
70
+        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
71
+        // Form Create
72
+        $requestsObj = $requestsHandler->create();
73
+        $form = $requestsObj->getFormRequests();
74
+        $GLOBALS['xoopsTpl']->assign('form', $form->render());
75
+        break;
76
+    case 'save':
77
+        // Security Check
78
+        if (!$GLOBALS['xoopsSecurity']->check()) {
79
+            \redirect_header('requests.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
80
+        }
81
+        if ($reqId > 0) {
82
+            $requestsObj = $requestsHandler->get($reqId);
83
+        } else {
84
+            $requestsObj = $requestsHandler->create();
85
+        }
86
+        // Set Vars
87
+        $requestsObj->setVar('req_request', Request::getString('req_request', ''));
88
+        $requestsObj->setVar('req_result', Request::getString('req_result', ''));
89
+        $requestDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('req_datecreated'));
90
+        $requestsObj->setVar('req_datecreated', $requestDatecreatedObj->getTimestamp());
91
+        $requestsObj->setVar('req_submitter', Request::getInt('req_submitter', 0));
92
+        // Insert Data
93
+        if ($requestsHandler->insert($requestsObj)) {
94
+            \redirect_header('requests.php?op=list', 2, \_AM_WGGITHUB_FORM_OK);
95
+        }
96
+        // Get Form
97
+        $GLOBALS['xoopsTpl']->assign('error', $requestsObj->getHtmlErrors());
98
+        $form = $requestsObj->getFormRequests();
99
+        $GLOBALS['xoopsTpl']->assign('form', $form->render());
100
+        break;
101
+    case 'edit':
102
+        $templateMain = 'wggithub_admin_requests.tpl';
103
+        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
104
+        $adminObject->addItemButton(\_AM_WGGITHUB_ADD_REQUEST, 'requests.php?op=new', 'add');
105
+        $adminObject->addItemButton(\_AM_WGGITHUB_REQUESTS_LIST, 'requests.php', 'list');
106
+        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
107
+        // Get Form
108
+        $requestsObj = $requestsHandler->get($reqId);
109
+        $form = $requestsObj->getFormRequests();
110
+        $GLOBALS['xoopsTpl']->assign('form', $form->render());
111
+        break;
112
+    case 'delete':
113
+        $templateMain = 'wggithub_admin_requests.tpl';
114
+        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('requests.php'));
115
+        $requestsObj = $requestsHandler->get($reqId);
116
+        $reqRequest = $requestsObj->getVar('req_request');
117
+        if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
118
+            if (!$GLOBALS['xoopsSecurity']->check()) {
119
+                \redirect_header('requests.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
120
+            }
121
+            if ($requestsHandler->delete($requestsObj)) {
122
+                \redirect_header('requests.php', 3, \_AM_WGGITHUB_FORM_DELETE_OK);
123
+            } else {
124
+                $GLOBALS['xoopsTpl']->assign('error', $requestsObj->getHtmlErrors());
125
+            }
126
+        } else {
127
+            $xoopsconfirm = new Common\XoopsConfirm(
128
+                ['ok' => 1, 'req_id' => $reqId, 'op' => 'delete'],
129
+                $_SERVER['REQUEST_URI'],
130
+                \sprintf(\_AM_WGGITHUB_FORM_SURE_DELETE, $requestsObj->getVar('req_request')));
131
+            $form = $xoopsconfirm->getFormXoopsConfirm();
132
+            $GLOBALS['xoopsTpl']->assign('form', $form->render());
133
+        }
134
+        break;
135 135
 }
136 136
 require __DIR__ . '/footer.php';
Please login to merge, or discard this patch.