Comments

salvis’s picture

Project: Devel » Profile 2
Version: 7.x-1.2 » 7.x-1.x-dev
Component: devel_generate » Code

Profile 2 would have to implement that.

zkday’s picture

Yes,
This is need feature, I'm worked add this is patch file for this feature.

zkday’s picture

Status: Active » Needs review

Change status.

kthull’s picture

Ooh, perfect timing...subscribing.

m4olivei’s picture

Thanks for the patch. When generating profiles with images or files, it fails with a bunch of errors. Just add an image to a profile type to reproduce.

fago’s picture

Status: Needs review » Needs work

+1 for adding something like that. Here is a first review.

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+  $types = profile2_get_types(); ¶

Trailing whitespace.

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+  //get all user.

Make sure the comments match the coding style.

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+  }
+  ¶
+  $member_types = array('all' => 'All', 'select' => 'Selecte form list');
+  ¶

Whitespaces in empty lines. Also in many others.

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+  $form['profile2_member_select'] = array(
+    '#type' => 'select',
+    '#multiple' => TRUE,
+    '#title' => t('How many profile would you like to generate of each type?'),
+    '#default_value' => -1,
+    '#options' => $options,
+    '#states' => array(
+       '!visible' => array('select[name="profile2_member"]' => array('value' => 'all')),
+    ),
+    '#size' => 10,

I think selecting users by role should do it + providing a numeric limit. E.g. "create max. 50 profiles".

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+  $form['profile2_kill'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Kill all existing profile first.'),
+  );

Let's call that replace existing profiles.

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+  } else {

Coding style.

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+ * @return void

Remove that.

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+      $profile2 = new Profile( ¶

This needs to go via entity_create()

+++ b/profile2.devel.inc
@@ -0,0 +1,129 @@
+      $new_pids[] = profile2_save($profile2);      ¶

the save function does not return an id.

+++ b/profile2.module
@@ -757,3 +757,20 @@ function profile2_user_get_properties($account, array $options, $name) {
+// menu general profile2.

What should this comment tell me?

+++ b/profile2.module
@@ -757,3 +757,20 @@ function profile2_user_get_properties($account, array $options, $name) {
+    if (module_exists('devel')) {
+      $items['admin/config/development/generate/profile2'] = array(
+        'title' => 'Generate Profile2',
+        'access arguments' => array('administer profile2'),
+        'page callback' => 'drupal_get_form',
+        'page arguments' => array('profile2_generate_form'),
+        'file' => 'profile2.devel.inc',
+      );
+    }
+    return $items;

Wrong indentation.

zkday’s picture

@fago thanks for the comment.

I rewrite another code for this features and fixed coding standards!

bjalford’s picture

Added description to menu link

bjalford’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, profile2-add_devel_generate_for_profile2_content-1276820.patch, failed testing.

zkday’s picture

Status: Needs work » Needs review
StatusFileSize
new5.42 KB

Add description for menu link and fix another comment in code.

Status: Needs review » Needs work

The last submitted patch, profile2-add_devel_generate_for_profile2_content-1276820.patch, failed testing.

zkday’s picture

Sorry, i'm update the patch!

zkday’s picture

Status: Needs work » Needs review

change status.

Status: Needs review » Needs work
zkday’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
aniebel’s picture

I'd like to use this. How can one tell what caused the last patch to fail?

Ok, I successfully patched using #7 however, can you tell me where I might find these generated profiles? It appears it's generated 50 profiles but without associating with a User, I am unsure how to access them.

EDIT: I had previously created 50 users via Devel Generate and the 50 Profiles I created populated using those User IDs. Thought I would submit my findindgs.

manarth’s picture

Status: Needs work » Needs review
StatusFileSize
new4.58 KB

Patch rerolled against latest dev.

@aniebel - I've just tested profile2 with this patch...I created 20 users through devel (before patching profile2); patched profile2 then generated 20 profiles. These were all properly associated with the users. Maybe try the new patch?

funkym’s picture

I had the same issue as #18, turns out the user ids they were not getting passed properly by array_rand (which returns the array keys and not the user ids). I simply switched array_rand to array_slice and it got rid of the issue.

I also cleaned up the title and added a description to profile2_menu()

varunity’s picture

Thanks funkym, I applied the patch, cleared cache and can now generate profiles.

miche’s picture

Success using patch in comment #20. Thank you!

braindrift’s picture

There shold not be more than one porfile of a type for one user. After applying this patch, i generated profiles two times and now some users have more than one profile of the same type.

braindrift’s picture

Status: Needs review » Needs work
kingfisher64’s picture

I'm not sure what #22 is saying to be honest.

Is the patch in #20 not ready to be committed then? It works lovely for me. Not experienced any problems. Maybe I missed something.

braindrift’s picture

@kingfisher: do you mean #23? If it is so, then I would say NO, because multiple profiles are generated for users if you run it multiple times.

kingfisher64’s picture

@dendie - yes sorry, I mean #23. Ok that does need fixing, would be v handy to have this working correctly.

kingfisher64’s picture

Would anyone be kind enough to advise me on how to clear up profile2 profile content generated?

I've removed the users and content from within the admin however I get the following errors:

Warning: Invalid argument supplied for foreach() in profile2_user_delete() (line 267 of sites/all/modules/profile2/profile2.module).

Warning: array_combine(): Both parameters should have an equal number of elements in profile2_load_by_user() (line 222 of sites/all/modules/profile2/profile2.module).

I applied the patch to be able to create users, however the content for those users is still left over in the view.

**** Edit **** Fixed by adding vbo field with delete option to the view and deleting the left over content.

joshf’s picture

The attached patch prevents duplicate profile types per user from being generated. It also ensures that the user-defined limit is always respected.

joshf’s picture

Status: Needs work » Needs review
spleshka’s picture

Status: Needs review » Fixed

@joshf,

Thanks for your patch. I reviewed it, fixed coding stardarts issues, and then made a workaround with several changes for profiles generation. In generaly, I used your patch as a base for a new one. Now it is commited/pushed to 7.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.