예제 #1
0
 public static function do_signin_content_user($user_name, $password)
 {
     $login_data = array();
     $login_data['user_login'] = $user_name;
     $login_data['user_password'] = $password;
     // 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 EntityAPIUtils::init_error($login_data, 'Invalid username or password. Please try again');
     }
     // 2. Ensure the account is active
     $profile_data = EntityAPI::get_by_field('partyprofile', 'profile_party', $user_party_data['id']);
     if (!isset($profile_data['id'])) {
         return EntityAPIUtils::init_error($user_party_data, 'Profile not found');
     }
     if ($profile_data['profile_status'] != 'A') {
         return EntityAPIUtils::init_error($user_party_data, 'You account has been deactivated please contact support on ' . get_option('cp_notify_accounts'));
     }
     $user_verify = wp_signon($login_data, true);
     if (is_wp_error($user_verify)) {
         return EntityAPIUtils::init_error($login_data, 'Invalid username or password. Please try again');
     }
     wp_set_current_user($user_verify->ID);
     wp_set_auth_cookie($user_verify->ID);
     // Build the return
     $content_user = array('user_login' => $user_name, 'user_password' => $password);
     // Process redirect
     if (isset($_POST['redirect_to'])) {
         $content_user['redirect_url'] = $_POST['redirect_to'];
     }
     return array('has_errors' => false, 'content_user' => $content_user);
 }
예제 #2
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;
 }
예제 #3
0
 /**
  * 
  */
 public static function do_files_upload($entity_data, $file_upload_param)
 {
     $count = 0;
     $entity_data['files_uploaded'] = array();
     $current_user = wp_get_current_user();
     /*$validation_errors = ContentFileUploadValidatorAPI::validate_file_upload($file_upload_param);
             if(!empty($validation_errors)) {
                 $entity_data['has_errors'] = true;
                 foreach ($validation_errors['file_upload_error_msg'] as $key => $value) {
                   $entity_data['message'] = $value;
                   LogUtils::shadow_log($entity_data['message']);
                 }
                 return $entity_data;
             }
     */
     if (!empty($_FILES)) {
         foreach ($_FILES[$file_upload_param]['name'] as $filename) {
             if ($_FILES[$file_upload_param]['tmp_name'][$count] != '') {
                 // Use the WordPress API to upload the file
                 $upload = wp_upload_bits($_FILES[$file_upload_param]['name'][$count], null, file_get_contents($_FILES[$file_upload_param]['tmp_name'][$count]));
                 if (isset($upload['error']) && $upload['error'] != 0) {
                     wp_die('There was an error uploading your file. The error is: ' . $upload['error']);
                 } else {
                     $file_size = $_FILES[$file_upload_param]["size"][$count];
                     $file_size = $file_size / 1024;
                     $file_size = number_format((double) $file_size, 2, '.', '');
                     $date_obj = new DateTime();
                     $file_obj = array('file_name' => $_FILES[$file_upload_param]['name'][$count], 'file_code' => $entity_data['entity_code'], 'file_url' => $upload['url'], 'file_size' => $file_size, 'file_owner' => $entity_data['id'], 'file_created_date' => $date_obj->format('M j, Y, H:i'), 'file_type' => 'FILE', 'file_mime_type' => '', 'file_description' => '');
                     // Post information
                     $post_information = array('post_title' => $file_obj['file_name'], 'post_content' => $file_obj['file_description'], 'post_type' => 'content_file', 'post_status' => 'publish');
                     // Insert the order into the database
                     $post_id = wp_insert_post($post_information);
                     if ($entity_data['entity_artifact_name'] == 'party') {
                         $image_entity_data = EntityAPIUtils::init_entity_data('partyimage');
                         $image_entity_data['file_party'] = $entity_data['id'];
                         self::save_image($entity_data, $image_entity_data, $file_obj);
                     }
                     if ($entity_data['entity_artifact_name'] == 'contentorder') {
                         $image_entity_data = EntityAPIUtils::init_entity_data('contentorderfile');
                         $image_entity_data['file_content_order'] = $entity_data['id'];
                         self::save_image($entity_data, $image_entity_data, $file_obj);
                     }
                     array_push($entity_data['files_uploaded'], $file_obj);
                 }
                 // end
             }
             $count++;
         }
     }
     return $entity_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;
 }
 /**
  *
  */
 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;
 }
 /**
  *
  */
 public static function find_child_entities_ajax()
 {
     if (!isset($_POST['artifact']) || !isset($_POST['parent_id']) || !isset($_POST['parent_field_name'])) {
         return array();
     }
     $parent_id = EntityRequestUtils::get_query_string_field('parent_id');
     $artifact_name = EntityRequestUtils::get_query_string_field('artifact');
     $parent_field_name = EntityRequestUtils::get_query_string_field('parent_field_name');
     $search_results = EntityAPI::find_by_criteria($artifact_name, array($parent_field_name => $parent_id));
     ArtficatAjaxRequestProcessorUtils::do_after_ajax_find(EntityAPIUtils::init_entity_data($artifact_name), $search_results);
 }
 /**
  *
  */
 public static function do_before_ajax_delete()
 {
     // Ensure we have a valid form
     if (!isset($_POST['submitted']) && !isset($_POST['post_nonce_field']) && !wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {
         // Nounce field did not validate
         wp_send_json_error(array('message' => "Invalid form operation!"));
     }
     // Ensure we have a valid ID
     if (!isset($_POST['id'])) {
         wp_send_json_error(array('message' => "Entity identifier missing"));
     }
     $artifact_name = EntityRequestUtils::get_artifact_name();
     $entity_data = EntityAPIUtils::init_entity_data($artifact_name);
     return $entity_data;
 }