Beispiel #1
1
 function handleSave($value, $oldValue)
 {
     global $prefs, $user;
     $tikilib = TikiLib::lib('tiki');
     $trackerId = $this->getConfiguration('trackerId');
     $file_name = $this->getConfiguration('file_name');
     $file_size = $this->getConfiguration('file_size');
     $file_type = $this->getConfiguration('file_type');
     $perms = Perms::get('tracker', $trackerId);
     if ($perms->attach_trackers && $file_name) {
         if ($prefs['t_use_db'] == 'n') {
             $fhash = md5($file_name . $tikilib->now);
             if (file_put_contents($prefs['t_use_dir'] . $fhash, $value) === false) {
                 $smarty = TikiLib::lib('smarty');
                 $smarty->assign('msg', tra('Cannot write to this file:') . $fhash);
                 $smarty->display("error.tpl");
                 die;
             }
             $value = '';
         } else {
             $fhash = 0;
         }
         $trklib = TikiLib::lib('trk');
         $value = $trklib->replace_item_attachment($oldValue, $file_name, $file_type, $file_size, $value, '', $user, $fhash, '', '', $trackerId, $this->getItemId(), '', false);
     }
     return array('value' => $value);
 }
 public function perms()
 {
     if ($this->requiresPermission('manage roles', $this->name)) {
         Fabriq::title('Admin | Manage permissions');
         FabriqModules::add_css('roles', 'roles');
         $perms = new Perms();
         $perms->getAll();
         $modules = new Modules();
         $modules->getEnabled();
         $roles = FabriqModules::new_model('roles', 'Roles');
         $roles->getRoles();
         $modulePerms = FabriqModules::new_model('roles', 'ModulePerms');
         $modulePerms->getAll();
         $permissions = array();
         foreach ($perms as $perm) {
             $permissions[$perm->id] = array();
             foreach ($roles as $role) {
                 if (isset($modulePerms->perms[$perm->id][$role->id])) {
                     $permissions[$perm->id][$role->id] = 1;
                 } else {
                     $permissions[$perm->id][$role->id] = 0;
                 }
             }
         }
         if (isset($_POST['submit'])) {
             foreach ($perms as $perm) {
                 foreach ($roles as $role) {
                     if (isset($_POST['permission'][$perm->id][$role->id])) {
                         $permissions[$perm->id][$role->id] = 1;
                         // add to database if it's not already set
                         if (!isset($modulePerms->perms[$perm->id][$role->id])) {
                             $p = FabriqModules::new_model('roles', 'ModulePerms');
                             $p->permission = $perm->id;
                             $p->role = $role->id;
                             $p->id = $p->create();
                             $modulePerms->perms[$perm->id][$role->id] = $modulePerms->count();
                             $modulePerms->add($p);
                         }
                     } else {
                         $permissions[$perm->id][$role->id] = 0;
                         // remove from database if it is already set
                         if (isset($modulePerms->perms[$perm->id][$role->id])) {
                             $p = FabriqModules::new_model('roles', 'ModulePerms');
                             $p->find($modulePerms[$modulePerms->perms[$perm->id][$role->id]]->id);
                             $p->destroy();
                             $modulePerms->remove($modulePerms->perms[$perm->id][$role->id]);
                             $modulePerms->reindex();
                         }
                     }
                 }
             }
             Messaging::message('Permissions have been updated.', 'success');
         }
         FabriqModules::set_var($this->name, 'perms', $perms);
         FabriqModules::set_var($this->name, 'modules', $modules);
         FabriqModules::set_var($this->name, 'roles', $roles);
         FabriqModules::set_var($this->name, 'permissions', $permissions);
     }
 }
 function setUp()
 {
     $perms = new Perms();
     $perms->setCheckSequence(array($this->globalAlternate = new Perms_Check_Alternate('admin'), new Perms_Check_Direct()));
     $perms->setResolverFactories(array(new Perms_ResolverFactory_StaticFactory('global', new Perms_Resolver_Static(array('Anonymous' => array('tiki_p_view'), 'Registered' => array('tiki_p_view', 'tiki_p_topic_read'))))));
     $index = new Search_Index_Memory();
     $indexer = new Search_Indexer($index);
     $this->indexer = $indexer;
     $this->index = $index;
     $this->perms = $perms;
 }
function module_contributors($mod_reference, $module_params)
{
	global $smarty, $userlib, $wikilib, $tikilib, $headerlib;
	$currentObject = current_object();
	if ($currentObject['type'] == 'wiki page') {
		$objectperms = Perms::get(array('type' => 'wiki page', 'object' => $currentObject['object']));
		if ($objectperms->view) {
			$contributors = $wikilib->get_contributors($currentObject['object']);
			$contributors_details = array();
			$headerlib->add_css('div.contributors div br {clear: both;}'); // Avoid avatar conflicts with lines below
			foreach ($contributors as $contributor) {
				$details = array('login' => $contributor);
				$details['realName'] = $userlib->get_user_preference($contributor, 'realName');
				$country = $tikilib->get_user_preference($contributor, 'country');
				if (!is_null($country) && $country != 'Other') {
					$details['country'] = $country;
				}
				$email_isPublic = $tikilib->get_user_preference($contributor, 'email is public');
				if ($email_isPublic != 'n') {
					include_once ('lib/userprefs/scrambleEmail.php');
					$details['email'] = $userlib->get_user_email($contributor);
					$details['scrambledEmail'] = scrambleEmail($details['email'], $email_isPublic);
				}
				$details['homePage'] = $tikilib->get_user_preference($contributor, 'homePage');
				$details['avatar'] = $tikilib->get_user_avatar($contributor);
				$contributors_details[] = $details;
			}
			$smarty->assign_by_ref('contributors_details', $contributors_details);
			$hiddenContributors = count($contributors_details) - 5;
			if ($hiddenContributors > 0) {
				$smarty->assign('hiddenContributors', $hiddenContributors);
			}
		}		
	}
}
Beispiel #5
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;
 }
/**
* Generates a link to the object permission screen, and verifies if there are
* active permissions to render the link differently as required.
*
* Important parameters: type and id, for the target object - otherwise global
*                       permType, if different from type
*                       title, the name of the object
*
* Almost mandatory: mode, display style of the button
*                      glyph: simple fa (Font Awesome)
*                      icon: classic tiki icon
*                      link: plain text link (label)
*                      text: glyph + label
*                      button: button with label
*                      button_link: button with label (btn-link)
*
* Occasional: label, alter the displayed text from default
              group, parameter to objectpermissions
			   textFilter, parameter to objectpermissions
			   showDisabled, parameter to objectpermissions
			   addclass: add classes separated by spaces
*/
function smarty_function_permission_link($params, $smarty)
{
    $params = new JitFilter($params);
    $type = $params->type->text();
    $id = $params->id->text();
    $objectlib = TikiLib::lib('object');
    if (isset($params['type'], $params['id'])) {
        $arguments = ['objectType' => $type, 'objectId' => $id, 'permType' => $type, 'objectName' => $params->title->text() ?: $objectlib->get_title($type, $id)];
    } else {
        $arguments = [];
    }
    if ($params->permType->text()) {
        $arguments['permType'] = $params->permType->text();
    }
    if ($params->textFilter->text()) {
        $arguments['textFilter'] = $params->textFilter->text();
    }
    if ($params->group->groupname()) {
        $arguments['group'] = $params->group->groupname();
    }
    if ($params->showDisabled->word() == 'y') {
        $arguments['show_disabled_features'] = 'y';
    }
    if (!empty($arguments)) {
        $link = 'tiki-objectpermissions.php?' . http_build_query($arguments, '', '&');
    } else {
        $link = 'tiki-objectpermissions.php';
    }
    $perms = Perms::get($type, $id);
    $source = $perms->getResolver()->from();
    return $smarty->fetch('permission_link.tpl', ['permission_link' => ['url' => $link, 'active' => $source == 'object', 'mode' => $params->mode->word() ?: 'glyph', 'label' => $params->label->text() ?: tr('Permissions'), 'count' => $params->count->int(), 'type' => $type, 'addclass' => $params->addclass->text()]]);
}
Beispiel #7
0
 public static function checkObject($perm, $type, $object)
 {
     $perms = Perms::get($type, $object);
     if (!$perms->{$perm}) {
         throw new self(tr('Permission denied'));
     }
 }
function wikiplugin_bigbluebutton($data, $params)
{
    try {
        global $smarty, $prefs, $user;
        $bigbluebuttonlib = TikiLib::lib('bigbluebutton');
        $meeting = $params['name'];
        // Meeting is more descriptive than name, but parameter name was already decided.
        $smarty->assign('bbb_meeting', $meeting);
        $smarty->assign('bbb_image', parse_url($prefs['bigbluebutton_server_location'], PHP_URL_SCHEME) . '://' . parse_url($prefs['bigbluebutton_server_location'], PHP_URL_HOST) . '/images/bbb_logo.png');
        $perms = Perms::get('bigbluebutton', $meeting);
        $params = array_merge(array('prefix' => ''), $params);
        // This is incomplete, will only apply if the dynamic feature is enabled. To be completed.
        $params['configuration'] = array('presentation' => array('active' => false));
        $smarty->assign('bbb_params', Tiki_Security::get()->encode($params));
        if (!$bigbluebuttonlib->roomExists($meeting)) {
            if (!isset($_POST['bbb']) || $_POST['bbb'] != $meeting || !$perms->bigbluebutton_create) {
                $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));
                return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_create.tpl');
            }
        }
        if ($perms->bigbluebutton_join) {
            $smarty->assign('bbb_attendees', $bigbluebuttonlib->getAttendees($meeting));
            if ($perms->bigbluebutton_view_rec) {
                $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));
            }
            return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton.tpl');
        } elseif ($perms->bigbluebutton_view_rec) {
            # Case for anonymous users with the perm to view recordings but not to join meetings
            $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));
            return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_view_recordings.tpl');
        }
    } catch (Exception $e) {
        return WikiParser_PluginOutput::internalError(tr('BigBlueButton misconfigured or unaccessible.'));
    }
}
Beispiel #9
0
 function setUp()
 {
     if (!Perms::get()->admin) {
         throw new Services_Exception(tr('Permission Denied'), 403);
     }
     $this->lib = TikiLib::lib('activity');
 }
function wikiplugin_transclude( $data, $params )
{
	if ( ! isset( $params['page'] ) ) {
		return WikiParser_PluginOutput::argumentError(array( 'page' ));
	}
	
	$page = $params['page'];
	unset($params['page']);

	global $tikilib;

	if ( ! Perms::get('wiki page', $page)->view ) {
		return WikiParser_PluginOutput::error(tra('Permission Denied'), tra('Attempt to include a page that cannot be viewed.'));
	}

	if ( $info = $tikilib->get_page_info($page) ) {
		$parts = preg_split('/%%%text%%%/', $info['data']);
		$data = $tikilib->parse_data($data);
                $pass = $parts[0] . $data . $parts[1];
		return preg_replace_callback(
						'/%%%([A-z0-9]+)%%%/',
						array( new WikiPlugin_Transclude_Replacer($params), 'callback' ),
						$pass
		);
	} else {
		return WikiParser_PluginOutput::error(tr('Page not found'), tr('Page named "%0" does not exist at this time.', $page));
	}
}
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_menupage($mod_reference, $module_params)
{
    if (!empty($module_params['pagemenu'])) {
        $wikilib = TikiLib::lib('wiki');
        $menulib = TikiLib::lib('menu');
        $smarty = TikiLib::lib('smarty');
        $pagemenu = $module_params['pagemenu'];
        if (!empty($module_params['use_namespace'])) {
            $pagemenu = $wikilib->include_default_namespace($pagemenu);
        }
        $perms = Perms::get(array('object' => $pagemenu, 'type' => 'wiki page'));
        if ($perms->view) {
            $content = $wikilib->get_parse($pagemenu, $dummy, true);
        } else {
            $content = '<label class="error">' . tra("You are not logged in") . '</label>';
        }
        if (!empty($content) && !empty($module_params['menu_type']) && in_array($module_params['menu_type'], array('horiz', 'vert'))) {
            $class = 'cssmenu_' . $module_params['menu_type'];
            $content = preg_replace_callback('/<(ul|ol|li)([^>]*)>/Umi', function ($matches) use($class) {
                if ($matches[1] == 'li') {
                    $class = 'menuSection';
                }
                return "<{$matches[1]} class=\"{$class}\" {$matches[2]}>";
            }, $content);
            $content = $menulib->clean_menu_html($content);
        }
        $smarty->assign('tpl_module_title', $wikilib->get_without_namespace($pagemenu));
        $smarty->assign_by_ref('contentmenu', $content);
    }
}
Beispiel #12
0
 /**
  * @param $offset
  * @param $maxRecords
  * @param string $sort_mode
  * @param null $find
  * @return array
  */
 public function list_quizzes($offset, $maxRecords, $sort_mode = 'name_desc', $find = null)
 {
     $quizzes = $this->table('tiki_quizzes');
     $conditions = array();
     if (!empty($find)) {
         $findesc = '%' . $find . '%';
         $conditions['search'] = $quizzes->expr('(`name` like ? or `description` like ?)', array($findesc, $findesc));
     }
     $result = $quizzes->fetchColumn('quizId', $conditions);
     $res = $ret = $retids = array();
     $n = 0;
     //FIXME Perm:filter ?
     foreach ($result as $res) {
         $objperm = Perms::get('quizzes', $res);
         if ($objperm->take_quiz) {
             if ($maxRecords == -1 || $n >= $offset && $n < $offset + $maxRecords) {
                 $retids[] = $res;
             }
             $n++;
         }
     }
     if ($n > 0) {
         $result = $quizzes->fetchAll($quizzes->all(), array('quizId' => $quizzes->in($retids)), -1, -1, $quizzes->expr($this->convertSortMode($sort_mode)));
         $questions = $this->table('tiki_quiz_questions');
         $results = $this->table('tiki_quiz_results');
         foreach ($result as $res) {
             $res['questions'] = $questions->fetchCount(array('quizId' => (int) $res['quizId']));
             $res['results'] = $results->fetchCount(array('quizId' => (int) $res['quizId']));
             $ret[] = $res;
         }
     }
     return array('data' => $ret, 'cant' => $n);
 }
function module_last_category_objects($mod_reference, $module_params)
{
	global $smarty;

	if (!isset($module_params['type'])) {
		$module_params['type'] = 'wiki page';
	}

	if ($module_params['type'] == '*') {
		$module_params['type'] = '';
	}

	global $categlib;
	require_once ('lib/categories/categlib.php');

	$last = $categlib->last_category_objects($module_params['id'], $mod_reference['rows'], $module_params['type']);

	$categperms = Perms::get(array('type' => 'category', 'object' => $module_params['id']));
	$jail = $categlib->get_jail();
	$smarty->assign(
					'mod_can_view', 
					$categperms->view_category && (empty($jail) || in_array($module_params['id'], $jail))
	);

	if (!is_array($last) or !is_array($last['data'])) {
		$last['data'][]['name'] = tra('no object here yet');
	}

	$smarty->assign('last', $last['data']);
	$smarty->assign('type', $module_params['type']);
	$smarty->assign('maxlen', isset($module_params['maxlen']) ? $module_params['maxlen'] : 0);
}
Beispiel #14
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Clearing tracker...</info>');
     $trackerId = $input->getArgument('trackerId');
     $tracker = \Tracker_Definition::get($trackerId);
     if (!$tracker) {
         throw new \Exception('Tracker Clear: Tracker not found');
     }
     $perms = \Perms::get('tracker', $trackerId);
     if (!$perms->admin_trackers) {
         throw new \Exception('Tracker Clear: Admin permission required');
     }
     $confirm = $input->getOption('confirm');
     $utilities = new \Services_Tracker_Utilities();
     if ($confirm) {
         $utilities->clearTracker($trackerId);
         $output->writeln('<info>Tracker clear done</info>');
     } else {
         $name = $tracker->getConfiguration('name');
         $output->writeln("<info>Use the --confirm option to proceed with the clear operation.</info>");
         $output->writeln("<info>  There is NO undo and no notifications will be sent.</info>");
         $output->writeln("<info>  All items in tracker #{$trackerId} \"{$name}\" will be deleted.</info>");
     }
     return 0;
 }
function module_freetags_current($mod_reference, $module_params)
{
	global $user, $page, $smarty;
	global $freetaglib;

	include_once 'lib/freetag/freetaglib.php';

	$objectperms = Perms::get(array('type' => 'wiki page', 'object' => $page));
	if (! empty($page) && $objectperms->view) {
		if ($objectperms->edit && $objectperms->freetags_tag) {
			if (isset($_POST['mod_add_tags'])) {
				$freetaglib->tag_object($user, $page, 'wiki page', $_POST['tags']);
				header("Location: {$_SERVER['REQUEST_URI']}");
				exit;
			}
			$smarty->assign('addFreetags', "y");
			$canTag = true;
		} else {
			$canTag = false;
		}

		$smarty->assign('tpl_module_title', tra('Freetags'));

		$currenttags = $freetaglib->get_tags_on_object($page, 'wiki page');
		if (count($currenttags['data']) || $canTag) {
			$smarty->assign('modFreetagsCurrent', $currenttags);
		}
	}
}
Beispiel #16
0
 /**
  * @param $transitionId
  * @param $object
  * @param null $type
  * @return bool
  */
 function triggerTransition($transitionId, $object, $type = null)
 {
     // Make sure the transition exists
     if (!($transition = $this->getTransition($transitionId))) {
         return false;
     }
     // Make sure the user can use it
     $perms = Perms::get(array('type' => 'transition', 'object' => $transitionId));
     if (!$perms->trigger_transition) {
         return false;
     }
     // Verify that the states are consistent
     $states = $this->getCurrentStates($object, $type);
     $tr = new Tiki_Transition($transition['from'], $transition['to']);
     $tr->setStates($states);
     foreach ($transition['guards'] as $guard) {
         call_user_func_array(array($tr, 'addGuard'), $guard);
     }
     if (!$tr->isReady()) {
         return false;
     }
     $this->addState($transition['to'], $object, $type);
     if (!$transition['preserve']) {
         $this->removeState($transition['from'], $object, $type);
     }
     return true;
 }
Beispiel #17
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Importing tracker...');
     $lib = \TikiLib::lib('tabular');
     $info = $lib->getInfo($input->getArgument('tabularId'));
     $perms = \Perms::get('tabular', $info['tabularId']);
     if (!$info || !$perms->tabular_import) {
         throw new \Exception('Tracker Import: Tabular Format not found');
     }
     $fileName = $input->getArgument('filename');
     if (!file_exists($fileName)) {
         throw new \Exception('Tracker Import: File not found');
     }
     // from \Services_Tracker_TabularController::getSchema TODO refactor?
     $tracker = \Tracker_Definition::get($info['trackerId']);
     if (!$tracker) {
         throw new \Exception('Tracker Import: Tracker not found');
     }
     $schema = new \Tracker\Tabular\Schema($tracker);
     $schema->loadFormatDescriptor($info['format_descriptor']);
     $schema->loadFilterDescriptor($info['filter_descriptor']);
     $schema->validate();
     if (!$schema->getPrimaryKey()) {
         throw new \Exception(tr('Primary Key required'));
     }
     // this will throw exceptions and not return if there's a problem
     $source = new \Tracker\Tabular\Source\CsvSource($schema, $fileName);
     $writer = new \Tracker\Tabular\Writer\TrackerWriter();
     $writer->write($source);
     $output->writeln('Import done');
     return 0;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $confirm = $input->getOption('confirm');
     $perms = \Perms::get();
     if (!$perms->admin_file_galleries) {
         throw new \Exception('Tracker Clear: Admin permission required');
     }
     if ($confirm) {
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             $output->writeln('<info>Deleting old filegal files...</info>');
         }
         \TikiLib::lib('filegal')->deleteOldFiles();
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             $output->writeln('<info>Deleting old filegal files done</info>');
         }
     } else {
         $query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
         $now = time();
         $files = \TikiDb::get()->query($query, array($now));
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             if ($files->numrows) {
                 $output->writeln("<comment>Files to delete:</comment>");
                 foreach ($files->result as $file) {
                     $old = ceil(abs($now - $file['lastModif']) / 86400);
                     $days = $old > 1 ? 'days' : 'day';
                     $deleteAfter = \TikiLib::lib('tiki')->get_short_datetime($file['deleteAfter']);
                     $output->writeln("<info>    \"{$file['name']}\" is {$old} {$days} old in gallery #{$file['galleryId']} (id #{$file['fileId']} deleteAfter {$deleteAfter})</info>");
                 }
             } else {
                 $output->writeln("<comment>No files to delete</comment>");
             }
         }
     }
 }
function wikiplugin_listexecute($data, $params)
{
    $unifiedsearchlib = TikiLib::lib('unifiedsearch');
    $actions = array();
    $factory = new Search_Action_Factory();
    $factory->register(array('change_status' => 'Search_Action_ChangeStatusAction', 'delete' => 'Search_Action_Delete', 'email' => 'Search_Action_EmailAction', 'wiki_approval' => 'Search_Action_WikiApprovalAction', 'tracker_item_modify' => 'Search_Action_TrackerItemModify'));
    $query = new Search_Query();
    $unifiedsearchlib->initQuery($query);
    $matches = WikiParser_PluginMatcher::match($data);
    $builder = new Search_Query_WikiBuilder($query);
    $builder->apply($matches);
    foreach ($matches as $match) {
        $name = $match->getName();
        if ($name == 'action') {
            $action = $factory->fromMatch($match);
            if ($action && $action->isAllowed(Perms::get()->getGroups())) {
                $actions[$action->getName()] = $action;
            }
        }
    }
    if (!empty($_REQUEST['sort_mode'])) {
        $query->setOrder($_REQUEST['sort_mode']);
    }
    $index = $unifiedsearchlib->getIndex();
    $result = $query->search($index);
    $plugin = new Search_Formatter_Plugin_SmartyTemplate('templates/wiki-plugins/wikiplugin_listexecute.tpl');
    $paginationArguments = $builder->getPaginationArguments();
    $dataSource = $unifiedsearchlib->getDataSource();
    $builder = new Search_Formatter_Builder();
    $builder->setPaginationArguments($paginationArguments);
    $builder->apply($matches);
    $builder->setFormatterPlugin($plugin);
    $formatter = $builder->getFormatter();
    $reportSource = new Search_Action_ReportingTransform();
    if (isset($_POST['list_action'], $_POST['objects'])) {
        $action = $_POST['list_action'];
        $objects = (array) $_POST['objects'];
        if (isset($actions[$action])) {
            $tx = TikiDb::get()->begin();
            $action = $actions[$action];
            $plugin->setFields(array_fill_keys($action->getFields(), null));
            $list = $formatter->getPopulatedList($result);
            foreach ($list as $entry) {
                $identifier = "{$entry['object_type']}:{$entry['object_id']}";
                if (in_array($identifier, $objects) || in_array('ALL', $objects)) {
                    $success = $action->execute($entry);
                    $reportSource->setStatus($entry['object_type'], $entry['object_id'], $success);
                }
            }
            $tx->commit();
        }
    }
    $plugin = new Search_Formatter_Plugin_SmartyTemplate('templates/wiki-plugins/wikiplugin_listexecute.tpl');
    $plugin->setFields(array('report_status' => null));
    $plugin->setData(array('actions' => array_keys($actions)));
    $formatter = new Search_Formatter($plugin);
    $result->applyTransform($reportSource);
    return $formatter->format($result);
}
Beispiel #20
0
 function __destruct()
 {
     global $user, $globalperms;
     $user = $this->previousUser;
     $perms = Perms::getInstance();
     $perms->setGroups($this->previousGroupList);
     $globalperms = Perms::get();
 }
Beispiel #21
0
 function setUp()
 {
     Services_Exception_Disabled::check('feature_mailin');
     $perms = Perms::get();
     if (!$perms->admin_mailin) {
         throw new Services_Exception_Denied(tr('Reserved for administrators.'));
     }
 }
Beispiel #22
0
 /**
  * Provides the complete list of notifications that can affect a
  * specific object in the system, including all of it's supported
  * structures, like translation sets.
  *
  * @param user login name
  * @param type standard object type
  * @param object full itemId
  */
 function getOptions($user, $type, $object)
 {
     global $prefs;
     $tikilib = TikiLib::lib('tiki');
     $userId = $tikilib->get_user_id($user);
     // Events applicable for this object
     $events = $this->getApplicableEvents($type);
     $options = [];
     // Include object directly
     $options[] = $this->gatherOptions($userId, $events, $type, $object);
     // Include translation set
     if ($this->hasMultilingual($type)) {
         // Using fake types - wiki page -> wiki page trans
         //                    article   -> article trans
         $options[] = $this->gatherOptions($userId, $events, "{$type} trans", $object);
     }
     if ($prefs['feature_wiki_structure'] == 'y' && $type == 'wiki page') {
         $structlib = TikiLib::lib('struct');
         $structures = $structlib->get_page_structures($object);
         foreach ($structures as $row) {
             $path = $structlib->get_structure_path($row['req_page_ref_id']);
             $path = array_reverse($path);
             foreach ($path as $level => $entry) {
                 $options[] = $this->gatherOptions($userId, $events, 'structure', $entry['page_ref_id'], $this->getStructureLabel($level, $entry));
             }
         }
     }
     if ($prefs['feature_forums'] == 'y' && $type == 'forum post') {
         $post = TikiLib::lib('comments')->get_comment($object);
         $options[] = $this->gatherOptions($userId, $events, 'forum', $post['object']);
     }
     if ($prefs['feature_trackers'] == 'y' && $type == 'trackeritem') {
         $item = TikiLib::lib('trk')->get_item_info($object);
         $options[] = $this->gatherOptions($userId, $events, 'tracker', $item['trackerId']);
     }
     // Include any category and parent category
     if ($prefs['feature_categories'] == 'y') {
         $categlib = TikiLib::lib('categ');
         $categories = $categlib->get_object_categories($type, $object);
         $parents = $categlib->get_with_parents($categories);
         foreach ($parents as $categoryId) {
             $perms = Perms::get('category', $categoryId);
             if ($perms->view_category) {
                 $options[] = array_map(function ($item) use($categories) {
                     $item['isParent'] = !in_array($item['object'], $categories);
                     return $item;
                 }, $this->gatherOptions($userId, $events, 'category', $categoryId));
             }
         }
     }
     // Global / Catch-all always applicable, except for tiki.save, which would
     // cause too much noise.
     $events = array_filter($events, function ($e) {
         return !$e['local'];
     });
     $options[] = $this->gatherOptions($userId, $events, 'global', null);
     return call_user_func_array('array_merge', $options);
 }
Beispiel #23
0
 function action_delete_recording($input)
 {
     if (!Perms::get()->admin) {
         throw new Services_Exception_Denied();
     }
     $bigbluebuttonlib = TikiLib::lib('bigbluebutton');
     $bigbluebuttonlib->removeRecording($input->recording_id->text());
     return array();
 }
Beispiel #24
0
 function setUp()
 {
     global $prefs;
     if ($prefs['feature_trackers'] != 'y') {
         throw new Services_Exception_Disabled('feature_trackers');
     }
     if (!Perms::get()->admin_trackers) {
         throw new Services_Exception(tr('Operation reserved for tracker administrators'), 403);
     }
 }
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_last_blog_posts($mod_reference, $module_params)
{
    $smarty = TikiLib::lib('smarty');
    $blogId = isset($module_params["blogid"]) ? $module_params["blogid"] : 0;
    $smarty->assign('blogid', $blogId);
    $perms = Perms::get(array('type' => 'blog', 'object' => $blogId));
    TikiLib::lib('tiki')->get_perm_object($blogId, 'blog');
    $blog_posts = TikiLib::lib('blog')->list_blog_posts($blogId, $perms->blog_admin, 0, $mod_reference["rows"], 'created_desc', '', '', TikiLib::lib('tiki')->now);
    $smarty->assign('modLastBlogPosts', $blog_posts["data"]);
    $smarty->assign('nodate', isset($module_params["nodate"]) ? $module_params["nodate"] : 'n');
}
function wikiplugin_bigbluebutton( $data, $params )
{
	try {
		global $smarty, $prefs, $user;
		$bigbluebuttonlib = TikiLib::lib('bigbluebutton');
		$meeting = $params['name']; // Meeting is more descriptive than name, but parameter name was already decided.

		$smarty->assign('bbb_meeting', $meeting);
		$smarty->assign('bbb_image', parse_url($prefs['bigbluebutton_server_location'], PHP_URL_SCHEME) . '://' . parse_url($prefs['bigbluebutton_server_location'], PHP_URL_HOST) . '/images/bbb_logo.png');

		$perms = Perms::get('bigbluebutton', $meeting);

		if ( ! $bigbluebuttonlib->roomExists($meeting) ) {
			if ( ! isset($_POST['bbb']) || $_POST['bbb'] != $meeting || ! $perms->bigbluebutton_create ) {
				$smarty->assign( 'bbb_recordings', $bigbluebuttonlib->getRecordings( $meeting ) );
				return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_create.tpl');
			}
		}

		$params = array_merge(array('prefix' => ''), $params);

		if ( $perms->bigbluebutton_join ) {
			if ( isset($_POST['bbb']) && $_POST['bbb'] == $meeting ) {
				if ( ! $user && isset($_POST['bbb_name']) && ! empty($_POST['bbb_name']) ) {
					$_SESSION['bbb_name'] = $params['prefix'] . $_POST['bbb_name'];
				}

				// Attempt to create room made before joining as the BBB server has no persistency.
				// Prior check ensures that the user has appropriate rights to create the room in the
				// first place or that the room was already officially created and this is only a
				// re-create if the BBB server restarted.
				//
				// This avoids the issue occuring when tiki cache thinks the room exist and it's gone
				// on the other hand. It does not solve the issue if the room is lost on the BBB server
				// and tiki cache gets flushed. To cover that one, create can be granted to everyone for
				// the specific object.
				$bigbluebuttonlib->createRoom($meeting, $params);
				$bigbluebuttonlib->joinMeeting($meeting);
			}

			$smarty->assign('bbb_attendees', $bigbluebuttonlib->getAttendees($meeting));
			$smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));

			return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton.tpl');

		} elseif ( $perms->bigbluebutton_view_rec ) { # Case for anonymous users with the perm to view recordings but not to join meetings
			$smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting));

			return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_view_recordings.tpl');
		}
	} catch (Exception $e) {
		return WikiParser_PluginOutput::internalError(tr('BigBlueButton misconfigured or unaccessible.'));
	}
}
Beispiel #27
0
 function action_capture($input)
 {
     $perms = Perms::get();
     if (!$perms->payment_admin) {
         throw new Services_Exception_Denied(tr('Reserved for payment administrators'));
     }
     $paymentlib = TikiLib::lib('payment');
     $paymentlib->capture_payment($input->paymentId->int());
     $access = TikiLib::lib('access');
     $access->redirect($input->next->url());
 }
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_freetags_most_popular($mod_reference, $module_params)
{
    $smarty = TikiLib::lib('smarty');
    $globalperms = Perms::get();
    if ($globalperms->view_freetags) {
        $freetaglib = TikiLib::lib('freetag');
        $most_popular_tags = $freetaglib->get_most_popular_tags('', 0, empty($module_params['max']) ? $mod_reference["rows"] : $module_params['max'], empty($module_params['where']) ? '' : $module_params['where'], empty($module_params['objectId']) ? '' : $module_params['objectId']);
        $smarty->assign_by_ref('most_popular_tags', $most_popular_tags);
        $smarty->assign('type', isset($module_params['type']) && $module_params['type'] == 'cloud' ? 'cloud' : 'list');
    }
}
function module_freetags_most_popular($mod_reference, $module_params)
{
	global $smarty;
	$globalperms = Perms::get();
	if ($globalperms->view_freetags) {
		global $freetaglib; require_once 'lib/freetag/freetaglib.php';
		$most_popular_tags = $freetaglib->get_most_popular_tags('', 0, empty($module_params['max']) ? $mod_reference["rows"] : $module_params['max']);
		$smarty->assign_by_ref('most_popular_tags', $most_popular_tags);
		$smarty->assign('type', (isset($module_params['type']) && $module_params['type'] == 'cloud') ? 'cloud' : 'list');
	}
}
Beispiel #30
0
 function applyPermissions()
 {
     $userlib = TikiLib::lib('user');
     $permNames = $userlib->get_permission_names_for('wiki');
     $objectperms = Perms::get(array('type' => 'wiki page', 'object' => $this->page));
     foreach ($permNames as $name) {
         $this->setGlobal($name, $objectperms->{$name} ? 'y' : 'n');
     }
     $this->canView = $objectperms->view;
     $this->smartyassign('page_user', $this->info['user']);
     return $objectperms;
 }