Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Alanaktion committed Nov 17, 2015
2 parents 5575826 + 6c745cd commit 8eb3259
Show file tree
Hide file tree
Showing 54 changed files with 1,139 additions and 249 deletions.
1 change: 1 addition & 0 deletions app/controller/api/issues.php
Expand Up @@ -196,6 +196,7 @@ public function post($f3) {
$issue->name = trim($post["name"]);
$issue->type_id = empty($post["type_id"]) ? 1 : $post["type_id"];
$issue->priority_id = empty($post["priority_id"]) ? $f3->get("issue_priority.default") : $post["priority_id"];
$issue->status = empty($status) ? 1 : $status->id;

// Set due date if valid
if(!empty($post["due_date"]) && preg_match("/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}( [0-9:]{8})?$/", $post["due_date"])) {
Expand Down
15 changes: 10 additions & 5 deletions app/controller/issues.php
Expand Up @@ -104,6 +104,9 @@ protected function _buildFilter() {
case "created":
$filter_str .= " ORDER BY created_date {$ascdesc}, priority DESC, due_date DESC ";
break;
case "due":
$filter_str .= " ORDER BY due_date {$ascdesc}, priority DESC";
break;
case "sprint":
$filter_str .= " ORDER BY sprint_start_date {$ascdesc}, priority DESC, due_date DESC ";
break;
Expand Down Expand Up @@ -390,7 +393,7 @@ public function add_selecttype($f3, $params) {
$type = new \Model\Issue\Type;
$f3->set("types", $type->find(null, null, $f3->get("cache_expire.db")));

$f3->set("title", $f3->get("dist.new_n", $f3->get("dict.issue")));
$f3->set("title", $f3->get("dict.new_n", $f3->get("dict.issues")));
$f3->set("menuitem", "new");
$this->_render("issues/new.html");
}
Expand Down Expand Up @@ -604,7 +607,7 @@ public function save($f3, $params) {
}

} else {
$f3->reroute("/issues/new/" . $post["type_id"]);
$f3->reroute("/issues/new/" . $f3->get("POST.type_id"));
}
}

Expand All @@ -629,9 +632,11 @@ public function single($f3, $params) {
$watching = new \Model\Issue\Watcher;
// Loads just in case the user is already a watcher
$watching->load(array("issue_id = ? AND user_id = ?", $issue->id, $post["user_id"]));
$watching->issue_id = $issue->id;
$watching->user_id = $post["user_id"];
$watching->save();
if(!$watching->id) {
$watching->issue_id = $issue->id;
$watching->user_id = $post["user_id"];
$watching->save();
}

if($f3->get("AJAX"))
return;
Expand Down
147 changes: 89 additions & 58 deletions app/controller/user.php
Expand Up @@ -20,85 +20,82 @@ public function __construct() {
"de" => \ISO::LC_de . " (Deutsch)",
"cs" => \ISO::LC_cs . " (Češka)",
"zh" => \ISO::LC_zh . " (中国)",
"ja" => \ISO::LC_ja . " (日本語)",
);
}

/**
* @param \Base $f3
*/
public function index($f3) {
$f3->reroute("/user");
}

/**
* GET /user/dashboard User dashboard
*
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function dashboard($f3, $params) {
$issue = new \Model\Issue\Detail();

// Add user's group IDs to owner filter
$owner_ids = array($this->_userId);
$groups = new \Model\User\Group();
foreach($groups->find(array("user_id = ?", $this->_userId)) as $r) {
$owner_ids[] = $r->group_id;
$dashboard = $f3->get("user_obj")->option("dashboard");
if(!$dashboard) {
$dashboard = array(
"left" => array("projects", "subprojects", "bugs", "repeat_work", "watchlist"),
"right" => array("tasks")
);
}
$owner_ids = implode(",", $owner_ids);


$order = "priority DESC, has_due_date ASC, due_date ASC";
$projects = $issue->find(
array(
"owner_id IN ($owner_ids) AND type_id=:type AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0",
":type" => $f3->get("issue_type.project"),
),array(
"order" => $order
)
);
$subprojects = array();
foreach($projects as $i=>$project) {
if($project->parent_id) {
$subprojects[] = $project;
unset($projects[$i]);
// Load dashboard widget data
$allWidgets = array("projects", "subprojects", "tasks", "bugs", "repeat_work", "watchlist", "my_comments", "recent_comments");
$helper = \Helper\Dashboard::instance();
foreach($dashboard as $pos=>$widgets) {
foreach($widgets as $widget) {
if(is_callable(array($helper, $widget))) {
$f3->set($widget, $helper->$widget());
} else {
$f3->set("error", "Widget '{$widget}' is not available.");
}
unset($allWidgets[array_search($widget, $allWidgets)]);
}
}
$f3->set("projects", $projects);
$f3->set("subprojects", $subprojects);

$f3->set("bugs", $issue->find(
array(
"owner_id IN ($owner_ids) AND type_id=:type AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0",
":type" => $f3->get("issue_type.bug"),
),array(
"order" => $order
)
));

$f3->set("repeat_issues", $issue->find(
array(
"owner_id IN ($owner_ids) AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0 AND repeat_cycle NOT IN ('none', '')",
":type" => $f3->get("issue_type.bug"),
),array(
"order" => $order
)
));

$watchlist = new \Model\Issue\Watcher();
$f3->set("watchlist", $watchlist->findby_watcher($this->_userId, $order));


$tasks = new \Model\Issue\Detail();
$f3->set("tasks", $tasks->find(
array(
"owner_id IN ($owner_ids) AND type_id=:type AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0",
":type" => $f3->get("issue_type.task"),
),array(
"order" => $order
)
));
$f3->set("unused_widgets", $allWidgets);

// Get current sprint if there is one
$sprint = new \Model\Sprint;
$sprint->load(array("? BETWEEN start_date AND end_date", date("Y-m-d")));
$f3->set("sprint", $sprint);

$f3->set("dashboard", $dashboard);
$f3->set("menuitem", "index");
$this->_render("user/dashboard.html");
}

/**
* POST /user/dashboard
*
* @param \Base $f3
*/
public function dashboardPost($f3) {
$user = $f3->get("user_obj");
if($f3->get("POST.action") == "add") {
$widgets = $user->option("dashboard");
foreach($f3->get("POST.widgets") as $widget) {
$widgets["left"][] = $widget;
}
} else {
$widgets = json_decode($f3->get("POST.widgets"));
}
$user->option("dashboard", $widgets);
$user->save();
if($f3->get("AJAX")) {
$this->_printJson($widgets);
} else {
$f3->reroute("/");
}
}

private function _loadThemes() {
$f3 = \Base::instance();

Expand All @@ -116,6 +113,12 @@ private function _loadThemes() {
return $themes;
}

/**
* GET /user
*
* @param \Base $f3
* @param array $params
*/
public function account($f3, $params) {
$f3->set("title", $f3->get("dict.my_account"));
$f3->set("menuitem", "user");
Expand All @@ -124,6 +127,13 @@ public function account($f3, $params) {
$this->_render("user/account.html");
}

/**
* POST /user
*
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function save($f3, $params) {
$f3 = \Base::instance();
$post = array_map("trim", $f3->get("POST"));
Expand Down Expand Up @@ -209,6 +219,13 @@ public function save($f3, $params) {
$this->_render("user/account.html");
}

/**
* POST /user/avatar
*
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function avatar($f3, $params) {
$f3 = \Base::instance();

Expand Down Expand Up @@ -256,6 +273,13 @@ function($file) use($f3, $user) {
$f3->reroute("/user");
}

/**
* GET /user/@username
*
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function single($f3, $params) {
$this->_requireLogin();

Expand Down Expand Up @@ -327,6 +351,13 @@ protected function _buildTree($array) {
return $tree;
}

/**
* GET /user/@username/tree
*
* @param \Base $f3
* @param array $params
* @throws \Exception
*/
public function single_tree($f3, $params) {
$this->_requireLogin();

Expand Down Expand Up @@ -373,7 +404,7 @@ public function single_tree($f3, $params) {

/**
* Helper function for recursive tree rendering
* @param Issue $issue
* @param array $issue
* @var callable $renderTree This function, required for recursive calls
*/
$renderTree = function(&$issue, $level = 0) use(&$renderTree) {
Expand Down
6 changes: 5 additions & 1 deletion app/dict/cs.ini
Expand Up @@ -32,7 +32,7 @@ sprint=Sprint
sprints=Sprints
browse=Hledat
open=Otevřít
closed=Closed
closed=Zavřeno
created_by_me=Created by me
assigned_to_me=Assigned to me
issue_search=Quickly find an issue
Expand Down Expand Up @@ -71,6 +71,8 @@ my_watchlist=My Watch List
add_project=Přidat projekt
add_task=Přidat úkol
add_bug=Přidat chybu
my_comments=My Comments
recent_comments=Recent Comments

; User pages
created_issues=Created Issues
Expand All @@ -89,7 +91,9 @@ edit_on_gravatar=Edit on Gravatar
save=Uložit
current_password=Stávající heslo
profile=Profil
settings=Settings
default=Default
disable_editor=Disable Editor

; Browse
general=General
Expand Down
6 changes: 5 additions & 1 deletion app/dict/de.ini
Expand Up @@ -32,7 +32,7 @@ sprints=Sprints
browse=Zeige
open=Offen
closed=Geschlossen
created_by_me=Erstellt von mir
created_by_me=Von mir erstellt
assigned_to_me=Mir zugewiesen
issue_search=Schnell ein Problem finden
administration=Administration
Expand Down Expand Up @@ -70,6 +70,8 @@ my_watchlist=Meine Watch-List
add_project=Projekt hinzufügen
add_task=Aufgabe hinzufügen
add_bug=Bug hinzufügen
my_comments=My Comments
recent_comments=Recent Comments

; User pages
created_issues=Erstelle Tickets
Expand All @@ -87,7 +89,9 @@ edit_on_gravatar=Bearbeiten auf Gravatar
save=Speichern
current_password=Aktuelles Passwort
profile=Profil
settings=Settings
default=Standard
disable_editor=Disable Editor

; Browse
general=Allgemein
Expand Down
2 changes: 2 additions & 0 deletions app/dict/en.ini
Expand Up @@ -70,6 +70,8 @@ my_watchlist=My Watch List
add_project=Add Project
add_task=Add Task
add_bug=Add Bug
my_comments=My Comments
recent_comments=Recent Comments

; User pages
created_issues=Created Issues
Expand Down
8 changes: 6 additions & 2 deletions app/dict/es.ini
Expand Up @@ -70,6 +70,8 @@ my_watchlist=Mi lista de observar
add_project=Crear Proyecto
add_task=Crear Tarea
add_bug=Crear Error
my_comments=Mis Comentarios
recent_comments=Comentarios Recientes

; User pages
created_issues=Peticiónes creados
Expand All @@ -87,7 +89,9 @@ edit_on_gravatar=Editar en Gravatar
save=Guardar
current_password=Contraseña actual
profile=Perfil
settings=Opciones
default=Defecto
disable_editor=Desactivar Editor

; Browse
general=General
Expand Down Expand Up @@ -309,7 +313,7 @@ convert_hashtags=Convertir Hashtags en Enlaces
convert_urls=Convertir URLs en Enlaces
convert_emoticons=Convertir emoticonos en glifos
outgoing_mail=Correo Saliente (SMTP)
from_address=From Address
from_address=Dirección desde
incoming_mail=Correo Entrante (IMAP)
hostname=Hostname
debug_level=El Nivel de depuración (DEBUG)
Expand All @@ -321,7 +325,7 @@ demo_user=Usuario demo (site.demo)
config_note=Nota
imap_truncate_lines=Líneas de truncar mensajes IMAP (mail.truncate_lines)
package_mail_config_note={0} utiliza su defecto de PHP configuración de correo electrónico para el correo electrónico saliente.
imap_settings_note=IMAP settings here will have no effect unless the {0} cron is being run.
imap_settings_note=Configuración IMAP aquí no tendrá ningún efecto a menos que el {0} cron se ejecuta.
email_leave_blank=Deje en blanco para desactivar el correo electrónico saliente
advanced_config_note=Estos valores pueden ser modificados por el tratamiento de los valores en la {0} tabla de base de datos.

0 comments on commit 8eb3259

Please sign in to comment.