Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Group membership

Activity

  • I am using following code to return entities based on certain metadata name, with an operand LIKE. I need to know is this the best way to do that?  Is this safe so that input is properly sanitized and validated to prevent SQL...
    • Which your Elgg version?

      Since Elgg 3 we use Doctrine DBAL for SQL queries.

    • Try this:

      $name = get_input('name', '');
      $query = get_input('query', '');
      
      echo elgg_list_entities([
           'types' => 'user',
           'metadata_name_value_pairs' => [
                [
                       'name' => 'usertype',
                       'value' => 'driver',
                ],
           ],
           'joins' => [
                new \Elgg\Database\Clauses\JoinClause('metadata', 'em',             function(\Elgg\Database\QueryBuilder $qb, $joined_alias, $main_alias) {
                return $qb->compare("{$joined_alias}.entity_guid", '=', 'e.guid', ELGG_VALUE_INTEGER));
               }),
           ],
           'wheres' => [
                 function(\Elgg\Database\QueryBuilder $qb) use($name, $query) {
                    return $qb->merge([
                               $qb->compare('em.name', '=', $name, ELGG_VALUE_STRING),
                               $qb->compare('em.value', 'LIKE', '%$query%', ELGG_VALUE_STRING),
                     ], 'AND');
                  },
            ],
            'limit' => 5,
      ]);

      On your questions:

      1 - Why not? Just use a new way ;)

      2 - Absolutely if you follow Elgg's code standards.

      3 - Look at my example and the existing core and plugins' code. Ask here or welcome to Elgg chat in Telegram. We've a channel also.

  • aqeel replied on the discussion topic Problem with Elgg Group Subscriptions
    That worked steve. Thank you. Why cant we use the owner_guid as the notifying user's guid value in such situations? view reply
  • aqeel added a new discussion topic Problem with Elgg Group Subscriptions in the group Plugin Development
    I am having a strange problem with the group subscription in Elgg. Not sure whether its a bug. So thought of first posting it here. Have an Elgg install of Version 1.11.2 with only group, profile and notification plugins enabled. I am trying to...
    • For now you could set the logged in user during the script.

      $session = elgg_get_session();
      $session->setLoggedInUser($user);
      $session->remove('guid');
      
      // actions
      
      $session->invalidate();
      

      This "logs in" $user as far as Elgg is concerned, but prevents the GUID from being stored in the session.

      If a browser hits this script, and actions fail, there'll be less chance that the browser would be left in a logged in state.

      Note that anybody on the web can call your /cron triggers!

    • That worked steve. Thank you.

      Why cant we use the owner_guid as the notifying user's guid value in such situations?