PDA

View Full Version : Privleged Task Creation


spabla
10-09-08, 06:55 AM
Wondering if anyone has encountered this issue. When creating tasks I am able to create tasks that are of the following access type:

Public
Participant
Protected
Private

But as soon as I try to create a task of access type Privileged I get the following dump on the screen.

ERROR: /var/www/dp/classes/query.class.php(623): query failed(SELECT COUNT(ut.*) AS user_task_count FROM ( `user_tasks` as ut ) WHERE ut.user_id = 1 AND ut.task_id = 6) - error was: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS user_task_count FROM ( `user_tasks` as ut ) WHERE ut.user_id = 1 AND ut.ta' at line 1
Backtrace:
0 /var/www/dp/classes/query.class.php:623 dprint('/var/www/dp/classes/query.class.php',623,0,'query failed(SELECT COUNT(ut.*) AS user_task_count FROM ( `user_tasks` as ut ) WHERE ut.user_id = 1 AND ut.task_id = 6) - error was: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'*) AS user_task_count FROM ( `user_tasks` as ut ) WHERE ut.user_id = 1 AND ut.ta\' at line 1')
1 /var/www/dp/classes/query.class.php:775 exec(1)
2 /var/www/dp/modules/tasks/tasks.class.php:1307 loadResult()
3 /var/www/dp/modules/tasks/tasks.class.php:2282 canAccess('1')
4 /var/www/dp/modules/tasks/tasks.php:640 showtask(array (
0 => '6',
'task_id' => '6',
1 => '6',
'task_parent' => '6',
2 => 'NewPrivTask',
'task_name' => 'NewPrivTask',
3 => '2008-09-09 08:15:00',
'task_start_date' => '2008-09-09 08:15:00',
4 => '2008-09-09 09:15:00',
'task_end_date' => '2008-09-09 09:15:00',
5 => '0',
'task_dynamic' => '0',
6 => NULL,
'task_pinned' => NULL,
7 => NULL,
'pin_user' => NULL,
8 => '0',
'task_priority' => '0',
9 => '0',
'task_percent_complete' => '0',
10 => '1',
'task_duration' => '1',
11 => '1',
'task_duration_type' => '1',
12 => '2',
'task_project' => '2',
13 => NULL,
'task_description' => NULL,
14 => '1',
'task_owner' => '1',
15 => '0',
'task_status' => '0',
16 => 'admin',
'user_username' => 'admin',
17 => '1',
'user_id' => '1',
18 => '0',
'task_milestone' => '0',
19 => 'admin',
'assignee_username' => 'admin',
20 => '1',
'assignee_count' => '1',
21 => 'Admin',
'contact_first_name' => 'Admin',
22 => 'Person',
'contact_last_name' => 'Person',
23 => '0',
'file_count' => '0',
24 => '0',
'task_log_problem' => '0',
'task_assigned_users' =>
array (
0 =>
array (
0 => '1',
'user_id' => '1',
1 => 'admin',
'user_username' => 'admin',
2 => 'admin@localhost',
'contact_email' => 'admin@localhost',
3 => '100',
'perc_assignment' => '100',
4 => '100',
'assign_extent' => '100',
5 => 'Admin',
'contact_first_name' => 'Admin',
6 => 'Person',
'contact_last_name' => 'Person',
),
),
),0,true,false,true)
5 /var/www/dp/style/default/overrides.php:92 require('/var/www/dp/modules/tasks/tasks.php')
6 /var/www/dp/modules/projects/view.php:486 show()
7 /var/www/dp/index.php:299 require('/var/www/dp/modules/projects/view.php')
<\pre>

Fatal error: Call to a member function ErrorMsg() on a non-object in /var/www/dp/classes/query.class.php on line 776


At this point I basicly have to delete the entire project because this msg will display from then on when I try to look at task for the project.

Any help is appreciated. Thanks

Sarvjit

renowong
04-10-08, 04:51 AM
Hello there,
no need to delete the project.

open up "tasks.class.php" in the \modules\tasks folder and edit line 1305

change "$q->addQuery('COUNT(ut.*) AS user_task_count');" ---> "$q->addQuery('COUNT(*) AS user_task_count');"

That should fix your problem

Cheers!

Reno

spabla
07-10-08, 09:26 AM
Thank you.

Sarvjit

timematcher
08-10-08, 01:57 PM
Hello there,
no need to delete the project.

open up "tasks.class.php" in the \modules\tasks folder and edit line 1305

change "$q->addQuery('COUNT(ut.*) AS user_task_count');" ---> "$q->addQuery('COUNT(*) AS user_task_count');"

That should fix your problem

Cheers!

Reno
Edit:
The solution works great and now you can set the task to "priviliged"

Hi all
I had the same problem and i am going to try that out and give feedback on that..


Thanks

oliverbuxton
17-04-09, 05:15 PM
Hello there,

I am also experiencing this problem at the moment. I note from the date that this issue was raised it was some time ago.

Before I go editing the file as per the recommendation, I wanted to check that this is still necessary? I question why it has not been resolved since the post date?

Can someone please advise if this is still the fix and what the implications are by making the change.

Thanks in advance,

Oliver

ajdonnison
17-04-09, 08:08 PM
This has been fixed in the nightly snapshot.

oliverbuxton
18-04-09, 12:49 AM
Sorry - I'm new to using this. What does that mean?

Karen
18-04-09, 10:07 AM
The nightly snapshot is explained here:

http://docs.dotproject.net/index.php?title=Nightly_Snapshot

schmicky
31-07-09, 05:30 PM
hi, i love dotproject, great work, i really apreciate it

what i would like to do is modify the privileged permission from
"users company matches project company" to "users company matches owners company" but did't succed... any tips?

thank you

schmicky
05-08-09, 07:58 AM
the protected permission had no break or return

a friend of mine repaired it but changed the "and" to "or" ... it is now working

case 1:
//protected

$retval = false;
// "the user owns the task" case
if ($this->task_owner == $user_id) {
$retval = true;
break;
}

// "the user and task owner are in the same company" case

$q->addTable('users', 'u');
$q->innerJoin('contacts', 'c', 'c.contact_id=u.user_contact');
$q->addQuery('c.contact_company');
$q->addWhere("u.user_id IN ($user_id, {$this->task_owner})");
$sql = $q->prepare();
$q->clear();
$user_owner_companies = db_loadColumn($sql);
$company_match = false;
foreach ($user_owner_companies as $current_company) {
$company_match = $company_match || ($last_company && $last_company == $current_company);
$last_company = $current_company;
}
if ($company_match) {
$retval = true;
break;
}

// "the user is assigned to the task" case
// we need to reset the $q var
$q = new DBQuery;
$q->addTable('user_tasks', 'ut');
$q->addQuery('COUNT(task_id)');
$q->addWhere('ut.user_id=' . $user_id . ' AND ut.task_id=' . $this->task_id);
$sql = $q->prepare();
$q->clear();
$count = db_loadResult($sql);
if ($count > 0) {
$retval = true;
}
break;

Roger Huston
30-01-10, 06:22 AM
Hello,

We have recently updated to 2.1.3 and we are still having problems. If I set one task to Privledge I get the following error:

ERROR: /home/consecom/public_html/project/classes/query.class.php(623): query failed(SELECT COUNT(ut.*) AS user_task_count FROM (`user_tasks` as ut) WHERE ut.user_id = 2 AND ut.task_id = 672) - error was: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS user_task_count FROM (`user_tasks` as ut) WHERE ut.user_id = 2 AND ut.task' at line 1
Backtrace:
0 /home/consecom/public_html/project/classes/query.class.php:623 dprint('/home/consecom/public_html/project/classes/query.class.php',623,0,'query failed(SELECT COUNT(ut.*) AS user_task_count FROM (`user_tasks` as ut) WHERE ut.user_id = 2 AND ut.task_id = 672) - error was: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'*) AS user_task_count FROM (`user_tasks` as ut) WHERE ut.user_id = 2 AND ut.task\' at line 1')
1 /home/consecom/public_html/project/classes/query.class.php:775 exec(1)
2 /home/consecom/public_html/project/modules/tasks/tasks.class.php:1313 loadResult()
3 /home/consecom/public_html/project/modules/tasks/view.php:25 canAccess('2')
4 /home/consecom/public_html/project/index.php:299 require('/home/consecom/public_html/project/modules/tasks/view.php')
<\pre>



I was hoping that this would have been fixed in 2.1.3. To a degree it is as only the User that has the privileged permissions see the error and not everyone.

Help would be appreciated.

- Roger

Roger Huston
30-01-10, 10:07 AM
Hello,

Ok, I have been working on this a little bit. There seems to be very few people that use the forums so I guess dotProject is near dead. I hope not, but oh well.

I tried running my query above directly in phpmyadmin and I kept getting the same error.

I found this in this thread so I thought this was the place to start.
change "$q->addQuery('COUNT(ut.*) AS user_task_count');" ---> "$q->addQuery('COUNT(*) AS user_task_count');"

I also looke at Case 2 //participant above and noticed there:

$q->addQuery('COUNT(*)');

so what I did was remove teh AS user_task_count from line 1229 and now I don't get the error. I will have some testing to do for functionality, but I was hoping a MySQL developer could comment on my findings.

Our goal is to have outside users have access to their tasks and no others.

- Roger

Karen
30-01-10, 12:29 PM
2.1.3 is having some problems with later versions of PHP5 - there is work going into the new release to resolve that at present.

If you lodge the bug at http://bugs.dotproject.net then the developers are more likely to see it.