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


PHP ActivityModel::store方法代码示例

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


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

示例1: plgAfterSave

 function plgAfterSave(&$model)
 {
     $data = array();
     App::import('Model', 'activity', 'jreviews');
     App::import('Helper', 'routes', 'jreviews');
     $Activity = new ActivityModel();
     $Routes = RegisterClass::getInstance('RoutesHelper');
     $data['Activity']['user_id'] = $this->c->_user->id;
     $data['Activity']['email'] = $this->c->_user->email;
     $data['Activity']['created'] = gmdate('Y-m-d H:i:s');
     $data['Activity']['ipaddress'] = $this->c->ipaddress;
     $data['Activity']['activity_new'] = isset($model->data['insertid']) ? 1 : 0;
     switch ($this->activityModel->name) {
         case 'Claim':
             //Get the full listing info to create proper permalinks
             $listing = $this->c->Listing->findRow(array('conditions' => array('Listing.id = ' . (int) $model->data['Claim']['listing_id'])), array());
             $permalink = $Routes->content('', $listing, array('return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $data['Activity']['activity_type'] = 'claim';
             $data['Activity']['listing_id'] = $model->data['Claim']['listing_id'];
             $data['Activity']['extension'] = 'com_content';
             $data['Activity']['activity_new'] = 1;
             $data['Activity']['permalink'] = $permalink;
             $Activity->store($data);
             break;
         case 'Listing':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Listing']['created_by']) break;
             //Get the full listing info to create proper permalinks
             $listing = $this->c->Listing->findRow(array('conditions' => array('Listing.id = ' . (int) $model->data['Listing']['id'])));
             $permalink = $Routes->content('', $listing, array('return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $data['Activity']['activity_type'] = 'listing';
             $data['Activity']['email'] = Sanitize::getString($model->data, 'email');
             $data['Activity']['listing_id'] = $model->data['Listing']['id'];
             $data['Activity']['extension'] = 'com_content';
             $data['Activity']['permalink'] = $permalink;
             $Activity->store($data);
             break;
         case 'Review':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Review']['userid']) break;
             $data['Activity']['activity_type'] = 'review';
             $data['Activity']['listing_id'] = $model->data['Review']['pid'];
             $data['Activity']['review_id'] = $model->data['Review']['id'];
             $data['Activity']['extension'] = $model->data['Review']['mode'];
             $data['Activity']['value'] = round(Sanitize::getVar($model->data, 'average_rating'), 0);
             $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
             $Activity->store($data);
             break;
         case 'OwnerReply':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Listing']['created_by']) break;
             $data['Activity']['activity_type'] = 'owner_reply';
             $data['Activity']['listing_id'] = $model->data['Listing']['listing_id'];
             $data['Activity']['review_id'] = $model->data['OwnerReply']['id'];
             $data['Activity']['extension'] = $model->data['Listing']['extension'];
             // Editing not yet implemented so all replies are new
             $data['Activity']['activity_new'] = 1;
             $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
             $Activity->store($data);
             break;
         case 'Discussion':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Discussion']['user_id']) break;
             // Get listing id and extension
             $this->c->_db->setQuery("\n                    SELECT \n                        Review.pid AS listing_id, Review.`mode` AS extension\n                    FROM \n                        #__jreviews_comments AS Review\n                    WHERE \n                        Review.id = " . $model->data['Discussion']['review_id']);
             // Get listing owner id and check if it matches the current user
             if ($listing = current($this->c->_db->loadAssocList())) {
                 $data['Activity']['activity_type'] = 'review_discussion';
                 $data['Activity']['listing_id'] = $listing['listing_id'];
                 $data['Activity']['review_id'] = $model->data['Discussion']['review_id'];
                 $data['Activity']['post_id'] = $model->data['Discussion']['discussion_id'];
                 $data['Activity']['extension'] = $listing['extension'];
                 $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
                 $Activity->store($data);
             }
             break;
         case 'Report':
             $data['Activity']['activity_type'] = $model->data['Report']['post_id'] ? 'discussion_report' : 'review_report';
             $data['Activity']['listing_id'] = $model->data['Report']['listing_id'];
             $data['Activity']['review_id'] = $model->data['Report']['review_id'];
             $data['Activity']['extension'] = $model->data['Report']['extension'];
             // Editing not yet implemented so all replies are new
             $data['Activity']['activity_new'] = 1;
             $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
             $Activity->store($data);
             break;
         case 'Vote':
             // Get listing id and extension
             $this->c->_db->setQuery("\n                    SELECT \n                        Review.pid AS listing_id, Review.`mode` AS extension\n                    FROM \n                        #__jreviews_comments AS Review\n                    WHERE \n                        Review.id = " . $model->data['Vote']['review_id']);
             // Get listing owner id and check if it matches the current user
             if ($listing = current($this->c->_db->loadAssocList())) {
                 $data['Activity']['activity_type'] = 'helpful_vote';
                 $data['Activity']['listing_id'] = $listing['listing_id'];
                 $data['Activity']['review_id'] = $model->data['Vote']['review_id'];
                 $data['Activity']['helpful_vote_id'] = $model->data['Vote']['vote_id'];
                 $data['Activity']['extension'] = $listing['extension'];
                 $data['Activity']['value'] = $model->data['Vote']['vote_yes'];
                 $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:activities.php


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