public function testRequirementSuccess() { $requirement = new Requirement(); $requirement->protocol_id = 1; $requirement->family = "user"; $requirement->parameter_id = 1; $this->assertTrue($requirement->save()); }
function get_error_message(Requirement $requirement, $lineSize) { if ($requirement->isFulfilled()) { return; } $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL . ' ') . PHP_EOL; $errorMessage .= ' > ' . wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL . ' > ') . PHP_EOL; return $errorMessage; }
function req_row(Requirement $req, $indentation, TableCreator $table_creator) { $req->with('validationTest', 'requirements'); $ret = ""; $ret .= $table_creator->row(array($table_creator->child_indentation($indentation), $req->public_id(), $req->validationTest == null ? '' : $req->validationTest->public_id())); $nested = $req->requirements; foreach ($nested as $c) { $ret .= req_row($c, $indentation + 1, $table_creator); } return $ret; }
function test_row(Requirement $req, $indentation, TableCreator $table_creator, $filter_cat, $filter_pri) { $test = $req->with('system_test')->system_test; $ret = ""; if (isset($req->system_test) && (!is_numeric($filter_cat) || $req->category == $filter_cat) && (!is_numeric($filter_pri) || $req->priority == $filter_pri)) { $test->with('test'); $ret .= $table_creator->row(array($test->public_id(), $test->test->description, 'success', $table_creator->anchor($req->public_id(), $req->public_id()))); } $nested = $req->with('requirements')->requirements; foreach ($nested as $nreq) { $ret .= test_row($nreq, $indentation + 1, $table_creator, $filter_cat, $filter_pri); } return $ret; }
/** * Constructor that initializes the requirement. * * @param bool $fulfilled Whether the requirement is fulfilled * @param string $testMessage The message for testing the requirement * @param string $helpHtml The help text formatted in HTML for resolving the problem * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement * @param array<boolean> $types Three booleans (informative, dependant, fromApp) */ public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false, $types = [self::INFORMATIVE, self::DEPENDANT, self::FROM_APP]) { parent::__construct($fulfilled, $testMessage, $helpHtml, $helpText, $optional); $this->informative = (bool) $types[0]; $this->dependant = (bool) $types[1]; $this->fromApp = (bool) $types[2]; }
function test_row(Requirement $req, $indentation, TableCreator $table_creator, $filter_cat, $filter_pri) { $test = $req->with('system_test')->system_test; $validation = $req->with('validation0')->validation0; $ret = ""; $rv = ''; if (isset($test)) { $rv = $test->public_id(); } else { if (isset($validation)) { $rv = $validation->name; } } $ret .= $table_creator->row(array($table_creator->child_indentation($indentation), $req->public_id(), $rv)); $nested = $req->with('requirements')->requirements; foreach ($nested as $nreq) { $ret .= test_row($nreq, $indentation + 1, $table_creator, $filter_cat, $filter_pri); } return $ret; }
/** * Prints a Requirement instance */ private function echo_requirement(\Requirement $requirement) { $result = $requirement->isFulfilled() ? 'OK' : ($requirement->isOptional() ? 'WARNING' : 'ERROR'); $data = ''; switch (rtrim(ltrim(str_pad($result, 9)))) { case 'OK': $data .= '<tr class="success">'; break; case 'WARNING': $data .= '<tr class="warning">'; break; case 'ERROR': $data .= '<tr class="danger">'; break; default: $data .= '<tr>'; break; } $data .= '<td>' . str_pad($result, 9) . '</td>'; $data .= '<td>' . $requirement->getTestMessage() . "</td>"; if (!$requirement->isFulfilled()) { $data .= '<td>' . $requirement->getHelpText() . '</td>'; } $data .= '</tr>'; return $data; }
public function alter() { if (!isset($_SESSION['logged'])) { return call('pages', 'home'); } else { if (!isset($_GET['code'])) { return call('pages', 'error', 2); } $sources = Sources::all(); $requirement = Requirement::get($_GET['code']); require_once 'views/requirements/alter.php'; } }
/** * Prints a Requirement instance */ function echo_requirement(Requirement $requirement) { $result = $requirement->isFulfilled() ? 'OK' : ($requirement->isOptional() ? 'WARNING' : 'ERROR'); echo ' ' . str_pad($result, 9); echo $requirement->getTestMessage() . "\n"; if (!$requirement->isFulfilled()) { echo sprintf(" %s\n\n", $requirement->getHelpText()); } }
public function save() { // yo thau ma requirement save huna aaucha // yei bata feri "index.php" ma falne jun chai profile ma jancha $req = new Requirement(); if (isset($_POST['title'])) { $req->setTitle($_POST['title']); } else { $req->setTitle(""); } if (isset($_POST['date'])) { $req->setDate($_POST['date']); } else { $req->setDate("01-01-2001"); } if (isset($_POST['details'])) { $req->setDescription($_POST['details']); } else { $req->setDescription(""); } $req->setStatus(1); $req->setOrgname(""); $this->requirement_repository->insert($req); }
public function download_tex() { if (!isset($_SESSION['logged'])) { $this->login(); } else { $rs = Requirement::reqSources(); $sr = Requirement::sourcesReq(); $frq = Requirement::functionalRequirements(); $tex = "\\section{Requisiti funzionali}<br>\n \\begin{longtable}[H]{|l|p{2cm}|p{6cm}|p{4cm}|}<br>\n \\hline<br>\n \\textbf{Requisito} & \\textbf{Tipologia} & \\textbf{Descrizione} & \\textbf{Fonti}\\\\<br>\n \\hline<br>"; foreach ($frq as $funcReq) { if ($funcReq->getType() == 'F') { $type = 'Funzionale'; } elseif ($funcReq->getType() == 'T') { $type = 'Tecnologico'; } elseif ($funcReq->getType() == 'Q') { $type = 'Qualitativo'; } elseif ($funcReq->getType() == 'B') { $type = 'Vincolo'; } $tex .= $funcReq->getCode() . " & \\multiLineCell{" . $type . "\\\\" . $funcReq->getPriority() . "} & " . $funcReq->getDescription() . " & \\multiLineCell{"; foreach ($funcReq->getSources() as $sources) { $tex .= $sources->getName() . "\\\\"; } $tex .= "}\\\\<br>\n \\hline<br>"; } $tex .= "\\end{longtable}<br>"; $tex .= "\\section{Tracciamento Requisiti-Fonti}<br>\n \\begin{longtable}[H]{|p{5.5cm}|p{5.5cm}|}<br>\n \\hline<br>\n \\textbf{Requisito} & \\textbf{Fonti}\\\\<br>\n \\hline<br>"; foreach ($rs as $key => $val) { $tex .= $key . " & \\multiLineCell[t]{"; foreach ($val as $v) { $tex .= $v . "\\\\"; } $tex .= "}\\\\<br>\n \\hline<br>"; } $tex .= "\\end{longtable}<br>\n \\section{Tracciamento Fonti-Requisiti}<br>\n \\begin{longtable}[H]{|p{5.5cm}|p{5.5cm}|}<br>\n \\hline<br>\n \\textbf{Fonte} & \\textbf{Requisiti}\\\\<br>\n \\hline<br>"; foreach ($sr as $key => $val) { $tex .= $key . " & \\multiLineCell[t]{"; foreach ($val as $v) { $tex .= $v . "\\\\"; } $tex .= "}\\\\<br>\n \\hline<br>"; } $tex .= "\\end{longtable}<br>"; require_once 'views/pages/output.php'; } }
function requirement_row($req, $indentation, TableCreator $table_creator, $filter_cat, $filter_pri) { $ret = ""; if ((!is_numeric($filter_cat) || $req->category == $filter_cat) && (!is_numeric($filter_pri) || $req->priority == $filter_pri)) { $pkg_name = array(); foreach ($req->classes as $c) { array_push($pkg_name, $table_creator->link($c->full_name(), $c->name)); } array_unique($pkg_name); sort($pkg_name); $cells = array($table_creator->child_indentation($indentation), $table_creator->link($req->public_id(), $req->public_id()), implode("\n\n", $pkg_name)); $ret .= $table_creator->row($cells); } $nested = Requirement::model()->with('classes')->findAll("t.parent=:parent", array(':parent' => $req->id_requirement)); foreach ($nested as $nreq) { $ret .= requirement_row($nreq, $indentation + 1, $table_creator, $filter_cat, $filter_pri); } return $ret; }
/** * Constructor that initializes the requirement. * * @param string $cfgName The configuration name used for ini_get() * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. Example: You require a config to be true but PHP later removes this config and defaults it to true internally. * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement */ public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) { $cfgValue = ini_get($cfgName); if (is_callable($evaluation)) { if (null === $testMessage || null === $helpHtml) { throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); } $fulfilled = call_user_func($evaluation, $cfgValue); } else { if (null === $testMessage) { $testMessage = sprintf('%s %s be %s in php.ini', $cfgName, $optional ? 'should' : 'must', $evaluation ? 'enabled' : 'disabled'); } if (null === $helpHtml) { $helpHtml = sprintf('Set <strong>%s</strong> to <strong>%s</strong> in php.ini<a href="#phpini">*</a>.', $cfgName, $evaluation ? 'on' : 'off'); } $fulfilled = $evaluation == $cfgValue; } parent::__construct($fulfilled || $approveCfgAbsence && false === $cfgValue, $testMessage, $helpHtml, $helpText, $optional); }
public function actionRequirementHandle() { if (parent::_ajax_acl('evaluate_update')) { $id = Yii::app()->request->getPost('id'); $requirement = Requirement::model()->findByPk($id); if (!empty($requirement)) { $requirement->status = 1; if ($requirement->save()) { AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新学区专栏房源需求处理状态,ID:' . $requirement->id)); echo CJSON::encode(array('success' => true, 'msg' => '需求处理成功')); } else { echo CJSON::encode(array('success' => false, 'msg' => '操作失败,请联系管理员')); } } else { echo CJSON::encode(array('success' => false, 'msg' => '此需求不存在')); } } else { echo CJSON::encode(array('success' => false, 'msg' => '当前角色组无权限进行此操作,请联系管理员授权')); } }
function requirement_row($req, $indentation, TableCreator $table_creator, $filter_cat, $filter_pri) { $ret = ""; if ((!is_numeric($filter_cat) || $req->category == $filter_cat) && (!is_numeric($filter_pri) || $req->priority == $filter_pri)) { $source_desc = array(); foreach ($req->sources as $rc) { $rc->with('useCase', 'externalSource'); if (isset($rc->useCase)) { array_push($source_desc, $table_creator->link($rc->useCase->public_id(), $rc->useCase->public_id())); } else { array_push($source_desc, $rc->externalSource->description); } } sort($source_desc); $cells = array($table_creator->child_indentation($indentation), $table_creator->anchor($req->public_id(), $req->public_id()), $req->category0->name . "\n\n" . $req->priority0->name, $req->description, implode("\n\n", $source_desc)); $ret .= $table_creator->row($cells); } $nested = Requirement::model()->with('sources', 'category0', 'priority0')->findAll("t.parent=:parent", array(':parent' => $req->id_requirement)); foreach ($nested as $nreq) { $ret .= requirement_row($nreq, $indentation + 1, $table_creator, $filter_cat, $filter_pri); } return $ret; }
/** * @return WebRootExposedFolderRequirement */ public function __construct() { parent::__construct(Craft::t('Sensitive Craft folders should not be publicly accessible'), null, false, '<a href="http://craftcms.com">Craft CMS</a>'); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Requirement::model()->findByPk($id); $model->with('category0', 'priority0', 'parent0', 'sources', 'validation0', 'system_test'); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php /// @warning HARD CODED DB PK!!!!!!!!!!! $reqs = Requirement::model()->findAll("category != 4 and priority != 4"); $table = $table_creator->begin_table("|m{3cm}|m{6cm}|m{4cm}|") . $table_creator->heading_row(array("Id", "Descrizione", "Implementazione")); foreach ($reqs as $r) { $id = $r->public_id(); $app = $r->apported; $strapp = ""; if ($app) { $strapp = "\\color{dkgreen}{Implementato}"; } else { $strapp = "\\color{dkred}{Non implementato}"; } $table .= $table_creator->row(array($id, $r->description, $strapp)); } $table .= $table_creator->caption("Tabella implementazione requisiti opzionali e desiderabili") . $table_creator->end_table(); if ($table_creator->id() != 'html' && !$raw) { echo CodeGen::generic_render_code($table, 'latex', true); } else { echo $table; }
public function actionRequirement() { $cs = Yii::app()->getClientScript(); $cs->registerCssFile(Yii::app()->baseUrl . '/css/requirement.css', 'screen'); $model = new Requirement(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='requirement-requirement-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ if (isset($_POST['Requirement'])) { $model->attributes = $_POST['Requirement']; if ($model->validate()) { // form inputs are valid, do something here return; } } $this->render('requirement', array('model' => $model)); }
public function actionAjaxRequirementCreate() { $city_id = Yii::app()->request->getPost('city_id'); $district_id = Yii::app()->request->getPost('district_id'); $investType_id = Yii::app()->request->getPost('investType_id'); $propertyType_id = Yii::app()->request->getPost('propertyType_id'); $total_price = Yii::app()->request->getPost('total_price'); $house_area = Yii::app()->request->getPost('house_area'); $land_area = Yii::app()->request->getPost('land_area'); $bedroom_num = Yii::app()->request->getPost('bedroom_num'); $construction_year = Yii::app()->request->getPost('construction_year'); if (!empty($this->_account['userId'])) { $user = User::model()->findByPk($this->_account['userId']); $model = new Requirement(); $model->city_id = $city_id; $model->district_id = $district_id; $model->investType_id = $investType_id; $model->propertyType_id = $propertyType_id; $model->total_price = $total_price; $model->house_area = $house_area; $model->land_area = $land_area; $model->bedroom_num = $bedroom_num; $model->construction_year = $construction_year; $model->phone = $user->phone; $model->email = $user->email; if ($model->save()) { $url = Yii::app()->createUrl('column/success'); echo CJSON::encode(array('status' => 'success', 'url' => $url, 'msg' => '提交成功')); } else { echo CJSON::encode(array('status' => 'failed', 'url' => '', 'msg' => '提交失败,请稍候重试')); } } else { echo CJSON::encode(array('status' => 'failed', 'url' => '', 'msg' => '您还未登录,请先登录')); } }
public function actionPost() { Yii::beginProfile('requirement_post'); $userId = Yii::app()->user->id; $model = new Requirement(); $modelState = new GeoState(); $requirementCities = new RequirementCities(); $requirementAmenities = new RequirementAmenities(); $requirementPropertyTypes = new RequirementPropertyTypes(); $requirementBedrooms = new RequirementBedrooms(); $amenities = null; $propertyTypes = null; $bedrooms = null; $cities = null; $this->performAjaxValidation(array($model)); if (isset($_POST['minsubmit'])) { $modelState->attributes = $_POST['GeoState']; } elseif (isset($_POST['PostRequirementMin'])) { $model->attributes = $_POST['Requirement']; if (isset($_POST['GeoCity']['city'])) { $cities[0] = $_POST['GeoCity']['city']; } } elseif (isset($_POST['submit'])) { $model->attributes = $_POST['Requirement']; $amenities = isset($_POST['amenity_id']) ? $_POST['amenity_id'] : null; $propertyTypes = isset($_POST['property_type_id']) ? $_POST['property_type_id'] : null; $bedrooms = isset($_POST['bedrooms']) ? $_POST['bedrooms'] : null; $cities = isset($_POST['city_id']) ? $_POST['city_id'] : null; $valid = true; $model->user_id = $userId; $valid = $valid && $model->validate(); if ($propertyTypes == null) { $requirementPropertyTypes->addError('property_type_id', 'Property Type cannot be blank.'); $valid = false; } if ($cities == null || empty($cities) || $cities[0] == '') { $requirementCities->addError('city_id', 'City cannot be blank.'); $valid = false; } if ($valid) { $data = $_POST['Requirement']; if ($data['covered_area_from'] == null) { $data['covered_area_from'] == 0; } if ($data['min_price'] == null) { $data['min_price'] = 0; } $requirement = RequirementApi::createRequirement($userId, $data); if (!$requirement->hasErrors()) { $addAmenities = true; $addCities = true; $addBedrooms = true; $addPropertyTypes = true; if (isset($_POST['amenity_id'])) { $addAmenities = RequirementAmenitiesApi::addAmenitiesForRequirement($requirement->id, $_POST['amenity_id']); } if (isset($_POST['city_id'])) { $addCities = RequirementCitiesApi::addCitiesForRequirement($requirement->id, $_POST['city_id']); } if (isset($_POST['bedrooms']) && !empty($_POST['bedrooms'])) { $addBedrooms = RequirementBedroomsApi::addBedroomForRequirement($requirement->id, $_POST['bedrooms']); } if (isset($_POST['property_type_id'])) { $addPropertyTypes = RequirementPropertyTypesApi::addPropertyTypesForRequirement($requirement->id, $_POST['property_type_id']); } if ($addAmenities && $addCities && $addBedrooms && $addPropertyTypes) { //$this->refresh(); $this->redirect('/requirement/' . $requirement->id); } else { RequirementAmenitiesApi::deleteAllAmenitiesForRequirement($requirement->id); RequirementCitiesApi::deleteAllCitiesForRequirement($requirement->id); RequirementBedroomsApi::deleteAllBedroomsForRequirement($requirement->id); RequirementPropertyTypesApi::deleteAllPropertyTypesForRequirement($requirement->id); } } else { if (isset($property->id)) { PropertyApi::deletePropertyById($property->id); } } } } $this->render('post', array('model' => $model, 'modelState' => $modelState, 'requirementCities' => $requirementCities, 'requirementAmenities' => $requirementAmenities, 'requirementPropertyTypes' => $requirementPropertyTypes, 'requirementBedrooms' => $requirementBedrooms, 'amenities' => $amenities, 'propertyTypes' => $propertyTypes, 'bedrooms' => $bedrooms, 'cities' => $cities)); Yii::endProfile('requirement_post'); }
/** * @return WebRootExposedFolderRequirement */ public function __construct() { parent::__construct(Craft::t('Craft folders in public web root'), null, false, '<a href="http://craftcms.com">Craft CMS</a>'); }
/** * @return PhpVersionRequirement */ public function __construct() { parent::__construct(Craft::t('PHP Version'), null, true, '<a href="http://buildwithcraft.com">Craft</a>'); }
/** * This method gets userId and array of data from user. * Returns model if update successful * Returns null if creation fails ** Data arrary should have the following Hash keys * string $i_want_to * string $description * double $covered_area_from * double $covered_area_to * double $plot_area_from * double $plot_area_to * double $min_price * double $max_price * * @param int $userId,array $data * @return model|false */ public static function updateRequirement($userId, $data) { $specialist = Requirement::model()->find('user_id=:userId', array(':userId' => $userId)); if ($specialist) { $specialist->attributes = $data; $specialist->save(); return $specialist; } else { return false; } }
/** * @return IconvRequirement */ public function __construct() { parent::__construct(Craft::t('iconv support'), null, false, '<a href="http://craftcms.com">Craft CMS</a>'); }
/** * @param Requirement $requirement * @param $data * @throws \Exception */ private function checkRequirementData(Requirement $requirement, $data) { if ($data === null && $requirement->isRequired()) { $requirement->fail(); throw new \Exception('Requirement "' . $requirement->getKey() . '" is required but could not be resolved'); } }
<?php $cats = RequirementCategory::model()->findAll(); $pris = RequirementPriority::model()->findAll(); $titles = array("Categoria"); foreach ($pris as $p) { array_push($titles, $p->name); } $table = $table_creator->begin_table(count($pris) + 1) . $table_creator->heading_row($titles); foreach ($cats as $c) { $row = array($c->name); foreach ($pris as $p) { array_push($row, Requirement::model()->count("priority=:p and category=:c", array("p" => $p->id_priority, "c" => $c->id_category))); } $table .= $table_creator->row($row); } $table .= $table_creator->caption("Riepilogo requisiti") . $table_creator->end_table(); if ($table_creator->id() != 'html' && !$raw) { echo CodeGen::generic_render_code($table, 'latex', true); } else { echo $table; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Requirement::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * @return PhpVersionRequirement */ public function __construct() { parent::__construct(Craft::t('iconv support'), null, false, '<a href="http://buildwithcraft.com">Craft</a>'); }
public function get_by_id($requirement_id) { $this->database->connect(); $sql = "SELECT * FROM welfrequirement WHERE welfreq_id=?"; //prepare the statement $statement = $this->database->initialize($sql); //Bind the parameters $statement->bind_param("i", $requirement_id); //Execute the above statement $statement->execute(); //Bind the result $statement->bind_result($welfreq_id, $title, $description, $end_date, $status, $org_name, $welf_id); $req = NULL; while ($statement->fetch()) { $req = new Requirement(); $req->setRequirementId($welfreq_id); $req->setTitle($title); $req->setDescription($description); $req->setDate($end_date); $req->setStatus($status); $req->setOrgname($org_name); $req->setWelfId($welf_id); } //Close Connection $this->database->close(); return $req; }