Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dev.biuro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Biuro
dev.biuro
Commits
5560195a
Commit
5560195a
authored
Apr 29, 2019
by
Skirmantas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
5a46cb9a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
41 deletions
+122
-41
class-biuro-contacts-activator.php
...iuro-contacts/includes/class-biuro-contacts-activator.php
+38
-0
class-biuro-contacts-public.php
...ins/biuro-contacts/public/class-biuro-contacts-public.php
+49
-31
biuro-contacts-public--position--step-2.php
...blic/partials/biuro-contacts-public--position--step-2.php
+23
-10
biuro-contacts-public--position.php
...tacts/public/partials/biuro-contacts-public--position.php
+12
-0
No files found.
wp-content/plugins/biuro-contacts/includes/class-biuro-contacts-activator.php
View file @
5560195a
...
...
@@ -38,6 +38,7 @@ class Biuro_Contacts_Activator {
foreach
(
$blog_ids
as
$blog_id
)
{
switch_to_blog
(
$blog_id
);
self
::
create_db_employees
();
self
::
create_db_employers
();
restore_current_blog
();
}
}
else
{
...
...
@@ -85,5 +86,42 @@ class Biuro_Contacts_Activator {
add_option
(
'biuro-contacts_db_version'
,
$plugin_name_db_version
);
}
}
public
static
function
create_db_employers
()
{
global
$wpdb
;
$table_name
=
$wpdb
->
prefix
.
"biuro_employers"
;
$version
=
get_option
(
'biuro-employers_db_version'
,
'1.0'
);
if
(
$wpdb
->
get_var
(
"show tables like '
{
$table_name
}
'"
)
!=
$table_name
||
version_compare
(
$version
,
'1.0'
)
<
0
)
{
$charset_collate
=
$wpdb
->
get_charset_collate
();
$sql
[]
=
"CREATE TABLE "
.
$table_name
.
" (
id mediumint(9) NOT NULL AUTO_INCREMENT,
created datetime DEFAULT '0000-00-00 00:00:00',
name tinytext,
email varchar(128) DEFAULT '',
phone varchar(128) DEFAULT '',
company varchar(255) DEFAULT null,
message longtext DEFAULT null,
updated datetime DEFAULT '0000-00-00 00:00:00',
confirm tinyint DEFAULT 0,
referer varchar(255) DEFAULT null,
PRIMARY KEY (id)
)
$charset_collate
;"
;
require_once
(
ABSPATH
.
'wp-admin/includes/upgrade.php'
);
/**
* It seems IF NOT EXISTS isn't needed if you're using dbDelta - if the table already exists it'll
* compare the schema and update it instead of overwriting the whole table.
*
* @link https://code.tutsplus.com/tutorials/custom-database-tables-maintaining-the-database--wp-28455
*/
dbDelta
(
$sql
);
add_option
(
'biuro-employers_db_version'
,
$plugin_name_db_version
);
}
}
}
wp-content/plugins/biuro-contacts/public/class-biuro-contacts-public.php
View file @
5560195a
...
...
@@ -112,20 +112,22 @@ class Biuro_Contacts_Public {
}
public
static
function
insert_row_to_db
(
$data
,
$format
)
{
public
static
function
insert_row_to_db
(
$data
,
$format
,
$customName
=
'biuro_employees'
)
{
global
$wpdb
;
$table
=
$wpdb
->
prefix
.
'biuro_employees'
;
$table
=
$wpdb
->
prefix
.
$customName
;
$wpdb
->
insert
(
$table
,
$data
,
$format
);
return
$wpdb
->
insert_id
;
}
public
static
function
update_row_in_db
(
$data
,
$insert_id
,
$format
)
{
public
static
function
update_row_in_db
(
$data
,
$insert_id
,
$format
,
$customName
=
'biuro_employees'
)
{
global
$wpdb
;
$table
=
$wpdb
->
prefix
.
'biuro_employees'
;
$table
=
$wpdb
->
prefix
.
$customName
;
$where
=
array
(
'id'
=>
$insert_id
);
...
...
@@ -213,6 +215,7 @@ class Biuro_Contacts_Public {
case
'message'
:
case
'confirm'
:
case
'job_id'
:
//?case 'company':
return
$empty
;
}
...
...
@@ -227,6 +230,7 @@ class Biuro_Contacts_Public {
case
'name'
:
case
'phone'
:
case
'city'
:
case
'company'
:
return
sanitize_text_field
(
$value
);
case
'email'
:
return
sanitize_email
(
$value
);
...
...
@@ -269,7 +273,9 @@ class Biuro_Contacts_Public {
}
if
(
$canSubmit
)
:
$insert_id
=
static
::
insert_row_to_db
(
$data
,
array
(
'%s'
,
'%s'
,
'%s'
,
'%s'
));
$data
[
'referer'
]
=
(
$_SESSION
[
'referer'
]
!==
null
)
?
$_SESSION
[
'referer'
]
:
null
;
$insert_id
=
static
::
insert_row_to_db
(
$data
,
array
(
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%s'
));
$_SESSION
[
$str
.
'--step'
]
=
2
;
$_SESSION
[
$str
.
'--id'
]
=
$insert_id
;
...
...
@@ -338,8 +344,10 @@ class Biuro_Contacts_Public {
$_SESSION
[
'employee_file_error'
]
=
$movefile
[
'error'
];
}
}
static
::
update_row_in_db
(
$data
,
$_SESSION
[
'employees--id'
],
array
(
'%s'
,
'%d'
,
'%s'
,
'%d'
,
'%s'
,
'%s'
));
$data
[
'referer'
]
=
(
$_SESSION
[
'referer'
]
!==
null
)
?
$_SESSION
[
'referer'
]
:
null
;
static
::
update_row_in_db
(
$data
,
$_SESSION
[
'employees--id'
],
[
'%s'
,
'%d'
,
'%s'
,
'%d'
,
'%s'
,
'%s'
,
'%s'
,
]);
endif
;
...
...
@@ -411,7 +419,10 @@ class Biuro_Contacts_Public {
}
if
(
$canSubmit
)
:
// $insert_id = static::insert_row_to_db($data, array( '%s', '%s', '%s', '%s' ));
$data
[
'referer'
]
=
(
$_SESSION
[
'referer'
]
!==
null
)
?
$_SESSION
[
'referer'
]
:
null
;
$insert_id
=
static
::
insert_row_to_db
(
$data
,
array
(
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%s'
),
'biuro_employers'
);
$_SESSION
[
$str
.
'--step'
]
=
2
;
$_SESSION
[
$str
.
'--id'
]
=
$insert_id
;
...
...
@@ -422,32 +433,22 @@ class Biuro_Contacts_Public {
elseif
(
$_POST
[
's'
]
==
"2"
)
:
$data
=
[
'city'
=>
static
::
getValue
(
'city'
,
$_POST
[
'city'
]),
'city_id'
=>
static
::
getValue
(
'city_id'
,
$_POST
[
'city_id'
]),
'company'
=>
static
::
getValue
(
'city'
,
$_POST
[
'company'
]),
'message'
=>
static
::
getValue
(
'message'
,
$_POST
[
'message'
]),
'confirm'
=>
static
::
getValue
(
'confirm'
,
$_POST
[
'confirm'
]),
'updated'
=>
current_time
(
'Y-m-d H:i:s'
)
];
$data
[
'referer'
]
=
(
$_SESSION
[
'referer'
]
!==
null
)
?
$_SESSION
[
'referer'
]
:
null
;
// # upload file
// if($_FILES) {
// # gali nusirody: 'mimes' => array('csv' => 'text/csv')
// $movefile = wp_handle_upload($_FILES['cv'], [
// 'test_form' => false,
// //'unique_filename_callback' => 'custom_file_name'
// ]);
// if ( $movefile && ! isset( $movefile['error'] ) ) {
// $data['cv'] = static::getValue('cv', $movefile['url']);
// } else {
// $_SESSION['employee_file_error'] = $movefile['error'];
// }
// }
// static::update_row_in_db($data, $_SESSION['employers--id'], array( '%s', '%d', '%s', '%d', '%s', '%s' ));
debug
(
$data
);
exit
();
static
::
update_row_in_db
(
$data
,
$_SESSION
[
'employers--id'
],
[
'%s'
,
'%s'
,
'%d'
,
'%s'
,
'%s'
]
,
'biuro_employers'
);
# isvalom klaidos teksta;
unset
(
$_SESSION
[
$str
.
'file_error'
]);
//debug($data);
//exit();
endif
;
...
...
@@ -500,6 +501,7 @@ class Biuro_Contacts_Public {
if
(
$_POST
[
's'
]
==
"1"
)
:
$_SESSION
[
'position--step'
]
=
2
;
$_SESSION
[
'position--s'
]
=
1
;
elseif
(
$_POST
[
's'
]
==
"2"
)
:
...
...
@@ -547,14 +549,16 @@ class Biuro_Contacts_Public {
$data
[
'cv'
]
=
static
::
getValue
(
'cv'
,
$movefile
[
'url'
]);
}
else
{
$_SESSION
[
'position_file_error'
]
=
$movefile
[
'error'
];
//po klaidos setinimo reikia redirecto?
}
}
$data
[
'referer'
]
=
(
$_SESSION
[
'referer'
]
!==
null
)
?
$_SESSION
[
'referer'
]
:
null
;
$insert_id
=
static
::
insert_row_to_db
(
$data
,
array
(
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%d'
,
'%s'
,
'%d'
,
'%d'
,
'%s'
));
$insert_id
=
static
::
insert_row_to_db
(
$data
,
array
(
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%s'
,
'%d'
,
'%s'
,
'%d'
,
'%d'
,
'%s'
,
'%s'
));
$_SESSION
[
'employee--id'
]
=
$insert_id
;
$_SESSION
[
'position--s'
]
=
2
;
endif
;
...
...
@@ -591,4 +595,18 @@ class Biuro_Contacts_Public {
where "
.
$orderBy
.
" >= '"
.
$from
.
"' ORDER BY "
.
$orderBy
.
" DESC LIMIT 50"
;
return
$wpdb
->
get_results
(
$sql
,
ARRAY_A
);
}
public
static
function
fetchRow
(
$primaryKey
,
$table
=
'biuro_employees'
)
{
global
$wpdb
;
if
(
!
is_numeric
(
$primaryKey
))
{
exit
;
}
$sql
=
"SELECT * FROM `"
.
$wpdb
->
prefix
.
$table
.
"`
where id = "
.
$primaryKey
.
" LIMIT 1"
;
return
$wpdb
->
get_row
(
$sql
,
ARRAY_A
);
}
}
wp-content/plugins/biuro-contacts/public/partials/biuro-contacts-public--position--step-2.php
View file @
5560195a
...
...
@@ -21,9 +21,30 @@ if ( ! defined( 'WPINC' ) ) die;
?>
<?php
# sitie po submito;
$nameValue
=
$_SESSION
[
'position--name-value'
];
$nameStatus
=
$_SESSION
[
'position--name-status'
];
$nameMessage
=
$_SESSION
[
'position--name-message'
];
$phoneValue
=
$_SESSION
[
'position--phone-value'
];
$phoneStatus
=
$_SESSION
[
'position--phone-status'
];
$phoneMessage
=
$_SESSION
[
'position--phone-message'
];
$emailValue
=
$_SESSION
[
'position--email-value'
];
$emailStatus
=
$_SESSION
[
'position--email-status'
];
$emailMessage
=
$_SESSION
[
'position--email-message'
];
if
(
is_numeric
(
$_SESSION
[
'employees--id'
])
&&
$_SESSION
[
'position--s'
]
===
1
)
{
$employeeData
=
Biuro_Contacts_Public
::
fetchRow
(
$_SESSION
[
'employees--id'
]);
$nameValue
=
$employeeData
[
'name'
];
$phoneValue
=
$employeeData
[
'phone'
];
$emailValue
=
$employeeData
[
'email'
];
$city
=
$employeeData
[
'city'
];
# city reiks uzdet turbut?
}
?>
<div
class=
"c-form--row"
>
<label
class=
"c-form--label"
for=
"form-name"
>
<?php
_e
(
'Name, surname'
,
'biuro-contacts'
);
?>
</label>
...
...
@@ -37,11 +58,7 @@ if ( ! defined( 'WPINC' ) ) die;
<?php
endif
;
?>
</div>
<!-- .c-form--row -->
<?php
$phoneValue
=
$_SESSION
[
'position--phone-value'
];
$phoneStatus
=
$_SESSION
[
'position--phone-status'
];
$phoneMessage
=
$_SESSION
[
'position--phone-message'
];
?>
<div
class=
"c-form--row"
>
<label
class=
"c-form--label"
for=
"form-phone"
>
<?php
_e
(
'Phone no.'
,
'biuro-contacts'
);
?>
</label>
<div
class=
"c-form--input-wrap
<?php
if
(
$phoneStatus
)
{
echo
"c-form--input-wrap--
$phoneStatus
"
;
}
?>
"
>
...
...
@@ -54,11 +71,7 @@ if ( ! defined( 'WPINC' ) ) die;
<?php
endif
;
?>
</div>
<!-- .c-form--row -->
<?php
$emailValue
=
$_SESSION
[
'position--email-value'
];
$emailStatus
=
$_SESSION
[
'position--email-status'
];
$emailMessage
=
$_SESSION
[
'position--email-message'
];
?>
<div
class=
"c-form--row"
>
<label
class=
"c-form--label"
for=
"form-email"
>
<?php
_e
(
'Email address'
,
'biuro-contacts'
);
?>
</label>
<div
class=
"c-form--input-wrap
<?php
if
(
$emailStatus
)
{
echo
"c-form--input-wrap--
$emailStatus
"
;
}
?>
"
>
...
...
wp-content/plugins/biuro-contacts/public/partials/biuro-contacts-public--position.php
View file @
5560195a
...
...
@@ -34,3 +34,15 @@ if ( ! defined( 'WPINC' ) ) die;
<input
type=
"hidden"
name=
"action"
value=
"position_post"
>
<?php
wp_nonce_field
(
'position_post_nonce'
);
?>
</form>
<?php
if
(
$_SESSION
[
'position--s'
]
==
1
)
{
?>
ok 1
<?php
unset
(
$_SESSION
[
'position--s'
]);
}
?>
<?php
if
(
$_SESSION
[
'position--s'
]
==
2
)
{
?>
ok 2
<?php
unset
(
$_SESSION
[
'position--s'
]);
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment