本文整理汇总了PHP中ilUtil::stableSortArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::stableSortArray方法的具体用法?PHP ilUtil::stableSortArray怎么用?PHP ilUtil::stableSortArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilUtil
的用法示例。
在下文中一共展示了ilUtil::stableSortArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItems
/**
* Get language data
*/
function getItems()
{
$languages = $this->folder->getLanguages();
$data = array();
foreach ($languages as $k => $l) {
$data[] = array_merge($l, array("key" => $k));
}
// sort alphabetically but shoe installed languages first
$data = ilUtil::stableSortArray($data, 'name', 'asc', false);
$data = ilUtil::stableSortArray($data, 'desc', 'asc', false);
$this->setData($data);
}
示例2: getUserDataForObject
//.........这里部分代码省略.........
* @param string $a_order_dir
* @param int $a_offset
* @param int $a_limit
* @param array $a_filters
* @param array $a_additional_fields
* @param int $check_agreement (obj id of parent course)
* @param arry $privacy_fields
* @return array cnt, set
*/
static function getUserDataForObject($a_ref_id, $a_order_field = "", $a_order_dir = "", $a_offset = 0, $a_limit = 9999, array $a_filters = NULL, array $a_additional_fields = NULL, $check_agreement = false, $privacy_fields = NULL)
{
global $ilDB;
$fields = array("usr_data.usr_id", "login", "active");
$udf = self::buildColumns($fields, $a_additional_fields);
$where = array();
$where[] = "usr_data.usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID, "integer");
// users
$left = "";
$a_users = self::getParticipantsForObject($a_ref_id);
$obj_id = ilObject::_lookupObjectId($a_ref_id);
self::refreshObjectsStatus(array($obj_id), $a_users);
if (is_array($a_users)) {
$left = "LEFT";
$where[] = $ilDB->in("usr_data.usr_id", $a_users, false, "integer");
}
$query = " FROM usr_data " . $left . " JOIN read_event ON (read_event.usr_id = usr_data.usr_id" . " AND read_event.obj_id = " . $ilDB->quote($obj_id, "integer") . ")" . " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " . " AND ut_lp_marks.obj_id = " . $ilDB->quote($obj_id, "integer") . ")" . " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " . $ilDB->quote("language", "text") . ")" . self::buildFilters($where, $a_filters);
$queries = array(array("fields" => $fields, "query" => $query));
// #9598 - if language is not in fields alias is missing
if ($a_order_field == "language") {
$a_order_field = "usr_pref.value";
}
// udf data is added later on, not in this query
$udf_order = null;
if (!$a_order_field) {
$a_order_field = "login";
} else {
if (substr($a_order_field, 0, 4) == "udf_") {
$udf_order = $a_order_field;
$a_order_field = null;
}
}
$result = self::executeQueries($queries, $a_order_field, $a_order_dir, $a_offset, $a_limit);
if ($result["cnt"]) {
if (sizeof($udf)) {
$query = "SELECT usr_id, field_id, value FROM udf_text WHERE " . $ilDB->in("field_id", $udf, false, "integer");
$set = $ilDB->query($query);
$udf = array();
while ($row = $ilDB->fetchAssoc($set)) {
$udf[$row["usr_id"]]["udf_" . $row["field_id"]] = $row["value"];
}
}
// (course) user agreement
if ($check_agreement) {
// admins/tutors (write-access) will never have agreement ?!
include_once "Services/Membership/classes/class.ilMemberAgreement.php";
$agreements = ilMemberAgreement::lookupAcceptedAgreements($check_agreement);
// public information for users
$query = "SELECT usr_id FROM usr_pref WHERE keyword = " . $ilDB->quote("public_profile", "text") . " AND value = " . $ilDB->quote("y", "text") . " OR value = " . $ilDB->quote("g", "text");
$set = $ilDB->query($query);
$all_public = array();
while ($row = $ilDB->fetchAssoc($set)) {
$all_public[] = $row["usr_id"];
}
$query = "SELECT usr_id,keyword FROM usr_pref WHERE " . $ilDB->like("keyword", "text", "public_%", false) . " AND value = " . $ilDB->quote("y", "text") . " AND " . $ilDB->in("usr_id", $all_public, "", "integer");
$set = $ilDB->query($query);
$public = array();
while ($row = $ilDB->fetchAssoc($set)) {
$public[$row["usr_id"]][] = substr($row["keyword"], 7);
}
unset($all_public);
}
foreach ($result["set"] as $idx => $row) {
// add udf data
if (isset($udf[$row["usr_id"]])) {
$result["set"][$idx] = $row = array_merge($row, $udf[$row["usr_id"]]);
}
// remove all private data - if active agreement and agreement not given by user
if (sizeof($privacy_fields) && $check_agreement && !in_array($row["usr_id"], $agreements)) {
foreach ($privacy_fields as $field) {
// check against public profile
if (isset($row[$field]) && (!isset($public[$row["usr_id"]]) || !in_array($field, $public[$row["usr_id"]]))) {
// remove complete entry - offending field was filtered
if (isset($a_filters[$field])) {
unset($result["set"][$idx]);
break;
} else {
$result["set"][$idx][$field] = false;
}
}
}
}
}
// as we cannot do this in the query, sort by custom field here
if ($udf_order) {
include_once "Services/Utilities/classes/class.ilStr.php";
$result["set"] = ilUtil::stableSortArray($result["set"], $udf_order, $a_order_dir);
}
}
return $result;
}
示例3: getItems
function getItems()
{
global $lng;
$this->determineOffsetAndOrder();
switch ($this->report) {
case "exportSelectedCore":
$tr_data = ilSCORM2004TrackingItems::exportSelectedCore($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
break;
case "exportSelectedInteractions":
$tr_data = ilSCORM2004TrackingItems::exportSelectedInteractions($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
break;
case "exportSelectedObjectives":
$tr_data = ilSCORM2004TrackingItems::exportSelectedObjectives($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
break;
case "exportObjGlobalToSystem":
$tr_data = ilSCORM2004TrackingItems::exportObjGlobalToSystem($this->userSelected, $this->allowExportPrivacy);
break;
case "tracInteractionItem":
$tr_data = ilSCORM2004TrackingItems::tracInteractionItem($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
break;
case "tracInteractionUser":
$tr_data = ilSCORM2004TrackingItems::tracInteractionUser($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
break;
case "tracInteractionUserAnswers":
$tr_data = ilSCORM2004TrackingItems::tracInteractionUserAnswers($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
break;
case "exportSelectedSuccess":
$tr_data = ilSCORM2004TrackingItems::exportSelectedSuccess($this->userSelected, $this->allowExportPrivacy);
break;
}
$this->setMaxCount($tr_data["cnt"]);
if (ilUtil::stripSlashes($this->getOrderField()) != "") {
include_once "Services/Utilities/classes/class.ilStr.php";
$tr_data = ilUtil::stableSortArray($tr_data, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()));
}
$this->setData($tr_data);
}
示例4: getUserDataForObject
/**
* Get all user-based tracking data for object
*
* @param int $a_ref_id
* @param string $a_order_field
* @param string $a_order_dir
* @param int $a_offset
* @param int $a_limit
* @param array $a_filters
* @param array $a_additional_fields
* @param int $check_agreement (obj id of parent course)
* @param arry $privacy_fields
* @return array cnt, set
*/
static function getUserDataForObject($a_ref_id, $a_order_field = "", $a_order_dir = "", $a_offset = 0, $a_limit = 9999, array $a_filters = NULL, array $a_additional_fields = NULL, $check_agreement = false, $privacy_fields = NULL)
{
global $ilDB;
$fields = array("usr_data.usr_id", "login", "active");
$udf = self::buildColumns($fields, $a_additional_fields);
$where = array();
$where[] = "usr_data.usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID, "integer");
// users
$left = "";
$a_users = self::getParticipantsForObject($a_ref_id);
$obj_id = ilObject::_lookupObjectId($a_ref_id);
self::refreshObjectsStatus(array($obj_id), $a_users);
if (is_array($a_users)) {
$left = "LEFT";
$where[] = $ilDB->in("usr_data.usr_id", $a_users, false, "integer");
}
$query = " FROM usr_data " . $left . " JOIN read_event ON (read_event.usr_id = usr_data.usr_id" . " AND read_event.obj_id = " . $ilDB->quote($obj_id, "integer") . ")" . " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " . " AND ut_lp_marks.obj_id = " . $ilDB->quote($obj_id, "integer") . ")" . " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " . $ilDB->quote("language", "text") . ")" . self::buildFilters($where, $a_filters);
$queries = array(array("fields" => $fields, "query" => $query));
// #9598 - if language is not in fields alias is missing
if ($a_order_field == "language") {
$a_order_field = "usr_pref.value";
}
// udf data is added later on, not in this query
$udf_order = null;
if (!$a_order_field) {
$a_order_field = "login";
} else {
if (substr($a_order_field, 0, 4) == "udf_") {
$udf_order = $a_order_field;
$a_order_field = null;
}
}
$result = self::executeQueries($queries, $a_order_field, $a_order_dir, $a_offset, $a_limit);
self::getUDFAndHandlePrivacy($result, $udf, $check_agreement, $privacy_fields, $a_filters);
// as we cannot do this in the query, sort by custom field here
// this will not work with pagination!
if ($udf_order) {
include_once "Services/Utilities/classes/class.ilStr.php";
$result["set"] = ilUtil::stableSortArray($result["set"], $udf_order, $a_order_dir);
}
return $result;
}