function getAvailableTransitions( $object, $type = null )
	{
		$states = $this->getCurrentStates($object, $type);

		$transitions = $this->getTransitionsFromStates($states);
		$transitions = Perms::filter(
						array('type' => 'transition'), 
						'object', 
						$transitions, 
						array('object' => 'transitionId'),
						'trigger_transition'
		);

		foreach ( $transitions as & $tr ) {
			$object = new Transition($tr['from'], $tr['to']);
			$object->setStates($states);
			foreach ( $tr['guards'] as $guard ) {
				call_user_func_array(array($object, 'addGuard' ), $guard);
			}

			$tr['enabled'] = $object->isReady();
			$tr['explain'] = $object->explain();
		}

		return $transitions;
	}
Exemple #2
0
 /**
  * @param $section
  * @param $offset
  * @param $maxRecords
  * @param $sort_mode
  * @param $find
  * @return array
  */
 public function list_templates($section, $offset, $maxRecords, $sort_mode, $find)
 {
     $bindvars = array($section);
     if ($find) {
         $findesc = '%' . $find . '%';
         $mid = " and (`content` like ?)";
         $bindvars[] = $findesc;
     } else {
         $mid = "";
     }
     $query = "select `name` ,`created`,tcts.`templateId` from `tiki_content_templates` tct, `tiki_content_templates_sections` tcts ";
     $query .= " where tcts.`templateId`=tct.`templateId` and `section`=? {$mid} order by " . $this->convertSortMode($sort_mode);
     $query_cant = "select count(*) from `tiki_content_templates` tct, `tiki_content_templates_sections` tcts ";
     $query_cant .= "where tcts.`templateId`=tct.`templateId` and `section`=? {$mid}";
     $result = $this->query($query, $bindvars, $maxRecords, $offset);
     $cant = $this->getOne($query_cant, $bindvars);
     $ret = array();
     while ($res = $result->fetchRow()) {
         $query2 = "select `section`  from `tiki_content_templates_sections` where `templateId`=?";
         $result2 = $this->query($query2, array((int) $res["templateId"]));
         $sections = array();
         while ($res2 = $result2->fetchRow()) {
             $sections[] = $res2["section"];
         }
         $res["sections"] = $sections;
         $ret[] = $res;
     }
     // filter out according to perms
     $ret = Perms::filter(array('type' => 'template'), 'object', $ret, array('object' => 'templateId'), 'use_content_templates');
     $cant = count($ret);
     $retval = array();
     $retval["data"] = $ret;
     $retval["cant"] = $cant;
     return $retval;
 }
 function get_past($offset, $max, $ofUser = '')
 {
     $conditions = 'tpr.`amount` <= tpr.`amount_paid` AND tpr.`cancel_date` IS NULL';
     if ($ofUser) {
         $conditions .= " AND uu.`login` = '{$ofUser}'";
     }
     $count = 'SELECT COUNT(*) FROM `tiki_payment_requests` tpr LEFT JOIN `users_users` uu ON (uu.`userId` = tpr.`userId`) WHERE ' . $conditions;
     $data = 'SELECT tpr.*, uu.`login` as `user`, tp.`type`, tp.`payment_date`,' . ' tp.`details` as `payment_detail`, uup.`login` as `payer`' . ' FROM `tiki_payment_requests` tpr' . ' LEFT JOIN `users_users` uu ON (uu.`userId` = tpr.`userId`)' . ' LEFT JOIN `tiki_payment_received` tp ON (tp.`paymentRequestId`=tpr.`paymentRequestId`)' . ' LEFT JOIN `users_users` uup ON (uup.`userId` = tp.`userId`) WHERE ' . $conditions;
     $all = $this->fetchAll($data, array(), $max, $offset);
     return array('cant' => $this->getOne($count), 'data' => Perms::filter(array('type' => 'payment'), 'object', $all, array('object' => 'paymentRequestId'), 'payment_view'));
 }
Exemple #4
0
 /**
  * @param $offset
  * @param $maxRecords
  * @param $sort_mode
  * @param $find
  * @return array
  */
 public function list_surveys($offset, $maxRecords, $sort_mode, $find, $perm = 'take_survey')
 {
     $conditions = array();
     if ($find) {
         $conditions['search'] = $this->surveysTable->expr('(`name` like ? or `description` like ?)', array("%{$find}%", "%{$find}%"));
     }
     $surveys = $this->surveysTable->fetchAll($this->surveysTable->all(), $conditions, $maxRecords, $offset, $this->surveysTable->sortMode($sort_mode));
     $surveys = Perms::filter(array('type' => 'survey'), 'object', $surveys, array('object' => 'surveyId'), $perm);
     foreach ($surveys as &$survey) {
         $survey['questions'] = $this->questionsTable->fetchOne($this->questionsTable->count(), array('surveyId' => $survey['surveyId']));
     }
     $retval["data"] = $surveys;
     $retval["cant"] = count($surveys);
     return $retval;
 }
Exemple #5
0
 /**
  * list_all_blog_posts Returns all the posts filtered by $date and $find
  *
  * @param int $offset
  * @param int $maxRecords
  * @param string $sort_mode
  * @param string $find
  * @param string $date
  * @access public
  * @return void
  */
 function list_all_blog_posts($offset = 0, $maxRecords = -1, $sort_mode = 'created_desc', $find = '', $date = '')
 {
     if ($find) {
         $findesc = '%' . $find . '%';
         $mid = " where (`data` like ?) ";
         $bindvars = array($findesc);
     } else {
         $mid = "";
         $bindvars = array();
     }
     if ($date) {
         $bindvars[] = $date;
         if ($mid) {
             $mid .= " and `created`<=? ";
         } else {
             $mid .= " where `created`<=? ";
         }
     }
     $query = "select * from `tiki_blog_posts` {$mid} order by " . $this->convertSortMode($sort_mode);
     $query_cant = "select count(*) from `tiki_blog_posts` {$mid}";
     $result = $this->fetchAll($query, $bindvars, $maxRecords, $offset);
     $cant = $this->getOne($query_cant, $bindvars);
     $ret = array();
     $result = Perms::filter(array('type' => 'blog'), 'object', $result, array('object' => 'blogId'), array('read_blog', 'blog_view_ref'));
     foreach ($result as $res) {
         $query2 = "select `title` from `tiki_blogs` where `blogId`=?";
         $title = $this->getOne($query2, array($res["blogId"]));
         $res["blogtitle"] = $title;
         $ret[] = $res;
     }
     $retval = array();
     $retval["data"] = $ret;
     $retval["cant"] = $cant;
     return $retval;
 }
Exemple #6
0
 /**
  * @param int $offset
  * @param $maxRecords
  * @param string $sort_mode
  * @param string $find
  * @param string $initial
  * @param bool $exact_match
  * @param bool $onlyName
  * @param bool $forListPages
  * @param bool $only_orphan_pages
  * @param string $filter
  * @param bool $onlyCant
  * @param string $ref
  * @return array
  */
 function list_pages($offset = 0, $maxRecords = -1, $sort_mode = 'pageName_desc', $find = '', $initial = '', $exact_match = true, $onlyName = false, $forListPages = false, $only_orphan_pages = false, $filter = '', $onlyCant = false, $ref = '')
 {
     global $prefs, $tiki_p_wiki_view_ratings;
     $loadCategories = isset($prefs['wiki_list_categories']) && $prefs['wiki_list_categories'] == 'y' || isset($prefs['wiki_list_categories_path']) && $prefs['wiki_list_categories_path'] == 'y';
     $loadCategories = $loadCategories && $forListPages;
     $join_tables = '';
     $join_bindvars = array();
     $old_sort_mode = '';
     if ($sort_mode == 'size_desc') {
         $sort_mode = 'page_size_desc';
     }
     if ($sort_mode == 'size_asc') {
         $sort_mode = 'page_size_asc';
     }
     $select = '';
     // If sort mode is versions, links or backlinks then offset is 0, maxRecords is -1 (again) and sort_mode is nil
     $need_everything = false;
     if (in_array($sort_mode, array('versions_desc', 'versions_asc', 'links_asc', 'links_desc', 'backlinks_asc', 'backlinks_desc'))) {
         $old_sort_mode = $sort_mode;
         $sort_mode = 'user_desc';
         $need_everything = true;
     }
     if (is_array($find)) {
         // you can use an array of pages
         $mid = " where LOWER(`pageName`) IN (" . implode(',', array_fill(0, count($find), 'LOWER(?)')) . ")";
         $bindvars = $find;
     } elseif (is_string($find) && !empty($find)) {
         // or a string
         if (!$exact_match && $find) {
             $find = preg_replace("/([^\\s]+)/", "%\\1%", $find);
             $f = preg_split("/[\\s]+/", $find, -1, PREG_SPLIT_NO_EMPTY);
             if (empty($f)) {
                 //look for space...
                 $mid = " where LOWER(`pageName`) like LOWER('%{$find}%')";
             } else {
                 $findop = $forListPages ? ' AND' : ' OR';
                 $mid = " where LOWER(`pageName`) like " . implode($findop . ' LOWER(`pageName`) like ', array_fill(0, count($f), 'LOWER(?)'));
                 $bindvars = $f;
             }
         } else {
             $mid = " where LOWER(`pageName`) like LOWER(?) ";
             $bindvars = array($find);
         }
     } else {
         $bindvars = array();
         $mid = '';
     }
     $categlib = TikiLib::lib('categ');
     $category_jails = $categlib->get_jail();
     if (!isset($filter['andCategId']) && !isset($filter['categId']) && empty($filter['noCateg']) && !empty($category_jails)) {
         $filter['categId'] = $category_jails;
     }
     // If language is set to '', assume that no language filtering should be done.
     if (isset($filter['lang']) && $filter['lang'] == '') {
         unset($filter['lang']);
     }
     $distinct = '';
     if (!empty($filter)) {
         $tmp_mid = array();
         foreach ($filter as $type => $val) {
             if ($type == 'andCategId') {
                 $categories = $categlib->get_jailed((array) $val);
                 $join_tables .= " inner join `tiki_objects` as tob on (tob.`itemId`= tp.`pageName` and tob.`type`= ?) ";
                 $join_bindvars[] = 'wiki page';
                 foreach ($categories as $i => $categId) {
                     $join_tables .= " inner join `tiki_category_objects` as tc{$i} on (tc{$i}.`catObjectId`=tob.`objectId` and tc{$i}.`categId` =?) ";
                     $join_bindvars[] = $categId;
                 }
             } elseif ($type == 'categId') {
                 $categories = $categlib->get_jailed((array) $val);
                 $categories[] = -1;
                 $cat_count = count($categories);
                 $join_tables .= " inner join `tiki_objects` as tob on (tob.`itemId`= tp.`pageName` and tob.`type`= ?) inner join `tiki_category_objects` as tc on (tc.`catObjectId`=tob.`objectId` and tc.`categId` IN(" . implode(', ', array_fill(0, $cat_count, '?')) . ")) ";
                 if ($cat_count > 1) {
                     $distinct = ' DISTINCT ';
                 }
                 $join_bindvars = array_merge(array('wiki page'), $categories);
             } elseif ($type == 'noCateg') {
                 $join_tables .= ' left join `tiki_objects` as tob on (tob.`itemId`= tp.`pageName` and tob.`type`= ?) left join `tiki_categorized_objects` as tcdo on (tcdo.`catObjectId`=tob.`objectId`) left join `tiki_category_objects` as tco on (tcdo.`catObjectId`=tco.`catObjectId`)';
                 $join_bindvars[] = 'wiki page';
                 $tmp_mid[] = '(tco.`categId` is null)';
             } elseif ($type == 'notCategId') {
                 foreach ($val as $v) {
                     $tmp_mid[] = '(tp.`pageName` NOT IN(SELECT itemId FROM tiki_objects INNER JOIN tiki_category_objects ON catObjectId = objectId WHERE type = "wiki page" AND categId = ?))';
                     $bindvars[] = $v;
                 }
             } elseif ($type == 'lang') {
                 $tmp_mid[] = 'tp.`lang`=?';
                 $bindvars[] = $val;
             } elseif ($type == 'structHead') {
                 $join_tables .= " inner join `tiki_structures` as ts on (ts.`page_id` = tp.`page_id` and ts.`parent_id` = 0) ";
                 $select .= ',ts.`page_alias`';
             } elseif ($type == 'langOrphan') {
                 $join_tables .= " left join `tiki_translated_objects` tro on (tro.`type` = 'wiki page' AND tro.`objId` = tp.`page_id`) ";
                 $tmp_mid[] = "( (tro.`traId` IS NULL AND tp.`lang` != ?) OR tro.`traId` NOT IN(SELECT `traId` FROM `tiki_translated_objects` WHERE `lang` = ?))";
                 $bindvars[] = $val;
                 $bindvars[] = $val;
             } elseif ($type == 'structure_orphans') {
                 $join_tables .= " left join `tiki_structures` as tss on (tss.`page_id` = tp.`page_id`) ";
                 $tmp_mid[] = "(tss.`page_ref_id` is null)";
             } elseif ($type == 'translationOrphan') {
                 $multilinguallib = TikiLib::lib('multilingual');
                 $multilinguallib->sqlTranslationOrphan('wiki page', 'tp', 'page_id', $val, $join_tables, $midto, $bindvars);
                 $tmp_mid[] = $midto;
             }
         }
         if (!empty($tmp_mid)) {
             $mid .= empty($mid) ? ' where (' : ' and (';
             $mid .= implode(' and ', $tmp_mid) . ')';
         }
     }
     if (!empty($initial)) {
         $mid .= empty($mid) ? ' where (' : ' and (';
         $tmp_mid = '';
         if (is_array($initial)) {
             foreach ($initial as $i) {
                 if (!empty($tmp_mid)) {
                     $tmp_mid .= ' or ';
                 }
                 $tmp_mid .= ' `pageName` like ? ';
                 $bindvars[] = $i . '%';
             }
         } else {
             $tmp_mid = " `pageName` like ? ";
             $bindvars[] = $initial . '%';
         }
         $mid .= $tmp_mid . ')';
     }
     if ($only_orphan_pages) {
         $join_tables .= ' left join `tiki_links` as tl on tp.`pageName` = tl.`toPage` left join `tiki_structures` as tsoo on tp.`page_id` = tsoo.`page_id`';
         $mid .= $mid == '' ? ' where ' : ' and ';
         $mid .= 'tl.`toPage` IS NULL and tsoo.`page_id` IS NULL';
     }
     if ($prefs['rating_advanced'] == 'y') {
         $ratinglib = TikiLib::lib('rating');
         $join_tables .= $ratinglib->convert_rating_sort($sort_mode, 'wiki page', '`page_id`');
     }
     if ($tiki_p_wiki_view_ratings === 'y' && $prefs['feature_polls'] == 'y' && $prefs['feature_wiki_ratings'] == 'y') {
         $select .= ', (select sum(`tiki_poll_options`.`title`*`tiki_poll_options`.`votes`) as rating from `tiki_objects` as tobt, `tiki_poll_objects` as tpo, `tiki_poll_options` where tobt.`itemId`= tp.`pageName` and tobt.`type`=\'wiki page\' and tobt.`objectId`=tpo.`catObjectId` and `tiki_poll_options`.`pollId`=tpo.`pollId` group by `tiki_poll_options`.`pollId`) as rating';
     }
     if (!empty($join_bindvars)) {
         $bindvars = empty($bindvars) ? $join_bindvars : array_merge($join_bindvars, $bindvars);
     }
     $query = "select {$distinct}" . ($onlyCant ? "tp.`pageName`" : "tp.* " . $select) . " from `tiki_pages` as tp {$join_tables} {$mid} order by " . $this->convertSortMode($sort_mode);
     $countquery = "select count({$distinct} tp.`pageName`) from `tiki_pages` as tp {$join_tables} {$mid}";
     $pageCount = $this->getOne($countquery, $bindvars);
     // HOTFIX (svn Rev. 22969 or near there)
     // Chunk loading. Because we cannot know what pages are visible, we load chunks of pages
     // and use Perms::filter to see what remains. Stop, if we have enough.
     $cant = 0;
     $n = -1;
     $ret = array();
     $raw = array();
     $offset_tmp = 0;
     $haveEnough = FALSE;
     $filterPerms = empty($ref) ? 'view' : array('view', 'wiki_view_ref');
     while (!$haveEnough) {
         $rawTemp = $this->fetchAll($query, $bindvars, $maxRecords, $offset_tmp);
         $offset_tmp += $maxRecords;
         // next offset
         if (count($rawTemp) == 0) {
             $haveEnough = TRUE;
         }
         // end of table
         $rawTemp = Perms::filter(array('type' => 'wiki page'), 'object', $rawTemp, array('object' => 'pageName', 'creator' => 'creator'), $filterPerms);
         $raw = array_merge($raw, $rawTemp);
         if (count($raw) >= $offset + $maxRecords || $maxRecords == -1) {
             $haveEnough = TRUE;
         }
         // now we have enough records
     }
     // prbably this brace has to include the next foreach??? I am unsure.
     // but if yes, the next lines have to be reviewed.
     $history = $this->table('tiki_history');
     $links = $this->table('tiki_links');
     foreach ($raw as $res) {
         if ($initial) {
             $valid = false;
             $verified = self::take_away_accent($res['pageName']);
             foreach ((array) $initial as $candidate) {
                 if (stripos($verified, $candidate) === 0) {
                     $valid = true;
                     break;
                 }
             }
             if (!$valid) {
                 continue;
             }
         }
         //WYSIWYCA
         $res['perms'] = $this->get_perm_object($res['pageName'], 'wiki page', $res, false);
         $n++;
         if (!$need_everything && $offset != -1 && $n < $offset) {
             continue;
         }
         if (!$onlyCant && ($need_everything || $maxRecords == -1 || $cant < $maxRecords)) {
             if ($onlyName) {
                 $res = array('pageName' => $res['pageName']);
             } else {
                 $page = $res['pageName'];
                 $res['len'] = $res['page_size'];
                 unset($res['page_size']);
                 $res['flag'] = $res['flag'] == 'L' ? 'locked' : 'unlocked';
                 if ($forListPages && $prefs['wiki_list_versions'] == 'y') {
                     $res['versions'] = $history->fetchCount(array('pageName' => $page));
                 }
                 if ($forListPages && $prefs['wiki_list_links'] == 'y') {
                     $res['links'] = $links->fetchCount(array('fromPage' => $page));
                 }
                 if ($forListPages && $prefs['wiki_list_backlinks'] == 'y') {
                     $res['backlinks'] = $links->fetchCount(array('toPage' => $page, 'fromPage' => $links->unlike('objectlink:%')));
                 }
                 // backlinks do not include links from non-page objects TODO: full feature allowing this with options
             }
             if ($loadCategories) {
                 $cats = $categlib->get_object_categories('wiki page', $res['pageName']);
                 $res['categpath'] = array();
                 $res['categname'] = array();
                 foreach ($cats as $cat) {
                     $res['categpath'][] = $cp = $categlib->get_category_path_string($cat);
                     if ($s = strrchr($cp, ':')) {
                         $res['categname'][] = substr($s, 1);
                     } else {
                         $res['categname'][] = $cp;
                     }
                 }
             }
             $ret[] = $res;
         }
         $cant++;
     }
     if (!$need_everything) {
         $cant += $offset;
     }
     // If sortmode is versions, links or backlinks sort using the ad-hoc function and reduce using old_offset and old_maxRecords
     if ($need_everything) {
         switch ($old_sort_mode) {
             case 'versions_asc':
                 usort($ret, 'compare_versions');
                 break;
             case 'versions_desc':
                 usort($ret, 'r_compare_versions');
                 break;
             case 'links_desc':
                 usort($ret, 'compare_links');
                 break;
             case 'links_asc':
                 usort($ret, 'r_compare_links');
                 break;
             case 'backlinks_desc':
                 usort($ret, 'compare_backlinks');
                 break;
             case 'backlinks_asc':
                 usort($ret, 'r_compare_backlinks');
                 break;
         }
     }
     $retval = array();
     $retval['data'] = $ret;
     $retval['cant'] = $pageCount;
     // this is not exact. Workaround.
     return $retval;
 }
						$smarty->assign('exportEOL', $_REQUEST['exportEOL']);
						$smarty->assign('exportQuote', $_REQUEST['exportQuote']);
						$smarty->assign('bookAutoTax', $_REQUEST['bookAutoTax']);
					}
					break;
	case 'close'  : 
		if (!$globalperms->acct_create_book) {
			$smarty->assign('msg', tra("You do not have permissions to close this book") . ": feature_accounting");
			$smarty->display("error.tpl");
			die;
		}
		$accountinglib->closeBook($_REQUEST['bookId']);
					break;
	case 'view'   :
					break;
	default ://list
}
$books=$accountinglib->listBooks();
$filtered = Perms::filter(
				array( 'type' => 'accounting book'), 
				'object',
				$books,
				array( 'object' => 'bookName' ),
				'acct_view'
);
$smarty->assign('books', $books);
$smarty->assign('canCreate', $globalperms->acct_create_book);
ask_ticket('accounting');
$smarty->assign('mid', 'tiki-accounting_books.tpl');
$smarty->display("tiki.tpl");
 function hasOnlyPrivateBacklinks($fileId)
 {
     $objects = $this->getFileBacklinks($fileId);
     if (empty($objects)) {
         return false;
     }
     foreach ($objects as $object) {
         $pobjects[$object['type']][] = $object;
     }
     include_once 'lib/objectlib.php';
     $map = ObjectLib::map_object_type_to_permission();
     foreach ($pobjects as $type => $list) {
         if ($type == 'blog post') {
             $this->parentObjects($list, 'tiki_blog_posts', 'postId', 'blogId');
             $f = Perms::filter(array('type' => 'blog'), 'object', $list, array('object' => 'blogId'), str_replace('tiki_p_', '', $map['blog']));
         } elseif (strstr($type, 'comment')) {
             $this->parentObjects($list, 'tiki_comments', 'threadId', 'object');
             $t = str_replace(' comment', '', $type);
             $f = Perms::filter(array('type' => $t), 'object', $list, array('object' => 'object'), str_replace('tiki_p_', '', $map[$t]));
         } elseif ($type == 'forum post') {
             $this->parentObjects($list, 'tiki_comments', 'threadId', 'object');
             $f = Perms::filter(array('type' => 'forum'), 'object', $list, array('object' => 'object'), str_replace('tiki_p_', '', $map['forum']));
         } elseif ($type == 'trackeritem') {
             $this->parentObjects($list, 'tiki_tracker_items', 'itemId', 'trackerId');
             $f = Perms::filter(array('type' => 'tracker'), 'object', $list, array('object' => 'trackerId'), str_replace('tiki_p_', '', $map['tracker']));
             //NEED to check item perm
         } else {
             $f = Perms::filter(array('type' => $type), 'object', $list, array('object' => 'itemId'), str_replace('tiki_p_', '', $map[$type]));
         }
         $debug = 0;
         if (!empty($debug)) {
             echo "<br />FILE{$fileId}";
             if (!empty($f)) {
                 echo 'OK-';
             } else {
                 echo 'NO-';
             }
             foreach ($list as $l) {
                 echo $l['type'] . ': ' . $l['itemId'] . '(' . $l['href'] . ')' . ',';
             }
         }
         if (!empty($f)) {
             return false;
         }
     }
     return true;
 }
Exemple #9
0
        $page_ref_id = $_REQUEST['page_ref_id'];
    } else {
        // else check if page is the head of a structure
        $page_ref_id = $structlib->get_struct_ref_if_head($_REQUEST['page']);
    }
    //If a structure page isnt going to be displayed
    if (empty($page_ref_id)) {
        //Check to see if its a member of any structures
        if (isset($_REQUEST['structure']) && !empty($_REQUEST['structure'])) {
            $struct = $_REQUEST['structure'];
        } else {
            $struct = '';
        }
        //Get the structures this page is a member of
        $structs = $structlib->get_page_structures($_REQUEST['page'], $struct);
        $structs_with_perm = Perms::filter(array('type' => 'wiki page'), 'object', $structs, array('object' => 'permName'), 'view');
        //If page is only member of one structure, display if requested
        $single_struct = count($structs_with_perm) == 1;
        if ((!empty($struct) || $prefs['feature_wiki_open_as_structure'] == 'y') && $single_struct) {
            $page_ref_id = $structs_with_perm[0]['req_page_ref_id'];
            $_REQUEST['page_ref_id'] = $page_ref_id;
        }
    }
} elseif (!empty($_REQUEST['page_ref_id'])) {
    $smarty->assign('msg', tra('This feature is disabled') . ': feature_wiki_structure');
    $smarty->display('error.tpl');
    die;
}
if (!empty($page_ref_id)) {
    $page_info = $structlib->s_get_page_info($page_ref_id);
    $info = null;
	function filter_categ_items($ret)
	{
		// FIXME: this is an approximation - the perm should be function of the status
		$categlib = TikiLib::lib('categ');
		if (!empty($ret[0]['itemId']) && $categlib->is_categorized('trackeritem', $ret[0]['itemId'])) {
			return Perms::filter(array('type' => 'trackeritem'), 'object', $ret, array('object' => 'itemId'), 'view_trackers');
		} else {
			return $ret;
		}
	}
 function list_perspectives($offset = 0, $maxRecords = -1)
 {
     $db = TikiDb::get();
     $list = $db->fetchAll("SELECT perspectiveId, name FROM tiki_perspectives", array(), $maxRecords, $offset);
     $list = Perms::filter(array('type' => 'perspective'), 'object', $list, array('object' => 'perspectiveId'), 'perspective_view');
     foreach ($list as &$info) {
         $perms = Perms::get(array('type' => 'perspective', 'object' => $info['perspectiveId']));
         $this->write_permissions($info, $perms);
     }
     return $list;
 }
Exemple #12
0
     $cats = $categlib->get_default_categories();
 }
 if ($cat_type == 'wiki page' || $cat_type == 'blog' || $cat_type == 'image gallery' || $cat_type == 'mypage') {
     $ext = $cat_type == 'wiki page' ? 'wiki' : str_replace(' ', '_', $cat_type);
     $pref = 'feature_' . $ext . '_mandatory_category';
     if ($prefs[$pref] > 0) {
         $categories = $categlib->getCategories(array('identifier' => $prefs[$pref], 'type' => 'descendants'));
     } else {
         $categories = $categlib->getCategories();
     }
     $smarty->assign('mandatory_category', $prefs[$pref]);
 } else {
     $categories = $categlib->getCategories();
 }
 $can = $catobjperms->modify_object_categories;
 $categories = Perms::filter(array('type' => 'category'), 'object', $categories, array('object' => 'categId'), array('view_category'));
 foreach ($categories as &$category) {
     $catperms = Perms::get(array('type' => 'category', 'object' => $category['categId']));
     if (in_array($category["categId"], $cats)) {
         $category["incat"] = 'y';
         $category['canchange'] = !$cat_object_exists || $can && $catperms->remove_object;
     } else {
         $category["incat"] = 'n';
         $category['canchange'] = $can && $catperms->add_object;
     }
     // allow to preselect categories when creating a new article
     // like this: /tiki-edit_article.php?cat_categories[]=1&cat_categorize=on
     if (!$cat_object_exists && isset($_REQUEST["cat_categories"]) && isset($_REQUEST["cat_categorize"]) && $_REQUEST["cat_categorize"] == 'on') {
         if (in_array($category["categId"], $_REQUEST["cat_categories"])) {
             $category["incat"] = 'y';
         } else {
Exemple #13
0
 function testContextBuilding()
 {
     $perms = new Perms();
     $perms->setResolverFactories(array($mock = $this->getMock('Perms_ResolverFactory')));
     Perms::set($perms);
     $mock->expects($this->once())->method('getResolver')->with($this->equalTo(array('type' => 'wiki page', 'object' => 'Hello World', 'creator' => 'admin')))->will($this->returnValue(null));
     $mock->expects($this->once())->method('bulk');
     $data = array(array('pageId' => 1, 'pageName' => 'Hello World', 'content' => 'Hello World', 'creator' => 'admin'));
     Perms::filter(array('type' => 'wiki page'), 'object', $data, array('object' => 'pageName', 'creator' => 'creator'), 'view');
 }
Exemple #14
0
 /**
  * @param $limit
  * @param bool $toponly
  * @param string $forumId
  * @return mixed
  */
 function forums_ranking_last_posts($limit, $toponly = false, $forumId = '')
 {
     global $user;
     $commentslib = TikiLib::lib('comments');
     $offset = 0;
     $count = 0;
     $ret = array();
     $result = $commentslib->get_all_comments('forum', 0, $limit, 'commentDate_desc', '', '', '', $toponly, $forumId);
     $result['data'] = Perms::filter(array('type' => 'forum'), 'object', $result['data'], array('object' => 'object'), 'forum_read');
     foreach ($result['data'] as $res) {
         $aux['name'] = $res['title'];
         $aux['title'] = $res['parentTitle'];
         $tmp = $res['parentId'];
         if ($tmp == 0) {
             $tmp = $res['threadId'];
         }
         $aux['href'] = $res['href'];
         $aux['hits'] = $this->get_long_datetime($res['commentDate']);
         $tmp = $res['parentId'];
         if ($tmp == 0) {
             $tmp = $res['threadId'];
         }
         $aux['date'] = $res['commentDate'];
         $aux['user'] = $res['userName'];
         $ret[] = $aux;
     }
     $retval["data"] = $ret;
     $retval["title"] = tra("Forums last posts");
     $retval["y"] = tra("Topic date");
     $retval["type"] = "date";
     return $retval;
 }
$smarty->assign('daysnames', $daysnames);
$smarty->assign('daysnames_abr', $daysnames_abr);
$smarty->assign('monthnames', $monthnames);
$smarty->assign('edit', false);
$smarty->assign('recurrent', '');
$hour_minmax = '';
$recurrence = array('id' => '', 'weekly' => '', 'weekday' => '', 'monthly' => '', 'dayOfMonth' => '', 'yearly' => '', 'dateOfYear_day' => '', 'dateOfYear_month' => '', 'startPeriod' => '', 'nbRecurrences' => '', 'endPeriod' => '');
$smarty->assign('recurrence', $recurrence);
$caladd = array();
$rawcals = $calendarlib->list_calendars();
if ($rawcals['cant'] == 0 && $tiki_p_admin_calendar == 'y') {
    $smarty->assign('msg', tra('You need to <a href="tiki-admin_calendars.php?cookietab=2">create a calendar</a>'));
    $smarty->display("error.tpl");
    die;
}
$rawcals['data'] = Perms::filter(array('type' => 'calendar'), 'object', $rawcals['data'], array('object' => 'calendarId'), 'view_calendar');
foreach ($rawcals["data"] as $cal_data) {
    $cal_id = $cal_data['calendarId'];
    $calperms = Perms::get(array('type' => 'calendar', 'object' => $cal_id));
    if ($cal_data["personal"] == "y") {
        if ($user) {
            $cal_data["tiki_p_view_calendar"] = 'y';
            $cal_data["tiki_p_view_events"] = 'y';
            $cal_data["tiki_p_add_events"] = 'y';
            $cal_data["tiki_p_change_events"] = 'y';
        } else {
            $cal_data["tiki_p_view_calendar"] = 'n';
            $cal_data["tiki_p_view_events"] = 'y';
            $cal_data["tiki_p_add_events"] = 'n';
            $cal_data["tiki_p_change_events"] = 'n';
        }
 function get_user_forum_comments($user, $max, $type = '')
 {
     // get parent title as well, especially useful in flat forum
     $parentinfo = '';
     $mid = '';
     if ($type == 'replies') {
         $parentinfo .= ", b.`title` as parentTitle";
         $mid .= " inner join `tiki_comments` b on b.`threadId` = a.`parentId`";
     }
     $mid .= " where a.`objectType`='forum' AND a.`userName`=?";
     if ($type == 'topics') {
         $mid .= " AND a.`parentId`=0";
     } elseif ($type == 'replies') {
         $mid .= " AND a.`parentId`>0";
     }
     $query = "select a.`threadId`, a.`object`, a.`title`, a.`parentId`, a.`commentDate` {$parentinfo}, a.`userName` from `tiki_comments` a {$mid} ORDER BY a.`commentDate` desc";
     $result = $this->fetchAll($query, array($user), $max);
     $ret = Perms::filter(array('type' => 'forum'), 'object', $result, array('object' => 'object', 'creator' => 'userName'), 'forum_read');
     return $ret;
 }
Exemple #17
0
	function get_last_changes($days, $offset = 0, $limit = -1, $sort_mode = 'lastModif_desc', $findwhat = '')
	{
	        global $user;

		$bindvars = array();
		$categories = $this->get_jail();
		if (!isset($categjoin)) $categjoin = '';
		if ($categories) {
			$categjoin .= "inner join `tiki_objects` as tob on (tob.`itemId`= ta.`object` and tob.`type`= ?) inner join `tiki_category_objects` as tc on (tc.`catObjectId`=tob.`objectId` and tc.`categId` IN(" . implode(', ', array_fill(0, count($categories), '?')) . ")) ";
			$bindvars = array_merge(array('wiki page'), $categories);
		}

		$where = "where true ";
		if ($findwhat) {
			$findstr='%' . $findwhat . '%';
			$where.= " and ta.`object` like ? or ta.`user` like ? or ta.`comment` like ?";
			$bindvars = array_merge($bindvars, array($findstr,$findstr,$findstr));
		}

		if ($days) {
			$toTime = $this->make_time(23, 59, 59, $this->date_format("%m"), $this->date_format("%d"), $this->date_format("%Y"));
			$fromTime = $toTime - (24 * 60 * 60 * $days);
			$where .= " and ta.`lastModif`>=? and ta.`lastModif`<=? ";
			$bindvars[] = $fromTime;
			$bindvars[] = $toTime;
		}

		// WARNING: This assumes the current version of each page will be found in tiki_history
		$query = "select distinct ta.`action`, ta.`lastModif`, ta.`user`, ta.`ip`, ta.`object`, thf.`comment`, thf.`version`, thf.`page_id` from `tiki_actionlog` ta 
			inner join (select th.`version`, th.`comment`, th.`pageName`, th.`lastModif`, tp.`page_id` from `tiki_history` as th LEFT OUTER JOIN `tiki_pages` tp ON tp.`pageName` = th.`pageName` AND tp.`version` = th.`version`) as thf on ta.`object`=thf.`pageName` and ta.`lastModif`=thf.`lastModif` and ta.`objectType`='wiki page' " . $categjoin . $where . " order by ta.".$this->convertSortMode($sort_mode);

		// TODO: Optimize. This fetches all records just to be able to give a count.
		$result = Perms::filter(array( 'type' => 'wiki page' ), 'object', $this->fetchAll($query, $bindvars), array( 'object' => 'object' ), 'view');
		$cant = count($result);
		$ret = array();
		
		if ($limit == -1) {
			$result = array_slice($result, $offset);
		} else {
			$result = array_slice($result, $offset, $limit);
		}
		foreach ($result as $res ) {
			$res['current'] = isset($res['page_id']);
			$res['pageName'] = $res['object'];
			$ret[] = $res;
		}

		return array('data' => $ret, 'cant' => $cant);
	}