Ejemplo n.º 1
0
 /**
  * Update the meta data of the user.
  * @param  User  $user       - the user who wants to update meta data
  * @param  String $metaKey   - the key of the meta
  * @param  String $metaValue - the value of the meta
  */
 private function updateUserMeta($user, $metaKey, $metaValue)
 {
     $userMeta = UserMeta::findFirst(array('conditions' => 'uid = ?1 AND meta_key = ?2', 'bind' => array(1 => $user->getUid(), 2 => $metaKey)));
     if ($userMeta == NULL) {
         if (empty($metaValue)) {
             return;
         }
         $userMeta = new UserMeta();
         $userMeta->setUser($user);
         $userMeta->setMetaKey($metaKey);
         $userMeta->setMetaValue($metaValue);
         $userMeta->create();
     } else {
         $userMeta->setMetaValue($metaValue);
         $userMeta->update();
     }
 }