PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/php/lib/data_manager/database_internship_organizer_data_manager.class.php

https://bitbucket.org/chamilo/chamilo-app-internship-organizer-dev/
PHP | 897 lines | 654 code | 235 blank | 8 comment | 13 complexity | c026116fca0853bf2772fdb267e1868f MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. namespace application\internship_organizer;
  3. use common\libraries\ObjectTableOrder;
  4. use common\libraries\InequalityCondition;
  5. use common\libraries\WebApplication;
  6. use common\libraries\Database;
  7. use common\libraries\Translation;
  8. use common\libraries\EqualityCondition;
  9. use common\libraries\AndCondition;
  10. use common\libraries\InCondition;
  11. use common\libraries\Session;
  12. use common\libraries\ConditionTranslator;
  13. use repository\RepositoryDataManager;
  14. use repository\ContentObject;
  15. use repository\ContentObjectPublicationAttributes;
  16. use user\UserDataManager;
  17. use user\User;
  18. use group\Group;
  19. use group\GroupDataManager;
  20. /**
  21. * @package internship_organizer.datamanager
  22. */
  23. require_once dirname(__FILE__) . '/../internship_organizer_data_manager.interface.php';
  24. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'category.class.php';
  25. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'location.class.php';
  26. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'category_rel_location.class.php';
  27. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'category_rel_period.class.php';
  28. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'organisation.class.php';
  29. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'organisation_rel_user.class.php';
  30. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'agreement.class.php';
  31. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'agreement_rel_location.class.php';
  32. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'agreement_rel_user.class.php';
  33. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'agreement_rel_mentor.class.php';
  34. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'appointment.class.php';
  35. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'publication.class.php';
  36. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'publication_place.class.php';
  37. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'publication_type.class.php';
  38. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'publication_place.class.php';
  39. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'moment.class.php';
  40. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'mentor.class.php';
  41. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'mentor_rel_user.class.php';
  42. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'mentor_rel_location.class.php';
  43. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'region.class.php';
  44. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'period.class.php';
  45. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'period_rel_user.class.php';
  46. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'period_rel_group.class.php';
  47. require_once WebApplication :: get_application_class_lib_path('internship_organizer') . 'user_type.class.php';
  48. class DatabaseInternshipOrganizerDataManager extends Database implements InternshipOrganizerDataManagerInterface
  49. {
  50. const STATUS = 'status';
  51. const MESSAGE = 'message';
  52. function initialize()
  53. {
  54. parent :: initialize();
  55. $this->set_prefix('internship_organizer_');
  56. }
  57. //internship planner locations
  58. function create_internship_organizer_location($location)
  59. {
  60. return $this->create($location);
  61. }
  62. function update_internship_organizer_location($location)
  63. {
  64. $condition = new EqualityCondition(InternshipOrganizerLocation :: PROPERTY_ID, $location->get_id());
  65. return $this->update($location, $condition);
  66. }
  67. function delete_internship_organizer_location($location)
  68. {
  69. $condition = new EqualityCondition(InternshipOrganizerLocation :: PROPERTY_ID, $location->get_id());
  70. return $this->delete($location->get_table_name(), $condition);
  71. }
  72. function retrieve_location($id)
  73. {
  74. $condition = new EqualityCondition(InternshipOrganizerLocation :: PROPERTY_ID, $id);
  75. return $this->retrieve_object(InternshipOrganizerLocation :: get_table_name(), $condition, array(), InternshipOrganizerLocation :: CLASS_NAME);
  76. }
  77. function retrieve_locations($condition = null, $offset = null, $max_objects = null, $order_by = null)
  78. {
  79. $region_alias = $this->get_alias(InternshipOrganizerRegion :: get_table_name());
  80. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  81. $location_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  82. $query = 'SELECT ' . $location_alias . '.* ,' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ID, $region_alias) . 'as Region_Id, ' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ZIP_CODE, $region_alias) . ',' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_CITY_NAME, $region_alias);
  83. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $location_alias;
  84. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ORGANISATION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias);
  85. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerRegion :: get_table_name()) . ' AS ' . $region_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_REGION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ID, $region_alias);
  86. return $this->retrieve_object_set($query, InternshipOrganizerLocation :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerLocation :: CLASS_NAME);
  87. }
  88. function count_locations($condition = null)
  89. {
  90. $region_alias = $this->get_alias(InternshipOrganizerRegion :: get_table_name());
  91. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  92. $location_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  93. $query = 'SELECT COUNT(* ) ';
  94. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $location_alias;
  95. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ORGANISATION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias);
  96. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerRegion :: get_table_name()) . ' AS ' . $region_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_REGION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ID, $region_alias);
  97. return $this->count_result_set($query, InternshipOrganizerLocation :: get_table_name(), $condition);
  98. }
  99. //internship planner organisations
  100. function create_internship_organizer_organisation($organisation)
  101. {
  102. return $this->create($organisation);
  103. }
  104. function update_internship_organizer_organisation($organisation)
  105. {
  106. $condition = new EqualityCondition(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation->get_id());
  107. return $this->update($organisation, $condition);
  108. }
  109. function delete_internship_organizer_organisation($organisation)
  110. {
  111. $condition = new EqualityCondition(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation->get_id());
  112. return $this->delete($organisation->get_table_name(), $condition);
  113. }
  114. function count_organisations($condition = null)
  115. {
  116. return $this->count_objects(InternshipOrganizerOrganisation :: get_table_name(), $condition);
  117. }
  118. function retrieve_organisation($id)
  119. {
  120. $condition = new EqualityCondition(InternshipOrganizerOrganisation :: PROPERTY_ID, $id);
  121. return $this->retrieve_object(InternshipOrganizerOrganisation :: get_table_name(), $condition, array(), InternshipOrganizerOrganisation :: CLASS_NAME);
  122. }
  123. function retrieve_organisations($condition = null, $offset = null, $max_objects = null, $order_by = null)
  124. {
  125. return $this->retrieve_objects(InternshipOrganizerOrganisation :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerOrganisation :: CLASS_NAME);
  126. }
  127. function delete_internship_organizer_organisation_rel_user($organisation_rel_user)
  128. {
  129. $conditions = array();
  130. $conditions[] = new EqualityCondition(InternshipOrganizerOrganisationRelUser :: PROPERTY_USER_ID, $organisation_rel_user->get_user_id());
  131. $conditions[] = new EqualityCondition(InternshipOrganizerOrganisationRelUser :: PROPERTY_ORGANISATION_ID, $organisation_rel_user->get_organisation_id());
  132. $condition = new AndCondition($conditions);
  133. $bool = $this->delete($organisation_rel_user->get_table_name(), $condition);
  134. if ($bool)
  135. {
  136. $conditions = array();
  137. $user_alias = UserDataManager :: get_instance()->get_alias(User :: get_table_name());
  138. $conditions[] = new EqualityCondition(User :: PROPERTY_ID, $organisation_rel_user->get_user_id(), $user_alias, true);
  139. $conditions[] = new EqualityCondition(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_rel_user->get_organisation_id(), InternshipOrganizerOrganisation :: get_table_name());
  140. $condition = new AndCondition($conditions);
  141. $mentor_rel_users = $this->retrieve_mentor_rel_users($condition);
  142. $mentor_ids = array();
  143. while ($mentor_rel_user = $mentor_rel_users->next_result())
  144. {
  145. $mentor_ids[] = $mentor_rel_user->get_mentor_id();
  146. }
  147. $mentor_ids = array_unique($mentor_ids);
  148. if (count($mentor_ids))
  149. {
  150. $conditions = array();
  151. $conditions[] = new EqualityCondition(InternshipOrganizerMentorRelUser :: PROPERTY_USER_ID, $organisation_rel_user->get_user_id(), InternshipOrganizerMentorRelUser :: get_table_name());
  152. $conditions[] = new InCondition(InternshipOrganizerMentorRelUser :: PROPERTY_MENTOR_ID, $mentor_ids);
  153. $condition = new AndCondition($conditions);
  154. $this->delete(InternshipOrganizerMentorRelUser :: get_table_name(), $condition);
  155. }
  156. }
  157. return $bool;
  158. }
  159. function create_internship_organizer_organisation_rel_user($organisation_rel_user)
  160. {
  161. return $this->create($organisation_rel_user);
  162. }
  163. function count_organisation_rel_users($condition = null)
  164. {
  165. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  166. $organisation_rel_user_alias = $this->get_alias(InternshipOrganizerOrganisationRelUser :: get_table_name());
  167. $user_alias = UserDataManager :: get_instance()->get_alias(User :: get_table_name());
  168. $query = 'SELECT COUNT(DISTINCT ' . $this->escape_column_name(User :: PROPERTY_ID, $user_alias) . ')';
  169. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerOrganisationRelUser :: get_table_name()) . ' AS ' . $organisation_rel_user_alias;
  170. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisationRelUser :: PROPERTY_ORGANISATION_ID, $organisation_rel_user_alias);
  171. $query .= ' JOIN ' . UserDataManager :: get_instance()->escape_table_name(User :: get_table_name()) . ' AS ' . $user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerOrganisationRelUser :: PROPERTY_USER_ID, $organisation_rel_user_alias) . ' = ' . $this->escape_column_name(User :: PROPERTY_ID, $user_alias);
  172. return $this->count_result_set($query, InternshipOrganizerOrganisationRelUser :: get_table_name(), $condition);
  173. }
  174. function retrieve_organisation_rel_users($condition = null, $offset = null, $max_objects = null, $order_by = null)
  175. {
  176. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  177. $organisation_rel_user_alias = $this->get_alias(InternshipOrganizerOrganisationRelUser :: get_table_name());
  178. $user_alias = UserDataManager :: get_instance()->get_alias(User :: get_table_name());
  179. $query = 'SELECT DISTINCT ' . $user_alias . '. * , ' . $organisation_rel_user_alias . '. * ';
  180. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerOrganisationRelUser :: get_table_name()) . ' AS ' . $organisation_rel_user_alias;
  181. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisationRelUser :: PROPERTY_ORGANISATION_ID, $organisation_rel_user_alias);
  182. $query .= ' JOIN ' . UserDataManager :: get_instance()->escape_table_name(User :: get_table_name()) . ' AS ' . $user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerOrganisationRelUser :: PROPERTY_USER_ID, $organisation_rel_user_alias) . ' = ' . $this->escape_column_name(User :: PROPERTY_ID, $user_alias);
  183. return $this->retrieve_object_set($query, InternshipOrganizerOrganisationRelUser :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerOrganisationRelUser :: CLASS_NAME);
  184. }
  185. function retrieve_organisation_rel_user($organisation_id, $user_id)
  186. {
  187. $conditions = array();
  188. $conditions[] = new EqualityCondition(InternshipOrganizerOrganisationRelUser :: PROPERTY_ORGANISATION_ID, $organisation_id);
  189. $conditions[] = new EqualityCondition(InternshipOrganizerOrganisationRelUser :: PROPERTY_USER_ID, $user_id);
  190. $condition = new AndCondition($conditions);
  191. return $this->retrieve_object(InternshipOrganizerOrganisationRelUser :: get_table_name(), $condition, array(), InternshipOrganizerOrganisationRelUser :: CLASS_NAME);
  192. }
  193. //internship planner categories
  194. function update_internship_organizer_category($category)
  195. {
  196. $condition = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_ID, $category->get_id());
  197. return $this->update($category, $condition);
  198. }
  199. function delete_internship_organizer_category($category)
  200. {
  201. $condition = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_ID, $category->get_id());
  202. $bool = $this->delete($category->get_table_name(), $condition);
  203. $condition_subcategories = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_PARENT_ID, $category->get_id());
  204. $categories = $this->retrieve_categories($condition_subcategories);
  205. while ($gr = $categories->next_result())
  206. {
  207. $bool = $bool & $this->delete_internship_organizer_category($gr);
  208. }
  209. $this->truncate_category($category);
  210. return $bool;
  211. }
  212. function truncate_category($category)
  213. {
  214. $condition = new EqualityCondition(InternshipOrganizerCategoryRelLocation :: PROPERTY_CATEGORY_ID, $category->get_id());
  215. return $this->delete(InternshipOrganizerCategoryRelLocation :: get_table_name(), $condition);
  216. }
  217. function delete_internship_organizer_category_rel_location($categoryrellocation)
  218. {
  219. $conditions = array();
  220. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelLocation :: PROPERTY_CATEGORY_ID, $categoryrellocation->get_category_id());
  221. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelLocation :: PROPERTY_LOCATION_ID, $categoryrellocation->get_location_id());
  222. $condition = new AndCondition($conditions);
  223. return $this->delete($categoryrellocation->get_table_name(), $condition);
  224. }
  225. function create_internship_organizer_category($category)
  226. {
  227. return $this->create($category);
  228. }
  229. function create_internship_organizer_category_rel_location($categoryrellocation)
  230. {
  231. return $this->create($categoryrellocation);
  232. }
  233. function count_categories($condition = null)
  234. {
  235. return $this->count_objects(InternshipOrganizerCategory :: get_table_name(), $condition);
  236. }
  237. function retrieve_categories($condition = null, $offset = null, $max_objects = null, $order_by = null)
  238. {
  239. return $this->retrieve_objects(InternshipOrganizerCategory :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerCategory :: CLASS_NAME);
  240. }
  241. function retrieve_internship_organizer_category($id)
  242. {
  243. $condition = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_ID, $id);
  244. return $this->retrieve_object(InternshipOrganizerCategory :: get_table_name(), $condition, array(), InternshipOrganizerCategory :: CLASS_NAME);
  245. }
  246. function retrieve_category_rel_locations($condition = null, $offset = null, $max_objects = null, $order_by = null)
  247. {
  248. $rel_alias = $this->get_alias(InternshipOrganizerCategoryRelLocation :: get_table_name());
  249. $region_alias = $this->get_alias(InternshipOrganizerRegion :: get_table_name());
  250. $category_alias = $this->get_alias(InternshipOrganizerCategory :: get_table_name());
  251. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  252. $location_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  253. $query = 'SELECT ' . $rel_alias . '.* ,' . $location_alias . '.* ,' . $region_alias . '.*';
  254. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerCategoryRelLocation :: get_table_name()) . ' AS ' . $rel_alias;
  255. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $location_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelLocation :: PROPERTY_LOCATION_ID, $rel_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ID, $location_alias);
  256. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerRegion :: get_table_name()) . ' AS ' . $region_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_REGION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ID, $region_alias);
  257. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ORGANISATION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias);
  258. return $this->retrieve_object_set($query, InternshipOrganizerCategoryRelLocation :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerCategoryRelLocation :: CLASS_NAME);
  259. }
  260. function count_category_rel_locations($condition = null)
  261. {
  262. $rel_alias = $this->get_alias(InternshipOrganizerCategoryRelLocation :: get_table_name());
  263. $region_alias = $this->get_alias(InternshipOrganizerRegion :: get_table_name());
  264. $category_alias = $this->get_alias(InternshipOrganizerCategory :: get_table_name());
  265. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  266. $location_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  267. $query = 'SELECT COUNT(* ) ';
  268. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerCategoryRelLocation :: get_table_name()) . ' AS ' . $rel_alias;
  269. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $location_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelLocation :: PROPERTY_LOCATION_ID, $rel_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ID, $location_alias);
  270. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerRegion :: get_table_name()) . ' AS ' . $region_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_REGION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ID, $region_alias);
  271. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ORGANISATION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias);
  272. return $this->count_result_set($query, InternshipOrganizerCategoryRelLocation :: get_table_name(), $condition);
  273. }
  274. function retrieve_period_rel_locations($condition = null, $offset = null, $max_objects = null, $order_by = null)
  275. {
  276. $category_rel__location_alias = $this->get_alias(InternshipOrganizerCategoryRelLocation :: get_table_name());
  277. $category_rel_period_alias = $this->get_alias(InternshipOrganizerCategoryRelPeriod :: get_table_name());
  278. $category_alias = $this->get_alias(InternshipOrganizerCategory :: get_table_name());
  279. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  280. $location_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  281. $query = 'SELECT ' . $category_rel_location_alias . ' * ';
  282. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerCategoryRelLocation :: get_table_name()) . ' AS ' . $category_rel__location_alias;
  283. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerCategoryRelPeriod :: get_table_name()) . ' AS ' . $category_rel_period_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelPeriod :: PROPERTY_CATEGORY_ID, $category_rel__location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerCategoryRelLocation :: PROPERTY_CATEGORY_ID, $category_rel__location_alias);
  284. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $location_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelLocation :: PROPERTY_LOCATION_ID, $category_rel__location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ID, $location_alias);
  285. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ORGANISATION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias);
  286. return $this->retrieve_object_set($query, InternshipOrganizerCategoryRelLocation :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerCategoryRelLocation :: CLASS_NAME);
  287. }
  288. function count_period_rel_locations($condition = null)
  289. {
  290. $category_rel__location_alias = $this->get_alias(InternshipOrganizerCategoryRelLocation :: get_table_name());
  291. $category_rel_period_alias = $this->get_alias(InternshipOrganizerCategoryRelPeriod :: get_table_name());
  292. $category_alias = $this->get_alias(InternshipOrganizerCategory :: get_table_name());
  293. $organisation_alias = $this->get_alias(InternshipOrganizerOrganisation :: get_table_name());
  294. $location_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  295. $query = 'SELECT COUNT(* ) ';
  296. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerCategoryRelLocation :: get_table_name()) . ' AS ' . $category_rel__location_alias;
  297. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerCategoryRelPeriod :: get_table_name()) . ' AS ' . $category_rel_period_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelPeriod :: PROPERTY_CATEGORY_ID, $category_rel__location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerCategoryRelLocation :: PROPERTY_CATEGORY_ID, $category_rel__location_alias);
  298. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $location_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelLocation :: PROPERTY_LOCATION_ID, $category_rel__location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ID, $location_alias);
  299. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerOrganisation :: get_table_name()) . ' AS ' . $organisation_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ORGANISATION_ID, $location_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerOrganisation :: PROPERTY_ID, $organisation_alias);
  300. return $this->count_result_set($query, InternshipOrganizerCategoryRelLocation :: get_table_name(), $condition);
  301. }
  302. function retrieve_category_rel_location($location_id, $category_id)
  303. {
  304. $conditions = array();
  305. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelLocation :: PROPERTY_LOCATION_ID, $location_id);
  306. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelLocation :: PROPERTY_CATEGORY_ID, $category_id);
  307. $condition = new AndCondition($conditions);
  308. return $this->retrieve_object(InternshipOrganizerCategoryRelLocation :: get_table_name(), $condition, array(), InternshipOrganizerCategoryRelLocation :: CLASS_NAME);
  309. }
  310. function retrieve_category_by_name($name)
  311. {
  312. $condition = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_NAME, $name);
  313. return $this->retrieve_object(InternshipOrganizerCategory :: get_table_name(), $condition);
  314. }
  315. function is_categoryname_available($categoryname, $category_id = null)
  316. {
  317. $condition = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_NAME, $categoryname);
  318. if ($category_id)
  319. {
  320. $conditions = array();
  321. $conditions[] = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_NAME, $categoryname);
  322. $conditions = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_ID, $category_id);
  323. $condition = new AndCondition($conditions);
  324. }
  325. return ! ($this->count_objects(InternshipOrganizerCategory :: get_table_name(), $condition) == 1);
  326. }
  327. function retrieve_category($category_id)
  328. {
  329. $condition = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_ID, $category_id);
  330. return $this->retrieve_object(InternshipOrganizerCategory :: get_table_name(), $condition, array(), InternshipOrganizerCategory :: CLASS_NAME);
  331. }
  332. function retrieve_root_category()
  333. {
  334. $conditions = array();
  335. $conditions[] = new EqualityCondition(InternshipOrganizerCategory :: PROPERTY_PARENT_ID, 0);
  336. $condition = new AndCondition($conditions);
  337. $root_category = $this->retrieve_categories($condition)->next_result();
  338. if (! isset($root_category))
  339. {
  340. $root_category = new InternshipOrganizerCategory();
  341. $root_category->set_name('ROOT');
  342. $root_category->set_parent_id(0);
  343. $root_category->create();
  344. }
  345. return $root_category;
  346. }
  347. function delete_internship_organizer_category_rel_period($category_rel_period)
  348. {
  349. $conditions = array();
  350. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelPeriod :: PROPERTY_CATEGORY_ID, $category_rel_period->get_category_id());
  351. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelPeriod :: PROPERTY_PERIOD_ID, $category_rel_period->get_period_id());
  352. $condition = new AndCondition($conditions);
  353. $bool = $this->delete($category_rel_period->get_table_name(), $condition);
  354. return $bool;
  355. }
  356. function create_internship_organizer_category_rel_period($category_rel_period)
  357. {
  358. return $this->create($category_rel_period);
  359. }
  360. function count_category_rel_periods($condition = null)
  361. {
  362. $category_alias = $this->get_alias(InternshipOrganizerCategory :: get_table_name());
  363. $category_rel_period_alias = $this->get_alias(InternshipOrganizerCategoryRelPeriod :: get_table_name());
  364. $period_alias = $this->get_alias(InternshipOrganizerPeriod :: get_table_name());
  365. $query = 'SELECT COUNT(* ) ';
  366. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerCategoryRelPeriod :: get_table_name()) . ' AS ' . $category_rel_period_alias;
  367. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerCategory :: get_table_name()) . ' AS ' . $category_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategory :: PROPERTY_ID, $category_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerCategoryRelPeriod :: PROPERTY_CATEGORY_ID, $category_rel_period_alias);
  368. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerPeriod :: get_table_name()) . ' AS ' . $period_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelPeriod :: PROPERTY_PERIOD_ID, $category_rel_period_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerPeriod :: PROPERTY_ID, $period_alias);
  369. return $this->count_result_set($query, InternshipOrganizerCategoryRelPeriod :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerCategoryRelPeriod :: CLASS_NAME);
  370. }
  371. function retrieve_category_rel_periods($condition = null, $offset = null, $max_objects = null, $order_by = null)
  372. {
  373. $category_alias = $this->get_alias(InternshipOrganizerCategory :: get_table_name());
  374. $category_rel_period_alias = $this->get_alias(InternshipOrganizerCategoryRelPeriod :: get_table_name());
  375. $period_alias = $this->get_alias(InternshipOrganizerPeriod :: get_table_name());
  376. $query = 'SELECT ' . $category_rel_period_alias . '. * ,' . $category_alias . '. * ';
  377. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerCategoryRelPeriod :: get_table_name()) . ' AS ' . $category_rel_period_alias;
  378. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerCategory :: get_table_name()) . ' AS ' . $category_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategory :: PROPERTY_ID, $category_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerCategoryRelPeriod :: PROPERTY_CATEGORY_ID, $category_rel_period_alias);
  379. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerPeriod :: get_table_name()) . ' AS ' . $period_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerCategoryRelPeriod :: PROPERTY_PERIOD_ID, $category_rel_period_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerPeriod :: PROPERTY_ID, $period_alias);
  380. return $this->retrieve_object_set($query, InternshipOrganizerCategoryRelPeriod :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerCategoryRelPeriod :: CLASS_NAME);
  381. }
  382. function retrieve_category_rel_period($category_id, $period_id)
  383. {
  384. $conditions = array();
  385. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelPeriod :: PROPERTY_CATEGORY_ID, $category_id);
  386. $conditions[] = new EqualityCondition(InternshipOrganizerCategoryRelPeriod :: PROPERTY_PERIOD_ID, $period_id);
  387. $condition = new AndCondition($conditions);
  388. return $this->retrieve_object(InternshipOrganizerCategoryRelPeriod :: get_table_name(), $condition, array(), InternshipOrganizerCategoryRelPeriod :: CLASS_NAME);
  389. }
  390. //internship planner moments
  391. function create_internship_organizer_moment($moment)
  392. {
  393. return $this->create($moment);
  394. }
  395. function update_internship_organizer_moment($moment)
  396. {
  397. $condition = new EqualityCondition(InternshipOrganizerMoment :: PROPERTY_ID, $moment->get_id());
  398. return $this->update($moment, $condition);
  399. }
  400. function delete_internship_organizer_moment($moment)
  401. {
  402. $condition = new EqualityCondition(InternshipOrganizerMoment :: PROPERTY_ID, $moment->get_id());
  403. return $this->delete($moment->get_table_name(), $condition);
  404. }
  405. function count_moments($condition = null)
  406. {
  407. return $this->count_objects(InternshipOrganizerMoment :: get_table_name(), $condition);
  408. }
  409. function retrieve_moment($id)
  410. {
  411. $condition = new EqualityCondition(InternshipOrganizerMoment :: PROPERTY_ID, $id);
  412. return $this->retrieve_object(InternshipOrganizerMoment :: get_table_name(), $condition, array(), InternshipOrganizerMoment :: CLASS_NAME);
  413. }
  414. function retrieve_moments($condition = null, $offset = null, $max_objects = null, $order_by = null)
  415. {
  416. return $this->retrieve_objects(InternshipOrganizerMoment :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerMoment :: CLASS_NAME);
  417. }
  418. function retrieve_moment_rel_users($condition = null, $offset = null, $max_objects = null, $order_by = null)
  419. {
  420. $moment_alias = $this->get_alias(InternshipOrganizerMoment :: get_table_name());
  421. $agreement_rel_user_alias = $this->get_alias(InternshipOrganizerAgreementRelUser :: get_table_name());
  422. $user_alias = UserDataManager :: get_instance()->get_alias(User :: get_table_name());
  423. $query = 'SELECT ' . $moment_alias . '. * ,' . $user_alias . '.lastname , ' . $user_alias . '.firstname , ' . $agreement_rel_user_alias . '. *';
  424. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerMoment :: get_table_name()) . ' AS ' . $moment_alias;
  425. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAgreementRelUser :: get_table_name()) . ' AS ' . $agreement_rel_user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreementRelUser :: PROPERTY_AGREEMENT_ID, $agreement_rel_user_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_AGREEMENT_ID, $moment_alias);
  426. $query .= ' JOIN ' . UserDataManager :: get_instance()->escape_table_name(User :: get_table_name()) . ' AS ' . $user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreementRelUser :: PROPERTY_USER_ID, $agreement_rel_user_alias) . ' = ' . $this->escape_column_name(User :: PROPERTY_ID, $user_alias);
  427. return $this->retrieve_object_set($query, InternshipOrganizerMoment :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerMoment :: CLASS_NAME);
  428. }
  429. function count_moment_rel_users($condition = null)
  430. {
  431. $moment_alias = $this->get_alias(InternshipOrganizerMoment :: get_table_name());
  432. $agreement_rel_user_alias = $this->get_alias(InternshipOrganizerAgreementRelUser :: get_table_name());
  433. $user_alias = UserDataManager :: get_instance()->get_alias(User :: get_table_name());
  434. $query = 'SELECT COUNT(* ) ';
  435. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerMoment :: get_table_name()) . ' AS ' . $moment_alias;
  436. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAgreementRelUser :: get_table_name()) . ' AS ' . $agreement_rel_user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreementRelUser :: PROPERTY_AGREEMENT_ID, $agreement_rel_user_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_AGREEMENT_ID, $moment_alias);
  437. $query .= ' JOIN ' . UserDataManager :: get_instance()->escape_table_name(User :: get_table_name()) . ' AS ' . $user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreementRelUser :: PROPERTY_USER_ID, $agreement_rel_user_alias) . ' = ' . $this->escape_column_name(User :: PROPERTY_ID, $user_alias);
  438. return $this->count_result_set($query, InternshipOrganizerMoment :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerMoment :: CLASS_NAME);
  439. }
  440. function retrieve_moment_rel_locations($condition = null, $offset = null, $max_objects = null, $order_by = null)
  441. {
  442. $moment_alias = $this->get_alias(InternshipOrganizerMoment :: get_table_name());
  443. $agreement_alias = $this->get_alias(InternshipOrganizerAgreement :: get_table_name());
  444. $user_alias = UserDataManager :: get_instance()->get_alias(User :: get_table_name());
  445. $agreement_rel_locations_alias = $this->get_alias(InternshipOrganizerAgreementRelLocation :: get_table_name());
  446. $locations_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  447. $region_alias = $this->get_alias(InternshipOrganizerRegion :: get_table_name());
  448. $period_alias = $this->get_alias(InternshipOrganizerPeriod :: get_table_name());
  449. $query = 'SELECT ' . $moment_alias . '.id as moment_id ,' . $moment_alias . '. * ,' . $user_alias . '.lastname , ' . $user_alias . '.firstname , ' . $agreement_alias . '. * , ' . $locations_alias . '. * , ' . $region_alias . '. * , ' . $period_alias . '. * ';
  450. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerMoment :: get_table_name()) . ' AS ' . $moment_alias;
  451. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAgreement :: get_table_name()) . ' AS ' . $agreement_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreement :: PROPERTY_ID, $agreement_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_AGREEMENT_ID, $moment_alias);
  452. $query .= ' JOIN ' . UserDataManager :: get_instance()->escape_table_name(User :: get_table_name()) . ' AS ' . $user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_OWNER, $moment_alias) . ' = ' . $this->escape_column_name(User :: PROPERTY_ID, $user_alias);
  453. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAgreementRelLocation :: get_table_name()) . ' AS ' . $agreement_rel_locations_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreementRelLocation :: PROPERTY_AGREEMENT_ID, $agreement_rel_locations_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_AGREEMENT_ID, $moment_alias);
  454. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $locations_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ID, $locations_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerAgreementRelLocation :: PROPERTY_LOCATION_ID, $agreement_rel_locations_alias);
  455. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerRegion :: get_table_name()) . ' AS ' . $region_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ID, $region_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_REGION_ID, $locations_alias);
  456. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerPeriod :: get_table_name()) . ' AS ' . $period_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerPeriod :: PROPERTY_ID, $period_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerAgreement :: PROPERTY_PERIOD_ID, $agreement_alias);
  457. return $this->retrieve_object_set($query, InternshipOrganizerMoment :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerMoment :: CLASS_NAME);
  458. }
  459. function count_moment_rel_locations($condition = null)
  460. {
  461. $moment_alias = $this->get_alias(InternshipOrganizerMoment :: get_table_name());
  462. $agreement_alias = $this->get_alias(InternshipOrganizerAgreement :: get_table_name());
  463. $user_alias = UserDataManager :: get_instance()->get_alias(User :: get_table_name());
  464. $agreement_rel_locations_alias = $this->get_alias(InternshipOrganizerAgreementRelLocation :: get_table_name());
  465. $locations_alias = $this->get_alias(InternshipOrganizerLocation :: get_table_name());
  466. $region_alias = $this->get_alias(InternshipOrganizerRegion :: get_table_name());
  467. $period_alias = $this->get_alias(InternshipOrganizerPeriod :: get_table_name());
  468. $query = 'SELECT COUNT(DISTINCT ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_ID, $moment_alias) . ')';
  469. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerMoment :: get_table_name()) . ' AS ' . $moment_alias;
  470. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAgreement :: get_table_name()) . ' AS ' . $agreement_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreement :: PROPERTY_ID, $agreement_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_AGREEMENT_ID, $moment_alias);
  471. $query .= ' JOIN ' . UserDataManager :: get_instance()->escape_table_name(User :: get_table_name()) . ' AS ' . $user_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_OWNER, $moment_alias) . ' = ' . $this->escape_column_name(User :: PROPERTY_ID, $user_alias);
  472. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAgreementRelLocation :: get_table_name()) . ' AS ' . $agreement_rel_locations_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAgreementRelLocation :: PROPERTY_AGREEMENT_ID, $agreement_rel_locations_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_AGREEMENT_ID, $moment_alias);
  473. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerLocation :: get_table_name()) . ' AS ' . $locations_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_ID, $locations_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerAgreementRelLocation :: PROPERTY_LOCATION_ID, $agreement_rel_locations_alias);
  474. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerRegion :: get_table_name()) . ' AS ' . $region_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerRegion :: PROPERTY_ID, $region_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerLocation :: PROPERTY_REGION_ID, $locations_alias);
  475. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerPeriod :: get_table_name()) . ' AS ' . $period_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerPeriod :: PROPERTY_ID, $period_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerAgreement :: PROPERTY_PERIOD_ID, $agreement_alias);
  476. return $this->count_result_set($query, InternshipOrganizerMoment :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerMoment :: CLASS_NAME);
  477. }
  478. function retrieve_moment_rel_appointments($condition = null, $offset = null, $max_objects = null, $order_by = null)
  479. {
  480. $moment_alias = $this->get_alias(InternshipOrganizerMoment :: get_table_name());
  481. $appointment_alias = $this->get_alias(InternshipOrganizerAppointment :: get_table_name());
  482. $query = 'SELECT ' . $moment_alias . '. * ';
  483. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerMoment :: get_table_name()) . ' AS ' . $moment_alias;
  484. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAppointment :: get_table_name()) . ' AS ' . $appointment_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAppointment :: PROPERTY_MOMENT_ID, $appointment_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_ID, $moment_alias);
  485. return $this->retrieve_object_set($query, InternshipOrganizerMoment :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerMoment :: CLASS_NAME);
  486. }
  487. function count_moment_rel_appointments($condition = null)
  488. {
  489. $moment_alias = $this->get_alias(InternshipOrganizerMoment :: get_table_name());
  490. $appointment_alias = $this->get_alias(InternshipOrganizerAppointment :: get_table_name());
  491. $query = 'SELECT COUNT(* ) ';
  492. $query = 'SELECT ' . $moment_alias . '. * ,';
  493. $query .= ' FROM ' . $this->escape_table_name(InternshipOrganizerMoment :: get_table_name()) . ' AS ' . $moment_alias;
  494. $query .= ' JOIN ' . $this->escape_table_name(InternshipOrganizerAppointment :: get_table_name()) . ' AS ' . $appointment_alias . ' ON ' . $this->escape_column_name(InternshipOrganizerAppointment :: PROPERTY_MOMENT_ID, $appointment_alias) . ' = ' . $this->escape_column_name(InternshipOrganizerMoment :: PROPERTY_ID, $moment_alias);
  495. return $this->count_result_set($query, InternshipOrganizerMoment :: get_table_name(), $condition, $offset, $max_objects, $order_by, InternshipOrganizerMoment :: CLASS_NAME);
  496. }
  497. //internship planner agreements
  498. function create_internship_organizer_agreement($agreement)
  499. {
  500. return $this->create($agreement);
  501. }
  502. function update_internship_organizer_agreement($agreement)
  503. {
  504. $condition = new EqualityCondition(InternshipOrganizerAgreement :: PROPERTY_ID, $agreement->get_id());
  505. return $this->update($agreement, $condition);
  506. }
  507. function delete_internship_organizer_agreement($agreement)
  508. {
  509. $agreement_id = $agreement->get_id();
  510. $condition = new EqualityCondition(InternshipOrganizerMoment :: PROPERTY_AGREEMENT_ID, $agreement_id);
  511. $moment_count = $this->count_moments($condition);
  512. if ($moment_count == 0)
  513. {
  514. $condition = new EqualityCondition(InternshipOrganizerAgreementRelUser :: PROPERTY_AGREEMENT_ID, $agreement_id);
  515. $agreement_rel_users = $this->retrieve_agreement_rel_users($condition);
  516. while ($agreement_rel_user = $agreement_rel_users->next_result())
  517. {
  518. $agreement_rel_user->delete();
  519. }
  520. $condition = new EqualityCondition(InternshipOrganizerAgreementRelLocation :: PROPERTY_AGREEMENT_ID, $agreement_id);
  521. $agreement_rel_locations = $this->retrieve_agreement_rel_locations($condition);
  522. while ($agreement_rel_location = $agreement_rel_locations->next_result())
  523. {
  524. $agreement_rel_location->delete();
  525. }
  526. $condition = new EqualityCondition(InternshipOrganizerAgreementRelMentor :: PROPERTY_AGREEMENT_ID, $agreement_id);
  527. $agreement_rel_mentors = $this->retrieve_agreement_rel_mentors($condition);
  528. while ($agreement_rel_mentor = $agreement_rel_mentors->next_result())
  529. {
  530. $agreement_rel_mentor->delete();
  531. }
  532. $conditions = array();
  533. $conditions[] = new EqualityCondition(InternshipOrganizerPublication :: PROPERTY_PUBLICATION_PLACE, InternshipOrganizerPublicationPlace :: AGREEMENT);
  534. $conditions[] = new EqualityCondition(InternshipOrganizerPublication :: PROPERTY_PLACE_ID, $agreement_id);
  535. $condition = new AndCondition($conditions);
  536. $publications = $this->retrieve_publications($condition);
  537. while ($publication = $publications->ne

Large files files are truncated, but you can click here to view the full file