public function __equal(Status $_status) { if ($this->id == $_status->getId() && strcmp($this->name, $_status->getName()) == 0 && strcmp($this->number, $_status->getNumber()) == 0) { return TRUE; } return FALSE; }
/** * @param WikiPage $article * @param $user * @param $text * @param $summary * @param $minoredit * @param $watchthis * @param $sectionanchor * @param $flags * @param $revision * @param Status $status * @param $baseRevId * @return bool */ function efSharedHelpArticleCreation(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId) { global $wgCityId, $wgHelpWikiId; // only run on help wikis if ($wgCityId !== $wgHelpWikiId) { return true; } // not likely if we got here, but... healthy paranoia ;) if (wfReadOnly()) { return true; } if ($article->mTitle->getNamespace() !== NS_HELP) { return true; } if (!$status->isOK()) { return true; } if (!($flags & EDIT_NEW)) { return true; } $talkTitle = Title::newFromText($article->mTitle->getText(), NS_HELP_TALK); if ($talkTitle->exists()) { return true; } $talkArticle = new Article($talkTitle); $redir = $article->getRedirectTarget(); if ($redir) { $target = $redir->getTalkNsText() . ':' . $redir->getText(); $talkArticle->doEdit("#REDIRECT [[{$target}]]", wfMsgForContent('sharedhelp-autotalkcreate-summary')); } else { $talkArticle->doEdit('{{talkheader}}', wfMsgForContent('sharedhelp-autotalkcreate-summary')); } return true; }
/** * Callable used to order Status. * * @param Status $s1 * @param Status $s2 * * @return int */ private function statusComparator($s1, $s2) { if (array_search($s1->getCode(), $this->statusOrder) === array_search($s2->getCode(), $this->statusOrder)) { return 0; } return array_search($s1->getCode(), $this->statusOrder) < array_search($s2->getCode(), $this->statusOrder) ? -1 : 1; }
/** * Hook function for EditFilterMergedContent * * @param IContextSource $context * @param Content $content * @param Status $status * @param string $summary * @param User $user * @param bool $minoredit * * @return bool */ static function filterMergedContent(IContextSource $context, Content $content, Status $status, $summary, User $user, $minoredit) { $title = $context->getTitle(); if (isset($title->spamBlackListFiltered) && $title->spamBlackListFiltered) { // already filtered return true; } // get the link from the not-yet-saved page content. // no need to generate html to get external links $pout = $content->getParserOutput($title, null, null, false); $links = array_keys($pout->getExternalLinks()); // HACK: treat the edit summary as a link if ($summary !== '') { $links[] = $summary; } $spamObj = BaseBlacklist::getInstance('spam'); $matches = $spamObj->filter($links, $title); if ($matches !== false) { $status->fatal('spamprotectiontext'); foreach ($matches as $match) { $status->fatal('spamprotectionmatch', $match); } } // Always return true, EditPage will look at $status->isOk(). return true; }
function do_post_testphp_example_v1($job, $resp) { $status = new Status($resp->status()); $status->add_message("this is a status message!"); throw new ERR_INTERNAL_SERVER_ERROR("uh oh"); return Worker::WORKER_SUCCESS; }
protected function insertComments(User $aUser) { $status = new Status(); $status->insert(array("user_id" => $aUser->id, "comment" => "comment1", "created_at" => "2008-01-01 00:00:00")); $status->insert(array("user_id" => $aUser->id, "comment" => "comment2", "created_at" => "2008-02-01 00:00:00")); $status->insert(array("user_id" => $aUser->id, "comment" => "comment3", "created_at" => "2008-03-01 00:00:00")); }
/** * @internal * * @param \SimpleXMLElement $xml * * @return Status */ public static function fromXml(\SimpleXMLElement $xml) { $status = new Status(); $status->setIsResponse(); $status->setCode($xml->Code)->setDescription($xml->Description); return $status; }
public function indexAction() { $status = new Status(); $status->setUid($this->_user->loggedIn->uid); $status->addStatus("test"); $this->_logger->log($status->getStatusMessages(), Zend_Log::INFO); }
public function deserialize(&$data) { parent::deserialize($data); $this->stringToBytes($this->username); $hash = new Status(); $hash->deserialize($data); $this->status = $hash; }
/** * @param integer|Status $status */ public function __construct($status) { if ($status instanceof self) { $this->status = $status->getValue(); } else { $this->status = (int) $status; } }
function test_it_gets_current_status_data() { $locater = $this->getMockBuilder('\\Bdsm\\Locater\\Locater')->getMock(); $locater->method('findMigrations')->willReturn(array(new DoneMigration1(), new DoneMigration2(), new NewMigration(), new SkippedMigration())); $log = $this->getMockBuilder('\\Bdsm\\Log\\Log')->getMock(); $log->method('get')->willReturn(array('Bdsm\\Query\\DoneMigration1' => 'done', 'Bdsm\\Query\\DoneMigration2' => 'done', 'Bdsm\\Query\\SkippedMigration' => 'skipped')); $query = new Status($locater, $log); $this->assertEquals(array('Bdsm\\Query\\DoneMigration1' => 'done', 'Bdsm\\Query\\DoneMigration2' => 'done', 'Bdsm\\Query\\NewMigration' => 'new', 'Bdsm\\Query\\SkippedMigration' => 'skipped'), $query->getResult()); }
/** * @param Status $status * @return bool */ public function equals(Status $status) { if ($this == $status) { return true; } if ($this->status == $status->getValue()) { return true; } return false; }
/** * @userCache * * @param int $userId ユーザID * @param int $statusId ステータスID * * @return Logics_Result */ public function remove($userId, $statusId) { $result = new Logics_Result(); $aStatus = new Status($statusId); if ($aStatus->isSelected() && $aStatus->user_id === $userId) { $aStatus->delete(); } else { $result->failure(); } return $result; }
public function logoutAction() { if (isset($this->_user->loggedIn->uid)) { $status = new Status(); $status->setUid($this->_user->loggedIn->uid); $status->addStatus('logout'); } $this->_user->logout(); $this->view->loginMsg = self::LOGOUT; $this->_forward('login'); }
/** * @param $wikiPage * @param \User $user * @param $content * @param $summary * @param $isMinor * @param $isWatch * @param $section * @param $flags * @param \Status $status * * @return bool */ public function onPageContentSave($wikiPage, $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $status) { if ($user && !$user->isEmailConfirmed()) { if (!$this->testResponse()) { $status->setResult(false); $status->error("recaptcha-failed"); return false; } } return true; }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('cs_status')->delete(); $status = array("Open", "In Progress", "Close", "Cancel"); foreach ($status as $stt) { $status = new Status(); $status->name = $stt; $status->description = "Lorem Ipsum has been the dummy text ever since the 1500s"; $status->save(); } }
public function carrega() { $this->conectar(); $queries[] = "SELECT * FROM status;"; $resultado = $this->query($queries); $this->desconectar(); foreach ($resultado as $result) { $status = new Status(); $status->setId($result["id"]); $status->setNome($result["status"]); $status->setCor($result["cor"]); $this->addStatus($status); } }
/** * @param string $step * @param Status $status */ public function endStage($step, $status) { if ($step == 'extension-tables') { $this->endLiveBox(); } $msg = $status->isOk() ? 'config-install-step-done' : 'config-install-step-failed'; $html = wfMessage('word-separator')->escaped() . wfMessage($msg)->escaped(); if (!$status->isOk()) { $html = "<span class=\"error\">{$html}</span>"; } $this->addHTML($html . "</li>\n"); if (!$status->isGood()) { $this->parent->showStatusBox($status); } }
/** * Get error message key and parameters from status * * @param \Status $status * @return array of error message key, and message parameters as an array * @throws Exception if called on an "OK" Status */ public function getStatusError(\Status $status) { if ($status->isOK()) { throw new \Exception('Status contains no errors'); } $errors = $status->getErrorsByType('error'); if (!empty($errors[0]['message'])) { $message = $errors[0]['message']; $params = $errors[0]['params']; } else { $message = 'fbconnect-error'; $params = []; } return [$message, $params]; }
/** * MovePageCheckPermissions hook (1.25+) * * @param Title $oldTitle * @param Title $newTitle * @param User $user * @param $reason * @param Status $status * @return bool */ public static function onMovePageCheckPermissions(Title $oldTitle, Title $newTitle, User $user, $reason, Status $status) { $titleBlacklist = TitleBlacklist::singleton(); $blacklisted = $titleBlacklist->userCannot($newTitle, $user, 'move'); if (!$blacklisted) { $blacklisted = $titleBlacklist->userCannot($oldTitle, $user, 'edit'); } if ($blacklisted instanceof TitleBlacklistEntry) { $errmsg = $blacklisted->getErrorMessage('move'); ApiBase::$messageMap[$errmsg] = array('code' => $errmsg, 'info' => 'TitleBlacklist prevents this new title from being created or old title from being edited'); $status->fatal($errmsg, $blacklisted->getRaw(), $oldTitle->getFullText(), $newTitle->getFullText()); return false; } return true; }
public function getJSONObject() { $o = parent::getJSONObject(); $o->mpID = $this->getMarketplaceItemID(); $o->mpHandle = $this->getMarketplaceItemHandle(); return $o; }
/** * Update the `is_closed` property. */ public function updateIsClosed() { $this->isClosing = false; $this->isReopening = false; // Don't do anything unless the status has changed if ($this->originalStatusId != $this['status_id']) { $status = Status::find($this['status_id']); // Did the status change to open/started or closed? if ($status->status >= 1) { // Reopen ticket if ($this['is_closed']) { $this->isClosing = false; $this->isReopening = true; } $this['is_closed'] = false; $this->isClosing = false; } elseif ($status->status == 0) { // Close ticket if (!$this['is_closed']) { $this->isClosing = true; } $this['is_closed'] = true; } } }
/** * @covers ApiErrorFormatter_BackCompat */ public function testErrorFormatterBC() { $mainpagePlain = wfMessage('mainpage')->useDatabase(false)->plain(); $parensPlain = wfMessage('parentheses', 'foobar')->useDatabase(false)->plain(); $result = new ApiResult(8388608); $formatter = new ApiErrorFormatter_BackCompat($result); $formatter->addWarning('string', 'mainpage'); $formatter->addError('err', 'mainpage'); $this->assertSame(array('error' => array('code' => 'mainpage', 'info' => $mainpagePlain), 'warnings' => array('string' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Simple test'); $result->reset(); $formatter->addWarning('foo', 'mainpage'); $formatter->addWarning('foo', 'mainpage'); $formatter->addWarning('foo', array('parentheses', 'foobar')); $msg1 = wfMessage('mainpage'); $formatter->addWarning('message', $msg1); $msg2 = new ApiMessage('mainpage', 'overriddenCode', array('overriddenData' => true)); $formatter->addWarning('messageWithData', $msg2); $formatter->addError('errWithData', $msg2); $this->assertSame(array('error' => array('code' => 'overriddenCode', 'info' => $mainpagePlain, 'overriddenData' => true), 'warnings' => array('messageWithData' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings'), 'message' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings'), 'foo' => array('warnings' => "{$mainpagePlain}\n{$parensPlain}", ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Complex test'); $result->reset(); $status = Status::newGood(); $status->warning('mainpage'); $status->warning('parentheses', 'foobar'); $status->warning($msg1); $status->warning($msg2); $status->error('mainpage'); $status->error('parentheses', 'foobar'); $formatter->addMessagesFromStatus('status', $status); $this->assertSame(array('error' => array('code' => 'parentheses', 'info' => $parensPlain), 'warnings' => array('status' => array('warnings' => "{$mainpagePlain}\n{$parensPlain}", ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Status test'); $I = ApiResult::META_INDEXED_TAG_NAME; $this->assertSame(array(array('type' => 'error', 'message' => 'mainpage', 'params' => array($I => 'param')), array('type' => 'error', 'message' => 'parentheses', 'params' => array('foobar', $I => 'param')), $I => 'error'), $formatter->arrayFromStatus($status, 'error'), 'arrayFromStatus test for error'); $this->assertSame(array(array('type' => 'warning', 'message' => 'mainpage', 'params' => array($I => 'param')), array('type' => 'warning', 'message' => 'parentheses', 'params' => array('foobar', $I => 'param')), array('message' => 'mainpage', 'params' => array($I => 'param'), 'type' => 'warning'), array('message' => 'mainpage', 'params' => array($I => 'param'), 'type' => 'warning'), $I => 'warning'), $formatter->arrayFromStatus($status, 'warning'), 'arrayFromStatus test for warning'); }
public function onSubmit(array $data, \HTMLForm $form = null) { // Get uploaded file $upload =& $_FILES['wpjsonimport']; // Check to make sure there is a file uploaded if ($upload === null || !$upload['name']) { return \Status::newFatal('importnofile'); } // Messages borrowed from Special:Import if (!empty($upload['error'])) { switch ($upload['error']) { case 1: case 2: return \Status::newFatal('importuploaderrorsize'); case 3: return \Status::newFatal('importuploaderrorpartial'); case 4: return \Status::newFatal('importuploaderrortemp'); default: return \Status::newFatal('importnofile'); } } // Read file $fname = $upload['tmp_name']; if (!is_uploaded_file($fname)) { return \Status::newFatal('importnofile'); } $data = \FormatJSON::parse(file_get_contents($fname)); // If there is an error during JSON parsing, abort if (!$data->isOK()) { return $data; } $this->doImport($data->getValue()); }
public function actionTest() { $start = time(); Yii::app()->cache->flush(); Yii::app()->db->createCommand()->truncateTable(Buy::model()->tableName()); Yii::app()->db->createCommand()->truncateTable(Sell::model()->tableName()); Yii::app()->db->createCommand()->truncateTable(Order::model()->tableName()); Yii::app()->db->createCommand()->truncateTable(Balance::model()->tableName()); // Тест на 10 000 руб. Status::setParam('balance', 10000); Status::setParam('balance_btc', 0); $exs = Exchange::getAllByDt('btc_rur', '2013-12-16', '2014-01-06'); $cnt = 0; foreach ($exs as $exchange) { $obj = new stdClass(); $obj->dtm = $exchange['dt']; $obj->buy = $exchange['buy']; $obj->sell = $exchange['sell']; $cnt++; $bot = new Bot($obj); $bot->run(); } $end = time(); echo '<b>Elapsed time: ' . ($end - $start) / 60 . ' min.<br/>'; echo '<b>Steps count: ' . $cnt . '<br/>'; }
/** * Perform validation on the user submitted data * and check that we can perform the rename * @param array $data * * @return Status */ function validate(array $data) { if (!class_exists('RenameuserSQL')) { return Status::newFatal('centralauth-rename-notinstalled'); } $oldUser = User::newFromName($data['oldname']); if (!$oldUser) { return Status::newFatal('centralauth-rename-doesnotexist'); } if ($oldUser->getName() === $this->getUser()->getName()) { return Status::newFatal('centralauth-rename-cannotself'); } $newUser = User::newFromName($data['newname']); if (!$newUser) { return Status::newFatal('centralauth-rename-badusername'); } if (!$this->overrideAntiSpoof && class_exists('CentralAuthSpoofUser')) { $spoofUser = new CentralAuthSpoofUser($newUser->getName()); $conflicts = $this->processAntiSpoofConflicts($oldUser->getName(), $spoofUser->getConflicts()); if ($conflicts) { return Status::newFatal('centralauth-rename-antispoofconflicts2', $this->getLanguage()->commaList($conflicts)); } } $validator = new GlobalRenameUserValidator(); $status = $validator->validate($oldUser, $newUser); return $status; }
public function buildSqlWhere() { $where = $this->config->filter(); $depth = Status::depth($this->statusVariables); if ($depth > 1) { if (!$this->config->connectionField()) { throw new \Ip\Exception("Nested GRID require 'connectionField' setting to be set."); } $where .= ' and (' . $where . ') and ' . $this->config->tableName() . '.`' . $this->config->connectionField() . '` = ' . ipDb()->getConnection()->quote($this->statusVariables['gridParentId' . ($depth - 1)]); } $searchVariables = array(); foreach ($this->statusVariables as $key => $value) { if (preg_match('/^s_/', $key)) { $searchVariables[substr($key, 2)] = $value; } } if (!empty($searchVariables)) { foreach ($this->config->fields() as $fieldData) { if (!empty($fieldData['type']) && $fieldData['type'] == 'Tab') { continue; } $fieldObject = $this->config->fieldObject($fieldData); $fieldQuery = $fieldObject->searchQuery($searchVariables); if ($fieldQuery) { if ($where != ' ') { $where .= ' and '; } $where .= $fieldQuery; } } } return $where; }
public function getList() { $addCreditRequests = Messaging::getSystemMessages(array('systemMessageType' => SYS_MSG_ADD_CREDIT, 'filterCustomerId' => array($this->customer->getId()))); // $this->log->write(print_r($addCreditRequests, true)); foreach ($addCreditRequests as $addCreditRequest) { // if ($addCreditRequest['senderId'] != $this->customer->getId()) // continue; $this->data['requests'][] = array('requestId' => $addCreditRequest['messageId'], 'amount' => $addCreditRequest['data']->amount, 'comment' => $addCreditRequest['data']->comment, 'currency' => $addCreditRequest['data']->currency, 'status' => Status::getStatus($addCreditRequest['data']->status, $this->config->get('language_id'), true), 'statusId' => $addCreditRequest['data']->status, 'timeAdded' => $addCreditRequest['timeAdded']); } /// Initialize interface $this->setBreadcrumps(); $this->data['textAmount'] = $this->language->get('AMOUNT'); $this->data['textComment'] = $this->language->get('COMMENT'); $this->data['textRequestId'] = $this->language->get('REQUEST_ID'); $this->data['textStatus'] = $this->language->get('STATUS'); $this->data['textTimeAdded'] = $this->language->get('TIME_ADDED'); $templateName = '/template/account/creditHistory.tpl'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $templateName)) { $this->template = $this->config->get('config_template') . $templateName; } else { $this->template = 'default' . $templateName; } $this->children = array('common/footer', 'common/header', 'common/column_right', 'common/column_left', 'common/content_top', 'common/content_bottom'); $this->getResponse()->setOutput($this->render()); }
function _retreat($params) { $user = $params['user']; $channel = $params['channel']; $inchannels = DB::get()->col('SELECT name FROM channels WHERE user_id = :user_id', array('user_id' => $user->id)); $join = 'office:' . $user->username; $joinalias = $this->_room_alias($join); foreach ($inchannels as $partchan) { DB::get()->query('DELETE FROM channels WHERE name = :name AND user_id = :user_id;', array('name' => $partchan, 'user_id' => $user->id)); if (preg_match('%^search:(?P<criteria>.+)$%i', $partchan, $searchmatches)) { DB::get()->query("DELETE FROM options WHERE name = :name AND grouping = 'searches' AND user_id = :user_id;", array('name' => $searchmatches['criteria'], 'user_id' => $user->id)); } else { if ($partchan != $join) { Status::create()->data("{$user->username} has retreated to <a href=\"#\" onclick=\"joinRoom('" . addslashes($join) . "');return false;\">{$joinalias}</a> from {$partchan}")->type('part')->channel($partchan)->insert(); } } } DB::get()->query('INSERT INTO channels (name, user_id, last) VALUES (:name, :user_id, NOW());', array('name' => $join, 'user_id' => $user->id)); if (!($herald = DB::get()->val("SELECT value FROM options WHERE user_id = :user_id AND name = :name AND grouping = :grouping", array('user_id' => $user->id, 'name' => 'Herald', 'grouping' => 'Identity')))) { $herald = '{$nickname} has joined {$room}'; } $js = ''; $cssclass = ''; $packed = Plugin::call('herald', array('herald' => $herald, 'js' => $js, 'cssclass' => $cssclass)); extract($packed); $herald = str_replace('{$nickname}', $user->nickname, $herald); $herald = str_replace('{$room}', $joinalias, $herald); $msg = htmlspecialchars($herald); Status::create()->data($msg)->type('join')->cssclass($cssclass)->channel($join)->js($js)->insert(); Immediate::create()->laststatus()->js('setRoom("' . addslashes($join) . '");'); return true; }
public function run() { $this->showActive($this->_controller, $this->_action); switch ($this->_controller) { case $this->_controller == 'site' && $this->_action != 'cadastro' && $this->_action != 'cadastro_editar' && $this->_action != 'esqueci' && $this->_action != 'ativarcadastro': $this->render('sideMenuHome'); break; case $this->_controller == 'quemsomos': $this->render('sideMenuQuemSomos'); break; case $this->_controller == 'areasdeatuacao': $this->render('sideMenuMercadosAtendidos'); break; case $this->_controller == 'compradores': $this->render('sideMenuCompradores'); break; case $this->_controller == 'avaliesuaempresa': $this->render('sideMenuAvalieSuaEmpresa'); break; case $this->_controller == 'negociosavenda' || $this->_action == 'cadastro' || $this->_action == 'cadastro_editar' || $this->_action == 'esqueci' || $this->_action == 'ativarcadastro': $criteria = new CDbCriteria(); $criteria->condition = 'status_excluido=\'S\''; $criteria->order = 'status_ordem'; $this->_status = Status::model()->findAll($criteria); $this->_model = new LoginForm(); $this->render('sideMenuNegociosaVenda'); break; case $this->_controller == 'contato': $this->render('sideMenuContato'); break; } }