Skip to content

Commit 01aff8e

Browse files
committed
Add HungNG_CI_Base_Custom_Model_Credentials_model
1 parent f5d73c5 commit 01aff8e

24 files changed

+210
-12
lines changed

composer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"classmap": [
3232
"hungng/",
3333
"lib/",
34+
"custom/",
3435
"hooks/"
3536
],
3637
"psr-4": {
@@ -39,5 +40,19 @@
3940
"files": [
4041
"helpers/codeigniter_modular.php"
4142
]
43+
},
44+
"suggest": {
45+
"nguyenanhung/helpers": "Awesome Helpers - Powerful Library, Helpers and Tools",
46+
"nguyenanhung/security": "Awesome Helpers - Wrapper for Security, Encrypt, Encode, Purifier",
47+
"nguyenanhung/validation": "Awesome Validation - A fast, extensible & stand-alone PHP input validation class that allows you to validate any data",
48+
"nguyenanhung/image": "Need support for Image Service",
49+
"nguyenanhung/seo": "Need support for SEO",
50+
"nguyenanhung/my-cache": "Need support for Powerful Cache Implement",
51+
"nguyenanhung/my-debug": "Need support for Powerful Logger (Extend from Monolog)",
52+
"nguyenanhung/requests": "Need support for Powerful HTTP Request",
53+
"nguyenanhung/database": "Need support for Powerful SQL Database Tools (Customize Laravel Database)",
54+
"nguyenanhung/monitor": "Need support for Send Monitor Message to Monitor Service",
55+
"nguyenanhung/markdown": "Parser for Markdown",
56+
"nguyenanhung/basic-firewall": "PHP Basic Firewall - Library providing IP filtering features"
4257
}
4358
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
3+
/**
4+
* Project codeigniter-framework
5+
* Created by PhpStorm
6+
* User: 713uk13m <dev@nguyenanhung.com>
7+
* Copyright: 713uk13m <dev@nguyenanhung.com>
8+
* Date: 11/02/2023
9+
* Time: 19:25
10+
*/
11+
if (!class_exists('HungNG_Basic_Custom_Model_Credentials_model')) {
12+
/**
13+
* Class HungNG_CI_Base_Custom_Model_Credentials_model
14+
*
15+
* @author 713uk13m <dev@nguyenanhung.com>
16+
* @copyright 713uk13m <dev@nguyenanhung.com>
17+
*
18+
* @property CI_DB_pdo_driver|CI_DB_mysqli_driver|CI_DB_query_builder|CI_DB_driver $db This is the platform-independent base Query Builder implementation class
19+
*/
20+
class HungNG_CI_Base_Custom_Model_Credentials_model extends HungNG_Custom_Based_model
21+
{
22+
const IS_ACTIVE = 1;
23+
const ROLE_PUSH = 1;
24+
const ROLE_PULL = 2;
25+
const ROLE_FULL = 3;
26+
27+
protected $fieldUsername;
28+
protected $fieldStatus;
29+
protected $fieldRole;
30+
31+
/**
32+
* HungNG_Basic_Custom_Credentials_model constructor.
33+
*
34+
* @author : 713uk13m <dev@nguyenanhung.com>
35+
* @copyright: 713uk13m <dev@nguyenanhung.com>
36+
*/
37+
public function __construct()
38+
{
39+
parent::__construct();
40+
$this->db = $this->load->database('default', true, true);
41+
$this->tableName = 'credentials';
42+
$this->primary_key = 'id';
43+
$this->fieldUsername = 'username';
44+
$this->fieldStatus = 'status';
45+
$this->fieldRole = 'role';
46+
}
47+
48+
/**
49+
* Function checkCredentials
50+
*
51+
* @param string $username
52+
*
53+
* @return int
54+
* @author : 713uk13m <dev@nguyenanhung.com>
55+
* @copyright: 713uk13m <dev@nguyenanhung.com>
56+
* @time : 09/03/2021 35:51
57+
*/
58+
public function checkCredentials($username = '')
59+
{
60+
$this->db->select($this->primary_key);
61+
$this->db->from($this->tableName);
62+
$this->db->where($this->fieldUsername, $username);
63+
$this->db->where($this->fieldStatus, self::IS_ACTIVE);
64+
return $this->db->count_all_results();
65+
}
66+
67+
/**
68+
* Function getInfoCredentials
69+
*
70+
* @param string $username
71+
*
72+
* @return array|mixed|object|null
73+
* @author : 713uk13m <dev@nguyenanhung.com>
74+
* @copyright: 713uk13m <dev@nguyenanhung.com>
75+
* @time : 09/03/2021 40:35
76+
*/
77+
public function getInfoCredentials($username = '')
78+
{
79+
$this->db->select();
80+
$this->db->from($this->tableName);
81+
$this->db->where($this->fieldUsername, $username);
82+
$this->db->where($this->fieldStatus, self::IS_ACTIVE);
83+
$info = $this->db->get()->row();
84+
if (empty($info)) {
85+
return null;
86+
}
87+
88+
return $info;
89+
}
90+
91+
/**
92+
* Function checkUserRoleIsFull
93+
*
94+
* @param string $username
95+
*
96+
* @return bool
97+
* @author : 713uk13m <dev@nguyenanhung.com>
98+
* @copyright: 713uk13m <dev@nguyenanhung.com>
99+
* @time : 09/03/2021 41:52
100+
*/
101+
public function checkUserRoleIsFull($username = '')
102+
{
103+
$this->db->select($this->primary_key);
104+
$this->db->from($this->tableName);
105+
$this->db->where($this->fieldUsername, $username);
106+
$this->db->where($this->fieldStatus, self::IS_ACTIVE);
107+
$this->db->where($this->fieldRole, self::ROLE_FULL);
108+
$result = $this->db->count_all_results();
109+
if ($result) {
110+
return true;
111+
}
112+
113+
return false;
114+
}
115+
116+
/**
117+
* Function checkUserRoleIsPull
118+
*
119+
* @param string $username
120+
*
121+
* @return bool
122+
* @author : 713uk13m <dev@nguyenanhung.com>
123+
* @copyright: 713uk13m <dev@nguyenanhung.com>
124+
* @time : 09/03/2021 42:35
125+
*/
126+
public function checkUserRoleIsPull($username = '')
127+
{
128+
$this->db->select($this->primary_key);
129+
$this->db->from($this->tableName);
130+
$this->db->where($this->fieldUsername, $username);
131+
$this->db->where($this->fieldStatus, self::IS_ACTIVE);
132+
$this->db->where_in($this->fieldRole, array(self::ROLE_FULL, self::ROLE_PULL));
133+
$result = $this->db->count_all_results();
134+
if ($result) {
135+
return true;
136+
}
137+
138+
return false;
139+
}
140+
141+
/**
142+
* Function checkUserRoleIsPush
143+
*
144+
* @param string $username
145+
*
146+
* @return bool
147+
* @author : 713uk13m <dev@nguyenanhung.com>
148+
* @copyright: 713uk13m <dev@nguyenanhung.com>
149+
* @time : 09/03/2021 42:58
150+
*/
151+
public function checkUserRoleIsPush($username = '')
152+
{
153+
$this->db->select($this->primary_key);
154+
$this->db->from($this->tableName);
155+
$this->db->where($this->fieldUsername, $username);
156+
$this->db->where($this->fieldStatus, self::IS_ACTIVE);
157+
$this->db->where_in($this->fieldRole, array(self::ROLE_FULL, self::ROLE_PUSH));
158+
$result = $this->db->count_all_results();
159+
if ($result) {
160+
return true;
161+
}
162+
163+
return false;
164+
}
165+
}
166+
}

custom/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 1 vài đoạn code custom được dùng và kế thừa ở nhiều dự án

hungng/BEAR_Lang.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
23
if (!class_exists('BEAR_Lang')) {
34
class BEAR_Lang extends HungNG_Lang
45
{

hungng/BEAR_Loader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
23
if (!class_exists('BEAR_Loader')) {
34
class BEAR_Loader extends HungNG_Loader
45
{

hungng/BEAR_Model.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
23
if (!class_exists('BEAR_Model')) {
34
class BEAR_Model extends HungNG_Model
45
{

hungng/BEAR_Router.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
23
if (!class_exists('BEAR_Router')) {
34
class BEAR_Router extends HungNG_Router
45
{

hungng/HungNG_CI_Base_Controllers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
23
/**
34
* Project codeigniter-framework
45
* Created by PhpStorm

hungng/HungNG_CI_Base_Lib_ElasticSearch.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
23
/**
34
* Project codeigniter-framework
45
* Created by PhpStorm

hungng/HungNG_CI_Base_Lib_Hmvc_Migration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
23
/**
34
* Project codeigniter-framework
45
* Created by PhpStorm

0 commit comments

Comments
 (0)