PageRenderTime 212ms CodeModel.GetById 165ms app.highlight 33ms RepoModel.GetById 1ms app.codeStats 1ms

/php/lib/weblcms_manager/weblcms_manager.class.php

https://bitbucket.org/chamilo/chamilo-app-weblcms/
PHP | 1746 lines | 1189 code | 144 blank | 413 comment | 47 complexity | 17feb9f83fd42e3cce9c9a97924b66e6 MD5 | raw file

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

   1<?php
   2namespace application\weblcms;
   3
   4use application\weblcms\tool\user\SubscribeGroupBrowserTable;
   5use application\weblcms\tool\user\SubscribedUserBrowserTable;
   6
   7use common\libraries\ObjectTable;
   8use common\libraries\DynamicAction;
   9use common\libraries\Filesystem;
  10use common\libraries\Redirect;
  11use common\libraries\Display;
  12use common\libraries\Application;
  13use common\libraries\Theme;
  14use common\libraries\Session;
  15use common\libraries\Breadcrumb;
  16use common\libraries\BreadcrumbTrail;
  17use common\libraries\Utilities;
  18use common\libraries\EqualityCondition;
  19use common\libraries\Request;
  20use common\libraries\WebApplication;
  21use common\libraries\Translation;
  22
  23use user\UserDataManager;
  24
  25use HTML_Table;
  26
  27/**
  28 * $Id: weblcms_manager.class.php 218 2009-11-13 14:21:26Z kariboe $
  29 * @package application.lib.weblcms.weblcms_manager
  30 */
  31require_once dirname(__FILE__) . '/weblcms_search_form.class.php';
  32require_once dirname(__FILE__) . '/../category_manager/content_object_publication_category.class.php';
  33require_once dirname(__FILE__) . '/../tool/tool.class.php';
  34require_once dirname(__FILE__) . '/../tool/tool_component.class.php';
  35require_once dirname(__FILE__) . '/../tool_list_renderer.class.php';
  36require_once dirname(__FILE__) . '/../course/course.class.php';
  37require_once dirname(__FILE__) . '/../course/course_request.class.php';
  38require_once dirname(__FILE__) . '/../course/course_create_request.class.php';
  39require_once dirname(__FILE__) . '/../course/course_settings.class.php';
  40require_once dirname(__FILE__) . '/../course/course_rights.class.php';
  41require_once dirname(__FILE__) . '/../course/course_group_subscribe_right.class.php';
  42require_once dirname(__FILE__) . '/../course/course_group_unsubscribe_right.class.php';
  43require_once dirname(__FILE__) . '/../course/course_user_relation.class.php';
  44require_once dirname(__FILE__) . '/../course_group/course_group.class.php';
  45require_once dirname(__FILE__) . '/component/admin_course_browser/admin_course_browser_table.class.php';
  46require_once dirname(__FILE__) . '/component/admin_course_type_browser/admin_course_type_browser_table.class.php';
  47//require_once dirname(__FILE__) . '/component/subscribed_user_browser/subscribed_user_browser_table.class.php';
  48//require_once dirname(__FILE__) . '/component/subscribe_group_browser/subscribe_group_browser_table.class.php';
  49require_once dirname(__FILE__) . '/component/admin_request_browser/admin_request_browser_table.class.php';
  50require_once dirname(__FILE__) . '/../weblcms_rights.class.php';
  51require_once dirname(__FILE__) . '/../course_type/course_type.class.php';
  52require_once dirname(__FILE__) . '/../course_type/course_type_layout.class.php';
  53require_once dirname(__FILE__) . '/../course_type/course_type_settings.class.php';
  54require_once dirname(__FILE__) . '/../course_type/course_type_tool.class.php';
  55require_once dirname(__FILE__) . '/../course_type/course_type_rights.class.php';
  56require_once dirname(__FILE__) . '/../course_type/course_type_group_subscribe_right.class.php';
  57require_once dirname(__FILE__) . '/../course_type/course_type_group_unsubscribe_right.class.php';
  58require_once dirname(__FILE__) . '/../course_type/course_type_group_creation_right.class.php';
  59require_once dirname(__FILE__) . '/../course_type/course_type_user_category.class.php';
  60
  61/**
  62 ==============================================================================
  63 * This is an application that creates a fully fledged web-based learning
  64 * content management system. The Web-LCMS is based on so-called "tools",
  65 * which each represent a segment in the application.
  66 *
  67 * @author Tim De Pauw
  68 ==============================================================================
  69 */
  70
  71class WeblcmsManager extends WebApplication
  72{
  73    const APPLICATION_NAME = 'weblcms';
  74
  75    const PARAM_REQUEST_TYPE = 'request_type';
  76    const PARAM_REQUEST_VIEW = 'request_view';
  77    const PARAM_REQUEST = 'request';
  78    const PARAM_REMOVE_SELECTED_REQUESTS = 'removed selected requests';
  79    const PARAM_COURSE = 'course';
  80    const PARAM_CATEGORY = 'publication_category';
  81    const PARAM_COURSE_CATEGORY_ID = 'category';
  82    const PARAM_COURSE_USER = 'course';
  83    const PARAM_COURSE_GROUP = 'course_group';
  84    const PARAM_COURSE_TYPE_USER_CATEGORY_ID = 'user_category';
  85    const PARAM_COURSE_TYPE = 'course_type';
  86    const PARAM_USERS = 'users';
  87    const PARAM_GROUP = 'group';
  88    const PARAM_TYPE = 'type';
  89    const PARAM_ACTIVE = 'active';
  90    const PARAM_TOOL = 'tool';
  91    const PARAM_COMPONENT_ACTION = 'action';
  92    const PARAM_DIRECTION = 'direction';
  93    const PARAM_REMOVE_SELECTED = 'remove_selected';
  94    const PARAM_REMOVE_SELECTED_COURSE_TYPES = 'remove selected coursetypes';
  95    const PARAM_ACTIVATE_SELECTED_COURSE_TYPES = 'activate selected coursetypes';
  96    const PARAM_DEACTIVATE_SELECTED_COURSE_TYPES = 'deactivate selected coursetypes';
  97    const PARAM_CHANGE_COURSE_TYPE_SELECTED_COURSES = 'Change Coursetype selected courses';
  98    const PARAM_UNSUBSCRIBE_SELECTED = 'unsubscribe_selected';
  99    const PARAM_SUBSCRIBE_SELECTED = 'subscribe_selected';
 100    const PARAM_SUBSCRIBE_SELECTED_AS_STUDENT = 'subscribe_selected_as_student';
 101    const PARAM_SUBSCRIBE_SELECTED_AS_ADMIN = 'subscribe_selected_as_admin';
 102    const PARAM_SUBSCRIBE_SELECTED_GROUP = 'subscribe_selected_group_admin';
 103    const PARAM_TOOL_ACTION = 'tool_action';
 104    const PARAM_STATUS = 'user_status';
 105    const PARAM_EXTRA = 'extra';
 106    const PARAM_PUBLICATION = 'publication';
 107    const PARAM_ALLOW_SELECTED_REQUESTS = 'allow_selected_requests';
 108    const PARAM_REFUSE_SELECTED_REQUESTS = 'refuse_selected_requests';
 109
 110    const ACTION_SUBSCRIBE = 'subscribe';
 111    const ACTION_CHANGE_COURSE_TYPE_FROM_COURSE = 'course_change_course_type';
 112    const ACTION_SUBSCRIBE_GROUP = 'group_subscribe';
 113    const ACTION_UNSUBSCRIBE_GROUP = 'group_unsubscribe';
 114    const ACTION_SUBSCRIBE_GROUP_USERS = 'group_users_subscribe';
 115    const ACTION_VIEW_WEBLCMS_HOME = 'home';
 116    const ACTION_VIEW_COURSE = 'course_viewer';
 117    const ACTION_CREATE_COURSE = 'course_creator';
 118    const ACTION_IMPORT_COURSES = 'course_importer';
 119    const ACTION_IMPORT_COURSE_USERS = 'course_user_importer';
 120    const ACTION_DELETE_COURSE = 'course_deleter';
 121    const ACTION_DELETE_COURSES_BY_COURSE_TYPE = 'course_type_courses_deleter';
 122    const ACTION_MANAGER_SORT = 'sorter';
 123    const ACTION_MANAGER_SUBSCRIBE = 'subscribe';
 124    const ACTION_MANAGER_UNSUBSCRIBE = 'unsubscribe';
 125    const ACTION_COURSE_CATEGORY_MANAGER = 'course_category_manager';
 126    const ACTION_ADMIN_COURSE_BROWSER = 'admin_course_browser';
 127    const ACTION_SELECT_COURSE_TYPE = 'course_type_selector';
 128    const ACTION_DELETE_COURSE_TYPE = 'course_type_deleter';
 129    const ACTION_VIEW_COURSE_TYPE = 'course_type_viewer';
 130    const ACTION_CHANGE_ACTIVATION = 'active_changer';
 131    const ACTION_CHANGE_ACTIVE = 'activity_changer';
 132    const ACTION_ADMIN_COURSE_TYPE_CREATOR = 'admin_course_type_creator';
 133    const ACTION_ADMIN_COURSE_TYPE_BROWSER = 'admin_course_type_browser';
 134    const ACTION_COURSE_EDITOR_REQUEST = 'course_request_editor';
 135    const ACTION_COURSE_SUBSCRIBE_CREATE_REQUEST = 'course_subscribe_request_creator';
 136    const ACTION_ADMIN_REQUEST_BROWSER = 'admin_request_browser';
 137    const ACTION_COURSE_REQUEST_DELETER = 'course_request_deleter';
 138    const ACTION_COURSE_ALLOWING_REQUEST = 'course_request_allow';
 139    const ACTION_COURSE_REFUSE_REQUEST = 'course_request_refuse';
 140    const ACTION_VIEW_REQUEST = 'course_request_viewer';
 141    const ACTION_PUBLISH_INTRODUCTION = 'introduction_publisher';
 142    const ACTION_DELETE_INTRODUCTION = 'introduction_deleter';
 143    const ACTION_EDIT_INTRODUCTION = 'introduction_editor';
 144    const ACTION_REPORTING = 'reporting';
 145    const ACTION_COURSE_CODE = 'course_code_subscriber';
 146    const ACTION_COURSE_CREATE_REQUEST_CREATOR = 'course_create_request_creator';
 147
 148    const ACTION_RENDER_BLOCK = 'block';
 149
 150    const DEFAULT_ACTION = self :: ACTION_VIEW_WEBLCMS_HOME;
 151
 152    /**
 153     * The tools that this course offers.
 154     */
 155    private $tools;
 156    /**
 157     * The sections that this application offers.
 158     */
 159    private $sections;
 160    /**
 161     * The class of the tool currently active in this application
 162     */
 163    private $tool_class;
 164
 165    /**
 166     * The course object of the course currently active in this application
 167     */
 168    private $course;
 169
 170    /**
 171     * The course_type object of the course currently active in this application
 172     */
 173    private $course_type;
 174
 175    /**
 176     * The course_group object of the course_group currently active in this application
 177     */
 178    private $course_group;
 179
 180    private $search_form;
 181
 182    private $request;
 183
 184    /**
 185     * The new publications for each tool are cached here
 186     * @var Array[tool] = new publications count
 187     */
 188    private static $new_publications;
 189
 190    /**
 191     * Constructor. Optionally takes a default tool; otherwise, it is taken
 192     * from the query string.
 193     * @param Tool $tool The default tool, or null if none.
 194     */
 195    function __construct($user)
 196    {
 197        parent :: __construct($user);
 198
 199        //        $this->set_parameter(self :: PARAM_ACTION, Request :: get(self :: PARAM_ACTION));
 200        //        $this->set_parameter(self :: PARAM_CATEGORY, Request :: get(self :: PARAM_CATEGORY));
 201        //        $this->set_parameter(self :: PARAM_COURSE, Request :: get(self :: PARAM_COURSE));
 202        //$this->parse_input_from_table();
 203
 204
 205        $this->course_type = $this->load_course_type();
 206        $this->tools = array();
 207        $this->course = new Course();
 208        $this->load_course();
 209
 210        $this->course_group = null;
 211        $this->load_course_group();
 212        $this->sections = array();
 213        $this->load_sections();
 214        if (! is_null($this->get_user()))
 215            $this->subscribe_user_to_allowed_courses($this->get_user_id());
 216    }
 217
 218    /**
 219     * Renders the weblcms block and returns it.
 220     */
 221    function render_block($block)
 222    {
 223        $weblcms_block = WeblcmsBlock :: factory($this, $block);
 224        return $weblcms_block->run();
 225    }
 226
 227    function set_tool_class($class)
 228    {
 229        return $this->tool_class = $class;
 230    }
 231
 232    /**
 233     * Gets the identifier of the current tool
 234     * @return string The identifier of current tool
 235     */
 236    function get_tool_id()
 237    {
 238        return $this->get_parameter(self :: PARAM_TOOL);
 239    }
 240
 241    /**
 242     * Retrieves the change active url
 243     * @return the change active component url
 244     */
 245    function get_change_active_url($type, $course_type_id)
 246    {
 247        $parameters = array();
 248        $parameters[self :: PARAM_ACTION] = self :: ACTION_CHANGE_ACTIVE;
 249        $parameters[self :: PARAM_TYPE] = $type;
 250        $parameters[self :: PARAM_COURSE_TYPE] = $course_type_id;
 251
 252        return $this->get_url($parameters);
 253    }
 254
 255    /**
 256     * Gets the user object for a given user
 257     * @param int $user_id
 258     * @return User
 259     */
 260    function get_user_info($user_id)
 261    {
 262        return UserDataManager :: get_instance()->retrieve_user($user_id);
 263    }
 264
 265    /**
 266     * Returns the course that is being used.
 267     * @return string The course.
 268     */
 269    function get_course()
 270    {
 271        return $this->course;
 272    }
 273
 274    /**
 275     * Sets the course
 276     * @param Course $course
 277     */
 278    function set_course($course)
 279    {
 280        $this->course = $course;
 281    }
 282
 283    function set_course_type($course_type)
 284    {
 285        $this->course_type = $course_type;
 286    }
 287
 288    function set_request($request)
 289    {
 290        $this->request = $request;
 291    }
 292
 293    //function set_course_type($course_type)
 294    //{
 295    //	$this->course_type = $course_type;
 296    //}
 297
 298
 299    /**
 300     * Returns the identifier of the course that is being used.
 301     * @return string The course identifier.
 302     */
 303    function get_course_id()
 304    {
 305        if ($this->course == null)
 306            return 0;
 307
 308        return $this->course->get_id();
 309    }
 310
 311    /*
 312	function get_course_type_id()
 313	{
 314		if($this->course_type == null)
 315		return 0;
 316
 317		return $this->course_type->get_id();
 318	}
 319	*/
 320
 321    /**
 322     * Returns the course_group that is being used.
 323     * @return string The course_group.
 324     */
 325    function get_course_group()
 326    {
 327        return $this->course_group;
 328    }
 329
 330    function get_course_type_deleting_all_courses_url($course_type)
 331    {
 332        return $this->get_url(array(
 333                self :: PARAM_ACTION => self :: ACTION_DELETE_COURSES_BY_COURSE_TYPE,
 334                self :: PARAM_COURSE_TYPE => $course_type->get_id()));
 335    }
 336
 337    /**
 338     * Returns the course_group that is being used.
 339     * @return string The course_group.
 340     */
 341    function get_course_type()
 342    {
 343        return $this->course_type;
 344    }
 345
 346    function get_request()
 347    {
 348        return $this->request;
 349    }
 350
 351    function get_course_changing_course_type_url($course)
 352    {
 353        return $this->get_url(array(
 354                self :: PARAM_ACTION => self :: ACTION_CHANGE_COURSE_TYPE_FROM_COURSE,
 355                self :: PARAM_COURSE => $course->get_id()));
 356    }
 357
 358    function get_course_type_deleting_url($course_type)
 359    {
 360        return $this->get_url(array(
 361                self :: PARAM_ACTION => self :: ACTION_DELETE_COURSE_TYPE,
 362                self :: PARAM_COURSE_TYPE => $course_type->get_id()));
 363    }
 364
 365    function get_course_type_editing_url($course_type)
 366    {
 367        return $this->get_url(array(
 368                self :: PARAM_ACTION => self :: ACTION_ADMIN_COURSE_TYPE_CREATOR,
 369                self :: PARAM_COURSE_TYPE => $course_type->get_id(),
 370                self :: PARAM_TOOL => 'course_type_settings',
 371                'previous' => 'admin'));
 372    }
 373
 374    function get_course_request_deleting_url($request, $request_type, $request_view)
 375    {
 376        return $this->get_url(array(
 377                self :: PARAM_ACTION => self :: ACTION_COURSE_REQUEST_DELETER,
 378                self :: PARAM_REQUEST => $request->get_id(),
 379                self :: PARAM_REQUEST_TYPE => $request_type,
 380                self :: PARAM_REQUEST_VIEW => $request_view));
 381    }
 382
 383    function get_course_request_allowing_url($request, $request_type, $request_view)
 384    {
 385        return $this->get_url(array(
 386                self :: PARAM_ACTION => self :: ACTION_COURSE_ALLOWING_REQUEST,
 387                self :: PARAM_REQUEST => $request->get_id(),
 388                self :: PARAM_REQUEST_TYPE => $request_type,
 389                self :: PARAM_REQUEST_VIEW => $request_view));
 390    }
 391
 392    function get_course_request_viewing_url($request, $request_type, $request_view)
 393    {
 394        return $this->get_url(array(
 395                self :: PARAM_ACTION => self :: ACTION_VIEW_REQUEST,
 396                self :: PARAM_REQUEST => $request->get_id(),
 397                self :: PARAM_REQUEST_TYPE => $request_type));
 398    }
 399
 400    function get_course_request_refuse_url($request, $request_type, $request_view)
 401    {
 402        return $this->get_url(array(
 403                self :: PARAM_ACTION => self :: ACTION_COURSE_REFUSE_REQUEST,
 404                self :: PARAM_REQUEST => $request->get_id(),
 405                self :: PARAM_REQUEST_TYPE => $request_type,
 406                self :: PARAM_REQUEST_VIEW => $request_view));
 407    }
 408
 409    function get_course_type_maintenance_url($course_type)
 410    {
 411        //return $this->get_url(array(self :: PARAM_ACTION => self :: ACTION_VIEW_COURSE, self :: PARAM_COURSE => $course->get_id(), self :: PARAM_TOOL => 'maintenance'));
 412        return null;
 413    }
 414
 415    function get_course_type_viewing_url($course_type)
 416    {
 417        return $this->get_url(array(
 418                self :: PARAM_ACTION => self :: ACTION_VIEW_COURSE_TYPE,
 419                self :: PARAM_COURSE_TYPE => $course_type->get_id()));
 420    }
 421
 422    function get_home_url()
 423    {
 424        return $this->get_url(array(self :: PARAM_ACTION => self :: ACTION_VIEW_WEBLCMS_HOME));
 425    }
 426
 427    /**
 428     * Sets the course_group
 429     * @param CourseGroup $course_group
 430     */
 431    function set_course_group($course_group)
 432    {
 433        $this->course_group = $course_group;
 434    }
 435
 436    /**
 437     * Gets a list of all course_groups of the current active course in which the
 438     * current user is subscribed.
 439     */
 440    function get_course_groups()
 441    {
 442        $wdm = WeblcmsDataManager :: get_instance();
 443        $course_groups = $wdm->retrieve_course_groups_from_user($this->get_user_id(), $this->get_course_id())->as_array();
 444        return $course_groups;
 445    }
 446
 447    /**
 448     * Makes a category tree ready for displaying by adding a prefix to the
 449     * category title based on the level of that category in the tree structure.
 450     * @param array $tree The category tree
 451     * @param array $categories In this array the new category titles (with
 452     * prefix) will be stored. The keys in this array are the category ids, the
 453     * values are the new titles
 454     * @param int $level The current level in the tree structure
 455     */
 456    private static function translate_category_tree($tree, $categories, $level = 0)
 457    {
 458        foreach ($tree as $node)
 459        {
 460            $obj = $node['obj'];
 461            $prefix = ($level ? str_repeat('&nbsp;&nbsp;&nbsp;', $level) . '&mdash; ' : '');
 462            $categories[$obj->get_id()] = $prefix . $obj->get_title();
 463            $subtree = $node['sub'];
 464            if (is_array($subtree) && count($subtree))
 465            {
 466                self :: translate_category_tree($subtree, $categories, $level + 1);
 467            }
 468        }
 469    }
 470
 471    /**
 472     * Gets a category
 473     * @param int $id The id of the requested category
 474     * @return LearningPublicationCategory The requested category
 475     */
 476    function get_category($id)
 477    {
 478        return WeblcmsDataManager :: get_instance()->retrieve_content_object_publication_category($id);
 479    }
 480
 481    /**
 482     * Displays the header of this application
 483     * @param array $breadcrumbs The breadcrumbs which should be displayed
 484     */
 485    /*function display_header($breadcrumbtrail = null, $display_search = false, $display_title = true)
 486	{
 487		if (is_null($breadcrumbtrail))
 488        {
 489            $breadcrumbtrail = BreadcrumbTrail :: get_instance();
 490            if($breadcrumbtrail->size() == 1)
 491            {
 492            	$breadcrumbtrail->add(new Breadcrumb($this->get_url(), Translation :: get(Utilities :: underscores_to_camelcase($this->get_application_name()))));
 493            }
 494        }
 495
 496		$tool = $this->get_parameter(self :: PARAM_TOOL);
 497		$course = $this->get_parameter(self :: PARAM_COURSE);
 498		$action = $this->get_parameter(self :: PARAM_ACTION);
 499
 500		if (isset($this->tool_class))
 501		{
 502			$tool = str_replace('_tool', '', Tool :: class_to_type($this->tool_class));
 503			$js_file = dirname(__FILE__) . '/tool/' . $tool . '/' . $tool . '.js';
 504			if (file_exists($js_file))
 505			{
 506				$htmlHeadXtra[] = '<script type="text/javascript" src="application/lib/weblcms/tool/' . $tool . '/' . $tool . '.js"></script>';
 507			}
 508		}
 509
 510		$title = $breadcrumbtrail->get_last()->get_name();
 511		$title_short = $title;
 512		if (strlen($title_short) > 53)
 513		{
 514			$title_short = substr($title_short, 0, 50) . '&hellip;';
 515		}
 516		Display :: header($breadcrumbtrail);
 517
 518		if ($course && is_object($this->course) && $action == self :: ACTION_VIEW_COURSE)
 519		{
 520			//echo '<h3 style="float: left;">'.htmlentities($this->course->get_name()).'</h3>';
 521			echo '<h3 style="float: left;">' . htmlentities($title) . '</h3>';
 522			// TODO: Add department name and url here somewhere ?
 523		}
 524		else
 525		{
 526			echo '<h3 style="float: left;">' . htmlentities($title) . '</h3>';
 527			if ($display_search)
 528			{
 529				$this->display_search_form();
 530			}
 531		}
 532
 533		if ($msg = Request :: get(Application :: PARAM_MESSAGE))
 534		{
 535			echo '<br />';
 536			$this->display_message($msg);
 537		}
 538		if ($msg = Request :: get(Application :: PARAM_ERROR_MESSAGE))
 539		{
 540			echo '<br />';
 541			$this->display_error_message($msg);
 542		}
 543
 544		echo '<div class="clear">&nbsp;</div>';
 545	}*/
 546
 547    /**
 548     * Displays the footer of this application
 549     */
 550    function display_footer()
 551    {
 552        Display :: footer();
 553    }
 554
 555    /**
 556     * Returns the names of the tools known to this application.
 557     * @return array The tools.
 558     */
 559    function get_registered_tools()
 560    {
 561        return $this->tools;
 562    }
 563
 564    /**
 565     * Returns the names of the sections known to this application.
 566     * @return array The tools.
 567     */
 568    function get_registered_sections()
 569    {
 570        if(is_null($this->sections))
 571        {
 572            $this->load_sections();
 573        }
 574        return $this->sections;
 575    }
 576
 577    function get_tool_properties($tool)
 578    {
 579        return $this->tools[$tool];
 580    }
 581
 582    /**
 583     * Loads the tools available to the course.
 584     */
 585    function load_tools($order_by_name = false)
 586    {
 587        if (! is_null($this->get_course_id()))
 588        {
 589            $wdm = WeblcmsDataManager :: get_instance();
 590            $this->tools = $wdm->get_course_modules($this->get_course_id(), $order_by_name);
 591
 592     //            foreach ($this->tools as $index => $tool)
 593        //            {
 594        //                require_once dirname(__FILE__) . '/../tool/' . $tool->name . '/' . $tool->name . '_tool.class.php';
 595        //            }
 596        }
 597    }
 598
 599    /**
 600     * Loads the sections installed on the system.
 601     */
 602    function load_sections()
 603    { 
 604        if (! is_null($this->get_course_id()))
 605        {
 606            $wdm = WeblcmsDataManager :: get_instance();
 607            $condition = new EqualityCondition(CourseSection :: PROPERTY_COURSE_CODE, $this->get_course_id());
 608            $sections = $wdm->retrieve_course_sections($condition);
 609            
 610            while ($section = $sections->next_result())
 611            {
 612                //$type = isset($section->type) ? $section->type : '';
 613                $this->sections[] = $section;
 614            }
 615        }
 616    }
 617
 618    /**
 619     * Loads the current course into the system.
 620     */
 621    public function load_course($id = null)
 622    {
 623        if ($id == null)
 624            $id = Request :: get(self :: PARAM_COURSE);
 625        $wdm = WeblcmsDataManager :: get_instance();
 626        if (! is_null($id) && ! is_array($id) && $id != '')
 627        {
 628            $this->course = $wdm->retrieve_course($id);
 629            if (! $this->course)
 630                $this->redirect(Translation :: get('CourseCorrupt') . " ID: " . $id, true, array(
 631                        'go' => WeblcmsManager :: ACTION_VIEW_WEBLCMS_HOME), array(), false, Redirect :: TYPE_LINK);
 632        }
 633        else
 634        {
 635            $this->course = $wdm->retrieve_empty_course();
 636            $this->course->set_course_type($this->course_type);
 637        }
 638        $this->load_tools(true);
 639        $this->course->set_tools($this->tools);
 640    }
 641
 642    /**
 643     * Loads the current course_group into the system.
 644     */
 645    private function load_course_group()
 646    {
 647        if (! is_null($this->get_parameter(self :: PARAM_COURSE_GROUP)) && strlen($this->get_parameter(self :: PARAM_COURSE_GROUP) > 0))
 648        {
 649            $wdm = WeblcmsDataManager :: get_instance();
 650            $this->course_group = $wdm->retrieve_course_group($this->get_parameter(self :: PARAM_COURSE_GROUP));
 651        }
 652    }
 653
 654    /**
 655     * Loads the current course_type into the system.
 656     */
 657    private function load_course_type($id = null)
 658    {
 659        $course_type = null;
 660        if (is_null($id))
 661            $id = Request :: get(self :: PARAM_COURSE_TYPE);
 662        $wdm = WeblcmsDataManager :: get_instance();
 663        if (! is_null($id) && strlen($id) > 0)
 664        {
 665            $course_type = $wdm->retrieve_course_type($id);
 666        }
 667        else
 668        {
 669            $course_type = $wdm->retrieve_empty_course_type();
 670        }
 671        return $course_type;
 672    }
 673
 674    /**
 675     * Determines whether or not the given name is a valid tool name.
 676     * @param string $name The name to evaluate.
 677     * @return True if the name is a valid tool name, false otherwise.
 678     */
 679    static function is_tool_name($name)
 680    {
 681        return (preg_match('/^[a-z][a-z_]+$/', $name) > 0);
 682    }
 683
 684    /*
 685	 * Inherited
 686	 */
 687    function retrieve_max_sort_value($table, $column, $condition = null)
 688    {
 689        return WeblcmsDataManager :: get_instance()->retrieve_max_sort_value($table, $column, $condition);
 690    }
 691
 692    /*
 693	 * Inherited
 694	 */
 695    static function content_object_is_published($object_id)
 696    {
 697        return WeblcmsDataManager :: get_instance()->content_object_is_published($object_id);
 698    }
 699
 700    /*
 701	 * Inherited
 702	 */
 703    static function any_content_object_is_published($object_ids)
 704    {
 705        return WeblcmsDataManager :: get_instance()->any_content_object_is_published($object_ids);
 706    }
 707
 708    /*
 709	 * Inherited
 710	 */
 711    static function get_content_object_publication_attributes($object_id, $type = null, $offset = null, $count = null, $order_property = null)
 712    {
 713        return WeblcmsDataManager :: get_instance()->get_content_object_publication_attributes(null, $object_id, $type, $offset, $count, $order_property);
 714    }
 715
 716    /*
 717	 * Inherited
 718	 */
 719    static function get_content_object_publication_attribute($publication_id)
 720    {
 721        return WeblcmsDataManager :: get_instance()->get_content_object_publication_attribute($publication_id);
 722    }
 723
 724    /*
 725	 * Inherited
 726	 */
 727    static function delete_content_object_publications($object_id)
 728    {
 729        return WeblcmsDataManager :: get_instance()->delete_content_object_publications($object_id);
 730    }
 731
 732    static function delete_content_object_publication($publication_id)
 733    {
 734        $publication = WeblcmsDataManager :: get_instance()->retrieve_content_object_publication($publication_id);
 735	if(!$publication)
 736	{
 737	    return false;
 738	}
 739	return $publication->delete();
 740    }
 741
 742    /*
 743	 * Inherited
 744	 */
 745    static function update_content_object_publication_id($publication_attr)
 746    {
 747        return WeblcmsDataManager :: get_instance()->update_content_object_publication_id($publication_attr);
 748    }
 749
 750    /**
 751     * Inherited
 752     */
 753    static function count_publication_attributes($user = null, $object_id = null, $condition = null)
 754    {
 755        return WeblcmsDataManager :: get_instance()->count_publication_attributes($user, $object_id, $condition);
 756    }
 757
 758    /**
 759     * Inherited
 760     */
 761    static function get_content_object_publication_locations($content_object, $user = null)
 762    {
 763        $locations = array();
 764        $type = $content_object->get_type();
 765
 766        //$courses = $this->retrieve_courses($user->get_id());
 767	$conditions = WeblcmsDataManager :: get_user_courses_condition($user);
 768        $courses = WeblcmsDataManager :: get_instance()->retrieve_user_courses($conditions);
 769        while ($course = $courses->next_result())
 770        {
 771            if ($course->is_course_admin($user)) //u can only publish in the course of u are course admin/ also documents in dropboxes
 772                $c[] = $course;
 773        }
 774
 775        $directory = dirname(__FILE__) . '/../../../tool/';
 776        $tools = Filesystem :: get_directory_content($directory, Filesystem :: LIST_DIRECTORIES, false);
 777        foreach ($tools as $tool)
 778        {
 779            $path = $directory . $tool . '/php/' . $tool . '_tool.class.php';
 780
 781            if (! file_exists($path))
 782                continue;
 783
 784            require_once $path;
 785            $class = Tool :: get_tool_type_namespace($tool) . '\\' . Utilities :: underscores_to_camelcase($tool) . 'Tool';
 786            $obj = new $class(new self());
 787            $types[$tool] = $obj->get_allowed_types();
 788        }
 789        foreach ($types as $tool => $allowed_types)
 790        {
 791            if (in_array($type, $allowed_types))
 792            {
 793                $user = Session :: get_user_id();
 794
 795                foreach ($c as $course)
 796                    $locations[$course->get_id() . '-' . $tool] = 'Course: ' . $course->get_name() . ' (' . $course->get_visual() . ')' . ' - Tool: ' . $tool;
 797            }
 798        }
 799        return $locations;
 800    }
 801
 802    static function publish_content_object($content_object, $location, $attributes)
 803    {
 804        $location_split = split('-', $location);
 805        $course = $location_split[0];
 806        $tool = $location_split[1]; //echo $location;
 807        $dm = WeblcmsDataManager :: get_instance();
 808        $do = $dm->get_next_content_object_publication_display_order_index($course, $tool, 0);
 809
 810        $pub = new ContentObjectPublication();
 811        $pub->set_content_object_id($content_object->get_id());
 812        $pub->set_course_id($course);
 813        $pub->set_tool($tool);
 814        $pub->set_publisher_id(Session :: get_user_id());
 815        $pub->set_display_order_index($do);
 816        $pub->set_publication_date(time());
 817        $pub->set_modified_date(time());
 818
 819        $pub->set_hidden($attributes[ContentObjectPublication :: PROPERTY_HIDDEN]);
 820        if (is_null($pub->is_hidden()))
 821            $pub->set_hidden(0);
 822
 823        if ($attributes['forever'] == 0)
 824        {
 825            $pub->set_from_date(Utilities :: time_from_datepicker($attributes['from_date']));
 826            $pub->set_to_date(Utilities :: time_from_datepicker($attributes['to_date']));
 827        }
 828
 829        $pub->create();
 830
 831        $course = $dm->retrieve_course($course);
 832
 833        return Translation :: get('PublicationCreated') . ': <b>' . Translation :: get('Course') . '</b>: ' . $course->get_name() . ' - <b>' . Translation :: get('Tool') . '</b>: ' . $tool;
 834    }
 835
 836    static function add_publication_attributes_elements($form)
 837    {
 838        $form->addElement('category', Translation :: get('PublicationDetails'));
 839        $form->addElement('checkbox', self :: APPLICATION_NAME . '_opt_' . ContentObjectPublication :: PROPERTY_HIDDEN, Translation :: get('Hidden'));
 840        $form->add_forever_or_timewindow('PublicationPeriod', self :: APPLICATION_NAME . '_opt_');
 841        $form->addElement('category');
 842        $form->addElement('html', '<br />');
 843
 844        $defaults[self :: APPLICATION_NAME . '_opt_forever'] = 1;
 845        $form->setDefaults($defaults);
 846    }
 847
 848    /**
 849     * Count the number of courses
 850     * @param Condition $condition
 851     * @return int
 852     */
 853    function count_courses($condition = null)
 854    {
 855        return WeblcmsDataManager :: get_instance()->count_courses($condition);
 856    }
 857
 858    function count_course_types($condition = null)
 859    {
 860        return WeblcmsDataManager :: get_instance()->count_course_types($condition);
 861    }
 862
 863    function count_requests($condition = null)
 864    {
 865        return WeblcmsDataManager :: get_instance()->count_requests($condition);
 866    }
 867
 868    function count_course_create_requests($condition = null)
 869    {
 870        return WeblcmsDataManager :: get_instance()->count_course_create_requests($condition);
 871    }
 872
 873    function count_requests_by_course($condition = null)
 874    {
 875        return WeblcmsDataManager :: get_instance()->count_requests_by_course($condition);
 876    }
 877
 878    function subscribe_user_to_allowed_courses($user_id)
 879    {
 880        return WeblcmsDataManager :: get_instance()->subscribe_user_to_allowed_courses($user_id);
 881    }
 882
 883    /**
 884     * Count the number of course categories
 885     * @param Condition $condition
 886     * @return int
 887     */
 888    function count_course_categories($condition = null)
 889    {
 890        return WeblcmsDataManager :: get_instance()->count_course_categories($condition);
 891    }
 892
 893    /**
 894     * Count the number of courses th user is subscribed to
 895     * @param Condition $condition
 896     * @return int
 897     */
 898    function count_user_courses($condition = null)
 899    {
 900        return WeblcmsDataManager :: get_instance()->count_user_courses($condition);
 901    }
 902
 903    /**
 904     * Count the number of course user categories
 905     * @param Condition $condition
 906     * @return int
 907     */
 908    function count_course_user_categories($condition = null)
 909    {
 910        return WeblcmsDataManager :: get_instance()->count_course_user_categories($condition);
 911    }
 912
 913    /**
 914     * Retrieves the course categories that match the criteria from persistent storage.
 915     * @param string $parent The parent of the course category.
 916     * @return DatabaseCourseCategoryResultSet The resultset of course category.
 917     */
 918    function retrieve_course_categories($conditions = null, $offset = null, $count = null, $order_by = null)
 919    {
 920        return WeblcmsDataManager :: get_instance()->retrieve_course_categories($conditions, $offset, $count, $order_by);
 921    }
 922
 923    /**
 924     * Retrieves the personal course categories for a given user.
 925     * @return DatabaseUserCourseCategoryResultSet The resultset of course categories.
 926     */
 927    function retrieve_course_user_categories($conditions = null, $offset = null, $count = null, $order_property = null)
 928    {
 929        return WeblcmsDataManager :: get_instance()->retrieve_course_user_categories($conditions, $offset, $count, $order_property);
 930    }
 931
 932    /**
 933     * Retrieves a personal course category for the user.
 934     * @return CourseUserCategory The course user category.
 935     */
 936    function retrieve_course_user_category($condition = null)
 937    {
 938        return WeblcmsDataManager :: get_instance()->retrieve_course_user_category($condition);
 939    }
 940
 941    function retrieve_course_type_user_category($condition = null)
 942    {
 943        return WeblcmsDataManager :: get_instance()->retrieve_course_type_user_category($condition);
 944    }
 945
 946    /**
 947     * Retrieves a personal course category for the user according to
 948     * @param int $user_id
 949     * @param int $sort
 950     * @param string $direction
 951     * @return CourseUserCategory The course user category.
 952     */
 953    function retrieve_course_type_user_category_at_sort($user_id, $course_type_id, $sort, $direction)
 954    {
 955        return WeblcmsDataManager :: get_instance()->retrieve_course_type_user_category_at_sort($user_id, $course_type_id, $sort, $direction);
 956    }
 957
 958    /**
 959     * Retrieves a single course from persistent storage.
 960     * @param string $course_code The alphanumerical identifier of the course.
 961     * @return Course The course.
 962     */
 963    function retrieve_course($course_code)
 964    {
 965        return WeblcmsDataManager :: get_instance()->retrieve_course($course_code);
 966    }
 967
 968    function retrieve_requests_by_course($id)
 969    {
 970        return WeblcmsDataManager :: get_instance()->retrieve_requests_by_course($id);
 971    }
 972
 973    function retrieve_course_type($course_type_id)
 974    {
 975        return WeblcmsDataManager :: get_instance()->retrieve_course_type($course_type_id);
 976    }
 977
 978    function retrieve_course_type_user_categories($condition = null, $offset = null, $count = null, $order_property = null)
 979    {
 980        return WeblcmsDataManager :: get_instance()->retrieve_course_type_user_categories($condition, $offset, $count, $order_property);
 981    }
 982
 983    function retrieve_course_types($condition = null, $offset = null, $count = null, $order_property = null)
 984    {
 985        return WeblcmsDataManager :: get_instance()->retrieve_course_types($condition, $offset, $count, $order_property);
 986    }
 987
 988    function retrieve_requests($condition = null, $offset = null, $count = null, $order_property = null)
 989    {
 990        return WeblcmsDataManager :: get_instance()->retrieve_requests($condition, $offset, $count, $order_property);
 991    }
 992
 993    function retrieve_course_create_requests($condition = null, $offset = null, $count = null, $order_property = null)
 994    {
 995        return WeblcmsDataManager :: get_instance()->retrieve_course_create_requests($condition, $offset, $count, $order_property);
 996    }
 997
 998    function retrieve_active_course_types()
 999    {
1000        return WeblcmsDataManager :: get_instance()->retrieve_active_course_types();
1001    }
1002
1003    function count_active_course_types()
1004    {
1005        return WeblcmsDataManager :: get_instance()->count_active_course_type();
1006    }
1007
1008    /**
1009     * Retrieves a single course category from persistent storage.
1010     * @param string $category_code The alphanumerical identifier of the course category.
1011     * @return CourseCategory The course category.
1012     */
1013    function retrieve_course_category($course_category)
1014    {
1015        return WeblcmsDataManager :: get_instance()->retrieve_course_category($course_category);
1016    }
1017
1018    /**
1019     * Retrieves a single course user relation from persistent storage.
1020     * @param string $course_code
1021     * @param int $user_id
1022     * @return CourseCategory The course category.
1023     */
1024    function retrieve_course_user_relation($course_code, $user_id)
1025    {
1026        return WeblcmsDataManager :: get_instance()->retrieve_course_user_relation($course_code, $user_id);
1027    }
1028
1029    /**
1030     * Retrieves the next course user relation according to.
1031     * @param int $user_id
1032     * @param int $category_id
1033     * @param int $sort
1034     * @param string $direction
1035     * @return CourseUserRelationResultSet
1036     */
1037    function retrieve_course_user_relation_at_sort($user_id, $course_type_id, $category_id, $sort, $direction)
1038    {
1039        return WeblcmsDataManager :: get_instance()->retrieve_course_user_relation_at_sort($user_id, $course_type_id, $category_id, $sort, $direction);
1040    }
1041
1042    /**
1043     * Retrieves a set of course user relations
1044     * @param int $user_id
1045     * @param string $course_user_category
1046     */
1047    function retrieve_course_user_relations($condition = null, $offset = null, $count = null, $order_property = null)
1048    {
1049        return WeblcmsDataManager :: get_instance()->retrieve_course_user_relations($condition, $offset, $count, $order_property);
1050    }
1051
1052    /**
1053     * Retrieve a series of courses
1054     * @param User $user
1055     * @param string $category
1056     * @param Condition $condition
1057     * @param array $order_by
1058     * @param int $offset
1059     * @param int $max_objects
1060     * @return CourseResultSet
1061     */
1062    function retrieve_courses($condition = null, $offset = null, $count = null, $order_property = null)
1063    {
1064        return WeblcmsDataManager :: get_instance()->retrieve_courses($condition, $offset, $count, $order_property);
1065    }
1066
1067    /**
1068     * Retrieve a series of courses for a specific user + the relation
1069     * @param Condition $condition
1070     * @param array $order_by
1071     * @param int $offset
1072     * @param int $max_objects
1073     * @return CourseResultSet
1074     */
1075    function retrieve_user_courses($condition = null, $offset = null, $count = null, $order_property = null)
1076    {
1077        return WeblcmsDataManager :: get_instance()->retrieve_user_courses($condition, $offset, $count, $order_property);
1078    }
1079    
1080    /**
1081     * Gets the date of the last visit of current user to the current location
1082     * @param string $tool If $tool equals null, current active tool will be
1083     * taken into account. If no tool is given or no tool is active the date of
1084     * last visit to the course homepage will be returned.
1085     * @param int $category_id The category in the given tool of which the last
1086     * visit date is requested. If $category_id equals null, the current active
1087     * category will be used.
1088     * @return int
1089     */
1090    function get_last_visit_date($tool = null, $category_id = null)
1091    {
1092        if (is_null($tool))
1093        {
1094            $tool = $this->get_parameter(self :: PARAM_TOOL);
1095        }
1096        if (is_null($category_id))
1097        {
1098            $category_id = $this->get_parameter(self :: PARAM_CATEGORY);
1099            if (is_null($category_id))
1100            {
1101                $category_id = 0;
1102            }
1103        }
1104        $wdm = WeblcmsDataManager :: get_instance();
1105        $date = $wdm->get_last_visit_date($this->get_course_id(), $this->get_user_id(), $tool, $category_id);
1106        return $date;
1107    }
1108
1109    /**
1110     * Determines if a tool has new publications  since the last time the
1111     * current user visited the tool.
1112     * @param string $tool
1113     * @param Course $course
1114     */
1115    function tool_has_new_publications($tool, Course $course = null)
1116    {
1117        if ($course == null)
1118        {
1119            $course = $this->get_course();
1120        }
1121
1122        return WeblcmsDataManager :: tool_has_new_publications($tool, $this->get_user(), $course);
1123    }
1124
1125    /**
1126     * Returns the url to the course's page
1127     * @param Course $course
1128     * @return String
1129     */
1130    function get_course_viewing_url($course)
1131    {
1132        return $this->get_url(array(
1133                self :: PARAM_ACTION => self :: ACTION_VIEW_COURSE,
1134                self :: PARAM_COURSE => $course->get_id()));
1135    }
1136
1137    function retrieve_request($id)
1138    {
1139        return WeblcmsDataManager :: get_instance()->retrieve_request($id);
1140    }
1141
1142    function retrieve_course_create_request($id)
1143    {
1144        return WeblcmsDataManager :: get_instance()->retrieve_course_create_request($id);
1145    }
1146
1147    /**
1148     * Returns the link to the course's page
1149     * @param Course $course
1150     * @return String
1151     */
1152    function get_course_viewing_link($course, $encode = false)
1153    {
1154        return $this->get_link(array(
1155                self :: PARAM_ACTION => self :: ACTION_VIEW_COURSE,
1156                self :: PARAM_COURSE => $course->get_id()), $encode);
1157    }
1158
1159    /**
1160     * Returns the editing url for the course
1161     * @param Course $course
1162     * @return String
1163     */
1164    function get_course_editing_url($course)
1165    {
1166        return $this->get_url(array(
1167                self :: PARAM_ACTION => self :: ACTION_CREATE_COURSE,
1168                self :: PARAM_COURSE => $course->get_id(),
1169                self :: PARAM_TOOL => 'course_settings',
1170                'previous' => 'admin'));
1171    }
1172
1173    /**
1174     * Returns the deleting url for the course
1175     * @param Course $course
1176     * @return String
1177     */
1178    function get_course_deleting_url($course)
1179    {
1180        return $this->get_url(array(
1181                self :: PARAM_ACTION => self :: ACTION_DELETE_COURSE,
1182                self :: PARAM_COURSE => $course->get_id()));
1183    }
1184
1185    /**
1186     * Returns the maintenance url for the course
1187     * @param Course $course
1188     * @return String
1189     */
1190    function get_course_maintenance_url($course)
1191    {
1192        return $this->get_url(array(
1193                self :: PARAM_ACTION => self :: ACTION_VIEW_COURSE,
1194                self :: PARAM_COURSE => $course->get_id(),
1195                self :: PARAM_TOOL => 'maintenance'));
1196    }
1197
1198    /**
1199     * Returns the subscription url for the course
1200     * @param Course $course
1201     * @return String
1202     */
1203    function get_course_subscription_url($course)
1204    {
1205        return $this->get_url(array(
1206                self :: PARAM_ACTION => self :: ACTION_MANAGER_SUBSCRIBE,
1207                self :: PARAM_COURSE => $course->get_id()));
1208    }
1209
1210    function get_course_request_form_url($course)
1211    {
1212        return $this->get_url(array(
1213                self :: PARAM_ACTION => self :: ACTION_COURSE_SUBSCRIBE_CREATE_REQUEST,
1214                self :: PARAM_COURSE => $course->get_id()));
1215
1216    }
1217
1218    function get_course_code_url($course)
1219    {
1220        return $this->get_url(array(
1221                self :: PARAM_ACTION => self :: ACTION_COURSE_CODE,
1222                self :: PARAM_COURSE => $course->get_id()));
1223    }
1224
1225    /**
1226     * Returns the unsubscription url for the course
1227     * @param Course $course
1228     * @return String
1229     */
1230    function get_course_unsubscription_url($course)
1231    {
1232        return $this->get_url(array(
1233                self :: PARAM_ACTION => self :: ACTION_MANAGER_UNSUBSCRIBE,
1234                self :: PARAM_COURSE => $course->get_id()));
1235    }
1236
1237    /**
1238     * Returns the editing url for the course user category
1239     * @param CourseUsercategory $course_user_category
1240     * @return String
1241     */
1242    function get_course_user_category_edit_url(CourseTypeUserCategory $course_type_user_category)
1243    {
1244        return $this->get_url(array(
1245                self :: PARAM_ACTION => self :: ACTION_MANAGER_SORT,
1246                self :: PARAM_COMPONENT_ACTION => 'edit',
1247                self :: PARAM_COURSE_TYPE_USER_CATEGORY_ID => $course_type_user_category->get_id()));
1248    }
1249
1250    /**
1251     * Returns the creating url for a course user category
1252     * @return String
1253     */
1254    function get_course_user_category_add_url()
1255    {
1256        return $this->get_url(array(
1257                self :: PARAM_ACTION => self :: ACTION_MANAGER_SORT,
1258                self :: PARAM_COMPONENT_ACTION => 'add'));
1259    }
1260
1261    /**
1262     * Returns the moving url for the course user category
1263     * @param CourseUserCategory $course_user_category
1264     * @param string $direction
1265     * @return String
1266     */
1267    function get_course_user_category_move_url(CourseTypeUserCategory $course_type_user_category, $direction)
1268    {
1269        return $this->get_url(array(
1270                self :: PARAM_ACTION => self :: ACTION_MANAGER_SORT,
1271                self :: PARAM_COMPONENT_ACTION => 'movecat',
1272                self :: PARAM_DIRECTION => $direction,
1273                self :: PARAM_COURSE_TYPE_USER_CATEGORY_ID => $course_type_user_category->get_id()));
1274    }
1275
1276    /**
1277     * Returns the deleting url for the course user category
1278     * @param CourseUserCategory $course_user_category
1279     * @return String
1280     */
1281    function get_course_user_category_delete_url(CourseTypeUserCategory $course_type_user_category)
1282    {
1283        return $this->get_url(array(
1284                self :: PARAM_ACTION => self :: ACTION_MANAGER_SORT,
1285                self :: PARAM_COMPONENT_ACTION => 'delete',
1286                self :: PARAM_COURSE_TYPE_USER_CATEGORY_ID => $course_type_user_category->get_id()));
1287    }
1288
1289    /**
1290     * Returns the editing url for the course category
1291     * @param CourseCategory $course_category
1292     * @return String
1293     */
1294    function get_course_category_edit_url($course_category)
1295    {
1296        return $this->get_url(array(
1297                self :: PARAM_ACTION => self :: ACTION_COURSE_CATEGORY_MANAGER,
1298                self :: PARAM_COMPONENT_ACTION => 'edit',
1299                self :: PARAM_COURSE_CATEGORY => $course_category->get_code()));
1300    }
1301
1302    /**
1303     * Returns the creating url for a course category
1304     * @return String
1305     */
1306    function get_course_category_add_url()
1307    {
1308        return $this->get_url(array(
1309                self :: PARAM_ACTION => self :: ACTION_COURSE_CATEGORY_MANAGER,
1310                self :: PARAM_COMPONENT_ACTION => 'add'));
1311    }
1312
1313    /**
1314     * Returns the deleting url for the course category
1315     * @param CourseCategory $course_category
1316     * @return String
1317     */
1318    function get_course_category_delete_url($coursecategory)
1319    {
1320        return $this->get_url(array(
1321                self :: PARAM_ACTION => self :: ACTION_COURSE_CATEGORY_MANAGER,
1322                self :: PARAM_COMPONENT_ACTION => 'delete',
1323                self :: PARAM_COURSE_CATEGORY_ID => $coursecategory->get_code()));
1324    }
1325
1326    /**
1327     * Returns the editing url for the course user relation
1328     * @param Course $course
1329     * @return String
1330     */
1331    function get_course_user_edit_url(CourseTypeUserCategory $course_type_user_category, Course $course)
1332    {
1333        if ($course_type_user_category)
1334        {
1335            $course_type_user_category_id = $course_type_user_category->get_id();
1336        }
1337
1338        return $this->get_url(array(
1339                self :: PARAM_ACTION => self :: ACTION_MANAGER_SORT,
1340                self :: PARAM_COMPONENT_ACTION => 'assign',
1341                self :: PARAM_COURSE => $course->get_id(),
1342                self :: PARAM_COURSE_TYPE_USER_CATEGORY_ID => $course_type_user_category_id));
1343    }
1344
1345    /**
1346     * Returns the moving url for the course user relation
1347     * @param Course $course
1348     * @param string $direction
1349     * @return String
1350     */
1351    function get_course_user_move_url(CourseTypeUserCategory $course_type_user_category, Course $course, $direction)
1352    {
1353        return $this->get_url(array(
1354                self :: PARAM_ACTION => self :: ACTION_MANAGER_SORT,
1355                self :: PARAM_COMPONENT_ACTION => 'move',
1356                self :: PARAM_DIRECTION => $direction,
1357                self :: PARAM_COURSE => $course->get_id(),
1358                self :: PARAM_COURSE_TYPE_USER_CATEGORY_ID => $course_type_user_category->get_id()));
1359    }
1360
1361    /**
1362     * Checks whether subscription to the course is allowed for the current user
1363     * @param Course $course
1364     * @return boolean
1365     */
1366    function course_subscription_allowed($course)
1367    {
1368        return WeblcmsDataManager :: course_subscription_allowed($course, $this->get_user());
1369    }
1370
1371    /**
1372     * Checks whether unsubscription from the course is allowed for the current user
1373     * @param Course $course
1374     * @return boolean
1375     */
1376    function course_unsubscription_allowed($course)
1377    {
1378        return WeblcmsDataManager :: course_unsubscription_allowed($course, $this->get_user());
1379    }
1380
1381    /**
1382     * Checks whether the user is subscribed to the given course
1383     * @param Course $course
1384     * @param User $user
1385     * @return boolean
1386     */
1387    function is_subscribed($course, $user)
1388    {
1389        $wdm = WeblcmsDa…

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