diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..dd6d900
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 4
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/README.org b/README.org
index ef26e74..eea5c08 100644
--- a/README.org
+++ b/README.org
@@ -53,7 +53,106 @@ but it is intended to become a standalone app with SMF mode implementation.
- SMF implementation mod
*** Conflicts
- - Member suggest doesn't work when the Simple Portal Advanced Unread extension mod (version 1.4). To fix it, you have to edit Sources/PortalUnread.php and comment out line 117, "window.onload=regenerateUnreadPosters". What exactly this does is not known yet.
+ - Member suggest doesn't work when the Simple Portal Advanced
+ Unread extension mod (version 1.4). To fix it, you have to edit
+ Sources/PortalUnread.php and comment out line 117,
+ "window.onload=regenerateUnreadPosters". What exactly this does
+ is not known yet.
+**** With SMF team
+ Here is mail correspondation:
+***** on 28th october SMF team wrote:
+ You have just been sent a personal message by SMF Customization Team on Simple Machines Community Forum.
+
+ IMPORTANT: Remember, this is just a notification. Please do not reply to this email.
+
+ The message they sent you was:
+
+ Hello passiveuser,
+
+ We have removed your customization from the approval queue for
+ now because we believe it isn't ready yet for the customization
+ site.
+
+ Please take a look at the links below. The information contained
+ in them will be a great resource for you, in order to get your
+ customization ready for the approval process.
+ http://wiki.simplemachines.org/smf/Customization_approval_guidelines
+ http://wiki.simplemachines.org/smf/Coding_Guidelines
+
+ Also, Simple Machine members are a mixed group of individuals of
+ many nationalities and ethnicities. We feel that some of the
+ content in your customization may be a little offensive to some
+ members of our software community. We suggest that you look over
+ portions of the customization that may offend and make
+ appropriate changes for consideration in the approval process.
+
+ We're looking forward to your updated work so please reply to this
+ message when you've had time to update the customization and it will
+ be added back to the queue!
+
+ Reply to this Personal Message here:
+ http://www.simplemachines.org/community/index.php?action=pm;sa=send;f=inbox;pmsg=569976;quote;u=1
+
+***** on 29th october ISKRA replied
+
+ Thank you, for your reply. Our developing team carefully read the
+ coding guidelines and customization approval guidelines and they
+ are a little bit vague, so we would kindly ask for some more
+ explanation regarding the reasons for your removal of the module
+ delegator - spread communism from the approval queue.
+
+ In regards to your other comment regarding the mixed groups of
+ individuals and beeing offensive to them I would like to reply
+ that I found it the most offensive thing I was told in quite some
+ time. you would not guess but some programmers are also communist
+ and would like their opinion on things to matter. The clear
+ objectivity of liberal democracy is what brought into power
+ people like Henry Kissinger, Richard Nixon, George Bush and many
+ other war criminals that spread death and destruction through
+ whole world. If you are afraid of communism I would suggest you
+ to read some books. Maybe it is the best to start with Bertold
+ Brecht since you get a gentle introduction through art. Then to
+ get a first grip there is a Communist Manifesto from Karl Marx -
+ the father scientific socialism. But still it is a vulgar
+ explanation of communistic theory. You should then proceed with
+ Marx's Kapital (don't bother with the Pickety's one - he is in
+ best case a Kaynesian). Still Marx did not live to finish his
+ work, which was then enriched by many other writers. I will
+ mention Vladimir Ilijič Lenin who is still vulgar in his
+ description of marxist theory, but managed to create the biggest
+ known revolution of our times (for reasons why and how it failed
+ you should read Lebowitz's The Contradictions of "Real
+ Socialism": The Conductor and the Conducted - which is, such as
+ many other literature available on gen.lib.rus.ec). There are
+ also many other brilliant authors such as Rosa Luxembourg,
+ Antonio Gramsci, Clara Zetkin and many others. Take a look at
+ this page: https://www.marxists.org/
+
+ Our Marxist-Leninist developers group looks forward to your
+ apology. We also don't blame you to much since you are a citizen
+ of western capitalistic and imperialistic nation. You were born
+ and raised into ideology of white supremacy, chauvinism,
+ colonialism ... The (capitalistic) system is very good at
+ reproduction of its own ideology which is masked as objective, as
+ natural (Luis Althuser wrote an extraordinary peace on that topic
+ called Ideology and ideological apparatus of state). It is a
+ postion of power and it is comfortable position to speak about
+ objectivity and liberalism but on the other hand it is also very
+ ignorant point of view. So if I conclude, you are the one who is
+ not accepting the other people's opinion (although it seems
+ opposite to you - that is because you were thought not to (or not
+ thought to) reflect your own social position). We hope our
+ arguments are understood.
+
+ We are looking forward to improve our smf costumization and also
+ to enrich smf itself. The code is not very nice and easy to
+ understand but this is what we have and what we are working with.
+
+ Regards,
+ Technology work commitee of Iskra
+
+
+
** SLO
*** Splošne informacije
Delegator je sloni na To Do list modu za SMF forum, ki ga je ustvaril grafitus - slava mu. Je zelo preprost program za projektno vodenje.
diff --git a/delegator/Delegator.php b/delegator/Delegator.php
index 2f01dcd..82d8203 100644
--- a/delegator/Delegator.php
+++ b/delegator/Delegator.php
@@ -4,9 +4,9 @@
***********************************************************************************
* Delegator *
* =============================================================================== *
-* Software Version: Delegator 0.1 *
+* Software Version: Delegator 0.99 *
* Software by: iskra dot@studentska-iskra.org *
-* Original software: To-Do list *
+* Original software: To-Do list *
* Original software by: grafitus (beratdogan@hileci.org) *
* Copyright 2009-2014 by: grafitus (beratdogan@hileci.org) *
* Support, News, Updates at: http://www.simplemachines.org *
@@ -24,21 +24,21 @@
* Delegator is continued work from To Do list created by grafitus - slava mu *
**********************************************************************************/
-// First of all, we make sure we are accessing the source file via SMF so that people can not directly access the file. Sledeci vrstici sta dodani, da kdo ne sheka (SMF uporablja v vseh fajlih, mod ni uporabljal).
+// First of all, we make sure we are accessing the source file via SMF so that people can not directly access the file.
+// Sledeci vrstici sta dodani, da kdo ne sheka (SMF uporablja v vseh fajlih, mod ni uporabljal).
if (!defined('SMF'))
die('Hack Attempt...');
/*******************
* Helper funkcije *
******************/
-
-include 'delegator_helpers.php';
+// @todo rename into Subs_Delegator.php
+require_once 'delegator_helpers.php';
//Tu se zacne originalni To-Do list mod
function Delegator()
{
global $context, $txt, $scripturl, $settings; // potrebne variable
- // $context - ne vem, se za kaj se uporablja
// $txt - notri so vsa prikazana besedila (zaradi prevodov)
// $scripturl - za razlicne URL-je brskalnika, da gre na pravo stran?
@@ -46,43 +46,44 @@ function Delegator()
loadTemplate('Delegator'); // nalozi template
- $context['page_title'] = $txt['delegator']; //poberes page title iz $txt['delegator']
-
- $subActions = array( //definira se vse funkcije v sklopu delegatorja
- 'delegator' => 'delegator_main', //tukaj bo pregled nad projekti in nedokoncanimi zadolzitvami
- 'add' => 'add', // nalozi view za add task... al kaj
- 'proj' => 'proj', // template za vnos projekta
- 'add_proj' => 'add_proj', // funkcija ki vnese projekt
- 'add_task' => 'add_task', // funkcija, ki vnese task
- 'en' => 'en', // nalozi template za end_task
- 'end_task' => 'end_task', // MANJKA zakljucek zadolzitve
- 'et' => 'et', // nalaganje edita - view
- 'edit_task' => 'edit_task', // editanje taska - funkcija, ki update-a bazo
- 'del_task' => 'del_task',
- 'claim_task' => 'claim_task', //vzemi odgovornost v svoje roke!
- 'unclaim_task' => 'unclaim_task', //ali pa si premisli
- 'edit_proj' => 'edit_proj', //MANJKA in BO SE MANJKALO editanje projekta
- 'view_proj' => 'view_proj', // podrobnosti projekta
- 'vt' => 'vt', // nalozi view za ogled zadolzitve
- 'view_worker' => 'view_worker', // prikaze naloge enega workerja
- 'my_tasks' => 'my_tasks', // moje naloge
- 'view_projects' => 'view_projects', // seznam vseh projektov
- 'view_log' => 'view_log', // seznam vseh projektov
- 'se' => 'se',
- 'super_edit' => 'super_edit',
- 'del_log' => 'del_log',
-
- // Kasneje bomo dodali se razlicne view-je - prikaz casovnice...
- // Spodnji komentarji so stara To-Do list mod koda
- // Tole sem dodal z zalinega racunalnika, prek ssh
+ $context['page_title'] = $txt['delegator']; // poberes page title iz $txt['delegator']
+
+ $subActions = array( // definira se vse funkcije v sklopu delegatorja
+ 'delegator' => 'delegator_main', //tukaj bo pregled nad projekti in nedokoncanimi zadolzitvami
+ 'add_task' => 'add_task', // nalozi view za add task... al kaj
+ 'add_task_save' => 'add_task_save', // funkcija, ki vnese task
+ 'view_task' => 'view_task', // nalozi view za ogled zadolzitve
+ 'edit_task' => 'edit_task', // nalaganje edita - view
+ 'edit_task_save' => 'edit_task_save', // editanje taska - funkcija, ki update-a bazo
+ 'claim_task' => 'claim_task', // vzemi odgovornost v svoje roke!
+ 'unclaim_task' => 'unclaim_task', // ali pa si premisli
+ 'end_task' => 'end_task', // nalozi view za end_task
+ 'end_task_save' => 'end_task_save', // zakljucek zadolzitve
+ 'del_task' => 'del_task', // Brisi task
+ 'add_project' => 'add_project', // view za vnos projekta
+ 'add_project_save' => 'add_project_save', // funkcija ki vnese projekt
+ 'view_projects' => 'view_projects', // seznam vseh projektov
+ 'view_project' => 'view_project', // podrobnosti projekta
+ 'edit_project' => 'edit_project', // loads add-proj with preloaded fields
+ 'edit_project_save' => 'edit_project_save',
+ 'del_project' => 'del_project', // brisi projekt
+ 'view_worker' => 'view_worker', // prikaze naloge enega workerja
+ 'my_tasks' => 'my_tasks', // moje naloge
+ 'view_log' => 'view_log', // seznam logov (sprememb)
+ 'del_log' => 'del_log', // brisanje logov
+ 'super_edit' => 'super_edit', // view za super edit
+ 'super_edit_save' => 'super_edit_save', // super edit - shrani
+
+ // Kasneje bomo dodali se razlicne view-je - prikaz casovnice...
);
// Delegator v celoti je kot en modul. Razni viewi so "subactioni". Defaulten subaction je delegator. Ce
// je izbran action ($_REQUEST['sa']) neveljaven ali ni specificiran, se zloada defaulten subaction, to je "delegator"
- if (!isset($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']]))
+ if (!isset($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) {
$sub_action = 'delegator';
- else
+ } else {
$sub_action = $_REQUEST['sa'];
+ }
//Dodaj delegator na navigacijo v zgornjem delu strani
$context['linktree'][] = array(
@@ -93,106 +94,68 @@ function Delegator()
// CSS, javascript!
$context['html_headers'] .= '
+
-
- ';
- $subActions[$sub_action]();
+ ';
+ // Pozeni subaction
+ $subActions[$sub_action]();
}
// Sixth, begin doing all the stuff that we want this action to display
// Store the results of this stuff in the $context array.
// This action's template(s) will display the contents of $context.
-
-function delegator_main() //glavna funkcija - prikaze taske
+/**
+ * Main delegator function.
+ *
+ * Shows unclaimed (unfinished) tasks.
+ */
+function delegator_main() //glavna funkcija - prikaze taske
{
// tukaj bi rad prikazal projekte in zadolzitve - mogoce je pomembnejse najprej zadolzitve
global $context, $scripturl, $sourcedir, $smcFunc, $txt; //globalne spremenljivke lahko kliceju funkcije iz zunaj kajne?
-
//isAllowedTo('view_todo'); // izkljuceni permissioni (za zdaj)
- $status = getStatus(false);
- //print_r($status); print_r($status=="unfinished");
+ $status = getStatus(false);
$list_options = array(
-
'id' => 'list_tasks',
'items_per_page' => 30,
- 'base_href' => $scripturl . '?action=delegator;status='.$status,
+ 'base_href' => "$scripturl?action=delegator;status=$status",
'default_sort_col' => 'deadline',
'get_items' => array(
-
'function' => function ($start, $items_per_page, $sort) use ($status) {
- if ($status==="unfinished") {
- $tasks0 = ret_tasks(0, "None", 1, $sort, $start, $items_per_page);
- $tasks1 = ret_tasks(1, "None", 1, $sort, $start, $items_per_page);
- return array_merge($tasks0, $tasks1);
- }
- elseif ($status==="finished") {
- $tasks2 = ret_tasks(2, "None", 1, $sort, $start, $items_per_page);
- $tasks3 = ret_tasks(3, "None", 1, $sort, $start, $items_per_page);
- $tasks4 = ret_tasks(4, "None", 1, $sort, $start, $items_per_page);
- return (array_merge($tasks2, $tasks3, $tasks4));
-
- }
- else {
- return ret_tasks($status, "None", 1, $sort, $start, $items_per_page);
+ switch ($status) {
+ case "unfinished":
+ $tasks0 = ret_tasks(0, "None", 1, $sort, $start, $items_per_page);
+ $tasks1 = ret_tasks(1, "None", 1, $sort, $start, $items_per_page);
+ return array_merge($tasks0, $tasks1);
+
+ case "finished":
+ $tasks2 = ret_tasks(2, "None", 1, $sort, $start, $items_per_page);
+ $tasks3 = ret_tasks(3, "None", 1, $sort, $start, $items_per_page);
+ $tasks4 = ret_tasks(4, "None", 1, $sort, $start, $items_per_page);
+ return (array_merge($tasks2, $tasks3, $tasks4));
+ default:
+ return ret_tasks($status, "None", 1, $sort, $start, $items_per_page);
}
},
'params' => array(
'id_member' => $context['user']['id'],
- ),
+ ),
),
-
'get_count' => array( //tudi tu je posodobljen query
'function' => function() use ($status) {
- if ($status==="unfinished") {
- //print_r("state unfinished - count"); print_r($status);
- return (ret_num(0, "None", 1) + ret_num(1, "None", 1));
- }
- elseif ($status==="finished") {
- //print_r("state finished - count");
- return (ret_num(2, "None", 1) + ret_num(3, "None", 1) + ret_num(4, "None", 1) );
+ switch ($status) {
+ case "unfinished":
+ return (ret_num(0, "None", 1) + ret_num(1, "None", 1));
+ case "finished":
+ return (ret_num(2, "None", 1) + ret_num(3, "None", 1) + ret_num(4, "None", 1) );
+ default:
+ return ret_num($status, "None", 1);
}
- else return ret_num($status, "None", 1);
},
),
'no_items_label' => $txt['delegator_tasks_empty'],
@@ -200,40 +163,46 @@ function delegator_main() //glavna funkcija
);
require_once($sourcedir . '/Subs-List.php');
-
createList($list_options);
}
-function add() //ni se prava funkcija za dodajanje - samo za gumb?
+/**
+ * Add task button.
+ *
+ * Also loads add_task template.
+ */
+function add_task() //ni se prava funkcija za dodajanje - samo za gumb?
{
global $smcFunc, $scripturl, $context, $txt;
-
//isAllowedTo('add_new_todo'); //spet izkljuceni permissioni
- $context['sub_template'] = 'add';
+ $context['sub_template'] = 'add_task';
$context['linktree'][] = array(
- 'url' => $scripturl . '?action=delegator;sa=add', //spet add
+ 'url' => $scripturl . '?action=delegator;sa=add_task_save', //spet add
'name' => $txt['delegator_task_add']
);
}
-//Prava funkcija za dodajanje taska:
-// Kaj se vpise v bazo, ko se ustvari task?
-//id, id_proj, id_author, name, description, creation_date, deadline, priority, state
-// MANJKA: description
-function add_task()
+/**
+ * Function that actually adds new task.
+ *
+ * When task is created; id, id_proj, id_author, name, description,
+ * creation_date, deadline, priority, state
+ * are written into database.
+ */
+function add_task_save()
{
global $smcFunc, $context;
-
//isAllowedTo('add_new_todo');
-
checkSession();
- $id_author = $context['user']['id'];
- $id_proj = $_POST['id_proj'];
+ $id_author = (int) $context['user']['id'];
+ $id_proj = (int) $_POST['id_proj'];
- $name = strtr($smcFunc['htmlspecialchars']($_POST['name']), array("\r" => '', "\n" => '', "\t" => ''));
- $description = strtr($smcFunc['htmlspecialchars']($_POST['description']), array("\r" => '', "\n" => '', "\t" => ''));
+ $name = strtr($smcFunc['htmlspecialchars']($_POST['name']),
+ array("\r" => '', "\n" => '', "\t" => ''));
+ $description = strtr($smcFunc['htmlspecialchars']($_POST['description']),
+ array("\r" => '', "\n" => '', "\t" => ''));
$deadline = $smcFunc['htmlspecialchars']($_POST['duedate']);
$members = $_POST["member_add"];
@@ -241,106 +210,133 @@ function add_task()
fatal_lang_error('delegator_empty_fields', false);
$smcFunc['db_insert']('', '{db_prefix}tasks',
- array('id_proj' => 'int', 'id_author' => 'int', 'name' => 'string', 'description' => 'string', 'deadline' => 'date', 'priority' => 'int', 'state' => 'int', 'creation_date' => 'string', 'start_date' => 'string'),
- array( $id_proj, $id_author, $name, $description, $deadline, $_POST['priority'], (count($members) ? 1 : 0 ), date("Y-m-d"), (count($members) ? date("Y-m-d") : "0001-01-01" ) ),
+ array(
+ 'id_proj' => 'int',
+ 'id_author' => 'int',
+ 'name' => 'string',
+ 'description' => 'string',
+ 'deadline' => 'date',
+ 'priority' => 'int',
+ 'state' => 'int',
+ 'creation_date' => 'string',
+ 'start_date' => 'string'
+ ),
+ array($id_proj, $id_author, $name, $description, $deadline,
+ $_POST['priority'], (count($members) ? 1 : 0 ), date("Y-m-d"),
+ (count($members) ? date("Y-m-d") : "0001-01-01")),
array('id')
);
// Dodaj delegirane memberje
- //
-
$request = $smcFunc['db_query']('', '
- SELECT T1.id AS id_task FROM {db_prefix}tasks T1
- ORDER BY T1.id DESC
- LIMIT 1', array() );
+ SELECT T1.id AS id_task FROM {db_prefix}tasks T1
+ ORDER BY T1.id DESC
+ LIMIT 1', array());
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
foreach ($members as $member) {
$smcFunc['db_insert']('', '{db_prefix}workers',
- array('id_member' => 'int', 'id_task' => 'int', 'status' => 'int'),
- array((int) $member, $row['id_task'], 1)
+ array(
+ 'id_member' => 'int',
+ 'id_task' => 'int',
+ 'status' => 'int'
+ ),
+ array((int) $member, $row['id_task'], 1)
);
}
zapisiLog($id_proj, $row['id_task'], 'add_task');
-
- redirectexit('action=delegator;sa=view_proj&id_proj='.$id_proj);
+ redirectexit("action=delegator;sa=view_project&id_proj=$id_proj");
}
-// analogija funkciji add()
-function proj()
+/**
+ * Function for add project initialization.
+ */
+function add_project()
{
global $smcFunc, $scripturl, $context, $txt;
-
//isAllowedTo('add_new_todo');
- $context['sub_template'] = 'proj';
+ $context['sub_template'] = 'add_project';
$context['linktree'][] = array(
- 'url' => $scripturl . '?action=delegator;sa=proj',
+ 'url' => $scripturl . '?action=delegator;sa=add_project_save',
'name' => $txt['delegator_project_name']
);
}
-// add_project: id, id_coord, name, description, start, end
-function add_proj() // mrbit bi moral imeti se eno funkcijo, v stilu add pri taskih
+
+/**
+ * Function that actually writes project into database.
+ *
+ * add_project: id, id_coord, name, description, start, end
+ * are written into database (delegator_projects table)
+ */
+function add_project_save() // mrbit bi moral imeti se eno funkcijo, v stilu add pri taskih
{
global $smcFunc, $context;
-
//isAllowedTo('add_new_todo');
-
checkSession();
$id_coord = $context['user']['id'];
- $name = strtr($smcFunc['htmlspecialchars']($_POST['name']), array("\r" => '', "\n" => '', "\t" => ''));
- $description = strtr($smcFunc['htmlspecialchars']($_POST['description']), array("\r" => '', "\n" => '', "\t" => ''));
+ $name = strtr($smcFunc['htmlspecialchars']($_POST['name']),
+ array("\r" => '', "\n" => '', "\t" => ''));
+ $description = strtr($smcFunc['htmlspecialchars']($_POST['description']),
+ array("\r" => '', "\n" => '', "\t" => ''));
$start = $smcFunc['htmlspecialchars']($_POST['start']);
$end = $smcFunc['htmlspecialchars']($_POST['end']);
- if ($smcFunc['htmltrim']($_POST['name']) === '' || $smcFunc['htmltrim']($_POST['end']) === '')
+ if ($smcFunc['htmltrim']($_POST['name']) === ''
+ || $smcFunc['htmltrim']($_POST['end']) === '') {
fatal_lang_error('delegator_empty_fields', false);
+ }
- $smcFunc['db_insert']('', '{db_prefix}projects',
- array(
- 'id_coord' => 'int', 'name' => 'string', 'description' => 'string', 'start' => 'date', 'end' => 'date',
- ),
- array(
- $id_coord, $name, $description, $start, $end,
- ),
- array('id')
+ $smcFunc['db_insert']('', '{db_prefix}projects', array(
+ 'id_coord' => 'int',
+ 'name' => 'string',
+ 'description' => 'string',
+ 'start' => 'date',
+ 'end' => 'date'
+ ),
+ array(
+ $id_coord, $name, $description, $start, $end
+ ),
+ array('id')
);
// Redirect vrze na isti projekt...
// Fora je, da moram pogledat, kateri id je dobil...
$request = $smcFunc['db_query']('', '
- SELECT T1.id AS id_proj FROM {db_prefix}projects T1
- ORDER BY T1.id DESC
- LIMIT 1', array() );
+ SELECT T1.id AS id_proj FROM {db_prefix}projects T1
+ ORDER BY T1.id DESC
+ LIMIT 1', array()
+ );
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
zapisiLog($row['id_proj'], -1, 'add_proj');
-
- redirectexit('action=delegator;sa=view_proj;id_proj='.$row['id_proj']); // redirect exit - logicno
+ redirectexit('action=delegator;sa=view_project;id_proj=' . $row['id_proj']); // redirect exit - logicno
}
##################################################################
########################## view_task #############################
##################################################################
-// analogija funkciji add()
-function vt()
+/**
+ * Initializes view task.
+ */
+function view_task()
{
global $smcFunc, $scripturl, $context, $txt;
- $context['sub_template'] = 'vt';
+ $context['sub_template'] = 'view_task';
$context['linktree'][] = array(
- 'url' => $scripturl . '?action=delegator;sa=vt',
+ 'url' => $scripturl . '?action=delegator;sa=view_task',
'name' => $txt['delegator_view_task']
);
}
@@ -348,14 +344,16 @@ function vt()
##################################################################
################### view project #################################
##################################################################
-
-function view_proj()
+/**
+ * Initializes view project.
+ */
+function view_project()
{
global $smcFunc, $scripturl, $context, $txt, $sourcedir;
- $context['sub_template'] = 'view_proj';
+ $context['sub_template'] = 'view_project';
$context['linktree'][] = array(
- 'url' => $scripturl . '?action=delegator;sa=view_proj',
+ 'url' => $scripturl . '?action=delegator;sa=view_project',
'name' => $txt['delegator_view_project']
);
@@ -363,35 +361,33 @@ function view_proj()
//////////////////// prikaz taskov v projektu //////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
- $id_proj = $_GET['id_proj'];
-
+ $id_proj = (int) $_GET['id_proj'];
$status = getStatus();
-// tole lahko uporabimo za prikaz taskov, ampak si ne upam...
-// matra me $id_proj, ker ne vem, kako naj ga dobim sem notri...
+ // tole lahko uporabimo za prikaz taskov, ampak si ne upam...
+ // matra me $id_proj, ker ne vem, kako naj ga dobim sem notri...
$list_options = array(
//'id' => 'list_todos', //stara To-Do List koda
'id' => 'list_tasks_of_proj',
'items_per_page' => 30, //stevilo taskov na stran
- 'base_href' => $scripturl . '?action=delegator;sa=view_proj;id_proj=' . $id_proj.';status='.$status, //prvi del URL-ja
+ 'base_href' => "$scripturl?action=delegator;sa=view_project;id_proj=$id_proj;status=$status", //prvi del URL-ja
'default_sort_col' => 'deadline', //razvrsis taske po roku
'get_items' => array(
// FUNKCIJE
-
'function' => function($start, $items_per_page, $sort) use ($status, $id_proj) {
- if ($status==="unfinished") {
- $tasks0 = ret_tasks(0, "Project", $id_proj, $sort, $start, $items_per_page);
- $tasks1 = ret_tasks(1, "Project", $id_proj, $sort, $start, $items_per_page);
- return array_merge($tasks0, $tasks1);
+ switch ($status) {
+ case "unfinished":
+ $tasks0 = ret_tasks(0, "Project", $id_proj, $sort, $start, $items_per_page);
+ $tasks1 = ret_tasks(1, "Project", $id_proj, $sort, $start, $items_per_page);
+ return array_merge($tasks0, $tasks1);
+ case "finished":
+ $tasks2 = ret_tasks(2, "Project", $id_proj, $sort, $start, $items_per_page);
+ $tasks3 = ret_tasks(3, "Project", $id_proj, $sort, $start, $items_per_page);
+ $tasks4 = ret_tasks(4, "Project", $id_proj, $sort, $start, $items_per_page);
+ return (array_merge($tasks2, $tasks3, $tasks4));
+ default:
+ return ret_tasks($status, "Project", $id_proj, $sort, $start, $items_per_page);
}
- elseif ($status==="finished") {
- $tasks2 = ret_tasks(2, "Project", $id_proj, $sort, $start, $items_per_page);
- $tasks3 = ret_tasks(3, "Project", $id_proj, $sort, $start, $items_per_page);
- $tasks4 = ret_tasks(4, "Project", $id_proj, $sort, $start, $items_per_page);
- return (array_merge($tasks2, $tasks3, $tasks4));
-
- }
- else return ret_tasks($status, "Project", $id_proj, $sort, $start, $items_per_page);
},
'params' => array(
'id_member' => $context['user']['id'],
@@ -399,13 +395,14 @@ function view_proj()
),
'get_count' => array( //tudi tu je posodobljen query
'function' => function() use ($status, $id_proj) {
- if ($status==="unfinished") {
- return (ret_num(0, "Project", $id_proj) + ret_num(1, "Project", $id_proj) );
+ switch ($status) {
+ case "unfinished":
+ return (ret_num(0, "Project", $id_proj) + ret_num(1, "Project", $id_proj) );
+ case "finished":
+ return (ret_num(2, "Project", $id_proj) + ret_num(3, "Project", $id_proj) + ret_num(4, "Project", $id_proj) );
+ default:
+ return ret_num($status, "Project", $id_proj);
}
- elseif ($status==="finished") {
- return (ret_num(2, "Project", $id_proj) + ret_num(3, "Project", $id_proj) + ret_num(4, "Project", $id_proj) );
- }
- else return ret_num($status, "Project", $id_proj);
}
),
'no_items_label' => $txt['delegator_tasks_empty'],
@@ -414,18 +411,18 @@ function view_proj()
require_once($sourcedir . '/Subs-List.php');
createList($list_options);
-
}
##################################################################
##################################################################
##################################################################
-# prikaze vse projekte in to v lepo urejeni tabeli...
+/**
+ * Shows projects in nice table.
+ */
function view_projects()
{
-
global $context, $scripturl, $sourcedir, $smcFunc, $txt; //globalne spremenljivke lahko kliceju funkcije iz zunaj kajne?
$id_member = 1; // kr neki...
@@ -437,16 +434,15 @@ function view_projects()
$list_options = array(
'id' => 'list_of_projects',
- 'items_per_page' => 30, //stevilo taskov na stran
- 'base_href' => $scripturl . '?action=delegator;sa=view_projects', //prvi del URL-ja
- 'default_sort_col' => 'end', //razvrsis taske po roku
+ 'items_per_page' => 30, // stevilo taskov na stran
+ 'base_href' => "$scripturl?action=delegator;sa=view_projects", //prvi del URL-ja
+ 'default_sort_col' => 'end', //razvrsis taske po roku
'get_items' => array(
- // FUNKCIJE
-/*
-query posodobljen - zdaj sta zdruzeni tabela taskov in projektov
-nadalje moramo query urediti tako, da bo se dodana tabela memberjov
-*/
- // $id_memberja tukaj res ne rabim...
+ /*
+ query posodobljen - zdaj sta zdruzeni tabela taskov in projektov
+ nadalje moramo query urediti tako, da bo se dodana tabela memberjov
+ @todo projects function from delegator_helpers.php
+ */
'function' => function($start, $items_per_page, $sort, $id_member) {
global $smcFunc;
@@ -457,15 +453,15 @@ function view_projects()
ORDER BY {raw:sort}
LIMIT {int:start}, {int:per_page}',
array(
- 'id_member' => $id_member,
'sort' => $sort,
'start' => $start,
'per_page' => $items_per_page,
)
);
$projects = array();
- while ($row = $smcFunc['db_fetch_assoc']($request))
+ while ($row = $smcFunc['db_fetch_assoc']($request)) {
$projects[] = $row;
+ }
$smcFunc['db_free_result']($request);
return $projects;
@@ -474,8 +470,7 @@ function view_projects()
'id_member' => $context['user']['id'],
),
),
-
- 'get_count' => array( //tudi tu je posodobljen query
+ 'get_count' => array( //tudi tu je posodobljen query
'function' => function() {
global $smcFunc;
@@ -498,8 +493,8 @@ function view_projects()
'value' => $txt['delegator_project_name'], //Napisi v header "Name"... potegne iz index.english.php
),
'data' => array( // zamenjal sem napisano funkcijo od grafitus-a...
- 'function' => function($row) {
- return ''.$row['project_name'].' ';
+ 'function' => function($row) use ($scripturl){
+ return "' . $row['project_name'] . ' ';
}
),
'sort' => array(
@@ -513,8 +508,8 @@ function view_projects()
'value' => $txt['delegator_coordinator_name'], //dodano v modification.xml
),
'data' => array(
- 'function' => function($row) {
- return ''.$row['coordinator'].' ';
+ 'function' => function($row) use ($scripturl) {
+ return "' . $row['coordinator'] . ' ';
}
),
'sort' => array(
@@ -542,7 +537,9 @@ function view_projects()
'value' => $txt['delegator_project_end'],
),
'data' => array(
- 'function' => function($row) { return '' . $row['end'] . ' '; },
+ 'function' => function($row) {
+ return '' . $row['end'] . ' ';
+ },
'style' => 'width: 20%; text-align: center;'
),
'sort' => array(
@@ -581,50 +578,46 @@ function view_worker()
$status = getStatus(true);
// id_member ze ima pravo vradnost, a ocitno se query izvrsi za trenutnega uporabnika
- //print_r("PRED VSEM"); die;
-// tole lahko uporabimo za prikaz taskov, ampak si ne upam...
-// matra me $id_proj, ker ne vem, kako naj ga dobim sem notri...
+ // tole lahko uporabimo za prikaz taskov, ampak si ne upam...
+ // matra me $id_proj, ker ne vem, kako naj ga dobim sem notri...
$list_options = array(
'id' => 'list_tasks_of_worker',
- 'items_per_page' => 30, //stevilo taskov na stran
- 'base_href' => $scripturl . '?action=delegator;sa=view_worker;id_member='.$id_member.';status='.$status, //prvi del URL-ja
- 'default_sort_col' => 'deadline', //razvrsis taske po roku
+ 'items_per_page' => 30, //stevilo taskov na stran
+ 'base_href' => $scripturl . "?action=delegator;sa=view_worker;id_member=$id_member;status=$status", //prvi del URL-ja
+ 'default_sort_col' => 'deadline', //razvrsis taske po roku
'get_items' => array(
-
'function' => function($start, $items_per_page, $sort) use ( $id_member, $status) {
- if ($status==="unfinished") {
- $tasks0 = ret_tasks(0, "Worker", $id_member, $sort, $start, $items_per_page);
- $tasks1 = ret_tasks(1, "Worker", $id_member, $sort, $start, $items_per_page);
- return array_merge($tasks0, $tasks1);
+ switch ($status) {
+ case "unfinished":
+ $tasks0 = ret_tasks(0, "Worker", $id_member, $sort, $start, $items_per_page);
+ $tasks1 = ret_tasks(1, "Worker", $id_member, $sort, $start, $items_per_page);
+ return array_merge($tasks0, $tasks1);
+ case "finished":
+ $tasks2 = ret_tasks(2, "Worker", $id_member, $sort, $start, $items_per_page);
+ $tasks3 = ret_tasks(3, "Worker", $id_member, $sort, $start, $items_per_page);
+ $tasks4 = ret_tasks(4, "Worker", $id_member, $sort, $start, $items_per_page);
+ return (array_merge($tasks2, $tasks3, $tasks4));
+ default:
+ return ret_tasks($status, "Worker", $id_member, $sort, $start, $items_per_page); //funkcija vrne taske
}
- elseif ($status==="finished") {
- $tasks2 = ret_tasks(2, "Worker", $id_member, $sort, $start, $items_per_page);
- $tasks3 = ret_tasks(3, "Worker", $id_member, $sort, $start, $items_per_page);
- $tasks4 = ret_tasks(4, "Worker", $id_member, $sort, $start, $items_per_page);
- return (array_merge($tasks2, $tasks3, $tasks4));
- }
-
- else return ret_tasks($status, "Worker", $id_member, $sort, $start, $items_per_page); //funkcija vrne taske
},
'params' => array(
'id_member' => $context['user']['id'],
),
),
-
- 'get_count' => array( //tudi tu je posodobljen query
+ 'get_count' => array( //tudi tu je posodobljen query
'function' => function() use ($id_member, $status) {
- if ($status==="unfinished") {
- return (ret_num(0, "Worker", $id_member) + ret_num(1, "Worker", $id_member) );
- }
- elseif ($status==="finished") {
- return (ret_num(2, "Worker", $id_member) + ret_num(3, "Worker", $id_member) + ret_num(4, "Worker", $id_member) );
+ switch ($status) {
+ case "unfinished":
+ return (ret_num(0, "Worker", $id_member) + ret_num(1, "Worker", $id_member) );
+ case "finished":
+ return (ret_num(2, "Worker", $id_member) + ret_num(3, "Worker", $id_member) + ret_num(4, "Worker", $id_member) );
+ default:
+ return ret_num($status, "Worker", $id_member);
}
- else return ret_num($status, "Worker", $id_member);
-
}
),
'no_items_label' => $txt['delegator_tasks_empty'],
-
'columns' => show_task_list($status)
);
@@ -653,14 +646,12 @@ function my_tasks()
// matra me $id_proj, ker ne vem, kako naj ga dobim sem notri...
$list_options = array(
'id' => 'list_tasks_of_worker',
- 'items_per_page' => 30, //stevilo taskov na stran
- 'base_href' => $scripturl . '?action=delegator;sa=my_tasks;status='.$status, //prvi del URL-ja
- 'default_sort_col' => 'deadline', //razvrsis taske po roku
+ 'items_per_page' => 30, //stevilo taskov na stran
+ 'base_href' => "$scripturl?action=delegator;sa=my_tasks;status=$status", //prvi del URL-ja
+ 'default_sort_col' => 'deadline', //razvrsis taske po roku
'get_items' => array(
// FUNKCIJE
-
'function' => function($start, $items_per_page, $sort ) use ($id_member, $status) {
-
if ($status==="unfinished") {
$tasks0 = ret_tasks(0, "Worker", $id_member, $sort, $start, $items_per_page);
$tasks1 = ret_tasks(1, "Worker", $id_member, $sort, $start, $items_per_page);
@@ -706,7 +697,7 @@ function my_tasks()
##################################################################
##################################################################
-function et()
+function edit_task()
{
// prebere podatke o tem tasku
// odpre template z vpisanimi podatki
@@ -714,14 +705,14 @@ function et()
global $smcFunc, $scripturl, $context, $txt;
- $context['sub_template'] = 'et';
+ $context['sub_template'] = 'edit_task';
$context['linktree'][] = array(
- 'url' => $scripturl . '?action=delegator;sa=et',
+ 'url' => $scripturl . '?action=delegator;sa=edit_task',
'name' => $txt['delegator_edit_task']
);
}
-function edit_task()
+function edit_task_save()
{
global $smcFunc, $context;
@@ -735,9 +726,12 @@ function edit_task()
$members = $_POST["member_add"];
- $name = strtr($smcFunc['htmlspecialchars']($_POST['name']), array("\r" => '', "\n" => '', "\t" => ''));
- $description = strtr($smcFunc['htmlspecialchars']($_POST['description']), array("\r" => '', "\n" => '', "\t" => ''));
- $deadline = strtr($smcFunc['htmlspecialchars']($_POST['deadline']), array("\r" => '', "\n" => '', "\t" => ''));
+ $name = strtr($smcFunc['htmlspecialchars']($_POST['name']),
+ array("\r" => '', "\n" => '', "\t" => ''));
+ $description = strtr($smcFunc['htmlspecialchars']($_POST['description']),
+ array("\r" => '', "\n" => '', "\t" => ''));
+ $deadline = strtr($smcFunc['htmlspecialchars']($_POST['deadline']),
+ array("\r" => '', "\n" => '', "\t" => ''));
$priority = (int) $_POST['priority'];
@@ -745,7 +739,15 @@ function edit_task()
UPDATE {db_prefix}tasks
SET name={string:name}, description={string:description}, deadline={string:deadline}, id_proj={int:id_proj}, priority={int:priority}, state={int:state}
WHERE id = {int:id_task}',
- array('name' => $name, 'description' => $description, 'deadline' => $deadline, 'id_proj' => $id_proj, 'id_task' => $id_task, 'priority' => $priority, 'state' => (count($members) ? 1 : 0 ) )
+ array(
+ 'name' => $name,
+ 'description' => $description,
+ 'deadline' => $deadline,
+ 'id_proj' => $id_proj,
+ 'id_task' => $id_task,
+ 'priority' => $priority,
+ 'state' => count($members) ? 1 : 0
+ )
);
// Dodaj delegirane memberje
@@ -754,84 +756,89 @@ function edit_task()
WHERE id_task={int:id_task}',
array('id_task' => $id_task)
);
- foreach ( $members as $member) {
+ foreach ($members as $member) {
$smcFunc['db_insert']('', '{db_prefix}workers',
- array('id_member' => 'int', 'id_task' => 'int', 'status' => 'int'),
- array((int) $member, $id_task, 1)
+ array(
+ 'id_member' => 'int',
+ 'id_task' => 'int',
+ 'status' => 'int'
+ ),
+ array((int) $member, $id_task, 1)
);
}
zapisiLog($id_proj, $id_task, 'edit_task');
- redirectexit('action=delegator;sa=vt&task_id='.$id_task);
+ // Send emails to delegated members
+ /*
+ delegator_send_mail('delegate', $members, [
+ "id_task" => $id_task,
+ "name" => $name,
+ "description" => $description,
+ "deadline" => $deadline,
+ "delegator" => $id_author
+ ]);
+ */
+
+ redirectexit("action=delegator;sa=view_task&id_task=$id_task");
}
+/**
+ * Invokes db_delete functions.
+ *
+ * Wraper is made, because we are deleting tasks on more occasions.
+ */
function del_task()
{
global $smcFunc, $context;
-
checkSession('get');
+ $id_task = (int) $_GET['id_task'];
- $id_task = (int) $_GET['task_id'];
-
- zapisiLog(-1, $id_task, 'del_task'); // Has to be before DELETE happens...
-
- $smcFunc['db_query']('', '
- DELETE FROM {db_prefix}tasks
- WHERE id = {int:id_task}',
- array(
- 'id_task' => $id_task
- )
- );
-
- $smcFunc['db_query']('', '
- DELETE FROM {db_prefix}workers
- WHERE id_task = {int:id_task}',
- array(
- 'id_task' => $id_task
- )
- );
-
+ db_del_task($id_task);
redirectexit('action=delegator');
}
function claim_task()
{
global $smcFunc, $context, $scripturl;
-
checkSession('get');
-
- $id_task = (int) $_GET['task_id'];
+ $id_task = (int) $_GET['id_task'];
$member_id = (int) $context['user']['id'];
// ubistvu moram to narest samo če je state 1
if(numberOfWorkers($id_task) == 0){
$smcFunc['db_query']('','
- UPDATE {db_prefix}tasks
- SET state={int:state}, start_date={string:start_date}
- WHERE id = {int:id_task}',
- array('state' => 1, 'start_date' => date('Y-m-d') , 'id_task' => $id_task)
+ UPDATE {db_prefix}tasks
+ SET state={int:state}, start_date={string:start_date}
+ WHERE id = {int:id_task}',
+ array(
+ 'state' => 1,
+ 'start_date' => date('Y-m-d'),
+ 'id_task' => $id_task
+ )
);
}
$smcFunc['db_insert']('', '{db_prefix}workers',
- array('id_member' => 'int', 'id_task' => 'int', 'status' => 'int'),
+ array(
+ 'id_member' => 'int',
+ 'id_task' => 'int',
+ 'status' => 'int'
+ ),
array($member_id, $id_task, 1),
- array('id') );
+ array('id')
+ );
zapisiLog(-1, $id_task, 'claim_task');
-
- redirectexit('action=delegator;sa=vt;task_id=' . $id_task);
+ redirectexit("action=delegator;sa=view_task;id_task=$id_task");
}
function unclaim_task()
{
global $smcFunc, $context, $scripturl;
-
checkSession('get');
-
- $id_task = (int) $_GET['task_id'];
+ $id_task = (int) $_GET['id_task'];
$id_member = (int) $context['user']['id'];
$smcFunc['db_query']('', '
@@ -846,79 +853,82 @@ function unclaim_task()
// preverim stevilo workerjev; ce jih je nic, updejtam v ena.
if(numberOfWorkers($id_task) == 0){
$smcFunc['db_query']('','
- UPDATE {db_prefix}tasks
- SET state = {int:state}
- WHERE id = {int:id_task}',
- array('state' => 0, 'id_task' => $id_task)
+ UPDATE {db_prefix}tasks
+ SET state = {int:state}
+ WHERE id = {int:id_task}',
+ array(
+ 'state' => 0,
+ 'id_task' => $id_task
+ )
);
}
zapisiLog(-1, $id_task, 'unclaim_task');
- //redirectexit($scripturl . '?action=delegator;sa=view_task;task_id=' . $task_id);
- redirectexit('action=delegator;sa=vt&task_id=' . $id_task);
+ redirectexit("action=delegator;sa=view_task&id_task=$id_task");
}
// Tukaj bomo nalozili template za koncanje taska
// Funkcija ustreza et, add, najbrz tudi proj
-function en()
+function end_task()
{
-
// prebere podatke o tem tasku
// odpre template z vpisanimi podatki
// naredis UPDATE v bazi z novimi podatki -> funkcija edit_task
-
global $smcFunc, $scripturl, $context, $txt;
- $context['sub_template'] = 'en';
+ $context['sub_template'] = 'end_task';
$context['linktree'][] = array(
- 'url' => $scripturl . '?action=delegator;sa=en',
+ 'url' => $scripturl . '?action=delegator;sa=end_task',
'name' => $txt['delegator_end_task']
);
}
-function end_task()
+function end_task_save()
{
global $smcFunc, $context, $scripturl;
-
checkSession(); // ali je to ok???
+ $id_task = (int) $_POST['id_task'];
- $id_task = (int) $_POST['id_task']; // @todo vse task_id je treba dat v id_task!
-
- if (isMemberWorker($id_task)){
- $end_comment = strtr($smcFunc['htmlspecialchars']($_POST['end_comment']), array("\r" => '', "\n" => '', "\t" => ''));
+ if (isMemberWorker($id_task)) {
+ $end_comment = strtr($smcFunc['htmlspecialchars']($_POST['end_comment']),
+ array("\r" => '', "\n" => '', "\t" => ''));
$state = (int) $_POST['state'];
-
// @TODO Za posiljanje mailov bi bilo bolje spisat svojo funkcijo
-
$smcFunc['db_query']('','
- UPDATE {db_prefix}tasks
- SET end_comment={string:end_comment}, end_date={string:end_date}, state={int:state}
- WHERE id = {int:id_task}',
- array( 'end_comment' => $end_comment, 'end_date' => date("Y-m-d"), 'state' => $state , 'id_task' => $id_task ));
+ UPDATE {db_prefix}tasks
+ SET end_comment={string:end_comment}, end_date={string:end_date}, state={int:state}
+ WHERE id = {int:id_task}',
+ array(
+ 'end_comment' => $end_comment,
+ 'end_date' => date("Y-m-d"),
+ 'state' => $state,
+ 'id_task' => $id_task
+ )
+ );
$smcFunc['db_query']('','
- UPDATE {db_prefix}workers
- SET status={int:status}
- WHERE id_task = {int:id_task}',
- array( 'status' => $state , 'id_task' => $id_task ));
-
+ UPDATE {db_prefix}workers
+ SET status={int:status}
+ WHERE id_task = {int:id_task}',
+ array(
+ 'status' => $state,
+ 'id_task' => $id_task
+ )
+ );
zapisiLog(-1, $id_task, 'end_task');
-
redirectexit('action=delegator;sa=my_tasks');
}
- redirectexit('action=delegator;sa=vt;task_id='.$id_task);
-
+ redirectexit("action=delegator;sa=view_task;id_task=$id_task");
}
function view_log()
{
-
global $smcFunc, $scripturl, $context, $txt, $sourcedir;
$context['sub_template'] = 'view_log';
@@ -929,27 +939,26 @@ function view_log()
$id_member = $context['user']['id'];
-// tole lahko uporabimo za prikaz taskov, ampak si ne upam...
-// matra me $id_proj, ker ne vem, kako naj ga dobim sem notri...
+ // tole lahko uporabimo za prikaz taskov, ampak si ne upam...
+ // matra me $id_proj, ker ne vem, kako naj ga dobim sem notri...
$list_options = array(
'id' => 'log',
- 'items_per_page' => 30, //stevilo taskov na stran
- 'base_href' => $scripturl . '?action=delegator;sa=view_log', //prvi del URL-ja
- 'default_sort_col' => 'action_date', //razvrsis taske po roku
+ 'items_per_page' => 30, //stevilo taskov na stran
+ 'base_href' => "$scripturl?action=delegator;sa=view_log", //prvi del URL-ja
+ 'default_sort_col' => 'action_date', //razvrsis taske po roku
+ 'default_sort_dir' => 'desc',
'get_items' => array(
// FUNKCIJE
-
'function' => function($start, $items_per_page, $sort) {
global $smcFunc;
$request = $smcFunc['db_query']('', '
- SELECT T1.action_date, T1.id_member, T1.id_task, T1.id_proj, T1.action, T2.real_name AS member, T3.name AS project_name, T4.name AS task_name
-
- FROM {db_prefix}delegator_log T1
- LEFT JOIN {db_prefix}members T2 ON T1.id_member = T2.id_member
- LEFT JOIN {db_prefix}projects T3 ON T1.id_proj = T3.id
- LEFT JOIN {db_prefix}tasks T4 ON T1.id_task = T4.id
- ORDER BY {raw:sort}
+ SELECT T1.action_date, T1.id_member, T1.id_task, T1.id_proj, T1.action, T2.real_name AS member, T3.name AS project_name, T4.name AS task_name
+ FROM {db_prefix}delegator_log T1
+ LEFT JOIN {db_prefix}members T2 ON T1.id_member = T2.id_member
+ LEFT JOIN {db_prefix}projects T3 ON T1.id_proj = T3.id
+ LEFT JOIN {db_prefix}tasks T4 ON T1.id_task = T4.id
+ ORDER BY {raw:sort}
LIMIT {int:start}, {int:per_page}',
array(
'sort' => $sort,
@@ -959,18 +968,18 @@ function view_log()
);
$logs = array();
- while ($row = $smcFunc['db_fetch_assoc']($request))
+ while ($row = $smcFunc['db_fetch_assoc']($request)) {
$logs[] = $row;
- $smcFunc['db_free_result']($request);
+ }
- return $logs; //funkcija vrne taske
+ $smcFunc['db_free_result']($request);
+ return $logs; //funkcija vrne taske
},
'params' => array(
'id_member' => $context['user']['id'], //tudi ne rabimo
- ),
+ ),
),
-
- 'get_count' => array( //tudi tu je posodobljen query
+ 'get_count' => array( //tudi tu je posodobljen query
'function' => function() {
global $smcFunc;
@@ -994,7 +1003,7 @@ function view_log()
),
'data' => array(
'function' => create_function('$row',
- 'return $row[\'action_date\'];'
+ 'return $row[\'action_date\'];'
),
),
'sort' => array(
@@ -1002,15 +1011,13 @@ function view_log()
'reverse' => 'action_date DESC',
),
),
-
'member' => array( //Member
'header' => array(
'value' => $txt['delegator_member_name'], //dodano v modification.xml
),
'data' => array(
'function' => create_function('$row',
- 'return \'\'.$row[\'member\'].\' \'; '
-
+ 'return \'\'.$row[\'member\'].\' \'; '
),
),
'sort' => array(
@@ -1018,7 +1025,6 @@ function view_log()
'reverse' => 'member DESC',
),
),
-
'action' => array(
'header' => array(
'value' => $txt['delegator_action'], //dodano v modification.xml
@@ -1033,16 +1039,13 @@ function view_log()
'reverse' => 'action DESC',
),
),
-
'project' => array(
'header' => array(
'value' => $txt['delegator_project_name'], //dodano v modification.xml
),
'data' => array(
'function' => create_function('$row',
- 'return \'\'.$row[\'project_name\'].\' \'; '
-//'return parse_bbc($row[\'project_name\']);
-
+ 'return \'\'.$row[\'project_name\'].\' \'; '
),
),
'sort' => array(
@@ -1056,7 +1059,7 @@ function view_log()
),
'data' => array(
'function' => create_function('$row',
- 'return \'\'.$row[\'task_name\'].\' \'; '
+ 'return \'\'.$row[\'task_name\'].\' \'; '
),
),
@@ -1070,7 +1073,6 @@ function view_log()
),
);
-
require_once($sourcedir . '/Subs-List.php');
createList($list_options);
}
@@ -1078,16 +1080,13 @@ function view_log()
function del_log()
{
global $smcFunc, $context;
-
-
isAllowedTo('delegator_super_edit');
-
checkSession('get');
$smcFunc['db_query']('', '
- TRUNCATE {db_prefix}delegator_log
- ',
- array());
+ TRUNCATE {db_prefix}delegator_log',
+ array()
+ );
// DELETE * FROM {db_prefix}delegator_log
zapisiLog(-2, -2, 'del_log');
redirectexit('action=delegator');
@@ -1100,7 +1099,7 @@ function del_log()
*** ******************* Super Edit *************************
************************************************************/
-function se()
+function super_edit()
{
// Super edit funkcija - koordinator lahko vrne projekt v nedokončano stanje
// Tukaj notri bi moral bit requesti!!!
@@ -1108,32 +1107,34 @@ function se()
global $smcFunc, $scripturl, $context, $txt;
- $context['sub_template'] = 'se';
+ $context['sub_template'] = 'super_edit';
$cnotext['linktree'][] = array(
- 'url' => $scripturl . '?action=delegator;sa=se',
+ 'url' => "$scripturl?action=delegator;sa=super_edit",
'name' => $txt['delegator_edit_task']
);
}
-
-function super_edit()
+/**
+ * super_edit_save is used to edit finished tasks.
+ *
+ */
+function super_edit_save()
{
global $smcFunc, $context;
-
//isAllowedTo('add_new_todo');
-
checkSession();
-
- if (isMemberCoordinator){
-
- $id_author = $context['user']['id'];
- $id_task = (int) $_POST['id_task'];
- $id_proj = $_POST['id_proj'];
-
+ $id_author = $context['user']['id'];
+ $id_task = (int) $_POST['id_task'];
+ $id_proj = (int) $_POST['id_proj'];
+ // var_dump($id_author, $id_task, $id_proj); die;
+ if (isMemberCoordinator($id_proj)){
$members = $_POST["member_add"];
- $name = strtr($smcFunc['htmlspecialchars']($_POST['name']), array("\r" => '', "\n" => '', "\t" => ''));
- $description = strtr($smcFunc['htmlspecialchars']($_POST['description']), array("\r" => '', "\n" => '', "\t" => ''));
- $deadline = strtr($smcFunc['htmlspecialchars']($_POST['deadline']), array("\r" => '', "\n" => '', "\t" => ''));
+ $name = strtr($smcFunc['htmlspecialchars']($_POST['name']),
+ array("\r" => '', "\n" => '', "\t" => ''));
+ $description = strtr($smcFunc['htmlspecialchars']($_POST['description']),
+ array("\r" => '', "\n" => '', "\t" => ''));
+ $deadline = strtr($smcFunc['htmlspecialchars']($_POST['deadline']),
+ array("\r" => '', "\n" => '', "\t" => ''));
$priority = (int) $_POST['priority'];
@@ -1147,36 +1148,142 @@ function super_edit()
if (count($members) AND $state===0) $state = 1;
$smcFunc['db_query']('','
- UPDATE {db_prefix}tasks
- SET name={string:name}, description={string:description}, deadline={string:deadline}, id_proj={int:id_proj}, priority={int:priority}, state={int:state}, start_date = {string:start_date}, end_date = {string:end_date}, end_comment = {string:end_comment}
- WHERE id = {int:id_task}',
- array('name' => $name, 'description' => $description, 'deadline' => $deadline, 'id_proj' => $id_proj, 'id_task' => $id_task, 'priority' => $priority, 'state' => $state, 'start_date' => $start_date, 'end_date' => $end_date, 'end_comment' => $end_comment )
- );
+ UPDATE {db_prefix}tasks
+ SET name={string:name}, description={string:description}, deadline={string:deadline}, id_proj={int:id_proj}, priority={int:priority}, state={int:state}, start_date = {string:start_date}, end_date = {string:end_date}, end_comment = {string:end_comment}
+ WHERE id = {int:id_task}',
+ array(
+ 'name' => $name,
+ 'description' => $description,
+ 'deadline' => $deadline,
+ 'id_proj' => $id_proj,
+ 'id_task' => $id_task,
+ 'priority' => $priority,
+ 'state' => $state,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date,
+ 'end_comment' => $end_comment
+ )
+ );
- // Dodaj delegirane memberje
+ // Dodaj delegirane memberje
$smcFunc['db_query']('', '
- DELETE FROM {db_prefix}workers
+ DELETE FROM {db_prefix}workers
WHERE id_task={int:id_task}',
- array('id_task' => $id_task)
- );
- foreach ( $members as $member) {
- $smcFunc['db_insert']('', '{db_prefix}workers',
- array('id_member' => 'int', 'id_task' => 'int', 'status' => 'int'),
- array((int) $member, $id_task, $state)
+ array('id_task' => $id_task)
);
- }
+
+ foreach ($members as $member) {
+ $smcFunc['db_insert']('', '{db_prefix}workers',
+ array(
+ 'id_member' => 'int',
+ 'id_task' => 'int',
+ 'status' => 'int'
+ ),
+ array((int) $member, $id_task, $state)
+ );
+ }
zapisiLog($id_proj, $id_task, 'super_edit');
+ redirectexit("action=delegator;sa=view_task&id_task=$id_task");
+ } else {
+ redirectexit("action=delegator;sa=view_task&id_task=$id_task");
+ }
+}
+
+/**
+ * Delete project function
+ *
+ * When project gets deleted - all the tasks gets deleted also
+ * When task gets deleted - you must also delete some fields in workers
+ * table. But this is already in del_task function.
+ * What we need is list of tasks in project.
+ * BE CAREFUL WITH PERMISSIONS FOR THIS FUNCTION!
+ *
+ * Delete project happens only on this occasion, so we do not need a wrapper or sub.
+ */
+
+function del_project()
+{
+ global $smcFunc, $context;
+
+ checkSession('get');
+
+ $id_proj = (int) $_GET['id_proj'];
+
+ $tasks = array(); // get list of tasks in projects
+ for ($i=0; $i <= 4; ++$i ){
+ $tasks = array_merge($tasks, ret_tasks($i, "Project", $id_proj, "deadline", 0, 30) );
+ }
- redirectexit('action=delegator;sa=vt&task_id='.$id_task);
+ // delete these tasks is clean.
+ for ($i=0; $i < count($tasks); ++$i) {
+ $id_task = $tasks[$i]["id_task"]; // kako dostopam do task_id-ja sedaj?
+ db_del_task($id_task);
}
- else redirectexit('action=delegator;sa=vt&task_id='.$id_task);
+ zapisiLog($id_proj, -1, 'del_project'); // Has to behappen before DELETE happens...
+
+ $smcFunc['db_query']('', '
+ DELETE FROM {db_prefix}projects
+ WHERE id = {int:id_proj}',
+ array(
+ 'id_proj' => $id_proj
+ )
+ );
+
+ redirectexit('action=delegator');
}
+/**
+ * Edit project function.
+ *
+ * Based on edit task.
+ */
+function edit_project()
+{
+ global $smcFunc, $scripturl, $context, $txt;
+ // var_dump("test"); die;
+ $context['sub_template'] = 'edit_project';
+ $context['linktree'][] = array(
+ 'url' => $scripturl . '?action=delegator;sa=edit_project',
+ 'name' => $txt['delegator_edit_project']
+ );
+}
-is_not_guest();
+/**
+ * Writes edited project to database.
+ *
+ * What happens with the coordinator? Do we also change it?
+ * @todo think about coordinator ...
+ */
+function edit_project_save()
+{
+ global $smcFunc, $context;
-?>
+ //isAllowedTo('add_new_todo');
+
+ checkSession();
+
+ $id_proj = (int) $_POST['id_proj'];
+ $id_coord = (int) $_POST['id_coord'];
+
+ $name = strtr($smcFunc['htmlspecialchars']($_POST['name']), array("\r" => '', "\n" => '', "\t" => ''));
+ $description = strtr($smcFunc['htmlspecialchars']($_POST['description']), array("\r" => '', "\n" => '', "\t" => ''));
+ $start = strtr($smcFunc['htmlspecialchars']($_POST['start']), array("\r" => '', "\n" => '', "\t" => ''));
+ $end = strtr($smcFunc['htmlspecialchars']($_POST['end']), array("\r" => '', "\n" => '', "\t" => ''));
+ //var_dump($id_proj, $id_coord, $name, $description, $start, $end);die;
+ $smcFunc['db_query']('','
+ UPDATE {db_prefix}projects
+ SET name={string:name}, description={string:description}, start={date:start}, end={date:end}, id_coord={int:id_coord}
+ WHERE id = {int:id_proj}',
+ array('name' => $name, 'description' => $description, 'start' => $start, 'end' => $end, 'id_proj' => $id_proj, 'id_coord' => $id_coord)
+ );
+
+ zapisiLog($id_proj, -1, 'edit_proj');
+
+ redirectexit('action=delegator;sa=view_project&id_proj='.$id_proj);
+}
+
+is_not_guest();
diff --git a/delegator/Delegator.template.php b/delegator/Delegator.template.php
index 9aae511..ee91581 100644
--- a/delegator/Delegator.template.php
+++ b/delegator/Delegator.template.php
@@ -1,60 +1,84 @@
wanna build communism?';
- template_button_strip(array(array('text' => 'delegator_task_add', 'image' => 'to_do_add.gif', 'lang' => true, 'url' => $scripturl . '?action=delegator' . ';sa=add', 'active'=> true)), 'right');
- template_button_strip(array(array('text' => 'delegator_project_add', 'image' => 'to_do_add.gif', 'lang' => true, 'url' => $scripturl . '?action=delegator' . ';sa=proj', 'active'=> true)), 'right');
-
+ // Task add button
+ template_button_strip(array(array(
+ 'text' => 'delegator_task_add',
+ 'image' => 'to_do_add.gif',
+ 'lang' => true,
+ 'url' => "$scripturl?action=delegator;sa=add_task",
+ 'active'=> true
+ )), 'right'
+ );
+
+ // Project add button
+ template_button_strip(array(array(
+ 'text' => 'delegator_project_add',
+ 'image' => 'to_do_add.gif',
+ 'lang' => true,
+ 'url' => $scripturl . '?action=delegator;sa=add_project',
+ 'active'=> true
+ )), 'right'
+ );
+
$status = getStatus();
-
- echo '
'.$txt['delegator_state_'.$status ].' '.$txt['delegator_tasks'].' ';
-
+ echo '' . $txt["delegator_state_$status"] . ' ' . $txt['delegator_tasks'] . ' ';
+
// Prestejem taske v posameznih stanjih :)
- $states = count_states(array (0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0), "None", 1);
+ $states = count_states(array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0), "None", 1);
foreach ($states as $status2 => $count){
// FUXK ZA COUNT NE SME BIT PRESLEDKA!!!
- echo ''.$txt['delegator_state_'.$status2].' : '.$states[$status2].'';
+ echo "" . $txt["delegator_state_$status2"] . ' : ' . $states[$status2] . '';
}
- echo ''.$txt['delegator_state_unfinished'].' : '.($states[0]+$states[1]).'';
- echo ''.$txt['delegator_state_finished'].' : '.($states[2]+$states[3]+$states[4]).' ';
+ echo "" . $txt['delegator_state_unfinished'] . ' : ' . ($states[0] + $states[1]) . '';
+ echo "" . $txt['delegator_state_finished'] . ' : ' . ($states[2] + $states[3] + $states[4]) . ' ';
template_show_list('list_tasks');
}
-function template_add()
+
+/**
+ * Add task template
+ *
+ * Querries for projects,
+ */
+function template_add_task()
{
global $scripturl, $context, $txt;
- // id_author, name, description, creation_date, deadline, priority, state
-
- // dobiti moram projekte: // vir: http://wiki.simplemachines.org/smf/Db_query
- global $smcFunc;
+ // id_author, name, description, creation_date, deadline, priority, state
+ // dobiti moram projekte: // vir: http://wiki.simplemachines.org/smf/Db_query
- $id_proj=(isset($_GET['id_proj']) ? $_GET['id_proj'] : FALSE ) ;
+ $id_proj=(isset($_GET['id_proj']) ? (int) $_GET['id_proj'] : FALSE ) ;
- $request = $smcFunc['db_query']('', '
- SELECT id, name
- FROM {db_prefix}projects ', array() ); // pred array je manjkala vejica in je sel cel forum v k
- // Zgoraj je treba querry tako popravit, da bo prikazoval se ne zakljucene projekte (POGOJ danasnji datum je pred koncem projekta)
+ $projects = list_projects();
+ // @todo maybe we could show not finished projects.
echo '
@@ -63,76 +87,35 @@ function template_add()
', $context['page_title'], '
-
' . generateMemberSuggest("to-add", "user-list", "member_add") . '
+
';
+ // @gismoe Tukaj klicemo generateMemberSuggest, ki bi moral kot param dobit
+ // parameter, ki nosi seznam memberjev, ta pa se nikjer ne ustvari ...
}
-//funkcija za dodajanje projektov
-//imena morajo ustrezat subactionnom...
-function template_proj()
+/**
+ * Template for adding projects.
+ */
+function template_add_project()
{
global $scripturl, $context, $txt;
@@ -143,36 +126,16 @@ function template_proj()
', $context['page_title'], '
-
+
-
-
- ', $txt['delegator_project_name'], '
-
-
-
-
-
-
- ', $txt['delegator_project_desc'], '
-
-
-
-
-
- ', $txt['delegator_project_start'], '
-
-
-
-
-
- ', $txt['delegator_project_end'], '
-
-
-
-
+ ';
+ echo dl_form("name", $txt['delegator_project_name'], "input-text", "", "input_text", 50, 255 );
+ echo dl_form("description", $txt['delegator_project_desc'], "textarea", "", "textarea", 3, 30);
+ echo dl_form("start", $txt['delegator_project_start'], "input-text", "", "input_text kalender", 8, 100);
+ echo dl_form("end", $txt['delegator_project_end'], "input-text", "", "input_text kalender", 8, 100);
+ echo '
@@ -184,37 +147,20 @@ function template_proj()
';
}
-function template_vt() // id bi bil kar dober argument
+/**
+ * Template shows particular task.
+ *
+ */
+function template_view_task() // id bi bil kar dober argument
{
- /*
- Imena zadolzitev je treba spremeniti v linke, id se lahko posreduje z metodo GET
- Iz baze moram potegniti podatke o tasku
- Prikazati: Ime, rok, pomembnost
- Opis, opis, opis, opis, opis
- Izvajalce...
- 2 gumba: Back in Submit (nazaj in sprejmi zadolzitev)
- */
- global $scripturl, $context, $txt, $settings;
- global $smcFunc;
- // id_author, name, description, creation_date, deadline, priority, state
- // dobiti moram projekte: // vir: http://wiki.simplemachines.org/smf/Db_query
- $task_id = (int) $_GET['task_id'];
-
- $request = $smcFunc['db_query']('', '
- SELECT T1.id AS id, T1.name AS task_name, T2.name AS project_name, T1.deadline AS deadline, T1.priority AS priority, T1.state AS state, T3.real_name AS author, T1.creation_date AS creation_date, T1.description AS description, T1.id_proj AS id_proj, T1.id_author AS id_author, T1.end_comment, T1.end_date
- FROM {db_prefix}tasks T1
- LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
- LEFT JOIN {db_prefix}members T3 ON T1.id_author = T3.id_member
- WHERE T1.id = {int:task_id} ', array('task_id' => $task_id) ); // pred array je manjkala vejica in je sel cel forum v kT1.state =0
-// id_proj in id_author searchamo, da bomo lahko linkali na view_person in view_proj
-
-/* SELECT *
- FROM {db_prefix}tasks
- WHERE id = '.$task_id .'', array() ); // pred array je manjkala vejica in je sel cel forum v k*/
-// id od zeljenega taska potrebujemo podatke
- $row = $smcFunc['db_fetch_assoc']($request);
-// v tale echo bo padla tudi kaka forma / claim task / edit task
+ global $smcFunc, $scripturl, $context, $txt, $settings;
+ $session_var = $context['session_var'];
+ $session_id = $context['session_id'];
+
+ $id_task = (int) $_GET['id_task'];
+
+ $row = task_info($id_task);
if ($row['priority'] == 0)
$pimage = 'warning_watch';
@@ -223,59 +169,24 @@ function template_vt() // id bi bil kar dober argument
elseif ($row['priority'] == 2)
$pimage = 'warning_mute';
- $session_var = $context['session_var'];
- $session_id = $context['session_id'];
-
- // Imam task claiman?
- $member_id = (int) $context['user']['id'];
-
- $request = $smcFunc['db_query']('',
- 'SELECT id
- FROM {db_prefix}workers
- WHERE id_task = {int:task_id} AND id_member = {int:member_id}',
- array(
- 'task_id' => $task_id,
- 'member_id' => $member_id
- )
- );
-
- $amClaimed = $smcFunc['db_fetch_assoc']($request);
-
- if ($amClaimed !== false) {
- $claimButton = '
' . $txt['delegator_unclaim_task'] . ' ';
- } else {
- $claimButton = '
' . $txt['delegator_claim_task'] . ' ';
+ if (isMemberWorker($id_task)) {
+ $claimButton = '
' . $txt['delegator_unclaim_task'] . ' ';
}
-
- // Seznam delegatov
-
- $request = $smcFunc['db_query']('',
- 'SELECT T1.id_member, T2.real_name
- FROM {db_prefix}workers T1
- LEFT JOIN {db_prefix}members T2 on T1.id_member = T2.id_member
- WHERE id_task = {int:task_id}',
- array(
- 'task_id' => $task_id
- )
- );
-
- $members = array();
- while ($m = $smcFunc['db_fetch_assoc']($request)) {
- $members[$m['id_member']] = $m["real_name"];
+ else {
+ $claimButton = '
' . $txt['delegator_claim_task'] . ' ';
}
+ $workers = workers_on_task($id_task);
+
$delegates = " (\_/)
=(^.^)= Čupi
(\")_(\")";
- if (count($members)) {
- $delegates = ' ';
- //$delegates = implode(", ", $members);
- foreach( $members as $id_member => $real_name ){
- $delegates = $delegates . '
'.$real_name.' ';
- //
\'.$row[\'member\'].\' \'
-}
- }
+ if (count($workers)) {
+ $delegates = ' ';
+ foreach ($workers as $id_member => $real_name) {
+ $delegates = $delegates . "
$real_name ";
+ }}
- echo '
+echo '
@@ -285,94 +196,47 @@ function template_vt() // id bi bil kar dober argument
-
-
- ', $txt['delegator_task_name'], '
-
-
- ', $row['task_name'] ,'
-
-
-
- ', $txt['delegator_task_author'], '
-
-
- ',$row['author'],'
-
-
- ', $txt['delegator_project_name'], '
-
-
- ', $row['project_name'], '
-
-
- ', $txt['delegator_creation_date'], '
-
-
- ', $row['creation_date'] ,'
-
-
- ', $txt['delegator_deadline'], '
-
-
- ', $row['deadline'], ' (' , $row['deadline'], ' )
-
-
- ', $txt['delegator_task_delegates'], '
-
-
- ', $delegates , '
-
-
- ', $txt['delegator_task_desc'], '
-
-
- ', $row['description'] ,'
-
-
- ', $txt['delegator_priority'], '
-
-
- ', $txt['delegator_priority_' . $row['priority']] ,'
-
-
- ', $txt['delegator_state'], '
-
-
- ', $row['state'] ,'
- ';
-
- if ($row['state'] > 1) echo '
-
- ', $txt['delegator_task_end_date'], '
-
- ', $row['end_date'] ,'
-
-
- ', $txt['delegator_task_end_comment'], '
-
- ', $row['end_comment'] ,'
- ';
-
- echo ' ';
- if( $row['state'] < 2) echo $claimButton, '
-
', $txt['delegator_edit_task'] ,'
-
', $txt['delegator_del_task'] ,'
-
- ';
- if(isMemberWorker($task_id) and $row['state']==1) echo '
', $txt['delegator_end_task'] ,' ';
- // TUKAJ PRIDE GUMBEK ZA SUPER_EDIT
- // FORA - zakaj pri canceled tasks manjka super_edit???
- //print_r(isMemberCoordinator($row['id_proj'])); print_r($row['state']);
- if(isMemberCoordinator($row['id_proj']) and $row['state'] > 1) echo '
', $txt['delegator_super_edit'] ,' ';
- echo '
-
-
-
-
-';
-$smcFunc['db_free_result']($request);
+
';
+
+ echo dl_view("name", $txt['delegator_task_name'], "title", $row['task_name'], "");
+ echo dl_view("author", $txt['delegator_task_author'], "link", "view_worker;id_member=".$row['id_author'] , $row['author']);
+ echo dl_view("project_name", $txt['delegator_project_name'], "link", 'view_project;id_proj='.$row['id_proj'] , $row['project_name']);
+ echo dl_view("creation_date", $txt['delegator_creation_date'], "date", $row['creation_date'] , "format-time");
+ echo dl_view("deadline", $txt['delegator_deadline'], "date", $row['deadline'] , "relative-time");
+ echo dl_view("delegates", $txt['delegator_task_delegates'], "description", $delegates, "");
+ echo dl_view("description", $txt['delegator_task_desc'], "description", $row['description'], "");
+ echo dl_view("priority", $txt['delegator_priority'], "priority", $settings['images_url'].'/'.$pimage .'.gif', $txt['delegator_priority_' . $row['priority']]);
+ echo dl_view("state", $txt['delegator_state'], "description", $row['state'] , "");
+
+ if ($row['state'] > 1) {
+ echo dl_view("end_date", $txt['delegator_task_end_date'], "date", $row['end_date'] , "format_time");
+ // var_dump($row); die;
+ echo dl_view("end_comment", $txt['delegator_task_end_comment'], "description", $row['end_comment'], "");
+ }
+ echo ' ';
+
+ if ($row['state'] < 2) {
+ echo $claimButton, '
+
', $txt['delegator_edit_task'], '
+
', $txt['delegator_del_task'] ,' ';
+ }
+
+ if (isMemberWorker($id_task) and $row['state']==1) {
+ echo ' ';
+ echo '
', $txt['delegator_end_task'] ,' ';
+ }
+ if(isMemberCoordinator($row['id_proj']) and $row['state'] > 1) {
+ echo ' ';
+ echo '
', $txt['delegator_super_edit'] ,' ';
+}
+
+ echo '
+
+
+
+
+ ';
}
//##############################//##############################
@@ -380,7 +244,7 @@ function template_vt() // id bi bil kar dober argument
//##############################//##############################
-function template_view_proj()
+function template_view_project()
{
global $scripturl, $context, $txt;
@@ -389,84 +253,65 @@ function template_view_proj()
$id_proj = (int) $_GET['id_proj'];
$status = getStatus();
-
- $request = $smcFunc['db_query']('', '
- SELECT T1.id AS id, T1.name AS proj_name, T1.id_coord AS id_coord, T1.description AS description, T1.start AS start, T1.end AS end, T2.real_name AS coord_name
- FROM {db_prefix}projects T1
- LEFT JOIN {db_prefix}members T2 on T1.id_coord = T2.id_member
- WHERE T1.id = {int:id_proj}', array('id_proj' => $id_proj) ); // pred array je manjkala vejica in je sel cel forum v kT1.state =0
- $row = $smcFunc['db_fetch_assoc']($request);
+ $session_var = $context['session_var']; // we do not understand this ...
+ $session_id = $context['session_id'];
+
+
+ $row = project_info($id_proj);
echo '
-
-
-
- ', $context['page_title'], '
-
-
-
-
-
-
-
- ', $txt['delegator_project_name'], '
-
-
- ', $row['proj_name'] ,'
-
-
- ', $txt['delegator_project_coord'], '
-
-
- ',$row['coord_name'],'
-
-
- ', $txt['delegator_project_start'], '
-
-
- ', $row['start'] ,'
-
-
- ', $txt['delegator_project_end'], '
-
-
- ', $row['end'] ,'
-
-
- ', $txt['delegator_project_desc'], '
-
-
- ', $row['description'] ,'
-
-
-
-
-
', $txt['delegator_task_add'] ,'
-
-
-
-
-
-
-
-';
+
+
+
+ ', $context['page_title'], '
+
+
+
+
+
+
';
+
+ echo dl_view("name", $txt['delegator_project_name'], "title", $row['proj_name'] , "");
+ echo dl_view("coordinator", $txt['delegator_project_coord'], "link", 'view_worker;id_member='.$row['id_coord'] , $row['coord_name']);
+ echo dl_view("start", $txt['delegator_project_start'], "date", $row['start'] , 'format-date');
+ echo dl_view("end", $txt['delegator_project_end'], "date", $row['end'] , 'format-date');
+ echo dl_view("description", $txt['delegator_project_desc'], "description", $row['description'] , '""');
+
+ echo '
+
+
+
', $txt['delegator_task_add'] ,'
+ ';
+ // preverim, ce se lahko narise gumbek za del project
+ // check if the user has permission to delete project
+ // @todo permission check
+ // kako je s tem $scripturl
+ echo '
', $txt['delegator_delete_project'] ,' ';
+
+ echo '
+
', $txt['delegator_edit_project'] ,'
+
+
+
+
+
+
+ ';
- $smcFunc['db_free_result']($request);
// This part shows number of tasks in different state
// @todo this part should be part of some upper div...
// also upper div should be edited properly and nicely
$states = count_states(array (0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0), "Project", $id_proj);
foreach ($states as $status2 => $count){
// FUXK ZA COUNT NE SME BIT PRESLEDKA!!!
- echo ''.$txt['delegator_state_'.$status2].' : '.$states[$status2].'';
+ echo ''.$txt['delegator_state_'.$status2].' : '.$states[$status2].'';
}
- echo ''.$txt['delegator_state_unfinished'].' : '.($states[0] + $states[1]).'';
- echo ''.$txt['delegator_state_finished'].' : '.($states[2]+$states[3]+$states[4]).' ';
+ echo ''.$txt['delegator_state_unfinished'].' : '.($states[0] + $states[1]).'';
+ echo ''.$txt['delegator_state_finished'].' : '.($states[2]+$states[3]+$states[4]).' ';
+
-
template_show_list('list_tasks_of_proj');
}
@@ -479,54 +324,35 @@ function template_view_proj()
function template_view_worker()
{
- global $scripturl, $context, $txt;
- global $smcFunc;
+ global $scripturl, $txt;
$id_member = (int) $_GET['id_member'];
+ $name = member_name($id_member);
- $request = $smcFunc['db_query']('', '
- SELECT T1.real_name AS name FROM {db_prefix}members T1
- WHERE T1.id_member={int:id_member}', array('id_member' => $id_member));
-
- $row = $smcFunc['db_fetch_assoc']($request);
- $smcFunc['db_free_result']($request);
-
- echo ' '. $txt['delegator_worker'] .': '.$row['name']. ' ';
+ echo ' '. $txt['delegator_worker'] .': '.$name. ' ';
$states = count_states(array (1 => 0, 2 => 0, 3 => 0, 4 => 0), "Worker", $id_member);
foreach ($states as $status2 => $count){
- // FUXK ZA COUNT NE SME BIT PRESLEDKA!!!
- echo ''.$txt['delegator_state_'.$status2].' : '.$states[$status2].'';
-
+ echo ''.$txt['delegator_state_'.$status2].' : '.$states[$status2].'';
}
- echo ''.$txt['delegator_state_unfinished'].' : '.$states[1].'';
- echo ''.$txt['delegator_state_finished'].' : '.($states[2]+$states[3]+$states[4]).' ';
-
-
-
- template_show_list('list_tasks_of_worker'); // ko bomo odkomentirali veliki del v Delegator.php, se odkomentira tudi to in vuala, bodo taski...
+ echo ''.$txt['delegator_state_unfinished'].' : '.$states[1].'';
+ echo ''.$txt['delegator_state_finished'].' : '.($states[2]+$states[3]+$states[4]).' ';
+ template_show_list('list_tasks_of_worker');
}
function template_my_tasks()
{
// Tukaj mora biti privzeit status 1!!!
- global $scripturl, $context, $txt;
- global $smcFunc;
+ global $scripturl, $txt, $context;
$id_member = $context['user']['id'];
-
$status = getStatus(true);
- $request = $smcFunc['db_query']('', '
- SELECT T1.real_name AS name FROM {db_prefix}members T1
- WHERE T1.id_member={int:id_member}', array('id_member' => $id_member) );
+ $name = member_name($id_member);
- $row = $smcFunc['db_fetch_assoc']($request);
- $smcFunc['db_free_result']($request);
+ echo ''.$txt['delegator_my_tasks'].' '. $txt['delegator_worker'] .': '.$name. ''.$txt['delegator_state_'.$status].' ';
- echo ''.$txt['delegator_my_tasks'].' '. $txt['delegator_worker'] .': '.$row['name']. ''.$txt['delegator_state_'.$status].' ';
-
$states = count_states(array (1 => 0, 2 => 0, 3 => 0, 4 => 0), "Worker", $id_member);
foreach ($states as $status2 => $count){
// FUXK ZA COUNT NE SME BIT PRESLEDKA!!!
@@ -535,42 +361,39 @@ function template_my_tasks()
}
echo ''.$txt['delegator_state_unfinished'].' : '.$states[1].'';
echo ''.$txt['delegator_state_finished'].' : '.($states[2]+$states[3]+$states[4]).' ';
-
+
template_show_list('list_tasks_of_worker'); // ko bomo odkomentirali veliki del v Delegator.php, se odkomentira tudi to in vuala, bodo taski...
}
function template_view_projects()
{
-
- global $scripturl, $context, $txt;
- global $smcFunc;
+ global $txt;
echo ' '. $txt['delegator_view_projects'] .' ';
- //print_r ("template se nalozi");
-
- template_show_list('list_of_projects'); // ko bomo odkomentirali veliki del v Delegator.php, se odkomentira tudi to in vuala, bodo taski...
+ template_show_list('list_of_projects');
}
function template_view_log()
{
global $scripturl, $context, $txt;
- global $smcFunc;
$session_var = $context['session_var'];
$session_id = $context['session_id'];
-
- template_button_strip(array(array('text' => 'delegator_del_log', 'image' => 'to_do_add.gif', 'lang' => true, 'url' => $scripturl . '?action=delegator' . ';sa=del_log;'.$session_var. '='. $session_id, 'active'=> true)), 'right');
- echo ' '. $txt['delegator_view_log'] .' ';
- //print_r ("template se nalozi");
+ template_button_strip(array(array(
+ 'text' => 'delegator_del_log',
+ 'image' => 'to_do_add.gif',
+ 'lang' => true,
+ 'url' => "$scripturl?action=delegator;sa=del_log;$session_var=$session_id",
+ 'active'=> true
+ )), 'right'
+ );
+ echo ' '. $txt['delegator_view_log'] .' ';
//echo '' . $txt['delegator_del_log'] . ' ';
-
-
-
-
+
template_show_list('log'); // ko bomo odkomentirali veliki del v Delegator.php, se odkomentira tudi to in vuala, bodo taski...
}
@@ -580,52 +403,25 @@ function template_view_log()
//##############################//##############################
//##############################//##############################
-function template_et()
+function template_edit_task()
{
global $scripturl, $context, $txt;
- global $smcFunc;
-
- $id_task = (int) $_GET['task_id'];
- $request = $smcFunc['db_query']('', '
- SELECT T1.id, T1.name AS task_name, T1.deadline, T1.description, T1.priority, T1.id_proj
- FROM {db_prefix}tasks T1
- LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
- LEFT JOIN {db_prefix}members T3 ON T1.id_author = T3.id_member
- WHERE T1.id = {int:id_task}',
- array( 'id_task' => $id_task)
- );
+ $id_task = (int) $_GET['id_task'];
- $row = $smcFunc['db_fetch_assoc']($request);
- $smcFunc['db_free_result']($request);
-
- // Delegirani uporabniki
- $request_d = $smcFunc['db_query']('', '
- SELECT T1.id_member, T2.real_name
- FROM {db_prefix}workers T1
- LEFT JOIN {db_prefix}members T2 ON T1.id_member = T2.id_member
- WHERE T1.id_task = {int:id_task}',
- array('id_task' => $id_task)
- );
+ $row_task = task_info($id_task);
+ $workers = workers_on_task($id_task);
$delegates = "";
- while ($member = $smcFunc['db_fetch_assoc']($request_d)) {
- $id = $member["id_member"];
- $name = $member["real_name"];
+ foreach ($workers as $id_worker => $real_name){
$delegates .=
- '
-
-
' . $name . '
+ '
';
}
- $smcFunc['db_free_result']($request_d);
-
- $request_p = $smcFunc['db_query']('', '
- SELECT id, name
- FROM {db_prefix}projects'
- );
echo '
@@ -634,151 +430,66 @@ function template_et()
', $context['page_title'], '
-
+
+
-
-
- ', $txt['delegator_task_name'], '
-
-
-
-
-
-
- ', $txt['delegator_task_desc'], '
-
-
- '.$row['description'].'
-
-
- ', $txt['delegator_deadline'], '
-
-
-
-
-
- ', $txt['delegator_task_delegates'], '
-
-
-
-
- ' . $delegates . '
-
-
-
- ', $txt['delegator_priority'], '
-
-
-
- ' . getPriorities($row, $txt) . '
-
-
-
- ', $txt['delegator_project_name'], '
-
-
- '; // nadomestil navadno vejico
- while ($row_p = $smcFunc['db_fetch_assoc']($request_p)) {
- if ($row_p['id'] == $row['id_proj']){
- echo '--'.$row_p['name'].'-- ';
- } else {
- echo ' '.$row_p['name'].' ';
- }
- }
- $smcFunc['db_free_result']($request_p);
- echo '
-
-
-
+
';
+ echo dl_form("name",$txt['delegator_task_name'], "input-text", $row_task['task_name'], "input_text", 50, 255 );
+ echo dl_form("description", $txt['delegator_task_desc'], "textarea", $row_task['description'], "", 3, 30);
+ echo dl_form("deadline", $txt['delegator_deadline'], "input-text", $row_task['deadline'], "input_text kalender", 8, 100);
+ echo dl_form("user", $txt['delegator_task_delegates'], "delegates", $delegates, "div");
+ echo dl_form("priority", $txt['delegator_priority'], "priority", getPriorities($row_task, $txt), "reset");
+ echo dl_form("id_proj", $txt['delegator_project_name'], "projects", $row_task['id_proj'], "");
+ echo '
+
Back
-
+
' . generateMemberSuggest("to-add", "user-list", "member_add") . '
+
';
+ // @gismoe zamenjal sem vrstni red forme in memberSuggesta. Je to okej?
}
-//en je okrajsava za end task...
-
-function template_en()
+function template_end_task()
{
global $scripturl, $context, $txt, $settings;
- global $smcFunc;
//$session_var = $context['session_var'];
//$session_id = $context['session_id'];
-
- // rabim samo id_task-a, ki se zakljucuje
-
- $id_task = (int) $_GET['task_id'];
-/***************************************************************************
- ******************* * Podvojeno iz vt *************************************
- **************************************************************************/
+ $id_task = (int) $_GET['id_task'];
+ $row_task = task_info($id_task);
- $request = $smcFunc['db_query']('', '
- SELECT T1.id AS id, T1.name AS task_name, T2.name AS project_name, T1.deadline AS deadline, T1.priority AS priority, T1.state AS state, T3.real_name AS author, T1.creation_date AS creation_date, T1.description AS description, T1.id_proj AS id_proj, T1.id_author AS id_author
- FROM {db_prefix}tasks T1
- LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
- LEFT JOIN {db_prefix}members T3 ON T1.id_author = T3.id_member
- WHERE T1.id = {int:id_task} ', array('id_task' => $id_task) ); // pred array je manjkala vejica in je sel cel forum v kT1.state =0
-// id_proj in id_author searchamo, da bomo lahko linkali na view_person in view_proj
-
-// id od zeljenega taska potrebujemo podatke
- $row = $smcFunc['db_fetch_assoc']($request);
-// v tale echo bo padla tudi kaka forma / claim task / edit task
-
- if ($row['priority'] == 0)
+ if ($row_task['priority'] == 0) {
$pimage = 'warning_watch';
- elseif ($row['priority'] == 1)
+ } elseif ($row_task['priority'] == 1) {
$pimage = 'warn';
- elseif ($row['priority'] == 2)
+ } elseif ($row_task['priority'] == 2) {
$pimage = 'warning_mute';
-
+ }
// Imam task claiman?
$member_id = (int) $context['user']['id'];
-
- $request = $smcFunc['db_query']('',
- 'SELECT id
- FROM {db_prefix}workers
- WHERE id_task = {int:id_task} AND id_member = {int:member_id}',
- array(
- 'id_task' => $id_task,
- 'member_id' => $member_id
- )
- );
-
-
- // Seznam delegatov
-
- $request = $smcFunc['db_query']('',
- 'SELECT T2.real_name
- FROM {db_prefix}workers T1
- LEFT JOIN {db_prefix}members T2 on T1.id_member = T2.id_member
-
- WHERE id_task = {int:id_task}',
- array(
- 'id_task' => $id_task
- )
- );
-
- $members = array();
- while ($m = $smcFunc['db_fetch_assoc']($request)) {
- $members[] = $m["real_name"];
- }
-
+ $workers = workers_on_task($id_task);
$delegates = " (\_/) =(^.^)= Čupi (\")_(\")";
- if (count($members)) {
- $delegates = implode(", ", $members);
+ // var_dump($workers);die;
+
+ if (count($workers)) {
+ $delegates = implode(", ", $workers);
}
-echo '
+ //////////////////////////////////////////////////////////////
+ // kako podvojeno iz view_task
+ //////////////////////////////////////////////////////////////
+
+ echo '
@@ -788,84 +499,29 @@ function template_en()
-
-
- ', $txt['delegator_task_name'], '
-
-
- ', $row['task_name'] ,'
-
-
-
- ', $txt['delegator_task_author'], '
-
-
- ',$row['author'],'
-
-
- ', $txt['delegator_project_name'], '
-
-
- ', $row['project_name'], '
-
-
- ', $txt['delegator_creation_date'], '
-
-
- ', $row['creation_date'] ,'
-
-
- ', $txt['delegator_deadline'], '
-
-
- ', $row['deadline'], ' (' , $row['deadline'], ' )
-
-
- ', $txt['delegator_task_delegates'], '
-
-
- ', $delegates , '
-
-
- ', $txt['delegator_task_desc'], '
-
-
- ', $row['description'] ,'
-
-
- ', $txt['delegator_priority'], '
-
-
- ', $txt['delegator_priority_' . $row['priority']] ,'
-
-
- ', $txt['delegator_state'], '
-
-
- ', $row['state'] ,'
-
+ ';
+ echo dl_view("name", $txt['delegator_task_name'], "title", $row_task['task_name'], "");
+ echo dl_view("author", $txt['delegator_task_author'], "link", "view_worker;id_member=".$row_task['id_author'] , $row_task['author']);
+ echo dl_view("project_name", $txt['delegator_project_name'], "link", 'view_project;id_proj='.$row_task['id_proj'] , $row_task['project_name']);
+ echo dl_view("creation_date", $txt['delegator_creation_date'], "date", $row_task['creation_date'] , "format-time");
+ echo dl_view("deadline", $txt['delegator_deadline'], "date", $row_task['deadline'] , "relative-time");
+ echo dl_view("delegates", $txt['delegator_task_delegates'], "description", $delegates, "");
+ echo dl_view("description", $txt['delegator_task_desc'], "description", $row_task['description'], "");
+ echo dl_view("priority", $txt['delegator_priority'], "priority", $settings['images_url'].'/'.$pimage .'.gif', $txt['delegator_priority_' . $row_task['priority']]);
+ echo dl_view("state", $txt['delegator_state'], "description", $row_task['state'] , "");
+
+ echo '
-
-
-
-';
-$smcFunc['db_free_result']($request);
-
-
-
-/***************************************************************************
- ****************** Konec Podvojitve ***************************************
- **************************************************************************/
-
-/**************************************************************************
- *********** Lepo je, ce se najprej prikaze specifikacija taska
- ******* Treba je se enkrat preverit, ce je trenutni uporabnik tudi izvajalec nadloge!
- ***************************************************************************/
+
+ ';
+ /***************************************************************************
+ ****************** Konec Podvojitve ***************************************
+ **************************************************************************/
echo '
@@ -874,24 +530,21 @@ function template_en()
', $context['page_title'], '
-
+
+
+
-
-
- End Comment
-
-
-
-
-
-
- End state (nacin zakljucka)
-
+ ';
+ echo dl_form("end_comment", $txt['delegator_end_task_comment'], "textarea", "", "textarea", 3, 30);
+ // echo dl_form("state", $txt['delegator_state'], "state", $row_task['state'], "");
+ // echo dl_form("state", $txt['delegator_end_task_state'], "state", 2, 2 );
+ echo '
+ '.$txt['delegator_end_task_state'].'
-
-
' . generateMemberSuggest('to-add', 'user-list', 'member_add') . '
+
';
}
-function template_se()
-{
-
+/**
+ * Templete for editing all tasks.
+ *
+ * Needs workers, project and task from database.
+ */
+function template_super_edit() {
global $scripturl, $context, $txt;
- global $smcFunc;
- $id_task = (int) $_GET['task_id'];
-
- $request = $smcFunc['db_query']('', '
- SELECT T1.id, T1.name AS task_name, T1.deadline, T1.description, T1.priority, T1.id_proj, T1.state, T1.start_date, T1.end_date, T1.end_comment
- FROM {db_prefix}tasks T1
- LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
- LEFT JOIN {db_prefix}members T3 ON T1.id_author = T3.id_member
- WHERE T1.id = {int:id_task}',
- array( 'id_task' => $id_task)
- );
+ $id_task = (int) $_GET['id_task'];
- $row = $smcFunc['db_fetch_assoc']($request);
- $smcFunc['db_free_result']($request);
+ $row_task = task_info($id_task);
// Delegirani uporabniki
- $request_d = $smcFunc['db_query']('', '
- SELECT T1.id_member, T2.real_name
- FROM {db_prefix}workers T1
- LEFT JOIN {db_prefix}members T2 ON T1.id_member = T2.id_member
- WHERE T1.id_task = {int:id_task}',
- array('id_task' => $id_task)
- );
+ $workers = workers_on_task($id_task);
$delegates = "";
- while ($member = $smcFunc['db_fetch_assoc']($request_d)) {
- $id = $member["id_member"];
- $name = $member["real_name"];
+ foreach ($workers as $id => $name){
$delegates .=
'
@@ -950,12 +587,6 @@ function template_se()
';
}
- $smcFunc['db_free_result']($request_d);
-
- $request_p = $smcFunc['db_query']('', '
- SELECT id, name
- FROM {db_prefix}projects'
- );
echo '
@@ -964,121 +595,73 @@ function template_se()
', $context['page_title'], '
-
+
-
-
- ', $txt['delegator_task_name'], '
-
-
-
-
-
-
- ', $txt['delegator_task_desc'], '
-
-
- '.$row['description'].'
-
-
- ', $txt['delegator_deadline'], '
-
-
-
-
-
- ', $txt['delegator_task_delegates'], '
-
-
-
-
- ' . $delegates . '
-
-
-
- ', $txt['delegator_priority'], '
-
-
-
- ' . getPriorities($row, $txt) . '
-
-
-
-
- ', $txt['delegator_project_name'], '
-
-
- '; // nadomestil navadno vejico
- while ($row_p = $smcFunc['db_fetch_assoc']($request_p)) {
- if ($row_p['id'] == $row['id_proj']){
- echo '--'.$row_p['name'].'-- ';
- }
- else {
- echo ' '.$row_p['name'].' ';
- }
- }
- $smcFunc['db_free_result']($request_p);
-
- echo '
-
-
-
-
- ', $txt['delegator_state'], '
-
-
- ';
-
- for ($i = 0; $i <= 5; $i++){
- if ($row['state'] == $i) echo '--'.$txt['delegator_state_'.$i].'-- ';
- else echo ''.$txt['delegator_state_'.$i].' ';
-
- }
-
-
- echo '
-
-
-
-
- ', $txt['delegator_task_start_date'], '
-
-
-
-
-
-
- ', $txt['delegator_task_end_date'], '
-
-
-
-
-
-
-
- ', $txt['delegator_end_comment'], '
-
-
- '.$row['end_comment'].'
-
-
-
-
-
+
';
+ echo dl_form("name",$txt['delegator_task_name'], "input-text", $row_task['task_name'], "input_text", 50, 255 );
+ echo dl_form("description", $txt['delegator_task_desc'], "textarea", $row_task['description'], "", 3, 30);
+ echo dl_form("deadline", $txt['delegator_deadline'], "input-text", $row_task['deadline'], "input_text kalender", 8, 100);
+ echo dl_form("user", $txt['delegator_task_delegates'], "delegates", $delegates, "div");
+ echo dl_form("priority", $txt['delegator_priority'], "priority", getPriorities($row_task, $txt), "reset");
+ echo dl_form("id_proj", $txt['delegator_project_name'], "projects", $row_task['id_proj'], "");
+ echo dl_form("state", $txt['delegator_state'], "state", $row_task['state'], 0);
+ echo dl_form("start_date", $txt['delegator_task_start_date'], "input-text", $row_task['start_date'], "kalender", 8, 100);
+ echo dl_form("end_date", $txt['delegator_task_end_date'], "input-text", $row_task['end_date'], "kalender", 8, 100);
+ echo dl_form("end_comment", $txt['delegator_task_end_comment'], "textarea", $row_task['end_comment'], "", 3, 30);
+ echo '
+
+
-
' . generateMemberSuggest('to-add', 'user-list', 'member_add') . '
+
';
}
-//en je okrajsava za end task...
+function template_edit_project()
+{
+ global $scripturl, $context, $txt;
+ ///////////////////////////////////////////////////////////////
+ //////// Copied mostly from add_project ///////////////////////
+ ///////////////////////////////////////////////////////////////
-?>
+ $id_proj = (int) $_GET['id_proj']; // here is the problem!
+ $row_p = project_info($id_proj);
+
+ echo '
+
+
+
+ ', $context['page_title'], '
+
+
+
+
+
+
+
';
+ echo dl_form("name", $txt['delegator_project_name'], "input-text", $row_p['proj_name'], "input_text", 50, 255 );
+ echo dl_form("description", $txt['delegator_project_desc'], "textarea", $row_p['description'], "textarea", 3, 30);
+ echo dl_form("start", $txt['delegator_project_start'], "input-text", $row_p['start'], "input_text kalender", 8, 100);
+ echo dl_form("end", $txt['delegator_project_end'], "input-text", $row_p['end'], "input_text kalender", 8, 100);
+
+ echo '
+
+
+
+
+
+
+
+
+
+
';
+
+}
diff --git a/delegator/delegator.css b/delegator/delegator.css
new file mode 100644
index 0000000..21ba5f0
--- /dev/null
+++ b/delegator/delegator.css
@@ -0,0 +1,45 @@
+dl.delegator_edit_task
+{
+ margin: 0;
+ clear: right;
+ overflow: auto;
+}
+
+dl.delegator_edit_task dt
+{
+ float: left;
+ clear: both;
+ width: 30%;
+ margin: 0.5em 0 0 0;
+}
+
+dl.delegator_edit_task label
+{
+ font-weight: bold;
+}
+
+dl.delegator_edit_task dd
+{
+ float: left;
+ width: 69%;
+ margin: 0.5em 0 0 0;
+}
+
+#confirm_buttons
+{
+ text-align: center;
+ padding: 1em 0;
+}
+
+table.delegator-sidebar td {
+ border-right: 1.5px solid #CCC;
+ padding: 2px 4px;
+}
+
+table.delegator-sidebar td:last-child {
+ border-right: none;
+}
+
+span.overdue {
+ color: red;
+}
diff --git a/delegator/delegator_helpers.php b/delegator/delegator_helpers.php
index 1cff705..25edc1a 100644
--- a/delegator/delegator_helpers.php
+++ b/delegator/delegator_helpers.php
@@ -1,25 +1,37 @@
';
+ return ' ';
}
-function getPriorities($row, $txt)
-{
+function getPriorities($row, $txt) {
$priorities = "";
for ($i = 0; $i < 3; $i++) {
$checked = ($i == $row["priority"]) ? "checked" : "";
$priorities .= '
-
+
' . $txt['delegator_priority_' . $i] . '
';
@@ -29,7 +41,14 @@ function getPriorities($row, $txt)
// Get status (ce gledas memberja, podas true in gre od 1 naprej)
// @todo Preveri ali je int ali ni!!!
-function getStatus($isMember = false){
+
+/**
+ * Get status function
+ *
+ * Helps us find out which state to choose when making
+ * db querries.
+ */
+function getStatus($isMember = false) {
if( isset($_GET['status']) ){
$status = $_GET['status'];
@@ -40,8 +59,35 @@ function getStatus($isMember = false){
return $status;
}
-// Lahko bi razsiril to funkcijo, da bi pregledala, ce je uporabnik koordinator - bi bila vec uporabna in povabljiva
-function isMemberWorker($id_task){
+
+/**
+ * Returns name of the member.
+ *
+ * Is used in template_my_tasks, template_view_worker
+ * should be the global members table ...
+ */
+function member_name($id_member){
+ global $smcFunc;
+ $request = $smcFunc['db_query']('', '
+ SELECT T1.real_name AS name FROM {db_prefix}members T1
+ WHERE T1.id_member={int:id_member}',
+ array('id_member' => $id_member)
+ );
+
+ $row = $smcFunc['db_fetch_assoc']($request);
+ $smcFunc['db_free_result']($request);
+ return $row['name'];
+}
+
+/**
+ * Checks if specific worker on particular task.
+ *
+ * Actually it works only for active user since
+ * You get the user from inside the function.
+ * It would be nice to make a call with two params
+ * member_id and task_id.
+ */
+function isMemberWorker($id_task) {
// Pogledamo, id memberja in ga primerjamo s taski v tabeli
// Funkcija je tudi pogoj za to, da se v templejtu vt pojavi gumb End_task
global $context, $smcFunc, $scripturl;
@@ -62,29 +108,56 @@ function isMemberWorker($id_task){
return FALSE;
}
-function isMemberCoordinator($id_proj){
+function isMemberCoordinator($id_proj) {
// Pogledamo, id memberja in ga primerjamo s taski v tabeli
- // Funkcija je tudi pogoj za to, da se v templejtu vt pojavi gumb End_task
+ // Funkcija je tudi pogoj za to, da se v templejtu view_task pojavi gumb End_task
global $context, $smcFunc, $scripturl;
-
$id_member = $context['user']['id'];
$request = $smcFunc['db_query']('', '
SELECT id_coord FROM {db_prefix}projects
WHERE id = {int:id_proj}',
- array('id_proj' => $id_proj, ) );
+ array('id_proj' => $id_proj)
+ );
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
- $ret = ($row['id_coord'] == $id_member ? TRUE : FALSE );
+ $ret = ($row['id_coord'] == $id_member) ? TRUE : FALSE;
return $ret;
}
+/**
+ * List of workers that are working on task.
+ *
+ * @return: Array of workers(id => name)
+ */
+function workers_on_task($id_task){
+ global $smcFunc;
+
+ $request = $smcFunc['db_query']('', '
+ SELECT T1.id_member, T2.real_name
+ FROM {db_prefix}workers T1
+ LEFT JOIN {db_prefix}members T2 ON T1.id_member = T2.id_member
+ WHERE T1.id_task = {int:id_task}',
+ array('id_task' => $id_task)
+ );
+
+ $delegates = array();
+ while ($member = $smcFunc['db_fetch_assoc']($request)){
+ $delegates[$member["id_member"]] = $member["real_name"];
+ }
+
+ $smcFunc['db_free_result']($request);
+ return $delegates;
+}
+
+
+/**
+ * Counts number of workers working on a specific task.
+ */
+function numberOfWorkers($id_task) {
-function numberOfWorkers($id_task){
- // Presteje Stevilo Workerjev
- // Trenutno se uporabi zgolj v unclaim, saj smo add_task in edit_task resili bolj elegantno...
global $context, $smcFunc;
$request = $smcFunc['db_query']('', '
@@ -97,33 +170,42 @@ function numberOfWorkers($id_task){
}
-function zapisiLog($id_proj, $id_task, $action){
- // Input: action - selfexplanatory
- // Output: None
- // What function does: Writes action into log table
- // Notation: When there is action on project id_task is less than zero (-1)
+/**
+ * Writes Log about current action.
+ *
+ * Notation: When there is action on project id_task is less than zero (-1)
+ */
+function zapisiLog($id_proj, $id_task, $action) {
global $smcFunc, $context;
-
$id_member = $context['user']['id'];
//checkSession(); // ali to rabimo???
//najbrz ne, ker se vedno klice samo v funkcijah, ki so ze preverile session, al kaj... 3h je slo za to!!!
- if ($id_proj < 0){
+ if ($id_proj < 0) {
$request = $smcFunc['db_query']('', '
SELECT id_proj FROM {db_prefix}tasks
- WHERE id = {int:id_task}', array('id_task' => $id_task) );
+ WHERE id = {int:id_task}', array('id_task' => $id_task)
+ );
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
$id_proj = $row['id_proj'];
}
- $smcFunc['db_insert']('', '{db_prefix}delegator_log',
- array('id_proj' => 'int', 'id_task' => 'int', 'action' => 'string', 'id_member' => 'int', 'action_date' => 'string' ),
- array( $id_proj, $id_task, $action, $id_member, date('Y-m-d H-i-s') ),
- array() );
+ $smcFunc['db_insert']('', '
+ {db_prefix}delegator_log',
+ array(
+ 'id_proj' => 'int',
+ 'id_task' => 'int',
+ 'action' => 'string',
+ 'id_member' => 'int',
+ 'action_date' => 'string'
+ ),
+ array($id_proj, $id_task, $action, $id_member, date('Y-m-d H-i-s')),
+ array()
+ );
// array( $id_proj, $id_task, $action, $id_member, date('Y-m-d') ),
}
@@ -131,123 +213,227 @@ function zapisiLog($id_proj, $id_task, $action){
// Druga Funkcija dobi iste argumente in vrne stevilo taskov...
// Fora je, da se bo dalo rezultate obeh funkcij združit/seštet...
-
+/**
+ * Returns array of tasks given the paramaters.
+ *
+ * Tasks of specific state, worker or project
+ * @var: int(status), string(what), (int)value, sort=deadline, start=0, items_per_page=30
+ * $what = [None, Project, Worker]
+ * @return: list of tasks (as $row)
+ */
function ret_tasks($status, $what, $value, $sort, $start, $items_per_page){
- /*****************************************
- Input: $status (int), $what(string) $value(int)
- !!! Much attention needed: $what = [None, Project, Worker]
-
- **************************************** */
global $smcFunc;
if ($what == "None") {
-
$query = '
- SELECT T1.id AS id_task, T1.name AS task_name, T2.name AS project_name, T1.deadline AS deadline, T1.priority AS priority, T1.state AS state, T3.real_name AS author, T1.id_proj AS id_proj, T1.id_author AS id_author, T1.creation_date, T1.end_date AS end_date
- FROM {db_prefix}tasks T1
- LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
- LEFT JOIN {db_prefix}members T3 ON T1.id_author = T3.id_member
- WHERE T1.state = {int:state}
- ORDER BY {raw:sort}
- LIMIT {int:start}, {int:per_page}';
+ SELECT T1.id AS id_task, T1.name AS task_name, T2.name AS project_name,
+ T1.deadline AS deadline, T1.priority AS priority, T1.state AS state,
+ T3.real_name AS author, T1.id_proj AS id_proj, T1.id_author AS id_author,
+ T1.creation_date, T1.end_date AS end_date
+ FROM {db_prefix}tasks T1
+ LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
+ LEFT JOIN {db_prefix}members T3 ON T1.id_author = T3.id_member
+ WHERE T1.state = {int:state}
+ ORDER BY {raw:sort}
+ LIMIT {int:start}, {int:per_page}';
$values = array (
'state' => $status,
'sort' => $sort,
'start' => $start,
- 'per_page' => $items_per_page,);
-
- }
-
- elseif ($what == "Project") {
- $query = '
- SELECT T1.id AS id_task, T1.name AS task_name, T2.name AS project_name, T1.deadline AS deadline, T1.priority AS priority, T1.state AS state, T3.real_name AS author, T1.id_proj AS id_proj, T1.id_author AS id_author, T1.creation_date, T1.end_date AS end_date
- FROM {db_prefix}tasks T1
- LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
- LEFT JOIN {db_prefix}members T3 on T1.id_author = T3.id_member
- WHERE T1.state = {int:state} AND T1.id_proj = {int:id_proj}
- ORDER BY {raw:sort}
- LIMIT {int:start}, {int:per_page}';
-
- $values = array(
- 'state' => $status,
- 'id_proj' => $value,
- 'sort' => $sort,
- 'start' => $start,
- 'per_page' => $items_per_page);
- }
-
- elseif ($what == "Worker"){
- $query = 'SELECT T1.id_task AS id_task,T2.name AS task_name, T3.name AS project_name, T2.deadline AS deadline, T2.priority AS priority, T2.state AS state, T4.real_name AS author, T2.id_proj AS id_proj, T2.id_author AS id_author, T2.creation_date, T2.end_date AS end_date
- FROM {db_prefix}workers T1
- LEFT JOIN {db_prefix}tasks T2 ON T1.id_task = T2.id
- LEFT JOIN {db_prefix}projects T3 ON T2.id_proj = T3.id
- LEFT JOIN {db_prefix}members T4 ON T2.id_author = T4.id_member
- WHERE T1.id_member={int:id_member} AND T1.status = {int:status}
- ORDER BY {raw:sort}
- LIMIT {int:start}, {int:per_page}';
-
- $values = array(
+ 'per_page' => $items_per_page
+ );
+ } elseif ($what == "Project") {
+ $query = '
+ SELECT T1.id AS id_task, T1.name AS task_name, T2.name AS project_name,
+ T1.deadline AS deadline, T1.priority AS priority, T1.state AS state,
+ T3.real_name AS author, T1.id_proj AS id_proj, T1.id_author AS id_author,
+ T1.creation_date, T1.end_date AS end_date
+ FROM {db_prefix}tasks T1
+ LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
+ LEFT JOIN {db_prefix}members T3 on T1.id_author = T3.id_member
+ WHERE T1.state = {int:state} AND T1.id_proj = {int:id_proj}
+ ORDER BY {raw:sort}
+ LIMIT {int:start}, {int:per_page}';
+ $values = array(
+ 'state' => $status,
+ 'id_proj' => $value,
+ 'sort' => $sort,
+ 'start' => $start,
+ 'per_page' => $items_per_page
+ );
+ } elseif ($what == "Worker") {
+ $query = '
+ SELECT T1.id_task AS id_task,T2.name AS task_name, T3.name AS project_name,
+ T2.deadline AS deadline, T2.priority AS priority, T2.state AS state,
+ T4.real_name AS author, T2.id_proj AS id_proj, T2.id_author AS id_author,
+ T2.creation_date, T2.end_date AS end_date
+ FROM {db_prefix}workers T1
+ LEFT JOIN {db_prefix}tasks T2 ON T1.id_task = T2.id
+ LEFT JOIN {db_prefix}projects T3 ON T2.id_proj = T3.id
+ LEFT JOIN {db_prefix}members T4 ON T2.id_author = T4.id_member
+ WHERE T1.id_member={int:id_member} AND T1.status = {int:status}
+ ORDER BY {raw:sort}
+ LIMIT {int:start}, {int:per_page}';
+ $values = array(
'id_member' => $value,
'status' => $status,
'sort' => $sort,
'start' => $start,
'per_page' => $items_per_page,
- );
+ );
+ } else {
+ return "Wrong input";
}
-
- else {return "Wrng input"; }
-
- $request = $smcFunc['db_query']('', $query , $values );
+ $request = $smcFunc['db_query']('', $query , $values);
$tasks = array();
- while ($row = $smcFunc['db_fetch_assoc']($request))
+ while ($row = $smcFunc['db_fetch_assoc']($request)) {
$tasks[] = $row;
+ }
$smcFunc['db_free_result']($request);
- return $tasks; //funkcija vrne taske
-
- }
+ return $tasks; //funkcija vrne taske
+}
+/**
+ * Returns number of database fields (tasks, projects and workers).
+ *
+ * @var: int(status), string(what), (int)value
+ * $what = [None, Project, Worker]
+ * @return: number of tasks/workers/projects (as $row)
+ */
function ret_num($status, $what, $value){
global $smcFunc;
$query = 'SELECT COUNT(id) FROM {db_prefix}';
if ($what == "None") {
- $query = $query . 'tasks WHERE state={int:state}';
- $values = array ('state' => $status );
-
- }
- elseif ($what == "Project") {
- $query = $query . 'tasks WHERE state = {int:state} AND id_proj = {int:id_proj}';
- $values = array ('state' => $status,
- 'id_proj' => $value,);
- }
- elseif ($what == "Worker"){
+ $query = $query . 'tasks
+ WHERE state={int:state}';
+ $values = array('state' => $status);
+
+ } elseif ($what == "Project") {
+ $query = $query . 'tasks
+ WHERE state = {int:state} AND id_proj = {int:id_proj}';
+ $values = array(
+ 'state' => $status,
+ 'id_proj' => $value
+ );
+ } elseif ($what == "Worker") {
$query = $query . 'workers
- WHERE id_member={int:id_member} AND status = {int:status}';
- $values = array ('id_member' => $value,
- 'status' => $status,);
+ WHERE id_member={int:id_member} AND status = {int:status}';
+ $values = array(
+ 'id_member' => $value,
+ 'status' => $status
+ );
}
- $request = $smcFunc['db_query']('', $query , $values );
+ $request = $smcFunc['db_query']('', $query , $values);
list($total_tasks) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
return $total_tasks;
}
+/**
+ * Creates string of html for input form.
+ *
+ * Used in add_task, add_project and all of the edit forms.
+ * @param name txt type value size1 size2 class
+ * @txt is string that is in $txt global variable
+ * type: textarea, input-text
+ * in case of textarea: size1=rows size2=cols
+ * in case of input text: size1=size size2=maxlength
+ */
+function dl_form($name, $text, $type, $value, $class, $size1=0, $size2=0){
+
+ global $txt;
+
+ $output = "\n\t".' '.$text.' '."\n\t".'';
+ switch($type) {
+ case "textarea":
+ $output .= ''.
+ $value.' '."\n";
+ break;
+ case "input-text":
+ $output .= ' '."\n";
+ break;
+ case "delegates": // drgac za add_task in druge ...
+ $output .= ' ';
+ if (strlen($class)) $output .= ''.$value .'
'."\n";
+ else $output .= "\t\t".' '."\n";
+ break;
+ case "priority":
+ $output .= ''."\n";
+ break;
+ case "projects":
+ $output .= '';
+ $projects = list_projects();
+ foreach ($projects as $id_proj => $proj_name){
+ if ($id_proj == $value) $output .= "\t\t".'--'.$proj_name.'-- ' ."\n";
+ else $output .= "\t\t".' '.$proj_name.' ' ."\n";}
+ $output .= "\t".' '."\n";
+ break;
+ case "state": // $class represents starting state
+ $output .= ''."\n";
+ for ($i = $class; $i <= 5; $i++) {
+ if ($value == $i) $output .= "\t\t".'--'.$txt['delegator_state_'.$i].'-- '."\n";
+ else $output .= "\t\t".''.$txt['delegator_state_'.$i].' ' . "\n";
+ }
+ $output .= "\t".' '."\n";
+ break;
+ }
+ return $output;
+}
+
+/**
+ * Creates string of html for view template - descriptive list.
+ *
+ * Used in view templates.
+ * @param name, txt, type, value, class
+ * depending on type - class might also mean value2
+ */
+function dl_view($name, $text, $type, $value, $class){
+ global $scripturl;
+
+ $output = "\n".''.$text.' '."\n".'';
+ switch ($type) {
+ case "title":
+ $output .= ''.$value.' '."\n";
+ break;
+ case "link":
+ $output .= ''.$class.' '."\n";
+ break;
+ case "date":
+ $output .= ''.$value.' '."\n";
+ break;
+ case "description": // also delegates
+ $output .= $value.''."\n";
+ break;
+ case "priority":
+ $output .= ' '.$class.''."\n";
+ break;
+ }
+ return $output;
+}
// status bi lahko bil argument in glede na to vrnil deadline...
// @todo function show_task_list($finished=false) {
// @todo lahko bi se napisalo funkcijo, ki dobi argumente 'name', 'header', 'data'...
-function show_task_list($status) {
- if ($status === "unfinished") $status = 0;
- elseif ($status === "finished") $status = 2;
- //else $status = $status;
+/**
+ * Complete list of tasks compatible with SMF presentation.
+ *
+ * @return list of tasks.
+ */
+function show_task_list($status) {
global $txt, $scripturl;
- //ena moznost je, da preverim stanje tu v funkciji, druga pa, da ga dam kot argument...
+
+ if ($status === "unfinished") {
+ $status = 0;
+ } elseif ($status === "finished") {
+ $status = 2;
+ }
$columns = array(
'name' => array( // TASK
@@ -255,8 +441,8 @@ function show_task_list($status) {
'value' => $txt['delegator_task_name'], //Napisi v header "Name"... potegne iz index.english.php
),
'data' => array( // zamenjal sem napisano funkcijo od grafitus-a...
- 'function' => function($row) {
- return ''.$row['task_name'].' ';
+ 'function' => function($row) use ($scripturl) {
+ return ''.$row['task_name'].' ';
}
),
'sort' => array(
@@ -264,14 +450,13 @@ function show_task_list($status) {
'reverse' => 'task_name DESC',
),
),
-
'project' => array( //PROJEKT - dela!
'header' => array(
'value' => $txt['delegator_project_name'], //dodano v modification.xml
),
'data' => array(
- 'function' => function($row) {
- return ''.$row['project_name'].' ';
+ 'function' => function($row) use ($scripturl) {
+ return ''.$row['project_name'].' ';
}
),
'sort' => array(
@@ -285,7 +470,7 @@ function show_task_list($status) {
'value' => $txt['delegator_author'], //dodano v modification.xml
),
'data' => array(
- 'function' => function($row) {
+ 'function' => function($row) use ($scripturl) {
return ''.$row['author'].' ';
}
),
@@ -294,43 +479,7 @@ function show_task_list($status) {
'reverse' => 'author DESC',
),
),
- //////////////////////////////// Ali bi lahko tukaj if stavek uturil?
- /////////////////////////////// Mislim, da ne, ker sem v arrayu...
- /*'deadline' => array(
- 'header' => array(
- 'value' => function () use ($status, $txt){
- if ($status < 2) return $txt['delegator_deadline'];
- else return $txt['delegator_task_end_date'];
- },
- ),
- 'data' => array(
- 'function' => function($row) use ($status) {
- if ($status < 2) {
- $deadline = $row['deadline'];
- if (date('Y-m-d') > $deadline) return "$deadline ";
- else return "$deadline ";
- }
- else {
- return $row['end_date'];
- }
- },
- ),
- //'style' => 'width: 20%; text-align: center;',
-
- 'sort' => array(
- 'default' => 'deadline',
- 'reverse' => 'deadline DESC',
- //'default' => function () use ($status){
- // if ($status < 2) return 'deadline';
- // else return 'end_date';
- //},
- //'reverse' => function () use ($status){
- // if ($status < 2) return 'deadline DESC';
- // else return 'end_date DESC';
- // }
- ),
- ),*/
'deadline' => array(
'header' => array(
'value' => $txt['delegator_deadline'],
@@ -338,9 +487,9 @@ function show_task_list($status) {
'data' => array(
'function' => function($row) use ($status) {
$deadline = $row['deadline'];
- if (date('Y-m-d') > $deadline and $status < 2) return "$deadline ";
+ if (date('Y-m-d') > $deadline and $status < 2) return "$deadline ";
elseif ($status > 1){
- if ($row['end_date'] > $deadline) return "$deadline ";
+ if ($row['end_date'] > $deadline) return "$deadline ";
else return $deadline;
}
@@ -354,13 +503,14 @@ function show_task_list($status) {
'reverse' => 'deadline DESC',
),
),
- //////////////////////////////////////
- // spet undefined index priority je v errolog-u
+ // spet undefined index priority je v errolog-u
'priority' => array( //POMEMBNOST
'header' => array(
'value' => $txt['delegator_priority'],
),
'data' => array(
+ // @todo Use of undefined constant getPriorityIcon - assumed 'getPriorityIcon'
+ // @gismoe bi to znal resit
'function' => getPriorityIcon,
'style' => 'width: 10%; text-align: center;',
),
@@ -391,60 +541,35 @@ function show_task_list($status) {
global $context, $settings, $scripturl;
if ($status < 2 ){
// ali pa ce bi to totalno skrajsal...
- if (isMemberCoordinator($row['id_proj'])===TRUE){
+ if (isMemberCoordinator($row['id_proj'])===TRUE) {
return '
-
-
-
-
-
-
-';
+
+
+
+
+
+ ';
+ } else {
+ return '
+
+
+
+
+
+ ';
}
- else {
- return '
-
-
-
-
-
- ';}}
- else {
+ } else {
return '
-
-
- ';
-
+
+
+ ';
}
- },
- 'style' => 'width: 10%; text-align: center;',
+ },
+ 'style' => 'width: 10%; text-align: center;',
),
),
);
- /* Hotel sem zamenjat deadline z end_date, pa query potem noce vec delat...
- if ($status > 1){
- $end_date = array (
- 'header' => array(
- 'value' => $txt['delegator_task_end_date'],
- ),
- 'data' => array(
- 'function' => function($row) {
- if ($row['end_date'] > $row['deadline']) return ''.$row['end_date'].' ';
- return $row['end_date']; },
- //'style' => 'width: 20%; text-align: center;',
- ),
- 'sort' => array(
- 'default' => 'end_date',
- 'reverse' => 'end_date DESC',
- ),
- );
- // sedaj moram pa to zamenjat...
- //$columns['end_date'] = $end_date;
- //unset($columns['deadline']);
- }*/
-
-
return $columns;
}
@@ -478,93 +603,238 @@ function generateMemberSuggest ($input, $container, $param) {
// ]]>';
}
+/**
+ * Recieves table of states and counts the databes imports of given state.
+ *
+ * @var: array(states), string(what), (int)value
+ * $what = [None, Project, Worker]
+ * @return: list of tasks (as $row)
+ *
+ * @todo case statement
+ */
function count_states($states, $what, $value){
//dobi tabelo stanj in jo dopolni...
// @todo Naslednji korak k temu, da iz Delegator.template odstranimo queryje
global $smcFunc, $txt, $scripturl, $context;
- if ($what==="Worker" ){
+ if ($what==="Worker") {
// Workers don't have state 0
- $query = 'SELECT COUNT(id) FROM {db_prefix}workers
+ $query = '
+ SELECT COUNT(id) FROM {db_prefix}workers
WHERE id_member={int:id_member} AND status = {int:status}';
- $values = function ($status) use ($value) {return array ('id_member' => $value, 'status' => $status);};
- }
- elseif ($what==="None"){
- $query = 'SELECT COUNT(id) FROM {db_prefix}tasks
+ $values = function ($status) use ($value) {
+ return array(
+ 'id_member' => $value,
+ 'status' => $status
+ );
+ };
+ } elseif ($what==="None") {
+ $query = '
+ SELECT COUNT(id) FROM {db_prefix}tasks
WHERE state = {int:state}';
- $values = function ($status) {return array ('state' => $status);};
- }
- elseif ($what==="Project"){
- $query = 'SELECT COUNT(id) FROM {db_prefix}tasks
- WHERE state = {int:state} AND id_proj = {int:id_proj}';
- $values = function ($status) use ($value) {return array ('state' => $status, 'id_proj' => $value);};
+ $values = function ($status) {
+ return array('state' => $status);
+ };
+ } elseif ($what==="Project") {
+ $query = '
+ SELECT COUNT(id) FROM {db_prefix}tasks
+ WHERE state = {int:state} AND id_proj = {int:id_proj}';
+ $values = function ($status) use ($value) {
+ return array(
+ 'state' => $status,
+ 'id_proj' => $value
+ );
+ };
}
+
foreach($states as $status => $count){
$request = $smcFunc['db_query']('', $query, $values($status));
$row = $smcFunc['db_fetch_assoc']($request);
$states[$status] = $row['COUNT(id)'];
$smcFunc['db_free_result']($request);
-
}
+
return $states;
}
-function delegator_send_mail(){
+function delegator_send_mail($type, $members, $data){
- $request = $smcFunc['db_query']('', '
- SELECT T2.real_name AS member, T2.email_address AS email, T3.name AS project_name, T4.name AS task_name, T4.description AS description
- FROM {db_prefix}workers T1
- LEFT JOIN {db_prefix}members T2 ON T1.id_member = T2.id_member
- LEFT JOIN {db_prefix}tasks T4 ON T1.id_task = T4.id
- LEFT JOIN {db_prefix}projects T3 ON T4.id_proj = T3.id
- WHERE T1.id_task = {int:id_task}
- ', array(
- "id_task" => $id_task
- )
- );
- $workerji = array();
- $emaili = array();
- $projekt = "";
- $task = "";
- $opis = "";
- while ($row = $smcFunc['db_fetch_assoc']($request)) {
- $workerji[] = $row["member"];
- $emaili[] = $row["email"];
- $projekt = $row["project_name"];
- $task = $row["task_name"];
- $opis = $row["description"];
- }
- $smcFunc['db_free_result']($request);
+ global $smcFunc, $txt, $scripturl, $context;
- $statusi = [
- 2 => "uspešno",
- 3 => "neuspešno",
- 4 => "preklicano"
- ];
- $status = $statusi[$state];
- $subject = "Opravilo $task v projektu $projekt zaključeno ($status)";
+ /*
+ $request = $smcFunc['db_query']('', '
+ SELECT T2.real_name AS member, T2.email_address AS email, T3.name AS project_name,
+ T4.name AS task_name, T4.description AS description
+ FROM {db_prefix}workers T1
+ LEFT JOIN {db_prefix}members T2 ON T1.id_member = T2.id_member
+ LEFT JOIN {db_prefix}tasks T4 ON T1.id_task = T4.id
+ LEFT JOIN {db_prefix}projects T3 ON T4.id_proj = T3.id
+ WHERE T1.id_task = {int:id_task}
+ ', array(
+ "id_task" => $id_task
+ )
+ );
- $body = "Pri projektu $projekt je bilo zaključeno opravilo $task, s stanjem \"$status\".\n";
- $body .= "Opis:\n$opis\nOpravilo so zaključili: ";
- $body .= implode(", ", $workerji) . ". Slava jim!\n";
+ $workerji = array();
+ $emaili = array();
+ $projekt = "";
+ $task = "";
+ $opis = "";
+ while ($row = $smcFunc['db_fetch_assoc']($request)) {
+ $workerji[] = $row["member"];
+ $emaili[] = $row["email"];
+ $projekt = $row["project_name"];
+ $task = $row["task_name"];
+ $opis = $row["description"];
+ }
+ $smcFunc['db_free_result']($request);
- // @TODO test? nevem ce dela to sploh.
- sendmail($emaili, $subject, $body, null, null, false, 5);
- /*
- var_dump($emaili);
- var_dump($subject);
- var_dump($body);
- die();
- */
+ $statusi = [
+ 2 => "uspešno",
+ 3 => "neuspešno",
+ 4 => "preklicano"
+ ];
+ $status = $statusi[$state];
+ $subject = "Opravilo $task v projektu $projekt zaključeno ($status)";
+
+ $body = "Pri projektu $projekt je bilo zaključeno opravilo $task, s stanjem \"$status\".\n";
+ $body .= "Opis:\n$opis\nOpravilo so zaključili: ";
+ $body .= implode(", ", $workerji) . ". Slava jim!\n";
+
+ // @TODO test? nevem ce dela to sploh.
+ sendmail($emaili, $subject, $body, null, null, false, 5);
+ var_dump($emaili);
+ var_dump($subject);
+ var_dump($body);
+ die();
+ */
+
+ switch ($type) {
+ // Email for delegation
+ case "delegate":
+ $subject = "Delegiran si bil na opravilo " . $data["name"];
+ $body =
+ "Delegiran si bil na task" . $data["name"] . "\n" .
+ "Opis:\n" .
+ $data["description"] . "\n" .
+ "Prioriteta: " . $data["priority"] .
+ "Delegiral te je: " . $data["delegator"] .
+ "Link: ' . $data['name'] . ' ';
+
+ sendmail($members, $subject, $body, null, null, false, 5);
+
+ break;
+ }
- // @TODO pošlji tudi koordinatorju (ne samo delavcem)
+ // @TODO pošlji tudi koordinatorju (ne samo delavcem)
- // @TODO Dodajmo proper email template za notifikacijo ob zaključitvi taska
- //$emaildata = loadEmailTemplate('new_announcement', $replacements, $cur_language);
+ // @TODO Dodajmo proper email template za notifikacijo ob zaključitvi taska
+ //$emaildata = loadEmailTemplate('new_announcement', $replacements, $cur_language);
+}
+/**
+ * Deletes from database.
+ */
+function db_del_task($id_task){
+ global $smcFunc, $txt, $scripturl, $context;
+
+ zapisiLog(-1, $id_task, 'del_task'); // Has to be before DELETE happens...
+
+ $smcFunc['db_query']('', '
+ DELETE FROM {db_prefix}tasks
+ WHERE id = {int:id_task}',
+ array(
+ 'id_task' => $id_task
+ )
+ );
+
+ $smcFunc['db_query']('', '
+ DELETE FROM {db_prefix}workers
+ WHERE id_task = {int:id_task}',
+ array(
+ 'id_task' => $id_task
+ )
+ );
+}
+
+/**
+ * Returns project information as row.
+ *
+ * Creates a database querry.
+ * IN: template_view_project
+ */
+function project_info($id_proj){
+
+ global $smcFunc, $txt, $scripturl, $context;
+
+ $request = $smcFunc['db_query']('', '
+ SELECT T1.id AS id, T1.name AS proj_name, T1.id_coord AS id_coord,
+ T1.description AS description, T1.start AS start, T1.end AS end,
+ T2.real_name AS coord_name
+ FROM {db_prefix}projects T1
+ LEFT JOIN {db_prefix}members T2 on T1.id_coord = T2.id_member
+ WHERE T1.id = {int:id_proj}', array('id_proj' => $id_proj)
+ ); // pred array je manjkala vejica in je sel cel forum v kT1.state =0
+
+ $row = $smcFunc['db_fetch_assoc']($request);
+
+ $smcFunc['db_free_result']($request);
+
+ return $row;
}
-?>
+/**
+ * Returns list of projects
+ *
+ * IN: template_edit_task, template_add_task, template_super_edit
+ */
+
+function list_projects(){
+ global $smcFunc, $txt, $scripturl, $context;
+
+ $request_p = $smcFunc['db_query']('', '
+ SELECT id, name
+ FROM {db_prefix}projects'
+ );
+
+ $projects = array();
+
+ while ($row_p = $smcFunc['db_fetch_assoc']($request_p)) {
+ $projects[$row_p["id"]] = $row_p["name"];
+ }
+ $smcFunc['db_free_result']($request_p);
+
+ return $projects;
+}
+
+/**
+ * Information about task.
+ *
+ * Workers/delegates are missing.
+ * IN: template_edit_task,
+ * @return task info as (array)row.
+ */
+function task_info($id_task){
+
+ global $smcFunc;
+
+ $request = $smcFunc['db_query']('', '
+ SELECT T1.id, T1.name AS task_name, T1.deadline,
+ T1.description, T1.priority, T1.id_proj, T1.id_author, T1.state, T1.start_date,
+ T1.end_date, T1.end_comment, T3.real_name AS author, T1.creation_date,
+ T2.name AS project_name
+ FROM {db_prefix}tasks T1
+ LEFT JOIN {db_prefix}projects T2 ON T1.id_proj = T2.id
+ LEFT JOIN {db_prefix}members T3 ON T1.id_author = T3.id_member
+ WHERE T1.id = {int:id_task}',
+ array('id_task' => $id_task)
+ );
+
+ $row = $smcFunc['db_fetch_assoc']($request);
+ $smcFunc['db_free_result']($request);
+ return $row;
+}
diff --git a/delegator/delegator_sidebar.php b/delegator/delegator_sidebar.php
index 921beae..c742d39 100644
--- a/delegator/delegator_sidebar.php
+++ b/delegator/delegator_sidebar.php
@@ -20,7 +20,7 @@ function getPriorityIcon2($row) {
}
function show(){
-
+
global $smcFunc, $context, $txt, $scipturl;
$id_member = $context['user']['id'];
@@ -59,10 +59,10 @@ function show(){
echo '