I need some help to change this code to sort by name ($name) instead of date. Any help much appreciated. This is the OS project mgmt system, Collabtive. Their forums are sparse.
/**
* Lists all projects assigned to a given member ordered by due date ascending
*
* @param int $user Eindeutige Mitgliedsnummer
* @param int $status Bearbeitungsstatus von Projekten (1 = offenes Projekt)
* @return array $myprojekte Projekte des Mitglieds
*/
function getMyProjects($user, $status = 1)
{
$user = mysql_real_escape_string($user);
$status = mysql_real_escape_string($status);
$user = (int) $user;
$status = (int) $status;
$myprojekte = array();
$sel = mysql_query("SELECT projekt FROM projekte_assigned WHERE user = $user ORDER BY ID ASC");
while ($projs = mysql_fetch_row($sel)) {
$projekt = mysql_fetch_array(mysql_query("SELECT ID FROM projekte WHERE ID = $projs[0] AND status=$status"), MYSQL_ASSOC);
if ($projekt) {
$project = $this->getProject($projekt["ID"]);
array_push($myprojekte, $project);
}
}
if (!empty($myprojekte)) {
// Sort projects by due date ascending
$date = array();
foreach ($myprojekte as $key => $row) {
$date[$key] = $row['end'];
}
array_multisort($date, SORT_ASC, $myprojekte);
return $myprojekte;
} else {
return false;
}
}