stanley-king преди 7 години
родител
ревизия
b3b6581c82
променени са 5 файла, в които са добавени 67 реда и са изтрити 41 реда
  1. 5 1
      helper/relation_helper.php
  2. 50 11
      helper/search/tcp_client.php
  3. 2 2
      helper/ugc_helper.php
  4. 5 21
      mobile/control/member_ugc.php
  5. 5 6
      test/TestFriends.php

+ 5 - 1
helper/relation_helper.php

@@ -104,7 +104,11 @@ class relation_helper
             }
             $relation = new relation\mem_relation($me_id);
             $ret = $relation->subscribe($someone_id);
-            if($ret == true) {
+            if($ret == true)
+            {
+                $someone_relation = new relation\mem_relation($someone_id);
+                $someone_relation->pass_subscribe();
+
                 $publisher = new message\publisher();
                 $publisher->add_follow($someone_id,[$me_id]);
                 $minfo = new member_info($me_id);

+ 50 - 11
helper/search/tcp_client.php

@@ -300,7 +300,6 @@ class relation_client extends tcp_client
             return $result['data']['invitees'];
         }
     }
-
     /////////////////////////////////////////////////////////////////////////
     public function add_follow($param)
     {
@@ -344,28 +343,68 @@ class relation_client extends tcp_client
     }
     public function add_special($param)
     {
-        $params = array("act" => 'special','op' => 'add', "params" => $param);
-        return $this->request($params);
+        $param = ["act" => 'special','op' => 'add', "params" => $param];
+        $result = $this->request($param);
+        if(empty($result)) return false;
+
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        }
+        else {
+            return true;
+        }
     }
     public function del_special($param)
     {
-        $param = array("act" => 'special','op' => 'del', "params" => $param);
-        return $this->request($param);
+        $param = ["act" => 'special','op' => 'del', "params" => $param];
+        $result = $this->request($param);
+        if(empty($result)) return false;
+
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        }
+        else {
+            return true;
+        }
     }
 
     public function fetch_self_special($param)
     {
-        $param = array("act" => 'special','op' => 'fetch_self', "params" => $param);
-        return $this->request($param);
+        $param = ["act" => 'special','op' => 'fetch_self', "params" => $param];
+        $result = $this->request($param);
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        }
+        else {
+            return $result['data']['specials'];
+        }
     }
+
     public function fetch_pri_special($param)
     {
-        $param = array("act" => 'special','op' => 'fetch_pri', "params" => $param);
-        return $this->request($param);
+        $param = ["act" => 'special','op' => 'fetch_pri', "params" => $param];
+        $result = $this->request($param);
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        }
+        else {
+            return $result['data']['specials'];
+        }
     }
     public function fetch_pub_special($param)
     {
-        $param = array("act" => 'special','op' => 'fetch_pub', "params" => $param);
-        return $this->request($param);
+        $param = ["act" => 'special','op' => 'fetch_pub', "params" => $param];
+        $result = $this->request($param);
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        }
+        else {
+            return $result['data']['specials'];
+        }
     }
 }

+ 2 - 2
helper/ugc_helper.php

@@ -223,8 +223,8 @@ class ugc_helper
     public static function init_server()
     {
         $initer = new ugciniter();
-        $initer->init_fellows();
         $initer->init_special();
+        $initer->init_fellows();
     }
     public static function send_reward()
     {
@@ -319,7 +319,7 @@ class ugciniter
         $special_id  = intval($item['special_id']);
         $reader_type = intval($item['reader_type']);
 
-        if($user_id >0 && $special_id > 0) {
+        if($user_id >0 && $special_id > 0 && $reader_type != ugc_helper::private_self) {
             search\relation_client::instance()->add_special(array('user_id' => $user_id,'specials'=> [['type' => $reader_type,'spid' => $special_id]]));
         }
     }

+ 5 - 21
mobile/control/member_ugc.php

@@ -60,14 +60,14 @@ class member_ugcControl extends specialControl
         }
 
         if($type == "pub_list") {
-            $result = search\relation_client::instance()->fetch_pub_special(['special_id' => $special_id,'count'=> $count,'type' => $direct]);
+            $specials = search\relation_client::instance()->fetch_pub_special(['special_id' => $special_id,'count'=> $count,'type' => $direct]);
         }
         elseif($type == 'pri_list') {
-            $result = search\relation_client::instance()->fetch_pri_special(['user_id' => intval($_SESSION['member_id']),
+            $specials = search\relation_client::instance()->fetch_pri_special(['user_id' => session_helper::memberid(),
                 'special_id' => $special_id,'count'=> $count,'type' => $direct]);
         }
         elseif($type == "mine_list") {
-            $result = $this->mine_specials($special_id,$count);
+            $specials = $this->mine_specials($special_id,$count);
         }
         else {
             return self::outerr(errcode::ErrParamter);
@@ -84,8 +84,7 @@ class member_ugcControl extends specialControl
             }
         }
 
-        $specials = $this->specials($result);
-        if($specials == false)
+        if(empty($specials))
         {
             $page_no = $this->page_no();
             if($page_no == 1) $page_no = 0;
@@ -123,12 +122,9 @@ class member_ugcControl extends specialControl
         }
 
         $result = [];
-        $result['code'] = 200;
-        $result['data'] = [];
-        $result['data']['specials'] = [];
         foreach ($items as $item) {
             $spid = intval($item['special_id']);
-            $result['data']['specials'][] = $spid;
+            $result[] = $spid;
         }
 
         return $result;
@@ -164,19 +160,7 @@ class member_ugcControl extends specialControl
             return self::lesser;
         }
     }
-    private function specials($result)
-    {
-        if(empty($result)) return false;
 
-        $code = intval($result['code']);
-        if($code != 200) {
-            return false;
-        }
-        else {
-            $specials = $result['data']['specials'];
-            return empty($specials) ? false : $specials;
-        }
-    }
     private function special_list($spids, &$ugcs)
     {
         $result = [];

+ 5 - 6
test/TestFriends.php

@@ -90,12 +90,6 @@ class TestFriends extends PHPUnit_Framework_TestCase
         $publisher = new message\publisher();
         $publisher->del_special(36490,array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3]));
     }
-    public function testFetchSelfSpecials()
-    {
-        $result = search\relation_client::instance()->fetch_self_special(['user_id' => 39621,
-            'special_id' => -1,'count'=> 20,'type' => 1]);
-    }
-
     public function testAddInviter()
     {
 //        search\relation_client::instance()->add_inviter(['user_id' => 39638,'inviter_id' => 39623]);
@@ -133,5 +127,10 @@ class TestFriends extends PHPUnit_Framework_TestCase
         $iRelation = new \relation\mem_relation(39623);
         $subscriber = $iRelation->subscriber();
         $follower = $iRelation->follower();
+
+        $inviters = search\relation_client::instance()->fetch_follow(['user_id' => 39623]);
+        $specials = search\relation_client::instance()->fetch_pri_special(['user_id' => 39623,'special_id' => -1,'count'=> 100,'type' => 1]);
+        $specials_follow = search\relation_client::instance()->fetch_self_special(['user_id' => 39646,'special_id' => -1,'count'=> 100,'type' => 1]);
+        $inviters = search\relation_client::instance()->fetch_follow(['user_id' => 39646]);
     }
 }