You are here

class CourseObjectUbercart in Course 7

Same name and namespace in other branches
  1. 8.3 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart
  2. 8.2 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart
  3. 6 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart
  4. 7.2 modules/course_uc/course_uc.classes.inc \CourseObjectUbercart

Hierarchy

Expanded class hierarchy of CourseObjectUbercart

1 string reference to 'CourseObjectUbercart'
course_uc_course_handlers in modules/course_uc/course_uc.module
Implements hook_course_handlers().

File

modules/course_uc/course_uc.classes.inc, line 3

View source
class CourseObjectUbercart extends CourseObjectNode {

  /**
   * Specify that this object needs a navigation listener.
   */
  public function hasPolling() {
    return TRUE;
  }
  function getTakeType() {
    return 'content';
  }

  /**
   * Display the add to cart button, or a message that it was already purchased.
   *
   * Implementing classes should override me if a custom display is desired.
   */
  function take() {
    if (!($this->node->sell_price > 0) && variable_get('course_access_bypass_checkout', 1)) {
      $this
        ->getFulfillment()
        ->setComplete(1)
        ->save();
    }
    if ($this
      ->getFulfillment()
      ->isComplete()) {
      return "You've already purchased this activity.";
    }
    else {
      $node_view = node_view($this->node);
      $atc = t('You must purchase this course before proceeding.') . drupal_render($node_view['display_price']) . drupal_render($node_view['add_to_cart']);
      if (!$atc) {

        // The add to cart form was hidden?
        return "Something isn't right...";
      }
      else {
        return $atc;
      }
    }
  }
  public function optionsForm(&$form, &$form_state) {
    parent::optionsForm($form, $form_state);
    $form['node']['instance']['#title'] = t('Product to check');
    $form['node']['instance']['#description'] .= '</br>' . t('Use an existing ubercart-enabled product for checking payment. Defaults to this course.');
  }

  /**
   * Set a specialized instance ID.
   *
   * Either the course node ID, or another ubercart node ID.
   */
  public function optionsSubmit(&$form, &$form_state) {
    if (isset($form_state['values']['instance'])) {
      if (!$form_state['values']['instance']) {
        $form_state['values']['instance'] = $this
          ->getCourseNid();
      }
    }
    parent::optionsSubmit($form, $form_state);
  }

  /**
   * Don't create new products.
   */
  public function create($node = NULL) {
    if (!$this
      ->getInstanceId()) {
      $this
        ->setOption('instance', $this
        ->getCourseNid());
    }
  }
  function getNodeTypes() {
    return uc_product_types();
  }
  function getCloneAbility() {
    return t('Payment objects will be created as a reference to the new course');
  }
  public function freeze() {
    return TRUE;
  }
  function thaw($ice) {

    // Not creating a new product. Using this course.
    return $this
      ->getCourseNid();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CourseHandler::addOptions final public function Merge an array of options onto the existing options.
CourseHandler::getAccessMessages public function Get an array of access messages.
CourseHandler::getDatabaseFields protected function Return an array of database fields. This determines what fields should be serialized instead of stored.
CourseHandler::getId function
CourseHandler::getOption public function Get an handler option's value.
CourseHandler::optionsMerge private function Merge arrays with replace, not append.
CourseHandler::setAccessMessage public function Set an access message to be displayed along with the course object when it is in the outline. For example, "This activity will open on XYZ" or "Please complete Step 1 to take this activity."
CourseHandler::setOption public function Set an option for this handler.
CourseHandler::setOptions final public function Set this entire handler's options.
CourseObject::$accessMessages protected property
CourseObject::buildContent function Builds a structured array representing the entity's content. Overrides Entity::buildContent
CourseObject::getComponent function Get the object component for this course object.
CourseObject::getComponentName function Get the object component title for this course object.
CourseObject::getCourse function Get the Course that contains this CourseObject.
CourseObject::getCourseNid function Get the course node ID this CourseObject belongs to.
CourseObject::getFulfillment public function Get the user's fulfillment for this course object.
CourseObject::getInstanceId function Get the instance ID. This could be the external component ID, a Node ID...
CourseObject::getMaxOccurences public static function Return the number of occurances that can be in a course at the same time. For example, the design of the Certificate module can only have 1 set of mappings per node. The same goes for Course Credit. We may also want a course object that can only be… 2
CourseObject::getModule function Get the module that provides this course object.
CourseObject::getOptions public function Get options, with session options, except weight, having precedence. Overrides CourseHandler::getOptions
CourseObject::getReport function Let the course object provide its own reports. 4
CourseObject::getReports function Let the course object provide its own reports. 4
CourseObject::getStatus public function Get the user's status in this course object. 2
CourseObject::getUrl public function Return the URL to the course object router.
CourseObject::getUser public function
CourseObject::isActive public function
CourseObject::isGraded function Is this object graded? 2
CourseObject::isRequired public function Is this course object required for course completion?
CourseObject::isSkippable public function If this course object is required, can be it skipped?
CourseObject::isTemporary function Checks the temporary status of a course object.
CourseObject::optionFilter private function
CourseObject::overrideNavigation public function Override navigation links. 1
CourseObject::overrideOutlineListItem public function Overrides a course outline list item. 1
CourseObject::poll function Give the course object a chance do asynchronous polling and set completion on demand.
CourseObject::renderOptionsSummary public function Get all course object implementations of getOptionsSummary().
CourseObject::setComponent function Set the object component for this course object.
CourseObject::setCourse public function Set the Course for this CourseObject.
CourseObject::setDelete public function Mark this object for deletion.
CourseObject::setId function Set the internal course object ID.
CourseObject::setModule function Set the module that provides this course object.
CourseObject::setUser public function
CourseObject::takeCourseObject final public function Take a course object.
CourseObject::unEnroll function Remove any records associated with this course object for the user. 2
CourseObject::uri public function Generate URI from course object. Overrides Entity::uri
CourseObjectNode::$node protected property
CourseObjectNode::access function Deny access to objects without content. Overrides CourseObject::access
CourseObjectNode::context public static function Course context handler callback. Overrides CourseObject::context
CourseObjectNode::delete public function Destroy the node instance. Overrides CourseObject::delete
CourseObjectNode::getEditUrl public function Get the URL to edit this course object, if any. Overrides CourseObject::getEditUrl
CourseObjectNode::getNode function
CourseObjectNode::getNodeInstances public static function When passed a node, this method should return the "parent" nodes that are contained in a course outline. 2
CourseObjectNode::getOptionsSummary function Get core options summary. Overrides CourseObject::getOptionsSummary 2
CourseObjectNode::getTakeUrl public function Get the URL to take this course object, if any. Overrides CourseObject::getTakeUrl 1
CourseObjectNode::getTitle function Get the object title, or return this object's node's title if the option is set. Overrides CourseObject::getTitle
CourseObjectNode::getViewUrl public function Get the URL to view this course object, if any. Overrides CourseObject::getViewUrl
CourseObjectNode::getWarnings function Show a warning if this object has an instance, but the node does not exist. Overrides CourseHandler::getWarnings 2
CourseObjectNode::grant function Grant access to course content before going to it. Overrides CourseObject::grant
CourseObjectNode::hasNodePrivacySupport public function
CourseObjectNode::optionsDefinition public function Define configuration elements and their defaults. Overrides CourseObject::optionsDefinition 4
CourseObjectNode::optionsValidate public function Validate the options form. Check the node type. Overrides CourseObject::optionsValidate
CourseObjectNode::revoke function Duration expired (or something) - CourseObject is telling us so. Overrides CourseObject::revoke
CourseObjectNode::save function On object write, set privacy on this node. Overrides CourseObject::save 1
CourseObjectNode::setInstanceId function When setting our instance ID, also set the node. Overrides CourseObject::setInstanceId
CourseObjectNode::setNode public function Set the node and instance ID (node ID) of this CourseObjectNode.
CourseObjectNode::__construct public function Overrides CourseHandler::__construct
CourseObjectUbercart::create public function Don't create new products. Overrides CourseObjectNode::create
CourseObjectUbercart::freeze public function Freeze data to persist over cloning/exporting. Overrides CourseObjectNode::freeze
CourseObjectUbercart::getCloneAbility function Returns an translated error message if this object has issues with cloning. Overrides CourseObjectNode::getCloneAbility
CourseObjectUbercart::getNodeTypes function Return a list of valid node types. Overrides CourseObjectNode::getNodeTypes
CourseObjectUbercart::getTakeType function Simple node course object behavior is to just redirect to the node. Overrides CourseObjectNode::getTakeType
CourseObjectUbercart::hasPolling public function Specify that this object needs a navigation listener. Overrides CourseObject::hasPolling
CourseObjectUbercart::optionsForm public function Default options form for all course objects. Overrides CourseObjectNode::optionsForm
CourseObjectUbercart::optionsSubmit public function Set a specialized instance ID. Overrides CourseObjectNode::optionsSubmit
CourseObjectUbercart::take function Display the add to cart button, or a message that it was already purchased. Overrides CourseObject::take
CourseObjectUbercart::thaw function Thaw data frozen from an earlier export/clone. Overrides CourseObjectNode::thaw
Entity::$defaultLabel protected property 1
Entity::$entityInfo protected property
Entity::$entityType protected property
Entity::$idKey protected property
Entity::$wrapper protected property
Entity::bundle public function Returns the bundle of the entity. Overrides EntityInterface::bundle
Entity::defaultLabel protected function Defines the entity label if the 'entity_class_label' callback is used. 1
Entity::defaultUri protected function Override this in order to implement a custom default URI and specify 'entity_class_uri' as 'uri callback' hook_entity_info().
Entity::entityInfo public function Returns the info of the type of the entity. Overrides EntityInterface::entityInfo
Entity::entityType public function Returns the type of the entity. Overrides EntityInterface::entityType
Entity::export public function Exports the entity. Overrides EntityInterface::export
Entity::getTranslation public function Gets the raw, translated value of a property or field. Overrides EntityInterface::getTranslation
Entity::hasStatus public function Checks if the entity has a certain exportable status. Overrides EntityInterface::hasStatus
Entity::identifier public function Returns the entity identifier, i.e. the entities name or numeric id. Overrides EntityInterface::identifier
Entity::internalIdentifier public function Returns the internal, numeric identifier. Overrides EntityInterface::internalIdentifier
Entity::isDefaultRevision public function Checks whether the entity is the default revision. Overrides EntityInterface::isDefaultRevision
Entity::label public function Returns the label of the entity. Overrides EntityInterface::label
Entity::setUp protected function Set up the object instance on construction or unserializiation.
Entity::view public function Generate an array for rendering the entity. Overrides EntityInterface::view
Entity::wrapper public function Returns the EntityMetadataWrapper of the entity. Overrides EntityInterface::wrapper
Entity::__sleep public function Magic method to only serialize what's necessary.
Entity::__wakeup public function Magic method to invoke setUp() on unserialization.