/**
  * Reference purchase summary
  *
  * @Route()
  * @Method({"GET", "POST"})
  * @Template()
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $previouslyPostedData = null;
     // if we are not posting new data, and a request for $this->formType is stored in the session, prepopulate the form with the stored request
     $storedRequest = unserialize($request->getSession()->get($this->formType->getName()));
     if ($request->isMethod('GET') && $storedRequest instanceof Request) {
         $previouslyPostedData = $this->createForm($this->formType)->handleRequest($storedRequest)->getData();
     }
     $form = $this->createForm($this->formType, $previouslyPostedData);
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             // Persist the case to IRIS
             /** @var ReferencingCase $case */
             $case = $form->getData()['case'];
             $this->irisEntityManager->persist($case);
             /** @var ReferencingApplication $application */
             foreach ($case->getApplications() as $application) {
                 // Always default
                 $application->setSignaturePreference(SignaturePreference::SCAN_DECLARATION);
                 $this->irisEntityManager->persist($application, array('caseId' => $case->getCaseId()));
                 // Persist each guarantor of the application
                 if (null !== $application->getGuarantors()) {
                     foreach ($application->getGuarantors() as $guarantor) {
                         $this->irisEntityManager->persist($guarantor, array('applicationId' => $application->getApplicationId()));
                     }
                 }
             }
             $request->getSession()->set('submitted-case', serialize($case));
             // Send the user to the success page
             return $this->redirect($this->generateUrl('barbon_hostedapi_agent_reference_newreference_tenancyagreement_index'), 301);
         }
     }
     return array('form' => $form->createView());
 }
 /**
  * @Route("/{applicationId}")
  * @Method({"GET", "POST"})
  * @Template()
  * @param Request $request
  * @param $applicationId
  * @return array
  */
 public function indexAction(Request $request, $applicationId)
 {
     // Validate the $applicationId, throws Exception if invalid.
     $application = $this->getApplication($this->irisEntityManager, $applicationId);
     // Get the Case for this Tenant and put in the session, as it's needed throughout
     $case = $this->getCase($this->irisEntityManager, $application->getCaseId());
     $request->getSession()->set('submitted-case', serialize($case));
     // Create an empty ReferencingGuarantor object.
     $guarantor = new ReferencingGuarantor();
     $guarantor->setCaseId($application->getCaseId());
     // Build the form.
     $form = $this->createForm($this->formType, $guarantor, array('guarantor_decorator' => $this->referencingGuarantorDecoratorBridgeSubscriber->getGuarantorDecorator(), 'attr' => array('id' => 'generic_step_form', 'class' => 'referencing branded individual-guarantor-form', 'novalidate' => 'novalidate')));
     // Process a client round trip, if necessary
     if ($request->isXmlHttpRequest()) {
         $form->submit($request);
         return $this->render('BarbonHostedApiLandlordReferenceBundle:NewReference/Guarantor/Validate:index.html.twig', array('form' => $form->createView()));
     }
     // Submit the form.
     $form->handleRequest($request);
     if ($form->isValid()) {
         $case = $this->getCase($this->irisEntityManager, $application->getCaseId());
         // Dispatch the new guarantor reference event.
         $this->eventDispatcher->dispatch(NewReferenceEvents::GUARANTOR_REFERENCE_CREATED, new NewGuarantorReferenceEvent($case, $application, $guarantor));
         // Send the user to the success page.
         return $this->redirectToRoute('barbon_hostedapi_landlord_reference_newreference_guarantor_confirmation_index', array('applicationId' => $applicationId));
     }
     return array('form' => $form->createView());
 }
Exemple #3
0
 /**
  * 编码session
  * @param mixed $session_data
  * @return string
  */
 public static function sessionEncode($session_data = '')
 {
     if ($session_data !== '') {
         return serialize($session_data);
     }
     return '';
 }
 /**
  * Adds new User Story
  * 
  * @param   integer     $user       User ID
  * @param   array       $story      User Story 
  * @return  array | bool     
  */
 public function addNew($user, $story)
 {
     $new = new Model_Userstory();
     $new->fromArray(array('user' => $user, 'content' => $story['content'], 'date' => date('Y-m-d H:i:s')));
     if (isset($story['gallery']) && is_array($story['gallery'])) {
         $storyMedia = new Model_Userstorymedia();
         $storyMedia->photos = serialize($story['gallery']);
         $storyMedia->totalphotos = count($story['gallery']);
     }
     if (isset($story['videos']) && is_array($story['videos'])) {
         if (!isset($storyMedia)) {
             $storyMedia = new Model_Userstorymedia();
         }
         $storyMedia->videos = serialize($story['videos']);
         $storyMedia->totalvideos = count($story['videos']);
     }
     if (isset($storyMedia)) {
         $new->Media = $storyMedia;
     }
     try {
         $new->save();
     } catch (Doctrine_Exception $e) {
         return $e->getMessage();
     }
     return $new->toArray();
 }
        function ewww_ngg_new_thumbs($gid, $images)
        {
            // store the gallery id, seems to help avoid errors
            $gallery = $gid;
            // prepare the $images array for POSTing
            $images = serialize($images);
            ?>
                <div id="bulk-forms"><p><?php 
            _e('The thumbnails for your new images have not been optimized.', EWWW_IMAGE_OPTIMIZER_DOMAIN);
            ?>
</p>
                <form id="thumb-optimize" method="post" action="admin.php?page=ewww-ngg-thumb-bulk">
			<?php 
            wp_nonce_field('ewww-image-optimizer-bulk', 'ewww_wpnonce');
            ?>
			<input type="hidden" name="ewww_attachments" value="<?php 
            echo $images;
            ?>
">
                        <input type="submit" class="button-secondary action" value="<?php 
            _e('Optimize Thumbs', EWWW_IMAGE_OPTIMIZER_DOMAIN);
            ?>
" />
                </form> 
<?php 
        }
 /**
  * @test
  */
 public function shouldDeserialize()
 {
     $helper = new SamlSpInfoHelper();
     $expectedSamlSpInfo = $helper->getSamlSpInfo();
     $unserializedSamlSpInfo = unserialize(serialize($expectedSamlSpInfo));
     $this->assertEquals($expectedSamlSpInfo, $unserializedSamlSpInfo);
 }
Exemple #7
0
 static function mark_review()
 {
     global $wpdb;
     $_watu = new WatuPRO();
     // this will only happen for logged in users
     if (!is_user_logged_in()) {
         return false;
     }
     $taking_id = $_watu->add_taking($_POST['exam_id'], 1);
     // select current data if any
     $marked_for_review = $wpdb->get_var($wpdb->prepare("SELECT marked_for_review FROM " . WATUPRO_TAKEN_EXAMS . "\n\t\t\tWHERE ID=%d", $taking_id));
     if (empty($marked_for_review)) {
         $marked_for_review = array("question_ids" => array(), "question_nums" => array());
     } else {
         $marked_for_review = unserialize($marked_for_review);
     }
     if ($_POST['act'] == 'mark') {
         $marked_for_review['question_ids'][] = $_POST['question_id'];
         $marked_for_review['question_nums'][] = $_POST['question_num'];
     } else {
         // unmark
         foreach ($marked_for_review['question_ids'] as $cnt => $id) {
             if ($id == $_POST['question_id']) {
                 unset($marked_for_review['question_ids'][$cnt]);
             }
         }
         foreach ($marked_for_review['question_nums'] as $cnt => $num) {
             if ($num == $_POST['question_num']) {
                 unset($marked_for_review['question_nums'][$cnt]);
             }
         }
     }
     // now save
     $wpdb->query($wpdb->prepare("UPDATE " . WATUPRO_TAKEN_EXAMS . " SET marked_for_review=%s WHERE ID=%d", serialize($marked_for_review), $taking_id));
 }
Exemple #8
0
 public function setStatuses($v)
 {
     if (!is_array($v)) {
         $v = array();
     }
     parent::setStatuses(serialize($v));
 }
Exemple #9
0
 public function ApplyChanges()
 {
     parent::ApplyChanges();
     $this->RegisterAction('Volume', 'Lautstärke', $typ = 1, $profil = '');
     $this->RegisterAction('Mute', 'Stumm', $typ = 0, $profil = 'RPC.OnOff');
     $this->RegisterVariableInteger('GroupMember', 'Gruppe', 0);
     if ($this->CheckConfig() === true) {
         $zoneConfig = IPS_GetKernelDir() . '/modules/ips2rpc/sonos_zone.config';
         if (!file_exists($zoneConfig)) {
             $file = $this->API()->BaseUrl(true) . '/status/topology';
             if ($xml = simplexml_load_file($file)) {
                 $out = [];
                 foreach ($xml->ZonePlayers->ZonePlayer as $item) {
                     if ($v = (array) $item->attributes()) {
                         $v = array_shift($v);
                     }
                     $v['name'] = (string) $item;
                     $out[$v['name']] = $v;
                 }
                 file_put_contents($zoneConfig, serialize($out));
             }
         }
         $this->Update();
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Order'])) {
         $model->attributes = $_POST['Order'];
         $model->id = F::get_order_id();
         $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
         if ($model->save()) {
             $cart = Yii::app()->cart;
             $mycart = $cart->contents();
             foreach ($mycart as $mc) {
                 $OrderItem = new OrderItem();
                 $OrderItem->order_id = $model->order_id;
                 $OrderItem->item_id = $mc['id'];
                 $OrderItem->title = $mc['title'];
                 $OrderItem->pic_url = serialize($mc['pic_url']);
                 $OrderItem->sn = $mc['sn'];
                 $OrderItem->num = $mc['qty'];
                 $OrderItem->save();
             }
             $cart->destroy();
             $this->redirect(array('success'));
         }
     }
     //        $this->render('create', array(
     //            'model' => $model,
     //        ));
 }
Exemple #11
0
 /**
  * 添加购物车
  * @access  public
  * @param array $data
  * <code>
  * $data为数组包含以下几个值
  * $Data=array(
  *  "id"=>1,                        //商品ID
  *  "name"=>"后盾网2周年西服",         //商品名称
  *  "num"=>2,                       //商品数量
  *  "price"=>188.88,                //商品价格
  *  "options"=>array(               //其他参数,如价格、颜色可以是数组或字符串|可以不添加
  *      "color"=>"red",
  *      "size"=>"L"
  *  )
  * </code>
  * @return void
  */
 static function add($data)
 {
     if (!is_array($data) || !isset($data['id']) || !isset($data['name']) || !isset($data['num']) || !isset($data['price'])) {
         throw_exception('购物车ADD方法参数设置错误');
     }
     $data = isset($data[0]) ? $data : array($data);
     $goods = self::getGoods();
     //获得商品数据
     //添加商品增持多商品添加
     foreach ($data as $v) {
         $options = isset($v['options']) ? $v['options'] : '';
         $sid = substr(md5($v['id'] . serialize($options)), 0, 8);
         //生成维一ID用于处理相同商品有不同属性时
         if (isset($goods[$sid])) {
             if ($v['num'] == 0) {
                 //如果数量为0删除商品
                 unset($goods[$sid]);
                 continue;
             }
             //已经存在相同商品时增加商品数量
             $goods[$sid]['num'] = $goods[$sid]['num'] + $v['num'];
             $goods[$sid]['total'] = $goods[$sid]['num'] * $goods[$sid]['price'];
         } else {
             if ($v['num'] == 0) {
                 continue;
             }
             $goods[$sid] = $v;
             $goods[$sid]['total'] = $v['num'] * $v['price'];
         }
     }
     self::save($goods);
 }
 /**
  * Export data
  * @param string $format
  * @param array $options
  * @throws Exception
  */
 public function export($format = self::EXPORT_DISPLAY, $options = array())
 {
     global $wpdb;
     $options = array();
     $options['upload_dir'] = wp_upload_dir();
     $options['options'] = array();
     $options['options']['permalink_structure'] = get_option('permalink_structure');
     $widgets = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE 'widget_%'");
     foreach ($widgets as $widget) {
         $options['options'][$widget->option_name] = $this->compress(get_option($widget->option_name));
     }
     $options['options']['sidebars_widgets'] = $this->compress(get_option('sidebars_widgets'));
     $current_template = get_option('stylesheet');
     $options['options']["theme_mods_{$current_template}"] = $this->compress(get_option("theme_mods_{$current_template}"));
     $data = serialize($options);
     if ($format == self::EXPORT_DISPLAY) {
         echo '<textarea>' . $data . '</textarea>';
     }
     //export settings to file
     if ($format == self::EXPORT_FILE) {
         $path = isset($options['path']) ? $options['path'] : self::getWpOptionsPath();
         if (!file_put_contents($path, $data)) {
             throw new Exception("Cannot save settings to: " . $path);
         }
     }
 }
Exemple #13
0
 /**
  *	控制器 AJAX脚本输出
  *  Controller中使用方法:$this->Controller->ajax_return()
  * 	@param  int     $status  0:错误信息|1:正确信息
  * 	@param  string  $message  显示的信息
  * 	@param  array   $data    传输的信息
  * 	@param  array   $type    返回数据类型,json|xml|eval|jsonp
  *  @return object
  */
 public function ajax_return($status, $message = '', $data = array(), $type = 'json')
 {
     $return_data = array('status' => $status, 'message' => $message, 'data' => $data);
     $type = strtolower($type);
     if ($type == 'json') {
         header("Content-type: application/json");
         exit(json_encode($return_data));
     } elseif ($type == 'xml') {
         header('Content-type: text/xml');
         $xml = '<?xml version="1.0" encoding="utf-8"?>';
         $xml .= '<return>';
         $xml .= '<status>' . $status . '</status>';
         $xml .= '<message>' . $message . '</message>';
         $xml .= '<data>' . serialize($data) . '</data>';
         $xml .= '</return>';
         exit($xml);
     } elseif ($type == "jsonp") {
         $callback = $this->get_gp('callback');
         $json_data = json_encode($return_data);
         if (is_string($callback) && isset($callback[0])) {
             exit("{$callback}({$json_data});");
         } else {
             exit($json_data);
         }
     } elseif ($type == 'eval') {
         exit($return_data);
     } else {
     }
 }
Exemple #14
0
 /**
  * Insert the templates.
  */
 private function insertTemplates()
 {
     /*
      * Fallback templates
      */
     // build templates
     $templates['core']['default'] = array('theme' => 'core', 'label' => 'Default', 'path' => 'Core/Layout/Templates/Default.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[main]', 'names' => array('main'))));
     $templates['core']['home'] = array('theme' => 'core', 'label' => 'Home', 'path' => 'Core/Layout/Templates/Home.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[main]', 'names' => array('main'))));
     // insert templates
     $this->getDB()->insert('themes_templates', $templates['core']['default']);
     $this->getDB()->insert('themes_templates', $templates['core']['home']);
     /*
      * Triton templates
      */
     // search will be installed by default; already link it to this template
     $extras['search_form'] = $this->insertExtra('search', ModuleExtraType::widget(), 'SearchForm', 'form', null, 'N', 2001);
     // build templates
     $templates['triton']['default'] = array('theme' => 'triton', 'label' => 'Default', 'path' => 'Core/Layout/Templates/Default.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[/,advertisement,advertisement,advertisement],[/,/,top,top],[/,/,/,/],[left,main,main,main]', 'names' => array('main', 'left', 'top', 'advertisement'), 'default_extras' => array('top' => array($extras['search_form'])), 'image' => false)));
     $templates['triton']['home'] = array('theme' => 'triton', 'label' => 'Home', 'path' => 'Core/Layout/Templates/Home.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[/,advertisement,advertisement,advertisement],[/,/,top,top],[/,/,/,/],[main,main,main,main],[left,left,right,right]', 'names' => array('main', 'left', 'right', 'top', 'advertisement'), 'default_extras' => array('top' => array($extras['search_form'])), 'image' => true)));
     // insert templates
     $this->getDB()->insert('themes_templates', $templates['triton']['default']);
     $this->getDB()->insert('themes_templates', $templates['triton']['home']);
     /*
      * General theme settings
      */
     // set default theme
     $this->setSetting('Core', 'theme', 'triton', true);
     // set default template
     $this->setSetting('Pages', 'default_template', $this->getTemplateId('default'));
     // disable meta navigation
     $this->setSetting('Pages', 'meta_navigation', false);
 }
 public function testRequireAllUnset()
 {
     $this->require->setRequire('vendor/name');
     $this->assertFalse($this->require->getAll());
     $this->assertEquals('C:50:"holisticagency\\satis\\utilities\\SatisRequireOptions":53:{a:1:{s:7:"require";a:1:{s:11:"vendor/name";s:1:"*";}}}', serialize($this->require));
     $this->assertFalse($this->require->getAll());
 }
Exemple #16
0
 /**
  * Add localization data to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xml
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Config
  */
 protected function _addLocalization(Mage_XmlConnect_Model_Simplexml_Element $xml)
 {
     /** @var $translateHelper Mage_XmlConnect_Helper_Translate */
     $translateHelper = Mage::helper('xmlconnect/translate');
     $xml->addCustomChild('localization', $this->getUrl('*/*/localization'), array('hash' => sha1(serialize($translateHelper->getLocalizationArray()))));
     return $this;
 }
 /**
  * Run the controller
  */
 public function run()
 {
     $objInstalledTabControl = $this->Database->query("SELECT version FROM tl_repository_installs WHERE extension='tabcontrol' LIMIT 1");
     if ($objInstalledTabControl->version <= '30000009') {
         if (!$this->Database->fieldExists('tab_tabs', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_tabs blob NULL");
         }
         if (!$this->Database->fieldExists('tab_template', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template varchar(64) NOT NULL default 'ce_tabcontrol_tab'");
         }
         if (!$this->Database->fieldExists('tab_template_start', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template_start varchar(64) NOT NULL default 'ce_tabcontrol_start'");
         }
         if (!$this->Database->fieldExists('tab_template_stop', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template_stop varchar(64) NOT NULL default 'ce_tabcontrol_stop'");
         }
         if (!$this->Database->fieldExists('tab_template_end', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template_end varchar(64) NOT NULL default 'ce_tabcontrol_end'");
         }
         $objTabControl = $this->Database->query("SELECT * FROM tl_content WHERE type='tabcontrol' AND tabType='tabcontroltab'");
         while ($objTabControl->next()) {
             if ($this->Database->fieldExists('tabTitles', 'tl_content')) {
                 $arrTabs = array();
                 $arrTabTitles = deserialize($objTabControl->tabTitles);
                 foreach ($arrTabTitles as $title) {
                     $arrTabs[] = array('tab_tabs_name' => $title, 'tab_tabs_cookies_value' => '', 'tab_tabs_default' => '');
                 }
                 $this->Database->query("UPDATE tl_content SET tab_tabs='" . serialize($arrTabs) . "' WHERE id=" . $objTabControl->id . "");
             }
         }
     }
 }
 public function getPHPDefaultValue()
 {
     $bDebug = false;
     if (!is_null($this->default) && strlen($this->default) != 0) {
         $mValue = $this->default;
         switch ($this->type) {
             case "check-var":
             case "check-varchar":
             case "check-text":
                 $mValue = eval("return " . $mValue . ';');
                 $mValue = explode($this->uploadseparator, $mValue);
                 $sScript = "return unserialize('" . str_replace("'", "\\'", serialize($mValue)) . "');";
                 break;
             default:
                 $sScript = "return " . $this->default . ";";
         }
     } else {
         switch ($this->type) {
             case "check-var":
             case "check-varchar":
             case "check-text":
                 $sScript = "return array();";
                 break;
             default:
                 $sScript = "return '';";
         }
     }
     if ($bDebug) {
         echo "script: " . $sScript . "<br/>\n";
     }
     return eval($sScript);
 }
function BXCreateSection(&$fileContent, &$sectionFileContent, &$absoluteFilePath, &$sectionPath)
{
    //Check quota
    $quota = new CDiskQuota();
    if (!$quota->CheckDiskQuota(array("FILE_SIZE" => strlen($fileContent) + strlen($sectionFileContent)))) {
        $GLOBALS["APPLICATION"]->ThrowException($quota->LAST_ERROR, "BAD_QUOTA");
        return false;
    }
    $io = CBXVirtualIo::GetInstance();
    //Create dir
    if (!$io->CreateDirectory($absoluteFilePath)) {
        $GLOBALS["APPLICATION"]->ThrowException(GetMessage("PAGE_NEW_FOLDER_CREATE_ERROR") . "<br /> (" . htmlspecialcharsbx($absoluteFilePath) . ")", "DIR_NOT_CREATE");
        return false;
    }
    //Create .section.php
    $f = $io->GetFile($absoluteFilePath . "/.section.php");
    if (!$GLOBALS["APPLICATION"]->SaveFileContent($absoluteFilePath . "/.section.php", $sectionFileContent)) {
        return false;
    }
    //Create index.php
    if (!$GLOBALS["APPLICATION"]->SaveFileContent($absoluteFilePath . "/index.php", $fileContent)) {
        return false;
    } else {
        if (COption::GetOptionString($module_id, "log_page", "Y") == "Y") {
            $res_log['path'] = $sectionPath . "/index.php";
            CEventLog::Log("content", "PAGE_ADD", "main", "", serialize($res_log));
        }
    }
    return true;
}
 function _getCacheFile($filename, $cacheParams)
 {
     if (!is_string($cacheParams)) {
         $cacheParams = md5(serialize($cacheParams));
     }
     return $this->cache_path . 'image_manager__' . $cacheParams . '_' . $filename;
 }
Exemple #21
0
 public function add_page($meta = array())
 {
     $result = false;
     $tb = $this->tables['posts'];
     $user_id = $this->users->get_user_id();
     if (!$meta || !$user_id) {
         $this->notification->set_error('pages_error_add');
         return $result;
     }
     $post_meta = array_key_exists('post_meta', $meta) ? element('post_meta', $meta) : array();
     $post_content = array_key_exists('post_content', $meta) ? element('post_content', $meta) : array();
     $meta = elements(array('user_id', 'post_title', 'server', 'post_description', 'post_date', 'post_type', 'post_content', 'active'), $meta);
     $data = array_merge($meta, array('user_id' => $user_id, 'post_type' => 'page', 'post_content' => serialize($post_content)));
     $data = array_filter($data, function ($var) {
         return !is_null($var) && !empty($var);
     });
     $this->db->insert($tb, $data);
     $id = $this->db->insert_id();
     if ($this->db->_error_message()) {
         $this->notification->set_error('pages_error_add');
     } else {
         $this->notification->set_message('pages_success_add');
         $result = $id;
     }
     return $result;
 }
Exemple #22
0
function ninja_forms_import_form($data)
{
    global $wpdb;
    $form = unserialize($data);
    // change the update date to today
    $form['date_updated'] = date('Y-m-d H:i:s');
    // get the form fields
    $form_fields = $form['field'];
    unset($form['field']);
    $form = apply_filters('ninja_forms_before_import_form', $form);
    $form['data'] = serialize($form['data']);
    $wpdb->insert(NINJA_FORMS_TABLE_NAME, $form);
    $form_id = $wpdb->insert_id;
    $form['id'] = $form_id;
    if (is_array($form_fields)) {
        for ($x = 0; $x < count($form_fields); $x++) {
            $form_fields[$x]['form_id'] = $form_id;
            $form_fields[$x]['data'] = serialize($form_fields[$x]['data']);
            $old_field_id = $form_fields[$x]['id'];
            $form_fields[$x]['id'] = NULL;
            $wpdb->insert(NINJA_FORMS_FIELDS_TABLE_NAME, $form_fields[$x]);
            $form_fields[$x]['id'] = $wpdb->insert_id;
            $form_fields[$x]['old_id'] = $old_field_id;
            $form_fields[$x]['data'] = unserialize($form_fields[$x]['data']);
        }
    }
    $form['data'] = unserialize($form['data']);
    $form['field'] = $form_fields;
    do_action('ninja_forms_after_import_form', $form);
    return $form['id'];
}
 public function testRun()
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     //Create 2 imports, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true);
     $modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
     $sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $import->getClassId('Item');
     ZurmoRedBean::exec($sql);
     $staleImportId = $import->id;
     $import2 = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import2->serializedData = serialize($serializedData);
     $this->assertTrue($import2->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import2->getTempTableName(), true);
     $this->assertEquals(2, Import::getCount());
     $tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
     $this->assertTrue($tableExists);
     $job = new ImportCleanupJob();
     $this->assertTrue($job->run());
     $tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
     $this->assertFalse($tableExists);
     $imports = Import::getAll();
     $this->assertEquals(1, count($imports));
     $this->assertEquals($import2->id, $imports[0]->id);
 }
function fixAllSwiftSyncData($dry, $limit)
{
    global $wgSwiftSyncDB, $method;
    $dbr = wfGetDB(DB_SLAVE, array(), $wgSwiftSyncDB);
    $res = $dbr->select(['image_sync_done'], ['id, city_id, img_action, img_src, img_dest, img_added, img_sync, img_error'], ['city_id' => 0], $method, ['ORDER BY' => 'id', 'LIMIT' => $limit]);
    $rows = array();
    while ($row = $dbr->fetchObject($res)) {
        $rows[] = $row;
    }
    $dbr->freeResult($res);
    print sprintf("Found %0d rows to fix \n", count($rows));
    foreach ($rows as $row) {
        print "Parsing " . $row->id . ", ";
        $image_path_dir = null;
        if (preg_match('/swift\\-backend\\/(.*)\\/images/', $row->img_dest, $data)) {
            $image_path_dir = $data[1];
        }
        if (empty($image_path_dir)) {
            print " cannot find image_path_dir \n";
            continue;
        }
        $image_path = sprintf("http://images.wikia.com/%s/images", $image_path_dir);
        $serialized_image_path = serialize($image_path);
        print "path: " . $serialized_image_path . ", ";
        $row->city_id = getCityIdByImagePath($serialized_image_path);
        if ($row->city_id > 0) {
            moveRecordToActiveQueue($row, $dry);
        } else {
            print " cannot find city_id \n";
        }
    }
}
 public function renderXml()
 {
     $system =& $this->_params['system'];
     $widgets =& $this->_params['widgets'];
     $document = new DOMDocument('1.0', 'utf-8');
     $document->formatOutput = true;
     $rootNode = $document->createElement('widget_framework');
     $rootNode->setAttribute('version', $system['version_string']);
     $document->appendChild($rootNode);
     foreach ($widgets as $widget) {
         $widgetNode = $document->createElement('widget');
         $widgetNode->setAttribute('title', $widget['title']);
         $widgetNode->setAttribute('class', $widget['class']);
         $optionsNode = $document->createElement('options');
         $optionsString = $widget['options'];
         if (!is_string($optionsString)) {
             $optionsString = serialize($optionsString);
         }
         $optionsData = XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $optionsString);
         $optionsNode->appendChild($optionsData);
         $widgetNode->appendChild($optionsNode);
         $widgetNode->setAttribute('position', $widget['position']);
         $widgetNode->setAttribute('display_order', $widget['display_order']);
         $widgetNode->setAttribute('active', $widget['active']);
         $rootNode->appendChild($widgetNode);
     }
     $this->setDownloadFileName('widget_framework-widgets-' . XenForo_Template_Helper_Core::date(XenForo_Application::$time, 'YmdHi') . '.xml');
     return $document->saveXml();
 }
 public function testSerialization()
 {
     $expression = new ParsedExpression('25', new ConstantNode('25'));
     $serializedExpression = serialize($expression);
     $unserializedExpression = unserialize($serializedExpression);
     $this->assertEquals($expression, $unserializedExpression);
 }
Exemple #27
0
 public function update()
 {
     if (empty($this->input['id'])) {
         $this->errorOutput(NO_ID);
     }
     if (empty($this->input['name'])) {
         $this->errorOutput(NO_NAME);
     }
     $id = intval($this->input['id']);
     $data = array('name' => trim($this->input['name']) ? trim($this->input['name']) : '', 'update_time' => TIMENOW);
     $check = $this->obj->checkName($data['name'], $id);
     if ($check) {
         $this->errorOutput(NAME_EXIST);
     }
     $material = array();
     $material = parent::upload_indexpic();
     if ($material) {
         $logo_info = array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename']);
         $data['logo_info'] = serialize($logo_info);
         $data['logo_id'] = $material['id'];
     }
     $ret = $this->obj->update($data, $id);
     $this->addItem($ret);
     $this->output();
 }
Exemple #28
0
 public function testSerialization()
 {
     $router = \Phalcon\DI::getDefault()->getShared('router');
     $serialized = serialize($router);
     $unserialized = unserialize($serialized);
     $this->assertEquals($unserialized, $router);
 }
Exemple #29
0
 function installLanguage($f, $l, $m)
 {
     global $php;
     $lng = array();
     include $f;
     foreach ($lng as $key => $value) {
         if (isset($php[$key])) {
             if ($php[$key]['type'] == 'array') {
                 $php[$key][$l] = serialize($value);
             } elseif ($value !== '') {
                 $php[$key][$l] = addslashes($value);
             }
         } else {
             $save = array();
             $save['key'] = $key;
             $save['owner'] = $m;
             if (is_array($value)) {
                 $save['type'] = 'array';
                 $save[$l] = serialize($value);
             } else {
                 if (preg_match('/^[0-9]+$/', $value)) {
                     $save['type'] = 'int';
                 } else {
                     $save['type'] = 'text';
                 }
                 $save[$l] = addslashes($value);
             }
             $save['js'] = 0;
             $php[$key] = $save;
         }
     }
 }
Exemple #30
0
 /**
  * @inheritdoc
  */
 public function render($context, $targetDir)
 {
     parent::render($context, $targetDir);
     if ($this->controller !== null) {
         $this->controller->stdout("writing packages file...");
     }
     $packages = [];
     $notNamespaced = [];
     foreach (array_merge($context->classes, $context->interfaces, $context->traits) as $type) {
         /* @var $type TypeDoc */
         if (empty($type->namespace)) {
             $notNamespaced[] = str_replace('\\', '-', $type->name);
         } else {
             $packages[$type->namespace][] = str_replace('\\', '-', $type->name);
         }
     }
     ksort($packages);
     $packages = array_merge(['Not namespaced' => $notNamespaced], $packages);
     foreach ($packages as $name => $classes) {
         sort($packages[$name]);
     }
     file_put_contents($targetDir . '/packages.txt', serialize($packages));
     if ($this->controller !== null) {
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
 }