How to make a Post and Comment is active without the approval of a superadmin
- Administrator
- Post, Comment, Aouth
- 935 Kali Dilihat
- 0 Komentar
Auto Active and Comment Post Member
Auto Active and Comment Post Member yang dimaksudkan dalam artikel ini adalah, bahwa setiap post yang di tulis dan di publikasikan oleh member melalui dashboard member akan otomatis aktif dan diberi ijin untuk dapat di beri komentar oleh pengunjung atau pembaca. Bagi anda para pengguna PopojiCms, tentu anda tahu bahwa secara default setiap post yang ditulis oleh member harus melalui persetujuan superadmin untuk aktif dan ijin komentar. Pada sebagian pengguna menginginkan sebaliknya, yaitu bahwa setiap post yang di tulis dan di publikasikan oleh member melalui dashboard member akan otomatis aktif dan diberi ijin untuk dapat di beri komentar oleh pengunjung atau pembaca.
Berikut adalah cara bagaimana agar setiap post yang di tulis dan di publikasikan oleh member melalui dashboard member akan otomatis aktif dan diberi ijin untuk dapat di beri komentar oleh pengunjung atau pembaca tanpa harus melalui persetujuan superadmin.
Cara Agar Setiap Post yang di tulis oleh member Langsung Aktif
Silahkan buka file post.php
yang berada pada root_dir/po-content/component/post/post.php
dan silahkan gulir kebawah pada Router untuk menampilkan request halaman member tambah post. Pada bagian tersebut terdapat script berikut:
$data = array(
'seotitle' => $seotitle,
'tag' => $core->postring->valid($_POST['tag'], 'xss'),
'picture_description' => $_POST['picture_description'],
'date' => $_POST['publishdate'],
'time' => $_POST['publishtime'],
'publishdate' => $_POST['publishdate']." ".$_POST['publishtime'],
'editor' => $_SESSION['iduser_member'],
'comment' => 'N',
'active' => 'N'
);
Silahkan Rubah array pada baris 2064 dan 2065 menjadi:
$data = array(
'seotitle' => $seotitle,
'tag' => $core->postring->valid($_POST['tag'], 'xss'),
'picture_description' => $_POST['picture_description'],
'date' => $_POST['publishdate'],
'time' => $_POST['publishtime'],
'publishdate' => $_POST['publishdate']." ".$_POST['publishtime'],
'editor' => $_SESSION['iduser_member'],
'comment' => 'Y', // 'N' rename to 'Y'
'active' => 'Y' // 'N' rename to 'Y'
);
Sehingga Router untuk menampilkan request halaman member tambah post secara keseluruhan menjadi seperti berikut:
/**
* Router untuk menampilkan request halaman member tambah post.
*
* Router for display request in member add post page.
*
*/
$router->match('GET|POST', '/member/post/addnew', function() use ($core, $templates) {
if ($core->posetting[17]['value'] == 'Y') {
if (empty($_SESSION['namauser_member']) AND empty($_SESSION['passuser_member']) AND empty($_SESSION['login_member'])) {
header('location:'.BASE_URL.'/member/login');
} else {
$alertmsg = '';
$lang = $core->setlang('post', WEB_LANG);
if (!empty($_POST)) {
if (!$core->auth($_SESSION['leveluser_member'], 'post', 'create')) {
header('location:'.BASE_URL.'/404.php');
} else {
if ($_POST['seotitle'] != "") {
$seotitle = $_POST['seotitle'];
} else {
$seotitle = $core->postring->seo_title($core->postring->valid($_POST['post'][1]['title'], 'xss'));
}
$data = array(
'seotitle' => $seotitle,
'tag' => $core->postring->valid($_POST['tag'], 'xss'),
'picture_description' => $_POST['picture_description'],
'date' => $_POST['publishdate'],
'time' => $_POST['publishtime'],
'publishdate' => $_POST['publishdate']." ".$_POST['publishtime'],
'editor' => $_SESSION['iduser_member'],
'comment' => 'Y',
'active' => 'Y'
);
if(!empty($_FILES['picture']['tmp_name'])){
$picture_name_exp = explode('.', $_FILES['picture']['name']);
$picture_name = $core->postring->seo_title($picture_name_exp[0]);
$file_exists = DIR_CON.'/uploads/'.$picture_name.'.jpg';
if (file_exists($file_exists)){
$datapic = array(
'picture' => $picture_name.'.jpg'
);
} else {
$upload = new PoUpload($_FILES['picture']);
if ($upload->uploaded) {
$upload->file_new_name_body = $picture_name;
$upload->image_convert = 'jpg';
$upload->image_resize = true;
$upload->image_x = 900;
$upload->image_y = 600;
$upload->image_ratio = true;
$upload->process(DIR_CON.'/uploads/');
if ($upload->processed) {
$datapic = array(
'picture' => $upload->file_dst_name
);
$upload_medium = new PoUpload($_FILES['picture']);
if ($upload_medium->uploaded) {
$upload_medium->file_new_name_body = 'medium_'.$picture_name;
$upload_medium->image_convert = 'jpg';
$upload_medium->image_resize = true;
$upload_medium->image_x = 640;
$upload_medium->image_y = 426;
$upload_medium->image_ratio = true;
$upload_medium->process(DIR_CON.'/uploads/medium/');
if ($upload_medium->processed) {
$upload_thumb = new PoUpload($_FILES['picture']);
if ($upload_thumb->uploaded) {
$upload_thumb->file_new_name_body = $picture_name;
$upload_thumb->image_convert = 'jpg';
$upload_thumb->image_resize = true;
$upload_thumb->image_x = 122;
$upload_thumb->image_y = 91;
$upload_thumb->image_ratio = true;
$upload_thumb->process(DIR_CON.'/thumbs/');
if ($upload_thumb->processed) {
$upload_thumb->clean();
$upload_medium->clean();
$upload->clean();
}
}
}
}
} else {
$datapic = array();
}
}
}
} else {
$datapic = array();
}
$datafinal = array_merge($data, $datapic);
$query_post = $core->podb->insertInto('post')->values($datafinal);
$query_post->execute();
$expl = explode(",", $core->postring->valid($_POST['tag'], 'xss'));
$total = count($expl);
for($i=0; $i<$total; $i++){
$last_tag = $core->podb->from('tag')
->where('tag_seo', $expl[$i])
->limit(1)
->fetch();
$query_tag = $core->podb->update('tag')
->set(array('count' => $last_tag['count']+1))
->where('tag_seo', $expl[$i]);
$query_tag->execute();
}
$last_post = $core->podb->from('post')
->orderBy('id_post DESC')
->limit(1)
->fetch();
$id_categorys = $_POST['id_category'];
if (!empty($_POST['id_category'])) {
foreach($id_categorys as $id_category){
$category = array(
'id_post' => $last_post['id_post'],
'id_category' => $id_category,
);
$query_category = $core->podb->insertInto('post_category')->values($category);
$query_category->execute();
}
}
foreach ($_POST['post'] as $id_language => $value) {
$post_description = array(
'id_post' => $last_post['id_post'],
'id_language' => $id_language,
'title' => $core->postring->valid($value['title'], 'xss'),
'content' => stripslashes(htmlspecialchars($value['content'],ENT_QUOTES))
);
$query_post_description = $core->podb->insertInto('post_description')->values($post_description);
$query_post_description->execute();
}
unset($_POST);
header('location:'.BASE_URL.'/member/post');
}
}
$info = array(
'page_title' => $lang['front_member_addpost'].' - Member Area',
'alertmsg' => $alertmsg
);
$adddata = array_merge($info, $lang);
$templates->addData(
$adddata
);
echo $templates->render('addpost', compact('lang'));
}
} else {
header('location:'.BASE_URL.'/404.php');
}
});
Dengan demikian maka setiap post yang ditulis member akan langsung aktif tanpa harus menunggu persetujuan superadministrator.
Selamat mencoba........