public function testRemove() { $this->container->set('a', function () { return stdClass(); }); $this->assertTrue($this->container->remove('a')); }
/** * activate_component() * * Mimics the activation of Courseware as a BuddyPress component for groups */ function activate_component() { global $bp; if (!isset($bp->courseware) || !is_object($bp->courseware)) { $bp->courseware = stdClass(); } $bp->courseware->id = 'courseware'; $bp->courseware->slug = 'courseware'; $bp->active_components[$bp->courseware->slug] = $bp->courseware->id; }
public function archive($paths) { $archive_file = $this->getUserDir($paths->target); // var_dump('arch path', $this->workdir.$paths['archive'], $archive_file); $options = is_null($paths->mode) ? stdClass() : $paths->mode; if (!isset($options->type) || !isset(Helper::$config['archive']['types'][$options->type])) { throw new Exception("invalid type", 1); } //$files = array_map(array($this, 'getJailPath'), (array)$paths->fls); $files = (array) $paths->fls; //var_dump($paths->fls, $file); $fs = Fs::get(); if ($fs->isFile($archive_file)) { throw new Exception("dest is file", 16); } $options->workdir = $this->workdir; $archive = new Archive($archive_file); $archive->setOptions((array) $options); return $archive->create($files); }
public function __construct($imageId, $keyName = null, $groupSet = null, $userData = null, $addressingType = null, $instanceType = null, $placement = null, $kernelId = null, $ramdiskId = null, BlockDeviceMappingType $blockDeviceMapping = null, $monitoring = null, $subnetId = null) { $this->imageId = $imageId; $this->keyName = $keyName; $this->addressingType = $addressingType; $this->instanceType = $instanceType; $this->kernelId = $kernelId; $this->ramdiskId = $ramdiskId; $this->subnetId = $subnetId; if (isset($userData)) { $this->userData = new stdClass(); $this->userData->data = $userData; } if (isset($blockDeviceMapping)) { $this->blockDeviceMapping = stdClass(); $this->blockDeviceMapping->item = array(); foreach ($blockDeviceMapping as $item) { $this->blockDeviceMapping->item[] = $item; } } if (isset($placement)) { $this->placement = new stdClass(); $this->placement->availabilityZone = $placement; } if (isset($monitoring)) { $this->monitoring = new stdClass(); $this->monitoring->enabled = $monitoring; } if (isset($groupSet)) { $this->groupSet = new stdClass(); $this->groupSet->item = array(); foreach ($groupSet as $id) { $this->groupSet->item[]->groupId = $id; } } }
public function __construct($name, $pool_type, $port, $coin_daemon = NULL) { $this->name = $name; $this->pool_type = $pool_type; $this->port = $port; if ($coin_daemon === NULL) { $this->coin_daemon = stdClass(); } else { $this->coin_daemon = (object) $coin_daemon; } }
//we have the framework now //save mpesa code $vars = JFactory::getApplication()->input; if (!empty($vars->get('mpesa_code'))) { //only if mpesa code is found $user = JFactory::getUser(); $db = JFactory::getDBO(); $mpesa = new stdClass(); $mpesa->id = NULL; $mpesa->t_id = strtoupper($vars->get('mpesa_code')); $mpesa->order_id = $vars->get('ORDERID'); $mpesa->t_date = date('d-m-Y', time()); $mpesa->name = $user->name; $mpesa->email = $user->email; $mpesa->time = time(); if ($db->insertObject('#__mpesa', $mpesa, 'id')) { $order = stdClass(); $order->order_id = $vars->get('ORDERID'); $order->mpesa_code = strtoupper($vars->get('mpesa_code')); if ($db->updateObject('#__hikashop_order', $order, 'order_id')) { $app->redirect('index.php', 'Payment saved Successfully. '); echo ' Payment saving Successfull '; } else { $app->redirect('index.php', 'Payment not saved. Contact Support'); } } else { echo ' Error '; } } else { $app->redirect('index.php', ' check parameters !'); }
/** * Build one 1-activity backup */ protected static function build_activity_plan($controller, $id) { $plan = $controller->get_plan(); // Add the activity task, responsible for outputting // all the module related information try { $plan->add_task(backup_factory::get_backup_activity_task($controller->get_format(), $id)); // For the given activity, add as many block tasks as necessary $blockids = backup_plan_dbops::get_blockids_from_moduleid($id); foreach ($blockids as $blockid) { try { $plan->add_task(backup_factory::get_backup_block_task($controller->get_format(), $blockid, $id)); } catch (backup_task_exception $e) { $a = stdClass(); $a->mid = $id; $a->bid = $blockid; $controller->log(get_string('error_block_for_module_not_found', 'backup', $a), backup::LOG_WARNING); } } } catch (backup_task_exception $e) { $controller->log(get_string('error_course_module_not_found', 'backup', $id), backup::LOG_WARNING); } }
/** * Create and append a new review * @param array $review Multidimensionnal array to create a review (see http://schema.org/Review) * @return void */ public function product_snippet_review($review) { if (empty($this->product)) { $this->create_product(); $this->product->review = array(); } if (!is_array($review)) { show_error($this->ci->lang->line('schema_array_only')); die; } $newReview = stdClass(); $newReview->{'@type'} = 'Review'; foreach ($review as $name => $value) { if (!is_array($value)) { $newReview->{$name} = $value; } else { $newReview->{$name} = new stdClass(); $newReview->{$name} = json_decode(json_encode($value), FALSE); } } $this->product->review[] = $newReview; }
/** * @global object * @param int $formanswer * @param object $choice * @param int $userid * @param object $course Course object * @param object $cm */ function choice_user_submit_response($formanswer, $choice, $userid, $course, $cm) { global $DB, $CFG; require_once($CFG->libdir.'/completionlib.php'); $current = $DB->get_record('choice_answers', array('choiceid' => $choice->id, 'userid' => $userid)); $context = get_context_instance(CONTEXT_MODULE, $cm->id); $countanswers=0; if($choice->limitanswers) { // Find out whether groups are being used and enabled if (groups_get_activity_groupmode($cm) > 0) { $currentgroup = groups_get_activity_group($cm); } else { $currentgroup = 0; } if($currentgroup) { // If groups are being used, retrieve responses only for users in // current group global $CFG; $answers = $DB->get_records_sql(" SELECT ca.* FROM {choice_answers} ca INNER JOIN {groups_members} gm ON ca.userid=gm.userid WHERE optionid=? AND gm.groupid=?", array($formanswer, $currentgroup)); } else { // Groups are not used, retrieve all answers for this option ID $answers = $DB->get_records("choice_answers", array("optionid" => $formanswer)); } if ($answers) { foreach ($answers as $a) { //only return enrolled users. if (is_enrolled($context, $a->userid, 'mod/choice:choose')) { $countanswers++; } } } $maxans = $choice->maxanswers[$formanswer]; } if (!($choice->limitanswers && ($countanswers >= $maxans) )) { if ($current) { $newanswer = $current; $newanswer->optionid = $formanswer; $newanswer->timemodified = time(); $DB->update_record("choice_answers", $newanswer); add_to_log($course->id, "choice", "choose again", "view.php?id=$cm->id", $choice->id, $cm->id); } else { $newanswer = stdClass(); $newanswer->choiceid = $choice->id; $newanswer->userid = $userid; $newanswer->optionid = $formanswer; $newanswer->timemodified = time(); $DB->insert_record("choice_answers", $newanswer); // Update completion state $completion = new completion_info($course); if ($completion->is_enabled($cm) && $choice->completionsubmit) { $completion->update_state($cm, COMPLETION_COMPLETE); } add_to_log($course->id, "choice", "choose", "view.php?id=$cm->id", $choice->id, $cm->id); } } else { if (!($current->optionid==$formanswer)) { //check to see if current choice already selected - if not display error print_error('choicefull', 'choice'); } } }
public function __construct() { $this->device = \stdClass(); $this->device->buffer = ''; }