function wikiplugin_trackerstat_info()
{
    return array('name' => tra('Tracker Stats'), 'documentation' => 'PluginTrackerStat', 'description' => tra('Display statistics about a tracker.'), 'prefs' => array('feature_trackers', 'wikiplugin_trackerstat'), 'body' => tra('Title'), 'iconname' => 'chart', 'introduced' => 2, 'params' => array('trackerId' => array('required' => true, 'name' => tra('Tracker ID'), 'description' => tra('Numeric value representing the tracker ID'), 'since' => '2.0', 'filter' => 'digits', 'default' => '', 'profile_reference' => 'tracker'), 'fields' => array('required' => false, 'name' => tra('Fields'), 'description' => tra('Colon-separated list of field IDs to be displayed. Example:') . ' <code>2:4:5</code>' . tra('. ') . tra('Leave it empty to display all fields from this tracker.'), 'since' => '2.0', 'default' => '', 'separator' => ':', 'profile_reference' => 'tracker_field'), 'show_count' => array('required' => false, 'name' => tra('Show Count'), 'description' => tra('Choose whether to show the count of votes each option received (shown by default)'), 'since' => '10.3', 'filter' => 'alpha', 'default' => 'y', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'show_percent' => array('required' => false, 'name' => tra('Show Percentage'), 'description' => tra('Choose whether to show the percentage of the vote each option received (not shown
					by default)'), 'since' => '2.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'show_bar' => array('required' => false, 'name' => tra('Show Bar'), 'description' => tra('Choose whether to show a bar representing the number of votes each option received
					(not shown by default)'), 'since' => '2.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'status' => array('required' => false, 'name' => tra('Status Filter'), 'description' => tra('Only show items matching certain status filters'), 'since' => '2.0', 'filter' => 'alpha', 'default' => 'o', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Open'), 'value' => 'o'), array('text' => tra('Pending'), 'value' => 'p'), array('text' => tra('Closed'), 'value' => 'c'), array('text' => tra('Open & Pending'), 'value' => 'op'), array('text' => tra('Open & Closed'), 'value' => 'oc'), array('text' => tra('Pending & Closed'), 'value' => 'pc'), array('text' => tra('Open, Pending & Closed'), 'value' => 'opc'))), 'show_link' => array('required' => false, 'name' => tra('Show Link'), 'description' => tra('Add a link to the tracker'), 'since' => '3.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'show_lastmodif' => array('required' => false, 'name' => tra('Last Modification Date'), 'description' => tr('Show last modification date of a tracker. Set to Yes (%0) to use site setting for
					the short date format or use PHP\'s format (www.php.net/strftime). Example:', '<code>y</code>', '<code>%A %d of %B, %Y</code>'), 'since' => '5.0', 'filter' => 'text', 'default' => '')));
}
Beispiel #2
0
function smarty_function_favorite($params, $smarty)
{
    global $prefs, $user;
    // Disabled, do nothing
    if (empty($user) || $prefs['user_favorites'] != 'y') {
        return;
    }
    $servicelib = TikiLib::lib('service');
    $smarty = TikiLib::lib('smarty');
    $smarty->loadPlugin('smarty_modifier_escape');
    $url = $servicelib->getUrl(array('controller' => 'favorite', 'action' => 'toggle', 'type' => $params['type'], 'object' => $params['object']));
    $url = smarty_modifier_escape($url, 'url');
    $e_user = smarty_modifier_escape($user);
    if (isset($params['label'])) {
        $label = $params['label'];
    } else {
        $label = tr('Favorite');
    }
    if (isset($params['button_classes'])) {
        $button_classes = $params['button_classes'];
    } else {
        $button_classes = "btn btn-default";
    }
    return '<a class="' . $button_classes . ' favorite-toggle" href="' . $url . '" data-key="favorite_' . $e_user . '"> ' . $label . '</a>';
}
Beispiel #3
0
function iconset_orange()
{
    /* This and themes/fivealive-lite/options/orange/icons/information.png are
     * just a demo of how to override an icon in a theme option
     * probably should be removed before release? */
    return array('name' => tr('Theme icons'), 'description' => tr('Icons to be used for this theme'), 'tag' => 'span', 'icons' => array('information' => array('id' => 'eye')));
}
/**
 * @todo check if it's useful to have the table admin two times in the same query
 * @param EasySCP_TemplateEngine $tpl
 */
function gen_reseller_table($tpl)
{
    $cfg = EasySCP_Registry::get('Config');
    $sql = EasySCP_Registry::get('Db');
    $query = "\n\t\tSELECT\n\t\t\tt1.`admin_id`, t1.`admin_name`, t2.`admin_name` AS created_by\n\t\tFROM\n\t\t\t`admin` AS t1,\n\t\t\t`admin` AS t2\n\t\tWHERE\n\t\t\tt1.`admin_type` = 'reseller'\n\t\tAND\n\t\t\tt1.`created_by` = t2.`admin_id`\n\t\tORDER BY\n\t\t\t`created_by`,\n\t\t\t`admin_id`\n\t";
    $rs = exec_query($sql, $query);
    $i = 0;
    if ($rs->recordCount() == 0) {
        set_page_message(tr('Reseller list is empty!'), 'info');
    } else {
        while (!$rs->EOF) {
            $admin_id = $rs->fields['admin_id'];
            $admin_id_var_name = "admin_id_" . $admin_id;
            $tpl->append(array('NUMBER' => $i + 1, 'RESELLER_NAME' => tohtml($rs->fields['admin_name']), 'OWNER' => tohtml($rs->fields['created_by']), 'CKB_NAME' => $admin_id_var_name));
            $rs->moveNext();
            $i++;
        }
        $tpl->assign('PAGE_MESSAGE', '');
    }
    $query = "\n\t\tSELECT\n\t\t\t`admin_id`, `admin_name`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'admin'\n\t\tORDER BY\n\t\t\t`admin_name`\n\t";
    $rs = exec_query($sql, $query);
    while (!$rs->EOF) {
        if (isset($_POST['uaction']) && $_POST['uaction'] === 'reseller_owner' && (isset($_POST['dest_admin']) && $_POST['dest_admin'] == $rs->fields['admin_id'])) {
            $selected = $cfg->HTML_SELECTED;
        } else {
            $selected = '';
        }
        $tpl->append(array('OPTION' => tohtml($rs->fields['admin_name']), 'VALUE' => $rs->fields['admin_id'], 'SELECTED' => $selected));
        $rs->moveNext();
    }
    $tpl->assign('PAGE_MESSAGE', '');
}
function module_forums_last_posts_info()
{
	return array(
		'name' => tra('Newest Forum Posts'),
		'description' => tra('Displays the latest forum posts.'),
		'prefs' => array('feature_forums'),
		'params' => array(
			'topics' => array(
				'name' => tra('Topics only'),
				'description' => tra('If set to "y", only displays topics.') . " " . tr('Not set by default.')
				),
			'forumId' => array(
				'name' => tra('List of forum identifiers'),
				'description' => tra('If set to a list of forum identifiers, restricts the posts to those in the identified forums. Identifiers are separated by colons (":").') . " " . tra('Example values:') . '"13", "31:49". ' . tra('Not set by default.'),
				'separator' => ':'
			),
			'date' => array(
				'name' => tra('Show date'),
				'description' => tra('If set to "y", show post date directly instead of as tooltip.') . ' ' . tra('Default:') . ' n',
			),
			'author' => array(
				'name' => tra('Show author'),
				'description' => tra('If set to "y", show post author directly instead of as tooltip.') . ' ' . tra('Default:') . ' n',
			),
		),
		'common_params' => array('nonums', 'rows')
	);
}
function smarty_function_error_report($params, $smarty)
{
    $errorreportlib = TikiLib::lib('errorreport');
    $errors = $errorreportlib->get_errors();
    $pre = '<div id="error_report">';
    $post = '</div>';
    TikiLib::lib('header')->add_js('
	$("#error_report").ajaxComplete(function (e, jqxhr) {
		var error = jqxhr.getResponseHeader("X-Tiki-Error");
		if (error) {
			if ($("ul", this).length === 0) {
				$(this).append($(error)[0].childNodes);
			} else {
				$("ul", this).append($(error).find("li"));
			}
		}
	});
	$("#error_report .clear").live("click", function () {
		$("#error_report").empty();
		return false;
	});
	');
    if (count($errors)) {
        $smarty->loadPlugin('smarty_block_remarksbox');
        $repeat = false;
        return $pre . smarty_block_remarksbox(array('type' => 'errors', 'title' => tra('Error(s)')), '<a class="clear" style="float: right;" href="#">' . tr('Clear errors') . '</a><ul><li>' . implode('</li><li>', $errors) . '</li></ul>', $smarty, $repeat) . $post;
    } else {
        return $pre . $post;
    }
}
function wikiplugin_adjustinventory($data, $params)
{
    if (!isset($params['add'])) {
        $params['add'] = 'y';
    }
    if (!isset($params['subtract'])) {
        $params['subtract'] = 'y';
    }
    $smarty = TikiLib::lib('smarty');
    $smarty->assign('code', $params['code']);
    $smarty->assign('add', $params['add']);
    $smarty->assign('subtract', $params['subtract']);
    $form = $smarty->fetch('wiki-plugins/wikiplugin_adjustinventory.tpl');
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        global $jitPost;
        $access = TikiLib::lib('access');
        $add_quantity = $jitPost->add_quantity->int();
        $subtract_quantity = $jitPost->subtract_quantity->int();
        $quantity = $add_quantity - $subtract_quantity;
        if ($jitPost->code->text() == $params['code'] && $quantity != 0) {
            $cartlib = TikiLib::lib('cart');
            $cartlib->change_inventory($params['code'], $quantity);
        }
        $access->redirect($_SERVER['REQUEST_URI'], tr('Inventory was adjusted by %0', $quantity));
    }
    return $form;
}
Beispiel #8
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;
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 public function __get($field)
 {
     if (isset($this->_fields[$field])) {
         return $this->_fields[$field];
     }
     throw new InvalidPropertyException(tr('Invalid property: %1', $field));
 }
Beispiel #10
0
/**
 * Schedule backup restoration.
 *
 * @param int $userId Customer unique identifier
 * @return void
 */
function scheduleBackupRestoration($userId)
{
    exec_query("UPDATE `domain` SET `domain_status` = ? WHERE `domain_admin_id` = ?", array('torestore', $userId));
    send_request();
    write_log($_SESSION['user_logged'] . ": scheduled backup restoration.", E_USER_NOTICE);
    set_page_message(tr('Backup has been successfully scheduled for restoration.'), 'success');
}
Beispiel #11
0
/**
 * \brief Smarty modifier plugin to create user links with optional mouseover info
 *
 * - type:     modifier
 * - name:     userlink
 * - purpose:  to return a user link
 *
 * @author
 * @param string class (optional)
 * @param string idletime (optional)
 * @param string fullname (optional)
 * @param integer max_length (optional)
 * @return string user link
 *
 * Syntax: {$foo|userlink[:"<class>"][:"<idletime>"][:"<fullname>"][:<max_length>]} (optional params in brackets)
 *
 * Example: {$userinfo.login|userlink:'link':::25}
 */
function smarty_modifier_userlink($other_user, $class = 'userlink', $idletime = 'not_set', $fullname = '', $max_length = 0, $popup = 'y')
{
    if (empty($other_user)) {
        return "";
    }
    if (is_array($other_user)) {
        if (count($other_user) > 1) {
            $other_user = array_map(function ($username) use($class, $idletime, $popup) {
                return smarty_modifier_userlink($username, $class, $idletime, '', 0, $popup);
            }, $other_user);
            $last = array_pop($other_user);
            return tr('%0 and %1', implode(', ', $other_user), $last);
        } else {
            $other_user = reset($other_user);
        }
    }
    if (!$fullname) {
        $fullname = TikiLib::lib('user')->clean_user($other_user);
    }
    if ($max_length) {
        TikiLib::lib('smarty')->loadPlugin('smarty_modifier_truncate');
        $fullname = smarty_modifier_truncate($fullname, $max_length, '...', true);
    }
    if ($popup === 'y') {
        return TikiLib::lib('user')->build_userinfo_tag($other_user, $fullname, $class);
    } else {
        return $fullname;
    }
}
Beispiel #12
0
function wikiplugin_mail_info()
{
    global $prefs;
    return array('name' => tra('Mail'), 'documentation' => 'PluginMail', 'description' => tra('Mail other users or groups'), 'validate' => 'all', 'prefs' => array('wikiplugin_mail'), 'iconname' => 'envelope', 'introduced' => 3, 'params' => array('group' => array('required' => false, 'name' => tra('Group'), 'description' => tra('Limit the list of groups to the groups including each group'), 'filter' => 'groupname', 'since' => '5.0', 'default' => '', 'separator' => ':'), 'showgroupdd' => array('required' => false, 'name' => tra('Group Dropdown'), 'description' => tra('Show a dropdown list of groups (not shown by default)'), 'since' => '5.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'recurse' => array('required' => false, 'name' => tra('Recurse Groups'), 'description' => tra('Show each group and each group included in this group'), 'since' => '8.0', 'filter' => 'alpha', 'default' => 'y', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'recurseuser' => array('required' => false, 'name' => tra('Recurse Group Users'), 'description' => tr('Indicate how many times to recurse to collect the users of a selected group and
					the users of each included groups. If %00%1 do not recurse, if %01%1, recurse one time, %02%1 for
					two times....', '<code>', '</code>'), 'since' => '8.0', 'filter' => 'int', 'default' => '0'), 'showuserdd' => array('required' => false, 'name' => tra('User Dropdown'), 'description' => tra('Show a dropdown list of users (not shown by default)'), 'since' => '5.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'showuser' => array('required' => false, 'name' => tra('User Emails'), 'description' => tra('Show a box for user to enter email addresses'), 'since' => '5.0', 'filter' => 'alpha', 'default' => 'y', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'showrealnamedd' => array('required' => false, 'name' => tra('Real Name Dropdown'), 'description' => tra('Show a dropdown list of user real names (not shown by default)'), 'since' => '5.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'popup' => array('required' => false, 'name' => tra('Popup'), 'description' => tra('Show in popup instead of inline.'), 'since' => '14.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'label_name' => array('required' => false, 'name' => tra('Button Text'), 'description' => tr('Text to show on the button to send emails (default: %0Send mail%1)', '<code>', '</code>'), 'since' => '14.0', 'filter' => 'text', 'default' => tra('Send mail')), 'mail_subject' => array('required' => true, 'name' => tra('Email Subject'), 'description' => tra('Present Email subject content'), 'since' => '14.0', 'filter' => 'text', 'default' => ''), 'bypass_preview' => array('required' => false, 'name' => tra('Bypass Preview'), 'description' => tra('Send emails without first previewing'), 'since' => '14.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'debug' => array('required' => false, 'name' => tra('Debug mode (admins only)'), 'description' => tra('Show list of emails that are sent (admins only)'), 'since' => '14.0', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n')))));
}
Beispiel #13
0
 function getLanguage($type, $object)
 {
     $lang = null;
     switch ($type) {
         case 'wiki page':
             $info = TikiLib::lib('tiki')->get_page_info($object);
             $lang = $info['lang'];
             break;
         case 'article':
             $info = TikiLib::lib('art')->get_article($object);
             $lang = $info['lang'];
             break;
         case 'trackeritem':
             $info = TikiLib::lib('trk')->get_tracker_item($object);
             $definition = Tracker_Definition::get($info['trackerId']);
             if ($field = $definition->getLanguageField()) {
                 $lang = $info[$field];
             }
             break;
         case 'forum post':
             $object = TikiLib::lib('comments')->get_comment_forum_id($object);
             // no break: drop through to forum
         // no break: drop through to forum
         case 'forum':
             $info = TikiLib::lib('comments')->get_forum($object);
             $lang = $info['forumLanguage'];
             break;
     }
     if (!$lang) {
         throw new Services_Exception(tr('Object has no language and cannot be translated'), 400);
     }
     return $lang;
 }
Beispiel #14
0
function css_edit_raw()
{
    global $event, $step;
    $default_name = safe_field('css', 'txp_section', "name = 'default'");
    extract(gpsa(array('name', 'newname', 'copy', 'savenew')));
    if ($step == 'css_delete' || empty($name) && $step != 'pour' && !$savenew) {
        $name = $default_name;
    } elseif (($copy || $savenew) && trim(preg_replace('/[<>&"\']/', '', $newname))) {
        $name = $newname;
    }
    if (empty($name)) {
        $buttons = '<div class="edit-title">' . gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew') . '</div>';
        $thecss = gps('css');
    } else {
        $buttons = '<div class="edit-title">' . gTxt('you_are_editing_css') . sp . strong(htmlspecialchars($name)) . '</div>';
        $thecss = fetch("css", 'txp_css', 'name', $name);
    }
    if (!empty($name)) {
        $copy = '<span class="copy-as"><label for="copy-css">' . gTxt('copy_css_as') . '</label>' . sp . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-css') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</span>';
    } else {
        $copy = '';
    }
    $right = '<div id="content_switcher">' . hed(gTxt('all_stylesheets'), 2) . graf(sLink('css', 'pour', gTxt('create_new_css')), ' class="action-create smallerbox"') . css_list($name, $default_name) . '</div>';
    echo '<div id="' . $event . '_container" class="txp-container txp-edit">' . startTable('edit') . tr(td(form('<div id="main_content">' . $buttons . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy . '</div>', '', '', 'post', 'edit-form', '', 'style_form'), '', 'column') . tdtl($right, ' class="column"')) . endTable() . '</div>';
}
Beispiel #15
0
function padd_group($tpl, $sql, $dmn_id)
{
    $cfg = EasySCP_Registry::get('Config');
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_group') {
        // we have to add the group
        if (isset($_POST['groupname'])) {
            if (!validates_username($_POST['groupname'])) {
                set_page_message(tr('Invalid group name!'), 'warning');
                return;
            }
            $groupname = $_POST['groupname'];
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_groups`\n\t\t\t\tWHERE\n\t\t\t\t\t`ugroup` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($sql, $query, array($groupname, $dmn_id));
            if ($rs->recordCount() == 0) {
                $change_status = $cfg->ITEM_ADD_STATUS;
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_groups`\n\t\t\t\t\t\t(`dmn_id`, `ugroup`, `status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?)\n\t\t\t\t";
                exec_query($sql, $query, array($dmn_id, $groupname, $change_status));
                send_request();
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: add group (protected areas): {$groupname}");
                user_goto('protected_user_manage.php');
            } else {
                set_page_message(tr('Group already exists!'), 'error');
                return;
            }
        } else {
            set_page_message(tr('Invalid group name!'), 'error');
            return;
        }
    } else {
        return;
    }
}
Beispiel #16
0
 function evaluate($element)
 {
     $default = 0;
     $allowed = ['qualifier', 'from', 'to'];
     if ($extra = $element->getExtraValues($allowed)) {
         $this->error(tr('Unexpected values: %0', implode(', ', $extra)));
     }
     $from = $element->from;
     $to = $element->to;
     $qualifier = $element->qualifier;
     if (!$qualifier || count($qualifier) != 1) {
         $this->error(tra('Qualifier must be provided and contain one argument: type'));
     }
     if (!$from || count($from) != 2) {
         $this->error(tra('From must be provided and contain two arguments: type, object-id'));
     }
     if (!$to || count($to) != 2) {
         $this->error(tra('To must be provided and contain two arguments: type, object-id'));
     }
     $qualifier = $this->evaluateChild($qualifier[0]);
     $typeFrom = $this->evaluateChild($from[0]);
     $objectFrom = $this->evaluateChild($from[1]);
     $typeTo = $this->evaluateChild($to[0]);
     $objectTo = $this->evaluateChild($to[1]);
     $lib = TikiLib::lib('relation');
     $id = $lib->get_relation_id($qualifier, $typeFrom, $objectFrom, $typeTo, $objectTo);
     return $id ? 1 : 0;
 }
Beispiel #17
0
/**
 * Performs the second half of a trade - "offer mode" only and also cclite only
 * The payment system does the first half ($user to manager account), this does manager to destination
 *
 * Work in progress
 *
 * @param string $main_user
 * @param string $other_user
 * @param float $price
 * @param string $currency
 * @param string $wanted = 'n'
 */
function payment_behavior_perform_trade($params)
{
    global $userlib, $paymentlib, $prefs, $cclitelib, $smarty;
    require_once 'lib/payment/cclitelib.php';
    $default = array('wanted' => 'n', 'registry' => '', 'currency' => '');
    $params = array_merge($default, $params);
    $smarty->assign('ccresult_ok', false);
    if (!$userlib->user_exists($params['main_user'])) {
        $smarty->assign('ccresult2', "Perform Trade: Main user {$params['main_user']} not found");
    }
    if (!$userlib->user_exists($params['other_user'])) {
        $smarty->assign('ccresult2', "Perform Trade: Other user {$params['other_user']} not found");
    }
    if (!$params['price'] || (int) $params['price'] === 0) {
        $smarty->assign('ccresult2', "Perform Trade: price not set");
    }
    $result = $cclitelib->pay_user($params['price'], $params['currency'], $params['registry'], $params['other_user'], $params['main_user']);
    if (!empty($result)) {
        $smarty->assign('ccresult2', $result);
        $smarty->assign('ccresult_ok', strpos($result, 'Transaction Accepted') !== false);
    } else {
        $smarty->assign('ccresult2', tr('Payment sent but verification not currently available. (Work in progress)'));
    }
    return $result;
}
Beispiel #18
0
function display_customer_summary($customer_record)
{
    global $table_style;
    $past1 = get_company_pref('past_due_days');
    $past2 = 2 * $past1;
    if ($customer_record["dissallow_invoices"] != 0) {
        echo "<center><font color=red size=4><b>" . tr("CUSTOMER ACCOUNT IS ON HOLD") . "</font></b></center>";
    }
    $nowdue = "1-" . $past1 . " " . tr('Days');
    $pastdue1 = $past1 + 1 . "-" . $past2 . " " . tr('Days');
    $pastdue2 = tr('Over') . " " . $past2 . " " . tr('Days');
    start_table("width=80% {$table_style}");
    $th = array(tr("Currency"), tr("Terms"), tr("Current"), $nowdue, $pastdue1, $pastdue2, tr("Total Balance"));
    table_header($th);
    start_row();
    label_cell($customer_record["curr_code"]);
    label_cell($customer_record["terms"]);
    amount_cell($customer_record["Balance"] - $customer_record["Due"]);
    amount_cell($customer_record["Due"] - $customer_record["Overdue1"]);
    amount_cell($customer_record["Overdue1"] - $customer_record["Overdue2"]);
    amount_cell($customer_record["Overdue2"]);
    amount_cell($customer_record["Balance"]);
    end_row();
    end_table();
}
Beispiel #19
0
/**
 * Generate page
 *
 * @param  iMSCP_pTemplate $tpl
 * @return void
 */
function admin_generatePage($tpl)
{
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    if (!isset($cfg['CHECK_FOR_UPDATES']) || !$cfg['CHECK_FOR_UPDATES']) {
        set_page_message(tr('i-MSCP version update checking is disabled'), 'static_warning');
    } else {
        /** @var iMSCP_Update_Version $updateVersion */
        $updateVersion = iMSCP_Update_Version::getInstance();
        if ($updateVersion->isAvailableUpdate()) {
            if ($updateInfo = $updateVersion->getUpdateInfo()) {
                $date = new DateTime($updateInfo['published_at']);
                $tpl->assign(array('TR_UPDATE_INFO' => tr('Update info'), 'TR_RELEASE_VERSION' => tr('Release version'), 'RELEASE_VERSION' => tohtml($updateInfo['tag_name']), 'TR_RELEASE_DATE' => tr('Release date'), 'RELEASE_DATE' => tohtml($date->format($cfg['DATE_FORMAT'])), 'TR_RELEASE_DESCRIPTION' => tr('Release description'), 'RELEASE_DESCRIPTION' => tohtml($updateInfo['body']), 'TR_DOWNLOAD_LINKS' => tr('Download links'), 'TR_DOWNLOAD_ZIP' => tr('Download ZIP'), 'TR_DOWNLOAD_TAR' => tr('Download TAR'), 'TARBALL_URL' => tohtml($updateInfo['tarball_url']), 'ZIPBALL_URL' => tohtml($updateInfo['zipball_url'])));
                return;
            } else {
                set_page_message($updateVersion->getError(), 'error');
            }
        } elseif ($updateVersion->getError()) {
            set_page_message($updateVersion, 'error');
        } else {
            set_page_message(tr('No update available'), 'static_info');
        }
    }
    $tpl->assign('UPDATE_INFO', '');
}
Beispiel #20
0
function wikiplugin_versions_info()
{
    return array('name' => tra('Versions'), 'documentation' => 'PluginVersions', 'description' => tra('Create tabs for showing alternate versions of content'), 'prefs' => array('wikiplugin_versions'), 'body' => tra('Block of text separated by ---(version x)--- markers. Text before the first marker is used by
			default.'), 'iconname' => 'copy', 'introduced' => 1, 'tags' => array('basic'), 'params' => array('nav' => array('required' => false, 'name' => tra('Navigation'), 'description' => tra('Display a navigation box that allows users to select a specific version to display.'), 'since' => '1', 'default' => 'n', 'filter' => 'alpha', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'title' => array('required' => false, 'name' => tra('Title'), 'description' => tr('Display the current version name as the title. No title shows when %0nav="y"%1;
					otherwise shows by default.', '<code>', '</code>'), 'since' => '1', 'default' => 'y', 'filter' => 'alpha', 'parent' => array('name' => 'nav', 'value' => 'n'), 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'default' => array('required' => false, 'name' => tra('Default Label'), 'description' => tra('Specifies version label to show when displaying the page for the first time.
					Default label is \'Default\''), 'since' => '1', 'default' => tra('Default'))));
}
Beispiel #21
0
 function getDocument($objectId, Search_Type_Factory_Interface $typeFactory)
 {
     $wikilib = TikiLib::lib('wiki');
     $info = $this->tikilib->get_page_info($objectId, true, true);
     if (!$info) {
         return false;
     }
     $contributors = $wikilib->get_contributors($objectId, $info['user']);
     if (!in_array($info['user'], $contributors)) {
         $contributors[] = $info['user'];
     }
     $data = array('title' => $typeFactory->sortable($info['pageName']), 'language' => $typeFactory->identifier(empty($info['lang']) ? 'unknown' : $info['lang']), 'modification_date' => $typeFactory->timestamp($info['lastModif']), 'description' => $typeFactory->plaintext($info['description']), 'contributors' => $typeFactory->multivalue($contributors), 'wiki_content' => $typeFactory->wikitext($info['data']), 'view_permission' => $typeFactory->identifier('tiki_p_view'), 'url' => $typeFactory->identifier($wikilib->sefurl($info['pageName'])), 'hash' => $typeFactory->identifier(''));
     if ($this->quantifylib) {
         $data['wiki_uptodateness'] = $typeFactory->sortable($this->quantifylib->getCompleteness($info['page_id']));
     }
     if ($this->flaggedrevisionlib) {
         $data['wiki_approval_state'] = $typeFactory->identifier('none');
     }
     $out = $data;
     if ($this->flaggedrevisionlib && $this->flaggedrevisionlib->page_requires_approval($info['pageName'])) {
         $out = array();
         // Will provide two documents: one approved and one latest
         $versionInfo = $this->flaggedrevisionlib->get_version_with($info['pageName'], 'moderation', 'OK');
         if (!$versionInfo || $versionInfo['version'] != $info['version']) {
             // No approved version or approved version differs, latest content marked as such
             $out[] = array_merge($data, array('hash' => $typeFactory->identifier('latest'), 'title' => $typeFactory->sortable(tr('%0 (latest)', $info['pageName'])), 'view_permission' => $typeFactory->identifier('tiki_p_wiki_view_latest'), 'wiki_approval_state' => $typeFactory->identifier('pending'), 'url' => $typeFactory->identifier(str_replace('&amp;', '&', $wikilib->sefurl($info['pageName'], true)) . 'latest')));
         }
         if ($versionInfo) {
             // Approved version not latest, include approved version in index
             // Also applies when versions are equal, data would be the same
             $out[] = array_merge($data, array('wiki_content' => $typeFactory->wikitext($versionInfo['data']), 'wiki_approval_state' => $typeFactory->identifier('approved')));
         }
     }
     return $out;
 }
Beispiel #22
0
 function evaluate($element)
 {
     $default = 0;
     $allowed = array('object', 'list');
     if ($extra = $element->getExtraValues($allowed)) {
         $this->error(tr('Unexpected values: %0', implode(', ', $extra)));
     }
     $object = $element->object;
     if (!$object || count($object) != 2) {
         $this->error(tra('Item must be provided and contain one argument: type, object-id'));
     }
     $type = $this->evaluateChild($object[0]);
     $object = $this->evaluateChild($object[1]);
     $list = $element->list;
     if (!$list || count($list) == 0) {
         $this->error(tra('List must be provided and contain at least one argument: category IDs'));
     }
     $categlib = TikiLib::lib('categ');
     $categories = $categlib->get_object_categories($type, $object, -1, false);
     $score = 0;
     foreach ($list as $entry) {
         if (in_array($entry, $categories)) {
             ++$score;
         }
     }
     return $score;
 }
Beispiel #23
0
function wikiplugin_shopperinfo($data, $params)
{
    global $user;
    $smarty = TikiLib::lib('smarty');
    if ($user && $params['showifloggedin'] != 'y' || empty($params['values'])) {
        return '';
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['shopperinfo'])) {
        foreach ($params['values'] as $v) {
            // Check all filled in
            if (empty($_POST[$v])) {
                $access = TikiLib::lib('access');
                $access->redirect($_SERVER['REQUEST_URI'], tr('Please fill in all fields'));
                die;
            }
        }
        foreach ($params['values'] as $v) {
            $_SESSION['shopperinfo'][$v] = $_POST[$v];
        }
    }
    $values = array();
    foreach ($params['values'] as $k => $v) {
        $t['name'] = $v;
        if (!empty($_SESSION['shopperinfo'][$v])) {
            $t['current'] = $_SESSION['shopperinfo'][$v];
        }
        if (!empty($params['labels'][$k])) {
            $t['label'] = $params['labels'][$k];
        }
        $values[] = $t;
    }
    $smarty->assign('values', $values);
    $form = $smarty->fetch('wiki-plugins/wikiplugin_shopperinfo.tpl');
    return $form;
}
 function action_compare($input)
 {
     $user = $input->user->username() ?: $GLOBALS['user'];
     $input = new R\Input\UserInput($user);
     $comparator = new R\Comparator($this->getEngineSet('content'));
     return ['title' => tr('Recommendations for %0', $user), 'recommendations' => $comparator->generate($input)];
 }
function t($str, $params = null)
{
    if ($params != null) {
        return vsprintf(tr(substr($str, 3, -4)), $params);
    }
    return tr(substr($str, 3, -4));
}
Beispiel #26
0
 function getFieldData(array $requestData = array())
 {
     global $tiki_p_admin_trackers, $user;
     $ins_id = $this->getInsertId();
     $data = array();
     $autoassign = (int) $this->getOption('autoassign');
     if (isset($requestData[$ins_id])) {
         if ($autoassign == 0 || $tiki_p_admin_trackers === 'y') {
             $auser = $requestData[$ins_id];
             if (!$auser || TikiLib::lib('user')->user_exists($auser)) {
                 $data['value'] = $auser;
             } else {
                 $data['value'] = $this->getValue();
                 TikiLib::lib('errorreport')->report(tr('User "%0" not found', $auser));
             }
         } else {
             if ($autoassign == 2) {
                 $data['value'] = $user;
             } elseif ($autoassign == 1) {
                 if (!$this->getItemId() || $this->getTrackerDefinition()->getConfiguration('userCanTakeOwnership') == 'y' && !$this->getValue()) {
                     $data['value'] = $user;
                     // the user appropiate the item
                 } else {
                     $data['value'] = $this->getValue();
                     // unset($data['fieldId']); hmm?
                 }
             } else {
                 $data['value'] = '';
             }
         }
     } else {
         $data['value'] = $this->getValue(false);
     }
     return $data;
 }
Beispiel #27
0
 function renderOutput($context = array())
 {
     $smarty = TikiLib::lib('smarty');
     $url = $this->getConfiguration('value');
     if (empty($url) || $context['list_mode'] == 'csv' || $this->getOption('linkToURL') == 1) {
         return $url;
     } elseif ($this->getOption('linkToURL') == 2) {
         // Site title as link
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 0) {
         // URL as link
         $parsedUrl = trim(str_replace('<br />', '', TikiLib::lib('tiki')->parse_data($url)));
         if ($parsedUrl != $url) {
             return $parsedUrl;
         }
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url, 'title' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 3) {
         // URL + site title
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external_extended', 'id' => $url), $smarty);
     } elseif ($this->getOption('linkToURL') == 4) {
         // URL as link
         $smarty->loadPlugin('smarty_function_object_link');
         return smarty_function_object_link(array('type' => 'external', 'id' => $url, 'title' => tr($this->getOption('other'))), $smarty);
     } else {
         return $url;
     }
 }
Beispiel #28
0
function wikiplugin_split_info()
{
    return array('name' => tra('Split'), 'documentation' => 'PluginSplit', 'description' => tra('Arrange content on a page into rows and columns'), 'prefs' => array('wikiplugin_split'), 'filter' => 'wikicontent', 'iconname' => 'th-large', 'introduced' => 1, 'tags' => array('basic'), 'params' => array('joincols' => array('required' => false, 'name' => tra('Join Columns'), 'description' => tra('Generate the colspan attribute if columns are missing'), 'since' => '1', 'filter' => 'alpha', 'default' => 'y', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'fixedsize' => array('required' => false, 'name' => tra('Fixed Size'), 'description' => tra('Generate the width attribute for the columns'), 'since' => '1', 'filter' => 'alpha', 'default' => 'y', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'colsize' => array('required' => false, 'name' => tra('Column Sizes'), 'description' => tr('Specify all column widths in number of pixels or percent, separating each width
					by a pipe (%0)', '<code>|</code>'), 'since' => '1', 'seprator' => '|', 'filter' => 'text', 'default' => ''), 'first' => array('required' => false, 'name' => tra('First'), 'description' => tra('Cells specified are ordered first left to right across rows (default) or top to
					bottom down columns'), 'since' => '1', 'filter' => 'alpha', 'default' => 'line', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Column'), 'value' => 'col'), array('text' => tra('Line'), 'value' => 'line'))), 'edit' => array('required' => false, 'name' => tra('Editable'), 'description' => tr('Display edit icon for each section. Works when used on a wiki page and the %0
					parameter is set to %1', '<code>first</code>', '<code>col</code>'), 'since' => '1', 'filter' => 'alpha', 'default' => 'n', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'customclass' => array('required' => false, 'name' => tra('Custom Class'), 'description' => tra('Add a class to customize the design'), 'since' => '3.0', 'filter' => 'text', 'default' => '')));
}
Beispiel #29
0
 public function getOutput(array $change)
 {
     $base_url = $change['data']['base_url'];
     $newVersion = $change['data']['oldVer'] + 1;
     $output = tr("%0 edited the wikipage %1 (<a href=%2>this history</a>, <a href=%3>all history</a>)", "<u>{$change['data']['editUser']}</u>", "<a href=\"{$base_url}tiki-index.php?page={$change['data']['pageName']}\">{$change['data']['pageName']}</a>", "\"{$base_url}tiki-pagehistory.php?page={$change['data']['pageName']}&diff_style=sidediff&compare=Compare&newver={$newVersion}&oldver={$change['data']['oldVer']}\"", "\"{$base_url}tiki-pagehistory.php?page={$change['data']['pageName']}&diff_style=sidediff&compare=Compare&newver=0&oldver={$change['data']['oldVer']}\"");
     return $output;
 }
Beispiel #30
0
function wikiplugin_sheet_info()
{
    return array('name' => tra('Sheet'), 'documentation' => 'PluginSheet', 'description' => tra('Display data from a TikiSheet'), 'prefs' => array('wikiplugin_sheet', 'feature_sheet'), 'body' => tra('Sheet Heading'), 'iconname' => 'table', 'introduced' => 1, 'tags' => array('basic'), 'params' => array('id' => array('required' => false, 'name' => tra('Sheet ID'), 'description' => tr('Internal ID of the TikiSheet. Either %0id%1 or %0url%1 is required.', '<code>', '</code>'), 'filter' => 'digits', 'accepted' => 'Sheet ID number', 'default' => '', 'since' => '1', 'profile_reference' => 'sheet'), 'url' => array('required' => false, 'name' => tra('Sheet Url Location'), 'description' => tr('Internal URL of the Table to use as a spreadsheet. Either %0id%1 or %0url%1 is
					required.', '<code>', '</code>'), 'filter' => 'url', 'default' => '', 'since' => '6.0'), 'simple' => array('required' => false, 'name' => tra('Simple'), 'description' => tr('Show a simple table view (Default: %0 = jquery.sheet view if feature enabled).', '<code>n</code>'), 'filter' => 'alpha', 'default' => 'n', 'since' => '5.0', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'width' => array('required' => false, 'name' => tra('Width'), 'description' => tr('Width in pixels or percentage. Default value is page width. e.g. %0200px%1 or
					%0100%%1', '<code>', '</code>'), 'filter' => 'text', 'accepted' => 'Number of pixels followed by \'px\' or percent followed by %).', 'default' => 'Page width', 'since' => '6.0'), 'height' => array('required' => false, 'name' => tra('Height'), 'description' => tra('Height in pixels or percentage. Default value is complete spreadsheet height.'), 'filter' => 'text', 'accepted' => 'Number of pixels followed by \'px\' or percent followed by %).', 'default' => 'Spreadsheet height', 'since' => '5.0'), 'editable' => array('required' => false, 'name' => tra('Editable'), 'description' => tra('Show edit button. Default is to show depending on user\'s permissions.'), 'filter' => 'alpha', 'accepted' => 'y or n', 'default' => 'y', 'since' => '6.0', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'subsheets' => array('required' => false, 'name' => tra('Show subsheets'), 'description' => tra('Show multi-sheets (default is to show)'), 'filter' => 'alpha', 'accepted' => 'y or n', 'default' => 'y', 'since' => '6.0', 'options' => array(array('text' => '', 'value' => ''), array('text' => tra('Yes'), 'value' => 'y'), array('text' => tra('No'), 'value' => 'n'))), 'range' => array('required' => false, 'name' => tra('Range'), 'description' => tr('Show a range of cells (or single cell). Default shows all. e.g. %0D1:F3%1 or
					%0e14:e14%1', '<code>', '</code>'), 'filter' => 'text', 'accepted' => 'Cell range, e.g. "D1:F3" or "e14:e14"', 'default' => 'All cells', 'since' => '6.0'), 'class' => array('required' => false, 'name' => tra('CSS Class'), 'description' => tra('Apply custom CSS class to the containing div.'), 'filter' => 'text', 'accepted' => 'Any valid CSS class', 'default' => '', 'since' => '6.0')));
}