Beispiel #1
0
 public static function create($field_name, $structure, $module)
 {
     $field = new __cms_field();
     $field->do_retrieve([], ['where_equals' => ['mid' => $module, 'field_name' => $field_name]]);
     if (!$field->get_primary_key()) {
         $field->field_name = $field_name;
         $field->mid = $module;
         $field->type = $structure->type;
         $field->title = isset($structure->title) ? $structure->title : ucwords(str_replace('_', ' ', $field_name));
         if (isset($structure->module) && $structure->module) {
             $_module = new __cms_module();
             $_module->do_retrieve(['mid'], ['where_equals' => ['table_name' => $structure->module]]);
             $field->link_module = $_module->mid;
             if (isset($structure->field) && $structure->field) {
                 $_field = new __cms_field();
                 $_field->do_retrieve(['fid'], ['where_equals' => ['field_name' => $structure->field, 'mid' => $_module->mid]]);
                 if ($_field->get_primary_key()) {
                     $field->link_field = $_field->fid;
                 }
             }
         }
         $field->list = isset($structure->list) ? $structure->list : true;
         $field->filter = isset($structure->filter) ? $structure->filter : true;
         $field->required = isset($structure->required) ? $structure->required : true;
         $field->do_save();
     } else {
         throw new \Exception('Field ' . $field_name . ' already exists in module ' . $module);
     }
     return $field;
 }
Beispiel #2
0
 /** Add user level management
  * ---CMS User
  * ---CMS User level
  * ---CMS User --> CMS Module
  * */
 public function patch_v4()
 {
     if (!db::table_exists('_cms_user')) {
         self::create_from_structure('_cms_user');
         table::reload_table_definitions();
         $user_level = new _cms_user_level();
         $user_level->title = 'User';
         $user_level->do_save();
         $user_level->ulid = 0;
         $user_level->title = 'Webmaster';
         $user_level->do_save();
         $user_level->ulid = 0;
         $user_level->title = 'Admin';
         $user_level->do_save();
         $cms_user = new _cms_user();
         $cms_user->title = 'admin';
         $cms_user->password = '******';
         $cms_user->ulid = 3;
         $cms_user->do_save();
         $_module = new _cms_module();
         $_module->do_retrieve([], ['where_equals' => ['table_name' => '_cms_module']]);
         $_field = new _cms_field();
         $_field->do_retrieve([], ['where_equals' => ['mid' => $_module->get_primary_key(), 'field_name' => 'user_level_view']]);
         static::modify_link_field($_field, '_cms_user_level', 'title');
         $_field = new _cms_field();
         $_field->do_retrieve([], ['where_equals' => ['mid' => $_module->get_primary_key(), 'field_name' => 'user_level_add']]);
         static::modify_link_field($_field, '_cms_user_level', 'title');
         $_field = new _cms_field();
         $_field->do_retrieve([], ['where_equals' => ['mid' => $_module->get_primary_key(), 'field_name' => 'user_level_delete']]);
         static::modify_link_field($_field, '_cms_user_level', 'title');
     }
 }