Exemplo n.º 1
0
 public function run()
 {
     $tpl = new template();
     $id = (int) $_GET['id'];
     if ($id > 0) {
         $lead = $this->getLead($id);
         // Comments
         $comments = new comments();
         if (isset($_POST['comment']) === true) {
             $values = array('text' => $_POST['text'], 'date' => date("Y-m-d H:i:s"), 'userId' => $_SESSION['userdata']['id'], 'moduleId' => $id, 'commentParent' => $_POST['father']);
             $comments->addComment($values, 'lead');
         }
         // files
         $file = new files();
         if (isset($_POST['upload'])) {
             if (isset($_FILES['file'])) {
                 $file->upload($_FILES, 'lead', $id);
                 $tpl->setNotification('FILE_UPLOADED', 'success');
             } else {
                 $tpl->setNotification('NO_FILE', 'error');
             }
         }
         $files = new files();
         $tpl->assign('files', $files->getFilesByModule('lead', $id));
         $tpl->assign('comments', $comments->getComments('lead', $id));
         $tpl->assign('contactInfo', $this->getLeadContact($id));
         $tpl->assign('lead', $lead);
     } else {
         $tpl->display('general.error');
     }
     $tpl->display('leads.showLead');
 }
Exemplo n.º 2
0
 public function new_comment()
 {
     if (!isset($_SESSION['uid'])) {
         echo 1;
         return;
     }
     $type = $_POST['type'];
     $post_id = $_POST['post_id'];
     $author_id = $_SESSION['uid'];
     $content = '';
     if ($type == 1) {
         $content = $_POST['content'];
     } else {
         if ($type == 2) {
             if ($_FILES['file']['error'] > 0) {
                 echo 2;
                 return;
             } else {
                 $arr = split('.', $_FILES['file']['name']);
                 $suffix = $arr[1];
                 $des = 'upload/' . time() . $suffix;
                 move_uploaded_file($_FILES['file']['tmp_name'], $des);
                 $content = $des;
             }
         }
     }
     $comment = new comments();
     $suc = $comment->insert($type, $post_id, $author_id, $content);
     echo $suc ? 0 : 1;
     return;
 }
 public function actionIndex()
 {
     if (isset(yii::$app->request->isAjax)) {
         $page_id = yii::$app->request->get('page_id');
         $comments = new comments();
         $commentsItems = $comments->GetComments($page_id);
         $data['items'] = $commentsItems['items'];
         $data['pagination'] = $commentsItems['pagination'];
         return $this->renderAjax('index', $data);
     }
 }
Exemplo n.º 4
0
function content_showcomments($id)
{
    global $set, $db, $apx, $user;
    $res = $db->first("SELECT allowcoms FROM " . PRE . "_content WHERE ( id='" . $id . "' AND active='1' " . section_filter() . " ) LIMIT 1");
    if (!$apx->is_module('comments') || !$set['content']['coms'] || !$res['allowcoms']) {
        return;
    }
    require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
    $coms = new comments('content', $id);
    $coms->assign_comments();
    $apx->tmpl->parse('comments', 'comments');
    require 'lib/_end.php';
}
Exemplo n.º 5
0
 function getPostComments($dbh, $id)
 {
     $stmt = $dbh->prepare("select * from " . comments::$table_name . " WHERE postid = :postid ORDER BY id;");
     $stmt->bindParam(":postid", $id);
     $stmt->execute();
     $result = array();
     while ($row = $stmt->fetch()) {
         $p = new comments();
         $p->copyFromRow($row);
         $result[] = $p;
     }
     return $result;
 }
Exemplo n.º 6
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 7
0
 function index()
 {
     if (isset($this->args[0]) && $this->args[0] != "index") {
         system::setParam("page", "layout");
         $cacheID = $this->args[0] . "|ARTICLE";
         $this->smarty->setCacheID($cacheID);
         if (isset($_POST["contentID"]) && $_POST["contentID"]) {
             comments::add(intval($_POST["contentID"]));
         }
         $this->smarty->assign("isFav", blog::isFavorite($this->args[0]));
         if (!$this->smarty->isCached()) {
             $sqlData = blog::getOnePost($this->args[0], "article")->fetch();
             if ($sqlData) {
                 $this->smarty->assign("comments", comments::get(intval($sqlData["contentID"])));
                 $this->smarty->assign("post", $sqlData);
             }
         }
     } else {
         $offset = 1;
         system::setParam("page", "list");
         if (isset($this->get["offset"])) {
             $offset = intval($this->get["offset"]);
         }
         $cacheID = "ARTICLES|artoffset_{$offset}";
         $this->smarty->setCacheID($cacheID);
         if (!$this->smarty->isCached()) {
             $allCount = $this->db->query("SELECT COUNT(*) as cnt FROM `content` WHERE `type`='article'")->fetch();
             $this->smarty->assign("posts", news::getPosts(core::pagination($allCount["cnt"], $offset), "article")->fetchAll());
         }
     }
 }
Exemplo n.º 8
0
 public function actionDetail()
 {
     $model = $this->GetModel();
     $properties = new Properties();
     $options = new Options();
     $comments = new comments();
     $this->blog = $model::findOne($this->item->parent_id);
     $this->name = $options->GetOptions('name');
     $data['options'] = $options;
     $data['properties'] = $properties;
     $data['comments'] = $comments;
     $data['value'] = $this->item;
     $commentsItems = $comments->GetComments($this->item->id);
     $data['commentsItems'] = $commentsItems['items'];
     $data['commentsPager'] = $commentsItems['pagination'];
     return $this->render('detail', $data);
 }
Exemplo n.º 9
0
 /**
  * Get a news post.
  * 
  * @param string $id The news id.
  * @param bool $idlib True if the Id library should be used (False for MongoIds)
  * @param bool $justOne True if only one entry should be returned.
  * @param bool $fixUTF8 True if UTF8 should be decoded.
  * 
  * @return mixed The news post as an array, or an error string.
  */
 protected function get($id, $idlib = true, $justOne = false, $fixUTF8 = true, $page = 1, $limit = self::PER_PAGE)
 {
     $query = array('ghosted' => false);
     if ($idlib) {
         $keys = Id::dissectKeys($id, 'news');
         $query['date'] = array('$gte' => $keys['date'], '$lte' => $keys['date'] + $keys['ambiguity']);
     } else {
         $query['_id'] = $this->_toMongoId($id);
     }
     $results = $this->db->find($query)->skip(($page - 1) * self::PER_PAGE)->sort(array('date' => -1));
     $total = $results->count();
     $valid = array();
     if ($limit != null) {
         $results->limit($limit);
     }
     if ($idlib) {
         foreach ($results as $result) {
             if (!Id::validateHash($id, array('ambiguity' => $keys['ambiguity'], 'reportedDate' => $keys['date'], 'date' => $result['date'], 'title' => $result['title']), 'news')) {
                 continue;
             }
             array_push($valid, $result);
         }
     } else {
         $valid = iterator_to_array($results);
     }
     if ($justOne) {
         $valid = array(reset($valid));
     }
     if (empty($valid)) {
         return array('Invalid id.', 0);
     }
     $comments = new comments(ConnectionFactory::get('mongo'));
     foreach ($valid as $key => $entry) {
         $this->resolveUser($valid[$key]['user']);
         if ($fixUTF8) {
             $this->resolveUTF8($valid[$key]);
         }
         $valid[$key]['comments'] = $comments->getCount($entry['_id']);
         $valid[$key]['rating'] = $this->getScore($entry['_id']);
     }
     if ($justOne) {
         return reset($valid);
     }
     return array($valid, $total);
 }
Exemplo n.º 10
0
 public function set_commented_object(ORM $underlying_object)
 {
     if (comments::can_comment_on($underlying_object)) {
         $this->underlying_object_name = $underlying_object->object_name;
         $this->underlying_object_id = $underlying_object->id;
     } else {
         throw new Comments_Not_Commentable_Object_Exception($underlying_object);
     }
 }
Exemplo n.º 11
0
 public function new_post()
 {
     if (!isset($_SESSION['uid'])) {
         echo 1;
         return;
     }
     $forum_id = $_POST['forum_id'];
     $author_id = $_SESSION['uid'];
     $title = $_POST['title'];
     $content = $_POST['content'];
     $post = new posts();
     $id = $post->insert($forum_id, $author_id, $title, $content);
     if (!$id) {
         echo 1;
         return;
     }
     $comment = new comments();
     $suc = $comment->insert($id, $author_id, $content);
     echo $suc ? 0 : 1;
     return;
 }
Exemplo n.º 12
0
 /**
  * run - display template and edit data
  *
  * @access public
  */
 public function run()
 {
     $tpl = new template();
     $id = '';
     if (isset($_GET['id']) === true) {
         $id = (int) $_GET['id'];
     }
     $client = $this->getClient($id);
     if (empty($client) === false) {
         $file = new files();
         $project = new projects();
         $msgKey = '';
         if ($_SESSION['userdata']['role'] == 'admin') {
             $tpl->assign('admin', true);
         }
         if (isset($_POST['upload'])) {
             if (isset($_FILES['file'])) {
                 $msgKey = $file->upload($_FILES, 'client', $id);
             }
         }
         $comment = new comments();
         //Add comment
         if (isset($_POST['comment']) === true) {
             $mail = new mailer();
             $values = array('text' => $_POST['text'], 'date' => date("Y-m-d H:i:s"), 'userId' => $_SESSION['userdata']['id'], 'moduleId' => $id, 'commentParent' => $_POST['father']);
             $comment->addComment($values, 'client');
         }
         $tpl->assign('userClients', $this->getClientsUsers($id));
         $tpl->assign('comments', $comment->getComments('client', $id));
         $tpl->assign('imgExtensions', array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv'));
         $tpl->assign('info', $msgKey);
         $tpl->assign('client', $client);
         $tpl->assign('clientProjects', $project->getClientProjects($id));
         $tpl->assign('files', $file->getFilesByModule('client'));
         //var_dump($file->getFilesByModule('client')); die();
         $tpl->display('clients.showClient');
     } else {
         $tpl->display('general.error');
     }
 }
Exemplo n.º 13
0
/**
 * Выводит форму редактировая комментария в админке комментариев.
 *
 * @param int $type Тип группы комментариев
 * @param int $id   id комментария
 *
 * @return xajaxResponse
 */
function EditComment($type, $id)
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/comments.php';
    session_start();
    $objResponse = new xajaxResponse();
    if (!hasPermissions('comments')) {
        return $objResponse;
    }
    $comments = new comments();
    $item = $comments->GetItem(intval($type), intval($id));
    $show_title = false;
    $show_files = $type == comments::T_ARTICLES;
    $show_video = $type == comments::T_ARTICLES;
    if (!empty($item)) {
        define('IS_SITE_ADMIN', 1);
        require_once $_SERVER['DOCUMENT_ROOT'] . '/siteadmin/comments/blocks.php';
        $objResponse->assign("edit-{$type}-{$id}", 'innerHTML', CommentEditor($item, $show_title, $show_files, $show_video));
        if ($show_video) {
            $objResponse->script("\$\$('.cl-form-files li input[type=image]').addEvent('click', FilesList)");
        }
    }
    return $objResponse;
}
Exemplo n.º 14
0
 public function change_rateAction()
 {
     if (!isset($_SESSION['comments_rate'][system::url(2)])) {
         if ($comment = comments::get(system::url(2))) {
             if (system::url(3) == 'up') {
                 $comment->rateUp();
             } else {
                 $comment->rateDown();
             }
             $_SESSION['comments_rate'][$comment->id()] = 1;
             $comment->save();
         }
     }
     system::stop();
 }
Exemplo n.º 15
0
 public static function make_a_comment_to(ORM $object, $insertion_user, $title, $content, $moderated_state = 'DEFAULT', Comment_Model $in_reply_to = NULL, $url_identifier = '')
 {
     $comment_to_insert = ORM::factory('comment');
     $comment_to_insert->commented_object = $object;
     $comment_to_insert->insertion_user_id = $insertion_user->id;
     Workshop::factory()->add_as_author_of($insertion_user, $object);
     $comment_to_insert->title = $title;
     $comment_to_insert->content = $content;
     $comment_to_insert->moderated_state = $moderated_state;
     if ($in_reply_to != NULL) {
         $comment_to_insert->in_reply_to_id = $in_reply_to->id;
     }
     if ($url_identifier == '') {
         $url_identifier = comments::make_url_identifier($comment_to_insert);
     }
     $comment_to_insert->url_identifier = url_identifier::get_next_available_url_identifier($comment_to_insert, $url_identifier);
     $comment_to_insert->save();
 }
Exemplo n.º 16
0
 protected function displayResults($entries)
 {
     $entry = $this->admin_general_options($this->url0);
     $entry_array = array();
     if (isset($entries[0]['title'])) {
         foreach ($entries as $e) {
             $e['site-url'] = SITE_URL;
             // Format the date from the timestamp
             $e['date'] = date('F d, Y', $e['created']);
             // Image options
             if (!empty($e['img']) && strlen($e['img']) > 1) {
                 // Display the latest two galleries
                 $e['image'] = $e['img'];
                 $e['preview'] = str_replace(IMG_SAVE_DIR, IMG_SAVE_DIR . 'preview/', $e['img']);
                 $e['thumb'] = str_replace(IMG_SAVE_DIR, IMG_SAVE_DIR . 'thumbs/', $e['img']);
             } else {
                 $e['image'] = '/assets/images/no-image.jpg';
                 $e['preview'] = '/assets/images/no-image.jpg';
                 $e['thumb'] = '/assets/images/no-image-thumb.jpg';
             }
             $e['comment-count'] = comments::getCommentCount($e['id']);
             $e['comment-text'] = $e['comment-count'] == 1 ? "comment" : "comments";
             $e['url'] = !empty($e['data6']) ? $e['data6'] : urlencode($e['title']);
             $e['admin'] = $this->admin_simple_options($this->url0, $e['id']);
             $entry_array[] = $e;
         }
         $template_file = $this->url0 . '.inc';
     } else {
         $entry_array[] = array('admin' => NULL, 'title' => 'No Entries Found That Match Your Search', 'body' => "<p>No entries match that query.</p>");
         $template_file = 'default.inc';
     }
     $extra['header']['title'] = 'Search Results for "' . urldecode($this->url2) . '" (' . $this->getEntryCountBySearch($this->url2, $this->url1) . ' entries found)';
     $extra['footer']['pagination'] = $this->paginateEntries();
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     $entry .= UTILITIES::parseTemplate($entry_array, $template, $extra);
     return $entry;
 }
Exemplo n.º 17
0
Arquivo: blog.php Projeto: ygres/sblog
 function index()
 {
     system::setParam("page", "post");
     if ($this->args[0] != "blog") {
         $cacheID = $this->args[0] . "|POST";
         $this->smarty->setCacheID($cacheID);
         if (isset($_POST["SLUG"]) && isset($_POST["comment"])) {
             blog::addCommentBySLUG($_POST["SLUG"]);
         }
         if (!$this->smarty->isCached()) {
             $sqlData = blog::getOnePost($this->args[0])->fetchAll();
             if ($sqlData) {
                 $sqlData = array_shift($sqlData);
                 $comments = comments::get($sqlData["contentID"]);
                 $this->smarty->assign("comments", $comments);
                 blog::highlightCode($sqlData["body"]);
                 $this->smarty->assign("item", $sqlData);
             }
         }
     } else {
         system::redirect("/");
     }
 }
Exemplo n.º 18
0
<?php

require_once "comments.php";
$comment = new comments();
if (isset($_GET['action']) and $_GET['action'] == "getComments") {
    echo $comment->getComments();
    exit;
}
if (isset($_GET['action']) and $_GET['action'] == "delete") {
    $comment->deleteComment($_GET['id']);
    exit;
}
if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
    echo $comment->addComment($_POST);
    exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Angular Demo</title>
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript">
 function commentsController($scope, $http){
	
	$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
	 
	$http.get("index.php?action=getComments")
	     .success(function(data){ $scope.comments = data;  });
	
Exemplo n.º 19
0
<?php

/**
 *
 */
if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) {
    exit;
}
if (!EfrontUser::isOptionVisible('comments')) {
    eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
}
//Create shorthands for user access rights, to avoid long variable names
!isset($currentUser->coreAccess['comments']) || $currentUser->coreAccess['comments'] == 'change' ? $_change_ = 1 : ($_change_ = 0);
$load_editor = true;
if ($_professor_) {
    $comments = comments::getComments($currentLesson->lesson['id'], false, $currentUnit['id'], false, false);
} else {
    $comments = comments::getComments($currentLesson->lesson['id'], $GLOBALS['currentUser'], $currentUnit['id'], false, false);
}
//An array of legal ids for editing entries
$legalValues = array();
foreach ($comments as $value) {
    //if ($value['users_LOGIN'] == $GLOBALS['currentUser'] -> user['login'] || $_professor_) {
    $legalValues[] = $value['id'];
    //}
}
//Theses values will be used for the new comment
$values = array('content_ID' => $currentUnit['id'], 'users_LOGIN' => $currentUser->user['login']);
$entityForm = new HTML_QuickForm("create_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=comments&view_unit=" . $currentUnit['id'] . (isset($_GET['add']) ? '&add=1' : '&edit=' . $_GET['edit']), "", null, true);
$entityName = 'comments';
include "entity.php";
Exemplo n.º 20
0
<?php

// +----------------------------------------------------------------------
// | Demila [ Beautiful Digital Content Trading System ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://demila.org All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Email author@demila.org
// +----------------------------------------------------------------------
define('USING_LANGUAGE', false);
require_once '../../../config.php';
require_once $config['root_path'] . '/core/functions.php';
include_once $config['system_core'] . "/initEngine.php";
admin_login();
if (isset($_POST['delete']) && isset($_POST['id']) && isset($_SESSION['user']['access']['items'])) {
    require_once ROOT_PATH . "/apps/items/models/items.class.php";
    $cms = new items();
    $cms->delete(intval($_POST['id']));
    die(json_encode(array_merge($_POST, array('status' => 'true'))));
} elseif (isset($_POST['deleteComment']) && isset($_POST['id']) && isset($_SESSION['user']['access']['items'])) {
    require_once ROOT_PATH . "/apps/items/models/comments.class.php";
    $cms = new comments();
    $cms->delete(intval($_POST['id']));
    die(json_encode(array_merge($_POST, array('status' => 'true'))));
}
echo json_encode(array_merge($_POST, array('status' => 'unknown error')));
die;
Exemplo n.º 21
0
 /**
  * Clear duplicate comments
  * 
  * There are times that the system may end up with duplicate comments, like when
  * copying content. This function is used to effectively eliminate duplicates.
  * <br/>Example:
  * <code>
  * comments :: clearDuplicates($currentLesson);
  * </code>
  * 
  * @param mixed $lesson a lesson id or an EfrontLesson object
  * @access public
  * @static
  * @since 3.6.0
  */
 public static function clearDuplicates($lesson)
 {
     if ($lesson instanceof EfrontLesson) {
         $lessonId = $lesson->lesson['id'];
     } elseif (eF_checkParameter($lesson, 'id')) {
         $lessonId = $lesson;
     } else {
         throw new EfrontLessonException(_INVALIDID . ": {$lesson}", EfrontLessonException::INVALID_ID);
     }
     $result = eF_getTableData("comments", "*", "lessons_ID=" . $lessonId, "id");
     foreach ($result as $value) {
         $commentsTerms[$value['id']] = $value;
         $id = $value['id'];
         unset($value['id']);
         $checksums[$id] = md5(serialize($value));
     }
     $uniques = array_unique($checksums);
     $duplicates = array_diff_key($checksums, $uniques);
     foreach ($duplicates as $key => $value) {
         $comments = new comments($commentsTerms[$key]);
         $comments->delete();
     }
 }
Exemplo n.º 22
0
 function runJob($job, $force = false)
 {
     $stopAfterJob = false;
     $startTime = microtime(true);
     $this->log($job->task . ', started ' . date('g:i a \\a\\t D M n, Y', $startTime));
     if (!isset($_GET['test']) && !$force) {
         if ($job->isRunning == 1) {
             $this->db->log('Cron race condition: ' . $job->task . ' last start= ' . $job->lastStart);
             echo 'Warning: Cron Race condition<br />';
             return;
         } else {
             $this->db->update("cronJobs", "isRunning=1,failureNoticeSent=0", "id={$job->id}");
         }
     }
     //echo 'Task: '.$job->task."\n";
     switch ($job->task) {
         default:
             // do nothing
             break;
         case 'updateUserLevels':
             require_once 'teamBackend.class.php';
             $teamObj = new teamBackend($this->db);
             $teamObj->updateUserLevels();
             break;
         case 'updateSiteChallenges':
             require_once 'teamBackend.class.php';
             $teamObj = new teamBackend($this->db);
             $teamObj->updateSiteChallenges();
             break;
         case 'updateCachedPointsAndChallenges':
             require_once 'teamBackend.class.php';
             $teamObj = new teamBackend($this->db);
             $teamObj->updateCachedPointsAndChallenges();
             break;
         case 'calcWeeklyLeaders':
             require_once 'teamBackend.class.php';
             $teamObj = new teamBackend($this->db);
             $teamObj->calcWeeklyLeaders();
             break;
         case 'updateUserLevels':
             require_once 'teamBackend.class.php';
             $teamObj = new teamBackend($this->db);
             $teamObj->updateUserLevels();
         case 'updateTwitter':
             // post top stories to twitter
             if (USE_TWITTER) {
                 require_once 'twitter.class.php';
                 $twitterObj = new twitter_old($this->db);
                 $twitterObj->postFeaturedStories();
                 $twitterObj->postNextTopStory();
             }
             break;
         case 'microAccountsSync':
             // sync twitter service accounts for micro blog room - done daily
             if (defined('ENABLE_MICRO')) {
                 require_once PATH_FACEBOOK . "/classes/micro.class.php";
                 $mObj = new micro();
                 $mObj->cleanRoom();
                 try {
                     $mObj->resetFriends(false);
                 } catch (Exception $e) {
                     $this->log('Failed running ' . $job->task . ', Error: ' . $e);
                     // reset this cron task manually because of twitter class trown exceptions
                     $execTime = microtime(true) - $startTime;
                     $this->db->update("cronJobs", "nextRun=date_sub(NOW(), INTERVAL (0-{$job->freqMinutes}) MINUTE),lastExecTime={$execTime},lastStart='" . date('Y-m-d H:i:s', $startTime) . "',isRunning=0", "id={$job->id}");
                 }
             }
             break;
         case 'microBlog':
             // post top stories to micro blog room
             if (defined('ENABLE_MICRO')) {
                 require_once PATH_FACEBOOK . "/classes/micro.class.php";
                 $mObj = new micro();
                 try {
                     $mObj->updateRoom();
                 } catch (Exception $e) {
                     $this->log('Failed running ' . $job->task . ', Error: ' . $e);
                     // reset this cron task manually because of twitter class trown exceptions
                     $execTime = microtime(true) - $startTime;
                     $this->db->update("cronJobs", "nextRun=date_sub(NOW(), INTERVAL (0-{$job->freqMinutes}) MINUTE),lastExecTime={$execTime},lastStart='" . date('Y-m-d H:i:s', $startTime) . "',isRunning=0", "id={$job->id}");
                 }
             }
             break;
         case 'updateCache':
             // build cached content for cover page layout
             require_once 'cache.class.php';
             $cacheObj = new cache($this->db);
             $cacheObj->update();
             break;
         case 'syncProperties':
             // sync Cloud properties with NewsCloud services
             require_once 'apiCloud.class.php';
             $apiObj = new apiCloud($this->db, $this->apiKey);
             $props = $apiObj->syncProperties($this->cloudid);
             require_once 'systemStatus.class.php';
             $ssObj = new systemStatus($this->db);
             $ssObj->setProperties($props['items'][0]);
             break;
         case 'syncAnnouncements':
             require_once 'apiCloud.class.php';
             $apiObj = new apiCloud($this->db, $this->apiKey);
             $resp = $apiObj->syncAnnouncements($this->cloudid);
             if ($resp[result] !== false) {
                 $itemlist = $resp[items];
                 require_once 'systemStatus.class.php';
                 $ssObj = new systemStatus($this->db);
                 $ssObj->resetAnnouncements();
                 if (count($itemlist) > 0) {
                     foreach ($itemlist as $data) {
                         $ssObj->insertState('announcement', html_entity_decode($data['announce']));
                     }
                 }
             }
             break;
         case 'syncNewswire':
             /* deprecated
             			require_once ('apiCloud.class.php');
             			$apiObj=new apiCloud($this->db,$this->apiKey);
             			$resp=$apiObj->syncNewswire($this->cloudid,$this->timeStrToUnixModB($job->lastItemTime));
             			$itemlist=$resp[items];
             			echo 'count: '.count($itemlist).'<br />';
             			if (count($itemlist)>0) {
             				require_once('newswire.class.php');
             				$nwObj=new newswire($this->db);
             				$lastItemTime=date('Y-m-d H:i:s',(time()-(6*30*24*3600))); // set to six months earlier 
             				foreach ($itemlist as $data) {					
             					$wire=$nwObj->serialize($data[title],$data[caption],$data[blogtitle],$data[webpage],$data[date],$data[blogid]);						
             					$id=$nwObj->add($wire);
             					if ($data[date]>$lastItemTime)						
             						$lastItemTime=$data[date];
             					if ($id===false)
             						echo 'skip '.$data[title].'<br />';
             					else						
             						echo 'adding '.$data[title].' id->'.$id.'<br />';
             				}
             				$this->db->update("cronJobs","lastItemTime='$lastItemTime'","id=$job->id");
             			}
             			*/
             break;
         case 'syncLog':
             require_once 'apiCloud.class.php';
             $apiObj = new apiCloud($this->db, $this->apiKey);
             // request server ask for log
             $resp = $apiObj->requestSyncLog($this->cloudid, URL_HOME, $this->timeStrToUnixModB($job->lastStart));
             // get result of log sync
             $logResult = $resp[items][0][log];
             require_once PATH_CORE . "/classes/log.class.php";
             $logObj = new log($this->db);
             // process results from sync operation
             $result = $logObj->receive($logResult);
             echo $result;
             break;
         case 'syncContent':
             // bring content from NewsCloud for this cloud to the remote site
             require_once 'apiCloud.class.php';
             $apiObj = new apiCloud($this->db, $this->apiKey);
             $resp = $apiObj->syncContent($this->cloudid, $this->timeStrToUnixModB($job->lastItemTime));
             $itemlist = $resp[items];
             if (count($itemlist) > 0) {
                 require_once 'content.class.php';
                 $cObj = new content($this->db);
                 // to do : set this to actual time
                 $lastItemTime = date('Y-m-d H:i:s', time() - 6 * 30 * 24 * 3600);
                 // set to six months earlier
                 foreach ($itemlist as $data) {
                     echo 'Contentid' . $data[contentid] . '<br />';
                     // to do: before we can do this below, we need to be syncing ncuid when new users register
                     // to do: get userid from ncUid
                     // lookup userid in user table where ncuid=submitbyid
                     // if not found make it 0
                     // to do: if external story, then check for local userid and set here
                     $story = $cObj->serialize($data[contentid], $data[title], $data[description], '', $data[webpage], $data[permalink], $data[submitbyid], $data[submit_member], $data[userid], $data[date], $data[avgrank], 0, $data[imageid]);
                     $id = $cObj->add($story);
                     // update comments table with new contentids
                     $cObj->updateCommentsTable($data[contentid], $id);
                     if ($data[date] > $lastItemTime) {
                         $lastItemTime = $data[date];
                     }
                     echo 'story added' . $id . '<br><br/>';
                 }
                 $this->db->update("cronJobs", "lastItemTime='{$lastItemTime}'", "id={$job->id}");
             }
             break;
         case 'syncComments':
             // bring comments from stories in this cloud from NewsCloud over to remote site
             require_once 'content.class.php';
             $cObj = new content($this->db);
             $idList = $cObj->fetchRecentStoryList(14, 99, true);
             $this->db->log('syncComments - stories to check for.', PATH_SYNCLOGFILE);
             $this->db->log($idList, PATH_SYNCLOGFILE);
             if ($idList != '') {
                 require_once 'comments.class.php';
                 $commentsObj = new comments($this->db);
                 require_once 'apiCloud.class.php';
                 $apiObj = new apiCloud($this->db, $this->apiKey);
                 $result = $apiObj->syncComments($this->cloudid, $idList, $this->timeStrToUnixModB($job->lastItemTime));
                 $itemlist = $result[items];
                 $this->db->log($itemlist, PATH_SYNCLOGFILE);
                 // update comment thread for each story
                 if (count($itemlist) > 0) {
                     $lastItemTime = date('Y-m-d H:i:s', time() - 6 * 30 * 24 * 3600);
                     // set to six months earlier
                     foreach ($itemlist as $data) {
                         $temp = 'Bring over contentid' . $data[contentid] . ' Commentid' . $data[commentid] . '<br />';
                         // to do: if external story, then check for local userid and set here
                         $comment = $commentsObj->remoteSerialize($data);
                         if ($data[date] > $lastItemTime) {
                             $lastItemTime = $data[date];
                         }
                         $id = $commentsObj->add($comment);
                         echo $temp . '<br />';
                         var_dump($comment);
                         $this->db->log($temp, PATH_SYNCLOGFILE);
                         $this->db->log($comment, PATH_SYNCLOGFILE);
                     }
                 }
                 $this->db->update("cronJobs", "lastItemTime='{$lastItemTime}'", "id={$job->id}");
             }
             break;
         case 'syncScores':
             require_once 'content.class.php';
             $cObj = new content($this->db);
             $idList = $cObj->fetchRecentStoryList(14, 99, true);
             if ($idList != '') {
                 require_once 'apiCloud.class.php';
                 $apiObj = new apiCloud($this->db, $this->apiKey);
                 $resp = $apiObj->syncScores($this->cloudid, $idList, $this->timeStrToUnixModB($job->lastStart));
                 $itemlist = $resp[items];
                 //var_dump($resp);
                 if (count($itemlist) > 0) {
                     // update the score for each story with new votes
                     foreach ($itemlist as $data) {
                         $this->db->update("Content", "score={$data['score']}", "contentid={$data['contentid']}");
                         $temp = 'Set score of contentid:' . $data[contentid] . 'to ' . $data[score];
                         echo $temp . '<br />';
                         $this->db->log($temp, PATH_SYNCLOGFILE);
                     }
                 }
             }
             break;
         case 'syncResources':
             require_once 'apiCloud.class.php';
             $apiObj = new apiCloud($this->db, $this->apiKey);
             require_once 'resources.class.php';
             $resObj = new resources($this->db);
             $result = $apiObj->syncResources($this->cloudid);
             $resObj->sync(html_entity_decode($result[items][0][resources]));
             break;
         case 'updateSiteMap':
             $currentHour = date('G');
             // 0 - 24
             $currentDayOfWeek = date('w');
             // day of week 0-6
             $currentDayOfMonth = date('j');
             // day of month 1-31
             require_once 'siteMap.class.php';
             $smObj = new siteMap($this->db);
             // do always - build the map for content from the last hour
             $smObj->buildMap('hourly');
             // only do this as midnight
             if ($currentHour == 0) {
                 // map to all the content from the last day
                 $smObj->buildMap('daily');
             }
             // only do this at 3 am on first day of week
             if ($currentDayOfWeek = 0 and $currentHour == 3) {
                 // map to all the content from the last week, etc.
                 $smObj->buildMap('weekly');
             }
             // only do this at 2 am on first day of month
             if ($currentDayOfMonth == 1 and $currentHour == 2) {
                 $smObj->buildMap('monthly');
             }
             // call buildIndexMap after updating any individual child maps above
             // just the time stamps from each individual map file are updated in the indexmap
             // warning: if a individual map hasn't been built - the index map won't include a reference to it
             $smObj->buildIndexMap();
             break;
         case 'fetchFeeds':
             // import stories from feeds
             require_once 'feed.class.php';
             $feedObj = new feed($this->db);
             $feedObj->fetchBookmarks();
             $feedObj->fetchFeeds();
             $feedObj->fetchImages();
             if ($feedObj->newStoryLoaded) {
                 // update features
             }
             break;
         case 'logHourlyStats':
             require_once 'statistics.class.php';
             $statsObj = new statistics($this->db);
             $statsObj->logHourlyStats();
             break;
         case 'facebookMinifeed':
             require_once PATH_FACEBOOK . "/classes/app.class.php";
             $app = new app(NULL, true);
             $facebook =& $app->loadFacebookLibrary();
             require_once PATH_FACEBOOK . '/classes/miniFeeds.class.php';
             $feedObj = new miniFeeds($this->db);
             $feedObj->loadFacebook($facebook);
             $feedObj->updateMiniFeeds();
             break;
         case 'facebookProfileBoxes':
             require_once PATH_FACEBOOK . "/classes/app.class.php";
             $app = new app(NULL, true);
             $facebook =& $app->loadFacebookLibrary();
             require_once PATH_FACEBOOK . '/classes/profileBoxes.class.php';
             $proObj = new profileBoxes($this->db);
             $proObj->loadFacebook($facebook);
             $proObj->updateProfileBoxes();
             break;
         case 'facebookEmailEngine':
             // tbd
             break;
         case 'facebookAllocations':
             // check nightly facebook allocations
             $ssObj = new systemStatus($this->db);
             /* initialize the SMT Facebook appliation class, NO Facebook library */
             require_once PATH_FACEBOOK . "/classes/app.class.php";
             $app = new app(NULL, true);
             $facebook =& $app->loadFacebookLibrary();
             $npd = $facebook->api_client->admin_getAllocation('notifications_per_day');
             $ssObj->setState('notifications_per_day', $npd);
             $ssObj->setState('announcement_notifications_per_week', $facebook->api_client->admin_getAllocation('announcement_notifications_per_week'));
             $ssObj->setState('requests_per_day', $facebook->api_client->admin_getAllocation('requests_per_day'));
             $ssObj->setState('emails_per_day', $facebook->api_client->admin_getAllocation('emails_per_day'));
             break;
         case 'facebookSendNotifications':
             require_once PATH_FACEBOOK . "/classes/app.class.php";
             $app = new app(NULL, true);
             $facebook =& $app->loadFacebookLibrary();
             require_once PATH_FACEBOOK . "/classes/shareStories.class.php";
             $ssObj = new shareStories($app);
             $ssObj->processNotifications();
             break;
         case 'facebookSendPromos':
             /* not needed for now
             				if (date('G')==0) {
             					require_once PATH_FACEBOOK."/classes/promos.class.php";
             					$promoObj=new promos($this->db);				
             					$promoObj->send();
             				}			
             */
             break;
         case 'insertNewResearchData':
             require_once PATH_CORE . "/classes/researchRawSession.class.php";
             require_once PATH_CORE . "/classes/researchRawExtLink.class.php";
             require_once PATH_CORE . "/classes/researchSessionLength.class.php";
             require_once PATH_CORE . "/classes/researchLogDump.class.php";
             require_once PATH_CORE . "/classes/researchUserCollective.class.php";
             $rawExtLinkTable = new RawExtLinkTable($this->db);
             $rawExtLinkTable->insertNewestData();
             $rawSessionTable = new RawSessionTable($this->db);
             $rawSessionTable->insertNewestData();
             $sessionLengthTable = new SessionLengthTable($this->db);
             $sessionLengthTable->insertNewestData();
             $logDumpTable = new LogDumpTable($this->db);
             $logDumpTable->insertNewestData();
             $userCollectiveTable = new UserCollectiveTable($this->db);
             $userCollectiveTable->assimilateUsers();
             $stopAfterJob = true;
             break;
         case 'autoFeature':
             require_once PATH_CORE . '/classes/content.class.php';
             $cObj = new content($this->db);
             $cObj->autoFeature();
             break;
         case 'cleanup':
             require_once 'cleanup.class.php';
             $cleanObj = new cleanup($this->db, 'daily');
             break;
             // deprecated
         // deprecated
         case 'syncFeedList':
             require_once 'apiCloud.class.php';
             $apiObj = new apiCloud($this->db, $this->apiKey);
             $result = $apiObj->syncFeedList($this->cloudid);
             require_once 'feed.class.php';
             $feedObj = new feed($this->db);
             $feedObj->syncFeedList($result[items]);
             break;
     }
     $execTime = microtime(true) - $startTime;
     $this->log('...completed in ' . $execTime . ' seconds.');
     $this->history[$this->cntJobs]['task'] = $job->task;
     $this->history[$this->cntJobs]['time'] = $execTime;
     $this->cntJobs += 1;
     $this->db->update("cronJobs", "nextRun=date_sub(NOW(), INTERVAL (0-{$job->freqMinutes}) MINUTE),lastExecTime={$execTime},lastStart='" . date('Y-m-d H:i:s', $startTime) . "',isRunning=0", "id={$job->id}");
     if ($stopAfterJob) {
         exit;
     }
 }
Exemplo n.º 23
0
 //Next and previous units are needed for navigation buttons
 //package_ID denotes that a SCORM 2004 unit is active.
 if (!isset($_GET['package_ID'])) {
     $nextUnit = $currentContent->getNextNode($currentUnit, $visitableIterator);
     $smarty->assign("T_NEXT_UNIT", $nextUnit);
     $previousUnit = $currentContent->getPreviousNode($currentUnit, $visitableIterator);
     $smarty->assign("T_PREVIOUS_UNIT", $previousUnit);
     //Parents are needed for printing the titles
     $smarty->assign("T_PARENT_LIST", $currentContent->getNodeAncestors($currentUnit));
 } else {
     //SCORM 2004 content handles navigation on its own, so it's illegal to have additional navigation handles
     $smarty->assign("T_PARENT_LIST", $currentContent->getNodeAncestors($_GET['package_ID']));
     $smarty->assign("T_SCORM_2004_TITLE", true);
 }
 $comments = array();
 $result = array_merge(comments::getComments($currentLesson->lesson['id'], false, $currentUnit['id']), comments::getComments($currentLesson->lesson['id'], $currentUser, $currentUnit['id'], false, false));
 foreach ($result as $value) {
     if (!isset($comments[$value['id']])) {
         $comments[$value['id']] = $value;
     }
 }
 foreach ($comments as $key => $value) {
     //$user = EfrontUserFactory :: factory($value['users_LOGIN']);
     //$comments[$key]['avatar'] = $user -> getAvatar();
 }
 if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) {
     //this applies to supervisors only
     $currentBranch = new EfrontBranch($_SESSION['s_current_branch']);
     $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers());
     foreach ($comments as $key => $value) {
         if (!in_array($value['users_LOGIN'], $branchTreeUsers)) {
Exemplo n.º 24
0
function glossar_showcomments($id)
{
    global $set, $db, $apx, $user;
    $id = (int) $id;
    $res = $db->first("SELECT id,allowcoms FROM " . PRE . "_glossar WHERE ( id='" . $id . "' AND starttime!='0' ) LIMIT 1");
    if (!$apx->is_module('comments') || !$set['glossar']['coms'] || !$res['allowcoms']) {
        return;
    }
    require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
    $coms = new comments('glossar', $id);
    $coms->assign_comments();
    $apx->tmpl->parse('comments', 'comments');
    require 'lib/_end.php';
}
Exemplo n.º 25
0
function products_print($data, $template)
{
    global $set, $db, $apx, $user;
    $tmpl = new tengine();
    $apx->lang->drop('fields', 'products');
    //Verwendet Variablen auslesen
    $parse = $apx->tmpl->used_vars($template, 'products');
    $ids = get_ids($data, 'id');
    $types = get_ids($data, 'type');
    if (count($data)) {
        $unitvars = array('PRODUCT.DEVELOPER', 'PRODUCT.DEVELOPER_WEBSITE', 'PRODUCT.DEVELOPER_LINK', 'PRODUCT.PUBLISHER', 'PRODUCT.PUBLISHER_WEBSITE', 'PRODUCT.PUBLISHER_LINK', 'PRODUCT.MANUFACTURER', 'PRODUCT.MANUFACTURER_WEBSITE', 'PRODUCT.MANUFACTURER_LINK', 'PRODUCT.STUDIO', 'PRODUCT.STUDIO_WEBSITE', 'PRODUCT.STUDIO_LINK', 'PRODUCT.LABEL', 'PRODUCT.LABEL_WEBSITE', 'PRODUCT.LABEL_LINK', 'PRODUCT.ARTIST', 'PRODUCT.ARTIST_WEBSITE', 'PRODUCT.ARTIST_LINK', 'PRODUCT.AUTHOR', 'PRODUCT.AUTHOR_WEBSITE', 'PRODUCT.AUTHOR_LINK');
        //Einheiten auslesen
        $unitinfo = array();
        if (in_template($unitvars, $parse)) {
            $unitids = array_merge(get_ids($data, 'manufacturer'), get_ids($data, 'publisher'));
            $unitinfo = $db->fetch_index("SELECT id,title,website FROM " . PRE . "_products_units WHERE id IN (" . implode(',', $unitids) . ")", 'id');
        }
        //Gruppen auslesen
        $groupinfo = array();
        $groups = array();
        /*if ( in_template(array('PRODUCT.MEDIA'),$parse) ) $groups = array_merge($groups,get_ids($data,'media'));
        		if ( in_array('PRODUCT.GENRE',$parse) ) $groups = array_merge($groups,get_ids($data,'genre'));
        		if ( in_array('game',$types) && in_template(array('PRODUCT.RELEASE.SYSTEM','PRODUCT.RELEASE.SYSTEM_ICON','PRODUCT.SYSTEM'),$parse) ) {
        			if ( count($groups)==0 ) $groups = array(0);
        			$groupinfo = $db->fetch_index("SELECT id,title,icon FROM ".PRE."_products_groups WHERE id IN (".implode(',',$groups).") OR grouptype='system'",'id');
        		}
        		elseif ( in_array('movie',$types) && in_template(array('PRODUCT.RELEASE.MEDIA','PRODUCT.RELEASE.MEDIA_ICON','PRODUCT.MEDIA'),$parse) ) {
        			if ( count($groups)==0 ) $groups = array(0);
        			$groupinfo = $db->fetch_index("SELECT id,title,icon FROM ".PRE."_products_groups WHERE id IN (".implode(',',$groups).") OR grouptype='media'",'id');
        		}
        		elseif ( count($groups) ) {
        			$groupinfo = $db->fetch_index("SELECT id,title,icon FROM ".PRE."_products_groups WHERE id IN (".implode(',',$groups).")",'id');
        		}*/
        $groupinfo = $db->fetch_index("SELECT id,title,icon FROM " . PRE . "_products_groups", 'id');
        //Veröffentlichungs-Daten auslesen
        $releaseinfo = array();
        if (in_array('PRODUCT.RELEASE', $parse)) {
            $releasedata = $db->fetch("SELECT prodid,system,data,stamp FROM " . PRE . "_products_releases WHERE prodid IN (" . implode(',', $ids) . ") ORDER BY stamp ASC");
            if (count($releasedata)) {
                foreach ($releasedata as $relres) {
                    $info = unserialize($relres['data']);
                    $releasedate = products_format_release($info);
                    $relentry = array('stamp' => $relres['stamp'], 'DATE' => $releasedate, 'SYSTEM' => $groupinfo[$relres['system']]['title'], 'SYSTEM_ICON' => $groupinfo[$relres['system']]['icon'], 'MEDIA' => $groupinfo[$relres['system']]['title'], 'MEDIA_ICON' => $groupinfo[$relres['system']]['icon']);
                    $releaseinfo[$relres['prodid']][] = $relentry;
                }
            }
        }
        //Produkte auflisten
        foreach ($data as $res) {
            ++$i;
            //Link
            $link = mklink('products.php?id=' . $res['id'], 'products,id' . $res['id'] . urlformat($res['title']) . '.html');
            //Produktbild
            if (in_array('PRODUCT.PICTURE', $parse) || in_array('PRODUCT.PICTURE_POPUP', $parse) || in_array('PRODUCT.PICTURE_POPUPPATH', $parse)) {
                list($picture, $picture_popup, $picture_popuppath) = products_pic($res['picture']);
            }
            //Teaserbild
            if (in_array('PRODUCT.TEASERPIC', $parse) || in_array('PRODUCT.TEASERPIC_POPUP', $parse) || in_array('PRODUCT.TEASERPIC_POPUPPATH', $parse)) {
                list($teaserpic, $teaserpic_popup, $teaserpic_popuppath) = products_pic($res['teaserpic']);
            }
            //Text
            $text = '';
            if (in_array('PRODUCT.TEXT', $parse)) {
                $text = mediamanager_inline($res['text']);
                if ($apx->is_module('glossar')) {
                    $text = glossar_highlight($text);
                }
            }
            //Datehead
            if ($laststamp != date('Y/m/d', $res['addtime'] - TIMEDIFF)) {
                $tabledata[$i]['DATEHEAD'] = $res['addtime'];
            }
            //Tags
            if (in_array('PRODUCT.TAG', $parse) || in_array('PRODUCT.TAG_IDS', $parse) || in_array('PRODUCT.KEYWORDS', $parse)) {
                list($tagdata, $tagids, $keywords) = products_tags($res['id']);
            }
            //Standard-Platzhalter
            $tabledata[$i]['ID'] = $res['id'];
            $tabledata[$i]['TYPE'] = $res['type'];
            $tabledata[$i]['LINK'] = $link;
            $tabledata[$i]['TITLE'] = $res['title'];
            $tabledata[$i]['TEXT'] = $text;
            $tabledata[$i]['TIME'] = $res['addtime'];
            $tabledata[$i]['WEBSITE'] = $res['website'];
            $tabledata[$i]['BUYLINK'] = $res['buylink'];
            $tabledata[$i]['PRICE'] = $res['price'];
            $tabledata[$i]['HITS'] = $res['hits'];
            $tabledata[$i]['PICTURE'] = $picture;
            $tabledata[$i]['PICTURE_POPUP'] = $picture_popup;
            $tabledata[$i]['PICTURE_POPUPPATH'] = $picture_popuppath;
            $tabledata[$i]['TEASERPIC'] = $teaserpic;
            $tabledata[$i]['TEASERPIC_POPUP'] = $teaserpic_popup;
            $tabledata[$i]['TEASERPIC_POPUPPATH'] = $teaserpic_popuppath;
            $tabledata[$i]['PRODUCT_ID'] = $res['prodid'];
            $tabledata[$i]['RECOMMENDED_PRICE'] = $res['recprice'];
            $tabledata[$i]['GUARANTEE'] = $res['guarantee'];
            //Sammlung
            if ($user->info['userid']) {
                if (!products_in_coll($res['id'])) {
                    $tabledata[$i]['LINK_COLLECTION_ADD'] = mklink('products.php?id=' . $res['id'] . '&amp;addcoll=1', 'products,id' . $res['id'] . urlformat($res['title']) . '.html?addcoll=1');
                } else {
                    $tabledata[$i]['LINK_COLLECTION_REMOVE'] = mklink('products.php?id=' . $res['id'] . '&amp;removecoll=1', 'products,id' . $res['id'] . urlformat($res['title']) . '.html?removecoll=1');
                }
            }
            //Tags
            $tabledata[$i]['TAG'] = $tagdata;
            $tabledata[$i]['TAG_IDS'] = $tagids;
            $tabledata[$i]['KEYWORDS'] = $keywords;
            //NORMAL
            if ($res['type'] == 'normal') {
                $manulink = mklink('manufacturers.php?id=' . $res['manufacturer'], 'manufacturers,id' . $res['manufacturer'] . urlformat($unitinfo[$res['manufacturer']]['title']) . '.html');
                $tabledata[$i]['MANUFACTURER'] = $unitinfo[$res['manufacturer']]['title'];
                $tabledata[$i]['MANUFACTURER_WEBSITE'] = $unitinfo[$res['manufacturer']]['website'];
                $tabledata[$i]['MANUFACTURER_LINK'] = $manulink;
            } elseif ($res['type'] == 'game') {
                //System-Liste
                $systemdata = array();
                if (in_array('PRODUCT.SYSTEM', $parse)) {
                    $systems = dash_unserialize($res['systems']);
                    if (!is_array($systems)) {
                        $systems = array();
                    }
                    foreach ($systems as $sysid) {
                        ++$ii;
                        $systemdata[$ii]['TITLE'] = $groupinfo[$sysid]['title'];
                        $systemdata[$ii]['ICON'] = $groupinfo[$sysid]['icon'];
                    }
                }
                //Media-Liste
                $media = dash_unserialize($res['media']);
                if (!is_array($media)) {
                    $media = array();
                }
                $mediadata = array();
                foreach ($media as $medid) {
                    ++$ii;
                    $mediadata[$ii]['TITLE'] = $groupinfo[$medid]['title'];
                    $mediadata[$ii]['ICON'] = $groupinfo[$medid]['icon'];
                }
                $manulink = mklink('manufacturers.php?id=' . $res['manufacturer'], 'manufacturers,id' . $res['manufacturer'] . urlformat($unitinfo[$res['manufacturer']]['title']) . '.html');
                $publink = mklink('manufacturers.php?id=' . $res['publisher'], 'manufacturers,id' . $res['publisher'] . urlformat($unitinfo[$res['publisher']]['title']) . '.html');
                $tabledata[$i]['DEVELOPER'] = $unitinfo[$res['manufacturer']]['title'];
                $tabledata[$i]['DEVELOPER_WEBSITE'] = $unitinfo[$res['manufacturer']]['website'];
                $tabledata[$i]['DEVELOPER_LINK'] = $manulink;
                $tabledata[$i]['PUBLISHER'] = $unitinfo[$res['publisher']]['title'];
                $tabledata[$i]['PUBLISHER_WEBSITE'] = $unitinfo[$res['publisher']]['website'];
                $tabledata[$i]['PUBLISHER_LINK'] = $publink;
                $tabledata[$i]['USK'] = $res['sk'];
                $tabledata[$i]['GENRE'] = $groupinfo[$res['genre']]['title'];
                $tabledata[$i]['MEDIA'] = $mediadata;
                $tabledata[$i]['SYSTEM'] = $systemdata;
                $tabledata[$i]['REQUIREMENTS'] = $res['requirements'];
            } elseif ($res['type'] == 'hardware') {
                $manulink = mklink('manufacturers.php?id=' . $res['manufacturer'], 'manufacturers,id' . $res['manufacturer'] . urlformat($unitinfo[$res['manufacturer']]['title']) . '.html');
                $tabledata[$i]['MANUFACTURER'] = $unitinfo[$res['manufacturer']]['title'];
                $tabledata[$i]['MANUFACTURER_WEBSITE'] = $unitinfo[$res['manufacturer']]['website'];
                $tabledata[$i]['MANUFACTURER_LINK'] = $manulink;
                $tabledata[$i]['EQUIPMENT'] = $res['equipment'];
            } elseif ($res['type'] == 'software') {
                //Media-Liste
                $media = dash_unserialize($res['media']);
                if (!is_array($media)) {
                    $media = array();
                }
                $mediadata = array();
                foreach ($media as $medid) {
                    ++$ii;
                    $mediadata[$ii]['TITLE'] = $groupinfo[$medid]['title'];
                    $mediadata[$ii]['ICON'] = $groupinfo[$medid]['icon'];
                }
                $manulink = mklink('manufacturers.php?id=' . $res['manufacturer'], 'manufacturers,id' . $res['manufacturer'] . urlformat($unitinfo[$res['manufacturer']]['title']) . '.html');
                $tabledata[$i]['MANUFACTURER'] = $unitinfo[$res['manufacturer']]['title'];
                $tabledata[$i]['MANUFACTURER_WEBSITE'] = $unitinfo[$res['manufacturer']]['website'];
                $tabledata[$i]['MANUFACTURER_LINK'] = $manulink;
                $tabledata[$i]['OS'] = $res['os'];
                $tabledata[$i]['LANGUAGES'] = $res['languages'];
                $tabledata[$i]['REQUIREMENTS'] = $res['requirements'];
                $tabledata[$i]['LICENSE'] = $res['license'];
                $tabledata[$i]['VERSION'] = $res['version'];
                $tabledata[$i]['MEDIA'] = $mediadata;
            } elseif ($res['type'] == 'music') {
                //Media-Liste
                $media = dash_unserialize($res['media']);
                if (!is_array($media)) {
                    $media = array();
                }
                $mediadata = array();
                foreach ($media as $medid) {
                    ++$ii;
                    $mediadata[$ii]['TITLE'] = $groupinfo[$medid]['title'];
                    $mediadata[$ii]['ICON'] = $groupinfo[$medid]['icon'];
                }
                $manulink = mklink('manufacturers.php?id=' . $res['manufacturer'], 'manufacturers,id' . $res['manufacturer'] . urlformat($unitinfo[$res['manufacturer']]['title']) . '.html');
                $publink = mklink('manufacturers.php?id=' . $res['publisher'], 'manufacturers,id' . $res['publisher'] . urlformat($unitinfo[$res['publisher']]['title']) . '.html');
                $tabledata[$i]['ARTIST'] = $unitinfo[$res['manufacturer']]['title'];
                $tabledata[$i]['ARTIST_WEBSITE'] = $unitinfo[$res['manufacturer']]['website'];
                $tabledata[$i]['ARTIST_LINK'] = $manulink;
                $tabledata[$i]['LABEL'] = $unitinfo[$res['publisher']]['title'];
                $tabledata[$i]['LABEL_WEBSITE'] = $unitinfo[$res['publisher']]['website'];
                $tabledata[$i]['LABEL_LINK'] = $publink;
                $tabledata[$i]['FSK'] = $res['sk'];
                $tabledata[$i]['GENRE'] = $groupinfo[$res['genre']]['title'];
                $tabledata[$i]['MEDIA'] = $mediadata;
            } elseif ($res['type'] == 'movie') {
                //Media-Liste
                $media = dash_unserialize($res['media']);
                if (!is_array($media)) {
                    $media = array();
                }
                $mediadata = array();
                foreach ($media as $medid) {
                    ++$ii;
                    $mediadata[$ii]['TITLE'] = $groupinfo[$medid]['title'];
                    $mediadata[$ii]['ICON'] = $groupinfo[$medid]['icon'];
                }
                $publink = mklink('manufacturers.php?id=' . $res['publisher'], 'manufacturers,id' . $res['publisher'] . urlformat($unitinfo[$res['publisher']]['title']) . '.html');
                $tabledata[$i]['STUDIO'] = $unitinfo[$res['publisher']]['title'];
                $tabledata[$i]['STUDIO_WEBSITE'] = $unitinfo[$res['publisher']]['website'];
                $tabledata[$i]['STUDIO_LINK'] = $publink;
                $tabledata[$i]['REGISSEUR'] = $res['regisseur'];
                $tabledata[$i]['ACTORS'] = $res['actors'];
                $tabledata[$i]['LENGTH'] = $res['length'];
                $tabledata[$i]['FSK'] = $res['sk'];
                $tabledata[$i]['GENRE'] = $groupinfo[$res['genre']]['title'];
                $tabledata[$i]['MEDIA'] = $mediadata;
            } elseif ($res['type'] == 'book') {
                //Media-Liste
                $media = dash_unserialize($res['media']);
                if (!is_array($media)) {
                    $media = array();
                }
                $mediadata = array();
                foreach ($media as $medid) {
                    ++$ii;
                    $mediadata[$ii]['TITLE'] = $groupinfo[$medid]['title'];
                    $mediadata[$ii]['ICON'] = $groupinfo[$medid]['icon'];
                }
                $manulink = mklink('manufacturers.php?id=' . $res['manufacturer'], 'manufacturers,id' . $res['manufacturer'] . urlformat($unitinfo[$res['manufacturer']]['title']) . '.html');
                $publink = mklink('manufacturers.php?id=' . $res['publisher'], 'manufacturers,id' . $res['publisher'] . urlformat($unitinfo[$res['publisher']]['title']) . '.html');
                $tabledata[$i]['AUTHOR'] = $unitinfo[$res['manufacturer']]['title'];
                $tabledata[$i]['AUTHOR_WEBSITE'] = $unitinfo[$res['manufacturer']]['website'];
                $tabledata[$i]['AUTHOR_LINK'] = $manulink;
                $tabledata[$i]['PUBLISHER'] = $unitinfo[$res['publisher']]['title'];
                $tabledata[$i]['PUBLISHER_WEBSITE'] = $unitinfo[$res['publisher']]['website'];
                $tabledata[$i]['PUBLISHER_LINK'] = $publink;
                $tabledata[$i]['GENRE'] = $groupinfo[$res['genre']]['title'];
                $tabledata[$i]['MEDIA'] = $mediadata;
                $tabledata[$i]['ISBN'] = $res['isbn'];
            }
            //Benutzerdefinierte Felder
            for ($ii = 1; $ii <= 10; $ii++) {
                $tabledata[$i]['CUSTOM' . $ii . '_NAME'] = replace($set['products']['custom_' . $res['type']][$ii - 1]);
                $tabledata[$i]['CUSTOM' . $ii] = $res['custom' . $ii];
            }
            //Veröffentlichung
            if (in_array('PRODUCT.RELEASE', $parse)) {
                if ($res['releasestamp']) {
                    $temprel = $releaseinfo[$res['id']];
                    foreach ($temprel as $rel) {
                        if ($rel['stamp'] != $res['releasestamp']) {
                            continue;
                        }
                        ++$ii;
                        $tabledata[$i]['RELEASE'][$ii] = $rel;
                    }
                } else {
                    $tabledata[$i]['RELEASE'] = $releaseinfo[$res['id']];
                }
            }
            //Kommentare
            if ($apx->is_module('comments') && $set['products']['coms'] && $res['allowcoms']) {
                require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
                if (!isset($coms)) {
                    $coms = new comments('products', $res['id']);
                } else {
                    $coms->mid = $res['id'];
                }
                $link = mklink('products.php?id=' . $res['id'], 'products,id' . $res['id'] . urlformat($res['title']) . '.html');
                $tabledata[$i]['COMMENT_COUNT'] = $coms->count();
                $tabledata[$i]['COMMENT_LINK'] = $coms->link($link);
                $tabledata[$i]['DISPLAY_COMMENTS'] = 1;
                if (in_template(array('PRODUCT.COMMENT_LAST_USERID', 'PRODUCT.COMMENT_LAST_NAME', 'PRODUCT.COMMENT_LAST_TIME'), $parse)) {
                    $tabledata[$i]['COMMENT_LAST_USERID'] = $coms->last_userid();
                    $tabledata[$i]['COMMENT_LAST_NAME'] = $coms->last_name();
                    $tabledata[$i]['COMMENT_LAST_TIME'] = $coms->last_time();
                }
            }
            //Bewertungen
            if ($apx->is_module('ratings') && $set['products']['ratings'] && $res['allowrating']) {
                require_once BASEDIR . getmodulepath('ratings') . 'class.ratings.php';
                if (!isset($rate)) {
                    $rate = new ratings('products', $res['id']);
                } else {
                    $rate->mid = $res['id'];
                }
                $tabledata[$i]['RATING'] = $rate->display();
                $tabledata[$i]['RATING_VOTES'] = $rate->count();
                $tabledata[$i]['DISPLAY_RATING'] = 1;
            }
            $laststamp = date('Y/m/d', $res['addtime'] - TIMEDIFF);
        }
    }
    $tmpl->assign('PRODUCT', $tabledata);
    $tmpl->parse($template, 'products');
}
Exemplo n.º 26
0
function calendar_print($data, $template)
{
    global $set, $db, $apx, $user;
    $tmpl = new tengine();
    $parse = $tmpl->used_vars($template, 'calendar');
    //Kategorie-Info
    $catids = get_ids($data, 'catid');
    $catdata = array();
    if (count($catids)) {
        $catdata = $db->fetch_index("SELECT * FROM " . PRE . "_calendar_cat WHERE id IN (" . implode(',', $catids) . ")", 'id');
    }
    //Termine auflisten
    if (count($data)) {
        foreach ($data as $res) {
            ++$i;
            $event = array();
            //Kategorie-Info
            $catinfo = $catdata[$res['catid']];
            //Link zum Termin
            $link = mklink('events.php?id=' . $res['id'], 'events,id' . $res['id'] . urlformat($res['title']) . '.html');
            //Aufmacher
            $picture = $picture_popup = '';
            if (in_template(array('EVENT.PICTURE', 'EVENT.PICTURE_POPUP', 'EVENT.PICTURE_POPUPPATH'), $parse)) {
                list($picture, $picture_popup, $picture_popuppath) = calendar_pic($res['picture']);
            }
            //Start berechnen
            $startday = $starttime = $endday = $endtime = 0;
            if (in_template(array('EVENT.STARTDAY', 'EVENT.STARTTIME'), $parse)) {
                $startday = calendar_stamp2time($res['startday']);
                if ($res['starttime'] != -1) {
                    $time_comp = calendar_explode_stamp($res['startday']);
                    $tmpstamp = sprintf('%04d', $res['starttime']);
                    $time_comp['hour'] = substr($tmpstamp, 0, 2);
                    $time_comp['minute'] = substr($tmpstamp, 2, 2);
                    $starttime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
                }
            }
            //Ende berechnen (falls nötig)
            if (in_template(array('EVENT.ENDDAY', 'EVENT.ENDTIME'), $parse)) {
                if ($res['endday'] != $res['startday'] || $res['endtime'] != -1) {
                    $endday = calendar_stamp2time($res['endday']);
                    if ($res['endtime'] != -1) {
                        $time_comp = calendar_explode_stamp($res['endday']);
                        $tmpstamp = sprintf('%04d', $res['endtime']);
                        $time_comp['hour'] = substr($tmpstamp, 0, 2);
                        $time_comp['minute'] = substr($tmpstamp, 2, 2);
                        $endtime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
                    }
                }
            }
            //Username + eMail
            if ($res['userid']) {
                $username = $res['username'];
                $email = iif(!$res['pub_hidemail'], $res['email']);
            } else {
                $username = $res['send_username'];
                $email = $res['send_email'];
            }
            //Text
            $eventtext = '';
            if (in_array('EVENT.TEXT', $parse)) {
                $eventtext = mediamanager_inline($res['text']);
                if ($apx->is_module('glossar')) {
                    $eventtext = glossar_highlight($eventtext);
                }
            }
            //Datehead
            if ($laststamp != $res['startday']) {
                $event['DATEHEAD'] = $startday;
            }
            //Tags
            if (in_array('EVENT.TAG', $parse) || in_array('EVENT.TAG_IDS', $parse) || in_array('EVENT.KEYWORDS', $parse)) {
                list($tagdata, $tagids, $keywords) = calendar_tags($res['id']);
            }
            $event['ID'] = $res['id'];
            $event['TITLE'] = $res['title'];
            $event['TEXT'] = $eventtext;
            $event['LINK'] = $link;
            $event['LOCATION'] = compatible_hsc($res['location']);
            $event['LOCATION_LINK'] = compatible_hsc($res['location_link']);
            $event['PRIORITY'] = $res['priority'];
            $event['RESTRICTED'] = $res['restricted'];
            $event['PRIVATE'] = $res['private'];
            $event['HITS'] = $res['hits'];
            $event['RELATED'] = calendar_links($res['links']);
            $event['PICTURE'] = $picture;
            $event['PICTURE_POPUP'] = $picture_popup;
            $event['PICTURE_POPUPPATH'] = $picture_popuppath;
            $event['STARTDAY'] = $startday;
            $event['STARTTIME'] = $starttime;
            $event['ENDDAY'] = $endday;
            $event['ENDTIME'] = $endtime;
            $event['USERID'] = $res['userid'];
            $event['USERNAME'] = replace($username);
            $event['EMAIL'] = replace($email);
            $event['EMAIL_ENCRYPTED'] = replace(cryptMail($email));
            $event['CATID'] = $res['catid'];
            $event['CATTITLE'] = $catinfo['title'];
            $event['CATICON'] = $catinfo['icon'];
            //Tags
            $event['TAG'] = $tagdata;
            $event['TAG_IDS'] = $tagids;
            $event['KEYWORDS'] = $keywords;
            //Galerie
            if ($apx->is_module('gallery') && $res['galid'] && !$res['private'] && in_template(array('EVENT.GALLERY_ID', 'EVENT.GALLERY_TITLE', 'EVENT.GALLERY_LINK'), $parse)) {
                $galinfo = gallery_info($res['galid']);
                $event['GALLERY_ID'] = $galinfo['id'];
                $event['GALLERY_TITLE'] = $galinfo['title'];
                $event['GALLERY_LINK'] = mklink('gallery.php?id=' . $galinfo['id'], 'gallery,list' . $galinfo['id'] . ',1' . urlformat($galinfo['title']) . '.html');
            }
            //Kommentare
            if ($apx->is_module('comments') && $set['calendar']['coms'] && $res['allowcoms']) {
                require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
                if (!isset($coms)) {
                    $coms = new comments('calendar', $res['id']);
                } else {
                    $coms->mid = $res['id'];
                }
                $link = mklink('events.php?id=' . $res['id'], 'events,id' . $res['id'] . urlformat($res['title']) . '.html');
                $event['COMMENT_COUNT'] = $coms->count();
                $event['COMMENT_LINK'] = $coms->link($link);
                $event['DISPLAY_COMMENTS'] = 1;
                if (in_template(array('EVENT.COMMENT_LAST_USERID', 'EVENT.COMMENT_LAST_NAME', 'EVENT.COMMENT_LAST_TIME'), $parse)) {
                    $event['COMMENT_LAST_USERID'] = $coms->last_userid();
                    $event['COMMENT_LAST_NAME'] = $coms->last_name();
                    $event['COMMENT_LAST_TIME'] = $coms->last_time();
                }
            }
            $eventdata[$i] = $event;
            $laststamp = $res['startday'];
        }
    }
    $tmpl->assign('EVENT', $eventdata);
    $tmpl->parse($template, 'calendar');
}
Exemplo n.º 27
0
 //Tags
 $tabledata[$i]['TAG'] = $tagdata;
 $tabledata[$i]['TAG_IDS'] = $tagids;
 $tabledata[$i]['KEYWORDS'] = $keywords;
 //Kategorie
 $tabledata[$i]['CATID'] = $res['catid'];
 $tabledata[$i]['CATTITLE'] = $catinfo[$res['catid']]['title'];
 $tabledata[$i]['CATTEXT'] = $catinfo[$res['catid']]['text'];
 $tabledata[$i]['CATICON'] = $catinfo[$res['catid']]['icon'];
 //Produkt
 $tabledata[$i]['PRODUCT_ID'] = $res['prodid'];
 //Kommentare
 if ($apx->is_module('comments') && $set['videos']['coms'] && $res['allowcoms']) {
     require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
     if (!isset($coms)) {
         $coms = new comments('videos', $res['id']);
     } else {
         $coms->mid = $res['id'];
     }
     $link = mklink('videos.php?id=' . $res['id'], 'videos,id' . $res['id'] . urlformat($res['title']) . '.html');
     $tabledata[$i]['COMMENT_COUNT'] = $coms->count();
     $tabledata[$i]['COMMENT_LINK'] = $coms->link($link);
     $tabledata[$i]['DISPLAY_COMMENTS'] = 1;
     if (in_template(array('VIDEO.COMMENT_LAST_USERID', 'VIDEO.COMMENT_LAST_NAME', 'VIDEO.COMMENT_LAST_TIME'), $parse)) {
         $tabledata[$i]['COMMENT_LAST_USERID'] = $coms->last_userid();
         $tabledata[$i]['COMMENT_LAST_NAME'] = $coms->last_name();
         $tabledata[$i]['COMMENT_LAST_TIME'] = $coms->last_time();
     }
 }
 //Bewertungen
 if ($apx->is_module('ratings') && $set['videos']['ratings'] && $res['allowrating']) {
 /**
  * Add all post data, which is necessary for rendering the posts
  * 
  * @param object $course
  * @param  object $postsdata containing retrieved posts in $postdata->post
  * @return object the postdata object with all of the data added
  */
 protected function add_posts_data($course, &$postsdata)
 {
     global $DB;
     if (empty($postsdata->posts)) {
         return $postsdata;
     }
     $courseid = $course->id;
     // ... gather all the authors ids from posts.
     foreach ($postsdata->posts as &$post) {
         $postsdata->authors[$post->fromuserid] = $post->fromuserid;
     }
     // ... add all comments, replies to comments and add more authors.
     comments::add_comments_to_posts($postsdata, $course->tlnumcomments, $course->tlnumreplies);
     // ... add all likes from this user.
     $likes = likes::instance($course);
     $likes->add_likes_to_posts($postsdata);
     // ... add all attachments.
     attaches::add_attaches_to_posts($courseid, $postsdata);
     // ... finally gather all the required userdata for authors.
     if (!($users = $DB->get_records_list('user', 'id', array_keys($postsdata->authors)))) {
         debugging('error while retrieving post authors');
     }
     $postsdata->authors = $users;
     return $postsdata;
 }
 public static function delete_comment()
 {
     $cid = required_param('cid', PARAM_INT);
     $formatsociallwallcomments = comments::instance();
     return $formatsociallwallcomments->delete_comment($cid);
 }
Exemplo n.º 30
0
 public static function parseQuote($message)
 {
     $i = 0;
     $pattern = '#\\[quote=([0-9]+)\\|p\\]#i';
     while (preg_match($pattern, $message) && ++$i < 11) {
         $message = preg_replace_callback($pattern, function ($m) {
             $username = comments::getUsernameFromCid($m[1], true);
             return $username ? '[commentquote=[user]' . $username . '[/user] [small][url=&quot;' . comments::getURLFromCid($m[1], true) . '&quot;]→ c' . $m[1] . '[/url][/small]]' . comments::getMessage($m[1], true) . '[/commentquote]' : '';
         }, $message, 1);
     }
     if ($i == 11) {
         $message = preg_replace('#\\[quote=([0-9]+)\\|p\\]#i', '', $message);
     }
     $i = 0;
     $pattern = '#\\[quote=([0-9]+)\\|u\\]#i';
     while (preg_match($pattern, $message) && ++$i < 11) {
         $message = preg_replace_callback($pattern, function ($m) {
             $username = comments::getUsernameFromCid($m[1]);
             return $username ? '[commentquote=[user]' . $username . '[/user] [small][url=&quot;' . comments::getURLFromCid($m[1]) . '&quot;]→ c' . $m[1] . '[/url][/small]]' . comments::getMessage($m[1]) . '[/commentquote]' : '';
         }, $message, 1);
     }
     if ($i == 11) {
         $message = preg_replace('#\\[quote=([0-9]+)\\|u\\]#i', '', $message);
     }
     //Brought back quotes
     return trim($message);
 }