コード例 #1
0
ファイル: Controller.php プロジェクト: ameoba32/tiki
 /**
  * Function to toggle relation. Sets relation when none set and then if there is a relation, it unsets.
  * @param $input
  * @return array with "relationId" as param. Null if relation is removed.
  * @throws Exception
  * @throws Services_Exception
  */
 function action_toggle($input)
 {
     $relation = $input->relation->none();
     $target_type = $input->target_type->none();
     $target_id = $input->target_id->none();
     $source_type = $input->source_type->none();
     $source_id = $input->source_id->none();
     // ensure the target, source, and relation info are passed to the service
     if (!$target_type || !$target_id || !$source_type || !$source_id || !$relation) {
         throw new Services_Exception(tr('Invalid input'), 400);
     }
     $relationlib = TikiLib::lib('relation');
     $tx = TikiDb::get()->begin();
     $relationId = $relationlib->get_relation_id($relation, $source_type, $source_id, $target_type, $target_id);
     // If there is not an existing relation, add the relation and trigger the add relation event.
     if (!$relationId) {
         $relationId = $relationlib->add_relation($relation, $source_type, $source_id, $target_type, $target_id);
         TikiLib::events()->trigger('tiki.relation.add', array('id' => $relationId, 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation));
     } else {
         //if there is a relation, remove the relation, trigger the event, and set the relationId to null
         $relationlib->remove_relation($relationId);
         TikiLib::events()->trigger('tiki.relation.remove', array('id' => $relationId, 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation));
         $relationId = null;
         // set the
     }
     $tx->commit();
     //return the relationId (new relation if added, null if removed)
     return array('relation_id' => $relationId);
 }
コード例 #2
0
ファイル: function.rating.php プロジェクト: linuxwhy/tiki-1
function smarty_function_rating($params, $smarty)
{
    global $prefs, $user;
    $ratinglib = TikiLib::lib('rating');
    if (!isset($params['type'], $params['id'])) {
        return tra('No object information provided for rating.');
    }
    $type = $params['type'];
    $id = $params['id'];
    if (isset($params['changemandated']) && $params['changemandated'] == 'y') {
        $changemandated = true;
        // needed to fix multiple submission problem in comments
    } else {
        $changemandated = false;
    }
    if (isset($_REQUEST['rating_value'][$type][$id], $_REQUEST['rating_prev'][$type][$id])) {
        $value = $_REQUEST['rating_value'][$type][$id];
        $prev = $_REQUEST['rating_prev'][$type][$id];
        if ((!$changemandated || $value != $prev) && $ratinglib->record_vote($type, $id, $value)) {
            // Handle type-specific actions
            if ($type == 'comment') {
                if ($user) {
                    $commentslib = TikiLib::lib('comments');
                    $commentslib->vote_comment($id, $user, $value);
                }
            }
            $tikilib = TikiLib::lib('tiki');
            if ($type == 'comment') {
                $forum_id = $commentslib->get_comment_forum_id($id);
                $forum_info = $commentslib->get_forum($forum_id);
                $thread_info = $commentslib->get_comment($id, null, $forum_info);
                $item_user = $thread_info['userName'];
            } elseif ($type == 'article') {
                $artlib = TikiLib::lib('art');
                $res = $artlib->get_article($id);
                $item_user = $res['author'];
            }
            if ($value == '1') {
                TikiLib::events()->trigger('tiki.social.rating.add', array('type' => $type, 'object' => $id, 'author' => $item_user, 'user' => $user));
            } elseif ($value == '2') {
                TikiLib::events()->trigger('tiki.social.rating.remove', array('type' => $type, 'object' => $id, 'author' => $item_user, 'user' => $user));
            }
        } elseif ($value != $prev) {
            return tra('An error occurred.');
        }
    }
    $vote = $ratinglib->get_vote($type, $id);
    $options = $ratinglib->get_options($type, $id, false, $hasLabels);
    if ($prefs['rating_smileys'] == 'y') {
        $smiles = $ratinglib->get_options_smiles($type, $id);
        $smarty->assign('rating_smiles', $smiles);
    }
    $smarty->assign('rating_type', $type);
    $smarty->assign('rating_id', $id);
    $smarty->assign('rating_options', $options);
    $smarty->assign('current_rating', $vote);
    $smarty->assign('rating_has_labels', $hasLabels);
    return $smarty->fetch('rating.tpl');
}
コード例 #3
0
ファイル: Transaction.php プロジェクト: linuxwhy/tiki-1
 function commit()
 {
     $done = TikiLib::lib('unifiedsearch')->endBatch($this->token);
     if ($done) {
         $events = TikiLib::events();
         $events->trigger('tiki.commit.after');
     }
 }
コード例 #4
0
 function addDocument(array $document)
 {
     $matches = $this->parent->getMatchingQueries($document);
     if (count($matches)) {
         $raw = TikiLib::lib('unifiedsearch')->getRawArray($document);
         foreach ($matches as $match) {
             list($priority, $id) = explode('-', $match, 2);
             TikiLib::events()->trigger('tiki.query.' . $priority, array('query' => $id, 'priority' => $priority, 'user' => $GLOBALS['user'], 'type' => $raw['object_type'], 'object' => $raw['object_id']));
         }
     }
     return $this->parent->addDocument($document);
 }
コード例 #5
0
ファイル: Broker.php プロジェクト: linuxwhy/tiki-1
 function process($controller, $action, JitFilter $request)
 {
     $access = TikiLib::lib('access');
     try {
         $this->preExecute();
         $output = $this->attemptProcess($controller, $action, $request);
         if (isset($output['FORWARD'])) {
             $output['FORWARD'] = array_merge(array('controller' => $controller, 'action' => $action), $output['FORWARD']);
         }
         if ($access->is_serializable_request()) {
             echo $access->output_serialized($output);
         } else {
             TikiLib::events()->trigger('tiki.process.render');
             echo $this->render($controller, $action, $output, $request);
         }
     } catch (Services_Exception_FieldError $e) {
         if ($request->modal->int() && $access->is_xml_http_request()) {
             // Special handling for modal dialog requests
             // Do not send an error code as bootstrap will just blank out
             // Render the error as a modal
             $smarty = TikiLib::lib('smarty');
             $smarty->assign('title', tr('Oops'));
             $smarty->assign('detail', ['message' => $e->getMessage()]);
             $smarty->display("extends:internal/modal.tpl|error-ajax.tpl");
         } else {
             $access->display_error(NULL, $e->getMessage(), $e->getCode());
         }
     } catch (Exception $e) {
         if ($request->modal->int() && $access->is_xml_http_request()) {
             // Special handling for modal dialog requests
             // Do not send an error code as bootstrap will just blank out
             // Render the error as a modal
             $smarty = TikiLib::lib('smarty');
             $smarty->assign('title', tr('Oops'));
             $smarty->assign('detail', ['message' => $e->getMessage()]);
             $smarty->display("extends:internal/modal.tpl|error-ajax.tpl");
         } else {
             $access->display_error(NULL, $e->getMessage(), $e->getCode());
         }
     }
 }
コード例 #6
0
 function action_toggle($input)
 {
     global $user;
     if (!$user) {
         throw new Services_Exception(tr('Must be authenticated'), 403);
     }
     $type = $input->type->none();
     $object = $input->object->none();
     $target = $input->target->int();
     if (!$type || !$object) {
         throw new Services_Exception(tr('Invalid input'), 400);
     }
     $relationlib = TikiLib::lib('relation');
     $tx = TikiDb::get()->begin();
     $relations = $this->action_list($input);
     $relationId = $this->getCurrentRelation($relations, $user, $type, $object);
     if ($type == 'trackeritem') {
         $parentobject = TikiLib::lib('trk')->get_tracker_for_item($object);
     } else {
         $parentobject = 'not implemented';
     }
     if ($target) {
         if (!$relationId) {
             $relationId = $relationlib->add_relation('tiki.user.favorite', 'user', $user, $type, $object);
             $relations[$relationId] = "{$type}:{$object}";
             $this->handleScore($type, $object);
             TikiLib::events()->trigger('tiki.social.favorite.add', array('type' => $type, 'object' => $object, 'parentobject' => $parentobject, 'user' => $user));
         }
     } else {
         if ($relationId) {
             $relationlib->remove_relation($relationId);
             unset($relations[$relationId]);
             TikiLib::events()->trigger('tiki.social.favorite.remove', array('type' => $type, 'object' => $object, 'parentobject' => $parentobject, 'user' => $user));
         }
     }
     $tx->commit();
     return array('list' => $relations);
 }
コード例 #7
0
ファイル: tiki-pagehistory.php プロジェクト: rjsmelo/tiki
} else if ({$not_comparing}) {
\t\$("input[name=newver]:eq(0)").prop("checked", "checked").change();
\t\$("input[name=oldver]:eq(1)").prop("checked", "checked").change();
}
JS
);
if (isset($_REQUEST["compare"])) {
    histlib_helper_setup_diff($page, $oldver, $newver);
    if (isset($approved_versions)) {
        $smarty->assign('flaggedrev_compare_approve', !in_array($newver, $approved_versions));
    }
} else {
    $smarty->assign('diff_style', $info['is_html'] === '1' ? 'htmldiff' : $prefs['default_wiki_diff_style']);
}
if ($info["flag"] == 'L') {
    $smarty->assign('lock', true);
} else {
    $smarty->assign('lock', false);
}
if (isset($_REQUEST['nohistory'])) {
    $smarty->assign('noHistory', true);
}
ask_ticket('page-history');
TikiLib::events()->trigger('tiki.wiki.view', array_merge(array('type' => 'wiki page', 'object' => $page, 'user' => $GLOBALS['user']), $info));
// disallow robots to index page:
$smarty->assign('page_user', $info['user']);
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
include_once 'tiki-section_options.php';
// Display the template
$smarty->assign('mid', 'tiki-pagehistory.tpl');
$smarty->display("tiki.tpl");
コード例 #8
0
 /**
  * Move file into another parent dir and/or rename.
  * Return new file path or false.
  *
  * @param  string  $source  source file path
  * @param  string  $targetDir  target dir path
  * @param  string  $name    file name
  * @return string|bool
  **/
 protected function _move($source, $targetDir, $name)
 {
     $ar = explode('_', $source);
     if (count($ar) === 2) {
         $isgal = $ar[0] === 'd';
         $source = $ar[1];
     } else {
         $isgal = true;
     }
     $name = trim(strip_tags($name));
     if (!$isgal) {
         $srcDirId = $this->options['accessControlData']['parentIds']['files'][$this->pathToId($source)];
     } else {
         $srcDirId = $this->pathToId($source);
     }
     $srcPerms = TikiLib::lib('tiki')->get_perm_object($srcDirId, 'file gallery', TikiLib::lib('filegal')->get_file_gallery_info($srcDirId));
     $targetDirId = $this->pathToId($targetDir);
     if ($srcDirId == $targetDirId) {
         $targetPerms = $srcPerms;
     } else {
         $targetPerms = TikiLib::lib('tiki')->get_perm_object($targetDirId, 'file gallery', TikiLib::lib('filegal')->get_file_gallery_info($targetDirId));
     }
     $canMove = $srcPerms['tiki_p_admin_file_galleries'] === 'y' && $targetPerms['tiki_p_admin_file_galleries'] === 'y' || $srcPerms['tiki_p_remove_files'] === 'y' && $targetPerms['tiki_p_upload_files'] === 'y';
     if ($isgal) {
         if ($canMove) {
             $result = $this->fileGalleriesTable->update(array('name' => $name, 'parentId' => $targetDirId), array('galleryId' => $srcDirId));
             if ($result) {
                 TikiLib::events()->trigger('tiki.filegallery.update', ['type' => 'file gallery', 'object' => $srcDirId]);
                 return 'd_' . $srcDirId;
             }
         }
     } else {
         if ($srcPerms['tiki_p_edit_gallery_file'] === 'y' && ($srcDirId !== $targetDirId || $canMove)) {
             $result = $this->filesTable->update(array('name' => $name, 'galleryId' => $targetDirId), array('fileId' => $this->pathToId($source)));
             if ($result) {
                 TikiLib::events()->trigger('tiki.file.update', ['type' => 'file', 'object' => $this->pathToId($source)]);
                 return 'f_' . $this->pathToId($source);
             }
         }
     }
     return '';
 }
コード例 #9
0
        }
    }
}
if ((!isset($_REQUEST["trackerId"]) || !$_REQUEST["trackerId"]) && isset($_REQUEST["itemId"])) {
    $item_info = $trklib->get_tracker_item($_REQUEST["itemId"]);
    $_REQUEST['trackerId'] = $item_info['trackerId'];
}
if (!isset($_REQUEST["trackerId"]) || !$_REQUEST["trackerId"]) {
    $smarty->assign('msg', tra("No tracker indicated"));
    $smarty->display("error.tpl");
    die;
}
if (isset($_REQUEST["itemId"])) {
    $item_info = $trklib->get_tracker_item($_REQUEST["itemId"]);
    $currentItemId = $_REQUEST["itemId"];
    TikiLib::events()->trigger('tiki.trackeritem.view', array('type' => 'trackeritem', 'object' => $currentItemId, 'owner' => $item_info['createdBy'], 'user' => $GLOBALS['user']));
}
$definition = Tracker_Definition::get($_REQUEST['trackerId']);
$xfields = array('data' => $definition->getFields());
$smarty->assign('tracker_is_multilingual', $prefs['feature_multilingual'] == 'y' && $definition->getLanguageField());
if (!isset($utid) and !isset($gtid) and (!isset($_REQUEST["itemId"]) or !$_REQUEST["itemId"]) and !isset($_REQUEST["offset"])) {
    $smarty->assign('msg', tra("No item indicated"));
    $smarty->display("error.tpl");
    die;
}
if ($prefs['feature_groupalert'] == 'y') {
    $groupforalert = $groupalertlib->GetGroup('tracker', $_REQUEST['trackerId']);
    if ($groupforalert != "") {
        $showeachuser = $groupalertlib->GetShowEachUser('tracker', $_REQUEST['trackerId'], $groupforalert);
        $listusertoalert = $userlib->get_users(0, -1, 'login_asc', '', '', false, $groupforalert, '');
        $smarty->assign_by_ref('listusertoalert', $listusertoalert['data']);
コード例 #10
0
 function replace_file($id, $name, $description, $filename, $data, $size, $type, $creator, $path, $comment = '', $gal_info, $didFileReplace, $author = '', $created = '', $lockedby = NULL, $deleteAfter = NULL)
 {
     global $prefs, $user;
     if (!$this->is_filename_valid($filename)) {
         return false;
     }
     $this->transformImage($path, $data, $size, $gal_info, $type);
     $filesTable = $this->table('tiki_files');
     $fileDraftsTable = $this->table('tiki_file_drafts');
     $galleriesTable = $this->table('tiki_file_galleries');
     $initialFileId = $id;
     // Update the fields in the database
     $name = trim(strip_tags($name));
     $description = strip_tags($description);
     // User avatar full images are always using db and not file location (at the curent state of feature)
     if (isset($prefs['user_store_file_gallery_picture']) && $prefs['user_store_file_gallery_picture'] == 'y' && $prefs["user_picture_gallery_id"] == $gal_info['galleryId']) {
         $userPictureGallery = true;
     } else {
         $userPictureGallery = false;
     }
     $checksum = $this->get_file_checksum($gal_info['galleryId'], $path, $data);
     $search_data = '';
     if ($prefs['fgal_enable_auto_indexing'] != 'n') {
         $search_data = $this->get_search_text_for_data($data, $path, $type, $gal_info['galleryId']);
         if ($search_data === false) {
             return false;
         }
     }
     $oldPath = '';
     if ($prefs['feature_file_galleries_save_draft'] == 'y') {
         $oldPath = $fileDraftsTable->fetchOne('path', array('fileId' => $id, 'user' => $user));
     } else {
         $oldPath = $filesTable->fetchOne('path', array('fileId' => $id));
     }
     if ($gal_info['archives'] == -1 || !$didFileReplace) {
         // no archive
         if ($prefs['feature_file_galleries_save_draft'] == 'y') {
             $result = $filesTable->update(array('name' => $name, 'description' => $description, 'lastModifUser' => $user, 'lastModif' => $this->now, 'author' => $author, 'user' => $creator), array('fileId' => $id));
             if (!$result) {
                 return false;
             }
             if ($didFileReplace) {
                 if (!$this->insert_draft($id, $filename, $size, $type, $data, $user, $path, $checksum, $lockedby)) {
                     return false;
                 }
             }
         } else {
             $result = $filesTable->update(array('name' => $name, 'description' => $description, 'filename' => $filename, 'filesize' => $size, 'filetype' => $type, 'data' => $data, 'lastModifUser' => $user, 'lastModif' => $this->now, 'path' => $path, 'hash' => $checksum, 'search_data' => $search_data, 'author' => $author, 'user' => $creator, 'lockedby' => $lockedby, 'deleteAfter' => $deleteAfter), array('fileId' => $id));
             if (!$result) {
                 return false;
             }
         }
         if ($didFileReplace && !empty($oldPath)) {
             $savedir = $this->get_gallery_save_dir($gal_info['galleryId'], $gal_info);
             unlink($savedir . $oldPath);
         }
         TikiLib::events()->trigger('tiki.file.update', array('type' => 'file', 'object' => $id, 'galleryId' => $gal_info['galleryId'], 'initialFileId' => $initialFileId, 'filetype' => $type));
     } else {
         //archive the old file : change archive_id, take away from indexation and categorization
         if ($prefs['feature_file_galleries_save_draft'] == 'y') {
             $this->insert_draft($id, $filename, $size, $type, $data, $user, $path, $checksum, $lockedby);
         } else {
             $id = $this->save_archive($id, $gal_info['galleryId'], $gal_info['archives'], $name, $description, $filename, $data, $size, $type, $creator, $path, $comment, $author, $created, $lockedby);
         }
     }
     if ($gal_info['galleryId']) {
         $galleriesTable->update(array('lastModif' => $this->now), array('galleryId' => $gal_info['galleryId']));
     }
     return $id;
 }
コード例 #11
0
ファイル: avatarlib.php プロジェクト: rjsmelo/tiki
 /**
  * sets the avatar from a given image file's URL
  *
  * @return string	URL for the current page
  */
 function set_avatar_from_url($url, $userwatch = "", $name = "")
 {
     global $user, $prefs;
     $access = TikiLib::lib('access');
     $access->check_feature('feature_userPreferences');
     $access->check_user($user);
     $userprefslib = TikiLib::lib('userprefs');
     $imagegallib = TikiLib::lib('imagegal');
     if (empty($userwatch)) {
         $userwatch = $user;
     }
     $data = file_get_contents($url);
     list($iwidth, $iheight, $itype, $iattr) = getimagesize($url);
     $itype = image_type_to_mime_type($itype);
     // Get proper file size of image
     $imgdata = get_headers($url, true);
     if (isset($imgdata['Content-Length'])) {
         # Return file size
         $size = (int) $imgdata['Content-Length'];
     }
     // Store full-size file gallery image if that is required
     if ($prefs["user_store_file_gallery_picture"] == 'y') {
         $fgImageId = $userprefslib->set_file_gallery_image($userwatch, $name, $size, $itype, $data);
     }
     // Store small avatar
     if ($prefs['user_small_avatar_size']) {
         $avsize = $prefs['user_small_avatar_size'];
     } else {
         $avsize = "45";
         //default
     }
     if (($iwidth == $avsize and $iheight <= $avsize) || ($iwidth <= $avsize and $iheight == $avsize)) {
         $userprefslib->set_user_avatar($userwatch, 'u', '', $name, $size, $itype, $data);
     } else {
         if (function_exists("ImageCreateFromString") && !strstr($type, "gif")) {
             $img = imagecreatefromstring($data);
             $size_x = imagesx($img);
             $size_y = imagesy($img);
             /* if the square crop is set, crop the image before resizing */
             if ($prefs['user_small_avatar_square_crop']) {
                 $crop_size = min($size_x, $size_y);
                 $offset_x = ($size_x - $crop_size) / 2;
                 $offset_y = ($size_y - $crop_size) / 2;
                 $crop_array = array('x' => $offset_x, 'y' => $offset_y, 'width' => $crop_size, 'height' => $crop_size);
                 $img = imagecrop($img, $crop_array);
                 $size_x = $size_y = $crop_size;
             }
             if ($size_x > $size_y) {
                 $tscale = (int) $size_x / $avsize;
             } else {
                 $tscale = (int) $size_y / $avsize;
             }
             $tw = (int) ($size_x / $tscale);
             $ty = (int) ($size_y / $tscale);
             if ($tw > $size_x) {
                 $tw = $size_x;
             }
             if ($ty > $size_y) {
                 $ty = $size_y;
             }
             if (chkgd2()) {
                 $t = imagecreatetruecolor($tw, $ty);
                 imagecopyresampled($t, $img, 0, 0, 0, 0, $tw, $ty, $size_x, $size_y);
             } else {
                 $t = imagecreate($tw, $ty);
                 $imagegallib->ImageCopyResampleBicubic($t, $img, 0, 0, 0, 0, $tw, $ty, $size_x, $size_y);
             }
             // CHECK IF THIS TEMP IS WRITEABLE OR CHANGE THE PATH TO A WRITEABLE DIRECTORY
             $tmpfname = tempnam($prefs['tmpDir'], "TMPIMG");
             imagejpeg($t, $tmpfname);
             // Now read the information
             $fp = fopen($tmpfname, "rb");
             $t_data = fread($fp, filesize($tmpfname));
             fclose($fp);
             unlink($tmpfname);
             $t_type = 'image/jpeg';
             $userprefslib->set_user_avatar($userwatch, 'u', '', $name, $size, $t_type, $t_data);
         } else {
             $userprefslib->set_user_avatar($userwatch, 'u', '', $name, $size, $type, $data);
         }
     }
     TikiLib::events()->trigger('tiki.user.avatar', array('type' => 'user', 'object' => $userwatch, 'user' => $userwatch));
 }
コード例 #12
0
ファイル: include_community.php プロジェクト: linuxwhy/tiki-1
<?php

// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
// This script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
    header('location: index.php');
    exit;
}
if (isset($_REQUEST['userfeatures'])) {
    check_ticket('admin-inc-community');
}
$smarty->assign('event_graph', TikiLib::events()->getEventGraph());
$command_parts = [realpath(__DIR__ . '/../console.php'), 'notification:digest', $url_host, 7];
if ($url_port) {
    $command_parts[] = '--port=' . $url_port;
}
if ($tikiroot != '/') {
    $command_parts[] = '--path=' . $tikiroot;
}
if ($url_scheme == 'https') {
    $command_parts[] = '--ssl';
}
$command = implode(' ', $command_parts);
$smarty->assign('monitor_command', $command);
ask_ticket('admin-inc-community');
コード例 #13
0
ファイル: searchlib-unified.php プロジェクト: ameoba32/tiki
 private function getElasticConnection($useMasterOnly)
 {
     global $prefs;
     static $connections = [];
     $target = $prefs['unified_elastic_url'];
     if (!$useMasterOnly && $prefs['federated_elastic_url']) {
         $target = $prefs['federated_elastic_url'];
     }
     if (!empty($connections[$target])) {
         return $connections[$target];
     }
     $connection = new Search_Elastic_Connection($target);
     $connection->startBulk();
     $connection->persistDirty(TikiLib::events());
     $connections[$target] = $connection;
     return $connection;
 }
コード例 #14
0
ファイル: filegallib.php プロジェクト: rjsmelo/tiki
 function add_file_hit($id)
 {
     global $prefs, $user;
     $files = $this->table('tiki_files');
     if (StatsLib::is_stats_hit()) {
         // Enforce max download per file
         if ($prefs['fgal_limit_hits_per_file'] == 'y') {
             $limit = $this->get_download_limit($id);
             if ($limit > 0) {
                 $count = $files->fetchCount(array('fileId' => $id, 'hits' => $files->lesserThan($limit)));
                 if (!$count) {
                     return false;
                 }
             }
         }
         $files->update(array('hits' => $files->increment(1), 'lastDownload' => $this->now), array('fileId' => (int) $id));
     } else {
         $files->update(array('lastDownload' => $this->now), array('fileId' => (int) $id));
     }
     if ($prefs['feature_score'] == 'y' && $prefs['fgal_prevent_negative_score'] == 'y') {
         $score = TikiLib::lib('score')->get_user_score($user);
         if ($score < 0) {
             return false;
         }
     }
     $owner = $files->fetchOne('user', array('fileId' => (int) $id));
     TikiLib::events()->trigger('tiki.file.download', array('type' => 'file', 'object' => $id, 'user' => $user, 'owner' => $owner));
     return true;
 }
コード例 #15
0
ファイル: messu-compose.php プロジェクト: rjsmelo/tiki
     //////////////////////////////////////////////////////////////////////////////////
     // hollmeer: send with gpg-armor block etc included				//
     // A changed encryption-related version was copied from lib/messu/messulib.pgp  //
     // into lib/openpgp/openpgplib.php for prepending/appending content into	//
     // message body									//
     if ($prefs['openpgp_gpg_pgpmimemail'] == 'y') {
         // USE PGP/MIME MAIL VERSION
         $result = $openpgplib->post_message_with_pgparmor_attachment($a_user, $user, $_REQUEST['to'], $_REQUEST['cc'], $_REQUEST['subject'], $_REQUEST['body'], $prepend_email_body, $user_armor, $_REQUEST['priority'], $_REQUEST['replyto_hash'], isset($_REQUEST['replytome']) ? 'y' : '', isset($_REQUEST['bccme']) ? 'y' : '');
     } else {
         // USE ORIGINAL TIKI MAIL VERSION
         $result = $messulib->post_message($a_user, $user, $_REQUEST['to'], $_REQUEST['cc'], $_REQUEST['subject'], $_REQUEST['body'], $_REQUEST['priority'], $_REQUEST['replyto_hash'], isset($_REQUEST['replytome']) ? 'y' : '', isset($_REQUEST['bccme']) ? 'y' : '');
     }
     // 										//
     //////////////////////////////////////////////////////////////////////////////////
     if ($result) {
         TikiLib::events()->trigger('tiki.user.message', array('type' => 'user', 'object' => $a_user, 'user' => $user));
         // if this is a reply flag the original messages replied to
         if ($_REQUEST['replyto_hash'] != '') {
             $messulib->mark_replied($a_user, $_REQUEST['replyto_hash']);
         }
     } else {
         $message = tra('An error occurred, please check your mail settings and try again');
     }
 }
 // Insert a copy of the message in the sent box of the sender
 $messulib->save_sent_message($user, $user, $_REQUEST['to'], $_REQUEST['cc'], $_REQUEST['subject'], $_REQUEST['body'], $_REQUEST['priority'], $_REQUEST['replyto_hash']);
 $smarty->assign('message', $message);
 if ($prefs['feature_actionlog'] == 'y') {
     if (isset($_REQUEST['reply']) && $_REQUEST['reply'] == 'y') {
         $logslib->add_action('Replied', '', 'message', 'add=' . $tikilib->strlen_quoted($_REQUEST['body']));
     } else {
コード例 #16
0
    } else {
        $tikilib->set_user_preference($userwatch, 'mytiki_items', 'n');
    }
    if (isset($_REQUEST['mytiki_articles']) && $_REQUEST['mytiki_articles'] == 'on') {
        $tikilib->set_user_preference($userwatch, 'mytiki_articles', 'y');
    } else {
        $tikilib->set_user_preference($userwatch, 'mytiki_articles', 'n');
    }
    if (isset($_REQUEST['tasks_maxRecords'])) {
        $tikilib->set_user_preference($userwatch, 'tasks_maxRecords', $_REQUEST['tasks_maxRecords']);
    }
    if ($prefs['feature_intertiki'] == 'y' && !empty($prefs['feature_intertiki_mymaster']) && $prefs['feature_intertiki_import_preferences'] == 'y') {
        //send to the master
        $userlib->interSendUserInfo($prefs['interlist'][$prefs['feature_intertiki_mymaster']], $userwatch);
    }
    TikiLib::events()->trigger('tiki.user.update', array('type' => 'user', 'object' => $userwatch, 'user' => $GLOBALS['user']));
}
if ($prefs['auth_method'] == 'ldap' && $user == 'admin' && $prefs['ldap_skip_admin'] == 'y') {
    $change_password = '******';
    $smarty->assign('change_password', $change_password);
}
if (isset($_REQUEST['chgadmin'])) {
    check_ticket('user-prefs');
    if (isset($_REQUEST['pass'])) {
        $pass = $_REQUEST['pass'];
    } else {
        $pass = '';
    }
    // check user's password, admin doesn't need it to change other user's info
    if ($tiki_p_admin != 'y' || $user == $userwatch) {
        if ($prefs['feature_intertiki'] == 'y' && !empty($prefs['feature_intertiki_mymaster'])) {
コード例 #17
0
ファイル: relationlib.php プロジェクト: rjsmelo/tiki
 /**
  * @param $id
  */
 function remove_relation($id)
 {
     $relation_info = $this->get_relation($id);
     $this->table->delete(array('relationId' => $id));
     $this->table('tiki_object_attributes')->deleteMultiple(array('type' => 'relation', 'itemId' => $id));
     TikiLib::events()->trigger('tiki.social.relation.remove', array('relation' => $relation_info['relation'], 'sourcetype' => $relation_info['source_type'], 'sourceobject' => $relation_info['source_itemId'], 'type' => $relation_info['target_type'], 'object' => $relation_info['target_itemId'], 'user' => $GLOBALS['user']));
     TikiLib::lib('tiki')->refresh_index($relation_info['source_type'], $relation_info['source_itemId']);
     TikiLib::lib('tiki')->refresh_index($relation_info['target_type'], $relation_info['target_itemId']);
 }
コード例 #18
0
ファイル: tiki-login.php プロジェクト: rjsmelo/tiki
            $error = tra("There is more than one user account with this email. Please contact the administrator.");
            break;
        default:
            $error = tra('Invalid username or password');
    }
    if (isset($extraButton)) {
        $smarty->assign_by_ref('extraButton', $extraButton);
    }
    //	Report error "inline" with the login module
    $smarty->assign('error_login', $error);
    $smarty->assign('mid', 'tiki-login.tpl');
    $smarty->display('tiki.tpl');
    exit;
}
if (isset($user)) {
    TikiLib::events()->trigger('tiki.user.login', array('type' => 'user', 'object' => $user, 'user' => $user));
}
// RFC 2616 defines that the 'Location' HTTP headerconsists of an absolute URI
if (!preg_match('/^https?\\:/i', $url)) {
    $url = (preg_match('/^\\//', $url) ? $url_scheme . '://' . $url_host . ($url_port != '' ? ":{$url_port}" : '') : $base_url) . $url;
}
// Force HTTP mode if needed
if ($stay_in_ssl_mode != 'y' || !$https_mode) {
    $url = str_replace('https://', 'http://', $url);
}
// Force Redirection to HTTPS mode of original URL if needed
if ($stay_in_ssl_mode == 'y' && $https_mode) {
    $url = str_replace('http://', 'https://', $url);
}
if (defined('SID') && SID != '') {
    $url .= (strpos($url, '?') === false ? '?' : '&') . SID;
コード例 #19
0
ファイル: userslib.php プロジェクト: hurcane/tiki-azure
 function reset_email_due($user)
 {
     $query = 'update `users_users` set `email_confirm`=?, `waiting`=? where `login`=?';
     $this->query($query, array(0, 'u', $user));
     TikiLib::events()->trigger('tiki.user.update', array('type' => 'user', 'object' => $user));
 }
コード例 #20
0
        if (empty($_REQUEST['subject']) && empty($_REQUEST['body'])) {
            $smarty->assign('message', tra('ERROR: Either the subject or body must be non-empty'));
            $smarty->display("tiki.tpl");
            die;
        }
        $sent = $messulib->post_message($userwatch, $user, $_REQUEST['to'], '', $_REQUEST['subject'], $_REQUEST['body'], $_REQUEST['priority'], '', isset($_REQUEST['replytome']) ? 'y' : '', isset($_REQUEST['bccme']) ? 'y' : '');
        if ($sent) {
            $message = tra('Message sent to') . ':' . $userlib->clean_user($userwatch) . '<br />';
        } else {
            $message = tra('An error occurred, please check your mail settings and try again');
        }
        $smarty->assign('message', $message);
    }
}
if (isset($user) and $user != $userwatch) {
    TikiLib::events()->trigger('tiki.user.view', array('type' => 'user', 'object' => $userwatch, 'user' => $user));
}
$smarty->assign('priority', 3);
if ($prefs['allowmsg_is_optional'] == 'y') {
    $allowMsgs = $tikilib->get_user_preference($userwatch, 'allowMsgs', 'y');
} else {
    $allowMsgs = 'y';
}
$smarty->assign('allowMsgs', $allowMsgs);
$smarty->assign_by_ref('user_prefs', $user_preferences[$userwatch]);
$user_style = $tikilib->get_user_preference($userwatch, 'theme', $prefs['site_style']);
$smarty->assign_by_ref('user_style', $user_style);
$user_language = $tikilib->get_language($userwatch);
$langLib = TikiLib::lib('language');
$user_language_text = $langLib->format_language_list(array($user_language));
$smarty->assign_by_ref('user_language', $user_language_text[0]['name']);
コード例 #21
0
ファイル: userslib.php プロジェクト: railfuture/tiki-website
	function change_user_password($user, $pass, $pass_first_login=false)
	{
		global $prefs;

		$hash = $this->hash_pass($pass);
		$new_pass_confirm = $this->now;
		$provpass = $pass;

		if ($prefs['feature_clear_passwords'] == 'n') {
			$pass = '';
		}

		if ($pass_first_login) {
			if (!empty($provpass)) {
				$query = 'update `users_users` set `hash`=? ,`password`=? ,`pass_confirm`=?, `provpass`=?, `pass_confirm`=? where binary `login`=?';
				$this->query($query, array($hash, $pass, $new_pass_confirm, $provpass, 0, $user));
			} else {
				$query = 'update `users_users` set `pass_confirm`=? where binary `login`=?';
				$this->query($query, array(0, $user));
			}
		} else {
			$query = 'update `users_users` set `hash`=? ,`password`=? ,`pass_confirm`=?, `provpass`=? where binary `login`=?';
			$this->query($query, array($hash, $pass, $new_pass_confirm, '',	$user));
		}
		// invalidate the cache so that after a fresh install, the admin (who has no user details at the install) can log in
		global $cachelib; require_once('lib/cache/cachelib.php');
		$cachelib->invalidate('user_details_'.$user);

		TikiLib::events()->trigger('tiki.user.update', array('user' => $user));

		return true;
	}
コード例 #22
0
function wikiplugin_trackerlist($data, $params)
{
    global $tiki_p_admin_trackers, $prefs, $tiki_p_view_trackers, $user, $page, $tiki_p_tracker_vote_ratings, $tiki_p_tracker_view_ratings, $tiki_p_export_tracker, $tiki_p_watch_trackers, $tiki_p_edit;
    $userlib = TikiLib::lib('user');
    $tikilib = TikiLib::lib('tiki');
    $trklib = TikiLib::lib('trk');
    $smarty = TikiLib::lib('smarty');
    $notificationlib = TikiLib::lib('notification');
    static $iTRACKERLIST = 0;
    ++$iTRACKERLIST;
    $smarty->assign('iTRACKERLIST', $iTRACKERLIST);
    $default = array('calendarfielddate' => '', 'wiki' => '', 'calendarviewmode' => 'month', 'calendarstickypopup' => 'n', 'calendarbeginmonth' => 'y', 'calendarviewnavbar' => 'y', 'calendartitle' => '', 'calendardelta' => '', 'force_compile' => 'n', 'editable' => array(), 'editableall' => 'n');
    $params = array_merge($default, $params);
    extract($params, EXTR_SKIP);
    $skip_status_perm_check = false;
    if (isset($force_separate_compile) && $force_separate_compile == 'y') {
        $smarty->assign('force_separate_compile', 'y');
    }
    if ($prefs['feature_trackers'] != 'y' || !isset($trackerId) || !($tracker_info = $trklib->get_tracker($trackerId))) {
        return $smarty->fetch("wiki-plugins/error_tracker.tpl");
    } else {
        global $auto_query_args;
        $auto_query_args_local = array('trackerId', 'tr_initial', "tr_sort_mode{$iTRACKERLIST}", 'tr_user', 'filterfield', 'filtervalue', 'exactvalue', 'itemId', "tr_offset{$iTRACKERLIST}");
        $auto_query_args = empty($auto_query_args) ? $auto_query_args_local : array_merge($auto_query_args, $auto_query_args_local);
        $smarty->assign('listTrackerId', $trackerId);
        $definition = Tracker_Definition::get($trackerId);
        $tracker_info = $definition->getInformation();
        if (!isset($sort)) {
            $sort = 'n';
        }
        $perms = $tikilib->get_perm_object($trackerId, 'tracker', $tracker_info, false);
        if ($perms['tiki_p_view_trackers'] != 'y' && !$user) {
            return;
        }
        $userCreatorFieldId = $definition->getAuthorField();
        $groupCreatorFieldId = $definition->getWriterGroupField();
        if ($perms['tiki_p_view_trackers'] != 'y' && !$definition->isEnabled('writerCanModify') && !$definition->isEnabled('userCanSeeOwn') && empty($userCreatorFieldId) && empty($groupCreatorFieldId)) {
            return;
        }
        $smarty->assign_by_ref('perms', $perms);
        if (!empty($fields)) {
            $limit = $fields;
        } else {
            $limit = '';
        }
        // Make sure limit is an array
        if (!is_array($limit) && !empty($limit)) {
            $limit = explode(':', $limit);
        }
        if (!empty($filterfield) && !empty($limit)) {
            $limit = array_unique(array_merge($limit, $filterfield));
        }
        // for some reason if param popup is set but empty, the array contains 2 empty elements. We filter them out.
        if (isset($popup)) {
            $popup = array_filter($popup);
            if (!empty($popup)) {
                $limit = array_unique(array_merge($limit, $popup));
            }
        }
        if (!empty($calendarfielddate)) {
            $limit = array_unique(array_merge($limit, $calendarfielddate));
        }
        if (!empty($limit) && $trklib->test_field_type($limit, array('C'))) {
            $limit = array();
        }
        $allfields = $trklib->list_tracker_fields($trackerId, 0, -1, 'position_asc', '', true, '', $trklib->flaten($limit));
        if (!empty($fields)) {
            $listfields = $fields;
            //We must include the $calendarfielddate, even if they are not in the listfields
            if (!empty($calendarfielddate)) {
                foreach ($calendarfielddate as $f) {
                    if (!in_array($f, $listfields)) {
                        $listfields[] = $f;
                    }
                }
            }
            if ($sort == 'y') {
                $allfields = $trklib->sort_fields($allfields, $listfields);
            }
        } elseif (!empty($wiki) || !empty($tpl) || !empty($tplwiki)) {
            if (!empty($wiki)) {
                $listfields = $trklib->get_pretty_fieldIds($wiki, 'wiki', $prettyModifier, $trackerId);
            } elseif (!empty($tplwiki)) {
                $listfields = $trklib->get_pretty_fieldIds($tplwiki, 'wiki', $prettyModifier, $trackerId);
            } else {
                $listfields = $trklib->get_pretty_fieldIds($tpl, 'tpl', $prettyModifier, $trackerId);
            }
        } else {
            $listfields = '';
        }
        if (!empty($compute) && !empty($listfields)) {
            if (preg_match_all('/[0-9.]+/', $compute, $matches)) {
                foreach ($matches[0] as $f) {
                    if (!in_array($f, $listfields)) {
                        $listfields[] = $f;
                    }
                }
            }
        }
        /*** tablesorter ***/
        //note whether ajax is needed
        $tsServer = isset($params['server']) && $params['server'] === 'y' ? true : false;
        $tsOn = isset($sortable) && $sortable !== 'n' && Table_Check::isEnabled($tsServer);
        $smarty->assign('tsOn', $tsOn);
        //note whether this is the initial tablesorter ajax call or a subsequent ajax call
        $tsAjax = Table_Check::isAjaxCall();
        $smarty->assign('tsAjax', $tsAjax);
        if ($tsAjax) {
            // if status is enabled, need to adjust field index by -1 - need to check both - tracker config and plugin config
            $adjustCol = isset($showstatus) && $showstatus == 'y' && $definition->isEnabled('showStatus') ? -1 : 0;
            //convert tablesorter filter syntax to tiki syntax
            if (!empty($_REQUEST['filter'])) {
                $i = 0;
                $tsfiltersArray = explode('|', $tsfilters);
                foreach ($_REQUEST['filter'] as $col => $ajaxfilter) {
                    $fieldtype = $allfields['data'][$col + $adjustCol]['type'];
                    $id = $allfields['data'][$col + $adjustCol]['fieldId'];
                    //handle status filter
                    if ($adjustCol === -1 && $col === 0 && in_array($ajaxfilter, ['o', 'p', 'c'])) {
                        $status = $ajaxfilter;
                        /*
                         * handle date filter - these are always one filter, in the form of:
                         * from: >=1427389832000; to: <=1427389832000; both from and to: 1427389832000 - 1427880000000
                         * which is unix timestamp in milliseconds
                         */
                    } elseif (strpos($tsfiltersArray[$col], 'type:date') !== false && in_array($fieldtype, ['f', 'j'])) {
                        $datefilter = explode(' - ', $ajaxfilter);
                        $filterfield[$i] = $id;
                        //a range (from and to filters) will have 2 items in the array
                        if (count($datefilter) == 2) {
                            $filterfield[$i + 1] = $id;
                            //use substr to leave off milliseconds since date is stored in seconds in the database
                            $exactvalue[$i] = 'greaterequal(@' . substr($datefilter[0], 0, 10) . ')';
                            $exactvalue[$i + 1] = 'lessequal(@' . substr($datefilter[1], 0, 10) . ')';
                        } else {
                            //use substr to leave off milliseconds since date is stored in seconds in the database
                            $stamp = '(@' . substr($datefilter[0], 2, 10) . ')';
                            $symbol = substr($datefilter[0], 0, 2);
                            if ($symbol === '<=') {
                                $compare = 'lessequal';
                            } elseif ($symbol === '>=') {
                                $compare = 'greaterequal';
                            }
                            $exactvalue[$i] = $compare . $stamp;
                        }
                    } else {
                        $filterfield[$i] = $id;
                        //convert category filters entered as text
                        if ($fieldtype === 'e' && !is_numeric($ajaxfilter)) {
                            $categlib = TikiLib::lib('categ');
                            $ajaxfilter = $categlib->get_category_id($ajaxfilter);
                        }
                        $filtervalue[$i] = $ajaxfilter;
                    }
                    $i++;
                }
            }
            //convert tablesorter sort syntax to tiki syntax
            if (!empty($_REQUEST['sort'])) {
                foreach ($_REQUEST['sort'] as $sortcol => $ajaxsort) {
                    if ($ajaxsort == '0') {
                        $dir = '_asc';
                    } elseif ($ajaxsort == '1') {
                        $dir = '_desc';
                    }
                    //avoid setting sort_mode based on status field - will return error. Handle later once records are retrieved
                    if ($adjustCol !== -1 || $sortcol !== 0) {
                        $sort_mode = 'f_' . $allfields['data'][$sortcol + $adjustCol]['fieldId'] . $dir;
                    }
                }
            }
            //set max records
            if (isset($_REQUEST['numrows'])) {
                $max = $_REQUEST['numrows'];
            }
        }
        /*** end first tablesorter section ***/
        if (!empty($filterfield)) {
            if (is_array($filterfield)) {
                foreach ($filterfield as $ff) {
                    unset($filterfieldok);
                    if (is_array($ff)) {
                        // already checked in trackerfilter
                        $filterfieldok = true;
                        break;
                    } else {
                        foreach ($allfields['data'] as $f) {
                            if ($f['fieldId'] == $ff) {
                                $filterfieldok = true;
                                break;
                            }
                        }
                    }
                    if (!isset($filterfieldok)) {
                        break;
                    }
                }
            } else {
                foreach ($allfields['data'] as $f) {
                    if ($f['fieldId'] == $filterfield) {
                        $filterfieldok = true;
                        break;
                    }
                }
            }
            if (!isset($filterfieldok)) {
                return tra('incorrect filterfield');
            }
        }
        $filter = array();
        if (isset($periodQuantity)) {
            switch ($periodUnit) {
                case 'hour':
                    $periodUnit = 3600;
                    break;
                case 'day':
                    $periodUnit = 86400;
                    break;
                case 'week':
                    $periodUnit = 604800;
                    break;
                case 'month':
                    $periodUnit = 2628000;
                    break;
                default:
                    break;
            }
            if (!isset($periodType)) {
                $periodType = 'c';
            }
            if (is_int($periodUnit) && $periodType == 'm') {
                $filter['lastModifAfter'] = $tikilib->now - $periodQuantity * $periodUnit;
                $filter['lastModifBefore'] = $tikilib->now;
            } elseif (is_int($periodUnit)) {
                # case for periodType beig c or anything else (therefore, set as case for default)
                $filter['createdAfter'] = $tikilib->now - $periodQuantity * $periodUnit;
                $filter['createdBefore'] = $tikilib->now;
            }
        }
        if (isset($_REQUEST['reloff']) && empty($_REQUEST['itemId']) && !empty($_REQUEST['trackerId'])) {
            //coming from a pagination
            $items = $trklib->list_items($_REQUEST['trackerId'], $_REQUEST['reloff'], 1, '', '', isset($_REQUEST['filterfield']) ? preg_split('/\\s*:\\s*/', $_REQUEST['filterfield']) : '', isset($_REQUEST['filtervalue']) ? preg_split('/\\s*:\\s*/', $_REQUEST['filtervalue']) : '', isset($_REQUEST['status']) ? preg_split('/\\s*:\\s*/', $_REQUEST['status']) : '', isset($_REQUEST['initial']) ? $_REQUEST['initial'] : '', isset($_REQUEST['exactvalue']) ? preg_split('/\\s*:\\s*/', $_REQUEST['exactvalue']) : '', $filter);
            if (isset($items['data'][0]['itemId'])) {
                $_REQUEST['cant'] = $items['cant'];
                $_REQUEST['itemId'] = $items['data'][0]['itemId'];
            }
        }
        if (!empty($_REQUEST['itemId']) && $tiki_p_tracker_vote_ratings == 'y' && $user) {
            $hasVoted = false;
            foreach ($allfields['data'] as $f) {
                if ($f['type'] == 's' && $definition->isEnabled('useRatings') && ($f['name'] == 'Rating' || ($f['name'] = tra('Rating')))) {
                    $i = $f['fieldId'];
                    if (isset($_REQUEST["ins_{$i}"]) && ($_REQUEST["ins_{$i}"] == 'NULL' || in_array($_REQUEST["ins_{$i}"], explode(',', $tracker_info['ratingOptions'])))) {
                        $trklib->replace_rating($trackerId, $_REQUEST['itemId'], $i, $user, $_REQUEST["ins_{$i}"]);
                        $hasVoted = true;
                    }
                } elseif ($f['type'] == '*' || $f['type'] == 'STARS') {
                    $i = $f['fieldId'];
                    if (isset($_REQUEST["ins_{$i}"])) {
                        $trklib->replace_star($_REQUEST["ins_{$i}"], $trackerId, $_REQUEST['itemId'], $f, $user);
                        $hasVoted = true;
                    }
                }
            }
            if ($hasVoted) {
                // Must strip NULL for remove my vote case
                $url = preg_replace('/[(\\?)|&]vote=y/', '$1', preg_replace('/[(\\?)|&]ins_[0-9]+=-?[0-9|N|U|L]*/', '$1', $_SERVER['REQUEST_URI']));
                // reduce duplicate itemIds in query string
                $occurences = preg_match_all('/[(\\?)|&]itemId=[0-9]+/', $url, $matches);
                if ($params['list_mode'] == 'y' && $occurences > 0) {
                    $url = preg_replace('/[(\\?)|&]itemId=[0-9]+/', '$1', $url, $occurences);
                } elseif ($occurences > 1) {
                    $url = preg_replace('/&itemId=[0-9]+/', '', $url, $occurences - 1);
                }
                header("Location: {$url}");
                die;
            }
        }
        if (!empty($showwatch) && $showwatch == 'y' && $prefs['feature_user_watches'] == 'y' && $tiki_p_watch_trackers == 'y' && !empty($user)) {
            if (isset($_REQUEST['watch']) && isset($_REQUEST['trackerId']) && $_REQUEST['trackerId'] == $trackerId) {
                if ($_REQUEST['watch'] == 'add') {
                    $tikilib->add_user_watch($user, 'tracker_modified', $trackerId, 'tracker', $tracker_info['name'], "tiki-view_tracker.php?trackerId=" . $trackerId);
                } elseif ($_REQUEST['watch'] == 'stop') {
                    $tikilib->remove_user_watch($user, 'tracker_modified', $trackerId, 'tracker');
                }
            }
            if ($tikilib->user_watches($user, 'tracker_modified', $trackerId, 'tracker')) {
                $smarty->assign('user_watching_tracker', 'y');
            } else {
                $smarty->assign('user_watching_tracker', 'n');
            }
        } else {
            $smarty->clear_assign('user_watching_tracker');
        }
        if (empty($showrss) || $showrss == 'n') {
            $smarty->assign('showrss', 'n');
        } else {
            $smarty->assign('showrss', 'y');
        }
        if (empty($listfields)) {
            foreach ($allfields['data'] as $f) {
                $listfields[] = $f['fieldId'];
            }
        }
        if (!empty($popup)) {
            $popupfields = $popup;
        } else {
            $popupfields = array();
        }
        $smarty->assign_by_ref('tracker_info', $tracker_info);
        //$query_array = array();
        //$quarray = array();
        //TikiLib::parse_str($_SERVER['QUERY_STRING'],$query_array);
        if (isset($stickypopup) && $stickypopup == 'y') {
            $stickypopup = true;
        } else {
            $stickypopup = false;
        }
        $smarty->assign_by_ref('stickypopup', $stickypopup);
        if (!isset($showtitle)) {
            $showtitle = 'n';
        }
        $smarty->assign_by_ref('showtitle', $showtitle);
        if (!isset($showlinks)) {
            $showlinks = 'n';
        }
        $smarty->assign_by_ref('showlinks', $showlinks);
        if (!isset($showdesc)) {
            $showdesc = 'n';
        }
        $smarty->assign_by_ref('showdesc', $showdesc);
        if (!isset($showinitials)) {
            $showinitials = 'n';
        }
        $smarty->assign_by_ref('showinitials', $showinitials);
        if (!isset($shownbitems)) {
            $shownbitems = 'n';
        }
        $smarty->assign_by_ref('shownbitems', $shownbitems);
        if (!isset($showstatus)) {
            $showstatus = 'n';
        }
        $smarty->assign_by_ref('showstatus', $showstatus);
        if (!isset($showfieldname)) {
            $showfieldname = 'y';
        }
        $smarty->assign_by_ref('showfieldname', $showfieldname);
        if (!isset($showitemrank)) {
            $showitemrank = 'n';
        }
        $smarty->assign_by_ref('showitemrank', $showitemrank);
        if (!isset($showdelete)) {
            $showdelete = 'n';
        }
        $smarty->assign_by_ref('showdelete', $showdelete);
        if (!isset($showpenditem)) {
            $showpenditem = 'n';
        }
        $smarty->assign_by_ref('showpenditem', $showpenditem);
        if (!isset($showcloseitem)) {
            $showcloseitem = 'n';
        }
        $smarty->assign_by_ref('showcloseitem', $showcloseitem);
        if (!isset($showopenitem)) {
            $showopenitem = 'n';
        }
        $smarty->assign_by_ref('showopenitem', $showopenitem);
        if (!isset($showpagination)) {
            $showpagination = 'y';
        }
        $smarty->assign_by_ref('showpagination', $showpagination);
        if (!isset($sortchoice)) {
            $sortchoice = '';
        } else {
            foreach ($sortchoice as $i => $sc) {
                $sc = explode('|', $sc);
                $sortchoice[$i] = array('value' => $sc[0], 'label' => empty($sc[1]) ? $sc[0] : $sc[1]);
            }
        }
        $smarty->assign_by_ref('sortchoice', $sortchoice);
        if (!isset($status)) {
            $status = 'o';
        }
        $tr_status = $status;
        $smarty->assign_by_ref('tr_status', $tr_status);
        if (!isset($list_mode)) {
            $list_mode = 'y';
        }
        $smarty->assign_by_ref('list_mode', $list_mode);
        if (!isset($showcreated)) {
            $showcreated = $tracker_info['showCreated'];
        }
        $smarty->assign_by_ref('showcreated', $showcreated);
        if (!isset($showlastmodif)) {
            $showlastmodif = $tracker_info['showLastModif'];
        }
        $smarty->assign_by_ref('showlastmodif', $showlastmodif);
        if (!isset($showlastmodifby)) {
            $showlastmodifby = $tracker_info['showLastModifBy'];
        }
        $smarty->assign_by_ref('showlastmodifby', $showlastmodifby);
        if (!isset($more)) {
            $more = 'n';
        }
        $smarty->assign_by_ref('more', $more);
        if (!isset($moreurl)) {
            $moreurl = 'tiki-view_tracker.php';
        }
        $smarty->assign_by_ref('moreurl', $moreurl);
        if (!isset($url)) {
            $url = '';
        }
        $smarty->assign_by_ref('url', $url);
        if (!isset($export)) {
            $export = 'n';
        }
        $smarty->assign_by_ref('export', $export);
        if (!empty($ldelim)) {
            $smarty->left_delimiter = $ldelim;
        }
        if (!empty($rdelim)) {
            $smarty->right_delimiter = $rdelim;
        }
        if (isset($checkbox)) {
            $check = array('ix' => -1, 'type' => 'checkbox');
            $cb = explode('/', $checkbox);
            if (isset($cb[0])) {
                $check['fieldId'] = $cb[0];
            }
            if (isset($cb[1])) {
                $check['name'] = $cb[1];
            }
            if (isset($cb[2])) {
                $check['title'] = $cb[2];
            }
            if (isset($cb[3])) {
                $check['submit'] = $cb[3];
            }
            if (isset($cb[4])) {
                $check['action'] = $cb[4];
            }
            if (isset($cb[5])) {
                $check['tpl'] = $cb[5];
            }
            if (isset($cb[6]) && $cb[6] == 'radio') {
                $check['radio'] = 'y';
                $check['type'] = 'radio';
            }
            if (isset($cb[6]) && $cb[6] == 'dropdown') {
                $check['dropdown'] = 'y';
            }
            // is this actually used?
            $smarty->assign_by_ref('checkbox', $check);
        }
        if (isset($_REQUEST["tr_sort_mode{$iTRACKERLIST}"])) {
            $sort_mode = $_REQUEST["tr_sort_mode{$iTRACKERLIST}"];
        } elseif (!isset($sort_mode)) {
            if (!empty($tracker_info['defaultOrderKey'])) {
                if ($tracker_info['defaultOrderKey'] == -1) {
                    $sort_mode = 'lastModif';
                } elseif ($tracker_info['defaultOrderKey'] == -2) {
                    $sort_mode = 'created';
                } elseif ($tracker_info['defaultOrderKey'] == -3) {
                    $sort_mode = 'itemId';
                } else {
                    $sort_mode = 'f_' . $tracker_info['defaultOrderKey'];
                }
                if (isset($tracker_info['defaultOrderDir'])) {
                    $sort_mode .= "_" . $tracker_info['defaultOrderDir'];
                } else {
                    $sort_mode .= "_asc";
                }
            } else {
                $sort_mode = '';
            }
        } elseif ($sort_mode != 'created_asc' && $sort_mode != 'lastModif_asc' && $sort_mode != 'created_desc' && $sort_mode != 'lastModif_desc' && !preg_match('/f_[0-9]+_(asc|desc)/', $sort_mode)) {
            return tra('Incorrect param') . ' sort_mode';
        }
        $tr_sort_mode = $sort_mode;
        $smarty->assign_by_ref('tr_sort_mode', $tr_sort_mode);
        if (!isset($max)) {
            $max = $prefs['maxRecords'];
        }
        if (isset($_REQUEST["tr_offset{$iTRACKERLIST}"]) && (!isset($forceoffset) || $forceoffset == 'n')) {
            $tr_offset = $_REQUEST["tr_offset{$iTRACKERLIST}"];
        } else {
            if (isset($offset) && $offset >= 0) {
                $tr_offset = $offset;
            } else {
                $tr_offset = 0;
            }
        }
        $smarty->assign_by_ref("tr_offset{$iTRACKERLIST}", $tr_offset);
        $tr_initial = '';
        if ($showinitials == 'y') {
            if (isset($_REQUEST['tr_initial'])) {
                //$query_array['tr_initial'] = $_REQUEST['tr_initial'];
                $tr_initial = $_REQUEST['tr_initial'];
            }
            $smarty->assign('initials', explode(' ', 'a b c d e f g h i j k l m n o p q r s t u v w x y z'));
        }
        $smarty->assign_by_ref('tr_initial', $tr_initial);
        if (isset($view) && $view == 'user' || isset($view_user) || isset($_REQUEST['tr_user'])) {
            if ($f = $definition->getAuthorField()) {
                $filterfield[] = $f;
                $filtervalue[] = '';
                if (!isset($_REQUEST['tr_user'])) {
                    $exactvalue[] = isset($view) ? empty($user) ? 'Anonymous' : $user : $view_user;
                } else {
                    $exactvalue[] = $_REQUEST['tr_user'];
                    $smarty->assign_by_ref('tr_user', $exactvalue);
                }
                if ($definition->isEnabled('writerCanModify') or $definition->isEnabled('userCanSeeOwn')) {
                    $skip_status_perm_check = true;
                }
            }
        }
        if (isset($view) && $view == 'page' && isset($_REQUEST['page'])) {
            if ($f = $trklib->get_page_field($trackerId)) {
                $filterfield[] = $f['fieldId'];
                $filtervalue[] = '';
                $exactvalue[] = $_REQUEST['page'];
            }
        }
        if (isset($view) && $view == 'ip') {
            if ($f = $definition->getAuthorIpField()) {
                $filterfield[] = $f;
                $filtervalue[] = '';
                $ip = $tikilib->get_ip_address();
                $exactvalue[] = $ip;
            }
        }
        if (!isset($filtervalue)) {
            $filtervalue = '';
        } else {
            foreach ($filtervalue as $i => $f) {
                if ($f == '#user') {
                    $filtervalue[$i] = $user;
                } else {
                    if ($f == '#default_group') {
                        $filtervalue[$i] = $_SESSION['u_info']['group'];
                    }
                }
            }
        }
        if (!isset($exactvalue)) {
            $exactvalue = '';
        } else {
            foreach ($exactvalue as $i => $f) {
                if ($f == '#user') {
                    $exactvalue[$i] = $user;
                }
            }
        }
        if (!empty($_REQUEST['itemId']) && (empty($ignoreRequestItemId) || $ignoreRequestItemId != 'y')) {
            $itemId = $_REQUEST['itemId'];
        }
        if (isset($itemId)) {
            if (is_string($itemId) && strstr($itemId, ':')) {
                // JB Tiki7: This doesn't quite make sense as itemId is an array
                $itemId = explode(':', $itemId);
                //			 Probably just some redundant code TOKIL
            }
            $filter['tti.`itemId`'] = $itemId;
        }
        $newItemRateField = false;
        $status_types = $trklib->status_types();
        $smarty->assign('status_types', $status_types);
        if (!isset($filterfield)) {
            $filterfield = '';
        } else {
            if (!empty($filterfield)) {
                if (!empty($filtervalue)) {
                    $fvs = $filtervalue;
                    unset($filtervalue);
                    for ($i = 0, $count_ff = count($filterfield); $i < $count_ff; ++$i) {
                        $filtervalue[] = isset($fvs[$i]) ? $fvs[$i] : '';
                    }
                }
                if (!empty($exactvalue)) {
                    $evs = $exactvalue;
                    unset($exactvalue);
                    for ($i = 0, $count_ff2 = count($filterfield); $i < $count_ff2; ++$i) {
                        if (isset($evs[$i])) {
                            if (is_array($evs[$i])) {
                                // already processed
                                $exactvalue[] = $evs[$i];
                            } elseif (preg_match('/(not)?categories\\(([0-9]+)\\)/', $evs[$i], $matches)) {
                                $categlib = TikiLib::lib('categ');
                                if (ctype_digit($matches[2]) && $matches[2] > 0) {
                                    $cfilter = array('identifier' => $matches[2], 'type' => 'descendants');
                                } else {
                                    $cfilter = NULL;
                                }
                                $categs = $categlib->getCategories($cfilter, true, false);
                                $l = array($matches[2]);
                                foreach ($categs as $cat) {
                                    $l[] = $cat['categId'];
                                }
                                if (empty($matches[1])) {
                                    $exactvalue[] = $l;
                                } else {
                                    $exactvalue[] = array('not' => $l);
                                }
                            } elseif (preg_match('/(not)?preference\\((.*)\\)/', $evs[$i], $matches)) {
                                if (empty($matches[1])) {
                                    $exactvalue[] = $prefs[$matches[2]];
                                } else {
                                    $exactvalue[] = array('not' => $prefs[$matches[2]]);
                                }
                            } elseif (preg_match('/(not)?field\\(([0-9]+)(,([0-9]+|user)(,([0-9]+))?)?\\)/', $evs[$i], $matches)) {
                                // syntax field(fieldId, user, trackerId) or field(fieldId)(need the REQUEST['itemId'] or field(fieldId, itemId) or field(fieldId, user)
                                if (empty($matches[4]) && !empty($_REQUEST['itemId'])) {
                                    // user the itemId of the url
                                    $matches[4] = $_REQUEST['itemId'];
                                }
                                if (!empty($matches[4]) && $matches[4] == 'user') {
                                    if (!empty($matches[6])) {
                                        // pick the user item of this tracker
                                        $t_i = $trklib->get_tracker($matches[6]);
                                        $matches[4] = $trklib->get_user_item($matches[6], $t_i, $user);
                                    } elseif ($prefs['userTracker'] == 'y') {
                                        //pick the generic user tracker
                                        $utid = $userlib->get_tracker_usergroup($user);
                                        $matches[4] = $trklib->get_item_id($utid['usersTrackerId'], $utid['usersFieldId'], $user);
                                    }
                                }
                                if (!empty($matches[4])) {
                                    $l = $trklib->get_item_value(0, $matches[4], $matches[2]);
                                    $field = $trklib->get_tracker_field($matches[2]);
                                    if ($field['type'] == 'r') {
                                        $refItemId = $l;
                                        $l = $trklib->get_item_value($field['options_array'][0], $refItemId, $field['options_array'][3]);
                                    }
                                }
                                if (empty($matches[1])) {
                                    $exactvalue[] = $l;
                                } else {
                                    $exactvalue[] = array('not' => $l);
                                }
                            } elseif (preg_match('/(less|greater|lessequal|greaterequal)\\((.+)\\)/', $evs[$i], $matches)) {
                                $conv = array('less' => '<', 'greater' => '>', 'lessequal' => '<=', 'greaterequal' => '>=');
                                $field = $trklib->get_tracker_field($filterfield[$i]);
                                if ($field['type'] == 'f' || $field['type'] == 'j') {
                                    if ($matches[2] == 'now') {
                                        $matches[2] = $tikilib->now;
                                    } elseif (($r = strtotime($matches[2])) !== false) {
                                        $matches[2] = $r;
                                    }
                                }
                                $exactvalue[] = array($conv[$matches[1]] => $matches[2]);
                            } elseif (preg_match('/not\\((.+)\\)/', $evs[$i], $matches)) {
                                $exactvalue[] = array('not' => $matches[1]);
                            } else {
                                $exactvalue[] = $evs[$i];
                            }
                        } else {
                            $exactvalue[] = '';
                        }
                    }
                }
            }
        }
        if ($tiki_p_admin_trackers != 'y' && $perms['tiki_p_view_trackers'] != 'y' && ($definition->isEnabled('writerCanModify') or $definition->isEnabled('userCanSeeOwn')) && $user && $userCreatorFieldId) {
            //patch this should be in list_items
            if ($filterfield != $userCreatorFieldId || is_array($filterfield) && !in_array(${$userCreatorFieldId}, $filterfield)) {
                if (is_array($filterfield)) {
                    $filterfield[] = $userCreatorFieldId;
                } elseif (empty($filterfield)) {
                    $filterfield = $userCreatorFieldId;
                } else {
                    $filterfield = array($filterfield, $fieldId);
                }
                if (is_array($exactvalue)) {
                    $exactvalue[] = $user;
                } elseif (empty($exactvalue)) {
                    $exactvalue = $user;
                } else {
                    $exactvalue = array($exactvalue, $user);
                }
            }
        }
        if ($tiki_p_admin_trackers != 'y' && $perms['tiki_p_view_trackers'] != 'y' && $user && $groupCreatorFieldId) {
            if ($filterfield != $groupCreatorFieldId || is_array($filterfield) && !in_array($groupCreatorFieldId, $filterfield)) {
                $groups = $userlib->get_user_groups($user);
                if (is_array($filterfield)) {
                    $filterfield[] = $groupCreatorFieldId;
                } elseif (empty($filterfield)) {
                    $filterfield = $groupCreatorFieldId;
                } else {
                    $filterfield = array($filterfield, $fieldId);
                }
                if (is_array($exactvalue)) {
                    $exactvalue[] = array_merge($exactvalue, $groups);
                } elseif (empty($exactvalue)) {
                    $exactvalue = $groups;
                } else {
                    $exactvalue = array_merge(array($exactvalue), $groups);
                }
                global $group;
                // awful trick - but the filter garantee that the group is ok
                $smarty->assign_by_ref('ours', $group);
                $perms = array_merge($perms, $trklib->get_special_group_tracker_perm($tracker_info));
            }
        }
        for ($i = 0, $count_allf = count($allfields['data']); $i < $count_allf; $i++) {
            if ($allfields['data'][$i]['type'] == 'C') {
                $infoComputed = $trklib->get_computed_info($allfields['data'][$i]['options_array'][0], $trackerId, $allfields['data']);
                if (!empty($infoComputed)) {
                    $allfields['data'][$i] = array_merge($infoComputed, $allfields['data'][$i]);
                }
            } elseif ($allfields["data"][$i]['type'] == 'w') {
                /* keep track of dynamic list items referring to user selectors */
                $refFieldId = $allfields["data"][$i]['options_array'][3];
                $refField = $trklib->get_tracker_field($refFieldId);
                if ($refField['type'] == 'u') {
                    $allfields["data"][$i]['type'] = $refField['type'];
                }
            }
            // If listfields is a colon separated string, convert it to an array
            if (!is_array($listfields)) {
                $listfields = explode(':', $listfields);
            }
            if ((in_array($allfields["data"][$i]['fieldId'], $listfields) or in_array($allfields["data"][$i]['fieldId'], $popupfields)) and $allfields["data"][$i]['isPublic'] == 'y') {
                $passfields["{$allfields["data"][$i]['fieldId']}"] = $allfields["data"][$i];
            }
            if (isset($check['fieldId']) && $allfields["data"][$i]['fieldId'] == $check['fieldId']) {
                $passfields["{$allfields["data"][$i]['fieldId']}"] = $allfields["data"][$i];
                if (!in_array($allfields["data"][$i]['fieldId'], $listfields)) {
                    $allfields["data"][$i]['isPublic'] == 'n';
                }
                //don't show it
                $check['ix'] = count($passfields) - 1;
            }
            if ($allfields["data"][$i]['name'] == 'page' && empty($filterfield) && empty($displayList) && !empty($view) && $view == 'page') {
                $filterfield = $allfields["data"][$i]['fieldId'];
                $filtervalue = $_REQUEST['page'];
            }
            if ($definition->isEnabled('useRatings') and $allfields["data"][$i]['type'] == 's' and $allfields["data"][$i]['name'] == 'Rating') {
                $newItemRateField = $allfields["data"][$i]['fieldId'];
            }
        }
        $nonPublicFieldsWarning = '';
        if ($tiki_p_edit === 'y') {
            foreach ($allfields['data'] as $field) {
                if ($field['isPublic'] !== 'y' && in_array($field['fieldId'], array_merge($listfields, $popupfields))) {
                    $nonPublicFieldsWarning = tra('You have attempted to view data of a tracker field which is not public. You need to ask the admin to change the setting to public for this field.');
                }
            }
        }
        if ($editableall == 'y') {
            $editable = $listfields;
        }
        $smarty->assign('nonPublicFieldsWarning', $nonPublicFieldsWarning);
        $smarty->assign_by_ref('filterfield', $filterfield);
        $smarty->assign_by_ref('filtervalue', $filtervalue);
        $smarty->assign_by_ref('fields', $passfields);
        $smarty->assign_by_ref('exactvalue', $exactvalue);
        $smarty->assign_by_ref('listfields', $listfields);
        $smarty->assign_by_ref('popupfields', $popupfields);
        $smarty->assign('editableFields', $editable);
        if (!empty($filterfield)) {
            $urlquery['filterfield'] = is_array($filtervalue) ? implode(':', $filterfield) : $filterfield;
            if (!is_array($filtervalue)) {
                $filtervalue = array($filtervalue);
            }
            $urlquery['filtervalue'] = is_array($filtervalue) ? implode(':', $filtervalue) : $filtervalue;
            $urlquery['exactvalue'] = is_array($exactvalue) ? implode(':', $exactvalue) : $exactvalue;
            $urlquery['trackerId'] = $trackerId;
            $smarty->assign('urlquery', $urlquery);
        } else {
            $smarty->assign('urlquery', '');
        }
        if (!empty($export) && $export != 'n' && $perms['tiki_p_export_tracker'] == 'y') {
            $smarty->loadPlugin('smarty_function_service');
            $exportParams = array('controller' => 'tracker', 'action' => 'export', 'trackerId' => $trackerId);
            if (!empty($fields)) {
                $exportParams['displayedFields'] = is_array($fields) ? implode(':', $fields) : $fields;
            }
            if (is_array($filterfield)) {
                foreach ($filterfield as $i => $fieldId) {
                    $exportParams["f_{$fieldId}"] = empty($filtervalue[$i]) ? $exactvalue[$i] : $filtervalue[$i];
                }
            } elseif (!empty($filterfield)) {
                $exportParams["f_{$filterfield}"] = empty($filtervalue) ? $exactvalue : $filtervalue;
            }
            $exportUrl = smarty_function_service($exportParams, $smarty);
            $smarty->assign('exportUrl', $exportUrl);
        }
        if (!empty($_REQUEST['delete'])) {
            $itemToDelete = Tracker_Item::fromId($_REQUEST['delete']);
            if ($itemToDelete->canRemove()) {
                $trklib->remove_tracker_item($_REQUEST['delete']);
            }
            if (!empty($urlafterdelete)) {
                header("Location: {$urlafterdelete}");
                exit;
            }
        }
        if (!empty($_REQUEST['closeitem'])) {
            $itemToModify = Tracker_Item::fromId($_REQUEST['closeitem']);
            if ($itemToModify->canModify()) {
                $trklib->change_status(array(array('itemId' => $_REQUEST['closeitem'])), 'c');
            }
        }
        if (!empty($_REQUEST['penditem'])) {
            $itemToModify = Tracker_Item::fromId($_REQUEST['penditem']);
            if ($itemToModify->canModify()) {
                $trklib->change_status(array(array('itemId' => $_REQUEST['penditem'])), 'p');
            }
        }
        if (!empty($_REQUEST['openitem'])) {
            $itemToModify = Tracker_Item::fromId($_REQUEST['openitem']);
            if ($itemToModify->canModify()) {
                $trklib->change_status(array(array('itemId' => $_REQUEST['openitem'])), 'o');
            }
        }
        if (!empty($calendarfielddate)) {
            $calendarlib = TikiLib::lib('calendar');
            $focusDate = empty($_REQUEST['todate']) ? $tikilib->now : $_REQUEST['todate'];
            $focus = $calendarlib->infoDate($focusDate);
            if (!empty($calendardelta)) {
                if ($calendardelta[0] == '-') {
                    $focus = $calendarlib->focusPrevious($focus, str_replace('-', '', $calendardelta));
                } else {
                    $focus = $calendarlib->focusNext($focus, str_replace('+', '', $calendardelta));
                }
            }
            $calendarlib->focusStartEnd($focus, $calendarviewmode, $calendarbeginmonth, $startPeriod, $startNextPeriod);
            $cell = $calendarlib->getTableViewCells($startPeriod, $startNextPeriod, $calendarviewmode, $calendarlib->firstDayofWeek($user));
            if (is_array($filterfield) == false) {
                $filterfield = array($filterfield);
            }
            if (is_array(${$filtervalue}) == false) {
                $filtervalue = array($filtervalue);
            }
            $filterfield[] = $calendarfielddate[0];
            $filtervalue[] = '';
            $exactvalue[] = array('>=' => $startPeriod['date']);
            $filterfield[] = empty($calendarfielddate[1]) ? $calendarfielddate[0] : $calendarfielddate[1];
            $filtervalue[] = '';
            $exactvalue[] = array('<' => $startNextPeriod['date']);
        }
        if (count($passfields)) {
            // Optimization: Group category fields using AND logic indicated by sub-array
            $catfilters = array();
            $catfiltervalue = array();
            $catfilternotvalue = array();
            if (!empty($filterfield)) {
                foreach ($filterfield as $k => $ff) {
                    $filterfieldinfo = $trklib->get_tracker_field($ff);
                    if ($filterfieldinfo['type'] == 'e') {
                        $catfilters[] = $k;
                        if (!empty($filtervalue[$k]) && empty($exactvalue[$k])) {
                            // Some people use filtervalue instead of exactvalue for category filters
                            $exactvalue[$k] = $filtervalue[$k];
                            for ($i = 0; $i < $k; $i++) {
                                if (!isset($exactvalue[$i])) {
                                    $exactvalue[$i] = '';
                                }
                            }
                        }
                        if (array_key_exists('not', array($exactvalue[$k]))) {
                            $catfilternotfield[0] = $ff;
                            $catfilternotvalue[] = array($exactvalue[$k]);
                        } else {
                            $catfilterfield[0] = $ff;
                            $catfiltervalue[] = array($exactvalue[$k]);
                        }
                    }
                }
            }
            if ($catfilters) {
                foreach ($catfilters as $cf) {
                    unset($filterfield[$cf]);
                    unset($exactvalue[$cf]);
                }
                if ($catfiltervalue) {
                    // array_merge is used because it reindexes
                    $filterfield = array_merge($filterfield, $catfilterfield);
                    $exactvalue = array_merge($exactvalue, array($catfiltervalue));
                }
                if ($catfilternotvalue) {
                    $filterfield = array_merge($filterfield, $catfilternotfield);
                    $exactvalue[] = array('not' => $catfilternotvalue);
                }
            }
            // End Optimization
            //fetch tracker items
            $items = $trklib->list_items($trackerId, $tr_offset, $max, $tr_sort_mode, $passfields, !empty($calendarfielddate) ? null : $filterfield, $filtervalue, $tr_status, $tr_initial, $exactvalue, $filter, $allfields, $skip_status_perm_check);
            /*** tablesorter ***/
            if ($tsOn && !$tsAjax) {
                // when using serverside filtering check wether a dropdown is in use
                // and we must take params from tracker definition because no explicit options have been defined
                if ($tsServer) {
                    //format from plugin: type:text|type:dropdown;option:1=Open;option:2=Closed|type:text|type:nofilter|type:nofilter|type:nofilter
                    if (!empty($tsfilters) && strpos($tsfilters, 'dropdown') !== false) {
                        $tsfiltersArray = explode('|', $tsfilters);
                        $adjustCol = isset($showstatus) && $showstatus == 'y' && $definition->isEnabled('showStatus') ? -1 : 0;
                        foreach ($tsfiltersArray as $col => &$tsfilterField) {
                            // only consider dropdown definitions without explicit option
                            if (strpos($tsfilterField, 'dropdown') !== false && strpos($tsfilterField, 'option') === false) {
                                //content from options (json object): {"options":["1=Open"," 2=Closed]} - note there can be whitespaces - it should not but there can be - yet another fix required
                                if ($allfields['data'][$col + $adjustCol]['type'] == 'd') {
                                    $options = $allfields['data'][$col + $adjustCol]['options'];
                                    $options = json_decode($options);
                                    $options = $options->options;
                                    // construct the new dropdown filterfield entry from the trackerfield definition
                                    $newTsfilterField = 'type:dropdown';
                                    foreach ($options as $option) {
                                        $newTsfilterField .= ";option:" . trim($option);
                                    }
                                    // update field - note that we used a ref
                                    $tsfilterField = $newTsfilterField;
                                }
                            }
                        }
                        // update tsfilters
                        $tsfilters = implode('|', $tsfiltersArray);
                    }
                }
                $ts_id = 'wptrackerlist' . $trackerId . '-' . $iTRACKERLIST;
                $ts = new Table_Plugin();
                $ts->setSettings($ts_id, isset($server) ? $server : null, $sortable, isset($sortList) ? $sortList : null, isset($tsortcolumns) ? $tsortcolumns : null, isset($tsfilters) ? $tsfilters : null, isset($tsfilteroptions) ? $tsfilteroptions : null, isset($tspaginate) ? $tspaginate : null, isset($tscolselect) ? $tscolselect : null, $GLOBALS['requestUri'], $items['cant'], isset($tstotals) ? $tstotals : null, isset($tstotalformat) ? $tstotalformat : null, isset($tstotaloptions) ? $tstotaloptions : null);
                //loads the jquery tablesorter code
                if (is_array($ts->settings)) {
                    $ts->settings['ajax']['offset'] = 'tr_offset' . $iTRACKERLIST;
                    Table_Factory::build('PluginWithAjax', $ts->settings);
                }
            }
            //determine whether totals will be added to bottom of table
            if (isset($ts->settings)) {
                Table_Totals::setTotals($ts->settings);
            }
            //handle certain tablesorter sorts
            if (isset($sortcol) && $items['cant'] > 1) {
                $fieldtype = $items['data'][0]['field_values'][$sortcol + $adjustCol]['type'];
                //convert categoryId sort to category name sort when tablesorter server side sorting is used
                if ($fieldtype === 'e') {
                    foreach ($items['data'] as $key => $record) {
                        $catfield = $record['field_values'][$sortcol + $adjustCol];
                        $sortarray[$key] = $catfield['list'][$catfield['value']]['name'];
                    }
                    //sort status
                } elseif ($adjustCol === -1 && $sortcol === 0) {
                    $sortarray = array_column($items['data'], 'status');
                }
                array_multisort($sortarray, $dir == '_desc' ? SORT_DESC : SORT_ASC, $items['data']);
            }
            /*** end second tablesorter section ***/
            if (isset($silent) && $silent == 'y' && empty($items['cant'])) {
                return;
            }
            if (isset($items['cant']) && $items['cant'] == 1 && isset($goIfOne) && ($goIfOne == 'y' || $goIfOne == 1)) {
                header('Location: tiki-view_tracker_item.php?itemId=' . $items['data'][0]['itemId'] . '&amp;trackerId=' . $items['data'][0]['trackerId']);
                die;
            }
            if ($newItemRateField && !empty($items['data'])) {
                foreach ($items['data'] as $f => $v) {
                    $items['data'][$f]['my_rate'] = $tikilib->get_user_vote("tracker." . $trackerId . '.' . $items['data'][$f]['itemId'], $user);
                }
            }
            if (!empty($items['data']) && ($definition->isEnabled('useComments') && $definition->isEnabled('showComments') || $definition->isEnabled('showLastComment'))) {
                foreach ($items['data'] as $itkey => $oneitem) {
                    if ($definition->isEnabled('showComments')) {
                        $items['data'][$itkey]['comments'] = $trklib->get_item_nb_comments($items['data'][$itkey]['itemId']);
                    }
                    if ($definition->isEnabled('showLastComment')) {
                        $l = $trklib->list_last_comments($items['data'][$itkey]['trackerId'], $items['data'][$itkey]['itemId'], 0, 1);
                        $items['data'][$itkey]['lastComment'] = !empty($l['cant']) ? $l['data'][0] : '';
                    }
                }
            }
            if (!empty($items['data']) && ($definition->isEnabled('useAttachments') && $definition->isEnabled('showAttachments'))) {
                foreach ($items["data"] as $itkey => $oneitem) {
                    $res = $trklib->get_item_nb_attachments($items["data"][$itkey]['itemId']);
                    $items["data"][$itkey]['attachments'] = $res['attachments'];
                }
            }
            if (!empty($compute) && !empty($items['data'])) {
                $fs = preg_split('/ *: */', $compute);
                foreach ($fs as $fieldId) {
                    if (strstr($fieldId, "/")) {
                        list($fieldId, $oper) = preg_split('/ *\\/ */', $fieldId);
                        $oper = strtolower($oper);
                        if ($oper == 'average') {
                            $oper = 'avg';
                        } elseif ($oper != 'sum' && $oper != 'avg') {
                            $oper = 'sum';
                        }
                    } else {
                        $oper = 'sum';
                    }
                    foreach ($items['data'] as $i => $item) {
                        foreach ($item['field_values'] as $field) {
                            if ($field['fieldId'] == $fieldId) {
                                if (preg_match('/^ *$/', $field['value']) || !is_numeric($field['value'])) {
                                    $amount[$i] = '0';
                                } else {
                                    $amount[$i] = $field['value'];
                                }
                                break;
                            }
                        }
                    }
                    $value = array_sum($amount);
                    if ($oper == 'avg') {
                        $value = round($value / count($amount));
                    }
                    $computedFields[$fieldId][] = array_merge(array('computedtype' => 'n', 'operator' => $oper, 'value' => $value), $passfields[$fieldId]);
                }
                $smarty->assign_by_ref('computedFields', $computedFields);
            } else {
                $smarty->assign('computedFields', '');
            }
            if (!empty($calendarfielddate)) {
                foreach ($items['data'] as $i => $item) {
                    if (!empty($wiki)) {
                        $smarty->assign('fields', $item['field_values']);
                        $smarty->assign('item', $item);
                        $smarty->assign('wiki', "wiki:{$wiki}");
                        $smarty->assign('showpopup', 'n');
                        $items['data'][$i]['over'] = $smarty->fetch('tracker_pretty_item.tpl');
                    }
                    if (!empty($tplwiki)) {
                        $smarty->assign('fields', $item['field_values']);
                        $smarty->assign('item', $item);
                        $smarty->assign('wiki', "tplwiki:{$tplwiki}");
                        $smarty->assign('showpopup', 'n');
                        $items['data'][$i]['over'] = $smarty->fetch('tracker_pretty_item.tpl');
                    }
                    if (empty($items['data'][$i]['over'])) {
                        $items['data'][$i]['over'] = $trklib->get_isMain_value($trackerId, $item['itemId']);
                    }
                    $items['data'][$i]['visible'] = 'y';
                }
                $trklib->fillTableViewCell($items['data'], $calendarfielddate, $cell);
                $smarty->assign('cell', $cell);
                $smarty->assign('show_calendar_module', 'y');
                $calendarlib->getDayNames($calendarlib->firstDayofWeek($user), $daysnames, $daysnames_abr);
                $smarty->assign('daysnames_abr', $daysnames_abr);
                $smarty->assign('focusmonth', TikiLib::date_format("%m", $focusDate));
                $smarty->assign('module_params', array('viewmode' => 'n', 'showaction' => 'n', 'notitle' => empty($calendartitle) ? 'y' : 'n', 'title' => $calendartitle, 'viewnavbar' => $calendarviewnavbar, 'decorations' => empty($calendartitle) ? 'n' : 'y'));
                $smarty->assign('tpl_module_title', tra($calendartitle));
                $smarty->assign('now', $tikilib->now);
                $smarty->assign('calendarViewMode', $calendarviewmode);
                $smarty->assign('viewmodelink', $calendarviewmode);
                $smarty->assign('viewmode', $calendarviewmode);
                $focus_prev = $calendarlib->focusPrevious($focus, $calendarviewmode);
                $smarty->assign('focus_prev', $focus_prev['date']);
                $focus_next = $calendarlib->focusNext($focus, $calendarviewmode);
                $smarty->assign('focus_next', $focus_next['date']);
                $smarty->assign('daystart', $startPeriod['date']);
                $dayend = $calendarlib->infoDate($startNextPeriod['date'] - 1);
                $smarty->assign('dayend', $dayend['date']);
                $smarty->assign('today', TikiLib::make_time(0, 0, 0, TikiLib::date_format('%m'), TikiLib::date_format('%d'), TikiLib::date_format('%Y')));
                $smarty->assign('sticky_popup', $calendarstickypopup);
                $smarty->assign('calendar_popup', $calendarpopup);
                $smarty->assign('showpopup', 'n');
                $headerlib = TikiLib::lib('header');
                $headerlib->add_cssfile('themes/base_files/feature_css/calendar.css', 20);
                return $smarty->fetch('modules/mod-calendar_new.tpl');
            }
            if (!empty($wiki)) {
                $tpl = "wiki:{$wiki}";
            } elseif (!empty($tplwiki)) {
                $tpl = "tplwiki:{$tplwiki}";
            } elseif (empty($tpl)) {
                $tpl = '';
            }
            if (!empty($tpl)) {
                $smarty->security = true;
            }
            $smarty->assign('tpl', $tpl);
            if (!empty($itemId) && $showpagination == 'y' && !empty($_REQUEST['cant'])) {
                $smarty->assign('max', 1);
                $smarty->assign('count_item', $_REQUEST['cant']);
                $smarty->assign('offset_arg', 'reloff');
                $smarty->assign("tr_offset{$iTRACKERLIST}", $_REQUEST['reloff']);
            } else {
                $smarty->assign_by_ref('max', $max);
                $smarty->assign_by_ref('item_count', $items['cant']);
                $smarty->assign_by_ref('count_item', $items['cant']);
                $smarty->assign('offset_arg', "tr_offset{$iTRACKERLIST}");
            }
            $smarty->assign_by_ref('items', $items["data"]);
            $smarty->assign('daformat', $tikilib->get_long_date_format() . " " . tra("at") . " %H:%M");
            if (!empty($params['showmap']) && $params['showmap'] == 'y') {
                $smarty->assign('trackerlistmapview', true);
                $smarty->assign('trackerlistmapname', "trackerlistmap_{$iTRACKERLIST}");
            } else {
                $smarty->assign('trackerlistmapview', false);
            }
            if (isset($items['data'])) {
                foreach ($items['data'] as $score_item) {
                    $item_info = $trklib->get_tracker_item($score_item['itemId']);
                    $currentItemId = $score_item['itemId'];
                    TikiLib::events()->trigger('tiki.trackeritem.view', array('type' => 'trackeritem', 'object' => $currentItemId, 'owner' => $item_info['createdBy'], 'user' => $GLOBALS['user']));
                }
            }
            $tracker = $trklib->get_tracker($trackerId, 0, -1);
            /*foreach ($query_array as $k=>$v) {
            			if (!is_array($v)) { //only to avoid an error: eliminate the params that are not simple (ex: if you have in the same page a tracker list plugin and a tracker plugin, filling the tracker plugin interfers with the tracker list. In any case this is buggy if two tracker list plugins in the same page and if one needs the query value....
            				$quarray[] = urlencode($k) ."=". urlencode($v);
            			}
            		}
            		if (is_array($quarray)) {
            			$query_string = implode("&amp;",$quarray);
            		} else {
            			$quering_string = '';
            		}
            		$smarty->assign('query_string', $query_string);
            		*/
            if (!$tracker) {
                $smarty->assign('msg', tra("Error in tracker ID"));
                return $smarty->fetch("error_raw.tpl");
            } else {
                $save_fc = null;
                if (!empty($wiki) && $params['force_compile'] === 'y') {
                    // some pretty trackers need to compile fresh for each item
                    $save_fc = $smarty->force_compile;
                    $smarty->force_compile = true;
                }
                //this options preloads the javascript for displaying sheets
                if (!empty($displaysheet) && $displaysheet == 'y') {
                    $headerlib = TikiLib::lib("header");
                    $sheetlib = TikiLib::lib("sheet");
                    $sheetlib->setup_jquery_sheet();
                    $headerlib->add_jq_onready('$("div.trackercontainer").sheet($.extend($.sheet.tikiOptions,{
							editable:false,
							buildSheet: true,
							minSize: {rows: 0, cols: 0}
						}));');
                    $smarty->assign('displaysheet', 'true');
                }
                //this method sets up the sheet just like it would for jquery.sheet, but assumes that the javascript will be handled elsewere
                if (!empty($tableassheet) && $tableassheet == 'y') {
                    $smarty->assign('tableassheet', 'true');
                }
                $smarty->assign('context', $params);
                try {
                    $str = $smarty->fetch('wiki-plugins/wikiplugin_trackerlist.tpl');
                } catch (SmartyException $e) {
                    $str = $e->getMessage();
                }
                if ($save_fc !== null) {
                    $smarty->force_compile = $save_fc;
                    // presumably will be false but put it back anyway
                }
                return $str;
            }
        } else {
            $smarty->assign('msg', tra("No field indicated"));
            return $smarty->fetch("error_raw.tpl");
        }
    }
    return $back;
}
コード例 #23
0
ファイル: tikilib.php プロジェクト: rjsmelo/tiki
 /** Update a wiki page
 		@param array $hash- lock_it,contributions, contributors
 		@param int $saveLastModif - modification time - pass null for now, unless importing a Wiki page
 	 **/
 function update_page($pageName, $edit_data, $edit_comment, $edit_user, $edit_ip, $edit_description = null, $edit_minor = 0, $lang = '', $is_html = null, $hash = null, $saveLastModif = null, $wysiwyg = '', $wiki_authors_style = '')
 {
     global $prefs;
     $histlib = TikiLib::lib('hist');
     if (!$edit_user) {
         $edit_user = '******';
     }
     $this->invalidate_cache($pageName);
     // Collect pages before modifying edit_data (see update of links below)
     $pages = $this->get_pages($edit_data, true);
     $this->check_alias($edit_data, $pageName);
     if (!$this->page_exists($pageName)) {
         return false;
     }
     // Get this page information
     $info = $this->get_page_info($pageName);
     if ($edit_description === null) {
         $edit_description = $info['description'];
     }
     // Use largest version +1 in history table rather than tiki_page because versions used to be bugged
     // tiki_history is also bugged as not all changes get stored in the history, like minor changes
     // and changes that do not modify the body of the page. Both numbers are wrong, but the largest of
     // them both is right.
     $old_version = max($info["version"], $histlib->get_page_latest_version($pageName));
     $user = $info["user"] ? $info["user"] : '******';
     $data = $info["data"];
     $willDoHistory = $prefs['feature_wiki_history_full'] == 'y' || $data != $edit_data || $info['description'] != $edit_description || $info["comment"] != $edit_comment;
     $version = $old_version + ($willDoHistory ? 1 : 0);
     if ($is_html === null) {
         $html = $info['is_html'];
     } else {
         $html = $is_html ? 1 : 0;
     }
     if ($wysiwyg == '') {
         $wysiwyg = $info['wysiwyg'];
     }
     if ($wysiwyg == 'y' && $html != 1 && $prefs['wysiwyg_htmltowiki'] != 'y') {
         // correct for html only wysiwyg
         $html = 1;
     }
     $parserlib = TikiLib::lib('parser');
     $edit_data = $parserlib->process_save_plugins($edit_data, array('type' => 'wiki page', 'itemId' => $pageName, 'user' => $user));
     if ($html == 1 && $prefs['feature_purifier'] != 'n') {
         $parserlib->isHtmlPurifying = true;
         $parserlib->isEditMode = true;
         $noparsed = array();
         $parserlib->plugins_remove($edit_data, $noparsed);
         require_once 'lib/htmlpurifier_tiki/HTMLPurifier.tiki.php';
         $edit_data = HTMLPurifier($edit_data);
         $parserlib->plugins_replace($edit_data, $noparsed, true);
         $parserlib->isHtmlPurifying = false;
         $parserlib->isEditMode = false;
     }
     if (is_null($saveLastModif)) {
         $saveLastModif = $this->now;
     }
     $queryData = array('description' => $edit_description, 'data' => $edit_data, 'comment' => $edit_comment, 'lastModif' => (int) $saveLastModif, 'version' => $version, 'version_minor' => $edit_minor, 'user' => $edit_user, 'ip' => $edit_ip, 'page_size' => strlen($edit_data), 'is_html' => $html, 'wysiwyg' => $wysiwyg, 'wiki_authors_style' => $wiki_authors_style, 'lang' => $lang);
     if ($hash !== null) {
         if (!empty($hash['lock_it']) && ($hash['lock_it'] == 'y' || $hash['lock_it'] == 'on')) {
             $queryData['flag'] = 'L';
             $queryData['lockedby'] = $user;
         } else {
             if (empty($hash['lock_it']) || $hash['lock_it'] == 'n') {
                 $queryData['flag'] = '';
                 $queryData['lockedby'] = '';
             }
         }
     }
     if ($prefs['wiki_comments_allow_per_page'] != 'n') {
         if (!empty($hash['comments_enabled']) && $hash['comments_enabled'] == 'y') {
             $queryData['comments_enabled'] = 'y';
         } else {
             if (empty($hash['comments_enabled']) || $hash['comments_enabled'] == 'n') {
                 $queryData['comments_enabled'] = 'n';
             }
         }
     }
     if (empty($hash['contributions'])) {
         $hash['contributions'] = '';
     }
     if (empty($hash['contributors'])) {
         $hash2 = '';
     } else {
         foreach ($hash['contributors'] as $c) {
             $hash3['contributor'] = $c;
             $hash2[] = $hash3;
         }
     }
     $this->table('tiki_pages')->update($queryData, array('pageName' => $pageName));
     // Synchronize object comment
     if ($prefs['feature_wiki_description'] == 'y') {
         $query = 'update `tiki_objects` set `description`=? where `itemId`=? and `type`=?';
         $this->query($query, array($edit_description, $pageName, 'wiki page'));
     }
     //update status, page storage was updated in tiki 9 to be non html encoded
     $wikilib = TikiLib::lib('wiki');
     $converter = new convertToTiki9();
     $converter->saveObjectStatus($this->getOne("SELECT page_id FROM tiki_pages WHERE pageName = ?", array($pageName)), 'tiki_pages');
     // Parse edit_data updating the list of links from this page
     $this->clear_links($pageName);
     // Pages collected above
     foreach ($pages as $page => $types) {
         $this->replace_link($pageName, $page, $types);
     }
     if (strtolower($pageName) != 'sandbox' && !$edit_minor) {
         $maxversions = $prefs['maxVersions'];
         if ($maxversions && ($nb = $histlib->get_nb_history($pageName)) > $maxversions) {
             // Select only versions older than keep_versions days
             $keep = $prefs['keep_versions'];
             $oktodel = $saveLastModif - $keep * 24 * 3600 + 1;
             $history = $this->table('tiki_history');
             $result = $history->fetchColumn('version', array('pageName' => $pageName, 'lastModif' => $history->lesserThan($oktodel)), $nb - $maxversions, 0, array('lastModif' => 'ASC'));
             foreach ($result as $toRemove) {
                 $histlib->remove_version($pageName, $toRemove);
             }
         }
     }
     // This if no longer checks for minor-ness of the change; sendWikiEmailNotification does that.
     if ($willDoHistory) {
         $this->replicate_page_to_history($pageName);
         if (strtolower($pageName) != 'sandbox') {
             if ($prefs['feature_contribution'] == 'y') {
                 // transfer page contributions to the history
                 $contributionlib = TikiLib::lib('contribution');
                 $history = $this->table('tiki_history');
                 $historyId = $history->fetchOne($history->max('historyId'), array('pageName' => $pageName, 'version' => (int) $old_version));
                 $contributionlib->change_assigned_contributions($pageName, 'wiki page', $historyId, 'history', '', $pageName . '/' . $old_version, "tiki-pagehistory.php?page={$pageName}&preview={$old_version}");
             }
         }
         include_once 'lib/diff/difflib.php';
         if (strtolower($pageName) != 'sandbox') {
             $logslib = TikiLib::lib('logs');
             $bytes = diff2($data, $edit_data, 'bytes');
             $logslib->add_action('Updated', $pageName, 'wiki page', $bytes, $edit_user, $edit_ip, '', $this->now, $hash['contributions'], $hash2);
             if ($prefs['feature_contribution'] == 'y') {
                 $contributionlib = TikiLib::lib('contribution');
                 $contributionlib->assign_contributions($hash['contributions'], $pageName, 'wiki page', $edit_description, $pageName, "tiki-index.php?page=" . urlencode($pageName));
             }
         }
         if ($prefs['feature_multilingual'] == 'y' && $lang) {
             // Need to update the translated objects table when an object's language changes.
             $this->table('tiki_translated_objects')->update(array('lang' => $lang), array('type' => 'wiki page', 'objId' => $info['page_id']));
         }
         if ($prefs['wiki_watch_minor'] != 'n' || !$edit_minor) {
             //  Deal with mail notifications.
             include_once 'lib/notifications/notificationemaillib.php';
             $histlib = TikiLib::lib('hist');
             $old = $histlib->get_version($pageName, $old_version);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = self::httpPrefix(true) . dirname($foo["path"]);
             $diff = diff2($old["data"], $edit_data, "unidiff");
             sendWikiEmailNotification('wiki_page_changed', $pageName, $edit_user, $edit_comment, $old_version, $edit_data, $machine, $diff, $edit_minor, $hash['contributions'], 0, 0, $lang);
         }
     }
     $tx = $this->begin();
     TikiLib::events()->trigger('tiki.wiki.update', array('type' => 'wiki page', 'object' => $pageName, 'namespace' => $wikilib->get_namespace($pageName), 'reply_action' => 'comment', 'user' => $GLOBALS['user'], 'page_id' => $info['page_id'], 'version' => $version, 'data' => $edit_data, 'old_data' => $info['data']));
     $tx->commit();
 }
コード例 #24
0
ファイル: Controller.php プロジェクト: rjsmelo/tiki
 /**
  * Function to toggle relation. Sets relation when none set and then if there is a relation, it unsets.
  * @param $input
  * @return array with "relationId" as param. Null if relation is removed.
  * @throws Exception
  * @throws Services_Exception
  */
 function action_toggle_group($input)
 {
     $relation_prefix = $input->relation_prefix->none();
     $relation = $input->relation->none();
     $target_type = $input->target_type->none();
     $target_id = $input->target_id->none();
     $source_type = $input->source_type->none();
     $source_id = $input->source_id->none();
     // ensure the target, source, and relation info are passed to the service
     if (!$target_type || !$target_id || !$source_type || !$source_id || !$relation_prefix) {
         throw new Services_Exception(tr('Invalid input'), 400);
     }
     $relationlib = TikiLib::lib('relation');
     $tx = TikiDb::get()->begin();
     $relations = $relationlib->get_relations_by_prefix($relation_prefix, $source_type, $source_id, $target_type, $target_id);
     // If there is not an existing relation, add the relation and trigger the add relation event.
     $relationWasSelected = false;
     if (!empty($relations)) {
         foreach ($relations as $rel) {
             if ($rel['relation'] == $relation) {
                 //sets whether the relation was previously selected and is being toggled off
                 $relationWasSelected = true;
             }
             //if there is a relation, remove the relation, trigger the event, and set the relationId to null
             $relationlib->remove_relation($rel['relationId']);
             TikiLib::events()->trigger('tiki.relation.remove', array('id' => $rel['relation_id'], 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation));
         }
     }
     $relationId = null;
     // set the return id
     //only adds relation if it hadn't previously been selected. If it was selected, then the user toggled it off.
     if (!$relationWasSelected) {
         $relationId = $relationlib->add_relation($relation, $source_type, $source_id, $target_type, $target_id);
         TikiLib::events()->trigger('tiki.relation.add', array('id' => $relationId, 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation));
     }
     $tx->commit();
     //return the relationId (new relation if added, null if removed)
     return array('relation_id' => $relationId);
 }
コード例 #25
0
ファイル: imagegallib.php プロジェクト: rjsmelo/tiki
 /**
  * @param $id
  * @return bool
  */
 function remove_gallery($id)
 {
     global $prefs;
     $query = "select `imageId`, path from `tiki_images` where `galleryId`=?";
     $result = $this->query($query, array((int) $id));
     while ($res = $result->fetchRow()) {
         $path = $res["path"];
         $query2 = "select `xsize`,`ysize`,`type` from `tiki_images_data` where `imageId`=?";
         $result2 = $this->query($query2, array((int) $res["imageId"]));
         while ($res2 = $result2->fetchRow()) {
             switch ($res2["type"]) {
                 case 't':
                     $ext = ".thumb";
                     break;
                 case 's':
                     $ext = ".scaled_" . $res2["xsize"] . "x" . $res2["ysize"];
                     break;
                 case 'b':
                     // for future use
                     $ext = ".backup";
                     break;
                 default:
                     $ext = '';
             }
             if ($path) {
                 @unlink($prefs['gal_use_dir'] . $path . $ext);
             }
         }
         $query3 = "delete from `tiki_images_data` where `imageId`=?";
         $result3 = $this->query($query3, array((int) $res["imageId"]));
         $this->remove_object('image', $res["imageId"]);
     }
     $query = "delete from `tiki_galleries` where `galleryId`=?";
     $result = $this->query($query, array((int) $id));
     $query = "delete from `tiki_images` where `galleryId`=?";
     $result = $this->query($query, array((int) $id));
     $this->remove_gallery_scale($id);
     $this->remove_object('image gallery', $id);
     TikiLib::events()->trigger('tiki.imagegallery.delete', array('type' => 'imagegallery', 'object' => $id, 'user' => $user));
     return true;
 }
コード例 #26
0
ファイル: commentslib.php プロジェクト: jkimdon/cohomeals
 /**
  * Post a new comment (forum post or comment on some Tiki object)
  *
  * @param string $objectId object type and id separated by two colon ('wiki page:HomePage' or 'blog post:2')
  * @param int $parentId id of parent comment of this comment
  * @param string $userName if empty $anonumous_name is used
  * @param string $title
  * @param string $data
  * @param unknown_type $message_id
  * @param unknown_type $in_reply_to
  * @param unknown_type $type
  * @param unknown_type $summary
  * @param unknown_type $smiley
  * @param unknown_type $contributions
  * @param string $anonymous_name name when anonymous user post a comment (optional)
  * @param int $postDate when the post was created (defaults to now)
  * @param string $anonymous_email optional
  * @param string $anonymous_website optional
  * @return int $threadId id of the new comment
  */
 function post_new_comment($objectId, $parentId, $userName, $title, $data, &$message_id, $in_reply_to = '', $type = 'n', $summary = '', $smiley = '', $contributions = '', $anonymous_name = '', $postDate = '', $anonymous_email = '', $anonymous_website = '', $parent_comment_info = '')
 {
     global $user;
     if ($postDate == '') {
         $postDate = $this->now;
     }
     if (!$userName) {
         $_SESSION["lastPost"] = $postDate;
     }
     // Check for banned userName or banned IP or IP in banned range
     // Check for duplicates.
     $title = strip_tags($title);
     if ($anonymous_name) {
         $userName = $anonymous_name;
     } elseif (!$userName) {
         $userName = tra('Anonymous');
     } elseif ($userName) {
         $postings = $this->table('tiki_user_postings');
         $count = $postings->fetchCount(array('user' => $userName));
         if ($count) {
             $postings->update(array('last' => (int) $postDate, 'posts' => $postings->increment(1)), array('user' => $userName));
         } else {
             $posts = $this->table('tiki_comments')->fetchCount(array('userName' => $userName));
             if (!$posts) {
                 $posts = 1;
             }
             $postings->insert(array('user' => $userName, 'first' => (int) $postDate, 'last' => (int) $postDate, 'posts' => (int) $posts));
         }
         // Calculate max
         $max = $postings->fetchOne($postings->max('posts'), array());
         $min = $postings->fetchOne($postings->min('posts'), array());
         $min = max($min, 1);
         $ids = $postings->fetchCount(array());
         $tot = $postings->fetchOne($postings->sum('posts'), array());
         $average = $tot / $ids;
         $range1 = ($min + $average) / 2;
         $range2 = ($max + $average) / 2;
         $posts = $postings->fetchOne('posts', array('user' => $userName));
         if ($posts == $max) {
             $level = 5;
         } elseif ($posts > $range2) {
             $level = 4;
         } elseif ($posts > $average) {
             $level = 3;
         } elseif ($posts > $range1) {
             $level = 2;
         } else {
             $level = 1;
         }
         $postings->update(array('level' => $level), array('user' => $userName));
     }
     $hash = md5($title . $data);
     // Check if we were passed a message-id.
     if (!$message_id) {
         // Construct a message id via proctological
         // extraction. -rlpowell
         $message_id = $userName . "-" . $parentId . "-" . substr($hash, 0, 10) . "@" . $_SERVER["SERVER_NAME"];
     }
     // Break out the type and object parameters.
     $object = explode(":", $objectId, 2);
     // Handle comments moderation (this should not affect forums and user with admin rights on comments)
     $approved = $this->determine_initial_approval(array('type' => $object[0], 'author' => $userName, 'email' => $user ? TikiLib::lib('user')->get_user_email($user) : $anonymous_email, 'website' => $anonymous_website, 'content' => $data));
     if ($approved === false) {
         TikiLib::lib('errorreport')->report(tr('Your comment was rejected.'));
         return false;
     }
     $comments = $this->table('tiki_comments');
     $threadId = $comments->fetchOne('threadId', array('hash' => $hash));
     // If this post was not already found.
     if (!$threadId) {
         $threadId = $comments->insert(array('objectType' => $object[0], 'object' => $object[1], 'commentDate' => (int) $postDate, 'userName' => $userName, 'title' => $title, 'data' => $data, 'votes' => 0, 'points' => 0, 'hash' => $hash, 'email' => $anonymous_email, 'website' => $anonymous_website, 'parentId' => (int) $parentId, 'average' => 0, 'hits' => 0, 'type' => $type, 'summary' => $summary, 'user_ip' => $this->get_ip_address(), 'message_id' => $message_id, 'in_reply_to' => $in_reply_to, 'approved' => $approved, 'locked' => 'n'));
     }
     global $prefs;
     if ($prefs['feature_actionlog'] == 'y') {
         $logslib = TikiLib::lib('logs');
         global $tikilib;
         if ($parentId == 0) {
             $l = strlen($data);
         } else {
             $l = $tikilib->strlen_quoted($data);
         }
         if ($object[0] == 'forum') {
             $logslib->add_action($parentId == 0 ? 'Posted' : 'Replied', $object[1], $object[0], 'comments_parentId=' . $threadId . '&amp;add=' . $l, '', '', '', '', $contributions);
         } else {
             $logslib->add_action($parentId == 0 ? 'Posted' : 'Replied', $object[1], 'comment', 'type=' . $object[0] . '&amp;add=' . $l . '#threadId' . $threadId, '', '', '', '', $contributions);
         }
     }
     if ($prefs['feature_contribution'] == 'y') {
         $contributionlib = TikiLib::lib('contribution');
         $contributionlib->assign_contributions($contributions, $threadId, 'comment', $title, '', '');
     }
     $this->update_comment_links($data, $object[0], $threadId);
     $tx = $this->begin();
     $type = $this->update_index($object[0], $threadId, $parentId);
     $finalEvent = 'tiki.comment.post';
     if ($type == 'forum post') {
         $finalEvent = $parentId ? 'tiki.forumpost.reply' : 'tiki.forumpost.create';
         if ($parent_comment_info) {
             $parent_title = $parent_comment_info['title'];
         } else {
             $parent_title = '';
         }
         TikiLib::events()->trigger($finalEvent, array('type' => $type, 'object' => $threadId, 'parent_id' => $parentId, 'forum_id' => $object[1], 'user' => $GLOBALS['user'], 'title' => $title, 'parent_title' => $parent_title, 'content' => $data, 'index_handled' => true));
     } else {
         $finalEvent = $parentId ? 'tiki.comment.reply' : 'tiki.comment.post';
         if ($object[0] == 'trackeritem') {
             $parentobject = TikiLib::lib('trk')->get_tracker_for_item($object[1]);
         } else {
             $parentobject = 'not implemented';
         }
         TikiLib::events()->trigger($finalEvent, array('type' => $object[0], 'object' => $object[1], 'parentobject' => $parentobject, 'user' => $GLOBALS['user'], 'title' => $title, 'content' => $data));
     }
     $tx->commit();
     return $threadId;
     //return $return_result;
 }
コード例 #27
0
ファイル: bloglib.php プロジェクト: linuxwhy/tiki-1
 /**
  * remove_post Removes a post identified by $postId
  *
  * @param int $postId
  * @access public
  * @return boolean inconditionnal true
  */
 function remove_post($postId)
 {
     $tikilib = TikiLib::lib('tiki');
     $objectlib = TikiLib::lib('object');
     $query = "select `blogId`, `data` from `tiki_blog_posts` where `postId`=?";
     $result = $this->query($query, array((int) $postId));
     if ($res = $result->fetchRow()) {
         $blogId = $res['blogId'];
     } else {
         $blogId = 0;
     }
     global $prefs;
     if ($prefs['feature_actionlog'] == 'y') {
         $logslib = TikiLib::lib('logs');
         $param = "blogId={$blogId}&amp;postId={$postId}";
         if ($blogId) {
             $param .= "&amp;del=" . strlen($res['data']);
         }
         $logslib->add_action('Removed', $blogId, 'blog', $param);
     }
     if ($blogId) {
         $query = "delete from `tiki_blog_posts` where `postId`=?";
         $result = $this->query($query, array((int) $postId));
         $query = "update `tiki_blogs` set `posts`=`posts`-1 where `blogId`=?";
         $result = $this->query($query, array((int) $blogId));
     }
     /*
      * TODO: this should be a method in freetaglib or maybe even better $tikilib->remove_object() should
      * remove the relation between the object and the tags, no?
      */
     // When a post is deleted, all freetags asociated must also be deleted
     $objectId = $objectlib->get_object_id('blog post', $postId);
     $query = "DELETE FROM `tiki_freetagged_objects` WHERE `objectId` = ?";
     $this->query($query, array((int) $objectId));
     $query = "delete from `tiki_blog_posts_images` where `postId`=?";
     $this->query($query, array((int) $postId));
     $tikilib->remove_object('blog post', $postId);
     TikiLib::events()->trigger('tiki.blogpost.delete', array('type' => 'blog post', 'object' => $postId, 'blog' => $blogId, 'user' => $GLOBALS['user']));
     return true;
 }
コード例 #28
0
ファイル: tiki-index.php プロジェクト: hurcane/tiki-azure
$statslib->stats_hit($page, 'wiki');
if ($prefs['feature_actionlog'] == 'y') {
    $logslib->add_action('Viewed', $page);
}
// Detect if we have a PDF export mod installed
$smarty->assign('pdf_export', $prefs['print_pdf_from_url'] != 'none' ? 'y' : 'n');
// Display the Index Template
$pageRenderer->runSetups();
//TRANSLATING HTML
$page_content = (string) $smarty->getTemplateVars('parsed');
// convert from Tiki_Render_Lazy to string here
if (!empty($_REQUEST['machine_translate_to_lang'])) {
    $page_content = generate_machine_translated_content($page_content, $info, $_REQUEST['machine_translate_to_lang']);
    $smarty->assign('parsed', $page_content);
}
TikiLib::events()->trigger('tiki.wiki.view', array_merge(array('type' => 'wiki', 'object' => $page), is_array($info) ? $info : array()));
$smarty->assign('info', $info);
$smarty->display('tiki-show_page.tpl');
// xdebug_dump_function_profile(XDEBUG_PROFILER_CPU);
// debug: print all objects
/**
 * generate machine translation of markup
 * @param $pageInfo
 * @param $targetLang
 * @return string
 */
function generate_machine_translated_markup($pageInfo, $targetLang)
{
    make_sure_machine_translation_is_enabled();
    $pageContent = $pageInfo['data'];
    $sourceLang = $pageInfo['lang'];
コード例 #29
0
 private function getEventTypes()
 {
     $graph = TikiLib::events()->getEventGraph();
     sort($graph['nodes']);
     return $graph['nodes'];
 }
コード例 #30
0
ファイル: categlib.php プロジェクト: rjsmelo/tiki
 function update_object_categories($categories, $objId, $objType, $desc = NULL, $name = NULL, $href = NULL, $managedCategories = null, $override_perms = false)
 {
     global $prefs, $user;
     $userlib = TikiLib::lib('user');
     if (empty($categories)) {
         $forcedcat = $userlib->get_user_group_default_category($user);
         if (!empty($forcedcat)) {
             $categories[] = $forcedcat;
         }
     }
     $manip = new Category_Manipulator($objType, $objId);
     if ($override_perms) {
         $manip->overrideChecks();
     }
     $manip->setNewCategories($categories ? $categories : array());
     if (is_array($managedCategories) && !$override_perms) {
         $manip->setManagedCategories($managedCategories);
     }
     if ($prefs['category_defaults']) {
         foreach ($prefs['category_defaults'] as $constraint) {
             $manip->addRequiredSet($this->extentCategories($constraint['categories']), $constraint['default'], $constraint['filter'], $constraint['type']);
         }
     }
     $this->applyManipulator($manip, $objType, $objId, $desc, $name, $href);
     if ($prefs['category_i18n_sync'] != 'n' && $prefs['feature_multilingual'] == 'y') {
         $multilinguallib = TikiLib::lib('multilingual');
         $targetCategories = $this->get_object_categories($objType, $objId, -1, false);
         if ($objType == 'wiki page') {
             $translations = $multilinguallib->getTranslations($objType, $this->get_page_id_from_name($objId), $objId);
             $objectIdKey = 'objName';
         } else {
             if (in_array($objType, array('article'))) {
                 // only try on supported types
                 $translations = $multilinguallib->getTranslations($objType, $objId);
                 $objectIdKey = 'objId';
             } else {
                 $translations = array();
                 $objectIdKey = 'objId';
             }
         }
         $subset = $prefs['category_i18n_synced'];
         if (is_string($subset)) {
             $subset = unserialize($subset);
         }
         foreach ($translations as $tr) {
             if (!empty($tr[$objectIdKey]) && $tr[$objectIdKey] != $objId) {
                 $manip = new Category_Manipulator($objType, $tr[$objectIdKey]);
                 $manip->setNewCategories($targetCategories);
                 $manip->overrideChecks();
                 if ($prefs['category_i18n_sync'] == 'whitelist') {
                     $manip->setManagedCategories($subset);
                 } elseif ($prefs['category_i18n_sync'] == 'blacklist') {
                     $manip->setUnmanagedCategories($subset);
                 }
                 $this->applyManipulator($manip, $objType, $tr[$objectIdKey]);
             }
         }
     }
     $added = $manip->getAddedCategories();
     $removed = $manip->getRemovedCategories();
     TikiLib::events()->trigger('tiki.object.categorized', array('object' => $objId, 'type' => $objType, 'added' => $added, 'removed' => $removed));
     $this->notify_add($added, $name, $objType, $href);
     $this->notify_remove($removed, $name, $objType, $href);
 }