<?php namespace Phpcmf\Model\Zone;
class Content extends \Phpcmf\Model\Content {
public function _content_post_before($id, $data, $old) {
if ($this->table($this->mytable)->where('id<>'.$id)->where('uid', (int)$data[1]['uid'])->counts()) {
\Phpcmf\Service::C()->_json(0, '一个账号只能创建一个空间');
}
return $data;
}
public function is_guanzhu($uid, $id) {
if (!$uid) {
return 0;
}
return $this->table($this->mytable.'_form_fensi')->where('cid', $id)->where('uid', $uid)->counts();
}
public function get_zone($uid) {
if (!$uid) {
return [];
}
$row = $this->table($this->mytable)->where('uid', $uid)->getRow();
if (!$row) {
return [];
}
$data = $this->table($this->mytable.'_data_'.intval($row['tableid']))->get($row['id']);
$data && $row = $row + $data;
return $row;
}
public function get_zone_id($uid) {
if (!$uid) {
return 0;
}
$row = $this->table($this->mytable)->where('uid', $uid)->getRow();
if (!$row) {
return 0;
}
return $row['id'];
}
}