Feature (approved)

No item link to person possible / #2208

Summary

v0.08
approved
Sep 27, 2006
60 min ... 2 hours
100%
Sep 27, 2006 / burger
Yesterday / phsouzacruz
 

Attached files

No files uploaded
What's the reason why I cannot set a link to a person?

We tried to set a link to a person (with '[ [item: 887 ] ]') in a comment, but we got an error warning.
Therefore I checked the code and saw that in the function (see following) a project id is always needed. But 'normal' persons are never linked to a project.

from db/db_item.inc.php

static function getVisibleById($id)
    {
        if($i= DbProjectItem::getById($id)) {
            if($i->type == ITEM_PROJECT) {
                return $i;
            }
            else {
                if($p= Project::getById($i->project)) {
                    if($p->validateViewItem($i)) {
                        return $i;
                    }
                }
                else {
                    trigger_error("item #$id (type= $i->type) has no project?",E_USER_WARNING);
                }
            }

        }
        return NULL;
    }

6 Comments

pixtur

Sep 27, 2006
Very good point!
Obviously the getVisibleById()-function has to be overwritten for Persons. But I am not sure if php can handle this. We just have to try.

Alternatively you can also link to a person with the nickname like [ [burger] ] -> burger

Also we could use [ [person:887] ]. But I am not sure if this is implemented either.



binder

Sep 27, 2006
Reply to Very good point!
[ [person:ID] ] doesn't work either, but [ [NICKNAME] ] does! ;)
nevertheless, [ [item:ID] ] should be worked over! ;)

pixtur

Oct 13, 2006
this is really tricky!
By fixing this I found a very hard bug that is much more complicated and important! For some reason, new persons did have an incorrect item type of "0". This was caused by a bug in Person::__construct(). It was luck, that no other parts were affected by this...

Anyways. All streber installations should be updated like:

UPDATE `item` SET `type` = 3  WHERE `type` = '0' 

The best would be restrict this change to rows that also have a matching id in the persons-list. (like WHERE item.type=0 AND item.id = person.id).

Does any of you SQL-Cracks know, how to do this?

pixtur

Oct 13, 2006

binder

Nov 7, 2006
sorry
just came across this with link to person only if person assigned to project.
What do you mean with restrict this change to rows, that have a matching id in person list? just for that streber installation update you mentioned or in general?

pixtur

Dec 11, 2006
 

Comment / Update