Re: codefight cms could not get admin page

Hi dbashyal,
Actually I did put you in a wrong impression by this

[quote:2q4o5bh2]I modified the URI.php library file to remove the suffix and then it started working.


[/quote:2q4o5bh2]

Hi Chaleswa,

Yes i missunderstood you. And, i think your solution is best for now and actually i added that to my site codefight.org now as well. Thanks :)

I saw that issue after upgrading to current codeigniter and not sure how i fixed that time. Hopefully it will be fine in next release of codeigniter.

continue reading ...

 

 

 

Author dbashyal has posted total 30 posts.
click here To post comments on the above post.
Date: 01-04-2010 17:07:52pm

Re: Admin multi edit feature validation

Thank you very much for the quick solution.
Author chaleswa has posted total 9 posts.

Date: 11-05-2010 00:14:33am

Re: Admin multi edit feature validation

For a quick solution you can replace edit function with this one:


function _edit()
{
$this->load->helper('security');
$this->load->library('form_validation');
$data = '';
$id_array = array();

if(!isset($_POST['users'])) {
if(isset($_POST['select'])) {
$id_array = $_POST['select'];
} else {
//$data['error_message']['select'] = "You must select atleast one user to edit";
$msg = array('error' => '<p>You must select atleast one user to edit.</p>');
set_global_messages($msg, 'error');

unset($_POST);
$this->index();
exit();

}
}

!is_array($id_array) ? $id_array = array() : '';

//START: for the first page load, get data from database
foreach($id_array as $id) {

$id = preg_replace('/[^0-9]+/','',$id);

$this->db->where('users_id',$id);
$query = $this->db->get('users');

foreach ($query->result() as $row)
{
$_POST['users'][$row->users_id]['id'] = $row->users_id;
$_POST['users'][$row->users_id]['active'] = $row->active;
$_POST['users'][$row->users_id]['email'] = $row->email;
$_POST['users'][$row->users_id]['firstname'] = $row->firstname;
$_POST['users'][$row->users_id]['lastname'] = $row->lastname;
$_POST['users'][$row->users_id]['groups_id'] = $row->groups_id;
}
}
//END: for the first page load, get data from database

//START: clean data and update in database
if($this->input->post('edit') == 'Update' && isset($_POST['users']) && is_array($_POST['users'])) {
foreach($_POST['users'] as $v) {
//cleaning
$id = (int)preg_replace('/[^0-9]+/','',$v['id']); //only intergers
$active = (int)preg_replace('/[^0-9]+/','',$v['active']);
$email = xss_clean($v['email']);
$firstname = xss_clean($v['firstname']);
$lastname = xss_clean($v['lastname']);
$groups_id = (int)preg_replace('/[^0-9]+/','',$v['groups_id']);

//clean the data to autofill in form
$_POST['users'][$id]['id'] = $id;
$_POST['users'][$id]['active'] = $active;
$_POST['users'][$id]['email'] = $email;
$_POST['users'][$id]['firstname'] = $firstname;
$_POST['users'][$id]['lastname'] = $lastname;
$_POST['users'][$id]['groups_id'] = $groups_id;

//update database if set
if(!empty($email) && !empty($groups_id) && !empty($id)) {

$_POST['email'] = $email;
$_POST['groups_id'] = $groups_id;
$_POST['firstname'] = $firstname;
$_POST['lastname'] = $lastname;

$val = array(
array('field' => 'email','label' => 'Email','rules' => 'trim|required|xss_clean|valid_email'),
array('field' => 'groups_id','label' => 'Group','rules' => 'trim|required|xss_clean'),
array('field' => 'firstname','label' => 'First Name','rules' => 'trim|required|xss_clean'),
array('field' => 'lastname','label' => 'Last Name','rules' => 'trim|required|xss_clean')
);

$this->form_validation->set_rules($val);

if ($this->form_validation->run() == FALSE)
{
if(!validation_errors() == '' && $this->input->post('edit') == 'Update') {
$msg = array('error' => validation_errors());
set_global_messages($msg, 'error');
}
}
else {
$this->db->where('users_id', $id);
$sql_update = array(
'active' => $active,
'email' => $email,
'firstname' => $firstname,
'lastname' => $lastname,
'groups_id' => $groups_id
);
$this->db->update('users', $sql_update);

$msg = array('success' => '<p>Updated successfully.</p>');
set_global_messages($msg, 'success');
}
} else {
$msg = array('error' => '<p>Required fields can not be empty!</p>');
set_global_messages($msg, 'error');
}
}
}
//END: validate data and update in database

$assets = array();

//load all required css
//if media type not defined, screen is default.
//$assets['css'] = array('admin','swiff','box','upload');
$assets['css'] = array(
'all' => array('admin','users','box')
);
//load all required js
$assets['js'] = array();

$this->assets->load($assets);

//$data['users'] = $this->usersmodel->get_users();

//---
$html_string = $this->load->view('users_edit_view', $data, true);//Get view data in place of sending to browser.

$this->process->view($html_string);
}
Author dbashyal has posted total 30 posts.

Date: 08-05-2010 17:58:38pm

Re: Admin multi edit feature validation

if(!empty($email) && !empty($groups_id) && !empty($id))

Because of above code it doesn't save without email but i haven't placed the validation for email yet. I'll do my best to look into these on this weekend.
Author dbashyal has posted total 30 posts.

Date: 06-05-2010 05:12:05am

Re: Admin multi edit feature validation

Sorry. I was indeed referring to validation in the user section of the admin panel.
The email is a must field for the user. So accidently, If the admin removes the email and updates, it gets updated. But it is a required field and should not get updated without a proper email address (like wise others pages etc as well).

I tried to add validation but since it is written to update multiple users at the same time, I feel difficult in doing so.

Also when creating/editing a page if a menu option is not chosen then php error appears on top after submission.
Author chaleswa has posted total 9 posts.

Date: 04-05-2010 04:58:06am

Re: Admin multi edit feature validation

Not exactly sure what you mean.

Do you want to save some users without email address? If so, whats the use of creating one as they need to enter email address when they login.

I am thinking to add username field as well, so users can login with either username or email. Also, someone suggested to include change of password for users from admin.

I am currently making changes on CMS to work on CodeIgniter 2.0. Its almost finished, just need to convert existing plugins to helper as Codeigniter doesn't support plugins anymore.

Please let me know if you think of any modification/upgrade that will be benficial for all.
Author dbashyal has posted total 30 posts.

Date: 04-05-2010 04:48:29am

Admin multi edit feature validation

The multiple edit feature is really a nice feature to have in the admin panel. But I don't know how to perform server side validation with multiple edit feature. For example if I edit two users and remove the mandatory field e.g email field, it updates with blank email.
Is there a way to do a validation without loosing the multi edit feature or is it better to remove and update for edit/updates.

Note: The new design in the admin panel looks nice and more compact than the previous one. Thanks for the quick update.
Author chaleswa has posted total 9 posts.

Date: 04-05-2010 00:01:21am

 

 

You may also like:

And, Around the globe:

 

 

 

 1 2 3 4 >  Last ›
 


Page rendered in 2.0799 seconds

 
Powered by: Codefight CMS | A Damodar Bashyal Creation.