本文整理匯總了PHP中Utility::getArrayForResults方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utility::getArrayForResults方法的具體用法?PHP Utility::getArrayForResults怎麽用?PHP Utility::getArrayForResults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Utility
的用法示例。
在下文中一共展示了Utility::getArrayForResults方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadList
/**
* load文件並給與權限判斷
*/
protected static function loadList($p_where = null, $p_order = null, $p_pageIndex = null, $p_pageSize = null, &$p_countThis = null, $isDetail = false)
{
$tmpResult = parent::loadList($p_where, $p_order, $p_pageIndex, $p_pageSize, $p_countThis, $isDetail);
if (is_array($tmpResult) && array_key_exists('errorCode', $tmpResult)) {
return $tmpResult;
}
switch ($auth = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), $isDetail ? 'detail' : 'list', $tmpResult)) {
case 'admin':
//有管理權限
//有管理權限
case 'self':
//作者
break;
case 'normal':
//正常用戶
//正常用戶
case 'draft':
//未激活
//未激活
case 'pending':
//待審禁言
//待審禁言
case 'disabled':
//封號
//封號
case 'visitor':
//遊客
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
case 'empty':
//空
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_DATA_EMPTY, '不存在對應數據');
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
}
PersonModel::$authViewDisabled = static::$authViewDisabledList[$auth];
return $tmpResult;
}
示例2: actionUploadMultipleFiles
/**
* 一次選中多個文件進行上傳,請使用name="files[]" multiple="multiple"上傳
* <input type="file" accept="image/gif, image/jpeg, image/png, image/jpg" name="files[]" multiple="multiple">
* @return string[] 多個來自七牛的預覽網址
*/
public static function actionUploadMultipleFiles()
{
$fileSizeMax = 5 * 1024 * 1024;
$fileTypeAllowed = array('jpg', 'png', 'jpeg', 'gif', 'doc', 'docx', 'pdf');
if (!array_key_exists('files', $_FILES) || count($_FILES['files']) == 0) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_UNKNOWN, '沒有發現上傳的文件,請檢查。');
}
$upload_file = $_FILES['files'];
$previewUrls = array();
for ($i = 0; $i < count($upload_file['name']); $i++) {
if ($upload_file["size"][$i] > 0) {
$file_tmp_path = $upload_file["tmp_name"][$i];
$file_type = pathinfo($upload_file["name"][$i], PATHINFO_EXTENSION);
if (isset($fileTypeAllowed) && !in_array(strtolower($file_type), $fileTypeAllowed)) {
Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '提示:不支持上傳該' . $file_type . '類型的文件,支持:' . implode('、', $fileTypeAllowed));
}
if ($upload_file["size"] > $fileSizeMax) {
Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '錯誤,文件大小不可超過' . $fileSizeMax . '字節。');
}
if ($upload_file["size"][$i] > 5 * 1024 * 1024) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_UNKNOWN, '錯誤,文件大小不可超過5MB。');
}
$file_tmp_path_type = $file_tmp_path . '.' . $file_type;
rename($file_tmp_path, $file_tmp_path_type);
$previewUrls[] = W2Qiniu::uploadAndReturnQiniuPreviewUrl($file_tmp_path_type);
}
}
return Utility::getArrayForResults(RUNTIME_CODE_OK, '', $previewUrls);
}
示例3: actionList
public static function actionList()
{
switch ($auther = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), 'list')) {
case 'admin':
//有管理權限
if (Utility::getCurrentUserID('uid') != null) {
$p_where['userid'] = W2HttpRequest::getRequestInt('uid');
}
//管理員可以篩選用戶
if (W2HttpRequest::getRequestInt('jobareaid') != null) {
$p_where['jobareaid'] = W2HttpRequest::getRequestInt('jobareaid');
}
//管理員可以篩選地區
if (W2HttpRequest::getRequestString('jobstartdate') != null) {
$p_where['jobstartdate >= \'%s\''] = W2HttpRequest::getRequestString('jobstartdate');
}
//管理員可以篩選開始時間
if (W2HttpRequest::getRequestString('jobenddate') != null) {
$p_where['jobenddate <= \'%s\''] = W2HttpRequest::getRequestString('jobenddate');
}
//管理員可以篩選結束時間
break;
case 'self':
//作者
//作者
case 'normal':
//正常用戶
$p_where['userID'] = Utility::getCurrentUserID('userid');
case 'draft':
//未激活
//未激活
case 'pending':
//待審禁言
//待審禁言
case 'disabled':
//封號
//封號
case 'visitor':
//遊客
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
}
$_order = W2HttpRequest::getRequestString('order', false, '');
switch (strtolower($_order)) {
case 'id':
case 'userid':
//用戶ID
//用戶ID
case 'jobAreaID':
//地區ID
//地區ID
case 'jobStartDate':
//開始時間
//開始時間
case 'jobEndDate':
//結束時間
$p_order = $_order;
break;
case '':
case 'default':
$p_order = 'id';
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請使用可選的排序方案。');
break;
}
$p_countThis = -1;
return static::aList($p_where, $p_order, $p_pageIndex = null, $p_pageSize = null, $p_countThis, $isDetail = false);
}
示例4: actionList
public static function actionList()
{
$p_where['status'] = STATUS_NORMAL;
//默認列表頁隻篩選STATUS_NORMAL狀態的數據
//根據權限不同,支持的篩選功能也可以不同
switch ($auther = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), 'list')) {
case 'admin':
//有管理權限
$p_where['status'] = W2HttpRequest::getRequestInt('status');
//管理員可以篩選狀態'
$p_where['userID'] = W2HttpRequest::getRequestInt('uid');
//管理員可以篩選用戶ID'
break;
case 'self':
//作者
$p_where['userID'] = Utility::getCurrentUserID();
break;
case 'normal':
//正常用戶
//正常用戶
case 'draft':
//未激活
//未激活
case 'pending':
//待審禁言
//待審禁言
case 'disabled':
//封號
//封號
case 'visitor':
//遊客
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
}
$_order = W2HttpRequest::getRequestString('order', false, '');
switch (strtolower($_order)) {
case 'id':
case 'userid':
//發布用戶ID
//發布用戶ID
case 'status':
//0: 不存在 1: 正常 2: 草稿 3:待審
//0: 不存在 1: 正常 2: 草稿 3:待審
case 'createtime':
//創建時間
//創建時間
case 'modifytime':
//修改時間
$p_order = $_order;
break;
case '':
case 'default':
$p_order = 'id';
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請使用可選的排序方案。');
break;
}
$p_countThis = -1;
return static::aList($p_where, $p_order, $p_pageIndex = null, $p_pageSize = null, $p_countThis, $isDetail = false);
}
示例5: actionCheckVerifyCode
public static function actionCheckVerifyCode()
{
$isRight = SmsVerifyHandler::isSmsVerifyRight(W2HttpRequest::getRequestTelephone('telephone'), W2HttpRequest::getRequestString('verifycode'));
if ($isRight) {
return Utility::getArrayForResults(RUNTIME_CODE_OK, '', true, '正確');
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '驗證碼錯誤');
}
}
示例6: actionList
public static function actionList()
{
$status = W2HttpRequest::getRequestInt('status');
$p_where = array();
switch ($auther = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), 'list')) {
case 'admin':
//有管理權限
$p_where['bossID'] = W2HttpRequest::getRequestInt('userid');
$p_where['status'] = W2HttpRequest::getRequestInt('status', null, true, false, STATUS_NORMAL);
//管理員可以篩選數據狀態
break;
case 'self':
//作者
//作者
case 'normal':
//正常用戶
$p_where['bossID'] = Utility::getCurrentUserID();
if ($status == 0) {
$p_where['status'] = STATUS_NORMAL;
} else {
$p_where['status'] = W2HttpRequest::getRequestInt('status', null, true, false, STATUS_NORMAL);
//用戶可以篩選數據狀態
}
break;
case 'draft':
//未激活
//未激活
case 'pending':
//待審禁言
//待審禁言
case 'disabled':
//封號
//封號
case 'visitor':
//遊客
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
}
$_order = W2HttpRequest::getRequestString('order', false, '');
switch (strtolower($_order)) {
case 'id':
case 'userid':
//用戶ID
//用戶ID
case 'bossid':
//技能名稱 認證後不可更改
//技能名稱 認證後不可更改
case 'missionid':
//技能認證日期
//技能認證日期
case 'countdays':
//認證機構
//認證機構
case 'status':
//認證狀態 0未認證 1已認證 2認證失敗
$p_order = $_order;
break;
case '':
case 'default':
$p_order = 'id';
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請使用可選的排序方案。');
break;
}
$p_countThis = -1;
return static::aList($p_where, $p_order, $p_pageIndex = null, $p_pageSize = null, $p_countThis, $isDetail = false);
}
示例7: pushMessage
/**
* 推送接口
* @param int $push_type 1單個設備 2部分人(*常用) 3所有人
* @param int $device_type 設備類型 1:瀏覽器設備 2:pc設備 3:Android設備 4:ios設備 5:windows phone設備
* @param string $title 標題(僅安卓)
* @param string $content 留言正文
* @param int $customtype 自定義類型,t
* @param string $customvalue 自定義值,v
* @param string $p_buserid 用戶推送ID,百度裏是buserid
* @param string $tag_name 指定標簽
* @return array results
*/
public static function pushMessage($push_type, $device_type, $title = '', $content, $customtype = null, $customvalue = null, $p_buserid = null, $tag_name = null)
{
$message_keys = uniqid();
//函數基於以微秒計的當前時間,生成一個唯一的 ID。
$channel = new Channel(W2PUSH::$API_KEY, W2PUSH::$SECRET_KEY);
if (isset($tag_name)) {
$optional[Channel::TAG_NAME] = $tag_name;
}
$optional[Channel::MESSAGE_TYPE] = 1;
//通知
$optional[Channel::DEPLOY_STATUS] = static::$DEPLOY_STATUS;
//1 測試狀態 2生產狀態
switch ($push_type) {
case 1:
if ($p_buserid === null) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請傳入正確的用戶推送ID');
}
$optional[Channel::USER_ID] = $p_buserid;
case 2:
$optional[Channel::DEVICE_TYPE] = $device_type;
if ($device_type == 4) {
$messages = '{' . '"aps":{' . '"alert":"' . $content . '",' . '"sound":"",' . '"badge":1' . '}';
if (isset($customtype, $customvalue)) {
$messages .= ',"t":' . intval($customtype) . ',"v":"' . $customvalue . '"';
}
$messages .= '}';
} else {
if ($device_type == 3) {
$messages = '{' . '"title": "' . $title . '",' . '"description": "' . $content . '",' . '"notification_builder_id": 0,' . '"notification_basic_style": 7,' . '"open_type": 2,' . '"net_support" : 1,' . '"pkg_content" : ",' . '"custom_content": {"t":' . intval($customtype) . ',"v":"' . $customvalue . '"}' . '}';
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請傳入正確的設備類型,iOS 還是 安卓');
}
}
$ret = $channel->pushMessage($push_type, $messages, $message_keys, $optional);
break;
case 3:
$ret = $channel->pushMessage($push_type, $messages, $message_keys);
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, 'push_type 1:單個人 2部分人 3所有人');
}
if (false === $ret) {
$ret = array();
$ret[] = 'WRONG, ' . __FUNCTION__ . ' ERROR!!!!!';
$ret[] = 'ERROR NUMBER: ' . $channel->errno();
$ret[] = 'ERROR MESSAGE: ' . $channel->errmsg();
$ret[] = 'REQUEST ID: ' . $channel->getRequestId();
}
return Utility::getArrayForResults(RUNTIME_CODE_OK, '', array('push_type' => $push_type, 'messages' => $messages, 'message_keys' => $message_keys, 'optional' => $optional, 'result' => $ret));
}
示例8: pushMessage
/**
* 推送接口
* @param int $push_type 1單個設備 2部分人(*常用)
* @param int $device_type 設備類型 1:瀏覽器設備 2:pc設備 3:Android設備 4:ios設備 5:windows phone設備
* @param string $title 標題(僅安卓)
* @param string $content 留言正文
* @param int $customtype 自定義類型,t
* @param string $customvalue 自定義值,v
* @param string $p_deviceToken 用戶推送ID,百度裏是buserid
* @param string $tag_name 指定標簽
* @return array results
*/
public static function pushMessage($push_type, $device_type, $title = '', $content, $customtype = null, $customvalue = null, $p_deviceToken = null, $tag_name = null)
{
$notification = new W2PUSH();
$notification->setAppMasterSecret(W2PUSH::$SECRET_KEY);
$params = $notification->getData();
$params['appkey'] = W2PUSH::$API_KEY;
$params['timestamp'] = strval(time());
if ($device_type == 4) {
$params['payload'] = array('aps' => array('alert' => $content));
if (isset($customtype, $customvalue)) {
$params['payload']['t'] = intval($customtype);
$params['payload']['v'] = $customvalue;
}
} else {
if ($device_type == 3) {
if ($title == '') {
$title = $content;
}
$params['payload'] = array();
$params['payload']['display_type'] = 'notification';
$params['payload']['body'] = array();
$params['payload']['body']['ticker'] = $title;
$params['payload']['body']['title'] = $title;
$params['payload']['body']['text'] = $content;
$params['payload']['body']['after_open'] = 'go_app';
if (isset($customtype, $customvalue)) {
$params['payload']['extra'] = array();
$params['payload']['extra']['t'] = intval($customtype);
$params['payload']['extra']['v'] = $customvalue;
}
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請傳入正確的設備類型,iOS 還是 安卓');
}
}
$params['production_mode'] = static::$DEPLOY_STATUS == 2;
//是否正式環境
switch ($push_type) {
case 1:
$p_deviceToken = is_array($p_deviceToken) ? $p_deviceToken : explode(',', $p_deviceToken);
if (count($p_deviceToken) == 0 || count($p_deviceToken) == 1 && $p_deviceToken[0] == null) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請傳入正確的用戶推送ID');
} else {
if (count($p_deviceToken) < 500) {
if (count($p_deviceToken) > 1) {
$params['type'] = 'listcast';
} else {
$params['type'] = 'unicast';
}
$params['device_tokens'] = implode(',', $p_deviceToken);
} else {
$params['type'] = 'filecast';
$notification->uploadContents(implode("\n", $p_deviceToken));
}
}
break;
case 2:
$params['type'] = 'groupcast';
$params['filter'] = array('where' => array('and' => array()));
if ($tag_name != null) {
$tag_name = is_array($tag_name) ? $tag_name : explode(',', $tag_name);
foreach ($tag_name as $tag) {
$params['filter']['where']['and'][] = array('tag' => $tag);
}
}
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, 'push_type 1:單個人 2部分人 3所有人');
}
$notification->setData($params);
try {
$ret = $notification->send();
} catch (Exception $e) {
$ret = 'Caught exception: ' . $e->getMessage();
}
return Utility::getArrayForResults(RUNTIME_CODE_OK, '', array('push_type' => $push_type, 'messages' => $params['payload'], 'message_keys' => $params['timestamp'], 'optional' => $params, 'result' => $ret));
}
示例9: actionList
public static function actionList()
{
$p_where = array();
$p_where['status'] = STATUS_NORMAL;
//根據權限不同,支持的篩選功能也可以不同
switch ($auther = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), 'list')) {
case 'admin':
//有管理權限
$p_where['status'] = W2HttpRequest::getRequestInt('status');
//管理員可以篩選狀態
//管理員可以篩選狀態
case 'self':
//作者
//作者
case 'normal':
//正常用戶
$p_where['areaId'] = W2HttpRequest::getRequestInt('areaId');
//用戶可以篩選地區
$p_where['schoolName like \'%%%s%%\''] = W2HttpRequest::getRequestString('schoolName');
//用戶可以篩選學校
$p_where['jiben'] = W2HttpRequest::getRequestString('jiben');
//用戶可以篩選本科類別
//用戶可以篩選本科類別
case 'draft':
//未激活
//未激活
case 'pending':
//待審禁言
//待審禁言
case 'disabled':
//封號
//封號
case 'visitor':
//遊客
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
}
$p_countThis = -1;
return static::aList($p_where, $p_order = null, $p_pageIndex = null, $p_pageSize = null, $p_countThis, $isDetail = false);
}
示例10: actionList1
public static function actionList1()
{
$p_where = array();
$p_where['status'] = STATUS_NORMAL;
//根據權限不同,支持的篩選功能也可以不同
switch ($auther = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), 'list')) {
case 'admin':
//有管理權限
$p_where['status'] = W2HttpRequest::getRequestInt('status');
//管理員可以篩選狀態
//管理員可以篩選狀態
case 'self':
//作者
//作者
case 'normal':
//正常用戶
$fid = W2HttpRequest::getRequestInt('fid');
if (empty($fid)) {
$p_where['fID'] = 0;
} else {
$p_where['fID'] = $fid;
}
$p_where['majorname like \'%%%s%%\''] = W2HttpRequest::getRequestString('majorname');
case 'draft':
//未激活
//未激活
case 'pending':
//待審禁言
//待審禁言
case 'disabled':
//封號
//封號
case 'visitor':
//遊客
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
}
$a = MajorHandler::getList($p_where, $content = array());
var_dump($a);
// $p_countThis = -1;
// return static::aList($p_where,$p_order = null,$p_pageIndex=null,$p_pageSize=null,$p_countThis,$isDetail = false);
}
示例11: reloadAreaList
public static function reloadAreaList($areaList)
{
// var_export($areaList);
$dataList = array();
foreach ($areaList as $area) {
$aM = (string) $area['areaMain'];
$aS = (string) $area['areaSecond'];
$aT = (string) $area['areaThird'];
// $aS= $aS==0?$aM:$aS;
// $aT= $aT==0?($aS==0?$aM:$aS):$aT;
if (!array_key_exists($aM, $dataList)) {
$dataList[$aM] = array();
$dataList[$aM]['areaID'] = $aM;
$dataList[$aM]['areaName'] = AreaHandler::loadAreaNameById($aM);
$dataList[$aM]['areaNameLocal'] = AreaHandler::loadAreaNameById($aM);
$dataList[$aM]['areaNameList'] = array(AreaHandler::loadAreaNameById($aM));
$dataList[$aM]['areaIDList'] = AreaHandler::getAreaInfo($dataList[$aM]['areaID']);
$dataList[$aM]['childs'] = array();
}
if ($aS > 0) {
$dataList[$aM]['childs'][$aM] = array();
$dataList[$aM]['childs'][$aM]['areaID'] = $aM;
$dataList[$aM]['childs'][$aM]['areaName'] = AreaHandler::loadAreaNameById($aM);
$dataList[$aM]['childs'][$aM]['areaNameLocal'] = '全部';
$dataList[$aM]['childs'][$aM]['areaNameList'] = $dataList[$aM]['areaNameList'];
$dataList[$aM]['childs'][$aM]['areaIDList'] = AreaHandler::getAreaInfo($dataList[$aM]['childs'][$aM]['areaID']);
$dataList[$aM]['childs'][$aM]['childs'] = array();
if (!array_key_exists($aS, $dataList[$aM]['childs'])) {
$dataList[$aM]['childs'][$aS] = array();
$dataList[$aM]['childs'][$aS]['areaID'] = $aS == 0 ? $aM : $aS;
$dataList[$aM]['childs'][$aS]['areaName'] = AreaHandler::loadAreaNameById($aS);
$dataList[$aM]['childs'][$aS]['areaNameLocal'] = AreaHandler::loadAreaNameById($aS);
$dataList[$aM]['childs'][$aS]['areaNameList'] = array_merge($dataList[$aM]['areaNameList'], array($dataList[$aM]['childs'][$aS]['areaNameLocal']));
$dataList[$aM]['childs'][$aS]['areaIDList'] = AreaHandler::getAreaInfo($dataList[$aM]['childs'][$aS]['areaID']);
$dataList[$aM]['childs'][$aS]['childs'] = array();
}
if ($aT > 0) {
$dataList[$aM]['childs'][$aS]['childs'][$aS] = array();
$dataList[$aM]['childs'][$aS]['childs'][$aS]['areaID'] = $aS;
$dataList[$aM]['childs'][$aS]['childs'][$aS]['areaName'] = AreaHandler::loadAreaNameById($aS);
$dataList[$aM]['childs'][$aS]['childs'][$aS]['areaNameLocal'] = '全部';
$dataList[$aM]['childs'][$aS]['childs'][$aS]['areaNameList'] = $dataList[$aM]['childs'][$aS]['areaNameList'];
$dataList[$aM]['childs'][$aS]['childs'][$aS]['areaIDList'] = AreaHandler::getAreaInfo($dataList[$aM]['childs'][$aS]['childs'][$aS]['areaID']);
$dataList[$aM]['childs'][$aS]['childs'][$aT] = array();
$dataList[$aM]['childs'][$aS]['childs'][$aT]['areaID'] = $aT == 0 ? $aS == 0 ? $aM : $aS : $aT;
$dataList[$aM]['childs'][$aS]['childs'][$aT]['areaName'] = AreaHandler::loadAreaNameById($aT);
$dataList[$aM]['childs'][$aS]['childs'][$aT]['areaNameLocal'] = AreaHandler::loadAreaNameById($aT);
$dataList[$aM]['childs'][$aS]['childs'][$aT]['areaNameList'] = array_merge($dataList[$aM]['childs'][$aS]['areaNameList'], array($dataList[$aM]['childs'][$aS]['childs'][$aT]['areaNameLocal']));
$dataList[$aM]['childs'][$aS]['childs'][$aT]['areaIDList'] = AreaHandler::getAreaInfo($dataList[$aM]['childs'][$aS]['childs'][$aT]['areaID']);
}
}
}
$outType = W2HttpRequest::getRequestString('outtype');
if ($outType == 'array') {
$result = array();
foreach ($dataList as $data) {
$data['subs'] = array();
foreach ($data['childs'] as $areaSecond => $da) {
$da['subs'] = array();
foreach ($da['childs'] as $areaThird => $d) {
$da['subs'][] = $d;
}
unset($da['childs']);
$data['subs'][] = $da;
}
unset($data['childs']);
$result[] = $data;
}
return Utility::getArrayForResults(RUNTIME_CODE_OK, '', $result);
}
return Utility::getArrayForResults(RUNTIME_CODE_OK, '', $dataList);
}
示例12: actionEvaluationList
public static function actionEvaluationList()
{
$p_where = array();
$p_where['status'] = STATUS_NORMAL;
//默認列表頁隻篩選STATUS_NORMAL狀態的數據
$p_where['missionStatus'] = 31;
//0: 不存在 11: 接受報名並已預付款 21: 確認完成並付款 31:已評價
$p_where['qualityRate'] = W2HttpRequest::getRequestInt('qualityrate');
//服務質量評分
$p_where['manneryRate'] = W2HttpRequest::getRequestInt('manneryrate');
//服務態度評分
$p_where['speedRate'] = W2HttpRequest::getRequestInt('speedrate');
//服務速度評分
$p_where['commentContent'] = W2HttpRequest::getRequestString('commentcontent', false);
//評語留言
$p_where['createTime >= \'%s\''] = W2HttpRequest::getRequestDateTime('createtimestart');
//創建時間
$p_where['createTime < \'%s\''] = W2HttpRequest::getRequestDateTime('createtimeend');
//創建時間
$p_where['modifyTime >= \'%s\''] = W2HttpRequest::getRequestDateTime('modifytimestart');
//修改時間
$p_where['modifyTime < \'%s\''] = W2HttpRequest::getRequestDateTime('modifytimeend');
//修改時間
switch ($auther = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), 'list')) {
case 'admin':
//有管理權限
$p_where['userID'] = W2HttpRequest::getRequestInt('userid');
//管理員可以篩選用戶ID
$p_where['id in (%s)'] = W2HttpRequest::getRequestArrayString('ids', false, true);
$p_where['id'] = W2HttpRequest::getRequestInt('id');
$p_where['jobID'] = W2HttpRequest::getRequestInt('jobid');
//任務ID
$p_where['status'] = W2HttpRequest::getRequestInt('status', null, true, false, STATUS_NORMAL);
//管理員可以篩選數據狀態
$p_where['missionStatus'] = W2HttpRequest::getRequestInt('missionstatus');
//0: 不存在 11: 接受報名並已預付款 21: 確認完成並付款 31:已評價
//0: 不存在 11: 接受報名並已預付款 21: 確認完成並付款 31:已評價
case 'self':
//作者
//作者
case 'normal':
//正常用戶
if ($auther == 'normal') {
$p_where['userID'] = Utility::getCurrentUserID();
//普通用戶,默認隻能篩選自己名下數據。
}
case 'draft':
//未激活
//未激活
case 'pending':
//待審禁言
//待審禁言
case 'disabled':
//封號
//封號
case 'visitor':
//遊客
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您沒有權限執行該操作');
break;
}
$_order = W2HttpRequest::getRequestString('order', false, '');
switch (strtolower($_order)) {
case 'id':
case 'userid':
//用戶ID
//用戶ID
case 'jobid':
//任務ID
//任務ID
case 'bossid':
//雇主ID
//雇主ID
case 'qualityrate':
//服務質量評分
//服務質量評分
case 'manneryrate':
//服務態度評分
//服務態度評分
case 'speedrate':
//服務速度評分
//服務速度評分
case 'commentcontent':
//評語留言
//評語留言
case 'createtime':
//創建時間
//創建時間
case 'modifytime':
//修改時間
$p_order = $_order;
break;
case '':
case 'default':
$p_order = 'id';
break;
default:
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請使用可選的排序方案。');
break;
//.........這裏部分代碼省略.........
示例13: payAction
/**
* 操作用於金額,並記錄
* @param int $p_userID 用戶ID
* @param string $p_payName 款項說明
* @param int $p_payType 操作類型
* @param double $p_money 涉及金額
* @param int $p_eventID 事件ID
* @return PayLogModel 記錄Model
*/
public static function payAction($p_userID, $p_payName, $p_payType, $p_money, $p_eventID)
{
$userModel = UserHandler::loadModelById($p_userID);
if (is_object($userModel)) {
if ($p_money < 0 && $userModel->getMoney() + $p_money < 0) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_MONEY_OUT, '用戶餘額不足,無法扣款。');
}
if ($p_money != 0 && $p_payType > 100) {
UserHandler::update(array('money = money ' . ($p_money > 0 ? '+' : '') . $p_money), array('id' => $userModel->getId()));
}
$tmpModel = new PayLogModel();
$tmpModel->setCreateTime(date('Y-m-d H:i:s'));
$tmpModel->setModifyTime(date('Y-m-d H:i:s'));
$tmpModel->setUserID($p_userID);
$tmpModel->setPayName($p_payName);
$tmpModel->setPayType($p_payType);
$tmpModel->setMoney($p_money);
$tmpModel->setEventID($p_eventID);
return static::saveModel($tmpModel);
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '用戶不存在');
}
}
示例14: list
//加載配置文件
require_once __DIR__ . '/../config.php';
//常用常量
require_once AXAPI_ROOT_PATH . '/components/constants.php';
//數據庫操作工具
require_once AXAPI_ROOT_PATH . '/lib/DBTool/DBModel.php';
//加載基礎方法
require_once AXAPI_ROOT_PATH . '/components/Utility.php';
$results = Utility::getAuthForApiRequest();
if ($results['errorCode'] == RUNTIME_CODE_OK) {
try {
list($apiController, $apiAction) = explode("/", W2HttpRequest::getRequestString('r', false, '/'), 2);
$method = new ReflectionMethod($apiController . 'Controller', 'action' . $apiAction);
$results = $method->invoke(null, 0);
} catch (Exception $e) {
$results = Utility::getArrayForResults(RUNTIME_CODE_ERROR_UNKNOWN, $e->getMessage(), null, array('errorContent' => 'Error on line ' . $e->getLine() . ' in ' . $e->getFile() . ': ' . $e->getMessage() . ''));
}
}
if (is_array($results) && array_key_exists('errorCode', $results)) {
$data = $results['results'];
if (is_object($results['results']) && is_subclass_of($results['results'], 'AbstractModel')) {
$data = $results['results']->properties();
} else {
if (is_array($results['results']) && array_key_exists(0, $results['results'])) {
$data = array();
foreach ($results['results'] as $_key => $_value) {
if (is_object($_value) && is_subclass_of($_value, 'AbstractModel')) {
$data[$_key] = $_value->properties();
} else {
$data[$_key] = $_value;
}
示例15: getAuthForApiRequest
public static function getAuthForApiRequest()
{
$isAuthed = false;
$_HEADERS = Utility::getallheadersUcfirst();
if (array_key_exists('Signature', $_HEADERS)) {
//定義一個空的數組
$tmpArr = array();
//將所有頭信息和數據組合成字符串格式:%s=%s,存入上麵的數組
foreach (array('Clientversion', 'Devicetype', 'Devicetoken', 'Requesttime', 'Userid', 'Logintime', 'Checkcode') as $_key) {
if (array_key_exists($_key, $_HEADERS)) {
array_push($tmpArr, sprintf('%s=%s', $_key, $_HEADERS[$_key]));
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請求信息錯誤', array('errorContent' => '缺少頭信息:' . $_key));
}
}
if (abs($_HEADERS['Requesttime'] - time()) > 7 * 24 * 60 * 60) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '該操作已過期,請重試。');
}
//同樣的,將所有表單數據也組成字符串後,放入數組。(注:file類型不包含)
foreach ($_REQUEST as $_key => $_value) {
array_push($tmpArr, sprintf('%s=%s', $_key, $_value));
}
//最後,將一串約定好的密鑰字符串也放入數組。(不同的項目甚至不同的版本中,可以使用不同的密鑰)
switch ($_HEADERS['Devicetype']) {
case 1:
//瀏覽器設備
array_push($tmpArr, SECRET_HAX_BROWSER);
break;
case 2:
//pc設備,服務器
array_push($tmpArr, SECRET_HAX_PC);
break;
case 3:
//安卓
array_push($tmpArr, SECRET_HAX_ANDROID);
break;
case 4:
//iOS
array_push($tmpArr, SECRET_HAX_IOS);
break;
case 5:
//WP
array_push($tmpArr, SECRET_HAX_WINDOWS);
break;
default:
array_push($tmpArr, SECRET_HAX_PC);
break;
}
//對數組進行自然排序
sort($tmpArr, SORT_STRING);
//將排序後的數組組合成字符串
$tmpStr = implode($tmpArr);
//對這個字符串進行MD5加密,即可獲得Signature
$tmpStr = md5($tmpStr);
if ($tmpStr != $_HEADERS['Signature']) {
$isAuthed = array('status' => false, 'tmpArr' => $tmpArr, 'tmpArrString' => implode($tmpArr), 'tmpArrMd5' => $tmpStr);
} else {
$isAuthed = true;
// print('Success of auth');
}
} else {
if (false) {
$isAuthed = true;
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '請求信息錯誤', array('errorContent' => '缺少頭信息:' . 'signature'));
}
}
if ($isAuthed === true) {
return Utility::getArrayForResults(RUNTIME_CODE_OK, '', $isAuthed);
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '校驗失敗', defined('IS_SQL_PRINT') && IS_SQL_PRINT ? $isAuthed : '');
}
}