Ejemplo n.º 1
0
 public static function push($type, $toUid, $push)
 {
     !is_array($toUid) && ($toUid = explode(",", $toUid));
     $imCfg = array();
     foreach (Ibos::app()->setting->get("setting/im") as $imType => $config) {
         if ($config["open"] == "1") {
             $className = "ICIM" . ucfirst($imType);
             $imCfg = $config;
             break;
         }
     }
     if (!empty($imCfg)) {
         $factory = new ICIMFactory();
         $properties = array_merge($push, array("uid" => $toUid, "pushType" => $type));
         $adapter = $factory->createAdapter($className, $imCfg, $properties);
         return $adapter !== false ? $adapter->push() : "";
     }
 }
Ejemplo n.º 2
0
 public function actionSyncUser()
 {
     $type = EnvUtil::getRequest("type");
     $uid = StringUtil::filterStr(EnvUtil::getRequest("uid"));
     $flag = intval(EnvUtil::getRequest("flag"));
     $pwd = EnvUtil::getRequest("pwd");
     if (MessageUtil::getIsImOpen($type)) {
         $im = Ibos::app()->setting->get("setting/im");
         $imCfg = $im[$type];
         $className = "ICIM" . ucfirst($type);
         $factory = new ICIMFactory();
         $properties = array("uid" => explode(",", $uid), "syncFlag" => $flag);
         if ($type == "rtx") {
             $properties["pwd"] = $pwd;
         }
         $adapter = $factory->createAdapter($className, $imCfg, $properties);
         return $adapter !== false ? $adapter->syncUser() : EnvUtil::iExit("初始化IM组件失败");
     } else {
         EnvUtil::iExit("未开启IM绑定");
     }
 }
Ejemplo n.º 3
0
    $cfg = $im["qq"];
    if (isset($cfg["checkpass"]) && $cfg["checkpass"] == "1") {
        if (!empty($cfg["refresh_token"]) && !empty($cfg["time"])) {
            $secs = TIMESTAMP - $im["time"];
            if (!empty($cfg["expires_in"])) {
                $leftsecs = $cfg["expires_in"] - $secs;
                if ($leftsecs / 86400 < 7) {
                    $neededUpgrade = true;
                }
            } else {
                $neededUpgrade = true;
            }
        }
    }
    if ($neededUpgrade) {
        $factory = new ICIMFactory();
        $adapter = $factory->createAdapter("ICIMQq", $cfg);
        $api = $adapter->getApi();
        $infoJson = $api->getRefreshToken(array("app_id" => $cfg["appid"], "app_secret" => $cfg["appsecret"], "refresh_token" => $cfg["refresh_token"]));
        $info = CJSON::decode($infoJson);
        if (isset($info["ret"]) && $info["ret"] == 0) {
            $cfg["token"] = $info["data"]["company_token"];
            $cfg["refresh_token"] = $info["data"]["refresh_token"];
            $cfg["expires_in"] = $info["data"]["expires_in"];
            $cfg["time"] = time();
            $im["qq"] = $cfg;
            Setting::model()->updateSettingValueByKey("im", $im);
            CacheUtil::update(array("setting"));
        }
    }
}
Ejemplo n.º 4
0
 public function actionBindingUser()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $map = filter_input(INPUT_POST, "map", FILTER_SANITIZE_STRING);
         if (!empty($map)) {
             UserBinding::model()->deleteAllByAttributes(array("app" => "bqq"));
             $maps = explode(",", $map);
             foreach ($maps as $relation) {
                 list($uid, $openId) = explode("=", $relation);
                 UserBinding::model()->add(array("uid" => $uid, "bindvalue" => $openId, "app" => "bqq"));
             }
             $this->ajaxReturn(array("isSuccess" => true));
         }
         $this->ajaxReturn(array("isSuccess" => false));
     } elseif (MessageUtil::getIsImOpen("qq")) {
         $imCfg = Ibos::app()->setting->get("setting/im/qq");
         $factory = new ICIMFactory();
         $adapter = $factory->createAdapter("ICIMQq", $imCfg);
         $api = $adapter->getApi();
         $rs = $api->getUserList(array("timestamp" => 0));
         $bqqUsers = array();
         if (substr($rs, 0, 5) !== "error") {
             $rsArr = json_decode($rs, true);
             if (isset($rsArr["ret"]) && $rsArr["ret"] == 0) {
                 $bqqUsers = $rsArr["data"]["items"];
             }
         }
         $data = array("ibosUsers" => UserUtil::loadUser(), "binds" => UserBinding::model()->fetchAllSortByPk("uid", "app = 'bqq'"), "bqqUsers" => $bqqUsers);
         $this->renderPartial("qqbinding", $data);
     }
 }