public function testCreate() { $model = new Module(); $model->crashreport_id = 1; $model->name = 'user32.dll'; $model->file_version = '6.1.0.7600'; $model->sym_load_status = 0; $model->loaded_debug_info_id = null; $saved = $model->save(); $this->assertTrue($saved); $model = Module::model()->find('name="user32.dll"'); $this->assertTrue($model != null); }
public function actionCreate() { $this->actionName = "New Data"; $model = new Module(); if (isset($_POST['Module'])) { $model->setAttributes($_POST['Module']); if ($model->save()) { Yii::app()->user->setFlash('success', "Data saved!"); $this->redirect(array('index')); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Module(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Module'])) { $model->attributes = $_POST['Module']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->name)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($yearId) { $model = new Module(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $model->academic_year = $yearId; if (isset($_POST['Module'])) { $model->attributes = $_POST['Module']; if ($model->save()) { $this->redirect(array('academicYear/view', "id" => $yearId)); } } $this->render('create', array('model' => $model)); }
public static function register($moduleData) { // find module $module = Module::findFirstByUid($moduleData['uid']); // if module not found if (!$module) { // create module $module = new Module(); $module->name = $moduleData['name']; $module->uid = $moduleData['uid']; $module->publicUrl = $moduleData['publicUrl']; $module->adminUrl = $moduleData['adminUrl']; $module->save(); } }
function save($id = FALSE) { if ($_POST) { if (isset($_POST['listperpage'])) { foreach ($_POST['listperpage'] as $key => $item) { if ($item) { $module = new Module(@$_POST['listid'][$key]); $module->from_array(array('listperpage' => $item)); $module->save(); } } set_notify('success', lang('save_data_complete')); } } redirect('listperpages/admin/listperpages'); }
public function add() { if (!$this->securitypolicy->validateAccessRight(6, 'add')) { $this->load->view('access_denied'); } $this->load->library('form_validation'); if ($this->form_validation->run() == false) { $this->load->helper('form'); $this->_viewData['showmsg'] = true; $this->_viewData['status'] = 'error'; $this->load->view('module_add', $this->_viewData); } else { $module = new Module(); $module->setName($this->input->post('module-name')); $module->setUserId(0); $module->setDateCreated(date('Y-m-d H:i:s')); $module->save(); $this->session->set_userdata(array('status' => 'success')); redirect(site_url('Admin/module_view_main')); } }
/** * detect modules * */ protected function detectModules() { $modulePath = Yii::app()->getModulePath(); $modules = array(); $handle = opendir($modulePath); while (($file = readdir($handle)) !== false) { if ($file === '.' || $file === '..' || $file === '.svn') { continue; } $path = $modulePath . DIRECTORY_SEPARATOR . $file; if (is_dir($path)) { $modules[] = basename($path); } } closedir($handle); $configChanged = false; if (count($modules)) { $enabled = Yii::app()->getModules(); foreach ($modules as $name) { if (!Module::model()->count('Name=:name', array(':name' => $name))) { $module = new Module(); $module->Name = $name; $module->Title = ucfirst($name); $module->Enabled = array_key_exists($name, $enabled) ? Module::ENABLED_YES : Module::ENABLED_NO; if ($module->save()) { $configChanged = true; } else { Yii::log('Load Modules error: ' . CVarDumper::dumpAsString($module->getErrors()), CLogger::LEVEL_ERROR, 'application.Cms.controllers.admin.ModulesController'); } } } } //create config file if (Yii::app()->hasComponent('config') && (Yii::app()->getComponent('config')->hasConfigFile('modules') === false || $configChanged)) { $this->initConfigCache(); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Module(); $userLevel = UserLevel::model()->findAll(); $preCheckedArray = array(); if (isset($_POST['privilages'])) { $preCheckedArray = Yii::app()->request->getPost('privilages'); } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Module'])) { $model->attributes = $_POST['Module']; $model->arrPrivilages = Yii::app()->request->getPost('privilages'); if ($model->p_id == 0 || count($model->arrPrivilages)) { $model->hasPrivilage = true; } if ($model->save()) { Yii::app()->user->setFlash('success', 'Module "' . $model->name . '" saved!'); $model = new Module(); $preCheckedArray = array(); } } $this->render('create', array('model' => $model, 'userLevel' => $userLevel, 'preCheckedArray' => $preCheckedArray)); }
/** * Install a module */ public function install($reinstall = false) { $isLoaded = app()->getModule($this->getName()); $moduleName = $this->getName(); $module = Module::model()->find('name=:name', array(':name' => $moduleName)); if (!is_object($module)) { $module = new Module(); $module->name = str_replace('Module', '', get_class($this)); } $metaData = $this->getMetaData(); $module->attributes = $metaData; $module->enabled = true; if (!$isLoaded || $isLoaded && empty($module->id) || $reinstall) { //Module is not loaded if (!$module->save()) { return errorHandler()->getException(); } if (!$this->checkDependencies() || !$this->checkCompatible()) { return errorHandler()->getException(); } if (($step = $this->runInstallScript()) !== true) { $this->runUninstallScript($step); return errorHandler()->getException(); } //activate module return $this->activate(); } else { //Module is loaded and stored in db return true; } }
public function actionModule() { $model = new Module(); // if the post data is set, the user submitted the form if ($model->load(Yii::$app->request->post())) { // in that case, validate the data if ($model->validate()) { // save it to the database $model->save(); return; } } // by default, diplay the form return $this->render('module', ['model' => $model]); }
public function gen() { foreach ($this->module as $key => $value) { $data = new Module(); $data->module = $key; $data->title = $value; $data->save(); } }
/** * @overrride * @see Module::save() */ public function save() { parent::save(); $this->updateSession(); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aModule !== null) { if ($this->aModule->isModified() || $this->aModule->isNew()) { $affectedRows += $this->aModule->save($con); } $this->setModule($this->aModule); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->customerGroupAclsScheduledForDeletion !== null) { if (!$this->customerGroupAclsScheduledForDeletion->isEmpty()) { \CustomerGroupAcl\Model\CustomerGroupAclQuery::create()->filterByPrimaryKeys($this->customerGroupAclsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->customerGroupAclsScheduledForDeletion = null; } } if ($this->collCustomerGroupAcls !== null) { foreach ($this->collCustomerGroupAcls as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->aclI18nsScheduledForDeletion !== null) { if (!$this->aclI18nsScheduledForDeletion->isEmpty()) { \CustomerGroupAcl\Model\AclI18nQuery::create()->filterByPrimaryKeys($this->aclI18nsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->aclI18nsScheduledForDeletion = null; } } if ($this->collAclI18ns !== null) { foreach ($this->collAclI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
</fieldset> <div class="rowSubmitLeft"> <input name="subbuttom" type="image" src="http://www.squidoo.com/images/btn-save.gif" alt="save" class="button" /> <input name="cancelbutton" type="image" src="http://www.squidoo.com/images/btn-cancel.gif" alt="cancel" class="button" onclick="closeEdit('module1', false); return false;"/> </div> </form> <?php exit; break; case 'save': //print "<pre>";print_r($_POST);print "</pre>"; foreach ($_POST['modules']['id'] as $key => $val) { $module->{$key} = $val; } if (!$module->save()) { print $module->file_error; } print $module->show(); exit; break; } } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Build a Module: Squidoo</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="scripts/custom/builder.js"></script> <script type="text/javascript" src="scripts/custom/display.js"></script>
public function saveModule() { $module = new Module(); $module->label = Input::get('label'); $module->module_name = Input::get('module_name'); $module->save(); return Redirect::back()->with('message', 'Module Saved!'); }
public function addNewModule($idCourse, $newModuleName, $lang){ $module = new Module(); $module->course = $idCourse; $order = Module::model()->count("course=$idCourse and `order`>0"); $module->order = ++$order; $module->alias = 'module'.$order; $module->language = $lang; //$teacher = Teacher::model()->find('user_id=:user', array(':user' => Yii::app()->user->getId()))->teacher_id; $module->module_name = $newModuleName; //var_dump($newModuleName);die(); if($module->validate()) { $module->save(); } return $order; }
/** * This method reads crash report information from XML file and * updates appropriate database tables. * @param string $xmlFileName XML file name. * @param integer $crashReportId Crash report ID in database. * @return boolean true on success. */ public function importCrashReportFromXml($xmlFileName, $crashReportId) { $status = false; // Find appropriate {{crashreport}} table record $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'id=' . $crashReportId; $crashReport = CrashReport::model()->find($criteria); if ($crashReport == Null) { Yii::log('Not found crash report id=' . $crashReportId); return $status; } $crashReport->status = CrashReport::STATUS_PROCESSED; // Begin DB transaction $transaction = Yii::app()->db->beginTransaction(); try { // Load XML file $doc = @simplexml_load_file($xmlFileName); if ($doc == Null) { throw new Exception('CrashFix service has encountered an error when retrieving information from crash report file'); } // Get command return status message from XML $elemSummary = $doc->Summary; if ($elemSummary == Null) { throw new Exception('Internal error: not found Summary element in XML document ' . $xmlFileName); } // Extract crash report info $generatorVersion = (int) $elemSummary->GeneratorVersion; $crashGuid = (string) $elemSummary->CrashGUID; $appName = (string) $elemSummary->ApplicationName; $appVersion = (string) $elemSummary->ApplicationVersion; $exeImage = (string) $elemSummary->ExecutableImage; $dateCreated = (string) $elemSummary->DateCreatedUTC; $osNameReg = (string) $elemSummary->OSNameReg; $osVersionMinidump = (string) $elemSummary->OSVersionMinidump; $osIs64Bit = (int) $elemSummary->OSIs64Bit; $geoLocation = (string) $elemSummary->GeographicLocation; $productType = (string) $elemSummary->ProductType; $cpuArchitecture = (string) $elemSummary->CPUArchitecture; $cpuCount = (int) $elemSummary->CPUCount; $guiResourceCount = (int) $elemSummary->GUIResourceCount; $openHandleCount = $elemSummary->OpenHandleCount; $memoryUsageKbytes = $elemSummary->MemoryUsageKbytes; $exceptionType = (string) $elemSummary->ExceptionType; $exceptionAddress = $elemSummary->ExceptionAddress; $sehExceptionCode = $elemSummary->SEHExceptionCode; $exceptionThreadID = $elemSummary->ExceptionThreadID; $exceptionModuleName = (string) $elemSummary->ExceptionModuleName; $exceptionModuleBase = (string) $elemSummary->ExceptionModuleBase; if (strlen($exceptionModuleBase) == 0) { $exceptionModuleBase = 0; } $crashReport->exceptionmodulebase = $exceptionModuleBase; $userEmail = (string) $elemSummary->UserEmail; $problemDescription = (string) $elemSummary->ProblemDescription; // Set crash report fields $crashReport->status = CrashReport::STATUS_PROCESSED; $crashReport->crashrptver = $generatorVersion; $crashReport->crashguid = $crashGuid; $ver = AppVersion::createIfNotExists($appVersion, $crashReport->project_id); $crashReport->appversion_id = $ver->id; if (strlen($userEmail) != 0) { $crashReport->emailfrom = $userEmail; } if (strlen($problemDescription) != 0) { $crashReport->description = $problemDescription; } if (strlen($dateCreated) != 0) { $crashReport->date_created = strtotime($dateCreated); } $crashReport->os_name_reg = $osNameReg; $crashReport->os_ver_mdmp = $osVersionMinidump; $crashReport->os_is_64bit = $osIs64Bit; $crashReport->geo_location = $geoLocation; $crashReport->product_type = $productType; $crashReport->cpu_architecture = $cpuArchitecture; $crashReport->cpu_count = $cpuCount; $crashReport->gui_resource_count = $guiResourceCount; $crashReport->memory_usage_kbytes = $memoryUsageKbytes; $crashReport->open_handle_count = $openHandleCount; $crashReport->exception_type = $exceptionType; if (strlen($sehExceptionCode) != 0) { $crashReport->exception_code = $sehExceptionCode; } if (strlen($exceptionThreadID) != 0) { $crashReport->exception_thread_id = $exceptionThreadID; } if (strlen($exceptionAddress) != 0) { $crashReport->exceptionaddress = $exceptionAddress; } if (strlen($exceptionModuleName) != 0) { $crashReport->exceptionmodule = $exceptionModuleName; } if (strlen($exceptionModuleBase) != 0) { $crashReport->exceptionmodulebase = $exceptionModuleBase; } $crashReport->exe_image = $exeImage; // Validate crash report fields if (!$crashReport->validate()) { // There are some errors $errors = $crashReport->getErrors(); foreach ($errors as $fieldName => $fieldErrors) { foreach ($fieldErrors as $errorMsg) { // Add an error message to log Yii::log('Error in crashreport data (' . $crashReport->{$fieldName} . '): ' . $errorMsg, 'error'); // Associate a processing error with crash report record $this->addProcessingError(ProcessingError::TYPE_CRASH_REPORT_ERROR, $crashReport->id, $errorMsg . ' (' . $crashReport->{$fieldName} . ')'); // Clear field - this should fix the error unset($crashReport->{$fieldName}); } } // Clear validation errors $crashReport->clearErrors(); } // Extract file items $elemFileList = $doc->FileList; if ($elemFileList != Null) { $i = 0; foreach ($elemFileList->Row as $elemRow) { $i++; if ($i == 1) { continue; } // Skip header row $itemNo = $elemRow->Cell[0]['val']; $itemName = $elemRow->Cell[1]['val']; $itemDesc = $elemRow->Cell[2]['val']; $fileItem = new FileItem(); $fileItem->filename = $itemName; $fileItem->description = $itemDesc; $fileItem->crashreport_id = $crashReportId; if (!$fileItem->save()) { throw new Exception('Could not save file item record'); } } } // Extract custom props $elemAppDefinedProps = $doc->ApplicationDefinedProperties; if ($elemAppDefinedProps != Null) { $i = 0; foreach ($elemAppDefinedProps->Row as $elemRow) { $i++; if ($i == 1) { continue; } // Skip header row $itemNo = $elemRow->Cell[0]['val']; $name = $elemRow->Cell[1]['val']; $val = $elemRow->Cell[2]['val']; $customProp = new CustomProp(); $customProp->name = $name; $customProp->value = $val; $customProp->crashreport_id = $crashReportId; if (!$customProp->save()) { throw new Exception('Could not save custom property record'); } } } // Extract the list of modules $elemModuleList = $doc->ModuleList; if ($elemModuleList != Null && $elemModuleList->count() != 0) { $i = 0; foreach ($elemModuleList->Row as $elemRow) { $i++; if ($i == 1) { continue; } // Skip header row $itemNo = $elemRow->Cell[0]['val']; $name = $elemRow->Cell[1]['val']; $symLoadStatus = $elemRow->Cell[2]['val']; $loadedPdbName = $elemRow->Cell[3]['val']; $loadedPdbGUID = $elemRow->Cell[4]['val']; $fileVersion = $elemRow->Cell[5]['val']; $timeStamp = $elemRow->Cell[6]['val']; $guidnAge = $elemRow->Cell[7]['val']; $module = new Module(); $module->crashreport_id = $crashReportId; $module->name = $name; $module->sym_load_status = $symLoadStatus; $module->file_version = $fileVersion; $module->timestamp = $timeStamp; $module->matching_pdb_guid = $guidnAge; $debugInfo = DebugInfo::model()->findByAttributes(array('guid' => $loadedPdbGUID)); if ($debugInfo != null) { $module->loaded_debug_info_id = $debugInfo->id; } if (!$module->save()) { throw new Exception('Could not save module record'); } } } // Extract the list of stack traces foreach ($doc->StackTrace as $elemStackTrace) { $threadId = $elemStackTrace->ThreadID; $stackTraceMD5 = $elemStackTrace->StackTraceMD5; $thread = new Thread(); $thread->thread_id = $threadId; $thread->crashreport_id = $crashReportId; if (strlen($stackTraceMD5) != 0) { $thread->stack_trace_md5 = $stackTraceMD5; } if (!$thread->save()) { throw new Exception('Could not save thread record'); } $i = 0; foreach ($elemStackTrace->Row as $elemRow) { $i++; if ($i == 1) { continue; } // Skip header row $title = $elemRow->Cell[0]['val']; $addrPC = $elemRow->Cell[1]['val']; $moduleName = $elemRow->Cell[2]['val']; $offsInModule = $elemRow->Cell[3]['val']; $symName = $elemRow->Cell[4]['val']; $undSymName = $elemRow->Cell[5]['val']; $offsInSym = $elemRow->Cell[6]['val']; $srcFile = $elemRow->Cell[7]['val']; $srcLine = $elemRow->Cell[8]['val']; $offsInLine = $elemRow->Cell[9]['val']; $stackFrame = new StackFrame(); $stackFrame->thread_id = $thread->id; $stackFrame->addr_pc = $addrPC; if (strlen($moduleName) != 0) { $module = Module::model()->findByAttributes(array('name' => $moduleName, 'crashreport_id' => $crashReportId)); if ($module != null) { $stackFrame->module_id = $module->id; } $stackFrame->offs_in_module = $offsInModule; } if (strlen($symName) != 0) { $stackFrame->symbol_name = $symName; } if (strlen($undSymName) != 0) { $stackFrame->und_symbol_name = $undSymName; } if (strlen($offsInSym) != 0) { $stackFrame->offs_in_symbol = $offsInSym; } if (strlen($srcFile) != 0) { $stackFrame->src_file_name = $srcFile; } if (strlen($srcLine) != 0) { $stackFrame->src_line = $srcLine; } if (strlen($offsInLine) != 0) { $stackFrame->offs_in_line = $offsInLine; } if (!$stackFrame->save()) { throw new Exception('Could not save stack frame record'); } } } // Commit transaction $transaction->commit(); // Success. $status = true; } catch (Exception $e) { // Rollback transaction $transaction->rollback(); // Add a message to log Yii::log($e->getMessage(), 'error'); $crashReport->status = CrashReport::STATUS_INVALID; // Associate a processing error with crash report record $this->addProcessingError(ProcessingError::TYPE_CRASH_REPORT_ERROR, $crashReport->id, $e->getMessage()); $status = false; } // Update crash group based on new data $crashGroup = $crashReport->createCrashGroup(); if ($crashGroup == Null) { Yii::log('Error creating crash group', 'error'); $status = false; } $crashReport->groupid = $crashGroup->id; // Update crash report $saved = $crashReport->save(); if (!$saved) { Yii::log('Error saving AR crashReport', 'error'); $status = false; } if (!$saved || !$crashReport->checkQuota()) { Yii::log('Error checking crash report quota', 'error'); $status = false; // Delete crash report $crashReport = $crashReport = CrashReport::model()->find('id=' . $crashReport->id); $crashReport->delete(); } // Return status return $status; }
public function save($data) { $module = new Module($data); $module->save(); return true; }
public function disableAction($name) { if (empty($name)) { return 'Модуль не найден'; } $module = new Module($name); $module->setActive(0); $module->save(); }