예제 #1
0
 public function GetByIM($grouid, $refreshCache = false)
 {
     try {
         $data = Cache_Enterprise::get("group_", $grouid, $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data) || $refreshCache === true) {
         $url = $this->container->getParameter('FILE_WEBSERVER_URL');
         $sql = "select a.*, b.employeename create_staff_name from im_group a left join im_employee b on b.loginname=a.creator where a.groupid=?";
         $params = array();
         $params[] = (string) $grouid;
         $ds = $this->conn_im->GetData("we_groups", $sql, $params);
         if (count($ds["we_groups"]["rows"]) > 0) {
             if (!empty($ds["we_groups"]["rows"][0]['logo'])) {
                 $ds["we_groups"]["rows"][0]['logo'] = $url . $ds["we_groups"]["rows"][0]['logo'];
             }
             Cache_Enterprise::set("group_", $grouid, json_encode($ds["we_groups"]["rows"][0]), 0, $this->container);
             return $ds["we_groups"]["rows"][0];
         } else {
             Cache_Enterprise::delete("group_", $grouid, $this->container);
             return null;
         }
     }
     $returnObj = json_decode($data, true);
     return $returnObj;
 }
예제 #2
0
파일: Dept.php 프로젝트: 3116246/haolinju
 public function getinfo($id, $isfresh = false)
 {
     try {
         $data = Cache_Enterprise::get(Cache_Enterprise::$EN_DEPT, $id, $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data) || $isfresh) {
         $sql = "select  *,deptid fafa_deptid from im_base_dept where deptid=?";
         $ds = $this->conn_im->GetData("d", $sql, array((string) $id));
         if (count($ds['d']['rows']) > 0) {
             $deptinfo = $ds['d']['rows'][0];
             Cache_Enterprise::set(Cache_Enterprise::$EN_DEPT, $id, json_encode($deptinfo), 0, $this->container);
             return $deptinfo;
         } else {
             Cache_Enterprise::delete(Cache_Enterprise::$EN_DEPT, $id, $this->container);
             return null;
         }
     }
     return json_decode($data, true);
 }
예제 #3
0
파일: App.php 프로젝트: 3116246/haolinju
 public function refreshPortal($parameter)
 {
     $eno = $parameter["eno"];
     Cache_Enterprise::delete(Cache_Enterprise::$EN_APP, $eno, $this->containerObj);
 }
예제 #4
0
 public function refresh($eno)
 {
     Cache_Enterprise::delete(Cache_Enterprise::$EN_INFO, $eno, $this->container);
     return $this->getInfo($eno);
 }
예제 #5
0
 public function deleteGroupVersion($groupid)
 {
     $conn_im = $this->containter->get("we_data_access_im");
     $conn_im->ExecSQL("delete from im_group_version where us=?", array((string) $groupid));
     Cache_Enterprise::delete("grp_ver_", $groupid, $this->containter);
 }
예제 #6
0
파일: Staff.php 프로젝트: 3116246/haolinju
 public function getStaffInfo($staff, $refreshCache = false)
 {
     if (empty($staff)) {
         return null;
     }
     try {
         $data = null;
         if (!$refreshCache) {
             $data = Cache_Enterprise::get(Cache_Enterprise::$EN_STAFF, $staff, $this->container);
             if (empty($data)) {
                 //判断是否是影射到帐号上的其他属性
                 $mapp_login_account = Cache_Enterprise::get('staff_mapp_', $staff, $this->container);
                 if (!empty($mapp_login_account)) {
                     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_STAFF, $mapp_login_account, $this->container);
                 }
             }
         }
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data)) {
         if (Utils::validateMobile($staff)) {
             $sql = "select a.nick_name, a.login_account,a.self_desc,a.sex_id,a.mobile_bind,a.state_id,a.photo_path_big photo_path, a.dept_id, a.eno,a.fafa_jid,a.fafa_jid jid,a.duty,a.openid from we_staff a where a.mobile_bind=? ";
             $ds = $this->conn->getData("t", $sql, array((string) $staff));
         } else {
             if (strlen($staff) >= 30) {
                 $sql = "select a.nick_name, a.login_account,a.self_desc,a.sex_id,a.mobile_bind,a.state_id,a.photo_path_big photo_path, a.dept_id, a.eno,a.fafa_jid,a.fafa_jid jid,a.duty,a.openid from we_staff a  where a.openid=? ";
                 $ds = $this->conn->getData("t", $sql, array((string) $staff));
             } else {
                 $sql = "select a.nick_name, a.login_account,a.self_desc,a.sex_id,a.mobile_bind,a.state_id,a.photo_path_big photo_path, a.dept_id, a.eno,a.fafa_jid,a.fafa_jid jid,a.duty,a.openid from we_staff a where a.login_account=? or a.fafa_jid=? or a.ldap_uid=?";
                 $ds = $this->conn->getData("t", $sql, array((string) $staff, (string) $staff, (string) $staff));
             }
         }
         if ($ds && count($ds["t"]["rows"]) > 0) {
             $fileurl = $this->container->getParameter("FILE_WEBSERVER_URL");
             $returnObj = $ds["t"]["rows"][0];
             if (!empty($returnObj["photo_path"])) {
                 $returnObj["photo_path"] = $fileurl . $returnObj["photo_path"];
             }
             $dept = new Dept($this->conn, $this->conn_im, $this->container);
             $d_info = $dept->getinfo($returnObj['dept_id']);
             $returnObj['dept_name'] = empty($d_info) ? '' : $d_info['deptname'];
             $en = new Enterprise($this->conn, $this->logger, $this->container);
             $e_info = $en->getinfo($returnObj['eno']);
             $returnObj['ename'] = empty($e_info) ? '' : $e_info['ename'];
             if ($staff != $returnObj["login_account"]) {
                 //非帐号时,做缓存影射
                 Cache_Enterprise::set('staff_mapp_', $staff, $returnObj["login_account"], 0, $this->container);
             }
             $staff = $returnObj["login_account"];
             Cache_Enterprise::delete(Cache_Enterprise::$EN_STAFF, $staff, $this->container);
             //判断人员状态。如果不正常朋需要刷新缓存时,从缓存中删除
             if ($returnObj["state_id"] == "1") {
                 Cache_Enterprise::set(Cache_Enterprise::$EN_STAFF, $staff, json_encode($returnObj), 0, $this->container);
             }
             return $returnObj;
         } else {
             //没有获取到人员时,从缓存中删除
             Cache_Enterprise::delete(Cache_Enterprise::$EN_STAFF, $staff, $this->container);
             return null;
         }
     }
     $returnObj = json_decode($data, true);
     return $returnObj;
 }
예제 #7
0
 public function tencentexmailloginAction()
 {
     $request = $this->getRequest();
     $param = $request->get("params");
     if (empty($param)) {
         $param = array();
     } else {
         if (is_string($param)) {
             $param = json_decode($param, true);
         }
     }
     if (!isset($param["appid"])) {
         $param["appid"] = $request->get("appid");
     }
     $openid = $request->get("openid");
     $staffObj = new \Justsy\BaseBundle\Management\Staff($this->get('we_data_access'), $this->get('we_data_access_im'), $openid, $this->get("logger"));
     $user = $staffObj->getSessionUser();
     $appid = $param["appid"];
     //$openid = $user->openid;
     //$ldap_uid = $user->ldap_uid;
     //判断是否绑定
     $app = new \Justsy\BaseBundle\Management\App($this->container);
     $appdata = $app->getappinfo(array("appid" => $appid));
     if (empty($appdata)) {
         $resp = new Response("无效的APPID");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $agent = $appdata["clientid"];
     //判断是否绑定
     $bindinfo = $app->getappbind(array("appid" => $appid, "openid" => $openid));
     if (empty($bindinfo)) {
         //$controller->get("logger")->err("================not bind");
         //重定向到绑定页面
         return $this->render("JustsyBaseBundle:AppCenter:h5bundle.html.twig", array('appid' => $appid, 'openid' => $openid, 'ssomodule' => "OAuth2"));
     }
     $ldap_uid = $bindinfo["bind_uid"];
     $cacheKey = md5($appid . $openid);
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $this->container);
     if (empty($data)) {
         $this->get("logger")->err("{$appid}.{$openid}");
         $resp = new Response("太长时间未操作,请重新进入应用");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $data = json_decode($data, true);
     $acctoken = $data["access_token"];
     //$this->get("logger")->err($acctoken);
     //获取authkey
     $url = "http://openapi.exmail.qq.com:12211/openapi/mail/authkey";
     $authkey = Utils::do_post_request($url, "alias=" . $ldap_uid . "&access_token=" . $acctoken);
     //$this->get("logger")->err($url."?"."alias=".$ldap_uid."&access_token=".$acctoken);
     //$this->get("logger")->err($authkey);
     if (empty($authkey)) {
         $resp = new Response("腾讯企业邮箱登录失败");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = json_decode($authkey, true);
     if (!isset($authkey["auth_key"])) {
         if ($authkey["error"] == "invalid_token") {
             Cache_Enterprise::delete(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $this->container);
             $resp = new Response("腾讯企业邮箱登录失败:<br>token无效或已经过期,请稍后重试!");
         } else {
             $resp = new Response("腾讯企业邮箱登录失败:<br>" . json_encode($authkey));
         }
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = $authkey["auth_key"];
     $login_url = "https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=" . $agent . "&user="******"&ticket=" . $authkey;
     //$this->get("logger")->err($login_url);
     return Utils::http_redirect($login_url);
 }