Feed aggregator

KnackForge: How to update Drupal 8 core?

Planet Drupal -

How to update Drupal 8 core?

Let's see how to update your Drupal site between 8.x.x minor and patch versions. For example, from 8.1.2 to 8.1.3, or from 8.3.5 to 8.4.0. I hope this will help you.

  • If you are upgrading to Drupal version x.y.z

           x -> is known as the major version number

           y -> is known as the minor version number

           z -> is known as the patch version number.

Sat, 03/24/2018 - 10:31

Acquia Developer Center Blog: Acquia U, before and after - meet Ally Gonthier

Planet Drupal -

I sat down with Ally Gonthier the first time I visited Acquia's then-new downtown Boston headquarters in mid-2015. At the time, she was preparing to leave her job as Support Coordinator at Acquia to enter Acquia's Drupal/tech bootcamp, known as Acquia U. When I returned to Boston in the spring of 2016, I took the chance to talk with her again about her experiences at Acquia U and what had become of her in the meantime. Below is a transcript of our before and after conversations.

Before and after on video

More with Ally
Before Acquia U: Mid 2015

jam: Hey. We are at Acquia’s brand-spanking-new headquarters. It’s been barely any time. This is only my third day here ever and we’re in downtown Boston, and it’s kind of exciting. I am with a current and future colleague, right? Why don’t you introduce yourself and tell us something about you.

Ally Gonthier: Something?

jam: Yes, whatever you like. Maybe something non-Drupaly.

Ally Gonthier: Okay. My name is Ally. My last name is pronounced differently depending on where you are in the world. In America, it’s Gonthier [read in American accent]. In France, it’s Gonthier [read in beautiful French accent], which is way better.

jam: Way better, okay. So I’m with Ally Gonthier. What’s your job at Acquia right now?

Ally Gonthier: I am a senior customer support coordinator, which is sort of a complicated-ish but not really.

jam: Interestingly, you’re about to be a "Ubie". So you’re changing from this job and going into Acquia’s Drupal training program.

Ally Gonthier: Yes.

jam: Why are you doing that?

Ally Gonthier: So I’m in support right now and it’s a very entry level position. There’s a lot to do, a lot of tasks to be done. To get me to the next level, I need to learn a lot more about Drupal and as intensely as I can, so ...

jam: And you’re excited about Drupal and you want ... ?

Ally Gonthier: Yes.

jam: You’re all about the Drupal now?

Ally Gonthier: That’s why I’m here.

jam: Okay. So this sounds kind of silly in context, but how did you hear about the Acquia U program?

Ally Gonthier: I literally met Amy who’s running the program at a Drupal camp last September and I bumped into her. We worked together but I didn’t even know who she was and we – she introduced herself to me and I was like fly paper. I didn’t leave her alone.

jam: Wow! Okay, okay. And had you heard of Drupal before you came to Acquia?

Ally Gonthier: Yes, yes. So I have been ... a “Supportian” for a while now. I had other jobs in life but when I went into sort of a technical land I found support really fit my personality well because not only do I enjoy learning and doing technical things, but I’m also really empathetic for customers. I really want to help people, and help them understand and ... I’m not necessarily a people person but I care if that makes sense, you know?

jam: No, it does. I think support, it’s actually such a great fit for people steeped in the open source mentality because you really do help people succeed and it’s all about transparency and sharing, right? And then I’ve also been told by other people from Acquia support that the difference between working in a support role and working in some company building website ...

Ally Gonthier: Like a help desk, right?

jam: Right. Well, you get to look at a different code base every day.

Ally Gonthier: Yes, absolutely.

jam: You’re not just working on the one thing for ...

Ally Gonthier: It’s every day is different. Every customer is different. It’s a different challenge every day. It’s great for somebody who doesn’t want to do the same thing all day every day.

jam: What’s your first Drupal memory?

Ally Gonthier: My first Drupal memory? Interesting. Well, honestly, I mean I learned about Acquia, obviously, because of Drupal but I was just looking into web design maybe five/six years ago. I just was comparing all the big CMSs or whatever was available at that time and I was like, “What is the best? And what is the hardest? And, okay, Drupal it is.” Then, I just started – I literally bought a book and I went front to back.

jam: What made you stick with it then?

Ally Gonthier: Honestly, I learned about – I figured I – I saw Acquia and they had some really neat tools that we still have this time like we had Dev Desktop which just made it really easy to spin up a site and play with it. Then, we had Drupal Gardens as well which you could just customize and then export that and then throw it wherever. So I did that for a couple of friends’ websites, and then I was like, “Where are these people located?” I saw they’re hiring so I just looked at their hiring page and applied to every job I could.

jam: Are you from the Boston area?

Ally Gonthier: Yes.

jam: Oh, that helped too, right?

Ally Gonthier: Yes.

jam: Okay, cool. So, how did you feel when you were accepted into the new Acquia U class?

Ally Gonthier: I’m ecstatic. I could not be more excited.

jam: Awesome. What were your expectations going in?

Ally Gonthier: I’m a little anxious, you know? I’m not super confident myself. I don’t know. It’s just something I had to work on. I mean, I’m going to just dive in and learn as much as I can and absorb it all.

jam: High five to that. So is it okay if we check-in again over the course of the program and see how you’re doing?

Ally Gonthier: Sure, absolutely.

jam: All right. I will see you some time soon.

Ally Gonthier: Okay.

jam: And good luck on Acquia U.

Ally Gonthier: All right, thanks.

jam: Thanks for talking to me.

Ally Gonthier: All right, great.

After Acquia U: Early 2016

jam: Ally Gonthier, it is now early-ish 2016. How are you?

Ally Gonthier: I’m well.

jam: Last time we were talking was the middle of 2015, right? And you were just going into Acquia U.

Ally Gonthier: Right.

jam: To recap, you’ve been at Acquia a while.

Ally Gonthier: Yes.

jam: And until you did Acquia U, your job title was?

Ally Gonthier: I was a Customer Support Coordinator.

jam: And what was your Drupal level, Drupal experience to be in that job?

Ally Gonthier: Zero basically. I didn’t need any Drupal experience for that position.

jam: Support coordinator?

Ally Gonthier: Yes.

jam: Then, you had the chance to do the Acquia U Drupal Bootcamp, tech boot camp thing.

Ally Gonthier: Yes, yes.

jam: How was that?

Ally Gonthier: That was eye-opening. It was crazy. It was fun. It was overwhelming. Every single emotion that I could ever – I was pushed to my limit and beyond. I cried more than once. I laughed more than once.

jam: I mean, it sounds funny that you say that but I’ve talked with a bunch of people ... It was a really powerful experience for a lot of people who have gone through the program.

Ally Gonthier: Yes, yes. I did things that I would have never normally have done and it gave me the Drupal picture, which I did not have before. It empowered me with my confidence. I knew what I wanted. I was just – it was a great experience.

jam: So I want to roll it back for a second. How did you end up at Acquia in the first place?

Ally Gonthier: I had always been in tech support for quite a while, different roles, different companies. I was sort of getting interested in web design, web development, and I was like, “Well, what’s the best?” So I was drawn to Drupal and I just literally downloaded Acquia Dev Desktop. I was like, “I wonder where these guys live.” I was like, “Oh, that’s 20 minutes away.” So I applied to three different positions. I interviewed for all of them and then they hired me.

jam: Cool, okay. So what was your thought process in going into Acquia U? What were you hoping for?

Ally Gonthier: I wasn’t sure. Ultimately, I wanted to grow and I wanted to try something different. Sad to say, but I wanted to make more money in the long run so ...

jam: There is nothing sad about that and, frankly, that’s a completely legitimate goal.

jam: What are some of the skills, some of the things that you learned in the – during the course?

Ally Gonthier: We built a bunch of different Drupal sites and, like I mentioned, it gave me the – it helped me for the big picture anyway. Like now I feel like I might not be a Drupal expert but I can join in the conversation and I can understand what my peers are talking about, you know? That’s like sort of the big part of it. I might not be an expert, but I know where the experts are. Now, I can have conversations with them, and grab that feedback, and learn from it so ...

jam: Even knowing how to figure out what the right question is and how to answer the question opens the door to enormous career, well, and enormous possibilities whether those are in career or whether doing something for yourself or your community with technology, right?

Ally Gonthier: Yes, absolutely. Yes.

jam: So what’s your title now? Did you get a new job coming out of Acquia U?

Ally Gonthier: I did. I am a Support Engineer now so yes.

jam: So you do actual Drupal on the job?

Ally Gonthier: Yes, I do. Yes, exactly. That’s right. So just like you described, I take questions. I might not know the answer, but I can find the answer and I have resources to help me with that. I’ve learned so much and every day just flies by. Of course, I’ve always loved the people I work with here. So I wouldn’t want to go anywhere else really.

jam: One of the things that I’ve always really admired about the approach that our global support team takes is that we’re not about – you have a problem with your website, you tell us what it is. We’ll fix it and then we’ll tell you it’s fixed and then go away. I’ve seen a lot of people share. They say, “Hey, so this got misconfigured. There was a problem on the server. The file system is corrupt in this way and these are the things that we did.” And whether subtle or not, we’re giving people the tools to help themselves or maybe not create the same problem for the second time. I imagine that you’ve got a situation where you now know enough about Drupal. You see all of these different everyday problems that people are having and every one of those is a chance for you to learn as well, right?

Ally Gonthier: Exactly, exactly. Definitely, yes.

jam: So you become more of an expert every day, more ready for – readier for new challenges, for new possibilities?

Ally Gonthier: Yes, that describes it. It’s fun. I like it.

jam: So you’re a problem solving sort of person?

Ally Gonthier: I am. I can’t do the same thing every day type of person if that makes sense.

jam: Oh, yes. So I remember talking with someone about their job in support saying that the best thing about working in support compared to working on a client project or an in-house project was, “Actually, I don’t have to touch the same code base every day. I get a completely different work day every day.”

Ally Gonthier: Every single day is something different. Different and you might touch something and not touch it again for three months. For me personally, it helps because I get bored honestly and in that kind of atmosphere, it’s really difficult to be bored, you know? So ...

jam: That’s really cool. So do you – let me think how to ask this. Do you have new and different career ambitions now?

Ally Gonthier: No, I don’t. I think I’m in a different point now where I’m just trying to do well at what I’m doing right now. Then, I’ve always thought of that like, “What’s next? What’s next? What’s next?” Right now, I’m just focusing on now and I’ll re-evaluate that eventually but for the time being, I’m pretty happy where I am right now so ...

jam: Cool, and Acquia U was part of putting you in this space right now. You’re pretty happy to sit and learn, and do this stuff?

Ally Gonthier: Yes, 100%. Yes, definitely.

jam: Cool. Well, congratulations.

Ally Gonthier: Thank you.

jam: We should probably make a pitch for Acquia Support being a really fun place to work.

Ally Gonthier: Yes, it is a lot of fun.

jam: Ally is a lot of fun to work with. I know that. So cool. So Acquia U, worth doing?

Ally Gonthier: Yes, yes. It was challenging. It was great. It was a good experience. It got me to where I wanted to be, so very happy for that.

jam: Excellent. Hey, so thanks for taking the time to come back and talk with me again.

Ally Gonthier: No problem.

jam: And you people watching this out on the internet have seen before Ally and this is after Ally.

Ally Gonthier: I’m sure I looked the same I hope.

jam: Well, you look enriched with Drupal knowledge now.

Ally Gonthier: Yes, I have the tattoo. No, I’m just kidding.

jam: Oh, you didn’t? Yes, you have to get that once you’ve taken the course.

Ally Gonthier: I know the secret handshake. No, I’m just kidding.

jam: It’s true. It’s real. Thanks, Ally.

Ally Gonthier: Thanks, jam.

Skill Level: BeginnerIntermediateAdvanced

Chapter Three: How to Register an Event Subscriber in Drupal 8

Planet Drupal -

Events in Drupal 8 allow for different components of the system to interact and communicate with each other. One system component dispatches the event at an appropriate time; many events are dispatched by Drupal core and the Symfony framework in every request. Other system components can register as event subscribers; when an event is dispatched, a method is called on each registered subscriber, allowing each one to react.

Most of the hooks from previous versions of Drupal were removed in Drupal 8 in favor of Events. Example: hook_boot() which now can be done by registering an event subscriber.

I will use the following structure for the example module:

Acquia Developer Center Blog: Four Ways That Acquia Cloud Helps You Develop Drupal Sites FAST: #1. Simple Code, Workflow, and Local Development

Planet Drupal -

When you spin up sites for a living, velocity is important. The developers at Acquia understand this, which is why we’re always looking for ways to make website development simpler and easier. Because that equals faster.

Many of our customers are already using these tools and practices. But we’d like to spread the word further.

We know you’re facing really challenging situations. We’ve got tools that will help you get past them, without taking up an entire afternoon. We can speed you up, and speed up your team.

Tags: acquia drupal planet

Evolving Web: Drush Commands for Themers and Site Builders

Planet Drupal -

Most people think that using the drush command-line tool is only something hardcore developers do, but it turns out it's also super-helpful for site builders and theme developers too! In my experience, using drush will speed up from 3 to 10 times usual Drupal Admin tasks, compared with visiting the Drupal admin pages in the browser. 

read more

Jeff Geerling's Blog: Highly available Drupal on a Raspberry Pi Cluster - phptek 2016 session

Planet Drupal -

Another year, another field trip for the Pi Dramble—my 5-Raspberry-Pi cluster! I presented a session titled Highly available Drupal on a Raspberry Pi Cluster at php[tek] 2016, which just so happens to have moved to my hometown, St. Louis, MO this year!

For this presentation, I remembered to record the audio using a lav mic plugged into my iPhone, as well as iShowU to record what was on my screen. Sadly, I didn't have a secondary camera to capture the Pi Dramble itself, but you can glance at all the other 'Let's build a Pi Cluster' videos if you want to see it in action!

Here's a video recording of the presentation:

Drupal.org frontpage posts for the Drupal planet: Gábor Hojtsy: Winner of the 2016 Aaron Winborn Award

Planet Drupal -

The Aaron Winborn Award was created in 2015 after the loss of one of one of the Drupal community’s most prominent members, Aaron Winborn, to Amyotrophic Lateral Sclerosis (also referred to as Lou Gehrig's Disease in the US and Motor Neuron Disease in the UK). Aaron’s commitment to the Drupal project and community made him the epitome of our unofficial motto: "Come for the code, stay for the community". The Community Working Group with the support of the Drupal Association came together to honor Aaron's memory by establishing the Aaron Winborn Award, which annually recognizes an individual who demonstrates personal integrity, kindness, and above-and-beyond commitment to the Drupal community.

Nominations were opened in March, giving community members the opportunity to nominate people they believe deserve the award, which were then voted on by the members of the Community Working Group, along with previous winners of the award.

We are pleased to announce that the 2016 recipient of the Aaron Winborn Award is Gábor Hojtsy. During the closing session of DrupalCon New Orleans, Community Working Group members presented the award to Gábor. The award was accompanied by a free ticket to DrupalCon, which he donated to Bojhan Somers.

Gábor was described in his nomination as an "amazing community connector" who is passionate about empowering others, stepping aside and allowing others the space and support to lead, and celebrating even the small wins that people who work with him achieve. The stellar work and leadership he displayed on the D8 Multilingual Initiative, managing sprints, Drupal events and setting up localize.drupal.org are just a few of the ways that this tireless Drupal contributor has been making an enormous impact in our community for more than a decade.

We hope you will join us in congratulating Gábor, who has demonstrated personal integrity, kindness, and above-and-beyond commitment to the Drupal community in abundance.

Front page news: Planet Drupal

Gábor Hojtsy: Winner of the 2016 Aaron Winborn Award

Drupal News -

The Aaron Winborn Award was created in 2015 after the loss of one of one of the Drupal community’s most prominent members, Aaron Winborn, to Amyotrophic Lateral Sclerosis (also referred to as Lou Gehrig's Disease in the US and Motor Neuron Disease in the UK). Aaron’s commitment to the Drupal project and community made him the epitome of our unofficial motto: "Come for the code, stay for the community". The Community Working Group with the support of the Drupal Association came together to honor Aaron's memory by establishing the Aaron Winborn Award, which annually recognizes an individual who demonstrates personal integrity, kindness, and above-and-beyond commitment to the Drupal community.

Nominations were opened in March, giving community members the opportunity to nominate people they believe deserve the award, which were then voted on by the members of the Community Working Group, along with previous winners of the award.

We are pleased to announce that the 2016 recipient of the Aaron Winborn Award is Gábor Hojtsy. During the closing session of DrupalCon New Orleans, Community Working Group members presented the award to Gábor. The award was accompanied by a free ticket to DrupalCon, which he donated to Bojhan Somers.

Gábor was described in his nomination as an "amazing community connector" who is passionate about empowering others, stepping aside and allowing others the space and support to lead, and celebrating even the small wins that people who work with him achieve. The stellar work and leadership he displayed on the D8 Multilingual Initiative, managing sprints, Drupal events and setting up localize.drupal.org are just a few of the ways that this tireless Drupal contributor has been making an enormous impact in our community for more than a decade.

We hope you will join us in congratulating Gábor, who has demonstrated personal integrity, kindness, and above-and-beyond commitment to the Drupal community in abundance.

Front page news: Planet Drupal

Web Wash: Presentation: Search in Drupal 8

Planet Drupal -

At this month's Sydney Drupal meet up I did a presentation about Search in Drupal 8. In the video, I explain three ways you can create a search page, they are as follows.

1. Core Search

The core Search module which comes with Drupal has some new functionality in Drupal 8. The biggest change is the ability to create custom search pages without using any other module.

2. Views Filter

A common way to build search pages in Drupal 7 was to create a views page and use the "Search Keywords" filter in views. This can still be done in Drupal 8 and best of all Views is now part of core.

3. Search API

The Search API module is used to create powerful search pages and it's highly extensible. It is the module to learn and use for building search pages.

myDropWizard.com: Drupal 6 security update for XML sitemap!

Planet Drupal -

As you may know, Drupal 6 has reached End-of-Life (EOL) which means the Drupal Security Team is no longer doing Security Advisories or working on security patches for Drupal 6 core or contrib modules - but the Drupal 6 LTS vendors are and we're one of them!

Today, there is a Moderately Critical security release for XML sitemap to fix a Cross-Site Scripting (XSS) vulnerability.

The module doesn't sufficiently filter the URL when it is displayed in the sitemap.

This vulnerability is mitigated if the setting for "Include a stylesheet in the sitemaps for humans." on the module's administration settings page is not enabled (the default is enabled).

Download the patch for XML Sitemap 6.x-2.x (also works with 6.x-2.1, the latest release), 6.x-1.x or 6.x-1.2.

If you have a Drupal 6 site using the XML sitemap, we recommend you update immediately! We have already deployed the patch for all of our Drupal 6 Long-Term Support clients. :-)

If you'd like all your Drupal 6 modules to receive security updates and have the fixes deployed the same day they're released, please check out our D6LTS plans.

Note: if you use the myDropWizard module (totally free!), you'll be alerted to these and any future security updates, and will be able to use drush to install them (even though they won't necessarily have a release on Drupal.org).

Acquia Developer Center Blog: Introducing Bolt, a Development Tool for Generating New Drupal 8 Projects

Planet Drupal -

It's my pleasure to introduce Acquia Bolt, a development tool for generating new Drupal projects using a template derived from our Professional Services' best practices.

We began building and using Bolt internally over the past year. Our goal was to codify a set of tools and conventions that would allow us to:

Tags: acquia drupal planet

Mediacurrent: Dropcast: Episode 20 - Kind of a big deal

Planet Drupal -

This episode we hit a land mark of twenty episodes, so instead of picking on Mario the entire time, we talk about our favorite moments at Drupalcon in New Orleans. Of course this is funny since half of us didn't actually attend the 'Con. Other episode titles considered: "Bob and Mario live vicariously through Mark and Ryan"

Drupal Bits at Web-Dev: Drupal file_scan_directory option nomask

Planet Drupal -

Other than a quick sample of blocking a specific file extension using the 'nomask' option, the documenttation for Drupal's file_scan_directory() does not help much with how to bock content from certain directories.  The documentation says

The  Perform a regular expression match">preg_match() regular expression of the files to ignore.'

So it leaves you to believe that any regex should work.   So setting

$options['nomask'] = "#(/deleted/)#"

should block any directory named 'deleted'.  The problem is, it doesn't work that way.   In file_scan_directory() the regex is not run against the full path of the file, it is only run against the directory or filename recursively.  It is not evaluating  'directory1/subsection/deleted/index.html' , where the regex above would definitely come back with a hit and reject the item.  It is first evaluating, 'directory', then 'subsection', then 'deleted'...   It does not get a hit on deleted because it is missing the slashes on each side.

One possibilty would be to remove the slashes from the regex like this:

$options['nomask'] = "#(deleted)#";

But without the slashes, it would not only reject the directory 'deleted', it would reject the directory 'not-deleted'  and the file 'faq-why-my-account-was-deleted.htm' which might have undesired consequences.

The trick to get it to reject only 'deleted' as a directory and its contents is to restrict the regex to only the start and end of the string being evaluated. like this

$options['nomask'] = "#^(deleted)$#";

and if you wanted to block 'deleted' and another directory like '_vti_cnf' it would look like this:

$options['nomask'] = "#^(deleted|_vti_cnf)$#";

 

May Lab Hours and Drupal User Group

Twin Cities Drupal Group -

Start:  2016-05-25 17:00 - 21:00 America/Menominee Organizers:  wylbur jerdavis Event type:  User group meeting

March 23rd, 2016

Community Lab Hours | 5pm - 7pm

Right before the monthly TCDUG meetup, let's work together! Get signed up here - http://lb.cm/lab-signup

Twin Cities Drupal User Group | 7pm - 9pm

We are picking sessions for the upcoming Twin Cities DrupalCamp.

Community Lab Hours and TC Drupal Usergroup are hosted by Advantage Labs and take place at Intermedia Arts.

Upcoming Meeting Schedule

June - no meeting because of DrupalCamp!
July - TBD


TCDUG and Community Lab Hours meetups are hosted by Advantage Labs and take place in their space at Intermedia Arts. Special thanks to Allie and Jer, who have provided pizza and beverages for this group since the beginning! That's a LOT of beer and pizza!

Intermedia Arts
2822 Lyndale Ave S
Minneapolis, MN 55408
map & directions

This is near the corner of Lake and Lyndale. There is parking in the lot to the right of the building (north side).

~Don't forget to signup and let us know you are coming!

Mediacurrent: 6 Questions Every Project Manager Should Ask

Planet Drupal -

Your company’s business development team just announced a new Drupal project has been given the green light, and you will be the project manager. What do you need to do to help your development and strategy teams succeed in giving the client the best possible experience and product? You need to ask the right questions.

3 questions to ask regardless of the CMS in play

The project manager of any technical project, leveraging Drupal or some other CMS, should first and foremost ask:

1. Where is the Statement of Work (SOW) and how do I access it?

Liip: Drupal: Dynamic IMCE Profiles

Planet Drupal -

Today I will describe a way to handle multiple teams with their own private file folders using the IMCE module.

Let’s pretend that we have to develop a website called awesome-website.com which consists of three (or more) different teams. The team structure could look as followed:

Every team should only be allowed to edit their own pages but no page from any other team. Therefore it would also make sense to separate the team’s file folders so that the files can be stored separately to secure its privacy.
Of course, we could simply add three IMCE profiles and define their folder access rights individually there. But what about when working with 10 teams? Or 50? Or even more? Then we definitely would prefer a more flexible solution.
Thankfully, IMCE ships with the ability to define user folders by PHP execution, how awesome! But in order to achieve this, we’ll have to set up teams as taxonomy terms first and reference them from our user entities.

Setting up the “Teams” taxonomy vocabulary

First things first: Let’s create a new taxonomy vocabulary called “Teams”. For every team that we will have on our website, we have to create a new taxonomy term in this vocabulary.
Before adding any teams as taxonomy terms though, we’ll have to add a new field called “FTP Folder” to the taxonomy vocabulary.
This field will specify the name of every team’s root folder. So, naturally it shouldn’t contain any spaces or other wicked special characters and it should be URL readable.
In order not to face any unusual results later, it is recommended to configure this field as required.

Afterwards, we can add our three terms, “Team Alpha”, “Team Beta” and “Team Gamma”.
As value for their FTP Folders, we use “team-alpha”, “team-beta” and so on.

That’s it for the taxonomy part! Now let’s link this information to the team’s users.

Adding a taxonomy term reference field to the user entity

In my case, I didn’t have multiple roles for the teams. I only had one, called “Team member”. Because every team has exactly the same rights as the others, maintaining only one role suited me best.
For really special cases, I could always just create a new role with the special permissions.

So, how do we link users to their teams the easiest? Exactly, by just adding a taxonomy term reference field to the user entity!
Let’s call this field “Team” and reference our previously created taxonomy vocabulary “Teams” with it.

Now, when adding a new user, we can select it’s team belonging and IMCE will be able to grab the needed information from there.
Yes, IMCE will be able to do that but it’s not doing it yet.
Getting the teams ftp folder for the current user is still something we have to code, so let’s proceed to the next step.

Writing a custom function to provide the accessible directories for an user

Now we need to provide IMCE the information that we’ve set up before.
We’ve created users belonging to teams, which hold the FTP root folder name for the teams.
What’s left to do, is to write a function (ideally in a custom module, in my example the module is called “awesome_teams”), that combines all information and returns it to IMCE.
Following function would do that for us:

function awesome_teams_imce($user) { $user_folders = array('cms/teams/all'); $user_wrapper = entity_metadata_wrapper('user', $user); $user_teams = $user_wrapper->field_team->value(); foreach ($user_teams as $user_team) { $user_team_wrapper = entity_metadata_wrapper('taxonomy_term', $user_team); array_push($user_folders, 'cms/teams/' . $user_team_wrapper->field_ftp_folder->value()); } return $user_folders; }

The function expects an user object as argument and will return an array of strings containing all the folder names an user is allowed to access.
Our folder structure would look like this:

  • sites/default/files/cms
  • sites/default/files/cms/teams
  • sites/default/files/cms/teams/all
  • sites/default/files/cms/teams/team-alpha
  • sites/default/files/cms/teams/team-beta
  • sites/default/files/cms/teams/team-gamma

Note: The folder “cms/teams/all” is a special folder and every user is allowed to access it.
It will be used to save files which are used globally over multiple or even all teams.

What our code does, is actually looping over all assigned teams for the given user (yes, an user can be in multiple teams!), and adding the teams ftp folder names to the array of accessible folders.

There is no “hook_imce” hook, the “_imce” in the function name does nothing till now. You can also name your function differently. The link from IMCE to our function is something we have to set up in an IMCE profile.
Let’s proceed to the last step then, shall we?

Creating the IMCE profile “Team member”

Now, as the last step, let’s create an IMCE profile called “Team member”. You’re free to define any settings as you like, there’s only one thing that will be special about this profile: The accessible directories path.

Instead of writing something constant as “cms/teams/team-alpha”, we’ll write “php: return awesome_teams_imce($user);” here.
So, the setting should look like this:

Now save the profile and you are done!

As soon as one team member now accesses the IMCE page (either via /imce or by the configured file/image fields), he will only see his team’s directories and the special directory “all” which is meant for exchange.

This wasn’t that difficult, was it?

I hope I was able to give you an insight on how to solve more complicated file permission issues with IMCE.
Don’t forget to give feedback, ask questions and follow our blog if you want to read more about our Drupal experiences at Liip!

Pages

Subscribe to Cruiskeen Consulting LLC aggregator