$load_editor = true;
$form = new HTML_QuickForm("content_report_form", "post", "content_report.php", "", null, true);
$form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
//$form -> addElement('text', 'topic', _TOPIC, 'class = "inputText"');
//$form -> addRule('topic', _THEFIELD.' "'._TOPIC.'" '._ISMANDATORY, 'required', null, 'client');
$form->addElement('hidden', 'page', htmlspecialchars_decode(http_build_query($_GET)));
$form->addElement('textarea', 'notes', _NOTES, 'class = "inputTextArea" style="width:45em;height:15em;"');
//$form -> addRule('notes', _THEFIELD.' "'._NOTES.'" '._ISMANDATORY, 'required', null, 'client');
$form->addElement('submit', 'submit_report', _REPORT, 'class = "flatButton"');
if ($form->isSubmitted()) {
    if ($form->validate()) {
        $values = $form->exportValues();
        $recipients = array();
        $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
        $lessonProfs = $lesson->getUsers("professor");
        foreach ($lessonProfs as $key => $value) {
            $recipients[] = $key;
        }
        if (strpos($values['page'], "glossary") !== false) {
            $title = _ERRORREPORTFOR . ' ' . $lesson->lesson['name'] . ' [' . _GLOSSARY . ']';
        } elseif (strpos($values['page'], "edit_question") !== false) {
            $title = _ERRORREPORTFOR . ' ' . $lesson->lesson['name'] . ' [' . _QUESTION . ']';
        } else {
            $contentId = mb_substr($values['page'], 10);
            preg_match("/.*view_unit=(\\d+).*/", $values['page'], $matches);
            $resultType = eF_getTableData("content", "ctg_type", "id=" . $matches[1]);
            if ($resultType[0]['ctg_type'] == "tests") {
                $title = _ERRORREPORTFOR . ' ' . $lesson->lesson['name'] . ' [' . _TESTS . ']';
            } else {
                $title = _ERRORREPORTFOR . ' ' . $lesson->lesson['name'] . ' [' . _CONTENT . ']';
Example #2
0
 if ($visibility) {
     $positions = serialize(array('first' => array_unique($firstlist), 'second' => array_unique($secondlist), 'visibility' => $visibility));
 } else {
     $positions = serialize(array('first' => array_unique($firstlist), 'second' => array_unique($secondlist)));
 }
 //Dashboard positions
 if ($_POST['dashboard']) {
     eF_updateTableData("users", array('dashboard_positions' => $positions), "login='******'login'] . "'");
 } else {
     if ($currentUser->user['user_type'] == 'administrator' && !isset($_POST['lessons_ID'])) {
         EfrontConfiguration::setValue($currentUser->user['login'] . "_positions", $positions);
     } else {
         if (isset($_POST['set_default']) && ($currentUser->user['user_type'] == 'administrator' || $roles[$currentLesson->getRole($currentUser->user['login'])] == 'professor')) {
             $currentLesson->setOptions(array("default_positions" => $positions));
             $positions = serialize(array('first' => array_unique($firstlist), 'second' => array_unique($secondlist), 'visibility' => $visibility, 'update' => true));
             $lessonStudents = $currentLesson->getUsers('student');
             if (sizeof($lessonStudents) > 0) {
                 $users = implode("','", array_keys($lessonStudents));
                 eF_updateTableData("users_to_lessons", array('positions' => $positions), "users_LOGIN in ('" . $users . "') and lessons_ID=" . $currentLesson->lesson['id']);
             }
         } else {
             if (!$visibility) {
                 $result = eF_getTableData("users_to_lessons", "positions", "lessons_ID=" . $currentLesson->lesson['id'] . " AND users_LOGIN='******'login'] . "'");
                 $result = unserialize($result[0]['positions']);
                 $visibility = $result['visibility'];
                 if (isset($result['visibility'])) {
                     $positions = serialize(array('first' => array_unique($firstlist), 'second' => array_unique($secondlist), 'visibility' => $visibility));
                 }
             }
             eF_updateTableData("users_to_lessons", array('positions' => $positions), "lessons_ID=" . $currentLesson->lesson['id'] . " AND users_LOGIN='******'login'] . "'");
         }
Example #3
0
 /**
  * Get user login time in a lesson
  *
  * This function calculates the total time each student spent in the lesson
  * If $users is not specified, then information on all users is calculated.
  * <br/>Example:
  * <code>
  * EfrontStats :: getUsersTime(3, 'jdoe');                          //Get statistics for user jdoe in lesson 3
  * EfrontStats :: getUsersTime(3, array('jdoe', 'george'));         //Get statistics for users george and jdoe in lesson 3
  * EfrontStats :: getUsersTime(3);                                  //Get statistics for all users in lesson 3
  * </code>
  * The results are of the form:
  * <code>
  *   Array
  *   (
  *       [jdoe] => Array
  *           (
  *               [minutes] => 0
  *               [seconds] => 42
  *               [hours] => 0
  *               [total_seconds] => 42
  *               [accesses] => 5
  *           )
  *   )
  * </code>
  * Accesses are the times the user accessed content on the lesson. total_seconds is the sum of time spent in the lesson in seconds
  *
  * @param int $lesson Either the lesson id or the equivalent EfrontLesson object
  * @param mixed $users One or more optional user logins
  * @return array The total time per user
  * @since 3.5.0
  * @access public
  * @static
  */
 public static function getUsersTime($lesson, $users = false, $fromTimestamp = false, $toTimestamp = false)
 {
     if (!$lesson instanceof EfrontLesson) {
         $lesson = new EfrontLesson($lesson);
     }
     $lessonId = $lesson->lesson['id'];
     if (!$users) {
         $users = array_keys($lesson->getUsers());
     } else {
         if (!is_array($users)) {
             $users = array($users);
         }
     }
     !$fromTimestamp ? $fromTimestamp = mktime(0, 0, 0, 1, 1, 1970) : null;
     !$toTimestamp ? $toTimestamp = time() : null;
     $result = eF_getTableData("logs", "id, timestamp, lessons_ID, users_LOGIN", "users_LOGIN in (\"" . implode('","', $users) . "\") and timestamp between {$fromTimestamp} and {$toTimestamp} order by timestamp");
     foreach ($result as $value) {
         $logResults[$value['users_LOGIN']][] = $value;
     }
     $result = eF_getTableData("logs", "users_LOGIN, count(id) as accesses", "users_LOGIN in (\"" . implode('","', $users) . "\") and lessons_ID = {$lessonId} and timestamp between {$fromTimestamp} and {$toTimestamp} group by users_LOGIN order by users_LOGIN");
     foreach ($result as $value) {
         $accessResults[$value['users_LOGIN']] = $value['accesses'];
     }
     $userTimes = array();
     foreach ($users as $login) {
         $totalTime = array('minutes' => 0, 'seconds' => 0, 'hours' => 0, 'total_seconds' => 0);
         $lessonStart = 0;
         $inLesson = 0;
         if (isset($logResults[$login])) {
             foreach ($logResults[$login] as $value) {
                 if ($inLesson) {
                     if ($value['timestamp'] - $lessonStart >= 0) {
                         $interval = eF_convertIntervalToTime($value['timestamp'] - $lessonStart);
                     } else {
                         $interval = eF_convertIntervalToTime(0);
                         //This is to avoid negative times
                     }
                     if ($interval['hours'] == 0 && $interval['minutes'] <= 30) {
                         //not with $GLOBALS['configuration']['autologout_time'] because it may be changed
                         $totalTime['minutes'] += $interval['minutes'];
                         $totalTime['seconds'] += $interval['seconds'];
                     }
                     if ($value['lessons_ID'] != $lessonId) {
                         $inLesson = 0;
                     } else {
                         $lessonStart = $value['timestamp'];
                     }
                 } else {
                     if ($value['lessons_ID'] == $lessonId) {
                         $inLesson = 1;
                         $lessonStart = $value['timestamp'];
                     }
                 }
             }
         }
         $sec = $totalTime['seconds'];
         if ($sec >= 60) {
             $totalTime['seconds'] = $sec % 60;
             $totalTime['minutes'] += floor($sec / 60);
         }
         if ($totalTime['minutes'] >= 60) {
             $totalTime['hours'] = floor($totalTime['minutes'] / 60);
             $totalTime['minutes'] = $totalTime['minutes'] % 60;
         }
         $totalTime['total_seconds'] = $totalTime['hours'] * 3600 + $totalTime['minutes'] * 60 + $totalTime['seconds'];
         $userTimes[$login] = $totalTime;
         isset($accessResults[$login]) ? $userTimes[$login]['accesses'] = $accessResults[$login] : ($userTimes[$login]['accesses'] = 0);
     }
     return $userTimes;
 }
 /**
  * Get project files
  *
  * This function returns a list of file ids that have been posted
  * for this project. this list includes the user name and surname,
  * the id, full path and name of the file and finally the time it
  * was uploaded.
  * <br/>Example:
  * <code>
  * $project -> getFiles();
  * </code>
  *
  * @return array The list of files posted for this project
  * @since 3.5.0
  * @access public
  */
 public function getFiles()
 {
     $files = eF_getTableData("files f, users u, users_to_projects up", "f.*, u.name, u.surname, u.login, up.upload_timestamp", "up.filename = f.id and up.users_LOGIN = u.login and up.projects_ID=" . $this->project['id']);
     $currentLesson = new EfrontLesson($GLOBALS['currentLesson']->lesson['id']);
     $lessonUsers = $currentLesson->getUsers('student');
     foreach ($files as $key => $file) {
         if (!in_array($file['login'], array_keys($lessonUsers))) {
             unset($files[$key]);
         }
     }
     return $files;
 }
Example #5
0
         echo "</xml>";
     }
     break;
 case 'lesson_info':
     if (isset($_GET['token']) && checkToken($_GET['token'])) {
         if (isset($_GET['lesson'])) {
             if (eF_checkParameter($_GET['lesson'], 'id') == false) {
                 echo "<xml>";
                 echo "<status>error</status>";
                 echo "<message>Invalid lesson id</message>";
                 echo "</xml>";
                 exit;
             }
             try {
                 $lesson = new EfrontLesson($_GET['lesson']);
                 $users = $lesson->getUsers('professor');
                 $content = $lesson->getUnits();
                 $info = $lesson->getStatisticInformation();
                 $lesson_info = unserialize($lesson->lesson['info']);
                 $metadata = unserialize($lesson->lesson['metadata']);
                 echo "<xml>";
                 echo "<general_info>";
                 echo "<name>" . $lesson->lesson['name'] . "</name>";
                 echo "<direction>" . $lesson->lesson['directions_ID'] . "</direction>";
                 echo "<price>";
                 echo "<value>" . $info['price'] . "</value>";
                 echo "<currency>" . $GLOBALS['configuration']['currency'] . "</currency>";
                 echo "</price>";
                 echo "<language>" . $info['language'] . "</language>";
                 echo "<info>";
                 foreach ($lesson_info as $key => $value) {
 public function getRecipients()
 {
     $recipients_list = array();
     if (isset($this->notification['send_conditions'])) {
         //echo $this -> notification['send_conditions'];
         if ($this->notification['send_conditions'] == "N;") {
             $recipients = eF_getTableData("users", "*", "active=1 and archive=0");
             //sending_queue_msgs[$key]['recipients'] = _ALLUSERS;
             foreach ($recipients as $recipient) {
                 $recipients_list[$recipient['login']] = $recipient;
             }
         } else {
             // the send_conditions field contains the information which identify the recipients
             // it is defined in ....
             //digests.php during the definition of the event notification
             $this->notification['send_conditions'] = unserialize($this->notification['send_conditions']);
             if ($this->notification['send_conditions'] == "supervisors") {
                 if (G_VERSIONTYPE == 'enterprise') {
                     #cpp#ifdef ENTERPRISE
                     $recipients = eF_getTableData("module_hcd_employee_works_at_branch as meb, users as u", "u.*", "meb.users_login=u.login and u.active=1 and u.archive=0 and meb.supervisor=1");
                     foreach ($recipients as $recipient) {
                         $recipients_list[$recipient['login']] = $recipient;
                     }
                 }
                 #cpp#endif
             } elseif (is_array($this->notification['send_conditions'])) {
                 $this->recipients = $this->notification['send_conditions'];
                 // The recipients array definitely exists, due to constructor checks
                 if (isset($this->recipients["lessons_ID"]) && $this->recipients["lessons_ID"]) {
                     $lesson = new EfrontLesson($this->recipients["lessons_ID"]);
                     if (isset($this->recipients["user_type"])) {
                         // return lesson users of specific type
                         $recipients = array();
                         foreach ($lesson->getUsers($this->recipients["user_type"]) as $value) {
                             if ($value['active']) {
                                 $recipients[] = $value;
                             }
                         }
                     } else {
                         if (isset($this->recipients["completed"])) {
                             // return lesson students according to whether they have completed the lesson or not
                             $recipients = array();
                             foreach ($lesson->getUsersCompleted($this->recipients["completed"]) as $value) {
                                 if ($value['active']) {
                                     $recipients[] = $value;
                                 }
                             }
                         } else {
                             // return all users
                             $recipients = array();
                             foreach ($lesson->getUsers() as $value) {
                                 if ($value['active']) {
                                     $recipients[] = $value;
                                 }
                             }
                         }
                     }
                 } else {
                     if (isset($this->recipients["courses_ID"])) {
                         $entity_parts = explode("_", $this->notification['id_type_entity']);
                         $notification_type = $entity_parts[1];
                         if ($this->recipients['user_type'] == "professor") {
                             $completed_condition = " AND uc.user_type = 'professor'";
                         } else {
                             if ($this->recipients['completed'] == "1") {
                                 $completed_condition = " AND completed = '1'";
                             } else {
                                 if ($this->recipients['completed'] == "2" || $notification_type == EfrontEvent::COURSE_PROGRAMMED_EXPIRY) {
                                     $completed_condition = " AND completed = '0' and uc.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "')";
                                 } else {
                                     $completed_condition = "";
                                 }
                             }
                         }
                         if ($this->recipients['supervisor']) {
                             if ($this->recipients['users_login']) {
                                 $editedUser = EfrontUserFactory::factory($this->recipients['users_login']);
                                 //new EfrontUser();
                                 $editedEmployee = $editedUser->aspects['hcd'];
                                 $supervisors = $editedEmployee->getSupervisors();
                                 $recipients = array();
                                 foreach ($supervisors as $supervisor) {
                                     $recipients[$supervisor] = array("login" => $supervisor);
                                 }
                             } else {
                                 $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)";
                                 //get course users' supervisors
                                 $result = eF_executeNew($query);
                                 $recipients = $result->getAll();
                             }
                         } elseif ($this->recipients['immediate_supervisor']) {
                             if ($this->recipients['users_login']) {
                                 $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and assigned=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')");
                                 $recipients = array();
                                 foreach ($result['users_LOGIN'] as $supervisor) {
                                     $recipients[$supervisor] = array("login" => $supervisor);
                                 }
                                 $filtered_recipients = array();
                                 if (!empty($recipients)) {
                                     $active_recipients = eF_getTableDataFlat("users", "login", "active=1 and archive=0 and login IN ('" . implode("','", array_keys($recipients)) . "')");
                                     foreach ($active_recipients["login"] as $login) {
                                         $filtered_recipients[$login] = array("login" => $login);
                                     }
                                     $recipients = $filtered_recipients;
                                 }
                             } else {
                                 $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where ewb.assigned=1 and supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and ewb.assigned=1 and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)";
                                 //get course users' supervisors
                                 $result = eF_executeNew($query);
                                 $recipients = $result->getAll();
                             }
                         } else {
                             $recipients = eF_getTableData("users_to_courses uc, users u", "u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID, uc.user_type as role", "u.active=1 and u.archive=0 and uc.archive=0 and uc.users_LOGIN = u.login and uc.courses_ID=" . $this->recipients["courses_ID"] . $completed_condition);
                         }
                     } else {
                         if (isset($this->recipients['user_type'])) {
                             $recipients = eF_getTableData("users", "*", "active=1 and archive=0 and user_type = '" . $this->recipients['user_type'] . "'");
                         } else {
                             if (isset($this->recipients['entity_ID']) && isset($this->recipients['entity_category'])) {
                                 if ($this->recipients['entity_category'] == "survey") {
                                     $recipients = eF_getTableData("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and surveys_ID = '" . $this->recipients["entity_ID"] . "'");
                                     $notified = eF_getTableDataFlat("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and users_to_surveys.last_post > 1 and surveys_ID = '" . $this->recipients["entity_ID"] . "'");
                                     //$resDone		= eF_getTableDataFlat("users_to_done_surveys", "users_LOGIN", "surveys_ID=".$this -> recipients["entity_ID"]);
                                     $usersToSent = array();
                                     if (!empty($notified['login'])) {
                                         foreach ($recipients as $key => $value) {
                                             if (!in_array($value['login'], $notified['login'])) {
                                                 $usersToSent[] = $value;
                                                 //eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login']."' and surveys_ID='".$this -> recipients["entity_ID"]."'");
                                             }
                                         }
                                         $recipients = $usersToSent;
                                     }
                                     foreach ($recipients as $key => $value) {
                                         // in order to include case empty($notified['login']
                                         eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login'] . "' and surveys_ID='" . $this->recipients["entity_ID"] . "'");
                                     }
                                 } else {
                                     if ($this->recipients['entity_category'] == "projects") {
                                         $recipients = eF_getTableData("users_to_projects JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and projects_ID = '" . $this->recipients["entity_ID"] . "'");
                                     }
                                 }
                             } else {
                                 if (isset($this->recipients["groups_ID"])) {
                                     $recipients = eF_getTableData("users_to_groups JOIN users ON users_login = users.login", "users.*", "users.active=1 and users.archive=0 and groups_ID = '" . $this->recipients["groups_ID"] . "'");
                                 } else {
                                     if (isset($this->recipients['users_login'])) {
                                         if (G_VERSIONTYPE == 'enterprise') {
                                             #cpp#ifdef ENTERPRISE
                                             if (isset($this->recipients['supervisor'])) {
                                                 $editedUser = EfrontUserFactory::factory($this->recipients['users_login']);
                                                 //new EfrontUser();
                                                 $editedEmployee = $editedUser->aspects['hcd'];
                                                 $supervisors = $editedEmployee->getSupervisors();
                                                 $recipients = array();
                                                 foreach ($supervisors as $supervisor) {
                                                     $recipients[$supervisor] = array("login" => $supervisor);
                                                 }
                                             } elseif (isset($this->recipients['immediate_supervisor'])) {
                                                 $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')");
                                                 $recipients = array();
                                                 foreach ($result['users_LOGIN'] as $supervisor) {
                                                     $recipients[$supervisor] = array("login" => $supervisor);
                                                 }
                                             } else {
                                                 $recipients = $this->recipients['users_login'];
                                             }
                                         } else {
                                             #cpp#else
                                             $recipients = $this->recipients['users_login'];
                                         }
                                         #cpp#endif
                                     }
                                 }
                             }
                         }
                     }
                 }
                 foreach ($recipients as $recipient) {
                     $recipients_list[$recipient['login']] = $recipient;
                 }
             } else {
                 if ($this->notification['recipient'] != "") {
                     preg_match("/\\d+_(\\d+)/", $this->notification['id_type_entity'], $matches);
                     if ($matches[1] == EfrontEvent::SYSTEM_ON_EMAIL_ACTIVATION) {
                         //In this case, we want an inactive user to receive the email
                         $user = eF_getTableData("users", "*", "archive=0 and login = '******'recipient'] . "'");
                     } else {
                         $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'");
                     }
                     if (!empty($user)) {
                         $recipients_list[$this->notification['recipient']] = $user[0];
                     }
                 }
             }
         }
     } else {
         if ($this->notification['recipient'] != "") {
             $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'");
             if (!empty($user)) {
                 $recipients_list[$this->notification['recipient']] = $user[0];
             }
         }
     }
     return $recipients_list;
 }
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     global $load_editor;
     $load_editor = true;
     $current_user = $this->getCurrentUser();
     $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType());
     $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'");
     $form->addElement('hidden', 'recipients', $_GET['rec']);
     $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"');
     $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"');
     $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"');
     $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"');
     $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         switch ($values['recipients']) {
             case "lesson_students":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("student");
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 //pr($mail_recipients);return;
                 break;
             case "lesson_professors":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("professor");
                 if (isset($_SESSION['s_courses_ID'])) {
                     $course = new EfrontCourse($_SESSION['s_courses_ID']);
                     $course_users = $course->getCourseUsers();
                     foreach ($lessonUsers as $key => $value) {
                         if (!isset($course_users[$key])) {
                             unset($lessonUsers[$key]);
                         }
                     }
                 }
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
             case "admin":
                 $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0");
                 //not
                 foreach ($result as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
         }
         //$list = implode(",",$mail_recipients);
         $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']);
         if ($_FILES['attachment']['name'][0] != "") {
             $maxFileSize = FileSystemTree::getUploadMaxSize();
             if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
                 //	G_MAXFILESIZE is deprecated
                 $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes";
                 $message_type = 'failure';
             }
             //Upload user avatar file
             $pm->sender_attachment_timestamp = time();
             $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
             mkdir($user_dir, 0755);
             $filesystem = new FileSystemTree($user_dir);
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         }
         if ($pm->send($values['email'], $values)) {
             $message = _MESSAGEWASSENT;
             $message_type = 'success';
         } else {
             $message = $pm->errorMessage;
             $message_type = 'failure';
         }
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     //Create a smarty renderer
     $renderer->setRequiredTemplate('{$html}{if $required}
     	&nbsp;<span class = "formRequired">*</span>
 		{/if}');
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     //Set javascript error messages
     $form->setRequiredNote(_REQUIREDNOTE);
     $form->accept($renderer);
     //Assign this form to the renderer, so that corresponding template code is created
     $smarty->assign('T_MODULE_MAIL_FORM', $renderer->toArray());
     $smarty->assign("T_MESSAGE_MAIL", $message);
     $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type);
     //pr($renderer -> toArray());
     return true;
 }
Example #8
0
         $lastTest = end($doneTests);
         $showTest = unserialize($lastTest['test']);
         //Take the last in the row
     }
 }
 if ($showTest->test['content_ID']) {
     $result = eF_getTableData("content", "ctg_type", "id=" . $showTest->test['content_ID']);
     $testType = $result[0]['ctg_type'];
     $smarty->assign("T_TEST_TYPE", $testType);
 }
 //Check if current user is eligible to see this test
 if ($_SESSION['s_type'] != 'administrator') {
     //$currentUser = EfrontUserFactory :: factory($_SESSION['s_login'], false);
     $result = eF_getTableData("content", "lessons_ID", "id=" . $test->test['content_ID']);
     $testLesson = new EfrontLesson($result[0]['lessons_ID']);
     $lessonUsers = $testLesson->getUsers();
     if (!in_array($_SESSION['s_login'], array_keys($lessonUsers))) {
         throw new Exception(_YOUARENOTAUTHORISEDTOSEETHISTEST);
     } else {
         if ($lessonUsers[$_SESSION['s_login']]['role'] == 'student' && $_SESSION['s_login'] != $showTest->completedTest['login']) {
             throw new Exception(_YOUARENOTAUTHORISEDTOSEETHISTEST);
         }
     }
 }
 if ($_SESSION['s_type'] != 'student') {
     $showTest->options['given_answers'] = 1;
     if ($testType != "feedback") {
         $showTest->options['answers'] = 1;
         $editHanles = true;
     }
 }
Example #9
0
 function getJournalLessonsStudents($professorJournalLessons)
 {
     $students = array();
     foreach ($professorJournalLessons as $lessonID) {
         $lesson = new EfrontLesson($lessonID);
         $lessonStudents = $lesson->getUsers('student');
         foreach ($lessonStudents as $userLogin => $value) {
             if (!in_array($userLogin, array_keys($students))) {
                 $students[$userLogin] = array('login' => $userLogin);
             }
         }
     }
     return $students;
 }
 private function getGradebookLessons($professorLessons, $currentLessonID)
 {
     // lessons where GradeBook is installed
     $lessons = array();
     unset($professorLessons[$currentLessonID]);
     // do not use current lesson
     foreach ($professorLessons as $key => $value) {
         $lesson = new EfrontLesson($key);
         $lessonUsers = $lesson->getUsers('student');
         // get all students that have this lesson
         $result = eF_getTableData("module_gradebook_users", "count(uid) as total_users", "lessons_ID=" . $key);
         if ($result[0]['total_users'] != 0) {
             // module installed for this lesson
             $lessons[$key] = array("id" => $key, "name" => $lesson->lesson['name']);
         }
     }
     return $lessons;
 }
 /**
  * Remove project from users
  *
  * This function is used to remove assignment of one or more users from the
  * current project.
  * <br/>Example:
  * <code>
  * $project = new EfrontProject(32);                    //Initialize project with id 32
  * $project -> removeUsers('jdoe');                     //Remove project from user 'jdoe'
  * $project -> removeUsers(array('john', 'george'));    //Remove project from users 'john' and 'george'
  * </code>
  *
  * @param mixed The users to remove from the project, may be a single login or an array of logins
  * @return array The new projet users list;
  * @since 3.5.0
  * @access public
  */
 public function removeUsers($login)
 {
     if (!is_array($login)) {
         $login = array($login);
     }
     $projectLesson = new EfrontLesson($this->project['lessons_ID']);
     $lessonUsers = $projectLesson->getUsers('student');
     foreach ($login as $value) {
         if (in_array($value, array_keys($lessonUsers)) && in_array($value, array_keys($this->users)) && eF_checkParameter($value, 'login')) {
             eF_deleteTableData("users_to_projects", "users_LOGIN = '******' and projects_ID = " . $this->project['id']);
         }
     }
     return $this->getUsers(true);
 }