Share user's calendar script doesn't work after Tine20 update

General development questions
Ryvius
Posts: 3
Joined: Tue Jul 04, 2017 12:52 pm

Share user's calendar script doesn't work after Tine20 update

Postby Ryvius » Fri Sep 29, 2017 3:37 pm

Hello,

After a recent update to our Tine20 installation, our script that shares user's personal calendar to be read for everyone has stopped working. Here's the script: https://paste.opensuse.org/74409d54

When running it, it gives this error:

Code: Select all

Found 1 rows with login_name = [i]user name provided[/i]
Found id de4377d92f055626da45fcee72801cd6fee063e7
Found 3 rows with account_id = de4377d92f055626da45fcee72801cd6fee063e7
Container IDs: Array
(
    [0] => 07a62c9cbed76bea156c7c2b8377a1de96f6c512
    [1] => dcc68cc9ce5e62d5a2c7313b22587728696f1e82
    [2] => f094b44ad2a9b3360db3f81e7961c016fe1894b8
)

Wrong SQL SELECT id FROM tine20_container WHERE id IN (07a62c9cbed76bea156c7c2b8377a1de96f6c512, dcc68cc9ce5e62d5a2c7313b22587728696f1e82, f094b44ad2a9b3360db3f81e7961c016fe1894b8) AND name LIKE '%personal calendar' AND model = 'Calendar_Model_Event' Error: Unknown column '07a62c9cbed76bea156c7c2b8377a1de96f6c512' in 'where clause'


I am not that proficient in PHP to see what's going on, but it looks like the format for container_id and account_id has changed to those log strings above; all old users' IDs are a simple four digit number.

I have also looked into doing it by CLI functions as per https://wiki.tine20.org/CLI_Functions#appName.setContainerGrants but that gives:

Code: Select all

tine20.php --method=Calendar.setContainerGrants containerId=07a62c9cbed76bea156c7c2b8377a1de96f6c512 accountId=de4377d92f055626da45fcee72801cd6fee063e7 accountType=user grants=readGrant

username> tine20admin

password>
No matching containers found.


I'm sorry for the messy problem, but if anyone has any ideas I'd be thankful.

hobbyist
Posts: 229
Joined: Wed Nov 19, 2014 5:30 pm

Re: Share user's calendar script doesn't work after Tine20 update

Postby hobbyist » Fri Sep 29, 2017 5:46 pm

Hi,

Wrong SQL SELECT id FROM tine20_container WHERE id IN (07a62c9cbed76bea156c7c2b8377a1de96f6c512, dcc68cc9ce5e62d5a2c7313b22587728696f1e82, f094b44ad2a9b3360db3f81e7961c016fe1894b8) AND name LIKE '%personal calendar' AND model = 'Calendar_Model_Event' Error: Unknown column '07a62c9cbed76bea156c7c2b8377a1de96f6c512' in 'where clause'


the container-ids are strings, so you have to put your container_ids in quotes, otherwise mysql tries to find a column with that alphanumeric name. You already do so in lines 107, 128 and 145.

Maybe you start in line 73 with

Code: Select all

                        $container_ids[] = "'{$row['container_id']}'";
the implode in l.85 should get no problems.

It should even work with old containers with "integer" ids too, because the id-column's type is varchar(40).

User avatar
lab@nohl
Tine 2.0 Community Contributor
Posts: 653
Joined: Tue Oct 12, 2010 7:07 pm

Re: Share user's calendar script doesn't work after Tine20 update

Postby lab@nohl » Sun Oct 01, 2017 8:29 pm

You definitly should go with CLI functions. Your script won't be stable at any time. Only API is future save.

Anyway, it seems to me that the container_id is wrong? Have you tried to use namefilter instead of containerId on CLI? Like this (untersted just a guess :shock:):

Code: Select all

tine20.php --method=Calendar.setContainerGrants namefilter="CONTAINS (personal calender)" accountId=XXXXeveryoneXXXX accountType=user grants=readGrant
Viele Grüße
Johannes

System: Apache 2.4, php-fpm 7.0, redis, cyrus IMAPd mit timsieve, postfix 2.2, MariaDB, openldap für Accounts + Auth.
--
Welche Informationen sind erforderlich, um effektiv geholfen zu bekommen? Siehe Hinweise.

hobbyist
Posts: 229
Joined: Wed Nov 19, 2014 5:30 pm

Re: Share user's calendar script doesn't work after Tine20 update

Postby hobbyist » Mon Oct 02, 2017 11:02 am

Hi,

lab@nohl wrote:You definitly should go with CLI functions. Your script won't be stable at any time. Only API is future save.
[...] Have you tried to use namefilter instead of containerId on CLI? [...]


I didn't recommend the CLI-functions, because I haven't tried them whether there is a bug for long or short id's. Second reason: I thought, he has to determine the container-id's from db. So Namefilters are a cool feature that I didn't know before and makes access more easier. When where namefilter introduced?

Ryvius
Posts: 3
Joined: Tue Jul 04, 2017 12:52 pm

Re: Share user's calendar script doesn't work after Tine20 update

Postby Ryvius » Fri Oct 06, 2017 1:22 pm

Thanks for your replies everyone.

Thankfully I had the original creator of the script come by and fix it. As hobbyist points out, the main issue was that the id's are now strings instead of integers. He also changed some other things, so it works now. It's probably not ideal but I'll stick to our script for as long as it works.


Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests