function form_title_url($title, $title_url, $existing_url = NULL)
{
    if ($title_url != '' && $title_url != $existing_url) {
        return $title_url;
    } else {
        return url_username($title, 'dash', TRUE);
    }
}
Example #2
0
 function modify_authd_post()
 {
     if ($this->oauth_user_id == $this->get('id')) {
         $this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
         $this->form_validation->set_rules('phone_number', 'Phone Number', 'valid_phone_number');
         if ($this->form_validation->run() == true) {
             // Update Data
             $user_id = $this->oauth_user_id;
             if (!$this->input->post('username')) {
                 $username = $this->input->post('name');
             } else {
                 $username = $this->input->post('username');
             }
             $update_data = array('username' => url_username($username, 'none', true), 'email' => $this->input->post('email'), 'gravatar' => md5($this->input->post('email')), 'phone_number' => $this->input->post('phone_number'), 'name' => $this->input->post('name'), 'time_zone' => $this->input->post('time_zone'), 'privacy' => $this->input->post('privacy'), 'language' => $this->input->post('language'), 'geo_enabled' => $this->input->post('geo_enabled'));
             if ($this->social_auth->update_user($user_id, $update_data)) {
                 $user = $this->social_auth->get_user('user_id', $user_id, TRUE);
                 if ($this->input->post('session') == 1) {
                     $this->social_auth->set_userdata($user);
                 }
                 $message = array('status' => 'success', 'message' => 'User changes saved', 'user' => $user);
             } else {
                 $message = array('status' => 'error', 'message' => 'Could not save user changes');
             }
         } else {
             $message = array('status' => 'error', 'message' => validation_errors());
         }
     } else {
         $message = array('status' => 'error', 'message' => 'Ooops this is not your user account');
     }
     $this->response($message, 200);
 }
 function create_public_post()
 {
     // Validation Rules
     $this->form_validation->set_rules('comment_name', 'Name', 'required');
     $this->form_validation->set_rules('comment_email', 'Email Address', 'required|valid_email');
     $this->form_validation->set_rules('comment', 'Comment', 'required');
     // Validates
     if ($this->form_validation->run() == true) {
         /*
         			// Akismet Enabled
         			if (config_item('comments_akismet') == 'TRUE')		
         			{
         				$this->load->library('akismet');
         				
         				$comment = array('author' => $this->input->post('comment_name'), 'email' => $this->input->post('comment_email'), 'body' => $this->input->post('comment'));
         				$config  = array('blog_url' => config_item('site_url'), 'api_key' => config_item('site_akismet_key'), 'comment' => $comment);
         				
         				$this->akismet->init($config);
         				 
         				if ($this->akismet->errors_exist())
         				{				
         					if ($this->akismet->is_error('AKISMET_INVALID_KEY')) 			
         					{
         						return FALSE;
         					}
         					elseif ($this->akismet->is_error('AKISMET_RESPONSE_FAILED'))
         					{
         						return FALSE;
         					}
         					elseif ($this->akismet->is_error('AKISMET_SERVER_NOT_FOUND'))
         					{
         						return FALSE;
         					}
         					else															
         					{
         						return TRUE;
         					}
         				}
         				else
         				{
         					if ($this->akismet->is_spam())	
         					{
         						$this->form_validation->set_message('akistmet_validate', 'We think your comment might be spam!"');		
         						return FALSE; 
         					}
         					else
         					{
         						return TRUE;
         					}
         				}
         			}
         			
         			// ReCAPTCHA Enabled
         			if (config_item('comments_recaptcha') == 'TRUE')		
         			{
         			    $this->load->library('recaptcha');	
         			
         				if ($this->recaptcha->check_answer($this->input->ip_address(), $this->input->post('recaptcha_challenge_field'), $val))
         				{
         					$recaptcha = TRUE;
         				} 
         				else
         				{
         					$this->form_validation->set_message('check_captcha', $this->lang->line('recaptcha_incorrect_response'));
         					$recaptcha = FALSE;
         				}	
         			}
         */
         log_message('debug', 'COOOOM inside validation');
         if ($content = $this->social_igniter->check_content_comments($this->input->post('content_id'))) {
             log_message('debug', 'COOOOM inside content');
             $user = $this->social_auth->get_user('email', $this->input->post('comment_email'));
             if (!$user) {
                 log_message('debug', 'COOOOM inside create user');
                 $username = url_username($this->input->post('comment_name'), 'none', true);
                 $email = $this->input->post('comment_email');
                 $password = random_string('unique');
                 $additional_data = array('name' => $this->input->post('comment_name'));
                 $level = config_item('comments_group');
                 // Register User
                 if ($this->social_auth->register($username, $password, $email, $additional_data, $level)) {
                     log_message('debug', 'COOOOM inside register');
                     $user = $this->social_auth->get_user('email', $this->input->post('comment_email'));
                 }
             }
             $comment_data = array('reply_to_id' => $this->input->post('reply_to_id'), 'content_id' => $content->content_id, 'owner_id' => $content->user_id, 'module' => $content->module, 'type' => $content->type, 'user_id' => $user->user_id, 'comment' => $this->input->post('comment'), 'geo_lat' => $this->input->post('geo_lat'), 'geo_long' => $this->input->post('geo_long'), 'approval' => $content->comments_allow);
             // Insert
             if ($comment = $this->social_tools->add_comment($comment_data)) {
                 log_message('debug', 'COOOOM inside comment created');
                 $comment_data['comment_id'] = $comment->comment_id;
                 $comment_data['created_at'] = format_datetime(config_item('comments_date_style'), $comment->created_at);
                 $comment_data['name'] = $comment->name;
                 $comment_data['username'] = $comment->username;
                 $comment_data['gravatar'] = $comment->gravatar;
                 $comment_data['image'] = $comment->image;
                 $comment_data['sub'] = '';
                 // Set Reply Id For Comments
                 if ($comment->reply_to_id) {
                     $comment_data['sub'] = 'sub_';
                     $comment_data['reply_id'] = $comment->reply_to_id;
                 }
                 // Set Display Comment
                 if ($content->comments_allow == 'A') {
                     $comment_data['comment'] = '<i>Your comment is awaiting approval!</i>';
                 }
                 $message = array('status' => 'success', 'message' => 'Yay we posted your comment', 'data' => $comment_data);
             } else {
                 $message = array('status' => 'error', 'message' => 'Oops unable to post your comment');
             }
         } else {
             $message = array('status' => 'error', 'message' => 'Oops you can not comment on that content');
         }
     } else {
         $message = array('status' => 'error', 'message' => validation_errors());
     }
     $this->response($message, 200);
 }
 function process_tags($tags_post, $content_id)
 {
     if ($tags_post) {
         // Declarations
         $tag_total = 1;
         $tags_array = array(explode(", ", $tags_post));
         foreach ($tags_array[0] as $tag) {
             if ($tag != '') {
                 // Check for tag existence
                 $tag_exists = $this->get_tag($tag);
                 // Insert New Tag
                 if (!$tag_exists) {
                     $tag_url = url_username($tag, 'dash', TRUE);
                     $tag_id = $this->ci->tags_model->add_tag($tag, $tag_url);
                 } else {
                     $tag_id = $tag_exists->tag_id;
                 }
                 // Insert Link
                 $insert_link = $this->ci->tags_model->add_tags_link($tag_id, $content_id);
                 // Check Taxonomy Existence
                 $tag_total = $this->ci->tags_model->get_tag_total($tag);
                 $tag_taxonomy = $this->ci->taxonomy_model->get_taxonomy($tag_id, 'tag');
                 if ($tag_taxonomy) {
                     $update_taxonomy = $this->ci->taxonomy_model->update_taxonomy($tag_taxonomy->taxonomy_id, $tag_total);
                 } else {
                     $insert_taxonomy = $this->ci->taxonomy_model->add_taxonomy($tag_id, 'tag', $tag_total);
                 }
             }
         }
         return TRUE;
     }
 }
Example #5
0
 function admin()
 {
     // Check If Superadmin Exists
     // Load Libraries (doing this before DB is created causes mean errors )
     $this->load->config('install');
     $this->load->database();
     $this->load->library('session');
     $this->load->library('social_igniter');
     $this->load->library('social_auth');
     $this->load->library('installer');
     // Validation
     $username = url_username($this->input->post('name'), 'none', true);
     $email = $this->input->post('email');
     $password = $this->input->post('password');
     $additional_data = array('phone_number' => '', 'name' => $this->input->post('name'), 'image' => '', 'language' => $this->input->post('language'));
     if ($user = $this->social_auth->register($username, $password, $email, $additional_data, config_item('super_admin_group'))) {
         // Add Admin To Settings
         $this->installer->install_settings('site', array('admin_email' => $email));
         // Send Emails
         $data = array('name' => $user->name, 'username' => $user->username, 'email' => $user->email);
         /*
         // If Activation Email
         if (config_item('email_activation') == false)
         {
         	$message = $this->load->view(config_item('email_templates').config_item('email_signup'), $data, true);
         		
         	$this->email->from(config_item('site_admin_email'), config_item('site_title'));
         	$this->email->to($user->email);
         	$this->email->subject(config_item('site_title').' thanks you for signing up');
         	$this->email->message($message);
         	$this->email->send();
         }
         else
         {		
         	$data = array(
         		'email'   	 => $user->email,
         		'user_id'    => $user->user_id,
         		'email'      => $user->email,
         		'activation' => $user->activation_code,
         	);
         		        
         	$message = $this->load->view(config_item('email_templates').config_item('email_activate'), $data, true);
         		
         	$this->email->from(config_item('site_admin_email'), config_item('site_title'));
         	$this->email->to($user->email);
         	$this->email->subject(config_item('site_title') . ' - Account Activation');
         	$this->email->message($message);
         	$this->email->send();
         }
         */
         // Check "remember me"
         if ($this->input->post('remember') == 1) {
             $remember = TRUE;
         } else {
             $remember = FALSE;
         }
         // Store Session Data
         if ($this->input->post('session') == 1) {
             $session = TRUE;
         } else {
             $session = FALSE;
         }
         // Login User
         if ($this->social_auth->login($user->email, $this->input->post('password'), $remember, $session)) {
             // Get User Data
             $meta = $this->social_auth->get_user_meta($user->user_id);
             $user->image = $this->social_igniter->profile_image($user->user_id, $user->image, $user->gravatar);
             $message = array('status' => 'success', 'message' => 'Success you will now be logged in', 'user' => $user, 'meta' => $meta);
         } else {
             $message = array('status' => 'error', 'message' => 'Oops could not log you in');
         }
     } else {
         $message = array('status' => 'error', 'message' => 'Oops could not create user');
     }
     echo json_encode($message);
 }
 function modify_authd_post()
 {
     if ($this->oauth_user_id == $this->get('id')) {
         // User
         $user_id = $this->oauth_user_id;
         // Delete Picture
         if ($this->input->post('delete_pic') == 1) {
             $this->load->helper('file');
             delete_files($this->config->item('profile_images') . $user->user_id . "/");
             $user_picture = '';
         } else {
             $user_picture = '';
         }
         /*    
             	// Upload Picture
         		if (!$this->input->post('userfile'))
         		{
         			$config['upload_path'] 		= config_item('uploads_folder');
         			$config['allowed_types'] 	= config_item('users_images_formats');		
         			$config['overwrite']		= true;
         			$config['max_size']			= config_item('users_images_max_size');
         			$config['max_width']  		= config_item('users_images_max_dimensions');
         			$config['max_height']  		= config_item('users_images_max_dimensions');
         		
         			$this->load->library('upload',$config);
         			
         			if (!$this->upload->do_upload())
         			{
         				$error = array('error' => $this->upload->display_errors());
         			}	
         			else
         			{
         				// Load Image Model
         				$this->load->model('image_model');
         				
         				// Upload & Sizes
         				$file_data		= $this->upload->data();
         				$image_sizes	= array('full', 'large', 'medium', 'small');
         
         				// Process New Images
         				$image_size 	= getimagesize(config_item('uploads_folder').$image_save);
         				$file_data		= array('file_name'	=> $image_save, 'image_width' => $image_size[0], 'image_height' => $image_size[1]);
         				$image_sizes	= array('full', 'large', 'medium', 'small');
         				$create_path	= config_item('users_images_folder').$user_id.'/';
         
         				$this->image_model->make_images($file_data, 'users', $image_sizes, $create_path, TRUE);
         			}	
         		}
         */
         $update_data = array('username' => url_username($this->input->post('username'), 'none', true), 'email' => $this->input->post('email'), 'gravatar' => md5($this->input->post('email')), 'name' => $this->input->post('name'), 'image' => $user_picture, 'time_zone' => $this->input->post('time_zone'), 'privacy' => $this->input->post('privacy'), 'language' => $this->input->post('language'), 'geo_enabled' => $this->input->post('geo_enabled'));
         if ($this->social_auth->update_user($user_id, $update_data)) {
             $user = $this->social_auth->get_user('user_id', $user_id);
             $this->social_auth->set_userdata($user);
             $message = array('status' => 'success', 'message' => 'User changes saved', 'data' => $user);
         } else {
             $message = array('status' => 'error', 'message' => 'Could not save user changes');
         }
     } else {
         $message = array('status' => 'error', 'message' => 'Ooops this is not your user account');
     }
     $this->response($message, 200);
 }