/** * @param TikiDb $db * @param $query * @param $values * @param $result */ function handle(TikiDb $db, $query, $values, $result) { global $smarty, $prefs; $msg = $db->getErrorMessage(); $q = $query; if (is_array($values)) { foreach ($values as $v) { if (is_null($v)) { $v = 'NULL'; } else { $v = "'" . addslashes($v) . "'"; } $pos = strpos($q, '?'); if ($pos !== false) { $q = substr($q, 0, $pos) . "{$v}" . substr($q, $pos + 1); } } } if (function_exists('xdebug_get_function_stack')) { /** * @param $stack * @return string */ function mydumpstack($stack) { $o = ''; foreach ($stack as $line) { $o .= '* ' . $line['file'] . " : " . $line['line'] . " -> " . $line['function'] . "(" . var_export($line['params'], true) . ")<br />"; } return $o; } $stacktrace = mydumpstack(xdebug_get_function_stack()); } else { $stacktrace = false; } require_once 'installer/installlib.php'; $installer = new Installer(); require_once 'tiki-setup.php'; $smarty->assign('msg', $msg); $smarty->assign('base_query', $query); $smarty->assign('values', $values); $smarty->assign('built_query', $q); $smarty->assign('stacktrace', $stacktrace); $smarty->assign('requires_update', $installer->requiresUpdate()); header("Cache-Control: no-cache, pre-check=0, post-check=0"); $smarty->display('database-connection-error.tpl'); $this->log($msg . ' - ' . $q); die; }
function action_create_from_url($input) { Services_Exception_Disabled::check('page_content_fetch'); Services_Exception_Denied::checkGlobal('edit_article'); $id = null; $title = null; $url = $input->url->url(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && $url) { $lib = TikiLib::lib('pagecontent'); $data = $lib->grabContent($url); if (!$data) { throw new Services_Exception_FieldError($input->errorfield->text() ?: 'url', tr('Content could not be loaded.')); } $data['content'] = trim($data['content']) == '' ? $data['content'] : '~np~' . $data['content'] . '~/np~'; $data['description'] = ''; $data['author'] = ''; $topicId = $input->topicId->int(); $articleType = $input->type->text(); $title = $data['title']; $hash = md5($data['title'] . $data['description'] . $data['content']); $id = TikiDb::get()->table('tiki_articles')->fetchOne('articleId', array('linkto' => $url)) ?: 0; if (!$id) { $tikilib = TikiLib::lib('tiki'); $publication = $tikilib->now; $expire = $publication + 3600 * 24 * 365; $rating = 10; $artlib = TikiLib::lib('art'); $id = $artlib->replace_article($title, $data['author'], $topicId, 'n', '', 0, '', '', $data['description'], $data['content'], $publication, $expire, $GLOBALS['user'], $id, 0, 0, $articleType, '', '', $url, '', '', $rating, 'n', '', '', '', '', 'y', true); } } $db = TikiDb::get(); $topics = $db->table('tiki_topics')->fetchMap('topicId', 'name', array(), -1, -1, 'name_asc'); $types = $db->table('tiki_article_types')->fetchColumn('type', array()); return ['title' => tr('Create article from URL'), 'url' => $url, 'id' => $id, 'articleTitle' => $title, 'topics' => $topics, 'types' => $types]; }
function tearDown() { global $user; $user = null; parent::tearDown(); TikiDb::get()->query('DELETE FROM `tiki_user_votings` WHERE `id` LIKE ?', array('test.%')); }
protected function execute(InputInterface $input, OutputInterface $output) { if ($since = $input->getOption('since')) { $since = strtotime($since); } $ignoreList = array(); foreach ($input->getOption('ignore') as $object) { if (preg_match("/^(?P<type>\\w+):(?P<object>.+)\$/", $object, $parts)) { $ignoreList[] = $parts; } } $since = $since ?: 0; $logs = \TikiDb::get()->table('tiki_actionlog'); $actions = $logs->fetchAll(array('timestamp' => 'lastModif', 'action', 'type' => 'objectType', 'object', 'detail' => 'comment'), array('lastModif' => $logs->greaterThan($since)), -1, -1, 'lastModif_asc'); $queue = new \Tiki_Profile_Writer_Queue(); foreach ($actions as $action) { $queue->add($action); } $writer = $this->getProfileWriter($input); if (count($ignoreList)) { foreach ($ignoreList as $entry) { $writer->addFake($entry['type'], $entry['object']); } $writer->save(); } $queue->filterIncluded($writer); $queue->filterInstalled(new \Tiki_Profile_Writer_ProfileFinder()); $output->writeln((string) $queue); }
protected function execute(InputInterface $input, OutputInterface $output) { $confirm = $input->getOption('confirm'); $perms = \Perms::get(); if (!$perms->admin_file_galleries) { throw new \Exception('Tracker Clear: Admin permission required'); } if ($confirm) { if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { $output->writeln('<info>Deleting old filegal files...</info>'); } \TikiLib::lib('filegal')->deleteOldFiles(); if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { $output->writeln('<info>Deleting old filegal files done</info>'); } } else { $query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc'; $now = time(); $files = \TikiDb::get()->query($query, array($now)); if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { if ($files->numrows) { $output->writeln("<comment>Files to delete:</comment>"); foreach ($files->result as $file) { $old = ceil(abs($now - $file['lastModif']) / 86400); $days = $old > 1 ? 'days' : 'day'; $deleteAfter = \TikiLib::lib('tiki')->get_short_datetime($file['deleteAfter']); $output->writeln("<info> \"{$file['name']}\" is {$old} {$days} old in gallery #{$file['galleryId']} (id #{$file['fileId']} deleteAfter {$deleteAfter})</info>"); } } else { $output->writeln("<comment>No files to delete</comment>"); } } } }
function action_create($input) { global $prefs; $templates = $this->utilities->getTemplateList(); if (0 === count($templates)) { throw new Services_Exception_Denied('No templates available to you'); } $name = $input->name->text(); $template = $input->template->int(); if ($template && $name) { $templateInfo = $this->utilities->getTemplate($template); $perms = Perms::get('workspace', $template); if (!$perms->workspace_instantiate) { throw new Services_Exception_Denied(); } $workspaceName = $name; $name = $templateInfo['name'] . $prefs['namespace_separator'] . $name; $transaction = TikiDb::get()->begin(); $parts = explode($prefs['namespace_separator'], $name); $this->utilities->validateCategory($parts); $this->utilities->validatePerspective($name); $this->utilities->validatePage($name); $this->utilities->validateGroup($name); $values = array('category' => $this->utilities->createCategory($parts), 'perspective' => $this->utilities->createPerspective($name), 'page' => $this->utilities->createPage($name), 'group' => $this->utilities->createGroup($name)); $values['namespace'] = $values['page']; $this->utilities->initialize($values); $this->utilities->applyTemplate($templateInfo, $values); $transaction->commit(); } return array('title' => tr('Create Workspace'), 'templates' => $templates); }
protected function execute(InputInterface $input, OutputInterface $output) { global $prefs, $url_scheme, $url_host, $tikiroot, $url_port; $days = intval($input->getArgument('days')) ?: 7; if ($input->getOption('ssl')) { $url_scheme = 'https'; } if ($input->hasOption('port')) { $url_port = (int) $input->getOption('port'); } if ($input->hasOption('path')) { $tikiroot = $input->getOption('path'); // Make sure slash before and after $tikiroot = rtrim($tikiroot, '/') . '/'; $tikiroot = '/' . ltrim($tikiroot, '/'); } $url_host = $input->getArgument('domain'); $list = \TikiDb::get()->fetchAll("\n\t\t\tSELECT userId, login, email, IFNULL(p.value, ?) language\n\t\t\tFROM users_users u\n\t\t\t\tLEFT JOIN tiki_user_preferences p ON u.login = p.user AND p.prefName = 'language'", [$prefs['site_language']]); $monitormail = \TikiLib::lib('monitormail'); $from = date('Y-m-d H:i:s', time() - $days * 24 * 3600); $to = date('Y-m-d H:i:s'); foreach ($list as $info) { $success = $monitormail->sendDigest($info, $from, $to); if ($success) { $output->writeln("Digest sent to {$info['email']}"); } else { $output->writeln("No data for {$info['email']}"); } } }
/** * Function to toggle relation. Sets relation when none set and then if there is a relation, it unsets. * @param $input * @return array with "relationId" as param. Null if relation is removed. * @throws Exception * @throws Services_Exception */ function action_toggle($input) { $relation = $input->relation->none(); $target_type = $input->target_type->none(); $target_id = $input->target_id->none(); $source_type = $input->source_type->none(); $source_id = $input->source_id->none(); // ensure the target, source, and relation info are passed to the service if (!$target_type || !$target_id || !$source_type || !$source_id || !$relation) { throw new Services_Exception(tr('Invalid input'), 400); } $relationlib = TikiLib::lib('relation'); $tx = TikiDb::get()->begin(); $relationId = $relationlib->get_relation_id($relation, $source_type, $source_id, $target_type, $target_id); // If there is not an existing relation, add the relation and trigger the add relation event. if (!$relationId) { $relationId = $relationlib->add_relation($relation, $source_type, $source_id, $target_type, $target_id); TikiLib::events()->trigger('tiki.relation.add', array('id' => $relationId, 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation)); } else { //if there is a relation, remove the relation, trigger the event, and set the relationId to null $relationlib->remove_relation($relationId); TikiLib::events()->trigger('tiki.relation.remove', array('id' => $relationId, 'target_type' => $target_type, 'target_id' => $target_id, 'source_type' => $source_type, 'source_id' => $source_id, 'relation' => $relation)); $relationId = null; // set the } $tx->commit(); //return the relationId (new relation if added, null if removed) return array('relation_id' => $relationId); }
function wikiplugin_votings($data, $params) { global $user; if (!isset($params['objectkey'])) { return ''; } else { $key = $params['objectkey']; } $smarty = TikiLib::lib('smarty'); $votings = TikiDb::get()->table('tiki_user_votings'); $data = $votings->fetchRow(array('count' => $votings->count(), 'total' => $votings->sum('optionId')), array('id' => $key)); $result = $votings->fetchAll(array('user'), array('id' => $key)); foreach ($result as $res) { $field['users'][] = $res['user']; } $field['numvotes'] = $data['count']; $field['total'] = $data['total']; if ($field['numvotes']) { $field['voteavg'] = $field['total'] / $field['numvotes']; } else { $field['voteavg'] = 0; } // be careful optionId is the value - not the optionId $field['my_rate'] = $votings->fetchOne('optionId', array('id' => $key, 'user' => $user)); $smarty->assign('wp_votings', $field); if (!empty($params['returnval']) && isset($field[$params['returnval']])) { return $field[$params['returnval']]; } else { return ''; } }
function removeEmptyAttachmentGals() { $galleryTable = TikiDb::get()->table('tiki_file_galleries'); $fileTable = TikiDb::get()->table('tiki_files'); $galleriesToDelete = array(); $attachmentGalleries = $galleryTable->fetchAll(array('galleryId', 'name'), array('type' => 'attachments')); foreach ($attachmentGalleries as $gal) { $files = $fileTable->fetchCount(array('galleryId' => $gal['galleryId'])); if (!$files) { $galleriesToDelete[] = $gal; echo "Attachment gallery: #{$gal['galleryId']} \"{$gal['name']}\" is empty, and will be removed\n"; ob_flush(); } } if ($galleriesToDelete) { $prompt = 'Are you sure you want to permanently remove all these (' . count($galleriesToDelete) . ') galleries? There is no undo... (y/n): '; if (readSTDIN($prompt, array('y', 'n')) == 'y') { echo "\n\n\nDeleting...\n\n"; foreach ($galleriesToDelete as $gal) { TikiLib::lib('filegal')->remove_file_gallery($gal['galleryId']); echo "Removed gallery: #{$gal['galleryId']} \"{$gal['name']}\"\n"; ob_flush(); } } } else { echo "No empty attachement galleries found\n"; ob_flush(); } $remaining = count($attachmentGalleries) - count($galleriesToDelete); echo "There are {$remaining} attachment galleries left that contain files.\n"; ob_flush(); }
private static function getPermissionList($writer, $objectType, $group) { switch ($objectType) { case 'category': $sub = "SELECT MD5(CONCAT('category', categId)) hash, categId objectId FROM tiki_categories"; break; case 'forum': $sub = "SELECT MD5(CONCAT('forum', forumId)) hash, forumId objectId FROM tiki_forums"; break; case 'tracker': $sub = "SELECT MD5(CONCAT('tracker', trackerId)) hash, trackerId objectId FROM tiki_trackers"; break; case 'wiki page': $sub = "SELECT MD5(CONCAT('wiki page', LOWER(pageName))) hash, pageName objectId FROM tiki_pages"; break; default: return array(); } $db = TikiDb::get(); $result = $db->fetchAll("\n\t\tSELECT i.objectId, permName\n\t\tFROM users_objectpermissions p\n\t\t\tINNER JOIN ({$sub}) i ON i.hash = p.objectId\n\t\tWHERE p.objectType = ? AND p.groupName = ?\n\t\t", array($objectType, $group)); $map = []; foreach ($result as $row) { $id = $row['objectId']; if (!isset($map[$id])) { $map[$id] = array('type' => $objectType, 'id' => $writer->getReference($objectType, $id), 'allow' => []); } // Strip tiki_p_ $map[$id]['allow'][] = substr($row['permName'], 7); } return array_values($map); }
private function gatherVoteData() { global $user; $field = $this->getBaseFieldData(); $trackerId = $this->getConfiguration('trackerId'); $itemId = $this->getItemId(); $votings = TikiDb::get()->table('tiki_user_votings'); if ($field['type'] == 's' && $field['name'] == tra('Rating')) { // global rating to an item - value is the sum of the votes $key = 'tracker.' . $trackerId . '.' . $itemId; } elseif ($field['type'] == '*' || $field['type'] == 'STARS') { // field rating - value is the average of the votes $key = "tracker.{$trackerId}.{$itemId}." . $field['fieldId']; } $data = $votings->fetchRow(array('count' => $votings->count(), 'total' => $votings->sum('optionId')), array('id' => $key)); $field['numvotes'] = $data['count']; $field['total'] = $data['total']; if ($field['numvotes']) { $field['voteavg'] = round($field['total'] / $field['numvotes'], 2); } else { $field['voteavg'] = 0; } // be careful optionId is the value - not the optionId $field['my_rate'] = $votings->fetchOne('optionId', array('id' => $key, 'user' => $user)); return $field; }
function fetch($name, $filters) { $filters = array_filter($filters); $filters['object'] = $name; $table = TikiDb::get()->table('tiki_profile_symbols'); return $table->fetchOne('value', $filters, 'creation_date_desc'); }
function action_regenerate_slugs($input) { global $prefs; Services_Exception_Denied::checkGlobal('admin'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $pages = TikiDb::get()->table('tiki_pages'); $initial = TikiLib::lib('slugmanager'); $tracker = new Tiki\Wiki\SlugManager\InMemoryTracker(); $manager = clone $initial; $manager->setValidationCallback($tracker); $list = $pages->fetchColumn('pageName', []); $pages->updateMultiple(['pageSlug' => null], []); foreach ($list as $page) { $slug = $manager->generate($prefs['wiki_url_scheme'], $page, $prefs['url_only_ascii'] === 'y'); $count = 1; while ($pages->fetchCount(['pageSlug' => $slug]) && $count < 100) { $count++; $slug = $manager->generate($prefs['wiki_url_scheme'], $page . ' ' . $count, $prefs['url_only_ascii'] === 'y'); } $tracker->add($page); $pages->update(['pageSlug' => $slug], ['pageName' => $page]); } TikiLib::lib('access')->redirect('tiki-admin.php?page=wiki'); } return array('title' => tr('Regenerate Wiki URLs')); }
public static function build($className, DateTime $dt = null, TikiMail $tm = null, TikiLib $tikilib = null, $tikiPrefs = null) { $db = TikiDb::get(); if (is_null($dt)) { $dt = new DateTime(); } if (is_null($tm)) { $tm = new TikiMail(); } if (is_null($tikilib)) { $tikilib = TikiLib::lib('tiki'); } if (is_null($tikiPrefs)) { global $prefs; $tikiPrefs = $prefs; } switch ($className) { case 'Reports_Users': return new Reports_Users($db, $dt); case 'Reports_Cache': return new Reports_Cache($db, $dt); case 'Reports_Manager': global $userlib; return new Reports_Manager(Reports_Factory::build('Reports_Users', $dt, $tm, $tikilib), Reports_Factory::build('Reports_Cache', $dt, $tm, $tikilib), Reports_Factory::build('Reports_Send', $dt, $tm, $tikilib), $userlib); case 'Reports_Send': global $prefs; return new Reports_Send($dt, $tm, Reports_Factory::build('Reports_Send_EmailBuilder', $dt, $tm, $tikilib), $tikiPrefs); case 'Reports_Send_EmailBuilder': return new Reports_Send_EmailBuilder($tikilib, new Reports_Send_EmailBuilder_Factory()); default: throw new Exception("Unknown class {$className}"); } }
function __construct() { $table = \TikiDb::get()->table('tiki_pages'); $this->validationCallback = function ($slug) use($table) { return $table->fetchCount(['pageSlug' => $slug]) > 0; }; }
function wikiplugin_listexecute($data, $params) { $unifiedsearchlib = TikiLib::lib('unifiedsearch'); $actions = array(); $factory = new Search_Action_Factory(); $factory->register(array('change_status' => 'Search_Action_ChangeStatusAction', 'delete' => 'Search_Action_Delete', 'email' => 'Search_Action_EmailAction', 'wiki_approval' => 'Search_Action_WikiApprovalAction', 'tracker_item_modify' => 'Search_Action_TrackerItemModify')); $query = new Search_Query(); $unifiedsearchlib->initQuery($query); $matches = WikiParser_PluginMatcher::match($data); $builder = new Search_Query_WikiBuilder($query); $builder->apply($matches); foreach ($matches as $match) { $name = $match->getName(); if ($name == 'action') { $action = $factory->fromMatch($match); if ($action && $action->isAllowed(Perms::get()->getGroups())) { $actions[$action->getName()] = $action; } } } if (!empty($_REQUEST['sort_mode'])) { $query->setOrder($_REQUEST['sort_mode']); } $index = $unifiedsearchlib->getIndex(); $result = $query->search($index); $plugin = new Search_Formatter_Plugin_SmartyTemplate('templates/wiki-plugins/wikiplugin_listexecute.tpl'); $paginationArguments = $builder->getPaginationArguments(); $dataSource = $unifiedsearchlib->getDataSource(); $builder = new Search_Formatter_Builder(); $builder->setPaginationArguments($paginationArguments); $builder->apply($matches); $builder->setFormatterPlugin($plugin); $formatter = $builder->getFormatter(); $reportSource = new Search_Action_ReportingTransform(); if (isset($_POST['list_action'], $_POST['objects'])) { $action = $_POST['list_action']; $objects = (array) $_POST['objects']; if (isset($actions[$action])) { $tx = TikiDb::get()->begin(); $action = $actions[$action]; $plugin->setFields(array_fill_keys($action->getFields(), null)); $list = $formatter->getPopulatedList($result); foreach ($list as $entry) { $identifier = "{$entry['object_type']}:{$entry['object_id']}"; if (in_array($identifier, $objects) || in_array('ALL', $objects)) { $success = $action->execute($entry); $reportSource->setStatus($entry['object_type'], $entry['object_id'], $success); } } $tx->commit(); } } $plugin = new Search_Formatter_Plugin_SmartyTemplate('templates/wiki-plugins/wikiplugin_listexecute.tpl'); $plugin->setFields(array('report_status' => null)); $plugin->setData(array('actions' => array_keys($actions))); $formatter = new Search_Formatter($plugin); $result->applyTransform($reportSource); return $formatter->format($result); }
function getEntries() { $table = \TikiDb::get()->table('tiki_tracker_items'); $ids = $table->fetchColumn('itemId', ['trackerId' => $this->trackerId]); foreach ($ids as $id) { (yield new TrackerSourceEntry($id)); } }
function __construct($visibility) { $this->db = TikiDb::get(); $this->user = TikiLib::lib('user'); $this->tiki = TikiLib::lib('tiki'); $this->geo = TikiLib::lib('geo'); $this->trk = TikiLib::lib('trk'); $this->visibility = $visibility; }
protected function execute(InputInterface $input, OutputInterface $output) { $writer = $this->getProfileWriter($input); $list = \TikiDb::get()->table('tiki_modules')->fetchColumn('moduleId', array()); foreach ($list as $moduleId) { \Tiki_Profile_InstallHandler_Module::export($writer, $moduleId); } $writer->save(); }
protected function setUp() { $db = TikiDb::get(); $dt = new DateTime(); $dt->setTimezone(new DateTimeZone('UTC')); $dt->setTimestamp('1326990210'); $this->obj = new Reports_Cache($db, $dt); parent::setUp(); }
protected function setUp() { $this->db = TikiDb::get(); $this->dt = new DateTime(); $this->dt->setTimezone(new DateTimeZone('UTC')); $this->dt->setTimestamp('1326734528'); $this->obj = new Reports_Users($this->db, $this->dt); parent::setUp(); }
function getInputs() { $db = \TikiDb::get(); $this->tx = $db->begin(); $result = $db->fetchAll('SELECT login FROM users_users u INNER JOIN tiki_user_monitors m ON u.userId = m.userId WHERE m.event = ?', ['tiki.recommendation.incoming']); foreach ($result as $row) { (yield new Input\UserInput($row['login'])); } }
public static function getTypes() { $db = TikiDb::get(); $topics = $db->table('tiki_topics')->fetchMap('topicId', 'name', array(), -1, -1, 'name_asc'); $types = $db->table('tiki_article_types')->fetchColumn('type', array()); $types = array_combine($types, $types); $options = array('articles' => array('name' => tr('Articles'), 'description' => tr('Attach articles to the tracker item.'), 'prefs' => array('trackerfield_articles', 'feature_articles'), 'tags' => array('advanced'), 'help' => 'Articles Tracker Field', 'default' => 'n', 'params' => array('topicId' => array('name' => tr('Topic'), 'description' => tr('Default article topic'), 'filter' => 'int', 'profile_reference' => 'article_topic', 'options' => $topics), 'type' => array('name' => tr('Article Type'), 'description' => tr('Default article type'), 'filter' => 'text', 'profile_reference' => 'article_type', 'options' => $types)))); return $options; }
/** * @param $maxlifetime * @return int */ public function gc($maxlifetime) { global $prefs; if ($prefs['session_lifetime'] > 0) { $qry = 'delete from sessions where expiry < ?'; TikiDb::get()->query($qry, array(time())); } return 1; }
/** * Ontain the list of email addresses and preferred language for each * user id to whom the notification email must be sent. */ private function getRecipients($sendTo) { global $prefs; $db = TikiDb::get(); $bindvars = [$prefs['site_language']]; $condition = $db->in('userId', $sendTo, $bindvars); $result = $db->fetchAll("\n\t\t\tSELECT login, email, IFNULL(p.value, ?) language\n\t\t\tFROM users_users u\n\t\t\t\tLEFT JOIN tiki_user_preferences p ON u.login = p.user AND p.prefName = 'language'\n\t\t\tWHERE {$condition}\n\t\t", $bindvars); return $result; }
function __construct($factory, $type, $object) { $this->factory = $factory; $db = TikiDb::get(); $this->permissions = new Perms_Reflection_PermissionSet(); $all = $db->fetchAll('SELECT `groupName`, `permName` FROM `users_grouppermissions`'); foreach ($all as $row) { $this->permissions->add($row['groupName'], $row['permName']); } }
/** * Constructor * Extend options with required fields * * @return void * @author Dmitry (dio) Levashov **/ public function __construct() { global $tikidomainslash, $prefs; $this->fileGalleriesTable = TikiDb::get()->table('tiki_file_galleries'); $this->filesTable = TikiDb::get()->table('tiki_files'); $opts = array('tmbPath' => 'temp/public/' . $tikidomainslash, 'tmpPath' => 'temp/' . $tikidomainslash, 'tmbURL' => 'temp/public/' . $tikidomainslash); $this->options = array_merge($this->options, $opts); $this->options['mimeDetect'] = 'internal'; $this->filegallib = TikiLib::lib('filegal'); }
/** * @param $installer */ function upgrade_20150508_perspectives_style_to_theme_tiki($installer) { // rename style to theme, style_option to theme_option and remove .css from values $perspectivePrefs = TikiDb::get()->table('tiki_perspective_preferences'); $result = $perspectivePrefs->fetchAll(array('perspectiveId', 'pref', 'value'), array('pref' => $perspectivePrefs->like('style%'))); foreach ($result as $row) { $val = unserialize($row['value']); $perspectivePrefs->update(array('value' => serialize(str_replace('.css', '', $val)), 'perspectiveId' => $row['perspectiveId'], 'pref' => str_replace('style', 'theme', $row['pref'])), array('perspectiveId' => $row['perspectiveId'], 'pref' => $row['pref'])); } }
function setUp() { $this->db = TikiDb::get(); $this->dt = new DateTime(); $this->dt->setTimezone(new DateTimeZone('UTC')); // 2012-02-03 15:25:07 $this->dt->setTimestamp('1328282707'); $this->table = $this->db->table('tiki_auth_tokens'); $this->obj = new AuthTokens($this->db, array(), $this->dt); parent::setUp(); }