public function create($data) { $data = array_map('mysql_real_escape_string', $data); if ($data['user_id']) { $this->user_id = $data['user_id']; } else { $this->user_id = get_active_user_id(); } $this->parent_id = $data['parent_id']; $this->name = $data['name']; $this->image = $data['image']; $this->groups_allowed = $data['groups_allowed']; $this->save(); }
public function show_objects($object_type) { $user = new users(); $group_id = $user->get_user_group_ids(get_active_user_id()); $condition = false; if ($object_type == 'post') { foreach ($group_id as $key => $value) { if ($user->get_group_by_id($value)->allow_posts == '1') { $condition = true; } } } elseif ($object_type == 'category') { foreach ($group_id as $key => $value) { if ($user->get_group_by_id($value)->allow_categories == '1') { $condition = true; } } } $data['objects'] = $this->get_object($object_type, '', true); $data['condition'] = $condition; $this->load->view('backend/show_' . $object_type . '_objects', $data); }
<?php if ($object->image) { ?> <div class="profile-avatar" style="width:250px !important"> <img style="width:100% !important; height:auto !important" class="file_preview" src="<?php echo $object->image; ?> " alt="No Image"> </div> <?php } ?> </div> </div> <?php $groups_name = $this->users->get_user_group_name(get_active_user_id()); $groups = array(); $use_created_categories = ''; foreach ($groups_name as $key => $value) { $group = $this->users->get_groups($value); if ($group[0]->use_created_categories) { $use_created_categories = 1; } $groups[] = $group[0]; } ?> <div class="form-group"> <label class="control-label col-md-4 col-sm-4" for="categoryselection">Category Selection:</label> <div class="col-md-8 col-sm-8"> <select class="form-control" id="select-required" name="category_id" data-parsley-required="true"> <option value="">Select Category</option>
<?php /* Template Name: Upgrade Profile */ require 'authnet/AuthnetAIM.class.php'; require 'authnet/AuthnetARB.class.php'; // let all of WP know that we are in the guide area //ao_set_in_guide(true); // this is the profile ID //$pid = pods_url_variable(2); // this is the "effective" user id, which is not neccessarily the user that is logged in, in the // case of admins, wo are able to mascarade as other users. $active_user_id = get_active_user_id(); // array to hold our profile fields $a = array(); // ******************************************************************* // INITIALIZATION, so to speak // ******************************************************************* // Basically, if we have a $pid, go ahead an get the data from the database, We might end up // replacing that data with data the user is trying to save, but this will make sure we have // all the images and related data.... a good baseline, so to speak $profile = new Pod('vendor_profiles'); //$profile->findRecords( 'id', -1, "t.id = '$pid' and t.vendor = $active_user_id"); $profile->findRecords('id', -1, "t.vendor = {$active_user_id}"); $total = $profile->getTotalRows(); if ($total > 0) { $profile->fetchRecord(); } $title = 'Business Profile Upgrade'; $profile_name = $profile->get_field('name'); $pid = $profile->get_field('id'); $result = pod_query("SELECT full_name, user_contact, user_email FROM ao_vendors WHERE id='{$active_user_id}'");
function invoke_attributes($module, $file, $user) { global $attr_module; global $attr_function; $attr_module = $module; $comments = get_comment_blocks($file); $attributes = extract_attributes($comments); $group_id = $user->get_user_group_ids(get_active_user_id()); $allow_posts = false; $allow_categories = false; foreach ($group_id as $key => $value) { if ($user->get_group_by_id($value)->allow_posts == '1') { $allow_posts = true; } if ($user->get_group_by_id($value)->allow_categories == '1') { $allow_categories = true; } } foreach ($attributes as $attribute) { if ($attribute['function'] == 'add_post' && $allow_posts || $attribute['function'] == 'add_category' && $allow_categories) { $attr_function = $attribute['function']; eval($attribute['attribute']); } else { if ($attribute['function'] != 'add_post' && $attribute['function'] != 'add_category') { $attr_function = $attribute['function']; eval($attribute['attribute']); } } } }
function set_profile_status() { // this is the "effective" user id, which is not neccessarily the user that is logged in, in the // case of admins, who are able to mascarade as other users. $active_user_id = get_active_user_id(); $profile = new Pod('vendor_profiles'); $profile->findRecords('id', -1, "t.vendor = {$active_user_id}"); $total = $profile->getTotalRows(); if ($total > 0) { $profile->fetchRecord(); $_SESSION['profile_type'] = $profile->get_field('profile_type'); } else { $_SESSION['profile_type'] = 'New'; } }
function is_admin() { foreach ($this->get_user_group_ids(get_active_user_id()) as $key => $value) { if ($this->get_group_by_id($value)->name == 'Administrators') { return true; } } return false; }
// decode json geoinfo into an object // make sure value is returned and allow manual change if ($decoded->status == "OK") { $event_data['latitude'] = $decoded->results[0]->geometry->location->lat; // copy lat into the field called lat in your pod $event_data['longitude'] = $decoded->results[0]->geometry->location->lng; // copy long into the field called long in your pod } } // all clear to save the data to the database $api = new PodAPI(); // safety cleansing pods_sanitize($event_data); if ($eid == 'new') { // since we are saving a new event, these fields need initializing this one time only $event_data['vendor'] = get_active_user_id(); $event_data['approved'] = '1'; $event_data['event_type'] = '1'; $a['approved'] = '1'; $params = array('datatype' => 'events', 'columns' => $event_data); // create the item $api->save_pod_item($params); $success = true; } else { // SCREW PODSCMS... just do a plain ole SQL update $sql = "UPDATE wp_pod_tbl_events SET "; $sql_fields = array(); foreach ($event_data as $key => $val) { $sql_fields[] .= "{$key}='{$val}'"; } $sql .= implode(', ', $sql_fields);
// decode json geoinfo into an object // make sure value is returned and allow manual change if ($decoded->status == "OK") { $profile_data['latitude'] = $decoded->results[0]->geometry->location->lat; // copy lat into the field called lat in your pod $profile_data['longitude'] = $decoded->results[0]->geometry->location->lng; // copy long into the field called long in your pod } } // all clear to save the data to the database $api = new PodAPI(); // safety cleansing pods_sanitize($profile_data); if ($pid == 'new') { // since we are saving a new profile, these fields need initializing this one time only $profile_data['vendor'] = get_active_user_id(); $profile_data['active'] = '0'; $profile_data['profile_type'] = 'Free'; $profile_data['expiration_date'] = '0000-00-00 00:00:00'; $profile_data['payment_plan'] = 'NA'; $profile_data['payment_amount'] = '0'; $params = array('datatype' => 'vendor_profiles', 'columns' => $profile_data); // create the item $api->save_pod_item($params); $success = true; } else { // SCREW PODSCMS... just do a plain ole SQL update $sql = "UPDATE wp_pod_tbl_vendor_profiles SET "; $sql_fields = array(); foreach ($profile_data as $key => $val) { $sql_fields[] .= "{$key}='{$val}'";
public function add_category($type = '', $id = -1) { $groups_name = $this->users->get_user_group_name(get_active_user_id()); $groups = array(); $user_created_posts = ''; $user_created_categories = ''; foreach ($groups_name as $key => $value) { $group = $this->users->get_groups($value); if ($group[0]->allow_posts) { $user_created_posts = 1; } if ($group[0]->allow_categories) { $user_created_categories = 1; } $groups[] = $group[0]; } if (!$this->user->is_logged_in()) { redirect("/user/main/userLogin", 'location'); } else { // if($this->builderengine->get_option('user_created_categories') == 'yes' && $type != '') if ($user_created_categories && $type != '') { $category = new category($id); $data['object'] = $category; $data['page'] = ucfirst($type); if ($this->input->post()) { $image_name = mt_rand() . '.jpg'; $this->load->model('user'); $this->user->upload_file('image', 'files/users', $image_name); $_POST['groups_allowed'] = implode(',', $this->users->get_user_group_name($this->user->get_id())); $_POST['user_id'] = $this->user->get_id(); $_POST['image'] = base_url() . 'files/users/' . $image_name; $category->create($_POST); redirect('/user/blog/categories', 'location'); } $this->show->set_user_backend(); $this->show->user_backend('add_category', $data); } else { redirect("user/main/dashboard", 'location'); } } }