/** * function getCategory returns the category of given $type * @param $type |string * @return array of guide **/ function getCategory() { $cols = " DISTINCT(" . getConfig("CATEGORY_GUIDES") . ") as category "; $whr = "blocked='false' "; $whr .= getAPIListWhere("api"); $sql = _db()->_selectQ('guides_tbl', $cols, $whr); $res = _dbQuery($sql); $data = _dbData($res); $categoryArray = array(); $i = 0; foreach ($data as $d) { $categoryArray[$i] = $d['category']; $i++; } return $categoryArray; }
/** * function getApiDetails returns api details with examples and comments * @param $id |md5() * @return $data |array **/ function getApiDetails($id) { $cols = " *,src_name as subcategory,lgks_type as category"; $whr = "blocked='false' AND md5(id)='" . $id . "'"; $whr .= getAPIListWhere("api"); $sql = _db()->_selectQ('api_toc', $cols, $whr); $res = _dbQuery($sql); if ($res) { $data = _dbFetch($res); _dbFree($res); if (isset($data['author'])) { $data['authorid'] = extractUserID($data['author']); } else { $data['authorid'] = ""; } if (isset($data['creator'])) { $data['creatorid'] = extractUserID($data['creator']); } else { $data['creatorid'] = ""; } if ($data['authorid'] == $_SESSION['SESS_USER_ID'] || $data['creatorid'] == $_SESSION['SESS_USER_ID']) { $data['editable'] = "true"; $data['edit_url'] = _link("api/edit/") . md5($data['id']); } elseif (checkUserRoles("api", "Allow Editing ALL API")) { $data['editable'] = "true"; $data['edit_url'] = _link("api/edit/") . md5($data['id']); } else { $data['editable'] = "false"; } $data['defination'] = stripslashes($data['defination']); $data['addExample'] = _link("api/createExample/") . $data['id']; //getcomments $cols = " id,comment,username,userid,dtoc"; $whr = "api_id='" . $data['id'] . "' AND approved='true'"; $sql = _db()->_selectQ('api_comments', $cols, $whr); $res = _dbQuery($sql); $comments = _dbData($res); $data['comments'] = $comments; //getexamples $cols = " id,eg_descs,eg_php,eg_author,dtoe"; $whr = "api_id='" . $data['id'] . "' AND locked='true'"; $sql = _db()->_selectQ('api_examples', $cols, $whr); $res = _dbQuery($sql); $examples = _dbData($res); _dbFree($res); $i = 0; foreach ($examples as $example) { if (isset($example['eg_author'])) { $example['eg_authorid'] = extractUserID($example['eg_author']); } else { $example['eg_authorid'] = ""; } if ($example['eg_authorid'] == $_SESSION['SESS_USER_ID']) { $example['editable'] = 'true'; $example['edit_url'] = _link("api/edit_example/") . md5($example['id']); } $data['examples'][$i] = $example; $i++; } } else { $data = array(); } return $data; }