public function store_field() { if (!Auth::user()) { return redirect('/'); } Field::create(Input::all()); return redirect('/add_field'); }
/** * Run the database seeds. * * @return void */ public function run() { Field::truncate(); Field::create(['field_name' => 'foreman', 'field_desc' => 'a worker, especially a man, who supervises and directs other workers.']); Field::create(['field_name' => 'Elevator Installers and Repairers', 'field_desc' => 'Assemble, install, repair, or maintain electric or hydraulic freight or passenger elevators, escalators, or dumbwaiters.']); Field::create(['field_name' => 'Plumber', 'field_desc' => 'A person who installs and repairs the pipes and fittings of water supply, sanitation, or heating systems.']); Field::create(['field_name' => 'Transportation Inspectors', 'field_desc' => 'Inspect equipment or goods in connection with the safe transport of cargo or people. Includes rail transportation inspectors, such as freight inspectors; rail inspectors; and other inspectors of transportation vehicles, not elsewhere classified.']); Field::create(['field_name' => 'Crane Operator', 'field_desc' => 'A crane operator is someone who uses a crane to transport various objects. There are many different types, makes, models and sizes of cranes, such as mobile cranes, tower cranes, boom trucks and self-erect tower cranes.']); Field::create(['field_name' => 'Carpenter', 'field_desc' => 'A person who makes and repairs wooden objects and structures.']); Field::create(['field_name' => 'Gardener', 'field_desc' => 'A person who tends and cultivates a garden as a pastime or for a living.']); }
/** * Run the migrations. * * @return void */ public function up() { \App\Field::create(['name' => 'male', 'title' => '男', 'field_class' => 'gender'])->create(['name' => 'female', 'title' => '女', 'field_class' => 'gender'])->create(['name' => 'news', 'title' => '订阅号', 'field_class' => 'wechat_type'])->create(['name' => 'service', 'title' => '服务号', 'field_class' => 'wechat_type'])->create(['name' => 'enterprise', 'title' => '企业号', 'field_class' => 'wechat_type'])->create(['name' => 'depot', 'title' => '素材', 'field_class' => 'wechat_message_type'])->create(['name' => 'news', 'title' => '图文', 'field_class' => 'wechat_message_type'])->create(['name' => 'image', 'title' => '图片', 'field_class' => 'wechat_message_type'])->create(['name' => 'thumb', 'title' => '缩略图', 'field_class' => 'wechat_message_type'])->create(['name' => 'video', 'title' => '视频', 'field_class' => 'wechat_message_type'])->create(['name' => 'shortvideo', 'title' => '小视频', 'field_class' => 'wechat_message_type'])->create(['name' => 'voice', 'title' => '音频', 'field_class' => 'wechat_message_type'])->create(['name' => 'music', 'title' => '音乐', 'field_class' => 'wechat_message_type'])->create(['name' => 'text', 'title' => '文字', 'field_class' => 'wechat_message_type'])->create(['name' => 'link', 'title' => '连接', 'field_class' => 'wechat_message_type'])->create(['name' => 'location', 'title' => '地址', 'field_class' => 'wechat_message_type'])->create(['name' => 'callback', 'title' => '回调', 'field_class' => 'wechat_message_type'])->create(['name' => 'event', 'title' => '事件', 'field_class' => 'wechat_message_type'])->create(['name' => 'subscribe', 'title' => '关注', 'field_class' => 'wechat_event_type'])->create(['name' => 'unsubscribe', 'title' => '取消关注', 'field_class' => 'wechat_event_type'])->create(['name' => 'SCAN', 'title' => '扫描二维码', 'field_class' => 'wechat_event_type'])->create(['name' => 'LOCATION', 'title' => '地址', 'field_class' => 'wechat_event_type'])->create(['name' => 'CLICK', 'title' => '点击', 'field_class' => 'wechat_event_type'])->create(['name' => 'VIEW', 'title' => '视图', 'field_class' => 'wechat_event_type'])->create(['name' => 'scancode_push', 'title' => '扫描事件', 'field_class' => 'wechat_event_type'])->create(['name' => 'scancode_waitmsg', 'title' => '扫描事件「非跳转」', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_sysphoto', 'title' => '系统拍照发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_photo_or_album', 'title' => '拍照或者相册发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_weixin', 'title' => '相册发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'location_select', 'title' => '地址选择', 'field_class' => 'wechat_event_type'])->create(['name' => 'XXS', 'title' => '特小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XS', 'title' => '加小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'S', 'title' => '小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'M', 'title' => '中号', 'field_class' => 'clothes_size_type'])->create(['name' => 'L', 'title' => '大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XL', 'title' => '加大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XXL', 'title' => '特大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XXXL', 'title' => '特特大号', 'field_class' => 'clothes_size_type'])->create(['name' => '27', 'title' => '腰围27', 'field_class' => 'clothes_size_type'])->create(['name' => '28', 'title' => '腰围28', 'field_class' => 'clothes_size_type'])->create(['name' => '29', 'title' => '腰围29', 'field_class' => 'clothes_size_type'])->create(['name' => '30', 'title' => '腰围30', 'field_class' => 'clothes_size_type'])->create(['name' => '31', 'title' => '腰围31', 'field_class' => 'clothes_size_type'])->create(['name' => '32', 'title' => '腰围32', 'field_class' => 'clothes_size_type'])->create(['name' => '33', 'title' => '腰围33', 'field_class' => 'clothes_size_type'])->create(['name' => '34', 'title' => '腰围34', 'field_class' => 'clothes_size_type'])->create(['name' => 'store', 'title' => '自提', 'field_class' => 'express_type'])->create(['name' => 'express', 'title' => '快递', 'field_class' => 'express_type'])->create(['name' => 'sf-express', 'title' => '顺丰快递', 'field_class' => 'express_name'])->create(['name' => 'sto-express', 'title' => '申通快递', 'field_class' => 'express_name'])->create(['name' => 'yto-express', 'title' => '圆通快递', 'field_class' => 'express_name'])->create(['name' => 'zto-express', 'title' => '中通快递', 'field_class' => 'express_name'])->create(['name' => 'ems', 'title' => 'EMS', 'field_class' => 'express_name'])->create(['name' => 'deppon', 'title' => '德邦物流', 'field_class' => 'express_name'])->create(['name' => 'china_bank', 'title' => '中国银行', 'field_class' => 'bank_name'])->create(['name' => 'construction_bank', 'title' => '中国建设银行', 'field_class' => 'bank_name'])->create(['name' => 'ICBC', 'title' => '中国工商银行', 'field_class' => 'bank_name'])->create(['name' => 'BOCOM', 'title' => '交通银行', 'field_class' => 'bank_name'])->create(['name' => 'agricultural_bank', 'title' => '中国农业银行', 'field_class' => 'bank_name'])->create(['name' => 'merchants_bank', 'title' => '招商银行', 'field_class' => 'bank_name'])->create(['name' => 'post_savings_bank', 'title' => '中国邮政储蓄银行', 'field_class' => 'bank_name'])->create(['name' => 'everbright_bank', 'title' => '中国光大银行', 'field_class' => 'bank_name'])->create(['name' => 'minsheng_bank', 'title' => '中国民生银行', 'field_class' => 'bank_name'])->create(['name' => 'pingan_bank', 'title' => '中国平安银行', 'field_class' => 'bank_name'])->create(['name' => 'SPD', 'title' => '浦发银行', 'field_class' => 'bank_name'])->create(['name' => 'CITIC', 'title' => '中信银行', 'field_class' => 'bank_name'])->create(['name' => 'industrial_bank', 'title' => '兴业银行', 'field_class' => 'bank_name'])->create(['name' => 'huaxia_bank', 'title' => '华夏银行', 'field_class' => 'bank_name'])->create(['name' => 'communications_bank', 'title' => '广发银行', 'field_class' => 'bank_name'])->create(['name' => '', 'title' => '无'])->update(['id' => 0]); \App\Role::create(['id' => 99, 'name' => 'admin', 'display_name' => '超级管理员', 'url' => 'admin'])->create(['id' => 98, 'name' => 'manager', 'display_name' => '项目总监', 'url' => 'admin'])->create(['id' => 97, 'name' => 'owner', 'display_name' => '经理', 'url' => 'admin'])->create(['id' => 96, 'name' => 'leader', 'display_name' => '负责人', 'url' => 'admin'])->create(['id' => 1, 'name' => 'viewer', 'display_name' => '普通用户', 'url' => ''])->create(['id' => 2, 'name' => 'wechater', 'display_name' => '微信用户', 'url' => ''])->create(['id' => 3, 'name' => 'factory', 'display_name' => '厂商'])->create(['id' => 4, 'name' => 'agent', 'display_name' => '代理商'])->create(['id' => 5, 'name' => 'store', 'display_name' => '门店'])->create(['id' => 0, 'name' => 'guest', 'display_name' => '访客', 'url' => ''])->update(['id' => 0]); foreach (['role' => '用户组、权限', 'attachment' => '附件', 'member' => '用户', 'factory' => '厂商', 'agent' => '代理商', 'store' => '门店', 'product' => '产品', 'wechat-account' => '微信公众号', 'wechat-depot' => '微信素材', 'wechat-menu' => '微信菜单', 'wechat-message' => '微信消息', 'wechat-reply' => '微信自定义回复', 'wechat-user' => '微信用户'] as $k => $v) { foreach (['view' => '查看', 'create' => '新建', 'edit' => '编辑', 'destroy' => '删除', 'export' => '导出'] as $k1 => $v1) { \App\Permission::create(['name' => $k . '.' . $k1, 'display_name' => '允许' . $v1 . $v]); } } \App\Role::find(99)->perms()->sync(\App\Permission::all()); (new \App\User())->add(['username' => 'admin', 'password' => '123456', 'nickname' => '超级管理员'], \App\Role::ADMIN); }
public function postSelected(Request $request, $form_code) { $randomCode = Auth::id() . mt_rand(0, 999) . time(); $form = Form::where('form_code', $form_code)->where('form_type', 'template')->where('form_active', '1')->firstOrFail(); $form->update(['form_copy' => $form->form_copy + 1]); $formCopy = Form::create(['form_cuid' => Auth::id(), 'form_type' => 'normal', 'form_code' => $randomCode, 'form_active' => 0, 'form_title' => $form->form_title, 'form_summary' => $form->form_summary, 'form_sort' => 0, 'form_url' => $randomCode, 'form_tips_email' => 0, 'form_limit_auz' => 'allow_all']); foreach ($form->Field()->get() as $field) { $fieldCopy = Field::create(['field_cuid' => Auth::id(), 'field_form_id' => $formCopy->form_id, 'field_sort' => $field->field_sort, 'field_type' => $field->field_type, 'field_title' => $field->field_title, 'field_tips' => $field->field_tips, 'field_attr_name' => Auth::id() . mt_rand(0, 999) . time() . mt_rand(0, 999), 'field_attr_value' => $field->field_attr_value, 'field_attr_width' => $field->field_attr_width, 'field_must' => $field->field_must]); foreach ($field->FieldChildren()->get() as $fieldchildren) { FieldChildren::create(['fieldchildren_field_id' => $fieldCopy->field_id, 'fieldchildren_key' => $fieldchildren->fieldchildren_key, 'fieldchildren_value' => $fieldchildren->fieldchildren_value, 'fieldchildren_value2' => $fieldchildren->fieldchildren_value2, 'fieldchildren_value3' => $fieldchildren->fieldchildren_value3, 'fieldchildren_img_id' => $fieldchildren->fieldchildren_img_id, 'fieldchildren_checked' => $fieldchildren->fieldchildren_checked, 'fieldchildren_disabled' => $fieldchildren->fieldchildren_disabled]); } } $res = redirect('/form/info/' . $formCopy->form_code)->with('msgSuccess', '此表单模板已经添加到您的表单中心当中'); return $res; }
// Route::resource('admin/field', 'Admin\\FieldController'); // Route::get('admin/table/{table}/fields', 'Admin\\tableController@fields' ); }); }); Route::group(['middleware' => ['admin']], function () { }); /***********************************************************************************/ /*********************************************************************************** //api for CRUD & vue Route::get('api/fields/', function(){ return Field::orderBy('id','desc')->get(); }); */ Route::resource('api/table/{table}/methods', 'Admin\\MethodController'); Route::post('api/fields/create', function () { return Field::create(Request::all()); }); Route::put('api/fields/{field}', function (App\Field $field) { //dd($field,Request::all()); if ($field->update(Request::all())) { return 'ok'; } }); Route::delete('api/fields/{field}', function (App\Field $field) { // http://organit.app/api/table/1/fields $field->delete(); }); Route::get('api/table/{table}/fields', function (App\Table $table) { // http://organit.app/api/table/1/fields return $table->fields; });
public function postFieldUpdate(FieldPRequest $request, $form_code) { $form = Form::where('form_code', '=', $form_code)->where('form_type', 'template')->firstOrFail(); //删除原始的 fields 和 fieldchildrens $fields = $form->Field(); foreach ($fields->get() as $field) { $field->FieldChildren()->forceDelete(); } $fields->forceDelete(); $sort = 1; foreach ($request->input('arr') as $row) { $field = Field::create(['field_cuid' => Auth::id(), 'field_form_id' => $form->form_id, 'field_sort' => $sort, 'field_type' => $row['field_type'], 'field_title' => $row['field_title'], 'field_tips' => $row['field_tips'], 'field_attr_name' => time() . str_random(5), 'field_attr_value' => isset($row['field_attr_value']) ? $row['field_attr_value'] : '', 'field_attr_width' => isset($row['field_attr_width']) ? $row['field_attr_width'] : 100, 'field_must' => isset($row['field_must']) ? $row['field_must'] : 0]); $sort++; if (isset($row['children']) && is_array($row['children'])) { foreach ($row['children'] as $key => $child) { FieldChildren::create(['fieldchildren_field_id' => $field->field_id, 'fieldchildren_key' => $key, 'fieldchildren_value' => $child['value'], 'fieldchildren_value2' => isset($child['value2']) ? $child['value2'] : '', 'fieldchildren_value3' => isset($child['value3']) ? $child['value3'] : '', 'fieldchildren_img_id' => isset($child['imgId']) ? $child['imgId'] : 0, 'fieldchildren_checked' => isset($child['checked']) ? 1 : 0, 'fieldchildren_disabled' => isset($child['disabled']) ? 1 : 0]); unset($child); } } } $res = redirect('/manage/template/list')->with('msgSuccess', MSG_SU); return $res; }
public function restoreData(Request $request) { $this->json_file = null; $this->decoded_json = null; $users_exempt_from_lockout = new Collection(); $users_exempt_from_lockout->put(1, 1); //Add another one of these with (userid,userid) to exempt extra users $this->lockUsers($users_exempt_from_lockout); if ($request->session()->has("restore_file_path")) { $filepath = $request->session()->get("restore_file_path"); $request->session()->forget("restore_file_path"); } else { return $this->ajaxResponse(false, "You did not select a valid restore point or upload a valid backup file"); } try { $this->json_file = Storage::get($filepath); } catch (\Exception $e) { $this->ajaxResponse(false, "The backup file couldn't be opened. Make sure it still exists and the permissions are correct."); } try { $this->decoded_json = json_decode($this->json_file); $this->decoded_json->kora3; } catch (\Exception $e) { $this->ajaxResponse(false, "The backup file contains invalid JSON data, it may be corrupt or damaged. Check the file or try another one.\n The restore did not start, so data already in the database was not deleted."); } $backup_data = $this->decoded_json; //Delete all existing data try { foreach (User::all() as $User) { if ($User->id == 1) { //Do not delete the default admin user continue; } else { $User->delete(); } } foreach (Project::all() as $Project) { $Project->delete(); } foreach (Form::all() as $Form) { $Form->delete(); } foreach (Field::all() as $Field) { $Field->delete(); } foreach (Record::all() as $Record) { $Record->delete(); } foreach (Metadata::all() as $Metadata) { $Metadata->delete(); } foreach (Token::all() as $Token) { $Token->delete(); } foreach (Revision::all() as $Revision) { $Revision->delete(); } foreach (DateField::all() as $DateField) { $DateField->delete(); } foreach (FormGroup::all() as $FormGroup) { $FormGroup->delete(); } foreach (GeneratedListField::all() as $GeneratedListField) { $GeneratedListField->delete(); } foreach (ListField::all() as $ListField) { $ListField->delete(); } foreach (MultiSelectListField::all() as $MultiSelectListField) { $MultiSelectListField->delete(); } foreach (NumberField::all() as $NumberField) { $NumberField->delete(); } foreach (ProjectGroup::all() as $ProjectGroup) { $ProjectGroup->delete(); } foreach (RichTextField::all() as $RichTextField) { $RichTextField->delete(); } foreach (ScheduleField::all() as $ScheduleField) { $ScheduleField->delete(); } foreach (TextField::all() as $TextField) { $TextField->delete(); } } catch (\Exception $e) { $this->ajaxResponse(false, "There was a problem when attempting to remove existing information from the\n database, the database user may not have permission to do this or the database may be in use."); } try { //This try-catch is for non-QueryExceptions, like if a table is missing entirely from the JSON data // User foreach ($backup_data->users as $user) { try { $new_user = User::create(array("username" => $user->username, "name" => $user->name, "email" => $user->email, "password" => $user->password, "organization" => $user->organization, "language" => $user->language, "regtoken" => $user->regtoken)); $new_user->id = $user->id; $new_user->admin = $user->admin; $new_user->active = $user->active; $new_user->remember_token = $user->remember_token; $new_user->created_at = $user->created_at; $new_user->updated_at = $user->updated_at; $new_user->locked_out = true; $new_user->save(); } catch (\Exception $e) { $this->ajax_error_list->push($e->getMessage()); } } // Project foreach ($backup_data->projects as $project) { //$new_project = Project::create(array("name" => $project->name, "slug" => $project->slug, "description" => $project->description, "adminGID" => $project->adminGID, "active" => $project->active)); try { $new_project = Project::create(array()); $new_project->name = $project->name; $new_project->slug = $project->slug; $new_project->description = $project->description; $new_project->adminGID = $project->adminGID; $new_project->active = $project->active; $new_project->pid = $project->pid; $new_project->created_at = $project->created_at; $new_project->updated_at = $project->updated_at; $new_project->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // Form foreach ($backup_data->forms as $form) { try { $new_form = Form::create(array("pid" => $form->pid)); $new_form->fid = $form->fid; $new_form->name = $form->name; $new_form->slug = $form->slug; $new_form->description = $form->description; $new_form->adminGID = $form->adminGID; $new_form->layout = $form->layout; $new_form->public_metadata = $form->public_metadata; $new_form->layout = $form->layout; $new_form->adminGID = $form->adminGID; $new_form->created_at = $form->created_at; $new_form->updated_at = $form->updated_at; $new_form->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // Field foreach ($backup_data->fields as $field) { try { $new_field = Field::create(array("pid" => $field->pid, "fid" => $field->fid, "order" => $field->order, "type" => $field->type, "name" => $field->name, "slug" => $field->slug, "desc" => $field->desc, "required" => $field->required, "default" => $field->default, "options" => $field->options)); $new_field->flid = $field->flid; $new_field->default = $field->default; $new_field->options = $field->options; $new_field->created_at = $field->created_at; $new_field->updated_at = $field->updated_at; $new_field->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // FormGroup foreach ($backup_data->formgroups as $formgroup) { try { $new_formgroup = new FormGroup(); $new_formgroup->name = $formgroup->group_data->name; $new_formgroup->fid = $formgroup->group_data->fid; $new_formgroup->create = $formgroup->group_data->create; $new_formgroup->edit = $formgroup->group_data->edit; $new_formgroup->ingest = $formgroup->group_data->ingest; $new_formgroup->delete = $formgroup->group_data->delete; $new_formgroup->modify = $formgroup->group_data->modify; $new_formgroup->destroy = $formgroup->group_data->destroy; $new_formgroup->id = $formgroup->group_data->id; $new_formgroup->created_at = $formgroup->group_data->created_at; $new_formgroup->updated_at = $formgroup->group_data->updated_at; $new_formgroup->save(); foreach ($formgroup->user_data as $user_id) { $new_formgroup->users()->attach($user_id); } } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // ProjectGroup foreach ($backup_data->projectgroups as $projectgroup) { try { $new_projectgroup = new ProjectGroup(); $new_projectgroup->id = $projectgroup->group_data->id; $new_projectgroup->name = $projectgroup->group_data->name; $new_projectgroup->pid = $projectgroup->group_data->pid; $new_projectgroup->create = $projectgroup->group_data->create; $new_projectgroup->edit = $projectgroup->group_data->edit; $new_projectgroup->delete = $projectgroup->group_data->delete; $new_projectgroup->created_at = $projectgroup->group_data->created_at; $new_projectgroup->updated_at = $projectgroup->group_data->updated_at; $new_projectgroup->save(); foreach ($projectgroup->user_data as $user_id) { $new_projectgroup->users()->attach($user_id); } } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // Record foreach ($backup_data->records as $record) { try { $new_record = new Record(array("pid" => $record->pid, "fid" => $record->fid, "owner" => $record->owner, "kid" => $record->kid)); $new_record->rid = $record->rid; $new_record->created_at = $record->created_at; $new_record->updated_at = $record->updated_at; $new_record->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // TextField foreach ($backup_data->textfields as $textfield) { try { $new_textfield = new TextField(array("rid" => $textfield->rid, "flid" => $textfield->flid, "text" => $textfield->text)); $new_textfield->id = $textfield->id; $new_textfield->created_at = $textfield->created_at; $new_textfield->updated_at = $textfield->updated_at; $new_textfield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // RichTextField foreach ($backup_data->richtextfields as $richtextfield) { try { $new_richtextfield = new RichTextField(array("rid" => $richtextfield->rid, "flid" => $richtextfield->flid, "rawtext" => $richtextfield->rawtext)); $new_richtextfield->id = $richtextfield->id; $new_richtextfield->created_at = $richtextfield->created_at; $new_richtextfield->updated_at = $richtextfield->updated_at; $new_richtextfield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // NumberField foreach ($backup_data->numberfields as $numberfield) { try { $new_numberfield = new NumberField(array("rid" => $numberfield->rid, "flid" => $numberfield->flid, "number" => $numberfield->number)); $new_numberfield->id = $numberfield->id; $new_numberfield->created_at = $numberfield->created_at; $new_numberfield->updated_at = $numberfield->updated_at; $new_numberfield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // ListField foreach ($backup_data->listfields as $listfield) { try { $new_listfield = new ListField(array("rid" => $listfield->rid, "flid" => $listfield->flid, "option" => $listfield->option)); $new_listfield->id = $listfield->id; $new_listfield->created_at = $listfield->created_at; $new_listfield->updated_at = $listfield->updated_at; $new_listfield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // GeneratedListField foreach ($backup_data->generatedlistfields as $generatedlistfield) { try { $new_generatedlistfield = new GeneratedListField(array("rid" => $generatedlistfield->rid, "flid" => $generatedlistfield->flid, "options" => $generatedlistfield->options)); $new_generatedlistfield->id = $generatedlistfield->id; $new_generatedlistfield->created_at = $generatedlistfield->created_at; $new_generatedlistfield->updated_at = $generatedlistfield->updated_at; $new_generatedlistfield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // MultiSelectListField foreach ($backup_data->multiselectlistfields as $multiselectlistfield) { try { $new_multiselectlistfield = new MultiSelectListField(array("rid" => $multiselectlistfield->rid, "flid" => $multiselectlistfield->flid, "options" => $multiselectlistfield->options)); $new_multiselectlistfield->id = $multiselectlistfield->id; $new_multiselectlistfield->created_at = $multiselectlistfield->created_at; $new_multiselectlistfield->updated_at = $multiselectlistfield->updated_at; $new_multiselectlistfield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // DateField foreach ($backup_data->datefields as $datefield) { try { $new_datefield = new DateField(); $new_datefield->id = $datefield->id; $new_datefield->rid = $datefield->rid; $new_datefield->flid = $datefield->flid; $new_datefield->circa = $datefield->circa; $new_datefield->month = $datefield->month; $new_datefield->day = $datefield->day; $new_datefield->year = $datefield->year; $new_datefield->era = $datefield->era; $new_datefield->created_at = $datefield->created_at; $new_datefield->updated_at = $datefield->updated_at; $new_datefield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // ScheduleField foreach ($backup_data->schedulefields as $schedulefield) { try { $new_schedulefield = new ScheduleField(array("rid" => $schedulefield->rid, "flid" => $schedulefield->flid, "events" => $schedulefield->events)); $new_schedulefield->id = $schedulefield->id; $new_schedulefield->created_at = $schedulefield->created_at; $new_schedulefield->updated_at = $schedulefield->updated_at; $new_schedulefield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // GeolocatorField foreach ($backup_data->geolocatorfields as $geolocatorfield) { try { $new_geolocatorfield = new GeolocatorField(array("rid" => $geolocatorfield->rid, "flid" => $geolocatorfield->flid, "locations" => $geolocatorfield->locations)); $new_geolocatorfield->id = $geolocatorfield->id; $new_geolocatorfield->created_at = $geolocatorfield->created_at; $new_geolocatorfield->updated_at = $new_geolocatorfield->updated_at; $new_geolocatorfield->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // Token foreach ($backup_data->tokens as $token) { try { $new_token = new Token(array('token' => $token->token, 'type' => $token->type)); $new_token->id = $token->id; $new_token->created_at = $token->created_at; $new_token->updated_at = $token->updated_at; $new_token->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // Metadata foreach ($backup_data->metadatas as $metadata) { try { $new_metadata = new Metadata(array()); $new_metadata->flid = $metadata->flid; $new_metadata->pid = $metadata->pid; $new_metadata->fid = $metadata->fid; $new_metadata->name = $metadata->name; $new_metadata->created_at = $metadata->created_at; $new_metadata->updated_at = $metadata->updated_at; $new_metadata->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } // Revision foreach ($backup_data->revisions as $revision) { try { $new_revision = new Revision(array('id' => $revision->id, 'fid' => $revision->fid, 'rid' => $revision->rid, 'userId' => $revision->userId, 'type' => $revision->type, 'data' => $revision->data, 'oldData' => $revision->oldData, 'rollback' => $revision->rollback)); $new_revision->created_at = $revision->created_at; $new_revision->updated_at = $revision->updated_at; $new_revision->save(); } catch (QueryException $e) { $this->ajax_error_list->push($e->getMessage()); } } } catch (\Exception $e) { $this->ajax_error_list->push($e->getMessage()); $this->ajaxResponse(false, "An unknown error prevented the restore from completing.\n You can try restoring from a different backup file or restore point.\n Users will stay locked out until you run a successful restore or manually unlock them above.\n For this error, it's not recommended that you unlock users unless you have resolved the problem"); } if (count($this->ajax_error_list) != 0) { $this->ajaxResponse(false, "Not all of your data was restored, check the errors below for details.\n The errors are in order that they occurred, if you can resolve the first error, it will often correct\n one or more of the errors below it.\n Users will stay locked out until you run a successful restore or manually unlock them above."); } else { $this->unlockUsers(); $this->ajaxResponse(true, "The restore completed successfully."); } }