예제 #1
0
 public function oldeditAppsAction(Request $request)
 {
     $appid = $request->get("appid");
     $appname = $request->get("appname");
     $logo = $request->get("applogo");
     $apptype = $request->get("apptype");
     $appsubtype = $request->get("appsubtype");
     $subscribe = $request->get("subscribe");
     $appdesc = $request->get("appdesc");
     $p_account = $request->get("p_account");
     //业务代理帐号
     $p_password = $request->get("p_password");
     //业务代理密码
     $bindurl = $request->get("bindurl");
     $sortid = $request->get("sortid");
     $functiontype = $request->get("functiontype");
     $native_code = $request->get("native_code");
     $curuser = $this->get('security.context')->getToken()->getUser();
     $appdeveloper = $curuser->eno;
     $username = $curuser->getUsername();
     $sql = "";
     $para = array();
     $da = $this->get('we_data_access');
     $result = array();
     try {
         if ($this->existsAppName($appdeveloper, $appid, $appname)) {
             $result = array("s" => "exists");
         } else {
             if (empty($appid)) {
                 $c_flag = true;
                 if (!empty($p_account)) {
                     $u_staff = new Staff($da, $this->get('we_data_access_im'), $curuser, $this->get('logger'));
                     $c_flag = $u_staff->cratestaff($curuser->eno, $appname, $p_account, $p_password, $this->get('security.encoder_factory'));
                 }
                 if ($c_flag) {
                     $appid = Utils::getAppid($appdeveloper, $username);
                     $appkey = Utils::getAppkey();
                     $sql = "insert into we_appcenter_apps(appid,appkey,logo,appname,state,appdeveloper,subscribe,appdesc,bindurl,apptype,sortid,functiontype,native_code,createstaffid)values(?,?,?,?,1,?,?,?,?,'99',?,?,?,?)";
                     $para = array((string) $appid, (string) $appkey, (string) $logo, (string) $appname, (string) $appdeveloper, (string) $subscribe, (string) $appdesc, (string) $bindurl, (string) $sortid, $functiontype, $native_code, (string) $curuser->getUserName());
                     $result = array("s" => "add", "appid" => $appid);
                 } else {
                     $result = array("s" => "error", "msg" => "帐号已被使用!");
                 }
             } else {
                 $sql = "update we_appcenter_apps set appname=?,logo=?,subscribe=?,appdesc=?,bindurl=?,sortid=?,functiontype=?,native_code=? where appid=?";
                 $para = array((string) $appname, (string) $logo, (string) $subscribe, (string) $appdesc, (string) $bindurl, (string) $sortid, $functiontype, $native_code, (string) $appid);
                 $result = array("s" => "edit", "appid" => $appid);
             }
             if ($sql != "") {
                 $da->ExecSQL($sql, $para);
             }
         }
     } catch (\Exception $e) {
         $result = array("s" => "error", "msg" => $e->getMessage());
     }
     $resp = new Response(json_encode($result));
     $resp->headers->set('Content-Type', 'text/json');
     //返回值说明:1=>添加成功;2=>修改成功;3=>已存在应用名称;0=>出错
     return $resp;
 }