示例#1
0
 /**
  * @author :majc
  * 判断用户是否收藏
  */
 protected function isCollect()
 {
     $params = array('uid' => $this->uid, 'object_type' => $this->object_type, 'object_id' => $this->object_id);
     $model = new PeopleContact();
     $co = $model->findByAttributes($params);
     if (!empty($co)) {
         return true;
     } else {
         return false;
     }
 }
示例#2
0
 public function actionUserCollect()
 {
     $model = new PeopleContact();
     $object_type = $_POST['object_type'];
     $object_id = $_POST['object_id'];
     $uid = Yii::app()->user->id;
     $op = $_POST['op'];
     $params = array('uid' => $uid, 'object_type' => $_POST['object_type'], 'object_id' => $_POST['object_id']);
     if ($op == 'add') {
         $model->attributes = $params;
         $model->save();
     } elseif ($op == 'delete') {
         $model = $model->findByAttributes($params);
         $model->delete();
     }
 }
示例#3
0
 public function addContact($uid, $object_type, $object_id)
 {
     $isExist = $this->isExist($uid, $object_type, $object_id);
     $params = array('uid' => $uid, 'object_type' => $object_type, 'object_id' => $object_id);
     if ($isExist) {
         //查找存在的记录
         $contact = $this->getContactInfo($uid, $object_type, $object_id);
     } else {
         $contact = new PeopleContact();
     }
     $contact->attributes = $params;
     $contact->save();
     return $contact;
 }