First commit
This commit is contained in:
142
source/include/collection/collection_comment.php
Normal file
142
source/include/collection/collection_comment.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: collection_comment.php 33715 2013-08-07 01:59:25Z andyzheng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
if(empty($_G['uid'])) {
|
||||
showmessage('login_before_enter_home', null, array(), array('showmsg' => true, 'login' => 1));
|
||||
}
|
||||
|
||||
$oplist = array('add', 'del', 'pop', 'recommend');
|
||||
if(!in_array($op, $oplist)) {
|
||||
$op = '';
|
||||
}
|
||||
|
||||
if(empty($op) || $op == 'add') {
|
||||
$_GET['handlekey'] = 'addComment';
|
||||
if(!$ctid) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
|
||||
if(!$_G['group']['allowcommentcollection']) {
|
||||
showmessage('collection_comment_closed');
|
||||
}
|
||||
|
||||
require_once libfile('function/spacecp');
|
||||
|
||||
|
||||
if(!$_G['collection']['ctid']) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
|
||||
$waittime = interval_check('post');
|
||||
if($waittime > 0) {
|
||||
showmessage('operating_too_fast', '', array('waittime' => $waittime), array('return' => true));
|
||||
}
|
||||
|
||||
$memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
|
||||
|
||||
if(!trim($_GET['message']) && ((!$memberrate && !$_GET['ratescore']) || $memberrate)) {
|
||||
showmessage('collection_edit_checkentire');
|
||||
}
|
||||
|
||||
if($_G['setting']['maxpostsize'] && strlen($_GET['message']) > $_G['setting']['maxpostsize']) {
|
||||
showmessage('post_message_toolong', '', array('maxpostsize' => $_G['setting']['maxpostsize']));
|
||||
}
|
||||
|
||||
$newcomment = array(
|
||||
'ctid' => $_G['collection']['ctid'],
|
||||
'uid' => $_G['uid'],
|
||||
'username' => $_G['username'],
|
||||
'message' => dhtmlspecialchars(censor($_GET['message'])),
|
||||
'dateline' => $_G['timestamp'],
|
||||
'useip' => $_G['clientip'],
|
||||
'port' => $_G['remoteport']
|
||||
);
|
||||
|
||||
if(!$memberrate) {
|
||||
$newcomment['rate'] = $_GET['ratescore'];
|
||||
} else {
|
||||
$_GET['ratescore'] = 0;
|
||||
}
|
||||
|
||||
C::t('forum_collectioncomment')->insert($newcomment);
|
||||
C::t('forum_collection')->update_by_ctid($_G['collection']['ctid'], 0, 0, 1, 0, $_GET['ratescore'], $_G['collection']['ratenum']);
|
||||
|
||||
if($_G['collection']['uid'] != $_G['uid']) {
|
||||
notification_add($_G['collection']['uid'], "system", 'collection_becommented', array('from_id'=>$_G['collection']['ctid'], 'from_idtype'=>'collectioncomment', 'ctid'=>$_G['collection']['ctid'], 'collectionname'=>$_G['collection']['name']), 1);
|
||||
}
|
||||
|
||||
C::t('common_member_status')->update($_G['uid'], array('lastpost' => TIMESTAMP), 'UNBUFFERED');
|
||||
|
||||
showmessage('collection_comment_succ', $tid ? 'forum.php?mod=viewthread&tid='.$tid : dreferer());
|
||||
} elseif($op == 'del') {
|
||||
if(!submitcheck('formhash')) {
|
||||
showmessage('undefined_action', NULL);
|
||||
} else {
|
||||
if(!$_G['collection']['ctid'] || !checkcollectionperm($_G['collection'], $_G['uid']) || empty($_GET['delcomment']) || !is_array($_GET['delcomment']) || count($_GET['delcomment']) == 0) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
$delrows = C::t('forum_collectioncomment')->delete_by_cid_ctid($_GET['delcomment'], $_G['collection']['ctid']);
|
||||
C::t('forum_collection')->update_by_ctid($_G['collection']['ctid'], 0, 0, -$delrows);
|
||||
|
||||
showmessage('collection_comment_remove_succ', 'forum.php?mod=collection&action=view&op=comment&ctid='.$ctid);
|
||||
}
|
||||
} elseif($op == 'pop') {
|
||||
$collectionthread = C::t('forum_collectionthread')->fetch_by_ctid_tid($ctid, $tid);
|
||||
if(!$collectionthread['ctid']) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
$thread = C::t('forum_thread')->fetch_thread($tid);
|
||||
|
||||
include template('forum/collection_commentpop');
|
||||
} elseif($op == 'recommend') {
|
||||
if(!$_G['collection']['ctid']) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
if(!submitcheck('formhash')) {
|
||||
include template('forum/collection_recommend');
|
||||
} else {
|
||||
if(!$_GET['threadurl']) {
|
||||
showmessage('collection_recommend_url', '', array(), array('alert'=> 'error', 'closetime' => true, 'showdialog' => 1));
|
||||
}
|
||||
|
||||
$touid = &$_G['collection']['uid'];
|
||||
$coef = 1;
|
||||
|
||||
$subject = $message = lang('message', 'collection_recommend_message', array('fromuser' => $_G['username'], 'collectioname' => $_G['collection']['name'], 'url' => $_GET['threadurl']));
|
||||
if(C::t('home_blacklist')->count_by_uid_buid($touid, $_G['uid'])) {
|
||||
showmessage('is_blacklist', '', array(), array('return' => true));
|
||||
}
|
||||
if(($value = getuserbyuid($touid))) {
|
||||
require_once libfile('function/friend');
|
||||
$value['onlyacceptfriendpm'] = $value['onlyacceptfriendpm'] ? $value['onlyacceptfriendpm'] : ($_G['setting']['onlyacceptfriendpm'] ? 1 : 2);
|
||||
if($_G['group']['allowsendallpm'] || $value['onlyacceptfriendpm'] == 2 || ($value['onlyacceptfriendpm'] == 1 && friend_check($touid))) {
|
||||
$return = sendpm($touid, $subject, $message, '', 0, 0);
|
||||
} else {
|
||||
showmessage('message_can_not_send_onlyfriend', '', array(), array('return' => true));
|
||||
}
|
||||
} else {
|
||||
showmessage('message_bad_touid', '', array(), array('return' => true));
|
||||
}
|
||||
|
||||
if($return > 0) {
|
||||
include_once libfile('function/stat');
|
||||
updatestat('sendpm', 0, $coef);
|
||||
|
||||
C::t('common_member_status')->update($_G['uid'], array('lastpost' => TIMESTAMP), 'UNBUFFERED');
|
||||
!($_G['group']['exempt'] & 1) && updatecreditbyaction('sendpm', 0, array(), '', $coef);
|
||||
showmessage('collection_recommend_succ', '', array(), array('alert'=> 'right', 'closetime' => true, 'showdialog' => 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
412
source/include/collection/collection_edit.php
Normal file
412
source/include/collection/collection_edit.php
Normal file
@@ -0,0 +1,412 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: collection_edit.php 33065 2013-04-16 10:06:07Z chenmengshu $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
$titlelimit = 30;
|
||||
$desclimit = 250;
|
||||
$reasonlimit = 250;
|
||||
|
||||
$oplist = array('add', 'edit', 'remove', 'addthread', 'delthread', 'acceptinvite', 'removeworker', 'invite');
|
||||
if(!in_array($op, $oplist)) {
|
||||
$op = '';
|
||||
}
|
||||
|
||||
if(empty($_G['uid'])) {
|
||||
showmessage('login_before_enter_home', null, array(), array('showmsg' => true, 'login' => 1));
|
||||
}
|
||||
|
||||
if(empty($op) || $op == 'add') {
|
||||
if(!helper_access::check_module('collection')) {
|
||||
showmessage('quickclear_noperm');
|
||||
}
|
||||
$_GET['handlekey'] = 'createcollection';
|
||||
|
||||
$navtitle = lang('core', 'title_collection_create');
|
||||
|
||||
$createdcollectionnum = C::t('forum_collection')->count_by_uid($_G['uid']);
|
||||
$reamincreatenum = $_G['group']['allowcreatecollection']-$createdcollectionnum;
|
||||
if(!$_G['group']['allowcreatecollection'] || $reamincreatenum <= 0) {
|
||||
showmessage('collection_create_exceed_limit');
|
||||
}
|
||||
if(!$_GET['submitcollection']) {
|
||||
|
||||
include template('forum/collection_add');
|
||||
|
||||
} else {
|
||||
if(!submitcheck('collectionsubmit')) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
if(!$_GET['title']) {
|
||||
showmessage('collection_edit_checkentire');
|
||||
}
|
||||
|
||||
$newCollectionTitle = censor(dhtmlspecialchars($_GET['title']));
|
||||
$newCollectionTitle = cutstr($newCollectionTitle, $titlelimit, '');
|
||||
|
||||
$newcollection = array(
|
||||
'name' => $newCollectionTitle,
|
||||
'uid' => $_G['uid'],
|
||||
'username' => $_G['username'],
|
||||
'desc' => dhtmlspecialchars(cutstr(censor($_GET['desc']), $desclimit, '')),
|
||||
'dateline' => $_G['timestamp'],
|
||||
'lastupdate' => $_G['timestamp'],
|
||||
'lastvisit' => $_G['timestamp'],
|
||||
'keyword' => parse_keyword($_GET['keyword'], true)
|
||||
);
|
||||
|
||||
$newctid = C::t('forum_collection')->insert($newcollection, true);
|
||||
|
||||
if($newctid) {
|
||||
showmessage('collection_create_succ', 'forum.php?mod=collection&action=view&ctid='.$newctid, array('ctid'=>$newctid, 'title'=>$newCollectionTitle), array('closetime' => '2', 'showmsg' => ($_GET['inajax'] ? '0' : '1')));
|
||||
}
|
||||
}
|
||||
|
||||
} elseif($op == 'edit') {
|
||||
$navtitle = lang('core', 'title_collection_edit');
|
||||
|
||||
if(!$ctid) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
|
||||
if(!$_G['collection']['ctid'] || !checkcollectionperm($_G['collection'], $_G['uid'])) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
|
||||
if(!submitcheck('collectionsubmit')) {
|
||||
|
||||
include template('forum/collection_add');
|
||||
|
||||
} else {
|
||||
if(!$_GET['title']) {
|
||||
showmessage('collection_edit_checkentire');
|
||||
}
|
||||
if($_GET['formhash'] != FORMHASH) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
|
||||
$newCollectionTitle = censor(dhtmlspecialchars($_GET['title']));
|
||||
$newCollectionTitle = cutstr($newCollectionTitle, 30, '');
|
||||
|
||||
$newcollection = array(
|
||||
'name' => $newCollectionTitle,
|
||||
'desc' => dhtmlspecialchars(cutstr(censor($_GET['desc']), $desclimit, '')),
|
||||
'keyword' => parse_keyword($_GET['keyword'], true)
|
||||
);
|
||||
|
||||
C::t('forum_collection')->update($ctid, $newcollection);
|
||||
|
||||
if($_GET['title'] != $_G['collection']['name']) {
|
||||
C::t('forum_collectionteamworker')->update_by_ctid($ctid, $_GET['title']);
|
||||
}
|
||||
|
||||
showmessage('collection_edit_succ', 'forum.php?mod=collection&action=view&ctid='.$ctid);
|
||||
}
|
||||
} elseif($op == 'remove') {
|
||||
if($_GET['formhash'] != FORMHASH) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
if($_G['collection'] && checkcollectionperm($_G['collection'], $_G['uid'])) {
|
||||
require_once libfile('function/delete');
|
||||
|
||||
deletecollection($_G['collection']['ctid']);
|
||||
|
||||
showmessage('collection_delete_succ', 'forum.php?mod=collection&op=my');
|
||||
} else {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
|
||||
} elseif($op == 'addthread') {
|
||||
if((!$_G['forum_thread'] || !$_G['forum']) && !is_array($_GET['tids'])) {
|
||||
showmessage('thread_nonexistence');
|
||||
}
|
||||
|
||||
if(!is_array($_GET['tids']) && $_G['forum']['disablecollect']) {
|
||||
showmessage('collection_forum_deny', '', array(), array('showdialog' => 1));
|
||||
}
|
||||
|
||||
if(!submitcheck('addthread')) {
|
||||
$createdcollectionnum = C::t('forum_collection')->count_by_uid($_G['uid']);
|
||||
$reamincreatenum = $_G['group']['allowcreatecollection']-$createdcollectionnum;
|
||||
|
||||
$collections = getmycollection($_G['uid']);
|
||||
$tidcollections = array();
|
||||
|
||||
if(count($collections) > 0) {
|
||||
$tidrelated = C::t('forum_collectionrelated')->fetch($tid, true);
|
||||
$tidcollections = explode("\t", $tidrelated['collection']);
|
||||
}
|
||||
$allowcollections = array_diff(array_keys($collections), $tidcollections);
|
||||
if($reamincreatenum <= 0 && count($allowcollections) <= 0) {
|
||||
showmessage('collection_none_avail_collection', '', array(), array('showdialog' => 1));
|
||||
}
|
||||
|
||||
include template('forum/collection_select');
|
||||
|
||||
} else {
|
||||
if(!$ctid) {
|
||||
showmessage('collection_no_selected', '', array(), array('showdialog' => 1));
|
||||
}
|
||||
if(!is_array($_GET['tids'])) {
|
||||
$tid = $_G['tid'];
|
||||
$thread[$tid] = &$_G['thread'];
|
||||
}
|
||||
$collectiondata = C::t('forum_collection')->fetch_all($ctid);
|
||||
if(!is_array($collectiondata) || count($collectiondata) < 0) {
|
||||
showmessage('undefined_action', NULL);
|
||||
} else {
|
||||
foreach ($collectiondata as $curcollectiondata) {
|
||||
if(!$curcollectiondata['ctid']) {
|
||||
showmessage('collection_permission_deny', '', array(), array('showdialog' => 1));
|
||||
}
|
||||
|
||||
if(!checkcollectionperm($curcollectiondata, $_G['uid'], true)) {
|
||||
showmessage('collection_non_creator', '', array(), array('showdialog' => 1));
|
||||
}
|
||||
|
||||
if(!is_array($_GET['tids'])) {
|
||||
$checkexistctid[$tid] = C::t('forum_collectionthread')->fetch_by_ctid_tid($curcollectiondata['ctid'], $thread[$tid]['tid']);
|
||||
if($checkexistctid[$tid]['ctid']) {
|
||||
showmessage('collection_thread_exists', '', array(), array('showdialog' => 1));
|
||||
}
|
||||
|
||||
$tids[0] = $tid;
|
||||
$checkexist[$tid] = C::t('forum_collectionrelated')->fetch($tid, true);
|
||||
} else {
|
||||
$thread = C::t('forum_thread')->fetch_all($_GET['tids']);
|
||||
foreach ($thread as $perthread) {
|
||||
$fids[$perthread['fid']] = $perthread['fid'];
|
||||
}
|
||||
$fids = array_keys($fids);
|
||||
$foruminfo = C::t('forum_forumfield')->fetch_all($fids);
|
||||
$tids = array_keys($thread);
|
||||
$checkexistctid = C::t('forum_collectionthread')->fetch_all_by_ctid_tid($curcollectiondata['ctid'], $tids);
|
||||
$checkexist = C::t('forum_collectionrelated')->fetch_all($tids, true);
|
||||
}
|
||||
|
||||
$addsum = 0;
|
||||
foreach ($tids as $curtid) {
|
||||
$thread_fid = $thread[$curtid]['fid'];
|
||||
if(!$checkexistctid[$curtid]['ctid'] && !$foruminfo[$thread_fid]['disablecollect']) {
|
||||
$newthread = array(
|
||||
'ctid' => $curcollectiondata['ctid'],
|
||||
'tid' => $thread[$curtid]['tid'],
|
||||
'dateline' => $thread[$curtid]['dateline'],
|
||||
'reason' => cutstr(censor(dhtmlspecialchars($_GET['reason'])), $reasonlimit, '')
|
||||
);
|
||||
|
||||
C::t('forum_collectionthread')->insert($newthread);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$checkexist[$curtid]) {
|
||||
C::t('forum_collectionrelated')->insert(array('tid'=>$curtid, 'collection'=>$curcollectiondata['ctid']."\t"));
|
||||
$checkexist[$curtid] = 1;
|
||||
} else {
|
||||
C::t('forum_collectionrelated')->update_collection_by_ctid_tid($curcollectiondata['ctid'], $curtid);
|
||||
}
|
||||
if(!getstatus($thread[$curtid]['status'], 9)) {
|
||||
C::t('forum_thread')->update_status_by_tid($curtid, '256');
|
||||
}
|
||||
|
||||
if($_G['uid'] != $thread[$curtid]['authorid']) {
|
||||
notification_add($thread[$curtid]['authorid'], "system", 'collection_becollected', array('from_id'=>$_G['collection']['ctid'], 'from_idtype'=>'collectionthread', 'ctid'=>$_G['collection']['ctid'], 'collectionname'=>$_G['collection']['name'], 'tid'=>$curtid, 'threadname'=>$thread[$curtid]['subject']), 1);
|
||||
}
|
||||
|
||||
$addsum++;
|
||||
}
|
||||
|
||||
if($addsum > 0) {
|
||||
$lastpost = array(
|
||||
'lastpost' => $thread[$tids[0]]['tid'],
|
||||
'lastsubject' => $thread[$tids[0]]['subject'],
|
||||
'lastposttime' => $thread[$tids[0]]['dateline'],
|
||||
'lastposter' => $thread[$tids[0]]['author']
|
||||
);
|
||||
C::t('forum_collection')->update_by_ctid($curcollectiondata['ctid'], $addsum, 0, 0, $_G['timestamp'], 0, 0, $lastpost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showmessage('collection_collect_succ', dreferer(), array(), array('alert'=> 'right', 'closetime' => true, 'locationtime' => true, 'showdialog' => 1));
|
||||
}
|
||||
|
||||
} elseif($op == 'delthread') {
|
||||
if($_GET['formhash'] != FORMHASH) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
if(!$ctid || empty($_GET['delthread']) || !is_array($_GET['delthread']) || count($_GET['delthread']) == 0) {
|
||||
showmessage('collection_no_thread');
|
||||
}
|
||||
|
||||
if(!$_G['collection']['ctid'] || !checkcollectionperm($_G['collection'], $_G['uid'])) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
require_once libfile('function/delete');
|
||||
deleterelatedtid($_GET['delthread'], $_G['collection']['ctid']);
|
||||
$decthread = C::t('forum_collectionthread')->delete_by_ctid_tid($ctid, $_GET['delthread']);
|
||||
|
||||
$lastpost = null;
|
||||
if(in_array($_G['collection']['lastpost'], $_GET['delthread']) && ($_G['collection']['threadnum'] - $decthread) > 0) {
|
||||
$collection_thread = C::t('forum_collectionthread')->fetch_by_ctid_dateline($ctid);
|
||||
if($collection_thread) {
|
||||
$thread = C::t('forum_thread')->fetch_thread($collection_thread['tid']);
|
||||
$lastpost = array(
|
||||
'lastpost' => $thread['tid'],
|
||||
'lastsubject' => $thread['subject'],
|
||||
'lastposttime' => $thread['dateline'],
|
||||
'lastposter' => $thread['authorid']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
C::t('forum_collection')->update_by_ctid($ctid, -$decthread, 0, 0, 0, 0, 0, $lastpost);
|
||||
|
||||
showmessage('collection_remove_thread', 'forum.php?mod=collection&action=view&ctid='.$ctid);
|
||||
} elseif($op == 'invite') {
|
||||
if(!$ctid) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
|
||||
if(!$_G['collection']['ctid'] || !checkcollectionperm($_G['collection'], $_G['uid'])) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
|
||||
$collectionteamworker = C::t('forum_collectionteamworker')->fetch_all_by_ctid($ctid);
|
||||
|
||||
$submitworkers = (!empty($_GET['users']) && is_array($_GET['users'])) ? count($_GET['users']) : 0;
|
||||
|
||||
if((count($collectionteamworker) + $submitworkers) >= $maxteamworkers) {
|
||||
showmessage('collection_teamworkers_exceed');
|
||||
}
|
||||
|
||||
require_once libfile('function/friend');
|
||||
|
||||
if($_GET['username'] && !$_GET['users']) {
|
||||
$_GET['users'][] = $_GET['username'];
|
||||
}
|
||||
|
||||
if(!$_GET['users']) {
|
||||
|
||||
if($_POST['formhash']) {
|
||||
showmessage('collection_teamworkers_noselect', NULL);
|
||||
}
|
||||
|
||||
$friends = array();
|
||||
if($space['friendnum']) {
|
||||
$query = C::t('home_friend')->fetch_all_by_uid($_G['uid'], 0, 100, true);
|
||||
foreach($query as $value) {
|
||||
$value['uid'] = $value['fuid'];
|
||||
$value['username'] = daddslashes($value['fusername']);
|
||||
$friends[] = $value;
|
||||
}
|
||||
}
|
||||
$friendgrouplist = friend_group_list();
|
||||
|
||||
include template('forum/collection_invite');
|
||||
} else {
|
||||
$invitememberuids = array();
|
||||
if(is_array($_GET['users'])) {
|
||||
$invitememberuids = C::t('common_member')->fetch_all_uid_by_username($_GET['users']);
|
||||
}
|
||||
|
||||
if(!$invitememberuids) {
|
||||
showmessage('collection_no_teamworkers');
|
||||
}
|
||||
|
||||
if(!friend_check($invitememberuids) || in_array($_G['uid'], $invitememberuids)) {
|
||||
showmessage('collection_non_friend');
|
||||
}
|
||||
|
||||
$collectionteamworker = array_keys($collectionteamworker);
|
||||
|
||||
if(in_array($invitememberuids, $collectionteamworker)) {
|
||||
showmessage('collection_teamworkers_exists');
|
||||
}
|
||||
|
||||
foreach($invitememberuids as $invitememberuid) {
|
||||
$data = array('ctid'=>$ctid,'uid'=>$invitememberuid,'dateline'=>$_G['timestamp']);
|
||||
|
||||
C::t('forum_collectioninvite')->insert($data, false, true);
|
||||
|
||||
notification_add($invitememberuid, "system", 'invite_collection', array('ctid'=>$_G['collection']['ctid'], 'collectionname'=>$_G['collection']['name'], 'dateline'=>$_G['timestamp']), 1);
|
||||
}
|
||||
|
||||
showmessage('collection_invite_succ', 'forum.php?mod=collection&action=view&ctid='.$ctid, array(), array('alert'=> 'right', 'closetime' => true, 'showdialog' => 1));
|
||||
}
|
||||
} elseif($op == 'acceptinvite') {
|
||||
if(!submitcheck('ctid', 1)) {
|
||||
showmessage('undefined_action', NULL);
|
||||
} else {
|
||||
$collectioninvite = C::t('forum_collectioninvite')->fetch_by_ctid_uid($ctid, $_G['uid']);
|
||||
if(!$collectioninvite['ctid'] || $_GET['dateline'] != $collectioninvite['dateline']) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
|
||||
$teamworkernum = C::t('forum_collectionteamworker')->count_by_ctid($ctid);
|
||||
if($teamworkernum >= $maxteamworkers) {
|
||||
showmessage('collection_teamworkers_exceed');
|
||||
}
|
||||
|
||||
C::t('forum_collectioninvite')->delete_by_ctid_uid($ctid, $_G['uid']);
|
||||
|
||||
$newworker = array(
|
||||
'ctid'=>$ctid,
|
||||
'uid'=>$_G['uid'],
|
||||
'name'=>$_G['collection']['name'],
|
||||
'username'=>$_G['username'],
|
||||
'lastvisit' => $_G['timestamp']
|
||||
);
|
||||
|
||||
C::t('forum_collectionteamworker')->insert($newworker, false, true);
|
||||
|
||||
showmessage('collection_invite_accept', 'forum.php?mod=collection&action=view&ctid='.$ctid);
|
||||
}
|
||||
} elseif($op == 'removeworker') {
|
||||
if(!submitcheck('ctid', 1)) {
|
||||
showmessage('undefined_action', NULL);
|
||||
} else {
|
||||
if($_GET['formhash'] != FORMHASH) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
|
||||
if(!$_G['collection']['ctid']) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
if($_GET['uid'] != $_G['uid']) {
|
||||
if($_G['collection']['uid'] != $_G['uid']) {
|
||||
showmessage('collection_remove_deny');
|
||||
}
|
||||
$removeuid = $_GET['uid'];
|
||||
} else {
|
||||
$removeuid = $_G['uid'];
|
||||
}
|
||||
|
||||
$collectionteamworker = array_keys(C::t('forum_collectionteamworker')->fetch_all_by_ctid($ctid));
|
||||
|
||||
if(!in_array($removeuid, $collectionteamworker)) {
|
||||
showmessage('collection_teamworkers_nonexists');
|
||||
}
|
||||
|
||||
C::t('forum_collectionteamworker')->delete_by_ctid_uid($ctid, $removeuid);
|
||||
|
||||
notification_add($removeuid, "system", 'exit_collection', array('ctid'=>$_G['collection']['ctid'], 'collectionname'=>$_G['collection']['name']), 1);
|
||||
|
||||
if($_GET['inajax']) {
|
||||
showmessage('', dreferer(), array(), array('msgtype' => 3, 'showmsg' => 1));
|
||||
} else {
|
||||
showmessage('collection_teamworkers_exit_succ', 'forum.php?mod=collection&action=view&ctid='.$ctid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
59
source/include/collection/collection_follow.php
Normal file
59
source/include/collection/collection_follow.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: collection_follow.php 25246 2011-11-02 03:34:53Z zhangguosheng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
if(!$op || !$ctid || $_GET['formhash'] != FORMHASH) {
|
||||
showmessage('undefined_action', NULL);
|
||||
}
|
||||
|
||||
if(!$_G['collection']['ctid'] || $_G['collection']['uid'] == $_G['uid']) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
$_GET['handlekey'] = 'followcollection';
|
||||
if($op == 'follow') {
|
||||
$follownum = C::t('forum_collectionfollow')->count_by_uid($_G['uid']);
|
||||
if($follownum >= $_G['group']['allowfollowcollection']) {
|
||||
showmessage('collection_follow_limited', '', array('limit' => $_G['group']['allowfollowcollection']), array('closetime' => '2', 'showmsg' => '1'));
|
||||
}
|
||||
|
||||
$collectionfollow = C::t('forum_collectionfollow')->fetch_by_ctid_uid($ctid, $_G['uid']);
|
||||
if(!$collectionfollow['ctid']) {
|
||||
$data = array(
|
||||
'uid' => $_G['uid'],
|
||||
'username' => $_G['username'],
|
||||
'ctid' => $ctid,
|
||||
'dateline' => $_G['timestamp'],
|
||||
'lastvisit' => $_G['timestamp']
|
||||
);
|
||||
|
||||
C::t('forum_collectionfollow')->insert($data);
|
||||
C::t('forum_collection')->update_by_ctid($ctid, 0, 1, 0);
|
||||
|
||||
if($_G['collection']['uid'] != $_G['uid']) {
|
||||
updatecreditbyaction('followedcollection', $_G['collection']['uid']);
|
||||
notification_add($_G['collection']['uid'], "system", 'collection_befollowed', array('from_id'=>$_G['collection']['ctid'], 'from_idtype'=>'collectionfollow', 'ctid'=>$_G['collection']['ctid'], 'collectionname'=>$_G['collection']['name']), 1);
|
||||
}
|
||||
|
||||
showmessage('collection_follow_succ', dreferer(), array('status'=>1), array('closetime' => '2', 'showmsg' => '1'));
|
||||
}
|
||||
|
||||
|
||||
} elseif($op == 'unfo') {
|
||||
$collectionfollow = C::t('forum_collectionfollow')->fetch_by_ctid_uid($ctid, $_G['uid']);
|
||||
if($collectionfollow['ctid']) {
|
||||
C::t('forum_collectionfollow')->delete_by_ctid_uid($ctid, $_G['uid']);
|
||||
C::t('forum_collection')->update_by_ctid($ctid, 0, -1, 0);
|
||||
showmessage('collection_unfollow_succ', dreferer(), array('status'=>2), array('closetime' => '2', 'showmsg' => '1'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
104
source/include/collection/collection_index.php
Normal file
104
source/include/collection/collection_index.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: collection_index.php 33200 2013-05-06 12:27:49Z laoguozhang $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
$navtitle = lang('core', 'title_collection');
|
||||
$searchtitle = '';
|
||||
$oplist = array('all', 'my', 'search');
|
||||
if(!in_array($op, $oplist)) {
|
||||
$op = '';
|
||||
}
|
||||
|
||||
$cpp = 20;
|
||||
$start = ($page-1)*$cpp;
|
||||
|
||||
if($op == 'all' || $op == 'search') {
|
||||
if($op == 'search' && $_GET['kw']) {
|
||||
dheader('Location: search.php?mod=collection&searchsubmit=yes&srchtxt='.urlencode($_GET['kw']));
|
||||
exit;
|
||||
} else {
|
||||
$orderbyarr = array('follownum', 'threadnum', 'commentnum', 'dateline');
|
||||
$count = C::t('forum_collection')->count();
|
||||
}
|
||||
|
||||
$orderby = (in_array($_GET['order'], $orderbyarr)) ? $_GET['order'] : 'dateline';
|
||||
$collectiondata = processCollectionData(C::t('forum_collection')->fetch_all('', $orderby, 'DESC', $start, $cpp, $searchtitle), array(), $orderby);
|
||||
$htmlsearchtitle = dhtmlspecialchars($searchtitle);
|
||||
$multipage = multi($count, $cpp, $page, 'forum.php?mod=collection&order='.$orderby.'&op='.$op.(($htmlsearchtitle) ? '&kw='.$htmlsearchtitle : ''));
|
||||
|
||||
include template('forum/collection_all');
|
||||
} elseif ($op == 'my') {
|
||||
$mycollection = C::t('forum_collection')->fetch_all_by_uid($_G['uid']);
|
||||
$myctid = array_keys($mycollection);
|
||||
$teamworker = C::t('forum_collectionteamworker')->fetch_all_by_uid($_G['uid']);
|
||||
$twctid = array_keys($teamworker);
|
||||
$follow = C::t('forum_collectionfollow')->fetch_all_by_uid($_G['uid']);
|
||||
if(empty($follow)) {
|
||||
$follow = array();
|
||||
}
|
||||
$followctid = array_keys($follow);
|
||||
|
||||
if(!$myctid) {
|
||||
$myctid = array();
|
||||
}
|
||||
if(!$twctid) {
|
||||
$twctid = array();
|
||||
}
|
||||
if(!$followctid) {
|
||||
$followctid = array();
|
||||
}
|
||||
|
||||
$ctidlist = array_merge($myctid, $twctid, $followctid);
|
||||
|
||||
if(count($ctidlist) > 0) {
|
||||
$tfcollection = $mycollection + $teamworker + $follow;
|
||||
$collectiondata = C::t('forum_collection')->fetch_all($ctidlist, 'dateline', 'DESC');
|
||||
$collectiondata = processCollectionData($collectiondata, $tfcollection);
|
||||
}
|
||||
|
||||
include template('forum/collection_mycollection');
|
||||
} else {
|
||||
if(!$tid) {
|
||||
$collectiondata = array();
|
||||
loadcache('collection');
|
||||
|
||||
if(TIMESTAMP - $_G['cache']['collection']['dateline'] > 300) {
|
||||
$collection = getHotCollection(500, false);
|
||||
$collectioncache = array('dateline' => TIMESTAMP, 'data' => $collection);
|
||||
savecache('collection', $collectioncache);
|
||||
} else {
|
||||
$collection = &$_G['cache']['collection']['data'];
|
||||
}
|
||||
$count = count($collection);
|
||||
for($i = $start; $i < $start+$cpp; $i++) {
|
||||
if(!$collection[$i]) {
|
||||
continue;
|
||||
}
|
||||
$collectiondata[] = $collection[$i];
|
||||
}
|
||||
unset($collection);
|
||||
$collectiondata = processCollectionData($collectiondata);
|
||||
} else {
|
||||
$tidrelate = C::t('forum_collectionrelated')->fetch($tid);
|
||||
$ctids = explode("\t", $tidrelate['collection'], -1);
|
||||
$count = count($ctids);
|
||||
$collectiondata = C::t('forum_collection')->fetch_all($ctids, 'follownum', 'DESC', $start, $cpp);
|
||||
$collectiondata = processCollectionData($collectiondata);
|
||||
}
|
||||
|
||||
$multipage = multi($count, $cpp, $page, 'forum.php?mod=collection'.($tid ? '&tid='.$tid : ''));
|
||||
|
||||
include template('forum/collection_index');
|
||||
}
|
||||
|
||||
|
||||
?>
|
125
source/include/collection/collection_view.php
Normal file
125
source/include/collection/collection_view.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: collection_view.php 33065 2013-04-16 10:06:07Z chenmengshu $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
$oplist = array('comment', 'followers', 'related');
|
||||
if(!in_array($op, $oplist)) {
|
||||
$op = '';
|
||||
}
|
||||
$fromoplist = array('my', 'all');
|
||||
$fromop = (!in_array($_GET['fromop'], $fromoplist)) ? '' : $_GET['fromop'];
|
||||
$fromtid = dintval($_GET['fromtid']);
|
||||
$tids = $fids = array();
|
||||
|
||||
if(!$_G['collection']['ctid']) {
|
||||
showmessage('collection_permission_deny');
|
||||
}
|
||||
|
||||
$navtitle = $_G['collection']['name'].' - '.lang('core', 'title_collection');
|
||||
|
||||
$permission = checkcollectionperm($_G['collection'], $_G['uid']);
|
||||
$avgrate = number_format($_G['collection']['rate'], 1);
|
||||
|
||||
$start = ($page-1)*$tpp;
|
||||
|
||||
$collectionfollowdata = C::t('forum_collectionfollow')->fetch_by_ctid_uid($ctid, $_G['uid']);
|
||||
$collectionteamworker = C::t('forum_collectionteamworker')->fetch_all_by_ctid($_G['collection']['ctid']);
|
||||
|
||||
$_G['collection']['arraykeyword'] = parse_keyword($_G['collection']['keyword'], false, false);
|
||||
if($_G['collection']['arraykeyword']) {
|
||||
foreach ($_G['collection']['arraykeyword'] as $kid=>$s_keyword) {
|
||||
$metakeywords .= ($metakeywords ? ',' : '').$s_keyword;
|
||||
$_G['collection']['urlkeyword'][$kid] = rawurlencode($s_keyword);
|
||||
}
|
||||
}
|
||||
$metadescription = $_G['collection']['name'];
|
||||
|
||||
if($_G['collection']['ratenum']) {
|
||||
$star = imgdisplayrate($avgrate);
|
||||
}
|
||||
|
||||
if(!$op || $op == 'related') {
|
||||
$isteamworkers = in_array($_G['uid'], array_keys($collectionteamworker));
|
||||
|
||||
$search_status = FALSE;
|
||||
require_once libfile('function/friend');
|
||||
$friendgrouplist = friend_group_list();
|
||||
|
||||
if(!$op && $op != 'related') {
|
||||
if($_G['collection']['uid'] == $_G['uid']) {
|
||||
$lastvisit = $_G['collection']['lastvisit'];
|
||||
if($_G['collection']['lastupdate'] >= $lastvisit) {
|
||||
C::t('forum_collection')->update($ctid, array('lastvisit' => TIMESTAMP), true, true);
|
||||
}
|
||||
} elseif($isteamworkers) {
|
||||
$lastvisit = $collectionteamworker[$_G['uid']]['lastvisit'];
|
||||
if($_G['collection']['lastupdate'] >= $lastvisit) {
|
||||
C::t('forum_collectionteamworker')->update_teamworker($ctid, $_G['uid'], array('lastvisit' => TIMESTAMP), true, true);
|
||||
}
|
||||
} elseif($collectionfollowdata['ctid']) {
|
||||
$lastvisit = $collectionfollowdata['lastvisit'];
|
||||
if($_G['collection']['lastupdate'] >= $lastvisit) {
|
||||
C::t('forum_collectionfollow')->update_collectionfollow($ctid, $_G['uid'], array('lastvisit' => TIMESTAMP), true, true);
|
||||
}
|
||||
} else {
|
||||
$lastvisit = null;
|
||||
}
|
||||
|
||||
$collectiontids = C::t('forum_collectionthread')->fetch_all_by_ctid($_G['collection']['ctid'], $start, $tpp);
|
||||
$tids = array_keys($collectiontids);
|
||||
$threadlist = C::t('forum_thread')->fetch_all_by_tid($tids);
|
||||
collectionThread($threadlist, false, $lastvisit, $collectiontids);
|
||||
|
||||
$multipage = multi($_G['collection']['threadnum'], $tpp, $page, "forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}");
|
||||
|
||||
$userCollections = C::t('forum_collection')->fetch_all_by_uid($_G['collection']['uid'], 0, 5, $_G['collection']['ctid']);
|
||||
}
|
||||
|
||||
if($_G['collection']['commentnum'] > 0) {
|
||||
$commentlist = C::t('forum_collectioncomment')->fetch_all_by_ctid($_G['collection']['ctid'], 0, 5);
|
||||
foreach($commentlist as &$curvalue) {
|
||||
$curvalue['dateline'] = dgmdate($curvalue['dateline'], 'u', '9999', getglobal('setting/dateformat'));
|
||||
$curvalue['message'] = cutstr($curvalue['message'], 150);
|
||||
$curvalue['rateimg'] = imgdisplayrate($curvalue['rate']);
|
||||
}
|
||||
|
||||
$memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
|
||||
}
|
||||
$followers = C::t('forum_collectionfollow')->fetch_all_collectionfollow($ctid, true, 0, 6);
|
||||
|
||||
include template('forum/collection_view');
|
||||
} elseif($op == 'comment') {
|
||||
$navtitle = lang('core', 'title_collection_comment_list').' - '.$navtitle;
|
||||
if($_G['collection']['commentnum'] > 0) {
|
||||
$start = ($page-1)*$_G['setting']['postperpage'];
|
||||
|
||||
$commentlist = C::t('forum_collectioncomment')->fetch_all_by_ctid($_G['collection']['ctid'], $start, $_G['setting']['postperpage']);
|
||||
foreach($commentlist as &$curvalue) {
|
||||
$curvalue['dateline'] = dgmdate($curvalue['dateline'], 'u', '9999', getglobal('setting/dateformat'));
|
||||
$curvalue['rateimg'] = imgdisplayrate($curvalue['rate']);
|
||||
}
|
||||
|
||||
$multipage = multi($_G['collection']['commentnum'], $_G['setting']['postperpage'], $page, "forum.php?mod=collection&action=view&op=comment&ctid={$_G['collection']['ctid']}");
|
||||
|
||||
$memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
|
||||
}
|
||||
include template('forum/collection_comment');
|
||||
} elseif($op == 'followers') {
|
||||
$navtitle = lang('core', 'title_collection_followers_list').' - '.$navtitle;
|
||||
$cmemberperpage = 28;
|
||||
$start = ($page-1)*$cmemberperpage;
|
||||
$followers = C::t('forum_collectionfollow')->fetch_all_collectionfollow($ctid, true, $start, $cmemberperpage);
|
||||
$multipage = multi($_G['collection']['follownum'], $cmemberperpage, $page, "forum.php?mod=collection&action=view&op=followers&ctid={$_G['collection']['ctid']}");
|
||||
|
||||
include template('forum/collection_followers');
|
||||
}
|
||||
?>
|
0
source/include/collection/index.htm
Normal file
0
source/include/collection/index.htm
Normal file
Reference in New Issue
Block a user