public function add_comment() { $obj_option = joosRequest::post('obj_option'); $obj_id = joosRequest::int('obj_id', 0); $comment_text = joosRequest::post('comment_text'); $parent_id = joosRequest::int('parent_id', 0); $comment = new modelComments(); $comment->obj_option = $obj_option; $comment->obj_id = $obj_id; $comment->comment_text = $comment_text; $comment->parent_id = $parent_id; $comment->store(); return array(); }
/** * Смена статуса доступа группы к действию * * @return array */ public function change_rules() { $group_id = joosRequest::int('group_id'); $task_id = joosRequest::int('task_id'); $access = new modelUsersAclRolesGroups(); $access->group_id = $group_id; $access->task_id = $task_id; $access->find(); if ($access->id) { $access->delete($access->id); } else { $access->store(); } return array('success' => true, 'message' => 'Сохранено'); }
public static function autoajax() { //$option = joosRequest::param('option'); // выполняемая задача $task = joosRequest::param('task'); // идентификатор запрашиваемого элемента $obj_id = joosRequest::int('obj_id', 0, $_POST); // ключ-название запрашиваемого элемента $obj_key = joosRequest::post('obj_key'); // название объекта запрашиваемого элемента $model = joosRequest::param('obj_model'); if (!$model) { return false; } // пустой объект для складирования результата $return_onj = new stdClass(); if (class_exists($model)) { // создаём объект класса $obj = new $model(); switch ($task) { case 'status_change': $obj->load($obj_id); // меняем состояние объекта на противоположное $obj->change_state($obj_key); // получаем настройки полей $fields_info = $obj->get_fieldinfo(); $fields_info[$obj_key] = array_merge_recursive($fields_info[$obj_key], array('html_table_element_param' => array('statuses' => array(0 => 'Скрыто', 1 => 'Опубликовано'), 'images' => array(0 => 'publish_x.png', 1 => 'publish_g.png')))); // формируем ответ из противоположных элементов текущему состоянию $return_onj->image = isset($fields_info[$obj_key]['html_table_element_param']['images'][!$obj->{$obj_key}]) ? $fields_info[$obj_key]['html_table_element_param']['images'][!$obj->{$obj_key}] : 'error.png'; $return_onj->mess = isset($fields_info[$obj_key]['html_table_element_param']['statuses'][!$obj->{$obj_key}]) ? $fields_info[$obj_key]['html_table_element_param']['statuses'][!$obj->{$obj_key}] : 'ERROR'; $return_onj->new_class = $obj->{$obj_key} ? 'icon-remove' : 'icon-ok'; break; default: return false; break; } echo json_encode($return_onj); return true; } $return_onj->image = 'error.png'; $return_onj->mess = 'error-class'; echo json_encode($return_onj); return false; }
/** * Смена статуса (поля 'state') */ public static function set_state() { $obj_id = joosRequest::int('obj_id', 0, $_POST); $obj_state = joosRequest::post('obj_state'); $obj_model = joosRequest::post('obj_model'); if (!$obj_model || !class_exists($obj_model)) { return array('type' => 'error'); } $new_state = $obj_state == 1 ? 0 : 1; $obj = new $obj_model(); $obj->load($obj_id); if (!$obj->change_state('state')) { return array('type' => 'error'); } return array('type' => 'success', 'message' => 'Статус изменён', 'new_state' => $new_state, 'new_title' => $new_state == 1 ? 'Активно' : 'Не активно', 'new_class' => $new_state == 1 ? 'icon-ok' : 'icon-remove'); }