Exemplo n.º 1
0
             }
             // Keep that for the avatar searching after the filtering
             $new_event['users_LOGIN'] = $event->event['users_LOGIN'];
             $events[] = $new_event;
         }
     }
 }
 if (isset($_GET['filter'])) {
     $events = eF_filterData($events, $_GET['filter']);
 }
 if (isset($_GET['ajax'])) {
     foreach ($events as $key => $event) {
         $events[$key]['avatar'] = $users_avatars[$event['users_LOGIN']];
         try {
             $file = new EfrontFile($events[$key]['avatar']);
             list($events[$key]['avatar_width'], $events[$key]['avatar_height']) = eF_getNormalizedDims($file['path'], 50, 50);
         } catch (EfrontFileException $e) {
             $events[$key]['avatar'] = G_SYSTEMAVATARSPATH . "unknown_small.png";
             $events[$key]['avatar_width'] = 50;
             $events[$key]['avatar_height'] = 50;
         }
     }
 }
 $count = sizeof($events);
 $smarty->assign("T_TIMELINE_EVENTS_SIZE", $count);
 if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) {
     isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0);
     $events = array_slice($events, $offset, $limit);
 }
 if ($count) {
     $smarty->assign("T_TIMELINE_EVENTS", $events);
Exemplo n.º 2
0
 /**
  * Get all events related with this lesson
  *
  * This function is used to acquire all events related for this lesson,
  * according to a topical timeline
  *
  * <br/>Example:
  * <code>
  * $lesson -> getEvents();   // Get all events of this lessons from the most recent to the oldest
  * </code>
  *
  * @param $topic_ID the id of the topic to which the return events for the timeline should belong
  * @param $returnObjects whether to return event objects or not
  * @param $avatarSize the normalization size for the avatar images
  * @param $limit maximum number of events to return
  * @return boolean true/false
  * @since 3.6.0
  * @access public
  */
 public function getEvents($topic_ID = false, $returnObjects = false, $avatarSize = 0, $limit = false)
 {
     if (!EfrontUser::isOptionVisible('lessons_timeline')) {
         return array();
     }
     if ($topic_ID) {
         // only current lesson users
         $users = $this->getUsers();
         $users_logins = array_keys($users);
         if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) {
             //this applies to supervisors only
             // don't mix with course events - with courses_ID = $this->lesson['id']
             $related_events = eF_getTableData("events, module_hcd_employee_works_at_branch ewb", "events.*", "ewb.branch_ID= " . $_SESSION['s_current_branch'] . " and events.users_LOGIN=ewb.users_login and type = '" . EfrontEvent::NEW_POST_FOR_LESSON_TIMELINE_TOPIC . "' AND entity_ID = '" . $topic_ID . "' AND lessons_ID = '" . $this->lesson['id'] . "' AND events.users_LOGIN IN ('" . implode("','", $users_logins) . "') AND (type < 50 OR type >74)", "timestamp desc", "", $limit ? $limit * 5 : null);
         } else {
             // don't mix with course events - with courses_ID = $this->lesson['id']
             $related_events = eF_getTableData("events, module_hcd_employee_works_at_branch ewb", "events.*", "ewb.branch_ID= " . $_SESSION['s_current_branch'] . " and events.users_LOGIN=ewb.users_login and type = '" . EfrontEvent::NEW_POST_FOR_LESSON_TIMELINE_TOPIC . "' AND entity_ID = '" . $topic_ID . "' AND lessons_ID = '" . $this->lesson['id'] . "' AND events.users_LOGIN IN ('" . implode("','", $users_logins) . "') AND (type < 50 OR type >74)", "timestamp desc", "", $limit ? $limit * 5 : null);
         }
     } else {
         // only current lesson users
         $users = $this->getUsers();
         $users_logins = array_keys($users);
         //    		if ($limit) {
         //    			$related_events = eF_getTableData("events", "*", "lessons_ID = '". $this->lesson['id']."' AND users_LOGIN IN ('".implode("','", $users_logins)."')", "timestamp desc LIMIT " . $limit);
         //
         //    		} else {
         if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) {
             //this applies to supervisors only
             $related_events = eF_getTableData("events, module_hcd_employee_works_at_branch ewb", "events.*", "ewb.branch_ID= " . $_SESSION['s_current_branch'] . " and events.users_LOGIN=ewb.users_login and lessons_ID = '" . $this->lesson['id'] . "' AND events.users_LOGIN IN ('" . implode("','", $users_logins) . "')  AND (type < 50 OR type >74)\t", "timestamp desc", "", $limit ? $limit * 5 : null);
         } else {
             $related_events = eF_getTableData("events", "events.*", "lessons_ID = '" . $this->lesson['id'] . "' AND events.users_LOGIN IN ('" . implode("','", $users_logins) . "')  AND (type < 50 OR type >74)\t", "timestamp desc", "", $limit ? $limit * 5 : null);
         }
         //    		}
     }
     if (!isset($avatarSize) || $avatarSize <= 0) {
         $avatarSize = 25;
     }
     $prev_event = false;
     $count = 0;
     $filtered_related_events = array();
     foreach ($related_events as $key => $event) {
         $user = $users[$event['users_LOGIN']];
         $filtered_related_events[$key] = $event;
         try {
             $file = new EfrontFile($user['avatar']);
             $filtered_related_events[$key]['avatar'] = $user['avatar'];
             list($filtered_related_events[$key]['avatar_width'], $filtered_related_events[$key]['avatar_height']) = eF_getNormalizedDims($file['path'], $avatarSize, $avatarSize);
         } catch (EfrontfileException $e) {
             $filtered_related_events[$key]['avatar'] = G_SYSTEMAVATARSPATH . "unknown_small.png";
             $filtered_related_events[$key]['avatar_width'] = $avatarSize;
             $filtered_related_events[$key]['avatar_height'] = $avatarSize;
         }
         // Logical combination of events
         if ($prev_event) {
             // since we have decreasing chronological order we now that $event['timestamp'] < $prev_event['timestamp']
             if ($event['users_LOGIN'] == $prev_event['event']['users_LOGIN'] && $event['type'] == $prev_event['event']['type'] && $prev_event['event']['timestamp'] - $event['timestamp'] < EfrontEvent::SAME_USER_INTERVAL) {
                 unset($filtered_related_events[$prev_event['key']]);
                 $count--;
             }
         }
         $prev_event = array("key" => $key, "event" => $event);
         if ($limit && ++$count == $limit) {
             break;
         }
     }
     if ($returnObjects) {
         $eventObjects = array();
         foreach ($filtered_related_events as $event) {
             $eventObjects[] = new EfrontEvent($event);
         }
         return $eventObjects;
     } else {
         return $filtered_related_events;
     }
 }
Exemplo n.º 3
0
if (!isset($horizontal_inframe_version) || !$horizontal_inframe_version) {
    /***** TOP MENU WITH AVATAR AND NAME *****/
    try {
        if (isset($_SESSION['facebook_details']['pic'])) {
            $avatar['path'] = $_SESSION['facebook_details']['pic'];
            $smarty->assign("T_ABSOLUTE_AVATAR_PATH", 1);
            $smarty->assign("T_AVATAR", $_SESSION['facebook_details']['pic']);
        } else {
            $avatar = new EfrontFile($currentUser->user['avatar']);
            $smarty->assign("T_AVATAR", $currentUser->user['avatar']);
        }
        // Get current dimensions
        list($width, $height) = getimagesize($avatar['path']);
        if ($width > 200 || $height > 100) {
            // Get normalized dimensions
            list($newwidth, $newheight) = eF_getNormalizedDims($avatar['path'], 200, 100);
            // The template will check if they are defined and normalize the picture only if needed
            $width = $newwidth;
            $height = $newheight;
        }
    } catch (Exception $e) {
        $width = 64;
        $height = 64;
    }
    $smarty->assign("T_NEWWIDTH", $width);
    $smarty->assign("T_NEWHEIGHT", $height);
}
//pr($_SESSION);
if (isset($_SESSION['facebook_user'])) {
    //pr($_SESSION);
    //$facebook = new EfrontFacebook();
Exemplo n.º 4
0
 if (isset($_GET['topic']) && eF_checkParameter($_GET['topic'], 'id')) {
     $topic = eF_getTableData("f_topics", "*", "id=" . $_GET['topic']);
     if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) {
         //this applies to supervisors only
         $user_posts = eF_getTableDataFlat("f_messages, users, module_hcd_employee_works_at_branch", "distinct login, count(f_messages.id) as num", "module_hcd_employee_works_at_branch.users_login=users.login and module_hcd_employee_works_at_branch.branch_ID=" . $currentBranch->branch['branch_ID'] . " and users.login = f_messages.users_LOGIN group by login");
         $posts = eF_getTableData("f_messages, users, module_hcd_employee_works_at_branch", "users.avatar, users.user_type, f_messages.*", "module_hcd_employee_works_at_branch.users_login=users.login and module_hcd_employee_works_at_branch.branch_ID=" . $currentBranch->branch['branch_ID'] . " and users.login = f_messages.users_LOGIN and f_topics_ID=" . $_GET['topic'], "timestamp");
     } else {
         $user_posts = eF_getTableDataFlat("f_messages, users", "distinct login, count(f_messages.id) as num", "users.login = f_messages.users_LOGIN group by login");
         $posts = eF_getTableData("f_messages, users", "users.avatar, users.user_type, f_messages.*", "users.login = f_messages.users_LOGIN and f_topics_ID=" . $_GET['topic'], "timestamp");
     }
     $user_posts = array_combine($user_posts['login'], $user_posts['num']);
     foreach ($posts as $key => $post) {
         $posts[$key]['body'] = eF_replaceQuotes($post['body']);
         try {
             $file = new EfrontFile($post['avatar']);
             list($posts[$key]['avatar_width'], $posts[$key]['avatar_height']) = eF_getNormalizedDims($file['path'], 150, 150);
         } catch (EfrontFileException $e) {
             $posts[$key]['avatar'] = G_SYSTEMAVATARSPATH . "unknown_small.png";
             $posts[$key]['avatar_width'] = 150;
             $posts[$key]['avatar_height'] = 150;
         }
     }
     //    $forum      = eF_getTableData("f_forums", "*", "id=".$topic[0]['f_forums_ID']);
     $smarty->assign("T_USER_POSTS", $user_posts);
     $smarty->assign("T_POSTS", $posts);
     $smarty->assign("T_TOPIC", $topic[0]);
     //    $smarty -> assign("T_FORUM", $forum[0]);
     $current_topic[0]['viewed_by'] ? $viewed_by = unserialize($topic[0]['viewed_by']) : ($viewed_by = array());
     if (!in_array($_SESSION['s_login'], $viewed_by)) {
         $viewed_by[] = $_SESSION['s_login'];
         $fields_update = array("views" => ++$topic[0]['views'], "viewed_by" => serialize($viewed_by));
Exemplo n.º 5
0
function eF_normalizeImage($filename, $extension, $maxNewWidth, $maxNewHeight)
{
    if (!extension_loaded('gd') && !extension_loaded('gd2')) {
        return false;
    }
    // Get current dimensions
    list($width, $height) = getimagesize($filename);
    // Get normalized dimensions
    list($newwidth, $newheight) = eF_getNormalizedDims($filename, $maxNewWidth, $maxNewHeight);
    return eF_createImage($filename, $extension, $width, $height, $newwidth, $newheight);
}