Пример #1
0
 public function loadsubforms($parent_sys_object_id)
 {
     // load relations
     $where = array();
     $order = array();
     $where[] = array('AND', 'id_sys_object_parent', '=', $parent_sys_object_id);
     $order[] = array('table_name', 'ASC');
     $selected_maped_object = new Crud_Models_Subform();
     $selected_maped_objects = $selected_maped_object->search($where);
     // load maped objects
     $where = array();
     $order = array();
     $where[] = array('AND', 'id', '!=', $parent_sys_object_id);
     $order[] = array('table_name', 'ASC');
     $maped_object = new Crud_Models_Object();
     $maped_objects = $maped_object->search($where, $order);
     Libraries_View::getInstance()->selected_maped_objects = $selected_maped_objects;
     Libraries_View::getInstance()->maped_objects = $maped_objects;
     echo Libraries_View::getInstance()->setModule('crud')->load('map/subforms');
 }
Пример #2
0
 public function modify($sys_object_id, $row_id = '', $subform_relation_id = null, $subform_relation_value = null)
 {
     $sys_object = new Crud_Models_Object();
     $sys_object->load(intval($sys_object_id));
     $sys_object->loadFieldsForObject();
     if ($sys_object->is_system == 1 && $this->user->role->safe_title != 'administrator') {
         echo '<script>window.location="' . SITE_ROOT_URI . '/admin/error/' . '"</script>';
         //header('location: ' . SITE_ROOT_URI . '/admin/error/');
         exit;
     }
     if (!$this->user->role->canExecuteAction('can_view_' . $sys_object->table_name)) {
         echo '<script>window.location="' . SITE_ROOT_URI . '/admin/error/' . '"</script>';
         //header('location: ' . SITE_ROOT_URI . '/admin/error/');
         exit;
     }
     if ($sys_object->custom_crud_class != '' && new $sys_object->custom_crud_class() instanceof Crud_Interfaces_Crud) {
         echo call_user_func(array(new $sys_object->custom_crud_class(), 'modify'), $sys_object_id, $row_id);
     } else {
         $object_data = new Libraries_Db_Mysql_Model($sys_object->table_name);
         $subforms = array();
         if ($row_id != '') {
             $object_data->load(intval($row_id));
             $where = array();
             $where[] = array('AND', 'id_sys_object_parent', '=', $sys_object->id);
             $subform = new Crud_Models_Subform();
             $subforms = $subform->search($where);
         }
         if (isset($_GET['clone']) && $_GET['clone'] == 1) {
             $object_data->id = null;
         }
         $subform_relation = null;
         $subform_relation_field = null;
         if ($subform_relation_id) {
             $subform_relation = new Crud_Models_Subform();
             $subform_relation->load($subform_relation_id);
             $subform_relation_field = new Crud_Models_Field();
             $subform_relation_field->load($subform_relation->id_sys_field);
         }
         Libraries_Event::trigger('beforeFormOpen', $sys_object, $object_data);
         $user = Admin_Libraries_Admin::getLogedUser()->loadRole();
         Libraries_View::getInstance()->sys_object = $sys_object;
         Libraries_View::getInstance()->object_data = $object_data;
         Libraries_View::getInstance()->subforms = $subforms;
         Libraries_View::getInstance()->subform_relation = $subform_relation;
         Libraries_View::getInstance()->subform_relation_field = $subform_relation_field;
         Libraries_View::getInstance()->subform_relation_value = $subform_relation_value;
         Libraries_View::getInstance()->user = $user;
         $content = Libraries_View::getInstance()->setModule('crud')->load('row');
         echo $content;
     }
 }