CRM icon indicating copy to clipboard operation
CRM copied to clipboard

Group Member Properties Editor issues:

Open DawoudIO opened this issue 8 years ago • 12 comments

edit a person's group properties via GroupPropsEditor.php?GroupID=13&PersonID=670

  • Date type does not show calendar picker
  • save does not save

DawoudIO avatar Oct 03 '16 14:10 DawoudIO

@crossan007 looks like when we converted the add person to group API we did not add the user to the custom group table

see

$this->post('/{groupID:[0-9]+}/adduser/{userID:[0-9]+}', function ($request, $response, $args) {
    $groupID = $args['groupID'];
    $userID = $args['userID'];
    $group = GroupQuery::create()->findOneById($groupID);
    $p2g2r = new ChurchCRM\Person2group2roleP2g2r();
    $p2g2r->setGroupId($groupID);
    $p2g2r->setPersonId($userID);
    $p2g2r->setRoleId($group->getDefaultRole());
    $p2g2r->save();
    $members = ChurchCRM\Person2group2roleP2g2rQuery::create()
            ->joinWithPerson()
            ->filterByPersonId($userID)
            ->findByGroupId($groupID);
    echo $members->toJSON();
  });

vs


function addUserToGroup($iGroupID, $iPersonID, $iRoleID)
  {
    requireUserGroupMembership("bManageGroups");
    //
    // Adds a person to a group with specified role.
    // Returns false if the operation fails. (such as person already in group)
    //
    global $cnInfoCentral;

    // Was a RoleID passed in?
    if ($iRoleID == 0) {
      // No, get the Default Role for this Group
      $sSQL = "SELECT grp_DefaultRole FROM group_grp WHERE grp_ID = " . $iGroupID;
      $rsRoleID = RunQuery($sSQL);
      $Row = mysql_fetch_row($rsRoleID);
      $iRoleID = $Row[0];
    }

    $sSQL = "INSERT INTO person2group2role_p2g2r (p2g2r_per_ID, p2g2r_grp_ID, p2g2r_rle_ID) VALUES (" . $iPersonID . ", " . $iGroupID . ", " . $iRoleID . ")";
    $result = RunQuery($sSQL, false);
    if ($result) {
      // Check if this group has special properties
      $sSQL = "SELECT grp_hasSpecialProps FROM group_grp WHERE grp_ID = " . $iGroupID;
      $rsTemp = RunQuery($sSQL);
      $rowTemp = mysql_fetch_row($rsTemp);
      $bHasProp = $rowTemp[0];

      if ($bHasProp == 'true') {
        $sSQL = "INSERT INTO groupprop_" . $iGroupID . " (per_ID) VALUES ('" . $iPersonID . "')";
        RunQuery($sSQL);
      }
    }

    return $this->getGroupMembers($iGroupID, $iPersonID);
  }


we need a way to do the following with ORM as right now we can't support group properties or on we can move that logic to the set prop section and not create the data unless it is needed which is what i think i rather do.

if ($bHasProp == 'true') {
        $sSQL = "INSERT INTO groupprop_" . $iGroupID . " (per_ID) VALUES ('" . $iPersonID . "')";
        RunQuery($sSQL);
      }

DawoudIO avatar Oct 06 '16 14:10 DawoudIO

I propose this:

  • Abandon the idea of having a separate table for every group that has specific properties
  • Create a column in the group table. the column will contain a JSON blob containing what properties are enabled / set for that group
  • Create a column in the person2group2role table that contains a JSON blob for each person's group specific properties.

We could use the MySQL JSON column type: https://dev.mysql.com/doc/refman/5.7/en/json.html

crossan007 avatar Oct 08 '16 00:10 crossan007

I like it less strange db mapping

DawoudIO avatar Oct 08 '16 01:10 DawoudIO

I won't have time to build it by this Sunday though. Probably include with 2.3.0. At end of October.

crossan007 avatar Oct 08 '16 01:10 crossan007

ok we will know that it is broken in 2.2.3 for now

DawoudIO avatar Oct 08 '16 01:10 DawoudIO

or we can have a 2.2.4 with just that

DawoudIO avatar Oct 08 '16 01:10 DawoudIO

It will be a db change. Should we increment to 2.3 anyway? Just sooner?

crossan007 avatar Oct 08 '16 01:10 crossan007

Let's do that after in done with self registration

DawoudIO avatar Oct 08 '16 02:10 DawoudIO

tracking this in https://github.com/ChurchCRM/CRM/tree/1092_group_specific_properties

Probably won't be done by end of month though.

crossan007 avatar Oct 29 '16 16:10 crossan007

@crossan007 is that branch is still active?

DawoudIO avatar Jan 01 '17 18:01 DawoudIO

Date picker works...

image

DawoudIO avatar Apr 27 '24 23:04 DawoudIO

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 20 '24 02:06 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 02 '24 02:08 github-actions[bot]

This issue was closed because it has been stalled for 15 days with no activity.

github-actions[bot] avatar Sep 07 '24 02:09 github-actions[bot]