protected function _checkUser() { if (fnGet($this->input, 'access_token') == '') { $this->_ajaxReturn(array('error_code' => '600020', 'error_msg' => '参数[access_token]不能为空'), 400); } // 设置当前用户和客户端 $this->session->setUser($user = new User())->setClient($client = new Client()); $passportConfig = $this->config->get("api.passport"); // 尝试从缓存获取 userInfo if ($this->_userInfo = S($cacheKey = 'access_token_info.' . fnGet($this->input, 'access_token'))) { $user->find(fnGet($this->_userInfo, 'user_id')); $client->find(fnGet($this->_userInfo, 'client_id')); return; } // 向 passport 请求 userInfo $time = time(); $url = str_replace('internal-resource/user-info?', '', $passportConfig->passportUrl) . 'internal-resource/user-info'; $params = array('access_token' => fnGet($this->input, 'access_token'), 'app' => $passportConfig->passportApp, 'time' => $time); $sign = md5(implode('', $params) . $passportConfig->passportSecret); $params['sign'] = $sign; $http = new HttpClient(); $response = $http->request($url, $params); $data = json_decode($response, true); if (fnGet($data, 'id')) { //检测用户是否已经保存 $user->getByUsername($username = fnGet($data, 'username')); if (!($userId = $user->getId()) || !$user->getData('passport_id') || $user->getData('mobile') != fnGet($data, 'mobile')) { $user->addData(array('username' => $username, 'email' => fnGet($data, 'email'), 'mobile' => fnGet($data, 'mobile'), 'passport_id' => fnGet($data, 'passport_id'), 'avatar' => fnGet($data, 'avatar'), 'nickname' => fnGet($data, 'nickname'))); $user->save(); $userId = $user->getId(); } //检测客户端是否已经保存 $client->getByAppId($appId = fnGet($data, 'client_info/id')); if (!($clientId = $client->getId()) || $client->getScopes() != fnGet($data, 'client_info/scopes')) { $client->addData(array('client' => $appId, 'name' => fnGet($data, 'client_info/name'), 'app_secret' => fnGet($data, 'client_info/secret'), 'developerurl' => fnGet($data, 'client_info/endpoint'), 'scopes' => fnGet($data, 'client_info/scopes'))); $client->save(); $clientId = $client->getId(); } $this->_userInfo = array('user_id' => $userId, 'client_id' => $clientId, 'username' => $username, 'session_data' => fnGet($data, 'session_data')); S($cacheKey, $this->_userInfo, 3600); return; } $this->_ajaxReturn(array('error_code' => '600020', 'error_msg' => '用户无效'), 400); }
/** * update the client using the client values * * @param Client $client * @return void */ public function updateClient($client) { try { $tmp = $this->getClientById($client->getId()); clientDaoImp::updateState($tmp, $client); $this->entityManager->persist($tmp); // $this->entityManager->flush(); } catch (Exception $ex) { "ClientDaoImp-update(): " . $ex->getTrace(); } }
/** * Removes the client from the "clients" and the "requests" * array. * * @param AlphaRPC\Manager\ClientHandler\Client $client * * @return \AlphaRPC\Manager\ClientHandler\ClientBucket */ public function remove(Client $client) { $clientId = $client->getId(); if (!isset($this->clients[$clientId])) { return $this; } $requestId = $client->getRequest(); $this->removeClientForRequest($clientId, $requestId); unset($this->clients[$clientId]); return $this; }
function test_getId() { //Arrange $client_name = "Ted"; $stylist_id = 1; $id = 1; $test_client = new Client($client_name, $id); //Act $result = $test_client->getId(); //Assert $this->assertEquals(true, is_numeric($result)); }
function test_getId() { $name = "Jane Doe"; $test_stylist = new Stylist($name); $test_stylist->save(); $client_name = "Jimmy"; $id = 1; $client_stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $client_stylist_id, $id); $result = $test_client->getId(); $this->assertEquals($id, $result); }
function test_getId() { $name = "Megan"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $client_name = "Shawnee"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id, $stylist_id); $test_client->save(); $result = $test_client->getId(); $this->assertEquals(true, is_numeric($result)); }
/** * * @param Client $client * @return type * @throws DaoException */ public function updateClient(Client $client) { try { $query = Doctrine_Query::create()->update('Client i'); $query->set('i.name', '?', $client->getName()); $query->set('i.address', '?', $client->getAddress()); $query->set('i.tp_hp', '?', $client->getTpHp()); $query->set('i.tp_home', '?', $client->getTpHome()); $query->set('i.notes', '?', $client->getNotes()); $query->where('i.id = ?', $client->getId()); return $query->execute(); } catch (Exception $e) { throw new DaoException($e->getMessage(), $e->getCode(), $e); } }
function test_getId() { //Arrange $name = "Sasha"; $id = 1; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $c_name = "Garry Gergich"; $phone = "503-472-8959"; $stylist_id = $test_stylist->getId(); $test_client = new Client($c_name, $phone, $id, $stylist_id); //Act $result = $test_client->getId(); //Assert $this->assertEquals(true, is_numeric($result)); }
function testFind() { //Arrange $id = null; $client_name = "Nico"; $stylist_id = 1; $test_client = new Client($id, $client_name, $stylist_id); $test_client->save(); $client_name2 = "Al"; $stylist_id2 = 2; $test_client2 = new Client($id, $client_name2, $stylist_id2); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
function test_client_find() { //Arrange $name = "Vidal Sassoon"; $test_stylist = new Stylist($name); $test_stylist->save(); $name2 = "Sweeney Todd"; $test_stylist2 = new Stylist($name2); $test_stylist2->save(); $name3 = "Mr. T"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name3, $stylist_id, null); $test_client->save(); $name4 = "Mrs. T"; $stylist_id2 = $test_stylist2->getId(); $test_client2 = new Client($name4, $stylist_id2, null); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
public function testSetGet() { $client = new Client(); $id = 'test_id'; $client->setId($id); $this->assertEquals($id, $client->getId(), 'Unable to setup id!'); $name = 'test_name'; $client->setName($name); $this->assertEquals($name, $client->getName(), 'Unable to setup name!'); $title = 'test_title'; $client->setTitle($title); $this->assertEquals($title, $client->getTitle(), 'Unable to setup title!'); $userAttributes = ['attribute1' => 'value1', 'attribute2' => 'value2']; $client->setUserAttributes($userAttributes); $this->assertEquals($userAttributes, $client->getUserAttributes(), 'Unable to setup user attributes!'); $normalizeUserAttributeMap = ['name' => 'some/name', 'email' => 'some/email']; $client->setNormalizeUserAttributeMap($normalizeUserAttributeMap); $this->assertEquals($normalizeUserAttributeMap, $client->getNormalizeUserAttributeMap(), 'Unable to setup normalize user attribute map!'); $viewOptions = ['option1' => 'value1', 'option2' => 'value2']; $client->setViewOptions($viewOptions); $this->assertEquals($viewOptions, $client->getViewOptions(), 'Unable to setup view options!'); }
public function addClient(Client $client) { return $this->storage->execute('INSERT INTO client(id,secret,name,redirect_url,user_id,description) VALUES ("' . $client->getId() . '" , "' . $client->getSecret() . '" ,"' . $client->getName() . '" ,"' . $client->getRedirectUrl() . '" ,"' . $client->getUserId() . '","' . $client->getDescription() . '")'); }
?> <input type="submit" value="Complete" onClick="setCompleted()"> <?php //} ?> <hr> <table> <tr><td style="width:200px;">Order Code</td> <td style="width:200px;">Title</td> <td style="width:200px;">Client</td> <td style="width:200px;">Destination</td> <td style="width:200px;">Action</td> </tr> <?php for ($i = 0; $i < sizeof($orderList); $i++) { $mOrder = new Order($orderList[$i]); $mClient = new Client($mOrder->getClient()); echo "<tr>"; echo "<td><a href='../order/detail.php?id=" . $mOrder->getId() . "'>" . $mOrder->getCode() . "</a></td>"; echo "<td>" . $mOrder->getTitle() . "</td>"; echo "<td><a href='../client/detail.php?id=" . $mClient->getId() . "'>" . $mClient->getName() . "</a></td>"; echo "<td>" . $mOrder->getDestination() . "</td>"; echo "<td><input type='submit' value='Assign'><input type='submit' value='Track'></td>"; echo "</tr>"; } ?> </table> <div> </div> </body>
function test_find() { //Arrange $name = "Tessa"; $id = null; $visits = 4; $description = "The best!"; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "jack"; $name2 = "Bob"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $stylist_id, $id, $visits, $description); $test_client->save(); $test_client2 = new Client($name, $stylist_id, $id, $visits, $description); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
/** * Runs a client level pre or post script. * * @param string $type Either "pre" or "post". * * @param int $status Status of previos command. * * @param Client $client Client entity * * @param Job $job Job entity. Null if running at the client level. * * @param Script $script Script entity * * @param string $stats Stats for script environment vars (not stored in DB) * * @return boolean true on success, false on error. * */ protected function runScript($type, $status, $client, $job, $script, $stats) { if ($script === null) { return true; } if (null == $job) { $entity = $client; $context = array('link' => $this->generateClientRoute($client->getId())); $errScriptError = 'Client "%entityid%" %scripttype% script "%scriptname%" execution failed. Diagnostic information follows: %output%'; $errScriptMissing = 'Client "%entityid%" %scripttype% script "%scriptname%" present but file "%scriptfile%" missing.'; $errScriptOk = 'Client "%entityid%" %scripttype% script "%scriptname%" execution succeeded. Output follows: %output%'; $level = 'CLIENT'; // Empty vars (only available under JOB level) $job_name = ''; $owner_email = ''; $recipient_list = ''; $job_total_size = 0; $job_run_size = 0; $job_starttime = 0; $job_endtime = 0; if ($type == 'post') { $client_endtime = $stats['ELKARBACKUP_CLIENT_ENDTIME']; $client_starttime = $stats['ELKARBACKUP_CLIENT_STARTTIME']; } else { $client_endtime = 0; $client_starttime = 0; } } else { $entity = $job; $context = array('link' => $this->generateJobRoute($job->getId(), $client->getId())); $errScriptError = 'Job "%entityid%" %scripttype% script "%scriptname%" execution failed. Diagnostic information follows: %output%'; $errScriptMissing = 'Job "%entityid%" %scripttype% script "%scriptname%" present but file "%scriptfile%" missing.'; $errScriptOk = 'Job "%entityid%" %scripttype% script "%scriptname%" execution succeeded. Output follows: %output%'; $level = 'JOB'; $job_name = $job->getName(); $owner_email = $job->getOwner()->getEmail(); $recipient_list = $job->getNotificationsEmail(); $job_total_size = $job->getDiskUsage(); $client_starttime = 0; $client_endtime = 0; if ($type == 'post') { $job_run_size = $stats['ELKARBACKUP_JOB_RUN_SIZE']; $job_starttime = $stats['ELKARBACKUP_JOB_STARTTIME']; $job_endtime = $stats['ELKARBACKUP_JOB_ENDTIME']; } else { $job_run_size = 0; $job_starttime = 0; $job_endtime = 0; } } $scriptName = $script->getName(); $scriptFile = $script->getScriptPath(); if (!file_exists($scriptFile)) { $this->err($errScriptMissing, array('%entityid%' => $entity->getId(), '%scriptfile%' => $scriptFile, '%scriptname%' => $scriptName, '%scripttype%' => $type), $context); return false; } $commandOutput = array(); $command = sprintf('env ELKARBACKUP_LEVEL="%s" ELKARBACKUP_EVENT="%s" ELKARBACKUP_URL="%s" ELKARBACKUP_ID="%s" ELKARBACKUP_PATH="%s" ELKARBACKUP_STATUS="%s" ELKARBACKUP_CLIENT_NAME="%s" ELKARBACKUP_JOB_NAME="%s" ELKARBACKUP_OWNER_EMAIL="%s" ELKARBACKUP_RECIPIENT_LIST="%s" ELKARBACKUP_CLIENT_TOTAL_SIZE="%s" ELKARBACKUP_JOB_TOTAL_SIZE="%s" ELKARBACKUP_JOB_RUN_SIZE="%s" ELKARBACKUP_CLIENT_STARTTIME="%s" ELKARBACKUP_CLIENT_ENDTIME="%s" ELKARBACKUP_JOB_STARTTIME="%s" ELKARBACKUP_JOB_ENDTIME="%s" sudo "%s" 2>&1', $level, 'pre' == $type ? 'PRE' : 'POST', $entity->getUrl(), $entity->getId(), $entity->getSnapshotRoot(), $status, $client->getName(), $job_name, $owner_email, $recipient_list, $client->getDiskUsage(), $job_total_size, $job_run_size, $client_starttime, $client_endtime, $job_starttime, $job_endtime, $scriptFile); exec($command, $commandOutput, $status); if (0 != $status) { $this->err($errScriptError, array('%entityid%' => $entity->getId(), '%output%' => "\n" . implode("\n", $commandOutput), '%scriptname%' => $scriptName, '%scripttype%' => $type), $context); return false; } $this->info($errScriptOk, array('%entityid%' => $entity->getId(), '%output%' => "\n" . implode("\n", $commandOutput), '%scriptname%' => $scriptName, '%scripttype%' => $type), $context); return true; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Client $value A Client object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Client $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
function testFind() { //Arrange $id = null; $name = "Martha Stewart"; $phone = "(888) 888-8888"; $next_visit = "2015-09-06"; $stylist_id = 1; $test_client = new Client($id, $name, $phone, $next_visit, $stylist_id); $test_client->save(); $name2 = "Jennifer Lopez"; $phone2 = "(609) 999-9999"; $next_visit2 = "2015-10-12"; $stylist_id2 = 2; $test_client2 = new Client($id, $name2, $phone2, $next_visit2, $stylist_id2); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
function test_client_getStars() { //Arrange $style = "Thai"; $test_cuisine = new Client($style); $test_cuisine->save(); $name = "Pok Pok"; $category_id = $test_cuisine->getId(); $stars = 5; $test_client = new Client($name, $category_id, null, $stars); $test_client->save(); $name2 = "Dicks"; $stars2 = 3; $category_id2 = $test_cuisine->getId(); $test_client2 = new Client($name2, $category_id, null, $stars2); $test_client2->save(); //Act $result = Client::getAll(); //Assert $this->assertEquals(5, $result[0]->getStars()); }
function test_find() { //Arrange $name = "Jackie"; $test_stylist = new Stylist($name); $test_stylist->save(); $name = "Sandra Jane"; $phone = "542-334-0984"; $style_choice = "The Rachel"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $phone, $style_choice, $stylist_id); $test_client->save(); $name2 = "Jordy Duran"; $phone2 = "239-094-0281"; $style_choice2 = "Bowl Cut"; $test_client2 = new Client($name2, $phone2, $style_choice2, $stylist_id); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
public function savePaymentInformation(sfWebRequest $request) { $payment_information = $request->getParameter('payment_information'); $first_name = $payment_information['first_name']; $last_name = $payment_information['last_name']; $number = $payment_information['number']; $cvv_code = $payment_information['cvv_code']; $address = $payment_information['address']; $mail = $payment_information['email']; $document = $payment_information['document']; $comments = $payment_information['comment']; $mes = $request->getParameter('mes'); $anio = $request->getParameter('anio'); $user_name = $this->getUser()->isAuthenticated() ? $this->getUser()->getUserName() : ""; $mail_object = new Mail(); $mail_object->setMail($mail); $mail_object->setIdState(2); $mail_object->setMailTypeId(1); $mail_object->save(); $client = new Client(); $client->setFirstName($first_name); $client->setLastName($last_name); $client->setIdState(2); $client->save(); $client_mail = new ClientMail(); $client_mail->setIdState(2); $client_mail->setClientId($client->getId()); $client_mail->setMailId($mail_object->getId()); $client_mail->save(); $identity_document = new IdentityDocument(); $identity_document->setIdState(2); $identity_document->setIdentityDocumentTypeId(1); $identity_document->setNumber($document); $identity_document->save(); $time = mktime(0, 0, 0, $mes, 1, $anio); $date = date('Y-m-d H:i:s', $time); $payment_inf = new PaymentInformation(); $payment_inf->setNumber($number); $payment_inf->setCvvCode($cvv_code); $payment_inf->setClientId($client->getId()); $payment_inf->setComment($comments); $payment_inf->setAddress($address); $payment_inf->setUserName($user_name); $payment_inf->setIdentityDocumentId($identity_document->getId()); // $payment_inf->setDate($date); $payment_inf->save(); }
function test_update() { //Arrange $name = "Erin"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "George"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $stylist_id, $id); $test_client->save(); $new_name = "Jim"; $new_test_client = new Client($new_name, $stylist_id, $test_client->getId()); //Act $test_client->update($new_name); //Assert $this->assertEquals($test_client, $new_test_client); }
function testFind() { $name = "Bob"; $phone = "555-555-5555"; $stylist_id = 1; $test_client = new Client($name, $phone, $stylist_id); $test_client->save(); $name2 = "Kevin"; $phone2 = "444-444-4444"; $test_client2 = new Client($name2, $phone2, $stylist_id); $test_client2->save(); $result = Client::find($test_client->getId()); $this->assertEquals($test_client, $result); }
function testFind() { //Arrange $stylist_name = "Gandalf the Gray"; $test_stylist = new Stylist($stylist_name, $id = null); $test_stylist->save(); $client_name = "Samwise"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id = null, $stylist_id); $test_client->save(); $client_name2 = "Arwen"; $test_client2 = new Client($client_name2, $id = null, $stylist_id); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
<?php require 'connect.php'; require 'client/Book.php'; require 'client/Employee.php'; require 'client/Client.php'; require 'client/Hire.php'; $book = new Book(1, 'Metro', 'Gluhowsky', 'apokalipsa'); $employee = new Employee(2, 'Jan', 'Kowalski', '*****@*****.**', 'Warszawa'); $client = new Client(3, 'Anna', 'Kowalska', '*****@*****.**'); $hire = new Hire(4, $book, $employee, '2015-12-15', '2015-12-26'); $query = "INSERT INTO `book` (`id`, `title`, `author`, `type`) VALUES ('1', '{$book->getTitle()}', '{$book->getAuthor()}', '{$book->getType()}')"; $libraryRequest = mysql_query($query); $query = "INSERT INTO `employee` (`id`, `firstname`, `lastname`, `email`, `city`) VALUES ('2', '{$employee->getfirstName()}', '{$employee->getlastName()}', '{$employee->getEmail()}', '{$employee->getCity()}')"; $libraryRequest = mysql_query($query); $query = "INSERT INTO `client` (`id`, `firstname`, `lastname`, `email`) VALUES ('3', '{$client->getfirstName()}', '{$client->getlastName()}', '{$client->getEmail()}')"; $libraryRequest = mysql_query($query); $query = "INSERT INTO `hire` (`id`, `id_client`, `id_book`, `id_employee`, `hiredate`, `returndate`) VALUES ('4', '{$client->getId()}', '{$book->getId()}', '{$employee->getId()}', '{$hire->getHireDate()}', '{$hire->getReturnDate()}')"; var_dump($query); $libraryRequest = mysql_query($query);
public function transformJobs() { $statusHash = array(); $statusObjects = StatusPeer::doSelect(new Criteria()); foreach ($statusObjects as $s) { $statusHash[$s->getState()] = $s->getId(); } $this->jobKeys = array(); $dom = DOMDocument::load("tuftsph_jm2db.xml"); $jobs = $dom->getElementsByTagName("jobs"); $total = $jobs->length; $count = 1; $jobList = array(); foreach ($jobs as $job) { $jid = 0; $childNodes = $job->childNodes; $j = new Job(); $del = new Delivery(); $jid = 1; $startTime = null; $shootStart = null; $shootEnd = null; $endTime = null; $notes = ""; $photog = 0; $slug = ""; $childNodes = $job->childNodes; foreach ($childNodes as $child) { switch ($child->nodeName) { case "id": $jid = $child->textContent; break; case "shoot_name": $j->setEvent($child->textContent); break; case "shoot_date": $j->setDate($child->textContent); break; case "shoot_startT": $startTime = $child->textContent; break; case "shoot_start": $shootStart = $child->textContent; break; case "shoot_endT": $endTime = $child->textContent; break; case "shoot_end": $shootEnd = $child->textContent; break; case "shoot_duedate": $j->setDueDate($child->textContent); break; case "submitted_at": $j->setCreatedAt($child->textContent); break; case "requester_address": $j->setStreet($child->textContent); break; case "requester_campus": $j->setCity($child->textContent); break; case "requester_name": $j->setContactName($child->textContent); break; case "requester_email": $j->setContactEmail($child->textContent); break; case "requester_phone": $j->setContactPhone($child->textContent); break; case "internal_notes": $notes .= $child->textContent . "<br/>"; break; case "billing_notes": $notes .= $child->textContent . "<br/>"; break; case "estimate": $j->setEstimate($child->textContent); break; case "billing_acctnum": $j->setAcctNum($child->textContent); break; case "billing_deptid": $j->setDeptId($child->textContent); break; case "billing_grantid": $j->setGrantId($child->textContent); break; case "shoot_directions": $j->setOther($child->textContent); break; case "status": $j->setStatusId($statusHash[$child->textContent]); break; case "photog_id": $photog = $child->textContent; break; case "delivery_pubname": $del->setPubName($child->textContent); break; case "delivery_pubtype": $del->setPubType($child->textContent); break; case "delivery_other": $del->setOther($child->textContent); break; case "delivery_format": break; case "delivery_color": $del->setColor($child->textContent); break; case "delivery_format": $del->setFormat($child->textContent); break; case "delivery_size": $del->setSize($child->textContent); break; case "delivery_method": $del->setMethod($child->textContent); break; case "delivery_special": $del->setInstructions($child->textContent); break; case "slug": $slug = $child->textContent; break; case "#text": default: break; } } if (is_null($endTime)) { $endTime = $shootEnd; } if (is_null($startTime)) { $startTime = $shootStart; } if ($j->getCity() == "Boston") { $j->setZip("02101"); } else { $j->setZip("02155"); } $j->setNotes($notes); $j->setState("Massachusetts"); list($hour, $min, $sec) = explode(":", $endTime); list($shour, $smin, $ssec) = explode(":", $startTime); $t = new DateTime(); $t->setTime($hour, $min, $sec); $j->setEndTime($t); $t = new DateTime(); $t->setTime($shour, $smin, $ssec); $j->setStartTime($t); $j->addTag($slug); if (isset($this->jobProjectKeys[$jid])) { $j->setProjectId($this->projectKeys[$this->jobProjectKeys[$jid]]); } while (count($jobList) - 1 != $jid) { $jobList[] = false; } $jobList[intval($jid)] = array("job" => $j, "del" => $del, "photog" => $photog); } for ($i = 1; $i < count($jobList); $i++) { sleep(1); $obj = $jobList[$i]; $c = new Criteria(); $c->add(JobPeer::ID, $i); if (JobPeer::doCount($c) > 0) { continue; } echo $i . "/" . $total . "\n"; // keep the ids lined up if ($obj == false) { $myJob = new Job(); try { $myJob->save(); } catch (Exception $ex) { echo $ex->getMessage(); } $myJob->delete(); } else { $j = $obj["job"]; $del = $obj["del"]; $photog = $obj["photog"]; try { $j->save(); } catch (Exception $ex) { echo $ex->getMessage(); echo $ex->getTraceAsString(); } $del->setJobId($j->getId()); $del->save(); $this->jobKeys[$jid] = $j->getId(); if ($photog) { $jp = new JobPhotographer(); $jp->setPhotographerId($this->photogKeys[$photog]); $jp->setJobId($j->getId()); try { $jp->save(); } catch (Exception $ex) { echo $ex->getMessage(); } } // add the requester as a client $c = new Criteria(); $c->add(sfGuardUserPeer::USERNAME, $j->getContactEmail()); if (ClientPeer::doCount($c) == 0 && trim(strlen($j->getContactEmail())) != 0) { $user = new sfGuardUser(); $user->setUsername($j->getContactEmail()); $user->setPassword("admin"); $user->save(); $userProfile = new sfGuardUserProfile(); $userProfile->setUserId($user->getId()); $userProfile->setUserTypeId(sfConfig::get("app_user_type_client")); $userProfile->save(); $clientProfile = new Client(); $clientProfile->setUserId($userProfile->getId()); $clientProfile->setName($j->getContactName()); $clientProfile->setEmail($j->getContactEmail()); $clientProfile->setPhone($j->getContactPhone()); $clientProfile->save(); $jobClient = new JobClient(); $jobClient->setClientId($clientProfile->getId()); $jobClient->setJobId($j->getId()); $jobClient->save(); } } $count += 1; } }
function test_find() { //Arrange $stylist_name = "jack"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $client_name = "joe"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id, $stylist_id); $test_client->save(); $client_name2 = "jill"; $test_client2 = new Client($client_name2, $id, $stylist_id); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
function lookup($id, $email) { return $id && is_numeric($id) && ($c = new Client($id, $email)) && $c->getId() == $id ? $c : null; }
function test_find() { //Arrange $name = "Stylist1"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "Client1"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $id, $stylist_id); $test_client->save(); $name = "Client2"; $test_client2 = new Client($name, $id, $stylist_id); $test_client2->save(); //Act $result = Client::find($test_client->getId()); //Assert $this->assertEquals($test_client, $result); }
$selected = $serviceHourInput == $hour ? "selected='selected'" : ""; $hourOptions .= "<option value=" . $hour . " {$selected} >" . $hour . "</option>"; } $minuteOptions = ""; $serviceMinuteInput = isset($_SESSION["formInput"]["service_minute"]) ? $_SESSION["formInput"]["service_minute"] : ""; for ($min = 0; $min < 60; $min++) { $selected = $serviceMinuteInput == $min ? "selected='selected'" : ""; $minute = $min <= 9 ? "0" . $min : $min; $minuteOptions .= "<option value=" . $minute . " {$selected}>" . $minute . "</option>"; } $client = new Client(); $clientDetails = $client->getClients(array("client_id" => "ASC")); $clientOption = ""; $serviceClient = isset($_SESSION["formInput"]["client_id"]) ? $_SESSION["formInput"]["client_id"] : ""; foreach ($clientDetails as $client) { $selected = $serviceClient == $client->getId() ? "selected='selected'" : ""; $clientOption .= "<option value='" . $client->getId() . "' {$selected}>" . $client->getFname() . " " . $client->getLname() . "</option>"; } if (!$isAdmin) { $clientID = $currentUser->getId(); } else { $clientID = $serviceClient; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
} } else { $errors['err'] = _('Uknown command!'); } } else { $errors['err'] = _('No roles selected.'); } } break; case 'client': include_once INCLUDE_DIR . 'class.client.php'; $do = strtolower($_POST['do']); switch ($do) { case 'update': $client = new Client($_POST['client_id']); if ($client && $client->getId()) { if ($client->update($_POST, $errors)) { $msg = _('Client profile updated successfully'); } elseif (!$errors['err']) { $errors['err'] = _('Error updating the user'); } } else { $errors['err'] = _('Internal error'); } break; case 'create': if ($uID = Client::create($_POST, $errors)) { $msg = sprintf(_('%s added successfully'), Format::htmlchars($_POST['client_firstname'] . ' ' . $_POST['client_lastname'])); } elseif (!$errors['err']) { $errors['err'] = _('Unable to add the user. Internal error'); }