コード例 #1
0
ファイル: UserTag.php プロジェクト: 3116246/haolinju
 public function addtag($login_account, $tag_name, $tag_desc)
 {
     try {
         $tag_id = SysSeq::GetSeqNextValue($this->da, "we_tag", "tag_id");
         $sql = "insert into we_tag (tag_id,tag_name,owner_id,owner_type,tag_desc,create_date) values(?,?,?,?,?,now())";
         $params = array($tag_id, $tag_name, $login_account, '01', $tag_desc);
         if (!$this->da->ExecSQL($sql, $params)) {
             return null;
         } else {
             $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($this->da, $this->logger, $this->container);
             $friendevent->addtag($login_account, $tag_id, $tag_name, $tag_desc);
             return $tag_id;
         }
     } catch (\Exception $e) {
         //var_dump($e->getMessage());
         $this->writelog($e);
         return null;
     }
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 public function savePcSyncAction(Request $request)
 {
     $session = $this->get('session');
     $filename120 = $session->get("avatar_big");
     $filename48 = $session->get("avatar_middle");
     $filename24 = $session->get("avatar_small");
     $user = $this->get('security.context')->getToken()->getUser();
     $dm = $this->get('doctrine.odm.mongodb.document_manager');
     if (!empty($filename120)) {
         $filename120 = $this->saveFile($filename120, $dm);
     }
     if (!empty($filename48)) {
         $filename48 = $this->saveFile($filename48, $dm);
     }
     if (!empty($filename24)) {
         $filename24 = $this->saveFile($filename24, $dm);
     }
     $session->remove("avatar_big");
     $session->remove("avatar_middle");
     $session->remove("avatar_small");
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $para["account"] = $user->getUsername();
     $table = $da->GetData("staff", "select nick_name,photo_path,photo_path_small,photo_path_big,fafa_jid from we_staff where login_account=?", array((string) $para["account"]));
     $oldRow = $table["staff"]["rows"][0];
     if (!empty($filename120)) {
         if ($table && $table["staff"]["recordcount"] > 0) {
             $this->removeFile($table["staff"]["rows"][0]["photo_path"], $dm);
             $this->removeFile($table["staff"]["rows"][0]["photo_path_small"], $dm);
             $this->removeFile($table["staff"]["rows"][0]["photo_path_big"], $dm);
         }
     }
     $old_nick_name = $oldRow["nick_name"];
     $Jid = $oldRow["fafa_jid"];
     $y = $request->get("dateYear");
     $birthday = empty($y) || $y == "0000" ? "" : $y . "-" . $request->get("dateMonth") . "-" . $request->get("dateDay");
     $nick_name = $request->get("txtname");
     if (empty($filename120)) {
         $sql = "update we_staff set nick_name=?,birthday=?,dept_id=?,work_phone=?,mobile=?,self_desc=?,specialty=?,hobby=?,hometown=?,graduated=?,work_his=?,sex_id=? where login_account=?";
         $paras[] = $nick_name;
         $paras[] = $birthday;
         $paras[] = $request->get("txtdeptid");
         $paras[] = $request->get("txtwork_phone");
         $paras[] = $request->get("txtmobile");
         $paras[] = $request->get("txtself_desc");
         $paras[] = $request->get("txtspecialty");
         $paras[] = $request->get("txthobby");
         $paras[] = $request->get("txthometown");
         $paras[] = $request->get("txtgraduated");
         $paras[] = $request->get("txtwork_his");
         $paras[] = $request->get("txtsex");
         $paras[] = $para["account"];
     } else {
         $sql = "update we_staff set nick_name=?,birthday=?,photo_path=?,photo_path_small=?,photo_path_big=?,dept_id=?,work_phone=?,mobile=?,self_desc=?,specialty=?,hobby=?,hometown=?,graduated=?,work_his=?,sex_id=?  where login_account=?";
         $paras[] = $nick_name;
         $paras[] = $birthday;
         $paras[] = $filename48;
         $paras[] = $filename24;
         $paras[] = $filename120;
         $paras[] = $request->get("txtdeptid");
         $paras[] = $request->get("txtwork_phone");
         $paras[] = $request->get("txtmobile");
         $paras[] = $request->get("txtself_desc");
         $paras[] = $request->get("txtspecialty");
         $paras[] = $request->get("txthobby");
         $paras[] = $request->get("txthometown");
         $paras[] = $request->get("txtgraduated");
         $paras[] = $request->get("txtwork_his");
         $paras[] = $request->get("txtsex");
         $paras[] = $para["account"];
     }
     try {
         if (empty($filename120)) {
             if ($table && $table["staff"]["recordcount"] > 0) {
                 $para["path"] = $this->container->getParameter('FILE_WEBSERVER_URL') . $table["staff"]["rows"][0]["photo_path_big"];
             } else {
                 $para["path"] = $this->get('templating.helper.assets')->geturl('bundles/fafatimewebase/images/no_photo.png');
             }
         } else {
             $para["path"] = $this->container->getParameter('FILE_WEBSERVER_URL') . $filename120;
             $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($da, $this->get('logger'), $this->container);
             $friendevent->photochange($user->getUserName(), $user->nick_name);
         }
         try {
             $da->ExecSQL($sql, $paras);
         } catch (\Exception $ex) {
             $this->get("logger")->err("========保存人员资料时错误:" . $ex);
             $this->get("logger")->err("========保存人员资料时错误-SQL:" . $sql);
             $this->get("logger")->err("========保存人员资料时错误-DATA:" . $paras);
             Utils::sendImPresence("", "*****@*****.**", "保存人员资料时错误", "AccountController->savePcSyncAction:<br>" . $sql . "<br>" . $paras, $this->container);
         }
         //如果更改了姓名时,需要同步到im库中并更新相关引用
         if ($old_nick_name != $nick_name) {
             $da_im->ExecSQL("call emp_change_name(?,?)", array((string) $user->fafa_jid, (string) $nick_name));
         }
         //发送个人资料编辑通知
         try {
             //发送即时消息
             $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $user);
             $message = "{\"path\":\"" . $para["path"] . "\",\"desc\":\"" . strtr($request->get("txtself_desc"), array("\"" => "“")) . "\"}";
             Utils::sendImPresence($user->fafa_jid, implode(",", $staffMgr->getFriendAndColleagueJid()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         } catch (\Exception $e) {
             $this->get('logger')->err($e);
         }
         $response = new Response("{\"succeed\":1,\"path\":\"" . $para["path"] . "\"}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     } catch (\Exception $e) {
         //return $this->render('JustsyBaseBundle:login:index.html.twig', array('name' => 'err'));
         $response = new Response("{\"succeed\":0,\"e\":{$e}}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
 }
コード例 #4
0
ファイル: Enterprise.php プロジェクト: 3116246/haolinju
 public function attenEno($paraObj)
 {
     $login_account = isset($paraObj["login_account"]) ? $paraObj["login_account"] : $paraObj["user"]->getUsername();
     $eno = $paraObj["eno"];
     try {
         //关注默认公众号
         $account = "_wexin_{$eno}@fafatime.com";
         //取出默认公众号
         $sql1 = "select number from we_micro_account where eno=? and number=?";
         $params1 = array((string) $eno, (string) $account);
         $ds = $this->da->Getdata('account', $sql1, $params1);
         if ($ds['account']['recordcount'] > 0) {
             $sql[] = "insert into we_staff_atten (login_account,atten_type,atten_id,atten_date) values(?,?,?,now())";
             $params[] = array($login_account, "01", $account);
         } else {
             //未找到公众号时,直接关注该企业,
             //注:当注册成功时,需要将这些关注数据转换为关注对应的默认公众号
             $sql[] = "insert into we_staff_atten (login_account,atten_type,atten_id,atten_date) values(?,?,?,now())";
             $params[] = array($login_account, self::$code, $eno);
         }
         if (!$this->da->ExecSQLs($sql, $params)) {
             return false;
         }
         $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($this->da, $this->logger, $this->container);
         $friendevent->atteneno($login_account, $eno);
         return true;
     } catch (\Exception $e) {
         $this->writelog($e);
         return false;
     }
 }
コード例 #5
0
ファイル: Staff.php プロジェクト: 3116246/haolinju
 public function attentionTo($attenaccount)
 {
     $staffinfo = $this->getInfo();
     $attention_type = '01';
     //关注人员
     $sql = "insert into we_staff_atten(login_account,atten_type,atten_id,atten_date)values(?,?,?,now())";
     $para = array((string) $staffinfo["login_account"], (string) $attention_type, (string) $attenaccount);
     $this->conn->ExecSQL($sql, $para);
     //每个关注0.2分
     $sql = "insert into we_staff_points (login_account,point_type,point_desc,point,point_date)\n          values (?,?,?,?,now())";
     $para = array((string) $staffinfo["login_account"], (string) '08', (string) '关注' . $attenaccount . ',获得积分0.2', (double) 0.2);
     $this->conn->ExecSQL($sql, $para);
     $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($this->conn, $this->logger, null);
     $friendevent->attenuser($staffinfo["login_account"], $staffinfo["nick_name"], $attenaccount);
 }