Daniel, for Mahara 16.10 we made a bunch of changes to the group
updates. Now all groups will have short names and can be updated via a
CSV file. If your problem still persists, please let us know.

** Changed in: mahara
       Status: New => Incomplete

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask 
on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1355761

Title:
  Group_update doesn't create groups

Status in Mahara:
  Incomplete

Bug description:
  Mahara version 1.9.1:

  According to the doc:

  /**
   * Update details of an existing group.
   *
   * @param array $new New values for the group table.
   * @param bool  $create Create the group if it doesn't exist yet
   */
  function group_update($new, $create=false)

  the $create boolean determines if Mahra should create the group if the
  id provided doesn't match any other but everytime it doesnt find one,
  it directly throws the "group_update: group not found"

  I think it's because the following code:

  if (!empty($new->id)) {
          $old = get_record_select('group', 'id = ? AND deleted = 0', 
array($new->id));
      }
      else if (!empty($new->institution) && isset($new->shortname) && 
strlen($new->shortname)) {
          $old = get_record_select(
              'group',
              'shortname = ? AND institution = ? AND deleted = 0',
              array($new->shortname, $new->institution)
          );

          if (!$old && $create) {
              return group_create((array)$new);
          }
      }

      if (!$old) {
          throw new NotFoundException("group_update: group not found");
      }

  
  should look like this: 

  if (!empty($new->id)) {
          $old = get_record_select('group', 'id = ? AND deleted = 0', 
array($new->id));
      }
      else if (!empty($new->institution) && isset($new->shortname) && 
strlen($new->shortname)) {
          $old = get_record_select(
              'group',
              'shortname = ? AND institution = ? AND deleted = 0',
              array($new->shortname, $new->institution)
          );

      }

  if (!$old && $create) {
              return group_create((array)$new);
          }
      if (!$old) {
          throw new NotFoundException("group_update: group not found");
      }

  
  with the "if (!$old && $create)" conditional OUT of the previous one. I tried 
it and it works fine now.

  Also, I don't know if this is another bug or intentional but, when an
  id is provided, and create is "true", shouldn't it create it with the
  ID PROVIDED, instead of an arbitrary one? Because right now it gives
  you an arbitrary one (since that's what group_create() does).

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1355761/+subscriptions

_______________________________________________
Mailing list: https://launchpad.net/~mahara-contributors
Post to     : mahara-contributors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to