function api_list()
{
$this->app_check("get");
if (!isset($this->appAllow["pm"]["list"])) {
$_arr_return = array("alert" => "x050319");
$_arr_logTarget[] = array("app_id" => $this->appRequest["app_id"]);
$_arr_logType = array("pm", "list");
$this->log_do($_arr_logTarget, "app", $_arr_return, $_arr_logType);
$this->obj_api->halt_re($_arr_return);
}
$_arr_userRow = $this->user_check("get");
$_num_perPage = fn_getSafe(fn_get("per_page"), "int", BG_SITE_PERPAGE);
$_str_pmIds = fn_getSafe(fn_get("pm_ids"), "txt", "");
$_str_type = fn_getSafe(fn_get("pm_type"), "txt", "");
$_str_status = fn_getSafe(fn_get("pm_status"), "txt", "");
$_str_key = fn_getSafe(fn_get("key"), "txt", "");
$_arr_sign = array("act_get" => $GLOBALS["act_get"], $this->userRequest["user_by"] => $this->userRequest["user_str"], "user_access_token" => $this->userRequest["user_access_token"], "pm_ids" => $_str_pmIds, "pm_type" => $_str_type, "pm_status" => $_str_status, "key" => $_str_key);
if (!fn_isEmpty(fn_get("per_page"))) {
$_arr_sign["per_page"] = $_num_perPage;
}
//file_put_contents(BG_PATH_ROOT . "debug.txt", json_encode($_arr_sign), FILE_APPEND);
if (!$this->obj_sign->sign_check(array_merge($this->appRequest, $_arr_sign), $this->appRequest["signature"])) {
$_arr_return = array("alert" => "x050403");
$this->obj_api->halt_re($_arr_return);
}
$_arr_pmIds = array();
if ($_str_pmIds) {
if (stristr($_str_pmIds, "|")) {
$_arr_pmIds = explode("|", $_str_pmIds);
} else {
$_arr_pmIds = array($_str_pmIds);
}
}
if (!$_str_type) {
$_arr_return = array("alert" => "x110218");
$this->obj_api->halt_re($_arr_return);
}
$_arr_search = array("type" => $_str_type, "status" => $_str_status, "key" => $_str_key, "pm_ids" => $_arr_pmIds);
switch ($_str_type) {
case "in":
$_arr_search["pm_to"] = $_arr_userRow["user_id"];
break;
case "out":
$_arr_search["pm_from"] = $_arr_userRow["user_id"];
break;
}
$_num_pmCount = $this->mdl_pm->mdl_count($_arr_search);
$_arr_page = fn_page($_num_pmCount);
$_arr_pmRows = $this->mdl_pm->mdl_list($_num_perPage, $_arr_page["except"], $_arr_search);
foreach ($_arr_pmRows as $_key => $_value) {
$_arr_pmRows[$_key]["fromUser"] = $this->mdl_user->mdl_read_api($_value["pm_from"]);
$_arr_pmRows[$_key]["toUser"] = $this->mdl_user->mdl_read_api($_value["pm_to"]);
if ($_str_type == "out") {
$_arr_sendRow = $this->mdl_pm->mdl_read($_value["pm_send_id"]);
if ($_arr_sendRow["alert"] != "y110102") {
$_arr_pmRows[$_key]["pm_send_status"] = "revoke";
} else {
$_arr_pmRows[$_key]["pm_send_status"] = $_arr_sendRow["pm_status"];
}
}
}
//print_r($_arr_pmRows);
$_arr_return = array("pmRows" => $_arr_pmRows, "pageRow" => $_arr_page);
$_str_src = fn_jsonEncode($_arr_return, "encode");
$_str_code = $this->obj_crypt->encrypt($_str_src, $this->appRow["app_key"]);
$_arr_return = array("code" => $_str_code, "alert" => "y110402");
$this->obj_api->halt_re($_arr_return);
}