private function split_attr(array $attr = null, $only_split = false) { $attr = $attr ? $attr : $this->attributes; $callback = Utils::array_pick($attr, self::$FIELDS_CALLBACK); $ios = Utils::array_pick($attr, self::$FIELDS_IOS); $channel = Utils::array_pick($attr, self::$FIELDS_CHANNEL); $diy = Utils::array_pick($attr, self::$FIELDS_DIY); $permissions = $attr['permission']; $provinces = $attr['provinces'] ? $attr['provinces'] : $attr['put_provinces']; if (!$only_split) { $me = $_SESSION['id']; $im_cp = $_SESSION['role'] == Auth::$CP_PERMISSION; $now = date('Y-m-d H:i:s'); $callback['ad_id'] = $channel['id'] = $ios['ad_id'] = $diy['id'] = $this->id; $attr['status'] = 2; // 新建,待审核 $attr['ad_sdk_type'] = 1; // 只允许广告墙 $attr['create_user'] = $me; $attr['create_time'] = $now; if ($im_cp) { $channel['feedback'] = 7; $channel['cycle'] = 1; $attr['ad_app_type'] = 2; $attr['cate'] = 1; } else { $admin = new Admin(); $channel = array_merge($channel, $admin->get_owner($attr, $me)); } if ($attr['replace']) { $this->replace = $attr['replace-with']; $attr['status'] = 3; // 欲替换之前的广告 $attr['status_time'] = $attr['replace-time']; } } $attr = Utils::array_omit($attr, self::$FIELDS_CALLBACK, self::$FIELDS_CHANNEL, self::$FIELDS_IOS, self::$FIELDS_DIY, self::$FIELDS_OMIT); if ($only_split) { unset($attr['id']); } return [$callback, $ios, $channel, $diy, $attr, $permissions, $provinces]; }
/** * 取当前用户的助理和被助理 * @return array|null|string */ public function get_assistant() { $me = $_SESSION['id']; $admin = new Admin(); $sales = $admin->get_sales_by_me($me); $owner = $admin->get_owner(null, $me); if ($sales) { $sales = array_keys($sales); } if ($owner) { $sales = array_unique(array_merge(array_values($owner), (array) $sales)); } return array_values($sales); }