public function parseAdminTable(ilDateTime $start, ilDateTime $end)
 {
     $booking_list = array();
     try {
         $con = new ilViteroBookingSoapConnector();
         $bookings = $con->getBookingListByDate(ilViteroSettings::getInstance()->getCustomer(), $start, $end);
     } catch (Exception $e) {
         throw $e;
     }
     $booking_arr = array();
     if (is_object($bookings->booking)) {
         $booking_arr = array($bookings->booking);
     } elseif (is_array($bookings->booking)) {
         $booking_arr = $bookings->booking;
     }
     $counter = 0;
     foreach ($booking_arr as $booking) {
         $fstart = ilViteroUtils::parseSoapDate($booking->start);
         $fend = ilViteroUtils::parseSoapDate($booking->end);
         $duration = $fend->get(IL_CAL_UNIX) - $fstart->get(IL_CAL_UNIX);
         $booking_list[$counter]['rec'] = $booking->repetitionpattern;
         $booking_list[$counter]['id'] = $booking->bookingid;
         $booking_list[$counter]['start'] = $fstart;
         $booking_list[$counter]['startt'] = $fstart->get(IL_CAL_UNIX);
         $bend = ilViteroUtils::parseSoapDate($booking->end);
         $booking_list[$counter]['end'] = $bend;
         if ($booking->cafe) {
             $booking_list[$counter]['start'] = new ilDate($booking_list[$counter]['startt'], IL_CAL_UNIX);
             $booking_list[$counter]['time'] = ilDatePresentation::formatDate($booking_list[$counter]['start']);
         } else {
             $booking_list[$counter]['time'] = ilDatePresentation::formatPeriod($booking_list[$counter]['start'], $booking_list[$counter]['end']);
         }
         $booking_list[$counter]['duration'] = ilFormat::_secondsToString($booking_list[$counter]['end']->get(IL_CAL_UNIX) - $booking_list[$counter]['start']->get(IL_CAL_UNIX), false);
         if ($booking->repetitionpattern) {
             $repend = ilViteroUtils::parseSoapDate($booking->repetitionenddate);
             $booking_list[$counter]['ends'] = ilDatePresentation::formatDate(new ilDate($repend->get(IL_CAL_UNIX), IL_CAL_UNIX));
         }
         $booking_list[$counter]['group'] = ilObjVitero::lookupObjIdByGroupId($booking->groupid);
         $counter++;
     }
     $this->setMaxCount(count($booking_list));
     $this->setData($booking_list);
 }
 /**
  * start session
  * @global <type> $ilDB
  */
 public function startSession()
 {
     global $ilDB, $ilUser, $ilCtrl, $ilAccess;
     // Handle deleted accounts
     ilObjVitero::handleDeletedUsers();
     try {
         // Create update user
         $map = new ilViteroUserMapping();
         $vuid = $map->getVUserId($ilUser->getId());
         $ucon = new ilViteroUserSoapConnector();
         if (!$vuid) {
             $vuid = $ucon->createUser($ilUser);
             $map->map($ilUser->getId(), $vuid);
         } else {
             try {
                 $ucon->updateUser($vuid, $ilUser);
             } catch (ilViteroConnectorException $e) {
                 if ($e->getCode() == 53) {
                     $map->unmap($ilUser->getId());
                     $vuid = $ucon->createUser($ilUser);
                     $map->map($ilUser->getId(), $vuid);
                 }
             }
         }
         // Store update image
         if (ilViteroSettings::getInstance()->isAvatarEnabled()) {
             $usr_image_path = ilUtil::getWebspaceDir() . '/usr_images/usr_' . $ilUser->getId() . '.jpg';
             if (@file_exists($usr_image_path)) {
                 $ucon->storeAvatarUsingBase64($vuid, array('name' => 'usr_image.jpg', 'type' => ilViteroAvatarSoapConnector::FILE_TYPE_NORMAL, 'file' => $usr_image_path));
             }
         }
         /*
         			if(ilViteroSettings::getInstance()->isAvatarEnabled() and 0)
         			{
         				try {
         					$avatar_service = new ilViteroAvatarSoapConnector();
         					$usr_image_path = ilUtil::getWebspaceDir().'/usr_images/usr_'.$ilUser->getId().'.jpg';
         
         					if(@file_exists($usr_image_path))
         					{
         						$avatar_service->storeAvatar(
         							$vuid,
         							array(
         								'name' => 'usr_image.jpg',
         								'type' => ilViteroAvatarSoapConnector::FILE_TYPE_NORMAL,
         								'file' => $usr_image_path
         							)
         						);
         					}
         				}
         				catch(ilViteroConnectorException $e)
         				{
         					// continue
         				}
         			}
         */
         // Assign user to vitero group
         $grp = new ilViteroGroupSoapConnector();
         $grp->addUserToGroup($this->object->getVGroupId(), $vuid);
         $grp->changeGroupRole($this->object->getVGroupId(), $vuid, $ilAccess->checkAccess('write', '', $this->object->getRefId()) ? ilViteroGroupSoapConnector::ADMIN_ROLE : ilViteroGroupSoapConnector::MEMBER_ROLE);
         $sc = new ilViteroSessionCodeSoapConnector();
         $dur = new ilDateTime(time(), IL_CAL_UNIX);
         $dur->increment(IL_CAL_HOUR, 2);
         $code = $sc->createPersonalBookingSessionCode($vuid, (int) $_GET['bid'], $dur);
         $GLOBALS['ilLog']->write(__METHOD__ . ': ' . ilViteroSettings::getInstance()->getWebstartUrl() . '?code=' . $code);
         ilUtil::redirect(ilViteroSettings::getInstance()->getWebstartUrl() . '?sessionCode=' . $code);
     } catch (ilViteroConnectorException $e) {
         ilUtil::sendFailure($e->getViteroMessage(), true);
         $ilCtrl->redirect($this, 'infoScreen');
     }
 }
示例#3
0
 public static function handleDeletedGroups()
 {
     global $ilDB;
     $query = 'SELECT child, obd.obj_id FROM tree ' . 'JOIN object_reference obr ON child = ref_id ' . 'JOIN object_data obd ON obr.obj_id = obd.obj_id ' . 'WHERE type = ' . $ilDB->quote('xvit', 'text') . ' ' . 'AND tree < ' . $ilDB->quote(0, 'integer');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if (!ilObject::_hasUntrashedReference($row->obj_id)) {
             try {
                 $vgroup_id = ilObjVitero::lookupVGroupId($row->obj_id);
                 if (!$vgroup_id) {
                     continue;
                 }
                 $start = new ilDate(time(), IL_CAL_UNIX);
                 $end = clone $start;
                 $start->increment(IL_CAL_YEAR, -2);
                 $end->increment(IL_CAL_YEAR, 2);
                 $booking_service = new ilViteroBookingSoapConnector();
                 $books = $booking_service->getByGroupAndDate($vgroup_id, $start, $end);
                 if (is_object($books->booking)) {
                     try {
                         $booking_service->deleteBooking($books->booking->bookingid);
                     } catch (ilViteroConnectorException $e) {
                         $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting deprecated booking failed with message: ' . $e->getMessage());
                     }
                 }
                 if (is_array($books->booking)) {
                     foreach ((array) $books->booking as $book) {
                         try {
                             $booking_service->deleteBooking($book->bookingid);
                         } catch (ilViteroConnectorException $e) {
                             $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting deprecated booking failed with message: ' . $e->getMessage());
                         }
                     }
                 }
             } catch (ilViteroConnectorException $e) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot read bookings of group "' . $vgroup_id . '": ' . $e->getMessage());
             }
         }
         // Delete group
         try {
             $groups = new ilViteroGroupSoapConnector();
             $groupDefinition = new ilViteroGroupSoap();
             $groupDefinition->groupid = $vgroup_id;
             $groups->delete($groupDefinition);
             // Update vgroup id
             $query = 'UPDATE rep_robj_xvit_data ' . 'SET vgroup_id = 0 ' . 'WHERE obj_id = ' . $ilDB->quote($row->obj_id, 'integer');
             $ilDB->manipulate($query);
         } catch (ilViteroConnectorException $e) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Delete group failed: "' . $vgroup_id . '": ' . $e->getMessage());
         }
     }
 }