Ejemplo n.º 1
0
 /**
  * addMobilePhoneNumberField (adds a mobile phone number field if it is not
  * already created)
  * @return  void
  */
 private function addMobilePhoneNumberField()
 {
     $extraField = new ExtraField('user');
     $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable('mobile_phone_number');
     if (empty($extraFieldInfo)) {
         $extraField->save(array('field_type' => 1, 'variable' => 'mobile_phone_number', 'display_text' => $this->get_lang('mobile_phone_number'), 'default_value' => null, 'field_order' => 2, 'visible' => 1, 'changeable' => 1, 'filter' => null));
     }
 }
 /**
  * addAreaField() (adds an area field if it is not already created)
  * @return void
  */
 private function addAreaField()
 {
     $extraField = new ExtraField('user');
     $extraFieldHandler = $extraField->get_handler_field_info_by_field_variable('area');
     $areaExists = $extraFieldHandler !== false;
     if (!$areaExists) {
         $extraField = new ExtraField('user');
         $extraField->save(array('field_type' => 1, 'variable' => 'area', 'display_text' => get_plugin_lang('Area', 'AdvancedSubscriptionPlugin'), 'default_value' => null, 'field_order' => null, 'visible' => 1, 'changeable' => 1, 'filter' => null));
     }
 }
Ejemplo n.º 3
0
$show_full_profile = true;
if ($show_full_profile) {
    $t_ufo = Database::get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
    $extra_user_data = UserManager::get_extra_user_data($user_id, false, true);
    $extra_information = '';
    if (is_array($extra_user_data) && count($extra_user_data) > 0) {
        $extra_information_value = '';
        $extraField = new ExtraField('user');
        foreach ($extra_user_data as $key => $data) {
            // Avoiding parameters
            if (in_array($key, array('mail_notify_invitation', 'mail_notify_message', 'mail_notify_group_message'))) {
                continue;
            }
            // get display text, visibility and type from user_field table
            $field_variable = str_replace('extra_', '', $key);
            $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($field_variable);
            if ($extraFieldInfo['visible'] != 1) {
                continue;
            }
            if (is_array($data)) {
                $extra_information_value .= '<dt>' . ucfirst($extraFieldInfo['display_text']) . '</dt>' . '<dd> ' . implode(',', $data) . '</dd>';
            } else {
                switch ($extraFieldInfo['field_type']) {
                    case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                        $id_options = explode(';', $data);
                        $value_options = array();
                        // get option display text from user_field_options table
                        foreach ($id_options as $id_option) {
                            $sql = "SELECT display_text FROM {$t_ufo} WHERE id = '{$id_option}'";
                            $res_options = Database::query($sql);
                            $row_options = Database::fetch_row($res_options);
Ejemplo n.º 4
0
 /**
  * @param string $file
  * @param bool   $moveFile
  *
  * @return int
  */
 private function importCalendarStatic($file, $moveFile = true)
 {
     $data = Import::csv_to_array($file);
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         $eventsToCreate = array();
         $errorFound = false;
         foreach ($data as $row) {
             $sessionId = null;
             $externalSessionId = null;
             if (isset($row['external_sessionID'])) {
                 $externalSessionId = $row['external_sessionID'];
                 $sessionId = SessionManager::get_session_id_from_original_id($externalSessionId, $this->extraFieldIdNameList['session']);
             }
             $courseCode = null;
             if (isset($row['coursecode'])) {
                 $courseCode = $row['coursecode'];
             }
             $courseInfo = api_get_course_info($courseCode);
             if (empty($courseInfo)) {
                 $this->logger->addInfo("Course '{$courseCode}' does not exists");
             }
             if (empty($sessionId)) {
                 $this->logger->addInfo("external_sessionID: " . $externalSessionId . " does not exists.");
             }
             $teacherId = null;
             if (!empty($sessionId) && !empty($courseInfo)) {
                 $courseIncluded = SessionManager::relation_session_course_exist($sessionId, $courseInfo['code']);
                 if ($courseIncluded == false) {
                     $this->logger->addInfo("Course '{$courseCode}' is not included in session: {$sessionId}");
                     $errorFound = true;
                 } else {
                     $teachers = CourseManager::get_coach_list_from_course_code($courseInfo['code'], $sessionId);
                     // Getting first teacher.
                     if (!empty($teachers)) {
                         $teacher = current($teachers);
                         $teacherId = $teacher['user_id'];
                     } else {
                         $sessionInfo = api_get_session_info($sessionId);
                         $teacherId = $sessionInfo['id_coach'];
                     }
                 }
             } else {
                 $errorFound = true;
             }
             if (empty($teacherId)) {
                 $errorFound = true;
                 $this->logger->addInfo("No teacher found in course code : '{$courseCode}' and session: '{$sessionId}'");
             }
             $date = $row['date'];
             $startTime = $row['time_start'];
             $endTime = $row['time_end'];
             $title = $row['title'];
             $comment = $row['comment'];
             $color = isset($row['color']) ? $row['color'] : '';
             $startDateYear = substr($date, 0, 4);
             $startDateMonth = substr($date, 4, 2);
             $startDateDay = substr($date, 6, 8);
             $startDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $startTime . ":00";
             $endDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $endTime . ":00";
             if (!api_is_valid_date($startDate) || !api_is_valid_date($endDate)) {
                 $this->logger->addInfo("Verify your dates:  '{$startDate}' : '{$endDate}' ");
                 $errorFound = true;
             }
             // If old events do nothing.
             /*if (api_strtotime($startDate) < time()) {
                   continue;
               }*/
             if ($errorFound == false) {
                 $eventsToCreate[] = array('start' => $startDate, 'end' => $endDate, 'title' => $title, 'sender_id' => $teacherId, 'course_id' => $courseInfo['real_id'], 'session_id' => $sessionId, 'comment' => $comment, 'color' => $color, $this->extraFieldIdNameList['calendar_event'] => $row['external_calendar_itemID']);
             }
         }
         if (empty($eventsToCreate)) {
             $this->logger->addInfo("No events to add");
             return 0;
         }
         $this->logger->addInfo("Ready to insert events");
         $agenda = new Agenda();
         $extraFieldValue = new ExtraFieldValue('calendar_event');
         $extraFieldName = $this->extraFieldIdNameList['calendar_event'];
         $externalEventId = null;
         $extraField = new ExtraField('calendar_event');
         $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
         if (empty($extraFieldInfo)) {
             $this->logger->addInfo("No calendar event extra field created: {$extraFieldName}");
             return 0;
         }
         foreach ($eventsToCreate as $event) {
             $update = false;
             $item = null;
             if (!isset($event[$extraFieldName])) {
                 $this->logger->addInfo("No external_calendar_itemID found. Skipping ...");
                 continue;
             } else {
                 $externalEventId = $event[$extraFieldName];
                 if (empty($externalEventId)) {
                     $this->logger->addInfo("external_calendar_itemID was set but empty. Skipping ...");
                     continue;
                 }
                 $items = $extraFieldValue->get_item_id_from_field_variable_and_field_value($extraFieldName, $externalEventId, false, false, true);
                 $item = null;
                 foreach ($items as $tempItem) {
                     if ($tempItem['c_id'] == $event['course_id']) {
                         $item = $tempItem;
                     }
                 }
                 if (!empty($item)) {
                     $this->logger->addInfo("Event #{$externalEventId} was already added. Updating ...");
                     $update = true;
                     //continue;
                 }
             }
             $courseInfo = api_get_course_info_by_id($event['course_id']);
             $agenda->set_course($courseInfo);
             $agenda->setType('course');
             $agenda->setSessionId($event['session_id']);
             $agenda->setSenderId($event['sender_id']);
             $agenda->setIsAllowedToEdit(true);
             $eventComment = $event['comment'];
             $color = $event['color'];
             // To use the event comment you need
             // ALTER TABLE c_calendar_event ADD COLUMN comment TEXT;
             // add in configuration.php allow_agenda_event_comment = true
             if (empty($courseInfo)) {
                 $this->logger->addInfo("No course found for added: #" . $event['course_id'] . " Skipping ...");
                 continue;
             }
             if (empty($event['sender_id'])) {
                 $this->logger->addInfo("No sender found: #" . $event['sender_id'] . " Skipping ...");
                 continue;
             }
             $content = '';
             if ($update && isset($item['calendar_event_id'])) {
                 //the event already exists, just update
                 $eventId = $agenda->edit_event($item['calendar_event_id'], $event['start'], $event['end'], false, $event['title'], $content, array('everyone'), array(), null, $eventComment, $color);
                 if ($eventId !== false) {
                     $this->logger->addInfo("Event updated: #{$eventId}");
                 } else {
                     $this->logger->addInfo("Error while updating event.");
                 }
             } else {
                 // New event. Create it.
                 $eventId = $agenda->add_event($event['start'], $event['end'], false, $event['title'], $content, array('everyone'), false, null, array(), null, $eventComment, $color);
                 if (!empty($eventId)) {
                     $extraFieldValue->is_course_model = true;
                     $extraFieldValue->save(array('field_value' => $externalEventId, 'field_id' => $extraFieldInfo['id'], 'calendar_event_id' => $eventId, 'c_id' => $event['course_id']));
                     $this->logger->addInfo("Event added: #{$eventId}");
                 } else {
                     $this->logger->addInfo("Error while creating event.");
                 }
             }
         }
     }
     if ($moveFile) {
         $this->moveFile($file);
     }
 }
Ejemplo n.º 5
0
 /**
  * Saves a series of records given as parameter into the coresponding table
  * @param array  Structured parameter for the insertion into the *_field_values table
  * @return mixed false on empty params, void otherwise
  * @assert (array()) === false
  */
 public function save_field_values($params)
 {
     $extra_field = new ExtraField($this->type);
     if (empty($params[$this->handler_id])) {
         return false;
     }
     foreach ($params as $key => $value) {
         $found = strpos($key, '__persist__');
         if ($found) {
             $tempKey = str_replace('__persist__', '', $key);
             if (!isset($params[$tempKey])) {
                 $params[$tempKey] = array();
             }
             break;
         }
     }
     // Parse params.
     foreach ($params as $key => $value) {
         if (substr($key, 0, 6) == 'extra_') {
             // An extra field.
             $field_variable = substr($key, 6);
             $extra_field_info = $extra_field->get_handler_field_info_by_field_variable($field_variable);
             if ($extra_field_info) {
                 $commentVariable = 'extra_' . $field_variable . '_comment';
                 $comment = isset($params[$commentVariable]) ? $params[$commentVariable] : null;
                 switch ($extra_field_info['field_type']) {
                     case ExtraField::FIELD_TYPE_TAG:
                         $old = self::getAllValuesByItemAndField($extra_field_info['id'], $params[$this->handler_id]);
                         $deleteItems = array();
                         if (!empty($old)) {
                             $oldIds = array();
                             foreach ($old as $oldItem) {
                                 $oldIds[] = $oldItem['field_value'];
                             }
                             $deleteItems = array_diff($oldIds, $value);
                         }
                         foreach ($value as $optionId) {
                             $new_params = array($this->handler_id => $params[$this->handler_id], 'field_id' => $extra_field_info['id'], 'field_value' => $optionId, 'comment' => $comment);
                             self::save($new_params);
                         }
                         if (!empty($deleteItems)) {
                             foreach ($deleteItems as $deleteFieldValue) {
                                 self::deleteValuesByHandlerAndFieldAndValue($extra_field_info['id'], $params[$this->handler_id], $deleteFieldValue);
                             }
                         }
                         break;
                     default:
                         $new_params = array($this->handler_id => $params[$this->handler_id], 'field_id' => $extra_field_info['id'], 'field_value' => $value, 'comment' => $comment);
                         self::save($new_params);
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Get the extra field information for a certain field (the options as well)
  * @param  int     $variable The name of the field we want to know everything about
  * @return array   Array containing all the information about the extra profile field
  * (first level of array contains field details, then 'options' sub-array contains options details,
  * as returned by the database)
  * @author Julio Montoya
  * @since v1.8.6
  */
 public static function get_extra_field_information_by_name($variable)
 {
     $extraField = new ExtraField('user');
     return $extraField->get_handler_field_info_by_field_variable($variable);
 }
Ejemplo n.º 7
0
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
$form->addGroup($group, '', get_lang('CourseAccess'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$form->addGroup($group, '', get_lang('Subscription'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get_lang('MB')));
$form->addRule('disk_quota', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
$specialCourseField = new ExtraField('course');
$specialCourseFieldInfo = $specialCourseField->get_handler_field_info_by_field_variable('special_course');
if (!empty($specialCourseFieldInfo)) {
    $specialCourseValue = new ExtraFieldValue('course');
    $specialCourseValueInfo = $specialCourseValue->get_values_by_handler_and_field_variable($course_code, 'special_course');
    $specialCourseAttributes = array();
    if (!empty($specialCourseValueInfo) && $specialCourseValueInfo['value'] == 1) {
        $specialCourseAttributes['checked'] = '';
    }
    $form->addElement('checkbox', 'extra_special_course', array(null, get_lang('AllUsersAreAutomaticallyRegistered')), get_lang('SpecialCourse'), $specialCourseAttributes);
}
//Extra fields
$extra_field = new ExtraField('course');
$extra = $extra_field->addElements($form, $courseId, ['special_course']);
$htmlHeadXtra[] = '
<script>
$(function() {
 static function get_horario_value($session_id)
 {
     $extra_field_value = new ExtraFieldValue('session');
     //Getting horario info
     $extra_field = new ExtraField('session');
     $extra_field_info = $extra_field->get_handler_field_info_by_field_variable('horario');
     $horario_info = $extra_field_value->get_values_by_handler_and_field_id($session_id, $extra_field_info['id']);
     $extra_field_option = new ExtraFieldOption('session');
     $horario_info = $extra_field_option->get_field_option_by_field_and_option($extra_field_info['id'], $horario_info['field_value']);
     $time = "08:00";
     if (isset($horario_info) && isset($horario_info[0])) {
         $horario = $horario_info[0]['option_display_text'];
         $horario_array = explode(' ', $horario);
         //Schedule format is "(01) 07:00 09:00" in this case. Adapt to your case
         if (isset($horario_array[1])) {
             $time = $horario_array[1];
         }
     }
     return $time;
 }
 /**
  * Saves a series of records given as parameter into the coresponding table
  * @param array  Structured parameter for the insertion into the *_field_values table
  * @return mixed false on empty params, void otherwise
  * @assert (array()) === false
  */
 public function save_field_values($params)
 {
     $extra_field = new ExtraField($this->type);
     if (empty($params[$this->handler_id])) {
         return false;
     }
     // Parse params.
     foreach ($params as $key => $value) {
         if (substr($key, 0, 6) == 'extra_') {
             // An extra field.
             $field_variable = substr($key, 6);
             $extra_field_info = $extra_field->get_handler_field_info_by_field_variable($field_variable);
             if ($extra_field_info) {
                 $commentVariable = 'extra_' . $field_variable . '_comment';
                 $comment = isset($params[$commentVariable]) ? $params[$commentVariable] : null;
                 $new_params = array($this->handler_id => $params[$this->handler_id], 'field_id' => $extra_field_info['id'], 'field_value' => $value, 'comment' => $comment);
                 self::save($new_params);
             }
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Get the drupal_user_id extra field information
  * @return array The info
  */
 private function getExtraFieldInfo()
 {
     $extraField = new ExtraField('user');
     $extraFieldHandler = $extraField->get_handler_field_info_by_field_variable(self::EXTRAFIELD_VARIABLE_NAME);
     return $extraFieldHandler;
 }
Ejemplo n.º 11
0
        Session::write('is_courseMember', $is_courseMember);
        Session::write('is_courseTutor', $is_courseTutor);
        Session::write('is_courseCoach', $is_courseCoach);
        Session::write('is_allowed_in_course', $is_allowed_in_course);
        Session::write('is_sessionAdmin', $is_sessionAdmin);
    }
};
/**
 * Deletes the exam_password user extra field *only* to students
 * @todo move to the login hook system
 * @param Request $request
 */
$afterLogin = function (Request $request) use($app) {
    if (isset($app['current_user']) && isset($app['current_user']['user_id']) && $app['current_user']['status'] == STUDENT) {
        $extraField = new ExtraField('user');
        $extraFieldData = $extraField->get_handler_field_info_by_field_variable('exam_password');
        if ($extraFieldData && !empty($extraFieldData)) {
            $extraField = new ExtraFieldValue('user');
            $extraFieldValue = $extraField->get_values_by_handler_and_field_variable($app['current_user']['user_id'], 'exam_password');
            if (!empty($extraFieldValue)) {
                $extraField->delete_values_by_handler_and_field_id($app['current_user']['user_id'], $extraFieldValue['id']);
            }
        }
    }
};
/** Removes the cid reset and other session values */
$removeCidReset = function (Request $request) use($app) {
    // Deleting course info.
    Session::erase('_cid');
    Session::erase('_real_cid');
    Session::erase('_course');
 /**
  * Create the user extra field
  */
 public static function init()
 {
     $extraField = new ExtraField('user');
     $fieldInfo = $extraField->get_handler_field_info_by_field_variable(self::EXTRA_FIELD_GCM_REGISTRATION);
     if (empty($fieldInfo)) {
         $extraField->save(['variable' => self::EXTRA_FIELD_GCM_REGISTRATION, 'field_type' => ExtraField::FIELD_TYPE_TEXT, 'display_text' => self::EXTRA_FIELD_GCM_REGISTRATION]);
     }
 }
Ejemplo n.º 13
0
 /**
  * @param string $file
  * @param bool   $moveFile
  *
  * @return int
  */
 private function importCalendarStatic($file, $moveFile = true)
 {
     $data = Import::csvToArray($file);
     if ($this->getDumpValues()) {
         // Remove all calendar items
         $truncateTables = array(Database::get_course_table(TABLE_AGENDA), Database::get_course_table(TABLE_AGENDA_ATTACHMENT), Database::get_course_table(TABLE_AGENDA_REPEAT), Database::get_course_table(TABLE_AGENDA_REPEAT_NOT), Database::get_main_table(TABLE_PERSONAL_AGENDA), Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT_NOT), Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT));
         foreach ($truncateTables as $table) {
             $sql = "TRUNCATE {$table}";
             Database::query($sql);
         }
         $table = Database::get_course_table(TABLE_ITEM_PROPERTY);
         $sql = "DELETE FROM {$table} WHERE tool = 'calendar_event'";
         Database::query($sql);
     }
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         $eventsToCreate = array();
         $errorFound = false;
         foreach ($data as $row) {
             $sessionId = null;
             $externalSessionId = null;
             if (isset($row['external_sessionID'])) {
                 $externalSessionId = $row['external_sessionID'];
                 $sessionId = SessionManager::getSessionIdFromOriginalId($externalSessionId, $this->extraFieldIdNameList['session']);
             }
             $courseCode = null;
             if (isset($row['coursecode'])) {
                 $courseCode = $row['coursecode'];
             }
             $courseInfo = api_get_course_info($courseCode);
             if (empty($courseInfo)) {
                 $this->logger->addInfo("Course '{$courseCode}' does not exists");
             }
             if (empty($sessionId)) {
                 $this->logger->addInfo("external_sessionID: " . $externalSessionId . " does not exists.");
             }
             $teacherId = null;
             if (!empty($sessionId) && !empty($courseInfo)) {
                 $courseIncluded = SessionManager::relation_session_course_exist($sessionId, $courseInfo['real_id']);
                 if ($courseIncluded == false) {
                     $this->logger->addInfo("Course '{$courseCode}' is not included in session: {$sessionId}");
                     $errorFound = true;
                 } else {
                     $teachers = CourseManager::get_coach_list_from_course_code($courseInfo['code'], $sessionId);
                     // Getting first teacher.
                     if (!empty($teachers)) {
                         $teacher = current($teachers);
                         $teacherId = $teacher['user_id'];
                     } else {
                         $sessionInfo = api_get_session_info($sessionId);
                         $teacherId = $sessionInfo['id_coach'];
                     }
                 }
             } else {
                 $errorFound = true;
             }
             if (empty($teacherId)) {
                 $errorFound = true;
                 $this->logger->addInfo("No teacher found in course code : '{$courseCode}' and session: '{$sessionId}'");
             }
             $date = $row['date'];
             $startTime = $row['time_start'];
             $endTime = $row['time_end'];
             $title = $row['title'];
             $startDateYear = substr($date, 0, 4);
             $startDateMonth = substr($date, 4, 2);
             $startDateDay = substr($date, 6, 8);
             $startDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $startTime . ":00";
             $endDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $endTime . ":00";
             if (!api_is_valid_date($startDate) or !api_is_valid_date($endDate)) {
                 $this->logger->addInfo("Verify your dates:  '{$startDate}' : '{$endDate}' ");
                 $errorFound = true;
             }
             if ($errorFound == false) {
                 $eventsToCreate[] = array('start' => $startDate, 'end' => $endDate, 'title' => $title, 'sender_id' => $teacherId, 'course_id' => $courseInfo['real_id'], 'session_id' => $sessionId, $this->extraFieldIdNameList['calendar_event'] => $row['external_calendar_itemID']);
             }
         }
         if (empty($eventsToCreate)) {
             $this->logger->addInfo("No events to add");
             return 0;
         }
         $this->logger->addInfo("Ready to insert events");
         $content = null;
         $agenda = new Agenda();
         $extraFieldValue = new ExtraFieldValue('calendar_event');
         $extraFieldName = $this->extraFieldIdNameList['calendar_event'];
         $externalEventId = null;
         $extraField = new ExtraField('calendar_event');
         $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
         if (empty($extraFieldInfo)) {
             $this->logger->addInfo("No calendar event extra field created: {$extraFieldName}");
             return 0;
         }
         foreach ($eventsToCreate as $event) {
             if (!isset($event[$extraFieldName])) {
                 $this->logger->addInfo("No external_calendar_itemID found. Skipping ...");
                 continue;
             } else {
                 $externalEventId = $event[$extraFieldName];
                 $item = $extraFieldValue->get_item_id_from_field_variable_and_field_value($extraFieldName, $externalEventId);
                 if (!empty($item) || empty($externalEventId)) {
                     $this->logger->addInfo("Event #{$externalEventId} was already added . Skipping ...");
                     continue;
                 }
             }
             $courseInfo = api_get_course_info_by_id($event['course_id']);
             $agenda->set_course($courseInfo);
             $agenda->setType('course');
             $agenda->setSessionId($event['session_id']);
             $agenda->setSenderId($event['sender_id']);
             $agenda->setIsAllowedToEdit(true);
             $eventComment = $event['comment'];
             if (empty($courseInfo)) {
                 $this->logger->addInfo("No course found for added: #" . $event['course_id'] . " Skipping ...");
                 continue;
             }
             if (empty($event['sender_id'])) {
                 $this->logger->addInfo("No sender found: #" . $event['sender_id'] . " Skipping ...");
                 continue;
             }
             $eventId = $agenda->addEvent($event['start'], $event['end'], false, $event['title'], $content, array('everyone'), false, null, array(), null, $eventComment);
             if (!empty($eventId)) {
                 $extraFieldValue->save(array('value' => $externalEventId, 'field_id' => $extraFieldInfo['id'], 'item_id' => $eventId));
                 $this->logger->addInfo("Event added: #{$eventId}");
             } else {
                 $this->logger->addInfo("Error while creating event.");
             }
         }
     }
     if ($moveFile) {
         $this->moveFile($file);
     }
 }
Ejemplo n.º 14
0
<?php

//Removing extra fields
$extra_fields = array('exam_room', 'exam_schedule', 'exam_password');
foreach ($extra_fields as $extra) {
    $extra_field = new ExtraField('user');
    $field_info = $extra_field->get_handler_field_info_by_field_variable($extra);
    if (isset($field_info['id'])) {
        $extra_field->delete($field_info['id']);
    }
}