Exemplo n.º 1
0
 function get_parsed_template($templateId, $lang = null, $format = 'yaml')
 {
     $res = $this->get_template($templateId, $lang);
     if (!$res) {
         return false;
     }
     switch ($format) {
         case 'yaml':
             require_once 'lib/profilelib/profilelib.php';
             require_once 'lib/profilelib/installlib.php';
             $content = "{CODE(caption=>YAML)}objects:\n" . " -\n" . "  type: file_gallery\n" . "  data:\n" . "   " . implode("\n   ", explode("\n", $res['content'])) . "{CODE}";
             $profile = Tiki_Profile::fromString($content, $res['name']);
             $installer = new Tiki_Profile_Installer();
             $objects = $profile->getObjects();
             if (isset($objects[0])) {
                 $data = $installer->getInstallHandler($objects[0])->getData();
                 unset($data['galleryId'], $data['parentId'], $data['name'], $data['user']);
                 $res['content'] = $data;
             } else {
                 $res['content'] = array();
             }
             break;
     }
     return $res;
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $profileName = $input->getArgument('profile');
     $repository = $input->getArgument('repository');
     $force = $input->getOption('force');
     $profile = \Tiki_Profile::fromNames($repository, $profileName);
     if (!$profile) {
         $output->writeln('<error>Profile not found.</error>');
         return;
     }
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     $isInstalled = $installer->isInstalled($profile);
     if ($isInstalled && $force) {
         $installer->forget($profile);
         $isInstalled = false;
     }
     if (!$isInstalled) {
         $transaction = $tikilib->begin();
         if ($installer->install($profile)) {
             $transaction->commit();
             $output->writeln('Profile applied.');
         } else {
             $output->writeln("<error>Installation failed:</error>");
             foreach ($installer->getFeedback() as $error) {
                 $output->writeln("<error>{$error}</error>");
             }
         }
     } else {
         $output->writeln('<info>Profile was already applied. Nothing happened.</info>');
     }
 }
Exemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $addon_utilities = new \TikiAddons_Utilities();
     $addonName = $input->getArgument('addon');
     if (strpos($addonName, '/') !== false && strpos($addonName, '_') === false) {
         $package = $addonName;
         $folder = str_replace('/', '_', $addonName);
     } else {
         $package = str_replace('_', '/', $addonName);
         $folder = $addonName;
     }
     $repository = 'file://addons/' . $folder . '/profiles';
     $reapply = $input->getOption('reapply');
     $ignoredepends = $input->getOption('ignoredepends');
     if (empty(glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml'))) {
         $output->writeln("<error>No profiles found.</error>");
         return false;
     }
     if (!$ignoredepends) {
         $addon_utilities->checkDependencies($folder);
     }
     $addons = \TikiAddons::getInstalled();
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     foreach (glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml') as $file) {
         $profileName = str_replace('.yml', '', basename($file));
         $profile = \Tiki_Profile::fromNames($repository, $profileName);
         if (!$profile) {
             $output->writeln("<error>Profile {$profileName} not found.</error>");
             continue;
         }
         $isInstalled = $installer->isInstalled($profile);
         if ($isInstalled && $reapply) {
             $installer->forget($profile);
             $isInstalled = false;
         }
         if (!$isInstalled) {
             $transaction = $tikilib->begin();
             if ($installer->install($profile)) {
                 $addon_utilities->updateProfile($folder, $addons[$package]->version, $profileName);
                 $transaction->commit();
                 $output->writeln("Profile {$profileName} applied.");
             } else {
                 $output->writeln("<error>Profile {$profileName} installation failed:</error>");
                 foreach ($installer->getFeedback() as $error) {
                     $output->writeln("<error>{$error}</error>");
                 }
             }
         } else {
             $output->writeln("<info>Profile {$profileName} was already applied. Nothing happened.</info>");
         }
     }
 }
Exemplo n.º 4
0
 function _install()
 {
     global $tikilib;
     $this->fetchData();
     $this->replaceReferences($this->name);
     $this->replaceReferences($this->description);
     $this->replaceReferences($this->parent);
     $this->replaceReferences($this->migrateparent);
     $this->replaceReferences($this->items);
     $categlib = TikiLib::lib('categ');
     if ($id = $categlib->exist_child_category($this->parent, $this->name)) {
         $categlib->update_category($id, $this->name, $this->description, $this->parent);
     } else {
         $id = $categlib->add_category($this->parent, $this->name, $this->description);
     }
     if ($this->migrateparent && ($from = $categlib->exist_child_category($this->migrateparent, $this->name))) {
         $categlib->move_all_objects($from, $id);
     }
     foreach ($this->items as $item) {
         list($type, $object) = $item;
         $type = Tiki_Profile_Installer::convertType($type);
         $object = Tiki_Profile_Installer::convertObject($type, $object);
         $categlib->categorize_any($type, $object, $id);
     }
     return $id;
 }
Exemplo n.º 5
0
 function getList($source = '', $categories = array(), $profilename = '')
 {
     $installer = new Tiki_Profile_Installer();
     $list = array();
     $sources = $this->getSources();
     foreach ($sources as $s) {
         if ($source && $s['url'] != $source) {
             continue;
         }
         if (!$s['lastupdate']) {
             continue;
         }
         $fp = fopen($this->getCacheLocation($s['url']), 'r');
         while (false !== ($row = fgetcsv($fp, 200, "\t"))) {
             if (count($row) != 3) {
                 continue;
             }
             list($c, $t, $i) = $row;
             $key = "{$s['url']}#{$i}";
             if ($profilename && stripos($i, $profilename) === false) {
                 continue;
             }
             if (array_key_exists($key, $list)) {
                 $list[$key]['categories'][] = $c;
             } else {
                 $list[$key] = array('domain' => $s['domain'], 'categories' => array($c), 'name' => $i, 'installed' => $installer->isKeyInstalled($s['domain'], $i));
             }
         }
         fclose($fp);
         // Apply category filter
         foreach ($list as $pkey => $profile) {
             $in = true;
             // If there are no required categories, don't filter anything.
             if (!empty($categories)) {
                 foreach ($categories as $category) {
                     $in = false;
                     // Start assuming this required category isn't in this profile's categories
                     foreach ($profile['categories'] as $pcategory) {
                         if ($category == $pcategory) {
                             $in = true;
                             break;
                         }
                     }
                     if (!$in) {
                         break;
                     }
                 }
             }
             if (!$in) {
                 unset($list[$pkey]);
             }
         }
     }
     return array_values($list);
 }
Exemplo n.º 6
0
function wikiplugin_datachannel($data, $params)
{
    static $execution = 0;
    global $prefs, $smarty;
    $executionId = 'datachannel-exec-' . ++$execution;
    $fields = array();
    $lines = explode("\n", $data);
    $lines = array_map('trim', $lines);
    $lines = array_filter($lines);
    foreach ($lines as $line) {
        $parts = explode(',', $line, 2);
        if (count($parts) == 2) {
            $fields[$parts[0]] = $parts[1];
        }
    }
    require_once 'lib/profilelib/profilelib.php';
    require_once 'lib/profilelib/channellib.php';
    require_once 'lib/profilelib/installlib.php';
    $groups = Perms::get()->getGroups();
    $config = Tiki_Profile_ChannelList::fromConfiguration($prefs['profile_channels']);
    if ($config->canExecuteChannels(array($params['channel']), $groups)) {
        if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['datachannel_execution']) && $_POST['datachannel_execution'] == $executionId) {
            $input = array_intersect_key($_POST, $fields);
            $static = $params;
            unset($static['channel']);
            $userInput = array_merge($input, $static);
            Tiki_Profile::useUnicityPrefix(uniqid());
            $installer = new Tiki_Profile_Installer();
            $installer->limitGlobalPreferences(array());
            $profiles = $config->getProfiles(array($params['channel']));
            $profile = reset($profiles);
            $installer->setUserData($userInput);
            $installer->install($profile);
            header('Location: ' . $_SERVER['REQUEST_URI']);
        } else {
            $smarty->assign('datachannel_fields', $fields);
            $smarty->assign('datachannel_execution', $executionId);
            return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_datachannel.tpl') . '~/np~';
        }
    }
}
Exemplo n.º 7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $profileName = $input->getArgument('profile');
     $repository = $input->getArgument('repository');
     $profile = \Tiki_Profile::fromNames($repository, $profileName);
     if (!$profile) {
         $output->writeln('<error>Profile not found.</error>');
         return;
     }
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     $isInstalled = $installer->isInstalled($profile);
     if ($isInstalled) {
         $transaction = $tikilib->begin();
         $installer->forget($profile);
         $transaction->commit();
         $output->writeln('Profile forgotten.');
     } else {
         $output->writeln('<info>Profile was not installed or did not create any objects.</info>');
     }
 }
Exemplo n.º 8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $writer = $this->getProfileWriter($input);
     $group = $input->getArgument('group');
     $category = $input->getOption('with-category');
     $object = $input->getOption('with-object');
     if (\Tiki_Profile_Installer::exportGroup($writer, $group, $category, $object)) {
         $writer->save();
     } else {
         $output->writeln("<error>Group '{$group}' not found.</error>");
     }
 }
Exemplo n.º 9
0
 function _install()
 {
     global $tikilib;
     $this->fetchData();
     $this->replaceReferences($this->type);
     $this->replaceReferences($this->object);
     $this->replaceReferences($this->categories);
     $categlib = TikiLib::lib('categ');
     $type = Tiki_Profile_Installer::convertType($this->type);
     $object = Tiki_Profile_Installer::convertObject($type, $this->object);
     foreach ($this->categories as $categId) {
         $categlib->categorize_any($type, $object, $categId);
     }
     return true;
 }
Exemplo n.º 10
0
function wikiplugin_profile( $data, $params )
{
	require_once 'lib/profilelib/profilelib.php';
	require_once 'lib/profilelib/installlib.php';

	global $tiki_p_admin;

	if ( $tiki_p_admin != 'y' ) {
		return '__' . tra('Profile plugin only available to administrators') . '__';
	}

	$params = array_merge(array('domain' => 'profiles.tiki.org'), $params);

	if ( !isset( $params['name'] ) ) {
		return 'Missing parameter __name__';
	}

	$profile = Tiki_Profile::fromNames($params['domain'], $params['name']);

	if ( $profile ) {
		$installer = new Tiki_Profile_Installer;

		try {
			if ( $installer->isInstalled($profile) ) {
				if ( $_POST['reinstall'] == "{$params['domain']}/{$params['name']}" ) {
					$installer->forget($profile);
					$installer->install($profile);

					header('Location: ' . $_SERVER['REQUEST_URI']);
					exit;
				}
			} else {
				if ( $_POST['install'] == "{$params['domain']}/{$params['name']}" ) {
					$installer->install($profile);

					header('Location: ' . $_SERVER['REQUEST_URI']);
					exit;
				}
			}
		} catch( Exception $e ) {
			return '__' . $e->getMessage() . '__';
		}

		global $smarty;
		$smarty->assign('profile_is_installed', $installer->isInstalled($profile));
		$smarty->assign('profile_key', "{$params['domain']}/{$params['name']}");
		return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_profile.tpl') . '~/np~';
	} else {
		return '__' . tr('Profile %0/%1 not found', $params['domain'], $params['name']) . '__';
	}
}
Exemplo n.º 11
0
 function getFolderFromObject($type, $id)
 {
     $type = Tiki_Profile_Installer::convertTypeInvert($type);
     $domain = $this->table('tiki_profile_symbols')->fetchOne('domain', array('value' => $id, 'type' => $type));
     $folder = str_replace('file://addons/', '', $domain);
     $folder = str_replace('/profiles', '', $folder);
     return $folder;
 }
Exemplo n.º 12
0
if ( ! $config->canExecuteChannels($channels, $groups) ) {
	$access->display_error(
					'tiki-channel.php',
					tra('One of the requested channels cannot be requested. It does not exist or permission is denied.')
	);
}

$profiles = $config->getProfiles($channels);

if ( count($profiles) != count($channels) ) {
	$access->display_error('tiki-channel.php', tra('One of the install profiles could not be obtained.'));
}

Tiki_Profile::useUnicityPrefix(uniqid());
$installer = new Tiki_Profile_Installer;
$installer->limitGlobalPreferences(array());

foreach ( $calls as $call ) {
	list($channel, $userInput) = $call;

	// Profile can be installed multiple times
	// Only last values preserved
	$profile = $profiles[$channel];
	$installer->forget($profile);

	$installer->setUserData($userInput);
	$installer->install($profile);
}

if ( isset($_REQUEST['return_uri']) ) {
Exemplo n.º 13
0
function wikiplugin_datachannel($data, $params)
{
    static $execution = 0;
    global $prefs, $smarty, $headerlib;
    $executionId = 'datachannel-exec-' . ++$execution;
    if (isset($params['price']) && $params['price'] == 0) {
        // Convert things like 0.00 to empty
        unset($params['price']);
    }
    $fields = array();
    $inputfields = array();
    $lines = explode("\n", $data);
    $lines = array_map('trim', $lines);
    $lines = array_filter($lines);
    $js = '';
    if (!isset($params['array_values'])) {
        $params['array_values'] = 'n';
    }
    foreach ($lines as $line) {
        $parts = explode(',', $line, 2);
        $parts = array_map('trim', $parts);
        if (count($parts) == 2) {
            if (strpos($parts[1], 'external') === 0) {
                // e.g. "fieldid,external=fieldname"
                $moreparts = explode('=', $parts[1], 2);
                $moreparts = array_map('trim', $moreparts);
                if (count($moreparts) < 2) {
                    $moreparts[1] = $parts[0];
                    // no fieldname supplied so use same as fieldid
                }
                $fields[$parts[0]] = $moreparts[0];
                if ($params['array_values'] === 'y' && preg_match('/[\\[\\]\\.#\\=]/', $moreparts[1])) {
                    // check for [ ] = or . which would be a jQuery selector
                    // might select multiple inputs
                    $js .= "\n" . '$("input[name=\'' . $parts[0] . '\']").val( unescape($("' . $moreparts[1] . '").serialize()));';
                } else {
                    // otherwise it's an id
                    $js .= "\n" . '$("input[name=\'' . $parts[0] . '\']").val( unescape($("#' . $moreparts[1] . '").val()));';
                }
                $inputfields[$parts[0]] = 'external';
            } elseif (strpos($parts[1], 'hidden') === 0) {
                $moreparts = explode('=', $parts[1], 2);
                $moreparts = array_map('trim', $moreparts);
                $fields[$parts[0]] = $moreparts[1];
                $inputfields[$parts[0]] = 'hidden';
            } else {
                $fields[$parts[0]] = $parts[1];
                $inputfields[$parts[0]] = $parts[1];
            }
        }
    }
    $groups = Perms::get()->getGroups();
    $config = Tiki_Profile_ChannelList::fromConfiguration($prefs['profile_channels']);
    if ($config->canExecuteChannels(array($params['channel']), $groups, true)) {
        $smarty->assign('datachannel_execution', $executionId);
        if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['datachannel_execution']) && $_POST['datachannel_execution'] == $executionId && $config->canExecuteChannels(array($params['channel']), $groups)) {
            $input = array_intersect_key(array_map('trim', $_POST), $inputfields);
            $itemIds = array();
            // process possible arrays in post
            if ($params['array_values'] === 'y') {
                foreach ($input as $key => $val) {
                    if (!empty($val)) {
                        parse_str($val, $vals);
                        if (is_array($vals)) {
                            // serialized collection of inputs
                            $arr = array();
                            if ($key == 'itemId') {
                                foreach ($vals as $v) {
                                    // itemId[x,y,z]
                                    if (is_array($v)) {
                                        $arr = array_merge($arr, $v);
                                    }
                                }
                                $itemIds = $arr;
                            } else {
                                foreach ($vals as $v) {
                                    // fieldname[x=>a,y=>b,z=>c]
                                    if (is_array($v)) {
                                        foreach ($v as $k => $kv) {
                                            if (in_array($k, $itemIds)) {
                                                // check if sent in itemIds array
                                                $arr[] = $kv;
                                                // (e.g. from trackerlist checkboxes)
                                            }
                                        }
                                    } else {
                                        $arr = $val;
                                        // not an array, so use the initial string val
                                    }
                                }
                            }
                            $input[$key] = $arr;
                        }
                    }
                }
            }
            $inputs = array();
            if ($params['array_values'] === 'y' && !empty($itemIds)) {
                $cid = count($itemIds);
                for ($i = 0; $i < $cid; $i++) {
                    // reorganise array
                    $arr = array();
                    foreach (array_keys($input) as $k) {
                        if (isset($input[$k]) && is_array($input[$k])) {
                            $arr[$k] = $input[$k][$i];
                        } else {
                            $arr[$k] = $input[$k];
                        }
                    }
                    $inputs[] = $arr;
                }
            } else {
                $inputs[] = $input;
            }
            $static = $params;
            $unsets = wikiplugin_datachannel_info();
            // get defined params
            $unsets = array_keys($unsets['params']);
            foreach ($unsets as $un) {
                // remove defined params leaving user supplied ones
                unset($static[$un]);
            }
            if (!empty($params['price'])) {
                global $paymentlib;
                require_once 'lib/payment/paymentlib.php';
                $desc = empty($params['paymentlabel']) ? tr('Datachannel:', $prefs['site_language']) . ' ' . $params['channel'] : $params['paymentlabel'];
                $posts = array();
                foreach ($input as $key => $post) {
                    $posts[$key] = $post;
                    $desc .= '/' . $post;
                }
                $id = $paymentlib->request_payment($desc, $params['price'], $prefs['payment_default_delay']);
                $paymentlib->register_behavior($id, 'complete', 'execute_datachannel', array($data, $params, $posts, $executionId));
                require_once 'lib/smarty_tiki/function.payment.php';
                return '^~np~' . smarty_function_payment(array('id' => $id), $smarty) . '~/np~^';
            }
            foreach ($inputs as $input) {
                $userInput = array_merge($input, $static);
                Tiki_Profile::useUnicityPrefix(uniqid());
                $profiles = $config->getProfiles(array($params['channel']));
                $profile = reset($profiles);
                $profile->removeSymbols();
                Tiki_Profile::useUnicityPrefix(uniqid());
                $installer = new Tiki_Profile_Installer();
                //TODO: What is the following line for? Future feature to limit capabilities of data channels?
                //$installer->limitGlobalPreferences( array() );
                // jb tiki6: looks like if set to an empty array it would prevent any prefs being set
                // i guess the idea is to be able to restrict the settable prefs to only harmless ones for security
                $installer->setUserData($userInput);
                if (!empty($params['debug']) && $params['debug'] === 'y') {
                    $installer->setDebug();
                }
                $params['emptyCache'] = isset($params['emptyCache']) ? $params['emptyCache'] : 'all';
                $installer->install($profile, $params['emptyCache']);
            }
            if (empty($params['returnURI'])) {
                $params['returnURI'] = $_SERVER['HTTP_REFERER'];
            }
            // default to return to same page
            if (empty($params['debug']) || $params['debug'] != 'y') {
                if (isset($params['quietReturn']) && $params['quietReturn'] == 'y') {
                    return true;
                } else {
                    header('Location: ' . $params['returnURI']);
                }
                die;
            }
            $smarty->assign('datachannel_feedbacks', array_merge($installer->getFeedback(), $profile->getFeedback()));
        }
        $smarty->assign('datachannel_inputfields', $inputfields);
        $smarty->assign('datachannel_fields', $fields);
        $smarty->assign('button_label', !empty($params['buttonLabel']) ? $params['buttonLabel'] : 'Go');
        $smarty->assign('form_class_attr', !empty($params['class']) ? ' class="' . $params['class'] . '"' : '');
        if (!empty($js)) {
            $headerlib->add_js("function datachannel_form_submit{$execution}() {{$js}\nreturn true;\n}");
            $smarty->assign('datachannel_form_onsubmit', ' onsubmit="return datachannel_form_submit' . $execution . '();"');
        } else {
            $smarty->assign('datachannel_form_onsubmit', '');
        }
        return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_datachannel.tpl') . '~/np~';
    }
}
Exemplo n.º 14
0
 private function setupGroup($groupName, $info, $permissions, $objects, $groupMap)
 {
     $userlib = TikiLib::lib('user');
     if (!$userlib->group_exists($groupName)) {
         $userlib->add_group($groupName, $info['description'], $info['home'], $info['user_tracker'], $info['group_tracker'], implode(':', $info['registration_fields']), $info['user_signup'], $info['default_category'], $info['theme'], $info['user_tracker_field'], $info['group_tracker_field']);
     } else {
         $userlib->change_group($groupName, $groupName, $info['description'], $info['home'], $info['user_tracker'], $info['group_tracker'], $info['user_tracker_field'], $info['group_tracker_field'], implode(':', $info['registration_fields']), $info['user_signup'], $info['default_category'], $info['theme']);
     }
     if (count($info['include'])) {
         $userlib->remove_all_inclusions($groupName);
         foreach ($info['include'] as $included) {
             $userlib->group_inclusion($groupName, $included);
         }
     }
     foreach ($permissions as $perm => $v) {
         if ($v == 'y') {
             $userlib->assign_permission_to_group($perm, $groupName);
         } else {
             $userlib->remove_permission_from_group($perm, $groupName);
         }
         $this->setFeedback(sprintf(tra('Modified permission %s for %s'), $perm, $groupName));
     }
     foreach ($objects as $data) {
         foreach ($data['permissions'] as $perm => $v) {
             $data['id'] = trim($data['id']);
             $data['type'] = self::convertType($data['type']);
             $data['id'] = Tiki_Profile_Installer::convertObject($data['type'], $data['id'], array('groupMap' => $groupMap));
             if ($v == 'y') {
                 $userlib->assign_object_permission($groupName, $data['id'], $data['type'], $perm);
             } else {
                 $userlib->remove_object_permission($groupName, $data['id'], $data['type'], $perm);
             }
             $this->setFeedback(sprintf(tra('Modified permission %s on %s/%s for %s'), $perm, $data['type'], $data['id'], $groupName));
         }
     }
     global $user;
     if ($info['autojoin'] == 'y' && $user) {
         $userlib->assign_user_to_group($user, $groupName);
         $this->setFeedback(tr('User %0 was added to %1', $user, $groupName));
     }
 }
/**
 * @param $installer
 */
function upgrade_99999999_image_plugins_kill_tiki($installer)
{
    global $tikilib, $prefs, $tikiroot, $user_overrider_prefs, $tiki_p_trust_input, $smarty, $access, $local_php;
    // globals are required here for tiki-setup_base.php
    require_once 'db/tiki-db.php';
    require_once 'lib/tikilib.php';
    $tikilib = new TikiLib();
    // ******************************** THUMB plugin
    $plugstring = <<<PLUGINTEXT
{CODE(caption=>YAML,wrap=1)}
objects:
 -
  type: plugin_alias
  ref: combine_thumb
  data:
   name: THUMB
   implementation: img
   description:
    name: Thumbnail
    documentation: PluginThumb
    description: Displays a thumbnail of an image that enlarges upon mouseover or links to a target
    prefs:
    params:
     file:
      required: false
      name: File ID
      description: File ID from the file gallery.
      filter: digits
     id:
      required: false
      name: Image ID
      description: Image ID from the image gallery.
      filter: digits
     image:
      required: false
      name: Image URL
      description: URL to the image.
      filter: url
     max:
      required: false
      name: Maximum Size
      description: Maximum width or height for the image.
      filter: int
     float:
      required: false
      name: Alignment
      description: Set alignment as left, right or none.
      filter: alpha
      options:
       none:
        text: None
       left:
        text: Left
       right:
        text: Right
     url:
      required: false
      name: Link Target
      description: Link target of the image.
      filter: url
   body:
    default: ''
   params:
    fileId:
     pattern: %file%
     params:
      file:
       token: file
    id:
     pattern: %id%
     params:
      id:
       token: id
    src:
     pattern: %image%
     params:
      image:
       token: image
    max:
     pattern: %max%
     params:
      max:
       token: max
    imalign:
     pattern: %float%
     params:
      float:
       token: float
    link:
     pattern: %url%
     params:
      url:
       token: url
    thumb: mouseover
{CODE}
PLUGINTEXT;
    $profile_installer = new Tiki_Profile_Installer();
    $profile = Tiki_Profile::fromString($plugstring, 'THUMB');
    $profile->removeSymbols();
    $profile_installer->install($profile);
    // ********************************  IMAGE plugin
    $plugstring = <<<PLUGINTEXT
{CODE(caption=>YAML,wrap=1)}
objects:
 -
  type: plugin_alias
  ref: combine_image
  data:
   name: IMAGE
   implementation: img
   description:
    name: Image
    documentation: PluginImage
    description: Display images (transitional alias, use IMG plugin instead)
    params:
     fileId:
      required: false
      name: File ID
      description: Numeric ID of an image in a File Gallery (or comma-separated list). "fileId", "id" or "src" required.
     id:
      required: false
      name: Image ID
      description: Numeric ID of an image in an Image Gallery (or comma-separated list). "fileId", "id" or "src" required.
     src:
      required: false
      name: Image source
      description: Full URL to the image to display. "fileId", "id" or "src" required.
      filter: url
     scalesize:
      required: false
      name: Maximum size
      description: Maximum width or height for the image in pixels.
     height:
      required: false
      name: Image height
      description: Height in pixels.
      filter: int
     width:
      required: false
      name: Image width
      description: Width in pixels.
      filter: int
     link:
      required: false
      name: Link
      description: For making the image a hyperlink. Enter a url to the page the image should link to.
      filter: url
     rel:
      required: false
      name: Link relation
      description: Link relation attribute to add to the link.
     title:
      required: false
      name: Link title
      description: Link title that appears upon mouseover.
     alt:
      required: false
      name: Alternate text
      description: Alternate text that displays image doesn't load.
     align:
      required: false
      name: Align image block
      description: Enter right, left or center to align the box containing the image.
      options:
       left:
        text: Left
       right:
        text: Right
       center:
        text: Center
     block:
      required: false
      name: Wrapping control
      description: Whether to block items from wrapping next to image from the top or bottom. (top,bottom,both,none)
      options:
       '':
        text: None
       top:
        text: Top
       bottom:
        text: Bottom
       both:
        text: Both
     desc:
      required: false
      name: Description
      description: Image caption
     usemap:
      required: false
      name: Image map
      description: Name of the image map to use.
     class:
      required: false
      name: CSS class
      description: CSS class to apply to the image.
     style:
      required: false
      name: CSS syle
      description: CSS styling to apply.
     border:
      required: false
      name: Border options
      description: Border configuration for image block.
     descoptions:
      required: false
      name: Caption style
      description: Styling of image description. Use CSS syntax to override default setting.
     default:
      required: false
      name: Default configuration
      description: Default configuration definitions (usually set by admin).
     mandatory:
      required: false
      name: Mandatory configuration
      description: Mandatory configuration definitions (usually set by admin).
   body:
    default: ''
   params:
    fileId:
     pattern: %fileId%
     params:
      fileId:
       token: fileId
    id:
     pattern: %id%
     params:
      id:
       token: id
    src:
     pattern: %src%
     params:
      src:
       token: src
    max:
     pattern: %scalesize%
     params:
      scalesize:
       token: scalesize
       default: 200
    height:
     pattern: %height%
     params:
      height:
       token: height
    width:
     pattern: %width%
     params:
      width:
       token: width
    link:
     pattern: %link%
     params:
      link:
       token: link
    rel:
     pattern: %rel%
     params:
      rel:
       token: rel
    title:
     pattern: %title%
     params:
      title:
       token: title
    alt:
     pattern: %alt%
     params:
      alt:
       token: alt
    align:
     pattern: %align%
     params:
      align:
       token: align
    block:
     pattern: %block%
     params:
      block:
       token: block
    desc:
     pattern: %desc%
     params:
      desc:
       token: desc
    usemap:
     pattern: %usemap%
     params:
      usemap:
       token: usemap
    class:
     pattern: %class%
     params:
      class:
       token: class
    stylebox:
     pattern: %style%
     params:
      style:
       token: style
       default: border:3px double;padding:.1cm; font-size:12px; line-height:1.5em; margin-left:4px; width:200px;
    styledesc:
     pattern: %descoptions%
     params:
      descoptions:
       token: descoptions
    default:
     pattern: %default%
     params:
      default:
       token: default
    mandatory:
     pattern: %mandatory%
     params:
      mandatory:
       token: mandatory
    button: y 
    imalign: center  
{CODE}
PLUGINTEXT;
    $profile_installer = new Tiki_Profile_Installer();
    $profile = Tiki_Profile::fromString($plugstring, 'IMAGE');
    $profile->removeSymbols();
    $profile_installer->install($profile);
    // ********************************  PICTURE plugin
    $plugstring = <<<PLUGINTEXT
{CODE(caption=>YAML,wrap=1)}
objects:
 -
  type: plugin_alias
  ref: combine_picture
  data:
   name: PICTURE
   implementation: img
   description:
    name: Picture
    description: Display uploaded pictures
    params:
     file:
      required: true
      name: File path
      description: File name or path of the image.
   body:
    default: ''
   params:
    src:
     pattern: %file%
     params:
      file:
       token: file
{CODE}
PLUGINTEXT;
    $profile_installer = new Tiki_Profile_Installer();
    $profile = Tiki_Profile::fromString($plugstring, 'PICTURE');
    $profile->removeSymbols();
    $profile_installer->install($profile);
}
Exemplo n.º 16
0
             $smarty->assign_by_ref('profilefeedback', $profilefeedback);
         }
     }
 }
 // }}}
 if (isset($_GET['refresh'])) {
     $toRefresh = (int) $_GET['refresh'];
     if (isset($sources[$toRefresh])) {
         echo json_encode(array('status' => $list->refreshCache($sources[$toRefresh]['url']) ? 'open' : 'closed', 'lastupdate' => date('Y-m-d H:i:s')));
     } else {
         echo '{}';
     }
     exit;
 }
 if (isset($_GET['getinfo'], $_GET['pd'], $_GET['pp'])) {
     $installer = new Tiki_Profile_Installer();
     $profile = Tiki_Profile::fromNames($_GET['pd'], $_GET['pp']);
     $error = '';
     // Check if profile is available.
     // This will not be the case for a misconfigured profile server
     if ($profile === false) {
         $error = "Profile is not available: " . $_GET['pd'] . ", " . $_GET['pp'];
     }
     try {
         if (!empty($error)) {
             $sequencable = false;
         } else {
             if (!($deps = $installer->getInstallOrder($profile))) {
                 $deps = $profile->getRequiredProfiles(true);
                 $deps[] = $profile;
                 $sequencable = false;
Exemplo n.º 17
0
include_once 'lib/core/Zend/Log/Writer/Syslog.php';
$log_level = Zend_Log::INFO;
$writer = new Zend_Log_Writer_Stream('php://output');
$writer->addFilter((int) $log_level);
$logger = new Zend_Log($writer);
$logger->debug('Running search shell utility');
require_once 'lib/profilelib/profilelib.php';
require_once 'lib/profilelib/installlib.php';
if ($_SERVER['argv'][1] === 'install') {
    $args = $_SERVER['argv'];
    $script = array_shift($args);
    $command = array_shift($args);
    $profile = array_shift($args);
    $repository = array_shift($args);
    if (!$repository) {
        $repository = 'profiles.tiki.org';
    }
    if (!$profile) {
        $logger->err('Profile not specified.');
        exit(1);
    }
    $profile = Tiki_Profile::fromNames($repository, $profile);
    if (!$profile) {
        $logger->err('Profile not found');
        exit(1);
    }
    $transaction = $tikilib->begin();
    $installer = new Tiki_Profile_Installer();
    $installer->install($profile);
    $transaction->commit();
}
Exemplo n.º 18
0
 public function action_import_profile($input)
 {
     $tikilib = TikiLib::lib('tiki');
     $perms = Perms::get();
     if (!$perms->admin) {
         throw new Services_Exception_Denied(tr('Reserved for administrators'));
     }
     unset($success);
     $confirm = $input->confirm->int();
     if ($confirm) {
         $transaction = $tikilib->begin();
         $installer = new Tiki_Profile_Installer();
         $yaml = $input->yaml->string();
         $name = "tracker_import:" . md5($yaml);
         $profile = Tiki_Profile::fromString('{CODE(caption="yaml")}' . "\n" . $yaml . "\n" . '{CODE}', $name);
         if ($installer->isInstallable($profile) == true) {
             if ($installer->isInstalled($profile) == true) {
                 $installer->forget($profile);
             }
             $installer->install($profile);
             $feedback = $installer->getFeedback();
             $transaction->commit();
             return $feedback;
             $success = 1;
         } else {
             return false;
         }
     }
     return array('title' => tr('Import Tracker From Profile/YAML'), 'modal' => $input->modal->int());
 }
Exemplo n.º 19
0
 private function getObject($type, $id)
 {
     $type = Tiki_Profile_Installer::convertTypeInvert($type);
     foreach ($this->data['objects'] as $object) {
         if ($object['type'] == $type && $object['_id'] == $id) {
             return $object;
         }
     }
     return null;
 }
Exemplo n.º 20
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $addon_utilities = new \TikiAddons_Utilities();
     $addonName = $input->getArgument('addon');
     if (strpos($addonName, '/') !== false && strpos($addonName, '_') === false) {
         $package = $addonName;
         $folder = str_replace('/', '_', $addonName);
     } else {
         $package = str_replace('_', '/', $addonName);
         $folder = $addonName;
     }
     $repository = 'file://addons/' . $folder . '/profiles';
     $confirm = $input->getOption('confirm');
     $uninstallInfo = json_decode(file_get_contents(TIKI_PATH . '/addons/' . $folder . '/uninstall.json'));
     $removeItems = $uninstallInfo->remove;
     $willRemove = false;
     foreach ($removeItems as $remove) {
         if (empty($remove->profile)) {
             $profile = '';
         } else {
             $profile = $remove->profile;
         }
         if (empty($remove->domain)) {
             $domain = '';
         } else {
             $domain = $remove->domain;
         }
         $objectId = $addon_utilities->getObjectId($folder, $remove->ref, $profile, $domain);
         if (is_array($objectId)) {
             $objectIds = $objectId;
         } else {
             $objectIds = [$objectId];
         }
         foreach ($objectIds as $objectId) {
             $objectType = $remove->type;
             if ($objectId) {
                 if ($confirm) {
                     $addon_utilities->removeObject($objectId, $objectType);
                     $output->writeln("{$objectType} '{$objectId}' has been deleted.");
                 } else {
                     $output->writeln("<info>{$objectType} '{$objectId}' will be deleted.</info>");
                 }
                 $willRemove = true;
             }
         }
     }
     $installedProfiles = $addon_utilities->getInstalledProfiles($folder);
     if (!$confirm && ($willRemove || !empty($installedProfiles))) {
         $output->writeln("<error>There will be NO undo, and all data in the above objects will be deleted.</error>");
         $output->writeln("<info>Use the --confirm option to proceed with removal.</info>");
     } elseif (!$willRemove) {
         $output->writeln("<info>It looks like the objects for this addon have been removed already.</info>");
     }
     if (empty($installedProfiles)) {
         $output->writeln("<info>It looks like the profiles for this addon have been removed from addon registry already.</info>");
     }
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     if ($confirm) {
         foreach (array_keys($installedProfiles) as $profileName) {
             $profile = \Tiki_Profile::fromNames($repository, $profileName);
             if (!$profile) {
                 $output->writeln("<error>Profile {$profileName} not found.</error>");
                 continue;
             }
             $isInstalled = $installer->isInstalled($profile);
             if ($isInstalled) {
                 $transaction = $tikilib->begin();
                 $installer->forget($profile);
                 $transaction->commit();
                 $output->writeln("Profile {$profileName} forgotten.");
             } else {
                 $output->writeln("<info>Profile {$profileName} was not installed or did not create any objects.</info>");
             }
             $addon_utilities->forgetProfileAllVersions($folder, $profileName);
             $output->writeln("Profile {$profileName} forgotten from addon registry.");
         }
     }
 }
Exemplo n.º 21
0
 private function applyProfile($profileFile)
 {
     // By the time a profile install is requested, the installation should be functional enough to work
     require_once 'tiki-setup.php';
     $directory = dirname($profileFile);
     $profile = substr(basename($profileFile), 0, -4);
     $profile = Tiki_Profile::fromFile($directory, $profile);
     $tx = $this->begin();
     $installer = new Tiki_Profile_Installer();
     $installer->install($profile);
     $tx->commit();
 }
Exemplo n.º 22
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $addon_utilities = new \TikiAddons_Utilities();
     $addonName = $input->getArgument('addon');
     if (strpos($addonName, '/') !== false && strpos($addonName, '_') === false) {
         $package = $addonName;
         $folder = str_replace('/', '_', $addonName);
     } else {
         $package = str_replace('_', '/', $addonName);
         $folder = $addonName;
     }
     $repository = 'file://addons/' . $folder . '/profiles';
     $ignoredepends = $input->getOption('ignoredepends');
     $confirm = $input->getOption('confirm');
     if (empty(glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml'))) {
         $output->writeln("<error>No profiles found.</error>");
         return;
     }
     if (!$ignoredepends) {
         $addon_utilities->checkDependencies($folder);
     }
     $upgradeInfo = json_decode(file_get_contents(TIKI_PATH . '/addons/' . $folder . '/upgrade.json'));
     $validVersions = array();
     foreach ($upgradeInfo as $version => $info) {
         $validVersions[] = $version;
     }
     $config = null;
     $lastVersionInstalled = $addon_utilities->getLastVersionInstalled($folder);
     $reapplyProfiles = array();
     $forgetProfiles = array();
     $removeItems = array();
     foreach ($validVersions as $v) {
         if ($addon_utilities->checkVersionMatch($lastVersionInstalled, $v)) {
             $config = $upgradeInfo->{$v};
             $removeItems = $config->remove;
             $forgetProfiles = $config->forget;
             $reapplyProfiles = $config->reapply;
             break;
         }
     }
     $addons = \TikiAddons::getInstalled();
     if (!$config) {
         if (strnatcmp($lastVersionInstalled, $addons[$package]->version) <= 0) {
             $output->writeln("<error>Currently installed version ({$lastVersionInstalled}) is already up to date.</error>");
         } else {
             $output->writeln("<error>No valid versions currently installed to upgrade found.</error>");
         }
         return false;
     }
     $installedProfiles = $addon_utilities->getInstalledProfiles($folder);
     $installedProfileNames = array_keys($installedProfiles);
     $willRemove = false;
     foreach ($removeItems as $remove) {
         if (empty($remove->profile)) {
             $profile = '';
         } else {
             $profile = $remove->profile;
         }
         $objectId = $addon_utilities->getObjectId($folder, $remove->ref, $profile);
         $objectType = $remove->type;
         if ($objectId) {
             if ($confirm) {
                 $addon_utilities->removeObject($objectId, $objectType);
                 $output->writeln("{$objectType} '{$objectId}' has been deleted.");
             } else {
                 $output->writeln("<info>{$objectType} '{$objectId}' will be deleted.</info>");
             }
             $willRemove = true;
         }
     }
     $tikilib = \TikiLib::lib('tiki');
     $installer = new \Tiki_Profile_Installer();
     // First forget profiles that need to be forgotten
     foreach ($forgetProfiles as $toForget) {
         if (in_array($toForget, $installedProfileNames)) {
             if ($confirm || !$willRemove) {
                 $addon_utilities->forgetProfileAllVersions($folder, $toForget);
                 $profile = \Tiki_Profile::fromNames($repository, $toForget);
                 if (!$profile) {
                     $output->writeln("<error>Profile {$toForget} not found.</error>");
                 } else {
                     $installer->forget($profile);
                 }
             } else {
                 $output->writeln("<info>The installed profile {$toForget} will be forgotten.</info>");
             }
         }
     }
     if (!$confirm && $willRemove) {
         $output->writeln("<error>There will be NO undo, and all data in the above objects will be deleted as part of the upgrade.</error>");
         $output->writeln("<info>Use the --confirm option to proceed with removal and upgrade.</info>");
     }
     if ($confirm || !$willRemove) {
         // Finally install profiles
         foreach (glob(TIKI_PATH . '/addons/' . $folder . '/profiles/*.yml') as $file) {
             $profileName = str_replace('.yml', '', basename($file));
             $profile = \Tiki_Profile::fromNames($repository, $profileName);
             if (in_array($profileName, $reapplyProfiles)) {
                 $reapply = true;
             } else {
                 $reapply = false;
             }
             if (!$profile) {
                 $output->writeln("<error>Profile {$profileName} not found.</error>");
                 continue;
             }
             $isInstalled = $installer->isInstalled($profile);
             if ($isInstalled && $reapply) {
                 $installer->forget($profile);
                 $isInstalled = false;
             }
             if (!$isInstalled) {
                 $transaction = $tikilib->begin();
                 if ($installer->install($profile)) {
                     $addon_utilities->updateProfile($folder, $addons[$package]->version, $profileName);
                     $transaction->commit();
                     $output->writeln("Profile {$profileName} applied.");
                 } else {
                     $output->writeln("<error>Profile {$profileName} installation failed:</error>");
                     foreach ($installer->getFeedback() as $error) {
                         $output->writeln("<error>{$error}</error>");
                     }
                 }
             } else {
                 $output->writeln("<info>Profile {$profileName} was already applied. Nothing happened.</info>");
             }
         }
     }
 }
Exemplo n.º 23
0
 function applyTemplate(array $template, array $data)
 {
     $profile = Tiki_Profile::fromString($template['definition'], uniqid());
     $installer = new Tiki_Profile_Installer();
     $installer->setUserData($data);
     $value = $installer->install($profile);
     if (!$value) {
         throw new Services_Exception('Profile could not be installed.');
     }
 }
Exemplo n.º 24
0
 function request_payment()
 {
     global $prefs, $user;
     $tikilib = TikiLib::lib('tiki');
     $paymentlib = TikiLib::lib('payment');
     $total = $this->get_total();
     if ($total > 0 || $this->total_no_discount) {
         // if anonymous shopping to set pref as to which shopperinfo to show in description
         if (empty($user) && $prefs['payment_cart_anonymous'] === 'y') {
             $shopperinfo_descvar = 'email';
             // TODO: make this a pref
             if (!empty($_SESSION['shopperinfo'][$shopperinfo_descvar])) {
                 $shopperinfo_desc = $_SESSION['shopperinfo'][$shopperinfo_descvar];
                 $description = tra($prefs['payment_cart_heading']) . " ({$shopperinfo_desc})";
             } else {
                 $description = tra($prefs['payment_cart_heading']);
             }
         } else {
             $description = tra($prefs['payment_cart_heading']) . " ({$user})";
         }
         $invoice = $paymentlib->request_payment($description, $total, $prefs['payment_default_delay'], $this->get_description());
         foreach ($this->get_behaviors() as $behavior) {
             $paymentlib->register_behavior($invoice, $behavior['event'], $behavior['behavior'], $behavior['arguments']);
         }
     } else {
         $invoice = 0;
         foreach ($this->get_behaviors() as $behavior) {
             if ($behavior['event'] == 'complete') {
                 $name = $behavior['behavior'];
                 $file = dirname(__FILE__) . "/behavior/{$name}.php";
                 $function = 'payment_behavior_' . $name;
                 require_once $file;
                 call_user_func_array($function, $behavior['arguments']);
             }
         }
     }
     // Handle anonymous user (not logged in) shopping that require only email
     if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
         if (!empty($_SESSION['shopperinfo'])) {
             // should also check for pref that this anonymous shopping feature is on
             // First create shopper info in shopper tracker
             global $record_profile_items_created;
             $record_profile_items_created = array();
             if (!empty($_SESSION['shopperinfoprofile'])) {
                 $shopper_profile_name = $_SESSION['shopperinfoprofile'];
             } else {
                 $shopper_profile_name = $prefs['payment_cart_anonshopper_profile'];
             }
             $shopperprofile = Tiki_Profile::fromDb($shopper_profile_name);
             $profileinstaller = new Tiki_Profile_Installer();
             $profileinstaller->forget($shopperprofile);
             // profile can be installed multiple times
             $profileinstaller->setUserData($_SESSION['shopperinfo']);
             $profileinstaller->install($shopperprofile);
             // Then set user to shopper ID
             $cartuser = $record_profile_items_created[0];
             $record_profile_items_created = array();
         } else {
             $this->empty_cart();
             return $invoice;
         }
     } else {
         $cartuser = $user;
     }
     $userInput = array('user' => $cartuser, 'time' => $tikilib->now, 'total' => $total, 'invoice' => $invoice, 'weight' => $this->get_total_weight());
     if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
         $orderprofile = Tiki_Profile::fromDb($prefs['payment_cart_anonorders_profile']);
         $orderitemprofile = Tiki_Profile::fromDb($prefs['payment_cart_anonorderitems_profile']);
     } else {
         $orderprofile = Tiki_Profile::fromDb($prefs['payment_cart_orders_profile']);
         $orderitemprofile = Tiki_Profile::fromDb($prefs['payment_cart_orderitems_profile']);
     }
     if ($user && $prefs['payment_cart_orders'] == 'y' || !$user && $prefs['payment_cart_anonymous'] == 'y') {
         if (!$orderprofile) {
             TikiLib::lib('errorreport')->report(tra('Advanced Shopping Cart setup error: Orders profile missing.'));
             return false;
         }
         $profileinstaller = new Tiki_Profile_Installer();
         $profileinstaller->forget($orderprofile);
         // profile can be installed multiple times
         $profileinstaller->setUserData($userInput);
     } else {
         $profileinstaller = '';
     }
     global $record_profile_items_created;
     $record_profile_items_created = array();
     if ($user && $prefs['payment_cart_orders'] == 'y' || !$user && $prefs['payment_cart_anonymous'] == 'y') {
         $profileinstaller->install($orderprofile, 'none');
     }
     $content = $this->get_content();
     foreach ($content as $info) {
         if (!isset($info['is_gift_certificate']) || !$info['is_gift_certificate']) {
             $process_info = $this->process_item($invoice, $total, $info, $userInput, $cartuser, $profileinstaller, $orderitemprofile);
         }
     }
     $email_template_ids = array();
     if (isset($process_info['product_classes']) && is_array($process_info['product_classes'])) {
         $product_classes = array_unique($process_info['product_classes']);
     } else {
         $product_classes = array();
     }
     foreach ($product_classes as $pc) {
         if ($email_template_id = $this->get_tracker_value_custom($prefs['payment_cart_productclasses_tracker_name'], 'Email Template ID', $pc)) {
             $email_template_ids[] = $email_template_id;
         }
     }
     if (!empty($record_profile_items_created)) {
         if ($total > 0) {
             $paymentlib->register_behavior($invoice, 'complete', 'record_cart_order', array($record_profile_items_created));
             $paymentlib->register_behavior($invoice, 'cancel', 'cancel_cart_order', array($record_profile_items_created));
             if ($user) {
                 $paymentlib->register_behavior($invoice, 'complete', 'cart_send_confirm_email', array($user, $email_template_ids));
             }
         } else {
             require_once 'lib/payment/behavior/record_cart_order.php';
             payment_behavior_record_cart_order($record_profile_items_created);
             if ($user) {
                 require_once 'lib/payment/behavior/cart_send_confirm_email.php';
                 payment_behavior_cart_send_confirm_email($user, $email_template_ids);
             }
         }
     }
     if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
         $shopperurl = 'tiki-index.php?page=' . $prefs['payment_cart_anon_reviewpage'] . '&shopper=' . intval($cartuser);
         global $tikiroot, $prefs;
         $shopperurl = $tikilib->httpPrefix(true) . $tikiroot . $shopperurl;
         require_once 'lib/auth/tokens.php';
         $tokenlib = AuthTokens::build($prefs);
         $shopperurl = $tokenlib->includeToken($shopperurl, array($prefs['payment_cart_anon_group'], 'Anonymous'));
         if (!empty($_SESSION['shopperinfo']['email'])) {
             require_once 'lib/webmail/tikimaillib.php';
             $smarty = TikiLib::lib('smarty');
             $smarty->assign('shopperurl', $shopperurl);
             $smarty->assign('email_template_ids', $email_template_ids);
             $mail_subject = $smarty->fetch('mail/cart_order_received_anon_subject.tpl');
             $mail_data = $smarty->fetch('mail/cart_order_received_anon.tpl');
             $mail = new TikiMail();
             $mail->setSubject($mail_subject);
             if ($mail_data == strip_tags($mail_data)) {
                 $mail->setText($mail_data);
             } else {
                 $mail->setHtml($mail_data);
             }
             $mail->send($_SESSION['shopperinfo']['email']);
             // the field to use probably needs to be configurable as well
         }
     }
     $this->update_gift_certificate($invoice);
     $this->update_group_discount($invoice);
     $this->empty_cart();
     return $invoice;
 }
Exemplo n.º 25
0
 public function action_import_profile($input)
 {
     global $tikilib, $access;
     $access->check_permission('tiki_p_admin');
     $transaction = $tikilib->begin();
     $installer = new Tiki_Profile_Installer();
     $yaml = $input->yaml->string();
     $name = "tracker_import:" . md5($yaml);
     $profile = Tiki_Profile::fromString('{CODE(caption="yaml")}' . "\n" . $yaml . "\n" . '{CODE}', $name);
     if ($installer->isInstallable($profile) == true) {
         if ($installer->isInstalled($profile) == true) {
             $installer->forget($profile);
         }
         $installer->install($profile);
         $feedback = $installer->getFeedback();
         $transaction->commit();
         return $feedback;
     } else {
         return false;
     }
 }