Comments

juliangb’s picture

Can you elaborate your point about stormperson_validate()?

willwh’s picture

Hi julian, my bad, switching between my few local branches, I dropped a few lines in there (not what was in 7.x-1.x-dev) - so you can safely ignore the comment about stormperson_validate()

I am re-writing SQL to d7 api, in bits - haven't had a lot of time up until now, but I will provide patches asap :)

willwh’s picture

Title: Convert SQL queries & rewrite stormperson_validate() » Convert SQL queries
Status: Active » Needs review
StatusFileSize
new2.21 KB

Updating the issue title to better reflect the issue.

Fixed up the stormperson_user_autocomplete() syntax.

willwh’s picture

Adding missing query limit, using ->range();

juliangb’s picture

Status: Needs review » Needs work
+      ->condition('name', '%' . db_like($string) . '%', 'LIKE')

Looks here like we're changing from string% to %string%

+   

One bit of trailing whitespace that's been added.

willwh’s picture

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

This patch is a little better.

I am a little stuck here though - _stormperson_user_load()

This always seem to be returning $account->uid = 0; - as the user_uid is always 0 on stormperson_insert($node)

I am not quite sure how to go about debugging this, any pointers appreciated :)

willwh’s picture

StatusFileSize
new924 bytes

Trying to post a patch that actually has correctly line endings etc.

Status: Needs review » Needs work

The last submitted patch, 1799550-stormperson_user_autocomplete-7.patch, failed testing.

willwh’s picture

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

Here's a patch for the ajax load of users by name & validation query.

Still lots of work to be done on Storm Person :)

Status: Needs review » Needs work

The last submitted patch, storm-1799550-sqlapi-d7-9.patch, failed testing.

juliangb’s picture

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

I think there was a rogue bracket in #9. This should fix.

juliangb’s picture

Status: Needs review » Needs work

A few questions on this patch:

+++ b/stormorganization/stormorganization.admin.inc
@@ -258,15 +258,19 @@ function stormorganization_list_filter_reset($form, &$form_state) {
+    $return = $query
+      ->addTag('node_access')
+      ->fields('n', array('nid', 'title'))
+      ->condition('n.type', 'stormorganization')
+      ->condition('title', '%' . db_like($string) . '%', 'LIKE')
+      ->range(0, 10);
+
+    foreach($return as $row) {
+      $matches[$row->title] = check_plain($row->title);

Need to execute() query.

+++ b/stormperson/stormperson.admin.inc
@@ -190,17 +190,20 @@ function _stormperson_organization_people_js($organization_nid=0) {
-    $s = "SELECT n.nid, n.title FROM {node} n INNER JOIN {stormperson} AS spe ON n.vid=spe.vid WHERE n.status=1 AND n.type='stormperson' AND spe.organization_nid=%d ORDER BY n.title";
-    $s = stormperson_access_sql($s);
-    $s = db_rewrite_sql($s);
-    $r = db_query($s, $organization_nid);
-
-    while ($item = db_fetch_object($r)) {
-      $nid = $item->nid;
-      $people[$nid] = $item->title;
+      $query = db_select('node', 'n')
+        ->fields('n', array('nid', 'title'))
+        ->condition('n.status', 1)
+        ->condition('n.type', 'organization')
+        ->condition('spe.organization', $organization_nid)
+        ->join('stormperson', 'spe', 'n.vid = spe.vid');
+
+  $result = $query->execute();
+    foreach($result as $row) {
+      $nid = $row->name;
+      $people[$nid] = $row->title;

Needs to be tagged for a node_access check.

+++ b/stormperson/stormperson.module
@@ -509,7 +524,8 @@ function stormperson_update($node) {
-  $ass_user = user_load(array('name' => $node->user_name));
+  $username = $node->username;

$node->username or $node->user_name ?

willwh’s picture

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

Maybe this'll do the job :)

Status: Needs review » Needs work

The last submitted patch, storm-1799550-sqlapi-d7.patch, failed testing.

esoteric1’s picture

Status: Needs work » Needs review

#13: storm-1799550-sqlapi-d7.patch queued for re-testing.

willwh’s picture

StatusFileSize
new11.08 KB

Ok, hopefully this is good :)

juliangb’s picture

Status: Needs review » Needs work

Looks like there is an old patch included in the diff!

Also - would you be able to briefly explain the parts that this fix to aid in testing?

willwh’s picture

StatusFileSize
new5.38 KB

Yup surely!

This should repair the "User" auto complete field in the "Add Storm Person" form - although - stormperson_insert() does not properly insert the user_uid correctly.

It may seem like stormperson_validate() is broken.

stormperson_validate() is not broken! If you manually set the user_uid in the db, for a Storm Person, to match the uid of a drupal user - you'll see it works correctly. i.e. You should not get this user returned in the "User" autocomplete field.

If you manually type the Drupal Users name in to the User field and submit, it will correctly throw form_set_error() as it should.

I could really use some help in getting the rest of stormperson.module sorted!

willwh’s picture

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

D'oh, let's test this puppy :)

juliangb’s picture

I tried to test this, but the Storm Person form isn't really working yet so I didn't see a form.

Do you see a form etc?

willwh’s picture

Yes, insofar I see Salutation, Name, Username, Email, Phone...

I'll take another look at this when I get home!

juliangb’s picture

I don't see those fields - so wondering if you've fixed this bit on your dev version?

willwh’s picture

Hi julian, I guess that must be fixed in this patch: http://drupal.org/node/1798036#comment-6629906

juliangb’s picture

Status: Needs review » Fixed

Once I'd a) committed your other patch and b) refreshed my storm install the fields were there! Not sure which fixed, but meant that I tested and committed your patch.

For me, it inserted the user_uid correctly, but throws an error on the user_nid. After some investigations, I found this was a bug present in 6.x-2.x also. Will create a separate issue for that.

What are you going to work on next? ;-)

willwh’s picture

Getting you in to #drupal-storm when you are around :P

Hah!

Status: Fixed » Closed (fixed)

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