stdClass PHP Class Code Examples

This page contains top rated real world PHP examples of class stdClass extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: JTwitterPlacesTest.php Project: shoffmann52/install-from-web-server
0
 /**
  * Tests the createPlace method - failure
  *
  * @return  void
  *
  * @since 12.3
  * @expectedException DomainException
  */
 public function testCreatePlaceFailure()
 {
     $lat = 45;
     $long = 45;
     $name = 'Twitter HQ';
     $token = '477ae90717508e4704b0ea150ebc12ba';
     $within = '247f43d441defc03';
     $attribute = '795 Folsom St';
     $callback = 'callback';
     $returnData = new stdClass();
     $returnData->code = 200;
     $returnData->body = $this->rateLimit;
     $path = $this->object->fetchUrl('/application/rate_limit_status.json', array("resources" => "geo"));
     $this->client->expects($this->at(0))->method('get')->with($path)->will($this->returnValue($returnData));
     $returnData = new stdClass();
     $returnData->code = 500;
     $returnData->body = $this->errorString;
     $data['lat'] = $lat;
     $data['long'] = $long;
     $data['name'] = rawurlencode($name);
     $data['token'] = $token;
     $data['contained_within'] = $within;
     $data['attribute:street_address'] = rawurlencode($attribute);
     $data['callback'] = $callback;
     $path = $this->object->fetchUrl('/geo/place.json');
     $this->client->expects($this->at(1))->method('post')->with($path, $data)->will($this->returnValue($returnData));
     $this->object->createPlace($lat, $long, $name, $token, $within, $attribute, $callback);
 }
Example #2
Show file File: JTwitterListsTest.php Project: klas/joomla-cms
0
 /**
  * Tests the deleteList method - failure
  *
  * @param   mixed  $list   Either an integer containing the list ID or a string containing the list slug.
  * @param   mixed  $owner  Either an integer containing the user ID or a string containing the screen name.
  *
  * @return  void
  *
  * @since 12.3
  * @dataProvider seedListStatuses
  * @expectedException DomainException
  */
 public function testDeleteFailure($list, $owner)
 {
     $returnData = new stdClass();
     $returnData->code = 200;
     $returnData->body = $this->rateLimit;
     $path = $this->object->fetchUrl('/application/rate_limit_status.json', array("resources" => "lists"));
     $this->client->expects($this->at(0))->method('get')->with($path)->will($this->returnValue($returnData));
     $returnData = new stdClass();
     $returnData->code = 500;
     $returnData->body = $this->errorString;
     // Set request parameters.
     if (is_numeric($list)) {
         $data['list_id'] = $list;
     } elseif (is_string($list)) {
         $data['slug'] = $list;
         if (is_numeric($owner)) {
             $data['owner_id'] = $owner;
         } elseif (is_string($owner)) {
             $data['owner_screen_name'] = $owner;
         } else {
             // We don't have a valid entry
             $this->setExpectedException('RuntimeException');
             $this->object->delete($list, $owner);
         }
     } else {
         $this->setExpectedException('RuntimeException');
         $this->object->delete($list, $owner);
     }
     $path = $this->object->fetchUrl('/lists/destroy.json');
     $this->client->expects($this->at(1))->method('post')->with($path, $data)->will($this->returnValue($returnData));
     $this->object->delete($list, $owner);
 }
Example #3
Show file File: Languages.php Project: m1has1k/Okay
0
 public function get_description($data, $object)
 {
     if (!in_array($object, array_keys($this->tables))) {
         return false;
     }
     $languages = $this->languages();
     if (empty($languages)) {
         return false;
     }
     $languag = reset($languages);
     $fields = $this->get_fields($this->tables[$object]);
     $intersect = array_intersect($fields, array_keys((array) $data));
     if (!empty($intersect)) {
         $description = new stdClass();
         foreach ($fields as $f) {
             if (isset($data->{$f})) {
                 $description->{$f} = $data->{$f};
             }
             if ($languag->id != $this->lang_id()) {
                 unset($data->{$f});
             }
         }
         $result = new stdClass();
         $result->description = $description;
         return $result;
     }
     return false;
 }
Example #4
Show file File: NoUnusedFragments.php Project: andytruong/graphql-php
0
 public function __invoke(ValidationContext $context)
 {
     $fragmentDefs = [];
     $spreadsWithinOperation = [];
     $fragAdjacencies = new \stdClass();
     $spreadNames = new \stdClass();
     return [Node::OPERATION_DEFINITION => function () use(&$spreadNames, &$spreadsWithinOperation) {
         $spreadNames = new \stdClass();
         $spreadsWithinOperation[] = $spreadNames;
     }, Node::FRAGMENT_DEFINITION => function (FragmentDefinition $def) use(&$fragmentDefs, &$spreadNames, &$fragAdjacencies) {
         $fragmentDefs[] = $def;
         $spreadNames = new \stdClass();
         $fragAdjacencies->{$def->name->value} = $spreadNames;
     }, Node::FRAGMENT_SPREAD => function (FragmentSpread $spread) use(&$spreadNames) {
         $spreadNames->{$spread->name->value} = true;
     }, Node::DOCUMENT => ['leave' => function () use(&$fragAdjacencies, &$spreadsWithinOperation, &$fragmentDefs) {
         $fragmentNameUsed = [];
         foreach ($spreadsWithinOperation as $spreads) {
             $this->reduceSpreadFragments($spreads, $fragmentNameUsed, $fragAdjacencies);
         }
         $errors = [];
         foreach ($fragmentDefs as $def) {
             if (empty($fragmentNameUsed[$def->name->value])) {
                 $errors[] = new Error(self::unusedFragMessage($def->name->value), [$def]);
             }
         }
         return !empty($errors) ? $errors : null;
     }]];
 }
Example #5
Show file File: LCTVAPI.php Project: andtrev/lctv-badges
0
 /**
  * Make an API request/call.
  *
  * @since 0.0.3
  * @access public
  * 
  * @param string $api_path         API endpoint. ex: 'v1/livestreams/'
  * @param int    $cache_expires_in (optional) Override LCTVAPI_CACHE_EXPIRES_IN constant. Default: false
  * @param bool   $cache            (optional) True to cache result, false to not. Default: true
  */
 public function api_request($api_path, $cache_expires_in = false, $cache = true)
 {
     /** Check if we're authorized. */
     if (!$this->is_authorized()) {
         $ret = new stdClass();
         $ret->result->detail = 'LCTVAPI not authorized';
         return $ret;
     }
     /** Setup api request type for data store. */
     $api_request_type = preg_replace("/[^a-zA-Z0-9]+/", "", $api_path);
     /** Attempt to load API request from cache. */
     $api_cache = $this->data_store->get_data($this->user, $api_request_type);
     /** Check for cache expire time override. */
     if ($cache_expires_in !== false) {
         $cache_check = $cache_expires_in;
     } else {
         $cache_check = LCTVAPI_CACHE_EXPIRES_IN;
     }
     /** Make API request call if we have no cache or if cache is expired. */
     if (!isset($api_cache->created_at) || time() - $api_cache->created_at > $cache_check) {
         $headers = array('Cache-Control: no-cache', 'Pragma: no-cache', 'Authorization: ' . $this->token->token_type . ' ' . $this->token->access_token);
         $api_ret = $this->get_url_contents('https://www.livecoding.tv:443/api/' . $api_path, $headers);
         $api_cache = new stdClass();
         $api_cache->result = json_decode($api_ret, false);
         $api_cache->created_at = time();
         if ($cache) {
             $this->data_store->put_data($this->user, $api_request_type, $api_cache);
         }
     }
     return $api_cache;
 }
Example #6
Show file File: JDatabaseDriverPostgresqlTest.php Project: klas/joomla-cms
0
 /**
  * Test loadObjectList method
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testLoadObjectList()
 {
     $query = self::$driver->getQuery(true);
     $query->select('*');
     $query->from('#__dbtest');
     $query->order('id');
     self::$driver->setQuery($query);
     $result = self::$driver->loadObjectList();
     $expected = array();
     $objCompare = new stdClass();
     $objCompare->id = 1;
     $objCompare->title = 'Testing';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'one';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 2;
     $objCompare->title = 'Testing2';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'one';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 3;
     $objCompare->title = 'Testing3';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'three';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 4;
     $objCompare->title = 'Testing4';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'four';
     $expected[] = clone $objCompare;
     $this->assertEquals($expected, $result);
 }
Example #7
Show file File: TimesheetController.php Project: mtday/timesheet-system
0
 /**
  * Retrieve the audit logs for a timesheet.
  */
 function auditAction()
 {
     // Get the id of the timesheet for which audit log information will be
     // retrieved.
     $id = $this->getInt('id');
     // Wrap the whole thing in a try/catch.
     try {
         // Get the DAO.
         $auditLogDao = new AuditLogDao();
         // Make sure the id is valid.
         if (isset($id) && is_numeric($id)) {
             // Retrieve all the audit logs.
             $logs = $auditLogDao->getForTimesheet($id);
             // Create the JSON object to return.
             $json = new stdClass();
             $json->logs = $logs;
             $json->success = true;
             $json->msg = 'The audit log info was retrieved successfully.';
         } else {
             // Create the error JSON object to return.
             $json = new stdClass();
             $json->success = false;
             $json->msg = 'Invalid timesheet id specified.';
         }
     } catch (Zend_Exception $ex) {
         // Create the error JSON object to return.
         $json = new stdClass();
         $json->success = false;
         $json->msg = $ex->getMessage();
     }
     // Return the JSON.
     $this->_helper->json($json);
 }
Example #8
Show file File: CRUDControllerTest.php Project: stuckiest/SymfonyBlog
0
 public function testhistoryCompareRevisionsActionAction()
 {
     $this->request->query->set('id', 123);
     $this->admin->expects($this->once())->method('isGranted')->with($this->equalTo('EDIT'))->will($this->returnValue(true));
     $object = new \stdClass();
     $this->admin->expects($this->once())->method('getObject')->will($this->returnValue($object));
     $this->admin->expects($this->any())->method('getClass')->will($this->returnValue('Foo'));
     $this->auditManager->expects($this->once())->method('hasReader')->with($this->equalTo('Foo'))->will($this->returnValue(true));
     $reader = $this->getMock('Sonata\\AdminBundle\\Model\\AuditReaderInterface');
     $this->auditManager->expects($this->once())->method('getReader')->with($this->equalTo('Foo'))->will($this->returnValue($reader));
     $objectRevision = new \stdClass();
     $objectRevision->revision = 456;
     $compareObjectRevision = new \stdClass();
     $compareObjectRevision->revision = 789;
     $reader->expects($this->at(0))->method('find')->with($this->equalTo('Foo'), $this->equalTo(123), $this->equalTo(456))->will($this->returnValue($objectRevision));
     $reader->expects($this->at(1))->method('find')->with($this->equalTo('Foo'), $this->equalTo(123), $this->equalTo(789))->will($this->returnValue($compareObjectRevision));
     $this->admin->expects($this->once())->method('setSubject')->with($this->equalTo($objectRevision))->will($this->returnValue(null));
     $fieldDescriptionCollection = new FieldDescriptionCollection();
     $this->admin->expects($this->once())->method('getShow')->will($this->returnValue($fieldDescriptionCollection));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $this->controller->historyCompareRevisionsAction(123, 456, 789));
     $this->assertSame($this->admin, $this->parameters['admin']);
     $this->assertSame('SonataAdminBundle::standard_layout.html.twig', $this->parameters['base_template']);
     $this->assertSame($this->pool, $this->parameters['admin_pool']);
     $this->assertSame('show', $this->parameters['action']);
     $this->assertSame($objectRevision, $this->parameters['object']);
     $this->assertSame($compareObjectRevision, $this->parameters['object_compare']);
     $this->assertSame($fieldDescriptionCollection, $this->parameters['elements']);
     $this->assertSame(array(), $this->session->getFlashBag()->all());
     $this->assertSame('SonataAdminBundle:CRUD:show_compare.html.twig', $this->template);
 }
Example #9
Show file File: pagetypes_test.php Project: evltuma/moodle
0
 public function test_lesson_essay_extract_useranswer()
 {
     // Test that reponseformat is added when not present.
     $answer = 'O:8:"stdClass":6:{s:4:"sent";i:1;s:6:"graded";i:1;s:5:"score";s:1:"1";' . 's:6:"answer";s:64:"<p>This is my answer <b>with bold</b> and <i>italics</i><br></p>";' . 's:12:"answerformat";s:1:"1";s:8:"response";s:10:"Well done!";}';
     $userresponse = new stdClass();
     $userresponse->sent = 1;
     $userresponse->graded = 1;
     $userresponse->score = 1;
     $userresponse->answer = "<p>This is my answer <b>with bold</b> and <i>italics</i><br></p>";
     $userresponse->answerformat = FORMAT_HTML;
     $userresponse->response = "Well done!";
     $userresponse->responseformat = FORMAT_HTML;
     $this->assertEquals($userresponse, lesson_page_type_essay::extract_useranswer($answer));
     // Test that reponseformat is not modified when present.
     $answer = 'O:8:"stdClass":7:{s:4:"sent";i:0;s:6:"graded";i:1;s:5:"score";s:1:"0";' . 's:6:"answer";s:64:"<p>This is my answer <b>with bold</b> and <i>italics</i><br></p>";' . 's:12:"answerformat";s:1:"1";s:8:"response";s:10:"Well done!";s:14:"responseformat";s:1:"2";}';
     $userresponse = new stdClass();
     $userresponse->sent = 0;
     $userresponse->graded = 1;
     $userresponse->score = 0;
     $userresponse->answer = "<p>This is my answer <b>with bold</b> and <i>italics</i><br></p>";
     $userresponse->answerformat = FORMAT_HTML;
     $userresponse->response = "Well done!";
     $userresponse->responseformat = FORMAT_PLAIN;
     $this->assertEquals($userresponse, lesson_page_type_essay::extract_useranswer($answer));
 }
Example #10
Show file File: github.php Project: RinkuArnob/wp-envato-market
0
 /**
  * @see Envato_Market_Github::update_plugins()
  */
 function test_update_plugins()
 {
     $transient = new stdClass();
     $api = new stdClass();
     $api->name = 'Envato Market';
     $api->slug = 'envato-market';
     $api->version = '10.0.0';
     $api->download_link = 'https://envato.github.io/wp-envato-market/dist/envato-market.zip';
     $this->assertEquals($transient, $this->github->update_plugins($transient));
     $mock = $this->getMockBuilder('Envato_Market_Github')->setMethods(array('api_check', 'state'))->disableOriginalConstructor()->getMock();
     $mock->expects($this->any())->method('api_check')->will($this->returnValue($api));
     $mock->expects($this->any())->method('state')->will($this->returnValue('activated'));
     // Replace private _instance reference with mock object
     $ref = new ReflectionProperty('Envato_Market_Github', '_instance');
     $ref->setAccessible(true);
     $ref->setValue(null, $mock);
     $this->assertEquals($api, $mock->api_check());
     $this->assertEquals('activated', $mock->state());
     $transient = $mock->update_plugins($transient);
     $this->assertObjectHasAttribute('slug', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('plugin', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('new_version', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('url', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('package', $transient->response['envato-market/envato-market.php']);
     $this->assertEquals('10.0.0', $transient->response['envato-market/envato-market.php']->new_version);
     $ref = new ReflectionProperty('Envato_Market_Github', '_instance');
     $ref->setAccessible(true);
     $ref->setValue(null, null);
 }
Example #11
Show file File: outputcomponents.php Project: sumitnegi933/Moodle_lms_New
0
 /**
  * Extract the aliased user fields from a given record
  *
  * Given a record that was previously obtained using {@link self::fields()} with aliases,
  * this method extracts user related unaliased fields.
  *
  * @param stdClass $record containing user picture fields
  * @param array $extrafields extra fields included in the $record
  * @param string $idalias alias of the id field
  * @param string $fieldprefix prefix added to all columns in their aliases, does not apply to 'id'
  * @return stdClass object with unaliased user fields
  */
 public static function unalias(stdClass $record, array $extrafields = null, $idalias = 'id', $fieldprefix = '')
 {
     if (empty($idalias)) {
         $idalias = 'id';
     }
     $return = new stdClass();
     foreach (self::$fields as $field) {
         if ($field === 'id') {
             if (property_exists($record, $idalias)) {
                 $return->id = $record->{$idalias};
             }
         } else {
             if (property_exists($record, $fieldprefix . $field)) {
                 $return->{$field} = $record->{$fieldprefix . $field};
             }
         }
     }
     // add extra fields if not already there
     if ($extrafields) {
         foreach ($extrafields as $e) {
             if ($e === 'id' or property_exists($return, $e)) {
                 continue;
             }
             $return->{$e} = $record->{$fieldprefix . $e};
         }
     }
     return $return;
 }
Example #12
Show file File: attempt_test.php Project: evltuma/moodle
0
 /**
  * Set a fake page layout. Used when we test URL generation.
  * @param int $id assumed attempt id.
  * @param string $layout layout to set. Like quiz attempt.layout. E.g. '1,2,0,3,4,0,'.
  * @param array $infos slot numbers which contain 'descriptions', or other non-questions.
  * @return quiz_attempt attempt object for use in unit tests.
  */
 public static function setup_fake_attempt_layout($id, $layout, $infos = array())
 {
     $attempt = new stdClass();
     $attempt->id = $id;
     $attempt->layout = $layout;
     $course = new stdClass();
     $quiz = new stdClass();
     $cm = new stdClass();
     $cm->id = 0;
     $attemptobj = new self($attempt, $quiz, $cm, $course, false);
     $attemptobj->slots = array();
     foreach (explode(',', $layout) as $slot) {
         if ($slot == 0) {
             continue;
         }
         $attemptobj->slots[$slot] = new stdClass();
         $attemptobj->slots[$slot]->slot = $slot;
         $attemptobj->slots[$slot]->requireprevious = 0;
         $attemptobj->slots[$slot]->questionid = 0;
     }
     $attemptobj->sections = array();
     $attemptobj->sections[0] = new stdClass();
     $attemptobj->sections[0]->heading = '';
     $attemptobj->sections[0]->firstslot = 1;
     $attemptobj->sections[0]->shufflequestions = 0;
     $attemptobj->infos = $infos;
     $attemptobj->link_sections_and_slots();
     $attemptobj->determine_layout();
     $attemptobj->number_questions();
     return $attemptobj;
 }
/**
 * Retrieve URL headers and content using WP HTTP Request API.
 *
 * @since 1.5.0
 * @package External
 * @subpackage MagpieRSS
 *
 * @param string $url URL to retrieve
 * @param array $headers Optional. Headers to send to the URL.
 * @return Snoopy style response
 */
function _fetch_remote_file($url, $headers = "")
{
    $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
    if (is_wp_error($resp)) {
        $error = array_shift($resp->errors);
        $resp = new stdClass();
        $resp->status = 500;
        $resp->response_code = 500;
        $resp->error = $error[0] . "\n";
        //\n = Snoopy compatibility
        return $resp;
    }
    // Snoopy returns headers unprocessed.
    // Also note, WP_HTTP lowercases all keys, Snoopy did not.
    $return_headers = array();
    foreach ($resp['headers'] as $key => $value) {
        if (!is_array($value)) {
            $return_headers[] = "{$key}: {$value}";
        } else {
            foreach ($value as $v) {
                $return_headers[] = "{$key}: {$v}";
            }
        }
    }
    $response = new stdClass();
    $response->status = $resp['response']['code'];
    $response->response_code = $resp['response']['code'];
    $response->headers = $return_headers;
    $response->results = $resp['body'];
    return $response;
}
Example #14
Show file File: coursecatlib.php Project: janaece/globalclassroom4_clean
0
 /**
  * Returns list of course contacts (usually teachers) to display in course link
  *
  * Roles to display are set up in $CFG->coursecontact
  *
  * The result is the list of users where user id is the key and the value
  * is an array with elements:
  *  - 'user' - object containing basic user information
  *  - 'role' - object containing basic role information (id, name, shortname, coursealias)
  *  - 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS)
  *  - 'username' => fullname($user, $canviewfullnames)
  *
  * @return array
  */
 public function get_course_contacts()
 {
     global $CFG;
     if (empty($CFG->coursecontact)) {
         // No roles are configured to be displayed as course contacts.
         return array();
     }
     if ($this->coursecontacts === null) {
         $this->coursecontacts = array();
         $context = context_course::instance($this->id);
         if (!isset($this->record->managers)) {
             // Preload course contacts from DB.
             $courses = array($this->id => &$this->record);
             coursecat::preload_course_contacts($courses);
         }
         // Build return array with full roles names (for this course context) and users names.
         $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
         foreach ($this->record->managers as $ruser) {
             if (isset($this->coursecontacts[$ruser->id])) {
                 // Only display a user once with the highest sortorder role.
                 continue;
             }
             $user = new stdClass();
             $user = username_load_fields_from_object($user, $ruser, null, array('id', 'username'));
             $role = new stdClass();
             $role->id = $ruser->roleid;
             $role->name = $ruser->rolename;
             $role->shortname = $ruser->roleshortname;
             $role->coursealias = $ruser->rolecoursealias;
             $this->coursecontacts[$user->id] = array('user' => $user, 'role' => $role, 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS), 'username' => fullname($user, $canviewfullnames));
         }
     }
     return $this->coursecontacts;
 }
Example #15
Show file File: questiontype.php Project: evltuma/moodle
0
 public function save_question_options($question)
 {
     global $DB;
     if (2 > $question->choose) {
         $result = new stdClass();
         $result->error = "At least two shortanswer questions need to be chosen!";
         return $result;
     }
     $context = $question->context;
     // Save the question options.
     $options = $DB->get_record('qtype_randomsamatch_options', array('questionid' => $question->id));
     if (!$options) {
         $options = new stdClass();
         $options->questionid = $question->id;
         $options->correctfeedback = '';
         $options->partiallycorrectfeedback = '';
         $options->incorrectfeedback = '';
         $options->id = $DB->insert_record('qtype_randomsamatch_options', $options);
     }
     $options->choose = $question->choose;
     $options->subcats = $question->subcats;
     $options = $this->save_combined_feedback_helper($options, $question, $context, true);
     $DB->update_record('qtype_randomsamatch_options', $options);
     $this->save_hints($question, true);
     return true;
 }
Example #16
Show file File: rrule_manager_tests.php Project: evltuma/moodle
0
 /**
  * Set up method.
  */
 protected function setUp()
 {
     global $DB, $CFG;
     $this->resetAfterTest();
     $this->setTimezone('Australia/Perth');
     $user = $this->getDataGenerator()->create_user();
     $sub = new stdClass();
     $sub->url = '';
     $sub->courseid = 0;
     $sub->groupid = 0;
     $sub->userid = $user->id;
     $sub->pollinterval = 0;
     $subid = $DB->insert_record('event_subscriptions', $sub, true);
     $event = new stdClass();
     $event->name = 'Event name';
     $event->description = '';
     $event->timestart = 1385913700;
     // A 2013-12-2 Monday event.
     $event->timeduration = 3600;
     $event->uuid = 'uuid';
     $event->subscriptionid = $subid;
     $event->userid = $user->id;
     $event->groupid = 0;
     $event->courseid = 0;
     $event->eventtype = 'user';
     $eventobj = calendar_event::create($event, false);
     $DB->set_field('event', 'repeatid', $eventobj->id, array('id' => $eventobj->id));
     $eventobj->repeatid = $eventobj->id;
     $this->event = $eventobj;
 }
Example #17
Show file File: ObjectCommand.php Project: phogl/autoloader
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->soapClient = new SoapClient('http://localhost/wsdl-creator/examples/rpc_encoded/ObjectExampleSoapServer.php?wsdl', array('uri' => "http://foo.bar/", 'location' => 'http://localhost/wsdl-creator/examples/rpc_encoded/ObjectExampleSoapServer.php', 'trace' => true, 'cache_wsdl' => WSDL_CACHE_NONE));
     $this->serviceInfo('Client Object - rpc/encoded');
     $this->renderMethodsTable();
     $user = new stdClass();
     $user->name = 'john';
     $user->age = 32;
     $response = $this->soapClient->userInfo($user);
     $this->method('userInfo', array($user), $response);
     $response = $this->soapClient->getAgentWithId('peter', 999444);
     $this->method('getAgentWithId', array('peter', 999444), $response);
     $namesInfo = new stdClass();
     $namesInfo->names = array('billy', 'clark');
     $namesInfo->id = 333;
     $response = $this->soapClient->namesForId($namesInfo);
     $this->method('namesForId', array($namesInfo), $response);
     $response = $this->soapClient->getCompanies();
     $this->method('getCompanies', array(), $response);
     $response = $this->soapClient->getListOfAgentsWithId();
     $this->method('getListOfAgentsWithId', array(), $response);
     $payments[0] = new stdClass();
     $payments[0]->payment = array(1.21, 3.21, 100.6);
     $payments[0]->user = 'john';
     $payments[1] = new stdClass();
     $payments[1]->payment = array(120.6);
     $payments[1]->user = 'peter';
     $response = $this->soapClient->setPayment($payments);
     $this->method('setPayment', array($payments), $response);
     $response = $this->soapClient->getAgentsWithPayment();
     $this->method('getAgentsWithPayment', array(), $response);
     $response = $this->soapClient->getEmployeesWithAgents();
     $this->method('getEmployeesWithAgents', array(), $response);
 }
Example #18
Show file File: JDatabaseDriverPdomysqlTest.php Project: joomla-projects/media-manager-improvement
0
 /**
  * Test loadObjectList method
  *
  * @return  void
  *
  * @since   3.4
  */
 public function testLoadObjectList()
 {
     $query = self::$driver->getQuery(true);
     $query->select('*');
     $query->from('#__dbtest');
     $query->order('id');
     self::$driver->setQuery($query);
     $result = self::$driver->loadObjectList();
     $expected = array();
     $objCompare = new stdClass();
     $objCompare->id = 1;
     $objCompare->title = 'Testing';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'one';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 2;
     $objCompare->title = 'Testing2';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'one';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 3;
     $objCompare->title = 'Testing3';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'three';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 4;
     $objCompare->title = 'Testing4';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'four';
     $expected[] = clone $objCompare;
     $this->assertThat($result, $this->equalTo($expected), __LINE__);
 }
Example #19
Show file File: lib.php Project: jeffthestampede/excelsior
0
 /**
  * Returns an array of user profile fields to be included in export
  *
  * @param int $courseid
  * @param bool $includecustomfields
  * @return array An array of stdClass instances with customid, shortname, datatype, default and fullname fields
  */
 public static function get_user_profile_fields($courseid, $includecustomfields = false)
 {
     global $CFG, $DB;
     // Gets the fields that have to be hidden
     $hiddenfields = array_map('trim', explode(',', $CFG->hiddenuserfields));
     $context = context_course::instance($courseid);
     $canseehiddenfields = has_capability('moodle/course:viewhiddenuserfields', $context);
     if ($canseehiddenfields) {
         $hiddenfields = array();
     }
     $fields = array();
     require_once $CFG->dirroot . '/user/lib.php';
     // Loads user_get_default_fields()
     require_once $CFG->dirroot . '/user/profile/lib.php';
     // Loads constants, such as PROFILE_VISIBLE_ALL
     $userdefaultfields = user_get_default_fields();
     // Sets the list of profile fields
     $userprofilefields = array_map('trim', explode(',', $CFG->grade_export_userprofilefields));
     if (!empty($userprofilefields)) {
         foreach ($userprofilefields as $field) {
             $field = trim($field);
             if (in_array($field, $hiddenfields) || !in_array($field, $userdefaultfields)) {
                 continue;
             }
             $obj = new stdClass();
             $obj->customid = 0;
             $obj->shortname = $field;
             $obj->fullname = get_string($field);
             $fields[] = $obj;
         }
     }
     // Sets the list of custom profile fields
     $customprofilefields = array_map('trim', explode(',', $CFG->grade_export_customprofilefields));
     if ($includecustomfields && !empty($customprofilefields)) {
         list($wherefields, $whereparams) = $DB->get_in_or_equal($customprofilefields);
         $customfields = $DB->get_records_sql("SELECT f.*\n                                                    FROM {user_info_field} f\n                                                    JOIN {user_info_category} c ON f.categoryid=c.id\n                                                    WHERE f.shortname {$wherefields}\n                                                    ORDER BY c.sortorder ASC, f.sortorder ASC", $whereparams);
         foreach ($customfields as $field) {
             // Make sure we can display this custom field
             if (!in_array($field->shortname, $customprofilefields)) {
                 continue;
             } else {
                 if (in_array($field->shortname, $hiddenfields)) {
                     continue;
                 } else {
                     if ($field->visible != PROFILE_VISIBLE_ALL && !$canseehiddenfields) {
                         continue;
                     }
                 }
             }
             $obj = new stdClass();
             $obj->customid = $field->id;
             $obj->shortname = $field->shortname;
             $obj->fullname = format_string($field->name);
             $obj->datatype = $field->datatype;
             $obj->default = $field->defaultdata;
             $fields[] = $obj;
         }
     }
     return $fields;
 }
Example #20
Show file File: completionlib_test.php Project: janaece/globalclassroom4_clean
0
 public function test_internal_get_grade_state()
 {
     $this->mock_setup();
     $item = new stdClass();
     $grade = new stdClass();
     $item->gradepass = 4;
     $item->hidden = 0;
     $grade->rawgrade = 4.0;
     $grade->finalgrade = null;
     // Grade has pass mark and is not hidden,  user passes.
     $this->assertEquals(COMPLETION_COMPLETE_PASS, completion_info::internal_get_grade_state($item, $grade));
     // Same but user fails.
     $grade->rawgrade = 3.9;
     $this->assertEquals(COMPLETION_COMPLETE_FAIL, completion_info::internal_get_grade_state($item, $grade));
     // User fails on raw grade but passes on final.
     $grade->finalgrade = 4.0;
     $this->assertEquals(COMPLETION_COMPLETE_PASS, completion_info::internal_get_grade_state($item, $grade));
     // Item is hidden.
     $item->hidden = 1;
     $this->assertEquals(COMPLETION_COMPLETE, completion_info::internal_get_grade_state($item, $grade));
     // Item isn't hidden but has no pass mark.
     $item->hidden = 0;
     $item->gradepass = 0;
     $this->assertEquals(COMPLETION_COMPLETE, completion_info::internal_get_grade_state($item, $grade));
 }
Example #21
Show file File: Stats.php Project: onedaylabs/onedaylabs.com
0
 public function get_scheduled($stats, $options = array())
 {
     $numberOfItems = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
     $scheduledItems = array();
     if (!$numberOfItems) {
         return $stats;
     }
     $scheduledPosts = get_posts('post_status=future&numberposts=' . $numberOfItems . '&orderby=post_date&order=desc');
     foreach ($scheduledPosts as $id => $scheduledPost) {
         $recentPost = new stdClass();
         $recentPost->post_permalink = get_permalink($scheduledPost->ID);
         $recentPost->ID = $scheduledPost->ID;
         $recentPost->post_date = $scheduledPost->post_date;
         $recentPost->post_type = $scheduledPost->post_type;
         $recentPost->post_title = $scheduledPost->post_title;
         $scheduledItems[] = $recentPost;
     }
     $scheduledPages = get_pages('post_status=future&numberposts=' . $numberOfItems . '&orderby=post_date&order=desc');
     foreach ((array) $scheduledPages as $id => $scheduledPage) {
         $recentPage = new stdClass();
         $recentPage->post_permalink = get_permalink($scheduledPage->ID);
         $recentPage->ID = $scheduledPage->ID;
         $recentPage->post_type = $scheduledPage->post_type;
         $recentPage->post_date = $scheduledPage->post_date;
         $recentPage->post_title = $scheduledPage->post_title;
         $scheduledItems[] = $recentPage;
     }
     if (!empty($scheduledItems)) {
         usort($scheduledItems, array($this, 'cmp_posts_worker'));
         $stats['scheduled'] = array_slice($scheduledItems, 0, $numberOfItems);
     }
     return $stats;
 }
Example #22
Show file File: endofcluster.php Project: evltuma/moodle
0
 public function construction_override($pageid, lesson $lesson)
 {
     global $CFG, $PAGE, $DB;
     require_sesskey();
     $timenow = time();
     // the new page is not the first page (end of cluster always comes after an existing page)
     if (!($page = $DB->get_record("lesson_pages", array("id" => $pageid)))) {
         print_error('cannotfindpages', 'lesson');
     }
     // could put code in here to check if the user really can insert an end of cluster
     $newpage = new stdClass();
     $newpage->lessonid = $lesson->id;
     $newpage->prevpageid = $pageid;
     $newpage->nextpageid = $page->nextpageid;
     $newpage->qtype = $this->qtype;
     $newpage->timecreated = $timenow;
     $newpage->title = get_string("endofclustertitle", "lesson");
     $newpage->contents = get_string("endofclustertitle", "lesson");
     $newpageid = $DB->insert_record("lesson_pages", $newpage);
     // update the linked list...
     $DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
     if ($page->nextpageid) {
         // the new page is not the last page
         $DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
     }
     // ..and the single "answer"
     $newanswer = new stdClass();
     $newanswer->lessonid = $lesson->id;
     $newanswer->pageid = $newpageid;
     $newanswer->timecreated = $timenow;
     $newanswer->jumpto = LESSON_NEXTPAGE;
     $newanswerid = $DB->insert_record("lesson_answers", $newanswer);
     $lesson->add_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess');
     redirect($CFG->wwwroot . '/mod/lesson/edit.php?id=' . $PAGE->cm->id);
 }
Example #23
Show file File: renderer.php Project: rushi963/moodle
0
 /**
 * Returns HTML to display one remote course
 *
 * @param stdClass $course remote course information, contains properties:
       id, remoteid, shortname, fullname, hostid, summary, summaryformat, cat_name, hostname
 * @return string
 */
 protected function frontpage_remote_course(stdClass $course)
 {
     $url = new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid));
     $output = '';
     $output .= html_writer::start_tag('div', array('class' => 'coursebox remotecoursebox clearfix'));
     $output .= html_writer::start_tag('div', array('class' => 'info'));
     $output .= html_writer::start_tag('h3', array('class' => 'name'));
     $output .= html_writer::link($url, format_string($course->fullname), array('title' => get_string('entercourse')));
     $output .= html_writer::end_tag('h3');
     // .name
     $output .= html_writer::tag('div', '', array('class' => 'moreinfo'));
     $output .= html_writer::end_tag('div');
     // .info
     $output .= html_writer::start_tag('div', array('class' => 'content'));
     $output .= html_writer::start_tag('div', array('class' => 'summary'));
     $options = new stdClass();
     $options->noclean = true;
     $options->para = false;
     $options->overflowdiv = true;
     $output .= format_text($course->summary, $course->summaryformat, $options);
     $output .= html_writer::end_tag('div');
     // .summary
     $addinfo = format_string($course->hostname) . ' : ' . format_string($course->cat_name) . ' : ' . format_string($course->shortname);
     $output .= html_writer::tag('div', $addinfo, array('class' => 'remotecourseinfo'));
     $output .= html_writer::end_tag('div');
     // .content
     $output .= html_writer::end_tag('div');
     // .coursebox
     return $output;
 }
Example #24
Show file File: JFormFieldCheckboxesTest.php Project: shoffmann52/install-from-web-server
0
 /**
  * Test the getOptions method.
  *
  * @since       12.2
  *
  * @return void
  */
 public function testGetOptions()
 {
     $formFieldCheckboxes = new JFormFieldCheckboxes();
     $option1 = new stdClass();
     $option1->value = 'yellow';
     $option1->text = 'yellow';
     $option1->disable = true;
     $option1->class = '';
     $option1->onclick = '';
     $option1->checked = false;
     $option1->onchange = '';
     $option2 = new stdClass();
     $option2->value = 'green';
     $option2->text = 'green';
     $option2->disable = false;
     $option2->class = '';
     $option2->onclick = '';
     $option2->checked = true;
     $option2->onchange = '';
     $optionsExpected = array($option1, $option2);
     // Test with two values checked, no checked element
     TestReflection::setValue($formFieldCheckboxes, 'element', simplexml_load_string('<field name="color" type="checkboxes">
<option value="yellow" disabled="true">yellow</option>
<option value="green" checked="true">green</option>
</field>'));
     $this->assertEquals($optionsExpected, TestReflection::invoke($formFieldCheckboxes, 'getOptions'), 'The field with two values did not produce the right options');
 }
Example #25
Show file File: ckvmcategory.php Project: bobozhangshao/HeartCare
0
 protected function getOptions()
 {
     // if VM is not installed
     if (!JFolder::exists(JPATH_ROOT . '/administrator/components/com_virtuemart') or !class_exists('ShopFunctions')) {
         // add the root item
         $option = new stdClass();
         $option->text = JText::_('MOD_ACCORDEONCK_VIRTUEMART_NOTFOUND');
         $option->value = '0';
         $options[] = $option;
         // Merge any additional options in the XML definition.
         $options = array_merge(parent::getOptions(), $options);
         return $options;
     }
     VmConfig::loadConfig();
     $categorylist = ShopFunctions::categoryListTree();
     // $categorylist = 'testced';
     $categorylist = trim($categorylist, '</option>');
     $categorylist = explode("</option><option", $categorylist);
     // add the root item
     $option = new stdClass();
     $option->text = JText::_('MOD_ACCORDEONCK_VIRTUEMART_ROOTNODE');
     $option->value = '0';
     $options[] = $option;
     foreach ($categorylist as $cat) {
         $option = new stdClass();
         $text = explode(">", $cat);
         $option->text = trim($text[1]);
         $option->value = strval(trim(trim(trim($text[0]), '"'), 'value="'));
         $options[] = $option;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #26
Show file File: rss.php Project: RA2WP/RA2WP
0
/**
 * Retrieve URL headers and content using WP HTTP Request API.
 *
 * @since 1.5.0
 * @package External
 * @subpackage MagpieRSS
 *
 * @param string $url URL to retrieve
 * @param array $headers Optional. Headers to send to the URL.
 * @return Snoopy style response
 */
function _fetch_remote_file($url, $headers = "")
{
    $resp = wp_safe_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
    if (is_wp_error($resp)) {
        $error = array_shift($resp->errors);
        $resp = new stdClass();
        $resp->status = 500;
        $resp->response_code = 500;
        $resp->error = $error[0] . "\n";
        //\n = Snoopy compatibility
        return $resp;
    }
    // Snoopy returns headers unprocessed.
    // Also note, WP_HTTP lowercases all keys, Snoopy did not.
    $return_headers = array();
    foreach (wp_remote_retrieve_headers($resp) as $key => $value) {
        if (!is_array($value)) {
            $return_headers[] = "{$key}: {$value}";
        } else {
            foreach ($value as $v) {
                $return_headers[] = "{$key}: {$v}";
            }
        }
    }
    $response = new stdClass();
    $response->status = wp_remote_retrieve_response_code($resp);
    $response->response_code = wp_remote_retrieve_response_code($resp);
    $response->headers = $return_headers;
    $response->results = wp_remote_retrieve_body($resp);
    return $response;
}
Example #27
Show file File: CacheTest.php Project: dasatti/dashboard
0
 public function getSetDelete($cache)
 {
     $cache->set('foo', 'bar');
     $cache->delete('foo');
     $this->assertEquals(false, $cache->get('foo'));
     $cache->set('foo.1', 'bar.1');
     $cache->delete('foo.1');
     $this->assertEquals($cache->get('foo.1'), false);
     $cache->set('foo', 'baz');
     $cache->delete('foo');
     $this->assertEquals($cache->get('foo'), false);
     $cache->set('foo', null);
     $cache->delete('foo');
     $this->assertEquals($cache->get('foo'), false);
     $obj = new stdClass();
     $obj->foo = 'bar';
     $cache->set('foo', $obj);
     $cache->delete('foo');
     $this->assertEquals($cache->get('foo'), false);
     $cache->set('foo.1', 'bar.1');
     $this->assertEquals($cache->get('foo.1'), 'bar.1');
     $cache->set('foo', 'baz');
     $this->assertEquals($cache->get('foo'), 'baz');
     $cache->set('foo', null);
     $this->assertEquals($cache->get('foo'), null);
     $cache->set('1/2/3', 'bar');
     $this->assertEquals($cache->get('1/2/3'), 'bar');
     $obj = new stdClass();
     $obj->foo = 'bar';
     $cache->set('foo', $obj);
     $this->assertEquals($cache->get('foo'), $obj);
 }
Frequently Used Methods