function execute() { $action = Request::post('contact_action'); if (!$action) { return; } $model = new contactsUsersModel(); if ($action == 'create') { if (sizeof($model->where(array('login' => Request::post('login')))->fetchAll()) > 0) { return; } $data = array('name' => Request::post('name'), 'login' => Request::post('login'), 'date' => time(), 'block' => false); if (Request::post('password')) { $data['password'] = md5(Request::post('password')); } $model->insert($data); } else { if ($action == 'update') { if (sizeof($model->where(array('login' => Request::post('login')))->fetchAll()) <= 0) { return; } $data = array('name' => Request::post('name')); if (Request::post('password')) { $data['password'] = md5(Request::post('password')); } $model->where(array('login' => Request::post('login')))->update($data); } } if (Rights::isHave('contacts', 'add_right')) { $this->setRights(Request::post('login'), Request::post('rights') ? Request::post('rights') : array()); } }