public function modifystaffinfoAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $login_account = $user->getUsername(); $nick_name = $request->get("nick_name"); $sex_id = $request->get("sex_id"); $self_desc = $request->get("self_desc"); $work_phone = $request->get("work_phone"); $dept_id = $request->get("dept_id"); $duty = $request->get("duty"); $old_self_desc = $user->self_desc; $sql = "update we_staff set "; $para = array(); $changeAttr = array(); try { if ($nick_name !== null) { $sql .= "nick_name=?,"; $para[] = $nick_name; $changeAttr["nick_name"] = $nick_name; } if ($sex_id !== null) { $sql .= "sex_id=?,"; $para[] = $sex_id; $changeAttr["sex_id"] = $sex_id; } if ($self_desc !== null) { $sql .= "self_desc=?,"; $para[] = $self_desc; $changeAttr["desc"] = $self_desc; } if ($work_phone !== null) { $sql .= "work_phone=?,"; $para[] = $work_phone; $changeAttr["work_phone"] = $work_phone; } if ($dept_id !== null) { $sql .= "dept_id=?,"; $para[] = $dept_id; $changeAttr["dept_id"] = $dept_id; } if ($duty !== null) { $sql .= "duty=?,"; $para[] = $duty; $changeAttr["duty"] = $duty; } if (count($para) === 0) { throw new \Exception("param is null"); } $sql = substr($sql, 0, strlen($sql) - 1); $sql .= " where login_account=?"; $para[] = $login_account; try { $da->ExecSQL($sql, $para); } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); } if ($dept_id !== null) { $ds = $da->GetData("dept", "select fafa_deptid from we_department where dept_id=?", array((string) $dept_id)); if ($ds && $ds['dept']['recordcount'] > 0) { $fafa_deptid = $ds["dept"]["rows"][0]["fafa_deptid"]; $sqls[] = "update im_employee set deptid=? where loginname=?"; $paras[] = array((string) $fafa_deptid, (string) $user->fafa_jid); //重置IM数据及版本 $da_im->ExecSQL("call dept_emp_stat(?)", array((string) $user->fafa_jid)); $da_im->ExecSQL("delete from im_employee_version where us=?", array((string) $user->fafa_jid)); } } if ($nick_name !== null) { try { //理改we_sns库相关昵称 $da->ExecSQL("call emp_change_name(?,?)", array((string) $user->fafa_jid, (string) $nick_name)); //理改we_im库相关昵称 $da_im->ExecSQL("call emp_change_name(?,?)", array((string) $user->fafa_jid, (string) $nick_name)); } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); } } $re["returncode"] = ReturnCode::$SUCCESS; if ($self_desc !== null && $old_self_desc != $self_desc) { $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($da, $this->get('logger'), $this->container); $friendevent->signchange($user->getUserName(), $user->nick_name, $self_desc); } //所有变化都默认通知在线的好友 //if($self_desc !== null){ $message = json_encode($changeAttr); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $user); Utils::sendImPresence($user->fafa_jid, implode(",", $staffMgr->getFriendAndColleagueJid()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code); //} //通知自己在线的其他设备 Utils::sendImPresence("", $user->fafa_jid, "staff-changeinfo", "", $this->container, "", "", false, Utils::$systemmessage_code); } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $this->get('logger')->err($e); } $this->get("logger")->err("---------------2---------" . $sql); $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function saveselfdescAction() { $res = $this->get("request"); $auth = $res->get("authcode"); $openid = $res->get("p"); $desc = $res->get("desc"); if ($auth == null || $auth == "") { $response = new Response("{\"s\":0,\"msg\":\"authcode is null\"}"); return $response; } try { $auth = trim(DES::decrypt($auth)); //解密参数串 $openid = trim(DES::decrypt($openid)); $desc = trim(DES::decrypt($desc)); //授权码已过期 $lng = time() - (int) $auth; if ($lng > 30 || $lng < 0) { $response = new Response("{\"s\":0,\"msg\":\"authcode date out!\"}"); return $response; } if (empty($openid)) { $response = new Response("{\"s\":0,\"msg\":\"openid is null\"}"); return $response; } $sql = "update we_staff set self_desc=? where openid=?"; $da = $this->get("we_data_access"); $da->ExecSQL($sql, array((string) $desc, (string) $openid)); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, null, $openid, $this->get('logger')); $staffinfo = $staffMgr->getInfo(); if ($staffinfo != null) { $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($da, $this->get('logger'), $this->container); $friendevent->signchange($staffinfo["login_account"], $staffinfo["nick_name"], $desc); } //$this->get('session')->migrate(); $response = new Response("{\"s\":1,\"msg\":\"\"}"); return $response; } catch (\Exception $e) { $this->get("logger")->err($e); $response = new Response("{\"s\":0,\"msg\":\"exception\"}"); return $response; } }