@@ -249,6 +249,7 @@ public function getUsersByProperty($propertyName, $value)
249249 public function getUsersByPropertySet ($ propertiesArray )
250250 {
251251 $ query = Query::getInstance ()
252+ ->field ("u.* " )
252253 ->table ($ this ->getUserDefinition ()->table (), "u " );
253254
254255 $ count = 0 ;
@@ -263,7 +264,7 @@ public function getUsersByPropertySet($propertiesArray)
263264 }
264265
265266 /**
266- * @param int $userId
267+ * @param int|string $userId
267268 * @param string $propertyName
268269 * @param string $value
269270 * @return bool
@@ -289,11 +290,30 @@ public function addProperty($userId, $propertyName, $value)
289290 return true ;
290291 }
291292
293+ public function setProperty ($ userId , $ propertyName , $ value )
294+ {
295+ $ query = Query::getInstance ()
296+ ->table ($ this ->getUserPropertiesDefinition ()->table ())
297+ ->where ("{$ this ->getUserPropertiesDefinition ()->getUserid ()} = :id " , ["id " => $ userId ])
298+ ->where ("{$ this ->getUserPropertiesDefinition ()->getName ()} = :name " , ["name " => $ propertyName ]);
299+
300+ $ userProperty = $ this ->propertiesRepository ->getByQuery ($ query );
301+ if (empty ($ userProperty )) {
302+ $ userProperty = new UserPropertiesModel ($ propertyName , $ value );
303+ $ userProperty ->setUserid ($ userId );
304+ } else {
305+ $ userProperty = $ userProperty [0 ];
306+ $ userProperty ->setValue ($ value );
307+ }
308+
309+ $ this ->propertiesRepository ->save ($ userProperty );
310+ }
311+
292312 /**
293313 * Remove a specific site from user
294314 * Return True or false
295315 *
296- * @param int $userId User Id
316+ * @param int|string $userId User Id
297317 * @param string $propertyName Property name
298318 * @param string $value Property value with a site
299319 * @return bool
0 commit comments