/**
  * Get item properties
  *
  * Overwrite this method to add properties at
  * the bottom of the item html
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 function getProperties($a_item = '')
 {
     //var_dump($a_item);
     global $ilias;
     $props = array();
     // docent
     include_once './Modules/ILinc/classes/class.ilObjiLincClassroom.php';
     $docent = ilObjiLincClassroom::_getDocent($a_item['instructoruserid']);
     if (!$docent) {
         $props[] = array("alert" => true, "property" => $this->lng->txt(ILINC_MEMBER_DOCENT), "value" => $this->lng->txt('ilinc_no_docent_assigned'));
     } else {
         $props[] = array("alert" => false, "property" => $this->lng->txt(ILINC_MEMBER_DOCENT), "value" => $docent);
     }
     // display offline/online status
     if ($a_item['alwaysopen']) {
         $props[] = array("alert" => false, "property" => $this->lng->txt("status"), "value" => $this->lng->txt("ilinc_classroom_always_open"));
     } else {
         $props[] = array("alert" => true, "property" => $this->lng->txt("status"), "value" => $this->lng->txt("ilinc_classroom_closed"));
     }
     // display cost centers if active
     /*
     		if ($ilias->getSetting("ilinc_akclassvalues_active"))
     		{
     $akclassvalues = ilObjiLincClassroom::_getDocent($a_item['instructoruserid']);
     
     			$value = "";
     			
     			if (!empty($akclassvalues[0]))
     			{
     				$value = $akclassvalues[0];
     				$property = $lng->txt("ilinc_akclassvalue");
     				
     				if (!empty($akclassvalues[1]))
     				{
     					$value .= " / ".$akclassvalues[1];
     					$property = $lng->txt("ilinc_akclassvalues");
     				}
     			}
     			elseif (!empty($akclassvalues[1]))
     			{
     				$value = $akclassvalues[1];
     				$property = $lng->txt("ilinc_akclassvalue");
     			}
     			else
     			{
     				$property = $lng->txt("ilinc_akclassvalues");
     				$value = $lng->txt("ilinc_no_akclassvalues");
     			}
     		}*/
     return $props;
 }
    function _getDocent($a_ilinc_user_id)
    {
        global $ilDB, $lng;
        $fullname = false;
        $ilDB->setLimit(1);
        $r = $ilDB->queryf('
			SELECT title, firstname, lastname FROM usr_data
			WHERE ilinc_id = %s', array('integer'), array($a_ilinc_user_id));
        while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) {
            $fullname = ilObjiLincClassroom::_setFullname($row->title, $row->firstname, $row->lastname);
        }
        return $fullname;
    }
 /**
  * save object
  * @access	public
  */
 public function save()
 {
     $this->prepareOutput();
     $this->initSettingsForm('create');
     if ($this->form_gui->checkInput()) {
         $_POST['Fobject']['title'] = $this->form_gui->getInput('title');
         $_POST['Fobject']['desc'] = $this->form_gui->getInput('desc');
         $_POST['Fobject']['instructoruserid'] = $this->form_gui->getInput('instructoruserid');
         $_POST['Fobject']['alwaysopen'] = $this->form_gui->getInput('alwaysopen');
         // Akclassvalues
         if ($this->ilias->getSetting('ilinc_akclassvalues_active')) {
             $icrs_obj_id = ilObject::_lookupObjectId($this->parent);
             include_once 'Modules/ILinc/classes/class.ilObjiLincCourse.php';
             $akclassvalues = ilObjiLincCourse::_getAKClassValues($icrs_obj_id);
             $_POST['Fobject']['akclassvalue1'] = $akclassvalues[0];
             $_POST['Fobject']['akclassvalue2'] = $akclassvalues[1];
         }
         $ilinc_course_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
         $this->object->ilincAPI->addClass($ilinc_course_id, $_POST['Fobject']);
         $response = $this->object->ilincAPI->sendRequest('addClass');
         if ($response->isError()) {
             $this->ilErr->raiseError($response->getErrorMsg(), $this->ilErr->MESSAGE);
         }
         // Always send a message
         ilUtil::sendInfo($response->getResultMsg(), true);
         $this->ctrl->redirectByClass('ilobjilinccoursegui');
     } else {
         if ($this->ilias->getSetting('ilinc_akclassvalues_active')) {
             $icrs_obj_id = ilObject::_lookupObjectId($this->parent);
             include_once 'Modules/ILinc/classes/class.ilObjiLincCourse.php';
             $akclassvalues = ilObjiLincCourse::_getAKClassValues($icrs_obj_id);
             $_POST['akclassvalue1'] = $akclassvalues[0];
             $_POST['akclassvalue2'] = $akclassvalues[1];
         }
         $this->form_gui->setValuesByPost();
         return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
     }
 }
 function updateClassrooms()
 {
     global $ilErr;
     $this->ilincAPI->findCourseClasses($this->getiLincId());
     $response = $this->ilincAPI->sendRequest();
     if ($response->isError()) {
         if (!$response->getErrorMsg()) {
             $this->error_msg = "err_get_classrooms";
         } else {
             $this->error_msg = $response->getErrorMsg();
         }
         return false;
     }
     if (!$response->data['classes']) {
         $this->error_msg = $response->data['result']['cdata'];
         return false;
     }
     if (array_key_exists('akclassvalue1', $_POST["Fobject"])) {
         $data["akclassvalue1"] = $_POST["Fobject"]["akclassvalue1"];
     }
     if (array_key_exists('akclassvalue2', $_POST["Fobject"])) {
         $data["akclassvalue2"] = $_POST["Fobject"]["akclassvalue2"];
     }
     foreach ($response->data['classes'] as $class_id => $data2) {
         include_once "./Modules/ILinc/classes/class.ilObjiLincClassroom.php";
         $icla_obj = new ilObjiLincClassroom($class_id, $this->ref_id);
         if (!$icla_obj->update($data)) {
             $this->error_msg = $icla_obj->getErrorMsg();
             return false;
         }
         unset($icla_obj);
     }
     return true;
 }