|
@@ -12,7 +12,7 @@ class Share extends Base
|
|
|
*
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function submit_api()
|
|
|
+ public function submit()
|
|
|
{
|
|
|
$this->check_user();
|
|
|
$source_table = Dever::input('type');
|
|
@@ -20,17 +20,28 @@ class Share extends Base
|
|
|
$uid = Dever::input('uid');
|
|
|
$content = Dever::input('content');
|
|
|
|
|
|
- $insert['add_source_table'] = $source_table;
|
|
|
- $insert['add_source_id'] = $source_id;
|
|
|
- $insert['add_uid'] = $uid;
|
|
|
- $insert['add_info_id'] = $this->data['info']['id'];
|
|
|
- $insert['add_key'] = $this->session($uid);
|
|
|
- $insert['add_content'] = $content;
|
|
|
+ $key = $this->session($uid . '_' . $source_table . '_' . $source_id);
|
|
|
+ $info = Dever::load('comment/share-one', array('option_source_table' => $source_table, 'option_source_id' => $source_id, 'option_uid' => $uid, 'option_key' => $key));
|
|
|
|
|
|
- $id = Dever::load('comment/share-insert', $insert);
|
|
|
+ if (!$info) {
|
|
|
+ $insert['add_source_table'] = $source_table;
|
|
|
+ $insert['add_source_id'] = $source_id;
|
|
|
+ $insert['add_uid'] = $uid;
|
|
|
+ $insert['add_info_id'] = $this->data['info']['id'];
|
|
|
+ $insert['add_key'] = $key;
|
|
|
+ $insert['add_content'] = $content;
|
|
|
+
|
|
|
+ $id = Dever::load('comment/share-insert', $insert);
|
|
|
+ } else {
|
|
|
+ $id = $info['id'];
|
|
|
+ $update['set_cdate'] = time();
|
|
|
+ $update['where_id'] = $id;
|
|
|
+ Dever::load('comment/share-update', $update);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
$result['share_uid'] = $uid;
|
|
|
- $result['share_key'] = $insert['add_key'];
|
|
|
+ $result['share_key'] = $key;
|
|
|
$result['share_id'] = $id;
|
|
|
|
|
|
return $result;
|
|
@@ -41,11 +52,11 @@ class Share extends Base
|
|
|
*
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function reflux_api()
|
|
|
+ public function reflux()
|
|
|
{
|
|
|
$this->check_user();
|
|
|
$source_uid = Dever::input('share_uid');
|
|
|
- $key = Dever::input('key');
|
|
|
+ $key = Dever::input('share_key');
|
|
|
$id = Dever::input('share_id');
|
|
|
$uid = Dever::input('uid');
|
|
|
|
|
@@ -57,7 +68,7 @@ class Share extends Base
|
|
|
$insert['add_source_uid'] = $source_uid;
|
|
|
$insert['add_uid'] = $uid;
|
|
|
$insert['add_info_id'] = $this->data['info']['id'];
|
|
|
- if ($source_uid != $uid && $this->check_session($source_uid)) {
|
|
|
+ if ($source_uid != $uid && $this->check_session($source_uid . '_' . $info['source_table'] . '_' . $info['source_id'], $key)) {
|
|
|
Dever::load('comment/share_reflux-insert', $insert);
|
|
|
}
|
|
|
}
|