当前位置: 首页>>代码示例>>PHP>>正文


PHP plugin::get_sms_providers方法代码示例

本文整理汇总了PHP中plugin::get_sms_providers方法的典型用法代码示例。如果您正苦于以下问题:PHP plugin::get_sms_providers方法的具体用法?PHP plugin::get_sms_providers怎么用?PHP plugin::get_sms_providers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plugin的用法示例。


在下文中一共展示了plugin::get_sms_providers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sms

    /**
     * Handles SMS Settings
     */
    function sms()
    {
        $this->template->content = new View('admin/sms');
        $this->template->content->title = Kohana::lang('ui_admin.settings');

        // setup and initialize form field names
        $form = array
        (
            'sms_provider' => '',
			'sms_no1' => '',
            'sms_no2' => '',
            'sms_no3' => ''
        );
        //  Copy the form as errors, so the errors will be stored with keys
        //  corresponding to the form field names
        $errors = $form;
        $form_error = FALSE;
        $form_saved = FALSE;

        // check, has the form been submitted, if so, setup validation
        if ($_POST)
        {
            // Instantiate Validation, use $post, so we don't overwrite $_POST
            // fields with our own things
            $post = new Validation($_POST);

            // Add some filters
            $post->pre_filter('trim', TRUE);

            // Add some rules, the input field, followed by a list of checks, carried out in order

            $post->add_rules('sms_provider', 'length[1,100]');
			$post->add_rules('sms_no1', 'numeric', 'length[1,30]');
            $post->add_rules('sms_no2', 'numeric', 'length[1,30]');
            $post->add_rules('sms_no3', 'numeric', 'length[1,30]');

            // Test to see if things passed the rule checks
            if ($post->validate())
            {
                // Yes! everything is valid
                $settings = new Settings_Model(1);
                $settings->sms_provider = $post->sms_provider;
				$settings->sms_no1 = $post->sms_no1;
                $settings->sms_no2 = $post->sms_no2;
                $settings->sms_no3 = $post->sms_no3;
                $settings->date_modify = date("Y-m-d H:i:s",time());
                $settings->save();

				// Delete Settings Cache
                $this->cache->delete('settings');
                $this->cache->delete_tag('settings');

                // Everything is A-Okay!
                $form_saved = TRUE;

                // repopulate the form fields
                $form = arr::overwrite($form, $post->as_array());

            }

            // No! We have validation errors, we need to show the form again,
            // with the errors
            else
            {
                // repopulate the form fields
                $form = arr::overwrite($form, $post->as_array());

                // populate the error fields, if any
                $errors = arr::overwrite($errors, $post->errors('settings'));
                $form_error = TRUE;
            }
        }
        else
        {
            // Retrieve Current Settings
            $settings = ORM::factory('settings', 1);

            $form = array
            (
                'sms_provider' => $settings->sms_provider,
				'sms_no1' => $settings->sms_no1,
                'sms_no2' => $settings->sms_no2,
                'sms_no3' => $settings->sms_no3
            );
        }
		
        $this->template->content->form = $form;
        $this->template->content->errors = $errors;
        $this->template->content->form_error = $form_error;
        $this->template->content->form_saved = $form_saved;
		
		$this->template->content->sms_provider_array = array_merge(
			array("" => "-- Select One --"),
		 	plugin::get_sms_providers()
			);
    }
开发者ID:nurous,项目名称:bushfireconnect,代码行数:99,代码来源:settings.php

示例2: sms

 /**
  * Handles SMS Settings
  */
 public function sms()
 {
     $this->template->content = new View('admin/settings/sms');
     $this->template->content->title = Kohana::lang('ui_admin.settings');
     // setup and initialize form field names
     $form = array('sms_provider' => '', 'sms_no1' => '', 'sms_no2' => '', 'sms_no3' => '', 'sms_alert_url' => '');
     //	Copy the form as errors, so the errors will be stored with keys
     //	corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('sms_provider', 'length[1,100]');
         $post->add_rules('sms_no1', 'numeric', 'length[1,30]');
         $post->add_rules('sms_no2', 'numeric', 'length[1,30]');
         $post->add_rules('sms_no3', 'numeric', 'length[1,30]');
         $post->add_rules('sms_alert_url', 'required', 'between[0,1]');
         // HT: new setting for url on sms
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             if (!Settings_Model::get_setting('sms_alert_url')) {
                 Settings_Model::save_setting('sms_alert_url', $post->sms_alert_url);
             }
             // Yes! everything is valid
             Settings_Model::save_all($post);
             // Delete Settings Cache
             $this->cache->delete('settings');
             $this->cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         $settings = Settings_Model::get_settings(array_keys($form));
         $settings['sms_alert_url'] = isset($settings['sms_alert_url']) ? $settings['sms_alert_url'] : 0;
         // HT: might not be in database so calling manually return NULL if not exist
         // Retrieve Current Settings
         $form = array('sms_provider' => $settings['sms_provider'], 'sms_no1' => $settings['sms_no1'], 'sms_no2' => $settings['sms_no2'], 'sms_no3' => $settings['sms_no3'], 'sms_alert_url' => $settings['sms_alert_url']);
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->alert_url_array = array('1' => Kohana::lang('ui_admin.yes'), '0' => Kohana::lang('ui_admin.no'));
     $this->template->content->sms_provider_array = array_merge(array("" => "-- Select One --"), plugin::get_sms_providers());
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:63,代码来源:settings.php


注:本文中的plugin::get_sms_providers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。