• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Hierarchie uživatelů v modulu FrontEndUsers
PostPosted: Sun Dec 29, 2013 12:40 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 186
Location: Plzen, CZ
Zdravím,
potřeboval bych vytvořit UDT pro hierarchický výpis uživatelů FEU. Ve vlastnostech uživatelů mám (kromě jiných vlastností) toto:
- jmeno
- prijmeni
- parent_id
Vlastnost "parent_id" obsahuje ID nadřízeného uživatele pod kterého uživatel patří.
Potřeboval bych udělat UDT, který by vypisoval uživatele tak, jak jsou si navzájem podřízení/nadřízení (a seřadit výpis abecedně podle příjmení). Výsledek by měl vypadat asi takhle:

Ředitel
- Manažer 1
- - Pracovník 1
- - Pracovník 2
- - Pracovník 3
- Manažer 2
- - Pracovník 4
- - Pracovník 5

Nějaký nápad jak takový UDT napsat?

Předem díky


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Hierarchie uživatelů v modulu FrontEndUsers
PostPosted: Fri Jan 03, 2014 5:17 am 
Offline
Dev Team Member
Dev Team Member

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 731
Location: OH, USA
Can you assign the users to FEU groups?

For example, - Worker 1, - Worker 2, and - Worker 3 belong with Manager 1 and create a group called "manager1" for them.

Then you can use Calguy's User Directory module to create a list from each of the manager groups.

_________________
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Hierarchie uživatelů v modulu FrontEndUsers
PostPosted: Fri Jan 03, 2014 6:47 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 186
Location: Plzen, CZ
It was my first idea but the hierarchy depth can be more deeper finaly than i use in example. I need something as hierachy tree for CMS pages or products hierarchy. There is used parent_id paramater too.
Additionaly, subject to some conditions can workers to be managers too and then they will have they own tree of workers or managers can advance even furters in hierarchy. On each of this changeswill only changed parent_id value in DB and tree will automatically updated based on this.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Hierarchie uživatelů v modulu FrontEndUsers
PostPosted: Fri Jan 03, 2014 6:18 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 731
Location: OH, USA
Here is a very basic idea to get you started. Not tested.
Does not contain any HTML markup, just a comma separated list. You will need to work out the layout and markup...

First, it looks up a FEU group by the group ID to loop through all of the users (ID) belonging to that group. This is needed to get all FEuser IDs.
Then, it loops through all of the User Properties and sets an array for them.
Finally, you can list the users that all have the same parent_id.

The $results will list every user's parent_id, name, surname.
The $list will list parent_id, name, surname for all users belonging to the parent_id set in the tag.

For example, if you have 10 different parent_id values, then you will need to use the UDT 10 times on the page:
\$1:
//assuming you have a feu group with ID of 1
{feu_hierarchy feu_group='1' parent_id='1'}
{feu_hierarchy feu_group='1' parent_id='2'}
...
{feu_hierarchy feu_group='1' parent_id='10'}


Create a user defined tag called "feu_hierarchy"
\$1:
// usage: {feu_hierarchy feu_group='1' parent_id=''}

// set params
$gid = $params['feu_group']; // required use Group ID number
$pid = $params['parent_id'];  // optional

if (!isset($gid)) exit; // no group to look up so exit

// get CMSMMS and FEU stuff
$gCms = cmsms();
$feusers = cms_utils::get_module('FrontEndUsers');
$feugroup = $feusers->GetUsersInGroup($gid); // gets all FEUsers in Group

// get all user properties into array
foreach ($feugroup as $feuids) {
   $feuprops = $feusers->GetUserProperties($feuids['id']);

   $feu_props=array(); // make an array
   foreach ($feuprops as $key=>$value) {
      $feu_props[$value['title']]=$value['data'];
   }

   // get parent_id, jmeno, & prijmeni -- add other user properties here to look up
   if( isset($feu_props['parent_id']) && isset($feu_props['jmeno']) && isset($feu_props['prijmeni'])) {
   
      // set $results
      $results = $feu_props['parent_id'] . "," . $feu_props['jmeno'] . "," . $feu_props['prijmeni'] . "\n";
      
      // test for wanted parent_id
      if ( isset($pid) && $feu_props['parent_id'] == $pid ) {
      $list = $feu_props['parent_id'] . "," . $feu_props['jmeno'] . "," . $feu_props['prijmeni'] . "\n";
      }

   }
   
// test results
print_r($results);

// test list using specified parent_id
print_r($list);

}


I did something very similar to get a list of users having a specified user property. So, it should work but it may need some help.

_________________
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Hierarchie uživatelů v modulu FrontEndUsers
PostPosted: Thu Jan 16, 2014 3:43 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 186
Location: Plzen, CZ
Look like this can working :) Will try your code over weekend and i hope it will works.

Thanks


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Hosting Nation - Managed CMSMS Hosting