function delete_list($id) { if ($id) { $rs = new Service($id); $rs->delete(); } }
/** * Requires memberOf attribute. * * @static * @param $ldapGroup * @param $options * @return User[] */ public static function getGroupMembers($ldapGroup, $options) { if ($options instanceof Service) { $ldap = $options; } else { $ldap = new Service($options); } $filter = "(&(objectCategory=user)(memberOf={$ldapGroup}))"; $attributes = array('samaccountname', 'cn', 'givenname', 'sn', 'mail', 'title', 'department', 'memberof'); $results = $ldap->search($filter, $attributes); $users = array(); foreach ($results as $row) { $users[] = new User($row); } // sort by name TODO use $options to change comparison property usort($users, function ($a, $b) { $al = strtolower($a->getName()); $bl = strtolower($b->getName()); if ($al == $bl) { return 0; } return $al > $bl ? +1 : -1; }); return $users; }
/** * Loads the routs fromm the api endpoint and stores them locally. */ public function loadRoutesFromService() { $service = new Service('endpoints'); $service->routes(array('list' => array('path' => '/api/endpoints', 'method' => 'GET'))); $this->_routeList = $service->list(); $this->cacheRoutes(); }
private function addService() { if ($this->requestParameter['submit']) { $objService = new Service(); $objServiceValidator = NCConfigFactory::getInstance()->getServiceValidator(); $objService->setServiceId($this->requestParameter['serviceId']); $objService->setServerId($this->requestParameter['serverId']); $objService->setServiceTypeId($this->requestParameter['serviceTypeId']); $objService->setServicePort($this->requestParameter['servicePort']); $objService->setServiceDNS($this->requestParameter['serviceDNS']); $objService->setServiceDNS2($this->requestParameter['serviceDNS2']); $objService->setServiceDNS3($this->requestParameter['serviceDNS3']); $objService->setServiceRefName($this->requestParameter['serviceRefName']); if ($this->requestParameter['serviceId']) { $errorArray = $objServiceValidator->editValidation($objService); if ($errorArray) { $errorArray['error'] = 'ERROR'; echo json_encode($errorArray); } else { $this->objServiceManager->editService($objService); echo json_encode(array('serviceId' => $this->requestParameter['serviceId'])); } } else { $errorArray = $objServiceValidator->addValidation($objService); if ($errorArray) { $errorArray['error'] = 'ERROR'; echo json_encode($errorArray); } else { $serviceId = $this->objServiceManager->addService($objService); echo json_encode(array('serviceId' => $serviceId)); } } } }
public function Decode($buf = '') { $this->buffer = new CodeEngine($buf); $this->ResultID = $this->buffer->DecodeInt16(); $this->Uin = $this->buffer->DecodeInt32(); if ($this->ResultID == CSResultID::result_id_success) { $temp1 = new PlayerCommonInfo(); $temp1->Decode($this->buffer); $this->BaseInfo = $temp1; $this->ServiceData->Count = $this->buffer->DecodeInt16(); for ($i = 0; $i < $this->ServiceData->Count; $i++) { $temp2 = new Service(); $temp2->Decode($this->buffer); $this->ServiceData->Service[] = $temp2; } $this->LockType = $this->buffer->DecodeInt16(); $this->GameID = $this->buffer->DecodeInt16(); $this->LockedServerType = $this->buffer->DecodeInt16(); $this->LockedServerID = $this->buffer->DecodeInt32(); $this->LockedRoomID = $this->buffer->DecodeInt32(); $this->LockedTableID = $this->buffer->DecodeInt32(); $this->LockMoney = $this->buffer->DecodeInt32(); $this->HappyBeanLockType = $this->buffer->DecodeInt16(); $this->HappyBeanGameID = $this->buffer->DecodeInt16(); $this->HappyBeanLockedServerType = $this->buffer->DecodeInt16(); $this->HappyBeanLockedServerID = $this->buffer->DecodeInt32(); $this->HappyBeanLockedRoomID = $this->buffer->DecodeInt32(); $this->HappyBeanLockedTableID = $this->buffer->DecodeInt32(); } return $this; }
/** * Updates or inserts a contact * @param Service $service * @return self * @throws NotValidException */ public function save(Service $service) { if (!$this->validate()) { throw new NotValidException('Unable to validate contact'); } return $this->reload($service->save($this)); }
public function get($customerId = null, $carId = null) { $sql = "SELECT * FROM {$this->tableName} WHERE 1=1"; if (!empty($customerId)) { $sql .= " AND `owner` = " . $this->db->escape($customerId); } if (!empty($carId)) { $sql .= " AND `id` = " . $this->db->escape($carId); } $result = array(); $service = new Service(); if (!empty($carId)) { $result = $this->db->fetchOne($sql); $customer = new Customer(false); $owner = $customer->get($result['owner']); if (!empty($owner)) { $result['owner'] = $owner; } $result['services'] = $service->getForCar($carId); } else { $result = $this->db->fetchAll($sql); $customer = new Customer(false); foreach ($result as $index => $car) { $owner = $customer->get($car['owner']); if (!empty($owner)) { $result[$index]['owner'] = $owner; } $result[$index]['services'] = $service->getForCar($car['id']); } } new Respond($result); }
public function __construct(Service $service) { $this->db = $db; //Выборка всех категорий для меню т.к. используются на всех страницах публичной части $this->category = $service->get('category_mapper')->getAll(); $this->basket_info = Basket::getBasketInfo(); }
/** * Get contacts from a given source * @param integer $idSource * @param integer|bool $page * @return bool|Response */ public function getContact($idSource, $page = false) { if ($page && is_numeric($page)) { $page = '?page=' . $page; } return $this->service->setRequestPath('origin/' . $idSource . '/contact' . $page)->setRequestType(Service::REQUEST_METHOD_GET)->request(); }
/** * SetUp */ protected function _start() { $this->table = Doctrine::getTable('OperationNotification'); // Создать услугу с захардкоженным ID $service = new Service(); $service->setKeyword(Service::SERVICE_SMS); $service->save(); }
public function change_template() { App::import('Model', 'Service'); $mService = new Service(); $service = $mService->find('first', array('conditions' => array('Service.id' => $this->request->data['idService']))); echo json_encode($service['Service']); die; }
/** * @covers \Request\Service::setParam * @covers \Request\Service::getParams * @depends testCreateService */ public function testSetAndGetParam() { $testKey = 'testKey'; $request = new Service(); $request->setParam($testKey, 'value'); $params = $request->getParams(); $this->assertEquals('value', $params[$testKey]); }
public function testUpdateStatusSuccessClose() { $payuplOrderId = 'ABC'; $status = 'COMPLETED'; $transaction = $this->getTransactionMockForUpdateStatus($payuplOrderId, $status); $transaction->expects($this->once())->method('setIsClosed')->with($this->equalTo(1))->will($this->returnSelf()); $transaction->expects($this->once())->method('save')->will($this->returnSelf()); $this->model->updateStatus($payuplOrderId, $status, true); }
public function testShouldDefineServiceWithSetterInjection() { $this->app->set('commonService', function (Container $di) { $service = new Service($di->get('component')); $service->setFormat('xml'); return $service; }); $service = $this->app->get('commonService'); $this->assertEquals('xml', $service->getFormat()); }
public function testShouldDefineServiceWithSetterInjection() { $this->app->commonService = function (Application $app) { $service = new Service($app->component); $service->setFormat('xml'); return $service; }; $service = $this->app->commonService; $this->assertEquals('xml', $service->getFormat()); }
/** * Applies the listeners needed to parse client models. * * @param Service $api API to create a parser for * * @return callable * * @throws \UnexpectedValueException */ public static function createParser(Service $api) { static $mapping = ['json' => 'Vws\\Api\\Parser\\JsonRpcParser', 'rest-json' => 'Vws\\Api\\Parser\\RestJsonParser']; $proto = $api->getProtocol(); if (isset($mapping[$proto])) { return new $mapping[$proto]($api); } else { throw new \UnexpectedValueException('Unknown protocol: ' . $api->getProtocol()); } }
/** * @param Message $message * * @return bool * * @throws UnexpectedValueException */ public function verify(Message $message) { $serviceResponse = $this->service->verifyIpnMessage($message); $serviceResponseBody = $serviceResponse->getBody(); $pattern = sprintf('/(%s|%s)/', self::STATUS_KEYWORD_VERIFIED, self::STATUS_KEYWORD_INVALID); if (!preg_match($pattern, $serviceResponseBody)) { throw new \UnexpectedValueException(sprintf('Unexpected verification status encountered: %s', $serviceResponseBody)); } return $serviceResponseBody === self::STATUS_KEYWORD_VERIFIED; }
/** * A Collection is an array of objects * * Some assumptions: * * The `Collection` class assumes that there exists on its service * a factory method with the same name of the class. For example, if * you create a Collection of class `Foobar`, it will attempt to call * the method `parent::Foobar()` to create instances of that class. * * It assumes that the factory method can take an array of values, and * it passes that to the method. * * @param Service $service - the service associated with the collection * @param string $itemclass - the Class of each item in the collection * (assumed to be the name of the factory method) * @param array $arr - the input array */ public function __construct($service, $class, array $array = array()) { $service->getLogger()->deprecated(__METHOD__, 'OpenCloud\\Common\\Collection\\CollectionBuilder'); $this->setService($service); $this->setNextPageClass($class); // If they've supplied a FQCN, only get the last part $class = false !== ($classNamePos = strrpos($class, '\\')) ? substr($class, $classNamePos + 1) : $class; $this->setItemClass($class); // Set data $this->setItemList($array); }
/** * Main process of widget * * @param array $args * @param array $instance */ public function widget($metric, $url = null) { $username = Engine_Api::_()->getApi('settings', 'core')->getSetting('ynblog.username'); $password = Engine_Api::_()->getApi('settings', 'core')->getSetting('ynblog.password'); $dimension = 'url'; $oRequest = new Request(new Authentication($username, $password), new Metric($metric), new Dimension($dimension), Ynblog_Api_Addthis::getServiceQuery()); $oService = new Service($oRequest); $response = $oService->getData(); echo Ynblog_Api_Addthis::getContent($response, $url); return Ynblog_Api_Addthis::getContent($response, $url); }
/** * Parse the service into array * * @param Service * @return array */ public function get(Service $service) { $result = array(); $lines = $service->getResult(); foreach ($lines as $index => $line) { if (strpos($line, self::IDENTIFIER) !== false) { $result[] = $this->parse($lines, $index); } } return $result; }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('cs_service_types')->delete(); $services = array("Theme", "Project", "Fix Bug"); foreach ($services as $service) { $sv = new Service(); $sv->name = $service; $sv->description = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"; $sv->save(); } }
/** * Тест /services/index * */ public function testIndex() { $user = $this->helper->makeUser(); $this->authenticateUser($user); $user->save(); $service = new Service(); $service->price = 100; $service->name = "Уникальное имя услуги " . uniqid(); $service->save(); $this->browser->get($this->generateUrl('services'))->with('response')->begin()->isStatusCode(200)->matches('/(' . $service->name . ')/i')->end(); }
/** * Performs decryption of data received from service. * Data need to be encrypted using service private key for this function to work (it uses service public key) * * @param Service $service * @param $data string Encrypted service data * * @return string Decrypted service data using it's public key */ public function serviceDecrypt(Service $service, $encryptedData) { $key = $this->getKey($service->getPublicKeyName(), self::TYPE_PUBLIC); $decryptedData = ''; if (!openssl_public_decrypt($encryptedData, $decryptedData, $key)) { throw new \RuntimeException('Service data decryption failed'); } unset($key); gc_collect_cycles(); //Remove key from memory return $decryptedData; }
/** * @param \SimpleXMLElement $xml * @return Service */ public static function createFromXML(\SimpleXMLElement $xml) { $service = new Service(); $service->setName((string) $xml); if (isset($xml['category'])) { $service->setCategory((string) $xml['category']); } if (isset($xml['flag'])) { $service->setFlag((string) $xml['flag']); } return $service; }
public function storeService() { $advisor = Auth::user(); // If form validation passes: $service = new Service(); $service->name = Input::get('name'); if (Input::get('notes')) { $service->notes = Input::get('notes'); } $service->save(); $advisor->services()->save($service); return Redirect::intended('advisor.dashboard'); }
/** install($name) Method that installs the relevant plugin. $name just sends the plugin name. Useful for schema adding. */ public function install($name) { $sql = "CREATE TABLE capone\n (cID INTEGER NOT NULL AUTO_INCREMENT,\n cImageID INTEGER NOT NULL,\n cOSID INTEGER NOT NULL,\n cKey VARCHAR(250) NOT NULL,\n PRIMARY KEY(cID),\n INDEX new_index (cImageID),\n INDEX new_index2 (cKey))\n ENGINE = MyISAM"; if ($this->DB->query($sql)) { $CaponeDMI = new Service(array('name' => 'FOG_PLUGIN_CAPONE_DMI', 'description' => 'This setting is used for the capone module to set the DMI field used.', 'value' => '', 'category' => 'Plugin: ' . $name)); $CaponeDMI->save(); $CaponeRegEx = new Service(array('name' => 'FOG_PLUGIN_CAPONE_REGEX', 'description' => 'This setting is used for the capone module to set the reg ex used.', 'value' => '', 'category' => 'Plugin: ' . $name)); $CaponeRegEx->save(); $CaponeShutdown = new Service(array('name' => 'FOG_PLUGIN_CAPONE_SHUTDOWN', 'description' => 'This setting is used for the capone module to set the shutdown after imaging.', 'value' => '', 'category' => 'Plugin: ' . $name)); $CaponeShutdown->save(); return true; } return false; }
public function load() { parent::load(); $model = new Metric(); $this->view->metrics = $model->getindex(); //additional info if (isset($_REQUEST["metric_attrs_showservices"])) { $model = new MetricService(); $this->view->metricservices = $model->getgroupby("metric_id"); $model = new Service(); $this->view->services = $model->getindex(); } $this->setpagetitle(self::default_title()); }
public function getUrisForPrincipalToService(Principal $p, Service $s) { if (!$s->isValidated()) { return NULL; } $es = $this->getEntitlementsForPrincipalToService($p, $s); if ($es) { foreach ($es as $e) { $uris[] = $e->getUri(); } return $uris; } return NULL; }
public function submit() { $facility1 = $this->input->post('spoint'); $service = $this->input->post('facility'); $u = new Service(); $u->facility_id = $service; $u->service_point = $facility1; $u->save(); $data['title'] = "Service Points"; $data['content_view'] = "facility_service"; $data['banner_text'] = "Service Points"; $data['quick_link'] = "facility_service"; $this->load->view("template", $data); }
public static function sandbox() { $service = Service::find(1); $services = Service::all(); $employees = Employee::all(); $employee = Employee::find(1); $service2 = new Service(array('name' => 'aasdd', 'price' => "2", 'description' => "asfafaf")); $errors = $service2->errors(); Kint::dump($employee); Kint::dump($employees); Kint::dump($service); Kint::dump($services); Kint::dump($errors); // View::make('helloworld.html'); }