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


PHP Social::model方法代码示例

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


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

示例1: actionEdit

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  */
 public function actionEdit()
 {
     $model = $this->loadUser();
     $social = Social::model()->find("provider='facebook' AND yiiuser=" . Yii::app()->user->id);
     $profile = $model->profile;
     UWprofilepic::handleProfilePic($model, $profile);
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'profile-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (isset($_POST['Profile'])) {
         $model->attributes = $_POST['User'];
         $profile->attributes = $_POST['Profile'];
         if ($model->validate() && $profile->validate()) {
             $model->save();
             $profile->save();
             Yii::app()->user->setFlash('success', 'Your changes have been saved successfully.');
             $this->redirect('/user/profile/edit/');
         } else {
             $profile->validate();
         }
     }
     $this->render('edit', array('model' => $model, 'social' => $social, 'profile' => $profile));
 }
开发者ID:mafiu,项目名称:listapp,代码行数:29,代码来源:ProfileController.php

示例2: testAfterDelete

 public function testAfterDelete()
 {
     $user = User::model()->findByPk('2');
     if (X2_TEST_DEBUG_LEVEL > 1) {
         /**/
         print 'id of user to delete: ';
         /**/
         print $user->id;
     }
     // test calendar permissions deletion
     $this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
     $this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
     // assert that group to user records exist for this user
     $this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) > 0);
     $this->assertTrue($user->delete());
     X2_TEST_DEBUG_LEVEL > 1 && (print 'looking for groupToUser records with userId = ' . $user->id);
     GroupToUser::model()->refresh();
     // assert that group to user records were deleted
     $this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) === 0);
     // test profile deletion
     $this->assertTrue(sizeof(Profile::model()->findAllByAttributes(array('username' => $user->username))) === 0);
     // test social deletion
     $this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('user' => $user->username))) === 0);
     $this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('associationId' => $user->id))) === 0);
     // test event deletion
     $this->assertTrue(sizeof(Events::model()->findAll("user=:username OR (type='feed' AND associationId=" . $user->id . ")", array(':username' => $user->username))) === 0);
     // test calendar permissions deletion
     $this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
     $this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:30,代码来源:UserTest.php

示例3: workOnUser

 public function workOnUser($provider, $provideruser)
 {
     $userClass = Yii::app()->controller->module->userClass;
     $social = Social::model()->find("provider='" . $provider . "' AND provideruser='" . $provideruser . "'");
     if ($social) {
         $user = $userClass::model()->find("id=" . $social->yiiuser);
         return $user;
     } else {
         // no user is connected to that provideruser,
         $social = new Social();
         // a new relation will be needed
         $social->provider = $provider;
         // what provider
         $social->provideruser = $provideruser;
         // the unique user
         // if a yii-user is already logged in add the provideruser to that account
         if (!Yii::app()->user->isGuest) {
             $social->yiiuser = Yii::app()->user->id;
             $user = $userClass::model()->findByPk(Yii::app()->user->id);
         } else {
             // we want to create a new $userClass
             $user = new $userClass();
             $user->username = $provideruser;
             if ($user->save()) {
                 //we get an user id
                 $social->yiiuser = $user->id;
             }
         }
         if ($social->save()) {
             return $user;
         }
     }
 }
开发者ID:mafiu,项目名称:listapp,代码行数:33,代码来源:Yiiauth.php

示例4: loadModel

 public function loadModel($id)
 {
     $model = Social::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:8,代码来源:SocialController.php

示例5: run

 public function run()
 {
     $content = Social::model()->findByAttributes(array('type' => 'motd'));
     if (isset($content)) {
         $content = CHtml::encode($content->data);
     } else {
         $content = Yii::t('app', 'Please enter a message of the day!');
     }
     $this->render('messageBox', array('content' => $content));
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:10,代码来源:MessageBox.php

示例6: run

 public function run()
 {
     $content = Social::model()->findAllByAttributes(array('type' => 'note', 'associationId' => Yii::app()->user->getId()), array('order' => 'timestamp DESC'));
     if (count($content) > 0) {
         $data = $content;
     } else {
         $soc = new Social();
         $soc->data = Yii::t('app', "Feel free to enter some notes!");
         $data = array($soc);
     }
     $this->render('noteBox', array('data' => $data));
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:12,代码来源:NoteBox.php

示例7: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id = null, $userid = null)
 {
     if ($id) {
         $model = Social::model()->findByPk($id);
     }
     if ($userid) {
         $model = Social::model()->find("yiiuser = '" . $userid . "'");
     }
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:mafiu,项目名称:listapp,代码行数:18,代码来源:SocialController.php

示例8: workOnUser

 public function workOnUser($provider, $provideruser, $profile)
 {
     // $provideruser has profile details from provider
     $social = Social::model()->find("provider='" . $provider . "' AND provideruser='" . $provideruser . "'");
     if ($social) {
         $user = User::model()->find("id=" . $social->yiiuser);
         // $user['yiiuser'] has app user id
         return $user;
     } else {
         // no user is connected to that provideruser,
         $social = new Social();
         // a new relation will be needed
         $social->provider = $provider;
         // what provider
         $social->provideruser = $provideruser;
         // the unique user
         // if a yii-user is already logged in add the provideruser to that account
         if (!Yii::app()->user->isGuest) {
             $social->yiiuser = Yii::app()->user->id;
             $user = User::model()->findByPk(Yii::app()->user->id);
             lg('Existing user' . $social->yiiuser);
             lg('Existing user email' . $user->email);
             // capture profile info
             $user_profile = Yii::app()->getModule('user')->user($social->yiiuser)->profile;
             $user->model()->syncProfileViaHybridAuth($user_profile, $profile);
         } else {
             lg('Facebook email: ' . $profile->email);
             $user = User::model()->findByAttributes(array('email' => $profile->email));
             if (!is_null($user)) {
                 // to do - create way to associate facebook account
                 Yii::app()->user->setFlash('email_problem', 'Your email already exists. Please log in to your account with your email.');
                 Yii::app()->user->setReturnUrl('/user/profile/edit');
                 $this->redirect('/user/login');
             }
             if ($profile->email == '') {
                 lg('Hybrid: No email, report error & redirect user');
                 Yii::app()->user->setFlash('email_problem', 'We require your email for registration.');
                 $this->redirect('/user/registration');
             }
             // we want to create a new user
             // take new profile info and register user
             lg('New user');
             $user_id = User::model()->registerViaHybridAuth($profile);
             if ($user_id !== false) {
                 $user = User::model()->findByPk($user_id);
                 $social->yiiuser = $user->id;
             }
             // to do - if no new user_id
             // then social id is 0 and future log in will fail
             // return with new user id
         }
         if ($social->save()) {
             return $user;
         }
     }
 }
开发者ID:mafiu,项目名称:listapp,代码行数:56,代码来源:DefaultController.php

示例9: afterDelete

 public function afterDelete()
 {
     // delete related social records (e.g. notes)
     $social = Social::model()->findAllByAttributes(array('user' => $this->username));
     foreach ($social as $socialItem) {
         $socialItem->delete();
     }
     $social = Social::model()->findAllByAttributes(array('associationId' => $this->id));
     foreach ($social as $socialItem) {
         $socialItem->delete();
     }
     X2CalendarPermissions::model()->deleteAllByAttributes(array(), 'user_id=:userId OR other_user_id=:userId', array(':userId' => $this->id));
     // delete profile
     $prof = Profile::model()->findByAttributes(array('username' => $this->username));
     if ($prof) {
         $prof->delete();
     }
     // delete associated events
     Yii::app()->db->createCommand()->delete('x2_events', "user=:username OR (type='feed' AND associationId=" . $this->id . ")", array(':username' => $this->username));
     // Delete associated group to user records
     GroupToUser::model()->deleteAll(array('condition' => 'userId=' . $this->id));
     parent::afterDelete();
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:23,代码来源:User.php

示例10: actionAddComment

	public function actionAddComment(){
		$soc=new Social;
			if(isset($_GET['comment'])){
				$soc->data=$_GET['comment'];
				$id=$_GET['id'];
				$model=Social::model()->findByPk($id);
				$soc->user=Yii::app()->user->getName();
				$soc->type='comment';
				$soc->timestamp=time();
				$soc->associationId=$id;
				$model->lastUpdated=time();
				if($soc->save() && $model->save()){

				}
			}
			if(isset($_GET['redirect'])) {
				if($_GET['redirect']=="view")
					$this->redirect(array('view','id'=>$model->associationId));
				if($_GET['redirect']=="index")
					$this->redirect(array('index'));
			} else
				$this->redirect(array('index'));
	}
开发者ID:ruchida,项目名称:X2Engine,代码行数:23,代码来源:ProfileController.php

示例11: array

 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************************************/
$authorRecord = User::model()->findByAttributes(array('username' => $data->user));
$author = $authorRecord->firstName . ' ' . $authorRecord->lastName;
?>
<div class="view">
	<div class="deleteButton">
		<?php 
$parent = Social::model()->findByPk($data->associationId);
if ($data->user == Yii::app()->user->getName() || $parent->associationId == Yii::app()->user->getId()) {
    echo CHtml::link('[x]', array('deletePost', 'id' => $data->id, 'redirect' => Yii::app()->controller->action->id));
}
//,array('class'=>'x2-button')
?>
	</div>
	<?php 
echo CHtml::link($author, array('profile/view', 'id' => $authorRecord->id));
?>
 <span class="comment-age"><?php 
echo x2base::timestampAge(date("Y-m-d H:i:s", $data->timestamp));
?>
</span><br />
	<?php 
echo $this->convertUrls(CHtml::encode($data->data));
开发者ID:netconstructor,项目名称:X2Engine,代码行数:31,代码来源:_view.php

示例12: actionDeleteMessage

	public function actionDeleteMessage($id,$url){
		$note=Social::model()->findByPk($id);
		$note->delete();
		$this->redirect($url);
	} 
开发者ID:ruchida,项目名称:X2Engine,代码行数:5,代码来源:SiteController.php

示例13: actionAddComment

 public function actionAddComment()
 {
     $soc = new Social();
     if (isset($_GET['comment'])) {
         $soc->data = $_GET['comment'];
         $id = $_GET['id'];
         $model = Social::model()->findByPk($id);
         $soc->user = Yii::app()->user->getName();
         $soc->type = 'comment';
         $soc->timestamp = time();
         $soc->associationId = $id;
         $model->lastUpdated = time();
         if ($soc->save() && $model->save()) {
             $notif = new Notifications();
             $prof = CActiveRecord::model('ProfileChild')->findByAttributes(array('username' => $soc->user));
             $notif->text = "{$prof->fullName} added a comment to a post.";
             $notif->record = "profile:{$model->associationId}";
             $notif->viewed = 0;
             $notif->createDate = time();
             $subject = CActiveRecord::model('ProfileChild')->findByAttributes(array('username' => $model->user));
             $notif->user = $subject->username;
             if ($notif->user != Yii::app()->user->getName()) {
                 $notif->save();
             }
             $notif = new Notifications();
             $prof = CActiveRecord::model('ProfileChild')->findByAttributes(array('username' => $soc->user));
             $subject = CActiveRecord::model('ProfileChild')->findByPk($model->associationId);
             $notif->text = "{$prof->fullName} added a comment to a post.";
             $notif->record = "profile:{$model->associationId}";
             $notif->viewed = 0;
             $notif->createDate = time();
             $notif->user = $subject->username;
             if ($notif->user != Yii::app()->user->getName()) {
                 $notif->save();
             }
         }
     }
     if (isset($_GET['redirect'])) {
         if ($_GET['redirect'] == "view") {
             $this->redirect(array('view', 'id' => $model->associationId));
         }
         if ($_GET['redirect'] == "index") {
             $this->redirect(array('index'));
         }
     } else {
         $this->redirect(array('index'));
     }
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:48,代码来源:ProfileController.php

示例14: foreach

<?php

$this->layout = "ajax";
?>
	<h4> By connecting a social provider to your account you can use it to login<h4>
<?php 
$socials = Social::model()->findAll('yiiuser=' . Yii::app()->user->id);
if ($socials) {
    echo "<h5>You have currently connected your account with:</h5>";
    foreach ($socials as $social) {
        echo CHtml::Link('<i class="icon-remove icon-white"></i>Delete', array(''), array('class' => 'btn btn-mini btn-danger social_delete', 'id' => $social->id));
        echo '* <b>' . $social->provider . '</b>';
        echo '<div id="delete_social_' . $social->id . '" style="display:none"></div><br/>';
    }
}
$this->widget('LoginWidget');
//displays the possible providers
?>
<script type="text/javascript">

		$(".social_delete").click(function(){
				deletesocial($(this).attr('id'));
			});

		function deletesocial( id ) {
			url = '/yiiauth/social/delete';
			jQuery.getJSON(url, {id: id}, function(data) {
				if (data.status == 'success')
					{
						$('#delete_social_'+id).html(data.div);
						$('#delete_social_'+id).fadeIn('slow');	
开发者ID:mafiu,项目名称:listapp,代码行数:31,代码来源:index.php


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