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


PHP Model_Ad::getCountAdWantUser方法代码示例

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


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

示例1: createAction

 public function createAction()
 {
     //first we check if user is logged, if not redir to login
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         //keep this url in zend session to redir after login
         $aNamespace = new Zend_Session_Namespace('Nolotiro');
         $aNamespace->redir = $this->lang . '/ad/create';
         $this->_redirect($this->lang . '/auth/login');
     } else {
         $request = $this->getRequest();
         require_once APPLICATION_PATH . '/forms/AdCreate.php';
         $form = new Form_AdCreate();
         $this->view->form = $form;
         $this->view->woeidName = $this->_helper->woeid->name($this->location, $this->lang);
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($request->getPost())) {
                 $formulario = $form->getValues();
                 //create thumbnail if image exists
                 if (!empty($formulario['photo'])) {
                     $photobrut = $formulario['photo'];
                     $formulario['photo'] = $this->_createThumbnail($photobrut, '100', '90');
                 }
                 // Create a filter chain and add filters to title and body against xss, etc
                 $f = new Zend_Filter();
                 $f->addFilter(new Zend_Filter_StripTags());
                 //->addFilter(new Zend_Filter_HtmlEntities());
                 $formulario['title'] = $f->filter($formulario['title']);
                 $formulario['body'] = $f->filter($formulario['body']);
                 //anti HOYGAN to title
                 //dont use strtolower because dont convert utf8 properly . ej: á é ó ...
                 $formulario['title'] = ucfirst(mb_convert_case($formulario['title'], MB_CASE_LOWER, "UTF-8"));
                 //anti hoygan to body
                 $split = explode(". ", $formulario['body']);
                 foreach ($split as $sentence) {
                     $sentencegood = ucfirst(mb_convert_case($sentence, MB_CASE_LOWER, "UTF-8"));
                     $formulario['body'] = str_replace($sentence, $sentencegood, $formulario['body']);
                 }
                 //get the ip of the ad publisher
                 if (getenv(HTTP_X_FORWARDED_FOR)) {
                     $ip = getenv(HTTP_X_FORWARDED_FOR);
                 } else {
                     $ip = getenv(REMOTE_ADDR);
                 }
                 $formulario['ip'] = $ip;
                 //get this ad user owner
                 $formulario['user_owner'] = $auth->getIdentity()->id;
                 //get date created
                 //TODO use the Zend Date object to fetch the user locale time zone
                 $datenow = date("Y-m-d H:i:s", time());
                 $formulario['date_created'] = $datenow;
                 //get woeid to assign to this ad
                 //the location its stored at session location value
                 //(setted by default on bootstrap to Madrid woeid number)
                 $formulario['woeid_code'] = $this->location;
                 $modelAd = new Model_Ad();
                 //chek if this user has 5 or more quieros published
                 if ($formulario['type'] == '2') {
                     $countQuieros = $modelAd->getCountAdWantUser($auth->getIdentity()->id);
                     if ($countQuieros >= 5) {
                         $this->_helper->_flashMessenger->addMessage($this->view->translate('Sorry, you have 5 or more want ads, delete olders!'));
                         $this->_redirect('/' . $this->lang . '/woeid/' . $this->location . '/give');
                     }
                 }
                 //if ok, create the form
                 $modelAd->createAd($formulario);
                 $this->_helper->_flashMessenger->addMessage($this->view->translate('Ad published succesfully!'));
                 $this->_redirect('/' . $this->lang . '/woeid/' . $this->location . '/give');
             }
         }
     }
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:72,代码来源:AdController.php


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