|
@@ -10,7 +10,7 @@ class Api
|
|
|
|
|
|
public function code($uid)
|
|
|
{
|
|
|
- $info = Dever::db('invite/code')->one(array('uid' => $uid));
|
|
|
+ $info = Dever::db('invite/code')->one(array('uid' => $uid, 'clear' => true));
|
|
|
if ($info) {
|
|
|
return $info['value'];
|
|
|
} else {
|
|
@@ -22,12 +22,12 @@ class Api
|
|
|
|
|
|
private function createCode($uid, $code)
|
|
|
{
|
|
|
- $info = Dever::db('invite/code')->one(array('value' => $code));
|
|
|
+ $info = Dever::db('invite/code')->one(array('value' => $code, 'clear' => true));
|
|
|
if ($info) {
|
|
|
$code = Dever::rand(5, 0);
|
|
|
return $this->createCode($uid, $code);
|
|
|
} else {
|
|
|
- Dever::db('invite/code')->insert(array('value' => $code, 'uid' => $uid));
|
|
|
+ Dever::db('invite/code')->insert(array('value' => $code, 'uid' => $uid, 'clear' => true));
|
|
|
return $code;
|
|
|
}
|
|
|
}
|
|
@@ -35,7 +35,7 @@ class Api
|
|
|
|
|
|
public function getUid($code)
|
|
|
{
|
|
|
- $info = Dever::db('invite/code')->one(array('value' => $code));
|
|
|
+ $info = Dever::db('invite/code')->one(array('value' => $code, 'clear' => true));
|
|
|
if ($info) {
|
|
|
return $info['uid'];
|
|
|
}
|
|
@@ -142,4 +142,22 @@ class Api
|
|
|
|
|
|
return $source_uid;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public function getRelation($uid, $parent_uid)
|
|
|
+ {
|
|
|
+ $data['uid'] = $parent_uid;
|
|
|
+ $data['to_uid'] = $uid;
|
|
|
+
|
|
|
+ $info = Dever::db('invite/relation')->one($data);
|
|
|
+ if ($info) {
|
|
|
+ $where['level'] = $info['level'] - 1;
|
|
|
+ $where['to_uid'] = $uid;
|
|
|
+ $info = Dever::db('invite/relation')->one($where);
|
|
|
+ if ($info) {
|
|
|
+ return $info['uid'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|