PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/php/lib/platform/dokeos185/data_class/dokeos185_assignment_file.class.php

https://bitbucket.org/chamilo/chamilo-migration-dev/
PHP | 335 lines | 2 code | 2 blank | 331 comment | 0 complexity | 7517d29d8882088a6eabefeb2527ac2b MD5 | raw file
  1. <?php
  2. //namespace migration;
  3. ///**
  4. // * $Id: dokeos185_assignment_file.class.php 221 2009-11-13 14:36:41Z vanpouckesven $
  5. // * @package migration.lib.platform.dokeos185
  6. // */
  7. //
  8. //require_once dirname(__FILE__) . '/../../lib/import/import_assignment_file.class.php';
  9. //require_once dirname(__FILE__) . '/../../../repository/lib/content_object/document/document.class.php';
  10. //require_once dirname(__FILE__) . '/../../../application/weblcms/php/content_object_publication.class.php';
  11. //require_once dirname(__FILE__) . '/../../../application/weblcms/php/content_object_publication_category.class.php';
  12. //
  13. ///**
  14. // * This class presents a Dokeos185 assignment_file
  15. // *
  16. // * @author Sven Vanpoucke
  17. // */
  18. //class Dokeos185AssignmentFile extends Dokeos185MigrationDataClass
  19. //{
  20. // /**
  21. // * Dokeos185AssignmentFile properties
  22. // */
  23. // const PROPERTY_ID = 'id';
  24. // const PROPERTY_ASSIGNMENT_ID = 'assignment_id';
  25. // const PROPERTY_DOC_PATH = 'doc_path';
  26. //
  27. // private static $mgdm;
  28. //
  29. // /**
  30. // * Default properties stored in an associative array.
  31. // */
  32. // private $defaultProperties;
  33. //
  34. // /**
  35. // * Creates a new Dokeos185AssignmentFile object
  36. // * @param array $defaultProperties The default properties
  37. // */
  38. // function __construct($defaultProperties = array ())
  39. // {
  40. // $this->defaultProperties = $defaultProperties;
  41. // }
  42. //
  43. // /**
  44. // * Gets a default property by name.
  45. // * @param string $name The name of the property.
  46. // */
  47. // function get_default_property($name)
  48. // {
  49. // return $this->defaultProperties[$name];
  50. // }
  51. //
  52. // /**
  53. // * Gets the default properties
  54. // * @return array An associative array containing the properties.
  55. // */
  56. // function get_default_properties()
  57. // {
  58. // return $this->defaultProperties;
  59. // }
  60. //
  61. // /**
  62. // * Get the default properties
  63. // * @return array The property names.
  64. // */
  65. // static function get_default_property_names()
  66. // {
  67. // return array(self :: PROPERTY_ID, self :: PROPERTY_ASSIGNMENT_ID, self :: PROPERTY_DOC_PATH);
  68. // }
  69. //
  70. // /**
  71. // * Sets a default property by name.
  72. // * @param string $name The name of the property.
  73. // * @param mixed $value The new value for the property.
  74. // */
  75. // function set_default_property($name, $value)
  76. // {
  77. // $this->defaultProperties[$name] = $value;
  78. // }
  79. //
  80. // /**
  81. // * Sets the default properties of this class
  82. // */
  83. // function set_default_properties($defaultProperties)
  84. // {
  85. // $this->defaultProperties = $defaultProperties;
  86. // }
  87. //
  88. // /**
  89. // * Returns the id of this Dokeos185AssignmentFile.
  90. // * @return the id.
  91. // */
  92. // function get_id()
  93. // {
  94. // return $this->get_default_property(self :: PROPERTY_ID);
  95. // }
  96. //
  97. // /**
  98. // * Returns the assignment_id of this Dokeos185AssignmentFile.
  99. // * @return the assignment_id.
  100. // */
  101. // function get_assignment_id()
  102. // {
  103. // return $this->get_default_property(self :: PROPERTY_ASSIGNMENT_ID);
  104. // }
  105. //
  106. // /**
  107. // * Returns the doc_path of this Dokeos185AssignmentFile.
  108. // * @return the doc_path.
  109. // */
  110. // function get_doc_path()
  111. // {
  112. // return $this->get_default_property(self :: PROPERTY_DOC_PATH);
  113. // }
  114. //
  115. //
  116. //
  117. // /**
  118. // * Convert to new assignment file
  119. // * Create document
  120. // * @param array $array the parameters for the conversion
  121. // * @return the new assignment file
  122. // */
  123. // function convert_data($array)
  124. //
  125. //{
  126. // $course = $array['course'];
  127. // $old_mgdm = $array['old_mgdm'];
  128. // $mgdm = MigrationDataManager :: get_instance();
  129. //
  130. // $new_course_code = $mgdm->get_id_reference($course->get_code(), 'weblcms_course');
  131. // $new_user_id = $this->get_data_manager()->get_owner_id($new_course_code);
  132. // $filename = $this->get_doc_path();
  133. // $new_path = $new_user_id . '/';
  134. // $old_rel_path = 'courses/' . $course->get_directory() . '/assignment/assig_' . $this->get_assignment_id() . '/';
  135. //
  136. // $new_rel_path = 'files/repository/' . $new_path;
  137. //
  138. // $lcms_document = null;
  139. //
  140. // $filename = iconv("UTF-8", "ISO-8859-1", $filename);
  141. // $old_rel_path = iconv("UTF-8", "ISO-8859-1", $old_rel_path);
  142. //
  143. // $document_md5 = md5_file($old_mgdm->append_full_path(false, $old_rel_path . $filename));
  144. // $document_id = $mgdm->get_document_from_md5($new_user_id, $document_md5);
  145. //
  146. // if (! $document_id)
  147. // {
  148. // $file = $old_mgdm->move_file($old_rel_path, $new_rel_path, $filename);
  149. //
  150. // if ($file)
  151. // {
  152. // //document parameters
  153. // $lcms_document = new Document();
  154. // $lcms_document->set_title($filename);
  155. // $lcms_document->set_description('...');
  156. //
  157. // $lcms_document->set_owner_id($new_user_id);
  158. //
  159. // $lcms_document->set_path($new_path . $file);
  160. // $lcms_document->set_filename($file);
  161. //
  162. // // Category for announcements already exists?
  163. // $lcms_category_id = $mgdm->get_parent_id($new_user_id, 'category', Translation :: get('assignment'));
  164. // if (! $lcms_category_id)
  165. // {
  166. // //Create category for tool in lcms
  167. // $lcms_repository_category = new Category();
  168. // $lcms_repository_category->set_owner_id($new_user_id);
  169. // $lcms_repository_category->set_title(Translation :: get('assignment'));
  170. // $lcms_repository_category->set_description('...');
  171. //
  172. // //Retrieve repository id from course
  173. // $repository_id = $mgdm->get_parent_id($new_user_id, 'category', Translation :: get('MyRepository'));
  174. // $lcms_repository_category->set_parent_id($repository_id);
  175. //
  176. // //Create category in database
  177. // $lcms_repository_category->create();
  178. //
  179. // $lcms_document->set_parent_id($lcms_repository_category->get_id());
  180. // }
  181. // else
  182. // {
  183. // $lcms_document->set_parent_id($lcms_category_id);
  184. // }
  185. //
  186. // //create document in database
  187. // $lcms_document->create();
  188. //
  189. // $mgdm->add_file_md5($new_user_id, $lcms_document->get_id(), $document_md5);
  190. // }
  191. // else
  192. // {
  193. // $document_id = $mgdm->get_document_id($new_rel_path . $filename, $new_user_id);
  194. // if ($document_id)
  195. // {
  196. // $lcms_document = new ContentObject();
  197. // $lcms_document->set_id($document_id);
  198. // }
  199. // }
  200. //
  201. // }
  202. // else
  203. // {
  204. // $lcms_document = new ContentObject();
  205. // $lcms_document->set_id($document_id);
  206. // }
  207. //
  208. // //publication
  209. // /*
  210. // if($this->item_property->get_visibility() <= 1 && $lcms_document)
  211. // {
  212. //
  213. // // Categories already exists?
  214. // $file_split = array();
  215. // $file_split = split('/', $old_path);
  216. //
  217. // array_shift($file_split);
  218. // array_pop($file_split);
  219. //
  220. // $parent = 0;
  221. //
  222. // foreach($file_split as $cat)
  223. // {
  224. // $lcms_category_id = self :: $mgdm->publication_category_exist($cat, $new_course_code,
  225. // 'assignment',$parent);
  226. //
  227. // if(!$lcms_category_id)
  228. // {
  229. // //Create category for tool in lcms
  230. // $lcms_category = new ContentObjectPublicationCategory();
  231. // $lcms_category->set_title($cat);
  232. // $lcms_category->set_course($new_course_code);
  233. // $lcms_category->set_tool('document');
  234. // $lcms_category->set_parent_category_id($parent);
  235. //
  236. // //Create category in database
  237. // $lcms_category->create();
  238. // $parent = $lcms_category->get_id();
  239. // }
  240. // else
  241. // {
  242. // $parent = $lcms_category_id;
  243. // }
  244. //
  245. // }
  246. //
  247. // $end_time_cat = Logger :: get_microtime();
  248. // $passedtime_categories = $end_time_cat - $start_time_cat;
  249. //
  250. // $publication = new ContentObjectPublication();
  251. //
  252. // $publication->set_content_object($lcms_document);
  253. // $publication->set_course_id($new_course_code);
  254. // $publication->set_publisher_id($new_user_id);
  255. // $publication->set_tool('document');
  256. // $publication->set_category_id($parent);
  257. // //$publication->set_from_date(self :: $mgdm->make_unix_time($this->item_property->get_start_visible()));
  258. // //$publication->set_to_date(self :: $mgdm->make_unix_time($this->item_property->get_end_visible()));
  259. // $publication->set_from_date(0);
  260. // $publication->set_to_date(0);
  261. // $publication->set_publication_date(self :: $mgdm->make_unix_time($this->item_property->get_insert_date()));
  262. // $publication->set_modified_date(self :: $mgdm->make_unix_time($this->item_property->get_lastedit_date()));
  263. // //$publication->set_modified_date(0);
  264. // //$publication->set_display_order_index($this->get_display_order());
  265. // $publication->set_display_order_index(0);
  266. // $publication->set_email_sent(0);
  267. //
  268. // $publication->set_hidden($this->item_property->get_visibility() == 1?0:1);
  269. //
  270. // //create publication in database
  271. // $publication->create();
  272. // }
  273. // */
  274. // return $lcms_document;
  275. //}
  276. //
  277. // /**
  278. // * Retrieve all assignment files from the database
  279. // * @param array $parameters parameters for the retrieval
  280. // * @return array of assignment files
  281. // */
  282. // static function retrieve_data($parameters)
  283. //{
  284. // $old_mgdm = $parameters['old_mgdm'];
  285. //
  286. // $coursedb = $parameters['course']->get_db_name();
  287. // $tablename = 'assignment_file';
  288. // $classname = 'Dokeos185AssignmentFile';
  289. //
  290. // return $old_mgdm->get_all($coursedb, $tablename, $classname, $tool_name, $parameters['offset'], $parameters['limit']);
  291. //}
  292. //
  293. // static function get_database_table($parameters)
  294. //{
  295. // $array = array();
  296. // $array['database'] = $parameters['course']->get_db_name();
  297. // $array['table'] = 'assignment_file';
  298. // return $array;
  299. //}
  300. //
  301. //function is_valid()
  302. // {
  303. // $old_mgdm = $array['old_mgdm'];
  304. //
  305. // $course = $array['course'];
  306. // $filename = $this->get_doc_path();
  307. // $old_rel_path = 'courses/' . $course->get_directory() . '/assignment/assig_' . $this->get_assignment_id() . '/';
  308. //
  309. // $filename = iconv("UTF-8", "ISO-8859-1", $filename);
  310. // $old_rel_path = iconv("UTF-8", "ISO-8859-1", $old_rel_path);
  311. //
  312. // if (! $this->get_assignment_id() || ! $this->get_doc_path() || ! file_exists($old_mgdm->append_full_path(false, $old_rel_path . $filename)))
  313. // {
  314. // $mgdm = MigrationDataManager :: get_instance();
  315. // $mgdm->add_failed_element($this->get_id(), $course->get_db_name() . '.assignment_file');
  316. // return false;
  317. // }
  318. // return true;
  319. // }
  320. //
  321. // public static function get_table_name() {
  322. // throw new Exception("Unimplemented method " . __FILE__ . "#" . __METHOD__ . "(" . __LINE__ . ")");
  323. // }
  324. //
  325. // public static function get_class_name() {
  326. // throw new Exception("Unimplemented method " . __FILE__ . "#" . __METHOD__ . "(" . __LINE__ . ")");
  327. // }
  328. //
  329. // public function get_database_name() {
  330. // throw new Exception("Unimplemented method " . __FILE__ . "#" . __METHOD__ . "(" . __LINE__ . ")");
  331. // }
  332. //}
  333. ?>