Example #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;
 }
Example #2
0
 private function getFunctionCode($roleid)
 {
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_FUNCTION, $roleid);
     if (empty($data)) {
         $sql = "select DISTINCT b.code from we_role_function a,we_function b where a.functionid=b.id and a.roleid=? and b.code is not null";
         $para = array((string) $roleid);
         $data = $this->conn->GetData("dt", $sql, $para);
         Cache_Enterprise::set(Cache_Enterprise::$EN_FUNCTION, $roleid, json_encode($data["dt"]["rows"]));
         return $data["dt"]["rows"];
     } else {
         return json_decode($data, true);
     }
 }
Example #3
0
 public function GetSysParam($ParamName, $defaultvalue = '', $isfresh = false)
 {
     $data = "";
     try {
         $data = Cache_Enterprise::get(Cache_Enterprise::$SYS, $ParamName, $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data) || $isfresh) {
         $dataaccess = $this->container->get('we_data_access');
         $dataset = $dataaccess->GetData("we_sys_param", "select param_name, param_value from we_sys_param where param_name = ? ", array((string) $ParamName));
         if ($dataset && count($dataset["we_sys_param"]["rows"]) > 0) {
             $data = $dataset["we_sys_param"]["rows"][0]["param_value"];
             Cache_Enterprise::set(Cache_Enterprise::$SYS, $ParamName, $data, 0, $this->container);
         } else {
             $dataaccess->ExecSQL('insert into we_sys_param(param_name, param_value)values(?,?)', array((string) $ParamName, (string) $defaultvalue));
             $data = $defaultvalue;
         }
     }
     return $data;
 }
Example #4
0
 public function getappsession($parameter)
 {
     $appid = $parameter["appid"];
     $openid = $parameter["openid"];
     $key = md5($appid . $openid);
     $appdata = Cache_Enterprise::get(Cache_Enterprise::$EN_OAUTH2, $key, $this->containerObj);
     if (!empty($appdata)) {
         return json_decode($appdata, true);
     }
     $sql = "select access_token,refresh_token,access_token_expires expires_in from we_app_oauth_sessions where appid=? and userid=?";
     $dsset = $this->conn->getdata("t", $sql, array((string) $appid, (string) $openid));
     if (count($dsset["t"]["rows"]) > 0) {
         Cache_Enterprise::set(Cache_Enterprise::$EN_APP_BIND, $key, json_encode($dsset["t"]["rows"][0]), 0, $this->containerObj);
         return $dsset["t"]["rows"][0];
     }
     return null;
 }
Example #5
0
 private function getSecurityDomains()
 {
     $securityDomains = \Justsy\BaseBundle\Common\Cache_Enterprise::get("securityDomains", "", $this->container);
     if (!empty($securityDomains)) {
         return json_decode($securityDomains, true);
     }
     $mayDomain = array("localhost", "127.0.0.1");
     $configWeFaFa = $this->container->getParameter('open_api_url');
     //获取配置的wefafa地址
     $tmp = parse_url($configWeFaFa);
     $host = $tmp["host"];
     //$this->get("logger")->err(">>>>>>>>>>>>>>>>>>>open_api_url>host:".$host);
     if (Utils::is_ip($host)) {
         $mayDomain[] = $host;
     } else {
         $host = substr($host, strpos($host, ".") + 1);
         $mayDomain[] = $host;
     }
     $configWeFaFa = $this->container->getParameter('fafa_appcenter_url');
     //获取配置的应用中心地址
     $tmp = parse_url($configWeFaFa);
     $host = $tmp["host"];
     //$this->get("logger")->err(">>>>>>>>>>>>>>>>>>>fafa_appcenter_url>host:".$host);
     if (Utils::is_ip($host)) {
         $mayDomain[] = $host;
     } else {
         $host = substr($host, strpos($host, ".") + 1);
         $mayDomain[] = $host;
     }
     //ApiController::$securityDomains = $mayDomain;
     \Justsy\BaseBundle\Common\Cache_Enterprise::set("securityDomains", "", json_encode($mayDomain), 0, $this->container);
     return $mayDomain;
 }
Example #6
0
 public function executeBydsid($user, $dsid, $inf_parameters, &$err)
 {
     $logger = $this->container->get("logger");
     //判断是否有缓存数据
     $cache_key = md5($dsid . $inf_parameters);
     try {
         $data = Cache_Enterprise::get(Cache_Enterprise::$EN_DATAINF, $cache_key, $this->container);
     } catch (\Exception $e) {
         $logger->err($e);
         $data = null;
     }
     if (!empty($data)) {
         $logger->err(Cache_Enterprise::$EN_DATAINF . $cache_key . "-------------get cache data------------");
         $result = json_decode($data, true);
         return $result;
     }
     try {
         $re = "";
         $dataaccess = $this->container->get('we_data_access');
         $dataset = $dataaccess->GetData("ds", "select * from mapp_datasource where id=? ", array((string) $dsid));
         if ($dataset && count($dataset["ds"]["rows"]) > 0) {
             $re = $dataset["ds"]["rows"][0];
             $inf_type = $re["inf_type"];
             //静态数据直接返回
             if ($re["inf_type"] == "Static") {
                 $result = json_decode($re["inf_url"], true);
                 $ztree = new ZtreeTransfer($this->container);
                 $returndata = $ztree->dataToTree($result);
                 return array("returncode" => "0000", "list" => $returndata);
             }
             $classname = "\\Justsy\\BaseBundle\\DataAccess\\DataExtract";
             $classname = $classname . "\\" . ucfirst($inf_type);
             try {
                 $returndata = null;
                 $http_data = call_user_func(array($classname, 'getByDsid'), $user, $re, $inf_parameters, $this->container);
                 if (is_string($http_data)) {
                     $returndata = json_decode($http_data, true);
                 } else {
                     $returndata = $http_data;
                 }
                 //转换数据
                 $ztree = new ZtreeTransfer($this->container);
                 $returndata = $ztree->dataToTree($returndata);
                 $result = array("returncode" => "0000", "list" => $returndata);
                 Cache_Enterprise::set(Cache_Enterprise::$EN_DATAINF, $cache_key, json_encode($result), 30, $this->container);
                 return $result;
             } catch (\Exception $e) {
                 $re = array("returncode" => "9999", "msg" => $e->getMessage());
             }
         } else {
             $re = array("returncode" => "9999", "msg" => "数据源id不存在");
         }
         return $re;
     } catch (\Exception $e) {
         return array("returncode" => "9999", "msg" => $e->getMessage());
     }
 }
Example #7
0
 public function GetRoleDataByCode($code)
 {
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_ROLE, $code);
     if (empty($data)) {
         $sql = "select id,name,code from we_role where code=?";
         $para = array((string) $code);
         $data = $this->conn->GetData("dt", $sql, $para);
         $datarow = $data["dt"]["rows"];
         Cache_Enterprise::set(Cache_Enterprise::$EN_ROLE, $code, json_encode($datarow));
         return $data["dt"]["rows"];
     } else {
         return json_decode($data, true);
     }
 }
Example #8
0
 public function getInfoByName($name)
 {
     try {
         $data = Cache_Enterprise::get(Cache_Enterprise::$EN_INFO, md5($name), $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data) || $data == "null") {
         $photo_url = $this->container->getParameter('FILE_WEBSERVER_URL');
         $sql = " select a.*,concat('{$photo_url}',ifnull(a.logo_path,'')) logo_path,wc.circle_id,wc.circle_name from we_enterprise a " . " left join we_circle wc on a.eno=wc.enterprise_no and a.edomain=wc.network_domain where a.enoname=?";
         $params = array((string) $name);
         $ds = $this->da->Getdata('main', $sql, $params);
         $data = empty($ds) || count($ds["main"]["rows"]) == 0 ? null : $ds["main"]["rows"][0];
         Cache_Enterprise::set(Cache_Enterprise::$EN_INFO, md5($name), json_encode($data), 0, $this->container);
     } else {
         return json_decode($data, true);
     }
     return $data;
 }
Example #9
0
 private function updatedeptversion($im_deptid)
 {
     $conn_im = $this->containter->get("we_data_access_im");
     $cache = Cache_Enterprise::get("d_ver_", $im_deptid, $this->containter);
     if (!empty($cache)) {
         $cache = (int) $cache + 1;
         $conn_im->ExecSQL("update im_dept_version set version=? where us=?", array((string) $cache, (string) $im_deptid));
     } else {
         $conn_im = $this->containter->get("we_data_access_im");
         $sql = "select * from im_dept_version where us=?";
         $v_ds = $conn_im->GetData("t", $sql, array((string) $im_deptid));
         if (count($v_ds["t"]["rows"]) == 0) {
             $cache = 1;
             $conn_im->ExecSQL("insert into im_dept_version(us,version)values(?,?)", array((string) $im_deptid, (string) $cache));
         } else {
             $cache = (int) $v_ds["t"]["rows"][0]["version"] + 1;
             $conn_im->ExecSQL("update im_dept_version set version=? where us=?", array((string) $cache, (string) $im_deptid));
         }
         Cache_Enterprise::set("d_ver_", $im_deptid, (string) $cache, 0, $this->containter);
     }
 }
Example #10
0
 public function getDefaultDept($eno)
 {
     try {
         $result = Cache_Enterprise::get(Cache_Enterprise::$EN_DEPT . "_defaultdept", $eno, $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $result = null;
     }
     if (!empty($result)) {
         return json_decode($result, true);
     }
     $result = $this->getIdByName($eno, "体验部门");
     if (!empty($result)) {
         $result["dept_id"] = $result["deptid"];
     } else {
         //没有体验部门时获取根部门
         $rootdeptid = 'v' . $eno;
         $result = $this->getinfo($rootdeptid);
         $result["fafa_deptid"] = $rootdeptid;
     }
     Cache_Enterprise::set(Cache_Enterprise::$EN_DEPT . "_defaultdept", $eno, json_encode($result), 0, $this->container);
     return $result;
 }
Example #11
0
 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;
 }