dokeos-gradebook
[ class tree: dokeos-gradebook ] [ index: dokeos-gradebook ] [ all elements ]

Source for file linkfactory.class.php

Documentation is available at linkfactory.class.php

  1. <?php
  2.  
  3. // To add your new link type here:
  4. // - define a unique type id
  5. // - add include
  6. // - change create() and get_all_types()
  7.  
  8.  
  9. // Please do not change existing values, they are used in the database !
  10. define('LINK_EXERCISE',1);
  11. define('LINK_DROPBOX',2);
  12. define('LINK_STUDENTPUBLICATION',3);
  13. define('LINK_LEARNPATH',4);
  14.  
  15.  
  16.  
  17. include_once('abstractlink.class.php');
  18. include_once('exerciselink.class.php');
  19. include_once('evallink.class.php');
  20. include_once('dropboxlink.class.php');
  21. include_once('studentpublicationlink.class.php');
  22. include_once('learnpathlink.class.php');
  23.  
  24.  
  25. /**
  26.  * Factory for link objects
  27.  * @author Bert SteppĂ©
  28.  * @package dokeos.gradebook
  29.  */
  30. {
  31.  
  32.     /**
  33.      * Retrieve links and return them as an array of extensions of AbstractLink.
  34.      * @param $id link id
  35.      * @param $type link type
  36.      * @param $ref_id reference id
  37.      * @param $user_id user id (link owner)
  38.      * @param $course_code course code
  39.      * @param $category_id parent category
  40.      * @param $visible visible
  41.      */
  42.     public function load ($id null$type null$ref_id null$user_id null$course_code null$category_id null$visible null)
  43.     {
  44.         return AbstractLink::load($id$type$ref_id$user_id$course_code$category_id$visible);
  45.     }
  46.  
  47.  
  48.     /**
  49.      * Get the link object referring to an evaluation
  50.      */
  51.     public function get_evaluation_link ($eval_id)
  52.     {
  53.         $links AbstractLink :: load(nullnull$eval_id);
  54.         foreach ($links as $link)
  55.         {
  56.             if (is_a($link'EvalLink'))
  57.                 return $link;
  58.         }
  59.         return null;
  60.     }
  61.  
  62.  
  63.     /**
  64.      * Find links by name
  65.      * @param string $name_mask search string
  66.      * @return array link objects matching the search criterium
  67.      */
  68.     public function find_links ($name_mask,$selectcat)
  69.     {
  70.         return AbstractLink::find_links($name_mask,$selectcat);
  71.     }
  72.  
  73.     /**
  74.      * Static method to create specific link objects
  75.      * @param $type link type
  76.      */
  77.     public function create ($type)
  78.     {
  79.         if ($type == LINK_EXERCISE return new ExerciseLink();
  80.         elseif ($type == LINK_DROPBOX return new DropboxLink();
  81.         elseif ($type == LINK_STUDENTPUBLICATION return new StudentPublicationLink();
  82.         elseif ($type == LINK_LEARNPATH return new LearnpathLink();
  83.         else return null;
  84.     }
  85.  
  86.     /**
  87.      * Return an array of all known link types
  88.      */
  89.     public function get_all_types ()
  90.     {
  91.         return array (LINK_EXERCISE,
  92.                       LINK_DROPBOX,
  93.                       LINK_STUDENTPUBLICATION,
  94.                       LINK_LEARNPATH,
  95.                       );
  96.     }
  97.  
  98. }
  99. ?>

Documentation generated on Thu, 12 Jun 2008 13:59:49 -0500 by phpDocumentor 1.4.1