public static function isValid(&$properties_dictionary, $limit_to_keys, &$error)
 {
     //	Check each property is valid
     //
     if (!parent::isValid($properties_dictionary, $limit_to_keys, $error)) {
         return false;
     }
     if (ValidationC::should_test_property('rawEmail', $properties_dictionary, true, $limit_to_keys) && !Email::propertyIsValid('rawEmail', $properties_dictionary[USER_KEY_EMAIL], $error)) {
         //	Email was not valid
         //
         return false;
     }
     if (ValidationC::should_test_property('rawPassword', $properties_dictionary, true, $limit_to_keys) && !Password::propertyIsValid('rawPassword', $properties_dictionary[USER_KEY_PASSWORD], $error)) {
         //	Password was not valid
         //
         return false;
     }
     if (isset($properties_dictionary[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS])) {
         if (ValidationC::should_test_property(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $properties_dictionary, true, $limit_to_keys) && !User::propertyIsValid(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $properties_dictionary[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS], $error)) {
             //	Password was not valid
             //
             return false;
         }
     }
     return true;
 }
 public static function isValid(&$properties_dictionary, $limit_to_keys, &$error)
 {
     //	Check each property is valid
     //
     if (ValidationC::should_test_property('rawPassword', $properties_dictionary, true, $limit_to_keys) && !Password::propertyIsValid('rawPassword', $properties_dictionary['rawPassword'], $error)) {
         //	Password was not valid
         //
         return false;
     }
     return true;
 }
 public static function update(Inputter $inputter, JSONOutputter $outputter)
 {
     //	Update
     //
     //	1) Test all data is available and valid
     //
     $required_dictionary = array(UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION => '');
     $optional_dictionary = array(USER_KEY_EMAIL => null, USER_KEY_PASSWORD => null, 'notificationDeviceIdentifiersToRemove' => array(), 'notificationDeviceIdentifiersToAdd' => array(), USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS => array(), UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED => date('c'), CREATINGUSER_KEY_FIRST_NAME => null, CREATINGUSER_KEY_SURNAME => null, CREATINGUSER_KEY_NAME => null, CREATINGUSER_KEY_GENDER => null);
     $inputter->validate_input($required_dictionary, $optional_dictionary);
     //			Remove things that shouldn't be updated
     //
     if (isset($inputter->variables_array[UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED])) {
         unset($inputter->variables_array[UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED]);
     }
     //		Valid
     //
     $update_error = null;
     //		Email
     //
     if (isset($inputter->variables_array[USER_KEY_EMAIL])) {
         Email::propertyIsValid('rawEmail', $inputter->variables_array[USER_KEY_EMAIL], $update_error);
     }
     //		Password
     //
     if (isset($inputter->variables_array[USER_KEY_PASSWORD])) {
         Password::propertyIsValid('rawPassword', $inputter->variables_array[USER_KEY_PASSWORD], $update_error);
     }
     //		Notification device identifiers
     //
     if (isset($inputter->variables_array[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS])) {
         User::propertyIsValid(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $inputter->variables_array[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS], $update_error);
     }
     if (isset($inputter->variables_array['notificationDeviceIdentifiersToRemove'])) {
         User::propertyIsValid(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $inputter->variables_array['notificationDeviceIdentifiersToRemove'], $update_error);
     }
     if (isset($inputter->variables_array['notificationDeviceIdentifiersToAdd'])) {
         User::propertyIsValid(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $inputter->variables_array['notificationDeviceIdentifiersToAdd'], $update_error);
     }
     //		Creating user
     //
     if (isset($inputter->variables_array[CREATINGUSER_KEY_FIRST_NAME]) || isset($inputter->variables_array[CREATINGUSER_KEY_SURNAME]) || isset($inputter->variables_array[CREATINGUSER_KEY_NAME])) {
         CreatingUser::isValid(array(CREATINGUSER_KEY_FIRST_NAME => $inputter->variables_array[CREATINGUSER_KEY_FIRST_NAME], CREATINGUSER_KEY_SURNAME => $inputter->variables_array[CREATINGUSER_KEY_SURNAME], CREATINGUSER_KEY_NAME => $inputter->variables_array[CREATINGUSER_KEY_NAME], CREATINGUSER_KEY_GENDER => $inputter->variables_array[CREATINGUSER_KEY_GENDER]), true, $update_error);
     }
     if (isset($update_error)) {
         $outputter->print_error($update_error);
         return;
     }
     //	2) Get user
     //
     //		User might exist (check against ID)
     //
     //			Create query
     //
     $client = new Everyman\Neo4j\Client('events.sb04.stations.graphenedb.com', 24789);
     $client->getTransport()->setAuth('Events', '3TP9LHROhv8LIcGmbYzq');
     $query_string_get_user = '******' . 'WHERE user.' . UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION . " = '" . $inputter->variables_array[UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION] . "'" . 'RETURN user';
     $query_get_user = new Everyman\Neo4j\Cypher\Query($client, $query_string_get_user);
     $result_get_user = $query_get_user->getResultSet();
     if ($result_get_user->count() < 1) {
         //	No users exist
         //
         $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, PRIVATE_EVENTS_REST_CONTROLLER_ERROR_CODE_ENTITY_DOES_NOT_EXIST, 'A user with the identification ' . $inputter->variables_array[UNIVERSALLY_UNIQUE_IDENTIFIER_KEY_IDENTIFICATION] . " doesn\\'t exist.");
         $outputter->print_error($error);
     }
     //	3) Update the user
     //
     //		Existing properties
     //
     $account_to_update = $result_get_user[0]['user'];
     $account_to_update->setProperty(UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED, date('c'));
     if (isset($inputter->variables_array[USER_KEY_EMAIL])) {
         $account_to_update->setProperty(USER_KEY_EMAIL, $inputter->variables_array[USER_KEY_EMAIL]);
     }
     if (isset($inputter->variables_array[USER_KEY_PASSWORD])) {
         $account_to_update->setProperty(USER_KEY_PASSWORD, $inputter->variables_array[USER_KEY_PASSWORD]);
     }
     //          Identifiers
     //
     $existing = $account_to_update->getProperty(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS);
     $new = array();
     if (isset($inputter->variables_array[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS])) {
         $new = $inputter->variables_array[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS];
     }
     if (isset($existing) && is_array($existing)) {
         //	Merge
         //
         $new = array_merge($new, $existing);
     }
     $new = array_unique($new);
     //              Add
     //
     if (isset($inputter->variables_array['notificationDeviceIdentifiersToAdd']) && is_array($inputter->variables_array['notificationDeviceIdentifiersToAdd'])) {
         $new = array_merge($new, $inputter->variables_array['notificationDeviceIdentifiersToAdd']);
         $new = array_unique($new);
     }
     //              Remove
     //
     if (isset($inputter->variables_array['notificationDeviceIdentifiersToRemove']) && is_array($inputter->variables_array['notificationDeviceIdentifiersToRemove'])) {
         $new = array_diff($new, $inputter->variables_array['notificationDeviceIdentifiersToRemove']);
         $new = array_unique($new);
     }
     //              Update
     //
     if (isset($new) && is_array($new)) {
         $account_to_update->setProperty(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $new);
     }
     //          First name
     //
     if (isset($inputter->variables_array[CREATINGUSER_KEY_FIRST_NAME])) {
         $account_to_update->setProperty(CREATINGUSER_KEY_FIRST_NAME, $inputter->variables_array[CREATINGUSER_KEY_FIRST_NAME]);
     }
     if (isset($inputter->variables_array[CREATINGUSER_KEY_SURNAME])) {
         $account_to_update->setProperty(CREATINGUSER_KEY_SURNAME, $inputter->variables_array[CREATINGUSER_KEY_SURNAME]);
     }
     if (isset($inputter->variables_array[CREATINGUSER_KEY_NAME])) {
         $account_to_update->setProperty(CREATINGUSER_KEY_NAME, $inputter->variables_array[CREATINGUSER_KEY_NAME]);
     }
     if (isset($inputter->variables_array[CREATINGUSER_KEY_GENDER])) {
         $account_to_update->setProperty(CREATINGUSER_KEY_GENDER, $inputter->variables_array[CREATINGUSER_KEY_GENDER]);
     }
     //	Save
     //
     $account_to_update->save();
     //	4) Output results
     //
     $outputter->print_data(array(AttendingUser::printer_dictionary($account_to_update)));
 }