• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Wiki documentation, examples of codes would be welcome

gilles.cloutier

New Member
Wiki documentation, examples of codes would be welcome!

I loose hours trying out simple code lines in plugins
The last time,
i wrote a line in List_canedit with standard placeholders
...trying 6 differents ways for the plugin to get his true or false
...using {tablename___element} then tablename.element
...using if (... == ...){return true;}else{return false;}
...using ... == ...
and few mores ways but...

I do not intend to come here each time i try something,
i would prefer to check the wiki with a simple example
where there would be some explanation on what is written
and displayed in the plugin: ...standard placeholders!!?
standard refering to fabrik, you mean with { and ___
or standard refering to SQL tablename.element
and the expected return true or false...!!?
evaluated on single comparaison of two elements or
elaborated into a test...

Like anyone here, i dont have time, i must work
and i come to think that i made a poor choice believing
in fabrik if i cant get results...
So i came to this ascertainment:
wiki documentation, examples of codes would be welcome.

Like most of us, i dont have much time but i feel like i have
no choice but to help the community in return and i will help
in the wiki documentation with examples about the plugins
that i used. Meanwhile, if there are some good news about
wiki documentation, i would welcome it!
 
You can use Fabrik's "out of the box" features without knowing about php, JS, mySQL.
If you want to extend the possibilities by using php, JS etc hooks you must know how to code.

There are several examples in general e.g.
http://fabrikar.com/forums/index.php?wiki/index/#developers
http://fabrikar.com/forums/index.php?wiki/common-php-tasks/
http://fabrikar.com/forums/index.php?wiki/placeholders/

and directly in the plugin WIKIs, e.g.
http://fabrikar.com/forums/index.php?wiki/can-edit-row-list-plugin/

Feels free to add more.
 
Thank you troester,
i realized that this information exists somewhere, i just didnt search enough...
well... almost true
I've been able to finish my code line this morning, thanks to you so...

This is a contribution i would like to do to help some of us dealing with List_can_edit_row or can_delete_row plugins documentation.

This situation is the same if you want to prevent a group to edit, delete, see or download a document reserved for that group.

Situational

Public and private organizations around the world compose workgroups to evaluate scenarios about IdCards, passport, driver's license, resident's card, eID and other eDocuments.
They evaluate the security awareness, the cost effectiveness and the convenience on 8 sections:
Application; Entitlement, Document design; Manufacturing; Personalization ; Issuance ; Information technology security and Facility security.

Each workgroup has an Access level preventing another workgroup to see their work.
Their work consist in answering 8 questionnaires precedently called sections, each section gets scores on awareness, effectiveness and convenience.

There are 3 testing workgroups with these access levels:

Registreted List eSAM
Workgroup-1 2 12 13
Workgroup-2 2 12 14
Workgroup-3 2 -- --

List
On the frontend, we enter in the scenarios from the List of scenarios with access level 12
which means that only workgroups -1 and -2 may see that list.

eSAM
Workgroup -1 has the usergroup_id 13, int(3) called esam_access.
Workgroup -1 creates a scenario, that scenario gets esam_access 13, also int(3).
Workgroup -2 has the esam_access 14; since the scenario has esam_access 13,
Workgroup -2 can see the list but can not edit the scenario with esam_access 13.

Using the List_can_edit_row plugin should do the thing.
I login with a user of workgroup -1, i can see the list of scenarios and i will see if i can edit the scenario -1.
Then i will login with a user of workgroup -2, i will be able the see the list but i wont see the edit button of scenario -1.

Since i login with user of workgroup -1, i have 2 cursors; the cursor of #___users and the cursor of fb_users.
The table #___users is from Joomla and the table fb_users is having the added attibutes of the users where the prefix fb_ means fabrik.
The cursor of #____ is not a problem, but the cursor of fb_users is a problem since i need these attibutes, i need esam_access.

If i can get the esam_access of the table fb_users, i will be able to compare with the esam_access of the scenario.
From scenario, '{fb_scenarios___esam_access}' should have that value on the row cursor.
From the users, '{fb_users___esam_access}' should have that value on the row of the user, i have to position the cursor.

I can position the cursor using '$my->id' from the PHPeval of Fabrik:

line
1 //$myId = (int) 798;//this functions; 793 has the right esam_access but 798 has not
2 //$myId= (int) '{#___users_id}';//doesnt work
3 //$myId = (int) '{$this->users___id->id}';// i didnt try this one
4 $myId = (int) '{$my->id}';
5
6 $db = JFactory::getDbo(); $query = $db->getQuery(true);
7
8 $query = "SELECT * from fb_users WHERE user_id = '".$myId."'";
9
10 $db->setQuery($query); $userRow = $db->loadObject();
11
12 $usersAccess = (int) $userRow->esam_access;
13 $scenariosAccess = (int) '{fb_scenarios___esam_access}';
14
15 return $usersAccess === $scenariosAccess ;

Now, everything runs as it should be. Let's review some lines.

Line 1
This is a way to start your test; you put the value you are expecting to find in line 4 to test the result from the cursor position on the table fb_users.
Line 4
Since it is a bit tricky to cleancode the query on line 8, i prefered to use variable;
Line 12 and 13
I prefered to cleancode line 15 using variables
Line 13
Using Fabrik PHPeval placeholders between '' and {} and use (int) to be sure there are both integer and evaluate the expression on the right,
i am never sure if the language i use evaluates only on the right side...
Line 15
There are many ways to write this, using variables is the easiest way i think

thanks fabrik community
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top