public function copyLocaleData(LocaleInterface $sourceLocale, LocaleInterface $targetLocale) { $repositories = $this->getTranslatableRespositories(); $repositories->map(function (EntityRepository $repository) use($sourceLocale, $targetLocale) { $this->copyTranslatableEntities($repository, $sourceLocale, $targetLocale); }); $this->entityManager->flush(); }
public function set($configKey, $value) { $configItem = $this->get($configKey); if (!$configItem) { $configItem = ConfigItemFactory::createConfigItem($configKey, $value, $this->applicationId); } $this->_em->persist($configItem); $this->_em->flush(); $this->_em->clear(); return $configItem; }
/** * Sets oauth code to database. * @param string $authCode * @param object $client * @return boolean * @throws \Exception */ public function setOauthCode($authCode, $client) { $oauthCode = new OauthCode(); $oauthCode->setClient($client); $oauthCode->setCode($authCode); $oauthCode->setExpired('false'); try { $this->em->persist($oauthCode); $this->em->flush(); return true; } catch (\Exception $ex) { throw new \Exception($ex->getMessage()); } }
public function execute() { /** @var Ticket $ticket */ $ticket = $this->context->getFact()->getTarget(); $branchId = $this->context->getParameters()->has('branch') ? $this->context->getParameters()->get('branch') : null; if (is_null($branchId)) { throw new \RuntimeException("Invalid rule configuration"); } $branch = $this->em->getRepository('DiamanteDeskBundle:Branch')->get($branchId); $ticket->move($branch); $this->em->persist($ticket); $this->em->flush(); $this->em->clear($ticket); }
/** * Listens to "scenario.after" and "outline.example.after" event. * * @param \Behat\Behat\Tester\Event\AbstractScenarioTested $event */ public function afterScenario(ScenarioTested $event) { if ('scenario' !== $this->lifetime) { return; } $this->fixtureService->flush(); }
/** * Listens to "outline.example.after" event. * * @param \Behat\Behat\Event\OutlineExampleEvent $event */ public function afterOutlineExample(OutlineExampleEvent $event) { if ('scenario' !== $this->lifetime) { return; } $this->fixtureService->flush(); }
/** * Performs an authentication attempt * * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed * @return Zend_Auth_Result */ public function authenticate() { $user = $this->_em->getRepository($this->_model)->findOneBy(array('username' => $this->_username)); $result = array('code' => Zend_Auth_Result::FAILURE, 'identity' => array('username' => $this->_username), 'messages' => array()); if (!$user) { return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $result['identity'], $result['messages']); } $pwcheck = false; if (!$this->_haveCookie) { $pwcheck = OSS_Auth_Password::verify($this->_password, $user->getPassword(), $this->_aoptions); if (!$pwcheck) { if (method_exists($user, 'setFailedLogins')) { $user->setFailedLogins($user->getFailedLogins() + 1); $this->_em->flush(); $result['identity'] = array('count' => $user->getFailedLogins()); } return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $result['identity'], $result['messages']); } } if ($pwcheck || $this->_haveCookie) { $result['code'] = Zend_Auth_Result::SUCCESS; $result['messages'] = array(); $result['identity'] = array('username' => $this->_username, 'user' => $user, 'id' => $user->getId()); } else { die('Huh? This should not have happened....'); } return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']); }
/** * Do any Page Caching if $this->cacheMethod is set. * You should also look at output caching by overriding the outputBody Method. * * Note that Caching is disabled in a number of situations. * a) cacheMethod is empty * b) POST requests * c) if sess is set (Eg. if you are using sessions) * d) useCache is not set in the [Cache] section of the config. * * utilizes $this->getCacheID() to * * @return none|boolean|string|int|object Description * @access public|private * @see see also methods..... */ function getCache() { if (!$this->cacheMethod) { return; } if ($_SERVER["REQUEST_METHOD"] == "POST") { return; } /* lets assume we can cache ourselves.. */ $coptions = PEAR::getStaticProperty('Cache', 'options'); if (!$coptions) { return; } if (empty($coptions['useCache'])) { return; } require_once 'Cache.php'; $this->_cache = new Cache($coptions['container'], $coptions); $id = $this->_cache->generateID($this->getCacheID()); if ($_SERVER["REQUEST_METHOD"] == "POST") { $this->_cache->flush($id); return; } if ($data = $this->_cache->get($id)) { echo $data; return TRUE; } }
/** * Deletes the specified cache or each one if '' given * * @param string $name cache name * * @return bool */ public function delete($name = '') { if ($name == '') { return $this->provider->flush(); } else { return $this->provider->delete($this->prefix . $name); } }
/** * Clean the Cache * * @return bool false on failure/true on success */ public function clean() { if ($this->is_supported()) { return $this->_memcached->flush(); } else { return FALSE; } }
/** * Delete all the saved models. * * @throws \League\FactoryMuffin\Exceptions\DeletingFailedException * * @return void */ public function deleteSaved() { parent::deleteSaved(); try { $this->storage->flush(); } catch (\Exception $e) { throw new DeletingFailedException([$e]); } }
/** * Leerung des Cache * * @since 2.0.7 * @change 2.0.7 */ public static function clear_cache() { /* Server connect */ if (!self::_connect_server()) { return; } /* Flush */ @self::$_memcached->flush(); }
/** * Set option * * @param $key * @param $value */ public function Clean() { if (!$this->IsConnected) $this->Connect(); if ($this->IsConnected) return $this->MemCache->flush(); else return false; }
/** * The session save handler callback for writing data to the session. * * @param string $key The key of the data to be returned. * @param mixed $value The value to be written to the session. * @return boolean True if write was successful, false otherwise. */ public function _write($id, $data) { $expires = new \DateTime(); $expires->add(\DateInterval::createFromDateString($this->config['expiration'])); $this->record->setId($id); $this->record->setData($data ?: null); $this->record->setExpires($expires); $this->entityManager->persist($this->record); $this->entityManager->flush($this->record); }
/** * Load data fixtures with the passed EntityManager * * @param object $manager */ function load($manager) { foreach (range(0, 10) as $n) { $feature = new Feature(); $feature->setName("feature-" . $n); $feature->setDescription("feature-" . $n); $feature->setProject($this->getReference('project-salgamos')); $this->addReference('feature-' . $n, $feature); $manager->persist($feature); } $manager->flush(); }
/** * Loads a template to display the current page. * * @access public */ public function loadTemplate() { $config = $this->_config; $lang = $this->_lang; $messages = $this->_messenger->get(); $this->_messenger->flush(); $user = $this->_user; $form = $this->_form; include __DIR__ . '/../templates/header.tpl'; include __DIR__ . '/../templates/' . get_called_class() . '/' . $this->_action . '.tpl'; include __DIR__ . '/../templates/footer.tpl'; }
/** * Load data fixtures with the passed EntityManager * * @param object $manager */ function load($manager) { $project1 = new Project(); $project1->setName('Salgamos'); $manager->persist($project1); $project2 = new Project(); $project2->setName('Aguila'); $manager->persist($project2); $manager->flush(); $this->addReference('project-salgamos', $project1); $this->addReference('project-aguila', $project2); }
/** * * @param string $token * @param object $user * @return boolean * @throws \Exception */ public function setAccessToken($token, $user) { $oauthToken = new OauthToken(); $oauthToken->setToken($token); $oauthToken->setUser($user); $oauthToken->setExpired('no'); try { $this->em->persist($oauthToken); $this->em->flush(); return true; } catch (\Exception $ex) { throw new \Exception($ex->getMessage()); } }
/** * Removes cache file(s). * * @param string $sName Name of the cache file we need to remove. * @param string $sType Pass an optional command to execute a specific routine. * @return bool Returns true if we were able to remove the cache file and false if the system was locked. */ public function remove($sName = null, $sType = '') { if (file_exists(PHPFOX_DIR_CACHE . 'cache.lock')) { return false; } if ($sName === null) { if (defined('PHPFOX_IS_HOSTED_SCRIPT')) { $this->_oDb->delete(md5('oncloudsite' . PHPFOX_IS_HOSTED_SCRIPT)); /* $aCacheData = $this->_oDb->get(md5('grouplysite' . PHPFOX_IS_HOSTED_SCRIPT)); if (is_array($aCacheData)) { foreach ($aCacheData as $sCacheId) { if (empty($sCacheId)) { continue; } $this->_oDb->delete($sCacheId); } } */ } else { $this->_oDb->flush(); } foreach ($this->getAll() as $aFile) { if (file_exists(PHPFOX_DIR_CACHE . $aFile['name'])) { if (is_dir(PHPFOX_DIR_CACHE . $aFile['name'])) { Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $aFile['name']); } else { unlink(PHPFOX_DIR_CACHE . $aFile['name']); $this->removeInfo(PHPFOX_DIR_CACHE . $aFile['name']); } } } return true; } else { if (is_array($sName)) { if ($sName[0] == 'feeds') { $sName[0] = $sName[0] . Phpfox_Locale::instance()->getLangId(); } $sName = $sName[0] . $sName[1]; } $this->_oDb->delete($this->_getName($sName)); } return true; }
/** * Process Entity arranges * @param Project $project * @param bool $remove * @return mixed */ protected function processProjectDeletionFinalize(Project $project, $remove = true) { $returnValues['slot_name'] = 'proc'; try { // Finalizing process if (!$remove) { // Unset Local DB VCS related datas $project->setGitLabProjectId(null); $project->setGitLabHttpUrlToRepo(null); $project->setGitLabSshUrlToRepo(null); $project->setGitLabWebUrl(null); $project->setGitLabNamespace(null); $project->setGitNbCommits(null); $project->setGitCommitLastUpdate(null); // Unset Local DB PM related datas $project->setRedmineProjectId(null); $project->setRedmineProjectIdentifier(null); $project->setRedmineWebUrl(null); // Unser local DB QA related datas $project->setSonarProjectId(null); $project->setSonarProjectKey(null); $project->setSonarProjectUrl(null); // Other $project->setActive(false); // Remove project CIs $cis = $this->em->getRepository('SpiritDevDBoxPortalBundle:ContinuousIntegration')->findBy(array('project' => $project)); foreach ($cis as $ci) { $this->em->remove($ci); } } else { // Removing project $this->em->remove($project); } // Updating datas $this->em->flush(); $returnValues['data'][] = $this->setRetVal('Entity updated', 'bool', true); // Send user mail + team mail ? $this->mailer->processProjectDeletionSendMail($project); $returnValues['data'][] = $this->setRetVal('Mail sent', 'bool', true); $this->session->getFlashBag()->set('success', 'flashbag.demand.processing_deletion_project.success'); } catch (\Exception $e) { $returnValues['data'][] = $this->setRetVal('Entity updated', 'bool', false); // $returnValues['data'][] = $this->setRetVal('Mail sent', 'bool', false); $this->session->getFlashBag()->set('error', 'flashbag.demand.processing_deletion_project.error'); } return $returnValues; }
/** * The execute method * * @param InputInterface $input The Input class * @param OutputInterface $output The output class * * @access protected * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $start_date = time(); $this->em = $this->getContainer()->get('doctrine')->getManager('default'); $root_dir = $this->getContainer()->getParameter("kernel.root_dir") . "/config/gatling/data"; PiFileManager::mkdirr($root_dir, 0777); $path = $root_dir . "/connexion_sfynx.csv"; file_put_contents($path, 'username,password' . "\n", LOCK_EX); // $firstId = (int) $input->getOption('firstId'); $lastId = (int) $input->getOption('lastId'); $output->writeln('First id user : '******'last id user : '******'fr_FR', :user, :user, :user, :user, 1, '73rwkq08i3wo0ow840c0g48k800o0ok', " . "'xREF5HHqHbZmlmoO3+s5BXtVtYa3TIf8Wv+IVXJsQwx+0FG1WnqxjJ46toQ1u/+v1lfKOwo90FqEbqiPDzDo+g==', '2014-11-13 00:00:00', " . "0, 0, NULL, NULL, NULL, 'a:1:{i:0;s:9:\"ROLE_USER\";}', 'a:4:{i:0;s:4:\"VIEW\";i:1;s:4:\"EDIT\";i:2;s:6:\"CREATE\";i:3;s:6:\"DELETE\";}', 0, NULL, :user, :user, '2014-11-12 17:55:21' " . ");"; $this->em->getConnection()->beginTransaction(); $stmtuser = $this->em->getConnection()->prepare($sqluser); try { $psw = "user"; $start_date_user = time(); for ($j = $firstId; $j <= $lastId; $j++) { $user_value = 'user' . $j; $params = array('id' => $j, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value); $stmtuser->execute($params); // file_put_contents($path, "{$user_value},{$psw}\n", FILE_APPEND); } $end_date_user = time(); $duration_user = $end_date_user - $start_date_user; $output->writeln(" - fin de chargement de données des users en " . $duration_user . "s"); $this->em->flush(); // Try and commit the transaction $this->em->getConnection()->commit(); } catch (\Exception $e) { $output->writeln($e->getMessage()); // Rollback the failed transaction attempt $this->em->getConnection()->rollback(); $this->em->close(); } $end_date = time(); $duration = $end_date - $start_date; $output->writeln(" - fin de chargement de donnée en " . $duration . "s"); }
/** * Load data fixtures with the passed EntityManager * * @param object $manager */ function load($manager) { $fortune = true; exec($this->getDescCommand(), $output); if (!$output) { $fortune = false; } foreach (range(0, 100) as $n) { $task = new Task(); $feature = $this->getReference("feature-" . $n % 11); $task->setFeature($feature); $task->setTitle(substr($this->getTitle(), 0, 40)); $task->setDifficulty(($n + 10) % 4); $task->setPriority($n % 4); $user = $manager->getRepository('AguilaBundle:User')->findOneBy(array('username' => 'admin')); $task->setReporter($user); $task->setCreatedAt(new \DateTime('now + ' . $n . 'days - ' . $n . 'months')); $task->setNumber($n + 1); $manager->persist($task); } $manager->flush(); }
/** * Clears entire cache by flushing it. All cache keys using the * configuration but *without* honoring the scope are removed. * * Internally keys are not removed but invalidated. Thus this * operation doesn't actually free memory on the instance. * * The behavior and result when removing a single key * during this process fails is unknown. * * @return boolean `true` on successful clearing, `false` otherwise. */ public function clear() { return $this->connection->flush(); }
/** * function iCal2xls * * Convert iCal file to xls format and send file to browser (default) or save xls file to disk * Definition iCal : rcf2445, http://kigkonsult.se/downloads/index.php#rfc * Using iCalcreator: http://kigkonsult.se/downloads/index.php#iCalcreator * Based on PEAR Spreadsheet_Excel_Writer-0.9.1 (and OLE-1.0.0RC1) * to be installed as * pear install channel://pear.php.net/OLE-1.0.0RC1 * pear install channel://pear.php.net/Spreadsheet_Excel_Writer-0.9.1 * * @author Kjell-Inge Gustafsson <*****@*****.**> * @since 3.0 - 2011-12-21 * @param object $calendar opt. iCalcreator calendar instance * @return bool returns FALSE when error */ public function iCal2xls($calendar = FALSE) { $timeexec = array('start' => microtime(TRUE)); if ($this->log) { $this->log->log(' ********** START **********', PEAR_LOG_NOTICE); } /** check input/output directory and filename */ $inputdirFile = $outputdirFile = ''; $inputFileParts = $outputFileParts = array(); $remoteInput = $remoteOutput = FALSE; if ($calendar) { $inputdirFile = $calendar->getConfig('DIRFILE'); $inputFileParts = pathinfo($inputdirFile); $inputFileParts['dirname'] = realpath($inputFileParts['dirname']); if ($this->log) { $this->log->log('fileParts:' . var_export($inputFileParts, TRUE), PEAR_LOG_DEBUG); } } elseif (FALSE === $this->_fixIO('input', 'ics', $inputdirFile, $inputFileParts, $remoteInput)) { if ($this->log) { $this->log->log(number_format(microtime(TRUE) - $timeexec['start'], 5) . ' sec', PEAR_LOG_ERR); $this->log->log("ERROR 2, invalid input ({$inputdirFile})", PEAR_LOG_ERR); $this->log->flush(); } return FALSE; } if (FALSE === $this->_fixIO('output', FALSE, $outputdirFile, $outputFileParts, $remoteOutput)) { if (FALSE === $this->setConfig('outputfilename', $inputFileParts['filename'] . '.xls')) { if ($this->log) { $this->log->log(number_format(microtime(TRUE) - $timeexec['start'], 5) . ' sec', PEAR_LOG_ERR); $this->log->log('ERROR 3, invalid output (' . $inputFileParts['filename'] . '.csv)', PEAR_LOG_ERR); $this->log->flush(); } return FALSE; } $outputdirFile = $this->getConfig('outputdirectory') . DIRECTORY_SEPARATOR . $inputFileParts['filename'] . '.xls'; $outputFileParts = pathinfo($outputdirFile); if ($this->log) { $this->log->log("output set to '{$outputdirFile}'", PEAR_LOG_INFO); } } if ($this->log) { $this->log->log("INPUT..FILE:{$inputdirFile}", PEAR_LOG_NOTICE); $this->log->log("OUTPUT.FILE:{$outputdirFile}", PEAR_LOG_NOTICE); } $save = $this->getConfig('save'); if ($calendar) { $calnl = $calendar->getConfig('nl'); } else { /** iCalcreator set config, read and parse input iCal file */ $calendar = new vcalendar(); if (FALSE !== ($unique_id = $this->getConfig('unique_id'))) { $calendar->setConfig('unique_id', $unique_id); } $calnl = $calendar->getConfig('nl'); if ($remoteInput) { if (FALSE === $calendar->setConfig('url', $inputdirFile)) { if ($this->log) { $this->log->log("ERROR 3 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid url", 3); } return FALSE; } } else { if (FALSE === $calendar->setConfig('directory', $inputFileParts['dirname'])) { if ($this->log) { $this->log->log("ERROR 4 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid directory: '" . $inputFileParts['dirname'] . "'", 3); $this->log->flush(); } return FALSE; } if (FALSE === $calendar->setConfig('filename', $inputFileParts['basename'])) { if ($this->log) { $this->log->log("ERROR 5 INPUT FILE:'{$inputdirFile}' iCalcreator: invalid filename: '" . $inputFileParts['basename'] . "'", 3); $this->log->flush(); } return FALSE; } } if (FALSE === $calendar->parse()) { if ($this->log) { $this->log->log("ERROR 6 INPUT FILE:'{$inputdirFile}' iCalcreator parse error", 3); $this->log->flush(); } return FALSE; } } // end if( !$calendar ) $timeexec['fileOk'] = microtime(TRUE); if (!function_exists('iCaldate2timestamp')) { function iCaldate2timestamp($d) { if (6 > count($d)) { return mktime(0, 0, 0, $d['month'], $d['day'], $d['year']); } else { return mktime($d['hour'], $d['min'], $d['sec'], $d['month'], $d['day'], $d['year']); } } } if (!function_exists('fixiCalString')) { function fixiCalString($s) { global $calnl; $s = str_replace('\\,', ',', $s); $s = str_replace('\\;', ';', $s); $s = str_replace('\\n ', chr(10), $s); $s = str_replace('\\\\', '\\', $s); $s = str_replace("{$calnl}", chr(10), $s); return utf8_decode($s); } } /** Creating a workbook */ require_once 'Spreadsheet/Excel/Writer.php'; if ($save) { $workbook = new Spreadsheet_Excel_Writer($outputdirFile); } else { $workbook = new Spreadsheet_Excel_Writer(); } $workbook->setVersion(8); // Use Excel97/2000 Format /** opt. sending HTTP headers */ if (!$save) { $workbook->send($outputFileParts['basename']); } /** Creating a worksheet */ $worksheet =& $workbook->addWorksheet($inputFileParts['filename']); /** fix formats */ $format_bold =& $workbook->addFormat(); $format_bold->setBold(); $timeexec['wrkbkOk'] = microtime(TRUE); /** info rows */ $row = -1; $worksheet->writeString(++$row, 0, 'kigkonsult.se', $format_bold); $worksheet->writeString($row, 1, ICALCREATOR_VERSION, $format_bold); $worksheet->writeString($row, 2, ICALCNVVERSION . ' iCal2xls', $format_bold); $worksheet->writeString($row, 3, date('Y-m-d H:i:s')); $filename = $remoteInput ? $inputdirFile : $inputFileParts['basename']; $worksheet->writeString(++$row, 0, 'iCal input', $format_bold); $worksheet->writeString($row, 1, $filename); $worksheet->writeString($row, 2, 'xls output', $format_bold); $worksheet->writeString($row, 3, $outputFileParts['basename']); if (FALSE !== ($prop = $calendar->getProperty('CALSCALE'))) { $worksheet->writeString(++$row, 0, 'CALSCALE', $format_bold); $worksheet->writeString($row, 1, $prop); } if (FALSE !== ($prop = $calendar->getProperty('METHOD'))) { $worksheet->writeString(++$row, 0, 'METHOD', $format_bold); $worksheet->writeString($row, 1, $prop); } while (FALSE !== ($xprop = $calendar->getProperty())) { $worksheet->writeString(++$row, 0, $xprop[0], $format_bold); $worksheet->writeString($row, 1, $xprop[1]); } $timeexec['infoOk'] = microtime(TRUE); if (FALSE === ($propsToSkip = $this->getConfig('skip'))) { $propsToSkip = array(); } /** fix property order list */ $proporderOrg = array(); for ($key = 2; $key < 99; $key++) { if (FALSE !== ($value = $this->getConfig($key))) { $proporderOrg[$value] = $key; if ($this->log) { $this->log->log("{$value} in column {$key}", 7); } } } /** fix vtimezone property order list */ $proporder = $proporderOrg; $proporder['TYPE'] = 0; $proporder['ORDER'] = 1; $props = array('TZID', 'LAST-MODIFIED', 'TZURL', 'DTSTART', 'TZOFFSETTO', 'TZOFFSETFROM', 'COMMENT', 'RRULE', 'RDATE', 'TZNAME'); $pix = 2; foreach ($props as $prop) { if (isset($proporder[$prop])) { continue; } if (in_array($prop, $propsToSkip)) { if ($this->log) { $this->log->log("'{$prop}' removed from output", 7); } continue; } while (in_array($pix, $proporder)) { $pix++; } $proporder[$prop] = $pix++; } /** remove unused properties from and add x-props to property order list */ $maxpropix = 11; if ($maxpropix != count($proporder) - 1) { $maxpropix = count($proporder) - 1; } $compsinfo = $calendar->getConfig('compsinfo'); $potmp = array(); $potmp[0] = 'TYPE'; $potmp[1] = 'ORDER'; foreach ($compsinfo as $cix => $compinfo) { if ('vtimezone' != $compinfo['type']) { continue; } $comp = $calendar->getComponent($compinfo['ordno']); foreach ($compinfo['props'] as $propName => $propcnt) { if (!in_array($propName, $potmp) && isset($proporder[$propName])) { $potmp[$proporder[$propName]] = $propName; } elseif ('X-PROP' == $propName) { while ($xprop = $comp->getProperty()) { if (!in_array($xprop[0], $potmp)) { $maxpropix += 1; $potmp[$maxpropix] = $xprop[0]; } // end if } // end while xprop } // end X-PROP } // end $compinfo['props'] if (isset($compinfo['sub'])) { foreach ($compinfo['sub'] as $compinfo2) { foreach ($compinfo2['props'] as $propName => $propcnt) { if (!in_array($propName, $potmp) && isset($proporder[$propName])) { $potmp[$proporder[$propName]] = $propName; } elseif ('X-PROP' == $propName) { $scomp = $comp->getComponent($compinfo2['ordno']); while ($xprop = $scomp->getProperty()) { if (!in_array($xprop[0], $potmp)) { $maxpropix += 1; $potmp[$maxpropix] = $xprop[0]; } // end if } // end while xprop } // end X-PROP } // end $compinfo['sub']['props'] } // end foreach( $compinfo['sub'] } // end if( isset( $compinfo['sub'] } // end foreach compinfo - vtimezone ksort($potmp, SORT_NUMERIC); $proporder = array_flip(array_values($potmp)); if ($this->log) { $this->log->log("timezone proporder=" . implode(',', array_flip($proporder)), 7); } /** create vtimezone info */ if (2 < count($proporder)) { $row += 1; /** create vtimezone header row */ foreach ($proporder as $propName => $col) { if (isset($this->config[$propName])) { $worksheet->writeString($row, $col, $this->config[$propName], $format_bold); // check map of userfriendly name to iCal property name if ($this->log) { $this->log->log("header row, col={$col}: {$propName}, replaced by " . $this->config[$propName], 7); } } else { $worksheet->writeString($row, $col, $propName, $format_bold); } } $allowedProps = array('VTIMEZONE' => array('TZID', 'LAST-MODIFIED', 'TZURL'), 'STANDARD' => array('DTSTART', 'TZOFFSETTO', 'TZOFFSETFROM', 'COMMENT', 'RDATE', 'RRULE', 'TZNAME'), 'DAYLIGHT' => array('DTSTART', 'TZOFFSETTO', 'TZOFFSETFROM', 'COMMENT', 'RDATE', 'RRULE', 'TZNAME')); /** create vtimezone data rows */ foreach ($compsinfo as $cix => $compinfo) { if ('vtimezone' != $compinfo['type']) { continue; } $row += 1; $worksheet->writeString($row, $proporder['TYPE'], $compinfo['type']); $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno']); $comp = $calendar->getComponent($compinfo['ordno']); foreach ($proporder as $propName => $col) { if ('TYPE' == $propName || 'ORDER' == $propName) { continue; } if ('X-' == substr($propName, 0, 2)) { continue; } if (!in_array($propName, $allowedProps['VTIMEZONE'])) { // check if component allows property if ($this->log) { $this->log->log("ERROR 7, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo['type'] . "': '{$propName}'", PEAR_LOG_INFO); } continue; } if (isset($compinfo['props'][$propName])) { if ('LAST-MODIFIED' == $propName) { $fcn = 'createLastModified'; } else { $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1)); } if (!method_exists($comp, $fcn)) { if ($this->log) { $this->log->log('ERROR 8 INPUT FILE:"' . $filename . '" iCalcreator: unknown property: "' . $propName . '" (' . $fcn . ')', PEAR_LOG_INFO); } continue; } $output = str_replace("{$calnl} ", '', rtrim($comp->{$fcn}())); $output = str_replace($propName . ';', '', $output); $output = str_replace($propName . ':', '', $output); $worksheet->writeString($row, $proporder[$propName], fixiCalString($output)); } } // end foreach( $proporder if (isset($compinfo['props']['X-PROP'])) { while ($xprop = $comp->getProperty()) { $output = str_replace("{$calnl} ", '', rtrim($xprop[1])); $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output)); } } if (isset($compinfo['sub'])) { foreach ($compinfo['sub'] as $compinfo2) { $row += 1; $worksheet->writeString($row, $proporder['TYPE'], $compinfo2['type']); $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno'] . ':' . $compinfo2['ordno']); $scomp = $comp->getComponent($compinfo2['ordno']); foreach ($proporder as $propName => $col) { if ('TYPE' == $propName || 'ORDER' == $propName) { continue; } if ('X-' == substr($propName, 0, 2)) { continue; } if (!in_array($propName, $allowedProps[strtoupper($compinfo2['type'])])) { // check if component allows property if ($this->log) { $this->log->log("ERROR 9, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo2['type'] . "': '{$propName}'", PEAR_LOG_INFO); } continue; } if (isset($compinfo2['props'][$propName])) { $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1)); if (!method_exists($scomp, $fcn)) { if ($this->log) { $this->log->log('ERROR 10 INPUT FILE:"' . $filename . '" iCalcreator: unknown property: "' . $propName . '" (' . $fcn . ')', PEAR_LOG_INFO); } continue; } $output = str_replace("{$calnl} ", '', rtrim($scomp->{$fcn}())); $output = str_replace($propName . ';', '', $output); $output = str_replace($propName . ':', '', $output); $worksheet->writeString($row, $proporder[$propName], fixiCalString($output)); } } // end foreach( $proporder if (isset($compinfo2['props']['X-PROP'])) { while ($xprop = $scomp->getProperty()) { $output = str_replace("{$calnl} ", '', rtrim($xprop[1])); $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output)); } } } // end foreach( $compinfo['sub'] } // end if( isset( $compinfo['sub']['props'] )) } // end foreach } // end vtimezone $timeexec['zoneOk'] = microtime(TRUE); $maxColCount = count($proporder); /** fix property order list */ $proporder = $proporderOrg; $proporder['TYPE'] = 0; $proporder['ORDER'] = 1; $props = array('UID', 'DTSTAMP', 'SUMMARY', 'DTSTART', 'DURATION', 'DTEND', 'DUE', 'RRULE', 'RDATE', 'EXRULE', 'EXDATE', 'DESCRIPTION', 'CATEGORIES', 'ORGANIZER', 'LOCATION', 'RESOURCES', 'CONTACT', 'URL', 'COMMENT', 'PRIORITY', 'ATTENDEE', 'CLASS', 'TRANSP', 'SEQUENCE', 'STATUS', 'COMPLETED', 'CREATED', 'LAST-MODIFIED', 'ACTION', 'TRIGGER', 'REPEAT', 'ATTACH', 'FREEBUSY', 'RELATED-TO', 'REQUEST-STATUS', 'GEO', 'PERCENT-COMPLETE', 'RECURRENCE-ID'); $pix = 2; foreach ($props as $prop) { if (isset($proporder[$prop])) { continue; } if (in_array($prop, $propsToSkip)) { if ($this->log) { $this->log->log("'{$prop}' removed from output", 7); } continue; } while (in_array($pix, $proporder)) { $pix++; } $proporder[$prop] = $pix++; } /** remove unused properties from and add x-props to property order list */ if ($maxpropix < count($proporder) - 1) { $maxpropix = count($proporder) - 1; } $potmp = array(); $potmp[0] = 'TYPE'; $potmp[1] = 'ORDER'; // $potmp[2] = 'UID'; foreach ($compsinfo as $cix => $compinfo) { if ('vtimezone' == $compinfo['type']) { continue; } foreach ($compinfo['props'] as $propName => $propcnt) { if (!in_array($propName, $potmp) && isset($proporder[$propName])) { $potmp[$proporder[$propName]] = $propName; } elseif ('X-PROP' == $propName) { $comp = $calendar->getComponent($compinfo['ordno']); while ($xprop = $comp->getProperty()) { if (!in_array($xprop[0], $potmp)) { $maxpropix += 1; $potmp[$maxpropix] = $xprop[0]; } // end if } // while( $xprop } // end elseif( 'X-PROP' } // end foreach( $compinfo['props'] if (isset($compinfo['sub'])) { foreach ($compinfo['sub'] as $compinfo2) { foreach ($compinfo2['props'] as $propName => $propcnt) { if (!in_array($propName, $potmp) && isset($proporder[$propName])) { $potmp[$proporder[$propName]] = $propName; } elseif ('X-PROP' == $propName) { $scomp = $comp->getComponent($compinfo2['ordno']); while ($xprop = $scomp->getProperty()) { if (!in_array($xprop[0], $potmp)) { $maxpropix += 1; $potmp[$maxpropix] = $xprop[0]; } // end if } // end while xprop } // end X-PROP } // end $compinfo['sub']['props'] } // end foreach( $compinfo['sub'] } // end if( isset( $compinfo['sub'] } ksort($potmp, SORT_NUMERIC); $proporder = array_flip(array_values($potmp)); if ($this->log) { $this->log->log("comp proporder=" . implode(',', array_flip($proporder)), 7); } if ($maxColCount < count($proporder)) { $maxColCount = count($proporder); } /** create header row */ $row += 1; foreach ($proporder as $propName => $col) { if (isset($this->config[$propName])) { $worksheet->writeString($row, $col, $this->config[$propName], $format_bold); // check map of userfriendly name to iCal property name if ($this->log) { $this->log->log("header row, col={$col}: {$propName}, replaced by " . $this->config[$propName], 7); } } else { $worksheet->writeString($row, $col, $propName, $format_bold); } } $allowedProps = array('VEVENT' => array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'CLASS', 'COMMENT', 'CONTACT', 'CREATED', 'DESCRIPTION', 'DTEND', 'DTSTAMP', 'DTSTART', 'DURATION', 'EXDATE', 'RXRULE', 'GEO', 'LAST-MODIFIED', 'LOCATION', 'ORGANIZER', 'PRIORITY', 'RDATE', 'RECURRENCE-ID', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'SEQUENCE', 'STATUS', 'SUMMARY', 'TRANSP', 'UID', 'URL'), 'VTODO' => array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'CLASS', 'COMMENT', 'COMPLETED', 'CONTACT', 'CREATED', 'DESCRIPTION', 'DTSTAMP', 'DTSTART', 'DUE', 'DURATION', 'EXDATE', 'EXRULE', 'GEO', 'LAST-MODIFIED', 'LOCATION', 'ORGANIZER', 'PERCENT', 'PRIORITY', 'RDATE', 'RECURRENCE-ID', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'SEQUENCE', 'STATUS', 'SUMMARY', 'UID', 'URL'), 'VJOURNAL' => array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'CLASS', 'COMMENT', 'CONTACT', 'CREATED', 'DESCRIPTION', 'DTSTAMP', 'DTSTART', 'EXDATE', 'EXRULE', 'LAST-MODIFIED', 'ORGANIZER', 'RDATE', 'RECURRENCE-ID', 'RELATED-TO', 'RRULE', 'REQUEST-STATUS', 'SEQUENCE', 'STATUS', 'SUMMARY', 'UID', 'URL'), 'VFREEBUSY' => array('ATTENDEE', 'COMMENT', 'CONTACT', 'DTEND', 'DTSTAMP', 'DTSTART', 'DURATION', 'FREEBUSY', 'ORGANIZER', 'UID', 'URL'), 'VALARM' => array('ACTION', 'ATTACH', 'ATTENDEE', 'DESCRIPTION', 'DURATION', 'REPEAT', 'SUMMARY', 'TRIGGER')); /** create data rows */ foreach ($compsinfo as $cix => $compinfo) { if ('vtimezone' == $compinfo['type']) { continue; } $row += 1; $worksheet->writeString($row, $proporder['TYPE'], $compinfo['type']); $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno']); // $worksheet->write( $row, $proporder['UID'], $compinfo['uid'] ); $comp = $calendar->getComponent($compinfo['ordno']); foreach ($proporder as $propName => $col) { if ('TYPE' == $propName || 'ORDER' == $propName) { continue; } if ('X-' == substr($propName, 0, 2)) { continue; } if (!in_array($propName, $allowedProps[strtoupper($compinfo['type'])])) { // check if component allows property if ($this->log) { $this->log->log("ERROR 11, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo['type'] . "': '{$propName}'", PEAR_LOG_INFO); } continue; } if (isset($compinfo['props'][$propName])) { switch ($propName) { case 'LAST-MODIFIED': $fcn = 'createLastModified'; break; case 'RECURRENCE-ID': $fcn = 'createRecurrenceid'; break; case 'RELATED-TO': $fcn = 'createRelatedTo'; break; case 'REQUEST-STATUS': $fcn = 'createRequestStatus'; break; case 'PERCENT-COMPLETE': $fcn = 'createPercentComplete'; break; default: $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1)); } if (!method_exists($comp, $fcn)) { if ($this->log) { $this->log->log("ERROR 12 INPUT FILE:'{$filename}' iCalcreator: unknown property: '{$propName}' ({$fcn})", PEAR_LOG_INFO); } continue; } $output = str_replace("{$calnl} ", '', rtrim($comp->{$fcn}())); $output = str_replace($propName . ';', '', $output); $output = str_replace($propName . ':', '', $output); $worksheet->writeString($row, $proporder[$propName], fixiCalString($output)); } } // end foreach( $proporder if (isset($compinfo['props']['X-PROP'])) { while ($xprop = $comp->getProperty()) { $output = str_replace("{$calnl} ", '', rtrim($xprop[1])); $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output)); } } if (isset($compinfo['sub'])) { foreach ($compinfo['sub'] as $compinfo2) { $row += 1; $worksheet->writeString($row, $proporder['TYPE'], $compinfo2['type']); $worksheet->writeString($row, $proporder['ORDER'], $compinfo['ordno'] . ':' . $compinfo2['ordno']); $scomp = $comp->getComponent($compinfo2['ordno']); foreach ($proporder as $propName => $col) { if ('TYPE' == $propName || 'ORDER' == $propName) { continue; } if ('X-' == substr($propName, 0, 2)) { continue; } if (!in_array($propName, $allowedProps[strtoupper($compinfo2['type'])])) { // check if component allows property if ($this->log) { $this->log->log("ERROR 13, INPUT FILE:'{$inputdirFile}' iCalcreator: unvalid property for component '" . $compinfo2['type'] . "': '{$propName}'", PEAR_LOG_INFO); } continue; } if (isset($compinfo2['props'][$propName])) { $fcn = 'create' . strtoupper(substr($propName, 0, 1)) . strtolower(substr($propName, 1)); if (!method_exists($scomp, $fcn)) { if ($this->log) { $this->log->log("ERROR 14 INPUT FILE:'{$filename}' iCalcreator: unknown property: '{$propName}' ({$fcn})", PEAR_LOG_INFO); } continue; } $output = str_replace("{$calnl} ", '', rtrim($scomp->{$fcn}())); $output = str_replace($propName . ';', '', $output); $output = str_replace($propName . ':', '', $output); $worksheet->writeString($row, $proporder[$propName], fixiCalString($output)); } // end if( isset( $compinfo2['props'][$propName] } // end foreach( $proporder if (isset($compinfo2['props']['X-PROP'])) { while ($xprop = $scomp->getProperty()) { $output = str_replace("{$calnl} ", '', rtrim($xprop[1])); $output = str_replace('\\n ', chr(10), $output); $worksheet->writeString($row, $proporder[$xprop[0]], fixiCalString($output)); } } // end if( isset( $compinfo2['props']['X-PROP'] } // end foreach( $compinfo['sub'] } // end if( isset( $compinfo['sub'] } // foreach( $compsinfo as if ($this->log) { $timeexec['exit'] = microtime(TRUE); $msg = "'{$filename}'"; $msg .= ' fileOk:' . number_format($timeexec['fileOk'] - $timeexec['start'], 5); $msg .= ' wrkbkOk:' . number_format($timeexec['wrkbkOk'] - $timeexec['fileOk'], 5); $msg .= ' infoOk:' . number_format($timeexec['infoOk'] - $timeexec['wrkbkOk'], 5); $msg .= ' zoneOk:' . number_format($timeexec['zoneOk'] - $timeexec['infoOk'], 5); $msg .= ' compOk:' . number_format($timeexec['exit'] - $timeexec['zoneOk'], 5); $msg .= ' total:' . number_format($timeexec['exit'] - $timeexec['start'], 5) . 'sec'; $msg .= ', ' . ($row + 1) . " rows, {$maxColCount} cols"; $this->log->log($msg, PEAR_LOG_DEBUG); $msg = "'{$filename}' (" . count($compsinfo) . ' components) start:' . date('H:i:s', $timeexec['start']); $msg .= ' total:' . number_format($timeexec['exit'] - $timeexec['start'], 5) . 'sec'; if ($save) { $msg .= " saved as '{$outputdirFile}'"; } else { $msg .= " redirected as '" . $outputFileParts['basename'] . "'"; } $this->log->log($msg, PEAR_LOG_NOTICE); } /** Close and, opt., send the file */ if ($this->log) { $this->log->flush(); } $workbook->close(); return TRUE; }
/** * Delete all keys from the cache * * @return boolean True if the cache was succesfully cleared, false otherwise * @access public */ function clear() { return $this->memcache->flush(); }
/** * 清空缓存 * * @param $mode string * @param $errorLevel int * @return boolean */ public function flush() { return $this->oCache->flush(); }
/** * Clean the Cache * * @return bool false on failure/true on success */ public function clean() { return $this->_memcached->flush(); }
/** * 清空缓存 * * @return bool */ public function flush() { return $this->isConnected ? $this->mem->flush() : FALSE; }
/** * * Removes all cache entries. * * @return void * */ public function deleteAll() { if (!$this->_active) { return; } $this->memcache->flush(); }
/** * Check if a Memcached connection is working by setting and immediately getting a value. * * @since 1.1.0 * * @param object $connection Memcache object. * * @return bool True on retrieving exactly the value set, false otherwise. */ protected function memcached_connection_is_working($connection, $type = 'Memcache') { if (!$connection) { return false; } if ($type == 'Memcache') { @$connection->set('SGCP_Memcached_Test', 'Test!1', MEMCACHE_COMPRESSED, 50); } elseif ($type == 'Memcached') { @$connection->set('SGCP_Memcached_Test', 'Test!1', 50); } if (@$connection->get('SGCP_Memcached_Test') === 'Test!1') { $connection->flush(); return true; } return false; }