Exemplo n.º 1
0
 /**
  * Does the party with the specified user name exist?
  */
 public static function does_party_exist($user_name)
 {
     $party_data = EntityAPI::get_by_field('party', 'user_name', $user_name);
     if (isset($party_data['id'])) {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 public static function save_image($entity_data, $image_entity_data, $file_obj)
 {
     $image_entity_data['edit_mode'] = true;
     $image_entity_data['name'] = $file_obj['file_name'];
     $image_entity_data['file_url'] = $file_obj['file_url'];
     $image_entity_data['file_size'] = $file_obj['file_size'];
     $image_entity_data['description'] = $file_obj['file_name'];
     EntityAPI::do_create_entity($image_entity_data);
 }
Exemplo n.º 3
0
 /**
  *
  */
 public static function do_edit_entity($entity_data)
 {
     // First check if the user exists
     $display_name = $entity_data['display_name'];
     $entity_data = EntityAPI::do_create_entity($entity_data);
     if (!isset($entity_data['id'])) {
         return EntityAPIUtils::init_error($entity_data, 'Could not update party');
     }
     $entity_data['display_name'] = $display_name;
     PartyProfileAPI::do_edit_party_profile($entity_data);
     BillingAccountAPI::do_edit_billing_account($entity_data);
     return $entity_data;
 }
Exemplo n.º 4
0
 /**
  *
  */
 public static function do_edit_person($entity_data, $party_data)
 {
     $entity_data['edit_mode'] = 0;
     LogUtils::shadow_log($entity_data);
     if (!isset($entity_data['name'])) {
         $entity_data['name'] = $party_data['name'];
     }
     if (!isset($entity_data['description'])) {
         $entity_data['description'] = $party_data['description'];
     }
     $entity_data = EntityAPI::do_create_entity($entity_data);
     return $entity_data;
 }
Exemplo n.º 5
0
 public static function do_reset_content_user_password($user_name)
 {
     // 1. Verify that the user name exists in the system
     $user_party_data = EntityAPI::get_by_field('party', 'user_name', $user_name);
     if (!isset($user_party_data['id'])) {
         return array('has_errors' => true, 'message' => "Sorry the username you provided is not registered");
     }
     // 2. Load the person associated with the party
     $user_person_data = EntityAPI::get_by_field('person', 'person_party', $user_party_data['id']);
     if (!isset($user_person_data['id'])) {
         return array('has_errors' => true, 'message' => "Sorry could not load the data for specified individual");
     }
     // Build the content user data
     $content_user_data = array('user_pass' => SecurityAPI::generate_password(), 'last_name' => $user_person_data['last_name'], 'first_name' => $user_person_data['first_name'], 'user_login' => $user_party_data['user_name']);
     MailAPI::do_send_user_password_email($content_user_data, array());
     return array('has_errors' => false, 'content_user' => $content_user_data);
 }
 /**
  * 
  */
 public static function edit_individual($content_user_data, $party_data)
 {
     $entity_data = EntityAPI::get_by_field('person', 'person_party', $party_data['id']);
     if (!isset($entity_data['id'])) {
         return EntityAPIUtils::init_error($content_user_data, 'Could not find the specified individual');
     }
     $entity_data['edit_mode'] = false;
     $entity_data['email'] = $content_user_data['user_login'];
     $entity_data['last_name'] = $content_user_data['last_name'];
     $entity_data['first_name'] = $content_user_data['first_name'];
     if (isset($content_user_data['description'])) {
         $entity_data['description'] = $content_user_data['description'];
     }
     if (isset($content_user_data['display_name'])) {
         $entity_data['display_name'] = $content_user_data['display_name'];
     }
     $entity_data = PartyAPI::do_edit_individual($entity_data, $party_data);
     return $entity_data;
 }
Exemplo n.º 7
0
 /**
  * Just a helper method to reduce amount of ugly typing
  */
 public static function get_by_email($user_name)
 {
     return EntityAPI::get_by_field('party', 'user_name', $user_name);
 }
 /**
  *
  */
 public static function delete_entity_ajax()
 {
     $entity_data = ArtficatAjaxRequestProcessorUtils::do_before_ajax_delete();
     $custom_processor = $entity_data['entity_name'] . 'AjaxRequestProcessor';
     if (class_exists($custom_processor) && method_exists($custom_processor, 'delete_entity_ajax')) {
         $entity_data = call_user_func($custom_processor . '::delete_entity_ajax', $entity_data);
     } else {
         $entity_data = EntityAPI::do_delete_entity($entity_data);
     }
     ArtficatAjaxRequestProcessorUtils::do_after_ajax_delete($entity_data);
 }
 /**
  *
  */
 public static function do_create_entity($entity_data)
 {
     // First check if the user exists
     if ($entity_data['edit_mode']) {
         if (UserPartyAPI::does_party_exist($entity_data['user_name'])) {
             return EntityAPIUtils::init_error($entity_data, 'Party with the specified user name already exists');
         }
     }
     $party_role = $entity_data['role'];
     $display_name = $entity_data['display_name'];
     $entity_data = EntityAPI::do_create_entity($entity_data);
     if (isset($entity_data['id'])) {
         $entity_data['display_name'] = $display_name;
         PartyProfileAPI::do_create_party_profile($entity_data);
         BillingAccountAPI::do_create_billing_account($entity_data);
         PartyRoleAPI::add_role_to_party($entity_data, $party_role);
     }
     return $entity_data;
 }