public function UploadFileAction() { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $request = $this->getRequest(); $content = $request->get("update_content"); $version1 = $request->get("version_1"); $version2 = $request->get("version_2"); $version3 = $request->get("version_3"); $version4 = $request->get("version_4"); $version = $version1 . "." . $version2 . "." . $version3 . "." . $version4; $plist_url = $request->get("plist_url"); $plist_url = empty($plist_url) ? null : $plist_url; $openid = $request->get('openid'); $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); $login_account = $staffdata["login_account"]; $fileElementName = 'filedata'; $success = true; $msg = ""; try { $filename = $_FILES[$fileElementName]['name']; $filesize = $_FILES[$fileElementName]['size']; $filetemp = $_FILES[$fileElementName]['tmp_name']; //判断文件类型 $file_name = basename($filename); $fixedType = explode(".", strtolower($file_name)); $fixedType = $fixedType[count($fixedType) - 1]; $type = 0; if ($fixedType == "apk") { $type = 1; } else { if ($fixedType == "ipa") { $type = 2; } } //比较版本号 $sql = "select max(replace(version,'.','')) version from we_version where type=?;"; try { $ds = $da->GetData("table", $sql, array((string) $type)); if ($ds && $ds["table"]["recordcount"] > 0) { $old_ver = (int) $ds["table"]["rows"][0]["version"]; $new_ver = $version1 . $version2 . $version3 . $version4; $new_ver = (int) $new_ver; if ($new_ver <= $old_ver) { return Utils::WrapResultError("你输入的版本号比数据库里的小,请重新输入"); } } } catch (\Exception $e) { return Utils::WrapResultError($e->getMessage()); } $fileid = $this->saveCertificate($filetemp, $filename); if (!empty($fileid)) { //上传文件成功后返回文件id $url = $this->container->getParameter('FILE_WEBSERVER_URL'); $path = $_SERVER['DOCUMENT_ROOT'] . "/download/app"; $dir = explode('src', __DIR__); if (!is_dir($dir[0] . '/download/app')) { mkdir($dir[0] . '/download/app', 0777, true); } $path = $path . "/"; $dowurl = $url . $fileid; $id = SysSeq::GetSeqNextValue($da, "we_version", "id"); $sql = "insert into we_version(id,version,type,update_content,filename,date,staffid,fileid,plist_url)values(?,?,?,?,?,now(),?,?,?)"; $para = array((string) $id, (string) $version, (string) $type, (string) $content, (string) $file_name, (string) $login_account, (string) $fileid, $plist_url); try { $da->ExecSQL($sql, $para); //发送出席 $presence = new \Justsy\OpenAPIBundle\Controller\ApiController(); $presence->setContainer($this->container); $my_jid = $staffdata['jid']; $sql = "select distinct us from global_session;"; $ds = $da_im->GetData("us", $sql); $tojids = array(); $title = ""; if ($type == 1) { $title = "andorid"; } else { if ($type == 2) { $title = "ios"; } else { $title = "pc"; } } $sendMessage = new \Justsy\BaseBundle\Common\SendMessage($da, $da_im); $body = "有新版本(" . $version . "),请及时更新!"; $notice = Utils::WrapMessageNoticeinfo($body, '系统通知', null, null); $msg = json_encode(Utils::WrapMessage('newversion', array('type' => $title), $notice)); $parameter = array("eno" => $staffdata['eno'], "flag" => "all", "title" => "newversion", "message" => $msg, "container" => $this->container); $sendMessage->sendImMessage($parameter); } catch (\Exception $e) { $success = false; $this->get("logger")->err($e->getMessage()); $msg = "添加数据记录失败!"; return Utils::WrapResultError($e->getMessage()); } } else { $success = false; $msg = "上传安装包文件失败"; return Utils::WrapResultError($msg); } } catch (\Exception $e) { $success = false; $msg = "上传安装包失败。"; $this->get("logger")->err($e->getMessage()); return Utils::WrapResultError($e->getMessage()); } //删除上传的文件 @unlink($_FILES[$fileElementName]); return Utils::WrapResultOK(""); }
public function checkAndUpdate($nick_name, $mobile = null, $deptid = null, $duty = null, $ldap_uid = null, $sex_id = null, $self_desc = null) { $sql = "update we_staff set "; $returnItem = array(); $para = array(); $updateItm = array(); if (!empty($nick_name)) { $updateItm[] = "nick_name=?"; $para[] = (string) $nick_name; $returnItem["nick_name"] = $nick_name; } if ($mobile !== null) { $updateItm[] = "mobile=?, mobile_bind=?"; $para[] = (string) $mobile; $para[] = (string) $mobile; $returnItem["mobile"] = $mobile; } if ($duty !== null) { $updateItm[] = "duty=?"; $para[] = (string) $duty; $returnItem["duty"] = $duty; } if ($ldap_uid != null) { $updateItm[] = "ldap_uid=?"; $para[] = (string) $ldap_uid; } if ($sex_id != null) { $updateItm[] = "sex_id=?"; $para[] = (string) $sex_id; $returnItem["sex_id"] = $sex_id; } if ($self_desc != null) { $updateItm[] = "self_desc=?"; $para[] = (string) $self_desc; $returnItem["self_desc"] = $self_desc; } if ($deptid !== null) { $staffinfo = $this->getInfo(); $this->moveToDept($deptid); } if (empty($updateItm) || count($updateItm) == 0) { return true; } $sql = "update we_staff set " . implode(",", $updateItm) . " where login_account=? or ldap_uid=? or openid=?"; $para[] = (string) $this->account; $para[] = (string) $this->account; $para[] = (string) $this->account; $this->conn->ExecSQL($sql, $para); if (!empty($nick_name)) { $this->conn->ExecSQL("call emp_change_name(?,?)", array((string) $this->account, (string) $nick_name)); $jid = $this->getInfo(); $jid = $jid["fafa_jid"]; $this->conn_im->ExecSQL("call emp_change_name(?,?)", array((string) $jid, (string) $nick_name)); } //刷新缓存 $staffdata = $this->getInfo(true); if (!empty($self_desc) || !empty($nick_name)) { $pinyin = $this->syncAttrsToIM(); $returnItem['spell'] = $pinyin; } $VersionChange = new VersionChange($this->conn, $this->logger, $this->container); $VersionChange->deptchange($staffdata); $returnItem['jid'] = $staffdata['jid']; $msg = json_encode(Utils::WrapMessage('staff-changeinfo', $returnItem, array())); //操作成功发送出席 $sendMessage = new \Justsy\BaseBundle\Common\SendMessage($this->conn, $this->conn_im); $parameter = array("eno" => $staffdata["eno"], "fromjid" => $staffdata["jid"], "flag" => "all", "title" => "staff-changeinfo", "message" => $msg, "container" => $this->container); $sendMessage->sendImMessage($parameter); $parameter = array("eno" => $staffdata["eno"], "fromjid" => $staffdata["jid"], "flag" => "onself", "title" => "staff-changeinfo", "message" => $msg, "container" => $this->container); $sendMessage->sendImPresence($parameter); return true; }